27 return StatusCode::SUCCESS;
34 <<
". In theory this should not be called, but may happen"
35 <<
" if multiple concurrent events are being processed out of order.");
36 return StatusCode::SUCCESS;
39 std::unique_ptr<ALineContainer> writeCdo{std::make_unique<ALineContainer>()};
44 return StatusCode::FAILURE;
53 itr != readHandle->end(); ++itr) {
55 const coral::AttributeList& atr = itr->second;
57 if (atr[
"data"].specification().
type() ==
typeid(coral::Blob)) {
61 return StatusCode::FAILURE;
64 data = *(
static_cast<const std::string*
>((atr[
"data"]).addressOfData()));
67 nlohmann::json lines = nlohmann::json::array();
71 nlohmann::json j = nlohmann::json::parse(
data);
72 lines = j[
"corrections"];
81 if (!inStream.good()) {
83 return StatusCode::FAILURE;
94 return StatusCode::SUCCESS;
100 constexpr std::string_view delimiter{
"\n"};
101 json = nlohmann::json::array();
103 for (
const std::string& blobline : lines) {
105 constexpr std::string_view delimiter {
":"};
108 if (tokens.empty()) {
110 return StatusCode::FAILURE;
112 const std::string_view
type = tokens[0];
114 if (
'#' ==
type[0]) {
118 if (
type.compare(0, 4,
"Corr") == 0) {
125 constexpr std::string_view delimiter{
" "};
127 if (tokens.size() != 12) {
128 ATH_MSG_FATAL(
"Invalid length in string retrieved from DB in folder. String length is "
130 return StatusCode::FAILURE;
140 line[
"typ"] = std::string(tokens[ival++]);
154 if (line.empty())
continue;
155 json.push_back(std::move(line));
157 return StatusCode::SUCCESS;
162 for (
auto& corr : lines.items()) {
163 nlohmann::json line = corr.value();
167 const int jff = line[
"jff"];
168 const int jzz = line[
"jzz"];
169 const int job = line[
"job"];
170 const int jlay = line[
"jlay"];
171 const std::string stationType = line[
"typ"];
172 newILine.
setAmdbId(stationType, jzz, jff, job);
175 bool is_valid{
false};
176 if (stationType[0] ==
'C') {
178 constexpr int chamberLayer = 2;
179 if (job != 3)
ATH_MSG_WARNING(
"job = " << job <<
" is not 3 => chamberLayer should be 1 - not existing ! setting 2");
180 id =
m_idHelperSvc->cscIdHelper().channelID(stationType, jzz, jff, chamberLayer, jlay, 0, 1, is_valid);
184 ATH_MSG_ERROR(
"There is a non CSC chamber in the list of CSC internal alignment parameters.");
185 return StatusCode::FAILURE;
189 newILine.
setParameters(line[
"tras"], line[
"traz"], line[
"trat"],
190 line[
"rots"], line[
"rotz"], line[
"rott"]);
192 const auto insertItr = writeCdo.insert(newILine);
193 if (!insertItr.second) {
194 ATH_MSG_FATAL(
"Could not insert "<<newILine<<
" as "<<(*insertItr.first)<<
" has already been safed before" );
195 return StatusCode::FAILURE;
199 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::set< ALinePar, std::less<> > ALineContainer
char data[hepevt_bytes_allocation_ATLAS]
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
void setParameters(float s, float z, float t, float rotS, float rotZ, float rotT)
Base class for conditions algorithms.
ChanAttrListMap::const_iterator const_iterator
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
StatusCode loadDataFromLegacy(const std::string &data, nlohmann::json &json) const
Load the Alignment data from the legacy format where the channels are parsed line wise The data is th...
SG::WriteCondHandleKey< ALineContainer > m_writeKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_readFromJSON
Load the alignment parameters from a JSON file.
virtual StatusCode execute(const EventContext &ctx) const override
StatusCode parseDataFromJSON(const nlohmann::json &lines, ALineContainer &writeCdo) const
Parse the JSON blob to fill the I Line container.
CscILinesCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< bool > m_newFormat2020
static EventIDRange infiniteTime()
Produces an EventIDRange that is inifinite in Time and invalid in RunLumi.
void setIdentifier(const Identifier &id)
Setters and getters for the Athena Identifier.
void setAmdbId(const std::string &stName, int stEta, int stPhi, int stJob)
AMDB identifiers. They're often not the same as the ATLAS ones (TGCs)
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
bool readBlobAsString(const coral::Blob &, std::string &)
std::vector< std::string > tokenize(const std::string &the_str, std::string_view delimiters)
Splits the string into smaller substrings.
double atof(std::string_view str)
Converts a string into a double / float.
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...