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

TrackAcceptance.cpp

Go to the documentation of this file.
00001 // Include files
00002 // -------------
00003 // from Gaudi
00004 #include "GaudiKernel/ToolFactory.h"
00005 #include "GaudiKernel/IDataProviderSvc.h"
00006 
00007 // from Det
00008 #include "STDet/DeSTDetector.h"
00009 #include "OTDet/DeOTDetector.h"
00010 
00011 // from Event
00012 #include "Event/MCVeloHit.h"
00013 
00014 // local
00015 #include "TrackAcceptance.h"
00016 
00017 //-----------------------------------------------------------------------------
00018 // Implementation file for class : TrackAcceptance
00019 //
00020 // 2003-07-04 : J. van Tilburg
00021 //
00022 //  3-7-2002: Rutger van der Eijk, Jeroen van Tilburg
00023 //-----------------------------------------------------------------------------
00024 
00025 // Declaration of the Tool Factory
00026 static const  ToolFactory<TrackAcceptance>    s_factory;
00027 const  IToolFactory& TrackAcceptanceFactory = s_factory;
00028 
00029 //=============================================================================
00030 // Standard constructor, initializes variables
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   // interfaces
00050   declareInterface<ITrackReconstructible>(this);
00051 
00052   // declare properties
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 // Destructor
00067 //=============================================================================
00068 TrackAcceptance::~TrackAcceptance() {};
00069 
00070 //=============================================================================
00071 // Initialization
00072 //=============================================================================
00073 StatusCode TrackAcceptance::initialize()
00074 {
00075   StatusCode sc = GaudiTool::initialize(); // must be executed first
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   // get pointers to the stations
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   // Retrieve MCParticle 2 Velo MCHit associator
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   // Retrieve MCParticle 2 OT MCHit associator
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   // Retrieve MCParticle 2 IT MCHit associator
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 // Checks if the MCParticle is in the Velo acceptance
00129 //=============================================================================
00130 bool TrackAcceptance::hasVelo( MCParticle* mcPart ) 
00131 {
00132   int nVeloRHits   = 0;
00133   int nVeloPhiHits = 0;
00134   
00135   // loop over associated Velo MCHits and count # hits
00136   MCVeloHitAsct::ToRange mcVeloHitsRange = m_p2VeloHitAsct->rangeFrom(mcPart);
00137   MCVeloHitAsct::ToIterator it;
00138   for ( it = mcVeloHitsRange.begin(); it != mcVeloHitsRange.end(); ++it) { 
00139     // retrieve MCHit
00140     MCVeloHit* mcVeloHit = it->to();
00141     if ( !mcVeloHit ) {
00142       error() << "Failed retrieving Velo MCHit." << endreq;
00143     }
00144     else {
00145       // R or Phi sensor?
00146       // calculate center point
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   // judge if MCParticle satisfies VELO track acceptance criteria
00159   bool isVeloTrack = false;
00160   if ((nVeloRHits >= m_minNVeloRHits) && (nVeloPhiHits >= m_minNVeloPhiHits)) {
00161     isVeloTrack = true;
00162   }
00163   return isVeloTrack;
00164 }
00165 
00166 //=============================================================================
00167 // Checks if the MCParticle is in the TT acceptance
00168 //=============================================================================
00169 bool TrackAcceptance::hasTT( MCParticle* mcPart ) 
00170 {  
00171   int nTTHits = 0;
00172 
00173   // loop over associated IT MCHits and count # TT hits
00174   MCHitAsct::ToRange mcITHitsRange = m_p2ITHitAsct->rangeFrom(mcPart);
00175   MCHitAsct::ToIterator it;
00176   for ( it = mcITHitsRange.begin(); it != mcITHitsRange.end(); ++it) { 
00177     // retrieve MCHit
00178     MCHit* mcHit = it -> to();
00179     if ( !mcHit ) {
00180       error() << "Failed retrieving TT MCHit" << endmsg;
00181     }
00182     else {
00183       // calculate center point
00184       HepPoint3D midPoint = (mcHit->entry() + mcHit->exit())/2.0;
00185 
00186       // TT1 MCHit?
00187       if ( m_TT1Station -> isInside( midPoint.z() ) ) {
00188         ++nTTHits;
00189       }
00190       // TT2 MCHit?
00191       if ( m_TT2Station -> isInside( midPoint.z() ) ) {
00192         ++nTTHits;
00193       }
00194     }
00195   }
00196   // judge if MCParticle satisfies TT1 track acceptance criteria
00197   bool isTTTrack = false;
00198   if (nTTHits >= m_minNTTHits) {
00199     isTTTrack = true;
00200   }
00201   return isTTTrack;
00202 }
00203 
00204 //=============================================================================
00205 // Checks if the MCParticle is in the T-station acceptance
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   // loop over associated OT MCHit s and count # hits
00217   MCHitAsct::ToRange mcOTHitsRange = m_p2OTHitAsct->rangeFrom(mcPart);
00218   MCHitAsct::ToIterator ot;
00219   for ( ot = mcOTHitsRange.begin(); ot != mcOTHitsRange.end(); ++ot) { 
00220     // retrieve MCHit
00221     MCHit* mcHit = ot -> to();
00222     if (!mcHit) {
00223       error() << "Failed retrieving OT MCHit " << endreq;
00224     }
00225     else {
00226       // calculate center point
00227       HepPoint3D midPoint = (mcHit->entry() + mcHit->exit())/2.0;
00228     
00229       // OT1 MCHit?
00230       if ( m_OT1Station -> isInside( midPoint ) ) {
00231         ++nOT1Hits;
00232       }
00233     
00234       // OT2 MCHit?
00235       if ( m_OT2Station -> isInside( midPoint ) ) {
00236         ++nOT2Hits;
00237       }
00238     
00239       // OT3 MCHit?
00240       if ( m_OT3Station -> isInside( midPoint ) ) {
00241         ++nOT3Hits;
00242       }
00243     }
00244   }
00245 
00246   // loop over associated IT MCHit s and count # hits in T1-T3
00247   MCHitAsct::ToRange mcITHitsRange = m_p2ITHitAsct->rangeFrom(mcPart);
00248   MCHitAsct::ToIterator it;
00249   for ( it = mcITHitsRange.begin(); it != mcITHitsRange.end(); ++it) { 
00250     // retrieve MCHit
00251     MCHit* mcHit = it->to();
00252     if (!mcHit) {
00253       error() << "Failed retrieving IT MCHit " << endreq;
00254     }
00255     else {
00256       // calculate center point
00257       HepPoint3D midPoint = (mcHit->entry() + mcHit->exit())/2.0;
00258 
00259       // IT1 MCHit?
00260       if ( m_IT1Station->isInside(midPoint.z()) ) {
00261         ++nIT1Hits;
00262       }
00263     
00264       // IT2 MCHit?
00265       if ( m_IT2Station->isInside(midPoint.z()) ) {
00266         ++nIT2Hits;
00267       }
00268     
00269       // IT3 MCHit?
00270       if ( m_IT3Station->isInside(midPoint.z()) ) {
00271         ++nIT3Hits;
00272       }
00273     }
00274   }
00275 
00276   // judge if MCParticle satisfies SEED track acceptance criteria
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 // Checks if the MCParticle is in the long-track acceptance
00288 //=============================================================================
00289 bool TrackAcceptance::hasVeloAndSeed( MCParticle* mcPart ) 
00290 {  
00291   return ( this->hasVelo(mcPart) && this->hasSeed(mcPart) );
00292 }

Generated on Fri May 27 13:59:37 2005 for New Track Event Model by doxygen 1.4.1