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 
34 
36  : conf_(conf),
37  trackProducer(conf.getParameter<std::string>("TrackProducer")),
38  useTrajectory(conf.getParameter<bool>("useTrajectory")),
39  setTrackerOnly(conf.getParameter<bool>("setTrackerOnly")),
40  setIsGsfTrackOpen(conf.getParameter<bool>("setIsGsfTrackOpen")),
41  setArbitratedEcalSeeded(conf.getParameter<bool>("setArbitratedEcalSeeded")),
42  setArbitratedMerged(conf.getParameter<bool>("setArbitratedMerged")),
43  setArbitratedMergedEcalGeneral(conf.getParameter<bool>("setArbitratedMergedEcalGeneral")),
44  beamSpotInputTag(consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("beamSpotInputTag"))),
45  filterOnConvTrackHyp(conf.getParameter<bool>("filterOnConvTrackHyp")),
46  minConvRadius(conf.getParameter<double>("minConvRadius")) {
48  genericTracks = consumes<edm::View<reco::Track> >(thetp);
49  kfTrajectories = consumes<TrajTrackAssociationCollection>(thetp);
50  gsfTrajectories = consumes<TrajGsfTrackAssociationCollection>(thetp);
51  produces<reco::ConversionTrackCollection>();
52 }
53 
54 // Virtual destructor needed.
56 
57 // Functions that gets called by framework every event
59  //get input collection (through edm::View)
61  e.getByToken(genericTracks, hTrks);
62 
63  //get association maps between trajectories and tracks and build temporary maps
66 
67  std::map<reco::TrackRef, edm::Ref<std::vector<Trajectory> > > tracktrajmap;
68  std::map<reco::GsfTrackRef, edm::Ref<std::vector<Trajectory> > > gsftracktrajmap;
69 
70  if (useTrajectory) {
71  if (!hTrks->empty()) {
72  if (dynamic_cast<const reco::GsfTrack*>(&hTrks->at(0))) {
73  //fill map for gsf tracks
74  e.getByToken(gsfTrajectories, hTTAssGsf);
75  for (TrajGsfTrackAssociationCollection::const_iterator iPair = hTTAssGsf->begin(); iPair != hTTAssGsf->end();
76  ++iPair) {
77  gsftracktrajmap[iPair->val] = iPair->key;
78  }
79 
80  } else {
81  //fill map for standard tracks
82  e.getByToken(kfTrajectories, hTTAss);
83  for (TrajTrackAssociationCollection::const_iterator iPair = hTTAss->begin(); iPair != hTTAss->end(); ++iPair) {
84  tracktrajmap[iPair->val] = iPair->key;
85  }
86  }
87  }
88  }
89 
90  // Step B: create empty output collection
91  outputTrks = std::make_unique<reco::ConversionTrackCollection>();
92 
93  //--------------------------------------------------
94  //Added by D. Giordano
95  // 2011/08/05
96  // Reduction of the track sample based on geometric hypothesis for conversion tracks
97 
98  edm::Handle<reco::BeamSpot> beamSpotHandle;
99  e.getByToken(beamSpotInputTag, beamSpotHandle);
100 
101  edm::ESHandle<MagneticField> magFieldHandle;
102  es.get<IdealMagneticFieldRecord>().get(magFieldHandle);
103 
104  if (filterOnConvTrackHyp && !beamSpotHandle.isValid()) {
105  edm::LogError("Invalid Collection") << "invalid collection for the BeamSpot";
106  throw;
107  }
108 
109  ConvTrackPreSelector.setMagnField(magFieldHandle.product());
110 
111  //----------------------------------------------------------
112 
113  // Simple conversion of tracks to conversion tracks, setting appropriate flags from configuration
114  for (size_t i = 0; i < hTrks->size(); ++i) {
115  //--------------------------------------------------
116  //Added by D. Giordano
117  // 2011/08/05
118  // Reduction of the track sample based on geometric hypothesis for conversion tracks
119 
120  math::XYZVector beamSpot = math::XYZVector(beamSpotHandle->position());
121  edm::RefToBase<reco::Track> trackBaseRef = hTrks->refAt(i);
122  if (filterOnConvTrackHyp &&
124  continue;
125  //--------------------------------------------------
126 
127  reco::ConversionTrack convTrack(trackBaseRef);
128  convTrack.setIsTrackerOnly(setTrackerOnly);
133 
134  //fill trajectory association if configured, using correct map depending on track type
135  if (useTrajectory) {
136  if (!gsftracktrajmap.empty()) {
137  convTrack.setTrajRef(gsftracktrajmap.find(trackBaseRef.castTo<reco::GsfTrackRef>())->second);
138  } else {
139  convTrack.setTrajRef(tracktrajmap.find(trackBaseRef.castTo<reco::TrackRef>())->second);
140  }
141  }
142 
143  outputTrks->push_back(convTrack);
144  }
145 
146  e.put(std::move(outputTrks));
147  return;
148 
149 } //end produce
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
ConversionTrackProducer::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: ConversionTrackProducer.cc:58
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
reco::ConversionTrack::setIsArbitratedMerged
void setIsArbitratedMerged(bool b)
Definition: ConversionTrack.h:43
mps_fire.i
i
Definition: mps_fire.py:355
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.h:75
ESHandle.h
align::BeamSpot
Definition: StructureType.h:89
L1TCSCTF_cfi.trackProducer
trackProducer
Run2: False; Run1: True.
Definition: L1TCSCTF_cfi.py:12
edm
HLT enums.
Definition: AlignableModifier.h:19
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
edm::Handle
Definition: AssociativeIterator.h:50
ConversionTrackProducer::setTrackerOnly
bool setTrackerOnly
Definition: ConversionTrackProducer.h:62
ConversionTrackProducer::setArbitratedMerged
bool setArbitratedMerged
Definition: ConversionTrackProducer.h:65
edm::Ref< GsfTrackCollection >
ConversionTrackProducer::kfTrajectories
edm::EDGetTokenT< TrajTrackAssociationCollection > kfTrajectories
Definition: ConversionTrackProducer.h:59
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
edm::AssociationMap::end
const_iterator end() const
last iterator over the map (read only)
Definition: AssociationMap.h:171
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
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:58
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
ConversionTrackProducer::setArbitratedMergedEcalGeneral
bool setArbitratedMergedEcalGeneral
Definition: ConversionTrackProducer.h:66
reco::BeamSpot::position
const Point & position() const
position
Definition: BeamSpot.h:59
reco::ConversionTrack::setTrajRef
void setTrajRef(edm::Ref< std::vector< Trajectory > > tr)
Definition: ConversionTrack.h:39
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ConversionTrackProducer::setArbitratedEcalSeeded
bool setArbitratedEcalSeeded
Definition: ConversionTrackProducer.h:64
conversionOpenTrackSequence_cff.setArbitratedEcalSeeded
setArbitratedEcalSeeded
Definition: conversionOpenTrackSequence_cff.py:10
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::GsfTrackCollection, unsigned short > >::const_iterator
friend struct const_iterator
Definition: AssociationMap.h:274
ConversionTrackProducer::useTrajectory
bool useTrajectory
Definition: ConversionTrackProducer.h:61
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
ConversionTrackProducer::filterOnConvTrackHyp
bool filterOnConvTrackHyp
Definition: ConversionTrackProducer.h:74
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
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:60
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
ConversionTrackProducer.h
get
#define get
ConversionTrackProducer::trackProducer
std::string trackProducer
Definition: ConversionTrackProducer.h:57
Trajectory.h
reco::ConversionTrack::setIsTrackerOnly
void setIsTrackerOnly(bool b)
Definition: ConversionTrack.h:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
GsfTrackFwd.h
conversionOpenTrackSequence_cff.setArbitratedMergedEcalGeneral
setArbitratedMergedEcalGeneral
Definition: conversionOpenTrackSequence_cff.py:9
edm::AssociationMap::begin
const_iterator begin() const
first iterator over the map (read only)
Definition: AssociationMap.h:169
ConversionTrackProducer::~ConversionTrackProducer
~ConversionTrackProducer() override
Definition: ConversionTrackProducer.cc:55
edm::RefToBase< reco::Track >
ConversionTrackProducer::beamSpotInputTag
edm::EDGetTokenT< reco::BeamSpot > beamSpotInputTag
Definition: ConversionTrackProducer.h:73
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:35
reco::ConversionTrack::setIsArbitratedMergedEcalGeneral
void setIsArbitratedMergedEcalGeneral(bool b)
Definition: ConversionTrack.h:44
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
ConversionTrackProducer::outputTrks
std::unique_ptr< reco::ConversionTrackCollection > outputTrks
Definition: ConversionTrackProducer.h:79
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:63