AliPhysics  b555aef (b555aef)
AliAnalysisTaskEMCALAlig.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2017, 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 #include <AliVCluster.h>
17 #include <AliVParticle.h>
18 #include "AliParticleContainer.h"
19 #include "AliClusterContainer.h"
20 #include "AliPIDResponse.h"
21 #include "AliInputEventHandler.h"
23 #include "AliEMCALRecoUtils.h"
24 #include "AliEMCALGeometry.h"
25 #include "AliExternalTrackParam.h"
26 #include "TVector3.h"
27 
31 
34 fEMCALRecoUtils(NULL),
35 fEMCALGeo(NULL),
36 fPIDResponse(NULL),
37 fElectronInformation(ElectronForAlignment()),
38 fElectronTree(NULL),
39 fTreeSuffix("")
40 {
41 
42 }
43 
45 AliAnalysisTaskEmcal(name, kTRUE),
46 fEMCALRecoUtils(NULL),
47 fEMCALGeo(NULL),
48 fPIDResponse(NULL),
49 fElectronInformation(ElectronForAlignment()),
50 fElectronTree(NULL),
51 fTreeSuffix("")
52 {
54  DefineOutput(2, TTree::Class());
55 }
56 
57 
59 {
60  if (fEMCALRecoUtils)
61  delete fEMCALRecoUtils;
62  if (fElectronTree)
63  delete fElectronTree;
64 }
65 
66 
68 {
70 
71  fPIDResponse = fInputHandler->GetPIDResponse();
72 
73  TString name_tree("electron_information");
74  name_tree += fTreeSuffix;
75 
76  fElectronTree = new TTree(name_tree,name_tree);
77  fElectronTree->Branch("electrons", &fElectronInformation);
78  PostData(2, fElectronTree);
79 }
80 
81 
83 {
84  DoTrackLoop();
85  return kTRUE;
86 }
87 
89 {
91 
92  if (!clusCont)
93  {
94  AliError("No Cluster Container Available\n");
95  return;
96  }
97 
98  AliParticleContainer* partCont = 0;
99 
100  TIter next(&fParticleCollArray);
101 
102  while ((partCont = static_cast<AliParticleContainer*>(next()))) {
103 
104  UInt_t count = 0;
105 
106  for(auto part : partCont->accepted())
107  {
108  if (!part)
109  continue;
110  count++;
111 
112  const AliVTrack* track = static_cast<const AliVTrack*>(part);
113  if (!track)
114  continue;
115 
116  //-1.5 to 3.5 sigma TPC to reduce the size of the trees
117  Double_t n_sigma_electron_TPC = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron);
118 
119  if (n_sigma_electron_TPC < -1.5 || n_sigma_electron_TPC > 3.5)
120  continue;
121 
122  Int_t iCluster = track->GetEMCALcluster();
123 
124  if (iCluster < 0)
125  continue;
126 
127  AliVCluster* cluster = clusCont->GetAcceptCluster(iCluster);
128 
129  if (!cluster)
130  continue;
131 
132  Double_t EoverP = cluster->GetNonLinCorrEnergy()/track->P();
133 
134  //Loose E/p cut to reduce tree
135  if (EoverP<0.7 || EoverP>1.3)
136  continue;
137 
138  //Cluster properties
139  Float_t emcx[3];
140  cluster->GetPosition(emcx);
141  TVector3 clustpos(emcx[0],emcx[1],emcx[2]);
142  Double_t emcphi = clustpos.Phi();
143  Double_t emceta = clustpos.Eta();
144 
145  if(emcphi < 0) emcphi = emcphi+(2*TMath::Pi());
146 
147  Int_t iSupMod = -9;
148  Int_t ieta = -9;
149  Int_t iphi = -9;
150  Int_t icell = -9;
151  Bool_t Isshared = kFALSE;
152 
153  //Get the SM number
154  fEMCALRecoUtils->GetMaxEnergyCell(fEMCALGeo,fCaloCells,cluster,icell,iSupMod,ieta,iphi,Isshared);
155 
156  //Default propagation
157  TVector3 trackposOnEMCAL;
158  trackposOnEMCAL.SetPtEtaPhi(440,track->GetTrackEtaOnEMCal(),track->GetTrackPhiOnEMCal());
159 
160  Float_t xdiff = trackposOnEMCAL.X() - clustpos.X();
161  Float_t ydiff = trackposOnEMCAL.Y() - clustpos.Y();
162  Float_t zdiff = trackposOnEMCAL.Z() - clustpos.Z();
163 
164  //propagation using electron mass
165 
166  Double_t xyz[3] = {0}, pxpypz[3] = {0}, cv[21] = {0};
167  track->PxPyPz(pxpypz);
168  track->XvYvZv(xyz);
169  track->GetCovarianceXYZPxPyPz(cv);
170  AliExternalTrackParam trackParam = AliExternalTrackParam(xyz,pxpypz,cv,track->Charge());
171 
172  Double_t trackPosExt[3] = {0.,0.,0.};
173  Double_t ElectronMass = 0.000510998910; //Electron mass in GeV
174  Float_t EtaResidualsForCrossCheck, PhiResidualsForCrossCheck;
175 
176  fEMCALRecoUtils->ExtrapolateTrackToPosition(&trackParam, emcx, ElectronMass, fEMCALRecoUtils->GetStep(), EtaResidualsForCrossCheck,PhiResidualsForCrossCheck);
177  trackParam.GetXYZ(trackPosExt);
178 
179  TVector3 trackposOnEMCALRU;
180 
181  trackposOnEMCALRU.SetXYZ(trackPosExt[0],trackPosExt[1],trackPosExt[2]);
182 
183  Double_t phidiffRU = TVector2::Phi_mpi_pi(trackposOnEMCALRU.Phi()-emcphi);
184  Double_t etadiffRU = trackposOnEMCALRU.Eta() - emceta;
185  Double_t xdiffRU = trackposOnEMCALRU.X() - clustpos.X();
186  Double_t ydiffRU = trackposOnEMCALRU.Y() - clustpos.Y();
187  Double_t zdiffRU = trackposOnEMCALRU.Z() - clustpos.Z();
188 
189  //Save to Tree
190 
191  fElectronInformation.charge = track->Charge();
192  fElectronInformation.pt = track->Pt();
193  fElectronInformation.pz = track->Pz();
194  fElectronInformation.eta_track = track->Eta();
195  fElectronInformation.phi_track = track->Phi();
196 
197  //cluster properties
198  fElectronInformation.energy = cluster->GetNonLinCorrEnergy();
199  fElectronInformation.M20 = cluster->GetM20();
200  fElectronInformation.M02 = cluster->GetM02();
201  fElectronInformation.eta_cluster = clustpos.Eta();
202  fElectronInformation.phi_cluster = clustpos.Phi();
203 
204  //mathing properties using default matcher
208  fElectronInformation.phi_resitual_def = cluster->GetTrackDx();
209  fElectronInformation.eta_resitual_def = cluster->GetTrackDz();
210 
211  //mathing properties using electron mass
217 
219  //PID properties
220  fElectronInformation.n_sigma_electron_TPC = n_sigma_electron_TPC;
221 
222  fElectronTree->Fill();
223 
224  }
225 
226 
227  }
228 
229  PostData(2, fElectronTree);
230 }
231 
233 {
235 
236  //EMCal utilits
237  fEMCALGeo = AliEMCALGeometry::GetInstance();
238  fEMCALRecoUtils = new AliEMCALRecoUtils();
239  fEMCALRecoUtils->InitParameters();
240 }
241 
243 {
244  return kTRUE;
245 }
246 
248 {
249 }
ElectronForAlignment fElectronInformation
PID response task used to perform electron identification.
double Double_t
Definition: External.C:58
AliPIDResponse * fPIDResponse
EMCAL geometry class.
Base task in the EMCAL framework.
TTree * fElectronTree
Object to hold the electron information.
Container for particles within the EMCAL framework.
TObjArray fParticleCollArray
particle/track collection array
void ExecOnce()
Perform steps needed to initialize the analysis.
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
TString fTreeSuffix
Electron tree output.
float Float_t
Definition: External.C:68
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
AliVCluster * GetAcceptCluster(Int_t i) const
AliVCaloCells * fCaloCells
!cells
Bool_t Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
Bool_t FillHistograms()
Function filling histograms.
void SetMakeGeneralHistograms(Bool_t g)
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
const AliParticleIterableContainer accepted() const
const char Option_t
Definition: External.C:48
AliEMCALGeometry * fEMCALGeo
EMCAL Reco utils used to recalculate the matching.
void UserCreateOutputObjects()
Main initialization function on the worker.
bool Bool_t
Definition: External.C:53
Container structure for EMCAL clusters.