18#include "CLHEP/Random/RandomEngine.h"
19#include "CLHEP/Random/RandFlat.h"
20#include "CLHEP/Random/RandGaussQ.h"
21#include "CLHEP/Random/RandPoissonQ.h"
25 const std::string& name,
26 const IInterface* parent) :
35 const ZdcID* zdcId =
nullptr;
36 if (detStore()->retrieve( zdcId ).isFailure() ) {
37 ATH_MSG_ERROR(
"execute: Could not retrieve ZdcID object from the detector store");
38 return StatusCode::FAILURE;
64 return StatusCode::SUCCESS;
123 CLHEP::HepRandomEngine* rngEngine = rngWrapper->
getEngine(ctx);
130 if (!hitCollection.
isValid()) {
131 ATH_MSG_ERROR(
"Could not get ZDC_SimFiberHit_Collection container " << hitCollection.
name() <<
" from store " << hitCollection.
store());
132 return StatusCode::FAILURE;
134 ATH_MSG_DEBUG(
"ZDC_SimFiberHitHitCollection found with " << hitCollection->size() <<
" hits");
146 moduleContainer->setStore( moduleAuxContainer.get() );
158 fillContainer(thpcZDC_Fiber, rngEngine, moduleContainer.get());
166 sumsContainer->setStore( sumsAuxContainer.get() );
169 for (
int iside : {-1, 0, 1}){
173 LucrodTriggerSideAmpAcc (*new_sum) = 42;
184 ATH_CHECK( moduleContainerH.record (std::move(moduleContainer), std::move(moduleAuxContainer)) );
187 ATH_CHECK( sumsContainerH.record (std::move(sumsContainer), std::move(sumsAuxContainer)) );
189 return StatusCode::SUCCESS;
194 ATH_MSG_DEBUG (
"ZDC_PileUpTool::prepareEvent() called for " << nInputEvents <<
" input events" );
207 return StatusCode::SUCCESS;
214 ATH_MSG_DEBUG (
"ZDC_PileUpTool::processBunchXing() " << bunchXing );
216 for (; iEvt!=eSubEvents; ++iEvt) {
219 <<
" bunch crossing : " << bunchXing
220 <<
" time offset : " << iEvt->time()
221 <<
" event number : " << iEvt->ptr()->eventNumber()
222 <<
" run number : " << iEvt->ptr()->runNumber());
227 ATH_MSG_ERROR (
"SubEvent ZDC_SimFiberHit_Collection not found in StoreGate " << seStore.name() );
228 return StatusCode::FAILURE;
230 ATH_MSG_DEBUG (
"ZDC_SimFiberHit_Collection found with " << tmpColl->
size() <<
" hits" );
238 return StatusCode::SUCCESS;
246 CLHEP::HepRandomEngine* rngEngine = rngWrapper->
getEngine(ctx);
252 return StatusCode::SUCCESS;
269 for (; it != itend; ++it) {
277 bool zdcFound[2][4] = {{}};
278 bool rpdFound[2][16] = {{}};
279 bool branFound[2] = {};
280 for(
auto module : *zdcModuleContainer){
281 int iside = (
module->zdcSide() == -1) ? 0 : 1;
282 int mod =
module->zdcModule();
284 zdcFound[iside][mod] =
true;
285 ATH_MSG_DEBUG(
"ZDC_PileUpTool::addEmptyWaveforms Found ZDC side " << module->zdcSide() <<
" module " << mod);
287 rpdFound[iside][module->zdcChannel()] =
true;
288 ATH_MSG_DEBUG(
"ZDC_PileUpTool::addEmptyWaveforms Found RPD side " << module->zdcSide() <<
" channel " << module->zdcChannel());
290 branFound[iside] =
true;
291 ATH_MSG_DEBUG(
"ZDC_PileUpTool::addEmptyWaveforms Found BRAN side " << module->zdcSide() );
295 for(
int iside : {0,1}){
296 int side = (iside == 0) ? -1 : 1;
297 for(
int mod = 0; mod < 4; mod++){
298 if(!zdcFound[iside][mod]){
299 ATH_MSG_DEBUG(
"ZDC_PileUpTool::addEmptyWaveforms Creating empty waveform for ZDC side " << side <<
" module " << mod);
303 for(
int channel = 0; channel < 16; channel++){
304 if(!rpdFound[iside][channel] &&
m_doRPD){
305 ATH_MSG_DEBUG(
"ZDC_PileUpTool::addEmptyWaveforms Creating empty waveform for RPD side " << side <<
" channel " << channel);
310 ATH_MSG_DEBUG(
"ZDC_PileUpTool::addEmptyWaveforms Creating empty waveform for BRAN side " << side );
324 int side = (
m_ZdcID->side(
id ) < 0 ) ? 0 : 1;
325 int module =
m_ZdcID->module(
id );
329 newCollection->
Insert(hit);
337 if(!newHits[side][module]){
348 for(
int side : {0,1}){
349 for(
int module = 0;
module < 4;
module++){
352 if(newHits[side][module]){
353 newCollection->Insert(*(newHits[side][module]));
360 newTimedCollection.
insert(0.0, newCollection);
362 return newTimedCollection;
369 int module =
m_ZdcID->module(
id);
370 int channel =
m_ZdcID->channel(
id);
372 if(module == 4 && !
m_doRPD)
return;
373 if(module == 5 && !
m_doBRAN)
return;
382 zdcModuleContainer->
back()->setZdcId(
id.get_identifier32().get_compact());
383 zdcModuleContainer->
back()->setZdcSide(side);
384 zdcModuleContainer->
back()->setZdcModule(module);
385 zdcModuleContainer->
back()->setZdcType(
m_ZdcID->type(
id));
386 zdcModuleContainer->
back()->setZdcChannel(channel);
389 " Module " << module <<
390 " Channel " << channel <<
393 uint iSide = (side == -1) ? 0 : 1;
394 float amplitude = 0,
t0 = 0;
395 bool doHighGain =
true;
396 std::shared_ptr<ZDCWaveformBase> waveformPtr;
397 std::shared_ptr<ZDCWaveformSampler> wfSampler;
437 std::vector<unsigned int> wf = wfSampler->Generate(amplitude,
t0);
438 std::vector<short unsigned int> retVal;
439 for(
uint sample = 0; sample < wf.size(); sample++){
440 retVal.push_back(wf[sample]);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
Helper class to provide type-safe access to aux data.
the preferred mechanism to access information from the different event stores in a pileup job.
ZDC_SimFiberHit_Collection::const_iterator ZDC_SimFiberHit_ConstIterator
std::string ZdcModuleToString(const xAOD::ZdcModule &zm)
A wrapper class for event-slot-local random engines.
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
CONT::const_iterator const_iterator
const_iterator begin() const
const_iterator end() const
const T * back() const
Access the last element in the collection as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
std::unique_ptr< base_value_type > unique_type
Helper class to provide type-safe access to aux data.
SG::Accessor< T, ALLOC > Accessor
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
std::string store() const
Return the name of the store holding the object we are proxying.
const std::string & name() const
Return the StoreGate ID for the referenced object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
The Athena Transient Store API.
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
bool nextDetectorElement(const_iterator &b, const_iterator &e)
sets an iterator range with the hits of current detector element returns a bool when done
TimedVector::const_iterator const_iterator
void insert(const PileUpTimeEventIndex &timeEventIndex, const AtlasHitsVector< HIT > *inputCollection)
void Add(int nphot, double edep)
void setWaveform(const std::string &, const std::vector< uint16_t > &)
void efficiency(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
ZdcModuleContainer_v1 ZdcModuleContainer
ZdcModuleAuxContainer_v2 ZdcModuleAuxContainer