CMS 3D CMS Logo

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

#include <ME0SimHitMatcher.h>

Inheritance diagram for ME0SimHitMatcher:
MuonSimHitMatcher

Public Member Functions

std::set< unsigned int > chamberIds () const
 
std::set< unsigned int > detIds () const
 
std::set< int > hitPadsInDetId (unsigned int) const
 
std::set< int > hitPartitions () const
 
const edm::PSimHitContainerhitsInSuperChamber (unsigned int) 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...
 
 ME0SimHitMatcher (const edm::ParameterSet &iPS, edm::ConsumesCollector &&iC)
 
int nCoincidenceChambers (int min_n_layers=4) const
 
int nLayersWithHitsInSuperChamber (unsigned int) const
 
int nPadsWithHits () const
 
float simHitsMeanStrip (const edm::PSimHitContainer &sim_hits) const
 
std::set< unsigned int > superChamberIds () const
 
std::set< unsigned int > superChamberIdsCoincidences (int min_n_layers=4) const
 
 ~ME0SimHitMatcher ()
 
- 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

std::map< unsigned int, std::set< int > > detids_to_copads_
 
std::map< unsigned int, std::set< int > > detids_to_pads_
 
edm::ESHandle< ME0Geometryme0_geom_
 
std::map< unsigned int, edm::PSimHitContainersuperChamber_to_hits_
 

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 ME0 SimHit to SimTrack

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

Definition at line 14 of file ME0SimHitMatcher.h.

Constructor & Destructor Documentation

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

Definition at line 5 of file ME0SimHitMatcher.cc.

References MuonSimHitMatcher::discardEleHits_, 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("me0SimHit");
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
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
ME0SimHitMatcher::~ME0SimHitMatcher ( )
inline

Member Function Documentation

std::set< unsigned int > ME0SimHitMatcher::chamberIds ( ) const

Definition at line 105 of file ME0SimHitMatcher.cc.

References MuonSimHitMatcher::chamber_to_hits_, AlCaHLTBitMon_ParallelJobs::p, and mps_fire::result.

Referenced by ~ME0SimHitMatcher().

105  {
106  std::set<unsigned int> result;
107  for (const auto& p : chamber_to_hits_) result.insert(p.first);
108  return result;
109 }
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
std::set< unsigned int > ME0SimHitMatcher::detIds ( void  ) const

Definition at line 99 of file ME0SimHitMatcher.cc.

References MuonSimHitMatcher::detid_to_hits_, AlCaHLTBitMon_ParallelJobs::p, and mps_fire::result.

Referenced by hitPartitions(), match(), matchSimHitsToSimTrack(), nPadsWithHits(), and ~ME0SimHitMatcher().

99  {
100  std::set<unsigned int> result;
101  for (const auto& p : detid_to_hits_) result.insert(p.first);
102  return result;
103 }
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_
std::set< int > ME0SimHitMatcher::hitPadsInDetId ( unsigned int  detid) const

Definition at line 191 of file ME0SimHitMatcher.cc.

References detids_to_pads_, and none.

Referenced by nPadsWithHits(), and ~ME0SimHitMatcher().

191  {
192  set<int> none;
193  if (detids_to_pads_.find(detid) == detids_to_pads_.end()) return none;
194  return detids_to_pads_.at(detid);
195 }
std::map< unsigned int, std::set< int > > detids_to_pads_
std::set< int > ME0SimHitMatcher::hitPartitions ( ) const

Definition at line 197 of file ME0SimHitMatcher.cc.

References detIds(), mps_fire::result, and ME0DetId::roll().

Referenced by ~ME0SimHitMatcher().

197  {
198  std::set<int> result;
199 
200  const auto& detids = detIds();
201  for (const auto& id : detids) {
202  ME0DetId idd(id);
203  result.insert(idd.roll());
204  }
205  return result;
206 }
std::set< unsigned int > detIds() const
const edm::PSimHitContainer & ME0SimHitMatcher::hitsInSuperChamber ( unsigned int  detid) const

Definition at line 117 of file ME0SimHitMatcher.cc.

References MuonSimHitMatcher::no_hits_, and superChamber_to_hits_.

Referenced by nLayersWithHitsInSuperChamber(), and ~ME0SimHitMatcher().

118  {
119  if (superChamber_to_hits_.find(detid) == superChamber_to_hits_.end())
120  return no_hits_;
121  return superChamber_to_hits_.at(detid);
122 }
edm::PSimHitContainer no_hits_
std::map< unsigned int, edm::PSimHitContainer > superChamber_to_hits_
std::set< int > ME0SimHitMatcher::hitStripsInDetId ( unsigned int  detid,
int  margin_n_strips = 0 
) const

Definition at line 168 of file ME0SimHitMatcher.cc.

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

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

169  {
170  set<int> result;
171  const auto& simhits = hitsInDetId(detid);
172  ME0DetId id(detid);
173  int max_nstrips =
174  dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(id)->nstrips();
175  for (const auto& h : simhits) {
176  const LocalPoint& lp = h.entryPoint();
177  int central_strip =
178  1 + static_cast<int>(dynamic_cast<const ME0Geometry*>(geometry_)
179  ->etaPartition(id)
180  ->topology()
181  .channel(lp));
182  int smin = central_strip - margin_n_strips;
183  smin = (smin > 0) ? smin : 1;
184  int smax = central_strip + margin_n_strips;
185  smax = (smax <= max_nstrips) ? smax : max_nstrips;
186  for (int ss = smin; ss <= smax; ++ss) result.insert(ss);
187  }
188  return result;
189 }
const TrackingGeometry * geometry_
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const edm::PSimHitContainer & hitsInDetId(unsigned int) const
void ME0SimHitMatcher::init ( const edm::Event e,
const edm::EventSetup eventSetup 
)

initialize the event

Definition at line 18 of file ME0SimHitMatcher.cc.

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

Referenced by ~ME0SimHitMatcher().

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

do the matching

Definition at line 32 of file ME0SimHitMatcher.cc.

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

Referenced by ~ME0SimHitMatcher().

32  {
33  // instantiates the track ids and simhits
35 
36  if (hasGeometry_) {
38 
39  if (verbose_) {
40  edm::LogInfo("ME0SimHitMatcher")
41  << "nTrackIds " << track_ids_.size() << " nSelectedME0SimHits "
42  << hits_.size() << endl;
43  edm::LogInfo("ME0SimHitMatcher")
44  << "detids ME0 " << detIds().size() << endl;
45 
46  const auto& me0_ch_ids = detIds();
47  for (const auto& id : me0_ch_ids) {
48  const auto& me0_simhits = MuonSimHitMatcher::hitsInChamber(id);
49  const auto& me0_simhits_gp = simHitsMeanPosition(me0_simhits);
50  edm::LogInfo("ME0SimHitMatcher")
51  << "me0chid " << ME0DetId(id) << ": nHits " << me0_simhits.size()
52  << " phi " << me0_simhits_gp.phi() << " nCh "
53  << chamber_to_hits_[id].size() << endl;
54  const auto& strips = hitStripsInDetId(id);
55  edm::LogInfo("ME0SimHitMatcher") << "nStrip " << strips.size() << endl;
56  edm::LogInfo("ME0SimHitMatcher") << "strips : ";
57  for (const auto& p : strips) {
58  edm::LogInfo("ME0SimHitMatcher") << p;
59  }
60  }
61  }
62  }
63 }
std::set< int > hitStripsInDetId(unsigned int, int margin_n_strips=0) const
edm::PSimHitContainer hits_
std::vector< unsigned > track_ids_
GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer &sim_hits) const
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
std::set< unsigned int > detIds() const
void match(const SimTrack &t, const SimVertex &v)
do the matching
const edm::PSimHitContainer & hitsInChamber(unsigned int) const
void ME0SimHitMatcher::matchSimHitsToSimTrack ( )
private

Definition at line 65 of file ME0SimHitMatcher.cc.

References funct::abs(), MuonSimHitMatcher::chamber_to_hits_, edmIntegrityCheck::d, MuonSimHitMatcher::detid_to_hits_, detIds(), detids_to_pads_, MuonSimHitMatcher::discardEleHits_, MuonSimHitMatcher::geometry_, h, hfClusterShapes_cfi::hits, MuonSimHitMatcher::hits_, MuonSimHitMatcher::hitsInDetId(), triggerObjects_cff::id, BPhysicsValidation_cfi::pdgid, MuonSimHitMatcher::simHits_, MuonSimHitMatcher::simMuOnly_, superChamber_to_hits_, and MuonSimHitMatcher::track_ids_.

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

65  {
66  for (const auto& track_id : track_ids_) {
67  for (const auto& h : simHits_) {
68  if (h.trackId() != track_id) continue;
69  int pdgid = h.particleType();
70  if (simMuOnly_ && std::abs(pdgid) != 13) continue;
71  // discard electron hits in the ME0 chambers
72  if (discardEleHits_ && std::abs(pdgid) == 11) continue;
73 
74  const ME0DetId& layer_id(h.detUnitId());
75  detid_to_hits_[h.detUnitId()].push_back(h);
76  hits_.push_back(h);
77  chamber_to_hits_[layer_id.layerId().rawId()].push_back(h);
78  superChamber_to_hits_[layer_id.chamberId().rawId()].push_back(h);
79  }
80  }
81 
82  // find pads with hits
83  const auto& detids = detIds();
84  for (const auto& d : detids) {
85  ME0DetId id(d);
86  const auto& hits = hitsInDetId(d);
87  const auto& roll =
88  dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(id);
89  // int max_npads = roll->npads();
90  set<int> pads;
91  for (const auto& h : hits) {
92  const LocalPoint& lp = h.entryPoint();
93  pads.insert(1 + static_cast<int>(roll->padTopology().channel(lp)));
94  }
95  detids_to_pads_[d] = pads;
96  }
97 }
const TrackingGeometry * geometry_
edm::PSimHitContainer hits_
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_
std::map< unsigned int, std::set< int > > detids_to_pads_
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
std::set< unsigned int > detIds() const
const edm::PSimHitContainer & hitsInDetId(unsigned int) const
std::map< unsigned int, edm::PSimHitContainer > superChamber_to_hits_
int ME0SimHitMatcher::nCoincidenceChambers ( int  min_n_layers = 4) const

Definition at line 146 of file ME0SimHitMatcher.cc.

References superChamberIdsCoincidences().

Referenced by ~ME0SimHitMatcher().

146  {
147  return superChamberIdsCoincidences(min_n_layers).size();
148 }
std::set< unsigned int > superChamberIdsCoincidences(int min_n_layers=4) const
int ME0SimHitMatcher::nLayersWithHitsInSuperChamber ( unsigned int  detid) const

Definition at line 124 of file ME0SimHitMatcher.cc.

References h, hfClusterShapes_cfi::hits, and hitsInSuperChamber().

Referenced by superChamberIdsCoincidences(), and ~ME0SimHitMatcher().

124  {
125  set<int> layers_with_hits;
126  const auto& hits = hitsInSuperChamber(detid);
127  for (const auto& h : hits) {
128  const ME0DetId& idd(h.detUnitId());
129  layers_with_hits.insert(idd.layer());
130  }
131  return layers_with_hits.size();
132 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const edm::PSimHitContainer & hitsInSuperChamber(unsigned int) const
int ME0SimHitMatcher::nPadsWithHits ( ) const

Definition at line 208 of file ME0SimHitMatcher.cc.

References detIds(), hitPadsInDetId(), and mps_fire::result.

Referenced by ~ME0SimHitMatcher().

208  {
209  int result = 0;
210  const auto& pad_ids = detIds();
211  for (const auto& id : pad_ids) {
212  result += hitPadsInDetId(id).size();
213  }
214  return result;
215 }
std::set< int > hitPadsInDetId(unsigned int) const
std::set< unsigned int > detIds() const
float ME0SimHitMatcher::simHitsMeanStrip ( const edm::PSimHitContainer sim_hits) const

Definition at line 150 of file ME0SimHitMatcher.cc.

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

Referenced by ~ME0SimHitMatcher().

151  {
152  if (sim_hits.empty()) return -1.f;
153 
154  float sums = 0.f;
155  size_t n = 0;
156  for (const auto& h : sim_hits) {
157  const LocalPoint& lp = h.entryPoint();
158  float s;
159  const auto& d = h.detUnitId();
160  s = dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(d)->strip(lp);
161  sums += s;
162  ++n;
163  }
164  if (n == 0) return -1.f;
165  return sums / n;
166 }
const TrackingGeometry * geometry_
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
double f[11][100]
std::set< unsigned int > ME0SimHitMatcher::superChamberIds ( ) const

Definition at line 111 of file ME0SimHitMatcher.cc.

References AlCaHLTBitMon_ParallelJobs::p, mps_fire::result, and superChamber_to_hits_.

Referenced by superChamberIdsCoincidences(), and ~ME0SimHitMatcher().

111  {
112  std::set<unsigned int> result;
113  for (const auto& p : superChamber_to_hits_) result.insert(p.first);
114  return result;
115 }
std::map< unsigned int, edm::PSimHitContainer > superChamber_to_hits_
std::set< unsigned int > ME0SimHitMatcher::superChamberIdsCoincidences ( int  min_n_layers = 4) const

Definition at line 134 of file ME0SimHitMatcher.cc.

References nLayersWithHitsInSuperChamber(), AlCaHLTBitMon_ParallelJobs::p, mps_fire::result, and superChamberIds().

Referenced by nCoincidenceChambers(), and ~ME0SimHitMatcher().

135  {
136  set<unsigned int> result;
137  // loop over the super chamber Ids
138  for (const auto& p : superChamberIds()) {
139  if (nLayersWithHitsInSuperChamber(p) >= min_n_layers) {
140  result.insert(p);
141  }
142  }
143  return result;
144 }
int nLayersWithHitsInSuperChamber(unsigned int) const
std::set< unsigned int > superChamberIds() const

Member Data Documentation

std::map<unsigned int, std::set<int> > ME0SimHitMatcher::detids_to_copads_
private

Definition at line 72 of file ME0SimHitMatcher.h.

std::map<unsigned int, std::set<int> > ME0SimHitMatcher::detids_to_pads_
private

Definition at line 69 of file ME0SimHitMatcher.h.

Referenced by hitPadsInDetId(), and matchSimHitsToSimTrack().

edm::ESHandle<ME0Geometry> ME0SimHitMatcher::me0_geom_
private

Definition at line 66 of file ME0SimHitMatcher.h.

Referenced by init().

std::map<unsigned int, edm::PSimHitContainer> ME0SimHitMatcher::superChamber_to_hits_
private

Definition at line 74 of file ME0SimHitMatcher.h.

Referenced by hitsInSuperChamber(), matchSimHitsToSimTrack(), and superChamberIds().