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=0;
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  auto doWide = [&] () {
130  for(unsigned int n_seg_min = 6u; n_seg_min >= wideParameters.minNumberOfHits; --n_seg_min)
131  lookForSegments(wideParameters,n_seg_min,rechits,recHits_per_layer, used,segments);
132  };
133  auto printSegments = [&] {
134 #ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
135  for(unsigned int iS = 0; iS < segments.size(); ++iS) {
136  const auto& seg = segments[iS];
137  ME0DetId chId(seg.me0DetId());
138  const auto& rechits = seg.specificRecHits();
139  edm::LogVerbatim("ME0SegAlgoRU") << "[ME0SegAlgoRU] segment in chamber " << chId << " which contains "<<rechits.size()<<" rechits and with specs: \n"<<seg;
140  for (auto rh=rechits.begin(); rh!=rechits.end(); ++rh){
141  auto me0id = rh->me0Id();
142  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<<" ]";
143  }
144  }
145 #endif
146  };
147 
148 
149  //If we arent doing collisions, do a single iteration
150  if(!doCollisions){
151  doDisplaced();
152  printSegments();
153  return segments;
154  }
155 
156  //Iteration 1: STD processing
157  doStd();
158 
159  if(false){
160  //How the CSC algorithm ~does iterations. for now not considering
161  //displaced muons will not worry about it later
162  //Iteration 2a: If we don't allow wide segments simply do displaced
163  // Or if we already found a segment simply skip to displaced
164  if(!allowWideSegments || segments.size()){
165  doDisplaced();
166  return segments;
167  }
168  doWide();
169  doDisplaced();
170  }
171  printSegments();
172  return segments;
173 }
174 
175 void ME0SegAlgoRU::lookForSegments( const SegmentParameters& params, const unsigned int n_seg_min,
176  const HitAndPositionContainer& rechits, const std::vector<unsigned int>& recHits_per_layer,
177  BoolContainer& used, std::vector<ME0Segment>& segments) const {
178  auto ib = rechits.begin();
179  auto ie = rechits.end();
180  std::vector<std::pair<float,HitAndPositionPtrContainer> > proto_segments;
181  // the first hit is taken from the back
182  for (auto i1 = ib; i1 != ie; ++i1) {
183  const auto& h1 = *i1;
184 
185  //skip if rh is used and the layer tat has big rh multiplicity(>25RHs)
186  if(used[h1.idx]) continue;
187  if(recHits_per_layer[h1.layer-1]>100) continue;
188 
189  // bool segok = false;
190  // the second hit from the front
191  for (auto i2 = ie-1; i2 != i1; --i2) {
192  // if(segok) break; //Currently turned off
193  const auto& h2 = *i2;
194 
195  //skip if rh is used and the layer tat has big rh multiplicity(>25RHs)
196  if(used[h2.idx]) continue;
197  if(recHits_per_layer[h2.layer-1]>100) continue;
198 
199  //Stop if the distance between layers is not large enough
200  if((std::abs(int(h2.layer) - int(h1.layer)) + 1) < int(n_seg_min)) break;
201 
202  if(std::fabs(h1.rh->tof()-h2.rh->tof()) > params.maxTOFDiff + 1.0 )continue;
203  if(!areHitsCloseInEta(params.maxETASeeds, params.requireBeamConstr, h1.gp, h2.gp)) continue;
204  if(!areHitsCloseInGlobalPhi(params.maxPhiSeeds,abs(int(h2.layer) - int(h1.layer)), h1.gp, h2.gp)) continue;
205 
206  HitAndPositionPtrContainer current_proto_segment;
207  std::unique_ptr<MuonSegFit> current_fit;
208  current_fit = addHit(current_proto_segment,h1);
209  current_fit = addHit(current_proto_segment,h2);
210 
211  tryAddingHitsToSegment(params.maxTOFDiff,params.maxETASeeds, params.maxPhiAdditional, params.maxChi2Additional, current_fit,current_proto_segment, used,i1,i2);
212 
213  if(current_proto_segment.size() > n_seg_min)
214  pruneBadHits(params.maxChi2Prune,current_proto_segment,current_fit,n_seg_min);
215 
216  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;
217 
218  if(current_proto_segment.size() < n_seg_min) continue;
219  const float current_metric = current_fit->chi2()/current_fit->ndof();
220  if(current_metric > params.maxChi2GoodSeg) continue;
221 
222  if(params.requireCentralBX){
223  int nCentral = 0;
224  int nNonCentral =0;
225  for(const auto* rh : current_proto_segment ) {
226  if(std::fabs(rh->rh->tof()) < 2 ) nCentral++;
227  else nNonCentral++;
228  }
229  if(nNonCentral >= nCentral) continue;
230  }
231  // segok = true;
232 
233  proto_segments.emplace_back( current_metric, current_proto_segment);
234  }
235 
236  }
237  addUniqueSegments(proto_segments,segments,used);
238 
239 }
240 
241 void ME0SegAlgoRU::addUniqueSegments(SegmentByMetricContainer& proto_segments, std::vector<ME0Segment>& segments,BoolContainer& used ) const {
242  std::sort(proto_segments.begin(),proto_segments.end(),
243  [](const std::pair<float,HitAndPositionPtrContainer> & a,
244  const std::pair<float,HitAndPositionPtrContainer> & b) { return a.first < b.first;});
245 
246  //Now add to the collect based on minChi2 marking the hits as used after
247  std::vector<unsigned int> usedHits;
248  for(unsigned int iS = 0; iS < proto_segments.size(); ++iS){
249  HitAndPositionPtrContainer currentProtoSegment = proto_segments[iS].second;
250 
251  //check to see if we already used thes hits this round
252  bool alreadyFilled=false;
253  for(unsigned int iH = 0; iH < currentProtoSegment.size(); ++iH){
254  for(unsigned int iOH = 0; iOH < usedHits.size(); ++iOH){
255  if(usedHits[iOH]!=currentProtoSegment[iH]->idx) continue;
256  alreadyFilled = true;
257  break;
258  }
259  }
260  if(alreadyFilled) continue;
261  for(const auto* h : currentProtoSegment){
262  usedHits.push_back(h->idx);
263  used[h->idx] = true;
264  }
265 
266  std::unique_ptr<MuonSegFit> current_fit = makeFit(currentProtoSegment);
267 
268  // Create an actual ME0Segment - retrieve all info from the fit
269  // calculate the timing fron rec hits associated to the TrackingRecHits used
270  // to fit the segment
271  float averageTime=0.;
272  for(const auto* h : currentProtoSegment){
273  averageTime += h->rh->tof();
274  }
275  averageTime /= float(currentProtoSegment.size());
276  float timeUncrt=0.;
277  for(const auto* h : currentProtoSegment){
278  timeUncrt += (h->rh->tof()-averageTime)*(h->rh->tof()-averageTime);
279  }
280  timeUncrt = std::sqrt(timeUncrt/float(currentProtoSegment.size()-1));
281 
282  std::sort(currentProtoSegment.begin(),currentProtoSegment.end(),
283  [](const HitAndPosition* a, const HitAndPosition *b) {return a->layer < b->layer;}
284  );
285 
286  std::vector<const ME0RecHit*> bareRHs; bareRHs.reserve(currentProtoSegment.size());
287  for(const auto* rh : currentProtoSegment) bareRHs.push_back(rh->rh);
288  const float dPhi = theChamber->computeDeltaPhi(current_fit->intercept(),current_fit->localdir());
289  ME0Segment temp(bareRHs, current_fit->intercept(),
290  current_fit->localdir(), current_fit->covarianceMatrix(), current_fit->chi2(), averageTime, timeUncrt, dPhi);
291  segments.push_back(temp);
292 
293 
294  }
295 }
296 
297 void ME0SegAlgoRU::tryAddingHitsToSegment(const float maxTOF, const float maxETA, const float maxPhi,const float maxChi2, std::unique_ptr<MuonSegFit>& current_fit, HitAndPositionPtrContainer& proto_segment,
298  const BoolContainer& used, HitAndPositionContainer::const_iterator i1, HitAndPositionContainer::const_iterator i2) const {
299  // Iterate over the layers with hits in the chamber
300  // Skip the layers containing the segment endpoints
301  // Test each hit on the other layers to see if it is near the segment
302  // If it is, see whether there is already a hit on the segment from the same layer
303  // - if so, and there are more than 2 hits on the segment, copy the segment,
304  // replace the old hit with the new hit. If the new segment chi2 is better
305  // then replace the original segment with the new one (by swap)
306  // - if not, copy the segment, add the hit. If the new chi2/dof is still satisfactory
307  // then replace the original segment with the new one (by swap)
308 
309  //Hits are ordered by layer, "i1" is the inner hit and i2 is the outer hit
310  //so possible hits to add must be between these two iterators
311  for(auto iH = i1 + 1; iH != i2; ++iH ){
312  if(iH->layer == i1->layer) continue;
313  if(iH->layer == i2->layer) break;
314  if(used[iH->idx]) continue;
315  if(!areHitsConsistentInTime(maxTOF,proto_segment,*iH)) continue;
316  if (!isHitNearSegment(maxETA,maxPhi,current_fit,proto_segment,*iH)) continue;
317  if(hasHitOnLayer(proto_segment,iH->layer))
318  compareProtoSegment(current_fit,proto_segment,*iH);
319  else
320  increaseProtoSegment(maxChi2, current_fit,proto_segment,*iH);
321  }
322 }
323 
324 bool ME0SegAlgoRU::areHitsCloseInEta(const float maxETA, const bool beamConst, const GlobalPoint& h1, const GlobalPoint& h2) const {
325  float diff = 0;
326  diff = std::fabs(h1.eta() - h1.eta());
327  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;
328  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.
329 }
330 
331 bool ME0SegAlgoRU::areHitsCloseInGlobalPhi(const float maxPHI, const unsigned int nLayDisp, const GlobalPoint& h1, const GlobalPoint& h2) const {
332  float dphi12 = deltaPhi(h1.barePhi(),h2.barePhi());
333  edm::LogVerbatim("ME0SegAlgoRU") << "[ME0SegAlgoRU::areHitsCloseInGlobalPhi] gp1 = "<<h1<<" and gp2 = "<<h2<<" ==> dPhi = "<<dphi12<<" ==> return "<<(fabs(dphi12) < std::max(maxPHI,float(0.02)))<<std::endl;
334  return fabs(dphi12) < std::max(maxPHI, float(float(nLayDisp)*0.004));
335 }
336 
337 bool ME0SegAlgoRU::isHitNearSegment(const float maxETA, const float maxPHI, const std::unique_ptr<MuonSegFit>& fit, const HitAndPositionPtrContainer& proto_segment, const HitAndPosition& h) const {
338  //Get average eta, based on the two seeds...asssumes that we have not started pruning yet!
339  const float avgETA = (proto_segment[1]->gp.eta() + proto_segment[0]->gp.eta())/2.;
340  // 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;
341  if(std::fabs(h.gp.eta() - avgETA) > std::max(maxETA,float(0.01) )) return false;
342 
343  //Now check the dPhi based on the segment fit
344  GlobalPoint globIntercept = globalAtZ(fit, h.lp.z());
345  float dPhi = deltaPhi(h.gp.barePhi(),globIntercept.phi());
346  //check to see if it is inbetween the two rolls of the outer and inner hits
347  // 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;
348  return (std::fabs(dPhi) < std::max(maxPHI,float(0.001)));
349 }
350 
351 bool ME0SegAlgoRU::areHitsConsistentInTime(const float maxTOF, const HitAndPositionPtrContainer& proto_segment, const HitAndPosition& h) const {
352  std::vector<float> tofs; tofs.reserve(proto_segment.size() + 1);
353  tofs.push_back(h.rh->tof());
354  for(const auto* ih : proto_segment) tofs.push_back(ih->rh->tof());
355  std::sort(tofs.begin(),tofs.end());
356  if(std::fabs(tofs.front() - tofs.back()) < maxTOF +1.0 ) return true;
357  return false;
358 }
359 
360 GlobalPoint ME0SegAlgoRU::globalAtZ(const std::unique_ptr<MuonSegFit>& fit, float z) const {
361  float x = fit->xfit(z);
362  float y = fit->yfit(z);
363  return theChamber->toGlobal(LocalPoint(x,y,z));
364 }
365 
366 std::unique_ptr<MuonSegFit> ME0SegAlgoRU::addHit( HitAndPositionPtrContainer& proto_segment, const HitAndPosition& aHit) const {
367  proto_segment.push_back(&aHit);
368  // make a fit
369  return makeFit(proto_segment);
370 }
371 
372 std::unique_ptr<MuonSegFit> ME0SegAlgoRU::makeFit(const HitAndPositionPtrContainer& proto_segment) const {
373  // for ME0 we take the me0rechit from the proto_segment we transform into Tracking Rechits
374  // the local rest frame is the ME0Chamber
376  for (auto rh=proto_segment.begin();rh<proto_segment.end(); rh++){
377  ME0RecHit *newRH = (*rh)->rh->clone();
378  newRH->setPosition((*rh)->lp);
379  MuonSegFit::MuonRecHitPtr trkRecHit(newRH);
380  muonRecHits.push_back(trkRecHit);
381  }
382  std::unique_ptr<MuonSegFit> currentFit(new MuonSegFit(muonRecHits));
383  currentFit->fit();
384  return currentFit;
385 }
386 
387 void ME0SegAlgoRU::pruneBadHits(const float maxChi2, HitAndPositionPtrContainer& proto_segment, std::unique_ptr<MuonSegFit>& fit, const unsigned int n_seg_min) const{
388  while(proto_segment.size() > n_seg_min && fit->chi2()/fit->ndof() > maxChi2){
389  float maxDev = -1;
390  HitAndPositionPtrContainer::iterator worstHit;
391  for(auto it = proto_segment.begin(); it != proto_segment.end(); ++it){
392  const float dev = getHitSegChi2(fit,*(*it)->rh);
393  if(dev < maxDev) continue;
394  maxDev = dev;
395  worstHit = it;
396  }
397  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;
398  proto_segment.erase( worstHit);
399  fit = makeFit(proto_segment);
400  }
401 }
402 
403 float ME0SegAlgoRU::getHitSegChi2(const std::unique_ptr<MuonSegFit>& fit, const ME0RecHit& hit) const{
404  const auto lp = hit.localPosition();
405  const auto le = hit.localPositionError();
406  const float du = fit->xdev(lp.x(),lp.z());
407  const float dv = fit->ydev(lp.y(),lp.z());
408 
409  ROOT::Math::SMatrix<double,2,2,ROOT::Math::MatRepSym<double,2> > IC;
410  IC(0,0) = le.xx();
411  IC(1,0) = le.xy();
412  IC(1,1) = le.yy();
413 
414  // Invert covariance matrix
415  IC.Invert();
416  return du*du*IC(0,0) + 2.*du*dv*IC(0,1) + dv*dv*IC(1,1);
417 }
418 
419 bool ME0SegAlgoRU::hasHitOnLayer(const HitAndPositionPtrContainer& proto_segment, const unsigned int layer) const {
420  for(const auto* h : proto_segment) if(h->layer == layer) return true;
421  return false;
422 }
423 
424 void ME0SegAlgoRU::compareProtoSegment(std::unique_ptr<MuonSegFit>& current_fit, HitAndPositionPtrContainer& current_proto_segment, const HitAndPosition& new_hit) const {
425  const HitAndPosition * old_hit = 0;
426  HitAndPositionPtrContainer new_proto_segment = current_proto_segment;
427 
428  HitAndPositionPtrContainer::const_iterator it;
429  for (auto it = new_proto_segment.begin(); it != new_proto_segment.end();) {
430  if ((*it)->layer == new_hit.layer) {
431  old_hit = *it;
432  it = new_proto_segment.erase(it);
433  } else {
434  ++it;
435  }
436  }
437  if(old_hit == 0) return;
438  auto new_fit = addHit(new_proto_segment,new_hit);
439 
440  //If on the same strip but different BX choose the closest
441  bool useNew = false;
442  if(old_hit->lp == new_hit.lp ){
443  float avgtof = 0;
444  for(const auto* h : current_proto_segment)
445  if(old_hit != h) avgtof += h->rh->tof();
446  avgtof /= float(current_proto_segment.size() - 1);
447  if(std::abs(avgtof - new_hit.rh->tof() ) <
448  std::abs(avgtof - old_hit->rh->tof() )
449  ) useNew = true;
450  } //otherwise base it on chi2
451  else if(new_fit->chi2() < current_fit->chi2()) useNew = true;
452 
453  if(useNew){
454  current_proto_segment = new_proto_segment;
455  current_fit = std::move(new_fit);
456  }
457 
458 }
459 
460 void ME0SegAlgoRU::increaseProtoSegment(const float maxChi2, std::unique_ptr<MuonSegFit>& current_fit, HitAndPositionPtrContainer& current_proto_segment, const HitAndPosition& new_hit) const {
461  HitAndPositionPtrContainer new_proto_segment = current_proto_segment;
462  auto new_fit = addHit(new_proto_segment,new_hit);
463  // 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;
464  if(new_fit->chi2()/new_fit->ndof() < maxChi2 ){
465  current_proto_segment = new_proto_segment;
466  current_fit = std::move(new_fit);
467  }
468 }
#define LogDebug(id)
std::shared_ptr< TrackingRecHit > MuonRecHitPtr
Definition: MuonSegFit.h:41
T getParameter(std::string const &) const
float xx() const
Definition: LocalError.h:24
virtual ME0RecHit * clone() const
Definition: ME0RecHit.cc:47
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
void setPosition(LocalPoint pos)
Set local position.
Definition: ME0RecHit.h:72
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
virtual LocalError localPositionError() const
Return the 3-dimensional error on the local position.
Definition: ME0RecHit.h:53
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
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
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
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
virtual LocalPoint localPosition() const
Return the 3-dimensional local position.
Definition: ME0RecHit.h:47
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
double b
Definition: hdecay.h:120
const ME0Chamber * theChamber
Definition: ME0SegAlgoRU.h:110
T eta() const
Definition: PV3DBase.h:76
bool areHitsCloseInEta(const float maxETA, const bool beamConst, const GlobalPoint &h1, const GlobalPoint &h2) const
double a
Definition: hdecay.h:121
std::vector< ME0Segment > run(const ME0Chamber *chamber, const HitAndPositionContainer &rechits)
Definition: ME0SegAlgoRU.cc:79
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:660