Belle II Software  release-08-01-10
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 
24 using namespace std;
25 using namespace Belle2;
26 
27 //-----------------------------------------------------------------
28 // Register module
29 //-----------------------------------------------------------------
30 
31 REG_MODULE(BeamBkgTagSetter);
32 
33 //-----------------------------------------------------------------
34 // Implementation
35 //-----------------------------------------------------------------
36 
37 BeamBkgTagSetterModule::BeamBkgTagSetterModule() : Module(),
38  m_backgroundTag(BackgroundMetaData::bg_none), m_fileType(BackgroundMetaData::c_Usual)
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 }
67 
69 {
70  if (m_realTime <= 0) B2FATAL("invalid realTime: " << m_realTime);
71 
73  if (m_backgroundTag == 0) {
74  B2ERROR("Unknown beam background type: " << m_backgroundType << "\n"
75  "Possible are: " + m_bgTypes.getBGTypes());
77  }
78 
79  if (m_specialFor != "") {
81  else if (m_specialFor == "PXD") {m_fileType = BackgroundMetaData::c_PXD;}
82  else {B2ERROR("specialFor " << m_specialFor << "not supported");}
83  }
84 
85  // set BackgroundMetaData
87  bkgMetaData.registerInDataStore();
88  if (!bkgMetaData.isValid())
89  bkgMetaData.create();
90  bkgMetaData->setBackgroundType(m_backgroundType);
91  bkgMetaData->setBackgroundTag(m_backgroundTag);
92  bkgMetaData->setRealTime(m_realTime);
93  bkgMetaData->setFileType(m_fileType);
94 
95  // registration of detector simHits
96  m_pxdSimHits.isOptional();
97  m_svdSimHits.isOptional();
98  m_cdcSimHits.isOptional();
99  m_topSimHits.isOptional();
100  m_arichSimHits.isOptional();
101  m_eclSimHits.isOptional();
102  m_eclHits.isOptional();
103  m_klmSimHits.isOptional();
104 
105  // registration of beast simHits
106  m_diaSimHits.isOptional();
107  m_clw2SimHits.isOptional();
108  m_clw1SimHits.isOptional();
109  m_fngSimHits.isOptional();
110  m_plmSimHits.isOptional();
111  m_pinSimHits.isOptional();
112  m_he3SimHits.isOptional();
113  m_tpcSimHits.isOptional();
114  m_sciSimHits.isOptional();
115  m_bgoSimHits.isOptional();
116  m_csiSimHits.isOptional();
117 }
118 
120 {
121 }
122 
124 {
125  int n = 0;
126  if (m_phase == 2 || m_phase == 3) {
135  }
136  // BEAST addition
137  if (m_phase == 1 || m_phase == 2) {
139  if (m_phase == 1) {
143  }
144  if (m_phase == 2) {
148  }
153  }
154 
155  if (m_fileType == BackgroundMetaData::c_ECL) n = m_eclHits.getEntries();
156  if (m_fileType == BackgroundMetaData::c_PXD) n = m_pxdSimHits.getEntries();
157 
158  setReturnValue(n > 0);
159 
160  StoreObjPtr<EventMetaData> evtMetaData;
161  B2INFO("Exp " << evtMetaData->getExperiment() <<
162  " Run " << evtMetaData->getRun() <<
163  " Event " << evtMetaData->getEvent() <<
164  " number of SimHits = " << n);
165 
166 }
167 
168 
170 {
171 }
172 
174 {
175 }
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
virtual void endRun() override
End-of-run action.
std::string m_specialFor
ordinary or special file for ECL, PXD
virtual void terminate() override
Termination action.
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
virtual ~BeamBkgTagSetterModule()
Destructor.
double m_realTime
real time that corresponds to beam background sample
StoreArray< CDCSimHit > m_cdcSimHits
CDC simulated hits.
virtual void beginRun() override
Called when entering a new run.
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
Base class for Modules.
Definition: Module.h:72
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
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.
Definition: StoreObjPtr.h:111
std::string getBGTypes() const
Return all defined BG types as a string.
Definition: BeamBGTypes.h:111
BackgroundMetaData::BG_TAG getTag(const std::string &bgType)
Return BG tag for a given BG type.
Definition: BeamBGTypes.h:74
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:560
#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.