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

unsigned int m_maxBunchCrossingPerOrbit
 max bunch crossings per orbit More...
 
unsigned int m_t0Offset
 offset of the t0 wrto our intensity pattern More...
 
Gaudi::Property< bool > m_allowEmptyT0BunchCrossing
 allow t0 to be in an empty bunch crossing More...
 
Gaudi::Property< std::vector< float > > m_intensityPatternProp
 user-defined intensity pattern More...
 
unsigned int m_ipLength
 length of the intensity pattern More...
 
double * m_intensityPattern
 normalized intensity pattern. More...
 
float m_largestElementInPattern
 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)
15  , m_t0Offset(0)
18  , m_ipLength(1)
19  , m_intensityPattern(new double[m_ipLength])
21 {
22  declareProperty("MaxBunchCrossingPerOrbit", m_maxBunchCrossingPerOrbit, "The number of slots in each LHC beam. Default: 3564.");
23  declareProperty("T0Offset", m_t0Offset, "Offset of the T0 w.r.t. our intensity pattern" );
24  declareProperty("AllowEmptyT0BunchCrossing", m_allowEmptyT0BunchCrossing, "Allow the offset of the T0 to sit in an empty bunch crossing." );
25  declareProperty("IntensityPattern", m_intensityPatternProp,
26  "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"
27  );
28  m_intensityPattern[0]=1.0;
29 }

◆ ~FixedArrayBM()

FixedArrayBM::~FixedArrayBM ( )
virtual

Definition at line 31 of file FixedArrayBM.cxx.

32 {
33  delete [] m_intensityPattern;
34 }

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 36 of file FixedArrayBM.cxx.

37 {
38  const std::vector<float>& rProp(m_intensityPatternProp.value());
39  std::vector<float>::const_iterator pBegin(rProp.begin());
40  std::vector<float>::const_iterator pEnd(rProp.end());
41  m_ipLength = rProp.size();
42  if(m_ipLength<1)
43  {
44  ATH_MSG_ERROR("IntensityPattern length (" << m_ipLength << ") is less than 1!");
45  return StatusCode::FAILURE;
46  }
47  //Consistency checks
49  {
50  ATH_MSG_ERROR("IntensityPattern length (" << m_ipLength << "), exceeds the maximum number of bunch crossings per orbit (" << m_maxBunchCrossingPerOrbit << ").");
51  return StatusCode::FAILURE;
52  }
53 
54  // Normalise the pattern so that the non-zero elements average to 1.0
55  float nonZeroElementCount(static_cast<float>(std::count_if(pBegin, pEnd, IsNonZero)));
56  if(nonZeroElementCount<1.0)
57  {
58  ATH_MSG_ERROR("IntensityPattern has no non-zero elements!");
59  return StatusCode::FAILURE;
60  }
61  float elementSum(static_cast<float>(std::accumulate(pBegin, pEnd,0.0)));
62  float denominator(elementSum/nonZeroElementCount);
63 
64  // Normalise the pattern so that the highest element value is 1.0
65  float maxElement(*(std::max_element(pBegin, pEnd)));
66  float inv_maxElement = maxElement != 0 ? 1. / maxElement : 1;
67 
68  // Copy normalized intensity pattern from the property
69  delete [] m_intensityPattern;
70  m_intensityPattern = new double[m_ipLength];
71 
72  for (unsigned int i(0); i<m_ipLength; ++i)
73  {
74  if (rProp[i]<0.0)
75  {
76  ATH_MSG_ERROR("All IntensityPattern elements must be >=0. Please fix element #" << i );
77  return StatusCode::FAILURE;
78  }
79  m_intensityPattern[i] = rProp[i] * inv_maxElement; // this ensures that the elements are all in the range [0,1]
80  }
81 
82  // Will be used to convert values in the m_intensityPattern
83  // from having max value 1.0 to having mean value 1.0
85 
86  //FIXME add a check that entry 0 is zero? In data, BCID=1 is always the first filled bunch.
87 
88  //check m_t0Offset is within allowed values
90  {
91  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.");
93  }
94  assert(m_intensityPattern[m_t0Offset % m_ipLength]>0.0); //just in case
96  {
97  ATH_MSG_DEBUG( "T0 offset set to " << m_t0Offset << " for all events in this run." );
98  }
99  else
100  {
101  if (!(m_allowEmptyT0BunchCrossing.value()))
102  {
103  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.");
104  return StatusCode::FAILURE;
105  }
106  else
107  {
108  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." );
109  }
110  }
111  return StatusCode::SUCCESS;
112 }

◆ 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 114 of file FixedArrayBM.cxx.

115  {
116  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));
117  //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.
118  ATH_MSG_VERBOSE("normFactor for BCID " << iXing
119  << " (offset " << m_t0Offset
120  << " index " << index
123  }

◆ 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

allow t0 to be in an empty bunch crossing

Definition at line 54 of file FixedArrayBM.h.

◆ m_intensityPattern

double* FixedArrayBM::m_intensityPattern
private

normalized intensity pattern.

Definition at line 60 of file FixedArrayBM.h.

◆ m_intensityPatternProp

Gaudi::Property<std::vector<float> > FixedArrayBM::m_intensityPatternProp
private

user-defined intensity pattern

Definition at line 56 of file FixedArrayBM.h.

◆ m_ipLength

unsigned int FixedArrayBM::m_ipLength
private

length of the intensity pattern

Definition at line 58 of file FixedArrayBM.h.

◆ m_largestElementInPattern

float FixedArrayBM::m_largestElementInPattern
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 65 of file FixedArrayBM.h.

◆ m_maxBunchCrossingPerOrbit

unsigned int FixedArrayBM::m_maxBunchCrossingPerOrbit
private

max bunch crossings per orbit

Definition at line 50 of file FixedArrayBM.h.

◆ m_t0Offset

unsigned int FixedArrayBM::m_t0Offset
private

offset of the t0 wrto our intensity pattern

Definition at line 52 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
user-defined intensity pattern
Definition: FixedArrayBM.h:56
FixedArrayBM::m_largestElementInPattern
float m_largestElementInPattern
The largest value in the pattern assuming that the pattern has mean value 1.0.
Definition: FixedArrayBM.h:65
index
Definition: index.py:1
FixedArrayBM::m_allowEmptyT0BunchCrossing
Gaudi::Property< bool > m_allowEmptyT0BunchCrossing
allow t0 to be in an empty bunch crossing
Definition: FixedArrayBM.h:54
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
FixedArrayBM::m_maxBunchCrossingPerOrbit
unsigned int m_maxBunchCrossingPerOrbit
max bunch crossings per orbit
Definition: FixedArrayBM.h:50
FixedArrayBM::m_t0Offset
unsigned int m_t0Offset
offset of the t0 wrto our intensity pattern
Definition: FixedArrayBM.h:52
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:58
lumiFormat.i
int i
Definition: lumiFormat.py:92
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
ReadTripsProbsFromCool.denominator
denominator
Definition: ReadTripsProbsFromCool.py:96
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DeMoScan.index
string index
Definition: DeMoScan.py:362
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
FixedArrayBM::m_intensityPattern
double * m_intensityPattern
normalized intensity pattern.
Definition: FixedArrayBM.h:60