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 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

std::map< unsigned int, std::set< int > > detids_to_copads_
 
std::map< unsigned int, std::set< int > > detids_to_pads_
 
edm::ESGetToken< ME0Geometry, MuonGeometryRecordgeomToken_
 
std::map< unsigned int, edm::PSimHitContainersuperChamber_to_hits_
 

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

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

Definition at line 16 of file ME0SimHitMatcher.h.

Constructor & Destructor Documentation

◆ ME0SimHitMatcher()

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

Definition at line 5 of file ME0SimHitMatcher.cc.

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

6  : MuonSimHitMatcher(ps, std::move(iC)) {
7  simHitPSet_ = ps.getParameterSet("me0SimHit");
8  verbose_ = simHitPSet_.getParameter<int>("verbose");
9  simMuOnly_ = simHitPSet_.getParameter<bool>("simMuOnly");
10  discardEleHits_ = simHitPSet_.getParameter<bool>("discardEleHits");
11 
14 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< ME0Geometry, MuonGeometryRecord > geomToken_
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

◆ ~ME0SimHitMatcher()

ME0SimHitMatcher::~ME0SimHitMatcher ( )
inline

Definition at line 22 of file ME0SimHitMatcher.h.

22 {}

Member Function Documentation

◆ chamberIds()

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

Definition at line 92 of file ME0SimHitMatcher.cc.

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

92  {
93  std::set<unsigned int> result;
94  for (const auto& p : chamber_to_hits_)
95  result.insert(p.first);
96  return result;
97 }
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_

◆ detIds()

std::set< unsigned int > ME0SimHitMatcher::detIds ( void  ) const

Definition at line 85 of file ME0SimHitMatcher.cc.

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

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

85  {
86  std::set<unsigned int> result;
87  for (const auto& p : detid_to_hits_)
88  result.insert(p.first);
89  return result;
90 }
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_

◆ hitPadsInDetId()

std::set< int > ME0SimHitMatcher::hitPadsInDetId ( unsigned int  detid) const

Definition at line 175 of file ME0SimHitMatcher.cc.

References detids_to_pads_, and none.

Referenced by nPadsWithHits().

175  {
176  set<int> none;
177  if (detids_to_pads_.find(detid) == detids_to_pads_.end())
178  return none;
179  return detids_to_pads_.at(detid);
180 }
std::map< unsigned int, std::set< int > > detids_to_pads_

◆ hitPartitions()

std::set< int > ME0SimHitMatcher::hitPartitions ( ) const

Definition at line 182 of file ME0SimHitMatcher.cc.

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

182  {
183  std::set<int> result;
184 
185  const auto& detids = detIds();
186  for (const auto& id : detids) {
187  ME0DetId idd(id);
188  result.insert(idd.roll());
189  }
190  return result;
191 }
std::set< unsigned int > detIds() const

◆ hitsInSuperChamber()

const edm::PSimHitContainer & ME0SimHitMatcher::hitsInSuperChamber ( unsigned int  detid) const

Definition at line 106 of file ME0SimHitMatcher.cc.

References MuonSimHitMatcher::no_hits_, and superChamber_to_hits_.

Referenced by nLayersWithHitsInSuperChamber().

106  {
107  if (superChamber_to_hits_.find(detid) == superChamber_to_hits_.end())
108  return no_hits_;
109  return superChamber_to_hits_.at(detid);
110 }
edm::PSimHitContainer no_hits_
std::map< unsigned int, edm::PSimHitContainer > superChamber_to_hits_

◆ hitStripsInDetId()

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

Definition at line 156 of file ME0SimHitMatcher.cc.

References MuonSimHitMatcher::geometry_, h, MuonSimHitMatcher::hitsInDetId(), l1ctLayer2EG_cff::id, mps_fire::result, HLTBitAnalyser_cfi::simhits, and contentValuesCheck::ss.

Referenced by match().

156  {
157  set<int> result;
158  const auto& simhits = hitsInDetId(detid);
159  ME0DetId id(detid);
160  int max_nstrips = dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(id)->nstrips();
161  for (const auto& h : simhits) {
162  const LocalPoint& lp = h.entryPoint();
163  int central_strip =
164  1 + static_cast<int>(dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(id)->topology().channel(lp));
165  int smin = central_strip - margin_n_strips;
166  smin = (smin > 0) ? smin : 1;
167  int smax = central_strip + margin_n_strips;
168  smax = (smax <= max_nstrips) ? smax : max_nstrips;
169  for (int ss = smin; ss <= smax; ++ss)
170  result.insert(ss);
171  }
172  return result;
173 }
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 ME0SimHitMatcher::init ( const edm::Event e,
const edm::EventSetup eventSetup 
)

initialize the event

Definition at line 17 of file ME0SimHitMatcher.cc.

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

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

◆ match()

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

do the matching

Definition at line 23 of file ME0SimHitMatcher.cc.

References MuonSimHitMatcher::chamber_to_hits_, detIds(), MuonSimHitMatcher::hits_, MuonSimHitMatcher::hitsInChamber(), hitStripsInDetId(), l1ctLayer2EG_cff::id, MuonSimHitMatcher::match(), matchSimHitsToSimTrack(), AlCaHLTBitMon_ParallelJobs::p, MuonSimHitMatcher::simHitsMeanPosition(), DigiDM_cff::strips, HLT_2024v14_cff::track, MuonSimHitMatcher::track_ids_, MuonSimHitMatcher::verbose_, and bphysicsOniaDQM_cfi::vertex.

23  {
24  // instantiates the track ids and simhits
26 
28 
29  if (verbose_) {
30  edm::LogInfo("ME0SimHitMatcher") << "nTrackIds " << track_ids_.size() << " nSelectedME0SimHits " << hits_.size();
31  edm::LogInfo("ME0SimHitMatcher") << "detids ME0 " << detIds().size();
32 
33  const auto& me0_ch_ids = detIds();
34  for (const auto& id : me0_ch_ids) {
35  const auto& me0_simhits = MuonSimHitMatcher::hitsInChamber(id);
36  const auto& me0_simhits_gp = simHitsMeanPosition(me0_simhits);
37  edm::LogInfo("ME0SimHitMatcher") << "me0chid " << ME0DetId(id) << ": nHits " << me0_simhits.size() << " phi "
38  << me0_simhits_gp.phi() << " nCh " << chamber_to_hits_[id].size();
39  const auto& strips = hitStripsInDetId(id);
40  edm::LogInfo("ME0SimHitMatcher") << "nStrip " << strips.size();
41  edm::LogInfo("ME0SimHitMatcher") << "strips : ";
42  for (const auto& p : strips) {
43  edm::LogInfo("ME0SimHitMatcher") << p;
44  }
45  }
46  }
47 }
const edm::PSimHitContainer & hitsInChamber(unsigned int) const
edm::PSimHitContainer hits_
GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer &sim_hits) const
std::vector< unsigned > track_ids_
std::set< unsigned int > detIds() const
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
Log< level::Info, false > LogInfo
void match(const SimTrack &t, const SimVertex &v)
do the matching
std::set< int > hitStripsInDetId(unsigned int, int margin_n_strips=0) 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 ME0SimHitMatcher::matchSimHitsToSimTrack ( )
private

Definition at line 49 of file ME0SimHitMatcher.cc.

References funct::abs(), MuonSimHitMatcher::chamber_to_hits_, ztail::d, MuonSimHitMatcher::detid_to_hits_, detIds(), detids_to_pads_, MuonSimHitMatcher::discardEleHits_, MuonSimHitMatcher::geometry_, h, hfClusterShapes_cfi::hits, MuonSimHitMatcher::hits_, MuonSimHitMatcher::hitsInDetId(), l1ctLayer2EG_cff::id, EgammaValidation_cff::pdgid, nano_mu_digi_cff::roll, MuonSimHitMatcher::simHits_, MuonSimHitMatcher::simMuOnly_, superChamber_to_hits_, and MuonSimHitMatcher::track_ids_.

Referenced by match().

49  {
50  for (const auto& track_id : track_ids_) {
51  for (const auto& h : simHits_) {
52  if (h.trackId() != track_id)
53  continue;
54  int pdgid = h.particleType();
55  if (simMuOnly_ && std::abs(pdgid) != 13)
56  continue;
57  // discard electron hits in the ME0 chambers
58  if (discardEleHits_ && std::abs(pdgid) == 11)
59  continue;
60 
61  const ME0DetId& layer_id(h.detUnitId());
62  detid_to_hits_[h.detUnitId()].push_back(h);
63  hits_.push_back(h);
64  chamber_to_hits_[layer_id.layerId().rawId()].push_back(h);
65  superChamber_to_hits_[layer_id.chamberId().rawId()].push_back(h);
66  }
67  }
68 
69  // find pads with hits
70  const auto& detids = detIds();
71  for (const auto& d : detids) {
72  ME0DetId id(d);
73  const auto& hits = hitsInDetId(d);
74  const auto& roll = dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(id);
75  // int max_npads = roll->npads();
76  set<int> pads;
77  for (const auto& h : hits) {
78  const LocalPoint& lp = h.entryPoint();
79  pads.insert(1 + static_cast<int>(roll->padTopology().channel(lp)));
80  }
81  detids_to_pads_[d] = pads;
82  }
83 }
const TrackingGeometry * geometry_
edm::PSimHitContainer hits_
std::map< unsigned int, edm::PSimHitContainer > detid_to_hits_
std::map< unsigned int, std::set< int > > detids_to_pads_
std::vector< unsigned > track_ids_
std::set< unsigned int > detIds() const
edm::PSimHitContainer simHits_
std::map< unsigned int, edm::PSimHitContainer > chamber_to_hits_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
d
Definition: ztail.py:151
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
std::map< unsigned int, edm::PSimHitContainer > superChamber_to_hits_

◆ nCoincidenceChambers()

int ME0SimHitMatcher::nCoincidenceChambers ( int  min_n_layers = 4) const

Definition at line 133 of file ME0SimHitMatcher.cc.

References superChamberIdsCoincidences().

133  {
134  return superChamberIdsCoincidences(min_n_layers).size();
135 }
std::set< unsigned int > superChamberIdsCoincidences(int min_n_layers=4) const

◆ nLayersWithHitsInSuperChamber()

int ME0SimHitMatcher::nLayersWithHitsInSuperChamber ( unsigned int  detid) const

Definition at line 112 of file ME0SimHitMatcher.cc.

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

Referenced by superChamberIdsCoincidences().

112  {
113  set<int> layers_with_hits;
114  const auto& hits = hitsInSuperChamber(detid);
115  for (const auto& h : hits) {
116  const ME0DetId& idd(h.detUnitId());
117  layers_with_hits.insert(idd.layer());
118  }
119  return layers_with_hits.size();
120 }
const edm::PSimHitContainer & hitsInSuperChamber(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

◆ nPadsWithHits()

int ME0SimHitMatcher::nPadsWithHits ( ) const

Definition at line 193 of file ME0SimHitMatcher.cc.

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

193  {
194  int result = 0;
195  const auto& pad_ids = detIds();
196  for (const auto& id : pad_ids) {
197  result += hitPadsInDetId(id).size();
198  }
199  return result;
200 }
std::set< int > hitPadsInDetId(unsigned int) const
std::set< unsigned int > detIds() const

◆ simHitsMeanStrip()

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

Definition at line 137 of file ME0SimHitMatcher.cc.

References ztail::d, f, MuonSimHitMatcher::geometry_, h, dqmiodumpmetadata::n, and alignCSCRings::s.

137  {
138  if (sim_hits.empty())
139  return -1.f;
140 
141  float sums = 0.f;
142  size_t n = 0;
143  for (const auto& h : sim_hits) {
144  const LocalPoint& lp = h.entryPoint();
145  float s;
146  const auto& d = h.detUnitId();
147  s = dynamic_cast<const ME0Geometry*>(geometry_)->etaPartition(d)->strip(lp);
148  sums += s;
149  ++n;
150  }
151  if (n == 0)
152  return -1.f;
153  return sums / n;
154 }
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

◆ superChamberIds()

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

Definition at line 99 of file ME0SimHitMatcher.cc.

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

Referenced by superChamberIdsCoincidences().

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

◆ superChamberIdsCoincidences()

std::set< unsigned int > ME0SimHitMatcher::superChamberIdsCoincidences ( int  min_n_layers = 4) const

Definition at line 122 of file ME0SimHitMatcher.cc.

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

Referenced by nCoincidenceChambers().

122  {
123  set<unsigned int> result;
124  // loop over the super chamber Ids
125  for (const auto& p : superChamberIds()) {
126  if (nLayersWithHitsInSuperChamber(p) >= min_n_layers) {
127  result.insert(p);
128  }
129  }
130  return result;
131 }
int nLayersWithHitsInSuperChamber(unsigned int) const
std::set< unsigned int > superChamberIds() const

Member Data Documentation

◆ detids_to_copads_

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

Definition at line 73 of file ME0SimHitMatcher.h.

◆ detids_to_pads_

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

Definition at line 70 of file ME0SimHitMatcher.h.

Referenced by hitPadsInDetId(), and matchSimHitsToSimTrack().

◆ geomToken_

edm::ESGetToken<ME0Geometry, MuonGeometryRecord> ME0SimHitMatcher::geomToken_
private

Definition at line 67 of file ME0SimHitMatcher.h.

Referenced by init(), and ME0SimHitMatcher().

◆ superChamber_to_hits_

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

Definition at line 75 of file ME0SimHitMatcher.h.

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