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

Public Member Functions

def make_good_iovs (self, iovs)
 
def map_input_channels (self, iovs)
 
def __hash__ (self)
 
def __repr__ (self)
 
def read (self, query_range, folder_base, folder_name)
 
def print_time_info (self, iovs)
 
def quantize (self, lbtime, iovs)
 
def make_good_iov (self, iov)
 
def calculate_good_iovs (self, lbtime, subdetector)
 

Public Attributes

 folder_name
 
 evaluator
 
 input_hashes
 
 subdetector
 
 iovs
 

Static Public Attributes

string input_db = "COOLONL_SCT/CONDBR2"
 
bool is_config_variable = True
 
 fetch_args = dict(what=["group", "id"])
 
bool is_global = False
 
bool timewise_folder = True
 

Detailed Description

Specialisation for the /SCT/DAQ/Configuration/Module folder.

CoraCOOL stores multiple elements per iov. This folder only ever contains 
zero or one elements.

Definition at line 10 of file sct.py.

Member Function Documentation

◆ __hash__()

def python.variable.DCSC_Variable.__hash__ (   self)
inherited
Useful for verifying if input variables have changed.

Definition at line 61 of file variable.py.

61  def __hash__(self):
62  """
63  Useful for verifying if input variables have changed.
64  """
65  # Consider the fact that hash((hash(x), hash(y))) == hash((x, y)) where
66  # x and y are tuples.
67  return hash(tuple(self.input_hashes))
68 

◆ __repr__()

def python.variable.DCSC_Variable.__repr__ (   self)
inherited

Definition at line 69 of file variable.py.

69  def __repr__(self):
70  return "<DCSCVariable %s>" % self.folder_name
71 

◆ calculate_good_iovs()

def python.variable.DCSC_Variable.calculate_good_iovs (   self,
  lbtime,
  subdetector 
)
inherited
Calculate LB-wise "good" states

Definition at line 180 of file variable.py.

180  def calculate_good_iovs(self, lbtime, subdetector):
181  """
182  Calculate LB-wise "good" states
183  """
184 
185  self.subdetector = subdetector
186 
187  if self.timewise_folder:
188  query_range = RANGEIOV_VAL(lbtime.first.since, lbtime.last.until)
189  else:
190  a, b = lbtime.first, lbtime.last
191  query_range = RANGEIOV_VAL(RunLumi(a.Run, a.LumiBlock),
192  RunLumi(b.Run, b.LumiBlock))
193 
194  # Read the database
195  iovs = self.read(query_range, subdetector.folder_base, self.folder_name)
196  #iovs.pprint()
197 
198  # Decide the states of the input iovs
199  iovs = self.make_good_iovs(iovs)
200  #iovs.pprint()
201 
202  # Apply a mapping for input channels if necessary
203  # This only does something for variables that require additional mapping
204  # i.e., if the channel numbers for different DCS variables don't match up
205  iovs = self.map_input_channels(iovs)
206 
207  if self.timewise_folder and not config.opts.timewise:
208  # we might already know the defect mapping
209  with timer("Quantize %s (%i iovs over %i lbs)" %
210  (self.folder_name, len(iovs), len(lbtime))):
211  # Quantize to luminosity block
212  iovs = self.quantize(lbtime, iovs)
213  #iovs.pprint()
214 
215  # Debug printout of problematic channels
216  # DQUtils messes with the logging and isEnabledFor doesn't work
217  #if log.isEnabledFor(logging.DEBUG):
218  #log.verbose("Bad input channels for %s:", self.folder_name)
219  #log.verbose("= [%r]", ", ".join(str(i.channel) for i in iovs if not i.good))
220 
221  self.iovs = iovs
222 
223  return self
224 

◆ make_good_iov()

def python.variable.DCSC_Variable.make_good_iov (   self,
  iov 
)
inherited
Determine if one input iov is good.

Reimplemented in python.variable.DCSC_Global_Variable, and python.subdetectors.tile.Tile_NoHighVoltage.

Definition at line 165 of file variable.py.

165  def make_good_iov(self, iov):
166  """
167  Determine if one input iov is good.
168  """
169  giov = GoodIOV(iov.since, iov.until, iov.channel, self.evaluator(iov))
170  giov._orig_iov = iov
171  return giov
172 

◆ make_good_iovs()

def python.subdetectors.sct.DCSC_Variable_SCT_Config.make_good_iovs (   self,
  iovs 
)
Beware, deceptive function name. Here we are really 
making OUT_OF_CONFIG iovs, rather than 'good' ones.

The resulting IoVs are in terms of detector serial number. These get
mapped onto the HV channel IDs with the `sct_sn_to_cool_ids` mapping.

Reimplemented from python.variable.DCSC_Variable.

Definition at line 25 of file sct.py.

25  def make_good_iovs(self, iovs):
26  """
27  Beware, deceptive function name. Here we are really
28  making OUT_OF_CONFIG iovs, rather than 'good' ones.
29 
30  The resulting IoVs are in terms of detector serial number. These get
31  mapped onto the HV channel IDs with the `sct_sn_to_cool_ids` mapping.
32  """
33  iovs = [iov for iov in iovs if iov.elements]
34  #assert all(len(iov.elements) == 1 for iov in iovs)
35  iovs = [GoodIOV(iov.since, iov.until, iov.elements[0].id, OUT_OF_CONFIG)
36  for iov in iovs if iov.elements[0].group == -1]
37 
38  return IOVSet(iovs)
39 

◆ map_input_channels()

def python.variable.DCSC_Variable_With_Mapping.map_input_channels (   self,
  iovs 
)
inherited
By default, do nothing. Overloaded by DCSC_Variable_With_Mapping.

Reimplemented from python.variable.DCSC_Variable.

Definition at line 229 of file variable.py.

229  def map_input_channels(self, iovs):
230  return map_channels(iovs, self.input_channel_map, self.folder_name)
231 

◆ print_time_info()

def python.variable.DCSC_Variable.print_time_info (   self,
  iovs 
)
inherited
Logs the first and last insertion times of the IoVs, and their ranges.

Definition at line 125 of file variable.py.

125  def print_time_info(self, iovs):
126  """
127  Logs the first and last insertion times of the IoVs, and their ranges.
128  """
129  first_value, last_value = iovs.range_iov
130 
131  log.info("Times for %s:", self)
132  log.info(" IoV : (first)%26s (last)%26s",
133  first_value.date, last_value.date)
134 
135  if not hasattr(iovs.first, "insertion_time"):
136  log.info("Insertion time not available")
137  else:
138  insertion_times = [iov.insertion_time for iov in iovs]
139  log.info(" Insertion: (first)%26s (last)%26s",
140  min(insertion_times), max(insertion_times))
141 

◆ quantize()

def python.variable.DCSC_Variable.quantize (   self,
  lbtime,
  iovs 
)
inherited
Quantize "good state" timewise-iovs to lumiblocks.
OUT_OF_CONFIG gets priority over BAD if BAD and OUT_OF_CONFIG overlap
the same lumiblock.

Reimplemented in python.variable.DCSC_Defect_Global_Variable, and python.variable.DCSC_Global_Variable.

Definition at line 148 of file variable.py.

148  def quantize(self, lbtime, iovs):
149  """
150  Quantize "good state" timewise-iovs to lumiblocks.
151  OUT_OF_CONFIG gets priority over BAD if BAD and OUT_OF_CONFIG overlap
152  the same lumiblock.
153  """
154  IOVSet = iovs.empty
155  iovs = [iovs_ for c, iovs_ in sorted(iovs.by_channel.items())]
156 
157  def quantizer (iovs):
158  return min(i.good for i in iovs) if iovs else None
159 
160  result = quantize_iovs_slow_mc(lbtime, iovs, quantizer)
161  return IOVSet(GoodIOV(*iov)
162  for iovs in result
163  for iov in iovs if iov[0].run == iov[1].run)
164 

◆ read()

def python.variable.DCSC_Variable.read (   self,
  query_range,
  folder_base,
  folder_name 
)
inherited
Read the relevant data from COOL for this variable

Definition at line 72 of file variable.py.

72  def read(self, query_range, folder_base, folder_name):
73  """
74  Read the relevant data from COOL for this variable
75  """
76  if folder_name.startswith("/"):
77  folder_path = folder_name
78  else:
79  # For relative folders prepend the folder_base
80  folder_path = "/".join((folder_base, folder_name))
81 
82  log.info("Querying COOL folder %s", folder_path)
83 
84  if config.opts.check_input_time:
85  self.fetch_args["with_time"] = True
86 
87  # Massage DB access
88  if '/' in self.input_db:
89  newdbstring = self.input_db.rsplit('/', 1)[0]
90  else:
91  newdbstring = self.input_db
92  if config.opts.input_database.startswith('sqlite'):
93  self.fetch_args['database'] = config.opts.input_database
94  else:
95  self.fetch_args['database'] = ('%s/%s' % (newdbstring, config.opts.input_database))
96  if self.fetch_args:
97  log.debug("Fetching with args: %r", self.fetch_args)
98 
99  iovs = fetch_iovs(folder_path, *query_range, **self.fetch_args)
100 
101  # Prints even when not doing debug.
102  # TODO: fix this. Might be broken in DQUtils.logger
103  #if log.isEnabledFor(logging.DEBUG):
104  # log.debug("Dumping input IOVs:")
105  # for iov in iovs:
106  # print iov
107 
108  #Remove Old TGC Chambers
109  original_length=len(list(iovs))
110  if folder_path=='/TGC/DCS/PSHVCHSTATE':
111  for i in range(original_length-1, -1, -1):
112  if list(iovs)[i].channel in range(5504,5552) or list(iovs)[i].channel in range(7362,7411):
113  iovs.pop(i)
114 
115  if config.opts.check_input_time:
116  self.print_time_info(iovs)
117 
118  if log.isEnabledFor(logging.INFO):
119  input_hash = hash(iovs)
120  self.input_hashes.append(input_hash)
121  log.info(" -> Input hash: % 09x (len=%i)", input_hash, len(iovs))
122 
123  return iovs
124 

Member Data Documentation

◆ evaluator

python.variable.DCSC_Variable.evaluator
inherited

Definition at line 55 of file variable.py.

◆ fetch_args

python.subdetectors.sct.DCSC_Variable_SCT_Config.fetch_args = dict(what=["group", "id"])
static

Definition at line 23 of file sct.py.

◆ folder_name

python.variable.DCSC_Variable.folder_name
inherited

Definition at line 54 of file variable.py.

◆ input_db

string python.subdetectors.sct.DCSC_Variable_SCT_Config.input_db = "COOLONL_SCT/CONDBR2"
static

Definition at line 18 of file sct.py.

◆ input_hashes

python.variable.DCSC_Variable.input_hashes
inherited

Definition at line 59 of file variable.py.

◆ iovs

python.variable.DCSC_Variable.iovs
inherited

Definition at line 221 of file variable.py.

◆ is_config_variable

bool python.subdetectors.sct.DCSC_Variable_SCT_Config.is_config_variable = True
static

Definition at line 19 of file sct.py.

◆ is_global

bool python.variable.DCSC_Variable.is_global = False
staticinherited

Definition at line 47 of file variable.py.

◆ subdetector

python.variable.DCSC_Variable.subdetector
inherited

Definition at line 185 of file variable.py.

◆ timewise_folder

bool python.variable.DCSC_Variable.timewise_folder = True
staticinherited

Definition at line 49 of file variable.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
python.libcore.map_channels
def map_channels(iovs, mapping, folder)
Definition: libcore.py:39
max
#define max(a, b)
Definition: cfImp.cxx:41
python.db.fetch_iovs
def fetch_iovs(folder_name, since=None, until=None, channels=None, tag="", what="all", max_records=-1, with_channel=True, loud=False, database=None, convert_time=False, named_channels=False, selection=None, runs=None, with_time=False, unicode_strings=False)
Definition: DQUtils/python/db.py:67
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.events.quantize_iovs_slow_mc
def quantize_iovs_slow_mc(lbtime, iovs, quantizer=default_quantizing_function)
Definition: events.py:330
python.variable.GoodIOV
def GoodIOV(channel, good)
Definition: variable.py:18
python.sugar.runlumi.RunLumi
RunLumi
Definition: runlumi.py:131
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
min
#define min(a, b)
Definition: cfImp.cxx:40
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109