13 #include "CLHEP/Random/RandFlat.h" 25 : theHitWriter(nullptr),
28 theNeutronTimeCut(
pset.getParameter<double>(
"neutronTimeCut")),
29 theTimeWindow(
pset.getParameter<double>(
"timeWindow")),
30 theT0(
pset.getParameter<double>(
"t0")),
34 useLocalDetId_(
true) {
35 string writer =
pset.getParameter<
string>(
"writer");
36 string output =
pset.getParameter<
string>(
"output");
39 }
else if (
writer ==
"ROOT") {
41 }
else if (
writer ==
"EDM") {
42 produces<edm::PSimHitContainer>();
50 <<
"SubsystemNeutronWriter requires the RandomNumberGeneratorService\n" 51 "which is not present in the configuration file. You must add the service\n" 52 "in the configuration file or remove the modules that require it.";
66 edm::LogInfo(
"SubsystemNeutronWriter") <<
"SubsystemNeutronWriter Statistics:\n";
70 <<
" theEventOccupancy[" << mapItr->first <<
"] = " << mapItr->second <<
" / " <<
theNEvents <<
" / NCT \n";
75 CLHEP::HepRandomEngine* engine =
nullptr;
85 std::map<int, edm::PSimHitContainer> hitsByChamber;
86 for (edm::PSimHitContainer::const_iterator hitItr =
hits->begin(); hitItr !=
hits->end(); ++hitItr) {
87 int chamberIndex =
chamberId(hitItr->detUnitId());
88 hitsByChamber[chamberIndex].push_back(*hitItr);
92 for (std::map<int, edm::PSimHitContainer>::iterator hitsByChamberItr = hitsByChamber.begin();
93 hitsByChamberItr != hitsByChamber.end();
95 int chambertype =
chamberType(hitsByChamberItr->first);
96 writeHits(chambertype, hitsByChamberItr->second, engine);
109 CLHEP::HepRandomEngine* engine) {
114 for (
size_t i = 0;
i < chamberHits.size(); ++
i) {
116 float tof =
hit.tof();
117 LogDebug(
"SubsystemNeutronWriter") <<
"found hit from part type " <<
hit.particleType() <<
" at tof " << tof
118 <<
" p " <<
hit.pabs() <<
" on det " <<
hit.detUnitId() <<
" chamber type " 126 smearing += CLHEP::RandFlat::shoot(engine, 25.);
128 if (!cluster.empty()) {
129 LogDebug(
"SubsystemNeutronWriter") <<
"filling old cluster";
137 cluster.push_back(
hit);
141 if (!cluster.empty()) {
155 float htime =
h.timeOfFlight() +
timeOffset + smearing;
157 if (
h.timeOfFlight() > 1.E+6) {
168 h.momentumAtEntry().theta(),
169 h.momentumAtEntry().phi());
virtual int chamberType(int globalDetId) const =0
void initialize(int chamberType)
good practice to do once for each chamber type
~SubsystemNeutronWriter() override
destructor prints statistics on number of events written
virtual bool accept(const edm::PSimHitContainer &cluster) const =0
decides whether this cluster is good enough to be included
const double theTimeWindow
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
virtual void beginEvent(edm::Event &e, const edm::EventSetup &es)
const double theNeutronTimeCut
void adjust(PSimHit &h, float timeOffset, float smearing)
helper to add time offsets and local det ID
virtual int localDetId(int globalDetId) const =0
virtual int chamberId(int globalDetId) const =0
virtual void writeHits(int chamberType, edm::PSimHitContainer &chamberHits, CLHEP::HepRandomEngine *)
const edm::EDGetTokenT< edm::PSimHitContainer > hitToken_
bool operator()(const PSimHit &h1, const PSimHit &h2)
std::map< int, int > theCountPerChamberType
virtual void writeCluster(int detType, const edm::PSimHitContainer &simHits)=0
writes out a list of SimHits.
virtual void initialize(int detType)
Log< level::Info, false > LogInfo
SubsystemNeutronWriter(edm::ParameterSet const &pset)
void updateCount(int chamberType)
updates the counter
float tof() const
deprecated name for timeOfFlight()
void writeCluster(int chamberType, const edm::PSimHitContainer &cluster)
NeutronWriter * theHitWriter
void produce(edm::Event &e, edm::EventSetup const &c) override
std::vector< PSimHit > PSimHitContainer
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.