CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
31 
34 
37  ratiosToken_(c.esConsumes<EcalGainRatios, EcalGainRatiosRcd>()),
38  pedestalsToken_(c.esConsumes<EcalPedestals, EcalPedestalsRcd>()) {}
39 
41  // Gain Ratios
42  LogDebug("EcalUncalibRecHitDebug") << "fetching gainRatios....";
44  LogDebug("EcalUncalibRecHitDebug") << "done.";
45 
46  // fetch the pedestals from the cond DB via EventSetup
47  LogDebug("EcalUncalibRecHitDebug") << "fetching pedestals....";
49  LogDebug("EcalUncalibRecHitDebug") << "done.";
50 }
51 
55  using namespace edm;
56 
57  const EcalGainRatioMap& gainMap = pRatio.product()->getMap(); // map of gain ratios
58  const EcalPedestalsMap& pedMap = pedHandle.product()->getMap(); // map of pedestals
59 
60  EcalPedestalsMapIterator pedIter; // pedestal iterator
61  EcalPedestals::Item aped; // pedestal object for a single xtal
62 
63  EcalGainRatioMap::const_iterator gainIter; // gain iterator
64  EcalMGPAGainRatio aGain; // gain object for a single xtal
65 
66  DetId detid(itdg->id());
67 
68  // find pedestals for this channel
69  //LogDebug("EcalUncalibRecHitDebug") << "looking up pedestal for crystal: " << itdg->id(); // FIXME
70  pedIter = pedMap.find(detid);
71  if (pedIter != pedMap.end()) {
72  aped = (*pedIter);
73  } else {
74  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "error!! could not find pedestals for channel: ";
75  if (detid.subdetId() == EcalBarrel) {
76  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EBDetId(detid);
77  } else {
78  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EEDetId(detid);
79  }
80  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "\n no uncalib rechit will be made for this digi!";
81  return false;
82  }
83  double pedVec[3];
84  pedVec[0] = aped.mean_x12;
85  pedVec[1] = aped.mean_x6;
86  pedVec[2] = aped.mean_x1;
87 
88  // find gain ratios
89  //LogDebug("EcalUncalibRecHitDebug") << "looking up gainRatios for crystal: " << itdg->id(); // FIXME
90  gainIter = gainMap.find(detid);
91  if (gainIter != gainMap.end()) {
92  aGain = (*gainIter);
93  } else {
94  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "error!! could not find gain ratios for channel: ";
95  if (detid.subdetId() == EcalBarrel) {
96  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EBDetId(detid);
97  } else {
98  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << EEDetId(detid);
99  }
100  edm::LogError("EcalUncalibRecHitWorkerAnalFit") << "\n no uncalib rechit will be made for this digi!";
101  return false;
102  }
103  double gainRatios[3];
104  gainRatios[0] = 1.;
105  gainRatios[1] = aGain.gain12Over6();
106  gainRatios[2] = aGain.gain6Over1() * aGain.gain12Over6();
107 
108  if (detid.subdetId() == EcalBarrel) {
109  EcalUncalibratedRecHit aHit = algoEB_.makeRecHit(*itdg, pedVec, gainRatios, nullptr, nullptr);
110  result.push_back(aHit);
111  if (aHit.amplitude() > 0.) {
112  LogDebug("EcalUncalibRecHitInfo") << "EcalUncalibRecHitWorkerAnalFit: processed EBDataFrame with id: "
113  << EBDetId(detid) << "\n"
114  << "uncalib rechit amplitude: " << aHit.amplitude();
115  }
116  } else {
117  EcalUncalibratedRecHit aHit = algoEE_.makeRecHit(*itdg, pedVec, gainRatios, nullptr, nullptr);
118  result.push_back(aHit);
119  if (aHit.amplitude() > 0.) {
120  LogDebug("EcalUncalibRecHitInfo") << "EcalUncalibRecHitWorkerAnalFit: processed EEDataFrame with id: "
121  << EEDetId(detid) << "\n"
122  << "uncalib rechit amplitude: " << aHit.amplitude();
123  }
124  }
125  return true;
126 }
127 
130  //psd.addNode(edm::ParameterSet<edm::InputTag>("EBdigiCollection", edm::InputTag("ecalDigis","ebDigis")) and
131  // edm::ParameterSet<std::string>("EEhitCollection", "EcalUncalibRecHitsEE") and
132  // edm::ParameterSet<edm::InputTag>("EEdigiCollection", edm::InputTag("ecalDigis","eeDigis")) and
133  // edm::ParameterSet<std::string>("algo", "EcalUncalibRecHitWorkerAnalFit") and
134  // edm::ParameterSet<std::string>("EBhitCollection", "EcalUncalibRecHitsEB"));
135  //
136  return psd;
137 }
138 
145  "EcalUncalibRecHitWorkerAnalFit");
const edm::EventSetup & c
void push_back(T const &t)
Log< level::Error, false > LogError
edm::ESHandle< EcalPedestals > pedHandle
tuple result
Definition: mps_fire.py:311
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
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.
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
edm::ESHandle< EcalGainRatios > pRatio
#define DEFINE_EDM_PLUGIN(factory, type, name)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
#define LogDebug(id)