CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalRecHitWorkerSimpleOld.cc
Go to the documentation of this file.
14 
15 
16 
19 {
21  v_chstatus_ = ps.getParameter<std::vector<int> >("ChannelStatusToBeExcluded");
22  v_DB_reco_flags_ = ps.getParameter<std::vector<int> >("flagsMapDBReco");
23  killDeadChannels_ = ps.getParameter<bool>("killDeadChannels");
24  laserCorrection_ = ps.getParameter<bool>("laserCorrection");
25  EBLaserMIN_ = ps.getParameter<double>("EBLaserMIN");
26  EELaserMIN_ = ps.getParameter<double>("EELaserMIN");
27  EBLaserMAX_ = ps.getParameter<double>("EBLaserMAX");
28  EELaserMAX_ = ps.getParameter<double>("EELaserMAX");
29 
30 }
31 
32 
34 {
38  es.get<EcalADCToGeVConstantRcd>().get(agc);
40  if ( laserCorrection_ ) es.get<EcalLaserDbRecord>().get(laser);
41 }
42 
43 
44 bool
46  const EcalUncalibratedRecHit& uncalibRH,
48 {
49  DetId detid=uncalibRH.id();
50 
52  EcalChannelStatusCode chStatusCode = 1;
53  if ( chit != chStatus->end() ) {
54  chStatusCode = *chit;
55  } else {
56  edm::LogError("EcalRecHitError") << "No channel status found for xtal "
57  << detid.rawId()
58  << "! something wrong with EcalChannelStatus in your DB? ";
59  }
60  if ( v_chstatus_.size() > 0) {
61  uint16_t code = chStatusCode.getStatusCode() & 0x001F;
62  std::vector<int>::const_iterator res = std::find( v_chstatus_.begin(), v_chstatus_.end(), code );
63  if ( res != v_chstatus_.end() ) {
64  return false;
65  }
66  }
67 
68  // find the proper flag for the recHit
69  // from a configurable vector
70  // (see cfg file for the association)
71  uint32_t recoFlag = 0;
72  uint16_t statusCode = chStatusCode.getStatusCode() & 0x001F;
73  if ( statusCode < v_DB_reco_flags_.size() ) {
74  // not very nice...
75  recoFlag = v_DB_reco_flags_[ statusCode ];
76  } else {
77  edm::LogError("EcalRecHitError") << "Flag " << statusCode
78  << " in DB exceed the allowed range of " << v_DB_reco_flags_.size();
79  }
80 
81  float offsetTime = 0; // the global time phase
82  const EcalIntercalibConstantMap& icalMap = ical->getMap();
83  if ( detid.subdetId() == EcalEndcap ) {
84  rechitMaker_->setADCToGeVConstant( float(agc->getEEValue()) );
85  offsetTime = offtime->getEEValue();
86  } else {
87  rechitMaker_->setADCToGeVConstant( float(agc->getEBValue()) );
88  offsetTime = offtime->getEBValue();
89  }
90 
91  // first intercalibration constants
92  EcalIntercalibConstantMap::const_iterator icalit = icalMap.find(detid);
93  EcalIntercalibConstant icalconst = 1;
94  if( icalit!=icalMap.end() ) {
95  icalconst = (*icalit);
96  } else {
97  edm::LogError("EcalRecHitError") << "No intercalib const found for xtal "
98  << detid.rawId()
99  << "! something wrong with EcalIntercalibConstants in your DB? ";
100  }
101 
102  // get laser coefficient
103  float lasercalib = 1.;
104  if ( laserCorrection_ ) lasercalib = laser->getLaserCorrection( detid, evt.time());
105 
106 
107  // get time calibration coefficient
108  const EcalTimeCalibConstantMap & itimeMap = itime->getMap();
110  EcalTimeCalibConstant itimeconst = 0;
111  if( itime!=itimeMap.end() ) {
112  itimeconst = (*itime);
113  } else {
114  edm::LogError("EcalRecHitError") << "No time calib const found for xtal "
115  << detid.rawId()
116  << "! something wrong with EcalTimeCalibConstants in your DB? ";
117  }
118 
119 
120  // make the rechit and put in the output collection
122  EcalRecHit myrechit( rechitMaker_->makeRecHit(uncalibRH, icalconst * lasercalib, (itimeconst + offsetTime), /*recoflags_*/ 0) );
123  if (detid.subdetId() == EcalBarrel && (lasercalib < EBLaserMIN_ || lasercalib > EBLaserMAX_)) myrechit.setFlag(EcalRecHit::kPoorCalib);
124  if (detid.subdetId() == EcalEndcap && (lasercalib < EELaserMIN_ || lasercalib > EELaserMAX_)) myrechit.setFlag(EcalRecHit::kPoorCalib);
125  result.push_back(myrechit);
126  }
127 
128  return true;
129 }
130 
132 
133  delete rechitMaker_;
134 }
135 
136 
T getParameter(std::string const &) const
edm::ESHandle< EcalTimeCalibConstants > itime
virtual EcalRecHit makeRecHit(const EcalUncalibratedRecHit &uncalibRH, const float &intercalibConstant, const float &timeIntercalib=0, const uint32_t &flags=0) const
Compute parameters.
void push_back(T const &t)
void setFlag(int flag)
set the flags (from Flags or ESFlags)
Definition: EcalRecHit.h:102
virtual void setADCToGeVConstant(const float &value)
make rechits from dataframes
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
EcalRecHitSimpleAlgo * rechitMaker_
edm::ESHandle< EcalLaserDbService > laser
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
uint16_t getStatusCode() const
tuple result
Definition: query.py:137
edm::ESHandle< EcalADCToGeVConstant > agc
edm::ESHandle< EcalChannelStatus > chStatus
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
void set(const edm::EventSetup &es)
edm::ESHandle< EcalTimeOffsetConstant > offtime
EcalRecHitWorkerSimpleOld(const edm::ParameterSet &, edm::ConsumesCollector &c)
float EcalTimeCalibConstant
const_iterator find(uint32_t rawId) const
#define DEFINE_EDM_PLUGIN(factory, type, name)
const_iterator end() const
bool run(const edm::Event &evt, const EcalUncalibratedRecHit &uncalibRH, EcalRecHitCollection &result)
edm::ESHandle< EcalIntercalibConstants > ical
edm::Timestamp time() const
Definition: EventBase.h:57
float EcalIntercalibConstant