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

Classes

class  GainsFromOracle
class  GainsFromSqlite
class  L1CaloGeometryConvertor

Functions

 WriteSqlite (name, input_dict)
 merge_gains (gains1, gains2, gains3, reference_gains, forced_list, geometry_map, writeAllChannels)

Variables

 parser = OptionParser()
 action
 type
 dest
 help
 options
 args
 geometry_convertor = L1CaloGeometryConvertor()
 gains_1 = GainsFromSqlite(options.input_file1,geometry_convertor)
 gains_2 = GainsFromSqlite(options.input_file2,geometry_convertor)
 gains_3 = GainsFromSqlite(options.input_file3,geometry_convertor)
 gains_reference = GainsFromOracle()
 gains_to_load = merge_gains(gains_1,gains_2,gains_3,gains_reference,options.forced_file,geometry_convertor,options.writeAllChannels)
 output_file_name = options.output_file

Function Documentation

◆ merge_gains()

mergeEnergyRamps.merge_gains ( gains1,
gains2,
gains3,
reference_gains,
forced_list,
geometry_map,
writeAllChannels )

Definition at line 421 of file mergeEnergyRamps.py.

421def merge_gains(gains1,gains2,gains3,reference_gains,forced_list,geometry_map,writeAllChannels):
422
423 output_gains={}
424
425 n_files_Tile = 0
426 n_files_LowEta_EMEC = 0
427 n_files_HighEta_EMB = 0
428
429#loop over gains3, fill in
430
431 if gains3 is not None:
432 good_gains=gains3.getGoodGains()
433 print (" Using run ", gains3.run_nr, " run strategy= ", gains3.strategy )
434
435 if gains3.strategy == "GainOne":
436 n_files_Tile = n_files_Tile + 1
437 if gains3.strategy == "GainOneOvEmecFcalLowEta":
438 n_files_LowEta_EMEC = n_files_LowEta_EMEC + 1
439 if gains3.strategy == "GainOneOvEmbFcalHighEta":
440 n_files_HighEta_EMB = n_files_HighEta_EMB + 1
441
442
443 for ppm_channel in good_gains.keys():
444 gain = good_gains[ppm_channel][0]
445 error_code = good_gains[ppm_channel][1]
446 rec_chan = geometry_map.getReceiverfromPPM(ppm_channel,gains3.strategy)
447 output_gains[rec_chan]=[gain,error_code]
448 else:
449 print ("Ignoring File 3, probably not specified" )
450
451#loop over gains2, fill in
452
453 if gains2 is not None:
454 good_gains=gains2.getGoodGains()
455 print (" Using run ", gains2.run_nr, " run strategy= ", gains2.strategy )
456
457 if gains2.strategy == "GainOne":
458 n_files_Tile = n_files_Tile + 1
459 if gains2.strategy == "GainOneOvEmecFcalLowEta":
460 n_files_LowEta_EMEC = n_files_LowEta_EMEC + 1
461 if gains2.strategy == "GainOneOvEmbFcalHighEta":
462 n_files_HighEta_EMB = n_files_HighEta_EMB + 1
463
464 for ppm_channel in good_gains.keys():
465 gain = good_gains[ppm_channel][0]
466 error_code = good_gains[ppm_channel][1]
467 rec_chan = geometry_map.getReceiverfromPPM(ppm_channel,gains2.strategy)
468 output_gains[rec_chan]=[gain,error_code]
469 else:
470 print ("Ignoring File 2, probably not specified" )
471
472
473#loop over gains 1, fill in
474
475 if gains1 is not None:
476 good_gains=gains1.getGoodGains()
477 print (" Using run ", gains1.run_nr, " run strategy= ", gains1.strategy )
478
479 if gains1.strategy == "GainOne":
480 n_files_Tile = n_files_Tile + 1
481 if gains1.strategy == "GainOneOvEmecFcalLowEta":
482 n_files_LowEta_EMEC = n_files_LowEta_EMEC + 1
483 if gains1.strategy == "GainOneOvEmbFcalHighEta":
484 n_files_HighEta_EMB = n_files_HighEta_EMB + 1
485
486 for ppm_channel in good_gains.keys():
487 gain = good_gains[ppm_channel][0]
488 error_code = good_gains[ppm_channel][1]
489 rec_chan = geometry_map.getReceiverfromPPM(ppm_channel,gains1.strategy)
490 output_gains[rec_chan]=[gain,error_code]
491 else:
492 print ("Ignoring File 1, probably not specified" )
493
494
495#read in forced list, overwrite
496
497 if forced_list is not None:
498 myfile = open(forced_list,'r')
499 for line in myfile.readlines():
500 line.rstrip()
501 line.lstrip()
502 line_cont = line.split(' ')
503 line_cont = [iii for iii in line_cont if not iii == '']
504 rec_chan = line_cont[0]
505 gain = float(line_cont[1])
506 error_code = 10 # code for forced channels
507 output_gains[rec_chan]=[gain,error_code]
508 print ("forcing channel ", rec_chan, " to value ", gain )
509 else:
510 print ("Ignoring forced channel list")
511
512#check channels that haven't been found yet, take them from reference
513
514 if writeAllChannels:
515
516 print ("Adding gains for missing channels from Oracle" )
517 missing_channels = geometry_convertor.getMissingReceiverChannels(output_gains.keys())
518 default_gains = reference_gains.getGoodGains()
519 for channel in missing_channels:
520 gain = default_gains[channel]
521 error_code = 100
522 output_gains[channel]=[gain,error_code]
523
524# print ("missing receiver=",channel, "PPM=", geometry_map.getPPMfromReceiver(channel) )
525
526 if (not n_files_Tile == 1) or (not n_files_LowEta_EMEC == 1) or (not n_files_HighEta_EMB == 1):
527 print ("WARNING! input files do not allow to calibrate all partitions, using defaults where needed" )
528
529 return output_gains
530
531
532

◆ WriteSqlite()

mergeEnergyRamps.WriteSqlite ( name,
input_dict )

Definition at line 241 of file mergeEnergyRamps.py.

241def WriteSqlite(name,input_dict):
242
243 UNIX2COOL = 1000000000
244
245 dbSvc = cool.DatabaseSvcFactory.databaseService()
246 connectString = 'sqlite://;schema='+name+';dbname=L1CALO'
247# folder_name="/TRIGGER/Receivers/Factors/CalibGains"
248
249
250 print ('\nrecreating database file:',name)
251 dbSvc.dropDatabase( connectString )
252 db = dbSvc.createDatabase( connectString )
253
254 spec = cool.RecordSpecification()
255 spec.extend("factor", cool.StorageType.Float)
256 spec.extend("status", cool.StorageType.UInt32 )
257 folderSpec = cool.FolderSpecification(cool.FolderVersioning.SINGLE_VERSION, spec)
258
259 now = int(time.time())
260
261 since = now*UNIX2COOL
262 until = cool.ValidityKeyMax
263 db.createFolderSet('/TRIGGER')
264 db.createFolderSet('/TRIGGER/Receivers')
265 db.createFolderSet('/TRIGGER/Receivers/Factors')
266
267 folder_description = '<timeStamp>time</timeStamp><addrHeader><address_header service_type="71" clid="1238547719"/></addrHeader><typeName>CondAttrListCollection</typeName>'
268 f = db.createFolder( "/TRIGGER/Receivers/Factors/CalibGains", folderSpec, folder_description)
269
270 print (" Now creating sqlite file for ", len(input_dict.keys()), " channels")
271 for i in input_dict.keys():
272 data = cool.Record( spec )
273 data['factor'] = input_dict[i][0]
274 data['status'] = input_dict[i][1]
275 f.storeObject(since,until, data, int(i,16) )
276
277 db.closeDatabase()
278

Variable Documentation

◆ action

mergeEnergyRamps.action

Definition at line 539 of file mergeEnergyRamps.py.

◆ args

mergeEnergyRamps.args

Definition at line 546 of file mergeEnergyRamps.py.

◆ dest

mergeEnergyRamps.dest

Definition at line 539 of file mergeEnergyRamps.py.

◆ gains_1

mergeEnergyRamps.gains_1 = GainsFromSqlite(options.input_file1,geometry_convertor)

Definition at line 554 of file mergeEnergyRamps.py.

◆ gains_2

mergeEnergyRamps.gains_2 = GainsFromSqlite(options.input_file2,geometry_convertor)

Definition at line 559 of file mergeEnergyRamps.py.

◆ gains_3

mergeEnergyRamps.gains_3 = GainsFromSqlite(options.input_file3,geometry_convertor)

Definition at line 564 of file mergeEnergyRamps.py.

◆ gains_reference

mergeEnergyRamps.gains_reference = GainsFromOracle()

Definition at line 569 of file mergeEnergyRamps.py.

◆ gains_to_load

mergeEnergyRamps.gains_to_load = merge_gains(gains_1,gains_2,gains_3,gains_reference,options.forced_file,geometry_convertor,options.writeAllChannels)

Definition at line 577 of file mergeEnergyRamps.py.

◆ geometry_convertor

mergeEnergyRamps.geometry_convertor = L1CaloGeometryConvertor()

Definition at line 548 of file mergeEnergyRamps.py.

◆ help

mergeEnergyRamps.help

Definition at line 539 of file mergeEnergyRamps.py.

◆ options

mergeEnergyRamps.options

Definition at line 546 of file mergeEnergyRamps.py.

◆ output_file_name

str mergeEnergyRamps.output_file_name = options.output_file

Definition at line 580 of file mergeEnergyRamps.py.

◆ parser

mergeEnergyRamps.parser = OptionParser()

Definition at line 537 of file mergeEnergyRamps.py.

◆ type

mergeEnergyRamps.type

Definition at line 539 of file mergeEnergyRamps.py.