CMS 3D CMS Logo

DTCombinatorialPatternReco Class Reference

Algo for reconstructing 2d segment in DT using a combinatorial approach. More...

#include <RecoLocalMuon/DTSegment/src/DTCombinatorialPatternReco.h>

Inheritance diagram for DTCombinatorialPatternReco:

DTRecSegment2DBaseAlgo

List of all members.

Public Member Functions

virtual std::string algoName () const
 return the algo name
 DTCombinatorialPatternReco (const edm::ParameterSet &pset)
 Constructor.
virtual edm::OwnVector
< DTSLRecSegment2D
reconstruct (const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
 this function is called in the producer
virtual void setES (const edm::EventSetup &setup)
 Through this function the EventSetup is percolated to the objs which request it.
virtual ~DTCombinatorialPatternReco ()
 Destructor.

Private Types

typedef std::pair
< DTHitPairForFit *,
DTEnums::DTCellSide
AssPoint

Private Member Functions

DTSegmentCandbuildBestSegment (std::vector< AssPoint > &assHits, const DTSuperLayer *sl)
void buildPointsCollection (std::vector< AssPoint > &points, std::deque< DTHitPairForFit * > &pointsNoLR, std::vector< DTSegmentCand * > &candidates, const DTSuperLayer *sl)
 build collection of compatible hits for L/R hits: the candidates is updated with the segment candidates found
std::vector< DTSegmentCand * > buildSegments (const DTSuperLayer *sl, const std::vector< DTHitPairForFit * > &hits)
bool checkDoubleCandidates (std::vector< DTSegmentCand * > &segs, DTSegmentCand *seg)
std::vector< AssPointfindCompatibleHits (const LocalPoint &pos, const LocalVector &dir, const std::vector< DTHitPairForFit * > &hits)
std::vector< DTHitPairForFit * > initHits (const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)

Private Attributes

bool debug
std::string theAlgoName
double theAlphaMaxPhi
double theAlphaMaxTheta
DTSegmentCleanertheCleaner
edm::ESHandle< DTGeometrytheDTGeometry
unsigned int theMaxAllowedHits
std::vector< inttheTriedPattern
DTSegmentUpdatortheUpdator
bool usePairs

Friends

class DTCombinatorialPatternReco4D


Detailed Description

Algo for reconstructing 2d segment in DT using a combinatorial approach.

Date
2008/04/04 15:23:01
Revision
1.10
Author:
Stefano Lacaprara - INFN Legnaro <stefano.lacaprara@pd.infn.it>

Riccardo Bellan - INFN TO <riccardo.bellan@cern.ch>

Definition at line 41 of file DTCombinatorialPatternReco.h.


Member Typedef Documentation

typedef std::pair<DTHitPairForFit*, DTEnums::DTCellSide> DTCombinatorialPatternReco::AssPoint [private]

Definition at line 70 of file DTCombinatorialPatternReco.h.


Constructor & Destructor Documentation

DTCombinatorialPatternReco::DTCombinatorialPatternReco ( const edm::ParameterSet pset  ) 

Constructor.

Definition at line 36 of file DTCombinatorialPatternReco.cc.

References debug, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), theAlphaMaxPhi, theAlphaMaxTheta, theCleaner, theMaxAllowedHits, theUpdator, and usePairs.

00036                                                                                   : 
00037 DTRecSegment2DBaseAlgo(pset), theAlgoName("DTCombinatorialPatternReco")
00038 {
00039   theMaxAllowedHits = pset.getParameter<unsigned int>("MaxAllowedHits"); // 100
00040   theAlphaMaxTheta = pset.getParameter<double>("AlphaMaxTheta");// 0.1 ;
00041   theAlphaMaxPhi = pset.getParameter<double>("AlphaMaxPhi");// 1.0 ;
00042   debug = pset.getUntrackedParameter<bool>("debug"); //true;
00043   theUpdator = new DTSegmentUpdator(pset);
00044   theCleaner = new DTSegmentCleaner(pset);
00045   string theHitAlgoName = pset.getParameter<string>("recAlgo");
00046   usePairs = !(theHitAlgoName=="DTNoDriftAlgo");
00047 }

DTCombinatorialPatternReco::~DTCombinatorialPatternReco (  )  [virtual]

Destructor.

Definition at line 50 of file DTCombinatorialPatternReco.cc.

00050                                                         {
00051 }


Member Function Documentation

virtual std::string DTCombinatorialPatternReco::algoName ( void   )  const [inline, virtual]

return the algo name

Implements DTRecSegment2DBaseAlgo.

Definition at line 59 of file DTCombinatorialPatternReco.h.

References theAlgoName.

00059 { return theAlgoName; }

DTSegmentCand * DTCombinatorialPatternReco::buildBestSegment ( std::vector< AssPoint > &  assHits,
const DTSuperLayer sl 
) [private]

Definition at line 298 of file DTCombinatorialPatternReco.cc.

References buildPointsCollection(), GenMuonPlsPt100GeV_cfg::cout, debug, iter, and DTEnums::undefLR.

Referenced by buildSegments().

00299                                                                      {
00300   if (hits.size()<3) {
00301     //cout << "buildBestSegment: hits " << hits.size()<< endl;
00302     return 0; // a least 3 point
00303   }
00304 
00305   // hits with defined LR
00306   vector<AssPoint> points;
00307 
00308   // without: I store both L and R, a deque since I need front insertion and
00309   // deletion
00310   deque<DTHitPairForFit* > pointsNoLR; 
00311 
00312   // first add only the hits with LR assigned
00313   for (vector<AssPoint>::const_iterator hit=hits.begin();
00314        hit!=hits.end(); ++hit) {
00315     if ((*hit).second != DTEnums::undefLR) {
00316       points.push_back(*hit);
00317     } else { // then also for the undef'd one
00318       pointsNoLR.push_back((*hit).first);
00319     }
00320   }
00321 
00322   if(debug) {
00323     cout << "points " << points.size() << endl;
00324     cout << "pointsNoLR " << pointsNoLR.size() << endl;
00325   }
00326 
00327   // build all possible candidates using L/R ambiguity
00328   vector<DTSegmentCand*> candidates ;
00329 
00330   buildPointsCollection(points, pointsNoLR, candidates, sl);
00331 
00332   if(debug)
00333     cout << "candidates " << candidates.size() << endl;
00334 
00335   // so now I have build a given number of segments, I should find the best one,
00336   // by #hits and chi2.
00337   vector<DTSegmentCand*>::const_iterator bestCandIter = candidates.end();
00338   double minChi2=999999.;
00339   unsigned int maxNumHits=0;
00340   for (vector<DTSegmentCand*>::const_iterator iter=candidates.begin();
00341        iter!=candidates.end(); ++iter) {
00342     if ((*iter)->nHits()==maxNumHits && (*iter)->chi2()<minChi2) {
00343       minChi2=(*iter)->chi2();
00344       bestCandIter=iter;
00345     } else if ((*iter)->nHits()>maxNumHits) {
00346       maxNumHits=(*iter)->nHits();
00347       minChi2=(*iter)->chi2();
00348       bestCandIter=iter;
00349     }
00350   }
00351 
00352   // delete all candidates but the best one!
00353   for (vector<DTSegmentCand*>::iterator iter=candidates.begin();
00354        iter!=candidates.end(); ++iter) if (iter!=bestCandIter) delete *iter;
00355 
00356        // return the best candate if any
00357        if (bestCandIter != candidates.end()) {
00358          return (*bestCandIter);
00359        }
00360        return 0;
00361 }

void DTCombinatorialPatternReco::buildPointsCollection ( std::vector< AssPoint > &  points,
std::deque< DTHitPairForFit * > &  pointsNoLR,
std::vector< DTSegmentCand * > &  candidates,
const DTSuperLayer sl 
) [private]

build collection of compatible hits for L/R hits: the candidates is updated with the segment candidates found

Referenced by buildBestSegment().

vector< DTSegmentCand * > DTCombinatorialPatternReco::buildSegments ( const DTSuperLayer sl,
const std::vector< DTHitPairForFit * > &  hits 
) [private]

get two hits in different layers and see if there are other / hits

Definition at line 105 of file DTCombinatorialPatternReco.cc.

References buildBestSegment(), checkDoubleCandidates(), DTSegmentCleaner::clean(), GenMuonPlsPt100GeV_cfg::cout, debug, lat::endl(), findCompatibleHits(), DTSegmentCand::good(), DTSuperLayer::id(), DTEnums::Left, HLT_VtxMuL3::result, DTEnums::Right, seg, theAlphaMaxPhi, theAlphaMaxTheta, theCleaner, theMaxAllowedHits, PV3DBase< T, PVType, FrameType >::theta(), and GeomDet::toGlobal().

Referenced by reconstruct().

00106                                                                                   {
00107 
00108   typedef vector<DTHitPairForFit*> hitCont;
00109   typedef hitCont::const_iterator  hitIter;
00110   vector<DTSegmentCand*> result;
00111   
00112   if(debug) {
00113     cout << "buildSegments: " << sl->id() << " nHits " << hits.size() << endl;
00114     for (vector<DTHitPairForFit*>::const_iterator hit=hits.begin();
00115          hit!=hits.end(); ++hit) cout << **hit<< endl;
00116   }
00117 
00118   // 10-Mar-2004 SL
00119   // put a protection against heavily populated chambers, for which the segment
00120   // building could lead to infinite memory usage...
00121   if (hits.size() > theMaxAllowedHits ) {
00122     if(debug) {
00123       cout << "Warning: this SuperLayer " << sl->id() << " has too many hits : "
00124         << hits.size() << " max allowed is " << theMaxAllowedHits << endl;
00125       cout << "Skipping segment reconstruction... " << endl;
00126     }
00127     return result;
00128   }
00129 
00131   //  compatible with them
00132   for (hitCont::const_iterator firstHit=hits.begin(); firstHit!=hits.end();
00133        ++firstHit) {
00134     for (hitCont::const_reverse_iterator lastHit=hits.rbegin(); 
00135          (*lastHit)!=(*firstHit); ++lastHit) {
00136       //if ( (*lastHit)->id().layerId() == (*firstHit)->id().layerId() ) continue; // hits must be in different layers!
00137       // hits must nor in the same nor in adiacent layers
00138       if ( fabs((*lastHit)->id().layerId()-(*firstHit)->id().layerId())<=1 ) continue;
00139       if(debug) {
00140         cout << "Selected these two hits pair " << endl;
00141         cout << "First " << *(*firstHit) << " Layer Id: " << (*firstHit)->id().layerId() << endl;
00142         cout << "Last "  << *(*lastHit)  << " Layer Id: " << (*lastHit)->id().layerId()  << endl;
00143       }
00144 
00145       GlobalPoint IP;
00146       float DAlphaMax;
00147       if ((sl->id()).superlayer()==2)  // Theta SL
00148         DAlphaMax=theAlphaMaxTheta;
00149       else // Phi SL
00150         DAlphaMax=theAlphaMaxPhi;
00151 
00152       DTEnums::DTCellSide codes[2]={DTEnums::Right, DTEnums::Left};
00153       for (int firstLR=0; firstLR<2; ++firstLR) {
00154         for (int lastLR=0; lastLR<2; ++lastLR) {
00155           // TODO move the global transformation in the DTHitPairForFit class
00156           // when it will be moved I will able to remove the sl from the input parameter
00157           GlobalPoint gposFirst=sl->toGlobal( (*firstHit)->localPosition(codes[firstLR]) );
00158           GlobalPoint gposLast= sl->toGlobal( (*lastHit)->localPosition(codes[lastLR]) );
00159 
00160           GlobalVector gvec=gposLast-gposFirst;
00161           GlobalVector gvecIP=gposLast-IP;
00162 
00163           // difference in angle measured
00164           float DAlpha=fabs(gvec.theta()-gvecIP.theta());
00165 
00166           // cout << "DAlpha " << DAlpha << endl;
00167           if (DAlpha<DAlphaMax) {
00168 
00169             // create a segment hypotesis
00170             // I don't need a true segment, just direction and position
00171             LocalPoint posIni = (*firstHit)->localPosition(codes[firstLR]);
00172             LocalVector dirIni = 
00173               ((*lastHit)->localPosition(codes[lastLR])-posIni).unit();
00174 
00175             // search for other compatible hits, with or without the L/R solved
00176             vector<AssPoint> assHits = findCompatibleHits(posIni, dirIni, hits);
00177             if(debug) 
00178               cout << "compatible hits " << assHits.size() << endl;
00179 
00180             // get the best segment with these hits: it's just one! 
00181             // (is it correct?)
00182             DTSegmentCand* seg = buildBestSegment(assHits, sl);
00183 
00184             if (seg) {
00185               if(debug) 
00186                 cout << "segment " << *seg<< endl;
00187 
00188               // check if the chi2 and #hits are ok
00189               if (!seg->good()) {
00190                 delete seg;
00191               } else { 
00192 
00193                 // remove duplicated segments (I know, would be better to do it before the
00194                 // fit...)
00195                 if (checkDoubleCandidates(result,seg)) {
00196                   // add to the vector of hypotesis
00197                   result.push_back(seg);
00198                   if(debug) 
00199                     cout << "result is now " << result.size() << endl;
00200                 } else { // delete it!
00201                   delete seg;
00202                   if(debug) 
00203                     cout << "already existing" << endl;
00204                 }
00205               }
00206             }
00207           }
00208         }
00209       }
00210     }
00211   }
00212   if (debug) {
00213     for (vector<DTSegmentCand*>::const_iterator seg=result.begin();
00214          seg!=result.end(); ++seg) 
00215       cout << *(*seg) << endl;
00216   }
00217 
00218   // now I have a couple of segment hypotesis, should check for ghost
00219   result = theCleaner->clean(result);
00220   if (debug) {
00221     cout << "result no ghost  " << result.size() << endl;
00222     for (vector<DTSegmentCand*>::const_iterator seg=result.begin();
00223          seg!=result.end(); ++seg) 
00224       cout << *(*seg) << endl;
00225   }
00226 
00227   return result;
00228 }

bool DTCombinatorialPatternReco::checkDoubleCandidates ( std::vector< DTSegmentCand * > &  segs,
DTSegmentCand seg 
) [private]

Referenced by buildSegments().

std::vector<AssPoint> DTCombinatorialPatternReco::findCompatibleHits ( const LocalPoint pos,
const LocalVector dir,
const std::vector< DTHitPairForFit * > &  hits 
) [private]

Referenced by buildSegments().

vector< DTHitPairForFit * > DTCombinatorialPatternReco::initHits ( const DTSuperLayer sl,
const std::vector< DTRecHit1DPair > &  hits 
) [private]

Definition at line 93 of file DTCombinatorialPatternReco.cc.

References HLT_VtxMuL3::result, and theDTGeometry.

Referenced by reconstruct().

00094                                                                            {  
00095   
00096   vector<DTHitPairForFit*> result;
00097   for (vector<DTRecHit1DPair>::const_iterator hit=hits.begin();
00098        hit!=hits.end(); ++hit) {
00099     result.push_back(new DTHitPairForFit(*hit, *sl, theDTGeometry));
00100   }
00101   return result;
00102 }

edm::OwnVector< DTSLRecSegment2D > DTCombinatorialPatternReco::reconstruct ( const DTSuperLayer sl,
const std::vector< DTRecHit1DPair > &  hits 
) [virtual]

this function is called in the producer

Implements DTRecSegment2DBaseAlgo.

Definition at line 55 of file DTCombinatorialPatternReco.cc.

References edm::OwnVector< T, P >::back(), buildSegments(), GenMuonPlsPt100GeV_cfg::cout, debug, lat::endl(), initHits(), it, edm::OwnVector< T, P >::push_back(), HLT_VtxMuL3::result, theTriedPattern, theUpdator, and DTSegmentUpdator::update().

Referenced by DTCombinatorialPatternReco4D::reconstruct().

00056                                                                                {
00057 
00058   theTriedPattern.clear();
00059   edm::OwnVector<DTSLRecSegment2D> result;
00060   vector<DTHitPairForFit*> hitsForFit = initHits(sl, pairs);
00061 
00062   vector<DTSegmentCand*> candidates = buildSegments(sl, hitsForFit);
00063 
00064   vector<DTSegmentCand*>::const_iterator cand=candidates.begin();
00065   while (cand<candidates.end()) {
00066     
00067     DTSLRecSegment2D *segment = (**cand);
00068 
00069     theUpdator->update(segment);
00070 
00071     result.push_back(segment);
00072 
00073     if (debug) {
00074       cout<<"Reconstructed 2D segments "<< result.back() <<endl;
00075     }
00076 
00077     delete *(cand++); // delete the candidate!
00078   }
00079 
00080   for (vector<DTHitPairForFit*>::iterator it = hitsForFit.begin(), ed = hitsForFit.end(); 
00081         it != ed; ++it) delete *it;
00082 
00083   return result;
00084 }

void DTCombinatorialPatternReco::setES ( const edm::EventSetup setup  )  [virtual]

Through this function the EventSetup is percolated to the objs which request it.

Implements DTRecSegment2DBaseAlgo.

Definition at line 86 of file DTCombinatorialPatternReco.cc.

References edm::EventSetup::get(), DTSegmentUpdator::setES(), theDTGeometry, and theUpdator.

Referenced by DTCombinatorialPatternReco4D::setES().

00086                                                                 {
00087   // Get the DT Geometry
00088   setup.get<MuonGeometryRecord>().get(theDTGeometry);
00089   theUpdator->setES(setup);
00090 }


Friends And Related Function Documentation

friend class DTCombinatorialPatternReco4D [friend]

Definition at line 68 of file DTCombinatorialPatternReco.h.


Member Data Documentation

bool DTCombinatorialPatternReco::debug [private]

Definition at line 104 of file DTCombinatorialPatternReco.h.

Referenced by buildBestSegment(), buildSegments(), DTCombinatorialPatternReco(), and reconstruct().

std::string DTCombinatorialPatternReco::theAlgoName [private]

Definition at line 100 of file DTCombinatorialPatternReco.h.

Referenced by algoName().

double DTCombinatorialPatternReco::theAlphaMaxPhi [private]

Definition at line 103 of file DTCombinatorialPatternReco.h.

Referenced by buildSegments(), and DTCombinatorialPatternReco().

double DTCombinatorialPatternReco::theAlphaMaxTheta [private]

Definition at line 102 of file DTCombinatorialPatternReco.h.

Referenced by buildSegments(), and DTCombinatorialPatternReco().

DTSegmentCleaner* DTCombinatorialPatternReco::theCleaner [private]

Definition at line 107 of file DTCombinatorialPatternReco.h.

Referenced by buildSegments(), and DTCombinatorialPatternReco().

edm::ESHandle<DTGeometry> DTCombinatorialPatternReco::theDTGeometry [private]

Definition at line 109 of file DTCombinatorialPatternReco.h.

Referenced by initHits(), and setES().

unsigned int DTCombinatorialPatternReco::theMaxAllowedHits [private]

Definition at line 101 of file DTCombinatorialPatternReco.h.

Referenced by buildSegments(), and DTCombinatorialPatternReco().

std::vector<int> DTCombinatorialPatternReco::theTriedPattern [private]

Definition at line 113 of file DTCombinatorialPatternReco.h.

Referenced by reconstruct().

DTSegmentUpdator* DTCombinatorialPatternReco::theUpdator [private]

Definition at line 106 of file DTCombinatorialPatternReco.h.

Referenced by DTCombinatorialPatternReco(), reconstruct(), and setES().

bool DTCombinatorialPatternReco::usePairs [private]

Definition at line 105 of file DTCombinatorialPatternReco.h.

Referenced by DTCombinatorialPatternReco().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:18:47 2009 for CMSSW by  doxygen 1.5.4