9 #include <tracking/modules/trackingPerformanceEvaluation/V0findingPerformanceEvaluationModule.h>
11 #include <tracking/dataobjects/MCParticleInfo.h>
12 #include <tracking/dataobjects/V0ValidationVertex.h>
14 #include <framework/datastore/StoreArray.h>
15 #include <framework/datastore/RelationVector.h>
17 #include <mdst/dataobjects/Track.h>
19 #include <framework/gearbox/Const.h>
21 #include <framework/geometry/BFieldManager.h>
23 #include <root/TAxis.h>
24 #include <root/TObject.h>
26 #include <boost/foreach.hpp>
36 V0findingPerformanceEvaluationModule::V0findingPerformanceEvaluationModule() :
40 setDescription(
"This module evaluates the V0 finding package performance");
42 addParam(
"outputFileName", m_rootFileName,
"Name of output root file.",
43 std::string(
"V0findingPerformanceEvaluation_output.root"));
44 addParam(
"V0sName", m_V0sName,
"Name of V0 collection.", std::string(
"V0ValidationVertexs"));
45 addParam(
"MCParticlesName", m_MCParticlesName,
"Name of MC Particle collection.", std::string(
""));
49 V0findingPerformanceEvaluationModule::~V0findingPerformanceEvaluationModule()
89 m_h2_vtxTvsR_err =
createHistogram2D(
"h2vtxTerrVsR",
"vtxT error vs R", 100, 0, 100,
"R (cm)", 100, 0, 0.3,
"#sigma_{vtxT} (cm)",
114 m_h2_mom =
createHistogram2D(
"h2mom",
"reco VS true momentum", 100, 0, 3,
"V0 mom (GeV/c)", 100, 0, 3,
"MC mom (GeV/c)",
116 m_h2_mass =
createHistogram2D(
"h2mass",
"reco VS true mass", 100, 0, 1.5,
"V0 mass (GeV/c2)", 100, 0, 1.5,
"MC mass (GeV/c)",
120 Double_t bins_pt[9 + 1] = {0, 0.05, 0.1, 0.15, 0.2, 0.3, 0.5, 1, 2, 3.5};
121 Double_t bins_theta[10 + 1] = {0, 0.25, 0.5, 0.75, 0.75 + 0.32, 0.75 + 2 * 0.32, 0.75 + 3 * 0.32, 0.75 + 4 * 0.32, 0.75 + 5 * 0.32, 2.65, TMath::Pi()};
122 Double_t bins_phi[14 + 1];
123 Double_t width_phi = 2 * TMath::Pi() / 14;
124 for (
int bin = 0; bin < 14 + 1; bin++)
125 bins_phi[bin] = - TMath::Pi() + bin * width_phi;
134 9, bins_pt,
"p_{t} (GeV/c)",
135 10, bins_theta,
"#theta",
136 14, bins_phi,
"#phi" );
139 "entry per V0 connected to a MCParticle",
147 "entry per MCParticle connected to a V0",
163 B2DEBUG(99,
"+++++ 1. loop on MCParticles");
164 BOOST_FOREACH(
MCParticle & mcParticle, mcParticles) {
166 if (!
isV0(mcParticle))
173 if (nMatchedDau != 2)
176 int pdgCode = mcParticle.
getPDG();
177 B2DEBUG(99,
"MCParticle has PDG code " << pdgCode);
182 TVector3 MC_prodvtx = mcParticle.
getVertex();
185 float MC_mass = mcParticle.
getMass();
186 TVector3 MC_FL = MC_vtx - MC_prodvtx;
187 float flightR = sqrt(MC_FL.X() * MC_FL.X() + MC_FL.Y() * MC_FL.Y());
196 DataStore::getRelationsWithObj<V0ValidationVertex>(&mcParticle,
m_V0sName);
200 if (V0s_toMCParticle.
size() > 0)
203 for (
int v0 = 0; v0 < (int)V0s_toMCParticle.
size(); v0++) {
205 TVector3 V0_vtx = V0s_toMCParticle[v0]->getVertexPosition();
206 float V0_mom = V0s_toMCParticle[v0]->getFittedMomentum();
207 float V0_chi2 = V0s_toMCParticle[v0]->getVertexChi2();
208 float V0_mass = V0s_toMCParticle[v0]->getFittedInvariantMass();
209 TMatrixDSym V0_cov = V0s_toMCParticle[v0]->getVertexPositionCovariance();
227 m_h1_vtxX_pll->Fill((V0_vtx.X() - MC_vtx.X()) / sqrt(V0_cov[0][0]));
228 m_h1_vtxY_pll->Fill((V0_vtx.Y() - MC_vtx.Y()) / sqrt(V0_cov[1][1]));
229 m_h1_vtxZ_pll->Fill((V0_vtx.Z() - MC_vtx.Z()) / sqrt(V0_cov[2][2]));
239 B2DEBUG(99,
"+++++ 2. loop on V0s");
247 int nMCParticles = 0;
254 nMCParticles = MCParticles_fromV0.
size();
256 if (nMCParticles == 0)
276 double efficiency = num / den ;
277 double efficiencyErr = sqrt(efficiency * (1 - efficiency)) / sqrt(den);
279 double nMCParticles = 0;
286 B2INFO(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
287 B2INFO(
"~ V0 Finding Performance Evaluation ~ SHORT SUMMARY ~");
289 B2INFO(
" + overall:");
290 B2INFO(
" efficiency = (" << efficiency * 100 <<
" +/- " << efficiencyErr * 100 <<
")% ");
291 B2INFO(
" purity = (" << purity * 100 <<
" +/- " << purityErr * 100 <<
")% ");
293 B2INFO(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
301 for (
int bin = 0; bin < h_eff_R->GetXaxis()->GetNbins(); bin++) {
308 eff = (double)num / den;
309 err = sqrt(eff * (1 - eff)) / sqrt(den);
312 h_eff_R->SetBinContent(bin + 1, eff);
313 h_eff_R->SetBinError(bin + 1, err);
325 TDirectory* oldDir = gDirectory;
327 TDirectory* dir_multiplicity = oldDir->mkdir(
"multiplicity");
328 dir_multiplicity->cd();
331 while ((obj = nextH_multiplicity()))
334 TDirectory* dir_efficiency = oldDir->mkdir(
"efficiency");
335 dir_efficiency->cd();
337 while ((obj = nextH_efficiency()))
340 TDirectory* dir_purity = oldDir->mkdir(
"purity");
343 while ((obj = nextH_purity()))
346 TDirectory* dir_trkQuality = oldDir->mkdir(
"trkQuality");
347 dir_trkQuality->cd();
349 while ((obj = nextH_trkQuality()))
353 while ((obj = nextH()))
366 bool isGamma =
false;
375 if (abs(the_mcParticle.
getPDG()) == 311)
378 bool isLambda =
false;
382 bool twoProngs =
false;
383 bool twoChargedProngs =
false;
390 twoChargedProngs =
true;
392 return ((isGamma || isK_S0 || isK_0 || isLambda) && twoChargedProngs);
401 std::vector< MCParticle* > MCPart_dau = the_mcParticle.
getDaughters();
406 RelationVector<Track> Tracks_fromMCParticle_0 = DataStore::getRelationsWithObj<Track>(MCPart_dau[0]);
407 if (Tracks_fromMCParticle_0.
size() > 0)
410 RelationVector<Track> Tracks_fromMCParticle_1 = DataStore::getRelationsWithObj<Track>(MCPart_dau[1]);
411 if (Tracks_fromMCParticle_1.
size() > 0)
int getPDGCode() const
PDG code.
static const ParticleType Lambda
Lambda particle.
static const ParticleType antiLambda
Anti-Lambda particle.
static const ParticleType Kshort
K^0_S particle.
static const ParticleType photon
photon particle
This struct is used by the TrackingPerformanceEvaluation Module to save information of reconstructed ...
double getPt()
Getter for transverse momentum.
double getPtheta()
Getter for theta of momentum vector.
double getPphi()
Getter for phi of momentum vector.
A Class to store the Monte Carlo particle information.
std::vector< Belle2::MCParticle * > getDaughters() const
Get vector of all daughter particles, empty vector if none.
float getMass() const
Return the particle mass in GeV.
TVector3 getVertex() const
Return production vertex position, shorthand for getProductionVertex().
TVector3 getMomentum() const
Return momentum.
TVector3 getDecayVertex() const
Return decay vertex.
int getPDG() const
Return PDG code of particle.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
static const double T
[tesla]
Class which stores some additional information on V0 vertices.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Abstract base class for different kinds of events.