ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7#include <string>
8#include <sstream>
9#include <iostream>
10
11// AttributeList
12#include "CoralBase/AttributeListSpecification.h"
14
15#include "GaudiKernel/MsgStream.h"
16
17
19 m_bEndOfRampRun(false),
23{
24 this->addSpecification(eEventsPerStep, std::string("EventsPerStep"), std::string("int") );
25 this->addSpecification(eEnergySteps, std::string("EnergySteps"), std::string("string"));
26}
27
28L1CaloRampRunPlan::L1CaloRampRunPlan(int nEventsPerStep, const std::vector<double>& vEnergySteps): AbstractL1CaloPersistentCondition("AthenaAttributeList"),
29 m_bEndOfRampRun(false),
30 m_nEventsPerStep(nEventsPerStep),
31 m_vEnergySteps(vEnergySteps),
33{
34 this->addSpecification(eEventsPerStep, std::string("EventsPerStep"), std::string("int") );
35 this->addSpecification(eEnergySteps, std::string("EnergySteps"), std::string("string"));
36
38}
39
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
68void 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);
83}
84
86 if(m_bEndOfRampRun) {
87 return;
88 }
89
91
96 } else {
97 m_iCurrentEvent = -1;
98 m_bEndOfRampRun = true;
99 return;
100 }
101 }
102}
103
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
115std::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
std::ostream & operator<<(std::ostream &output, const L1CaloRampRunPlan &rplan)
static Double_t ss
AbstractL1CaloPersistentCondition(const std::string &condType)
void addSpecification(int specId, const std::string &specName, const std::string &specType)
coral::AttributeListSpecification * createAttributeListSpecification() const
An AttributeList represents a logical row of attributes in a metadata table.
std::vector< double >::iterator m_itCurrentStep
int eventsPerStep() const
virtual void makeTransient(const AthenaAttributeList *&attributeList)
std::vector< double > m_vEnergySteps
const std::vector< double > & energySteps() const
virtual DataObject * makePersistent() const