16 template <
class T1,
class T2,
typename Comp=std::less<T1> >
struct PairSortByFirst {
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);}
26 if(lhs.
ieta()<rhs.
ieta())
return true;
27 else if(lhs.
ieta()>rhs.
ieta())
return false;
37 if(lhs.
ix()<rhs.
ix())
return true;
38 else if(lhs.
ix()>rhs.
ix())
return false;
39 else return lhs.
iy()<rhs.
iy();
53 const std::vector<EcalEtaPhiRegion>& regions
70 ecalPart_string =
"EndCap";
76 ecalPart_string =
"Barrel";
79 LogTrace(
"EcalClusters") <<
"-------------------------------------------------------------";
80 LogTrace(
"EcalClusters") <<
"Island algorithm invoked for ECAL" << ecalPart_string ;
81 LogTrace(
"EcalClusters") <<
"Looking for seeds, energy threshold used = " << threshold <<
" GeV";
85 if(regional) nregions=regions.size();
87 if(!regional || nregions) {
90 for(it = hits->
begin(); it != hits->
end(); it++)
92 double energy = it->energy();
93 if (energy < threshold)
continue;
100 bool withinRegion =
false;
102 std::vector<EcalEtaPhiRegion>::const_iterator
region;
103 for (region=regions.begin(); region!=regions.end(); region++) {
104 if (region->inRegion(position)) {
111 if (!regional || withinRegion) {
112 float ET = it->energy() *
sin(position.
theta());
113 if (ET > threshold)
seeds.push_back(*it);
121 LogTrace(
"EcalClusters") <<
"Total number of seeds found in event = " <<
seeds.size();
124 mainSearch(hits, geometry_p, topology_p, geometryES_p);
127 LogTrace(
"EcalClusters") <<
"---------- end of main search. clusters have been sorted ----";
143 LogTrace(
"EcalClusters") <<
"Building clusters............";
146 std::vector<EcalRecHit>::iterator it;
147 for (it =
seeds.begin(); it !=
seeds.end(); it++)
152 bool usedButCanSeed =
false;
161 if ((
used_s.find(it->id()) !=
used_s.end()) && (usedButCanSeed ==
false))
163 if (it ==
seeds.begin())
165 LogTrace(
"EcalClusters") <<
"##############################################################" ;
166 LogTrace(
"EcalClusters") <<
"DEBUG ALERT: Highest energy seed already belongs to a cluster!";
167 LogTrace(
"EcalClusters") <<
"##############################################################";
200 makeCluster(hits, geometry_p, geometryES_p, seedIt, usedButCanSeed);
213 typedef std::vector<std::pair<DetId,int> >::iterator It;
216 if(result.first!=result.second)
protoClusters_[result.first->second].removeHit(seedHit);
250 std::vector<std::pair<DetId, float> >::iterator it;
266 LogTrace(
"EcalClusters") <<
"******** NEW CLUSTER ********";
269 LogTrace(
"EcalClusters") <<
" Phi = " << position.phi();
270 LogTrace(
"EcalClusters") <<
" Eta " << position.eta();
271 LogTrace(
"EcalClusters") <<
"*****************************";
276 double seedEnergy = seedIt->energy();
277 if ((seedOutside && energy>=0) || (!seedOutside && energy >= seedEnergy))
289 std::vector<std::pair<DetId, float> >::iterator iter;
292 used_s.erase(iter->first);
305 double seedEnergy = seedHit->energy();
307 std::vector<DetId> swissCrossVec;
308 swissCrossVec.clear();
310 swissCrossVec.push_back(navigator.
west());
312 swissCrossVec.push_back(navigator.
east());
314 swissCrossVec.push_back(navigator.
north());
316 swissCrossVec.push_back(navigator.
south());
319 std::vector<DetId>::const_iterator detItr;
320 for (
unsigned int i = 0;
i < swissCrossVec.size(); ++
i)
331 uint32_t rhFlag = thisHit->recoFlag();
337 if (thisHit->energy() > seedEnergy)
354 std::set<DetId>::iterator setItr;
361 for (
int dx = -2; dx < 3; ++dx)
363 for (
int dy = -2; dy < 3; ++ dy)
368 thisDet = navigator.
offsetBy(dx, dy);
377 if ((
abs(dx) > 1) || (
abs(dy) > 1))
416 current_v.push_back( std::pair<DetId, float>(det, 1.) );
425 std::vector<std::pair<DetId,float> >::iterator hitPos;
426 for(hitPos=
hits_.begin();hitPos<
hits_.end();hitPos++){
427 if(hitToRM.
id()==hitPos->first)
break;
429 if(hitPos!=
hits_.end()){
440 typedef std::vector<std::pair<DetId,float> >::iterator It;
441 std::pair<It,It> hitPos;
449 if(hitPos.first==hitPos.second){
450 hits_.insert(hitPos.first,std::pair<DetId,float>(seed_.id(),1.));
451 energy_+=seed_.energy();
461 for(
size_t hitNr=0;hitNr<hits_.size();hitNr++){
462 if(seed_.id()==hits_[hitNr].first)
return true;
void makeCluster(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry_p, const CaloSubdetectorGeometry *geometryES_p, const EcalRecHitCollection::const_iterator &seedIt, bool seedOutside)
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< EcalEtaPhiRegion > ®ions=std::vector< EcalEtaPhiRegion >())
std::set< DetId > canSeed_s
double ecalEndcapSeedThreshold
const EcalRecHitCollection * recHits_
Sin< T >::type sin(const T &t)
std::vector< std::pair< DetId, float > > hits_
bool reassignSeedCrysToClusterItSeeds_
std::vector< EcalRecHit >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hits() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Geom::Theta< T > theta() const
int iphi() const
get the crystal iphi
double ecalBarrelSeedThreshold
void mainSearch(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry_p, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p)
std::vector< int > v_chstatus_
T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
void prepareCluster(CaloNavigator< DetId > &navigator, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
std::vector< std::pair< DetId, int > > whichClusCrysBelongsTo_
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)
std::vector< std::pair< DetId, float > > current_v
T south() const
move the navigator south
int ieta() const
get the crystal ieta
T pos() const
get the current position
bool operator()(const T1 &lhs, const T1 &rhs)
std::vector< ProtoBasicCluster > protoClusters_
const_iterator end() const
bool isSeedCrysInHits_() const
bool removeHit(const EcalRecHit &hitToRM)
std::vector< EcalRecHit > seeds
T east() const
move the navigator east
void home() const
move the navigator back to the starting point
DetId id() const
get the id
bool operator()(const EBDetId &lhs, const EBDetId &rhs)
bool operator()(const std::pair< T1, T2 > &lhs, const std::pair< T1, T2 > &rhs)
bool checkMaxima(CaloNavigator< DetId > &navigator, const EcalRecHitCollection *hits)
bool operator()(const T1 &lhs, const std::pair< T1, T2 > &rhs)
ESHandle< TrackerGeometry > geometry
math::XYZPoint Point
point in the space
iterator find(key_type k)
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
static int position[264][3]
reco::CaloID::Detectors detector_
The ecal region used.
T north() const
move the navigator north
std::vector< reco::BasicCluster > clusters_v
const EcalRecHit & seed() const
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
PositionCalc posCalculator_
const_iterator begin() const