AliPhysics  7273240 (7273240)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskChargedParticlesRefMC.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2015, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 #include <iostream>
16 #include <memory>
17 
18 #include <TArrayD.h>
19 #include <TChain.h>
20 #include <TClonesArray.h>
21 #include <TFile.h>
22 #include <THashList.h>
23 #include <TH1.h>
24 #include <THistManager.h>
25 #include <TKey.h>
26 #include <TList.h>
27 #include <TPDGCode.h>
28 #include <TProfile.h>
29 #include <TMath.h>
30 #include <TString.h>
31 #include <TSystem.h>
32 #include <TTree.h>
33 
34 #include "AliAnalysisManager.h"
35 #include "AliAnalysisUtils.h"
36 #include "AliAODMCHeader.h"
37 #include "AliAODInputHandler.h"
38 #include "AliAODMCParticle.h"
39 #include "AliAODTrack.h"
41 #include "AliEmcalTrackSelection.h"
43 #include "AliEMCALTriggerPatchInfo.h"
44 #include "AliEMCALGeometry.h"
45 #include "AliEMCALRecoUtils.h"
46 #include "AliESDEvent.h"
47 #include "AliESDtrack.h"
48 #include "AliGenPythiaEventHeader.h"
49 #include "AliInputEventHandler.h"
50 #include "AliMCEvent.h"
51 #include "AliOADBContainer.h"
52 #include "AliVVertex.h"
53 
56 
60 
61 namespace EMCalTriggerPtAnalysis {
62 
63 AliAnalysisTaskChargedParticlesRefMC::AliAnalysisTaskChargedParticlesRefMC():
65  fTrackCuts(nullptr),
66  fTriggerSelection(nullptr),
67  fHistos(nullptr),
68  fWeightHandler(nullptr),
69  fEventTriggers(),
70  fEventWeight(1.),
71  fYshift(0.465),
72  fEtaSign(1),
73  fEtaLabCut(-0.5, 0.5),
74  fEtaCmsCut(-0.13, 0.13),
75  fPhiCut(0., TMath::TwoPi()),
76  fFracPtHard(-1),
77  fNameAcceptanceOADB()
78 {
79  SetCaloTriggerPatchInfoName("EmcalTriggers");
80  SetNeedEmcalGeom(true);
81 }
82 
84  AliAnalysisTaskEmcal(name, true),
85  fTrackCuts(nullptr),
86  fTriggerSelection(nullptr),
87  fHistos(nullptr),
88  fWeightHandler(nullptr),
89  fEventTriggers(),
90  fEventWeight(1.),
91  fYshift(0.465),
92  fEtaSign(1),
93  fEtaLabCut(-0.5, 0.5),
94  fEtaCmsCut(-0.13, 0.13),
95  fPhiCut(0., TMath::TwoPi()),
96  fFracPtHard(-1),
97  fNameAcceptanceOADB()
98 {
99  SetCaloTriggerPatchInfoName("EmcalTriggers");
100  SetNeedEmcalGeom(true);
101 }
102 
104  //if(fTrackCuts) delete fTrackCuts;
105  if(fTriggerSelection) delete fTriggerSelection;
106  if(fHistos) delete fHistos;
107 }
108 
111 
112  if(!fAliAnalysisUtils) fAliAnalysisUtils = new AliAnalysisUtils;
113  fHistos = new THistManager("Ref");
114 
115  if(!fTrackCuts) InitializeTrackCuts("standard",fInputHandler->IsA() == AliAODInputHandler::Class());
116 
117  PtBinning newbinning;
118 
119  fHistos->CreateTH1("hPtHard", "Pt of the hard interaction", 1000, 0., 500);
120  TString triggers[7] = {"True", "MB", "EMC7", "EJ1", "EJ2", "EG1", "EG2"};
121  Double_t ptcuts[5] = {1., 2., 5., 10., 20.};
122  TString species[6] = {"El", "Mu", "Pi", "Ka", "Pr", "Ot"};
123  for(TString *trg = triggers; trg < triggers + sizeof(triggers)/sizeof(TString); trg++){
124  fHistos->CreateTH1(Form("hEventCount%s", trg->Data()), Form("Event Counter for trigger class %s", trg->Data()), 1, 0.5, 1.5);
125  fHistos->CreateTH1(Form("hVertexBefore%s", trg->Data()), Form("Vertex distribution before z-cut for trigger class %s", trg->Data()), 500, -50, 50);
126  fHistos->CreateTH1(Form("hVertexAfter%s", trg->Data()), Form("Vertex distribution after z-cut for trigger class %s", trg->Data()), 100, -10, 10);
127  fHistos->CreateTH1(Form("hPtEtaAll%s", trg->Data()), Form("Charged particle pt distribution all eta trigger %s", trg->Data()), newbinning);
128  fHistos->CreateTH1(Form("hPtEtaCent%s", trg->Data()), Form("Charged particle pt distribution central eta trigger %s", trg->Data()), newbinning);
129  fHistos->CreateTH1(Form("hPtEMCALEtaAll%s", trg->Data()), Form("Charged particle in EMCAL pt distribution all eta trigger %s", trg->Data()), newbinning);
130  fHistos->CreateTH1(Form("hPtEMCALEtaCent%s", trg->Data()), Form("Charged particle in EMCAL pt distribution central eta trigger %s", trg->Data()), newbinning);
131  fHistos->CreateTH1(Form("hPtEMCALNoTRDEtaAll%s", trg->Data()), Form("Charged particle in EMCAL (no TRD in front) pt distribution all eta trigger %s", trg->Data()), newbinning);
132  fHistos->CreateTH1(Form("hPtEMCALNoTRDEtaCent%s", trg->Data()), Form("Charged particle in EMCAL (no TRD in front) pt distribution central eta trigger %s", trg->Data()), newbinning);
133  fHistos->CreateTH1(Form("hPtEMCALWithTRDEtaAll%s", trg->Data()), Form("Charged particle in EMCAL (with TRD in front) pt distribution all eta trigger %s", trg->Data()), newbinning);
134  fHistos->CreateTH1(Form("hPtEMCALWithTRDEtaCent%s", trg->Data()), Form("Charged particle in EMCAL (with TRD in front) pt distribution central eta trigger %s", trg->Data()), newbinning);
135  for(TString *piditer = species; piditer < species + sizeof(species)/sizeof(TString); ++piditer){
136  fHistos->CreateTH1(Form("hPtEtaAll%s%s", piditer->Data(), trg->Data()), Form("Charged %s pt distribution all eta trigger %s", piditer->Data(), trg->Data()), newbinning);
137  fHistos->CreateTH1(Form("hPtEtaCent%s%s", piditer->Data(), trg->Data()), Form("Charged %s pt distribution central eta trigger %s", piditer->Data(), trg->Data()), newbinning);
138  fHistos->CreateTH1(Form("hPtEMCALEtaAll%s%s", piditer->Data(), trg->Data()), Form("Charged %s in EMCAL pt distribution all eta trigger %s", piditer->Data(), trg->Data()), newbinning);
139  fHistos->CreateTH1(Form("hPtEMCALEtaCent%s%s", piditer->Data(), trg->Data()), Form("Charged %s in EMCAL pt distribution central eta trigger %s", piditer->Data(), trg->Data()), newbinning);
140  fHistos->CreateTH1(Form("hPtEMCALNoTRDEtaAll%s%s", piditer->Data(), trg->Data()), Form("Charged %s in EMCAL (no TRD in front) pt distribution all eta trigger %s", piditer->Data(), trg->Data()), newbinning);
141  fHistos->CreateTH1(Form("hPtEMCALNoTRDEtaCent%s%s", piditer->Data(), trg->Data()), Form("Charged %s in EMCAL (no TRD in front) pt distribution central eta trigger %s", piditer->Data(), trg->Data()), newbinning);
142  fHistos->CreateTH1(Form("hPtEMCALWithTRDEtaAll%s%s", piditer->Data(), trg->Data()), Form("Charged %s in EMCAL (with TRD in front) pt distribution all eta trigger %s", piditer->Data(), trg->Data()), newbinning);
143  fHistos->CreateTH1(Form("hPtEMCALWithTRDEtaCent%s%s", piditer->Data(), trg->Data()), Form("Charged %s in EMCAL (with TRD in front) pt distribution central eta trigger %s", piditer->Data(), trg->Data()), newbinning);
144  }
145  for(int ipt = 0; ipt < 5; ipt++){
146  fHistos->CreateTH1(
147  Form("hEtaLabDistAllPt%d%s", static_cast<Int_t>(ptcuts[ipt]), trg->Data()),
148  Form("Eta (lab) distribution without etacut for tracks with Pt above %.1f GeV/c trigger %s", ptcuts[ipt], trg->Data()),
149  100,
150  -1.,
151  1.
152  );
153  fHistos->CreateTH1(
154  Form("hEtaLabDistCutPt%d%s", static_cast<Int_t>(ptcuts[ipt]), trg->Data()),
155  Form("Eta (lab) distribution with etacut for tracks with Pt above %.1f GeV/c trigger %s", ptcuts[ipt], trg->Data()),
156  100,
157  -1.,
158  1.
159  );
160  fHistos->CreateTH1(
161  Form("hEtaCentDistAllPt%d%s", static_cast<Int_t>(ptcuts[ipt]), trg->Data()),
162  Form("Eta (cent) distribution without etacut for tracks with Pt above %.1f GeV/c trigger %s", ptcuts[ipt], trg->Data()),
163  160,
164  -1.3,
165  1.3
166  );
167  fHistos->CreateTH1(
168  Form("hEtaCentDistCutPt%d%s", static_cast<Int_t>(ptcuts[ipt]), trg->Data()),
169  Form("Eta (cent) distribution with etacut for tracks with Pt above %.1f GeV/c trigger %s", ptcuts[ipt], trg->Data()),
170  160,
171  -1.3,
172  1.3
173  );
174  fHistos->CreateTH1(
175  Form("hEtaLabDistAllEMCALPt%d%s", static_cast<Int_t>(ptcuts[ipt]), trg->Data()),
176  Form("Eta (lab) distribution without etacut for tracks in EMCAL with Pt above %.1f GeV/c trigger %s", ptcuts[ipt], trg->Data()),
177  100,
178  -1.,
179  1.
180  );
181  fHistos->CreateTH1(
182  Form("hEtaLabDistCutEMCALPt%d%s", static_cast<Int_t>(ptcuts[ipt]), trg->Data()),
183  Form("Eta (lab) distribution with etacut for tracks in EMCAL with Pt above %.1f GeV/c trigger %s", ptcuts[ipt], trg->Data()),
184  100,
185  -1.,
186  1.
187  );
188  fHistos->CreateTH1(
189  Form("hEtaCentDistAllEMCALPt%d%s", static_cast<Int_t>(ptcuts[ipt]), trg->Data()),
190  Form("Eta (cent) distribution without etacut for tracks in EMCAL with Pt above %.1f GeV/c trigger %s", ptcuts[ipt], trg->Data()),
191  160,
192  -1.3,
193  1.3
194  );
195  fHistos->CreateTH1(
196  Form("hEtaCentDistCutEMCALPt%d%s", static_cast<Int_t>(ptcuts[ipt]), trg->Data()),
197  Form("Eta (cent) distribution with etacut for tracks in EMCAL with Pt above %.1f GeV/c trigger %s", ptcuts[ipt], trg->Data()),
198  160,
199  -1.3,
200  1.3
201  );
202  fHistos->CreateTH1(
203  Form("hPhiDistAllPt%d%s", static_cast<Int_t>(ptcuts[ipt]), trg->Data()),
204  Form("#phi distribution of particles with Pt above %.1f GeV/c trigger %s", ptcuts[ipt], trg->Data()),
205  300,
206  0.,
207  2*TMath::Pi()
208  );
209  }
210  }
211  //fHistos->GetListOfHistograms()->Add(fTrackCuts);
212  for(auto hist : *(fHistos->GetListOfHistograms())){
213  fOutput->Add(hist);
214  }
215 
216  PostData(1, fOutput);
217 }
218 
220  fEventTriggers.clear();
221  AliDebugStream(1) << GetName() << ": Using custom event selection" << std::endl;
222  if(!MCEvent()) return false;
223  if(!fTriggerPatchInfo) return false;
224  fEventWeight = fWeightHandler ? fWeightHandler->GetEventWeight(fPythiaHeader) : 1.;
225 
226  // Do MC outlier cut
227  if(fIsPythia){
228  if(!CheckMCOutliers()) return false;
229  }
230 
231 
232  // select trigger
233  bool isMinBias;
234  if((isMinBias = fInputHandler->IsEventSelected() & AliVEvent::kINT7)) fEventTriggers.push_back("MB");
235  // In simulations triggered events are a subset of min. bias events
236  if(fTriggerPatchInfo && fTriggerSelection){
237  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEL0, fTriggerPatchInfo))
238  fEventTriggers.push_back("EMC7"); // triggerstring.Contains("EMC7"),
239  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEJ1, fTriggerPatchInfo))
240  fEventTriggers.push_back("EJ1"); // triggerstring.Contains("EJ1"),
241  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEJ2, fTriggerPatchInfo))
242  fEventTriggers.push_back("EJ2"); // triggerstring.Contains("EJ2"),
243  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEG1, fTriggerPatchInfo))
244  fEventTriggers.push_back("EG1"); // triggerstring.Contains("EG1"),
245  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEG2, fTriggerPatchInfo))
246  fEventTriggers.push_back("EG2"); // triggerstring.Contains("EG2");
247  }
248  if(!fEventTriggers.size()){
249  AliDebugStream(1) << GetName() << ": No trigger selected" << std::endl;
250  }
251 
252  const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
253  if(vtx->GetNContributors() < 1) return false;
254  if(!fAliAnalysisUtils->IsVertexSelected2013pA(fInputEvent)) return false; // Apply new vertex cut
255  if(fAliAnalysisUtils->IsPileUpEvent(fInputEvent)) return false; // Apply new vertex cut
256  // Fill reference distribution for the primary vertex before any z-cut
257  fHistos->FillTH1("hVertexBeforeTrue", vtx->GetZ(), fEventWeight);
258  for(const auto &trg : fEventTriggers) fHistos->FillTH1(Form("hVertexBefore%s", trg.c_str()), vtx->GetZ(), fEventWeight);
259  // Apply vertex z cut
260  if(vtx->GetZ() < -10. || vtx->GetZ() > 10.) return false;
261 
262 
263  // Fill Event counter and reference vertex distributions for the different trigger classes
264  fHistos->FillTH1("hEventCountTrue", 1, fEventWeight);
265  fHistos->FillTH1("hVertexAfterTrue", vtx->GetZ(), fEventWeight);
266  for(const auto &trg : fEventTriggers){
267  fHistos->FillTH1(Form("hEventCount%s", trg.c_str()), 1, fEventWeight);
268  fHistos->FillTH1(Form("hVertexAfter%s", trg.c_str()), vtx->GetZ(), fEventWeight);
269  }
270 
271  return true;
272 }
273 
276 
277  if(!fLocalInitialized) {
278  AliErrorStream() << GetName() << ": Failed initializing AliAnalysisTaskEmcal" << std::endl;
279  return;
280  }
281 
282  // Load acceptance OADB
283  if(fNameAcceptanceOADB.Length() && fTriggerSelection){
284  AliDebugStream(1) << GetName() << ": Loading acceptance map from OADB file " << fNameAcceptanceOADB << std::endl;
285  AliOADBContainer acceptanceCont("AliEmcalTriggerAcceptance");
286  acceptanceCont.InitFromFile(fNameAcceptanceOADB.Data(), "AliEmcalTriggerAcceptance");
287  TObjArray *acceptanceMaps = dynamic_cast<TObjArray *>(acceptanceCont.GetObject(fInputEvent->GetRunNumber()));
288  TH2 *map(nullptr);
289  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("EG1")))){
290  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger EG1" << std::endl;
291  map->SetDirectory(nullptr);
292  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgEG1, map);
293  }
294  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("EG2")))){
295  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger EG2" << std::endl;
296  map->SetDirectory(nullptr);
297  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgEG2, map);
298  }
299  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("DG1")))){
300  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger DG1" << std::endl;
301  map->SetDirectory(nullptr);
302  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgDG1, map);
303  }
304  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("DG2")))){
305  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger DG2" << std::endl;
306  map->SetDirectory(nullptr);
307  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgDG1, map);
308  }
309  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("EJ1")))){
310  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger EJ1" << std::endl;
311  map->SetDirectory(nullptr);
312  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgEJ1, map);
313  }
314  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("EJ2")))){
315  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger EJ2" << std::endl;
316  map->SetDirectory(nullptr);
317  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgEJ2, map);
318  }
319  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("DJ1")))){
320  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger DJ1" << std::endl;
321  map->SetDirectory(nullptr);
322  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgDJ1, map);
323  }
324  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("DJ2")))){
325  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger DJ2" << std::endl;
326  map->SetDirectory(nullptr);
327  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgDJ1, map);
328  }
329  }
330 }
331 
333  // MonteCarlo Loop
334  // Histograms
335  // - Full eta (-0.8, 0.8), new binning
336  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c without eta cut
337  // - Central eta_{cms} (-0.3, 0.3), new binning,
338  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c
339  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c with eta cut
340  AliVParticle *truepart = NULL;
341  Bool_t isEMCAL(kFALSE);
342  for(int ipart = 0; ipart < fMCEvent->GetNumberOfTracks(); ipart++){
343  truepart = fMCEvent->GetTrack(ipart);
344 
345  // Select only particles within ALICE acceptance
346  if(!fEtaLabCut.IsInRange(truepart->Eta())) continue;
347  if(!fPhiCut.IsInRange(truepart->Phi())) continue;
348  if(TMath::Abs(truepart->Pt()) < 0.1) continue;
349  if(!truepart->Charge()) continue;
350 
351  if(!IsPhysicalPrimary(truepart, fMCEvent)) continue;
352  isEMCAL = (truepart->Phi() > 1.5 && truepart->Phi() < 3.1) ? kTRUE : kFALSE;
353 
354  // Calculate eta in cms frame according
355  // EPJC74 (2014) 3054:
356  // eta_cms = - eta_lab - |yshift|
357  Double_t etacent = -1. * truepart->Eta() - TMath::Abs(fYshift);
358  etacent *= fEtaSign;
359 
360  Bool_t etacentcut = fEtaCmsCut.IsInRange(etacent);
361 
362  // Get PID
363  TString pid = "";
364  switch(TMath::Abs(truepart->PdgCode())){
365  case kPiPlus: pid = "Pi"; break;
366  case kMuonMinus: pid = "Mu"; break;
367  case kElectron: pid = "El"; break;
368  case kKPlus: pid = "Ka"; break;
369  case kProton: pid = "Pr"; break;
370  default: pid = "Ot"; break;
371  };
372 
373  // Particle selected (do not filter TRD sectors for MC truth)
374  FillTrackHistos("True", fEventWeight, truepart->Pt(), truepart->Eta() * fEtaSign, etacent, truepart->Phi(), etacentcut, isEMCAL, kFALSE, pid);
375  }
376 
377  // Loop over tracks, fill select particles
378  // Histograms
379  // - Full eta (-0.8, 0.8), new binning
380  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c without eta cut
381  // - Central eta (-0.8, -0.2), new binning,
382  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c
383  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c with eta cut
384  AliVTrack *checktrack(NULL);
385  AliVParticle *assocMC(NULL);
386  double ptparticle(-1.), etaparticle(-100.), etaEMCAL(0.), phiEMCAL(0.);
387  Bool_t hasTRD = kFALSE;
388  for(int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
389  checktrack = dynamic_cast<AliVTrack *>(fInputEvent->GetTrack(itrk));
390  if(!checktrack) continue;
391  // Find associated particle
392  assocMC = fMCEvent->GetTrack(TMath::Abs(checktrack->GetLabel()));
393  if(!assocMC) continue; // Fake track
394  if(!IsPhysicalPrimary(assocMC, fMCEvent)) continue;
395 
396  // Select only particles within ALICE acceptance
397  if(!fEtaLabCut.IsInRange(checktrack->Eta())) continue;
398  if(!fPhiCut.IsInRange(checktrack->Phi())) continue;
399  if(TMath::Abs(checktrack->Pt()) < 0.1) continue;
400  if(checktrack->IsA() == AliESDtrack::Class()){
401  AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
402  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
403  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
404  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
405  } else {
406  AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
407  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
408  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
409  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
410  }
411  Int_t supermoduleID = -1;
412  isEMCAL = fGeom->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
413  // Exclude supermodules 10 and 11 as they did not participate in the trigger
414  isEMCAL = isEMCAL && supermoduleID < 10;
415  hasTRD = isEMCAL && supermoduleID >= 4; // supermodules 4 - 10 have TRD in front in the 2012-2013 ALICE setup
416 
417  if(!fTrackCuts->IsTrackAccepted(checktrack)) continue;
418 
419  ptparticle = TMath::Abs(assocMC->Pt());
420  etaparticle = assocMC->Eta();
421 
422  // Calculate eta in cms frame according
423  // EPJC74 (2014) 3054:
424  // eta_cms = - eta_lab - |yshift|
425  Double_t etacent = -1. * checktrack->Eta() - TMath::Abs(fYshift);
426  etacent *= fEtaSign;
427 
428  Bool_t etacentcut = fEtaCmsCut.IsInRange(etacent);
429 
430  // Get PID
431  TString assocpid = "";
432  switch(TMath::Abs(assocMC->PdgCode())){
433  case kPiPlus: assocpid = "Pi"; break;
434  case kMuonMinus: assocpid = "Mu"; break;
435  case kElectron: assocpid = "El"; break;
436  case kKPlus: assocpid = "Ka"; break;
437  case kProton: assocpid = "Pr"; break;
438  default: assocpid = "Ot"; break;
439  };
440  for(const auto &trg : fEventTriggers)
441  FillTrackHistos(trg.c_str(), fEventWeight, ptparticle, checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, hasTRD, assocpid);
442  }
443  return true;
444 }
445 
446 void AliAnalysisTaskChargedParticlesRefMC::FillTrackHistos(
447  const char *eventclass,
448  Double_t weight,
449  Double_t pt,
450  Double_t etalab,
451  Double_t etacent,
452  Double_t phi,
453  Bool_t etacut,
454  Bool_t inEmcal,
455  Bool_t hasTRD,
456  const char *pid
457  )
458 {
459  fHistos->FillTH1(Form("hPtEtaAll%s", eventclass), TMath::Abs(pt), weight);
460  fHistos->FillTH1(Form("hPtEtaAll%s%s", pid, eventclass), TMath::Abs(pt), weight);
461  if(inEmcal){
462  fHistos->FillTH1(Form("hPtEMCALEtaAll%s", eventclass), TMath::Abs(pt), weight);
463  fHistos->FillTH1(Form("hPtEMCALEtaAll%s%s", pid, eventclass), TMath::Abs(pt), weight);
464  if(hasTRD){
465  fHistos->FillTH1(Form("hPtEMCALWithTRDEtaAll%s", eventclass), TMath::Abs(pt), weight);
466  fHistos->FillTH1(Form("hPtEMCALWithTRDEtaAll%s%s", pid, eventclass), TMath::Abs(pt), weight);
467  } else {
468  fHistos->FillTH1(Form("hPtEMCALNoTRDEtaAll%s", eventclass), TMath::Abs(pt), weight);
469  fHistos->FillTH1(Form("hPtEMCALNoTRDEtaAll%s%s", pid, eventclass), TMath::Abs(pt), weight);
470  }
471  }
472 
473  int ptmin[5] = {1,2,5,10,20}; // for eta distributions
474  for(int icut = 0; icut < 5; icut++){
475  if(TMath::Abs(pt) > static_cast<double>(ptmin[icut])){
476  fHistos->FillTH1(Form("hPhiDistAllPt%d%s", ptmin[icut], eventclass), phi, weight);
477  fHistos->FillTH1(Form("hEtaLabDistAllPt%d%s", ptmin[icut], eventclass), etalab, weight);
478  fHistos->FillTH1(Form("hEtaCentDistAllPt%d%s", ptmin[icut], eventclass), etacent, weight);
479  if(inEmcal){
480  fHistos->FillTH1(Form("hEtaLabDistAllEMCALPt%d%s", ptmin[icut], eventclass), etalab, weight);
481  fHistos->FillTH1(Form("hEtaCentDistAllEMCALPt%d%s", ptmin[icut], eventclass), etacent, weight);
482  }
483  }
484  }
485 
486  if(etacut){
487  fHistos->FillTH1(Form("hPtEtaCent%s", eventclass), TMath::Abs(pt), weight);
488  fHistos->FillTH1(Form("hPtEtaCent%s%s", pid, eventclass), TMath::Abs(pt), weight);
489  if(inEmcal){
490  fHistos->FillTH1(Form("hPtEMCALEtaCent%s", eventclass), TMath::Abs(pt), weight);
491  fHistos->FillTH1(Form("hPtEMCALEtaCent%s%s", pid, eventclass), TMath::Abs(pt), weight);
492  if(hasTRD){
493  fHistos->FillTH1(Form("hPtEMCALWithTRDEtaCent%s", eventclass), TMath::Abs(pt), weight);
494  fHistos->FillTH1(Form("hPtEMCALWithTRDEtaCent%s%s", pid, eventclass), TMath::Abs(pt), weight);
495  } else {
496  fHistos->FillTH1(Form("hPtEMCALNoTRDEtaCent%s", eventclass), TMath::Abs(pt), weight);
497  fHistos->FillTH1(Form("hPtEMCALNoTRDEtaCent%s%s", pid, eventclass), TMath::Abs(pt), weight);
498  }
499  }
500  for(int icut = 0; icut < 5; icut++){
501  if(TMath::Abs(pt) > static_cast<double>(ptmin[icut])){
502  fHistos->FillTH1(Form("hEtaLabDistCutPt%d%s", ptmin[icut], eventclass), etalab, weight);
503  fHistos->FillTH1(Form("hEtaCentDistCutPt%d%s", ptmin[icut], eventclass), etacent, weight);
504  if(inEmcal){
505  fHistos->FillTH1(Form("hEtaLabDistCutEMCALPt%d%s", ptmin[icut], eventclass), etalab, weight);
506  fHistos->FillTH1(Form("hEtaCentDistCutEMCALPt%d%s", ptmin[icut], eventclass), etacent, weight);
507  }
508  }
509  }
510  }
511 }
512 
513 
516 }
517 
518 
519 
520 TString AliAnalysisTaskChargedParticlesRefMC::GetFiredTriggerClasses(const TClonesArray* triggerpatches) {
521  TString triggerstring = "";
522  Int_t nEJ1 = 0, nEJ2 = 0, nEG1 = 0, nEG2 = 0;
523  double minADC_EJ1 = 260.,
524  minADC_EJ2 = 127.,
525  minADC_EG1 = 140.,
526  minADC_EG2 = 89.;
527  for(TIter patchIter = TIter(triggerpatches).Begin(); patchIter != TIter::End(); ++patchIter){
528  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(*patchIter);
529  if(!patch->IsOfflineSimple()) continue;
530  if(patch->IsJetHighSimple() && patch->GetADCOfflineAmp() > minADC_EJ1) nEJ1++;
531  if(patch->IsJetLowSimple() && patch->GetADCOfflineAmp() > minADC_EJ2) nEJ2++;
532  if(patch->IsGammaHighSimple() && patch->GetADCOfflineAmp() > minADC_EG1) nEG1++;
533  if(patch->IsGammaLowSimple() && patch->GetADCOfflineAmp() > minADC_EG2) nEG2++;
534  }
535  if(nEJ1) triggerstring += "EJ1";
536  if(nEJ2){
537  if(triggerstring.Length()) triggerstring += ",";
538  triggerstring += "EJ2";
539  }
540  if(nEG1){
541  if(triggerstring.Length()) triggerstring += ",";
542  triggerstring += "EG1";
543  }
544  if(nEG2){
545  if(triggerstring.Length()) triggerstring += ",";
546  triggerstring += "EG2";
547  }
548  return triggerstring;
549 }
550 
551 Bool_t AliAnalysisTaskChargedParticlesRefMC::IsPhysicalPrimary(const AliVParticle* const part, AliMCEvent* const mcevent) {
552  Bool_t physprim = false;
553  const AliAODMCParticle *aodmc = dynamic_cast<const AliAODMCParticle *>(part);
554  if(aodmc){
555  physprim = aodmc->IsPhysicalPrimary();
556  } else {
557  physprim = mcevent->IsPhysicalPrimary(part->GetLabel());
558  }
559  return physprim;
560 }
561 
565 AliAnalysisTaskChargedParticlesRefMC::PtBinning::PtBinning() :
567 {
568  this->SetMinimum(0.);
569  this->AddStep(1, 0.05);
570  this->AddStep(2, 0.1);
571  this->AddStep(4, 0.2);
572  this->AddStep(7, 0.5);
573  this->AddStep(16, 1);
574  this->AddStep(36, 2);
575  this->AddStep(40, 4);
576  this->AddStep(50, 5);
577  this->AddStep(100, 10);
578  this->AddStep(200, 20);
579 }
580 
581 } /* namespace EMCalTriggerPtAnalysis */
Bool_t fIsPythia
trigger, if it is a PYTHIA production
double Double_t
Definition: External.C:58
static AliEmcalTrackSelection * TrackCutsFactory(TString name, Bool_t isAOD)
Base task in the EMCAL framework.
Bool_t fLocalInitialized
whether or not the task has been already initialized
void SetCaloTriggerPatchInfoName(const char *n)
int Int_t
Definition: External.C:63
AliEMCALGeometry * fGeom
!emcal geometry
AliGenPythiaEventHeader * fPythiaHeader
!event Pythia header
AliAnalysisUtils * fAliAnalysisUtils
!vertex selection (optional)
Helper class creating user defined custom binning.
const Double_t ptmin
Test class for charged particle distributions (MC case)
virtual Bool_t IsEventSelected()
AliEmcalList * fOutput
!output list
Definition: External.C:220
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
TClonesArray * fTriggerPatchInfo
!trigger patch info array
void SetNeedEmcalGeom(Bool_t n)
Container class for histograms for the high- charged particle analysis.
Definition: THistManager.h:43
bool Bool_t
Definition: External.C:53