41 #include <Math/DistFunc.h>
47 HICaloCompatibleTrackSelector::HICaloCompatibleTrackSelector(
const edm::ParameterSet & cfg ) :
48 srcTracks_(cfg.getParameter<edm::InputTag>(
"srcTracks")),
49 srcPFCands_(cfg.getParameter<edm::InputTag>(
"srcPFCands")),
50 srcTower_(cfg.getParameter<edm::InputTag>(
"srcTower")),
51 usePFCandMatching_(cfg.getUntrackedParameter<bool>(
"usePFCandMatching",
true)),
52 trkMatchPtMin_(cfg.getUntrackedParameter<double>(
"trkMatchPtMin",10.0)),
53 trkCompPtMin_(cfg.getUntrackedParameter<double>(
"trkCompPtMin",35.0)),
54 trkEtaMax_(cfg.getUntrackedParameter<double>(
"trkEtaMax",2.4)),
55 towerPtMin_(cfg.getUntrackedParameter<double>(
"towerPtMin",5.0)),
56 matchConeRadius_(cfg.getUntrackedParameter<double>(
"matchConeRadius",0.087)),
57 keepAllTracks_(cfg.getUntrackedParameter<bool>(
"keepAllTracks",
true)),
58 copyExtras_(cfg.getUntrackedParameter<bool>(
"copyExtras",
true)),
59 copyTrajectories_(cfg.getUntrackedParameter<bool>(
"copyTrajectories",
true)),
60 qualityToSet_(cfg.getParameter<std::string>(
"qualityToSet")),
61 qualityToSkip_(cfg.getParameter<std::string>(
"qualityToSkip")),
62 qualityToMatch_(cfg.getParameter<std::string>(
"qualityToMatch")),
63 minimumQuality_(cfg.getParameter<std::string>(
"minimumQuality")),
64 resetQuality_(cfg.getUntrackedParameter<bool>(
"resetQuality",
true)),
65 passMuons_(cfg.getUntrackedParameter<bool>(
"passMuons",
true)),
66 passElectrons_(cfg.getUntrackedParameter<bool>(
"passElectrons",
false)),
67 funcDeltaRTowerMatch_(cfg.getParameter<std::string>(
"funcDeltaRTowerMatch")),
68 funcCaloComp_(cfg.getParameter<std::string>(
"funcCaloComp"))
70 std::string alias( cfg.
getParameter<std::string>(
"@module_label" ) );
71 produces<reco::TrackCollection>().setBranchAlias( alias +
"Tracks");
73 produces<reco::TrackExtraCollection>().setBranchAlias( alias +
"TrackExtras");
74 produces<TrackingRecHitCollection>().setBranchAlias( alias +
"RecHits");
77 produces< std::vector<Trajectory> >().setBranchAlias( alias +
"Trajectories");
78 produces< TrajTrackAssociationCollection >().setBranchAlias( alias +
"TrajectoryTrackAssociations");
125 bool isPFThere =
false;
126 bool isTowerThere =
false;
132 for (
TI ti = hSrcTrack->begin(), ed = hSrcTrack->end(); ti != ed; ++ti, ++
current) {
139 else isSelected =
selectByTowers(ti, hSrcTrack, towers, isTowerThere);
162 selHits_->push_back( (*hit)->clone() );
178 selTrajs_ = auto_ptr< vector<Trajectory> >(
new vector<Trajectory>());
181 for (
size_t i = 0,
n = hTraj->size();
i <
n; ++
i) {
184 if (match != hTTAss->end()) {
186 short oldKey =
static_cast<short>(trkRef.
key());
225 double trkPt = trk.
pt();
231 unsigned int trackKey = ti - hSrcTrack->begin();
237 if(!(caloEt>0.))
return false;
247 if(caloEt>compPt)
return true;
252 throw cms::Exception(
"Undefined case in HICaloCompatibleTrackSelector") <<
"Undefined case in HICaloCompatibleTrackSelector";
276 if (caloEt>0 && matchDr>matchConeRadius_pt) caloEt=0.;
292 double sum_ecal=0.0, sum_hcal=0.0;
299 for(
CI ci = pfCandidates->begin(); ci!=pfCandidates->end(); ++ci) {
315 if(it==candTrackRefKey) {
340 switch (elements[indexInBlock].
type()) {
344 sum_ecal += clusterRef->energy()/cosh(clusterRef->eta());
350 sum_hcal += clusterRef->energy()/cosh(clusterRef->eta());
368 return sum_ecal+sum_hcal;
377 for(
unsigned int i = 0;
i < towers->size(); ++
i){
379 double pt = tower.
pt();
T getParameter(std::string const &) const
reco::TrackCollection::const_iterator TI
std::auto_ptr< TrackingRecHitCollection > selHits_
void produce(edm::Event &evt, const edm::EventSetup &es)
process one event
std::vector< Track > TrackCollection
collection of Tracks
virtual ~HICaloCompatibleTrackSelector()
destructor
bool innerOk() const
return true if the innermost hit is valid
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
std::string qualityToSet_
std::string qualityToMatch_
const math::XYZPoint & outerPosition() const
position of the outermost hit
std::auto_ptr< reco::TrackExtraCollection > selTrackExtras_
virtual double eta() const
momentum pseudorapidity
edm::InputTag srcPFCands_
std::string qualityToSkip_
const ElementsInBlocks & elementsInBlocks() const
double deltaR(double eta1, double phi1, double eta2, double phi2)
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
reco::TrackRef trackRef() const
const math::XYZPoint & innerPosition() const
position of the innermost hit
TrackingRecHitRefProd rHits_
reco::PFCandidateCollection::const_iterator CI
std::auto_ptr< std::vector< Trajectory > > selTrajs_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::Ref< TrackingRecHitCollection > TrackingRecHitRef
persistent reference to a TrackingRecHit
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
double pt() const
track transverse momentum
std::string minimumQuality_
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
bool selectByTowers(TI ti, const edm::Handle< TrackCollection > hSrcTrack, const edm::Handle< CaloTowerCollection > towers, bool isTowerThere)
reco::TrackRefProd rTracks_
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
edm::RefProd< std::vector< Trajectory > > rTrajectories_
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
std::vector< reco::TrackRef > trackRefs_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
RefProd< PROD > getRefBeforePut()
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
edm::RefToBase< TrajectorySeed > seedRef() const
static TrackQuality qualityByName(const std::string &name)
double matchPFCandToTrack(const edm::Handle< PFCandidateCollection > &pfCandidates, unsigned it, double trkPt)
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
bool outerOk() const
return true if the outermost hit is valid
virtual double pt() const
transverse momentum
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
key_type key() const
Accessor for product key.
std::string funcCaloComp_
bool quality(const TrackQuality) const
Track quality.
static std::string const emptyString("")
Particle reconstructed by the particle flow algorithm.
reco::TrackExtraRefProd rTrackExtras_
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
std::auto_ptr< reco::TrackCollection > selTracks_
storage
std::auto_ptr< TrajTrackAssociationCollection > selTTAss_
const TrackResiduals & residuals() const
bool selectByPFCands(TI ti, const edm::Handle< TrackCollection > hSrcTrack, const edm::Handle< PFCandidateCollection > pfCandidates, bool isPFThere)
void matchByDrAllowReuse(const reco::Track &trk, const edm::Handle< CaloTowerCollection > &towers, double &bestdr, double &bestpt)
PropagationDirection seedDirection() const
direction of how the hits were sorted in the original seed
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
edm::InputTag srcTracks_
source collection label
std::string funcDeltaRTowerMatch_
virtual ParticleType particleId() const
bool copyTrajectories_
copy also trajectories and trajectory->track associations
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.