/[PAMELA software]/PamVMC/include/PamVMCPrimaryGenerator.h
ViewVC logotype

Contents of /PamVMC/include/PamVMCPrimaryGenerator.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Thu Feb 19 16:50:36 2009 UTC (15 years, 10 months ago) by nikolas
Branch: MAIN
File MIME type: text/plain
Cleaning before committing

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
83 void GenDirection(Double_t thetamin, Double_t thetamax, Double_t phimin, Double_t phimax){
84 SetDirection(frnd->Uniform(thetamin,thetamax),frnd->Uniform(phimin,phimax)); }
85
86 //flat spectra generator
87 void GenSpe(Double_t PEmin, Double_t PEmax, Bool_t isEnergy=kFALSE);
88 //power law spectra, gamma - differential spectral index
89 void GenSpe(Double_t PEmin, Double_t PEmax, Double_t gamma, Bool_t isEnergy=kFALSE);
90
91 // get methods
92 Int_t GetParticle(){ return fprim.fPDG; };
93 void GetPositon(TVector3 & v){ v.SetXYZ(fprim.fX0,fprim.fY0,fprim.fZ0); };
94 void GetPosition(Double_t X0, Double_t Y0,Double_t Z0)
95 {X0=fprim.fX0; Y0=fprim.fY0; Z0=fprim.fZ0;};
96
97 Double_t GetKinEnergy() { return MomentumToKinE(fprim.fP0); };
98 Double_t GetRigidity() { return MomentumToRig(fprim.fP0); };
99 Double_t GetMomentum() { return fprim.fP0; };
100
101 void GetDirection(TVector2 & v) {v.Set(fprim.fTHETA,fprim.fPHI);}
102
103 Bool_t Getgood(){ return fprim.fGOOD; };
104
105 //work with collection of primaries
106
107 void Register(){
108 PamRootManager::Instance()->
109 Register("PRIM","TClonesArray", &fprimColl);
110 }
111
112 void ClearPrimCol(){
113 fevno=0;
114 (*fprimColl).Clear();
115 }
116
117 private:
118 // methods
119
120 Double_t MomentumToKinE(Double_t P0);
121 Double_t KinEToMomentum(Double_t E0);
122 Double_t MomentumToRig(Double_t P0) { return P0/fcharge; };
123 Double_t RigToMomentum(Double_t R0){ return R0*fcharge; };
124
125 // data members
126 TVirtualMCStack* fStack;
127 Int_t fevno;
128 PamVMCPrimary fprim;
129 Double_t fmass;
130 Double_t fcharge;
131 TClonesArray* fprimColl;
132
133 TRandom3 * frnd;
134
135 ClassDef(PamVMCPrimaryGenerator,1) //PamVMCPrimaryGenerator
136 };
137
138 // inline functions
139
140
141 inline Double_t PamVMCPrimaryGenerator::MomentumToKinE(Double_t P0)
142 { return Sqrt(P0*P0+fmass*fmass)-fmass; }
143
144 inline Double_t PamVMCPrimaryGenerator::KinEToMomentum(Double_t E0)
145 { return Sqrt(E0*E0+2.*E0*fmass); }
146
147 #endif //PAMVMC_PRIMARY_GENERATOR_H
148

  ViewVC Help
Powered by ViewVC 1.1.23