16 #include "G4VProcess.hh" 17 #include "G4HCofThisEvent.hh" 18 #include "CLHEP/Units/GlobalSystemOfUnits.h" 19 #include "CLHEP/Units/GlobalPhysicalConstants.h" 38 nsec =
new std::vector<int>();
39 px =
new std::vector<double>();
40 py =
new std::vector<double>();
41 pz =
new std::vector<double>();
42 mass =
new std::vector<double>();
43 deltae =
new std::vector<double>();
44 procids =
new std::vector<int>();
45 procs =
new std::vector<std::string>();
47 if (saveFile !=
"None") {
50 edm::LogInfo(
"CheckSecondary") <<
"Instantiate CheckSecondary with first" 51 <<
" hadronic interaction information" 52 <<
" to be saved in file " << saveFile;
55 edm::LogInfo(
"CheckSecondary") <<
"Instantiate CheckSecondary with first" 56 <<
" hadronic interaction information" 77 file =
new TFile (fileName.c_str(),
"RECREATE");
80 TTree * t1 =
new TTree(
"T1",
"Secondary Particle Information");
81 t1->Branch(
"SecondaryPx",
"std::vector<double>", &
px);
82 t1->Branch(
"SecondaryPy",
"std::vector<double>", &
py);
83 t1->Branch(
"SecondaryPz",
"std::vector<double>", &
pz);
84 t1->Branch(
"SecondaryMass",
"std::vector<double>", &
mass);
85 t1->Branch(
"NumberSecondaries",
"std::vector<int>", &
nsec);
86 t1->Branch(
"DeltaEinInteract",
"std::vector<double>", &
deltae);
87 t1->Branch(
"ProcessID",
"std::vector<int>", &
procids);
88 t1->Branch(
"ProcessNames",
"std::vector<std::string>", &
procs);
94 edm::LogInfo(
"CheckSecondary") <<
"Save the Secondary Tree " 96 <<
") in file " <<
file->GetName() <<
" (" 106 int iev = (*evt)()->GetEventID();
107 LogDebug(
"CheckSecondary") <<
"CheckSecondary::=====> Begin of event = " 122 const G4Track * thTk = (*trk)();
124 if (thTk->GetParentID() <= 0)
storeIt =
true;
127 LogDebug(
"CheckSecondary") <<
"CheckSecondary:: Track " << thTk->GetTrackID()
128 <<
" Parent " << thTk->GetParentID() <<
" Flag " 146 double pInit = (aStep->GetPreStepPoint()->GetMomentum()).
mag();
147 double pEnd = (aStep->GetPostStepPoint()->GetMomentum()).
mag();
149 int sec = (
int)(tracks.size());
150 LogDebug(
"CheckSecondary") <<
"CheckSecondary:: Hadronic Interaction " 151 <<
nHad <<
" of type " << name <<
" ID " 152 << procID <<
" with " << sec <<
" secondaries " 153 <<
" and Momentum (MeV/c) at start " << pInit
154 <<
" and at end " << pEnd;
155 (*nsec).push_back(sec);
156 (*procs).push_back(name);
157 (*procids).push_back(procID);
158 (*deltae).push_back(deltaE);
160 for (
int i=0;
i<sec;
i++) {
161 double m = tracks[
i].M();
162 if (charge[
i]<0) m = -
m;
163 (*px).push_back(tracks[
i].Px());
164 (*py).push_back(tracks[
i].Py());
165 (*pz).push_back(tracks[
i].Pz());
166 (*mass).push_back(m);
174 LogDebug(
"CheckSecondary") <<
"CheckSecondary::EndofEvent =====> Event " 175 << (*evt)()->GetEventID() <<
" with " 176 << (*nsec).size() <<
" hadronic collisions with" 177 <<
" secondaries produced in each step";
178 for (
unsigned int i= 0;
i < (*nsec).size();
i++)
179 LogDebug(
"CheckSecondary") <<
" " << (*nsec)[
i] <<
" from " << (*procs)[
i]
180 <<
" ID " << (*procids)[
i] <<
" (" 182 <<
") deltaE = " << (*deltae)[
i] <<
" MeV";
183 LogDebug(
"CheckSecondary") <<
"And " << (*mass).size() <<
" secondaries " 184 <<
"produced in the first interactions";
185 for (
unsigned int i= 0; i < (*mass).size(); i++)
186 LogDebug(
"CheckSecondary") <<
"Secondary " << i <<
" (" << (*px)[
i] <<
", " 187 << (*py)[
i] <<
", " << (*pz)[
i] <<
", " 188 << (*mass)[
i] <<
")";
T getParameter(std::string const &) const
std::vector< std::string > * procs
T getUntrackedParameter(std::string const &, T const &) const
~CheckSecondary() override
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)
std::vector< double > * py
void update(const BeginOfEvent *evt) override
This routine will be called when the appropriate signal arrives.
CheckSecondary(const edm::ParameterSet &p)
std::vector< int > * procids
std::vector< double > * px
TreatSecondary * treatSecondary
std::vector< double > * mass