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) {
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 }
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
static std::pair< int, int > etaphiDistanceClosestProblematic(const reco::CaloCluster &, const EcalRecHitCollection &, const CaloTopology *topology, const EcalSeverityLevelAlgo &)
std::vector< EcalRecHit >::const_iterator const_iterator
Log< level::Error, false > LogError
double getMaximum(TObjArray *array)
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
static int distanceEta(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:118
T sqrt(T t)
Definition: SSEVec.h:23
static int distancePhi(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:125
static float goodFraction(const reco::CaloCluster &, const EcalRecHitCollection &, const EcalSeverityLevelAlgo &)
static float fractionAroundClosestProblematic(const reco::CaloCluster &, const EcalRecHitCollection &, const CaloTopology *topology, const EcalSeverityLevelAlgo &)
double energy() const
cluster energy
Definition: CaloCluster.h:149
Definition: DetId.h:17
static DetId closestProblematic(const reco::CaloCluster &, const EcalRecHitCollection &, const CaloTopology *topology, const EcalSeverityLevelAlgo &)
EcalSubdetector