57 #include "CLHEP/Random/RandFlat.h" 62 : gainLabel(conf.getParameter<
std::
string>(
"Gain")),
64 trackerContainers(conf.getParameter<
std::vector<
std::
string>>(
"ROUList")),
70 useConfFromDB(conf.getParameter<
bool>(
"TrackerConfigurationFromDB")),
72 makeDigiSimLinks_(conf.getUntrackedParameter<
bool>(
"makeDigiSimLinks",
false)),
73 includeAPVSimulation_(conf.getParameter<
bool>(
"includeAPVSimulation")),
74 fracOfEventsToSimAPV_(conf.getParameter<double>(
"fracOfEventsToSimAPV")) {
81 .setBranchAlias(alias +
"StripAmplitudes");
83 .setBranchAlias(alias +
"StripAmplitudesPostAPV");
85 .setBranchAlias(alias +
"StripAPVBaselines");
88 producesCollector.
produces<
bool>(
"SimulatedAPVDynamicGain").setBranchAlias(alias +
"SimulatedAPVDynamicGain");
89 producesCollector.
produces<std::vector<std::pair<int, std::bitset<6>>>>(
"AffectedAPVList")
90 .setBranchAlias(alias +
"AffectedAPV");
96 if (!rng.isAvailable()) {
98 <<
"SiStripDigitizer requires the RandomNumberGeneratorService\n" 99 "which is not present in the configuration file. You must add the service\n" 100 "in the configuration file or remove the modules that require it.";
110 size_t globalSimHitIndex,
111 const unsigned int tofBin) {
116 if (hSimHits.isValid()) {
117 std::set<unsigned int> detIds;
118 std::vector<PSimHit>
const&
simHits = *hSimHits.product();
119 for (std::vector<PSimHit>::const_iterator it = simHits.begin(), itEnd = simHits.end(); it != itEnd;
120 ++it, ++globalSimHitIndex) {
121 unsigned int detId = (*it).detUnitId();
122 if (detIds.insert(detId).second) {
129 LogDebug(
"Digitizer ") <<
"B-field(T) at " << stripdet->surface().position()
130 <<
"(cm): " <<
pSetup->
inTesla(stripdet->surface().position());
150 if (trackerContainer.find(
std::string(
"HighTof")) != std::string::npos)
179 if (trackerContainer.find(
std::string(
"HighTof")) != std::string::npos)
223 unsigned int detId = iu->geographicalId().rawId();
224 if (iu->type().isTrackerStrip()) {
226 assert(stripdet !=
nullptr);
246 std::unique_ptr<bool> simulateAPVInThisEvent = std::make_unique<bool>(
false);
249 *simulateAPVInThisEvent =
true;
253 std::vector<edm::DetSet<SiStripDigi>> theDigiVector;
254 std::vector<edm::DetSet<SiStripRawDigi>> theRawDigiVector;
256 std::unique_ptr<edm::DetSetVector<SiStripRawDigi>> theStripAmplitudeVectorPostAPV(
266 theDigiVector.reserve(10000);
267 theDigiVector.clear();
276 if (sgd !=
nullptr) {
284 unsigned int detID = sgd->geographicalId().rawId();
289 collectorStripAmplitudes,
290 collectorStripAmplitudesPostAPV,
291 collectorStripAPVBaselines,
298 *simulateAPVInThisEvent,
299 apvSimulationParametersHandle,
304 if (!collectorStripAmplitudes.data.empty())
305 theStripAmplitudeVector->insert(collectorStripAmplitudes);
306 if (!collectorStripAmplitudesPostAPV.data.empty())
307 theStripAmplitudeVectorPostAPV->insert(collectorStripAmplitudesPostAPV);
308 if (!collectorStripAPVBaselines.data.empty())
309 theStripAPVBaselines->insert(collectorStripAPVBaselines);
312 if (!collectorZS.data.empty()) {
313 theDigiVector.push_back(collectorZS);
314 if (!collectorLink.data.empty())
315 pOutputDigiSimLink->insert(collectorLink);
318 if (!collectorRaw.data.empty()) {
319 theRawDigiVector.push_back(collectorRaw);
320 if (!collectorLink.data.empty())
321 pOutputDigiSimLink->insert(collectorLink);
332 std::unique_ptr<std::vector<std::pair<int, std::bitset<6>>>> AffectedAPVList(
339 iEvent.
put(
std::move(theStripAmplitudeVector),
"StripAmplitudes");
340 iEvent.
put(
std::move(theStripAmplitudeVectorPostAPV),
"StripAmplitudesPostAPV");
341 iEvent.
put(
std::move(theStripAPVBaselines),
"StripAPVBaselines");
343 iEvent.
put(
std::move(AffectedAPVList),
"AffectedAPVList");
344 iEvent.
put(
std::move(simulateAPVInThisEvent),
"SimulatedAPVDynamicGain");
350 std::unique_ptr<edm::DetSetVector<SiStripRawDigi>> output_virginraw(
360 iEvent.
put(
std::move(theStripAmplitudeVector),
"StripAmplitudes");
361 iEvent.
put(
std::move(theStripAmplitudeVectorPostAPV),
"StripAmplitudesPostAPV");
362 iEvent.
put(
std::move(theStripAPVBaselines),
"StripAPVBaselines");
364 iEvent.
put(
std::move(simulateAPVInThisEvent),
"SimulatedAPVDynamicGain");
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.
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
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. ...
void addConnected(std::map< uint32_t, std::vector< int >> &) const
const bool makeDigiSimLinks_
SiStripDigitizer(const edm::ParameterSet &conf, edm::ProducesCollector, edm::ConsumesCollector &iC)
T const * product() const
const std::string gainLabel
std::unique_ptr< PileupMixingContent > PileupInfo_