CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/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 
00045 namespace pftools { 
00046   class PFClusterCalibration;
00047 }
00048 
00049 class PFAlgo {
00050 
00051  public:
00052 
00054   PFAlgo();
00055 
00057   virtual ~PFAlgo();
00058 
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<pftools::PFClusterCalibration>& clusterCalibration,
00067                      const boost::shared_ptr<PFEnergyCalibrationHF>& thepfEnergyCalibrationHF,
00068                      unsigned int newCalib);
00069   
00070   void setCandConnectorParameters( const edm::ParameterSet& iCfgCandConnector ){
00071     connector_.setParameters(iCfgCandConnector);
00072   }
00073  
00074   void setCandConnectorParameters(bool bCorrect, 
00075                                   bool bCalibPrimary, 
00076                                   double dptRel_PrimaryTrack, 
00077                                   double dptRel_MergedTrack, 
00078                                   double ptErrorSecondary, 
00079                                   std::vector<double> nuclCalibFactors){
00080     connector_.setParameters(bCorrect, bCalibPrimary, dptRel_PrimaryTrack, dptRel_MergedTrack, ptErrorSecondary, nuclCalibFactors);
00081   }
00082 
00083 
00084   void setPFMuonAndFakeParameters(std::vector<double> muonHCAL,
00085                                   std::vector<double> muonECAL,
00086                                   double nSigmaTRACK,
00087                                   double ptError,
00088                                   std::vector<double> factors45,
00089                                   bool usePFMuonMomAssign);   
00090 
00091   void setPFEleParameters(double mvaEleCut,
00092                           std::string mvaWeightFileEleID,
00093                           bool usePFElectrons,
00094                           const boost::shared_ptr<PFSCEnergyCalibration>& thePFSCEnergyCalibration,
00095                           double sumEtEcalIsoForEgammaSC_barrel,
00096                           double sumEtEcalIsoForEgammaSC_endcap,
00097                           double coneEcalIsoForEgammaSC,
00098                           double sumPtTrackIsoForEgammaSC_barrel,
00099                           double sumPtTrackIsoForEgammaSC_endcap,
00100                           unsigned int nTrackIsoForEgammaSC,
00101                           double coneTrackIsoForEgammaSC,
00102                           bool applyCrackCorrections=false,
00103                           bool usePFSCEleCalib=true,
00104                           bool useEGElectrons=false,
00105                           bool useEGammaSupercluster = true);
00106 
00107   void setPostHFCleaningParameters(bool postHFCleaning,
00108                                    double minHFCleaningPt,
00109                                    double minSignificance,
00110                                    double maxSignificance,
00111                                    double minSignificanceReduction,
00112                                    double maxDeltaPhiPt,
00113                                    double minDeltaMet);
00114 
00115   void setDisplacedVerticesParameters(bool rejectTracks_Bad,
00116                                       bool rejectTracks_Step45,
00117                                       bool usePFNuclearInteractions,
00118                                       bool usePFConversions,
00119                                       bool usePFDecays,
00120                                       double dptRel_DispVtx);
00121   
00122   //MIKEB : Parameters for the vertices..
00123   void setPFVertexParameters(bool useVertex,
00124                            const reco::VertexCollection& primaryVertices);                         
00125   
00126   // FlorianB : Collection of e/g electrons
00127   void setEGElectronCollection(const reco::GsfElectronCollection & egelectrons);
00128 
00132   void reconstructParticles( const reco::PFBlockHandle& blockHandle );
00133 
00135   virtual void reconstructParticles( const reco::PFBlockCollection& blocks );
00136   
00138   void checkCleaning( const reco::PFRecHitCollection& cleanedHF );
00139 
00140   // Post Muon Cleaning
00141   void postMuonCleaning( const edm::Handle<reco::MuonCollection>& muonh,
00142                          const reco::VertexCollection& primaryVertices );
00143 
00144   // Post Electron Extra Ref
00145   void setElectronExtraRef(const edm::OrphanHandle<reco::PFCandidateElectronExtraCollection >& extrah);            
00146 
00148   const std::auto_ptr< reco::PFCandidateCollection >& pfCandidates() const {
00149     return pfCandidates_;
00150   }
00151 
00153   std::auto_ptr< reco::PFCandidateCollection> transferElectronCandidates()  {
00154     return pfElectronCandidates_;
00155   }
00156 
00158   // 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
00159   std::auto_ptr< reco::PFCandidateElectronExtraCollection> transferElectronExtra()  {
00160     std::auto_ptr< reco::PFCandidateElectronExtraCollection> result(new reco::PFCandidateElectronExtraCollection);
00161     result->insert(result->end(),pfElectronExtra_.begin(),pfElectronExtra_.end());
00162     return result;
00163   }
00164 
00165 
00167   std::auto_ptr< reco::PFCandidateCollection >& transferCleanedCandidates() {
00168     return pfCleanedCandidates_;
00169   }
00170   
00172   std::auto_ptr< reco::PFCandidateCollection > transferCosmicsMuonCleanedCandidates() {
00173     return pfCosmicsMuonCleanedCandidates_;
00174   }
00175 
00177   std::auto_ptr< reco::PFCandidateCollection > transferCleanedTrackerAndGlobalMuonCandidates() {
00178     return pfCleanedTrackerAndGlobalMuonCandidates_;
00179   }
00180 
00182   std::auto_ptr< reco::PFCandidateCollection > transferFakeMuonCleanedCandidates() {
00183     return pfFakeMuonCleanedCandidates_;
00184   }
00185 
00187   std::auto_ptr< reco::PFCandidateCollection > transferPunchThroughMuonCleanedCandidates() {
00188     return pfPunchThroughMuonCleanedCandidates_;
00189   }
00190 
00192   std::auto_ptr< reco::PFCandidateCollection > transferPunchThroughHadronCleanedCandidates() {
00193     return pfPunchThroughHadronCleanedCandidates_;
00194   }
00195 
00197   std::auto_ptr< reco::PFCandidateCollection > transferAddedMuonCandidates() {
00198     return pfAddedMuonCandidates_;
00199   }
00200    
00202   std::auto_ptr< reco::PFCandidateCollection >  transferCandidates() {
00203     return connector_.connect(pfCandidates_);
00204   }
00205   
00206   friend std::ostream& operator<<(std::ostream& out, const PFAlgo& algo);
00207   
00208  protected:
00209 
00212   virtual void processBlock( const reco::PFBlockRef& blockref,
00213                              std::list<reco::PFBlockRef>& hcalBlockRefs, 
00214                              std::list<reco::PFBlockRef>& ecalBlockRefs ); 
00215   
00218   unsigned reconstructTrack( const reco::PFBlockElement& elt );
00219 
00225 
00226   unsigned reconstructCluster( const reco::PFCluster& cluster,
00227                                double particleEnergy,
00228                                bool useDirection = false,
00229                                double particleX=0.,
00230                                double particleY=0.,
00231                                double particleZ=0.);
00232 
00233 
00235   // double gammaCalibratedEnergy( double clusterEnergy ) const;
00236 
00239   // double neutralHadronCalibratedEnergy( double energyHCAL, 
00240   //                                    double energyECAL=-1) const;
00241   
00242 
00244   double neutralHadronEnergyResolution( double clusterEnergy,
00245                                         double clusterEta ) const;
00246 
00247  
00248   double nSigmaHCAL( double clusterEnergy, 
00249                      double clusterEta ) const;
00250 
00251   std::auto_ptr< reco::PFCandidateCollection >    pfCandidates_;
00253   std::auto_ptr< reco::PFCandidateCollection >    pfElectronCandidates_;
00254   // the post-HF-cleaned candidates
00255   std::auto_ptr< reco::PFCandidateCollection >    pfCleanedCandidates_;
00257   std::auto_ptr< reco::PFCandidateCollection >    pfCosmicsMuonCleanedCandidates_;
00259   std::auto_ptr< reco::PFCandidateCollection >    pfCleanedTrackerAndGlobalMuonCandidates_;
00261   std::auto_ptr< reco::PFCandidateCollection >    pfFakeMuonCleanedCandidates_;
00263   std::auto_ptr< reco::PFCandidateCollection >    pfPunchThroughMuonCleanedCandidates_;
00265   std::auto_ptr< reco::PFCandidateCollection >    pfPunchThroughHadronCleanedCandidates_;
00267   std::auto_ptr< reco::PFCandidateCollection >    pfAddedMuonCandidates_;
00268 
00270   reco::PFCandidateElectronExtraCollection    pfElectronExtra_;
00271 
00274   bool isSatelliteCluster( const reco::PFRecTrack& track,
00275                            const reco::PFCluster& cluster );
00276 
00278   void associatePSClusters(unsigned iEcal,
00279                            reco::PFBlockElement::Type psElementType,
00280                            const reco::PFBlock& block,
00281                            const edm::OwnVector< reco::PFBlockElement >& elements, 
00282                            const reco::PFBlock::LinkData& linkData, 
00283                            std::vector<bool>& active, 
00284                            std::vector<double>& psEne);
00285 
00286   bool isFromSecInt(const reco::PFBlockElement& eTrack,  std::string order) const;
00287 
00288 
00289   // Post HF Cleaning
00290   void postCleaning();
00291 
00292 
00293 
00294 
00295  private:
00298   reco::PFBlockRef createBlockRef( const reco::PFBlockCollection& blocks, 
00299                                    unsigned bi );
00300     
00302   reco::PFBlockHandle    blockHandle_;
00303 
00305   double             nSigmaECAL_;
00306   
00308   double             nSigmaHCAL_;
00309   
00310   boost::shared_ptr<PFEnergyCalibration>  calibration_;
00311   boost::shared_ptr<pftools::PFClusterCalibration>  clusterCalibration_;
00312   boost::shared_ptr<PFEnergyCalibrationHF>  thepfEnergyCalibrationHF_;
00313   boost::shared_ptr<PFSCEnergyCalibration> thePFSCEnergyCalibration_;
00314 
00315   unsigned int newCalib_;
00316 
00317   // std::vector<unsigned> hcalBlockUsed_;
00318   
00319   int                algo_;
00320   bool               debug_;
00321 
00323   std::string mvaWeightFileEleID_;
00324   std::vector<double> setchi2Values_;
00325   double mvaEleCut_;
00326   bool usePFElectrons_;
00327   bool applyCrackCorrectionsElectrons_;
00328   bool usePFSCEleCalib_;
00329   bool useEGElectrons_;
00330   bool useEGammaSupercluster_;
00331   double sumEtEcalIsoForEgammaSC_barrel_;
00332   double sumEtEcalIsoForEgammaSC_endcap_;
00333   double coneEcalIsoForEgammaSC_;
00334   double sumPtTrackIsoForEgammaSC_barrel_;
00335   double sumPtTrackIsoForEgammaSC_endcap_;
00336   double coneTrackIsoForEgammaSC_;
00337   unsigned int nTrackIsoForEgammaSC_;
00338   PFElectronAlgo *pfele_;
00339 
00340   // Option to let PF decide the muon momentum
00341   bool usePFMuonMomAssign_;
00342 
00345   bool rejectTracks_Bad_;
00346   bool rejectTracks_Step45_;
00347 
00348   bool usePFNuclearInteractions_;
00349   bool usePFConversions_;
00350   PFConversionAlgo* pfConversion_;
00351   bool usePFDecays_;
00352 
00355   double dptRel_DispVtx_;
00356 
00357 
00360   PFCandConnector connector_;
00361     
00363   std::vector<double> muonHCAL_;
00364   std::vector<double> muonECAL_;
00365   double nSigmaTRACK_;
00366   double ptError_;
00367   std::vector<double> factors45_;
00368 
00369   // Parameters for post HF cleaning
00370   bool postHFCleaning_;
00371   bool postMuonCleaning_;
00372   double minHFCleaningPt_;
00373   double minSignificance_;
00374   double maxSignificance_;
00375   double minSignificanceReduction_;
00376   double maxDeltaPhiPt_;
00377   double minDeltaMet_;
00378 
00379   //MIKE -May19th: Add option for the vertices....
00380   reco::Vertex       primaryVertex_;
00381   bool               useVertices_; 
00382 
00383 };
00384 
00385 
00386 #endif
00387 
00388