AliPhysics  70cdb53 (70cdb53)
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 #include "AliTrackerBase.h"
28 
32 
35 fEMCALRecoUtils(NULL),
36 fEMCALGeo(NULL),
37 fPIDResponse(NULL),
38 fElectronInformation(ElectronForAlignment()),
39 fElectronTree(NULL),
40 fTreeSuffix("")
41 {
42 
43 }
44 
46 AliAnalysisTaskEmcal(name, kTRUE),
47 fEMCALRecoUtils(NULL),
48 fEMCALGeo(NULL),
49 fPIDResponse(NULL),
50 fElectronInformation(ElectronForAlignment()),
51 fElectronTree(NULL),
52 fTreeSuffix("")
53 {
55  DefineOutput(2, TTree::Class());
56 }
57 
58 
60 {
61  if (fEMCALRecoUtils)
62  delete fEMCALRecoUtils;
63  if (fElectronTree)
64  delete fElectronTree;
65 }
66 
67 
69 {
71 
72  fPIDResponse = fInputHandler->GetPIDResponse();
73 
74  TString name_tree("electron_information");
75  name_tree += fTreeSuffix;
76 
77  fElectronTree = new TTree(name_tree,name_tree);
78  fElectronTree->Branch("electrons", &fElectronInformation);
79  PostData(2, fElectronTree);
80 }
81 
82 
84 {
85  DoTrackLoop();
86  return kTRUE;
87 }
88 
90 {
92 
93  if (!clusCont)
94  {
95  AliError("No Cluster Container Available\n");
96  return;
97  }
98 
99  AliParticleContainer* partCont = 0;
100 
101  TIter next(&fParticleCollArray);
102 
103  while ((partCont = static_cast<AliParticleContainer*>(next()))) {
104  for(auto part : partCont->accepted())
105  {
106  if (!part)
107  continue;
108 
109  const AliVTrack* track = static_cast<const AliVTrack*>(part);
110  if (!track)
111  continue;
112 
113  //-1.5 to 3.5 sigma TPC to reduce the size of the trees
114  Double_t n_sigma_electron_TPC = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron);
115 
116  if (n_sigma_electron_TPC < -1.5 || n_sigma_electron_TPC > 3.5)
117  continue;
118 
119  Int_t iCluster = track->GetEMCALcluster();
120 
121  if (iCluster < 0)
122  continue;
123 
124  AliVCluster* cluster = clusCont->GetAcceptCluster(iCluster);
125 
126  if (!cluster)
127  continue;
128 
129  Double_t EoverP = cluster->E()/track->P();
130 
131  //Loose E/p cut to reduce tree
132  if (EoverP<0.7 || EoverP>1.3)
133  continue;
134 
135  //Cluster properties
136  Float_t emcx[3];
137  cluster->GetPosition(emcx);
138  TVector3 clustpos(emcx[0],emcx[1],emcx[2]);
139 
140  Int_t iSupMod = -9;
141  Int_t ieta = -9;
142  Int_t iphi = -9;
143  Int_t icell = -9;
144  Bool_t Isshared = kFALSE;
145 
146  //Get the SM number
147  fEMCALRecoUtils->GetMaxEnergyCell(fEMCALGeo,fCaloCells,cluster,icell,iSupMod,ieta,iphi,Isshared);
148 
149  //Propagation using electron mass
150 
151  Double_t xyz[3] = {0}, pxpypz[3] = {0}, cv[21] = {0};
152  track->PxPyPz(pxpypz);
153  track->XvYvZv(xyz);
154  track->GetCovarianceXYZPxPyPz(cv);
155  AliExternalTrackParam trackParam = AliExternalTrackParam(xyz,pxpypz,cv,track->Charge());
156 
157  Double_t trackPosExt[3] = {0.,0.,0.};
158  Double_t ElectronMass = 0.000510998910; //Electron mass in GeV
159 
160  if (!AliTrackerBase::PropagateTrackToBxByBz(&trackParam, clustpos.Perp(), ElectronMass, fEMCALRecoUtils->GetStep(),kTRUE, 0.8, -1))
161  continue;
162 
163  trackParam.GetXYZ(trackPosExt);
164 
165  TVector3 trackposOnEMCAL;
166  trackposOnEMCAL.SetXYZ(trackPosExt[0],trackPosExt[1],trackPosExt[2]);
167 
168  //Save to Tree
169  //Basic track properties
170  fElectronInformation.charge = track->Charge();
171  fElectronInformation.pt = track->Pt();
172  fElectronInformation.pz = track->Pz();
173  fElectronInformation.eta_track = track->Eta();
174  fElectronInformation.phi_track = track->Phi();
176 
177  //cluster properties
178  fElectronInformation.energy = cluster->E();
179  fElectronInformation.M20 = cluster->GetM20();
180  fElectronInformation.M02 = cluster->GetM02();
181  fElectronInformation.eta_cluster = clustpos.Eta();
182  fElectronInformation.phi_cluster = clustpos.Phi();
183  fElectronInformation.x_cluster = clustpos.X();
184  fElectronInformation.y_cluster = clustpos.Y();
185  fElectronInformation.z_cluster = clustpos.Z();
186 
187 
188  //mathing properties using electron mass
189  fElectronInformation.x_track = trackposOnEMCAL.X();
190  fElectronInformation.y_track = trackposOnEMCAL.Y();
191  fElectronInformation.z_track = trackposOnEMCAL.Z();
192 
193  //aditional information
195  fElectronInformation.distance_bad_channel = cluster->GetDistanceToBadChannel();
196 
197  AliVCaloCells *cells = InputEvent()->GetEMCALCells();
199 
200  //PID properties
201  fElectronInformation.n_sigma_electron_TPC = n_sigma_electron_TPC;
202 
203  fElectronTree->Fill();
204 
205  }
206 
207 
208  }
209 
210  PostData(2, fElectronTree);
211 }
212 
214 {
216 
217  //EMCal utilits
218  fEMCALGeo = AliEMCALGeometry::GetInstance();
222 }
223 
225 {
226  return kTRUE;
227 }
228 
230 {
231 }
ElectronForAlignment fElectronInformation
PID response task used to perform electron identification.
double Double_t
Definition: External.C:58
Bool_t CheckCellFiducialRegion(const AliEMCALGeometry *geom, const AliVCluster *cluster, AliVCaloCells *cells)
AliPIDResponse * fPIDResponse
EMCAL geometry class.
void SetNumberOfCellsFromEMCALBorder(Int_t n)
Base task in the EMCAL framework.
TTree * fElectronTree
Object to hold the electron information.
Some utilities for cluster and cell treatment.
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
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
void GetMaxEnergyCell(const AliEMCALGeometry *geom, AliVCaloCells *cells, const AliVCluster *clu, Int_t &absId, Int_t &iSupMod, Int_t &ieta, Int_t &iphi, Bool_t &shared)
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.
Double_t GetStep() const
Double_t fVertex[3]
!event vertex
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.