AliPhysics  b752f14 (b752f14)
 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 <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  fRequireTOFBunchCrossing(false),
81  fNameAcceptanceOADB()
82 {
83  SetCaloTriggerPatchInfoName("EmcalTriggers");
84  SetNeedEmcalGeom(true);
86 }
87 
89  AliAnalysisTaskEmcal(name, true),
90  fTrackCuts(nullptr),
91  fTriggerSelection(nullptr),
92  fHistos(nullptr),
93  fWeightHandler(nullptr),
94  fEventTriggers(),
95  fEventWeight(1.),
96  fYshift(0.465),
97  fEtaSign(1),
98  fMinPt(0.1),
99  fEtaLabCut(-0.5, 0.5),
100  fEtaCmsCut(-2., 2.),
101  fPhiCut(0., TMath::TwoPi()),
102  fFracPtHard(-1),
103  fEnableSumw2(kFALSE),
104  fStudyPID(kFALSE),
105  fStudyEMCALgeo(false),
106  fRequireTOFBunchCrossing(false),
107  fNameAcceptanceOADB()
108 {
109  SetCaloTriggerPatchInfoName("EmcalTriggers");
110  SetNeedEmcalGeom(true);
112 }
113 
115  //if(fTrackCuts) delete fTrackCuts;
116  if(fTriggerSelection) delete fTriggerSelection;
117  if(fHistos) delete fHistos;
118 }
119 
122 
123  if(!fAliAnalysisUtils) fAliAnalysisUtils = new AliAnalysisUtils;
124  fHistos = new THistManager("Ref");
125 
126  if(!fTrackCuts) InitializeTrackCuts("standard",fInputHandler->IsA() == AliAODInputHandler::Class());
127  fTrackCuts->SaveQAObjects(fOutput);
128 
129  PtBinning newbinning;
130  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);
131  const TBinning *binning5D[5] = {&newbinning, &etabinning, &phibinning, &chargebinning, &primarybinning};
132 
133  TString optionstring = fEnableSumw2 ? "s" : "";
134 
135  fHistos->CreateTH1("hPtHard", "Pt of the hard interaction", 1000, 0., 500);
136  const std::array<TString,7> triggers = {"True", "MB", "EMC7", "EJ1", "EJ2", "EG1", "EG2"};
137  const std::array<TString,6> species = {"El", "Mu", "Pi", "Ka", "Pr", "Ot"};
138  for(const auto &trg : triggers){
139  fHistos->CreateTH1("hEventCount" + trg, "Event Counter for trigger class " + trg, 1, 0.5, 1.5, optionstring);
140  fHistos->CreateTH1("hVertexBefore" + trg, "Vertex distribution before z-cut for trigger class " + trg, 500, -50, 50, optionstring);
141  fHistos->CreateTH1("hVertexAfter" + trg, "Vertex distribution after z-cut for trigger class " + trg, 100, -10, 10, optionstring);
142 
143  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);
144  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);
145  if(fStudyEMCALgeo){
146  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);
147  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);
148  }
149 
150  if(fStudyPID){
151  for(const auto &pid : species){
152  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);
153  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);
154  if(fStudyEMCALgeo){
155  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);
156  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);
157  }
158  }
159  }
160  }
161  //fHistos->GetListOfHistograms()->Add(fTrackCuts);
162  for(auto hist : *(fHistos->GetListOfHistograms())){
163  fOutput->Add(hist);
164  }
165 
166  PostData(1, fOutput);
167 }
168 
170  fEventTriggers.clear();
171  AliDebugStream(1) << GetName() << ": Using custom event selection" << std::endl;
172  if(!MCEvent()) return false;
173  if(!fTriggerPatchInfo) return false;
174  fEventWeight = fWeightHandler ? fWeightHandler->GetEventWeight(fPythiaHeader) : 1.;
175 
176  // Do MC outlier cut
177  if(fIsPythia){
178  if(!CheckMCOutliers()) return false;
179  }
180 
181  fHistos->FillTH1("hPtHard", fPtHard);
182 
183 
184  // select trigger
185  bool isMinBias;
186  if((isMinBias = fInputHandler->IsEventSelected() & AliVEvent::kINT7)) fEventTriggers.push_back("MB");
187  // In simulations triggered events are a subset of min. bias events
188  if(fTriggerPatchInfo && fTriggerSelection){
189  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEL0, fInputEvent))
190  fEventTriggers.push_back("EMC7"); // triggerstring.Contains("EMC7"),
191  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEJ1, fInputEvent))
192  fEventTriggers.push_back("EJ1"); // triggerstring.Contains("EJ1"),
193  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEJ2, fInputEvent))
194  fEventTriggers.push_back("EJ2"); // triggerstring.Contains("EJ2"),
195  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEG1, fInputEvent))
196  fEventTriggers.push_back("EG1"); // triggerstring.Contains("EG1"),
197  if(isMinBias && fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEG2, fInputEvent))
198  fEventTriggers.push_back("EG2"); // triggerstring.Contains("EG2");
199  }
200  if(!fEventTriggers.size()){
201  AliDebugStream(1) << GetName() << ": No trigger selected" << std::endl;
202  }
203 
204  const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
205  if(vtx->GetNContributors() < 1) return false;
206  if(!fAliAnalysisUtils->IsVertexSelected2013pA(fInputEvent)) return false; // Apply new vertex cut
207  if(fAliAnalysisUtils->IsPileUpEvent(fInputEvent)) return false; // Apply new vertex cut
208  // Fill reference distribution for the primary vertex before any z-cut
209  fHistos->FillTH1("hVertexBeforeTrue", vtx->GetZ(), fEventWeight);
210  for(const auto &trg : fEventTriggers) fHistos->FillTH1("hVertexBefore" + trg, vtx->GetZ(), fEventWeight);
211  // Apply vertex z cut
212  if(vtx->GetZ() < -10. || vtx->GetZ() > 10.) return false;
213 
214 
215  // Fill Event counter and reference vertex distributions for the different trigger classes
216  fHistos->FillTH1("hEventCountTrue", 1, fEventWeight);
217  fHistos->FillTH1("hVertexAfterTrue", vtx->GetZ(), fEventWeight);
218  for(const auto &trg : fEventTriggers){
219  fHistos->FillTH1("hEventCount" + trg, 1, fEventWeight);
220  fHistos->FillTH1("hVertexAfter" + trg, vtx->GetZ(), fEventWeight);
221  }
222 
223  return true;
224 }
225 
228 
229  if(!fLocalInitialized) {
230  AliErrorStream() << GetName() << ": Failed initializing AliAnalysisTaskEmcal" << std::endl;
231  return;
232  }
233 
234  if(!fTriggerSelection->GetNameClusterContainer().Length()){
235  fTriggerSelection->SetClusterContainer(AliEmcalAnalysisFactory::ClusterContainerNameFactory(fInputEvent->IsA() == AliAODEvent::Class()));
236  }
237 
238  // Load acceptance OADB
239  if(fNameAcceptanceOADB.Length() && fTriggerSelection){
240  AliDebugStream(1) << GetName() << ": Loading acceptance map from OADB file " << fNameAcceptanceOADB << std::endl;
241  AliOADBContainer acceptanceCont("AliEmcalTriggerAcceptance");
242  acceptanceCont.InitFromFile(fNameAcceptanceOADB.Data(), "AliEmcalTriggerAcceptance");
243  TObjArray *acceptanceMaps = dynamic_cast<TObjArray *>(acceptanceCont.GetObject(fInputEvent->GetRunNumber()));
244  TH2 *map(nullptr);
245  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("EG1")))){
246  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger EG1" << std::endl;
247  map->SetDirectory(nullptr);
248  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgEG1, map);
249  }
250  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("EG2")))){
251  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger EG2" << std::endl;
252  map->SetDirectory(nullptr);
253  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgEG2, map);
254  }
255  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("DG1")))){
256  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger DG1" << std::endl;
257  map->SetDirectory(nullptr);
258  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgDG1, map);
259  }
260  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("DG2")))){
261  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger DG2" << std::endl;
262  map->SetDirectory(nullptr);
263  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgDG1, map);
264  }
265  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("EJ1")))){
266  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger EJ1" << std::endl;
267  map->SetDirectory(nullptr);
268  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgEJ1, map);
269  }
270  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("EJ2")))){
271  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger EJ2" << std::endl;
272  map->SetDirectory(nullptr);
273  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgEJ2, map);
274  }
275  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("DJ1")))){
276  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger DJ1" << std::endl;
277  map->SetDirectory(nullptr);
278  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgDJ1, map);
279  }
280  if((map = dynamic_cast<TH2 *>(acceptanceMaps->FindObject("DJ2")))){
281  AliDebugStream(1) << GetName() << ": Found acceptance map for trigger DJ2" << std::endl;
282  map->SetDirectory(nullptr);
283  fTriggerSelection->SetAcceptanceMap(AliEmcalTriggerOfflineSelection::kTrgDJ1, map);
284  }
285  }
286 }
287 
289  // MonteCarlo Loop
290  // Histograms
291  // - Full eta (-0.8, 0.8), new binning
292  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c without eta cut
293  // - Central eta_{cms} (-0.3, 0.3), new binning,
294  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c
295  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c with eta cut
296  AliVParticle *truepart = NULL;
297  Bool_t isEMCAL(kFALSE);
298  for(int ipart = 0; ipart < fMCEvent->GetNumberOfTracks(); ipart++){
299  truepart = fMCEvent->GetTrack(ipart);
300 
301  // Select only particles within ALICE acceptance
302  if(!fEtaLabCut.IsInRange(truepart->Eta())) continue;
303  if(!fPhiCut.IsInRange(truepart->Phi())) continue;
304  if(TMath::Abs(truepart->Pt()) < fMinPt) continue;
305  if(!truepart->Charge()) continue;
306 
307  if(!IsPhysicalPrimary(truepart, fMCEvent)) continue;
308  if(fStudyEMCALgeo) isEMCAL = (truepart->Phi() > 1.5 && truepart->Phi() < 3.1) ? kTRUE : kFALSE;
309 
310  // Calculate eta in cms frame according
311  // EPJC74 (2014) 3054:
312  // eta_cms = - eta_lab - |yshift|
313  Double_t etacent = -1. * truepart->Eta() - TMath::Abs(fYshift);
314  etacent *= fEtaSign;
315 
316  if(!fEtaCmsCut.IsInRange(etacent)) continue; // Apply eta-cent cut
317 
318  // Get PID
319  TString pid = "";
320  if(fStudyPID){
321  switch(TMath::Abs(truepart->PdgCode())){
322  case kPiPlus: pid = "Pi"; break;
323  case kMuonMinus: pid = "Mu"; break;
324  case kElectron: pid = "El"; break;
325  case kKPlus: pid = "Ka"; break;
326  case kProton: pid = "Pr"; break;
327  default: pid = "Ot"; break;
328  };
329  }
330 
331  // Particle selected (do not filter TRD sectors for MC truth)
332  FillTrackHistos("True", fEventWeight, truepart->Charge() > 0, truepart->Pt(), truepart->Eta() * fEtaSign, etacent, truepart->Phi(), isEMCAL, true, pid);
333  }
334 
335  // Loop over tracks, fill select particles
336  // Histograms
337  // - Full eta (-0.8, 0.8), new binning
338  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c without eta cut
339  // - Central eta (-0.8, -0.2), new binning,
340  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c
341  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c with eta cut
342  AliVTrack *checktrack(NULL);
343  AliVParticle *assocMC(NULL);
344  double ptparticle(-1.), etaparticle(-100.), etaEMCAL(0.), phiEMCAL(0.);
345  for(int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
346  checktrack = dynamic_cast<AliVTrack *>(fInputEvent->GetTrack(itrk));
347  if(!checktrack) continue;
348  // Find associated particle
349  assocMC = fMCEvent->GetTrack(TMath::Abs(checktrack->GetLabel()));
350  if(!assocMC) continue; // Fake track
351 
352  // Require bunch crossing informaiton per track from TOF
353  // As this criterion cannot be checked in simulation
354  // the requirement reduces to the simple presence of a
355  // TOF hit as this is mandatory in order to determine
356  // a bunch crossing ID in data
357  if(fRequireTOFBunchCrossing){
358  if(!checktrack->IsOn(AliVTrack::kTOFout)) continue;
359  }
360 
361  // Select only particles within ALICE acceptance
362  if(!fEtaLabCut.IsInRange(checktrack->Eta())) continue;
363  if(!fPhiCut.IsInRange(checktrack->Phi())) continue;
364  if(TMath::Abs(checktrack->Pt()) < fMinPt) continue;
365  if(fStudyEMCALgeo){
366  if(checktrack->IsA() == AliESDtrack::Class()){
367  AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
368  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
369  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
370  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
371  } else {
372  AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
373  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
374  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
375  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
376  }
377  Int_t supermoduleID = -1;
378  isEMCAL = fGeom->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
379  // Exclude supermodules 10 and 11 as they did not participate in the trigger
380  isEMCAL = isEMCAL && supermoduleID < 10;
381  }
382 
383  if(!fTrackCuts->IsTrackAccepted(checktrack)) continue;
384 
385  ptparticle = TMath::Abs(assocMC->Pt());
386  etaparticle = assocMC->Eta();
387 
388  // Calculate eta in cms frame according
389  // EPJC74 (2014) 3054:
390  // eta_cms = - eta_lab - |yshift|
391  Double_t etacent = -1. * checktrack->Eta() - TMath::Abs(fYshift);
392  etacent *= fEtaSign;
393 
394  if(!fEtaCmsCut.IsInRange(etacent)) continue; // Apply eta-cent cut
395 
396  // Get PID
397  TString assocpid = "";
398  if(fStudyPID){
399  switch(TMath::Abs(assocMC->PdgCode())){
400  case kPiPlus: assocpid = "Pi"; break;
401  case kMuonMinus: assocpid = "Mu"; break;
402  case kElectron: assocpid = "El"; break;
403  case kKPlus: assocpid = "Ka"; break;
404  case kProton: assocpid = "Pr"; break;
405  default: assocpid = "Ot"; break;
406  };
407  }
408  for(const auto &trg : fEventTriggers)
409  FillTrackHistos(trg, fEventWeight, checktrack->Charge() > 0, ptparticle, checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), isEMCAL, IsPhysicalPrimary(assocMC, fMCEvent), assocpid);
410  }
411  return true;
412 }
413 
414 void AliAnalysisTaskChargedParticlesRefMC::FillTrackHistos(
415  const TString &eventclass,
416  Double_t weight,
417  Bool_t posCharge,
418  Double_t pt,
419  Double_t etalab,
420  Double_t etacent,
421  Double_t phi,
422  Bool_t inEmcal,
423  Bool_t isPrimary,
424  const TString &pid
425  )
426 {
427 
428  double kinepointall[5] = {TMath::Abs(pt), etalab, phi, posCharge ? 1.: -1., isPrimary ? 1. : 0.},
429  kinepointcent[5] = {TMath::Abs(pt), etacent, phi, posCharge ? 1.: -1., isPrimary ? 1. : 0.};
430  TString chargelabel = posCharge ? "Pos" : "Neg";
431  fHistos->FillTHnSparse("hPtEtaPhiAll" + eventclass, kinepointall, weight);
432  fHistos->FillTHnSparse("hPtEtaPhiCent" + eventclass, kinepointcent, weight);
433 
434  if(fStudyPID){
435  fHistos->FillTHnSparse("hPtEtaPhiAll" + pid + eventclass, kinepointall, weight);
436  fHistos->FillTHnSparse("hPtEtaPhiCent" + pid + eventclass, kinepointcent, weight);
437  }
438 
439  if(fStudyEMCALgeo && inEmcal){
440  fHistos->FillTHnSparse("hPtEtaPhiEMCALAll" + eventclass, kinepointall, weight);
441  fHistos->FillTHnSparse("hPtEtaPhiEMCALCent" + eventclass, kinepointall, weight);
442 
443  if(fStudyPID){
444  fHistos->FillTHnSparse("hPtEtaPhiEMCALAll" + pid + eventclass, kinepointall, weight);
445  fHistos->FillTHnSparse("hPtEtaPhiEMCALCent" + pid + eventclass, kinepointall, weight);
446  }
447  }
448 }
449 
450 
453 }
454 
455 
456 
457 TString AliAnalysisTaskChargedParticlesRefMC::GetFiredTriggerClasses(const TClonesArray* triggerpatches) {
458  TString triggerstring = "";
459  Int_t nEJ1 = 0, nEJ2 = 0, nEG1 = 0, nEG2 = 0;
460  double minADC_EJ1 = 260.,
461  minADC_EJ2 = 127.,
462  minADC_EG1 = 140.,
463  minADC_EG2 = 89.;
464  for(auto patchIter : *(triggerpatches)){
465  AliEMCALTriggerPatchInfo *patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(patchIter);
466  if(!patch->IsOfflineSimple()) continue;
467  if(patch->IsJetHighSimple() && patch->GetADCOfflineAmp() > minADC_EJ1) nEJ1++;
468  if(patch->IsJetLowSimple() && patch->GetADCOfflineAmp() > minADC_EJ2) nEJ2++;
469  if(patch->IsGammaHighSimple() && patch->GetADCOfflineAmp() > minADC_EG1) nEG1++;
470  if(patch->IsGammaLowSimple() && patch->GetADCOfflineAmp() > minADC_EG2) nEG2++;
471  }
472  if(nEJ1) triggerstring += "EJ1";
473  if(nEJ2){
474  if(triggerstring.Length()) triggerstring += ",";
475  triggerstring += "EJ2";
476  }
477  if(nEG1){
478  if(triggerstring.Length()) triggerstring += ",";
479  triggerstring += "EG1";
480  }
481  if(nEG2){
482  if(triggerstring.Length()) triggerstring += ",";
483  triggerstring += "EG2";
484  }
485  return triggerstring;
486 }
487 
488 Bool_t AliAnalysisTaskChargedParticlesRefMC::IsPhysicalPrimary(const AliVParticle* const part, AliMCEvent* const mcevent) {
489  Bool_t physprim = false;
490  const AliAODMCParticle *aodmc = dynamic_cast<const AliAODMCParticle *>(part);
491  if(aodmc){
492  physprim = aodmc->IsPhysicalPrimary();
493  } else {
494  physprim = mcevent->IsPhysicalPrimary(part->GetLabel());
495  }
496  return physprim;
497 }
498 
500  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
501 
502  TString taskname = "chargedParticleMCQA_" + name;
503 
505  task->SetJetPtFactor(4.);
506  task->SetTrackPtFactor(1.5);
507  mgr->AddTask(task);
508 
509  TString outfile(mgr->GetCommonFileName());
510  outfile += ":ChargedParticleQA_" + name;
511 
512  task->ConnectInput(0, mgr->GetCommonInputContainer());
513  mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form("TrackResults_%s", name.Data()), AliEmcalList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
514 
515  return task;
516 }
517 
519  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
520 
521  AliAnalysisTaskChargedParticlesRefMC *task = new AliAnalysisTaskChargedParticlesRefMC(Form("chargedParticleMCQA_%s", cutname.Data()));
522  task->SetJetPtFactor(4.);
523  task->SetTrackPtFactor(1.5);
524  // Set Energy thresholds for additional patch selection:
525  // These are events with offline patches of a given type where the trigger reached already the plateau
526  // These numers are determined as:
527  // EMC7: 5 GeV
528  // EG1: 14 GeV
529  // EG2: 8 GeV
530  // EJ1: 22 GeV
531  // EJ2: 12 GeV
532  mgr->AddTask(task);
535  );
538  cutname,
539  mgr->GetInputEventHandler()->IsA() == AliAODInputHandler::Class()
540  )
541  );
542 
543  TString outfile(mgr->GetCommonFileName());
544  outfile += ":ChargedParticleQA" + cutname;
545 
546  task->ConnectInput(0, mgr->GetCommonInputContainer());
547  mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form("TrackResults_%s", cutname.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
548 
549  return task;
550 }
551 
555 AliAnalysisTaskChargedParticlesRefMC::PtBinning::PtBinning() :
557 {
558  this->SetMinimum(0.);
559  this->AddStep(1, 0.05);
560  this->AddStep(2, 0.1);
561  this->AddStep(4, 0.2);
562  this->AddStep(7, 0.5);
563  this->AddStep(16, 1);
564  this->AddStep(36, 2);
565  this->AddStep(40, 4);
566  this->AddStep(50, 5);
567  this->AddStep(100, 10);
568  this->AddStep(200, 20);
569 }
570 
571 } /* 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
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)
ClassImp(AliAnalysisTaskDeltaPt) AliAnalysisTaskDeltaPt
virtual Bool_t IsEventSelected()
Performing event selection.
Float_t fPtHard
!event -hard
AliEmcalList * fOutput
!output list
Definition: External.C:220
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.