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::ESHandle< EcalPedestalspedHandle
 
edm::ESHandle< EcalGainRatiospRatio
 
bool useAlphaBetaArray_
 

Detailed Description

Definition at line 23 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Constructor & Destructor Documentation

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

Definition at line 34 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  :
36 {
37  alphaEB_= ps.getParameter<double>("alphaEB");
38  betaEB_= ps.getParameter<double>("betaEB");
39  alphaEE_= ps.getParameter<double>("alphaEE");
40  betaEE_= ps.getParameter<double>("betaEE");
41 
42  alphabetaFilename_= ps.getUntrackedParameter<std::string>("AlphaBetaFilename");
43  useAlphaBetaArray_=setAlphaBeta(); // set crystalwise values of alpha and beta
44  if ( !useAlphaBetaArray_ ) {
45  edm::LogInfo("EcalUncalibRecHitError") << " No alfa-beta file found. Using the deafult values.";
46  }
47 
48  algoEB_.SetMinAmpl( ps.getParameter<double> ("MinAmplBarrel") );
49  algoEE_.SetMinAmpl( ps.getParameter<double> ("MinAmplEndcap") );
50 
51  bool dyn_pede = ps.getParameter<bool>("UseDynamicPedestal");
52  algoEB_.SetDynamicPedestal(dyn_pede);
53  algoEE_.SetDynamicPedestal(dyn_pede);
54 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
EcalUncalibRecHitFixedAlphaBetaAlgo< EEDataFrame > algoEE_
EcalUncalibRecHitFixedAlphaBetaAlgo< EBDataFrame > algoEB_
EcalUncalibRecHitWorkerFixedAlphaBetaFit::EcalUncalibRecHitWorkerFixedAlphaBetaFit ( )
inline

Definition at line 27 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

27 {};
EcalUncalibRecHitWorkerFixedAlphaBetaFit::~EcalUncalibRecHitWorkerFixedAlphaBetaFit ( )
inlineoverride

Definition at line 28 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

References mps_fire::result, and findQualityFiles::run.

28 {};

Member Function Documentation

edm::ParameterSetDescription EcalUncalibRecHitWorkerFixedAlphaBetaFit::getAlgoDescription ( )
overridevirtual

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 193 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

References edm::ParameterSetDescription::addNode(), and DEFINE_EDM_PLUGIN.

193  {
194 
196 
197  psd.addNode(edm::ParameterDescription<double>("alphaEB", 1.138, true) and
198  edm::ParameterDescription<double>("alphaEE", 1.89, true) and
199  edm::ParameterDescription<std::string>("AlphaBetaFilename", "NOFILE", false) and
200  edm::ParameterDescription<double>("betaEB", 1.655, true) and
201  edm::ParameterDescription<double>("MinAmplEndcap", 14.0, true) and
202  edm::ParameterDescription<double>("MinAmplBarrel", 8.0, true) and
203  edm::ParameterDescription<double>("betaEE", 1.4, true) and
204  edm::ParameterDescription<bool>("UseDynamicPedestal", true, true) );
205 
206  return psd;
207 }
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
bool EcalUncalibRecHitWorkerFixedAlphaBetaFit::run ( const edm::Event evt,
const EcalDigiCollection::const_iterator digi,
EcalUncalibratedRecHitCollection result 
)
overridevirtual

Implements EcalUncalibRecHitWorkerRunOneDigiBase.

Definition at line 107 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(), EcalPedestal::mean_x1, EcalPedestal::mean_x12, EcalPedestal::mean_x6, pedHandle, pRatio, edm::SortedCollection< T, SORT >::push_back(), EcalUncalibRecHitFixedAlphaBetaAlgo< C >::SetAlphaBeta(), and useAlphaBetaArray_.

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

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 58 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

References edm::EventSetup::get(), LogDebug, pedHandle, and pRatio.

59 {
60  // Gain Ratios
61  LogDebug("EcalUncalibRecHitDebug") << "fetching gainRatios....";
62  es.get<EcalGainRatiosRcd>().get(pRatio);
63  LogDebug("EcalUncalibRecHitDebug") << "done." ;
64 
65  // fetch the pedestals from the cond DB via EventSetup
66  LogDebug("EcalUncalibRecHitDebug") << "fetching pedestals....";
67  es.get<EcalPedestalsRcd>().get( pedHandle );
68  LogDebug("EcalUncalibRecHitDebug") << "done." ;
69 }
#define LogDebug(id)
const T & get() const
Definition: EventSetup.h:59
bool EcalUncalibRecHitWorkerFixedAlphaBetaFit::setAlphaBeta ( )
private

Definition at line 73 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

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

Referenced by EcalUncalibRecHitWorkerFixedAlphaBetaFit().

73  {
74  std::ifstream file(alphabetaFilename_.c_str());
75  if (! file.is_open())
76  return false;
77 
78  alphaBetaValues_.resize(36);
79 
80  char buffer[100];
81  int sm, cry,ret;
82  float a,b;
83  std::pair<double,double> p(-1,-1);
84 
85  while( ! file.getline(buffer,100).eof() ){
86  ret=sscanf(buffer,"%d %d %f %f", &sm, &cry, &a, &b);
87  if ((ret!=4)||
88  (sm<=0) ||(sm>36)||
89  (cry<=0)||(cry>1700)){
90  // send warning
91  continue;
92  }
93 
94  if (alphaBetaValues_[sm-1].empty()){
95  alphaBetaValues_[sm-1].resize(1700,p);
96  }
97  alphaBetaValues_[sm-1][cry-1].first = a;
98  alphaBetaValues_[sm-1][cry-1].second = b;
99 
100  }
101 
102  file.close();
103  return true;
104 }
std::vector< std::vector< std::pair< double, double > > > alphaBetaValues_
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

Member Data Documentation

EcalUncalibRecHitFixedAlphaBetaAlgo<EBDataFrame> EcalUncalibRecHitWorkerFixedAlphaBetaFit::algoEB_
private
EcalUncalibRecHitFixedAlphaBetaAlgo<EEDataFrame> EcalUncalibRecHitWorkerFixedAlphaBetaFit::algoEE_
private
std::string EcalUncalibRecHitWorkerFixedAlphaBetaFit::alphabetaFilename_
private
std::vector<std::vector<std::pair<double,double> > > EcalUncalibRecHitWorkerFixedAlphaBetaFit::alphaBetaValues_
private

Definition at line 46 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Referenced by run(), and setAlphaBeta().

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::alphaEB_
private
double EcalUncalibRecHitWorkerFixedAlphaBetaFit::alphaEE_
private
double EcalUncalibRecHitWorkerFixedAlphaBetaFit::AmplThrEB_
private

Definition at line 36 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::AmplThrEE_
private

Definition at line 37 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::betaEB_
private
double EcalUncalibRecHitWorkerFixedAlphaBetaFit::betaEE_
private
edm::ESHandle<EcalPedestals> EcalUncalibRecHitWorkerFixedAlphaBetaFit::pedHandle
private

Definition at line 53 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Referenced by run(), and set().

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

Definition at line 52 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Referenced by run(), and set().

bool EcalUncalibRecHitWorkerFixedAlphaBetaFit::useAlphaBetaArray_
private