CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
dumpRecoGeometry_cfg.py
Go to the documentation of this file.
1 from __future__ import print_function
2 import FWCore.ParameterSet.Config as cms
3 import sys, os
4 import FWCore.ParameterSet.VarParsing as VarParsing
5 from FWCore.Utilities.Enumerate import Enumerate
6 from Configuration.Geometry.dict2026Geometry import detectorVersionDict
7 
8 varType = Enumerate ("Run1 2015 2017 2021 2026 MaPSA")
9 defaultVersion=str();
10 
11 def help():
12  print("Usage: cmsRun dumpFWRecoGeometry_cfg.py tag=TAG ")
13  print(" tag=tagname")
14  print(" identify geometry condition database tag")
15  print(" ", varType.keys())
16  print("")
17  print(" version=versionNumber")
18  print(" scenario version from 2026 dictionary")
19  print("")
20  print(" tgeo=bool")
21  print(" dump in TGeo format to browse in geometry viewer")
22  print(" import this in Fireworks with option --sim-geom-file")
23  print("")
24  print(" tracker=bool")
25  print(" include Tracker subdetectors")
26  print("")
27  print(" muon=bool")
28  print(" include Muon subdetectors")
29  print("")
30  print(" calo=bool")
31  print(" include Calo subdetectors")
32  print("")
33  print(" timing=bool")
34  print(" include Timing subdetectors")
35  print("")
36  print("")
37  os._exit(1);
38 
39 def versionCheck(ver):
40  if ver == "":
41  print("Please, specify 2026 scenario version\n")
42  print(sorted([x[1] for x in detectorVersionDict.items()]))
43  print("")
44  help()
45 
46 def recoGeoLoad(score):
47  print("Loading configuration for tag ", options.tag ,"...\n")
48 
49  if score == "Run1":
50  process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
51  from Configuration.AlCa.autoCond import autoCond
52  process.GlobalTag.globaltag = autoCond['run1_mc']
53  process.load("Configuration.StandardSequences.GeometryDB_cff")
54 
55  elif score == "2015":
56  process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
57  from Configuration.AlCa.autoCond import autoCond
58  process.GlobalTag.globaltag = autoCond['run2_mc']
59  process.load("Configuration.StandardSequences.GeometryDB_cff")
60 
61  elif score == "2017":
62  process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
63  from Configuration.AlCa.autoCond import autoCond
64  process.GlobalTag.globaltag = autoCond['upgrade2017']
65  process.load('Configuration.Geometry.GeometryExtended2017Reco_cff')
66 
67  elif score == "2021":
68  process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
69  from Configuration.AlCa.autoCond import autoCond
70  process.GlobalTag.globaltag = autoCond['upgrade2021']
71  ## NOTE: There is no PTrackerParameters Rcd in this GT yet
72  process.load('Geometry.TrackerGeometryBuilder.trackerParameters_cfi')
73  process.load('Configuration.Geometry.GeometryExtended2021Reco_cff')
74  ## NOTE: There are no Muon alignement records in the GT yet
75  process.DTGeometryESModule.applyAlignment = cms.bool(False)
76  process.CSCGeometryESModule.applyAlignment = cms.bool(False)
77 
78  elif "2026" in score:
79  versionCheck(options.version)
80  process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
81  from Configuration.AlCa.autoCond import autoCond
82  process.GlobalTag.globaltag = autoCond['run2_mc']
83  process.load('Configuration.Geometry.GeometryExtended2026'+options.version+'Reco_cff')
84 
85  elif score == "MaPSA":
86  process.load('Geometry.TrackerGeometryBuilder.idealForDigiTrackerGeometry_cff')
87  process.load('Geometry.TrackerCommonData.mapsaGeometryXML_cfi')
88  process.load('Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi')
89  process.load('Geometry.TrackerNumberingBuilder.trackerTopology_cfi')
90  process.load('Geometry.TrackerGeometryBuilder.trackerParameters_cfi')
91  process.load('Geometry.TrackerGeometryBuilder.trackerGeometry_cfi')
92  process.trackerGeometry.applyAlignment = cms.bool(False)
93  process.load('RecoTracker.GeometryESProducer.TrackerRecoGeometryESProducer_cfi')
94 
95  process.load('Geometry.CommonTopologies.bareGlobalTrackingGeometry_cfi')
96 
97  elif score == "HGCTB160": ## hgcal testbeam
98  process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
99  from Configuration.AlCa.autoCond import autoCond
100  process.GlobalTag.globaltag = autoCond['mc']
101  process.load('Geometry.HGCalCommonData.hgcalV6ParametersInitialization_cfi')
102  process.load('Geometry.HGCalCommonData.hgcalV6NumberingInitialization_cfi')
103  process.load('Geometry.CaloEventSetup.HGCalV6Topology_cfi')
104  process.load('Geometry.HGCalGeometry.HGCalV6GeometryESProducer_cfi')
105  process.load('Geometry.CaloEventSetup.CaloTopology_cfi')
106  process.load('Geometry.CaloEventSetup.CaloGeometryBuilder_cfi')
107  process.CaloGeometryBuilder = cms.ESProducer(
108  "CaloGeometryBuilder",
109  SelectedCalos = cms.vstring("HGCalEESensitive")
110  )
111  process.load("SimG4CMS.HGCalTestBeam.HGCalTB160XML_cfi")
112 
113  else:
114  help()
115 
116 
117 
118 
120 
121 
122 defaultOutputFileName="cmsRecoGeom.root"
123 
124 options.register ('tag',
125  "2017", # default value
126  VarParsing.VarParsing.multiplicity.singleton,
127  VarParsing.VarParsing.varType.string,
128  "tag info about geometry database conditions")
129 
130 options.register ('version',
131  defaultVersion, # default value
132  VarParsing.VarParsing.multiplicity.singleton,
133  VarParsing.VarParsing.varType.string,
134  "info about 2026 geometry scenario version")
135 
136 options.register ('tgeo',
137  False, # default value
138  VarParsing.VarParsing.multiplicity.singleton,
139  VarParsing.VarParsing.varType.bool,
140  "write geometry in TGeo format")
141 
142 options.register ('tracker',
143  True, # default value
144  VarParsing.VarParsing.multiplicity.singleton,
145  VarParsing.VarParsing.varType.bool,
146  "write Tracker geometry")
147 
148 options.register ('muon',
149  True, # default value
150  VarParsing.VarParsing.multiplicity.singleton,
151  VarParsing.VarParsing.varType.bool,
152  "write Muon geometry")
153 
154 options.register ('calo',
155  True, # default value
156  VarParsing.VarParsing.multiplicity.singleton,
157  VarParsing.VarParsing.varType.bool,
158  "write Calo geometry")
159 
160 options.register ('timing',
161  False, # default value
162  VarParsing.VarParsing.multiplicity.singleton,
163  VarParsing.VarParsing.varType.bool,
164  "write Timing geometry")
165 
166 options.register ('out',
167  defaultOutputFileName, # default value
168  VarParsing.VarParsing.multiplicity.singleton,
169  VarParsing.VarParsing.varType.string,
170  "Output file name")
171 
172 options.parseArguments()
173 
174 
175 
176 
177 process = cms.Process("DUMP")
178 process.add_(cms.Service("InitRootHandlers", ResetRootErrHandler = cms.untracked.bool(False)))
179 process.source = cms.Source("EmptySource")
180 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))
181 
182 
183 recoGeoLoad(options.tag)
184 
185 if ( options.tgeo == True):
186  if (options.out == defaultOutputFileName ):
187  options.out = "cmsTGeoRecoGeom-" + str(options.tag) + ".root"
188  process.add_(cms.ESProducer("FWTGeoRecoGeometryESProducer",
189  Tracker = cms.untracked.bool(options.tracker),
190  Muon = cms.untracked.bool(options.muon),
191  Calo = cms.untracked.bool(options.calo),
192  Timing = cms.untracked.bool(options.timing)))
193  process.dump = cms.EDAnalyzer("DumpFWTGeoRecoGeometry",
194  tagInfo = cms.untracked.string(options.tag),
195  outputFileName = cms.untracked.string(options.out)
196  )
197 else:
198  if (options.out == defaultOutputFileName ):
199  options.out = "cmsRecoGeom-" + str(options.tag) + ".root"
200  process.add_(cms.ESProducer("FWRecoGeometryESProducer",
201  Tracker = cms.untracked.bool(options.tracker),
202  Muon = cms.untracked.bool(options.muon),
203  Calo = cms.untracked.bool(options.calo),
204  Timing = cms.untracked.bool(options.timing)))
205  process.dump = cms.EDAnalyzer("DumpFWRecoGeometry",
206  level = cms.untracked.int32(1),
207  tagInfo = cms.untracked.string(options.tag),
208  outputFileName = cms.untracked.string(options.out)
209  )
210 
211 print("Dumping geometry in " , options.out, "\n");
212 process.p = cms.Path(process.dump)
213 
214 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)