CMS 3D CMS Logo

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