ATLAS Offline Software
List of all members
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 More...
 
double * m_intensityPattern
 normalized intensity pattern. More...
 
float m_largestElementInPattern {1.0}
 The largest value in the pattern assuming that the pattern has mean value 1.0. More...
 
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 }

◆ ~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  }

◆ 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
73 
74  //FIXME add a check that entry 0 is zero? In data, BCID=1 is always the first filled bunch.
75 
76  //check m_t0Offset is within allowed values
78  {
79  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.");
81  }
82  assert(m_intensityPattern[m_t0Offset % m_ipLength]>0.0); //just in case
84  {
85  ATH_MSG_DEBUG( "T0 offset set to " << m_t0Offset << " for all events in this run." );
86  }
87  else
88  {
89  if (!(m_allowEmptyT0BunchCrossing.value()))
90  {
91  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.");
92  return StatusCode::FAILURE;
93  }
94  else
95  {
96  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." );
97  }
98  }
99  return StatusCode::SUCCESS;
100 }

◆ largestElementInPattern()

virtual float FixedArrayBM::largestElementInPattern ( ) const
inlinefinaloverridevirtual

Definition at line 38 of file FixedArrayBM.h.

38 { return m_largestElementInPattern; }

◆ normFactor()

float FixedArrayBM::normFactor ( int  iXing) const
finaloverridevirtual

Definition at line 102 of file FixedArrayBM.cxx.

103  {
104  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));
105  //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.
106  ATH_MSG_VERBOSE("normFactor for BCID " << iXing
107  << " (offset " << m_t0Offset
108  << " index " << index
111  }

◆ 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.

◆ 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.

◆ m_ipLength

unsigned int FixedArrayBM::m_ipLength {1}
private

length of the intensity pattern

Definition at line 65 of file FixedArrayBM.h.

◆ 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.

◆ 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.

◆ 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.


The documentation for this class was generated from the following files:
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FixedArrayBM::m_intensityPatternProp
Gaudi::Property< std::vector< float > > m_intensityPatternProp
Definition: FixedArrayBM.h:59
FixedArrayBM::m_largestElementInPattern
float m_largestElementInPattern
The largest value in the pattern assuming that the pattern has mean value 1.0.
Definition: FixedArrayBM.h:72
index
Definition: index.py:1
FixedArrayBM::m_allowEmptyT0BunchCrossing
Gaudi::Property< bool > m_allowEmptyT0BunchCrossing
Definition: FixedArrayBM.h:56
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
FixedArrayBM::m_ipLength
unsigned int m_ipLength
length of the intensity pattern
Definition: FixedArrayBM.h:65
lumiFormat.i
int i
Definition: lumiFormat.py:85
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
FixedArrayBM::m_maxBunchCrossingPerOrbit
Gaudi::Property< unsigned int > m_maxBunchCrossingPerOrbit
Definition: FixedArrayBM.h:50
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
ReadTripsProbsFromCool.denominator
denominator
Definition: ReadTripsProbsFromCool.py:96
FixedArrayBM::m_t0Offset
Gaudi::Property< unsigned int > m_t0Offset
Definition: FixedArrayBM.h:53
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
DeMoScan.index
string index
Definition: DeMoScan.py:362
runIDAlign.accumulate
accumulate
Update flags based on parser line args.
Definition: runIDAlign.py:60
FixedArrayBM::m_intensityPattern
double * m_intensityPattern
normalized intensity pattern.
Definition: FixedArrayBM.h:67