CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
CSCSegAlgoSK Class Reference

#include <CSCSegAlgoSK.h>

Inheritance diagram for CSCSegAlgoSK:
CSCSegmentAlgorithm

Public Types

typedef std::deque< bool > BoolContainer
 
typedef std::vector< const
CSCRecHit2D * > 
ChamberHitContainer
 
typedef std::vector< const
CSCRecHit2D * >
::const_iterator 
ChamberHitContainerCIt
 
typedef std::vector< int > LayerIndex
 Typedefs. More...
 

Public Member Functions

std::vector< CSCSegmentbuildSegments (const ChamberHitContainer &rechits)
 
 CSCSegAlgoSK (const edm::ParameterSet &ps)
 Constructor. More...
 
std::vector< CSCSegmentrun (const CSCChamber *aChamber, const ChamberHitContainer &rechits) override
 
 ~CSCSegAlgoSK () override
 Destructor. More...
 
- Public Member Functions inherited from CSCSegmentAlgorithm
 CSCSegmentAlgorithm (const edm::ParameterSet &)
 Constructor. More...
 
virtual std::vector< CSCSegmentrun (const CSCChamber *chamber, const std::vector< const CSCRecHit2D * > &rechits)=0
 
virtual ~CSCSegmentAlgorithm ()
 Destructor. More...
 

Private Member Functions

bool addHit (const CSCRecHit2D *hit, int layer)
 Utility functions. More...
 
bool areHitsCloseInGlobalPhi (const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
 
bool areHitsCloseInLocalX (const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
 Utility functions. More...
 
void compareProtoSegment (const CSCRecHit2D *h, int layer)
 
void dumpHits (const ChamberHitContainer &rechits) const
 
void dumpSegment (const CSCSegment &seg) const
 
void flagHitsAsUsed (const ChamberHitContainer &rechitsInChamber, BoolContainer &used) const
 
bool hasHitOnLayer (int layer) const
 
void increaseProtoSegment (const CSCRecHit2D *h, int layer)
 
bool isHitNearSegment (const CSCRecHit2D *h) const
 
bool isSegmentGood (const ChamberHitContainer &rechitsInChamber) const
 
float phiAtZ (float z) const
 
bool replaceHit (const CSCRecHit2D *h, int layer)
 
void tryAddingHitsToSegment (const ChamberHitContainer &rechitsInChamber, const BoolContainer &used, const LayerIndex &layerIndex, const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2)
 
void updateParameters (void)
 

Private Attributes

float chi2Max
 
bool debugInfo
 
float dPhiFineMax
 
float dPhiMax
 
float dRPhiFineMax
 
float dRPhiMax
 
int minLayersApart
 
const std::string myName
 
ChamberHitContainer proto_segment
 
CSCSegFitsfit_
 
const CSCChambertheChamber
 
float wideSeg
 
float windowScale
 

Detailed Description

This is the original algorithm for building endcap muon track segments out of the rechit's in a CSCChamber. cf. CSCSegmentizerTC.
'SK' = 'Sasha Khanov' = Speed King

A CSCSegment is a RecSegment4D, and is built from CSCRecHit2D objects, each of which is a RecHit2DLocalPos.

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

Original (in FORTRAN): Alexa.nosp@m.ndre.nosp@m..Khan.nosp@m.ov@c.nosp@m.ern.c.nosp@m.h
Ported to C++ and improved: Rick..nosp@m.Wilk.nosp@m.inson.nosp@m.@cer.nosp@m.n.ch
Reimplemented in terms of layer index, and bug fix: Tim.C.nosp@m.ox@c.nosp@m.ern.c.nosp@m.h
Ported to CMSSW 2006-04-03: Matte.nosp@m.o.Sa.nosp@m.ni@ce.nosp@m.rn.c.nosp@m.h
Factored out segment fitter Tim.C.nosp@m.ox@c.nosp@m.ern.c.nosp@m.h Feb-2015

Definition at line 35 of file CSCSegAlgoSK.h.

Member Typedef Documentation

typedef std::deque<bool> CSCSegAlgoSK::BoolContainer

Definition at line 56 of file CSCSegAlgoSK.h.

typedef std::vector<const CSCRecHit2D*> CSCSegAlgoSK::ChamberHitContainer

Definition at line 48 of file CSCSegAlgoSK.h.

typedef std::vector<const CSCRecHit2D*>::const_iterator CSCSegAlgoSK::ChamberHitContainerCIt

Definition at line 49 of file CSCSegAlgoSK.h.

typedef std::vector<int> CSCSegAlgoSK::LayerIndex

Typedefs.

Definition at line 47 of file CSCSegAlgoSK.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 19 of file CSCSegAlgoSK.cc.

References chi2Max, debugInfo, dPhiFineMax, dPhiMax, dRPhiFineMax, dRPhiMax, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), LogDebug, minLayersApart, myName, and wideSeg.

20  : CSCSegmentAlgorithm(ps), myName("CSCSegAlgoSK"), sfit_(nullptr) {
21  debugInfo = ps.getUntrackedParameter<bool>("verboseInfo");
22 
23  dRPhiMax = ps.getParameter<double>("dRPhiMax");
24  dPhiMax = ps.getParameter<double>("dPhiMax");
25  dRPhiFineMax = ps.getParameter<double>("dRPhiFineMax");
26  dPhiFineMax = ps.getParameter<double>("dPhiFineMax");
27  chi2Max = ps.getParameter<double>("chi2Max");
28  wideSeg = ps.getParameter<double>("wideSeg");
29  minLayersApart = ps.getParameter<int>("minLayersApart");
30 
31  LogDebug("CSC") << myName << " has algorithm cuts set to: \n"
32  << "--------------------------------------------------------------------\n"
33  << "dRPhiMax = " << dRPhiMax << '\n'
34  << "dPhiMax = " << dPhiMax << '\n'
35  << "dRPhiFineMax = " << dRPhiFineMax << '\n'
36  << "dPhiFineMax = " << dPhiFineMax << '\n'
37  << "chi2Max = " << chi2Max << '\n'
38  << "wideSeg = " << wideSeg << '\n'
39  << "minLayersApart = " << minLayersApart << std::endl;
40 }
T getUntrackedParameter(std::string const &, T const &) const
float dPhiFineMax
Definition: CSCSegAlgoSK.h:128
CSCSegmentAlgorithm(const edm::ParameterSet &)
Constructor.
CSCSegFit * sfit_
Definition: CSCSegAlgoSK.h:134
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const std::string myName
Definition: CSCSegAlgoSK.h:122
float dRPhiFineMax
Definition: CSCSegAlgoSK.h:127
#define LogDebug(id)
CSCSegAlgoSK::~CSCSegAlgoSK ( )
inlineoverride

Destructor.

Definition at line 61 of file CSCSegAlgoSK.h.

61 {};

Member Function Documentation

bool CSCSegAlgoSK::addHit ( const CSCRecHit2D hit,
int  layer 
)
private

Utility functions.

Definition at line 358 of file CSCSegAlgoSK.cc.

References phase1PixelTopology::layer, proto_segment, and updateParameters().

Referenced by buildSegments(), increaseProtoSegment(), and replaceHit().

358  {
359  // Return true if hit was added successfully
360  // (and then parameters are updated).
361  // Return false if there is already a hit on the same layer, or insert failed.
362 
363  ChamberHitContainer::const_iterator it;
364 
365  for (it = proto_segment.begin(); it != proto_segment.end(); it++)
366  if (((*it)->cscDetId().layer() == layer) && (aHit != (*it)))
367  return false;
368 
369  proto_segment.push_back(aHit);
370 
371  // make a fit
373  return true;
374 }
ChamberHitContainer proto_segment
Definition: CSCSegAlgoSK.h:121
constexpr std::array< uint8_t, layerIndexSize > layer
void updateParameters(void)
bool CSCSegAlgoSK::areHitsCloseInGlobalPhi ( const CSCRecHit2D h1,
const CSCRecHit2D h2 
) const
private

Definition at line 244 of file CSCSegAlgoSK.cc.

References CSCRecHit2D::cscDetId(), dPhiMax, CSCDetId::layer(), CSCChamber::layer(), CSCRecHit2D::localPosition(), LogDebug, M_PI, PV3DBase< T, PVType, FrameType >::phi(), theChamber, GeomDet::toGlobal(), and windowScale.

Referenced by buildSegments().

244  {
245  const CSCLayer* l1 = theChamber->layer(h1->cscDetId().layer());
246  GlobalPoint gp1 = l1->toGlobal(h1->localPosition());
247  const CSCLayer* l2 = theChamber->layer(h2->cscDetId().layer());
248  GlobalPoint gp2 = l2->toGlobal(h2->localPosition());
249 
250  float h1p = gp1.phi();
251  float h2p = gp2.phi();
252  float dphi12 = h1p - h2p;
253 
254  // Into range [-pi, pi) (phi() returns values in this range)
255  if (dphi12 < -M_PI)
256  dphi12 += 2. * M_PI;
257  if (dphi12 > M_PI)
258  dphi12 -= 2. * M_PI;
259  LogDebug("CSC") << " Hits at global phi= " << h1p << ", " << h2p << " have separation= " << dphi12;
260  return (fabs(dphi12) < (dPhiMax * windowScale)) ? true : false; // +v
261 }
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:58
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
int layer() const
Definition: CSCDetId.h:56
float windowScale
Definition: CSCSegAlgoSK.h:124
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
#define M_PI
LocalPoint localPosition() const override
Definition: CSCRecHit2D.h:56
const CSCChamber * theChamber
Definition: CSCSegAlgoSK.h:120
#define LogDebug(id)
bool CSCSegAlgoSK::areHitsCloseInLocalX ( const CSCRecHit2D h1,
const CSCRecHit2D h2 
) const
private

Utility functions.

Definition at line 237 of file CSCSegAlgoSK.cc.

References dRPhiMax, CSCRecHit2D::localPosition(), LogDebug, windowScale, and x.

Referenced by buildSegments().

237  {
238  float deltaX = (h1->localPosition() - h2->localPosition()).x();
239  LogDebug("CSC") << " Hits at local x= " << h1->localPosition().x() << ", " << h2->localPosition().x()
240  << " have separation= " << deltaX;
241  return (fabs(deltaX) < (dRPhiMax * windowScale)) ? true : false; // +v
242 }
float windowScale
Definition: CSCSegAlgoSK.h:124
LocalPoint localPosition() const override
Definition: CSCRecHit2D.h:56
#define LogDebug(id)
std::vector< CSCSegment > CSCSegAlgoSK::buildSegments ( const ChamberHitContainer rechits)

Build track segments in this chamber (this is where the actual segment-building algorithm hides.)

Definition at line 47 of file CSCSegAlgoSK.cc.

References funct::abs(), addHit(), areHitsCloseInGlobalPhi(), areHitsCloseInLocalX(), CSCChamberSpecs::chamberTypeName(), CSCSegFit::chi2(), CSCSegFit::covarianceMatrix(), debugInfo, dumpSegment(), flagHitsAsUsed(), CSCSegFit::hits(), mps_fire::i, cuy::ib, CSCSegFit::intercept(), isSegmentGood(), CSCChamber::layer(), CSCSegFit::localdir(), CSCRecHit2D::localPosition(), LogDebug, minLayersApart, myName, GeomDet::position(), proto_segment, HI_PhotonSkim_cff::rechits, sfit_, CSCChamber::specs(), groupFilesInBlocks::temp, theChamber, GeomDet::toGlobal(), tryAddingHitsToSegment(), wideSeg, windowScale, and PV3DBase< T, PVType, FrameType >::z().

Referenced by run().

47  {
48  LogDebug("CSC") << "*********************************************";
49  LogDebug("CSC") << "Start segment building in the new chamber: " << theChamber->specs()->chamberTypeName();
50  LogDebug("CSC") << "*********************************************";
51 
52  ChamberHitContainer rechits = urechits;
53  LayerIndex layerIndex(rechits.size());
54 
55  for (unsigned int i = 0; i < rechits.size(); i++) {
56  layerIndex[i] = rechits[i]->cscDetId().layer();
57  }
58 
59  double z1 = theChamber->layer(1)->position().z();
60  double z6 = theChamber->layer(6)->position().z();
61 
62  if (z1 > 0.) {
63  if (z1 > z6) {
64  reverse(layerIndex.begin(), layerIndex.end());
65  reverse(rechits.begin(), rechits.end());
66  }
67  } else if (z1 < 0.) {
68  if (z1 < z6) {
69  reverse(layerIndex.begin(), layerIndex.end());
70  reverse(rechits.begin(), rechits.end());
71  }
72  }
73 
74  // if (debugInfo) dumpHits(rechits);
75 
76  if (rechits.size() < 2) {
77  LogDebug("CSC") << myName << ": " << rechits.size() << " hit(s) in chamber is not enough to build a segment.\n";
78  return std::vector<CSCSegment>();
79  }
80 
81  // We have at least 2 hits. We intend to try all possible pairs of hits to start
82  // segment building. 'All possible' means each hit lies on different layers in the chamber.
83  // BUT... once a hit has been assigned to a segment, we don't consider
84  // it again.
85 
86  // Choose first hit (as close to IP as possible) h1 and
87  // second hit (as far from IP as possible) h2
88  // To do this we iterate over hits in the chamber by layer - pick two layers.
89  // @@ Require the two layers are at least 3 layers apart. May need tuning?
90  // Then we iterate over hits within each of these layers and pick h1 and h2 from these.
91  // If they are 'close enough' we build an empty segment.
92  // Then try adding hits to this segment.
93 
94  // Initialize flags that a given hit has been allocated to a segment
95  BoolContainer used(rechits.size(), false);
96 
97  // Define buffer for segments we build
98  std::vector<CSCSegment> segments;
99 
100  // This is going to point to fits to hits, and its content will be used to create a CSCSegment
101  sfit_ = nullptr;
102 
103  ChamberHitContainerCIt ib = rechits.begin();
104  ChamberHitContainerCIt ie = rechits.end();
105 
106  // Possibly allow 2 passes, second widening scale factor for cuts
107  windowScale = 1.; // scale factor for cuts
108 
109  int npass = (wideSeg > 1.) ? 2 : 1;
110 
111  for (int ipass = 0; ipass < npass; ++ipass) {
112  for (ChamberHitContainerCIt i1 = ib; i1 != ie; ++i1) {
113  bool segok = false;
114  if (used[i1 - ib])
115  continue;
116 
117  int layer1 = layerIndex[i1 - ib]; //(*i1)->cscDetId().layer();
118  const CSCRecHit2D* h1 = *i1;
119 
120  for (ChamberHitContainerCIt i2 = ie - 1; i2 != i1; --i2) {
121  if (used[i2 - ib])
122  continue;
123 
124  int layer2 = layerIndex[i2 - ib]; //(*i2)->cscDetId().layer();
125 
126  if (abs(layer2 - layer1) < minLayersApart)
127  break;
128  const CSCRecHit2D* h2 = *i2;
129 
130  if (areHitsCloseInLocalX(h1, h2) && areHitsCloseInGlobalPhi(h1, h2)) {
131  proto_segment.clear();
132 
133  const CSCLayer* l1 = theChamber->layer(layer1);
134  GlobalPoint gp1 = l1->toGlobal(h1->localPosition());
135  const CSCLayer* l2 = theChamber->layer(layer2);
136  GlobalPoint gp2 = l2->toGlobal(h2->localPosition());
137  LogDebug("CSC") << "start new segment from hits "
138  << "h1: " << gp1 << " - h2: " << gp2 << "\n";
139 
140  //@@ TRY ADDING A HIT - AND FIT
141  if (!addHit(h1, layer1)) {
142  LogDebug("CSC") << " failed to add hit h1\n";
143  continue;
144  }
145 
146  if (!addHit(h2, layer2)) {
147  LogDebug("CSC") << " failed to add hit h2\n";
148  continue;
149  }
150 
151  // Can only add hits if already have a segment
152  if (sfit_)
153  tryAddingHitsToSegment(rechits, used, layerIndex, i1, i2);
154 
155  // Check no. of hits on segment, and if enough flag them as used
156  // and store the segment
157  segok = isSegmentGood(rechits);
158  if (segok) {
159  flagHitsAsUsed(rechits, used);
160  // Copy the proto_segment and its properties inside a CSCSegment.
161  // Then fill the segment vector..
162 
163  if (proto_segment.empty()) {
164  LogDebug("CSC") << "No segment has been found !!!\n";
165  } else {
166  // Create an actual CSCSegment - retrieve all info from the fit
169  delete sfit_;
170  sfit_ = nullptr;
171  LogDebug("CSC") << "Found a segment !!!\n";
172  if (debugInfo)
173  dumpSegment(temp);
174  segments.push_back(temp);
175  }
176  }
177  } // h1 & h2 close
178 
179  if (segok)
180  break;
181  } // i2
182  } // i1
183 
184  if (segments.size() > 1)
185  break; // only change window if no segments found
186 
187  // Increase cut windows by factor of wideSeg
189 
190  } // ipass
191 
192  // Give the segments to the CSCChamber
193  return segments;
194 }
CSCSetOfHits hits(void) const
Definition: CSCSegFit.h:79
int ib
Definition: cuy.py:661
LocalVector localdir() const
Definition: CSCSegFit.h:85
bool areHitsCloseInLocalX(const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
Utility functions.
ChamberHitContainer proto_segment
Definition: CSCSegAlgoSK.h:121
void flagHitsAsUsed(const ChamberHitContainer &rechitsInChamber, BoolContainer &used) const
std::vector< const CSCRecHit2D * >::const_iterator ChamberHitContainerCIt
Definition: CSCSegAlgoSK.h:49
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
bool addHit(const CSCRecHit2D *hit, int layer)
Utility functions.
void dumpSegment(const CSCSegment &seg) const
std::string chamberTypeName() const
float windowScale
Definition: CSCSegAlgoSK.h:124
CSCSegFit * sfit_
Definition: CSCSegAlgoSK.h:134
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
const CSCChamberSpecs * specs() const
Definition: CSCChamber.h:39
double chi2(void) const
Definition: CSCSegFit.h:82
T z() const
Definition: PV3DBase.h:61
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
LocalPoint localPosition() const override
Definition: CSCRecHit2D.h:56
AlgebraicSymMatrix covarianceMatrix(void)
Definition: CSCSegFit.cc:352
LocalPoint intercept() const
Definition: CSCSegFit.h:84
const std::string myName
Definition: CSCSegAlgoSK.h:122
std::vector< int > LayerIndex
Typedefs.
Definition: CSCSegAlgoSK.h:47
bool isSegmentGood(const ChamberHitContainer &rechitsInChamber) const
std::vector< const CSCRecHit2D * > ChamberHitContainer
Definition: CSCSegAlgoSK.h:48
void tryAddingHitsToSegment(const ChamberHitContainer &rechitsInChamber, const BoolContainer &used, const LayerIndex &layerIndex, const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2)
bool areHitsCloseInGlobalPhi(const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
std::deque< bool > BoolContainer
Definition: CSCSegAlgoSK.h:56
const CSCChamber * theChamber
Definition: CSCSegAlgoSK.h:120
#define LogDebug(id)
void CSCSegAlgoSK::compareProtoSegment ( const CSCRecHit2D h,
int  layer 
)
private

Definition at line 407 of file CSCSegAlgoSK.cc.

References CSCSegFit::chi2(), LogDebug, convertSQLiteXML::ok, replaceHit(), and sfit_.

Referenced by tryAddingHitsToSegment().

407  {
408  // Copy the input CSCSegFit
409  CSCSegFit* oldfit = new CSCSegFit(*sfit_);
410 
411  // May create a new fit
412  bool ok = replaceHit(h, layer);
413 
414  if (ok) {
415  LogDebug("CSCSegment") << " hit in same layer as a hit on segment; try replacing old one..."
416  << " chi2 new: " << sfit_->chi2() << " old: " << oldfit->chi2() << "\n";
417  }
418 
419  if ((sfit_->chi2() < oldfit->chi2()) && ok) {
420  LogDebug("CSC") << " segment with replaced hit is better.\n";
421  delete oldfit; // new fit is better
422  } else {
423  // keep original fit
424  delete sfit_; // now the new fit
425  sfit_ = oldfit; // reset to the original input fit
426  }
427 }
bool replaceHit(const CSCRecHit2D *h, int layer)
constexpr std::array< uint8_t, layerIndexSize > layer
CSCSegFit * sfit_
Definition: CSCSegAlgoSK.h:134
double chi2(void) const
Definition: CSCSegFit.h:82
#define LogDebug(id)
void CSCSegAlgoSK::dumpHits ( const ChamberHitContainer rechits) const
private

Dump position and phi of each rechit in chamber after sort in z

Definition at line 313 of file CSCSegAlgoSK.cc.

References CSCChamber::layer(), PV3DBase< T, PVType, FrameType >::phi(), Geom::Phi< T1, Range >::phi(), theChamber, and GeomDet::toGlobal().

313  {
314  // Dump positions of RecHit's in each CSCChamber
316  edm::LogInfo("CSCSegment") << "CSCChamber rechit dump.\n";
317  for (it = rechits.begin(); it != rechits.end(); it++) {
318  const CSCLayer* l1 = theChamber->layer((*it)->cscDetId().layer());
319  GlobalPoint gp1 = l1->toGlobal((*it)->localPosition());
320 
321  edm::LogInfo("CSCSegment") << "Global pos.: " << gp1 << ", phi: " << gp1.phi()
322  << ". Local position: " << (*it)->localPosition()
323  << ", phi: " << (*it)->localPosition().phi() << ". Layer: " << (*it)->cscDetId().layer()
324  << "\n";
325  }
326 }
std::vector< const CSCRecHit2D * >::const_iterator ChamberHitContainerCIt
Definition: CSCSegAlgoSK.h:49
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T1 phi() const
Definition: Phi.h:78
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
Log< level::Info, false > LogInfo
const CSCChamber * theChamber
Definition: CSCSegAlgoSK.h:120
void CSCSegAlgoSK::dumpSegment ( const CSCSegment seg) const
private

Definition at line 453 of file CSCSegAlgoSK.cc.

References CSCSegment::chi2(), CSCSegment::degreesOfFreedom(), CSCChamber::id(), CSCSegment::localDirection(), CSCSegment::localDirectionError(), CSCSegment::localPosition(), CSCSegment::localPositionError(), CSCSegment::parametersError(), CSCSegment::specificRecHits(), theChamber, and CSCSegment::time().

Referenced by buildSegments().

453  {
454  edm::LogVerbatim("CSCSegment") << "CSCSegment in " << theChamber->id() << "\nlocal position = " << seg.localPosition()
455  << "\nerror = " << seg.localPositionError()
456  << "\nlocal direction = " << seg.localDirection()
457  << "\nerror =" << seg.localDirectionError() << "\ncovariance matrix"
458  << seg.parametersError() << "chi2/ndf = " << seg.chi2() << "/"
459  << seg.degreesOfFreedom() << "\n#rechits = " << seg.specificRecHits().size()
460  << "\ntime = " << seg.time();
461 }
Log< level::Info, true > LogVerbatim
LocalPoint localPosition() const override
Definition: CSCSegment.h:39
CSCDetId id() const
Get the (concrete) DetId.
Definition: CSCChamber.h:34
double chi2() const override
Chi2 of the segment fit.
Definition: CSCSegment.h:58
LocalVector localDirection() const override
Local direction.
Definition: CSCSegment.h:42
int degreesOfFreedom() const override
Degrees of freedom of the segment fit.
Definition: CSCSegment.h:62
const std::vector< CSCRecHit2D > & specificRecHits() const
Definition: CSCSegment.h:66
LocalError localDirectionError() const override
Error on the local direction.
Definition: CSCSegment.cc:52
AlgebraicSymMatrix parametersError() const override
Covariance matrix of parameters()
Definition: CSCSegment.h:49
LocalError localPositionError() const override
Definition: CSCSegment.cc:48
float time() const
Definition: CSCSegment.cc:144
const CSCChamber * theChamber
Definition: CSCSegAlgoSK.h:120
void CSCSegAlgoSK::flagHitsAsUsed ( const ChamberHitContainer rechitsInChamber,
BoolContainer used 
) const
private

Flag hits on segment as used

Definition at line 345 of file CSCSegAlgoSK.cc.

References cuy::ib, and proto_segment.

Referenced by buildSegments().

345  {
346  // Flag hits on segment as used
347  ChamberHitContainerCIt ib = rechitsInChamber.begin();
348  ChamberHitContainerCIt hi, iu;
349 
350  for (hi = proto_segment.begin(); hi != proto_segment.end(); ++hi) {
351  for (iu = ib; iu != rechitsInChamber.end(); ++iu) {
352  if (*hi == *iu)
353  used[iu - ib] = true;
354  }
355  }
356 }
int ib
Definition: cuy.py:661
ChamberHitContainer proto_segment
Definition: CSCSegAlgoSK.h:121
std::vector< const CSCRecHit2D * >::const_iterator ChamberHitContainerCIt
Definition: CSCSegAlgoSK.h:49
bool CSCSegAlgoSK::hasHitOnLayer ( int  layer) const
private

Definition at line 383 of file CSCSegAlgoSK.cc.

References phase1PixelTopology::layer, and proto_segment.

Referenced by tryAddingHitsToSegment().

383  {
384  // Is there is already a hit on this layer?
386 
387  for (it = proto_segment.begin(); it != proto_segment.end(); it++)
388  if ((*it)->cscDetId().layer() == layer)
389  return true;
390 
391  return false;
392 }
ChamberHitContainer proto_segment
Definition: CSCSegAlgoSK.h:121
std::vector< const CSCRecHit2D * >::const_iterator ChamberHitContainerCIt
Definition: CSCSegAlgoSK.h:49
constexpr std::array< uint8_t, layerIndexSize > layer
void CSCSegAlgoSK::increaseProtoSegment ( const CSCRecHit2D h,
int  layer 
)
private

Definition at line 429 of file CSCSegAlgoSK.cc.

References addHit(), CSCSegFit::chi2(), chi2Max, LogDebug, CSCSegFit::ndof(), convertSQLiteXML::ok, and sfit_.

Referenced by tryAddingHitsToSegment().

429  {
430  // Copy input fit
431  CSCSegFit* oldfit = new CSCSegFit(*sfit_);
432 
433  // Creates a new fit
434  bool ok = addHit(h, layer);
435 
436  if (ok) {
437  LogDebug("CSCSegment") << " hit in new layer: added to segment, new chi2: " << sfit_->chi2() << "\n";
438  }
439 
440  // int ndf = 2*proto_segment.size() - 4;
441 
442  //@@ TEST ON ndof<=0 IS JUST TO ACCEPT nhits=2 CASE??
443  if (ok && ((sfit_->ndof() <= 0) || (sfit_->chi2() / sfit_->ndof() < chi2Max))) {
444  LogDebug("CSCSegment") << " segment with added hit is good.\n";
445  delete oldfit; // new fit is better
446  } else {
447  // reset to original fit
448  delete sfit_;
449  sfit_ = oldfit;
450  }
451 }
bool addHit(const CSCRecHit2D *hit, int layer)
Utility functions.
constexpr std::array< uint8_t, layerIndexSize > layer
CSCSegFit * sfit_
Definition: CSCSegAlgoSK.h:134
double chi2(void) const
Definition: CSCSegFit.h:82
int ndof(void) const
Definition: CSCSegFit.h:83
#define LogDebug(id)
bool CSCSegAlgoSK::isHitNearSegment ( const CSCRecHit2D h) const
private

Definition at line 263 of file CSCSegAlgoSK.cc.

References CSCRecHit2D::cscDetId(), dPhiFineMax, dRPhiFineMax, CSCDetId::layer(), CSCChamber::layer(), CSCRecHit2D::localPosition(), LogDebug, M_PI, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), phiAtZ(), theChamber, GeomDet::toGlobal(), windowScale, and PV3DBase< T, PVType, FrameType >::z().

Referenced by tryAddingHitsToSegment().

263  {
264  // Is hit near segment?
265  // Requires deltaphi and rxy*deltaphi within ranges specified
266  // in parameter set, where rxy=sqrt(x**2+y**2) of hit itself.
267  // Note that to make intuitive cuts on delta(phi) one must work in
268  // phi range (-pi, +pi] not [0, 2pi)
269 
270  const CSCLayer* l1 = theChamber->layer(h->cscDetId().layer());
271  GlobalPoint hp = l1->toGlobal(h->localPosition());
272 
273  float hphi = hp.phi(); // in (-pi, +pi]
274  if (hphi < 0.)
275  hphi += 2. * M_PI; // into range [0, 2pi)
276  float sphi = phiAtZ(hp.z()); // in [0, 2*pi)
277  float phidif = sphi - hphi;
278  if (phidif < 0.)
279  phidif += 2. * M_PI; // into range [0, 2pi)
280  if (phidif > M_PI)
281  phidif -= 2. * M_PI; // into range (-pi, pi]
282 
283  float dRPhi = fabs(phidif) * hp.perp();
284  LogDebug("CSC") << " is hit at phi_h= " << hphi << " near segment phi_seg= " << sphi << "? is " << dRPhi << "<"
285  << dRPhiFineMax * windowScale << " ? "
286  << " and is |" << phidif << "|<" << dPhiFineMax * windowScale << " ?";
287 
288  return ((dRPhi < dRPhiFineMax * windowScale) && (fabs(phidif) < dPhiFineMax * windowScale)) ? true : false; // +v
289 }
float dPhiFineMax
Definition: CSCSegAlgoSK.h:128
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:58
T perp() const
Definition: PV3DBase.h:69
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
int layer() const
Definition: CSCDetId.h:56
float windowScale
Definition: CSCSegAlgoSK.h:124
T z() const
Definition: PV3DBase.h:61
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
float phiAtZ(float z) const
#define M_PI
LocalPoint localPosition() const override
Definition: CSCRecHit2D.h:56
float dRPhiFineMax
Definition: CSCSegAlgoSK.h:127
const CSCChamber * theChamber
Definition: CSCSegAlgoSK.h:120
#define LogDebug(id)
bool CSCSegAlgoSK::isSegmentGood ( const ChamberHitContainer rechitsInChamber) const
private

Return true if segment is 'good'. In this algorithm, 'good' means has sufficient hits

Definition at line 328 of file CSCSegAlgoSK.cc.

References convertSQLiteXML::ok, proto_segment, and windowScale.

Referenced by buildSegments().

328  {
329  // If the chamber has 20 hits or fewer, require at least 3 hits on segment
330  // If the chamber has >20 hits require at least 4 hits
331 
332  bool ok = false;
333 
334  unsigned int iadd = (rechitsInChamber.size() > 20) ? 1 : 0;
335 
336  if (windowScale > 1.)
337  iadd = 1;
338 
339  if (proto_segment.size() >= 3 + iadd)
340  ok = true;
341 
342  return ok;
343 }
ChamberHitContainer proto_segment
Definition: CSCSegAlgoSK.h:121
float windowScale
Definition: CSCSegAlgoSK.h:124
float CSCSegAlgoSK::phiAtZ ( float  z) const
private

Definition at line 291 of file CSCSegAlgoSK.cc.

References validate-o2o-wbm::f, runTauDisplay::gp, CSCSegFit::intercept(), CSCChamber::layer(), CSCSegFit::localdir(), LogTrace, M_PI, phi, proto_segment, sfit_, theChamber, GeomDet::toGlobal(), x, PV3DBase< T, PVType, FrameType >::x(), y, PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by isHitNearSegment().

291  {
292  if (!sfit_) {
293  edm::LogVerbatim("CSCSegment") << "[CSCSegAlgoSK::phiAtZ] Segment fit undefined";
294  return 0.;
295  }
296 
297  // Returns a phi in [ 0, 2*pi )
298  const CSCLayer* l1 = theChamber->layer((*(proto_segment.begin()))->cscDetId().layer());
300  GlobalVector gv = l1->toGlobal(sfit_->localdir());
301 
302  LogTrace("CSCSegment") << "[CSCSegAlgoSK::phiAtZ] Global intercept = " << gp << ", direction = " << gv;
303 
304  float x = gp.x() + (gv.x() / gv.z()) * (z - gp.z());
305  float y = gp.y() + (gv.y() / gv.z()) * (z - gp.z());
306  float phi = atan2(y, x);
307  if (phi < 0.f)
308  phi += 2. * M_PI;
309 
310  return phi;
311 }
Log< level::Info, true > LogVerbatim
LocalVector localdir() const
Definition: CSCSegFit.h:85
ChamberHitContainer proto_segment
Definition: CSCSegAlgoSK.h:121
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
T y() const
Definition: PV3DBase.h:60
#define LogTrace(id)
CSCSegFit * sfit_
Definition: CSCSegAlgoSK.h:134
T z() const
Definition: PV3DBase.h:61
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
#define M_PI
LocalPoint intercept() const
Definition: CSCSegFit.h:84
T x() const
Definition: PV3DBase.h:59
const CSCChamber * theChamber
Definition: CSCSegAlgoSK.h:120
bool CSCSegAlgoSK::replaceHit ( const CSCRecHit2D h,
int  layer 
)
private

Definition at line 394 of file CSCSegAlgoSK.cc.

References addHit(), phase1PixelTopology::layer, and proto_segment.

Referenced by compareProtoSegment().

394  {
395  // replace a hit from a layer
396  ChamberHitContainer::iterator it;
397  for (it = proto_segment.begin(); it != proto_segment.end();) {
398  if ((*it)->cscDetId().layer() == layer)
399  it = proto_segment.erase(it);
400  else
401  ++it;
402  }
403 
404  return addHit(h, layer);
405 }
ChamberHitContainer proto_segment
Definition: CSCSegAlgoSK.h:121
bool addHit(const CSCRecHit2D *hit, int layer)
Utility functions.
constexpr std::array< uint8_t, layerIndexSize > layer
std::vector< CSCSegment > CSCSegAlgoSK::run ( const CSCChamber aChamber,
const ChamberHitContainer rechits 
)
override

Here we must implement the algorithm

Definition at line 42 of file CSCSegAlgoSK.cc.

References buildSegments(), and theChamber.

42  {
43  theChamber = aChamber;
44  return buildSegments(rechits);
45 }
std::vector< CSCSegment > buildSegments(const ChamberHitContainer &rechits)
Definition: CSCSegAlgoSK.cc:47
const CSCChamber * theChamber
Definition: CSCSegAlgoSK.h:120
void CSCSegAlgoSK::tryAddingHitsToSegment ( const ChamberHitContainer rechitsInChamber,
const BoolContainer used,
const LayerIndex layerIndex,
const ChamberHitContainerCIt  i1,
const ChamberHitContainerCIt  i2 
)
private

Try adding non-used hits to segment

Definition at line 196 of file CSCSegAlgoSK.cc.

References compareProtoSegment(), h, hasHitOnLayer(), mps_fire::i, cuy::ib, increaseProtoSegment(), isHitNearSegment(), CSCChamber::layer(), phase1PixelTopology::layer, CSCRecHit2D::localPosition(), LogDebug, proto_segment, theChamber, and GeomDet::toGlobal().

Referenced by buildSegments().

200  {
201  // Iterate over the layers with hits in the chamber
202  // Skip the layers containing the segment endpoints
203  // Test each hit on the other layers to see if it is near the segment
204  // If it is, see whether there is already a hit on the segment from the same layer
205  // - if so, and there are more than 2 hits on the segment, copy the segment,
206  // replace the old hit with the new hit. If the new segment chi2 is better
207  // then replace the original segment with the new one (by swap)
208  // - if not, copy the segment, add the hit. If the new chi2/dof is still satisfactory
209  // then replace the original segment with the new one (by swap)
210 
212  ChamberHitContainerCIt ie = rechits.end();
213 
214  for (ChamberHitContainerCIt i = ib; i != ie; ++i) {
215  if (i == i1 || i == i2 || used[i - ib])
216  continue;
217 
218  int layer = layerIndex[i - ib];
219  const CSCRecHit2D* h = *i;
220  if (isHitNearSegment(h)) {
221  GlobalPoint gp1 = theChamber->layer(layer)->toGlobal(h->localPosition());
222  LogDebug("CSC") << " hit at global " << gp1 << " is near segment\n.";
223 
224  // Don't consider alternate hits on layers holding the two starting points
225  if (hasHitOnLayer(layer)) {
226  if (proto_segment.size() <= 2) {
227  LogDebug("CSC") << " " << proto_segment.size() << " hits on segment...skip hit on same layer.\n";
228  continue;
229  }
230  compareProtoSegment(h, layer);
231  } else
232  increaseProtoSegment(h, layer);
233  } // h & seg close
234  } // i
235 }
int ib
Definition: cuy.py:661
ChamberHitContainer proto_segment
Definition: CSCSegAlgoSK.h:121
std::vector< const CSCRecHit2D * >::const_iterator ChamberHitContainerCIt
Definition: CSCSegAlgoSK.h:49
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
constexpr std::array< uint8_t, layerIndexSize > layer
bool isHitNearSegment(const CSCRecHit2D *h) const
void increaseProtoSegment(const CSCRecHit2D *h, int layer)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
LocalPoint localPosition() const override
Definition: CSCRecHit2D.h:56
bool hasHitOnLayer(int layer) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void compareProtoSegment(const CSCRecHit2D *h, int layer)
const CSCChamber * theChamber
Definition: CSCSegAlgoSK.h:120
#define LogDebug(id)
void CSCSegAlgoSK::updateParameters ( void  )
private

Definition at line 376 of file CSCSegAlgoSK.cc.

References CSCSegFit::fit(), proto_segment, sfit_, and theChamber.

Referenced by addHit().

376  {
377  // Delete input CSCSegFit, create a new one and make the fit
378  delete sfit_;
380  sfit_->fit();
381 }
void fit(void)
Definition: CSCSegFit.cc:13
ChamberHitContainer proto_segment
Definition: CSCSegAlgoSK.h:121
CSCSegFit * sfit_
Definition: CSCSegAlgoSK.h:134
const CSCChamber * theChamber
Definition: CSCSegAlgoSK.h:120

Member Data Documentation

float CSCSegAlgoSK::chi2Max
private

Definition at line 129 of file CSCSegAlgoSK.h.

Referenced by CSCSegAlgoSK(), and increaseProtoSegment().

bool CSCSegAlgoSK::debugInfo
private

Definition at line 132 of file CSCSegAlgoSK.h.

Referenced by buildSegments(), and CSCSegAlgoSK().

float CSCSegAlgoSK::dPhiFineMax
private

Definition at line 128 of file CSCSegAlgoSK.h.

Referenced by CSCSegAlgoSK(), and isHitNearSegment().

float CSCSegAlgoSK::dPhiMax
private

Definition at line 126 of file CSCSegAlgoSK.h.

Referenced by areHitsCloseInGlobalPhi(), and CSCSegAlgoSK().

float CSCSegAlgoSK::dRPhiFineMax
private

Definition at line 127 of file CSCSegAlgoSK.h.

Referenced by CSCSegAlgoSK(), and isHitNearSegment().

float CSCSegAlgoSK::dRPhiMax
private

Definition at line 125 of file CSCSegAlgoSK.h.

Referenced by areHitsCloseInLocalX(), and CSCSegAlgoSK().

int CSCSegAlgoSK::minLayersApart
private

Definition at line 131 of file CSCSegAlgoSK.h.

Referenced by buildSegments(), and CSCSegAlgoSK().

const std::string CSCSegAlgoSK::myName
private

Definition at line 122 of file CSCSegAlgoSK.h.

Referenced by buildSegments(), and CSCSegAlgoSK().

ChamberHitContainer CSCSegAlgoSK::proto_segment
private
CSCSegFit* CSCSegAlgoSK::sfit_
private
const CSCChamber* CSCSegAlgoSK::theChamber
private
float CSCSegAlgoSK::wideSeg
private

Definition at line 130 of file CSCSegAlgoSK.h.

Referenced by buildSegments(), and CSCSegAlgoSK().

float CSCSegAlgoSK::windowScale
private