AliPhysics  dc874a1 (dc874a1)
 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 "AliAnalysisDataContainer.h"
26 #include "AliAnalysisManager.h"
27 #include "AliAnalysisUtils.h"
28 #include "AliAODInputHandler.h"
29 #include "AliAODTrack.h"
31 #include "AliEMCALGeometry.h"
32 #include "AliEMCALRecoUtils.h"
33 #include "AliEMCALTriggerPatchInfo.h"
34 #include "AliEmcalTrackSelection.h"
35 #include "AliESDtrackCuts.h"
36 #include "AliESDEvent.h"
37 #include "AliInputEventHandler.h"
38 #include "AliPIDResponse.h"
39 #include "AliTOFPIDResponse.h"
40 #include "AliVEvent.h"
41 #include "AliVEventHandler.h"
42 #include "AliVVertex.h"
43 
46 
50 
51 namespace EMCalTriggerPtAnalysis {
52 
53 AliAnalysisTaskChargedParticlesRef::AliAnalysisTaskChargedParticlesRef() :
55  fTrackCuts(nullptr),
56  fYshift(0.465),
57  fEtaSign(1),
58  fEtaLabCut(-0.5, 0.5),
59  fEtaCmsCut(-2., 2.),
60  fPhiCut(0., TMath::TwoPi()),
61  fStudyPID(false)
62 {
63 }
64 
67  fTrackCuts(nullptr),
68  fYshift(0.465),
69  fEtaSign(1),
70  fEtaLabCut(-0.5, 0.5),
71  fEtaCmsCut(-2., 2.),
72  fPhiCut(0., TMath::TwoPi()),
73  fStudyPID(false)
74 {
75  SetNeedEmcalGeom(true);
76  SetCaloTriggerPatchInfoName("EmcalTriggers");
77 }
78 
80  //if(fTrackCuts) delete fTrackCuts;
81 }
82 
84  if(!fTrackCuts) InitializeTrackCuts("standard", fInputHandler->IsA() == AliAODInputHandler::Class());
85 }
86 
88 
89  PtBinning newbinning;
90 
91  // Binning for the PID histogram
92  const int kdimPID = 3;
93  const int knbinsPID[kdimPID] = {1000, 200, 300};
94  const double kminPID[kdimPID] = {-100., 0., 0.}, kmaxPID[kdimPID] = {100., 200., 1.5};
95  for(auto trg : GetSupportedTriggers()){
96  fHistos->CreateTH1(Form("hEventCount%s", trg.Data()), Form("Event Counter for trigger class %s", trg.Data()), 1, 0.5, 1.5);
97  fHistos->CreateTH1(Form("hVertexBefore%s", trg.Data()), Form("Vertex distribution before z-cut for trigger class %s", trg.Data()), 500, -50, 50);
98  fHistos->CreateTH1(Form("hVertexAfter%s", trg.Data()), Form("Vertex distribution after z-cut for trigger class %s", trg.Data()), 100, -10, 10);
99 
100  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()));
101  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()));
102  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()));
103  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()));
104 
105  if(fStudyPID){
106  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.);
107  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);
108  fHistos->CreateTHnSparse(Form("hPIDcorrEMCAL%s", trg.Data()), Form("Correlation of PID observables for Trigger %s", trg.Data()), kdimPID, knbinsPID, kminPID, kmaxPID);
109  }
110  }
111 }
112 
114  Bool_t hasPIDresponse = fInputHandler->GetPIDResponse() != nullptr;
115  if(fStudyPID && !hasPIDresponse) AliErrorStream() << "PID requested but PID response not available" << std::endl;
116 
117 
118  // Loop over tracks, fill select particles
119  // Histograms
120  // - Full eta_{lab} (-0.8, 0.8), new binning
121  // - Full eta_{lab} (-0.8, 0.8), old binning
122  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c without eta cut
123  // - Central eta_{cms} (-0.3, -0.2), new binning,
124  // - Central eta_{cms} (-0.8, -0.2), old binning,
125  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c
126  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c with eta cut
127  AliVTrack *checktrack(nullptr);
128  int ptmin[5] = {1,2,5,10,20}; // for eta distributions
129  Bool_t isEMCAL(kFALSE);
130  Double_t etaEMCAL(0.), phiEMCAL(0.);
131  for(int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
132  checktrack = dynamic_cast<AliVTrack *>(fInputEvent->GetTrack(itrk));
133  if(!checktrack) continue;
134  if(!fEtaLabCut.IsInRange(checktrack->Eta())) continue;
135  if(!fPhiCut.IsInRange(checktrack->Phi())) continue;
136  if(TMath::Abs(checktrack->Pt()) < 0.1) continue;
137  if(checktrack->IsA() == AliESDtrack::Class()){
138  AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
139  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
140  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
141  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
142  } else {
143  AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
144  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
145  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
146  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
147  }
148  Int_t supermoduleID = -1;
149  isEMCAL = fGeom->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
150  // Exclude supermodules 10 and 11 as they did not participate in the trigger
151  isEMCAL = isEMCAL && supermoduleID < 10;
152 
153  // Calculate eta in cms frame according
154  // EPJC74 (2014) 3054:
155  // eta_cms = - eta_lab - |yshift|
156  Double_t etacent = -1. * checktrack->Eta() - TMath::Abs(fYshift);
157  etacent *= fEtaSign;
158 
159  if(!fEtaCmsCut.IsInRange(etacent)) continue; // Apply eta-cent cut
160  if(!fTrackCuts->IsTrackAccepted(checktrack)) continue;
161 
162  for(const auto &t : fSelectedTriggers){
163  FillTrackHistos(t, checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), isEMCAL);
164  if(fStudyPID && hasPIDresponse)
165  if(isEMCAL) FillPIDHistos(t, *checktrack);
166  }
167  }
168  return true;
169 }
170 
172  // Apply vertex z cut
173  for(const auto &t : fSelectedTriggers){
174  Double_t weight = GetTriggerWeight(t);
175  fHistos->FillTH1(Form("hVertexBefore%s", t.Data()), fVertex[2], weight);
176  }
177 }
178 
180  for(const auto &t : fSelectedTriggers) {
181  Double_t weight = GetTriggerWeight(t);
182  // Fill Event counter and reference vertex distributions after event selection
183  fHistos->FillTH1(Form("hEventCount%s", t.Data()), 1, weight);
184  fHistos->FillTH1(Form("hVertexAfter%s", t.Data()), fVertex[2], weight);
185  }
186 }
187 
189  const TString &eventclass,
190  Double_t pt,
191  Double_t etalab,
192  Double_t etacent,
193  Double_t phi,
194  Bool_t inEmcal
195  )
196 {
197  Double_t weight = GetTriggerWeight(eventclass);
198  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << eventclass << " in particle histograms." << std::endl;
199  double kinepointall[3] = {TMath::Abs(pt), etalab, phi}, kinepointcent[3] = {TMath::Abs(pt), etacent, phi};
200  fHistos->FillTH3(Form("hPtEtaPhiAll%s", eventclass.Data()), kinepointall, weight);
201  fHistos->FillTH3(Form("hPtEtaPhiCent%s", eventclass.Data()), kinepointcent, weight);
202  if(inEmcal){
203  fHistos->FillTH3(Form("hPtEtaPhiEMCALAll%s", eventclass.Data()), kinepointall, weight);
204  fHistos->FillTH3(Form("hPtEtaPhiEMCALCent%s", eventclass.Data()), kinepointall, weight);
205  }
206 }
207 
209  const TString &eventclass,
210  const AliVTrack &trk
211 ) {
212  Double_t weight = GetTriggerWeight(eventclass);
213  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << eventclass << " in PID histograms." << std::endl;
214  AliPIDResponse *pid = fInputHandler->GetPIDResponse();
215  if(TMath::Abs(trk.Eta()) > 0.5) return;
216  if(!((trk.GetStatus() & AliVTrack::kTOFout) && (trk.GetStatus() & AliVTrack::kTIME))) return;
217 
218  double poverz = TMath::Abs(trk.P())/static_cast<double>(trk.Charge());
219  fHistos->FillTH2(Form("hTPCdEdxEMCAL%s", eventclass.Data()), poverz, trk.GetTPCsignal(), weight);
220  // correct for units - TOF in ps, track length in cm
221  Double_t trtime = (trk.GetTOFsignal() - pid->GetTOFResponse().GetTimeZero()) * 1e-12;
222  Double_t v = trk.GetIntegratedLength()/(100. * trtime);
223  Double_t beta = v / TMath::C();
224  fHistos->FillTH2(Form("hTOFBetaEMCAL%s", eventclass.Data()), poverz, beta, weight);
225  double datapoint[3] = {poverz, trk.GetTPCsignal(), beta};
226  fHistos->FillTHnSparse(Form("hPIDcorrEMCAL%s", eventclass.Data()), datapoint, weight);
227 }
228 
231 }
232 
234  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
235 
236  TString taskname = "chargedParticleQA_" + suffix;
237 
239  mgr->AddTask(task);
240 
241  TString outfile(mgr->GetCommonFileName());
242  outfile += ":ChargedParticleQA_" + suffix;
243  TString containername = "TrackResults_" + suffix;
244 
245  task->ConnectInput(0, mgr->GetCommonInputContainer());
246  mgr->ConnectOutput(task, 1, mgr->CreateContainer(containername.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
247 
248  return task;
249 }
250 
252  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
253 
255  mgr->AddTask(task);
256 
257  // Set Energy thresholds for additional patch selection:
258  // These are events with offline patches of a given type where the trigger reached already the plateau
259  // These numers are determined as:
260  // EMC7: 5 GeV
261  // EG1: 14 GeV
262  // EG2: 8 GeV
263  // EJ1: 22 GeV
264  // EJ2: 12 GeV
265  mgr->AddTask(task);
268  );
271  cutname,
272  mgr->GetInputEventHandler()->IsA() == AliAODInputHandler::Class()
273  )
274  );
275 
276  TString outfile(mgr->GetCommonFileName());
277  outfile += ":ChargedParticleQA_%s" + cutname;
278 
279  task->ConnectInput(0, mgr->GetCommonInputContainer());
280  mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form("TrackResults_%s", cutname.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
281 
282  return task;
283 }
284 
287 {
288  this->SetMinimum(0.);
289  this->AddStep(1, 0.05);
290  this->AddStep(2, 0.1);
291  this->AddStep(4, 0.2);
292  this->AddStep(7, 0.5);
293  this->AddStep(16, 1);
294  this->AddStep(36, 2);
295  this->AddStep(40, 4);
296  this->AddStep(50, 5);
297  this->AddStep(100, 10);
298  this->AddStep(200, 20);
299 }
300 
301 } /* 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)
static AliAnalysisTaskChargedParticlesRef * AddTaskChargedParticlesRef(const TString &suffix)
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 SetOfflineTriggerSelection(AliEmcalTriggerOfflineSelection *sel)
void SetCaloTriggerPatchInfoName(const char *n)
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
static AliAnalysisTaskChargedParticlesRef * AddTaskChargedParticlesRefDefault(const TString &cutname="standard")
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
static AliEmcalTriggerOfflineSelection * TriggerSelectionFactory(Double_t el0, Double_t eg1, Double_t eg2, Double_t ej1, Double_t ej2)
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)