75 #include "CLHEP/Random/RandomEngine.h" 82 hitsProducer_(iConfig.getParameter<
std::
string>(
"hitsProducer")),
83 trackerContainers_(iConfig.getParameter<
std::vector<
std::
string> >(
"ROUList")),
84 geometryType_(iConfig.getParameter<
std::
string>(
"GeometryType")),
85 isOuterTrackerReadoutAnalog(iConfig.getParameter<
bool>(
"isOTreadoutAnalog")),
86 premixStage1_(iConfig.getParameter<
bool>(
"premixStage1")),
87 makeDigiSimLinks_(iConfig.getParameter<
edm::
ParameterSet>(
"AlgorithmCommon").getUntrackedParameter<
bool>(
"makeDigiSimLinks"))
128 unsigned int detId_raw = det_u->geographicalId().rawId();
143 size_t globalSimHitIndex,
const unsigned int tofBin) {
144 if (hSimHits.isValid()) {
145 std::set<unsigned int> detIds;
146 std::vector<PSimHit>
const&
simHits = *hSimHits.product();
148 for (
auto it = simHits.begin(), itEnd = simHits.end(); it != itEnd; ++it, ++globalSimHitIndex) {
149 unsigned int detId_raw = (*it).detUnitId();
151 if (detIds.insert(detId_raw).second) {
160 algomap_[algotype]->accumulateSimHits(it, itEnd, globalSimHitIndex, tofBin, phase2det, bfield);
162 edm::LogInfo(
"Phase2TrackerDigitizer") <<
"Unsupported algorithm: ";
175 <<
"Phase2TrackerDigitizer requires the RandomNumberGeneratorService\n" 176 "which is not present in the configuration file. You must add the service\n" 177 "in the configuration file or remove the modules that require it.";
182 if (
first_) el.second->init(iSetup);
195 accumulate_local<edm::Event>(
iEvent, iSetup);
200 accumulate_local<PileUpEventPrincipal>(
iEvent, iSetup);
208 iEvent.getByLabel(tag, simHits);
229 algo.loadAccumulator(detMap.first, detMap.second);
238 addOuterTrackerCollection<PixelDigi>(
iEvent, iSetup);
241 addOuterTrackerCollection<Phase2TrackerDigi>(
iEvent, iSetup);
246 DetId detId(detId_raw);
284 edm::LogError(
"Phase2TrackerDigitizer")<<
"ERROR - Wrong Detector Type, No Algorithm available ";
291 std::vector<edm::DetSet<PixelDigi> > digiVector;
292 std::vector<edm::DetSet<PixelDigiSimLink> > digiLinkVector;
294 DetId detId_raw =
DetId(det_u->geographicalId().rawId());
300 std::map<int, DigitizerUtility::DigiSimInfo> digi_map;
301 algomap_[algotype]->digitize(dynamic_cast<const Phase2TrackerGeomDetUnit*>(det_u),
305 for (
auto const & digi_p : digi_map) {
308 collector.data.emplace_back(ip.first, ip.second, info.
sig_tot);
310 linkcollector.data.emplace_back(digi_p.first, sim_p.second->trackId(), sim_p.second->hitIndex(), sim_p.second->tofBin(), sim_p.second->eventId(), sim_p.first);
313 if (!collector.data.empty()) digiVector.push_back(
std::move(collector));
314 if (!linkcollector.data.empty()) digiLinkVector.push_back(
std::move(linkcollector));
318 std::unique_ptr<edm::DetSetVector<PixelDigi> >
320 std::unique_ptr<edm::DetSetVector<PixelDigiSimLink> >
337 collector.
data.emplace_back(ip.first, ip.second, info.
sig_tot);
341 collector.
data.emplace_back(ip.first, ip.second, info.
ot_bit);
345 template <
typename DigiType>
348 std::vector<edm::DetSet<DigiType> > digiVector;
349 std::vector<edm::DetSet<PixelDigiSimLink> > digiLinkVector;
351 DetId detId_raw =
DetId(det_u->geographicalId().rawId());
356 std::map<int, DigitizerUtility::DigiSimInfo> digi_map;
357 algomap_[algotype]->digitize(dynamic_cast<const Phase2TrackerGeomDetUnit*>(det_u),
362 for (
auto const & digi_p : digi_map) {
364 addToCollector(collector, digi_p.first, info);
367 linkcollector.data.emplace_back(digi_p.first, sim_p.second->trackId(), sim_p.second->hitIndex(), sim_p.second->tofBin(), sim_p.second->eventId(), sim_p.first);
371 if (!collector.data.empty()) digiVector.push_back(
std::move(collector));
372 if (!linkcollector.data.empty()) digiLinkVector.push_back(
std::move(linkcollector));
376 std::unique_ptr<edm::DetSetVector<DigiType> >
378 std::unique_ptr<edm::DetSetVector<PixelDigiSimLink> >
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
T getParameter(std::string const &) const
const bool isOuterTrackerReadoutAnalog
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void accumulate(edm::Event const &e, edm::EventSetup const &c) override
edm::ESWatcher< TrackerDigiGeometryRecord > theTkDigiGeomWatcher
ModuleTypeCache moduleTypeCache_
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
void accumulatePixelHits(edm::Handle< std::vector< PSimHit > >, size_t globalSimHitIndex, const unsigned int tofBin)
void accumulate_local(T const &iEvent, edm::EventSetup const &iSetup)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
const Plane & surface() const
The nominal surface of the GeomDet.
std::unordered_map< unsigned, TrackerGeometry::ModuleType > ModuleTypeCache
std::map< unsigned int, const Phase2TrackerGeomDetUnit * > detectorUnits_
const bool makeDigiSimLinks_
edm::ESHandle< TrackerTopology > tTopoHand
const std::string geometryType_
edm::ESHandle< TrackerGeometry > pDD_
void loadAccumulator(const std::map< unsigned int, std::map< int, float > > &accumulator)
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. ...
ModuleType getDetectorType(DetId) const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Namespace of DDCMS conversion namespace.
void addOuterTrackerCollection(edm::Event &iEvent, const edm::EventSetup &iSetup)
AlgorithmType getAlgoType(unsigned int idet)
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &iSetup) override
static std::pair< int, int > channelToPixel(int ch)
bool check(const edm::EventSetup &iSetup)
const vstring trackerContainers_
edm::ESHandle< MagneticField > pSetup_
std::map< AlgorithmType, std::unique_ptr< Phase2TrackerDigitizerAlgorithm > > algomap_
const std::string hitsProducer_
#define DEFINE_DIGI_ACCUMULATOR(type)
StreamID streamID() const
Phase2TrackerDigitizer(const edm::ParameterSet &iConfig, edm::ProducerBase &mixMod, edm::ConsumesCollector &iC)
std::vector< std::pair< float, SimHitInfoForLinks * > > simInfoList
void addPixelCollection(edm::Event &iEvent, const edm::EventSetup &iSetup, const bool ot_analog)
~Phase2TrackerDigitizer() override
const PositionType & position() const
T const * product() const
static std::pair< unsigned int, unsigned int > channelToPixel(unsigned int ch)