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"
63 virtual void event()
override;
69 virtual void endRun()
override;
136 const std::string& bkgType,
137 const std::string& fileName,
159 template<
class SIMHIT>
161 TClonesArray* cloneArray,
166 if (!cloneArray)
return;
167 if (!simHits.
isValid())
return;
169 int numEntries = cloneArray->GetEntriesFast();
170 for (
int i = 0; i < numEntries; i++) {
171 SIMHIT* bkgSimHit =
static_cast<SIMHIT*
>(cloneArray->AddrAt(i));
172 SIMHIT* simHit = simHits.
appendNew(*bkgSimHit);
173 simHit->shiftInTime(timeShift);
174 if (simHit->getBackgroundTag() == 0)
177 double time = simHit->getGlobalTime();
178 if (time > maxTime) {
179 double windowSize = maxTime - minTime;
180 double shift = int((time - minTime) / windowSize) * windowSize;
181 simHit->shiftInTime(-shift);
198 double timeShift,
double minTime,
double maxTime)
202 if (!cloneArray)
return;
203 if (!hits.isValid())
return;
207 int numEntries = cloneArray->GetEntriesFast();
208 for (
int i = 0; i < numEntries; i++) {
209 HIT* bkgHit =
static_cast<HIT*
>(cloneArray->AddrAt(i));
211 if (!keep[bkgHit->getSubDet()])
continue;
212 HIT* hit = hits.appendNew(*bkgHit);
213 hit->shiftInTime(timeShift);
217 double time = hit->getTime();
218 if (time > maxTime) {
219 double windowSize = maxTime - minTime;
220 double shift = int((time - minTime) / windowSize) * windowSize;
221 hit->shiftInTime(-shift);
235 const std::string& component);
246 const std::string& bkgType,
247 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.