30 #include "CLHEP/Random/RandFlat.h" 71 typedef std::multimap<int, PixelDigi>
126 LogDebug(
"PreMixingSiPixelWorker") <<
"===============> adding MC signals for " <<
e.id();
133 for (; DSViter !=
input->end(); DSViter++) {
135 LogDebug(
"PreMixingSiPixelWorker") <<
"Processing DetID " << DSViter->id;
138 uint32_t detID = DSViter->id;
145 for (icopy =
begin; icopy !=
end; icopy++) {
155 LogDebug(
"PreMixingSiPixelWorker") <<
"\n===============> adding pileups from event " << pep.
principal().
id()
172 const auto&
input = *inputHandle;
174 bool loadExtraInformation =
false;
178 loadExtraInformation =
true;
181 for (detIdIter = pixelAddInfo->begin(); detIdIter != pixelAddInfo->end(); detIdIter++) {
182 uint32_t
detid = detIdIter->id;
185 for (di = detIdIter->data.
begin(); di != detIdIter->data.
end(); di++) {
192 edm::LogError(
"PreMixingSiPixelWorker") <<
" Problem in accessing the Extra Pixel SimHit Collection !!!! ";
193 edm::LogError(
"PreMixingSiPixelWorker") <<
" The Late Charge Reweighting can not be applied ";
195 <<
" Problem in accessing the Extra Pixel SimHit Collection for Late Charge Reweighting \n";
200 for (; DSViter !=
input.end(); DSViter++) {
202 LogDebug(
"PreMixingSiPixelWorker") <<
"Pileups: Processing DetID " << DSViter->id;
205 uint32_t detID = DSViter->id;
212 SiGlobalIndex::const_iterator itest;
216 std::vector<PixelDigi> TempDigis;
217 for (icopy =
begin; icopy !=
end; icopy++) {
218 TempDigis.push_back(*icopy);
220 if (loadExtraInformation) {
222 SiPixelExtraInfo::const_iterator jtest;
225 std::vector<PixelSimHitExtraInfo> TempSimExtra;
226 for (
auto& iLocal : LocalSimHitExtraMap) {
227 TempSimExtra.push_back(iLocal.second);
230 for (
const auto& iu : pDD.detUnits()) {
231 if (iu->type().isTrackerPixel()) {
232 uint32_t detIDinLoop = iu->geographicalId().rawId();
233 if (detIDinLoop == detID) {
235 dynamic_cast<const PixelGeomDetUnit*>(iu), TempDigis, TempSimExtra, tTopo, engine);
247 for (
unsigned int ij = 0; ij < TempDigis.size(); ij++) {
257 for (
unsigned int ij = 0; ij < TempDigis.size(); ij++) {
269 std::vector<PileupSummaryInfo>
const& ps,
273 std::vector<edm::DetSet<PixelDigi>> vPixelDigi;
281 uint32_t detID = IDet->first;
289 int formerPixel = -1;
293 OneDetectorMap::const_iterator iLocalchk;
295 for (OneDetectorMap::const_iterator iLocal = LocalMap.begin(); iLocal != LocalMap.end(); ++iLocal) {
296 currentPixel = iLocal->first;
298 if (currentPixel == formerPixel) {
299 ADCSum += (iLocal->second).
adc();
301 if (formerPixel != -1) {
304 else if (ADCSum > 253 && ADCSum < 512)
307 Signals.insert(std::make_pair(formerPixel, ADCSum));
310 formerPixel = currentPixel;
311 ADCSum = (iLocal->second).
adc();
315 if ((++iLocalchk) == LocalMap.end()) {
318 else if (ADCSum > 253 && ADCSum < 512)
320 Signals.insert(std::make_pair(formerPixel, ADCSum));
326 signal.insert(std::make_pair(detID, Signals));
331 edm::LogInfo(
"PreMixingSiPixelWorker") <<
"total # Merged Pixels: " << signal.size();
333 std::vector<edm::DetSet<PixelDigi>> theDigiVector;
345 CLHEP::HepRandomEngine* engine = &rng->
getEngine(
e.streamID());
352 if (PixelFEDChannelCollection_ ==
nullptr) {
353 throw cms::Exception(
"NullPointerError") <<
"PixelFEDChannelCollection not set in chooseScenario function.\n";
358 for (
const auto& iu : pDD.detUnits()) {
359 if (iu->type().isTrackerPixel()) {
362 iu->geographicalId().rawId());
363 std::vector<PixelDigiAddTempInfo> tempcollector;
366 dynamic_cast<const PixelGeomDetUnit*>(iu), collector.data, linkcollector.data, tempcollector, tTopo, engine);
367 if (!collector.data.empty()) {
368 theDigiVector.push_back(
std::move(collector));
void init(const edm::EventSetup &es)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
T getParameter(std::string const &) const
void put(edm::Event &e, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bs) override
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
edm::EDGetTokenT< edm::DetSetVector< PixelSimHitExtraInfo > > PixelDigiPExtraToken_
std::multimap< int, PixelDigi > OneDetectorMap
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > PixelDigiPToken_
void addPileups(PileUpEventPrincipal const &, edm::EventSetup const &es) override
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
edm::InputTag pixeldigi_collectionSig_
edm::InputTag pixeldigi_collectionPile_
PreMixingSiPixelWorker(const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &&iC)
int bunchCrossing() const
std::map< uint32_t, OneExtraInfoMap > SiPixelExtraInfo
Log< level::Error, false > LogError
StreamID streamID() const
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
bool firstInitializeEvent_
static std::string const input
edm::EventPrincipal const & principal()
Container::value_type value_type
~PreMixingSiPixelWorker() override=default
void digitize(const PixelGeomDetUnit *pixdet, std::vector< PixelDigi > &digis, std::vector< PixelDigiSimLink > &simlinks, std::vector< PixelDigiAddTempInfo > &newClass_Digi_extra, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *)
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > PixelDigiToken_
SiPixelDigitizerAlgorithm digitizer_
std::string PixelDigiCollectionDM_
void init_DynIneffDB(const edm::EventSetup &)
std::unique_ptr< PixelFEDChannelCollection > chooseScenario(PileupMixingContent *puInfo, CLHEP::HepRandomEngine *)
iterator end()
Return the off-the-end iterator.
SiPixelExtraInfo SiHitExtraStorage_
void addSignals(edm::Event const &e, edm::EventSetup const &es) override
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > pDDToken_
edm::InputTag pixeldigi_extraInfo_
void setSimAccumulator(const std::map< uint32_t, std::map< int, int > > &signalMap)
std::multimap< int, PixelSimHitExtraInfo > OneExtraInfoMap
Log< level::Info, false > LogInfo
bool applyLateReweighting_
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
void calculateInstlumiFactor(PileupMixingContent *puInfo)
std::map< uint32_t, signal_map_type > signalMaps
void lateSignalReweight(const PixelGeomDetUnit *pixdet, std::vector< PixelDigi > &digis, std::vector< PixelSimHitExtraInfo > &newClass_Sim_extra, const TrackerTopology *tTopo, CLHEP::HepRandomEngine *engine)
void insert(detset const &s)
Insert the given DetSet.
iterator begin()
Return an iterator to the first DetSet.
std::map< int, Amplitude, std::less< int > > signal_map_type
bool killBadFEDChannels() const
collection_type::const_iterator const_iterator
collection_type::const_iterator const_iterator
EventID const & id() const
#define DEFINE_PREMIXING_WORKER(TYPE)
SiGlobalIndex SiHitStorage_
uint16_t *__restrict__ uint16_t const *__restrict__ adc
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
std::map< uint32_t, OneDetectorMap > SiGlobalIndex