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 
34 
35 #include <string>
36 #include <vector>
37 
41 
42 public:
43  explicit ConversionTrackProducer(const edm::ParameterSet& conf);
44 
45  ~ConversionTrackProducer() override;
46 
47  void produce(edm::Event& e, const edm::EventSetup& c) override;
48 
49 private:
59 
60  //--------------------------------------------------
61  //Added by D. Giordano
62  // 2011/08/05
63  // Reduction of the track sample based on geometric hypothesis for conversion tracks
64 
68  double minConvRadius;
70 };
71 
74 
76  : useTrajectory(conf.getParameter<bool>("useTrajectory")),
77  setTrackerOnly(conf.getParameter<bool>("setTrackerOnly")),
78  setIsGsfTrackOpen(conf.getParameter<bool>("setIsGsfTrackOpen")),
79  setArbitratedEcalSeeded(conf.getParameter<bool>("setArbitratedEcalSeeded")),
80  setArbitratedMerged(conf.getParameter<bool>("setArbitratedMerged")),
81  setArbitratedMergedEcalGeneral(conf.getParameter<bool>("setArbitratedMergedEcalGeneral")),
82  beamSpotInputTag(consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("beamSpotInputTag"))),
83  filterOnConvTrackHyp(conf.getParameter<bool>("filterOnConvTrackHyp")),
84  minConvRadius(conf.getParameter<double>("minConvRadius")) {
85  edm::InputTag thetp(conf.getParameter<std::string>("TrackProducer"));
86  genericTracks = consumes<edm::View<reco::Track> >(thetp);
87  if (useTrajectory) {
88  kfTrajectories = consumes<TrajTrackAssociationCollection>(thetp);
89  gsfTrajectories = consumes<TrajGsfTrackAssociationCollection>(thetp);
90  }
92  produces<reco::ConversionTrackCollection>();
93 }
94 
95 // Virtual destructor needed.
97 
98 // Functions that gets called by framework every event
100  //get input collection (through edm::View)
102 
103  //get association maps between trajectories and tracks and build temporary maps
104  std::map<reco::TrackRef, edm::Ref<std::vector<Trajectory> > > tracktrajmap;
105  std::map<reco::GsfTrackRef, edm::Ref<std::vector<Trajectory> > > gsftracktrajmap;
106 
107  if (useTrajectory) {
108  if (!trks.empty()) {
109  if (dynamic_cast<const reco::GsfTrack*>(&trks.at(0))) {
110  //fill map for gsf tracks
111  for (auto const& pair : e.get(gsfTrajectories)) {
112  gsftracktrajmap[pair.val] = pair.key;
113  }
114  } else {
115  //fill map for standard tracks
116  for (auto const& pair : e.get(kfTrajectories)) {
117  tracktrajmap[pair.val] = pair.key;
118  }
119  }
120  }
121  }
122 
123  // Step B: create empty output collection
124  auto outputTrks = std::make_unique<reco::ConversionTrackCollection>();
125 
126  //--------------------------------------------------
127  //Added by D. Giordano
128  // 2011/08/05
129  // Reduction of the track sample based on geometric hypothesis for conversion tracks
130 
131  math::XYZVector beamSpot{e.get(beamSpotInputTag).position()};
132 
134 
135  //----------------------------------------------------------
136 
137  // Simple conversion of tracks to conversion tracks, setting appropriate flags from configuration
138  for (size_t i = 0; i < trks.size(); ++i) {
139  //--------------------------------------------------
140  //Added by D. Giordano
141  // 2011/08/05
142  // Reduction of the track sample based on geometric hypothesis for conversion tracks
143 
144  edm::RefToBase<reco::Track> trackBaseRef = trks.refAt(i);
145  if (filterOnConvTrackHyp &&
147  continue;
148  //--------------------------------------------------
149 
150  reco::ConversionTrack convTrack(trackBaseRef);
151  convTrack.setIsTrackerOnly(setTrackerOnly);
156 
157  //fill trajectory association if configured, using correct map depending on track type
158  if (useTrajectory) {
159  if (!gsftracktrajmap.empty()) {
160  convTrack.setTrajRef(gsftracktrajmap.find(trackBaseRef.castTo<reco::GsfTrackRef>())->second);
161  } else {
162  convTrack.setTrajRef(tracktrajmap.find(trackBaseRef.castTo<reco::TrackRef>())->second);
163  }
164  }
165 
166  outputTrks->push_back(convTrack);
167  }
168 
169  e.put(std::move(outputTrks));
170  return;
171 
172 } //end produce
IdealHelixParameters.h
ConversionTrackProducer::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: ConversionTrackProducer.cc:99
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
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
reco::ConversionTrack
Definition: ConversionTrack.h:19
ConversionTrackProducer::minConvRadius
double minConvRadius
Definition: ConversionTrackProducer.cc:68
ESHandle.h
align::BeamSpot
Definition: StructureType.h:95
edm::EDGetTokenT
Definition: EDGetToken.h:33
TrackBase.h
edm
HLT enums.
Definition: AlignableModifier.h:19
ConversionTrackProducer::TrajGsfTrackAssociationCollection
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::GsfTrackCollection, unsigned short > > TrajGsfTrackAssociationCollection
Definition: ConversionTrackProducer.cc:40
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
conversionTrackProducer_cfi.useTrajectory
useTrajectory
Definition: conversionTrackProducer_cfi.py:7
EDProducer.h
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:46
TrajGsfTrackAssociation.h
ConversionTrackProducer::setTrackerOnly
bool setTrackerOnly
Definition: ConversionTrackProducer.cc:54
ConversionTrackProducer::setArbitratedMerged
bool setArbitratedMerged
Definition: ConversionTrackProducer.cc:57
edm::Ref< GsfTrackCollection >
ConversionTrackProducer::kfTrajectories
edm::EDGetTokenT< TrajTrackAssociationCollection > kfTrajectories
Definition: ConversionTrackProducer.cc:51
conversionTrackProducer_cfi.beamSpotInputTag
beamSpotInputTag
Definition: conversionTrackProducer_cfi.py:14
MakerMacros.h
TrackingRecHit.h
Track.h
ConversionTrack.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
IdealHelixParameters
Definition: IdealHelixParameters.h:21
IdealHelixParameters::setMagnField
void setMagnField(const MagneticField *magnField)
Definition: IdealHelixParameters.h:31
ConversionTrackProducer::genericTracks
edm::EDGetTokenT< edm::View< reco::Track > > genericTracks
Definition: ConversionTrackProducer.cc:50
IdealMagneticFieldRecord.h
ConversionTrackProducer::setArbitratedMergedEcalGeneral
bool setArbitratedMergedEcalGeneral
Definition: ConversionTrackProducer.cc:58
reco::ConversionTrack::setTrajRef
void setTrajRef(edm::Ref< std::vector< Trajectory > > tr)
Definition: ConversionTrack.h:39
ConversionTrackFwd.h
edm::RefToBase::get
value_type const * get() const
Definition: RefToBase.h:209
TrajTrackAssociation.h
ConversionTrackProducer::setArbitratedEcalSeeded
bool setArbitratedEcalSeeded
Definition: ConversionTrackProducer.cc:56
conversionOpenTrackSequence_cff.setArbitratedEcalSeeded
setArbitratedEcalSeeded
Definition: conversionOpenTrackSequence_cff.py:10
edm::View
Definition: CaloClusterFwd.h:14
ConversionTrackProducer::useTrajectory
bool useTrajectory
Definition: ConversionTrackProducer.cc:53
ConversionTrackProducer::filterOnConvTrackHyp
bool filterOnConvTrackHyp
Definition: ConversionTrackProducer.cc:67
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edm::AssociationMap
Definition: AssociationMap.h:48
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.cc:52
edm::stream::EDProducer
Definition: EDProducer.h:36
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:58
edm::RefToBase::castTo
REF castTo() const
Definition: RefToBase.h:257
ConversionTrackProducer::magFieldToken
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken
Definition: ConversionTrackProducer.cc:66
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
Trajectory.h
reco::ConversionTrack::setIsTrackerOnly
void setIsTrackerOnly(bool b)
Definition: ConversionTrack.h:40
reco::GsfTrackCollection
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
eostools.move
def move(src, dest)
Definition: eostools.py:511
GsfTrackFwd.h
conversionOpenTrackSequence_cff.setArbitratedMergedEcalGeneral
setArbitratedMergedEcalGeneral
Definition: conversionOpenTrackSequence_cff.py:9
ConversionTrackProducer
Definition: ConversionTrackProducer.cc:38
EventSetup.h
ConversionTrackProducer::~ConversionTrackProducer
~ConversionTrackProducer() override
Definition: ConversionTrackProducer.cc:96
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.cc:65
conversionTrackProducer_cfi.minConvRadius
minConvRadius
Definition: conversionTrackProducer_cfi.py:16
hltEgammaHLTExtra_cfi.trks
trks
Definition: hltEgammaHLTExtra_cfi.py:43
ParameterSet.h
reco::ConversionTrack::setIsGsfTrackOpen
void setIsGsfTrackOpen(bool b)
Definition: ConversionTrack.h:41
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
ConversionTrackProducer::ConversionTrackProducer
ConversionTrackProducer(const edm::ParameterSet &conf)
Definition: ConversionTrackProducer.cc:75
reco::ConversionTrack::setIsArbitratedMergedEcalGeneral
void setIsArbitratedMergedEcalGeneral(bool b)
Definition: ConversionTrack.h:44
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
ConversionTrackProducer::ConvTrackPreSelector
IdealHelixParameters ConvTrackPreSelector
Definition: ConversionTrackProducer.cc:69
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.cc:55