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 
21  es.get<EcalGainRatiosRcd>().get(gains);
22  es.get<EcalPedestalsRcd>().get(peds);
23  es.get<EcalWeightXtalGroupsRcd>().get(grps);
24  es.get<EcalTBWeightsRcd>().get(wgts);
25 
28 }
29 
33  DetId detid(itdg->id());
34 
35  const EcalPedestals::Item* aped = nullptr;
36  const EcalMGPAGainRatio* aGain = nullptr;
37  const EcalXtalGroupId* gid = nullptr;
38  EcalTBWeights::EcalTDCId tdcid(1);
39 
40  if (detid.subdetId() == EcalEndcap) {
41  unsigned int hashedIndex = EEDetId(detid).hashedIndex();
42  aped = &peds->endcap(hashedIndex);
43  aGain = &gains->endcap(hashedIndex);
44  gid = &grps->endcap(hashedIndex);
45  } else {
46  unsigned int hashedIndex = EBDetId(detid).hashedIndex();
47  aped = &peds->barrel(hashedIndex);
48  aGain = &gains->barrel(hashedIndex);
49  gid = &grps->barrel(hashedIndex);
50  }
51 
52  pedVec[0] = aped->mean_x12;
53  pedVec[1] = aped->mean_x6;
54  pedVec[2] = aped->mean_x1;
55  pedRMSVec[0] = aped->rms_x12;
56  pedRMSVec[1] = aped->rms_x6;
57  pedRMSVec[2] = aped->rms_x1;
58  gainRatios[0] = 1.;
59  gainRatios[1] = aGain->gain12Over6();
60  gainRatios[2] = aGain->gain6Over1() * aGain->gain12Over6();
61 
62  // now lookup the correct weights in the map
63  EcalTBWeights::EcalTBWeightMap const& wgtsMap = wgts->getMap();
64  EcalTBWeights::EcalTBWeightMap::const_iterator wit;
65  wit = wgtsMap.find(std::make_pair(*gid, tdcid));
66  if (wit == wgtsMap.end()) {
67  edm::LogError("EcalUncalibRecHitError")
68  << "No weights found for EcalGroupId: " << gid->id() << " and EcalTDCId: " << tdcid
69  << "\n skipping digi with id: " << detid.rawId();
70 
71  return false;
72  }
73  const EcalWeightSet& wset = wit->second; // this is the EcalWeightSet
74 
77  // const EcalWeightSet::EcalChi2WeightMatrix& mat3 = wset.getChi2WeightsBeforeGainSwitch();
78  // const EcalWeightSet::EcalChi2WeightMatrix& mat4 = wset.getChi2WeightsAfterGainSwitch();
79 
80  weights[0] = &mat1;
81  weights[1] = &mat2;
82 
83  // chi2mat[0] = &mat3;
84  // chi2mat[1] = &mat4;
85  /*
86  if (detid.subdetId()==EcalEndcap) {
87  result.push_back(uncalibMaker_endcap_.makeRecHit(*itdg, pedVec, gainRatios, weights, chi2mat));
88  } else {
89  result.push_back(uncalibMaker_barrel_.makeRecHit(*itdg, pedVec, gainRatios, weights, chi2mat));
90  }
91 */
92  if (detid.subdetId() == EcalEndcap) {
95  if (((EcalDataFrame)(*itdg)).hasSwitchToGain6())
97  if (((EcalDataFrame)(*itdg)).hasSwitchToGain1())
99  result.emplace_back(rhit);
100  } else {
103  if (((EcalDataFrame)(*itdg)).hasSwitchToGain6())
105  if (((EcalDataFrame)(*itdg)).hasSwitchToGain1())
107  result.emplace_back(rhit);
108  }
109  return true;
110 }
111 
114  return psd;
115 }
116 
123  "EcalUncalibRecHitWorkerWeights");
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
edm::ESHandle< EcalGainRatios > gains
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< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:20
const EcalWeightSet::EcalWeightMatrix * weights[2]
const unsigned int id() const
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:38
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:28
Definition: EBShape.h:6
Definition: DetId.h:17
edm::ESHandle< EcalWeightXtalGroups > grps
int hashedIndex() const
Definition: EEDetId.h:183
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:27
float gain12Over6() const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
T get() const
Definition: EventSetup.h:73
void setEventSetup(const edm::EventSetup &evtSetup)
const EcalTBWeightMap & getMap() const
Definition: EcalTBWeights.h:28
#define DEFINE_EDM_PLUGIN(factory, type, name)
edm::ParameterSetDescription getAlgoDescription() override
Definition: EEShape.h:6