65 hitsProducer_(iConfig.getParameter<
std::
string>(
"hitsProducer")),
70 isOuterTrackerReadoutAnalog_(iConfig.getParameter<
bool>(
"isOTreadoutAnalog")),
71 usePseudoPixel3DAlgo_(iConfig.getParameter<
bool>(
"usePseudoPixel3DAlgo")),
72 premixStage1_(iConfig.getParameter<
bool>(
"premixStage1")),
75 iConfig.getParameter<
edm::
ParameterSet>(
"AlgorithmCommon").getUntrackedParameter<
bool>(
"makeDigiSimLinks")) {
103 size_t globalSimHitIndex,
104 const uint32_t tofBin) {
105 if (hSimHits.isValid()) {
106 std::set<uint32_t> detIds;
107 auto const&
simHits = *(hSimHits.product());
108 for (
auto it = std::begin(
simHits), itEnd = std::end(
simHits); it != itEnd; ++it, ++globalSimHitIndex) {
109 uint32_t detId_raw = (*it).detUnitId();
114 if (detIds.insert(detId_raw).second) {
125 kiter->second->accumulateSimHits(it, itEnd, globalSimHitIndex, tofBin, phase2det, bfield);
127 edm::LogInfo(
"Phase2TrackerDigitizer") <<
"Unsupported algorithm: ";
137 <<
"Phase2TrackerDigitizer requires the RandomNumberGeneratorService\n" 138 "which is not present in the configuration file. You must add the service\n" 139 "in the configuration file or remove the modules that require it.";
152 uint32_t rawId = det_u->geographicalId().rawId();
164 el.second->init(iSetup);
166 el.second->initializeEvent(rng->
getEngine(
e.streamID()));
176 accumulate_local<edm::Event>(
iEvent, iSetup);
182 accumulate_local<PileUpEventPrincipal>(
iEvent, iSetup);
196 if (
v.find(
std::string(
"HighTof")) != std::string::npos)
213 algo.loadAccumulator(detMap.first, detMap.second);
222 addOuterTrackerCollection<PixelDigi>(
iEvent, iSetup);
224 addOuterTrackerCollection<Phase2TrackerDigi>(
iEvent, iSetup);
268 edm::LogError(
"Phase2TrackerDigitizer") <<
"ERROR - Wrong Detector Type, No Algorithm available ";
275 const bool ot_analog) {
276 std::vector<edm::DetSet<PixelDigi> > digiVector;
277 std::vector<edm::DetSet<PixelDigiSimLink> > digiLinkVector;
279 uint32_t rawId = det_u->geographicalId().rawId();
281 auto fiter =
algomap_.find(algotype);
289 std::map<int, digitizerUtility::DigiSimInfo> digi_map;
290 fiter->second->digitize(dynamic_cast<const Phase2TrackerGeomDetUnit*>(det_u), digi_map,
tTopo_);
294 for (
auto const& digi_p : digi_map) {
297 collector.
data.emplace_back(ip.first, ip.second,
info.sig_tot);
298 for (
auto const& sim_p :
info.simInfoList) {
299 linkcollector.
data.emplace_back(digi_p.first,
300 sim_p.second->trackId(),
301 sim_p.second->hitIndex(),
302 sim_p.second->tofBin(),
303 sim_p.second->eventId(),
307 if (!collector.
data.empty())
308 digiVector.push_back(
std::move(collector));
309 if (!linkcollector.
data.empty())
310 digiLinkVector.push_back(
std::move(linkcollector));
314 auto output = std::make_unique<edm::DetSetVector<PixelDigi> >(digiVector);
315 auto outputlink = std::make_unique<edm::DetSetVector<PixelDigiSimLink> >(digiLinkVector);
330 collector.
data.emplace_back(ip.first, ip.second,
info.sig_tot);
336 collector.
data.emplace_back(ip.first, ip.second,
info.ot_bit);
340 template <
typename DigiType>
342 std::vector<edm::DetSet<DigiType> > digiVector;
343 std::vector<edm::DetSet<PixelDigiSimLink> > digiLinkVector;
345 uint32_t rawId = det_u->geographicalId().rawId();
348 auto fiter =
algomap_.find(algotype);
352 std::map<int, digitizerUtility::DigiSimInfo> digi_map;
353 fiter->second->digitize(dynamic_cast<const Phase2TrackerGeomDetUnit*>(det_u), digi_map,
tTopo_);
357 for (
auto const& digi_p : digi_map) {
359 addToCollector(collector, digi_p.first,
info);
360 for (
auto const& sim_p :
info.simInfoList) {
361 linkcollector.
data.emplace_back(digi_p.first,
362 sim_p.second->trackId(),
363 sim_p.second->hitIndex(),
364 sim_p.second->tofBin(),
365 sim_p.second->eventId(),
370 if (!collector.
data.empty())
371 digiVector.push_back(
std::move(collector));
372 if (!linkcollector.
data.empty())
373 digiLinkVector.push_back(
std::move(linkcollector));
377 auto output = std::make_unique<edm::DetSetVector<DigiType> >(digiVector);
378 auto outputlink = std::make_unique<edm::DetSetVector<PixelDigiSimLink> >(digiLinkVector);
edm::ESWatcher< TrackerDigiGeometryRecord > theTkDigiGeomWatcher_
Phase2TrackerDigitizer(const edm::ParameterSet &iConfig, edm::ProducesCollector, edm::ConsumesCollector &iC)
T getParameter(std::string const &) const
const MagneticField * pSetup_
const TrackerTopology * tTopo_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
void accumulate(edm::Event const &e, edm::EventSetup const &c) override
static std::pair< int, int > channelToPixel(int ch)
ModuleTypeCache moduleTypeCache_
void accumulatePixelHits(edm::Handle< std::vector< PSimHit > >, size_t globalSimHitIndex, const uint32_t tofBin)
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
AlgorithmType getAlgoType(uint32_t idet)
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const bool isOuterTrackerReadoutAnalog_
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
void accumulate_local(T const &iEvent, edm::EventSetup const &iSetup)
Log< level::Error, false > LogError
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
const bool makeDigiSimLinks_
ModuleType getDetectorType(DetId) const
std::unordered_map< uint32_t, TrackerGeometry::ModuleType > ModuleTypeCache
void loadAccumulator(const std::map< uint32_t, std::map< int, float > > &accumulator)
Namespace of DDCMS conversion namespace.
Log< level::Info, false > LogInfo
std::map< uint32_t, const Phase2TrackerGeomDetUnit * > detectorUnits_
void addOuterTrackerCollection(edm::Event &iEvent, const edm::EventSetup &iSetup)
const Plane & surface() const
The nominal surface of the GeomDet.
const PositionType & position() const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > pSetupToken_
const TrackerGeometry * pDD_
bool check(const edm::EventSetup &iSetup)
const vstring trackerContainers_
std::map< AlgorithmType, std::unique_ptr< Phase2TrackerDigitizerAlgorithm > > algomap_
static std::pair< unsigned int, unsigned int > channelToPixel(unsigned int ch)
const std::string hitsProducer_
#define DEFINE_DIGI_ACCUMULATOR(type)
const bool usePseudoPixel3DAlgo_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > pDDToken_
void addPixelCollection(edm::Event &iEvent, const edm::EventSetup &iSetup, const bool ot_analog)
~Phase2TrackerDigitizer() override
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. ...