AliPhysics  7f2a7c4 (7f2a7c4)
 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  fMinPt(0.1),
59  fEtaLabCut(-0.5, 0.5),
60  fEtaCmsCut(-2., 2.),
61  fPhiCut(0., TMath::TwoPi()),
62  fStudyPID(false),
63  fEnableSumw2(false)
64 {
65 }
66 
69  fTrackCuts(nullptr),
70  fYshift(0.465),
71  fEtaSign(1),
72  fMinPt(0.1),
73  fEtaLabCut(-0.5, 0.5),
74  fEtaCmsCut(-2., 2.),
75  fPhiCut(0., TMath::TwoPi()),
76  fStudyPID(false),
77  fEnableSumw2(false)
78 {
79  SetNeedEmcalGeom(true);
80  SetCaloTriggerPatchInfoName("EmcalTriggers");
81 }
82 
84  //if(fTrackCuts) delete fTrackCuts;
85 }
86 
88  if(!fTrackCuts) InitializeTrackCuts("standard", fInputHandler->IsA() == AliAODInputHandler::Class());
90 }
91 
93 
94  PtBinning newbinning;
95  TString optionstring = fEnableSumw2 ? "s" : "";
96 
97  TLinearBinning etabinning(64, -0.8, 0.8), phibinning(100, 0., 2*TMath::Pi()), chargebinning(2, -1.5, 1.5);
98  const TBinning *binning4D[4] = {&newbinning, &etabinning, &phibinning, &chargebinning};
99 
100  // Binning for the PID histogram
101  const int kdimPID = 3;
102  const int knbinsPID[kdimPID] = {1000, 200, 300};
103  const double kminPID[kdimPID] = {-100., 0., 0.}, kmaxPID[kdimPID] = {100., 200., 1.5};
104  for(auto trg : GetSupportedTriggers()){
105  fHistos->CreateTH1("hEventCount" + trg, "Event Counter for trigger class " + trg, 1, 0.5, 1.5, optionstring);
106  fHistos->CreateTH1("hVertexBefore" + trg, "Vertex distribution before z-cut for trigger class " + trg, 500, -50, 50, optionstring);
107  fHistos->CreateTH1("hVertexAfter" + trg, "Vertex distribution after z-cut for trigger class " + trg, 100, -10, 10, optionstring);
108 
109  fHistos->CreateTHnSparse("hPtEtaPhiAll" + trg, "p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg + " ; p_{t} (GeV/c); #eta; #phi; charge", 4, binning4D, optionstring);
110  fHistos->CreateTHnSparse("hPtEtaPhiEMCALAll" + trg, "p_{t}-#eta-#phi distribution of all accepted tracks pointing to the EMCAL for trigger " + trg + "; p_{t} (GeV/c); #eta; #phi; charge", 4, binning4D, optionstring);
111  fHistos->CreateTHnSparse("hPtEtaPhiCent" + trg, "p_{t}-#eta-#phi distribution of all accepted tracks for trigger " + trg + "; p_{t} (GeV/c); #eta; #phi; charge", 4, binning4D, optionstring);
112  fHistos->CreateTHnSparse("hPtEtaPhiEMCALCent" + trg, "p_{t}-#eta-#phi distribution of all accepted tracks pointing to the EMCAL for trigger " + trg + "; p_{t} (GeV/c); #eta; #phi; charge", 4, binning4D, optionstring);
113 
114  if(fStudyPID){
115  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);
116  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);
117  fHistos->CreateTHnSparse(Form("hPIDcorrEMCAL%s", trg.Data()), Form("Correlation of PID observables for Trigger %s", trg.Data()), kdimPID, knbinsPID, kminPID, kmaxPID, optionstring);
118  }
119  }
120 }
121 
123  Bool_t hasPIDresponse = fInputHandler->GetPIDResponse() != nullptr;
124  if(fStudyPID && !hasPIDresponse) AliErrorStream() << "PID requested but PID response not available" << std::endl;
125 
126  // Loop over tracks, fill select particles
127  // Histograms
128  // - Full eta_{lab} (-0.8, 0.8), new binning
129  // - Full eta_{lab} (-0.8, 0.8), old binning
130  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c without eta cut
131  // - Central eta_{cms} (-0.3, -0.2), new binning,
132  // - Central eta_{cms} (-0.8, -0.2), old binning,
133  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c
134  // - Eta distribution for tracks above 1, 2, 5, 10 GeV/c with eta cut
135  AliVTrack *checktrack(nullptr);
136  int ptmin[5] = {1,2,5,10,20}; // for eta distributions
137  Bool_t isEMCAL(kFALSE);
138  Double_t etaEMCAL(0.), phiEMCAL(0.);
139  for(int itrk = 0; itrk < fInputEvent->GetNumberOfTracks(); ++itrk){
140  checktrack = dynamic_cast<AliVTrack *>(fInputEvent->GetTrack(itrk));
141  if(!checktrack) continue;
142  if(!fEtaLabCut.IsInRange(checktrack->Eta())) continue;
143  if(!fPhiCut.IsInRange(checktrack->Phi())) continue;
144  if(TMath::Abs(checktrack->Pt()) < fMinPt) continue;
145  if(checktrack->IsA() == AliESDtrack::Class()){
146  AliESDtrack copytrack(*(static_cast<AliESDtrack *>(checktrack)));
147  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
148  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
149  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
150  } else {
151  AliAODTrack copytrack(*(static_cast<AliAODTrack *>(checktrack)));
152  AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&copytrack);
153  etaEMCAL = copytrack.GetTrackEtaOnEMCal();
154  phiEMCAL = copytrack.GetTrackPhiOnEMCal();
155  }
156  Int_t supermoduleID = -1;
157  isEMCAL = fGeom->SuperModuleNumberFromEtaPhi(etaEMCAL, phiEMCAL, supermoduleID);
158  // Exclude supermodules 10 and 11 as they did not participate in the trigger
159  isEMCAL = isEMCAL && supermoduleID < 10;
160 
161  // Calculate eta in cms frame according
162  // EPJC74 (2014) 3054:
163  // eta_cms = - eta_lab - |yshift|
164  Double_t etacent = -1. * checktrack->Eta() - TMath::Abs(fYshift);
165  etacent *= fEtaSign;
166 
167  if(!fEtaCmsCut.IsInRange(etacent)) continue; // Apply eta-cent cut
168  if(!fTrackCuts->IsTrackAccepted(checktrack)) continue;
169 
170  // Charge separation
171  bool posCharge = checktrack->Charge() > 0;
172 
173  for(const auto &t : fSelectedTriggers){
174  FillTrackHistos(t, posCharge, checktrack->Pt(), checktrack->Eta() * fEtaSign, etacent, checktrack->Phi(), isEMCAL);
175  if(fStudyPID && hasPIDresponse)
176  if(isEMCAL) FillPIDHistos(t, *checktrack);
177  }
178  }
179  return true;
180 }
181 
183  // Apply vertex z cut
184  for(const auto &t : fSelectedTriggers){
185  Double_t weight = GetTriggerWeight(t);
186  fHistos->FillTH1(Form("hVertexBefore%s", t.Data()), fVertex[2], weight);
187  }
188 }
189 
191  for(const auto &t : fSelectedTriggers) {
192  Double_t weight = GetTriggerWeight(t);
193  // Fill Event counter and reference vertex distributions after event selection
194  fHistos->FillTH1(Form("hEventCount%s", t.Data()), 1, weight);
195  fHistos->FillTH1(Form("hVertexAfter%s", t.Data()), fVertex[2], weight);
196  }
197 }
198 
200  const TString &eventclass,
201  Bool_t posCharge,
202  Double_t pt,
203  Double_t etalab,
204  Double_t etacent,
205  Double_t phi,
206  Bool_t inEmcal
207  )
208 {
209  Double_t weight = GetTriggerWeight(eventclass);
210  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << eventclass << " in particle histograms." << std::endl;
211  double kinepointall[4] = {TMath::Abs(pt), etalab, phi, posCharge ? 1. : -1.}, kinepointcent[4] = {TMath::Abs(pt), etacent, phi, posCharge ? 1. : -1.};
212  fHistos->FillTHnSparse("hPtEtaPhiAll" + eventclass, kinepointall, weight);
213  fHistos->FillTHnSparse("hPtEtaPhiCent" + eventclass, kinepointcent, weight);
214  if(inEmcal){
215  fHistos->FillTHnSparse("hPtEtaPhiEMCALAll" + eventclass, kinepointall, weight);
216  fHistos->FillTHnSparse("hPtEtaPhiEMCALCent" + eventclass, kinepointall, weight);
217  }
218 }
219 
221  const TString &eventclass,
222  const AliVTrack &trk
223 ) {
224  Double_t weight = GetTriggerWeight(eventclass);
225  AliDebugStream(1) << GetName() << ": Using weight " << weight << " for trigger " << eventclass << " in PID histograms." << std::endl;
226  AliPIDResponse *pid = fInputHandler->GetPIDResponse();
227  if(TMath::Abs(trk.Eta()) > 0.5) return;
228  if(!((trk.GetStatus() & AliVTrack::kTOFout) && (trk.GetStatus() & AliVTrack::kTIME))) return;
229 
230  double poverz = TMath::Abs(trk.P())/static_cast<double>(trk.Charge());
231  fHistos->FillTH2("hTPCdEdxEMCAL" + eventclass, poverz, trk.GetTPCsignal(), weight);
232  // correct for units - TOF in ps, track length in cm
233  Double_t trtime = (trk.GetTOFsignal() - pid->GetTOFResponse().GetTimeZero()) * 1e-12;
234  Double_t v = trk.GetIntegratedLength()/(100. * trtime);
235  Double_t beta = v / TMath::C();
236  fHistos->FillTH2("hTOFBetaEMCAL" + eventclass, poverz, beta, weight);
237  double datapoint[3] = {poverz, trk.GetTPCsignal(), beta};
238  fHistos->FillTHnSparse("hPIDcorrEMCAL" + eventclass, datapoint, weight);
239 }
240 
243 }
244 
246  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
247 
248  TString taskname = "chargedParticleQA_" + suffix;
249 
251  mgr->AddTask(task);
252 
253  TString outfile(mgr->GetCommonFileName());
254  outfile += ":ChargedParticleQA_" + suffix;
255  TString containername = "TrackResults_" + suffix;
256 
257  task->ConnectInput(0, mgr->GetCommonInputContainer());
258  mgr->ConnectOutput(task, 1, mgr->CreateContainer(containername.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
259 
260  return task;
261 }
262 
264  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
265 
267  mgr->AddTask(task);
268 
269  // Set Energy thresholds for additional patch selection:
270  // These are events with offline patches of a given type where the trigger reached already the plateau
271  // These numers are determined as:
272  // EMC7: 5 GeV
273  // EG1: 14 GeV
274  // EG2: 8 GeV
275  // EJ1: 22 GeV
276  // EJ2: 12 GeV
277  mgr->AddTask(task);
280  );
283  cutname,
284  mgr->GetInputEventHandler()->IsA() == AliAODInputHandler::Class()
285  )
286  );
287 
288  TString outfile(mgr->GetCommonFileName());
289  outfile += ":ChargedParticleQA_%s" + cutname;
290 
291  task->ConnectInput(0, mgr->GetCommonInputContainer());
292  mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form("TrackResults_%s", cutname.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
293 
294  return task;
295 }
296 
299 {
300  this->SetMinimum(0.);
301  this->AddStep(1, 0.05);
302  this->AddStep(2, 0.1);
303  this->AddStep(4, 0.2);
304  this->AddStep(7, 0.5);
305  this->AddStep(16, 1);
306  this->AddStep(36, 2);
307  this->AddStep(40, 4);
308  this->AddStep(50, 5);
309  this->AddStep(100, 10);
310  this->AddStep(200, 20);
311 }
312 
313 } /* namespace EMCalTriggerPtAnalysis */
std::vector< TString > fSelectedTriggers
! Triggers selected for given event
virtual bool Run()
Simple task testing particle spectra in triggered events.
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 AliAnalysisTaskChargedParticlesRef * AddTaskChargedParticlesRef(const TString &suffix)
Pre-configure task so that it can be used in subwagons.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
virtual void SaveQAObjects(TList *outputList)
void AddStep(Double_t max, Double_t binwidth)
virtual void UserFillHistosBeforeEventSelection()
Implementation of framework function UserFillHistosBeforeEventSelection.
Interface for binnings used by the histogram handler.
Definition: TBinning.h:21
void SetOfflineTriggerSelection(AliEmcalTriggerOfflineSelection *sel)
Set an offline trigger selection.
void SetCaloTriggerPatchInfoName(const char *n)
static AliEmcalTrackSelection * TrackCutsFactory(TString name, Bool_t isAOD)
Fully-configure EMCAL track selection independent of the data type.
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
static AliAnalysisTaskChargedParticlesRef * AddTaskChargedParticlesRefDefault(const TString &cutname="standard")
Fully configure task, not intended for subwagons. Using a default cut configuration.
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
int Int_t
Definition: External.C:63
AliEMCALGeometry * fGeom
!emcal geometry
void FillTrackHistos(const TString &eventclass, Bool_t posCharge, Double_t pt, Double_t eta, Double_t etacent, Double_t phi, Bool_t inEmcal)
Fill track (kinematic) histograms.
void SetEMCALTrackSelection(AliEmcalTrackSelection *sel)
Set the virtual track selection.
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
Helper class creating user defined custom binning.
const Double_t ptmin
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
Declaration of class AliEMCalTriggerExtraCuts.
AliEmcalList * fOutput
!output list
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Double_t fVertex[3]
!event vertex
void FillPIDHistos(const TString &eventclass, const AliVTrack &track)
Fill PID-related histograms.
void SetNeedEmcalGeom(Bool_t n)
void InitializeTrackCuts(TString cutname, bool isAOD)
Set the track selection.
bool Bool_t
Definition: External.C:53
virtual void UserFillHistosAfterEventSelection()
Implementation of framework function UserFillHistosAfterEventSelection.
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
Create a new THnSparse within the container.
static AliEmcalTriggerOfflineSelection * TriggerSelectionFactory(Double_t el0, Double_t eg1, Double_t eg2, Double_t ej1, Double_t ej2, AliEmcalTriggerOfflineSelection::EmcalEnergyDefinition_t endef=AliEmcalTriggerOfflineSelection::kFEEEnergy)
Configures EMCAL trigger offline selection used to restrict EMCAL triggered sample.
virtual bool IsTrackAccepted(AliVTrack *const trk)=0
Interface for track selection code.
void SetMinimum(Double_t min)