]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/AliGammaMCReader.cxx
update Toolkit classes
[u/mrichter/AliRoot.git] / PWG4 / AliGammaMCReader.cxx
CommitLineData
bdcfac30 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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 *
4b707925 12 * about the suitability of this software for any purpose. It is *
bdcfac30 13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15/* $Id$ */
16
17/* History of cvs commits:
18 *
19 * $Log$
bdcfac30 20 *
21 */
22
23//_________________________________________________________________________
24// Class for reading data (Kinematics) in order to do prompt gamma correlations
25// Class created from old AliPHOSGammaJet
26// (see AliRoot versions previous Release 4-09)
27//
28//*-- Author: Gustavo Conesa (LNF-INFN)
29//////////////////////////////////////////////////////////////////////////////
30
31
32// --- ROOT system ---
33
34#include <TFile.h>
35#include <TParticle.h>
36#include <TH2.h>
37#include <TChain.h>
38#include <TRandom.h>
39
40//---- ANALYSIS system ----
41#include "AliGammaMCReader.h"
42#include "Riostream.h"
43#include "AliLog.h"
44
45ClassImp(AliGammaMCReader)
46
47//____________________________________________________________________________
48AliGammaMCReader::AliGammaMCReader() :
4b707925 49 AliGammaReader(), fDecayPi0(0), fCheckOverlapping(kFALSE)
bdcfac30 50{
51 //Ctor
52
53 //Initialize parameters
bdcfac30 54 InitParameters();
4b707925 55 fDataType = kMC;
bdcfac30 56
57}
58
59//____________________________________________________________________________
60AliGammaMCReader::AliGammaMCReader(const AliGammaMCReader & g) :
4b707925 61 AliGammaReader(g), fDecayPi0(g.fDecayPi0), fCheckOverlapping(g.fCheckOverlapping)
bdcfac30 62{
63 // cpy ctor
64}
65
66//_________________________________________________________________________
67AliGammaMCReader & AliGammaMCReader::operator = (const AliGammaMCReader & source)
68{
69 // assignment operator
70
71 if(&source == this) return *this;
72
4b707925 73 fDecayPi0 = source.fDecayPi0;
74 fCheckOverlapping = source.fCheckOverlapping;
bdcfac30 75
76 return *this;
77
78}
79
4b707925 80//___________________________________________________________________________
81void AliGammaMCReader::CaseDecayGamma(Int_t index, TParticle * particle, AliStack * sta,
82 TClonesArray * plEMCAL, Int_t &indexEMCAL,
83 TClonesArray * plPHOS, Int_t &indexPHOS){
84 //In case pi0 are decayed by pythia, check if mother is pi0 and in such case look if
85 //there is overlapping. Send particle=pi0 if there is overlapping.
86
87 TParticle * pmother =sta->Particle(particle->GetFirstMother());
88 if(pmother->GetPdgCode() == 111 && pmother->GetNDaughters() == 2) {//Do not consider 3 particle decay case
89 Int_t idaug0 = pmother->GetDaughter(0);
90 Int_t idaug1 = pmother->GetDaughter(1);
91 TParticle * pdaug0 = sta -> Particle(idaug0);
92 TParticle * pdaug1 = sta -> Particle(idaug1);
93
94 if((index == idaug0 && pdaug0->Pt() > fNeutralPtCut) ||
95 (index == idaug1 && pdaug0->Pt() <= fNeutralPtCut))//Check decay when first daughter arrives, do nothing with second.
96 FillListWithDecayGammaOrPi0(pmother, pdaug0, pdaug1, plEMCAL, indexEMCAL, plPHOS, indexPHOS);
97
98 }//mother is a pi0 with 2 daughters
99 else{
100 if(IsInPHOS(particle->Phi(),particle->Eta()))
101 new((*plPHOS)[indexPHOS++]) TParticle(*particle) ;
102 else if(IsInEMCAL(particle->Phi(),particle->Eta()))
103 new((*plEMCAL)[indexEMCAL++]) TParticle(*particle) ;
104 }
105
106}
107
108//___________________________________________________________________________
109 void AliGammaMCReader::CaseGeantDecay(TParticle * particle, AliStack * stack,
110 TClonesArray * plEMCAL, Int_t &indexEMCAL,
111 TClonesArray * plPHOS, Int_t &indexPHOS){
112 //Find decay gamma from pi0, decayed by GEANT and put them in the list.
113
114 Int_t ndaug = particle->GetNDaughters() ;
115 TParticle * d1 = new TParticle();
116 TParticle * d2 = new TParticle();
117
118 if(ndaug > 0){//At least 1 daugther
119 d1 = stack->Particle(particle->GetDaughter(0));
120 if (ndaug > 1 )
121 d2 = stack->Particle(particle->GetDaughter(1));
122
123 FillListWithDecayGammaOrPi0(particle, d1, d2, plEMCAL, indexEMCAL, plPHOS, indexPHOS);
124
125 }// ndaugh > 0
126 }
127
128//___________________________________________________________________________
129void AliGammaMCReader::CasePi0Decay(TParticle * pPi0,
130 TClonesArray * plEMCAL, Int_t &indexEMCAL,
131 TClonesArray * plPHOS, Int_t &indexPHOS){
132
133 //Decays pi0, see if aperture angle is small and then add the pi0 or the 2 gamma
134
135 TLorentzVector lvPi0, lvGamma1, lvGamma2 ;
136 //Double_t angle = 0;
137
138 lvPi0.SetPxPyPzE(pPi0->Px(),pPi0->Py(),pPi0->Pz(),pPi0->Energy());
139
140 //Decay
141 MakePi0Decay(lvPi0,lvGamma1,lvGamma2);//,angle);
142
143 //Check if Pi0 is in the acceptance of the calorimeters, if aperture angle is small, keep it
144 TParticle * pPhoton1 = new TParticle(22,1,0,0,0,0,lvGamma1.Px(),lvGamma1.Py(),
145 lvGamma1.Pz(),lvGamma1.E(),0,0,0,0);
146 TParticle * pPhoton2 = new TParticle(22,1,0,0,0,0,lvGamma2.Px(),lvGamma2.Py(),
147 lvGamma2.Pz(),lvGamma2.E(),0,0,0,0);
148
149 FillListWithDecayGammaOrPi0(pPi0, pPhoton1, pPhoton2, plEMCAL, indexEMCAL, plPHOS, indexPHOS);
150
151}
152
153//_______________________________________________________________
154void AliGammaMCReader::InitParameters()
155{
156
157 //Initialize the parameters of the analysis.
158
159 fDecayPi0 = kGeantDecay;
160 fCheckOverlapping = kTRUE ;
161}
bdcfac30 162
163//____________________________________________________________________________
164void AliGammaMCReader::CreateParticleList(TObject * data, TObject *,
4b707925 165 TClonesArray * plCh,
166 TClonesArray * plEMCAL,
bdcfac30 167 TClonesArray * plPHOS,
4b707925 168 TClonesArray *plParton,TClonesArray *,TClonesArray *)
bdcfac30 169{
170 //Create list of particles from EMCAL, PHOS and CTS.
171 AliStack * stack = (AliStack *) data ;
172 Int_t indexCh = plCh->GetEntries() ;
173 Int_t indexEMCAL = plEMCAL->GetEntries() ;
174 Int_t indexPHOS = plPHOS->GetEntries() ;
175 Int_t indexParton = plParton->GetEntries() ;
176 Int_t iParticle = 0 ;
177 Double_t charge = 0.;
178
179 for (iParticle=0 ; iParticle < stack->GetNprimary() ; iParticle++) {
180 TParticle * particle = stack->Particle(iParticle);
181
4b707925 182
bdcfac30 183 //Keep partons
184 if(particle->GetStatusCode() == 21 && iParticle>=2){//All partons, not nucleus
185 new((*plParton)[indexParton++]) TParticle(*particle) ;
186 }
187
188 //Keep Stable particles
4b707925 189 if((particle->GetStatusCode() == 1) && (particle->Pt() > 0)){
bdcfac30 190
191 charge = TDatabasePDG::Instance()->GetParticle(particle->GetPdgCode())->Charge();
192
193 //---------- Charged particles ----------------------
194 if((charge != 0) && (particle->Pt() > fChargedPtCut)){
195 //Particles in CTS acceptance
196 if(TMath::Abs(particle->Eta())<fCTSEtaCut){
197 //Fill lists
198 new((*plCh)[indexCh++]) TParticle(*particle) ;
199 }
200 }
201 //-------------Neutral particles ----------------------
202 else if((charge == 0) && particle->Pt() > fNeutralPtCut &&
203 TMath::Abs(particle->GetPdgCode())>16){//Avoid neutrinos
204
205 if(particle->GetPdgCode()!=111){
4b707925 206 //In case that we force PYTHIA to decay pi0, and we want to check the overlapping of
207 // the decay gamma.
208 if(particle->GetPdgCode() == 22 && fDecayPi0==kDecayGamma){
209 CaseDecayGamma(iParticle,particle, stack,plEMCAL, indexEMCAL, plPHOS, indexPHOS); //If pythia decays pi0
210 }
211 else{
212 if(IsInPHOS(particle->Phi(),particle->Eta()))
213 new((*plPHOS)[indexPHOS++]) TParticle(*particle) ;
214 else if(IsInEMCAL(particle->Phi(),particle->Eta()))
215 new((*plEMCAL)[indexEMCAL++]) TParticle(*particle) ;
216 }
bdcfac30 217 }//no pi0
218 else{
219 if(fDecayPi0 == kNoDecay){//keep the pi0 do not decay
220 if(IsInPHOS(particle->Phi(),particle->Eta()))
221 new((*plPHOS)[indexPHOS++]) TParticle(*particle) ;
222 else if(IsInEMCAL(particle->Phi(),particle->Eta()))
223 new((*plEMCAL)[indexEMCAL++]) TParticle(*particle) ;
224 }
225 else if(fDecayPi0 == kDecay)
4b707925 226 CasePi0Decay(particle,plEMCAL,indexEMCAL,plPHOS, indexPHOS);
bdcfac30 227 else if(fDecayPi0 == kGeantDecay)
4b707925 228 CaseGeantDecay(particle, stack,plEMCAL, indexEMCAL, plPHOS, indexPHOS);
bdcfac30 229 }//pi0
230 }//neutral particle
231 }//stable particle
232 }//particle loop
233}
234
4b707925 235
236//___________________________________________________________________________
237void AliGammaMCReader::FillListWithDecayGammaOrPi0(TParticle * pPi0, TParticle * pdaug0, TParticle * pdaug1,
238 TClonesArray * plEMCAL, Int_t &indexEMCAL,
239 TClonesArray * plPHOS, Int_t &indexPHOS){
240
241 //Check if decay gamma overlapp in calorimeter, in such case keep the pi0, if not keep both photons.
242
243 Bool_t overlap = kFALSE ;
244 TLorentzVector lv1 , lv2 ;
245 pdaug0->Momentum(lv1);
246 pdaug1->Momentum(lv2);
247 Double_t angle = lv1.Angle(lv2.Vect());
248
249 if(fCheckOverlapping){//Check if decay products overlapp
250 if(IsInEMCAL(pPi0->Phi(), pPi0->Eta())){
251 if (angle < fEMCALMinAngle){
252 new((*plEMCAL)[indexEMCAL++]) TParticle(*pPi0) ;
253 overlap = kTRUE;
254 }
255 }
256 else if(IsInPHOS(pPi0->Phi(), pPi0->Eta())){
257 if (angle < fPHOSMinAngle){
258 new((*plPHOS)[indexPHOS++]) TParticle(*pPi0) ;
259 overlap = kTRUE;
260 }
261 }
262 }//fCheckOverlapping
263
264 //Fill with gammas if not overlapp
265 if(!overlap){
266 if(pdaug0->GetPdgCode() == 22 || TMath::Abs(pdaug0->GetPdgCode() ) == 11 ){
267 if(IsInEMCAL(pdaug0->Phi(),pdaug0->Eta()) && pdaug0->Pt() > fNeutralPtCut)
268 new((*plEMCAL)[indexEMCAL++]) TParticle(*pdaug0) ;
269 else if(IsInPHOS(pdaug0->Phi(),pdaug0->Eta()) && pdaug0->Pt() > fNeutralPtCut)
270 new((*plPHOS)[indexPHOS++]) TParticle(*pdaug0) ;
271 }
272
273 if(pdaug1->GetPdgCode() == 22 || TMath::Abs(pdaug1->GetPdgCode() ) == 11 ){
274 if(IsInEMCAL(pdaug1->Phi(),pdaug1->Eta()) && pdaug1->Pt() > fNeutralPtCut)
275 new((*plEMCAL)[indexEMCAL++]) TParticle(*pdaug1) ;
276 else if(IsInPHOS(pdaug1->Phi(),pdaug1->Eta()) && pdaug1->Pt() > fNeutralPtCut)
277 new((*plPHOS)[indexPHOS++]) TParticle(*pdaug1) ;
278 }
279 }// overlap?
280 }
281
282
283
bdcfac30 284//___________________________________________________________________________
285Bool_t AliGammaMCReader::IsInEMCAL(Double_t phi, Double_t eta){
286 //Check if particle is in EMCAL acceptance
287 if(phi<0)
288 phi+=TMath::TwoPi();
289 if( phi > fPhiEMCALCut[0] && phi < fPhiEMCALCut[1] &&
290 TMath::Abs(eta)<fEMCALEtaCut) return kTRUE ;
291 else return kFALSE;
292
293 return kFALSE ;
294}
295
296//___________________________________________________________________________
297Bool_t AliGammaMCReader::IsInPHOS(Double_t phi, Double_t eta){
298 //Check if particle is in EMCAL acceptance
299 if(phi<0)
300 phi+=TMath::TwoPi();
301 if( phi > fPhiPHOSCut[0] && phi < fPhiPHOSCut[1] &&
302 TMath::Abs(eta)<fPHOSEtaCut) return kTRUE ;
303 else return kFALSE;
304
305 return kFALSE ;
306}
307
bdcfac30 308//____________________________________________________________________________
4b707925 309void AliGammaMCReader::MakePi0Decay(TLorentzVector &p0, TLorentzVector &p1,
310 TLorentzVector &p2){//, Double_t &angle) {
bdcfac30 311 // Perform isotropic decay pi0 -> 2 photons
312 // p0 is pi0 4-momentum (inut)
313 // p1 and p2 are photon 4-momenta (output)
314 // cout<<"Boost vector"<<endl;
315 Double_t mPi0 = TDatabasePDG::Instance()->GetParticle(111)->Mass();
316 TVector3 b = p0.BoostVector();
317 //cout<<"Parameters"<<endl;
318 //Double_t mPi0 = p0.M();
319 Double_t phi = TMath::TwoPi() * gRandom->Rndm();
320 Double_t cosThe = 2 * gRandom->Rndm() - 1;
321 Double_t cosPhi = TMath::Cos(phi);
322 Double_t sinPhi = TMath::Sin(phi);
323 Double_t sinThe = TMath::Sqrt(1-cosThe*cosThe);
324 Double_t ePi0 = mPi0/2.;
325 //cout<<"ePi0 "<<ePi0<<endl;
326 //cout<<"Components"<<endl;
327 p1.SetPx(+ePi0*cosPhi*sinThe);
328 p1.SetPy(+ePi0*sinPhi*sinThe);
329 p1.SetPz(+ePi0*cosThe);
330 p1.SetE(ePi0);
331 //cout<<"p1: "<<p1.Px()<<" "<<p1.Py()<<" "<<p1.Pz()<<" "<<p1.E()<<endl;
332 //cout<<"p1 Mass: "<<p1.Px()*p1.Px()+p1.Py()*p1.Py()+p1.Pz()*p1.Pz()-p1.E()*p1.E()<<endl;
333 p2.SetPx(-ePi0*cosPhi*sinThe);
334 p2.SetPy(-ePi0*sinPhi*sinThe);
335 p2.SetPz(-ePi0*cosThe);
336 p2.SetE(ePi0);
337 //cout<<"p2: "<<p2.Px()<<" "<<p2.Py()<<" "<<p2.Pz()<<" "<<p2.E()<<endl;
338 //cout<<"p2 Mass: "<<p2.Px()*p2.Px()+p2.Py()*p2.Py()+p2.Pz()*p2.Pz()-p2.E()*p2.E()<<endl;
339 //cout<<"Boost "<<b.X()<<" "<<b.Y()<<" "<<b.Z()<<endl;
340 p1.Boost(b);
341 //cout<<"p1: "<<p1.Px()<<" "<<p1.Py()<<" "<<p1.Pz()<<" "<<p1.E()<<endl;
342 p2.Boost(b);
343 //cout<<"p2: "<<p2.Px()<<" "<<p2.Py()<<" "<<p2.Pz()<<" "<<p2.E()<<endl;
344 //cout<<"angle"<<endl;
4b707925 345 //angle = p1.Angle(p2.Vect());
bdcfac30 346 //cout<<angle<<endl;
347}
348
349//________________________________________________________________
350void AliGammaMCReader::Print(const Option_t * opt) const
351{
352
353 //Print some relevant parameters set for the analysis
354 if(! opt)
355 return;
356
357 Info("Print", "%s %s", GetName(), GetTitle() ) ;
358
bdcfac30 359 printf("Decay Pi0? : %d\n", fDecayPi0) ;
4b707925 360 printf("Check Overlapping? : %d\n", fCheckOverlapping) ;
361
bdcfac30 362}
4b707925 363
364
365
366