18 ATH_MSG_WARNING(
"You have activated the retrieval of the pslope per CSC channel from the COOL database. "
19 <<
"Please make sure that a correct PSLOPE database is in place which uses geometrical CSC hashes in hex format "
20 <<
"as keys and different values of the pslopes for the different CSC channels as values, otherwise please run "
21 <<
"with the ReadPSlopeFromDatabase property set to false");
24 if (!(pslope > 0 && pslope < 1)) {
25 ATH_MSG_FATAL(
"The Pslope cannot be set to a value <=0 or >=1");
26 return StatusCode::FAILURE;
29 <<
"). Please check whether this is really intended.");
43 return StatusCode::SUCCESS;
54 <<
" In theory this should not be called, but may happen"
55 <<
" if multiple concurrent events are being processed out of order.");
56 return StatusCode::SUCCESS;
58 std::unique_ptr<CscCondDbData> writeCdo{std::make_unique<CscCondDbData>()};
81 if (writeHandle.
record(std::move(writeCdo)).isFailure()) {
82 ATH_MSG_FATAL(
"Could not record CscCondDbData " << writeHandle.
key() <<
" with EventRange " << writeHandle.
getRange()
83 <<
" into Conditions Store");
84 return StatusCode::FAILURE;
86 ATH_MSG_DEBUG(
"Recorded new " << writeHandle.
key() <<
" with range " << writeHandle.
getRange() <<
" into Conditions Store");
88 return StatusCode::SUCCESS;
95 if (readCdo ==
nullptr) {
97 return StatusCode::FAILURE;
101 ATH_MSG_DEBUG(
"Size of CondAttrListCollection " << readHandle.
fullKey() <<
" readCdo->size()= " << readCdo->
size());
105 std::map<Identifier, int> layerMap;
106 int hv_state, lv_state, hv_setpoint0, hv_setpoint1;
107 unsigned int chan_index = 0;
108 for (itr = readCdo->
begin(); itr != readCdo->
end(); ++itr) {
109 unsigned int chanNum = readCdo->
chanNum(chan_index);
110 const std::string& csc_chan_name = readCdo->
chanName(chanNum);
112 const coral::AttributeList& atr = itr->second;
115 hv_state = *(
static_cast<const int*
>((atr[
"HVState"]).addressOfData()));
116 lv_state = *(
static_cast<const int*
>((atr[
"LVState"]).addressOfData()));
117 hv_setpoint0 = *(
static_cast<const int*
>((atr[
"HVSetpoint0"]).addressOfData()));
118 hv_setpoint1 = *(
static_cast<const int*
>((atr[
"HVSetpoint1"]).addressOfData()));
120 std::string_view delimiter{
"_"};
123 if ((hv_state != 1 or lv_state != 1 or hv_setpoint0 < 1000 or hv_setpoint1 < 1000) && !tokens.empty()) {
124 std::string_view layer = tokens[1];
125 std::string number_layer = tokens[1].substr(1, 2);
129 char eta_side = tokens[0][0];
130 if (eta_side ==
'A')
eta = +1;
131 if (eta_side ==
'C')
eta = -1;
133 std::string chamber_name;
134 char size_side = tokens[0][1];
135 if (size_side ==
'L') chamber_name =
"CSL";
136 else if (size_side ==
'S') chamber_name =
"CSS";
139 std::string sector_side = tokens[0].substr(2, 4);
140 if (sector_side ==
"01" || sector_side ==
"02")
phi = 1;
141 else if (sector_side ==
"03" || sector_side ==
"04")
phi = 2;
142 else if (sector_side ==
"05" || sector_side ==
"06")
phi = 3;
143 else if (sector_side ==
"07" || sector_side ==
"08")
phi = 4;
144 else if (sector_side ==
"09" || sector_side ==
"10")
phi = 5;
145 else if (sector_side ==
"11" || sector_side ==
"12")
phi = 6;
146 else if (sector_side ==
"13" || sector_side ==
"14")
phi = 7;
147 else if (sector_side ==
"15" || sector_side ==
"16")
phi = 8;
151 std::string WireLayerstring = std::string(chamber_name);
152 WireLayerstring +=
'_';
153 WireLayerstring += eta_side;
154 WireLayerstring +=
'_';
155 WireLayerstring += sector_side;
156 WireLayerstring +=
'_';
157 WireLayerstring += layer;
160 int& mapval = layerMap[ChamberId];
162 if (mapval == 3) writeCdo->
setDeadStation(chamber_name, ChamberId);
168 return StatusCode::SUCCESS;
175 return loadData(writeCdo, *readHandle,
"f001");
182 return loadData(writeCdo, *readHandle,
"noise");
189 return loadData(writeCdo, *readHandle,
"ped");
196 return loadData(writeCdo, *readHandle,
"pslope");
203 return loadData(writeCdo, *readHandle,
"rms");
210 return loadData(writeCdo, *readHandle,
"status");
217 return loadData(writeCdo, *readHandle,
"t0base");
224 return loadData(writeCdo, *readHandle,
"t0phase",
true);
232 for (itr = readCdo->
begin(); itr != readCdo->
end(); ++itr) {
233 const coral::AttributeList& atr = itr->second;
234 std::string
data = atr[
"Data"].data<std::string>();
237 std::istringstream
ss(
data);
247 if (version ==
"02-00" && parAsm) {
249 ATH_MSG_ERROR(
"Failed caching from COOL string version 02-00 in ASM format");
250 return StatusCode::FAILURE;
252 }
else if (version ==
"02-00") {
253 if (!
cache(
data, writeCdo, parName).isSuccess()) {
254 ATH_MSG_ERROR(
"Failed caching from COOL string version 02-00");
255 return StatusCode::FAILURE;
260 ATH_MSG_WARNING(
"Don't recognize CSC COOL string version " << version <<
". Will treat as default version "
264 ATH_MSG_ERROR(
"Failed caching from COOL string version 02-00 in ASM format");
265 return StatusCode::FAILURE;
268 if (!
cache(
data, writeCdo, parName).isSuccess()) {
269 ATH_MSG_ERROR(
"Failed caching from COOL string version 02-00");
270 return StatusCode::FAILURE;
275 <<
". Currently, only version 02-00 is supported. The keys of the database have to be geometrical CSC hashes "
277 return StatusCode::FAILURE;
282 return StatusCode::SUCCESS;
286 std::istringstream
ss(
data);
287 std::string valueStr;
288 unsigned int chanAddress = 0;
290 bool started =
false;
294 if (valueStr ==
"<END_DATA>")
break;
296 if (valueStr ==
"<BEGIN_DATA>") {
300 if (!started)
continue;
302 std::istringstream iss(valueStr);
305 if (chanAddress == 0) {
306 iss >> std::hex >> chanAddress;
311 if (
recordParameter(chanAddress, valueStr, writeCdo, parName).isFailure())
return StatusCode::FAILURE;
317 return StatusCode::SUCCESS;
321 std::istringstream
ss(
data);
322 std::string valueStr;
323 std::string chanAddress;
324 bool setAddress =
false;
326 bool started =
false;
330 if (valueStr ==
"<END_DATA>")
break;
332 if (valueStr ==
"<BEGIN_DATA>") {
336 if (!started)
continue;
338 std::istringstream iss(valueStr);
350 int asmNum = atoi(chanAddress.substr(3, 1).c_str());
353 if (chanAddress[5] ==
'A')
355 else if (chanAddress[5] ==
'C')
358 ATH_MSG_FATAL(
"Bad ASMID String in CSC COOL database \"" << chanAddress <<
"\" (wheel " << chanAddress[5] <<
" doesn't exist!");
359 return StatusCode::FAILURE;
362 int stationPhi = atoi(chanAddress.substr(6, 1).c_str());
363 int stationName = atoi(chanAddress.substr(8, 2).c_str());
366 ATH_MSG_FATAL(
"Bad ASMID String in CSC COOL database: \"" << chanAddress <<
"\"");
368 return StatusCode::FAILURE;
371 int chamberLayer = 2;
378 if (!
getAsmScope(asmNum, measuresPhi, layerSince, layerUntil, stripSince, stripUntil).isSuccess()) {
380 return StatusCode::FAILURE;
384 unsigned int index = 0;
387 for (
int iStrip = stripSince; iStrip < stripUntil; iStrip++) {
388 for (
int iLayer = layerSince; iLayer < layerUntil; iLayer++) {
396 static std::atomic<bool> conversionFailPrinted =
false;
398 if (!conversionFailPrinted.load()) {
400 "Failed to retrieve offline identifier from ASM cool "
403 <<
". This is likely due to the fact that the CSCCool "
405 <<
"more entries than the detector layout.");
406 conversionFailPrinted.store(
true);
410 if (
m_idHelperSvc->cscIdHelper().get_channel_hash(chanId, hashIdentifier)) {
413 index = (int)hashIdentifier;
414 if (
index == UINT_MAX)
continue;
416 ATH_MSG_VERBOSE(
"[cache version 2 (ASM)] Recording " << valueStr <<
" at index " <<
index <<
"\nstationName " << stationName
418 <<
"\nchamberLayer " << chamberLayer <<
"\niLayer " << iLayer
419 <<
"\nmeasuresPhi " << measuresPhi <<
"\niStrip " << iStrip);
422 if (
recordParameter(hashIdentifier, valueStr, writeCdo, parName).isFailure())
return StatusCode::FAILURE;
431 return StatusCode::SUCCESS;
436 int& stripUntil)
const {
445 }
else if (asmNum == 2) {
451 }
else if (asmNum == 3) {
457 }
else if (asmNum == 4) {
463 }
else if (asmNum == 5) {
470 ATH_MSG_FATAL(
"ASM number \"" << asmNum <<
"\" is invalid. It needs to end in a number from 1-5.");
471 return StatusCode::FAILURE;
473 return StatusCode::SUCCESS;
478 const std::string& parName)
const {
485 return StatusCode::SUCCESS;
489 if (
m_idHelperSvc->cscIdHelper().get_channel_hash(channelId, chanHash)) {
490 ATH_MSG_WARNING(
"recordParameter(): Failed to retrieve channel Identifier hash for Identifier " << channelId.get_compact()
491 <<
". Not recording parameter...");
492 return StatusCode::SUCCESS;
501 const std::string& parName)
const {
503 StatusCode
sc = StatusCode::FAILURE;
504 if (parName ==
"f001")
506 else if (parName ==
"noise")
508 else if (parName ==
"ped")
510 else if (parName ==
"pslope")
512 else if (parName ==
"rms")
514 else if (parName ==
"status")
516 else if (parName ==
"t0base")
518 else if (parName ==
"t0phase")
522 ATH_MSG_ERROR(
"Cannot extract parameter " << parName <<
" for channel hash " << chanHash <<
" from data string '" <<
data <<
"'");
529 if (
getParameter(chanHash, std::move(
data), token).isFailure())
return StatusCode::FAILURE;
531 return StatusCode::SUCCESS;
537 if (
getParameter(chanHash, std::move(
data), token).isFailure())
return StatusCode::FAILURE;
539 return StatusCode::SUCCESS;
545 if (
getParameter(chanHash, std::move(
data), token).isFailure())
return StatusCode::FAILURE;
547 return StatusCode::SUCCESS;
554 if (
getParameter(chanHash, std::move(
data), token).isFailure())
return StatusCode::FAILURE;
560 return StatusCode::SUCCESS;
566 if (
getParameter(chanHash, std::move(
data), token).isFailure())
return StatusCode::FAILURE;
568 return StatusCode::SUCCESS;
574 if (
getParameter(chanHash, std::move(
data), token).isFailure())
return StatusCode::FAILURE;
577 return StatusCode::SUCCESS;
583 if (
getParameter(chanHash, std::move(
data), token).isFailure())
return StatusCode::FAILURE;
585 return StatusCode::SUCCESS;
591 if (
getParameter(chanHash, std::move(
data), token).isFailure())
return StatusCode::FAILURE;
593 return StatusCode::SUCCESS;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
char data[hepevt_bytes_allocation_ATLAS]
This class is a collection of AttributeLists where each one is associated with a channel number.
ChanNum chanNum(unsigned int index) const
channel number for index: (index = 0 to size-1)
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
const std::string & chanName(ChanNum chanNum) const
find name for particular channel
size_type size() const
number of Chan/AttributeList pairs
ChanAttrListMap::const_iterator const_iterator
StatusCode onlineToOfflineIds(const CscIdHelper *, const unsigned int &, Identifier &, Identifier &) const
void setChannelStatus(IdentifierHash, int)
void setDeadLayer(std::string_view, Identifier)
void setChannelT0Phase(IdentifierHash, bool)
void setChannelRMS(IdentifierHash, float)
void setDeadStation(std::string_view, Identifier)
void setChannelNoise(IdentifierHash, float)
void setChannelPSlope(IdentifierHash, float)
void setChannelF001(IdentifierHash, float)
void setChannelT0Base(IdentifierHash, float)
void setChannelPed(IdentifierHash, float)
This is a "hash" representation of an Identifier.
value_type get_compact() const
Get the compact id.
StatusCode loadDataT0Base(writeHandle_t &, CscCondDbData *, const EventContext &) const
StatusCode loadData(CscCondDbData *, const CondAttrListCollection *, const std::string &, bool=false) const
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
StatusCode loadDataNoise(writeHandle_t &, CscCondDbData *, const EventContext &) const
virtual StatusCode execute(const EventContext &) const override
StatusCode loadDataHv(writeHandle_t &, CscCondDbData *, const EventContext &) const
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_pslope
Gaudi::Property< float > m_pslope
StatusCode cacheASM(const std::string &, CscCondDbData *, const std::string &) const
StatusCode recordParameterRMS(IdentifierHash, std::string, CscCondDbData *) const
StatusCode loadDataPed(writeHandle_t &, CscCondDbData *, const EventContext &) const
StatusCode loadDataPSlope(writeHandle_t &, CscCondDbData *, const EventContext &) const
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_noise
StatusCode recordParameterStatus(IdentifierHash, std::string, CscCondDbData *) const
StatusCode loadDataRMS(writeHandle_t &, CscCondDbData *, const EventContext &) const
StatusCode loadDataStatus(writeHandle_t &, CscCondDbData *, const EventContext &) const
StatusCode getParameter(IdentifierHash chanHash, std::string data, T &token) const
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_hv
Gaudi::Property< bool > m_pslopeFromDB
The pslope is the gain of each CSC channel.
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_t0base
virtual StatusCode initialize() override
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_f001
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_status
StatusCode recordParameterF001(IdentifierHash, std::string, CscCondDbData *) const
StatusCode recordParameter(unsigned int, const std::string &, CscCondDbData *, const std::string &) const
StatusCode recordParameterPSlope(IdentifierHash, std::string, CscCondDbData *) const
StatusCode getAsmScope(int, int &, int &, int &, int &, int &) const
Gaudi::Property< bool > m_isData
Gaudi::Property< bool > m_isOnline
Gaudi::Property< std::string > m_defaultDatabaseReadVersion
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_ped
SG::WriteCondHandleKey< CscCondDbData > m_writeKey
StatusCode cache(const std::string &, CscCondDbData *, const std::string &) const
StatusCode recordParameterNoise(IdentifierHash, std::string, CscCondDbData *) const
StatusCode recordParameterT0Phase(IdentifierHash, std::string, CscCondDbData *) const
StatusCode loadDataF001(writeHandle_t &, CscCondDbData *, const EventContext &) const
const float m_DEFAULT_PSLOPE
The CSC gain was originally 5.304 ADC counts per fC, but later increased to 5.7 ADC counts per fC,...
Gaudi::Property< bool > m_onlineOfflinePhiFlip
SG::WriteCondHandle< CscCondDbData > writeHandle_t
StatusCode recordParameterPed(IdentifierHash, std::string, CscCondDbData *) const
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_rms
StatusCode recordParameterT0Base(IdentifierHash, std::string, CscCondDbData *) const
StatusCode loadDataT0Phase(writeHandle_t &, CscCondDbData *, const EventContext &) const
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_t0phase
const DataObjID & fullKey() const
const EventIDRange & getRange()
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const
std::vector< std::string > tokenize(const std::string &the_str, std::string_view delimiters)
Splits the string into smaller substrings.
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.