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