ATLAS Offline Software
List of all members
StepArrayBM Class Reference

#include <StepArrayBM.h>

Inheritance diagram for StepArrayBM:
Collaboration diagram for StepArrayBM:

Public Member Functions

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

IBeamIntensity methods

unsigned int m_maxBunchCrossingPerOrbit
 max bunch crossings per orbit More...
 
Gaudi::Hive::ContextSpecificData< unsigned int > m_t0Offset
 offset of the t0 wrto our intensity pattern More...
 
Gaudi::Hive::ContextSpecificData< unsigned int > m_signalOffset
 offset of the current xing wrto the signal pattern More...
 
Gaudi::Property< std::vector< float > > m_intensityPatternProp
 user-defined intensity pattern More...
 
Gaudi::Property< std::vector< float > > m_signalPatternProp
 user-defined signal pattern - non zero numbers means "Do Signal" More...
 
unsigned int m_ipLength
 length of the intensity pattern More...
 
unsigned int m_spLength
 length of the signal pattern More...
 
double * m_intensityPattern
 normalized intensity pattern. C array to make clhep RandGeneral happy More...
 
bool * m_signalPattern
 locally stored siganlPattern 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 run, unsigned long long event) override final
 
virtual unsigned int getCurrentT0BunchCrossing () const override final
 
virtual unsigned int getBeamPatternLength () const override final
 

Detailed Description

Definition at line 25 of file StepArrayBM.h.

Constructor & Destructor Documentation

◆ StepArrayBM()

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

Definition at line 12 of file StepArrayBM.cxx.

13  : base_class(name,svc)
15  , m_t0Offset(0)
16  , m_signalOffset(0)
19  , m_ipLength(1)
20  , m_spLength(1)
21  , m_intensityPattern(new double[m_ipLength])
22  , m_signalPattern(new bool[m_spLength])
24 {
25  declareProperty("MaxBunchCrossingPerOrbit", m_maxBunchCrossingPerOrbit, "The number of slots in each LHC beam. Default: 3564.");
26  declareProperty("IntensityPattern", m_intensityPatternProp,
27  "An array of floats containing the beam intensity distribution as a function of time in bins of 25ns. ArrayBM normalizes the distribution and uses it as a stencil to determine the relative intensity at each beam xing in the simulated range"
28  );
29  declareProperty("SignalPattern", m_signalPatternProp, "An array of booleans to complement the IntensityPattern to indicate where the signal event should happen (i.e. which events to actually simulate). Default behaviour is to do EVERY bunch crossing."
30  );
31  m_intensityPattern[0]=1.0;
32  m_signalPattern[0]=true;
33 }

◆ ~StepArrayBM()

StepArrayBM::~StepArrayBM ( )
virtual

Definition at line 35 of file StepArrayBM.cxx.

36 {
37  delete [] m_intensityPattern;
38  delete [] m_signalPattern;
39 }

Member Function Documentation

◆ getBeamPatternLength()

virtual unsigned int StepArrayBM::getBeamPatternLength ( ) const
inlinefinaloverridevirtual

Definition at line 52 of file StepArrayBM.h.

52 { return m_ipLength; }

◆ getCurrentT0BunchCrossing()

virtual unsigned int StepArrayBM::getCurrentT0BunchCrossing ( ) const
inlinefinaloverridevirtual

Definition at line 51 of file StepArrayBM.h.

51 { return m_t0Offset; }

◆ initialize()

StatusCode StepArrayBM::initialize ( )
finaloverridevirtual

Definition at line 41 of file StepArrayBM.cxx.

42 {
43  const std::vector<float>& rProp(m_intensityPatternProp.value());
44  const std::vector<float>& sProp(m_signalPatternProp.value());
45  std::vector<float>::const_iterator pBegin(rProp.begin());
46  std::vector<float>::const_iterator pEnd(rProp.end());
47  m_ipLength = rProp.size();
48  //Consistency checks
50  {
51  ATH_MSG_ERROR("IntensityPattern length (" << m_ipLength << "), exceeds the maximum number of bunch crossings per orbit (" << m_maxBunchCrossingPerOrbit << ").");
52  return StatusCode::FAILURE;
53  }
54 
55  // Normalise the pattern so that the non-zero elements average to 1.0
56  float nonZeroElementCount(static_cast<float>(std::count_if(pBegin, pEnd, IsNonZero)));
57  if(nonZeroElementCount<1.0)
58  {
59  ATH_MSG_ERROR("IntensityPattern has no non-zero elements!");
60  return StatusCode::FAILURE;
61  }
62  float elementSum(static_cast<float>(std::accumulate(pBegin, pEnd,0.0)));
63  float denominator(elementSum/nonZeroElementCount);
64 
65  // Normalise the pattern so that the highest element value is 1.0
66  float maxElement(*(std::max_element(pBegin, pEnd)));
67  float inv_maxElement = maxElement != 0 ? 1. / maxElement : 1;
68 
69  //copy normalized intensity pattern from the property, and match signal pattern if requested
70  delete [] m_intensityPattern;
71  m_intensityPattern = new double[m_ipLength];
72 
73  for (unsigned int i(0); i<m_ipLength; ++i)
74  {
75  if (rProp[i]<0.0)
76  {
77  ATH_MSG_ERROR("All IntensityPattern elements must be >=0. Please fix element #" << i );
78  return StatusCode::FAILURE;
79  }
80  m_intensityPattern[i] = rProp[i] * inv_maxElement;
81  }
82 
83  // Will be used to convert values in the m_intensityPattern
84  // from having max value 1.0 to having mean value 1.0
86 
87  //FIXME add a check that entry 0 is zero? In data, BCID=1 is always the first filled bunch.
88 
89  //get the signal pattern from the property
90  m_spLength = sProp.size();
91  delete [] m_signalPattern;
92  m_signalPattern = new bool[m_spLength];
93  bool isOk=false;
94  for (unsigned int i(0); i<m_spLength; ++i)
95  {
96  m_signalPattern[i] = (sProp[i]>0.0);
97  if(m_signalPattern[i]) { isOk=true; }
98  }
99  if(!isOk)
100  {
101  ATH_MSG_ERROR("SignalPattern MUST have at least one non-zero value in it.");
102  return StatusCode::FAILURE;
103  }
104 
105  //start the t0Offset and signalOffset at the LAST entry in the arrays, so that the first event is for the FIRST entry in the arrays
108 
109  return StatusCode::SUCCESS;
110 }

◆ largestElementInPattern()

virtual float StepArrayBM::largestElementInPattern ( ) const
inlinefinaloverridevirtual

Definition at line 49 of file StepArrayBM.h.

49 { return m_largestElementInPattern; }

◆ normFactor()

virtual float StepArrayBM::normFactor ( int  iXing) const
inlinefinaloverridevirtual

Definition at line 39 of file StepArrayBM.h.

40  {
41  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));
42  //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.
43  ATH_MSG_VERBOSE("normFactor for BCID " << iXing
44  << " (offset " << m_t0Offset
45  << " index " << index
48  }

◆ selectT0()

void StepArrayBM::selectT0 ( unsigned int  run,
unsigned long long  event 
)
finaloverridevirtual

Definition at line 112 of file StepArrayBM.cxx.

113 {
114  //move to the next xing as dictated by the signalPattern, for each incremember, shift the t0Offset
115  do {
117  m_t0Offset = (unsigned int)((m_t0Offset+1) % m_ipLength);
118  } while(!m_signalPattern[m_signalOffset]);
119 
120 
121  //assert(m_intensityPattern[m_t0Offset % m_ipLength]>0.0); //commented out to allow events with no intensity
122 
123  ATH_MSG_DEBUG( "selectT0 offset for this event " << m_t0Offset );
124 }

Member Data Documentation

◆ m_intensityPattern

double* StepArrayBM::m_intensityPattern
private

normalized intensity pattern. C array to make clhep RandGeneral happy

Definition at line 70 of file StepArrayBM.h.

◆ m_intensityPatternProp

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

user-defined intensity pattern

Definition at line 62 of file StepArrayBM.h.

◆ m_ipLength

unsigned int StepArrayBM::m_ipLength
private

length of the intensity pattern

Definition at line 66 of file StepArrayBM.h.

◆ m_largestElementInPattern

float StepArrayBM::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 77 of file StepArrayBM.h.

◆ m_maxBunchCrossingPerOrbit

unsigned int StepArrayBM::m_maxBunchCrossingPerOrbit
private

max bunch crossings per orbit

Definition at line 56 of file StepArrayBM.h.

◆ m_signalOffset

Gaudi::Hive::ContextSpecificData<unsigned int> StepArrayBM::m_signalOffset
private

offset of the current xing wrto the signal pattern

Definition at line 60 of file StepArrayBM.h.

◆ m_signalPattern

bool* StepArrayBM::m_signalPattern
private

locally stored siganlPattern

Definition at line 72 of file StepArrayBM.h.

◆ m_signalPatternProp

Gaudi::Property<std::vector<float> > StepArrayBM::m_signalPatternProp
private

user-defined signal pattern - non zero numbers means "Do Signal"

Definition at line 64 of file StepArrayBM.h.

◆ m_spLength

unsigned int StepArrayBM::m_spLength
private

length of the signal pattern

Definition at line 68 of file StepArrayBM.h.

◆ m_t0Offset

Gaudi::Hive::ContextSpecificData<unsigned int> StepArrayBM::m_t0Offset
private

offset of the t0 wrto our intensity pattern

Definition at line 58 of file StepArrayBM.h.


The documentation for this class was generated from the following files:
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
index
Definition: index.py:1
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
StepArrayBM::m_intensityPatternProp
Gaudi::Property< std::vector< float > > m_intensityPatternProp
user-defined intensity pattern
Definition: StepArrayBM.h:62
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
StepArrayBM::m_largestElementInPattern
float m_largestElementInPattern
The largest value in the pattern assuming that the pattern has mean value 1.0.
Definition: StepArrayBM.h:77
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
StepArrayBM::m_ipLength
unsigned int m_ipLength
length of the intensity pattern
Definition: StepArrayBM.h:66
StepArrayBM::m_t0Offset
Gaudi::Hive::ContextSpecificData< unsigned int > m_t0Offset
offset of the t0 wrto our intensity pattern
Definition: StepArrayBM.h:58
StepArrayBM::m_maxBunchCrossingPerOrbit
unsigned int m_maxBunchCrossingPerOrbit
max bunch crossings per orbit
Definition: StepArrayBM.h:56
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
ReadTripsProbsFromCool.denominator
denominator
Definition: ReadTripsProbsFromCool.py:96
StepArrayBM::m_signalPattern
bool * m_signalPattern
locally stored siganlPattern
Definition: StepArrayBM.h:72
StepArrayBM::m_signalPatternProp
Gaudi::Property< std::vector< float > > m_signalPatternProp
user-defined signal pattern - non zero numbers means "Do Signal"
Definition: StepArrayBM.h:64
StepArrayBM::m_intensityPattern
double * m_intensityPattern
normalized intensity pattern. C array to make clhep RandGeneral happy
Definition: StepArrayBM.h:70
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DeMoScan.index
string index
Definition: DeMoScan.py:362
StepArrayBM::m_signalOffset
Gaudi::Hive::ContextSpecificData< unsigned int > m_signalOffset
offset of the current xing wrto the signal pattern
Definition: StepArrayBM.h:60
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
StepArrayBM::m_spLength
unsigned int m_spLength
length of the signal pattern
Definition: StepArrayBM.h:68