CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
EcalRecHitWorkerRecover Class Reference

#include <EcalRecHitWorkerRecover.h>

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)
 
void set (const edm::EventSetup &es)
 
virtual ~EcalRecHitWorkerRecover ()
 
- 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)
 
void insertRecHit (const EcalRecHit &hit, EcalRecHitCollection &collection)
 
float recCheckCalib (float energy, int ieta)
 

Protected Attributes

edm::ESHandle< CaloGeometrycaloGeometry_
 
edm::ESHandle< CaloTopologycaloTopology_
 
edm::ESHandle< EcalChannelStatuschStatus_
 
std::vector< int > dbStatusToBeExcludedEB_
 
std::vector< int > dbStatusToBeExcludedEE_
 
EcalDeadChannelRecoveryAlgos< EBDetIdebDeadChannelCorrector
 
const CaloSubdetectorGeometryebGeom_
 
const EcalElectronicsMappingecalMapping_
 
EcalTPGScale ecalScale_
 
EcalDeadChannelRecoveryAlgos< EEDetIdeeDeadChannelCorrector
 
const CaloGeometrygeo_
 
bool killDeadChannels_
 
edm::ESHandle< EcalLaserDbServicelaser
 
double logWarningEtThreshold_EB_FE_
 
double logWarningEtThreshold_EE_FE_
 
edm::ESHandle< CaloSubdetectorGeometrypEBGeom_
 
edm::ESHandle< EcalElectronicsMappingpEcalMapping_
 
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_
 
edm::EDGetTokenT< EcalTrigPrimDigiCollectiontpDigiToken_
 
EcalTPGScale tpgscale_
 
edm::ESHandle< EcalTrigTowerConstituentsMapttMap_
 

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 30 of file EcalRecHitWorkerRecover.h.

Constructor & Destructor Documentation

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

Definition at line 22 of file EcalRecHitWorkerRecover.cc.

References edm::ConsumesCollector::consumes(), dbStatusToBeExcludedEB_, dbStatusToBeExcludedEE_, edm::ParameterSet::getParameter(), killDeadChannels_, logWarningEtThreshold_EB_FE_, logWarningEtThreshold_EE_FE_, rechitMaker_, recoverEBFE_, recoverEBIsolatedChannels_, recoverEBVFE_, recoverEEFE_, recoverEEIsolatedChannels_, recoverEEVFE_, singleRecoveryMethod_, singleRecoveryThreshold_, AlCaHLTBitMon_QueryRunRegistry::string, and tpDigiToken_.

22  :
24 {
25  rechitMaker_ = std::make_unique<EcalRecHitSimpleAlgo>();
26  // isolated channel recovery
27  singleRecoveryMethod_ = ps.getParameter<std::string>("singleChannelRecoveryMethod");
28  singleRecoveryThreshold_ = ps.getParameter<double>("singleChannelRecoveryThreshold");
29  killDeadChannels_ = ps.getParameter<bool>("killDeadChannels");
30  recoverEBIsolatedChannels_ = ps.getParameter<bool>("recoverEBIsolatedChannels");
31  recoverEEIsolatedChannels_ = ps.getParameter<bool>("recoverEEIsolatedChannels");
32  recoverEBVFE_ = ps.getParameter<bool>("recoverEBVFE");
33  recoverEEVFE_ = ps.getParameter<bool>("recoverEEVFE");
34  recoverEBFE_ = ps.getParameter<bool>("recoverEBFE");
35  recoverEEFE_ = ps.getParameter<bool>("recoverEEFE");
36 
37  dbStatusToBeExcludedEE_ = ps.getParameter<std::vector<int> >("dbStatusToBeExcludedEE");
38  dbStatusToBeExcludedEB_ = ps.getParameter<std::vector<int> >("dbStatusToBeExcludedEB");
39 
40  logWarningEtThreshold_EB_FE_ = ps.getParameter<double>("logWarningEtThreshold_EB_FE");
41  logWarningEtThreshold_EE_FE_ = ps.getParameter<double>("logWarningEtThreshold_EE_FE");
42 
43  tpDigiToken_ =
44  c.consumes<EcalTrigPrimDigiCollection>(ps.getParameter<edm::InputTag>("triggerPrimitiveDigiCollection"));
45 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::vector< int > dbStatusToBeExcludedEE_
std::unique_ptr< EcalRecHitSimpleAlgo > rechitMaker_
EcalRecHitWorkerBaseClass(const edm::ParameterSet &, edm::ConsumesCollector &c)
edm::EDGetTokenT< EcalTrigPrimDigiCollection > tpDigiToken_
std::vector< int > dbStatusToBeExcludedEB_
virtual EcalRecHitWorkerRecover::~EcalRecHitWorkerRecover ( )
inlinevirtual

Member Function Documentation

bool EcalRecHitWorkerRecover::alreadyInserted ( const DetId id)
protected

Definition at line 407 of file EcalRecHitWorkerRecover.cc.

References EcalBarrel, EcalEndcap, recoveredDetIds_EB_, and recoveredDetIds_EE_.

Referenced by insertRecHit(), run(), and ~EcalRecHitWorkerRecover().

408 {
409  bool res = false;
410  if ( id.subdetId() == EcalBarrel ) {
411  res = ( recoveredDetIds_EB_.find( id ) != recoveredDetIds_EB_.end() );
412  } else if ( id.subdetId() == EcalEndcap ) {
413  res = ( recoveredDetIds_EE_.find( id ) != recoveredDetIds_EE_.end() );
414  } else {
415  edm::LogError("EcalRecHitWorkerRecover::InvalidDetId") << "Invalid DetId " << id.rawId();
416  }
417  return res;
418 }
Definition: Electron.h:4
std::set< DetId > recoveredDetIds_EE_
std::set< DetId > recoveredDetIds_EB_
bool EcalRecHitWorkerRecover::checkChannelStatus ( const DetId id,
const std::vector< int > &  statusestoexclude 
)
protected

Definition at line 431 of file EcalRecHitWorkerRecover.cc.

References chStatus_, DEFINE_EDM_PLUGIN, and mps_update::status.

Referenced by run(), and ~EcalRecHitWorkerRecover().

432  {
433 
434 
435  if (!chStatus_.isValid())
436  edm::LogError("ObjectNotFound") << "Channel Status not set";
437 
438 
439  EcalChannelStatus::const_iterator chIt = chStatus_->find( id );
440  uint16_t dbStatus = 0;
441  if ( chIt != chStatus_->end() ) {
442  dbStatus = chIt->getEncodedStatusCode();
443  } else {
444  edm::LogError("ObjectNotFound") << "No channel status found for xtal "
445  << id.rawId()
446  << "! something wrong with EcalChannelStatus in your DB? ";
447  }
448 
449  for (std::vector<int>::const_iterator status = statusestoexclude.begin();
450  status!= statusestoexclude.end(); ++status){
451 
452  if ( *status == dbStatus) return false;
453 
454  }
455 
456  return true;
457 }
std::vector< Item >::const_iterator const_iterator
edm::ESHandle< EcalChannelStatus > chStatus_
float EcalRecHitWorkerRecover::estimateEnergy ( int  ieta,
EcalRecHitCollection hits,
const std::set< DetId > &  sId,
const std::vector< DetId > &  vId 
)
protected

Definition at line 353 of file EcalRecHitWorkerRecover.cc.

References KineDebug3::count(), stringResolutionProvider_cfi::eta, PV3DBase< T, PVType, FrameType >::eta(), edm::SortedCollection< T, SORT >::find(), objects.autophobj::float, geo_, CaloGeometry::getPosition(), EcalTPGScale::getTPGInGeV(), packedPFCandidateRefMixer_cfi::pf, EcalTrigTowerConstituentsMap::towerOf(), tpgscale_, and ttMap_.

Referenced by run(), and ~EcalRecHitWorkerRecover().

353  {
354 
355  float xtalE=0;
356  int count = 0;
357  for (std::vector<DetId>::const_iterator vIdit = vId.begin(); vIdit != vId.end(); ++ vIdit){
358  std::set<DetId>::const_iterator sIdit = sId.find(*vIdit);
359  if (sIdit==sId.end()){
360  float energy = hits->find(*vIdit)->energy();
361  float eta = geo_->getPosition(*vIdit).eta();
362  float pf = 1.0/cosh(eta);
363  xtalE += energy*pf;
364  count++;
365  }
366  }
367 
368  if (count==0) { // If there are no overlapping crystals return saturated value.
369 
370  double etsat = tpgscale_.getTPGInGeV(0xFF,
371  ttMap_->towerOf(*vId.begin())); // get saturation value for the first
372  // constituent, for the others it's the same
373 
374  return etsat/cosh(ieta)*(ieta>26?2:1); // account for duplicated TT in EE for ieta>26
375  }
376  else return xtalE*((vId.size()/(float)count) - 1)*(ieta>26?2:1);
377 
378 
379 }
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:24
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
edm::ESHandle< EcalTrigTowerConstituentsMap > ttMap_
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:70
T eta() const
Definition: PV3DBase.h:76
iterator find(key_type k)
void EcalRecHitWorkerRecover::insertRecHit ( const EcalRecHit hit,
EcalRecHitCollection collection 
)
protected

Definition at line 382 of file EcalRecHitWorkerRecover.cc.

References alreadyInserted(), EcalBarrel, EcalEndcap, edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), EcalRecHit::id(), edm::SortedCollection< T, SORT >::push_back(), DetId::rawId(), recoveredDetIds_EB_, recoveredDetIds_EE_, and DetId::subdetId().

Referenced by run(), and ~EcalRecHitWorkerRecover().

383 {
384  // skip already inserted DetId's and raise a log warning
385  if ( alreadyInserted( hit.id() ) ) {
386  edm::LogWarning("EcalRecHitWorkerRecover") << "DetId already recovered! Skipping...";
387  return;
388  }
389  EcalRecHitCollection::iterator it = collection.find( hit.id() );
390  if ( it == collection.end() ) {
391  // insert the hit in the collection
392  collection.push_back( hit );
393  } else {
394  // overwrite existing recHit
395  *it = hit;
396  }
397  if ( hit.id().subdetId() == EcalBarrel ) {
398  recoveredDetIds_EB_.insert( hit.id() );
399  } else if ( hit.id().subdetId() == EcalEndcap ) {
400  recoveredDetIds_EE_.insert( hit.id() );
401  } else {
402  edm::LogError("EcalRecHitWorkerRecover::InvalidDetId") << "Invalid DetId " << hit.id().rawId();
403  }
404 }
bool alreadyInserted(const DetId &id)
void push_back(T const &t)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
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< EcalRecHit >::iterator iterator
const_iterator end() const
DetId id() const
get the id
Definition: EcalRecHit.h:77
std::set< DetId > recoveredDetIds_EE_
iterator find(key_type k)
std::set< DetId > recoveredDetIds_EB_
float EcalRecHitWorkerRecover::recCheckCalib ( float  energy,
int  ieta 
)
protected

Definition at line 422 of file EcalRecHitWorkerRecover.cc.

Referenced by ~EcalRecHitWorkerRecover().

422  {
423 
424  return eTT;
425 
426 }
bool EcalRecHitWorkerRecover::run ( const edm::Event evt,
const EcalUncalibratedRecHit uncalibRH,
EcalRecHitCollection result 
)
virtual

Implements EcalRecHitWorkerBaseClass.

Definition at line 70 of file EcalRecHitWorkerRecover.cc.

References alreadyInserted(), caloTopology_, checkChannelStatus(), EcalTrigTowerConstituentsMap::constituentsOf(), EcalDeadChannelRecoveryAlgos< DetIdT >::correct(), dbStatusToBeExcludedEB_, dbStatusToBeExcludedEE_, EcalRecHitWorkerBaseClass::EB_FE, EcalRecHitWorkerBaseClass::EB_single, EcalRecHitWorkerBaseClass::EB_VFE, ebDeadChannelCorrector, ebGeom_, ecalScale_, EcalRecHitWorkerBaseClass::EE_FE, EcalRecHitWorkerBaseClass::EE_single, EcalRecHitWorkerBaseClass::EE_VFE, eeDeadChannelCorrector, edm::SortedCollection< T, SORT >::end(), EcalRecHit::energy(), estimateEnergy(), stringResolutionProvider_cfi::eta, PV3DBase< T, PVType, FrameType >::eta(), edm::SortedCollection< T, SORT >::find(), EcalUncalibratedRecHit::flags(), flags, geo_, edm::Event::getByToken(), CaloSubdetectorGeometry::getGeometry(), CaloGeometry::getPosition(), CaloCellGeometry::getPosition(), EcalTPGScale::getTPGInGeV(), hfClusterShapes_cfi::hits, mps_fire::i, hcalTTPDigis_cfi::id, EcalUncalibratedRecHit::id(), insertRecHit(), EcalScDetId::ix(), EEDetId::ix(), EcalScDetId::iy(), EEDetId::iy(), 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, SimDataFormats::CaloAnalysis::sc, EcalDeadChannelRecoveryAlgos< DetIdT >::setCaloTopology(), EcalRecHit::setFlag(), funct::sin(), singleRecoveryMethod_, singleRecoveryThreshold_, PV3DBase< T, PVType, FrameType >::theta(), theta(), EcalTrigTowerConstituentsMap::towerOf(), tpDigiToken_, funct::true, ttMap_, findQualityFiles::v, EEDetId::validDetId(), HcalDigiParam_cfi::zside, EcalScDetId::zside(), and EEDetId::zside().

Referenced by ~EcalRecHitWorkerRecover().

73 {
74  DetId detId=uncalibRH.id();
75  uint32_t flags = (0xF & uncalibRH.flags());
76 
77  // get laser coefficient
78  //float lasercalib = laser->getLaserCorrection( detId, evt.time());
79 
80  // killDeadChannels_ = true, means explicitely kill dead channels even if the recovered energies are computed in the code
81  // if you don't want to store the recovered energies in the rechit you can produce LogWarnings if logWarningEtThreshold_EB(EE)_FE>0
82  // logWarningEtThreshold_EB(EE)_FE_<0 will not compute the recovered energies at all (faster)
83 
84  if ( killDeadChannels_ ) {
89  ) {
90  EcalRecHit hit( detId, 0., 0., EcalRecHit::kDead );
91  hit.setFlag( EcalRecHit::kDead) ;
92  insertRecHit( hit, result); // insert trivial rechit with kDead flag
93  return true;
94  }
95  if ( flags == EcalRecHitWorkerRecover::EB_FE && !recoverEBFE_) {
96  EcalTrigTowerDetId ttDetId( ((EBDetId)detId).tower() );
97  std::vector<DetId> vid = ttMap_->constituentsOf( ttDetId );
98  for ( std::vector<DetId>::const_iterator dit = vid.begin(); dit != vid.end(); ++dit ) {
99  EcalRecHit hit( (*dit), 0., 0., EcalRecHit::kDead );
100  hit.setFlag( EcalRecHit::kDead ) ;
101  insertRecHit( hit, result ); // insert trivial rechit with kDead flag
102  }
103  if(logWarningEtThreshold_EB_FE_<0)return true; // if you don't want log warning just return true
104  }
105  if ( flags == EcalRecHitWorkerRecover::EE_FE && !recoverEEFE_) {
106  EEDetId id( detId );
107  EcalScDetId sc( 1+(id.ix()-1)/5, 1+(id.iy()-1)/5, id.zside() );
108  std::vector<DetId> eeC;
109  for(int dx=1; dx<=5; ++dx){
110  for(int dy=1; dy<=5; ++dy){
111  int ix = (sc.ix()-1)*5 + dx;
112  int iy = (sc.iy()-1)*5 + dy;
113  int iz = sc.zside();
114  if(EEDetId::validDetId(ix, iy, iz)){
115  eeC.push_back(EEDetId(ix, iy, iz));
116  }
117  }
118  }
119  for ( size_t i = 0; i < eeC.size(); ++i ) {
120  EcalRecHit hit( eeC[i], 0., 0., EcalRecHit::kDead );
121  hit.setFlag( EcalRecHit::kDead ) ;
122  insertRecHit( hit, result ); // insert trivial rechit with kDead flag
123  }
124  if(logWarningEtThreshold_EE_FE_<0) return true; // if you don't want log warning just return true
125  }
126  }
127 
128  if ( flags == EcalRecHitWorkerRecover::EB_single ) {
129  // recover as single dead channel
131 
132  // channel recovery. Accepted new RecHit has the flag AcceptRecHit=TRUE
133  bool AcceptRecHit=true;
135 
136  if ( hit.energy() != 0 and AcceptRecHit == true ) {
138  } else {
139  // recovery failed
140  hit.setFlag( EcalRecHit::kDead ) ;
141  }
142  insertRecHit( hit, result );
143 
144  } else if ( flags == EcalRecHitWorkerRecover::EE_single ) {
145  // recover as single dead channel
147 
148  // channel recovery. Accepted new RecHit has the flag AcceptRecHit=TRUE
149  bool AcceptRecHit=true;
151  if ( hit.energy() != 0 and AcceptRecHit == true ) {
153  } else {
154  // recovery failed
155  hit.setFlag( EcalRecHit::kDead ) ;
156  }
157  insertRecHit( hit, result );
158 
159  } else if ( flags == EcalRecHitWorkerRecover::EB_VFE ) {
160  // recover as dead VFE
161  EcalRecHit hit( detId, 0., 0.);
162  hit.setFlag( EcalRecHit::kDead ) ;
163  // recovery not implemented
164  insertRecHit( hit, result );
165  } else if ( flags == EcalRecHitWorkerRecover::EB_FE ) {
166  // recover as dead TT
167 
168  EcalTrigTowerDetId ttDetId( ((EBDetId)detId).tower() );
170  evt.getByToken(tpDigiToken_, pTPDigis);
171  const EcalTrigPrimDigiCollection * tpDigis = 0;
172  tpDigis = pTPDigis.product();
173 
174  EcalTrigPrimDigiCollection::const_iterator tp = tpDigis->find( ttDetId );
175  // recover the whole trigger tower
176  if ( tp != tpDigis->end() ) {
177  //std::vector<DetId> vid = ecalMapping_->dccTowerConstituents( ecalMapping_->DCCid( ttDetId ), ecalMapping_->iTT( ttDetId ) );
178  std::vector<DetId> vid = ttMap_->constituentsOf( ttDetId );
179  float tpEt = ecalScale_.getTPGInGeV( tp->compressedEt(), tp->id() );
180  float tpEtThreshEB = logWarningEtThreshold_EB_FE_;
181  if(tpEt>tpEtThreshEB){
182  edm::LogWarning("EnergyInDeadEB_FE")<<"TP energy in the dead TT = "<<tpEt<<" at "<<ttDetId;
183  }
184  if ( !killDeadChannels_ || recoverEBFE_ ) {
185  // democratic energy sharing
186 
187  for ( std::vector<DetId>::const_iterator dit = vid.begin(); dit != vid.end(); ++dit ) {
188  if (alreadyInserted(*dit)) continue;
189  float theta = ebGeom_->getGeometry(*dit)->getPosition().theta();
190  float tpEt = ecalScale_.getTPGInGeV( tp->compressedEt(), tp->id() );
192  EcalRecHit hit( *dit, tpEt /((float)vid.size()) / sin(theta), 0.);
194  if ( tp->compressedEt() == 0xFF ) hit.setFlag( EcalRecHit::kTPSaturated );
195  if ( tp->sFGVB() ) hit.setFlag( EcalRecHit::kL1SpikeFlag );
196  insertRecHit( hit, result );
197  }
198  }
199  } else {
200  // tp not found => recovery failed
201  std::vector<DetId> vid = ttMap_->constituentsOf( ttDetId );
202  for ( std::vector<DetId>::const_iterator dit = vid.begin(); dit != vid.end(); ++dit ) {
203  if (alreadyInserted(*dit)) continue;
204  EcalRecHit hit( *dit,0., 0. );
205  hit.setFlag( EcalRecHit::kDead ) ;
206  insertRecHit( hit, result );
207  }
208  }
209  }
210  } else if ( flags == EcalRecHitWorkerRecover::EE_FE ) {
211  // Structure for recovery:
212  // ** SC --> EEDetId constituents (eeC) --> associated Trigger Towers (aTT) --> EEDetId constituents (aTTC)
213  // ** energy for a SC EEDetId = [ sum_aTT(energy) - sum_aTTC(energy) ] / N_eeC
214  // .. i.e. the total energy of the TTs covering the SC minus
215  // .. the energy of the recHits in the TTs but not in the SC
216  //std::vector<DetId> vid = ecalMapping_->dccTowerConstituents( ecalMapping_->DCCid( ttDetId ), ecalMapping_->iTT( ttDetId ) );
217  // due to lack of implementation of the EcalTrigTowerDetId ix,iy methods in EE we compute Et recovered energies (in EB we compute E)
218 
219  EEDetId eeId( detId );
220  EcalScDetId sc( (eeId.ix()-1)/5+1, (eeId.iy()-1)/5+1, eeId.zside() );
221  std::set<DetId> eeC;
222  for(int dx=1; dx<=5; ++dx){
223  for(int dy=1; dy<=5; ++dy){
224  int ix = (sc.ix()-1)*5 + dx;
225  int iy = (sc.iy()-1)*5 + dy;
226  int iz = sc.zside();
227  if(EEDetId::validDetId(ix, iy, iz)){
228  EEDetId id(ix, iy, iz);
230  eeC.insert(id);
231  } // check status
232  }
233  }
234  }
235 
237  evt.getByToken(tpDigiToken_, pTPDigis);
238  const EcalTrigPrimDigiCollection * tpDigis = 0;
239  tpDigis = pTPDigis.product();
240 
241  // associated trigger towers
242  std::set<EcalTrigTowerDetId> aTT;
243  for ( std::set<DetId>::const_iterator it = eeC.begin(); it!=eeC.end(); ++it ) {
244  aTT.insert( ttMap_->towerOf( *it ) );
245  }
246  // associated trigger towers: total energy
247  float totE = 0;
248  // associated trigger towers: EEDetId constituents
249  std::set<DetId> aTTC;
250  bool atLeastOneTPSaturated = false;
251  for ( std::set<EcalTrigTowerDetId>::const_iterator it = aTT.begin(); it != aTT.end(); ++it ) {
252  // add the energy of this trigger tower
253  EcalTrigPrimDigiCollection::const_iterator itTP = tpDigis->find( *it );
254  if ( itTP != tpDigis->end() ) {
255 
256  std::vector<DetId> v = ttMap_->constituentsOf( *it );
257 
258  // from the constituents, remove dead channels
259  std::vector<DetId>::iterator ttcons = v.begin();
260  while (ttcons != v.end()){
262  ttcons=v.erase(ttcons);
263  } else {
264  ++ttcons;
265  }
266  }// while
267 
268  if ( itTP->compressedEt() == 0xFF ){ // In the case of a saturated trigger tower, a fraction
269  atLeastOneTPSaturated = true; //of the saturated energy is put in: number of xtals in dead region/total xtals in TT *63.75
270 
271  //Alternative recovery algorithm that I will now investigate.
272  //Estimate energy sums the energy in the working channels, then decides how much energy
273  //to put here depending on that. Duncan 20101203
274 
275  totE += estimateEnergy(itTP->id().ietaAbs(), &result, eeC, v);
276 
277  /*
278  These commented out lines use
279  64GeV*fraction of the TT overlapping the dead FE
280 
281  int count = 0;
282  for (std::vector<DetId>::const_iterator idsit = v.begin(); idsit != v.end(); ++ idsit){
283  std::set<DetId>::const_iterator itFind = eeC.find(*idsit);
284  if (itFind != eeC.end())
285  ++count;
286  }
287  //std::cout << count << ", " << v.size() << std::endl;
288  totE+=((float)count/(float)v.size())* ((it->ietaAbs()>26)?2*ecalScale_.getTPGInGeV( itTP->compressedEt(), itTP->id() ):ecalScale_.getTPGInGeV( itTP->compressedEt(), itTP->id() ));*/
289  }
290  else {totE += ((it->ietaAbs()>26)?2:1)*ecalScale_.getTPGInGeV( itTP->compressedEt(), itTP->id() );}
291 
292 
293  // get the trigger tower constituents
294 
295  if (itTP->compressedEt() == 0){ // If there's no energy in TT, the constituents are removed from the recovery.
296  for (size_t i = 0 ; i < v.size(); ++i)
297  eeC.erase(v[i]);
298  }
299  else if (itTP->compressedEt()!=0xFF){ //If it's saturated the energy has already been determined, so we do not want to subtract any channels
300  for ( size_t j = 0; j < v.size(); ++j ) {
301  aTTC.insert( v[j] );
302  }
303  }
304 
305  }
306  }
307  // remove crystals of dead SC
308  // (this step is not needed if sure that SC crystals are not
309  // in the recHit collection)
310 
311  for ( std::set<DetId>::const_iterator it = eeC.begin(); it != eeC.end(); ++it ) {
312  aTTC.erase(*it);
313  }
314  // compute the total energy for the dead SC
315  const EcalRecHitCollection * hits = &result;
316  for ( std::set<DetId>::const_iterator it = aTTC.begin(); it != aTTC.end(); ++it ) {
317  EcalRecHitCollection::const_iterator jt = hits->find( *it );
318  if ( jt != hits->end() ) {
319  float energy = jt->energy(); // Correct conversion to Et
320  float eta = geo_->getPosition(jt->id()).eta();
321  float pf = 1.0/cosh(eta);
322  // use Et instead of E, consistent with the Et estimation of the associated TT
323  totE -= energy*pf;
324  }
325  }
326 
327 
328  float scEt = totE;
329  float scEtThreshEE = logWarningEtThreshold_EE_FE_;
330  if(scEt>scEtThreshEE){
331  edm::LogWarning("EnergyInDeadEE_FE")<<"TP energy in the dead TT = "<<scEt<<" at "<<sc;
332  }
333 
334  // assign the energy to the SC crystals
335  if ( !killDeadChannels_ || recoverEEFE_ ) { // if eeC is empty, i.e. there are no hits
336  // in the tower, nothing is returned. No negative values from noise.
337  for ( std::set<DetId>::const_iterator it = eeC.begin(); it != eeC.end(); ++it ) {
338 
339  float eta = geo_->getPosition(*it).eta(); //Convert back to E from Et for the recovered hits
340  float pf = 1.0/cosh(eta);
341  EcalRecHit hit( *it, totE / ((float)eeC.size()*pf), 0);
342 
343  if (atLeastOneTPSaturated) hit.setFlag(EcalRecHit::kTPSaturated );
345  insertRecHit( hit, result );
346 
347  }// for
348  }// if
349  }
350  return true;
351 }
bool alreadyInserted(const DetId &id)
EcalDeadChannelRecoveryAlgos< EEDetId > eeDeadChannelCorrector
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< EcalTriggerPrimitiveDigi >::const_iterator const_iterator
Geom::Theta< T > theta() const
std::vector< int > dbStatusToBeExcludedEE_
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
void setFlag(int flag)
set the flags (from Flags or ESFlags)
Definition: EcalRecHit.h:185
edm::ESHandle< CaloTopology > caloTopology_
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:24
void setCaloTopology(const CaloTopology *topology)
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
void insertRecHit(const EcalRecHit &hit, EcalRecHitCollection &collection)
EcalRecHit correct(const DetIdT id, const EcalRecHitCollection &hit_collection, std::string algo, double Sum8Cut, bool *AccFlag)
edm::ESHandle< EcalTrigTowerConstituentsMap > ttMap_
float energy() const
Definition: EcalRecHit.h:68
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:70
float estimateEnergy(int ieta, EcalRecHitCollection *hits, const std::set< DetId > &sId, const std::vector< DetId > &vId)
std::vector< DetId > constituentsOf(const EcalTrigTowerDetId &id) const
Get the constituent detids for this tower id.
const CaloSubdetectorGeometry * ebGeom_
const_iterator end() const
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:81
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
edm::EDGetTokenT< EcalTrigPrimDigiCollection > tpDigiToken_
T eta() const
Definition: PV3DBase.h:76
iterator find(key_type k)
std::vector< int > dbStatusToBeExcludedEB_
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
EcalDeadChannelRecoveryAlgos< EBDetId > ebDeadChannelCorrector
T const * product() const
Definition: ESHandle.h:86
bool checkChannelStatus(const DetId &id, const std::vector< int > &statusestoexclude)
void EcalRecHitWorkerRecover::set ( const edm::EventSetup es)
virtual

Implements EcalRecHitWorkerBaseClass.

Definition at line 48 of file EcalRecHitWorkerRecover.cc.

References caloGeometry_, caloTopology_, chStatus_, ebGeom_, ecalMapping_, ecalScale_, geo_, edm::EventSetup::get(), laser, pEBGeom_, pEcalMapping_, edm::ESHandle< T >::product(), recoveredDetIds_EB_, recoveredDetIds_EE_, EcalTPGScale::setEventSetup(), tpgscale_, and ttMap_.

49 {
50 
51  es.get<EcalLaserDbRecord>().get(laser);
54  es.get<EcalMappingRcd>().get(pEcalMapping_);
56  // geometry...
57  es.get<EcalBarrelGeometryRecord>().get("EcalBarrel",pEBGeom_);
62  es.get<IdealGeometryRecord>().get(ttMap_);
63  recoveredDetIds_EB_.clear();
64  recoveredDetIds_EE_.clear();
66 }
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:19
edm::ESHandle< CaloTopology > caloTopology_
edm::ESHandle< EcalTrigTowerConstituentsMap > ttMap_
edm::ESHandle< CaloSubdetectorGeometry > pEBGeom_
const CaloSubdetectorGeometry * ebGeom_
const T & get() const
Definition: EventSetup.h:56
std::set< DetId > recoveredDetIds_EE_
edm::ESHandle< CaloGeometry > caloGeometry_
edm::ESHandle< EcalChannelStatus > chStatus_
T const * product() const
Definition: ESHandle.h:86
edm::ESHandle< EcalLaserDbService > laser
const EcalElectronicsMapping * ecalMapping_
edm::ESHandle< EcalElectronicsMapping > pEcalMapping_
std::set< DetId > recoveredDetIds_EB_

Member Data Documentation

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

Definition at line 53 of file EcalRecHitWorkerRecover.h.

Referenced by set().

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

Definition at line 52 of file EcalRecHitWorkerRecover.h.

Referenced by run(), and set().

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

Definition at line 54 of file EcalRecHitWorkerRecover.h.

Referenced by checkChannelStatus(), and set().

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

Definition at line 71 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

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

Definition at line 70 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

EcalDeadChannelRecoveryAlgos<EBDetId> EcalRecHitWorkerRecover::ebDeadChannelCorrector
protected

Definition at line 94 of file EcalRecHitWorkerRecover.h.

Referenced by run().

const CaloSubdetectorGeometry* EcalRecHitWorkerRecover::ebGeom_
protected

Definition at line 84 of file EcalRecHitWorkerRecover.h.

Referenced by run(), and set().

const EcalElectronicsMapping* EcalRecHitWorkerRecover::ecalMapping_
protected

Definition at line 77 of file EcalRecHitWorkerRecover.h.

Referenced by set().

EcalTPGScale EcalRecHitWorkerRecover::ecalScale_
protected

Definition at line 74 of file EcalRecHitWorkerRecover.h.

Referenced by run(), and set().

EcalDeadChannelRecoveryAlgos<EEDetId> EcalRecHitWorkerRecover::eeDeadChannelCorrector
protected

Definition at line 95 of file EcalRecHitWorkerRecover.h.

Referenced by run().

const CaloGeometry* EcalRecHitWorkerRecover::geo_
protected

Definition at line 85 of file EcalRecHitWorkerRecover.h.

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

bool EcalRecHitWorkerRecover::killDeadChannels_
protected

Definition at line 59 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

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

Definition at line 49 of file EcalRecHitWorkerRecover.h.

Referenced by set().

double EcalRecHitWorkerRecover::logWarningEtThreshold_EB_FE_
protected

Definition at line 78 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

double EcalRecHitWorkerRecover::logWarningEtThreshold_EE_FE_
protected

Definition at line 79 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

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

Definition at line 83 of file EcalRecHitWorkerRecover.h.

Referenced by set().

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

Definition at line 76 of file EcalRecHitWorkerRecover.h.

Referenced by set().

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

Definition at line 87 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover().

bool EcalRecHitWorkerRecover::recoverEBFE_
protected

Definition at line 65 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

bool EcalRecHitWorkerRecover::recoverEBIsolatedChannels_
protected

Definition at line 61 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

bool EcalRecHitWorkerRecover::recoverEBVFE_
protected

Definition at line 63 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

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

Definition at line 89 of file EcalRecHitWorkerRecover.h.

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

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

Definition at line 90 of file EcalRecHitWorkerRecover.h.

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

bool EcalRecHitWorkerRecover::recoverEEFE_
protected

Definition at line 66 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

bool EcalRecHitWorkerRecover::recoverEEIsolatedChannels_
protected

Definition at line 62 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

bool EcalRecHitWorkerRecover::recoverEEVFE_
protected

Definition at line 64 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

std::string EcalRecHitWorkerRecover::singleRecoveryMethod_
protected

Definition at line 58 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

double EcalRecHitWorkerRecover::singleRecoveryThreshold_
protected

Definition at line 57 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

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

Definition at line 75 of file EcalRecHitWorkerRecover.h.

Referenced by EcalRecHitWorkerRecover(), and run().

EcalTPGScale EcalRecHitWorkerRecover::tpgscale_
protected

Definition at line 92 of file EcalRecHitWorkerRecover.h.

Referenced by estimateEnergy(), and set().

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

Definition at line 81 of file EcalRecHitWorkerRecover.h.

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