#include <TrackTools/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 46 of file TrueStateCreator.h.
|
Typedefs.
Definition at line 50 of file TrueStateCreator.h. |
|
Definition at line 51 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 119 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(). 00121 { 00122 // First create the state 00123 HepSymMatrix stateCov = HepSymMatrix(5, 1); 00124 State* pState = new State(); 00125 pState -> setZ( zRec ); 00126 pState -> setCovariance( stateCov ); 00127 state = pState; 00128 00129 // Check if MCParticle exists 00130 if ( mcPart == 0 ) return StatusCode::FAILURE; 00131 00132 // check for associators 00133 if ( !m_p2VeloHitAsct || !m_p2OTHitAsct || !m_p2ITHitAsct ) 00134 return Error( "MCParticle 2 MCHit Associator missing." ); 00135 00136 MCHit* closestHit = 0; 00137 MCHit* secondClosestHit = 0; 00138 double closestZ = 10000; 00139 double secondClosestZ = 10000; 00140 00141 // loop over associated Velo MCHits and find closest hits 00142 MCVeloHitAsct::ToRange mcVeloHitsRange = m_p2VeloHitAsct->rangeFrom(mcPart); 00143 MCVeloHitAsct::ToIterator vt; 00144 for ( vt = mcVeloHitsRange.begin(); vt != mcVeloHitsRange.end(); ++vt) { 00145 // retrieve MCHit 00146 MCVeloHit* mcVeloHit = vt->to(); 00147 if ( !mcVeloHit ) 00148 return Error( "Failed retrieving Velo MCHit" ); 00149 00150 // calculate center point 00151 // workaround for CLHEP 1.9! 00152 HepPoint3D midPointTmp = ( mcVeloHit->entry() + mcVeloHit->exit() ) / 2.0; 00153 Hep3Vector midPoint = ( midPointTmp.x(), midPointTmp.y(), midPointTmp.z() ); 00154 //Hep3Vector midPoint = (mcVeloHit->entry() + mcVeloHit->exit())/2.0; 00155 00156 // get the closest and second closest hits 00157 if ( fabs(midPoint.z() - zRec) < closestZ ) { 00158 secondClosestHit = closestHit; 00159 secondClosestZ = closestZ; 00160 closestHit = mcVeloHit; 00161 closestZ = fabs(midPoint.z()- zRec); 00162 } 00163 else if ( fabs(midPoint.z()- zRec) < secondClosestZ ) { 00164 secondClosestHit = mcVeloHit; 00165 secondClosestZ = fabs(midPoint.z()- zRec); 00166 } 00167 } 00168 00169 // loop over associated OT MCHits and find closest hits 00170 MCHitAsct::ToRange mcOTHitsRange = m_p2OTHitAsct->rangeFrom(mcPart); 00171 MCHitAsct::ToIterator ot; 00172 for ( ot = mcOTHitsRange.begin(); ot != mcOTHitsRange.end(); ++ot) { 00173 // retrieve MCHit 00174 MCHit* mcHit = ot->to(); 00175 if ( !mcHit ) 00176 return Error( "Failed retrieving OT MCHit" ); 00177 00178 // calculate center point 00179 // workaround for CLHEP 1.9! 00180 HepPoint3D midPointTmp = ( mcHit->entry() + mcHit->exit() ) / 2.0; 00181 Hep3Vector midPoint = ( midPointTmp.x(), midPointTmp.y(), midPointTmp.z() ); 00182 //Hep3Vector midPoint = (mcHit->entry() + mcHit->exit())/2.0; 00183 00184 // get the closest and second closest hits 00185 if ( fabs(midPoint.z() - zRec) < closestZ ) { 00186 secondClosestHit = closestHit; 00187 secondClosestZ = closestZ; 00188 closestHit = mcHit; 00189 closestZ = fabs(midPoint.z()- zRec); 00190 } 00191 else if ( fabs(midPoint.z()- zRec) < secondClosestZ ) { 00192 secondClosestHit = mcHit; 00193 secondClosestZ = fabs(midPoint.z()- zRec); 00194 } 00195 } 00196 00197 // loop over associated IT MCHits and find closest hits 00198 MCHitAsct::ToRange mcITHitsRange = m_p2ITHitAsct->rangeFrom(mcPart); 00199 MCHitAsct::ToIterator it; 00200 for ( it = mcITHitsRange.begin(); it != mcITHitsRange.end(); ++it) { 00201 // retrieve MCHit 00202 MCHit* mcHit = it->to(); 00203 if ( !mcHit ) 00204 return Error( "Failed retrieving IT MCHit" ); 00205 00206 // calculate center point 00207 // workaround for CLHEP 1.9! 00208 HepPoint3D midPointTmp = ( mcHit->entry() + mcHit->exit() ) / 2.0; 00209 Hep3Vector midPoint = ( midPointTmp.x(), midPointTmp.y(), midPointTmp.z() ); 00210 //Hep3Vector midPoint = (mcHit->entry() + mcHit->exit())/2.0; 00211 00212 // get the closest and second closest hits 00213 if ( fabs(midPoint.z()- zRec) < closestZ ) { 00214 secondClosestHit = closestHit; 00215 secondClosestZ = closestZ; 00216 closestHit = mcHit; 00217 closestZ = fabs(midPoint.z()- zRec); 00218 } 00219 else if ( fabs(midPoint.z()- zRec) < secondClosestZ ) { 00220 secondClosestHit = mcHit; 00221 secondClosestZ = fabs(midPoint.z()- zRec); 00222 } 00223 00224 } 00225 00226 if ( !closestHit || !secondClosestHit ) { 00227 warning() << "No two closest MCHits found!!" << endreq; 00228 return StatusCode::FAILURE; 00229 } 00230 00231 // Find beginPoint (smallest z-value) 00232 Hep3Vector beginPoint = closestHit->entry(); 00233 if ( beginPoint.z() > closestHit->exit().z() ) 00234 beginPoint = closestHit->exit(); 00235 if ( beginPoint.z() > secondClosestHit->entry().z() ) 00236 beginPoint = secondClosestHit->entry(); 00237 if ( beginPoint.z() > secondClosestHit->exit().z() ) 00238 beginPoint = secondClosestHit->exit(); 00239 00240 // Find endPoint (highest z-value) 00241 Hep3Vector endPoint = secondClosestHit->exit(); 00242 if ( endPoint.z() < secondClosestHit->entry().z() ) 00243 endPoint = secondClosestHit->entry(); 00244 if ( endPoint.z() < closestHit->entry().z() ) 00245 endPoint = closestHit->entry(); 00246 if ( endPoint.z() < closestHit->exit().z() ) 00247 endPoint = closestHit->exit(); 00248 00249 double dz = (beginPoint.z() - endPoint.z()); 00250 if ( dz == 0. ) { 00251 warning() << "Delta z between two hits equals zero." << endreq; 00252 return StatusCode::FAILURE; 00253 } 00254 double slopeX = (beginPoint.x() - endPoint.x()) / dz; 00255 double slopeY = (beginPoint.y() - endPoint.y()) / dz; 00256 double x = (beginPoint.x()); 00257 double y = (beginPoint.y()); 00258 double z = (beginPoint.z()); 00259 00260 // set the state parameters 00261 pState->setState( x, y, z, slopeX, slopeY, this->qOverP(mcPart) ); 00262 00263 // set covariance matrix 00264 HepSymMatrix cov = HepSymMatrix(5,0); 00265 cov.fast(1,1) = m_eX2; 00266 cov.fast(2,2) = m_eY2; 00267 cov.fast(3,3) = m_eTx2; 00268 cov.fast(4,4) = m_eTy2; 00269 cov.fast(5,5) = pow(m_eP * pState->qOverP(), 2.); 00270 pState -> setCovariance( cov ); 00271 00272 // extrapolate state to exact z position 00273 ParticleID partID = 211; // pion 00274 StatusCode sc = m_extrapolator -> propagate( *pState, zRec, partID ); 00275 if ( sc.isFailure() ) { 00276 debug() << "Extrapolation of True State from z = " 00277 << z << " to z = " << zRec << " failed!" << endreq; 00278 } 00279 00280 return sc; 00281 }
|
|
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 287 of file TrueStateCreator.cpp. References m_eP, m_eTx2, m_eTy2, m_eX2, m_eY2, State::qOverP(), qOverP(), and State::setState(). 00289 { 00291 HepSymMatrix stateCov = HepSymMatrix(5, 1); 00292 State* trueState = new State(); 00293 trueState -> setCovariance( stateCov ); 00294 state = trueState; 00295 00296 // Check if MCParticle exists 00297 if ( mcParticle == 0 ) return StatusCode::FAILURE; 00298 00299 // retrieve true MC particle info 00300 const MCVertex* mcVertex = mcParticle -> originVertex(); 00301 const HepPoint3D mcPos = mcVertex -> position(); 00302 const HepLorentzVector mc4Mom = mcParticle -> momentum(); 00303 00304 // determine QdivP 00305 double trueQdivP = this -> qOverP( mcParticle ); 00306 00307 // determine slopes 00308 double trueTx = 99999999; 00309 double trueTy = 99999999; 00310 double px = mc4Mom.px(); 00311 double py = mc4Mom.py(); 00312 double pz = mc4Mom.pz(); 00313 if ( fabs(pz) > TrackParameters::lowTolerance ) { 00314 trueTx = px/pz; 00315 trueTy = py/pz; 00316 } 00317 else { 00318 warning() << "No momentum z component." << endreq; 00319 return StatusCode::FAILURE; 00320 } 00321 00322 // construct true State 00323 trueState->setState( mcPos.x(), 00324 mcPos.y(), 00325 mcPos.z(), 00326 trueTx, 00327 trueTy, 00328 trueQdivP ); 00329 00330 // set covariance matrix 00331 HepSymMatrix cov = HepSymMatrix(5,0); 00332 cov.fast(1,1) = m_eX2; 00333 cov.fast(2,2) = m_eY2; 00334 cov.fast(3,3) = m_eTx2; 00335 cov.fast(4,4) = m_eTy2; 00336 cov.fast(5,5) = pow(m_eP * trueState->qOverP(), 2.); 00337 trueState -> setCovariance( cov ); 00338 00339 return StatusCode::SUCCESS; 00340 }
|
|
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 StatusCode sc; 00078 00079 debug() << "==> Initialize" << endreq; 00080 00081 std::string ascType = "Associator<MCParticle,MCHit>"; 00082 std::string ascVeloType = "Associator<MCParticle,MCVeloHit>"; 00083 00084 // Retrieve MCParticle 2 Velo MCHit associator 00085 sc = toolSvc() -> retrieveTool( ascVeloType, 00086 m_p2VeloHitAsctName, m_p2VeloHitAsct ); 00087 if ( sc.isFailure() ) { 00088 error() << "Unable to retrieve the Velo MCHit Associator " 00089 << m_p2VeloHitAsctName << endreq; 00090 return sc; 00091 } 00092 00093 // Retrieve MCParticle 2 OT MCHit associator 00094 sc = toolSvc() -> retrieveTool( ascType, m_p2OTHitAsctName, m_p2OTHitAsct ); 00095 if ( sc.isFailure() ) { 00096 error() << "Unable to retrieve the OT MCHit Associator " 00097 << m_p2OTHitAsctName << endreq; 00098 return sc; 00099 } 00100 00101 // Retrieve MCParticle 2 IT MCHit associator 00102 sc = toolSvc()->retrieveTool(ascType, m_p2ITHitAsctName, m_p2ITHitAsct); 00103 if ( sc.isFailure() ) { 00104 error() << "Unable to retrieve the IT MCHit Associator " 00105 << m_p2ITHitAsctName << endreq; 00106 return sc; 00107 } 00108 00109 // Retrieve extrapolator 00110 m_extrapolator = tool<ITrackExtrapolator>( m_extrapolatorName ); 00111 00112 return StatusCode::SUCCESS; 00113 }
|
|
Determine Q/P for a MCParticle. Determine Q/P for a MCParticle Definition at line 345 of file TrueStateCreator.cpp. Referenced by createStateVertex(). 00346 { 00348 double momentum = mcPart -> momentum().vect().mag(); 00349 double charge = (mcPart -> particleID().threeCharge())/3.; 00350 if ( momentum > TrackParameters::lowTolerance) { 00351 return charge/momentum; 00352 } 00353 else { 00354 return 0.0; 00355 } 00356 }
|
|
dp/p
Definition at line 105 of file TrueStateCreator.h. Referenced by createState(), createStateVertex(), and TrueStateCreator(). |
|
Error^2 on slope x.
Definition at line 103 of file TrueStateCreator.h. Referenced by createState(), createStateVertex(), and TrueStateCreator(). |
|
Error^2 on slope y.
Definition at line 104 of file TrueStateCreator.h. Referenced by createState(), createStateVertex(), and TrueStateCreator(). |
|
Error^2 on x.
Definition at line 101 of file TrueStateCreator.h. Referenced by createState(), createStateVertex(), and TrueStateCreator(). |
|
Extrapolator Tool.
Definition at line 94 of file TrueStateCreator.h. Referenced by createState(), and initialize(). |
|
Name of track state extrapolator.
Definition at line 100 of file TrueStateCreator.h. Referenced by initialize(), and TrueStateCreator(). |
|
Error^2 on y.
Definition at line 102 of file TrueStateCreator.h. Referenced by createState(), createStateVertex(), and TrueStateCreator(). |
|
MCParticle to IT MCHit Associator.
Definition at line 91 of file TrueStateCreator.h. Referenced by createState(), and initialize(). |
|
Name of MCParticle to IT MCHit Asc.
Definition at line 98 of file TrueStateCreator.h. Referenced by initialize(), and TrueStateCreator(). |
|
MCParticle to OT MCHit Associator.
Definition at line 92 of file TrueStateCreator.h. Referenced by createState(), and initialize(). |
|
Name of MCParticle to OT MCHit Asc.
Definition at line 99 of file TrueStateCreator.h. Referenced by initialize(), and TrueStateCreator(). |
|
MCParticle to Velo MCHit Associator.
Definition at line 90 of file TrueStateCreator.h. Referenced by createState(), and initialize(). |
|
Name of MCParticle to Velo MCHit Asc.
Definition at line 97 of file TrueStateCreator.h. Referenced by initialize(), and TrueStateCreator(). |
|
Velo detector information.
Definition at line 88 of file TrueStateCreator.h. |