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());
40 fC[
i] -=
calib.pedestal(capId);
45 void convertAdc2fChelper<QIE10DataFrame>(
const QIE10DataFrame &digi,
50 for (
int i = 0;
i < digi.samples(); ++
i) {
51 int capId(digi[
i].capid());
52 fC[
i] -=
calib.pedestal(capId);
57 void convertAdc2fChelper<QIE11DataFrame>(
const QIE11DataFrame &digi,
62 for (
int i = 0;
i < digi.samples(); ++
i) {
63 int capId(digi[
i].capid());
64 fC[
i] -=
calib.pedestal(capId);
74 coder.adc2fC(digi, fC);
80 template <
class DIGIS>
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>
133 if (!
e.getByToken(
token, digis))
139 template <
class DIGIS>
145 auto digis = edm::getProductByTag<DIGIS>(
ep,
tag, mcc);
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());
178 const DetId &formerID,
182 digis.push_back(formerID.rawId());
188 template <
class DIGIS>
190 std::unique_ptr<DIGIS> digis(
new DIGIS);
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")) {
300 LogInfo(
"DataMixingHcalDigiWorker") <<
"===============> adding MC signals for " <<
e.id();
315 ZDCDigis = pZDCDigis.
product();
317 LogDebug(
"DataMixingHcalDigiWorker") <<
"total # ZDC digis: " << ZDCDigis->
size();
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();
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();
edm::InputTag QIE10PileInputTag_
std::string HBHEDigiCollectionDM_
std::string QIE10DigiCollectionDM_
T getParameter(std::string const &) const
edm::InputTag HBHEPileInputTag_
edm::EDGetTokenT< HBHEDigiCollection > HBHEDigiPToken_
int size() const
get the size
edm::EDGetTokenT< HODigiCollection > HODigiToken_
std::string ZDCDigiCollectionDM_
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_
T const * product() 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_
DetId id() const
get the (generic) id
edm::ESGetToken< HcalDbService, HcalDbRecord > dbToken_
edm::InputTag HOPileInputTag_
edm::InputTag QIE10digiCollectionSig_
const_iterator begin() const
edm::InputTag ZDCPileInputTag_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::InputTag ZDCdigiCollectionSig_
const_iterator end() const
Log< level::Info, false > LogInfo
edm::InputTag HFdigiCollectionSig_
virtual ~DataMixingHcalDigiWorker()
edm::EDGetTokenT< HFDigiCollection > HFDigiToken_
std::string HFDigiCollectionDM_
edm::EDGetTokenT< QIE11DigiCollection > QIE11DigiToken_
edm::InputTag QIE11digiCollectionSig_
edm::EDGetTokenT< QIE11DigiCollection > QIE11DigiPToken_
Log< level::Warning, false > LogWarning
void addHcalSignals(const edm::Event &e, const edm::EventSetup &ES)
QIE11DigiMap QIE11DigiStorage_
edm::EDGetTokenT< QIE10DigiCollection > QIE10DigiToken_
edm::EDGetTokenT< QIE10DigiCollection > QIE10DigiPToken_
edm::EDGetTokenT< HBHEDigiCollection > HBHEDigiToken_
std::string QIE11DigiCollectionDM_
edm::InputTag HOdigiCollectionSig_