]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliCollisionNormalization.cxx
Added getters and members for some event counters (A. Marin)
[u/mrichter/AliRoot.git] / ANALYSIS / AliCollisionNormalization.cxx
index 252187aeffc85d8434165e47dc8b20bcf6d413e1..552b45091bcc4025ec9bebb622f32d836517be47 100644 (file)
@@ -36,7 +36,15 @@ AliCollisionNormalization::AliCollisionNormalization() :
   fHistVzData       (0),
   fHistProcTypes    (0),
   fHistStatBin0     (0),
-  fHistStat     (0)
+  fHistStat     (0),
+  fInputEvents(0),   
+  fPhysSelEvents(0),
+  fBgEvents(0),      
+  fAllEvents(0),     
+  fAllEventsZRange(0),
+  fAllEventsZRangeMult1(0), 
+  fAllEventsInBin0ZRange(0),
+  fTrigEffBin0(0)  
 {
 
   // ctor
@@ -68,8 +76,15 @@ AliCollisionNormalization::AliCollisionNormalization(Int_t nbinz, Float_t minz,
   fHistVzData       (0),
   fHistProcTypes    (0),
   fHistStatBin0     (0),
-  fHistStat     (0)
-
+  fHistStat     (0),
+  fInputEvents(0),   
+  fPhysSelEvents(0),
+  fBgEvents(0),      
+  fAllEvents(0),     
+  fAllEventsZRange(0),
+  fAllEventsZRangeMult1(0), 
+  fAllEventsInBin0ZRange(0),
+  fTrigEffBin0(0)  
 {
 
   // ctor, allows setting binning
@@ -101,7 +116,15 @@ AliCollisionNormalization::AliCollisionNormalization(const char * dataFile, cons
   fHistVzData       (0),
   fHistProcTypes    (0),
   fHistStatBin0     (0),
-  fHistStat     (0)
+  fHistStat     (0),
+  fInputEvents(0),   
+  fPhysSelEvents(0),
+  fBgEvents(0),      
+  fAllEvents(0),     
+  fAllEventsZRange(0),
+  fAllEventsZRangeMult1(0), 
+  fAllEventsInBin0ZRange(0),
+  fTrigEffBin0(0)  
 
 {
 
@@ -281,39 +304,59 @@ Double_t AliCollisionNormalization::ComputeNint() {
   // selection: this allows to crosscheck that all runs were
   // successfully processed (useful if running on grid: you may have a
   // crash without noticing it).
+
+  fInputEvents = fHistStat->GetBinContent(1,1);
+  fPhysSelEvents = fHistStat->GetBinContent( fHistStat->GetNbinsX(),1);
+
   AliInfo(Form("Input Events (No cuts: %d, After Phys. Sel.:%d)",
-              Int_t(fHistStat->GetBinContent(1,1)),
-              Int_t(fHistStat->GetBinContent(fHistStat->GetNbinsX(),1)))); // Fixme: will this change with a different trigger scheme?
+              Int_t(fInputEvents),
+              Int_t(fPhysSelEvents))); // Fixme: will this change with a different trigger scheme?
 
   // Get or compute BG. This assumes the CINT1B suite
   Double_t triggeredEventsWith0MultWithBG = fHistVzData->Integral(0, fHistVzData->GetNbinsX()+1,1, 1);
-  Double_t bg = 0; // This will include beam gas + accidentals
+  //  Double_t bg = 0; // This will include beam gas + accidentals
   if (fHistStatBin0->GetNbinsY() > 4) { // FIXME: we need a better criterion to decide...
     AliInfo("Using BG computed by Physics Selection");
-    bg = fHistStatBin0->GetBinContent(fHistStatBin0->GetNbinsX(),AliPhysicsSelection::kStatRowBG);
-    bg += fHistStatBin0->GetBinContent(fHistStatBin0->GetNbinsX(),AliPhysicsSelection::kStatRowAcc);
+    // WARNING
+    // CHECK IF THE COMPUTATION OF BG OFFSET IS STILL OK, IN CASE OF CHANGES TO THE PHYSICS SELECTION
+    Int_t bgOffset = 0; 
+    Int_t nbiny = fHistStatBin0->GetNbinsY();
+    for(Int_t ibiny =1; ibiny <= nbiny; ibiny++){
+      bgOffset++;
+      printf("%d, %s\n", bgOffset, fHistStatBin0->GetYaxis()->GetBinLabel(ibiny) );
+      
+      if(!strncmp("All B", fHistStatBin0->GetYaxis()->GetBinLabel(ibiny),5)) break;
+      if((ibiny+1)==nbiny) AliFatal("Cannot compute bg offset");
+    }
+    
+    if(fVerbose > 2) AliInfo(Form("BG Offset: %d",bgOffset));
+    
+
+    fBgEvents = fHistStatBin0->GetBinContent(fHistStatBin0->GetNbinsX(), bgOffset+AliPhysicsSelection::kStatRowBG);
+    fBgEvents += fHistStatBin0->GetBinContent(fHistStatBin0->GetNbinsX(),bgOffset+AliPhysicsSelection::kStatRowAcc);
     Int_t cint1B = (Int_t) fHistStatBin0->GetBinContent(fHistStatBin0->GetNbinsX(),1); 
     if (cint1B != Int_t(triggeredEventsWith0MultWithBG)) {
       AliWarning(Form("Events in bin0 from physics selection and local counter not consistent: %d - %d", cint1B, Int_t(triggeredEventsWith0MultWithBG)));
     }
   } else {
     AliInfo("Computing BG using CINT1A/B/C/E, ignoring intensities");
+    AliError("This will only work for early runs!!! USE BG FROM PHYSICS SELECTION INSTEAD");
     Int_t icol = fHistStatBin0->GetNbinsX();
     Int_t cint1B = (Int_t) fHistStatBin0->GetBinContent(icol,1);       
     Int_t cint1A = (Int_t) fHistStatBin0->GetBinContent(icol,2);       
     Int_t cint1C = (Int_t) fHistStatBin0->GetBinContent(icol,3);       
     Int_t cint1E = (Int_t) fHistStatBin0->GetBinContent(icol,4);      
-    bg   = cint1A + cint1C-2*cint1E ;
+    fBgEvents   = cint1A + cint1C-2*cint1E ; // FIXME: to be changed to take into account ratios of events
     if (cint1B != triggeredEventsWith0MultWithBG) {
       AliWarning(Form("Events in bin0 from physics selection and local counter not consistent: %d - %d", cint1B, (Int_t)triggeredEventsWith0MultWithBG));
     }
   }
 
-  Double_t triggeredEventsWith0Mult = triggeredEventsWith0MultWithBG - bg
+  Double_t triggeredEventsWith0Mult = triggeredEventsWith0MultWithBG - fBgEvents
   if(fVerbose > 0) AliInfo(Form("Measured events with vertex: %d",allEventsWithVertex));
   Double_t bin0 = fHistVzData->Integral(0, fHistVzData->GetNbinsX()+1,
                                        1, 1);
-  if(fVerbose > 0) AliInfo(Form("Zero Bin, Meas: %2.2f, BG: %2.2f, Meas - BG: %2.2f", bin0, bg, triggeredEventsWith0Mult)); 
+  if(fVerbose > 0) AliInfo(Form("Zero Bin, Meas: %2.2f, BG: %2.2f, Meas - BG: %2.2f", bin0, fBgEvents, triggeredEventsWith0Mult)); 
 
   // This pointers are here so that I use the same names used in Jan Fiete's code (allows for faster/easier comparison)
 
@@ -337,7 +380,9 @@ Double_t AliCollisionNormalization::ComputeNint() {
       Double_t alpha = (Double_t) hVzData->GetBinContent(i) / allEventsWithVertex;
       Double_t events = alpha * triggeredEventsWith0Mult;
       
-      if (histVzMCRec->GetBinContent(i,1) == 0)
+      // if (histVzMCRec->GetBinContent(i,1) == 0)
+      //   continue;
+      if (!eTrigVtx_projx->GetBinContent(i) || !eTrig->Integral(0, eTrig->GetNbinsX()+1, 1, 1))
         continue;
 
       Double_t fZ = eTrigVtx_projx->Integral(0, eTrigVtx_projx->GetNbinsX()+1) / eTrigVtx_projx->GetBinContent(i) *
@@ -350,36 +395,42 @@ Double_t AliCollisionNormalization::ComputeNint() {
       events *= correction;
 
       if (fVerbose > 1) Printf("  Bin %d, alpha is %.2f%%, fZ is %.3f, number of events with 0 mult.: %.2f (MC comparison: %.2f)", i, alpha * 100., fZ, events, 
-                              histVzMCRec->GetBinContent(i,1));
+                              histVzMCTrg->GetBinContent(i,1));
       correctedEvents->SetBinContent(i, 1, events);
     }
 
   
   
   // Integrate correctedEvents over full z range
-  Double_t allEvents       = correctedEvents->Integral(0, correctedEvents->GetNbinsX()+1,0, correctedEvents->GetNbinsY()+1);
+  fAllEvents       = correctedEvents->Integral(0, correctedEvents->GetNbinsX()+1,0, correctedEvents->GetNbinsY()+1);
   // Integrate correctedEvents over needed z range
-  Double_t allEventsZrange = correctedEvents->Integral(correctedEvents->GetXaxis()->FindBin(-fZRange), correctedEvents->GetXaxis()->FindBin(fZRange),
+  fAllEventsZRange = correctedEvents->Integral(correctedEvents->GetXaxis()->FindBin(-fZRange), correctedEvents->GetXaxis()->FindBin(fZRange),
                                                       0, correctedEvents->GetNbinsY()+1);
-  
+
+  fAllEventsZRangeMult1 = correctedEvents->Integral(correctedEvents->GetXaxis()->FindBin(-fZRange), correctedEvents->GetXaxis()->FindBin(fZRange), 
+                                                   2,correctedEvents->GetNbinsX()+1);
+
+  fAllEventsInBin0ZRange = correctedEvents->Integral(correctedEvents->GetXaxis()->FindBin(-fZRange), correctedEvents->GetXaxis()->FindBin(fZRange),1,1);
+
   if(fVerbose > 1) AliInfo(Form("Results in |Vz| < %3.3f",fZRange));
   if(fVerbose > 1) AliInfo(Form(" Events in Bin0: %2.2f, With > 1 track: %2.2f, All corrected: %2.2f",
-                               correctedEvents->Integral(correctedEvents->GetXaxis()->FindBin(-fZRange), correctedEvents->GetXaxis()->FindBin(fZRange),1,1),
-                               correctedEvents->Integral(correctedEvents->GetXaxis()->FindBin(-fZRange), correctedEvents->GetXaxis()->FindBin(fZRange), 
-                                                         2,correctedEvents->GetNbinsX()+1),
-                               allEventsZrange));
+                               fAllEventsInBin0ZRange,
+                               fAllEventsZRangeMult1,
+                               fAllEventsZRange));
+
   if(fVerbose > 1) {    
-    Int_t nbin = histVzMCRec->GetNbinsX();
-    AliInfo(Form("Efficiency in the zero bin: %3.3f", histVzMCRec->Integral(0,nbin+1,1,1)/histVzMCGen->Integral(0,nbin+1,1,1) ));
+    Int_t nbin = histVzMCTrg->GetNbinsX();
+    fTrigEffBin0 =  histVzMCTrg->Integral(0,nbin+1,1,1)/histVzMCGen->Integral(0,nbin+1,1,1);
+    AliInfo(Form("Trigger Efficiency in the zero bin: %3.3f", fTrigEffBin0 ));
   }
   
 
-  AliInfo(Form("Number of collisions in full phase space: %2.2f", allEvents));
+  AliInfo(Form("Number of collisions in full phase space: %2.2f", fAllEvents));
 //   effVtxTrig->Draw();
 //   new TCanvas();
 //   correctedEvents->Draw(); // FIXME: debug
 
-  return allEvents;
+  return fAllEvents;
 }
 
 Long64_t AliCollisionNormalization::Merge(TCollection* list)