CMS 3D CMS Logo

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