AliPhysics  eb0e5d9 (eb0e5d9)
AddTaskEMCALPi0Calibration.C
Go to the documentation of this file.
1 
11 // Root6
12 #if !defined(__CINT__) || defined(__MAKECINT__)
13 
14 #include <TString.h>
15 #include <TROOT.h>
16 #include <TSystem.h>
17 
18 #include "AliLog.h"
20 #include "AliAnalysisManager.h"
21 #include "AliAnalysisDataContainer.h"
22 
23 R__ADD_INCLUDE_PATH($ALICE_PHYSICS)
24 #include "PWGPP/EMCAL/macros/ConfigureEMCALRecoUtils.C"
25 
26 #endif // CINT
27 
42 (TString calibPath = "", // "alienpath/RecalibrationFactors.root"
43  TString trigger = "",
44  Bool_t recalE = kFALSE,
45  Bool_t recalT = kFALSE,
46  Bool_t rmBad = kFALSE,
47  Bool_t nonlin = kTRUE,
48  Bool_t simu = kFALSE,
49  TString outputFile = "", // AnalysisResults.root
50  const char *trigSuffix = ""
51 )
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  {
58  ::Error("AddTaskEMCALTriggerQA", "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  {
66  ::Error("AddTaskEMCALPi0Calibration", "This task requires an input event handler");
67  return NULL;
68  }
69 
70  TString wagon = trigSuffix;
71  if ( wagon.Length() > 0 ) trigger = wagon;
72 
73  AliAnalysisTaskEMCALPi0CalibSelection * pi0calib = new AliAnalysisTaskEMCALPi0CalibSelection(Form("EMCALPi0Calibration_%s",trigger.Data()));
74  //pi0calib->SetDebugLevel(10);
75  //pi0calib->UseFilteredEventAsInput();
76  pi0calib->SetClusterMinEnergy(0.7);
77  pi0calib->SetClusterMaxEnergy(10.);
78  pi0calib->SetClusterLambda0Cuts(0.1,0.5);
79 
80  pi0calib->SetAsymmetryCut(1.);
81  pi0calib->SetClusterMinNCells(1);
82  pi0calib->SetNCellsGroup(0);
83  pi0calib->SwitchOnSameSM();
84 
85  // Timing cuts
86  pi0calib->SetPairDTimeCut(100); // 20 ns in Run1
87  pi0calib->SetClusterMinTime(300); // 560 ns in Run1
88  pi0calib->SetClusterMaxTime(800); // 610 ns in Run1
89 
90  pi0calib->SetTriggerName(trigger);
91 
92  // Centrality selection
93 // pi0calib->SwitchOnCentrality();
94 // pi0calib->SetCentralityRange(50.,90.);
95 // pi0calib->SetCentralityClass("V0M");
96 
97  //
98  // Cluster recalculation, Reco Utils configuration
99  //
100  AliEMCALRecoUtils * reco = pi0calib->GetEMCALRecoUtils();
101 
102  // Root5
103 #if defined(__CINT__)
104 
105  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/ConfigureEMCALRecoUtils.C");
106 
107 #endif
108 
110  simu,
111  kTRUE, // exotic
112  nonlin,
113  recalE,
114  rmBad,
115  recalT);
116 
117  reco->SetNumberOfCellsFromEMCALBorder(0); // Do not remove clusters in borders!
118 
119  // recalibrate energy and do corrections because of Temperature corrections
120  pi0calib->SwitchOnClusterCorrection();
121  reco->SwitchOnRecalibration();
122  reco->SwitchOnRunDepCorrection();
123 
124  //reco->Print("");
125 
126  //---------------------
127  // Geometry alignment
128  //---------------------
129 
130  pi0calib->SetGeometryName("EMCAL_COMPLETE12SMV1_DCAL_8SM");
131 
133 
134  //---------------------
135  // Pass recalibration factors
136  // Do it here or inside the task
137  // If previous pass not available (first) avoid recalculate clusters
138  //---------------------
139 
140  pi0calib->SetCalibrationFilePath(calibPath);
141 
142  if(calibPath != "" && recalE)
143  {
144  printf("AddTaskEMCALPi0Calibration - Get the energy calibration factors from: \n %s \n",calibPath.Data());
145  pi0calib->InitEnergyCalibrationFactors();
146  }
147 
148  if(!recalE)
149  {
150  // Do not calibrate anything
151  // First iteration, just fill histograms, switch off recalculation
152  reco->SwitchOffRecalibration();
153  reco->SwitchOffRunDepCorrection(); // Careful!!!, activate when T corrections are available.
155  pi0calib->SwitchOffRecalculatePosition();
156  printf("AddTaskEMCALPi0Calibration - Pi0 Calibration: Do not recalculate the clusters! First iteration. \n");
157  // check if time is corrected in case of calibration available!!!
158  }
159 
160  pi0calib->PrintInfo();
161 
162  mgr->AddTask(pi0calib);
163 
164  if(outputFile.Length()==0) outputFile = AliAnalysisManager::GetCommonFileName();
165 
166  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
167 
168 
169  AliAnalysisDataContainer *coutput = 0;
170  if( wagon.Length()==0 )
171  {
172  coutput = mgr->CreateContainer(Form("Pi0Calibration_Trig%s",trigger.Data()), TList::Class(),
173  AliAnalysisManager::kOutputContainer,outputFile.Data());
174  }
175  else
176  {
177  TString containerName = "Pi0Calibration";
178  coutput = mgr->CreateContainer(wagon, TList::Class(),
179  AliAnalysisManager::kOutputContainer,Form("%s:%s",outputFile.Data(),containerName.Data()));
180  }
181 
182 // AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("ParamsPi0Calibration_Trig%s",trigger.Data()),
183 // TList::Class(), AliAnalysisManager::kOutputContainer,
184 // "AnalysisParameters.root");
185 
186  mgr->AddTask(pi0calib);
187 
188  mgr->ConnectInput (pi0calib, 0, cinput1);
189  mgr->ConnectOutput (pi0calib, 1, coutput);
190 // mgr->ConnectOutput (pi0calib, 2, cout_cuts);
191 
192  return pi0calib;
193 }
void SetNumberOfCellsFromEMCALBorder(Int_t n)
AliAnalysisTaskEMCALPi0CalibSelection * AddTaskEMCALPi0Calibration(TString calibPath="", TString trigger="", Bool_t recalE=kFALSE, Bool_t recalT=kFALSE, Bool_t rmBad=kFALSE, Bool_t nonlin=kTRUE, Bool_t simu=kFALSE, TString outputFile="", const char *trigSuffix="")
This task provides the input for the EMCal energy calibration with pi0 invariant mass analysis per ch...
Some utilities for cluster and cell treatment.
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)
bool Bool_t
Definition: External.C:53