ATLAS Offline Software
Loading...
Searching...
No Matches
ReadRPCRun2DataFile Namespace Reference

Classes

class  Decodes
class  Mioct
class  MuonGeometry
class  ROI
class  Sector
class  TopoCell

Functions

 rpcMioctAndSectorInfo (sectorID)
 read2015Geometry (fn)
 read2015RPCCodeMapping (geometry)
 feetRegionMapping (sectorId, roiId)
 read2016RPCGeomData (fn, oldMapping)
 updateGeometryTGC (newGeometry, oldGeometry)
 sectorAsXML_2 (sector, depth, stats)
 roiAsXML_2 (roi, depth)
 sectorAsXML (xxx_todo_changeme, depth, stats)
 roiAsXML (roi, depth)
 main (args)

Variables

 parser
 dest
 default
 type
 help
 args = parser.parse_args()

Function Documentation

◆ feetRegionMapping()

ReadRPCRun2DataFile.feetRegionMapping ( sectorId,
roiId )
 provides the new mapping for the feet and elevator region
The numbers can be found in doc/roi_map_R2.pdf

Definition at line 330 of file ReadRPCRun2DataFile.py.

330def feetRegionMapping(sectorId, roiId):
331 """ provides the new mapping for the feet and elevator region
332 The numbers can be found in doc/roi_map_R2.pdf
333 """
334
335 etacode = -1
336 phicode = -1
337
338 if sectorId in [23,24,55,56]:
339 # elevator region
340
341 # eta
342 etaMap = { 23 : [ [0,1,2,3,5,7], [4,6,8,9,10,11], range(12,20) + [21,23], [20,22] + range(24,28) ],
343 24 : [ [0,1,2,3,4,6], [5,7,8,9,10,11], range(12,20) + [20,22], [21,23] + range(24,28) ] }
344 etaMap[55] = etaMap[24]
345 etaMap[56] = etaMap[23]
346
347 for ec, tt in enumerate(etaMap[sectorId]):
348 if roiId in tt:
349 etacode = ec
350 break
351
352 # phi
353 if sectorId in [23,55]:
354 if roiId in [2,3,6,7,10,11,18,19,22,23,27]:
355 phicode = 2
356 if roiId in [0,1,4,5,8,9,12,13,14,15,16,17,20,21,25]:
357 phicode = 3
358 elif sectorId in [24,56]:
359 if roiId in [0,1,4,5,8,9,12,13,14,15,16,17,20,21,24]:
360 phicode = 4
361 if roiId in [2,3,6,7,10,11,18,19,22,23,26]:
362 phicode = 5
363
364 if sectorId == 23:
365 if roiId == 27: phicode = 2
366 elif roiId == 25: phicode = 3
367 elif sectorId == 24:
368 if roiId == 24: phicode = 4
369 elif roiId == 26: phicode = 5
370 elif sectorId == 55:
371 if roiId == 24: phicode = 3
372 elif roiId == 26: phicode = 2
373 elif sectorId == 56:
374 if roiId == 27: phicode = 5
375 elif roiId == 25: phicode = 4
376
377
378
379 elif [21,22,25,26,53,54,57,58]:
380 # feet region
381
382 # eta
383 etaMap = { 21 : [ range(0,8), range(8,16) + [17,19], [16,18] + range(20,32) ],
384 22 : [ range(0,8), range(8,16) + [16,18], [17,19] + range(20,32) ] }
385 etaMap[25] = etaMap[21]
386 etaMap[26] = etaMap[22]
387 etaMap[53] = etaMap[22]
388 etaMap[54] = etaMap[21]
389 etaMap[57] = etaMap[53]
390 etaMap[58] = etaMap[54]
391
392 for ec, tt in enumerate(etaMap[sectorId]):
393 if roiId in tt:
394 etacode = ec
395 break
396
397 # phi
398 if sectorId in [21,53]:
399 if roiId in [2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31]:
400 phicode = 6
401 elif roiId in [0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29]:
402 phicode = 7
403 elif sectorId in [22,54]:
404 if roiId in [0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29]:
405 phicode = 0
406 elif roiId in [2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31]:
407 phicode = 1
408 elif sectorId in [25,57]:
409 if roiId in [2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31]:
410 phicode = 6
411 elif roiId in [0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29]:
412 phicode = 7
413 elif sectorId in [26,58]:
414 if roiId in [0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29]:
415 phicode = 0
416 elif roiId in [2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31]:
417 phicode = 1
418
419 if etacode == -1:
420 raise RuntimeError("No etacode for SL %i and ROI %i" % (sectorId, roiId))
421 if phicode == -1:
422 raise RuntimeError("No phicode for SL %i and ROI %i" % (sectorId, roiId))
423
424 return (etacode,phicode)
425
426
427
428

◆ main()

ReadRPCRun2DataFile.main ( args)

Definition at line 528 of file ReadRPCRun2DataFile.py.

528def main(args):
529
530 # read 2015 geometry xml file
531 muonGeometry2015 = read2015Geometry( args.infile2015 )
532
533 muonGeometry2015.printStats()
534
535 # maps roi number to etacode and phicode
536 rpcCodeMapping = read2015RPCCodeMapping( muonGeometry2015 )
537
538
539 muonGeometry2016 = read2016RPCGeomData( args.infile, rpcCodeMapping )
540 muonGeometry2016.printStats()
541
542
543 updateGeometryTGC(muonGeometry2016, muonGeometry2015)
544 muonGeometry2016.printStats()
545
546 # write out the RPC info and the TGC info
547 muonGeometry2016.writeXML("TestMioctGeometry2016.xml")
548
549
550
551
int main()
Definition hello.cxx:18

◆ read2015Geometry()

ReadRPCRun2DataFile.read2015Geometry ( fn)

Definition at line 299 of file ReadRPCRun2DataFile.py.

299def read2015Geometry( fn ):
300 xmlgeometry = MioctGeometryXMLReader(fn)
301 miocts = []
302 for MIOCT in xmlgeometry.getMIOCTs():
303 sectors = []
304 for sector in MIOCT.Sectors:
305 #if sn.startswith('B'): continue
306 rois = []
307 for roiElem in sector.ROIs:
308 rois += [ ROI.fromROIelement(roiElem) ]
309 sectors += [ Sector(name=sector['name'], connector=int(sector['connector']), rois=rois) ]
310 miocts += [ Mioct( id=int(MIOCT['id']), slot=int(MIOCT['slot']), sectors=sectors) ]
311 decodes = Decodes()
312 for tc in MIOCT.Decode.TopoCells:
313 decodes.addTopoCell( TopoCell.fromTopoCellElement(tc) )
314 miocts[-1].decodes=decodes
315 return MuonGeometry("full geometry 2015", miocts=miocts)
316
317
318

◆ read2015RPCCodeMapping()

ReadRPCRun2DataFile.read2015RPCCodeMapping ( geometry)

Definition at line 319 of file ReadRPCRun2DataFile.py.

319def read2015RPCCodeMapping( geometry ):
320 mapping = {}
321 for mioct in geometry.miocts:
322 for sector in mioct.sectors:
323 if sector.isBarrel():
324 mapping[sector.id] = dict( [ (roi.roiid, (roi.etacode, roi.phicode)) for roi in sector.rois ] )
325 return mapping
326
327
328
329

◆ read2016RPCGeomData()

ReadRPCRun2DataFile.read2016RPCGeomData ( fn,
oldMapping )

Definition at line 429 of file ReadRPCRun2DataFile.py.

429def read2016RPCGeomData(fn, oldMapping):
430
431 rpcGeometry2016 = MuonGeometry("RPC geometry 2016")
432
433 print("read2016RPCGeomData: Reading %s", fn)
434 f = open(fn,"read")
435 for line in f:
436 if line.lstrip().startswith("#"): # remove comments
437 continue
438 ls = line.split()
439 side = int(ls[0])
440 sector = int(ls[1])
441 roiid = int(ls[2])
442 etamin = float(ls[3])
443 etamax = float(ls[4])
444 phimin = float(ls[5])
445 phimax = float(ls[6])
446 if max(phimin, phimax) < 0:
447 phimin += 2 * PI
448 phimax += 2 * PI
449 eta = (etamin + etamax) / 2
450 phi = (phimin + phimax) / 2
451
452 sectorId = sector + 32 * side
453 if sectorId in [21,22,23,24,25,26,53,54,55,56,57,58]:
454 (etacode, phicode) = feetRegionMapping(sectorId, roiid)
455 else:
456 (etacode, phicode) = oldMapping[sectorId][roiid]
457
458 roi = ROI( eta=eta, phi=phi, phimin=phimin, phimax=phimax, etamin=etamin, etamax=etamax, etacode=etacode, phicode=phicode, roiid=roiid )
459
460 # now find MIOCT and Sector where to add the ROI to
461 mioctId, mioctSlot, sectorConnector, sectorName = rpcMioctAndSectorInfo(sectorId)
462 mioct = rpcGeometry2016.getMioct(mioctId)
463 if not mioct:
464 mioct = rpcGeometry2016.addMioct(Mioct(id=mioctId, slot=mioctSlot))
465
466 sector = mioct.getSector(sectorConnector)
467 if not sector:
468 sector = mioct.addSector( Sector(name=sectorName, connector=sectorConnector) )
469
470 sector.addROI( roi )
471
472 return rpcGeometry2016
473
474
void print(char *figname, TCanvas *c1)
#define max(a, b)
Definition cfImp.cxx:41

◆ roiAsXML()

ReadRPCRun2DataFile.roiAsXML ( roi,
depth )

Definition at line 514 of file ReadRPCRun2DataFile.py.

514def roiAsXML(roi, depth):
515 roi['eta'] = (float(roi['etamin']) + float(roi['etamax'])) / 2
516 roi['phi'] = (float(roi['phimin']) + float(roi['phimax'])) / 2
517 s = ' ' * depth + '<ROI eta="%f" phi="%f" etacode="0x%s" phicode="0x%s" etamin="%f" etamax="%f" phimin="%f" phimax="%f" roiid="%i"/>\n' % (roi["eta"], roi["phi"], roi["etacode"], roi["phicode"], roi["etamin"], roi["etamax"], roi["phimin"], roi["phimax"], roi["roiid"] )
518 return s
519
520
521
522
523
524
525
526
527

◆ roiAsXML_2()

ReadRPCRun2DataFile.roiAsXML_2 ( roi,
depth )

Definition at line 497 of file ReadRPCRun2DataFile.py.

497def roiAsXML_2(roi, depth):
498 attr = ["eta", "phi", "etacode", "phicode", "etamin", "etamax", "phimin", "phimax", "roiid"]
499 s = ' ' * depth + "<ROI %s/>\n" % (" ".join(['%s="%s"' % (a, roi[a]) for a in attr]) )
500 return s
501
502

◆ rpcMioctAndSectorInfo()

ReadRPCRun2DataFile.rpcMioctAndSectorInfo ( sectorID)

Definition at line 285 of file ReadRPCRun2DataFile.py.

285def rpcMioctAndSectorInfo(sectorID):
286 sectorName = "B%02i" % sectorID
287 sectorConnector = (sectorID+2) % 4
288
289 mioctID = ( (sectorID+2) % 32 ) / 4
290 mioctSlot = mioctID + 4
291 if sectorID >= 32:
292 mioctID += 8
293 mioctSlot = mioctID + 6
294
295 return mioctID, mioctSlot, sectorConnector, sectorName
296
297
298

◆ sectorAsXML()

ReadRPCRun2DataFile.sectorAsXML ( xxx_todo_changeme,
depth,
stats )

Definition at line 503 of file ReadRPCRun2DataFile.py.

503def sectorAsXML(xxx_todo_changeme, depth, stats):
504 (connector, name, rois) = xxx_todo_changeme
505 s = ' '*depth + '<Sector connector="%s" name="%s">\n' % (connector, name)
506 s += ' '*depth + ' <!-- contains %i ROIs -->\n' % len(rois)
507 s += ' '*depth + ' <!-- mapping from ROI to coding scheme -->\n'
508 for roi in rois:
509 s += roiAsXML(roi, depth + 4 )
510 s += ' '*depth + "</Sector>\n"
511 stats['rois'] += len(rois)
512 return s
513

◆ sectorAsXML_2()

ReadRPCRun2DataFile.sectorAsXML_2 ( sector,
depth,
stats )

Definition at line 486 of file ReadRPCRun2DataFile.py.

486def sectorAsXML_2(sector, depth, stats):
487 attr = ["connector", "name"]
488 s = ' '*depth + "<%s %s>\n" % (sector.tag, " ".join(['%s="%s"' % (a, sector[a]) for a in attr]) )
489 s += ' '*depth + ' <!-- contains %i ROIs -->\n' % len(sector.ROIs)
490 s += ' '*depth + ' <!-- mapping from ROI to coding scheme -->\n'
491 for roi in sorted(sector.ROIs, key=lambda roi: int(roi['roiid'])):
492 s += roiAsXML_2(roi, depth + 4 )
493 s += ' '*depth + "</%s>\n" % sector.tag
494 stats['rois'] += len(sector.ROIs)
495 return s
496

◆ updateGeometryTGC()

ReadRPCRun2DataFile.updateGeometryTGC ( newGeometry,
oldGeometry )

Definition at line 475 of file ReadRPCRun2DataFile.py.

475def updateGeometryTGC(newGeometry, oldGeometry):
476 newGeometry.name = "updated full geometry for 2016"
477 for mioct in newGeometry.miocts:
478 oldMioct = oldGeometry.getMioct(mioct.id)
479 for sector in oldMioct.sectors:
480 if sector.isBarrel(): continue
481 mioct.addSector(sector)
482 mioct.fillTopoCells()
483
484
485

Variable Documentation

◆ args

ReadRPCRun2DataFile.args = parser.parse_args()

Definition at line 563 of file ReadRPCRun2DataFile.py.

◆ default

ReadRPCRun2DataFile.default

Definition at line 557 of file ReadRPCRun2DataFile.py.

◆ dest

ReadRPCRun2DataFile.dest

Definition at line 557 of file ReadRPCRun2DataFile.py.

◆ help

ReadRPCRun2DataFile.help

Definition at line 558 of file ReadRPCRun2DataFile.py.

◆ parser

ReadRPCRun2DataFile.parser
Initial value:
1= argparse.ArgumentParser( description=__doc__,
2 formatter_class = argparse.RawTextHelpFormatter)

Definition at line 554 of file ReadRPCRun2DataFile.py.

◆ type

ReadRPCRun2DataFile.type

Definition at line 557 of file ReadRPCRun2DataFile.py.