6 if __name__==
'__main__':
8 from argparse
import ArgumentParser
9 parser = ArgumentParser()
11 parser.add_argument(
'--disableHistograms', action=
'store_false', help=
'Turn off histograming')
12 parser.add_argument(
'--disableGlobalGroups', action=
'store_false', help=
'Turn off global groups')
13 parser.add_argument(
'--disableTriggerGroups', action=
'store_false', help=
'Turn off per-trigger groups')
14 parser.add_argument(
'--disableExpressGroup', action=
'store_false', help=
'Turn off express stream rates')
15 parser.add_argument(
'--disableUniqueRates', action=
'store_false', help=
'Turn off unique rates (much faster!)')
16 parser.add_argument(
'--disableLumiExtrapolation', action=
'store_false', help=
'Turn off luminosity extrapolation')
18 parser.add_argument(
'--MCDatasetName', default=
'', type=str, help=
'For MC input: Name of the dataset, can be used instead of MCCrossSection, MCFilterEfficiency')
19 parser.add_argument(
'--MCCrossSection', default=0.0, type=float, help=
'For MC input: Cross section of process in nb')
20 parser.add_argument(
'--MCFilterEfficiency', default=1.0, type=float, help=
'For MC input: Filter efficiency of any MC filter (0.0 - 1.0)')
21 parser.add_argument(
'--MCKFactor', default=1.0, type=float, help=
'For MC input: Additional multiplicitive fudge-factor to the supplied cross section.')
22 parser.add_argument(
'--MCIgnoreGeneratorWeights', action=
'store_true', help=
'For MC input: Flag to disregard any generator weights.')
24 parser.add_argument(
'--outputHist', default=
'RatesHistograms.root', type=str, help=
'Histogram output ROOT file')
26 parser.add_argument(
'--targetLuminosity', default=2e34, type=float)
28 parser.add_argument(
'--doRatesVsPositionInTrain', action=
'store_true', help=
'Study rates vs BCID position in bunch train')
29 parser.add_argument(
'--vetoStartOfTrain', default=0, type=int, help=
'Number of BCIDs at the start of the train to veto, implies doRatesVsPositionInTrain')
31 parser.add_argument(
'--maxEvents', type=int, help=
'Maximum number of events to process')
32 parser.add_argument(
'--loglevel', type=int, default=3, help=
'Verbosity level')
33 parser.add_argument(
'flags', nargs=
'*', help=
'Config flag overrides')
34 args = parser.parse_args()
37 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
41 flags.Input.Files = [
"root://eosatlas.cern.ch//eos/atlas/atlasdatadisk/rucio/data16_13TeV/8d/de/AOD.10654269._000566.pool.root.1"]
42 flags.Exec.OutputLevel = args.loglevel
43 flags.Exec.EventPrintoutInterval = 1000
44 flags.fillFromArgs(args.flags)
45 useBunchCrossingData = (args.doRatesVsPositionInTrain
or args.vetoStartOfTrain > 0)
50 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
51 from AthenaConfiguration.ComponentFactory
import CompFactory
53 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
57 histSvc = CompFactory.THistSvc()
58 histSvc.Output += [
"RATESTREAM DATAFILE='" + args.outputHist +
"' OPT='RECREATE'"]
59 cfg.addService(histSvc)
62 from AthenaServices.MetaDataSvcConfig
import MetaDataSvcCfg
68 xsec = args.MCCrossSection
69 fEff = args.MCFilterEfficiency
70 dset = args.MCDatasetName
71 if flags.Input.isMC
and xsec == 0:
72 from RatesAnalysis.GetCrossSectionAMITool
import GetCrossSectionAMI
73 amiTool = GetCrossSectionAMI()
75 dset = amiTool.getDatasetNameFromPath(flags.Input.Files[0])
76 amiTool.queryAmi(dset)
77 xsec = amiTool.crossSection
78 fEff = amiTool.filterEfficiency
80 ebw = CompFactory.EnhancedBiasWeighter(
'EnhancedBiasRatesTool')
81 ebw.RunNumber = flags.Input.RunNumbers[0]
82 ebw.UseBunchCrossingData = useBunchCrossingData
83 ebw.IsMC = flags.Input.isMC
85 ebw.MCCrossSection = xsec
86 ebw.MCFilterEfficiency = fEff
87 ebw.MCKFactor = args.MCKFactor
88 ebw.MCIgnoreGeneratorWeights = args.MCIgnoreGeneratorWeights
89 cfg.addPublicTool(ebw)
91 rates = CompFactory.RatesEmulationExample()
92 rates.DoTriggerGroups = args.disableTriggerGroups
93 rates.DoGlobalGroups = args.disableGlobalGroups
94 rates.DoExpressRates = args.disableExpressGroup
95 rates.DoUniqueRates = args.disableUniqueRates
96 rates.DoHistograms = args.disableHistograms
97 rates.UseBunchCrossingData = useBunchCrossingData
98 rates.TargetLuminosity = args.targetLuminosity
99 rates.VetoStartOfTrain = args.vetoStartOfTrain
100 rates.EnableLumiExtrapolation = args.disableLumiExtrapolation
101 rates.EnhancedBiasRatesTool = ebw
102 rates.OutputLevel = args.loglevel
103 rates.TrigConfigSvc =
""
104 rates.TrigDecisionTool =
""
106 cfg.addEventAlgo(rates)
115 cfg.printConfig(withDetails=
False)
117 sc = cfg.run(args.maxEvents)
118 sys.exit(0
if sc.isSuccess()
else 1)