CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoEcal/EgammaClusterAlgos/interface/Multi5x5ClusterAlgo.h

Go to the documentation of this file.
00001 #ifndef RecoECAL_ECALClusters_Multi5x5ClusterAlgo_h
00002 #define RecoECAL_ECALClusters_Multi5x5ClusterAlgo_h
00003 
00004 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00005 
00006 #include "DataFormats/Math/interface/Point3D.h"
00007 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00008 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00009 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00010 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00011 
00012 #include "RecoCaloTools/Navigation/interface/CaloNavigator.h"
00013 #include "RecoCaloTools/Navigation/interface/EcalBarrelNavigator.h"
00014 #include "RecoCaloTools/Navigation/interface/EcalEndcapNavigator.h"
00015 #include "Geometry/CaloTopology/interface/EcalBarrelHardcodedTopology.h"
00016 #include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h"
00017 #include "RecoEcal/EgammaCoreTools/interface/EcalEtaPhiRegion.h"
00018 #include "RecoEcal/EgammaCoreTools/interface/EcalRecHitLess.h"
00019 #include "DataFormats/CaloRecHit/interface/CaloID.h"
00020 
00021 // C/C++ headers
00022 #include <string>
00023 #include <vector>
00024 #include <set>
00025 
00026 typedef std::map<DetId, EcalRecHit> RecHitsMap;
00027 
00028 class Multi5x5ClusterAlgo 
00029 {
00030  public:
00031   
00032   enum VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 }; 
00033 
00034   Multi5x5ClusterAlgo() {
00035   }
00036 
00037   Multi5x5ClusterAlgo(double ebst, double ecst, std::vector<int> v_chstatus, const PositionCalc& posCalc, VerbosityLevel the_verbosity = pERROR) : 
00038     ecalBarrelSeedThreshold(ebst), ecalEndcapSeedThreshold(ecst),  v_chstatus_(v_chstatus), verbosity(the_verbosity) {
00039     posCalculator_ = posCalc;
00040     std::sort( v_chstatus_.begin(), v_chstatus_.end() );
00041   }
00042 
00043   virtual ~Multi5x5ClusterAlgo()
00044     {
00045     }
00046 
00047   void setVerbosity(VerbosityLevel the_verbosity)
00048     {
00049       verbosity = the_verbosity;
00050     }
00051 
00052   // this is the method that will start the clusterisation
00053   std::vector<reco::BasicCluster> makeClusters(const EcalRecHitCollection* hits,
00054                                                const CaloSubdetectorGeometry *geometry,
00055                                                const CaloSubdetectorTopology *topology_p,
00056                                                const CaloSubdetectorGeometry *geometryES_p,
00057                                                reco::CaloID::Detectors detector,
00058                                                bool regional = false,
00059                                                const std::vector<EcalEtaPhiRegion>& regions = std::vector<EcalEtaPhiRegion>());
00060 
00062   typedef math::XYZPoint Point;
00063 
00064  private: 
00065   
00066   //algo to compute position of clusters
00067   PositionCalc posCalculator_;
00068 
00070   reco::CaloID::Detectors detector_;
00071 
00072   // Energy required for a seed:
00073   double ecalBarrelSeedThreshold;
00074   double ecalEndcapSeedThreshold;
00075   
00076   // collection of all rechits
00077   const EcalRecHitCollection *recHits_;
00078 
00079   // The vector of seeds:
00080   std::vector<EcalRecHit> seeds;
00081 
00082   // The set of used DetID's
00083   std::set<DetId> used_s;
00084   std::set<DetId> canSeed_s; // set of crystals not to be added but which can seed
00085                                 // a new 3x3 (e.g. the outer crystals in a 5x5)
00086 
00087 
00088   // The vector of DetId's in the cluster currently reconstructed
00089   std::vector<std::pair<DetId, float> > current_v;
00090 
00091   // The vector of clusters
00092   std::vector<reco::BasicCluster> clusters_v;
00093 
00094   // recHit flag to be excluded from seeding
00095   std::vector<int> v_chstatus_;
00096 
00097   // The verbosity level
00098   VerbosityLevel verbosity;
00099 
00100   void mainSearch(const EcalRecHitCollection* hits,
00101                   const CaloSubdetectorGeometry *geometry_p,
00102                   const CaloSubdetectorTopology *topology_p,
00103                   const CaloSubdetectorGeometry *geometryES_p);
00104 
00105   // Is the crystal at the navigator position a 
00106   // local maxiumum in energy?
00107   bool checkMaxima(CaloNavigator<DetId> &navigator,
00108                    const EcalRecHitCollection *hits);
00109 
00110   // prepare the 5x5 taking care over which crystals
00111   // are allowed to seed new clusters and which are not
00112   // after the preparation is complete
00113   void prepareCluster(CaloNavigator<DetId> &navigator,
00114                 const EcalRecHitCollection *hits,
00115                 const CaloSubdetectorGeometry *geometry);
00116 
00117   // Add the crystal with DetId det to the current
00118   // vector of crystals if it meets certain criteria
00119   void addCrystal(const DetId &det);
00120 
00121   
00122   // take the crystals in the current_v and build 
00123   // them into a BasicCluster
00124   void makeCluster(const EcalRecHitCollection* hits,
00125                    const CaloSubdetectorGeometry *geometry_p,
00126                    const CaloSubdetectorGeometry *geometryES_p, 
00127                    const EcalRecHitCollection::const_iterator &seedIt);
00128 
00129  };
00130 
00131 #endif