31 typedef std::multimap<DetId, CaloSamples> HcalDigiMap;
35 DIGI& digi,
int capIdOffset = 0) {
40 coder.fC2adc(fC, digi, capIdOffset);
49 coder.adc2fC(digi, fC);
52 for (
int i = 0;
i < digi.size(); ++
i) {
53 int capId (digi.sample(
i).capid());
59 template <
class DIGIS>
60 void convertHcalDigis (
const DIGIS& digis,
const HcalDbService& conditions,
bool keepPedestals, HcalDigiMap& map) {
61 for (
auto digi = digis.begin(); digi != digis.end(); ++digi) {
63 convertAdc2fC (*digi, conditions, keepPedestals, fC);
64 if (!keepPedestals && map.find(digi->id()) == map.end()) {
65 edm::LogWarning(
"DataMixingHcalDigiWorker")<<
"No signal hits found for HCAL cell "<<digi->id()<<
" Pedestals may be lost for mixed hit";
71 template <
class DIGIS>
75 if (!e.
getByToken (token, digis))
return false;
76 convertHcalDigis (*digis, conditions,
true, map);
80 template <
class DIGIS>
84 auto digis = edm::getProductByTag<DIGIS>(ep,
tag, mcc);
85 if (!digis)
return false;
86 convertHcalDigis (*(digis->
product()), conditions,
false, map);
90 template <
class DIGIS>
91 std::auto_ptr<DIGIS> buildHcalDigis (
const HcalDigiMap& map,
const HcalDbService& conditions) {
92 std::auto_ptr<DIGIS> digis(
new DIGIS );
97 for(
auto hit = map.begin();
hit != map.end(); ++
hit) {
101 if (currentID == formerID) {
103 unsigned int sizenew = (hitSample).
size();
104 unsigned int sizeold = resultSample.
size();
105 if (sizenew > sizeold) {
106 for (
unsigned int isamp = sizeold; isamp < sizenew; ++isamp) resultSample[isamp] = 0;
107 resultSample.
setSize (sizenew);
109 for(
unsigned int isamp = 0; isamp<sizenew; isamp++) {
110 resultSample[isamp] += hitSample[isamp];
114 bool lastEntry = (++hit1 == map.end());
115 if (currentID != formerID || lastEntry) {
116 if (formerID>0 || lastEntry) {
119 convertFc2adc (resultSample, conditions, digis->back(), 0);
122 formerID = currentID;
123 resultSample = hitSample;
136 DataMixingHcalDigiWorker::DataMixingHcalDigiWorker() { }
140 label_(ps.getParameter<std::
string>(
"Label"))
170 if(ZDCPileInputTag_.
label() !=
"") DoZDC_ =
true;
199 LogInfo(
"DataMixingHcalDigiWorker")<<
"===============> adding MC signals for "<<e.
id();
215 ZDCDigis = pZDCDigis.
product();
217 LogDebug(
"DataMixingHcalDigiWorker") <<
"total # ZDC digis: " << ZDCDigis->
size();
226 it != ZDCDigis->
end(); ++it) {
231 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
232 const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
256 LogDebug(
"DataMixingHcalDigiWorker") <<
"\n===============> adding pileups from event "<<ep->
id()<<
" for bunchcrossing "<<bcr;
272 std::shared_ptr<Wrapper<ZDCDigiCollection>
const> ZDCDigisPTR =
279 LogDebug(
"DataMixingHcalDigiWorker") <<
"total # ZDC digis: " << ZDCDigis->
size();
283 it != ZDCDigis->
end(); ++it) {
288 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
289 const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
315 std::auto_ptr< HBHEDigiCollection > HBHEdigis = buildHcalDigis<HBHEDigiCollection> (
HBHEDigiStorage_, *conditions);
316 std::auto_ptr< HODigiCollection > HOdigis = buildHcalDigis<HODigiCollection> (
HODigiStorage_, *conditions);
317 std::auto_ptr< HFDigiCollection > HFdigis = buildHcalDigis<HFDigiCollection> (
HFDigiStorage_, *conditions);
335 ZDCDigiMap::const_iterator iZDCchk;
340 currentID = iZDC->first;
342 if (currentID == formerID) {
345 unsigned int sizenew = (iZDC->second).
size();
346 unsigned int sizeold = ZDC_old.
size();
348 unsigned int max_samp =
std::max(sizenew, sizeold);
354 if(sizenew > sizeold) usenew =
true;
359 for(
unsigned int isamp = 0; isamp<max_samp; isamp++) {
360 if(isamp < sizenew) {
361 fC_new = (iZDC->second)[isamp];
365 if(isamp < sizeold) {
366 fC_old = ZDC_old[isamp];
371 fC_sum = fC_new + fC_old;
373 if(usenew) {ZDC_bigger[isamp] = fC_sum; }
374 else { ZDC_old[isamp] = fC_sum; }
377 if(usenew) ZDC_old = ZDC_bigger;
388 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
389 const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
392 unsigned int sizeold = ZDC_old.
size();
393 for(
unsigned int isamp = 0; isamp<sizeold; isamp++) {
394 coder.
fC2adc(ZDC_old,(ZDCdigis->back()), 1 );
398 formerID = currentID;
399 ZDC_old = iZDC->second;
410 const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
411 const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
414 unsigned int sizeold = (iZDC->second).
size();
415 for(
unsigned int isamp = 0; isamp<sizeold; isamp++) {
416 coder.
fC2adc(ZDC_old,(ZDCdigis->back()), 1 );
427 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HBHE Merged digis: " << HBHEdigis->size() ;
428 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HO Merged digis: " << HOdigis->size() ;
429 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # HF Merged digis: " << HFdigis->size() ;
430 LogInfo(
"DataMixingHcalDigiWorker") <<
"total # ZDC Merged digis: " << ZDCdigis->size() ;
442 e.
put( hbheupgradeResult,
"HBHEUpgradeDigiCollection" );
443 e.
put( hfupgradeResult,
"HFUpgradeDigiCollection" );
446 HBHEDigiStorage_.clear();
447 HODigiStorage_.clear();
448 HFDigiStorage_.clear();
T getParameter(std::string const &) const
std::string HBHEDigiCollectionDM_
edm::InputTag HBHEPileInputTag_
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_
EventID const & id() const
edm::InputTag HBHEdigiCollectionSig_
std::string HODigiCollectionDM_
std::vector< ZDCDataFrame >::const_iterator const_iterator
HBHEDigiMap HBHEDigiStorage_
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_
virtual void fC2adc(const CaloSamples &clf, HBHEDataFrame &df, int fCapIdOffset) const
edm::EDGetTokenT< ZDCDigiCollection > ZDCDigiPToken_
MVATrainerComputer * calib
Container::value_type value_type
edm::EDGetTokenT< HFDigiCollection > HFDigiPToken_
void putHcal(edm::Event &e, const edm::EventSetup &ES)
edm::InputTag HFPileInputTag_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const
edm::InputTag HOPileInputTag_
edm::SortedCollection< HcalUpgradeDataFrame > HFUpgradeDigiCollection
edm::InputTag ZDCPileInputTag_
edm::SortedCollection< HcalUpgradeDataFrame > HBHEUpgradeDigiCollection
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_
DetId id() const
get the (generic) id
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
void addHcalSignals(const edm::Event &e, const edm::EventSetup &ES)
tuple size
Write out results.
const_iterator begin() const
edm::EDGetTokenT< HBHEDigiCollection > HBHEDigiToken_
edm::InputTag HOdigiCollectionSig_