24 typedef std::multimap<DetId, CaloSamples> HcalDigiMap;
32 coder.fC2adc(fC, digi, capIdOffset);
38 for (
int i = 0;
i < digi.size(); ++
i) {
39 int capId(digi.sample(
i).capid());
45 void convertAdc2fChelper<QIE10DataFrame>(
const QIE10DataFrame &digi,
50 for (
int i = 0;
i < digi.samples(); ++
i) {
51 int capId(digi[
i].capid());
57 void convertAdc2fChelper<QIE11DataFrame>(
const QIE11DataFrame &digi,
62 for (
int i = 0;
i < digi.samples(); ++
i) {
63 int capId(digi[
i].capid());
74 coder.adc2fC(digi, fC);
76 convertAdc2fChelper(digi, conditions, fC,
id);
80 template <
class DIGIS>
81 void convertHcalDigis(
const DIGIS &digis,
const HcalDbService &conditions,
bool keepPedestals, HcalDigiMap &map) {
82 for (
auto digi = digis.begin(); digi != digis.end(); ++digi) {
84 convertAdc2fC(*digi, conditions, keepPedestals, fC);
85 if (!keepPedestals && map.find(digi->id()) == map.end()) {
87 <<
"No signal hits found for HCAL cell " << digi->id() <<
" Pedestals may be lost for mixed hit";
98 for (
auto digiItr = digis.begin(); digiItr != digis.end(); ++digiItr) {
101 convertAdc2fC(digi, conditions, keepPedestals, fC);
102 if (!keepPedestals && map.find(digi.id()) == map.end()) {
104 <<
"No signal hits found for HCAL cell " << digi.id() <<
" Pedestals may be lost for mixed hit";
115 for (
auto digiItr = digis.begin(); digiItr != digis.end(); ++digiItr) {
118 convertAdc2fC(digi, conditions, keepPedestals, fC);
119 if (!keepPedestals && map.find(digi.id()) == map.end()) {
121 <<
"No signal hits found for HCAL cell " << digi.id() <<
" Pedestals may be lost for mixed hit";
127 template <
class DIGIS>
135 convertHcalDigis(*digis, conditions,
true, map);
139 template <
class DIGIS>
145 auto digis = edm::getProductByTag<DIGIS>(ep,
tag, mcc);
148 convertHcalDigis(*(digis->
product()), conditions,
false,
153 template <
class DIGIS>
154 void buildHcalDigisHelper(DIGIS &digis,
155 const DetId &formerID,
160 convertFc2adc(resultSample, conditions, digis.back(),
166 const DetId &formerID,
170 digis.push_back(formerID.rawId());
172 convertFc2adc(resultSample, conditions, digi,
178 const DetId &formerID,
182 digis.push_back(formerID.rawId());
184 convertFc2adc(resultSample, conditions, digi,
188 template <
class DIGIS>
189 std::unique_ptr<DIGIS> buildHcalDigis(
const HcalDigiMap &map,
const HcalDbService &conditions) {
190 std::unique_ptr<DIGIS> digis(
new DIGIS);
196 for (
auto hit = map.begin();
hit != map.end(); ++
hit) {
200 if (currentID == formerID) {
202 unsigned int sizenew = (hitSample).
size();
203 unsigned int sizeold = resultSample.
size();
204 if (sizenew > sizeold) {
207 for (
unsigned int isamp = 0; isamp < sizenew; isamp++) {
208 resultSample[isamp] += hitSample[isamp];
212 bool lastEntry = (++hit1 == map.end());
213 if (currentID != formerID || lastEntry) {
214 if (formerID > 0 || lastEntry) {
216 buildHcalDigisHelper(*digis, formerID, resultSample, conditions);
219 formerID = currentID;
220 resultSample = hitSample;
232 DataMixingHcalDigiWorker::DataMixingHcalDigiWorker() {}
236 : label_(ps.getParameter<std::
string>(
"Label")) {
272 if (!ZDCPileInputTag_.
label().empty())
300 LogInfo(
"DataMixingHcalDigiWorker") <<
"===============> adding MC signals for " << e.
id();
315 ZDCDigis = pZDCDigis.
product();
317 LogDebug(
"DataMixingHcalDigiWorker") <<
"total # ZDC digis: " << ZDCDigis->
size();
329 const HcalQIECoder *channelCoder = conditions->getHcalCoder(cell);
330 const HcalQIEShape *shape = conditions->getHcalShape(channelCoder);
334 coder.
adc2fC((*it), tool);
354 unsigned int eventNr,
357 LogDebug(
"DataMixingHcalDigiWorker") <<
"\n===============> adding pileups from event " << ep->
id()
358 <<
" for bunchcrossing " << bcr;
372 std::shared_ptr<Wrapper<ZDCDigiCollection>
const> ZDCDigisPTR =
378 LogDebug(
"DataMixingHcalDigiWorker") <<
"total # ZDC digis: " << ZDCDigis->
size();
385 const HcalQIECoder *channelCoder = conditions->getHcalCoder(cell);
386 const HcalQIEShape *shape = conditions->getHcalShape(channelCoder);
390 coder.
adc2fC((*it), tool);
414 std::unique_ptr<QIE10DigiCollection> QIE10digis =
416 std::unique_ptr<QIE11DigiCollection> QIE11digis =
436 ZDCDigiMap::const_iterator iZDCchk;
439 currentID = iZDC->first;
441 if (currentID == formerID) {
444 unsigned int sizenew = (iZDC->second).
size();
445 unsigned int sizeold = ZDC_old.
size();
447 unsigned int max_samp =
std::max(sizenew, sizeold);
453 if (sizenew > sizeold)
459 for (
unsigned int isamp = 0; isamp < max_samp; isamp++) {
460 if (isamp < sizenew) {
461 fC_new = (iZDC->second)[isamp];
466 if (isamp < sizeold) {
467 fC_old = ZDC_old[isamp];
473 fC_sum = fC_new + fC_old;
476 ZDC_bigger[isamp] = fC_sum;
478 ZDC_old[isamp] = fC_sum;
482 ZDC_old = ZDC_bigger;
496 unsigned int sizeold = ZDC_old.
size();
497 for (
unsigned int isamp = 0; isamp < sizeold; isamp++) {
498 coder.
fC2adc(ZDC_old, (ZDCdigis->back()),
503 formerID = currentID;
504 ZDC_old = iZDC->second;
519 unsigned int sizeold = (iZDC->second).
size();
520 for (
unsigned int isamp = 0; isamp < sizeold; isamp++) {
521 coder.
fC2adc(ZDC_old, (ZDCdigis->back()),
530 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HBHE Merged digis: " << HBHEdigis->size();
531 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HO Merged digis: " << HOdigis->size();
532 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HF Merged digis: " << HFdigis->size();
533 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # QIE10 Merged digis: " << QIE10digis->size();
534 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # QIE11 Merged digis: " << QIE11digis->size();
535 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # ZDC Merged digis: " << ZDCdigis->size();
545 HBHEDigiStorage_.clear();
546 HODigiStorage_.clear();
547 HFDigiStorage_.clear();
548 QIE10DigiStorage_.clear();
549 QIE11DigiStorage_.clear();
edm::InputTag QIE10PileInputTag_
std::string HBHEDigiCollectionDM_
std::string QIE10DigiCollectionDM_
edm::InputTag HBHEPileInputTag_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< HBHEDigiCollection > HBHEDigiPToken_
edm::EDGetTokenT< HODigiCollection > HODigiToken_
uint16_t *__restrict__ id
std::string ZDCDigiCollectionDM_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< ZDCDigiCollection > ZDCDigiToken_
void setSize(unsigned int size)
void fC2adc(const CaloSamples &clf, HBHEDataFrame &df, int fCapIdOffset) const override
edm::EDGetTokenT< HODigiCollection > HODigiPToken_
QIE10DigiMap QIE10DigiStorage_
EventID const & id() const
edm::InputTag HBHEdigiCollectionSig_
std::string HODigiCollectionDM_
std::vector< T >::const_iterator const_iterator
HBHEDigiMap HBHEDigiStorage_
void addHcalPileups(const int bcr, const edm::EventPrincipal *, unsigned int EventId, const edm::EventSetup &ES, ModuleCallingContext const *)
ZDCDigiMap ZDCDigiStorage_
edm::InputTag QIE11PileInputTag_
edm::EDGetTokenT< ZDCDigiCollection > ZDCDigiPToken_
void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const override
Container::value_type value_type
edm::EDGetTokenT< HFDigiCollection > HFDigiPToken_
void putHcal(edm::Event &e, const edm::EventSetup &ES)
edm::InputTag HFPileInputTag_
edm::ESGetToken< HcalDbService, HcalDbRecord > dbToken_
edm::InputTag HOPileInputTag_
edm::InputTag QIE10digiCollectionSig_
edm::InputTag ZDCPileInputTag_
edm::InputTag ZDCdigiCollectionSig_
const_iterator end() const
Log< level::Info, false > LogInfo
constexpr double pedestal(int fCapId) const
get pedestal for capid=0..3
T const * product() const
int size() const
get the size
edm::InputTag HFdigiCollectionSig_
T getParameter(std::string const &) const
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
virtual ~DataMixingHcalDigiWorker()
edm::EDGetTokenT< HFDigiCollection > HFDigiToken_
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
std::string HFDigiCollectionDM_
edm::EDGetTokenT< QIE11DigiCollection > QIE11DigiToken_
edm::InputTag QIE11digiCollectionSig_
DetId id() const
get the (generic) id
edm::EDGetTokenT< QIE11DigiCollection > QIE11DigiPToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Log< level::Warning, false > LogWarning
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
void addHcalSignals(const edm::Event &e, const edm::EventSetup &ES)
QIE11DigiMap QIE11DigiStorage_
edm::EDGetTokenT< QIE10DigiCollection > QIE10DigiToken_
tuple size
Write out results.
edm::EDGetTokenT< QIE10DigiCollection > QIE10DigiPToken_
const_iterator begin() const
edm::EDGetTokenT< HBHEDigiCollection > HBHEDigiToken_
std::string QIE11DigiCollectionDM_
edm::InputTag HOdigiCollectionSig_