00001
00002
00003
00004
00005 #include "GaudiKernel/ToolFactory.h"
00006
00007
00008 #include "Event/ITMeasurement.h"
00009 #include "Event/OTMeasurement.h"
00010 #include "Event/VeloRMeasurement.h"
00011 #include "Event/VeloPhiMeasurement.h"
00012
00013
00014 #include "MeasurementProvider.h"
00015
00016
00017
00018
00019
00020
00021
00022
00023 static const ToolFactory<MeasurementProvider> s_factory ;
00024 const IToolFactory& MeasurementProviderFactory = s_factory ;
00025
00026
00027
00028
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<MeasurementProvider>(this);
00036
00037 declareProperty( "OTGeometryPath",
00038 m_otDetPath = DeOTDetectorLocation::Default );
00039 declareProperty( "ITGeometryPath",
00040 m_itDetPath = DeSTDetectorLocation::Default );
00041 declareProperty( "VeloGeometryPath",
00042 m_otDetPath = "/dd/Structure/LHCb/Velo" );
00043
00044 declareProperty( "MeasLocation" ,
00045 m_measLocation = "/Event/Rec/Tr/Measurements" );
00046 }
00047
00048
00049
00050
00051 MeasurementProvider::~MeasurementProvider() {};
00052
00053
00054
00055
00056 StatusCode MeasurementProvider::initialize() {
00057
00058 StatusCode sc = GaudiTool::initialize();
00059 if (sc.isFailure()) return sc;
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 Measurement& meas = measurement(id);
00092 track.addToMeasurements(meas);
00093 }
00094 return StatusCode::SUCCESS;
00095 }
00096
00097
00098
00099
00100 Measurement& MeasurementProvider::measurement ( const LHCbID& id,
00101 double par0,
00102 double par1 ) {
00103
00104
00105 Measurement* meas = NULL;
00106 if (id.isVelo()) {
00107 VeloChannelID vid = id.veloID();
00108 VeloCluster* clus = m_veloClusters->object(vid);
00109 if (clus != NULL) {
00110 if (vid.isRType()) {
00111 meas = new VeloRMeasurement(*clus,*m_veloDet, par0);
00112 } else {
00113 meas = new VeloPhiMeasurement(*clus,*m_veloDet);
00114 }
00115 }
00116 } else if (id.isST()) {
00117 ITChannelID sid = id.stID();
00118 ITCluster* clus = m_itClusters->object(sid);
00119 if (clus != NULL)
00120 meas = new ITMeasurement(*clus,*m_itDet);
00121 } else if (id.isOT()) {
00122 OTChannelID oid = id.otID();
00123 OTTime* clus = m_otTimes->object(oid);
00124 if (clus != NULL) {
00125 if (par0 == 999.) par0 = 0.;
00126 meas = new OTMeasurement(*clus,*m_otDet, (int) par0, par1);
00127 }
00128
00129 }
00130
00131 if (meas != NULL) {
00132
00133 } else {
00134 error() << " not able to create measurement " << endreq;
00135 }
00136
00137 debug() << " creating measurement " << id.detectorType()
00138 << " channel " << id.channelID()
00139 << " pars : " << par0 << ","<< par1 << endreq;
00140
00141 return *meas;
00142 }
00143
00144