Belle II Software development
RestOfEventPrinterModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9// Own header.
10#include <analysis/modules/RestOfEventPrinter/RestOfEventPrinterModule.h>
11
12// framework - DataStore
13#include <framework/datastore/StoreArray.h>
14#include <framework/datastore/StoreObjPtr.h>
15
16// framework aux
17#include <framework/logging/Logger.h>
18
19// dataobjects
20#include <analysis/dataobjects/Particle.h>
21#include <analysis/dataobjects/RestOfEvent.h>
22#include <mdst/dataobjects/MCParticle.h>
23
24using namespace std;
25using namespace Belle2;
26
27//-----------------------------------------------------------------
28// Register module
29//-----------------------------------------------------------------
30
31REG_MODULE(RestOfEventPrinter);
32
33//-----------------------------------------------------------------
34// Implementation
35//-----------------------------------------------------------------
36
38{
39 // set module description (e.g. insert text)
40 setDescription("Prints basic or detailed RestOfEvent info to screen. It is possible to print out ROEMasks for specific mask names as well.");
42
43 // Add parameters
44 std::vector<std::string> emptyVector;
45
46 addParam("maskNames", m_maskNames, "List of all mask names for which the info will be printed.", emptyVector);
47 addParam("fullPrint", m_fullPrint, "If true, print whole masks content.", false);
48 addParam("unpackComposites", m_unpackComposites, "If true, replace composites by their daughters", true);
49}
50
55
57{
58 B2INFO("[RestOfEventPrinterModule] START ----------------------------------------");
59
60 StoreObjPtr<RestOfEvent> roe("RestOfEvent");
61
62 if (roe.isValid()) {
63
64 const Particle* part = roe->getRelatedFrom<Particle>();
65 const MCParticle* mcpart = part->getRelated<MCParticle>();
66
67 int relatedPDG = part->getPDGCode();
68 int relatedMCPDG;
69 if (mcpart)
70 relatedMCPDG = mcpart->getPDG();
71 else
72 relatedMCPDG = -1;
73
74 // Start printing
75 B2INFO(" - " << "ROE related to particle with" << LogVar("PDG", relatedPDG));
76 B2INFO(" - " << "ROE related to MC particle with" << LogVar("PDG", relatedMCPDG));
77
79
80 for (const auto& maskName : m_maskNames) {
81 if (!roe->hasMask(maskName)) continue;
82 B2INFO(" - " << "Info for ROEMask with name: \'" << maskName << "\'");
83 roe->print(maskName, m_unpackComposites);
84
85 if (m_fullPrint) {
86 printMaskParticles(roe->getParticles(maskName));
87 }
88 }
89 } else
90 B2ERROR("RestOfEvent object not valid! Did you build ROE?");
91
92 B2INFO("[RestOfEventPrinterModule] END ------------------------------------------");
93}
94
95void RestOfEventPrinterModule::printMaskParticles(const std::vector<const Particle*>& maskParticles) const
96{
97 for (auto* particle : maskParticles) {
98 particle->print();
99 }
100}
A Class to store the Monte Carlo particle information.
Definition MCParticle.h:32
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
Module()
Constructor.
Definition Module.cc:30
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
Class to store reconstructed particles.
Definition Particle.h:76
int getPDGCode(void) const
Returns PDG code.
Definition Particle.h:465
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
bool m_fullPrint
True: Print whole masks content.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
std::vector< std::string > m_maskNames
List of all mask names for which the info will be printed.
bool m_unpackComposites
True: Replace composite particles or V0 by their daughters, default is true.
void printMaskParticles(const std::vector< const Particle * > &maskParticles) const
Prints out values of the specific ROE mask.
static constexpr const char * c_defaultMaskName
Default mask name.
Definition RestOfEvent.h:58
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
bool isValid() const
Check whether the object was created.
Class to store variables with their name which were sent to the logging service.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.
STL namespace.