CMS 3D CMS Logo

AntiElectronDeadECAL.cc
Go to the documentation of this file.
2 
17 
19  : minStatus_(cfg.getParameter<uint32_t>("minStatus")),
20  dR2_(std::pow(cfg.getParameter<double>("dR"), 2)),
21  extrapolateToECalEntrance_(cfg.getParameter<bool>("extrapolateToECalEntrance")),
22  verbosity_(cfg.getParameter<int>("verbosity")),
23  isFirstEvent_(true) {}
24 
26 
28  updateBadTowers(es);
30 }
31 
32 namespace {
33  template <class Id>
34  void loopXtals(std::map<uint32_t, unsigned>& nBadCrystals,
35  std::map<uint32_t, unsigned>& maxStatus,
36  std::map<uint32_t, double>& sumEta,
37  std::map<uint32_t, double>& sumPhi,
38  const EcalChannelStatus* channelStatus,
39  const CaloGeometry* caloGeometry,
40  const EcalTrigTowerConstituentsMap* ttMap,
41  unsigned minStatus,
42  const uint16_t statusMask) {
43  // NOTE: modified version of SUSY CAF code
44  // UserCode/SusyCAF/plugins/SusyCAF_EcalDeadChannels.cc
45  for (int i = 0; i < Id::kSizeForDenseIndexing; ++i) {
46  Id id = Id::unhashIndex(i);
47  if (id == Id(0))
48  continue;
49  EcalChannelStatusMap::const_iterator it = channelStatus->getMap().find(id.rawId());
50  unsigned status = (it == channelStatus->end()) ? 0 : (it->getStatusCode() & statusMask);
51  if (status >= minStatus) {
52  const GlobalPoint& point = caloGeometry->getPosition(id);
53  uint32_t key = ttMap->towerOf(id);
54  maxStatus[key] = std::max(status, maxStatus[key]);
55  ++nBadCrystals[key];
56  sumEta[key] += point.eta();
57  sumPhi[key] += point.phi();
58  }
59  }
60  }
61 } // namespace
62 
64  // NOTE: modified version of SUSY CAF code
65  // UserCode/SusyCAF/plugins/SusyCAF_EcalDeadChannels.cc
66 
69  return;
70 
72  es.get<EcalChannelStatusRcd>().get(channelStatus);
73 
74  edm::ESHandle<CaloGeometry> caloGeometry;
75  es.get<CaloGeometryRecord>().get(caloGeometry);
76 
78  es.get<IdealGeometryRecord>().get(ttMap);
79 
80  std::map<uint32_t, unsigned> nBadCrystals, maxStatus;
81  std::map<uint32_t, double> sumEta, sumPhi;
82 
83  loopXtals<EBDetId>(nBadCrystals,
84  maxStatus,
85  sumEta,
86  sumPhi,
87  channelStatus.product(),
88  caloGeometry.product(),
89  ttMap.product(),
90  minStatus_,
91  statusMask_);
92  loopXtals<EEDetId>(nBadCrystals,
93  maxStatus,
94  sumEta,
95  sumPhi,
96  channelStatus.product(),
97  caloGeometry.product(),
98  ttMap.product(),
99  minStatus_,
100  statusMask_);
101 
102  badTowers_.clear();
103  for (auto it : nBadCrystals) {
104  uint32_t key = it.first;
105  badTowers_.push_back(TowerInfo(key, it.second, maxStatus[key], sumEta[key] / it.second, sumPhi[key] / it.second));
106  }
107 
108  isFirstEvent_ = false;
109 }
110 
112  bool isNearBadTower = false;
113  double tau_eta = tau->eta();
114  double tau_phi = tau->phi();
115  const reco::Candidate* leadChargedHadron = nullptr;
117  const reco::PFTau* pfTau = dynamic_cast<const reco::PFTau*>(tau);
118  if (pfTau != nullptr) {
119  leadChargedHadron = pfTau->leadChargedHadrCand().isNonnull() ? pfTau->leadChargedHadrCand().get() : nullptr;
120  } else {
121  const pat::Tau* patTau = dynamic_cast<const pat::Tau*>(tau);
122  if (patTau != nullptr) {
123  leadChargedHadron = patTau->leadChargedHadrCand().isNonnull() ? patTau->leadChargedHadrCand().get() : nullptr;
124  }
125  }
126  }
127  if (leadChargedHadron != nullptr) {
128  bool success = false;
129  reco::Candidate::Point positionAtECalEntrance = positionAtECalEntrance_(leadChargedHadron, success);
130  if (success) {
131  tau_eta = positionAtECalEntrance.eta();
132  tau_phi = positionAtECalEntrance.phi();
133  }
134  }
135  if (verbosity_) {
136  edm::LogPrint("TauAgainstEleDeadECAL") << "<AntiElectronDeadECal::operator()>:";
137  edm::LogPrint("TauAgainstEleDeadECAL") << " #badTowers = " << badTowers_.size();
138  if (leadChargedHadron != nullptr) {
139  edm::LogPrint("TauAgainstEleDeadECAL")
140  << " leadChargedHadron (" << leadChargedHadron->pdgId() << "): Pt = " << leadChargedHadron->pt()
141  << ", eta at ECAL (vtx) = " << tau_eta << " (" << leadChargedHadron->eta() << ")"
142  << ", phi at ECAL (vtx) = " << tau_phi << " (" << leadChargedHadron->phi() << ")";
143  } else {
144  edm::LogPrint("TauAgainstEleDeadECAL")
145  << " tau: Pt = " << tau->pt() << ", eta at vtx = " << tau_eta << ", phi at vtx = " << tau_phi;
146  }
147  }
148  for (auto const& badTower : badTowers_) {
149  if (deltaR2(badTower.eta_, badTower.phi_, tau_eta, tau_phi) < dR2_) {
150  if (verbosity_) {
151  edm::LogPrint("TauAgainstEleDeadECAL")
152  << " matches badTower: eta = " << badTower.eta_ << ", phi = " << badTower.phi_;
153  }
154  isNearBadTower = true;
155  break;
156  }
157  }
158  return isNearBadTower;
159 }
pat::Tau::leadChargedHadrCand
const reco::CandidatePtr leadChargedHadrCand() const
EcalCondObjectContainer::getMap
const self & getMap() const
Definition: EcalCondObjectContainer.h:80
AntiElectronDeadECAL::statusMask_
static const uint16_t statusMask_
Definition: AntiElectronDeadECAL.h:65
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalCondObjectContainer::end
const_iterator end() const
Definition: EcalCondObjectContainer.h:76
AntiElectronDeadECAL::~AntiElectronDeadECAL
~AntiElectronDeadECAL()
Definition: AntiElectronDeadECAL.cc:25
AntiElectronDeadECAL::isFirstEvent_
bool isFirstEvent_
Definition: AntiElectronDeadECAL.h:71
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
AntiElectronDeadECAL.h
MessageLogger.h
runTauDisplay.tau_eta
tau_eta
Definition: runTauDisplay.py:126
ESHandle.h
AntiElectronDeadECAL::verbosity_
const int verbosity_
Definition: AntiElectronDeadECAL.h:48
metsig::tau
Definition: SignAlgoResolutions.h:49
mps_update.status
status
Definition: mps_update.py:69
CaloGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
reco::Candidate::eta
virtual double eta() const =0
momentum pseudorapidity
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
AntiElectronDeadECAL::dR2_
const double dR2_
Definition: AntiElectronDeadECAL.h:46
pat::Tau
Analysis-level tau class.
Definition: Tau.h:53
EBDetId.h
EEDetId.h
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
reco::PFTau
Definition: PFTau.h:36
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
EcalCondObjectContainer< EcalChannelStatusCode >
Tau.h
AntiElectronDeadECAL::caloGeometryWatcher_
edm::ESWatcher< CaloGeometryRecord > caloGeometryWatcher_
Definition: AntiElectronDeadECAL.h:68
AntiElectronDeadECAL::updateBadTowers
void updateBadTowers(const edm::EventSetup &)
Definition: AntiElectronDeadECAL.cc:63
PositionAtECalEntranceComputer::beginEvent
void beginEvent(const edm::EventSetup &)
Definition: PositionAtECalEntranceComputer.cc:13
deltaR.h
AntiElectronDeadECAL::TowerInfo
Definition: AntiElectronDeadECAL.h:54
CaloGeometry
Definition: CaloGeometry.h:21
AntiElectronDeadECAL::operator()
bool operator()(const reco::Candidate *tau) const
Definition: AntiElectronDeadECAL.cc:111
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
edm::ESHandle
Definition: DTSurvey.h:22
AntiElectronDeadECAL::idealGeometryWatcher_
edm::ESWatcher< IdealGeometryRecord > idealGeometryWatcher_
Definition: AntiElectronDeadECAL.h:69
AntiElectronDeadECAL::AntiElectronDeadECAL
AntiElectronDeadECAL(const edm::ParameterSet &)
Definition: AntiElectronDeadECAL.cc:18
summarizeEdmComparisonLogfiles.success
success
Definition: summarizeEdmComparisonLogfiles.py:115
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
Point3DBase< float, GlobalTag >
runTauDisplay.tau_phi
tau_phi
Definition: runTauDisplay.py:127
reco::PFTau::leadChargedHadrCand
const CandidatePtr & leadChargedHadrCand() const
Definition: PFTau.cc:62
AntiElectronDeadECAL::positionAtECalEntrance_
PositionAtECalEntranceComputer positionAtECalEntrance_
Definition: AntiElectronDeadECAL.h:50
CaloGeometryRecord.h
EcalTrigTowerConstituentsMap
Definition: EcalTrigTowerConstituentsMap.h:19
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:36
AntiElectronDeadECAL::minStatus_
const unsigned minStatus_
Definition: AntiElectronDeadECAL.h:45
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
EcalChannelStatusRcd
Definition: EcalChannelStatusRcd.h:5
createfilelist.int
int
Definition: createfilelist.py:10
edm::LogPrint
Definition: MessageLogger.h:342
IdealGeometryRecord.h
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
reco::Candidate::pdgId
virtual int pdgId() const =0
PDG identifier.
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
EcalTrigTowerConstituentsMap::towerOf
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
Definition: EcalTrigTowerConstituentsMap.cc:11
AntiElectronDeadECAL::channelStatusWatcher_
edm::ESWatcher< EcalChannelStatusRcd > channelStatusWatcher_
Definition: AntiElectronDeadECAL.h:67
EcalTrigTowerConstituentsMap.h
std
Definition: JetResolutionObject.h:76
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
DetId.h
CaloGeometry.h
PFTau.h
edm::Ptr::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
EcalCondObjectContainer< EcalChannelStatusCode >::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: EcalCondObjectContainer.h:19
reco::Candidate::Point
math::XYZPoint Point
point in the space
Definition: Candidate.h:40
point
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
crabWrapper.key
key
Definition: crabWrapper.py:19
reco::Candidate::phi
virtual double phi() const =0
momentum azimuthal angle
EcalChannelStatus.h
AntiElectronDeadECAL::extrapolateToECalEntrance_
const bool extrapolateToECalEntrance_
Definition: AntiElectronDeadECAL.h:47
IdealGeometryRecord
Definition: IdealGeometryRecord.h:27
EcalChannelStatusRcd.h
AntiElectronDeadECAL::badTowers_
std::vector< TowerInfo > badTowers_
Definition: AntiElectronDeadECAL.h:64
AntiElectronDeadECAL::beginEvent
void beginEvent(const edm::EventSetup &)
Definition: AntiElectronDeadECAL.cc:27