|
ATLAS Offline Software
|
Go to the documentation of this file.
18 #include "GaudiKernel/NTuple.h"
19 #include "GaudiKernel/INTupleSvc.h"
20 #include "GaudiKernel/SmartDataPtr.h"
37 #include "CLHEP/GenericFunctions/CumulativeChiSquare.hh"
38 #include "CLHEP/Geometry/Point3D.h"
39 #include "CLHEP/Units/SystemOfUnits.h"
47 static const int maxTracks = 10000;
53 const std::string&
name,
81 return StatusCode::SUCCESS;
125 return StatusCode::SUCCESS;
136 const EventContext& ctx = Gaudi::Hive::currentContext();
174 if (StatusCode::SUCCESS !=
dumpMatching(Uptracks, Lowtracks)) {
176 return StatusCode::FAILURE;
189 return StatusCode::FAILURE;
193 return StatusCode::FAILURE;
198 msg(
MSG::DEBUG) <<
"Retrieved " << truthCol->size() <<
" truth tracks from StoreGate" <<
endmsg;
207 for (; trackItr != trackItrE && nTracks < maxTracks; ++trackItr) {
209 if (
track ==
nullptr) {
225 TrackTruthCollection::const_iterator
found = truthCol->find(trackLink2);
227 if (
found != truthCol->end()) {
247 Amg::Vector3D productionVertex(genParticle->production_vertex()->position().x(),
248 genParticle->production_vertex()->position().y(),
249 genParticle->production_vertex()->position().z());
255 float genPt = std::sqrt((genParticle->momentum().x()) * (genParticle->momentum().x())
256 + (genParticle->momentum().y()) * (genParticle->momentum().y()));
259 <<
", p " << genParticle->momentum().e() /
CLHEP::GeV <<
" CLHEP::GeV/c"
260 <<
", eta " << genParticle->momentum().eta()
261 <<
", phi " << genParticle->momentum().phi() <<
" CLHEP::rad");
266 float pX = genParticle->momentum().px();
267 float pY = genParticle->momentum().py();
268 float genParticlePt = std::sqrt((pX * pX) + (pY * pY));
273 if (genParticle->pdg_id() == 0)
ATH_MSG_WARNING(
"Particle with PDG 0!");
275 "No GenVertex (generator level) production vertex found!");
282 generatedTrackPerigee =
m_truthToTrack->makePerigeeParameters(genParticle);
284 if (!generatedTrackPerigee) {
287 msg(
MSG::DEBUG) <<
"Trying to extrapolate directly to exclude material effects!" <<
endmsg;
292 sc = evtStore()->retrieve(recordCollection,
"CaloEntryLayer");
293 if (
sc == StatusCode::FAILURE) {
298 << recordCollection->
size());
303 record != recordCollection->
end(); ++record) {
304 if (std::abs((*record).GetPDGCode()) != 13)
continue;
305 HepGeom::Point3D<double> productionVertex = (*record).GetPosition();
306 double charge = (*record).GetPDGCode() > 0 ? -1.0 : 1.0;
310 (*record).GetMomentum().y(),
311 (*record).GetMomentum().z());
315 double genPar_qOverP = 1. / direction.mag();
316 direction *= genPar_qOverP;
317 if (
charge < 0) genPar_qOverP = -genPar_qOverP;
320 double genPar_phi = direction.phi();
321 if (genPar_phi < 0.) genPar_phi = genPar_phi + 2.0*
M_PI;
324 << productionVertex.x() <<
", "
325 << productionVertex.y() <<
", "
326 << productionVertex.z() <<
")");
328 double genPar_theta = direction.theta();
332 globalSurfaceCentre.setIdentity();
334 productionVertex.y(), productionVertex.z());
338 const Amg::Vector3D productionVertexAsGlobalPosition(productionVertex.x(),
339 productionVertex.y(),
340 productionVertex.z());
344 genPar_phi, genPar_theta, genPar_qOverP,
356 << perigeeGlobalPosition.x() <<
", "
357 << perigeeGlobalPosition.y() <<
", "
358 << perigeeGlobalPosition.z() <<
")");
364 const Amg::Vector3D difference = productionVertexAsGlobalPosition - perigeeGlobalPosition;
366 double distance = std::sqrt(difference.x() * difference.x() + difference.y() * difference.y());
367 ATH_MSG_DEBUG(
"Distance between perigee point and generated vertex: "
374 ATH_MSG_DEBUG(
"Distance between perigee and generated vertex exceeds tolerance ("
375 << 1.
e-4 <<
" mm)... Extrapolating!");
378 *productionVertexTrackParams,
383 if (!generatedTrackPerigee)
continue;
385 ATH_MSG_DEBUG(
"Distance between perigee and generated vertex is less than tolerance ("
386 << 1.
e-4 <<
" CLHEP::mm)... " <<
"No propagation to perigee required");
390 genPar_phi, genPar_theta, genPar_qOverP,
399 delete productionVertexTrackParams;
400 delete generatedTrackPerigee;
406 if (generatedTrackPerigee) {
408 m_nt_mc_Trk_vtxX[nTracks] = genParticle->production_vertex()->position().x();
409 m_nt_mc_Trk_vtxY[nTracks] = genParticle->production_vertex()->position().y();
410 m_nt_mc_Trk_vtxZ[nTracks] = genParticle->production_vertex()->position().z();
412 delete generatedTrackPerigee;
446 std::string nt3id =
m_ntupleName +
"/TrkTrack_Matching";
482 return StatusCode::SUCCESS;
493 std::string
comments =
"Trk::Track Information";
567 else ATH_MSG_DEBUG(
"Ntuple " << nt0id <<
" has been booked successfully! ");
583 std::string
comments =
"Trk::UpTrack Information";
628 else ATH_MSG_DEBUG(
"Ntuple " << nt1id <<
" has been booked successfully! ");
642 std::string
comments =
"Trk::LowTrack Information";
697 ATH_MSG_DEBUG(
"Booking Matching between Up and Low Trk::Track Collections...");
699 std::string nt3id =
m_ntupleName +
"/TrkTrack_Matching";
700 std::string
comments =
"Matching between Up and Low Trk::Track Collections";
748 const std::string& TrkColName) {
757 for (; trackItr != trackItrE && itrk < maxTracks; ++trackItr) {
758 if (*trackItr !=
nullptr)
dumpTrack(itrk, (*trackItr), TrkColName);
770 const std::string& TrkColName) {
775 if (aMeasPer ==
nullptr) {
778 double d0 = aMeasPer->parameters()[
Trk::d0];
779 double z0 = aMeasPer->parameters()[
Trk::z0];
786 <<
" Track Parameters (d0, z0, phi0, theta, q/p)" <<
endmsg;
791 float transverseMomentum = std::sqrt((aMeasPer->momentum().x()) * (aMeasPer->momentum().x())
792 + (aMeasPer->momentum().y()) * (aMeasPer->momentum().y()));
795 <<
" pT = " << transverseMomentum /
CLHEP::GeV <<
" CLHEP::GeV/c");
798 int nHits = (*trk).measurementsOnTrack()->size();
807 int nhitspix = 0, nhitssct = 0, nhitstrt = 0;
808 int nshared = 0, nshpix = 0, nshsct = 0;
809 int nholes = 0, nhpix = 0, nhsct = 0;
814 if (not trackPart)
ATH_MSG_ERROR(
"Could not get xAOD::TrackParticle");
847 nshared = nshpix + nshsct;
849 if (nshpix < 0) nshpix = 0;
850 if (nshsct < 0) nshsct = 0;
851 if (nshared < 0) nshared = 0;
862 nholes = nhpix + nhsct;
864 if (nhpix < 0) nhpix = 0;
865 if (nhsct < 0) nhsct = 0;
866 if (nholes < 0) nholes = 0;
877 double chi2Prob = 0.;
879 if (fitQual ==
nullptr) {
884 Genfun::CumulativeChiSquare probabilityFunction(fitQual->
numberDoF());
885 chi2Prob = 1 - probabilityFunction(fitQual->
chiSquared());
895 if (TrkColName ==
"Up") {
923 }
else if (TrkColName ==
"Low") {
992 float d0 = generatedTrackPerigee->parameters()[
Trk::d0];
993 float z0 = generatedTrackPerigee->parameters()[
Trk::z0];
996 float eta = generatedTrackPerigee->
eta();
998 float qoverp = generatedTrackPerigee->parameters()[
Trk::qOverP];
1000 float pt = (1 / qoverpt) * (
charge);
1004 msg(
MSG::DEBUG) <<
" - Extrapolated genParticle perigee parameters "
1005 <<
"(d0, z0, phi0, theta, q/p)" <<
endmsg;
1033 int nTracksUpper = 0;
1038 for (; trackItrUpper != trackItrUpperE; ++trackItrUpper) {
1039 const Trk::Track* trackUpper = *trackItrUpper;
1040 if (trackUpper ==
nullptr) {
1041 ATH_MSG_DEBUG(
"No associated Trk::Track object found for track " << nTracksUpper);
1048 float d0Up = measUpperPer->parameters()[
Trk::d0];
1049 float phi0Up = measUpperPer->parameters()[
Trk::phi0];
1050 float eta0Up = measUpperPer->eta();
1051 float z0Up = measUpperPer->parameters()[
Trk::z0];
1052 float thetaUp = measUpperPer->parameters()[
Trk::theta];
1054 float chargeUp = measUpperPer->charge();
1055 float ptUp = measUpperPer->pT() / 1000.;
1059 msg(
MSG::DEBUG) <<
" d0, z0, phi0, theta, q/p" << d0Up <<
", " << z0Up <<
", "
1060 << phi0Up <<
", " << thetaUp <<
", " << qOverPtUp <<
endmsg;
1063 int nTracksLower = 0;
1065 bool matchFound =
false;
1066 float Matched_Low_d0 = -999;
1067 float Matched_Low_phi0 = -999;
1069 float Matched_Low_theta = -999;
1070 float Matched_Low_eta0 = -999;
1071 float Matched_Low_z0 = -999;
1072 float Matched_Low_qOverPt = -999;
1073 float Matched_Low_charge = -999;
1074 float Matched_Low_pt = -999;
1079 for (; trackItrLower != trackItrLowerE; ++trackItrLower) {
1080 const Trk::Track* trackLower = *trackItrLower;
1081 if (trackLower ==
nullptr) {
1082 ATH_MSG_DEBUG(
"No associated Trk::Track object found for track " << nTracksLower);
1088 float d0Low = measLowerPer->parameters()[
Trk::d0];
1089 float phi0Low = measLowerPer->parameters()[
Trk::phi0];
1090 float eta0Low = measLowerPer->eta();
1091 float z0Low = measLowerPer->parameters()[
Trk::z0];
1092 float thetaLow = measLowerPer->parameters()[
Trk::theta];
1094 float chargeLow = measLowerPer->charge();
1095 float ptLow = measLowerPer->pT() / 1000.;
1098 float dphi2 = (phi0Up - phi0Low) * (phi0Up - phi0Low);
1102 float deta2 = (eta0Up - eta0Low) * (eta0Up - eta0Low);
1105 float dR = std::sqrt(dphi2 + deta2);
1110 Matched_Low_d0 = d0Low;
1111 Matched_Low_phi0 = phi0Low;
1113 Matched_Low_theta = thetaLow;
1114 Matched_Low_eta0 = eta0Low;
1115 Matched_Low_z0 = z0Low;
1116 Matched_Low_qOverPt = qOverPtLow;
1117 Matched_Low_charge = chargeLow;
1118 Matched_Low_pt = ptLow;
1123 msg(
MSG::DEBUG) <<
" d0, z0, phi0, theta, q/p: " << d0Low <<
", " << z0Low <<
", "
1124 << phi0Low <<
", " << thetaLow <<
", " << qOverPtLow <<
endmsg;
1153 return StatusCode::SUCCESS;
def retrieve(aClass, aKey=None)
HepMC::ConstGenParticlePtr scptr() const
Dereference/smart pointer.
NTuple::Array< float > m_nt_Trk_phi0_Up
phi0 parameter (Up track)
@ numberOfPixelHoles
number of pixel layers on track with absence of hits [unit8_t].
NTuple::Array< float > m_nt_Trk_chi2_Low
number of chi2 (Low track)
NTuple::Array< float > m_nt_mc_Trk_genParticleEta
generated eta
NTuple::Array< float > m_nt_Trk_d0_Up
d0 parameter (Up track)
NTuple::Array< float > m_nt_Trk_phi0
phi0 parameter
Const iterator class for DataVector/DataList.
NTuple::Array< float > m_nt_Trk_d0_Low
d0 parameter (Low track)
void bookMatchingNtuple()
NTuple::Array< float > m_nt_mc_Trk_theta0
MonteCarlo theta0 parameter.
NTuple::Array< float > m_nt_mc_Trk_qoverpt
MonteCarlo q/pt parameter.
@ numberOfSCTSharedHits
number of SCT hits shared by several tracks [unit8_t].
NTuple::Array< float > m_nt_mc_Trk_genParticlePt
generated pt
void dumpTrack(int, const Trk::Track *, const std::string &)
double charge() const
Returns the charge.
NTuple::Array< float > m_nt_Trk_theta0
theta0 parameter
Scalar eta() const
pseudorapidity method
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
NTuple::Array< float > m_nt_Trk_pt
pt parameter
NTuple::Array< long > m_nt_Trk_nsharedPixels_Up
number of Pixel shared hits (Up track)
NTuple::Array< float > m_nt_mc_Trk_phi0
MonteCarlo phi0 parameter.
Scalar theta() const
theta method
NTuple::Array< long > m_nt_Trk_nshared_Low
number of shared hits (Low track)
NTuple::Array< long > m_nt_Trk_nholes_Low
number of holes (Low track)
NTuple::Array< float > m_nt_Trk_z0_Low
z0 parameter (Low track)
NTuple::Array< long > m_nt_Trk_nholes
number of holes
NTuple::Array< float > m_nt_Trk_chi2Prob_Low
number of chi2 probability (Low track)
NTuple::Array< float > m_nt_mc_trkistruth
Has the Track an associated truth track?
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
NTuple::Array< float > m_nt_Trk_delta_z0
z0 parameter
@ numberOfTRTHits
number of TRT hits [unit8_t].
ToolHandle< Trk::ITrackParticleCreatorTool > m_particleCreator
NTuple::Array< float > m_nt_mc_Trk_charge
MonteCarlo charge parameter.
#define ATH_MSG_VERBOSE(x)
NTuple::Array< float > m_nt_Trk_pt_Low
pt parameter (Low track)
const Amg::Vector3D & center() const
Returns the center position of the Surface.
NTuple::Item< long > m_nt_nmctracks
number of mc tracks
const_iterator begin() const
NTuple::Array< long > m_nt_Trk_nhitstrt
number of TRT hits
int dumpTrackCol(const TrackCollection *)
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
NTuple::Array< float > m_nt_Trk_delta_eta
eta parameter
NTuple::Array< float > m_nt_Trk_delta_qoverpt
q/pt parameter
NTuple::Array< long > m_nt_Trk_nhitstrt_Up
number of TRT hits (Up track)
NTuple::Array< float > m_nt_Trk_qoverp_Low
q/p parameter (Low track)
CONT::const_iterator const_iterator
NTuple::Array< long > m_nt_Trk_nholesPixels_Low
number of Pixel holes (Low track)
NTuple::Array< long > m_nt_Trk_nHits_Up
number of hits (Up track)
void dumpPerigee(const Trk::TrackParameters *, int)
virtual StatusCode FillTrack() override
NTuple::Array< float > m_nt_Trk_pt_Up
pt parameter (Up track)
NTuple::Array< float > m_nt_mc_Trk_prob
MonteCarlo prob parameter.
NTuple::Array< long > m_nt_Trk_nholes_Up
number of holes (Up track)
HepMC::ConstGenParticlePtr cptr() const
Dereference.
a link optimized in size for a GenParticle in a McEventCollection
@ numberOfPixelSharedHits
number of Pixel all-layer hits shared by several tracks [unit8_t].
NTuple::Array< float > m_nt_Trk_z0_Up
z0 parameter (Up track)
NTuple::Array< long > m_nt_Trk_nhitssct_Low
number of SCT hits (Low track)
NTuple::Array< long > m_nt_Trk_ndof_Low
number of ndof (Low track)
NTuple::Array< long > m_nt_Trk_nholesSCT_Up
number of SCT holes (Up track)
NTuple::Array< long > m_nt_Trk_nsharedSCT_Up
number of SCT shared hits (Up track)
NTuple::Item< long > m_nt_nLowtracks
number of Low tracks
NTuple::Item< long > m_nt_ntracks
number of tracks
::StatusCode StatusCode
StatusCode definition for legacy code.
NTuple::Array< long > m_nt_Trk_nholesSCT
number of SCT holes
NTuple::Array< float > m_nt_Trk_qoverp
q/p parameter
NTuple::Array< long > m_nt_Trk_nholesSCT_Low
number of SCT holes (Low track)
Eigen::Affine3d Transform3D
NTuple::Array< float > m_nt_Trk_phi0_Low
phi0 parameter (Low track)
NTuple::Array< float > m_nt_Trk_chi2_Up
number of chi2 (Up track)
NTuple::Array< float > m_nt_Trk_d0
d0 parameter
BooleanProperty m_doMatching
switch on/off the matching information
NTuple::Array< long > m_nt_Trk_nhitspix_Low
number of Pixel hits (Low track)
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
NTuple::Item< long > m_nt_nUptracks
number of Up tracks
NTuple::Array< long > m_nt_Trk_nhitssct_Up
number of SCT hits (Up track)
NTuple::Array< long > m_nt_Trk_nhitspix_Up
number of Pixel hits (Up track)
@ numberOfSCTHoles
number of SCT holes [unit8_t].
NTuple::Array< float > m_nt_Trk_delta_pt
pt parameter
bool isValid() const
Validity check.
NTuple::Array< long > m_nt_Trk_nsharedSCT_Low
number of SCT shared hits (Low track)
NTuple::Array< long > m_nt_Trk_nhitstrt_Low
number of TRT hits (Low track)
const HepMcParticleLink & particleLink() const
ToolHandle< Trk::IExtrapolator > m_extrapolator
NTuple::Array< float > m_nt_Trk_chi2
number of chi2
NTuple::Array< float > m_nt_Trk_chi2Prob_Up
number of chi2 probability (Up track)
bool setElement(ElementType element)
Set to point to an element.
const Perigee * perigeeParameters() const
return Perigee.
const GenParticle * ConstGenParticlePtr
NTuple::Array< long > m_nt_Trk_nHits_Low
number of hits (Low track)
bool setStorableObject(BaseConstReference data, bool replace=false, IProxyDict *sg=0)
Set link to point to a new container (storable).
NTuple::Array< float > m_nt_Trk_delta_theta0
theta parameter
StringProperty m_inputLowCol
double charge(const T &p)
NTuple::Array< float > m_nt_mc_Trk_qoverp
MonteCarlo q/p parameter.
StringProperty m_inputCol
StringProperty m_TruthTrkCol
NTuple::Array< long > m_nt_Trk_nsharedPixels
number of Pixel shared hits
Eigen::Matrix< double, 3, 1 > Vector3D
NTuple::Array< long > m_nt_Trk_nholesPixels_Up
number of Pixel holes (Up track)
NTuple::Array< float > m_nt_Trk_z0
z0 parameter
NTuple::Array< float > m_nt_mc_Trk_eta
MonteCarlo eta parameter.
NTuple::Array< float > m_nt_Trk_chi2Prob
number of chi2 probability
NTuple::Array< float > m_nt_mc_Trk_vtxX
MonteCarlo Vertex.X parameter.
NTuple::Array< float > m_nt_mc_Trk_genParticlePhi
generated phi
virtual StatusCode initialize() override
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
NTuple::Array< float > m_nt_Trk_delta_charge
charge parameter
An STL vector of pointers that by default owns its pointed-to elements.
MC particle associated with a reco track + the quality of match.
NTuple::Array< long > m_nt_Trk_nsharedSCT
number of SCT shared hits
NTuple::Array< long > m_nt_Trk_nshared
number of shared hits
NTuple::Array< long > m_nt_Trk_nholesPixels
number of Pixel holes
NTuple::Array< float > m_nt_Trk_delta_phi0
phi0 parameter
virtual StatusCode finalize() override
#define ATH_MSG_WARNING(x)
NTuple::Array< long > m_nt_Trk_nHits
number of hits
NTuple::Array< long > m_nt_Trk_ndof
number of ndof
const_iterator end() const
float probability() const
NTuple::Array< float > m_nt_Trk_theta0_Low
theta0 parameter (Low track)
InDetAlignFillTrack(const std::string &type, const std::string &name, const IInterface *parent)
ParametersT< TrackParametersDim, Charged, PlaneSurface > AtaPlane
Eigen::Translation< double, 3 > Translation3D
ToolHandle< Trk::ITruthToTrack > m_truthToTrack
NTuple::Array< float > m_nt_Trk_delta_d0
d0 parameter
NTuple::Array< float > m_nt_Trk_qoverp_Up
q/p parameter (Up track)
NTuple::Array< long > m_nt_Trk_nhitssct
number of SCT hits
@ numberOfSCTHits
number of hits in SCT [unit8_t].
double chiSquared() const
returns the of the overall track fit
double eta() const
Access method for pseudorapidity - from momentum.
StatusCode dumpMatching(const TrackCollection *, const TrackCollection *)
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
NTuple::Array< long > m_nt_Trk_nhitspix
number of Pixel hits
NTuple::Array< float > m_nt_mc_Trk_pdg
MonteCarlo pdg parameter.
NTuple::Array< float > m_nt_mc_Trk_vtxY
MonteCarlo Vertex.Y parameter.
Class describing a TrackParticle.
StringProperty m_inputUpCol
NTuple::Array< float > m_nt_mc_Trk_pt
MonteCarlo pt parameter.
NTuple::Array< float > m_nt_mc_Trk_z0
MonteCarlo z0 parameter.
ServiceHandle< INTupleSvc > m_ntupleSvc
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
FloatProperty m_matchedRcut
StringProperty m_ntupleName
size_type size() const noexcept
Returns the number of elements in the collection.
NTuple::Array< long > m_nt_Trk_nshared_Up
number of shared hits (Up track)
NTuple::Array< long > m_nt_Trk_nsharedPixels_Low
number of Pixel shared hits (Low track)
bool empty() const noexcept
Returns true if the collection is empty.
NTuple::Array< float > m_nt_mc_Trk_vtxZ
MonteCarlo Vertex.Z parameter.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
NTuple::Item< long > m_nt_matchingTrk
matching tracks
NTuple::Array< float > m_nt_Trk_theta0_Up
theta0 parameter (Up track)
NTuple::Array< float > m_nt_mc_Trk_d0
MonteCarlo d0 parameter.
NTuple::Array< long > m_nt_Trk_ndof_Up
number of ndof (Up track)
BooleanProperty m_doTruth
switch on/off the truth information