AliPhysics  f05a842 (f05a842)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskChargedParticlesMCTriggerMimic.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 <bitset>
17 #include <iomanip>
18 #include <iostream>
19 #include <memory>
20 #include <string>
21 
22 #include <TClonesArray.h>
23 #include <TFile.h>
24 #include <THistManager.h>
25 #include <TLinearBinning.h>
26 #include <TMath.h>
27 #include <TPDGCode.h>
28 #include <TTree.h>
29 
30 #include "AliAnalysisUtils.h"
31 #include "AliAODInputHandler.h"
32 #include "AliAODMCHeader.h"
33 #include "AliAODMCParticle.h"
34 #include "AliAODTrack.h"
35 #include "AliClusterContainer.h"
37 #include "AliEMCALGeometry.h"
38 #include "AliEMCALRecoUtils.h"
39 #include "AliEMCALTriggerPatchInfo.h"
41 #include "AliESDtrack.h"
42 #include "AliGenPythiaEventHeader.h"
43 #include "AliInputEventHandler.h"
44 #include "AliLog.h"
45 #include "AliVCluster.h"
46 #include "AliVEvent.h"
47 #include "AliVParticle.h"
48 
50 
54 
55 namespace EMCalTriggerPtAnalysis {
56 
60 AliAnalysisTaskChargedParticlesMCTriggerMimic::AliAnalysisTaskChargedParticlesMCTriggerMimic():
62  fTrackCuts(NULL),
63  fHistos(NULL),
64  fWeightHandler(NULL),
65  fYshift(0.465),
66  fEtaSign(1),
67  fEtaLabCut(-0.6, 0.6),
68  fEtaCmsCut(-0.13, 0.13),
69  fPatchType(kUndef),
70  fEnergyThreshold(0.),
71  fObservables(),
72  fNameClusters()
73 {
74  SetCaloTriggerPatchInfoName("EmcalTriggers");
75  SetNeedEmcalGeom(true);
76 }
77 
83  AliAnalysisTaskEmcal(name, true),
84  fTrackCuts(nullptr),
85  fHistos(nullptr),
86  fWeightHandler(nullptr),
87  fYshift(0.465),
88  fEtaSign(1),
89  fEtaLabCut(-0.6, 0.6),
90  fEtaCmsCut(-0.13, 0.13),
91  fPatchType(kUndef),
92  fEnergyThreshold(0.),
93  fObservables(),
94  fNameClusters()
95 {
96  SetCaloTriggerPatchInfoName("EmcalTriggers");
97  SetNeedEmcalGeom(true);
99 }
100 
105  //if(fTrackCuts) delete fTrackCuts;
106  if(fHistos) delete fHistos;
107 }
108 
111 
112  if(fIsPythia){
113  AliDebugStream(1) << GetName() << ": Running on PYTHIA Hard production" << std::endl;
114  } else {
115  AliDebugStream(1) << GetName() << ": Not running on PYTHIA Hard production" << std::endl;
116  }
117 
118  if(!fAliAnalysisUtils) fAliAnalysisUtils = new AliAnalysisUtils;
119  if(!fTrackCuts) InitializeTrackCuts("standard",fInputHandler->IsA() == AliAODInputHandler::Class());
120 
121  PtBinning newbinning;
122  TLinearBinning smbinning(21, -0.5, 20.5), etabinning(100, -0.7, 0.7);
123  fHistos = new THistManager("Ref");
124 
125  // The first two histograms should lead to a re-implementation inside AliAnalysisTaskEMCAL:
126  // Users should be able to set event weights.
127  fHistos->CreateTH1("hUserEventCount", "User event counter", 1, 0.5, 1.5);
128  fHistos->CreateTH1("hUserVertexZ", "User vertex distribution after z-cut", 100, -10, 10);
129  fHistos->CreateTH1("hUserPtHard", "User pt-hard distribution", 1000, 0., 300.);
130 
131  // Histograms for observable tracks
132  if(HasObservable(kTracks)){
133  const std::array<std::string, 2> kInputs = {"True", "Accept"};
134  const std::array<std::string, 6> kSpecies = {"El", "Mu", "Pi", "Ka", "Pr", "Ot"};
135  const std::array<double, 5> kPtCuts = {1., 2., 5., 10., 20.};
136  for(const auto &input : kInputs){
137  AliDebugStream(1) << GetName() << ": Creating histograms for case " << input << std::endl;
138  fHistos->CreateTH1(Form("hTrackPtEtaAll%s", input.c_str()), Form("Charged particle p_{t} distribution all #eta %s", input.c_str()), newbinning, "s");
139  fHistos->CreateTH1(Form("hTrackPtEtaCent%s", input.c_str()), Form("Charged particle p_{t} distribution central #eta %s", input.c_str()), newbinning, "s");
140  fHistos->CreateTH1(Form("hTrackPtEMCALEtaAll%s", input.c_str()), Form("Charged particle in EMCAL p_{t} distribution all #eta trigger %s", input.c_str()), newbinning);
141  fHistos->CreateTH1(Form("hTrackPtEMCALEtaCent%s", input.c_str()), Form("Charged particle in EMCAL p_{t} distribution central eta trigger %s", input.c_str()), newbinning);
142  for(const auto &piditer : kSpecies){
143  fHistos->CreateTH1(Form("hTrackPtEtaAll%s%s", piditer.c_str(), input.c_str()), Form("Charged %s p_{t} distribution all #eta %s", piditer.c_str(), input.c_str()), newbinning);
144  fHistos->CreateTH1(Form("hTrackPtEtaCent%s%s", piditer.c_str(), input.c_str()), Form("Charged %s p_{t} distribution central #eta %s", piditer.c_str(), input.c_str()), newbinning);
145  fHistos->CreateTH1(Form("hTrackPtEMCALEtaAll%s%s", piditer.c_str(), input.c_str()), Form("Charged %s in EMCAL p_{t} distribution all #eta %s", piditer.c_str(), input.c_str()), newbinning);
146  fHistos->CreateTH1(Form("hTrackPtEMCALEtaCent%s%s", piditer.c_str(), input.c_str()), Form("Charged %s in EMCAL p_{t} distribution central #eta %s", piditer.c_str(), input.c_str()), newbinning);
147  }
148  for(const auto &ptcut : kPtCuts){
150  Form("hTrackEtaLabDistAllPt%d%s", static_cast<Int_t>(ptcut), input.c_str()),
151  Form("#eta_{lab} distribution without #eta-cut for tracks with p_{t} above %.1f GeV/c %s", ptcut, input.c_str()),
152  100,
153  -1.,
154  1.
155  );
157  Form("hTrackEtaLabDistCutPt%d%s", static_cast<Int_t>(ptcut), input.c_str()),
158  Form("#eta_{lab} distribution with #eta-cut for tracks with p_{t} above %.1f GeV/c %s", ptcut, input.c_str()),
159  100,
160  -1.,
161  1.
162  );
164  Form("hTrackEtaCentDistAllPt%d%s", static_cast<Int_t>(ptcut), input.c_str()),
165  Form("#eta_{cent} distribution without #eta-cut for tracks with p_{t} above %.1f GeV/c %s", ptcut, input.c_str()),
166  160,
167  -1.3,
168  1.3
169  );
171  Form("hTrackEtaCentDistCutPt%d%s", static_cast<Int_t>(ptcut), input.c_str()),
172  Form("#eta_{cent} distribution with #eta-cut for tracks with p_{t} above %.1f GeV/c %s", ptcut, input.c_str()),
173  160,
174  -1.3,
175  1.3
176  );
178  Form("hTrackEtaLabDistAllEMCALPt%d%s", static_cast<Int_t>(ptcut), input.c_str()),
179  Form("#eta_{lab} distribution without #eta-cut for tracks in EMCAL with p_{t} above %.1f GeV/c %s", ptcut, input.c_str()),
180  100,
181  -1.,
182  1.
183  );
185  Form("hTrackEtaLabDistCutEMCALPt%d%s", static_cast<Int_t>(ptcut), input.c_str()),
186  Form("#eta_{lab} distribution with #eta-cut for tracks in EMCAL with p_{t} above %.1f GeV/c %s", ptcut, input.c_str()),
187  100,
188  -1.,
189  1.
190  );
192  Form("hTrackEtaCentDistAllEMCALPt%d%s", static_cast<Int_t>(ptcut), input.c_str()),
193  Form("#eta_{cent} distribution without #eta-cut for tracks in EMCAL with p_{t} above %.1f GeV/c %s", ptcut, input.c_str()),
194  160,
195  -1.3,
196  1.3
197  );
199  Form("hTrackEtaCentDistCutEMCALPt%d%s", static_cast<Int_t>(ptcut), input.c_str()),
200  Form("Eta (cent) distribution with #eta-cut for tracks in EMCAL with p_{t} above %.1f GeV/c %s", ptcut, input.c_str()),
201  160,
202  -1.3,
203  1.3
204  );
206  Form("hTrackPhiDistAllPt%d%s", static_cast<Int_t>(ptcut), input.c_str()),
207  Form("#phi distribution of particles with p_{t} above %.1f GeV/c trigger %s", ptcut, input.c_str()),
208  300,
209  0.,
210  2*TMath::Pi()
211  );
212  }
213  }
214  }
215 
216  // Histograms for observable clusters
217  std::array<Double_t, 5> kEnCuts = {1., 2., 5., 10., 20.};
219  Int_t sectorsWithEMCAL[10] = {4, 5, 6, 7, 8, 9, 13, 14, 15, 16};
220  fHistos->CreateTH1("hClusterEnergy", "Cluster energy", newbinning);
221  fHistos->CreateTH1("hClusterET", "Cluster transverse energy", newbinning);
222  fHistos->CreateTH2("hClusterEnergySM", "Cluster energy versus supermodule", smbinning, newbinning);
223  fHistos->CreateTH2("hClusterETSM", "Cluster transverse energy versus supermodule", smbinning, newbinning);
224  fHistos->CreateTH2("hClusterEtaEnergy", "Cluster energy vs. eta", etabinning, newbinning);
225  fHistos->CreateTH2("hClusterEtaET", "Cluster transverse energy vs. eta", etabinning, newbinning);
226  for(int ism = 0; ism < 20; ism++){
227  fHistos->CreateTH2(Form("hClusterEtaEnergySM%d", ism), Form("Cluster energy vs. eta in Supermodule %d", ism), etabinning, newbinning);
228  fHistos->CreateTH2(Form("hClusterEtaETSM%d", ism), Form("Cluster transverse energy vs. eta in Supermodule %d", ism), etabinning, newbinning);
229  }
230  for(int isec = 0; isec < 10; isec++){
231  fHistos->CreateTH2(Form("hClusterEtaEnergySec%d", sectorsWithEMCAL[isec]), Form("Cluster energy vs.eta in tracking sector %d", sectorsWithEMCAL[isec]), etabinning, newbinning);
232  fHistos->CreateTH2(Form("hClusterEtaETSec%d", sectorsWithEMCAL[isec]), Form("Cluster transverse energy vs.eta in tracking sector %d", sectorsWithEMCAL[isec]), etabinning, newbinning);
233  }
234  for(auto ien : kEnCuts){
235  fHistos->CreateTH2(Form("hClusterEtaPhi%dG", static_cast<int>(ien)), Form("cluster #eta-#phi map for clusters with energy larger than %f GeV/c", ien), 100, -0.7, 0.7, 200, 0, 2*TMath::Pi());
236  }
237  }
238 
239  // Histograms for Observable EGA or EJE patches
241  const int kNPatchTypes = 2;
242  const std::array<Observable_t, kNPatchTypes> kPatchObservables = {kEGAPatches, kEJEPatches};
243  const std::array<TString, kNPatchTypes> kPatchTypes = {"EGA","EJE"};
244  for(int ipatch = 0; ipatch < kNPatchTypes; ipatch++){
245  if(!HasObservable(kPatchObservables[ipatch])) continue;
246  fHistos->CreateTH1(Form("h%sPatchEnergy", kPatchTypes[ipatch].Data()), Form("%s-patch energy", kPatchTypes[ipatch].Data()), newbinning);
247  fHistos->CreateTH1(Form("h%sPatchET", kPatchTypes[ipatch].Data()), Form("%s-patch transverse energy", kPatchTypes[ipatch].Data()), newbinning);
248  fHistos->CreateTH2(Form("h%sPatchEnergyEta", kPatchTypes[ipatch].Data()), Form("%s-patch energy", kPatchTypes[ipatch].Data()), newbinning, etabinning);
249  fHistos->CreateTH2(Form("h%sPatchETEta", kPatchTypes[ipatch].Data()), Form("%s-patch transverse energy", kPatchTypes[ipatch].Data()), newbinning, etabinning);
250  for(auto enc : kEnCuts){
251  fHistos->CreateTH2(Form("h%sPatchEtaPhi%dG", kPatchTypes[ipatch].Data(), static_cast<int>(enc)), Form("%s-patch #eta-#phi map for patches with energy larger than %f GeV/c", kPatchTypes[ipatch].Data(), enc), 100, -0.7, 0.7, 200, 0, TMath::TwoPi());
252  fHistos->CreateTH2(Form("h%sPatchColRow%dG", kPatchTypes[ipatch].Data(), static_cast<int>(enc)), Form("%s-patch col-row map for patches with energy larger than %f GeV/c", kPatchTypes[ipatch].Data(), enc), 48, -0.5, 47.5, 104, -0.5, 103.5);
253  }
254  }
255  }
256 
257  for(auto hist : *(fHistos->GetListOfHistograms())) fOutput->Add(hist);
258  PostData(1, fOutput);
259 
260  AliDebugStream(1) << GetName() << ": Output objects initialized" << std::endl;
261 }
262 
269  AliDebugStream(2) << GetName() << ": Using custom event selection method" << std::endl;
270  if(!fTriggerPatchInfo){
271  AliErrorStream() << GetName() << ": Trigger patch container not found but required" << std::endl;
272  return false;
273  }
274  if(!(fInputHandler->IsEventSelected() & AliVEvent::kINT7)) return false;
275  AliDebugStream(3) << GetName() << "Event is an INT7 event" << std::endl;
276 
277  // MC outlier cut
278  if(fIsPythia){
279  if(!CheckMCOutliers()){
280  AliDebugStream(3) << GetName() << ": Event identified as outlier" << std::endl;
281  return false;
282  } else {
283  AliDebugStream(3) << GetName() << ": Not an outlier event" << std::endl;
284  }
285  }
286 
287  // Generall event quality cuts
288  // The vertex cut also contains cuts on the number
289  // of contributors and the position in z
290  AliDebugStream(3) << GetName() << ": Applying vertex selection" << std::endl;
291  if(fAliAnalysisUtils){
292  if(!fAliAnalysisUtils->IsVertexSelected2013pA(InputEvent())) return false;
293  if(fAliAnalysisUtils->IsPileUpEvent(InputEvent())) return false;
294  AliDebugStream(3) << GetName() << ": Vertex selection passed" << std::endl;
295  }
296 
297  AliDebugStream(3) << GetName() << ": Applying EMCAL trigger selection" << std::endl;
298  if(fPatchType != kUndef){
300  AliDebugStream(3) << GetName() << ": Failed trigger selection" << std::endl;
301  return false;
302  }
303  }
304 
305  AliDebugStream(2) << GetName() << "Event selected" << std::endl;
306  return true;
307 }
308 
314  AliDebugStream(1) << GetName() << ": Inspecting event" << std::endl;
315  Double_t weight = 1.;
316  if(fIsPythia){
317  if(!fPythiaHeader){
318  AliErrorStream() << GetName() << ": PYTHIA event header not found" << std::endl;
319  } else {
321  }
322  }
323 
324  fHistos->FillTH1("hUserEventCount", 1, weight);
325  const AliVVertex *vtx = InputEvent()->GetPrimaryVertex();
326  fHistos->FillTH1("hUserVertexZ", vtx->GetZ(), weight);
327  fHistos->FillTH1("hUserPtHard", fPtHard);
328 
329  if(HasObservable(kTracks)){
330  AliDebugStream(3) << GetName() << ": eta-lab cut: " << fEtaLabCut << ", eta-cms cut: " << fEtaCmsCut << std::endl;
331 
332  AliVParticle *truepart(nullptr);
333  Bool_t isEMCAL(kFALSE);
334  if(MCEvent()){
335  for(int ipart = 0; ipart < fMCEvent->GetNumberOfTracks(); ipart++){
336  truepart = MCEvent()->GetTrack(ipart);
337 
338  // Select only particles within ALICE acceptance
339  if(!fEtaLabCut.IsInRange(truepart->Eta())) continue;
340  if(TMath::Abs(truepart->Pt()) < 0.1) continue;
341  if(!truepart->Charge()) continue;
342 
343  if(!IsPhysicalPrimary(truepart, fMCEvent)) continue;
344  AliAODMCParticle *aodmc = static_cast<AliAODMCParticle *>(truepart);
345  isEMCAL = (truepart->Phi() > 1.5 && truepart->Phi() < 3.1) ? kTRUE : kFALSE;
346 
347  // Calculate eta in cms frame according
348  // EPJC74 (2014) 3054:
349  // eta_cms = - eta_lab - |yshift|
350  Double_t etacent = -1. * truepart->Eta() - TMath::Abs(fYshift);
351  etacent *= fEtaSign;
352 
353  Bool_t etacentcut = fEtaCmsCut.IsInRange(etacent);
354 
355  // Get PID
356  TString pid = "";
357  switch(TMath::Abs(truepart->PdgCode())){
358  case kPiPlus: pid = "Pi"; break;
359  case kMuonMinus: pid = "Mu"; break;
360  case kElectron: pid = "El"; break;
361  case kKPlus: pid = "Ka"; break;
362  case kProton: pid = "Pr"; break;
363  default: pid = "Ot"; break;
364  };
365 
366  // Particle selected (do not filter TRD sectors for MC truth)
367  FillTrackHistos("True", weight, TMath::Abs(truepart->Pt()), truepart->Eta() * fEtaSign, etacent, truepart->Phi(), etacentcut, isEMCAL, pid);
368  }
369  }
370 
371  // Loop over tracks, fill select particles
372  // Histograms
373  // - Full eta (-0.8, 0.8), new binning
374  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c without eta cut
375  // - Central eta (-0.8, -0.2), new binning,
376  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c
377  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c with eta cut
378  AliVTrack *checktrack(NULL);
379  AliVParticle *assocMC(NULL);
380  double ptparticle(-1.), etaparticle(-100.), etaEMCAL(0.), phiEMCAL(0.);
381  for(int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
382  checktrack = dynamic_cast<AliVTrack *>(fInputEvent->GetTrack(itrk));
383  if(!checktrack) continue;
384  TString assocpid = "Ot";
385  // Find associated particle
386  if(MCEvent()){
387  assocMC = MCEvent()->GetTrack(TMath::Abs(checktrack->GetLabel()));
388  if(!assocMC) continue; // Fake track
389  if(!IsPhysicalPrimary(assocMC, fMCEvent)) continue;
390  // Get PID
391  switch(TMath::Abs(assocMC->PdgCode())){
392  case kPiPlus: assocpid = "Pi"; break;
393  case kMuonMinus: assocpid = "Mu"; break;
394  case kElectron: assocpid = "El"; break;
395  case kKPlus: assocpid = "Ka"; break;
396  case kProton: assocpid = "Pr"; break;
397  default: assocpid = "Ot"; break;
398  };
399  }
400 
401  // Select only particles within ALICE acceptance
402  if(!fEtaLabCut.IsInRange(checktrack->Eta())) continue;
403  if(TMath::Abs(checktrack->Pt()) < 0.1) continue;
404  if(checktrack->IsA() == AliESDtrack::Class()){
405  AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
406  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
407  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
408  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
409  } else {
410  AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
411  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
412  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
413  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
414  }
415  Int_t supermoduleID = -1;
416  isEMCAL = fGeom->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
417  // Exclude supermodules 10 and 11 as they did not participate in the trigger
418  isEMCAL = isEMCAL && supermoduleID < 10;
419 
420  if(!fTrackCuts->IsTrackAccepted(checktrack)) continue;
421 
422  // prefer true pt and eta, however in case of running on data take measured values
423  ptparticle = assocMC ? TMath::Abs(assocMC->Pt()) : TMath::Abs(checktrack->Pt());
424  etaparticle = assocMC ? assocMC->Eta() : checktrack->Eta();
425 
426  // Calculate eta in cms frame according
427  // EPJC74 (2014) 3054:
428  // eta_cms = - eta_lab - |yshift|
429  Double_t etacent = -1. * checktrack->Eta() - TMath::Abs(fYshift);
430  etacent *= fEtaSign;
431 
432  Bool_t etacentcut = fEtaCmsCut.IsInRange(etacent);
433 
434  FillTrackHistos("Accept", weight, ptparticle, checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, assocpid);
435  }
436  }
437 
439  Double_t vertexpos[3];
440  fInputEvent->GetPrimaryVertex()->GetXYZ(vertexpos);
441 
442  Double_t energy, et, eta, phi;
443  AliClusterContainer *clustercont = this->GetClusterContainer(fNameClusters.Data());
444  if(clustercont){
445  for(const auto &clust : clustercont->all()){
446  if(!clust->IsEMCAL()) continue;
447  if(clust->GetIsExotic()) continue;
448 
449  TLorentzVector posvec;
450  energy = clust->GetNonLinCorrEnergy();
451  et = posvec.Et();
452  clust->GetMomentum(posvec, vertexpos);
453  eta = posvec.Eta();
454  phi = posvec.Phi();
455  FillClusterHistos(weight, energy, et, eta, phi);
456  }
457  }
458  }
459 
461  AliEMCALTriggerPatchInfo *recpatch(nullptr);
462  TString patchname;
463  for(TIter patchiter = TIter(fTriggerPatchInfo).Begin(); patchiter != TIter::End(); ++patchiter){
464  recpatch = static_cast<AliEMCALTriggerPatchInfo *>(*patchiter);
465  if(!recpatch->IsOfflineSimple()) continue;
466  if(recpatch->IsJetHighSimple() && HasObservable(kEJEPatches)){
467  patchname = "EJE";
468  } else if(recpatch->IsGammaHighSimple() && HasObservable(kEGAPatches)){
469  patchname = "EGA";
470  } else continue;
471 
472  FillPatchHistos(patchname.Data(), weight, recpatch->GetPatchE(), recpatch->GetPatchET(), recpatch->GetEtaGeo(), recpatch->GetPhiGeo(), recpatch->GetColStart(), recpatch->GetRowStart());
473  }
474  }
475 
476  return true;
477 }
478 
491  const char *eventclass,
492  Double_t weight,
493  Double_t pt,
494  Double_t etalab,
495  Double_t etacent,
496  Double_t phi,
497  Bool_t etacut,
498  Bool_t inEmcal,
499  const char *pid
500  )
501 {
502  fHistos->FillTH1(Form("hTrackPtEtaAll%s", eventclass), TMath::Abs(pt), weight);
503  fHistos->FillTH1(Form("hTrackPtEtaAll%s%s", pid, eventclass), TMath::Abs(pt), weight);
504  if(inEmcal){
505  fHistos->FillTH1(Form("hTrackPtEMCALEtaAll%s", eventclass), TMath::Abs(pt), weight);
506  fHistos->FillTH1(Form("hTrackPtEMCALEtaAll%s%s", pid, eventclass), TMath::Abs(pt), weight);
507  }
508 
509  const std::array<int, 5> kPtMin = {1,2,5,10,20}; // for eta distributions
510  for(const auto &ptmin : kPtMin){
511  if(TMath::Abs(pt) > static_cast<double>(ptmin)){
512  fHistos->FillTH1(Form("hTrackPhiDistAllPt%d%s", ptmin, eventclass), phi, weight);
513  fHistos->FillTH1(Form("hTrackEtaLabDistAllPt%d%s", ptmin, eventclass), etalab, weight);
514  fHistos->FillTH1(Form("hTrackEtaCentDistAllPt%d%s", ptmin, eventclass), etacent, weight);
515  if(inEmcal){
516  fHistos->FillTH1(Form("hTrackEtaLabDistAllEMCALPt%d%s", ptmin, eventclass), etalab, weight);
517  fHistos->FillTH1(Form("hTrackEtaCentDistAllEMCALPt%d%s", ptmin, eventclass), etacent, weight);
518  }
519  }
520  }
521 
522  if(etacut){
523  fHistos->FillTH1(Form("hTrackPtEtaCent%s", eventclass), TMath::Abs(pt), weight);
524  fHistos->FillTH1(Form("hTrackPtEtaCent%s%s", pid, eventclass), TMath::Abs(pt), weight);
525  if(inEmcal){
526  fHistos->FillTH1(Form("hTrackPtEMCALEtaCent%s", eventclass), TMath::Abs(pt), weight);
527  fHistos->FillTH1(Form("hTrackPtEMCALEtaCent%s%s", pid, eventclass), TMath::Abs(pt), weight);
528  }
529  for(const auto &ptmin : kPtMin){
530  if(TMath::Abs(pt) > static_cast<double>(ptmin)){
531  fHistos->FillTH1(Form("hTrackEtaLabDistCutPt%d%s", ptmin, eventclass), etalab, weight);
532  fHistos->FillTH1(Form("hTrackEtaCentDistCutPt%d%s", ptmin, eventclass), etacent, weight);
533  if(inEmcal){
534  fHistos->FillTH1(Form("hTrackEtaLabDistCutEMCALPt%d%s", ptmin, eventclass), etalab, weight);
535  fHistos->FillTH1(Form("hTrackEtaCentDistCutEMCALPt%d%s", ptmin, eventclass), etacent, weight);
536  }
537  }
538  }
539  }
540 }
541 
551  double weight,
552  double energy,
553  double transverseenergy,
554  double eta,
555  double phi
556  )
557 {
558  Int_t supermoduleID = -1, sector = -1;
559  fGeom->SuperModuleNumberFromEtaPhi(eta, phi, supermoduleID);
560 
561  fHistos->FillTH1("hClusterEnergy", energy, weight);
562  fHistos->FillTH1("hClusterET", transverseenergy, weight);
563  fHistos->FillTH2("hClusterEtaEnergy", eta, energy, weight);
564  fHistos->FillTH2("hClusterEtaET", eta, transverseenergy, weight);
565  if(supermoduleID >= 0){
566  fHistos->FillTH2("hClusterEnergySM", supermoduleID, energy, weight);
567  fHistos->FillTH2("hClusterETSM", supermoduleID, transverseenergy, weight);
568  fHistos->FillTH2(Form("hClusterEtaEnergySM%d", supermoduleID), eta, energy, weight);
569  fHistos->FillTH2(Form("hClusterEtaETSM%d", supermoduleID), eta, transverseenergy, weight);
570  if(supermoduleID < 12)
571  sector = 4 + int(supermoduleID/2); // EMCAL
572  else
573  sector = 13 + int((supermoduleID-12)/2); // DCAL
574  fHistos->FillTH2(Form("hClusterEtaEnergySec%d", sector), eta, energy, weight);
575  fHistos->FillTH2(Form("hClusterEtaETSec%d", sector), eta, transverseenergy, weight);
576  }
577  std::array<Double_t, 5> encuts = {1., 2., 5., 10., 20.};
578  for(auto e : encuts){
579  if(energy > e){
580  fHistos->FillTH2(Form("hClusterEtaPhi%dG", static_cast<int>(e)), eta, phi, weight);
581  }
582  }
583 }
584 
592 void AliAnalysisTaskChargedParticlesMCTriggerMimic::FillPatchHistos(const char *patchname, double weight, double energy, double transverseenergy, double eta, double phi, int col, int row){
593  fHistos->FillTH1(Form("h%sPatchEnergy", patchname), energy, weight);
594  fHistos->FillTH1(Form("h%sPatchET", patchname), transverseenergy, weight);
595  fHistos->FillTH2(Form("h%sPatchEnergyEta", patchname), energy, eta, weight);
596  fHistos->FillTH2(Form("h%sPatchETEta", patchname), transverseenergy, eta, weight);
597  const std::array<Double_t, 5> kEnCuts = {1., 2., 5., 10., 20.};
598  for(auto e : kEnCuts){
599  if(energy > e){
600  fHistos->FillTH2(Form("h%sPatchEtaPhi%dG", patchname, static_cast<int>(e)), eta, phi, weight);
601  fHistos->FillTH2(Form("h%sPatchColRow%dG", patchname, static_cast<int>(e)), col, row, weight);
602  }
603  }
604 }
605 
606 
615 Bool_t AliAnalysisTaskChargedParticlesMCTriggerMimic::IsPhysicalPrimary(const AliVParticle* const part, AliMCEvent* const mcevent) {
616  Bool_t physprim = false;
617  const AliAODMCParticle *aodmc = dynamic_cast<const AliAODMCParticle *>(part);
618  if(aodmc){
619  physprim = aodmc->IsPhysicalPrimary();
620  } else {
621  physprim = mcevent->IsPhysicalPrimary(part->GetLabel());
622  }
623  return physprim;
624 }
625 
633 }
634 
643  bool selected = false;
644  AliEMCALTriggerPatchInfo *patch(nullptr);
645  AliDebugStream(2) << GetName() << ": Selecting EMCAL triggered event type (" << (fPatchType == kEMCEGA ? "EGA" : "EJE") << ") using patch energy above threshold" << std::endl;
646  AliDebugStream(2) << GetName() << ": Energy threshold " << fEnergyThreshold << " GeV" << std::endl;
647  AliDebugStream(2) << GetName() << ": Number of reconstructed patches " << triggerpatches->GetEntries() << std::endl;
648  for(TIter patchiter = TIter(triggerpatches).Begin(); patchiter != TIter::End(); ++patchiter){
649  patch = static_cast<AliEMCALTriggerPatchInfo *>(*patchiter);
650  AliDebugStream(4) << GetName() << ": Next patch" << std::endl;
651  if(!patch->IsOfflineSimple()) continue;
652  AliDebugStream(4) << GetName() << "Patch is an offline simple patch" << std::endl;
653  AliDebugStream(4) << GetName() << ": Trigger bits: " << std::bitset<32>(patch->GetTriggerBits()) << std::endl;
654  AliDebugStream(4) << GetName() << ": J1(" << patch->IsJetHighSimple() << "), J2(" << patch->IsJetLowSimple()
655  << "), G1(" << patch->IsGammaHighSimple() << ") G2(" << patch->IsGammaLowSimple() << ")" << std::endl;
656  if(fPatchType == kEMCEJE){
657  if(!patch->IsJetHighSimple()) continue;
658  AliDebugStream(3) << GetName() << ": Patch is jet high simple" << std::endl;
659  } else if(fPatchType == kEMCEGA){
660  if(!patch->IsGammaHighSimple()) continue;
661  AliDebugStream(4) << GetName() << ": Patch is gamma high simple" << std::endl;
662  }
663  AliDebugStream(3) << GetName() << ": Found trigger patch of matching type, now cutting on energy ...." << std::endl;
664  if(patch->GetPatchE() > fEnergyThreshold){
665  // firing trigger patch found
666  AliDebugStream(2) << GetName() << ": Firing trigger patch found at energy " << std::setprecision(1) << patch->GetPatchE() << std::endl;
667  selected = true;
668  break;
669  }
670  }
671  return selected;
672 }
673 
679 {
680  this->SetMinimum(0.);
681  this->AddStep(1, 0.05);
682  this->AddStep(2, 0.1);
683  this->AddStep(4, 0.2);
684  this->AddStep(7, 0.5);
685  this->AddStep(16, 1);
686  this->AddStep(36, 2);
687  this->AddStep(40, 4);
688  this->AddStep(50, 5);
689  this->AddStep(100, 10);
690  this->AddStep(200, 20);
691 }
692 
693 
694 } /* namespace EMCalTriggerPtAnalysis */
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)
void FillTrackHistos(const char *eventclass, Double_t weight, Double_t pt, Double_t eta, Double_t etacent, Double_t phi, Bool_t etacut, Bool_t inEmcal, const char *pid)
Base task in the EMCAL framework.
AliCutValueRange< double > fEtaCmsCut
Cut applied in Eta centre-of-mass frame.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Double_t fPtHard
!event pt hard
void AddStep(Double_t max, Double_t binwidth)
void FillPatchHistos(const char *patchname, double weight, double energy, double transverseenergy, double eta, double phi, int col, int row)
void SetCaloTriggerPatchInfoName(const char *n)
const AliClusterIterableContainer all() const
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
int Int_t
Definition: External.C:63
THashList * GetListOfHistograms() const
Definition: THistManager.h:504
AliEMCALGeometry * fGeom
!emcal geometry
AliGenPythiaEventHeader * fPythiaHeader
!event Pythia header
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
AliAnalysisUtils * fAliAnalysisUtils
!vertex selection (optional)
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Helper class creating user defined custom binning.
const Double_t ptmin
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
energy
double GetEventWeight(const AliMCEvent *const event) const
AliEmcalList * fOutput
!output list
void FillClusterHistos(double weight, double energy, double transversenergy, double eta, double phi)
Bool_t IsPhysicalPrimary(const AliVParticle *const part, AliMCEvent *const mcevent)
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
void SetMakeGeneralHistograms(Bool_t g)
TClonesArray * fTriggerPatchInfo
!trigger patch info array
void SetNeedEmcalGeom(Bool_t n)
Bool_t GetMomentum(TLorentzVector &mom, const AliVCluster *vc, Double_t mass) const
Container class for histograms for the high- charged particle analysis.
Definition: THistManager.h:43
Double_t fEtaSign
Sign of the eta distribution (swaps when beam directions swap): p-Pb: +1, Pb-p: -1.
bool Bool_t
Definition: External.C:53
Container structure for EMCAL clusters.
virtual bool IsTrackAccepted(AliVTrack *const trk)=0
void SetMinimum(Double_t min)