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

Annotation of /PamVMC/include/PamVMCPrimaryGenerator.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Fri Jun 12 18:39:19 2009 UTC (15 years, 6 months ago) by pam-rm2
Branch: MAIN
CVS Tags: v1r0
Changes since 1.1: +13 -7 lines
File MIME type: text/plain
- Introduced user-defined names of output files and random seeds number.
Users can do it use options of PamVMCApplication constructor:
PamVMCApplication(const char* name,  const char *title, const char*
filename="pamtest", Int_t seed=0).
The Random object that I use is TRandom3 object which has astronomical
large period (in case of default initialization 0). All random generators
in the code use this object by calling of gRandom singleton which keeps
it.

- Corrected TOF digitization routine. No problems with TDC hits due to
hadronic interactions anymore.

- Some small changes was done to compile code under Root 5.23. +
geant4_vmc v. 2.6 without any warnings

- Some classes of PamG4RunConfiguartion was changed for geant4_vmc v.
2.6.Some obsolete classes was deleted as soon as developers implemented
regions.

- Navigation was changed from "geomRootToGeant4" to "geomRoot", because on
VMC web page written that as soon as Geant4 has no option ONLY/MANY
translation of overlapped geometry to Geant4 through VGM could be wrong.
I'd like to stay with Root navigation:
http://root.cern.ch/root/vmc/Geant4VMC.html. This should be default
option.

- New Tracker digitization routine written by Sergio was implemented

- PamVMC again became compatible with geant4_vmc v.2.5 and ROOT 5.20.
 The problem was that ROOT developers introduced in TVirtualMC class a new
method SetMagField and new base class:TVirtualMagField from which
user-defined classes shoukd be derived

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    
92     // get methods
93     Int_t GetParticle(){ return fprim.fPDG; };
94     void GetPositon(TVector3 & v){ v.SetXYZ(fprim.fX0,fprim.fY0,fprim.fZ0); };
95     void GetPosition(Double_t X0, Double_t Y0,Double_t Z0)
96     {X0=fprim.fX0; Y0=fprim.fY0; Z0=fprim.fZ0;};
97    
98     Double_t GetKinEnergy() { return MomentumToKinE(fprim.fP0); };
99     Double_t GetRigidity() { return MomentumToRig(fprim.fP0); };
100     Double_t GetMomentum() { return fprim.fP0; };
101    
102     void GetDirection(TVector2 & v) {v.Set(fprim.fTHETA,fprim.fPHI);}
103    
104     Bool_t Getgood(){ return fprim.fGOOD; };
105    
106 pam-rm2 1.5 //initialize random
107     void SetRandom(TRandom* random){
108     frandom = random;
109     }
110    
111 nikolas 1.1 //work with collection of primaries
112    
113     void Register(){
114     PamRootManager::Instance()->
115     Register("PRIM","TClonesArray", &fprimColl);
116     }
117    
118     void ClearPrimCol(){
119     fevno=0;
120     (*fprimColl).Clear();
121     }
122    
123     private:
124     // methods
125    
126     Double_t MomentumToKinE(Double_t P0);
127     Double_t KinEToMomentum(Double_t E0);
128     Double_t MomentumToRig(Double_t P0) { return P0/fcharge; };
129     Double_t RigToMomentum(Double_t R0){ return R0*fcharge; };
130    
131     // data members
132     TVirtualMCStack* fStack;
133     Int_t fevno;
134     PamVMCPrimary fprim;
135     Double_t fmass;
136     Double_t fcharge;
137     TClonesArray* fprimColl;
138 pam-rm2 1.5 TRandom* frandom; // Class is not a owner of this object
139     TF1* ftheta; // To generate sherical distributhin in theta-angle
140 nikolas 1.1
141     ClassDef(PamVMCPrimaryGenerator,1) //PamVMCPrimaryGenerator
142     };
143    
144     // inline functions
145    
146    
147     inline Double_t PamVMCPrimaryGenerator::MomentumToKinE(Double_t P0)
148     { return Sqrt(P0*P0+fmass*fmass)-fmass; }
149    
150     inline Double_t PamVMCPrimaryGenerator::KinEToMomentum(Double_t E0)
151     { return Sqrt(E0*E0+2.*E0*fmass); }
152    
153     #endif //PAMVMC_PRIMARY_GENERATOR_H
154    

  ViewVC Help
Powered by ViewVC 1.1.23