CMS 3D CMS Logo

Multi5x5ClusterAlgo.h
Go to the documentation of this file.
1 #ifndef RecoECAL_ECALClusters_Multi5x5ClusterAlgo_h
2 #define RecoECAL_ECALClusters_Multi5x5ClusterAlgo_h
3 
5 
12 
19 
20 // C/C++ headers
21 #include <string>
22 #include <vector>
23 #include <set>
24 
25 typedef std::map<DetId, EcalRecHit> RecHitsMap;
26 
28 public:
29  //the 5x5 clustering algo by default makes basic clusters which may not contain their seed crystal if they are close by to other clusters
30  //however we would like to post-fix the basic clusters to ensure they always contain their seed crystal
31  //so we define a proto basic cluster class which contains all the information which would be in a basic cluster
32  //which allows the addition of its seed and the removal of a seed of another cluster easily
34  float energy_;
36  std::vector<std::pair<DetId, float> > hits_;
38 
39  public:
41  ProtoBasicCluster(float iEnergy, const EcalRecHit &iSeed, std::vector<std::pair<DetId, float> > &iHits)
42  : energy_(iEnergy), seed_(iSeed) {
43  hits_.swap(iHits);
45  }
46 
47  float energy() const { return energy_; }
48  const EcalRecHit &seed() const { return seed_; }
49  const std::vector<std::pair<DetId, float> > &hits() const { return hits_; }
50  bool containsSeed() const { return containsSeed_; }
51 
52  bool removeHit(const EcalRecHit &hitToRM);
53  bool addSeed();
54 
55  private:
56  bool isSeedCrysInHits_() const;
57  };
58 
60 
61  Multi5x5ClusterAlgo(double ebst,
62  double ecst,
63  const std::vector<int> &v_chstatus,
64  const PositionCalc &posCalc,
68  v_chstatus_(v_chstatus),
70  posCalculator_ = posCalc;
71  std::sort(v_chstatus_.begin(), v_chstatus_.end());
72  }
73 
74  virtual ~Multi5x5ClusterAlgo() {}
75 
76  // this is the method that will start the clusterisation
77  std::vector<reco::BasicCluster> makeClusters(
80  const CaloSubdetectorTopology *topology_p,
81  const CaloSubdetectorGeometry *geometryES_p,
83  bool regional = false,
84  const std::vector<RectangularEtaPhiRegion> &regions = std::vector<RectangularEtaPhiRegion>());
85 
88 
89 private:
90  //algo to compute position of clusters
92 
95 
96  // Energy required for a seed:
99 
100  // collection of all rechits
102 
103  // The vector of seeds:
104  std::vector<EcalRecHit> seeds;
105 
106  std::vector<std::pair<DetId, int> > whichClusCrysBelongsTo_;
107 
108  // The set of used DetID's
109  std::set<DetId> used_s;
110  std::set<DetId> canSeed_s; // set of crystals not to be added but which can seed
111  // a new 3x3 (e.g. the outer crystals in a 5x5)
112 
113  // The vector of DetId's in the cluster currently reconstructed
114  std::vector<std::pair<DetId, float> > current_v;
115 
116  // The vector of clusters
117  std::vector<reco::BasicCluster> clusters_v;
118  std::vector<ProtoBasicCluster> protoClusters_;
119  // recHit flag to be excluded from seeding
120  std::vector<int> v_chstatus_;
121 
122  bool reassignSeedCrysToClusterItSeeds_; //the seed of the 5x5 crystal is sometimes in another basic cluster, however we may want to put it back into the cluster it seeds
123 
125  const CaloSubdetectorGeometry *geometry_p,
126  const CaloSubdetectorTopology *topology_p,
127  const CaloSubdetectorGeometry *geometryES_p);
128 
129  // Is the crystal at the navigator position a
130  // local maxiumum in energy?
132 
133  // prepare the 5x5 taking care over which crystals
134  // are allowed to seed new clusters and which are not
135  // after the preparation is complete
137  const EcalRecHitCollection *hits,
139 
140  // Add the crystal with DetId det to the current
141  // vector of crystals if it meets certain criteria
142  void addCrystal(const DetId &det);
143 
144  // take the crystals in the current_v and build
145  // them into a BasicCluster
147  const CaloSubdetectorGeometry *geometry_p,
148  const CaloSubdetectorGeometry *geometryES_p,
150  bool seedOutside);
151 };
152 
153 #endif
void makeCluster(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry_p, const CaloSubdetectorGeometry *geometryES_p, const EcalRecHitCollection::const_iterator &seedIt, bool seedOutside)
std::set< DetId > canSeed_s
ProtoBasicCluster(float iEnergy, const EcalRecHit &iSeed, std::vector< std::pair< DetId, float > > &iHits)
const EcalRecHitCollection * recHits_
std::vector< EcalRecHit >::const_iterator const_iterator
void mainSearch(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry_p, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p)
std::vector< int > v_chstatus_
void prepareCluster(CaloNavigator< DetId > &navigator, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
void addCrystal(const DetId &det)
const std::vector< std::pair< DetId, float > > & hits() const
std::set< DetId > used_s
std::vector< std::pair< DetId, float > > current_v
std::map< DetId, EcalRecHit > RecHitsMap
std::vector< ProtoBasicCluster > protoClusters_
bool removeHit(const EcalRecHit &hitToRM)
std::vector< EcalRecHit > seeds
Definition: DetId.h:17
std::vector< std::pair< DetId, float > > hits_
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 > &regions=std::vector< RectangularEtaPhiRegion >())
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
bool checkMaxima(CaloNavigator< DetId > &navigator, const EcalRecHitCollection *hits)
Multi5x5ClusterAlgo(double ebst, double ecst, const std::vector< int > &v_chstatus, const PositionCalc &posCalc, bool reassignSeedCrysToClusterItSeeds=false)
math::XYZPoint Point
point in the space
reco::CaloID::Detectors detector_
The ecal region used.
std::vector< reco::BasicCluster > clusters_v
std::vector< std::pair< DetId, int > > whichClusCrysBelongsTo_