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 
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");
ConfigurationDescriptions.h
EcalCondObjectContainer::end
const_iterator end() const
Definition: EcalCondObjectContainer.h:74
EcalUncalibRecHitWorkerAnalFit.h
EcalUncalibRecHitWorkerAnalFit
Definition: EcalUncalibRecHitWorkerAnalFit.h:30
Handle.h
EcalUncalibRecHitFillDescriptionWorkerFactory.h
MessageLogger.h
ESHandle.h
edm::DataFrameContainer::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: DataFrameContainer.h:61
EcalUncalibRecHitWorkerAnalFit::EcalUncalibRecHitWorkerAnalFit
EcalUncalibRecHitWorkerAnalFit()
Definition: EcalUncalibRecHitWorkerAnalFit.h:33
EcalUncalibratedRecHit::amplitude
float amplitude() const
Definition: EcalUncalibratedRecHit.h:28
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::SortedCollection
Definition: SortedCollection.h:49
EcalUncalibRecHitRecAnalFitAlgo::makeRecHit
EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalWeightSet::EcalChi2WeightMatrix **chi2Matrix) override
Compute parameters.
Definition: EcalUncalibRecHitRecAnalFitAlgo.h:46
EcalUncalibRecHitWorkerAnalFit::set
void set(const edm::EventSetup &es) override
Definition: EcalUncalibRecHitWorkerAnalFit.cc:40
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
EcalUncalibRecHitWorkerAnalFit::pedestalsToken_
edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > pedestalsToken_
Definition: EcalUncalibRecHitWorkerAnalFit.h:50
EcalBarrel
Definition: EcalSubdetector.h:10
EcalRecHitCollections.h
EcalUncalibRecHitWorkerAnalFit::getAlgoDescription
edm::ParameterSetDescription getAlgoDescription() override
Definition: EcalUncalibRecHitWorkerAnalFit.cc:128
DetId
Definition: DetId.h:17
MakerMacros.h
EcalUncalibRecHitWorkerRunOneDigiBase
Definition: EcalUncalibRecHitWorkerRunOneDigiBase.h:10
EcalDigiCollections.h
EcalUncalibRecHitWorkerAnalFit::pedHandle
edm::ESHandle< EcalPedestals > pedHandle
Definition: EcalUncalibRecHitWorkerAnalFit.h:48
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
EcalMGPAGainRatio.h
ParameterSetDescription.h
EcalUncalibratedRecHit.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
EcalMGPAGainRatio::gain12Over6
float gain12Over6() const
Definition: EcalMGPAGainRatio.h:19
EEDetId
Definition: EEDetId.h:14
EcalGainRatiosRcd
Definition: EcalGainRatiosRcd.h:5
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
EcalCondObjectContainer::Item
T Item
Definition: EcalCondObjectContainer.h:15
edmplugin::PluginFactory
Definition: PluginFactory.h:34
EcalUncalibRecHitWorkerAnalFit::pRatio
edm::ESHandle< EcalGainRatios > pRatio
Definition: EcalUncalibRecHitWorkerAnalFit.h:47
EcalPedestalsMapIterator
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
Definition: EcalPedestals.h:49
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
EBDataFrame.h
edm::EventSetup
Definition: EventSetup.h:58
EcalUncalibRecHitWorkerAnalFit::algoEE_
EcalUncalibRecHitRecAnalFitAlgo< EEDataFrame > algoEE_
Definition: EcalUncalibRecHitWorkerAnalFit.h:45
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
EcalMGPASample.h
EcalUncalibRecHitWorkerAnalFit::run
bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result) override
Definition: EcalUncalibRecHitWorkerAnalFit.cc:52
EEDataFrame.h
EcalUncalibratedRecHit
Definition: EcalUncalibratedRecHit.h:8
EcalUncalibRecHitWorkerFactory.h
EcalMGPAGainRatio::gain6Over1
float gain6Over1() const
Definition: EcalMGPAGainRatio.h:20
EcalUncalibRecHitWorkerAnalFit::ratiosToken_
edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcd > ratiosToken_
Definition: EcalUncalibRecHitWorkerAnalFit.h:49
EcalCondObjectContainer::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: EcalCondObjectContainer.h:19
mps_fire.result
result
Definition: mps_fire.py:311
EcalPedestalsRcd
Definition: EcalPedestalsRcd.h:5
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
EcalUncalibRecHitWorkerAnalFit::algoEB_
EcalUncalibRecHitRecAnalFitAlgo< EBDataFrame > algoEB_
Definition: EcalUncalibRecHitWorkerAnalFit.h:44
edm::Event
Definition: Event.h:73
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
EcalMGPAGainRatio
Definition: EcalMGPAGainRatio.h:13