CMS 3D CMS Logo

EcalUncalibRecHitWorkerAnalFit.cc
Go to the documentation of this file.
1 
13 
14 #include <iostream>
15 #include <cmath>
16 
18 
19 //#include "CondFormats/EcalObjects/interface/EcalPedestals.h"
20 //#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
23 
24 //#include "CLHEP/Matrix/Matrix.h"
25 //#include "CLHEP/Matrix/SymMatrix.h"
26 #include <vector>
27 
29 
32 
35  ratiosToken_(c.esConsumes<EcalGainRatios, EcalGainRatiosRcd>()),
36  pedestalsToken_(c.esConsumes<EcalPedestals, EcalPedestalsRcd>()) {}
37 
39  // Gain Ratios
40  LogDebug("EcalUncalibRecHitDebug") << "fetching gainRatios....";
42  LogDebug("EcalUncalibRecHitDebug") << "done.";
43 
44  // fetch the pedestals from the cond DB via EventSetup
45  LogDebug("EcalUncalibRecHitDebug") << "fetching pedestals....";
47  LogDebug("EcalUncalibRecHitDebug") << "done.";
48 }
49 
53  using namespace edm;
54 
55  const EcalGainRatioMap& gainMap = pRatio.product()->getMap(); // map of gain ratios
56  const EcalPedestalsMap& pedMap = pedHandle.product()->getMap(); // map of pedestals
57 
58  EcalPedestalsMapIterator pedIter; // pedestal iterator
59  EcalPedestals::Item aped; // pedestal object for a single xtal
60 
61  EcalGainRatioMap::const_iterator gainIter; // gain iterator
62  EcalMGPAGainRatio aGain; // gain object for a single xtal
63 
64  DetId detid(itdg->id());
65 
66  // find pedestals for this channel
67  //LogDebug("EcalUncalibRecHitDebug") << "looking up pedestal for crystal: " << itdg->id(); // FIXME
68  pedIter = pedMap.find(detid);
69  if (pedIter != pedMap.end()) {
70  aped = (*pedIter);
71  } else {
72  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "error!! could not find pedestals for channel: ";
73  if (detid.subdetId() == EcalBarrel) {
74  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EBDetId(detid);
75  } else {
76  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EEDetId(detid);
77  }
78  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "\n no uncalib rechit will be made for this digi!";
79  return false;
80  }
81  double pedVec[3];
82  pedVec[0] = aped.mean_x12;
83  pedVec[1] = aped.mean_x6;
84  pedVec[2] = aped.mean_x1;
85 
86  // find gain ratios
87  //LogDebug("EcalUncalibRecHitDebug") << "looking up gainRatios for crystal: " << itdg->id(); // FIXME
88  gainIter = gainMap.find(detid);
89  if (gainIter != gainMap.end()) {
90  aGain = (*gainIter);
91  } else {
92  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "error!! could not find gain ratios for channel: ";
93  if (detid.subdetId() == EcalBarrel) {
94  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EBDetId(detid);
95  } else {
96  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EEDetId(detid);
97  }
98  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "\n no uncalib rechit will be made for this digi!";
99  return false;
100  }
101  double gainRatios[3];
102  gainRatios[0] = 1.;
103  gainRatios[1] = aGain.gain12Over6();
104  gainRatios[2] = aGain.gain6Over1() * aGain.gain12Over6();
105 
106  if (detid.subdetId() == EcalBarrel) {
107  EcalUncalibratedRecHit aHit = algoEB_.makeRecHit(*itdg, pedVec, gainRatios, nullptr, nullptr);
108  result.push_back(aHit);
109  if (aHit.amplitude() > 0.) {
110  LogDebug("EcalUncalibRecHitInfo") << "EcalUncalibRecHitWorkerAnalFit: processed EBDataFrame with id: "
111  << EBDetId(detid) << "\n"
112  << "uncalib rechit amplitude: " << aHit.amplitude();
113  }
114  } else {
115  EcalUncalibratedRecHit aHit = algoEE_.makeRecHit(*itdg, pedVec, gainRatios, nullptr, nullptr);
116  result.push_back(aHit);
117  if (aHit.amplitude() > 0.) {
118  LogDebug("EcalUncalibRecHitInfo") << "EcalUncalibRecHitWorkerAnalFit: processed EEDataFrame with id: "
119  << EEDetId(detid) << "\n"
120  << "uncalib rechit amplitude: " << aHit.amplitude();
121  }
122  }
123  return true;
124 }
125 
128  //psd.addNode(edm::ParameterSet<edm::InputTag>("EBdigiCollection", edm::InputTag("ecalDigis","ebDigis")) and
129  // edm::ParameterSet<std::string>("EEhitCollection", "EcalUncalibRecHitsEE") and
130  // edm::ParameterSet<edm::InputTag>("EEdigiCollection", edm::InputTag("ecalDigis","eeDigis")) and
131  // edm::ParameterSet<std::string>("algo", "EcalUncalibRecHitWorkerAnalFit") and
132  // edm::ParameterSet<std::string>("EBhitCollection", "EcalUncalibRecHitsEB"));
133  //
134  return psd;
135 }
136 
143  "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)