--- PamVMC/src/PamVMCApplication.cxx 2009/02/19 18:43:14 1.3 +++ PamVMC/src/PamVMCApplication.cxx 2009/06/12 18:39:29 1.5 @@ -29,47 +29,40 @@ ClassImp(PamVMCApplication) -PamVMCApplication::PamVMCApplication(const char *name, const char *title) +PamVMCApplication::PamVMCApplication(const char *name, const char *title, const char* filename, Int_t seed) : TVirtualMCApplication(name,title), fEventNo(0), fVerbose(2), fStack(0), fdetector(0), fPrimaryGenerator(0), - fRootManager("pamtest",kWrite) + fRootManager(filename,kWrite) { // Standard constructor // Create a user stack fStack = new PamVMCStack(1000); - - + // Create a primary generator fPrimaryGenerator = new PamVMCPrimaryGenerator(fStack); + //Create random object + frandom = new TRandom3(seed); fdetector = new PamVMCDetPamela(); PamVMCFieldMgr::Instance()->LoadField(); -} - + + TString fname=filename; fname+=".pam"; -PamVMCApplication::PamVMCApplication() - : TVirtualMCApplication(), - fEventNo(0), - fVerbose(0), - fStack(0), - fdetector(0), - fPrimaryGenerator(0), - fRootManager() -{ -// Default constructor + PamVMCRawMgr::Instance()-> CreateOutFile(fname.Data()); } + PamVMCApplication::~PamVMCApplication() { // Destructor - + delete frandom; delete fStack; delete fdetector; delete fPrimaryGenerator; @@ -87,23 +80,31 @@ gROOT->LoadMacro(setup); gInterpreter->ProcessLine("Config()"); gMC->SetStack(fStack); + gMC->SetRandom(frandom); + std::cout<<"!!! BEFORE INIT GMC"<Init(); cout<<"INIT MC"<BuildPhysics(); cout<<"PHYSICS BUILDED"<= 333572 + gMC->SetMagField(PamVMCFieldMgr::Instance()); + cout<<"Magnetic field setted"<InitMC(); // fdetector->Print(); PamVMCSDMgr::Instance()->Register(); - PamVMCDigMgr::Instance()->LoadCalib(); + PamVMCDigMgr::Instance()->Initialize(gMC->GetRandom()); + PamVMCRawMgr::Instance()->WriteToFile(); + fPrimaryGenerator->SetRandom(gMC->GetRandom()); fPrimaryGenerator->Register(); std::cout<<"LIST OF ACTIVE SD'S:"<DefineIon("He4",2,4,1,0.); - gMC->DefineIon("Boron",5,10,1,0.); - gMC->DefineIon("Carbon",6,12,1,0.); + //Arguments are: + //name + //Z (atomic number) + //A (atomic mass) + //Q (charge eplus) + //exitation exitation energy [GeV] 0. if in ground state + //mass [GeV], if not specified, calculated approx + + gMC->DefineIon("He3",2,3,2,0.,2.808); + gMC->DefineIon("He4",2,4,2,0.,3.727); + + //gMC->DefineIon("He7",2,7,2,0.); + //gMC->DefineIon("Boron",5,10,5,0.); + //gMC->DefineIon("Carbon",6,12,6,0.); } @@ -175,7 +187,7 @@ void PamVMCApplication::BeginPrimary() { // User actions at beginning of a primary track - + fPrimaryGenerator->SetGood(kTRUE); fVerbose.BeginPrimary(); } @@ -185,14 +197,28 @@ } + +#define CAVITY_X 8.07 +#define CAVITY_Y 6.57 +#define ZCAVITY_MIN 27.399 +#define ZCAVITY_MAX 71.059 + + +Bool_t PamVMCApplication::IsInsideCavity(){ + Double_t x,y,z; + gMC->TrackPosition(x,y,z); + if( (zZCAVITY_MAX)) return kTRUE; + if( (TMath::Abs(x) > CAVITY_X) || (TMath::Abs(y) > CAVITY_Y)) return kFALSE; + return kTRUE; +} + + void PamVMCApplication::Stepping() { if (fStack->GetCurrentTrack()->IsPrimary()){ - PamVMCVolCross* tmp=(PamVMCVolCross*)PamVMCVolCrossMgr::Instance()->GetSD(gMC->CurrentVolName()); - if (tmp){ - tmp->CrossVol(); - } + if(!IsInsideCavity()) fPrimaryGenerator->SetGood(kFALSE); } + // User actions at each step fVerbose.Stepping(); PamVMCDetectorSD* temp=(PamVMCDetectorSD*) PamVMCSDMgr::Instance()->GetSD(gMC->CurrentVolName()); @@ -200,7 +226,7 @@ fdstatus=INSIDE; if(gMC->IsTrackEntering()){ fdstatus=ENTERING; } if(gMC->IsTrackExiting() || gMC->IsTrackOut() || gMC->IsTrackStop() ) { fdstatus=EXITING;} - temp->FillHit(fdstatus,gMC); + temp->FillHit(fdstatus,gMC,fStack->GetCurrentTrack()->IsPrimary()); } } @@ -214,8 +240,8 @@ void PamVMCApplication::FinishPrimary() { // User actions after finishing of a primary track - fPrimaryGenerator->SetGood(PamVMCVolCrossMgr::Instance()->IsTrackGood()); - PamVMCVolCrossMgr::Instance()->Reset(); + //fPrimaryGenerator->SetGood(PamVMCVolCrossMgr::Instance()->IsTrackGood()); + //PamVMCVolCrossMgr::Instance()->Reset(); fVerbose.FinishPrimary(); } @@ -257,7 +283,9 @@ } +#if ROOT_VERSION_CODE < 333572 void PamVMCApplication::Field(const Double_t* x, Double_t* b) const { PamVMCFieldMgr::Instance()->Field(x,b); } +#endif