35 std::vector<IovHashPair>
37 std::vector<IovHashPair> iovHashPairs;
39 std::string_view iovSignature =
"since\":";
40 std::string_view hashSignature =
"payloadHash\":\"";
41 size_t startpoint = jsonReply.find(hashSignature);
44 while(startpoint!=std::string::npos) {
45 startpoint+=hashSignature.size();
46 endpoint = jsonReply.find(
'\"',startpoint);
47 if(endpoint==std::string::npos) {
51 std::string_view hashString = jsonReply.substr(startpoint,endpoint-startpoint);
52 startpoint= jsonReply.find(iovSignature,endpoint);
53 if(startpoint==std::string::npos) {
57 startpoint+=iovSignature.size();
58 endpoint = jsonReply.find(
',',startpoint);
59 if(endpoint==std::string::npos) {
63 std::string_view iovString = jsonReply.substr(startpoint,endpoint-startpoint);
64 iovHashPairs.emplace_back(iovString,hashString);
65 startpoint= jsonReply.find(hashSignature,endpoint);
68 std::cerr<<__FILE__<<
":"<<__LINE__<<
": Formatting error found while trying to extract IOVs and Hashes from "<<jsonReply<<std::endl;
78 std::string_view signature=
"payloadHash\":\"";
79 auto signaturePosition=jsonReply.rfind(signature);
80 if (signaturePosition == std::string::npos)
throw std::runtime_error(
"signature "+std::string(signature)+
" not found");
81 auto startOfHash=signaturePosition + signature.size();
82 auto endOfHash=jsonReply.find(
'\"',startOfHash);
83 auto len=endOfHash-startOfHash;
84 if (startOfHash > jsonReply.size())
throw std::runtime_error(
"Hash start is beyond end of string");
85 hash=jsonReply.substr(startOfHash, len);
87 std::cout<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the hash in "<<jsonReply<<std::endl;
92 std::vector<IovHashPair>
94 std::string reply{R
"delim([{"insertionTime":"2022-05-26T12:10:58+0000","payloadHash":"99331506eefbe6783a8d5d5bc8b9a44828a325adfcaac32f62af212e9642db71","since":0,"tagName":"LARIdentifierFebRodMap-RUN2-000"}])delim"};
99 reply = myCrestClient.findAllIovs(
tag).dump();
101 std::cout<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the IOVs"<<std::endl;
112 std::string reply{R
"delim([{"insertionTime":"2022-05-26T12:10:58+0000","payloadHash":"99331506eefbe6783a8d5d5bc8b9a44828a325adfcaac32f62af212e9642db71","since":0,"tagName":"LARIdentifierFebRodMap-RUN2-000"}])delim"};
117 reply = myCrestClient.findAllIovs(
tag).dump();
119 std::cout<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the IOVs"<<std::endl;
129 std::string reply{R
"delim({"data":{"0":["[DB=B2E3B2B6-B76C-DF11-A505-000423D5ADDA][CNT=CollectionTree(LArTTCell_P/LArTTCellMapAtlas)][CLID=DF8C509C-A91A-40B5-B76C-5B57EEE21EC3][TECH=00000202][OID=00000003-00000000]"]}})delim"};
134 reply = myCrestClient.getPayloadAsString(
hash);
136 std::cout<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the payload"<<std::endl;
152 const std::string_view signature=
"node_description\\\":\\\"";
153 const auto signaturePosition = jsonReply.find(signature);
154 if (signaturePosition == std::string::npos)
throw std::runtime_error(
"signature "+std::string(signature)+
" not found");
155 const auto startOfDescription= signaturePosition + signature.size();
156 const std::string_view endSignature =
"\\\",\\\"payload_spec";
157 const auto endOfDescription=jsonReply.find(endSignature);
158 if (endOfDescription == std::string::npos)
throw std::runtime_error(
"end signature "+std::string(endSignature)+
" not found");
159 const auto len=endOfDescription-startOfDescription;
160 description=jsonReply.substr(startOfDescription, len);
162 std::cout<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the description in "<<jsonReply<<std::endl;
172 const std::string_view signature=
"payload_spec\\\":\\\"";
173 const auto signaturePosition = jsonReply.find(signature);
174 if (signaturePosition == std::string::npos)
throw std::runtime_error(
"signature "+std::string(signature)+
" not found");
175 const auto startOfSpec= signaturePosition + signature.size();
176 const auto endOfSpec=jsonReply.find(
"\\\"}\"",startOfSpec);
177 const auto len=endOfSpec-startOfSpec;
178 spec=jsonReply.substr(startOfSpec, len);
180 std::cout<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
" while trying to find the payload spec in "<<jsonReply<<std::endl;
185 std::pair<std::vector<cool::ChannelId> , std::vector<std::string>>
187 std::vector<cool::ChannelId>
list;
188 std::vector<std::string>
names;
191 const std::string_view signature=
"channel_list\\\":[";
192 const auto startOfList=jsonReply.find(signature) + signature.size();
193 const auto endOfList=jsonReply.find(
']', startOfList);
194 const auto len=endOfList-startOfList;
195 textRep=jsonReply.substr(startOfList, len);
197 std::cout<<__FILE__<<
":"<<__LINE__<<
": "<<
e.what()<<
"\n while trying to find the description in "<<jsonReply<<std::endl;
200 std::string
s=R
"d(\{\\\"([0-9]+)\\\":\\\"([^\"]*)\"},?)d";
202 std::sregex_iterator it(textRep.begin(), textRep.end(), r);
203 std::sregex_iterator end;
205 const std::smatch&
m= *
it;
207 list.push_back(std::stoll(
m[1].
str()));
209 std::string
s =
m[2].str();
211 names.emplace_back(std::move(
s));
215 auto isEmpty=[](
const std::string &
s){
return s.empty();};
217 return std::make_pair(std::move(
list), std::move(
names));
222 std::string jsonReply{R
"delim({"format":"TagMetaSetDto","resources":[{"tagName":"LARAlign-RUN2-UPD4-03","description":"{\"dbname\":\"CONDBR2\",\"nodeFullpath\":\"/LAR/Align\",\"schemaName\":\"COOLONL_LAR\"}","chansize":1,"colsize":1,"tagInfo":"{\"channel_list\":[{\"0\":\"\"}],\"node_description\":\"<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\\\"256\\\" clid=\\\"1238547719\\\" /></addrHeader><typeName>CondAttrListCollection</typeName><updateMode>UPD1</updateMode>\",\"payload_spec\":\"PoolRef:String4k\"}","insertionTime":"2022-05-26T12:10:38+0000"}],"size":1,"datatype":"tagmetas","format":null,"page":null,"filter":null})delim"};
225 jsonReply= myCrestClient.getTagMetaInfo(
tag).dump();
232 std::string jsonReply{R
"delim({"folder_payloadspec": "PoolRef: String4k"})delim"};
235 jsonReply= myCrestClient.getTagMetaInfo(specTag).dump();
240 std::pair<std::vector<cool::ChannelId> , std::vector<std::string>>
242 std::string reply{R
"delim([{"chansize":8,"colsize":5,"description":"{\"dbname\":\"CONDBR2\",\"nodeFullpath\":\"/LAR/BadChannelsOfl/BadChannels\",\"schemaName\":\"COOLOFL_LAR\"}","insertionTime":"2022-05-26T16:40:32+0000","tagInfo":"{\"channel_list\":[{\"0\":\"\"},{\"1\":\"\"},{\"2\":\"\"},{\"3\":\"\"},{\"4\":\"\"},{\"5\":\"\"},{\"6\":\"\"},{\"7\":\"\"}],\"node_description\":\"<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\\\"71\\\" clid=\\\"1238547719\\\" /></addrHeader><typeName>CondAttrListCollection</typeName>\",\"payload_spec\":\"ChannelSize:UInt32,StatusWordSize:UInt32,Endianness:UInt32,Version:UInt32,Blob:Blob64k\"}","tagName":"LARBadChannelsOflBadChannels-RUN2-UPD4-21"}])delim"};
245 reply= myCrestClient.getTagMetaInfo(
tag).dump();
253 if (not forceTag.empty())
return forceTag;
254 if (testing)
return "LARAlign-RUN2-UPD4-03";
256 auto j = crestClient.findGlobalTagMap(globalTagName);
257 for (
const auto &
i:j){
259 result=
static_cast<std::string
>(
i[
"tagName"]);
271 std::map<std::string, std::string>
273 std::map<std::string, std::string> tagmap;
278 for (
int i = 0;
i <
n;
i++ ){
280 if (j_item.contains(
"label") && j_item.contains(
"tagName") ){
281 tagmap[j_item[
"label"]] = j_item[
"tagName"];
285 std::cout<<__FILE__<<
":"<<__LINE__<<
": " <<
e.what() <<
" Cannot get a global tag map for " <<
globaltag << std::endl;
297 if (meta_info.contains(
"tagInfo")){
298 return crestClient.getJson(meta_info[
"tagInfo"]);
302 std::cout<<__FILE__<<
":"<<__LINE__<<
": " <<
e.what() <<
" Cannot get a tag meta info " <<
tag << std::endl;
310 return crestClient.findTag(
tag)[0];
313 std::cout<<__FILE__<<
":"<<__LINE__<<
": " <<
e.what() <<
" Cannot get a tag Properties of " <<
tag << std::endl;
319 if (tag_info.contains(
key)){
320 if (
key ==
"channel_list"){
321 return tag_info[
key].dump();
324 return tag_info[
key];
330 std::pair<std::vector<cool::ChannelId> , std::vector<std::string>>
332 std::vector<cool::ChannelId>
list;
333 std::vector<std::string>
names;
337 for (
int i = 0;
i <=
n;
i++) {
339 for (
auto& [
key,
val] : j_object.items()){
340 list.push_back(std::stoll(
key));
346 auto isEmpty=[](
const std::string &
s){
return s.empty();};
348 return std::make_pair(std::move(
list), std::move(
names));