7 #include "TStopwatch.h" 10 #include "G4GeometryManager.hh" 11 #include "G4StateManager.hh" 12 #include "G4UImanager.hh" 13 #include "G4UIterminal.hh" 14 #include "G4UItcsh.hh" 15 #include "G4ParticleDefinition.hh" 16 #include "G4ParticleTypes.hh" 17 #include "G4DecayTable.hh" 18 #include "G4KL3DecayChannel.hh" 19 #include "G4StepLimiter.hh" 20 #include "G4ParticleTable.hh" 22 #include "G4ProcessManager.hh" 23 #include "G4ParticleDefinition.hh" 24 #include "G4VEnergyLossProcess.hh" 25 #include "G4VModularPhysicsList.hh" 26 #include "G4PhysListFactory.hh" 32 fGeometryIntializedHere(false),
33 fPhysicsInitializedHere(false),
34 fPhysicsListName(
"QGSP_BERT"),
36 fLBNESteppingAction(0),
37 fLBNEStackingAction(0),
38 fLBNETrackingAction(0),
40 fMarsOrFlukaInputFileName(
""),
41 fAsciiOutputFileName(
""),
42 fNptOutputFileName(
""),
43 fDk2NuOutputFileName(
""),
44 fDetectorLocationFileName(
"?"),
48 fCreateDk2NuOutput(false),
49 fCreateAsciiOutput(false),
50 fCreateTrkPlaneOutput(false),
51 fCreateTrkPlaneH1Output(false),
52 fCreateTrkPlaneH2Output(false),
53 fCreateTrkPlaneDPOutput(false),
54 fCreateTrackingTargetOutASCII(false),
55 fCreateTargetOutput(false),
56 fUseRealisticNearDetectorVolume(false),
65 std::cout <<
"LBNERunManager Constructor Called." <<
std::endl;
73 std::cout <<
"LBNERunManager Destructor Called." <<
std::endl;
82 "LBNERunManager InitializeGeometry: LBNE Beam line should be already constructed... " <<
std::endl;
84 G4RunManager::InitializeGeometry();
85 std::cout <<
" ... Geometry has been closed. keep going... " <<
std::endl;
86 std::cout <<
" Geant4 is at stage " << G4StateManager::GetStateManager()->GetCurrentState() <<
std::endl;
91 std::cout<<G4State_PreInit<<
"\t"<<G4State_Init<<
"\t"<<G4State_Idle<<G4endl;
92 std::cout <<
" InitPhys::Geant4 is at stage " << G4StateManager::GetStateManager()->GetCurrentState() <<
std::endl;
98 std::cout <<
" Before::Geant4 is at stage " << G4StateManager::GetStateManager()->GetCurrentState() <<
std::endl;
99 G4StateManager* stateManager = G4StateManager::GetStateManager();
100 stateManager->SetNewState(G4State_PreInit);
102 G4PhysListFactory factory;
103 G4VModularPhysicsList *phys = 0;
108 G4cout <<
"Exiting" << G4endl;
111 this->SetUserInitialization(phys);
114 G4RunManager::InitializePhysics();
116 std::cout <<
" After::Geant4 is at stage " << G4StateManager::GetStateManager()->GetCurrentState() <<
std::endl;
117 G4UImanager* UI = G4UImanager::GetUIpointer();
133 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
134 if (!particleTable->contains(
"kaon0L")) {
135 std::ostringstream mStrStr;
136 mStrStr <<
" The Particle table does not know about kaon Long.. Something not initialized ";
137 G4String mStr(mStrStr.str());
138 G4Exception(
"LBNERunManager::InitializePhysics",
" ", FatalException, mStr.c_str());
141 G4cout <<
"Setting correct branching fractions and form factors for " 142 <<
"K0L, K+ and K- decays (MINOS-doc-1786)"<<G4endl;
144 UI->ApplyCommand(
"/particle/select kaon0L");
145 UI->ApplyCommand(
"/particle/property/decay/select 0");
146 UI->ApplyCommand(
"/particle/property/decay/br 19.72e-2");
147 UI->ApplyCommand(
"/particle/property/decay/select 1");
148 UI->ApplyCommand(
"/particle/property/decay/br 20.20e-2");
149 UI->ApplyCommand(
"/particle/property/decay/select 2");
150 UI->ApplyCommand(
"/particle/property/decay/br 20.20e-2");
151 UI->ApplyCommand(
"/particle/property/decay/select 3");
152 UI->ApplyCommand(
"/particle/property/decay/br 13.495e-2");
153 UI->ApplyCommand(
"/particle/property/decay/select 4");
154 UI->ApplyCommand(
"/particle/property/decay/br 13.495e-2");
155 UI->ApplyCommand(
"/particle/property/decay/select 5");
156 UI->ApplyCommand(
"/particle/property/decay/br 12.53e-2");
158 UI->ApplyCommand(
"/particle/select kaon+");
159 UI->ApplyCommand(
"/particle/property/decay/select 0");
160 UI->ApplyCommand(
"/particle/property/decay/br 63.39e-2");
161 UI->ApplyCommand(
"/particle/property/decay/select 1");
162 UI->ApplyCommand(
"/particle/property/decay/br 21.03e-2");
163 UI->ApplyCommand(
"/particle/property/decay/select 2");
164 UI->ApplyCommand(
"/particle/property/decay/br 5.59e-2");
165 UI->ApplyCommand(
"/particle/property/decay/select 3");
166 UI->ApplyCommand(
"/particle/property/decay/br 5.14e-2");
167 UI->ApplyCommand(
"/particle/property/decay/select 4");
168 UI->ApplyCommand(
"/particle/property/decay/br 3.30e-2");
169 UI->ApplyCommand(
"/particle/property/decay/select 5");
170 UI->ApplyCommand(
"/particle/property/decay/br 1.757e-2");
172 UI->ApplyCommand(
"/particle/select kaon-");
173 UI->ApplyCommand(
"/particle/property/decay/select 0");
174 UI->ApplyCommand(
"/particle/property/decay/br 63.39e-2");
175 UI->ApplyCommand(
"/particle/property/decay/select 1");
176 UI->ApplyCommand(
"/particle/property/decay/br 21.03e-2");
177 UI->ApplyCommand(
"/particle/property/decay/select 2");
178 UI->ApplyCommand(
"/particle/property/decay/br 5.59e-2");
179 UI->ApplyCommand(
"/particle/property/decay/select 3");
180 UI->ApplyCommand(
"/particle/property/decay/br 5.14e-2");
181 UI->ApplyCommand(
"/particle/property/decay/select 4");
182 UI->ApplyCommand(
"/particle/property/decay/br 3.30e-2");
183 UI->ApplyCommand(
"/particle/property/decay/select 5");
184 UI->ApplyCommand(
"/particle/property/decay/br 1.757e-2");
189 G4ParticleTable::G4PTblDicIterator *ptiter=particleTable->GetIterator();
191 G4double lamp = 2.81e-2;
192 G4double lam0 = 1.64e-2;
193 G4double xi_kp= 12.377 * (lam0 - lamp);
194 G4double xi_k0= 11.713 * (lam0 - lamp);
202 G4ParticleDefinition *particle = ptiter->value();
203 if (particle==G4KaonPlus::KaonPlusDefinition()||
204 particle==G4KaonMinus::KaonMinusDefinition()){
205 G4DecayTable *decayTable=particle->GetDecayTable();
206 for (G4int ii=0; ii<decayTable->entries(); ++ii){
207 if (decayTable->GetDecayChannel(ii)->GetKinematicsName()==
"KL3 Decay"){
208 G4KL3DecayChannel *decayChannel=(G4KL3DecayChannel *)decayTable->GetDecayChannel(ii);
211 for (G4int jj=0; jj<decayChannel->GetNumberOfDaughters();++jj){
215 if (decayChannel->GetDaughter(jj)==G4Positron::PositronDefinition()){
219 if (decayChannel->GetDaughter(jj)==G4Electron::ElectronDefinition()){
223 if (decayChannel->GetDaughter(jj)==G4MuonPlus::MuonPlusDefinition()){
227 if (decayChannel->GetDaughter(jj)==G4MuonMinus::MuonMinusDefinition()){
234 decayChannel->SetDalitzParameter(pLambda,pXi0);
238 if (particle==G4KaonZeroLong::KaonZeroLongDefinition()){
239 G4DecayTable *decayTable=particle->GetDecayTable();
240 for (G4int ii=0; ii<decayTable->entries(); ++ii){
241 if (decayTable->GetDecayChannel(ii)->GetKinematicsName()==
"KL3 Decay"){
242 G4KL3DecayChannel *decayChannel=(G4KL3DecayChannel *)decayTable->GetDecayChannel(ii);
244 for (G4int jj=0; jj<decayChannel->GetNumberOfDaughters();++jj){
248 if (decayChannel->GetDaughter(jj)==G4Positron::PositronDefinition()||
249 decayChannel->GetDaughter(jj)==G4Electron::ElectronDefinition()){
253 if (decayChannel->GetDaughter(jj)==G4MuonPlus::MuonPlusDefinition()||
254 decayChannel->GetDaughter(jj)==G4MuonMinus::MuonMinusDefinition()){
262 decayChannel->SetDalitzParameter(pLambda,pXi0);
270 G4ParticleTable* ptbl = G4ParticleTable::GetParticleTable();
271 G4ParticleTable::G4PTblDicIterator* piter = ptbl->GetIterator();
272 G4StepLimiter* slim =
new G4StepLimiter(
"StepLimiter");
275 while ( (*piter)() ) {
276 G4ParticleDefinition* pdef = piter->value();
277 G4ProcessManager* pmgr = pdef->GetProcessManager();
281 pmgr->AddProcess( slim, -1, -1, 3);
285 G4RunManager::Initialize();
287 std::cerr <<
" G4RunManager::Initialize invoked, state is now " 288 << G4StateManager::GetStateManager()->GetCurrentState() <<
std::endl;
307 if (!G4RunManager::ConfirmBeamOnCondition()) {
308 std::ostringstream mStrStr;
309 mStrStr <<
" Expecting to be able to turn on the beam at this stage. Not the case ! Fatal ";
310 G4String mStr(mStrStr.str());
311 G4Exception(
"LBNERunManager::InitializePhysics",
" ", FatalException, mStr.c_str());
313 std::cout <<
" Expecting to be able to turn on the beam at this stage " <<
std::endl;
317 G4ParticleDefinition *piPlus = particleTable->FindParticle(211);
319 G4ProcessManager *piPlusProcM = piPlus->GetProcessManager();
320 piPlusProcM->AddDiscreteProcess(pfProc);
321 G4ParticleDefinition *piMinus = particleTable->FindAntiParticle(211);
322 G4ProcessManager *piMinusProcM = piMinus->GetProcessManager();
323 piMinusProcM->AddDiscreteProcess(pfProc);
324 G4ParticleDefinition *kPlus = particleTable->FindParticle(321);
325 G4ProcessManager *kPlusProcM = kPlus->GetProcessManager();
326 kPlusProcM->AddDiscreteProcess(pfProc);
327 G4ParticleDefinition *kMinus = particleTable->FindAntiParticle(321);
328 G4ProcessManager *kMinusProcM = kMinus->GetProcessManager();
329 kMinusProcM->AddDiscreteProcess(pfProc);
335 G4bool cond = ConfirmBeamOnCondition();
340 TStopwatch *sWatch=
new TStopwatch();
343 numberOfEventToBeProcessed =
nEvents;
352 std::cout <<
"********************************************************" <<
std::endl;
353 std::cout <<
"********************************************************" <<
std::endl;
354 std::cout <<
"*****LBNERunManager::BeamOn - With "<<
nEvents <<
" Events " <<
std::endl;
355 std::cout <<
"***** (argument n_event = " << n_event <<
" ignored, O.K.) " <<
std::endl;
356 std::cout <<
"********************************************************" <<
std::endl;
357 G4RunManager::BeamOn(
nEvents, macroFile, n_select);
358 std::cout <<
"********************************************************" <<
std::endl;
359 std::cout <<
"***LBNERunManager::BeamOn - ...Done ***" <<
std::endl;
360 std::cout <<
"********************************************************" <<
std::endl;
361 std::cout <<
"********************************************************" <<
std::endl;
364 G4cout <<
"LBNERunManager::BeamOn - Run Summary..." << G4endl;
365 G4cout <<
" Processed "<<
nEvents <<
" beam particles in ";
367 G4cout << sWatch->RealTime() <<
" s = " 368 << sWatch->RealTime()/60. <<
" min " 369 << sWatch->RealTime()/3600. <<
" hr " << G4endl;
virtual void BeamOn(G4int n_event, const char *macroFile=0, G4int n_select=-1)
bool fPhysicsInitializedHere
bool fCreateAlcoveTrackingOutput
LBNEStackingAction * fLBNEStackingAction
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
LBNERunAction * fLBNERunAction
LBNETrackingAction * fLBNETrackingAction
virtual void InitializeGeometry()
bool fGeometryIntializedHere
virtual void InitializePhysics()
virtual ~LBNERunManager()
LBNEEventAction * fLBNEEventAction
LBNESteppingAction * fLBNESteppingAction
G4String fPhysicsListName
QTextStream & endl(QTextStream &s)