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
def CSCsorter
def define_scenario
def DTsorter
def make_scenario_sqlite
 called once at the end of this script
def sorter
def write_check_cfg
def write_conversion_cfg
 that's it! everything this uses is defined below
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 ##############################################################
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.

00065                     :
00066     os.system("cmsRun %(fileName)s" % vars())

def MCScenario_CRAFT1_22X::CSCsorter (   a,
  b 
)

Definition at line 73 of file MCScenario_CRAFT1_22X.py.

00073                    : return cmp(CSCpreferred_order[a], CSCpreferred_order[b])
00074 
00075 # 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.

00147                      :
00148     # this will be a list of operations to write to an XML file
00149     scenario = []
00150 
00151     # Uncertainty in DT chamber positions comes in two parts:
00152     #    1. positions within sectors
00153     #    2. positions of the sector-groups
00154 
00155     # Aligned chambers (wheels -1, 0, +1 except sectors 1 and 7)
00156     # uncertainty within sectors:
00157     #    x: 0.08 cm (from segment-matching)  phix: 0.0007 rad (from MC)
00158     #    y: 0.10 cm (from MC)                phiy: 0.0007 rad (from segment-matching)
00159     #    z: 0.10 cm (from MC)                phiz: 0.0003 rad (from MC)
00160     # uncertainty of sector-groups (depends on choice of pT cut, not well understood):
00161     #    x: 0.05 cm
00162 
00163     # Unaligned chambers uncertainty within sectors:
00164     #    x: 0.08 cm (same as above)          phix: 0.0016 rad
00165     #    y: 0.24 cm                          phiy: 0.0021 rad
00166     #    z: 0.42 cm with a -0.35 cm bias     phiz: 0.0010 rad
00167     # uncertainty of sector-groups:
00168     #    x: 0.65 cm
00169     # These come from actual alignments measured in the aligned
00170     # chambers (we assume that the unaligned chambers have
00171     # misalignments on the same scale)
00172 
00173     # Also, superlayer z uncertainty is 0.054 cm
00174 
00175     # Before starting, let's build a list of chambers
00176     DTchambers = []
00177     for wheel in -2, -1, 0, 1, 2:
00178         for station in 1, 2, 3, 4:
00179             if station == 4: nsectors = 14
00180             else: nsectors = 12
00181             for sector in range(1, nsectors+1):
00182                 DTchambers.append(DTChamber(wheel = wheel, station = station, sector = sector))
00183 
00184     # the superlayers
00185     for dtchamber in DTchambers:
00186         for superlayer in 1, 2, 3:
00187             if superlayer == 2 and dtchamber.station == 4: continue
00188 
00189             alignable = Alignable("DTSuperLayer", wheel = dtchamber.wheel, station = dtchamber.station, sector = dtchamber.sector, superlayer = superlayer)
00190             position = Position(x = 0, y = 0, z = random.gauss(0, 0.054), phix = 0, phiy = 0, phiz = 0)
00191             scenario.append(Operation(alignable, position))
00192 
00193     sector_errx = {}
00194 
00195     # sector-groups for aligned chambers:
00196     for wheel in -1, 0, 1:
00197         for sector in 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14:
00198             sector_errx[wheel, sector] = random.gauss(0., 0.05)
00199 
00200     # sector-groups for unaligned chambers:
00201     for wheel in -1, 0, 1:
00202         for sector in 1, 7:
00203             sector_errx[wheel, sector] = random.gauss(0., 0.65)
00204     for wheel in -2, 2:
00205         for sector in 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14:
00206             sector_errx[wheel, sector] = random.gauss(0., 0.65)
00207 
00208     for dtchamber in DTchambers:
00209         # within sectors for aligned chambers:
00210         if dtchamber.wheel in (-1, 0, 1) and dtchamber.sector in (2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14):
00211             errx = random.gauss(0, 0.08)
00212             erry = random.gauss(0, 0.10)
00213             errz = random.gauss(0, 0.10)
00214             errphix = random.gauss(0, 0.0007)
00215             errphiy = random.gauss(0, 0.0007)
00216             errphiz = random.gauss(0, 0.0003)
00217 
00218         # within sectors for unaligned chambers:
00219         else:
00220             errx = random.gauss(0, 0.08)
00221             erry = random.gauss(0, 0.24)
00222             errz = random.gauss(-0.35, 0.42)
00223             errphix = random.gauss(0, 0.0016)
00224             errphiy = random.gauss(0, 0.0021)
00225             errphiz = random.gauss(0, 0.0010)
00226 
00227         errx += sector_errx[dtchamber.wheel, dtchamber.sector]
00228 
00229         # now turn this into an operation
00230         alignable = Alignable("DTChamber", wheel = dtchamber.wheel, station = dtchamber.station, sector = dtchamber.sector)
00231         position = Position(x = errx, y = erry, z = errz, phix = errphix, phiy = errphiy, phiz = errphiz)
00232         scenario.append(Operation(alignable, position))
00233 
00234     # Uncertainty in CSC chamber positions comes in 5 parts:
00235     #    1. 0.0092 cm layer x misalignments observed with beam-halo tracks
00236     #    2. isotropic photogrammetry uncertainty of 0.03 cm (x, y, z) and 0.00015 rad in phiz
00237     #    3. 0.0023 rad phiy misalignment observed with beam-halo tracks
00238     #    4. 0.1438 cm z and 0.00057 rad phix uncertainty between rings from SLM (from comparison in 0T data with PG)
00239     #    5. 0.05 cm (x, y, z) disk misalignments and 0.0001 rad rotation around beamline
00240 
00241     # Before starting, let's build a list of chambers
00242     CSCchambers = []
00243     for endcap in 1, 2:
00244         for station, ring in (1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (3, 1), (3, 2), (4, 1):
00245             if station > 1 and ring == 1:
00246                 nchambers = 18
00247             else:
00248                 nchambers = 36
00249 
00250             for chamber in range(1, nchambers+1):
00251                 CSCchambers.append(CSCChamber(endcap = endcap, station = station, ring = ring, chamber = chamber))
00252             
00253     # First, the layer uncertainties: x only for simplicity, observed 0.0092 cm in overlaps alignment test
00254     for chamber in CSCchambers:
00255         for layer in 1, 2, 3, 4, 5, 6:
00256             alignable = Alignable("CSCLayer", endcap = chamber.endcap, station = chamber.station, ring = chamber.ring, chamber = chamber.chamber, layer = layer)
00257             position = Position(x = random.gauss(0, 0.0092), y = 0, z = 0, phix = 0, phiy = 0, phiz = 0)
00258             scenario.append(Operation(alignable, position))
00259 
00260     # Next, the ring errors from DCOPS (derived from comparison with photogrammetry)
00261     CSCrings = []
00262     for endcap in 1, 2:
00263         for station, ring in (1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (3, 1), (3, 2), (4, 1):
00264             CSCrings.append(CSCChamber(endcap = endcap, station = station, ring = ring, z = random.gauss(0, 0.1438), phix = random.gauss(0, 0.00057)))
00265 
00266     # Next, the chamber errors
00267     for chamber in CSCchambers:
00268         errx = random.gauss(0, 0.03)
00269         erry = random.gauss(0, 0.03)
00270         errz = random.gauss(0, 0.03)
00271         errphix = random.gauss(0, 0.00057)
00272         errphiy = random.gauss(0, 0.0023)
00273         errphiz = random.gauss(0, 0.00015)
00274         
00275         for ring in CSCrings:
00276             if ring.endcap == chamber.endcap and ring.station == chamber.station and ring.ring == chamber.ring:
00277                 errz += ring.z
00278                 errphix += ring.phix
00279                 break
00280 
00281         alignable = Alignable("CSCChamber", endcap = chamber.endcap, station = chamber.station, ring = chamber.ring, chamber = chamber.chamber)
00282         position = Position(x = errx, y = erry, z = errz, phix = errphix, phiy = errphiy, phiz = errphiz)
00283         scenario.append(Operation(alignable, position))
00284 
00285     # Finally, the disk errors
00286     for endcap in 1, 2:
00287         for station in 1, 2, 3, 4:
00288             alignable = Alignable("CSCStation", endcap = endcap, station = station)
00289             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))
00290             scenario.append(Operation(alignable, position))
00291 
00292     return scenario
00293 
00294 # run it all!
00295 make_scenario_sqlite()
def MCScenario_CRAFT1_22X::DTsorter (   a,
  b 
)

Definition at line 72 of file MCScenario_CRAFT1_22X.py.

00072 : 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.

00034                           :
00035     scenario = define_scenario()
00036     write_xml(scenario, "MCScenario_CRAFT1_22X.xml")
00037     write_conversion_cfg("convert_cfg.py", "MCScenario_CRAFT1_22X.xml", "MCScenario_CRAFT1_22X.db")
00038     cmsRun("convert_cfg.py")
00039     write_check_cfg("check_cfg.py", "MCScenario_CRAFT1_22X.db", "MCScenario_CRAFT1_22X_CHECKME.xml")
    cmsRun("check_cfg.py")
def MCScenario_CRAFT1_22X::sorter (   a,
  b 
)

Definition at line 96 of file MCScenario_CRAFT1_22X.py.

Referenced by HLTTauDQMCaloPlotter::analyze(), HPSPFRecoTauAlgorithm::getBestTauCandidate(), EcalZeroSuppressionProducer::produce(), L2TauJetsMerger::produce(), and TauTagTools::sortRefVectorByPt().

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

Definition at line 50 of file MCScenario_CRAFT1_22X.py.

00051                                                       :
00052     outfile = file(fileName, "w")
00053     outfile.write("""
00054 from Alignment.MuonAlignment.convertSQLitetoXML_cfg import *
00055 process.PoolDBESSource.connect = "sqlite_file:%(dbFileName)s"
00056 process.MuonGeometryDBConverter.outputXML.fileName = "%(xmlFileName)s"
00057 process.MuonGeometryDBConverter.outputXML.relativeto = "ideal"
00058 process.MuonGeometryDBConverter.outputXML.suppressDTChambers = False
00059 process.MuonGeometryDBConverter.outputXML.suppressDTSuperLayers = False
00060 process.MuonGeometryDBConverter.outputXML.suppressDTLayers = True
00061 process.MuonGeometryDBConverter.outputXML.suppressCSCChambers = False
00062 process.MuonGeometryDBConverter.outputXML.suppressCSCLayers = False
00063 """ % vars())

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.

00043                                                            :
00044     outfile = file(fileName, "w")
00045     outfile.write("""
00046 from Alignment.MuonAlignment.convertXMLtoSQLite_cfg import *
00047 process.MuonGeometryDBConverter.fileName = "%(xmlFileName)s"
00048 process.PoolDBOutputService.connect = "sqlite_file:%(dbFileName)s"
00049 """ % vars())

def MCScenario_CRAFT1_22X::write_xml (   scenario,
  fileName 
)

Definition at line 124 of file MCScenario_CRAFT1_22X.py.

00125                                  :
00126     # a scenario is an ordered list of Operations
00127     XMLlist = ["<MuonAlignment>\n"]
00128     for operation in scenario:
00129         XMLlist.append(operation.writeXML())
00130     XMLlist.append("</MuonAlignment>\n")
00131     XMLstring = "".join(XMLlist)
00132         
00133     outfile = file(fileName, "w")
00134     outfile.write(XMLstring)


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.