CMS 3D CMS Logo

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

#include <RPCSimHitMatcher.h>

Inheritance diagram for RPCSimHitMatcher:
MuonSimHitMatcher

Public Member Functions

std::set< unsigned int > chamberIds (int type=MuonHitHelper::RPC_ALL) const
 
std::set< unsigned int > detIds (int type=MuonHitHelper::RPC_ALL) const
 
bool hitStation (int st) const
 
std::set< int > hitStripsInDetId (unsigned int, int margin_n_strips=0) 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...
 
int nStations () const
 
 RPCSimHitMatcher (const edm::ParameterSet &iPS, edm::ConsumesCollector &&iC)
 
float simHitsMeanStrip (const edm::PSimHitContainer &sim_hits) const
 
 ~RPCSimHitMatcher ()
 
- Public Member Functions inherited from MuonSimHitMatcher
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 ()
 

Private Member Functions

void matchSimHitsToSimTrack ()
 

Private Attributes

edm::ESGetToken< RPCGeometry, MuonGeometryRecordgeomToken_
 

Additional Inherited Members

- Protected Member Functions inherited from MuonSimHitMatcher
void clear ()
 
std::vector< unsigned int > getIdsOfSimTrackShower (unsigned trk_id, const edm::SimTrackContainer &simTracks, const edm::SimVertexContainer &simVertices)
 
- Protected Attributes inherited from MuonSimHitMatcher
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 RPC SimHit to SimTrack

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

Definition at line 16 of file RPCSimHitMatcher.h.

Constructor & Destructor Documentation

◆ RPCSimHitMatcher()

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

Definition at line 6 of file RPCSimHitMatcher.cc.

References MuonSimHitMatcher::discardEleHits_, geomToken_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), MuonSimHitMatcher::simHitInput_, MuonSimHitMatcher::simHitPSet_, MuonSimHitMatcher::simMuOnly_, and MuonSimHitMatcher::verbose_.

7  : MuonSimHitMatcher(ps, std::move(iC)) {
8  simHitPSet_ = ps.getParameterSet("rpcSimHit");
9  verbose_ = simHitPSet_.getParameter<int>("verbose");
10  simMuOnly_ = simHitPSet_.getParameter<bool>("simMuOnly");
11  discardEleHits_ = simHitPSet_.getParameter<bool>("discardEleHits");
12 
15 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
ParameterSet const & getParameterSet(std::string const &) const
edm::ParameterSet simHitPSet_
edm::EDGetTokenT< edm::PSimHitContainer > simHitInput_
MuonSimHitMatcher(const edm::ParameterSet &iPS, edm::ConsumesCollector &&iC)
std::vector< PSimHit > PSimHitContainer
def move(src, dest)
Definition: eostools.py:511
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > geomToken_

◆ ~RPCSimHitMatcher()

RPCSimHitMatcher::~RPCSimHitMatcher ( )
inline

Definition at line 22 of file RPCSimHitMatcher.h.

22 {}

Member Function Documentation

◆ chamberIds()

std::set< unsigned int > RPCSimHitMatcher::chamberIds ( int  type = MuonHitHelper::RPC_ALL) const

Definition at line 85 of file RPCSimHitMatcher.cc.

References MuonSimHitMatcher::chamber_to_hits_, hcalRecHitTable_cff::detId, AlCaHLTBitMon_ParallelJobs::p, mps_fire::result, and MuonHitHelper::toRPCType().

Referenced by hitStation(), and match().

85  {
86  std::set<unsigned int> result;
87  for (const auto& p : chamber_to_hits_) {
88  const auto& id = p.first;
89  if (type > 0) {
90  RPCDetId detId(id);
91  if (MuonHitHelper::toRPCType(detId.region(), detId.station(), detId.ring()) != type)
92  continue;
93  }
94  result.insert(id);
95  }
96  return result;
97 }
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
static int toRPCType(int re, int st, int ri)

◆ detIds()

std::set< unsigned int > RPCSimHitMatcher::detIds ( int  type = MuonHitHelper::RPC_ALL) const

Definition at line 71 of file RPCSimHitMatcher.cc.

References hcalRecHitTable_cff::detId, MuonSimHitMatcher::detid_to_hits_, AlCaHLTBitMon_ParallelJobs::p, mps_fire::result, and MuonHitHelper::toRPCType().

Referenced by match().

71  {
72  std::set<unsigned int> result;
73  for (const auto& p : detid_to_hits_) {
74  const auto& id = p.first;
75  if (type > 0) {
76  RPCDetId detId(id);
77  if (MuonHitHelper::toRPCType(detId.region(), detId.station(), detId.ring()) != type)
78  continue;
79  }
80  result.insert(id);
81  }
82  return result;
83 }
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_
static int toRPCType(int re, int st, int ri)

◆ hitStation()

bool RPCSimHitMatcher::hitStation ( int  st) const

Definition at line 99 of file RPCSimHitMatcher.cc.

References chamberIds(), l1ctLayer2EG_cff::id, and relativeConstraints::station.

Referenced by nStations().

99  {
100  int nst = 0;
101  for (const auto& ddt : chamberIds(0)) {
102  const RPCDetId id(ddt);
103  if (id.station() != st)
104  continue;
105  ++nst;
106  }
107  return nst;
108 }
std::set< unsigned int > chamberIds(int type=MuonHitHelper::RPC_ALL) const

◆ hitStripsInDetId()

std::set< int > RPCSimHitMatcher::hitStripsInDetId ( unsigned int  detid,
int  margin_n_strips = 0 
) const

Definition at line 129 of file RPCSimHitMatcher.cc.

References relativeConstraints::chamber, MuonSimHitMatcher::geometry_, h, MuonSimHitMatcher::hitsInDetId(), l1ctLayer2EG_cff::id, mps_fire::result, nano_mu_digi_cff::roll, and contentValuesCheck::ss.

Referenced by match().

129  {
130  set<int> result;
131  RPCDetId id(detid);
132  for (const auto& roll : dynamic_cast<const RPCGeometry*>(geometry_)->chamber(id)->rolls()) {
133  int max_nstrips = roll->nstrips();
134  for (const auto& h : MuonSimHitMatcher::hitsInDetId(roll->id().rawId())) {
135  const LocalPoint& lp = h.entryPoint();
136  int central_strip = static_cast<int>(roll->topology().channel(lp));
137  int smin = central_strip - margin_n_strips;
138  smin = (smin > 0) ? smin : 1;
139  int smax = central_strip + margin_n_strips;
140  smax = (smax <= max_nstrips) ? smax : max_nstrips;
141  for (int ss = smin; ss <= smax; ++ss)
142  result.insert(ss);
143  }
144  }
145  return result;
146 }
const TrackingGeometry * geometry_
const edm::PSimHitContainer & hitsInDetId(unsigned int) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ init()

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

initialize the event

Definition at line 18 of file RPCSimHitMatcher.cc.

References MuonSimHitMatcher::geometry_, geomToken_, edm::EventSetup::getData(), iEvent, and MuonSimHitMatcher::init().

18  {
19  geometry_ = &iSetup.getData(geomToken_);
21 }
const TrackingGeometry * geometry_
int iEvent
Definition: GenABIO.cc:224
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > geomToken_

◆ match()

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

do the matching

Definition at line 24 of file RPCSimHitMatcher.cc.

References MuonSimHitMatcher::chamber_to_hits_, chamberIds(), detIds(), MuonSimHitMatcher::hitsInChamber(), hitStripsInDetId(), l1ctLayer2EG_cff::id, MuonSimHitMatcher::match(), matchSimHitsToSimTrack(), AlCaHLTBitMon_ParallelJobs::p, HLTBitAnalyser_cfi::simhits, MuonSimHitMatcher::simHits_, MuonSimHitMatcher::simHitsMeanPosition(), DigiDM_cff::strips, HLT_2024v12_cff::track, MuonSimHitMatcher::track_ids_, MuonSimHitMatcher::verbose_, and bphysicsOniaDQM_cfi::vertex.

24  {
25  // instantiates the track ids and simhits
27 
29 
30  if (verbose_) {
31  edm::LogInfo("RPCSimHitMatcher") << "nSimHits " << simHits_.size() << " nTrackIds " << track_ids_.size();
32  edm::LogInfo("RPCSimHitMatcher") << "detids RPC " << detIds().size();
33 
34  const auto& ch_ids = chamberIds();
35  for (const auto& id : ch_ids) {
36  const auto& simhits = MuonSimHitMatcher::hitsInChamber(id);
37  const auto& simhits_gp = simHitsMeanPosition(simhits);
38  edm::LogInfo("RPCSimHitMatcher") << "RPCDetId " << RPCDetId(id) << ": nHits " << simhits.size() << " eta "
39  << simhits_gp.eta() << " phi " << simhits_gp.phi() << " nCh "
40  << chamber_to_hits_[id].size();
41  const auto& strips = hitStripsInDetId(id);
42  edm::LogInfo("RPCSimHitMatcher") << "nStrips " << strips.size();
43  edm::LogInfo("RPCSimHitMatcher") << "strips : ";
44  for (const auto& p : strips) {
45  edm::LogInfo("RPCSimHitMatcher") << p;
46  }
47  }
48  }
49 }
const edm::PSimHitContainer & hitsInChamber(unsigned int) const
GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer &sim_hits) const
std::vector< unsigned > track_ids_
edm::PSimHitContainer simHits_
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
std::set< int > hitStripsInDetId(unsigned int, int margin_n_strips=0) const
std::set< unsigned int > chamberIds(int type=MuonHitHelper::RPC_ALL) const
Log< level::Info, false > LogInfo
void match(const SimTrack &t, const SimVertex &v)
do the matching
std::set< unsigned int > detIds(int type=MuonHitHelper::RPC_ALL) const
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers.hcal.doNoise = False simEcalUnsuppressedDigis.doNoise = False mix.digitizers.ecal.doNoise = False simEcalUnsuppressedDigis.doESNoise = False simSiPixelDigis.AddNoise = False mix.digitizers.pixel.AddNoise = False simSiStripDigis.Noise = False mix.digitizers.strip.AddNoise = False
Definition: DigiDM_cff.py:32

◆ matchSimHitsToSimTrack()

void RPCSimHitMatcher::matchSimHitsToSimTrack ( )
private

Definition at line 51 of file RPCSimHitMatcher.cc.

References funct::abs(), MuonSimHitMatcher::chamber_to_hits_, MuonSimHitMatcher::detid_to_hits_, MuonSimHitMatcher::discardEleHits_, h, MuonSimHitMatcher::hits_, EgammaValidation_cff::pdgid, MuonSimHitMatcher::simHits_, MuonSimHitMatcher::simMuOnly_, and MuonSimHitMatcher::track_ids_.

Referenced by match().

51  {
52  for (const auto& track_id : track_ids_) {
53  for (const auto& h : simHits_) {
54  if (h.trackId() != track_id)
55  continue;
56  int pdgid = h.particleType();
57  if (simMuOnly_ && std::abs(pdgid) != 13)
58  continue;
59  // discard electron hits in the RPC chambers
60  if (discardEleHits_ && std::abs(pdgid) == 11)
61  continue;
62 
63  const RPCDetId& layer_id(h.detUnitId());
64  detid_to_hits_[h.detUnitId()].push_back(h);
65  hits_.push_back(h);
66  chamber_to_hits_[layer_id.chamberId().rawId()].push_back(h);
67  }
68  }
69 }
edm::PSimHitContainer hits_
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_
std::vector< unsigned > track_ids_
edm::PSimHitContainer simHits_
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ nStations()

int RPCSimHitMatcher::nStations ( ) const

Definition at line 110 of file RPCSimHitMatcher.cc.

References hitStation().

110 { return (hitStation(1) + hitStation(2) + hitStation(3) + hitStation(4)); }
bool hitStation(int st) const

◆ simHitsMeanStrip()

float RPCSimHitMatcher::simHitsMeanStrip ( const edm::PSimHitContainer sim_hits) const

Definition at line 112 of file RPCSimHitMatcher.cc.

References ztail::d, f, MuonSimHitMatcher::geometry_, h, dqmiodumpmetadata::n, and nano_mu_digi_cff::roll.

112  {
113  if (sim_hits.empty())
114  return -1.f;
115 
116  float sums = 0.f;
117  size_t n = 0;
118  for (const auto& h : sim_hits) {
119  const LocalPoint& lp = h.entryPoint();
120  const auto& d = h.detUnitId();
121  sums += dynamic_cast<const RPCGeometry*>(geometry_)->roll(d)->strip(lp);
122  ++n;
123  }
124  if (n == 0)
125  return -1.f;
126  return sums / n;
127 }
const TrackingGeometry * geometry_
double f[11][100]
d
Definition: ztail.py:151
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

Member Data Documentation

◆ geomToken_

edm::ESGetToken<RPCGeometry, MuonGeometryRecord> RPCSimHitMatcher::geomToken_
private

Definition at line 49 of file RPCSimHitMatcher.h.

Referenced by init(), and RPCSimHitMatcher().