CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/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 "CondFormats/EgammaObjects/interface/GBRForest.h"
00009 #include "DataFormats/Common/interface/Handle.h"
00010 // #include "FWCore/Framework/interface/OrphanHandle.h"
00011 #include "DataFormats/Common/interface/OrphanHandle.h"
00012 
00013 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00014 #include "DataFormats/ParticleFlowReco/interface/PFBlockFwd.h"
00015 #include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
00016 
00017 // next include is necessary for inline functions. 
00018 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00019 
00020 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00021 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateElectronExtra.h"
00022 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateElectronExtraFwd.h"
00023 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidatePhotonExtra.h"
00024 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidatePhotonExtraFwd.h"
00025 #include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h"
00026 
00027 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
00028 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
00029 #include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h"
00030 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00031 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00032 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00033 #include "RecoParticleFlow/PFProducer/interface/PFCandConnector.h"
00034 
00036 
00042 class PFEnergyCalibration;
00043 class PFSCEnergyCalibration;
00044 class PFEnergyCalibrationHF;
00045 class PFElectronAlgo;
00046 class PFPhotonAlgo;
00047 
00048 class PFAlgo {
00049 
00050  public:
00051 
00053   PFAlgo();
00054 
00056   virtual ~PFAlgo();
00057 
00058   void setHOTag(bool ho) { useHO_ = ho;}
00059   void setAlgo( int algo ) {algo_ = algo;}
00060 
00061   void setDebug( bool debug ) {debug_ = debug; connector_.setDebug(debug_);}
00062 
00063   void setParameters(double nSigmaECAL,
00064                      double nSigmaHCAL, 
00065                      const boost::shared_ptr<PFEnergyCalibration>& calibration,
00066                      const boost::shared_ptr<PFEnergyCalibrationHF>& thepfEnergyCalibrationHF);
00067   
00068   void setCandConnectorParameters( const edm::ParameterSet& iCfgCandConnector ){
00069     connector_.setParameters(iCfgCandConnector);
00070   }
00071  
00072   void setCandConnectorParameters(bool bCorrect, 
00073                                   bool bCalibPrimary, 
00074                                   double dptRel_PrimaryTrack, 
00075                                   double dptRel_MergedTrack, 
00076                                   double ptErrorSecondary, 
00077                                   std::vector<double> nuclCalibFactors){
00078     connector_.setParameters(bCorrect, bCalibPrimary, dptRel_PrimaryTrack, dptRel_MergedTrack, ptErrorSecondary, nuclCalibFactors);
00079   }
00080 
00081 
00082   void setPFMuonAndFakeParameters(std::vector<double> muonHCAL,
00083                                   std::vector<double> muonECAL,
00084                                   std::vector<double> muonHO,
00085                                   double nSigmaTRACK,
00086                                   double ptError,
00087                                   std::vector<double> factors45,
00088                                   bool usePFMuonMomAssign,
00089                                   bool useBestMuonTrack);   
00090 
00091   void setPFEleParameters(double mvaEleCut,
00092                           std::string mvaWeightFileEleID,
00093                           bool usePFElectrons,
00094                           const boost::shared_ptr<PFSCEnergyCalibration>& thePFSCEnergyCalibration,
00095                           const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration,
00096                           double sumEtEcalIsoForEgammaSC_barrel,
00097                           double sumEtEcalIsoForEgammaSC_endcap,
00098                           double coneEcalIsoForEgammaSC,
00099                           double sumPtTrackIsoForEgammaSC_barrel,
00100                           double sumPtTrackIsoForEgammaSC_endcap,
00101                           unsigned int nTrackIsoForEgammaSC,
00102                           double coneTrackIsoForEgammaSC,
00103                           bool applyCrackCorrections=false,
00104                           bool usePFSCEleCalib=true,
00105                           bool useEGElectrons=false,
00106                           bool useEGammaSupercluster = true);
00107 
00108   void setPFPhotonParameters(bool usePFPhoton,
00109                              std::string mvaWeightFileConvID,
00110                              double mvaConvCut,
00111                              bool useReg,
00112                              std::string X0_Map,
00113                              const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration,
00114                              double sumPtTrackIsoForPhoton,
00115                              double sumPtTrackIsoSlopeForPhoton
00116 );  
00117 
00118   // void setPFPhotonRegWeights(
00119   //                 const GBRForest *LCorrForest,
00120   //                 const GBRForest *GCorrForest,
00121   //                 const GBRForest *ResForest
00122                              
00123   //                 ); 
00124   void setPFPhotonRegWeights(
00125                              const GBRForest *LCorrForestEB,
00126                              const GBRForest *LCorrForestEE,
00127                              const GBRForest *GCorrForestBarrel,
00128                              const GBRForest *GCorrForestEndcapHr9,
00129                              const GBRForest *GCorrForestEndcapLr9,
00130                              const GBRForest *PFEcalResolution
00131                              ); 
00132   void setPostHFCleaningParameters(bool postHFCleaning,
00133                                    double minHFCleaningPt,
00134                                    double minSignificance,
00135                                    double maxSignificance,
00136                                    double minSignificanceReduction,
00137                                    double maxDeltaPhiPt,
00138                                    double minDeltaMet);
00139 
00140   void setDisplacedVerticesParameters(bool rejectTracks_Bad,
00141                                       bool rejectTracks_Step45,
00142                                       bool usePFNuclearInteractions,
00143                                       bool usePFConversions,
00144                                       bool usePFDecays,
00145                                       double dptRel_DispVtx);
00146   
00147   //MIKEB : Parameters for the vertices..
00148   void setPFVertexParameters(bool useVertex,
00149                            const reco::VertexCollection& primaryVertices);                         
00150   
00151   // FlorianB : Collection of e/g electrons
00152   void setEGElectronCollection(const reco::GsfElectronCollection & egelectrons);
00153 
00157   void reconstructParticles( const reco::PFBlockHandle& blockHandle );
00158 
00160   virtual void reconstructParticles( const reco::PFBlockCollection& blocks );
00161   
00163   void checkCleaning( const reco::PFRecHitCollection& cleanedHF );
00164 
00165   // Post Muon Cleaning
00166   void postMuonCleaning( const edm::Handle<reco::MuonCollection>& muonh,
00167                          const reco::VertexCollection& primaryVertices );
00168 
00169   // Post Electron Extra Ref
00170   void setElectronExtraRef(const edm::OrphanHandle<reco::PFCandidateElectronExtraCollection >& extrah); 
00171            
00172   // Post Photon Extra Ref
00173   void setPhotonExtraRef(const edm::OrphanHandle<reco::PFCandidatePhotonExtraCollection >& pf_extrah);  
00174 
00176   const std::auto_ptr< reco::PFCandidateCollection >& pfCandidates() const {
00177     return pfCandidates_;
00178   }
00179 
00181   std::auto_ptr< reco::PFCandidateCollection> transferElectronCandidates()  {
00182     return pfElectronCandidates_;
00183   }
00184 
00186   // 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
00187   std::auto_ptr< reco::PFCandidateElectronExtraCollection> transferElectronExtra()  {
00188     std::auto_ptr< reco::PFCandidateElectronExtraCollection> result(new reco::PFCandidateElectronExtraCollection);
00189     result->insert(result->end(),pfElectronExtra_.begin(),pfElectronExtra_.end());
00190     return result;
00191   }
00192 
00193 
00195   // done this way because the pfPhotonExtra is needed later in the code to create the Refs and with an auto_ptr, it would be destroyed
00196   std::auto_ptr< reco::PFCandidatePhotonExtraCollection> transferPhotonExtra()  {
00197     std::auto_ptr< reco::PFCandidatePhotonExtraCollection> result(new reco::PFCandidatePhotonExtraCollection);
00198     result->insert(result->end(),pfPhotonExtra_.begin(),pfPhotonExtra_.end());
00199     return result;
00200   }
00201 
00202 
00204   std::auto_ptr< reco::PFCandidateCollection >& transferCleanedCandidates() {
00205     return pfCleanedCandidates_;
00206   }
00207   
00209   std::auto_ptr< reco::PFCandidateCollection > transferCosmicsMuonCleanedCandidates() {
00210     return pfCosmicsMuonCleanedCandidates_;
00211   }
00212 
00214   std::auto_ptr< reco::PFCandidateCollection > transferCleanedTrackerAndGlobalMuonCandidates() {
00215     return pfCleanedTrackerAndGlobalMuonCandidates_;
00216   }
00217 
00219   std::auto_ptr< reco::PFCandidateCollection > transferFakeMuonCleanedCandidates() {
00220     return pfFakeMuonCleanedCandidates_;
00221   }
00222 
00224   std::auto_ptr< reco::PFCandidateCollection > transferPunchThroughMuonCleanedCandidates() {
00225     return pfPunchThroughMuonCleanedCandidates_;
00226   }
00227 
00229   std::auto_ptr< reco::PFCandidateCollection > transferPunchThroughHadronCleanedCandidates() {
00230     return pfPunchThroughHadronCleanedCandidates_;
00231   }
00232 
00234   std::auto_ptr< reco::PFCandidateCollection > transferAddedMuonCandidates() {
00235     return pfAddedMuonCandidates_;
00236   }
00237    
00239   std::auto_ptr< reco::PFCandidateCollection >  transferCandidates() {
00240     return connector_.connect(pfCandidates_);
00241   }
00242   
00244   boost::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration() { 
00245     return calibration_;
00246   }
00247 
00248   friend std::ostream& operator<<(std::ostream& out, const PFAlgo& algo);
00249   
00250  protected:
00251 
00254   virtual void processBlock( const reco::PFBlockRef& blockref,
00255                              std::list<reco::PFBlockRef>& hcalBlockRefs, 
00256                              std::list<reco::PFBlockRef>& ecalBlockRefs ); 
00257   
00260   unsigned reconstructTrack( const reco::PFBlockElement& elt );
00261 
00267 
00268   unsigned reconstructCluster( const reco::PFCluster& cluster,
00269                                double particleEnergy,
00270                                bool useDirection = false,
00271                                double particleX=0.,
00272                                double particleY=0.,
00273                                double particleZ=0.);
00274 
00275 
00277   // double gammaCalibratedEnergy( double clusterEnergy ) const;
00278 
00281   // double neutralHadronCalibratedEnergy( double energyHCAL, 
00282   //                                    double energyECAL=-1) const;
00283   
00284 
00286   double neutralHadronEnergyResolution( double clusterEnergy,
00287                                         double clusterEta ) const;
00288 
00289  
00290   double nSigmaHCAL( double clusterEnergy, 
00291                      double clusterEta ) const;
00292 
00293   std::auto_ptr< reco::PFCandidateCollection >    pfCandidates_;
00295   std::auto_ptr< reco::PFCandidateCollection >    pfElectronCandidates_;
00297   std::auto_ptr< reco::PFCandidateCollection >    pfPhotonCandidates_;
00298   // the post-HF-cleaned candidates
00299   std::auto_ptr< reco::PFCandidateCollection >    pfCleanedCandidates_;
00301   std::auto_ptr< reco::PFCandidateCollection >    pfCosmicsMuonCleanedCandidates_;
00303   std::auto_ptr< reco::PFCandidateCollection >    pfCleanedTrackerAndGlobalMuonCandidates_;
00305   std::auto_ptr< reco::PFCandidateCollection >    pfFakeMuonCleanedCandidates_;
00307   std::auto_ptr< reco::PFCandidateCollection >    pfPunchThroughMuonCleanedCandidates_;
00309   std::auto_ptr< reco::PFCandidateCollection >    pfPunchThroughHadronCleanedCandidates_;
00311   std::auto_ptr< reco::PFCandidateCollection >    pfAddedMuonCandidates_;
00312 
00314   reco::PFCandidateElectronExtraCollection    pfElectronExtra_;
00316   reco::PFCandidatePhotonExtraCollection      pfPhotonExtra_; 
00317 
00319   void associatePSClusters(unsigned iEcal,
00320                            reco::PFBlockElement::Type psElementType,
00321                            const reco::PFBlock& block,
00322                            const edm::OwnVector< reco::PFBlockElement >& elements, 
00323                            const reco::PFBlock::LinkData& linkData, 
00324                            std::vector<bool>& active, 
00325                            std::vector<double>& psEne);
00326 
00327   bool isFromSecInt(const reco::PFBlockElement& eTrack,  std::string order) const;
00328 
00329 
00330   // Post HF Cleaning
00331   void postCleaning();
00332 
00333 
00334 
00335 
00336  private:
00339   reco::PFBlockRef createBlockRef( const reco::PFBlockCollection& blocks, 
00340                                    unsigned bi );
00341     
00343   reco::PFBlockHandle    blockHandle_;
00344 
00346   double             nSigmaECAL_;
00347   
00349   double             nSigmaHCAL_;
00350   
00351   boost::shared_ptr<PFEnergyCalibration>  calibration_;
00352   boost::shared_ptr<PFEnergyCalibrationHF>  thepfEnergyCalibrationHF_;
00353   boost::shared_ptr<PFSCEnergyCalibration> thePFSCEnergyCalibration_;
00354 
00355   bool               useHO_;
00356   int                algo_;
00357   bool               debug_;
00358 
00360   std::string mvaWeightFileEleID_;
00361   std::vector<double> setchi2Values_;
00362   double mvaEleCut_;
00363   bool usePFElectrons_;
00364   bool usePFPhotons_;
00365   bool applyCrackCorrectionsElectrons_;
00366   bool usePFSCEleCalib_;
00367   bool useEGElectrons_;
00368   bool useEGammaSupercluster_;
00369   double sumEtEcalIsoForEgammaSC_barrel_;
00370   double sumEtEcalIsoForEgammaSC_endcap_;
00371   double coneEcalIsoForEgammaSC_;
00372   double sumPtTrackIsoForEgammaSC_barrel_;
00373   double sumPtTrackIsoForEgammaSC_endcap_;
00374   double coneTrackIsoForEgammaSC_;
00375   unsigned int nTrackIsoForEgammaSC_;
00376   PFElectronAlgo *pfele_;
00377   PFPhotonAlgo *pfpho_;
00378 
00379   // Option to let PF decide the muon momentum
00380   bool usePFMuonMomAssign_;
00381 
00384   bool rejectTracks_Bad_;
00385   bool rejectTracks_Step45_;
00386 
00387   bool usePFNuclearInteractions_;
00388   bool usePFConversions_;
00389   bool usePFDecays_;
00390 
00393   double dptRel_DispVtx_;
00394 
00395 
00398   PFCandConnector connector_;
00399     
00401   std::vector<double> muonHCAL_;
00402   std::vector<double> muonECAL_;
00403   std::vector<double> muonHO_;
00404   double nSigmaTRACK_;
00405   double ptError_;
00406   std::vector<double> factors45_;
00407 
00408   // Parameters for post HF cleaning
00409   bool postHFCleaning_;
00410   bool postMuonCleaning_;
00411   double minHFCleaningPt_;
00412   double minSignificance_;
00413   double maxSignificance_;
00414   double minSignificanceReduction_;
00415   double maxDeltaPhiPt_;
00416   double minDeltaMet_;
00417   double useBestMuonTrack_;
00418 
00419   //MIKE -May19th: Add option for the vertices....
00420   reco::Vertex       primaryVertex_;
00421   bool               useVertices_; 
00422 
00423 };
00424 
00425 
00426 #endif
00427 
00428