AliPhysics  v5-06-21-01 (1eac791)
 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 <TList.h>
22 #include <TMath.h>
23 #include <TString.h>
24 
25 #include "AliAODMCParticle.h"
26 #include "AliLog.h"
27 #include "AliEmcalTriggerPatchInfo.h"
28 #include "AliMCEvent.h"
29 #include "AliPicoTrack.h"
30 #include "AliVCluster.h"
31 #include "AliVEvent.h"
32 #include "AliVParticle.h"
33 #include "AliVTrack.h"
34 
42 
46 
47 namespace EMCalTriggerPtAnalysis {
48 
54 AliEMCalTriggerRecTrackAnalysisComponent::AliEMCalTriggerRecTrackAnalysisComponent() :
56  fTrackSelection(NULL),
57  fSwapEta(kFALSE),
58  fTriggerMethod(kTriggerString),
59  fRequestMCtrue(kFALSE),
60  fDoMatchPatches(kFALSE)
61 {
62 }
63 
72  fTrackSelection(NULL),
73  fSwapEta(kFALSE),
74  fTriggerMethod(kTriggerString),
75  fRequestMCtrue(kFALSE),
76  fDoMatchPatches(kFALSE)
77 {
78 }
79 
87 }
88 
106 
107  // Create trigger definitions
108  std::map<std::string, std::string> triggerCombinations;
109  const char *triggernames[11] = {"MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh",
110  "EMCGLow", "EMCHighBoth", "EMCHighGammaOnly", "EMCHighJetOnly",
111  "EMCLowBoth", "EMCLowGammaOnly", "EMCLowJetOnly"};
112  // Define names and titles for different triggers in the histogram container
113  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[0], "min. bias events"));
114  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[1], "jet-triggered events (high threshold)"));
115  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[2], "jet-triggered events (low threshold)"));
116  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[3], "gamma-triggered events (high threshold)"));
117  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[4], "gamma-triggered events (low threshold)"));
118  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[5], "jet and gamma triggered events (high threshold)"));
119  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[6], "exclusively gamma-triggered events (high threshold)"));
120  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[7], "exclusively jet-triggered events (high threshold)"));
121  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[8], "jet and gamma triggered events (low threshold)"));
122  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[9], "exclusively gamma-triggered events (low threshold)"));
123  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[10], "exclusively-triggered events (low threshold)"));
124 
125  // Create axis definitions
126  const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
127  *etabinning = fBinning->GetBinning("eta"),
128  *phibinning = fBinning->GetBinning("phi"),
129  *vertexbinning = fBinning->GetBinning("zvertex");
130 
131  const TAxis *trackaxes[5] = {
132  DefineAxis("pt", ptbinning),
133  DefineAxis("eta", etabinning),
134  DefineAxis("phi", phibinning),
135  DefineAxis("zvertex", vertexbinning),
136  DefineAxis("mbtrigger", 2, -0.5, 1.5)
137  };
138 
139  // Build histograms
140  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
141  const std::string name = it->first, &title = it->second;
142  fHistos->CreateTHnSparse(Form("hTrackHist%s", name.c_str()), Form("Track-based data for %s events", title.c_str()), 5, trackaxes, "s");
143  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");
144  fHistos->CreateTHnSparse(Form("hMCTrackHist%s", name.c_str()), Form("Track-based data for %s events with MC kinematics", title.c_str()), 5, trackaxes, "s");
145  fHistos->CreateTHnSparse(Form("hMCTrackInAcceptanceHist%s", name.c_str()), Form("Track-based data for %s events for tracks matched to EMCal clusters with MC kinematics", title.c_str()), 5, trackaxes, "s");
146  if(fDoMatchPatches){
147  fHistos->CreateTHnSparse(Form("hTrackHistPatchMatch%s", name.c_str()), Form("Track-based data for %s events for tracks matched to EMCal patches", title.c_str()), 5, trackaxes, "s");
148  fHistos->CreateTHnSparse(Form("hMCTrackHistPatchMatch%s", name.c_str()), Form("Track-based data for %s events for tracks matched to EMCal patches with MC kinematics", title.c_str()), 5, trackaxes, "s");
149  }
150  }
151 
152  // Correlation Matrix
153  // 1. gen pt
154  // 2. rec pt
155  // 3. rec eta
156  // 4. rec phi
157  const TAxis *corraxes[4] = {
158  DefineAxis("ptgen", ptbinning),
159  DefineAxis("ptrec", ptbinning),
160  DefineAxis("eta", etabinning),
161  DefineAxis("phi", phibinning)
162  };
163  fHistos->CreateTHnSparse("hTrackPtCorrelation", "Correlation matrix for track pt", 4, corraxes);
164 
165  for(int iaxis = 0; iaxis < 5; iaxis++) delete trackaxes[iaxis];
166 }
167 
187  AliDebug(1, Form("Number of matched tracks: %d", data->GetMatchedTrackContainer()->GetEntries()));
188  if(fRequestMCtrue && !data->GetMCEvent()) return;
189 
190  std::vector<std::string> triggernames;
191  this->GetMachingTriggerNames(triggernames, fTriggerMethod);
192 
193  AliVTrack *track(NULL);
194  const AliVParticle *assocMC(NULL);
195  if(!data->GetMatchedTrackContainer()){
196  AliError("No container for matched tracks");
197  return;
198  }
199  TIter trackIter(data->GetMatchedTrackContainer());
200 
201  double weight = 1.;
202  if(fWeightHandler && data->GetMCEvent()){
203  weight = fWeightHandler->GetEventWeight(data->GetMCEvent());
204  }
205  while((track = dynamic_cast<AliVTrack *>(trackIter()))){
206  // Apply track selection
207  assocMC = NULL;
208  if(fKineCuts && !fKineCuts->IsSelected(track)) continue;
210  AliDebug(2, "Track not accepted");
211  continue;
212  }
213 
214  if(fRequestMCtrue){
215  if(!(assocMC = IsMCTrueTrack(track, data->GetMCEvent()))) continue; // Not a true track
216  this->FillCorrelation(assocMC, track);
217  }
218  // Try to match the cluster
219  Bool_t hasCluster = kFALSE;
220  AliVCluster *clust(NULL);
221  AliVTrack *testtrack = track;
222  AliPicoTrack *pictrack = dynamic_cast<AliPicoTrack *>(track);
223  if(pictrack) testtrack = pictrack->GetTrack();
224  if(testtrack->GetEMCALcluster() >= 0 && (clust = dynamic_cast<AliVCluster *>(data->GetClusterContainer()->At(testtrack->GetEMCALcluster()))))
225  hasCluster = kTRUE;
226 
227  // Try to match to EMCAL patches (only in case the event is triggered)
228  TList patches;
229  if(fDoMatchPatches && triggernames.size()) MatchTriggerPatches(track, data->GetTriggerPatchContainer(), patches);
230 
231  // Fill histograms
232  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); name++){
233  FillHistogram(Form("hTrackHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE, weight);
234  if(hasCluster) FillHistogram(Form("hTrackInAcceptanceHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE, weight);
235  Bool_t hasPatch = HasMatchedPatchOfType(*name, patches);
236  if(fDoMatchPatches && hasPatch) FillHistogram(Form("hTrackHistPatchMatch%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE, weight);
237  if(assocMC){
238  FillHistogram(Form("hMCTrackHist%s", name->c_str()), track, assocMC, data->GetRecEvent(), kTRUE, weight);
239  if(hasCluster) FillHistogram(Form("hMCTrackInAcceptanceHist%s", name->c_str()), track, assocMC, data->GetRecEvent(), kTRUE, weight);
240  if(fDoMatchPatches && hasPatch) FillHistogram(Form("hMCTrackHistPatchMatch%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE, weight);
241  }
242  }
243  }
244 }
245 
257  const AliVTrack* const trk, const AliMCEvent* evnt) const {
258  int label = TMath::Abs(trk->GetLabel());
259  const AliVParticle *mcpart = evnt->GetTrack(label);
260  if(!mcpart) return NULL;
261  const AliAODMCParticle *aodpart = dynamic_cast<const AliAODMCParticle *>(mcpart);
262  if(aodpart){
263  if(!aodpart->IsPhysicalPrimary()) return NULL;
264  } else {
265  if(!evnt->IsPhysicalPrimary(label)) return NULL;
266  }
267  return mcpart;
268 }
269 
290  const TString& histname, const AliVTrack* const trk,
291  const AliVParticle* assocMC, const AliVEvent* const recev,
292  Bool_t useMCkine, Double_t weight) {
293  if(useMCkine && !assocMC) return;
294  double data[5];
295  data[0] = useMCkine ? TMath::Abs(assocMC->Pt()) : TMath::Abs(trk->Pt());
296  data[1] = (fSwapEta ? -1. : 1.) * (useMCkine ? assocMC->Eta() : trk->Eta());
297  data[2] = useMCkine ? assocMC->Phi() : trk->Phi();
298  data[3] = recev->GetPrimaryVertex()->GetZ();
299  data[4] = fTriggerDecision->IsMinBias();
300  fHistos->FillTHnSparse(histname.Data(), data, weight);
301 }
302 
315  const AliVParticle* const genparticle,
316  const AliVParticle* const recparticle, double weight) {
317  double data[4] = {TMath::Abs(genparticle->Pt()), TMath::Abs(recparticle->Pt()), recparticle->Eta(), recparticle->Phi()};
318  fHistos->FillTHnSparse("hTrackPtCorrelation", data, weight);
319 }
320 
329  const AliVTrack* rectrack, const TClonesArray* inputpatches,
330  TList& outputpatches) const {
331  outputpatches.Clear();
332  Double_t etaEMCAL = rectrack->GetTrackEtaOnEMCal(),
333  phiEMCAL = rectrack->GetTrackPhiOnEMCal();
334  for(TIter patchiter = TIter(inputpatches).Begin(); patchiter != TIter::End(); ++patchiter){
335  AliEmcalTriggerPatchInfo *recpatch = static_cast<AliEmcalTriggerPatchInfo *>(*patchiter);
336  double etamin = TMath::Min(recpatch->GetEtaMin(), recpatch->GetEtaMax()),
337  etamax = TMath::Max(recpatch->GetEtaMin(), recpatch->GetEtaMax()),
338  phimin = TMath::Min(recpatch->GetPhiMin(), recpatch->GetPhiMax()),
339  phimax = TMath::Max(recpatch->GetPhiMin(), recpatch->GetPhiMax());
340  if(etaEMCAL >= etamin && etaEMCAL <= etamax && phiEMCAL >= phimin && phiEMCAL <= phimax){
341  // Patch accepted
342  outputpatches.Add(recpatch);
343  }
344  }
345 }
346 
354  TString triggertype, const TList& patches) const {
355  Bool_t hasGammaLow = kFALSE,
356  hasGammaHigh = kFALSE,
357  hasJetLow = kFALSE,
358  hasJetHigh = kFALSE;
359  for(TIter patchIter = TIter(&patches).Begin(); patchIter != TIter::End(); ++patchIter){
360  AliEmcalTriggerPatchInfo *matchedpad = static_cast<AliEmcalTriggerPatchInfo *>(*patchIter);
362  if(!matchedpad->IsOfflineSimple()) continue;
363  if(matchedpad->IsJetHighSimple()) hasJetHigh = kTRUE;
364  if(matchedpad->IsJetLowSimple()) hasJetLow = kTRUE;
365  if(matchedpad->IsGammaHighSimple()) hasGammaHigh = kTRUE;
366  if(matchedpad->IsGammaLowSimple()) hasGammaLow = kTRUE;
367  } else {
368  if(matchedpad->IsOfflineSimple()) continue;
369  if(matchedpad->IsJetHigh()) hasJetHigh = kTRUE;
370  if(matchedpad->IsJetLow()) hasJetLow = kTRUE;
371  if(matchedpad->IsGammaHigh()) hasGammaHigh = kTRUE;
372  if(matchedpad->IsGammaLow()) hasGammaLow = kTRUE;
373  }
374  }
375  // Evaluate status
376  if((triggertype.Contains("EMCJHigh") || triggertype.Contains("EMCHighJetOnly")) && hasJetHigh) return kTRUE;
377  if((triggertype.Contains("EMCJLow") || triggertype.Contains("EMCLowJetOnly")) && hasJetLow) return kTRUE;
378  if((triggertype.Contains("EMCGHigh") || triggertype.Contains("EMCHighGammaOnly")) && hasGammaHigh) return kTRUE;
379  if((triggertype.Contains("EMCGLow") || triggertype.Contains("EMCLowGammaOnly")) && hasGammaLow) return kTRUE;
380  if(triggertype.Contains("EMCHighBoth") && (hasJetHigh || hasGammaHigh)) return kTRUE;
381  if(triggertype.Contains("EMCLowBoth") && (hasJetLow || hasGammaLow)) return kTRUE;
382  return kFALSE;
383 }
384 
385 } /* 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...
const char * title
Definition: MakeQAPdf.C:26
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)
const AliEMCalTriggerAnaTriggerDecisionConfig * GetConfiguration() const
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.
AliEMCalTriggerBinningDimension * GetBinning(const char *name) const
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
Declaration of the classes AliEMCalTriggerBinningComponent and AliEMCalTriggerBinningDimension.
virtual bool IsTrackAccepted(AliVTrack *const trk)=0
Bool_t HasMatchedPatchOfType(TString triggertype, const TList &patches) const
void FillCorrelation(const AliVParticle *const genparticle, const AliVParticle *const recparticle, double weight=1.)
void MatchTriggerPatches(const AliVTrack *rectrack, const TClonesArray *inputpatches, TList &outputpatches) const
virtual void Process(const AliEMCalTriggerEventData *const data)
Run track loop on list of matching tracks.
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.
Declartion of class AliEMCalPtTaskVTrackSelection.