AliPhysics  608b256 (608b256)
AddTaskCalorimeterQA.C
Go to the documentation of this file.
1 
13 #if !defined(__CINT__) || defined(__MAKECINT__)
14 
15 #include <TString.h>
16 #include <TROOT.h>
17 #include <TSystem.h>
18 
19 #include "AliLog.h"
21 #include "AliCaloTrackESDReader.h"
22 #include "AliCaloTrackAODReader.h"
23 #include "AliCalorimeterUtils.h"
24 #include "AliAnaCalorimeterQA.h"
25 #include "AliHistogramRanges.h"
26 #include "AliAnaCalorimeterQA.h"
28 #include "AliAnalysisManager.h"
29 #include "AliInputEventHandler.h"
30 
31 #endif // CINT
32 
47  Bool_t simulation = kFALSE,
48  TString outputFile = "",
49  Int_t year = 2015,
50  Bool_t printSettings = kFALSE,
51  Bool_t calibrate = kTRUE)
52 {
53  // Get the pointer to the existing analysis manager via the static access method.
54  //==============================================================================
55  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
56  if (!mgr) {
57  ::Error("AddTaskCalorimeterQA", "No analysis manager to connect to.");
58  return NULL;
59  }
60 
61  // Check the analysis type using the event handlers connected to the analysis manager.
62  //==============================================================================
63  if (!mgr->GetInputEventHandler()) {
64  ::Error("AddTaskCalorimeter", "This task requires an input event handler");
65  return NULL;
66  }
67 
68  TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
69 
70  Bool_t kUseKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;
71 
72  TString ssuffix = suffix;
73  if(kUseKinematics || simulation)
74  {
75  simulation = kTRUE;
76  printf("AddTaskCalorimeterQA - CAREFUL : Triggered events not checked in simulation!! \n");
77  if(!ssuffix.Contains("default")) return NULL;
78  }
79 
80  // Configure analysis
81  //===========================================================================
82 
83  //Reader
84  //For this particular analysis few things done by the reader.
85  //Nothing else needs to be set.
86 
87  AliCaloTrackReader * reader = 0x0;
88  if (inputDataType.Contains("AOD")) reader = new AliCaloTrackAODReader();
89  else if(inputDataType.Contains("ESD")) reader = new AliCaloTrackESDReader();
90  //reader->SetDebug(10);//10 for lots of messages
91 
92  reader->SwitchOnEMCALCells();
93  reader->SwitchOnEMCAL();
94  reader->SwitchOnPHOSCells(); // For correlation plots
95  reader->SwitchOnPHOS(); // For correlation plots
96  reader->SetEMCALPtMin(0.);
97  reader->SwitchOnCTS();
98  reader->SetCTSPtMin (0.);
99  reader->SetZvertexCut(10.);
100 
101  reader->SetMultiplicityWithPhysSel(kFALSE); // Do not rely on Physics selection in case calibration not done yet.
102 
103  reader->SetDeltaAODFileName(""); //Do not create deltaAOD file, this analysis do not create branches.
104  reader->SwitchOffWriteDeltaAOD() ;
105 
106  if(!ssuffix.Contains("default"))
107  {
110  reader->SetTriggerPatchTimeWindow(8,9);
111  //reader->SetEventTriggerL0Threshold(2.);
112  }
113 
114  if(!simulation) reader->AnalyzeOnlyPhysicsEvents(); // in case physics selection was not on
115 
116  if(calibrate && !simulation) reader->SwitchOnClusterRecalculation();
117  else reader->SwitchOffClusterRecalculation();
118 
119  if(printSettings) reader->Print("");
120 
121  // *** Calorimeters Utils ***
123  // Remove clusters close to borders, at least max energy cell is 1 cell away
125 
126  if (year == 2010) cu->SetNumberOfSuperModulesUsed(4); //EMCAL first year
127  else if (year < 2014) cu->SetNumberOfSuperModulesUsed(10);
128  else cu->SetNumberOfSuperModulesUsed(20);
129 
130 
131  cu->SwitchOffRecalibration(); // Check the reader if it is taken into account during filtering
133 
135 
136  Bool_t bExotic = kTRUE;
137  Bool_t bNonLin = kTRUE;
138  Bool_t bBadMap = kTRUE;
139 
140  Bool_t bEnCalib = kFALSE;
141  Bool_t bTiCalib = kFALSE;
142 
143  if(calibrate && !simulation)
144  {
145  cu->SwitchOnRecalibration(); // Check the reader if it is taken into account during filtering
148 
149  bEnCalib = kTRUE;
150  bTiCalib = kTRUE;
151  }
152 
153  AliEMCALRecoUtils* recou = cu->GetEMCALRecoUtils();
154 
155  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/ConfigureEMCALRecoUtils.C");
156 
157  TString recouStr = Form("(reinterpret_cast<AliEMCALRecoUtils*>(%p))", recou);
158 
159  gInterpreter->ProcessLine(Form("ConfigureEMCALRecoUtils(%s, %d, %d, %d, %d, %d, %d)", recouStr.Data(),
160  (Int_t)simulation,
161  (Int_t)bExotic,
162  (Int_t)bNonLin,
163  (Int_t)bEnCalib,
164  (Int_t)bBadMap,
165  (Int_t)bTiCalib));
166 
167  if(bBadMap)
169 
170  cu->SetDebug(-1);
171  if(printSettings) cu->Print("");
172 
173  // ##### Analysis algorithm settings ####
174 
175  AliAnaCalorimeterQA *emcalQA = new AliAnaCalorimeterQA();
176  //emcalQA->SetDebug(10); //10 for lots of messages
177 
178  TString calorimeter = "EMCAL";
179  emcalQA->SetCalorimeter(calorimeter);
180 
181  if(simulation)
182  {
183  // Access MC stack and fill more histograms
184  emcalQA->SwitchOnDataMC() ;
185 
186  emcalQA->SwitchOffStudyBadClusters();
188  }
189  else
190  {
191  emcalQA->SwitchOffDataMC() ;
192  emcalQA->SwitchOffStudyBadClusters();
193  emcalQA->SwitchOnFillAllCellTimeHisto();
194  }
195 
196  emcalQA->AddToHistogramsName("EMCAL_"); //Begining of histograms name
197  emcalQA->SwitchOffFiducialCut();
198  emcalQA->SwitchOnCorrelation();
199  emcalQA->SwitchOffFillAllTH3Histogram();
202 
203  //Set Histrograms bins and ranges
204  emcalQA->GetHistogramRanges()->SetHistoPtRangeAndNBins(0, 50, 100) ;
205  emcalQA->GetHistogramRanges()->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
206  emcalQA->GetHistogramRanges()->SetHistoEtaRangeAndNBins(-0.70, 0.70, 140) ;
207 
208  if ( year==2010 )
209  {
210  emcalQA->GetHistogramRanges()->SetHistoPhiRangeAndNBins(80*TMath::DegToRad(), 120*TMath::DegToRad(), 48) ;
211  emcalQA->GetHistogramRanges()->SetHistoXRangeAndNBins(-230,90,120);
212  emcalQA->GetHistogramRanges()->SetHistoYRangeAndNBins(370,450,40);
213  }
214  else if ( year < 2014 )
215  {
216  emcalQA->GetHistogramRanges()->SetHistoPhiRangeAndNBins(80*TMath::DegToRad(), 180*TMath::DegToRad(), 120) ;
217  emcalQA->GetHistogramRanges()->SetHistoXRangeAndNBins(-460,90,200);
218  emcalQA->GetHistogramRanges()->SetHistoYRangeAndNBins(100,450,100);
219  }
220  else // Run2
221  {
222  emcalQA->GetHistogramRanges()->SetHistoPhiRangeAndNBins(80*TMath::DegToRad(), 327*TMath::DegToRad(), 250) ;
223  emcalQA->GetHistogramRanges()->SetHistoXRangeAndNBins(-460,460,230);
224  emcalQA->GetHistogramRanges()->SetHistoYRangeAndNBins(-450,450,225);
225  }
226 
227  emcalQA->GetHistogramRanges()->SetHistoMassRangeAndNBins(0., 0.65, 325) ;
228  emcalQA->GetHistogramRanges()->SetHistoAsymmetryRangeAndNBins(0., 1. , 10 );
229  emcalQA->GetHistogramRanges()->SetHistoEOverPRangeAndNBins(0,2.,50);
230  emcalQA->GetHistogramRanges()->SetHistodEdxRangeAndNBins(0.,200.,100);
231  emcalQA->GetHistogramRanges()->SetHistodRRangeAndNBins(0.,0.10,50);
232  //emcalQA->GetHistogramRanges()->SetHistoTimeRangeAndNBins( 400,900,250);
233  //emcalQA->GetHistogramRanges()->SetHistoTimeRangeAndNBins(-275,275,250);
234  emcalQA->GetHistogramRanges()->SetHistoTimeRangeAndNBins(-275,975,250);
235  emcalQA->GetHistogramRanges()->SetHistoRatioRangeAndNBins(0.,2.,100);
236  emcalQA->GetHistogramRanges()->SetHistoVertexDistRangeAndNBins(0.,500.,500);
238  emcalQA->GetHistogramRanges()->SetHistoZRangeAndNBins(-350,350,175);
239  emcalQA->GetHistogramRanges()->SetHistoRRangeAndNBins(430,460,30);
240  emcalQA->GetHistogramRanges()->SetHistoV0SignalRangeAndNBins(0,5000,100);
244  emcalQA->GetHistogramRanges()->SetHistoDiffTimeRangeAndNBins(-300, 300, 120);
245  emcalQA->GetHistogramRanges()->SetHistoTrackResidualEtaRangeAndNBins(-0.075,0.075,50);
246  emcalQA->GetHistogramRanges()->SetHistoTrackResidualPhiRangeAndNBins(-0.075,0.075,50);
247 
248  if(printSettings) emcalQA->Print("");
249 
250  // #### Configure Maker ####
252  if(ssuffix.Contains("default")) maker->SwitchOffDataControlHistograms();
253  else maker->SwitchOnDataControlHistograms();
254  maker->SetReader(reader);//pointer to reader
255  maker->SetCaloUtils(cu); //pointer to calorimeter utils
256  maker->AddAnalysis(emcalQA,0);
257  maker->SetAnaDebug(-1) ; // 0 to at least print the event number
258  maker->SwitchOnHistogramsMaker() ;
259  maker->SwitchOffAODsMaker() ;
260 
261  if(simulation)
262  {
263  // Calculate the cross section weights, apply them to all histograms
264  // and fill xsec and trial histo. Sumw2 must be activated.
265  //maker->GetReader()->GetWeightUtils()->SwitchOnMCCrossSectionCalculation();
266  //maker->SwitchOnSumw2Histograms();
267 
268  // For recent productions where the cross sections and trials are not stored in separate file
269  //maker->GetReader()->GetWeightUtils()->SwitchOnMCCrossSectionFromEventHeader() ;
270 
271  // Just fill cross section and trials histograms.
273 
274  // Add control histogram with pT hard to control aplication of weights
275  maker->SwitchOnPtHardHistogram();
276  }
277 
278  if(printSettings) maker->Print("");
279 
280  printf("======================== \n");
281  printf("AddTaskCalorimeterQA() - End Configuration \n");
282  printf("======================== \n");
283 
284  // Create task
285  //===========================================================================
286  AliAnalysisTaskCaloTrackCorrelation * task = new AliAnalysisTaskCaloTrackCorrelation (Form("CalorimeterPerformance_%s",suffix));
287 
288  //task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
289 
290  //task->SetDebugLevel(-1);
291 
292  task->SetAnalysisMaker(maker);
293 
294  task->SetBranches("ESD:AliESDRun.,AliESDHeader"); //just a trick to get Constantin's analysis to work
295 
296  mgr->AddTask(task);
297 
298  //Create containers
299  // AliAnalysisDataContainer *cout_pc = mgr->CreateContainer("Calo.Performance",TList::Class(),
300  // AliAnalysisManager::kOutputContainer, "Calo.Performance.root");
301 
302  TString cname;
303  if(outputFile.Length()==0)outputFile = AliAnalysisManager::GetCommonFileName();
304 
305 
306  cname = Form("CaloQA_%s", suffix);
307  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(cname, TList::Class(),
308  AliAnalysisManager::kOutputContainer,
309  Form("%s:%s",outputFile.Data(),cname.Data()));
310 
311 // cname = Form("CaloQACuts_%s", suffix);
312 // AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(cname, TList::Class(),
313 // AliAnalysisManager::kParamContainer,
314 // Form("%s:%s",outputFile.Data(),cname.Data()));
315 
316  //Form("%s:PartCorrCuts",outputfile.Data()));
317  // Create ONLY the output containers for the data produced by the task.
318  // Get and connect other common input/output containers via the manager as below
319  //==============================================================================
320  mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
321  mgr->ConnectOutput (task, 1, cout_pc);
322 // mgr->ConnectOutput (task, 2, cout_cuts);
323 
324  return task;
325 }
326 
327 
void SetHistoTrackMultiplicityRangeAndNBins(Int_t min, Int_t max, Int_t n)
void SetHistoMassRangeAndNBins(Float_t min, Float_t max, Int_t n)
virtual void AddToHistogramsName(TString add)
void SetHistoXRangeAndNBins(Float_t min, Float_t max, Int_t n)
void SetTriggerPatchTimeWindow(Int_t min, Int_t max)
AliEMCALRecoUtils * GetEMCALRecoUtils() const
void SetHistoPtRangeAndNBins(Float_t min, Float_t max, Int_t n)
void AddAnalysis(TObject *ana, Int_t n)
Add analysis depending on AliAnaCaloTrackCorrBaseClass to list.
Class for the Calorimeter QA analysis.
void SetHistodRRangeAndNBins(Float_t min, Float_t max, Int_t n)
void SwitchOnMCCrossSectionHistoFill()
Definition: AliAnaWeights.h:88
void SetNumberOfCellsFromEMCALBorder(Int_t n)
const TString calorimeter
Definition: anaM.C:36
Some utilities for cluster and cell treatment.
void SetHistoTrackResidualEtaRangeAndNBins(Float_t min, Float_t max, Int_t n)
virtual void Print(const Option_t *opt) const
Print some relevant parameters set for the analysis.
Class for event, clusters and tracks filtering and preparation for the AOD analysis.
void SetCTSPtMin(Float_t pt)
virtual void SetCalorimeter(TString calo)
Set the calorimeter for the analysis. A string.
AliAnalysisTaskCaloTrackCorrelation * AddTaskCalorimeterQA(const char *suffix="default", Bool_t simulation=kFALSE, TString outputFile="", Int_t year=2015, Bool_t printSettings=kFALSE, Bool_t calibrate=kTRUE)
virtual void SetDebug(Int_t d)
void SetHistoPhiRangeAndNBins(Float_t min, Float_t max, Int_t n)
int Int_t
Definition: External.C:63
virtual AliHistogramRanges * GetHistogramRanges()
void SwitchOnDataControlHistograms(Int_t lev=1)
void SetHistoTrackResidualPhiRangeAndNBins(Float_t min, Float_t max, Int_t n)
void SetHistoEOverPRangeAndNBins(Float_t min, Float_t max, Int_t n)
Base class for event, clusters and tracks filtering and preparation for the analysis.
void SetHistoNClusterCellRangeAndNBins(Int_t min, Int_t max, Int_t n)
void SwitchOffBadTriggerEventsRemoval()
void SetAnalysisMaker(AliAnaCaloTrackCorrMaker *const maker)
void SetHistoYRangeAndNBins(Float_t min, Float_t max, Int_t n)
virtual void Print(const Option_t *opt) const
Print some relevant parameters set for the analysis.
virtual void SetZvertexCut(Float_t zcut=10.)
void SetNumberOfSuperModulesUsed(Int_t nSM)
Class for event, clusters and tracks filtering and preparation for the ESD analysis.
void SetReader(AliCaloTrackReader *re)
void SetEMCALPtMin(Float_t pt)
void SetMultiplicityWithPhysSel(Bool_t ps)
void SetHistoEtaRangeAndNBins(Float_t min, Float_t max, Int_t n)
void SetHistoAsymmetryRangeAndNBins(Float_t min, Float_t max, Int_t n)
void SetHistoV0MultiplicityRangeAndNBins(Int_t min, Int_t max, Int_t n)
Main class conecting the CaloTrackCorrelations package and Analysis Frame.
void SetHistoZRangeAndNBins(Float_t min, Float_t max, Int_t n)
void SetHistoV0SignalRangeAndNBins(Int_t min, Int_t max, Int_t n)
void SetHistoTimeRangeAndNBins(Float_t min, Float_t max, Int_t n)
void SetHistoFinePtRangeAndNBins(Float_t min, Float_t max, Int_t n)
void SetHistoShowerShapeRangeAndNBins(Float_t min, Float_t max, Int_t n)
void Print(const Option_t *opt) const
Print some relevant parameters set for the analysis.
bool Bool_t
Definition: External.C:53
void SetHistodEdxRangeAndNBins(Float_t min, Float_t max, Int_t n)
Class with utils specific to calorimeter clusters/cells.
AliCaloTrackReader * GetReader()
AliAnaWeights * GetWeightUtils()
void SetHistoRRangeAndNBins(Float_t min, Float_t max, Int_t n)
void SetHistoVertexDistRangeAndNBins(Float_t min, Float_t max, Int_t n)
void SetHistoDiffTimeRangeAndNBins(Float_t min, Float_t max, Int_t n)
void SetHistoRatioRangeAndNBins(Float_t min, Float_t max, Int_t n)
void Print(const Option_t *opt) const
Print some relevant parameters set for the analysis.
void SetCaloUtils(AliCalorimeterUtils *cu)
Steering class of package CaloTrackCorrelartions.
void SetDeltaAODFileName(TString name)