CMS 3D CMS Logo

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

#include <GEMRecHitMatcher.h>

Public Types

typedef matching::Digi RecHit
 
typedef matching::DigiContainer RecHitContainer
 

Public Member Functions

std::set< unsigned int > chamberIds () const
 
std::set< unsigned int > detIds () const
 
 GEMRecHitMatcher (const SimHitMatcher &sh, const edm::Event &, const GEMGeometry &geom, const edm::ParameterSet &cfg, edm::EDGetToken &)
 
int nLayersWithRecHitsInSuperChamber (unsigned int) const
 
int nRecHits () const
 How many recHits in GEM did this simtrack get in total? More...
 
std::set< int > partitionNumbers () const
 
GlobalPoint recHitMeanPosition (const RecHitContainer &rechits) const
 
GlobalPoint recHitPosition (const RecHit &rechit) const
 
const RecHitContainerrecHitsInChamber (unsigned int) const
 
const RecHitContainerrecHitsInDetId (unsigned int) const
 
const RecHitContainerrecHitsInSuperChamber (unsigned int) const
 
std::set< int > stripNumbersInDetId (unsigned int) const
 
std::set< unsigned int > superChamberIds () const
 
bool verbose () const
 
 ~GEMRecHitMatcher ()
 

Private Member Functions

void init (const edm::Event &)
 
void matchRecHitsToSimTrack (const GEMRecHitCollection &recHits)
 

Private Attributes

std::map< unsigned int, RecHitContainerchamber_to_recHits_
 
std::map< unsigned int, RecHitContainerdetid_to_recHits_
 
const GEMGeometrygem_geo_
 
edm::Handle< GEMRecHitCollectiongem_rechits_
 
int matchDeltaStrip_
 
int maxBXGEM_
 
int minBXGEM_
 
const RecHitContainer no_recHits_
 
const SimHitMatchersimhit_matcher_
 
std::map< unsigned int, RecHitContainersuperchamber_to_recHits_
 
bool verbose_
 

Detailed Description

Definition at line 39 of file GEMRecHitMatcher.h.

Member Typedef Documentation

Definition at line 41 of file GEMRecHitMatcher.h.

Definition at line 42 of file GEMRecHitMatcher.h.

Constructor & Destructor Documentation

GEMRecHitMatcher::GEMRecHitMatcher ( const SimHitMatcher sh,
const edm::Event e,
const GEMGeometry geom,
const edm::ParameterSet cfg,
edm::EDGetToken gem_recHitToken 
)

Definition at line 11 of file GEMRecHitMatcher.cc.

References gem_rechits_, edm::Event::getByToken(), edm::ParameterSet::getUntrackedParameter(), init(), matchDeltaStrip_, maxBXGEM_, minBXGEM_, and verbose_.

16  : simhit_matcher_(sh), gem_geo_(geom) {
17  minBXGEM_ = cfg.getUntrackedParameter<int>("minBXGEM", -1);
18  maxBXGEM_ = cfg.getUntrackedParameter<int>("maxBXGEM", 1);
19 
20  matchDeltaStrip_ = cfg.getUntrackedParameter<int>("matchDeltaStripGEM", 1);
21 
22  // setVerbose(cfg.getUntrackedParameter<int>("verboseGEMDigi", 0));
23  verbose_ = false;
24 
25  e.getByToken(gem_recHitToken, gem_rechits_);
26 
27  init(e);
28 }
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const SimHitMatcher & simhit_matcher_
void init(const edm::Event &)
edm::Handle< GEMRecHitCollection > gem_rechits_
const GEMGeometry & gem_geo_
GEMRecHitMatcher::~GEMRecHitMatcher ( )

Definition at line 30 of file GEMRecHitMatcher.cc.

30 {}

Member Function Documentation

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

Definition at line 87 of file GEMRecHitMatcher.cc.

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

Referenced by GEMRecHitTrackMatch::analyze().

87  {
88  std::set<unsigned int> result;
89  for (auto &p : chamber_to_recHits_)
90  result.insert(p.first);
91  return result;
92 }
std::map< unsigned int, RecHitContainer > chamber_to_recHits_
std::set< unsigned int > GEMRecHitMatcher::detIds ( void  ) const

Definition at line 80 of file GEMRecHitMatcher.cc.

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

Referenced by partitionNumbers().

80  {
81  std::set<unsigned int> result;
82  for (auto &p : detid_to_recHits_)
83  result.insert(p.first);
84  return result;
85 }
std::map< unsigned int, RecHitContainer > detid_to_recHits_
void GEMRecHitMatcher::init ( const edm::Event e)
private

Definition at line 32 of file GEMRecHitMatcher.cc.

References gem_rechits_, matchRecHitsToSimTrack(), and edm::Handle< T >::product().

Referenced by GEMRecHitMatcher(), and verbose().

void matchRecHitsToSimTrack(const GEMRecHitCollection &recHits)
T const * product() const
Definition: Handle.h:74
edm::Handle< GEMRecHitCollection > gem_rechits_
void GEMRecHitMatcher::matchRecHitsToSimTrack ( const GEMRecHitCollection recHits)
private

Definition at line 34 of file GEMRecHitMatcher.cc.

References GEMDetId::chamber(), chamber_to_recHits_, GEMDetId::chamberId(), popcon2dropbox::copy(), gather_cfg::cout, edmIntegrityCheck::d, detid_to_recHits_, SimHitMatcher::detIdsGEM(), matching::GEM_STRIP, SimHitMatcher::hitStripsInDetId(), mps_fire::i, triggerObjects_cff::id, matching::make_digi(), matchDeltaStrip_, maxBXGEM_, minBXGEM_, DetId::rawId(), GEMDetId::region(), GEMDetId::ring(), simhit_matcher_, GEMDetId::station(), superchamber_to_recHits_, and verbose().

Referenced by init(), and verbose().

34  {
35  auto det_ids = simhit_matcher_.detIdsGEM();
36  for (auto id : det_ids) {
37  GEMDetId p_id(id);
38  GEMDetId superch_id(p_id.region(), p_id.ring(), p_id.station(), 1, p_id.chamber(), 0);
39 
40  auto hit_strips = simhit_matcher_.hitStripsInDetId(id, matchDeltaStrip_);
41  if (verbose()) {
42  cout << "hit_strips_fat ";
43  copy(hit_strips.begin(), hit_strips.end(), ostream_iterator<int>(cout, " "));
44  cout << endl;
45  }
46 
47  auto rechits_in_det = rechits.get(GEMDetId(id));
48 
49  for (auto d = rechits_in_det.first; d != rechits_in_det.second; ++d) {
50  if (verbose())
51  cout << "recHit " << p_id << " " << *d << endl;
52  // check that the rechit is within BX range
53  if (d->BunchX() < minBXGEM_ || d->BunchX() > maxBXGEM_)
54  continue;
55  // check that it matches a strip that was hit by SimHits from our track
56 
57  int firstStrip = d->firstClusterStrip();
58  int cls = d->clusterSize();
59  bool stripFound = false;
60 
61  for (int i = firstStrip; i < (firstStrip + cls); i++) {
62  if (hit_strips.find(i) != hit_strips.end())
63  stripFound = true;
64  // std::cout<<i<<" "<<firstStrip<<" "<<cls<<" "<<stripFound<<std::endl;
65  }
66 
67  if (!stripFound)
68  continue;
69  if (verbose())
70  cout << "oki" << endl;
71 
72  auto myrechit = make_digi(id, d->firstClusterStrip(), d->BunchX(), GEM_STRIP, d->clusterSize());
73  detid_to_recHits_[id].push_back(myrechit);
74  chamber_to_recHits_[p_id.chamberId().rawId()].push_back(myrechit);
75  superchamber_to_recHits_[superch_id()].push_back(myrechit);
76  }
77  }
78 }
std::set< unsigned int > detIdsGEM() const
GEM partitions&#39; detIds with SimHits.
def copy(args, dbName)
std::map< unsigned int, RecHitContainer > detid_to_recHits_
std::set< int > hitStripsInDetId(unsigned int, int margin_n_strips=0) const
std::map< unsigned int, RecHitContainer > superchamber_to_recHits_
const SimHitMatcher & simhit_matcher_
std::map< unsigned int, RecHitContainer > chamber_to_recHits_
Digi make_digi()
Definition: GenericDigi.h:46
bool verbose() const
int GEMRecHitMatcher::nLayersWithRecHitsInSuperChamber ( unsigned int  detid) const

Definition at line 119 of file GEMRecHitMatcher.cc.

References LayerTriplets::layers().

119  {
120  set<int> layers;
121  /*
122  auto recHits = recHitsInSuperChamber(detid);
123  for (auto& d: recHits)
124  {
125  GEMDetId idd(digi_id(d));
126  layers.insert(idd.layer());
127  }
128  */
129  return layers.size();
130 }
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
int GEMRecHitMatcher::nRecHits ( ) const

How many recHits in GEM did this simtrack get in total?

std::set< int > GEMRecHitMatcher::partitionNumbers ( ) const

Definition at line 144 of file GEMRecHitMatcher.cc.

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

144  {
145  std::set<int> result;
146 
147  auto detids = detIds();
148  for (auto id : detids) {
149  GEMDetId idd(id);
150  result.insert(idd.roll());
151  }
152  return result;
153 }
std::set< unsigned int > detIds() const
GlobalPoint GEMRecHitMatcher::recHitMeanPosition ( const RecHitContainer rechits) const

Definition at line 170 of file GEMRecHitMatcher.cc.

References edmIntegrityCheck::d, runTauDisplay::gp, gen::n, recHitPosition(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by verbose().

170  {
171  GlobalPoint point_zero;
172  if (rechit.empty())
173  return point_zero; // point "zero"
174 
175  float sumx, sumy, sumz;
176  sumx = sumy = sumz = 0.f;
177  size_t n = 0;
178  for (auto &d : rechit) {
180  if (gp == point_zero)
181  continue;
182 
183  sumx += gp.x();
184  sumy += gp.y();
185  sumz += gp.z();
186  ++n;
187  }
188  if (n == 0)
189  return GlobalPoint();
190  return GlobalPoint(sumx / n, sumy / n, sumz / n);
191 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
GlobalPoint recHitPosition(const RecHit &rechit) const
T x() const
Definition: PV3DBase.h:62
GlobalPoint GEMRecHitMatcher::recHitPosition ( const RecHit rechit) const

Definition at line 155 of file GEMRecHitMatcher.cc.

References GEMEtaPartition::centreOfStrip(), matching::digi_channel(), matching::digi_id(), matching::digi_type(), GEMGeometry::etaPartition(), gem_geo_, matching::GEM_STRIP, runTauDisplay::gp, GEMGeometry::idToDet(), digitizers_cfi::strip, GeomDet::surface(), lumiQTWidget::t, and Surface::toGlobal().

Referenced by recHitMeanPosition(), and verbose().

155  {
156  unsigned int id = digi_id(rechit);
157  int strip = digi_channel(rechit);
158  DigiType t = digi_type(rechit);
159 
160  GlobalPoint gp;
161  if (t == GEM_STRIP) {
162  GEMDetId idd(id);
163  LocalPoint lp = gem_geo_.etaPartition(idd)->centreOfStrip(strip);
164  gp = gem_geo_.idToDet(id)->surface().toGlobal(lp);
165  }
166 
167  return gp;
168 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:99
DigiType digi_type(const Digi &d)
Definition: GenericDigi.h:69
LocalPoint centreOfStrip(int strip) const
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:38
int digi_channel(const Digi &d)
Definition: GenericDigi.h:67
const GEMGeometry & gem_geo_
unsigned int digi_id(const Digi &d)
Definition: GenericDigi.h:66
const GEMRecHitMatcher::RecHitContainer & GEMRecHitMatcher::recHitsInChamber ( unsigned int  detid) const

Definition at line 107 of file GEMRecHitMatcher.cc.

References chamber_to_recHits_, and no_recHits_.

107  {
108  if (chamber_to_recHits_.find(detid) == chamber_to_recHits_.end())
109  return no_recHits_;
110  return chamber_to_recHits_.at(detid);
111 }
const RecHitContainer no_recHits_
std::map< unsigned int, RecHitContainer > chamber_to_recHits_
const GEMRecHitMatcher::RecHitContainer & GEMRecHitMatcher::recHitsInDetId ( unsigned int  detid) const

Definition at line 101 of file GEMRecHitMatcher.cc.

References detid_to_recHits_, and no_recHits_.

101  {
102  if (detid_to_recHits_.find(detid) == detid_to_recHits_.end())
103  return no_recHits_;
104  return detid_to_recHits_.at(detid);
105 }
std::map< unsigned int, RecHitContainer > detid_to_recHits_
const RecHitContainer no_recHits_
const GEMRecHitMatcher::RecHitContainer & GEMRecHitMatcher::recHitsInSuperChamber ( unsigned int  detid) const

Definition at line 113 of file GEMRecHitMatcher.cc.

References no_recHits_, and superchamber_to_recHits_.

113  {
114  if (superchamber_to_recHits_.find(detid) == superchamber_to_recHits_.end())
115  return no_recHits_;
116  return superchamber_to_recHits_.at(detid);
117 }
const RecHitContainer no_recHits_
std::map< unsigned int, RecHitContainer > superchamber_to_recHits_
std::set< int > GEMRecHitMatcher::stripNumbersInDetId ( unsigned int  detid) const

Definition at line 132 of file GEMRecHitMatcher.cc.

References mps_fire::result.

132  {
133  set<int> result;
134  /*
135  auto recHits = recHitsInDetId(detid);
136  for (auto& d: recHits)
137  {
138  result.insert( digi_channel(d) );
139  }
140  */
141  return result;
142 }
std::set< unsigned int > GEMRecHitMatcher::superChamberIds ( ) const

Definition at line 94 of file GEMRecHitMatcher.cc.

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

94  {
95  std::set<unsigned int> result;
96  for (auto &p : superchamber_to_recHits_)
97  result.insert(p.first);
98  return result;
99 }
std::map< unsigned int, RecHitContainer > superchamber_to_recHits_
bool GEMRecHitMatcher::verbose ( ) const
inline

Member Data Documentation

std::map<unsigned int, RecHitContainer> GEMRecHitMatcher::chamber_to_recHits_
private

Definition at line 99 of file GEMRecHitMatcher.h.

Referenced by chamberIds(), matchRecHitsToSimTrack(), and recHitsInChamber().

std::map<unsigned int, RecHitContainer> GEMRecHitMatcher::detid_to_recHits_
private

Definition at line 98 of file GEMRecHitMatcher.h.

Referenced by detIds(), matchRecHitsToSimTrack(), and recHitsInDetId().

const GEMGeometry& GEMRecHitMatcher::gem_geo_
private

Definition at line 91 of file GEMRecHitMatcher.h.

Referenced by recHitPosition().

edm::Handle<GEMRecHitCollection> GEMRecHitMatcher::gem_rechits_
private

Definition at line 88 of file GEMRecHitMatcher.h.

Referenced by GEMRecHitMatcher(), and init().

int GEMRecHitMatcher::matchDeltaStrip_
private

Definition at line 96 of file GEMRecHitMatcher.h.

Referenced by GEMRecHitMatcher(), and matchRecHitsToSimTrack().

int GEMRecHitMatcher::maxBXGEM_
private

Definition at line 93 of file GEMRecHitMatcher.h.

Referenced by GEMRecHitMatcher(), and matchRecHitsToSimTrack().

int GEMRecHitMatcher::minBXGEM_
private

Definition at line 93 of file GEMRecHitMatcher.h.

Referenced by GEMRecHitMatcher(), and matchRecHitsToSimTrack().

const RecHitContainer GEMRecHitMatcher::no_recHits_
private

Definition at line 102 of file GEMRecHitMatcher.h.

Referenced by recHitsInChamber(), recHitsInDetId(), and recHitsInSuperChamber().

const SimHitMatcher& GEMRecHitMatcher::simhit_matcher_
private

Definition at line 90 of file GEMRecHitMatcher.h.

Referenced by matchRecHitsToSimTrack().

std::map<unsigned int, RecHitContainer> GEMRecHitMatcher::superchamber_to_recHits_
private
bool GEMRecHitMatcher::verbose_
private

Definition at line 94 of file GEMRecHitMatcher.h.

Referenced by GEMRecHitMatcher(), and verbose().