9#include <analysis/modules/FlavorTaggerInfoFiller/FlavorTaggerInfoFillerModule.h>
10#include <framework/core/ModuleParam.templateDetails.h>
11#include <analysis/dataobjects/ParticleList.h>
12#include <analysis/dataobjects/FlavorTaggerInfo.h>
13#include <analysis/VariableManager/Manager.h>
26 setDescription(
"Creates a new flavorTaggerInfoMap DataObject for the specific methods. Saves there all the relevant information of the flavorTagger.");
30 vector<tuple<string, string>>());
32 vector<tuple<string, string, string>>());
33 addParam(
"FANNmlp",
m_FANNmlp,
"Sets if FANN Combiner output will be saved or not",
false);
34 addParam(
"TMVAfbdt",
m_TMVAfbdt,
"Sets if FANN Combiner output will be saved or not",
false);
35 addParam(
"DNNmlp",
m_DNNmlp,
"Sets if DNN Tagger output will be saved or not",
false);
36 addParam(
"qpCategories",
m_qpCategories,
"Sets if individual categories output will be saved or not",
false);
38 addParam(
"targetProb",
m_targetProb,
"Sets if individual Categories output will be saved or not",
false);
54 if (flavorTaggerInfo ==
nullptr) {
55 B2ERROR(
"flavorTaggerInfoFiller: FlavorTaggerInfo does not exist");
59 flavorTaggerInfo -> setUseModeFlavorTagger(
"Expert");
65 if (qrCombined < 1.1 && qrCombined > 1.0) qrCombined = 1.0;
66 if (qrCombined > - 1.1 && qrCombined < -1.0) qrCombined = -1.0;
67 float B0Probability = qrCombined / 2 + 0.5;
68 float B0barProbability = 1 - B0Probability;
78 float B0barProbability = 1 - B0Probability;
79 float qrCombined = 2 * (B0Probability - 0.5);
80 if (qrCombined < 1.1 && qrCombined > 1.0) qrCombined = 1.0;
81 if (qrCombined > - 1.1 && qrCombined < -1.0) qrCombined = -1.0;
90 float B0Probability = particle->
getExtraInfo(
"dnn_output");
91 float B0barProbability = 1 - B0Probability;
92 float qrCombined = 2 * (B0Probability - 0.5);
93 if (qrCombined < 1.1 && qrCombined > 1.0) qrCombined = 1.0;
94 if (qrCombined > - 1.1 && qrCombined < -1.0) qrCombined = -1.0;
103 string particleListName = get<0>(iTuple);
104 string category = get<1>(iTuple);
108 if (!particleList.isValid()) {
109 B2INFO(
"ParticleList " << particleListName <<
" not found");
111 if (particleList -> getListSize() == 0) {
112 infoMapsFBDT -> setProbTrackLevel(category, 0);
113 if (
m_trackPointers) infoMapsFBDT -> setTargetTrackLevel(category,
nullptr);
116 for (
unsigned int i = 0; i < particleList->getListSize(); ++i) {
117 Particle* iParticle = particleList ->getParticle(i);
118 bool hasMaxProb = std::get<bool>(manager.getVariable(
"hasHighestProbInCat(" + particleListName +
"," +
"isRightTrack(" + category +
119 "))")->function(iParticle));
120 if (hasMaxProb == 1) {
121 float targetProb = iParticle -> getExtraInfo(
"isRightTrack(" + category +
")");
124 infoMapsFBDT-> setTargetTrackLevel(category, iParticle -> getTrack());
137 string particleListName = get<0>(iTuple);
138 string category = get<1>(iTuple);
139 string qpCategoryVariable = get<2>(iTuple);
142 if (!particleList.isValid()) {
143 B2INFO(
"ParticleList " << particleListName <<
" not found");
145 if (particleList -> getListSize() == 0) {
146 infoMapsFBDT -> setProbEventLevel(category, 0);
147 infoMapsFBDT -> setQpCategory(category, 0);
149 infoMapsFBDT -> setHasTrueTarget(category, 0);
150 infoMapsFBDT -> setIsTrueCategory(category, 0);
152 if (
m_trackPointers) infoMapsFBDT -> setTargetEventLevel(category,
nullptr);
155 for (
unsigned int i = 0; i < particleList->getListSize(); ++i) {
156 Particle* iParticle = particleList ->getParticle(i);
157 bool hasMaxProb = std::get<bool>(manager.getVariable(
"hasHighestProbInCat(" + particleListName +
"," +
"isRightCategory(" + category
158 +
"))")-> function(iParticle));
159 if (hasMaxProb == 1) {
160 float categoryProb = iParticle -> getExtraInfo(
"isRightCategory(" + category +
")");
161 float qpCategory = std::get<double>(manager.getVariable(qpCategoryVariable)-> function(iParticle));
163 infoMapsFBDT -> setQpCategory(category, qpCategory);
165 float isTrueTarget = std::get<double>(manager.getVariable(
"hasTrueTarget(" + category +
")")-> function(
nullptr));
166 infoMapsFBDT -> setHasTrueTarget(category, isTrueTarget);
167 float isTrueCategory = std::get<double>(manager.getVariable(
"isTrueCategory(" + category +
")")-> function(
nullptr));
168 infoMapsFBDT -> setIsTrueCategory(category, isTrueCategory);
171 infoMapsFBDT-> setTargetEventLevel(category, iParticle -> getTrack());
std::vector< std::tuple< std::string, std::string > > m_trackLevelParticleLists
Used Flavor Tagger trackLevel Categories of the lists.
StoreObjPtr< RestOfEvent > m_roe
ROE object pointer.
virtual void initialize() override
Initialises the module.
virtual void event() override
Method called for each event.
bool m_targetProb
Sets if individual Categories output will be saved or not.
StoreArray< MCParticle > m_mcparticles
StoreArray of MCParticles.
FlavorTaggerInfoFillerModule()
Constructor.
virtual void terminate() override
Write TTree to file, and close file if necessary.
bool m_TMVAfbdt
Sets if FastBDT Combiner output will be saved or not.
bool m_FANNmlp
Sets if FANN Combiner output will be saved or not.
bool m_DNNmlp
Sets if DNN tagger output will be saved or not.
bool m_qpCategories
Sets if individual Categories output will be saved or not.
bool m_istrueCategories
Sets if individual MC thruth for each Category is saved or not.
StoreObjPtr< EventExtraInfo > m_eventExtraInfo
event extra info object pointer
std::vector< std::tuple< std::string, std::string, std::string > > m_eventLevelParticleLists
Used Flavor Tagger eventLevel Categories of the lists.
bool m_trackPointers
Sets if track pointers to target tracks are saved or not.
This class stores the Flavor Tagger information for a specific method and particle filled in the Flav...
void setProbEventLevel(const std::string &category, float probability)
Map filler: Set the category name and the highest category probability for the corresponding category...
void setProbTrackLevel(const std::string &category, float probability)
Map filler: Set the category name and the corresponding highest target track probability.
void setB0Probability(float B0Probability)
Saves the B0Probability output of the Combiner.
void setB0barProbability(float B0barProbability)
Saves the B0barProbability output of the Combiner.
void setQrCombined(float qr)
Saves qr Output of the Combiner.
This class stores the relevant information for the TagV vertex fit, extracted mainly from the Flavor ...
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Class to store reconstructed particles.
double getExtraInfo(const std::string &name) const
Return given value if set.
Type-safe access to single objects in the data store.
Global list of available variables.
static Manager & Instance()
get singleton instance.
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.
Abstract base class for different kinds of events.