/[PAMELA software]/trieste/pamVMC/include/PamVMCPrimaryGenerator.h
ViewVC logotype

Contents of /trieste/pamVMC/include/PamVMCPrimaryGenerator.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Wed Mar 4 12:51:14 2009 UTC (15 years, 11 months ago) by pamelats
Branch: MAIN
Branch point for: pamVMC
File MIME type: text/plain
Initial revision

1 // $Id: PamVMCPrimaryGenerator.h,v 1.0 2007/06/03
2
3 #ifndef PAMVMC_PRIMARY_GENERATOR_H
4 #define PAMVMC_PRIMARY_GENERATOR_H
5
6 #include <iostream>
7 #include <TVirtualMCApplication.h>
8 #include <TClonesArray.h>
9 #include <TVector3.h>
10 #include <TVector2.h>
11 #include <TMath.h>
12 #include <TRandom3.h>
13
14 #include "PamRootManager.h"
15
16 class TVirtualMCStack;
17
18 using std::cout;
19 using std::endl;
20 using TMath::Sqrt;
21
22 class PamVMCPrimary : public TObject
23 {
24
25 public:
26
27 PamVMCPrimary(): fPDG(0), fX0(0.), fY0(0.), fZ0(0.), fTHETA(0.), fPHI(0.), fP0(0.), fGOOD(kFALSE) { };
28
29
30 Int_t fPDG;
31 Double_t fX0, fY0, fZ0;
32 Double_t fTHETA, fPHI;
33 Double_t fP0;
34 Bool_t fGOOD;
35
36 void Clean() { fPDG=0; fX0=fY0=fZ0=fTHETA=fPHI=fP0=0.; fGOOD=kFALSE;}
37
38 void Clear(const Option_t * =""){ Clean(); }
39
40 void Print(const Option_t * ="") const
41 { cout<<"PRIMARY particle infromation:"<<endl;
42 cout<<"Pdg="<<fPDG<<endl; //add name later
43 cout<<"Position: "<<"("<<fX0<<","<<fY0<<","<<fZ0<<")"<<endl;
44 cout<<"P0, Theta, Phi: "<<fP0<<","<<fTHETA<<","<<fPHI<<endl;
45 cout<<"GOOD Single Track:"<<fGOOD<<endl;
46 }
47
48 ClassDef(PamVMCPrimary,1);
49 };
50
51 PamVMCPrimary & operator+=(PamVMCPrimary &a, const PamVMCPrimary &b);
52
53 class PamVMCPrimaryGenerator : public TObject
54 {
55 public:
56 PamVMCPrimaryGenerator(TVirtualMCStack* stack);
57 PamVMCPrimaryGenerator();
58
59 virtual ~PamVMCPrimaryGenerator();
60
61 // methods
62
63 void GeneratePrimary();
64 // set methods
65 void SetParticle(Int_t pdg);
66 void SetPosition(Double_t vx, Double_t vy, Double_t vz)
67 {fprim.fX0=vx; fprim.fY0=vy; fprim.fZ0=vz;};
68
69 void SetKinEnergy(Double_t kinEnergy) {fprim.fP0=KinEToMomentum(kinEnergy);};
70 void SetRigidity(Double_t rigidity) {fprim.fP0=RigToMomentum(rigidity);};
71 void SetMomentum(Double_t momentum) {fprim.fP0=momentum; };
72
73 void SetDirection(Double_t theta, Double_t phi) {fprim.fTHETA=theta; fprim.fPHI=phi; };
74 void SetMomentum(Double_t px, Double_t py, Double_t pz);
75
76 void SetGood(Bool_t isgood) {fprim.fGOOD=isgood; };
77
78 // gen methods
79
80 void GenPosition(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax){
81 SetPosition(frnd->Uniform(xmin,xmax),frnd->Uniform(ymin,ymax),frnd->Uniform(zmin,zmax)); }
82 //Spherical distribution in radius, thetamin, thetamax, phimin, phimax.
83 void GenSphDist(Double_t, Double_t, Double_t, Double_t, Double_t);
84
85 void GenDirection(Double_t thetamin, Double_t thetamax, Double_t phimin, Double_t phimax){
86 SetDirection(frnd->Uniform(thetamin,thetamax),frnd->Uniform(phimin,phimax)); }
87
88 //flat spectra generator
89 void GenSpe(Double_t PEmin, Double_t PEmax, Bool_t isEnergy=kFALSE);
90 //power law spectra, gamma - differential spectral index
91 void GenSpe(Double_t PEmin, Double_t PEmax, Double_t gamma, Bool_t isEnergy=kFALSE);
92
93 //spherical dist. from radius r, allow only those particles going to cross 3 TOFs
94 void GenSphDist(Double_t);
95
96 // get methods
97 Int_t GetParticle(){ return fprim.fPDG; };
98 void GetPositon(TVector3 & v){ v.SetXYZ(fprim.fX0,fprim.fY0,fprim.fZ0); };
99 void GetPosition(Double_t X0, Double_t Y0,Double_t Z0)
100 {X0=fprim.fX0; Y0=fprim.fY0; Z0=fprim.fZ0;};
101
102 Double_t GetKinEnergy() { return MomentumToKinE(fprim.fP0); };
103 Double_t GetRigidity() { return MomentumToRig(fprim.fP0); };
104 Double_t GetMomentum() { return fprim.fP0; };
105
106 void GetDirection(TVector2 & v) {v.Set(fprim.fTHETA,fprim.fPHI);}
107
108 Bool_t Getgood(){ return fprim.fGOOD; };
109
110 //work with collection of primaries
111
112 void Register(){
113 PamRootManager::Instance()->
114 Register("PRIM","TClonesArray", &fprimColl);
115 }
116
117 void ClearPrimCol(){
118 fevno=0;
119 (*fprimColl).Clear();
120 }
121
122 void Print(const Option_t * ="") const {fprim.Print();};
123
124 private:
125 // methods
126
127 Double_t MomentumToKinE(Double_t P0);
128 Double_t KinEToMomentum(Double_t E0);
129 Double_t MomentumToRig(Double_t P0) { return P0/fcharge; };
130 Double_t RigToMomentum(Double_t R0){ return R0*fcharge; };
131
132 // data members
133 TVirtualMCStack* fStack;
134 Int_t fevno;
135 PamVMCPrimary fprim;
136 Double_t fmass;
137 Double_t fcharge;
138 TClonesArray* fprimColl;
139
140 TRandom3 * frnd;
141
142 ClassDef(PamVMCPrimaryGenerator,1) //PamVMCPrimaryGenerator
143 };
144
145 // inline functions
146
147
148 inline Double_t PamVMCPrimaryGenerator::MomentumToKinE(Double_t P0)
149 { return Sqrt(P0*P0+fmass*fmass)-fmass; }
150
151 inline Double_t PamVMCPrimaryGenerator::KinEToMomentum(Double_t E0)
152 { return Sqrt(E0*E0+2.*E0*fmass); }
153
154 #endif //PAMVMC_PRIMARY_GENERATOR_H
155

  ViewVC Help
Powered by ViewVC 1.1.23