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