ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
ZDCTriggerSimFADC Class Reference

#include <ZDCTriggerSim.h>

Inheritance diagram for ZDCTriggerSimFADC:
Collaboration diagram for ZDCTriggerSimFADC:

Public Member Functions

 ZDCTriggerSimFADC (const std::array< unsigned int, 4096 > &sideALUT, const std::array< unsigned int, 4096 > &sideCLUT, const std::array< unsigned int, 256 > &inCombLUT, const std::array< std::array< unsigned int, 4 >, 2 > &negDeriv2ndThresh, unsigned int minSampleAna, unsigned int maxSampleAna, unsigned int baselineDelta)
 
virtual unsigned int simLevel1Trig (const ZDCTriggerSim::SimDataCPtr &inputData) override
 
auto getMaxNegDeriv2nds () const
 
auto getMaxADCs () const
 
auto getBaselines () const
 
SimStack::const_iterator stackBottom () const
 
SimStack::const_reverse_iterator stackTop () const
 
void dump (std::ostream &strm) const
 

Protected Member Functions

virtual void doSimStage () override
 
std::vector< unsigned int > CalculateNeg2ndDerivatives (const std::vector< unsigned int > &samples, unsigned int step)
 
void stackClear ()
 
void stackPush (const ZDCTriggerSim::SimDataCPtr &ptr)
 
const ZDCTriggerSim::SimDataCPtrstackTopData () const
 

Private Types

typedef std::list< ZDCTriggerSim::SimDataCPtrSimStack
 

Private Attributes

std::array< std::array< unsigned int, 4 >, 2 > m_deriv2ndThresholds
 
unsigned int m_minSampleAna {}
 
unsigned int m_maxSampleAna {}
 
unsigned int m_baselineDelta {}
 
std::array< std::array< int, 4 >, 2 > m_maxNegDeriv2nd {}
 
std::array< std::array< unsigned int, 4 >, 2 > m_maxADC {}
 
std::array< std::array< unsigned int, 4 >, 2 > m_baseline {}
 
SimStack m_stack
 
std::array< unsigned int, 4096 > m_LUTA {}
 
std::array< unsigned int, 4096 > m_LUTC {}
 
std::array< unsigned int, 256 > m_combLUT {}
 

Detailed Description

Definition at line 304 of file ZDCTriggerSim.h.

Member Typedef Documentation

◆ SimStack

typedef std::list<ZDCTriggerSim::SimDataCPtr> ZDCTriggerSimBase::SimStack
privateinherited

Definition at line 181 of file ZDCTriggerSim.h.

Constructor & Destructor Documentation

◆ ZDCTriggerSimFADC()

ZDCTriggerSimFADC::ZDCTriggerSimFADC ( const std::array< unsigned int, 4096 > &  sideALUT,
const std::array< unsigned int, 4096 > &  sideCLUT,
const std::array< unsigned int, 256 > &  inCombLUT,
const std::array< std::array< unsigned int, 4 >, 2 > &  negDeriv2ndThresh,
unsigned int  minSampleAna,
unsigned int  maxSampleAna,
unsigned int  baselineDelta 
)
inline

Definition at line 328 of file ZDCTriggerSim.h.

332  :
333  ZDCTriggerSimModuleAmpls(sideALUT, sideCLUT, inCombLUT),
334  m_deriv2ndThresholds(negDeriv2ndThresh),
335  m_minSampleAna(minSampleAna),
336  m_maxSampleAna(maxSampleAna),
337  m_baselineDelta(baselineDelta)
338  {}

Member Function Documentation

◆ CalculateNeg2ndDerivatives()

std::vector< unsigned int > ZDCTriggerSimFADC::CalculateNeg2ndDerivatives ( const std::vector< unsigned int > &  samples,
unsigned int  step 
)
protected

Definition at line 193 of file ZDCTriggerSim.cxx.

194 {
195  std::vector<unsigned int> der2ndVec(step, 0);
196 
197  for (size_t sample = step; sample < samples.size() - step; sample++) {
198  int diff2nd = samples[sample + step] + samples[sample - step] - 2*samples[sample];
199  if (diff2nd > 0) der2ndVec.push_back(0);
200  else der2ndVec.push_back(-diff2nd);
201  }
202 
203  der2ndVec.insert(der2ndVec.end(), step, 0);
204 
205  return der2ndVec;
206 }

◆ doSimStage()

void ZDCTriggerSimFADC::doSimStage ( )
overrideprotectedvirtual

Implements ZDCTriggerSimBase.

Definition at line 100 of file ZDCTriggerSim.cxx.

100  {
102  if (ptr->getNumData() != 24*8 || ptr->getNumBits() != 12)
103  throw std::logic_error("Invalid input data in ZDCTriggerSimModuleAmpls");
104 
105  unsigned int sampleIdx = 0;
106 
107  std::vector<unsigned int> moduleAmplitudes;
108 
109  // Loop over the eight ZDC modules
110  //
111  for (size_t side : {0, 1}) {
112  for (size_t module : {0, 1, 2, 3}) {
113  std::vector<unsigned int> FADCsamples;
114 
115  bool adcOverflow = false;
116 
117  //
118  // Loop over the FADCs for the channel and put them in a vector for easier manipulation
119  // While we're at it, check for overflows since the trigger firmware always sends up
120  // 4095 if there is an overflow
121  //
122  for (size_t i = 0; i < 24; i++) {
123  unsigned int ADC = ptr->getValueTrunc(sampleIdx++);
124  if (ADC == 4095) {
125  adcOverflow = true;
126  break;
127  }
128 
129  FADCsamples.push_back(ADC);
130  }
131 
132  m_baseline[side][module] = 0;
133  m_maxADC[side][module] = 0;
135 
136  if (adcOverflow) {
137  //
138  // If the ADC overflows, the firmware returns amplitude of 4095
139  //
140  moduleAmplitudes.push_back(4095);
141  }
142  else {
143  std::vector<unsigned int> negDeriv2nd = CalculateNeg2ndDerivatives(FADCsamples, 2);
144 
145  // Now loop over the min-max sample range (within single channel) and see
146  // if the second derivative threshold is exceeded. If so, we pick off the
147  // maximum amplitude in that same range -- this is what the firmware does
148  //
149  bool havePulse = false;
150  unsigned int maxAmp = 0;
151  unsigned int baseline = 0;
152  unsigned int maxNeg2ndDeriv = 0;
153 
154  for (unsigned int sampleTest = m_minSampleAna; sampleTest <= m_maxSampleAna; sampleTest++) {
155  if (negDeriv2nd.at(sampleTest) > maxNeg2ndDeriv) maxNeg2ndDeriv = negDeriv2nd.at(sampleTest);
156  if (negDeriv2nd.at(sampleTest) > m_deriv2ndThresholds[side][module] && !havePulse) {
157  havePulse = true;
158 
159  // The firmware evaluates the baseline a certain number of samples before
160  // the 2nd derivative threshold is crossed
161  //
162  baseline = FADCsamples.at(sampleTest - m_baselineDelta);
163  }
164 
165  if (FADCsamples.at(sampleTest) > maxAmp) maxAmp = FADCsamples.at(sampleTest);
166  }
167 
168  m_maxNegDeriv2nd[side][module] = maxNeg2ndDeriv;
169  if (havePulse) {
170  moduleAmplitudes.push_back(std::max<int>(int(maxAmp - baseline), 0));
172  m_maxADC[side][module] = maxAmp;
173  }
174  else {
175  moduleAmplitudes.push_back(0);
176  m_baseline[side][module] = 0;
177  m_maxADC[side][module] = 0;
178  }
179  }
180  }
181  }
182 
184  static_cast<ZDCTriggerSim::ModuleAmplInputsInt*>(inputs_p.get())->setData(moduleAmplitudes);
185 
186  stackPush(inputs_p);
187 
189 }

◆ dump()

void ZDCTriggerSimBase::dump ( std::ostream &  strm) const
inherited

Definition at line 11 of file ZDCTriggerSim.cxx.

11  {
12  for (auto entry : m_stack) {
13  strm << entry->getType() << ": ";
14  entry->dump(strm);
15  strm << std::endl;
16  }
17 }

◆ getBaselines()

auto ZDCTriggerSimFADC::getBaselines ( ) const
inline

Definition at line 351 of file ZDCTriggerSim.h.

351 {return m_baseline;}

◆ getMaxADCs()

auto ZDCTriggerSimFADC::getMaxADCs ( ) const
inline

Definition at line 350 of file ZDCTriggerSim.h.

350 {return m_maxADC;}

◆ getMaxNegDeriv2nds()

auto ZDCTriggerSimFADC::getMaxNegDeriv2nds ( ) const
inline

Definition at line 349 of file ZDCTriggerSim.h.

349 {return m_maxNegDeriv2nd;}

◆ simLevel1Trig()

virtual unsigned int ZDCTriggerSimFADC::simLevel1Trig ( const ZDCTriggerSim::SimDataCPtr inputData)
inlineoverridevirtual

Implements ZDCTriggerSimBase.

Definition at line 340 of file ZDCTriggerSim.h.

340  {
341  stackClear();
342  stackPush(inputData);
343 
344  doSimStage();
345  return stackTopData()->getValueTrunc();
346  }

◆ stackBottom()

SimStack::const_iterator ZDCTriggerSimBase::stackBottom ( ) const
inlineinherited

Definition at line 212 of file ZDCTriggerSim.h.

213  {
214  return m_stack.begin();
215  }

◆ stackClear()

void ZDCTriggerSimBase::stackClear ( )
inlineprotectedinherited

Definition at line 187 of file ZDCTriggerSim.h.

187 { m_stack.clear(); }

◆ stackPush()

void ZDCTriggerSimBase::stackPush ( const ZDCTriggerSim::SimDataCPtr ptr)
inlineprotectedinherited

Definition at line 189 of file ZDCTriggerSim.h.

189  {
190  m_stack.push_back(SimStack::value_type(ptr));
191  }

◆ stackTop()

SimStack::const_reverse_iterator ZDCTriggerSimBase::stackTop ( ) const
inlineinherited

Definition at line 217 of file ZDCTriggerSim.h.

217  {
218  return m_stack.rbegin();
219  }

◆ stackTopData()

const ZDCTriggerSim::SimDataCPtr& ZDCTriggerSimBase::stackTopData ( ) const
inlineprotectedinherited

Definition at line 193 of file ZDCTriggerSim.h.

193  {
194  return m_stack.back();
195  }

Member Data Documentation

◆ m_baseline

std::array<std::array<unsigned int, 4>, 2> ZDCTriggerSimFADC::m_baseline {}
private

Definition at line 314 of file ZDCTriggerSim.h.

◆ m_baselineDelta

unsigned int ZDCTriggerSimFADC::m_baselineDelta {}
private

Definition at line 310 of file ZDCTriggerSim.h.

◆ m_combLUT

std::array<unsigned int, 256> ZDCTriggerSimCombLUT::m_combLUT {}
privateinherited

Definition at line 225 of file ZDCTriggerSim.h.

◆ m_deriv2ndThresholds

std::array<std::array<unsigned int, 4>, 2> ZDCTriggerSimFADC::m_deriv2ndThresholds
private

Definition at line 307 of file ZDCTriggerSim.h.

◆ m_LUTA

std::array<unsigned int, 4096> ZDCTriggerSimAllLUTs::m_LUTA {}
privateinherited

Definition at line 250 of file ZDCTriggerSim.h.

◆ m_LUTC

std::array<unsigned int, 4096> ZDCTriggerSimAllLUTs::m_LUTC {}
privateinherited

Definition at line 251 of file ZDCTriggerSim.h.

◆ m_maxADC

std::array<std::array<unsigned int, 4>, 2> ZDCTriggerSimFADC::m_maxADC {}
private

Definition at line 313 of file ZDCTriggerSim.h.

◆ m_maxNegDeriv2nd

std::array<std::array<int, 4>, 2> ZDCTriggerSimFADC::m_maxNegDeriv2nd {}
private

Definition at line 312 of file ZDCTriggerSim.h.

◆ m_maxSampleAna

unsigned int ZDCTriggerSimFADC::m_maxSampleAna {}
private

Definition at line 309 of file ZDCTriggerSim.h.

◆ m_minSampleAna

unsigned int ZDCTriggerSimFADC::m_minSampleAna {}
private

Definition at line 308 of file ZDCTriggerSim.h.

◆ m_stack

SimStack ZDCTriggerSimBase::m_stack
privateinherited

Definition at line 184 of file ZDCTriggerSim.h.


The documentation for this class was generated from the following files:
ZDCTriggerSimModuleAmpls::doSimStage
virtual void doSimStage() override
Definition: ZDCTriggerSim.cxx:67
ZDCTriggerSimBase::m_stack
SimStack m_stack
Definition: ZDCTriggerSim.h:184
MonDataType::ADC
@ ADC
ZDCTriggerSim::SimDataCPtr
std::shared_ptr< const ZDCTriggerSimDataBase > SimDataCPtr
Definition: ZDCTriggerSim.h:170
ZDCTriggerSimBase::stackClear
void stackClear()
Definition: ZDCTriggerSim.h:187
ZDCTriggerSimFADC::m_baselineDelta
unsigned int m_baselineDelta
Definition: ZDCTriggerSim.h:310
ZDCTriggerSimFADC::m_maxSampleAna
unsigned int m_maxSampleAna
Definition: ZDCTriggerSim.h:309
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
ZDCTriggerSimFADC::m_maxADC
std::array< std::array< unsigned int, 4 >, 2 > m_maxADC
Definition: ZDCTriggerSim.h:313
TRT::Hit::side
@ side
Definition: HitInfo.h:83
ZDCTriggerSimBase::stackTopData
const ZDCTriggerSim::SimDataCPtr & stackTopData() const
Definition: ZDCTriggerSim.h:193
python.PyAthena.module
module
Definition: PyAthena.py:131
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:116
lumiFormat.i
int i
Definition: lumiFormat.py:85
baseline
@ baseline
Definition: SUSYToolsTester.cxx:99
ZDCTriggerSimFADC::m_minSampleAna
unsigned int m_minSampleAna
Definition: ZDCTriggerSim.h:308
ZDCTriggerSim::SimDataPtr
std::shared_ptr< ZDCTriggerSimDataBase > SimDataPtr
Definition: ZDCTriggerSim.h:171
ZDCTriggerSimBase::stackPush
void stackPush(const ZDCTriggerSim::SimDataCPtr &ptr)
Definition: ZDCTriggerSim.h:189
ZDCTriggerSimFADC::doSimStage
virtual void doSimStage() override
Definition: ZDCTriggerSim.cxx:100
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
ZDCTriggerSimData
Definition: ZDCTriggerSim.h:58
ZDCTriggerSimFADC::m_maxNegDeriv2nd
std::array< std::array< int, 4 >, 2 > m_maxNegDeriv2nd
Definition: ZDCTriggerSim.h:312
ZDCTriggerSimModuleAmpls::ZDCTriggerSimModuleAmpls
ZDCTriggerSimModuleAmpls(const std::array< unsigned int, 4096 > &sideALUT, const std::array< unsigned int, 4096 > &sideCLUT, const std::array< unsigned int, 256 > &inCombLUT)
Definition: ZDCTriggerSim.h:290
ZDCTriggerSimFADC::CalculateNeg2ndDerivatives
std::vector< unsigned int > CalculateNeg2ndDerivatives(const std::vector< unsigned int > &samples, unsigned int step)
Definition: ZDCTriggerSim.cxx:193
LArCellBinning.step
step
Definition: LArCellBinning.py:158
ZDCTriggerSimFADC::m_deriv2ndThresholds
std::array< std::array< unsigned int, 4 >, 2 > m_deriv2ndThresholds
Definition: ZDCTriggerSim.h:307
ZDCTriggerSimFADC::m_baseline
std::array< std::array< unsigned int, 4 >, 2 > m_baseline
Definition: ZDCTriggerSim.h:314