66 hitsProducer_(iConfig.getParameter<
std::
string>(
"hitsProducer")),
71 isOuterTrackerReadoutAnalog_(iConfig.getParameter<
bool>(
"isOTreadoutAnalog")),
72 premixStage1_(iConfig.getParameter<
bool>(
"premixStage1")),
74 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);
277 edm::LogError(
"Phase2TrackerDigitizer") <<
"ERROR - Wrong Detector Type, No Algorithm available ";
284 const bool ot_analog) {
285 std::vector<edm::DetSet<PixelDigi> > digiVector;
286 std::vector<edm::DetSet<PixelDigiSimLink> > digiLinkVector;
288 uint32_t rawId = det_u->geographicalId().rawId();
290 auto fiter =
algomap_.find(algotype);
299 std::map<int, DigitizerUtility::DigiSimInfo> digi_map;
300 fiter->second->digitize(dynamic_cast<const Phase2TrackerGeomDetUnit*>(det_u), digi_map,
tTopo_);
304 for (
auto const& digi_p : digi_map) {
307 collector.
data.emplace_back(ip.first, ip.second,
info.sig_tot);
308 for (
auto const& sim_p :
info.simInfoList) {
309 linkcollector.
data.emplace_back(digi_p.first,
310 sim_p.second->trackId(),
311 sim_p.second->hitIndex(),
312 sim_p.second->tofBin(),
313 sim_p.second->eventId(),
317 if (!collector.
data.empty())
318 digiVector.push_back(
std::move(collector));
319 if (!linkcollector.
data.empty())
320 digiLinkVector.push_back(
std::move(linkcollector));
324 auto output = std::make_unique<edm::DetSetVector<PixelDigi> >(digiVector);
325 auto outputlink = std::make_unique<edm::DetSetVector<PixelDigiSimLink> >(digiLinkVector);
340 collector.
data.emplace_back(ip.first, ip.second,
info.sig_tot);
346 collector.
data.emplace_back(ip.first, ip.second,
info.ot_bit);
350 template <
typename DigiType>
352 std::vector<edm::DetSet<DigiType> > digiVector;
353 std::vector<edm::DetSet<PixelDigiSimLink> > digiLinkVector;
355 uint32_t rawId = det_u->geographicalId().rawId();
358 auto fiter =
algomap_.find(algotype);
363 std::map<int, DigitizerUtility::DigiSimInfo> digi_map;
364 fiter->second->digitize(dynamic_cast<const Phase2TrackerGeomDetUnit*>(det_u), digi_map,
tTopo_);
368 for (
auto const& digi_p : digi_map) {
370 addToCollector(collector, digi_p.first,
info);
371 for (
auto const& sim_p :
info.simInfoList) {
372 linkcollector.
data.emplace_back(digi_p.first,
373 sim_p.second->trackId(),
374 sim_p.second->hitIndex(),
375 sim_p.second->tofBin(),
376 sim_p.second->eventId(),
381 if (!collector.
data.empty())
382 digiVector.push_back(
std::move(collector));
383 if (!linkcollector.
data.empty())
384 digiLinkVector.push_back(
std::move(linkcollector));
388 auto output = std::make_unique<edm::DetSetVector<DigiType> >(digiVector);
389 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_
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_
virtual bool isBricked() const =0
ModuleType getDetectorType(DetId) const
bool getData(T &iHolder) 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)
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
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. ...