ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
python.subdetectors.afp.TDAQC_Variable Class Reference
Inheritance diagram for python.subdetectors.afp.TDAQC_Variable:
Collaboration diagram for python.subdetectors.afp.TDAQC_Variable:

Public Member Functions

def __init__ (self, query, evaluator, *regex=False, mapping=dict(), force_mapping=False, empty_value=None)
 
def __repr__ (self)
 
def read (self, query_range, query, *regex=False)
 
def calculate_good_iovs (self, lbtime, subdetector)
 
def make_good_iov (self, iov)
 

Static Public Member Functions

def timeCOOL2PBeast (timestamp)
 
def timePBeast2COOL (timestamp)
 

Public Attributes

 regex
 
 mapping
 
 force_mapping
 
 empty_value
 
 query
 
 path
 
 input_hashes
 
 subdetector
 
 iovs
 

Static Public Attributes

int TIME_RATIO = 1e3
 

Detailed Description

A variable which reads data from pBeast.

Definition at line 93 of file afp.py.

Constructor & Destructor Documentation

◆ __init__()

def python.subdetectors.afp.TDAQC_Variable.__init__ (   self,
  query,
  evaluator,
regex = False,
  mapping = dict(),
  force_mapping = False,
  empty_value = None 
)

Definition at line 107 of file afp.py.

107  def __init__(self, query, evaluator, *, regex=False, mapping=dict(), force_mapping=False, empty_value=None):
108  super().__init__(query, evaluator)
109  self.regex = regex
110  self.mapping = mapping
111  self.force_mapping = force_mapping
112  self.empty_value = empty_value
113  self.query = query
114  self.partition, self.className, self.attribute, self.path = query.split('.', 3)
115  self.input_hashes = []
116 

Member Function Documentation

◆ __repr__()

def python.subdetectors.afp.TDAQC_Variable.__repr__ (   self)

Definition at line 117 of file afp.py.

117  def __repr__(self):
118  return f"<TDAQCVariable {self.query}>"
119 

◆ calculate_good_iovs()

def python.subdetectors.afp.TDAQC_Variable.calculate_good_iovs (   self,
  lbtime,
  subdetector 
)
Calculate LB-wise "good" states

Definition at line 166 of file afp.py.

166  def calculate_good_iovs(self, lbtime, subdetector):
167  """
168  Calculate LB-wise "good" states
169  """
170 
171  self.subdetector = subdetector
172 
173  since, until = lbtime.first, lbtime.last
174  if self.timewise_folder:
175  query_range = RANGEIOV_VAL(since.since, until.until)
176  else:
177  query_range = RANGEIOV_VAL(RunLumi(since.Run, since.LumiBlock),
178  RunLumi(until.Run, until.LumiBlock))
179 
180  # Read the database
181  iovs = self.read(query_range, self.query, regex=self.regex)
182  # Decide the states of the input iovs
183  iovs = self.make_good_iovs(iovs)
184  # Apply a mapping for input channels if necessary
185  iovs = self.map_input_channels(iovs)
186 
187  if self.timewise_folder and not config.opts.timewise:
188  # we might already know the defect mapping
189  with timer("Quantize %s (%i iovs over %i lbs)" %
190  (self.query, len(iovs), len(lbtime))):
191  # Quantize to luminosity block
192  iovs = self.quantize(lbtime, iovs)
193 
194  self.iovs = iovs
195  return self
196 

◆ make_good_iov()

def python.subdetectors.afp.TDAQC_Variable.make_good_iov (   self,
  iov 
)
Determine if one input iov is good.

Reimplemented in python.subdetectors.afp.TDAQC_Array_Variable, python.subdetectors.afp.TDAQC_Bit_Flag_Variable, and python.subdetectors.afp.TDAQC_Multi_Channel_Variable.

Definition at line 197 of file afp.py.

197  def make_good_iov(self, iov):
198  """
199  Determine if one input iov is good.
200  """
201  giov = GoodIOV(iov.since, iov.until, self.mapping.get(iov.channel, iov.channel), self.evaluator(iov))
202  giov._orig_iov = iov
203  return giov

◆ read()

def python.subdetectors.afp.TDAQC_Variable.read (   self,
  query_range,
  query,
regex = False 
)
Read the relevant data from pBeast for this variable, and convert them to COOL-like format

Definition at line 120 of file afp.py.

120  def read(self, query_range, query, *, regex=False):
121  """
122  Read the relevant data from pBeast for this variable, and convert them to COOL-like format
123  """
124  partition, className, attribute, path = query.split('.', 3)
125 
126  log.info(f"Querying pBeast object{'s using regex' if regex else ''} {query}")
127 
128  since, until = query_range
129  since, until = TDAQC_Variable.timeCOOL2PBeast(since), TDAQC_Variable.timeCOOL2PBeast(until)
130 
131  query_data = pbeast.get_data(partition, className, attribute, path, regex, since, until)
132  data = dict.fromkeys(self.mapping.keys()) if self.force_mapping else dict()
133  if query_data:
134  data.update(query_data[0].data)
135 
136  def instantiate(since, until, channel, value):
137  if isinstance(value, list):
138  value = tuple(value)
139  return PBeastIOV(TDAQC_Variable.timePBeast2COOL(since), TDAQC_Variable.timePBeast2COOL(until), channel, value)
140 
141  iovs = []
142  for channel, entries in data.items():
143  if not entries:
144  iovs.append(PBeastIOV(*query_range, channel, self.empty_value))
145  continue
146  first = entries[0]
147  since = first.ts
148  value = first.value
149  for point in entries:
150  if point.value == value:
151  continue
152  iovs.append(instantiate(since, point.ts, channel, value))
153  since = point.ts
154  value = point.value
155  last = entries[-1]
156  iovs.append(instantiate(since, last.ts, channel, value))
157  iovs = IOVSet(iovs, iov_type=PBeastIOV, origin=query)
158 
159  if log.isEnabledFor(logging.INFO):
160  input_hash = hash(iovs)
161  self.input_hashes.append(input_hash)
162  log.info(" -> Input hash: % 09x (len=%i)", input_hash, len(iovs))
163 
164  return iovs
165 

◆ timeCOOL2PBeast()

def python.subdetectors.afp.TDAQC_Variable.timeCOOL2PBeast (   timestamp)
static

Definition at line 100 of file afp.py.

100  def timeCOOL2PBeast(timestamp):
101  return int(timestamp/TDAQC_Variable.TIME_RATIO)
102 

◆ timePBeast2COOL()

def python.subdetectors.afp.TDAQC_Variable.timePBeast2COOL (   timestamp)
static

Definition at line 104 of file afp.py.

104  def timePBeast2COOL(timestamp):
105  return TimestampType(timestamp*TDAQC_Variable.TIME_RATIO)
106 

Member Data Documentation

◆ empty_value

python.subdetectors.afp.TDAQC_Variable.empty_value

Definition at line 112 of file afp.py.

◆ force_mapping

python.subdetectors.afp.TDAQC_Variable.force_mapping

Definition at line 111 of file afp.py.

◆ input_hashes

python.subdetectors.afp.TDAQC_Variable.input_hashes

Definition at line 115 of file afp.py.

◆ iovs

python.subdetectors.afp.TDAQC_Variable.iovs

Definition at line 194 of file afp.py.

◆ mapping

python.subdetectors.afp.TDAQC_Variable.mapping

Definition at line 110 of file afp.py.

◆ path

python.subdetectors.afp.TDAQC_Variable.path

Definition at line 114 of file afp.py.

◆ query

python.subdetectors.afp.TDAQC_Variable.query

Definition at line 113 of file afp.py.

◆ regex

python.subdetectors.afp.TDAQC_Variable.regex

Definition at line 109 of file afp.py.

◆ subdetector

python.subdetectors.afp.TDAQC_Variable.subdetector

Definition at line 171 of file afp.py.

◆ TIME_RATIO

int python.subdetectors.afp.TDAQC_Variable.TIME_RATIO = 1e3
static

Definition at line 97 of file afp.py.


The documentation for this class was generated from the following file:
read
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
Definition: openCoraCool.cxx:569
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.sugar.iovtype.RANGEIOV_VAL
def RANGEIOV_VAL()
Definition: iovtype.py:153
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.utils.AtlRunQueryTimer.timer
def timer(name, disabled=False)
Definition: AtlRunQueryTimer.py:86
python.variable.GoodIOV
def GoodIOV(channel, good)
Definition: variable.py:18
python.sugar.runlumi.RunLumi
RunLumi
Definition: runlumi.py:131
python.subdetectors.afp.PBeastIOV
def PBeastIOV(channel, value)
Definition: afp.py:90
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790