CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Attributes
SiStripOnTrackClusterTableProducerBase Class Referenceabstract

#include <SiStripOnTrackClusterTableProducerBase.h>

Inheritance diagram for SiStripOnTrackClusterTableProducerBase:
edm::stream::EDProducer<> SiStripGainCalibTableProducer SiStripPositionCorrectionsTableProducer

Classes

struct  OnTrackCluster
 

Public Member Functions

virtual void fillTable (const std::vector< OnTrackCluster > &clusters, const edm::View< reco::Track > &tracks, nanoaod::FlatTable *table, const edm::EventSetup &iSetup)=0
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) final
 
 SiStripOnTrackClusterTableProducerBase (const edm::ParameterSet &params)
 
 ~SiStripOnTrackClusterTableProducerBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

template<typename VALUES >
static void addColumn (nanoaod::FlatTable *table, const std::string &name, VALUES &&values, const std::string &doc)
 

Private Attributes

const edm::EDGetTokenT< TrajTrackAssociationCollectionm_association_token
 
const std::string m_doc
 
bool m_extension
 
const std::string m_name
 
const edm::EDGetTokenT< edm::View< reco::Track > > m_tracks_token
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 10 of file SiStripOnTrackClusterTableProducerBase.h.

Constructor & Destructor Documentation

◆ SiStripOnTrackClusterTableProducerBase()

SiStripOnTrackClusterTableProducerBase::SiStripOnTrackClusterTableProducerBase ( const edm::ParameterSet params)
inlineexplicit

Definition at line 12 of file SiStripOnTrackClusterTableProducerBase.h.

13  : m_name(params.getParameter<std::string>("name")),
14  m_doc(params.existsAs<std::string>("doc") ? params.getParameter<std::string>("doc") : ""),
15  m_extension(params.existsAs<bool>("extension") ? params.getParameter<bool>("extension") : true),
16  m_tracks_token(consumes<edm::View<reco::Track>>(params.getParameter<edm::InputTag>("Tracks"))),
17  m_association_token(consumes<TrajTrackAssociationCollection>(params.getParameter<edm::InputTag>("Tracks"))) {
18  produces<nanoaod::FlatTable>();
19  }
const edm::EDGetTokenT< TrajTrackAssociationCollection > m_association_token
const edm::EDGetTokenT< edm::View< reco::Track > > m_tracks_token

◆ ~SiStripOnTrackClusterTableProducerBase()

SiStripOnTrackClusterTableProducerBase::~SiStripOnTrackClusterTableProducerBase ( )
override

Definition at line 7 of file SiStripOnTrackClusterTableProducerBase.cc.

7 {}

Member Function Documentation

◆ addColumn()

template<typename VALUES >
static void SiStripOnTrackClusterTableProducerBase::addColumn ( nanoaod::FlatTable table,
const std::string &  name,
VALUES &&  values,
const std::string &  doc 
)
inlinestatic

◆ fillTable()

virtual void SiStripOnTrackClusterTableProducerBase::fillTable ( const std::vector< OnTrackCluster > &  clusters,
const edm::View< reco::Track > &  tracks,
nanoaod::FlatTable table,
const edm::EventSetup iSetup 
)
pure virtual

◆ produce()

void SiStripOnTrackClusterTableProducerBase::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
final

Definition at line 20 of file SiStripOnTrackClusterTableProducerBase.cc.

References addColumn(), trackingPlots::assoc, bsc_activity_cfg::clusters, fillTable(), shallow::findTrackIndex(), iEvent, m_association_token, m_extension, m_name, m_tracks_token, muonTagProbeFilters_cff::matched, eostools::move(), MillePedeFileConverter_cfg::out, HLT_2024v14_cff::track, and DiMuonV_cfg::tracks.

20  {
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 }
int findTrackIndex(const edm::Handle< edm::View< reco::Track > > &h, const reco::Track *t)
Definition: ShallowTools.cc:25
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< TrajTrackAssociationCollection > m_association_token
static void addColumn(nanoaod::FlatTable *table, const std::string &name, VALUES &&values, const std::string &doc)
const edm::EDGetTokenT< edm::View< reco::Track > > m_tracks_token
virtual void fillTable(const std::vector< OnTrackCluster > &clusters, const edm::View< reco::Track > &tracks, nanoaod::FlatTable *table, const edm::EventSetup &iSetup)=0
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ m_association_token

const edm::EDGetTokenT<TrajTrackAssociationCollection> SiStripOnTrackClusterTableProducerBase::m_association_token
private

Definition at line 55 of file SiStripOnTrackClusterTableProducerBase.h.

Referenced by produce().

◆ m_doc

const std::string SiStripOnTrackClusterTableProducerBase::m_doc
private

Definition at line 51 of file SiStripOnTrackClusterTableProducerBase.h.

◆ m_extension

bool SiStripOnTrackClusterTableProducerBase::m_extension
private

Definition at line 52 of file SiStripOnTrackClusterTableProducerBase.h.

Referenced by produce().

◆ m_name

const std::string SiStripOnTrackClusterTableProducerBase::m_name
private

Definition at line 50 of file SiStripOnTrackClusterTableProducerBase.h.

Referenced by produce().

◆ m_tracks_token

const edm::EDGetTokenT<edm::View<reco::Track> > SiStripOnTrackClusterTableProducerBase::m_tracks_token
private

Definition at line 54 of file SiStripOnTrackClusterTableProducerBase.h.

Referenced by produce().