Go to the documentation of this file.00001 #include "RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerWeights.h"
00002
00003 #include "FWCore/Framework/interface/EventSetup.h"
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006
00007 #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h"
00008 #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
00009 #include "CondFormats/DataRecord/interface/EcalWeightXtalGroupsRcd.h"
00010 #include "CondFormats/DataRecord/interface/EcalTBWeightsRcd.h"
00011
00012 EcalUncalibRecHitWorkerWeights::EcalUncalibRecHitWorkerWeights(const edm::ParameterSet&ps) :
00013 EcalUncalibRecHitWorkerBaseClass(ps)
00014 {
00015 }
00016
00017 void
00018 EcalUncalibRecHitWorkerWeights::set(const edm::EventSetup& es)
00019 {
00020 es.get<EcalGainRatiosRcd>().get(gains);
00021 es.get<EcalPedestalsRcd>().get(peds);
00022 es.get<EcalWeightXtalGroupsRcd>().get(grps);
00023 es.get<EcalTBWeightsRcd>().get(wgts);
00024 }
00025
00026
00027 bool
00028 EcalUncalibRecHitWorkerWeights::run( const edm::Event & evt,
00029 const EcalDigiCollection::const_iterator & itdg,
00030 EcalUncalibratedRecHitCollection & result )
00031 {
00032 DetId detid(itdg->id());
00033
00034 const EcalPedestals::Item * aped = 0;
00035 const EcalMGPAGainRatio * aGain = 0;
00036 const EcalXtalGroupId * gid = 0;
00037 EcalTBWeights::EcalTDCId tdcid(1);
00038
00039 if (detid.subdetId()==EcalEndcap) {
00040 unsigned int hashedIndex = EEDetId(detid).hashedIndex();
00041 aped = &peds->endcap(hashedIndex);
00042 aGain = &gains->endcap(hashedIndex);
00043 gid = &grps->endcap(hashedIndex);
00044 } else {
00045 unsigned int hashedIndex = EBDetId(detid).hashedIndex();
00046 aped = &peds->barrel(hashedIndex);
00047 aGain = &gains->barrel(hashedIndex);
00048 gid = &grps->barrel(hashedIndex);
00049 }
00050
00051 pedVec[0] = aped->mean_x12;
00052 pedVec[1] = aped->mean_x6;
00053 pedVec[2] = aped->mean_x1;
00054 pedRMSVec[0] = aped->rms_x12;
00055 pedRMSVec[1] = aped->rms_x6;
00056 pedRMSVec[2] = aped->rms_x1;
00057 gainRatios[0] = 1.;
00058 gainRatios[1] = aGain->gain12Over6();
00059 gainRatios[2] = aGain->gain6Over1()*aGain->gain12Over6();
00060
00061
00062 EcalTBWeights::EcalTBWeightMap const & wgtsMap = wgts->getMap();
00063 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
00064 wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
00065 if( wit == wgtsMap.end() ) {
00066 edm::LogError("EcalUncalibRecHitError") << "No weights found for EcalGroupId: "
00067 << gid->id() << " and EcalTDCId: " << tdcid
00068 << "\n skipping digi with id: " << detid.rawId();
00069
00070 return false;
00071 }
00072 const EcalWeightSet& wset = wit->second;
00073
00074 const EcalWeightSet::EcalWeightMatrix& mat1 = wset.getWeightsBeforeGainSwitch();
00075 const EcalWeightSet::EcalWeightMatrix& mat2 = wset.getWeightsAfterGainSwitch();
00076
00077
00078
00079 weights[0] = &mat1;
00080 weights[1] = &mat2;
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 if (detid.subdetId()==EcalEndcap) {
00092 result.push_back(uncalibMaker_endcap_.makeRecHit(*itdg, pedVec, pedRMSVec, gainRatios, weights, testbeamEEShape));
00093 } else {
00094 result.push_back(uncalibMaker_barrel_.makeRecHit(*itdg, pedVec, pedRMSVec, gainRatios, weights, testbeamEBShape));
00095 }
00096 return true;
00097 }
00098
00099 #include "FWCore/Framework/interface/MakerMacros.h"
00100 #include "RecoLocalCalo/EcalRecProducers/interface/EcalUncalibRecHitWorkerFactory.h"
00101 DEFINE_EDM_PLUGIN( EcalUncalibRecHitWorkerFactory, EcalUncalibRecHitWorkerWeights, "EcalUncalibRecHitWorkerWeights" );