/[PAMELA software]/PamVMC_update/include/PamVMCPrimaryGenerator.h_backup_120619_vformato
ViewVC logotype

Annotation of /PamVMC_update/include/PamVMCPrimaryGenerator.h_backup_120619_vformato

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Tue Oct 15 15:52:31 2013 UTC (11 years, 4 months ago) by formato
Branch: MAIN, rel
CVS Tags: reltag, HEAD
Changes since 1.1: +0 -0 lines
PamVMC update

1 formato 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     #include <TRandom.h>
13     #include <TF1.h>
14     //#include <TObjectTable.h>
15    
16     #include "PamRootManager.h"
17     #include "PamVMC2PiAux.h"
18     #include "PamVMCPrimaryGF.h"
19    
20     class TVirtualMCStack;
21    
22     using std::cout;
23     using std::endl;
24     using TMath::Sqrt;
25    
26     class PamVMCPrimary : public TObject
27     {
28    
29     public:
30    
31     PamVMCPrimary(): fID(0), fPDG(0), fX0(0.), fY0(0.), fZ0(0.), fTHETA(0.), fPHI(0.), fP0(0.), fGOOD(kFALSE), fXTOL(-100.), fYTOL(-100.){
32    
33    
34     for (Int_t j = 0; j<14; j++){
35     fCR_X[j] = -100.;
36     fCR_Y[j] = -100.;
37     }
38     };
39    
40     virtual ~PamVMCPrimary(){ /*gObjectTable->Remove(this);*/};
41    
42     UInt_t fID;
43     Int_t fPDG;
44     Double_t fX0, fY0, fZ0;
45     Double_t fTHETA, fPHI;
46     Double_t fP0;
47     Bool_t fGOOD;
48     Double_t fXTOL, fYTOL;
49     Double_t fCR_X [14];
50     Double_t fCR_Y [14];
51    
52    
53     void Clean() { fID=0; fPDG=0; fX0=fY0=fZ0=fTHETA=fPHI=fP0=0.; fGOOD=kFALSE; fXTOL=fYTOL=-100.;
54     for (Int_t j = 0; j<14; j++){
55     fCR_X[j] = -100.;
56     fCR_Y[j] = -100.;
57     }
58    
59     }
60    
61     void Clear(const Option_t * =""){ this->~PamVMCPrimary(); }
62    
63     void Print(const Option_t * ="") const
64     { cout<<"PRIMARY particle "<<fID<<" infromation:"<<endl;
65     cout<<"Pdg="<<fPDG<<endl;
66     cout<<"Position: "<<"("<<fX0<<","<<fY0<<","<<fZ0<<")"<<endl;
67     cout<<"P0, Theta, Phi: "<<fP0<<","<<fTHETA<<","<<fPHI<<endl;
68     cout<<"GOOD Single Track:"<<fGOOD<<endl;
69     cout<<"Xtol= "<<fXTOL<<" Ytol= "<<fYTOL<<endl;
70     cout<<" Coordinates of acceptance planes crossing:"<<endl;
71     for(Int_t i = 0; i< 14; i++){
72     cout<<"i="<<i<<" X="<<fCR_X[i]<<" Y="<<fCR_Y[i]<<endl;
73     }
74     }
75    
76     ClassDef(PamVMCPrimary,1);
77     };
78    
79     PamVMCPrimary & operator+=(PamVMCPrimary &a, const PamVMCPrimary &b);
80    
81     class PamVMCPrimaryGenerator : public TObject
82     {
83     public:
84     PamVMCPrimaryGenerator(TVirtualMCStack* stack);
85     PamVMCPrimaryGenerator();
86    
87     virtual ~PamVMCPrimaryGenerator();
88    
89     // methods
90    
91     void GeneratePrimary();
92     // set methods
93     void SetParticle(Int_t pdg);
94     void SetParticleID(UInt_t id){ fprim.fID = id; };
95     void SetPosition(Double_t vx, Double_t vy, Double_t vz)
96     {fprim.fX0=vx; fprim.fY0=vy; fprim.fZ0=vz;};
97    
98     void SetKinEnergy(Double_t kinEnergy) {fprim.fP0=KinEToMomentum(kinEnergy);};
99     void SetRigidity(Double_t rigidity) {fprim.fP0=RigToMomentum(rigidity);};
100     void SetMomentum(Double_t momentum) {fprim.fP0=momentum; };
101    
102     void SetDirection(Double_t theta, Double_t phi) {fprim.fTHETA=theta; fprim.fPHI=phi; };
103     void SetMomentum(Double_t px, Double_t py, Double_t pz);
104    
105    
106     // gen methods
107    
108     void GenPosition(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax){
109     SetPosition(frandom->Uniform(xmin,xmax),frandom->Uniform(ymin,ymax),frandom->Uniform(zmin,zmax)); }
110    
111     void GenDirection(Double_t thetamin, Double_t thetamax, Double_t phimin, Double_t phimax){
112     Double_t theta = TMath::ASin(Sqrt( frandom->Uniform( TMath::ASin(thetamin), TMath::ASin(thetamax))));
113     Double_t phi = TMath::TwoPi() * frandom->Uniform( phimin, phimax );
114     SetDirection(theta, phi);
115     }
116    
117     void GenPosAng(TVector3 &pos, TVector2 &ang) { f2PiAux->GenPosAng(pos,ang); }
118    
119     void Gen2PiPosAng(){
120     TVector3 pos;
121     TVector2 ang;
122     GenPosAng(pos,ang);
123     SetPosition( pos.X(), pos.Y(), pos.Z() );
124     SetDirection( ang.X(), ang.Y() );
125     }
126    
127     //flat spectra generator
128     void GenSpe(Double_t PEmin, Double_t PEmax, Bool_t isEnergy=kFALSE);
129     //power law spectra, gamma - differential spectral index
130     void GenSpe(Double_t PEmin, Double_t PEmax, Double_t gamma, Bool_t isEnergy=kFALSE);
131     void GenSpe_Flat(Double_t PEmin, Double_t PEmax, Double_t gamma, Bool_t isEnergy=kFALSE);
132     void GenSpe_3par(Double_t PEmin, Double_t PEmax, Double_t a, Double_t b, Double_t c);
133     void GenSphericalPhiThe(); // cecilia // flusso istropo // sets phi the
134     void GenSphPhiThe(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax,
135     Double_t zmin, Double_t zmax); // flusso isotropo entro S2 S3
136     // sets position and phi the
137    
138    
139     // get methods
140     Int_t GetParticleID(){ return fprim.fID; };
141     Int_t GetParticle(){ return fprim.fPDG; };
142     void GetPositon(TVector3 & v){ v.SetXYZ(fprim.fX0,fprim.fY0,fprim.fZ0); };
143     void GetPosition(Double_t & X0, Double_t & Y0,Double_t & Z0)
144     {X0=fprim.fX0; Y0=fprim.fY0; Z0=fprim.fZ0;};
145    
146     Double_t GetKinEnergy() { return MomentumToKinE(fprim.fP0); };
147     Double_t GetRigidity() { return MomentumToRig(fprim.fP0); };
148     Double_t GetMomentum() { return fprim.fP0; };
149    
150     Double_t Get2PiArea() { return f2PiAux->GetArea(); };
151    
152     void GetDirection(TVector2 & v) {v.Set(fprim.fTHETA,fprim.fPHI);}
153     void GetDirection(Double_t &theta, Double_t & phi) { theta = fprim.fTHETA; phi = fprim.fPHI;}
154    
155     Bool_t Getgood(){ return fprim.fGOOD; };
156    
157     void GetTol(Double_t& xtol, Double_t& ytol){ xtol=fprim.fXTOL; ytol=fprim.fYTOL; };
158    
159     void GetCR_GF(Double_t& xcr, Double_t& ycr, Int_t id_GF){
160     if(id_GF<14){
161     xcr=fprim.fCR_X[id_GF];
162     ycr=fprim.fCR_Y[id_GF];
163     }
164     }
165    
166     Int_t GetNgood(){ return fngood; }
167    
168     //initialize random
169     void SetRandom(TRandom* random){
170     frandom = random;
171     f2PiAux->SetRandom(random);
172     }
173    
174     //work with collection of primaries
175    
176     void Register(){
177     PamRootManager::Instance()->
178     Register("PRIM","TClonesArray", &fprimColl);
179     }
180    
181     void ClearPrimCol(){
182     fevno=0;
183     (*fprimColl).Clear("C");
184     }
185     //all methods to operate with PamVMCPrimaryGF object
186     //after each step of primary
187     void SetZeroStep(Double_t z_curr, Double_t x_curr, Double_t y_curr){
188     fzprev = z_curr;
189     fxprev = x_curr;
190     fyprev = y_curr;
191     }
192     void CheckCrossing(Double_t z_curr, Double_t x_curr, Double_t y_curr){
193     fpgf->CheckCrossing(fzprev,fxprev,fyprev, z_curr, x_curr, y_curr);
194     SetZeroStep(z_curr,x_curr, y_curr);
195     }
196     //after last step of primary
197     void CheckInsideAcceptance(){
198     for(Int_t i = 0; i<NGF; i++) fprim.fCR_X[i] = fprim.fCR_Y[i] = fprim.fXTOL = fprim.fYTOL = -100.; //zeroing
199     fprim.fGOOD = fpgf->IsInsideAcceptance(fprim.fCR_X, fprim.fCR_Y, fprim.fXTOL, fprim.fYTOL);
200     fpgf->Clear();
201     if(fprim.fGOOD) fngood++;
202     //Here I'm getting what I have in collection and asume that I have only 1 primary here
203     //If I wish to launch more in 1 event I need change this stuff
204     PamVMCPrimary* tmp = (PamVMCPrimary*)fprimColl->At(0);
205     if(tmp) *tmp = fprim;
206     }
207    
208     Double_t MomentumToKinE(Double_t P0);
209     Double_t KinEToMomentum(Double_t E0);
210     Double_t MomentumToRig(Double_t P0) { return TMath::Abs(P0/fcharge); };
211     Double_t RigToMomentum(Double_t R0){ return TMath::Abs(R0*fcharge); };
212     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);};
213    
214     private:
215     // methods
216    
217    
218    
219     // data members
220     TVirtualMCStack* fStack;
221     Int_t fevno;
222     Int_t fngood; //particles inside nominal acceptance
223     PamVMCPrimary fprim;
224     Double_t fmass;
225     Double_t fcharge;
226     Double_t fxprev, fyprev, fzprev; // coordinates of primary on prev. step
227     TClonesArray* fprimColl;
228     TRandom* frandom; // Class is not a owner of this object
229     TF1* ftheta; // To generate sherical distributhin in theta-angle
230     PamVMC2PiAux* f2PiAux; //2 Pi generator aux stuff
231     PamVMCPrimaryGF* fpgf; // Object which
232    
233    
234     ClassDef(PamVMCPrimaryGenerator,1) //PamVMCPrimaryGenerator
235     };
236    
237     // inline functions
238    
239    
240     inline Double_t PamVMCPrimaryGenerator::MomentumToKinE(Double_t P0)
241     { return Sqrt(P0*P0+fmass*fmass)-fmass; }
242    
243     inline Double_t PamVMCPrimaryGenerator::KinEToMomentum(Double_t E0)
244     { return Sqrt(E0*E0+2.*E0*fmass); }
245    
246     #endif //PAMVMC_PRIMARY_GENERATOR_H
247    

  ViewVC Help
Powered by ViewVC 1.1.23