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