CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoParticleFlow/PFProducer/interface/PFAlgo.h

Go to the documentation of this file.
00001 #ifndef RecoParticleFlow_PFProducer_PFAlgo_h
00002 #define RecoParticleFlow_PFProducer_PFAlgo_h 
00003 
00004 #include <iostream>
00005 
00006 
00007 // #include "FWCore/Framework/interface/Handle.h"
00008 #include "DataFormats/Common/interface/Handle.h"
00009 // #include "FWCore/Framework/interface/OrphanHandle.h"
00010 #include "DataFormats/Common/interface/OrphanHandle.h"
00011 
00012 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00013 #include "DataFormats/ParticleFlowReco/interface/PFBlockFwd.h"
00014 #include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
00015 
00016 // next include is necessary for inline functions. 
00017 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00018 
00019 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00020 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateElectronExtra.h"
00021 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateElectronExtraFwd.h"
00022 #include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h"
00023 
00024 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
00025 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
00026 #include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h"
00027 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00028 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00029 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00030 #include "RecoParticleFlow/PFProducer/interface/PFCandConnector.h"
00031 
00033 
00039 class PFEnergyCalibration;
00040 class PFSCEnergyCalibration;
00041 class PFEnergyCalibrationHF;
00042 class PFElectronAlgo;
00043 class PFConversionAlgo;
00044 class PFPhotonAlgo;
00045 
00046 class PFAlgo {
00047 
00048  public:
00049 
00051   PFAlgo();
00052 
00054   virtual ~PFAlgo();
00055 
00056   void setAlgo( int algo ) {algo_ = algo;}
00057 
00058   void setDebug( bool debug ) {debug_ = debug; connector_.setDebug(debug_);}
00059 
00060   void setParameters(double nSigmaECAL,
00061                      double nSigmaHCAL, 
00062                      const boost::shared_ptr<PFEnergyCalibration>& calibration,
00063                      const boost::shared_ptr<PFEnergyCalibrationHF>& thepfEnergyCalibrationHF);
00064   
00065   void setCandConnectorParameters( const edm::ParameterSet& iCfgCandConnector ){
00066     connector_.setParameters(iCfgCandConnector);
00067   }
00068  
00069   void setCandConnectorParameters(bool bCorrect, 
00070                                   bool bCalibPrimary, 
00071                                   double dptRel_PrimaryTrack, 
00072                                   double dptRel_MergedTrack, 
00073                                   double ptErrorSecondary, 
00074                                   std::vector<double> nuclCalibFactors){
00075     connector_.setParameters(bCorrect, bCalibPrimary, dptRel_PrimaryTrack, dptRel_MergedTrack, ptErrorSecondary, nuclCalibFactors);
00076   }
00077 
00078 
00079   void setPFMuonAndFakeParameters(std::vector<double> muonHCAL,
00080                                   std::vector<double> muonECAL,
00081                                   double nSigmaTRACK,
00082                                   double ptError,
00083                                   std::vector<double> factors45,
00084                                   bool usePFMuonMomAssign);   
00085 
00086   void setPFEleParameters(double mvaEleCut,
00087                           std::string mvaWeightFileEleID,
00088                           bool usePFElectrons,
00089                           const boost::shared_ptr<PFSCEnergyCalibration>& thePFSCEnergyCalibration,
00090                           const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration,
00091                           double sumEtEcalIsoForEgammaSC_barrel,
00092                           double sumEtEcalIsoForEgammaSC_endcap,
00093                           double coneEcalIsoForEgammaSC,
00094                           double sumPtTrackIsoForEgammaSC_barrel,
00095                           double sumPtTrackIsoForEgammaSC_endcap,
00096                           unsigned int nTrackIsoForEgammaSC,
00097                           double coneTrackIsoForEgammaSC,
00098                           bool applyCrackCorrections=false,
00099                           bool usePFSCEleCalib=true,
00100                           bool useEGElectrons=false,
00101                           bool useEGammaSupercluster = true);
00102 
00103   void setPFPhotonParameters(bool usePFPhoton,
00104                              std::string mvaWeightFileConvID,
00105                              double mvaConvCut,
00106                              const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration);  
00107 
00108   void setPostHFCleaningParameters(bool postHFCleaning,
00109                                    double minHFCleaningPt,
00110                                    double minSignificance,
00111                                    double maxSignificance,
00112                                    double minSignificanceReduction,
00113                                    double maxDeltaPhiPt,
00114                                    double minDeltaMet);
00115 
00116   void setDisplacedVerticesParameters(bool rejectTracks_Bad,
00117                                       bool rejectTracks_Step45,
00118                                       bool usePFNuclearInteractions,
00119                                       bool usePFConversions,
00120                                       bool usePFDecays,
00121                                       double dptRel_DispVtx);
00122   
00123   //MIKEB : Parameters for the vertices..
00124   void setPFVertexParameters(bool useVertex,
00125                            const reco::VertexCollection& primaryVertices);                         
00126   
00127   // FlorianB : Collection of e/g electrons
00128   void setEGElectronCollection(const reco::GsfElectronCollection & egelectrons);
00129 
00133   void reconstructParticles( const reco::PFBlockHandle& blockHandle );
00134 
00136   virtual void reconstructParticles( const reco::PFBlockCollection& blocks );
00137   
00139   void checkCleaning( const reco::PFRecHitCollection& cleanedHF );
00140 
00141   // Post Muon Cleaning
00142   void postMuonCleaning( const edm::Handle<reco::MuonCollection>& muonh,
00143                          const reco::VertexCollection& primaryVertices );
00144 
00145   // Post Electron Extra Ref
00146   void setElectronExtraRef(const edm::OrphanHandle<reco::PFCandidateElectronExtraCollection >& extrah);            
00147 
00149   const std::auto_ptr< reco::PFCandidateCollection >& pfCandidates() const {
00150     return pfCandidates_;
00151   }
00152 
00154   std::auto_ptr< reco::PFCandidateCollection> transferElectronCandidates()  {
00155     return pfElectronCandidates_;
00156   }
00157 
00159   // done this way because the pfElectronExtra is needed later in the code to create the Refs and with an auto_ptr, it would be destroyed
00160   std::auto_ptr< reco::PFCandidateElectronExtraCollection> transferElectronExtra()  {
00161     std::auto_ptr< reco::PFCandidateElectronExtraCollection> result(new reco::PFCandidateElectronExtraCollection);
00162     result->insert(result->end(),pfElectronExtra_.begin(),pfElectronExtra_.end());
00163     return result;
00164   }
00165 
00166 
00168   std::auto_ptr< reco::PFCandidateCollection >& transferCleanedCandidates() {
00169     return pfCleanedCandidates_;
00170   }
00171   
00173   std::auto_ptr< reco::PFCandidateCollection > transferCosmicsMuonCleanedCandidates() {
00174     return pfCosmicsMuonCleanedCandidates_;
00175   }
00176 
00178   std::auto_ptr< reco::PFCandidateCollection > transferCleanedTrackerAndGlobalMuonCandidates() {
00179     return pfCleanedTrackerAndGlobalMuonCandidates_;
00180   }
00181 
00183   std::auto_ptr< reco::PFCandidateCollection > transferFakeMuonCleanedCandidates() {
00184     return pfFakeMuonCleanedCandidates_;
00185   }
00186 
00188   std::auto_ptr< reco::PFCandidateCollection > transferPunchThroughMuonCleanedCandidates() {
00189     return pfPunchThroughMuonCleanedCandidates_;
00190   }
00191 
00193   std::auto_ptr< reco::PFCandidateCollection > transferPunchThroughHadronCleanedCandidates() {
00194     return pfPunchThroughHadronCleanedCandidates_;
00195   }
00196 
00198   std::auto_ptr< reco::PFCandidateCollection > transferAddedMuonCandidates() {
00199     return pfAddedMuonCandidates_;
00200   }
00201    
00203   std::auto_ptr< reco::PFCandidateCollection >  transferCandidates() {
00204     return connector_.connect(pfCandidates_);
00205   }
00206   
00208   boost::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration() { 
00209     return calibration_;
00210   }
00211 
00212   friend std::ostream& operator<<(std::ostream& out, const PFAlgo& algo);
00213   
00214  protected:
00215 
00218   virtual void processBlock( const reco::PFBlockRef& blockref,
00219                              std::list<reco::PFBlockRef>& hcalBlockRefs, 
00220                              std::list<reco::PFBlockRef>& ecalBlockRefs ); 
00221   
00224   unsigned reconstructTrack( const reco::PFBlockElement& elt );
00225 
00231 
00232   unsigned reconstructCluster( const reco::PFCluster& cluster,
00233                                double particleEnergy,
00234                                bool useDirection = false,
00235                                double particleX=0.,
00236                                double particleY=0.,
00237                                double particleZ=0.);
00238 
00239 
00241   // double gammaCalibratedEnergy( double clusterEnergy ) const;
00242 
00245   // double neutralHadronCalibratedEnergy( double energyHCAL, 
00246   //                                    double energyECAL=-1) const;
00247   
00248 
00250   double neutralHadronEnergyResolution( double clusterEnergy,
00251                                         double clusterEta ) const;
00252 
00253  
00254   double nSigmaHCAL( double clusterEnergy, 
00255                      double clusterEta ) const;
00256 
00257   std::auto_ptr< reco::PFCandidateCollection >    pfCandidates_;
00259   std::auto_ptr< reco::PFCandidateCollection >    pfElectronCandidates_;
00261   std::auto_ptr< reco::PFCandidateCollection >    pfPhotonCandidates_;
00262   // the post-HF-cleaned candidates
00263   std::auto_ptr< reco::PFCandidateCollection >    pfCleanedCandidates_;
00265   std::auto_ptr< reco::PFCandidateCollection >    pfCosmicsMuonCleanedCandidates_;
00267   std::auto_ptr< reco::PFCandidateCollection >    pfCleanedTrackerAndGlobalMuonCandidates_;
00269   std::auto_ptr< reco::PFCandidateCollection >    pfFakeMuonCleanedCandidates_;
00271   std::auto_ptr< reco::PFCandidateCollection >    pfPunchThroughMuonCleanedCandidates_;
00273   std::auto_ptr< reco::PFCandidateCollection >    pfPunchThroughHadronCleanedCandidates_;
00275   std::auto_ptr< reco::PFCandidateCollection >    pfAddedMuonCandidates_;
00276 
00278   reco::PFCandidateElectronExtraCollection    pfElectronExtra_;
00279 
00282   bool isSatelliteCluster( const reco::PFRecTrack& track,
00283                            const reco::PFCluster& cluster );
00284 
00286   void associatePSClusters(unsigned iEcal,
00287                            reco::PFBlockElement::Type psElementType,
00288                            const reco::PFBlock& block,
00289                            const edm::OwnVector< reco::PFBlockElement >& elements, 
00290                            const reco::PFBlock::LinkData& linkData, 
00291                            std::vector<bool>& active, 
00292                            std::vector<double>& psEne);
00293 
00294   bool isFromSecInt(const reco::PFBlockElement& eTrack,  std::string order) const;
00295 
00296 
00297   // Post HF Cleaning
00298   void postCleaning();
00299 
00300 
00301 
00302 
00303  private:
00306   reco::PFBlockRef createBlockRef( const reco::PFBlockCollection& blocks, 
00307                                    unsigned bi );
00308     
00310   reco::PFBlockHandle    blockHandle_;
00311 
00313   double             nSigmaECAL_;
00314   
00316   double             nSigmaHCAL_;
00317   
00318   boost::shared_ptr<PFEnergyCalibration>  calibration_;
00319   boost::shared_ptr<PFEnergyCalibrationHF>  thepfEnergyCalibrationHF_;
00320   boost::shared_ptr<PFSCEnergyCalibration> thePFSCEnergyCalibration_;
00321 
00322   // std::vector<unsigned> hcalBlockUsed_;
00323   
00324   int                algo_;
00325   bool               debug_;
00326 
00328   std::string mvaWeightFileEleID_;
00329   std::vector<double> setchi2Values_;
00330   double mvaEleCut_;
00331   bool usePFElectrons_;
00332   bool usePFPhotons_;
00333   bool applyCrackCorrectionsElectrons_;
00334   bool usePFSCEleCalib_;
00335   bool useEGElectrons_;
00336   bool useEGammaSupercluster_;
00337   double sumEtEcalIsoForEgammaSC_barrel_;
00338   double sumEtEcalIsoForEgammaSC_endcap_;
00339   double coneEcalIsoForEgammaSC_;
00340   double sumPtTrackIsoForEgammaSC_barrel_;
00341   double sumPtTrackIsoForEgammaSC_endcap_;
00342   double coneTrackIsoForEgammaSC_;
00343   unsigned int nTrackIsoForEgammaSC_;
00344   PFElectronAlgo *pfele_;
00345   PFPhotonAlgo *pfpho_;
00346 
00347   // Option to let PF decide the muon momentum
00348   bool usePFMuonMomAssign_;
00349 
00352   bool rejectTracks_Bad_;
00353   bool rejectTracks_Step45_;
00354 
00355   bool usePFNuclearInteractions_;
00356   bool usePFConversions_;
00357   PFConversionAlgo* pfConversion_;
00358   bool usePFDecays_;
00359 
00362   double dptRel_DispVtx_;
00363 
00364 
00367   PFCandConnector connector_;
00368     
00370   std::vector<double> muonHCAL_;
00371   std::vector<double> muonECAL_;
00372   double nSigmaTRACK_;
00373   double ptError_;
00374   std::vector<double> factors45_;
00375 
00376   // Parameters for post HF cleaning
00377   bool postHFCleaning_;
00378   bool postMuonCleaning_;
00379   double minHFCleaningPt_;
00380   double minSignificance_;
00381   double maxSignificance_;
00382   double minSignificanceReduction_;
00383   double maxDeltaPhiPt_;
00384   double minDeltaMet_;
00385 
00386   //MIKE -May19th: Add option for the vertices....
00387   reco::Vertex       primaryVertex_;
00388   bool               useVertices_; 
00389 
00390 };
00391 
00392 
00393 #endif
00394 
00395