Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:38

0001 #ifndef RecoECAL_ECALClusters_CosmicClusterAlgo_h
0002 #define RecoECAL_ECALClusters_CosmicClusterAlgo_h
0003 
0004 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0005 
0006 #include "DataFormats/Math/interface/Point3D.h"
0007 #include "DataFormats/Math/interface/RectangularEtaPhiRegion.h"
0008 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
0009 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0010 #include "DataFormats/EcalRecHit/interface/EcalUncalibratedRecHit.h"
0011 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0012 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
0013 
0014 #include "RecoCaloTools/Navigation/interface/CaloNavigator.h"
0015 #include "RecoCaloTools/Navigation/interface/EcalBarrelNavigator.h"
0016 #include "RecoCaloTools/Navigation/interface/EcalEndcapNavigator.h"
0017 #include "Geometry/CaloTopology/interface/EcalBarrelHardcodedTopology.h"
0018 #include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h"
0019 
0020 // C/C++ headers
0021 #include <string>
0022 #include <vector>
0023 #include <set>
0024 
0025 typedef std::map<DetId, EcalRecHit> RecHitsMap;
0026 
0027 class CosmicClusterAlgo {
0028 public:
0029   enum EcalPart { barrel = 0, endcap = 1 };
0030   enum VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 };
0031 
0032   CosmicClusterAlgo() {}
0033 
0034   CosmicClusterAlgo(double ebst,
0035                     double ebSt,
0036                     double ebDt,
0037                     double ebSp,
0038                     double ecst,
0039                     double ecSt,
0040                     double ecDt,
0041                     double ecSp,
0042                     const PositionCalc &posCalc,
0043                     VerbosityLevel the_verbosity = pERROR)
0044       : ecalBarrelSeedThreshold(ebst),
0045         ecalBarrelSingleThreshold(ebSt),
0046         ecalBarrelSecondThreshold(ebDt),
0047         ecalBarrelSupThreshold(ebSp),
0048         ecalEndcapSeedThreshold(ecst),
0049         ecalEndcapSingleThreshold(ecSt),
0050         ecalEndcapSecondThreshold(ecDt),
0051         ecalEndcapSupThreshold(ecSp),
0052         verbosity(the_verbosity) {
0053     posCalculator_ = posCalc;
0054   }
0055 
0056   virtual ~CosmicClusterAlgo() {}
0057 
0058   void setVerbosity(VerbosityLevel the_verbosity) { verbosity = the_verbosity; }
0059 
0060   // this is the method that will start the clusterisation
0061   std::vector<reco::BasicCluster> makeClusters(
0062       const EcalRecHitCollection *hits,
0063       const EcalUncalibratedRecHitCollection *uncalibhits,
0064       const CaloSubdetectorGeometry *geometry,
0065       const CaloSubdetectorTopology *topology_p,
0066       const CaloSubdetectorGeometry *geometryES_p,
0067       EcalPart ecalPart,
0068       bool regional = false,
0069       const std::vector<RectangularEtaPhiRegion> &regions = std::vector<RectangularEtaPhiRegion>());
0070 
0071   /// point in the space
0072   typedef math::XYZPoint Point;
0073 
0074 private:
0075   //algo to compute position of clusters
0076   PositionCalc posCalculator_;
0077 
0078   // Energy required for a seed:
0079   double ecalBarrelSeedThreshold;
0080   double ecalBarrelSingleThreshold;
0081   double ecalBarrelSecondThreshold;
0082   double ecalBarrelSupThreshold;
0083 
0084   double ecalEndcapSeedThreshold;
0085   double ecalEndcapSingleThreshold;
0086   double ecalEndcapSecondThreshold;
0087   double ecalEndcapSupThreshold;
0088 
0089   // collection of all rechits
0090   const EcalRecHitCollection *recHits_;
0091   // collection of all uncalibrated rechits
0092   const EcalUncalibratedRecHitCollection *uncalibRecHits_;
0093 
0094   // The vector of seeds:
0095   std::vector<EcalRecHit> seeds;
0096 
0097   // The set of used DetID's
0098   std::set<DetId> used_s;
0099   std::set<DetId> canSeed_s;  // set of crystals not to be added but which can seed
0100                               // a new 3x3 (e.g. the outer crystals in a 5x5)
0101 
0102   //in EB or EE?
0103   bool inEB;
0104 
0105   // The vector of DetId's in the cluster currently reconstructed
0106   std::vector<DetId> current_v9;
0107   std::vector<DetId> current_v25;
0108   std::vector<std::pair<DetId, float> > current_v25Sup;
0109 
0110   // The vector of clusters
0111   std::vector<reco::BasicCluster> clusters_v;
0112 
0113   // The verbosity level
0114   VerbosityLevel verbosity;
0115 
0116   void mainSearch(const CaloSubdetectorGeometry *geometry_p,
0117                   const CaloSubdetectorTopology *topology_p,
0118                   const CaloSubdetectorGeometry *geometryES_p,
0119                   EcalPart ecalPart);
0120 
0121   // Is the crystal at the navigator position a
0122   // local maxiumum in energy?
0123   bool checkMaxima(CaloNavigator<DetId> &navigator);
0124 
0125   // prepare the 5x5 taking care over which crystals
0126   // are allowed to seed new clusters and which are not
0127   // after the preparation is complete
0128   void prepareCluster(CaloNavigator<DetId> &navigator, const CaloSubdetectorGeometry *geometry);
0129 
0130   // Add the crystal with DetId det to the current
0131   // vector of crystals if it meets certain criteria
0132   void addCrystal(const DetId &det, const bool in9);
0133 
0134   // take the crystals in the current_v and build
0135   // them into a BasicCluster
0136   void makeCluster(const CaloSubdetectorGeometry *geometry_p,
0137                    const CaloSubdetectorGeometry *geometryES_p,
0138                    DetId seedId);
0139 };
0140 
0141 #endif