CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SeedGeneratorFromProtoTracksEDProducer.cc
Go to the documentation of this file.
2 
5 
10 
16 
21 
23 #include <vector>
24 
25 using namespace edm;
26 using namespace reco;
27 
28 template <class T>
29 T sqr(T t) {
30  return t * t;
31 }
33 
35  bool operator()(const Hit& h1, const Hit& h2) { return h1->globalPosition().perp2() < h2->globalPosition().perp2(); }
36 };
37 
40  desc.add<InputTag>("InputCollection", InputTag("pixelTracks"));
41  desc.add<InputTag>("InputVertexCollection", InputTag(""));
42  desc.add<double>("originHalfLength", 1E9);
43  desc.add<double>("originRadius", 1E9);
44  desc.add<bool>("useProtoTrackKinematics", false);
45  desc.add<bool>("useEventsWithNoVertex", true);
46  desc.add<std::string>("TTRHBuilder", "TTRHBuilderWithoutAngle4PixelTriplets");
47  desc.add<bool>("usePV", false);
48  desc.add<bool>("includeFourthHit", false);
49 
51  psd0.add<std::string>("ComponentName", std::string("SeedFromConsecutiveHitsCreator"));
52  psd0.add<std::string>("propagator", std::string("PropagatorWithMaterial"));
53  psd0.add<double>("SeedMomentumForBOFF", 5.0);
54  psd0.add<double>("OriginTransverseErrorMultiplier", 1.0);
55  psd0.add<double>("MinOneOverPtError", 1.0);
56  psd0.add<std::string>("magneticField", std::string(""));
57  psd0.add<std::string>("TTRHBuilder", std::string("WithTrackAngle"));
58  psd0.add<bool>("forceKinematicWithRegionDirection", false);
59  desc.add<edm::ParameterSetDescription>("SeedCreatorPSet", psd0);
60 
61  descriptions.add("SeedGeneratorFromProtoTracksEDProducer", desc);
62 }
63 
65  : originHalfLength(cfg.getParameter<double>("originHalfLength")),
66  originRadius(cfg.getParameter<double>("originRadius")),
67  useProtoTrackKinematics(cfg.getParameter<bool>("useProtoTrackKinematics")),
68  useEventsWithNoVertex(cfg.getParameter<bool>("useEventsWithNoVertex")),
69  usePV_(cfg.getParameter<bool>("usePV")),
70  includeFourthHit_(cfg.getParameter<bool>("includeFourthHit")),
71  theInputCollectionTag(consumes<reco::TrackCollection>(cfg.getParameter<InputTag>("InputCollection"))),
72  theInputVertexCollectionTag(
73  consumes<reco::VertexCollection>(cfg.getParameter<InputTag>("InputVertexCollection"))),
74  seedCreator_(cfg.getParameter<edm::ParameterSet>("SeedCreatorPSet"), consumesCollector()),
75  config_(consumesCollector()) {
76  produces<TrajectorySeedCollection>();
77 }
78 
80  auto result = std::make_unique<TrajectorySeedCollection>();
83 
84  const TrackCollection& protos = *(trks.product());
85 
87  bool foundVertices = ev.getByToken(theInputVertexCollectionTag, vertices);
88  //const reco::VertexCollection & vertices = *(h_vertices.product());
89 
93  for (TrackCollection::const_iterator it = protos.begin(); it != protos.end(); ++it) {
94  const Track& proto = (*it);
95  GlobalPoint vtx(proto.vertex().x(), proto.vertex().y(), proto.vertex().z());
96 
97  // check the compatibility with a primary vertex
98  bool keepTrack = false;
99  if ((!foundVertices) || vertices->empty()) {
101  keepTrack = true;
102  } else if (usePV_) {
103  GlobalPoint aPV(
104  vertices->begin()->position().x(), vertices->begin()->position().y(), vertices->begin()->position().z());
105  double distR2 = sqr(vtx.x() - aPV.x()) + sqr(vtx.y() - aPV.y());
106  double distZ = fabs(vtx.z() - aPV.z());
107  if (distR2 < sqr(originRadius) && distZ < originHalfLength) {
108  keepTrack = true;
109  }
110  } else {
111  for (reco::VertexCollection::const_iterator iv = vertices->begin(); iv != vertices->end(); ++iv) {
112  GlobalPoint aPV(iv->position().x(), iv->position().y(), iv->position().z());
113  double distR2 = sqr(vtx.x() - aPV.x()) + sqr(vtx.y() - aPV.y());
114  double distZ = fabs(vtx.z() - aPV.z());
115  if (distR2 < sqr(originRadius) && distZ < originHalfLength) {
116  keepTrack = true;
117  break;
118  }
119  }
120  }
121  if (!keepTrack)
122  continue;
123 
125  SeedFromProtoTrack seedFromProtoTrack(config_, proto, es);
126  if (seedFromProtoTrack.isValid())
127  (*result).push_back(seedFromProtoTrack.trajectorySeed());
128  } else {
129  std::vector<Hit> hits;
130  for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) {
131  TrackingRecHitRef refHit = proto.recHit(iHit);
132  if (refHit->isValid())
133  hits.push_back((Hit) & (*refHit));
134  }
135  sort(hits.begin(), hits.end(), HitLessByRadius());
136 
137  if (hits.size() > 1) {
138  double mom_perp =
139  sqrt(proto.momentum().x() * proto.momentum().x() + proto.momentum().y() * proto.momentum().y());
140  GlobalTrackingRegion region(mom_perp, vtx, 0.2, 0.2);
141 
142  seedCreator_.init(region, es, nullptr);
143  seedCreator_.makeSeed(
144  *result,
145  SeedingHitSet(hits[0],
146  hits[1],
147  hits.size() > 2 ? hits[2] : SeedingHitSet::nullPtr(),
148  (includeFourthHit_ && hits.size() > 3) ? hits[3] : SeedingHitSet::nullPtr()));
149  }
150  }
151  }
152 
153  ev.put(std::move(result));
154 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
tuple cfg
Definition: looper.py:296
int32_t *__restrict__ iv
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
tuple useEventsWithNoVertex
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:97
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
bool ev
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:664
int sqr(const T &t)
tuple result
Definition: mps_fire.py:311
const edm::EDGetTokenT< reco::TrackCollection > theInputCollectionTag
TrajectorySeed trajectorySeed() const
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:676
bool operator()(const Hit &h1, const Hit &h2)
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:10
T sqrt(T t)
Definition: SSEVec.h:19
static ConstRecHitPointer nullPtr()
Definition: SeedingHitSet.h:12
def move
Definition: eostools.py:511
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const edm::EDGetTokenT< reco::VertexCollection > theInputVertexCollectionTag
SeedingHitSet::ConstRecHitPointer Hit
void produce(edm::Event &ev, const edm::EventSetup &es) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell const int32_t nHits
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
Definition: Track.h:94
tuple useProtoTrackKinematics
long double T
tuple originHalfLength