10 #include <background/modules/BeamBkgTagSetter/BeamBkgTagSetterModule.h>
14 #include <framework/datastore/DataStore.h>
15 #include <framework/datastore/StoreArray.h>
16 #include <framework/datastore/StoreObjPtr.h>
19 #include <framework/logging/Logger.h>
22 #include <framework/dataobjects/EventMetaData.h>
47 setDescription(
"Sets beam background tag variable in SimHits and "
48 "adds BackgroundMetaData branch in persistent tree; "
49 "returns true if at least one of the SimHit store arrays "
50 "has entries. Return value can be used to discard empty "
54 setPropertyFlags(c_ParallelProcessingCertified);
57 addParam(
"backgroundType", m_backgroundType,
58 "one of: " + m_bgTypes.getBGTypes());
59 addParam(
"realTime", m_realTime,
60 "equivalent time of superKEKB running in [ns] to obtain this sample");
61 addParam(
"specialFor", m_specialFor,
62 "tag ordinary file (default) or additional file ('ECL' or 'PXD')",
64 addParam(
"Phase", m_phase,
65 "specify the Phase: 1 for Phase 1, 2 for Phase 2, 3 for Physics Run or Phase 3", 3);
69 BeamBkgTagSetterModule::~BeamBkgTagSetterModule()
73 void BeamBkgTagSetterModule::initialize()
75 if (m_realTime <= 0) B2FATAL(
"invalid realTime: " << m_realTime);
77 m_backgroundTag = m_bgTypes.getTag(m_backgroundType);
78 if (m_backgroundTag == 0) {
79 B2ERROR(
"Unknown beam background type: " << m_backgroundType <<
"\n"
80 "Possible are: " + m_bgTypes.getBGTypes());
81 m_backgroundTag = BackgroundMetaData::bg_other;
84 if (m_specialFor !=
"") {
85 if (m_specialFor ==
"ECL") {m_fileType = BackgroundMetaData::c_ECL;}
86 else if (m_specialFor ==
"PXD") {m_fileType = BackgroundMetaData::c_PXD;}
87 else {B2ERROR(
"specialFor " << m_specialFor <<
"not supported");}
95 bkgMetaData->setBackgroundType(m_backgroundType);
96 bkgMetaData->setBackgroundTag(m_backgroundTag);
97 bkgMetaData->setRealTime(m_realTime);
98 bkgMetaData->setFileType(m_fileType);
102 m_svdSimHits.isOptional();
103 m_cdcSimHits.isOptional();
104 m_topSimHits.isOptional();
105 m_arichSimHits.isOptional();
106 m_eclSimHits.isOptional();
107 m_eclHits.isOptional();
108 m_bklmSimHits.isOptional();
109 m_eklmSimHits.isOptional();
112 m_diaSimHits.isOptional();
113 m_clw2SimHits.isOptional();
114 m_clw1SimHits.isOptional();
115 m_fngSimHits.isOptional();
116 m_plmSimHits.isOptional();
117 m_pinSimHits.isOptional();
118 m_he3SimHits.isOptional();
119 m_tpcSimHits.isOptional();
120 m_sciSimHits.isOptional();
121 m_bgoSimHits.isOptional();
122 m_csiSimHits.isOptional();
125 void BeamBkgTagSetterModule::beginRun()
129 void BeamBkgTagSetterModule::event()
132 if (m_phase == 2 || m_phase == 3) {
133 n += setBackgroundTag(m_pxdSimHits);
134 n += setBackgroundTag(m_svdSimHits);
135 n += setBackgroundTag(m_cdcSimHits);
136 n += setBackgroundTag(m_topSimHits);
137 n += setBackgroundTag(m_arichSimHits);
138 n += setBackgroundTag(m_eclSimHits);
139 n += setBackgroundTag(m_eclHits);
140 n += setBackgroundTag(m_bklmSimHits);
141 n += setBackgroundTag(m_eklmSimHits);
144 if (m_phase == 1 || m_phase == 2) {
145 n += setBackgroundTag(m_diaSimHits);
147 n += setBackgroundTag(m_clw1SimHits);
148 n += setBackgroundTag(m_csiSimHits);
149 n += setBackgroundTag(m_bgoSimHits);
152 n += setBackgroundTag(m_clw2SimHits);
153 n += setBackgroundTag(m_fngSimHits);
154 n += setBackgroundTag(m_plmSimHits);
156 n += setBackgroundTag(m_pinSimHits);
157 n += setBackgroundTag(m_he3SimHits);
158 n += setBackgroundTag(m_tpcSimHits);
159 n += setBackgroundTag(m_sciSimHits);
162 if (m_fileType == BackgroundMetaData::c_ECL) n = m_eclHits.getEntries();
163 if (m_fileType == BackgroundMetaData::c_PXD) n = m_pxdSimHits.getEntries();
165 setReturnValue(n > 0);
168 B2INFO(
"Exp " << evtMetaData->getExperiment() <<
169 " Run " << evtMetaData->getRun() <<
170 " Event " << evtMetaData->getEvent() <<
171 " number of SimHits = " << n);
176 void BeamBkgTagSetterModule::endRun()
180 void BeamBkgTagSetterModule::terminate()
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
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.
bool isValid() const
Check whether the object was created.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.