CMS 3D CMS Logo

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

#include <GEMSegmentAlgorithm.h>

Inheritance diagram for GEMSegmentAlgorithm:
GEMSegmentAlgorithmBase

Public Types

typedef std::vector< const GEMRecHit * > EnsembleHitContainer
 Typedefs. More...
 
typedef std::vector< EnsembleHitContainerProtoSegments
 
- Public Types inherited from GEMSegmentAlgorithmBase
typedef std::pair< const GEMSuperChamber *, std::map< uint32_t, const GEMEtaPartition * > > GEMEnsemble
 

Public Member Functions

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

Private Member Functions

void buildSegments (const GEMEnsemble &ensemble, const EnsembleHitContainer &rechits, std::vector< GEMSegment > &gemsegs)
 
ProtoSegments chainHits (const GEMEnsemble &ensemble, const EnsembleHitContainer &rechits)
 
ProtoSegments clusterHits (const GEMEnsemble &ensemble, const EnsembleHitContainer &rechits)
 Utility functions. More...
 
bool isGoodToMerge (const GEMEnsemble &ensemble, const EnsembleHitContainer &newChain, const EnsembleHitContainer &oldChain)
 

Private Attributes

bool clusterOnlySameBXRecHits
 
bool debug
 
double dEtaChainBoxMax
 
double dPhiChainBoxMax
 
double dXclusBoxMax
 
double dYclusBoxMax
 
int maxRecHitsInCluster
 
unsigned int minHitsPerSegment
 
const std::string myName
 
bool preClustering
 
bool preClustering_useChaining
 
EnsembleHitContainer proto_segment
 
std::unique_ptr< MuonSegFitsfit_
 
GEMDetId theChamberId
 

Static Private Attributes

static float running_max = std::numeric_limits<float>::max()
 

Detailed Description

This algorithm is very basic no attemp to deal with ambiguities , noise etc. The GEM track segments (actually more correct would be: GEM correlated hits) is built out of the rechits in two GEM layers in GE1/1 or GE2/1 as the GEM Ensabmle .

Authors
Piet Verwilligen updated by Jason Lee to use general segment fitter, MuonSegFit

Definition at line 25 of file GEMSegmentAlgorithm.h.

Member Typedef Documentation

Typedefs.

Definition at line 28 of file GEMSegmentAlgorithm.h.

Definition at line 29 of file GEMSegmentAlgorithm.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 25 of file GEMSegmentAlgorithm.cc.

References clusterOnlySameBXRecHits, debug, dEtaChainBoxMax, dPhiChainBoxMax, dXclusBoxMax, dYclusBoxMax, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), maxRecHitsInCluster, minHitsPerSegment, preClustering, and preClustering_useChaining.

26  : GEMSegmentAlgorithmBase(ps), myName("GEMSegmentAlgorithm") {
27  debug = ps.getUntrackedParameter<bool>("GEMDebug");
28  minHitsPerSegment = ps.getParameter<unsigned int>("minHitsPerSegment");
29  preClustering = ps.getParameter<bool>("preClustering");
30  dXclusBoxMax = ps.getParameter<double>("dXclusBoxMax");
31  dYclusBoxMax = ps.getParameter<double>("dYclusBoxMax");
32  preClustering_useChaining = ps.getParameter<bool>("preClusteringUseChaining");
33  dPhiChainBoxMax = ps.getParameter<double>("dPhiChainBoxMax");
34  dEtaChainBoxMax = ps.getParameter<double>("dEtaChainBoxMax");
35  maxRecHitsInCluster = ps.getParameter<int>("maxRecHitsInCluster");
36  clusterOnlySameBXRecHits = ps.getParameter<bool>("clusterOnlySameBXRecHits");
37 
38  // maybe to be used in the future ???
39  // Pruning = ps.getParameter<bool>("Pruning");
40  // BrutePruning = ps.getParameter<bool>("BrutePruning");
41  // maxRecHitsInCluster is the maximal number of hits in a precluster that is being processed
42  // This cut is intended to remove messy events. Currently nothing is returned if there are
43  // more that maxRecHitsInCluster hits. It could be useful to return an estimate of the
44  // cluster position, which is available.
45  // maxRecHitsInCluster = ps.getParameter<int>("maxRecHitsInCluster");
46  // onlyBestSegment = ps.getParameter<bool>("onlyBestSegment");
47 
48  // CSC uses pruning to remove clearly bad hits, using as much info from the rechits as possible: charge, position, timing, ...
49  // In fits with bad chi^2 they look for the worst hit (hit with abnormally large residual)
50  // if worst hit was found, refit without worst hit and select if considerably better than original fit.
51 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
GEMSegmentAlgorithmBase(const edm::ParameterSet &)
Constructor.
const std::string myName
unsigned int minHitsPerSegment
GEMSegmentAlgorithm::~GEMSegmentAlgorithm ( )
override

Destructor.

Definition at line 56 of file GEMSegmentAlgorithm.cc.

56 {}

Member Function Documentation

void GEMSegmentAlgorithm::buildSegments ( const GEMEnsemble ensemble,
const EnsembleHitContainer rechits,
std::vector< GEMSegment > &  gemsegs 
)
private

Definition at line 323 of file GEMSegmentAlgorithm.cc.

References l1GtPatternGenerator_cfi::bx, GEMRecHit::clone(), GEMSegment::gemDetId(), runTauDisplay::gp, minHitsPerSegment, proto_segment, GEMRecHit::setPosition(), sfit_, createJobs::tmp, GeomDet::toGlobal(), and GeomDet::toLocal().

Referenced by run().

325  {
326  if (rechits.size() < minHitsPerSegment)
327  return;
328 
330  proto_segment.clear();
331 
332  // select hits from the ensemble and sort it
333  const GEMSuperChamber* suCh = ensemble.first;
334  for (auto rh = rechits.begin(); rh != rechits.end(); rh++) {
335  proto_segment.push_back(*rh);
336 
337  // for segFit - using local point in chamber frame
338  const GEMEtaPartition* thePartition = (ensemble.second.find((*rh)->gemId()))->second;
339  GlobalPoint gp = thePartition->toGlobal((*rh)->localPosition());
340  const LocalPoint lp = suCh->toLocal(gp);
341 
342  GEMRecHit* newRH = (*rh)->clone();
343  newRH->setPosition(lp);
344  MuonSegFit::MuonRecHitPtr trkRecHit(newRH);
345  muonRecHits.push_back(trkRecHit);
346  }
347 
348 #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
349  edm::LogVerbatim("GEMSegmentAlgorithm")
350  << "[GEMSegmentAlgorithm::buildSegments] will now try to fit a GEMSegment from collection of " << rechits.size()
351  << " GEM RecHits";
352  for (auto rh = rechits.begin(); rh != rechits.end(); ++rh) {
353  auto gemid = (*rh)->gemId();
354  auto rhLP = (*rh)->localPosition();
355  edm::LogVerbatim("GEMSegmentAlgorithm")
356  << "[RecHit :: Loc x = " << std::showpos << std::setw(9) << rhLP.x() << " Loc y = " << std::showpos
357  << std::setw(9) << rhLP.y() << " BX = " << std::showpos << (*rh)->BunchX() << " -- " << gemid.rawId() << " = "
358  << gemid << " ]";
359  }
360 #endif
361 
362  // The actual fit on all hits of the vector of the selected Tracking RecHits:
363  sfit_ = std::make_unique<MuonSegFit>(muonRecHits);
364  bool goodfit = sfit_->fit();
365  edm::LogVerbatim("GEMSegmentAlgorithm")
366  << "[GEMSegmentAlgorithm::buildSegments] GEMSegment fit done :: fit is good = " << goodfit;
367 
368  // quit function if fit was not OK
369  if (!goodfit) {
370  for (auto rh : muonRecHits)
371  rh.reset();
372  return;
373  }
374  // obtain all information necessary to make the segment:
375  LocalPoint protoIntercept = sfit_->intercept();
376  LocalVector protoDirection = sfit_->localdir();
377  AlgebraicSymMatrix protoErrors = sfit_->covarianceMatrix();
378  double protoChi2 = sfit_->chi2();
379 
380  // Calculate the bunch crossing of the GEM Segment
381  float bx = 0.0;
382  for (auto rh = rechits.begin(); rh != rechits.end(); ++rh) {
383  bx += (*rh)->BunchX();
384  }
385  if (!rechits.empty())
386  bx = bx * 1.0 / (rechits.size());
387 
388  // Calculate the central value and uncertainty of the segment time
389  // if we want to study impact of 2-3ns time resolution on GEM Segment
390  // (if there will be TDCs in readout and not just BX determination)
391  // then implement tof() method for rechits and use this here
392  /*`
393  float averageTime=0.;
394  for (auto rh=rechits.begin(); rh!=rechits.end(); ++rh){
395  GEMEtaPartition thePartition = ensemble.second.find((*rh)->gemId));
396  GlobalPoint pos = (thePartition->toGlobal((*rh)->localPosition());
397  float tof = pos.mag() * 0.01 / 0.2997925 + 25.0*(*rh)->BunchX();
398  averageTime += pos;
399  }
400  if(rechits.size() != 0) averageTime=averageTime/(rechits.size());
401  float timeUncrt=0.;
402  for (auto rh=rechits.begin(); rh!=rechits.end(); ++rh){
403  GEMEtaPartition thePartition = ensemble.second.find((*rh)->gemId));
404  GlobalPoint pos = (thePartition->toGlobal((*rh)->localPosition());
405  float tof = pos.mag() * 0.01 / 0.2997925 + 25.0*(*rh)->BunchX();
406  timeUncrt += pow(tof-averageTime,2);
407  }
408  if(rechits.size() != 0) timeUncrt=timeUncrt/(rechits.size());
409  timeUncrt = sqrt(timeUncrt);
410  */
411 
412  // save all information inside GEMCSCSegment
413  edm::LogVerbatim("GEMSegmentAlgorithm")
414  << "[GEMSegmentAlgorithm::buildSegments] will now wrap fit info in GEMSegment dataformat";
415  GEMSegment tmp(proto_segment, protoIntercept, protoDirection, protoErrors, protoChi2, bx);
416  // GEMSegment tmp(proto_segment, protoIntercept, protoDirection, protoErrors, protoChi2, averageTime, timeUncrt);
417 
418  edm::LogVerbatim("GEMSegmentAlgorithm")
419  << "[GEMSegmentAlgorithm::buildSegments] GEMSegment made in " << tmp.gemDetId();
420  edm::LogVerbatim("GEMSegmentAlgorithm") << "[GEMSegmentAlgorithm::buildSegments] " << tmp;
421 
422  for (auto rh : muonRecHits)
423  rh.reset();
424  gemsegs.push_back(tmp);
425 }
std::shared_ptr< TrackingRecHit > MuonRecHitPtr
Definition: MuonSegFit.h:38
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
unsigned int minHitsPerSegment
std::vector< MuonRecHitPtr > MuonRecHitContainer
Definition: MuonSegFit.h:39
std::unique_ptr< MuonSegFit > sfit_
GEMRecHit * clone() const override
Definition: GEMRecHit.cc:58
CLHEP::HepSymMatrix AlgebraicSymMatrix
EnsembleHitContainer proto_segment
void setPosition(LocalPoint pos)
Set local position.
Definition: GEMRecHit.h:53
tmp
align.sh
Definition: createJobs.py:716
GEMSegmentAlgorithm::ProtoSegments GEMSegmentAlgorithm::chainHits ( const GEMEnsemble ensemble,
const EnsembleHitContainer rechits 
)
private

Definition at line 217 of file GEMSegmentAlgorithm.cc.

References begin, end, mps_fire::i, and isGoodToMerge().

Referenced by run().

218  {
219  ProtoSegments rechits_chains;
220  ProtoSegments seeds;
221  seeds.reserve(rechits.size());
222  std::vector<bool> usedCluster(rechits.size(), false);
223 
224  // split rechits into subvectors and return vector of vectors:
225  // Loop over rechits
226  // Create one seed per hit
227  for (unsigned int i = 0; i < rechits.size(); ++i)
228  seeds.push_back(EnsembleHitContainer(1, rechits[i]));
229 
230  // merge chains that are too close ("touch" each other)
231  for (size_t NNN = 0; NNN < seeds.size(); ++NNN) {
232  for (size_t MMM = NNN + 1; MMM < seeds.size(); ++MMM) {
233  if (usedCluster[MMM] || usedCluster[NNN]) {
234  continue;
235  }
236  // all is in the way we define "good";
237  // try not to "cluster" the hits but to "chain" them;
238  // it does the clustering but also does a better job
239  // for inclined tracks (not clustering them together;
240  // crossed tracks would be still clustered together)
241  // 22.12.09: In fact it is not much more different
242  // than the "clustering", we just introduce another
243  // variable in the game - Z. And it makes sense
244  // to re-introduce Y (or actually wire group mumber)
245  // in a similar way as for the strip number - see
246  // the code below.
247  bool goodToMerge = isGoodToMerge(ensemble, seeds[NNN], seeds[MMM]);
248  if (goodToMerge) {
249  // merge chains!
250  // merge by adding seed NNN to seed MMM and erasing seed NNN
251 
252  // add seed NNN to MMM (lower to larger number)
253  seeds[MMM].insert(seeds[MMM].end(), seeds[NNN].begin(), seeds[NNN].end());
254 
255  // mark seed NNN as used
256  usedCluster[NNN] = true;
257  // we have merged a seed (NNN) to the highter seed (MMM) - need to contimue to
258  // next seed (NNN+1)
259  break;
260  }
261  }
262  }
263 
264  // hand over the final seeds to the output
265  // would be more elegant if we could do the above step with
266  // erasing the merged ones, rather than the
267  for (size_t NNN = 0; NNN < seeds.size(); ++NNN) {
268  if (usedCluster[NNN])
269  continue; //skip seeds that have been marked as used up in merging
270  rechits_chains.push_back(seeds[NNN]);
271  }
272 
273  //***************************************************************
274 
275  return rechits_chains;
276 }
std::vector< const GEMRecHit * > EnsembleHitContainer
Typedefs.
bool isGoodToMerge(const GEMEnsemble &ensemble, const EnsembleHitContainer &newChain, const EnsembleHitContainer &oldChain)
std::vector< EnsembleHitContainer > ProtoSegments
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
GEMSegmentAlgorithm::ProtoSegments GEMSegmentAlgorithm::clusterHits ( const GEMEnsemble ensemble,
const EnsembleHitContainer rechits 
)
private

Utility functions.

Definition at line 95 of file GEMSegmentAlgorithm.cc.

References begin, dXclusBoxMax, dYclusBoxMax, end, Exception, mps_fire::i, LogDebug, DetId::rawId(), running_max, findQualityFiles::size, GeomDet::toGlobal(), GeomDet::toLocal(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by run().

96  {
97  // think how to implement BX requirement here
98 
99  ProtoSegments rechits_clusters; // this is a collection of groups of rechits
100 
101  float dXclus_box = 0.0;
102  float dYclus_box = 0.0;
103 
104  ProtoSegments seeds;
105  seeds.reserve(rechits.size());
106 
107  std::vector<float> running_meanX;
108  running_meanX.reserve(rechits.size());
109  std::vector<float> running_meanY;
110  running_meanY.reserve(rechits.size());
111 
112  std::vector<float> seed_minX;
113  seed_minX.reserve(rechits.size());
114  std::vector<float> seed_maxX;
115  seed_maxX.reserve(rechits.size());
116  std::vector<float> seed_minY;
117  seed_minY.reserve(rechits.size());
118  std::vector<float> seed_maxY;
119  seed_maxY.reserve(rechits.size());
120 
121  // split rechits into subvectors and return vector of vectors:
122  // Loop over rechits
123  // Create one seed per hit
124  for (unsigned int i = 0; i < rechits.size(); ++i) {
125  seeds.push_back(EnsembleHitContainer(1, rechits[i]));
126 
127  GEMDetId rhID = rechits[i]->gemId();
128  const GEMEtaPartition* rhEP = (ensemble.second.find(rhID.rawId()))->second;
129  if (!rhEP)
130  throw cms::Exception("GEMEtaPartition not found")
131  << "Corresponding GEMEtaPartition to GEMDetId: " << rhID << " not found in the GEMEnsemble";
132  const GEMSuperChamber* rhCH = ensemble.first;
133  LocalPoint rhLP_inEtaPartFrame = rechits[i]->localPosition();
134  GlobalPoint rhGP_inCMSFrame = rhEP->toGlobal(rhLP_inEtaPartFrame);
135  LocalPoint rhLP_inChamberFrame = rhCH->toLocal(rhGP_inCMSFrame);
136 
137  running_meanX.push_back(rhLP_inChamberFrame.x());
138  running_meanY.push_back(rhLP_inChamberFrame.y());
139 
140  // set min/max X and Y for box containing the hits in the precluster:
141  seed_minX.push_back(rhLP_inChamberFrame.x());
142  seed_maxX.push_back(rhLP_inChamberFrame.x());
143  seed_minY.push_back(rhLP_inChamberFrame.y());
144  seed_maxY.push_back(rhLP_inChamberFrame.y());
145  }
146 
147  // merge clusters that are too close
148  // measure distance between final "running mean"
149  for (size_t NNN = 0; NNN < seeds.size(); ++NNN) {
150  for (size_t MMM = NNN + 1; MMM < seeds.size(); ++MMM) {
151  if (running_meanX[MMM] == running_max || running_meanX[NNN] == running_max) {
152  LogDebug("GEMSegmentAlgorithm") << "[GEMSegmentAlgorithm::clusterHits]: ALARM! Skipping used seeds, this "
153  "should not happen - inform developers!";
154  continue; //skip seeds that have been used
155  }
156 
157  // calculate cut criteria for simple running mean distance cut:
158  //dXclus = fabs(running_meanX[NNN] - running_meanX[MMM]);
159  //dYclus = fabs(running_meanY[NNN] - running_meanY[MMM]);
160  // calculate minmal distance between precluster boxes containing the hits:
161  if (running_meanX[NNN] > running_meanX[MMM])
162  dXclus_box = seed_minX[NNN] - seed_maxX[MMM];
163  else
164  dXclus_box = seed_minX[MMM] - seed_maxX[NNN];
165  if (running_meanY[NNN] > running_meanY[MMM])
166  dYclus_box = seed_minY[NNN] - seed_maxY[MMM];
167  else
168  dYclus_box = seed_minY[MMM] - seed_maxY[NNN];
169 
170  if (dXclus_box < dXclusBoxMax && dYclus_box < dYclusBoxMax) {
171  // merge clusters!
172  // merge by adding seed NNN to seed MMM and erasing seed NNN
173 
174  // calculate running mean for the merged seed:
175  if (seeds[NNN].size() + seeds[MMM].size() != 0) {
176  running_meanX[MMM] = (running_meanX[NNN] * seeds[NNN].size() + running_meanX[MMM] * seeds[MMM].size()) /
177  (seeds[NNN].size() + seeds[MMM].size());
178  running_meanY[MMM] = (running_meanY[NNN] * seeds[NNN].size() + running_meanY[MMM] * seeds[MMM].size()) /
179  (seeds[NNN].size() + seeds[MMM].size());
180  }
181 
182  // update min/max X and Y for box containing the hits in the merged cluster:
183  if (seed_minX[NNN] < seed_minX[MMM])
184  seed_minX[MMM] = seed_minX[NNN];
185  if (seed_maxX[NNN] > seed_maxX[MMM])
186  seed_maxX[MMM] = seed_maxX[NNN];
187  if (seed_minY[NNN] < seed_minY[MMM])
188  seed_minY[MMM] = seed_minY[NNN];
189  if (seed_maxY[NNN] > seed_maxY[MMM])
190  seed_maxY[MMM] = seed_maxY[NNN];
191 
192  // add seed NNN to MMM (lower to larger number)
193  seeds[MMM].insert(seeds[MMM].end(), seeds[NNN].begin(), seeds[NNN].end());
194 
195  // mark seed NNN as used (at the moment just set running mean to 999999.)
196  running_meanX[NNN] = running_max;
197  running_meanY[NNN] = running_max;
198  // we have merged a seed (NNN) to the highter seed (MMM) - need to contimue to
199  // next seed (NNN+1)
200  break;
201  }
202  }
203  }
204 
205  // hand over the final seeds to the output
206  // would be more elegant if we could do the above step with
207  // erasing the merged ones, rather than the
208  for (size_t NNN = 0; NNN < seeds.size(); ++NNN) {
209  if (running_meanX[NNN] == running_max)
210  continue; //skip seeds that have been marked as used up in merging
211  rechits_clusters.push_back(seeds[NNN]);
212  }
213 
214  return rechits_clusters;
215 }
#define LogDebug(id)
size
Write out results.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
std::vector< const GEMRecHit * > EnsembleHitContainer
Typedefs.
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
T y() const
Definition: PV3DBase.h:60
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
std::vector< EnsembleHitContainer > ProtoSegments
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
T x() const
Definition: PV3DBase.h:59
bool GEMSegmentAlgorithm::isGoodToMerge ( const GEMEnsemble ensemble,
const EnsembleHitContainer newChain,
const EnsembleHitContainer oldChain 
)
private

Definition at line 278 of file GEMSegmentAlgorithm.cc.

References funct::abs(), clusterOnlySameBXRecHits, reco::deltaPhi(), dEtaChainBoxMax, dPhiChainBoxMax, PV3DBase< T, PVType, FrameType >::eta(), PV3DBase< T, PVType, FrameType >::phi(), edm::second(), and GeomDet::toGlobal().

Referenced by chainHits().

280  {
281  bool phiRequirementOK = false; // once it is true in the loop, it is ok to merge
282  bool etaRequirementOK = false; // once it is true in the loop, it is ok to merge
283  bool bxRequirementOK = false; // once it is true in the loop, it is ok to merge
284 
285  for (size_t iRH_new = 0; iRH_new < newChain.size(); ++iRH_new) {
286  int layer_new = (newChain[iRH_new]->gemId().station() - 1) * 2 + newChain[iRH_new]->gemId().layer();
287 
288  const GEMEtaPartition* rhEP = (ensemble.second.find(newChain[iRH_new]->gemId().rawId()))->second;
289  GlobalPoint pos_new = rhEP->toGlobal(newChain[iRH_new]->localPosition());
290 
291  for (size_t iRH_old = 0; iRH_old < oldChain.size(); ++iRH_old) {
292  int layer_old = (oldChain[iRH_old]->gemId().station() - 1) * 2 + oldChain[iRH_old]->gemId().layer();
293  // Layers - hits on the same layer should not be allowed ==> if abs(layer_new - layer_old) > 0 is ok. if = 0 is false
294  if (layer_new == layer_old)
295  return false;
296 
297  const GEMEtaPartition* oldrhEP = (ensemble.second.find(oldChain[iRH_old]->gemId().rawId()))->second;
298  GlobalPoint pos_old = oldrhEP->toGlobal(oldChain[iRH_old]->localPosition());
299 
300  // Eta & Phi- to be chained, two hits need also to be "close" in phi and eta
301  if (phiRequirementOK == false)
302  phiRequirementOK = std::abs(reco::deltaPhi(float(pos_new.phi()), float(pos_old.phi()))) < dPhiChainBoxMax;
303  if (etaRequirementOK == false)
304  etaRequirementOK = std::abs(pos_new.eta() - pos_old.eta()) < dEtaChainBoxMax;
305  // and they should have a time difference compatible with the hypothesis
306  // that the rechits originate from the same particle, but were detected in different layers
307  if (bxRequirementOK == false) {
309  bxRequirementOK = true;
310  } else {
311  if (newChain[iRH_new]->BunchX() == oldChain[iRH_old]->BunchX())
312  bxRequirementOK = true;
313  }
314  }
315 
316  if (phiRequirementOK && etaRequirementOK && bxRequirementOK)
317  return true;
318  }
319  }
320  return false;
321 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
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
U second(std::pair< T, U > const &p)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T eta() const
Definition: PV3DBase.h:73
std::vector< GEMSegment > GEMSegmentAlgorithm::run ( const GEMEnsemble ensemble,
const EnsembleHitContainer rechits 
)
override

Build segments for all desired groups of hits

Definition at line 58 of file GEMSegmentAlgorithm.cc.

References buildSegments(), chainHits(), clusterHits(), preClustering, and preClustering_useChaining.

58  {
59  // pre-cluster rechits and loop over all sub clusters separately
60  std::vector<GEMSegment> segments_temp;
61  std::vector<GEMSegment> segments;
62  ProtoSegments rechits_clusters; // this is a collection of groups of rechits
63 
64  if (preClustering) {
65  // run a pre-clusterer on the given rechits to split obviously separated segment seeds:
67  // it uses X,Y,Z information; there are no configurable parameters used;
68  // the X, Y, Z "cuts" are just (much) wider than reasonable high pt segments
69  edm::LogVerbatim("GEMSegmentAlgorithm") << "[GEMSegmentAlgorithm::run] preClustering :: use Chaining";
70  rechits_clusters = this->chainHits(ensemble, rechits);
71  } else {
72  // it uses X,Y information + configurable parameters
73  edm::LogVerbatim("GEMSegmentAlgorithm") << "[GEMSegmentAlgorithm::run] Clustering";
74  rechits_clusters = this->clusterHits(ensemble, rechits);
75  }
76  // loop over the found clusters:
77  edm::LogVerbatim("GEMSegmentAlgorithm") << "[GEMSegmentAlgorithm::run] Loop over clusters and build segments";
78  for (auto sub_rechits = rechits_clusters.begin(); sub_rechits != rechits_clusters.end(); ++sub_rechits) {
79  // clear the buffer for the subset of segments:
80  segments_temp.clear();
81  // build the subset of segments:
82  this->buildSegments(ensemble, (*sub_rechits), segments_temp);
83  // add the found subset of segments to the collection of all segments in this chamber:
84  segments.insert(segments.end(), segments_temp.begin(), segments_temp.end());
85  }
86 
87  return segments;
88  } else {
89  this->buildSegments(ensemble, rechits, segments);
90  return segments;
91  }
92 }
ProtoSegments chainHits(const GEMEnsemble &ensemble, const EnsembleHitContainer &rechits)
ProtoSegments clusterHits(const GEMEnsemble &ensemble, const EnsembleHitContainer &rechits)
Utility functions.
std::vector< EnsembleHitContainer > ProtoSegments
void buildSegments(const GEMEnsemble &ensemble, const EnsembleHitContainer &rechits, std::vector< GEMSegment > &gemsegs)

Member Data Documentation

bool GEMSegmentAlgorithm::clusterOnlySameBXRecHits
private

Definition at line 72 of file GEMSegmentAlgorithm.h.

Referenced by GEMSegmentAlgorithm(), and isGoodToMerge().

bool GEMSegmentAlgorithm::debug
private
double GEMSegmentAlgorithm::dEtaChainBoxMax
private

Definition at line 70 of file GEMSegmentAlgorithm.h.

Referenced by GEMSegmentAlgorithm(), and isGoodToMerge().

double GEMSegmentAlgorithm::dPhiChainBoxMax
private

Definition at line 69 of file GEMSegmentAlgorithm.h.

Referenced by GEMSegmentAlgorithm(), and isGoodToMerge().

double GEMSegmentAlgorithm::dXclusBoxMax
private

Definition at line 66 of file GEMSegmentAlgorithm.h.

Referenced by clusterHits(), and GEMSegmentAlgorithm().

double GEMSegmentAlgorithm::dYclusBoxMax
private

Definition at line 67 of file GEMSegmentAlgorithm.h.

Referenced by clusterHits(), and GEMSegmentAlgorithm().

int GEMSegmentAlgorithm::maxRecHitsInCluster
private

Definition at line 71 of file GEMSegmentAlgorithm.h.

Referenced by GEMSegmentAlgorithm().

unsigned int GEMSegmentAlgorithm::minHitsPerSegment
private

Definition at line 64 of file GEMSegmentAlgorithm.h.

Referenced by buildSegments(), and GEMSegmentAlgorithm().

const std::string GEMSegmentAlgorithm::myName
private

Definition at line 60 of file GEMSegmentAlgorithm.h.

bool GEMSegmentAlgorithm::preClustering
private

Definition at line 65 of file GEMSegmentAlgorithm.h.

Referenced by GEMSegmentAlgorithm(), and run().

bool GEMSegmentAlgorithm::preClustering_useChaining
private

Definition at line 68 of file GEMSegmentAlgorithm.h.

Referenced by GEMSegmentAlgorithm(), and run().

EnsembleHitContainer GEMSegmentAlgorithm::proto_segment
private

Definition at line 74 of file GEMSegmentAlgorithm.h.

Referenced by buildSegments().

float GEMSegmentAlgorithm::running_max = std::numeric_limits<float>::max()
staticprivate

Definition at line 77 of file GEMSegmentAlgorithm.h.

Referenced by clusterHits().

std::unique_ptr<MuonSegFit> GEMSegmentAlgorithm::sfit_
private

Definition at line 78 of file GEMSegmentAlgorithm.h.

Referenced by buildSegments().

GEMDetId GEMSegmentAlgorithm::theChamberId
private

Definition at line 75 of file GEMSegmentAlgorithm.h.