CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
AlignmentTrackFromVertexCompositeCandidateSelector Class Reference

#include <AlignmentTracksFromVertexCompositeCandidateSelector.h>

Public Types

typedef std::vector< const reco::Track * > Tracks
 

Public Member Functions

 AlignmentTrackFromVertexCompositeCandidateSelector (const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
 constructor More...
 
Tracks select (const edm::Handle< reco::TrackCollection > &tc, const edm::Event &evt, const edm::EventSetup &setup) const
 select tracks More...
 
 ~AlignmentTrackFromVertexCompositeCandidateSelector ()
 destructor More...
 

Private Attributes

const edm::EDGetTokenT< reco::VertexCompositeCandidateCollectionvccToken_
 

Detailed Description

Definition at line 19 of file AlignmentTracksFromVertexCompositeCandidateSelector.h.

Member Typedef Documentation

◆ Tracks

Constructor & Destructor Documentation

◆ AlignmentTrackFromVertexCompositeCandidateSelector()

AlignmentTrackFromVertexCompositeCandidateSelector::AlignmentTrackFromVertexCompositeCandidateSelector ( const edm::ParameterSet cfg,
edm::ConsumesCollector iC 
)

constructor

Definition at line 10 of file AlignmentTracksFromVertexCompositeCandidateSelector.cc.

13  cfg.getParameter<edm::InputTag>("vertexCompositeCandidates"))) {}
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > vccToken_

◆ ~AlignmentTrackFromVertexCompositeCandidateSelector()

AlignmentTrackFromVertexCompositeCandidateSelector::~AlignmentTrackFromVertexCompositeCandidateSelector ( )

destructor

Definition at line 16 of file AlignmentTracksFromVertexCompositeCandidateSelector.cc.

16 {}

Member Function Documentation

◆ select()

AlignmentTrackFromVertexCompositeCandidateSelector::Tracks AlignmentTrackFromVertexCompositeCandidateSelector::select ( const edm::Handle< reco::TrackCollection > &  tc,
const edm::Event evt,
const edm::EventSetup setup 
) const

select tracks

Definition at line 19 of file AlignmentTracksFromVertexCompositeCandidateSelector.cc.

References reco::Candidate::daughter(), spr::find(), edm::Event::getByToken(), mps_fire::i, edm::Ref< C, T, F >::isNonnull(), edm::HandleBase::isValid(), edm::Ref< C, T, F >::key(), LogDebug, mps_fire::result, reco::RecoChargedCandidate::track(), and vccToken_.

Referenced by TrackFromVertexCompositeCandidateConfigSelector::select().

20  {
21  Tracks result;
22 
23  std::vector<unsigned int> theV0keys;
24 
26  evt.getByToken(vccToken_, vccHandle);
27 
28  if (vccHandle.isValid()) {
29  // Loop over VertexCompositeCandidates and associate tracks
30  for (const auto& vcc : *vccHandle) {
31  for (size_t i = 0; i < vcc.numberOfDaughters(); ++i) {
32  LogDebug("AlignmentTrackFromVertexCompositeCandidateSelector") << "daughter: " << i << std::endl;
33  const reco::Candidate* daughter = vcc.daughter(i);
34  const reco::RecoChargedCandidate* chargedDaughter = dynamic_cast<const reco::RecoChargedCandidate*>(daughter);
35  if (chargedDaughter) {
36  LogDebug("AlignmentTrackFromVertexCompositeCandidateSelector") << "charged daughter: " << i << std::endl;
37  const reco::TrackRef trackRef = chargedDaughter->track();
38  if (trackRef.isNonnull()) {
39  LogDebug("AlignmentTrackFromVertexCompositeCandidateSelector")
40  << "charged daughter has non-null trackref: " << i << std::endl;
41  theV0keys.push_back(trackRef.key());
42  }
43  }
44  }
45  }
46  } else {
47  edm::LogError("AlignmentTrackFromVertexCompositeCandidateSelector")
48  << "Error >> Failed to get VertexCompositeCandidateCollection";
49  }
50 
51  LogDebug("AlignmentTrackFromVertexCompositeCandidateSelector")
52  << "collection will have size: " << theV0keys.size() << std::endl;
53 
54  if (tc.isValid()) {
55  int indx(0);
56  // put the track in the collection is it was used for the vertex
57  for (reco::TrackCollection::const_iterator tk = tc->begin(); tk != tc->end(); ++tk, ++indx) {
58  reco::TrackRef trackRef = reco::TrackRef(tc, indx);
59  if (std::find(theV0keys.begin(), theV0keys.end(), trackRef.key()) != theV0keys.end()) {
60  LogDebug("AlignmentTrackFromVertexSelector") << "track index: " << indx << "filling result vector" << std::endl;
61  result.push_back(&(*tk));
62  } // if a valid key is found
63  } // end loop over tracks
64  } // if the handle is valid
65 
66  LogDebug("AlignmentTrackFromVertexCompositeCandidateSelector")
67  << "collection will have size: " << result.size() << std::endl;
68 
69  return result;
70 }
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:526
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
key_type key() const
Accessor for product key.
Definition: Ref.h:250
reco::TrackRef track() const override
reference to a track
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
bool isValid() const
Definition: HandleBase.h:70
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > vccToken_
#define LogDebug(id)

Member Data Documentation

◆ vccToken_

const edm::EDGetTokenT<reco::VertexCompositeCandidateCollection> AlignmentTrackFromVertexCompositeCandidateSelector::vccToken_
private

Definition at line 35 of file AlignmentTracksFromVertexCompositeCandidateSelector.h.

Referenced by select().