AliPhysics  97a96ce (97a96ce)
 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 <yaml-cpp/yaml.h>
7 
8 #include "AliEmcalList.h"
9 
13 
14 // Must create an instance of the map, since it is static
16 
21  TNamed("AliEmcalCorrectionComponent", "AliEmcalCorrectionComponent"),
22  fUserConfiguration(),
23  fDefaultConfiguration(),
24  fCreateHisto(kTRUE),
25  fRun(-1),
26  fFilepass(0),
27  fGetPassFromFileName(kTRUE),
28  fEvent(0),
29  fEsdMode(0),
30  fMCEvent(0),
31  fCent(0),
32  fNcentBins(4),
33  fCentBin(0),
34  fNbins(250),
35  fMinBinPt(0),
36  fMaxBinPt(250),
37  fGeom(0),
38  fIsEmbedded(kFALSE),
39  fMinMCLabel(0),
40  fClusCont(0),
41  fPartCont(0),
42  fCaloCells(0),
43  fRecoUtils(0),
44  fOutput(0),
45  fBasePath("")
46 
47 {
48  // Default constructor
49  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
50 
51  fVertex[0] = 0;
52  fVertex[1] = 0;
53  fVertex[2] = 0;
54 }
55 
60  TNamed(name, name),
61  fUserConfiguration(),
62  fDefaultConfiguration(),
63  fCreateHisto(kTRUE),
64  fRun(-1),
65  fFilepass(0),
66  fGetPassFromFileName(kTRUE),
67  fEvent(0),
68  fEsdMode(0),
69  fMCEvent(0),
70  fCent(0),
71  fNcentBins(4),
72  fCentBin(0),
73  fNbins(250),
74  fMinBinPt(0),
75  fMaxBinPt(250),
76  fGeom(0),
77  fIsEmbedded(kFALSE),
78  fMinMCLabel(0),
79  fClusCont(0),
80  fPartCont(0),
81  fCaloCells(0),
82  fRecoUtils(0),
83  fOutput(0),
84  fBasePath("")
85 
86 {
87  // Standard constructor
88  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
89 
90  fVertex[0] = 0;
91  fVertex[1] = 0;
92  fVertex[2] = 0;
93 }
94 
99 {
100 }
101 
106 {
107  std::string inputObjectBranch = "";
108  if (objType == kCluster) {
109  if (esdMode == true) {
110  inputObjectBranch = "CaloClusters";
111  }
112  else {
113  inputObjectBranch = "caloClusters";
114  }
115  }
116  else if (objType == kTrack) {
117  if (esdMode == true) {
118  inputObjectBranch = "Tracks";
119  }
120  else {
121  inputObjectBranch = "tracks";
122  }
123  }
124  else if (objType == kCaloCells) {
125  if (esdMode == true) {
126  inputObjectBranch = "EMCALCells";
127  }
128  else {
129  inputObjectBranch = "emcalCells";
130  }
131  }
132  else {
133  // Default to empty if we are given an unrecognized type with "usedefault"
134  inputObjectBranch = "";
135  }
136 
137  return inputObjectBranch;
138 }
139 
153 {
154  // Determine the type of branch to request
155  std::string containerBranch = "";
156  std::string containerBranchInConfiguration = "BranchName";
157  if (contType == kCluster) {
158  containerBranchInConfiguration = "cluster" + containerBranchInConfiguration;
159  }
160  else if (contType == kTrack) {
161  containerBranchInConfiguration = "track" + containerBranchInConfiguration;
162  } else {
163  AliFatal(TString::Format("%s: Must specify type of container when requesting branch.", GetName()));
164  }
165 
166  // Retrieve branch name
167  GetProperty(containerBranchInConfiguration, containerBranch);
168  // Should be unnecessary, since the user can only do this if done explicitly.
169  /*if (containerBranch == "")
170  {
171  AliFatal(TString::Format("%s: Request %i container, but the container branch is empty!", GetName(), contType));
172  }*/
173 
174  // Determine proper name if using "usedefault" pattern
175  if (containerBranch == "usedefault") {
176  containerBranch = DetermineUseDefaultName(contType, fEsdMode);
177  }
178 
179  // Create containers and set them to the name of the component
180  if (contType == kCluster)
181  {
182  fClusCont = new AliClusterContainer(containerBranch.c_str());
183  fClusCont->SetName(GetName());
184  }
185  else if (contType == kTrack)
186  {
187  if (containerBranch == "mcparticles") {
188  fPartCont = new AliMCParticleContainer(containerBranch.c_str());
189  }
190  else {
191  fPartCont = new AliTrackContainer(containerBranch.c_str());
192  }
193  fPartCont->SetName(GetName());
194  }
195 }
196 
202 {
203  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
204 
205  // Dynamic cast to see if event if ESD or AOD
206  fEsdMode = dynamic_cast<AliESDEvent*>(fEvent);
207 
208  // Read in pass. If it is empty, set flag to automatically find the pass from the filename.
209  std::string tempString = "";
210  GetProperty("pass", tempString);
211  fFilepass = tempString.c_str();
212  if(fFilepass != "")
213  fGetPassFromFileName = kFALSE;
214 
215  // Output
216  fOutput = new AliEmcalList();
217  fOutput->SetOwner();
218 
219  return kTRUE;
220 }
221 
227 {
228  // Initialize using ExecOnce()
229  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
230 }
231 
237 {
238  // Run
239  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
240 
242  GetPass();
243 
244  return kTRUE;
245 }
246 
252 {
253  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
254  return kTRUE;
255 }
256 
265 void AliEmcalCorrectionComponent::GetEtaPhiDiff(const AliVTrack *t, const AliVCluster *v, Double_t &phidiff, Double_t &etadiff)
266 {
267  phidiff = 999;
268  etadiff = 999;
269 
270  if (!t||!v) return;
271 
272  Double_t veta = t->GetTrackEtaOnEMCal();
273  Double_t vphi = t->GetTrackPhiOnEMCal();
274 
275  Float_t pos[3] = {0};
276  v->GetPosition(pos);
277  TVector3 cpos(pos);
278  Double_t ceta = cpos.Eta();
279  Double_t cphi = cpos.Phi();
280  etadiff=veta-ceta;
281  phidiff=TVector2::Phi_mpi_pi(vphi-cphi);
282 }
283 
289 {
290 
291  if (!fEvent) return ;
292 
293  Int_t bunchCrossNo = fEvent->GetBunchCrossNumber();
294 
295  if (fRecoUtils)
296  fRecoUtils->RecalibrateCells(fCaloCells, bunchCrossNo);
297 
298  fCaloCells->Sort();
299 }
300 
305 {
306  // Get run number.
307  return fRun != fEvent->GetRunNumber();
308 }
309 
310 
321 {
322  std::size_t sharedParameterLocation = value.find("sharedParameters:");
323  if (sharedParameterLocation != std::string::npos)
324  {
325  // "sharedParameters:" is 17 characters long
326  value.erase(sharedParameterLocation, sharedParameterLocation + 17);
327  return true;
328  }
329  // Return false otherwise
330  return false;
331 }
332 
338 {
339  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
340  TTree *inputTree = mgr->GetTree();
341 
342  if (!inputTree)
343  {
344  AliError("Pointer to tree = 0, returning");
345  return;
346  }
347 
348  TFile *inputFile = inputTree->GetCurrentFile();
349  if (!inputFile) {
350  AliError("Null pointer input file, returning");
351  return;
352  }
353 
354  TString fname(inputFile->GetName());
355  if (fname.Contains("pass1")) fFilepass = TString("pass1");
356  else if (fname.Contains("pass2")) fFilepass = TString("pass2");
357  else if (fname.Contains("pass3")) fFilepass = TString("pass3");
358  else if (fname.Contains("pass4")) fFilepass = TString("pass4");
359  else if (fname.Contains("pass5")) fFilepass = TString("pass5");
360  else if (fname.Contains("LHC11c") &&
361  fname.Contains("spc_calo")) fFilepass = TString("spc_calo");
362  else if (fname.Contains("calo") || fname.Contains("high_lumi"))
363 
364  {
365  //printf("AliEMCALTenderSupply::GetPass() - Path contains <calo> or <high-lumi>, set as <pass1>\n");
366  fFilepass = TString("pass1");
367  }
368  else if (fname.Contains("LHC14a1a"))
369  {
370  AliInfo("Energy calibration activated for this MC production!");
371  fFilepass = TString("LHC14a1a");
372  }
373  else
374  {
375  AliError(Form("Pass number string not found: %s", fname.Data()));
376  return;
377  }
378 }
379 
384  TString name = h->GetName();
385 
386  Short_t absId =-1;
387  Double_t ecell = 0;
388  Double_t tcell = 0;
389  Double_t efrac = 0;
390  Int_t mclabel = -1;
391 
392  for (Int_t iCell = 0; iCell < fCaloCells->GetNumberOfCells(); iCell++){
393 
394  fCaloCells->GetCell(iCell, absId, ecell, tcell, mclabel, efrac);
395  if(name.Contains("Energy")){
396  h->Fill(ecell);
397  }
398  else if(name.Contains("Time")){
399  h->Fill(tcell);
400  }
401 
402  }
403 
404 }
void AddContainer(inputObjectType type)
static std::string DetermineUseDefaultName(inputObjectType contType, Bool_t esdMode)
double Double_t
Definition: External.C:58
Container with name, TClonesArray and cuts for particles.
AliVCaloCells * fCaloCells
! pointer to calo cells
AliEMCALRecoUtils * fRecoUtils
! pointer to reco utils
AliClusterContainer * fClusCont
! pointer to the cluster container
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
void GetProperty(std::string propertyName, T &property, bool requiredProperty=true, std::string correctionName="")
Retrieve property.
std::map< std::string, AliEmcalCorrectionComponent *(*)()> map_type
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:23
static bool IsSharedValue(std::string &value)
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
void GetEtaPhiDiff(const AliVTrack *t, const AliVCluster *v, Double_t &phidiff, Double_t &etadiff)
bool Bool_t
Definition: External.C:53
AliParticleContainer * fPartCont
! pointer to the track/particle container
Container structure for EMCAL clusters.
Container for MC-true particles within the EMCAL framework.