AliPhysics  7b9e818 (7b9e818)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalCorrectionComponent.cxx
Go to the documentation of this file.
1 // AliEmcalCorrectionComponent
2 //
3 
5 
6 #include <TFile.h>
7 #include <TH1.h>
8 
9 #include "AliEmcalList.h"
10 #include "AliEMCALRecoUtils.h"
11 #include "AliAnalysisManager.h"
12 #include "AliVEvent.h"
13 #include "AliClusterContainer.h"
14 #include "AliTrackContainer.h"
15 #include "AliParticleContainer.h"
16 #include "AliMCParticleContainer.h"
17 
21 
22 // Must create an instance of the map, since it is static
24 
29  TNamed("AliEmcalCorrectionComponent", "AliEmcalCorrectionComponent"),
30  fUserConfiguration(),
31  fDefaultConfiguration(),
32  fCreateHisto(kTRUE),
33  fRun(-1),
34  fFilepass(""),
35  fGetPassFromFileName(kTRUE),
36  fEvent(0),
37  fEsdMode(0),
38  fMCEvent(0),
39  fCent(0),
40  fNcentBins(4),
41  fCentBin(0),
42  fNbins(250),
43  fMinBinPt(0),
44  fMaxBinPt(250),
45  fGeom(0),
46  fIsEmbedded(kFALSE),
47  fMinMCLabel(0),
48  fClusCont(0),
49  fPartCont(0),
50  fCaloCells(0),
51  fRecoUtils(0),
52  fOutput(0),
53  fBasePath("")
54 
55 {
56  // Default constructor
57  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
58 
59  fVertex[0] = 0;
60  fVertex[1] = 0;
61  fVertex[2] = 0;
62 }
63 
68  TNamed(name, name),
69  fUserConfiguration(),
70  fDefaultConfiguration(),
71  fCreateHisto(kTRUE),
72  fRun(-1),
73  fFilepass(""),
74  fGetPassFromFileName(kTRUE),
75  fEvent(0),
76  fEsdMode(0),
77  fMCEvent(0),
78  fCent(0),
79  fNcentBins(4),
80  fCentBin(0),
81  fNbins(250),
82  fMinBinPt(0),
83  fMaxBinPt(250),
84  fGeom(0),
85  fIsEmbedded(kFALSE),
86  fMinMCLabel(0),
87  fClusCont(0),
88  fPartCont(0),
89  fCaloCells(0),
90  fRecoUtils(0),
91  fOutput(0),
92  fBasePath("")
93 
94 {
95  // Standard constructor
96  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
97 
98  fVertex[0] = 0;
99  fVertex[1] = 0;
100  fVertex[2] = 0;
101 }
102 
107 {
108 }
109 
115 {
116  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
117 
118  // Read in pass. If it is empty, set flag to automatically find the pass from the filename.
119  std::string tempString = "";
120  GetProperty("pass", tempString);
121  fFilepass = tempString.c_str();
122  if(fFilepass != "")
123  fGetPassFromFileName = kFALSE;
124 
125  return kTRUE;
126 }
127 
133 {
134  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
135 
136  // Setup Output
137  fOutput = new AliEmcalList();
138  fOutput->SetOwner();
139 }
140 
146 {
147  // Initialize using ExecOnce()
148  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
149 }
150 
156 {
157  // Run
158  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
159 
161  GetPass();
162 
163  return kTRUE;
164 }
165 
171 {
172  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
173  return kTRUE;
174 }
175 
184 void AliEmcalCorrectionComponent::GetEtaPhiDiff(const AliVTrack *t, const AliVCluster *v, Double_t &phidiff, Double_t &etadiff)
185 {
186  phidiff = 999;
187  etadiff = 999;
188 
189  if (!t||!v) return;
190 
191  Double_t veta = t->GetTrackEtaOnEMCal();
192  Double_t vphi = t->GetTrackPhiOnEMCal();
193 
194  Float_t pos[3] = {0};
195  v->GetPosition(pos);
196  TVector3 cpos(pos);
197  Double_t ceta = cpos.Eta();
198  Double_t cphi = cpos.Phi();
199  etadiff=veta-ceta;
200  phidiff=TVector2::Phi_mpi_pi(vphi-cphi);
201 }
202 
208 {
209 
210  if (!fEvent) return ;
211 
212  Int_t bunchCrossNo = fEvent->GetBunchCrossNumber();
213 
214  if (fRecoUtils)
215  fRecoUtils->RecalibrateCells(fCaloCells, bunchCrossNo);
216 
217  fCaloCells->Sort();
218 }
219 
224 {
225  // Get run number.
226  return fRun != fEvent->GetRunNumber();
227 }
228 
229 
240 {
241  std::size_t sharedParameterLocation = value.find("sharedParameters:");
242  if (sharedParameterLocation != std::string::npos)
243  {
244  // "sharedParameters:" is 17 characters long
245  value.erase(sharedParameterLocation, sharedParameterLocation + 17);
246  return true;
247  }
248  // Return false otherwise
249  return false;
250 }
251 
257 {
258  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
259  TTree *inputTree = mgr->GetTree();
260 
261  if (!inputTree)
262  {
263  AliError("Pointer to tree = 0, returning");
264  return;
265  }
266 
267  TFile *inputFile = inputTree->GetCurrentFile();
268  if (!inputFile) {
269  AliError("Null pointer input file, returning");
270  return;
271  }
272 
273  TString fname(inputFile->GetName());
274  if (fname.Contains("pass1")) fFilepass = TString("pass1");
275  else if (fname.Contains("pass2")) fFilepass = TString("pass2");
276  else if (fname.Contains("pass3")) fFilepass = TString("pass3");
277  else if (fname.Contains("pass4")) fFilepass = TString("pass4");
278  else if (fname.Contains("pass5")) fFilepass = TString("pass5");
279  else if (fname.Contains("LHC11c") &&
280  fname.Contains("spc_calo")) fFilepass = TString("spc_calo");
281  else if (fname.Contains("calo") || fname.Contains("high_lumi"))
282 
283  {
284  //printf("AliEMCALTenderSupply::GetPass() - Path contains <calo> or <high-lumi>, set as <pass1>\n");
285  fFilepass = TString("pass1");
286  }
287  else if (fname.Contains("LHC14a1a"))
288  {
289  AliInfo("Energy calibration activated for this MC production!");
290  fFilepass = TString("LHC14a1a");
291  }
292  else
293  {
294  AliFatal(Form("Pass number string not found: %s. Please set the pass number in the configuration!", fname.Data()));
295  return;
296  }
297 }
298 
303  TString name = h->GetName();
304 
305  Short_t absId =-1;
306  Double_t ecell = 0;
307  Double_t tcell = 0;
308  Double_t efrac = 0;
309  Int_t mclabel = -1;
310 
311  for (Int_t iCell = 0; iCell < fCaloCells->GetNumberOfCells(); iCell++){
312 
313  fCaloCells->GetCell(iCell, absId, ecell, tcell, mclabel, efrac);
314  if(name.Contains("Energy")){
315  h->Fill(ecell);
316  }
317  else if(name.Contains("Time")){
318  h->Fill(tcell);
319  }
320 
321  }
322 
323 }
double Double_t
Definition: External.C:58
AliVCaloCells * fCaloCells
! Pointer to CaloCells
AliEMCALRecoUtils * fRecoUtils
Pointer to RecoUtils.
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
Base class for correction components in the EMCal correction framework.
static map_type * componentMap
Contains the map to all of the components.
std::map< std::string, AliEmcalCorrectionComponent *(*)()> map_type
Double_t fVertex[3]
! Event vertex
AliVEvent * fEvent
! Pointer to event
TList * fOutput
! List of output histograms
short Short_t
Definition: External.C:23
Enhanced TList-derived class that implements correct merging for pt_hard binned production.
Definition: AliEmcalList.h:25
static bool IsSharedValue(std::string &value)
Bool_t fGetPassFromFileName
Get fFilepass from file name.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
void GetEtaPhiDiff(const AliVTrack *t, const AliVCluster *v, Double_t &phidiff, Double_t &etadiff)
bool Bool_t
Definition: External.C:53
TString fFilepass
Input data pass number.
bool GetProperty(std::string propertyName, T &property, bool requiredProperty=true, std::string correctionName="")
Retrieve property.