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 TrackingGeometrygeometry ()
 
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

void clear ()
 
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 32 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(), cscDigiValidation_cfi::simTrack, and HLTEgPhaseIITestSequence_cff::simVertex.

◆ ~MuonSimHitMatcher()

MuonSimHitMatcher::~MuonSimHitMatcher ( )
inline

Definition at line 38 of file MuonSimHitMatcher.h.

38 {}

Member Function Documentation

◆ chamberIds()

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

◆ clear()

void MuonSimHitMatcher::clear ( void  )
protected

Definition at line 139 of file MuonSimHitMatcher.cc.

139  {
140  track_ids_.clear();
141  trkid_to_index_.clear();
142  hits_.clear();
143  detid_to_hits_.clear();
144  chamber_to_hits_.clear();
145 }

Referenced by CSCSimHitMatcher::clear(), and GEMSimHitMatcher::clear().

◆ detIds()

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

◆ geometry()

const TrackingGeometry* MuonSimHitMatcher::geometry ( )
inline

Definition at line 69 of file MuonSimHitMatcher.h.

69 { return geometry_; }

References geometry_.

Referenced by CSCSimHitMatcher::simHitsMeanWG().

◆ 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 SimTrack::noVertex(), mps_fire::result, submitPVValidationJobs::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 submitPVValidationJobs::t, and HLT_FULL_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

Definition at line 82 of file MuonSimHitMatcher.h.

◆ 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 92 of file MuonSimHitMatcher.h.

◆ simMuOnly_

bool MuonSimHitMatcher::simMuOnly_
protected

◆ simTrackInput_

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

Definition at line 87 of file MuonSimHitMatcher.h.

◆ simTracks_

edm::SimTrackContainer MuonSimHitMatcher::simTracks_
protected

Definition at line 94 of file MuonSimHitMatcher.h.

◆ simTracksH_

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

Definition at line 90 of file MuonSimHitMatcher.h.

◆ simVertexInput_

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

Definition at line 86 of file MuonSimHitMatcher.h.

◆ simVertices_

edm::SimVertexContainer MuonSimHitMatcher::simVertices_
protected

Definition at line 95 of file MuonSimHitMatcher.h.

◆ simVerticesH_

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

Definition at line 91 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 100 of file MuonSimHitMatcher.h.

◆ verbose_

bool MuonSimHitMatcher::verbose_
protected

◆ verboseSimTrack_

bool MuonSimHitMatcher::verboseSimTrack_
protected

Definition at line 78 of file MuonSimHitMatcher.h.

Vector3DBase< float, LocalTag >
cscDigiValidation_cfi.simTrack
simTrack
Definition: cscDigiValidation_cfi.py:29
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
MuonSimHitMatcher::simVerticesH_
edm::Handle< edm::SimVertexContainer > simVerticesH_
Definition: MuonSimHitMatcher.h:91
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:84
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
MuonSimHitMatcher::detid_to_hits_
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_
Definition: MuonSimHitMatcher.h:106
MuonSimHitMatcher::simTracks_
edm::SimTrackContainer simTracks_
Definition: MuonSimHitMatcher.h:94
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
MuonSimHitMatcher::simHits_
edm::PSimHitContainer simHits_
Definition: MuonSimHitMatcher.h:97
MuonSimHitMatcher::simVertices_
edm::SimVertexContainer simVertices_
Definition: MuonSimHitMatcher.h:95
MuonSimHitMatcher::simVertexInput_
edm::EDGetTokenT< edm::SimVertexContainer > simVertexInput_
Definition: MuonSimHitMatcher.h:86
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
HLTEgPhaseIITestSequence_cff.simVertex
simVertex
Definition: HLTEgPhaseIITestSequence_cff.py:51
SimTrack::noVertex
bool noVertex() const
Definition: SimTrack.h:34
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:100
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, LocalTag >
MuonSimHitMatcher::track_ids_
std::vector< unsigned > track_ids_
Definition: MuonSimHitMatcher.h:99
MuonSimHitMatcher::no_hits_
edm::PSimHitContainer no_hits_
Definition: MuonSimHitMatcher.h:102
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
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
MuonSimHitMatcher::hasGeometry_
bool hasGeometry_
Definition: MuonSimHitMatcher.h:82
iEvent
int iEvent
Definition: GenABIO.cc:224
MuonSimHitMatcher::chamber_to_hits_
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
Definition: MuonSimHitMatcher.h:107
MuonSimHitMatcher::verboseSimTrack_
bool verboseSimTrack_
Definition: MuonSimHitMatcher.h:78
MuonSimHitMatcher::simHitInput_
edm::EDGetTokenT< edm::PSimHitContainer > simHitInput_
Definition: MuonSimHitMatcher.h:88
MuonSimHitMatcher::simTracksH_
edm::Handle< edm::SimTrackContainer > simTracksH_
Definition: MuonSimHitMatcher.h:90
hgcal::association
std::tuple< layerClusterToCaloParticle, caloParticleToLayerCluster > association
Definition: LayerClusterAssociatorByEnergyScoreImpl.h:44
edm::SimTrackContainer
std::vector< SimTrack > SimTrackContainer
Definition: SimTrackContainer.h:12
SimTrack
Definition: SimTrack.h:9
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:33
MuonSimHitMatcher::simMuOnly_
bool simMuOnly_
Definition: MuonSimHitMatcher.h:79
MuonSimHitMatcher::simHitsH_
edm::Handle< edm::PSimHitContainer > simHitsH_
Definition: MuonSimHitMatcher.h:92
MuonSimHitMatcher::simTrackInput_
edm::EDGetTokenT< edm::SimTrackContainer > simTrackInput_
Definition: MuonSimHitMatcher.h:87
mps_fire.result
result
Definition: mps_fire.py:311
MuonSimHitMatcher::hits_
edm::PSimHitContainer hits_
Definition: MuonSimHitMatcher.h:105
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::SimVertexContainer
std::vector< SimVertex > SimVertexContainer
Definition: SimVertexContainer.h:12
edm::InputTag
Definition: InputTag.h:15