CMS 3D CMS Logo

DTHitPairForFit.cc

Go to the documentation of this file.
00001 
00009 /* This Class Header */
00010 #include "RecoLocalMuon/DTSegment/src/DTHitPairForFit.h"
00011 
00012 /* Collaborating Class Header */
00013 #include "FWCore/Utilities/interface/Exception.h"
00014 
00015 /* C++ Headers */
00016 #include <iostream>
00017 using namespace std;
00018 
00019 /* ====================================================================== */
00020 
00022 DTHitPairForFit::DTHitPairForFit(const DTRecHit1DPair& pair,
00023                                  const DTSuperLayer& sl,
00024                                  const edm::ESHandle<DTGeometry>& dtGeom) {
00025 
00026   theWireId = pair.wireId();
00027   theDigiTime = pair.digiTime();
00028   
00029   const DTLayer* layer = dtGeom->layer(theWireId.layerId());
00030 
00031   // transform the Local position in Layer-rf in a SL local position
00032   theLeftPos =
00033     sl.toLocal(layer->toGlobal(pair.componentRecHit(DTEnums::Left)->localPosition()));
00034   theRightPos =
00035     sl.toLocal(layer->toGlobal(pair.componentRecHit(DTEnums::Right)->localPosition()));
00036 
00037   // TODO how do I transform an error from local to global?
00038   theError = pair.componentRecHit(DTEnums::Left)->localPositionError();
00039   // theError =
00040   //   layer->surface().toLocal(sl.surface().toGlobal(pair.componentRecHit(DTEnums::Left)->localPositionError()));
00041   
00042 }
00043 
00045 DTHitPairForFit::~DTHitPairForFit() {
00046 }
00047 
00048 /* Operations */ 
00049 LocalPoint DTHitPairForFit::localPosition(DTEnums::DTCellSide s) const {
00050   if (s==DTEnums::Left) return theLeftPos;
00051   else if (s==DTEnums::Right) return theRightPos;
00052   else{ 
00053     throw cms::Exception("DTHitPairForFit")<<" localPosition called with undef LR code"<<endl;
00054     return LocalPoint();
00055   }
00056 }
00057 
00058 pair<bool,bool> 
00059 DTHitPairForFit::isCompatible(const LocalPoint& posIni,
00060                               const LocalVector& dirIni) const {
00061   return std::pair<bool,bool>(isCompatible(posIni, dirIni, DTEnums::Left),
00062                               isCompatible(posIni, dirIni, DTEnums::Right));
00063 }
00064 
00065 bool DTHitPairForFit::isCompatible(const LocalPoint& posIni,
00066                                    const LocalVector& dirIni,
00067                                    DTEnums::DTCellSide code) const {
00068   // all is in SL frame
00069   LocalPoint pos= localPosition(code);
00070   LocalError err= localPositionError();
00071 
00072   const float errorScale=10.; // to be tuned!!
00073 
00074   LocalPoint segPosAtZ=
00075     posIni+dirIni*(pos.z()-posIni.z())/dirIni.z();
00076 
00077   // cout << "segPosAtZ     " << segPosAtZ << endl;
00078   // cout << "segPosInLayer " << pos<< endl;
00079   // cout << "errInLayer (" << err.xx() << "," << 
00080   //    err.xy() << "," << err.yy() << ")" << endl;
00081 
00082   float dx=pos.x()-segPosAtZ.x();
00083   // cout << "Dx " << dx << " vs " << sqrt(err.xx())*errorScale << endl;
00084 
00085   return fabs(dx)<sqrt(err.xx())*errorScale;
00086 
00087 }
00088 
00089 bool DTHitPairForFit::operator<(const DTHitPairForFit& hit) const {
00090   //SL if same layer use x() for strict ordering
00091   if (id()==hit.id()) 
00092     return (theLeftPos.x() < hit.localPosition(DTEnums::Left).x());
00093   return (id() < hit.id());
00094 }
00095 
00096 bool DTHitPairForFit::operator==(const DTHitPairForFit& hit) const {
00097   return  (id() == hit.id() && fabs(digiTime() - hit.digiTime()) < 0.1 );
00098 }
00099 
00100 ostream& operator<<(ostream& out, const DTHitPairForFit& hit) {
00101   out << hit.leftPos() << " " << hit.rightPos() ;
00102   return out;
00103 }

Generated on Tue Jun 9 17:43:53 2009 for CMSSW by  doxygen 1.5.4