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