CMS 3D CMS Logo

AlCa.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 """
3 _AlCa_
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,dqmIOSource,harvestingMode,dictIO,gtNameAndConnect,addMonitoring
15 import FWCore.ParameterSet.Config as cms
16 
17 class AlCa(Scenario):
18  def __init__(self):
19  Scenario.__init__(self)
20 
21  """
22  _AlCa_
23 
24  Implement configuration building for data processing for proton
25  collision data taking
26 
27  """
28 
29  def skimsIfNotGiven(self,args,sl):
30  if not 'skims' in args:
31  args['skims']=sl
32 
33  def promptReco(self, globalTag, **args):
34  if not 'skims' in args:
35  args['skims']=self.skims
36  step = stepALCAPRODUCER(args['skims'])
37  options = Options()
38  options.__dict__.update(defaultOptions.__dict__)
39  options.scenario = "pp"
40  options.step = step
41  dictIO(options,args)
42  options.conditions = gtNameAndConnect(globalTag, args)
43 
44  process = cms.Process('RECO', self.eras)
45  cb = ConfigBuilder(options, process = process, with_output = True)
46 
47  # Input source
48  process.source = cms.Source("PoolSource",
49  fileNames = cms.untracked.vstring()
50  )
51  cb.prepare()
52 
53  return process
54 
55  def alcaSkim(self, skims, **args):
56  """
57  _alcaSkim_
58 
59  AlcaReco processing & skims for proton collisions
60 
61  """
62  step = ""
63  pclWflws = [x for x in skims if "PromptCalibProd" in x]
64  skims = [x for x in skims if x not in pclWflws]
65 
66  if len(pclWflws):
67  step += 'ALCA:'+('+'.join(pclWflws))
68 
69  if len(skims) > 0:
70  if step != "":
71  step += ","
72  step += "ALCAOUTPUT:"+('+'.join(skims))
73 
74  options = Options()
75  options.__dict__.update(defaultOptions.__dict__)
76  options.scenario = "pp"
77  options.step = step
78  options.conditions = args['globaltag'] if 'globaltag' in args else 'None'
79  if 'globalTagConnect' in args and args['globalTagConnect'] != '':
80  options.conditions += ','+args['globalTagConnect']
81 
82  options.triggerResultsProcess = 'RECO'
83 
84  process = cms.Process('ALCA', self.eras)
85  cb = ConfigBuilder(options, process=process)
86 
87  # Input source
88  process.source = cms.Source(
89  "PoolSource",
90  fileNames=cms.untracked.vstring()
91  )
92 
93  cb.prepare()
94 
95  # FIXME: dirty hack..any way around this?
96  # Tier0 needs the dataset used for ALCAHARVEST step to be a different data-tier
97  for wfl in pclWflws:
98  methodToCall = getattr(process, 'ALCARECOStream'+wfl)
99  methodToCall.dataset.dataTier = cms.untracked.string('ALCAPROMPT')
100 
101  return process
102 
103 
104  def dqmHarvesting(self, datasetName, runNumber, globalTag, **args):
105  """
106  _dqmHarvesting_
107 
108  Proton collisions data taking DQM Harvesting
109 
110  """
111  options = defaultOptions
112  options.scenario = "pp"
113  options.step = "HARVESTING:alcaHarvesting"
114  options.name = "EDMtoMEConvert"
115  options.conditions = gtNameAndConnect(globalTag, args)
116 
117  process = cms.Process("HARVESTING", self.eras)
118  process.source = dqmIOSource(args)
119  configBuilder = ConfigBuilder(options, process = process)
120  configBuilder.prepare()
121 
122  #
123  # customise process for particular job
124  #
125  #process.source.processingMode = cms.untracked.string('RunsAndLumis')
126  #process.source.fileNames = cms.untracked(cms.vstring())
127  #process.maxEvents.input = -1
128  #process.dqmSaver.workflow = datasetName
129  #process.dqmSaver.saveByLumiSection = 1
130  harvestingMode(process,datasetName,args)
131 
132  return process
133 
134  def alcaHarvesting(self, globalTag, datasetName, **args):
135  """
136  _alcaHarvesting_
137 
138  Proton collisions data taking AlCa Harvesting
139 
140  """
141  skims = []
142  if 'skims' in args:
143  skims = args['skims']
144 
145 
146  if 'alcapromptdataset' in args:
147  skims.append('@'+args['alcapromptdataset'])
148 
149  if len(skims) == 0: return None
150  options = defaultOptions
151  options.scenario = self.cbSc if hasattr(self,'cbSc') else self.__class__.__name__
152  options.step = "ALCAHARVEST:"+('+'.join(skims))
153  options.name = "ALCAHARVEST"
154  options.conditions = gtNameAndConnect(globalTag, args)
155 
156  process = cms.Process("ALCAHARVEST", self.eras)
157  process.source = cms.Source("PoolSource")
158 
159  if 'customs' in args:
160  options.customisation_file=args['customs']
161 
162  configBuilder = ConfigBuilder(options, process = process)
163  configBuilder.prepare()
164 
165  #
166  # customise process for particular job
167  #
168  process.source.processingMode = cms.untracked.string('RunsAndLumis')
169  process.source.fileNames = cms.untracked(cms.vstring())
170  process.maxEvents.input = -1
171  process.dqmSaver.workflow = datasetName
172 
173  return process
174 
175  def expressProcessing(self, globalTag, **args):
176  """
177  _expressProcessing_
178 
179  Proton collision data taking express processing
180 
181  """
182  skims = []
183  if 'skims' in args:
184  skims = args['skims']
185  pclWkflws = [x for x in skims if "PromptCalibProd" in x]
186  for wfl in pclWkflws:
187  skims.remove(wfl)
188 
189  options = Options()
190  options.__dict__.update(defaultOptions.__dict__)
191  options.scenario = "pp"
192  options.step = stepALCAPRODUCER(skims)
193 
194  if 'outputs' in args:
195  # the RAW data-tier needs a special treatment since the event-content as defined in release is not good enough
196  outputs_Raw = [x for x in args['outputs'] if x['dataTier'] == 'RAW']
197  outputs_noRaw = [x for x in args['outputs'] if x['dataTier'] != 'RAW']
198  if len(outputs_Raw) == 1:
199  print('RAW data-tier requested')
200  options.outputDefinition = outputs_noRaw.__str__()
201 
202  # dictIO(options,args)
203  options.conditions = gtNameAndConnect(globalTag, args)
204 
205  options.filein = 'tobeoverwritten.xyz'
206  if 'inputSource' in args:
207  options.filetype = args['inputSource']
208  process = cms.Process('RECO', self.eras)
209 
210  if 'customs' in args:
211  options.customisation_file=args['customs']
212 
213  cb = ConfigBuilder(options, process = process, with_output = True, with_input = True)
214 
215  cb.prepare()
216 
217  addMonitoring(process)
218 
219  for output in outputs_Raw:
220  print(output)
221  moduleLabel = output['moduleLabel']
222  selectEvents = output.get('selectEvents', None)
223  maxSize = output.get('maxSize', None)
224 
225  outputModule = cms.OutputModule(
226  "PoolOutputModule",
227  fileName = cms.untracked.string("%s.root" % moduleLabel)
228  )
229 
230  outputModule.dataset = cms.untracked.PSet(dataTier = cms.untracked.string("RAW"))
231 
232  if maxSize != None:
233  outputModule.maxSize = cms.untracked.int32(maxSize)
234 
235  if selectEvents != None:
236  outputModule.SelectEvents = cms.untracked.PSet(
237  SelectEvents = cms.vstring(selectEvents)
238  )
239  outputModule.outputCommands = cms.untracked.vstring('drop *',
240  'keep *_*_*_HLT')
241 
242  setattr(process, moduleLabel, outputModule)
243  # outputModule=getattr(self.process,theModuleLabel)
244  setattr(process, moduleLabel+'_step', cms.EndPath(outputModule))
245  path = getattr(process, moduleLabel+'_step')
246  process.schedule.append(path)
247 
248  return process
def harvestingMode(process, datasetName, args, rANDl=True)
Definition: Utils.py:114
def expressProcessing(self, globalTag, args)
Definition: AlCa.py:175
def gtNameAndConnect(globalTag, args)
Definition: Utils.py:135
def dqmHarvesting(self, datasetName, runNumber, globalTag, args)
Definition: AlCa.py:104
def dictIO(options, args)
Definition: Utils.py:121
def skimsIfNotGiven(self, args, sl)
Definition: AlCa.py:29
def promptReco(self, globalTag, args)
Definition: AlCa.py:33
def addMonitoring(process)
Definition: Utils.py:38
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def alcaSkim(self, skims, args)
Definition: AlCa.py:55
def stepALCAPRODUCER(skims)
Definition: Utils.py:9
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def __init__(self)
Definition: AlCa.py:18
def alcaHarvesting(self, globalTag, datasetName, args)
Definition: AlCa.py:134
def dqmIOSource(args)
Definition: Utils.py:103