ATLAS Offline Software
Loading...
Searching...
No Matches
FixedArrayBM Class Reference

#include <FixedArrayBM.h>

Inheritance diagram for FixedArrayBM:
Collaboration diagram for FixedArrayBM:

Public Member Functions

Constructor and Destructor
 FixedArrayBM (const std::string &name, ISvcLocator *svc)
virtual ~FixedArrayBM ()
AthService methods
virtual StatusCode initialize () override final

IBeamIntensity methods

Gaudi::Property< unsigned int > m_maxBunchCrossingPerOrbit
Gaudi::Property< unsigned int > m_t0Offset
Gaudi::Property< bool > m_allowEmptyT0BunchCrossing
Gaudi::Property< std::vector< float > > m_intensityPatternProp
unsigned int m_ipLength {1}
 length of the intensity pattern
double * m_intensityPattern
 normalized intensity pattern.
float m_largestElementInPattern {1.0}
 The largest value in the pattern assuming that the pattern has mean value 1.0.
virtual float normFactor (int iXing) const override final
virtual float largestElementInPattern () const override final
virtual void selectT0 (unsigned int, unsigned long long) override final
virtual unsigned int getCurrentT0BunchCrossing () const override final
virtual unsigned int getBeamPatternLength () const override final
virtual unsigned int getBCID (int iXing) const

Detailed Description

Definition at line 23 of file FixedArrayBM.h.

Constructor & Destructor Documentation

◆ FixedArrayBM()

FixedArrayBM::FixedArrayBM ( const std::string & name,
ISvcLocator * svc )

Definition at line 12 of file FixedArrayBM.cxx.

13 : base_class(name,svc)
14 , m_intensityPattern(new double[m_ipLength])
15{
16 m_intensityPattern[0]=1.0;
17}
double * m_intensityPattern
normalized intensity pattern.
unsigned int m_ipLength
length of the intensity pattern

◆ ~FixedArrayBM()

FixedArrayBM::~FixedArrayBM ( )
virtual

Definition at line 19 of file FixedArrayBM.cxx.

20{
21 delete [] m_intensityPattern;
22}

Member Function Documentation

◆ getBCID()

virtual unsigned int FixedArrayBM::getBCID ( int iXing) const
inlineprivatevirtual

Definition at line 44 of file FixedArrayBM.h.

45 {
46 //FIXME to be completely safe this should should probably depend on the bunch spacing too. Perhaps that concept should be deprecated though?
47 return static_cast<unsigned int>((((iXing + static_cast<int>(m_t0Offset)) % static_cast<int>(m_maxBunchCrossingPerOrbit)) + static_cast<int>(m_maxBunchCrossingPerOrbit) ) % static_cast<int>(m_maxBunchCrossingPerOrbit));
48 }
Gaudi::Property< unsigned int > m_maxBunchCrossingPerOrbit
Gaudi::Property< unsigned int > m_t0Offset

◆ getBeamPatternLength()

virtual unsigned int FixedArrayBM::getBeamPatternLength ( ) const
inlinefinaloverridevirtual

Definition at line 41 of file FixedArrayBM.h.

41{ return m_ipLength; }

◆ getCurrentT0BunchCrossing()

virtual unsigned int FixedArrayBM::getCurrentT0BunchCrossing ( ) const
inlinefinaloverridevirtual

Definition at line 40 of file FixedArrayBM.h.

40{ return m_t0Offset; }

◆ initialize()

StatusCode FixedArrayBM::initialize ( )
finaloverridevirtual

Definition at line 24 of file FixedArrayBM.cxx.

25{
26 const std::vector<float>& rProp(m_intensityPatternProp.value());
27 std::vector<float>::const_iterator pBegin(rProp.begin());
28 std::vector<float>::const_iterator pEnd(rProp.end());
29 m_ipLength = rProp.size();
30 if(m_ipLength<1)
31 {
32 ATH_MSG_ERROR("IntensityPattern length (" << m_ipLength << ") is less than 1!");
33 return StatusCode::FAILURE;
34 }
35 //Consistency checks
37 {
38 ATH_MSG_ERROR("IntensityPattern length (" << m_ipLength << "), exceeds the maximum number of bunch crossings per orbit (" << m_maxBunchCrossingPerOrbit << ").");
39 return StatusCode::FAILURE;
40 }
41
42 // Normalise the pattern so that the non-zero elements average to 1.0
43 float nonZeroElementCount(static_cast<float>(std::count_if(pBegin, pEnd, IsNonZero)));
44 if(nonZeroElementCount<1.0)
45 {
46 ATH_MSG_ERROR("IntensityPattern has no non-zero elements!");
47 return StatusCode::FAILURE;
48 }
49 float elementSum(static_cast<float>(std::accumulate(pBegin, pEnd,0.0)));
50 float denominator(elementSum/nonZeroElementCount);
51
52 // Normalise the pattern so that the highest element value is 1.0
53 float maxElement(*(std::max_element(pBegin, pEnd)));
54 float inv_maxElement = maxElement != 0 ? 1. / maxElement : 1;
55
56 // Copy normalized intensity pattern from the property
57 delete [] m_intensityPattern;
58 m_intensityPattern = new double[m_ipLength];
59
60 for (unsigned int i(0); i<m_ipLength; ++i)
61 {
62 if (rProp[i]<0.0)
63 {
64 ATH_MSG_ERROR("All IntensityPattern elements must be >=0. Please fix element #" << i );
65 return StatusCode::FAILURE;
66 }
67 m_intensityPattern[i] = rProp[i] * inv_maxElement; // this ensures that the elements are all in the range [0,1]
68 }
69
70 // Will be used to convert values in the m_intensityPattern
71 // from having max value 1.0 to having mean value 1.0
72 if (denominator != 0) {
74 }
75
76 //FIXME add a check that entry 0 is zero? In data, BCID=1 is always the first filled bunch.
77
78 //check m_t0Offset is within allowed values
80 {
81 ATH_MSG_INFO("Requested T0 offset (" << m_t0Offset << ") does not lie within IntensityPattern provided. Resetting offset to " << (m_t0Offset % m_ipLength) << " as this will give the same result.");
83 }
84 assert(m_intensityPattern[m_t0Offset % m_ipLength]>0.0); //just in case
86 {
87 ATH_MSG_DEBUG( "T0 offset set to " << m_t0Offset << " for all events in this run." );
88 }
89 else
90 {
91 if (!(m_allowEmptyT0BunchCrossing.value()))
92 {
93 ATH_MSG_ERROR("Requested T0 offset (" << m_t0Offset << ") coincides with an empty bunch crossing in the IntensityPattern provided. Please re-submit your job and select an offset corresponding to a bunch crossing with non-zero luminosity.");
94 return StatusCode::FAILURE;
95 }
96 else
97 {
98 ATH_MSG_INFO( "Allowing T0 to coincide with an empty bunch crossing in the IntensityPattern provided. T0 offset set to " << m_t0Offset << " for all events in this run." );
99 }
100 }
101 return StatusCode::SUCCESS;
102}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
static bool IsNonZero(float lumi)
Gaudi::Property< std::vector< float > > m_intensityPatternProp
Gaudi::Property< bool > m_allowEmptyT0BunchCrossing
float m_largestElementInPattern
The largest value in the pattern assuming that the pattern has mean value 1.0.

◆ largestElementInPattern()

virtual float FixedArrayBM::largestElementInPattern ( ) const
inlinefinaloverridevirtual

Definition at line 38 of file FixedArrayBM.h.

◆ normFactor()

float FixedArrayBM::normFactor ( int iXing) const
finaloverridevirtual

Definition at line 104 of file FixedArrayBM.cxx.

105 {
106 unsigned int index = static_cast<unsigned int>((((iXing + static_cast<int>(m_t0Offset)) % static_cast<int>(m_ipLength)) + static_cast<int>(m_ipLength) ) % static_cast<int>(m_ipLength));
107 //The array itself has max-value 1.0, but we want it to have mean value 1.0 (for filled bunch crossings), so we multiple by the m_largestElementInPattern.
108 ATH_MSG_VERBOSE("normFactor for BCID " << iXing
109 << " (offset " << m_t0Offset
110 << " index " << index
111 << ") is = " << m_largestElementInPattern*m_intensityPattern[ index ]);
113 }
#define ATH_MSG_VERBOSE(x)
str index
Definition DeMoScan.py:362

◆ selectT0()

virtual void FixedArrayBM::selectT0 ( unsigned int ,
unsigned long long  )
inlinefinaloverridevirtual

Definition at line 39 of file FixedArrayBM.h.

39{ }

Member Data Documentation

◆ m_allowEmptyT0BunchCrossing

Gaudi::Property<bool> FixedArrayBM::m_allowEmptyT0BunchCrossing
private
Initial value:
{this, "AllowEmptyT0BunchCrossing", false,
"Allow the offset of the T0 to sit in an empty bunch crossing."}

Definition at line 56 of file FixedArrayBM.h.

56 {this, "AllowEmptyT0BunchCrossing", false,
57 "Allow the offset of the T0 to sit in an empty bunch crossing."};

◆ m_intensityPattern

double* FixedArrayBM::m_intensityPattern
private

normalized intensity pattern.

Definition at line 67 of file FixedArrayBM.h.

◆ m_intensityPatternProp

Gaudi::Property<std::vector<float> > FixedArrayBM::m_intensityPatternProp
private
Initial value:
{this, "IntensityPattern", {},
"An array of floats containing the beam intensity distribution as a function of "
"time in bins of 25ns. FixedArrayBM normalizes the distribution and uses it as a "
"stencil to determine the relative intensity at each beam xing in the simulated range"}

Definition at line 59 of file FixedArrayBM.h.

59 {this, "IntensityPattern", {},
60 "An array of floats containing the beam intensity distribution as a function of "
61 "time in bins of 25ns. FixedArrayBM normalizes the distribution and uses it as a "
62 "stencil to determine the relative intensity at each beam xing in the simulated range"};

◆ m_ipLength

unsigned int FixedArrayBM::m_ipLength {1}
private

length of the intensity pattern

Definition at line 65 of file FixedArrayBM.h.

65{1};

◆ m_largestElementInPattern

float FixedArrayBM::m_largestElementInPattern {1.0}
private

The largest value in the pattern assuming that the pattern has mean value 1.0.

Multiplying by this converts values in the m_intensityPattern from having max value 1.0 to having mean value 1.0.

Definition at line 72 of file FixedArrayBM.h.

72{1.0};

◆ m_maxBunchCrossingPerOrbit

Gaudi::Property<unsigned int> FixedArrayBM::m_maxBunchCrossingPerOrbit
private
Initial value:
{this, "MaxBunchCrossingPerOrbit", 3564,
"The number of slots in each LHC beam. Default: 3564."}

Definition at line 50 of file FixedArrayBM.h.

50 {this, "MaxBunchCrossingPerOrbit", 3564,
51 "The number of slots in each LHC beam. Default: 3564."};

◆ m_t0Offset

Gaudi::Property<unsigned int> FixedArrayBM::m_t0Offset
private
Initial value:
{this, "T0Offset", 0,
"Offset of the T0 w.r.t. our intensity pattern"}

Definition at line 53 of file FixedArrayBM.h.

53 {this, "T0Offset", 0,
54 "Offset of the T0 w.r.t. our intensity pattern"};

The documentation for this class was generated from the following files: