CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoEcal/EgammaClusterAlgos/interface/PFECALSuperClusterAlgo.h

Go to the documentation of this file.
00001 #ifndef RecoEcal_EgammaClusterAlgos_PFECALSuperClusterAlgo_h
00002 #define RecoEcal_EgammaClusterAlgos_PFECALSuperClusterAlgo_h
00003 
00004 
00005 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
00006 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
00007 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
00008 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
00009 #include "DataFormats/ParticleFlowReco/interface/PFLayer.h"
00010 #include "DataFormats/Common/interface/OrphanHandle.h"
00011 
00012 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00013 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00014 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00015 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00016 
00017 #include "RecoParticleFlow/PFClusterTools/interface/PFEnergyCalibration.h"
00018 
00019 #include "TVector2.h"
00020 
00021 #include <string>
00022 #include <vector>
00023 #include <unordered_map>
00024 #include <set>
00025 
00026 #include <memory>
00027 
00028 class TFile;
00029 class TH2F;
00030 
00032 
00038 // hash function for edm::Ptr<reco::PFCluster
00039 namespace std {
00040   template <> struct hash<edm::Ptr<reco::PFCluster> > {
00041     size_t operator()(const edm::Ptr<reco::PFCluster> & x) const {
00042       return hash<ptrdiff_t>()((ptrdiff_t)x.get());
00043     }
00044   };
00045 }
00046 
00047 class PFECALSuperClusterAlgo {  
00048  public:
00049   enum clustering_type{kBOX=1, kMustache=2};
00050 
00051   // simple class for associating calibrated energies
00052   class CalibratedPFCluster {
00053   public:
00054     CalibratedPFCluster(const edm::Ptr<reco::PFCluster>& p,
00055                         const double ce) : cluptr(p), calib_e(ce) {}
00056     
00057     double energy() const { return calib_e; }
00058     double energy_nocalib() const { return cluptr->energy(); }
00059     double eta() const { return cluptr->positionREP().eta(); }
00060     double phi() const { return cluptr->positionREP().phi(); }
00061     
00062     void resetCalibratedEnergy(const double ce) { calib_e = ce; }
00063    
00064     edm::Ptr<reco::PFCluster> the_ptr() const { return cluptr; }
00065 
00066   private:
00067     edm::Ptr<reco::PFCluster> cluptr;
00068     double calib_e;
00069   };
00070   typedef std::shared_ptr<CalibratedPFCluster> CalibratedClusterPtr;
00071   typedef std::vector<CalibratedClusterPtr> CalibratedClusterPtrVector;
00072 
00073 
00075   PFECALSuperClusterAlgo();
00076 
00077   void setVerbosityLevel(bool verbose){ verbose_ = verbose;}
00078   
00079   void setClusteringType(clustering_type thetype) { _clustype = thetype; } 
00080 
00081   void setUseDynamicDPhi(bool useit) { _useDynamicDPhi = useit; } 
00082 
00083   void setThreshPFClusterSeedBarrel(double thresh){ threshPFClusterSeedBarrel_ = thresh;}
00084   void setThreshPFClusterBarrel(double thresh){ threshPFClusterBarrel_ = thresh;}
00085   void setThreshPFClusterSeedEndcap(double thresh){ threshPFClusterSeedEndcap_ = thresh;}
00086   void setThreshPFClusterEndcap(double thresh){ threshPFClusterEndcap_ = thresh;}
00087   
00088   void setPhiwidthSuperClusterBarrel( double phiwidth ){ phiwidthSuperClusterBarrel_ = phiwidth;}
00089   void setEtawidthSuperClusterBarrel( double etawidth ){ etawidthSuperClusterBarrel_ = etawidth;}
00090   void setPhiwidthSuperClusterEndcap( double phiwidth ){ phiwidthSuperClusterEndcap_ = phiwidth;}
00091   void setEtawidthSuperClusterEndcap( double etawidth ){ etawidthSuperClusterEndcap_ = etawidth;}
00092   void setUsePS( bool useit ){ usePS = useit; }
00093 
00094   void setPFClusterCalibration(const std::shared_ptr<PFEnergyCalibration>&);
00095   
00096   void setThreshPFClusterES(double thresh){threshPFClusterES_ = thresh;}
00097   
00098   void setSatelliteMerging( const bool doit ) { doSatelliteClusterMerge_ = doit; }
00099   void setSatelliteThreshold( const double t ) { satelliteThreshold_ = t; }
00100   void setMajorityFraction( const double f ) { fractionForMajority_ = f; }
00101   //void setThreshPFClusterMustacheOutBarrel(double thresh){ threshPFClusterMustacheOutBarrel_ = thresh;}
00102   //void setThreshPFClusterMustacheOutEndcap(double thresh){ threshPFClusterMustacheOutEndcap_ = thresh;}
00103 
00104   void setCrackCorrections( bool applyCrackCorrections) { applyCrackCorrections_ = applyCrackCorrections;}
00105 
00106   std::auto_ptr<reco::SuperClusterCollection>
00107     getEBOutputSCCollection() { return superClustersEB_; }
00108   std::auto_ptr<reco::SuperClusterCollection>
00109     getEEOutputSCCollection() { return superClustersEE_; }  
00110 
00111   void loadAndSortPFClusters(const edm::View<reco::PFCluster>& ecalclusters,
00112                              const edm::View<reco::PFCluster>& psclusters);
00113   
00114   void run();
00115 
00116  private:  
00117 
00118   CalibratedClusterPtrVector _clustersEB;
00119   CalibratedClusterPtrVector _clustersEE;
00120   std::unordered_map<edm::Ptr<reco::PFCluster>, 
00121     edm::PtrVector<reco::PFCluster> > _psclustersforee;
00122   std::auto_ptr<reco::SuperClusterCollection> superClustersEB_;
00123   std::auto_ptr<reco::SuperClusterCollection> superClustersEE_;
00124   std::shared_ptr<PFEnergyCalibration> _pfEnergyCalibration;
00125   clustering_type _clustype;
00126   void buildAllSuperClusters(CalibratedClusterPtrVector&,
00127                              double seedthresh);
00128   void buildSuperCluster(CalibratedClusterPtr&,
00129                          CalibratedClusterPtrVector&); 
00130 
00131   bool verbose_;
00132 
00133   double threshPFClusterSeed_;
00134   double threshPFCluster_;
00135   double etawidthSuperCluster_;
00136   double phiwidthSuperCluster_;
00137 
00138   double threshPFClusterSeedBarrel_;
00139   double threshPFClusterBarrel_;
00140   double threshPFClusterSeedEndcap_;
00141   double threshPFClusterEndcap_;
00142   double threshPFClusterES_;
00143 
00144   double phiwidthSuperClusterBarrel_;
00145   double etawidthSuperClusterBarrel_;
00146   double phiwidthSuperClusterEndcap_;
00147   double etawidthSuperClusterEndcap_;
00148 
00149   bool doSatelliteClusterMerge_; //rock it
00150   double satelliteThreshold_, fractionForMajority_;
00151 
00152   bool _useDynamicDPhi;
00153 
00154   bool applyCrackCorrections_;
00155   
00156   bool usePS;
00157 
00158 };
00159 
00160 #endif