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_ =
20  StringToEnumValue<EcalChannelStatusCode::Code>(ps.getParameter<std::vector<std::string> >("ChannelStatusToBeExcluded"));
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  // 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)
36  StringToEnumValue<EcalRecHit::Flags>(recoflagbitsStrings[i]);
37  std::vector<std::string> dbstatus_s =
38  p.getParameter<std::vector<std::string> >(recoflagbitsStrings[i]);
39  std::vector<uint32_t> dbstatuses;
40  for (unsigned int j=0; j!= dbstatus_s.size(); ++j){
42  StringToEnumValue<EcalChannelStatusCode::Code>(dbstatus_s[j]);
43  dbstatuses.push_back(dbstatus);
44  }
45 
46  v_DB_reco_flags_[recoflagbit]=dbstatuses;
47  }
48 
49  flagmask_=0;
56 }
57 
58 
60 {
64  es.get<EcalADCToGeVConstantRcd>().get(agc);
66  if ( laserCorrection_ ) es.get<EcalLaserDbRecord>().get(laser);
67 }
68 
69 
70 bool
72  const EcalUncalibratedRecHit& uncalibRH,
74 {
75  DetId detid=uncalibRH.id();
76 
78  EcalChannelStatusCode::Code dbstatus = chit->getStatusCode();
79 
80  // check for channels to be excluded from reconstruction
81  if ( v_chstatus_.size() > 0) {
82 
83  std::vector<int>::const_iterator res =
84  std::find( v_chstatus_.begin(), v_chstatus_.end(), dbstatus );
85  if ( res != v_chstatus_.end() ) return false;
86 
87  }
88 
89  uint32_t flagBits = setFlagBits(v_DB_reco_flags_, dbstatus);
90 
91  float offsetTime = 0; // the global time phase
92  const EcalIntercalibConstantMap& icalMap = ical->getMap();
93  if ( detid.subdetId() == EcalEndcap ) {
94  rechitMaker_->setADCToGeVConstant( float(agc->getEEValue()) );
95  offsetTime = offtime->getEEValue();
96  } else {
97  rechitMaker_->setADCToGeVConstant( float(agc->getEBValue()) );
98  offsetTime = offtime->getEBValue();
99  }
100 
101  // first intercalibration constants
102  EcalIntercalibConstantMap::const_iterator icalit = icalMap.find(detid);
103  EcalIntercalibConstant icalconst = 1;
104  if( icalit!=icalMap.end() ) {
105  icalconst = (*icalit);
106  } else {
107  edm::LogError("EcalRecHitError") << "No intercalib const found for xtal "
108  << detid.rawId()
109  << "! something wrong with EcalIntercalibConstants in your DB? ";
110  }
111 
112  // get laser coefficient
113  float lasercalib = 1.;
114  if ( laserCorrection_ ) lasercalib = laser->getLaserCorrection( detid, evt.time());
115 
116 
117  // get time calibration coefficient
118  const EcalTimeCalibConstantMap & itimeMap = itime->getMap();
120  EcalTimeCalibConstant itimeconst = 0;
121  if( itime!=itimeMap.end() ) {
122  itimeconst = (*itime);
123  } else {
124  edm::LogError("EcalRecHitError") << "No time calib const found for xtal "
125  << detid.rawId()
126  << "! something wrong with EcalTimeCalibConstants in your DB? ";
127  }
128 
129 
130  // make the rechit and put in the output collection, unless recovery has to take care of it
131  if (! (flagmask_ & flagBits ) || !killDeadChannels_) {
132  EcalRecHit myrechit( rechitMaker_->makeRecHit(uncalibRH,
133  icalconst * lasercalib,
134  (itimeconst + offsetTime),
135  /*recoflags_ 0*/
136  flagBits) );
137 
138  if (detid.subdetId() == EcalBarrel && (lasercalib < EBLaserMIN_ || lasercalib > EBLaserMAX_))
140  if (detid.subdetId() == EcalEndcap && (lasercalib < EELaserMIN_ || lasercalib > EELaserMAX_))
141  myrechit.setFlag(EcalRecHit::kPoorCalib);
142  result.push_back(myrechit);
143  }
144 
145  return true;
146 }
147 
148 // Take our association map of dbstatuses-> recHit flagbits and return the apporpriate flagbit word
149 uint32_t EcalRecHitWorkerSimple::setFlagBits(const std::vector<std::vector<uint32_t> >& map,
150  const uint32_t& status ){
151 
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 
160 
162 
163  delete rechitMaker_;
164 }
165 
166 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
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.
std::vector< std::vector< uint32_t > > v_DB_reco_flags_
void push_back(T const &t)
void setFlag(int flag)
set the flags (from Flags or ESFlags)
Definition: EcalRecHit.h:168
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
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
#define end
Definition: vmac.h:37
EcalRecHitSimpleAlgo * rechitMaker_
std::vector< std::string > getParameterNames() const
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:56
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
bool run(const edm::Event &evt, const EcalUncalibratedRecHit &uncalibRH, EcalRecHitCollection &result)
float EcalTimeCalibConstant
#define begin
Definition: vmac.h:30
const_iterator find(uint32_t rawId) const
#define DEFINE_EDM_PLUGIN(factory, type, name)
const_iterator end() const
tuple status
Definition: ntuplemaker.py:245
edm::Timestamp time() const
Definition: EventBase.h:61
edm::ESHandle< EcalIntercalibConstants > ical
float EcalIntercalibConstant
edm::ESHandle< EcalLaserDbService > laser