CMS 3D CMS Logo

AlCa.py
Go to the documentation of this file.
1 #!/usr/bin/env python
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  #if args.has_key('referenceFile') and args.get('referenceFile', ''):
131  # process.DQMStore.referenceFileName = \
132  # cms.untracked.string(args['referenceFile'])
133  harvestingMode(process,datasetName,args)
134 
135  return process
136 
137  def alcaHarvesting(self, globalTag, datasetName, **args):
138  """
139  _alcaHarvesting_
140 
141  Proton collisions data taking AlCa Harvesting
142 
143  """
144  skims = []
145  if 'skims' in args:
146  skims = args['skims']
147 
148 
149  if 'alcapromptdataset' in args:
150  skims.append('@'+args['alcapromptdataset'])
151 
152  if len(skims) == 0: return None
153  options = defaultOptions
154  options.scenario = self.cbSc if hasattr(self,'cbSc') else self.__class__.__name__
155  options.step = "ALCAHARVEST:"+('+'.join(skims))
156  options.name = "ALCAHARVEST"
157  options.conditions = gtNameAndConnect(globalTag, args)
158 
159  process = cms.Process("ALCAHARVEST", self.eras)
160  process.source = cms.Source("PoolSource")
161 
162  if 'customs' in args:
163  options.customisation_file=args['customs']
164 
165  configBuilder = ConfigBuilder(options, process = process)
166  configBuilder.prepare()
167 
168  #
169  # customise process for particular job
170  #
171  process.source.processingMode = cms.untracked.string('RunsAndLumis')
172  process.source.fileNames = cms.untracked(cms.vstring())
173  process.maxEvents.input = -1
174  process.dqmSaver.workflow = datasetName
175 
176  return process
177 
178  def expressProcessing(self, globalTag, **args):
179  """
180  _expressProcessing_
181 
182  Proton collision data taking express processing
183 
184  """
185  skims = []
186  if 'skims' in args:
187  skims = args['skims']
188  pclWkflws = [x for x in skims if "PromptCalibProd" in x]
189  for wfl in pclWkflws:
190  skims.remove(wfl)
191 
192  options = Options()
193  options.__dict__.update(defaultOptions.__dict__)
194  options.scenario = "pp"
195  options.step = stepALCAPRODUCER(skims)
196 
197  if 'outputs' in args:
198  # the RAW data-tier needs a special treatment since the event-content as defined in release is not good enough
199  outputs_Raw = [x for x in args['outputs'] if x['dataTier'] == 'RAW']
200  outputs_noRaw = [x for x in args['outputs'] if x['dataTier'] != 'RAW']
201  if len(outputs_Raw) == 1:
202  print('RAW data-tier requested')
203  options.outputDefinition = outputs_noRaw.__str__()
204 
205  # dictIO(options,args)
206  options.conditions = gtNameAndConnect(globalTag, args)
207 
208  options.filein = 'tobeoverwritten.xyz'
209  if 'inputSource' in args:
210  options.filetype = args['inputSource']
211  process = cms.Process('RECO', self.eras)
212 
213  if 'customs' in args:
214  options.customisation_file=args['customs']
215 
216  cb = ConfigBuilder(options, process = process, with_output = True, with_input = True)
217 
218  cb.prepare()
219 
220  addMonitoring(process)
221 
222  for output in outputs_Raw:
223  print(output)
224  moduleLabel = output['moduleLabel']
225  selectEvents = output.get('selectEvents', None)
226  maxSize = output.get('maxSize', None)
227 
228  outputModule = cms.OutputModule(
229  "PoolOutputModule",
230  fileName = cms.untracked.string("%s.root" % moduleLabel)
231  )
232 
233  outputModule.dataset = cms.untracked.PSet(dataTier = cms.untracked.string("RAW"))
234 
235  if maxSize != None:
236  outputModule.maxSize = cms.untracked.int32(maxSize)
237 
238  if selectEvents != None:
239  outputModule.SelectEvents = cms.untracked.PSet(
240  SelectEvents = cms.vstring(selectEvents)
241  )
242  outputModule.outputCommands = cms.untracked.vstring('drop *',
243  'keep *_*_*_HLT')
244 
245  setattr(process, moduleLabel, outputModule)
246  # outputModule=getattr(self.process,theModuleLabel)
247  setattr(process, moduleLabel+'_step', cms.EndPath(outputModule))
248  path = getattr(process, moduleLabel+'_step')
249  process.schedule.append(path)
250 
251  return process
def harvestingMode(process, datasetName, args, rANDl=True)
Definition: Utils.py:114
def expressProcessing(self, globalTag, args)
Definition: AlCa.py:178
def gtNameAndConnect(globalTag, args)
Definition: Utils.py:137
def dqmHarvesting(self, datasetName, runNumber, globalTag, args)
Definition: AlCa.py:104
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def dictIO(options, args)
Definition: Utils.py:123
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
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:17
def __init__(self)
Definition: AlCa.py:18
def alcaHarvesting(self, globalTag, datasetName, args)
Definition: AlCa.py:137
def dqmIOSource(args)
Definition: Utils.py:103