|
ATLAS Offline Software
|
Go to the documentation of this file.
11 #include "TEfficiency.h"
13 const float GeV = 1000.;
18 :
EL::AnaAlgorithm(
name, svcLoc ) {}
31 std::vector<std::string> recoTypes{
"All",
"Matched",
"Merged",
"Fake",
"Split",
"Other"};
32 std::vector<std::string> truthTypes{
"Inclusive",
"Reconstructable",
"Accepted",
"Seeded",
"Reconstructed",
"ReconstructedSplit"};
34 ANA_CHECK (
book(
TH1F(
"RecoVertex/matchType",
"Vertex Match Type", 65, -0.5, 64.5)));
36 for(
const auto& recoType : recoTypes) {
37 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_x").c_str(),
"Reco vertex x [mm]", 1000, -500, 500)));
38 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_y").c_str(),
"Reco vertex y [mm]", 1000, -500, 500)));
39 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_z").c_str(),
"Reco vertex z [mm]", 1000, -500, 500)));
40 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Lxy").c_str(),
"Reco vertex L_{xy} [mm]", 500, 0, 500)));
41 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_pT").c_str(),
"Reco vertex p_{T} [GeV]", 100, 0, 100)));
42 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_eta").c_str(),
"Reco vertex #eta", 100, -5, 5)));
43 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_phi").c_str(),
"Reco vertex #phi", 100, -TMath::Pi(), TMath::Pi())));
44 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_mass").c_str(),
"Reco vertex mass [GeV]", 500, 0, 100)));
45 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_mu").c_str(),
"Reco vertex Red. Mass [GeV]", 500, 0, 100)));
46 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_chi2").c_str(),
"Reco vertex recoChi2", 100, 0, 10)));
47 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_dir").c_str(),
"Reco vertex recoDirection", 100, -1, 1)));
48 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_charge").c_str(),
"Reco vertex recoCharge", 20, -10, 10)));
49 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_H").c_str(),
"Reco vertex H [GeV]", 100, 0, 100)));
50 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_HT").c_str(),
"Reco vertex Mass [GeV]", 100, 0, 100)));
51 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_minOpAng").c_str(),
"Reco vertex minOpAng", 100, -1, 1)));
52 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_maxOpAng").c_str(),
"Reco vertex maxOpAng", 100, -1, 1)));
53 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_maxdR").c_str(),
"Reco vertex maxDR", 100, 0, 10)));
54 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_mind0").c_str(),
"Reco vertex min d0 [mm]", 100, 0, 100)));
55 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_maxd0").c_str(),
"Reco vertex max d0 [mm]", 100, 0, 100)));
56 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_ntrk").c_str(),
"Reco vertex n tracks", 30, 0, 30)));
59 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_qOverP").c_str(),
"Reco track qOverP ", 100, 0, .01)));
60 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_theta").c_str(),
"Reco track theta ", 64, 0, 3.2)));
61 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_E").c_str(),
"Reco track E ", 100, 0, 100)));
62 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_M").c_str(),
"Reco track M ", 100, 0, 10)));
63 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_Pt").c_str(),
"Reco track Pt ", 100, 0, 100)));
64 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_Px").c_str(),
"Reco track Px ", 100, 0, 100)));
65 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_Py").c_str(),
"Reco track Py ", 100, 0, 100)));
66 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_Pz").c_str(),
"Reco track Pz ", 100, 0, 100)));
67 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_Eta").c_str(),
"Reco track Eta ", 100, -5, 5)));
68 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_Phi").c_str(),
"Reco track Phi ", 63, -3.2, 3.2)));
69 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_D0").c_str(),
"Reco track D0 ", 300, -300, 300)));
70 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_Z0").c_str(),
"Reco track Z0 ", 500, -500, 500)));
71 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_errD0").c_str(),
"Reco track errD0 ", 300, 0, 30)));
72 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_errZ0").c_str(),
"Reco track errZ0 ", 500, 0, 50)));
73 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_Chi2").c_str(),
"Reco track Chi2 ", 100, 0, 10)));
74 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_nDoF").c_str(),
"Reco track nDoF ", 100, 0, 100)));
75 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_Trk_charge").c_str(),
"Reco track charge ", 3, -1.5, 1.5)));
78 if ( recoType !=
"All" and recoType !=
"Fake" ) {
79 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_positionRes_R").c_str(),
"Position resolution for vertices matched to truth decays", 400, -20, 20)));
80 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_positionRes_Z").c_str(),
"Position resolution for vertices matched to truth decays", 400, -20, 20)));
81 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_matchScore_weight").c_str(),
"Vertex Match Score (weight)", 101, 0, 1.01)));
82 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_matchScore_pt").c_str(),
"Vertex Match Score (pT)", 101, 0, 1.01)));
83 ANA_CHECK (
book(
TH1F((
"RecoVertex/" + recoType +
"_matchedTruthID").c_str(),
"Vertex Truth Match ID", 100, 0, 100)));
101 ANA_CHECK (
book(
TH1F((
"TruthVertex/" +
truthType +
"_ParentProdX").c_str(),
"truthParentProd vertex x [mm]", 500, -500, 500)));
102 ANA_CHECK (
book(
TH1F((
"TruthVertex/" +
truthType +
"_ParentProdY").c_str(),
"truthParentProd vertex y [mm]", 500, -500, 500)));
103 ANA_CHECK (
book(
TH1F((
"TruthVertex/" +
truthType +
"_ParentProdZ").c_str(),
"truthParentProd vertex z [mm]", 500, -500, 500)));
105 ANA_CHECK (
book(
TH1F((
"TruthVertex/" +
truthType +
"_ParentProddistFromPV").c_str(),
"truthParentProd vertex distFromPV [mm]", 500, 0, 500)));
110 Double_t
bins[] = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 35, 40, 50, 60, 70, 80, 90, 100, 125, 150, 200, 300, 500};
118 return StatusCode::SUCCESS;
128 std::vector<const xAOD::Vertex*> recoVerticesToMatch;
129 std::vector<const xAOD::TruthVertex*> truthVerticesToMatch;
131 for(
const auto recoVertex : *recoVertexContainer) {
138 recoVerticesToMatch.push_back(recoVertex);
141 for(
const auto truthVertex : *truthVertexContainer) {
142 if(truthVertex->nIncomingParticles() != 1) {
152 if(truthVertex->nOutgoingParticles() < 2) {
155 truthVerticesToMatch.push_back(truthVertex);
159 ATH_CHECK(
m_matchTool->matchVertices( recoVerticesToMatch, truthVerticesToMatch, trackParticleContainer.
cptr() ) );
163 for(
const auto& secVtx : recoVerticesToMatch) {
164 int matchTypeBitset = matchTypeDecor(*secVtx);
165 hist(
"RecoVertex/matchType")->Fill(matchTypeBitset);
186 for(
const auto& truthVtx : truthVerticesToMatch) {
187 int truthTypeBitset = truthTypeDecor(*truthVtx);
214 return StatusCode::SUCCESS;
226 TVector3 reco_pos(secVtx->
x(), secVtx->
y(), secVtx->
z());
227 float Lxy = reco_pos.Perp();
231 ntracks = trkParts.size();
233 TLorentzVector sumP4(0,0,0,0);
237 double minOpAng = -1.0* 1.e10;
238 double maxOpAng = 1.0* 1.e10;
239 double minD0 = 1.0* 1.e10;
246 for(
size_t t = 0;
t < ntracks;
t++){
256 if(trk_d0 < minD0){ minD0 = trk_d0; }
257 if(trk_d0 > maxD0){ maxD0 = trk_d0; }
261 vv.SetPtEtaPhiM(trk.
pt(),trk.
eta(), trk.
phi0(), trk.
m());
263 H +=
vv.Vect().Mag();
266 TLorentzVector v_minus_iv(0,0,0,0);
267 for(
size_t j = 0; j < ntracks; j++){
268 if (j ==
t){
continue; }
278 tmp.SetPtEtaPhiM(trk_2.
pt(),trk_2.
eta(), trk_2.
phi0(), trk_2.
m());
282 double tm =
vv *
tmp / (
vv.Mag() *
tmp.Mag() );
283 if( minOpAng < tm ) minOpAng = tm;
284 if( maxOpAng > tm ) maxOpAng = tm;
287 double DR =
vv.DeltaR(v_minus_iv);
288 if( DR > maxDR ){ maxDR = DR;}
296 hist(
"RecoVertex/" + matchType +
"_Trk_Chi2")->Fill(Trk_Chi2(trk) / Trk_nDoF(trk));
297 hist(
"RecoVertex/" + matchType +
"_Trk_nDoF")->Fill(Trk_nDoF(trk));
299 hist(
"RecoVertex/" + matchType +
"_Trk_D0")->Fill(trk_d0);
300 hist(
"RecoVertex/" + matchType +
"_Trk_Z0")->Fill(trk_z0);
303 hist(
"RecoVertex/" + matchType +
"_Trk_Eta")->Fill(trk.
eta());
304 hist(
"RecoVertex/" + matchType +
"_Trk_Phi")->Fill(trk.
phi0());
305 hist(
"RecoVertex/" + matchType +
"_Trk_E")->Fill(trk.
e() /
GeV);
306 hist(
"RecoVertex/" + matchType +
"_Trk_M")->Fill(trk.
m() /
GeV);
307 hist(
"RecoVertex/" + matchType +
"_Trk_Pt")->Fill(trk.
pt() /
GeV);
308 hist(
"RecoVertex/" + matchType +
"_Trk_Px")->Fill(trk.
p4().Px() /
GeV);
309 hist(
"RecoVertex/" + matchType +
"_Trk_Py")->Fill(trk.
p4().Py() /
GeV);
310 hist(
"RecoVertex/" + matchType +
"_Trk_Pz")->Fill(trk.
p4().Pz() /
GeV);
311 hist(
"RecoVertex/" + matchType +
"_Trk_charge")->Fill(trk.
charge());
316 const double dir = sumP4.Vect().Dot( reco_pos ) / sumP4.Vect().Mag() / reco_pos.Mag();
321 hist(
"RecoVertex/" + matchType +
"_x")->Fill(secVtx->
x());
322 hist(
"RecoVertex/" + matchType +
"_y")->Fill(secVtx->
y());
323 hist(
"RecoVertex/" + matchType +
"_z")->Fill(secVtx->
z());
324 hist(
"RecoVertex/" + matchType +
"_Lxy")->Fill(Lxy);
325 hist(
"RecoVertex/" + matchType +
"_ntrk")->Fill(ntracks);
326 hist(
"RecoVertex/" + matchType +
"_pT")->Fill(sumP4.Pt() /
GeV);
327 hist(
"RecoVertex/" + matchType +
"_eta")->Fill(sumP4.Eta());
328 hist(
"RecoVertex/" + matchType +
"_phi")->Fill(sumP4.Phi());
329 hist(
"RecoVertex/" + matchType +
"_mass")->Fill(sumP4.M() /
GeV);
330 hist(
"RecoVertex/" + matchType +
"_mu")->Fill(sumP4.M()/maxDR /
GeV);
331 hist(
"RecoVertex/" + matchType +
"_chi2")->Fill(Chi2(*secVtx)/nDoF(*secVtx));
332 hist(
"RecoVertex/" + matchType +
"_dir")->Fill(
dir);
333 hist(
"RecoVertex/" + matchType +
"_charge")->Fill(
charge);
334 hist(
"RecoVertex/" + matchType +
"_H")->Fill(
H /
GeV);
335 hist(
"RecoVertex/" + matchType +
"_HT")->Fill(HT /
GeV);
336 hist(
"RecoVertex/" + matchType +
"_minOpAng")->Fill(minOpAng);
337 hist(
"RecoVertex/" + matchType +
"_maxOpAng")->Fill(maxOpAng);
338 hist(
"RecoVertex/" + matchType +
"_mind0")->Fill(minD0);
339 hist(
"RecoVertex/" + matchType +
"_maxd0")->Fill(maxD0);
340 hist(
"RecoVertex/" + matchType +
"_maxdR")->Fill(maxDR);
342 std::vector<InDetSecVtxTruthMatchUtils::VertexTruthMatchInfo> truthmatchinfo;
343 truthmatchinfo = matchInfoDecor(*secVtx);
346 if (matchType !=
"All" and matchType !=
"Fake") {
347 if(not truthmatchinfo.empty()){
348 float matchScore_weight = std::get<1>(truthmatchinfo.at(0));
349 float matchScore_pt = std::get<2>(truthmatchinfo.at(0));
351 ATH_MSG_DEBUG(
"Match Score and probability: " << matchScore_weight <<
" " << matchScore_pt/0.01);
356 hist(
"RecoVertex/" + matchType +
"_positionRes_R")->Fill(Lxy - truthVtx.
perp());
357 hist(
"RecoVertex/" + matchType +
"_positionRes_Z")->Fill(secVtx->
z() - truthVtx.
z());
358 hist(
"RecoVertex/" + matchType +
"_matchScore_weight")->Fill(matchScore_weight);
359 hist(
"RecoVertex/" + matchType +
"_matchScore_pt")->Fill(matchScore_pt);
size_t nOutgoingParticles() const
Get the number of outgoing particles.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
float x() const
Returns the x position.
virtual double m() const override final
The invariant mass of the particle..
float phi() const
Vertex azimuthal angle.
std::string find(const std::string &s)
return a remapped string
const_pointer_type cptr()
Dereference the pointer.
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
bool isFake(int matchInfo)
float charge() const
Returns the charge.
bool isReconstructable(int matchInfo)
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
TEfficiency * efficiency(const std::string &effName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TEfficiency.
bool isMerged(int matchInfo)
bool isMatched(int matchInfo)
Helper class to provide constant type-safe access to aux data.
bool isSplit(int matchInfo)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Select isolated Photons, Electrons and Muons.
float y() const
Vertex y displacement.
int truthType(const U &p)
ToolHandle< IInDetSecVtxTruthMatchTool > m_matchTool
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
void fillTruthHistograms(const xAOD::TruthVertex *truthVtx, const std::string &truthType)
Gaudi::Property< bool > m_writeHistograms
bool isOther(int matchInfo)
bool isReconstructed(int matchInfo)
virtual double e() const override final
The total energy of the particle.
Helper class to provide type-safe access to aux data.
virtual StatusCode initialize() override
bool isAccepted(int matchInfo)
::StatusCode StatusCode
StatusCode definition for legacy code.
@ SecVtx
Secondary vertex.
Class describing a truth particle in the MC record.
SG::ReadHandleKey< xAOD::VertexContainer > m_secVtxContainerKey
Gaudi::Property< std::vector< int > > m_targetPDGIDs
float perp() const
Vertex transverse distance from the beam line.
bool hasProdVtx() const
Check for a production vertex on this particle.
virtual StatusCode execute() override
This module defines the arguments passed from the BATCH driver to the BATCH worker.
std::vector< ElementLink< xAOD::TrackParticleContainer > > TrackParticleLinks_t
Type for the associated track particles.
float z() const
Returns the z position.
const TruthParticle_v1 * incomingParticle(size_t index) const
Get one of the incoming particles.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
ElementLink implementation for ROOT usage.
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
Class describing a truth vertex in the MC record.
float phi0() const
Returns the parameter, which has range to .
const ParametersCovMatrix_t definingParametersCovMatrix() const
Returns the 5x5 symmetric matrix containing the defining parameters covariance matrix.
void fillRecoHistograms(const xAOD::Vertex *secVtx, const std::string &matchType)
double charge(const T &p)
virtual double e() const override final
The total energy of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
DefiningParameters_t definingParameters() const
Returns a SVector of the Perigee track parameters.
float x() const
Vertex x displacement.
SecVertexTruthMatchAlg(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
bool isReconstructedSplit(int matchInfo)
Class describing a Vertex.
float eta() const
Vertex pseudorapidity.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
float z() const
Vertex longitudinal distance along the beam line form the origin.
float y() const
Returns the y position.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
TH1 * hist(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered histograms of any type.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
SG::ReadHandleKey< xAOD::TruthVertexContainer > m_truthVtxContainerKey
Class describing a TrackParticle.
bool isSeeded(int matchInfo)
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleContainerKey
virtual double m() const override final
The mass of the particle.
double charge() const
Physical charge.