CMS 3D CMS Logo

SeedGeneratorFromProtoTracksEDProducer.cc
Go to the documentation of this file.
2 
5 
10 
18 
23 
25 #include <vector>
26 
27 using namespace edm;
28 using namespace reco;
29 
30 template <class T>
31 T sqr(T t) {
32  return t * t;
33 }
35 
37  bool operator()(const Hit& h1, const Hit& h2) { return h1->globalPosition().perp2() < h2->globalPosition().perp2(); }
38 };
39 
42  desc.add<InputTag>("InputCollection", InputTag("pixelTracks"));
43  desc.add<InputTag>("InputVertexCollection", InputTag(""));
44  desc.add<double>("originHalfLength", 1E9);
45  desc.add<double>("originRadius", 1E9);
46  desc.add<bool>("useProtoTrackKinematics", false);
47  desc.add<bool>("useEventsWithNoVertex", true);
48  desc.add<std::string>("TTRHBuilder", "TTRHBuilderWithoutAngle4PixelTriplets");
49  desc.add<bool>("usePV", false);
50  desc.add<bool>("includeFourthHit", false);
51 
53  psd0.add<std::string>("ComponentName", std::string("SeedFromConsecutiveHitsCreator"));
54  psd0.add<std::string>("propagator", std::string("PropagatorWithMaterial"));
55  psd0.add<double>("SeedMomentumForBOFF", 5.0);
56  psd0.add<double>("OriginTransverseErrorMultiplier", 1.0);
57  psd0.add<double>("MinOneOverPtError", 1.0);
58  psd0.add<std::string>("magneticField", std::string(""));
59  psd0.add<std::string>("TTRHBuilder", std::string("WithTrackAngle"));
60  psd0.add<bool>("forceKinematicWithRegionDirection", false);
61  desc.add<edm::ParameterSetDescription>("SeedCreatorPSet", psd0);
62 
63  descriptions.add("SeedGeneratorFromProtoTracksEDProducer", desc);
64 }
65 
67  : theConfig(cfg),
68  originHalfLength(cfg.getParameter<double>("originHalfLength")),
69  originRadius(cfg.getParameter<double>("originRadius")),
70  useProtoTrackKinematics(cfg.getParameter<bool>("useProtoTrackKinematics")),
71  useEventsWithNoVertex(cfg.getParameter<bool>("useEventsWithNoVertex")),
72  builderName(cfg.getParameter<std::string>("TTRHBuilder")),
73  usePV_(cfg.getParameter<bool>("usePV")),
74  includeFourthHit_(cfg.getParameter<bool>("includeFourthHit")),
75  theInputCollectionTag(consumes<reco::TrackCollection>(cfg.getParameter<InputTag>("InputCollection"))),
76  theInputVertexCollectionTag(
77  consumes<reco::VertexCollection>(cfg.getParameter<InputTag>("InputVertexCollection"))) {
78  produces<TrajectorySeedCollection>();
79 }
80 
82  auto result = std::make_unique<TrajectorySeedCollection>();
84  ev.getByToken(theInputCollectionTag, trks);
85 
86  const TrackCollection& protos = *(trks.product());
87 
89  bool foundVertices = ev.getByToken(theInputVertexCollectionTag, vertices);
90  //const reco::VertexCollection & vertices = *(h_vertices.product());
91 
95  for (TrackCollection::const_iterator it = protos.begin(); it != protos.end(); ++it) {
96  const Track& proto = (*it);
97  GlobalPoint vtx(proto.vertex().x(), proto.vertex().y(), proto.vertex().z());
98 
99  // check the compatibility with a primary vertex
100  bool keepTrack = false;
101  if ((!foundVertices) || vertices->empty()) {
103  keepTrack = true;
104  } else if (usePV_) {
105  GlobalPoint aPV(
106  vertices->begin()->position().x(), vertices->begin()->position().y(), vertices->begin()->position().z());
107  double distR2 = sqr(vtx.x() - aPV.x()) + sqr(vtx.y() - aPV.y());
108  double distZ = fabs(vtx.z() - aPV.z());
109  if (distR2 < sqr(originRadius) && distZ < originHalfLength) {
110  keepTrack = true;
111  }
112  } else {
113  for (reco::VertexCollection::const_iterator iv = vertices->begin(); iv != vertices->end(); ++iv) {
114  GlobalPoint aPV(iv->position().x(), iv->position().y(), iv->position().z());
115  double distR2 = sqr(vtx.x() - aPV.x()) + sqr(vtx.y() - aPV.y());
116  double distZ = fabs(vtx.z() - aPV.z());
117  if (distR2 < sqr(originRadius) && distZ < originHalfLength) {
118  keepTrack = true;
119  break;
120  }
121  }
122  }
123  if (!keepTrack)
124  continue;
125 
127  SeedFromProtoTrack seedFromProtoTrack(proto, es);
128  if (seedFromProtoTrack.isValid())
129  (*result).push_back(seedFromProtoTrack.trajectorySeed());
130  } else {
132  es.get<TransientRecHitRecord>().get(builderName, ttrhbESH);
133  std::vector<Hit> hits;
134  for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) {
135  TrackingRecHitRef refHit = proto.recHit(iHit);
136  if (refHit->isValid())
137  hits.push_back((Hit) & (*refHit));
138  }
139  sort(hits.begin(), hits.end(), HitLessByRadius());
140 
141  if (hits.size() > 1) {
142  double mom_perp =
143  sqrt(proto.momentum().x() * proto.momentum().x() + proto.momentum().y() * proto.momentum().y());
144  GlobalTrackingRegion region(mom_perp, vtx, 0.2, 0.2);
145 
146  edm::ParameterSet seedCreatorPSet = theConfig.getParameter<edm::ParameterSet>("SeedCreatorPSet");
147  SeedFromConsecutiveHitsCreator seedCreator(seedCreatorPSet);
148  seedCreator.init(region, es, nullptr);
149  seedCreator.makeSeed(
150  *result,
151  SeedingHitSet(hits[0],
152  hits[1],
153  hits.size() > 2 ? hits[2] : SeedingHitSet::nullPtr(),
154  (includeFourthHit_ && hits.size() > 3) ? hits[3] : SeedingHitSet::nullPtr()));
155  }
156  }
157  }
158 
159  ev.put(std::move(result));
160 }
ConfigurationDescriptions.h
Hit
Definition: HitCollection.h:12
Handle.h
GlobalTrackingRegion.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
SeedFromProtoTrack
Definition: SeedFromProtoTrack.h:16
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
MessageLogger.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
SeedingHitSet
Definition: SeedingHitSet.h:6
SeedGeneratorFromProtoTracksEDProducer::useProtoTrackKinematics
const bool useProtoTrackKinematics
Definition: SeedGeneratorFromProtoTracksEDProducer.h:26
edm
HLT enums.
Definition: AlignableModifier.h:19
gpuVertexFinder::iv
int32_t *__restrict__ iv
Definition: gpuClusterTracksDBSCAN.h:42
TransientRecHitRecord.h
SeedFromConsecutiveHitsCreator_cfi.SeedFromConsecutiveHitsCreator
SeedFromConsecutiveHitsCreator
Definition: SeedFromConsecutiveHitsCreator_cfi.py:3
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
SeedingHitSet::ConstRecHitPointer
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:10
SeedFromProtoTrack::trajectorySeed
TrajectorySeed trajectorySeed() const
Definition: SeedFromProtoTrack.cc:78
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TransientRecHitRecord
Definition: TransientRecHitRecord.h:14
SeedFromConsecutiveHitsCreator.h
TransientTrackingRecHit.h
HLT_FULL_cff.useProtoTrackKinematics
useProtoTrackKinematics
Definition: HLT_FULL_cff.py:9921
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
SeedGeneratorFromProtoTracksEDProducer::usePV_
const bool usePV_
Definition: SeedGeneratorFromProtoTracksEDProducer.h:29
rpcPointValidation_cfi.refHit
refHit
Definition: rpcPointValidation_cfi.py:6
edm::Handle< reco::TrackCollection >
GlobalTrackingRegion
Definition: GlobalTrackingRegion.h:13
edm::Ref
Definition: AssociativeIterator.h:58
SeedGeneratorFromProtoTracksEDProducer::theInputCollectionTag
const edm::EDGetTokenT< reco::TrackCollection > theInputCollectionTag
Definition: SeedGeneratorFromProtoTracksEDProducer.h:31
reco::Track::recHitsSize
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits).
Definition: Track.h:97
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
HitLessByRadius
Definition: SeedGeneratorFromProtoTracksEDProducer.cc:36
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
nHits
const caConstants::TupleMultiplicity *__restrict__ const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t nHits
Definition: BrokenLineFitOnGPU.h:27
SeedingHitSet.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::Track
Definition: Track.h:27
edm::ESHandle< TransientTrackingRecHitBuilder >
Point3DBase< float, GlobalTag >
ParameterSetDescription.h
sqr
T sqr(T t)
Definition: SeedGeneratorFromProtoTracksEDProducer.cc:31
SeedGeneratorFromProtoTracksEDProducer::includeFourthHit_
const bool includeFourthHit_
Definition: SeedGeneratorFromProtoTracksEDProducer.h:30
SeedGeneratorFromProtoTracksEDProducer::builderName
const std::string builderName
Definition: SeedGeneratorFromProtoTracksEDProducer.h:28
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
HLT_FULL_cff.useEventsWithNoVertex
useEventsWithNoVertex
Definition: HLT_FULL_cff.py:9919
SeedFromProtoTrack.h
edm::ParameterSet
Definition: ParameterSet.h:47
SeedingHitSet::nullPtr
static ConstRecHitPointer nullPtr()
Definition: SeedingHitSet.h:12
Event.h
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
SeedGeneratorFromProtoTracksEDProducer::produce
void produce(edm::Event &ev, const edm::EventSetup &es) override
Definition: SeedGeneratorFromProtoTracksEDProducer.cc:81
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88267
SeedFromProtoTrack::isValid
bool isValid() const
Definition: SeedFromProtoTrack.h:25
SeedGeneratorFromProtoTracksEDProducer::originRadius
const double originRadius
Definition: SeedGeneratorFromProtoTracksEDProducer.h:25
edm::EventSetup
Definition: EventSetup.h:58
SeedGeneratorFromProtoTracksEDProducer::originHalfLength
const double originHalfLength
Definition: SeedGeneratorFromProtoTracksEDProducer.h:24
get
#define get
SeedGeneratorFromProtoTracksEDProducer::theInputVertexCollectionTag
const edm::EDGetTokenT< reco::VertexCollection > theInputVertexCollectionTag
Definition: SeedGeneratorFromProtoTracksEDProducer.h:32
TrajectorySeedCollection.h
reco::Track::recHit
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
Definition: Track.h:94
reco::TrackBase::vertex
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead
Definition: TrackBase.h:676
SeedGeneratorFromProtoTracksEDProducer::useEventsWithNoVertex
const bool useEventsWithNoVertex
Definition: SeedGeneratorFromProtoTracksEDProducer.h:27
InputTag.h
looper.cfg
cfg
Definition: looper.py:297
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
LaserSeedGenerator_cfi.originHalfLength
originHalfLength
Definition: LaserSeedGenerator_cfi.py:4
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
T
long double T
Definition: Basic3DVectorLD.h:48
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
SeedGeneratorFromProtoTracksEDProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: SeedGeneratorFromProtoTracksEDProducer.cc:40
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SeedGeneratorFromProtoTracksEDProducer::SeedGeneratorFromProtoTracksEDProducer
SeedGeneratorFromProtoTracksEDProducer(const edm::ParameterSet &cfg)
Definition: SeedGeneratorFromProtoTracksEDProducer.cc:66
TransientTrackingRecHitBuilder.h
hltEgammaHLTExtra_cfi.trks
trks
Definition: hltEgammaHLTExtra_cfi.py:43
mps_fire.result
result
Definition: mps_fire.py:311
reco::TrackBase::momentum
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:664
edm::Event
Definition: Event.h:73
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
HitLessByRadius::operator()
bool operator()(const Hit &h1, const Hit &h2)
Definition: SeedGeneratorFromProtoTracksEDProducer.cc:37
Hit
SeedingHitSet::ConstRecHitPointer Hit
Definition: SeedGeneratorFromProtoTracksEDProducer.cc:34
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7
SeedGeneratorFromProtoTracksEDProducer::theConfig
const edm::ParameterSet theConfig
Definition: SeedGeneratorFromProtoTracksEDProducer.h:23
SeedGeneratorFromProtoTracksEDProducer.h
LaserSeedGenerator_cfi.originRadius
originRadius
Definition: LaserSeedGenerator_cfi.py:10