ATLAS Offline Software
histoConfigurationWrapper.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2 
3 def getHistogram1D( myMap,chains=[""] ):
4  output = []
5 
6  for el in myMap:
7  print( 'Looking at',el )
8  definition = myMap[el]
9  if definition[ 'path' ].get('ART',None) is None:
10  continue
11 
12  probabilities = [""]
13  if 'forEach' in definition:
14  if len( definition[ 'forEach' ] ) > 0:
15  probabilities = definition[ 'forEach' ]
16  print( 'forEach:',probabilities )
17  flavours = [""]
18  if 'forEachTruthType' in definition:
19  if len( definition[ 'forEachTruthType' ] ) > 0:
20  flavours = definition[ 'forEachTruthType' ]
21  print( 'FLAVS:',flavours )
22  output += createHistogram1D( el,definition,probabilities,flavours,chains )
23 
24  return output
25 
26 def getHistogram2D( myMap,chains=[""] ):
27  output = []
28 
29  for el in myMap:
30  definition = myMap[el]
31  if definition[ 'path' ].get('ART',None) is None:
32  continue
33 
34  probabilities = [""]
35  if 'forEach' in definition:
36  if len( definition[ 'forEach' ] ) > 0:
37  probabilities = definition[ 'forEach' ]
38  print( 'forEach:',probabilities )
39  flavours = [""]
40  if 'forEachTruthType' in definition:
41  if len( definition[ 'forEachTruthType' ] ) > 0:
42  flavours = definition[ 'forEachTruthType' ]
43  output += createHistogram2D( el,definition,probabilities,flavours,chains )
44 
45  return output
46 
47 def createHistogram1D( el,definition,probabilities,flavours,chains=[""] ):
48  output = []
49 
50  for chain in chains:
51  for prob in probabilities:
52  for flav in flavours:
53  name = str(el)
54  histoPath = str(definition['path']['ART'])
55 
56  if str(prob) != "":
57  name += "_" + str(prob)
58 
59  if str(flav) != "":
60  name = str(flav) + "_" + name
61  histoPath = str(flav)+"/"+str(definition['path']['ART'])
62 
63  if str(chain) != "":
64  name = str(chain) + "_" + name
65  histoPath = str(chain) +"/"+ histoPath
66 
67  toAdd = [ str(definition['type']),
68  name,
69  str(definition['title']+";"+definition['xtitle']+";"+definition['ytitle']),
70  histoPath,
71  str(definition['xbins']),
72  str(definition['xmin']),
73  str(definition['xmax']) ]
74  output.append( toAdd )
75 
76  return output
77 
78 def createHistogram2D( el,definition,probabilities,flavours,chains=[""] ):
79  output = []
80 
81  for chain in chains:
82  for prob in probabilities:
83  for flav in flavours:
84  name = str(el)
85  histoPath = str(definition['path']['ART'])
86 
87  if str(prob) != "":
88  name += "_" + str(prob)
89 
90  if str(flav) != "":
91  name = str(flav) + "_" + name
92  histoPath = str(flav)+"/"+str(definition['path']['ART'])
93 
94  if str(chain) != "":
95  name = str(chain) + "_" + name
96  histoPath = str(chain) +"/"+ histoPath
97 
98  toAdd = [ str(definition['type']),
99  name,
100  str(definition['title']+";"+definition['xtitle']+";"+definition['ytitle']),
101  histoPath,
102  str(definition['xbins']),
103  str(definition['xmin']),
104  str(definition['xmax']),
105  str(definition['ybins']),
106  str(definition['ymin']),
107  str(definition['ymax']) ]
108  output.append( toAdd )
109 
110  return output
111 
112 
113 
114 def getHistoDefs( category = 'ART',chains=[""] ):
115  import json
116  import os
117  from AthenaCommon.Utils.unixtools import FindFile
118 
119  path = FindFile("JetTagDQA/PhysValBtag_VariablesMenu.json", os.environ["DATAPATH"].split(os.pathsep), os.R_OK)
120 
121  inFile = open( path,'r' )
122  mappa = json.load( inFile )
123 
124 
125  variables1D = []
126  variables2D = []
127 
128  # Taking 1D histograms
129  variables1D += getHistogram1D( mappa['GLOBAL'],chains )
130  variables1D += getHistogram1D( mappa['JET'],chains )
131  variables1D += getHistogram1D( mappa['TAGGER'],chains )
132  variables1D += getHistogram1D( mappa['TRACKS'],chains )
133  variables1D += getHistogram1D( mappa['SV'],chains )
134  # Taking 2D histograms
135  variables2D += getHistogram2D( mappa[ 'CombinedQuantities' ],chains )
136 
137  return [ variables1D,variables2D ]
histoConfigurationWrapper.getHistogram2D
def getHistogram2D(myMap, chains=[""])
Definition: histoConfigurationWrapper.py:26
histoConfigurationWrapper.getHistogram1D
def getHistogram1D(myMap, chains=[""])
Definition: histoConfigurationWrapper.py:3
python.Utils.unixtools.FindFile
def FindFile(filename, pathlist, access)
helper -------------------------------------------------------------------—
Definition: unixtools.py:20
histoConfigurationWrapper.createHistogram2D
def createHistogram2D(el, definition, probabilities, flavours, chains=[""])
Definition: histoConfigurationWrapper.py:78
Trk::open
@ open
Definition: BinningType.h:40
histoConfigurationWrapper.getHistoDefs
def getHistoDefs(category='ART', chains=[""])
Definition: histoConfigurationWrapper.py:114
histoConfigurationWrapper.createHistogram1D
def createHistogram1D(el, definition, probabilities, flavours, chains=[""])
Definition: histoConfigurationWrapper.py:47
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
str
Definition: BTagTrackIpAccessor.cxx:11
Trk::split
@ split
Definition: LayerMaterialProperties.h:38