Accumulator to perform digitisation on the strip tracker sim hits. More...
#include <SiStripDigitizer.h>
Public Member Functions | |
virtual void | accumulate (edm::Event const &e, edm::EventSetup const &c) override |
virtual void | accumulate (PileUpEventPrincipal const &e, edm::EventSetup const &c) override |
virtual void | finalizeEvent (edm::Event &e, edm::EventSetup const &c) override |
virtual void | initializeEvent (edm::Event const &e, edm::EventSetup const &c) override |
SiStripDigitizer (const edm::ParameterSet &conf, edm::EDProducer &mixMod) | |
virtual | ~SiStripDigitizer () |
Private Types | |
typedef std::map< unsigned int, std::vector< std::pair< const PSimHit *, int > >, std::less < unsigned int > > | simhit_map |
typedef simhit_map::iterator | simhit_map_iterator |
typedef std::vector< std::string > | vstring |
Private Member Functions | |
void | accumulateStripHits (edm::Handle< std::vector< PSimHit > >, const TrackerTopology *tTopo, size_t globalSimHitIndex) |
Private Attributes | |
std::map< std::string, size_t > | crossingSimHitIndexOffset_ |
Offset to add to the index of each sim hit to account for which crossing it's in. | |
std::map< unsigned int, StripGeomDetUnit * > | detectorUnits |
const std::string | gainLabel |
const std::string | geometryType |
const std::string | hitsProducer |
const bool | makeDigiSimLinks_ |
Whether or not to create the association to sim truth collection. Set in configuration. | |
edm::ESHandle< TrackerGeometry > | pDD |
const std::string | PRDigi |
edm::ESHandle< MagneticField > | pSetup |
CLHEP::HepRandomEngine * | rndEngine |
const std::string | SCDigi |
std::map< uint32_t, std::vector< int > > | theDetIdList |
std::unique_ptr < SiStripDigitizerAlgorithm > | theDigiAlgo |
const vstring | trackerContainers |
const bool | useConfFromDB |
const std::string | VRDigi |
const bool | zeroSuppression |
const std::string | ZSDigi |
Accumulator to perform digitisation on the strip tracker sim hits.
Definition at line 41 of file SiStripDigitizer.h.
typedef std::map<unsigned int, std::vector<std::pair<const PSimHit*, int> >,std::less<unsigned int> > SiStripDigitizer::simhit_map [private] |
Definition at line 56 of file SiStripDigitizer.h.
typedef simhit_map::iterator SiStripDigitizer::simhit_map_iterator [private] |
Definition at line 57 of file SiStripDigitizer.h.
typedef std::vector<std::string> SiStripDigitizer::vstring [private] |
Definition at line 55 of file SiStripDigitizer.h.
SiStripDigitizer::SiStripDigitizer | ( | const edm::ParameterSet & | conf, |
edm::EDProducer & | mixMod | ||
) | [explicit] |
Definition at line 60 of file SiStripDigitizer.cc.
References Exception, edm::Service< T >::isAvailable(), PRDigi, rndEngine, SCDigi, AlCaHLTBitMon_QueryRunRegistry::string, theDigiAlgo, VRDigi, and ZSDigi.
: gainLabel(conf.getParameter<std::string>("Gain")), hitsProducer(conf.getParameter<std::string>("hitsProducer")), trackerContainers(conf.getParameter<std::vector<std::string> >("ROUList")), ZSDigi(conf.getParameter<edm::ParameterSet>("DigiModeList").getParameter<std::string>("ZSDigi")), SCDigi(conf.getParameter<edm::ParameterSet>("DigiModeList").getParameter<std::string>("SCDigi")), VRDigi(conf.getParameter<edm::ParameterSet>("DigiModeList").getParameter<std::string>("VRDigi")), PRDigi(conf.getParameter<edm::ParameterSet>("DigiModeList").getParameter<std::string>("PRDigi")), geometryType(conf.getParameter<std::string>("GeometryType")), useConfFromDB(conf.getParameter<bool>("TrackerConfigurationFromDB")), zeroSuppression(conf.getParameter<bool>("ZeroSuppression")), makeDigiSimLinks_(conf.getUntrackedParameter<bool>("makeDigiSimLinks", false)) { const std::string alias("simSiStripDigis"); mixMod.produces<edm::DetSetVector<SiStripDigi> >(ZSDigi).setBranchAlias(ZSDigi); mixMod.produces<edm::DetSetVector<SiStripRawDigi> >(SCDigi).setBranchAlias(alias + SCDigi); mixMod.produces<edm::DetSetVector<SiStripRawDigi> >(VRDigi).setBranchAlias(alias + VRDigi); mixMod.produces<edm::DetSetVector<SiStripRawDigi> >(PRDigi).setBranchAlias(alias + PRDigi); mixMod.produces<edm::DetSetVector<StripDigiSimLink> >().setBranchAlias(alias + "siStripDigiSimLink"); edm::Service<edm::RandomNumberGenerator> rng; if ( ! rng.isAvailable()) { throw cms::Exception("Configuration") << "SiStripDigitizer requires the RandomNumberGeneratorService\n" "which is not present in the configuration file. You must add the service\n" "in the configuration file or remove the modules that require it."; } rndEngine = &(rng->getEngine()); theDigiAlgo.reset(new SiStripDigitizerAlgorithm(conf,(*rndEngine))); }
SiStripDigitizer::~SiStripDigitizer | ( | ) | [virtual] |
Definition at line 94 of file SiStripDigitizer.cc.
{ }
void SiStripDigitizer::accumulate | ( | edm::Event const & | e, |
edm::EventSetup const & | c | ||
) | [override, virtual] |
Implements DigiAccumulatorMixMod.
Definition at line 126 of file SiStripDigitizer.cc.
References accumulateStripHits(), crossingSimHitIndexOffset_, edm::InputTag::encode(), edm::EventSetup::get(), edm::Event::getByLabel(), hitsProducer, i, edm::HandleBase::isValid(), edm::ESHandle< T >::product(), trackerHits::simHits, GlobalPosition_Frontier_DevDB_cff::tag, and trackerContainers.
{ //Retrieve tracker topology from geometry edm::ESHandle<TrackerTopology> tTopoHand; iSetup.get<IdealGeometryRecord>().get(tTopoHand); const TrackerTopology *tTopo=tTopoHand.product(); // Step A: Get Inputs for(vstring::const_iterator i = trackerContainers.begin(), iEnd = trackerContainers.end(); i != iEnd; ++i) { edm::Handle<std::vector<PSimHit> > simHits; edm::InputTag tag(hitsProducer, *i); iEvent.getByLabel(tag, simHits); accumulateStripHits(simHits,tTopo,crossingSimHitIndexOffset_[tag.encode()]); // Now that the hits have been processed, I'll add the amount of hits in this crossing on to // the global counter. Next time accumulateStripHits() is called it will count the sim hits // as though they were on the end of this collection. // Note that this is only used for creating digi-sim links (if configured to do so). if( simHits.isValid() ) crossingSimHitIndexOffset_[tag.encode()]+=simHits->size(); } }
void SiStripDigitizer::accumulate | ( | PileUpEventPrincipal const & | e, |
edm::EventSetup const & | c | ||
) | [override, virtual] |
Implements DigiAccumulatorMixMod.
Definition at line 148 of file SiStripDigitizer.cc.
References accumulateStripHits(), crossingSimHitIndexOffset_, edm::InputTag::encode(), edm::EventSetup::get(), PileUpEventPrincipal::getByLabel(), hitsProducer, i, edm::HandleBase::isValid(), edm::ESHandle< T >::product(), trackerHits::simHits, GlobalPosition_Frontier_DevDB_cff::tag, and trackerContainers.
{ edm::ESHandle<TrackerTopology> tTopoHand; iSetup.get<IdealGeometryRecord>().get(tTopoHand); const TrackerTopology *tTopo=tTopoHand.product(); // Step A: Get Inputs for(vstring::const_iterator i = trackerContainers.begin(), iEnd = trackerContainers.end(); i != iEnd; ++i) { edm::Handle<std::vector<PSimHit> > simHits; edm::InputTag tag(hitsProducer, *i); iEvent.getByLabel(tag, simHits); accumulateStripHits(simHits,tTopo,crossingSimHitIndexOffset_[tag.encode()]); // Now that the hits have been processed, I'll add the amount of hits in this crossing on to // the global counter. Next time accumulateStripHits() is called it will count the sim hits // as though they were on the end of this collection. // Note that this is only used for creating digi-sim links (if configured to do so). if( simHits.isValid() ) crossingSimHitIndexOffset_[tag.encode()]+=simHits->size(); } }
void SiStripDigitizer::accumulateStripHits | ( | edm::Handle< std::vector< PSimHit > > | hSimHits, |
const TrackerTopology * | tTopo, | ||
size_t | globalSimHitIndex | ||
) | [private] |
Definition at line 97 of file SiStripDigitizer.cc.
References detectorUnits, LogDebug, GloballyPositioned< T >::position(), pSetup, trackerHits::simHits, DetId::subdetId(), GeomDet::surface(), StripSubdetector::TEC, theDigiAlgo, StripSubdetector::TIB, StripSubdetector::TID, and StripSubdetector::TOB.
Referenced by accumulate().
{ // globalSimHitIndex is the index the sim hit will have when it is put in a collection // of sim hits for all crossings. This is only used when creating digi-sim links if // configured to do so. if(hSimHits.isValid()) { std::set<unsigned int> detIds; std::vector<PSimHit> const& simHits = *hSimHits.product(); for(std::vector<PSimHit>::const_iterator it = simHits.begin(), itEnd = simHits.end(); it != itEnd; ++it, ++globalSimHitIndex ) { unsigned int detId = (*it).detUnitId(); if(detIds.insert(detId).second) { // The insert succeeded, so this detector element has not yet been processed. unsigned int isub = DetId(detId).subdetId(); if((isub == StripSubdetector::TIB) || (isub == StripSubdetector::TID) || (isub == StripSubdetector::TOB) || (isub == StripSubdetector::TEC)) { StripGeomDetUnit* stripdet = detectorUnits[detId]; //access to magnetic field in global coordinates GlobalVector bfield = pSetup->inTesla(stripdet->surface().position()); LogDebug ("Digitizer ") << "B-field(T) at " << stripdet->surface().position() << "(cm): " << pSetup->inTesla(stripdet->surface().position()); theDigiAlgo->accumulateSimHits(it, itEnd, globalSimHitIndex, stripdet, bfield, tTopo); } } } // end of loop over sim hits } }
void SiStripDigitizer::finalizeEvent | ( | edm::Event & | e, |
edm::EventSetup const & | c | ||
) | [override, virtual] |
Implements DigiAccumulatorMixMod.
Definition at line 213 of file SiStripDigitizer.cc.
References gainLabel, edm::EventSetup::get(), makeDigiSimLinks_, convertSQLitetoXML_cfg::output, pDD, PRDigi, edm::Event::put(), SCDigi, theDetIdList, theDigiAlgo, useConfFromDB, VRDigi, zeroSuppression, and ZSDigi.
{ edm::ESHandle<SiStripGain> gainHandle; edm::ESHandle<SiStripNoises> noiseHandle; edm::ESHandle<SiStripThreshold> thresholdHandle; edm::ESHandle<SiStripPedestals> pedestalHandle; iSetup.get<SiStripGainSimRcd>().get(gainLabel,gainHandle); iSetup.get<SiStripNoisesRcd>().get(noiseHandle); iSetup.get<SiStripThresholdRcd>().get(thresholdHandle); iSetup.get<SiStripPedestalsRcd>().get(pedestalHandle); std::vector<edm::DetSet<SiStripDigi> > theDigiVector; std::vector<edm::DetSet<SiStripRawDigi> > theRawDigiVector; std::auto_ptr< edm::DetSetVector<StripDigiSimLink> > pOutputDigiSimLink( new edm::DetSetVector<StripDigiSimLink> ); // Step B: LOOP on StripGeomDetUnit theDigiVector.reserve(10000); theDigiVector.clear(); for(TrackingGeometry::DetUnitContainer::const_iterator iu = pDD->detUnits().begin(); iu != pDD->detUnits().end(); iu ++){ if(useConfFromDB){ //apply the cable map _before_ digitization: consider only the detis that are connected if(theDetIdList.find((*iu)->geographicalId().rawId())==theDetIdList.end()) continue; } StripGeomDetUnit* sgd = dynamic_cast<StripGeomDetUnit*>((*iu)); if (sgd != 0){ edm::DetSet<SiStripDigi> collectorZS((*iu)->geographicalId().rawId()); edm::DetSet<SiStripRawDigi> collectorRaw((*iu)->geographicalId().rawId()); edm::DetSet<StripDigiSimLink> collectorLink((*iu)->geographicalId().rawId()); theDigiAlgo->digitize(collectorZS,collectorRaw,collectorLink,sgd, gainHandle,thresholdHandle,noiseHandle,pedestalHandle); if(zeroSuppression){ if(collectorZS.data.size()>0){ theDigiVector.push_back(collectorZS); if( !collectorLink.data.empty() ) pOutputDigiSimLink->insert(collectorLink); } }else{ if(collectorRaw.data.size()>0){ theRawDigiVector.push_back(collectorRaw); if( !collectorLink.data.empty() ) pOutputDigiSimLink->insert(collectorLink); } } } } if(zeroSuppression){ // Step C: create output collection std::auto_ptr<edm::DetSetVector<SiStripRawDigi> > output_virginraw(new edm::DetSetVector<SiStripRawDigi>()); std::auto_ptr<edm::DetSetVector<SiStripRawDigi> > output_scopemode(new edm::DetSetVector<SiStripRawDigi>()); std::auto_ptr<edm::DetSetVector<SiStripRawDigi> > output_processedraw(new edm::DetSetVector<SiStripRawDigi>()); std::auto_ptr<edm::DetSetVector<SiStripDigi> > output(new edm::DetSetVector<SiStripDigi>(theDigiVector) ); // Step D: write output to file iEvent.put(output, ZSDigi); iEvent.put(output_scopemode, SCDigi); iEvent.put(output_virginraw, VRDigi); iEvent.put(output_processedraw, PRDigi); if( makeDigiSimLinks_ ) iEvent.put( pOutputDigiSimLink ); // The previous EDProducer didn't name this collection so I won't either }else{ // Step C: create output collection std::auto_ptr<edm::DetSetVector<SiStripRawDigi> > output_virginraw(new edm::DetSetVector<SiStripRawDigi>(theRawDigiVector)); std::auto_ptr<edm::DetSetVector<SiStripRawDigi> > output_scopemode(new edm::DetSetVector<SiStripRawDigi>()); std::auto_ptr<edm::DetSetVector<SiStripRawDigi> > output_processedraw(new edm::DetSetVector<SiStripRawDigi>()); std::auto_ptr<edm::DetSetVector<SiStripDigi> > output(new edm::DetSetVector<SiStripDigi>() ); // Step D: write output to file iEvent.put(output, ZSDigi); iEvent.put(output_scopemode, SCDigi); iEvent.put(output_virginraw, VRDigi); iEvent.put(output_processedraw, PRDigi); if( makeDigiSimLinks_ ) iEvent.put( pOutputDigiSimLink ); // The previous EDProducer didn't name this collection so I won't either } }
void SiStripDigitizer::initializeEvent | ( | edm::Event const & | e, |
edm::EventSetup const & | c | ||
) | [override, virtual] |
Implements DigiAccumulatorMixMod.
Definition at line 170 of file SiStripDigitizer.cc.
References crossingSimHitIndexOffset_, detectorUnits, geometryType, edm::EventSetup::get(), pDD, pSetup, DetId::subdetId(), StripSubdetector::TEC, theDetIdList, theDigiAlgo, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, and useConfFromDB.
{ // Make sure that the first crossing processed starts indexing the sim hits from zero. // This variable is used so that the sim hits from all crossing frames have sequential // indices used to create the digi-sim link (if configured to do so) rather than starting // from zero for each crossing. crossingSimHitIndexOffset_.clear(); // Step A: Get Inputs if(useConfFromDB){ edm::ESHandle<SiStripDetCabling> detCabling; iSetup.get<SiStripDetCablingRcd>().get(detCabling); detCabling->addConnected(theDetIdList); } theDigiAlgo->initializeEvent(iSetup); iSetup.get<TrackerDigiGeometryRecord>().get(geometryType,pDD); iSetup.get<IdealMagneticFieldRecord>().get(pSetup); // FIX THIS! We only need to clear and (re)fill detectorUnits when the geometry type IOV changes. Use ESWatcher to determine this. bool changes = true; if(changes) { // Replace with ESWatcher detectorUnits.clear(); } for(TrackingGeometry::DetUnitContainer::const_iterator iu = pDD->detUnits().begin(); iu != pDD->detUnits().end(); ++iu) { unsigned int detId = (*iu)->geographicalId().rawId(); DetId idet=DetId(detId); unsigned int isub=idet.subdetId(); if((isub == StripSubdetector::TIB) || (isub == StripSubdetector::TID) || (isub == StripSubdetector::TOB) || (isub == StripSubdetector::TEC)) { StripGeomDetUnit* stripdet = dynamic_cast<StripGeomDetUnit*>((*iu)); assert(stripdet != 0); if(changes) { // Replace with ESWatcher detectorUnits.insert(std::make_pair(detId, stripdet)); } theDigiAlgo->initializeDetUnit(stripdet, iSetup); } } }
std::map<std::string,size_t> SiStripDigitizer::crossingSimHitIndexOffset_ [private] |
Offset to add to the index of each sim hit to account for which crossing it's in.
I need to know what each sim hit index will be when the hits from all crossing frames are merged into one collection (assuming the MixingModule is configured to create the crossing frame for all sim hits). To do this I'll record how many hits were in each crossing, and then add that on to the index for a given hit in a given crossing. This assumes that the crossings are processed in the same order here as they are put into the crossing frame, which I'm pretty sure is true.
The key is the name of the sim hit collection.
Definition at line 78 of file SiStripDigitizer.h.
Referenced by accumulate(), and initializeEvent().
std::map<unsigned int, StripGeomDetUnit*> SiStripDigitizer::detectorUnits [private] |
Definition at line 84 of file SiStripDigitizer.h.
Referenced by accumulateStripHits(), and initializeEvent().
const std::string SiStripDigitizer::gainLabel [private] |
Definition at line 59 of file SiStripDigitizer.h.
Referenced by finalizeEvent().
const std::string SiStripDigitizer::geometryType [private] |
Definition at line 66 of file SiStripDigitizer.h.
Referenced by initializeEvent().
const std::string SiStripDigitizer::hitsProducer [private] |
Definition at line 60 of file SiStripDigitizer.h.
Referenced by accumulate().
const bool SiStripDigitizer::makeDigiSimLinks_ [private] |
Whether or not to create the association to sim truth collection. Set in configuration.
Definition at line 69 of file SiStripDigitizer.h.
Referenced by finalizeEvent().
edm::ESHandle<TrackerGeometry> SiStripDigitizer::pDD [private] |
Definition at line 82 of file SiStripDigitizer.h.
Referenced by finalizeEvent(), and initializeEvent().
const std::string SiStripDigitizer::PRDigi [private] |
Definition at line 65 of file SiStripDigitizer.h.
Referenced by finalizeEvent(), and SiStripDigitizer().
edm::ESHandle<MagneticField> SiStripDigitizer::pSetup [private] |
Definition at line 83 of file SiStripDigitizer.h.
Referenced by accumulateStripHits(), and initializeEvent().
CLHEP::HepRandomEngine* SiStripDigitizer::rndEngine [private] |
Definition at line 86 of file SiStripDigitizer.h.
Referenced by SiStripDigitizer().
const std::string SiStripDigitizer::SCDigi [private] |
Definition at line 63 of file SiStripDigitizer.h.
Referenced by finalizeEvent(), and SiStripDigitizer().
std::map<uint32_t, std::vector<int> > SiStripDigitizer::theDetIdList [private] |
Definition at line 81 of file SiStripDigitizer.h.
Referenced by finalizeEvent(), and initializeEvent().
std::unique_ptr<SiStripDigitizerAlgorithm> SiStripDigitizer::theDigiAlgo [private] |
Definition at line 80 of file SiStripDigitizer.h.
Referenced by accumulateStripHits(), finalizeEvent(), initializeEvent(), and SiStripDigitizer().
const vstring SiStripDigitizer::trackerContainers [private] |
Definition at line 61 of file SiStripDigitizer.h.
Referenced by accumulate().
const bool SiStripDigitizer::useConfFromDB [private] |
Definition at line 67 of file SiStripDigitizer.h.
Referenced by finalizeEvent(), and initializeEvent().
const std::string SiStripDigitizer::VRDigi [private] |
Definition at line 64 of file SiStripDigitizer.h.
Referenced by finalizeEvent(), and SiStripDigitizer().
const bool SiStripDigitizer::zeroSuppression [private] |
Definition at line 68 of file SiStripDigitizer.h.
Referenced by finalizeEvent().
const std::string SiStripDigitizer::ZSDigi [private] |
Definition at line 62 of file SiStripDigitizer.h.
Referenced by finalizeEvent(), and SiStripDigitizer().