CMS 3D CMS Logo

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