421 def merge_gains(gains1,gains2,gains3,reference_gains,forced_list,geometry_map,writeAllChannels):
426 n_files_LowEta_EMEC = 0
427 n_files_HighEta_EMB = 0
431 if gains3
is not None:
432 good_gains=gains3.getGoodGains()
433 print (
" Using run ", gains3.run_nr,
" run strategy= ", gains3.strategy )
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
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]
449 print (
"Ignoring File 3, probably not specified" )
453 if gains2
is not None:
454 good_gains=gains2.getGoodGains()
455 print (
" Using run ", gains2.run_nr,
" run strategy= ", gains2.strategy )
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
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]
470 print (
"Ignoring File 2, probably not specified" )
475 if gains1
is not None:
476 good_gains=gains1.getGoodGains()
477 print (
" Using run ", gains1.run_nr,
" run strategy= ", gains1.strategy )
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
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]
492 print (
"Ignoring File 1, probably not specified" )
497 if forced_list
is not None:
498 myfile =
open(forced_list,
'r')
499 for line
in myfile.readlines():
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])
507 output_gains[rec_chan]=[gain,error_code]
508 print (
"forcing channel ", rec_chan,
" to value ", gain )
510 print (
"Ignoring forced channel list")
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]
522 output_gains[channel]=[gain,error_code]
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" )