CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
IslandClusterAlgo Class Reference

#include <IslandClusterAlgo.h>

Public Types

enum  EcalPart { barrel = 0, endcap = 1 }
 
typedef math::XYZPoint Point
 point in the space More...
 
enum  VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 }
 

Public Member Functions

 IslandClusterAlgo ()
 
 IslandClusterAlgo (double ebst, double ecst, const PositionCalc &posCalc, VerbosityLevel the_verbosity=pERROR)
 
std::vector< reco::BasicClustermakeClusters (const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p, EcalPart ecalPart, bool regional=false, const std::vector< EcalEtaPhiRegion > &regions=std::vector< EcalEtaPhiRegion >())
 
void setVerbosity (VerbosityLevel the_verbosity)
 
virtual ~IslandClusterAlgo ()
 

Private Member Functions

void mainSearch (const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry_p, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p, EcalPart ecalPart)
 
void makeCluster (const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry_p, const CaloSubdetectorGeometry *geometryES_p)
 
void searchEast (const CaloNavigator< DetId > &navigator, const CaloSubdetectorTopology *topology)
 
void searchNorth (const CaloNavigator< DetId > &navigator)
 
void searchSouth (const CaloNavigator< DetId > &navigator)
 
void searchWest (const CaloNavigator< DetId > &navigator, const CaloSubdetectorTopology *topology)
 
bool shouldBeAdded (EcalRecHitCollection::const_iterator candidate_it, EcalRecHitCollection::const_iterator previous_it)
 

Private Attributes

std::vector< reco::BasicClusterclusters_v
 
std::vector< std::pair< DetId,
float > > 
current_v
 
double ecalBarrelSeedThreshold
 
double ecalEndcapSeedThreshold
 
PositionCalc posCalculator_
 
const EcalRecHitCollectionrecHits_
 
std::vector< EcalRecHitseeds
 
std::set< DetIdused_s
 
VerbosityLevel verbosity
 

Detailed Description

Definition at line 27 of file IslandClusterAlgo.h.

Member Typedef Documentation

point in the space

Definition at line 61 of file IslandClusterAlgo.h.

Member Enumeration Documentation

Enumerator
barrel 
endcap 

Definition at line 31 of file IslandClusterAlgo.h.

Enumerator
pDEBUG 
pWARNING 
pINFO 
pERROR 

Definition at line 32 of file IslandClusterAlgo.h.

Constructor & Destructor Documentation

IslandClusterAlgo::IslandClusterAlgo ( )
inline

Definition at line 34 of file IslandClusterAlgo.h.

34  {
35  }
IslandClusterAlgo::IslandClusterAlgo ( double  ebst,
double  ecst,
const PositionCalc posCalc,
VerbosityLevel  the_verbosity = pERROR 
)
inline

Definition at line 37 of file IslandClusterAlgo.h.

References posCalculator_.

37  :
38  ecalBarrelSeedThreshold(ebst), ecalEndcapSeedThreshold(ecst), verbosity(the_verbosity) {
39  posCalculator_ = posCalc;
40  }
PositionCalc posCalculator_
VerbosityLevel verbosity
virtual IslandClusterAlgo::~IslandClusterAlgo ( )
inlinevirtual

Definition at line 42 of file IslandClusterAlgo.h.

43  {
44  }

Member Function Documentation

void IslandClusterAlgo::mainSearch ( const EcalRecHitCollection hits,
const CaloSubdetectorGeometry geometry_p,
const CaloSubdetectorTopology topology_p,
const CaloSubdetectorGeometry geometryES_p,
EcalPart  ecalPart 
)
private

Definition at line 106 of file IslandClusterAlgo.cc.

References gather_cfg::cout, current_v, makeCluster(), HLT_FULL_cff::navigator, pINFO, searchEast(), searchNorth(), searchSouth(), searchWest(), seeds, used_s, and verbosity.

Referenced by makeClusters().

111 {
112  if (verbosity < pINFO)
113  {
114  std::cout << "Building clusters............" << std::endl;
115  }
116 
117  // Loop over seeds:
118  std::vector<EcalRecHit>::iterator it;
119  for (it = seeds.begin(); it != seeds.end(); it++)
120  {
121  // make sure the current seed does not belong to a cluster already.
122  if (used_s.find(it->id()) != used_s.end())
123  {
124  if (it == seeds.begin())
125  {
126  if (verbosity < pINFO)
127  {
128  std::cout << "##############################################################" << std::endl;
129  std::cout << "DEBUG ALERT: Highest energy seed already belongs to a cluster!" << std::endl;
130  std::cout << "##############################################################" << std::endl;
131  }
132  }
133  continue;
134  }
135 
136  // clear the vector of hits in current cluster
137  current_v.clear();
138 
139  current_v.push_back( std::pair<DetId, float>(it->id(), 1.) ); // by default hit energy fractions are set at 1.
140  used_s.insert(it->id());
141 
142  // Create a navigator at the seed
143  CaloNavigator<DetId> navigator(it->id(), topology_p);
144 
146  navigator.home();
148  navigator.home();
149  searchWest(navigator, topology_p);
150  navigator.home();
151  searchEast(navigator, topology_p);
152 
153  makeCluster(hits,geometry_p,geometryES_p);
154  }
155 }
void searchEast(const CaloNavigator< DetId > &navigator, const CaloSubdetectorTopology *topology)
void searchWest(const CaloNavigator< DetId > &navigator, const CaloSubdetectorTopology *topology)
std::set< DetId > used_s
VerbosityLevel verbosity
std::vector< EcalRecHit > seeds
void searchNorth(const CaloNavigator< DetId > &navigator)
void makeCluster(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry_p, const CaloSubdetectorGeometry *geometryES_p)
std::vector< std::pair< DetId, float > > current_v
tuple cout
Definition: gather_cfg.py:145
void searchSouth(const CaloNavigator< DetId > &navigator)
void IslandClusterAlgo::makeCluster ( const EcalRecHitCollection hits,
const CaloSubdetectorGeometry geometry_p,
const CaloSubdetectorGeometry geometryES_p 
)
private

Definition at line 266 of file IslandClusterAlgo.cc.

References PositionCalc::Calculate_Location(), clusters_v, gather_cfg::cout, current_v, reco::CaloID::DET_ECAL_BARREL, reco::CaloID::DET_ECAL_ENDCAP, EcalBarrel, relval_parameters_module::energy, EcalRecHit::energy(), edm::SortedCollection< T, SORT >::find(), reco::CaloCluster::island, pINFO, posCalculator_, position, and verbosity.

Referenced by mainSearch().

269 {
270  double energy = 0;
271  reco::CaloID caloID;
272 
273  Point position;
274  position = posCalculator_.Calculate_Location(current_v,hits,geometry,geometryES);
275 
276  std::vector< std::pair<DetId, float> >::iterator it;
277  for (it = current_v.begin(); it != current_v.end(); it++)
278  {
279  EcalRecHitCollection::const_iterator itt = hits->find( (*it).first );
280  EcalRecHit hit_p = *itt;
281  if ( (*it).first.subdetId() == EcalBarrel ) {
283  } else {
285  }
286  // if (hit_p != 0)
287  // {
288  energy += hit_p.energy();
289  // }
290  // else
291  // {
292  // std::cout << "DEBUG ALERT: Requested rechit has gone missing from rechits map! :-S" << std::endl;
293  // }
294  }
295 
296  if (verbosity < pINFO)
297  {
298  std::cout << "******** NEW CLUSTER ********" << std::endl;
299  std::cout << "No. of crystals = " << current_v.size() << std::endl;
300  std::cout << " Energy = " << energy << std::endl;
301  std::cout << " Phi = " << position.phi() << std::endl;
302  std::cout << " Eta = " << position.eta() << std::endl;
303  std::cout << "*****************************" << std::endl;
304  }
305  clusters_v.push_back(reco::BasicCluster(energy, position, caloID, current_v, reco::CaloCluster::island));
306 }
std::vector< EcalRecHit >::const_iterator const_iterator
PositionCalc posCalculator_
math::XYZPoint Point
VerbosityLevel verbosity
float energy() const
Definition: EcalRecHit.h:68
std::vector< reco::BasicCluster > clusters_v
ESHandle< TrackerGeometry > geometry
iterator find(key_type k)
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
Definition: PositionCalc.h:68
static int position[264][3]
Definition: ReadPGInfo.cc:509
std::vector< std::pair< DetId, float > > current_v
tuple cout
Definition: gather_cfg.py:145
std::vector< reco::BasicCluster > IslandClusterAlgo::makeClusters ( const EcalRecHitCollection hits,
const CaloSubdetectorGeometry geometry,
const CaloSubdetectorTopology topology_p,
const CaloSubdetectorGeometry geometryES_p,
EcalPart  ecalPart,
bool  regional = false,
const std::vector< EcalEtaPhiRegion > &  regions = std::vector<EcalEtaPhiRegion>() 
)

Definition at line 17 of file IslandClusterAlgo.cc.

References barrel, edm::SortedCollection< T, SORT >::begin(), clusters_v, gather_cfg::cout, ecalBarrelSeedThreshold, ecalEndcapSeedThreshold, edm::SortedCollection< T, SORT >::end(), endcap, relval_parameters_module::energy, ET, CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), mainSearch(), pINFO, position, recHits_, HLT_FULL_cff::region, seeds, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, PV3DBase< T, PVType, FrameType >::theta(), dtDQMClient_cfg::threshold, used_s, and verbosity.

Referenced by IslandClusterProducer::clusterizeECALPart(), EgammaHLTIslandClusterProducer::clusterizeECALPart(), and Pi0FixedMassWindowCalibration::duringLoop().

25 {
26  seeds.clear();
27  used_s.clear();
28  clusters_v.clear();
29 
30  recHits_ = hits;
31 
32  double threshold = 0;
33  std::string ecalPart_string;
34  if (ecalPart == endcap)
35  {
36  threshold = ecalEndcapSeedThreshold;
37  ecalPart_string = "EndCap";
38  }
39  if (ecalPart == barrel)
40  {
41  threshold = ecalBarrelSeedThreshold;
42  ecalPart_string = "Barrel";
43  }
44 
45  if (verbosity < pINFO)
46  {
47  std::cout << "-------------------------------------------------------------" << std::endl;
48  std::cout << "Island algorithm invoked for ECAL" << ecalPart_string << std::endl;
49  std::cout << "Looking for seeds, energy threshold used = " << threshold << " GeV" <<std::endl;
50  }
51 
52  int nregions=0;
53  if(regional) nregions=regions.size();
54 
55  if(!regional || nregions) {
56 
58  for(it = hits->begin(); it != hits->end(); it++)
59  {
60  double energy = it->energy();
61  if (energy < threshold) continue; // need to check to see if this line is useful!
62 
63  const CaloCellGeometry *thisCell = geometry_p->getGeometry(it->id());
64  GlobalPoint position = thisCell->getPosition();
65 
66  // Require that RecHit is within clustering region in case
67  // of regional reconstruction
68  bool withinRegion = false;
69  if (regional) {
70  std::vector<EcalEtaPhiRegion>::const_iterator region;
71  for (region=regions.begin(); region!=regions.end(); region++) {
72  if (region->inRegion(position)) {
73  withinRegion = true;
74  break;
75  }
76  }
77  }
78 
79  if (!regional || withinRegion) {
80  float ET = it->energy() * sin(position.theta());
81  if (ET > threshold) seeds.push_back(*it);
82  }
83  }
84 
85  }
86 
87  sort(seeds.begin(), seeds.end(), EcalRecHitLess());
88 
89  if (verbosity < pINFO)
90  {
91  std::cout << "Total number of seeds found in event = " << seeds.size() << std::endl;
92  }
93 
94  mainSearch(hits,geometry_p,topology_p,geometryES_p,ecalPart);
95  sort(clusters_v.rbegin(), clusters_v.rend(), ClusterEtLess());
96 
97  if (verbosity < pINFO)
98  {
99  std::cout << "---------- end of main search. clusters have been sorted ----" << std::endl;
100  }
101 
102  return clusters_v;
103 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< EcalRecHit >::const_iterator const_iterator
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
std::set< DetId > used_s
VerbosityLevel verbosity
std::vector< EcalRecHit > seeds
const_iterator end() const
std::vector< reco::BasicCluster > clusters_v
static int position[264][3]
Definition: ReadPGInfo.cc:509
tuple cout
Definition: gather_cfg.py:145
#define ET
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
const EcalRecHitCollection * recHits_
const_iterator begin() const
void mainSearch(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry_p, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p, EcalPart ecalPart)
void IslandClusterAlgo::searchEast ( const CaloNavigator< DetId > &  navigator,
const CaloSubdetectorTopology topology 
)
private

Definition at line 226 of file IslandClusterAlgo.cc.

References current_v, CaloNavigator< T, TOPO >::east(), edm::SortedCollection< T, SORT >::find(), CaloNavigator< T, TOPO >::home(), CaloNavigator< T, TOPO >::pos(), recHits_, searchNorth(), searchSouth(), shouldBeAdded(), and used_s.

Referenced by mainSearch().

227 {
228  DetId western = navigator.pos();
229  EcalRecHitCollection::const_iterator western_it = recHits_->find(western);
230 
231  DetId eastern = navigator.east();
232  if (eastern == DetId(0)) return; // This means that we went off the ECAL!
233  EcalRecHitCollection::const_iterator eastern_it = recHits_->find(eastern);
234 
235  if (shouldBeAdded(eastern_it, western_it))
236  {
237  CaloNavigator<DetId> nsNavigator(eastern, topology);
238 
239  searchNorth(nsNavigator);
240  nsNavigator.home();
241  searchSouth(nsNavigator);
242  nsNavigator.home();
243  searchEast(navigator, topology);
244 
245  current_v.push_back( std::pair<DetId, float>(eastern, 1.)); // by default hit energy fractions are set at 1.
246  used_s.insert(eastern);
247  }
248 }
void searchEast(const CaloNavigator< DetId > &navigator, const CaloSubdetectorTopology *topology)
std::vector< EcalRecHit >::const_iterator const_iterator
std::set< DetId > used_s
T pos() const
get the current position
Definition: CaloNavigator.h:32
T east() const
move the navigator east
Definition: CaloNavigator.h:52
Definition: DetId.h:18
void searchNorth(const CaloNavigator< DetId > &navigator)
bool shouldBeAdded(EcalRecHitCollection::const_iterator candidate_it, EcalRecHitCollection::const_iterator previous_it)
iterator find(key_type k)
std::vector< std::pair< DetId, float > > current_v
const EcalRecHitCollection * recHits_
void searchSouth(const CaloNavigator< DetId > &navigator)
void IslandClusterAlgo::searchNorth ( const CaloNavigator< DetId > &  navigator)
private

Definition at line 158 of file IslandClusterAlgo.cc.

References current_v, edm::SortedCollection< T, SORT >::find(), CaloNavigator< T, TOPO >::north(), CaloNavigator< T, TOPO >::pos(), recHits_, shouldBeAdded(), and used_s.

Referenced by mainSearch(), searchEast(), and searchWest().

159 {
160  DetId southern = navigator.pos();
161 
162  DetId northern = navigator.north();
163  if (northern == DetId(0)) return; // This means that we went off the ECAL!
164  // if the crystal to the north belongs to another cluster return
165  if (used_s.find(northern) != used_s.end()) return;
166 
167 
168  EcalRecHitCollection::const_iterator southern_it = recHits_->find(southern);
169  EcalRecHitCollection::const_iterator northern_it = recHits_->find(northern);
170 
171  if (shouldBeAdded(northern_it, southern_it))
172  {
173  current_v.push_back( std::pair<DetId, float>(northern, 1.)); // by default hit energy fractions are set at 1.
174  used_s.insert(northern);
175  searchNorth(navigator);
176  }
177 }
std::vector< EcalRecHit >::const_iterator const_iterator
std::set< DetId > used_s
T pos() const
get the current position
Definition: CaloNavigator.h:32
Definition: DetId.h:18
void searchNorth(const CaloNavigator< DetId > &navigator)
bool shouldBeAdded(EcalRecHitCollection::const_iterator candidate_it, EcalRecHitCollection::const_iterator previous_it)
iterator find(key_type k)
std::vector< std::pair< DetId, float > > current_v
T north() const
move the navigator north
Definition: CaloNavigator.h:38
const EcalRecHitCollection * recHits_
void IslandClusterAlgo::searchSouth ( const CaloNavigator< DetId > &  navigator)
private

Definition at line 180 of file IslandClusterAlgo.cc.

References current_v, edm::SortedCollection< T, SORT >::find(), CaloNavigator< T, TOPO >::pos(), recHits_, shouldBeAdded(), CaloNavigator< T, TOPO >::south(), and used_s.

Referenced by mainSearch(), searchEast(), and searchWest().

181 {
182  DetId northern = navigator.pos();
183 
184  DetId southern = navigator.south();
185  if (southern == DetId(0)) return; // This means that we went off the ECAL!
186  if (used_s.find(southern) != used_s.end()) return;
187 
188 
189  EcalRecHitCollection::const_iterator northern_it = recHits_->find(northern);
190  EcalRecHitCollection::const_iterator southern_it = recHits_->find(southern);
191 
192  if (shouldBeAdded(southern_it, northern_it))
193  {
194  current_v.push_back( std::pair<DetId, float>(southern, 1.)); // by default hit energy fractions are set at 1.
195  used_s.insert(southern);
196  searchSouth(navigator);
197  }
198 }
std::vector< EcalRecHit >::const_iterator const_iterator
std::set< DetId > used_s
T south() const
move the navigator south
Definition: CaloNavigator.h:45
T pos() const
get the current position
Definition: CaloNavigator.h:32
Definition: DetId.h:18
bool shouldBeAdded(EcalRecHitCollection::const_iterator candidate_it, EcalRecHitCollection::const_iterator previous_it)
iterator find(key_type k)
std::vector< std::pair< DetId, float > > current_v
const EcalRecHitCollection * recHits_
void searchSouth(const CaloNavigator< DetId > &navigator)
void IslandClusterAlgo::searchWest ( const CaloNavigator< DetId > &  navigator,
const CaloSubdetectorTopology topology 
)
private

Definition at line 201 of file IslandClusterAlgo.cc.

References current_v, edm::SortedCollection< T, SORT >::find(), CaloNavigator< T, TOPO >::home(), CaloNavigator< T, TOPO >::pos(), recHits_, searchNorth(), searchSouth(), shouldBeAdded(), used_s, and CaloNavigator< T, TOPO >::west().

Referenced by mainSearch().

202 {
203  DetId eastern = navigator.pos();
204  EcalRecHitCollection::const_iterator eastern_it = recHits_->find(eastern);
205 
206  DetId western = navigator.west();
207  if (western == DetId(0)) return; // This means that we went off the ECAL!
208  EcalRecHitCollection::const_iterator western_it = recHits_->find(western);
209 
210  if (shouldBeAdded(western_it, eastern_it))
211  {
212  CaloNavigator<DetId> nsNavigator(western, topology);
213 
214  searchNorth(nsNavigator);
215  nsNavigator.home();
216  searchSouth(nsNavigator);
217  nsNavigator.home();
218  searchWest(navigator, topology);
219 
220  current_v.push_back( std::pair<DetId, float>(western, 1.)); // by default hit energy fractions are set at 1.
221  used_s.insert(western);
222  }
223 }
void searchWest(const CaloNavigator< DetId > &navigator, const CaloSubdetectorTopology *topology)
std::vector< EcalRecHit >::const_iterator const_iterator
T west() const
move the navigator west
Definition: CaloNavigator.h:59
std::set< DetId > used_s
T pos() const
get the current position
Definition: CaloNavigator.h:32
Definition: DetId.h:18
void searchNorth(const CaloNavigator< DetId > &navigator)
bool shouldBeAdded(EcalRecHitCollection::const_iterator candidate_it, EcalRecHitCollection::const_iterator previous_it)
iterator find(key_type k)
std::vector< std::pair< DetId, float > > current_v
const EcalRecHitCollection * recHits_
void searchSouth(const CaloNavigator< DetId > &navigator)
void IslandClusterAlgo::setVerbosity ( VerbosityLevel  the_verbosity)
inline

Definition at line 46 of file IslandClusterAlgo.h.

References verbosity.

47  {
48  verbosity = the_verbosity;
49  }
VerbosityLevel verbosity
bool IslandClusterAlgo::shouldBeAdded ( EcalRecHitCollection::const_iterator  candidate_it,
EcalRecHitCollection::const_iterator  previous_it 
)
private

Definition at line 252 of file IslandClusterAlgo.cc.

References edm::SortedCollection< T, SORT >::end(), recHits_, and used_s.

Referenced by searchEast(), searchNorth(), searchSouth(), and searchWest().

253 {
254  // crystal should not be included...
255  if ( (candidate_it == recHits_->end()) || // ...if it does not correspond to a hit
256  (used_s.find(candidate_it->id()) != used_s.end()) || // ...if it already belongs to a cluster
257  (candidate_it->energy() <= 0) || // ...if it has a negative or zero energy
258  (candidate_it->energy() > previous_it->energy())) // ...or if the previous crystal had lower E
259  {
260  return false;
261  }
262  return true;
263 }
std::set< DetId > used_s
const_iterator end() const
const EcalRecHitCollection * recHits_

Member Data Documentation

std::vector<reco::BasicCluster> IslandClusterAlgo::clusters_v
private

Definition at line 86 of file IslandClusterAlgo.h.

Referenced by makeCluster(), and makeClusters().

std::vector< std::pair<DetId, float> > IslandClusterAlgo::current_v
private
double IslandClusterAlgo::ecalBarrelSeedThreshold
private

Definition at line 70 of file IslandClusterAlgo.h.

Referenced by makeClusters().

double IslandClusterAlgo::ecalEndcapSeedThreshold
private

Definition at line 71 of file IslandClusterAlgo.h.

Referenced by makeClusters().

PositionCalc IslandClusterAlgo::posCalculator_
private

Definition at line 66 of file IslandClusterAlgo.h.

Referenced by IslandClusterAlgo(), and makeCluster().

const EcalRecHitCollection* IslandClusterAlgo::recHits_
private
std::vector<EcalRecHit> IslandClusterAlgo::seeds
private

Definition at line 77 of file IslandClusterAlgo.h.

Referenced by mainSearch(), and makeClusters().

std::set<DetId> IslandClusterAlgo::used_s
private
VerbosityLevel IslandClusterAlgo::verbosity
private

Definition at line 89 of file IslandClusterAlgo.h.

Referenced by mainSearch(), makeCluster(), makeClusters(), and setVerbosity().