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

MeasurementProvider.cpp

Go to the documentation of this file.
00001 // $Id: MeasurementProvider.cpp,v 1.3 2005/06/29 14:41:19 erodrigu Exp $
00002 // Include files 
00003 // -------------
00004 // from Gaudi
00005 #include "GaudiKernel/ToolFactory.h" 
00006 
00007 // from TrackFitEvent
00008 #include "Event/ITMeasurement.h"
00009 #include "Event/OTMeasurement.h"
00010 #include "Event/VeloRMeasurement.h"
00011 #include "Event/VeloPhiMeasurement.h"
00012 
00013 // local
00014 #include "MeasurementProvider.h"
00015 
00016 //-----------------------------------------------------------------------------
00017 // Implementation file for class : MeasurementProvider
00018 //
00019 // 2005-04-14 : Jose Angel Hernando Morata
00020 //-----------------------------------------------------------------------------
00021 
00022 // Declaration of the Tool Factory
00023 static const  ToolFactory<MeasurementProvider>          s_factory ;
00024 const        IToolFactory& MeasurementProviderFactory = s_factory ; 
00025 
00026 
00027 //=============================================================================
00028 // Standard constructor, initializes variables
00029 //=============================================================================
00030 MeasurementProvider::MeasurementProvider( const std::string& type,
00031                                           const std::string& name,
00032                                           const IInterface* parent )
00033   : GaudiTool ( type, name , parent )
00034 {
00035   declareInterface<IMeasurementProvider>(this);
00036 
00037   declareProperty( "OTGeometryPath",
00038                    m_otDetPath = DeOTDetectorLocation::Default );
00039   declareProperty( "ITGeometryPath",
00040                    m_itDetPath = DeSTDetectorLocation::Default );
00041   declareProperty( "VeloGeometryPath",
00042                    m_veloDetPath = "/dd/Structure/LHCb/Velo" );
00043 
00044   declareProperty( "MeasLocation" ,
00045                    m_measLocation = "/Event/Rec/Track/Measurements" );
00046 }
00047 
00048 //=============================================================================
00049 // Destructor
00050 //=============================================================================
00051 MeasurementProvider::~MeasurementProvider() {};
00052 
00053 //=============================================================================
00054 // 
00055 //=============================================================================
00056 StatusCode MeasurementProvider::initialize() {
00057 
00058   StatusCode sc = GaudiTool::initialize();
00059   if (sc.isFailure()) return sc;  // error already reported by base class
00060 
00061   m_otDet   = getDet<DeOTDetector>( m_otDetPath );
00062   
00063   m_itDet   = getDet<DeSTDetector>( m_itDetPath );
00064   
00065   m_veloDet = getDet<DeVelo>( m_veloDetPath );
00066   
00067   return StatusCode::SUCCESS;
00068 }
00069 
00070 //=============================================================================
00071 // 
00072 //=============================================================================
00073 void MeasurementProvider::load() {
00074 
00075   m_otTimes      = get<OTTimes>( OTTimeLocation::Default );
00076 
00077   m_itClusters   = get<ITClusters>( ITClusterLocation::Default );
00078 
00079   m_veloClusters = get<VeloClusters>( VeloClusterLocation::Default );
00080 } 
00081 
00082 //=============================================================================
00083 // 
00084 //=============================================================================
00085 StatusCode MeasurementProvider::load( Track& track ) 
00086 {
00087   const std::vector<LHCbID>& ids = track.lhcbIDs();
00088   for (std::vector<LHCbID>::const_iterator it = ids.begin();
00089        it != ids.end(); it++) {
00090     const LHCbID& id = *it;
00091     debug() << "LHCbID = " << id << endreq;
00092   }
00093   for (std::vector<LHCbID>::const_iterator it = ids.begin();
00094        it != ids.end(); it++) {
00095     const LHCbID& id = *it;
00096     Measurement& meas = measurement(id);
00097     track.addToMeasurements(meas);
00098   }
00099   return StatusCode::SUCCESS;
00100 }
00101 
00102 //=============================================================================
00103 // 
00104 //=============================================================================
00105 Measurement& MeasurementProvider::measurement ( const LHCbID& id,
00106                                                 double par0,
00107                                                 double par1 ) {
00108 
00109   // TODO first look if it is in the list already :)
00110   Measurement* meas = NULL;
00111   if ( id.isVelo() ) {
00112     VeloChannelID vid = id.veloID();
00113     VeloCluster* clus = m_veloClusters->object( vid );
00114     if (clus != NULL) {
00115       if (vid.isRType()) {
00116         meas = new VeloRMeasurement(*clus,*m_veloDet, par0);
00117       } else {
00118         meas = new VeloPhiMeasurement(*clus,*m_veloDet);
00119       }
00120     }
00121     else {
00122       debug() << "VeloCluster is NULL!" << endreq;
00123     }
00124   } else if ( id.isST() ) {
00125     ITChannelID sid = id.stID();
00126     ITCluster* clus = m_itClusters->object(sid);
00127     if (clus != NULL)
00128       meas = new ITMeasurement(*clus,*m_itDet);
00129     else {
00130       debug() << "ITCluster is NULL!" << endreq;
00131     }
00132   } else if ( id.isOT() ) {
00133     OTChannelID oid = id.otID();
00134     OTTime* clus = m_otTimes->object(oid);
00135     if (clus != NULL) {
00136       if (par0 == 999.) par0 = 0.;
00137       meas = new OTMeasurement(*clus,*m_otDet, (int) par0, par1);
00138     }
00139     else {
00140       debug() << "OTTime is NULL!" << endreq;
00141     }    
00142   }
00143 
00144   if (meas == NULL)
00145     error() << "Unable to create measurement!" << endreq;
00146 
00147   debug() << "Creating measurement of type " << meas -> type()
00148           << " lhcbID " << id
00149           << " pars : " << par0 << ","<< par1 << endreq;
00150 
00151   return *meas;  
00152 }
00153 
00154 //=============================================================================

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