ATLAS Offline Software
Loading...
Searching...
No Matches
RivetAnalysis_JO_MEfromFile.py
Go to the documentation of this file.
1import os
2
3theApp.EvtMax = -1
4
5import AthenaPoolCnvSvc.ReadAthenaPool
6svcMgr.EventSelector.InputCollections = ["!TESTSAMPLE!"]
7from PyUtils.MetaReader import read_metadata
8filename = svcMgr.EventSelector.InputCollections[0]
9#Below are some example
10systWeights=None
11
12
13def safeFileName(name):
14 name=name.strip()
15 name= name.replace(".","p").replace(" ","_")
16 name= name.replace("pyoda",".yoda")
17 name= name.replace(":","_")
18 return name
19
20
21metadata = read_metadata(filename, None, 'full')[filename]
22if '/Generation/Parameters' in metadata:
23 genpars=metadata['/Generation/Parameters']
24 if 'HepMCWeightNames' in genpars:
25 systWeights=genpars['HepMCWeightNames']
26 else:
27 print('HepMCWeightName not found in /Generation/Parameters:')
28 print(genpars)
29else:
30 print('/Generation/Parameters not found in metadata:')
31 print(metadata)
32
33
34from AthenaCommon.AlgSequence import AlgSequence
35job = AlgSequence()
36
37from Rivet_i.Rivet_iConf import Rivet_i
38
39
40from AthenaCommon.AppMgr import ServiceMgr as svcMgr
41from GaudiSvc.GaudiSvcConf import THistSvc
42
43svcMgr += THistSvc()
44analyses= "!RIVETANALYSIS!"
45if systWeights==None: systWeights={'Nominal': 0}
46for i in systWeights:
47 systName=safeFileName(i)
48
49 print('weight name:',i,', output name',systName)
50
51 rivet = Rivet_i(systName)
52 for analysis in analyses.split(","):
53 rivet.Analyses +=[analysis]
54
55 rivet.RunName = ""
56 if i!="Nominal" : rivet.WeightName=i
57 rivet.HistoFile = systName
58 rivet.DoRootHistos = False
59 rivet.AnalysisPath = os.environ['PWD']
60 rivet.CrossSection = 1.0
61
62 job += rivet
63
void print(char *figname, TCanvas *c1)
Interface to the Rivet analysis package.
Definition Rivet_i.h:31
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310