 |
Belle II Software
release-05-01-25
|
13 #include <framework/core/Module.h>
14 #include <framework/datastore/StoreArray.h>
15 #include <simulation/background/BeamBGTypes.h>
16 #include <framework/dataobjects/BackgroundMetaData.h>
21 #include "TClonesArray.h"
36 class BeamBkgMixerModule :
public Module {
65 virtual void event()
override;
71 virtual void endRun()
override;
114 std::unique_ptr<TChain>
tree;
139 const std::string& bkgType,
140 const std::string& fileName,
162 template<
class SIMHIT>
164 TClonesArray* cloneArray,
169 if (!cloneArray)
return;
170 if (!simHits.
isValid())
return;
172 int numEntries = cloneArray->GetEntriesFast();
173 for (
int i = 0; i < numEntries; i++) {
174 SIMHIT* bkgSimHit =
static_cast<SIMHIT*
>(cloneArray->AddrAt(i));
175 SIMHIT* simHit = simHits.
appendNew(*bkgSimHit);
176 simHit->shiftInTime(timeShift);
177 if (simHit->getBackgroundTag() == 0)
180 double time = simHit->getGlobalTime();
181 if (time > maxTime) {
182 double windowSize = maxTime - minTime;
183 double shift = int((time - minTime) / windowSize) * windowSize;
184 simHit->shiftInTime(-shift);
201 double timeShift,
double minTime,
double maxTime)
206 if (!cloneArray)
return;
207 if (!hits.isValid())
return;
211 int numEntries = cloneArray->GetEntriesFast();
212 for (
int i = 0; i < numEntries; i++) {
213 HIT* bkgHit =
static_cast<HIT*
>(cloneArray->AddrAt(i));
215 if (!keep[bkgHit->getSubDet()])
continue;
216 HIT* hit = hits.appendNew(*bkgHit);
217 hit->shiftInTime(timeShift);
221 double time = hit->getTime();
222 if (time > maxTime) {
223 double windowSize = maxTime - minTime;
224 double shift = int((time - minTime) / windowSize) * windowSize;
225 hit->shiftInTime(-shift);
239 const std::string& component);
250 const std::string& bkgType,
251 const std::string& fileName,
T * appendNew()
Construct a new T object at the end of the array.
bool m_SVD
true if found in m_components
unsigned numFiles
number of files connected to TChain
void appendSample(BackgroundMetaData::BG_TAG bkgTag, const std::string &bkgType, const std::string &fileName, double realTime, BackgroundMetaData::EFileType fileTyp)
appends background sample to m_backgrounds
virtual ~BeamBkgMixerModule()
Destructor.
An input event buffer definition for background SimHits.
bool m_CDC
true if found in m_components
std::unique_ptr< TChain > tree
tree pointer
int m_rejectedCount
counter for suppresing "rejected event" messages
double m_maxTimeECL
maximal time shift of background event for ECL
BkgFiles()
default constructor
std::vector< BkgFiles > m_backgrounds
container for background samples
BeamBkgMixerModule()
Constructor.
BackgroundMetaData::BG_TAG tag
background tag
bool acceptEvent(TClonesArray *cloneArrayECL)
Checks for deposited energy of ECLHits and returns true if Edep < m_maxEdepECL.
TClonesArray * BKLM
BKLM SimHits from collision file.
BkgHits m_simHits
input event buffer
TClonesArray * EKLM
EKLM SimHits from collision file.
virtual void beginRun() override
Called when entering a new run.
TClonesArray * ECL
ECL SimHits from collision file.
double m_maxTimePXD
maximal time shift of background event for PXD
bool m_TOP
true if found in m_components
void addSimHits(StoreArray< SIMHIT > &simHits, TClonesArray *cloneArray, double timeShift, double minTime, double maxTime)
functions that add background SimHits to those in the DataStore
bool m_PXD
true if found in m_components
TClonesArray * CDC
CDC SimHits from collision file.
TClonesArray * ARICH
ARICH SimHits from collision file.
bool m_KLM
true if found in m_components
virtual void event() override
Event processor.
TClonesArray * SVD
SVD SimHits from collision file.
virtual void endRun() override
End-of-run action.
BkgHits()
default constructor
std::vector< std::tuple< std::string, double > > m_scaleFactors
scale factors
unsigned numEvents
number of events (tree entries) in the sample
TClonesArray * PXD
PXD SimHits from collision file.
double realTime
real time of BG samlpe
bool isComponentIncluded(std::vector< std::string > &components, const std::string &component)
Returns true if a component is found in components or the list is empty.
std::map< std::string, int > m_rejected
messages: rejected events
std::vector< std::string > m_components
detector components
unsigned eventCount
current event (tree entry)
Abstract base class for different kinds of events.
std::vector< std::string > fileNames
file names
virtual void initialize() override
Initialize the Module.
double m_maxTime
maximal time shift of background event
bool m_BeamBackHits
if true add also background hits
std::vector< std::string > m_backgroundFiles
names of beam background files
bool isValid() const
Check wether the array was registered.
std::map< std::string, int > m_reused
messages: rejused events
double m_minTimeECL
minimal time shift of background event for ECL
bool m_ARICH
true if found in m_components
Class to define BG types and to convert between BG types and tags or v.v.
double m_maxEdepECL
maximal allowed deposited energy in ECL
double m_minTime
minimal time shift of background event
double m_minTimePXD
minimal time shift of background event for PXD
unsigned index
index of this element in the std::vector
double scaleFactor
scale factor for the rate
double m_overallScaleFactor
overall scale factor
bool m_wrapAround
if true wrap around events in the tail after maxTime
bool m_ECL
true if found in m_components
Accessor to arrays stored in the data store.
BackgroundMetaData::EFileType fileType
file type
void addBeamBackHits(StoreArray< HIT > &hits, TClonesArray *cloneArray, double timeShift, double minTime, double maxTime)
functions that add BeamBackHits to those in the DataStore
std::string type
background type
int m_cacheSize
file cache size in Mbytes
virtual void terminate() override
Termination action.
TClonesArray * BeamBackHits
BeamBackHits from collision file.
TClonesArray * TOP
TOP SimHits from collision file.
double rate
background rate of the sample
background::BeamBGTypes m_bgTypes
defined BG types