4 from AnalysisAlgorithmsConfig.ConfigBlock
import ConfigBlock
5 from AnalysisAlgorithmsConfig.ConfigAccumulator
import DataType
9 """the ConfigBlock for event cleaning"""
12 super (EventCleaningBlock, self).__init__ ()
13 self.addOption (
'runPrimaryVertexSelection',
True, type=bool,
14 info=
"whether to run primary vertex selection. The default is True.")
15 self.addOption (
'runEventCleaning',
False, type=bool,
16 info=
"whether to run event cleaning (sets up an instance of "
17 "CP::EventFlagSelectionAlg). The default is False.")
18 self.addOption (
'userGRLFiles', [], type=
None,
19 info=
"a list of GRL files (list of strings) to select data from. "
20 "The default is [] (empty list).")
21 self.addOption (
'minTracksPerVertex', 2, type=int,
22 info=
"minimum number (integer) of tracks per vertex. The default is 2.")
23 self.addOption (
'selectionFlags', [
'DFCommonJets_eventClean_LooseBad'], type=
None,
24 info=
"lags (list of strings) to use for jet cleaning. The default is "
25 "['DFCommonJets_eventClean_LooseBad'].")
28 self.addOption (
'invertFlags', [0], type=
None,
29 info=
"list of booleans determining whether to invert the cut of the "
30 "above selectionFlags. The default is [0].")
31 self.addOption (
'GRLDict', {}, type=
None)
32 self.addOption (
'noFilter',
False, type=bool,
33 info=
"do apply event decoration, but do not filter. The default is False, i.e. 'We decorate events but do not filter' ")
36 """ returns a reasonable set of GRLs that should be suited for most analyses """
39 return [
'GoodRunsLists/data15_13TeV/20170619/data15_13TeV.periodAllYear_DetStatus-v89-pro21-02_Unknown_PHYS_StandardGRL_All_Good_25ns.xml']
40 elif data_year == 2016:
41 return [
'GoodRunsLists/data16_13TeV/20180129/data16_13TeV.periodAllYear_DetStatus-v89-pro21-01_DQDefects-00-02-04_PHYS_StandardGRL_All_Good_25ns.xml']
42 elif data_year == 2017:
43 return [
'GoodRunsLists/data17_13TeV/20180619/data17_13TeV.periodAllYear_DetStatus-v99-pro22-01_Unknown_PHYS_StandardGRL_All_Good_25ns_Triggerno17e33prim.xml']
44 elif data_year == 2018:
45 return [
'GoodRunsLists/data18_13TeV/20190318/data18_13TeV.periodAllYear_DetStatus-v102-pro22-04_Unknown_PHYS_StandardGRL_All_Good_25ns_Triggerno17e33prim.xml']
46 elif data_year == 2022:
47 return [
'GoodRunsLists/data22_13p6TeV/20230207/data22_13p6TeV.periodAllYear_DetStatus-v109-pro28-04_MERGED_PHYS_StandardGRL_All_Good_25ns.xml']
48 elif data_year == 2023:
49 return [
'GoodRunsLists/data23_13p6TeV/20230712/data23_13p6TeV.periodAllYear_DetStatus-v110-pro31-05_MERGED_PHYS_StandardGRL_All_Good_25ns.xml']
51 raise ValueError (f
"Data year {data_year} is not recognised for automatic GRL retrieval!")
55 if config.dataType()
is DataType.Data:
57 """ here we only decorate the PHYSLITE events with a boolean and don't do any cleaning"""
60 for GRLDecoratorName,GRLFile
in (self.GRLDict).
items():
61 alg = config.createAlgorithm(
'GRLSelectorAlg', GRLDecoratorName )
62 config.addPrivateTool(
'Tool',
'GoodRunsListSelectionTool' )
63 alg.Tool.GoodRunsListVec = GRLFile
64 alg.grlKey =
"EventInfo." + GRLDecoratorName
68 alg = config.createAlgorithm(
'GRLSelectorAlg',
'GRLSelectorAlg' )
69 config.addPrivateTool(
'Tool',
'GoodRunsListSelectionTool' )
71 alg.Tool.GoodRunsListVec = self.userGRLFiles
73 alg.Tool.GoodRunsListVec = self.
getDefaultGRLs( config.dataYear() )
76 if self.runPrimaryVertexSelection:
77 alg = config.createAlgorithm(
'CP::VertexSelectionAlg',
78 'PrimaryVertexSelectorAlg' )
79 alg.VertexContainer =
'PrimaryVertices'
81 alg.MinTracks = self.minTracksPerVertex
84 if self.runEventCleaning:
85 if config.dataType()
is DataType.Data:
86 alg = config.createAlgorithm(
'CP::EventStatusSelectionAlg',
'EventStatusSelectionAlg' )
87 alg.FilterKey =
'EventErrorState'
88 alg.FilterDescription =
'selecting events without any error state set'
90 alg = config.createAlgorithm(
'CP::EventFlagSelectionAlg',
'EventFlagSelectionAlg' )
91 alg.FilterKey =
'JetCleaning'
92 alg.selectionFlags = [f
'{sel},as_char' for sel
in self.selectionFlags]
93 alg.invertFlags = self.invertFlags
94 alg.FilterDescription = f
"selecting events passing: {','.join(alg.selectionFlags)}"
100 runPrimaryVertexSelection = None,
101 runEventCleaning = None,
106 """Create a basic event cleaning analysis algorithm sequence
109 runPrimaryVertexSelection -- whether to run primary vertex selection
110 runEventCleaning -- wether to run event cleaning
111 userGRLFiles -- a list of GRL files to select data from
112 GRLDict -- a dictionary of GRL files to determine decoration names
113 noFilter -- wether to apply event decoration or not
116 config = EventCleaningBlock ()
117 config.setOptionValue (
'runPrimaryVertexSelection', runPrimaryVertexSelection)
118 config.setOptionValue (
'runEventCleaning', runEventCleaning)
119 config.setOptionValue (
'userGRLFiles', userGRLFiles)
120 config.setOptionValue (
'GRLDict', GRLDict)
121 config.setOptionValue (
'noFilter', noFilter)