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  geomToken_ = iC.esConsumes<RPCGeometry, MuonGeometryRecord>();
15 }
16 
19  geometry_ = &iSetup.getData(geomToken_);
21 }
22 
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 }
50 
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 }
70 
71 std::set<unsigned int> RPCSimHitMatcher::detIds(int type) const {
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 }
84 
85 std::set<unsigned int> RPCSimHitMatcher::chamberIds(int type) const {
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 }
98 
99 bool RPCSimHitMatcher::hitStation(int st) const {
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 }
109 
110 int RPCSimHitMatcher::nStations() const { return (hitStation(1) + hitStation(2) + hitStation(3) + hitStation(4)); }
111 
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 }
128 
129 std::set<int> RPCSimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) const {
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 }
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
SimVertex
Definition: SimVertex.h:5
RPCDetId::station
int station() const
Definition: RPCDetId.h:78
RPCDetId::region
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
MuonSimHitMatcher::geometry_
const TrackingGeometry * geometry_
Definition: MuonSimHitMatcher.h:84
RPCSimHitMatcher::match
void match(const SimTrack &t, const SimVertex &v)
do the matching
Definition: RPCSimHitMatcher.cc:24
relativeConstraints.station
station
Definition: relativeConstraints.py:67
MuonSimHitMatcher::verbose_
bool verbose_
Definition: MuonSimHitMatcher.h:81
RPCDetId
Definition: RPCDetId.h:16
MuonSimHitMatcher::detid_to_hits_
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_
Definition: MuonSimHitMatcher.h:106
RPCSimHitMatcher::RPCSimHitMatcher
RPCSimHitMatcher(const edm::ParameterSet &iPS, edm::ConsumesCollector &&iC)
Definition: RPCSimHitMatcher.cc:6
MuonSimHitMatcher::simHitsMeanPosition
GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer &sim_hits) const
Definition: MuonSimHitMatcher.cc:99
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
MuonSimHitMatcher::simHits_
edm::PSimHitContainer simHits_
Definition: MuonSimHitMatcher.h:97
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
h
RPCSimHitMatcher::chamberIds
std::set< unsigned int > chamberIds(int type=MuonHitHelper::RPC_ALL) const
Definition: RPCSimHitMatcher.cc:85
MuonSimHitMatcher::simHitPSet_
edm::ParameterSet simHitPSet_
Definition: MuonSimHitMatcher.h:109
RPCSimHitMatcher::init
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
Definition: RPCSimHitMatcher.cc:18
Point3DBase< float, LocalTag >
MuonSimHitMatcher::track_ids_
std::vector< unsigned > track_ids_
Definition: MuonSimHitMatcher.h:99
RPCSimHitMatcher::nStations
int nStations() const
Definition: RPCSimHitMatcher.cc:110
MuonSimHitMatcher::discardEleHits_
bool discardEleHits_
Definition: MuonSimHitMatcher.h:80
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
HLTBitAnalyser_cfi.simhits
simhits
SIM objects.
Definition: HLTBitAnalyser_cfi.py:21
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
MuonSimHitMatcher
Definition: MuonSimHitMatcher.h:32
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
MuonSimHitMatcher::match
void match(const SimTrack &t, const SimVertex &v)
do the matching
Definition: MuonSimHitMatcher.cc:26
RPCSimHitMatcher::hitStripsInDetId
std::set< int > hitStripsInDetId(unsigned int, int margin_n_strips=0) const
Definition: RPCSimHitMatcher.cc:129
RPCSimHitMatcher.h
MuonHitHelper::toRPCType
static int toRPCType(int re, int st, int ri)
Definition: MuonHitHelper.cc:60
iEvent
int iEvent
Definition: GenABIO.cc:224
RPCSimHitMatcher::simHitsMeanStrip
float simHitsMeanStrip(const edm::PSimHitContainer &sim_hits) const
Definition: RPCSimHitMatcher.cc:112
MuonSimHitMatcher::chamber_to_hits_
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
Definition: MuonSimHitMatcher.h:107
edm::EventSetup
Definition: EventSetup.h:58
MuonSimHitMatcher::simHitInput_
edm::EDGetTokenT< edm::PSimHitContainer > simHitInput_
Definition: MuonSimHitMatcher.h:88
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
RPCDetId::ring
int ring() const
Definition: RPCDetId.h:59
MuonSimHitMatcher::hitsInDetId
const edm::PSimHitContainer & hitsInDetId(unsigned int) const
Definition: MuonSimHitMatcher.cc:87
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
TrapezoidalStripTopology.h
RPCSimHitMatcher::matchSimHitsToSimTrack
void matchSimHitsToSimTrack()
Definition: RPCSimHitMatcher.cc:51
SimTrack
Definition: SimTrack.h:9
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
RPCSimHitMatcher::geomToken_
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > geomToken_
Definition: RPCSimHitMatcher.h:49
RPCSimHitMatcher::hitStation
bool hitStation(int st) const
Definition: RPCSimHitMatcher.cc:99
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
MuonSimHitMatcher::simMuOnly_
bool simMuOnly_
Definition: MuonSimHitMatcher.h:79
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MuonSimHitMatcher::hitsInChamber
const edm::PSimHitContainer & hitsInChamber(unsigned int) const
Definition: MuonSimHitMatcher.cc:93
ztail.d
d
Definition: ztail.py:151
mps_fire.result
result
Definition: mps_fire.py:311
RPCGeometry
Definition: RPCGeometry.h:20
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
MuonSimHitMatcher::hits_
edm::PSimHitContainer hits_
Definition: MuonSimHitMatcher.h:105
edm::Event
Definition: Event.h:73
EgammaValidation_cff.pdgid
pdgid
Definition: EgammaValidation_cff.py:29
MuonSimHitMatcher::init
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
initialize the event
Definition: MuonSimHitMatcher.cc:17
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
edm::InputTag
Definition: InputTag.h:15
DigiDM_cff.strips
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers....
Definition: DigiDM_cff.py:32
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
RPCSimHitMatcher::detIds
std::set< unsigned int > detIds(int type=MuonHitHelper::RPC_ALL) const
Definition: RPCSimHitMatcher.cc:71
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128