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