00001
00002
00003
00004
00005 #include "GaudiKernel/ToolFactory.h"
00006
00007
00008 #include "MeasurementProvider.h"
00009 #include "Event/ITMeasurement.h"
00010 #include "Event/OTMeasurement.h"
00011 #include "Event/VeloRMeasurement.h"
00012 #include "Event/VeloPhiMeasurement.h"
00013
00014
00015
00016
00017
00018
00019
00020
00021 static const ToolFactory<MeasurementProvider> s_factory ;
00022 const IToolFactory& MeasurementProviderFactory = s_factory ;
00023
00024
00025
00026
00027
00028 MeasurementProvider::MeasurementProvider( const std::string& type,
00029 const std::string& name,
00030 const IInterface* parent )
00031 : GaudiTool ( type, name , parent )
00032 {
00033 declareInterface<MeasurementProvider>(this);
00034
00035 declareProperty( "OTGeometryPath",
00036 m_otDetPath = "/dd/Structure/LHCb/Tracker/OT" );
00037 declareProperty( "ITGeometryPath",
00038 m_itDetPath = "/dd/Structure/LHCb/Tracker/IT" );
00039 declareProperty( "VeloGeometryPath",
00040 m_otDetPath = "/dd/Structure/LHCb/Velo" );
00041
00042 declareProperty( "MeasLocation" ,
00043 m_measLocation = "/Event/Rec/Tr/Measurements" );
00044 }
00045
00046
00047
00048 MeasurementProvider::~MeasurementProvider() {};
00049
00050 StatusCode MeasurementProvider::initialize() {
00051
00052 m_otDet = getDet<DeOTDetector>( m_otDetPath );
00053
00054 m_itDet = getDet<DeSTDetector>( m_itDetPath );
00055
00056 m_veloDet = getDet<DeVelo>( m_veloDetPath );
00057
00058 return StatusCode::SUCCESS;
00059 }
00060
00061 StatusCode MeasurementProvider::load() {
00062
00063 m_otTimes = get<OTTimes>( OTTimeLocation::Default );
00064
00065 m_itClusters = get<ITClusters>( ITClusterLocation::Default );
00066
00067 m_veloClusters = get<VeloClusters>( VeloClusterLocation::Default);
00068
00069 m_meas = new Measurements();
00070 StatusCode sc = put(m_meas, m_measLocation );
00071 return sc;
00072 }
00073
00074 Measurement& MeasurementProvider::measurement
00075 (const LHCbID& id, double par0, double par1) {
00076
00077
00078 Measurement* meas = NULL;
00079 if (id.isVelo()) {
00080 VeloChannelID vid = id.veloID();
00081 VeloCluster* clus = m_veloClusters->object(vid);
00082 if (clus != NULL) {
00083 if (vid.isRType()) {
00084 meas = new VeloRMeasurement(*clus,*m_veloDet, par0);
00085 } else {
00086 meas = new VeloPhiMeasurement(*clus,*m_veloDet);
00087 }
00088 }
00089 } else if (id.isST()) {
00090 ITChannelID sid = id.stID();
00091 ITCluster* clus = m_itClusters->object(sid);
00092 if (clus != NULL)
00093 meas = new ITMeasurement(*clus,*m_itDet);
00094 } else if (id.isOT()) {
00095 OTChannelID oid = id.otID();
00096 OTTime* clus = m_otTimes->object(oid);
00097 if (clus != NULL) {
00098 if (par0 == 999.) par0 = 0.;
00099 meas = new OTMeasurement(*clus,*m_otDet, (int) par0, par1);
00100 }
00101
00102 }
00103
00104 if (meas != NULL) {
00105 meas->setLhcbID(id);
00106 m_meas->insert(meas);
00107 } else {
00108 error() << " not able to create measurement " << endreq;
00109 }
00110
00111 debug() << " creating measurement " << id.detectorType()
00112 << " channel " << id.channelID()
00113 << " pars : " << par0 << ","<< par1 << endreq;
00114
00115 return *meas;
00116 }
00117
00118 StatusCode MeasurementProvider::load(Track& track)
00119 {
00120 const std::vector<LHCbID>& ids = track.lhcbIDs();
00121 for (std::vector<LHCbID>::const_iterator it = ids.begin();
00122 it != ids.end(); it++) {
00123 const LHCbID& id = *it;
00124 Measurement& meas = measurement(id);
00125 track.addToMeasurements(meas);
00126 }
00127 return StatusCode::SUCCESS;
00128 }
00129