CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Reco.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 """
3 _pp_
4 
5 Scenario supporting proton collisions
6 
7 """
8 from __future__ import print_function
9 
10 import os
11 import sys
12 
14 from Configuration.DataProcessing.Utils import stepALCAPRODUCER,stepSKIMPRODUCER,addMonitoring,dictIO,dqmIOSource,harvestingMode,dqmSeq,gtNameAndConnect
15 import FWCore.ParameterSet.Config as cms
16 from Configuration.DataProcessing.RecoTLR import customisePrompt,customiseExpress
17 
18 class Reco(Scenario):
19  def __init__(self):
20  Scenario.__init__(self)
21  self.recoSeq=''
22  self.cbSc=self.__class__.__name__
23  self.promptModifiers = cms.ModifierChain()
24  self.expressModifiers = cms.ModifierChain()
25  self.visModifiers = cms.ModifierChain()
26  """
27  _pp_
28 
29  Implement configuration building for data processing for proton
30  collision data taking
31 
32  """
33 
34 
35  def _checkRepackedFlag(self, options, **args):
36  if 'repacked' in args:
37  if args['repacked'] == True:
38  options.isRepacked = True
39  else:
40  options.isRepacked = False
41 
42 
43 
44  def promptReco(self, globalTag, **args):
45  """
46  _promptReco_
47 
48  Proton collision data taking prompt reco
49 
50  """
51  step = stepALCAPRODUCER(args['skims'])
52  PhysicsSkimStep = ''
53  if ("PhysicsSkims" in args) :
54  PhysicsSkimStep = stepSKIMPRODUCER(args['PhysicsSkims'])
55  dqmStep = dqmSeq(args,'')
56  options = Options()
57  options.__dict__.update(defaultOptions.__dict__)
58  options.scenario = self.cbSc
59  if ('nThreads' in args) :
60  options.nThreads=args['nThreads']
61 
62  miniAODStep=''
63 
64 # if miniAOD is asked for - then retrieve the miniaod config
65  if 'outputs' in args:
66  for a in args['outputs']:
67  if a['dataTier'] == 'MINIAOD':
68  miniAODStep=',PAT'
69 
70  self._checkRepackedFlag(options, **args)
71 
72  if 'customs' in args:
73  options.customisation_file=args['customs']
74 
75  eiStep=''
76 
77  options.step = 'RAW2DIGI,L1Reco,RECO'+self.recoSeq+eiStep+step+PhysicsSkimStep+miniAODStep+',DQM'+dqmStep+',ENDJOB'
78 
79  dictIO(options,args)
80  options.conditions = gtNameAndConnect(globalTag, args)
81 
82  process = cms.Process('RECO', cms.ModifierChain(self.eras, self.promptModifiers) )
83  cb = ConfigBuilder(options, process = process, with_output = True)
84 
85  # Input source
86  process.source = cms.Source("PoolSource",
87  fileNames = cms.untracked.vstring()
88  )
89  cb.prepare()
90 
91  addMonitoring(process)
92 
93  return process
94 
95 
96  def expressProcessing(self, globalTag, **args):
97  """
98  _expressProcessing_
99 
100  Proton collision data taking express processing
101 
102  """
103  skims = args['skims']
104  # the AlCaReco skims for PCL should only run during AlCaSkimming step which uses the same configuration on the Tier0 side, for this reason we drop them here
105  pclWkflws = [x for x in skims if "PromptCalibProd" in x]
106  for wfl in pclWkflws:
107  skims.remove(wfl)
108 
109  step = stepALCAPRODUCER(skims)
110  dqmStep= dqmSeq(args,'')
111  options = Options()
112  options.__dict__.update(defaultOptions.__dict__)
113  options.scenario = self.cbSc
114  if ('nThreads' in args) :
115  options.nThreads=args['nThreads']
116 
117  eiStep=''
118 
119  options.step = 'RAW2DIGI,L1Reco,RECO'+self.recoSeq+eiStep+step+',DQM'+dqmStep+',ENDJOB'
120 
121  dictIO(options,args)
122  options.conditions = gtNameAndConnect(globalTag, args)
123 
124 
125  options.filein = 'tobeoverwritten.xyz'
126  if 'inputSource' in args:
127  options.filetype = args['inputSource']
128  process = cms.Process('RECO', cms.ModifierChain(self.eras, self.expressModifiers) )
129 
130  if 'customs' in args:
131  options.customisation_file=args['customs']
132 
133  self._checkRepackedFlag(options,**args)
134 
135  cb = ConfigBuilder(options, process = process, with_output = True, with_input = True)
136 
137  cb.prepare()
138 
139  addMonitoring(process)
140 
141  return process
142 
143 
144  def visualizationProcessing(self, globalTag, **args):
145  """
146  _visualizationProcessing_
147 
148  """
149 
150  options = Options()
151  options.__dict__.update(defaultOptions.__dict__)
152  options.scenario = self.cbSc
153  # FIXME: do we need L1Reco here?
154  options.step =''
155  if 'preFilter' in args:
156  options.step +='FILTER:'+args['preFilter']+','
157 
158  eiStep=''
159 
160  options.step += 'RAW2DIGI,L1Reco,RECO'+eiStep+',ENDJOB'
161 
162 
163  dictIO(options,args)
164  options.conditions = gtNameAndConnect(globalTag, args)
165  options.timeoutOutput = True
166  # FIXME: maybe can go...maybe not
167  options.filein = 'tobeoverwritten.xyz'
168 
169  if 'inputSource' in args:
170  options.filetype = args['inputSource']
171  else:
172  # this is the default as this is what is needed on the OnlineCluster
173  options.filetype = 'DQMDAQ'
174 
175  print("Using %s source"%options.filetype)
176 
177  process = cms.Process('RECO', cms.ModifierChain(self.eras, self.visModifiers) )
178 
179  if 'customs' in args:
180  options.customisation_file=args['customs']
181 
182  self._checkRepackedFlag(options, **args)
183 
184  cb = ConfigBuilder(options, process = process, with_output = True, with_input = True)
185 
186  cb.prepare()
187 
188 
189 
190 
191  # FIXME: not sure abou this one...drop for the moment
192  # addMonitoring(process)
193 
194  return process
195 
196 
197 
198 
199  def alcaSkim(self, skims, **args):
200  """
201  _alcaSkim_
202 
203  AlcaReco processing & skims for proton collisions
204 
205  """
206 
207  step = ""
208  pclWflws = [x for x in skims if "PromptCalibProd" in x]
209  skims = [x for x in skims if x not in pclWflws]
210 
211  if len(pclWflws):
212  step += 'ALCA:'+('+'.join(pclWflws))
213 
214  if len( skims ) > 0:
215  if step != "":
216  step += ","
217  step += "ALCAOUTPUT:"+('+'.join(skims))
218 
219  options = Options()
220  options.__dict__.update(defaultOptions.__dict__)
221  options.scenario = self.cbSc
222  options.step = step
223  options.conditions = args['globaltag'] if 'globaltag' in args else 'None'
224  if 'globalTagConnect' in args and args['globalTagConnect'] != '':
225  options.conditions += ','+args['globalTagConnect']
226 
227  options.triggerResultsProcess = 'RECO'
228 
229  if 'customs' in args:
230  options.customisation_file=args['customs']
231 
232  process = cms.Process('ALCA', self.eras)
233  cb = ConfigBuilder(options, process = process)
234 
235  # Input source
236  process.source = cms.Source(
237  "PoolSource",
238  fileNames = cms.untracked.vstring()
239  )
240 
241  cb.prepare()
242 
243  # FIXME: dirty hack..any way around this?
244  # Tier0 needs the dataset used for ALCAHARVEST step to be a different data-tier
245  for wfl in pclWflws:
246  methodToCall = getattr(process, 'ALCARECOStream'+wfl)
247  methodToCall.dataset.dataTier = cms.untracked.string('ALCAPROMPT')
248 
249  return process
250 
251 
252  def dqmHarvesting(self, datasetName, runNumber, globalTag, **args):
253  """
254  _dqmHarvesting_
255 
256  Proton collisions data taking DQM Harvesting
257 
258  """
259  options = defaultOptions
260  options.scenario = self.cbSc
261  options.step = "HARVESTING"+dqmSeq(args,':dqmHarvesting')
262  options.name = "EDMtoMEConvert"
263  options.conditions = gtNameAndConnect(globalTag, args)
264 
265  process = cms.Process("HARVESTING", self.eras)
266  process.source = dqmIOSource(args)
267 
268  if 'customs' in args:
269  options.customisation_file=args['customs']
270 
271  configBuilder = ConfigBuilder(options, process = process)
272  configBuilder.prepare()
273 
274  harvestingMode(process,datasetName,args,rANDl=False)
275  return process
276 
277 
278  def alcaHarvesting(self, globalTag, datasetName, **args):
279  """
280  _alcaHarvesting_
281 
282  Proton collisions data taking AlCa Harvesting
283 
284  """
285  skims = []
286  if 'skims' in args:
287  skims = args['skims']
288 
289 
290  if 'alcapromptdataset' in args:
291  skims.append('@'+args['alcapromptdataset'])
292 
293  if len(skims) == 0: return None
294  options = defaultOptions
295  options.scenario = self.cbSc if hasattr(self,'cbSc') else self.__class__.__name__
296  options.step = "ALCAHARVEST:"+('+'.join(skims))
297  options.name = "ALCAHARVEST"
298  options.conditions = gtNameAndConnect(globalTag, args)
299 
300  process = cms.Process("ALCAHARVEST", self.eras)
301  process.source = cms.Source("PoolSource")
302 
303  if 'customs' in args:
304  options.customisation_file=args['customs']
305 
306  configBuilder = ConfigBuilder(options, process = process)
307  configBuilder.prepare()
308 
309  #
310  # customise process for particular job
311  #
312  process.source.processingMode = cms.untracked.string('RunsAndLumis')
313  process.source.fileNames = cms.untracked(cms.vstring())
314  process.maxEvents.input = -1
315  process.dqmSaver.workflow = datasetName
316 
317  return process
318 
319  def skimming(self, skims, globalTag,**options):
320  """
321  _skimming_
322 
323  skimming method overload for the prompt skiming
324 
325  """
326  options = defaultOptions
327  options.scenario = self.cbSc if hasattr(self,'cbSc') else self.__class__.__name__
328  options.step = "SKIM:"+('+'.join(skims))
329  options.name = "SKIM"
330  options.conditions = gtNameAndConnect(globalTag, args)
331  process = cms.Process("SKIM", self.eras)
332  process.source = cms.Source("PoolSource")
333 
334  if 'customs' in args:
335  options.customisation_file=args['customs']
336 
337  configBuilder = ConfigBuilder(options, process = process)
338  configBuilder.prepare()
339 
340  return process
341 
342  """
343  def repack(self, **args):
344  options = defaultOptions
345  dictIO(options,args)
346  options.filein='file.dat'
347  options.filetype='DAT'
348  options.scenario = self.cbSc if hasattr(self,'cbSc') else self.__class__.__name__
349  process = cms.Process('REPACK', self.eras)
350  cb = ConfigBuilder(options, process = process, with_output = True,with_input=True)
351  cb.prepare()
352  print cb.pythonCfgCode
353  return process
354  """
def alcaHarvesting
Definition: Reco.py:278
def dqmSeq
Definition: Utils.py:129
visModifiers
Definition: Reco.py:25
def stepALCAPRODUCER
Definition: Utils.py:9
expressModifiers
Definition: Reco.py:24
def skimming
Definition: Reco.py:319
def addMonitoring
Definition: Utils.py:38
def __init__
Definition: Reco.py:19
def dqmHarvesting
Definition: Reco.py:252
def stepSKIMPRODUCER
Definition: Utils.py:24
def promptReco
Definition: Reco.py:44
promptModifiers
Definition: Reco.py:23
def gtNameAndConnect
Definition: Utils.py:135
def dqmIOSource
Definition: Utils.py:103
def visualizationProcessing
Definition: Reco.py:144
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def dictIO
Definition: Utils.py:121
def _checkRepackedFlag
Definition: Reco.py:35
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def harvestingMode
Definition: Utils.py:114
def alcaSkim
Definition: Reco.py:199
recoSeq
Definition: Reco.py:21
cbSc
Definition: Reco.py:22
def expressProcessing
Definition: Reco.py:96