+// function to print statistics used to calibrate the various detectors
+
+void printCalibStat(Int_t run, const char * fname, TTreeSRedirector * pcstream){
+
+ //
+ // Dump the statistical information about all histograms in the calibration files
+ // into the statistical tree, print on the screen (log files) as well
+ //
+ //
+ // 1. Default dump for all histograms
+ // Information to dump:
+ // stat =Entries, Mean, MeanError, RMS, MaxBin
+ // Branch naming convention:
+ // <detName>_<hisName><statName>
+ //
+ // 2. Detector statistical information - to be implemented by expert
+ // - First version implemented by MI
+ //
+ //
+
+ TFile *fin = TFile::Open(fname);
+ if (!fin) return;
+ const Double_t kMaxHis=10000;
+
+ TList * keyList = fin->GetListOfKeys();
+ Int_t nkeys=keyList->GetEntries();
+ Double_t *hisEntries = new Double_t[kMaxHis];
+ Double_t *hisMean = new Double_t[kMaxHis];
+ Double_t *hisMeanError = new Double_t[kMaxHis];
+ Double_t *hisRMS = new Double_t[kMaxHis];
+ Double_t *hisMaxBin = new Double_t[kMaxHis];
+ Int_t counter=0;
+
+ if (pcstream) (*pcstream)<<"calibStatAll"<<"run="<<run;
+ for (Int_t ikey=0; ikey<nkeys; ikey++){
+ TObject * object = fin->Get(keyList->At(ikey)->GetName());
+ if (!object) continue;
+ if (object->InheritsFrom("TCollection")==0) continue;
+ TSeqCollection *collection = (TSeqCollection*)object;
+ Int_t nentries= collection->GetEntries();
+ for (Int_t ihis=0; ihis<nentries; ihis++){
+ TObject * ohis = collection->At(ihis);
+ if (!ohis) continue;
+ if (ohis->InheritsFrom("TH1")==0) continue;
+ TH1* phis = (TH1*)ohis;
+ hisEntries[counter]=phis->GetEntries();
+ Int_t idim=1;
+ if (ohis->InheritsFrom("TH2")) idim=2;
+ if (ohis->InheritsFrom("TH3")) idim=3;
+ hisMean[counter]=phis->GetMean(idim);
+ hisMeanError[counter]=phis->GetMeanError(idim);
+ hisRMS[counter]=phis->GetRMS(idim);
+ hisMaxBin[counter]=phis->GetBinCenter(phis->GetMaximumBin());
+ if (pcstream) (*pcstream)<<"calibStatAll"<<
+ Form("%s_%sEntries=",keyList->At(ikey)->GetName(), phis->GetName())<<hisEntries[counter]<<
+ Form("%s_%sMean=",keyList->At(ikey)->GetName(), phis->GetName())<<hisMean[counter]<<
+ Form("%s_%sMeanError=",keyList->At(ikey)->GetName(), phis->GetName())<<hisMeanError[counter]<<
+ Form("%s_%sRMS=",keyList->At(ikey)->GetName(), phis->GetName())<<hisRMS[counter]<<
+ Form("%s_%sMaxBin=",keyList->At(ikey)->GetName(), phis->GetName())<<hisMaxBin[counter];
+ //printf("Histo:\t%s_%s\t%f\t%d\n",keyList->At(ikey)->GetName(), phis->GetName(), hisEntries[counter],idim);
+ counter++;
+ }
+ delete object;
+ }
+
+ //
+ // Expert dump example (MI first iteration):
+ //
+ // 0.) TOF dump
+ //
+
+ Int_t tofEvents=0;
+ Int_t tofTracks=0;
+ TList * TOFCalib = (TList*)fin->Get("TOFHistos");
+ if (TOFCalib) {
+ TH1 *histoEvents = (TH1*)TOFCalib->FindObject("hHistoVertexTimestamp");
+ TH1 *histoTracks = (TH1*)TOFCalib->FindObject("hHistoDeltatTimestamp");
+ if (histoEvents && histoTracks){
+ tofEvents = TMath::Nint(histoEvents->GetEntries());
+ tofTracks = TMath::Nint(histoTracks->GetEntries());
+ }
+ delete TOFCalib;
+ }
+ printf("Monalisa TOFevents\t%d\n",tofEvents);
+ if (pcstream) (*pcstream)<<"calibStatAll"<<"TOFevents="<<tofEvents;
+ printf("Monalisa TOFtracks\t%d\n",tofTracks);
+ if (pcstream) (*pcstream)<<"calibStatAll"<<"TOFtracks="<<tofTracks;