AliPhysics  b095172 (b095172)
 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  // Find associated particle
385  assocMC = MCEvent()->GetTrack(TMath::Abs(checktrack->GetLabel()));
386  if(!assocMC) continue; // Fake track
387  if(!IsPhysicalPrimary(assocMC, fMCEvent)) continue;
388 
389  // Select only particles within ALICE acceptance
390  if(!fEtaLabCut.IsInRange(checktrack->Eta())) continue;
391  if(TMath::Abs(checktrack->Pt()) < 0.1) continue;
392  if(checktrack->IsA() == AliESDtrack::Class()){
393  AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
394  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
395  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
396  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
397  } else {
398  AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
399  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
400  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
401  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
402  }
403  Int_t supermoduleID = -1;
404  isEMCAL = fGeom->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
405  // Exclude supermodules 10 and 11 as they did not participate in the trigger
406  isEMCAL = isEMCAL && supermoduleID < 10;
407 
408  if(!fTrackCuts->IsTrackAccepted(checktrack)) continue;
409 
410  ptparticle = TMath::Abs(assocMC->Pt());
411  etaparticle = assocMC->Eta();
412 
413  // Calculate eta in cms frame according
414  // EPJC74 (2014) 3054:
415  // eta_cms = - eta_lab - |yshift|
416  Double_t etacent = -1. * checktrack->Eta() - TMath::Abs(fYshift);
417  etacent *= fEtaSign;
418 
419  Bool_t etacentcut = fEtaCmsCut.IsInRange(etacent);
420 
421  // Get PID
422  TString assocpid = "";
423  switch(TMath::Abs(assocMC->PdgCode())){
424  case kPiPlus: assocpid = "Pi"; break;
425  case kMuonMinus: assocpid = "Mu"; break;
426  case kElectron: assocpid = "El"; break;
427  case kKPlus: assocpid = "Ka"; break;
428  case kProton: assocpid = "Pr"; break;
429  default: assocpid = "Ot"; break;
430  };
431 
432  FillTrackHistos("Accept", weight, ptparticle, checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), etacentcut, isEMCAL, assocpid);
433  }
434  }
435 
437  Double_t vertexpos[3];
438  fInputEvent->GetPrimaryVertex()->GetXYZ(vertexpos);
439 
440  Double_t energy, et, eta, phi;
441  AliClusterContainer *clustercont = this->GetClusterContainer(fNameClusters.Data());
442  if(clustercont){
443  for(const auto &clust : clustercont->all()){
444  if(!clust->IsEMCAL()) continue;
445  if(clust->GetIsExotic()) continue;
446 
447  TLorentzVector posvec;
448  energy = clust->GetNonLinCorrEnergy();
449  et = posvec.Et();
450  clust->GetMomentum(posvec, vertexpos);
451  eta = posvec.Eta();
452  phi = posvec.Phi();
453  FillClusterHistos(weight, energy, et, eta, phi);
454  }
455  }
456  }
457 
459  AliEMCALTriggerPatchInfo *recpatch(nullptr);
460  TString patchname;
461  for(TIter patchiter = TIter(fTriggerPatchInfo).Begin(); patchiter != TIter::End(); ++patchiter){
462  recpatch = static_cast<AliEMCALTriggerPatchInfo *>(*patchiter);
463  if(!recpatch->IsOfflineSimple()) continue;
464  if(recpatch->IsJetHighSimple() && HasObservable(kEJEPatches)){
465  patchname = "EJE";
466  } else if(recpatch->IsGammaHighSimple() && HasObservable(kEGAPatches)){
467  patchname = "EGA";
468  } else continue;
469 
470  FillPatchHistos(patchname.Data(), weight, recpatch->GetPatchE(), recpatch->GetPatchET(), recpatch->GetEtaGeo(), recpatch->GetPhiGeo(), recpatch->GetColStart(), recpatch->GetRowStart());
471  }
472  }
473 
474  return true;
475 }
476 
489  const char *eventclass,
490  Double_t weight,
491  Double_t pt,
492  Double_t etalab,
493  Double_t etacent,
494  Double_t phi,
495  Bool_t etacut,
496  Bool_t inEmcal,
497  const char *pid
498  )
499 {
500  fHistos->FillTH1(Form("hTrackPtEtaAll%s", eventclass), TMath::Abs(pt), weight);
501  fHistos->FillTH1(Form("hTrackPtEtaAll%s%s", pid, eventclass), TMath::Abs(pt), weight);
502  if(inEmcal){
503  fHistos->FillTH1(Form("hTrackPtEMCALEtaAll%s", eventclass), TMath::Abs(pt), weight);
504  fHistos->FillTH1(Form("hTrackPtEMCALEtaAll%s%s", pid, eventclass), TMath::Abs(pt), weight);
505  }
506 
507  const std::array<int, 5> kPtMin = {1,2,5,10,20}; // for eta distributions
508  for(const auto &ptmin : kPtMin){
509  if(TMath::Abs(pt) > static_cast<double>(ptmin)){
510  fHistos->FillTH1(Form("hTrackPhiDistAllPt%d%s", ptmin, eventclass), phi, weight);
511  fHistos->FillTH1(Form("hTrackEtaLabDistAllPt%d%s", ptmin, eventclass), etalab, weight);
512  fHistos->FillTH1(Form("hTrackEtaCentDistAllPt%d%s", ptmin, eventclass), etacent, weight);
513  if(inEmcal){
514  fHistos->FillTH1(Form("hTrackEtaLabDistAllEMCALPt%d%s", ptmin, eventclass), etalab, weight);
515  fHistos->FillTH1(Form("hTrackEtaCentDistAllEMCALPt%d%s", ptmin, eventclass), etacent, weight);
516  }
517  }
518  }
519 
520  if(etacut){
521  fHistos->FillTH1(Form("hTrackPtEtaCent%s", eventclass), TMath::Abs(pt), weight);
522  fHistos->FillTH1(Form("hTrackPtEtaCent%s%s", pid, eventclass), TMath::Abs(pt), weight);
523  if(inEmcal){
524  fHistos->FillTH1(Form("hTrackPtEMCALEtaCent%s", eventclass), TMath::Abs(pt), weight);
525  fHistos->FillTH1(Form("hTrackPtEMCALEtaCent%s%s", pid, eventclass), TMath::Abs(pt), weight);
526  }
527  for(const auto &ptmin : kPtMin){
528  if(TMath::Abs(pt) > static_cast<double>(ptmin)){
529  fHistos->FillTH1(Form("hTrackEtaLabDistCutPt%d%s", ptmin, eventclass), etalab, weight);
530  fHistos->FillTH1(Form("hTrackEtaCentDistCutPt%d%s", ptmin, eventclass), etacent, weight);
531  if(inEmcal){
532  fHistos->FillTH1(Form("hTrackEtaLabDistCutEMCALPt%d%s", ptmin, eventclass), etalab, weight);
533  fHistos->FillTH1(Form("hTrackEtaCentDistCutEMCALPt%d%s", ptmin, eventclass), etacent, weight);
534  }
535  }
536  }
537  }
538 }
539 
549  double weight,
550  double energy,
551  double transverseenergy,
552  double eta,
553  double phi
554  )
555 {
556  Int_t supermoduleID = -1, sector = -1;
557  fGeom->SuperModuleNumberFromEtaPhi(eta, phi, supermoduleID);
558 
559  fHistos->FillTH1("hClusterEnergy", energy, weight);
560  fHistos->FillTH1("hClusterET", transverseenergy, weight);
561  fHistos->FillTH2("hClusterEtaEnergy", eta, energy, weight);
562  fHistos->FillTH2("hClusterEtaET", eta, transverseenergy, weight);
563  if(supermoduleID >= 0){
564  fHistos->FillTH2("hClusterEnergySM", supermoduleID, energy, weight);
565  fHistos->FillTH2("hClusterETSM", supermoduleID, transverseenergy, weight);
566  fHistos->FillTH2(Form("hClusterEtaEnergySM%d", supermoduleID), eta, energy, weight);
567  fHistos->FillTH2(Form("hClusterEtaETSM%d", supermoduleID), eta, transverseenergy, weight);
568  if(supermoduleID < 12)
569  sector = 4 + int(supermoduleID/2); // EMCAL
570  else
571  sector = 13 + int((supermoduleID-12)/2); // DCAL
572  fHistos->FillTH2(Form("hClusterEtaEnergySec%d", sector), eta, energy, weight);
573  fHistos->FillTH2(Form("hClusterEtaETSec%d", sector), eta, transverseenergy, weight);
574  }
575  std::array<Double_t, 5> encuts = {1., 2., 5., 10., 20.};
576  for(auto e : encuts){
577  if(energy > e){
578  fHistos->FillTH2(Form("hClusterEtaPhi%dG", static_cast<int>(e)), eta, phi, weight);
579  }
580  }
581 }
582 
590 void AliAnalysisTaskChargedParticlesMCTriggerMimic::FillPatchHistos(const char *patchname, double weight, double energy, double transverseenergy, double eta, double phi, int col, int row){
591  fHistos->FillTH1(Form("h%sPatchEnergy", patchname), energy, weight);
592  fHistos->FillTH1(Form("h%sPatchET", patchname), transverseenergy, weight);
593  fHistos->FillTH2(Form("h%sPatchEnergyEta", patchname), energy, eta, weight);
594  fHistos->FillTH2(Form("h%sPatchETEta", patchname), transverseenergy, eta, weight);
595  const std::array<Double_t, 5> kEnCuts = {1., 2., 5., 10., 20.};
596  for(auto e : kEnCuts){
597  if(energy > e){
598  fHistos->FillTH2(Form("h%sPatchEtaPhi%dG", patchname, static_cast<int>(e)), eta, phi, weight);
599  fHistos->FillTH2(Form("h%sPatchColRow%dG", patchname, static_cast<int>(e)), col, row, weight);
600  }
601  }
602 }
603 
604 
613 Bool_t AliAnalysisTaskChargedParticlesMCTriggerMimic::IsPhysicalPrimary(const AliVParticle* const part, AliMCEvent* const mcevent) {
614  Bool_t physprim = false;
615  const AliAODMCParticle *aodmc = dynamic_cast<const AliAODMCParticle *>(part);
616  if(aodmc){
617  physprim = aodmc->IsPhysicalPrimary();
618  } else {
619  physprim = mcevent->IsPhysicalPrimary(part->GetLabel());
620  }
621  return physprim;
622 }
623 
631 }
632 
641  bool selected = false;
642  AliEMCALTriggerPatchInfo *patch(nullptr);
643  AliDebugStream(2) << GetName() << ": Selecting EMCAL triggered event type (" << (fPatchType == kEMCEGA ? "EGA" : "EJE") << ") using patch energy above threshold" << std::endl;
644  AliDebugStream(2) << GetName() << ": Energy threshold " << fEnergyThreshold << " GeV" << std::endl;
645  AliDebugStream(2) << GetName() << ": Number of reconstructed patches " << triggerpatches->GetEntries() << std::endl;
646  for(TIter patchiter = TIter(triggerpatches).Begin(); patchiter != TIter::End(); ++patchiter){
647  patch = static_cast<AliEMCALTriggerPatchInfo *>(*patchiter);
648  AliDebugStream(4) << GetName() << ": Next patch" << std::endl;
649  if(!patch->IsOfflineSimple()) continue;
650  AliDebugStream(4) << GetName() << "Patch is an offline simple patch" << std::endl;
651  AliDebugStream(4) << GetName() << ": Trigger bits: " << std::bitset<32>(patch->GetTriggerBits()) << std::endl;
652  AliDebugStream(4) << GetName() << ": J1(" << patch->IsJetHighSimple() << "), J2(" << patch->IsJetLowSimple()
653  << "), G1(" << patch->IsGammaHighSimple() << ") G2(" << patch->IsGammaLowSimple() << ")" << std::endl;
654  if(fPatchType == kEMCEJE){
655  if(!patch->IsJetHighSimple()) continue;
656  AliDebugStream(3) << GetName() << ": Patch is jet high simple" << std::endl;
657  } else if(fPatchType == kEMCEGA){
658  if(!patch->IsGammaHighSimple()) continue;
659  AliDebugStream(4) << GetName() << ": Patch is gamma high simple" << std::endl;
660  }
661  AliDebugStream(3) << GetName() << ": Found trigger patch of matching type, now cutting on energy ...." << std::endl;
662  if(patch->GetPatchE() > fEnergyThreshold){
663  // firing trigger patch found
664  AliDebugStream(2) << GetName() << ": Firing trigger patch found at energy " << std::setprecision(1) << patch->GetPatchE() << std::endl;
665  selected = true;
666  break;
667  }
668  }
669  return selected;
670 }
671 
677 {
678  this->SetMinimum(0.);
679  this->AddStep(1, 0.05);
680  this->AddStep(2, 0.1);
681  this->AddStep(4, 0.2);
682  this->AddStep(7, 0.5);
683  this->AddStep(16, 1);
684  this->AddStep(36, 2);
685  this->AddStep(40, 4);
686  this->AddStep(50, 5);
687  this->AddStep(100, 10);
688  this->AddStep(200, 20);
689 }
690 
691 
692 } /* 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)