CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalClusterSeverityLevelAlgo.cc
Go to the documentation of this file.
9 
11  const EcalRecHitCollection & recHits, const EcalSeverityLevelAlgo& sevlv)
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;
18  EcalRecHitCollection::const_iterator jrh = recHits.find( id );
19  if ( jrh == recHits.end() ) {
20  edm::LogError("EcalClusterSeverityLevelAlgo") << "The cluster DetId " << id.rawId() << " is not in the recHit collection!!";
21  return -1;
22  }
23 
24  uint32_t sev = sevlv.severityLevel( id, recHits);
25  // if ( sev == EcalSeverityLevelAlgo::kBad ) ++recoveryFailed;
28  {
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 
37  const EcalRecHitCollection & recHits, const CaloTopology* topology, const EcalSeverityLevelAlgo& sevlv )
38 {
39  DetId closestProb = closestProblematic(cluster , recHits, topology, sevlv);
40  // std::cout << "%%%%%%%%%%% Closest prob is " << EBDetId(closestProb) << std::endl;
41  if (closestProb.null())
42  return 0.;
43 
44  std::vector<DetId> neighbours = topology->getWindow(closestProb,3,3);
45  std::vector<DetId>::const_iterator itn;
46 
47  std::vector< std::pair<DetId, float> > hitsAndFracs = cluster.hitsAndFractions();
48  std::vector< std::pair<DetId, float> >::const_iterator it;
49 
50  float fraction = 0.;
51 
52  for ( itn = neighbours.begin(); itn != neighbours.end(); ++itn )
53  {
54  // std::cout << "Checking detId " << EBDetId((*itn)) << std::endl;
55  for ( it = hitsAndFracs.begin(); it != hitsAndFracs.end(); ++it )
56  {
57  DetId id = (*it).first;
58  if ( id != (*itn) )
59  continue;
60  // std::cout << "Is in cluster detId " << EBDetId(id) << std::endl;
61  EcalRecHitCollection::const_iterator jrh = recHits.find( id );
62  if ( jrh == recHits.end() )
63  {
64  edm::LogError("EcalClusterSeverityLevelAlgo") << "The cluster DetId " << id.rawId() << " is not in the recHit collection!!";
65  return -1;
66  }
67 
68  fraction += (*jrh).energy() * (*it).second / cluster.energy();
69  }
70  }
71  // std::cout << "%%%%%%%%%%% Fraction is " << fraction << std::endl;
72  return fraction;
73 }
74 
76  const EcalRecHitCollection & recHits,
77  const CaloTopology* topology , const EcalSeverityLevelAlgo& sevlv)
78 {
79  DetId seed=EcalClusterTools::getMaximum(cluster,&recHits).first;
80  if ( (seed.det() != DetId::Ecal) ||
81  (EcalSubdetector(seed.subdetId()) != EcalBarrel) )
82  {
83  //method not supported if not in Barrel
84  edm::LogError("EcalClusterSeverityLevelAlgo") << "The cluster seed is not in the BARREL";
85  return DetId(0);
86  }
87 
88  int minDist=9999; DetId closestProb(0);
89  //Get a window of DetId around the seed crystal
90  std::vector<DetId> neighbours = topology->getWindow(seed,51,11);
91 
92  for ( std::vector<DetId>::const_iterator it = neighbours.begin(); it != neighbours.end(); ++it )
93  {
94  EcalRecHitCollection::const_iterator jrh = recHits.find(*it);
95  if ( jrh == recHits.end() )
96  continue;
97  //Now checking rh flag
98  uint32_t sev = sevlv.severityLevel( *it, recHits);
99  if (sev == EcalSeverityLevel::kGood)
100  continue;
101  // std::cout << "[closestProblematic] Found a problematic channel " << EBDetId(*it) << " " << flag << std::endl;
102  //Find the closest DetId in eta,phi space (distance defined by deta^2 + dphi^2)
103  int deta=EBDetId::distanceEta(EBDetId(seed),EBDetId(*it));
104  int dphi=EBDetId::distancePhi(EBDetId(seed),EBDetId(*it));
105  double r = sqrt(deta*deta + dphi*dphi);
106  if (r < minDist){
107  closestProb = *it;
108  minDist = r;
109  }
110  }
111 
112  return closestProb;
113 }
114 
116  const EcalRecHitCollection & recHits,
117  const CaloTopology* topology, const EcalSeverityLevelAlgo& sevlv )
118 {
119  DetId seed=EcalClusterTools::getMaximum(cluster,&recHits).first;
120  if ( (seed.det() != DetId::Ecal) ||
121  (EcalSubdetector(seed.subdetId()) != EcalBarrel) )
122  {
123  edm::LogError("EcalClusterSeverityLevelAlgo") << "The cluster seed is not in the BARREL";
124  //method not supported if not in Barrel
125  return std::pair<int,int>(-1,-1);
126  }
127 
128  DetId closestProb = closestProblematic(cluster , recHits, topology, sevlv);
129 
130  if (! closestProb.null())
131  return std::pair<int,int>(EBDetId::distanceEta(EBDetId(seed),EBDetId(closestProb)),EBDetId::distancePhi(EBDetId(seed),EBDetId(closestProb)));
132  else
133  return std::pair<int,int>(-1,-1);
134 }
135 
136 
137 
138 
139 
140 
141 
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
static std::pair< int, int > etaphiDistanceClosestProblematic(const reco::CaloCluster &, const EcalRecHitCollection &, const CaloTopology *topology, const EcalSeverityLevelAlgo &)
CaloTopology const * topology(0)
std::vector< EcalRecHit >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:190
static int distanceEta(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:135
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:73
T sqrt(T t)
Definition: SSEVec.h:48
static int distancePhi(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:143
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:120
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
const_iterator end() const
Definition: DetId.h:18
static DetId closestProblematic(const reco::CaloCluster &, const EcalRecHitCollection &, const CaloTopology *topology, const EcalSeverityLevelAlgo &)
bool null() const
is this a null id ?
Definition: DetId.h:45
iterator find(key_type k)
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
EcalSubdetector