11#include <framework/core/Module.h>
12#include <framework/datastore/StoreArray.h>
13#include <simulation/background/BeamBGTypes.h>
14#include <framework/dataobjects/BackgroundMetaData.h>
19#include "TClonesArray.h"
60 virtual void event()
override;
66 virtual void endRun()
override;
133 const std::string& bkgType,
134 const std::string& fileName,
156 template<
class SIMHIT>
158 TClonesArray* cloneArray,
163 if (!cloneArray)
return;
164 if (!simHits.
isValid())
return;
166 int numEntries = cloneArray->GetEntriesFast();
167 for (
int i = 0; i < numEntries; i++) {
168 SIMHIT* bkgSimHit =
static_cast<SIMHIT*
>(cloneArray->AddrAt(i));
169 SIMHIT* simHit = simHits.
appendNew(*bkgSimHit);
170 simHit->shiftInTime(timeShift);
171 if (simHit->getBackgroundTag() == 0)
174 double time = simHit->getGlobalTime();
175 if (time > maxTime) {
176 double windowSize = maxTime - minTime;
177 double shift = int((time - minTime) / windowSize) * windowSize;
178 simHit->shiftInTime(-shift);
195 double timeShift,
double minTime,
double maxTime)
199 if (!cloneArray)
return;
200 if (!hits.isValid())
return;
204 int numEntries = cloneArray->GetEntriesFast();
205 for (
int i = 0; i < numEntries; i++) {
206 HIT* bkgHit =
static_cast<HIT*
>(cloneArray->AddrAt(i));
208 if (!keep[bkgHit->getSubDet()])
continue;
209 HIT* hit = hits.appendNew(*bkgHit);
210 hit->shiftInTime(timeShift);
214 double time = hit->getTime();
215 if (time > maxTime) {
216 double windowSize = maxTime - minTime;
217 double shift = int((time - minTime) / windowSize) * windowSize;
218 hit->shiftInTime(-shift);
232 const std::string& component);
243 const std::string& bkgType,
244 const std::string& fileName,
New beam background mixer; this one doesn't need ROF files.
std::map< std::string, int > m_reused
messages: rejused events
double m_maxEdepECL
maximal allowed deposited energy in ECL
std::vector< BkgFiles > m_backgrounds
container for background samples
virtual ~BeamBkgMixerModule()
Destructor.
double m_maxTimeECL
maximal time shift of background event for ECL
std::map< std::string, int > m_rejected
messages: rejected events
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.
bool m_ECL
true if found in m_components
std::vector< std::string > m_components
detector components
void addBeamBackHits(StoreArray< HIT > &hits, TClonesArray *cloneArray, double timeShift, double minTime, double maxTime)
functions that add BeamBackHits to those in the DataStore
double m_minTimePXD
minimal time shift of background event for PXD
bool m_PXD
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
background::BeamBGTypes m_bgTypes
defined BG types
std::vector< std::string > m_backgroundFiles
names of beam background files
virtual void initialize() override
Initialize the Module.
bool m_CDC
true if found in m_components
double m_maxTime
maximal time shift of background event
virtual void event() override
Event processor.
double m_minTime
minimal time shift of background event
bool m_wrapAround
if true wrap around events in the tail after maxTime
virtual void endRun() override
End-of-run action.
double m_maxTimePXD
maximal time shift of background event for PXD
int m_rejectedCount
counter for suppresing "rejected event" messages
virtual void terminate() override
Termination action.
BkgHits m_simHits
input event buffer
int m_cacheSize
file cache size in Mbytes
bool m_BeamBackHits
if true add also background hits
virtual void beginRun() override
Called when entering a new run.
bool m_ARICH
true if found in m_components
double m_overallScaleFactor
overall scale factor
BeamBkgMixerModule()
Constructor.
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
bool acceptEvent(TClonesArray *cloneArrayECL)
Checks for deposited energy of ECLHits and returns true if Edep < m_maxEdepECL.
double m_minTimeECL
minimal time shift of background event for ECL
std::vector< std::tuple< std::string, double > > m_scaleFactors
scale factors
bool m_KLM
true if found in m_components
bool m_SVD
true if found in m_components
bool m_TOP
true if found in m_components
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
bool isValid() const
Check wether the array was registered.
Class to define BG types and to convert between BG types and tags or v.v.
Abstract base class for different kinds of events.
structure to hold samples of a particular background type
std::vector< std::string > fileNames
file names
unsigned index
index of this element in the std::vector
double rate
background rate of the sample
std::unique_ptr< TChain > tree
tree pointer
BkgFiles(BackgroundMetaData::BG_TAG bkgTag, const std::string &bkgType, const std::string &fileName, double time, double scaleFac, BackgroundMetaData::EFileType fileTyp=BackgroundMetaData::c_Usual, unsigned indx=0)
usefull constructor
BackgroundMetaData::BG_TAG tag
background tag
std::string type
background type
double scaleFactor
scale factor for the rate
double realTime
real time of BG samlpe
unsigned numEvents
number of events (tree entries) in the sample
unsigned numFiles
number of files connected to TChain
BkgFiles()
default constructor
BackgroundMetaData::EFileType fileType
file type
unsigned eventCount
current event (tree entry)
An input event buffer definition for background SimHits.
BkgHits()
default constructor
TClonesArray * BeamBackHits
BeamBackHits from collision file.
TClonesArray * KLM
KLM SimHits from collision file.
TClonesArray * ARICH
ARICH SimHits from collision file.
TClonesArray * CDC
CDC SimHits from collision file.
TClonesArray * PXD
PXD SimHits from collision file.
TClonesArray * ECL
ECL SimHits from collision file.
TClonesArray * SVD
SVD SimHits from collision file.
TClonesArray * TOP
TOP SimHits from collision file.