26 from builtins
import range
36 write_xml(scenario,
"MCScenario_CRAFT1_22X.xml")
39 write_check_cfg(
"check_cfg.py",
"MCScenario_CRAFT1_22X.db",
"MCScenario_CRAFT1_22X_CHECKME.xml")
44 outfile =
file(fileName,
"w")
46 from Alignment.MuonAlignment.convertXMLtoSQLite_cfg import * 47 process.MuonGeometryDBConverter.fileName = "%(xmlFileName)s" 48 process.PoolDBOutputService.connect = "sqlite_file:%(dbFileName)s" 52 outfile =
file(fileName,
"w")
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 66 os.system(
"cmsRun %(fileName)s" % vars())
71 DTpreferred_order = {
"wheel":1,
"station":2,
"sector":3,
"superlayer":4,
"layer":5}
72 CSCpreferred_order = {
"endcap":1,
"station":2,
"ring":3,
"chamber":4,
"layer":5}
73 def DTsorter(a, b):
return cmp(DTpreferred_order[a], DTpreferred_order[b])
74 def CSCsorter(a, b):
return cmp(CSCpreferred_order[a], CSCpreferred_order[b])
83 parameters = self.location.keys()
85 parameters.sort(DTsorter)
87 parameters.sort(CSCsorter)
90 for parameter
in parameters:
91 output.extend([parameter,
"=\"",
str(self.
location[parameter]),
"\" "])
94 return "".
join(output)
96 preferred_order = {
"x":1,
"y":2,
"z":3,
"phix":4,
"phiy":5,
"phiz":6}
97 def sorter(a, b):
return cmp(preferred_order[a], preferred_order[b])
105 parameters = self.location.keys()
106 parameters.sort(sorter)
108 output = [
"<setposition relativeto=\"ideal\" "]
109 for parameter
in parameters:
110 output.extend([parameter,
"=\"",
str(self.
location[parameter]),
"\" "])
113 return "".
join(output)
122 output = [
"<operation> ", self.alignable.writeXML(),
" ", self.position.writeXML(),
" </operation>\n"]
123 return "".
join(output)
127 XMLlist = [
"<MuonAlignment>\n"]
128 for operation
in scenario:
129 XMLlist.append(operation.writeXML())
130 XMLlist.append(
"</MuonAlignment>\n")
131 XMLstring =
"".
join(XMLlist)
133 outfile =
file(fileName,
"w")
134 outfile.write(XMLstring)
138 self.__dict__.update(location)
142 self.__dict__.update(location)
177 for wheel
in -2, -1, 0, 1, 2:
178 for station
in 1, 2, 3, 4:
179 if station == 4: nsectors = 14
181 for sector
in range(1, nsectors+1):
182 DTchambers.append(
DTChamber(wheel = wheel, station = station, sector = sector))
185 for dtchamber
in DTchambers:
186 for superlayer
in 1, 2, 3:
187 if superlayer == 2
and dtchamber.station == 4:
continue 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))
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)
201 for wheel
in -1, 0, 1:
203 sector_errx[wheel, sector] = random.gauss(0., 0.65)
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)
208 for dtchamber
in DTchambers:
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)
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)
227 errx += sector_errx[dtchamber.wheel, dtchamber.sector]
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))
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:
250 for chamber
in range(1, nchambers+1):
251 CSCchambers.append(
CSCChamber(endcap = endcap, station = station, ring = ring, chamber = chamber))
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))
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)))
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)
275 for ring
in CSCrings:
276 if ring.endcap == chamber.endcap
and ring.station == chamber.station
and ring.ring == chamber.ring:
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))
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))
def __init__(self, alignabletype, location)
def __init__(self, location)
def make_scenario_sqlite()
called once at the end of this script
def write_conversion_cfg(fileName, xmlFileName, dbFileName)
that's it! everything this uses is defined below
def __init__(self, alignable, position)
def __init__(self, location)
def write_xml(scenario, fileName)
static std::string join(char **cmd)
def __init__(self, location)
def write_check_cfg(fileName, dbFileName, xmlFileName)