CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalUncalibRecHitWorkerFixedAlphaBetaFit Class Reference
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 32 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

Constructor & Destructor Documentation

◆ EcalUncalibRecHitWorkerFixedAlphaBetaFit() [1/2]

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

Definition at line 69 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_.

74  alphaEB_ = ps.getParameter<double>("alphaEB");
75  betaEB_ = ps.getParameter<double>("betaEB");
76  alphaEE_ = ps.getParameter<double>("alphaEE");
77  betaEE_ = ps.getParameter<double>("betaEE");
78 
79  alphabetaFilename_ = ps.getUntrackedParameter<std::string>("AlphaBetaFilename");
80  useAlphaBetaArray_ = setAlphaBeta(); // set crystalwise values of alpha and beta
81  if (!useAlphaBetaArray_) {
82  edm::LogInfo("EcalUncalibRecHitError") << " No alfa-beta file found. Using the deafult values.";
83  }
84 
85  algoEB_.SetMinAmpl(ps.getParameter<double>("MinAmplBarrel"));
86  algoEE_.SetMinAmpl(ps.getParameter<double>("MinAmplEndcap"));
87 
88  bool dyn_pede = ps.getParameter<bool>("UseDynamicPedestal");
89  algoEB_.SetDynamicPedestal(dyn_pede);
90  algoEE_.SetDynamicPedestal(dyn_pede);
91 }
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 35 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

35 {};

◆ ~EcalUncalibRecHitWorkerFixedAlphaBetaFit()

EcalUncalibRecHitWorkerFixedAlphaBetaFit::~EcalUncalibRecHitWorkerFixedAlphaBetaFit ( )
inlineoverride

Definition at line 36 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

36 {};

Member Function Documentation

◆ getAlgoDescription()

edm::ParameterSetDescription EcalUncalibRecHitWorkerFixedAlphaBetaFit::getAlgoDescription ( )
overridevirtual

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 219 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

References edm::ParameterSetDescription::addNode().

219  {
221 
222  psd.addNode(edm::ParameterDescription<double>("alphaEB", 1.138, true) and
223  edm::ParameterDescription<double>("alphaEE", 1.89, true) and
224  edm::ParameterDescription<std::string>("AlphaBetaFilename", "NOFILE", false) and
225  edm::ParameterDescription<double>("betaEB", 1.655, true) and
226  edm::ParameterDescription<double>("MinAmplEndcap", 14.0, true) and
227  edm::ParameterDescription<double>("MinAmplBarrel", 8.0, true) and
228  edm::ParameterDescription<double>("betaEE", 1.4, true) and
229  edm::ParameterDescription<bool>("UseDynamicPedestal", true, true));
230 
231  return psd;
232 }
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 136 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_.

138  {
139  const EcalGainRatioMap& gainMap = pRatio.product()->getMap(); // map of gain ratios
140  EcalGainRatioMap::const_iterator gainIter; // gain iterator
141  EcalMGPAGainRatio aGain; // gain object for a single xtal
142 
143  const EcalPedestalsMap& pedMap = pedHandle.product()->getMap(); // map of pedestals
144  EcalPedestalsMapIterator pedIter; // pedestal iterator
145  EcalPedestals::Item aped; // pedestal object for a single xtal
146 
147  DetId detid(itdg->id());
148 
149  // find pedestals for this channel
150  //LogDebug("EcalUncalibRecHitDebug") << "looking up pedestal for crystal: " << itdg->id();
151  pedIter = pedMap.find(itdg->id());
152  if (pedIter != pedMap.end()) {
153  aped = (*pedIter);
154  } else {
155  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << "error!! could not find pedestals for channel: ";
156  if (detid.subdetId() == EcalBarrel) {
157  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << EBDetId(detid);
158  } else {
159  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << EEDetId(detid);
160  }
161  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << "\n no uncalib rechit will be made for this digi!";
162  return false;
163  }
164  double pedVec[3];
165  pedVec[0] = aped.mean_x12;
166  pedVec[1] = aped.mean_x6;
167  pedVec[2] = aped.mean_x1;
168 
169  // find gain ratios
170  //LogDebug("EcalUncalibRecHitDebug") << "looking up gainRatios for crystal: " << EBDetId(itdg->id()) ; // FIXME!!!!!!!!
171  gainIter = gainMap.find(itdg->id());
172  if (gainIter != gainMap.end()) {
173  aGain = (*gainIter);
174  } else {
175  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << "error!! could not find gain ratios for channel: ";
176  if (detid.subdetId() == EcalBarrel) {
177  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << EBDetId(detid);
178  } else {
179  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << EEDetId(detid);
180  }
181  edm::LogError("EcalUncalibRecHitWorkerFixedAlphaBetaFit") << "\n no uncalib rechit will be made for this digi!";
182  return false;
183  }
184  double gainRatios[3];
185  gainRatios[0] = 1.;
186  gainRatios[1] = aGain.gain12Over6();
187  gainRatios[2] = aGain.gain6Over1() * aGain.gain12Over6();
188 
189  if (detid.subdetId() == EcalBarrel) {
190  // Define Alpha and Beta either by stored values or by default universal values
191  EBDetId ebDetId(detid);
192  double a, b;
193  if (useAlphaBetaArray_) {
194  if (!alphaBetaValues_[ebDetId.ism() - 1].empty()) {
195  a = alphaBetaValues_[ebDetId.ism() - 1][ebDetId.ic() - 1].first;
196  b = alphaBetaValues_[ebDetId.ism() - 1][ebDetId.ic() - 1].second;
197  if ((a == -1) && (b == -1)) {
198  a = alphaEB_;
199  b = betaEB_;
200  }
201  } else {
202  a = alphaEB_;
203  b = betaEB_;
204  }
205  } else {
206  a = alphaEB_;
207  b = betaEB_;
208  }
210  result.push_back(algoEB_.makeRecHit(*itdg, pedVec, gainRatios, nullptr, nullptr));
211  } else {
212  //FIX ME load in a and b from a file
214  result.push_back(algoEE_.makeRecHit(*itdg, pedVec, gainRatios, nullptr, nullptr));
215  }
216  return true;
217 }
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:120
float gain6Over1() const
double a
Definition: hdecay.h:121
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 93 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

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

93  {
94  // Gain Ratios
95  LogDebug("EcalUncalibRecHitDebug") << "fetching gainRatios....";
97  LogDebug("EcalUncalibRecHitDebug") << "done.";
98 
99  // fetch the pedestals from the cond DB via EventSetup
100  LogDebug("EcalUncalibRecHitDebug") << "fetching pedestals....";
102  LogDebug("EcalUncalibRecHitDebug") << "done.";
103 }
edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > pedestalsToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcd > ratiosToken_
#define LogDebug(id)

◆ setAlphaBeta()

bool EcalUncalibRecHitWorkerFixedAlphaBetaFit::setAlphaBeta ( )
private

Definition at line 106 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

References a, alphabetaFilename_, alphaBetaValues_, b, edmScanValgrind::buffer, relativeConstraints::empty, geometryDiff::file, AlCaHLTBitMon_ParallelJobs::p, runTheMatrix::ret, and ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::sm().

Referenced by EcalUncalibRecHitWorkerFixedAlphaBetaFit().

106  {
107  std::ifstream file(alphabetaFilename_.c_str());
108  if (!file.is_open())
109  return false;
110 
111  alphaBetaValues_.resize(36);
112 
113  char buffer[100];
114  int sm, cry, ret;
115  float a, b;
116  std::pair<double, double> p(-1, -1);
117 
118  while (!file.getline(buffer, 100).eof()) {
119  ret = sscanf(buffer, "%d %d %f %f", &sm, &cry, &a, &b);
120  if ((ret != 4) || (sm <= 0) || (sm > 36) || (cry <= 0) || (cry > 1700)) {
121  // send warning
122  continue;
123  }
124 
125  if (alphaBetaValues_[sm - 1].empty()) {
126  alphaBetaValues_[sm - 1].resize(1700, p);
127  }
128  alphaBetaValues_[sm - 1][cry - 1].first = a;
129  alphaBetaValues_[sm - 1][cry - 1].second = b;
130  }
131 
132  file.close();
133  return true;
134 }
ret
prodAgent to be discontinued
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
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 57 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

Referenced by run(), and setAlphaBeta().

◆ alphaEB_

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::alphaEB_
private

◆ alphaEE_

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::alphaEE_
private

◆ AmplThrEB_

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::AmplThrEB_
private

Definition at line 46 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

◆ AmplThrEE_

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::AmplThrEE_
private

Definition at line 47 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

◆ betaEB_

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::betaEB_
private

◆ betaEE_

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::betaEE_
private

◆ pedestalsToken_

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

Definition at line 66 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

Referenced by set().

◆ pedHandle

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

Definition at line 64 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

Referenced by run(), and set().

◆ pRatio

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

Definition at line 63 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

Referenced by run(), and set().

◆ ratiosToken_

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

Definition at line 65 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

Referenced by set().

◆ useAlphaBetaArray_

bool EcalUncalibRecHitWorkerFixedAlphaBetaFit::useAlphaBetaArray_
private