CMS 3D CMS Logo

EcalUncalibRecHitWorkerAnalFit.cc
Go to the documentation of this file.
1 
30 
31 #include <cmath>
32 #include <iostream>
33 #include <vector>
34 
36 public:
39 
40  void set(const edm::EventSetup& es) override;
41  bool run(const edm::Event& evt,
44 
46 
47 private:
50 
55 };
56 
59  ratiosToken_(c.esConsumes<EcalGainRatios, EcalGainRatiosRcd>()),
60  pedestalsToken_(c.esConsumes<EcalPedestals, EcalPedestalsRcd>()) {}
61 
63  // Gain Ratios
64  LogDebug("EcalUncalibRecHitDebug") << "fetching gainRatios....";
66  LogDebug("EcalUncalibRecHitDebug") << "done.";
67 
68  // fetch the pedestals from the cond DB via EventSetup
69  LogDebug("EcalUncalibRecHitDebug") << "fetching pedestals....";
71  LogDebug("EcalUncalibRecHitDebug") << "done.";
72 }
73 
77  using namespace edm;
78 
79  const EcalGainRatioMap& gainMap = pRatio.product()->getMap(); // map of gain ratios
80  const EcalPedestalsMap& pedMap = pedHandle.product()->getMap(); // map of pedestals
81 
82  EcalPedestalsMapIterator pedIter; // pedestal iterator
83  EcalPedestals::Item aped; // pedestal object for a single xtal
84 
85  EcalGainRatioMap::const_iterator gainIter; // gain iterator
86  EcalMGPAGainRatio aGain; // gain object for a single xtal
87 
88  DetId detid(itdg->id());
89 
90  // find pedestals for this channel
91  //LogDebug("EcalUncalibRecHitDebug") << "looking up pedestal for crystal: " << itdg->id(); // FIXME
92  pedIter = pedMap.find(detid);
93  if (pedIter != pedMap.end()) {
94  aped = (*pedIter);
95  } else {
96  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "error!! could not find pedestals for channel: ";
97  if (detid.subdetId() == EcalBarrel) {
98  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EBDetId(detid);
99  } else {
100  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EEDetId(detid);
101  }
102  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "\n no uncalib rechit will be made for this digi!";
103  return false;
104  }
105  double pedVec[3];
106  pedVec[0] = aped.mean_x12;
107  pedVec[1] = aped.mean_x6;
108  pedVec[2] = aped.mean_x1;
109 
110  // find gain ratios
111  //LogDebug("EcalUncalibRecHitDebug") << "looking up gainRatios for crystal: " << itdg->id(); // FIXME
112  gainIter = gainMap.find(detid);
113  if (gainIter != gainMap.end()) {
114  aGain = (*gainIter);
115  } else {
116  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "error!! could not find gain ratios for channel: ";
117  if (detid.subdetId() == EcalBarrel) {
118  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EBDetId(detid);
119  } else {
120  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EEDetId(detid);
121  }
122  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "\n no uncalib rechit will be made for this digi!";
123  return false;
124  }
125  double gainRatios[3];
126  gainRatios[0] = 1.;
127  gainRatios[1] = aGain.gain12Over6();
128  gainRatios[2] = aGain.gain6Over1() * aGain.gain12Over6();
129 
130  if (detid.subdetId() == EcalBarrel) {
131  EcalUncalibratedRecHit aHit = algoEB_.makeRecHit(*itdg, pedVec, gainRatios, nullptr, nullptr);
132  result.push_back(aHit);
133  if (aHit.amplitude() > 0.) {
134  LogDebug("EcalUncalibRecHitInfo") << "EcalUncalibRecHitWorkerAnalFit: processed EBDataFrame with id: "
135  << EBDetId(detid) << "\n"
136  << "uncalib rechit amplitude: " << aHit.amplitude();
137  }
138  } else {
139  EcalUncalibratedRecHit aHit = algoEE_.makeRecHit(*itdg, pedVec, gainRatios, nullptr, nullptr);
140  result.push_back(aHit);
141  if (aHit.amplitude() > 0.) {
142  LogDebug("EcalUncalibRecHitInfo") << "EcalUncalibRecHitWorkerAnalFit: processed EEDataFrame with id: "
143  << EEDetId(detid) << "\n"
144  << "uncalib rechit amplitude: " << aHit.amplitude();
145  }
146  }
147  return true;
148 }
149 
152  //psd.addNode(edm::ParameterSet<edm::InputTag>("EBdigiCollection", edm::InputTag("ecalDigis","ebDigis")) and
153  // edm::ParameterSet<std::string>("EEhitCollection", "EcalUncalibRecHitsEE") and
154  // edm::ParameterSet<edm::InputTag>("EEdigiCollection", edm::InputTag("ecalDigis","eeDigis")) and
155  // edm::ParameterSet<std::string>("algo", "EcalUncalibRecHitWorkerAnalFit") and
156  // edm::ParameterSet<std::string>("EBhitCollection", "EcalUncalibRecHitsEB"));
157  //
158  return psd;
159 }
160 
167  "EcalUncalibRecHitWorkerAnalFit");
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Log< level::Error, false > LogError
edm::ESHandle< EcalPedestals > pedHandle
void set(const edm::EventSetup &es) override
edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcd > ratiosToken_
edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > pedestalsToken_
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
Definition: EcalPedestals.h:49
EcalUncalibRecHitRecAnalFitAlgo< EBDataFrame > algoEB_
bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result) override
EcalUncalibRecHitRecAnalFitAlgo< EEDataFrame > algoEE_
edm::ParameterSetDescription getAlgoDescription() override
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
const_iterator find(uint32_t rawId) const
float gain12Over6() const
Definition: DetId.h:17
std::vector< Item >::const_iterator const_iterator
EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalWeightSet::EcalChi2WeightMatrix **chi2Matrix) override
Compute parameters.
float gain6Over1() const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
edm::ESHandle< EcalGainRatios > pRatio
HLT enums.
#define DEFINE_EDM_PLUGIN(factory, type, name)
const_iterator end() const
#define LogDebug(id)