14 #include "G4VProcess.hh"
15 #include "G4HCofThisEvent.hh"
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
17 #include "CLHEP/Units/GlobalPhysicalConstants.h"
36 nsec =
new std::vector<int>();
37 px =
new std::vector<double>();
38 py =
new std::vector<double>();
39 pz =
new std::vector<double>();
40 mass =
new std::vector<double>();
41 deltae =
new std::vector<double>();
42 procids =
new std::vector<int>();
43 procs =
new std::vector<std::string>();
45 if (saveFile !=
"None") {
48 edm::LogInfo(
"CheckSecondary") <<
"Instantiate CheckSecondary with first"
49 <<
" hadronic interaction information"
50 <<
" to be saved in file " << saveFile;
53 edm::LogInfo(
"CheckSecondary") <<
"Instantiate CheckSecondary with first"
54 <<
" hadronic interaction information"
75 file =
new TFile (fileName.c_str(),
"RECREATE");
78 TTree * t1 =
new TTree(
"T1",
"Secondary Particle Information");
79 t1->Branch(
"SecondaryPx",
"std::vector<double>", &
px);
80 t1->Branch(
"SecondaryPy",
"std::vector<double>", &
py);
81 t1->Branch(
"SecondaryPz",
"std::vector<double>", &
pz);
82 t1->Branch(
"SecondaryMass",
"std::vector<double>", &
mass);
83 t1->Branch(
"NumberSecondaries",
"std::vector<int>", &
nsec);
84 t1->Branch(
"DeltaEinInteract",
"std::vector<double>", &
deltae);
85 t1->Branch(
"ProcessID",
"std::vector<int>", &
procids);
86 t1->Branch(
"ProcessNames",
"std::vector<std::string>", &
procs);
92 edm::LogInfo(
"CheckSecondary") <<
"Save the Secondary Tree "
94 <<
") in file " <<
file->GetName() <<
" ("
104 int iev = (*evt)()->GetEventID();
105 LogDebug(
"CheckSecondary") <<
"CheckSecondary::=====> Begin of event = "
120 const G4Track * thTk = (*trk)();
122 if (thTk->GetParentID() <= 0)
storeIt =
true;
125 LogDebug(
"CheckSecondary") <<
"CheckSecondary:: Track " << thTk->GetTrackID()
126 <<
" Parent " << thTk->GetParentID() <<
" Flag "
144 double pInit = (aStep->GetPreStepPoint()->GetMomentum()).
mag();
145 double pEnd = (aStep->GetPostStepPoint()->GetMomentum()).
mag();
147 int sec = (int)(tracks.size());
148 LogDebug(
"CheckSecondary") <<
"CheckSecondary:: Hadronic Interaction "
149 <<
nHad <<
" of type " << name <<
" ID "
150 << procID <<
" with " << sec <<
" secondaries "
151 <<
" and Momentum (MeV/c) at start " << pInit
152 <<
" and at end " << pEnd;
153 (*nsec).push_back(sec);
154 (*procs).push_back(name);
155 (*procids).push_back(procID);
156 (*deltae).push_back(deltaE);
158 for (
int i=0;
i<sec;
i++) {
159 double m = tracks[
i].M();
160 if (charge[
i]<0) m = -
m;
161 (*px).push_back(tracks[
i].Px());
162 (*py).push_back(tracks[
i].Py());
163 (*pz).push_back(tracks[
i].Pz());
164 (*mass).push_back(m);
172 LogDebug(
"CheckSecondary") <<
"CheckSecondary::EndofEvent =====> Event "
173 << (*evt)()->GetEventID() <<
" with "
174 << (*nsec).size() <<
" hadronic collisions with"
175 <<
" secondaries produced in each step";
176 for (
unsigned int i= 0;
i < (*nsec).size();
i++)
177 LogDebug(
"CheckSecondary") <<
" " << (*nsec)[
i] <<
" from " << (*procs)[
i]
178 <<
" ID " << (*procids)[
i] <<
" ("
180 <<
") deltaE = " << (*deltae)[
i] <<
" MeV";
181 LogDebug(
"CheckSecondary") <<
"And " << (*mass).size() <<
" secondaries "
182 <<
"produced in the first interactions";
183 for (
unsigned int i= 0; i < (*mass).size(); i++)
184 LogDebug(
"CheckSecondary") <<
"Secondary " << i <<
" (" << (*px)[
i] <<
", "
185 << (*py)[
i] <<
", " << (*pz)[
i] <<
", "
186 << (*mass)[
i] <<
")";
T getParameter(std::string const &) const
std::vector< std::string > * procs
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > * pz
std::vector< double > * deltae
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
std::vector< math::XYZTLorentzVector > tracks(const G4Step *step, std::string &procName, int &procID, bool &intr, double &deltaE, std::vector< int > &charges)
std::string processG4Name(int)
std::vector< int > * nsec
G4ProcessTypeEnumerator * typeEnumerator
TTree * bookTree(std::string)
void initTrack(const G4Track *trk)
void update(const BeginOfEvent *evt)
This routine will be called when the appropriate signal arrives.
virtual ~CheckSecondary()
std::vector< double > * py
CheckSecondary(const edm::ParameterSet &p)
std::vector< int > * procids
std::vector< double > * px
TreatSecondary * treatSecondary
std::vector< double > * mass