]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
sometimes histograms are empty, don't crash
authormkrzewic <mikolaj.krzewicki@cern.ch>
Thu, 6 Nov 2014 19:11:46 +0000 (20:11 +0100)
committermkrzewic <mikolaj.krzewicki@cern.ch>
Thu, 6 Nov 2014 19:11:46 +0000 (20:11 +0100)
PWGPP/ZDC/trending/MakeTrendingZDCQA.C

index 56cf0fa9ff73c852aa153bd8abfcdb15051c0fed..bef025d96f2c88f398c7fd22ce0314a81c4c9a56 100755 (executable)
@@ -111,12 +111,24 @@ Int_t MakeTrendingZDCQA(TString qafilename,               //full path of the QA
   TH1F    *fhTDCZNAcorr      = (TH1F*)generalList->FindObject("fhTDCZNAcorr");   //! ZNA corrected TDC
   TH1F    *fhTDCZNCcorr      = (TH1F*)generalList->FindObject("fhTDCZNCcorr");   //! ZNC corrected TDC
   
-  Double_t ZNC_mean = fhZNCpmc->GetMean()/TMath::Sqrt(fhZNCpmc->GetEntries());
-  Double_t ZNA_mean = fhZNApmc->GetMean()/TMath::Sqrt(fhZNApmc->GetEntries());
-  Double_t ZPC_mean = fhZPCpmc->GetMean()/TMath::Sqrt(fhZPCpmc->GetEntries());
-  Double_t ZPA_mean = fhZPApmc->GetMean()/TMath::Sqrt(fhZPApmc->GetEntries());  
-  Double_t ZEM1_mean = fhZEM1Spectrum->GetMean()/TMath::Sqrt(fhZEM1Spectrum->GetEntries());
-  Double_t ZEM2_mean = fhZEM2Spectrum->GetMean()/TMath::Sqrt(fhZEM2Spectrum->GetEntries());  
+  Int_t fhZNCpmcEntries = fhZNCpmc->GetEntries();
+  Int_t fhZNApmcEntries = fhZNApmc->GetEntries();
+  Int_t fhZPCpmcEntries = fhZPCpmc->GetEntries();
+  Int_t fhZPApmcEntries = fhZPApmc->GetEntries();
+  Double_t ZNC_mean = 0.0;
+  Double_t ZNA_mean = 0.0;
+  Double_t ZPC_mean = 0.0;
+  Double_t ZPA_mean = 0.0;  
+  if (fhZNCpmcEntries>0) ZNC_mean = fhZNCpmc->GetMean()/TMath::Sqrt(fhZNCpmcEntries);
+  if (fhZNApmcEntries>0) ZNA_mean = fhZNApmc->GetMean()/TMath::Sqrt(fhZNApmcEntries);
+  if (fhZPCpmcEntries>0) ZPC_mean = fhZPCpmc->GetMean()/TMath::Sqrt(fhZPCpmcEntries);
+  if (fhZPApmcEntries>0) ZPA_mean = fhZPApmc->GetMean()/TMath::Sqrt(fhZPApmcEntries);  
+  Int_t fhZEM1SpectrumEntries = fhZEM1Spectrum->GetEntries();
+  Int_t fhZEM2SpectrumEntries = fhZEM2Spectrum->GetEntries();
+  Double_t ZEM1_mean = 0.;
+  Double_t ZEM2_mean = 0.;
+  if (fhZEM1SpectrumEntries>0) ZEM1_mean = fhZEM1Spectrum->GetMean()/TMath::Sqrt(fhZEM1SpectrumEntries);
+  if (fhZEM2SpectrumEntries>0) ZEM2_mean = fhZEM2Spectrum->GetMean()/TMath::Sqrt(fhZEM2SpectrumEntries);  
   Double_t ZNC_XCent = fhZNCCentroid->GetMean(1);
   Double_t ZNC_YCent = fhZNCCentroid->GetMean(2);    
   Double_t ZNA_XCent = fhZNACentroid->GetMean(1);
@@ -185,4 +197,4 @@ Int_t MakeTrendingZDCQA(TString qafilename,               //full path of the QA
   ttree->Write();
   trendFile->Close();
 
-}
\ No newline at end of file
+}