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