5 from CoolConvUtilities.AtlCoolLib 
import indirectOpen
 
    6 from functools 
import cache
 
   10     "Wrapper class to hold LAr run configuration information" 
   11     def __init__(self,nSamples,gainType,latency,firstSample,format,runType):
 
   20         "Number of samples readout from FEB" 
   24         "gainType: 0=auto,1=L,2=M,3=H,4=LM,5=LH,6=ML,7=MH,8=HL,9=HM,10=LMH,11=LHM,12=MLH,13=MHL,14=HLM,15=HML" 
   28         "latency between l1 trigger and readout" 
   36         "format:0=Transparent, 1=Format 1, 2=Format 2" 
   40         "runType: 0=RawData, 1=RawDataResult, 2=Result" 
   55            return 'RawDataResult' 
   61     from AthenaCommon.Logging 
import logging
 
   62     mlog_LRF = logging.getLogger( 
'getLArRunFormatForRun' )
 
   64     mlog_LRF.info(
"Connecting to database %s", connstring)
 
   68         mlog_LRF.error(
"Cannot connect to database %s",connstring)
 
   69         raise RuntimeError(
"getLArFormatForRun ERROR: Cannot connect to database %s",connstring)
 
   77         folder=runDB.getFolder(
'/LAR/Configuration/RunLog')
 
   79         obj=folder.findObject(runiov,0)
 
   81         format=payload[
'format']
 
   82         nSamples=ord(payload[
'nbOfSamples'])
 
   83         gainType=payload[
'gainType'] 
 
   84         runType=payload[
'runType']
 
   85         latency=ord(payload[
'l1aLatency'])
 
   86         firstSample=ord(payload[
'firstSample'])
 
   88         mlog_LRF.warning(
"No information in /LAR/Configuration/RunLog for run %i", run)
 
   92     return  LArRunInfo(nSamples,gainType,latency,firstSample,format,runType)
 
   95     "Wrapper class to hold LAr DT run configuration information" 
   96     def __init__(self,streamTypes, streamLengths, streamTypesPEB, streamLengthsPEB, timing, adccalib, fw):
 
  128     typesMap={0:
"ADC", 1:
"RawADC", 2:
"Energy", 3:
"SelectedEnergy",15:
"Invalid"}
 
  131     for s,m 
in [
"at0_bc",0],[
"at1_bc",1]:
 
  136              n=
int(recipe[pos+6:pos+8])
 
  139                n=
int(recipe[pos+6:pos+7])
 
  141                mlog.warning(
"could not decode %s",recipe[pos+6:])
 
  144              if mux[m] 
in typesMap.keys():
 
  145                 sTypes.append(typesMap[mux[m]])
 
  150     return (sTypes,sLengths) 
 
  154     from AthenaCommon.Logging 
import logging
 
  155     mlog_LRF = logging.getLogger( 
'getLArDTRunInfoForRun' )
 
  156     mlog_LRF.info(
"Connecting to database %s", connstring)
 
  160         mlog_LRF.error(
"Cannot connect to database %s",connstring)
 
  161         raise RuntimeError(
"getLArFormatForRun ERROR: Cannot connect to database %s",connstring)
 
  168         folder=runDB.getFolder(
'/LAR/Configuration/RunLogDT')
 
  170         obj=folder.findObject(runiov,0)
 
  171         payload=obj.payload()
 
  172         timing=payload[
'timing_configuration']
 
  173         recipe=payload[
'recipe_tdaq_A']
 
  174         recipePEB=payload[
'recipe_tdaq_B']
 
  175         mux.append(ord(payload[
'mux_setting_0_tdaq']))
 
  176         mux.append(ord(payload[
'mux_setting_1_tdaq']))
 
  177         adccalib=ord(payload[
'ADCCalibMode'])
 
  179             fw=ord(payload[
'ttype_mask_A'])
 
  181         mlog_LRF.warning(
"No information in /LAR/Configuration/RunLogDT for run %i", run)
 
  182         mlog_LRF.warning(
"Using defaults: MUX0: ADC MUX1: ET_ID receipe: at0_bc5-at1_bc1_ts1-q")
 
  183         recipe=
"at0_bc5-at1_bc1_ts1-q" 
  188     runDB.closeDatabase()
 
  190     sTypesPEB, sLengthsPEB = 
parse_recipe(recipePEB,mux,mlog_LRF)
 
  191     return  LArDTRunInfo(sTypes, sLengths, sTypesPEB, sLengthsPEB, timing, adccalib, fw)
 
  194 if __name__==
'__main__':
 
  197         print(
"Syntax",sys.argv[0],
'<run>')
 
  201     if (myformat 
is not None):
 
  202       print(
" LAr run configuration: Nsamples:%d  GainType:%d  Latency:%d  FirstSample:%d  Format:%s  runType:%s" % (myformat.nSamples(),myformat.gainType(),myformat.latency(),myformat.firstSample(),myformat.stringFormat(),myformat.stringRunType()))
 
  204       print(
" LAr run information not available")
 
  207     if (myformat1 
is not None):
 
  208       print(
" LAr DT run configuration: timing:%s  adccalib:%d" % (myformat1.timing(),myformat1.ADCCalib()))
 
  209       for i 
in range(0,len(myformat1.streamTypes())):
 
  210          print(
" stream: %s  size: %d" % (myformat1.streamTypes()[i], myformat1.streamLengths()[i]))  
 
  212       print(
" LAr DT run information not available")