ATLAS Offline Software
Loading...
Searching...
No Matches
IOVDbCoolFunctions.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4//@file IOVDbCoolFunctions.h
5//@brief Numeric and COOL/Coral dependent helper functions
6//@author Shaun Roe
7#ifndef IOVDbSvc_IOVDbCoolFunctions_h
8#define IOVDbSvc_IOVDbCoolFunctions_h
9#include "CoolKernel/ChannelId.h"
10#include "CoolKernel/ValidityKey.h"
11
13//
14#include <utility>
15#include <vector>
16#include <algorithm>
17#include <functional>
18#include <string>
19
20
21class IOVRange;
22class IOVDbConn;
23
24namespace coral{
25 class AttributeListSpecification;
26 class AttributeSpecification;
27 class AttributeList;
28 class Attribute;
29}
30namespace cool{
31 class ChannelSelection;
32}
33
34namespace IOVDbNamespace{
36 constexpr unsigned long long ALL_LUMI_BLOCKS{0xFFFFFFFF};
37
40 template <class NumericType>
41 bool
42 inRange(const NumericType & val, const std::pair<NumericType, NumericType> & range){
43 return (val>=range.first && val<=range.second);
44 }
45
46 template <class NumericType>
47 bool
48 inRange(const NumericType & val, const std::vector<std::pair<NumericType, NumericType> > & ranges){
49 auto valueInRange=[val](const std::pair<NumericType, NumericType> & range){ return inRange(val,range); };
50 return std::any_of(ranges.begin(), ranges.end(), valueInRange);
51 }
52
54 const coral::AttributeListSpecification &
55 attrList2Spec(const coral::AttributeList& atrlist);
56
58 unsigned int
59 attributeSize(const coral::Attribute & attribute);
60
62 bool
63 typeSizeIsKnown(const coral::Attribute & attribute);
64
66 unsigned int
67 attributeListSize(const coral::AttributeList& atrlist);
68
70 int
71 countSelectedChannels(const std::vector<cool::ChannelId> & channels, const cool::ChannelSelection & selected);
72
75 makeEpochOrRunLumi(const cool::ValidityKey key, const bool timeIsEpoch);
76
78 unsigned long long
79 iovTimeFromSeconds(const unsigned long long seconds);
80
82 unsigned long long
83 iovTimeFromRunLumi(const unsigned long long run, const unsigned long long lumi=0);
84
86 std::pair<unsigned long long, unsigned long long>
87 runLumiFromIovTime(const unsigned long long iovTime);
88
91 makeRange(const cool::ValidityKey since,const cool::ValidityKey until,const bool timeIsEpoch);
92
94 cool::ChannelId
95 makeChannel(const std::string& strval, const cool::ChannelId defchan);
96
98 std::pair<bool, std::string>
99 folderMetadata(IOVDbConn * pConnection, const std::string & folderName);
100
102 std::pair<std::vector<cool::ChannelId>, std::vector<std::string>>
103 channelList(IOVDbConn * pConnection, const std::string & folderName, const bool named=false);
104
105}
106
107#endif
Basic time unit for IOVSvc.
Validity Range object.
Definition IOVRange.h:30
Basic time unit for IOVSvc.
Definition IOVTime.h:33
bool inRange(const NumericType &val, const std::pair< NumericType, NumericType > &range)
Function to check whether a number is in the inclusive range, given as a pair.
int countSelectedChannels(const std::vector< cool::ChannelId > &channels, const cool::ChannelSelection &selected)
Count the number of selected channels in a vector of channels according to cool::Channel selection.
unsigned int attributeListSize(const coral::AttributeList &atrlist)
return the size (in bytes) of an AttributeList
unsigned int attributeSize(const coral::Attribute &attribute)
return the size (in bytes) of an Attribute
std::pair< unsigned long long, unsigned long long > runLumiFromIovTime(const unsigned long long iovTime)
Return a [run,lumi] pair from an IOV time.
bool typeSizeIsKnown(const coral::Attribute &attribute)
Return a bool indicating whether the size of a given Attribute can be determined.
std::pair< bool, std::string > folderMetadata(IOVDbConn *pConnection, const std::string &folderName)
Retrieve (bool) multiversion flag and folder description.
const coral::AttributeListSpecification & attrList2Spec(const coral::AttributeList &atrlist)
return the AttributeListSpecification of an AttributeList
IOVTime makeEpochOrRunLumi(const cool::ValidityKey key, const bool timeIsEpoch)
Create an IOVTime in ns of epoch or run-lumi (determined by the bool) from a ValidityKey.
std::pair< std::vector< cool::ChannelId >, std::vector< std::string > > channelList(IOVDbConn *pConnection, const std::string &folderName, const bool named)
Retrieve channel information.
unsigned long long iovTimeFromSeconds(const unsigned long long seconds)
Create a long long time in ns from s.
constexpr unsigned long long ALL_LUMI_BLOCKS
All the lumi blocks in one run.
cool::ChannelId makeChannel(const std::string &strval, const cool::ChannelId defchan)
Create a ChannelId from a string; if string is empty, return the default channel number given.
unsigned long long iovTimeFromRunLumi(const unsigned long long run, const unsigned long long lumi)
Create a long long representing the IOV from run, lumi.
IOVRange makeRange(const cool::ValidityKey since, const cool::ValidityKey until, const bool timeIsEpoch)
Make an IOVRange from two validity keys.
Definition run.py:1