Belle II Software light-2406-ragdoll
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/RestOfEvent.h>
21#include <mdst/dataobjects/MCParticle.h>
22
23#include <iostream>
24
25using namespace std;
26using namespace Belle2;
27
28//-----------------------------------------------------------------
29// Register module
30//-----------------------------------------------------------------
31
32REG_MODULE(RestOfEventPrinter);
33
34//-----------------------------------------------------------------
35// Implementation
36//-----------------------------------------------------------------
37
39{
40 // set module description (e.g. insert text)
41 setDescription("Prints basic or detailed RestOfEvent info to screen. It is possible to print out ROEMasks for specific mask names as well.");
43
44 // Add parameters
45 std::vector<std::string> emptyVector;
46
47 addParam("maskNames", m_maskNames, "List of all mask names for which the info will be printed.", emptyVector);
48 addParam("fullPrint", m_fullPrint, "If true, print whole masks content.", false);
49 addParam("unpackComposites", m_unpackComposites, "If true, replace composites by their daughters", true);
50}
51
53{
55}
56
58{
59 B2INFO("[RestOfEventPrinterModule] START ----------------------------------------");
60
61 StoreObjPtr<RestOfEvent> roe("RestOfEvent");
62
63 if (roe.isValid()) {
64
65 const Particle* part = roe->getRelatedFrom<Particle>();
66 const MCParticle* mcpart = part->getRelated<MCParticle>();
67
68 int relatedPDG = part->getPDGCode();
69 int relatedMCPDG;
70 if (mcpart)
71 relatedMCPDG = mcpart->getPDG();
72 else
73 relatedMCPDG = -1;
74
75 // Start printing
76 B2INFO(" - " << "ROE related to particle with" << LogVar("PDG", relatedPDG));
77 B2INFO(" - " << "ROE related to MC particle with" << LogVar("PDG", relatedMCPDG));
78
80
81 for (const auto& maskName : m_maskNames) {
82 if (!roe->hasMask(maskName)) continue;
83 B2INFO(" - " << "Info for ROEMask with name: \'" << maskName << "\'");
84 roe->print(maskName, m_unpackComposites);
85
86 if (m_fullPrint) {
87 printMaskParticles(roe->getParticles(maskName));
88 }
89 }
90 } else
91 B2ERROR("RestOfEvent object not valid! Did you build ROE?");
92
93 B2INFO("[RestOfEventPrinterModule] END ------------------------------------------");
94}
95
96void RestOfEventPrinterModule::printMaskParticles(const std::vector<const Particle*>& maskParticles) const
97{
98 for (auto* particle : maskParticles) {
99 particle->print();
100 }
101}
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Base class for Modules.
Definition: Module.h:72
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
@ 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:75
int getPDGCode(void) const
Returns PDG code.
Definition: Particle.h:454
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:60
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.
Definition: StoreObjPtr.h:111
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:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24
STL namespace.