ATLAS Offline Software
Functions | Variables
ParseFlavourInput Namespace Reference

Functions

def GetKeyNames (self, dir="")
 
def ReadFlavourHistograms (dirName)
 
def ReadFlavourHistograms (dirName, freezepT=False)
 

Variables

dictionary SystematicNameDictionary
 
dictionary jetDefDict
 
list SystematicNames = ['flavorCompLight','flavorCompGlu','FlavorResponse']
 

Function Documentation

◆ GetKeyNames()

def ParseFlavourInput.GetKeyNames (   self,
  dir = "" 
)

Definition at line 11 of file Final2012/ParseFlavourInput.py.

11 def GetKeyNames(self,dir=""):
12  self.cd(dir)
13  return [key.GetName() for key in gDirectory.GetListOfKeys()]
14 TFile.GetKeyNames = GetKeyNames
15 
16 

◆ ReadFlavourHistograms() [1/2]

def ParseFlavourInput.ReadFlavourHistograms (   dirName)

Definition at line 30 of file Final2012/ParseFlavourInput.py.

30 def ReadFlavourHistograms(dirName):
31  if not dirName.endswith("/"):
32  dirName = dirName + "/"
33 
34  # Run over each file (one per jet definition for LQ/Gluon and one per jet definition for HvP)
35  histos = {}
36  files = sorted(glob.glob(dirName+"*.root"))
37  for aFileName in files:
38  # Determine the jet definition
39  jetDef = ""
40  for aFileDef,aJetDef in jetDefDict.iteritems():
41  if aFileDef in aFileName:
42  jetDef = aJetDef
43  break
44  if jetDef == "":
45  print "Failed to determine jet definition for file:",aFileName
46  return None
47  if jetDef not in histos:
48  histos[jetDef] = {}
49 
50  # Read in the histograms from the file
51  # Note that we want all the histograms, but with this scheme not everything in the dict is in each file
52  # So instead loop over all histos in the file
53  inFile = TFile(aFileName,"READ")
54  for histName in inFile.GetKeyNames():
55  systematicName = SystematicNameDictionary[histName]+"_"+jetDef
56  histo = inFile.Get(histName)
57  if histo is None:
58  print "Failed to get histogram:",systematicName
59  return None
60 
61  histoSym = ProviderHistoHelpers.SymmetrizeHistoInEta(histo,systematicName)
62  histoSym.SetDirectory(0)
63  histos[jetDef][SystematicNameDictionary[histName]] = histoSym
64  # Done reading, close the file
65  inFile.Close()
66 
67  return histos
68 
69 
70 

◆ ReadFlavourHistograms() [2/2]

def ParseFlavourInput.ReadFlavourHistograms (   dirName,
  freezepT = False 
)

Definition at line 23 of file ICHEP2016/ParseFlavourInput.py.

23 def ReadFlavourHistograms(dirName,freezepT=False):
24  if not dirName.endswith("/") and not dirName.endswith(".root"):
25  dirName = dirName + "/"
26  if dirName.endswith("/") :
27  files = sorted(glob.glob(dirName+"*.root"))
28  else :
29  files = [dirName]
30 
31  # Run over each file (one per jet definition for LQ/Gluon and one per jet definition for HvP)
32  histos = {}
33  for aFileName in files:
34  # Determine the jet definition
35  jetDef = ""
36  for jetDef in jetDefDict.keys() :
37  print "Beginning jetDef",jetDef
38  if jetDefDict[jetDef] not in histos:
39  histos[jetDefDict[jetDef]] = {}
40 
41  # Read in the histograms from the file
42  # Note that we want all the histograms, but with this scheme not everything in the dict is in each file
43  # So instead loop over all histos in the file
44  inFile = TFile(aFileName,"READ")
45  for histName in inFile.GetKeyNames():
46  systName = histName.split("_")[0]
47  if not systName in SystematicNames :
48  print "Error!!!"
49  continue
50  if not jetDef in histName :
51  continue
52  systematicName = systName + "_" + jetDefDict[jetDef]
53  histo = inFile.Get(histName)
54  if histo is None:
55  print "Failed to get histogram:",systematicName
56  return None
57 
58  if freezepT :
59  # Loop over eta bins.
60  for ybin in range(histo.GetNbinsY()+2) :
61  # Loop out in pT.
62  freezeval = 0
63  for xbin in range(histo.GetNbinsX()+2) :
64  inbin = histo.GetBinContent(xbin,ybin)
65  #print "Bin at pT ",histo.GetXaxis().GetBinCenter(xbin)," and [ylow,y,yhigh] = ", binYLow, histo.GetYaxis().GetBinCenter(ybin), binYHigh
66  # Store bin contents as we go out: last one is one we want as frozen value.
67  if inbin > 0 :
68  freezeval = inbin
69  else :
70  histo.SetBinContent(xbin,ybin,freezeval)
71 
72  if systName.find("FlavorResponse")!=-1 :
73  histo.Scale(-1.0)
74 
75  histoSym = ProviderHistoHelpers.SymmetrizeHistoInEta(histo,systematicName)
76  histoSym.SetDirectory(0)
77  histos[jetDefDict[jetDef]][systName] = histoSym
78 
79  # Done reading, close the file
80  inFile.Close()
81 
82  return histos

Variable Documentation

◆ jetDefDict

dictionary ParseFlavourInput.jetDefDict
Initial value:
1 = {
2  '4EM' : 'AntiKt4Topo_EMJES',
3  '6EM' : 'AntiKt6Topo_EMJES',
4  '4LC' : 'AntiKt4Topo_LCJES',
5  '6LC' : 'AntiKt6Topo_LCJES'
6  }

Definition at line 23 of file Final2012/ParseFlavourInput.py.

◆ SystematicNameDictionary

dictionary ParseFlavourInput.SystematicNameDictionary
Initial value:
1 = {
2  'LQ' : 'flavorCompLight',
3  'Gluon' : 'flavorCompGlu',
4  'HerwigVsPythia_Gluon' : 'FlavorResponse'
5  }

Definition at line 17 of file Final2012/ParseFlavourInput.py.

◆ SystematicNames

list ParseFlavourInput.SystematicNames = ['flavorCompLight','flavorCompGlu','FlavorResponse']

Definition at line 17 of file ICHEP2016/ParseFlavourInput.py.

ParseFlavourInput.GetKeyNames
def GetKeyNames(self, dir="")
Definition: Final2012/ParseFlavourInput.py:11
ParseFlavourInput.ReadFlavourHistograms
def ReadFlavourHistograms(dirName)
Definition: Final2012/ParseFlavourInput.py:30
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
ProviderHistoHelpers.SymmetrizeHistoInEta
def SymmetrizeHistoInEta(histo, histoName)
Definition: Final2012/ProviderHistoHelpers.py:127
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.
ParseFlavourInput.ReadFlavourHistograms
def ReadFlavourHistograms(dirName, freezepT=False)
Definition: ICHEP2016/ParseFlavourInput.py:23