#include <SubsystemNeutronReader.h>
Public Member Functions | |
void | clear () |
void | generateChamberNoise (int chamberType, int chamberIndex, edm::PSimHitContainer &result) |
void | setRandomEngine (CLHEP::HepRandomEngine &engine) |
SubsystemNeutronReader (const edm::ParameterSet &pset) | |
virtual | ~SubsystemNeutronReader () |
Protected Member Functions | |
virtual int | detId (int chamberIndex, int localDetId)=0 |
Private Attributes | |
std::vector< int > | theChambersDone |
just makes sure chambers aren't done twice | |
float | theEndTime |
std::vector< double > | theEventOccupancy |
float | theEventsInWindow |
how many collsions happened between theStartTime and theEndTime | |
NeutronReader * | theHitReader |
float | theLuminosity |
in units of 10**34, set by Muon:NeutronLuminosity | |
CLHEP::RandFlat * | theRandFlat |
CLHEP::RandPoissonQ * | theRandPoisson |
float | theStartTime |
Definition at line 17 of file SubsystemNeutronReader.h.
SubsystemNeutronReader::SubsystemNeutronReader | ( | const edm::ParameterSet & | pset | ) |
the hits will be distributed flat in time between startTime and endTime eventOccupancy is the expected chamber occupancy from a single min bias event for each chamber type
Definition at line 13 of file SubsystemNeutronReader.cc.
References edm::ParameterSet::getParameter(), LaserDQM_cfg::input, matplotRender::reader, theEndTime, theEventsInWindow, theHitReader, theLuminosity, and theStartTime.
: theHitReader(0), theRandFlat(0), theRandPoisson(0), theLuminosity(pset.getParameter<double>("luminosity")), // in units of 10^34 theStartTime(pset.getParameter<double>("startTime")), theEndTime(pset.getParameter<double>("endTime")), theEventOccupancy(pset.getParameter<vector<double> >("eventOccupancy")) // TODO make map { // 17.3 collisions per live bx, 79.5% of bx live float collisionsPerCrossing = 13.75 * theLuminosity; int windowSize = (int)((theEndTime-theStartTime)/25.); theEventsInWindow = collisionsPerCrossing * windowSize; string reader = pset.getParameter<string>("reader"); edm::FileInPath input = pset.getParameter<edm::FileInPath>("input"); if(reader == "ASCII") { theHitReader = new AsciiNeutronReader(input.fullPath()); } else if (reader == "ROOT") { theHitReader = new RootNeutronReader(input.fullPath()); } }
SubsystemNeutronReader::~SubsystemNeutronReader | ( | ) | [virtual] |
Definition at line 39 of file SubsystemNeutronReader.cc.
References theHitReader, theRandFlat, and theRandPoisson.
{ delete theHitReader; delete theRandFlat; delete theRandPoisson; }
void SubsystemNeutronReader::clear | ( | void | ) | [inline] |
Definition at line 32 of file SubsystemNeutronReader.h.
References theChambersDone.
{theChambersDone.clear();}
virtual int SubsystemNeutronReader::detId | ( | int | chamberIndex, |
int | localDetId | ||
) | [protected, pure virtual] |
detector-specific way to get the global detector ID, given the local one.
Implemented in CSCNeutronReader.
Referenced by generateChamberNoise().
void SubsystemNeutronReader::generateChamberNoise | ( | int | chamberType, |
int | chamberIndex, | ||
edm::PSimHitContainer & | result | ||
) |
this class makes sure the same chamberIndex isn't called twice for an event
Definition at line 54 of file SubsystemNeutronReader.cc.
References detId(), PSimHit::detUnitId(), PSimHit::energyLoss(), PSimHit::entryPoint(), PSimHit::exitPoint(), spr::find(), i, PSimHit::pabs(), PSimHit::particleType(), PSimHit::phiAtEntry(), PSimHit::processType(), NeutronReader::readNextEvent(), theChambersDone, theEndTime, theEventOccupancy, theEventsInWindow, theHitReader, theRandFlat, theRandPoisson, theStartTime, PSimHit::thetaAtEntry(), PSimHit::tof(), and PSimHit::trackId().
{ // make sure this chamber hasn't been done before if(find(theChambersDone.begin(), theChambersDone.end(), chamberIndex) == theChambersDone.end()) { float meanNumberOfEvents = theEventOccupancy[chamberType-1] * theEventsInWindow; int nEventsToAdd = theRandPoisson->fire(meanNumberOfEvents); // LogDebug("NeutronReader") << "Number of neutron events to add: " //std::cout << "Number of neutron events to add for chamber type " << chamberType << " : " // << nEventsToAdd << " mean " << meanNumberOfEvents << std::endl; // << nEventsToAdd << " mean " << meanNumberOfEvents; for(int i = 0; i < nEventsToAdd; ++i) { // find the time for this event float timeOffset = theRandFlat->fire(theStartTime, theEndTime); vector<PSimHit> neutronHits; theHitReader->readNextEvent(chamberType, neutronHits); for( vector<PSimHit>::const_iterator neutronHitItr = neutronHits.begin(); neutronHitItr != neutronHits.end(); ++neutronHitItr) { const PSimHit & rawHit = *neutronHitItr; // do the time offset and local det id int det = detId(chamberIndex, rawHit.detUnitId()); PSimHit hit(rawHit.entryPoint(), rawHit.exitPoint(), rawHit.pabs(), rawHit.tof()+timeOffset, rawHit.energyLoss(), rawHit.particleType(), det, rawHit.trackId(), rawHit.thetaAtEntry(), rawHit.phiAtEntry(), rawHit.processType()); //std::cout << "NEWHIT " << hit << std::endl; result.push_back(hit); } } theChambersDone.push_back(chamberIndex); } }
void SubsystemNeutronReader::setRandomEngine | ( | CLHEP::HepRandomEngine & | engine | ) |
Definition at line 46 of file SubsystemNeutronReader.cc.
References theRandFlat, and theRandPoisson.
Referenced by CSCDigitizer::setRandomEngine().
{ theRandFlat = new CLHEP::RandFlat(engine); theRandPoisson = new CLHEP::RandPoissonQ(engine); }
std::vector<int> SubsystemNeutronReader::theChambersDone [private] |
just makes sure chambers aren't done twice
Definition at line 48 of file SubsystemNeutronReader.h.
Referenced by clear(), and generateChamberNoise().
float SubsystemNeutronReader::theEndTime [private] |
Definition at line 54 of file SubsystemNeutronReader.h.
Referenced by generateChamberNoise(), and SubsystemNeutronReader().
std::vector<double> SubsystemNeutronReader::theEventOccupancy [private] |
Definition at line 58 of file SubsystemNeutronReader.h.
Referenced by generateChamberNoise().
float SubsystemNeutronReader::theEventsInWindow [private] |
how many collsions happened between theStartTime and theEndTime
Definition at line 56 of file SubsystemNeutronReader.h.
Referenced by generateChamberNoise(), and SubsystemNeutronReader().
Definition at line 42 of file SubsystemNeutronReader.h.
Referenced by generateChamberNoise(), SubsystemNeutronReader(), and ~SubsystemNeutronReader().
float SubsystemNeutronReader::theLuminosity [private] |
in units of 10**34, set by Muon:NeutronLuminosity
Definition at line 52 of file SubsystemNeutronReader.h.
Referenced by SubsystemNeutronReader().
CLHEP::RandFlat* SubsystemNeutronReader::theRandFlat [private] |
Definition at line 44 of file SubsystemNeutronReader.h.
Referenced by generateChamberNoise(), setRandomEngine(), and ~SubsystemNeutronReader().
CLHEP::RandPoissonQ* SubsystemNeutronReader::theRandPoisson [private] |
Definition at line 45 of file SubsystemNeutronReader.h.
Referenced by generateChamberNoise(), setRandomEngine(), and ~SubsystemNeutronReader().
float SubsystemNeutronReader::theStartTime [private] |
Definition at line 53 of file SubsystemNeutronReader.h.
Referenced by generateChamberNoise(), and SubsystemNeutronReader().