26 typedef std::multimap<DetId, CaloSamples> HcalDigiMap;
34 coder.fC2adc(fC, digi, capIdOffset);
40 for (
int i = 0;
i < digi.size(); ++
i) {
41 int capId(digi.sample(
i).capid());
47 void convertAdc2fChelper<QIE10DataFrame>(
const QIE10DataFrame &digi,
52 for (
int i = 0;
i < digi.samples(); ++
i) {
53 int capId(digi[
i].capid());
59 void convertAdc2fChelper<QIE11DataFrame>(
const QIE11DataFrame &digi,
64 for (
int i = 0;
i < digi.samples(); ++
i) {
65 int capId(digi[
i].capid());
76 coder.adc2fC(digi, fC);
78 convertAdc2fChelper(digi, conditions, fC,
id);
82 template <
class DIGIS>
83 void convertHcalDigis(
const DIGIS &digis,
const HcalDbService &conditions,
bool keepPedestals, HcalDigiMap &
map) {
84 for (
auto digi = digis.begin(); digi != digis.end(); ++digi) {
86 convertAdc2fC(*digi, conditions, keepPedestals, fC);
87 if (!keepPedestals && map.find(digi->id()) == map.end()) {
89 <<
"No signal hits found for HCAL cell " << digi->id() <<
" Pedestals may be lost for mixed hit";
100 for (
auto digiItr = digis.begin(); digiItr != digis.end(); ++digiItr) {
103 convertAdc2fC(digi, conditions, keepPedestals, fC);
104 if (!keepPedestals && map.find(digi.id()) == map.end()) {
106 <<
"No signal hits found for HCAL cell " << digi.id() <<
" Pedestals may be lost for mixed hit";
117 for (
auto digiItr = digis.begin(); digiItr != digis.end(); ++digiItr) {
120 convertAdc2fC(digi, conditions, keepPedestals, fC);
121 if (!keepPedestals && map.find(digi.id()) == map.end()) {
123 <<
"No signal hits found for HCAL cell " << digi.id() <<
" Pedestals may be lost for mixed hit";
129 template <
class DIGIS>
137 convertHcalDigis(*digis, conditions,
true, map);
141 template <
class DIGIS>
147 auto digis = edm::getProductByTag<DIGIS>(ep,
tag, mcc);
150 convertHcalDigis(*(digis->
product()), conditions,
false,
155 template <
class DIGIS>
156 void buildHcalDigisHelper(DIGIS &digis,
157 const DetId &formerID,
162 convertFc2adc(resultSample, conditions, digis.back(),
168 const DetId &formerID,
172 digis.push_back(formerID.rawId());
174 convertFc2adc(resultSample, conditions, digi,
180 const DetId &formerID,
184 digis.push_back(formerID.rawId());
186 convertFc2adc(resultSample, conditions, digi,
190 template <
class DIGIS>
191 std::unique_ptr<DIGIS> buildHcalDigis(
const HcalDigiMap &map,
const HcalDbService &conditions) {
192 std::unique_ptr<DIGIS> digis(
new DIGIS);
198 for (
auto hit = map.begin();
hit != map.end(); ++
hit) {
202 if (currentID == formerID) {
204 unsigned int sizenew = (hitSample).
size();
205 unsigned int sizeold = resultSample.
size();
206 if (sizenew > sizeold) {
209 for (
unsigned int isamp = 0; isamp < sizenew; isamp++) {
210 resultSample[isamp] += hitSample[isamp];
214 bool lastEntry = (++hit1 == map.end());
215 if (currentID != formerID || lastEntry) {
216 if (formerID > 0 || lastEntry) {
218 buildHcalDigisHelper(*digis, formerID, resultSample, conditions);
221 formerID = currentID;
222 resultSample = hitSample;
234 DataMixingHcalDigiWorker::DataMixingHcalDigiWorker() {}
238 : label_(ps.getParameter<
std::
string>(
"Label")) {
274 if (!ZDCPileInputTag_.
label().empty())
301 LogInfo(
"DataMixingHcalDigiWorker") <<
"===============> adding MC signals for " << e.
id();
316 ZDCDigis = pZDCDigis.
product();
318 LogDebug(
"DataMixingHcalDigiWorker") <<
"total # ZDC digis: " << ZDCDigis->
size();
330 const HcalQIECoder *channelCoder = conditions->getHcalCoder(cell);
331 const HcalQIEShape *shape = conditions->getHcalShape(channelCoder);
335 coder.
adc2fC((*it), tool);
355 unsigned int eventNr,
358 LogDebug(
"DataMixingHcalDigiWorker") <<
"\n===============> adding pileups from event " << ep->
id()
359 <<
" for bunchcrossing " << bcr;
374 std::shared_ptr<Wrapper<ZDCDigiCollection>
const> ZDCDigisPTR =
380 LogDebug(
"DataMixingHcalDigiWorker") <<
"total # ZDC digis: " << ZDCDigis->
size();
387 const HcalQIECoder *channelCoder = conditions->getHcalCoder(cell);
388 const HcalQIEShape *shape = conditions->getHcalShape(channelCoder);
392 coder.
adc2fC((*it), tool);
414 std::unique_ptr<HBHEDigiCollection> HBHEdigis = buildHcalDigis<HBHEDigiCollection>(
HBHEDigiStorage_, *conditions);
415 std::unique_ptr<HODigiCollection> HOdigis = buildHcalDigis<HODigiCollection>(
HODigiStorage_, *conditions);
416 std::unique_ptr<HFDigiCollection> HFdigis = buildHcalDigis<HFDigiCollection>(
HFDigiStorage_, *conditions);
417 std::unique_ptr<QIE10DigiCollection> QIE10digis =
419 std::unique_ptr<QIE11DigiCollection> QIE11digis =
439 ZDCDigiMap::const_iterator iZDCchk;
442 currentID = iZDC->first;
444 if (currentID == formerID) {
447 unsigned int sizenew = (iZDC->second).
size();
448 unsigned int sizeold = ZDC_old.
size();
450 unsigned int max_samp =
std::max(sizenew, sizeold);
456 if (sizenew > sizeold)
462 for (
unsigned int isamp = 0; isamp < max_samp; isamp++) {
463 if (isamp < sizenew) {
464 fC_new = (iZDC->second)[isamp];
469 if (isamp < sizeold) {
470 fC_old = ZDC_old[isamp];
476 fC_sum = fC_new + fC_old;
479 ZDC_bigger[isamp] = fC_sum;
481 ZDC_old[isamp] = fC_sum;
485 ZDC_old = ZDC_bigger;
499 unsigned int sizeold = ZDC_old.
size();
500 for (
unsigned int isamp = 0; isamp < sizeold; isamp++) {
501 coder.
fC2adc(ZDC_old, (ZDCdigis->back()),
506 formerID = currentID;
507 ZDC_old = iZDC->second;
522 unsigned int sizeold = (iZDC->second).
size();
523 for (
unsigned int isamp = 0; isamp < sizeold; isamp++) {
524 coder.
fC2adc(ZDC_old, (ZDCdigis->back()),
533 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HBHE Merged digis: " << HBHEdigis->size();
534 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HO Merged digis: " << HOdigis->size();
535 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HF Merged digis: " << HFdigis->size();
536 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # QIE10 Merged digis: " << QIE10digis->size();
537 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # QIE11 Merged digis: " << QIE11digis->size();
538 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # ZDC Merged digis: " << ZDCdigis->size();
548 HBHEDigiStorage_.clear();
549 HODigiStorage_.clear();
550 HFDigiStorage_.clear();
551 QIE10DigiStorage_.clear();
552 QIE11DigiStorage_.clear();
edm::InputTag QIE10PileInputTag_
T getParameter(std::string const &) const
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_
std::string ZDCDigiCollectionDM_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< ZDCDigiCollection > ZDCDigiToken_
void setSize(unsigned int size)
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 fC2adc(const CaloSamples &clf, HBHEDataFrame &df, int fCapIdOffset) const override
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::InputTag HOPileInputTag_
edm::InputTag QIE10digiCollectionSig_
edm::InputTag ZDCPileInputTag_
edm::InputTag ZDCdigiCollectionSig_
const_iterator end() const
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_
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_
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
void addHcalSignals(const edm::Event &e, const edm::EventSetup &ES)
QIE11DigiMap QIE11DigiStorage_
edm::EDGetTokenT< QIE10DigiCollection > QIE10DigiToken_
edm::EDGetTokenT< QIE10DigiCollection > QIE10DigiPToken_
const_iterator begin() const
edm::EDGetTokenT< HBHEDigiCollection > HBHEDigiToken_
std::string QIE11DigiCollectionDM_
edm::InputTag HOdigiCollectionSig_