CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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<> 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
< TrajTrackAssociationCollection
m_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 ( 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),
17  m_association_token(consumes<TrajTrackAssociationCollection>(params.getParameter<edm::InputTag>("Tracks"))) {
18  produces<nanoaod::FlatTable>();
19  }
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
const edm::EDGetTokenT< TrajTrackAssociationCollection > m_association_token
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< edm::View< reco::Track > > m_tracks_token
SiStripOnTrackClusterTableProducerBase::~SiStripOnTrackClusterTableProducerBase ( )
override

Definition at line 7 of file SiStripOnTrackClusterTableProducerBase.cc.

7 {}

Member Function Documentation

template<typename VALUES >
static void SiStripOnTrackClusterTableProducerBase::addColumn ( nanoaod::FlatTable table,
const std::string &  name,
VALUES &&  values,
const std::string &  doc 
)
inlinestatic
virtual void SiStripOnTrackClusterTableProducerBase::fillTable ( const std::vector< OnTrackCluster > &  clusters,
const edm::View< reco::Track > &  tracks,
nanoaod::FlatTable table,
const edm::EventSetup iSetup 
)
pure virtual

Implemented in SiStripPositionCorrectionsTableProducer.

Referenced by produce().

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

Definition at line 20 of file SiStripOnTrackClusterTableProducerBase.cc.

References addColumn(), HLT_FULL_cff::clusters, fillTable(), shallow::findTrackIndex(), edm::Event::getByToken(), m_association_token, m_extension, m_name, m_tracks_token, eostools::move(), submitPVResolutionJobs::out, edm::Event::put(), reco::Track::recHit(), HLT_FULL_cff::track, and 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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
int findTrackIndex(const edm::Handle< edm::View< reco::Track > > &h, const reco::Track *t)
Definition: ShallowTools.cc:25
auto const & tracks
cannot be loose
def move
Definition: eostools.py:511
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

Member Data Documentation

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

Definition at line 55 of file SiStripOnTrackClusterTableProducerBase.h.

Referenced by produce().

const std::string SiStripOnTrackClusterTableProducerBase::m_doc
private

Definition at line 51 of file SiStripOnTrackClusterTableProducerBase.h.

bool SiStripOnTrackClusterTableProducerBase::m_extension
private

Definition at line 52 of file SiStripOnTrackClusterTableProducerBase.h.

Referenced by produce().

const std::string SiStripOnTrackClusterTableProducerBase::m_name
private

Definition at line 50 of file SiStripOnTrackClusterTableProducerBase.h.

Referenced by produce().

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

Definition at line 54 of file SiStripOnTrackClusterTableProducerBase.h.

Referenced by produce().