CMS 3D CMS Logo

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

#include <GE0SegAlgoRU.h>

Inheritance diagram for GE0SegAlgoRU:
GEMSegmentAlgorithmBase

Classes

struct  HitAndPosition
 
struct  SegmentParameters
 

Public Types

typedef std::vector< bool > BoolContainer
 
typedef std::vector< HitAndPositionHitAndPositionContainer
 
typedef std::vector< const HitAndPosition * > HitAndPositionPtrContainer
 
typedef std::vector< std::pair< float, HitAndPositionPtrContainer > > SegmentByMetricContainer
 
- Public Types inherited from GEMSegmentAlgorithmBase
typedef std::pair< const GEMSuperChamber *, std::map< uint32_t, const GEMEtaPartition * > > GEMEnsemble
 

Public Member Functions

 GE0SegAlgoRU (const edm::ParameterSet &ps)
 Constructor. More...
 
std::vector< GEMSegmentrun (const GEMEnsemble &ensemble, const std::vector< const GEMRecHit * > &rechits) override
 
std::vector< GEMSegmentrun (const GEMSuperChamber *chamber, const HitAndPositionContainer &rechits)
 
 ~GE0SegAlgoRU () override
 Destructor. More...
 
- Public Member Functions inherited from GEMSegmentAlgorithmBase
 GEMSegmentAlgorithmBase (const edm::ParameterSet &)
 Constructor. More...
 
virtual ~GEMSegmentAlgorithmBase ()
 Destructor. More...
 

Private Member Functions

std::unique_ptr< MuonSegFitaddHit (HitAndPositionPtrContainer &proto_segment, const HitAndPosition &aHit) const
 
void addUniqueSegments (SegmentByMetricContainer &proto_segments, std::vector< GEMSegment > &segments, BoolContainer &used) const
 
bool areHitsCloseInEta (const float maxETA, const bool beamConst, const GlobalPoint &h1, const GlobalPoint &h2) const
 
bool areHitsCloseInGlobalPhi (const float maxPHI, const unsigned int nLayDisp, const GlobalPoint &h1, const GlobalPoint &h2) const
 
void compareProtoSegment (std::unique_ptr< MuonSegFit > &current_fit, HitAndPositionPtrContainer &current_proto_segment, const HitAndPosition &new_hit) const
 
float getHitSegChi2 (const std::unique_ptr< MuonSegFit > &fit, const GEMRecHit &hit) const
 
GlobalPoint globalAtZ (const std::unique_ptr< MuonSegFit > &fit, float z) const
 
bool hasHitOnLayer (const HitAndPositionPtrContainer &proto_segment, const unsigned int layer) const
 
void increaseProtoSegment (const float maxChi2, std::unique_ptr< MuonSegFit > &current_fit, HitAndPositionPtrContainer &current_proto_segment, const HitAndPosition &new_hit) const
 
bool isHitNearSegment (const float maxETA, const float maxPHI, const std::unique_ptr< MuonSegFit > &fit, const HitAndPositionPtrContainer &proto_segment, const HitAndPosition &h) const
 
void lookForSegments (const SegmentParameters &params, const unsigned int n_seg_min, const HitAndPositionContainer &rechits, const std::vector< unsigned int > &recHits_per_layer, BoolContainer &used, std::vector< GEMSegment > &segments) const
 
std::unique_ptr< MuonSegFitmakeFit (const HitAndPositionPtrContainer &proto_segment) const
 
void pruneBadHits (const float maxChi2, HitAndPositionPtrContainer &proto_segment, std::unique_ptr< MuonSegFit > &fit, const unsigned int n_seg_min) const
 
void tryAddingHitsToSegment (const float maxETA, const float maxPhi, const float maxChi2, std::unique_ptr< MuonSegFit > &current_fit, HitAndPositionPtrContainer &proto_segment, const BoolContainer &used, HitAndPositionContainer::const_iterator i1, HitAndPositionContainer::const_iterator i2) const
 

Private Attributes

bool allowWideSegments
 
SegmentParameters displacedParameters
 
bool doCollisions
 
const std::string myName
 
SegmentParameters stdParameters
 
const GEMSuperChambertheChamber
 
SegmentParameters wideParameters
 

Detailed Description

adapted from CSC to ME0 bt Marcello Maggi and ME0 to GE0 by Ian J. Watson

This is the original algorithm for building endcap muon track segments out of the rechit's in a GE0Chamber 'RU' = 'RUssia' = Road Usage

A GEMSegment is a RecSegment4D, and is built from GEMRecHit2D objects, each of which is a RecHit2DLocalPos.

This class is used by the GEMSegmentAlgorithm.
Alternative algorithms can be used for the segment building by writing classes like this, and then selecting which one is actually used via the GEMSegmentBuilder.

developed and implemented by Vladimir Palichik Vladi.nosp@m.mir..nosp@m.Paltc.nosp@m.hik@.nosp@m.cern..nosp@m.ch and Nikolay Voytishin nikol.nosp@m.ay.v.nosp@m.oytis.nosp@m.hin@.nosp@m.cern..nosp@m.ch

Definition at line 32 of file GE0SegAlgoRU.h.

Member Typedef Documentation

◆ BoolContainer

typedef std::vector<bool> GE0SegAlgoRU::BoolContainer

Definition at line 62 of file GE0SegAlgoRU.h.

◆ HitAndPositionContainer

Definition at line 58 of file GE0SegAlgoRU.h.

◆ HitAndPositionPtrContainer

Definition at line 59 of file GE0SegAlgoRU.h.

◆ SegmentByMetricContainer

typedef std::vector<std::pair<float, HitAndPositionPtrContainer> > GE0SegAlgoRU::SegmentByMetricContainer

Definition at line 63 of file GE0SegAlgoRU.h.

Constructor & Destructor Documentation

◆ GE0SegAlgoRU()

GE0SegAlgoRU::GE0SegAlgoRU ( const edm::ParameterSet ps)
explicit

Constructor.

Definition at line 26 of file GE0SegAlgoRU.cc.

26  : GEMSegmentAlgorithmBase(ps), myName("GE0SegAlgoRU") {
27  allowWideSegments = ps.getParameter<bool>("allowWideSegments");
28  doCollisions = ps.getParameter<bool>("doCollisions");
29 
30  stdParameters.maxChi2Additional = ps.getParameter<double>("maxChi2Additional");
31  stdParameters.maxChi2Prune = ps.getParameter<double>("maxChi2Prune");
32  stdParameters.maxChi2GoodSeg = ps.getParameter<double>("maxChi2GoodSeg");
33  stdParameters.maxPhiSeeds = ps.getParameter<double>("maxPhiSeeds");
34  stdParameters.maxPhiAdditional = ps.getParameter<double>("maxPhiAdditional");
35  stdParameters.maxETASeeds = ps.getParameter<double>("maxETASeeds");
36  stdParameters.requireCentralBX = ps.getParameter<bool>("requireCentralBX");
37  stdParameters.minNumberOfHits = ps.getParameter<unsigned int>("minNumberOfHits");
38  stdParameters.maxNumberOfHits = ps.getParameter<unsigned int>("maxNumberOfHits");
39  stdParameters.maxNumberOfHitsPerLayer = ps.getParameter<unsigned int>("maxNumberOfHitsPerLayer");
41 
48 
57 
58  LogDebug("GE0SegAlgoRU") << myName << " has algorithm cuts set to: \n"
59  << "--------------------------------------------------------------------\n"
60  << "allowWideSegments = " << allowWideSegments << "\n"
61  << "doCollisions = " << doCollisions << "\n"
62  << "maxChi2Additional = " << stdParameters.maxChi2Additional << "\n"
63  << "maxChi2Prune = " << stdParameters.maxChi2Prune << "\n"
64  << "maxChi2GoodSeg = " << stdParameters.maxChi2GoodSeg << "\n"
65  << "maxPhiSeeds = " << stdParameters.maxPhiSeeds << "\n"
66  << "maxPhiAdditional = " << stdParameters.maxPhiAdditional << "\n"
67  << "maxETASeeds = " << stdParameters.maxETASeeds << "\n"
68  << std::endl;
69 
70  theChamber = nullptr;
71 }

References allowWideSegments, displacedParameters, doCollisions, edm::ParameterSet::getParameter(), LogDebug, GE0SegAlgoRU::SegmentParameters::maxChi2Additional, GE0SegAlgoRU::SegmentParameters::maxChi2GoodSeg, GE0SegAlgoRU::SegmentParameters::maxChi2Prune, GE0SegAlgoRU::SegmentParameters::maxETASeeds, GE0SegAlgoRU::SegmentParameters::maxNumberOfHits, GE0SegAlgoRU::SegmentParameters::maxNumberOfHitsPerLayer, GE0SegAlgoRU::SegmentParameters::maxPhiAdditional, GE0SegAlgoRU::SegmentParameters::maxPhiSeeds, GE0SegAlgoRU::SegmentParameters::minNumberOfHits, myName, GE0SegAlgoRU::SegmentParameters::requireBeamConstr, GE0SegAlgoRU::SegmentParameters::requireCentralBX, stdParameters, theChamber, and wideParameters.

◆ ~GE0SegAlgoRU()

GE0SegAlgoRU::~GE0SegAlgoRU ( )
inlineoverride

Destructor.

Definition at line 68 of file GE0SegAlgoRU.h.

68 {};

Member Function Documentation

◆ addHit()

std::unique_ptr< MuonSegFit > GE0SegAlgoRU::addHit ( HitAndPositionPtrContainer proto_segment,
const HitAndPosition aHit 
) const
private

Definition at line 430 of file GE0SegAlgoRU.cc.

431  {
432  proto_segment.push_back(&aHit);
433  // make a fit
434  return makeFit(proto_segment);
435 }

References makeFit().

Referenced by compareProtoSegment(), increaseProtoSegment(), and lookForSegments().

◆ addUniqueSegments()

void GE0SegAlgoRU::addUniqueSegments ( SegmentByMetricContainer proto_segments,
std::vector< GEMSegment > &  segments,
BoolContainer used 
) const
private

Definition at line 287 of file GE0SegAlgoRU.cc.

289  {
290  std::sort(proto_segments.begin(),
291  proto_segments.end(),
292  [](const std::pair<float, HitAndPositionPtrContainer>& a,
293  const std::pair<float, HitAndPositionPtrContainer>& b) { return a.first < b.first; });
294 
295  //Now add to the collect based on minChi2 marking the hits as used after
296  std::vector<unsigned int> usedHits;
297  for (auto& container : proto_segments) {
298  HitAndPositionPtrContainer currentProtoSegment = container.second;
299 
300  //check to see if we already used thes hits this round
301  bool alreadyFilled = false;
302  for (const auto& h : currentProtoSegment) {
303  for (unsigned int iOH = 0; iOH < usedHits.size(); ++iOH) {
304  if (usedHits[iOH] != h->idx)
305  continue;
306  alreadyFilled = true;
307  break;
308  }
309  }
310  if (alreadyFilled)
311  continue;
312  for (const auto* h : currentProtoSegment) {
313  usedHits.push_back(h->idx);
314  used[h->idx] = true;
315  }
316 
317  std::unique_ptr<MuonSegFit> current_fit = makeFit(currentProtoSegment);
318 
319  // Create an actual GEMSegment - retrieve all info from the fit
320  // calculate the timing fron rec hits associated to the TrackingRecHits used
321  // to fit the segment
322  float averageBX = 0.;
323  for (const auto* h : currentProtoSegment) {
324  averageBX += h->rh->BunchX();
325  }
326  averageBX /= int(currentProtoSegment.size());
327 
328  std::sort(currentProtoSegment.begin(),
329  currentProtoSegment.end(),
330  [](const HitAndPosition* a, const HitAndPosition* b) { return a->layer < b->layer; });
331 
332  std::vector<const GEMRecHit*> bareRHs;
333  bareRHs.reserve(currentProtoSegment.size());
334  for (const auto* rh : currentProtoSegment)
335  bareRHs.push_back(rh->rh);
336  const float dPhi = theChamber->computeDeltaPhi(current_fit->intercept(), current_fit->localdir());
337  GEMSegment temp(bareRHs,
338  current_fit->intercept(),
339  current_fit->localdir(),
340  current_fit->covarianceMatrix(),
341  current_fit->chi2(),
342  averageBX,
343  dPhi);
344  segments.push_back(temp);
345  }
346 }

References a, b, GEMSuperChamber::computeDeltaPhi(), HLT_FULL_cff::dPhi, createfilelist::int, makeFit(), jetUpdater_cfi::sort, groupFilesInBlocks::temp, and theChamber.

Referenced by lookForSegments().

◆ areHitsCloseInEta()

bool GE0SegAlgoRU::areHitsCloseInEta ( const float  maxETA,
const bool  beamConst,
const GlobalPoint h1,
const GlobalPoint h2 
) const
private

Definition at line 384 of file GE0SegAlgoRU.cc.

387  {
388  float diff = std::abs(h1.eta() - h2.eta());
389  edm::LogVerbatim("GE0SegAlgoRU") << "[GE0SegAlgoRU::areHitsCloseInEta] gp1 = " << h1 << " in eta part = " << h1.eta()
390  << " and gp2 = " << h2 << " in eta part = " << h2.eta() << " ==> dEta = " << diff
391  << " ==> return " << (diff < 0.1) << std::endl;
392  //temp for floating point comparision...maxEta is the difference between partitions, so x1.5 to take into account non-circle geom.
393  return (diff < std::max(maxETA, 0.01f));
394 }

References funct::abs(), change_name::diff, PV3DBase< T, PVType, FrameType >::eta(), f, SiStripPI::max, and HLT_FULL_cff::maxETA.

Referenced by lookForSegments().

◆ areHitsCloseInGlobalPhi()

bool GE0SegAlgoRU::areHitsCloseInGlobalPhi ( const float  maxPHI,
const unsigned int  nLayDisp,
const GlobalPoint h1,
const GlobalPoint h2 
) const
private

Definition at line 396 of file GE0SegAlgoRU.cc.

399  {
400  float dphi12 = deltaPhi(h1.barePhi(), h2.barePhi());
401  edm::LogVerbatim("GE0SegAlgoRU") << "[GE0SegAlgoRU::areHitsCloseInGlobalPhi] gp1 = " << h1 << " and gp2 = " << h2
402  << " ==> dPhi = " << dphi12 << " ==> return "
403  << (std::abs(dphi12) < std::max(maxPHI, 0.02f)) << std::endl;
404  return std::abs(dphi12) < std::max(maxPHI, float(float(nLayDisp) * 0.004));
405 }

References funct::abs(), PV3DBase< T, PVType, FrameType >::barePhi(), SiPixelRawToDigiRegional_cfi::deltaPhi, f, and SiStripPI::max.

Referenced by lookForSegments().

◆ compareProtoSegment()

void GE0SegAlgoRU::compareProtoSegment ( std::unique_ptr< MuonSegFit > &  current_fit,
HitAndPositionPtrContainer current_proto_segment,
const HitAndPosition new_hit 
) const
private

Definition at line 497 of file GE0SegAlgoRU.cc.

499  {
500  const HitAndPosition* old_hit = nullptr;
501  HitAndPositionPtrContainer new_proto_segment = current_proto_segment;
502 
503  for (auto it = new_proto_segment.begin(); it != new_proto_segment.end();) {
504  if ((*it)->layer == new_hit.layer) {
505  old_hit = *it;
506  it = new_proto_segment.erase(it);
507  } else {
508  ++it;
509  }
510  }
511  if (old_hit == nullptr)
512  return;
513  auto new_fit = addHit(new_proto_segment, new_hit);
514 
515  //If on the same strip but different BX choose the closest
516  bool useNew = false;
517  if (old_hit->lp == new_hit.lp) {
518  float avgbx = 0;
519  for (const auto* h : current_proto_segment)
520  if (old_hit != h)
521  avgbx += h->rh->BunchX();
522  avgbx /= float(current_proto_segment.size() - 1);
523  if (std::abs(avgbx - new_hit.rh->BunchX()) < std::abs(avgbx - old_hit->rh->BunchX()))
524  useNew = true;
525  } //otherwise base it on chi2
526  else if (new_fit->chi2() < current_fit->chi2())
527  useNew = true;
528 
529  if (useNew) {
530  current_proto_segment = new_proto_segment;
531  current_fit = std::move(new_fit);
532  }
533 }

References funct::abs(), addHit(), GEMRecHit::BunchX(), dqmMemoryStats::float, GE0SegAlgoRU::HitAndPosition::layer, GE0SegAlgoRU::HitAndPosition::lp, eostools::move(), and GE0SegAlgoRU::HitAndPosition::rh.

Referenced by tryAddingHitsToSegment().

◆ getHitSegChi2()

float GE0SegAlgoRU::getHitSegChi2 ( const std::unique_ptr< MuonSegFit > &  fit,
const GEMRecHit hit 
) const
private

Definition at line 474 of file GE0SegAlgoRU.cc.

474  {
475  const auto lp = hit.localPosition();
476  const auto le = hit.localPositionError();
477  const float du = fit->xdev(lp.x(), lp.z());
478  const float dv = fit->ydev(lp.y(), lp.z());
479 
480  ROOT::Math::SMatrix<double, 2, 2, ROOT::Math::MatRepSym<double, 2> > IC;
481  IC(0, 0) = le.xx();
482  IC(1, 0) = le.xy();
483  IC(1, 1) = le.yy();
484 
485  // Invert covariance matrix
486  IC.Invert();
487  return du * du * IC(0, 0) + 2. * du * dv * IC(0, 1) + dv * dv * IC(1, 1);
488 }

Referenced by pruneBadHits().

◆ globalAtZ()

GlobalPoint GE0SegAlgoRU::globalAtZ ( const std::unique_ptr< MuonSegFit > &  fit,
float  z 
) const
private

Definition at line 424 of file GE0SegAlgoRU.cc.

424  {
425  float x = fit->xfit(z);
426  float y = fit->yfit(z);
427  return theChamber->toGlobal(LocalPoint(x, y, z));
428 }

References theChamber, GeomDet::toGlobal(), x, y, and z.

Referenced by isHitNearSegment().

◆ hasHitOnLayer()

bool GE0SegAlgoRU::hasHitOnLayer ( const HitAndPositionPtrContainer proto_segment,
const unsigned int  layer 
) const
private

Definition at line 490 of file GE0SegAlgoRU.cc.

490  {
491  for (const auto* h : proto_segment)
492  if (h->layer == layer)
493  return true;
494  return false;
495 }

References phase1PixelTopology::layer.

Referenced by tryAddingHitsToSegment().

◆ increaseProtoSegment()

void GE0SegAlgoRU::increaseProtoSegment ( const float  maxChi2,
std::unique_ptr< MuonSegFit > &  current_fit,
HitAndPositionPtrContainer current_proto_segment,
const HitAndPosition new_hit 
) const
private

Definition at line 535 of file GE0SegAlgoRU.cc.

538  {
539  HitAndPositionPtrContainer new_proto_segment = current_proto_segment;
540  auto new_fit = addHit(new_proto_segment, new_hit);
541  if (new_fit->chi2() / new_fit->ndof() < maxChi2) {
542  current_proto_segment = new_proto_segment;
543  current_fit = std::move(new_fit);
544  }
545 }

References addHit(), beam_dqm_sourceclient-live_cfg::maxChi2, and eostools::move().

Referenced by tryAddingHitsToSegment().

◆ isHitNearSegment()

bool GE0SegAlgoRU::isHitNearSegment ( const float  maxETA,
const float  maxPHI,
const std::unique_ptr< MuonSegFit > &  fit,
const HitAndPositionPtrContainer proto_segment,
const HitAndPosition h 
) const
private

Definition at line 407 of file GE0SegAlgoRU.cc.

411  {
412  //Get average eta, based on the two seeds...asssumes that we have not started pruning yet!
413  const float avgETA = (proto_segment[1]->gp.eta() + proto_segment[0]->gp.eta()) / 2.;
414  if (std::abs(h.gp.eta() - avgETA) > std::max(maxETA, 0.01f))
415  return false;
416 
417  //Now check the dPhi based on the segment fit
418  GlobalPoint globIntercept = globalAtZ(fit, h.lp.z());
419  float dPhi = deltaPhi(h.gp.barePhi(), globIntercept.phi());
420  //check to see if it is inbetween the two rolls of the outer and inner hits
421  return (std::abs(dPhi) < std::max(maxPHI, 0.001f));
422 }

References funct::abs(), SiPixelRawToDigiRegional_cfi::deltaPhi, HLT_FULL_cff::dPhi, f, globalAtZ(), SiStripPI::max, HLT_FULL_cff::maxETA, and PV3DBase< T, PVType, FrameType >::phi().

Referenced by tryAddingHitsToSegment().

◆ lookForSegments()

void GE0SegAlgoRU::lookForSegments ( const SegmentParameters params,
const unsigned int  n_seg_min,
const HitAndPositionContainer rechits,
const std::vector< unsigned int > &  recHits_per_layer,
BoolContainer used,
std::vector< GEMSegment > &  segments 
) const
private

Definition at line 200 of file GE0SegAlgoRU.cc.

205  {
206  auto ib = rechits.begin();
207  auto ie = rechits.end();
208  std::vector<std::pair<float, HitAndPositionPtrContainer> > proto_segments;
209  // the first hit is taken from the back
210  for (auto i1 = ib; i1 != ie; ++i1) {
211  const auto& h1 = *i1;
212 
213  //skip if rh is used and the layer tat has big rh multiplicity(>25RHs)
214  if (used[h1.idx])
215  continue;
216  if (recHits_per_layer[h1.layer - 1] > params.maxNumberOfHitsPerLayer)
217  continue;
218 
219  // the second hit from the front
220  for (auto i2 = ie - 1; i2 != i1; --i2) {
221  const auto& h2 = *i2;
222 
223  //skip if rh is used and the layer tat has big rh multiplicity(>25RHs)
224  if (used[h2.idx])
225  continue;
226  if (recHits_per_layer[h2.layer - 1] > params.maxNumberOfHitsPerLayer)
227  continue;
228 
229  //Stop if the distance between layers is not large enough
230  if ((std::abs(int(h2.layer) - int(h1.layer)) + 1) < int(n_seg_min))
231  break;
232 
233  if (!areHitsCloseInEta(params.maxETASeeds, params.requireBeamConstr, h1.gp, h2.gp))
234  continue;
235  if (!areHitsCloseInGlobalPhi(params.maxPhiSeeds, std::abs(int(h2.layer) - int(h1.layer)), h1.gp, h2.gp))
236  continue;
237 
238  HitAndPositionPtrContainer current_proto_segment;
239  std::unique_ptr<MuonSegFit> current_fit;
240  current_fit = addHit(current_proto_segment, h1);
241  current_fit = addHit(current_proto_segment, h2);
242 
243  tryAddingHitsToSegment(params.maxETASeeds,
244  params.maxPhiAdditional,
245  params.maxChi2Additional,
246  current_fit,
247  current_proto_segment,
248  used,
249  i1,
250  i2);
251 
252  if (current_proto_segment.size() > n_seg_min)
253  pruneBadHits(params.maxChi2Prune, current_proto_segment, current_fit, n_seg_min);
254 
255  edm::LogVerbatim("GE0SegAlgoRU") << "[GE0SegAlgoRU::lookForSegments] # of hits in segment "
256  << current_proto_segment.size() << " min # " << n_seg_min << " => "
257  << (current_proto_segment.size() >= n_seg_min) << " chi2/ndof "
258  << current_fit->chi2() / current_fit->ndof() << " => "
259  << (current_fit->chi2() / current_fit->ndof() < params.maxChi2GoodSeg)
260  << std::endl;
261 
262  if (current_proto_segment.size() < n_seg_min)
263  continue;
264  const float current_metric = current_fit->chi2() / current_fit->ndof();
265  if (current_metric > params.maxChi2GoodSeg)
266  continue;
267 
268  if (params.requireCentralBX) {
269  int nCentral = 0;
270  int nNonCentral = 0;
271  for (const auto* rh : current_proto_segment) {
272  if (std::abs(rh->rh->BunchX()) < 2)
273  nCentral++;
274  else
275  nNonCentral++;
276  }
277  if (nNonCentral >= nCentral)
278  continue;
279  }
280 
281  proto_segments.emplace_back(current_metric, current_proto_segment);
282  }
283  }
284  addUniqueSegments(proto_segments, segments, used);
285 }

References funct::abs(), addHit(), addUniqueSegments(), areHitsCloseInEta(), areHitsCloseInGlobalPhi(), testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, cuy::ib, CalibrationSummaryClient_cfi::params, pruneBadHits(), HI_PhotonSkim_cff::rechits, and tryAddingHitsToSegment().

Referenced by run().

◆ makeFit()

std::unique_ptr< MuonSegFit > GE0SegAlgoRU::makeFit ( const HitAndPositionPtrContainer proto_segment) const
private

Definition at line 437 of file GE0SegAlgoRU.cc.

437  {
438  // for GE0 we take the gemrechit from the proto_segment we transform into Tracking Rechits
439  // the local rest frame is the GEMSuperChamber
441  for (const auto& rh : proto_segment) {
442  GEMRecHit* newRH = rh->rh->clone();
443  newRH->setPosition(rh->lp);
444  MuonSegFit::MuonRecHitPtr trkRecHit(newRH);
445  muonRecHits.push_back(trkRecHit);
446  }
447  auto currentFit = std::make_unique<MuonSegFit>(muonRecHits);
448  currentFit->fit();
449  return currentFit;
450 }

References GEMRecHit::clone(), and GEMRecHit::setPosition().

Referenced by addHit(), addUniqueSegments(), and pruneBadHits().

◆ pruneBadHits()

void GE0SegAlgoRU::pruneBadHits ( const float  maxChi2,
HitAndPositionPtrContainer proto_segment,
std::unique_ptr< MuonSegFit > &  fit,
const unsigned int  n_seg_min 
) const
private

Definition at line 452 of file GE0SegAlgoRU.cc.

455  {
456  while (proto_segment.size() > n_seg_min && fit->chi2() / fit->ndof() > maxChi2) {
457  float maxDev = -1;
458  HitAndPositionPtrContainer::iterator worstHit;
459  for (auto it = proto_segment.begin(); it != proto_segment.end(); ++it) {
460  const float dev = getHitSegChi2(fit, *(*it)->rh);
461  if (dev < maxDev)
462  continue;
463  maxDev = dev;
464  worstHit = it;
465  }
466  edm::LogVerbatim("GE0SegAlgoRU") << "[GE0SegAlgoRU::pruneBadHits] pruning one hit-> layer: " << (*worstHit)->layer
467  << " eta: " << (*worstHit)->gp.eta() << " phi: " << (*worstHit)->gp.phi()
468  << " old chi2/dof: " << fit->chi2() / fit->ndof() << std::endl;
469  proto_segment.erase(worstHit);
470  fit = makeFit(proto_segment);
471  }
472 }

References getHitSegChi2(), makeFit(), and beam_dqm_sourceclient-live_cfg::maxChi2.

Referenced by lookForSegments().

◆ run() [1/2]

std::vector< GEMSegment > GE0SegAlgoRU::run ( const GEMEnsemble ensemble,
const std::vector< const GEMRecHit * > &  rechits 
)
overridevirtual

Run the algorithm = build the segments in this chamber

Implements GEMSegmentAlgorithmBase.

Definition at line 73 of file GE0SegAlgoRU.cc.

73  {
74  HitAndPositionContainer hitAndPositions;
75  auto& superchamber = ensemble.first;
76  for (const auto& rechit : rechits) {
77  const GEMEtaPartition* part = ensemble.second.at(rechit->gemId().rawId());
78  GlobalPoint glb = part->toGlobal(rechit->localPosition());
79  LocalPoint nLoc = superchamber->toLocal(glb);
80  hitAndPositions.emplace_back(&(*rechit), nLoc, glb, hitAndPositions.size());
81  }
82 
83  LogDebug("GE0Segment|GE0") << "found " << hitAndPositions.size() << " rechits in superchamber " << superchamber->id();
84  //sort by layer
85  float z1 = superchamber->chamber(1)->position().z();
86  float zlast = superchamber->chamber(superchamber->nChambers())->position().z();
87  if (z1 < zlast)
88  std::sort(hitAndPositions.begin(), hitAndPositions.end(), [](const HitAndPosition& h1, const HitAndPosition& h2) {
89  return h1.layer < h2.layer;
90  });
91  else
92  std::sort(hitAndPositions.begin(), hitAndPositions.end(), [](const HitAndPosition& h1, const HitAndPosition& h2) {
93  return h1.layer > h2.layer;
94  });
95  return run(ensemble.first, hitAndPositions);
96 }

References glb, GE0SegAlgoRU::HitAndPosition::layer, LogDebug, position, HI_PhotonSkim_cff::rechits, run(), and jetUpdater_cfi::sort.

◆ run() [2/2]

std::vector< GEMSegment > GE0SegAlgoRU::run ( const GEMSuperChamber chamber,
const HitAndPositionContainer rechits 
)

Here we must implement the algorithm

Definition at line 98 of file GE0SegAlgoRU.cc.

98  {
99 #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
100  GEMDetId chId(chamber->id());
101  edm::LogVerbatim("GE0SegAlgoRU") << "[GEMSegmentAlgorithm::run] build segments in chamber " << chId
102  << " which contains " << rechits.size() << " rechits";
103  for (const auto& h : rechits) {
104  auto ge0id = h.rh->gemId();
105  auto rhLP = h.lp;
106  edm::LogVerbatim("GE0SegAlgoRU") << "[RecHit :: Loc x = " << std::showpos << std::setw(9) << rhLP.x()
107  << " Glb y = " << std::showpos << std::setw(9) << rhLP.y()
108  << " Time = " << std::showpos << h.rh->BunchX() << " -- " << ge0id.rawId() << " = "
109  << ge0id << " ]" << std::endl;
110  }
111 #endif
112 
114  return std::vector<GEMSegment>();
115  }
116 
118 
119  std::vector<unsigned int> recHits_per_layer(theChamber->nChambers(), 0);
120  for (const auto& rechit : rechits) {
121  recHits_per_layer[rechit.layer - 1]++;
122  }
123 
124  BoolContainer used(rechits.size(), false);
125 
126  // We have at least 2 hits. We intend to try all possible pairs of hits to start
127  // segment building. 'All possible' means each hit lies on different layers in the chamber.
128  // after all same size segs are build we get rid of the overcrossed segments using the chi2 criteria
129  // the hits from the segs that are left are marked as used and are not added to segs in future iterations
130  // the hits from 3p segs are marked as used separately in order to try to assamble them in longer segments
131  // in case there is a second pass
132 
133  // Choose first hit (as close to IP as possible) h1 and second hit
134  // (as far from IP as possible) h2 To do this we iterate over hits
135  // in the chamber by layer - pick two layers. Then we
136  // iterate over hits within each of these layers and pick h1 and h2
137  // these. If they are 'close enough' we build an empty
138  // segment. Then try adding hits to this segment.
139 
140  std::vector<GEMSegment> segments;
141 
142  auto doStd = [&]() {
143  for (unsigned int n_seg_min = 6u; n_seg_min >= stdParameters.minNumberOfHits; --n_seg_min)
144  lookForSegments(stdParameters, n_seg_min, rechits, recHits_per_layer, used, segments);
145  };
146  auto doDisplaced = [&]() {
147  for (unsigned int n_seg_min = 6u; n_seg_min >= displacedParameters.minNumberOfHits; --n_seg_min)
148  lookForSegments(displacedParameters, n_seg_min, rechits, recHits_per_layer, used, segments);
149  };
150  // Not currently used
151  // auto doWide = [&] () {
152  // for(unsigned int n_seg_min = 6u; n_seg_min >= wideParameters.minNumberOfHits; --n_seg_min)
153  // lookForSegments(wideParameters,n_seg_min,rechits,recHits_per_layer, used,segments);
154  // };
155  auto printSegments = [&] {
156 #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
157  for (const auto& seg : segments) {
158  GEMDetId chId(seg.gemDetId());
159  const auto& rechits = seg.specificRecHits();
160  edm::LogVerbatim("GE0SegAlgoRU") << "[GE0SegAlgoRU] segment in chamber " << chId << " which contains "
161  << rechits.size() << " rechits and with specs: \n"
162  << seg;
163  for (const auto& rh : rechits) {
164  auto ge0id = rh.gemId();
165  edm::LogVerbatim("GE0SegAlgoRU") << "[RecHit :: Loc x = " << std::showpos << std::setw(9)
166  << rh.localPosition().x() << " Loc y = " << std::showpos << std::setw(9)
167  << rh.localPosition().y() << " Time = " << std::showpos << rh.BunchX()
168  << " -- " << ge0id.rawId() << " = " << ge0id << " ]";
169  }
170  }
171 #endif
172  };
173 
174  //If we arent doing collisions, do a single iteration
175  if (!doCollisions) {
176  doDisplaced();
177  printSegments();
178  return segments;
179  }
180 
181  //Iteration 1: STD processing
182  doStd();
183 
184  if (false) {
185  //How the CSC algorithm ~does iterations. for now not considering
186  //displaced muons will not worry about it later
187  //Iteration 2a: If we don't allow wide segments simply do displaced
188  // Or if we already found a segment simply skip to displaced
189  if (!allowWideSegments || !segments.empty()) {
190  doDisplaced();
191  return segments;
192  }
193  //doWide();
194  doDisplaced();
195  }
196  printSegments();
197  return segments;
198 }

References allowWideSegments, relativeConstraints::chamber, displacedParameters, doCollisions, lookForSegments(), GE0SegAlgoRU::SegmentParameters::maxNumberOfHits, GE0SegAlgoRU::SegmentParameters::minNumberOfHits, GEMSuperChamber::nChambers(), HI_PhotonSkim_cff::rechits, stdParameters, and theChamber.

Referenced by run().

◆ tryAddingHitsToSegment()

void GE0SegAlgoRU::tryAddingHitsToSegment ( const float  maxETA,
const float  maxPhi,
const float  maxChi2,
std::unique_ptr< MuonSegFit > &  current_fit,
HitAndPositionPtrContainer proto_segment,
const BoolContainer used,
HitAndPositionContainer::const_iterator  i1,
HitAndPositionContainer::const_iterator  i2 
) const
private

Definition at line 348 of file GE0SegAlgoRU.cc.

355  {
356  // Iterate over the layers with hits in the chamber
357  // Skip the layers containing the segment endpoints
358  // Test each hit on the other layers to see if it is near the segment
359  // If it is, see whether there is already a hit on the segment from the same layer
360  // - if so, and there are more than 2 hits on the segment, copy the segment,
361  // replace the old hit with the new hit. If the new segment chi2 is better
362  // then replace the original segment with the new one (by swap)
363  // - if not, copy the segment, add the hit. If the new chi2/dof is still satisfactory
364  // then replace the original segment with the new one (by swap)
365 
366  //Hits are ordered by layer, "i1" is the inner hit and i2 is the outer hit
367  //so possible hits to add must be between these two iterators
368  for (auto iH = i1 + 1; iH != i2; ++iH) {
369  if (iH->layer == i1->layer)
370  continue;
371  if (iH->layer == i2->layer)
372  break;
373  if (used[iH->idx])
374  continue;
375  if (!isHitNearSegment(maxETA, maxPhi, current_fit, proto_segment, *iH))
376  continue;
377  if (hasHitOnLayer(proto_segment, iH->layer))
378  compareProtoSegment(current_fit, proto_segment, *iH);
379  else
380  increaseProtoSegment(maxChi2, current_fit, proto_segment, *iH);
381  }
382 }

References compareProtoSegment(), hasHitOnLayer(), testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, increaseProtoSegment(), isHitNearSegment(), beam_dqm_sourceclient-live_cfg::maxChi2, HLT_FULL_cff::maxETA, and HLT_FULL_cff::maxPhi.

Referenced by lookForSegments().

Member Data Documentation

◆ allowWideSegments

bool GE0SegAlgoRU::allowWideSegments
private

Definition at line 143 of file GE0SegAlgoRU.h.

Referenced by GE0SegAlgoRU(), and run().

◆ displacedParameters

SegmentParameters GE0SegAlgoRU::displacedParameters
private

Definition at line 146 of file GE0SegAlgoRU.h.

Referenced by GE0SegAlgoRU(), and run().

◆ doCollisions

bool GE0SegAlgoRU::doCollisions
private

Definition at line 142 of file GE0SegAlgoRU.h.

Referenced by GE0SegAlgoRU(), and run().

◆ myName

const std::string GE0SegAlgoRU::myName
private

Definition at line 141 of file GE0SegAlgoRU.h.

Referenced by GE0SegAlgoRU().

◆ stdParameters

SegmentParameters GE0SegAlgoRU::stdParameters
private

Definition at line 145 of file GE0SegAlgoRU.h.

Referenced by GE0SegAlgoRU(), and run().

◆ theChamber

const GEMSuperChamber* GE0SegAlgoRU::theChamber
private

Definition at line 150 of file GE0SegAlgoRU.h.

Referenced by addUniqueSegments(), GE0SegAlgoRU(), globalAtZ(), and run().

◆ wideParameters

SegmentParameters GE0SegAlgoRU::wideParameters
private

Definition at line 147 of file GE0SegAlgoRU.h.

Referenced by GE0SegAlgoRU().

change_name.diff
diff
Definition: change_name.py:13
DDAxes::y
GE0SegAlgoRU::SegmentParameters::maxChi2Prune
float maxChi2Prune
Definition: GE0SegAlgoRU.h:39
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
GE0SegAlgoRU::compareProtoSegment
void compareProtoSegment(std::unique_ptr< MuonSegFit > &current_fit, HitAndPositionPtrContainer &current_proto_segment, const HitAndPosition &new_hit) const
Definition: GE0SegAlgoRU.cc:497
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
GE0SegAlgoRU::myName
const std::string myName
Definition: GE0SegAlgoRU.h:141
GE0SegAlgoRU::HitAndPositionContainer
std::vector< HitAndPosition > HitAndPositionContainer
Definition: GE0SegAlgoRU.h:58
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
GE0SegAlgoRU::isHitNearSegment
bool isHitNearSegment(const float maxETA, const float maxPHI, const std::unique_ptr< MuonSegFit > &fit, const HitAndPositionPtrContainer &proto_segment, const HitAndPosition &h) const
Definition: GE0SegAlgoRU.cc:407
GE0SegAlgoRU::SegmentParameters::minNumberOfHits
unsigned int minNumberOfHits
Definition: GE0SegAlgoRU.h:42
GE0SegAlgoRU::areHitsCloseInGlobalPhi
bool areHitsCloseInGlobalPhi(const float maxPHI, const unsigned int nLayDisp, const GlobalPoint &h1, const GlobalPoint &h2) const
Definition: GE0SegAlgoRU.cc:396
MuonSegFit::MuonRecHitContainer
std::vector< MuonRecHitPtr > MuonRecHitContainer
Definition: MuonSegFit.h:39
GE0SegAlgoRU::addUniqueSegments
void addUniqueSegments(SegmentByMetricContainer &proto_segments, std::vector< GEMSegment > &segments, BoolContainer &used) const
Definition: GE0SegAlgoRU.cc:287
GEMEtaPartition
Definition: GEMEtaPartition.h:12
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
beam_dqm_sourceclient-live_cfg.maxChi2
maxChi2
Definition: beam_dqm_sourceclient-live_cfg.py:147
GEMSuperChamber::nChambers
int nChambers() const
Return numbers of chambers.
Definition: GEMSuperChamber.cc:25
DDAxes::x
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
HLT_FULL_cff.dPhi
dPhi
Definition: HLT_FULL_cff.py:13695
GE0SegAlgoRU::SegmentParameters::maxPhiSeeds
float maxPhiSeeds
Definition: GE0SegAlgoRU.h:36
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
GEMRecHit::clone
GEMRecHit * clone() const override
Definition: GEMRecHit.cc:58
GE0SegAlgoRU::hasHitOnLayer
bool hasHitOnLayer(const HitAndPositionPtrContainer &proto_segment, const unsigned int layer) const
Definition: GE0SegAlgoRU.cc:490
GE0SegAlgoRU::wideParameters
SegmentParameters wideParameters
Definition: GE0SegAlgoRU.h:147
GE0SegAlgoRU::doCollisions
bool doCollisions
Definition: GE0SegAlgoRU.h:142
GEMSuperChamber::computeDeltaPhi
float computeDeltaPhi(const LocalPoint &position, const LocalVector &direction) const
Definition: GEMSuperChamber.cc:41
HLT_FULL_cff.maxPhi
maxPhi
Definition: HLT_FULL_cff.py:52995
GE0SegAlgoRU::displacedParameters
SegmentParameters displacedParameters
Definition: GE0SegAlgoRU.h:146
part
part
Definition: HCALResponse.h:20
GE0SegAlgoRU::lookForSegments
void lookForSegments(const SegmentParameters &params, const unsigned int n_seg_min, const HitAndPositionContainer &rechits, const std::vector< unsigned int > &recHits_per_layer, BoolContainer &used, std::vector< GEMSegment > &segments) const
Definition: GE0SegAlgoRU.cc:200
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
GEMSegmentAlgorithmBase::GEMSegmentAlgorithmBase
GEMSegmentAlgorithmBase(const edm::ParameterSet &)
Constructor.
Definition: GEMSegmentAlgorithmBase.h:28
GE0SegAlgoRU::makeFit
std::unique_ptr< MuonSegFit > makeFit(const HitAndPositionPtrContainer &proto_segment) const
Definition: GE0SegAlgoRU.cc:437
GE0SegAlgoRU::SegmentParameters::maxETASeeds
float maxETASeeds
Definition: GE0SegAlgoRU.h:35
DDAxes::z
GE0SegAlgoRU::addHit
std::unique_ptr< MuonSegFit > addHit(HitAndPositionPtrContainer &proto_segment, const HitAndPosition &aHit) const
Definition: GE0SegAlgoRU.cc:430
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
h
Point3DBase< float, GlobalTag >
b
double b
Definition: hdecay.h:118
GE0SegAlgoRU::globalAtZ
GlobalPoint globalAtZ(const std::unique_ptr< MuonSegFit > &fit, float z) const
Definition: GE0SegAlgoRU.cc:424
GE0SegAlgoRU::pruneBadHits
void pruneBadHits(const float maxChi2, HitAndPositionPtrContainer &proto_segment, std::unique_ptr< MuonSegFit > &fit, const unsigned int n_seg_min) const
Definition: GE0SegAlgoRU.cc:452
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
GE0SegAlgoRU::increaseProtoSegment
void increaseProtoSegment(const float maxChi2, std::unique_ptr< MuonSegFit > &current_fit, HitAndPositionPtrContainer &current_proto_segment, const HitAndPosition &new_hit) const
Definition: GE0SegAlgoRU.cc:535
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
a
double a
Definition: hdecay.h:119
MuonSegFit::MuonRecHitPtr
std::shared_ptr< TrackingRecHit > MuonRecHitPtr
Definition: MuonSegFit.h:38
GE0SegAlgoRU::HitAndPositionPtrContainer
std::vector< const HitAndPosition * > HitAndPositionPtrContainer
Definition: GE0SegAlgoRU.h:59
GE0SegAlgoRU::SegmentParameters::maxPhiAdditional
float maxPhiAdditional
Definition: GE0SegAlgoRU.h:37
PV3DBase::barePhi
T barePhi() const
Definition: PV3DBase.h:65
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
GE0SegAlgoRU::SegmentParameters::maxChi2Additional
float maxChi2Additional
Definition: GE0SegAlgoRU.h:38
GEMDetId
Definition: GEMDetId.h:18
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
createfilelist.int
int
Definition: createfilelist.py:10
GE0SegAlgoRU::SegmentParameters::maxChi2GoodSeg
float maxChi2GoodSeg
Definition: GE0SegAlgoRU.h:40
cuy.ib
ib
Definition: cuy.py:661
GE0SegAlgoRU::allowWideSegments
bool allowWideSegments
Definition: GE0SegAlgoRU.h:143
GE0SegAlgoRU::BoolContainer
std::vector< bool > BoolContainer
Definition: GE0SegAlgoRU.h:62
GEMSegment
Definition: GEMSegment.h:19
GE0SegAlgoRU::tryAddingHitsToSegment
void tryAddingHitsToSegment(const float maxETA, const float maxPhi, const float maxChi2, std::unique_ptr< MuonSegFit > &current_fit, HitAndPositionPtrContainer &proto_segment, const BoolContainer &used, HitAndPositionContainer::const_iterator i1, HitAndPositionContainer::const_iterator i2) const
Definition: GE0SegAlgoRU.cc:348
GE0SegAlgoRU::SegmentParameters::maxNumberOfHits
unsigned int maxNumberOfHits
Definition: GE0SegAlgoRU.h:43
GE0SegAlgoRU::SegmentParameters::maxNumberOfHitsPerLayer
unsigned int maxNumberOfHitsPerLayer
Definition: GE0SegAlgoRU.h:44
GE0SegAlgoRU::SegmentParameters::requireBeamConstr
bool requireBeamConstr
Definition: GE0SegAlgoRU.h:45
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
GE0SegAlgoRU::stdParameters
SegmentParameters stdParameters
Definition: GE0SegAlgoRU.h:145
GE0SegAlgoRU::SegmentParameters::requireCentralBX
bool requireCentralBX
Definition: GE0SegAlgoRU.h:41
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
GEMRecHit
Definition: GEMRecHit.h:14
GE0SegAlgoRU::getHitSegChi2
float getHitSegChi2(const std::unique_ptr< MuonSegFit > &fit, const GEMRecHit &hit) const
Definition: GE0SegAlgoRU.cc:474
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GEMRecHit::setPosition
void setPosition(LocalPoint pos)
Set local position.
Definition: GEMRecHit.h:53
GE0SegAlgoRU::areHitsCloseInEta
bool areHitsCloseInEta(const float maxETA, const bool beamConst, const GlobalPoint &h1, const GlobalPoint &h2) const
Definition: GE0SegAlgoRU.cc:384
glb
double glb
Definition: hdecay.h:103
GE0SegAlgoRU::run
std::vector< GEMSegment > run(const GEMSuperChamber *chamber, const HitAndPositionContainer &rechits)
Definition: GE0SegAlgoRU.cc:98
GE0SegAlgoRU::theChamber
const GEMSuperChamber * theChamber
Definition: GE0SegAlgoRU.h:150
fit
Definition: CombinedChiSquaredLikelihood.h:6
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
HLT_FULL_cff.maxETA
maxETA
Definition: HLT_FULL_cff.py:50885
hit
Definition: SiStripHitEffFromCalibTree.cc:88