CMS 3D CMS Logo

EcalUncalibRecHitWorkerWeights.cc
Go to the documentation of this file.
2 
6 
11 
14 
16 
19 {
20 }
21 
22 void
24 {
25  es.get<EcalGainRatiosRcd>().get(gains);
26  es.get<EcalPedestalsRcd>().get(peds);
27  es.get<EcalWeightXtalGroupsRcd>().get(grps);
28  es.get<EcalTBWeightsRcd>().get(wgts);
29 }
30 
31 
32 bool
36 {
37  DetId detid(itdg->id());
38 
39  const EcalPedestals::Item * aped = nullptr;
40  const EcalMGPAGainRatio * aGain = nullptr;
41  const EcalXtalGroupId * gid = nullptr;
42  EcalTBWeights::EcalTDCId tdcid(1);
43 
44  if (detid.subdetId()==EcalEndcap) {
45  unsigned int hashedIndex = EEDetId(detid).hashedIndex();
46  aped = &peds->endcap(hashedIndex);
47  aGain = &gains->endcap(hashedIndex);
48  gid = &grps->endcap(hashedIndex);
49  } else {
50  unsigned int hashedIndex = EBDetId(detid).hashedIndex();
51  aped = &peds->barrel(hashedIndex);
52  aGain = &gains->barrel(hashedIndex);
53  gid = &grps->barrel(hashedIndex);
54  }
55 
56  pedVec[0] = aped->mean_x12;
57  pedVec[1] = aped->mean_x6;
58  pedVec[2] = aped->mean_x1;
59  pedRMSVec[0] = aped->rms_x12;
60  pedRMSVec[1] = aped->rms_x6;
61  pedRMSVec[2] = aped->rms_x1;
62  gainRatios[0] = 1.;
63  gainRatios[1] = aGain->gain12Over6();
64  gainRatios[2] = aGain->gain6Over1()*aGain->gain12Over6();
65 
66  // now lookup the correct weights in the map
67  EcalTBWeights::EcalTBWeightMap const & wgtsMap = wgts->getMap();
68  EcalTBWeights::EcalTBWeightMap::const_iterator wit;
69  wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
70  if( wit == wgtsMap.end() ) {
71  edm::LogError("EcalUncalibRecHitError") << "No weights found for EcalGroupId: "
72  << gid->id() << " and EcalTDCId: " << tdcid
73  << "\n skipping digi with id: " << detid.rawId();
74 
75  return false;
76  }
77  const EcalWeightSet& wset = wit->second; // this is the EcalWeightSet
78 
81 // const EcalWeightSet::EcalChi2WeightMatrix& mat3 = wset.getChi2WeightsBeforeGainSwitch();
82 // const EcalWeightSet::EcalChi2WeightMatrix& mat4 = wset.getChi2WeightsAfterGainSwitch();
83 
84  weights[0] = &mat1;
85  weights[1] = &mat2;
86 
87 // chi2mat[0] = &mat3;
88 // chi2mat[1] = &mat4;
89 /*
90  if (detid.subdetId()==EcalEndcap) {
91  result.push_back(uncalibMaker_endcap_.makeRecHit(*itdg, pedVec, gainRatios, weights, chi2mat));
92  } else {
93  result.push_back(uncalibMaker_barrel_.makeRecHit(*itdg, pedVec, gainRatios, weights, chi2mat));
94  }
95 */
96  if (detid.subdetId()==EcalEndcap) {
98  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain6() ) rhit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain6 );
99  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain1() ) rhit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain1 );
100  result.emplace_back(rhit);
101  } else {
103  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain6() ) rhit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain6 );
104  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain1() ) rhit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain1 );
105  result.emplace_back(rhit);
106  }
107  return true;
108 }
109 
112 
114  return psd;
115 }
116 
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
Definition: EcalTBWeights.h:21
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:86
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
edm::ESHandle< EcalGainRatios > gains
bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result) override
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > uncalibMaker_endcap_
void set(const edm::EventSetup &es) override
const EcalWeightSet::EcalWeightMatrix * weights[2]
const unsigned int id() const
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *pedestalsRMS, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalShapeBase &testbeamPulseShape)
Compute parameters.
float gain6Over1() const
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:30
Definition: DetId.h:18
edm::ESHandle< EcalWeightXtalGroups > grps
int hashedIndex() const
Definition: EEDetId.h:182
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:29
const T & get() const
Definition: EventSetup.h:55
float gain12Over6() const
const EcalTBWeightMap & getMap() const
Definition: EcalTBWeights.h:31
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:22
#define DEFINE_EDM_PLUGIN(factory, type, name)
edm::ParameterSetDescription getAlgoDescription() override