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

Generated on Thu Apr 7 22:43:27 2005 for New Track Event Model by doxygen 1.4.1