CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
MuonSimHitMatcher Class Reference

#include <MuonSimHitMatcher.h>

Inheritance diagram for MuonSimHitMatcher:
CSCSimHitMatcher DTSimHitMatcher GEMSimHitMatcher ME0SimHitMatcher RPCSimHitMatcher

Public Member Functions

std::set< unsigned int > chamberIds (int type=0) const
 
std::set< unsigned int > detIds (int type=0) const
 
const edm::PSimHitContainerhitsInChamber (unsigned int) const
 
const edm::PSimHitContainerhitsInDetId (unsigned int) const
 
void init (const edm::Event &e, const edm::EventSetup &eventSetup)
 initialize the event More...
 
void match (const SimTrack &t, const SimVertex &v)
 do the matching More...
 
 MuonSimHitMatcher (const edm::ParameterSet &iPS, edm::ConsumesCollector &&iC)
 
const edm::PSimHitContainersimHits (int) const
 
GlobalVector simHitsMeanMomentum (const edm::PSimHitContainer &sim_hits) const
 
GlobalPoint simHitsMeanPosition (const edm::PSimHitContainer &sim_hits) const
 
GlobalPoint simHitsMeanPositionStation (int n) const
 
 ~MuonSimHitMatcher ()
 

Protected Member Functions

std::vector< unsigned int > getIdsOfSimTrackShower (unsigned trk_id, const edm::SimTrackContainer &simTracks, const edm::SimVertexContainer &simVertices)
 

Protected Attributes

std::map< unsigned int, edm::PSimHitContainerchamber_to_hits_
 
std::map< unsigned int, edm::PSimHitContainerdetid_to_hits_
 
bool discardEleHits_
 
const TrackingGeometrygeometry_
 
bool hasGeometry_
 
edm::PSimHitContainer hits_
 
edm::PSimHitContainer no_hits_
 
edm::EDGetTokenT< edm::PSimHitContainersimHitInput_
 
edm::ParameterSet simHitPSet_
 
edm::PSimHitContainer simHits_
 
edm::Handle< edm::PSimHitContainersimHitsH_
 
bool simMuOnly_
 
edm::EDGetTokenT< edm::SimTrackContainersimTrackInput_
 
edm::SimTrackContainer simTracks_
 
edm::Handle< edm::SimTrackContainersimTracksH_
 
edm::EDGetTokenT< edm::SimVertexContainersimVertexInput_
 
edm::SimVertexContainer simVertices_
 
edm::Handle< edm::SimVertexContainersimVerticesH_
 
std::vector< unsigned > track_ids_
 
std::map< unsigned int, unsigned int > trkid_to_index_
 
bool verbose_
 
bool verboseSimTrack_
 

Detailed Description

Description: Matching of muon SimHit to SimTrack

Author: Sven Dildick (TAMU), Tao Huang (TAMU)

Definition at line 33 of file MuonSimHitMatcher.h.

Constructor & Destructor Documentation

◆ MuonSimHitMatcher()

MuonSimHitMatcher::MuonSimHitMatcher ( const edm::ParameterSet iPS,
edm::ConsumesCollector &&  iC 
)

Definition at line 7 of file MuonSimHitMatcher.cc.

7  {
8  const auto& simVertex = ps.getParameterSet("simVertex");
9  const auto& simTrack = ps.getParameterSet("simTrack");
10  verboseSimTrack_ = simTrack.getParameter<int>("verbose");
11 
13  simTrackInput_ = iC.consumes<edm::SimTrackContainer>(simTrack.getParameter<edm::InputTag>("inputTag"));
14 }

References edm::ParameterSet::getParameterSet(), muonSimHitMatcherPSet::simTrack, and ecalDetailedTimeRecHit_cfi::simVertex.

◆ ~MuonSimHitMatcher()

MuonSimHitMatcher::~MuonSimHitMatcher ( )
inline

Definition at line 39 of file MuonSimHitMatcher.h.

39 {}

Member Function Documentation

◆ chamberIds()

std::set<unsigned int> MuonSimHitMatcher::chamberIds ( int  type = 0) const

◆ detIds()

std::set<unsigned int> MuonSimHitMatcher::detIds ( int  type = 0) const

◆ getIdsOfSimTrackShower()

std::vector< unsigned int > MuonSimHitMatcher::getIdsOfSimTrackShower ( unsigned  trk_id,
const edm::SimTrackContainer simTracks,
const edm::SimVertexContainer simVertices 
)
protected

Definition at line 47 of file MuonSimHitMatcher.cc.

49  {
50  vector<unsigned int> result;
51  result.push_back(initial_trk_id);
52 
53  if (!simMuOnly_)
54  return result;
55 
56  for (const auto& t : simTracks_) {
57  SimTrack last_trk = t;
58  // if (std::abs(t.type()) != 13) continue;
59  bool is_child = false;
60  while (true) {
61  if (last_trk.noVertex())
62  break;
63  if (simVertices_[last_trk.vertIndex()].noParent())
64  break;
65 
66  unsigned parentId = simVertices_[last_trk.vertIndex()].parentIndex();
67  if (parentId == initial_trk_id) {
68  is_child = true;
69  break;
70  }
71 
72  const auto& association = trkid_to_index_.find(parentId);
73  if (association == trkid_to_index_.end())
74  break;
75 
76  last_trk = simTracks_[association->second];
77  }
78  if (is_child) {
79  result.push_back(t.trackId());
80  }
81  }
82  return result;
83 }

References TrackValidation_cff::association, SimTrack::noVertex(), mps_fire::result, OrderedSet::t, and SimTrack::vertIndex().

◆ hitsInChamber()

const edm::PSimHitContainer & MuonSimHitMatcher::hitsInChamber ( unsigned int  detid) const

◆ hitsInDetId()

const edm::PSimHitContainer & MuonSimHitMatcher::hitsInDetId ( unsigned int  detid) const

◆ init()

void MuonSimHitMatcher::init ( const edm::Event e,
const edm::EventSetup eventSetup 
)

initialize the event

Definition at line 17 of file MuonSimHitMatcher.cc.

17  {
18  hasGeometry_ = true;
19 
20  iEvent.getByToken(simTrackInput_, simTracksH_);
22  iEvent.getByToken(simHitInput_, simHitsH_);
23 }

References iEvent.

Referenced by CSCSimHitMatcher::init(), RPCSimHitMatcher::init(), ME0SimHitMatcher::init(), GEMSimHitMatcher::init(), and DTSimHitMatcher::init().

◆ match()

void MuonSimHitMatcher::match ( const SimTrack t,
const SimVertex v 
)

do the matching

Definition at line 26 of file MuonSimHitMatcher.cc.

26  {
30 
31  // fill trkId2Index association:
32  int no = 0;
33  trkid_to_index_.clear();
34  for (const auto& t : simTracks_) {
35  trkid_to_index_[t.trackId()] = no;
36  no++;
37  }
38 
40  if (verboseSimTrack_) {
41  edm::LogInfo("MuonSimHitMatcher") << "Printing track_ids" << std::endl;
42  for (const auto& id : track_ids_)
43  edm::LogInfo("MuonSimHitMatcher") << "id: " << id << std::endl;
44  }
45 }

References OrderedSet::t, and HLT_2018_cff::track.

Referenced by CSCSimHitMatcher::match(), RPCSimHitMatcher::match(), ME0SimHitMatcher::match(), GEMSimHitMatcher::match(), and DTSimHitMatcher::match().

◆ simHits()

const edm::PSimHitContainer & MuonSimHitMatcher::simHits ( int  sub) const

Definition at line 85 of file MuonSimHitMatcher.cc.

85 { return hits_; }

Referenced by ntupleDataFormat.TrackingParticle::bestMatchingTrack().

◆ simHitsMeanMomentum()

GlobalVector MuonSimHitMatcher::simHitsMeanMomentum ( const edm::PSimHitContainer sim_hits) const

Definition at line 119 of file MuonSimHitMatcher.cc.

119  {
120  if (sim_hits.empty())
121  return GlobalVector(); // point "zero"
122 
123  float sumx, sumy, sumz;
124  sumx = sumy = sumz = 0.f;
125  size_t n = 0;
126  for (const auto& h : sim_hits) {
127  const LocalVector& lv = h.momentumAtEntry();
128  const GlobalVector& gv = geometry_->idToDet(h.detUnitId())->surface().toGlobal(lv);
129  sumx += gv.x();
130  sumy += gv.y();
131  sumz += gv.z();
132  ++n;
133  }
134  if (n == 0)
135  return GlobalVector();
136  return GlobalVector(sumx / n, sumy / n, sumz / n);
137 }

References dqmiodumpmetadata::n, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

◆ simHitsMeanPosition()

GlobalPoint MuonSimHitMatcher::simHitsMeanPosition ( const edm::PSimHitContainer sim_hits) const

Definition at line 99 of file MuonSimHitMatcher.cc.

99  {
100  if (sim_hits.empty())
101  return GlobalPoint(); // point "zero"
102 
103  float sumx, sumy, sumz;
104  sumx = sumy = sumz = 0.f;
105  size_t n = 0;
106  for (const auto& h : sim_hits) {
107  const LocalPoint& lp = h.entryPoint();
108  const GlobalPoint& gp = geometry_->idToDet(h.detUnitId())->surface().toGlobal(lp);
109  sumx += gp.x();
110  sumy += gp.y();
111  sumz += gp.z();
112  ++n;
113  }
114  if (n == 0)
115  return GlobalPoint();
116  return GlobalPoint(sumx / n, sumy / n, sumz / n);
117 }

References runTauDisplay::gp, and dqmiodumpmetadata::n.

Referenced by CSCSimHitMatcher::LocalBendingInChamber(), RPCSimHitMatcher::match(), ME0SimHitMatcher::match(), GEMSimHitMatcher::match(), DTSimHitMatcher::match(), and CSCSimHitMatcher::match().

◆ simHitsMeanPositionStation()

GlobalPoint MuonSimHitMatcher::simHitsMeanPositionStation ( int  n) const

Member Data Documentation

◆ chamber_to_hits_

std::map<unsigned int, edm::PSimHitContainer> MuonSimHitMatcher::chamber_to_hits_
protected

◆ detid_to_hits_

std::map<unsigned int, edm::PSimHitContainer> MuonSimHitMatcher::detid_to_hits_
protected

◆ discardEleHits_

bool MuonSimHitMatcher::discardEleHits_
protected

◆ geometry_

const TrackingGeometry* MuonSimHitMatcher::geometry_
protected

◆ hasGeometry_

bool MuonSimHitMatcher::hasGeometry_
protected

◆ hits_

edm::PSimHitContainer MuonSimHitMatcher::hits_
protected

◆ no_hits_

edm::PSimHitContainer MuonSimHitMatcher::no_hits_
protected

◆ simHitInput_

edm::EDGetTokenT<edm::PSimHitContainer> MuonSimHitMatcher::simHitInput_
protected

◆ simHitPSet_

edm::ParameterSet MuonSimHitMatcher::simHitPSet_
protected

◆ simHits_

edm::PSimHitContainer MuonSimHitMatcher::simHits_
protected

◆ simHitsH_

edm::Handle<edm::PSimHitContainer> MuonSimHitMatcher::simHitsH_
protected

Definition at line 89 of file MuonSimHitMatcher.h.

◆ simMuOnly_

bool MuonSimHitMatcher::simMuOnly_
protected

◆ simTrackInput_

edm::EDGetTokenT<edm::SimTrackContainer> MuonSimHitMatcher::simTrackInput_
protected

Definition at line 84 of file MuonSimHitMatcher.h.

◆ simTracks_

edm::SimTrackContainer MuonSimHitMatcher::simTracks_
protected

Definition at line 91 of file MuonSimHitMatcher.h.

◆ simTracksH_

edm::Handle<edm::SimTrackContainer> MuonSimHitMatcher::simTracksH_
protected

Definition at line 87 of file MuonSimHitMatcher.h.

◆ simVertexInput_

edm::EDGetTokenT<edm::SimVertexContainer> MuonSimHitMatcher::simVertexInput_
protected

Definition at line 83 of file MuonSimHitMatcher.h.

◆ simVertices_

edm::SimVertexContainer MuonSimHitMatcher::simVertices_
protected

Definition at line 92 of file MuonSimHitMatcher.h.

◆ simVerticesH_

edm::Handle<edm::SimVertexContainer> MuonSimHitMatcher::simVerticesH_
protected

Definition at line 88 of file MuonSimHitMatcher.h.

◆ track_ids_

std::vector<unsigned> MuonSimHitMatcher::track_ids_
protected

◆ trkid_to_index_

std::map<unsigned int, unsigned int> MuonSimHitMatcher::trkid_to_index_
protected

Definition at line 97 of file MuonSimHitMatcher.h.

◆ verbose_

bool MuonSimHitMatcher::verbose_
protected

◆ verboseSimTrack_

bool MuonSimHitMatcher::verboseSimTrack_
protected

Definition at line 75 of file MuonSimHitMatcher.h.

Vector3DBase< float, LocalTag >
MuonSimHitMatcher::simVerticesH_
edm::Handle< edm::SimVertexContainer > simVerticesH_
Definition: MuonSimHitMatcher.h:88
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::Handle::product
T const * product() const
Definition: Handle.h:70
MuonSimHitMatcher::geometry_
const TrackingGeometry * geometry_
Definition: MuonSimHitMatcher.h:81
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
edm::LogInfo
Definition: MessageLogger.h:254
MuonSimHitMatcher::detid_to_hits_
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_
Definition: MuonSimHitMatcher.h:103
MuonSimHitMatcher::simTracks_
edm::SimTrackContainer simTracks_
Definition: MuonSimHitMatcher.h:91
ecalDetailedTimeRecHit_cfi.simVertex
simVertex
Definition: ecalDetailedTimeRecHit_cfi.py:13
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
MuonSimHitMatcher::simHits_
edm::PSimHitContainer simHits_
Definition: MuonSimHitMatcher.h:94
MuonSimHitMatcher::simVertices_
edm::SimVertexContainer simVertices_
Definition: MuonSimHitMatcher.h:92
MuonSimHitMatcher::simVertexInput_
edm::EDGetTokenT< edm::SimVertexContainer > simVertexInput_
Definition: MuonSimHitMatcher.h:83
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
SimTrack::noVertex
bool noVertex() const
Definition: SimTrack.h:31
TrackingGeometry::idToDet
virtual const GeomDet * idToDet(DetId) const =0
h
MuonSimHitMatcher::trkid_to_index_
std::map< unsigned int, unsigned int > trkid_to_index_
Definition: MuonSimHitMatcher.h:97
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, LocalTag >
OrderedSet.t
t
Definition: OrderedSet.py:90
MuonSimHitMatcher::track_ids_
std::vector< unsigned > track_ids_
Definition: MuonSimHitMatcher.h:96
MuonSimHitMatcher::no_hits_
edm::PSimHitContainer no_hits_
Definition: MuonSimHitMatcher.h:99
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
muonSimHitMatcherPSet.simTrack
simTrack
Definition: muonSimHitMatcherPSet.py:4
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
MuonSimHitMatcher::hasGeometry_
bool hasGeometry_
Definition: MuonSimHitMatcher.h:79
iEvent
int iEvent
Definition: GenABIO.cc:224
MuonSimHitMatcher::chamber_to_hits_
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
Definition: MuonSimHitMatcher.h:104
MuonSimHitMatcher::verboseSimTrack_
bool verboseSimTrack_
Definition: MuonSimHitMatcher.h:75
TrackValidation_cff.association
association
Definition: TrackValidation_cff.py:286
MuonSimHitMatcher::simHitInput_
edm::EDGetTokenT< edm::PSimHitContainer > simHitInput_
Definition: MuonSimHitMatcher.h:85
MuonSimHitMatcher::simTracksH_
edm::Handle< edm::SimTrackContainer > simTracksH_
Definition: MuonSimHitMatcher.h:87
edm::SimTrackContainer
std::vector< SimTrack > SimTrackContainer
Definition: SimTrackContainer.h:12
SimTrack
Definition: SimTrack.h:6
MuonSimHitMatcher::getIdsOfSimTrackShower
std::vector< unsigned int > getIdsOfSimTrackShower(unsigned trk_id, const edm::SimTrackContainer &simTracks, const edm::SimVertexContainer &simVertices)
Definition: MuonSimHitMatcher.cc:47
SimTrack::vertIndex
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
Definition: SimTrack.h:30
MuonSimHitMatcher::simMuOnly_
bool simMuOnly_
Definition: MuonSimHitMatcher.h:76
MuonSimHitMatcher::simHitsH_
edm::Handle< edm::PSimHitContainer > simHitsH_
Definition: MuonSimHitMatcher.h:89
MuonSimHitMatcher::simTrackInput_
edm::EDGetTokenT< edm::SimTrackContainer > simTrackInput_
Definition: MuonSimHitMatcher.h:84
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
mps_fire.result
result
Definition: mps_fire.py:303
MuonSimHitMatcher::hits_
edm::PSimHitContainer hits_
Definition: MuonSimHitMatcher.h:102
edm::SimVertexContainer
std::vector< SimVertex > SimVertexContainer
Definition: SimVertexContainer.h:12
edm::InputTag
Definition: InputTag.h:15