Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
JetMonitoringStandard.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 '''@file JetMonitoringExample.py
6 @author P-A. Delsart
7 @date 2019-03-12
8 @brief Main python configuration for the Run III Jet Monitoring
9 '''
10 from AthenaMonitoring.DQConfigFlags import DQDataType
11 from JetMonitoring.JetMonitoringConfig import JetMonAlgSpec, HistoSpec, EventHistoSpec, SelectSpec, VarSpec
12 
13 # *********************************************
14 # Define a list of histograms we want to draw for all jet containers.
15 # Write this list as a list of Jet histo specifications. Read comments below for details on specifications
16 commonHistoSpecs = [
17  # Specification can be simple string.
18  # in this case they are aliases to standard spec has defined in JetStandardHistoSpecs.knownHistos
19  "pt",
20  "highpt",
21  "m",
22  "eta",
23  "rapidity",
24  "phi",
25  "EMFrac",
26  "LArQuality",
27  "AverageLArQF",
28  "HECQuality",
29  "HECFrac",
30  "FracSamplingMax",
31  "FracSamplingMaxIndex",
32  "EM3Frac",
33  "Tile0Frac",
34  "CentroidR",
35  "OotFracClusters5",
36  "OotFracClusters10",
37  "JVF",
38  "JVF[0]",
39  "JVF[1]",
40  "Jvt",
41  "Timing",
42  "nconstit",
43  "N90Constituents",
44  "leadingJetsRel",
45  "JetConstitScaleMomentum_pt","JetEMScaleMomentum_pt","JetPileupScaleMomentum_pt","JetEtaJESScaleMomentum_pt",
46  "JetConstitScaleMomentum_eta","JetEMScaleMomentum_eta","JetPileupScaleMomentum_eta","JetEtaJESScaleMomentum_eta",
47  "JetConstitScaleMomentum_phi","JetEMScaleMomentum_phi","JetPileupScaleMomentum_phi","JetEtaJESScaleMomentum_phi",
48 
49 
50  # or we can directly add our custom histo specification in the form of a HistoSpec
51  # (HistoSpec is nothing more than a specialized python dictionnary)
52  EventHistoSpec('njets',(100,0.,100.),title="Number of Jets;Njets;"),
53  EventHistoSpec('njetsPt20',(100,0.,100.),title="Number of Jets pT>20 GeV;Njets;"),
54  EventHistoSpec('njetsPt200',(800,0.,8000.),title="Number of Jets pT>200 GeV;Njets;"),
55  # the basic call is : HistoSpec( variable, histobins, title='histotile;xtitle,ytitle')
56 
57 
58  # 2D histos, by concatenating 1D histo specifications :
59  "m;pt",
60  "eta;pt",
61  "eta;phi",
62  "eta;Timing",
63 
64  # TProfile2D : just use 3 variables. For now the sytem will automatically
65  # interpret it as a TProfile2D (the 3rd variable being profiled)
66  "eta;phi;e", # --> Average Energy vs pt and eta
67  "eta;phi;pt", # --> Average pt vs phi and eta
68 
69  # Histograms build from a selection of filtered jets.
70  # Use a SelectSpec dictionary to define the selection, and the histo to be drawn from it.
71  SelectSpec( 'central', # the name of the selection
72  '|eta|<0.5', # selection expression. The form 'min<var<max' is automatically interpreted.
73  path='CentralJets', # force the path where the histos are saved in the final ROOT file
74  FillerTools = ["pt","m","eta","phi","EMFrac","Tile0Frac","LArQuality","nconstit","N90Constituents",
75  "JetConstitScaleMomentum_pt","JetEMScaleMomentum_pt","JetPileupScaleMomentum_pt","JetEtaJESScaleMomentum_pt",
76  "JetConstitScaleMomentum_eta","JetEMScaleMomentum_eta","JetPileupScaleMomentum_eta","JetEtaJESScaleMomentum_eta",
77  "JetConstitScaleMomentum_phi","JetEMScaleMomentum_phi","JetPileupScaleMomentum_phi","JetEtaJESScaleMomentum_phi",
78  ] ),
79 
80  SelectSpec( 'tilegap3', # the name of the selection
81  '1.0<|eta|<1.4', # selection expression. The form 'min<var<max' is automatically interpreted.
82  path='TileGap3', # force the path where the histos are saved in the final ROOT file
83  FillerTools = ["pt","m","eta","phi","EMFrac","Tile0Frac","HECFrac","LArQuality","nconstit","N90Constituents",
84  ] ),
85 
86  # another selection : only leading jets
87  SelectSpec( 'leading',
88  '', # no selection on variables
89  SelectedIndex=0, # force 1st (leading) jet (we would set 1 for sub-leading jets)
90  path='LeadingJets', # force the path where the histos are saved in the final ROOT file
91  FillerTools = ["pt","m","eta","phi","EMFrac","Tile0Frac","HECFrac","LArQuality","nconstit","N90Constituents",
92  "JetConstitScaleMomentum_pt","JetEMScaleMomentum_pt","JetPileupScaleMomentum_pt","JetEtaJESScaleMomentum_pt",
93  "JetConstitScaleMomentum_eta","JetEMScaleMomentum_eta","JetPileupScaleMomentum_eta","JetEtaJESScaleMomentum_eta",
94  "JetConstitScaleMomentum_phi","JetEMScaleMomentum_phi","JetPileupScaleMomentum_phi","JetEtaJESScaleMomentum_phi",
95  ] ),
96 
97  # another selection : only subleading jets
98  SelectSpec( 'subleading',
99  '', # no selection on variables
100  SelectedIndex=1, # force 2nd (sub-leading) jet
101  path='SubleadingJets', # force the path where the histos are saved in the final ROOT file
102  FillerTools = ["pt","m","eta","phi","EMFrac","Tile0Frac","HECFrac","LArQuality","nconstit","N90Constituents",
103  "JetConstitScaleMomentum_pt","JetEMScaleMomentum_pt","JetPileupScaleMomentum_pt","JetEtaJESScaleMomentum_pt",
104  "JetConstitScaleMomentum_eta","JetEMScaleMomentum_eta","JetPileupScaleMomentum_eta","JetEtaJESScaleMomentum_eta",
105  "JetConstitScaleMomentum_phi","JetEMScaleMomentum_phi","JetPileupScaleMomentum_phi","JetEtaJESScaleMomentum_phi",
106  ] ),
107 
108  # another selection : only very high pT jets
109  SelectSpec( 'highptrange2TeVto8TeV','2000<pt:GeV<8000',path='highptrange2TeVto8TeV',FillerTools = ["highpt","m","eta","phi","eta;phi",] ),
110  SelectSpec( 'highptrange1TeVto2TeV','1000<pt:GeV<2000',path='highptrange1TeVto2TeV',FillerTools = ["highpt","m","eta","phi","eta;phi",] ),
111  SelectSpec( 'highptrange500GeVto1TeV','500<pt:GeV<1000',path='highptrange500GeVto1TeV',FillerTools = ["highpt","m","eta","phi","eta;phi",] ),
112  SelectSpec( 'highptrange200GeVto500GeV','200<pt:GeV<500',path='highptrange200GeVto500GeV',FillerTools = ["highpt","m","eta","phi","eta;phi",] ),
113 
114  # Selecting jets failing the LooseBad selection from the JetCleaningTool.
115  SelectSpec( 'LooseBadFailedJets', 'LooseBad', InverseJetSel=True,
116  FillerTools = ["pt","phi","eta","m","EMFrac","LArQuality","Tile0Frac","HECFrac","nconstit","N90Constituents",
117  "phi;eta","phi;eta;e","phi;eta;pt",
118  ]),
119 
120  # Selecting jets passing the LooseBad selection from the JetCleaningTool.
121  SelectSpec( 'LooseBadJets',
122  'LooseBad', # this is not in the form 'min<x<max', so it will be assumed 'LooseBad' is an entry existing in JetStandardHistoSpecs.knownSelector
123  FillerTools = [ "pt","eta","phi","m","EMFrac","LArQuality","Tile0Frac","HECFrac","nconstit","N90Constituents",
124  "phi;eta","phi;eta;e","phi;eta;pt",
125  ] ),
126  ] # end commonHistoSpecs
127 
128 # Separate these out because they cannot run in cosmics
129 jvfHistosSpec = [
130  SelectSpec( 'highJVF',
131  '0.3<JVF[0]', # JVF is a vector<float> for each jets. Here we cut on the 0th entry of this vector
132  FillerTools = ["pt","m","eta","phi",
133  ] ),
134 ]
135 
136 topoHistosSpec = [
137  # histos common to all topo jets. Energy By Sampling layer plots.
138  HistoSpec("PreSamplerB",(100,0.,200.),title="Energy in PreSamplerB;E;Entries",xvar=VarSpec('EnergyPerSampling[0]')),
139  HistoSpec("EMB1",(100,0.,200.),title="Energy in EMB1;E;Entries",xvar=VarSpec('EnergyPerSampling[1]')),
140  HistoSpec("EMB2",(100,0.,200.),title="Energy in EMB2;E;Entries",xvar=VarSpec('EnergyPerSampling[2]')),
141  HistoSpec("EMB3",(100,0.,200.),title="Energy in EMB3;E;Entries",xvar=VarSpec('EnergyPerSampling[3]')),
142  HistoSpec("PreSamplerE",(100,0.,200.),title="Energy in PreSamplerE;E;Entries",xvar=VarSpec('EnergyPerSampling[4]')),
143  HistoSpec("EME1",(100,0.,200.),title="Energy in EME2;E;Entries",xvar=VarSpec('EnergyPerSampling[5]')),
144  HistoSpec("EME2",(100,0.,200.),title="Energy in EME2;E;Entries",xvar=VarSpec('EnergyPerSampling[6]')),
145  HistoSpec("EME3",(100,0.,200.),title="Energy in EME3;E;Entries",xvar=VarSpec('EnergyPerSampling[7]')),
146  HistoSpec("HEC0",(100,0.,200.),title="Energy in HEC0;E;Entries",xvar=VarSpec('EnergyPerSampling[8]')),
147  HistoSpec("HEC1",(100,0.,200.),title="Energy in HEC1;E;Entries",xvar=VarSpec('EnergyPerSampling[9]')),
148  HistoSpec("HEC2",(100,0.,200.),title="Energy in HEC2;E;Entries",xvar=VarSpec('EnergyPerSampling[10]')),
149  HistoSpec("HEC3",(100,0.,200.),title="Energy in HEC3;E;Entries",xvar=VarSpec('EnergyPerSampling[11]')),
150  HistoSpec("TileBar0",(100,0.,200.),title="Energy in TileBar0;E;Entries",xvar=VarSpec('EnergyPerSampling[12]')),
151  HistoSpec("TileBar1",(100,0.,200.),title="Energy in TileBar1;E;Entries",xvar=VarSpec('EnergyPerSampling[13]')),
152  HistoSpec("TileBar2",(100,0.,200.),title="Energy in TileBar1;E;Entries",xvar=VarSpec('EnergyPerSampling[14]')),
153  HistoSpec("TileGap1",(100,0.,200.),title="Energy in TileGap1;E;Entries",xvar=VarSpec('EnergyPerSampling[15]')),
154  HistoSpec("TileGap2",(100,0.,200.),title="Energy in TileGap2;E;Entries",xvar=VarSpec('EnergyPerSampling[16]')),
155  HistoSpec("TileGap3",(100,0.,200.),title="Energy in TileGap3;E;Entries",xvar=VarSpec('EnergyPerSampling[17]')),
156  HistoSpec("TileExt0",(100,0.,200.),title="Energy in TileExt0;E;Entries",xvar=VarSpec('EnergyPerSampling[18]')),
157  HistoSpec("TileExt1",(100,0.,200.),title="Energy in TileExt1;E;Entries",xvar=VarSpec('EnergyPerSampling[19]')),
158  HistoSpec("TileExt2",(100,0.,200.),title="Energy in TileExt2;E;Entries",xvar=VarSpec('EnergyPerSampling[20]')),
159  HistoSpec("FCAL0",(100,0.,200.),title="Energy in FCAL0;E;Entries",xvar=VarSpec('EnergyPerSampling[21]')),
160  HistoSpec("FCAL1",(100,0.,200.),title="Energy in FCAL1;E;Entries",xvar=VarSpec('EnergyPerSampling[22]')),
161  HistoSpec("FCAL2",(100,0.,200.),title="Energy in FCAL2;E;Entries",xvar=VarSpec('EnergyPerSampling[23]')),
162 ]
163 
164 pflowHistosSpec = [
165  # histos common to all PFlow jets. These are defined in JetStandardHistoSpecs.py
166  "SumPtChargedPFOPt500[0]",
167  "SumPtTrkPt500[0]",
168  "NumTrkPt500[0]",
169  "NumTrkPt1000[0]",
170  "fCharged",
171 ]
172 
173 
174 
175 def jetMonAlgConfig( jetName, inputFlags, truthJetName='', trigger=''):
176  """returns a specification of a JetMonitoringAlg (in the form of a JetMonAlgSpec dictionnary).
177  """
178 
179  # we use a specialized dictionnary (JetMonAlgSpec) which will be translated into the final C++ tool
180  jetAlgConfig = JetMonAlgSpec(
181  jetName+"MonAlg",
182  JetContainerName = jetName,
183  TriggerChain = trigger ,
184  )
185 
186  # the list of histos specifications
187  histoSpecs = []
188 
189  # then add pre-defined lists as defined above :
190  histoSpecs += commonHistoSpecs
191 
192  if inputFlags.DQ.DataType is not DQDataType.Cosmics:
193  histoSpecs += jvfHistosSpec
194 
195  if 'Topo' in jetName:
196  histoSpecs += topoHistosSpec
197  if 'PFlow' in jetName:
198  histoSpecs += pflowHistosSpec
199 
200 
201  if truthJetName != "" :
202  # then add histos showing efficiency and pT responses vs True
203  from JetMonitoring.JetStandardHistoSpecs import responseAndEffSpecMap
204  if truthJetName not in responseAndEffSpecMap:
205  print( "ERROR !! can't schedule a JetHistoResponseAndEff for truth container : ",truthJetName, ". No specification available" )
206  return None
207 
208  histoSpecs +=[ responseAndEffSpecMap[truthJetName] ]
209 
210  # finally all all histos specs to our JetMonitoringAlg specification :
211  jetAlgConfig.appendHistos( * histoSpecs)
212 
213  return jetAlgConfig
214 
215 
216 
217 def standardJetMonitoring(inputFlags):
218  """Standard jet monitoring function to be inserted from top-level algs.
219  returns an a component accumulator as given by AthMonitorCfgHelper.result()
220  Details of what goes into jet monitoring is implemented by dedicated functions such as jetMonAlgConfig().
221  """
222 
223  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
224  rv = ComponentAccumulator()
225 
226  # do not run monitoring in RAWtoESD
227  if inputFlags.DQ.Environment == 'tier0Raw':
228  return rv
229 
230  from AthenaMonitoring import AthMonitorCfgHelper
231  helper = AthMonitorCfgHelper(inputFlags,'JetMonitoring')
232 
233  # create a list of JetMonitoringAlg specifications
234  jetAlgConfs = []
235 
236  if inputFlags.Reco.EnableHI:
237  if inputFlags.Tracking.doUPC:
238  jetAlgConfs.append(jetMonAlgConfig( "AntiKt4EMPFlowJets", inputFlags))
239  else:
240  jetAlgConfs.append(jetMonAlgConfig( "AntiKt4HIJets", inputFlags))
241  else:
242  # use the helper function defined above :
243  #jetMonAlgConfig( "AntiKt4LCTopoJets", truthJetName="AntiKt4TruthJets"), #How can we make sure truth jets are available ??
244  jetAlgConfs.append(jetMonAlgConfig( "AntiKt4LCTopoJets", inputFlags))
245  jetAlgConfs.append(jetMonAlgConfig( "AntiKt4EMTopoJets", inputFlags))
246  jetAlgConfs.append(jetMonAlgConfig( "AntiKt4EMPFlowJets", inputFlags))
247 
248  # Configure filter tools
249  from AthenaMonitoring.EventFlagFilterToolConfig import EventFlagFilterToolCfg
250 # from AthenaMonitoring.AtlasReadyFilterConfig import AtlasReadyFilterCfg
251  from AthenaMonitoring.BadLBFilterToolConfig import LArBadLBFilterToolCfg
252 # from AthenaMonitoring.FilledBunchFilterToolConfig import FilledBunchFilterToolCfg
253 
254  # schedule each JetMonitoringAlg by invoking the toAlg() methods of the config specification
255  for conf in jetAlgConfs:
256  alg = conf.toAlg(helper)
257  alg.FilterTools = [ EventFlagFilterToolCfg(inputFlags),helper.resobj.popToolsAndMerge(LArBadLBFilterToolCfg(inputFlags))]
258 
259  rv.merge(helper.result()) # the AthMonitorCfgHelper returns an accumulator to be used by the general configuration system.
260  return rv
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
JetMonitoringStandard.jetMonAlgConfig
def jetMonAlgConfig(jetName, inputFlags, truthJetName='', trigger='')
Definition: JetMonitoringStandard.py:175
python.BadLBFilterToolConfig.LArBadLBFilterToolCfg
def LArBadLBFilterToolCfg(inputFlags, origDbTag=None)
Definition: BadLBFilterToolConfig.py:100
JetMonitoringStandard.standardJetMonitoring
def standardJetMonitoring(inputFlags)
Definition: JetMonitoringStandard.py:217
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.EventFlagFilterToolConfig.EventFlagFilterToolCfg
def EventFlagFilterToolCfg(flags, name="EventFlagFilter", doLAr=True, doTile=True, doSCT=True, doCore=True, alwaysReturnTrue=False)
Definition: EventFlagFilterToolConfig.py:5