CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalUncalibRecHitWorkerFixedAlphaBetaFit Class Reference

#include <EcalUncalibRecHitWorkerFixedAlphaBetaFit.h>

Inheritance diagram for EcalUncalibRecHitWorkerFixedAlphaBetaFit:
EcalUncalibRecHitWorkerBaseClass

Public Member Functions

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

Private Member Functions

bool setAlphaBeta ()
 

Private Attributes

EcalUncalibRecHitFixedAlphaBetaAlgo
< EBDataFrame
algoEB_
 
EcalUncalibRecHitFixedAlphaBetaAlgo
< EEDataFrame
algoEE_
 
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 22 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Constructor & Destructor Documentation

EcalUncalibRecHitWorkerFixedAlphaBetaFit::EcalUncalibRecHitWorkerFixedAlphaBetaFit ( const edm::ParameterSet ps)

Definition at line 31 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(), and useAlphaBetaArray_.

31  :
33 {
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","NOFILE");
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
T getUntrackedParameter(std::string const &, T const &) const
EcalUncalibRecHitFixedAlphaBetaAlgo< EEDataFrame > algoEE_
EcalUncalibRecHitWorkerBaseClass(const edm::ParameterSet &)
EcalUncalibRecHitFixedAlphaBetaAlgo< EBDataFrame > algoEB_
virtual EcalUncalibRecHitWorkerFixedAlphaBetaFit::~EcalUncalibRecHitWorkerFixedAlphaBetaFit ( )
inlinevirtual

Definition at line 26 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

26 {};

Member Function Documentation

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

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 104 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

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

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

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 55 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

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

Referenced by betterConfigParser.BetterConfigParser::getGeneral().

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

Definition at line 70 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.cc.

References a, alphabetaFilename_, alphaBetaValues_, b, mergeVDriftHistosByStation::file, AlCaHLTBitMon_ParallelJobs::p, run_regression::ret, and findQualityFiles::size.

Referenced by EcalUncalibRecHitWorkerFixedAlphaBetaFit().

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

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 43 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Referenced by run(), and setAlphaBeta().

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

Definition at line 33 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

double EcalUncalibRecHitWorkerFixedAlphaBetaFit::AmplThrEE_
private

Definition at line 34 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

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

Definition at line 50 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Referenced by run(), and set().

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

Definition at line 49 of file EcalUncalibRecHitWorkerFixedAlphaBetaFit.h.

Referenced by run(), and set().

bool EcalUncalibRecHitWorkerFixedAlphaBetaFit::useAlphaBetaArray_
private