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