 |
Belle II Software
release-05-02-19
|
11 #include <ecl/modules/eclTrackClusterMatching/ECLTrackClusterMatchingPerformanceModule.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>
17 #include <mdst/dataobjects/HitPatternCDC.h>
18 #include <mdst/dataobjects/HitPatternVXD.h>
20 #include <root/TFile.h>
21 #include <root/TTree.h>
30 ECLTrackClusterMatchingPerformanceModule::ECLTrackClusterMatchingPerformanceModule() :
31 Module(), m_trackProperties()
33 setDescription(
"Module to test the track cluster matching efficiency. Writes information about the tracks and MCParticles in a ROOT file.");
36 addParam(
"outputFileName", m_outputFileName,
"Name of output root file.",
37 std::string(
"ECLTrackClusterMatchingPerformance.root"));
38 addParam(
"minClusterEnergy", m_minClusterEnergy,
"Minimal cluster energy in units of particle's true energy for MC match",
40 addParam(
"minWeight", m_minWeight,
"Fraction of cluster energy required to originate from particle to be matched to cluster.",
42 addParam(
"trackClusterRelationName", m_trackClusterRelationName,
"Name of relation array between tracks and ECL clusters",
55 TDirectory* oldDir = gDirectory;
67 m_iEvent = eventMetaData->getEvent();
68 m_iRun = eventMetaData->getRun();
73 bool found_photon =
false, found_mcmatch =
false, found_charged_stable =
false;
75 const auto& relatedMCParticles = eclCluster.getRelationsWith<
MCParticle>();
76 for (
unsigned int index = 0; index < relatedMCParticles.size() && (!found_photon || !found_charged_stable); ++index) {
77 const MCParticle* relatedMCParticle = relatedMCParticles.object(index);
82 const double weight = relatedMCParticles.weight(index);
92 if (eclCluster.getEnergy(hypo) >= 0.5 * relatedMCParticle->
getEnergy()) {
94 found_charged_stable =
true;
95 }
else if (relatedMCParticle->
getPDG() == 22 && weight >= 0.5 * eclCluster.getEnergy(hypo) && !found_photon) {
102 if (eclCluster.isTrack()) {
135 int pdgCode = mcParticle.getPDG();
136 B2DEBUG(29,
"Primary MCParticle has PDG code " << pdgCode);
150 const Track* b2Track =
nullptr;
151 double maximumWeight = -2;
154 for (
unsigned int index = 0; index < relatedTracks.size(); ++index) {
155 const Track* relatedTrack = relatedTracks.object(index);
156 const double weight = relatedTracks.weight(index);
158 if (weight > maximumWeight) {
159 maximumWeight = weight;
160 b2Track = relatedTrack;
166 B2ASSERT(
"Related Belle2 Track has no related track fit result!", fitResult);
193 const ECLCluster* eclCluster_PhotonHypothesis_track_related =
nullptr;
194 const ECLCluster* eclCluster_HadronHypothesis_track_related =
nullptr;
196 if (!(eclCluster.isTrack()))
continue;
204 eclCluster_PhotonHypothesis_track_related = &eclCluster;
213 eclCluster_HadronHypothesis_track_related = &eclCluster;
218 const ECLCluster* eclCluster_matchedBestToMCParticle =
nullptr;
220 for (
unsigned int index = 0; index < relatedECLClusters.size(); ++index) {
221 const ECLCluster* relatedECLCluster = relatedECLClusters.object(index);
223 const double weight = relatedECLClusters.weight(index);
224 if (weight > maximumWeight) {
225 eclCluster_matchedBestToMCParticle = relatedECLCluster;
226 maximumWeight = weight;
229 if (eclCluster_matchedBestToMCParticle !=
nullptr) {
235 if ((eclCluster_PhotonHypothesis_track_related == eclCluster_matchedBestToMCParticle
237 || (eclCluster_HadronHypothesis_track_related == eclCluster_matchedBestToMCParticle
268 B2FATAL(
"Data tree or event tree was not created.");
366 TDirectory* oldDir = gDirectory;
461 std::stringstream leaf;
462 leaf << varName <<
"/D";
463 tree->Branch(varName.c_str(), &varReference, leaf.str().c_str());
468 std::stringstream leaf;
469 leaf << varName <<
"/I";
470 tree->Branch(varName.c_str(), &varReference, leaf.str().c_str());
float getEnergy() const
Return particle energy in GeV.
unsigned short getNPXDHits() const
Get total number of hits in the PXD.
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.
TVector3 getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
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.
double phi_gen
azimuthal angle of generated momentum vector
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
EHypothesisBit
The hypothesis bits for this ECLCluster (Connected region (CR) is split using this hypothesis.
double py_gen
generated momentum in y direction
double getPValue() const
Getter for Chi2 Probability of the track fit.
double getTheta() const
Return Corrected Theta of Shower (radian).
static const ParticleSet chargedStableSet
set of charged stable particles
double getPhi() const
Return Corrected Phi of Shower (radian).
@ c_nPhotons
CR is split into n photons (N1)
bool hasHypothesis(EHypothesisBit bitmask) const
Return if specific hypothesis bit is set.
Values of the result of a track fit with a given particle hypothesis.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
TVector3 getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
double pz_gen
generated momentum in z direction
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
double getZ0() const
Getter for z0.
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.
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.
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from another store array to this object.
double y
measured y value of position
int nCDChits
Number of CDC hits in reconstructed track
@ c_neutralHadron
CR is reconstructed as a neutral hadron (N2)
int pdg_gen
PDG code of generated particle.
HitPatternVXD getHitPatternVXD() const
Getter for the hit pattern in the VXD;.
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
int nPXDhits
Number of PXD hits in reconstructed track
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.
Provides a type-safe way to pass members of the chargedStableSet set.
short getLastLayer() const
Returns the index of the last layer with a hit.
double phi
azimuthal angle of measured momentum vector
unsigned short getNHits() const
Get the total Number of CDC hits in the fit.
unsigned short getNSVDHits() const
Get total number of hits in the SVD.
Class that bundles various TrackFitResults.
A Class to store the Monte Carlo particle information.
int getDetectorRegion() const
Return detector region: 0: below acceptance, 1: FWD, 2: BRL, 3: BWD, 11: FWDGAP, 13: BWDGAP.
@ 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
short getChargeSign() const
Return track charge (1 or -1).
double z
measured z value of position
@ c_PrimaryParticle
bit 0: Particle is primary particle.
double getD0() const
Getter for d0.