// $Id: PamVMCPrimaryGenerator.h,v 1.0 2007/06/03 #ifndef PAMVMC_PRIMARY_GENERATOR_H #define PAMVMC_PRIMARY_GENERATOR_H #include #include #include #include #include #include #include #include #include "PamRootManager.h" class TVirtualMCStack; using std::cout; using std::endl; using TMath::Sqrt; class PamVMCPrimary : public TObject { public: PamVMCPrimary(): fPDG(0), fX0(0.), fY0(0.), fZ0(0.), fTHETA(0.), fPHI(0.), fP0(0.), fGOOD(kFALSE) { }; Int_t fPDG; Double_t fX0, fY0, fZ0; Double_t fTHETA, fPHI; Double_t fP0; Bool_t fGOOD; void Clean() { fPDG=0; fX0=fY0=fZ0=fTHETA=fPHI=fP0=0.; fGOOD=kFALSE;} void Clear(const Option_t * =""){ Clean(); } void Print(const Option_t * ="") const { cout<<"PRIMARY particle infromation:"<Uniform(xmin,xmax),frandom->Uniform(ymin,ymax),frandom->Uniform(zmin,zmax)); } void GenDirection(Double_t thetamin, Double_t thetamax, Double_t phimin, Double_t phimax){ SetDirection(ftheta->GetRandom(thetamin, thetamax), frandom->Uniform(phimin,phimax)); } //flat spectra generator void GenSpe(Double_t PEmin, Double_t PEmax, Bool_t isEnergy=kFALSE); //power law spectra, gamma - differential spectral index void GenSpe(Double_t PEmin, Double_t PEmax, Double_t gamma, Bool_t isEnergy=kFALSE); void GenSpe_Flat(Double_t PEmin, Double_t PEmax, Double_t gamma, Bool_t isEnergy=kFALSE); void GenSpe_3par(Double_t PEmin, Double_t PEmax, Double_t a, Double_t b, Double_t c); void GenSphericalPhiThe(); // cecilia // flusso istropo // sets phi the void GenSphPhiThe(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax); // flusso isotropo entro S2 S3 // sets position and phi the // get methods Int_t GetParticle(){ return fprim.fPDG; }; void GetPositon(TVector3 & v){ v.SetXYZ(fprim.fX0,fprim.fY0,fprim.fZ0); }; void GetPosition(Double_t X0, Double_t Y0,Double_t Z0) {X0=fprim.fX0; Y0=fprim.fY0; Z0=fprim.fZ0;}; Double_t GetKinEnergy() { return MomentumToKinE(fprim.fP0); }; Double_t GetRigidity() { return MomentumToRig(fprim.fP0); }; Double_t GetMomentum() { return fprim.fP0; }; void GetDirection(TVector2 & v) {v.Set(fprim.fTHETA,fprim.fPHI);} Bool_t Getgood(){ return fprim.fGOOD; }; //initialize random void SetRandom(TRandom* random){ frandom = random; } //work with collection of primaries void Register(){ PamRootManager::Instance()-> Register("PRIM","TClonesArray", &fprimColl); } void ClearPrimCol(){ fevno=0; (*fprimColl).Clear(); } private: // methods Double_t MomentumToKinE(Double_t P0); Double_t KinEToMomentum(Double_t E0); Double_t MomentumToRig(Double_t P0) { return P0/fcharge; }; Double_t RigToMomentum(Double_t R0){ return R0*fcharge; }; 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);}; // data members TVirtualMCStack* fStack; Int_t fevno; PamVMCPrimary fprim; Double_t fmass; Double_t fcharge; TClonesArray* fprimColl; TRandom* frandom; // Class is not a owner of this object TF1* ftheta; // To generate sherical distributhin in theta-angle ClassDef(PamVMCPrimaryGenerator,1) //PamVMCPrimaryGenerator }; // inline functions inline Double_t PamVMCPrimaryGenerator::MomentumToKinE(Double_t P0) { return Sqrt(P0*P0+fmass*fmass)-fmass; } inline Double_t PamVMCPrimaryGenerator::KinEToMomentum(Double_t E0) { return Sqrt(E0*E0+2.*E0*fmass); } #endif //PAMVMC_PRIMARY_GENERATOR_H