CMS 3D CMS Logo

List of all members | Static Public Member Functions
EcalClusterSeverityLevelAlgo Class Reference

#include <EcalClusterSeverityLevelAlgo.h>

Static Public Member Functions

static DetId closestProblematic (const reco::CaloCluster &, const EcalRecHitCollection &, const CaloTopology *topology, const EcalSeverityLevelAlgo &)
 
static std::pair< int, int > etaphiDistanceClosestProblematic (const reco::CaloCluster &, const EcalRecHitCollection &, const CaloTopology *topology, const EcalSeverityLevelAlgo &)
 
static float fractionAroundClosestProblematic (const reco::CaloCluster &, const EcalRecHitCollection &, const CaloTopology *topology, const EcalSeverityLevelAlgo &)
 
static float goodFraction (const reco::CaloCluster &, const EcalRecHitCollection &, const EcalSeverityLevelAlgo &)
 

Detailed Description

Definition at line 13 of file EcalClusterSeverityLevelAlgo.h.

Member Function Documentation

◆ closestProblematic()

DetId EcalClusterSeverityLevelAlgo::closestProblematic ( const reco::CaloCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
const EcalSeverityLevelAlgo sevlv 
)
static

Definition at line 74 of file EcalClusterSeverityLevelAlgo.cc.

References EBDetId::distanceEta(), EBDetId::distancePhi(), DetId::Ecal, EcalBarrel, SiStripPI::getMaximum(), CaloTopology::getWindow(), EcalSeverityLevel::kGood, alignCSCRings::r, FastTrackerRecHitMaskProducer_cfi::recHits, fileCollector::seed, EcalSeverityLevelAlgo::severityLevel(), and mathSSE::sqrt().

Referenced by etaphiDistanceClosestProblematic(), and fractionAroundClosestProblematic().

77  {
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 }
std::vector< EcalRecHit >::const_iterator const_iterator
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
Log< level::Error, false > LogError
double getMaximum(TObjArray *array)
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
static int distanceEta(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:118
T sqrt(T t)
Definition: SSEVec.h:19
static int distancePhi(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:125
Definition: DetId.h:17
EcalSubdetector

◆ etaphiDistanceClosestProblematic()

std::pair< int, int > EcalClusterSeverityLevelAlgo::etaphiDistanceClosestProblematic ( const reco::CaloCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
const EcalSeverityLevelAlgo sevlv 
)
static

Definition at line 112 of file EcalClusterSeverityLevelAlgo.cc.

References closestProblematic(), EBDetId::distanceEta(), EBDetId::distancePhi(), DetId::Ecal, EcalBarrel, SiStripPI::getMaximum(), DetId::null(), FastTrackerRecHitMaskProducer_cfi::recHits, and fileCollector::seed.

115  {
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 }
Log< level::Error, false > LogError
double getMaximum(TObjArray *array)
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
static int distancePhi(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:125
Definition: DetId.h:17
static DetId closestProblematic(const reco::CaloCluster &, const EcalRecHitCollection &, const CaloTopology *topology, const EcalSeverityLevelAlgo &)
EcalSubdetector

◆ fractionAroundClosestProblematic()

float EcalClusterSeverityLevelAlgo::fractionAroundClosestProblematic ( const reco::CaloCluster cluster,
const EcalRecHitCollection recHits,
const CaloTopology topology,
const EcalSeverityLevelAlgo sevlv 
)
static

Definition at line 36 of file EcalClusterSeverityLevelAlgo.cc.

References closestProblematic(), reco::CaloCluster::energy(), HLT_2022v12_cff::fraction, CaloTopology::getWindow(), reco::CaloCluster::hitsAndFractions(), DetId::null(), and FastTrackerRecHitMaskProducer_cfi::recHits.

39  {
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 }
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
std::vector< EcalRecHit >::const_iterator const_iterator
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
Log< level::Error, false > LogError
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
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 &)

◆ goodFraction()

float EcalClusterSeverityLevelAlgo::goodFraction ( const reco::CaloCluster cluster,
const EcalRecHitCollection recHits,
const EcalSeverityLevelAlgo sevlv 
)
static

Definition at line 10 of file EcalClusterSeverityLevelAlgo.cc.

References reco::CaloCluster::energy(), HLT_2022v12_cff::fraction, reco::CaloCluster::hitsAndFractions(), EcalSeverityLevel::kBad, EcalSeverityLevel::kProblematic, EcalSeverityLevel::kRecovered, FastTrackerRecHitMaskProducer_cfi::recHits, and EcalSeverityLevelAlgo::severityLevel().

12  {
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 }
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
std::vector< EcalRecHit >::const_iterator const_iterator
Log< level::Error, false > LogError
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
double energy() const
cluster energy
Definition: CaloCluster.h:149
Definition: DetId.h:17