AliPhysics  56f1704 (56f1704)
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->SetDeltaAODFileName(""); //Do not create deltaAOD file, this analysis do not create branches.
102  reader->SwitchOffWriteDeltaAOD() ;
103 
104  if(!ssuffix.Contains("default"))
105  {
108  reader->SetTriggerPatchTimeWindow(8,9);
109  //reader->SetEventTriggerL0Threshold(2.);
110  }
111 
112  if(!simulation) reader->AnalyzeOnlyPhysicsEvents(); // in case physics selection was not on
113 
114  if(calibrate && !simulation) reader->SwitchOnClusterRecalculation();
115  else reader->SwitchOffClusterRecalculation();
116 
117  if(printSettings) reader->Print("");
118 
119  // *** Calorimeters Utils ***
121  // Remove clusters close to borders, at least max energy cell is 1 cell away
123 
124  if (year == 2010) cu->SetNumberOfSuperModulesUsed(4); //EMCAL first year
125  else if (year < 2014) cu->SetNumberOfSuperModulesUsed(10);
126  else cu->SetNumberOfSuperModulesUsed(20);
127 
128 
129  cu->SwitchOffRecalibration(); // Check the reader if it is taken into account during filtering
131 
133 
134  Bool_t bExotic = kTRUE;
135  Bool_t bNonLin = kTRUE;
136  Bool_t bBadMap = kTRUE;
137 
138  Bool_t bEnCalib = kFALSE;
139  Bool_t bTiCalib = kFALSE;
140 
141  if(calibrate && !simulation)
142  {
143  cu->SwitchOnRecalibration(); // Check the reader if it is taken into account during filtering
146 
147  bEnCalib = kTRUE;
148  bTiCalib = kTRUE;
149  }
150 
151  AliEMCALRecoUtils* recou = cu->GetEMCALRecoUtils();
152 
153  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/ConfigureEMCALRecoUtils.C");
154 
155  TString recouStr = Form("(reinterpret_cast<AliEMCALRecoUtils*>(%p))", recou);
156 
157  gInterpreter->ProcessLine(Form("ConfigureEMCALRecoUtils(%s, %d, %d, %d, %d, %d, %d)", recouStr.Data(),
158  (Int_t)simulation,
159  (Int_t)bExotic,
160  (Int_t)bNonLin,
161  (Int_t)bEnCalib,
162  (Int_t)bBadMap,
163  (Int_t)bTiCalib));
164 
165  if(bBadMap)
167 
168  cu->SetDebug(-1);
169  if(printSettings) cu->Print("");
170 
171  // ##### Analysis algorithm settings ####
172 
173  AliAnaCalorimeterQA *emcalQA = new AliAnaCalorimeterQA();
174  //emcalQA->SetDebug(10); //10 for lots of messages
175 
176  TString calorimeter = "EMCAL";
177  emcalQA->SetCalorimeter(calorimeter);
178 
179  if(simulation)
180  {
181  // Access MC stack and fill more histograms
182  emcalQA->SwitchOnDataMC() ;
183 
184  emcalQA->SwitchOffStudyBadClusters();
186  }
187  else
188  {
189  emcalQA->SwitchOffDataMC() ;
190  emcalQA->SwitchOffStudyBadClusters();
191  emcalQA->SwitchOnFillAllCellTimeHisto();
192  }
193 
194  emcalQA->AddToHistogramsName("EMCAL_"); //Begining of histograms name
195  emcalQA->SwitchOffFiducialCut();
196  emcalQA->SwitchOnCorrelation();
197  emcalQA->SwitchOffFillAllTH3Histogram();
200 
201  //Set Histrograms bins and ranges
202  emcalQA->GetHistogramRanges()->SetHistoPtRangeAndNBins(0, 50, 100) ;
203  emcalQA->GetHistogramRanges()->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
204  emcalQA->GetHistogramRanges()->SetHistoEtaRangeAndNBins(-0.70, 0.70, 140) ;
205 
206  if ( year==2010 )
207  {
208  emcalQA->GetHistogramRanges()->SetHistoPhiRangeAndNBins(80*TMath::DegToRad(), 120*TMath::DegToRad(), 48) ;
209  emcalQA->GetHistogramRanges()->SetHistoXRangeAndNBins(-230,90,120);
210  emcalQA->GetHistogramRanges()->SetHistoYRangeAndNBins(370,450,40);
211  }
212  else if ( year < 2014 )
213  {
214  emcalQA->GetHistogramRanges()->SetHistoPhiRangeAndNBins(80*TMath::DegToRad(), 180*TMath::DegToRad(), 120) ;
215  emcalQA->GetHistogramRanges()->SetHistoXRangeAndNBins(-460,90,200);
216  emcalQA->GetHistogramRanges()->SetHistoYRangeAndNBins(100,450,100);
217  }
218  else // Run2
219  {
220  emcalQA->GetHistogramRanges()->SetHistoPhiRangeAndNBins(80*TMath::DegToRad(), 327*TMath::DegToRad(), 250) ;
221  emcalQA->GetHistogramRanges()->SetHistoXRangeAndNBins(-460,460,230);
222  emcalQA->GetHistogramRanges()->SetHistoYRangeAndNBins(-450,450,225);
223  }
224 
225  emcalQA->GetHistogramRanges()->SetHistoMassRangeAndNBins(0., 0.65, 325) ;
226  emcalQA->GetHistogramRanges()->SetHistoAsymmetryRangeAndNBins(0., 1. , 10 );
227  emcalQA->GetHistogramRanges()->SetHistoPOverERangeAndNBins(0,2.,50);
228  emcalQA->GetHistogramRanges()->SetHistodEdxRangeAndNBins(0.,200.,100);
229  emcalQA->GetHistogramRanges()->SetHistodRRangeAndNBins(0.,0.10,50);
230  //emcalQA->GetHistogramRanges()->SetHistoTimeRangeAndNBins( 400,900,250);
231  //emcalQA->GetHistogramRanges()->SetHistoTimeRangeAndNBins(-275,275,250);
232  emcalQA->GetHistogramRanges()->SetHistoTimeRangeAndNBins(-275,975,250);
233  emcalQA->GetHistogramRanges()->SetHistoRatioRangeAndNBins(0.,2.,100);
234  emcalQA->GetHistogramRanges()->SetHistoVertexDistRangeAndNBins(0.,500.,500);
236  emcalQA->GetHistogramRanges()->SetHistoZRangeAndNBins(-350,350,175);
237  emcalQA->GetHistogramRanges()->SetHistoRRangeAndNBins(430,460,30);
238  emcalQA->GetHistogramRanges()->SetHistoV0SignalRangeAndNBins(0,5000,100);
242  emcalQA->GetHistogramRanges()->SetHistoDiffTimeRangeAndNBins(-300, 300, 120);
243  emcalQA->GetHistogramRanges()->SetHistoTrackResidualEtaRangeAndNBins(-0.075,0.075,50);
244  emcalQA->GetHistogramRanges()->SetHistoTrackResidualPhiRangeAndNBins(-0.075,0.075,50);
245 
246  if(printSettings) emcalQA->Print("");
247 
248  // #### Configure Maker ####
250  if(ssuffix.Contains("default")) maker->SwitchOffDataControlHistograms();
251  else maker->SwitchOnDataControlHistograms();
252  maker->SetReader(reader);//pointer to reader
253  maker->SetCaloUtils(cu); //pointer to calorimeter utils
254  maker->AddAnalysis(emcalQA,0);
255  maker->SetAnaDebug(-1) ; // 0 to at least print the event number
256  maker->SwitchOnHistogramsMaker() ;
257  maker->SwitchOffAODsMaker() ;
258 
259  if(simulation)
260  {
261  // Calculate the cross section weights, apply them to all histograms
262  // and fill xsec and trial histo. Sumw2 must be activated.
263  //maker->GetReader()->GetWeightUtils()->SwitchOnMCCrossSectionCalculation();
264  //maker->SwitchOnSumw2Histograms();
265 
266  // For recent productions where the cross sections and trials are not stored in separate file
267  //maker->GetReader()->GetWeightUtils()->SwitchOnMCCrossSectionFromEventHeader() ;
268 
269  // Just fill cross section and trials histograms.
271 
272  // Add control histogram with pT hard to control aplication of weights
273  maker->SwitchOnPtHardHistogram();
274  }
275 
276  if(printSettings) maker->Print("");
277 
278  printf("======================== \n");
279  printf("AddTaskCalorimeterQA() - End Configuration \n");
280  printf("======================== \n");
281 
282  // Create task
283  //===========================================================================
284  AliAnalysisTaskCaloTrackCorrelation * task = new AliAnalysisTaskCaloTrackCorrelation (Form("CalorimeterPerformance_%s",suffix));
285 
286  //task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
287 
288  //task->SetDebugLevel(-1);
289 
290  task->SetAnalysisMaker(maker);
291 
292  task->SetBranches("ESD:AliESDRun.,AliESDHeader"); //just a trick to get Constantin's analysis to work
293 
294  mgr->AddTask(task);
295 
296  //Create containers
297  // AliAnalysisDataContainer *cout_pc = mgr->CreateContainer("Calo.Performance",TList::Class(),
298  // AliAnalysisManager::kOutputContainer, "Calo.Performance.root");
299 
300  TString cname;
301  if(outputFile.Length()==0)outputFile = AliAnalysisManager::GetCommonFileName();
302 
303 
304  cname = Form("CaloQA_%s", suffix);
305  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(cname, TList::Class(),
306  AliAnalysisManager::kOutputContainer,
307  Form("%s:%s",outputFile.Data(),cname.Data()));
308 
309 // cname = Form("CaloQACuts_%s", suffix);
310 // AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(cname, TList::Class(),
311 // AliAnalysisManager::kParamContainer,
312 // Form("%s:%s",outputFile.Data(),cname.Data()));
313 
314  //Form("%s:PartCorrCuts",outputfile.Data()));
315  // Create ONLY the output containers for the data produced by the task.
316  // Get and connect other common input/output containers via the manager as below
317  //==============================================================================
318  mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
319  mgr->ConnectOutput (task, 1, cout_pc);
320 // mgr->ConnectOutput (task, 2, cout_cuts);
321 
322  return task;
323 }
324 
325 
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)
virtual void SetCalorimeter(TString &calo)
Set the calorimeter for the analysis. A string.
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)
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 SetHistoPOverERangeAndNBins(Float_t min, Float_t max, Int_t n)
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)
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 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)