14#include "CoolKernel/ConstRecordAdapter.h"
15#include "CoolKernel/FolderSpecification.h"
16#include "CoralBase/Attribute.h"
17#include "CoralBase/AttributeList.h"
67 ATH_MSG_FATAL(
"Configuration error: Number of folders and tags do not match!");
68 return StatusCode::FAILURE;
81 }
catch (cool::DatabaseDoesNotExist &e) {
85 }
catch (cool::Exception &e) {
86 ATH_MSG_FATAL(
"Cannot create database and datbasae does not exist!");
87 return StatusCode::FAILURE;
104 int iov_start(-1), iov_end(-1);
110 ATH_MSG_FATAL(
"IOV has to be set, if no calibration source provides it!");
111 return StatusCode::FAILURE;
128 return StatusCode::SUCCESS;
134 for (
auto & i :
m_mdtt0_fld) i->flushStorageBuffer();
135 for (
auto & i :
m_mdtrt_fld) i->flushStorageBuffer();
136 }
catch (std::exception &e) {
138 return StatusCode::FAILURE;
140 return StatusCode::SUCCESS;
149 return StatusCode::FAILURE;
152 return StatusCode::SUCCESS;
158 m_sid.SetMultilayer(0);
162 if (MuonDetMgr ==
nullptr) {
163 ATH_MSG_ERROR(
"Null pointer to the read MuonDetectorManager conditions object");
167 if (!
m_sid.InitializeGeometry(
m_idHelperSvc->mdtIdHelper(), MuonDetMgr))
return false;
171 for (
int ml = 0; ml <
m_sid.NMultilayers(); ml++) {
172 if (max_nly <
m_sid.NLayers(ml)) max_nly =
m_sid.NLayers(ml);
173 if (max_ntb <
m_sid.NTubes(ml)) max_ntb =
m_sid.NTubes(ml);
209 for (
unsigned int i = 0; i <
m_t0_folder.size(); i++) {
219 cool::RecordSpecification mdtt0_rec = (
m_mdtt0_fld[i]->payloadSpecification());
220 bool compressed(
false);
228 it.second[
"file"].data<cool::String4k>() =
file;
229 it.second[
"tech"].data<
int>() = creation_flags;
232 coral::Blob &blob(it.second[
"data"].data<coral::Blob>());
233 blob.resize(dest_len);
234 Bytef *p =
static_cast<Bytef *
>(blob.startingAddress());
237 blob.resize(dest_len);
239 it.second[
"data"].data<cool::String16M>() =
m_data_string.str();
241 for (
unsigned int i = 0; i <
m_mdtt0_fld.size(); i++) {
251 unsigned int creation_flags) {
258 for (
int i = 0; i < 3; i++) {
262 if (
id.GetMl() == 0) {
263 if (found[0] || (found[1] && found[2]))
return true;
268 if (
id.GetMl() != 0) {
269 if (found[0] || found[
id.GetMl()])
return true;
273 for (
unsigned int i = 0; i <
m_rt_folder.size(); i++) {
283 cool::RecordSpecification mdtrt_rec = (
m_mdtrt_fld[i]->payloadSpecification());
284 bool compressed(
false);
290 std::ostringstream data_column;
291 data_column << id_cp.
FixedId() <<
"," << points.size() << std::endl;
292 for (
const auto & point : points) {
293 data_column << point.second.x2() <<
"," << point.second.x1() <<
"," << point.second.error() <<
",";
297 it.second[
"tech"].data<
int>() = creation_flags;
298 it.second[
"file"].data<cool::String4k>() =
file;
300 uLongf dest_len = compressBound(data_column.str().size());
301 coral::Blob &blob(it.second[
"data"].data<coral::Blob>());
302 blob.resize(dest_len);
303 Bytef *p =
static_cast<Bytef *
>(blob.startingAddress());
305 compress(p, &dest_len,
reinterpret_cast<const Bytef *
>(data_column.str().c_str()), data_column.str().size());
306 blob.resize(dest_len);
308 it.second[
"data"].data<cool::String16M>() = data_column.str();
311 for (
unsigned int i = 0; i <
m_mdtrt_fld.size(); i++) {
325 "<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"1238547719\" "
326 "/></addrHeader><typeName>CondAttrListCollection</typeName><key>") +
331 "<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"1238547719\" "
332 "/></addrHeader><typeName>CondAttrListCollection</typeName><key>") +
336 bool compressed(
false);
344 cool::RecordSpecification spec;
345 spec.extend(
"tech", cool::StorageType::Int32);
347 spec.extend(
"file", cool::StorageType::String255);
348 spec.extend(
"data", cool::StorageType::Blob64k);
350 spec.extend(
"file", cool::StorageType::String4k);
352 spec.extend(
"data", cool::StorageType::String4k);
354 spec.extend(
"data", cool::StorageType::String16M);
357 cool::FolderSpecification fspec(cool::FolderVersioning::MULTI_VERSION, spec);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Basic time unit for IOVSvc.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Basic time unit for IOVSvc.
static constexpr uint64_t MAXTIMESTAMP
std::vector< std::string > m_t0_folder
std::vector< std::string > m_tagrt
CoolInserter(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandleArray< IMuonCalibConditionsSource > m_calibration_sources
std::map< bool, coral::AttributeList > m_mdtrt_cool_row
StatusCode finalize()
finalize functions
StatusCode execute()
execute function NOTE: This will read all events at once
bool AppendT0(float t0, int validflag, float adc0)
bool StartT0Chamber(const NtupleStationId &sid)
std::vector< bool > m_compressed_rt
std::vector< cool::IFolderPtr > m_mdtt0_fld
std::map< bool, coral::AttributeList > m_mdtt0_cool_row
std::set< NtupleStationId > m_rt_filled
bool create_folder(const unsigned int &fldr_nr, const bool &is_rt)
StatusCode initialize()
Is called at the beginning of the analysis.
std::set< NtupleStationId > m_t0_filled
bool StoreT0Chamber(const NtupleStationId &id, const std::string &file, unsigned int creation_flags=0)
std::string m_cool_connection_string
std::vector< bool > m_compressed_t0
bool StoreRtChamber(const NtupleStationId &id, const std::map< int, SamplePoint > &points, const std::string &file, unsigned int creation_flags=0)
std::ostringstream m_data_string
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
ServiceHandle< RegionSelectionSvc > m_reg_sel_svc
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
std::vector< cool::IFolderPtr > m_mdtrt_fld
std::vector< std::string > m_tagt0
std::vector< std::string > m_rt_folder
Implements fixed identifiers not dependent upon Athena Identifier for internal use in the calibration...
Station Identifier for sorting calibration data.
void SetMultilayer(const int &ml)
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const_pointer_type cptr()
std::string description
glabal timer - how long have I taken so far?
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.