29 |
|
|
30 |
ClassImp(PamVMCApplication) |
ClassImp(PamVMCApplication) |
31 |
|
|
32 |
PamVMCApplication::PamVMCApplication(const char *name, const char *title) |
PamVMCApplication::PamVMCApplication(const char *name, const char *title, const char* filename, Int_t seed) |
33 |
: TVirtualMCApplication(name,title), |
: TVirtualMCApplication(name,title), |
34 |
fEventNo(0), |
fEventNo(0), |
35 |
fVerbose(2), |
fVerbose(2), |
36 |
fStack(0), |
fStack(0), |
37 |
fdetector(0), |
fdetector(0), |
38 |
fPrimaryGenerator(0), |
fPrimaryGenerator(0), |
39 |
fRootManager("pamtest",kWrite) |
fRootManager(filename,kWrite) |
40 |
{ |
{ |
41 |
// Standard constructor |
// Standard constructor |
42 |
|
|
43 |
// Create a user stack |
// Create a user stack |
44 |
fStack = new PamVMCStack(1000); |
fStack = new PamVMCStack(1000); |
45 |
|
|
|
|
|
46 |
// Create a primary generator |
// Create a primary generator |
47 |
fPrimaryGenerator = new PamVMCPrimaryGenerator(fStack); |
fPrimaryGenerator = new PamVMCPrimaryGenerator(fStack); |
48 |
|
|
49 |
|
//Create random object |
50 |
|
frandom = new TRandom3(seed); |
51 |
|
|
52 |
fdetector = new PamVMCDetPamela(); |
fdetector = new PamVMCDetPamela(); |
53 |
|
|
54 |
PamVMCFieldMgr::Instance()->LoadField(); |
PamVMCFieldMgr::Instance()->LoadField(); |
55 |
} |
|
56 |
|
TString fname=filename; fname+=".pam"; |
57 |
|
|
58 |
PamVMCApplication::PamVMCApplication() |
PamVMCRawMgr::Instance()-> CreateOutFile(fname.Data()); |
|
: TVirtualMCApplication(), |
|
|
fEventNo(0), |
|
|
fVerbose(0), |
|
|
fStack(0), |
|
|
fdetector(0), |
|
|
fPrimaryGenerator(0), |
|
|
fRootManager() |
|
|
{ |
|
|
// Default constructor |
|
59 |
} |
} |
60 |
|
|
61 |
|
|
62 |
PamVMCApplication::~PamVMCApplication() |
PamVMCApplication::~PamVMCApplication() |
63 |
{ |
{ |
64 |
// Destructor |
// Destructor |
65 |
|
delete frandom; |
66 |
delete fStack; |
delete fStack; |
67 |
delete fdetector; |
delete fdetector; |
68 |
delete fPrimaryGenerator; |
delete fPrimaryGenerator; |
80 |
gROOT->LoadMacro(setup); |
gROOT->LoadMacro(setup); |
81 |
gInterpreter->ProcessLine("Config()"); |
gInterpreter->ProcessLine("Config()"); |
82 |
gMC->SetStack(fStack); |
gMC->SetStack(fStack); |
83 |
|
gMC->SetRandom(frandom); |
84 |
|
|
85 |
std::cout<<"!!! BEFORE INIT GMC"<<std::endl; |
std::cout<<"!!! BEFORE INIT GMC"<<std::endl; |
86 |
|
|
87 |
gMC->Init(); |
gMC->Init(); |
88 |
cout<<"INIT MC"<<endl; |
cout<<"INIT MC"<<endl; |
89 |
gMC->BuildPhysics(); |
gMC->BuildPhysics(); |
90 |
cout<<"PHYSICS BUILDED"<<endl; |
cout<<"PHYSICS BUILDED"<<endl; |
91 |
|
|
92 |
|
#if ROOT_VERSION_CODE >= 333572 |
93 |
|
gMC->SetMagField(PamVMCFieldMgr::Instance()); |
94 |
|
cout<<"Magnetic field setted"<<endl; |
95 |
|
#endif |
96 |
|
|
97 |
fdetector->InitMC(); |
fdetector->InitMC(); |
98 |
|
|
99 |
// fdetector->Print(); |
// fdetector->Print(); |
100 |
|
|
101 |
PamVMCSDMgr::Instance()->Register(); |
PamVMCSDMgr::Instance()->Register(); |
102 |
|
|
103 |
PamVMCDigMgr::Instance()->LoadCalib(); |
PamVMCDigMgr::Instance()->Initialize(gMC->GetRandom()); |
104 |
|
|
105 |
PamVMCRawMgr::Instance()->WriteToFile(); |
PamVMCRawMgr::Instance()->WriteToFile(); |
106 |
|
|
107 |
|
fPrimaryGenerator->SetRandom(gMC->GetRandom()); |
108 |
fPrimaryGenerator->Register(); |
fPrimaryGenerator->Register(); |
109 |
|
|
110 |
std::cout<<"LIST OF ACTIVE SD'S:"<<std::endl; |
std::cout<<"LIST OF ACTIVE SD'S:"<<std::endl; |
126 |
void PamVMCApplication::AddIons(){ |
void PamVMCApplication::AddIons(){ |
127 |
|
|
128 |
fVerbose.AddIons(); |
fVerbose.AddIons(); |
129 |
gMC->DefineIon("He4",2,4,1,0.); |
//Arguments are: |
130 |
gMC->DefineIon("Boron",5,10,1,0.); |
//name |
131 |
gMC->DefineIon("Carbon",6,12,1,0.); |
//Z (atomic number) |
132 |
|
//A (atomic mass) |
133 |
|
//Q (charge eplus) |
134 |
|
//exitation exitation energy [GeV] 0. if in ground state |
135 |
|
//mass [GeV], if not specified, calculated approx |
136 |
|
|
137 |
|
gMC->DefineIon("He3",2,3,2,0.,2.808); |
138 |
|
gMC->DefineIon("He4",2,4,2,0.,3.727); |
139 |
|
|
140 |
|
//gMC->DefineIon("He7",2,7,2,0.); |
141 |
|
//gMC->DefineIon("Boron",5,10,5,0.); |
142 |
|
//gMC->DefineIon("Carbon",6,12,6,0.); |
143 |
} |
} |
144 |
|
|
145 |
|
|
187 |
void PamVMCApplication::BeginPrimary() |
void PamVMCApplication::BeginPrimary() |
188 |
{ |
{ |
189 |
// User actions at beginning of a primary track |
// User actions at beginning of a primary track |
190 |
|
fPrimaryGenerator->SetGood(kTRUE); |
191 |
fVerbose.BeginPrimary(); |
fVerbose.BeginPrimary(); |
192 |
} |
} |
193 |
|
|
197 |
|
|
198 |
} |
} |
199 |
|
|
200 |
|
|
201 |
|
#define CAVITY_X 8.07 |
202 |
|
#define CAVITY_Y 6.57 |
203 |
|
#define ZCAVITY_MIN 27.399 |
204 |
|
#define ZCAVITY_MAX 71.059 |
205 |
|
|
206 |
|
|
207 |
|
Bool_t PamVMCApplication::IsInsideCavity(){ |
208 |
|
Double_t x,y,z; |
209 |
|
gMC->TrackPosition(x,y,z); |
210 |
|
if( (z<ZCAVITY_MIN) || (z>ZCAVITY_MAX)) return kTRUE; |
211 |
|
if( (TMath::Abs(x) > CAVITY_X) || (TMath::Abs(y) > CAVITY_Y)) return kFALSE; |
212 |
|
return kTRUE; |
213 |
|
} |
214 |
|
|
215 |
|
|
216 |
void PamVMCApplication::Stepping() |
void PamVMCApplication::Stepping() |
217 |
{ |
{ |
218 |
if (fStack->GetCurrentTrack()->IsPrimary()){ |
if (fStack->GetCurrentTrack()->IsPrimary()){ |
219 |
PamVMCVolCross* tmp=(PamVMCVolCross*)PamVMCVolCrossMgr::Instance()->GetSD(gMC->CurrentVolName()); |
if(!IsInsideCavity()) fPrimaryGenerator->SetGood(kFALSE); |
|
if (tmp){ |
|
|
tmp->CrossVol(); |
|
|
} |
|
220 |
} |
} |
221 |
|
|
222 |
// User actions at each step |
// User actions at each step |
223 |
fVerbose.Stepping(); |
fVerbose.Stepping(); |
224 |
PamVMCDetectorSD* temp=(PamVMCDetectorSD*) PamVMCSDMgr::Instance()->GetSD(gMC->CurrentVolName()); |
PamVMCDetectorSD* temp=(PamVMCDetectorSD*) PamVMCSDMgr::Instance()->GetSD(gMC->CurrentVolName()); |
226 |
fdstatus=INSIDE; |
fdstatus=INSIDE; |
227 |
if(gMC->IsTrackEntering()){ fdstatus=ENTERING; } |
if(gMC->IsTrackEntering()){ fdstatus=ENTERING; } |
228 |
if(gMC->IsTrackExiting() || gMC->IsTrackOut() || gMC->IsTrackStop() ) { fdstatus=EXITING;} |
if(gMC->IsTrackExiting() || gMC->IsTrackOut() || gMC->IsTrackStop() ) { fdstatus=EXITING;} |
229 |
temp->FillHit(fdstatus,gMC); |
temp->FillHit(fdstatus,gMC,fStack->GetCurrentTrack()->IsPrimary()); |
230 |
} |
} |
231 |
|
|
232 |
} |
} |
240 |
void PamVMCApplication::FinishPrimary() |
void PamVMCApplication::FinishPrimary() |
241 |
{ |
{ |
242 |
// User actions after finishing of a primary track |
// User actions after finishing of a primary track |
243 |
fPrimaryGenerator->SetGood(PamVMCVolCrossMgr::Instance()->IsTrackGood()); |
//fPrimaryGenerator->SetGood(PamVMCVolCrossMgr::Instance()->IsTrackGood()); |
244 |
PamVMCVolCrossMgr::Instance()->Reset(); |
//PamVMCVolCrossMgr::Instance()->Reset(); |
245 |
fVerbose.FinishPrimary(); |
fVerbose.FinishPrimary(); |
246 |
} |
} |
247 |
|
|
283 |
|
|
284 |
} |
} |
285 |
|
|
286 |
|
#if ROOT_VERSION_CODE < 333572 |
287 |
void PamVMCApplication::Field(const Double_t* x, Double_t* b) const |
void PamVMCApplication::Field(const Double_t* x, Double_t* b) const |
288 |
{ |
{ |
289 |
PamVMCFieldMgr::Instance()->Field(x,b); |
PamVMCFieldMgr::Instance()->Field(x,b); |
290 |
} |
} |
291 |
|
#endif |