9#include <tracking/modules/trackingPerformanceEvaluation/V0findingPerformanceEvaluationModule.h>
11#include <tracking/dataobjects/MCParticleInfo.h>
13#include <framework/datastore/StoreArray.h>
14#include <framework/datastore/RelationVector.h>
16#include <mdst/dataobjects/Track.h>
18#include <framework/gearbox/Const.h>
20#include <framework/geometry/BFieldManager.h>
22#include <root/TAxis.h>
23#include <root/TObject.h>
38 setDescription(
"This module evaluates the V0 finding package performance");
41 std::string(
"V0findingPerformanceEvaluation_output.root"));
42 addParam(
"V0sName",
m_V0sName,
"Name of V0 collection.", std::string(
"V0ValidationVertexs"));
84 m_h2_vtxTvsR_err =
createHistogram2D(
"h2vtxTerrVsR",
"vtxT error vs R", 100, 0, 100,
"R (cm)", 100, 0, 0.3,
"#sigma_{vtxT} (cm)",
109 m_h2_mom =
createHistogram2D(
"h2mom",
"reco VS true momentum", 100, 0, 3,
"V0 mom (GeV/c)", 100, 0, 3,
"MC mom (GeV/c)",
111 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)",
115 Double_t bins_pt[9 + 1] = {0, 0.05, 0.1, 0.15, 0.2, 0.3, 0.5, 1, 2, 3.5};
116 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, M_PI};
117 Double_t bins_phi[14 + 1];
118 Double_t width_phi = 2 * M_PI / 14;
119 for (
int bin = 0; bin < 14 + 1; bin++)
120 bins_phi[bin] = - M_PI + bin * width_phi;
129 9, bins_pt,
"p_{t} (GeV/c)",
130 10, bins_theta,
"#theta",
131 14, bins_phi,
"#phi" );
134 "entry per V0 connected to a MCParticle",
142 "entry per MCParticle connected to a V0",
156 B2DEBUG(29,
"+++++ 1. loop on MCParticles");
159 if (!
isV0(mcParticle))
166 if (nMatchedDau != 2)
169 int pdgCode = mcParticle.getPDG();
170 B2DEBUG(29,
"MCParticle has PDG code " << pdgCode);
175 ROOT::Math::XYZVector MC_prodvtx = mcParticle.getVertex();
176 ROOT::Math::XYZVector MC_vtx = mcParticle.getDecayVertex();
177 float MC_mom = mcParticle.getMomentum().R();
178 float MC_mass = mcParticle.getMass();
179 ROOT::Math::XYZVector MC_FL = MC_vtx - MC_prodvtx;
180 float flightR =
sqrt(MC_FL.X() * MC_FL.X() + MC_FL.Y() * MC_FL.Y());
189 DataStore::getRelationsWithObj<V0ValidationVertex>(&mcParticle,
m_V0sName);
193 if (V0s_toMCParticle.
size() > 0)
196 for (
int v0 = 0; v0 < (int)V0s_toMCParticle.
size(); v0++) {
198 ROOT::Math::XYZVector V0_vtx = V0s_toMCParticle[v0]->getVertexPosition();
199 float V0_mom = V0s_toMCParticle[v0]->getFittedMomentum();
200 float V0_chi2 = V0s_toMCParticle[v0]->getVertexChi2();
201 float V0_mass = V0s_toMCParticle[v0]->getFittedInvariantMass();
202 TMatrixDSym V0_cov = V0s_toMCParticle[v0]->getVertexPositionCovariance();
232 B2DEBUG(29,
"+++++ 2. loop on V0s");
236 int nMCParticles = 0;
243 nMCParticles = MCParticles_fromV0.
size();
245 if (nMCParticles == 0)
265 double efficiency = num / den ;
266 double efficiencyErr =
sqrt(efficiency * (1 - efficiency)) /
sqrt(den);
268 double nMCParticles = 0;
275 B2INFO(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
276 B2INFO(
"~ V0 Finding Performance Evaluation ~ SHORT SUMMARY ~");
278 B2INFO(
" + overall:");
279 B2INFO(
" efficiency = (" << efficiency * 100 <<
" +/- " << efficiencyErr * 100 <<
")% ");
280 B2INFO(
" purity = (" << purity * 100 <<
" +/- " << purityErr * 100 <<
")% ");
282 B2INFO(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
290 for (
int bin = 0; bin < h_eff_R->GetXaxis()->GetNbins(); bin++) {
297 eff = (double)num / den;
298 err =
sqrt(eff * (1 - eff)) /
sqrt(den);
301 h_eff_R->SetBinContent(bin + 1, eff);
302 h_eff_R->SetBinError(bin + 1, err);
314 TDirectory* oldDir = gDirectory;
316 TDirectory* dir_multiplicity = oldDir->mkdir(
"multiplicity");
317 dir_multiplicity->cd();
320 while ((obj = nextH_multiplicity()))
323 TDirectory* dir_efficiency = oldDir->mkdir(
"efficiency");
324 dir_efficiency->cd();
326 while ((obj = nextH_efficiency()))
329 TDirectory* dir_purity = oldDir->mkdir(
"purity");
332 while ((obj = nextH_purity()))
335 TDirectory* dir_trkQuality = oldDir->mkdir(
"trkQuality");
336 dir_trkQuality->cd();
338 while ((obj = nextH_trkQuality()))
342 while ((obj = nextH()))
355 bool isGamma =
false;
364 if (abs(the_mcParticle.
getPDG()) == 311)
367 bool isLambda =
false;
371 bool twoProngs =
false;
372 bool twoChargedProngs =
false;
379 twoChargedProngs =
true;
381 return ((isGamma || isK_S0 || isK_0 || isLambda) && twoChargedProngs);
390 std::vector< MCParticle* > MCPart_dau = the_mcParticle.
getDaughters();
395 RelationVector<Track> Tracks_fromMCParticle_0 = DataStore::getRelationsWithObj<Track>(MCPart_dau[0]);
396 if (Tracks_fromMCParticle_0.
size() > 0)
399 RelationVector<Track> Tracks_fromMCParticle_1 = DataStore::getRelationsWithObj<Track>(MCPart_dau[1]);
400 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.
int getPDG() const
Return PDG code of particle.
void setDescription(const std::string &description)
Sets the description of the module.
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.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#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.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.