ATLAS Offline Software
Classes | Functions | Variables
python.checkMetadata Namespace Reference

Classes

class  ValidateMetadataAlg
 

Functions

def validateInputMetadata (infile)
 
def checkFileMetaData (file_names)
 

Variables

 flags = initConfigFlags()
 
 EventPrintoutInterval
 
 metadata = defaultdict(list)
 
 cfg = MainServicesCfg(flags)
 
 sequenceName
 
 sc = cfg.run()
 

Function Documentation

◆ checkFileMetaData()

def python.checkMetadata.checkFileMetaData (   file_names)
Check if FileMetaData is in all files

Definition at line 130 of file checkMetadata.py.

130 def checkFileMetaData(file_names):
131  """Check if FileMetaData is in all files"""
132 
133  return all(
134  [
135  fmd_items
136  for file_name in file_names
137  for fmd_items in [
138  value
139  for _, value in GetFileMD(file_name)["metadata_items"].items()
140  if "FileMetaData" in value
141  ]
142  ]
143  )
144 
145 

◆ validateInputMetadata()

def python.checkMetadata.validateInputMetadata (   infile)

Definition at line 62 of file checkMetadata.py.

62 def validateInputMetadata(infile):
63  logging.info(f"Using input file {infile}")
64 
65  current_file = ROOT.TFile(infile)
66  md = read_metadata(infile, mode="full", unique_tag_info_values=False)
67 
68  nevts_esi = next(
69  (
70  md[infile][key]["numberOfEvents"]
71  for key, value in md[infile].items()
72  if isinstance(value, dict) and "numberOfEvents" in value
73  ),
74  None,
75  )
76 
77  dataHeaderTree = current_file.Get(PoolOpts.TTreeNames.DataHeader)
78  if isinstance(dataHeaderTree, ROOT.TTree):
79  nevts_dh = dataHeaderTree.GetEntriesFast()
80  else:
81  if (
82  current_file.GetListOfKeys().Contains(PoolOpts.RNTupleNames.DataHeader)
83  and ROOT.gROOT.GetVersionInt() < 63100
84  ):
85  raise RuntimeError(
86  "ROOT ver. 6.31/01 or greater needed to read RNTuple files"
87  )
88  dataHeaderRNT = current_file.Get(PoolOpts.RNTupleNames.DataHeader)
89  if isRNTuple( dataHeaderRNT ):
90  nevts_dh = ROOT.Experimental.RNTupleReader.Open(dataHeaderRNT).GetNEntries()
91  else:
92  nevts_dh = None
93 
94  if not (md[infile]["nentries"] == nevts_esi == nevts_dh):
95  logging.error(
96  "Number of events from EventStreamInfo inconsistent with number of entries in DataHeader"
97  )
98  return 1
99 
100  tag_info = md[infile]["/TagInfo"]
101  if "project_name" in tag_info and isinstance(tag_info["project_name"], list):
102  if "IS_SIMULATION" in tag_info["project_name"] and any(
103  [item for item in tag_info["project_name"] if item.startswith("data")]
104  ):
105  logging.error("/TagInfo contains values reserved for both MC and data")
106  return 1
107  if (
108  len(
109  set(
110  item[5:6]
111  for item in tag_info["project_name"]
112  if item.startswith("data")
113  )
114  )
115  > 1
116  ):
117  logging.error("/TagInfo contains values from different data taking periods")
118  return 1
119  if (
120  "data_year" in tag_info
121  and isinstance(tag_info["data_year"], list)
122  and len(set(tag_info["data_year"])) > 1
123  ):
124  logging.error("/TagInfo contains values from different data taking periods")
125  return 1
126 
127  return 0
128 
129 

Variable Documentation

◆ cfg

python.checkMetadata.cfg = MainServicesCfg(flags)

Definition at line 184 of file checkMetadata.py.

◆ EventPrintoutInterval

python.checkMetadata.EventPrintoutInterval

Definition at line 158 of file checkMetadata.py.

◆ flags

python.checkMetadata.flags = initConfigFlags()

Definition at line 157 of file checkMetadata.py.

◆ metadata

python.checkMetadata.metadata = defaultdict(list)

Definition at line 175 of file checkMetadata.py.

◆ sc

python.checkMetadata.sc = cfg.run()

Definition at line 198 of file checkMetadata.py.

◆ sequenceName

python.checkMetadata.sequenceName

Definition at line 194 of file checkMetadata.py.

python.AutoConfigFlags.GetFileMD
def GetFileMD(filenames, allowEmpty=True, maxLevel='peeker')
Definition: AutoConfigFlags.py:65
python.MetaReader.read_metadata
def read_metadata(filenames, file_type=None, mode='lite', promote=None, meta_key_filter=None, unique_tag_info_values=True, ignoreNonExistingLocalFiles=False)
Definition: MetaReader.py:53
python.checkMetadata.validateInputMetadata
def validateInputMetadata(infile)
Definition: checkMetadata.py:62
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
python.checkMetadata.checkFileMetaData
def checkFileMetaData(file_names)
Definition: checkMetadata.py:130
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:67
python.PoolFile.isRNTuple
def isRNTuple(obj)
Definition: PoolFile.py:36