31 typedef std::multimap<DetId, CaloSamples> HcalDigiMap;
39 coder.fC2adc(fC, digi, capIdOffset);
45 for (
int i = 0;
i < digi.size(); ++
i) {
46 int capId (digi.sample(
i).capid());
54 for (
int i = 0;
i < digi.samples(); ++
i) {
55 int capId (digi[
i].capid());
63 for (
int i = 0;
i < digi.samples(); ++
i) {
64 int capId (digi[
i].capid());
75 coder.adc2fC(digi, fC);
77 convertAdc2fChelper(digi,conditions,fC,
id);
81 template <
class DIGIS>
82 void convertHcalDigis (
const DIGIS& digis,
const HcalDbService& conditions,
bool keepPedestals, HcalDigiMap&
map) {
83 for (
auto digi = digis.begin(); digi != digis.end(); ++digi) {
85 convertAdc2fC (*digi, conditions, keepPedestals, fC);
86 if (!keepPedestals && map.find(digi->id()) == map.end()) {
87 edm::LogWarning(
"DataMixingHcalDigiWorker")<<
"No signal hits found for HCAL cell "<<digi->id()<<
" Pedestals may be lost for mixed hit";
95 for (
auto digiItr = digis.begin(); digiItr != digis.end(); ++digiItr) {
98 convertAdc2fC (digi, conditions, keepPedestals, fC);
99 if (!keepPedestals && map.find(digi.id()) == map.end()) {
100 edm::LogWarning(
"DataMixingHcalDigiWorker")<<
"No signal hits found for HCAL cell "<<digi.id()<<
" Pedestals may be lost for mixed hit";
108 for (
auto digiItr = digis.begin(); digiItr != digis.end(); ++digiItr) {
111 convertAdc2fC (digi, conditions, keepPedestals, fC);
112 if (!keepPedestals && map.find(digi.id()) == map.end()) {
113 edm::LogWarning(
"DataMixingHcalDigiWorker")<<
"No signal hits found for HCAL cell "<<digi.id()<<
" Pedestals may be lost for mixed hit";
119 template <
class DIGIS>
123 if (!e.
getByToken (token, digis))
return false;
124 convertHcalDigis (*digis, conditions,
true, map);
128 template <
class DIGIS>
132 auto digis = edm::getProductByTag<DIGIS>(ep,
tag, mcc);
133 if (!digis)
return false;
134 convertHcalDigis (*(digis->
product()), conditions,
false, map);
138 template <
class DIGIS>
142 convertFc2adc (resultSample, conditions, digis.back(), 0);
148 digis.push_back(formerID.rawId());
150 convertFc2adc (resultSample, conditions, digi, 0);
156 digis.push_back(formerID.rawId());
158 convertFc2adc (resultSample, conditions, digi, 0);
161 template <
class DIGIS>
162 std::unique_ptr<DIGIS> buildHcalDigis (
const HcalDigiMap& map,
const HcalDbService& conditions) {
163 std::unique_ptr<DIGIS> digis(
new DIGIS );
168 for(
auto hit = map.begin();
hit != map.end(); ++
hit) {
172 if (currentID == formerID) {
174 unsigned int sizenew = (hitSample).
size();
175 unsigned int sizeold = resultSample.
size();
176 if (sizenew > sizeold) {
177 resultSample.
setSize (sizenew);
179 for(
unsigned int isamp = 0; isamp<sizenew; isamp++) {
180 resultSample[isamp] += hitSample[isamp];
184 bool lastEntry = (++hit1 == map.end());
185 if (currentID != formerID || lastEntry) {
186 if (formerID>0 || lastEntry) {
188 buildHcalDigisHelper(*digis,formerID,resultSample,conditions);
191 formerID = currentID;
192 resultSample = hitSample;
207 DataMixingHcalDigiWorker::DataMixingHcalDigiWorker() { }
211 label_(ps.getParameter<
std::
string>(
"Label"))
248 if(ZDCPileInputTag_.
label() !=
"") DoZDC_ =
true;
279 LogInfo(
"DataMixingHcalDigiWorker")<<
"===============> adding MC signals for "<<e.
id();
297 ZDCDigis = pZDCDigis.
product();
299 LogDebug(
"DataMixingHcalDigiWorker") <<
"total # ZDC digis: " << ZDCDigis->
size();
312 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
313 const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
337 LogDebug(
"DataMixingHcalDigiWorker") <<
"\n===============> adding pileups from event "<<ep->
id()<<
" for bunchcrossing "<<bcr;
355 std::shared_ptr<Wrapper<ZDCDigiCollection>
const> ZDCDigisPTR = getProductByTag<ZDCDigiCollection>(*ep,
ZDCPileInputTag_, mcc);
361 LogDebug(
"DataMixingHcalDigiWorker") <<
"total # ZDC digis: " << ZDCDigis->
size();
368 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
369 const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
395 std::unique_ptr< HBHEDigiCollection > HBHEdigis = buildHcalDigis<HBHEDigiCollection> (
HBHEDigiStorage_, *conditions);
396 std::unique_ptr< HODigiCollection > HOdigis = buildHcalDigis<HODigiCollection> (
HODigiStorage_, *conditions);
397 std::unique_ptr< HFDigiCollection > HFdigis = buildHcalDigis<HFDigiCollection> (
HFDigiStorage_, *conditions);
398 std::unique_ptr< QIE10DigiCollection > QIE10digis = buildHcalDigis<QIE10DigiCollection> (
QIE10DigiStorage_, *conditions);
399 std::unique_ptr< QIE11DigiCollection > QIE11digis = buildHcalDigis<QIE11DigiCollection> (
QIE11DigiStorage_, *conditions);
417 ZDCDigiMap::const_iterator iZDCchk;
421 currentID = iZDC->first;
423 if (currentID == formerID) {
426 unsigned int sizenew = (iZDC->second).
size();
427 unsigned int sizeold = ZDC_old.
size();
429 unsigned int max_samp =
std::max(sizenew, sizeold);
435 if(sizenew > sizeold) usenew =
true;
440 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
441 if(isamp < sizenew) {
442 fC_new = (iZDC->second)[isamp];
446 if(isamp < sizeold) {
447 fC_old = ZDC_old[isamp];
452 fC_sum = fC_new + fC_old;
454 if(usenew) {ZDC_bigger[isamp] = fC_sum; }
455 else { ZDC_old[isamp] = fC_sum; }
458 if(usenew) ZDC_old = ZDC_bigger;
473 unsigned int sizeold = ZDC_old.
size();
474 for(
unsigned int isamp = 0; isamp<sizeold; isamp++) {
475 coder.
fC2adc(ZDC_old,(ZDCdigis->back()), 1 );
479 formerID = currentID;
480 ZDC_old = iZDC->second;
495 unsigned int sizeold = (iZDC->second).
size();
496 for(
unsigned int isamp = 0; isamp<sizeold; isamp++) {
497 coder.
fC2adc(ZDC_old,(ZDCdigis->back()), 1 );
507 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HBHE Merged digis: " << HBHEdigis->size() ;
508 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HO Merged digis: " << HOdigis->size() ;
509 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HF Merged digis: " << HFdigis->size() ;
510 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # QIE10 Merged digis: " << QIE10digis->size() ;
511 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # QIE11 Merged digis: " << QIE11digis->size() ;
512 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # ZDC Merged digis: " << ZDCdigis->size() ;
523 HBHEDigiStorage_.clear();
524 HODigiStorage_.clear();
525 HFDigiStorage_.clear();
526 QIE10DigiStorage_.clear();
527 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< ZDCDataFrame >::const_iterator const_iterator
HBHEDigiMap HBHEDigiStorage_
void fC2adc(const CaloSamples &clf, HBHEDataFrame &df, int fCapIdOffset) const override
double pedestal(int fCapId) const
get pedestal for capid=0..3
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
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_