AliPhysics  04715ba (04715ba)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
31 
32 #endif // CINT
33 
48  Bool_t simulation = kFALSE,
49  TString outputFile = "",
50  Int_t year = 2015,
51  Bool_t printSettings = kFALSE,
52  Bool_t calibrate = kTRUE)
53 {
54  // Get the pointer to the existing analysis manager via the static access method.
55  //==============================================================================
56  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
57  if (!mgr) {
58  ::Error("AddTaskCalorimeterQA", "No analysis manager to connect to.");
59  return NULL;
60  }
61 
62  // Check the analysis type using the event handlers connected to the analysis manager.
63  //==============================================================================
64  if (!mgr->GetInputEventHandler()) {
65  ::Error("AddTaskCalorimeter", "This task requires an input event handler");
66  return NULL;
67  }
68 
69  TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
70 
71  Bool_t kUseKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;
72 
73  TString ssuffix = suffix;
74  if(kUseKinematics || simulation)
75  {
76  simulation = kTRUE;
77  printf("AddTaskCalorimeterQA - CAREFUL : Triggered events not checked in simulation!! \n");
78  if(!ssuffix.Contains("default")) return NULL;
79  }
80 
81  // Configure analysis
82  //===========================================================================
83 
84  //Reader
85  //For this particular analysis few things done by the reader.
86  //Nothing else needs to be set.
87 
88  AliCaloTrackReader * reader = 0x0;
89  if (inputDataType.Contains("AOD")) reader = new AliCaloTrackAODReader();
90  else if(inputDataType.Contains("ESD")) reader = new AliCaloTrackESDReader();
91  //reader->SetDebug(10);//10 for lots of messages
92 
93  reader->SwitchOnEMCALCells();
94  reader->SwitchOnEMCAL();
95  reader->SwitchOnPHOSCells(); // For correlation plots
96  reader->SwitchOnPHOS(); // For correlation plots
97  reader->SetEMCALPtMin(0.);
98  reader->SwitchOnCTS();
99  reader->SetCTSPtMin (0.);
100  reader->SetZvertexCut(10.);
101 
102  reader->SetDeltaAODFileName(""); //Do not create deltaAOD file, this analysis do not create branches.
103  reader->SwitchOffWriteDeltaAOD() ;
104 
105  if(!ssuffix.Contains("default"))
106  {
109  reader->SetTriggerPatchTimeWindow(8,9);
110  //reader->SetEventTriggerL0Threshold(2.);
111  }
112 
113  if(!simulation) reader->AnalyzeOnlyPhysicsEvents(); // in case physics selection was not on
114 
115  if(calibrate && !simulation) reader->SwitchOnClusterRecalculation();
116  else reader->SwitchOffClusterRecalculation();
117 
118  if(printSettings) reader->Print("");
119 
120  // *** Calorimeters Utils ***
122  // Remove clusters close to borders, at least max energy cell is 1 cell away
124 
125  if (year == 2010) cu->SetNumberOfSuperModulesUsed(4); //EMCAL first year
126  else if (year < 2014) cu->SetNumberOfSuperModulesUsed(10);
127  else cu->SetNumberOfSuperModulesUsed(20);
128 
129 
130  cu->SwitchOffRecalibration(); // Check the reader if it is taken into account during filtering
132 
134 
135  Bool_t bExotic = kTRUE;
136  Bool_t bNonLin = kTRUE;
137  Bool_t bBadMap = kTRUE;
138 
139  Bool_t bEnCalib = kFALSE;
140  Bool_t bTiCalib = kFALSE;
141 
142  if(calibrate && !simulation)
143  {
144  cu->SwitchOnRecalibration(); // Check the reader if it is taken into account during filtering
147 
148  bEnCalib = kTRUE;
149  bTiCalib = kTRUE;
150  }
151 
152  AliEMCALRecoUtils* recou = cu->GetEMCALRecoUtils();
153 
154  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/ConfigureEMCALRecoUtils.C");
156  simulation,
157  bExotic,
158  bNonLin,
159  bEnCalib,
160  bBadMap,
161  bTiCalib);
162 
163  if(bBadMap)
165 
166  cu->SetDebug(-1);
167  if(printSettings) cu->Print("");
168 
169  // ##### Analysis algorithm settings ####
170 
171  AliAnaCalorimeterQA *emcalQA = new AliAnaCalorimeterQA();
172  //emcalQA->SetDebug(10); //10 for lots of messages
173 
174  TString calorimeter = "EMCAL";
175  emcalQA->SetCalorimeter(calorimeter);
176 
177  if(simulation)
178  {
179  // Access MC stack and fill more histograms
180  emcalQA->SwitchOnDataMC() ;
181 
182  emcalQA->SwitchOffStudyBadClusters();
184  }
185  else
186  {
187  emcalQA->SwitchOffDataMC() ;
188  emcalQA->SwitchOffStudyBadClusters();
189  emcalQA->SwitchOnFillAllCellTimeHisto();
190  }
191 
192  emcalQA->AddToHistogramsName("EMCAL_"); //Begining of histograms name
193  emcalQA->SwitchOffFiducialCut();
194  emcalQA->SwitchOnCorrelation();
195  emcalQA->SwitchOffFillAllTH3Histogram();
198 
199  //Set Histrograms bins and ranges
200  emcalQA->GetHistogramRanges()->SetHistoPtRangeAndNBins(0, 50, 100) ;
201  emcalQA->GetHistogramRanges()->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
202  emcalQA->GetHistogramRanges()->SetHistoEtaRangeAndNBins(-0.70, 0.70, 140) ;
203 
204  if ( year==2010 )
205  {
206  emcalQA->GetHistogramRanges()->SetHistoPhiRangeAndNBins(80*TMath::DegToRad(), 120*TMath::DegToRad(), 48) ;
207  emcalQA->GetHistogramRanges()->SetHistoXRangeAndNBins(-230,90,120);
208  emcalQA->GetHistogramRanges()->SetHistoYRangeAndNBins(370,450,40);
209  }
210  else if ( year < 2014 )
211  {
212  emcalQA->GetHistogramRanges()->SetHistoPhiRangeAndNBins(80*TMath::DegToRad(), 180*TMath::DegToRad(), 120) ;
213  emcalQA->GetHistogramRanges()->SetHistoXRangeAndNBins(-460,90,200);
214  emcalQA->GetHistogramRanges()->SetHistoYRangeAndNBins(100,450,100);
215  }
216  else // Run2
217  {
218  emcalQA->GetHistogramRanges()->SetHistoPhiRangeAndNBins(80*TMath::DegToRad(), 327*TMath::DegToRad(), 250) ;
219  emcalQA->GetHistogramRanges()->SetHistoXRangeAndNBins(-460,460,230);
220  emcalQA->GetHistogramRanges()->SetHistoYRangeAndNBins(-450,450,225);
221  }
222 
223  emcalQA->GetHistogramRanges()->SetHistoMassRangeAndNBins(0., 0.65, 325) ;
224  emcalQA->GetHistogramRanges()->SetHistoAsymmetryRangeAndNBins(0., 1. , 10 );
225  emcalQA->GetHistogramRanges()->SetHistoPOverERangeAndNBins(0,2.,50);
226  emcalQA->GetHistogramRanges()->SetHistodEdxRangeAndNBins(0.,200.,100);
227  emcalQA->GetHistogramRanges()->SetHistodRRangeAndNBins(0.,0.10,50);
228  //emcalQA->GetHistogramRanges()->SetHistoTimeRangeAndNBins( 400,900,250);
229  //emcalQA->GetHistogramRanges()->SetHistoTimeRangeAndNBins(-275,275,250);
230  emcalQA->GetHistogramRanges()->SetHistoTimeRangeAndNBins(-275,975,250);
231  emcalQA->GetHistogramRanges()->SetHistoRatioRangeAndNBins(0.,2.,100);
232  emcalQA->GetHistogramRanges()->SetHistoVertexDistRangeAndNBins(0.,500.,500);
234  emcalQA->GetHistogramRanges()->SetHistoZRangeAndNBins(-350,350,175);
235  emcalQA->GetHistogramRanges()->SetHistoRRangeAndNBins(430,460,30);
236  emcalQA->GetHistogramRanges()->SetHistoV0SignalRangeAndNBins(0,5000,100);
240  emcalQA->GetHistogramRanges()->SetHistoDiffTimeRangeAndNBins(-300, 300, 120);
241  emcalQA->GetHistogramRanges()->SetHistoTrackResidualEtaRangeAndNBins(-0.075,0.075,50);
242  emcalQA->GetHistogramRanges()->SetHistoTrackResidualPhiRangeAndNBins(-0.075,0.075,50);
243 
244  if(printSettings) emcalQA->Print("");
245 
246  // #### Configure Maker ####
248  if(ssuffix.Contains("default")) maker->SwitchOffDataControlHistograms();
249  else maker->SwitchOnDataControlHistograms();
250  maker->SetReader(reader);//pointer to reader
251  maker->SetCaloUtils(cu); //pointer to calorimeter utils
252  maker->AddAnalysis(emcalQA,0);
253  maker->SetAnaDebug(-1) ; // 0 to at least print the event number
254  maker->SwitchOnHistogramsMaker() ;
255  maker->SwitchOffAODsMaker() ;
256 
257  if(simulation)
258  {
259  // Calculate the cross section weights, apply them to all histograms
260  // and fill xsec and trial histo. Sumw2 must be activated.
261  //maker->GetReader()->GetWeightUtils()->SwitchOnMCCrossSectionCalculation();
262  //maker->SwitchOnSumw2Histograms();
263 
264  // For recent productions where the cross sections and trials are not stored in separate file
265  //maker->GetReader()->GetWeightUtils()->SwitchOnMCCrossSectionFromEventHeader() ;
266 
267  // Just fill cross section and trials histograms.
269 
270  // Add control histogram with pT hard to control aplication of weights
271  maker->SwitchOnPtHardHistogram();
272  }
273 
274  if(printSettings) maker->Print("");
275 
276  printf("======================== \n");
277  printf("AddTaskCalorimeterQA() - End Configuration \n");
278  printf("======================== \n");
279 
280  // Create task
281  //===========================================================================
282  AliAnalysisTaskCaloTrackCorrelation * task = new AliAnalysisTaskCaloTrackCorrelation (Form("CalorimeterPerformance_%s",suffix));
283 
284  //task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
285 
286  //task->SetDebugLevel(-1);
287 
288  task->SetAnalysisMaker(maker);
289 
290  task->SetBranches("ESD:AliESDRun.,AliESDHeader"); //just a trick to get Constantin's analysis to work
291 
292  mgr->AddTask(task);
293 
294  //Create containers
295  // AliAnalysisDataContainer *cout_pc = mgr->CreateContainer("Calo.Performance",TList::Class(),
296  // AliAnalysisManager::kOutputContainer, "Calo.Performance.root");
297 
298  TString cname;
299  if(outputFile.Length()==0)outputFile = AliAnalysisManager::GetCommonFileName();
300 
301 
302  cname = Form("CaloQA_%s", suffix);
303  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(cname, TList::Class(),
304  AliAnalysisManager::kOutputContainer,
305  Form("%s:%s",outputFile.Data(),cname.Data()));
306 
307 // cname = Form("CaloQACuts_%s", suffix);
308 // AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(cname, TList::Class(),
309 // AliAnalysisManager::kParamContainer,
310 // Form("%s:%s",outputFile.Data(),cname.Data()));
311 
312  //Form("%s:PartCorrCuts",outputfile.Data()));
313  // Create ONLY the output containers for the data produced by the task.
314  // Get and connect other common input/output containers via the manager as below
315  //==============================================================================
316  mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
317  mgr->ConnectOutput (task, 1, cout_pc);
318 // mgr->ConnectOutput (task, 2, cout_cuts);
319 
320  return task;
321 }
322 
323 
void SetHistoTrackMultiplicityRangeAndNBins(Int_t min, Int_t max, Int_t n)
Configuration of AliEMCALRecoUtils.
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
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 ConfigureEMCALRecoUtils(AliEMCALRecoUtils *reco, Bool_t bMC=kFALSE, Bool_t bExotic=kTRUE, Bool_t bNonLin=kFALSE, Bool_t bRecalE=kTRUE, Bool_t bBad=kTRUE, Bool_t bRecalT=kTRUE, Int_t debug=-1)
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)