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;
137 const std::string& bkgType,
138 const std::string& fileName,
160 template<
class SIMHIT>
162 TClonesArray* cloneArray,
167 if (!cloneArray)
return;
168 if (!simHits.
isValid())
return;
170 int numEntries = cloneArray->GetEntriesFast();
171 for (
int i = 0; i < numEntries; i++) {
172 SIMHIT* bkgSimHit =
static_cast<SIMHIT*
>(cloneArray->AddrAt(i));
173 SIMHIT* simHit = simHits.
appendNew(*bkgSimHit);
174 simHit->shiftInTime(timeShift);
175 if (simHit->getBackgroundTag() == 0)
178 double time = simHit->getGlobalTime();
179 if (time > maxTime) {
180 double windowSize = maxTime - minTime;
181 double shift = int((time - minTime) / windowSize) * windowSize;
182 simHit->shiftInTime(-shift);
199 double timeShift,
double minTime,
double maxTime)
204 if (!cloneArray)
return;
205 if (!hits.isValid())
return;
209 int numEntries = cloneArray->GetEntriesFast();
210 for (
int i = 0; i < numEntries; i++) {
211 HIT* bkgHit =
static_cast<HIT*
>(cloneArray->AddrAt(i));
213 if (!keep[bkgHit->getSubDet()])
continue;
214 HIT* hit = hits.appendNew(*bkgHit);
215 hit->shiftInTime(timeShift);
219 double time = hit->getTime();
220 if (time > maxTime) {
221 double windowSize = maxTime - minTime;
222 double shift = int((time - minTime) / windowSize) * windowSize;
223 hit->shiftInTime(-shift);
237 const std::string& component);
248 const std::string& bkgType,
249 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
double m_maxTimeECL
maximal time shift of background event for ECL
std::map< std::string, int > m_rejected
messages: rejected events
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
bool m_CDC
true if found in m_components
double m_maxTime
maximal time shift of background event
double m_minTime
minimal time shift of background event
bool m_wrapAround
if true wrap around events in the tail after maxTime
double m_maxTimePXD
maximal time shift of background event for PXD
int m_rejectedCount
counter for suppresing "rejected event" messages
BkgHits m_simHits
input event buffer
int m_cacheSize
file cache size in Mbytes
bool m_BeamBackHits
if true add also background hits
bool m_ARICH
true if found in m_components
double m_overallScaleFactor
overall scale factor
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.
virtual ~BeamBkgMixerModule()
Destructor.
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.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void endRun() override
End-of-run action.
virtual void terminate() override
Termination action.
virtual void beginRun() override
Called when entering a new run.
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.
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 * ARICH
ARICH SimHits from collision file.
TClonesArray * BKLM
BKLM 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 * EKLM
EKLM SimHits from collision file.
TClonesArray * TOP
TOP SimHits from collision file.