43 #include "CLHEP/Matrix/Matrix.h"
44 #include "CLHEP/Matrix/SymMatrix.h"
80 LogDebug(
"EcalUncalibRecHitInfo") <<
"total # EBdigis: " << EBdigis->
size();
96 LogDebug(
"EcalUncalibRecHitInfo") <<
"total # EEdigis: " << EEdigis->
size();
102 if (!EBdigis && !EEdigis)
130 LogDebug(
"EcalUncalibRecHitDebug") <<
"Fetching EcalTBWeights from DB ";
141 LogDebug(
"EcalUncalibRecHitDebug") <<
"EcalTBWeightMap.size(): " << std::setprecision(3) << wgts->
getMap().size();
147 LogDebug(
"EcalUncalibRecHitDebug") <<
"fetching pedestals....";
154 LogDebug(
"EcalUncalibRecHitDebug") <<
"done.";
159 auto EBuncalibRechits = std::make_unique<EBUncalibratedRecHitCollection>();
160 auto EEuncalibRechits = std::make_unique<EEUncalibratedRecHitCollection>();
168 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
174 if (recTDC->
offset() == -999.) {
175 edm::LogError(
"EcalUncalibRecHitError") <<
"TDC bin completely out of range. Returning";
180 for (
unsigned int idig = 0; idig < EBdigis->
size(); ++idig) {
187 LogDebug(
"EcalUncalibRecHitDebug") <<
"looking up pedestal for crystal: " <<
EBDetId(itdg.
id());
190 if (pedIter == pedMap.
end()) {
192 <<
"error!! could not find pedestals for channel: " <<
EBDetId(itdg.
id())
193 <<
"\n no uncalib rechit will be made for this digi!";
199 pedVec[0] = aped.mean_x12;
200 pedVec[1] = aped.mean_x6;
201 pedVec[2] = aped.mean_x1;
202 pedRMSVec[0] = aped.rms_x12;
203 pedRMSVec[1] = aped.rms_x6;
204 pedRMSVec[2] = aped.rms_x1;
208 LogDebug(
"EcalUncalibRecHitDebug") <<
"looking up gainRatios for crystal: " <<
EBDetId(itdg.
id());
211 if (gainIter == gainMap.
end()) {
213 <<
"error!! could not find gain ratios for channel: " <<
EBDetId(itdg.
id())
214 <<
"\n no uncalib rechit will be made for this digi!";
218 double gainRatios[3];
225 if (git == grpMap.
end()) {
227 <<
"No group id found for this crystal. something wrong with EcalWeightXtalGroups in your DB?"
228 <<
"\n no uncalib rechit will be made for digi with id: " <<
EBDetId(itdg.
id());
234 double sampleGainRef = 1;
235 int sampleSwitch = 999;
238 if (gainSample != sampleGainRef) {
239 sampleGainRef = gainSample;
247 if (recTDC->
offset() <= 0.)
249 else if (recTDC->
offset() >= 1.)
256 <<
"TDC bin out of range " << tdcBin <<
" offset " << recTDC->
offset();
273 wit = wgts->
getMap().find(std::make_pair(gid, tdcid));
274 if (wit == wgts->
getMap().end()) {
276 <<
"No weights found for EcalGroupId: " << gid.
id() <<
" and EcalTDCId: " << tdcid
277 <<
"\n skipping digi with id: " <<
EBDetId(itdg.
id());
285 LogDebug(
"EcalUncalibRecHitDebug") <<
"accessing matrices of weights...";
306 EBuncalibRechits->push_back(aHit);
309 LogDebug(
"EcalUncalibRecHitDebug") <<
"processed EBDataFrame with id: " <<
EBDetId(itdg.
id()) <<
"\n"
310 <<
"uncalib rechit amplitude: " << aHit.
amplitude();
319 for (
unsigned int idig = 0; idig < EEdigis->
size(); ++idig) {
326 LogDebug(
"EcalUncalibRecHitDebug") <<
"looking up pedestal for crystal: " <<
EEDetId(itdg.
id());
330 if (pedIter == pedMap.
end()) {
332 <<
"error!! could not find pedestals for channel: " <<
EEDetId(itdg.
id())
333 <<
"\n no uncalib rechit will be made for this digi!";
339 pedVec[0] = aped.mean_x12;
340 pedVec[1] = aped.mean_x6;
341 pedVec[2] = aped.mean_x1;
342 pedRMSVec[0] = aped.rms_x12;
343 pedRMSVec[1] = aped.rms_x6;
344 pedRMSVec[2] = aped.rms_x1;
348 LogDebug(
"EcalUncalibRecHitDebug") <<
"looking up gainRatios for crystal: " <<
EEDetId(itdg.
id());
352 if (gainIter == gainMap.
end()) {
354 <<
"error!! could not find gain ratios for channel: " <<
EEDetId(itdg.
id())
355 <<
"\n no uncalib rechit will be made for this digi!";
359 double gainRatios[3];
366 if (git == grpMap.
end()) {
368 <<
"No group id found for this crystal. something wrong with EcalWeightXtalGroups in your DB?"
369 <<
"\n no uncalib rechit will be made for digi with id: " <<
EEDetId(itdg.
id());
375 double sampleGainRef = 1;
376 int sampleSwitch = 999;
379 if (gainSample != sampleGainRef) {
380 sampleGainRef = gainSample;
388 if (recTDC->
offset() <= 0.)
390 else if (recTDC->
offset() >= 1.)
397 <<
"TDC bin out of range " << tdcBin <<
" offset " << recTDC->
offset();
414 wit = wgts->
getMap().find(std::make_pair(gid, tdcid));
415 if (wit == wgts->
getMap().end()) {
417 <<
"No weights found for EcalGroupId: " << gid.
id() <<
" and EcalTDCId: " << tdcid
418 <<
"\n skipping digi with id: " <<
EEDetId(itdg.
id());
426 LogDebug(
"EcalUncalibRecHitDebug") <<
"accessing matrices of weights...";
448 EEuncalibRechits->push_back(aHit);
451 LogDebug(
"EcalUncalibRecHitDebug") <<
"processed EEDataFrame with id: " <<
EEDetId(itdg.
id()) <<
"\n"
452 <<
"uncalib rechit amplitude: " << aHit.
amplitude()