CMS 3D CMS Logo

SiStripOnTrackClusterTableProducerBase.cc
Go to the documentation of this file.
4 
6 
8 
9 namespace {
11  for (auto iTr = tracks.begin(); iTr != tracks.end(); ++iTr) {
12  if (&(*iTr) == track) {
13  return iTr - tracks.begin();
14  }
15  }
16  return -2;
17  }
18 } // namespace
19 
22  iEvent.getByToken(m_tracks_token, tracks);
23  edm::Handle<TrajTrackAssociationCollection> trajTrackAssociations;
24  iEvent.getByToken(m_association_token, trajTrackAssociations);
25 
26  std::vector<OnTrackCluster> clusters{};
27 
28  for (const auto& assoc : *trajTrackAssociations) {
29  const auto traj = assoc.key.get();
30  const auto track = assoc.val.get();
31 
32  for (const auto& meas : traj->measurements()) {
33  const auto& trajState = meas.updatedState();
34  if (!trajState.isValid())
35  continue;
36 
37  // there can be 2 (stereo module), 1 (no stereo module), or 0 (no strip hit) clusters per measurement
38  const auto trechit = meas.recHit()->hit();
39  const auto simple1d = dynamic_cast<const SiStripRecHit1D*>(trechit);
40  const auto simple = dynamic_cast<const SiStripRecHit2D*>(trechit);
41  const auto matched = dynamic_cast<const SiStripMatchedRecHit2D*>(trechit);
42  if (matched) {
43  clusters.emplace_back(matched->monoId(), &matched->monoCluster(), traj, track, meas);
44  clusters.emplace_back(matched->stereoId(), &matched->stereoCluster(), traj, track, meas);
45  } else if (simple) {
46  clusters.emplace_back(simple->geographicalId().rawId(), simple->cluster().get(), traj, track, meas);
47  } else if (simple1d) {
48  clusters.emplace_back(simple1d->geographicalId().rawId(), simple1d->cluster().get(), traj, track, meas);
49  }
50  }
51  }
52 
53  auto out = std::make_unique<nanoaod::FlatTable>(clusters.size(), m_name, false, m_extension);
54  if (!m_extension) {
55  std::vector<int> c_trackindex;
56  c_trackindex.reserve(clusters.size());
57  std::vector<uint32_t> c_rawid;
58  c_rawid.reserve(clusters.size());
59  for (const auto clus : clusters) {
60  c_trackindex.push_back(findTrackIndex(*tracks, clus.track));
61  c_rawid.push_back(clus.det);
62  }
63  addColumn(out.get(), "trackindex", c_trackindex, "Track index");
64  addColumn(out.get(), "rawid", c_rawid, "DetId");
65  }
66  fillTable(clusters, *tracks, out.get(), iSetup);
67  iEvent.put(std::move(out));
68 }
muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
SiStripOnTrackClusterTableProducerBase::m_tracks_token
const edm::EDGetTokenT< edm::View< reco::Track > > m_tracks_token
Definition: SiStripOnTrackClusterTableProducerBase.h:54
edm::Handle
Definition: AssociativeIterator.h:50
SiStripOnTrackClusterTableProducerBase::m_name
const std::string m_name
Definition: SiStripOnTrackClusterTableProducerBase.h:50
trackingPlots.assoc
assoc
Definition: trackingPlots.py:183
SiStripOnTrackClusterTableProducerBase::m_extension
bool m_extension
Definition: SiStripOnTrackClusterTableProducerBase.h:52
SiStripOnTrackClusterTableProducerBase::m_association_token
const edm::EDGetTokenT< TrajTrackAssociationCollection > m_association_token
Definition: SiStripOnTrackClusterTableProducerBase.h:55
reco::Track
Definition: Track.h:27
SiStripOnTrackClusterTableProducerBase::addColumn
static void addColumn(nanoaod::FlatTable *table, const std::string &name, VALUES &&values, const std::string &doc)
Definition: SiStripOnTrackClusterTableProducerBase.h:44
SiStripOnTrackClusterTableProducerBase::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) final
Definition: SiStripOnTrackClusterTableProducerBase.cc:20
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
edm::View
Definition: CaloClusterFwd.h:14
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
SiStripOnTrackClusterTableProducerBase::fillTable
virtual void fillTable(const std::vector< OnTrackCluster > &clusters, const edm::View< reco::Track > &tracks, nanoaod::FlatTable *table, const edm::EventSetup &iSetup)=0
SiStripRecHit1D.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
SiStripOnTrackClusterTableProducerBase::~SiStripOnTrackClusterTableProducerBase
~SiStripOnTrackClusterTableProducerBase() override
Definition: SiStripOnTrackClusterTableProducerBase.cc:7
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
SiStripMatchedRecHit2D.h
edm::Event
Definition: Event.h:73
SiStripRecHit2D.h
SiStripOnTrackClusterTableProducerBase.h
shallow::findTrackIndex
int findTrackIndex(const edm::Handle< edm::View< reco::Track > > &h, const reco::Track *t)
Definition: ShallowTools.cc:25