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;
130 9, bins_pt,
"p_{t} (GeV/c)",
131 10, bins_theta,
"#theta",
132 14, bins_phi,
"#phi" );
135 "entry per V0 connected to a MCParticle",
143 "entry per MCParticle connected to a V0",
157 B2DEBUG(29,
"+++++ 1. loop on MCParticles");
160 if (!
isV0(mcParticle))
167 if (nMatchedDau != 2)
171 int pdgCode = mcParticle.getPDG();
172 B2DEBUG(29,
"MCParticle has PDG code " << pdgCode);
177 ROOT::Math::XYZVector MC_prodvtx = mcParticle.getVertex();
178 ROOT::Math::XYZVector MC_vtx = mcParticle.getDecayVertex();
179 float MC_mom = mcParticle.getMomentum().R();
180 float MC_mass = mcParticle.getMass();
181 ROOT::Math::XYZVector MC_FL = MC_vtx - MC_prodvtx;
182 float flightR =
sqrt(MC_FL.X() * MC_FL.X() + MC_FL.Y() * MC_FL.Y());
195 if (V0s_toMCParticle.
size() > 0)
198 for (
int v0 = 0; v0 < (int)V0s_toMCParticle.
size(); v0++) {
200 ROOT::Math::XYZVector V0_vtx = V0s_toMCParticle[v0]->getVertexPosition();
201 float V0_mom = V0s_toMCParticle[v0]->getFittedMomentum();
202 float V0_chi2 = V0s_toMCParticle[v0]->getVertexChi2();
203 float V0_mass = V0s_toMCParticle[v0]->getFittedInvariantMass();
204 TMatrixDSym V0_cov = V0s_toMCParticle[v0]->getVertexPositionCovariance();
234 B2DEBUG(29,
"+++++ 2. loop on V0s");
238 int nMCParticles = 0;
245 nMCParticles = MCParticles_fromV0.
size();
247 if (nMCParticles == 0)
267 double efficiency = num / den ;
268 double efficiencyErr =
sqrt(efficiency * (1 - efficiency)) /
sqrt(den);
270 double nMCParticles = 0;
277 B2INFO(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
278 B2INFO(
"~ V0 Finding Performance Evaluation ~ SHORT SUMMARY ~");
280 B2INFO(
" + overall:");
281 B2INFO(
" efficiency = (" << efficiency * 100 <<
" +/- " << efficiencyErr * 100 <<
")% ");
282 B2INFO(
" purity = (" << purity * 100 <<
" +/- " << purityErr * 100 <<
")% ");
284 B2INFO(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
292 for (
int bin = 0; bin < h_eff_R->GetXaxis()->GetNbins(); bin++) {
299 eff = (double)num / den;
300 err =
sqrt(eff * (1 - eff)) /
sqrt(den);
303 h_eff_R->SetBinContent(bin + 1, eff);
304 h_eff_R->SetBinError(bin + 1, err);
316 TDirectory* oldDir = gDirectory;
318 TDirectory* dir_multiplicity = oldDir->mkdir(
"multiplicity");
319 dir_multiplicity->cd();
322 while ((obj = nextH_multiplicity()))
325 TDirectory* dir_efficiency = oldDir->mkdir(
"efficiency");
326 dir_efficiency->cd();
328 while ((obj = nextH_efficiency()))
331 TDirectory* dir_purity = oldDir->mkdir(
"purity");
334 while ((obj = nextH_purity()))
337 TDirectory* dir_trkQuality = oldDir->mkdir(
"trkQuality");
338 dir_trkQuality->cd();
340 while ((obj = nextH_trkQuality()))
344 while ((obj = nextH()))
357 bool isGamma =
false;
366 if (abs(the_mcParticle.
getPDG()) == 311)
369 bool isLambda =
false;
373 bool twoProngs =
false;
374 bool twoChargedProngs =
false;
381 twoChargedProngs =
true;
383 return ((isGamma || isK_S0 || isK_0 || isLambda) && twoChargedProngs);
392 std::vector< MCParticle* > MCPart_dau = the_mcParticle.
getDaughters();
398 if (Tracks_fromMCParticle_0.
size() > 0)
402 if (Tracks_fromMCParticle_1.
size() > 0)
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
static RelationVector< T > getRelationsWithObj(const TObject *object, const std::string &name="", const std::string &namedRelation="")
Get the relations between an object and other objects in a store array.
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.
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.