Belle II Software  release-05-02-19
BGOverlayExecutorModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 // Own include
12 #include <background/modules/BGOverlayExecutor/BGOverlayExecutorModule.h>
13 
14 // framework - DataStore
15 #include <framework/datastore/DataStore.h>
16 #include <framework/datastore/StoreArray.h>
17 #include <framework/datastore/StoreObjPtr.h>
18 
19 // framework aux
20 #include <framework/logging/Logger.h>
21 
22 // detector Digits, Clusters or waveforms
23 #include <pxd/dataobjects/PXDDigit.h>
24 #include <svd/dataobjects/SVDShaperDigit.h>
25 #include <cdc/dataobjects/CDCHit.h>
26 #include <top/dataobjects/TOPDigit.h>
27 #include <arich/dataobjects/ARICHDigit.h>
28 #include <klm/dataobjects/KLMDigit.h>
29 #include <framework/dataobjects/BackgroundInfo.h>
30 
31 using namespace std;
32 
33 namespace Belle2 {
39  //-----------------------------------------------------------------
40  // Register module
41  //-----------------------------------------------------------------
42 
43  REG_MODULE(BGOverlayExecutor)
44 
45  //-----------------------------------------------------------------
46  // Implementation
47  //-----------------------------------------------------------------
48 
50 
51  {
52  // module description
53  setDescription("Overlay of measured background with simulated data");
54  setPropertyFlags(c_ParallelProcessingCertified);
55 
56  // Add parameters
57  addParam("bkgInfoName", m_BackgroundInfoInstanceName, "name of the BackgroundInfo StoreObjPtr", string(""));
58  addParam("PXDDigitsName", m_PXDDigitsName,
59  "name of PXD collection to overlay with BG", string(""));
60  addParam("SVDShaperDigitsName", m_SVDShaperDigitsName,
61  "name of SVD collection to overlay with BG", string(""));
62  addParam("CDCHitsName", m_CDCHitsName,
63  "name of CDC collection to overlay with BG", string(""));
64  addParam("TOPDigitsName", m_TOPDigitsName,
65  "name of TOP collection to overlay with BG", string(""));
66  addParam("ARICHDigitsName", m_ARICHDigitsName,
67  "name of ARICH collection to overlay with BG", string(""));
68  addParam("KLMDigitsName", m_KLMDigitsName,
69  "name of KLM collection to overlay with BG", string(""));
70 
71  }
72 
73  BGOverlayExecutorModule::~BGOverlayExecutorModule()
74  {
75  }
76 
77  void BGOverlayExecutorModule::initialize()
78  {
79  // get name of extension that is used in BGOverlayInput for BG collections
80  StoreObjPtr<BackgroundInfo> bkgInfo(m_BackgroundInfoInstanceName, DataStore::c_Persistent);
81  if (bkgInfo.isValid()) {
82  if (bkgInfo->getMethod() == BackgroundInfo::c_Overlay) {
83  m_extensionName = bkgInfo->getExtensionName();
84  } else {
85  B2ERROR("BGOverlayExecutor: no BGOverlayInput module in the path");
86  }
87  } else {
88  B2ERROR("BGOverlayExecutor: no BGOverlayInput module in the path");
89  }
90 
91  // registration in datastore (all as optional input - see template function)
92  registerDigits<PXDDigit>(m_PXDDigitsName);
93  registerDigits<SVDShaperDigit>(m_SVDShaperDigitsName);
94  registerDigits<CDCHit>(m_CDCHitsName);
95  registerDigits<TOPDigit>(m_TOPDigitsName);
96  registerDigits<ARICHDigit>(m_ARICHDigitsName);
97  registerDigits<KLMDigit>(m_KLMDigitsName);
98 
99  }
100 
101  void BGOverlayExecutorModule::beginRun()
102  {
103  }
104 
105  void BGOverlayExecutorModule::event()
106  {
107  /* note: dataobject must inherit from DigitBase */
108 
109  addBGDigits<PXDDigit>(m_PXDDigitsName);
110  addBGDigits<SVDShaperDigit>(m_SVDShaperDigitsName);
111  addBGDigits<CDCHit>(m_CDCHitsName);
112  addBGDigits<TOPDigit>(m_TOPDigitsName);
113  addBGDigits<ARICHDigit>(m_ARICHDigitsName);
114  //Compressed waveforms are loaded to the datastore by BGOverlayInputModule and unpacked and overlayed in ECLDigitizerModule
115  addBGDigits<KLMDigit>(m_KLMDigitsName);
116 
117  }
118 
119 
120  void BGOverlayExecutorModule::endRun()
121  {
122  }
123 
124  void BGOverlayExecutorModule::terminate()
125  {
126  }
127 
128 
130 } // end Belle2 namespace
131 
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
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::BGOverlayExecutorModule
Overlay of measured background with simulated data (Digits or Clusters)
Definition: BGOverlayExecutorModule.h:39
Belle2::StoreObjPtr::isValid
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:120