CMS 3D CMS Logo

EcalRecHitWorkerSimple.cc
Go to the documentation of this file.
14 
16  : EcalRecHitWorkerBaseClass(ps, c) {
18  v_chstatus_ = StringToEnumValue<EcalChannelStatusCode::Code>(
19  ps.getParameter<std::vector<std::string> >("ChannelStatusToBeExcluded"));
20  killDeadChannels_ = ps.getParameter<bool>("killDeadChannels");
21  laserCorrection_ = ps.getParameter<bool>("laserCorrection");
22  EBLaserMIN_ = ps.getParameter<double>("EBLaserMIN");
23  EELaserMIN_ = ps.getParameter<double>("EELaserMIN");
24  EBLaserMAX_ = ps.getParameter<double>("EBLaserMAX");
25  EELaserMAX_ = ps.getParameter<double>("EELaserMAX");
26 
27  skipTimeCalib_ = ps.getParameter<bool>("skipTimeCalib");
28 
29  // Traslate string representation of flagsMapDBReco into enum values
30  const edm::ParameterSet& p = ps.getParameter<edm::ParameterSet>("flagsMapDBReco");
31  std::vector<std::string> recoflagbitsStrings = p.getParameterNames();
32  v_DB_reco_flags_.resize(32);
33 
34  for (unsigned int i = 0; i != recoflagbitsStrings.size(); ++i) {
35  EcalRecHit::Flags recoflagbit = (EcalRecHit::Flags)StringToEnumValue<EcalRecHit::Flags>(recoflagbitsStrings[i]);
36  std::vector<std::string> dbstatus_s = p.getParameter<std::vector<std::string> >(recoflagbitsStrings[i]);
37  std::vector<uint32_t> dbstatuses;
38  for (unsigned int j = 0; j != dbstatus_s.size(); ++j) {
40  (EcalChannelStatusCode::Code)StringToEnumValue<EcalChannelStatusCode::Code>(dbstatus_s[j]);
41  dbstatuses.push_back(dbstatus);
42  }
43 
44  v_DB_reco_flags_[recoflagbit] = dbstatuses;
45  }
46 
47  flagmask_ = 0;
50  flagmask_ |= 0x1 << EcalRecHit::kDead;
54 }
55 
58 
59  if (!skipTimeCalib_) {
62  }
63 
64  es.get<EcalADCToGeVConstantRcd>().get(agc);
66  if (laserCorrection_)
67  es.get<EcalLaserDbRecord>().get(laser);
68 }
69 
71  const EcalUncalibratedRecHit& uncalibRH,
73  DetId detid = uncalibRH.id();
74 
76  EcalChannelStatusCode::Code dbstatus = chit->getStatusCode();
77 
78  // check for channels to be excluded from reconstruction
79  if (!v_chstatus_.empty()) {
80  std::vector<int>::const_iterator res = std::find(v_chstatus_.begin(), v_chstatus_.end(), dbstatus);
81  if (res != v_chstatus_.end())
82  return false;
83  }
84 
85  uint32_t flagBits = setFlagBits(v_DB_reco_flags_, dbstatus);
86 
87  float offsetTime = 0; // the global time phase
88  const EcalIntercalibConstantMap& icalMap = ical->getMap();
89  if (detid.subdetId() == EcalEndcap) {
91  if (!skipTimeCalib_)
92  offsetTime = offtime->getEEValue();
93  } else {
95  if (!skipTimeCalib_)
96  offsetTime = offtime->getEBValue();
97  }
98 
99  // first intercalibration constants
100  EcalIntercalibConstantMap::const_iterator icalit = icalMap.find(detid);
101  EcalIntercalibConstant icalconst = 1;
102  if (icalit != icalMap.end()) {
103  icalconst = (*icalit);
104  } else {
105  edm::LogError("EcalRecHitError") << "No intercalib const found for xtal " << detid.rawId()
106  << "! something wrong with EcalIntercalibConstants in your DB? ";
107  }
108 
109  // get laser coefficient
110  float lasercalib = 1.;
111  if (laserCorrection_)
112  lasercalib = laser->getLaserCorrection(detid, evt.time());
113 
114  // get time calibration coefficient
115  EcalTimeCalibConstant itimeconst = 0;
116 
117  if (!skipTimeCalib_) {
118  const EcalTimeCalibConstantMap& itimeMap = itime->getMap();
120 
121  if (itime != itimeMap.end()) {
122  itimeconst = (*itime);
123  } else {
124  edm::LogError("EcalRecHitError") << "No time calib const found for xtal " << detid.rawId()
125  << "! something wrong with EcalTimeCalibConstants in your DB? ";
126  }
127  }
128 
129  // make the rechit and put in the output collection, unless recovery has to take care of it
130  if (!(flagmask_ & flagBits) || !killDeadChannels_) {
131  EcalRecHit myrechit(rechitMaker_->makeRecHit(uncalibRH,
132  icalconst * lasercalib,
133  (itimeconst + offsetTime),
134  /*recoflags_ 0*/
135  flagBits));
136 
137  if (detid.subdetId() == EcalBarrel && (lasercalib < EBLaserMIN_ || lasercalib > EBLaserMAX_))
139  if (detid.subdetId() == EcalEndcap && (lasercalib < EELaserMIN_ || lasercalib > EELaserMAX_))
140  myrechit.setFlag(EcalRecHit::kPoorCalib);
141  result.push_back(myrechit);
142  }
143 
144  return true;
145 }
146 
147 // Take our association map of dbstatuses-> recHit flagbits and return the apporpriate flagbit word
148 uint32_t EcalRecHitWorkerSimple::setFlagBits(const std::vector<std::vector<uint32_t> >& map, const uint32_t& status) {
149  for (unsigned int i = 0; i != map.size(); ++i) {
150  if (std::find(map[i].begin(), map[i].end(), status) != map[i].end())
151  return 0x1 << i;
152  }
153 
154  return 0;
155 }
156 
158 
T getParameter(std::string const &) const
EcalRecHitWorkerSimple(const edm::ParameterSet &, edm::ConsumesCollector &c)
edm::ESHandle< EcalADCToGeVConstant > agc
std::vector< std::vector< uint32_t > > v_DB_reco_flags_
float getLaserCorrection(DetId const &xid, edm::Timestamp const &iTime) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void push_back(T const &t)
void setFlag(int flag)
set the flags (from Flags or ESFlags)
Definition: EcalRecHit.h:183
edm::ESHandle< EcalChannelStatus > chStatus
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Definition: Electron.h:6
edm::ESHandle< EcalTimeCalibConstants > itime
EcalRecHit makeRecHit(const EcalUncalibratedRecHit &uncalibRH, const float &intercalibConstant, const float &timeIntercalib=0, const uint32_t &flags=0) const override
Compute parameters.
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
#define end
Definition: vmac.h:39
EcalRecHitSimpleAlgo * rechitMaker_
std::vector< std::string > getParameterNames() const
std::vector< int > v_chstatus_
void setADCToGeVConstant(const float &value) override
make rechits from dataframes
Definition: DetId.h:17
std::vector< Item >::const_iterator const_iterator
uint32_t setFlagBits(const std::vector< std::vector< uint32_t > > &map, const uint32_t &status)
edm::ESHandle< EcalTimeOffsetConstant > offtime
float EcalTimeCalibConstant
#define begin
Definition: vmac.h:32
T get() const
Definition: EventSetup.h:73
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) override
edm::Timestamp time() const
Definition: EventBase.h:60
void set(const edm::EventSetup &es) override
edm::ESHandle< EcalIntercalibConstants > ical
float EcalIntercalibConstant
edm::ESHandle< EcalLaserDbService > laser