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