Adding the VZERO equalization map
authorpchrista <pchrista@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 Nov 2013 22:11:00 +0000 (22:11 +0000)
committerpchrista <pchrista@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 Nov 2013 22:11:00 +0000 (22:11 +0000)
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.cxx
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskBFPsi.h
PWGCF/EBYE/BalanceFunctions/VZEROEqualization/pp/CalibrationVZERO.root [new file with mode: 0644]

index e15175c..db06977 100755 (executable)
@@ -173,8 +173,10 @@ AliAnalysisTaskBFPsi::AliAnalysisTaskBFPsi(const char *name)
   fUseMCPdgCode(kFALSE),\r
   fPDGCodeToBeAnalyzed(-1),\r
   fEventClass("EventPlane"), \r
-  fCustomBinning("") \r
-{\r
+  fCustomBinning(""),\r
+  fHistVZEROAGainEqualizationMap(0),\r
+  fHistVZEROCGainEqualizationMap(0),\r
+  fHistVZEROChannelGainEqualizationMap(0) {\r
   // Constructor\r
   // Define input and output slots here\r
   // Input slot #0 works with a TChain\r
@@ -1079,7 +1081,15 @@ Double_t AliAnalysisTaskBFPsi::GetRefMultiOrCentrality(AliVEvent *event){
 Double_t AliAnalysisTaskBFPsi::GetReferenceMultiplicityFromAOD(AliVEvent *event){\r
   //Function that returns the reference multiplicity from AODs (data or reco MC)\r
   //Different ref. mult. implemented: V0M, V0A, V0C, TPC\r
-  Double_t gRefMultiplicity = 0., gRefMultiplicityTPC = 0., gRefMultiplicityVZERO = 0.;\r
+  Double_t gRefMultiplicity = 0., gRefMultiplicityTPC = 0.;\r
+  Double_t gRefMultiplicityVZERO = 0., gRefMultiplicityVZEROA = 0., gRefMultiplicityVZEROC = 0.;\r
+\r
+  AliAODHeader *header = dynamic_cast<AliAODHeader *>(event->GetHeader());\r
+  if(!header) {\r
+    Printf("ERROR: AOD header not available");\r
+    return -999;\r
+  }\r
+  Int_t gRunNumber = header->GetRunNumber();\r
 \r
   // Loop over tracks in event\r
   for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) {\r
@@ -1127,17 +1137,25 @@ Double_t AliAnalysisTaskBFPsi::GetReferenceMultiplicityFromAOD(AliVEvent *event)
   }// track loop\r
   \r
   //VZERO segmentation in two detectors (0-31: VZERO-C, 32-63: VZERO-A)\r
-  for(Int_t i = 0; i < 64; i++) {\r
-    fHistVZEROSignal->Fill(i,event->GetVZEROEqMultiplicity(i));\r
+  for(Int_t iChannel = 0; iChannel < 64; iChannel++) {\r
+    fHistVZEROSignal->Fill(iChannel,event->GetVZEROEqMultiplicity(iChannel));\r
     \r
-    if(fMultiplicityEstimator == "V0C") {\r
-      if(i > 31) continue;}\r
-    else if(fMultiplicityEstimator == "V0A") {\r
-      if(i < 32) continue;}\r
-    \r
-    gRefMultiplicityVZERO += event->GetVZEROEqMultiplicity(i);\r
+    if(iChannel < 32) \r
+      gRefMultiplicityVZEROC += event->GetVZEROEqMultiplicity(iChannel);\r
+    else if(iChannel >= 32) \r
+      gRefMultiplicityVZEROA += event->GetVZEROEqMultiplicity(iChannel);\r
   }//loop over PMTs\r
   \r
+  //Equalization of gain\r
+  Double_t gFactorA = GetEqualizationFactor(gRunNumber,"A");\r
+  if(gFactorA != 0)\r
+    gRefMultiplicityVZEROA /= gFactorA;\r
+  Double_t gFactorC = GetEqualizationFactor(gRunNumber,"C");\r
+  if(gFactorC != 0)\r
+    gRefMultiplicityVZEROC /= gFactorC;\r
+  if((gFactorA != 0)&&(gFactorC != 0)) \r
+    gRefMultiplicityVZERO = (gRefMultiplicityVZEROA/gFactorA)+(gRefMultiplicityVZEROC/gFactorC);\r
+  \r
   if(fDebugLevel) \r
     Printf("VZERO multiplicity: %.0f - TPC multiplicity: %.0f",gRefMultiplicityVZERO,gRefMultiplicityTPC);\r
 \r
@@ -1145,10 +1163,12 @@ Double_t AliAnalysisTaskBFPsi::GetReferenceMultiplicityFromAOD(AliVEvent *event)
 \r
   if(fMultiplicityEstimator == "TPC") \r
     gRefMultiplicity = gRefMultiplicityTPC;\r
-  else if((fMultiplicityEstimator == "V0M")||\r
-         (fMultiplicityEstimator == "V0A")||\r
-         (fMultiplicityEstimator == "V0C")) \r
+  else if(fMultiplicityEstimator == "V0M")\r
     gRefMultiplicity = gRefMultiplicityVZERO;\r
+  else if(fMultiplicityEstimator == "V0A")\r
+    gRefMultiplicity = gRefMultiplicityVZEROA;\r
+  else if(fMultiplicityEstimator == "V0C")\r
+    gRefMultiplicity = gRefMultiplicityVZEROC;\r
   \r
   return gRefMultiplicity;\r
 }\r
@@ -2050,6 +2070,72 @@ TObjArray* AliAnalysisTaskBFPsi::GetShuffledTracks(TObjArray *tracks, Double_t g
   return tracksShuffled;\r
 }\r
 \r
+//________________________________________________________________________\r
+void  AliAnalysisTaskBFPsi::SetVZEROCalibrationFile(const char* filename,\r
+                                                   const char* lhcPeriod) {\r
+  //Function to setup the VZERO gain equalization\r
+    //============Get the equilization map============//\r
+  TFile *calibrationFile = TFile::Open(filename);\r
+  if((!calibrationFile)||(!calibrationFile->IsOpen())) {\r
+    Printf("No calibration file found!!!");\r
+    return;\r
+  }\r
+\r
+  TList *list = dynamic_cast<TList *>(calibrationFile->Get(lhcPeriod));\r
+  if(!list) {\r
+    Printf("Calibration TList not found!!!");\r
+    return;\r
+  }\r
+\r
+  fHistVZEROAGainEqualizationMap = dynamic_cast<TH1F *>(list->FindObject("gHistVZEROAGainEqualizationMap"));\r
+  if(!fHistVZEROAGainEqualizationMap) {\r
+    Printf("VZERO-A calibration object not found!!!");\r
+    return;\r
+  }\r
+  fHistVZEROCGainEqualizationMap = dynamic_cast<TH1F *>(list->FindObject("gHistVZEROCGainEqualizationMap"));\r
+  if(!fHistVZEROCGainEqualizationMap) {\r
+    Printf("VZERO-C calibration object not found!!!");\r
+    return;\r
+  }\r
+\r
+  fHistVZEROChannelGainEqualizationMap = dynamic_cast<TH2F *>(list->FindObject("gHistVZEROChannelGainEqualizationMap"));\r
+  if(!fHistVZEROChannelGainEqualizationMap) {\r
+    Printf("VZERO channel calibration object not found!!!");\r
+    return;\r
+  }\r
+}\r
+\r
+//________________________________________________________________________\r
+Double_t AliAnalysisTaskBFPsi::GetChannelEqualizationFactor(Int_t run, \r
+                                                           Int_t channel) {\r
+  //\r
+  for(Int_t iBinX = 1; iBinX <= fHistVZEROChannelGainEqualizationMap->GetNbinsX(); iBinX++) {\r
+    Int_t gRunNumber = atoi(fHistVZEROChannelGainEqualizationMap->GetXaxis()->GetBinLabel(iBinX));\r
+    if(gRunNumber == run)\r
+      return fHistVZEROChannelGainEqualizationMap->GetBinContent(iBinX,channel+1);\r
+  }\r
+\r
+  return 1.0;\r
+}\r
+\r
+//________________________________________________________________________\r
+Double_t AliAnalysisTaskBFPsi::GetEqualizationFactor(Int_t run, \r
+                                                    const char* side) {\r
+  //\r
+  TString gVZEROSide = side;\r
+  for(Int_t iBinX = 1; iBinX <= fHistVZEROAGainEqualizationMap->GetNbinsX(); iBinX++) {\r
+    Int_t gRunNumber = atoi(fHistVZEROAGainEqualizationMap->GetXaxis()->GetBinLabel(iBinX));\r
+    //cout<<"Looking for run "<<run<<" - current run: "<<gRunNumber<<endl;\r
+    if(gRunNumber == run) {\r
+      if(gVZEROSide == "A") \r
+       return fHistVZEROAGainEqualizationMap->GetBinContent(iBinX);\r
+      else if(gVZEROSide == "C") \r
+       return fHistVZEROCGainEqualizationMap->GetBinContent(iBinX);\r
+    }\r
+  }\r
+\r
+  return 1.0;\r
+}\r
 \r
 //________________________________________________________________________\r
 void  AliAnalysisTaskBFPsi::FinishTaskOutput(){\r
index 307dceb..560d435 100755 (executable)
@@ -177,6 +177,7 @@ class AliAnalysisTaskBFPsi : public AliAnalysisTaskSE {
       fElectronRejectionMaxPt  = maxPt;\r
     }\r
 \r
+    void SetVZEROCalibrationFile(const char* filename, const char* lhcPeriod);\r
 \r
  private:\r
   Double_t    IsEventAccepted(AliVEvent* event);\r
@@ -192,6 +193,9 @@ class AliAnalysisTaskBFPsi : public AliAnalysisTaskSE {
   //===============================correction\r
   TObjArray* GetAcceptedTracks(AliVEvent* event, Double_t gCentrality, Double_t gReactionPlane);\r
   TObjArray* GetShuffledTracks(TObjArray* tracks, Double_t gCentrality);\r
+\r
+  Double_t GetChannelEqualizationFactor(Int_t run, Int_t channel);\r
+  Double_t GetEqualizationFactor(Int_t run, const char *side);\r
  \r
   Bool_t fDebugLevel; // debug level\r
 \r
@@ -343,6 +347,10 @@ class AliAnalysisTaskBFPsi : public AliAnalysisTaskSE {
   TString fEventClass; //Can be "EventPlane", "Centrality", "Multiplicity"\r
   TString fCustomBinning;//for setting customized binning (for output AliTHn of AliBalancePsi)\r
   \r
+  //VZERO calibration\r
+  TH1F *fHistVZEROAGainEqualizationMap;//VZERO calibration map\r
+  TH1F *fHistVZEROCGainEqualizationMap;//VZERO calibration map\r
+  TH2F *fHistVZEROChannelGainEqualizationMap; //VZERO calibration map\r
 \r
   AliAnalysisTaskBFPsi(const AliAnalysisTaskBFPsi&); // not implemented\r
   AliAnalysisTaskBFPsi& operator=(const AliAnalysisTaskBFPsi&); // not implemented\r
diff --git a/PWGCF/EBYE/BalanceFunctions/VZEROEqualization/pp/CalibrationVZERO.root b/PWGCF/EBYE/BalanceFunctions/VZEROEqualization/pp/CalibrationVZERO.root
new file mode 100644 (file)
index 0000000..f131c39
Binary files /dev/null and b/PWGCF/EBYE/BalanceFunctions/VZEROEqualization/pp/CalibrationVZERO.root differ