CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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 #include "RecoParticleFlow/PFProducer/interface/PFMuonAlgo.h"
00035 
00037 
00043 class PFEnergyCalibration;
00044 class PFSCEnergyCalibration;
00045 class PFEnergyCalibrationHF;
00046 class PFElectronAlgo;
00047 class PFPhotonAlgo;
00048 class PFMuonAlgo;
00049 
00050 class PFAlgo {
00051 
00052  public:
00053 
00055   PFAlgo();
00056 
00058   virtual ~PFAlgo();
00059 
00060   void setHOTag(bool ho) { useHO_ = ho;}
00061   void setAlgo( int algo ) {algo_ = algo;}
00062   void setPFMuonAlgo(PFMuonAlgo* algo) {pfmu_ =algo;}
00063   void setMuonHandle(const edm::Handle<reco::MuonCollection>&);
00064   void setDebug( bool debug ) {debug_ = debug; connector_.setDebug(debug_);}
00065 
00066   void setParameters(double nSigmaECAL,
00067                      double nSigmaHCAL, 
00068                      const boost::shared_ptr<PFEnergyCalibration>& calibration,
00069                      const boost::shared_ptr<PFEnergyCalibrationHF>& thepfEnergyCalibrationHF);
00070   
00071   void setCandConnectorParameters( const edm::ParameterSet& iCfgCandConnector ){
00072     connector_.setParameters(iCfgCandConnector);
00073   }
00074  
00075   void setCandConnectorParameters(bool bCorrect, 
00076                                   bool bCalibPrimary, 
00077                                   double dptRel_PrimaryTrack, 
00078                                   double dptRel_MergedTrack, 
00079                                   double ptErrorSecondary, 
00080                                   std::vector<double> nuclCalibFactors){
00081     connector_.setParameters(bCorrect, bCalibPrimary, dptRel_PrimaryTrack, dptRel_MergedTrack, ptErrorSecondary, nuclCalibFactors);
00082   }
00083 
00084 
00085   void setPFMuonAndFakeParameters(const edm::ParameterSet& pset);
00086   
00087   PFMuonAlgo*  getPFMuonAlgo();
00088   
00089   void setPFEleParameters(double mvaEleCut,
00090                           std::string mvaWeightFileEleID,
00091                           bool usePFElectrons,
00092                           const boost::shared_ptr<PFSCEnergyCalibration>& thePFSCEnergyCalibration,
00093                           const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration,
00094                           double sumEtEcalIsoForEgammaSC_barrel,
00095                           double sumEtEcalIsoForEgammaSC_endcap,
00096                           double coneEcalIsoForEgammaSC,
00097                           double sumPtTrackIsoForEgammaSC_barrel,
00098                           double sumPtTrackIsoForEgammaSC_endcap,
00099                           unsigned int nTrackIsoForEgammaSC,
00100                           double coneTrackIsoForEgammaSC,
00101                           bool applyCrackCorrections=false,
00102                           bool usePFSCEleCalib=true,
00103                           bool useEGElectrons=false,
00104                           bool useEGammaSupercluster = true);
00105 
00106   void setPFPhotonParameters(bool usePFPhoton,
00107                              std::string mvaWeightFileConvID,
00108                              double mvaConvCut,
00109                              bool useReg,
00110                              std::string X0_Map,
00111                              const boost::shared_ptr<PFEnergyCalibration>& thePFEnergyCalibration,
00112                              double sumPtTrackIsoForPhoton,
00113                              double sumPtTrackIsoSlopeForPhoton
00114 );  
00115 
00116   // void setPFPhotonRegWeights(
00117   //                 const GBRForest *LCorrForest,
00118   //                 const GBRForest *GCorrForest,
00119   //                 const GBRForest *ResForest
00120                              
00121   //                 ); 
00122   void setPFPhotonRegWeights(
00123                              const GBRForest *LCorrForestEB,
00124                              const GBRForest *LCorrForestEE,
00125                              const GBRForest *GCorrForestBarrel,
00126                              const GBRForest *GCorrForestEndcapHr9,
00127                              const GBRForest *GCorrForestEndcapLr9,
00128                              const GBRForest *PFEcalResolution
00129                              ); 
00130   void setPostHFCleaningParameters(bool postHFCleaning,
00131                                    double minHFCleaningPt,
00132                                    double minSignificance,
00133                                    double maxSignificance,
00134                                    double minSignificanceReduction,
00135                                    double maxDeltaPhiPt,
00136                                    double minDeltaMet);
00137 
00138   void setDisplacedVerticesParameters(bool rejectTracks_Bad,
00139                                       bool rejectTracks_Step45,
00140                                       bool usePFNuclearInteractions,
00141                                       bool usePFConversions,
00142                                       bool usePFDecays,
00143                                       double dptRel_DispVtx);
00144   
00145   //MIKEB : Parameters for the vertices..
00146   void setPFVertexParameters(bool useVertex,
00147                              const reco::VertexCollection*  primaryVertices);                      
00148   
00149   // FlorianB : Collection of e/g electrons
00150   void setEGElectronCollection(const reco::GsfElectronCollection & egelectrons);
00151 
00155   void reconstructParticles( const reco::PFBlockHandle& blockHandle );
00156 
00158   virtual void reconstructParticles( const reco::PFBlockCollection& blocks );
00159   
00161   void checkCleaning( const reco::PFRecHitCollection& cleanedHF );
00162 
00163   // Post Electron Extra Ref
00164   void setElectronExtraRef(const edm::OrphanHandle<reco::PFCandidateElectronExtraCollection >& extrah); 
00165            
00166   // Post Photon Extra Ref
00167   void setPhotonExtraRef(const edm::OrphanHandle<reco::PFCandidatePhotonExtraCollection >& pf_extrah);  
00168 
00170   const std::auto_ptr< reco::PFCandidateCollection >& pfCandidates() const {
00171     return pfCandidates_;
00172   }
00173 
00175   std::auto_ptr< reco::PFCandidateCollection> transferElectronCandidates()  {
00176     return pfElectronCandidates_;
00177   }
00178 
00180   // 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
00181   std::auto_ptr< reco::PFCandidateElectronExtraCollection> transferElectronExtra()  {
00182     std::auto_ptr< reco::PFCandidateElectronExtraCollection> result(new reco::PFCandidateElectronExtraCollection);
00183     result->insert(result->end(),pfElectronExtra_.begin(),pfElectronExtra_.end());
00184     return result;
00185   }
00186 
00187 
00189   // 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
00190   std::auto_ptr< reco::PFCandidatePhotonExtraCollection> transferPhotonExtra()  {
00191     std::auto_ptr< reco::PFCandidatePhotonExtraCollection> result(new reco::PFCandidatePhotonExtraCollection);
00192     result->insert(result->end(),pfPhotonExtra_.begin(),pfPhotonExtra_.end());
00193     return result;
00194   }
00195 
00196 
00198   std::auto_ptr< reco::PFCandidateCollection >& transferCleanedCandidates() {
00199     return pfCleanedCandidates_;
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   
00225   unsigned reconstructTrack( const reco::PFBlockElement& elt,bool allowLoose= false);
00226 
00232 
00233   unsigned reconstructCluster( const reco::PFCluster& cluster,
00234                                double particleEnergy,
00235                                bool useDirection = false,
00236                                double particleX=0.,
00237                                double particleY=0.,
00238                                double particleZ=0.);
00239 
00240 
00242   // double gammaCalibratedEnergy( double clusterEnergy ) const;
00243 
00246   // double neutralHadronCalibratedEnergy( double energyHCAL, 
00247   //                                    double energyECAL=-1) const;
00248   
00249 
00251   double neutralHadronEnergyResolution( double clusterEnergy,
00252                                         double clusterEta ) const;
00253 
00254  
00255   double nSigmaHCAL( double clusterEnergy, 
00256                      double clusterEta ) const;
00257 
00258   std::auto_ptr< reco::PFCandidateCollection >    pfCandidates_;
00260   std::auto_ptr< reco::PFCandidateCollection >    pfElectronCandidates_;
00262   std::auto_ptr< reco::PFCandidateCollection >    pfPhotonCandidates_;
00263   // the post-HF-cleaned candidates
00264   std::auto_ptr< reco::PFCandidateCollection >    pfCleanedCandidates_;
00265 
00267   reco::PFCandidateElectronExtraCollection    pfElectronExtra_;
00269   reco::PFCandidatePhotonExtraCollection      pfPhotonExtra_; 
00270 
00272   void associatePSClusters(unsigned iEcal,
00273                            reco::PFBlockElement::Type psElementType,
00274                            const reco::PFBlock& block,
00275                            const edm::OwnVector< reco::PFBlockElement >& elements, 
00276                            const reco::PFBlock::LinkData& linkData, 
00277                            std::vector<bool>& active, 
00278                            std::vector<double>& psEne);
00279 
00280   bool isFromSecInt(const reco::PFBlockElement& eTrack,  std::string order) const;
00281 
00282 
00283   // Post HF Cleaning
00284   void postCleaning();
00285 
00286 
00287 
00288 
00289  private:
00292   reco::PFBlockRef createBlockRef( const reco::PFBlockCollection& blocks, 
00293                                    unsigned bi );
00294     
00296   reco::PFBlockHandle    blockHandle_;
00297 
00299   double             nSigmaECAL_;
00300   
00302   double             nSigmaHCAL_;
00303   
00304   boost::shared_ptr<PFEnergyCalibration>  calibration_;
00305   boost::shared_ptr<PFEnergyCalibrationHF>  thepfEnergyCalibrationHF_;
00306   boost::shared_ptr<PFSCEnergyCalibration> thePFSCEnergyCalibration_;
00307 
00308   bool               useHO_;
00309   int                algo_;
00310   bool               debug_;
00311 
00313   std::string mvaWeightFileEleID_;
00314   std::vector<double> setchi2Values_;
00315   double mvaEleCut_;
00316   bool usePFElectrons_;
00317   bool usePFPhotons_;
00318   bool applyCrackCorrectionsElectrons_;
00319   bool usePFSCEleCalib_;
00320   bool useEGElectrons_;
00321   bool useEGammaSupercluster_;
00322   double sumEtEcalIsoForEgammaSC_barrel_;
00323   double sumEtEcalIsoForEgammaSC_endcap_;
00324   double coneEcalIsoForEgammaSC_;
00325   double sumPtTrackIsoForEgammaSC_barrel_;
00326   double sumPtTrackIsoForEgammaSC_endcap_;
00327   double coneTrackIsoForEgammaSC_;
00328   unsigned int nTrackIsoForEgammaSC_;
00329   PFElectronAlgo *pfele_;
00330   PFPhotonAlgo *pfpho_;
00331   PFMuonAlgo *pfmu_;
00332 
00333   // Option to let PF decide the muon momentum
00334   bool usePFMuonMomAssign_;
00335 
00338   bool rejectTracks_Bad_;
00339   bool rejectTracks_Step45_;
00340 
00341   bool usePFNuclearInteractions_;
00342   bool usePFConversions_;
00343   bool usePFDecays_;
00344 
00347   double dptRel_DispVtx_;
00348 
00349 
00352   PFCandConnector connector_;
00353     
00355   std::vector<double> muonHCAL_;
00356   std::vector<double> muonECAL_;
00357   std::vector<double> muonHO_;
00358   double nSigmaTRACK_;
00359   double ptError_;
00360   std::vector<double> factors45_;
00361 
00362   // Parameters for post HF cleaning
00363   bool postHFCleaning_;
00364   bool postMuonCleaning_;
00365   double minHFCleaningPt_;
00366   double minSignificance_;
00367   double maxSignificance_;
00368   double minSignificanceReduction_;
00369   double maxDeltaPhiPt_;
00370   double minDeltaMet_;
00371   double useBestMuonTrack_;
00372 
00373   //MIKE -May19th: Add option for the vertices....
00374   reco::Vertex       primaryVertex_;
00375   bool               useVertices_; 
00376 
00377   edm::Handle<reco::MuonCollection> muonHandle_;
00378 
00379 };
00380 
00381 
00382 #endif
00383 
00384