Belle II Software  release-06-01-15
BGOverlayExecutorModule.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 include
10 #include <background/modules/BGOverlayExecutor/BGOverlayExecutorModule.h>
11 
12 // framework - DataStore
13 #include <framework/datastore/StoreObjPtr.h>
14 
15 // framework aux
16 #include <framework/logging/Logger.h>
17 
18 // detector Digits, Clusters or waveforms
19 #include <pxd/dataobjects/PXDDigit.h>
20 #include <svd/dataobjects/SVDShaperDigit.h>
21 #include <cdc/dataobjects/CDCHit.h>
22 #include <top/dataobjects/TOPDigit.h>
23 #include <arich/dataobjects/ARICHDigit.h>
24 #include <klm/dataobjects/KLMDigit.h>
25 #include <framework/dataobjects/BackgroundInfo.h>
26 
27 using namespace std;
28 
29 namespace Belle2 {
35  //-----------------------------------------------------------------
36  // Register module
37  //-----------------------------------------------------------------
38 
39  REG_MODULE(BGOverlayExecutor)
40 
41  //-----------------------------------------------------------------
42  // Implementation
43  //-----------------------------------------------------------------
44 
46 
47  {
48  // module description
49  setDescription("Overlay of measured background with simulated data");
50  setPropertyFlags(c_ParallelProcessingCertified);
51 
52  // Add parameters
53  addParam("bkgInfoName", m_BackgroundInfoInstanceName, "name of the BackgroundInfo StoreObjPtr", string(""));
54  addParam("PXDDigitsName", m_PXDDigitsName,
55  "name of PXD collection to overlay with BG", string(""));
56  addParam("SVDShaperDigitsName", m_SVDShaperDigitsName,
57  "name of SVD collection to overlay with BG", string(""));
58  addParam("CDCHitsName", m_CDCHitsName,
59  "name of CDC collection to overlay with BG", string(""));
60  addParam("TOPDigitsName", m_TOPDigitsName,
61  "name of TOP collection to overlay with BG", string(""));
62  addParam("ARICHDigitsName", m_ARICHDigitsName,
63  "name of ARICH collection to overlay with BG", string(""));
64  addParam("KLMDigitsName", m_KLMDigitsName,
65  "name of KLM collection to overlay with BG", string(""));
66  addParam("components", m_components,
67  "Detector components to be included in overlay (empty list means all)", m_components);
68  }
69 
70 
71  void BGOverlayExecutorModule::initialize()
72  {
73  // get name of extension that is used in BGOverlayInput for BG collections
74  StoreObjPtr<BackgroundInfo> bkgInfo(m_BackgroundInfoInstanceName, DataStore::c_Persistent);
75  if (bkgInfo.isValid()) {
76  if (bkgInfo->getMethod() == BackgroundInfo::c_Overlay) {
77  m_extensionName = bkgInfo->getExtensionName();
78  } else {
79  B2ERROR("BGOverlayExecutor: no BGOverlayInput module in the path");
80  }
81  } else {
82  B2ERROR("BGOverlayExecutor: no BGOverlayInput module in the path");
83  }
84 
85  // registration in datastore (all as optional input - see template function)
86  registerDigits<PXDDigit>(m_PXDDigitsName);
87  registerDigits<SVDShaperDigit>(m_SVDShaperDigitsName);
88  registerDigits<CDCHit>(m_CDCHitsName);
89  registerDigits<TOPDigit>(m_TOPDigitsName);
90  registerDigits<ARICHDigit>(m_ARICHDigitsName);
91  registerDigits<KLMDigit>(m_KLMDigitsName);
92 
93  // toggle ON the components from the list
94  if (m_components.empty()) {
95  m_addPXD = true;
96  m_addSVD = true;
97  m_addCDC = true;
98  m_addTOP = true;
99  m_addARICH = true;
100  m_addKLM = true;
101  } else {
102  for (const auto& component : m_components) {
103  if (component == "PXD") m_addPXD = true;
104  else if (component == "SVD") m_addSVD = true;
105  else if (component == "CDC") m_addCDC = true;
106  else if (component == "TOP") m_addTOP = true;
107  else if (component == "ARICH") m_addARICH = true;
108  else if (component == "ECL") continue; // not relevant - overlay implemented in ECLDigitizer
109  else if (component == "KLM") m_addKLM = true;
110  else B2ERROR("Unknown detector component '" << component << "'");
111  }
112  }
113 
114  }
115 
116 
117  void BGOverlayExecutorModule::event()
118  {
119  /* note: dataobject must inherit from DigitBase */
120 
121  if (m_addPXD) addBGDigits<PXDDigit>(m_PXDDigitsName);
122  if (m_addSVD) addBGDigits<SVDShaperDigit>(m_SVDShaperDigitsName);
123  if (m_addCDC) addBGDigits<CDCHit>(m_CDCHitsName);
124  if (m_addTOP) addBGDigits<TOPDigit>(m_TOPDigitsName);
125  if (m_addARICH) addBGDigits<ARICHDigit>(m_ARICHDigitsName);
126  //Compressed waveforms are loaded to the datastore by BGOverlayInputModule and unpacked and overlayed in ECLDigitizerModule
127  if (m_addKLM) addBGDigits<KLMDigit>(m_KLMDigitsName);
128  }
129 
131 } // end Belle2 namespace
132 
Overlay of measured background with simulated data (Digits or Clusters)
Base class for Modules.
Definition: Module.h:72
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:110
#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.