File indexing completed on 2025-01-18 09:14:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DD4hep/InstanceCount.h>
0016 #include <DDDigi/DigiKernel.h>
0017 #include <DDDigi/DigiSegmentation.h>
0018 #include <DDDigi/noise/DigiSignalProcessorSequence.h>
0019
0020
0021 #include <stdexcept>
0022
0023 using namespace dd4hep::digi;
0024
0025 template <> void
0026 DigiParallelWorker<DigiSignalProcessor,
0027 DigiSignalProcessorSequence::CallData,
0028 int>::execute(void* data) const {
0029 calldata_t* args = reinterpret_cast<calldata_t*>(data);
0030 args->value += (*action)(args->context);
0031 }
0032
0033
0034 DigiSignalProcessorSequence::DigiSignalProcessorSequence(const DigiKernel& kernel, const std::string& nam)
0035 : DigiSignalProcessor(kernel, nam)
0036 {
0037 InstanceCount::increment(this);
0038 }
0039
0040
0041 DigiSignalProcessorSequence::~DigiSignalProcessorSequence() {
0042 InstanceCount::decrement(this);
0043 }
0044
0045
0046 void DigiSignalProcessorSequence::adopt(DigiSignalProcessor* action) {
0047 if (action) {
0048 m_actors.insert(new Worker(action, 0));
0049 return;
0050 }
0051 except("DigiSignalProcessorSequence","++ Attempt to add invalid actor!");
0052 }
0053
0054
0055 double DigiSignalProcessorSequence::operator()(DigiCellContext& context) const {
0056 CallData args { context, 0e0 };
0057 double result = context.data.signal;
0058 auto group = m_actors.get_group();
0059 for ( const auto* p : group.actors() ) {
0060 args.value = 0e0;
0061 p->execute(&args);
0062 result += args.value;
0063 }
0064 return context.data.kill ? 0e0 : result;
0065 }