AliPhysics  5eaf189 (5eaf189)
AliAnalysisTaskTrackDCA.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 <map>
16 #include <string>
17 #include <vector>
18 
19 #include <TArrayD.h>
20 #include <THashList.h>
21 #include <THistManager.h>
22 #include <TList.h>
23 #include <TMath.h>
24 
25 #include "AliAnalysisUtils.h"
26 #include "AliInputEventHandler.h"
27 #include "AliESDEvent.h"
28 #include "AliESDtrackCuts.h"
29 
31 
35 
36 namespace EMCalTriggerPtAnalysis {
37 
41 AliAnalysisTaskTrackDCA::AliAnalysisTaskTrackDCA():
43  fAnalysisUtils(NULL),
44  fStandardCuts(NULL),
45  fHistos(NULL)
46 {
47 }
48 
54  AliAnalysisTaskSE(name),
55  fAnalysisUtils(NULL),
56  fStandardCuts(NULL),
57  fHistos(NULL)
58 {
59  DefineOutput(1, TList::Class());
60 }
61 
66  if(fAnalysisUtils) delete fAnalysisUtils;
67  if(fStandardCuts) delete fStandardCuts;
68  if(fHistos) delete fHistos;
69 }
70 
77  fAnalysisUtils = new AliAnalysisUtils;
78 
79  std::string triggerclasses[] = {"MinBiasINT7", "MinBiasINT8", "EGAINT7", "EGAINT8", "EJEINT7", "EJEINT8"};
80  TArrayD ptbinning, dcarbinning, dcazbinning;
81  CreatePtBinning(ptbinning);
82  CreateLinearBinning(dcarbinning, 200, -0.1, 0.1);
83  CreateLinearBinning(dcazbinning, 500, -5, 5);
84  fHistos = new THistManager("trackDCA");
85  for(std::string *trgiter = triggerclasses; trgiter < triggerclasses + sizeof(triggerclasses)/sizeof(std::string); trgiter++){
86  fHistos->CreateTH1(Form("hEvents%s", trgiter->c_str()), Form("Event counter for trigger class %s", trgiter->c_str()), 1, 0.5, 1.5);
87  fHistos->CreateTH2(Form("hDCAr%s", trgiter->c_str()), Form("DCA distribution vs. p_{t} for trigger class %s", trgiter->c_str()), ptbinning, dcarbinning);
88  fHistos->CreateTH2(Form("hDCAz%s", trgiter->c_str()), Form("DCA distribution vs. p_{t} for trigger class %s", trgiter->c_str()), ptbinning, dcazbinning);
89  }
90 
91  PostData(1, fHistos->GetListOfHistograms());
92 
93 }
94 
104  AliESDEvent *esdev = dynamic_cast<AliESDEvent *>(fInputEvent);
105  if(!esdev) return;
106 
107  // Check triggers - split them up in INT7 (V0) and INT8 (T0)
108  std::vector<std::string> triggers;
109  if(fInputHandler->IsEventSelected() & AliVEvent::kINT7) triggers.push_back("MinBiasINT7");
110  if(fInputHandler->IsEventSelected() & AliVEvent::kINT8) triggers.push_back("MinBiasINT8");
111  TString triggerstring = esdev->GetFiredTriggerClasses();
112  if(triggerstring.Contains("EGA")){
113  if(triggerstring.Contains("CEMC7")) triggers.push_back("EGAINT7");
114  else if(triggerstring.Contains("CEMC8")) triggers.push_back("EGAINT8");
115  } else if(triggerstring.Contains("EJE")){
116  if(triggerstring.Contains("CEMC7")) triggers.push_back("EJEINT7");
117  else if(triggerstring.Contains("CEMC8")) triggers.push_back("EJEINT8");
118  }
119  if(!triggers.size()) return;
120 
121  // Apply event selection via AliAnalysisUtils
122  if(!fAnalysisUtils->IsVertexSelected2013pA(fInputEvent)) return;
123  const AliESDVertex *primVertex = esdev->GetPrimaryVertex();
124  if(TMath::Abs(primVertex->GetZ()) > 10.) return;
125 
126  for(std::vector<std::string>::iterator trgiter = triggers.begin(); trgiter != triggers.end(); ++trgiter)
127  fHistos->FillTH1(Form("hEvents%s", trgiter->c_str()), 1.);
128  /*
129  * In case AliRoot will at some point support c++-11 (in the far future)
130  * for(auto trgit : triggers) fHistos->FillTH1(Form("hEvents%s", trgit.c_str()), 1.);
131  */
132 
133  // Loop over tracks, apply track selection, fill histograms
134  const AliESDtrack *track(NULL);
135  for(Int_t ipart = 0; ipart < esdev->GetNumberOfTracks(); ipart++){
136  track = esdev->GetTrack(ipart);
137  AliESDtrack copytrack(*track);
138  if(!fStandardCuts->IsSelected(&copytrack)) continue;
139  Float_t dcaR, dcaZ;
140  Double_t pt = TMath::Abs(copytrack.Pt());
141  copytrack.GetImpactParameters(dcaR, dcaZ);
142  for(std::vector<std::string>::iterator trgit = triggers.begin(); trgit != triggers.end(); ++trgit){
143  fHistos->FillTH1(Form("hDCAr%s", trgit->c_str()), pt, dcaR);
144  fHistos->FillTH1(Form("hDCAz%s", trgit->c_str()), pt, dcaZ);
145  }
146  /*
147  * In case AliRoot will at some point support c++-11 (in the far future)
148  *
149  * for(auto trgit : triggers){
150  * fHistos->FillTH1(Form("hDCAr%s", trgit.c_str()), dcaR);
151  * fHistos->FillTH1(Form("hDCAz%s", trgit.c_str()), dcaZ);
152  * }
153  */
154  }
155 
156  PostData(1, fHistos->GetListOfHistograms());
157 }
158 
176  std::vector<double> mybinning;
177  std::map<double,double> definitions;
178  definitions.insert(std::pair<double, double>(1, 0.05));
179  definitions.insert(std::pair<double, double>(2, 0.1));
180  definitions.insert(std::pair<double, double>(4, 0.2));
181  definitions.insert(std::pair<double, double>(7, 0.5));
182  definitions.insert(std::pair<double, double>(16, 1));
183  definitions.insert(std::pair<double, double>(36, 2));
184  definitions.insert(std::pair<double, double>(40, 4));
185  definitions.insert(std::pair<double, double>(50, 5));
186  definitions.insert(std::pair<double, double>(100, 10));
187  definitions.insert(std::pair<double, double>(200, 20));
188  double currentval = 0.;
189  mybinning.push_back(currentval);
190  for(std::map<double,double>::iterator id = definitions.begin(); id != definitions.end(); ++id){
191  double limit = id->first, binwidth = id->second;
192  while(currentval < limit){
193  currentval += binwidth;
194  mybinning.push_back(currentval);
195  }
196  }
197  binning.Set(mybinning.size());
198  int ib = 0;
199  for(std::vector<double>::iterator it = mybinning.begin(); it != mybinning.end(); ++it)
200  binning[ib++] = *it;
201 }
202 
211 void AliAnalysisTaskTrackDCA::CreateLinearBinning(TArrayD& binning, int nbins, double min, double max) const {
212  double binwidth = (max-min)/static_cast<double>(nbins);
213  binning.Set(nbins+1);
214  binning[0] = min;
215  double currentlimit = min + binwidth;
216  for(int ibin = 0; ibin < nbins; ibin++){
217  binning[ibin+1] = currentlimit;
218  currentlimit += binwidth;
219  }
220 }
221 
222 } /* namespace EMCalTriggerPtAnalysis */
double Double_t
Definition: External.C:58
Simple analysis task monitoring the track DCA distribution.
void CreateLinearBinning(TArrayD &binning, int nbins, double min, double max) const
AliESDtrackCuts * fStandardCuts
Standard track cuts.
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
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
float Float_t
Definition: External.C:68
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
Analysis of high- tracks in triggered events.
Container class for histograms.
Definition: THistManager.h:99
const char Option_t
Definition: External.C:48
const Int_t nbins
AliAnalysisUtils * fAnalysisUtils
Analysis utils (helper)