00001
00002
00003
00004 #include "GaudiKernel/ToolFactory.h"
00005 #include "GaudiKernel/IDataProviderSvc.h"
00006
00007
00008 #include "STDet/DeSTDetector.h"
00009 #include "OTDet/DeOTDetector.h"
00010
00011
00012 #include "Event/MCVeloHit.h"
00013
00014
00015 #include "TrackAcceptance.h"
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 static const ToolFactory<TrackAcceptance> s_factory;
00027 const IToolFactory& TrackAcceptanceFactory = s_factory;
00028
00029
00030
00031
00032 TrackAcceptance::TrackAcceptance( const std::string& type,
00033 const std::string& name,
00034 const IInterface* parent )
00035 : GaudiTool( type, name, parent )
00036 , m_velo(0)
00037 , m_TT1Station(0)
00038 , m_TT2Station(0)
00039 , m_IT1Station(0)
00040 , m_IT2Station(0)
00041 , m_IT3Station(0)
00042 , m_OT1Station(0)
00043 , m_OT2Station(0)
00044 , m_OT3Station(0)
00045 , m_p2VeloHitAsct(0)
00046 , m_p2ITHitAsct(0)
00047 , m_p2OTHitAsct(0)
00048 {
00049
00050 declareInterface<ITrackReconstructible>(this);
00051
00052
00053 declareProperty( "MCP2VeloMCHitAscName",
00054 m_p2VeloHitAsctName = "MCP2VeloMCHitAsc");
00055 declareProperty( "MCP2ITMCHitAscName", m_p2ITHitAsctName = "MCP2ITMCHitAsc");
00056 declareProperty( "MCP2OTMCHitAscName", m_p2OTHitAsctName = "MCP2OTMCHitAsc");
00057 declareProperty( "minNVeloRHits", m_minNVeloRHits = 3);
00058 declareProperty( "minNVeloPhiHits", m_minNVeloPhiHits = 3);
00059 declareProperty( "minNTTHits", m_minNTTHits = 1);
00060 declareProperty( "minNT1Hits", m_minNT1Hits = 1);
00061 declareProperty( "minNT2Hits", m_minNT2Hits = 1);
00062 declareProperty( "minNT3Hits", m_minNT3Hits = 1);
00063 }
00064
00065
00066
00067
00068 TrackAcceptance::~TrackAcceptance() {};
00069
00070
00071
00072
00073 StatusCode TrackAcceptance::initialize()
00074 {
00075 StatusCode sc = GaudiTool::initialize();
00076 if ( sc.isFailure() ) return sc;
00077
00079 debug() << " start reading geometry ..." << endreq;
00080
00081 DeOTDetector* otDet = getDet<DeOTDetector>( DeOTDetectorLocation::Default );
00082
00083 DeSTDetector* stDet = getDet<DeSTDetector>( DeSTDetectorLocation::Default );
00084
00085 m_velo = getDet<DeVelo>( "/dd/Structure/LHCb/Velo" );
00086
00087
00088 m_TT1Station = stDet -> station( 1 );
00089 m_TT2Station = stDet -> station( 2 );
00090 m_IT1Station = stDet -> station( 3 );
00091 m_IT2Station = stDet -> station( 4 );
00092 m_IT3Station = stDet -> station( 5 );
00093 m_OT1Station = otDet -> station( 1 );
00094 m_OT2Station = otDet -> station( 2 );
00095 m_OT3Station = otDet -> station( 3 );
00096
00097
00098 std::string ascVeloType = "Associator<MCParticle,MCVeloHit>";
00099 sc = toolSvc()->retrieveTool(ascVeloType,
00100 m_p2VeloHitAsctName, m_p2VeloHitAsct);
00101 if ( sc.isFailure() ) {
00102 error() << "Unable to retrieve Velo MCHit Associator "
00103 << m_p2VeloHitAsctName << endreq;
00104 return sc;
00105 }
00106
00107
00108 std::string ascType = "Associator<MCParticle,MCHit>";
00109 sc = toolSvc()->retrieveTool(ascType, m_p2OTHitAsctName, m_p2OTHitAsct);
00110 if ( sc.isFailure() ) {
00111 error() << "Unable to retrieve OT MCHit Associator "
00112 << m_p2OTHitAsctName << endreq;
00113 return sc;
00114 }
00115
00116
00117 sc = toolSvc()->retrieveTool(ascType, m_p2ITHitAsctName, m_p2ITHitAsct);
00118 if ( sc.isFailure() ) {
00119 error() << "Unable to retrieve IT MCHit Associator "
00120 << m_p2ITHitAsctName << endreq;
00121 return sc;
00122 }
00123
00124 return StatusCode::SUCCESS;
00125 }
00126
00127
00128
00129
00130 bool TrackAcceptance::hasVelo( MCParticle* mcPart )
00131 {
00132 int nVeloRHits = 0;
00133 int nVeloPhiHits = 0;
00134
00135
00136 MCVeloHitAsct::ToRange mcVeloHitsRange = m_p2VeloHitAsct->rangeFrom(mcPart);
00137 MCVeloHitAsct::ToIterator it;
00138 for ( it = mcVeloHitsRange.begin(); it != mcVeloHitsRange.end(); ++it) {
00139
00140 MCVeloHit* mcVeloHit = it->to();
00141 if ( !mcVeloHit ) {
00142 error() << "Failed retrieving Velo MCHit." << endreq;
00143 }
00144 else {
00145
00146
00147 HepPoint3D midPoint = (mcVeloHit->entry() + mcVeloHit->exit())/2.0;
00148 int staNr = m_velo -> sensorNumber( midPoint );
00149 if ( m_velo -> isRSensor( staNr ) ) {
00150 ++nVeloRHits;
00151 }
00152 else {
00153 ++nVeloPhiHits;
00154 }
00155 }
00156 }
00157
00158
00159 bool isVeloTrack = false;
00160 if ((nVeloRHits >= m_minNVeloRHits) && (nVeloPhiHits >= m_minNVeloPhiHits)) {
00161 isVeloTrack = true;
00162 }
00163 return isVeloTrack;
00164 }
00165
00166
00167
00168
00169 bool TrackAcceptance::hasTT( MCParticle* mcPart )
00170 {
00171 int nTTHits = 0;
00172
00173
00174 MCHitAsct::ToRange mcITHitsRange = m_p2ITHitAsct->rangeFrom(mcPart);
00175 MCHitAsct::ToIterator it;
00176 for ( it = mcITHitsRange.begin(); it != mcITHitsRange.end(); ++it) {
00177
00178 MCHit* mcHit = it -> to();
00179 if ( !mcHit ) {
00180 error() << "Failed retrieving TT MCHit" << endmsg;
00181 }
00182 else {
00183
00184 HepPoint3D midPoint = (mcHit->entry() + mcHit->exit())/2.0;
00185
00186
00187 if ( m_TT1Station -> isInside( midPoint.z() ) ) {
00188 ++nTTHits;
00189 }
00190
00191 if ( m_TT2Station -> isInside( midPoint.z() ) ) {
00192 ++nTTHits;
00193 }
00194 }
00195 }
00196
00197 bool isTTTrack = false;
00198 if (nTTHits >= m_minNTTHits) {
00199 isTTTrack = true;
00200 }
00201 return isTTTrack;
00202 }
00203
00204
00205
00206
00207 bool TrackAcceptance::hasSeed( MCParticle* mcPart )
00208 {
00209 int nOT1Hits = 0;
00210 int nOT2Hits = 0;
00211 int nOT3Hits = 0;
00212 int nIT1Hits = 0;
00213 int nIT2Hits = 0;
00214 int nIT3Hits = 0;
00215
00216
00217 MCHitAsct::ToRange mcOTHitsRange = m_p2OTHitAsct->rangeFrom(mcPart);
00218 MCHitAsct::ToIterator ot;
00219 for ( ot = mcOTHitsRange.begin(); ot != mcOTHitsRange.end(); ++ot) {
00220
00221 MCHit* mcHit = ot -> to();
00222 if (!mcHit) {
00223 error() << "Failed retrieving OT MCHit " << endreq;
00224 }
00225 else {
00226
00227 HepPoint3D midPoint = (mcHit->entry() + mcHit->exit())/2.0;
00228
00229
00230 if ( m_OT1Station -> isInside( midPoint ) ) {
00231 ++nOT1Hits;
00232 }
00233
00234
00235 if ( m_OT2Station -> isInside( midPoint ) ) {
00236 ++nOT2Hits;
00237 }
00238
00239
00240 if ( m_OT3Station -> isInside( midPoint ) ) {
00241 ++nOT3Hits;
00242 }
00243 }
00244 }
00245
00246
00247 MCHitAsct::ToRange mcITHitsRange = m_p2ITHitAsct->rangeFrom(mcPart);
00248 MCHitAsct::ToIterator it;
00249 for ( it = mcITHitsRange.begin(); it != mcITHitsRange.end(); ++it) {
00250
00251 MCHit* mcHit = it->to();
00252 if (!mcHit) {
00253 error() << "Failed retrieving IT MCHit " << endreq;
00254 }
00255 else {
00256
00257 HepPoint3D midPoint = (mcHit->entry() + mcHit->exit())/2.0;
00258
00259
00260 if ( m_IT1Station->isInside(midPoint.z()) ) {
00261 ++nIT1Hits;
00262 }
00263
00264
00265 if ( m_IT2Station->isInside(midPoint.z()) ) {
00266 ++nIT2Hits;
00267 }
00268
00269
00270 if ( m_IT3Station->isInside(midPoint.z()) ) {
00271 ++nIT3Hits;
00272 }
00273 }
00274 }
00275
00276
00277 bool isSeedTrack = false;
00278 if (((nOT1Hits + nIT1Hits) >= m_minNT1Hits) &&
00279 ((nOT2Hits + nIT2Hits) >= m_minNT2Hits) &&
00280 ((nOT3Hits + nIT3Hits) >= m_minNT3Hits)) {
00281 isSeedTrack = true;
00282 }
00283 return isSeedTrack;
00284 }
00285
00286
00287
00288
00289 bool TrackAcceptance::hasVeloAndSeed( MCParticle* mcPart )
00290 {
00291 return ( this->hasVelo(mcPart) && this->hasSeed(mcPart) );
00292 }