CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
PreshowerClusterAlgo Class Reference

#include <PreshowerClusterAlgo.h>

Public Types

typedef std::set< DetIdHitsID
 
typedef math::XYZPoint Point
 
typedef std::map< DetId, EcalRecHitRecHitsMap
 

Public Member Functions

void findRoad (ESDetId strip, EcalPreshowerNavigator theESNav, int plane)
 
bool goodStrip (RecHitsMap::iterator candidate_it)
 
reco::PreshowerCluster makeOneCluster (ESDetId strip, HitsID *used_strips, RecHitsMap *rechits_map, const CaloSubdetectorGeometry *geometry_p, const CaloSubdetectorTopology *topology_p)
 
 PreshowerClusterAlgo ()
 
 PreshowerClusterAlgo (double stripEnergyCut, double clusterEnergyCut, int nStripCut)
 
 ~PreshowerClusterAlgo ()
 

Private Attributes

double preshClusterEnergyCut_
 
int preshSeededNstr_
 
double preshStripEnergyCut_
 
RecHitsMaprechits_map
 
std::vector< ESDetIdroad_2d
 
HitsIDused_s
 

Detailed Description

Definition at line 22 of file PreshowerClusterAlgo.h.

Member Typedef Documentation

◆ HitsID

Definition at line 27 of file PreshowerClusterAlgo.h.

◆ Point

Definition at line 24 of file PreshowerClusterAlgo.h.

◆ RecHitsMap

Definition at line 26 of file PreshowerClusterAlgo.h.

Constructor & Destructor Documentation

◆ PreshowerClusterAlgo() [1/2]

PreshowerClusterAlgo::PreshowerClusterAlgo ( )
inline

◆ PreshowerClusterAlgo() [2/2]

PreshowerClusterAlgo::PreshowerClusterAlgo ( double  stripEnergyCut,
double  clusterEnergyCut,
int  nStripCut 
)
inline

Definition at line 31 of file PreshowerClusterAlgo.h.

32  : preshStripEnergyCut_(stripEnergyCut), preshClusterEnergyCut_(clusterEnergyCut), preshSeededNstr_(nStripCut) {}

◆ ~PreshowerClusterAlgo()

PreshowerClusterAlgo::~PreshowerClusterAlgo ( )
inline

Definition at line 34 of file PreshowerClusterAlgo.h.

34 {};

Member Function Documentation

◆ findRoad()

void PreshowerClusterAlgo::findRoad ( ESDetId  strip,
EcalPreshowerNavigator  theESNav,
int  plane 
)

Definition at line 269 of file PreshowerClusterAlgo.cc.

References CaloNavigator< T, TOPO >::east(), CaloNavigator< T, TOPO >::home(), LogTrace, GetRecoTauVFromDQM_MC_cff::next, CaloNavigator< T, TOPO >::north(), preshSeededNstr_, road_2d, CaloNavigator< T, TOPO >::setHome(), CaloNavigator< T, TOPO >::south(), nano_mu_digi_cff::strip, and CaloNavigator< T, TOPO >::west().

Referenced by makeOneCluster().

269  {
270  if (strip == ESDetId(0))
271  return;
272 
273  ESDetId next;
274  theESNav.setHome(strip);
275  // First, add a central strip to the road
276  road_2d.push_back(strip);
277  LogTrace("PreShowerClusterAlgo") << "findRoad starts from strip" << strip;
278 
279  if (plane == 1) {
280  // east road
281  int n_east = 0;
282  LogTrace("PreShowerClusterAlgo") << " Go to the East ";
283 
284  while (((next = theESNav.east()) != ESDetId(0) && next != strip)) {
285  LogTrace("PreShowerClusterAlgo") << "East:" << n_east << "current strip is" << next;
286 
287  road_2d.push_back(next);
288  ++n_east;
289  if (n_east == preshSeededNstr_)
290  break;
291  }
292  // west road
293  int n_west = 0;
294  LogTrace("PreShowerClusterAlgo") << "Go to the West";
295 
296  theESNav.home();
297  while (((next = theESNav.west()) != ESDetId(0) && next != strip)) {
298  LogTrace("PreShowerClusterAlgo") << "West: " << n_west << "current strip is" << next;
299 
300  road_2d.push_back(next);
301  ++n_west;
302  if (n_west == preshSeededNstr_)
303  break;
304  }
305  LogTrace("PreShowerClusterAlgo") << "Total number of strips found in the road at 1-st plane is" << n_east + n_west;
306 
307  } else if (plane == 2) {
308  // north road
309  int n_north = 0;
310  LogTrace("PreShowerClusterAlgo") << "Go to the North";
311 
312  while (((next = theESNav.north()) != ESDetId(0) && next != strip)) {
313  LogTrace("PreShowerClusterAlgo") << "North:" << n_north << "current strip is" << next;
314 
315  road_2d.push_back(next);
316  ++n_north;
317  if (n_north == preshSeededNstr_)
318  break;
319  }
320  // south road
321  int n_south = 0;
322  LogTrace("PreShowerClusterAlgo") << "Go to the South";
323 
324  theESNav.home();
325  while (((next = theESNav.south()) != ESDetId(0) && next != strip)) {
326  LogTrace("PreShowerClusterAlgo") << "South:" << n_south << "current strip is" << next;
327 
328  road_2d.push_back(next);
329  ++n_south;
330  if (n_south == preshSeededNstr_)
331  break;
332  }
333 
334  LogTrace("PreShowerClusterAlgo") << "Total number of strips found in the road at 2-nd plane is"
335  << n_south + n_north;
336 
337  } else {
338  LogTrace("PreShowerClusterAlgo") << " Wrong plane number, null cluster will be returned!";
339 
340  } // end of if
341 
342  theESNav.home();
343 }
void home() const
move the navigator back to the starting point
Definition: CaloNavigator.h:96
T north() const
move the navigator north
Definition: CaloNavigator.h:30
T south() const
move the navigator south
Definition: CaloNavigator.h:36
#define LogTrace(id)
void setHome(const T &startingPoint)
set the starting position
Definition: CaloNavigator.h:90
std::vector< ESDetId > road_2d
T east() const
move the navigator east
Definition: CaloNavigator.h:42
T west() const
move the navigator west
Definition: CaloNavigator.h:48

◆ goodStrip()

bool PreshowerClusterAlgo::goodStrip ( RecHitsMap::iterator  candidate_it)

Definition at line 250 of file PreshowerClusterAlgo.cc.

References LogTrace, preshStripEnergyCut_, rechits_map, and used_s.

Referenced by makeOneCluster().

250  {
251  if (used_s->find(candidate_it->first) != used_s->end())
252  LogTrace("PreShowerClusterAlgo") << " This strip is in use";
253  if (candidate_it == rechits_map->end())
254  LogTrace("PreShowerClusterAlgo") << " No such a strip in rechits_map";
255  if (candidate_it->second.energy() <= preshStripEnergyCut_)
256  LogTrace("PreShowerClusterAlgo") << "Strip energy" << candidate_it->second.energy() << "is below threshold";
257 
258  // crystal should not be included...
259  if ((used_s->find(candidate_it->first) != used_s->end()) || // ...if it already belongs to a cluster
260  (candidate_it == rechits_map->end()) || // ...if it corresponds to a hit
261  (candidate_it->second.energy() <= preshStripEnergyCut_)) // ...if it has a negative or zero energy
262  {
263  return false;
264  }
265  return true;
266 }
#define LogTrace(id)

◆ makeOneCluster()

reco::PreshowerCluster PreshowerClusterAlgo::makeOneCluster ( ESDetId  strip,
HitsID used_strips,
RecHitsMap rechits_map,
const CaloSubdetectorGeometry geometry_p,
const CaloSubdetectorTopology topology_p 
)

Definition at line 13 of file PreshowerClusterAlgo.cc.

References edm::SortedCollection< T, SORT >::begin(), CommonMethods::cp(), edm::SortedCollection< T, SORT >::end(), reco::CaloCluster::energy(), reco::CaloCluster::eta(), findRoad(), newFWLiteAna::found, CaloSubdetectorGeometry::getGeometry(), goodStrip(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, LogTrace, HLT_2024v14_cff::navigator, GetRecoTauVFromDQM_MC_cff::next, reco::PreshowerCluster::nhits(), reco::CaloCluster::phi(), reco::CaloCluster::position(), position, preshClusterEnergyCut_, edm::SortedCollection< T, SORT >::push_back(), rechits_map, road_2d, edm::SortedCollection< T, SORT >::size(), nano_mu_digi_cff::strip, used_s, reco::CaloCluster::x(), reco::CaloCluster::y(), and reco::CaloCluster::z().

Referenced by HLTRegionalEcalResonanceFilter::makeClusterES().

17  {
18  road_2d.clear();
19 
20  rechits_map = the_rechitsMap_p;
21 
22  used_s = used_strips;
23 
24  int plane = strip.plane();
25 
26  LogTrace("PreShowerClusterAlgo") << "Preshower Seeded Algorithm - looking for clusters";
27  LogTrace("PreShowerClusterAlgo") << "Preshower is intersected at strip" << strip.strip() << ",at plane" << plane;
28 
29  // create null-cluster
30  std::vector<std::pair<DetId, float> > dummy;
31  Point posi(0, 0, 0);
32  LogTrace("PreShowerClusterAlgo") << " Creating a null-cluster";
33 
34  reco::PreshowerCluster nullcluster = reco::PreshowerCluster(0., posi, dummy, plane);
35 
36  if (strip == ESDetId(0))
37  return nullcluster; //works in case of no intersected strip found (e.g. in the Barrel)
38 
39  // Collection of cluster strips
40  EcalRecHitCollection clusterRecHits;
41  // Map of strips for position calculation
42  RecHitsMap recHits_pos;
43 
44  //Make a navigator, and set it to the strip cell.
46  navigator.setHome(strip);
47  //search for neighbours in the central road
48  findRoad(strip, navigator, plane);
49  LogTrace("PreShowerClusterAlgo") << "Total number of strips in the central road:" << road_2d.size();
50 
51  if (plane == 1) {
52  ESDetId strip_north = navigator.north();
53  findRoad(strip_north, navigator, plane);
54  navigator.home();
55  ESDetId strip_south = navigator.south();
56  findRoad(strip_south, navigator, plane);
57  navigator.home();
58  }
59  if (plane == 2) {
60  ESDetId strip_east = navigator.east();
61  findRoad(strip_east, navigator, plane);
62  navigator.home();
63  ESDetId strip_west = navigator.west();
64  findRoad(strip_west, navigator, plane);
65  navigator.home();
66  }
67  LogTrace("PreShowerClusterAlgo") << "Total number of strips in all three roads:" << road_2d.size();
68 
69  // Start clustering from strip with max Energy in the road
70  float E_max = 0.;
71  bool found = false;
72  RecHitsMap::iterator max_it;
73  // Loop over strips:
74  std::vector<ESDetId>::iterator itID;
75  for (itID = road_2d.begin(); itID != road_2d.end(); itID++) {
76  LogTrace("PreShowerClusterAlgo") << "ID =" << *itID;
77 
78  RecHitsMap::iterator strip_it = rechits_map->find(*itID);
79  //if ( strip_it->second.energy() < 0 ) std::cout << " ##### E = " << strip_it->second.energy() << std::endl;
80  if (strip_it == rechits_map->end() || !goodStrip(strip_it))
81  continue;
82  LogTrace("PreShowerClusterAlgo") << " strip is " << ESDetId(strip_it->first) << "E =" << strip_it->second.energy();
83 
84  float E = strip_it->second.energy();
85  if (E > E_max) {
86  E_max = E;
87  found = true;
88  max_it = strip_it;
89  }
90  }
91  // no hottest strip found ==> null cluster will be returned
92  if (!found)
93  return nullcluster;
94 
95  // First, save the hottest strip
96  clusterRecHits.push_back(max_it->second);
97  recHits_pos.insert(std::make_pair(max_it->first, max_it->second));
98  used_s->insert(max_it->first);
99  LogTrace("PreShowerClusterAlgo") << "Central hottest strip" << ESDetId(max_it->first)
100  << "is saved with energy E =" << E_max;
101 
102  // Find positions of adjacent strips:
103  ESDetId next, strip_1, strip_2;
104  navigator.setHome(max_it->first);
105  ESDetId startES = max_it->first;
106 
107  if (plane == 1) {
108  // Save two neighbouring strips to the east
109  int nadjacents_east = 0;
110  while ((next = navigator.east()) != ESDetId(0) && next != startES && nadjacents_east < 2) {
111  ++nadjacents_east;
112  LogTrace("PreShowerClusterAlgo") << "Adjacent east #" << nadjacents_east << ":" << next;
113 
114  RecHitsMap::iterator strip_it = rechits_map->find(next);
115 
116  if (strip_it == rechits_map->end() || !goodStrip(strip_it))
117  continue;
118  // Save strip for clustering if it exists, not already in use, and satisfies an energy threshold
119  clusterRecHits.push_back(strip_it->second);
120  // save strip for position calculation
121  if (nadjacents_east == 1)
122  strip_1 = next;
123  used_s->insert(strip_it->first);
124  LogTrace("PreShowerClusterAlgo") << "East adjacent strip #" << nadjacents_east
125  << "is saved with energy E =" << strip_it->second.energy();
126  }
127  // Save two neighbouring strips to the west
128  navigator.home();
129  int nadjacents_west = 0;
130  while ((next = navigator.west()) != ESDetId(0) && next != startES && nadjacents_west < 2) {
131  ++nadjacents_west;
132  LogTrace("PreShowerClusterAlgo") << "Adjacent west #" << nadjacents_west << ":" << next;
133 
134  RecHitsMap::iterator strip_it = rechits_map->find(next);
135  if (strip_it == rechits_map->end() || !goodStrip(strip_it))
136  continue;
137  clusterRecHits.push_back(strip_it->second);
138  if (nadjacents_west == 1)
139  strip_2 = next;
140  used_s->insert(strip_it->first);
141  LogTrace("PreShowerClusterAlgo") << "West adjacent strip #" << nadjacents_west
142  << "is saved with energy E =" << strip_it->second.energy();
143  }
144  } else if (plane == 2) {
145  // Save two neighbouring strips to the north
146  int nadjacents_north = 0;
147  while ((next = navigator.north()) != ESDetId(0) && next != startES && nadjacents_north < 2) {
148  ++nadjacents_north;
149  LogTrace("PreShowerClusterAlgo") << "Adjacent north #" << nadjacents_north << ":" << next;
150 
151  RecHitsMap::iterator strip_it = rechits_map->find(next);
152  if (strip_it == rechits_map->end() || !goodStrip(strip_it))
153  continue;
154  clusterRecHits.push_back(strip_it->second);
155  if (nadjacents_north == 1)
156  strip_1 = next;
157  used_s->insert(strip_it->first);
158  LogTrace("PreShowerClusterAlgo") << "North adjacent strip #" << nadjacents_north
159  << "is saved with energy E =" << strip_it->second.energy();
160  }
161  // Save two neighbouring strips to the south
162  navigator.home();
163  int nadjacents_south = 0;
164  while ((next = navigator.south()) != ESDetId(0) && next != startES && nadjacents_south < 2) {
165  ++nadjacents_south;
166  LogTrace("PreShowerClusterAlgo") << "Adjacent south #" << nadjacents_south << ":" << next;
167 
168  RecHitsMap::iterator strip_it = rechits_map->find(next);
169  if (strip_it == rechits_map->end() || !goodStrip(strip_it))
170  continue;
171  clusterRecHits.push_back(strip_it->second);
172  if (nadjacents_south == 1)
173  strip_2 = next;
174  used_s->insert(strip_it->first);
175  LogTrace("PreShowerClusterAlgo") << "South adjacent strip #" << nadjacents_south
176  << "is saved with energy E =" << strip_it->second.energy();
177  }
178  } else {
179  LogTrace("PreShowerClusterAlgo") << " Wrong plane number" << plane << ", null cluster will be returned! "
180  << std::endl;
181  return nullcluster;
182  } // end of if
183 
184  LogTrace("PreShowerClusterAlgo") << "Total size of clusterRecHits is" << clusterRecHits.size();
185  LogTrace("PreShowerClusterAlgo") << "Two adjacent strips for position calculation are:" << strip_1 << "and"
186  << strip_2;
187 
188  // strips for position calculation
189  RecHitsMap::iterator strip_it1, strip_it2;
190  if (strip_1 != ESDetId(0)) {
191  strip_it1 = rechits_map->find(strip_1);
192  recHits_pos.insert(std::make_pair(strip_it1->first, strip_it1->second));
193  }
194  if (strip_2 != ESDetId(0)) {
195  strip_it2 = rechits_map->find(strip_2);
196  recHits_pos.insert(std::make_pair(strip_it2->first, strip_it2->second));
197  }
198 
199  RecHitsMap::iterator cp;
200  double energy_pos = 0;
201  double x_pos = 0;
202  double y_pos = 0;
203  double z_pos = 0;
204  for (cp = recHits_pos.begin(); cp != recHits_pos.end(); cp++) {
205  double E = cp->second.energy();
206  energy_pos += E;
207  auto thisCell = geometry_p->getGeometry(cp->first);
208  const GlobalPoint& position = thisCell->getPosition();
209  x_pos += E * position.x();
210  y_pos += E * position.y();
211  z_pos += E * position.z();
212  }
213  if (energy_pos > 0.) {
214  x_pos /= energy_pos;
215  y_pos /= energy_pos;
216  z_pos /= energy_pos;
217  }
218  Point pos(x_pos, y_pos, z_pos);
219  LogTrace("PreShowerClusterAlgo") << "ES Cluster position ="
220  << "(" << x_pos << "," << y_pos << "," << z_pos << ")";
221 
223  double Eclust = 0;
224 
225  std::vector<std::pair<DetId, float> > usedHits;
226  for (it = clusterRecHits.begin(); it != clusterRecHits.end(); it++) {
227  Eclust += it->energy();
228  usedHits.push_back(std::pair<DetId, float>(it->id(), 1.));
229  }
230 
231  // ES cluster is created from vector clusterRecHits
232  reco::PreshowerCluster cluster = reco::PreshowerCluster(Eclust, pos, usedHits, plane);
233  LogTrace("PreShowerClusterAlgo") << " ES Cluster is created with:";
234  LogTrace("PreShowerClusterAlgo") << " energy =" << cluster.energy();
235  LogTrace("PreShowerClusterAlgo") << " (eta,phi) ="
236  << "(" << cluster.eta() << "," << cluster.phi() << ")";
237  LogTrace("PreShowerClusterAlgo") << " nhits =" << cluster.nhits();
238  LogTrace("PreShowerClusterAlgo") << " radius =" << cluster.position().r();
239  LogTrace("PreShowerClusterAlgo") << " (x,y,z) ="
240  << "(" << cluster.x() << ", " << cluster.y() << "," << cluster.z() << ")";
241 
242  // return the cluster if its energy is greater a threshold
243  if (cluster.energy() > preshClusterEnergyCut_)
244  return cluster;
245  else
246  return nullcluster;
247 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
void findRoad(ESDetId strip, EcalPreshowerNavigator theESNav, int plane)
size_type size() const
void push_back(T const &t)
double x() const
x coordinate of cluster centroid
Definition: CaloCluster.h:172
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:184
#define LogTrace(id)
int nhits() const
Number of RecHits the cluster.
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:178
double y() const
y coordinate of cluster centroid
Definition: CaloCluster.h:175
bool goodStrip(RecHitsMap::iterator candidate_it)
const_iterator begin() const
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::vector< ESDetId > road_2d
std::vector< EcalRecHit >::iterator iterator
const_iterator end() const
double energy() const
cluster energy
Definition: CaloCluster.h:149
std::map< DetId, EcalRecHit > RecHitsMap
Structure Point Contains parameters of Gaussian fits to DMRs.
static int position[264][3]
Definition: ReadPGInfo.cc:289
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181
def cp(fromDir, toDir, listOfFiles, overwrite=False, smallList=False)

Member Data Documentation

◆ preshClusterEnergyCut_

double PreshowerClusterAlgo::preshClusterEnergyCut_
private

Definition at line 48 of file PreshowerClusterAlgo.h.

Referenced by makeOneCluster().

◆ preshSeededNstr_

int PreshowerClusterAlgo::preshSeededNstr_
private

Definition at line 49 of file PreshowerClusterAlgo.h.

Referenced by findRoad().

◆ preshStripEnergyCut_

double PreshowerClusterAlgo::preshStripEnergyCut_
private

Definition at line 47 of file PreshowerClusterAlgo.h.

Referenced by goodStrip().

◆ rechits_map

RecHitsMap* PreshowerClusterAlgo::rechits_map
private

Definition at line 54 of file PreshowerClusterAlgo.h.

Referenced by goodStrip(), and makeOneCluster().

◆ road_2d

std::vector<ESDetId> PreshowerClusterAlgo::road_2d
private

Definition at line 51 of file PreshowerClusterAlgo.h.

Referenced by findRoad(), and makeOneCluster().

◆ used_s

HitsID* PreshowerClusterAlgo::used_s
private

Definition at line 57 of file PreshowerClusterAlgo.h.

Referenced by goodStrip(), and makeOneCluster().