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 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::ESHandle< RPCGeometryrpc_geom_
 

Additional Inherited Members

- Protected Member Functions inherited from MuonSimHitMatcher
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 14 of file RPCSimHitMatcher.h.

Constructor & Destructor Documentation

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

Definition at line 6 of file RPCSimHitMatcher.cc.

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

8  : MuonSimHitMatcher(ps, std::move(iC)) {
9  simHitPSet_ = ps.getParameterSet("rpcSimHit");
10  verbose_ = simHitPSet_.getParameter<int>("verbose");
11  simMuOnly_ = simHitPSet_.getParameter<bool>("simMuOnly");
12  discardEleHits_ = simHitPSet_.getParameter<bool>("discardEleHits");
13 
16 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::ParameterSet simHitPSet_
ParameterSet const & getParameterSet(std::string const &) const
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
RPCSimHitMatcher::~RPCSimHitMatcher ( )
inline

Member Function Documentation

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

Definition at line 98 of file RPCSimHitMatcher.cc.

References MuonSimHitMatcher::chamber_to_hits_, AlCaHLTBitMon_ParallelJobs::p, RPCDetId::region(), mps_fire::result, RPCDetId::ring(), RPCDetId::station(), and MuonHitHelper::toRPCType().

Referenced by hitStation(), match(), and ~RPCSimHitMatcher().

98  {
99  std::set<unsigned int> result;
100  for (const auto& p : chamber_to_hits_) {
101  const auto& id = p.first;
102  if (type > 0) {
103  RPCDetId detId(id);
104  if (MuonHitHelper::toRPCType(detId.region(), detId.station(),
105  detId.ring()) != type)
106  continue;
107  }
108  result.insert(id);
109  }
110  return result;
111 }
type
Definition: HCALResponse.h:21
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
static int toRPCType(int re, int st, int ri)
std::set< unsigned int > RPCSimHitMatcher::detIds ( int  type = MuonHitHelper::RPC_ALL) const

Definition at line 83 of file RPCSimHitMatcher.cc.

References MuonSimHitMatcher::detid_to_hits_, AlCaHLTBitMon_ParallelJobs::p, RPCDetId::region(), mps_fire::result, RPCDetId::ring(), RPCDetId::station(), and MuonHitHelper::toRPCType().

Referenced by match(), and ~RPCSimHitMatcher().

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

Definition at line 113 of file RPCSimHitMatcher.cc.

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

Referenced by nStations(), and ~RPCSimHitMatcher().

113  {
114  int nst = 0;
115  for (const auto& ddt : chamberIds(0)) {
116  const RPCDetId id(ddt);
117  if (id.station() != st) continue;
118  ++nst;
119  }
120  return nst;
121 }
std::set< unsigned int > chamberIds(int type=MuonHitHelper::RPC_ALL) const
std::set< int > RPCSimHitMatcher::hitStripsInDetId ( unsigned int  detid,
int  margin_n_strips = 0 
) const

Definition at line 143 of file RPCSimHitMatcher.cc.

References relativeConstraints::chamber, MuonSimHitMatcher::geometry_, h, MuonSimHitMatcher::hitsInDetId(), triggerObjects_cff::id, and mps_fire::result.

Referenced by match(), and ~RPCSimHitMatcher().

144  {
145  set<int> result;
146  RPCDetId id(detid);
147  for (const auto& roll :
148  dynamic_cast<const RPCGeometry*>(geometry_)->chamber(id)->rolls()) {
149  int max_nstrips = roll->nstrips();
150  for (const auto& h : MuonSimHitMatcher::hitsInDetId(roll->id().rawId())) {
151  const LocalPoint& lp = h.entryPoint();
152  int central_strip = static_cast<int>(roll->topology().channel(lp));
153  int smin = central_strip - margin_n_strips;
154  smin = (smin > 0) ? smin : 1;
155  int smax = central_strip + margin_n_strips;
156  smax = (smax <= max_nstrips) ? smax : max_nstrips;
157  for (int ss = smin; ss <= smax; ++ss) result.insert(ss);
158  }
159  }
160  return result;
161 }
const TrackingGeometry * geometry_
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const edm::PSimHitContainer & hitsInDetId(unsigned int) const
void RPCSimHitMatcher::init ( const edm::Event e,
const edm::EventSetup eventSetup 
)

initialize the event

Definition at line 19 of file RPCSimHitMatcher.cc.

References MuonSimHitMatcher::geometry_, edm::EventSetup::get(), MuonSimHitMatcher::hasGeometry_, MuonSimHitMatcher::init(), edm::ESHandleBase::isValid(), and rpc_geom_.

Referenced by ~RPCSimHitMatcher().

20  {
21  iSetup.get<MuonGeometryRecord>().get(rpc_geom_);
22  if (rpc_geom_.isValid()) {
23  geometry_ = &*rpc_geom_;
24  } else {
25  hasGeometry_ = false;
26  edm::LogWarning("RPCSimHitMatcher")
27  << "+++ Info: RPC geometry is unavailable. +++\n";
28  }
30 }
const TrackingGeometry * geometry_
int iEvent
Definition: GenABIO.cc:224
edm::ESHandle< RPCGeometry > rpc_geom_
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
bool isValid() const
Definition: ESHandle.h:44
void RPCSimHitMatcher::match ( const SimTrack t,
const SimVertex v 
)

do the matching

Definition at line 33 of file RPCSimHitMatcher.cc.

References MuonSimHitMatcher::chamber_to_hits_, chamberIds(), detIds(), MuonSimHitMatcher::hasGeometry_, MuonSimHitMatcher::hitsInChamber(), hitStripsInDetId(), triggerObjects_cff::id, MuonSimHitMatcher::match(), matchSimHitsToSimTrack(), AlCaHLTBitMon_ParallelJobs::p, MuonSimHitMatcher::simHits_, MuonSimHitMatcher::simHitsMeanPosition(), RecoTauPiZeroBuilderPlugins_cfi::strips, MuonSimHitMatcher::track_ids_, and MuonSimHitMatcher::verbose_.

Referenced by ~RPCSimHitMatcher().

33  {
34  // instantiates the track ids and simhits
36 
37  if (hasGeometry_) {
39 
40  if (verbose_) {
41  edm::LogInfo("RPCSimHitMatcher")
42  << "nSimHits " << simHits_.size() << " nTrackIds "
43  << track_ids_.size() << endl;
44  edm::LogInfo("RPCSimHitMatcher")
45  << "detids RPC " << detIds().size() << endl;
46 
47  const auto& ch_ids = chamberIds();
48  for (const auto& id : ch_ids) {
49  const auto& simhits = MuonSimHitMatcher::hitsInChamber(id);
50  const auto& simhits_gp = simHitsMeanPosition(simhits);
51  edm::LogInfo("RPCSimHitMatcher")
52  << "RPCDetId " << RPCDetId(id) << ": nHits " << simhits.size()
53  << " eta " << simhits_gp.eta() << " phi " << simhits_gp.phi()
54  << " nCh " << chamber_to_hits_[id].size() << endl;
55  const auto& strips = hitStripsInDetId(id);
56  edm::LogInfo("RPCSimHitMatcher") << "nStrips " << strips.size() << endl;
57  edm::LogInfo("RPCSimHitMatcher") << "strips : ";
58  for (const auto& p : strips) {
59  edm::LogInfo("RPCSimHitMatcher") << p;
60  }
61  }
62  }
63  }
64 }
std::set< unsigned int > detIds(int type=MuonHitHelper::RPC_ALL) const
std::set< int > hitStripsInDetId(unsigned int, int margin_n_strips=0) const
std::set< unsigned int > chamberIds(int type=MuonHitHelper::RPC_ALL) const
std::vector< unsigned > track_ids_
GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer &sim_hits) const
edm::PSimHitContainer simHits_
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
void match(const SimTrack &t, const SimVertex &v)
do the matching
const edm::PSimHitContainer & hitsInChamber(unsigned int) const
void RPCSimHitMatcher::matchSimHitsToSimTrack ( )
private

Definition at line 66 of file RPCSimHitMatcher.cc.

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

Referenced by match(), and ~RPCSimHitMatcher().

66  {
67  for (const auto& track_id : track_ids_) {
68  for (const auto& h : simHits_) {
69  if (h.trackId() != track_id) continue;
70  int pdgid = h.particleType();
71  if (simMuOnly_ && std::abs(pdgid) != 13) continue;
72  // discard electron hits in the RPC chambers
73  if (discardEleHits_ && pdgid == 11) continue;
74 
75  const RPCDetId& layer_id(h.detUnitId());
76  detid_to_hits_[h.detUnitId()].push_back(h);
77  hits_.push_back(h);
78  chamber_to_hits_[layer_id.chamberId().rawId()].push_back(h);
79  }
80  }
81 }
edm::PSimHitContainer hits_
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
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
int RPCSimHitMatcher::nStations ( ) const

Definition at line 123 of file RPCSimHitMatcher.cc.

References hitStation().

Referenced by ~RPCSimHitMatcher().

123  {
124  return (hitStation(1) + hitStation(2) + hitStation(3) + hitStation(4));
125 }
bool hitStation(int st) const
float RPCSimHitMatcher::simHitsMeanStrip ( const edm::PSimHitContainer sim_hits) const

Definition at line 127 of file RPCSimHitMatcher.cc.

References edmIntegrityCheck::d, f, MuonSimHitMatcher::geometry_, h, and gen::n.

Referenced by ~RPCSimHitMatcher().

128  {
129  if (sim_hits.empty()) return -1.f;
130 
131  float sums = 0.f;
132  size_t n = 0;
133  for (const auto& h : sim_hits) {
134  const LocalPoint& lp = h.entryPoint();
135  const auto& d = h.detUnitId();
136  sums += dynamic_cast<const RPCGeometry*>(geometry_)->roll(d)->strip(lp);
137  ++n;
138  }
139  if (n == 0) return -1.f;
140  return sums / n;
141 }
const TrackingGeometry * geometry_
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
double f[11][100]

Member Data Documentation

edm::ESHandle<RPCGeometry> RPCSimHitMatcher::rpc_geom_
private

Definition at line 47 of file RPCSimHitMatcher.h.

Referenced by init().