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

def MCScenario_CRAFT1_22X.cmsRun (   fileName)

Definition at line 64 of file MCScenario_CRAFT1_22X.py.

Referenced by make_scenario_sqlite().

64 def cmsRun(fileName):
65  os.system("cmsRun %(fileName)s" % vars())
66 
def MCScenario_CRAFT1_22X.CSCsorter (   a,
  b 
)

Definition at line 73 of file MCScenario_CRAFT1_22X.py.

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

Definition at line 146 of file MCScenario_CRAFT1_22X.py.

References make_scenario_sqlite().

Referenced by make_scenario_sqlite().

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

Definition at line 72 of file MCScenario_CRAFT1_22X.py.

72 def DTsorter(a, b): return cmp(DTpreferred_order[a], DTpreferred_order[b])
def MCScenario_CRAFT1_22X.make_scenario_sqlite ( )

called once at the end of this script

Definition at line 33 of file MCScenario_CRAFT1_22X.py.

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

Referenced by define_scenario().

34  scenario = define_scenario()
35  write_xml(scenario, "MCScenario_CRAFT1_22X.xml")
36  write_conversion_cfg("convert_cfg.py", "MCScenario_CRAFT1_22X.xml", "MCScenario_CRAFT1_22X.db")
37  cmsRun("convert_cfg.py")
38  write_check_cfg("check_cfg.py", "MCScenario_CRAFT1_22X.db", "MCScenario_CRAFT1_22X_CHECKME.xml")
39  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)
def MCScenario_CRAFT1_22X.write_check_cfg (   fileName,
  dbFileName,
  xmlFileName 
)

Definition at line 50 of file MCScenario_CRAFT1_22X.py.

References FrontierConditions_GlobalTag_cff.file.

Referenced by make_scenario_sqlite().

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

that's it! everything this uses is defined below

Definition at line 42 of file MCScenario_CRAFT1_22X.py.

References FrontierConditions_GlobalTag_cff.file.

Referenced by make_scenario_sqlite().

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

Definition at line 124 of file MCScenario_CRAFT1_22X.py.

References FrontierConditions_GlobalTag_cff.file, and join().

Referenced by make_scenario_sqlite(), and parserTimingReport.perf_profile().

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

Variable Documentation

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

Definition at line 71 of file MCScenario_CRAFT1_22X.py.

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

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

Definition at line 70 of file MCScenario_CRAFT1_22X.py.

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

Definition at line 95 of file MCScenario_CRAFT1_22X.py.