ATLAS Offline Software
detmaskmod.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 
3 import eformat
4 import operator
5 from functools import reduce
6 
7 
8 detmaskmap_defects = {
9  'FORWARD_AFP': 'AFP_DISABLED', # not yet functional
10  'FORWARD_ALPHA': 'ALFA_DISABLED',
11  #'FORWARD_LUCID': 'LCD_DISABLED', # LUCID now operates outside ATLAS partition
12  'FORWARD_ZDC': 'ZDC_DISABLED',
13  'LAR_EM_BARREL_A_SIDE': 'LAR_EMBA_DISABLED',
14  'LAR_EM_BARREL_C_SIDE': 'LAR_EMBC_DISABLED',
15  'LAR_EM_ENDCAP_A_SIDE': 'LAR_EMECA_DISABLED',
16  'LAR_EM_ENDCAP_C_SIDE': 'LAR_EMECC_DISABLED',
17  'LAR_FCAL_A_SIDE': 'LAR_FCALA_DISABLED',
18  'LAR_FCAL_C_SIDE': 'LAR_FCALC_DISABLED',
19  'LAR_HAD_ENDCAP_A_SIDE': 'LAR_HECA_DISABLED',
20  'LAR_HAD_ENDCAP_C_SIDE': 'LAR_HECC_DISABLED',
21  'MUON_MDT_BARREL_A_SIDE': 'MS_MDT_BA_DISABLED',
22  'MUON_MDT_BARREL_C_SIDE': 'MS_MDT_BC_DISABLED',
23  'MUON_MDT_ENDCAP_A_SIDE': 'MS_MDT_EA_DISABLED',
24  'MUON_MDT_ENDCAP_C_SIDE': 'MS_MDT_EC_DISABLED',
25  'MUON_RPC_BARREL_A_SIDE': 'MS_RPC_BA_DISABLED',
26  'MUON_RPC_BARREL_C_SIDE': 'MS_RPC_BC_DISABLED',
27  'MUON_TGC_ENDCAP_A_SIDE': 'MS_TGC_EA_DISABLED',
28  'MUON_TGC_ENDCAP_C_SIDE': 'MS_TGC_EC_DISABLED',
29  'PIXEL_BARREL': 'PIXEL_BARREL_DISABLED',
30  'PIXEL_B_LAYER': 'PIXEL_LAYER0_DISABLED',
31  'PIXEL_DISK_SIDE': 'PIXEL_ENDCAPS_DISABLED',
32  ('SCT_BARREL_A_SIDE', 'SCT_BARREL_C_SIDE',
33  'SCT_ENDCAP_A_SIDE', 'SCT_ENDCAP_C_SIDE'): 'SCT_GLOBAL_DISABLED',
34  'TILECAL_BARREL_A_SIDE': 'TILE_LBA_DISABLED',
35  'TILECAL_BARREL_C_SIDE': 'TILE_LBC_DISABLED',
36  'TILECAL_EXT_A_SIDE': 'TILE_EBA_DISABLED',
37  'TILECAL_EXT_C_SIDE': 'TILE_EBC_DISABLED',
38  ('TRT_BARREL_A_SIDE', 'TRT_BARREL_C_SIDE',
39  'TRT_ENDCAP_A_SIDE', 'TRT_ENDCAP_C_SIDE'): 'TRT_DISABLED',
40  }
41 
42 def getSubDetectorObj(sdstr):
43  return getattr(eformat.helper.SubDetector, sdstr)
44 
45 def decodeBlack(mask, defects=True): # defects argument is deprecated and now a nop
46  dm = eformat.helper.DetectorMask(mask)
47  rv = []
48  dmap = detmaskmap_defects
49  for keys, value in dmap.items():
50  if isinstance(keys, str):
51  keys = [keys]
52  if reduce(operator.and_,
53  [not dm.is_set(getSubDetectorObj(key)) for key in keys]):
54  flags = value
55  if isinstance(flags, str):
56  flags = [flags]
57  rv += list(flags)
58 
59  return sorted(rv)
60 
61 def getRunMask(run):
62  from PyCool import cool
63  dbSvc = cool.DatabaseSvcFactory.databaseService()
64  # Necessary to work around COOL database lookup stupidity
65  db = dbSvc.openDatabase('oracle://ATLAS_COOLPROD;dbname=CONDBR2;schema=ATLAS_COOLONL_TDAQ', True)
66  iov = run << 32
67  folder = db.getFolder('/TDAQ/RunCtrl/SOR')
68  obj = folder.findObject(iov, 0)
69  mask = obj.payload()['DetectorMask']
70  db.closeDatabase()
71  return mask
72 
74  from DQUtils.db import fetch_iovs
75  lbs = fetch_iovs('LBLB', (run, 1), (run, 0xFFFFFFFF), database='oracle://ATLAS_COOLPROD;dbname=CONDBR2;schema=ATLAS_COOLONL_TRIGGER')
76  return len(lbs)
77 
78 
python.detmaskmod.getSubDetectorObj
def getSubDetectorObj(sdstr)
Definition: detmaskmod.py:42
python.detmaskmod.getNumLumiBlocks
def getNumLumiBlocks(run)
Definition: detmaskmod.py:73
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
reduce
void reduce(HepMC::GenEvent *ge, std::vector< HepMC::GenParticlePtr > toremove)
Remove unwanted particles from the event, collapsing the graph structure consistently.
Definition: FixHepMC.cxx:81
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.
python.detmaskmod.getRunMask
def getRunMask(run)
Definition: detmaskmod.py:61
python.detmaskmod.decodeBlack
def decodeBlack(mask, defects=True)
Definition: detmaskmod.py:45