CMS 3D CMS Logo

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