CMS 3D CMS Logo

AlCaPPS_Run3.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 """
3 _AlCaPPS_Run3_
4 
5 Scenario supporting proton collisions for AlCa needs for the CT-PPS detector
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 from Configuration.Eras.Era_Run3_cff import Run3
16 import FWCore.ParameterSet.Config as cms
17 
19  def __init__(self):
20  Scenario.__init__(self)
21  self.eras=Run3
22  self.skims=['PPSCalMaxTracks']
23 
24  """
25  _AlCaPPS_Run3_
26 
27  Implement configuration building for data processing for proton
28  collision data taking for AlCa needs for the CT-PPS detector
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 
42  options = Options()
43  options.__dict__.update(defaultOptions.__dict__)
44  options.scenario = "pp"
45  dictIO(options,args)
46  options.conditions = gtNameAndConnect(globalTag, args)
47 
48  if 'customs' in args:
49  print(args['customs'])
50  options.customisation_file=args['customs']
51 
52  options.step += stepALCAPRODUCER(args['skims'])
53 
54  process = cms.Process('RECO', cms.ModifierChain(self.eras) )
55  cb = ConfigBuilder(options, process = process, with_output = True)
56 
57  # Input source
58  process.source = cms.Source("PoolSource",
59  fileNames = cms.untracked.vstring()
60  )
61  cb.prepare()
62 
63  return process
64 
65 
66  def alcaSkim(self, skims, **args):
67  """
68  _alcaSkim_
69 
70  AlcaReco processing & skims for proton collisions
71 
72  """
73  step = ""
74  pclWflws = [x for x in skims if "PromptCalibProd" in x]
75  skims = [x for x in skims if x not in pclWflws]
76 
77  if len(pclWflws):
78  step += 'ALCA:'+('+'.join(pclWflws))
79 
80  if len(skims) > 0:
81  if step != "":
82  step += ","
83  step += "ALCAOUTPUT:"+('+'.join(skims))
84 
85  options = Options()
86  options.__dict__.update(defaultOptions.__dict__)
87  options.scenario = "pp"
88  options.step = step
89  options.conditions = args['globaltag'] if 'globaltag' in args else 'None'
90  if 'globalTagConnect' in args and args['globalTagConnect'] != '':
91  options.conditions += ','+args['globalTagConnect']
92 
93  options.triggerResultsProcess = 'RECO'
94 
95  process = cms.Process('ALCA', self.eras)
96  cb = ConfigBuilder(options, process=process)
97 
98  # Input source
99  process.source = cms.Source(
100  "PoolSource",
101  fileNames=cms.untracked.vstring()
102  )
103 
104  cb.prepare()
105 
106  # Tier0 needs the dataset used for ALCAHARVEST step to be a different data-tier
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  def dqmHarvesting(self, datasetName, runNumber, globalTag, **args):
114  """
115  _dqmHarvesting_
116 
117  Proton collisions data taking DQM Harvesting
118 
119  """
120  options = defaultOptions
121  options.scenario = "pp"
122  options.step = "HARVESTING:alcaHarvesting"
123  options.name = "EDMtoMEConvert"
124  options.conditions = gtNameAndConnect(globalTag, args)
125 
126  process = cms.Process("HARVESTING", self.eras)
127  process.source = dqmIOSource(args)
128  configBuilder = ConfigBuilder(options, process = process)
129  configBuilder.prepare()
130 
131  # customise process for particular job
132  harvestingMode(process,datasetName,args)
133 
134  return process
135 
136  def expressProcessing(self, globalTag, **args):
137  """
138  _expressProcessing_
139 
140  Proton collision data taking express processing
141 
142  """
143  skims = []
144  if 'skims' in args:
145  skims = args['skims']
146  pclWkflws = [x for x in skims if "PromptCalibProd" in x]
147  for wfl in pclWkflws:
148  skims.remove(wfl)
149 
150  options = Options()
151  options.__dict__.update(defaultOptions.__dict__)
152  options.scenario = "pp"
153  options.step = stepALCAPRODUCER(skims)
154 
155  if 'outputs' in args:
156  # the RAW data-tier needs a special treatment since the event-content as defined in release is not good enough
157  outputs_Raw = [x for x in args['outputs'] if x['dataTier'] == 'RAW']
158  outputs_noRaw = [x for x in args['outputs'] if x['dataTier'] != 'RAW']
159  if len(outputs_Raw) == 1:
160  print('RAW data-tier requested')
161  options.outputDefinition = outputs_noRaw.__str__()
162 
163  options.conditions = gtNameAndConnect(globalTag, args)
164 
165  options.filein = 'tobeoverwritten.xyz'
166  if 'inputSource' in args:
167  options.filetype = args['inputSource']
168  process = cms.Process('RECO', self.eras)
169 
170  if 'customs' in args:
171  options.customisation_file=args['customs']
172 
173  cb = ConfigBuilder(options, process = process, with_output = True, with_input = True)
174 
175  cb.prepare()
176 
177  addMonitoring(process)
178 
179  for output in outputs_Raw:
180  print(output)
181  moduleLabel = output['moduleLabel']
182  selectEvents = output.get('selectEvents', None)
183  maxSize = output.get('maxSize', None)
184 
185  outputModule = cms.OutputModule(
186  "PoolOutputModule",
187  fileName = cms.untracked.string("%s.root" % moduleLabel)
188  )
189 
190  outputModule.dataset = cms.untracked.PSet(dataTier = cms.untracked.string("RAW"))
191 
192  if maxSize != None:
193  outputModule.maxSize = cms.untracked.int32(maxSize)
194 
195  if selectEvents != None:
196  outputModule.SelectEvents = cms.untracked.PSet(
197  SelectEvents = cms.vstring(selectEvents)
198  )
199  outputModule.outputCommands = cms.untracked.vstring('drop *',
200  'keep *_*_*_HLT')
201 
202  setattr(process, moduleLabel, outputModule)
203  setattr(process, moduleLabel+'_step', cms.EndPath(outputModule))
204  path = getattr(process, moduleLabel+'_step')
205  process.schedule.append(path)
206 
207  return process
def harvestingMode(process, datasetName, args, rANDl=True)
Definition: Utils.py:114
def gtNameAndConnect(globalTag, args)
Definition: Utils.py:135
def dqmHarvesting(self, datasetName, runNumber, globalTag, args)
def dictIO(options, args)
Definition: Utils.py:121
def expressProcessing(self, globalTag, args)
def addMonitoring(process)
Definition: Utils.py:38
def alcaSkim(self, skims, args)
Definition: AlCaPPS_Run3.py:66
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def promptReco(self, globalTag, args)
Definition: AlCaPPS_Run3.py:36
def stepALCAPRODUCER(skims)
Definition: Utils.py:9
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def skimsIfNotGiven(self, args, sl)
Definition: AlCaPPS_Run3.py:32
def dqmIOSource(args)
Definition: Utils.py:103