CMS 3D CMS Logo

ConversionTrackProducer.cc
Go to the documentation of this file.
1 //
2 // Package: RecoTracker/FinalTrackSelectors
3 // Class: ConversionTrackProducer
4 //
5 // Description: Trivial producer of ConversionTrack collection from an edm::View of a track collection
6 // (ConversionTrack is a simple wrappper class containing a TrackBaseRef and some additional flags)
7 //
8 // Original Author: J.Bendavid
9 //
10 //
11 
12 #include <memory>
13 #include <string>
14 #include <iostream>
15 #include <cmath>
16 #include <vector>
17 
19 
22 
25 
27 
29 
31 
33  : useTrajectory(conf.getParameter<bool>("useTrajectory")),
34  setTrackerOnly(conf.getParameter<bool>("setTrackerOnly")),
35  setIsGsfTrackOpen(conf.getParameter<bool>("setIsGsfTrackOpen")),
36  setArbitratedEcalSeeded(conf.getParameter<bool>("setArbitratedEcalSeeded")),
37  setArbitratedMerged(conf.getParameter<bool>("setArbitratedMerged")),
38  setArbitratedMergedEcalGeneral(conf.getParameter<bool>("setArbitratedMergedEcalGeneral")),
39  beamSpotInputTag(consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("beamSpotInputTag"))),
40  filterOnConvTrackHyp(conf.getParameter<bool>("filterOnConvTrackHyp")),
41  minConvRadius(conf.getParameter<double>("minConvRadius")) {
42  edm::InputTag thetp(conf.getParameter<std::string>("TrackProducer"));
43  genericTracks = consumes<edm::View<reco::Track> >(thetp);
44  if (useTrajectory) {
45  kfTrajectories = consumes<TrajTrackAssociationCollection>(thetp);
46  gsfTrajectories = consumes<TrajGsfTrackAssociationCollection>(thetp);
47  }
48  magFieldToken = esConsumes();
49  produces<reco::ConversionTrackCollection>();
50 }
51 
52 // Virtual destructor needed.
54 
55 // Functions that gets called by framework every event
57  //get input collection (through edm::View)
58  edm::View<reco::Track> const& trks = e.get(genericTracks);
59 
60  //get association maps between trajectories and tracks and build temporary maps
61  std::map<reco::TrackRef, edm::Ref<std::vector<Trajectory> > > tracktrajmap;
62  std::map<reco::GsfTrackRef, edm::Ref<std::vector<Trajectory> > > gsftracktrajmap;
63 
64  if (useTrajectory) {
65  if (!trks.empty()) {
66  if (dynamic_cast<const reco::GsfTrack*>(&trks.at(0))) {
67  //fill map for gsf tracks
68  for (auto const& pair : e.get(gsfTrajectories)) {
69  gsftracktrajmap[pair.val] = pair.key;
70  }
71  } else {
72  //fill map for standard tracks
73  for (auto const& pair : e.get(kfTrajectories)) {
74  tracktrajmap[pair.val] = pair.key;
75  }
76  }
77  }
78  }
79 
80  // Step B: create empty output collection
81  auto outputTrks = std::make_unique<reco::ConversionTrackCollection>();
82 
83  //--------------------------------------------------
84  //Added by D. Giordano
85  // 2011/08/05
86  // Reduction of the track sample based on geometric hypothesis for conversion tracks
87 
88  math::XYZVector beamSpot{e.get(beamSpotInputTag).position()};
89 
91 
92  //----------------------------------------------------------
93 
94  // Simple conversion of tracks to conversion tracks, setting appropriate flags from configuration
95  for (size_t i = 0; i < trks.size(); ++i) {
96  //--------------------------------------------------
97  //Added by D. Giordano
98  // 2011/08/05
99  // Reduction of the track sample based on geometric hypothesis for conversion tracks
100 
101  edm::RefToBase<reco::Track> trackBaseRef = trks.refAt(i);
102  if (filterOnConvTrackHyp &&
104  continue;
105  //--------------------------------------------------
106 
107  reco::ConversionTrack convTrack(trackBaseRef);
108  convTrack.setIsTrackerOnly(setTrackerOnly);
113 
114  //fill trajectory association if configured, using correct map depending on track type
115  if (useTrajectory) {
116  if (!gsftracktrajmap.empty()) {
117  convTrack.setTrajRef(gsftracktrajmap.find(trackBaseRef.castTo<reco::GsfTrackRef>())->second);
118  } else {
119  convTrack.setTrajRef(tracktrajmap.find(trackBaseRef.castTo<reco::TrackRef>())->second);
120  }
121  }
122 
123  outputTrks->push_back(convTrack);
124  }
125 
126  e.put(std::move(outputTrks));
127  return;
128 
129 } //end produce
ConversionTrackProducer::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: ConversionTrackProducer.cc:56
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
reco::ConversionTrack::setIsArbitratedMerged
void setIsArbitratedMerged(bool b)
Definition: ConversionTrack.h:43
mps_fire.i
i
Definition: mps_fire.py:428
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
conversionTrackProducer_cfi.setTrackerOnly
setTrackerOnly
Definition: conversionTrackProducer_cfi.py:9
MessageLogger.h
edm::View::empty
bool empty() const
reco::ConversionTrack
Definition: ConversionTrack.h:19
ConversionTrackProducer::minConvRadius
double minConvRadius
Definition: ConversionTrackProducer.h:75
ESHandle.h
align::BeamSpot
Definition: StructureType.h:89
edm::View::refAt
RefToBase< value_type > refAt(size_type i) const
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
conversionTrackProducer_cfi.useTrajectory
useTrajectory
Definition: conversionTrackProducer_cfi.py:7
reco::ConversionTrack::setIsArbitratedEcalSeeded
void setIsArbitratedEcalSeeded(bool b)
Definition: ConversionTrack.h:42
conversionOpenTrackSequence_cff.setIsGsfTrackOpen
setIsGsfTrackOpen
Definition: conversionOpenTrackSequence_cff.py:8
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
ConversionTrackProducer::setTrackerOnly
bool setTrackerOnly
Definition: ConversionTrackProducer.h:61
ConversionTrackProducer::setArbitratedMerged
bool setArbitratedMerged
Definition: ConversionTrackProducer.h:64
edm::Ref< GsfTrackCollection >
ConversionTrackProducer::kfTrajectories
edm::EDGetTokenT< TrajTrackAssociationCollection > kfTrajectories
Definition: ConversionTrackProducer.h:58
BeamSpot.h
IdealHelixParameters::setMagnField
void setMagnField(const MagneticField *magnField)
Definition: IdealHelixParameters.h:31
ConversionTrackProducer::genericTracks
edm::EDGetTokenT< edm::View< reco::Track > > genericTracks
Definition: ConversionTrackProducer.h:57
ConversionTrackProducer::setArbitratedMergedEcalGeneral
bool setArbitratedMergedEcalGeneral
Definition: ConversionTrackProducer.h:65
reco::ConversionTrack::setTrajRef
void setTrajRef(edm::Ref< std::vector< Trajectory > > tr)
Definition: ConversionTrack.h:39
edm::RefToBase::get
value_type const * get() const
Definition: RefToBase.h:209
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View::size
size_type size() const
ConversionTrackProducer::setArbitratedEcalSeeded
bool setArbitratedEcalSeeded
Definition: ConversionTrackProducer.h:63
conversionOpenTrackSequence_cff.setArbitratedEcalSeeded
setArbitratedEcalSeeded
Definition: conversionOpenTrackSequence_cff.py:10
edm::View
Definition: CaloClusterFwd.h:14
edm::View::at
const_reference at(size_type pos) const
ConversionTrackProducer::useTrajectory
bool useTrajectory
Definition: ConversionTrackProducer.h:60
ConversionTrackProducer::filterOnConvTrackHyp
bool filterOnConvTrackHyp
Definition: ConversionTrackProducer.h:74
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
conversionOpenTrackSequence_cff.filterOnConvTrackHyp
filterOnConvTrackHyp
Definition: conversionOpenTrackSequence_cff.py:12
GsfTrack.h
ConversionTrackProducer::gsfTrajectories
edm::EDGetTokenT< TrajGsfTrackAssociationCollection > gsfTrajectories
Definition: ConversionTrackProducer.h:59
edm::EventSetup
Definition: EventSetup.h:57
edm::RefToBase::castTo
REF castTo() const
Definition: RefToBase.h:257
ConversionTrackProducer.h
ConversionTrackProducer::magFieldToken
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken
Definition: ConversionTrackProducer.h:73
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
Trajectory.h
reco::ConversionTrack::setIsTrackerOnly
void setIsTrackerOnly(bool b)
Definition: ConversionTrack.h:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
GsfTrackFwd.h
conversionOpenTrackSequence_cff.setArbitratedMergedEcalGeneral
setArbitratedMergedEcalGeneral
Definition: conversionOpenTrackSequence_cff.py:9
ConversionTrackProducer::~ConversionTrackProducer
~ConversionTrackProducer() override
Definition: ConversionTrackProducer.cc:53
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::RefToBase< reco::Track >
ConversionTrackProducer::beamSpotInputTag
edm::EDGetTokenT< reco::BeamSpot > beamSpotInputTag
Definition: ConversionTrackProducer.h:72
distMuonMETValueMapProducer_cff.beamSpotInputTag
beamSpotInputTag
Definition: distMuonMETValueMapProducer_cff.py:9
conversionTrackProducer_cfi.minConvRadius
minConvRadius
Definition: conversionTrackProducer_cfi.py:16
reco::ConversionTrack::setIsGsfTrackOpen
void setIsGsfTrackOpen(bool b)
Definition: ConversionTrack.h:41
ConversionTrackProducer::ConversionTrackProducer
ConversionTrackProducer(const edm::ParameterSet &conf)
Definition: ConversionTrackProducer.cc:32
reco::ConversionTrack::setIsArbitratedMergedEcalGeneral
void setIsArbitratedMergedEcalGeneral(bool b)
Definition: ConversionTrack.h:44
edm::Event
Definition: Event.h:73
ConversionTrackProducer::ConvTrackPreSelector
IdealHelixParameters ConvTrackPreSelector
Definition: ConversionTrackProducer.h:76
edm::InputTag
Definition: InputTag.h:15
conversionOpenTrackSequence_cff.setArbitratedMerged
setArbitratedMerged
Definition: conversionOpenTrackSequence_cff.py:11
IdealHelixParameters::isTangentPointDistanceLessThan
bool isTangentPointDistanceLessThan(float rmax, const reco::Track *track, const math::XYZVector &refPoint)
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
ConversionTrackProducer::setIsGsfTrackOpen
bool setIsGsfTrackOpen
Definition: ConversionTrackProducer.h:62