48 #include "CLHEP/Matrix/Matrix.h"
49 #include "CLHEP/Matrix/SymMatrix.h"
80 if (!pEBDigis.isValid()) {
83 EBdigis = pEBDigis.product();
85 LogDebug(
"EcalUncalibRecHitInfo") <<
"total # EBdigis: " << EBdigis->size() ;
97 if (!pEEDigis.isValid()) {
100 EEdigis = pEEDigis.product();
102 LogDebug(
"EcalUncalibRecHitInfo") <<
"total # EEdigis: " << EEdigis->size() ;
109 if (!EBdigis && !EEdigis)
117 if (pRecTDC.isValid()) {
118 recTDC = pRecTDC.product();
139 LogDebug(
"EcalUncalibRecHitDebug") <<
"Fetching EcalTBWeights from DB " ;
150 LogDebug(
"EcalUncalibRecHitDebug") <<
"EcalTBWeightMap.size(): " << std::setprecision(3) << wgts->getMap().size() ;
156 LogDebug(
"EcalUncalibRecHitDebug") <<
"fetching pedestals....";
163 LogDebug(
"EcalUncalibRecHitDebug") <<
"done." ;
177 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
183 if (recTDC->offset() == -999.)
185 edm::LogError(
"EcalUncalibRecHitError") <<
"TDC bin completely out of range. Returning" ;
191 for(
unsigned int idig = 0; idig < EBdigis->size(); ++idig) {
200 LogDebug(
"EcalUncalibRecHitDebug") <<
"looking up pedestal for crystal: " <<
EBDetId(itdg.
id()) ;
202 pedIter = pedMap.find(itdg.
id().
rawId());
203 if( pedIter == pedMap.end() ) {
204 edm::LogError(
"EcalUncalibRecHitError") <<
"error!! could not find pedestals for channel: " <<
EBDetId(itdg.
id())
205 <<
"\n no uncalib rechit will be made for this digi!"
212 pedVec[0]=aped.mean_x12;pedVec[1]=aped.mean_x6;pedVec[2]=aped.mean_x1;
213 pedRMSVec[0]=aped.rms_x12;pedRMSVec[1]=aped.rms_x6;pedRMSVec[2]=aped.rms_x1;
217 LogDebug(
"EcalUncalibRecHitDebug") <<
"looking up gainRatios for crystal: " <<
EBDetId(itdg.
id()) ;
219 gainIter = gainMap.find(itdg.
id().
rawId());
220 if( gainIter == gainMap.end() ) {
221 edm::LogError(
"EcalUncalibRecHitError") <<
"error!! could not find gain ratios for channel: " <<
EBDetId(itdg.
id())
222 <<
"\n no uncalib rechit will be made for this digi!"
227 double gainRatios[3];
233 git = grpMap.find( itdg.
id().
rawId() );
234 if( git == grpMap.end() ) {
235 edm::LogError(
"EcalUncalibRecHitError") <<
"No group id found for this crystal. something wrong with EcalWeightXtalGroups in your DB?"
236 <<
"\n no uncalib rechit will be made for digi with id: " <<
EBDetId(itdg.
id())
244 double sampleGainRef = 1;
245 int sampleSwitch = 999;
249 if(gainSample != sampleGainRef) {sampleGainRef = gainSample; sampleSwitch =
sample;}
256 if (recTDC->offset() <= 0.)
258 if (recTDC->offset() >= 1.)
261 tdcBin = int(recTDC->offset()*float(
nbTimeBin_))+1;
265 edm::LogError(
"EcalUncalibRecHitError") <<
"TDC bin out of range " << tdcBin <<
" offset " << recTDC->offset();
282 wit = wgts->getMap().find( std::make_pair(gid,tdcid) );
283 if( wit == wgts->getMap().end() ) {
284 edm::LogError(
"EcalUncalibRecHitError") <<
"No weights found for EcalGroupId: " << gid.
id() <<
" and EcalTDCId: " << tdcid
285 <<
"\n skipping digi with id: " <<
EBDetId(itdg.
id())
295 LogDebug(
"EcalUncalibRecHitDebug") <<
"accessing matrices of weights...";
318 EBuncalibRechits->push_back( aHit );
321 LogDebug(
"EcalUncalibRecHitDebug") <<
"processed EBDataFrame with id: "
323 <<
"uncalib rechit amplitude: " << aHit.
amplitude()
335 for(
unsigned int idig = 0; idig < EEdigis->size(); ++idig) {
343 LogDebug(
"EcalUncalibRecHitDebug") <<
"looking up pedestal for crystal: " <<
EEDetId(itdg.
id()) ;
346 pedIter = pedMap.find(itdg.
id().
rawId());
347 if( pedIter == pedMap.end() ) {
348 edm::LogError(
"EcalUncalibRecHitError") <<
"error!! could not find pedestals for channel: " <<
EEDetId(itdg.
id())
349 <<
"\n no uncalib rechit will be made for this digi!"
356 pedVec[0]=aped.mean_x12;pedVec[1]=aped.mean_x6;pedVec[2]=aped.mean_x1;
357 pedRMSVec[0]=aped.rms_x12;pedRMSVec[1]=aped.rms_x6;pedRMSVec[2]=aped.rms_x1;
361 LogDebug(
"EcalUncalibRecHitDebug") <<
"looking up gainRatios for crystal: " <<
EEDetId(itdg.
id()) ;
364 gainIter = gainMap.find(itdg.
id().
rawId());
365 if( gainIter == gainMap.end() ) {
366 edm::LogError(
"EcalUncalibRecHitError") <<
"error!! could not find gain ratios for channel: " <<
EEDetId(itdg.
id())
367 <<
"\n no uncalib rechit will be made for this digi!"
372 double gainRatios[3];
378 git = grpMap.find( itdg.
id().
rawId() );
379 if( git == grpMap.end() ) {
380 edm::LogError(
"EcalUncalibRecHitError") <<
"No group id found for this crystal. something wrong with EcalWeightXtalGroups in your DB?"
381 <<
"\n no uncalib rechit will be made for digi with id: " <<
EEDetId(itdg.
id())
389 double sampleGainRef = 1;
390 int sampleSwitch = 999;
394 if(gainSample != sampleGainRef) {sampleGainRef = gainSample; sampleSwitch =
sample;}
401 if (recTDC->offset() <= 0.)
403 if (recTDC->offset() >= 1.)
406 tdcBin = int(recTDC->offset()*float(
nbTimeBin_))+1;
410 edm::LogError(
"EcalUncalibRecHitError") <<
"TDC bin out of range " << tdcBin <<
" offset " << recTDC->offset();
427 wit = wgts->getMap().find( std::make_pair(gid,tdcid) );
428 if( wit == wgts->getMap().end() ) {
429 edm::LogError(
"EcalUncalibRecHitError") <<
"No weights found for EcalGroupId: " << gid.
id() <<
" and EcalTDCId: " << tdcid
430 <<
"\n skipping digi with id: " <<
EEDetId(itdg.
id())
440 LogDebug(
"EcalUncalibRecHitDebug") <<
"accessing matrices of weights...";
464 EEuncalibRechits->push_back( aHit );
467 LogDebug(
"EcalUncalibRecHitDebug") <<
"processed EEDataFrame with id: "
469 <<
"uncalib rechit amplitude: " << aHit.
amplitude()
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag tdcRecInfoCollection_
const self & getMap() const
EcalMGPASample sample(int i) const
int gainId() const
get the gainId (2 bits)
std::string EEhitCollection_
std::string EBhitCollection_
const unsigned int id() const
edm::InputTag EEdigiCollection_
uint32_t rawId() const
get the raw id
const EBShape testbeamEBShape
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
EcalTBWeightUncalibRecHitProducer(const edm::ParameterSet &ps)
~EcalTBWeightUncalibRecHitProducer()
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *pedestalsRMS, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalShapeBase &testbeamPulseShape)
Compute parameters.
EcalWeightMatrix & getWeightsAfterGainSwitch()
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > EEalgo_
bool use2004OffsetConvention_
virtual void produce(edm::Event &evt, const edm::EventSetup &es)
EcalWeightMatrix & getWeightsBeforeGainSwitch()
std::vector< Item >::const_iterator const_iterator
float gain12Over6() const
const EEShape testbeamEEShape
math::Matrix< 3, 10 >::type EcalWeightMatrix
edm::InputTag EBdigiCollection_
EcalUncalibRecHitRecWeightsAlgo< EBDataFrame > EBalgo_