14 #include "CLHEP/Units/GlobalPhysicalConstants.h"
15 #include "CLHEP/Units/GlobalSystemOfUnits.h"
16 #include "G4HCofThisEvent.hh"
19 #include "G4VProcess.hh"
26 : treatSecondary(nullptr),
27 typeEnumerator(nullptr),
43 nsec =
new std::vector<int>();
44 px =
new std::vector<double>();
45 py =
new std::vector<double>();
46 pz =
new std::vector<double>();
47 mass =
new std::vector<double>();
48 deltae =
new std::vector<double>();
49 procids =
new std::vector<int>();
50 procs =
new std::vector<std::string>();
52 if (saveFile !=
"None") {
55 edm::LogInfo(
"CheckSecondary") <<
"Instantiate CheckSecondary with first"
56 <<
" hadronic interaction information"
57 <<
" to be saved in file " << saveFile;
60 edm::LogInfo(
"CheckSecondary") <<
"Instantiate CheckSecondary with first"
61 <<
" hadronic interaction information"
92 file =
new TFile(fileName.c_str(),
"RECREATE");
95 TTree *t1 =
new TTree(
"T1",
"Secondary Particle Information");
96 t1->Branch(
"SecondaryPx",
"std::vector<double>", &
px);
97 t1->Branch(
"SecondaryPy",
"std::vector<double>", &
py);
98 t1->Branch(
"SecondaryPz",
"std::vector<double>", &
pz);
99 t1->Branch(
"SecondaryMass",
"std::vector<double>", &
mass);
100 t1->Branch(
"NumberSecondaries",
"std::vector<int>", &
nsec);
101 t1->Branch(
"DeltaEinInteract",
"std::vector<double>", &
deltae);
102 t1->Branch(
"ProcessID",
"std::vector<int>", &
procids);
103 t1->Branch(
"ProcessNames",
"std::vector<std::string>", &
procs);
108 edm::LogInfo(
"CheckSecondary") <<
"Save the Secondary Tree " <<
tree->GetName() <<
" (" <<
tree <<
") in file "
109 <<
file->GetName() <<
" (" <<
file <<
")";
117 int iev = (*evt)()->GetEventID();
118 LogDebug(
"CheckSecondary") <<
"CheckSecondary::=====> Begin of event = " <<
iev;
131 const G4Track *thTk = (*trk)();
133 if (thTk->GetParentID() <= 0)
138 LogDebug(
"CheckSecondary") <<
"CheckSecondary:: Track " << thTk->GetTrackID() <<
" Parent " << thTk->GetParentID()
150 double pInit = (aStep->GetPreStepPoint()->GetMomentum()).
mag();
151 double pEnd = (aStep->GetPostStepPoint()->GetMomentum()).
mag();
153 int sec = (int)(tracks.size());
154 LogDebug(
"CheckSecondary") <<
"CheckSecondary:: Hadronic Interaction " <<
nHad <<
" of type " << name <<
" ID "
155 << procID <<
" with " << sec <<
" secondaries "
156 <<
" and Momentum (MeV/c) at start " << pInit <<
" and at end " << pEnd;
157 (*nsec).push_back(sec);
158 (*procs).push_back(name);
159 (*procids).push_back(procID);
160 (*deltae).push_back(deltaE);
162 for (
int i = 0;
i < sec;
i++) {
163 double m = tracks[
i].M();
166 (*px).push_back(tracks[
i].Px());
167 (*py).push_back(tracks[
i].Py());
168 (*pz).push_back(tracks[
i].Pz());
169 (*mass).push_back(m);
176 LogDebug(
"CheckSecondary") <<
"CheckSecondary::EndofEvent =====> Event " << (*evt)()->GetEventID() <<
" with "
177 << (*nsec).size() <<
" hadronic collisions with"
178 <<
" secondaries produced in each step";
179 for (
unsigned int i = 0;
i < (*nsec).size();
i++)
180 LogDebug(
"CheckSecondary") <<
" " << (*nsec)[
i] <<
" from " << (*procs)[
i] <<
" ID " << (*procids)[
i] <<
" ("
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] <<
", " << (*py)[
i] <<
", " << (*pz)[
i] <<
", "
187 << (*mass)[
i] <<
")";
std::vector< std::string > * procs
T getUntrackedParameter(std::string const &, T const &) const
~CheckSecondary() override
std::string processG4Name(int) const
std::vector< double > * pz
std::vector< double > * deltae
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
auto const & tracks
cannot be loose
std::vector< math::XYZTLorentzVector > tracks(const G4Step *step, std::string &procName, int &procID, bool &intr, double &deltaE, std::vector< int > &charges)
std::vector< int > * nsec
Log< level::Info, false > LogInfo
G4ProcessTypeEnumerator * typeEnumerator
TTree * bookTree(std::string)
T getParameter(std::string const &) const
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
HitContainer const *__restrict__ TkSoA const *__restrict__ Quality const *__restrict__ CAHitNtupletGeneratorKernelsGPU::HitToTuple const *__restrict__ int32_t int iev
std::vector< double > * px
TreatSecondary * treatSecondary
std::vector< double > * mass