AliPhysics  1811c8f (1811c8f)
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 <array>
16 #include <iostream>
17 #include <memory>
18 
19 #include <TClonesArray.h>
20 #include <THashList.h>
21 #include <TH1.h>
22 #include <THistManager.h>
23 #include <TLinearBinning.h>
24 #include <TList.h>
25 #include <TPDGCode.h>
26 #include <TMath.h>
27 #include <TString.h>
28 
29 #include "AliAnalysisDataContainer.h"
30 #include "AliAnalysisManager.h"
31 #include "AliAnalysisUtils.h"
32 #include "AliAODMCHeader.h"
33 #include "AliAODInputHandler.h"
34 #include "AliAODMCParticle.h"
35 #include "AliAODTrack.h"
37 #include "AliEmcalList.h"
38 #include "AliEmcalTrackSelection.h"
40 #include "AliEMCALTriggerPatchInfo.h"
41 #include "AliEMCALGeometry.h"
42 #include "AliEMCALRecoUtils.h"
43 #include "AliESDEvent.h"
44 #include "AliESDtrack.h"
45 #include "AliGenPythiaEventHeader.h"
46 #include "AliInputEventHandler.h"
47 #include "AliMCEvent.h"
48 #include "AliOADBContainer.h"
49 #include "AliVEvent.h"
50 #include "AliVEventHandler.h"
51 #include "AliVVertex.h"
52 
55 
59 
60 namespace EMCalTriggerPtAnalysis {
61 
62 AliAnalysisTaskChargedParticlesRefMC::AliAnalysisTaskChargedParticlesRefMC():
64  fTrackCuts(nullptr),
65  fTriggerSelection(nullptr),
66  fHistos(nullptr),
67  fWeightHandler(nullptr),
68  fEventTriggers(),
69  fEventWeight(1.),
70  fYshift(0.465),
71  fEtaSign(1),
72  fMinPt(0.1),
73  fEtaLabCut(-0.5, 0.5),
74  fEtaCmsCut(-2., 2.),
75  fPhiCut(0., TMath::TwoPi()),
76  fFracPtHard(-1),
77  fEnableSumw2(kFALSE),
78  fStudyPID(kFALSE),
79  fStudyEMCALgeo(false),
80  fExclusiveMinBias(false),
81  fRequireTOFBunchCrossing(false),
82  fNameAcceptanceOADB()
83 {
84  SetCaloTriggerPatchInfoName("EmcalTriggers");
85  SetNeedEmcalGeom(true);
87 }
88 
90  AliAnalysisTaskEmcal(name, true),
91  fTrackCuts(nullptr),
92  fTriggerSelection(nullptr),
93  fHistos(nullptr),
94  fWeightHandler(nullptr),
95  fEventTriggers(),
96  fEventWeight(1.),
97  fYshift(0.465),
98  fEtaSign(1),
99  fMinPt(0.1),
100  fEtaLabCut(-0.5, 0.5),
101  fEtaCmsCut(-2., 2.),
102  fPhiCut(0., TMath::TwoPi()),
103  fFracPtHard(-1),
104  fEnableSumw2(kFALSE),
105  fStudyPID(kFALSE),
106  fStudyEMCALgeo(false),
107  fExclusiveMinBias(false),
108  fRequireTOFBunchCrossing(false),
109  fNameAcceptanceOADB()
110 {
111  SetCaloTriggerPatchInfoName("EmcalTriggers");
112  SetNeedEmcalGeom(true);
114 }
115 
117  //if(fTrackCuts) delete fTrackCuts;
118  if(fTriggerSelection) delete fTriggerSelection;
119  if(fHistos) delete fHistos;
120 }
121 
124 
125  if(!fAliAnalysisUtils) fAliAnalysisUtils = new AliAnalysisUtils;
126  fHistos = new THistManager("Ref");
127 
128  if(!fTrackCuts) InitializeTrackCuts("standard",fInputHandler->IsA() == AliAODInputHandler::Class());
129  fTrackCuts->SaveQAObjects(fOutput);
130 
131  PtBinning newbinning;
132  TLinearBinning etabinning(64, -0.8, 0.8), phibinning(100, 0., 2*TMath::Pi()), chargebinning(2, -1.5, 1.5), primarybinning(2, -0.5, 1.5);
133  const TBinning *binning5D[5] = {&newbinning, &etabinning, &phibinning, &chargebinning, &primarybinning};
134 
135  TString optionstring = fEnableSumw2 ? "s" : "";
136 
137  fHistos->CreateTH1("hPtHard", "Pt of the hard interaction", 1000, 0., 500);
138  const std::array<TString,6> species = {{"El", "Mu", "Pi", "Ka", "Pr", "Ot"}};
139  std::vector<TString> triggers = {"True", "MB"};
140  if(!fExclusiveMinBias){
141  const std::array<TString,5> kEMCALtriggers = {{"EMC7", "EJ1", "EJ2", "EG1", "EG2"}};
142  for(const auto &t : kEMCALtriggers) triggers.emplace_back(t);
143  }
144  for(const auto &trg : triggers){
145  fHistos->CreateTH1("hEventCount" + trg, "Event Counter for trigger class " + trg, 1, 0.5, 1.5, optionstring);
146  fHistos->CreateTH1("hVertexBefore" + trg, "Vertex distribution before z-cut for trigger class " + trg, 500, -50, 50, optionstring);
147  fHistos->CreateTH1("hVertexAfter" + trg, "Vertex distribution after z-cut for trigger class " + trg, 100, -10, 10, optionstring);
148 
149  fHistos->CreateTHnSparse("hPtEtaPhiAll" + trg, "p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg + "; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
150  fHistos->CreateTHnSparse("hPtEtaPhiCent" + trg, "p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg + "; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
151  if(fStudyEMCALgeo){
152  fHistos->CreateTHnSparse("hPtEtaPhiEMCALAll" + trg, "p_{t}-#eta-#phi distribution of all accepted tracks pointing to the EMCAL for trigger " + trg + "; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
153  fHistos->CreateTHnSparse("hPtEtaPhiEMCALCent" + trg, "p_{t}-#eta-#phi distribution of all accepted tracks pointing to the EMCAL for trigger " + trg + "; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
154  }
155 
156  if(fStudyPID){
157  for(const auto &pid : species){
158  fHistos->CreateTHnSparse("hPtEtaPhiAll" + pid + trg, "p_{t}-#eta-#phi distribution of all accepted " + pid + " for trigger " + trg + "; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
159  fHistos->CreateTHnSparse("hPtEtaPhiCent" + pid + trg, "p_{t}-#eta-#phi distribution of all accepted " + pid + " for trigger " + trg + "; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
160  if(fStudyEMCALgeo){
161  fHistos->CreateTHnSparse("hPtEtaPhiEMCALAll" + pid + trg, "p_{t}-#eta-#phi distribution of all accepted " + pid + " pointing to the EMCAL for trigger " + trg + "; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
162  fHistos->CreateTHnSparse("hPtEtaPhiEMCALCent" + pid + trg, "p_{t}-#eta-#phi distribution of all accepted " + pid + " pointing to the EMCAL for trigger " + trg + "; p_{t} (GeV/c); #eta; #phi; charge; primary", 5, binning5D, optionstring);
163  }
164  }
165  }
166  }
167  //fHistos->GetListOfHistograms()->Add(fTrackCuts);
168  for(auto hist : *(fHistos->GetListOfHistograms())){
169  fOutput->Add(hist);
170  }
171 
172  PostData(1, fOutput);
173 }
174 
176  fEventTriggers.clear();
177  AliDebugStream(1) << GetName() << ": Using custom event selection" << std::endl;
178  if(!MCEvent()) return false;
179  if(!fExclusiveMinBias && !fTriggerPatchInfo) return false;
180  fEventWeight = fWeightHandler ? fWeightHandler->GetEventWeight(fPythiaHeader) : 1.;
181 
182  // Do MC outlier cut
183  if(fIsPythia){
184  if(!CheckMCOutliers()) return false;
185  }
186 
187  fHistos->FillTH1("hPtHard", fPtHard);
188 
189 
190  // select trigger
191  bool isMinBias;
192  if((isMinBias = fInputHandler->IsEventSelected() & AliVEvent::kINT7)) fEventTriggers.push_back("MB");
193  if(!fExclusiveMinBias){
194  // In simulations triggered events are a subset of min. bias events
195  if(fTriggerPatchInfo && fTriggerSelection){
196  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEL0, fInputEvent))
197  fEventTriggers.push_back("EMC7"); // triggerstring.Contains("EMC7"),
198  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEJ1, fInputEvent))
199  fEventTriggers.push_back("EJ1"); // triggerstring.Contains("EJ1"),
200  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEJ2, fInputEvent))
201  fEventTriggers.push_back("EJ2"); // triggerstring.Contains("EJ2"),
202  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEG1, fInputEvent))
203  fEventTriggers.push_back("EG1"); // triggerstring.Contains("EG1"),
204  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEG2, fInputEvent))
205  fEventTriggers.push_back("EG2"); // triggerstring.Contains("EG2");
206  }
207  }
208  if(!fEventTriggers.size()){
209  AliDebugStream(1) << GetName() << ": No trigger selected" << std::endl;
210  }
211 
212  const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
213  if(vtx->GetNContributors() < 1) return false;
214  if(!fAliAnalysisUtils->IsVertexSelected2013pA(fInputEvent)) return false; // Apply new vertex cut
215  if(fAliAnalysisUtils->IsPileUpEvent(fInputEvent)) return false; // Apply new vertex cut
216  // Fill reference distribution for the primary vertex before any z-cut
217  fHistos->FillTH1("hVertexBeforeTrue", vtx->GetZ(), fEventWeight);
218  for(const auto &trg : fEventTriggers) fHistos->FillTH1("hVertexBefore" + trg, vtx->GetZ(), fEventWeight);
219  // Apply vertex z cut
220  if(vtx->GetZ() < -10. || vtx->GetZ() > 10.) return false;
221 
222 
223  // Fill Event counter and reference vertex distributions for the different trigger classes
224  fHistos->FillTH1("hEventCountTrue", 1, fEventWeight);
225  fHistos->FillTH1("hVertexAfterTrue", vtx->GetZ(), fEventWeight);
226  for(const auto &trg : fEventTriggers){
227  fHistos->FillTH1("hEventCount" + trg, 1, fEventWeight);
228  fHistos->FillTH1("hVertexAfter" + trg, vtx->GetZ(), fEventWeight);
229  }
230 
231  return true;
232 }
233 
236 
237  if(!fLocalInitialized) {
238  AliErrorStream() << GetName() << ": Failed initializing AliAnalysisTaskEmcal" << std::endl;
239  return;
240  }
241 
242  if(fTriggerSelection && !fTriggerSelection->GetNameClusterContainer().Length()){
243  fTriggerSelection->SetClusterContainer(AliEmcalAnalysisFactory::ClusterContainerNameFactory(fInputEvent->IsA() == AliAODEvent::Class()));
244  }
245 
246  // Load acceptance OADB
247  if(fNameAcceptanceOADB.Length() && fTriggerSelection){
248  AliDebugStream(1) << GetName() << ": Loading acceptance map from OADB file " << fNameAcceptanceOADB << std::endl;
249  AliOADBContainer acceptanceCont("AliEmcalTriggerAcceptance");
250  acceptanceCont.InitFromFile(fNameAcceptanceOADB.Data(), "AliEmcalTriggerAcceptance");
251  TObjArray *acceptanceMaps = dynamic_cast<TObjArray *>(acceptanceCont.GetObject(fInputEvent->GetRunNumber()));
252  TH2 *map(nullptr);
253  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("EG1")))){
254  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger EG1" << std::endl;
255  map->SetDirectory(nullptr);
256  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgEG1, map);
257  }
258  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("EG2")))){
259  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger EG2" << std::endl;
260  map->SetDirectory(nullptr);
261  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgEG2, map);
262  }
263  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("DG1")))){
264  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger DG1" << std::endl;
265  map->SetDirectory(nullptr);
266  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgDG1, map);
267  }
268  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("DG2")))){
269  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger DG2" << std::endl;
270  map->SetDirectory(nullptr);
271  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgDG1, map);
272  }
273  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("EJ1")))){
274  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger EJ1" << std::endl;
275  map->SetDirectory(nullptr);
276  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgEJ1, map);
277  }
278  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("EJ2")))){
279  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger EJ2" << std::endl;
280  map->SetDirectory(nullptr);
281  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgEJ2, map);
282  }
283  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("DJ1")))){
284  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger DJ1" << std::endl;
285  map->SetDirectory(nullptr);
286  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgDJ1, map);
287  }
288  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("DJ2")))){
289  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger DJ2" << std::endl;
290  map->SetDirectory(nullptr);
291  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgDJ1, map);
292  }
293  }
294 }
295 
297  // MonteCarlo Loop
298  // Histograms
299  // - Full eta (-0.8, 0.8), new binning
300  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c without eta cut
301  // - Central eta_{cms} (-0.3, 0.3), new binning,
302  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c
303  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c with eta cut
304  AliVParticle *truepart = NULL;
305  Bool_t isEMCAL(kFALSE);
306  for(int ipart = 0; ipart < fMCEvent->GetNumberOfTracks(); ipart++){
307  truepart = fMCEvent->GetTrack(ipart);
308 
309  // Select only particles within ALICE acceptance
310  if(!fEtaLabCut.IsInRange(truepart->Eta())) continue;
311  if(!fPhiCut.IsInRange(truepart->Phi())) continue;
312  if(TMath::Abs(truepart->Pt()) < fMinPt) continue;
313  if(!truepart->Charge()) continue;
314 
315  if(!IsPhysicalPrimary(truepart, fMCEvent)) continue;
316  if(fStudyEMCALgeo) isEMCAL = (truepart->Phi() > 1.5 && truepart->Phi() < 3.1) ? kTRUE : kFALSE;
317 
318  // Calculate eta in cms frame according
319  // EPJC74 (2014) 3054:
320  // eta_cms = - eta_lab - |yshift|
321  Double_t etacent = -1. * truepart->Eta() - TMath::Abs(fYshift);
322  etacent *= fEtaSign;
323 
324  if(!fEtaCmsCut.IsInRange(etacent)) continue; // Apply eta-cent cut
325 
326  // Get PID
327  TString pid = "";
328  if(fStudyPID){
329  switch(TMath::Abs(truepart->PdgCode())){
330  case kPiPlus: pid = "Pi"; break;
331  case kMuonMinus: pid = "Mu"; break;
332  case kElectron: pid = "El"; break;
333  case kKPlus: pid = "Ka"; break;
334  case kProton: pid = "Pr"; break;
335  default: pid = "Ot"; break;
336  };
337  }
338 
339  // Particle selected (do not filter TRD sectors for MC truth)
340  FillTrackHistos("True", fEventWeight, truepart->Charge() > 0, truepart->Pt(), truepart->Eta() * fEtaSign, etacent, truepart->Phi(), isEMCAL, true, pid);
341  }
342 
343  // Loop over tracks, fill select particles
344  // Histograms
345  // - Full eta (-0.8, 0.8), new binning
346  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c without eta cut
347  // - Central eta (-0.8, -0.2), new binning,
348  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c
349  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c with eta cut
350  AliVTrack *checktrack(NULL);
351  AliVParticle *assocMC(NULL);
352  double ptparticle(-1.), etaparticle(-100.), etaEMCAL(0.), phiEMCAL(0.);
353  for(int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
354  checktrack = dynamic_cast<AliVTrack *>(fInputEvent->GetTrack(itrk));
355  if(!checktrack) continue;
356  // Find associated particle
357  assocMC = fMCEvent->GetTrack(TMath::Abs(checktrack->GetLabel()));
358  if(!assocMC) continue; // Fake track
359 
360  // Require bunch crossing informaiton per track from TOF
361  // As this criterion cannot be checked in simulation
362  // the requirement reduces to the simple presence of a
363  // TOF hit as this is mandatory in order to determine
364  // a bunch crossing ID in data
365  if(fRequireTOFBunchCrossing){
366  if(!checktrack->IsOn(AliVTrack::kTOFout)) continue;
367  }
368 
369  // Select only particles within ALICE acceptance
370  if(!fEtaLabCut.IsInRange(checktrack->Eta())) continue;
371  if(!fPhiCut.IsInRange(checktrack->Phi())) continue;
372  if(TMath::Abs(checktrack->Pt()) < fMinPt) continue;
373  if(fStudyEMCALgeo){
374  if(checktrack->IsA() == AliESDtrack::Class()){
375  AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
376  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
377  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
378  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
379  } else {
380  AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
381  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
382  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
383  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
384  }
385  Int_t supermoduleID = -1;
386  isEMCAL = fGeom->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
387  // Exclude supermodules 10 and 11 as they did not participate in the trigger
388  isEMCAL = isEMCAL && supermoduleID < 10;
389  }
390 
391  if(!fTrackCuts->IsTrackAccepted(checktrack)) continue;
392 
393  ptparticle = TMath::Abs(assocMC->Pt());
394  etaparticle = assocMC->Eta();
395 
396  // Calculate eta in cms frame according
397  // EPJC74 (2014) 3054:
398  // eta_cms = - eta_lab - |yshift|
399  Double_t etacent = -1. * checktrack->Eta() - TMath::Abs(fYshift);
400  etacent *= fEtaSign;
401 
402  if(!fEtaCmsCut.IsInRange(etacent)) continue; // Apply eta-cent cut
403 
404  // Get PID
405  TString assocpid = "";
406  if(fStudyPID){
407  switch(TMath::Abs(assocMC->PdgCode())){
408  case kPiPlus: assocpid = "Pi"; break;
409  case kMuonMinus: assocpid = "Mu"; break;
410  case kElectron: assocpid = "El"; break;
411  case kKPlus: assocpid = "Ka"; break;
412  case kProton: assocpid = "Pr"; break;
413  default: assocpid = "Ot"; break;
414  };
415  }
416  for(const auto &trg : fEventTriggers)
417  FillTrackHistos(trg, fEventWeight, checktrack->Charge() > 0, ptparticle, checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), isEMCAL, IsPhysicalPrimary(assocMC, fMCEvent), assocpid);
418  }
419  return true;
420 }
421 
422 void AliAnalysisTaskChargedParticlesRefMC::FillTrackHistos(
423  const TString &eventclass,
424  Double_t weight,
425  Bool_t posCharge,
426  Double_t pt,
427  Double_t etalab,
428  Double_t etacent,
429  Double_t phi,
430  Bool_t inEmcal,
431  Bool_t isPrimary,
432  const TString &pid
433  )
434 {
435 
436  double kinepointall[5] = {TMath::Abs(pt), etalab, phi, posCharge ? 1.: -1., isPrimary ? 1. : 0.},
437  kinepointcent[5] = {TMath::Abs(pt), etacent, phi, posCharge ? 1.: -1., isPrimary ? 1. : 0.};
438  TString chargelabel = posCharge ? "Pos" : "Neg";
439  fHistos->FillTHnSparse("hPtEtaPhiAll" + eventclass, kinepointall, weight);
440  fHistos->FillTHnSparse("hPtEtaPhiCent" + eventclass, kinepointcent, weight);
441 
442  if(fStudyPID){
443  fHistos->FillTHnSparse("hPtEtaPhiAll" + pid + eventclass, kinepointall, weight);
444  fHistos->FillTHnSparse("hPtEtaPhiCent" + pid + eventclass, kinepointcent, weight);
445  }
446 
447  if(fStudyEMCALgeo && inEmcal){
448  fHistos->FillTHnSparse("hPtEtaPhiEMCALAll" + eventclass, kinepointall, weight);
449  fHistos->FillTHnSparse("hPtEtaPhiEMCALCent" + eventclass, kinepointall, weight);
450 
451  if(fStudyPID){
452  fHistos->FillTHnSparse("hPtEtaPhiEMCALAll" + pid + eventclass, kinepointall, weight);
453  fHistos->FillTHnSparse("hPtEtaPhiEMCALCent" + pid + eventclass, kinepointall, weight);
454  }
455  }
456 }
457 
458 
461 }
462 
463 
464 
465 TString AliAnalysisTaskChargedParticlesRefMC::GetFiredTriggerClasses(const TClonesArray* triggerpatches) {
466  TString triggerstring = "";
467  Int_t nEJ1 = 0, nEJ2 = 0, nEG1 = 0, nEG2 = 0;
468  double minADC_EJ1 = 260.,
469  minADC_EJ2 = 127.,
470  minADC_EG1 = 140.,
471  minADC_EG2 = 89.;
472  for(auto patchIter : *(triggerpatches)){
473  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(patchIter);
474  if(!patch->IsOfflineSimple()) continue;
475  if(patch->IsJetHighSimple() && patch->GetADCOfflineAmp() > minADC_EJ1) nEJ1++;
476  if(patch->IsJetLowSimple() && patch->GetADCOfflineAmp() > minADC_EJ2) nEJ2++;
477  if(patch->IsGammaHighSimple() && patch->GetADCOfflineAmp() > minADC_EG1) nEG1++;
478  if(patch->IsGammaLowSimple() && patch->GetADCOfflineAmp() > minADC_EG2) nEG2++;
479  }
480  if(nEJ1) triggerstring += "EJ1";
481  if(nEJ2){
482  if(triggerstring.Length()) triggerstring += ",";
483  triggerstring += "EJ2";
484  }
485  if(nEG1){
486  if(triggerstring.Length()) triggerstring += ",";
487  triggerstring += "EG1";
488  }
489  if(nEG2){
490  if(triggerstring.Length()) triggerstring += ",";
491  triggerstring += "EG2";
492  }
493  return triggerstring;
494 }
495 
496 Bool_t AliAnalysisTaskChargedParticlesRefMC::IsPhysicalPrimary(const AliVParticle* const part, AliMCEvent* const mcevent) {
497  Bool_t physprim = false;
498  const AliAODMCParticle *aodmc = dynamic_cast<const AliAODMCParticle *>(part);
499  if(aodmc){
500  physprim = aodmc->IsPhysicalPrimary();
501  } else {
502  physprim = mcevent->IsPhysicalPrimary(part->GetLabel());
503  }
504  return physprim;
505 }
506 
508  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
509 
510  TString taskname = "chargedParticleMCQA_" + name;
511 
513  task->SetJetPtFactor(4.);
514  task->SetTrackPtFactor(1.5);
515  mgr->AddTask(task);
516 
517  TString outfile(mgr->GetCommonFileName());
518  outfile += ":ChargedParticleQA_" + name;
519 
520  task->ConnectInput(0, mgr->GetCommonInputContainer());
521  mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form("TrackResults_%s", name.Data()), AliEmcalList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
522 
523  return task;
524 }
525 
527  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
528 
529  AliAnalysisTaskChargedParticlesRefMC *task = new AliAnalysisTaskChargedParticlesRefMC(Form("chargedParticleMCQA_%s", cutname.Data()));
530  task->SetJetPtFactor(4.);
531  task->SetTrackPtFactor(1.5);
532  // Set Energy thresholds for additional patch selection:
533  // These are events with offline patches of a given type where the trigger reached already the plateau
534  // These numers are determined as:
535  // EMC7: 5 GeV
536  // EG1: 14 GeV
537  // EG2: 8 GeV
538  // EJ1: 22 GeV
539  // EJ2: 12 GeV
540  mgr->AddTask(task);
543  );
546  cutname,
547  mgr->GetInputEventHandler()->IsA() == AliAODInputHandler::Class()
548  )
549  );
550 
551  TString outfile(mgr->GetCommonFileName());
552  outfile += ":ChargedParticleQA" + cutname;
553 
554  task->ConnectInput(0, mgr->GetCommonInputContainer());
555  mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form("TrackResults_%s", cutname.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
556 
557  return task;
558 }
559 
563 AliAnalysisTaskChargedParticlesRefMC::PtBinning::PtBinning() :
565 {
566  this->SetMinimum(0.);
567  this->AddStep(1, 0.05);
568  this->AddStep(2, 0.1);
569  this->AddStep(4, 0.2);
570  this->AddStep(7, 0.5);
571  this->AddStep(16, 1);
572  this->AddStep(36, 2);
573  this->AddStep(40, 4);
574  this->AddStep(50, 5);
575  this->AddStep(100, 10);
576  this->AddStep(200, 20);
577 }
578 
579 } /* namespace EMCalTriggerPtAnalysis */
void SetJetPtFactor(Float_t f)
virtual Bool_t Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
void SetTrackPtFactor(Float_t f)
Bool_t fIsPythia
trigger, if it is a PYTHIA production
void SetOfflineTriggerSelection(AliEmcalTriggerOfflineSelection *sel)
Set offline trigger selection.
double Double_t
Definition: External.C:58
Class creating a linear binning, used in the histogram manager.
Base task in the EMCAL framework.
Bool_t fLocalInitialized
whether or not the task has been already initialized
Interface for binnings used by the histogram handler.
Definition: TBinning.h:21
TString part
use mixed event to constrain combinatorial background
Definition: InvMassFit.C:52
void SetCaloTriggerPatchInfoName(const char *n)
static AliEmcalTrackSelection * TrackCutsFactory(TString name, Bool_t isAOD)
Fully-configure EMCAL track selection independent of the data type.
Bool_t CheckMCOutliers()
Filter the mc tails in pt-hard distributions.
int Int_t
Definition: External.C:63
AliEMCALGeometry * fGeom
!emcal geometry
static AliAnalysisTaskChargedParticlesRefMC * AddTaskChargedParticlesRefMCDefault(const TString &cutname="standard")
AliGenPythiaEventHeader * fPythiaHeader
!event Pythia header
AliAnalysisUtils * fAliAnalysisUtils
!vertex selection (optional)
Helper class creating user defined custom binning.
Test class for charged particle distributions (MC case)
virtual Bool_t IsEventSelected()
Performing event selection.
Float_t fPtHard
!event -hard
AliEmcalList * fOutput
!output list
Definition: External.C:220
Analysis of high- tracks in triggered events.
void SetMakeGeneralHistograms(Bool_t g)
TClonesArray * fTriggerPatchInfo
!trigger patch info array
void SetNeedEmcalGeom(Bool_t n)
Container class for histograms.
Definition: THistManager.h:99
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
void UserCreateOutputObjects()
Main initialization function on the worker.
void SetEMCALTrackSelection(AliEmcalTrackSelection *sel)
Set the virtual track selection.
bool Bool_t
Definition: External.C:53
static AliAnalysisTaskChargedParticlesRefMC * AddTaskChargedParticlesRefMC(const TString &suffix)
static AliEmcalTriggerOfflineSelection * TriggerSelectionFactory(Double_t el0, Double_t eg1, Double_t eg2, Double_t ej1, Double_t ej2, AliEmcalTriggerOfflineSelection::EmcalEnergyDefinition_t endef=AliEmcalTriggerOfflineSelection::kFEEEnergy)
Configures EMCAL trigger offline selection used to restrict EMCAL triggered sample.
static TString ClusterContainerNameFactory(Bool_t isAOD)
Get name of the default cluster container.