13 #include "CLHEP/Random/RandFlat.h"
22 return (h1.
tof() < h2.
tof());
30 theInputTag(pset.getParameter<edm::
InputTag>(
"input")),
31 theNeutronTimeCut(pset.getParameter<double>(
"neutronTimeCut")),
32 theTimeWindow(pset.getParameter<double>(
"timeWindow")),
33 theT0(pset.getParameter<double>(
"t0")),
44 else if (writer ==
"ROOT")
48 else if (writer ==
"EDM")
50 produces<edm::PSimHitContainer>();
58 <<
"SubsystemNeutronWriter requires the RandomNumberGeneratorService\n"
59 "which is not present in the configuration file. You must add the service\n"
60 "in the configuration file or remove the modules that require it.";
81 edm::LogInfo(
"SubsystemNeutronWriter") <<
"SubsystemNeutronWriter Statistics:\n";
84 edm::LogInfo(
"SubsystemNeutronWriter") <<
" theEventOccupancy[" << mapItr->first <<
"] = "
85 << mapItr->second <<
" / " <<
theNEvents <<
" / NCT \n";
92 CLHEP::HepRandomEngine* engine =
nullptr;
103 map<int, edm::PSimHitContainer> hitsByChamber;
104 for(edm::PSimHitContainer::const_iterator hitItr = hits->begin();
105 hitItr != hits->end(); ++hitItr)
107 int chamberIndex =
chamberId(hitItr->detUnitId());
108 hitsByChamber[chamberIndex].push_back(*hitItr);
112 for(map<int, edm::PSimHitContainer>::iterator hitsByChamberItr = hitsByChamber.begin();
113 hitsByChamberItr != hitsByChamber.end(); ++hitsByChamberItr)
115 int chambertype =
chamberType(hitsByChamberItr->first);
116 writeHits(chambertype, hitsByChamberItr->second, engine);
131 CLHEP::HepRandomEngine* engine)
136 float startTime = -1000.;
138 for(
size_t i = 0;
i < chamberHits.size(); ++
i) {
140 float tof = hit.
tof();
142 <<
" at tof " << tof <<
" p " << hit.
pabs()
151 smearing += CLHEP::RandFlat::shoot(engine, 25.);
153 if(!cluster.empty()) {
154 LogDebug(
"SubsystemNeutronWriter") <<
"filling old cluster";
158 LogDebug(
"SubsystemNeutronWriter") <<
"starting neutron cluster at time " << startTime
161 adjust(hit, -1.*startTime, smearing);
162 cluster.push_back( hit );
166 if(!cluster.empty()) {
T getParameter(std::string const &) const
float tof() const
deprecated name for timeOfFlight()
virtual int chamberType(int globalDetId) const =0
virtual ~SubsystemNeutronWriter()
destructor prints statistics on number of events written
void initialize(int chamberType)
good practice to do once for each chamber type
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
virtual bool accept(const edm::PSimHitContainer &cluster) const =0
decides whether this cluster is good enough to be included
Geom::Phi< T > phi() const
virtual void beginEvent(edm::Event &e, const edm::EventSetup &es)
void adjust(PSimHit &h, float timeOffset, float smearing)
helper to add time offsets and local det ID
Geom::Theta< T > theta() const
virtual int localDetId(int globalDetId) const =0
Local3DPoint exitPoint() const
Exit point in the local Det frame.
virtual int chamberId(int globalDetId) const =0
float timeOfFlight() const
virtual void writeHits(int chamberType, edm::PSimHitContainer &chamberHits, CLHEP::HepRandomEngine *)
edm::InputTag theInputTag
bool operator()(const PSimHit &h1, const PSimHit &h2)
std::map< int, int > theCountPerChamberType
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
virtual void writeCluster(int detType, const edm::PSimHitContainer &simHits)=0
writes out a list of SimHits.
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual void initialize(int detType)
SubsystemNeutronWriter(edm::ParameterSet const &pset)
void updateCount(int chamberType)
updates the counter
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
void writeCluster(int chamberType, const edm::PSimHitContainer &cluster)
NeutronWriter * theHitWriter
float energyLoss() const
The energy deposit in the PSimHit, in ???.
StreamID streamID() const
unsigned int trackId() const
virtual void produce(edm::Event &e, edm::EventSetup const &c)
std::vector< PSimHit > PSimHitContainer
volatile std::atomic< bool > shutdown_flag false
Local3DPoint entryPoint() const
Entry point in the local Det frame.
unsigned int detUnitId() const