Belle II Software development
BeamBkgTagSetterModule.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 <background/modules/BeamBkgTagSetter/BeamBkgTagSetterModule.h>
11
12
13// framework - DataStore
14#include <framework/datastore/DataStore.h>
15#include <framework/datastore/StoreArray.h>
16#include <framework/datastore/StoreObjPtr.h>
17
18// framework aux
19#include <framework/logging/Logger.h>
20
21// MetaData
22#include <framework/dataobjects/EventMetaData.h>
23
24using namespace std;
25using namespace Belle2;
26
27//-----------------------------------------------------------------
28// Register module
29//-----------------------------------------------------------------
30
31REG_MODULE(BeamBkgTagSetter);
32
33//-----------------------------------------------------------------
34// Implementation
35//-----------------------------------------------------------------
36
39
40{
41 // set module description (e.g. insert text)
42 setDescription("Sets beam background tag variable in SimHits and "
43 "adds BackgroundMetaData branch in persistent tree; "
44 "returns true if at least one of the SimHit store arrays "
45 "has entries. Return value can be used to discard empty "
46 "events at output.");
47
48 // parallel processing certificate
50
51 // Add parameters
52 addParam("backgroundType", m_backgroundType,
53 "one of: " + m_bgTypes.getBGTypes());
54 addParam("realTime", m_realTime,
55 "equivalent time of superKEKB running in [ns] to obtain this sample");
56 addParam("specialFor", m_specialFor,
57 "tag ordinary file (default) or additional file ('ECL' or 'PXD')",
58 string(""));
59 addParam("Phase", m_phase,
60 "specify the Phase: 1 for Phase 1, 2 for Phase 2, 3 for Physics Run or Phase 3", 3);
61
62}
63
65{
66 if (m_realTime <= 0) B2FATAL("invalid realTime: " << m_realTime);
67
69 if (m_backgroundTag == 0) {
70 B2ERROR("Unknown beam background type: " << m_backgroundType << "\n"
71 "Possible are: " + m_bgTypes.getBGTypes());
73 }
74
75 if (m_specialFor != "") {
78 else {B2ERROR("specialFor " << m_specialFor << "not supported");}
79 }
80
81 // set BackgroundMetaData
83 bkgMetaData.registerInDataStore();
84 if (!bkgMetaData.isValid())
85 bkgMetaData.create();
86 bkgMetaData->setBackgroundType(m_backgroundType);
87 bkgMetaData->setBackgroundTag(m_backgroundTag);
88 bkgMetaData->setRealTime(m_realTime);
89 bkgMetaData->setFileType(m_fileType);
90
91 // registration of detector simHits
92 m_pxdSimHits.isOptional();
93 m_svdSimHits.isOptional();
94 m_cdcSimHits.isOptional();
95 m_topSimHits.isOptional();
96 m_arichSimHits.isOptional();
97 m_eclSimHits.isOptional();
98 m_eclHits.isOptional();
99 m_klmSimHits.isOptional();
100
101 // registration of beast simHits
102 m_diaSimHits.isOptional();
103 m_clw2SimHits.isOptional();
104 m_clw1SimHits.isOptional();
105 m_fngSimHits.isOptional();
106 m_plmSimHits.isOptional();
107 m_pinSimHits.isOptional();
108 m_he3SimHits.isOptional();
109 m_tpcSimHits.isOptional();
110 m_sciSimHits.isOptional();
111 m_bgoSimHits.isOptional();
112 m_csiSimHits.isOptional();
113}
114
116{
117 int n = 0;
118 if (m_phase == 2 || m_phase == 3) {
127 }
128 // BEAST addition
129 if (m_phase == 1 || m_phase == 2) {
131 if (m_phase == 1) {
135 }
136 if (m_phase == 2) {
140 }
145 }
146
147 if (m_fileType == BackgroundMetaData::c_ECL) n = m_eclHits.getEntries();
148 if (m_fileType == BackgroundMetaData::c_PXD) n = m_pxdSimHits.getEntries();
149
150 setReturnValue(n > 0);
151
152 StoreObjPtr<EventMetaData> evtMetaData;
153 B2INFO("Exp " << evtMetaData->getExperiment() <<
154 " Run " << evtMetaData->getRun() <<
155 " Event " << evtMetaData->getEvent() <<
156 " number of SimHits = " << n);
157
158}
Metadata information about the beam background file.
@ bg_other
Other type of background.
int setBackgroundTag(StoreArray< SIMHIT > &simHits)
functions that set background tag in SimHits
StoreArray< FANGSSimHit > m_fngSimHits
beast simulated hits
StoreArray< PindiodeSimHit > m_pinSimHits
beast simulated hits
int m_phase
Phase that corresponds to beam background sample.
StoreArray< BeamabortSimHit > m_diaSimHits
beast simulated hits
background::BeamBGTypes m_bgTypes
defined BG types
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
StoreArray< KLMSimHit > m_klmSimHits
KLM simulated hits.
StoreArray< PXDSimHit > m_pxdSimHits
PXD simulated hits.
BackgroundMetaData::EFileType m_fileType
file type to set
std::string m_specialFor
ordinary or special file for ECL, PXD
StoreArray< ECLSimHit > m_eclSimHits
ECL simulated hits.
StoreArray< CLAWSSimHit > m_clw2SimHits
beast simulated hits
StoreArray< ARICHSimHit > m_arichSimHits
ARICH simulated hits.
StoreArray< MicrotpcSimHit > m_tpcSimHits
beast simulated hits
double m_realTime
real time that corresponds to beam background sample
StoreArray< CDCSimHit > m_cdcSimHits
CDC simulated hits.
StoreArray< BgoSimHit > m_bgoSimHits
beast simulated hits
StoreArray< QcsmonitorSimHit > m_sciSimHits
beast simulated hits
StoreArray< ECLHit > m_eclHits
ECL simulated hits (short version)
StoreArray< CsiSimHit > m_csiSimHits
beast simulated hits
StoreArray< He3tubeSimHit > m_he3SimHits
beast simulated hits
BackgroundMetaData::BG_TAG m_backgroundTag
background tag to set (from BG type)
StoreArray< ClawSimHit > m_clw1SimHits
beast simulated hits
StoreArray< SVDSimHit > m_svdSimHits
SVD simulated hits.
StoreArray< TOPSimHit > m_topSimHits
TOP simulated hits.
StoreArray< PlumeSimHit > m_plmSimHits
beast simulated hits
@ c_Persistent
Object is available during entire execution time.
Definition DataStore.h:60
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
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition Module.cc:220
@ 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
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool create(bool replace=false)
Create a default object in the data store.
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
bool isValid() const
Check whether the object was created.
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.