ATLAS Offline Software
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 
12 #include "AthenaKernel/IOVTime.h"
13 //
14 #include <utility>
15 #include <vector>
16 #include <algorithm>
17 #include <functional>
18 #include <string>
19 
20 
21 class IOVRange;
22 class IOVDbConn;
23 
24 namespace coral{
25  class AttributeListSpecification;
26  class AttributeSpecification;
27  class AttributeList;
28  class Attribute;
29 }
30 namespace cool{
31  class ChannelSelection;
32 }
33 
34 namespace 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
68 
70  int
71  countSelectedChannels(const std::vector<cool::ChannelId> & channels, const cool::ChannelSelection & selected);
72 
74  IOVTime
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 
90  IOVRange
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
trigbs_pickEvents.ranges
ranges
Definition: trigbs_pickEvents.py:60
IOVRange
Validity Range object. Holds two IOVTimes (start and stop)
Definition: IOVRange.h:30
IOVDbNamespace::ALL_LUMI_BLOCKS
constexpr unsigned long long ALL_LUMI_BLOCKS
All the lumi blocks in one run.
Definition: IOVDbCoolFunctions.h:36
IOVDbNamespace::inRange
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.
Definition: IOVDbCoolFunctions.h:42
IOVDbNamespace::iovTimeFromSeconds
unsigned long long iovTimeFromSeconds(const unsigned long long seconds)
Create a long long time in ns from s.
Definition: IOVDbCoolFunctions.cxx:98
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
IOVDbNamespace::makeEpochOrRunLumi
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.
Definition: IOVDbCoolFunctions.cxx:87
cool
Definition: CoolTagInfo.h:12
dq_defect_copy_defect_database.channels
def channels
Definition: dq_defect_copy_defect_database.py:56
IOVTime.h
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
dq_defect_copy_defect_database.since
def since
Definition: dq_defect_copy_defect_database.py:54
IOVDbNamespace::attrList2Spec
const coral::AttributeListSpecification & attrList2Spec(const coral::AttributeList &atrlist)
return the AttributeListSpecification of an AttributeList
Definition: IOVDbCoolFunctions.cxx:52
dq_defect_copy_defect_database.until
def until
Definition: dq_defect_copy_defect_database.py:55
coral
Definition: ISecondaryEventSelector.h:19
IOVTime
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
Definition: IOVTime.h:33
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
run
Definition: run.py:1
IOVDbNamespace::channelList
std::pair< std::vector< cool::ChannelId >, std::vector< std::string > > channelList(IOVDbConn *pConnection, const std::string &folderName, const bool named)
Retrieve channel information.
Definition: IOVDbCoolFunctions.cxx:160
python.LArCalib_HVCorrConfig.seconds
seconds
Definition: LArCalib_HVCorrConfig.py:86
IOVDbNamespace::makeRange
IOVRange makeRange(const cool::ValidityKey since, const cool::ValidityKey until, const bool timeIsEpoch)
Make an IOVRange from two validity keys.
Definition: IOVDbCoolFunctions.cxx:113
IOVDbConn
Definition: IOVDbConn.h:18
CaloCellTimeCorrFiller.folderName
string folderName
Definition: CaloCellTimeCorrFiller.py:20
IOVDbNamespace::typeSizeIsKnown
bool typeSizeIsKnown(const coral::Attribute &attribute)
Return a bool indicating whether the size of a given Attribute can be determined.
Definition: IOVDbCoolFunctions.cxx:67
IOVDbNamespace::runLumiFromIovTime
std::pair< unsigned long long, unsigned long long > runLumiFromIovTime(const unsigned long long iovTime)
Return a [run,lumi] pair from an IOV time.
Definition: IOVDbCoolFunctions.cxx:108
lumiFormat.lumi
lumi
Definition: lumiFormat.py:106
IOVDbNamespace::attributeSize
unsigned int attributeSize(const coral::Attribute &attribute)
return the size (in bytes) of an Attribute
Definition: IOVDbCoolFunctions.cxx:57
IOVDbNamespace::attributeListSize
unsigned int attributeListSize(const coral::AttributeList &atrlist)
return the size (in bytes) of an AttributeList
Definition: IOVDbCoolFunctions.cxx:72
IOVDbNamespace::folderMetadata
std::pair< bool, std::string > folderMetadata(IOVDbConn *pConnection, const std::string &folderName)
Retrieve (bool) multiversion flag and folder description
Definition: IOVDbCoolFunctions.cxx:136
WriteCalibToCool.strval
strval
Definition: WriteCalibToCool.py:583
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
IOVDbNamespace::iovTimeFromRunLumi
unsigned long long iovTimeFromRunLumi(const unsigned long long run, const unsigned long long lumi)
Create a long long representing the IOV from run, lumi.
Definition: IOVDbCoolFunctions.cxx:103
IOVDbNamespace::countSelectedChannels
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.
Definition: IOVDbCoolFunctions.cxx:81
IOVDbNamespace::makeChannel
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.
Definition: IOVDbCoolFunctions.cxx:128
IOVDbNamespace
Definition: Base64Codec.cxx:16
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37