43 #include "CLHEP/Matrix/Matrix.h"
44 #include "CLHEP/Matrix/SymMatrix.h"
75 if (!pEBDigis.isValid()) {
78 EBdigis = pEBDigis.product();
80 LogDebug(
"EcalUncalibRecHitInfo") <<
"total # EBdigis: " << EBdigis->size() ;
92 if (!pEEDigis.isValid()) {
95 EEdigis = pEEDigis.product();
97 LogDebug(
"EcalUncalibRecHitInfo") <<
"total # EEdigis: " << EEdigis->size() ;
104 if (!EBdigis && !EEdigis)
112 if (pRecTDC.isValid()) {
113 recTDC = pRecTDC.product();
134 LogDebug(
"EcalUncalibRecHitDebug") <<
"Fetching EcalTBWeights from DB " ;
145 LogDebug(
"EcalUncalibRecHitDebug") <<
"EcalTBWeightMap.size(): " << std::setprecision(3) << wgts->getMap().size() ;
151 LogDebug(
"EcalUncalibRecHitDebug") <<
"fetching pedestals....";
158 LogDebug(
"EcalUncalibRecHitDebug") <<
"done." ;
172 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
178 if (recTDC->offset() == -999.)
180 edm::LogError(
"EcalUncalibRecHitError") <<
"TDC bin completely out of range. Returning" ;
186 for(
unsigned int idig = 0; idig < EBdigis->size(); ++idig) {
195 LogDebug(
"EcalUncalibRecHitDebug") <<
"looking up pedestal for crystal: " <<
EBDetId(itdg.
id()) ;
197 pedIter = pedMap.find(itdg.
id().
rawId());
198 if( pedIter == pedMap.end() ) {
199 edm::LogError(
"EcalUncalibRecHitError") <<
"error!! could not find pedestals for channel: " <<
EBDetId(itdg.
id())
200 <<
"\n no uncalib rechit will be made for this digi!"
212 LogDebug(
"EcalUncalibRecHitDebug") <<
"looking up gainRatios for crystal: " <<
EBDetId(itdg.
id()) ;
214 gainIter = gainMap.find(itdg.
id().
rawId());
215 if( gainIter == gainMap.end() ) {
216 edm::LogError(
"EcalUncalibRecHitError") <<
"error!! could not find gain ratios for channel: " <<
EBDetId(itdg.
id())
217 <<
"\n no uncalib rechit will be made for this digi!"
222 double gainRatios[3];
228 git = grpMap.find( itdg.
id().
rawId() );
229 if( git == grpMap.end() ) {
230 edm::LogError(
"EcalUncalibRecHitError") <<
"No group id found for this crystal. something wrong with EcalWeightXtalGroups in your DB?"
231 <<
"\n no uncalib rechit will be made for digi with id: " <<
EBDetId(itdg.
id())
239 double sampleGainRef = 1;
240 int sampleSwitch = 999;
244 if(gainSample != sampleGainRef) {sampleGainRef = gainSample; sampleSwitch =
sample;}
251 if (recTDC->offset() <= 0.)
253 if (recTDC->offset() >= 1.)
256 tdcBin = int(recTDC->offset()*float(
nbTimeBin_))+1;
260 edm::LogError(
"EcalUncalibRecHitError") <<
"TDC bin out of range " << tdcBin <<
" offset " << recTDC->offset();
277 wit = wgts->getMap().find( std::make_pair(gid,tdcid) );
278 if( wit == wgts->getMap().end() ) {
279 edm::LogError(
"EcalUncalibRecHitError") <<
"No weights found for EcalGroupId: " << gid.
id() <<
" and EcalTDCId: " << tdcid
280 <<
"\n skipping digi with id: " <<
EBDetId(itdg.
id())
290 LogDebug(
"EcalUncalibRecHitDebug") <<
"accessing matrices of weights...";
313 EBuncalibRechits->push_back( aHit );
316 LogDebug(
"EcalUncalibRecHitDebug") <<
"processed EBDataFrame with id: "
318 <<
"uncalib rechit amplitude: " << aHit.
amplitude()
330 for(
unsigned int idig = 0; idig < EEdigis->size(); ++idig) {
338 LogDebug(
"EcalUncalibRecHitDebug") <<
"looking up pedestal for crystal: " <<
EEDetId(itdg.
id()) ;
341 pedIter = pedMap.find(itdg.
id().
rawId());
342 if( pedIter == pedMap.end() ) {
343 edm::LogError(
"EcalUncalibRecHitError") <<
"error!! could not find pedestals for channel: " <<
EEDetId(itdg.
id())
344 <<
"\n no uncalib rechit will be made for this digi!"
356 LogDebug(
"EcalUncalibRecHitDebug") <<
"looking up gainRatios for crystal: " <<
EEDetId(itdg.
id()) ;
359 gainIter = gainMap.find(itdg.
id().
rawId());
360 if( gainIter == gainMap.end() ) {
361 edm::LogError(
"EcalUncalibRecHitError") <<
"error!! could not find gain ratios for channel: " <<
EEDetId(itdg.
id())
362 <<
"\n no uncalib rechit will be made for this digi!"
367 double gainRatios[3];
373 git = grpMap.find( itdg.
id().
rawId() );
374 if( git == grpMap.end() ) {
375 edm::LogError(
"EcalUncalibRecHitError") <<
"No group id found for this crystal. something wrong with EcalWeightXtalGroups in your DB?"
376 <<
"\n no uncalib rechit will be made for digi with id: " <<
EEDetId(itdg.
id())
384 double sampleGainRef = 1;
385 int sampleSwitch = 999;
389 if(gainSample != sampleGainRef) {sampleGainRef = gainSample; sampleSwitch =
sample;}
396 if (recTDC->offset() <= 0.)
398 if (recTDC->offset() >= 1.)
401 tdcBin = int(recTDC->offset()*float(
nbTimeBin_))+1;
405 edm::LogError(
"EcalUncalibRecHitError") <<
"TDC bin out of range " << tdcBin <<
" offset " << recTDC->offset();
422 wit = wgts->getMap().find( std::make_pair(gid,tdcid) );
423 if( wit == wgts->getMap().end() ) {
424 edm::LogError(
"EcalUncalibRecHitError") <<
"No weights found for EcalGroupId: " << gid.
id() <<
" and EcalTDCId: " << tdcid
425 <<
"\n skipping digi with id: " <<
EEDetId(itdg.
id())
435 LogDebug(
"EcalUncalibRecHitDebug") <<
"accessing matrices of weights...";
459 EEuncalibRechits->push_back( aHit );
462 LogDebug(
"EcalUncalibRecHitDebug") <<
"processed EEDataFrame with id: "
464 <<
"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_