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 
31 
33 {
37  es.get<EcalADCToGeVConstantRcd>().get(agc);
39  if ( laserCorrection_ ) es.get<EcalLaserDbRecord>().get(laser);
40 }
41 
42 
43 bool
45  const EcalUncalibratedRecHit& uncalibRH,
47 {
48  DetId detid=uncalibRH.id();
49 
51  EcalChannelStatusCode chStatusCode = 1;
52  if ( chit != chStatus->end() ) {
53  chStatusCode = *chit;
54  } else {
55  edm::LogError("EcalRecHitError") << "No channel status found for xtal "
56  << detid.rawId()
57  << "! something wrong with EcalChannelStatus in your DB? ";
58  }
59  if ( v_chstatus_.size() > 0) {
60  uint16_t code = chStatusCode.getStatusCode() & 0x001F;
61  std::vector<int>::const_iterator res = std::find( v_chstatus_.begin(), v_chstatus_.end(), code );
62  if ( res != v_chstatus_.end() ) {
63  return false;
64  }
65  }
66 
67  // find the proper flag for the recHit
68  // from a configurable vector
69  // (see cfg file for the association)
70  uint32_t recoFlag = 0;
71  uint16_t statusCode = chStatusCode.getStatusCode() & 0x001F;
72  if ( statusCode < v_DB_reco_flags_.size() ) {
73  // not very nice...
74  recoFlag = v_DB_reco_flags_[ statusCode ];
75  } else {
76  edm::LogError("EcalRecHitError") << "Flag " << statusCode
77  << " in DB exceed the allowed range of " << v_DB_reco_flags_.size();
78  }
79 
80  float offsetTime = 0; // the global time phase
81  const EcalIntercalibConstantMap& icalMap = ical->getMap();
82  if ( detid.subdetId() == EcalEndcap ) {
83  rechitMaker_->setADCToGeVConstant( float(agc->getEEValue()) );
84  offsetTime = offtime->getEEValue();
85  } else {
86  rechitMaker_->setADCToGeVConstant( float(agc->getEBValue()) );
87  offsetTime = offtime->getEBValue();
88  }
89 
90  // first intercalibration constants
91  EcalIntercalibConstantMap::const_iterator icalit = icalMap.find(detid);
92  EcalIntercalibConstant icalconst = 1;
93  if( icalit!=icalMap.end() ) {
94  icalconst = (*icalit);
95  } else {
96  edm::LogError("EcalRecHitError") << "No intercalib const found for xtal "
97  << detid.rawId()
98  << "! something wrong with EcalIntercalibConstants in your DB? ";
99  }
100 
101  // get laser coefficient
102  float lasercalib = 1.;
103  if ( laserCorrection_ ) lasercalib = laser->getLaserCorrection( detid, evt.time());
104 
105 
106  // get time calibration coefficient
107  const EcalTimeCalibConstantMap & itimeMap = itime->getMap();
109  EcalTimeCalibConstant itimeconst = 0;
110  if( itime!=itimeMap.end() ) {
111  itimeconst = (*itime);
112  } else {
113  edm::LogError("EcalRecHitError") << "No time calib const found for xtal "
114  << detid.rawId()
115  << "! something wrong with EcalTimeCalibConstants in your DB? ";
116  }
117 
118 
119  // make the rechit and put in the output collection
121  EcalRecHit myrechit( rechitMaker_->makeRecHit(uncalibRH, icalconst * lasercalib, (itimeconst + offsetTime), /*recoflags_*/ 0) );
122  if (detid.subdetId() == EcalBarrel && (lasercalib < EBLaserMIN_ || lasercalib > EBLaserMAX_)) myrechit.setFlag(EcalRecHit::kPoorCalib);
123  if (detid.subdetId() == EcalEndcap && (lasercalib < EELaserMIN_ || lasercalib > EELaserMAX_)) myrechit.setFlag(EcalRecHit::kPoorCalib);
124  result.push_back(myrechit);
125  }
126 
127  return true;
128 }
129 
131 
132  delete rechitMaker_;
133 }
134 
135 
T getParameter(std::string const &) const
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:99
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:45
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:39
std::vector< int > v_chstatus_
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
EcalRecHitWorkerSimple(const edm::ParameterSet &)
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