AliPhysics  v5-06-11-01 (156c7f3)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliEMCalTriggerRecTrackAnalysisComponent.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2014, 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 <TAxis.h>
20 #include <TClonesArray.h>
21 #include <TMath.h>
22 #include <TString.h>
23 
24 #include "AliAODMCParticle.h"
25 #include "AliLog.h"
26 #include "AliMCEvent.h"
27 #include "AliPicoTrack.h"
28 #include "AliVCluster.h"
29 #include "AliVEvent.h"
30 #include "AliVParticle.h"
31 #include "AliVTrack.h"
32 
40 
44 
45 namespace EMCalTriggerPtAnalysis {
46 
52 AliEMCalTriggerRecTrackAnalysisComponent::AliEMCalTriggerRecTrackAnalysisComponent() :
54  fTrackSelection(NULL),
55  fSwapEta(kFALSE),
56  fTriggerMethod(kTriggerString),
57  fRequestMCtrue(kFALSE)
58 {
59 }
60 
69  fTrackSelection(NULL),
70  fSwapEta(kFALSE),
71  fTriggerMethod(kTriggerString),
72  fRequestMCtrue(kFALSE)
73 {
74 }
75 
83 }
84 
102 
103  // Create trigger definitions
104  std::map<std::string, std::string> triggerCombinations;
105  const char *triggernames[11] = {"MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh",
106  "EMCGLow", "EMCHighBoth", "EMCHighGammaOnly", "EMCHighJetOnly",
107  "EMCLowBoth", "EMCLowGammaOnly", "EMCLowJetOnly"};
108  // Define names and titles for different triggers in the histogram container
109  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[0], "min. bias events"));
110  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[1], "jet-triggered events (high threshold)"));
111  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[2], "jet-triggered events (low threshold)"));
112  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[3], "gamma-triggered events (high threshold)"));
113  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[4], "gamma-triggered events (low threshold)"));
114  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[5], "jet and gamma triggered events (high threshold)"));
115  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[6], "exclusively gamma-triggered events (high threshold)"));
116  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[7], "exclusively jet-triggered events (high threshold)"));
117  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[8], "jet and gamma triggered events (low threshold)"));
118  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[9], "exclusively gamma-triggered events (low threshold)"));
119  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[10], "exclusively-triggered events (low threshold)"));
120 
121  // Create axis definitions
122  const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
123  *etabinning = fBinning->GetBinning("eta"),
124  *phibinning = fBinning->GetBinning("phi"),
125  *vertexbinning = fBinning->GetBinning("zvertex");
126 
127  const TAxis *trackaxes[5] = {
128  DefineAxis("pt", ptbinning),
129  DefineAxis("eta", etabinning),
130  DefineAxis("phi", phibinning),
131  DefineAxis("zvertex", vertexbinning),
132  DefineAxis("mbtrigger", 2, -0.5, 1.5)
133  };
134 
135  // Build histograms
136  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
137  const std::string name = it->first, &title = it->second;
138  fHistos->CreateTHnSparse(Form("hTrackHist%s", name.c_str()), Form("Track-based data for %s events", title.c_str()), 5, trackaxes, "s");
139  fHistos->CreateTHnSparse(Form("hTrackInAcceptanceHist%s", name.c_str()), Form("Track-based data for %s events for tracks matched to EMCal clusters", title.c_str()), 5, trackaxes, "s");
140  fHistos->CreateTHnSparse(Form("hMCTrackHist%s", name.c_str()), Form("Track-based data for %s events with MC kinematics", title.c_str()), 5, trackaxes, "s");
141  fHistos->CreateTHnSparse(Form("hMCTrackInAcceptanceHist%s", name.c_str()), Form("Track-based data for %s events with MC kinematics for tracks matched to EMCal clusters", title.c_str()), 5, trackaxes, "s");
142  }
143 
144  // Correlation Matrix
145  // 1. gen pt
146  // 2. rec pt
147  // 3. rec eta
148  // 4. rec phi
149  const TAxis *corraxes[4] = {
150  DefineAxis("ptgen", ptbinning),
151  DefineAxis("ptrec", ptbinning),
152  DefineAxis("eta", etabinning),
153  DefineAxis("phi", phibinning)
154  };
155  fHistos->CreateTHnSparse("hTrackPtCorrelation", "Correlation matrix for track pt", 4, corraxes);
156 
157  for(int iaxis = 0; iaxis < 5; iaxis++) delete trackaxes[iaxis];
158 }
159 
178  AliDebug(1, Form("Number of matched tracks: %d", data->GetMatchedTrackContainer()->GetEntries()));
179  if(fRequestMCtrue && !data->GetMCEvent()) return;
180 
181  std::vector<std::string> triggernames;
182  this->GetMachingTriggerNames(triggernames, fTriggerMethod);
183 
184  AliVTrack *track(NULL);
185  const AliVParticle *assocMC(NULL);
186  if(!data->GetMatchedTrackContainer()){
187  AliError("No container for matched tracks");
188  return;
189  }
190  TIter trackIter(data->GetMatchedTrackContainer());
191 
192  double weight = 1.;
193  if(fWeightHandler && data->GetMCEvent()){
194  weight = fWeightHandler->GetEventWeight(data->GetMCEvent());
195  }
196  while((track = dynamic_cast<AliVTrack *>(trackIter()))){
197  // Apply track selection
198  assocMC = NULL;
199  if(fKineCuts && !fKineCuts->IsSelected(track)) continue;
201  AliDebug(2, "Track not accepted");
202  continue;
203  }
204 
205  if(fRequestMCtrue){
206  if(!(assocMC = IsMCTrueTrack(track, data->GetMCEvent()))) continue; // Not a true track
207  this->FillCorrelation(assocMC, track);
208  }
209  // Try to match the cluster
210  Bool_t hasCluster = kFALSE;
211  AliVCluster *clust(NULL);
212  AliVTrack *testtrack = track;
213  AliPicoTrack *pictrack = dynamic_cast<AliPicoTrack *>(track);
214  if(pictrack) testtrack = pictrack->GetTrack();
215  if(testtrack->GetEMCALcluster() >= 0 && (clust = dynamic_cast<AliVCluster *>(data->GetClusterContainer()->At(testtrack->GetEMCALcluster()))))
216  hasCluster = kTRUE;
217 
218  // Fill histograms
219  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); name++){
220  FillHistogram(Form("hTrackHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE, weight);
221  if(hasCluster) FillHistogram(Form("hTrackInAcceptanceHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE, weight);
222  if(assocMC){
223  FillHistogram(Form("hMCTrackHist%s", name->c_str()), track, assocMC, data->GetRecEvent(), kTRUE, weight);
224  if(hasCluster) FillHistogram(Form("hMCTrackInAcceptanceHist%s", name->c_str()), track, assocMC, data->GetRecEvent(), kTRUE, weight);
225  }
226  }
227  }
228 }
229 
241  const AliVTrack* const trk, const AliMCEvent* evnt) const {
242  int label = TMath::Abs(trk->GetLabel());
243  const AliVParticle *mcpart = evnt->GetTrack(label);
244  if(!mcpart) return NULL;
245  const AliAODMCParticle *aodpart = dynamic_cast<const AliAODMCParticle *>(mcpart);
246  if(aodpart){
247  if(!aodpart->IsPhysicalPrimary()) return NULL;
248  } else {
249  if(!evnt->IsPhysicalPrimary(label)) return NULL;
250  }
251  return mcpart;
252 }
253 
274  const TString& histname, const AliVTrack* const trk,
275  const AliVParticle* assocMC, const AliVEvent* const recev,
276  Bool_t useMCkine, Double_t weight) {
277  if(useMCkine && !assocMC) return;
278  double data[5];
279  data[0] = useMCkine ? TMath::Abs(assocMC->Pt()) : TMath::Abs(trk->Pt());
280  data[1] = (fSwapEta ? -1. : 1.) * (useMCkine ? assocMC->Eta() : trk->Eta());
281  data[2] = useMCkine ? assocMC->Phi() : trk->Phi();
282  data[3] = recev->GetPrimaryVertex()->GetZ();
283  data[4] = fTriggerDecision->IsMinBias();
284  fHistos->FillTHnSparse(histname.Data(), data, weight);
285 }
286 
299  const AliVParticle* const genparticle,
300  const AliVParticle* const recparticle, double weight) {
301  double data[4] = {TMath::Abs(genparticle->Pt()), TMath::Abs(recparticle->Pt()), recparticle->Eta(), recparticle->Phi()};
302  fHistos->FillTHnSparse("hTrackPtCorrelation", data, weight);
303 }
304 
305 } /* namespace EMCalTriggerPtAnalysis */
bool IsSelected(const AliVParticle *const track) const
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Weight handler for the analysis of high- tracks in EMCAL-triggered events.
Declaration of class AliEMCalTriggerAnaTriggerDecision, a container for trigger decision in EMCAL-tri...
void FillHistogram(const TString &histname, const AliVTrack *const trk, const AliVParticle *assocMC, const AliVEvent *const recev, Bool_t useMCkine, Double_t weight)
Fill main track-based histogram.
const AliEMCalTriggerWeightHandler * fWeightHandler
Event weight handler.
void GetMachingTriggerNames(std::vector< std::string > &triggernames, ETriggerMethod_t usePatches)
TAxis * DefineAxis(const char *name, const AliEMCalTriggerBinningDimension *binning)
void FillTHnSparse(const char *name, const double *x, double weight=1.)
Analysis component for reconstructed tracks.
void CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
const AliVParticle * IsMCTrueTrack(const AliVTrack *const trk, const AliMCEvent *evnt) const
Check whether track is a true signal track.
AliEMCalHistoContainer * fHistos
Histogram container of the analysis component.
const AliEMCalTriggerAnaTriggerDecision * fTriggerDecision
Trigger decision handler.
AliEMCalPtTaskVTrackSelection * fTrackSelection
Track selection cuts used in the analysis.
virtual void CreateHistos()
Creating histograms for the analysis component.
const AliEMCalTriggerKineCuts * fKineCuts
Kinematical cuts for tracks and particle selection.
Base class for analysis components in the analysis of EMCAL-triggered events.
double GetEventWeight(const AliMCEvent *const event) const
virtual bool IsTrackAccepted(AliVTrack *const trk)=0
AliEMCalTriggerBinningDimension * GetBinning(const char *name) const
void FillCorrelation(const AliVParticle *const genparticle, const AliVParticle *const recparticle, double weight=1.)
virtual void Process(const AliEMCalTriggerEventData *const data)
Run track loop on list of matching tracks.
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.