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