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.");
27 setPropertyFlags(c_ParallelProcessingCertified);
29 addParam(
"trackLevelParticleLists", m_trackLevelParticleLists,
"Used Flavor Tagger trackLevel Categories of the lists ",
30 vector<tuple<string, string>>());
31 addParam(
"eventLevelParticleLists", m_eventLevelParticleLists,
"Used Flavor Tagger eventLevel Categories of the lists ",
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);
37 addParam(
"istrueCategories", m_istrueCategories,
"Sets if individual MC truth for each category is saved or not",
false);
38 addParam(
"targetProb", m_targetProb,
"Sets if individual Categories output will be saved or not",
false);
39 addParam(
"trackPointers", m_trackPointers,
"Sets if track pointers to target tracks are saved or not",
false);
43 void FlavorTaggerInfoFillerModule::initialize()
47 void FlavorTaggerInfoFillerModule::event()
54 if (flavorTaggerInfo ==
nullptr) {
55 B2ERROR(
"flavorTaggerInfoFiller: FlavorTaggerInfo does not exist");
59 flavorTaggerInfo -> setUseModeFlavorTagger(
"Expert");
64 float qrCombined = m_eventExtraInfo->getExtraInfo(
"qrCombinedFANN");
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;
77 float B0Probability = m_eventExtraInfo->getExtraInfo(
"qrCombinedFBDT");
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;
102 for (
auto& iTuple : m_trackLevelParticleLists) {
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 float hasMaxProb = manager.getVariable(
"hasHighestProbInCat(" + particleListName +
"," +
"isRightTrack(" +
119 category +
"))")->
function(iParticle);
120 if (hasMaxProb == 1) {
121 float targetProb = iParticle -> getExtraInfo(
"isRightTrack(" + category +
")");
123 if (m_trackPointers) {
124 infoMapsFBDT-> setTargetTrackLevel(category, iParticle -> getTrack());
134 if (m_qpCategories) {
136 for (
auto& iTuple : m_eventLevelParticleLists) {
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);
148 if (m_istrueCategories and m_mcparticles.isValid()) {
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 float hasMaxProb = manager.getVariable(
"hasHighestProbInCat(" + particleListName +
"," +
"isRightCategory(" +
158 category +
"))")->
function(iParticle);
159 if (hasMaxProb == 1) {
160 float categoryProb = iParticle -> getExtraInfo(
"isRightCategory(" + category +
")");
161 float qpCategory = manager.getVariable(qpCategoryVariable)->
function(iParticle);
163 infoMapsFBDT -> setQpCategory(category, qpCategory);
164 if (m_istrueCategories and m_mcparticles.isValid()) {
165 float isTrueTarget = manager.getVariable(
"hasTrueTarget(" + category +
")")->
function(
nullptr);
166 infoMapsFBDT -> setHasTrueTarget(category, isTrueTarget);
167 float isTrueCategory = manager.getVariable(
"isTrueCategory(" + category +
")")->
function(
nullptr);
168 infoMapsFBDT -> setIsTrueCategory(category, isTrueCategory);
170 if (m_trackPointers) {
171 infoMapsFBDT-> setTargetEventLevel(category, iParticle -> getTrack());
183 void FlavorTaggerInfoFillerModule::terminate()
Creates a new flavorTaggerInfoMap DataObject for the specific methods.
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 ...
Class to store reconstructed particles.
Type-safe access to single objects in the data store.
Global list of available variables.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.