CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalUncalibRecHitWorkerFixedAlphaBetaFit Class Reference

#include <EcalUncalibRecHitWorkerFixedAlphaBetaFit.h>

Inheritance diagram for EcalUncalibRecHitWorkerFixedAlphaBetaFit:
EcalUncalibRecHitWorkerRunOneDigiBase EcalUncalibRecHitWorkerBaseClass

Public Member Functions

 EcalUncalibRecHitWorkerFixedAlphaBetaFit (const edm::ParameterSet &ps, edm::ConsumesCollector &)
 
 EcalUncalibRecHitWorkerFixedAlphaBetaFit ()
 
edm::ParameterSetDescription getAlgoDescription () override
 
bool run (const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result) override
 
void set (const edm::EventSetup &es) override
 
 ~EcalUncalibRecHitWorkerFixedAlphaBetaFit () override
 
- Public Member Functions inherited from EcalUncalibRecHitWorkerRunOneDigiBase
 EcalUncalibRecHitWorkerRunOneDigiBase (const edm::ParameterSet &p, edm::ConsumesCollector &c)
 
 EcalUncalibRecHitWorkerRunOneDigiBase (const edm::ParameterSet &p)
 
 EcalUncalibRecHitWorkerRunOneDigiBase ()
 
void run (const edm::Event &evt, const EcalDigiCollection &digis, EcalUncalibratedRecHitCollection &result) override
 
 ~EcalUncalibRecHitWorkerRunOneDigiBase () override
 
- Public Member Functions inherited from EcalUncalibRecHitWorkerBaseClass
 EcalUncalibRecHitWorkerBaseClass (const edm::ParameterSet &, edm::ConsumesCollector &c)
 
 EcalUncalibRecHitWorkerBaseClass (const edm::ParameterSet &)
 
 EcalUncalibRecHitWorkerBaseClass ()
 
virtual void set (const edm::Event &evt)
 
virtual ~EcalUncalibRecHitWorkerBaseClass ()
 

Private Member Functions

bool setAlphaBeta ()
 

Private Attributes

EcalUncalibRecHitFixedAlphaBetaAlgo< EBDataFramealgoEB_
 
EcalUncalibRecHitFixedAlphaBetaAlgo< EEDataFramealgoEE_
 
std::string alphabetaFilename_
 
std::vector< std::vector< std::pair< double, double > > > alphaBetaValues_
 
double alphaEB_
 
double alphaEE_
 
double AmplThrEB_
 
double AmplThrEE_
 
double betaEB_
 
double betaEE_
 
edm::ESGetToken< EcalPedestals, EcalPedestalsRcdpedestalsToken_
 
edm::ESHandle< EcalPedestalspedHandle
 
edm::ESHandle< EcalGainRatiospRatio
 
edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcdratiosToken_
 
bool useAlphaBetaArray_
 

Detailed Description

Definition at line 25 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Constructor & Destructor Documentation

◆ EcalUncalibRecHitWorkerFixedAlphaBetaFit() [1/2]

EcalUncalibRecHitWorkerFixedAlphaBetaFit::EcalUncalibRecHitWorkerFixedAlphaBetaFit ( const edm::ParameterSet ps,
edm::ConsumesCollector c 
)

Definition at line 29 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

References algoEB_, algoEE_, alphabetaFilename_, alphaEB_, alphaEE_, betaEB_, betaEE_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), setAlphaBeta(), EcalUncalibRecHitFixedAlphaBetaAlgo< C >::SetDynamicPedestal(), EcalUncalibRecHitFixedAlphaBetaAlgo< C >::SetMinAmpl(), AlCaHLTBitMon_QueryRunRegistry::string, and useAlphaBetaArray_.

34  alphaEB_ = ps.getParameter<double>("alphaEB");
35  betaEB_ = ps.getParameter<double>("betaEB");
36  alphaEE_ = ps.getParameter<double>("alphaEE");
37  betaEE_ = ps.getParameter<double>("betaEE");
38 
39  alphabetaFilename_ = ps.getUntrackedParameter<std::string>("AlphaBetaFilename");
40  useAlphaBetaArray_ = setAlphaBeta(); // set crystalwise values of alpha and beta
41  if (!useAlphaBetaArray_) {
42  edm::LogInfo("EcalUncalibRecHitError") << " No alfa-beta file found. Using the deafult values.";
43  }
44 
45  algoEB_.SetMinAmpl(ps.getParameter<double>("MinAmplBarrel"));
46  algoEE_.SetMinAmpl(ps.getParameter<double>("MinAmplEndcap"));
47 
48  bool dyn_pede = ps.getParameter<bool>("UseDynamicPedestal");
49  algoEB_.SetDynamicPedestal(dyn_pede);
50  algoEE_.SetDynamicPedestal(dyn_pede);
51 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > pedestalsToken_
EcalUncalibRecHitFixedAlphaBetaAlgo< EEDataFrame > algoEE_
T getUntrackedParameter(std::string const &, T const &) const
edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcd > ratiosToken_
EcalUncalibRecHitFixedAlphaBetaAlgo< EBDataFrame > algoEB_
Log< level::Info, false > LogInfo

◆ EcalUncalibRecHitWorkerFixedAlphaBetaFit() [2/2]

EcalUncalibRecHitWorkerFixedAlphaBetaFit::EcalUncalibRecHitWorkerFixedAlphaBetaFit ( )
inline

Definition at line 28 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

28 {};

◆ ~EcalUncalibRecHitWorkerFixedAlphaBetaFit()

EcalUncalibRecHitWorkerFixedAlphaBetaFit::~EcalUncalibRecHitWorkerFixedAlphaBetaFit ( )
inlineoverride

Definition at line 29 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

29 {};

Member Function Documentation

◆ getAlgoDescription()

edm::ParameterSetDescription EcalUncalibRecHitWorkerFixedAlphaBetaFit::getAlgoDescription ( )
overridevirtual

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 179 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

References edm::ParameterSetDescription::addNode().

179  {
181 
182  psd.addNode(edm::ParameterDescription<double>("alphaEB", 1.138, true) and
183  edm::ParameterDescription<double>("alphaEE", 1.89, true) and
184  edm::ParameterDescription<std::string>("AlphaBetaFilename", "NOFILE", false) and
185  edm::ParameterDescription<double>("betaEB", 1.655, true) and
186  edm::ParameterDescription<double>("MinAmplEndcap", 14.0, true) and
187  edm::ParameterDescription<double>("MinAmplBarrel", 8.0, true) and
188  edm::ParameterDescription<double>("betaEE", 1.4, true) and
189  edm::ParameterDescription<bool>("UseDynamicPedestal", true, true));
190 
191  return psd;
192 }
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)

◆ run()

bool EcalUncalibRecHitWorkerFixedAlphaBetaFit::run ( const edm::Event evt,
const EcalDigiCollection::const_iterator digi,
EcalUncalibratedRecHitCollection result 
)
overridevirtual

Implements EcalUncalibRecHitWorkerRunOneDigiBase.

Definition at line 96 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

References a, algoEB_, algoEE_, alphaBetaValues_, alphaEB_, alphaEE_, b, betaEB_, betaEE_, EcalBarrel, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), EcalMGPAGainRatio::gain12Over6(), EcalMGPAGainRatio::gain6Over1(), EBDetId::ic(), EBDetId::ism(), EcalUncalibRecHitFixedAlphaBetaAlgo< C >::makeRecHit(), pedHandle, pRatio, mps_fire::result, EcalUncalibRecHitFixedAlphaBetaAlgo< C >::SetAlphaBeta(), and useAlphaBetaArray_.

98  {
99  const EcalGainRatioMap& gainMap = pRatio.product()->getMap(); // map of gain ratios
100  EcalGainRatioMap::const_iterator gainIter; // gain iterator
101  EcalMGPAGainRatio aGain; // gain object for a single xtal
102 
103  const EcalPedestalsMap& pedMap = pedHandle.product()->getMap(); // map of pedestals
104  EcalPedestalsMapIterator pedIter; // pedestal iterator
105  EcalPedestals::Item aped; // pedestal object for a single xtal
106 
107  DetId detid(itdg->id());
108 
109  // find pedestals for this channel
110  //LogDebug("EcalUncalibRecHitDebug") << "looking up pedestal for crystal: " << itdg->id();
111  pedIter = pedMap.find(itdg->id());
112  if (pedIter != pedMap.end()) {
113  aped = (*pedIter);
114  } else {
115  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << "error!! could not find pedestals for channel: ";
116  if (detid.subdetId() == EcalBarrel) {
117  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << EBDetId(detid);
118  } else {
119  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << EEDetId(detid);
120  }
121  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << "\n no uncalib rechit will be made for this digi!";
122  return false;
123  }
124  double pedVec[3];
125  pedVec[0] = aped.mean_x12;
126  pedVec[1] = aped.mean_x6;
127  pedVec[2] = aped.mean_x1;
128 
129  // find gain ratios
130  //LogDebug("EcalUncalibRecHitDebug") << "looking up gainRatios for crystal: " << EBDetId(itdg->id()) ; // FIXME!!!!!!!!
131  gainIter = gainMap.find(itdg->id());
132  if (gainIter != gainMap.end()) {
133  aGain = (*gainIter);
134  } else {
135  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << "error!! could not find gain ratios for channel: ";
136  if (detid.subdetId() == EcalBarrel) {
137  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << EBDetId(detid);
138  } else {
139  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << EEDetId(detid);
140  }
141  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << "\n no uncalib rechit will be made for this digi!";
142  return false;
143  }
144  double gainRatios[3];
145  gainRatios[0] = 1.;
146  gainRatios[1] = aGain.gain12Over6();
147  gainRatios[2] = aGain.gain6Over1() * aGain.gain12Over6();
148 
149  if (detid.subdetId() == EcalBarrel) {
150  // Define Alpha and Beta either by stored values or by default universal values
151  EBDetId ebDetId(detid);
152  double a, b;
153  if (useAlphaBetaArray_) {
154  if (!alphaBetaValues_[ebDetId.ism() - 1].empty()) {
155  a = alphaBetaValues_[ebDetId.ism() - 1][ebDetId.ic() - 1].first;
156  b = alphaBetaValues_[ebDetId.ism() - 1][ebDetId.ic() - 1].second;
157  if ((a == -1) && (b == -1)) {
158  a = alphaEB_;
159  b = betaEB_;
160  }
161  } else {
162  a = alphaEB_;
163  b = betaEB_;
164  }
165  } else {
166  a = alphaEB_;
167  b = betaEB_;
168  }
170  result.push_back(algoEB_.makeRecHit(*itdg, pedVec, gainRatios, nullptr, nullptr));
171  } else {
172  //FIX ME load in a and b from a file
174  result.push_back(algoEE_.makeRecHit(*itdg, pedVec, gainRatios, nullptr, nullptr));
175  }
176  return true;
177 }
EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalWeightSet::EcalChi2WeightMatrix **chi2Matrix) override
Compute parameters.
Log< level::Error, false > LogError
EcalUncalibRecHitFixedAlphaBetaAlgo< EEDataFrame > algoEE_
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
Definition: EcalPedestals.h:49
const_iterator find(uint32_t rawId) const
EcalUncalibRecHitFixedAlphaBetaAlgo< EBDataFrame > algoEB_
float gain12Over6() const
Definition: DetId.h:17
std::vector< Item >::const_iterator const_iterator
double b
Definition: hdecay.h:118
float gain6Over1() const
double a
Definition: hdecay.h:119
const_iterator end() const
std::vector< std::vector< std::pair< double, double > > > alphaBetaValues_

◆ set()

void EcalUncalibRecHitWorkerFixedAlphaBetaFit::set ( const edm::EventSetup es)
overridevirtual

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 53 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

References edm::EventSetup::getHandle(), LogDebug, pedestalsToken_, pedHandle, pRatio, and ratiosToken_.

53  {
54  // Gain Ratios
55  LogDebug("EcalUncalibRecHitDebug") << "fetching gainRatios....";
57  LogDebug("EcalUncalibRecHitDebug") << "done.";
58 
59  // fetch the pedestals from the cond DB via EventSetup
60  LogDebug("EcalUncalibRecHitDebug") << "fetching pedestals....";
62  LogDebug("EcalUncalibRecHitDebug") << "done.";
63 }
edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > pedestalsToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcd > ratiosToken_
#define LogDebug(id)

◆ setAlphaBeta()

bool EcalUncalibRecHitWorkerFixedAlphaBetaFit::setAlphaBeta ( )
private

Definition at line 66 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

References a, alphabetaFilename_, alphaBetaValues_, b, edmScanValgrind::buffer, relativeConstraints::empty, geometryDiff::file, AlCaHLTBitMon_ParallelJobs::p, and runTheMatrix::ret.

Referenced by EcalUncalibRecHitWorkerFixedAlphaBetaFit().

66  {
67  std::ifstream file(alphabetaFilename_.c_str());
68  if (!file.is_open())
69  return false;
70 
71  alphaBetaValues_.resize(36);
72 
73  char buffer[100];
74  int sm, cry, ret;
75  float a, b;
76  std::pair<double, double> p(-1, -1);
77 
78  while (!file.getline(buffer, 100).eof()) {
79  ret = sscanf(buffer, "%d %d %f %f", &sm, &cry, &a, &b);
80  if ((ret != 4) || (sm <= 0) || (sm > 36) || (cry <= 0) || (cry > 1700)) {
81  // send warning
82  continue;
83  }
84 
85  if (alphaBetaValues_[sm - 1].empty()) {
86  alphaBetaValues_[sm - 1].resize(1700, p);
87  }
88  alphaBetaValues_[sm - 1][cry - 1].first = a;
89  alphaBetaValues_[sm - 1][cry - 1].second = b;
90  }
91 
92  file.close();
93  return true;
94 }
ret
prodAgent to be discontinued
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
std::vector< std::vector< std::pair< double, double > > > alphaBetaValues_

Member Data Documentation

◆ algoEB_

EcalUncalibRecHitFixedAlphaBetaAlgo<EBDataFrame> EcalUncalibRecHitWorkerFixedAlphaBetaFit::algoEB_
private

◆ algoEE_

EcalUncalibRecHitFixedAlphaBetaAlgo<EEDataFrame> EcalUncalibRecHitWorkerFixedAlphaBetaFit::algoEE_
private

◆ alphabetaFilename_

std::string EcalUncalibRecHitWorkerFixedAlphaBetaFit::alphabetaFilename_
private

◆ alphaBetaValues_

std::vector<std::vector<std::pair<double, double> > > EcalUncalibRecHitWorkerFixedAlphaBetaFit::alphaBetaValues_
private

Definition at line 50 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Referenced by run(), and setAlphaBeta().

◆ alphaEB_

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::alphaEB_
private

◆ alphaEE_

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::alphaEE_
private

◆ AmplThrEB_

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::AmplThrEB_
private

Definition at line 39 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

◆ AmplThrEE_

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::AmplThrEE_
private

Definition at line 40 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

◆ betaEB_

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::betaEB_
private

◆ betaEE_

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::betaEE_
private

◆ pedestalsToken_

edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> EcalUncalibRecHitWorkerFixedAlphaBetaFit::pedestalsToken_
private

Definition at line 59 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Referenced by set().

◆ pedHandle

edm::ESHandle<EcalPedestals> EcalUncalibRecHitWorkerFixedAlphaBetaFit::pedHandle
private

Definition at line 57 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Referenced by run(), and set().

◆ pRatio

edm::ESHandle<EcalGainRatios> EcalUncalibRecHitWorkerFixedAlphaBetaFit::pRatio
private

Definition at line 56 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Referenced by run(), and set().

◆ ratiosToken_

edm::ESGetToken<EcalGainRatios, EcalGainRatiosRcd> EcalUncalibRecHitWorkerFixedAlphaBetaFit::ratiosToken_
private

Definition at line 58 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Referenced by set().

◆ useAlphaBetaArray_

bool EcalUncalibRecHitWorkerFixedAlphaBetaFit::useAlphaBetaArray_
private