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 42 of file GEMRecHitMatcher.h.

Member Typedef Documentation

Definition at line 46 of file GEMRecHitMatcher.h.

Definition at line 47 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_.

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

Definition at line 28 of file GEMRecHitMatcher.cc.

28 {}

Member Function Documentation

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

Definition at line 100 of file GEMRecHitMatcher.cc.

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

Referenced by GEMRecHitTrackMatch::analyze().

101 {
102  std::set<unsigned int> result;
103  for (auto& p: chamber_to_recHits_) result.insert(p.first);
104  return result;
105 }
std::map< unsigned int, RecHitContainer > chamber_to_recHits_
std::set< unsigned int > GEMRecHitMatcher::detIds ( void  ) const

Definition at line 91 of file GEMRecHitMatcher.cc.

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

Referenced by partitionNumbers().

92 {
93  std::set<unsigned int> result;
94  for (auto& p: detid_to_recHits_) result.insert(p.first);
95  return result;
96 }
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().

33 {
35 }
void matchRecHitsToSimTrack(const GEMRecHitCollection &recHits)
T const * product() const
Definition: Handle.h:81
edm::Handle< GEMRecHitCollection > gem_rechits_
void GEMRecHitMatcher::matchRecHitsToSimTrack ( const GEMRecHitCollection recHits)
private

Definition at line 39 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().

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

Definition at line 138 of file GEMRecHitMatcher.cc.

References LayerTriplets::layers().

139 {
140  set<int> layers;
141  /*
142  auto recHits = recHitsInSuperChamber(detid);
143  for (auto& d: recHits)
144  {
145  GEMDetId idd(digi_id(d));
146  layers.insert(idd.layer());
147  }
148  */
149  return layers.size();
150 }
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 168 of file GEMRecHitMatcher.cc.

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

169 {
170  std::set<int> result;
171 
172  auto detids = detIds();
173  for (auto id: detids)
174  {
175  GEMDetId idd(id);
176  result.insert( idd.roll() );
177  }
178  return result;
179 }
std::set< unsigned int > detIds() const
GlobalPoint GEMRecHitMatcher::recHitMeanPosition ( const RecHitContainer rechits) const

Definition at line 201 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().

202 {
203  GlobalPoint point_zero;
204  if (rechit.empty()) return point_zero; // point "zero"
205 
206  float sumx, sumy, sumz;
207  sumx = sumy = sumz = 0.f;
208  size_t n = 0;
209  for (auto& d: rechit)
210  {
212  if (gp == point_zero) continue;
213 
214  sumx += gp.x();
215  sumy += gp.y();
216  sumz += gp.z();
217  ++n;
218  }
219  if (n == 0) return GlobalPoint();
220  return GlobalPoint(sumx/n, sumy/n, sumz/n);
221 }
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 182 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().

183 {
184  unsigned int id = digi_id(rechit);
185  int strip = digi_channel(rechit);
186  DigiType t = digi_type(rechit);
187 
188  GlobalPoint gp;
189  if ( t == GEM_STRIP )
190  {
191  GEMDetId idd(id);
192  LocalPoint lp = gem_geo_.etaPartition(idd)->centreOfStrip(strip);
193  gp = gem_geo_.idToDet(id)->surface().toGlobal(lp);
194  }
195 
196  return gp;
197 }
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:49
LocalPoint centreOfStrip(int strip) const
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:38
int digi_channel(const Digi &d)
Definition: GenericDigi.h:47
const GEMGeometry & gem_geo_
unsigned int digi_id(const Digi &d)
Definition: GenericDigi.h:46
const GEMRecHitMatcher::RecHitContainer & GEMRecHitMatcher::recHitsInChamber ( unsigned int  detid) const

Definition at line 124 of file GEMRecHitMatcher.cc.

References chamber_to_recHits_, and no_recHits_.

125 {
126  if (chamber_to_recHits_.find(detid) == chamber_to_recHits_.end()) return no_recHits_;
127  return chamber_to_recHits_.at(detid);
128 }
const RecHitContainer no_recHits_
std::map< unsigned int, RecHitContainer > chamber_to_recHits_
const GEMRecHitMatcher::RecHitContainer & GEMRecHitMatcher::recHitsInDetId ( unsigned int  detid) const

Definition at line 117 of file GEMRecHitMatcher.cc.

References detid_to_recHits_, and no_recHits_.

118 {
119  if (detid_to_recHits_.find(detid) == detid_to_recHits_.end()) return no_recHits_;
120  return detid_to_recHits_.at(detid);
121 }
std::map< unsigned int, RecHitContainer > detid_to_recHits_
const RecHitContainer no_recHits_
const GEMRecHitMatcher::RecHitContainer & GEMRecHitMatcher::recHitsInSuperChamber ( unsigned int  detid) const

Definition at line 131 of file GEMRecHitMatcher.cc.

References no_recHits_, and superchamber_to_recHits_.

132 {
133  if (superchamber_to_recHits_.find(detid) == superchamber_to_recHits_.end()) return no_recHits_;
134  return superchamber_to_recHits_.at(detid);
135 }
const RecHitContainer no_recHits_
std::map< unsigned int, RecHitContainer > superchamber_to_recHits_
std::set< int > GEMRecHitMatcher::stripNumbersInDetId ( unsigned int  detid) const

Definition at line 154 of file GEMRecHitMatcher.cc.

References mps_fire::result.

155 {
156  set<int> result;
157  /*
158  auto recHits = recHitsInDetId(detid);
159  for (auto& d: recHits)
160  {
161  result.insert( digi_channel(d) );
162  }
163  */
164  return result;
165 }
std::set< unsigned int > GEMRecHitMatcher::superChamberIds ( ) const

Definition at line 108 of file GEMRecHitMatcher.cc.

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

109 {
110  std::set<unsigned int> result;
111  for (auto& p: superchamber_to_recHits_) result.insert(p.first);
112  return result;
113 }
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 101 of file GEMRecHitMatcher.h.

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

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

Definition at line 100 of file GEMRecHitMatcher.h.

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

const GEMGeometry& GEMRecHitMatcher::gem_geo_
private

Definition at line 93 of file GEMRecHitMatcher.h.

Referenced by recHitPosition().

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

Definition at line 90 of file GEMRecHitMatcher.h.

Referenced by GEMRecHitMatcher(), and init().

int GEMRecHitMatcher::matchDeltaStrip_
private

Definition at line 98 of file GEMRecHitMatcher.h.

Referenced by GEMRecHitMatcher(), and matchRecHitsToSimTrack().

int GEMRecHitMatcher::maxBXGEM_
private

Definition at line 95 of file GEMRecHitMatcher.h.

Referenced by GEMRecHitMatcher(), and matchRecHitsToSimTrack().

int GEMRecHitMatcher::minBXGEM_
private

Definition at line 95 of file GEMRecHitMatcher.h.

Referenced by GEMRecHitMatcher(), and matchRecHitsToSimTrack().

const RecHitContainer GEMRecHitMatcher::no_recHits_
private

Definition at line 104 of file GEMRecHitMatcher.h.

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

const SimHitMatcher& GEMRecHitMatcher::simhit_matcher_
private

Definition at line 92 of file GEMRecHitMatcher.h.

Referenced by matchRecHitsToSimTrack().

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

Definition at line 96 of file GEMRecHitMatcher.h.

Referenced by GEMRecHitMatcher(), and verbose().