CMS 3D CMS Logo

ME0SegAlgoRU.cc
Go to the documentation of this file.
1 
8 #include "ME0SegAlgoRU.h"
9 #include "MuonSegFit.h"
15 
16 #include <algorithm>
17 #include <cmath>
18 #include <iostream>
19 #include <string>
20 
21 #include <Math/Functions.h>
22 #include <Math/SVector.h>
23 #include <Math/SMatrix.h>
24 
25 
26 
28 : ME0SegmentAlgorithmBase(ps), myName("ME0SegAlgoRU") {
29 
30  allowWideSegments = ps.getParameter<bool>("allowWideSegments");
31  doCollisions = ps.getParameter<bool>("doCollisions");
32 
33  stdParameters.maxChi2Additional = ps.getParameter<double>("maxChi2Additional");
34  stdParameters.maxChi2Prune = ps.getParameter<double>("maxChi2Prune" );
35  stdParameters.maxChi2GoodSeg = ps.getParameter<double>("maxChi2GoodSeg" ) ;
36  stdParameters.maxPhiSeeds = ps.getParameter<double>("maxPhiSeeds" ) ;
37  stdParameters.maxPhiAdditional = ps.getParameter<double>("maxPhiAdditional" );
38  stdParameters.maxETASeeds = ps.getParameter<double>("maxETASeeds" );
39  stdParameters.maxTOFDiff = ps.getParameter<double>("maxTOFDiff" );
40  stdParameters.requireCentralBX = ps.getParameter<bool>("requireCentralBX" );
41  stdParameters.minNumberOfHits = ps.getParameter<unsigned int>("minNumberOfHits" );
43 
50 
51 
60 
61 
62  LogDebug("ME0SegAlgoRU") << myName << " has algorithm cuts set to: \n"
63  << "--------------------------------------------------------------------\n"
64  << "allowWideSegments = " <<allowWideSegments << "\n"
65  << "doCollisions = " <<doCollisions << "\n"
66  << "maxChi2Additional = " <<stdParameters.maxChi2Additional<< "\n"
67  << "maxChi2Prune = " <<stdParameters.maxChi2Prune << "\n"
68  << "maxChi2GoodSeg = " <<stdParameters.maxChi2GoodSeg << "\n"
69  << "maxPhiSeeds = " <<stdParameters.maxPhiSeeds << "\n"
70  << "maxPhiAdditional = " <<stdParameters.maxPhiAdditional << "\n"
71  << "maxETASeeds = " <<stdParameters.maxETASeeds << "\n"
72  << "maxTOFDiff = " <<stdParameters.maxTOFDiff << "\n"
73  << std::endl;
74 
75  theChamber=nullptr;
76 
77 }
78 
79 std::vector<ME0Segment> ME0SegAlgoRU::run(const ME0Chamber * chamber, const HitAndPositionContainer& rechits){
80 
81 #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
82  ME0DetId chId(chamber->id());
83  edm::LogVerbatim("ME0SegAlgoRU") << "[ME0SegmentAlgorithm::run] build segments in chamber " << chId << " which contains "<<rechits.size()<<" rechits";
84  for(unsigned int iH = 0; iH < rechits.size(); ++iH){
85  auto me0id = rechits[iH].rh->me0Id();
86  auto rhLP = rechits[iH].lp;
87  edm::LogVerbatim("ME0SegAlgoRU") << "[RecHit :: Loc x = "<<std::showpos<<std::setw(9)<<rhLP.x()<<" Glb y = "<<std::showpos<<std::setw(9)<<rhLP.y()<<" Time = "<<std::showpos<<rechits[iH].rh->tof()<<" -- "<<me0id.rawId()<<" = "<<me0id<<" ]"<<std::endl;
88  }
89 #endif
90 
91 
92  if (rechits.size() < 3 || rechits.size()>300){
93  return std::vector<ME0Segment>();
94  }
95 
97 
98  std::vector<unsigned int> recHits_per_layer(6,0);
99  for(unsigned int iH = 0; iH < rechits.size(); ++iH) {
100  recHits_per_layer[rechits[iH].layer-1]++;
101  }
102 
103  BoolContainer used(rechits.size(),false);
104 
105  // We have at least 2 hits. We intend to try all possible pairs of hits to start
106  // segment building. 'All possible' means each hit lies on different layers in the chamber.
107  // after all same size segs are build we get rid of the overcrossed segments using the chi2 criteria
108  // the hits from the segs that are left are marked as used and are not added to segs in future iterations
109  // the hits from 3p segs are marked as used separately in order to try to assamble them in longer segments
110  // in case there is a second pass
111 
112  // Choose first hit (as close to IP as possible) h1 and second hit
113  // (as far from IP as possible) h2 To do this we iterate over hits
114  // in the chamber by layer - pick two layers. Then we
115  // iterate over hits within each of these layers and pick h1 and h2
116  // these. If they are 'close enough' we build an empty
117  // segment. Then try adding hits to this segment.
118 
119  std::vector<ME0Segment> segments;
120 
121  auto doStd = [&] () {
122  for(unsigned int n_seg_min = 6u; n_seg_min >= stdParameters.minNumberOfHits; --n_seg_min)
123  lookForSegments(stdParameters,n_seg_min,rechits,recHits_per_layer, used, segments);
124  };
125  auto doDisplaced = [&] () {
126  for(unsigned int n_seg_min = 6u; n_seg_min >= displacedParameters.minNumberOfHits; --n_seg_min)
127  lookForSegments(displacedParameters,n_seg_min,rechits,recHits_per_layer, used,segments);
128  };
129  // Not currently used
130  // auto doWide = [&] () {
131  // for(unsigned int n_seg_min = 6u; n_seg_min >= wideParameters.minNumberOfHits; --n_seg_min)
132  // lookForSegments(wideParameters,n_seg_min,rechits,recHits_per_layer, used,segments);
133  // };
134  auto printSegments = [&] {
135 #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
136  for(unsigned int iS = 0; iS < segments.size(); ++iS) {
137  const auto& seg = segments[iS];
138  ME0DetId chId(seg.me0DetId());
139  const auto& rechits = seg.specificRecHits();
140  edm::LogVerbatim("ME0SegAlgoRU") << "[ME0SegAlgoRU] segment in chamber " << chId << " which contains "<<rechits.size()<<" rechits and with specs: \n"<<seg;
141  for (auto rh=rechits.begin(); rh!=rechits.end(); ++rh){
142  auto me0id = rh->me0Id();
143  edm::LogVerbatim("ME0SegAlgoRU") << "[RecHit :: Loc x = "<<std::showpos<<std::setw(9)<<rh->localPosition().x()<<" Loc y = "<<std::showpos<<std::setw(9)<<rh->localPosition().y()<<" Time = "<<std::showpos<<rh->tof()<<" -- "<<me0id.rawId()<<" = "<<me0id<<" ]";
144  }
145  }
146 #endif
147  };
148 
149 
150  //If we arent doing collisions, do a single iteration
151  if(!doCollisions){
152  doDisplaced();
153  printSegments();
154  return segments;
155  }
156 
157  //Iteration 1: STD processing
158  doStd();
159 
160  if(false){
161  //How the CSC algorithm ~does iterations. for now not considering
162  //displaced muons will not worry about it later
163  //Iteration 2a: If we don't allow wide segments simply do displaced
164  // Or if we already found a segment simply skip to displaced
165  if(!allowWideSegments || !segments.empty()){
166  doDisplaced();
167  return segments;
168  }
169  //doWide();
170  doDisplaced();
171  }
172  printSegments();
173  return segments;
174 }
175 
176 void ME0SegAlgoRU::lookForSegments( const SegmentParameters& params, const unsigned int n_seg_min,
177  const HitAndPositionContainer& rechits, const std::vector<unsigned int>& recHits_per_layer,
178  BoolContainer& used, std::vector<ME0Segment>& segments) const {
179  auto ib = rechits.begin();
180  auto ie = rechits.end();
181  std::vector<std::pair<float,HitAndPositionPtrContainer> > proto_segments;
182  // the first hit is taken from the back
183  for (auto i1 = ib; i1 != ie; ++i1) {
184  const auto& h1 = *i1;
185 
186  //skip if rh is used and the layer tat has big rh multiplicity(>25RHs)
187  if(used[h1.idx]) continue;
188  if(recHits_per_layer[h1.layer-1]>100) continue;
189 
190  // bool segok = false;
191  // the second hit from the front
192  for (auto i2 = ie-1; i2 != i1; --i2) {
193  // if(segok) break; //Currently turned off
194  const auto& h2 = *i2;
195 
196  //skip if rh is used and the layer tat has big rh multiplicity(>25RHs)
197  if(used[h2.idx]) continue;
198  if(recHits_per_layer[h2.layer-1]>100) continue;
199 
200  //Stop if the distance between layers is not large enough
201  if((std::abs(int(h2.layer) - int(h1.layer)) + 1) < int(n_seg_min)) break;
202 
203  if(std::fabs(h1.rh->tof()-h2.rh->tof()) > params.maxTOFDiff + 1.0 )continue;
204  if(!areHitsCloseInEta(params.maxETASeeds, params.requireBeamConstr, h1.gp, h2.gp)) continue;
205  if(!areHitsCloseInGlobalPhi(params.maxPhiSeeds,abs(int(h2.layer) - int(h1.layer)), h1.gp, h2.gp)) continue;
206 
207  HitAndPositionPtrContainer current_proto_segment;
208  std::unique_ptr<MuonSegFit> current_fit;
209  current_fit = addHit(current_proto_segment,h1);
210  current_fit = addHit(current_proto_segment,h2);
211 
212  tryAddingHitsToSegment(params.maxTOFDiff,params.maxETASeeds, params.maxPhiAdditional, params.maxChi2Additional, current_fit,current_proto_segment, used,i1,i2);
213 
214  if(current_proto_segment.size() > n_seg_min)
215  pruneBadHits(params.maxChi2Prune,current_proto_segment,current_fit,n_seg_min);
216 
217  edm::LogVerbatim("ME0SegAlgoRU") << "[ME0SegAlgoRU::lookForSegments] # of hits in segment " << current_proto_segment.size() <<" min # "<< n_seg_min <<" => "<< (current_proto_segment.size() >= n_seg_min) << " chi2/ndof "<<current_fit->chi2()/current_fit->ndof()<<" => "<<(current_fit->chi2()/current_fit->ndof() < params.maxChi2GoodSeg ) <<std::endl;
218 
219  if(current_proto_segment.size() < n_seg_min) continue;
220  const float current_metric = current_fit->chi2()/current_fit->ndof();
221  if(current_metric > params.maxChi2GoodSeg) continue;
222 
223  if(params.requireCentralBX){
224  int nCentral = 0;
225  int nNonCentral =0;
226  for(const auto* rh : current_proto_segment ) {
227  if(std::fabs(rh->rh->tof()) < 2 ) nCentral++;
228  else nNonCentral++;
229  }
230  if(nNonCentral >= nCentral) continue;
231  }
232  // segok = true;
233 
234  proto_segments.emplace_back( current_metric, current_proto_segment);
235  }
236 
237  }
238  addUniqueSegments(proto_segments,segments,used);
239 
240 }
241 
242 void ME0SegAlgoRU::addUniqueSegments(SegmentByMetricContainer& proto_segments, std::vector<ME0Segment>& segments,BoolContainer& used ) const {
243  std::sort(proto_segments.begin(),proto_segments.end(),
244  [](const std::pair<float,HitAndPositionPtrContainer> & a,
245  const std::pair<float,HitAndPositionPtrContainer> & b) { return a.first < b.first;});
246 
247  //Now add to the collect based on minChi2 marking the hits as used after
248  std::vector<unsigned int> usedHits;
249  for(unsigned int iS = 0; iS < proto_segments.size(); ++iS){
250  HitAndPositionPtrContainer currentProtoSegment = proto_segments[iS].second;
251 
252  //check to see if we already used thes hits this round
253  bool alreadyFilled=false;
254  for(unsigned int iH = 0; iH < currentProtoSegment.size(); ++iH){
255  for(unsigned int iOH = 0; iOH < usedHits.size(); ++iOH){
256  if(usedHits[iOH]!=currentProtoSegment[iH]->idx) continue;
257  alreadyFilled = true;
258  break;
259  }
260  }
261  if(alreadyFilled) continue;
262  for(const auto* h : currentProtoSegment){
263  usedHits.push_back(h->idx);
264  used[h->idx] = true;
265  }
266 
267  std::unique_ptr<MuonSegFit> current_fit = makeFit(currentProtoSegment);
268 
269  // Create an actual ME0Segment - retrieve all info from the fit
270  // calculate the timing fron rec hits associated to the TrackingRecHits used
271  // to fit the segment
272  float averageTime=0.;
273  for(const auto* h : currentProtoSegment){
274  averageTime += h->rh->tof();
275  }
276  averageTime /= float(currentProtoSegment.size());
277  float timeUncrt=0.;
278  for(const auto* h : currentProtoSegment){
279  timeUncrt += (h->rh->tof()-averageTime)*(h->rh->tof()-averageTime);
280  }
281  timeUncrt = std::sqrt(timeUncrt/float(currentProtoSegment.size()-1));
282 
283  std::sort(currentProtoSegment.begin(),currentProtoSegment.end(),
284  [](const HitAndPosition* a, const HitAndPosition *b) {return a->layer < b->layer;}
285  );
286 
287  std::vector<const ME0RecHit*> bareRHs; bareRHs.reserve(currentProtoSegment.size());
288  for(const auto* rh : currentProtoSegment) bareRHs.push_back(rh->rh);
289  const float dPhi = theChamber->computeDeltaPhi(current_fit->intercept(),current_fit->localdir());
290  ME0Segment temp(bareRHs, current_fit->intercept(),
291  current_fit->localdir(), current_fit->covarianceMatrix(), current_fit->chi2(), averageTime, timeUncrt, dPhi);
292  segments.push_back(temp);
293 
294 
295  }
296 }
297 
298 void ME0SegAlgoRU::tryAddingHitsToSegment(const float maxTOF, const float maxETA, const float maxPhi,const float maxChi2, std::unique_ptr<MuonSegFit>& current_fit, HitAndPositionPtrContainer& proto_segment,
299  const BoolContainer& used, HitAndPositionContainer::const_iterator i1, HitAndPositionContainer::const_iterator i2) const {
300  // Iterate over the layers with hits in the chamber
301  // Skip the layers containing the segment endpoints
302  // Test each hit on the other layers to see if it is near the segment
303  // If it is, see whether there is already a hit on the segment from the same layer
304  // - if so, and there are more than 2 hits on the segment, copy the segment,
305  // replace the old hit with the new hit. If the new segment chi2 is better
306  // then replace the original segment with the new one (by swap)
307  // - if not, copy the segment, add the hit. If the new chi2/dof is still satisfactory
308  // then replace the original segment with the new one (by swap)
309 
310  //Hits are ordered by layer, "i1" is the inner hit and i2 is the outer hit
311  //so possible hits to add must be between these two iterators
312  for(auto iH = i1 + 1; iH != i2; ++iH ){
313  if(iH->layer == i1->layer) continue;
314  if(iH->layer == i2->layer) break;
315  if(used[iH->idx]) continue;
316  if(!areHitsConsistentInTime(maxTOF,proto_segment,*iH)) continue;
317  if (!isHitNearSegment(maxETA,maxPhi,current_fit,proto_segment,*iH)) continue;
318  if(hasHitOnLayer(proto_segment,iH->layer))
319  compareProtoSegment(current_fit,proto_segment,*iH);
320  else
321  increaseProtoSegment(maxChi2, current_fit,proto_segment,*iH);
322  }
323 }
324 
325 bool ME0SegAlgoRU::areHitsCloseInEta(const float maxETA, const bool beamConst, const GlobalPoint& h1, const GlobalPoint& h2) const {
326  float diff = 0;
327  diff = std::fabs(h1.eta() - h1.eta());
328  edm::LogVerbatim("ME0SegAlgoRU") << "[ME0SegAlgoRU::areHitsCloseInEta] gp1 = "<<h1<<" in eta part = "<<h1.eta() <<" and gp2 = "<<h2<<" in eta part = "<<h2.eta() <<" ==> dEta = "<<diff<<" ==> return "<<(diff < 0.1)<<std::endl;
329  return (diff < std::max(maxETA,float(0.01)) ); //temp for floating point comparision...maxEta is the difference between partitions, so x1.5 to take into account non-circle geom.
330 }
331 
332 bool ME0SegAlgoRU::areHitsCloseInGlobalPhi(const float maxPHI, const unsigned int nLayDisp, const GlobalPoint& h1, const GlobalPoint& h2) const {
333  float dphi12 = deltaPhi(h1.barePhi(),h2.barePhi());
334  edm::LogVerbatim("ME0SegAlgoRU") << "[ME0SegAlgoRU::areHitsCloseInGlobalPhi] gp1 = "<<h1<<" and gp2 = "<<h2<<" ==> dPhi = "<<dphi12<<" ==> return "<<(fabs(dphi12) < std::max(maxPHI,float(0.02)))<<std::endl;
335  return fabs(dphi12) < std::max(maxPHI, float(float(nLayDisp)*0.004));
336 }
337 
338 bool ME0SegAlgoRU::isHitNearSegment(const float maxETA, const float maxPHI, const std::unique_ptr<MuonSegFit>& fit, const HitAndPositionPtrContainer& proto_segment, const HitAndPosition& h) const {
339  //Get average eta, based on the two seeds...asssumes that we have not started pruning yet!
340  const float avgETA = (proto_segment[1]->gp.eta() + proto_segment[0]->gp.eta())/2.;
341  // edm::LogVerbatim("ME0SegAlgoRU") << "[ME0SegAlgoRU::isHitNearSegment] average eta = "<<avgETA<<" additionalHit eta = "<<h.gp.eta() <<" ==> dEta = "<<std::fabs(h.gp.eta() - avgETA) <<" ==> return "<<(std::fabs(h.gp.eta() - avgETA) < std::max(maxETA,float(0.01) ))<<std::endl;
342  if(std::fabs(h.gp.eta() - avgETA) > std::max(maxETA,float(0.01) )) return false;
343 
344  //Now check the dPhi based on the segment fit
345  GlobalPoint globIntercept = globalAtZ(fit, h.lp.z());
346  float dPhi = deltaPhi(h.gp.barePhi(),globIntercept.phi());
347  //check to see if it is inbetween the two rolls of the outer and inner hits
348  // edm::LogVerbatim("ME0SegAlgoRU") << "[ME0SegAlgoRU::isHitNearSegment] projected phi = "<<globIntercept.phi()<<" additionalHit phi = "<<h.gp.barePhi() <<" ==> dPhi = "<<dPhi <<" ==> return "<<(std::fabs(dPhi) < std::max(maxPHI,float(0.001)))<<std::endl;
349  return (std::fabs(dPhi) < std::max(maxPHI,float(0.001)));
350 }
351 
352 bool ME0SegAlgoRU::areHitsConsistentInTime(const float maxTOF, const HitAndPositionPtrContainer& proto_segment, const HitAndPosition& h) const {
353  std::vector<float> tofs; tofs.reserve(proto_segment.size() + 1);
354  tofs.push_back(h.rh->tof());
355  for(const auto* ih : proto_segment) tofs.push_back(ih->rh->tof());
356  std::sort(tofs.begin(),tofs.end());
357  if(std::fabs(tofs.front() - tofs.back()) < maxTOF +1.0 ) return true;
358  return false;
359 }
360 
361 GlobalPoint ME0SegAlgoRU::globalAtZ(const std::unique_ptr<MuonSegFit>& fit, float z) const {
362  float x = fit->xfit(z);
363  float y = fit->yfit(z);
364  return theChamber->toGlobal(LocalPoint(x,y,z));
365 }
366 
367 std::unique_ptr<MuonSegFit> ME0SegAlgoRU::addHit( HitAndPositionPtrContainer& proto_segment, const HitAndPosition& aHit) const {
368  proto_segment.push_back(&aHit);
369  // make a fit
370  return makeFit(proto_segment);
371 }
372 
373 std::unique_ptr<MuonSegFit> ME0SegAlgoRU::makeFit(const HitAndPositionPtrContainer& proto_segment) const {
374  // for ME0 we take the me0rechit from the proto_segment we transform into Tracking Rechits
375  // the local rest frame is the ME0Chamber
377  for (auto rh=proto_segment.begin();rh<proto_segment.end(); rh++){
378  ME0RecHit *newRH = (*rh)->rh->clone();
379  newRH->setPosition((*rh)->lp);
380  MuonSegFit::MuonRecHitPtr trkRecHit(newRH);
381  muonRecHits.push_back(trkRecHit);
382  }
383  std::unique_ptr<MuonSegFit> currentFit(new MuonSegFit(muonRecHits));
384  currentFit->fit();
385  return currentFit;
386 }
387 
388 void ME0SegAlgoRU::pruneBadHits(const float maxChi2, HitAndPositionPtrContainer& proto_segment, std::unique_ptr<MuonSegFit>& fit, const unsigned int n_seg_min) const{
389  while(proto_segment.size() > n_seg_min && fit->chi2()/fit->ndof() > maxChi2){
390  float maxDev = -1;
391  HitAndPositionPtrContainer::iterator worstHit;
392  for(auto it = proto_segment.begin(); it != proto_segment.end(); ++it){
393  const float dev = getHitSegChi2(fit,*(*it)->rh);
394  if(dev < maxDev) continue;
395  maxDev = dev;
396  worstHit = it;
397  }
398  edm::LogVerbatim("ME0SegAlgoRU") << "[ME0SegAlgoRU::pruneBadHits] pruning one hit-> layer: "<< (*worstHit)->layer <<" eta: "<< (*worstHit)->gp.eta() <<" phi: "<<(*worstHit)->gp.phi()<<" old chi2/dof: "<<fit->chi2()/fit->ndof() << std::endl;
399  proto_segment.erase( worstHit);
400  fit = makeFit(proto_segment);
401  }
402 }
403 
404 float ME0SegAlgoRU::getHitSegChi2(const std::unique_ptr<MuonSegFit>& fit, const ME0RecHit& hit) const{
405  const auto lp = hit.localPosition();
406  const auto le = hit.localPositionError();
407  const float du = fit->xdev(lp.x(),lp.z());
408  const float dv = fit->ydev(lp.y(),lp.z());
409 
410  ROOT::Math::SMatrix<double,2,2,ROOT::Math::MatRepSym<double,2> > IC;
411  IC(0,0) = le.xx();
412  IC(1,0) = le.xy();
413  IC(1,1) = le.yy();
414 
415  // Invert covariance matrix
416  IC.Invert();
417  return du*du*IC(0,0) + 2.*du*dv*IC(0,1) + dv*dv*IC(1,1);
418 }
419 
420 bool ME0SegAlgoRU::hasHitOnLayer(const HitAndPositionPtrContainer& proto_segment, const unsigned int layer) const {
421  for(const auto* h : proto_segment) if(h->layer == layer) return true;
422  return false;
423 }
424 
425 void ME0SegAlgoRU::compareProtoSegment(std::unique_ptr<MuonSegFit>& current_fit, HitAndPositionPtrContainer& current_proto_segment, const HitAndPosition& new_hit) const {
426  const HitAndPosition * old_hit = nullptr;
427  HitAndPositionPtrContainer new_proto_segment = current_proto_segment;
428 
429  HitAndPositionPtrContainer::const_iterator it;
430  for (auto it = new_proto_segment.begin(); it != new_proto_segment.end();) {
431  if ((*it)->layer == new_hit.layer) {
432  old_hit = *it;
433  it = new_proto_segment.erase(it);
434  } else {
435  ++it;
436  }
437  }
438  if(old_hit == nullptr) return;
439  auto new_fit = addHit(new_proto_segment,new_hit);
440 
441  //If on the same strip but different BX choose the closest
442  bool useNew = false;
443  if(old_hit->lp == new_hit.lp ){
444  float avgtof = 0;
445  for(const auto* h : current_proto_segment)
446  if(old_hit != h) avgtof += h->rh->tof();
447  avgtof /= float(current_proto_segment.size() - 1);
448  if(std::abs(avgtof - new_hit.rh->tof() ) <
449  std::abs(avgtof - old_hit->rh->tof() )
450  ) useNew = true;
451  } //otherwise base it on chi2
452  else if(new_fit->chi2() < current_fit->chi2()) useNew = true;
453 
454  if(useNew){
455  current_proto_segment = new_proto_segment;
456  current_fit = std::move(new_fit);
457  }
458 
459 }
460 
461 void ME0SegAlgoRU::increaseProtoSegment(const float maxChi2, std::unique_ptr<MuonSegFit>& current_fit, HitAndPositionPtrContainer& current_proto_segment, const HitAndPosition& new_hit) const {
462  HitAndPositionPtrContainer new_proto_segment = current_proto_segment;
463  auto new_fit = addHit(new_proto_segment,new_hit);
464  // edm::LogVerbatim("ME0SegAlgoRU") << "[ME0SegAlgoRU::increaseProtoSegment] new chi2 = "<<new_fit->chi2()<<" new chi2/dof = "<<new_fit->chi2()/new_fit->ndof() <<" ==> add: " << (new_fit->chi2()/new_fit->ndof() < maxChi2 ) <<std::endl;
465  if(new_fit->chi2()/new_fit->ndof() < maxChi2 ){
466  current_proto_segment = new_proto_segment;
467  current_fit = std::move(new_fit);
468  }
469 }
#define LogDebug(id)
std::shared_ptr< TrackingRecHit > MuonRecHitPtr
Definition: MuonSegFit.h:41
LocalError localPositionError() const override
Return the 3-dimensional error on the local position.
Definition: ME0RecHit.h:53
T getParameter(std::string const &) const
float xx() const
Definition: LocalError.h:24
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
void setPosition(LocalPoint pos)
Set local position.
Definition: ME0RecHit.h:72
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
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< ME0Segment > &segments) const
bool areHitsCloseInGlobalPhi(const float maxPHI, const unsigned int nLayDisp, const GlobalPoint &h1, const GlobalPoint &h2) const
std::vector< std::pair< float, HitAndPositionPtrContainer > > SegmentByMetricContainer
Definition: ME0SegAlgoRU.h:51
SegmentParameters displacedParameters
Definition: ME0SegAlgoRU.h:106
void increaseProtoSegment(const float maxChi2, std::unique_ptr< MuonSegFit > &current_fit, HitAndPositionPtrContainer &current_proto_segment, const HitAndPosition &new_hit) const
std::unique_ptr< MuonSegFit > makeFit(const HitAndPositionPtrContainer &proto_segment) const
ME0DetId id() const
Return the ME0DetId of this chamber.
Definition: ME0Chamber.cc:14
std::vector< HitAndPosition > HitAndPositionContainer
std::vector< const HitAndPosition * > HitAndPositionPtrContainer
T barePhi() const
Definition: PV3DBase.h:68
void tryAddingHitsToSegment(const float maxTOF, 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
void addUniqueSegments(SegmentByMetricContainer &proto_segments, std::vector< ME0Segment > &segments, BoolContainer &used) const
GlobalPoint globalAtZ(const std::unique_ptr< MuonSegFit > &fit, float z) const
LocalPoint localPosition() const override
Return the 3-dimensional local position.
Definition: ME0RecHit.h:47
ME0SegAlgoRU(const edm::ParameterSet &ps)
Constructor.
Definition: ME0SegAlgoRU.cc:27
float tof() const
Definition: ME0RecHit.h:95
float computeDeltaPhi(const LocalPoint &position, const LocalVector &direction) const
Definition: ME0Chamber.cc:82
const std::string myName
Definition: ME0SegAlgoRU.h:101
std::vector< bool > BoolContainer
Definition: ME0SegAlgoRU.h:50
T sqrt(T t)
Definition: SSEVec.h:18
void pruneBadHits(const float maxChi2, HitAndPositionPtrContainer &proto_segment, std::unique_ptr< MuonSegFit > &fit, const unsigned int n_seg_min) const
T z() const
Definition: PV3DBase.h:64
std::vector< MuonRecHitPtr > MuonRecHitContainer
Definition: MuonSegFit.h:42
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool areHitsConsistentInTime(const float maxTOF, const HitAndPositionPtrContainer &proto_segment, const HitAndPosition &h) 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 ME0RecHit &hit) const
SegmentParameters stdParameters
Definition: ME0SegAlgoRU.h:105
bool isHitNearSegment(const float maxETA, const float maxPHI, const std::unique_ptr< MuonSegFit > &fit, const HitAndPositionPtrContainer &proto_segment, const HitAndPosition &h) const
bool hasHitOnLayer(const HitAndPositionPtrContainer &proto_segment, const unsigned int layer) const
ME0RecHit * clone() const override
Definition: ME0RecHit.cc:47
double b
Definition: hdecay.h:120
const ME0Chamber * theChamber
Definition: ME0SegAlgoRU.h:110
T eta() const
Definition: PV3DBase.h:76
std::vector< ME0Segment > run(const ME0Chamber *chamber, const HitAndPositionContainer &rechits) override
Definition: ME0SegAlgoRU.cc:79
bool areHitsCloseInEta(const float maxETA, const bool beamConst, const GlobalPoint &h1, const GlobalPoint &h2) const
double a
Definition: hdecay.h:121
bool allowWideSegments
Definition: ME0SegAlgoRU.h:103
SegmentParameters wideParameters
Definition: ME0SegAlgoRU.h:107
std::unique_ptr< MuonSegFit > addHit(HitAndPositionPtrContainer &proto_segment, const HitAndPosition &aHit) const
def move(src, dest)
Definition: eostools.py:510
ib
Definition: cuy.py:661