Belle II Software  release-05-02-19
RestOfEventPrinterModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Matic Lubej *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 // Own include
12 #include <analysis/modules/RestOfEventPrinter/RestOfEventPrinterModule.h>
13 
14 // framework - DataStore
15 #include <framework/datastore/StoreArray.h>
16 #include <framework/datastore/StoreObjPtr.h>
17 
18 // framework aux
19 #include <framework/logging/Logger.h>
20 
21 // dataobjects
22 #include <analysis/dataobjects/RestOfEvent.h>
23 #include <mdst/dataobjects/MCParticle.h>
24 
25 #include <iostream>
26 
27 using namespace std;
28 
29 namespace Belle2 {
35  //-----------------------------------------------------------------
36  // Register module
37  //-----------------------------------------------------------------
38 
39  REG_MODULE(RestOfEventPrinter)
40 
41  //-----------------------------------------------------------------
42  // Implementation
43  //-----------------------------------------------------------------
44 
46  {
47  // set module description (e.g. insert text)
48  setDescription("Prints basic or detailed RestOfEvent info to screen. It is possible to print out ROEMasks for specific mask names as well.");
49  setPropertyFlags(c_ParallelProcessingCertified);
50 
51  // Add parameters
52  std::vector<std::string> emptyVector;
53 
54  addParam("maskNames", m_maskNames, "List of all mask names for which the info will be printed.", emptyVector);
55  addParam("whichMask", m_whichMask, "Print Track mask (track), ECLCluster mask (cluster), or (both)?", std::string("both"));
56  addParam("fullPrint", m_fullPrint, "True: Print whole masks content.", false);
57  }
58 
59  void RestOfEventPrinterModule::initialize()
60  {
61  StoreArray<RestOfEvent>().isRequired();
62  }
63 
64  void RestOfEventPrinterModule::event()
65  {
66  B2INFO("[RestOfEventPrinterModule] START ----------------------------------------");
67 
68  StoreObjPtr<RestOfEvent> roe("RestOfEvent");
69 
70  if (roe.isValid()) {
71 
72  const Particle* part = roe->getRelated<Particle>();
73  const MCParticle* mcpart = part->getRelated<MCParticle>();
74 
75  unsigned int nAllTracks = roe->getNTracks();
76  unsigned int nAllECLClusters = roe->getNECLClusters();
77  unsigned int nAllKLMClusters = roe->getNKLMClusters();
78  int relatedPDG = part->getPDGCode();
79  int relatedMCPDG;
80  if (mcpart)
81  relatedMCPDG = mcpart->getPDG();
82  else
83  relatedMCPDG = -1;
84 
85  // Start printing
86  B2INFO(" - " << "ROE related to particle with PDG: " << relatedPDG);
87  B2INFO(" - " << "ROE related to MC particle with PDG: " << relatedMCPDG);
88  B2INFO(" - " << "No. of Tracks in ROE: " << nAllTracks);
89  B2INFO(" - " << "No. of ECLClusters in ROE: " << nAllECLClusters);
90  B2INFO(" - " << "No. of KLMClusters in ROE: " << nAllKLMClusters);
91 
92  for (const auto& maskName : m_maskNames) {
93  unsigned int nTracks = roe->getNTracks(maskName);
94  unsigned int nECLClusters = roe->getNECLClusters(maskName);
95 
96 
97  B2INFO(" - " << "Info for ROEMask with name: \'" << maskName << "\'");
98 
99  B2INFO(" o) " << "No. of Tracks which pass the mask: " << nTracks);
100 
101  B2INFO(" o) " << "No. of ECLClusters which pass the mask: " << nECLClusters);
102  if (m_fullPrint) {
103  printMaskParticles(roe->getParticles(maskName));
104  }
105  }
106  } else
107  B2ERROR("RestOfEvent object not valid! Did you build ROE?");
108 
109  B2INFO("[RestOfEventPrinterModule] END ------------------------------------------");
110  }
111  void RestOfEventPrinterModule::printMaskParticles(const std::vector<const Particle*>& maskParticles) const
112  {
113  for (auto* particle : maskParticles) {
114  particle->print();
115  }
116  }
118 } // end Belle2 namespace
119 
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::RestOfEventPrinterModule
prints ROE information and masks to screen
Definition: RestOfEventPrinterModule.h:37
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::StoreObjPtr::isValid
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:120