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

Track2TrFitTrackCnv.cpp

Go to the documentation of this file.
00001 // Include files 
00002 // -------------
00003 // from Gaudi
00004 #include "GaudiKernel/AlgFactory.h"
00005 #include "GaudiKernel/IDataProviderSvc.h"
00006 
00007 // from TrFitEvent
00008 #include "Event/TrFitTrack.h"
00009 #include "Event/ITClusterOnTrack.h"
00010 #include "Event/OTClusterOnTrack.h"
00011 #include "Event/VeloRClusterOnTrack.h"
00012 #include "Event/VeloPhiClusterOnTrack.h"
00013 
00014 // from TrackEvent
00015 #include "Event/Track.h"
00016 #include "Event/TrackKeys.h"
00017 
00018 // from Kernel
00019 #include "Kernel/LHCbID.h"
00020 
00021 // local
00022 #include "Track2TrFitTrackCnv.h"
00023 
00024 //-----------------------------------------------------------------------------
00025 // Implementation file for class : Track2TrFitTrackCnv
00026 //
00027 // 13/12/2004 : Eduardo Rodrigues
00028 //-----------------------------------------------------------------------------
00029 
00030 // Declaration of the Algorithm Factory
00031 static const AlgFactory<Track2TrFitTrackCnv>           Factory ;
00032 const        IAlgFactory& Track2TrFitTrackCnvFactory = Factory ;
00033 
00034 //=============================================================================
00035 // Standard constructor, initializes variables
00036 //=============================================================================
00037 Track2TrFitTrackCnv::Track2TrFitTrackCnv( const std::string& name,
00038                                           ISvcLocator* pSvcLocator)
00039   : GaudiAlgorithm    ( name , pSvcLocator )
00040   , m_inputTrackName  ( TrackLocation::Default )
00041   , m_outputTrackName ( TrFitTrackLocation::Default )
00042   , m_veloDet(0)
00043   , m_itTrackerDet(0)
00044   , m_otTrackerDet(0)
00045 {
00046   declareProperty( "InputTracks",  m_inputTrackName  );
00047   declareProperty( "OutputTracks", m_outputTrackName );
00048 }
00049 
00050 //=============================================================================
00051 // Destructor
00052 //=============================================================================
00053 Track2TrFitTrackCnv::~Track2TrFitTrackCnv() {};
00054 
00055 //=============================================================================
00056 // Initialisation. Check parameters
00057 //=============================================================================
00058 StatusCode Track2TrFitTrackCnv::initialize()
00059 {
00060   // Force the initialization of the base class
00061   //-------------------------------------------
00062   StatusCode sc = GaudiAlgorithm::initialize() ;
00063   if ( sc.isFailure() )
00064     return Error( "Base class \"GaudiAlgorithm\" was not initialized properly!" );
00065 
00066   debug() << "==> Initialize" << endreq;
00067 
00068   // Retrieve the Velo Geometry
00069   m_veloDet = getDet<DeVelo>( "/dd/Structure/LHCb/Velo" );
00070 
00071   // Retrieve the ST Geometry
00072   m_itTrackerDet = getDet<DeSTDetector>( DeSTDetectorLocation::Default );
00073 
00074   // Retrieve the OT Geometry
00075   m_otTrackerDet = getDet<DeOTDetector>( "/dd/Structure/LHCb/OT" );
00076 
00077   return StatusCode::SUCCESS;
00078 }
00079 
00080 //=============================================================================
00081 // Main execution
00082 //=============================================================================
00083 StatusCode Track2TrFitTrackCnv::execute() {
00084 
00085   debug() << "==> Execute" << endreq;
00086 
00087   // retrieve the Tracks container
00088   Tracks* inTra = get<Tracks>( m_inputTrackName );
00089   debug() << "- # Tracks = " << inTra -> size() << endreq;
00090 
00091   // create and register the TrFitTracks container
00092   TrFitTracks* outTra = new TrFitTracks();
00093   StatusCode sc = put( outTra, m_outputTrackName );
00094 
00095   Tracks::const_iterator              itSto;
00096   std::vector<LHCbID>::const_iterator itID;
00097 
00098   TrFitTrack*                         trFit;
00099 
00100   debug() << "Processing Tracks ... " << endreq;
00101 
00102   for ( itSto = inTra->begin(); inTra->end() != itSto ; ++itSto) {
00103     // create the TrFitTrack
00104     trFit = new TrFitTrack();
00105     outTra -> insert( trFit, (*itSto)->key() );   // Same key, for associators
00106 
00107     // debugging Track ...
00108     debug()
00109       << "- Track with key # " << (*itSto) -> key() << endreq
00110       << "  * charge        = " << (*itSto) -> charge() << endreq
00111       << "  * is Valid      = " << (*itSto) -> checkFlag( TrackKeys::Valid ) << endreq
00112       << "  * is Unique     = " << (*itSto) -> checkFlag( TrackKeys::Unique ) << endreq
00113       << "  * is Long       = " << (*itSto) -> checkType( TrackKeys::Long ) << endreq
00114       << "  * is Upstream   = " << (*itSto) -> checkType( TrackKeys::Upstream ) << endreq
00115       << "  * is Downstream = " << (*itSto) -> checkType( TrackKeys::Downstream ) << endreq
00116       << "  * is Velo       = " << (*itSto) -> checkType( TrackKeys::Velo ) << endreq
00117       << "  * is Backward   = " << (*itSto) -> checkType( TrackKeys::Backward ) << endreq
00118       << "  * is Ttrack     = " << (*itSto) -> checkType( TrackKeys::Ttrack ) << endreq
00119       << "  * # LHCbIDs     = " << (*itSto) -> lhcbIDs().size() << endreq;
00120 
00121     // set the properties of TrFitTrack
00122     trFit -> setCharge( (*itSto)->charge() );
00123     trFit -> setErrorFlag( (bool) !((*itSto)->checkFlag(TrackKeys::Valid)) );
00124     trFit -> setUnique( (bool) ((*itSto)->checkFlag(TrackKeys::Unique)) );
00125 
00126     if      ( (*itSto)->checkType( TrackKeys::Long ) )       trFit -> setForward(true); // could also be match!
00127     else if ( (*itSto)->checkType( TrackKeys::Upstream ) )   trFit -> setVeloTT( true );
00128     else if ( (*itSto)->checkType( TrackKeys::Downstream ) ) trFit -> setFollow( true ); // could also be ksTrack
00129     else if ( (*itSto)->checkType( TrackKeys::Velo ) )       trFit -> setVelo( true );
00130     else if ( (*itSto)->checkType( TrackKeys::Backward ) )   trFit -> setVeloBack( true );
00131     else if ( (*itSto)->checkType( TrackKeys::Ttrack ) )     trFit -> setSeed( true);
00132 
00133     // look at the "first state"
00134     State& pstate = (*itSto) -> firstState();
00135     TrStateP* trStaP = new TrStateP( pstate.z(), pstate.stateVector(), pstate.covariance() );
00136     // put the created TrStateP in TrFitTrack
00137     trFit -> addState( trStaP );
00138     debug() << "  -> stored physics state at z = " << pstate.z() << " as TrStateP" << endreq
00139             << "    - (x,y,z)     = (" << pstate.x() << ", "
00140             << pstate.y() << ", "
00141             << pstate.z() << ")" << endreq
00142             << "    - tx, ty, Q/P = " << pstate.tx() << ", "
00143             << pstate.ty() << ", "
00144             << pstate.qOverP() << endreq;
00145 
00146     // loop over the LHCbIDs
00147     const std::vector<LHCbID> trStoID = (*itSto) -> lhcbIDs();
00148     for ( itID = trStoID.begin(); itID != trStoID.end(); ++itID) {
00149       // continue according to type ...
00150       if ( (*itID).isOT() ) {
00151         OTChannelID otChID = (*itID).otID();
00152         OTTimes* otTimes = get<OTTimes>( OTTimeLocation::Default );
00153         OTTimes::const_iterator itOTTime;
00154         for ( itOTTime=otTimes->begin() ; otTimes->end()!= itOTTime ; ++itOTTime ) {
00155           if ( otChID == (*itOTTime)->channel() ) {
00156             // create OTClusterOnTrack
00157             int driftAmbiguity = 0;
00158             //driftAmbiguity stored in the LHCbID in the
00159             // spareBits: 11 / 10 for ambiguity = +1 / -1
00160             if      ( (*itID).spareBits() == 2 ) { driftAmbiguity = -1; }
00161             else if ( (*itID).spareBits() == 3 ) { driftAmbiguity =  1; }
00162             OTClusterOnTrack* otCluOnT =
00163               new OTClusterOnTrack( (*itOTTime), driftAmbiguity, m_otTrackerDet );
00164             // add OTClusterOnTrack to the TrFitTrack
00165             trFit -> addMeasurement( otCluOnT );
00166             debug() << "  * LHCbID = " << (*itID).lhcbID()
00167                     << "  (detectorType / spareBits = "
00168                     << (*itID).detectorType() << " / "
00169                     << (*itID).spareBits() << ")" << endreq
00170                     << "  -> stored OTClusterOnTrack at z = "
00171                     << otCluOnT -> z()
00172                           << " , channelID = "
00173                     << (*itOTTime) -> channel().channelID()
00174                     << " , ambiguity = " << otCluOnT -> ambiguity() << endreq;
00175           }
00176         }
00177       }
00178       else if ( (*itID).isST() ) {
00179         ITChannelID itChID = (*itID).stID();
00180         ITClusters* itClus = get<ITClusters>( ITClusterLocation::Default );
00181         ITClusters::const_iterator itITClu;
00182         for ( itITClu=itClus->begin() ; itClus->end()!= itITClu ; ++itITClu ) {
00183           if ( itChID == (*itITClu)->channelID() ) {
00184             // create ITClusterOnTrack
00185             ITClusterOnTrack* itCluOnT =
00186               new ITClusterOnTrack( (*itITClu), m_itTrackerDet );
00187             // add ITClusterOnTrack to the TrFitTrack
00188             trFit -> addMeasurement( itCluOnT );
00189             debug() << "  * LHCbID = " << (*itID).lhcbID()
00190                     << "  (detectorType / spareBits = "
00191                     << (*itID).detectorType() << " / "
00192                     << (*itID).spareBits() << ")" << endreq
00193                     << "  -> stored ITClusterOnTrack at z = "
00194                     << itCluOnT -> z()
00195                           << " , channelID = "
00196                     << (*itITClu) -> channelID().channelID() << endreq;
00197           }
00198         }
00199       }
00200       else if ( (*itID).isVelo() ) {
00201         VeloChannelID veloChID = (*itID).veloID();
00202         VeloClusters* veloClus = get<VeloClusters>( VeloClusterLocation::Default );
00203         VeloClusters::const_iterator itVeloClu;
00204         for ( itVeloClu=veloClus->begin() ; veloClus->end()!= itVeloClu ; ++itVeloClu ) {
00205           if ( veloChID.channelID() == (*itVeloClu)->channelID(0).channelID() ) {
00206             debug() << "  -> VeloChannelID of type R/Phi = "
00207                     << m_veloDet->isRSensor( (*itVeloClu)->sensor() ) << "/"
00208                     << m_veloDet->isPhiSensor( (*itVeloClu)->sensor() ) << endreq
00209                     << "sensor # from velocluster = "
00210                     << (*itVeloClu)->sensor() << endreq
00211                     << "VChID, sensor, veloChannelID.type = "
00212                     <<  veloChID<< " , " << veloChID.sensor() << " , "
00213                     << veloChID.type() << endreq;
00214             //if ( veloChID.isRType() ) {
00215             if ( m_veloDet->isRSensor( (*itVeloClu)->sensor() ) ) {
00216                     debug()
00217                 << "  -> stored as type R(sensorType=1), VChID, veloChannelID.type = "
00218                 <<  veloChID << " , " << veloChID.type() << endreq;
00219               // create VeloRClusterOnTrack
00220               VeloRClusterOnTrack* veloRCluOnT =
00221                 new VeloRClusterOnTrack( (*itVeloClu), m_veloDet );
00222               // add VeloRClusterOnTrack to the TrFitTrack
00223               trFit -> addMeasurement( veloRCluOnT );
00224             }
00225                   else {
00226               debug()
00227                 << "  -> stored as type Phi(sensorType=2), veloChannelID.type = "
00228                 << veloChID.type() << endreq;
00229               // create VeloPhiClusterOnTrack
00230               VeloPhiClusterOnTrack* veloPhiCluOnT =
00231                 new VeloPhiClusterOnTrack( (*itVeloClu), m_veloDet );
00232               // add VeloPhiClusterOnTrack to the TrFitTrack
00233               trFit -> addMeasurement( veloPhiCluOnT );
00234             }
00235           }
00236         }
00237       }
00238     }
00239     // debugging TrFitTrack ...
00240     debug()
00241       << "  -> TrFitTrack stored with key # " << trFit -> key() << endreq
00242       << "    * # states       = " << trFit -> nStates() << endreq
00243       << "    * # measurements = " << trFit -> nMeasurements() << endreq
00244       << "      - # IT         = "
00245       << trFit -> nMeasurements( TrMeasurement::kITClusterOnTrack ) << endreq
00246       << "      - # OT         = "
00247       << trFit -> nMeasurements( TrMeasurement::kOTClusterOnTrack ) << endreq
00248       << "      - # VeloR      = "
00249       << trFit -> nMeasurements( TrMeasurement::kVeloRClusterOnTrack ) << endreq
00250       << "      - # VeloPhi    = "
00251       << trFit -> nMeasurements( TrMeasurement::kVeloPhiClusterOnTrack ) << endreq
00252       << "    * charge         = " << trFit -> charge() << endreq
00253       << "    * error flag     = " << trFit -> errorFlag() << endreq
00254       << "    * is Unique      = " << trFit -> unique() << endreq
00255       << "    * is Long        = " << trFit -> isLong() << endreq
00256       << "    * is Upstream    = " << trFit -> isUpstream() << endreq
00257       << "    * is Downstream  = " << trFit -> isDownstream() << endreq
00258       << "    * is Velotrack   = " << trFit -> isVelotrack() << endreq
00259       << "    * is Backward    = " << trFit -> isBackward() << endreq
00260       << "    * is Ttrack      = " << trFit -> isTtrack() << endreq
00261       << "    * velo           = " << trFit -> velo() << endreq
00262       << "    * seed           = " << trFit -> seed() << endreq
00263       << "    * match          = " << trFit -> match() << endreq
00264       << "    * forward        = " << trFit -> forward() << endreq
00265       << "    * follow         = " << trFit -> follow() << endreq
00266       << "    * veloTT         = " << trFit -> veloTT() << endreq
00267       << "    * veloBack       = " << trFit -> veloBack() << endreq
00268       << "    * ksTrack        = " << trFit -> ksTrack() << endreq;
00269   }
00270   // summary of stored information
00271   //debug() << "-> stored " << outTra -> size() << " TrFitTracks " << endreq;
00272 
00273   return StatusCode::SUCCESS;
00274 }
00275 
00276 //=============================================================================
00277 //  Finalize
00278 //=============================================================================
00279 StatusCode Track2TrFitTrackCnv::finalize()
00280 {
00281   debug() << "==> Finalize" << endreq;
00282 
00283   //if( m_associator ) toolSvc()->releaseTool( m_associator );
00284 
00285   // Force the finalization of the base class
00286   //-----------------------------------------
00287   return GaudiAlgorithm::finalize();
00288 }

Generated on Fri May 27 13:59:37 2005 for New Track Event Model by doxygen 1.4.1