15 template <
class T1,
class T2,
typename Comp = std::less<T1> >
18 bool operator()(
const std::pair<T1, T2>& lhs,
const std::pair<T1, T2>& rhs) {
return comp(lhs.first, rhs.first); }
19 bool operator()(
const T1& lhs,
const std::pair<T1, T2>& rhs) {
return comp(lhs, rhs.first); }
20 bool operator()(
const std::pair<T1, T2>& lhs,
const T1& rhs) {
return comp(lhs.first, rhs); }
42 if (lhs.
ix() < rhs.
ix())
44 else if (lhs.
ix() > rhs.
ix())
47 return lhs.
iy() < rhs.
iy();
60 const std::vector<RectangularEtaPhiRegion>&
regions) {
73 threshold = ecalEndcapSeedThreshold;
74 ecalPart_string =
"EndCap";
78 threshold = ecalBarrelSeedThreshold;
79 ecalPart_string =
"Barrel";
82 LogTrace(
"EcalClusters") <<
"-------------------------------------------------------------";
83 LogTrace(
"EcalClusters") <<
"Island algorithm invoked for ECAL" << ecalPart_string;
84 LogTrace(
"EcalClusters") <<
"Looking for seeds, energy threshold used = " << threshold <<
" GeV";
88 nregions = regions.size();
90 if (!regional || nregions) {
92 for (it = hits->
begin(); it != hits->
end(); it++) {
93 double energy = it->energy();
94 if (energy < threshold)
100 bool withinRegion =
false;
102 std::vector<RectangularEtaPhiRegion>::const_iterator
region;
103 for (region = regions.begin(); region != regions.end(); region++) {
104 if (region->inRegion(thisCell->etaPos(), thisCell->phiPos())) {
111 if (!regional || withinRegion) {
112 float ET = it->energy() * thisCell->getPosition().basicVector().unit().perp();
114 seeds.push_back(*it);
119 sort(seeds.begin(), seeds.end(), [](
auto const&
x,
auto const&
y) {
return (
x.energy() >
y.energy()); });
121 LogTrace(
"EcalClusters") <<
"Total number of seeds found in event = " << seeds.size();
123 mainSearch(hits, geometry_p, topology_p, geometryES_p);
126 LogTrace(
"EcalClusters") <<
"---------- end of main search. clusters have been sorted ----";
137 LogTrace(
"EcalClusters") <<
"Building clusters............";
140 std::vector<EcalRecHit>::iterator it;
141 for (it = seeds.begin(); it != seeds.end(); it++) {
144 bool usedButCanSeed =
false;
145 if (canSeed_s.find(it->id()) != canSeed_s.end())
146 usedButCanSeed =
true;
150 if (it->checkFlags(v_chstatus_))
155 if ((used_s.find(it->id()) != used_s.end()) && (usedButCanSeed ==
false)) {
156 if (it == seeds.begin()) {
157 LogTrace(
"EcalClusters") <<
"##############################################################";
158 LogTrace(
"EcalClusters") <<
"DEBUG ALERT: Highest energy seed already belongs to a cluster!";
159 LogTrace(
"EcalClusters") <<
"##############################################################";
178 bool localMaxima = checkMaxima(
navigator, hits);
183 prepareCluster(
navigator, hits, geometry_p);
188 if (!current_v.empty()) {
189 makeCluster(hits, geometry_p, geometryES_p, seedIt, usedButCanSeed);
194 if (reassignSeedCrysToClusterItSeeds_) {
197 for (
size_t clusNr = 0; clusNr < protoClusters_.size(); clusNr++) {
198 if (!protoClusters_[clusNr].containsSeed()) {
199 const EcalRecHit& seedHit = protoClusters_[clusNr].seed();
200 typedef std::vector<std::pair<DetId, int> >::iterator It;
201 std::pair<It, It>
result = std::equal_range(whichClusCrysBelongsTo_.begin(),
202 whichClusCrysBelongsTo_.end(),
206 if (result.first != result.second)
207 protoClusters_[result.first->second].removeHit(seedHit);
208 protoClusters_[clusNr].addSeed();
213 for (
size_t clusNr = 0; clusNr < protoClusters_.size(); clusNr++) {
216 position = posCalculator_.Calculate_Location(protoCluster.
hits(),
hits, geometry_p, geometryES_p);
222 protoCluster.
seed().
id()));
225 protoClusters_.clear();
226 whichClusCrysBelongsTo_.clear();
238 position = posCalculator_.Calculate_Location(current_v, hits, geometry, geometryES);
240 std::vector<std::pair<DetId, float> >::iterator it;
241 for (it = current_v.begin(); it != current_v.end(); it++) {
254 LogTrace(
"EcalClusters") <<
"******** NEW CLUSTER ********";
255 LogTrace(
"EcalClusters") <<
"No. of crystals = " << current_v.size();
257 LogTrace(
"EcalClusters") <<
" Phi = " << position.phi();
258 LogTrace(
"EcalClusters") <<
" Eta " << position.eta();
259 LogTrace(
"EcalClusters") <<
"*****************************";
263 double seedEnergy = seedIt->energy();
264 if ((seedOutside && energy >= 0) || (!seedOutside && energy >= seedEnergy)) {
265 if (reassignSeedCrysToClusterItSeeds_) {
266 for (
size_t hitNr = 0; hitNr < current_v.size(); hitNr++)
267 whichClusCrysBelongsTo_.push_back(std::pair<DetId, int>(current_v[hitNr].first, protoClusters_.size()));
276 std::vector<std::pair<DetId, float> >::iterator iter;
277 for (iter = current_v.begin(); iter != current_v.end(); iter++) {
278 used_s.erase(iter->first);
287 double seedEnergy = seedHit->energy();
289 std::vector<DetId> swissCrossVec;
290 swissCrossVec.clear();
292 swissCrossVec.push_back(navigator.
west());
294 swissCrossVec.push_back(navigator.
east());
296 swissCrossVec.push_back(navigator.
north());
298 swissCrossVec.push_back(navigator.
south());
301 for (
unsigned int i = 0;
i < swissCrossVec.size(); ++
i) {
303 thisHit = recHits_->find(swissCrossVec[
i]);
306 if ((swissCrossVec[i] ==
DetId(0)) || thisHit == recHits_->end())
311 uint32_t rhFlag = thisHit->recoFlag();
312 std::vector<int>::const_iterator vit =
std::find(v_chstatus_.begin(), v_chstatus_.end(), rhFlag);
313 if (vit != v_chstatus_.end())
318 if (thisHit->energy() > seedEnergy) {
331 std::set<DetId>::iterator setItr;
338 for (
int dx = -2;
dx < 3; ++
dx) {
339 for (
int dy = -2;
dy < 3; ++
dy) {
355 canSeed_s.insert(thisDet);
360 setItr = canSeed_s.find(thisDet);
361 if (setItr != canSeed_s.end()) {
363 canSeed_s.erase(setItr);
378 if ((thisIt != recHits_->end()) && (thisIt->id() !=
DetId(0))) {
379 if ((used_s.find(thisIt->id()) == used_s.end())) {
381 current_v.push_back(std::pair<DetId, float>(det, 1.));
388 std::vector<std::pair<DetId, float> >::iterator hitPos;
389 for (hitPos = hits_.begin(); hitPos < hits_.end(); hitPos++) {
390 if (hitToRM.
id() == hitPos->first)
393 if (hitPos != hits_.end()) {
395 energy_ -= hitToRM.
energy();
404 typedef std::vector<std::pair<DetId, float> >::iterator It;
405 std::pair<It, It> hitPos;
413 if (hitPos.first == hitPos.second) {
414 hits_.insert(hitPos.first, std::pair<DetId, float>(seed_.id(), 1.));
415 energy_ += seed_.energy();
416 containsSeed_ =
true;
424 for (
size_t hitNr = 0; hitNr < hits_.size(); hitNr++) {
425 if (seed_.id() == hits_[hitNr].first)
void makeCluster(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry_p, const CaloSubdetectorGeometry *geometryES_p, const EcalRecHitCollection::const_iterator &seedIt, bool seedOutside)
std::vector< EcalRecHit >::const_iterator const_iterator
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const std::vector< std::pair< DetId, float > > & hits() const
int iphi() const
get the crystal iphi
void mainSearch(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry_p, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p)
T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
void prepareCluster(CaloNavigator< DetId > &navigator, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
bool operator()(const std::pair< T1, T2 > &lhs, const T1 &rhs)
T west() const
move the navigator west
void addCrystal(const DetId &det)
Abs< T >::type abs(const T &t)
bool operator()(const EEDetId &lhs, const EEDetId &rhs)
T south() const
move the navigator south
int ieta() const
get the crystal ieta
bool isClusterEtLess(const reco::CaloCluster &x, const reco::CaloCluster &y)
T pos() const
get the current position
bool operator()(const T1 &lhs, const T1 &rhs)
const_iterator end() const
bool isSeedCrysInHits_() const
bool removeHit(const EcalRecHit &hitToRM)
T east() const
move the navigator east
void home() const
move the navigator back to the starting point
DetId id() const
get the id
std::vector< reco::BasicCluster > makeClusters(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p, reco::CaloID::Detectors detector, bool regional=false, const std::vector< RectangularEtaPhiRegion > ®ions=std::vector< RectangularEtaPhiRegion >())
bool operator()(const EBDetId &lhs, const EBDetId &rhs)
bool operator()(const std::pair< T1, T2 > &lhs, const std::pair< T1, T2 > &rhs)
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.
bool checkMaxima(CaloNavigator< DetId > &navigator, const EcalRecHitCollection *hits)
bool operator()(const T1 &lhs, const std::pair< T1, T2 > &rhs)
iterator find(key_type k)
Structure Point Contains parameters of Gaussian fits to DMRs.
static int position[264][3]
T north() const
move the navigator north
const EcalRecHit & seed() const
const_iterator begin() const