00001
00002
00003
00004 #include "GaudiKernel/ToolFactory.h"
00005
00006
00007 #include "TrackProjectors/TrackVeloPhiProjector.h"
00008 #include "Event/VeloPhiMeasurement.h"
00009
00010
00011
00012
00013
00014
00015
00016
00017 static const ToolFactory<TrackVeloPhiProjector> s_factory ;
00018 const IToolFactory& TrackVeloPhiProjectorFactory = s_factory ;
00019
00020
00021
00022
00023
00024 StatusCode TrackVeloPhiProjector::project( const State& state,
00025 Measurement& meas )
00026 {
00027 double x = state.x();
00028 double y = state.y();
00029
00030 VeloPhiMeasurement& veloPhiMeas = *( dynamic_cast<VeloPhiMeasurement*>(&meas) );
00031
00032 int sensor = veloPhiMeas.cluster() -> sensor();
00033
00034 double sum = 0.;
00035 double sum2 = 0.;
00036 double sums = 0.;
00037 double second = 0.;
00038 double phi = -999.;
00039 double cosPhi = 0.;
00040 double sinPhi = 0.;
00041
00042 std::vector< std::pair<long,double> > sign = veloPhiMeas.cluster()->stripSignals();
00043 std::vector< std::pair<long,double> >::const_iterator strIt;
00044 int strip = (*sign.begin()).first;
00045 VeloChannelID channel(sensor,strip);
00046 for ( strIt = sign.begin() ; sign.end() != strIt ; strIt++ ) {
00047 strip = (*strIt).first;
00048 phi = m_det -> trgPhiDirectionOfStrip( channel );
00049 second = (*strIt).second;
00050 sum += second;
00051 sum2 += second * second;
00052 sums += second * phi ;
00053 }
00054 if ( 0 < sum ) {
00055 double phi = sums / sum;
00056 cosPhi = cos( phi );
00057 sinPhi = sin( phi );
00058 }
00059
00060 unsigned int n = state.nParameters();
00061 m_H = HepVector(n,0);
00062
00063 m_H[0] = - sinPhi;
00064 m_H[1] = cosPhi;
00065 m_H[2] = 0.;
00066
00067 m_residual = meas.measure() - ( y * cosPhi - x * sinPhi );
00068
00069 computeErrorResidual( state, meas );
00070
00071 return StatusCode::SUCCESS ;
00072 }
00073
00074
00075
00076
00077 StatusCode TrackVeloPhiProjector::initialize()
00078 {
00079 StatusCode sc = GaudiTool::initialize();
00080 if ( sc.isFailure() )
00081 return Error( "Failed to initialize!", sc );
00082
00083 m_det = getDet<DeVelo>( m_veloPath );
00084
00085 return StatusCode::SUCCESS;
00086 }
00087
00088
00089
00090
00091 TrackVeloPhiProjector::TrackVeloPhiProjector( const std::string& type,
00092 const std::string& name,
00093 const IInterface* parent )
00094 : TrackProjector ( type, name , parent )
00095 {
00096 declareInterface<ITrackProjector>(this);
00097
00098 declareProperty( "VeloGeometryPath",
00099 m_veloPath = "/dd/Structure/LHCb/Velo" );
00100 }
00101
00102
00103
00104 TrackVeloPhiProjector::~TrackVeloPhiProjector() {};
00105
00106