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