CMS 3D CMS Logo

EcalClusterSeverityLevelAlgo.cc
Go to the documentation of this file.
9 
12  const EcalSeverityLevelAlgo& sevlv) {
13  float fraction = 0.;
14  std::vector<std::pair<DetId, float> > hitsAndFracs = cluster.hitsAndFractions();
15  std::vector<std::pair<DetId, float> >::const_iterator it;
16  for (it = hitsAndFracs.begin(); it != hitsAndFracs.end(); ++it) {
17  DetId id = (*it).first;
19  if (jrh == recHits.end()) {
20  edm::LogError("EcalClusterSeverityLevelAlgo")
21  << "The cluster DetId " << id.rawId() << " is not in the recHit collection!!";
22  return -1;
23  }
24 
25  uint32_t sev = sevlv.severityLevel(id, recHits);
26  // if ( sev == EcalSeverityLevelAlgo::kBad ) ++recoveryFailed;
28  sev == EcalSeverityLevel::kBad) {
29  // std::cout << "[goodFraction] Found a problematic channel " << EBDetId(id) << " " << flag << " energy: " << (*jrh).energy() << std::endl;
30  fraction += (*jrh).energy() * (*it).second / cluster.energy();
31  }
32  }
33  return 1. - fraction;
34 }
35 
38  const CaloTopology* topology,
39  const EcalSeverityLevelAlgo& sevlv) {
40  DetId closestProb = closestProblematic(cluster, recHits, topology, sevlv);
41  // std::cout << "%%%%%%%%%%% Closest prob is " << EBDetId(closestProb) << std::endl;
42  if (closestProb.null())
43  return 0.;
44 
45  std::vector<DetId> neighbours = topology->getWindow(closestProb, 3, 3);
46  std::vector<DetId>::const_iterator itn;
47 
48  std::vector<std::pair<DetId, float> > hitsAndFracs = cluster.hitsAndFractions();
49  std::vector<std::pair<DetId, float> >::const_iterator it;
50 
51  float fraction = 0.;
52 
53  for (itn = neighbours.begin(); itn != neighbours.end(); ++itn) {
54  // std::cout << "Checking detId " << EBDetId((*itn)) << std::endl;
55  for (it = hitsAndFracs.begin(); it != hitsAndFracs.end(); ++it) {
56  DetId id = (*it).first;
57  if (id != (*itn))
58  continue;
59  // std::cout << "Is in cluster detId " << EBDetId(id) << std::endl;
61  if (jrh == recHits.end()) {
62  edm::LogError("EcalClusterSeverityLevelAlgo")
63  << "The cluster DetId " << id.rawId() << " is not in the recHit collection!!";
64  return -1;
65  }
66 
67  fraction += (*jrh).energy() * (*it).second / cluster.energy();
68  }
69  }
70  // std::cout << "%%%%%%%%%%% Fraction is " << fraction << std::endl;
71  return fraction;
72 }
73 
76  const CaloTopology* topology,
77  const EcalSeverityLevelAlgo& sevlv) {
78  DetId seed = EcalClusterTools::getMaximum(cluster, &recHits).first;
79  if ((seed.det() != DetId::Ecal) || (EcalSubdetector(seed.subdetId()) != EcalBarrel)) {
80  //method not supported if not in Barrel
81  edm::LogError("EcalClusterSeverityLevelAlgo") << "The cluster seed is not in the BARREL";
82  return DetId(0);
83  }
84 
85  int minDist = 9999;
86  DetId closestProb(0);
87  //Get a window of DetId around the seed crystal
88  std::vector<DetId> neighbours = topology->getWindow(seed, 51, 11);
89 
90  for (std::vector<DetId>::const_iterator it = neighbours.begin(); it != neighbours.end(); ++it) {
92  if (jrh == recHits.end())
93  continue;
94  //Now checking rh flag
95  uint32_t sev = sevlv.severityLevel(*it, recHits);
96  if (sev == EcalSeverityLevel::kGood)
97  continue;
98  // std::cout << "[closestProblematic] Found a problematic channel " << EBDetId(*it) << " " << flag << std::endl;
99  //Find the closest DetId in eta,phi space (distance defined by deta^2 + dphi^2)
100  int deta = EBDetId::distanceEta(EBDetId(seed), EBDetId(*it));
101  int dphi = EBDetId::distancePhi(EBDetId(seed), EBDetId(*it));
102  double r = sqrt(deta * deta + dphi * dphi);
103  if (r < minDist) {
104  closestProb = *it;
105  minDist = r;
106  }
107  }
108 
109  return closestProb;
110 }
111 
114  const CaloTopology* topology,
115  const EcalSeverityLevelAlgo& sevlv) {
116  DetId seed = EcalClusterTools::getMaximum(cluster, &recHits).first;
117  if ((seed.det() != DetId::Ecal) || (EcalSubdetector(seed.subdetId()) != EcalBarrel)) {
118  edm::LogError("EcalClusterSeverityLevelAlgo") << "The cluster seed is not in the BARREL";
119  //method not supported if not in Barrel
120  return std::pair<int, int>(-1, -1);
121  }
122 
123  DetId closestProb = closestProblematic(cluster, recHits, topology, sevlv);
124 
125  if (!closestProb.null())
126  return std::pair<int, int>(EBDetId::distanceEta(EBDetId(seed), EBDetId(closestProb)),
127  EBDetId::distancePhi(EBDetId(seed), EBDetId(closestProb)));
128  else
129  return std::pair<int, int>(-1, -1);
130 }
EcalSeverityLevelAlgo
Definition: EcalSeverityLevelAlgo.h:33
EcalSeverityLevel::kGood
Definition: EcalSeverityLevel.h:19
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
EcalClusterSeverityLevelAlgo::fractionAroundClosestProblematic
static float fractionAroundClosestProblematic(const reco::CaloCluster &, const EcalRecHitCollection &, const CaloTopology *topology, const EcalSeverityLevelAlgo &)
Definition: EcalClusterSeverityLevelAlgo.cc:36
EcalClusterSeverityLevelAlgo.h
EcalSeverityLevelAlgo::severityLevel
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
Definition: EcalSeverityLevelAlgo.cc:85
EBDetId
Definition: EBDetId.h:17
CaloTopology::getWindow
std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
Get the neighbors of the given cell in a window of given size.
Definition: CaloTopology.cc:64
EBDetId.h
edm::SortedCollection< EcalRecHit >
DetId::null
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
EcalSubdetector
EcalSubdetector
Definition: EcalSubdetector.h:10
EcalClusterSeverityLevelAlgo::closestProblematic
static DetId closestProblematic(const reco::CaloCluster &, const EcalRecHitCollection &, const CaloTopology *topology, const EcalSeverityLevelAlgo &)
Definition: EcalClusterSeverityLevelAlgo.cc:74
EcalSeverityLevel::kProblematic
Definition: EcalSeverityLevel.h:20
CaloTopology
Definition: CaloTopology.h:19
EcalBarrel
Definition: EcalSubdetector.h:10
DetId
Definition: DetId.h:17
ecaldqm::topology
const CaloTopology * topology(nullptr)
Service.h
reco::CaloCluster
Definition: CaloCluster.h:31
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
EcalSeverityLevelAlgo.h
EcalSubdetector.h
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
edm::LogError
Definition: MessageLogger.h:183
reco::CaloCluster::hitsAndFractions
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
EBDetId::distanceEta
static int distanceEta(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:118
EcalClusterTools.h
DetId::Ecal
Definition: DetId.h:27
alignCSCRings.r
r
Definition: alignCSCRings.py:93
CaloTopology.h
EcalClusterSeverityLevelAlgo::etaphiDistanceClosestProblematic
static std::pair< int, int > etaphiDistanceClosestProblematic(const reco::CaloCluster &, const EcalRecHitCollection &, const CaloTopology *topology, const EcalSeverityLevelAlgo &)
Definition: EcalClusterSeverityLevelAlgo.cc:112
EcalSeverityLevel::kRecovered
Definition: EcalSeverityLevel.h:21
EcalSeverityLevel::kBad
Definition: EcalSeverityLevel.h:24
EBDetId::distancePhi
static int distancePhi(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:125
reco::CaloCluster::energy
double energy() const
cluster energy
Definition: CaloCluster.h:149
HLT_2018_cff.fraction
fraction
Definition: HLT_2018_cff.py:51317
EcalClusterSeverityLevelAlgo::goodFraction
static float goodFraction(const reco::CaloCluster &, const EcalRecHitCollection &, const EcalSeverityLevelAlgo &)
Definition: EcalClusterSeverityLevelAlgo.cc:10
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295