]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/Tracks/AliEMCalTriggerRecTrackAnalysisComponent.cxx
Implement eta sign swapping for LHC13f
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / Tracks / 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 <TAxis.h>
26 #include <TClonesArray.h>
27 #include <TMath.h>
28 #include <TString.h>
29
30 #include "AliMCEvent.h"
31 #include "AliVCluster.h"
32 #include "AliVEvent.h"
33 #include "AliVParticle.h"
34 #include "AliVTrack.h"
35
36 #include "AliEMCalTriggerAnaTriggerDecision.h"
37 #include "AliEMCalTriggerBinningComponent.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   AliEMCalTriggerTracksAnalysisComponent::CreateHistos();
91
92   // Create trigger definitions
93   std::map<std::string, std::string> triggerCombinations;
94   const char *triggernames[11] = {"MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh",
95       "EMCGLow", "EMCHighBoth", "EMCHighGammaOnly", "EMCHighJetOnly",
96       "EMCLowBoth", "EMCLowGammaOnly", "EMCLowJetOnly"};
97   // Define names and titles for different triggers in the histogram container
98   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[0], "min. bias events"));
99   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[1], "jet-triggered events (high threshold)"));
100   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[2], "jet-triggered events (low threshold)"));
101   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[3], "gamma-triggered events (high threshold)"));
102   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[4], "gamma-triggered events (low threshold)"));
103   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[5], "jet and gamma triggered events (high threshold)"));
104   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[6], "exclusively gamma-triggered events (high threshold)"));
105   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[7], "exclusively jet-triggered events (high threshold)"));
106   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[8], "jet and gamma triggered events (low threshold)"));
107   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[9], "exclusively gamma-triggered events (low threshold)"));
108   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[10], "exclusively-triggered events (low threshold)"));
109
110   // Create axis definitions
111   const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
112       *etabinning = fBinning->GetBinning("eta"),
113       *phibinning = fBinning->GetBinning("phi"),
114       *vertexbinning = fBinning->GetBinning("vertex");
115
116   const TAxis *trackaxes[5] = {
117       DefineAxis("pt", ptbinning),
118       DefineAxis("eta", etabinning),
119       DefineAxis("phi", phibinning),
120       DefineAxis("zvertex", vertexbinning),
121       DefineAxis("mbtrigger", 2, -0.5, 1.5)
122   };
123
124   // Build histograms
125   for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
126     const std::string name = it->first, &title = it->second;
127     fHistos->CreateTHnSparse(Form("hTrackHist%s", name.c_str()), Form("Track-based data for %s events", title.c_str()), 5, trackaxes, "s");
128     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");
129     fHistos->CreateTHnSparse(Form("hMCTrackHist%s", name.c_str()), Form("Track-based data for %s events with MC kinematics", title.c_str()), 5, trackaxes, "s");
130     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");
131   }
132
133   for(int iaxis = 0; iaxis < 5; iaxis++) delete trackaxes[iaxis];
134 }
135
136 //______________________________________________________________________________
137 void AliEMCalTriggerRecTrackAnalysisComponent::Process(const AliEMCalTriggerEventData* const data) {
138   /*
139    * Run track loop on list of matching tracks
140    *
141    * @param data: the event data
142    */
143
144   std::vector<std::string> triggernames;
145   this->GetMachingTriggerNames(triggernames, fUsePatches);
146
147   AliVTrack *track(NULL);
148   AliVParticle *assocMC(NULL);
149   TIter trackIter(data->GetMatchedTrackContainer());
150   while((track = dynamic_cast<AliVTrack *>(trackIter()))){
151     // Apply track selection
152     assocMC = NULL;
153     if(fKineCuts && !fKineCuts->IsSelected(track)) continue;
154     if(fTrackSelection && !fTrackSelection->IsTrackAccepted(track)) continue;
155     if(fRequestMCtrue && data->GetMCEvent() && !(assocMC = IsMCTrueTrack(track, data->GetMCEvent()))) continue;
156
157     // Try to match the cluster
158     Bool_t hasCluster = kFALSE;
159     AliVCluster *clust(NULL);
160     if(track->GetEMCALcluster() >= 0 && (clust = dynamic_cast<AliVCluster *>(data->GetClusterContainer()->At(track->GetEMCALcluster()))))
161       hasCluster = kTRUE;
162
163     // Fill histograms
164     for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); name++){
165       FillHistogram(Form("hTrackHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE);
166       if(hasCluster) FillHistogram(Form("hTrackInAcceptanceHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE);
167       if(assocMC){
168         FillHistogram(Form("hMCTrackHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kTRUE);
169         if(hasCluster) FillHistogram(Form("hMCTrackInAcceptanceHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kTRUE);
170       }
171     }
172   }
173 }
174
175 //______________________________________________________________________________
176 AliVParticle * AliEMCalTriggerRecTrackAnalysisComponent::IsMCTrueTrack(
177     const AliVTrack* const trk, const AliMCEvent* evnt) const {
178   /*
179    * Check according to the associated MC information whether the track is a MC true track,
180    * and whether it is physical primary
181    *
182    * @param trk: track to check
183    * @param evnt: MC event information necessary for the check
184    *
185    * @return: the associated MC particle (NULL if not MC true)
186    */
187   int label = TMath::Abs(trk->GetLabel());
188   AliVParticle *mcpart = evnt->GetTrack(label);
189   if(!mcpart) return NULL;
190   if(!evnt->IsPhysicalPrimary(label)) return NULL;
191   return mcpart;
192 }
193
194 //______________________________________________________________________________
195 void AliEMCalTriggerRecTrackAnalysisComponent::FillHistogram(
196     const TString& histname, const AliVTrack* const trk,
197     const AliVParticle* assocMC, const AliVEvent* const recev,
198     Bool_t useMCkine) {
199   /*
200    *
201    */
202   if(useMCkine && !assocMC) return;
203   double data[5];
204   data[0] = useMCkine ? TMath::Abs(assocMC->Pt()) : TMath::Abs(trk->Pt());
205   data[1] = (fSwapEta ? -1. : 1.) * (useMCkine ? assocMC->Eta() : trk->Eta());
206   data[2] = useMCkine ? assocMC->Phi() : trk->Phi();
207   data[3] = recev->GetPrimaryVertex()->GetZ();
208   data[4] = fTriggerDecision->IsMinBias();
209   fHistos->FillTHnSparse(histname.Data(), data);
210 }
211
212 } /* namespace EMCalTriggerPtAnalysis */