AliPhysics  5b5fbb3 (5b5fbb3)
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  // Cluster recalculation, Reco Utils configuration
91 
92 
93  AliEMCALRecoUtils * reco = pi0calib->GetEMCALRecoUtils();
94 
95  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/ConfigureEMCALRecoUtils.C");
96 
98  simu,
99  kTRUE, // exotic
100  nonlin,
101  recalE,
102  rmBad,
103  recalT);
104 
105  reco->SetNumberOfCellsFromEMCALBorder(0); // Do not remove clusters in borders!
106 
107  // recalibrate energy and do corrections because of Temperature corrections
108  pi0calib->SwitchOnClusterCorrection();
109  reco->SwitchOnRecalibration();
110  reco->SwitchOnRunDepCorrection();
111 
112  //reco->Print("");
113 
114  //---------------------
115  // Geometry alignment
116  //---------------------
117 
118  pi0calib->SetGeometryName("EMCAL_COMPLETE12SMV1_DCAL_8SM");
119 
121 
122  //---------------------
123  // Pass recalibration factors
124  // Do it here or inside the task
125  // If previous pass not available (first) avoid recalculate clusters
126  //---------------------
127 
128  pi0calib->SetCalibrationFilePath(calibPath);
129 
130  if(calibPath != "" && recalE)
131  {
132  printf("AddTaskEMCALPi0Calibration - Get the energy calibration factors from: \n %s \n",calibPath.Data());
133  pi0calib->InitEnergyCalibrationFactors();
134  }
135 
136  if(!recalE)
137  {
138  // Do not calibrate anything
139  // First iteration, just fill histograms, switch off recalculation
140  reco->SwitchOffRecalibration();
141  reco->SwitchOffRunDepCorrection(); // Careful!!!, activate when T corrections are available.
143  pi0calib->SwitchOffRecalculatePosition();
144  printf("AddTaskEMCALPi0Calibration - Pi0 Calibration: Do not recalculate the clusters! First iteration. \n");
145  // check if time is corrected in case of calibration available!!!
146  }
147 
148  pi0calib->PrintInfo();
149 
150  mgr->AddTask(pi0calib);
151 
152  if(outputFile.Length()==0) outputFile = AliAnalysisManager::GetCommonFileName();
153 
154  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
155 
156 
157  AliAnalysisDataContainer *coutput = 0;
158  if( wagon.Length()==0 )
159  {
160  coutput = mgr->CreateContainer(Form("Pi0Calibration_Trig%s",trigger.Data()), TList::Class(),
161  AliAnalysisManager::kOutputContainer,outputFile.Data());
162  }
163  else
164  {
165  TString containerName = "Pi0Calibration";
166  coutput = mgr->CreateContainer(wagon, TList::Class(),
167  AliAnalysisManager::kOutputContainer,Form("%s:%s",outputFile.Data(),containerName.Data()));
168  }
169 
170 // AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("ParamsPi0Calibration_Trig%s",trigger.Data()),
171 // TList::Class(), AliAnalysisManager::kOutputContainer,
172 // "AnalysisParameters.root");
173 
174  mgr->AddTask(pi0calib);
175 
176  mgr->ConnectInput (pi0calib, 0, cinput1);
177  mgr->ConnectOutput (pi0calib, 1, coutput);
178 // mgr->ConnectOutput (pi0calib, 2, cout_cuts);
179 
180  return pi0calib;
181 }
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