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 {
29  public:
30  //the 5x5 clustering algo by default makes basic clusters which may not contain their seed crystal if they are close by to other clusters
31  //however we would like to post-fix the basic clusters to ensure they always contain their seed crystal
32  //so we define a proto basic cluster class which contains all the information which would be in a basic cluster
33  //which allows the addition of its seed and the removal of a seed of another cluster easily
35  float energy_;
37  std::vector<std::pair<DetId,float> > hits_;
39  public:
41  ProtoBasicCluster(float iEnergy,const EcalRecHit& iSeed,std::vector<std::pair<DetId,float> >& iHits):energy_(iEnergy),seed_(iSeed){hits_.swap(iHits);containsSeed_=isSeedCrysInHits_();}
42 
43  float energy()const{return energy_;}
44  const EcalRecHit& seed()const{return seed_;}
45  const std::vector<std::pair<DetId,float> >& hits()const{return hits_;}
46  bool containsSeed()const{return containsSeed_;}
47 
48  bool removeHit(const EcalRecHit& hitToRM);
49  bool addSeed();
50  private:
51  bool isSeedCrysInHits_()const;
52 
53  };
54 
55 
57  }
58 
59  Multi5x5ClusterAlgo(double ebst, double ecst, const std::vector<int>& v_chstatus, const PositionCalc& posCalc,bool reassignSeedCrysToClusterItSeeds=false) :
61  posCalculator_ = posCalc;
62  std::sort( v_chstatus_.begin(), v_chstatus_.end() );
63  }
64 
66  {
67  }
68 
69 
70  // this is the method that will start the clusterisation
71  std::vector<reco::BasicCluster> makeClusters(const EcalRecHitCollection* hits,
73  const CaloSubdetectorTopology *topology_p,
74  const CaloSubdetectorGeometry *geometryES_p,
76  bool regional = false,
77  const std::vector<RectangularEtaPhiRegion>& regions = std::vector<RectangularEtaPhiRegion>());
78 
81 
82  private:
83 
84  //algo to compute position of clusters
86 
89 
90  // Energy required for a seed:
93 
94  // collection of all rechits
96 
97  // The vector of seeds:
98  std::vector<EcalRecHit> seeds;
99 
100  std::vector<std::pair<DetId,int> > whichClusCrysBelongsTo_;
101 
102  // The set of used DetID's
103  std::set<DetId> used_s;
104  std::set<DetId> canSeed_s; // set of crystals not to be added but which can seed
105  // a new 3x3 (e.g. the outer crystals in a 5x5)
106 
107 
108  // The vector of DetId's in the cluster currently reconstructed
109  std::vector<std::pair<DetId, float> > current_v;
110 
111  // The vector of clusters
112  std::vector<reco::BasicCluster> clusters_v;
113  std::vector<ProtoBasicCluster> protoClusters_;
114  // recHit flag to be excluded from seeding
115  std::vector<int> v_chstatus_;
116 
117  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
118 
119 
120 
121  void mainSearch(const EcalRecHitCollection* hits,
122  const CaloSubdetectorGeometry *geometry_p,
123  const CaloSubdetectorTopology *topology_p,
124  const CaloSubdetectorGeometry *geometryES_p);
125 
126  // Is the crystal at the navigator position a
127  // local maxiumum in energy?
129  const EcalRecHitCollection *hits);
130 
131  // prepare the 5x5 taking care over which crystals
132  // are allowed to seed new clusters and which are not
133  // after the preparation is complete
135  const EcalRecHitCollection *hits,
136  const CaloSubdetectorGeometry *geometry);
137 
138  // Add the crystal with DetId det to the current
139  // vector of crystals if it meets certain criteria
140  void addCrystal(const DetId &det);
141 
142 
143  // take the crystals in the current_v and build
144  // them into a BasicCluster
145  void makeCluster(const EcalRecHitCollection* hits,
146  const CaloSubdetectorGeometry *geometry_p,
147  const CaloSubdetectorGeometry *geometryES_p,
149  bool seedOutside);
150 
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< std::pair< DetId, float > > hits_
std::vector< EcalRecHit >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hits() const
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)
std::vector< std::pair< DetId, int > > whichClusCrysBelongsTo_
void addCrystal(const DetId &det)
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:18
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