AliPhysics  v5-07-18-02 (20ec537)
 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 "AliEmcalTriggerPatchInfoAP.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  fRequestMCtrue(kFALSE),
59  fDoMatchPatches(kFALSE)
60 {
61 }
62 
71  fTrackSelection(NULL),
72  fSwapEta(kFALSE),
73  fRequestMCtrue(kFALSE),
74  fDoMatchPatches(kFALSE)
75 {
76 }
77 
85 }
86 
104 
105  // Create trigger definitions
106  std::map<std::string, std::string> triggerCombinations;
107  GetAllTriggerNamesAndTitles(triggerCombinations);
108 
109  // Create axis definitions
110  const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
111  *etabinning = fBinning->GetBinning("eta"),
112  *phibinning = fBinning->GetBinning("phi"),
113  *vertexbinning = fBinning->GetBinning("zvertex");
114 
115  const TAxis *trackaxes[5] = {
116  DefineAxis("pt", ptbinning),
117  DefineAxis("eta", etabinning),
118  DefineAxis("phi", phibinning),
119  DefineAxis("zvertex", vertexbinning),
120  DefineAxis("mbtrigger", 2, -0.5, 1.5)
121  };
122 
123  // Build histograms
124  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
125  const std::string name = it->first, &title = it->second;
126  fHistos->CreateTHnSparse(Form("hTrackHist%s", name.c_str()), Form("Track-based data for %s events", title.c_str()), 5, trackaxes, "s");
127  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");
128  fHistos->CreateTHnSparse(Form("hMCTrackHist%s", name.c_str()), Form("Track-based data for %s events with MC kinematics", title.c_str()), 5, trackaxes, "s");
129  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");
130  if(fDoMatchPatches){
131  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");
132  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");
133  }
134  }
135 
136  // Correlation Matrix
137  // 1. gen pt
138  // 2. rec pt
139  // 3. rec eta
140  // 4. rec phi
141  const TAxis *corraxes[4] = {
142  DefineAxis("ptgen", ptbinning),
143  DefineAxis("ptrec", ptbinning),
144  DefineAxis("eta", etabinning),
145  DefineAxis("phi", phibinning)
146  };
147  fHistos->CreateTHnSparse("hTrackPtCorrelation", "Correlation matrix for track pt", 4, corraxes);
148 
149  for(int iaxis = 0; iaxis < 5; iaxis++) delete trackaxes[iaxis];
150 }
151 
171  AliDebug(1, Form("Number of matched tracks: %d", data->GetMatchedTrackContainer()->GetEntries()));
172  if(fRequestMCtrue && !data->GetMCEvent()) return;
173 
174  std::vector<std::string> triggernames;
175  this->GetMachingTriggerNames(triggernames);
176 
177  AliVTrack *track(NULL);
178  const AliVParticle *assocMC(NULL);
179  if(!data->GetMatchedTrackContainer()){
180  AliError("No container for matched tracks");
181  return;
182  }
183  TIter trackIter(data->GetMatchedTrackContainer());
184 
185  double weight = 1.;
186  if(fWeightHandler && data->GetMCEvent()){
187  weight = fWeightHandler->GetEventWeight(data->GetMCEvent());
188  }
189  while((track = dynamic_cast<AliVTrack *>(trackIter()))){
190  // Apply track selection
191  assocMC = NULL;
192  if(fKineCuts && !fKineCuts->IsSelected(track)) continue;
194  AliDebug(2, "Track not accepted");
195  continue;
196  }
197 
198  if(fRequestMCtrue){
199  if(!(assocMC = IsMCTrueTrack(track, data->GetMCEvent()))) continue; // Not a true track
200  this->FillCorrelation(assocMC, track);
201  }
202  // Try to match the cluster
203  Bool_t hasCluster = kFALSE;
204  AliVCluster *clust(NULL);
205  AliVTrack *testtrack = track;
206  AliPicoTrack *pictrack = dynamic_cast<AliPicoTrack *>(track);
207  if(pictrack) testtrack = pictrack->GetTrack();
208  if(testtrack->GetEMCALcluster() >= 0 && (clust = dynamic_cast<AliVCluster *>(data->GetClusterContainer()->At(testtrack->GetEMCALcluster()))))
209  hasCluster = kTRUE;
210 
211  // Try to match to EMCAL patches (only in case the event is triggered)
212  TList patches;
213  if(fDoMatchPatches && triggernames.size()) MatchTriggerPatches(track, data->GetTriggerPatchContainer(), patches);
214 
215  // Fill histograms
216  for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); name++){
217  FillHistogram(Form("hTrackHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE, weight);
218  if(hasCluster) FillHistogram(Form("hTrackInAcceptanceHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE, weight);
219  Bool_t hasPatch = HasMatchedPatchOfType(*name, patches);
220  if(fDoMatchPatches && hasPatch) FillHistogram(Form("hTrackHistPatchMatch%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE, weight);
221  if(assocMC){
222  FillHistogram(Form("hMCTrackHist%s", name->c_str()), track, assocMC, data->GetRecEvent(), kTRUE, weight);
223  if(hasCluster) FillHistogram(Form("hMCTrackInAcceptanceHist%s", name->c_str()), track, assocMC, data->GetRecEvent(), kTRUE, weight);
224  if(fDoMatchPatches && hasPatch) FillHistogram(Form("hMCTrackHistPatchMatch%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE, 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(mcpart->GetLabel())) 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();
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 
313  const AliVTrack* rectrack, const TClonesArray* inputpatches,
314  TList& outputpatches) const {
315  outputpatches.Clear();
316  Double_t etaEMCAL = rectrack->GetTrackEtaOnEMCal(),
317  phiEMCAL = rectrack->GetTrackPhiOnEMCal();
318  for(TIter patchiter = TIter(inputpatches).Begin(); patchiter != TIter::End(); ++patchiter){
319  AliEmcalTriggerPatchInfo *recpatch = static_cast<AliEmcalTriggerPatchInfo *>(*patchiter);
320  double etamin = TMath::Min(recpatch->GetEtaMin(), recpatch->GetEtaMax()),
321  etamax = TMath::Max(recpatch->GetEtaMin(), recpatch->GetEtaMax()),
322  phimin = TMath::Min(recpatch->GetPhiMin(), recpatch->GetPhiMax()),
323  phimax = TMath::Max(recpatch->GetPhiMin(), recpatch->GetPhiMax());
324  if(etaEMCAL >= etamin && etaEMCAL <= etamax && phiEMCAL >= phimin && phiEMCAL <= phimax){
325  // Patch accepted
326  outputpatches.Add(recpatch);
327  }
328  }
329 }
330 
338  TString triggertype, const TList& patches) const {
339  Bool_t hasGammaLow = kFALSE,
340  hasGammaHigh = kFALSE,
341  hasJetLow = kFALSE,
342  hasJetHigh = kFALSE;
343  for(TIter patchIter = TIter(&patches).Begin(); patchIter != TIter::End(); ++patchIter){
344  AliEmcalTriggerPatchInfo *matchedpad = static_cast<AliEmcalTriggerPatchInfo *>(*patchIter);
345  if(matchedpad->IsOfflineSimple()) continue;
346  if(matchedpad->IsJetHigh()) hasJetHigh = kTRUE;
347  if(matchedpad->IsJetLow()) hasJetLow = kTRUE;
348  if(matchedpad->IsGammaHigh()) hasGammaHigh = kTRUE;
349  if(matchedpad->IsGammaLow()) hasGammaLow = kTRUE;
350  }
351  // Evaluate status
352  if((triggertype.Contains("EMCJHigh") || triggertype.Contains("EMCHighJetOnly")) && hasJetHigh) return kTRUE;
353  if((triggertype.Contains("EMCJLow") || triggertype.Contains("EMCLowJetOnly")) && hasJetLow) return kTRUE;
354  if((triggertype.Contains("EMCGHigh") || triggertype.Contains("EMCHighGammaOnly")) && hasGammaHigh) return kTRUE;
355  if((triggertype.Contains("EMCGLow") || triggertype.Contains("EMCLowGammaOnly")) && hasGammaLow) return kTRUE;
356  if(triggertype.Contains("EMCHighBoth") && (hasJetHigh || hasGammaHigh)) return kTRUE;
357  if(triggertype.Contains("EMCLowBoth") && (hasJetLow || hasGammaLow)) return kTRUE;
358  return kFALSE;
359 }
360 
361 } /* namespace EMCalTriggerPtAnalysis */
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Weight handler for the analysis of high- tracks in EMCAL-triggered events.
const char * title
Definition: MakeQAPdf.C:26
void GetMachingTriggerNames(std::vector< std::string > &triggernames) const
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.
TAxis * DefineAxis(const char *name, const AliEMCalTriggerBinningDimension *binning)
void FillTHnSparse(const char *name, const double *x, double weight=1.)
Analysis component for reconstructed tracks.
const Double_t etamin
Declaration of a management class for trigger classes.
void CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
void GetAllTriggerNamesAndTitles(std::map< std::string, std::string > &triggers) const
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.
AliEMCalPtTaskVTrackSelection * fTrackSelection
Track selection cuts used in the analysis.
const AliEMCalTriggerAnaClassManager * fTriggerClassManager
Global trigger class manager.
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.
AliVTrack * GetTrack() const
Definition: AliPicoTrack.h:59
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
const Double_t etamax
void FillCorrelation(const AliVParticle *const genparticle, const AliVParticle *const recparticle, double weight=1.)
void MatchTriggerPatches(const AliVTrack *rectrack, const TClonesArray *inputpatches, TList &outputpatches) const
Simple event container within the high- track analysis.
virtual void Process(const AliEMCalTriggerEventData *const data)
Run track loop on list of matching tracks.
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.
Event Data used in exchange to the different analysis components.
Declartion of class AliEMCalPtTaskVTrackSelection.
const Double_t phimin