CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
MCScenario_CRAFT1_22X Namespace Reference

Classes

class  Alignable
 
class  CSCChamber
 
class  DTChamber
 
class  Operation
 
class  Position
 

Functions

def cmsRun
 
def CSCsorter
 
def define_scenario
 
def DTsorter
 
def make_scenario_sqlite
 called once at the end of this script More...
 
def sorter
 
def write_check_cfg
 
def write_conversion_cfg
 that's it! everything this uses is defined below More...
 
def write_xml
 

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 65 of file MCScenario_CRAFT1_22X.py.

Referenced by make_scenario_sqlite().

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

Definition at line 74 of file MCScenario_CRAFT1_22X.py.

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

Definition at line 147 of file MCScenario_CRAFT1_22X.py.

References make_scenario_sqlite(), and sistrip::SpyUtilities.range().

Referenced by make_scenario_sqlite().

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

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

Definition at line 97 of file MCScenario_CRAFT1_22X.py.

Referenced by PFMuonAlgo.getTrackWithSmallestError(), PFHFRecHitCreator.importRecHits(), L1TMuonBarrelKalmanRegionModule.process(), L2TauJetsMerger.produce(), EcalZeroSuppressionProducer.produce(), SimpleForwardNavigableLayer.setInwardLinks(), and SimpleBarrelNavigableLayer.setInwardLinks().

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

Definition at line 51 of file MCScenario_CRAFT1_22X.py.

References mergeVDriftHistosByStation.file.

Referenced by make_scenario_sqlite().

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

Referenced by make_scenario_sqlite().

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

Definition at line 125 of file MCScenario_CRAFT1_22X.py.

References mergeVDriftHistosByStation.file, and join().

Referenced by make_scenario_sqlite().

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

Variable Documentation

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.

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.

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.