7 #include "G4TrackingManager.hh" 9 #include "G4Trajectory.hh" 10 #include "G4ParticleDefinition.hh" 11 #include "G4ParticleTypes.hh" 12 #include "G4EventManager.hh" 36 if(fpTrackingManager->GetVerboseLevel() > 0)
38 std::cout <<
"LBNETrackingAction Destructor Called." <<
std::endl;
43 std::cerr <<
" From LBNETrackingAction::OpenHadronAtVertex, file already opened, fatal... " <<
std::endl;
50 const char *clusterEnv =
getenv(
"CLUSTER");
51 if (clusterEnv != 0) clusterNum = atoi(clusterEnv);
52 const char *procEnv =
getenv(
"PROCESS");
53 if (procEnv != 0) procNum = atoi(procEnv);
54 std::string fName(
"./hadronFluxPreTrackingASCII.txt");
55 if ((clusterNum != 0) || (procNum != 0)) {
58 std::ostringstream fNStrStr;
59 fNStrStr <<
"./hadronFluxAtPreTrackingASCII_" 60 << clusterNum <<
"_" << procNum <<
".txt";
61 fName = fNStrStr.str();
65 std::cout <<
" LBNETrackingAction::OpenHadronAtVertex, Opening file " <<
78 int myPid = aTrack->GetParticleDefinition()->GetPDGEncoding();
79 if ((
std::abs(myPid) == 211) || (myPid == 2212) ||
81 double pTotSq = 0;
for (
int k=0;
k != 3;
k++) pTotSq += aTrack->GetMomentum()[
k]*aTrack->GetMomentum()[
k];
82 double pTot = std::sqrt(pTotSq)/CLHEP::GeV;
83 if ((myPid == 2212) || ((pTot > 0.001) && (pTot < 50.))) {
84 int evtId = G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID();
106 if(fpTrackingManager->GetVerboseLevel() > 1)
108 G4int evtno =
pRunManager->GetCurrentEvent()->GetEventID();
109 std::cout <<
"Event " << evtno <<
": LBNETrackingAction::PreUserTrackingAction() Called." <<
std::endl;
110 if(fpTrackingManager->GetVerboseLevel() > 2)
113 trackinfo -> Print(aTrack);
129 if(fpTrackingManager->GetVerboseLevel() > 2) std::cerr <<
" .... ..... about to store trajectory " <<
std::endl;
132 fpTrackingManager->SetStoreTrajectory(
true);
135 if(fpTrackingManager->GetVerboseLevel() > 2) std::cerr <<
" .... ..... did store trajectory " <<
std::endl;
137 if(fpTrackingManager->GetVerboseLevel() > 2) std::cerr <<
" .... ..... did Analyze if neutrino " <<
std::endl;
141 if(fpTrackingManager->GetVerboseLevel() > 1)
143 std::cout <<
" LBNETrackingAction::PreUserTrackingAction() - done." <<
std::endl;
150 if(fpTrackingManager->GetVerboseLevel() > 1)
152 G4int evtno =
pRunManager->GetCurrentEvent()->GetEventID();
153 std::cout <<
"Event " << evtno <<
": LBNETrackingAction::PostUserTrackingAction() Called." <<
std::endl;
154 if(fpTrackingManager->GetVerboseLevel() > 2)
157 trackinfo -> Print(aTrack);
176 if(fpTrackingManager->GetVerboseLevel() > 1)
178 std::cout <<
" LBNETrackingAction::PostUserTrackingAction() - done." <<
std::endl;
196 if(fpTrackingManager->GetVerboseLevel() > 3)
198 G4int evtno =
pRunManager->GetCurrentEvent()->GetEventID();
199 std::cout <<
"Event " << evtno
200 <<
": NumiTrackingAction::SetPreNumiTrackInformation() Called." 205 if (aTrack->GetTrackID()==1)
223 G4Track* theTrack = (G4Track*)aTrack;
224 theTrack->SetUserInformation(info);
233 if(fpTrackingManager->GetVerboseLevel() > 3)
235 G4int evtno =
pRunManager->GetCurrentEvent()->GetEventID();
236 std::cout <<
"Event " << evtno
237 <<
": NumiTrackingAction::SetPostNumiTrackInformation() Called." 247 G4TrackVector* SecVector = fpTrackingManager->GimmeSecondaries();
248 for (
size_t ii=0;ii<(*SecVector).size();ii++)
255 (*SecVector)[ii]->SetUserInformation(newinfo);
273 if(fpTrackingManager->GetVerboseLevel() > 3)
275 G4int evtno =
pRunManager->GetCurrentEvent()->GetEventID();
276 std::cout <<
"Event " << evtno
277 <<
": NumiTrackingAction::AnalyzeIfNeutrino() Called." 282 G4ParticleDefinition * particleDefinition = aTrack->GetDefinition();
283 if ((particleDefinition == G4NeutrinoE::NeutrinoEDefinition())||
284 (particleDefinition == G4NeutrinoMu::NeutrinoMuDefinition()) ||
285 (particleDefinition == G4NeutrinoTau::NeutrinoTauDefinition()) ||
286 (particleDefinition == G4AntiNeutrinoE::AntiNeutrinoEDefinition()) ||
287 (particleDefinition == G4AntiNeutrinoMu::AntiNeutrinoMuDefinition()) ||
288 (particleDefinition == G4AntiNeutrinoTau::AntiNeutrinoTauDefinition()))
293 const G4Event*
event =
pRunManager->GetCurrentEvent();
294 G4TrajectoryContainer* trajectories =
event->GetTrajectoryContainer();
296 std::map<int,G4VTrajectory*> trajectoryMap;
297 for (std::size_t
i = 0;
i < trajectories->size(); ++
i) {
298 G4VTrajectory* traj = (*trajectories)[
i];
299 trajectoryMap[traj->GetTrackID()] = traj;
302 std::vector<G4VTrajectory*> nuHistory;
303 G4VTrajectory* neutrino = fpTrackingManager->GimmeTrajectory();
304 nuHistory.push_back(neutrino);
305 int parentId = aTrack->GetParentID();
306 while (parentId != 0) {
307 G4VTrajectory* parentTraj = trajectoryMap[parentId];
309 G4cerr <<
"Invalid trajectory object" << G4endl;
312 nuHistory.push_back(parentTraj);
314 if (!lbneTrajectory)
continue;
317 parentId = parentTraj->GetParentID();
bool doImportanceWeightSelection
void SetPreLBNETrackInformation(const G4Track *aTrack)
void FillNeutrinoNtuple(const G4Track &track, const std::vector< G4VTrajectory * > &nuHistory)
virtual void PostUserTrackingAction(const G4Track *)
bool GetUseMarsInput() const
LBNEPrimaryGeneratorAction * NPGA
LBNERunManager * pRunManager
std::ofstream fOutHadronAtVectex
void SetPostLBNETrackInformation(const G4Track *aTrack)
static LBNEAnalysis * getInstance()
virtual ~LBNETrackingAction()
virtual G4String GetPreStepVolumeName(G4int i) const
std::string getenv(std::string const &name)
void OpenHadronAtVertex() const
void ResetFlagParticleGotToHAFront() const
bool GetUseFlukaInput() const
void AnalyzeIfNeutrino(const G4Track *aTrack)
void ResetNumSteps() const
virtual int GetPointEntries() const
virtual void PreUserTrackingAction(const G4Track *)
QTextStream & endl(QTextStream &s)