CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
EcalRecHitWorkerRecover Class Reference
Inheritance diagram for EcalRecHitWorkerRecover:
EcalRecHitWorkerBaseClass

Public Member Functions

 EcalRecHitWorkerRecover (const edm::ParameterSet &, edm::ConsumesCollector &c)
 
bool run (const edm::Event &evt, const EcalUncalibratedRecHit &uncalibRH, EcalRecHitCollection &result) override
 
void set (const edm::EventSetup &es) override
 
- Public Member Functions inherited from EcalRecHitWorkerBaseClass
 EcalRecHitWorkerBaseClass (const edm::ParameterSet &, edm::ConsumesCollector &c)
 
 EcalRecHitWorkerBaseClass (const edm::ParameterSet &)
 
virtual ~EcalRecHitWorkerBaseClass ()
 

Protected Member Functions

bool alreadyInserted (const DetId &id)
 
bool checkChannelStatus (const DetId &id, const std::vector< int > &statusestoexclude)
 
float estimateEnergy (int ieta, EcalRecHitCollection *hits, const std::set< DetId > &sId, const std::vector< DetId > &vId, const EcalTPGScale &tpgscale)
 
void insertRecHit (const EcalRecHit &hit, EcalRecHitCollection &collection)
 
float recCheckCalib (float energy, int ieta)
 

Protected Attributes

edm::ESHandle< CaloGeometrycaloGeometry_
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordcaloGeometryToken_
 
edm::ESHandle< CaloTopologycaloTopology_
 
edm::ESGetToken< CaloTopology, CaloTopologyRecordcaloTopologyToken_
 
edm::ESHandle< EcalChannelStatuschStatus_
 
edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcdchStatusToken_
 
std::vector< int > dbStatusToBeExcludedEB_
 
std::vector< int > dbStatusToBeExcludedEE_
 
EcalDeadChannelRecoveryAlgos< EBDetIdebDeadChannelCorrector
 
const CaloSubdetectorGeometryebGeom_
 
const EcalElectronicsMappingecalMapping_
 
EcalTPGScale::Tokens ecalScaleTokens_
 
EcalDeadChannelRecoveryAlgos< EEDetIdeeDeadChannelCorrector
 
const edm::EventSetupeventSetup_ = nullptr
 
const CaloGeometrygeo_
 
bool killDeadChannels_
 
edm::ESHandle< EcalLaserDbServicelaser
 
edm::ESGetToken< EcalLaserDbService, EcalLaserDbRecordlaserToken_
 
double logWarningEtThreshold_EB_FE_
 
double logWarningEtThreshold_EE_FE_
 
edm::ESHandle< CaloSubdetectorGeometrypEBGeom_
 
edm::ESGetToken< CaloSubdetectorGeometry, EcalBarrelGeometryRecordpEBGeomToken_
 
edm::ESHandle< EcalElectronicsMappingpEcalMapping_
 
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcdpEcalMappingToken_
 
std::unique_ptr< EcalRecHitSimpleAlgorechitMaker_
 
bool recoverEBFE_
 
bool recoverEBIsolatedChannels_
 
bool recoverEBVFE_
 
std::set< DetIdrecoveredDetIds_EB_
 
std::set< DetIdrecoveredDetIds_EE_
 
bool recoverEEFE_
 
bool recoverEEIsolatedChannels_
 
bool recoverEEVFE_
 
std::string singleRecoveryMethod_
 
double singleRecoveryThreshold_
 
double sum8RecoveryThreshold_
 
edm::EDGetTokenT< EcalTrigPrimDigiCollectiontpDigiToken_
 
EcalTPGScale::Tokens tpgscaleTokens_
 
edm::ESHandle< EcalTrigTowerConstituentsMapttMap_
 
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecordttMapToken_
 

Additional Inherited Members

- Public Types inherited from EcalRecHitWorkerBaseClass
enum  RecoveryFlags {
  EB_single, EE_single, EB_VFE, EE_VFE,
  EB_FE, EE_FE
}
 

Detailed Description

Algorithms to recover dead channels

Definition at line 38 of file EcalRecHitWorkerRecover.cc.

Constructor & Destructor Documentation

◆ EcalRecHitWorkerRecover()

EcalRecHitWorkerRecover::EcalRecHitWorkerRecover ( const edm::ParameterSet ps,
edm::ConsumesCollector c 
)

Definition at line 112 of file EcalRecHitWorkerRecover.cc.

References HltBtagPostValidation_cff::c, caloGeometryToken_, caloTopologyToken_, chStatusToken_, dbStatusToBeExcludedEB_, dbStatusToBeExcludedEE_, ebDeadChannelCorrector, ecal_dqm_sourceclient-live_cfg::EcalLaserDbService, edm::ParameterSet::getParameter(), killDeadChannels_, laserToken_, logWarningEtThreshold_EB_FE_, logWarningEtThreshold_EE_FE_, pEBGeomToken_, pEcalMappingToken_, rechitMaker_, recoverEBFE_, recoverEBIsolatedChannels_, recoverEBVFE_, recoverEEFE_, recoverEEIsolatedChannels_, recoverEEVFE_, EcalDeadChannelRecoveryAlgos< DetIdT >::setParameters(), singleRecoveryMethod_, singleRecoveryThreshold_, AlCaHLTBitMon_QueryRunRegistry::string, sum8RecoveryThreshold_, tpDigiToken_, and ttMapToken_.

114  rechitMaker_ = std::make_unique<EcalRecHitSimpleAlgo>();
115  // isolated channel recovery
116  singleRecoveryMethod_ = ps.getParameter<std::string>("singleChannelRecoveryMethod");
117  singleRecoveryThreshold_ = ps.getParameter<double>("singleChannelRecoveryThreshold");
118  sum8RecoveryThreshold_ = ps.getParameter<double>("sum8ChannelRecoveryThreshold");
119  killDeadChannels_ = ps.getParameter<bool>("killDeadChannels");
120  recoverEBIsolatedChannels_ = ps.getParameter<bool>("recoverEBIsolatedChannels");
121  recoverEEIsolatedChannels_ = ps.getParameter<bool>("recoverEEIsolatedChannels");
122  recoverEBVFE_ = ps.getParameter<bool>("recoverEBVFE");
123  recoverEEVFE_ = ps.getParameter<bool>("recoverEEVFE");
124  recoverEBFE_ = ps.getParameter<bool>("recoverEBFE");
125  recoverEEFE_ = ps.getParameter<bool>("recoverEEFE");
133 
134  dbStatusToBeExcludedEE_ = ps.getParameter<std::vector<int> >("dbStatusToBeExcludedEE");
135  dbStatusToBeExcludedEB_ = ps.getParameter<std::vector<int> >("dbStatusToBeExcludedEB");
136 
137  logWarningEtThreshold_EB_FE_ = ps.getParameter<double>("logWarningEtThreshold_EB_FE");
138  logWarningEtThreshold_EE_FE_ = ps.getParameter<double>("logWarningEtThreshold_EE_FE");
139 
140  tpDigiToken_ =
141  c.consumes<EcalTrigPrimDigiCollection>(ps.getParameter<edm::InputTag>("triggerPrimitiveDigiCollection"));
142 
145 }
edm::ESGetToken< CaloSubdetectorGeometry, EcalBarrelGeometryRecord > pEBGeomToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > pEcalMappingToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
std::vector< int > dbStatusToBeExcludedEE_
edm::ESGetToken< EcalLaserDbService, EcalLaserDbRecord > laserToken_
edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > chStatusToken_
EcalTPGScale::Tokens tpgscaleTokens_
EcalTPGScale::Tokens ecalScaleTokens_
std::unique_ptr< EcalRecHitSimpleAlgo > rechitMaker_
EcalChannelStatusMap EcalChannelStatus
EcalRecHitWorkerBaseClass(const edm::ParameterSet &, edm::ConsumesCollector &c)
void setParameters(const edm::ParameterSet &ps)
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > ttMapToken_
edm::EDGetTokenT< EcalTrigPrimDigiCollection > tpDigiToken_
std::vector< int > dbStatusToBeExcludedEB_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
EcalDeadChannelRecoveryAlgos< EBDetId > ebDeadChannelCorrector

Member Function Documentation

◆ alreadyInserted()

bool EcalRecHitWorkerRecover::alreadyInserted ( const DetId id)
protected

Definition at line 509 of file EcalRecHitWorkerRecover.cc.

References EcalBarrel, EcalEndcap, recoveredDetIds_EB_, and recoveredDetIds_EE_.

Referenced by insertRecHit(), and run().

509  {
510  bool res = false;
511  if (id.subdetId() == EcalBarrel) {
512  res = (recoveredDetIds_EB_.find(id) != recoveredDetIds_EB_.end());
513  } else if (id.subdetId() == EcalEndcap) {
514  res = (recoveredDetIds_EE_.find(id) != recoveredDetIds_EE_.end());
515  } else {
516  edm::LogError("EcalRecHitWorkerRecover::InvalidDetId") << "Invalid DetId " << id.rawId();
517  }
518  return res;
519 }
Log< level::Error, false > LogError
Definition: Electron.h:6

◆ checkChannelStatus()

bool EcalRecHitWorkerRecover::checkChannelStatus ( const DetId id,
const std::vector< int > &  statusestoexclude 
)
protected

Definition at line 528 of file EcalRecHitWorkerRecover.cc.

References chStatus_, and mps_update::status.

Referenced by run().

528  {
529  if (!chStatus_.isValid())
530  edm::LogError("ObjectNotFound") << "Channel Status not set";
531 
533  uint16_t dbStatus = 0;
534  if (chIt != chStatus_->end()) {
535  dbStatus = chIt->getEncodedStatusCode();
536  } else {
537  edm::LogError("ObjectNotFound") << "No channel status found for xtal " << id.rawId()
538  << "! something wrong with EcalChannelStatus in your DB? ";
539  }
540 
541  for (std::vector<int>::const_iterator status = statusestoexclude.begin(); status != statusestoexclude.end();
542  ++status) {
543  if (*status == dbStatus)
544  return false;
545  }
546 
547  return true;
548 }
Log< level::Error, false > LogError
std::vector< Item >::const_iterator const_iterator
edm::ESHandle< EcalChannelStatus > chStatus_

◆ estimateEnergy()

float EcalRecHitWorkerRecover::estimateEnergy ( int  ieta,
EcalRecHitCollection hits,
const std::set< DetId > &  sId,
const std::vector< DetId > &  vId,
const EcalTPGScale tpgscale 
)
protected

Definition at line 457 of file EcalRecHitWorkerRecover.cc.

References submitPVResolutionJobs::count, hcalRecHitTable_cff::energy, PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), nano_mu_digi_cff::float, geo_, CaloGeometry::getPosition(), EcalTPGScale::getTPGInGeV(), hfClusterShapes_cfi::hits, hcalRecHitTable_cff::ieta, packedPFCandidateRefMixer_cfi::pf, EcalTrigTowerConstituentsMap::towerOf(), and ttMap_.

Referenced by run().

461  {
462  float xtalE = 0;
463  int count = 0;
464  for (std::vector<DetId>::const_iterator vIdit = vId.begin(); vIdit != vId.end(); ++vIdit) {
465  std::set<DetId>::const_iterator sIdit = sId.find(*vIdit);
466  if (sIdit == sId.end()) {
467  float energy = hits->find(*vIdit)->energy();
468  float eta = geo_->getPosition(*vIdit).eta();
469  float pf = 1.0 / cosh(eta);
470  xtalE += energy * pf;
471  count++;
472  }
473  }
474 
475  if (count == 0) { // If there are no overlapping crystals return saturated value.
476 
477  double etsat = tpgscale.getTPGInGeV(0xFF,
478  ttMap_->towerOf(*vId.begin())); // get saturation value for the first
479  // constituent, for the others it's the same
480 
481  return etsat / cosh(ieta) * (ieta > 26 ? 2 : 1); // account for duplicated TT in EE for ieta>26
482  } else
483  return xtalE * ((vId.size() / (float)count) - 1) * (ieta > 26 ? 2 : 1);
484 }
T eta() const
Definition: PV3DBase.h:73
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
edm::ESHandle< EcalTrigTowerConstituentsMap > ttMap_
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi) const
Definition: EcalTPGScale.cc:17

◆ insertRecHit()

void EcalRecHitWorkerRecover::insertRecHit ( const EcalRecHit hit,
EcalRecHitCollection collection 
)
protected

Definition at line 486 of file EcalRecHitWorkerRecover.cc.

References alreadyInserted(), universalConfigTemplate::collection, EcalBarrel, EcalEndcap, hit::id, recoveredDetIds_EB_, and recoveredDetIds_EE_.

Referenced by run().

486  {
487  // skip already inserted DetId's and raise a log warning
488  if (alreadyInserted(hit.id())) {
489  edm::LogWarning("EcalRecHitWorkerRecover") << "DetId already recovered! Skipping...";
490  return;
491  }
493  if (it == collection.end()) {
494  // insert the hit in the collection
495  collection.push_back(hit);
496  } else {
497  // overwrite existing recHit
498  *it = hit;
499  }
500  if (hit.id().subdetId() == EcalBarrel) {
501  recoveredDetIds_EB_.insert(hit.id());
502  } else if (hit.id().subdetId() == EcalEndcap) {
503  recoveredDetIds_EE_.insert(hit.id());
504  } else {
505  edm::LogError("EcalRecHitWorkerRecover::InvalidDetId") << "Invalid DetId " << hit.id().rawId();
506  }
507 }
bool alreadyInserted(const DetId &id)
Log< level::Error, false > LogError
std::vector< EcalRecHit >::iterator iterator
unsigned int id
Log< level::Warning, false > LogWarning

◆ recCheckCalib()

float EcalRecHitWorkerRecover::recCheckCalib ( float  energy,
int  ieta 
)
protected

Definition at line 523 of file EcalRecHitWorkerRecover.cc.

523 { return eTT; }

◆ run()

bool EcalRecHitWorkerRecover::run ( const edm::Event evt,
const EcalUncalibratedRecHit uncalibRH,
EcalRecHitCollection result 
)
overridevirtual

Implements EcalRecHitWorkerBaseClass.

Definition at line 164 of file EcalRecHitWorkerRecover.cc.

References alreadyInserted(), caloTopology_, checkChannelStatus(), EcalTrigTowerConstituentsMap::constituentsOf(), EcalDeadChannelRecoveryAlgos< DetIdT >::correct(), dbStatusToBeExcludedEB_, dbStatusToBeExcludedEE_, hcalRecHitTable_cff::detId, PVValHelper::dx, PVValHelper::dy, EcalRecHitWorkerBaseClass::EB_FE, EcalRecHitWorkerBaseClass::EB_single, EcalRecHitWorkerBaseClass::EB_VFE, ebDeadChannelCorrector, ebGeom_, ecalScaleTokens_, EcalRecHitWorkerBaseClass::EE_FE, EcalRecHitWorkerBaseClass::EE_single, EcalRecHitWorkerBaseClass::EE_VFE, eeDeadChannelCorrector, edm::SortedCollection< T, SORT >::end(), hcalRecHitTable_cff::energy, estimateEnergy(), PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), eventSetup_, edm::SortedCollection< T, SORT >::find(), EcalUncalibratedRecHit::flags(), HLT_2023v12_cff::flags, geo_, edm::Event::getByToken(), CaloSubdetectorGeometry::getGeometry(), CaloGeometry::getPosition(), EcalTPGScale::getTPGInGeV(), hfClusterShapes_cfi::hits, mps_fire::i, EcalUncalibratedRecHit::id(), l1ctLayer2EG_cff::id, insertRecHit(), EcalScDetId::ix(), EEDetId::ix(), EcalScDetId::iy(), EEDetId::iy(), dqmiolumiharvest::j, EcalRecHit::kDead, killDeadChannels_, EcalRecHit::kL1SpikeFlag, EcalRecHit::kNeighboursRecovered, EcalRecHit::kTowerRecovered, EcalRecHit::kTPSaturated, logWarningEtThreshold_EB_FE_, logWarningEtThreshold_EE_FE_, packedPFCandidateRefMixer_cfi::pf, edm::Handle< T >::product(), edm::ESHandle< T >::product(), recoverEBFE_, recoverEBIsolatedChannels_, recoverEBVFE_, recoverEEFE_, recoverEEIsolatedChannels_, recoverEEVFE_, mps_fire::result, EcalDeadChannelRecoveryAlgos< DetIdT >::setCaloTopology(), funct::sin(), singleRecoveryMethod_, singleRecoveryThreshold_, sum8RecoveryThreshold_, theta(), l1tHGCalTowerProducer_cfi::tower, EcalTrigTowerConstituentsMap::towerOf(), cmsswSequenceInfo::tp, tpDigiToken_, tpgscaleTokens_, ttMap_, findQualityFiles::v, EEDetId::validDetId(), EcalScDetId::zside(), EEDetId::zside(), and ecaldqm::zside().

166  {
167  DetId detId = uncalibRH.id();
168  uint32_t flags = (0xF & uncalibRH.flags());
169 
170  // get laser coefficient
171  //float lasercalib = laser->getLaserCorrection( detId, evt.time());
172 
173  // killDeadChannels_ = true, means explicitely kill dead channels even if the recovered energies are computed in the code
174  // if you don't want to store the recovered energies in the rechit you can produce LogWarnings if logWarningEtThreshold_EB(EE)_FE>0
175  // logWarningEtThreshold_EB(EE)_FE_<0 will not compute the recovered energies at all (faster)
176 
177  if (killDeadChannels_) {
183  hit.setFlag(EcalRecHit::kDead);
184  insertRecHit(hit, result); // insert trivial rechit with kDead flag
185  return true;
186  }
188  EcalTrigTowerDetId ttDetId(((EBDetId)detId).tower());
189  std::vector<DetId> vid = ttMap_->constituentsOf(ttDetId);
190  for (std::vector<DetId>::const_iterator dit = vid.begin(); dit != vid.end(); ++dit) {
191  EcalRecHit hit((*dit), 0., 0., EcalRecHit::kDead);
192  hit.setFlag(EcalRecHit::kDead);
193  insertRecHit(hit, result); // insert trivial rechit with kDead flag
194  }
196  return true; // if you don't want log warning just return true
197  }
199  EEDetId id(detId);
200  EcalScDetId sc(1 + (id.ix() - 1) / 5, 1 + (id.iy() - 1) / 5, id.zside());
201  std::vector<DetId> eeC;
202  for (int dx = 1; dx <= 5; ++dx) {
203  for (int dy = 1; dy <= 5; ++dy) {
204  int ix = (sc.ix() - 1) * 5 + dx;
205  int iy = (sc.iy() - 1) * 5 + dy;
206  int iz = sc.zside();
207  if (EEDetId::validDetId(ix, iy, iz)) {
208  eeC.push_back(EEDetId(ix, iy, iz));
209  }
210  }
211  }
212  for (size_t i = 0; i < eeC.size(); ++i) {
213  EcalRecHit hit(eeC[i], 0., 0., EcalRecHit::kDead);
214  hit.setFlag(EcalRecHit::kDead);
215  insertRecHit(hit, result); // insert trivial rechit with kDead flag
216  }
218  return true; // if you don't want log warning just return true
219  }
220  }
221 
223  // recover as single dead channel
225 
226  // channel recovery. Accepted new RecHit has the flag AcceptRecHit=TRUE
227  bool AcceptRecHit = true;
228  float ebEn = ebDeadChannelCorrector.correct(
231 
232  if (hit.energy() != 0 and AcceptRecHit == true) {
234  } else {
235  // recovery failed
236  hit.setFlag(EcalRecHit::kDead);
237  }
239 
241  // recover as single dead channel
243 
244  // channel recovery. Accepted new RecHit has the flag AcceptRecHit=TRUE
245  bool AcceptRecHit = true;
246  float eeEn = eeDeadChannelCorrector.correct(
249  if (hit.energy() != 0 and AcceptRecHit == true) {
251  } else {
252  // recovery failed
253  hit.setFlag(EcalRecHit::kDead);
254  }
256 
257  } else if (flags == EcalRecHitWorkerRecover::EB_VFE) {
258  // recover as dead VFE
259  EcalRecHit hit(detId, 0., 0.);
260  hit.setFlag(EcalRecHit::kDead);
261  // recovery not implemented
263  } else if (flags == EcalRecHitWorkerRecover::EB_FE) {
264  // recover as dead TT
265 
266  EcalTrigTowerDetId ttDetId(((EBDetId)detId).tower());
268  evt.getByToken(tpDigiToken_, pTPDigis);
269  const EcalTrigPrimDigiCollection* tpDigis = nullptr;
270  tpDigis = pTPDigis.product();
271 
273  // recover the whole trigger tower
274  if (tp != tpDigis->end()) {
276  //std::vector<DetId> vid = ecalMapping_->dccTowerConstituents( ecalMapping_->DCCid( ttDetId ), ecalMapping_->iTT( ttDetId ) );
277  std::vector<DetId> vid = ttMap_->constituentsOf(ttDetId);
278  float tpEt = ecalScale.getTPGInGeV(tp->compressedEt(), tp->id());
279  float tpEtThreshEB = logWarningEtThreshold_EB_FE_;
280  if (tpEt > tpEtThreshEB) {
281  edm::LogWarning("EnergyInDeadEB_FE") << "TP energy in the dead TT = " << tpEt << " at " << ttDetId;
282  }
284  // democratic energy sharing
285 
286  for (std::vector<DetId>::const_iterator dit = vid.begin(); dit != vid.end(); ++dit) {
287  if (alreadyInserted(*dit))
288  continue;
289  float theta = ebGeom_->getGeometry(*dit)->getPosition().theta();
290  float tpEt = ecalScale.getTPGInGeV(tp->compressedEt(), tp->id());
292  EcalRecHit hit(*dit, tpEt / ((float)vid.size()) / sin(theta), 0.);
294  if (tp->compressedEt() == 0xFF)
295  hit.setFlag(EcalRecHit::kTPSaturated);
296  if (tp->sFGVB())
297  hit.setFlag(EcalRecHit::kL1SpikeFlag);
299  }
300  }
301  } else {
302  // tp not found => recovery failed
303  std::vector<DetId> vid = ttMap_->constituentsOf(ttDetId);
304  for (std::vector<DetId>::const_iterator dit = vid.begin(); dit != vid.end(); ++dit) {
305  if (alreadyInserted(*dit))
306  continue;
307  EcalRecHit hit(*dit, 0., 0.);
308  hit.setFlag(EcalRecHit::kDead);
310  }
311  }
312  }
313  } else if (flags == EcalRecHitWorkerRecover::EE_FE) {
314  // Structure for recovery:
315  // ** SC --> EEDetId constituents (eeC) --> associated Trigger Towers (aTT) --> EEDetId constituents (aTTC)
316  // ** energy for a SC EEDetId = [ sum_aTT(energy) - sum_aTTC(energy) ] / N_eeC
317  // .. i.e. the total energy of the TTs covering the SC minus
318  // .. the energy of the recHits in the TTs but not in the SC
319  //std::vector<DetId> vid = ecalMapping_->dccTowerConstituents( ecalMapping_->DCCid( ttDetId ), ecalMapping_->iTT( ttDetId ) );
320  // due to lack of implementation of the EcalTrigTowerDetId ix,iy methods in EE we compute Et recovered energies (in EB we compute E)
321 
322  EEDetId eeId(detId);
323  EcalScDetId sc((eeId.ix() - 1) / 5 + 1, (eeId.iy() - 1) / 5 + 1, eeId.zside());
324  std::set<DetId> eeC;
325  for (int dx = 1; dx <= 5; ++dx) {
326  for (int dy = 1; dy <= 5; ++dy) {
327  int ix = (sc.ix() - 1) * 5 + dx;
328  int iy = (sc.iy() - 1) * 5 + dy;
329  int iz = sc.zside();
330  if (EEDetId::validDetId(ix, iy, iz)) {
331  EEDetId id(ix, iy, iz);
333  eeC.insert(id);
334  } // check status
335  }
336  }
337  }
338 
340  evt.getByToken(tpDigiToken_, pTPDigis);
341  const EcalTrigPrimDigiCollection* tpDigis = nullptr;
342  tpDigis = pTPDigis.product();
343 
344  // associated trigger towers
345  std::set<EcalTrigTowerDetId> aTT;
346  for (std::set<DetId>::const_iterator it = eeC.begin(); it != eeC.end(); ++it) {
347  aTT.insert(ttMap_->towerOf(*it));
348  }
349 
352  // associated trigger towers: total energy
353  float totE = 0;
354  // associated trigger towers: EEDetId constituents
355  std::set<DetId> aTTC;
356  bool atLeastOneTPSaturated = false;
357  for (std::set<EcalTrigTowerDetId>::const_iterator it = aTT.begin(); it != aTT.end(); ++it) {
358  // add the energy of this trigger tower
360  if (itTP != tpDigis->end()) {
361  std::vector<DetId> v = ttMap_->constituentsOf(*it);
362 
363  // from the constituents, remove dead channels
364  std::vector<DetId>::iterator ttcons = v.begin();
365  while (ttcons != v.end()) {
367  ttcons = v.erase(ttcons);
368  } else {
369  ++ttcons;
370  }
371  } // while
372 
373  if (itTP->compressedEt() == 0xFF) { // In the case of a saturated trigger tower, a fraction
374  atLeastOneTPSaturated =
375  true; //of the saturated energy is put in: number of xtals in dead region/total xtals in TT *63.75
376 
377  //Alternative recovery algorithm that I will now investigate.
378  //Estimate energy sums the energy in the working channels, then decides how much energy
379  //to put here depending on that. Duncan 20101203
380 
381  totE += estimateEnergy(itTP->id().ietaAbs(), &result, eeC, v, tpgscale);
382 
383  /*
384  These commented out lines use
385  64GeV*fraction of the TT overlapping the dead FE
386 
387  int count = 0;
388  for (std::vector<DetId>::const_iterator idsit = v.begin(); idsit != v.end(); ++ idsit){
389  std::set<DetId>::const_iterator itFind = eeC.find(*idsit);
390  if (itFind != eeC.end())
391  ++count;
392  }
393  //std::cout << count << ", " << v.size() << std::endl;
394  totE+=((float)count/(float)v.size())* ((it->ietaAbs()>26)?2*ecalScale_.getTPGInGeV( itTP->compressedEt(), itTP->id() ):ecalScale_.getTPGInGeV( itTP->compressedEt(), itTP->id() ));*/
395  } else {
396  totE += ((it->ietaAbs() > 26) ? 2 : 1) * ecalScale.getTPGInGeV(itTP->compressedEt(), itTP->id());
397  }
398 
399  // get the trigger tower constituents
400 
401  if (itTP->compressedEt() == 0) { // If there's no energy in TT, the constituents are removed from the recovery.
402  for (size_t i = 0; i < v.size(); ++i)
403  eeC.erase(v[i]);
404  } else if (itTP->compressedEt() != 0xFF) {
405  //If it's saturated the energy has already been determined, so we do not want to subtract any channels
406  for (size_t j = 0; j < v.size(); ++j) {
407  aTTC.insert(v[j]);
408  }
409  }
410  }
411  }
412  // remove crystals of dead SC
413  // (this step is not needed if sure that SC crystals are not
414  // in the recHit collection)
415 
416  for (std::set<DetId>::const_iterator it = eeC.begin(); it != eeC.end(); ++it) {
417  aTTC.erase(*it);
418  }
419  // compute the total energy for the dead SC
420  const EcalRecHitCollection* hits = &result;
421  for (std::set<DetId>::const_iterator it = aTTC.begin(); it != aTTC.end(); ++it) {
423  if (jt != hits->end()) {
424  float energy = jt->energy(); // Correct conversion to Et
425  float eta = geo_->getPosition(jt->id()).eta();
426  float pf = 1.0 / cosh(eta);
427  // use Et instead of E, consistent with the Et estimation of the associated TT
428  totE -= energy * pf;
429  }
430  }
431 
432  float scEt = totE;
433  float scEtThreshEE = logWarningEtThreshold_EE_FE_;
434  if (scEt > scEtThreshEE) {
435  edm::LogWarning("EnergyInDeadEE_FE") << "TP energy in the dead TT = " << scEt << " at " << sc;
436  }
437 
438  // assign the energy to the SC crystals
439  if (!killDeadChannels_ || recoverEEFE_) { // if eeC is empty, i.e. there are no hits
440  // in the tower, nothing is returned. No negative values from noise.
441  for (std::set<DetId>::const_iterator it = eeC.begin(); it != eeC.end(); ++it) {
442  float eta = geo_->getPosition(*it).eta(); //Convert back to E from Et for the recovered hits
443  float pf = 1.0 / cosh(eta);
444  EcalRecHit hit(*it, totE / ((float)eeC.size() * pf), 0);
445 
446  if (atLeastOneTPSaturated)
447  hit.setFlag(EcalRecHit::kTPSaturated);
450 
451  } // for
452  } // if
453  }
454  return true;
455 }
const edm::EventSetup * eventSetup_
float estimateEnergy(int ieta, EcalRecHitCollection *hits, const std::set< DetId > &sId, const std::vector< DetId > &vId, const EcalTPGScale &tpgscale)
bool alreadyInserted(const DetId &id)
std::vector< DetId > constituentsOf(const EcalTrigTowerDetId &id) const
Get the constituent detids for this tower id.
EcalDeadChannelRecoveryAlgos< EEDetId > eeDeadChannelCorrector
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T eta() const
Definition: PV3DBase.h:73
T const * product() const
Definition: Handle.h:70
std::vector< T >::const_iterator const_iterator
std::vector< int > dbStatusToBeExcludedEE_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:536
int zside(DetId const &)
edm::ESHandle< CaloTopology > caloTopology_
EcalTPGScale::Tokens tpgscaleTokens_
void setCaloTopology(const CaloTopology *topology)
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
void insertRecHit(const EcalRecHit &hit, EcalRecHitCollection &collection)
EcalTPGScale::Tokens ecalScaleTokens_
T const * product() const
Definition: ESHandle.h:86
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
edm::ESHandle< EcalTrigTowerConstituentsMap > ttMap_
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
const CaloSubdetectorGeometry * ebGeom_
const_iterator end() const
Definition: DetId.h:17
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
edm::EDGetTokenT< EcalTrigPrimDigiCollection > tpDigiToken_
iterator find(key_type k)
std::vector< int > dbStatusToBeExcludedEB_
float correct(const DetIdT id, const EcalRecHitCollection &hit_collection, std::string algo, double single8Cut, double sum8Cut, bool *accFlag)
Log< level::Warning, false > LogWarning
EcalDeadChannelRecoveryAlgos< EBDetId > ebDeadChannelCorrector
Geom::Theta< T > theta() const
bool checkChannelStatus(const DetId &id, const std::vector< int > &statusestoexclude)

◆ set()

void EcalRecHitWorkerRecover::set ( const edm::EventSetup es)
overridevirtual

Implements EcalRecHitWorkerBaseClass.

Definition at line 147 of file EcalRecHitWorkerRecover.cc.

References caloGeometry_, caloGeometryToken_, caloTopology_, caloTopologyToken_, chStatus_, chStatusToken_, ebGeom_, ecalMapping_, eventSetup_, geo_, edm::EventSetup::getHandle(), laser, laserToken_, pEBGeom_, pEBGeomToken_, pEcalMapping_, pEcalMappingToken_, edm::ESHandle< T >::product(), recoveredDetIds_EB_, recoveredDetIds_EE_, ttMap_, and ttMapToken_.

147  {
152  // geometry...
159  recoveredDetIds_EB_.clear();
160  recoveredDetIds_EE_.clear();
161  eventSetup_ = &es;
162 }
edm::ESGetToken< CaloSubdetectorGeometry, EcalBarrelGeometryRecord > pEBGeomToken_
const edm::EventSetup * eventSetup_
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > pEcalMappingToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
edm::ESGetToken< EcalLaserDbService, EcalLaserDbRecord > laserToken_
edm::ESHandle< EcalElectronicsMapping > pEcalMapping_
edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > chStatusToken_
edm::ESHandle< CaloTopology > caloTopology_
T const * product() const
Definition: ESHandle.h:86
edm::ESHandle< EcalTrigTowerConstituentsMap > ttMap_
edm::ESHandle< CaloSubdetectorGeometry > pEBGeom_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
const CaloSubdetectorGeometry * ebGeom_
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > ttMapToken_
edm::ESHandle< CaloGeometry > caloGeometry_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
edm::ESHandle< EcalChannelStatus > chStatus_
edm::ESHandle< EcalLaserDbService > laser
const EcalElectronicsMapping * ecalMapping_

Member Data Documentation

◆ caloGeometry_

edm::ESHandle<CaloGeometry> EcalRecHitWorkerRecover::caloGeometry_
protected

Definition at line 61 of file EcalRecHitWorkerRecover.cc.

Referenced by set().

◆ caloGeometryToken_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> EcalRecHitWorkerRecover::caloGeometryToken_
protected

Definition at line 64 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and set().

◆ caloTopology_

edm::ESHandle<CaloTopology> EcalRecHitWorkerRecover::caloTopology_
protected

Definition at line 60 of file EcalRecHitWorkerRecover.cc.

Referenced by run(), and set().

◆ caloTopologyToken_

edm::ESGetToken<CaloTopology, CaloTopologyRecord> EcalRecHitWorkerRecover::caloTopologyToken_
protected

Definition at line 63 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and set().

◆ chStatus_

edm::ESHandle<EcalChannelStatus> EcalRecHitWorkerRecover::chStatus_
protected

Definition at line 62 of file EcalRecHitWorkerRecover.cc.

Referenced by checkChannelStatus(), and set().

◆ chStatusToken_

edm::ESGetToken<EcalChannelStatus, EcalChannelStatusRcd> EcalRecHitWorkerRecover::chStatusToken_
protected

Definition at line 65 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and set().

◆ dbStatusToBeExcludedEB_

std::vector<int> EcalRecHitWorkerRecover::dbStatusToBeExcludedEB_
protected

Definition at line 82 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ dbStatusToBeExcludedEE_

std::vector<int> EcalRecHitWorkerRecover::dbStatusToBeExcludedEE_
protected

Definition at line 81 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ ebDeadChannelCorrector

EcalDeadChannelRecoveryAlgos<EBDetId> EcalRecHitWorkerRecover::ebDeadChannelCorrector
protected

Definition at line 108 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ ebGeom_

const CaloSubdetectorGeometry* EcalRecHitWorkerRecover::ebGeom_
protected

Definition at line 96 of file EcalRecHitWorkerRecover.cc.

Referenced by run(), and set().

◆ ecalMapping_

const EcalElectronicsMapping* EcalRecHitWorkerRecover::ecalMapping_
protected

Definition at line 89 of file EcalRecHitWorkerRecover.cc.

Referenced by set().

◆ ecalScaleTokens_

EcalTPGScale::Tokens EcalRecHitWorkerRecover::ecalScaleTokens_
protected

Definition at line 86 of file EcalRecHitWorkerRecover.cc.

Referenced by run().

◆ eeDeadChannelCorrector

EcalDeadChannelRecoveryAlgos<EEDetId> EcalRecHitWorkerRecover::eeDeadChannelCorrector
protected

Definition at line 109 of file EcalRecHitWorkerRecover.cc.

Referenced by run().

◆ eventSetup_

const edm::EventSetup* EcalRecHitWorkerRecover::eventSetup_ = nullptr
protected

Definition at line 84 of file EcalRecHitWorkerRecover.cc.

Referenced by run(), and set().

◆ geo_

const CaloGeometry* EcalRecHitWorkerRecover::geo_
protected

Definition at line 97 of file EcalRecHitWorkerRecover.cc.

Referenced by estimateEnergy(), run(), and set().

◆ killDeadChannels_

bool EcalRecHitWorkerRecover::killDeadChannels_
protected

Definition at line 70 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ laser

edm::ESHandle<EcalLaserDbService> EcalRecHitWorkerRecover::laser
protected

Definition at line 56 of file EcalRecHitWorkerRecover.cc.

Referenced by set().

◆ laserToken_

edm::ESGetToken<EcalLaserDbService, EcalLaserDbRecord> EcalRecHitWorkerRecover::laserToken_
protected

Definition at line 57 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and set().

◆ logWarningEtThreshold_EB_FE_

double EcalRecHitWorkerRecover::logWarningEtThreshold_EB_FE_
protected

Definition at line 90 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ logWarningEtThreshold_EE_FE_

double EcalRecHitWorkerRecover::logWarningEtThreshold_EE_FE_
protected

Definition at line 91 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ pEBGeom_

edm::ESHandle<CaloSubdetectorGeometry> EcalRecHitWorkerRecover::pEBGeom_
protected

Definition at line 95 of file EcalRecHitWorkerRecover.cc.

Referenced by set().

◆ pEBGeomToken_

edm::ESGetToken<CaloSubdetectorGeometry, EcalBarrelGeometryRecord> EcalRecHitWorkerRecover::pEBGeomToken_
protected

Definition at line 100 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and set().

◆ pEcalMapping_

edm::ESHandle<EcalElectronicsMapping> EcalRecHitWorkerRecover::pEcalMapping_
protected

Definition at line 88 of file EcalRecHitWorkerRecover.cc.

Referenced by set().

◆ pEcalMappingToken_

edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> EcalRecHitWorkerRecover::pEcalMappingToken_
protected

Definition at line 98 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and set().

◆ rechitMaker_

std::unique_ptr<EcalRecHitSimpleAlgo> EcalRecHitWorkerRecover::rechitMaker_
protected

Definition at line 101 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover().

◆ recoverEBFE_

bool EcalRecHitWorkerRecover::recoverEBFE_
protected

Definition at line 76 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ recoverEBIsolatedChannels_

bool EcalRecHitWorkerRecover::recoverEBIsolatedChannels_
protected

Definition at line 72 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ recoverEBVFE_

bool EcalRecHitWorkerRecover::recoverEBVFE_
protected

Definition at line 74 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ recoveredDetIds_EB_

std::set<DetId> EcalRecHitWorkerRecover::recoveredDetIds_EB_
protected

Definition at line 103 of file EcalRecHitWorkerRecover.cc.

Referenced by alreadyInserted(), insertRecHit(), and set().

◆ recoveredDetIds_EE_

std::set<DetId> EcalRecHitWorkerRecover::recoveredDetIds_EE_
protected

Definition at line 104 of file EcalRecHitWorkerRecover.cc.

Referenced by alreadyInserted(), insertRecHit(), and set().

◆ recoverEEFE_

bool EcalRecHitWorkerRecover::recoverEEFE_
protected

Definition at line 77 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ recoverEEIsolatedChannels_

bool EcalRecHitWorkerRecover::recoverEEIsolatedChannels_
protected

Definition at line 73 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ recoverEEVFE_

bool EcalRecHitWorkerRecover::recoverEEVFE_
protected

Definition at line 75 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ singleRecoveryMethod_

std::string EcalRecHitWorkerRecover::singleRecoveryMethod_
protected

Definition at line 69 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ singleRecoveryThreshold_

double EcalRecHitWorkerRecover::singleRecoveryThreshold_
protected

Definition at line 67 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ sum8RecoveryThreshold_

double EcalRecHitWorkerRecover::sum8RecoveryThreshold_
protected

Definition at line 68 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ tpDigiToken_

edm::EDGetTokenT<EcalTrigPrimDigiCollection> EcalRecHitWorkerRecover::tpDigiToken_
protected

Definition at line 87 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and run().

◆ tpgscaleTokens_

EcalTPGScale::Tokens EcalRecHitWorkerRecover::tpgscaleTokens_
protected

Definition at line 106 of file EcalRecHitWorkerRecover.cc.

Referenced by run().

◆ ttMap_

edm::ESHandle<EcalTrigTowerConstituentsMap> EcalRecHitWorkerRecover::ttMap_
protected

Definition at line 93 of file EcalRecHitWorkerRecover.cc.

Referenced by estimateEnergy(), run(), and set().

◆ ttMapToken_

edm::ESGetToken<EcalTrigTowerConstituentsMap, IdealGeometryRecord> EcalRecHitWorkerRecover::ttMapToken_
protected

Definition at line 99 of file EcalRecHitWorkerRecover.cc.

Referenced by EcalRecHitWorkerRecover(), and set().