17 #include "GaudiKernel/ConcurrencyFlags.h"
27 const std::string&
name,
28 ISvcLocator* pSvcLocator)
38 ATH_CHECK(m_currInputKey.initialize(m_useDCS));
41 ATH_CHECK(m_mapCondObjInputKey.initialize());
44 ATH_CHECK(m_condObjOutputKey.initialize());
46 ATH_MSG_DEBUG(
"Initialize: Key " << m_condObjOutputKey.fullKey()
47 <<
" has been succesfully registered ");
50 (m_useDCS ?
"conditions" :
"parameters"));
52 ATH_MSG_INFO(
"Initialize: useDCS, useSoleCurrent, useToroCurrent. "
53 << (
int)m_useDCS <<
", " << m_useSoleCurrent <<
", "
54 << m_useToroCurrent <<
" LockMapCurrents "
55 << (
int)m_lockMapCurrents);
57 return StatusCode::SUCCESS;
70 if (writeHandle.isValid()) {
72 << writeHandle.fullKey() <<
" is already valid. "
73 <<
" May happen if multiple concurrent events are being "
74 "processed out of order.");
75 return StatusCode::SUCCESS;
82 ATH_CHECK(updateCurrentFromConditions(ctx, cache));
84 ATH_CHECK(updateCurrentFromParameters(ctx, cache));
91 if (mapCondObj ==
nullptr) {
92 ATH_MSG_ERROR(
"execute: Could not access conditions map for key: "
93 << m_mapCondObjInputKey.fullKey());
94 return StatusCode::FAILURE;
102 if (!m_lockMapCurrents) {
103 scaleField(cache, fieldMap);
107 auto fieldCondObj = std::make_unique<AtlasFieldCacheCondObj>();
111 fieldCondObj->initialize(
112 cache.m_solScaleFactor, cache.m_torScaleFactor, fieldMap);
116 if (writeHandle.record(cache.m_condObjOutputRange, std::move(fieldCondObj))
119 "execute: Could not record AtlasFieldCacheCondObj object with "
120 << writeHandle.key() <<
" with EventRange " << cache.m_condObjOutputRange
121 <<
" into Conditions Store");
122 return StatusCode::FAILURE;
126 "execute: initialized AtlasFieldCacheCondObj and cache with SFs - sol/tor "
127 << cache.m_solScaleFactor <<
"/" << cache.m_torScaleFactor
128 <<
", EventRange " << cache.m_condObjOutputRange);
135 return StatusCode::SUCCESS;
140 const EventContext& ctx,
147 if (attrListColl ==
nullptr) {
148 ATH_MSG_ERROR(
"updateCurrentFromConditions: Failed to retrieve "
149 "CondAttributeListCollection with key "
150 << m_currInputKey.key());
151 return StatusCode::FAILURE;
156 if (!readHandle.range(rangeW)) {
158 "updateCurrentFromConditions: Failed to retrieve validity range for "
159 << readHandle.key());
160 return StatusCode::FAILURE;
163 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Range of input/output is "
169 bool gotsol{
false };
170 bool gottor{
false };
177 bool hasChanNames{
false };
178 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Attempt 1 at reading currents "
179 "from DCS (using channel name)");
181 itr != attrListColl->end();
183 const std::string&
name = attrListColl->chanName(itr->first);
184 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Trying to read from DCS: "
185 "[channel name, index, value] "
186 <<
name <<
" , " << itr->first <<
" , "
187 << itr->second[
"value"].data<
float>());
188 if (
name.compare(
"") != 0) {
191 if (
name.compare(
"CentralSol_Current") == 0) {
193 solcur = itr->second[
"value"].data<
float>();
195 }
else if (
name.compare(
"Toroids_Current") == 0) {
197 torcur = itr->second[
"value"].data<
float>();
202 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Attempt 2 at reading currents "
203 "from DCS (using channel index)");
206 itr != attrListColl->end();
209 if (itr->first == 1) {
211 solcur = itr->second[
"value"].data<
float>();
213 }
else if (itr->first == 3) {
215 torcur = itr->second[
"value"].data<
float>();
220 if (!gotsol || !gottor) {
222 ATH_MSG_ERROR(
"UpdateCurrentFromConditions: Missing solenoid current in "
225 ATH_MSG_ERROR(
"UpdateCurrentFromConditions: Missing toroid current in "
227 return StatusCode::FAILURE;
230 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Currents read from DCS - solenoid "
231 << solcur <<
" toroid " << torcur);
234 if (solcur < m_soleMinCurrent) {
236 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Solenoid is off");
238 if (torcur < m_toroMinCurrent) {
240 ATH_MSG_INFO(
"UpdateCurrentFromConditions: Toroids are off");
246 return StatusCode::SUCCESS;
251 const EventContext& ctx,
256 double solcur{ m_useSoleCurrent };
257 double torcur{ m_useToroCurrent };
258 if (solcur < m_soleMinCurrent) {
260 ATH_MSG_INFO(
"updateCurrentFromParameters: Solenoid is off");
262 if (torcur < m_toroMinCurrent) {
264 ATH_MSG_INFO(
"updateCurrentFromParameters: Toroids are off");
272 start.set_run_number(ctx.eventID().run_number());
273 start.set_lumi_block(0);
274 stop.set_run_number(ctx.eventID().run_number() + 1);
275 stop.set_lumi_block(0);
278 ATH_MSG_INFO(
"updateCurrentFromParameters: Update from job options: Range of "
282 return StatusCode::SUCCESS;
296 bool mapHasToroid = fieldMap && (fieldMap->
toroidCurrent()>0);
303 if (mapHasSolenoid &&
311 <<
". Desired current and map current: "
320 <<
". Desired current and map current: "
337 <<
". Desired current and map current: "
344 <<
". Desired current and map current: "
350 if (mapHasToroid && !mapHasSolenoid) {
355 if (!mapHasToroid && mapHasSolenoid) {