CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/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 setPostHFCleaningParameters(bool postHFCleaning,
00125                                    double minHFCleaningPt,
00126                                    double minSignificance,
00127                                    double maxSignificance,
00128                                    double minSignificanceReduction,
00129                                    double maxDeltaPhiPt,
00130                                    double minDeltaMet);
00131 
00132   void setDisplacedVerticesParameters(bool rejectTracks_Bad,
00133                                       bool rejectTracks_Step45,
00134                                       bool usePFNuclearInteractions,
00135                                       bool usePFConversions,
00136                                       bool usePFDecays,
00137                                       double dptRel_DispVtx);
00138   
00139   //MIKEB : Parameters for the vertices..
00140   void setPFVertexParameters(bool useVertex,
00141                            const reco::VertexCollection& primaryVertices);                         
00142   
00143   // FlorianB : Collection of e/g electrons
00144   void setEGElectronCollection(const reco::GsfElectronCollection & egelectrons);
00145 
00149   void reconstructParticles( const reco::PFBlockHandle& blockHandle );
00150 
00152   virtual void reconstructParticles( const reco::PFBlockCollection& blocks );
00153   
00155   void checkCleaning( const reco::PFRecHitCollection& cleanedHF );
00156 
00157   // Post Muon Cleaning
00158   void postMuonCleaning( const edm::Handle<reco::MuonCollection>& muonh,
00159                          const reco::VertexCollection& primaryVertices );
00160 
00161   // Post Electron Extra Ref
00162   void setElectronExtraRef(const edm::OrphanHandle<reco::PFCandidateElectronExtraCollection >& extrah); 
00163            
00164   // Post Photon Extra Ref
00165   void setPhotonExtraRef(const edm::OrphanHandle<reco::PFCandidatePhotonExtraCollection >& pf_extrah);  
00166 
00168   const std::auto_ptr< reco::PFCandidateCollection >& pfCandidates() const {
00169     return pfCandidates_;
00170   }
00171 
00173   std::auto_ptr< reco::PFCandidateCollection> transferElectronCandidates()  {
00174     return pfElectronCandidates_;
00175   }
00176 
00178   // 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
00179   std::auto_ptr< reco::PFCandidateElectronExtraCollection> transferElectronExtra()  {
00180     std::auto_ptr< reco::PFCandidateElectronExtraCollection> result(new reco::PFCandidateElectronExtraCollection);
00181     result->insert(result->end(),pfElectronExtra_.begin(),pfElectronExtra_.end());
00182     return result;
00183   }
00184 
00185 
00187   // 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
00188   std::auto_ptr< reco::PFCandidatePhotonExtraCollection> transferPhotonExtra()  {
00189     std::auto_ptr< reco::PFCandidatePhotonExtraCollection> result(new reco::PFCandidatePhotonExtraCollection);
00190     result->insert(result->end(),pfPhotonExtra_.begin(),pfPhotonExtra_.end());
00191     return result;
00192   }
00193 
00194 
00196   std::auto_ptr< reco::PFCandidateCollection >& transferCleanedCandidates() {
00197     return pfCleanedCandidates_;
00198   }
00199   
00201   std::auto_ptr< reco::PFCandidateCollection > transferCosmicsMuonCleanedCandidates() {
00202     return pfCosmicsMuonCleanedCandidates_;
00203   }
00204 
00206   std::auto_ptr< reco::PFCandidateCollection > transferCleanedTrackerAndGlobalMuonCandidates() {
00207     return pfCleanedTrackerAndGlobalMuonCandidates_;
00208   }
00209 
00211   std::auto_ptr< reco::PFCandidateCollection > transferFakeMuonCleanedCandidates() {
00212     return pfFakeMuonCleanedCandidates_;
00213   }
00214 
00216   std::auto_ptr< reco::PFCandidateCollection > transferPunchThroughMuonCleanedCandidates() {
00217     return pfPunchThroughMuonCleanedCandidates_;
00218   }
00219 
00221   std::auto_ptr< reco::PFCandidateCollection > transferPunchThroughHadronCleanedCandidates() {
00222     return pfPunchThroughHadronCleanedCandidates_;
00223   }
00224 
00226   std::auto_ptr< reco::PFCandidateCollection > transferAddedMuonCandidates() {
00227     return pfAddedMuonCandidates_;
00228   }
00229    
00231   std::auto_ptr< reco::PFCandidateCollection >  transferCandidates() {
00232     return connector_.connect(pfCandidates_);
00233   }
00234   
00236   boost::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration() { 
00237     return calibration_;
00238   }
00239 
00240   friend std::ostream& operator<<(std::ostream& out, const PFAlgo& algo);
00241   
00242  protected:
00243 
00246   virtual void processBlock( const reco::PFBlockRef& blockref,
00247                              std::list<reco::PFBlockRef>& hcalBlockRefs, 
00248                              std::list<reco::PFBlockRef>& ecalBlockRefs ); 
00249   
00252   unsigned reconstructTrack( const reco::PFBlockElement& elt );
00253 
00259 
00260   unsigned reconstructCluster( const reco::PFCluster& cluster,
00261                                double particleEnergy,
00262                                bool useDirection = false,
00263                                double particleX=0.,
00264                                double particleY=0.,
00265                                double particleZ=0.);
00266 
00267 
00269   // double gammaCalibratedEnergy( double clusterEnergy ) const;
00270 
00273   // double neutralHadronCalibratedEnergy( double energyHCAL, 
00274   //                                    double energyECAL=-1) const;
00275   
00276 
00278   double neutralHadronEnergyResolution( double clusterEnergy,
00279                                         double clusterEta ) const;
00280 
00281  
00282   double nSigmaHCAL( double clusterEnergy, 
00283                      double clusterEta ) const;
00284 
00285   std::auto_ptr< reco::PFCandidateCollection >    pfCandidates_;
00287   std::auto_ptr< reco::PFCandidateCollection >    pfElectronCandidates_;
00289   std::auto_ptr< reco::PFCandidateCollection >    pfPhotonCandidates_;
00290   // the post-HF-cleaned candidates
00291   std::auto_ptr< reco::PFCandidateCollection >    pfCleanedCandidates_;
00293   std::auto_ptr< reco::PFCandidateCollection >    pfCosmicsMuonCleanedCandidates_;
00295   std::auto_ptr< reco::PFCandidateCollection >    pfCleanedTrackerAndGlobalMuonCandidates_;
00297   std::auto_ptr< reco::PFCandidateCollection >    pfFakeMuonCleanedCandidates_;
00299   std::auto_ptr< reco::PFCandidateCollection >    pfPunchThroughMuonCleanedCandidates_;
00301   std::auto_ptr< reco::PFCandidateCollection >    pfPunchThroughHadronCleanedCandidates_;
00303   std::auto_ptr< reco::PFCandidateCollection >    pfAddedMuonCandidates_;
00304 
00306   reco::PFCandidateElectronExtraCollection    pfElectronExtra_;
00308   reco::PFCandidatePhotonExtraCollection      pfPhotonExtra_; 
00309 
00311   void associatePSClusters(unsigned iEcal,
00312                            reco::PFBlockElement::Type psElementType,
00313                            const reco::PFBlock& block,
00314                            const edm::OwnVector< reco::PFBlockElement >& elements, 
00315                            const reco::PFBlock::LinkData& linkData, 
00316                            std::vector<bool>& active, 
00317                            std::vector<double>& psEne);
00318 
00319   bool isFromSecInt(const reco::PFBlockElement& eTrack,  std::string order) const;
00320 
00321 
00322   // Post HF Cleaning
00323   void postCleaning();
00324 
00325 
00326 
00327 
00328  private:
00331   reco::PFBlockRef createBlockRef( const reco::PFBlockCollection& blocks, 
00332                                    unsigned bi );
00333     
00335   reco::PFBlockHandle    blockHandle_;
00336 
00338   double             nSigmaECAL_;
00339   
00341   double             nSigmaHCAL_;
00342   
00343   boost::shared_ptr<PFEnergyCalibration>  calibration_;
00344   boost::shared_ptr<PFEnergyCalibrationHF>  thepfEnergyCalibrationHF_;
00345   boost::shared_ptr<PFSCEnergyCalibration> thePFSCEnergyCalibration_;
00346 
00347   bool               useHO_;
00348   int                algo_;
00349   bool               debug_;
00350 
00352   std::string mvaWeightFileEleID_;
00353   std::vector<double> setchi2Values_;
00354   double mvaEleCut_;
00355   bool usePFElectrons_;
00356   bool usePFPhotons_;
00357   bool applyCrackCorrectionsElectrons_;
00358   bool usePFSCEleCalib_;
00359   bool useEGElectrons_;
00360   bool useEGammaSupercluster_;
00361   double sumEtEcalIsoForEgammaSC_barrel_;
00362   double sumEtEcalIsoForEgammaSC_endcap_;
00363   double coneEcalIsoForEgammaSC_;
00364   double sumPtTrackIsoForEgammaSC_barrel_;
00365   double sumPtTrackIsoForEgammaSC_endcap_;
00366   double coneTrackIsoForEgammaSC_;
00367   unsigned int nTrackIsoForEgammaSC_;
00368   PFElectronAlgo *pfele_;
00369   PFPhotonAlgo *pfpho_;
00370 
00371   // Option to let PF decide the muon momentum
00372   bool usePFMuonMomAssign_;
00373 
00376   bool rejectTracks_Bad_;
00377   bool rejectTracks_Step45_;
00378 
00379   bool usePFNuclearInteractions_;
00380   bool usePFConversions_;
00381   bool usePFDecays_;
00382 
00385   double dptRel_DispVtx_;
00386 
00387 
00390   PFCandConnector connector_;
00391     
00393   std::vector<double> muonHCAL_;
00394   std::vector<double> muonECAL_;
00395   std::vector<double> muonHO_;
00396   double nSigmaTRACK_;
00397   double ptError_;
00398   std::vector<double> factors45_;
00399 
00400   // Parameters for post HF cleaning
00401   bool postHFCleaning_;
00402   bool postMuonCleaning_;
00403   double minHFCleaningPt_;
00404   double minSignificance_;
00405   double maxSignificance_;
00406   double minSignificanceReduction_;
00407   double maxDeltaPhiPt_;
00408   double minDeltaMet_;
00409   double useBestMuonTrack_;
00410 
00411   //MIKE -May19th: Add option for the vertices....
00412   reco::Vertex       primaryVertex_;
00413   bool               useVertices_; 
00414 
00415 };
00416 
00417 
00418 #endif
00419 
00420