CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PreMixingTrackingParticleWorker Class Reference
Inheritance diagram for PreMixingTrackingParticleWorker:
PreMixingWorker

Public Member Functions

void addPileups (PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override
 
void addSignals (edm::Event const &iEvent, edm::EventSetup const &iSetup) override
 
void initializeEvent (edm::Event const &iEvent, edm::EventSetup const &iSetup) override
 
 PreMixingTrackingParticleWorker (const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &&iC)
 
void put (edm::Event &iEvent, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bunchSpacing) override
 
 ~PreMixingTrackingParticleWorker () override=default
 
- Public Member Functions inherited from PreMixingWorker
virtual void beginLuminosityBlock (edm::LuminosityBlock const &iLumi, edm::EventSetup const &iSetup)
 
virtual void beginRun (edm::Run const &iRun, edm::EventSetup const &iSetup)
 
virtual void endRun ()
 
virtual void finalizeBunchCrossing (edm::Event &iEvent, edm::EventSetup const &iSetup, int bunchCrossing)
 
virtual void initializeBunchCrossing (edm::Event const &iEvent, edm::EventSetup const &iSetup, int bunchCrossing)
 
 PreMixingWorker ()=default
 
virtual ~PreMixingWorker ()=default
 

Private Member Functions

void add (const std::vector< TrackingParticle > &particles, const std::vector< TrackingVertex > &vertices)
 

Private Attributes

std::unique_ptr< std::vector< TrackingParticle > > NewTrackList_
 
std::unique_ptr< std::vector< TrackingVertex > > NewVertexList_
 
std::string TrackingParticleCollectionDM_
 
edm::InputTag TrackingParticlePileInputTag_
 
TrackingParticleRefProd TrackListRef_
 
edm::EDGetTokenT< std::vector< TrackingParticle > > TrackSigToken_
 
TrackingVertexRefProd VertexListRef_
 
edm::EDGetTokenT< std::vector< TrackingVertex > > VtxSigToken_
 

Detailed Description

Definition at line 15 of file PreMixingTrackingParticleWorker.cc.

Constructor & Destructor Documentation

◆ PreMixingTrackingParticleWorker()

PreMixingTrackingParticleWorker::PreMixingTrackingParticleWorker ( const edm::ParameterSet ps,
edm::ProducesCollector  producesCollector,
edm::ConsumesCollector &&  iC 
)

Definition at line 45 of file PreMixingTrackingParticleWorker.cc.

48  : TrackSigToken_(iC.consumes<std::vector<TrackingParticle>>(ps.getParameter<edm::InputTag>("labelSig"))),
49  VtxSigToken_(iC.consumes<std::vector<TrackingVertex>>(ps.getParameter<edm::InputTag>("labelSig"))),
52  producesCollector.produces<std::vector<TrackingParticle>>(TrackingParticleCollectionDM_);
53  producesCollector.produces<std::vector<TrackingVertex>>(TrackingParticleCollectionDM_);
54 }

References edm::ProducesCollector::produces(), and TrackingParticleCollectionDM_.

◆ ~PreMixingTrackingParticleWorker()

PreMixingTrackingParticleWorker::~PreMixingTrackingParticleWorker ( )
overridedefault

Member Function Documentation

◆ add()

void PreMixingTrackingParticleWorker::add ( const std::vector< TrackingParticle > &  particles,
const std::vector< TrackingVertex > &  vertices 
)
private

Definition at line 96 of file PreMixingTrackingParticleWorker.cc.

97  {
98  const size_t StartingIndexV = NewVertexList_->size();
99  const size_t StartingIndexT = NewTrackList_->size();
100 
101  // grab Vertices, store copy, preserving indices. Easier to loop over
102  // vertices first - fewer links
103  for (const auto &vtx : vertices) {
104  NewVertexList_->push_back(vtx);
105  }
106 
107  // grab tracks, store copy
108  for (const auto &track : particles) {
109  const auto &oldRef = track.parentVertex();
110  auto newRef = TrackingVertexRef(VertexListRef_, oldRef.index() + StartingIndexV);
111  NewTrackList_->push_back(track);
112 
113  auto &Ntrack = NewTrackList_->back(); // modify copy
114 
115  Ntrack.setParentVertex(newRef);
116  Ntrack.clearDecayVertices();
117 
118  // next, loop over daughter vertices, same strategy
119  for (auto const &vertexRef : track.decayVertices()) {
120  auto newRef = TrackingVertexRef(VertexListRef_, vertexRef.index() + StartingIndexV);
121  Ntrack.addDecayVertex(newRef);
122  }
123  }
124 
125  // Now that tracks are handled, go back and put correct Refs in vertices
126  // Operate only on the added pileup vertices, and leave the already-existing
127  // vertices untouched
128  std::vector<decltype(TrackingParticleRef().index())> sourceTrackIndices;
129  std::vector<decltype(TrackingParticleRef().index())> daughterTrackIndices;
130  for (size_t iVertex = StartingIndexV; iVertex != NewVertexList_->size(); ++iVertex) {
131  auto &vertex = (*NewVertexList_)[iVertex];
132 
133  // Need to copy the indices before clearing the vectors
134  sourceTrackIndices.reserve(vertex.sourceTracks().size());
135  daughterTrackIndices.reserve(vertex.daughterTracks().size());
136  for (auto const &ref : vertex.sourceTracks())
137  sourceTrackIndices.push_back(ref.index());
138  for (auto const &ref : vertex.daughterTracks())
139  daughterTrackIndices.push_back(ref.index());
140 
141  vertex.clearParentTracks();
142  vertex.clearDaughterTracks();
143 
144  for (auto index : sourceTrackIndices) {
145  auto newRef = TrackingParticleRef(TrackListRef_, index + StartingIndexT);
146  vertex.addParentTrack(newRef);
147  }
148 
149  // next, loop over daughter tracks, same strategy
150  for (auto index : daughterTrackIndices) {
151  auto newRef = TrackingParticleRef(TrackListRef_, index + StartingIndexT);
152  vertex.addDaughterTrack(newRef);
153  }
154 
155  sourceTrackIndices.clear();
156  daughterTrackIndices.clear();
157  }
158 }

References NewTrackList_, NewVertexList_, ecalTrigSettings_cff::particles, HLT_FULL_cff::track, TrackListRef_, trackerHitRTTI::vector, bphysicsOniaDQM_cfi::vertex, VertexListRef_, pwdgSkimBPark_cfi::vertices, and extraflags_cff::vtx.

Referenced by addPileups(), addSignals(), and counter.Counter::register().

◆ addPileups()

void PreMixingTrackingParticleWorker::addPileups ( PileUpEventPrincipal const &  pep,
edm::EventSetup const &  iSetup 
)
overridevirtual

Implements PreMixingWorker.

Definition at line 81 of file PreMixingTrackingParticleWorker.cc.

81  {
82  LogDebug("PreMixingTrackingParticleWorker") << "\n===============> adding pileups from event "
83  << pep.principal().id() << " for bunchcrossing " << pep.bunchCrossing();
84 
86  pep.getByLabel(TrackingParticlePileInputTag_, inputHandle);
87 
89  pep.getByLabel(TrackingParticlePileInputTag_, inputVHandle);
90 
91  if (inputHandle.isValid() && inputVHandle.isValid()) {
92  add(*inputHandle, *inputVHandle);
93  }
94 }

References add(), PileUpEventPrincipal::bunchCrossing(), PileUpEventPrincipal::getByLabel(), edm::EventPrincipal::id(), edm::HandleBase::isValid(), LogDebug, PileUpEventPrincipal::principal(), and TrackingParticlePileInputTag_.

◆ addSignals()

void PreMixingTrackingParticleWorker::addSignals ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)
overridevirtual

Implements PreMixingWorker.

Definition at line 69 of file PreMixingTrackingParticleWorker.cc.

69  {
71  iEvent.getByToken(TrackSigToken_, tracks);
72 
74  iEvent.getByToken(VtxSigToken_, vtxs);
75 
76  if (tracks.isValid() && vtxs.isValid()) {
77  add(*tracks, *vtxs);
78  }
79 }

References add(), iEvent, edm::HandleBase::isValid(), tracks, TrackSigToken_, and VtxSigToken_.

◆ initializeEvent()

void PreMixingTrackingParticleWorker::initializeEvent ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)
overridevirtual

Implements PreMixingWorker.

Definition at line 56 of file PreMixingTrackingParticleWorker.cc.

56  {
57  NewTrackList_ = std::make_unique<std::vector<TrackingParticle>>();
58  NewVertexList_ = std::make_unique<std::vector<TrackingVertex>>();
59 
60  // need RefProds in order to re-key the particle<->vertex refs
61  // TODO: try to remove const_cast, requires making Event non-const in
62  // BMixingModule::initializeEvent
64  const_cast<edm::Event &>(iEvent).getRefBeforePut<std::vector<TrackingParticle>>(TrackingParticleCollectionDM_);
66  const_cast<edm::Event &>(iEvent).getRefBeforePut<std::vector<TrackingVertex>>(TrackingParticleCollectionDM_);
67 }

References iEvent, NewTrackList_, NewVertexList_, TrackingParticleCollectionDM_, TrackListRef_, and VertexListRef_.

◆ put()

void PreMixingTrackingParticleWorker::put ( edm::Event iEvent,
edm::EventSetup const &  iSetup,
std::vector< PileupSummaryInfo > const &  ps,
int  bunchSpacing 
)
overridevirtual

Implements PreMixingWorker.

Definition at line 160 of file PreMixingTrackingParticleWorker.cc.

163  {
164  edm::LogInfo("PreMixingTrackingParticleWorker") << "total # Merged Tracks: " << NewTrackList_->size();
167 }

References iEvent, eostools::move(), NewTrackList_, NewVertexList_, and TrackingParticleCollectionDM_.

Member Data Documentation

◆ NewTrackList_

std::unique_ptr<std::vector<TrackingParticle> > PreMixingTrackingParticleWorker::NewTrackList_
private

Definition at line 39 of file PreMixingTrackingParticleWorker.cc.

Referenced by add(), initializeEvent(), and put().

◆ NewVertexList_

std::unique_ptr<std::vector<TrackingVertex> > PreMixingTrackingParticleWorker::NewVertexList_
private

Definition at line 40 of file PreMixingTrackingParticleWorker.cc.

Referenced by add(), initializeEvent(), and put().

◆ TrackingParticleCollectionDM_

std::string PreMixingTrackingParticleWorker::TrackingParticleCollectionDM_
private

◆ TrackingParticlePileInputTag_

edm::InputTag PreMixingTrackingParticleWorker::TrackingParticlePileInputTag_
private

Definition at line 34 of file PreMixingTrackingParticleWorker.cc.

Referenced by addPileups().

◆ TrackListRef_

TrackingParticleRefProd PreMixingTrackingParticleWorker::TrackListRef_
private

Definition at line 41 of file PreMixingTrackingParticleWorker.cc.

Referenced by add(), and initializeEvent().

◆ TrackSigToken_

edm::EDGetTokenT<std::vector<TrackingParticle> > PreMixingTrackingParticleWorker::TrackSigToken_
private

Definition at line 31 of file PreMixingTrackingParticleWorker.cc.

Referenced by addSignals().

◆ VertexListRef_

TrackingVertexRefProd PreMixingTrackingParticleWorker::VertexListRef_
private

Definition at line 42 of file PreMixingTrackingParticleWorker.cc.

Referenced by add(), and initializeEvent().

◆ VtxSigToken_

edm::EDGetTokenT<std::vector<TrackingVertex> > PreMixingTrackingParticleWorker::VtxSigToken_
private

Definition at line 32 of file PreMixingTrackingParticleWorker.cc.

Referenced by addSignals().

PreMixingTrackingParticleWorker::TrackSigToken_
edm::EDGetTokenT< std::vector< TrackingParticle > > TrackSigToken_
Definition: PreMixingTrackingParticleWorker.cc:31
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
PreMixingTrackingParticleWorker::NewTrackList_
std::unique_ptr< std::vector< TrackingParticle > > NewTrackList_
Definition: PreMixingTrackingParticleWorker.cc:39
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
PreMixingTrackingParticleWorker::TrackListRef_
TrackingParticleRefProd TrackListRef_
Definition: PreMixingTrackingParticleWorker.cc:41
ecalTrigSettings_cff.particles
particles
Definition: ecalTrigSettings_cff.py:11
PreMixingTrackingParticleWorker::VtxSigToken_
edm::EDGetTokenT< std::vector< TrackingVertex > > VtxSigToken_
Definition: PreMixingTrackingParticleWorker.cc:32
TrackingVertexRef
edm::Ref< TrackingVertexCollection > TrackingVertexRef
Definition: TrackingVertexContainer.h:9
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
PreMixingTrackingParticleWorker::TrackingParticleCollectionDM_
std::string TrackingParticleCollectionDM_
Definition: PreMixingTrackingParticleWorker.cc:36
iEvent
int iEvent
Definition: GenABIO.cc:224
PreMixingTrackingParticleWorker::NewVertexList_
std::unique_ptr< std::vector< TrackingVertex > > NewVertexList_
Definition: PreMixingTrackingParticleWorker.cc:40
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::ProducesCollector::produces
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
Definition: ProducesCollector.h:52
PreMixingTrackingParticleWorker::TrackingParticlePileInputTag_
edm::InputTag TrackingParticlePileInputTag_
Definition: PreMixingTrackingParticleWorker.cc:34
PreMixingTrackingParticleWorker::add
void add(const std::vector< TrackingParticle > &particles, const std::vector< TrackingVertex > &vertices)
Definition: PreMixingTrackingParticleWorker.cc:96
eostools.move
def move(src, dest)
Definition: eostools.py:511
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
PreMixingTrackingParticleWorker::VertexListRef_
TrackingVertexRefProd VertexListRef_
Definition: PreMixingTrackingParticleWorker.cc:42
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
TrackingParticleRef
edm::Ref< TrackingParticleCollection > TrackingParticleRef
Definition: TrackingParticleFwd.h:12
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7