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

Annotation of /PamVMC/include/PamVMCPrimaryGenerator.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Wed Sep 15 07:05:42 2010 UTC (14 years, 3 months ago) by pizzolot
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +8 -0 lines
File MIME type: text/plain
new particle generation methods

1 nikolas 1.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 pam-rm2 1.5 #include <TRandom.h>
13     #include <TF1.h>
14 nikolas 1.1
15     #include "PamRootManager.h"
16    
17     class TVirtualMCStack;
18    
19     using std::cout;
20     using std::endl;
21     using TMath::Sqrt;
22    
23     class PamVMCPrimary : public TObject
24     {
25    
26     public:
27    
28     PamVMCPrimary(): fPDG(0), fX0(0.), fY0(0.), fZ0(0.), fTHETA(0.), fPHI(0.), fP0(0.), fGOOD(kFALSE) { };
29    
30    
31     Int_t fPDG;
32     Double_t fX0, fY0, fZ0;
33     Double_t fTHETA, fPHI;
34     Double_t fP0;
35     Bool_t fGOOD;
36    
37     void Clean() { fPDG=0; fX0=fY0=fZ0=fTHETA=fPHI=fP0=0.; fGOOD=kFALSE;}
38    
39     void Clear(const Option_t * =""){ Clean(); }
40    
41     void Print(const Option_t * ="") const
42     { cout<<"PRIMARY particle infromation:"<<endl;
43     cout<<"Pdg="<<fPDG<<endl; //add name later
44     cout<<"Position: "<<"("<<fX0<<","<<fY0<<","<<fZ0<<")"<<endl;
45     cout<<"P0, Theta, Phi: "<<fP0<<","<<fTHETA<<","<<fPHI<<endl;
46     cout<<"GOOD Single Track:"<<fGOOD<<endl;
47     }
48    
49     ClassDef(PamVMCPrimary,1);
50     };
51    
52     PamVMCPrimary & operator+=(PamVMCPrimary &a, const PamVMCPrimary &b);
53    
54     class PamVMCPrimaryGenerator : public TObject
55     {
56     public:
57     PamVMCPrimaryGenerator(TVirtualMCStack* stack);
58     PamVMCPrimaryGenerator();
59    
60     virtual ~PamVMCPrimaryGenerator();
61    
62     // methods
63    
64     void GeneratePrimary();
65     // set methods
66     void SetParticle(Int_t pdg);
67     void SetPosition(Double_t vx, Double_t vy, Double_t vz)
68     {fprim.fX0=vx; fprim.fY0=vy; fprim.fZ0=vz;};
69    
70     void SetKinEnergy(Double_t kinEnergy) {fprim.fP0=KinEToMomentum(kinEnergy);};
71     void SetRigidity(Double_t rigidity) {fprim.fP0=RigToMomentum(rigidity);};
72     void SetMomentum(Double_t momentum) {fprim.fP0=momentum; };
73    
74     void SetDirection(Double_t theta, Double_t phi) {fprim.fTHETA=theta; fprim.fPHI=phi; };
75     void SetMomentum(Double_t px, Double_t py, Double_t pz);
76    
77     void SetGood(Bool_t isgood) {fprim.fGOOD=isgood; };
78    
79     // gen methods
80    
81     void GenPosition(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax){
82 pam-rm2 1.5 SetPosition(frandom->Uniform(xmin,xmax),frandom->Uniform(ymin,ymax),frandom->Uniform(zmin,zmax)); }
83    
84 nikolas 1.1 void GenDirection(Double_t thetamin, Double_t thetamax, Double_t phimin, Double_t phimax){
85 pam-rm2 1.5 SetDirection(ftheta->GetRandom(thetamin, thetamax), frandom->Uniform(phimin,phimax));
86     }
87 nikolas 1.1 //flat spectra generator
88     void GenSpe(Double_t PEmin, Double_t PEmax, Bool_t isEnergy=kFALSE);
89     //power law spectra, gamma - differential spectral index
90     void GenSpe(Double_t PEmin, Double_t PEmax, Double_t gamma, Bool_t isEnergy=kFALSE);
91 pizzolot 1.6 void GenSpe_Flat(Double_t PEmin, Double_t PEmax, Double_t gamma, Bool_t isEnergy=kFALSE);
92     void GenSpe_3par(Double_t PEmin, Double_t PEmax, Double_t a, Double_t b, Double_t c);
93     void GenSphericalPhiThe(); // cecilia // flusso istropo // sets phi the
94     void GenSphPhiThe(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax,
95     Double_t zmin, Double_t zmax); // flusso isotropo entro S2 S3
96     // sets position and phi the
97    
98 nikolas 1.1
99     // get methods
100     Int_t GetParticle(){ return fprim.fPDG; };
101     void GetPositon(TVector3 & v){ v.SetXYZ(fprim.fX0,fprim.fY0,fprim.fZ0); };
102     void GetPosition(Double_t X0, Double_t Y0,Double_t Z0)
103     {X0=fprim.fX0; Y0=fprim.fY0; Z0=fprim.fZ0;};
104    
105     Double_t GetKinEnergy() { return MomentumToKinE(fprim.fP0); };
106     Double_t GetRigidity() { return MomentumToRig(fprim.fP0); };
107     Double_t GetMomentum() { return fprim.fP0; };
108    
109     void GetDirection(TVector2 & v) {v.Set(fprim.fTHETA,fprim.fPHI);}
110    
111     Bool_t Getgood(){ return fprim.fGOOD; };
112    
113 pam-rm2 1.5 //initialize random
114     void SetRandom(TRandom* random){
115     frandom = random;
116     }
117    
118 nikolas 1.1 //work with collection of primaries
119    
120     void Register(){
121     PamRootManager::Instance()->
122     Register("PRIM","TClonesArray", &fprimColl);
123     }
124    
125     void ClearPrimCol(){
126     fevno=0;
127     (*fprimColl).Clear();
128     }
129    
130     private:
131     // methods
132    
133     Double_t MomentumToKinE(Double_t P0);
134     Double_t KinEToMomentum(Double_t E0);
135     Double_t MomentumToRig(Double_t P0) { return P0/fcharge; };
136     Double_t RigToMomentum(Double_t R0){ return R0*fcharge; };
137 pizzolot 1.6 Double_t function3par(Double_t xx, Double_t a, Double_t b, Double_t c){return 5.*pow((xx + b * exp(-c * sqrt(xx))),-a);};
138 nikolas 1.1
139     // data members
140     TVirtualMCStack* fStack;
141     Int_t fevno;
142     PamVMCPrimary fprim;
143     Double_t fmass;
144     Double_t fcharge;
145     TClonesArray* fprimColl;
146 pam-rm2 1.5 TRandom* frandom; // Class is not a owner of this object
147     TF1* ftheta; // To generate sherical distributhin in theta-angle
148 nikolas 1.1
149     ClassDef(PamVMCPrimaryGenerator,1) //PamVMCPrimaryGenerator
150     };
151    
152     // inline functions
153    
154    
155     inline Double_t PamVMCPrimaryGenerator::MomentumToKinE(Double_t P0)
156     { return Sqrt(P0*P0+fmass*fmass)-fmass; }
157    
158     inline Double_t PamVMCPrimaryGenerator::KinEToMomentum(Double_t E0)
159     { return Sqrt(E0*E0+2.*E0*fmass); }
160    
161     #endif //PAMVMC_PRIMARY_GENERATOR_H
162    

  ViewVC Help
Powered by ViewVC 1.1.23