CMS 3D CMS Logo

EcalPhiSymRecoSequence_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
3 
4 def ecal_phisym_workflow(process,
5  produce_by_run : bool=False,
6  save_edm : bool=False,
7  save_edmnano : bool=False,
8  save_flatnano : bool=True):
9  """
10  Customize the process to include the entire EcalPhiSym workflow:
11  - ECAL local reco
12  - PhiSymRecHit producer
13  - EDM output (standard, EDMNANO, FlatNANO)
14  """
15 
16  reco = ecal_phisym_reco_sequence(process, produce_by_run=produce_by_run)
17  tables = ecal_phisym_flattables(process, produce_by_run=produce_by_run)
18  outputs = ecal_phisym_output(process,
19  save_edm=save_edm,
20  save_edmnano=save_edmnano,
21  save_flatnano=save_flatnano)
22 
23  process.path = cms.Path(reco*tables)
24  process.output_step = cms.EndPath()
25  for out in outputs:
26  process.output_step += out
27  process.schedule = cms.Schedule(process.path, process.output_step)
28 
29 def ecal_phisym_reco_sequence(process, produce_by_run : bool=False):
30  """
31  Customize process to include the EcalPhiSym standard reco sequence
32  """
33 
34  process.load('RecoLuminosity.LumiProducer.bunchSpacingProducer_cfi')
35  process.load('RecoLocalCalo.EcalRecProducers.ecalMultiFitUncalibRecHit_cfi')
36  process.load('RecoLocalCalo.EcalRecProducers.ecalUncalibRecHit_cfi')
37  process.load('RecoLocalCalo.EcalRecProducers.ecalRecHit_cfi')
38 
39  #ecalMultiFitUncalibRecHit
40  process.ecalMultiFitUncalibRecHit.EBdigiCollection = cms.InputTag("hltEcalPhiSymFilter","phiSymEcalDigisEB")
41  process.ecalMultiFitUncalibRecHit.EEdigiCollection = cms.InputTag("hltEcalPhiSymFilter","phiSymEcalDigisEE")
42 
43  #ecalRecHit (no ricovery)
44  process.ecalRecHit.killDeadChannels = cms.bool( False )
45  process.ecalRecHit.recoverEBVFE = cms.bool( False )
46  process.ecalRecHit.recoverEEVFE = cms.bool( False )
47  process.ecalRecHit.recoverEBFE = cms.bool( False )
48  process.ecalRecHit.recoverEEFE = cms.bool( False )
49  process.ecalRecHit.recoverEEIsolatedChannels = cms.bool( False )
50  process.ecalRecHit.recoverEBIsolatedChannels = cms.bool( False )
51 
52  # PHISYM producer
53  process.load('Calibration.EcalCalibAlgos.EcalPhiSymRecHitProducers_cfi')
54 
55  # SCHEDULE
56  reconstruction_step = cms.Sequence( process.bunchSpacingProducer * (process.ecalMultiFitUncalibRecHit + process.ecalRecHit) )
57  reconstruction_step *= process.EcalPhiSymRecHitProducerRun if produce_by_run else process.EcalPhiSymRecHitProducerLumi
58 
59  return reconstruction_step
60 
61 def ecal_phisym_flattables(process, produce_by_run : bool=False):
62  """
63  Add the NanoAOD flat table producers.
64  This functions adjust also the output columns.
65  Should be called once nMisCalib has been set in the EcalPhiSymRecHitProducer
66  """
67 
68  process.load('Calibration.EcalCalibAlgos.EcalPhiSymFlatTableProducers_cfi')
69 
70  nmis = process.EcalPhiSymRecHitProducerRun.nMisCalib.value()
71  for imis in range(1, nmis+1):
72  # get the naming and indexing right.
73  if imis<nmis/2+1:
74  var_name = 'sumEt_m'+str(abs(int(imis-(nmis/2)-1)))
75  var = Var(f'sumEt({imis})', float, doc='ECAL PhiSym rechits: '+str(imis-(nmis/2)-1)+'*miscalib et', precision=23)
76  else:
77  var_name = 'sumEt_p'+str(int(imis-(nmis/2)))
78  var = Var(f'sumEt({imis})', float, doc='ECAL PhiSym rechits: '+str(imis-(nmis/2))+'*miscalib et', precision=23)
79 
80  if produce_by_run:
81  setattr(process.ecalPhiSymRecHitRunTableEB.variables, var_name, var)
82  setattr(process.ecalPhiSymRecHitRunTableEE.variables, var_name, var)
83  flattable_sequence = cms.Sequence( process.ecalPhiSymRecHitRunTableEB +
84  process.ecalPhiSymRecHitRunTableEE +
85  process.ecalPhiSymInfoRunTable )
86  else:
87  setattr(process.ecalPhiSymRecHitLumiTableEB.variables, var_name, var)
88  setattr(process.ecalPhiSymRecHitLumiTableEE.variables, var_name, var)
89  flattable_sequence = cms.Sequence( process.ecalPhiSymRecHitLumiTableEB +
90  process.ecalPhiSymRecHitLumiTableEE +
91  process.ecalPhiSymInfoLumiTable
92  )
93 
94  return flattable_sequence
95 
96 def ecal_phisym_output(process,
97  save_edm : bool=False,
98  save_edmnano : bool=False,
99  save_flatnano : bool=True):
100  """
101  Customize EcalPhiSym output
102  """
103 
104  outputs = []
105 
106  if save_flatnano or save_edmnano:
107  NanoAODEcalPhiSymEventContent = cms.PSet(
108  outputCommands = cms.untracked.vstring(
109  'drop *',
110  "keep nanoaod*_*_*_*", # event data
111  "keep nanoaodMergeableCounterTable_*Table_*_*", # accumulated per/run or per/lumi data
112  "keep nanoaodUniqueString_nanoMetadata_*_*", # basic metadata
113  )
114  )
115 
116  if save_flatnano:
117  process.nanoout = cms.OutputModule("NanoAODOutputModule",
118  fileName = cms.untracked.string('ecal_phisym_nano.root'),
119  outputCommands = NanoAODEcalPhiSymEventContent.outputCommands,
120  compressionLevel = cms.untracked.int32(9),
121  compressionAlgorithm = cms.untracked.string("LZMA"),
122  )
123  outputs.append(process.nanoout)
124 
125  if save_edmnano:
126  process.nanooutedm = cms.OutputModule("PoolOutputModule",
127  fileName = cms.untracked.string('ecal_phisym_edmnano.root'),
128  outputCommands = NanoAODEcalPhiSymEventContent.outputCommands,
129  )
130  outputs.append(process.nanooutedm)
131 
132  if save_edm:
133  ECALPHISYM_output_commands = cms.untracked.vstring(
134  "drop *",
135  "keep *_PhiSymProducerRun_*_*")
136 
137  process.EcalPhiSymOutput = cms.OutputModule("PoolOutputModule",
138  splitLevel = cms.untracked.int32(2),
139  compressionLevel = cms.untracked.int32(5),
140  compressionAlgorithm = cms.untracked.string('LZMA'),
141  outputCommands = ECALPHISYM_output_commands,
142  fileName = cms.untracked.string('ecal_phisym_reco.root')
143  )
144  outputs.append(process.EcalPhiSymOutput)
145 
146  return outputs
147 
148 def customise(process):
149  """
150  Function to customize the process produced by cmsDriver.
151  The customisation works for a process that satisfies the following conditions:
152  - Run on /AlCaPhiSym/*/RAW data
153  - Run the following sequence (-s option of cmsDriver):
154  RECO:bunchSpacingProducer+ecalMultiFitUncalibRecHitTask+ecalCalibratedRecHitTask,ALCA:EcalPhiSymByRun (or EcalPhiSymByLumi)
155  """
156 
157  # Change input collection for the /AlCaPhiSym/*/RAW stream dataformat
158  process.ecalMultiFitUncalibRecHitCPU.EBdigiCollection = "hltEcalPhiSymFilter:phiSymEcalDigisEB"
159  process.ecalMultiFitUncalibRecHitCPU.EEdigiCollection = "hltEcalPhiSymFilter:phiSymEcalDigisEE"
160  process.ecalRecHit.cpu.killDeadChannels = cms.bool( False )
161  process.ecalRecHit.cpu.recoverEBVFE = cms.bool( False )
162  process.ecalRecHit.cpu.recoverEEVFE = cms.bool( False )
163  process.ecalRecHit.cpu.recoverEBFE = cms.bool( False )
164  process.ecalRecHit.cpu.recoverEEFE = cms.bool( False )
165  process.ecalRecHit.cpu.recoverEEIsolatedChannels = cms.bool( False )
166  process.ecalRecHit.cpu.recoverEBIsolatedChannels = cms.bool( False )
167 
168  if "ALCARECOStreamEcalPhiSymByRunOutPath" in process.pathNames():
169  process.schedule.remove(process.ALCARECOStreamEcalPhiSymByRunOutPath)
170  if "ALCARECOStreamEcalPhiSymByLumiOutPath" in process.pathNames():
171  process.schedule.remove(process.ALCARECOStreamEcalPhiSymByLumiOutPath)
172  process.ALCARECOStreamEcalPhiSymOutNanoPath = cms.EndPath(ecal_phisym_output(process, save_edm=False, save_edmnano=True, save_flatnano=False)[0])
173  process.schedule.append(process.ALCARECOStreamEcalPhiSymOutNanoPath)
174 
175  return process
def Var(expr, valtype, doc=None, precision=-1, lazyEval=False)
Definition: common_cff.py:17
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define str(s)