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   if( sc.isFailure() ) {
00095     delete outTra;
00096     error() << "Unable to register the output container "
00097             << m_outputTrackName << ". Status is " << sc << endreq;
00098     return sc ;
00099   }
00100   else {
00101     debug() << "Output container " << m_outputTrackName
00102             << " registered" << endreq;
00103   }
00104 
00105 
00106   Tracks::const_iterator              itSto;
00107   std::vector<LHCbID>::const_iterator itID;
00108 
00109   TrFitTrack*                         trFit;
00110 
00111   debug() << "Processing Tracks ... " << endreq;
00112 
00113   for ( itSto = inTra->begin(); inTra->end() != itSto ; ++itSto) {
00114     // create the TrFitTrack
00115     trFit = new TrFitTrack();
00116     outTra -> insert( trFit, (*itSto)->key() );   // Same key, for associators
00117 
00118     // debugging Track ...
00119     debug()
00120       << "- Track with key # " << (*itSto) -> key() << endreq
00121       << "  * charge        = " << (*itSto) -> charge() << endreq
00122       << "  * is Valid      = " << !(*itSto) -> checkFlag( TrackKeys::Invalid ) << endreq
00123       << "  * is Unique     = " << (*itSto) -> checkFlag( TrackKeys::Unique ) << endreq
00124       << "  * is Long       = " << (*itSto) -> checkType( TrackKeys::Long ) << endreq
00125       << "  * is Upstream   = " << (*itSto) -> checkType( TrackKeys::Upstream ) << endreq
00126       << "  * is Downstream = " << (*itSto) -> checkType( TrackKeys::Downstream ) << endreq
00127       << "  * is Velo       = " << (*itSto) -> checkType( TrackKeys::Velo ) << endreq
00128       << "  * is Backward   = " << (*itSto) -> checkFlag( TrackKeys::Backward ) << endreq
00129       << "  * is Ttrack     = " << (*itSto) -> checkType( TrackKeys::Ttrack ) << endreq
00130       << "  * # LHCbIDs     = " << (*itSto) -> lhcbIDs().size() << endreq;
00131 
00132     // set the properties of TrFitTrack
00133     trFit -> setCharge( (*itSto)->charge() );
00134     trFit -> setErrorFlag( (bool) (*itSto)->checkFlag(TrackKeys::Invalid) );
00135     trFit -> setUnique( (bool) ((*itSto)->checkFlag(TrackKeys::Unique)) );
00136 
00137     if      ( (*itSto)->checkType( TrackKeys::Long ) )       trFit -> setForward(true); // could also be match!
00138     else if ( (*itSto)->checkType( TrackKeys::Upstream ) )   trFit -> setVeloTT( true );
00139     else if ( (*itSto)->checkType( TrackKeys::Downstream ) ) trFit -> setFollow( true ); // could also be ksTrack
00140     else if ( (*itSto)->checkType( TrackKeys::Velo ) )       trFit -> setVelo( true );
00141     else if ( (*itSto)->checkFlag( TrackKeys::Backward ) )   trFit -> setVeloBack( true );
00142     else if ( (*itSto)->checkType( TrackKeys::Ttrack ) )     trFit -> setSeed( true);
00143 
00144     // look at the "first state"
00145     State& pstate = (*itSto) -> firstState();
00146     TrStateP* trStaP = new TrStateP( pstate.z(), pstate.stateVector(), pstate.covariance() );
00147     // put the created TrStateP in TrFitTrack
00148     trFit -> addState( trStaP );
00149     debug() << "  -> stored physics state at z = " << pstate.z() << " as TrStateP" << endreq
00150             << "    - (x,y,z)     = (" << pstate.x() << ", "
00151             << pstate.y() << ", "
00152             << pstate.z() << ")" << endreq
00153             << "    - tx, ty, Q/P = " << pstate.tx() << ", "
00154             << pstate.ty() << ", "
00155             << pstate.qOverP() << endreq;
00156 
00157     // loop over the LHCbIDs
00158     const std::vector<LHCbID> trStoID = (*itSto) -> lhcbIDs();
00159     for ( itID = trStoID.begin(); itID != trStoID.end(); ++itID) {
00160       // continue according to type ...
00161       if ( (*itID).isOT() ) {
00162         OTChannelID otChID = (*itID).otID();
00163         OTTimes* otTimes = get<OTTimes>( OTTimeLocation::Default );
00164         OTTimes::const_iterator itOTTime;
00165         for ( itOTTime=otTimes->begin() ; otTimes->end()!= itOTTime ; ++itOTTime ) {
00166           if ( otChID == (*itOTTime)->channel() ) {
00167             // create OTClusterOnTrack
00168             int driftAmbiguity = 0;
00169             //driftAmbiguity stored in the LHCbID in the
00170             // spareBits: 11 / 10 for ambiguity = +1 / -1
00171             if      ( (*itID).spareBits() == 2 ) { driftAmbiguity = -1; }
00172             else if ( (*itID).spareBits() == 3 ) { driftAmbiguity =  1; }
00173             OTClusterOnTrack* otCluOnT =
00174               new OTClusterOnTrack( (*itOTTime), driftAmbiguity, m_otTrackerDet );
00175             // add OTClusterOnTrack to the TrFitTrack
00176             trFit -> addMeasurement( otCluOnT );
00177             debug() << "  * LHCbID = " << (*itID).lhcbID()
00178                     << "  (detectorType / spareBits = "
00179                     << (*itID).detectorType() << " / "
00180                     << (*itID).spareBits() << ")" << endreq
00181                     << "  -> stored OTClusterOnTrack at z = "
00182                     << otCluOnT -> z()
00183                           << " , channelID = "
00184                     << (*itOTTime) -> channel().channelID()
00185                     << " , ambiguity = " << otCluOnT -> ambiguity() << endreq;
00186           }
00187         }
00188       }
00189       else if ( (*itID).isST() ) {
00190         ITChannelID itChID = (*itID).stID();
00191         ITClusters* itClus = get<ITClusters>( ITClusterLocation::Default );
00192         ITClusters::const_iterator itITClu;
00193         for ( itITClu=itClus->begin() ; itClus->end()!= itITClu ; ++itITClu ) {
00194           if ( itChID == (*itITClu)->channelID() ) {
00195             // create ITClusterOnTrack
00196             ITClusterOnTrack* itCluOnT =
00197               new ITClusterOnTrack( (*itITClu), m_itTrackerDet );
00198             // add ITClusterOnTrack to the TrFitTrack
00199             trFit -> addMeasurement( itCluOnT );
00200             debug() << "  * LHCbID = " << (*itID).lhcbID()
00201                     << "  (detectorType / spareBits = "
00202                     << (*itID).detectorType() << " / "
00203                     << (*itID).spareBits() << ")" << endreq
00204                     << "  -> stored ITClusterOnTrack at z = "
00205                     << itCluOnT -> z()
00206                           << " , channelID = "
00207                     << (*itITClu) -> channelID().channelID() << endreq;
00208           }
00209         }
00210       }
00211       else if ( (*itID).isVelo() ) {
00212         VeloChannelID veloChID = (*itID).veloID();
00213         VeloClusters* veloClus = get<VeloClusters>( VeloClusterLocation::Default );
00214         VeloClusters::const_iterator itVeloClu;
00215         for ( itVeloClu=veloClus->begin() ; veloClus->end()!= itVeloClu ; ++itVeloClu ) {
00216           if ( veloChID.channelID() == (*itVeloClu)->channelID(0).channelID() ) {
00217             debug() << "  -> VeloChannelID of type R/Phi = "
00218                     << m_veloDet->isRSensor( (*itVeloClu)->sensor() ) << "/"
00219                     << m_veloDet->isPhiSensor( (*itVeloClu)->sensor() ) << endreq
00220                     << "sensor # from velocluster = "
00221                     << (*itVeloClu)->sensor() << endreq
00222                     << "VChID, sensor, veloChannelID.type = "
00223                     <<  veloChID<< " , " << veloChID.sensor() << " , "
00224                     << veloChID.type() << endreq;
00225             //if ( veloChID.isRType() ) {
00226             if ( m_veloDet->isRSensor( (*itVeloClu)->sensor() ) ) {
00227                     debug()
00228                 << "  -> stored as type R(sensorType=1), VChID, veloChannelID.type = "
00229                 <<  veloChID << " , " << veloChID.type() << endreq;
00230               // create VeloRClusterOnTrack
00231               VeloRClusterOnTrack* veloRCluOnT =
00232                 new VeloRClusterOnTrack( (*itVeloClu), m_veloDet );
00233               // add VeloRClusterOnTrack to the TrFitTrack
00234               trFit -> addMeasurement( veloRCluOnT );
00235             }
00236                   else {
00237               debug()
00238                 << "  -> stored as type Phi(sensorType=2), veloChannelID.type = "
00239                 << veloChID.type() << endreq;
00240               // create VeloPhiClusterOnTrack
00241               VeloPhiClusterOnTrack* veloPhiCluOnT =
00242                 new VeloPhiClusterOnTrack( (*itVeloClu), m_veloDet );
00243               // add VeloPhiClusterOnTrack to the TrFitTrack
00244               trFit -> addMeasurement( veloPhiCluOnT );
00245             }
00246           }
00247         }
00248       }
00249     }
00250     // debugging TrFitTrack ...
00251     debug()
00252       << "  -> TrFitTrack stored with key # " << trFit -> key() << endreq
00253       << "    * # states       = " << trFit -> nStates() << endreq
00254       << "    * # measurements = " << trFit -> nMeasurements() << endreq
00255       << "      - # IT         = "
00256       << trFit -> nMeasurements( TrMeasurement::kITClusterOnTrack ) << endreq
00257       << "      - # OT         = "
00258       << trFit -> nMeasurements( TrMeasurement::kOTClusterOnTrack ) << endreq
00259       << "      - # VeloR      = "
00260       << trFit -> nMeasurements( TrMeasurement::kVeloRClusterOnTrack ) << endreq
00261       << "      - # VeloPhi    = "
00262       << trFit -> nMeasurements( TrMeasurement::kVeloPhiClusterOnTrack ) << endreq
00263       << "    * charge         = " << trFit -> charge() << endreq
00264       << "    * error flag     = " << trFit -> errorFlag() << endreq
00265       << "    * is Unique      = " << trFit -> unique() << endreq
00266       << "    * is Long        = " << trFit -> isLong() << endreq
00267       << "    * is Upstream    = " << trFit -> isUpstream() << endreq
00268       << "    * is Downstream  = " << trFit -> isDownstream() << endreq
00269       << "    * is Velotrack   = " << trFit -> isVelotrack() << endreq
00270       << "    * is Backward    = " << trFit -> isBackward() << endreq
00271       << "    * is Ttrack      = " << trFit -> isTtrack() << endreq
00272       << "    * velo           = " << trFit -> velo() << endreq
00273       << "    * seed           = " << trFit -> seed() << endreq
00274       << "    * match          = " << trFit -> match() << endreq
00275       << "    * forward        = " << trFit -> forward() << endreq
00276       << "    * follow         = " << trFit -> follow() << endreq
00277       << "    * veloTT         = " << trFit -> veloTT() << endreq
00278       << "    * veloBack       = " << trFit -> veloBack() << endreq
00279       << "    * ksTrack        = " << trFit -> ksTrack() << endreq;
00280   }
00281   // summary of stored information
00282   //debug() << "-> stored " << outTra -> size() << " TrFitTracks " << endreq;
00283 
00284   return StatusCode::SUCCESS;
00285 }
00286 
00287 //=============================================================================
00288 //  Finalize
00289 //=============================================================================
00290 StatusCode Track2TrFitTrackCnv::finalize()
00291 {
00292   debug() << "==> Finalize" << endreq;
00293 
00294   //if( m_associator ) toolSvc()->releaseTool( m_associator );
00295 
00296   // Force the finalization of the base class
00297   //-----------------------------------------
00298   return GaudiAlgorithm::finalize();
00299 }

Generated on Mon Jul 4 13:54:29 2005 for New Track Event Model by doxygen 1.4.1