13 #include "CLHEP/Random/RandFlat.h" 27 theInputTag(pset.getParameter<
edm::InputTag>(
"input")),
28 theNeutronTimeCut(pset.getParameter<double>(
"neutronTimeCut")),
29 theTimeWindow(pset.getParameter<double>(
"timeWindow")),
30 theT0(pset.getParameter<double>(
"t0")),
33 useLocalDetId_(
true) {
36 if (writer ==
"ASCII") {
38 }
else if (writer ==
"ROOT") {
40 }
else if (writer ==
"EDM") {
41 produces<edm::PSimHitContainer>();
49 <<
"SubsystemNeutronWriter requires the RandomNumberGeneratorService\n" 50 "which is not present in the configuration file. You must add the service\n" 51 "in the configuration file or remove the modules that require it.";
65 edm::LogInfo(
"SubsystemNeutronWriter") <<
"SubsystemNeutronWriter Statistics:\n";
69 <<
" theEventOccupancy[" << mapItr->first <<
"] = " << mapItr->second <<
" / " <<
theNEvents <<
" / NCT \n";
74 CLHEP::HepRandomEngine* engine =
nullptr;
85 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 (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) {
110 sort(chamberHits.begin(), chamberHits.end(),
SortByTime());
112 float startTime = -1000.;
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";
134 <<
"starting neutron cluster at time " << startTime <<
" on detType " <<
chamberType;
136 adjust(hit, -1. * startTime, smearing);
137 cluster.push_back(hit);
141 if (!cluster.empty()) {
T getParameter(std::string const &) const
float tof() const
deprecated name for timeOfFlight()
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void initialize(int chamberType)
good practice to do once for each chamber type
~SubsystemNeutronWriter() override
destructor prints statistics on number of events written
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
Geom::Phi< T > phi() const
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
virtual void beginEvent(edm::Event &e, const edm::EventSetup &es)
virtual bool accept(const edm::PSimHitContainer &cluster) const =0
decides whether this cluster is good enough to be included
void adjust(PSimHit &h, float timeOffset, float smearing)
helper to add time offsets and local det ID
Geom::Theta< T > theta() const
Local3DPoint exitPoint() const
Exit point in the local Det frame.
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
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
void writeCluster(int chamberType, const edm::PSimHitContainer &cluster)
NeutronWriter * theHitWriter
virtual int chamberId(int globalDetId) const =0
void produce(edm::Event &e, edm::EventSetup const &c) override
float energyLoss() const
The energy deposit in the PSimHit, in ???.
StreamID streamID() const
unsigned int trackId() const
std::vector< PSimHit > PSimHitContainer
virtual int chamberType(int globalDetId) const =0
Local3DPoint entryPoint() const
Entry point in the local Det frame.
virtual int localDetId(int globalDetId) const =0
unsigned int detUnitId() const