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 "TrackTools/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;
00076
00078 debug() << " start reading geometry ..." << endreq;
00079
00080 DeOTDetector* otDet = getDet<DeOTDetector>( DeOTDetectorLocation::Default );
00081
00082 DeSTDetector* stDet = getDet<DeSTDetector>( DeSTDetectorLocation::Default );
00083
00084 m_velo = getDet<DeVelo>( "/dd/Structure/LHCb/Velo" );
00085
00086
00087 m_TT1Station = stDet -> station( 1 );
00088 m_TT2Station = stDet -> station( 2 );
00089 m_IT1Station = stDet -> station( 3 );
00090 m_IT2Station = stDet -> station( 4 );
00091 m_IT3Station = stDet -> station( 5 );
00092 m_OT1Station = otDet -> station( 1 );
00093 m_OT2Station = otDet -> station( 2 );
00094 m_OT3Station = otDet -> station( 3 );
00095
00096
00097 std::string ascVeloType = "Associator<MCParticle,MCVeloHit>";
00098 sc = toolSvc()->retrieveTool(ascVeloType,
00099 m_p2VeloHitAsctName, m_p2VeloHitAsct);
00100 if ( sc.isFailure() ) {
00101 error() << "Unable to retrieve Velo MCHit Associator "
00102 << m_p2VeloHitAsctName << endreq;
00103 return sc;
00104 }
00105
00106
00107 std::string ascType = "Associator<MCParticle,MCHit>";
00108 sc = toolSvc()->retrieveTool(ascType, m_p2OTHitAsctName, m_p2OTHitAsct);
00109 if ( sc.isFailure() ) {
00110 error() << "Unable to retrieve OT MCHit Associator "
00111 << m_p2OTHitAsctName << endreq;
00112 return sc;
00113 }
00114
00115
00116 sc = toolSvc()->retrieveTool(ascType, m_p2ITHitAsctName, m_p2ITHitAsct);
00117 if ( sc.isFailure() ) {
00118 error() << "Unable to retrieve IT MCHit Associator "
00119 << m_p2ITHitAsctName << endreq;
00120 return sc;
00121 }
00122
00123 return StatusCode::SUCCESS;
00124 }
00125
00126
00127
00128
00129 bool TrackAcceptance::hasVelo( MCParticle* mcPart )
00130 {
00131 int nVeloRHits = 0;
00132 int nVeloPhiHits = 0;
00133
00134
00135 MCVeloHitAsct::ToRange mcVeloHitsRange = m_p2VeloHitAsct->rangeFrom(mcPart);
00136 MCVeloHitAsct::ToIterator it;
00137 for ( it = mcVeloHitsRange.begin(); it != mcVeloHitsRange.end(); ++it) {
00138
00139 MCVeloHit* mcVeloHit = it->to();
00140 if ( !mcVeloHit ) {
00141 error() << "Failed retrieving Velo MCHit." << endreq;
00142 }
00143 else {
00144
00145
00146 HepPoint3D midPoint = (mcVeloHit->entry() + mcVeloHit->exit())/2.0;
00147 int staNr = m_velo -> sensorNumber( midPoint );
00148 if ( m_velo -> isRSensor( staNr ) ) {
00149 ++nVeloRHits;
00150 }
00151 else {
00152 ++nVeloPhiHits;
00153 }
00154 }
00155 }
00156
00157
00158 bool isVeloTrack = false;
00159 if ((nVeloRHits >= m_minNVeloRHits) && (nVeloPhiHits >= m_minNVeloPhiHits)) {
00160 isVeloTrack = true;
00161 }
00162 return isVeloTrack;
00163 }
00164
00165
00166
00167
00168 bool TrackAcceptance::hasTT( MCParticle* mcPart )
00169 {
00170 int nTTHits = 0;
00171
00172
00173 MCHitAsct::ToRange mcITHitsRange = m_p2ITHitAsct->rangeFrom(mcPart);
00174 MCHitAsct::ToIterator it;
00175 for ( it = mcITHitsRange.begin(); it != mcITHitsRange.end(); ++it) {
00176
00177 MCHit* mcHit = it -> to();
00178 if ( !mcHit ) {
00179 error() << "Failed retrieving TT MCHit" << endmsg;
00180 }
00181 else {
00182
00183 HepPoint3D midPoint = (mcHit->entry() + mcHit->exit())/2.0;
00184
00185
00186 if ( m_TT1Station -> isInside( midPoint.z() ) ) {
00187 ++nTTHits;
00188 }
00189
00190 if ( m_TT2Station -> isInside( midPoint.z() ) ) {
00191 ++nTTHits;
00192 }
00193 }
00194 }
00195
00196 bool isTTTrack = false;
00197 if (nTTHits >= m_minNTTHits) {
00198 isTTTrack = true;
00199 }
00200 return isTTTrack;
00201 }
00202
00203
00204
00205
00206 bool TrackAcceptance::hasSeed( MCParticle* mcPart )
00207 {
00208 int nOT1Hits = 0;
00209 int nOT2Hits = 0;
00210 int nOT3Hits = 0;
00211 int nIT1Hits = 0;
00212 int nIT2Hits = 0;
00213 int nIT3Hits = 0;
00214
00215
00216 MCHitAsct::ToRange mcOTHitsRange = m_p2OTHitAsct->rangeFrom(mcPart);
00217 MCHitAsct::ToIterator ot;
00218 for ( ot = mcOTHitsRange.begin(); ot != mcOTHitsRange.end(); ++ot) {
00219
00220 MCHit* mcHit = ot -> to();
00221 if (!mcHit) {
00222 error() << "Failed retrieving OT MCHit " << endreq;
00223 }
00224 else {
00225
00226 HepPoint3D midPoint = (mcHit->entry() + mcHit->exit())/2.0;
00227
00228
00229 if ( m_OT1Station -> isInside( midPoint ) ) {
00230 ++nOT1Hits;
00231 }
00232
00233
00234 if ( m_OT2Station -> isInside( midPoint ) ) {
00235 ++nOT2Hits;
00236 }
00237
00238
00239 if ( m_OT3Station -> isInside( midPoint ) ) {
00240 ++nOT3Hits;
00241 }
00242 }
00243 }
00244
00245
00246 MCHitAsct::ToRange mcITHitsRange = m_p2ITHitAsct->rangeFrom(mcPart);
00247 MCHitAsct::ToIterator it;
00248 for ( it = mcITHitsRange.begin(); it != mcITHitsRange.end(); ++it) {
00249
00250 MCHit* mcHit = it->to();
00251 if (!mcHit) {
00252 error() << "Failed retrieving IT MCHit " << endreq;
00253 }
00254 else {
00255
00256 HepPoint3D midPoint = (mcHit->entry() + mcHit->exit())/2.0;
00257
00258
00259 if ( m_IT1Station->isInside(midPoint.z()) ) {
00260 ++nIT1Hits;
00261 }
00262
00263
00264 if ( m_IT2Station->isInside(midPoint.z()) ) {
00265 ++nIT2Hits;
00266 }
00267
00268
00269 if ( m_IT3Station->isInside(midPoint.z()) ) {
00270 ++nIT3Hits;
00271 }
00272 }
00273 }
00274
00275
00276 bool isSeedTrack = false;
00277 if (((nOT1Hits + nIT1Hits) >= m_minNT1Hits) &&
00278 ((nOT2Hits + nIT2Hits) >= m_minNT2Hits) &&
00279 ((nOT3Hits + nIT3Hits) >= m_minNT3Hits)) {
00280 isSeedTrack = true;
00281 }
00282 return isSeedTrack;
00283 }
00284
00285
00286
00287
00288 bool TrackAcceptance::hasVeloAndSeed( MCParticle* mcPart )
00289 {
00290 return ( this->hasVelo(mcPart) && this->hasSeed(mcPart) );
00291 }