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/GlobalSystemOfUnits.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 }
TreatSecondary
Definition: TreatSecondary.h:16
mps_fire.i
i
Definition: mps_fire.py:428
TreatSecondary::tracks
std::vector< math::XYZTLorentzVector > tracks(const G4Step *step, std::string &procName, int &procID, bool &intr, double &deltaE, std::vector< int > &charges)
Definition: TreatSecondary.cc:46
MessageLogger.h
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
StoreSecondary::storeIt
bool storeIt
Definition: StoreSecondary.h:41
StoreSecondary::nHad
int nHad
Definition: StoreSecondary.h:40
StoreSecondary::~StoreSecondary
~StoreSecondary() override
Definition: StoreSecondary.cc:34
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
StoreSecondary::nsecs
std::vector< int > nsecs
Definition: StoreSecondary.h:43
BeginOfTrack.h
BeginOfTrack
Definition: BeginOfTrack.h:6
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
StoreSecondary::update
void update(const BeginOfEvent *evt) override
This routine will be called when the appropriate signal arrives.
Definition: StoreSecondary.cc:57
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
EgHLTOffHistBins_cfi.deltaE
deltaE
Definition: EgHLTOffHistBins_cfi.py:28
StoreSecondary::procs
std::vector< std::string > procs
Definition: StoreSecondary.h:44
StoreSecondary::secondaries
std::vector< math::XYZTLorentzVector > secondaries
Definition: StoreSecondary.h:42
BeginOfEvent.h
StoreSecondary::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: StoreSecondary.cc:36
StoreSecondary.h
createfilelist.int
int
Definition: createfilelist.py:10
BeginOfEvent
Definition: BeginOfEvent.h:6
edm::EventSetup
Definition: EventSetup.h:58
fileinputsource_cfi.sec
sec
Definition: fileinputsource_cfi.py:94
eostools.move
def move(src, dest)
Definition: eostools.py:511
TreatSecondary::initTrack
void initTrack(const G4Track *trk)
Definition: TreatSecondary.cc:35
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
StoreSecondary::StoreSecondary
StoreSecondary(const edm::ParameterSet &p)
Definition: StoreSecondary.cc:22
StoreSecondary::treatSecondary
TreatSecondary * treatSecondary
Definition: StoreSecondary.h:45
edm::Event
Definition: Event.h:73
TreatSecondary.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37