array of identical histos read from a file

From: Chiara Zampolli <Chiara.Zampolli_at_bo.infn.it>
Date: Sat, 30 Sep 2006 20:53:36 +0200


Dear rooters,

    sorry for the long (and I hope not too messy) mail, but I have some problems working with the HEAD ROOT..

    In order to determine the size of a file containing an array of ~160000 histos (i am studying 2 different cases: TH1C and TH1F) which will be filled during real data taking, I am trying to make it easier simulating them starting from a unique histo I have stored in a file (for the time being, it is not important whether the histograms are all the same). You find the sample histos in the attached files. For this reason, I have tried to follow different ways:

  1. reading the sample histo from the file where it is stored, and copying it 160000, adding each time the histo to the array:

void writing(){
static const Int_t size =160000;
TFile *fileout = new TFile("outTH1C.root","RECREATE"); //output file TFile file("inTH1C.root","READ"); //input file const TH1C *hsample = (TH1C*)file.Get("DeltaTAll90"); // sample histo fileout->cd();
TObjArray harray;
harray.SetName("array");
for (Int_t i=0;i<size;i++){

   TH1C *hciccio = new TH1C(*hsample);
   harray.Add(hciccio);
   delete hciccio;
   hciccio =0;
}
  cout << "out of the loop, entries in the array = " << harray.GetEntries() << endl; // checking printings   harray.Write("array",TObject::kSingleKey);   cout << "written array = " << &harray << endl; //checking printings   fileout->Close();
}

This macro ends with a "*** Break *** segmentation violation...." error, at the point where the array has to be written, but i don't know why...

2) without deleting each time the hciccios, then the macros goes on becoming slower and slower each histo is added (~40 mins to fill the whole array!!!), but then it crashes as before... Again, why??

3) creating an array of histos, instead of a single hciccio:

TH1C *hciccio[size];
...
for (Int_t i=0;i<size;i++){

   hciccio[i]=new TH1C(*hsample);
....

it crashes again, becoming also this time slower and slower.

4) In case I define only one copy of my sample, and then add it to the array 160000, the output file is too smal, i.e. ~8 KB for TH1F and a bit less for TH1C.

5) Since too many problems in trying to use a sample histo occurred, i have tried creating an array of 160000 DIFFERENT histograms, with 4000 entries each. This time, it works. BUT!!!! only if the histograms are TH1F, when I try with TH1C, at the point of writing the array into the file, it crashes again.. Why?? What's the difference between the two???

I think that one of the main problem could be that the file becomes too big when using a sample histogram (apart from case 4), which is quite "weird" for my inexperienced ears, since when creating new ones it works and has a reasonable size (~1.6 MB) - obviously only in the case of TH1F, in that of TH1C, I don't know, since it does not work...

Could you help me in solving this problem? It's very lickely that I am not following the correct way, but I have no ideas...

Thank you a lot.
Best Regards,

      Chiara

Received on Sat Sep 30 2006 - 20:52:14 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:01 MET