CMS 3D CMS Logo

EcalUncalibRecHitWorkerWeights.cc
Go to the documentation of this file.
1 
28 
30 public:
32  EcalUncalibRecHitWorkerWeights() = default; // for EcalUncalibRecHitFillDescriptionWorkerFactory
33 
34  void set(const edm::EventSetup& es) override;
35  bool run(const edm::Event& evt,
38 
40 
41 protected:
50 
51  double pedVec[3];
52  double pedRMSVec[3];
53  double gainRatios[3];
54 
57 
60 
61  EEShape testbeamEEShape; // used in the chi2
62  EBShape testbeamEBShape; // can be replaced by simple shape arrays of floats in the future (kostas)
63 };
64 
71  testbeamEEShape(c),
72  testbeamEBShape(c) {}
73 
79 
82 }
83 
87  DetId detid(itdg->id());
88 
89  const EcalPedestals::Item* aped = nullptr;
90  const EcalMGPAGainRatio* aGain = nullptr;
91  const EcalXtalGroupId* gid = nullptr;
92  EcalTBWeights::EcalTDCId tdcid(1);
93 
94  if (detid.subdetId() == EcalEndcap) {
95  unsigned int hashedIndex = EEDetId(detid).hashedIndex();
96  aped = &peds_->endcap(hashedIndex);
97  aGain = &gains_->endcap(hashedIndex);
98  gid = &grps_->endcap(hashedIndex);
99  } else {
100  unsigned int hashedIndex = EBDetId(detid).hashedIndex();
101  aped = &peds_->barrel(hashedIndex);
102  aGain = &gains_->barrel(hashedIndex);
103  gid = &grps_->barrel(hashedIndex);
104  }
105 
106  pedVec[0] = aped->mean_x12;
107  pedVec[1] = aped->mean_x6;
108  pedVec[2] = aped->mean_x1;
109  pedRMSVec[0] = aped->rms_x12;
110  pedRMSVec[1] = aped->rms_x6;
111  pedRMSVec[2] = aped->rms_x1;
112  gainRatios[0] = 1.;
113  gainRatios[1] = aGain->gain12Over6();
114  gainRatios[2] = aGain->gain6Over1() * aGain->gain12Over6();
115 
116  // now lookup the correct weights in the map
117  EcalTBWeights::EcalTBWeightMap const& wgtsMap = wgts_->getMap();
118  EcalTBWeights::EcalTBWeightMap::const_iterator wit;
119  wit = wgtsMap.find(std::make_pair(*gid, tdcid));
120  if (wit == wgtsMap.end()) {
121  edm::LogError("EcalUncalibRecHitError")
122  << "No weights found for EcalGroupId: " << gid->id() << " and EcalTDCId: " << tdcid
123  << "\n skipping digi with id: " << detid.rawId();
124 
125  return false;
126  }
127  const EcalWeightSet& wset = wit->second; // this is the EcalWeightSet
128 
131  // const EcalWeightSet::EcalChi2WeightMatrix& mat3 = wset.getChi2WeightsBeforeGainSwitch();
132  // const EcalWeightSet::EcalChi2WeightMatrix& mat4 = wset.getChi2WeightsAfterGainSwitch();
133 
134  weights[0] = &mat1;
135  weights[1] = &mat2;
136 
137  // chi2mat[0] = &mat3;
138  // chi2mat[1] = &mat4;
139  /*
140  if (detid.subdetId()==EcalEndcap) {
141  result.push_back(uncalibMaker_endcap_.makeRecHit(*itdg, pedVec, gainRatios, weights, chi2mat));
142  } else {
143  result.push_back(uncalibMaker_barrel_.makeRecHit(*itdg, pedVec, gainRatios, weights, chi2mat));
144  }
145 */
146  if (detid.subdetId() == EcalEndcap) {
149  if (((EcalDataFrame)(*itdg)).hasSwitchToGain6())
151  if (((EcalDataFrame)(*itdg)).hasSwitchToGain1())
153  result.emplace_back(rhit);
154  } else {
157  if (((EcalDataFrame)(*itdg)).hasSwitchToGain6())
159  if (((EcalDataFrame)(*itdg)).hasSwitchToGain1())
161  result.emplace_back(rhit);
162  }
163  return true;
164 }
165 
168  return psd;
169 }
170 
177  "EcalUncalibRecHitWorkerWeights");
edm::ESHandle< EcalWeightXtalGroups > grps_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const EcalTBWeightMap & getMap() const
Definition: EcalTBWeights.h:28
bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result) override
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
Definition: EcalTBWeights.h:18
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > uncalibMaker_endcap_
void set(const edm::EventSetup &es) override
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
Definition: EcalWeightSet.h:20
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:19
edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > tokenPeds_
Log< level::Error, false > LogError
const EcalWeightSet::EcalWeightMatrix * weights[2]
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:36
edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcd > tokenGains_
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *pedestalsRMS, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalShapeBase &testbeamPulseShape)
Compute parameters.
unsigned int id() const
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:27
void setEventSetup(const edm::EventSetup &evtSetup, bool normalize=true)
Definition: EBShape.h:7
float gain12Over6() const
Definition: DetId.h:17
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:26
float gain6Over1() const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
edm::ESGetToken< EcalTBWeights, EcalTBWeightsRcd > tokenWgts_
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
#define DEFINE_EDM_PLUGIN(factory, type, name)
const EcalWeightSet::EcalChi2WeightMatrix * chi2mat[2]
edm::ESGetToken< EcalWeightXtalGroups, EcalWeightXtalGroupsRcd > tokenGrps_
int hashedIndex() const
Definition: EEDetId.h:183
edm::ESHandle< EcalGainRatios > gains_
edm::ParameterSetDescription getAlgoDescription() override
Definition: EEShape.h:7
EcalUncalibRecHitRecWeightsAlgo< EBDataFrame > uncalibMaker_barrel_