CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/SimDataFormats/SLHC/interface/L1TkTrack.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #ifndef STACKED_TRACKER_L1TK_TRACK_FORMAT_H
00012 #define STACKED_TRACKER_L1TK_TRACK_FORMAT_H
00013 
00014 #include "DataFormats/SiPixelDetId/interface/StackedTrackerDetId.h"
00015 #include "CLHEP/Units/PhysicalConstants.h"
00016 
00017 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00018 #include "SimDataFormats/SLHC/interface/L1TkStub.h"
00019 
00026   template< typename T >
00027   class L1TkTrack
00028   {
00029 
00030     private:
00032       std::vector< edm::Ptr< L1TkStub< T > > >  theStubPtrs;
00033       GlobalVector                              theMomentum;
00034       double                                    theRInv;
00035 
00036 /*
00037       L1TkStubPtrCollection   theBrickStubs;    /// The Stubs
00038       L1TkTrackletPtrType     theSeedTracklet;  /// The Seed
00039       unsigned int            theSimTrackId;
00040       bool                    theGenuine;
00041       int                     theType;
00043       GlobalPoint             theVertex;
00044       GlobalVector            theMomentum;
00045       double                  theCharge; /// WARNING maybe should be changed to short int
00046       double                  theRadius; /// WARNING do we need it?
00047       GlobalPoint             theAxis;   /// WARNING do we need it?
00048       double                  theChi2RPhi;
00049       double                  theChi2ZPhi;
00050       bool                    theUseSeedVertex; /// Used also Vertex from Seed in Fit?
00051 */
00052 
00053     public:
00055       L1TkTrack();
00056       L1TkTrack( std::vector< edm::Ptr< L1TkStub< T > > > aStubs );
00057 
00059       ~L1TkTrack();
00060 
00062       std::vector< edm::Ptr< L1TkStub< T > > > getStubPtrs() const;
00063       void addStubPtr( edm::Ptr< L1TkStub< T > > aStub );
00064 
00066       GlobalVector getMomentum() const;
00067       void setMomentum( GlobalVector aMomentum );
00068 
00070       double getRInv() const;
00071       void setRInv( double aRInv );
00072 
00073 /*
00074       L1TkTrackletType       getSeedTracklet() const;
00075       L1TkStubCollection     getStubs() const;
00076       L1TkStubType           getStub( unsigned int layerIdentifier ) const;
00077       L1TkStubPtrType        getStubRef( unsigned int layerIdentifier) const;
00078       //void                   addStub( L1TkStubPtrType aL1TkStub );
00079       unsigned int           getSeedDoubleStack() const;
00081       void                   setVertex( GlobalPoint aVertex );
00082       GlobalPoint            getVertex() const;
00084       void                   setMomentum( GlobalVector aMomentum );
00085       GlobalVector           getMomentum() const;
00087       void                   setCharge( double aCharge ); /// WARNING maybe better to change it into a short int!
00088       double                 getCharge() const;
00090       void                   setRadius( double aRadius ); /// WARNING additional information with sign?
00091       double                 getRadius() const;
00093       void                   setAxis( double xAxis, double yAxis );
00094       GlobalPoint            getAxis() const;
00096       void                   setChi2RPhi( double aChi2RPhi );
00097       double                 getChi2RPhi() const;
00098       void                   setChi2ZPhi( double aChi2ZPhi );
00099       double                 getChi2ZPhi() const;
00100       double                 getChi2Tot() const;
00102       void                   setUseSeedVertex( bool aUseSeedVertex );
00103       bool                   getUseSeedVertex() const;
00105       bool                   isGenuine() const;
00106       void                   setGenuine( bool aGenuine );
00107       int                    getType() const;
00108       void                   setType( int aType );
00109       unsigned int           getSimTrackId() const;
00110       void                   setSimTrackId( unsigned int aSimTrackId );
00111 */
00112 
00116 //      void checkSimTrack();
00117 
00121 //      void fitTrack( double aMagneticFieldStrength, bool useAlsoVtx, bool aDoHelixFit );
00122 
00123 
00124 
00127 //      std::string print( unsigned int i=0 ) const;
00128 
00129   }; 
00130 
00131 
00132 
00139 
00140   template< typename T >
00141   L1TkTrack< T >::L1TkTrack()
00142   {
00143     theStubPtrs.clear();
00144     theMomentum = GlobalVector(0.0,0.0,0.0);
00145     theRInv = 0;
00146 /*    theBrickStubs.clear();
00147     theSeedTracklet = edm::Ptr< L1TkTracklet< T > >();
00148     theVertex   = GlobalPoint(0.0,0.0,0.0);
00149     theMomentum = GlobalVector(0.0,0.0,0.0);
00150     theCharge   = 0;
00151     theRadius   = -99999.9;
00152     theAxis     = GlobalPoint(0.0,0.0,0.0);
00153     theChi2RPhi = -999.9;
00154     theChi2ZPhi = -999.9;
00155     theSimTrackId = 0;
00156     theGenuine = false;
00157     theType = -999999999;
00158 */
00159   }
00160 
00161 
00163   template< typename T >
00164   L1TkTrack< T >::L1TkTrack( std::vector< edm::Ptr< L1TkStub< T > > > aStubs )
00165   {
00166     theStubPtrs = aStubs;
00167     theMomentum = GlobalVector(0.0,0.0,0.0);
00168     theRInv = 0;
00169   }
00170 
00171 /*  L1TkTrack< T >::L1TkTrack( std::vector< edm::Ptr< L1TkStub< T > > > aBrickStubs, edm::Ptr< L1TkTracklet< T > > aSeedTracklet ) 
00172   {
00174     theSimTrackId = 0;
00175     theGenuine = false;
00176     theType = -999999999;
00178     theBrickStubs = aBrickStubs;
00179     theSeedTracklet = aSeedTracklet;
00181     theVertex   = GlobalPoint(0.0,0.0,0.0);
00182     theMomentum = GlobalVector(0.0,0.0,0.0);
00183     theCharge   = 0;
00184     theRadius   = -99999.9;
00185     theAxis     = GlobalPoint(0.0,0.0,0.0);
00186     theChi2RPhi = -999.9;
00187     theChi2ZPhi = -999.9;
00188   }
00189 */
00191   template< typename T >
00192   L1TkTrack< T >::~L1TkTrack(){}
00193 
00195   template< typename T >
00196   std::vector< edm::Ptr< L1TkStub< T > > > L1TkTrack< T >::getStubPtrs() const { return theStubPtrs; }
00197 
00198   template< typename T >
00199   void L1TkTrack< T >::addStubPtr( edm::Ptr< L1TkStub< T > > aStub )
00200   {
00201     theStubPtrs.push_back( aStub );
00202   }
00203 
00205   template< typename T >
00206   GlobalVector L1TkTrack< T >::getMomentum() const { return theMomentum; }
00207 
00208   template< typename T >
00209   void L1TkTrack< T >::setMomentum( GlobalVector aMomentum )
00210   {
00211     theMomentum = aMomentum;
00212   }
00213 
00215   template< typename T >
00216   double L1TkTrack< T >::getRInv() const { return theRInv; }
00217 
00218   template< typename T >
00219   void L1TkTrack< T >::setRInv( double aRInv )
00220   {
00221     theRInv = aRInv;
00222   }
00223 
00224 
00225 
00226 /*
00230 
00232   template< typename T >
00233   L1TkTracklet< T > L1TkTrack< T >::getSeedTracklet() const
00234   {
00235     return *theSeedTracklet;
00236   }
00237 
00239   template< typename T >
00240   std::vector< L1TkStub< T > > L1TkTrack< T >::getStubs() const
00241   {
00242     std::vector< L1TkStub< T > > tempColl;
00243     tempColl.clear();
00244     for ( unsigned int i = 0; i < theBrickStubs.size(); i++ ) {
00245       tempColl.push_back( *(theBrickStubs.at(i)) );
00246     }
00247     return tempColl;
00248   }
00249 
00251   template< typename T >
00252   L1TkStub< T > L1TkTrack< T >::getStub( unsigned int layerIdentifier ) const
00253   {
00255     for ( unsigned int i = 0; i < theBrickStubs.size(); i++ ) {
00256       StackedTrackerDetId stDetId( theBrickStubs.at(i)->getDetId() );
00257       if ( stDetId.iLayer() == layerIdentifier ) return *(theBrickStubs.at(i));
00258     }
00260     return L1TkStub< T >();
00261   }
00262 
00264   template< typename T >
00265   edm::Ptr< L1TkStub< T > > L1TkTrack< T >::getStubRef( unsigned int layerIdentifier ) const
00266   {
00268     for ( unsigned int i = 0; i < theBrickStubs.size(); i++ ) {
00269       StackedTrackerDetId stDetId( theBrickStubs.at(i)->getDetId() );
00270       if ( stDetId.iLayer() == layerIdentifier ) return theBrickStubs.at(i);
00271     }
00273     return edm::Ptr< L1TkStub< T > >();
00274   }
00275 
00277   template< typename T>
00278   unsigned int L1TkTrack< T >::getSeedDoubleStack() const
00279   {
00280     return theSeedTracklet->getDoubleStack();
00281   }
00282 
00284   template< typename T >
00285   void L1TkTrack< T >::setVertex( GlobalPoint aVertex )
00286   {
00287     theVertex = aVertex;
00288   }
00289 
00290   template< typename T >
00291   GlobalPoint L1TkTrack< T >::getVertex() const
00292   {
00293     return theVertex;
00294   }
00295 
00297   template< typename T >
00298   void L1TkTrack< T >::setMomentum( GlobalVector aMomentum )
00299   {
00300     theMomentum = aMomentum;
00301   }
00302 
00303   template< typename T >
00304   GlobalVector L1TkTrack< T >::getMomentum() const
00305   {
00306     return theMomentum;
00307   }
00308 
00310   template< typename T >
00311   void L1TkTrack< T >::setCharge( double aCharge )
00312   {
00313     theCharge = aCharge;
00314   }
00315 
00316   template< typename T >
00317   double L1TkTrack< T >::getCharge() const
00318   {
00319     return theCharge;
00320   }
00321 
00323   template< typename T >
00324   void L1TkTrack< T >::setRadius( double aRadius )
00325   {
00326     theRadius = aRadius;
00327   }
00328 
00329   template< typename T >
00330   double L1TkTrack< T >::getRadius() const
00331   {
00332     return theRadius;
00333   }
00334 
00336   template< typename T >
00337   void L1TkTrack< T >::setAxis( double xAxis, double yAxis )
00338   {
00339     theAxis = GlobalPoint( xAxis, yAxis, 0.0 );
00340   }
00341 
00342   template< typename T >
00343   GlobalPoint L1TkTrack< T >::getAxis() const
00344   {
00345     return theAxis;
00346   }
00347 
00349   template< typename T >
00350   void L1TkTrack< T >::setChi2RPhi( double aChi2RPhi )
00351   {
00352     theChi2RPhi = aChi2RPhi;
00353   }
00354 
00355   template< typename T >
00356   double L1TkTrack< T >::getChi2RPhi() const
00357   {
00358     return theChi2RPhi;
00359   }
00360 
00361   template< typename T >
00362   void L1TkTrack< T >::setChi2ZPhi( double aChi2ZPhi )
00363   {
00364     theChi2ZPhi = aChi2ZPhi;
00365   }
00366 
00367   template< typename T >
00368   double L1TkTrack< T >::getChi2ZPhi() const
00369   {
00370     return theChi2ZPhi;
00371   }
00372 
00373   template< typename T >
00374   double L1TkTrack< T >::getChi2Tot() const
00375   {
00376     return this->getChi2RPhi() + this->getChi2ZPhi();
00377   }
00378 
00380   template< typename T >
00381   void L1TkTrack< T >::setUseSeedVertex( bool aUseSeedVertex )
00382   {
00383     theUseSeedVertex = aUseSeedVertex;
00384   }
00385 
00386   template< typename T >
00387   bool L1TkTrack< T >::getUseSeedVertex() const
00388   {
00389     return theUseSeedVertex;
00390   }
00391 
00393   template< typename T >
00394   bool L1TkTrack< T >::isGenuine() const
00395   {
00396     return theGenuine;
00397   }
00398 
00399   template< typename T >
00400   void L1TkTrack< T >::setGenuine( bool aGenuine ) {
00401     theGenuine = aGenuine;
00402   }
00403 
00404   template< typename T >
00405   int L1TkTrack< T >::getType() const
00406   {
00407     return theType;
00408   }
00409 
00410   template< typename T >
00411   void L1TkTrack< T >::setType( int aType ) {
00412     theType = aType;
00413   }
00414 
00415   template< typename T >
00416   unsigned int L1TkTrack< T >::getSimTrackId() const
00417   {
00418     return theSimTrackId;
00419   }
00420 
00421   template< typename T >
00422   void L1TkTrack< T >::setSimTrackId( unsigned int aSimTrackId ) {
00423     theSimTrackId = aSimTrackId;
00424   }
00425 
00426 
00430 
00432   template< typename T >
00433   void L1TkTrack< T >::checkSimTrack()
00434   {
00437     bool tempGenuine = theBrickStubs.at(0)->isGenuine();
00438     unsigned int tempSimTrack = theBrickStubs.at(0)->findSimTrackId();
00439     int tempType = theBrickStubs.at(0)->findType();
00440 
00442     for ( unsigned int i = 1; i < theBrickStubs.size(); i++ ) {
00443 
00444       if ( tempGenuine == false ) continue;
00445       if ( tempSimTrack !=  theBrickStubs.at(i)->findSimTrackId() ) {
00446         tempGenuine = false;
00447         continue;
00448       }
00449       else {
00450         tempGenuine = theBrickStubs.at(i)->isGenuine();
00451         tempSimTrack = theBrickStubs.at(i)->findSimTrackId();
00458       }
00459     } /// End of Loop over L1TkStubs
00460 
00461     this->setGenuine( tempGenuine );
00462     if ( tempGenuine ) {
00463       this->setType( tempType );
00464       this->setSimTrackId( tempSimTrack );
00465     }
00466   }
00467 
00468 
00470   template< typename T >
00471   void L1TkTrack< T >::fitTrack( double aMagneticFieldStrength, bool useAlsoVtx, bool aDoHelixFit )
00472   {
00476     //iSetup.get<IdealMagneticFieldRecord>().get(magnet);
00477     //magnet_ = magnet.product();
00478     //mMagneticFieldStrength = magnet_->inTesla(GlobalPoint(0,0,0)).z();
00483     double mPtFactor = (floor(aMagneticFieldStrength*10.0 + 0.5))/10.0*0.0015;
00484 
00487     std::vector< L1TkStub< T > > brickStubs = this->getStubs();
00488     L1TkTracklet< T >            seedTracklet = this->getSeedTracklet();
00490     GlobalPoint seedVertexXY = GlobalPoint( seedTracklet.getVertex().x(), seedTracklet.getVertex().y(), 0.0 );
00491 
00493     if ( useAlsoVtx ) {
00495       std::vector< L1TkStub< T > > auxStubs;
00496       auxStubs.clear();
00497       L1TkStub< T > dummyStub = L1TkStub< T >( 0 );
00498 
00499 //      dummyStub.setPosition( seedTracklet.getVertex() );
00500 //      dummyStub.setDirection( GlobalVector(0,0,0) );
00501 
00502       auxStubs.push_back( dummyStub );
00504       for ( unsigned int j = 0; j < brickStubs.size(); j++ ) auxStubs.push_back( brickStubs.at(j) );
00506       brickStubs = auxStubs;
00507     }
00508 */
00509 
00510 
00511 
00512 /*
00515     unsigned int iMin = 0;
00516     if ( useAlsoVtx ) iMin = 1;
00518     double outerPointPhi = brickStubs.at( brickStubs.size()-1 ).getPosition().phi();
00519     double innerPointPhi = brickStubs.at( iMin ).getPosition().phi();
00520     double deltaPhi = outerPointPhi - innerPointPhi;
00521     if ( fabs(deltaPhi) >= KGMS_PI) {
00522       if ( deltaPhi>0 ) deltaPhi = deltaPhi - 2*KGMS_PI;
00523       else deltaPhi = 2*KGMS_PI - fabs(deltaPhi);
00524     }
00525     double deltaPhiC = deltaPhi; /// This is for charge
00526     deltaPhi = fabs(deltaPhi);
00527     double fCharge = -deltaPhiC / deltaPhi;
00528     this->setCharge( fCharge );
00529 
00532     std::vector< double > outputFitPt; outputFitPt.clear();
00533     std::vector< double > outputFitPz; outputFitPz.clear();
00534     std::vector< double > outputFitX;  outputFitX.clear();
00535     std::vector< double > outputFitY;  outputFitY.clear();
00537     unsigned int totalTriplets = 0;
00538     for ( unsigned int a1 = 0; a1 < brickStubs.size(); a1++ ) {
00539       for ( unsigned int a2 = a1+1; a2 < brickStubs.size(); a2++ ) {
00540         for ( unsigned int a3 = a2+1; a3 < brickStubs.size(); a3++ ) {
00541           totalTriplets++;
00543           GlobalPoint vtxPos = brickStubs.at(a1).getPosition();
00544           GlobalPoint innPos = brickStubs.at(a2).getPosition();
00545           GlobalPoint outPos = brickStubs.at(a3).getPosition();
00547           innPos = GlobalPoint( innPos.x()-vtxPos.x(), innPos.y()-vtxPos.y(), innPos.z() );
00548           outPos = GlobalPoint( outPos.x()-vtxPos.x(), outPos.y()-vtxPos.y(), outPos.z() );
00549           double outRad = outPos.perp();
00550           double innRad = innPos.perp();
00551           deltaPhi = outPos.phi() - innPos.phi(); /// NOTE overwrite already declared deltaPhi
00552           if ( fabs(deltaPhi) >= KGMS_PI ) {
00553             if ( deltaPhi>0 ) deltaPhi = deltaPhi - 2*KGMS_PI;
00554             else deltaPhi = 2*KGMS_PI - fabs(deltaPhi);
00555           }
00556           deltaPhi = fabs(deltaPhi);
00557           double x2 = outRad * outRad + innRad * innRad - 2 * innRad * outRad * cos(deltaPhi);
00558           double twoRadius = sqrt(x2) / sin(fabs(deltaPhi));
00559           double roughPt = mPtFactor * twoRadius;
00560           double roughPz;
00562           if ( !aDoHelixFit ) roughPz = roughPt * (outPos.z()-innPos.z()) / (outRad-innRad);
00563           else {
00564             double phioi = acos(1 - 2*x2/(twoRadius*twoRadius));
00565             if ( fabs(phioi) >= KGMS_PI ) {
00566               if ( phioi>0 ) phioi = phioi - 2*KGMS_PI;
00567               else phioi = 2*KGMS_PI - fabs(phioi);
00568             }
00569             if ( phioi == 0 ) return;
00570             roughPz = 2 * mPtFactor * (outPos.z()-innPos.z()) / fabs(phioi);
00571           }
00573           outputFitPt.push_back( roughPt );
00574           outputFitPz.push_back( roughPz );
00576           double vertexangle = acos( outRad/twoRadius );
00577           vertexangle = outPos.phi() - fCharge * vertexangle;
00579           outputFitX.push_back( 0.5 * twoRadius * cos(vertexangle) + vtxPos.x() );
00580           outputFitY.push_back( 0.5 * twoRadius * sin(vertexangle) + vtxPos.y() );
00581         } /// End of loop over third element
00582       } /// End of loop over second element
00583     } /// End of loop over first element
00585     double tempOutputX = 0;
00586     double tempOutputY = 0;
00587     double tempOutputPt = 0;
00588     double tempOutputPz = 0;
00589     for ( unsigned int q = 0; q < totalTriplets; q++ ) {
00590       tempOutputX += outputFitX.at(q);
00591       tempOutputY += outputFitY.at(q);
00592       tempOutputPt += outputFitPt.at(q);
00593       tempOutputPz += outputFitPz.at(q);        
00594     }
00595 
00598     GlobalPoint fAxis = GlobalPoint( tempOutputX/totalTriplets, tempOutputY/totalTriplets, 0.0 );
00599     GlobalPoint fAxisCorr = GlobalPoint( fAxis.x() - seedVertexXY.x(), fAxis.y() - seedVertexXY.y(), 0.0 );
00600     this->setAxis( tempOutputX/totalTriplets, tempOutputY/totalTriplets );
00601 
00604     double fPhiV = atan2( fCharge*fAxisCorr.x(), -fCharge*fAxisCorr.y() );
00605     double fPt = tempOutputPt/totalTriplets;
00606     double fPz = tempOutputPz/totalTriplets;
00607     double fRadius  = 0.5*fPt/mPtFactor;
00608     GlobalVector fMomentum = GlobalVector( cos(fPhiV)*fPt, sin(fPhiV)*fPt, fPz );
00609     this->setMomentum( fMomentum );
00610 
00613     double rMinAppr = fAxisCorr.perp() - fRadius;
00614     double xMinAppr = rMinAppr*cos( fAxisCorr.phi() ) + seedVertexXY.x();
00615     double yMinAppr = rMinAppr*sin( fAxisCorr.phi() ) + seedVertexXY.y();
00616     GlobalPoint tempVertex = GlobalPoint( xMinAppr, yMinAppr, 0.0 );
00617     double propFactorHel = 0;
00618     double offsetHel = 0;
00620     std::vector< double > outputFitZ; outputFitZ.clear();
00626     unsigned int totalDoublets = 0;
00627     for ( unsigned int a1 = iMin; a1 < brickStubs.size(); a1++) { /// iMin already set according to useAlsoVtx or not
00628       for ( unsigned int a2 = a1+1; a2 < brickStubs.size(); a2++) {
00629         totalDoublets++;
00631         GlobalPoint innPos = brickStubs.at(a1).getPosition();
00632         GlobalPoint outPos = brickStubs.at(a2).getPosition();
00634         GlobalPoint innPosStar = GlobalPoint( innPos.x() - fAxis.x(), innPos.y() - fAxis.y(), innPos.z() - fAxis.z() );
00635         GlobalPoint outPosStar = GlobalPoint( outPos.x() - fAxis.x(), outPos.y() - fAxis.y(), outPos.z() - fAxis.z() );
00636         double deltaPhiStar = outPosStar.phi() - innPosStar.phi();
00637         if ( fabs(deltaPhiStar) >= KGMS_PI ) {
00638           if ( outPosStar.phi() < 0 ) deltaPhiStar += KGMS_PI;
00639           else deltaPhiStar -= KGMS_PI;
00640           if ( innPosStar.phi() < 0 ) deltaPhiStar -= KGMS_PI;
00641           else deltaPhiStar += KGMS_PI;
00642         }
00643         if ( deltaPhiStar == 0 ) std::cerr<<"BIG PROBLEM IN DELTAPHI DENOMINATOR"<<std::endl;
00644         else {
00645           propFactorHel += ( outPosStar.z() - innPosStar.z() )/deltaPhiStar;
00646           offsetHel += innPosStar.z() - innPosStar.phi()*( outPosStar.z() - innPosStar.z() )/deltaPhiStar;
00647         } /// End of calculate z = z0 + c*phiStar
00648         innPos = GlobalPoint( innPos.x() - tempVertex.x(), innPos.y() - tempVertex.y(), innPos.z() );
00649         outPos = GlobalPoint( outPos.x() - tempVertex.x(), outPos.y() - tempVertex.y(), outPos.z() );
00650         double outRad = outPos.perp();
00651         double innRad = innPos.perp();
00652         deltaPhi = outPos.phi() - innPos.phi(); /// NOTE overwrite already declared deltaPhi
00653         if ( fabs(deltaPhi) >= KGMS_PI ) {
00654           if ( deltaPhi>0 ) deltaPhi = deltaPhi - 2*KGMS_PI;
00655           else deltaPhi = 2*KGMS_PI - fabs(deltaPhi);
00656         }
00657         deltaPhi = fabs(deltaPhi);
00658         double x2 = outRad * outRad + innRad * innRad - 2 * innRad * outRad * cos(deltaPhi);
00659         double twoRadius = sqrt(x2) / sin(fabs(deltaPhi));
00660         double zProj;
00662         if ( !aDoHelixFit ) zProj = outPos.z() - ( outRad * (outPos.z() - innPos.z()) / (outRad - innRad) );
00663         else {
00664           double phioi = acos(1 - 2*x2/(twoRadius*twoRadius));
00665           double phiiv = acos(1 - 2*innRad*innRad/(twoRadius*twoRadius));
00666           if ( fabs(phioi) >= KGMS_PI ) {
00667             if ( phioi>0 ) phioi = phioi - 2*KGMS_PI;
00668             else phioi = 2*KGMS_PI - fabs(phioi);
00669           }
00670           if ( fabs(phiiv) >= KGMS_PI ) {
00671             if ( phiiv>0 ) phiiv = phiiv - 2*KGMS_PI;
00672             else phiiv = 2*KGMS_PI - fabs(phiiv);
00673           }
00674           if ( phioi == 0 ) return;
00676           zProj = innPos.z() - (outPos.z()-innPos.z())*phiiv/phioi;
00677         }
00678         outputFitZ.push_back( zProj );
00679       } /// End of loop over second element
00680     } /// End of loop over first element
00682     double tempOutputZ = 0;
00683     for ( unsigned int q = 0; q < totalDoublets; q++ ) tempOutputZ += outputFitZ.at(q);
00684     double zMinAppr = tempOutputZ/totalDoublets;
00685 
00688     GlobalPoint fVertex = GlobalPoint( xMinAppr, yMinAppr, zMinAppr );
00689     this->setVertex( fVertex );
00690 
00691 
00694     propFactorHel = propFactorHel/totalDoublets;
00695     offsetHel = offsetHel/totalDoublets;
00696     double fChi2RPhi = 0;
00697     double fChi2ZPhi = 0;
00698     double tempStep;
00700     if (useAlsoVtx) {
00701       GlobalPoint posPoint = seedTracklet.getVertex();
00702       GlobalPoint posPointCorr = GlobalPoint( posPoint.x() - fAxis.x(), posPoint.y() - fAxis.y(), posPoint.z() );
00704       tempStep = posPoint.x() - fAxis.x() - fRadius * cos( posPointCorr.phi() );
00705       fChi2RPhi += tempStep*tempStep;
00707       tempStep = posPoint.y() - fAxis.y() - fRadius * sin( posPointCorr.phi() );
00708       fChi2RPhi += tempStep*tempStep;
00713       tempStep = posPoint.z() - offsetHel - propFactorHel * posPointCorr.phi();
00714       fChi2ZPhi += tempStep*tempStep;
00715     }
00717     for ( unsigned int a = iMin; a < brickStubs.size(); a++ ) {
00718       GlobalPoint posPoint = brickStubs.at(a).getPosition();
00719       GlobalPoint posPointCorr = GlobalPoint( posPoint.x() - fAxis.x(), posPoint.y() - fAxis.y(), posPoint.z() );
00720 
00721       tempStep = posPoint.x() - fAxis.x() - fRadius * cos( posPointCorr.phi() );
00722       fChi2RPhi += tempStep*tempStep;
00723       tempStep = posPoint.y() - fAxis.y() - fRadius * sin( posPointCorr.phi() );
00724       fChi2RPhi += tempStep*tempStep;
00725 
00726       tempStep = posPoint.z() - offsetHel - propFactorHel * posPointCorr.phi();
00727       fChi2ZPhi += tempStep*tempStep;
00728     }
00729     this->setChi2RPhi( fChi2RPhi );
00730     this->setChi2ZPhi( fChi2ZPhi );
00731 
00732 */
00733 
00734 
00735 
00736 /*
00737   }
00738 
00739 
00740 
00744 
00745   template< typename T >
00746   std::string L1TkTrack< T >::print( unsigned int i ) const {
00747     std::string padding("");
00748     for ( unsigned int j=0; j!=i; ++j )padding+="\t";
00749     std::stringstream output;
00750     output<<padding<<"L1TkTrack:\n";
00751     padding+='\t';
00752     output << padding << "SeedDoubleStack: " << this->getSeedDoubleStack() << '\n';
00753     output << padding << "Length of Chain: " << theBrickStubs.size() << '\n';
00754     unsigned int iStub = 0;
00755     for ( L1TkStubPtrCollectionIterator i = theBrickStubs.begin(); i!= theBrickStubs.end(); ++i )
00756       output << padding << "stub: " << iStub++ << ", stack: \n";// << (*i)->getStack() << ", rough Pt: " << '\n';//(*i)->getRoughPt() << '\n';
00757     return output.str();
00758   }
00759 
00760   template< typename T >
00761   std::ostream& operator << (std::ostream& os, const L1TkTrack< T >& aL1TkTrack) {
00762     return (os<<aL1TkTrack.print() );
00763   }
00764 */
00765 
00766 
00767 
00768 
00769 
00770 
00771 
00772 
00773 
00774 
00775 
00776 
00777 
00778 #endif
00779 
00780