AliPhysics  9fe175b (9fe175b)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskTrackDensityData.cxx
Go to the documentation of this file.
1 /*
2  * AliAnalysisTaskTrackDensityData.cxx
3  *
4  * Created on: Mar 11, 2016
5  * Author: markus
6  */
7 #include <THistManager.h>
8 #include <TMath.h>
9 
10 #include "AliEmcalJet.h"
11 #include "AliJetContainer.h"
12 #include "AliTrackContainer.h"
15 
17 
18 namespace EMCalTriggerPtAnalysis {
19 
22  fHistos(NULL),
23  fTrackSelection(NULL),
24  fBinHandler(NULL),
25  fNameJetContainer(""),
26  fNameTrackContainer("")
27 {
28 }
29 
31  AliAnalysisTaskEmcalJet(name, true),
32  fHistos(NULL),
33  fTrackSelection(NULL),
34  fBinHandler(new AliEMCalTriggerBinningComponent),
35  fNameJetContainer(""),
36  fNameTrackContainer("")
37 {
39  double defaultJetRadii[] = {0, 0.01, 0.02, 0.05, 0.1, 0.2, 0.4},
40  defaultPtMinSteps[] = {0.5, 1, 2, 5, 10, 20},
41  defaultJetPtBins[] = {20, 40, 60, 80, 100, 150, 200, 1000};
42 
43  fBinHandler->SetLinearBinning("jetpt", 100, 0, 100.);
44  fBinHandler->SetLinearBinning("contributors", 101, -0.5, 100.5);
45  fBinHandler->SetBinning("jetradii", sizeof(defaultJetRadii)/sizeof(double) - 1, defaultJetRadii);
46  fBinHandler->SetBinning("ptmin", sizeof(defaultPtMinSteps)/sizeof(double) - 1, defaultPtMinSteps);
47  fBinHandler->SetBinning("jetlarge", sizeof(defaultJetPtBins)/sizeof(double) - 1, defaultJetPtBins);
48 }
49 
50 
52  if(fHistos) delete fHistos;
53  if(fBinHandler) delete fBinHandler;
54 }
55 
58  fHistos = new THistManager("histos");
60 
62  bininit.Create(fBinHandler);
63 
64  const TArrayD &trackptbinning = fBinHandler->GetBinning("pt")->GetBinning(),
65  &jetptbinning = fBinHandler->GetBinning("jetpt")->GetBinning(),
66  &contributorbinning = fBinHandler->GetBinning("contributors")->GetBinning(),
67  &jetradii = fBinHandler->GetBinning("jetradii")->GetBinning(),
68  &ptminsteps = fBinHandler->GetBinning("ptmin")->GetBinning(),
69  &jetptlarge = fBinHandler->GetBinning("jetlarge")->GetBinning();
70 
71  fHistos->CreateTH1("hTrackPtSel", "Pt spectrum of selected tracks", trackptbinning);
72  fHistos->CreateTH1("hTrackPtSelEvent", "Pt spectrum of selected tracks (directly from the input event)", trackptbinning);
73  fHistos->CreateTH2("hJetMultiplicity", "Multiplicity of particles in jets", jetptbinning, contributorbinning);
74  fHistos->CreateTH2("hParticlePtJet", "Correlation between track pt and jet pt", jetptbinning, trackptbinning);
75 
76  for(int irad = 0; irad < jetradii.GetSize()-1; irad++){
77  for(int ptstep = 0; ptstep <ptminsteps.GetSize(); ptstep++){
78  fHistos->CreateTH2(Form("trackDensityJet_r%d_%d_minpt%d",
79  static_cast<int>(jetradii[irad] * 100.),
80  static_cast<int>(jetradii[irad+1] * 100.),
81  static_cast<int>(ptminsteps[ptstep] * 10.)),
82  Form("Density of tracks with p_{t} > %f GeV/c in r [%.2f, %.2f]; p_{t, jet} (GeV/c); Number of tracks",
83  ptminsteps[ptstep],
84  jetradii[irad],
85  jetradii[irad+1]),
86  200, 0., 200.,
87  102, -0.5, 100.5);
88  }
89  for(int jetptbin = 0 ; jetptbin < jetptlarge.GetSize()-1; jetptbin++){
90  fHistos->CreateTH2(Form("trackDensityParticle_r%d_%d_jetpt%d_%d",
91  static_cast<int>(jetradii[irad] * 100.),
92  static_cast<int>(jetradii[irad+1] * 100.),
93  static_cast<int>(jetptlarge[jetptbin]),
94  static_cast<int>(jetptlarge[jetptbin+1])),
95  Form("Density of tracks in jet with p_{t} [%.1f, %.1f] in r[%.2f,%2f]",
96  jetptlarge[jetptbin],
97  jetptlarge[jetptbin+1],
98  jetradii[irad],
99  jetradii[irad+1]),
100  trackptbinning, contributorbinning);
101  }
102  }
103 
104  for(THistManager::iterator it = fHistos->begin(); it != fHistos->end(); it++){
105  fOutput->Add(*it);
106  }
107 
108  /*
109  for(auto it : *fHistos){
110  fOutput->Add(it);
111  }
112  */
113 }
114 
116  // Loop over jets
119  AliEmcalJet *myjet = NULL;
120  AliVParticle *jetparticle = NULL;
121  const TArrayD &particlePtBinning = this->fBinHandler->GetBinning("pt")->GetBinning(),
122  &jetradii = this->fBinHandler->GetBinning("jetradii")->GetBinning(),
123  &ptminsteps = fBinHandler->GetBinning("ptmin")->GetBinning();
124  for(int ipart = 0; ipart < InputEvent()->GetNumberOfTracks(); ipart++){
125  jetparticle = InputEvent()->GetTrack(ipart);
126  if(TMath::Abs(jetparticle->Eta()) > 0.8) continue;
127  if(!fTrackSelection->IsTrackAccepted(static_cast<AliVTrack *>(jetparticle))) continue;
128  fHistos->FillTH1("hTrackPtSelEvent", TMath::Abs(jetparticle->Pt()));
129  }
130  const AliTrackIterableContainer accepted_tracks = tcont->accepted();
131  for(AliTrackIterableContainer::iterator trackiter = accepted_tracks.begin(); trackiter != accepted_tracks.end(); ++trackiter){
132  jetparticle = *trackiter;
133  if(TMath::Abs(jetparticle->Eta()) > 0.8) continue;
134  if(!fTrackSelection->IsTrackAccepted(static_cast<AliVTrack *>(jetparticle))) continue;
135  fHistos->FillTH1("hTrackPtSel", TMath::Abs(jetparticle->Pt()));
136  }
137  const AliJetIterableContainer accepted_jets = jcont->accepted();
138  for(AliJetIterableContainer::iterator jetiter = accepted_jets.begin(); jetiter != accepted_jets.end(); ++jetiter){
139  myjet = *jetiter;
140  fHistos->FillTH2("hJetMultiplicity", myjet->Pt(), myjet->GetNumberOfConstituents());
141 
142  for(int iconst = 0; iconst < myjet->GetNumberOfTracks(); iconst++){
143  jetparticle = myjet->TrackAt(iconst, tcont->GetArray());
144  if(TMath::Abs(jetparticle->Eta()) > 0.8) continue;
145  if(!fTrackSelection->IsTrackAccepted(static_cast<AliVTrack *>(jetparticle))) continue;
146  fHistos->FillTH2("hParticlePtJet", myjet->Pt(), jetparticle->Pt());
147  }
148 
149  for(int irad = 0 ; irad < jetradii.GetSize()-1; irad++){
150  for(int ptstep = 0; ptstep < ptminsteps.GetSize(); ptstep++){
151  fHistos->FillTH2(Form("trackDensityJet_r%d_%d_minpt%d", static_cast<int>(jetradii[irad] * 100.), static_cast<int>(jetradii[irad+1] * 100.), static_cast<int>(ptminsteps[ptstep] * 10.)),
152  TMath::Abs(myjet->Pt()), GetParticleMultiplicity(*myjet, *tcont, ptminsteps[ptstep], 10000., jetradii[irad], jetradii[irad+1]));
153  }
154  double jetptmin, jetptmax;
155  FindJetPtBin(myjet, jetptmin, jetptmax);
156  if(jetptmin > 0 && jetptmax > 0){
157  for(int ptstep = 0; ptstep < particlePtBinning.GetSize()-1; ptstep++){
158  double mean = (particlePtBinning[ptstep] + particlePtBinning[ptstep+1])/2.;
159  fHistos->FillTH2(Form("trackDensityParticle_r%d_%d_jetpt%d_%d", static_cast<int>(jetradii[irad] * 100.),static_cast<int>(jetradii[irad+1] * 100.),
160  static_cast<int>(jetptmin), static_cast<int>(jetptmax)), mean, GetParticleMultiplicity(*myjet, *tcont, particlePtBinning[ptstep], particlePtBinning[+1], jetradii[irad], jetradii[irad+1]));
161  }
162  }
163  }
164 
165  }
166  return true;
167 }
168 
169 int AliAnalysisTaskTrackDensityData::GetParticleMultiplicity(const AliEmcalJet &jet, const AliParticleContainer &partcont, double ptmin, double ptmax, double rmin, double rmax) const {
170  AliDebug(1, Form("Next jet: %s\n", jet.toString().Data()));
171  TLorentzVector jetaxis(jet.Px(), jet.Py(), jet.Pz(), jet.E());
172  int nselected = 0;
173  AliVParticle *jetparticle(NULL);
174  for(int ipart = 0; ipart < jet.GetNumberOfTracks(); ipart++){
175  jetparticle = static_cast<AliVParticle *>(jet.TrackAt(ipart, partcont.GetArray()));
176  if(TMath::Abs(jetparticle->Eta()) > 0.8) continue;
177  if(!fTrackSelection->IsTrackAccepted(static_cast<AliVTrack *>(jetparticle))) continue;
178  double partpt = TMath::Abs(jetparticle->Pt());
179  if(partpt >= ptmin && partpt < ptmax){
180  TLorentzVector partvector(jetparticle->Px(), jetparticle->Py(), jetparticle->Pz(), jetparticle->E());
181  double r = TMath::Abs(jetaxis.DeltaR(partvector));
182  if(r >= rmin && r < rmax) nselected++;
183  }
184  }
185  return nselected;
186 }
187 
188 void AliAnalysisTaskTrackDensityData::FindJetPtBin(const AliEmcalJet *const jet, double &ptmin, double &ptmax) const {
189  const TArrayD &jetptlarge = fBinHandler->GetBinning("jetlarge")->GetBinning();
190  ptmin = ptmax = -1;
191  double jetpt = TMath::Abs(jet->Pt());
192  for(int ptstep = 0; ptstep < jetptlarge.GetSize() - 1; ptstep++){
193  if(jetpt >= jetptlarge[ptstep] && jetpt < jetptlarge[ptstep+1]){
194  ptmin = jetptlarge[ptstep];
195  ptmax = jetptlarge[ptstep+1];
196  break;
197  }
198  }
199 }
200 
201 
202 } /* namespace EMCalTriggerPtAnalysis */
AliJetContainer * GetJetContainer(Int_t i=0) const
bidirectional stl iterator over the EMCAL iterable container
Double_t Py() const
Definition: AliEmcalJet.h:91
Container with name, TClonesArray and cuts for particles.
int GetParticleMultiplicity(const AliEmcalJet &jet, const AliParticleContainer &partcont, double ptmin, double ptmax, double rmin, double rmax) const
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
void Create(AliEMCalTriggerBinningComponent *const data)
Double_t E() const
Definition: AliEmcalJet.h:103
Container for particles within the EMCAL framework.
UShort_t GetNumberOfTracks() const
Definition: AliEmcalJet.h:123
Double_t Px() const
Definition: AliEmcalJet.h:90
Global binning handler used by several analysis components.
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
const Double_t ptmax
TString toString() const
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
void ReleaseOwner()
Definition: THistManager.h:180
const Double_t ptmin
void SetBinning(const char *dimname, int nbins, const double *binning)
AliEMCalTriggerBinningDimension * GetBinning(const char *name) const
stl-iterator for the histogram manager
Definition: THistManager.h:59
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Global binning definition for the high- charged particle analysis.
Double_t Pt() const
Definition: AliEmcalJet.h:93
iterator begin() const
Definition: THistManager.h:564
AliEmcalList * fOutput
!output list
Short_t TrackAt(Int_t idx) const
Definition: AliEmcalJet.h:144
AliEMCalTriggerBinningComponent * fBinHandler
EMCAL track selection.
AliTrackContainer * GetTrackContainer(Int_t i=0) const
iterator end() const
Definition: THistManager.h:572
void SetMakeGeneralHistograms(Bool_t g)
Base task in the EMCAL jet framework.
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:44
Container class for histograms for the high- charged particle analysis.
Definition: THistManager.h:43
Double_t Pz() const
Definition: AliEmcalJet.h:92
const AliJetIterableContainer accepted() const
Container for jet within the EMCAL jet framework.
virtual bool IsTrackAccepted(AliVTrack *const trk)=0
void SetLinearBinning(const char *dirname, int nbins, double min, double max)
void FindJetPtBin(const AliEmcalJet *const jet, double &ptmin, double &ptmax) const