 |
Belle II Software
release-05-02-19
|
11 #include <tracking/modules/standardTrackingPerformance/StandardTrackingPerformanceModule.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 #include <framework/dataobjects/EventMetaData.h>
16 #include <framework/datastore/RelationVector.h>
18 #include <tracking/dataobjects/RecoTrack.h>
19 #include <genfit/TrackPoint.h>
20 #include <genfit/KalmanFitterInfo.h>
22 #include <mdst/dataobjects/MCParticle.h>
23 #include <mdst/dataobjects/Track.h>
25 #include <pxd/reconstruction/PXDRecoHit.h>
26 #include <svd/reconstruction/SVDRecoHit.h>
27 #include <svd/reconstruction/SVDRecoHit2D.h>
28 #include <cdc/dataobjects/CDCRecoHit.h>
30 #include <root/TFile.h>
31 #include <root/TTree.h>
40 StandardTrackingPerformanceModule::StandardTrackingPerformanceModule() :
41 Module(), m_outputFile(NULL), m_dataTree(NULL), m_trackProperties(-999), m_pValue(-999),
42 m_nGeneratedChargedStableMcParticles(-999), m_nReconstructedChargedStableTracks(-999),
43 m_nFittedChargedStabletracks(-999)
45 setDescription(
"Module to test the tracking efficiency. Writes information about the tracks and MCParticles in a ROOT file.");
49 std::string(
"StandardTrackingPerformanceOutput.root"));
60 mcParticles.isRequired();
65 recoTracks.isRequired();
68 trackFitResults.isRequired();
71 TDirectory* oldDir = gDirectory;
82 unsigned long eventNumber = eventMetaData->getEvent();
83 unsigned long runNumber = eventMetaData->getRun();
84 unsigned long expNumber = eventMetaData->getExperiment();
87 "Processes experiment " << expNumber <<
" run " << runNumber <<
" event " << eventNumber);
101 int pdgCode = mcParticle.getPDG();
102 B2DEBUG(99,
"Primary MCParticle has PDG code " << pdgCode);
118 double maximumWeight = -2;
125 for (
unsigned int index = 0; index < relatedRecoTracks.size(); ++index) {
126 const RecoTrack* relatedRecoTrack = relatedRecoTracks.object(index);
127 const double weight = relatedRecoTracks.weight(index);
130 B2ASSERT(
"B2Track <-> RecoTrack is not a 1:1 relation as expected!", numberOfRelatedTracks <= 1);
132 if (numberOfRelatedTracks == 1) {
133 if (weight > maximumWeight) {
134 maximumWeight = weight;
135 recoTrack = relatedRecoTrack;
143 B2ASSERT(
"Related Belle2 Track has no related track fit result for pion!", fitResult);
147 TVector3 mom = fitResult->getMomentum();
176 B2ERROR(
"Unknown AbsMeasurement in track.");
178 std::vector<double> weights;
218 B2FATAL(
"Data tree was not created.");
264 TDirectory* oldDir = gDirectory;
279 for (
const MCParticle& mcParticle : mcParticles) {
281 if (abs(mcParticle.getPDG()) != 511 && abs(mcParticle.getPDG()) != 521)
293 std::vector<int> daughterPDGs;
294 std::vector<MCParticle*> daughterMcParticles = mcParticle.
getDaughters();
299 for (
auto daughterMCParticle : daughterMcParticles) {
301 daughterPDGs.push_back(daughterMCParticle->getPDG());
304 std::sort(daughterPDGs.begin(), daughterPDGs.end());
318 std::vector<MCParticle*> daughtersWOFSR;
319 for (
unsigned int iDaughter = 0; iDaughter < in_daughters.size(); iDaughter++)
320 if (abs(in_daughters[iDaughter]->getPDG()) != 22)
321 daughtersWOFSR.push_back(in_daughters[iDaughter]);
323 return daughtersWOFSR;
331 std::vector<MCParticle*> daughters = mcParticle.
getDaughters();
332 if (daughters.size() != 0) {
333 for (
auto daughterMcParticle : daughters) {
359 std::stringstream leaf;
360 leaf << varName <<
"/D";
361 m_dataTree->Branch(varName.c_str(), &varReference, leaf.str().c_str());
366 std::stringstream leaf;
367 leaf << varName <<
"/I";
368 m_dataTree->Branch(varName.c_str(), &varReference, leaf.str().c_str());
Object containing AbsMeasurement and AbsFitterInfo objects.
SVDRecoHit - an extended form of SVDHit containing geometry information.
float weights[maxNweights]
Weights of the hits in sequence
RelationVector< T > getRelationsWith(const std::string &name="", const std::string &namedRelation="") const
Get the relations between this object and another store array.
void setDescription(const std::string &description)
Sets the description of the module.
static const ParticleType invalidParticle
Invalid particle, used internally.
double py
measured momentum in y direction
double ptot_gen
generated total momentum
double px
measured momentum in x direction
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
int nWeights
Number of entries in weights array
double py_gen
generated momentum in y direction
static const ParticleSet chargedStableSet
set of charged stable particles
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
PXDRecoHit - an extended form of PXDCluster containing geometry information.
Values of the result of a track fit with a given particle hypothesis.
double pz_gen
generated momentum in z direction
double mass_gen
generated mass
This class is used to transfer CDC information to the track fit.
const std::vector< genfit::TrackPoint * > & getHitPointsWithMeasurement() const
Return a list of measurements and track points, which can be used e.g. to extrapolate....
double px_gen
generated momentum in x direction
double pt
measured transverse momentum
int nSVDhits
Number of SVD hits in reconstructed track
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
bool hasStatus(unsigned short int bitmask) const
Return if specific status bit is set.
Contains the measurement and covariance in raw detector coordinates.
This is the Reconstruction Event-Data Model Track.
static const ChargedStable pion
charged pion particle
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
double cosTheta
polar angle of measured momentum vector
const ParticleType & find(int pdg) const
Returns particle in set with given PDG code, or invalidParticle if not found.
const TrackFitResult * getTrackFitResultWithClosestMass(const Const::ChargedStable &requestedType) const
Return the track fit for a fit hypothesis with the closest mass.
Abstract base class for different kinds of events.
Type-safe access to single objects in the data store.
int getPDG() const
Return PDG code of particle.
double y
measured y value of position
int nCDChits
Number of CDC hits in reconstructed track
double y_gen
y value of generated position
@ c_StableInGenerator
bit 1: Particle is stable, i.e., not decaying in the generator.
double pt_gen
generated transverse momentum
SVDRecoHit - an extended form of SVDHit containing geometry information.
int nPXDhits
Number of PXD hits in reconstructed track
std::vector< Belle2::MCParticle * > getDaughters() const
Get vector of all daughter particles, empty vector if none.
double cosTheta_gen
polar angle of generated momentum vector
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Class that bundles various TrackFitResults.
static const int maxNweights
the maximum number of stored weights
A Class to store the Monte Carlo particle information.
std::vector< double > getWeights() const
Get weights of measurements.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
double x
measured x value of position
double z_gen
z value of generated position
double ptot
measured total momentum
double x_gen
x value of generated position
double pz
measured momentum in z direction
double z
measured z value of position
@ c_PrimaryParticle
bit 0: Particle is primary particle.