ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1CaloCalibConditions
src
L1CaloRampRunPlan.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrigT1CaloCalibConditions/L1CaloRampRunPlan.h
"
6
7
#include <string>
8
#include <sstream>
9
#include <iostream>
10
11
// AttributeList
12
#include "CoralBase/AttributeListSpecification.h"
13
#include "
AthenaPoolUtilities/AthenaAttributeList.h
"
14
15
#include "GaudiKernel/MsgStream.h"
16
17
18
L1CaloRampRunPlan::L1CaloRampRunPlan
():
AbstractL1CaloPersistentCondition
(
"AthenaAttributeList"
),
19
m_bEndOfRampRun
(false),
20
m_nEventsPerStep
(0),
21
m_itCurrentStep
(0),
22
m_iCurrentEvent
(-1)
23
{
24
this->
addSpecification
(
eEventsPerStep
, std::string(
"EventsPerStep"
), std::string(
"int"
) );
25
this->
addSpecification
(
eEnergySteps
, std::string(
"EnergySteps"
), std::string(
"string"
));
26
}
27
28
L1CaloRampRunPlan::L1CaloRampRunPlan
(
int
nEventsPerStep,
const
std::vector<double>& vEnergySteps):
AbstractL1CaloPersistentCondition
(
"AthenaAttributeList"
),
29
m_bEndOfRampRun
(false),
30
m_nEventsPerStep
(nEventsPerStep),
31
m_vEnergySteps
(vEnergySteps),
32
m_iCurrentEvent
(-1)
33
{
34
this->
addSpecification
(
eEventsPerStep
, std::string(
"EventsPerStep"
), std::string(
"int"
) );
35
this->
addSpecification
(
eEnergySteps
, std::string(
"EnergySteps"
), std::string(
"string"
));
36
37
m_itCurrentStep
=
m_vEnergySteps
.begin();
38
}
39
40
DataObject*
L1CaloRampRunPlan::makePersistent
()
const
{
41
42
// Create AttributeListSpecification according to the attributes to be recorded
43
// this is required to create the AttributeList objs
44
coral::AttributeListSpecification* attrSpecification = this->
createAttributeListSpecification
();
45
if
(!attrSpecification->size())
return
NULL;
46
47
48
AthenaAttributeList
* attrList =
new
AthenaAttributeList
(*attrSpecification);
49
50
// Set value of each row for the current channel
51
int
nEventsPerStep = this->
eventsPerStep
();
52
std::vector<double> vEnergySteps = this->
energySteps
();
53
54
(*attrList)[ this->
specificationName
(
eEventsPerStep
) ].data<
int
>() = nEventsPerStep;
55
56
57
// export energies to a string
58
std::ostringstream oss;
59
std::vector<double>::const_iterator energy_it = vEnergySteps.begin();
60
for
(;energy_it!=vEnergySteps.end();++energy_it) {
61
oss << *energy_it <<
" "
;
62
}
63
(*attrList)[ this->
specificationName
(
eEnergySteps
) ].data<std::string>()= oss.str();
64
65
return
attrList;
66
}
67
68
void
L1CaloRampRunPlan::makeTransient
(
const
AthenaAttributeList
*& athenaAttributeList) {
69
70
int
nEventsPerStep = (*athenaAttributeList)[ this->
specificationName
(
eEventsPerStep
) ].data<
int
>();
71
std::string strEnergySteps = (*athenaAttributeList)[ this->
specificationName
(
eEnergySteps
) ].data<std::string>();
72
73
//tokenize strTable
74
int
buf;
75
std::stringstream
ss
(strEnergySteps);
// insert the table string into a stream
76
std::vector<double> vEnergySteps;
// create vector to hold our words
77
while
(
ss
>> buf) vEnergySteps.push_back(buf);
78
79
m_nEventsPerStep
= nEventsPerStep;
80
81
m_vEnergySteps
= std::move(vEnergySteps);
82
m_itCurrentStep
=
m_vEnergySteps
.begin();
83
}
84
85
void
L1CaloRampRunPlan::nextEvent
() {
86
if
(
m_bEndOfRampRun
) {
87
return
;
88
}
89
90
++
m_iCurrentEvent
;
91
92
if
(
m_iCurrentEvent
==(
m_nEventsPerStep
)) {
93
++
m_itCurrentStep
;
94
m_iCurrentEvent
=0;
95
if
(
m_itCurrentStep
!=
m_vEnergySteps
.end()) {
96
}
else
{
97
m_iCurrentEvent
= -1;
98
m_bEndOfRampRun
=
true
;
99
return
;
100
}
101
}
102
}
103
104
std::string
L1CaloRampRunPlan::status
() {
105
std::ostringstream oss;
106
if
(!
m_bEndOfRampRun
) {
107
oss <<
"L1CaloRampRunPlan - Current event: "
<<
m_iCurrentEvent
<<
", current step: "
<<*
m_itCurrentStep
;
108
}
else
{
109
oss <<
"L1CaloRampRunPlan: No more events/steps to process"
;
110
}
111
return
oss.str();
112
}
113
114
115
std::ostream&
operator<<
(std::ostream& output,
const
L1CaloRampRunPlan
& rplan) {
116
output <<
"nEventsPerStep: "
<< rplan.
m_nEventsPerStep
<<
" "
;
117
std::vector<double> vSteps = rplan.
energySteps
();
118
output<<
" nsteps: "
<< vSteps.size()<<
" - steps: "
;
119
std::vector<double>::const_iterator it = vSteps.begin();
120
for
(;it!=vSteps.end();++it) {
121
output << *it<<
" "
;
122
}
123
return
output;
124
}
125
AthenaAttributeList.h
operator<<
std::ostream & operator<<(std::ostream &output, const L1CaloRampRunPlan &rplan)
Definition
L1CaloRampRunPlan.cxx:115
L1CaloRampRunPlan.h
ss
static Double_t ss
Definition
LArPhysWaveHECTool.cxx:37
AbstractL1CaloPersistentCondition::specificationName
std::string specificationName(int specId) const
Definition
AbstractL1CaloPersistentCondition.cxx:44
AbstractL1CaloPersistentCondition::AbstractL1CaloPersistentCondition
AbstractL1CaloPersistentCondition(const std::string &condType)
Definition
AbstractL1CaloPersistentCondition.h:45
AbstractL1CaloPersistentCondition::addSpecification
void addSpecification(int specId, const std::string &specName, const std::string &specType)
Definition
AbstractL1CaloPersistentCondition.cxx:26
AbstractL1CaloPersistentCondition::createAttributeListSpecification
coral::AttributeListSpecification * createAttributeListSpecification() const
Definition
AbstractL1CaloPersistentCondition.cxx:31
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table.
Definition
PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:46
L1CaloRampRunPlan::m_iCurrentEvent
int m_iCurrentEvent
Definition
L1CaloRampRunPlan.h:52
L1CaloRampRunPlan::eEventsPerStep
@ eEventsPerStep
Definition
L1CaloRampRunPlan.h:43
L1CaloRampRunPlan::eEnergySteps
@ eEnergySteps
Definition
L1CaloRampRunPlan.h:43
L1CaloRampRunPlan::L1CaloRampRunPlan
L1CaloRampRunPlan()
Definition
L1CaloRampRunPlan.cxx:18
L1CaloRampRunPlan::m_nEventsPerStep
int m_nEventsPerStep
Definition
L1CaloRampRunPlan.h:47
L1CaloRampRunPlan::m_itCurrentStep
std::vector< double >::iterator m_itCurrentStep
Definition
L1CaloRampRunPlan.h:51
L1CaloRampRunPlan::eventsPerStep
int eventsPerStep() const
Definition
L1CaloRampRunPlan.h:34
L1CaloRampRunPlan::m_bEndOfRampRun
bool m_bEndOfRampRun
Definition
L1CaloRampRunPlan.h:45
L1CaloRampRunPlan::makeTransient
virtual void makeTransient(const AthenaAttributeList *&attributeList)
Definition
L1CaloRampRunPlan.cxx:68
L1CaloRampRunPlan::m_vEnergySteps
std::vector< double > m_vEnergySteps
Definition
L1CaloRampRunPlan.h:48
L1CaloRampRunPlan::energySteps
const std::vector< double > & energySteps() const
Definition
L1CaloRampRunPlan.h:35
L1CaloRampRunPlan::nextEvent
void nextEvent()
Definition
L1CaloRampRunPlan.cxx:85
L1CaloRampRunPlan::status
std::string status()
Definition
L1CaloRampRunPlan.cxx:104
L1CaloRampRunPlan::makePersistent
virtual DataObject * makePersistent() const
Definition
L1CaloRampRunPlan.cxx:40
Generated on
for ATLAS Offline Software by
1.17.0