AliPhysics  1a228f7 (1a228f7)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskChargedParticlesRef.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 <algorithm>
16 #include <array>
17 #include <functional>
18 #include <iostream>
19 #include <map>
20 
21 #include <TMath.h>
22 #include <THistManager.h>
23 #include <TLinearBinning.h>
24 
25 #include "AliAnalysisUtils.h"
26 #include "AliAODInputHandler.h"
27 #include "AliAODTrack.h"
29 #include "AliEMCALGeometry.h"
30 #include "AliEMCALRecoUtils.h"
31 #include "AliEMCALTriggerPatchInfo.h"
32 #include "AliEmcalTrackSelection.h"
33 #include "AliESDtrackCuts.h"
34 #include "AliESDEvent.h"
35 #include "AliInputEventHandler.h"
36 #include "AliPIDResponse.h"
37 #include "AliTOFPIDResponse.h"
38 #include "AliVVertex.h"
39 
42 
46 
47 namespace EMCalTriggerPtAnalysis {
48 
49 AliAnalysisTaskChargedParticlesRef::AliAnalysisTaskChargedParticlesRef() :
51  fTrackCuts(nullptr),
52  fYshift(0.465),
53  fEtaSign(1),
54  fEtaLabCut(-0.5, 0.5),
55  fEtaCmsCut(-2., 2.),
56  fPhiCut(0., TMath::TwoPi()),
57  fStudyPID(false)
58 {
59 }
60 
63  fTrackCuts(nullptr),
64  fYshift(0.465),
65  fEtaSign(1),
66  fEtaLabCut(-0.5, 0.5),
67  fEtaCmsCut(-2., 2.),
68  fPhiCut(0., TMath::TwoPi()),
69  fStudyPID(false)
70 {
71  SetNeedEmcalGeom(true);
72  SetCaloTriggerPatchInfoName("EmcalTriggers");
73 }
74 
76  //if(fTrackCuts) delete fTrackCuts;
77 }
78 
80  if(!fTrackCuts) InitializeTrackCuts("standard", fInputHandler->IsA() == AliAODInputHandler::Class());
81 }
82 
84 
85  PtBinning newbinning;
86 
87  // Binning for the PID histogram
88  const int kdimPID = 3;
89  const int knbinsPID[kdimPID] = {1000, 200, 300};
90  const double kminPID[kdimPID] = {-100., 0., 0.}, kmaxPID[kdimPID] = {100., 200., 1.5};
91  for(auto trg : GetSupportedTriggers()){
92  fHistos->CreateTH1(Form("hEventCount%s", trg.Data()), Form("Event Counter for trigger class %s", trg.Data()), 1, 0.5, 1.5);
93  fHistos->CreateTH1(Form("hVertexBefore%s", trg.Data()), Form("Vertex distribution before z-cut for trigger class %s", trg.Data()), 500, -50, 50);
94  fHistos->CreateTH1(Form("hVertexAfter%s", trg.Data()), Form("Vertex distribution after z-cut for trigger class %s", trg.Data()), 100, -10, 10);
95 
96  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()));
97  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()));
98  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()));
99  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()));
100 
101  if(fStudyPID){
102  fHistos->CreateTH2(Form("hTPCdEdxEMCAL%s", trg.Data()), Form("TPC dE/dx of charged particles in the EMCAL region for trigger %s", trg.Data()), 400, -20., 20., 200, 0., 200.);
103  fHistos->CreateTH2(Form("hTOFBetaEMCAL%s", trg.Data()), Form("TOF beta of charged particles in the EMCAL region for trigger %s", trg.Data()), 400, -20., 20., 150, 0., 1.5);
104  fHistos->CreateTHnSparse(Form("hPIDcorrEMCAL%s", trg.Data()), Form("Correlation of PID observables for Trigger %s", trg.Data()), kdimPID, knbinsPID, kminPID, kmaxPID);
105  }
106  }
107 }
108 
110  Bool_t hasPIDresponse = fInputHandler->GetPIDResponse() != nullptr;
111  if(fStudyPID && !hasPIDresponse) AliErrorStream() << "PID requested but PID response not available" << std::endl;
112 
113 
114  // Loop over tracks, fill select particles
115  // Histograms
116  // - Full eta_{lab} (-0.8, 0.8), new binning
117  // - Full eta_{lab} (-0.8, 0.8), old binning
118  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c without eta cut
119  // - Central eta_{cms} (-0.3, -0.2), new binning,
120  // - Central eta_{cms} (-0.8, -0.2), old binning,
121  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c
122  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c with eta cut
123  AliVTrack *checktrack(nullptr);
124  int ptmin[5] = {1,2,5,10,20}; // for eta distributions
125  Bool_t isEMCAL(kFALSE);
126  Double_t etaEMCAL(0.), phiEMCAL(0.);
127  for(int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
128  checktrack = dynamic_cast<AliVTrack *>(fInputEvent->GetTrack(itrk));
129  if(!checktrack) continue;
130  if(!fEtaLabCut.IsInRange(checktrack->Eta())) continue;
131  if(!fPhiCut.IsInRange(checktrack->Phi())) continue;
132  if(TMath::Abs(checktrack->Pt()) < 0.1) continue;
133  if(checktrack->IsA() == AliESDtrack::Class()){
134  AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
135  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
136  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
137  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
138  } else {
139  AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
140  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
141  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
142  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
143  }
144  Int_t supermoduleID = -1;
145  isEMCAL = fGeom->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
146  // Exclude supermodules 10 and 11 as they did not participate in the trigger
147  isEMCAL = isEMCAL && supermoduleID < 10;
148 
149  // Calculate eta in cms frame according
150  // EPJC74 (2014) 3054:
151  // eta_cms = - eta_lab - |yshift|
152  Double_t etacent = -1. * checktrack->Eta() - TMath::Abs(fYshift);
153  etacent *= fEtaSign;
154 
155  if(!fEtaCmsCut.IsInRange(etacent)) continue; // Apply eta-cent cut
156  if(!fTrackCuts->IsTrackAccepted(checktrack)) continue;
157 
158  for(const auto &t : fSelectedTriggers){
159  FillTrackHistos(t, checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), isEMCAL);
160  if(fStudyPID && hasPIDresponse)
161  if(isEMCAL) FillPIDHistos(t, *checktrack);
162  }
163  }
164  return true;
165 }
166 
168  // Apply vertex z cut
169  for(const auto &t : fSelectedTriggers){
170  Double_t weight = GetTriggerWeight(t);
171  fHistos->FillTH1(Form("hVertexBefore%s", t.Data()), fVertex[2], weight);
172  }
173 }
174 
176  for(const auto &t : fSelectedTriggers) {
177  Double_t weight = GetTriggerWeight(t);
178  // Fill Event counter and reference vertex distributions after event selection
179  fHistos->FillTH1(Form("hEventCount%s", t.Data()), 1, weight);
180  fHistos->FillTH1(Form("hVertexAfter%s", t.Data()), fVertex[2], weight);
181  }
182 }
183 
185  const TString &eventclass,
186  Double_t pt,
187  Double_t etalab,
188  Double_t etacent,
189  Double_t phi,
190  Bool_t inEmcal
191  )
192 {
193  Double_t weight = GetTriggerWeight(eventclass);
194  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << eventclass << " in particle histograms." << std::endl;
195  double kinepointall[3] = {TMath::Abs(pt), etalab, phi}, kinepointcent[3] = {TMath::Abs(pt), etacent, phi};
196  fHistos->FillTH3(Form("hPtEtaPhiAll%s", eventclass.Data()), kinepointall, weight);
197  fHistos->FillTH3(Form("hPtEtaPhiCent%s", eventclass.Data()), kinepointcent, weight);
198  if(inEmcal){
199  fHistos->FillTH3(Form("hPtEtaPhiEMCALAll%s", eventclass.Data()), kinepointall, weight);
200  fHistos->FillTH3(Form("hPtEtaPhiEMCALCent%s", eventclass.Data()), kinepointall, weight);
201  }
202 }
203 
205  const TString &eventclass,
206  const AliVTrack &trk
207 ) {
208  Double_t weight = GetTriggerWeight(eventclass);
209  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << eventclass << " in PID histograms." << std::endl;
210  AliPIDResponse *pid = fInputHandler->GetPIDResponse();
211  if(TMath::Abs(trk.Eta()) > 0.5) return;
212  if(!((trk.GetStatus() & AliVTrack::kTOFout) && (trk.GetStatus() & AliVTrack::kTIME))) return;
213 
214  double poverz = TMath::Abs(trk.P())/static_cast<double>(trk.Charge());
215  fHistos->FillTH2(Form("hTPCdEdxEMCAL%s", eventclass.Data()), poverz, trk.GetTPCsignal(), weight);
216  // correct for units - TOF in ps, track length in cm
217  Double_t trtime = (trk.GetTOFsignal() - pid->GetTOFResponse().GetTimeZero()) * 1e-12;
218  Double_t v = trk.GetIntegratedLength()/(100. * trtime);
219  Double_t beta = v / TMath::C();
220  fHistos->FillTH2(Form("hTOFBetaEMCAL%s", eventclass.Data()), poverz, beta, weight);
221  double datapoint[3] = {poverz, trk.GetTPCsignal(), beta};
222  fHistos->FillTHnSparse(Form("hPIDcorrEMCAL%s", eventclass.Data()), datapoint, weight);
223 }
224 
227 }
228 
231 {
232  this->SetMinimum(0.);
233  this->AddStep(1, 0.05);
234  this->AddStep(2, 0.1);
235  this->AddStep(4, 0.2);
236  this->AddStep(7, 0.5);
237  this->AddStep(16, 1);
238  this->AddStep(36, 2);
239  this->AddStep(40, 4);
240  this->AddStep(50, 5);
241  this->AddStep(100, 10);
242  this->AddStep(200, 20);
243 }
244 
245 } /* namespace EMCalTriggerPtAnalysis */
std::vector< TString > fSelectedTriggers
! Triggers selected for given event
double Double_t
Definition: External.C:58
Double_t fEtaSign
Sign of the eta distribution (swaps when beam directions swap): p-Pb: +1, Pb-p: -1.
Class creating a linear binning, used in the histogram manager.
static AliEmcalTrackSelection * TrackCutsFactory(TString name, Bool_t isAOD)
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
void FillTH3(const char *hname, double x, double y, double z, double weight=1., Option_t *opt="")
void AddStep(Double_t max, Double_t binwidth)
void SetCaloTriggerPatchInfoName(const char *n)
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
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
AliEMCALGeometry * fGeom
!emcal geometry
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Helper class creating user defined custom binning.
const Double_t ptmin
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Declaration of class AliEMCalTriggerExtraCuts.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Double_t fVertex[3]
!event vertex
void FillPIDHistos(const TString &eventclass, const AliVTrack &track)
void SetNeedEmcalGeom(Bool_t n)
bool Bool_t
Definition: External.C:53
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
void FillTrackHistos(const TString &eventclass, Double_t pt, Double_t eta, Double_t etacent, Double_t phi, Bool_t inEmcal)
TH3 * CreateTH3(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, int nbinsz, double zmin, double zmax, Option_t *opt="")
virtual bool IsTrackAccepted(AliVTrack *const trk)=0
void SetMinimum(Double_t min)