CMS 3D CMS Logo

LSTPixelSeedInputProducer.cc
Go to the documentation of this file.
2 
6 
8 
11 
14 
16 
20 
22 
24 public:
25  explicit LSTPixelSeedInputProducer(edm::ParameterSet const& iConfig);
26  ~LSTPixelSeedInputProducer() override = default;
27 
28  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
29 
30 private:
31  void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
32 
35  std::vector<edm::EDGetTokenT<edm::View<reco::Track>>> seedTokens_;
38 };
39 
41  : mfToken_(esConsumes()),
42  beamSpotToken_(consumes(iConfig.getParameter<edm::InputTag>("beamSpot"))),
43  lstPixelSeedInputPutToken_(produces()),
44  lstPixelSeedsPutToken_(produces()) {
45  seedTokens_ = edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag>>("seedTracks"),
46  [&](const edm::InputTag& tag) { return consumes<edm::View<reco::Track>>(tag); });
47 }
48 
51 
52  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
53 
54  desc.add<std::vector<edm::InputTag>>("seedTracks",
55  std::vector<edm::InputTag>{edm::InputTag("lstInitialStepSeedTracks"),
56  edm::InputTag("lstHighPtTripletStepSeedTracks")});
57 
58  descriptions.addWithDefaultLabel(desc);
59 }
60 
62  // Setup
63  auto const& mf = iSetup.getData(mfToken_);
64  auto const& bs = iEvent.get(beamSpotToken_);
65 
66  // Vector definitions
67  std::vector<float> see_px;
68  std::vector<float> see_py;
69  std::vector<float> see_pz;
70  std::vector<float> see_dxy;
71  std::vector<float> see_dz;
72  std::vector<float> see_ptErr;
73  std::vector<float> see_etaErr;
74  std::vector<float> see_stateTrajGlbX;
75  std::vector<float> see_stateTrajGlbY;
76  std::vector<float> see_stateTrajGlbZ;
77  std::vector<float> see_stateTrajGlbPx;
78  std::vector<float> see_stateTrajGlbPy;
79  std::vector<float> see_stateTrajGlbPz;
80  std::vector<int> see_q;
81  std::vector<std::vector<int>> see_hitIdx;
82  TrajectorySeedCollection see_seeds;
83 
84  for (size_t iColl = 0; iColl < seedTokens_.size(); ++iColl) {
85  // Get seed tokens
86  auto const& seedToken = seedTokens_[iColl];
87  auto const& seedTracks = iEvent.get(seedToken);
88 
89  if (seedTracks.empty())
90  continue;
91 
92  // Get seed track refs
94  for (edm::View<reco::Track>::size_type i = 0; i < seedTracks.size(); ++i) {
95  seedTrackRefs.push_back(seedTracks.refAt(i));
96  }
97 
98  edm::ProductID id = seedTracks[0].seedRef().id();
99 
100  for (size_t iSeed = 0; iSeed < seedTrackRefs.size(); ++iSeed) {
101  auto const& seedTrackRef = seedTrackRefs[iSeed];
102  auto const& seedTrack = *seedTrackRef;
103  auto const& seedRef = seedTrack.seedRef();
104  auto const& seed = *seedRef;
105 
106  if (seedRef.id() != id)
107  throw cms::Exception("LogicError")
108  << "All tracks in 'TracksFromSeeds' collection should point to seeds in the same collection. Now the "
109  "element 0 had ProductID "
110  << id << " while the element " << seedTrackRef.key() << " had " << seedTrackRef.id() << ".";
111 
112  const bool seedFitOk = !trackFromSeedFitFailed(seedTrack);
113 
114  const TrackingRecHit* lastRecHit = &*(seed.recHits().end() - 1);
116  trajectoryStateTransform::transientState(seed.startingState(), lastRecHit->surface(), &mf);
117  auto const& stateGlobal = tsos.globalParameters();
118 
119  std::vector<int> hitIdx;
120  for (auto const& hit : seed.recHits()) {
121  int subid = hit.geographicalId().subdetId();
122  if (subid == (int)PixelSubdetector::PixelBarrel || subid == (int)PixelSubdetector::PixelEndcap) {
123  const BaseTrackerRecHit* bhit = dynamic_cast<const BaseTrackerRecHit*>(&hit);
124  const auto& clusterRef = bhit->firstClusterRef();
125  const auto clusterKey = clusterRef.cluster_pixel().key();
126  hitIdx.push_back(clusterKey);
127  } else {
128  throw cms::Exception("LSTPixelSeedInputProducer") << "Not pixel hits found!";
129  }
130  }
131 
132  // Fill output
133  see_px.push_back(seedFitOk ? seedTrack.px() : 0);
134  see_py.push_back(seedFitOk ? seedTrack.py() : 0);
135  see_pz.push_back(seedFitOk ? seedTrack.pz() : 0);
136  see_dxy.push_back(seedFitOk ? seedTrack.dxy(bs.position()) : 0);
137  see_dz.push_back(seedFitOk ? seedTrack.dz(bs.position()) : 0);
138  see_ptErr.push_back(seedFitOk ? seedTrack.ptError() : 0);
139  see_etaErr.push_back(seedFitOk ? seedTrack.etaError() : 0);
140  see_stateTrajGlbX.push_back(stateGlobal.position().x());
141  see_stateTrajGlbY.push_back(stateGlobal.position().y());
142  see_stateTrajGlbZ.push_back(stateGlobal.position().z());
143  see_stateTrajGlbPx.push_back(stateGlobal.momentum().x());
144  see_stateTrajGlbPy.push_back(stateGlobal.momentum().y());
145  see_stateTrajGlbPz.push_back(stateGlobal.momentum().z());
146  see_q.push_back(seedTrack.charge());
147  see_hitIdx.push_back(hitIdx);
148  see_seeds.push_back(seed);
149  }
150  }
151 
152  LSTPixelSeedInput pixelSeedInput(std::move(see_px),
153  std::move(see_py),
154  std::move(see_pz),
156  std::move(see_dz),
165  std::move(see_q),
167  iEvent.emplace(lstPixelSeedInputPutToken_, std::move(pixelSeedInput));
168  iEvent.emplace(lstPixelSeedsPutToken_, std::move(see_seeds));
169 }
170 
const edm::EDPutTokenT< LSTPixelSeedInput > lstPixelSeedInputPutToken_
unsigned int size_type
Definition: View.h:92
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const std::vector< int > & see_q()
Definition: Trktree.cc:6752
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const std::vector< float > & see_py()
Definition: Trktree.cc:6727
bool trackFromSeedFitFailed(const reco::Track &track)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const std::vector< float > & see_stateTrajGlbX()
Definition: Trktree.cc:6809
const std::vector< float > & see_stateTrajGlbY()
Definition: Trktree.cc:6810
const std::vector< float > & see_ptErr()
Definition: Trktree.cc:6880
const GlobalTrajectoryParameters & globalParameters() const
~LSTPixelSeedInputProducer() override=default
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
size_type size() const
const std::vector< float > & see_stateTrajGlbPz()
Definition: Trktree.cc:6721
const std::vector< float > & see_stateTrajGlbPy()
Definition: Trktree.cc:7008
key_type key() const
Accessor for product key.
Definition: Ref.h:244
ClusterPixelRef cluster_pixel() const
int iEvent
Definition: GenABIO.cc:224
std::vector< TrajectorySeed > TrajectorySeedCollection
virtual const Surface * surface() const
const edm::EDPutTokenT< TrajectorySeedCollection > lstPixelSeedsPutToken_
const std::vector< float > & see_stateTrajGlbPx()
Definition: Trktree.cc:6881
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > mfToken_
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
virtual OmniClusterRef const & firstClusterRef() const =0
const std::vector< float > & see_dz()
Definition: Trktree.cc:6911
const std::vector< float > & see_etaErr()
Definition: Trktree.cc:6829
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
const std::vector< float > & see_px()
Definition: Trktree.cc:6899
HLT enums.
const std::vector< float > & see_dxy()
Definition: Trktree.cc:6779
void push_back(const RefToBase< T > &)
const edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > seedTokens_
const std::vector< float > & see_pz()
Definition: Trktree.cc:6900
def move(src, dest)
Definition: eostools.py:511
LSTPixelSeedInputProducer(edm::ParameterSet const &iConfig)
const std::vector< float > & see_stateTrajGlbZ()
Definition: Trktree.cc:6808
const std::vector< std::vector< int > > & see_hitIdx()
Definition: Trktree.cc:6734