CMS 3D CMS Logo

RPCSimHitMatcher.cc
Go to the documentation of this file.
3 
4 using namespace std;
5 
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 
14 }
15 
18  iSetup.get<MuonGeometryRecord>().get(rpc_geom_);
19  if (rpc_geom_.isValid()) {
20  geometry_ = &*rpc_geom_;
21  } else {
22  hasGeometry_ = false;
23  edm::LogWarning("RPCSimHitMatcher") << "+++ Info: RPC geometry is unavailable. +++\n";
24  }
25  MuonSimHitMatcher::init(iEvent, iSetup);
26 }
27 
30  // instantiates the track ids and simhits
31  MuonSimHitMatcher::match(track, vertex);
32 
33  if (hasGeometry_) {
35 
36  if (verbose_) {
37  edm::LogInfo("RPCSimHitMatcher") << "nSimHits " << simHits_.size() << " nTrackIds " << track_ids_.size() << endl;
38  edm::LogInfo("RPCSimHitMatcher") << "detids RPC " << detIds().size() << endl;
39 
40  const auto& ch_ids = chamberIds();
41  for (const auto& id : ch_ids) {
42  const auto& simhits = MuonSimHitMatcher::hitsInChamber(id);
43  const auto& simhits_gp = simHitsMeanPosition(simhits);
44  edm::LogInfo("RPCSimHitMatcher") << "RPCDetId " << RPCDetId(id) << ": nHits " << simhits.size() << " eta "
45  << simhits_gp.eta() << " phi " << simhits_gp.phi() << " nCh "
46  << chamber_to_hits_[id].size() << endl;
47  const auto& strips = hitStripsInDetId(id);
48  edm::LogInfo("RPCSimHitMatcher") << "nStrips " << strips.size() << endl;
49  edm::LogInfo("RPCSimHitMatcher") << "strips : ";
50  for (const auto& p : strips) {
51  edm::LogInfo("RPCSimHitMatcher") << p;
52  }
53  }
54  }
55  }
56 }
57 
59  for (const auto& track_id : track_ids_) {
60  for (const auto& h : simHits_) {
61  if (h.trackId() != track_id)
62  continue;
63  int pdgid = h.particleType();
64  if (simMuOnly_ && std::abs(pdgid) != 13)
65  continue;
66  // discard electron hits in the RPC chambers
67  if (discardEleHits_ && pdgid == 11)
68  continue;
69 
70  const RPCDetId& layer_id(h.detUnitId());
71  detid_to_hits_[h.detUnitId()].push_back(h);
72  hits_.push_back(h);
73  chamber_to_hits_[layer_id.chamberId().rawId()].push_back(h);
74  }
75  }
76 }
77 
78 std::set<unsigned int> RPCSimHitMatcher::detIds(int type) const {
79  std::set<unsigned int> result;
80  for (const auto& p : detid_to_hits_) {
81  const auto& id = p.first;
82  if (type > 0) {
83  RPCDetId detId(id);
84  if (MuonHitHelper::toRPCType(detId.region(), detId.station(), detId.ring()) != type)
85  continue;
86  }
87  result.insert(id);
88  }
89  return result;
90 }
91 
92 std::set<unsigned int> RPCSimHitMatcher::chamberIds(int type) const {
93  std::set<unsigned int> result;
94  for (const auto& p : chamber_to_hits_) {
95  const auto& id = p.first;
96  if (type > 0) {
97  RPCDetId detId(id);
98  if (MuonHitHelper::toRPCType(detId.region(), detId.station(), detId.ring()) != type)
99  continue;
100  }
101  result.insert(id);
102  }
103  return result;
104 }
105 
106 bool RPCSimHitMatcher::hitStation(int st) const {
107  int nst = 0;
108  for (const auto& ddt : chamberIds(0)) {
109  const RPCDetId id(ddt);
110  if (id.station() != st)
111  continue;
112  ++nst;
113  }
114  return nst;
115 }
116 
117 int RPCSimHitMatcher::nStations() const { return (hitStation(1) + hitStation(2) + hitStation(3) + hitStation(4)); }
118 
120  if (sim_hits.empty())
121  return -1.f;
122 
123  float sums = 0.f;
124  size_t n = 0;
125  for (const auto& h : sim_hits) {
126  const LocalPoint& lp = h.entryPoint();
127  const auto& d = h.detUnitId();
128  sums += dynamic_cast<const RPCGeometry*>(geometry_)->roll(d)->strip(lp);
129  ++n;
130  }
131  if (n == 0)
132  return -1.f;
133  return sums / n;
134 }
135 
136 std::set<int> RPCSimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) const {
137  set<int> result;
138  RPCDetId id(detid);
139  for (const auto& roll : dynamic_cast<const RPCGeometry*>(geometry_)->chamber(id)->rolls()) {
140  int max_nstrips = roll->nstrips();
141  for (const auto& h : MuonSimHitMatcher::hitsInDetId(roll->id().rawId())) {
142  const LocalPoint& lp = h.entryPoint();
143  int central_strip = static_cast<int>(roll->topology().channel(lp));
144  int smin = central_strip - margin_n_strips;
145  smin = (smin > 0) ? smin : 1;
146  int smax = central_strip + margin_n_strips;
147  smax = (smax <= max_nstrips) ? smax : max_nstrips;
148  for (int ss = smin; ss <= smax; ++ss)
149  result.insert(ss);
150  }
151  }
152  return result;
153 }
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const TrackingGeometry * geometry_
edm::PSimHitContainer hits_
std::set< unsigned int > detIds(int type=MuonHitHelper::RPC_ALL) const
std::set< int > hitStripsInDetId(unsigned int, int margin_n_strips=0) const
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_
std::set< unsigned int > chamberIds(int type=MuonHitHelper::RPC_ALL) const
float simHitsMeanStrip(const edm::PSimHitContainer &sim_hits) const
RPCSimHitMatcher(const edm::ParameterSet &iPS, edm::ConsumesCollector &&iC)
std::vector< unsigned > track_ids_
int iEvent
Definition: GenABIO.cc:224
GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer &sim_hits) const
edm::PSimHitContainer simHits_
int ring() const
Definition: RPCDetId.h:59
edm::ParameterSet simHitPSet_
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
int nStations() const
d
Definition: ztail.py:151
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
ParameterSet const & getParameterSet(std::string const &) const
const edm::PSimHitContainer & hitsInDetId(unsigned int) const
void match(const SimTrack &t, const SimVertex &v)
do the matching
edm::EDGetTokenT< edm::PSimHitContainer > simHitInput_
T get() const
Definition: EventSetup.h:73
edm::ESHandle< RPCGeometry > rpc_geom_
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
std::vector< PSimHit > PSimHitContainer
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
bool hitStation(int st) const
static int toRPCType(int re, int st, int ri)
bool isValid() const
Definition: ESHandle.h:44
const edm::PSimHitContainer & hitsInChamber(unsigned int) const
def move(src, dest)
Definition: eostools.py:511
void match(const SimTrack &t, const SimVertex &v)
do the matching
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
int station() const
Definition: RPCDetId.h:78