]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerRecTrackAnalysisComponent.cxx
79635b50a4480c32dac6ec74ab7c8bd619bf1b82
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliEMCalTriggerRecTrackAnalysisComponent.cxx
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 /*
16  * Track analysis component: Loops over tracks from the EMCal track container and
17  * counts the tracks in histograms
18  *
19  *   Author: Markus Fasel
20  */
21 #include <map>
22 #include <string>
23 #include <vector>
24
25 #include <TClonesArray.h>
26 #include <TMath.h>
27 #include <TString.h>
28
29 #include "AliMCEvent.h"
30 #include "AliVCluster.h"
31 #include "AliVEvent.h"
32 #include "AliVParticle.h"
33 #include "AliVTrack.h"
34 #include "AliVVertex.h"
35
36 #include "AliEMCalTriggerBinningComponent.h"
37 #include "AliEMCalTriggerAnaTriggerDecision.h"
38 #include "AliEMCalTriggerEventData.h"
39 #include "AliEMCalTriggerKineCuts.h"
40 #include "AliEMCalPtTaskVTrackSelection.h"
41 #include "AliEMCalTriggerRecTrackAnalysisComponent.h"
42
43 ClassImp(EMCalTriggerPtAnalysis::AliEMCalTriggerRecTrackAnalysisComponent)
44
45 namespace EMCalTriggerPtAnalysis {
46
47 //______________________________________________________________________________
48 AliEMCalTriggerRecTrackAnalysisComponent::AliEMCalTriggerRecTrackAnalysisComponent() :
49   AliEMCalTriggerTracksAnalysisComponent(),
50   fTrackSelection(NULL),
51   fSwapEta(kFALSE),
52   fUsePatches(kFALSE),
53   fRequestMCtrue(kFALSE)
54 {
55   /*
56    * Dummy (I/O) constructor
57    */
58 }
59
60 //______________________________________________________________________________
61 AliEMCalTriggerRecTrackAnalysisComponent::AliEMCalTriggerRecTrackAnalysisComponent(const char *name) :
62   AliEMCalTriggerTracksAnalysisComponent(name),
63   fTrackSelection(NULL),
64   fSwapEta(kFALSE),
65   fUsePatches(kFALSE),
66   fRequestMCtrue(kFALSE)
67 {
68   /*
69    * Main constructor
70    */
71 }
72
73 //______________________________________________________________________________
74 AliEMCalTriggerRecTrackAnalysisComponent::~AliEMCalTriggerRecTrackAnalysisComponent() {
75   /*
76    * Destructor, taking care of the track selection
77    */
78   if(fTrackSelection) delete fTrackSelection;
79 }
80
81 //______________________________________________________________________________
82 void AliEMCalTriggerRecTrackAnalysisComponent::CreateHistos() {
83   /*
84    * Create histograms of the track analysis component. For each trigger class we have
85    * - tracks with esd information
86    * - tracks with MC information
87    * - tracks with clusters and esd information
88    * - tracks with clusters and MC information
89    */
90   // Create trigger definitions
91   std::map<std::string, std::string> triggerCombinations;
92   const char *triggernames[12] = {"MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh",
93       "EMCGLow", "NoEMCal", "EMCHighBoth", "EMCHighGammaOnly", "EMCHighJetOnly",
94       "EMCLowBoth", "EMCLowGammaOnly", "EMCLowJetOnly"};
95   // Define names and titles for different triggers in the histogram container
96   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[0], "min. bias events"));
97   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[1], "jet-triggered events (high threshold)"));
98   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[2], "jet-triggered events (low threshold)"));
99   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[3], "gamma-triggered events (high threshold)"));
100   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[4], "gamma-triggered events (low threshold)"));
101   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[5], "non-EMCal-triggered events"));
102   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[6], "jet and gamma triggered events (high threshold)"));
103   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[7], "exclusively gamma-triggered events (high threshold)"));
104   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[8], "exclusively jet-triggered events (high threshold)"));
105   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[9], "jet and gamma triggered events (low threshold)"));
106   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[10], "exclusively gamma-triggered events (low threshold)"));
107   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[11], "exclusively-triggered events (low threshold)"));
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("vertex");
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 with MC kinematics for tracks matched to EMCal clusters", title.c_str()), 5, trackaxes, "s");
130   }
131
132   for(int iaxis = 0; iaxis < 5; iaxis++) delete trackaxes[iaxis];
133 }
134
135 //______________________________________________________________________________
136 void AliEMCalTriggerRecTrackAnalysisComponent::Process(const AliEMCalTriggerEventData* const data) {
137   /*
138    * Run track loop on list of matching tracks
139    *
140    * @param data: the event data
141    */
142
143   std::vector<std::string> triggernames;
144   this->GetMachingTriggerNames(triggernames, fUsePatches);
145
146   AliVTrack *track(NULL);
147   AliVParticle *assocMC(NULL);
148   TIter trackIter(data->GetMatchedTrackContainer());
149   while((track = dynamic_cast<AliVTrack *>(trackIter()))){
150     // Apply track selection
151     assocMC = NULL;
152     if(fKineCuts && !fKineCuts->IsSelected(track)) continue;
153     if(fTrackSelection && !fTrackSelection->IsTrackAccepted(track)) continue;
154     if(fRequestMCtrue && data->GetMCEvent() && !(assocMC = IsMCTrueTrack(track, data->GetMCEvent()))) continue;
155
156     // Try to match the cluster
157     Bool_t hasCluster = kFALSE;
158     AliVCluster *clust(NULL);
159     if(track->GetEMCALcluster() >= 0 && (clust = dynamic_cast<AliVCluster *>(data->GetClusterContainer()->At(track->GetEMCALcluster()))))
160       hasCluster = kTRUE;
161
162     // Fill histograms
163     for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); name++){
164       FillHistogram(Form("hTrackHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE);
165       if(hasCluster) FillHistogram(Form("hTrackInAcceptanceHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE);
166       if(assocMC){
167         FillHistogram(Form("hMCTrackHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kTRUE);
168         if(hasCluster) FillHistogram(Form("hMCTrackInAcceptanceHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kTRUE);
169       }
170     }
171   }
172 }
173
174 //______________________________________________________________________________
175 AliVParticle * AliEMCalTriggerRecTrackAnalysisComponent::IsMCTrueTrack(
176     const AliVTrack* const trk, const AliMCEvent* evnt) const {
177   /*
178    * Check according to the associated MC information whether the track is a MC true track,
179    * and whether it is physical primary
180    *
181    * @param trk: track to check
182    * @param evnt: MC event information necessary for the check
183    *
184    * @return: the associated MC particle (NULL if not MC true)
185    */
186   int label = TMath::Abs(trk->GetLabel());
187   AliVParticle *mcpart = evnt->GetTrack(label);
188   if(!mcpart) return NULL;
189   if(!evnt->IsPhysicalPrimary(label)) return NULL;
190   return mcpart;
191 }
192
193 //______________________________________________________________________________
194 void AliEMCalTriggerRecTrackAnalysisComponent::FillHistogram(
195     const TString& histname, const AliVTrack* const trk,
196     const AliVParticle* assocMC, const AliVEvent* const recev,
197     Bool_t useMCkine) {
198   /*
199    *
200    */
201   if(useMCkine && !assocMC) return;
202   double data[5];
203   data[0] = useMCkine ? TMath::Abs(assocMC->Pt()) : TMath::Abs(trk->Pt());
204   data[1] = useMCkine ? assocMC->Eta() : trk->Eta();
205   data[2] = useMCkine ? assocMC->Phi() : trk->Phi();
206   data[3] = recev->GetPrimaryVertex()->GetZ();
207   data[4] = fTriggerDecision->IsMinBias();
208   fHistos->FillTHnSparse(histname.Data(), data);
209 }
210
211 } /* namespace EMCalTriggerPtAnalysis */