#include <TrackMCTools/TrueStateCreator.h>
Inheritance diagram for TrueStateCreator:
Public Types | |
typedef IAssociator< MCParticle, MCHit > | MCHitAsct |
Typedefs. | |
typedef IAssociator< MCParticle, MCVeloHit > | MCVeloHitAsct |
Public Member Functions | |
TrueStateCreator (const std::string &type, const std::string &name, const IInterface *parent) | |
Standard constructor. | |
virtual | ~TrueStateCreator () |
Destructor. | |
virtual StatusCode | initialize () |
Tool initialization. | |
virtual StatusCode | createState (const MCParticle *mcPart, double zRec, State *&pState) const |
virtual StatusCode | createStateVertex (const MCParticle *mcPart, State *&pState) const |
Private Member Functions | |
double | qOverP (const MCParticle *mcPart) const |
Determine Q/P for a MCParticle. | |
Private Attributes | |
DeVelo * | m_velo |
Velo detector information. | |
MCVeloHitAsct * | m_p2VeloHitAsct |
MCParticle to Velo MCHit Associator. | |
MCHitAsct * | m_p2ITHitAsct |
MCParticle to IT MCHit Associator. | |
MCHitAsct * | m_p2OTHitAsct |
MCParticle to OT MCHit Associator. | |
ITrackExtrapolator * | m_extrapolator |
Extrapolator Tool. | |
std::string | m_p2VeloHitAsctName |
Name of MCParticle to Velo MCHit Asc. | |
std::string | m_p2ITHitAsctName |
Name of MCParticle to IT MCHit Asc. | |
std::string | m_p2OTHitAsctName |
Name of MCParticle to OT MCHit Asc. | |
std::string | m_extrapolatorName |
Name of track state extrapolator. | |
double | m_eX2 |
Error^2 on x. | |
double | m_eY2 |
Error^2 on y. | |
double | m_eTx2 |
Error^2 on slope x. | |
double | m_eTy2 |
Error^2 on slope y. | |
double | m_eP |
dp/p |
The diagonal elements of the covariance matrix are set with the job options. Note that "eP" is dp/p.
Definition at line 44 of file TrueStateCreator.h.
|
Typedefs.
Definition at line 48 of file TrueStateCreator.h. |
|
Definition at line 49 of file TrueStateCreator.h. |
|
Standard constructor.
Definition at line 30 of file TrueStateCreator.cpp. References m_eP, m_eTx2, m_eTy2, m_eX2, m_extrapolatorName, m_eY2, m_p2ITHitAsctName, m_p2OTHitAsctName, and m_p2VeloHitAsctName. 00033 : GaudiTool( type, name, parent ) 00034 , m_velo(0) 00035 , m_p2VeloHitAsct(0) 00036 , m_p2ITHitAsct(0) 00037 , m_p2OTHitAsct(0) 00038 , m_extrapolator(0) 00039 , m_p2VeloHitAsctName("") 00040 , m_p2ITHitAsctName("") 00041 , m_p2OTHitAsctName("") 00042 , m_eX2(2.e-5*mm2) 00043 , m_eY2(2.e-5*mm2) 00044 , m_eTx2(1.e-7) 00045 , m_eTy2(1.e-7) 00046 , m_eP(0.005) 00047 { 00048 // interfaces 00049 declareInterface<IStateCreator>(this); 00050 00051 // declare properties 00052 declareProperty( "MCP2VeloMCHitAscName", 00053 m_p2VeloHitAsctName = "MCP2VeloMCHitAsc" ); 00054 declareProperty( "MCP2ITMCHitAscName", 00055 m_p2ITHitAsctName = "MCP2ITMCHitAsc" ); 00056 declareProperty( "MCP2OTMCHitAscName", 00057 m_p2OTHitAsctName = "MCP2OTMCHitAsc" ); 00058 declareProperty( "extrapolatorName", 00059 m_extrapolatorName = "TrackHerabExtrapolator" ); 00060 declareProperty( "eX2", m_eX2 ); 00061 declareProperty( "eY2", m_eY2 ); 00062 declareProperty( "eTx2", m_eTx2 ); 00063 declareProperty( "eTy2", m_eTy2 ); 00064 declareProperty( "eP", m_eP ); // dp/p 00065 }
|
|
Destructor.
Definition at line 70 of file TrueStateCreator.cpp. 00070 {};
|
|
This method creates a state at z position from a MCParticle using the entry/exit points of the MCHits.
Implements IStateCreator. Definition at line 120 of file TrueStateCreator.cpp. References m_eP, m_eTx2, m_eTy2, m_eX2, m_extrapolator, m_eY2, m_p2ITHitAsct, m_p2OTHitAsct, m_p2VeloHitAsct, State::qOverP(), and State::setState(). 00122 { 00123 // First create the state 00124 HepSymMatrix stateCov = HepSymMatrix(5, 1); 00125 State* pState = new State(); 00126 pState -> setZ( zRec ); 00127 pState -> setCovariance( stateCov ); 00128 state = pState; 00129 00130 // Check if MCParticle exists 00131 if ( mcPart == 0 ) return StatusCode::FAILURE; 00132 00133 // check for associators 00134 if ( !m_p2VeloHitAsct || !m_p2OTHitAsct || !m_p2ITHitAsct ) 00135 return Error( "MCParticle 2 MCHit Associator missing." ); 00136 00137 MCHit* closestHit = 0; 00138 MCHit* secondClosestHit = 0; 00139 double closestZ = 10000; 00140 double secondClosestZ = 10000; 00141 00142 // loop over associated Velo MCHits and find closest hits 00143 MCVeloHitAsct::ToRange mcVeloHitsRange = m_p2VeloHitAsct->rangeFrom(mcPart); 00144 MCVeloHitAsct::ToIterator vt; 00145 for ( vt = mcVeloHitsRange.begin(); vt != mcVeloHitsRange.end(); ++vt) { 00146 // retrieve MCHit 00147 MCVeloHit* mcVeloHit = vt->to(); 00148 if ( !mcVeloHit ) 00149 return Error( "Failed retrieving Velo MCHit" ); 00150 00151 // calculate center point 00152 // workaround for CLHEP 1.9! 00153 HepPoint3D midPointTmp = ( mcVeloHit->entry() + mcVeloHit->exit() ) / 2.0; 00154 Hep3Vector midPoint = ( midPointTmp.x(), midPointTmp.y(), midPointTmp.z() ); 00155 //Hep3Vector midPoint = (mcVeloHit->entry() + mcVeloHit->exit())/2.0; 00156 00157 // get the closest and second closest hits 00158 if ( fabs(midPoint.z() - zRec) < closestZ ) { 00159 secondClosestHit = closestHit; 00160 secondClosestZ = closestZ; 00161 closestHit = mcVeloHit; 00162 closestZ = fabs(midPoint.z()- zRec); 00163 } 00164 else if ( fabs(midPoint.z()- zRec) < secondClosestZ ) { 00165 secondClosestHit = mcVeloHit; 00166 secondClosestZ = fabs(midPoint.z()- zRec); 00167 } 00168 } 00169 00170 // loop over associated OT MCHits and find closest hits 00171 MCHitAsct::ToRange mcOTHitsRange = m_p2OTHitAsct->rangeFrom(mcPart); 00172 MCHitAsct::ToIterator ot; 00173 for ( ot = mcOTHitsRange.begin(); ot != mcOTHitsRange.end(); ++ot) { 00174 // retrieve MCHit 00175 MCHit* mcHit = ot->to(); 00176 if ( !mcHit ) 00177 return Error( "Failed retrieving OT MCHit" ); 00178 00179 // calculate center point 00180 // workaround for CLHEP 1.9! 00181 HepPoint3D midPointTmp = ( mcHit->entry() + mcHit->exit() ) / 2.0; 00182 Hep3Vector midPoint = ( midPointTmp.x(), midPointTmp.y(), midPointTmp.z() ); 00183 //Hep3Vector midPoint = (mcHit->entry() + mcHit->exit())/2.0; 00184 00185 // get the closest and second closest hits 00186 if ( fabs(midPoint.z() - zRec) < closestZ ) { 00187 secondClosestHit = closestHit; 00188 secondClosestZ = closestZ; 00189 closestHit = mcHit; 00190 closestZ = fabs(midPoint.z()- zRec); 00191 } 00192 else if ( fabs(midPoint.z()- zRec) < secondClosestZ ) { 00193 secondClosestHit = mcHit; 00194 secondClosestZ = fabs(midPoint.z()- zRec); 00195 } 00196 } 00197 00198 // loop over associated IT MCHits and find closest hits 00199 MCHitAsct::ToRange mcITHitsRange = m_p2ITHitAsct->rangeFrom(mcPart); 00200 MCHitAsct::ToIterator it; 00201 for ( it = mcITHitsRange.begin(); it != mcITHitsRange.end(); ++it) { 00202 // retrieve MCHit 00203 MCHit* mcHit = it->to(); 00204 if ( !mcHit ) 00205 return Error( "Failed retrieving IT MCHit" ); 00206 00207 // calculate center point 00208 // workaround for CLHEP 1.9! 00209 HepPoint3D midPointTmp = ( mcHit->entry() + mcHit->exit() ) / 2.0; 00210 Hep3Vector midPoint = ( midPointTmp.x(), midPointTmp.y(), midPointTmp.z() ); 00211 //Hep3Vector midPoint = (mcHit->entry() + mcHit->exit())/2.0; 00212 00213 // get the closest and second closest hits 00214 if ( fabs(midPoint.z()- zRec) < closestZ ) { 00215 secondClosestHit = closestHit; 00216 secondClosestZ = closestZ; 00217 closestHit = mcHit; 00218 closestZ = fabs(midPoint.z()- zRec); 00219 } 00220 else if ( fabs(midPoint.z()- zRec) < secondClosestZ ) { 00221 secondClosestHit = mcHit; 00222 secondClosestZ = fabs(midPoint.z()- zRec); 00223 } 00224 00225 } 00226 00227 if ( !closestHit || !secondClosestHit ) { 00228 warning() << "No two closest MCHits found!!" << endreq; 00229 return StatusCode::FAILURE; 00230 } 00231 00232 // Find beginPoint (smallest z-value) 00233 Hep3Vector beginPoint = closestHit->entry(); 00234 if ( beginPoint.z() > closestHit->exit().z() ) 00235 beginPoint = closestHit->exit(); 00236 if ( beginPoint.z() > secondClosestHit->entry().z() ) 00237 beginPoint = secondClosestHit->entry(); 00238 if ( beginPoint.z() > secondClosestHit->exit().z() ) 00239 beginPoint = secondClosestHit->exit(); 00240 00241 // Find endPoint (highest z-value) 00242 Hep3Vector endPoint = secondClosestHit->exit(); 00243 if ( endPoint.z() < secondClosestHit->entry().z() ) 00244 endPoint = secondClosestHit->entry(); 00245 if ( endPoint.z() < closestHit->entry().z() ) 00246 endPoint = closestHit->entry(); 00247 if ( endPoint.z() < closestHit->exit().z() ) 00248 endPoint = closestHit->exit(); 00249 00250 double dz = (beginPoint.z() - endPoint.z()); 00251 if ( dz == 0. ) { 00252 warning() << "Delta z between two hits equals zero." << endreq; 00253 return StatusCode::FAILURE; 00254 } 00255 double slopeX = (beginPoint.x() - endPoint.x()) / dz; 00256 double slopeY = (beginPoint.y() - endPoint.y()) / dz; 00257 double x = (beginPoint.x()); 00258 double y = (beginPoint.y()); 00259 double z = (beginPoint.z()); 00260 00261 // set the state parameters 00262 pState->setState( x, y, z, slopeX, slopeY, this->qOverP(mcPart) ); 00263 00264 // set covariance matrix 00265 HepSymMatrix cov = HepSymMatrix(5,0); 00266 cov.fast(1,1) = m_eX2; 00267 cov.fast(2,2) = m_eY2; 00268 cov.fast(3,3) = m_eTx2; 00269 cov.fast(4,4) = m_eTy2; 00270 cov.fast(5,5) = pow(m_eP * pState->qOverP(), 2.); 00271 pState -> setCovariance( cov ); 00272 00273 // extrapolate state to exact z position 00274 ParticleID partID = 211; // pion 00275 StatusCode sc = m_extrapolator -> propagate( *pState, zRec, partID ); 00276 if ( sc.isFailure() ) { 00277 debug() << "Extrapolation of True State from z = " 00278 << z << " to z = " << zRec << " failed!" << endreq; 00279 } 00280 00281 return sc; 00282 }
|
|
This method creates a state at the origin vertex from a MCParticle using the entry/exit points of the MCHits.
Implements IStateCreator. Definition at line 288 of file TrueStateCreator.cpp. References m_eP, m_eTx2, m_eTy2, m_eX2, m_eY2, State::qOverP(), qOverP(), and State::setState(). 00290 { 00292 HepSymMatrix stateCov = HepSymMatrix(5, 1); 00293 State* trueState = new State(); 00294 trueState -> setCovariance( stateCov ); 00295 state = trueState; 00296 00297 // Check if MCParticle exists 00298 if ( mcParticle == 0 ) return StatusCode::FAILURE; 00299 00300 // retrieve true MC particle info 00301 const MCVertex* mcVertex = mcParticle -> originVertex(); 00302 const HepPoint3D mcPos = mcVertex -> position(); 00303 const HepLorentzVector mc4Mom = mcParticle -> momentum(); 00304 00305 // determine QdivP 00306 double trueQdivP = this -> qOverP( mcParticle ); 00307 00308 // determine slopes 00309 double trueTx = 99999999; 00310 double trueTy = 99999999; 00311 double px = mc4Mom.px(); 00312 double py = mc4Mom.py(); 00313 double pz = mc4Mom.pz(); 00314 if ( fabs(pz) > TrackParameters::lowTolerance ) { 00315 trueTx = px/pz; 00316 trueTy = py/pz; 00317 } 00318 else { 00319 warning() << "No momentum z component." << endreq; 00320 return StatusCode::FAILURE; 00321 } 00322 00323 // construct true State 00324 trueState->setState( mcPos.x(), 00325 mcPos.y(), 00326 mcPos.z(), 00327 trueTx, 00328 trueTy, 00329 trueQdivP ); 00330 00331 // set covariance matrix 00332 HepSymMatrix cov = HepSymMatrix(5,0); 00333 cov.fast(1,1) = m_eX2; 00334 cov.fast(2,2) = m_eY2; 00335 cov.fast(3,3) = m_eTx2; 00336 cov.fast(4,4) = m_eTy2; 00337 cov.fast(5,5) = pow(m_eP * trueState->qOverP(), 2.); 00338 trueState -> setCovariance( cov ); 00339 00340 return StatusCode::SUCCESS; 00341 }
|
|
Tool initialization.
Definition at line 75 of file TrueStateCreator.cpp. References m_extrapolator, m_extrapolatorName, m_p2ITHitAsct, m_p2ITHitAsctName, m_p2OTHitAsct, m_p2OTHitAsctName, m_p2VeloHitAsct, and m_p2VeloHitAsctName. 00076 { 00077 debug() << "==> Initialize" << endreq; 00078 00079 StatusCode sc = GaudiTool::initialize(); // must be executed first 00080 if ( sc.isFailure() ) return sc; 00081 00082 std::string ascType = "Associator<MCParticle,MCHit>"; 00083 std::string ascVeloType = "Associator<MCParticle,MCVeloHit>"; 00084 00085 // Retrieve MCParticle 2 Velo MCHit associator 00086 sc = toolSvc() -> retrieveTool( ascVeloType, 00087 m_p2VeloHitAsctName, m_p2VeloHitAsct ); 00088 if ( sc.isFailure() ) { 00089 error() << "Unable to retrieve the Velo MCHit Associator " 00090 << m_p2VeloHitAsctName << endreq; 00091 return sc; 00092 } 00093 00094 // Retrieve MCParticle 2 OT MCHit associator 00095 sc = toolSvc() -> retrieveTool( ascType, m_p2OTHitAsctName, m_p2OTHitAsct ); 00096 if ( sc.isFailure() ) { 00097 error() << "Unable to retrieve the OT MCHit Associator " 00098 << m_p2OTHitAsctName << endreq; 00099 return sc; 00100 } 00101 00102 // Retrieve MCParticle 2 IT MCHit associator 00103 sc = toolSvc()->retrieveTool(ascType, m_p2ITHitAsctName, m_p2ITHitAsct); 00104 if ( sc.isFailure() ) { 00105 error() << "Unable to retrieve the IT MCHit Associator " 00106 << m_p2ITHitAsctName << endreq; 00107 return sc; 00108 } 00109 00110 // Retrieve extrapolator 00111 m_extrapolator = tool<ITrackExtrapolator>( m_extrapolatorName ); 00112 00113 return StatusCode::SUCCESS; 00114 }
|
|
Determine Q/P for a MCParticle. Determine Q/P for a MCParticle Definition at line 346 of file TrueStateCreator.cpp. Referenced by createStateVertex(). 00347 { 00349 double momentum = mcPart -> momentum().vect().mag(); 00350 double charge = (mcPart -> particleID().threeCharge())/3.; 00351 if ( momentum > TrackParameters::lowTolerance) { 00352 return charge/momentum; 00353 } 00354 else { 00355 return 0.0; 00356 } 00357 }
|
|
dp/p
Definition at line 103 of file TrueStateCreator.h. Referenced by createState(), createStateVertex(), and TrueStateCreator(). |
|
Error^2 on slope x.
Definition at line 101 of file TrueStateCreator.h. Referenced by createState(), createStateVertex(), and TrueStateCreator(). |
|
Error^2 on slope y.
Definition at line 102 of file TrueStateCreator.h. Referenced by createState(), createStateVertex(), and TrueStateCreator(). |
|
Error^2 on x.
Definition at line 99 of file TrueStateCreator.h. Referenced by createState(), createStateVertex(), and TrueStateCreator(). |
|
Extrapolator Tool.
Definition at line 92 of file TrueStateCreator.h. Referenced by createState(), and initialize(). |
|
Name of track state extrapolator.
Definition at line 98 of file TrueStateCreator.h. Referenced by initialize(), and TrueStateCreator(). |
|
Error^2 on y.
Definition at line 100 of file TrueStateCreator.h. Referenced by createState(), createStateVertex(), and TrueStateCreator(). |
|
MCParticle to IT MCHit Associator.
Definition at line 89 of file TrueStateCreator.h. Referenced by createState(), and initialize(). |
|
Name of MCParticle to IT MCHit Asc.
Definition at line 96 of file TrueStateCreator.h. Referenced by initialize(), and TrueStateCreator(). |
|
MCParticle to OT MCHit Associator.
Definition at line 90 of file TrueStateCreator.h. Referenced by createState(), and initialize(). |
|
Name of MCParticle to OT MCHit Asc.
Definition at line 97 of file TrueStateCreator.h. Referenced by initialize(), and TrueStateCreator(). |
|
MCParticle to Velo MCHit Associator.
Definition at line 88 of file TrueStateCreator.h. Referenced by createState(), and initialize(). |
|
Name of MCParticle to Velo MCHit Asc.
Definition at line 95 of file TrueStateCreator.h. Referenced by initialize(), and TrueStateCreator(). |
|
Velo detector information.
Definition at line 86 of file TrueStateCreator.h. |