Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:20

0001 #ifndef HICaloCompatibleTrackSelector_H
0002 #define HICaloCompatibleTrackSelector_H
0003 
0004 /** \class HICaloCompatibleTrackSelector
0005  *
0006  *  It selects tracks based on a cut imposed on track-calo compatibility, 
0007  *  and saves tracks in event. 
0008  * 
0009  *
0010  */
0011 
0012 #include <utility>
0013 #include <vector>
0014 #include <memory>
0015 #include <algorithm>
0016 #include <map>
0017 #include "FWCore/Framework/interface/stream/EDProducer.h"
0018 #include "FWCore/Framework/interface/Event.h"
0019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0020 
0021 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0022 #include "DataFormats/TrackReco/interface/Track.h"
0023 #include "DataFormats/TrackReco/interface/TrackExtra.h"
0024 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0025 #include "DataFormats/VertexReco/interface/Vertex.h"
0026 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0027 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0028 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
0029 
0030 #include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
0031 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
0032 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
0033 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0034 
0035 #include "DataFormats/CaloTowers/interface/CaloTower.h"
0036 #include "DataFormats/CaloTowers/interface/CaloTowerDefs.h"
0037 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
0038 
0039 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0040 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
0041 
0042 // ROOT includes
0043 #include "TF1.h"
0044 
0045 namespace reco {
0046   namespace modules {
0047 
0048     class HICaloCompatibleTrackSelector : public edm::stream::EDProducer<> {
0049     public:
0050       /// constructor
0051       explicit HICaloCompatibleTrackSelector(const edm::ParameterSet& cfg);
0052       /// destructor
0053       ~HICaloCompatibleTrackSelector() override;
0054 
0055     private:
0056       typedef math::XYZPoint Point;
0057       typedef reco::PFCandidateCollection::const_iterator CI;
0058       typedef reco::TrackCollection::const_iterator TI;
0059 
0060       /// process one event
0061       void produce(edm::Event& evt, const edm::EventSetup& es) override;
0062 
0063       void matchByDrAllowReuse(const reco::Track& trk,
0064                                const edm::Handle<CaloTowerCollection>& towers,
0065                                double& bestdr,
0066                                double& bestpt);
0067 
0068       double matchPFCandToTrack(const edm::Handle<PFCandidateCollection>& pfCandidates, unsigned it, double trkPt);
0069 
0070       bool selectByPFCands(TI ti,
0071                            const edm::Handle<TrackCollection> hSrcTrack,
0072                            const edm::Handle<PFCandidateCollection> pfCandidates,
0073                            bool isPFThere);
0074       bool selectByTowers(TI ti,
0075                           const edm::Handle<TrackCollection> hSrcTrack,
0076                           const edm::Handle<CaloTowerCollection> towers,
0077                           bool isTowerThere);
0078 
0079       /// source collection label
0080       edm::EDGetTokenT<reco::TrackCollection> srcTracks_;
0081       edm::EDGetTokenT<reco::PFCandidateCollection> srcPFCands_;
0082       edm::EDGetTokenT<CaloTowerCollection> srcTower_;
0083       edm::EDGetTokenT<std::vector<Trajectory>> srcTrackTrajs_;
0084       edm::EDGetTokenT<TrajTrackAssociationCollection> srcTrackTrajAssoc_;
0085 
0086       //
0087       bool applyPtDepCut_;
0088       bool usePFCandMatching_;
0089       double trkMatchPtMin_;
0090       double trkCompPtMin_;
0091       double trkEtaMax_;
0092       double towerPtMin_;
0093       double matchConeRadius_;
0094 
0095       bool keepAllTracks_;
0096       /// copy only the tracks, not extras and rechits (for AOD)
0097       bool copyExtras_;
0098       /// copy also trajectories and trajectory->track associations
0099       bool copyTrajectories_;
0100 
0101       std::string qualityToSet_;
0102       std::string qualityToSkip_;
0103       std::string qualityToMatch_;
0104       std::string minimumQuality_;
0105       bool resetQuality_;
0106 
0107       bool passMuons_;
0108       bool passElectrons_;
0109 
0110       // string of functional form
0111       std::string funcDeltaRTowerMatch_;
0112       std::string funcCaloComp_;
0113 
0114       /// storage
0115       std::unique_ptr<reco::TrackCollection> selTracks_;
0116       std::unique_ptr<reco::TrackExtraCollection> selTrackExtras_;
0117       std::unique_ptr<TrackingRecHitCollection> selHits_;
0118       std::unique_ptr<std::vector<Trajectory>> selTrajs_;
0119       std::unique_ptr<std::vector<const Trajectory*>> selTrajPtrs_;
0120       std::unique_ptr<TrajTrackAssociationCollection> selTTAss_;
0121       reco::TrackRefProd rTracks_;
0122       reco::TrackExtraRefProd rTrackExtras_;
0123       TrackingRecHitRefProd rHits_;
0124       edm::RefProd<std::vector<Trajectory>> rTrajectories_;
0125       std::vector<reco::TrackRef> trackRefs_;
0126 
0127       // TF1
0128       TF1 *fDeltaRTowerMatch, *fCaloComp;
0129     };
0130 
0131   }  // namespace modules
0132 }  // namespace reco
0133 
0134 #endif