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 for (
unsigned int isamp = sizeold; isamp < sizenew; ++isamp) resultSample[isamp] = 0;
178 resultSample.
setSize (sizenew);
180 for(
unsigned int isamp = 0; isamp<sizenew; isamp++) {
181 resultSample[isamp] += hitSample[isamp];
185 bool lastEntry = (++hit1 == map.end());
186 if (currentID != formerID || lastEntry) {
187 if (formerID>0 || lastEntry) {
189 buildHcalDigisHelper(*digis,formerID,resultSample,conditions);
192 formerID = currentID;
193 resultSample = hitSample;
208 DataMixingHcalDigiWorker::DataMixingHcalDigiWorker() { }
212 label_(ps.getParameter<
std::
string>(
"Label"))
249 if(ZDCPileInputTag_.
label() !=
"") DoZDC_ =
true;
280 LogInfo(
"DataMixingHcalDigiWorker")<<
"===============> adding MC signals for "<<e.
id();
298 ZDCDigis = pZDCDigis.
product();
300 LogDebug(
"DataMixingHcalDigiWorker") <<
"total # ZDC digis: " << ZDCDigis->
size();
313 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
314 const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
338 LogDebug(
"DataMixingHcalDigiWorker") <<
"\n===============> adding pileups from event "<<ep->
id()<<
" for bunchcrossing "<<bcr;
356 std::shared_ptr<Wrapper<ZDCDigiCollection>
const> ZDCDigisPTR = getProductByTag<ZDCDigiCollection>(*ep,
ZDCPileInputTag_, mcc);
362 LogDebug(
"DataMixingHcalDigiWorker") <<
"total # ZDC digis: " << ZDCDigis->
size();
369 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
370 const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
396 std::unique_ptr< HBHEDigiCollection > HBHEdigis = buildHcalDigis<HBHEDigiCollection> (
HBHEDigiStorage_, *conditions);
397 std::unique_ptr< HODigiCollection > HOdigis = buildHcalDigis<HODigiCollection> (
HODigiStorage_, *conditions);
398 std::unique_ptr< HFDigiCollection > HFdigis = buildHcalDigis<HFDigiCollection> (
HFDigiStorage_, *conditions);
399 std::unique_ptr< QIE10DigiCollection > QIE10digis = buildHcalDigis<QIE10DigiCollection> (
QIE10DigiStorage_, *conditions);
400 std::unique_ptr< QIE11DigiCollection > QIE11digis = buildHcalDigis<QIE11DigiCollection> (
QIE11DigiStorage_, *conditions);
418 ZDCDigiMap::const_iterator iZDCchk;
422 currentID = iZDC->first;
424 if (currentID == formerID) {
427 unsigned int sizenew = (iZDC->second).
size();
428 unsigned int sizeold = ZDC_old.
size();
430 unsigned int max_samp =
std::max(sizenew, sizeold);
436 if(sizenew > sizeold) usenew =
true;
441 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
442 if(isamp < sizenew) {
443 fC_new = (iZDC->second)[isamp];
447 if(isamp < sizeold) {
448 fC_old = ZDC_old[isamp];
453 fC_sum = fC_new + fC_old;
455 if(usenew) {ZDC_bigger[isamp] = fC_sum; }
456 else { ZDC_old[isamp] = fC_sum; }
459 if(usenew) ZDC_old = ZDC_bigger;
474 unsigned int sizeold = ZDC_old.
size();
475 for(
unsigned int isamp = 0; isamp<sizeold; isamp++) {
476 coder.
fC2adc(ZDC_old,(ZDCdigis->back()), 1 );
480 formerID = currentID;
481 ZDC_old = iZDC->second;
496 unsigned int sizeold = (iZDC->second).
size();
497 for(
unsigned int isamp = 0; isamp<sizeold; isamp++) {
498 coder.
fC2adc(ZDC_old,(ZDCdigis->back()), 1 );
508 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HBHE Merged digis: " << HBHEdigis->size() ;
509 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HO Merged digis: " << HOdigis->size() ;
510 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HF Merged digis: " << HFdigis->size() ;
511 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # QIE10 Merged digis: " << QIE10digis->size() ;
512 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # QIE11 Merged digis: " << QIE11digis->size() ;
513 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # ZDC Merged digis: " << ZDCdigis->size() ;
524 HBHEDigiStorage_.clear();
525 HODigiStorage_.clear();
526 HFDigiStorage_.clear();
527 QIE10DigiStorage_.clear();
528 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_