CMS 3D CMS Logo

EcalUncalibRecHitWorkerWeights.cc
Go to the documentation of this file.
2 
6 
11 
14 
16 
18  EcalUncalibRecHitWorkerRunOneDigiBase(ps,c),testbeamEEShape(EEShape(true)), testbeamEBShape(EBShape(true))
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 
32 }
33 
34 
35 bool
39 {
40  DetId detid(itdg->id());
41 
42  const EcalPedestals::Item * aped = nullptr;
43  const EcalMGPAGainRatio * aGain = nullptr;
44  const EcalXtalGroupId * gid = nullptr;
45  EcalTBWeights::EcalTDCId tdcid(1);
46 
47  if (detid.subdetId()==EcalEndcap) {
48  unsigned int hashedIndex = EEDetId(detid).hashedIndex();
49  aped = &peds->endcap(hashedIndex);
50  aGain = &gains->endcap(hashedIndex);
51  gid = &grps->endcap(hashedIndex);
52  } else {
53  unsigned int hashedIndex = EBDetId(detid).hashedIndex();
54  aped = &peds->barrel(hashedIndex);
55  aGain = &gains->barrel(hashedIndex);
56  gid = &grps->barrel(hashedIndex);
57  }
58 
59  pedVec[0] = aped->mean_x12;
60  pedVec[1] = aped->mean_x6;
61  pedVec[2] = aped->mean_x1;
62  pedRMSVec[0] = aped->rms_x12;
63  pedRMSVec[1] = aped->rms_x6;
64  pedRMSVec[2] = aped->rms_x1;
65  gainRatios[0] = 1.;
66  gainRatios[1] = aGain->gain12Over6();
67  gainRatios[2] = aGain->gain6Over1()*aGain->gain12Over6();
68 
69  // now lookup the correct weights in the map
70  EcalTBWeights::EcalTBWeightMap const & wgtsMap = wgts->getMap();
71  EcalTBWeights::EcalTBWeightMap::const_iterator wit;
72  wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
73  if( wit == wgtsMap.end() ) {
74  edm::LogError("EcalUncalibRecHitError") << "No weights found for EcalGroupId: "
75  << gid->id() << " and EcalTDCId: " << tdcid
76  << "\n skipping digi with id: " << detid.rawId();
77 
78  return false;
79  }
80  const EcalWeightSet& wset = wit->second; // this is the EcalWeightSet
81 
84 // const EcalWeightSet::EcalChi2WeightMatrix& mat3 = wset.getChi2WeightsBeforeGainSwitch();
85 // const EcalWeightSet::EcalChi2WeightMatrix& mat4 = wset.getChi2WeightsAfterGainSwitch();
86 
87  weights[0] = &mat1;
88  weights[1] = &mat2;
89 
90 // chi2mat[0] = &mat3;
91 // chi2mat[1] = &mat4;
92 /*
93  if (detid.subdetId()==EcalEndcap) {
94  result.push_back(uncalibMaker_endcap_.makeRecHit(*itdg, pedVec, gainRatios, weights, chi2mat));
95  } else {
96  result.push_back(uncalibMaker_barrel_.makeRecHit(*itdg, pedVec, gainRatios, weights, chi2mat));
97  }
98 */
99  if (detid.subdetId()==EcalEndcap) {
101  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain6() ) rhit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain6 );
102  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain1() ) rhit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain1 );
103  result.emplace_back(rhit);
104  } else {
106  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain6() ) rhit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain6 );
107  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain1() ) rhit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain1 );
108  result.emplace_back(rhit);
109  }
110  return true;
111 }
112 
115 
117  return psd;
118 }
119 
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
Definition: EcalTBWeights.h:21
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
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: EBShape.h:6
Definition: DetId.h:18
edm::ESHandle< EcalWeightXtalGroups > grps
int hashedIndex() const
Definition: EEDetId.h:183
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:29
float gain12Over6() const
T get() const
Definition: EventSetup.h:71
void setEventSetup(const edm::EventSetup &evtSetup)
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
Definition: EEShape.h:6