CMS 3D CMS Logo

Classes | Functions | Variables
MCScenario_CRAFT1_22X Namespace Reference

Classes

class  Alignable
 
class  CSCChamber
 
class  DTChamber
 
class  Operation
 
class  Position
 

Functions

def cmsRun (fileName)
 
def CSCsorter (a, b)
 
def define_scenario ()
 
def DTsorter (a, b)
 
def make_scenario_sqlite ()
 called once at the end of this script More...
 
def sorter (a, b)
 
def write_check_cfg (fileName, dbFileName, xmlFileName)
 
def write_conversion_cfg (fileName, xmlFileName, dbFileName)
 that's it! everything this uses is defined below More...
 
def write_xml (scenario, fileName)
 

Variables

dictionary CSCpreferred_order = {"endcap":1, "station":2, "ring":3, "chamber":4, "layer":5}
 
dictionary DTpreferred_order = {"wheel":1, "station":2, "sector":3, "superlayer":4, "layer":5}
 writing a scenario in XML ############################################################## More...
 
dictionary preferred_order = {"x":1, "y":2, "z":3, "phix":4, "phiy":5, "phiz":6}
 

Function Documentation

◆ cmsRun()

def MCScenario_CRAFT1_22X.cmsRun (   fileName)

Definition at line 65 of file MCScenario_CRAFT1_22X.py.

Referenced by make_scenario_sqlite().

65 def cmsRun(fileName):
66  os.system("cmsRun %(fileName)s" % vars())
67 

◆ CSCsorter()

def MCScenario_CRAFT1_22X.CSCsorter (   a,
  b 
)

Definition at line 74 of file MCScenario_CRAFT1_22X.py.

74 def CSCsorter(a, b): return cmp(CSCpreferred_order[a], CSCpreferred_order[b])
75 
76 # an instance of this class corresponds to one <DTChamber ... /> or <CSCStation ... />, etc.

◆ define_scenario()

def MCScenario_CRAFT1_22X.define_scenario ( )

Definition at line 147 of file MCScenario_CRAFT1_22X.py.

References make_scenario_sqlite(), and FastTimerService_cff.range.

Referenced by make_scenario_sqlite().

147 def define_scenario():
148  # this will be a list of operations to write to an XML file
149  scenario = []
150 
151  # Uncertainty in DT chamber positions comes in two parts:
152  # 1. positions within sectors
153  # 2. positions of the sector-groups
154 
155  # Aligned chambers (wheels -1, 0, +1 except sectors 1 and 7)
156  # uncertainty within sectors:
157  # x: 0.08 cm (from segment-matching) phix: 0.0007 rad (from MC)
158  # y: 0.10 cm (from MC) phiy: 0.0007 rad (from segment-matching)
159  # z: 0.10 cm (from MC) phiz: 0.0003 rad (from MC)
160  # uncertainty of sector-groups (depends on choice of pT cut, not well understood):
161  # x: 0.05 cm
162 
163  # Unaligned chambers uncertainty within sectors:
164  # x: 0.08 cm (same as above) phix: 0.0016 rad
165  # y: 0.24 cm phiy: 0.0021 rad
166  # z: 0.42 cm with a -0.35 cm bias phiz: 0.0010 rad
167  # uncertainty of sector-groups:
168  # x: 0.65 cm
169  # These come from actual alignments measured in the aligned
170  # chambers (we assume that the unaligned chambers have
171  # misalignments on the same scale)
172 
173  # Also, superlayer z uncertainty is 0.054 cm
174 
175  # Before starting, let's build a list of chambers
176  DTchambers = []
177  for wheel in -2, -1, 0, 1, 2:
178  for station in 1, 2, 3, 4:
179  if station == 4: nsectors = 14
180  else: nsectors = 12
181  for sector in range(1, nsectors+1):
182  DTchambers.append(DTChamber(wheel = wheel, station = station, sector = sector))
183 
184  # the superlayers
185  for dtchamber in DTchambers:
186  for superlayer in 1, 2, 3:
187  if superlayer == 2 and dtchamber.station == 4: continue
188 
189  alignable = Alignable("DTSuperLayer", wheel = dtchamber.wheel, station = dtchamber.station, sector = dtchamber.sector, superlayer = superlayer)
190  position = Position(x = 0, y = 0, z = random.gauss(0, 0.054), phix = 0, phiy = 0, phiz = 0)
191  scenario.append(Operation(alignable, position))
192 
193  sector_errx = {}
194 
195  # sector-groups for aligned chambers:
196  for wheel in -1, 0, 1:
197  for sector in 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14:
198  sector_errx[wheel, sector] = random.gauss(0., 0.05)
199 
200  # sector-groups for unaligned chambers:
201  for wheel in -1, 0, 1:
202  for sector in 1, 7:
203  sector_errx[wheel, sector] = random.gauss(0., 0.65)
204  for wheel in -2, 2:
205  for sector in 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14:
206  sector_errx[wheel, sector] = random.gauss(0., 0.65)
207 
208  for dtchamber in DTchambers:
209  # within sectors for aligned chambers:
210  if dtchamber.wheel in (-1, 0, 1) and dtchamber.sector in (2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14):
211  errx = random.gauss(0, 0.08)
212  erry = random.gauss(0, 0.10)
213  errz = random.gauss(0, 0.10)
214  errphix = random.gauss(0, 0.0007)
215  errphiy = random.gauss(0, 0.0007)
216  errphiz = random.gauss(0, 0.0003)
217 
218  # within sectors for unaligned chambers:
219  else:
220  errx = random.gauss(0, 0.08)
221  erry = random.gauss(0, 0.24)
222  errz = random.gauss(-0.35, 0.42)
223  errphix = random.gauss(0, 0.0016)
224  errphiy = random.gauss(0, 0.0021)
225  errphiz = random.gauss(0, 0.0010)
226 
227  errx += sector_errx[dtchamber.wheel, dtchamber.sector]
228 
229  # now turn this into an operation
230  alignable = Alignable("DTChamber", wheel = dtchamber.wheel, station = dtchamber.station, sector = dtchamber.sector)
231  position = Position(x = errx, y = erry, z = errz, phix = errphix, phiy = errphiy, phiz = errphiz)
232  scenario.append(Operation(alignable, position))
233 
234  # Uncertainty in CSC chamber positions comes in 5 parts:
235  # 1. 0.0092 cm layer x misalignments observed with beam-halo tracks
236  # 2. isotropic photogrammetry uncertainty of 0.03 cm (x, y, z) and 0.00015 rad in phiz
237  # 3. 0.0023 rad phiy misalignment observed with beam-halo tracks
238  # 4. 0.1438 cm z and 0.00057 rad phix uncertainty between rings from SLM (from comparison in 0T data with PG)
239  # 5. 0.05 cm (x, y, z) disk misalignments and 0.0001 rad rotation around beamline
240 
241  # Before starting, let's build a list of chambers
242  CSCchambers = []
243  for endcap in 1, 2:
244  for station, ring in (1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (3, 1), (3, 2), (4, 1):
245  if station > 1 and ring == 1:
246  nchambers = 18
247  else:
248  nchambers = 36
249 
250  for chamber in range(1, nchambers+1):
251  CSCchambers.append(CSCChamber(endcap = endcap, station = station, ring = ring, chamber = chamber))
252 
253  # First, the layer uncertainties: x only for simplicity, observed 0.0092 cm in overlaps alignment test
254  for chamber in CSCchambers:
255  for layer in 1, 2, 3, 4, 5, 6:
256  alignable = Alignable("CSCLayer", endcap = chamber.endcap, station = chamber.station, ring = chamber.ring, chamber = chamber.chamber, layer = layer)
257  position = Position(x = random.gauss(0, 0.0092), y = 0, z = 0, phix = 0, phiy = 0, phiz = 0)
258  scenario.append(Operation(alignable, position))
259 
260  # Next, the ring errors from DCOPS (derived from comparison with photogrammetry)
261  CSCrings = []
262  for endcap in 1, 2:
263  for station, ring in (1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (3, 1), (3, 2), (4, 1):
264  CSCrings.append(CSCChamber(endcap = endcap, station = station, ring = ring, z = random.gauss(0, 0.1438), phix = random.gauss(0, 0.00057)))
265 
266  # Next, the chamber errors
267  for chamber in CSCchambers:
268  errx = random.gauss(0, 0.03)
269  erry = random.gauss(0, 0.03)
270  errz = random.gauss(0, 0.03)
271  errphix = random.gauss(0, 0.00057)
272  errphiy = random.gauss(0, 0.0023)
273  errphiz = random.gauss(0, 0.00015)
274 
275  for ring in CSCrings:
276  if ring.endcap == chamber.endcap and ring.station == chamber.station and ring.ring == chamber.ring:
277  errz += ring.z
278  errphix += ring.phix
279  break
280 
281  alignable = Alignable("CSCChamber", endcap = chamber.endcap, station = chamber.station, ring = chamber.ring, chamber = chamber.chamber)
282  position = Position(x = errx, y = erry, z = errz, phix = errphix, phiy = errphiy, phiz = errphiz)
283  scenario.append(Operation(alignable, position))
284 
285  # Finally, the disk errors
286  for endcap in 1, 2:
287  for station in 1, 2, 3, 4:
288  alignable = Alignable("CSCStation", endcap = endcap, station = station)
289  position = Position(x = random.gauss(0, 0.05), y = random.gauss(0, 0.05), z = random.gauss(0, 0.05), phix = 0., phiy = 0., phiz = random.gauss(0, 0.0001))
290  scenario.append(Operation(alignable, position))
291 
292  return scenario
293 
294 # run it all!

◆ DTsorter()

def MCScenario_CRAFT1_22X.DTsorter (   a,
  b 
)

Definition at line 73 of file MCScenario_CRAFT1_22X.py.

73 def DTsorter(a, b): return cmp(DTpreferred_order[a], DTpreferred_order[b])

◆ make_scenario_sqlite()

def MCScenario_CRAFT1_22X.make_scenario_sqlite ( )

called once at the end of this script

Definition at line 34 of file MCScenario_CRAFT1_22X.py.

References cmsRun(), define_scenario(), write_check_cfg(), write_conversion_cfg(), and write_xml().

Referenced by define_scenario().

35  scenario = define_scenario()
36  write_xml(scenario, "MCScenario_CRAFT1_22X.xml")
37  write_conversion_cfg("convert_cfg.py", "MCScenario_CRAFT1_22X.xml", "MCScenario_CRAFT1_22X.db")
38  cmsRun("convert_cfg.py")
39  write_check_cfg("check_cfg.py", "MCScenario_CRAFT1_22X.db", "MCScenario_CRAFT1_22X_CHECKME.xml")
40  cmsRun("check_cfg.py")
def make_scenario_sqlite()
called once at the end of this script
def write_conversion_cfg(fileName, xmlFileName, dbFileName)
that&#39;s it! everything this uses is defined below
def write_xml(scenario, fileName)
def write_check_cfg(fileName, dbFileName, xmlFileName)

◆ sorter()

def MCScenario_CRAFT1_22X.sorter (   a,
  b 
)

Definition at line 97 of file MCScenario_CRAFT1_22X.py.

97 def sorter(a, b): return cmp(preferred_order[a], preferred_order[b])
98 
99 # an instance of this class corresponds to one <setposition ... />

◆ write_check_cfg()

def MCScenario_CRAFT1_22X.write_check_cfg (   fileName,
  dbFileName,
  xmlFileName 
)

Definition at line 51 of file MCScenario_CRAFT1_22X.py.

References geometryDiff.file.

Referenced by make_scenario_sqlite().

51 def write_check_cfg(fileName, dbFileName, xmlFileName):
52  outfile = file(fileName, "w")
53  outfile.write("""
54 from Alignment.MuonAlignment.convertSQLitetoXML_cfg import *
55 process.PoolDBESSource.connect = "sqlite_file:%(dbFileName)s"
56 process.MuonGeometryDBConverter.outputXML.fileName = "%(xmlFileName)s"
57 process.MuonGeometryDBConverter.outputXML.relativeto = "ideal"
58 process.MuonGeometryDBConverter.outputXML.suppressDTChambers = False
59 process.MuonGeometryDBConverter.outputXML.suppressDTSuperLayers = False
60 process.MuonGeometryDBConverter.outputXML.suppressDTLayers = True
61 process.MuonGeometryDBConverter.outputXML.suppressCSCChambers = False
62 process.MuonGeometryDBConverter.outputXML.suppressCSCLayers = False
63 """ % vars())
64 
def write_check_cfg(fileName, dbFileName, xmlFileName)

◆ write_conversion_cfg()

def MCScenario_CRAFT1_22X.write_conversion_cfg (   fileName,
  xmlFileName,
  dbFileName 
)

that's it! everything this uses is defined below

Definition at line 43 of file MCScenario_CRAFT1_22X.py.

References geometryDiff.file.

Referenced by make_scenario_sqlite().

43 def write_conversion_cfg(fileName, xmlFileName, dbFileName):
44  outfile = file(fileName, "w")
45  outfile.write("""
46 from Alignment.MuonAlignment.convertXMLtoSQLite_cfg import *
47 process.MuonGeometryDBConverter.fileName = "%(xmlFileName)s"
48 process.PoolDBOutputService.connect = "sqlite_file:%(dbFileName)s"
49 """ % vars())
50 
def write_conversion_cfg(fileName, xmlFileName, dbFileName)
that&#39;s it! everything this uses is defined below

◆ write_xml()

def MCScenario_CRAFT1_22X.write_xml (   scenario,
  fileName 
)

Definition at line 125 of file MCScenario_CRAFT1_22X.py.

References geometryDiff.file, and join().

Referenced by make_scenario_sqlite().

125 def write_xml(scenario, fileName):
126  # a scenario is an ordered list of Operations
127  XMLlist = ["<MuonAlignment>\n"]
128  for operation in scenario:
129  XMLlist.append(operation.writeXML())
130  XMLlist.append("</MuonAlignment>\n")
131  XMLstring = "".join(XMLlist)
132 
133  outfile = file(fileName, "w")
134  outfile.write(XMLstring)
135 
def write_xml(scenario, fileName)
static std::string join(char **cmd)
Definition: RemoteFile.cc:19

Variable Documentation

◆ CSCpreferred_order

dictionary MCScenario_CRAFT1_22X.CSCpreferred_order = {"endcap":1, "station":2, "ring":3, "chamber":4, "layer":5}

Definition at line 72 of file MCScenario_CRAFT1_22X.py.

◆ DTpreferred_order

dictionary MCScenario_CRAFT1_22X.DTpreferred_order = {"wheel":1, "station":2, "sector":3, "superlayer":4, "layer":5}

writing a scenario in XML ##############################################################

Definition at line 71 of file MCScenario_CRAFT1_22X.py.

◆ preferred_order

dictionary MCScenario_CRAFT1_22X.preferred_order = {"x":1, "y":2, "z":3, "phix":4, "phiy":5, "phiz":6}

Definition at line 96 of file MCScenario_CRAFT1_22X.py.