58 #include "CLHEP/Random/RandFlat.h" 61 : gainLabel(conf.getParameter<
std::
string>(
"Gain")),
63 trackerContainers(conf.getParameter<
std::vector<
std::
string>>(
"ROUList")),
69 useConfFromDB(conf.getParameter<
bool>(
"TrackerConfigurationFromDB")),
70 zeroSuppression(conf.getParameter<
bool>(
"ZeroSuppression")),
71 makeDigiSimLinks_(conf.getUntrackedParameter<
bool>(
"makeDigiSimLinks",
false)),
72 includeAPVSimulation_(conf.getParameter<
bool>(
"includeAPVSimulation")),
73 fracOfEventsToSimAPV_(conf.getParameter<double>(
"fracOfEventsToSimAPV")) {
81 .setBranchAlias(alias +
"StripAmplitudesPostAPV");
85 mixMod.
produces<
bool>(
"SimulatedAPVDynamicGain").setBranchAlias(alias +
"SimulatedAPVDynamicGain");
86 mixMod.
produces<std::vector<std::pair<int, std::bitset<6>>>>(
"AffectedAPVList").setBranchAlias(alias +
"AffectedAPV");
92 if (!rng.isAvailable()) {
94 <<
"SiStripDigitizer requires the RandomNumberGeneratorService\n" 95 "which is not present in the configuration file. You must add the service\n" 96 "in the configuration file or remove the modules that require it.";
106 size_t globalSimHitIndex,
107 const unsigned int tofBin) {
112 if (hSimHits.isValid()) {
113 std::set<unsigned int> detIds;
114 std::vector<PSimHit>
const&
simHits = *hSimHits.product();
115 for (std::vector<PSimHit>::const_iterator it = simHits.begin(), itEnd = simHits.end(); it != itEnd;
116 ++it, ++globalSimHitIndex) {
117 unsigned int detId = (*it).detUnitId();
118 if (detIds.insert(detId).second) {
125 LogDebug(
"Digitizer ") <<
"B-field(T) at " << stripdet->surface().position()
126 <<
"(cm): " <<
pSetup->
inTesla(stripdet->surface().position());
146 if (trackerContainer.find(
std::string(
"HighTof")) != std::string::npos)
175 if (trackerContainer.find(
std::string(
"HighTof")) != std::string::npos)
219 unsigned int detId = iu->geographicalId().rawId();
220 if (iu->type().isTrackerStrip()) {
222 assert(stripdet !=
nullptr);
242 std::unique_ptr<bool> simulateAPVInThisEvent = std::make_unique<bool>(
false);
245 *simulateAPVInThisEvent =
true;
249 std::vector<edm::DetSet<SiStripDigi>> theDigiVector;
250 std::vector<edm::DetSet<SiStripRawDigi>> theRawDigiVector;
261 theDigiVector.reserve(10000);
262 theDigiVector.clear();
271 if (sgd !=
nullptr) {
279 unsigned int detID = sgd->geographicalId().rawId();
284 collectorStripAmplitudes,
285 collectorStripAmplitudesPostAPV,
286 collectorStripAPVBaselines,
293 *simulateAPVInThisEvent,
294 apvSimulationParametersHandle,
299 if ( !collectorStripAmplitudes.data.empty() ) theStripAmplitudeVector->insert(collectorStripAmplitudes);
300 if ( !collectorStripAmplitudesPostAPV.data.empty() ) theStripAmplitudeVectorPostAPV->insert(collectorStripAmplitudesPostAPV);
301 if ( !collectorStripAPVBaselines.data.empty() ) theStripAPVBaselines->insert(collectorStripAPVBaselines);
304 if (!collectorZS.data.empty()) {
305 theDigiVector.push_back(collectorZS);
306 if (!collectorLink.data.empty())
307 pOutputDigiSimLink->insert(collectorLink);
310 if (!collectorRaw.data.empty()) {
311 theRawDigiVector.push_back(collectorRaw);
312 if (!collectorLink.data.empty())
313 pOutputDigiSimLink->insert(collectorLink);
324 std::unique_ptr<std::vector<std::pair<int, std::bitset<6>>>> AffectedAPVList(
331 iEvent.
put(
std::move(theStripAmplitudeVector),
"StripAmplitudes");
332 iEvent.
put(
std::move(theStripAmplitudeVectorPostAPV),
"StripAmplitudesPostAPV");
333 iEvent.
put(
std::move(theStripAPVBaselines),
"StripAPVBaselines");
335 iEvent.
put(
std::move(AffectedAPVList),
"AffectedAPVList");
336 iEvent.
put(
std::move(simulateAPVInThisEvent),
"SimulatedAPVDynamicGain");
342 std::unique_ptr<edm::DetSetVector<SiStripRawDigi>> output_virginraw(
352 iEvent.
put(
std::move(theStripAmplitudeVector),
"StripAmplitudes");
353 iEvent.
put(
std::move(theStripAmplitudeVectorPostAPV),
"StripAmplitudesPostAPV");
354 iEvent.
put(
std::move(theStripAPVBaselines),
"StripAPVBaselines");
356 iEvent.
put(
std::move(simulateAPVInThisEvent),
"SimulatedAPVDynamicGain");
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
const vstring trackerContainers
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::ESHandle< TrackerGeometry > pDD
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
const bool zeroSuppression
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
const std::string hitsProducer
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
void accumulate(edm::Event const &e, edm::EventSetup const &c) override
std::map< unsigned int, StripGeomDetUnit const * > detectorUnits
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
std::map< uint32_t, std::vector< int > > theDetIdList
CLHEP::HepRandomEngine * randomEngine_
const bool includeAPVSimulation_
void accumulateStripHits(edm::Handle< std::vector< PSimHit >>, const TrackerTopology *tTopo, size_t globalSimHitIndex, const unsigned int tofBin)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
bool isTrackerStrip(GeomDetEnumerators::SubDetector m)
~SiStripDigitizer() override
std::unique_ptr< SiStripDigitizerAlgorithm > theDigiAlgo
edm::ESHandle< MagneticField > pSetup
const std::string geometryType
std::vector< std::pair< int, std::bitset< 6 > > > theAffectedAPVvector
const double fracOfEventsToSimAPV_
Whether or not to create the association to sim truth collection. Set in configuration.
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
StreamID streamID() const
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. ...
SiStripDigitizer(const edm::ParameterSet &conf, edm::ProducerBase &mixMod, edm::ConsumesCollector &iC)
void addConnected(std::map< uint32_t, std::vector< int >> &) const
const bool makeDigiSimLinks_
T const * product() const
const std::string gainLabel
std::unique_ptr< PileupMixingContent > PileupInfo_