CMS 3D CMS Logo

StoreSecondary.cc
Go to the documentation of this file.
3 
6 
9 
11 
12 #include <CLHEP/Units/GlobalPhysicalConstants.h>
13 #include <CLHEP/Units/SystemOfUnits.h>
14 #include "G4HCofThisEvent.hh"
15 #include "G4Step.hh"
16 #include "G4Track.hh"
17 
18 #include <cmath>
19 #include <iomanip>
20 #include <iostream>
21 
23  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("StoreSecondary");
24  treatSecondary = new TreatSecondary(m_p);
25 
26  produces<std::vector<math::XYZTLorentzVector>>("SecondaryMomenta");
27  produces<std::vector<int>>("SecondaryParticles");
28 
29  edm::LogInfo("CheckSecondary") << "Instantiate StoreSecondary to store "
30  << "secondaries after 1st hadronic inelastic"
31  << " interaction";
32 }
33 
35 
37  std::unique_ptr<std::vector<math::XYZTLorentzVector>> secMom(new std::vector<math::XYZTLorentzVector>);
38  *secMom = secondaries;
39  e.put(std::move(secMom), "SecondaryMomenta");
40 
41  std::unique_ptr<std::vector<int>> secNumber(new std::vector<int>);
42  *secNumber = nsecs;
43  e.put(std::move(secNumber), "SecondaryParticles");
44 
45  LogDebug("CheckSecondary") << "StoreSecondary:: Event " << e.id() << " with " << nsecs.size()
46  << " hadronic collisions with "
47  << "secondaries produced in each step";
48  for (unsigned int i = 0; i < nsecs.size(); i++) {
49  LogDebug("CheckSecondary") << " " << nsecs[i] << " from " << procs[i];
50  }
51  LogDebug("CheckSecondary") << " and " << secondaries.size() << " secondaries"
52  << " produced in the first interactions:";
53  for (unsigned int i = 0; i < secondaries.size(); i++)
54  LogDebug("CheckSecondary") << "Secondary " << i << " " << secondaries[i];
55 }
56 
58  nsecs.clear();
59  procs.clear();
60  secondaries.clear();
61 }
62 
64  const G4Track *thTk = (*trk)();
66  if (nsecs.empty() && thTk->GetParentID() <= 0)
67  storeIt = true;
68  else
69  storeIt = false;
70  nHad = 0;
71 }
72 
73 void StoreSecondary::update(const G4Step *aStep) {
75  int procID;
76  bool hadrInt;
77  double deltaE;
78  std::vector<int> charge;
79  std::vector<math::XYZTLorentzVector> tracks = treatSecondary->tracks(aStep, name, procID, hadrInt, deltaE, charge);
80  if (hadrInt) {
81  ++nHad;
82  if (storeIt) {
83  int sec = (int)(tracks.size());
84  nsecs.push_back(sec);
85  procs.push_back(name);
86  if (nHad == 1) {
87  for (int i = 0; i < sec; i++)
88  secondaries.push_back(tracks[i]);
89  }
90  }
91  }
92 }
~StoreSecondary() override
std::vector< int > nsecs
void update(const BeginOfEvent *evt) override
This routine will be called when the appropriate signal arrives.
Trktree trk
Definition: Trktree.cc:2
StoreSecondary(const edm::ParameterSet &p)
std::vector< math::XYZTLorentzVector > tracks(const G4Step *step, std::string &procName, int &procID, bool &intr, double &deltaE, std::vector< int > &charges)
std::vector< math::XYZTLorentzVector > secondaries
std::vector< std::string > procs
Log< level::Info, false > LogInfo
void initTrack(const G4Track *trk)
TreatSecondary * treatSecondary
void produce(edm::Event &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)