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....";
47  LogDebug("EcalUncalibRecHitDebug") << "done.";
48 
49  // fetch the pedestals from the cond DB via EventSetup
50  LogDebug("EcalUncalibRecHitDebug") << "fetching pedestals....";
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");
ConfigurationDescriptions.h
EcalCondObjectContainer::end
const_iterator end() const
Definition: EcalCondObjectContainer.h:76
EcalUncalibRecHitWorkerAnalFit.h
EcalUncalibRecHitWorkerAnalFit
Definition: EcalUncalibRecHitWorkerAnalFit.h:27
Handle.h
EcalPedestals.h
EcalUncalibRecHitFillDescriptionWorkerFactory.h
MessageLogger.h
EcalPedestal::mean_x6
float mean_x6
Definition: EcalPedestals.h:21
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:30
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
EcalUncalibratedRecHit.h
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:43
EcalCondObjectContainer< EcalMGPAGainRatio >
EcalBarrel
Definition: EcalSubdetector.h:10
EcalRecHitCollections.h
EcalPedestal::mean_x1
float mean_x1
Definition: EcalPedestals.h:23
EcalUncalibRecHitWorkerAnalFit::getAlgoDescription
edm::ParameterSetDescription getAlgoDescription() override
Definition: EcalUncalibRecHitWorkerAnalFit.cc:131
DetId
Definition: DetId.h:17
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
EcalPedestal::mean_x12
float mean_x12
Definition: EcalPedestals.h:19
EcalUncalibRecHitWorkerRunOneDigiBase
Definition: EcalUncalibRecHitWorkerRunOneDigiBase.h:10
EcalDigiCollections.h
EcalUncalibRecHitWorkerAnalFit::pedHandle
edm::ESHandle< EcalPedestals > pedHandle
Definition: EcalUncalibRecHitWorkerAnalFit.h:45
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
EcalMGPAGainRatio.h
ParameterSetDescription.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:670
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
edmplugin::PluginFactory
Definition: PluginFactory.h:34
EcalUncalibRecHitWorkerAnalFit::pRatio
edm::ESHandle< EcalGainRatios > pRatio
Definition: EcalUncalibRecHitWorkerAnalFit.h:44
EcalPedestalsMapIterator
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
Definition: EcalPedestals.h:49
EBDataFrame.h
edm::EventSetup
Definition: EventSetup.h:57
EcalUncalibRecHitWorkerAnalFit::algoEE_
EcalUncalibRecHitRecAnalFitAlgo< EEDataFrame > algoEE_
Definition: EcalUncalibRecHitWorkerAnalFit.h:42
EcalGainRatiosRcd.h
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
EcalMGPASample.h
get
#define get
EcalGainRatios.h
EcalUncalibRecHitWorkerAnalFit::run
bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result) override
Definition: EcalUncalibRecHitWorkerAnalFit.cc:55
EEDataFrame.h
EcalUncalibratedRecHit
Definition: EcalUncalibratedRecHit.h:8
EcalUncalibRecHitWorkerFactory.h
EcalMGPAGainRatio::gain6Over1
float gain6Over1() const
Definition: EcalMGPAGainRatio.h:20
EcalPedestal
Definition: EcalPedestals.h:8
EcalPedestalsRcd.h
EcalCondObjectContainer< EcalMGPAGainRatio >::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: EcalCondObjectContainer.h:19
mps_fire.result
result
Definition: mps_fire.py:303
EcalPedestalsRcd
Definition: EcalPedestalsRcd.h:5
EcalUncalibRecHitWorkerAnalFit::algoEB_
EcalUncalibRecHitRecAnalFitAlgo< EBDataFrame > algoEB_
Definition: EcalUncalibRecHitWorkerAnalFit.h:41
edm::Event
Definition: Event.h:73
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
EcalMGPAGainRatio
Definition: EcalMGPAGainRatio.h:13