Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

TrFitTrack2TrackCnv Class Reference

#include <TrFitTrack2TrackCnv.h>

List of all members.

Public Member Functions

 TrFitTrack2TrackCnv (const std::string &name, ISvcLocator *pSvcLocator)
 Standard constructor.
virtual ~TrFitTrack2TrackCnv ()
 Destructor.
virtual StatusCode initialize ()
 Algorithm initialization.
virtual StatusCode execute ()
 Algorithm execution.
virtual StatusCode finalize ()
 Algorithm finalization.

Private Attributes

std::string m_inputTrackName
 Path of the input ("TrFitTrack") tracks.
std::string m_outputTrackName
 Path of the output ("Track") tracks.
bool m_convertAllStates
 Create all States and not just the "firstState".
bool m_createMeasurements
 Create the Measurements from the LHCbIDs?
IMeasurementProviderm_measProvider
 MeasurementProvider tool.


Detailed Description

Converts a TrFitTrack to a Track

Author:
Eduardo Rodrigues
Date:
13/12/2004

Definition at line 20 of file TrFitTrack2TrackCnv.h.


Constructor & Destructor Documentation

TrFitTrack2TrackCnv::TrFitTrack2TrackCnv const std::string &  name,
ISvcLocator *  pSvcLocator
 

Standard constructor.

Definition at line 38 of file TrFitTrack2TrackCnv.cpp.

References m_convertAllStates, m_createMeasurements, m_inputTrackName, and m_outputTrackName.

00040   : GaudiAlgorithm    ( name , pSvcLocator )
00041   , m_inputTrackName  ( TrFitTrackLocation::Default )
00042   , m_outputTrackName ( TrackLocation::Default )
00043   , m_measProvider(0)
00044 {
00045   declareProperty( "InputTracks" ,     m_inputTrackName  );
00046   declareProperty( "OutputTracks",     m_outputTrackName );
00047   declareProperty( "ConvertAllStates", m_convertAllStates = true );
00048   declareProperty( "LoadMeasurements", m_createMeasurements = true );
00049 }

TrFitTrack2TrackCnv::~TrFitTrack2TrackCnv  )  [virtual]
 

Destructor.

Definition at line 54 of file TrFitTrack2TrackCnv.cpp.

00054 {}; 


Member Function Documentation

StatusCode TrFitTrack2TrackCnv::execute  )  [virtual]
 

Algorithm execution.

Definition at line 81 of file TrFitTrack2TrackCnv.cpp.

References LHCbID::channelID(), Track::clone(), LHCbID::detectorType(), LHCbID::lhcbID(), m_convertAllStates, m_createMeasurements, m_inputTrackName, m_measProvider, m_outputTrackName, TrackFunctor::nMeasurements(), State::setCovariance(), LHCbID::setSpareBits(), State::setState(), LHCbID::spareBits(), and str::states().

00081                                         {
00082 
00083   debug() << "==> Execute" << endreq;
00084 
00085   // retrieve the TrFitTracks container
00086   TrFitTracks* inTra = get<TrFitTracks>( m_inputTrackName );
00087   debug() << "- # TrFitTracks = " << inTra -> size() << endreq;
00088 
00089   // create and register the Tracks container
00090   Tracks* outTra = new Tracks();
00091   StatusCode sc = eventSvc() -> registerObject( m_outputTrackName, outTra );
00092   if( sc.isFailure() ) {
00093     delete outTra;
00094     error() << "Unable to register the output container "
00095             << m_outputTrackName << ". Status is " << sc << endreq;
00096     return sc ;
00097   }
00098   else {
00099     debug() << "Output container " << m_outputTrackName
00100             << " registered" << endreq;
00101   }
00102 
00103   TrStateP*                               trStaP;
00104   TrStateL*                               trStaL;
00105   TrState*                                trSta;
00106   OTClusterOnTrack*                       myOt;
00107   ITClusterOnTrack*                       myIt;
00108   VeloRClusterOnTrack*                    myRV;
00109   VeloPhiClusterOnTrack*                  myPV;
00110   TrFitTracks::const_iterator             itF;
00111   TrStates::const_iterator                itS;
00112   TrTrack::TrMeasurements::const_iterator itM;
00113 
00114   Track*              trSto;
00115   LHCbID              myID;
00116   std::vector<LHCbID> myIDs;
00117 
00118   // need to load XxxClusters and OTTimes
00119   if ( m_createMeasurements ) m_measProvider -> load();
00120 
00121   debug() << "Processing TrFitTracks ... " << endreq;
00122 
00123   for ( itF = inTra->begin() ; inTra->end() != itF ; ++itF ) {
00124     // create the Track
00125     trSto = new Track();
00126     outTra -> insert( trSto, (*itF)->key() );   // Same key, for associators
00127 
00128     // debugging TrFitTrack ...
00129     debug()
00130       << "- TrFitTrack with key # " << (*itF) -> key() << endreq
00131       << "  * # states       = " << (*itF) -> nStates() << endreq
00132       << "  * # measurements = " << (*itF) -> nMeasurements() << endreq
00133       << "    - # IT         = " << (*itF) -> nMeasurements( TrMeasurement::kITClusterOnTrack ) << endreq
00134       << "    - # OT         = " << (*itF) -> nMeasurements( TrMeasurement::kOTClusterOnTrack ) << endreq
00135       << "    - # VeloR      = " << (*itF) -> nMeasurements( TrMeasurement::kVeloRClusterOnTrack ) << endreq
00136       << "    - # VeloPhi    = " << (*itF) -> nMeasurements( TrMeasurement::kVeloPhiClusterOnTrack ) << endreq
00137       << "  * charge         = " << (*itF) -> charge() << endreq
00138       << "  * error flag     = " << (*itF) -> errorFlag() << endreq
00139       << "  * is Unique      = " << (*itF) -> unique() << endreq
00140       << "  * is Long        = " << (*itF) -> isLong() << endreq
00141       << "  * is Upstream    = " << (*itF) -> isUpstream() << endreq
00142       << "  * is Downstream  = " << (*itF) -> isDownstream() << endreq
00143       << "  * is Velotrack   = " << (*itF) -> isVelotrack() << endreq
00144       << "  * is Backward    = " << (*itF) -> isBackward() << endreq
00145       << "  * is Ttrack      = " << (*itF) -> isTtrack() << endreq
00146       << "  * velo           = " << (*itF) -> velo() << endreq
00147       << "  * seed           = " << (*itF) -> seed() << endreq
00148       << "  * match          = " << (*itF) -> match() << endreq
00149       << "  * forward        = " << (*itF) -> forward() << endreq
00150       << "  * follow         = " << (*itF) -> follow() << endreq
00151       << "  * veloTT         = " << (*itF) -> veloTT() << endreq
00152       << "  * veloBack       = " << (*itF) -> veloBack() << endreq
00153       << "  * ksTrack        = " << (*itF) -> ksTrack() << endreq;
00154 
00155     // set the properties of Track
00156     // (the charge is calculated from Q/P of the first state)
00157     if ( (bool) (*itF)->errorFlag() )  trSto -> setFlag( TrackKeys::Invalid, true );
00158     if ( (bool) (*itF)->unique() )     trSto -> setFlag( TrackKeys::Unique, true );
00159 
00160     if      ( (*itF)->isLong() )       trSto -> setType( TrackKeys::Long );
00161     else if ( (*itF)->isUpstream() )   trSto -> setType( TrackKeys::Upstream );
00162     else if ( (*itF)->isDownstream() ) trSto -> setType( TrackKeys::Downstream );
00163     else if ( (*itF)->isVelotrack() )  trSto -> setType( TrackKeys::Velo );
00164     else if ( (*itF)->isBackward() ) { trSto -> setType( TrackKeys::Velo );
00165                                        trSto -> setFlag( TrackKeys::Backward, true );
00166                                      }
00167     
00168     else if ( (*itF)->isTtrack() )     trSto -> setType( TrackKeys::Ttrack );
00169 
00170     if ( (*itF)->ksTrack() ) trSto -> setHistory( TrackKeys::TrKshort );
00171 
00172     // debugging Track ...
00173     debug()
00174       << "  -> Track stored with key # " << trSto -> key() << endreq
00175       << "    * is Invalid    = "
00176       << trSto -> checkFlag( TrackKeys::Invalid ) << endreq
00177       << "    * is Unique     = "
00178       << trSto -> checkFlag( TrackKeys::Unique ) << endreq
00179       << "    * is Long       = "
00180       << trSto -> checkType( TrackKeys::Long ) << endreq
00181       << "    * is Upstream   = "
00182       << trSto -> checkType( TrackKeys::Upstream ) << endreq
00183       << "    * is Downstream = "
00184       << trSto -> checkType( TrackKeys::Downstream ) << endreq
00185       << "    * is Velo       = "
00186       << trSto -> checkType( TrackKeys::Velo ) << endreq
00187       << "    * is Backward   = "
00188       << trSto -> checkFlag( TrackKeys::Backward ) << endreq
00189       << "    * is Ttrack     = "
00190       << trSto -> checkType( TrackKeys::Ttrack ) << endreq;
00191 
00192     // loop over the states in TrFitTrack
00193     if ( m_convertAllStates ) {
00194       unsigned ist = 0;
00195       for ( itS = (*itF)->beginS() ; (*itF)->endS() != itS; itS++ ) {
00196         trSta = (*itS)->clone();
00197         trStaP = dynamic_cast<TrStateP*>(trSta);
00198         trStaL = dynamic_cast<TrStateL*>(trSta);
00199         if ( 0 != trStaP ) {
00200           verbose() << "  * TrStateP # " << ist++ << endreq
00201                     << "    - (x,y,z)     = (" << trStaP -> x() << ", "
00202                     << trStaP -> y() << ", "
00203                     << trStaP -> z() << ")" << endreq
00204                     << "    - tx, ty, Q/P = " << trStaP -> tx() << ", "
00205                     << trStaP -> ty() << ", "
00206                     << trStaP -> qDivP() << endreq;
00207           State pstate = State();
00208           pstate.setState( trStaP->x(), trStaP->y(), trStaP->z(),
00209                            trStaP->tx(), trStaP->ty(), trStaP->qDivP() );
00210           pstate.setCovariance( trStaP->stateCov() );
00211           trSto -> addToStates( pstate );
00212           verbose() << "  -> stored TrStateP at z = " << trStaP -> z()
00213                     << " as state # " << ist << endreq;
00214         }
00215         else if ( 0 != trStaL ) {
00216           verbose() << "  * TrStateL # " << ist++ << endreq
00217                     << "    - (x,y,z) = (" << trStaL -> x() << ", "
00218                     << trStaL -> y() << ", "
00219                     << trStaL -> z() << ")" << endreq
00220                     << "    - tx, ty  = " << trStaL -> tx() << ", "
00221                     << trStaL -> ty() << endreq;
00222           State lstate = State();
00223           lstate.setState( trStaL->x(), trStaL->y(), trStaL->z(),
00224                            trStaL->tx(), trStaL->ty(), 0. );
00225           lstate.setCovariance( trStaL->stateCov() );
00226           trSto -> addToStates( lstate );
00227           verbose() << "  -> stored TrStateL at z = " << trStaL -> z()
00228                     << " as state # " << ist << endreq;
00229         }
00230         else {
00231           verbose() << "  * unknown state at z =" << trSta -> z() << "!" << endreq;
00232           delete trSta;
00233         }
00234       }
00235     }
00236     else {
00237       // store the state closest to the nominal IP as the "first state"
00238       trSta = (*itF) -> closestState(0.);
00239       trStaP = dynamic_cast<TrStateP*>(trSta);
00240       trStaL = dynamic_cast<TrStateL*>(trSta);
00241       if ( 0 != trStaP ) {
00242         //State& pstate = trSto -> firstState();
00243         State pstate = State();
00244         pstate.setState( trStaP->x(), trStaP->y(), trStaP->z(),
00245                          trStaP->tx(), trStaP->ty(), trStaP->qDivP() );
00246         pstate.setCovariance( trStaP->stateCov() );
00247         trSto -> addToStates( pstate );
00248         verbose() << "  -> stored TrStateP at z = " << trStaP -> z()
00249                 << " as first state" << endreq;
00250       }
00251       else if ( 0 != trStaL ) {
00252         verbose() << "  -> no first state stored!" << endreq;
00253       }
00254       debug() << "  -> track charge = " << trSto -> charge() << endreq;
00255     }
00256     debug() << "  -> # States stored = " << trSto -> states().size() << endreq;
00257     
00258     // loop over the measurements in TrFitTrack
00259     myIDs.clear();
00260     for ( itM = (*itF)->beginM() ; (*itF)->endM() != itM ; itM++ ) {
00261       if ( TrMeasurement::kOTClusterOnTrack == (*itM)->measType()) {
00262         // old event model stored the following OT measurement properties:
00263         //   cluster       <- OTTime
00264         //   ambiguity     <- from pattern recognition algorithms
00265         //   z             <- calculated from the detector element,
00266         //                    OTTime and drift ambiguity
00267         //   residual      <- from track fit
00268         //   errorResidual <- from track fit
00269         // -> only needs to be stored: OTTime and drift ambiguity
00270         myOt = dynamic_cast<OTClusterOnTrack*>(*itM);
00271         OTTime* otTime = myOt -> time();
00272         myID = LHCbID( otTime -> channel() );
00273         int amb = myOt -> ambiguity();
00274         // spareBits: 11 / 10 for ambiguity = +1 / -1
00275         if ( amb != 0 ) {
00276           ( amb < 0 ) ? myID.setSpareBits( 2 ) : myID.setSpareBits( 3 );
00277         }
00278         else {
00279           myID.setSpareBits( 0 );
00280         }
00281         myIDs.push_back( myID );
00282         verbose() << "  * OTCluster at z = " << myOt -> z()
00283                   << " , channelID = " << otTime -> channel().channelID()
00284                   << " , ambiguity = " << amb << endreq
00285                   << "  -> stored as LHCbID = " << myID.lhcbID()
00286                   << "  (detectorType / spareBits = "
00287                   << myID.detectorType() << " / "
00288                   << myID.spareBits() << ")" << endreq;
00289         if ( m_createMeasurements ) {
00290           Measurement& meas = m_measProvider -> measurement( myID, amb);
00291           trSto -> addToMeasurements(meas);          
00292         }
00293       }
00294       else if ( TrMeasurement::kITClusterOnTrack == (*itM)->measType() ) {
00295         // old event model stored the following IT measurement properties:
00296         //   cluster       <- ITCluster
00297         //   z             <- calculated from the detector element
00298         //                    and the ITCluster
00299         //   residual      <- from track fit
00300         //   errorResidual <- from track fit
00301         // -> only needs to be stored: ITCluster
00302         myIt = dynamic_cast<ITClusterOnTrack*>(*itM);
00303         ITCluster* itClu = myIt -> cluster();
00304         myID = LHCbID( itClu -> channelID() );
00305         myIDs.push_back( myID );
00306         verbose() << "  * ITCluster at z = " << myIt -> z()
00307                   << " , channelID = "
00308                   << itClu -> channelID().channelID() << endreq
00309                   << "  -> stored as LHCbID = " << myID.lhcbID()
00310                   << "  (detectorType / spareBits = "
00311                   << myID.detectorType() << " / "
00312                   << myID.spareBits() << ")" << endreq;
00313         if ( m_createMeasurements ) {
00314           Measurement& meas = m_measProvider -> measurement( myID );
00315           trSto -> addToMeasurements(meas);          
00316         }
00317       }
00318       else if ( TrMeasurement::kVeloRClusterOnTrack == (*itM)->measType() ) {
00319         // old event model stored the following Velo-R measurement properties:
00320         //   cluster       <- VeloCluster
00321         //   z             <- calculated from the detector element
00322         //                    and the VeloCluster
00323         //   residual      <- from track fit
00324         //   errorResidual <- from track fit
00325         // -> only needs to be stored: VeloCluster
00326         myRV = dynamic_cast<VeloRClusterOnTrack*>(*itM);
00327         VeloCluster* veloClu = myRV -> cluster();
00328         int sensor = veloClu -> sensor();
00329         std::vector< std::pair<long,double> > sign = veloClu->stripSignals();
00330         int strip = (*sign.begin()).first;
00331         VeloChannelID channel(sensor,strip);
00332         myID = LHCbID( channel );
00333         myIDs.push_back( myID );
00334         verbose() << "  * R Velo Cluster at z = " << myRV -> z()
00335                   << " , VeloChannelID = " << channel << endreq
00336                   << " , key = " << veloClu -> key() << endreq
00337                   << "  -> stored as LHCbID = " << myID.lhcbID()
00338                   << "  (detectorType / spareBits = "
00339                   << myID.detectorType() << " / "
00340                   << myID.spareBits() << ")" << endreq;
00341         if ( m_createMeasurements ) {
00342           Measurement& meas = m_measProvider -> measurement( myID );
00343           trSto -> addToMeasurements(meas);          
00344         }
00345       }
00346       else if ( TrMeasurement::kVeloPhiClusterOnTrack == (*itM)->measType() ) {
00347         // old event model stored the following Velo-Phi measurement properties:
00348         //   cluster       <- VeloCluster
00349         //   z             <- calculated from the det. elem. and VeloCluster
00350         //   residual      <- from track fit
00351         //   errorResidual <- from track fit
00352         // -> only needs to be stored: VeloCluster
00353         myPV = dynamic_cast<VeloPhiClusterOnTrack*>(*itM);
00354         VeloCluster* veloClu = myPV -> cluster();
00355         int sensor = veloClu -> sensor();
00356         std::vector< std::pair<long,double> > sign = veloClu->stripSignals();
00357         int strip = (*sign.begin()).first;
00358         VeloChannelID channel(sensor,strip);
00359         myID = LHCbID( channel );
00360         myIDs.push_back( myID );
00361         verbose() << "  * Phi Velo Cluster at z = " << myPV -> z()
00362                   << " , VeloChannelID = " << channel << endreq
00363                   << " , key = " << veloClu -> key() << endreq
00364                   << "  -> stored as LHCbID = " << myID.lhcbID()
00365                   << "  (detectorType / spareBits = "
00366                   << myID.detectorType() << " / "
00367                   << myID.spareBits() << ")" << endreq;
00368         if ( m_createMeasurements ) {
00369           Measurement& meas = m_measProvider -> measurement( myID );
00370           trSto -> addToMeasurements(meas);          
00371         }
00372       }
00373     }
00374     // store all the measurements as LHCbIDs
00375     trSto -> setLhcbIDs( myIDs );
00376     debug() << "  -> # LHCbIDs stored = " << myIDs.size() << endreq;
00377     // create also the measurements if requested
00378     if ( m_createMeasurements ) {
00379       //sc = m_measProvider -> load( *trSto );
00380       trSto -> setStatus( TrackKeys::PatRecMeas );
00381       debug() << "  -> # measurements created = "
00382               << trSto -> measurements().size() << endreq;
00383     }
00384   } // end of loop over TrFitTracks
00385 
00386   // summary of stored information
00387   debug() << "-> stored " << outTra -> size() << " Tracks " << endreq;
00388 
00389   return StatusCode::SUCCESS;
00390 };

StatusCode TrFitTrack2TrackCnv::finalize  )  [virtual]
 

Algorithm finalization.

Definition at line 395 of file TrFitTrack2TrackCnv.cpp.

00395                                          {
00396 
00397   debug() << "==> Finalize" << endreq;
00398 
00399   // Force the finalization of the base class
00400   //-----------------------------------------
00401   return GaudiAlgorithm::finalize();
00402 }

StatusCode TrFitTrack2TrackCnv::initialize  )  [virtual]
 

Algorithm initialization.

Definition at line 59 of file TrFitTrack2TrackCnv.cpp.

References m_measProvider.

00059                                            {
00060 
00061   // Force the initialization of the base class
00062   //-------------------------------------------
00063   StatusCode sc = GaudiAlgorithm::initialize() ;
00064   if ( sc.isFailure() )
00065     return Error( "Base class \"GaudiAlgorithm\" was not initialized properly!" );
00066 
00067   debug() << "==> Initialize" << endreq;
00068 
00069   m_measProvider = tool<IMeasurementProvider>( "MeasurementProvider" );
00070   if ( 0 == m_measProvider )
00071     return Error( "Unable to retrieve the \"MeasurementProvider\" tool!" );
00072   else
00073     debug() << "Found the \"MeasurementProvider\" tool" << endreq;
00074 
00075   return StatusCode::SUCCESS;
00076 };


Member Data Documentation

bool TrFitTrack2TrackCnv::m_convertAllStates [private]
 

Create all States and not just the "firstState".

Definition at line 39 of file TrFitTrack2TrackCnv.h.

Referenced by execute(), and TrFitTrack2TrackCnv().

bool TrFitTrack2TrackCnv::m_createMeasurements [private]
 

Create the Measurements from the LHCbIDs?

Definition at line 40 of file TrFitTrack2TrackCnv.h.

Referenced by execute(), and TrFitTrack2TrackCnv().

std::string TrFitTrack2TrackCnv::m_inputTrackName [private]
 

Path of the input ("TrFitTrack") tracks.

Definition at line 36 of file TrFitTrack2TrackCnv.h.

Referenced by execute(), and TrFitTrack2TrackCnv().

IMeasurementProvider* TrFitTrack2TrackCnv::m_measProvider [private]
 

MeasurementProvider tool.

Definition at line 42 of file TrFitTrack2TrackCnv.h.

Referenced by execute(), and initialize().

std::string TrFitTrack2TrackCnv::m_outputTrackName [private]
 

Path of the output ("Track") tracks.

Definition at line 37 of file TrFitTrack2TrackCnv.h.

Referenced by execute(), and TrFitTrack2TrackCnv().


The documentation for this class was generated from the following files:
Generated on Mon Jul 4 13:54:55 2005 for New Track Event Model by doxygen 1.4.1