]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVGEN/AliGenMC.cxx
Can compile with or without aliroot.
[u/mrichter/AliRoot.git] / EVGEN / AliGenMC.cxx
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     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.4  2001/11/27 13:13:07  morsch
19 Maximum lifetime for long-lived particles to be put on the stack is parameter.
20 It can be set via SetMaximumLifetime(..).
21
22 Revision 1.3  2001/10/16 08:48:56  morsch
23 Common vertex related code moved to base class AliGenerator.
24
25 Revision 1.2  2001/10/15 08:15:51  morsch
26 Event vertex and vertex truncation setting moved into AliMC.
27
28 Revision 1.1  2001/07/13 10:56:00  morsch
29 AliGenMC base class for AliGenParam and AliGenPythia commonalities.
30
31 */
32
33 #include "AliGenMC.h"
34 #include "AliPDG.h"
35 #include <TParticle.h>
36
37  ClassImp(AliGenMC)
38
39 AliGenMC::AliGenMC()
40                  :AliGenerator()
41 {
42 // Default Constructor
43     SetCutOnChild();
44     SetChildMomentumRange();
45     SetChildPtRange();
46     SetChildPhiRange();
47     SetChildThetaRange(); 
48     SetChildYRange(); 
49     SetMaximumLifetime();
50 }
51
52 AliGenMC::AliGenMC(Int_t npart)
53                  :AliGenerator(npart)
54 {
55 //  Constructor
56     SetCutOnChild();
57     SetChildMomentumRange();
58     SetChildPtRange();
59     SetChildPhiRange();
60     SetChildThetaRange();
61     SetChildYRange(); 
62 // 
63     fParentSelect.Set(8);
64     fChildSelect.Set(8);
65     for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
66     SetMaximumLifetime();
67 }
68
69 AliGenMC::AliGenMC(const AliGenMC & mc)
70 {
71 // copy constructor
72 }
73
74 AliGenMC::~AliGenMC()
75 {
76 // Destructor
77 }
78
79 void AliGenMC::Init()
80 {
81 //
82 //  Initialization
83     switch (fForceDecay) {
84     case kSemiElectronic:
85     case kDiElectron:
86     case kBJpsiDiElectron:
87     case kBPsiPrimeDiElectron:
88         fChildSelect[0] = kElectron;    
89         break;
90     case kSemiMuonic:
91     case kDiMuon:
92     case kBJpsiDiMuon:
93     case kBPsiPrimeDiMuon:
94     case kPiToMu:
95     case kKaToMu:
96         fChildSelect[0]=kMuonMinus;
97         break;
98     case kHadronicD:
99         fChildSelect[0]=kPiPlus;
100         fChildSelect[1]=kKPlus;
101         break;
102     case kAll:
103     case kNoDecay:
104         break;
105     }
106 }
107
108
109 Bool_t AliGenMC::ParentSelected(Int_t ip)
110 {
111 // True if particle is in list of parent particles to be selected
112     for (Int_t i=0; i<8; i++)
113     {
114         if (fParentSelect[i]==ip) return kTRUE;
115     }
116     return kFALSE;
117 }
118
119 Bool_t AliGenMC::ChildSelected(Int_t ip)
120 {
121 // True if particle is in list of decay products to be selected
122     for (Int_t i=0; i<5; i++)
123     {
124         if (fChildSelect[i]==ip) return kTRUE;
125     }
126     return kFALSE;
127 }
128
129 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag)
130 {
131 // Perform kinematic selection
132     Float_t px    = particle->Px();
133     Float_t py    = particle->Py();
134     Float_t pz    = particle->Pz();
135     Float_t  e    = particle->Energy();
136     Float_t pt    = particle->Pt();
137     Float_t p     = particle->P();
138     Float_t theta = particle->Theta();
139     Float_t mass  = particle->GetMass();
140     Float_t mt2   = pt * pt + mass * mass;
141     
142     Float_t phi   = Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
143     Double_t y, y0;
144
145     if (TMath::Abs(pz) != e) {
146         y = 0.5*TMath::Log((e+pz)/(e-pz));
147     } else {
148         y = 1.e10;
149     }
150     
151     if (mt2) {
152         y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
153     } else {
154         if (TMath::Abs(y) < 1.e10) {
155             y0 = y;
156         } else {
157             y0 = 1.e10;
158         }
159     }
160       
161     y = (pz < 0) ? -y0 : y0;
162     
163     if (flag == 0) {
164 //
165 // Primary particle cuts
166 //
167 //  transverse momentum cut    
168         if (pt > fPtMax || pt < fPtMin) {
169 //          printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
170             return kFALSE;
171         }
172 //
173 // momentum cut
174         if (p > fPMax || p < fPMin) {
175 //          printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
176             return kFALSE;
177         }
178 //
179 // theta cut
180         if (theta > fThetaMax || theta < fThetaMin) {
181 //          printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
182             return kFALSE;
183         }
184 //
185 // rapidity cut
186         if (y > fYMax || y < fYMin) {
187 //          printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
188             return kFALSE;
189         }
190 //
191 // phi cut
192         if (phi > fPhiMax || phi < fPhiMin) {
193 //          printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
194             return kFALSE;
195         }
196     } else {
197 //
198 // Decay product cuts
199 //
200 //  transverse momentum cut    
201         if (pt > fChildPtMax || pt < fChildPtMin) {
202 //          printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
203             return kFALSE;
204         }
205 //
206 // momentum cut
207         if (p > fChildPMax || p < fChildPMin) {
208 //          printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
209             return kFALSE;
210         }
211 //
212 // theta cut
213         if (theta > fChildThetaMax || theta < fChildThetaMin) {
214 //          printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
215             return kFALSE;
216         }
217 //
218 // rapidity cut
219         if (y > fChildYMax || y < fChildYMin) {
220 //          printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
221             return kFALSE;
222         }
223 //
224 // phi cut
225         if (phi > fChildPhiMax || phi < fChildPhiMin) {
226 //          printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
227             return kFALSE;
228         }
229     }
230     
231     
232
233     return kTRUE;
234 }
235
236 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode)
237 {
238 //
239 //  If the particle is in a diffractive state, then take action accordingly
240   switch (pdgcode) {
241   case 91:
242     return 92;
243   case 110:
244     //rho_diff0 -- difficult to translate, return rho0
245     return 113;
246   case 210:
247     //pi_diffr+ -- change to pi+
248     return 211;
249   case 220:
250     //omega_di0 -- change to omega0
251     return 223;
252   case 330:
253     //phi_diff0 -- return phi0
254     return 333;
255   case 440:
256     //J/psi_di0 -- return J/psi
257     return 443;
258   case 2110:
259     //n_diffr -- return neutron
260     return 2112;
261   case 2210:
262     //p_diffr+ -- return proton
263     return 2212;
264   }
265   //non diffractive state -- return code unchanged
266   return pdgcode;
267 }
268           
269 AliGenMC& AliGenMC::operator=(const  AliGenMC& rhs)
270 {
271 // Assignment operator
272     return *this;
273 }
274