def LArADC2MeVToolOnline(name="LArADC2MeVToolOnline", **kw): # call base class constructor from AthenaCommon import CfgMgr kw['name'] = name tool = CfgMgr.LArADC2MeVTool(**kw) mlog = logging.getLogger('LArADC2MeVToolOnline::__init__ ') mlog.info("entering") # do the configuration tool.MCSym = False tool.UseMphysOverMcal = True tool.UseHVScaleCorr = True # setup old ADC2MeVTool key_suffix = "_online" oldlarCondDBFolders = [ "/LAR/ElecCalibOnl/DAC2uA<key>DAC2uA" + key_suffix + "</key>", "/LAR/ElecCalibOnl/MphysOverMcal<key>MphysOverMcal" + key_suffix + "</key>", "/LAR/ElecCalibOnl/Ramp<key>Ramp" + key_suffix + "</key>", "/LAR/ElecCalibOnl/uA2MeV<key>uA2MeV" + key_suffix + "</key>", "/LAR/ElecCalibOnl/HVScaleCorr<key>HVScaleCorr" + key_suffix + "</key>", ] from IOVDbSvc.CondDB import conddb forceRN = "" selection = "" LArDBConnection = "" from LArConditionsCommon.LArCondFlags import larCondFlags if larCondFlags.LArDBConnection.statusOn: LArDBConnection = larCondFlags.LArDBConnection() if larCondFlags.LArForceIOVRunNumber.statusOn: forceRN = "<forceRunNumber>" + larCondFlags.LArForceIOVRunNumber( ) + "</forceRunNumber>" if larCondFlags.LArCoolChannelSelection.statusOn: selection = "<channelSelection>" + larCondFlags.LArCoolChannelSelection( ) + "</channelSelection>" for i in oldlarCondDBFolders: if i.find("DAC2uA") > 0 or i.find("uA2MeV") > 0 or i.find( "HVScale") > 0: conddb.addFolder("LAR", i + LArDBConnection + forceRN) else: conddb.addFolder("LAR", i + LArDBConnection + forceRN + selection) tool.keyADC2DAC = "Ramp" + key_suffix tool.keyDAC2uA = "DAC2uA" + key_suffix tool.keyuA2MeV = "uA2MeV" + key_suffix tool.keyMphysMcal = "MphysOverMcal" + key_suffix tool.keyHVScaleCorr = "HVScaleCorr" + key_suffix return tool
def configure(self): mlog = logging.getLogger( 'Py:LArRawChannelGetter::configure %s:' % self.__class__ ) from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() from AthenaCommon.AppMgr import ToolSvc # get LArDigitGetter in MC case from AthenaCommon.DetFlags import DetFlags if DetFlags.digitize.LAr_on() : try: from LArDigitization.LArDigitGetter import LArDigitGetter theLArDigitGetter = LArDigitGetter() except Exception as configException: mlog.error("could not get handle to LArDigitGetter Quit") import traceback mlog.error(traceback.format_exc()) return False if not theLArDigitGetter.usable(): mlog.error("LArDigitGetter unusable. Quite") return False from LArROD.LArRODFlags import larRODFlags from AthenaCommon.GlobalFlags import globalflags if globalflags.DataSource()=='data' or larRODFlags.forceIter() : # ADC2MeV tool from LArRecUtils.LArADC2MeVToolDefault import LArADC2MeVToolDefault theADC2MeVTool = LArADC2MeVToolDefault() ToolSvc += theADC2MeVTool from AthenaCommon.AppMgr import ServiceMgr as svcMgr # Data case if larRODFlags.readDigits(): from AthenaCommon.GlobalFlags import globalflags if globalflags.InputFormat() == 'bytestream': if not larRODFlags.keepDSPRaw(): topSequence.LArRawDataReaderAlg.LArRawChannelKey="" if globalflags.DetGeo() == 'ctbh6' or globalflags.DetGeo() == 'ctbh8': from LArROD.LArRODConf import LArRawChannelBuilder theLArRawChannelBuilder=LArRawChannelBuilder() topSequence += theLArRawChannelBuilder return True from LArROD.LArRODConf import LArRawChannelBuilderDriver theLArRawChannelBuilder=LArRawChannelBuilderDriver("LArRawChannelBuilder") topSequence += theLArRawChannelBuilder if larRODFlags.keepDSPRaw(): theLArRawChannelBuilder.LArRawChannelContainerName=larRODFlags.RawChannelFromDigitsContainerName() # bad channel masking if required if not larRODFlags.doBuildBadChannel(): # The first tool filters out bad channels from LArROD.LArRODConf import LArRawChannelBuilderToolBadChannelTool theLArRawChannelBuilderToolBadChannel=LArRawChannelBuilderToolBadChannelTool() from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelMasker theLArRCBMasker=LArBadChannelMasker("LArRCBMasker") theLArRCBMasker.DoMasking=True theLArRCBMasker.ProblemsToMask=[ "deadReadout","deadPhys","almostDead","short", "lowNoiseHG","highNoiseHG","unstableNoiseHG", "lowNoiseMG","highNoiseMG","unstableNoiseMG", "lowNoiseLG","highNoiseLG","unstableNoiseLG" ] theLArRawChannelBuilderToolBadChannel.BadChannelMask=theLArRCBMasker theLArRawChannelBuilder.BuilderTools += [theLArRawChannelBuilderToolBadChannel] ToolSvc+=theLArRawChannelBuilderToolBadChannel # Pulse reconstruction # main method: OFC iteration from LArROD.LArRODConf import LArRawChannelBuilderToolOFCIter theLArRawChannelBuilderToolOFCIter=LArRawChannelBuilderToolOFCIter() theLArRawChannelBuilderToolOFCIter.minSample = 2 theLArRawChannelBuilderToolOFCIter.maxSample = 12 theLArRawChannelBuilderToolOFCIter.minADCforIterInSigma=4 # ADCmax at least 4 sigma above noise for iteration theLArRawChannelBuilderToolOFCIter.minADCforIter=15 # min adc for iteration (only if no pedestalRMS found) theLArRawChannelBuilderToolOFCIter.defaultPhase=0 # starting delay, also the fixed delay for ADC below min. theLArRawChannelBuilderToolOFCIter.ECut=250. # Energy to save quality theLArRawChannelBuilder.BuilderTools += [theLArRawChannelBuilderToolOFCIter] theLArRawChannelBuilder+=theLArRawChannelBuilderToolOFCIter # no fallback when emulating exactly DSP computation if not larRODFlags.doDSP(): # fallback(1): cubic method from LArROD.LArRODConf import LArRawChannelBuilderToolCubic theLArRawChannelBuilderToolCubic=LArRawChannelBuilderToolCubic() theLArRawChannelBuilderToolCubic.minADCforCubic=30 theLArRawChannelBuilder.BuilderTools += [theLArRawChannelBuilderToolCubic] theLArRawChannelBuilder += theLArRawChannelBuilderToolCubic # fallback(2) averageing from LArROD.LArRODConf import LArRawChannelBuilderToolAverage theLArRawChannelBuilderToolAverage=LArRawChannelBuilderToolAverage() theLArRawChannelBuilderToolAverage.NScan=0 theLArRawChannelBuilder.BuilderTools += [theLArRawChannelBuilderToolAverage] theLArRawChannelBuilder += theLArRawChannelBuilderToolAverage # Pedestal # main method from database from LArROD.LArRODConf import LArRawChannelBuilderPedestalDataBase theLArRawChannelBuilderPedestalDataBase=LArRawChannelBuilderPedestalDataBase() theLArRawChannelBuilderPedestalDataBase.LArPedestalKey = "LArPedestal" theLArRawChannelBuilder.PedestalTools = [theLArRawChannelBuilderPedestalDataBase] theLArRawChannelBuilder += theLArRawChannelBuilderPedestalDataBase # no fallback when emulating exactly DSP computation if not larRODFlags.doDSP(): # fallback. sample 0 from LArROD.LArRODConf import LArRawChannelBuilderPedestalSampleZero theLArRawChannelBuilderPedestalSampleZero=LArRawChannelBuilderPedestalSampleZero() theLArRawChannelBuilder.PedestalTools += [theLArRawChannelBuilderPedestalSampleZero] theLArRawChannelBuilder += theLArRawChannelBuilderPedestalSampleZero # ADC to energy # main method from database from LArROD.LArRODConf import LArRawChannelBuilderADC2EDataBase theLArRawChannelBuilderADC2EDataBase=LArRawChannelBuilderADC2EDataBase() theLArRawChannelBuilder.ADCtoEnergyTools = [theLArRawChannelBuilderADC2EDataBase] theLArRawChannelBuilderADC2EDataBase.ADC2MeVTool = theADC2MeVTool theLArRawChannelBuilder += theLArRawChannelBuilderADC2EDataBase # no fallback when emulating exactly DSP computation if not larRODFlags.doDSP(): # fallback, constant conversion factors from LArROD.LArRODConf import LArRawChannelBuilderADC2EConstants theLArRawChannelBuilderADC2EConstants=LArRawChannelBuilderADC2EConstants() theLArRawChannelBuilder.ADCtoEnergyTools += [theLArRawChannelBuilderADC2EConstants] theLArRawChannelBuilder += theLArRawChannelBuilderADC2EConstants #more tools to be configured from LArRecUtils.LArRecUtilsConf import LArOFPeakRecoTool theLArOFPeakRecoTool=LArOFPeakRecoTool() from LArConditionsCommon.LArCondFlags import larCondFlags theLArOFPeakRecoTool.UseShape=larCondFlags.useShape() if larCondFlags.LArCoolChannelSelection.statusOn: if len(larCondFlags.LArCoolChannelSelection())>0: theLArOFPeakRecoTool.forceHighGain=larCondFlags.useOFCOnlyCoolChannelSelection() ToolSvc += theLArOFPeakRecoTool # # adjust default timing to match first sample information written in cool from Lar online configuration # nominalPeakSample=2 if globalflags.DataSource()=='data': from LArConditionsCommon.LArCool import larcool if (larcool is not None): nominalPeakSample = larcool.firstSample() # don't use ramp intercept in calibration if gain type is not auto if larcool.gainType() > 0 : mlog.info(" Gain Type: %d don't use intercept in ADC to Energy ramp calibration",larcool.gainType()) theLArRawChannelBuilderADC2EDataBase.UseHighGainRampIntercept = False theLArRawChannelBuilderADC2EDataBase.UseMedGainRampIntercept = False theLArRawChannelBuilderADC2EDataBase.UseLowGainRampIntercept = False else : mlog.info(" Gain Type: %d use intercept in ADC to energy ramp calibraion ",larcool.gainType()) if (nominalPeakSample > 1) : theLArRawChannelBuilder.DefaultShiftTimeSample=nominalPeakSample-2 else : theLArRawChannelBuilder.DefaultShiftTimeSample=0 theLArRawChannelBuilder.DataLocation = "FREE" else: from AthenaCommon.GlobalFlags import globalflags if globalflags.InputFormat() == 'bytestream': if not "LArRawChannelContainer/LArRawChannels" in svcMgr.ByteStreamAddressProviderSvc.TypeNames: svcMgr.ByteStreamAddressProviderSvc.TypeNames+=["LArRawChannelContainer/LArRawChannels"] # In the case of DSP monitoring and reading rawchannels, need to give a different name to the LArRawChannels container # read from the bytestream ... # This name has to be coherent with the name in LArMonTools/LArRODMonTool_jobOptions.py if larRODFlags.doDSP() and larRODFlags.readRawChannels(): #Reading LArRawChannel print ("Reading RawChannels in DSP physics mode") # !!! The name of the LArRawChannels container read from the Bytestream is LArRawChannels_fB !!! if not "LArRawChannelContainer/LArRawChannels_fB" in svcMgr.ByteStreamAddressProviderSvc.TypeNames: svcMgr.ByteStreamAddressProviderSvc.TypeNames+=["LArRawChannelContainer/LArRawChannels_fB"] print (svcMgr.ByteStreamAddressProviderSvc.TypeNames) else: # MC Case try: from AthenaCommon import CfgGetter topSequence += CfgGetter.getAlgorithm("LArRawChannelBuilder", tryDefaultConfigurable=True) except Exception as cfgException: mlog.error("Failed to retrieve LArRawChannelBuilder. Quit") import traceback mlog.error(traceback.format_exc()) return False return True
#Load HVScaleCorr. For run 2,these constants are also used by the CaloNoiseToolDB if (haveElecCalibInline): conddb.addFolder(ONLDB, "/LAR/ElecCalibFlat/HVScaleCorr" + forceRN + sqlDB) theLArCondSvc.HVScaleCorrInput = "/LAR/ElecCalibFlat/HVScaleCorr" #Load Electronic Calibration folders: if larCondFlags.LoadElecCalib(): #Some examples based on ExtendedFTGrouping, not duely tested. #Always use correction channels #LArCoolChannelSelection="0,1,3:473" #Ignore low gain #LArCoolChannelSelection="0:3,3:66,117:180,238:304,355:418" #Barrel High, Med gain #LArCoolChannelSelection="0:238,306,313,319,325,331,338,334,350" #EM High, HEC medium gain selection = "" if larCondFlags.LArCoolChannelSelection.statusOn and larCondFlags.LArCoolChannelSelection( ) != "": selection = "<channelSelection>" + larCondFlags.LArCoolChannelSelection( ) + "</channelSelection>" pass if (haveElecCalibInline): if not SuperCells: # Run 2 case: #1. uA2MeV if larCondFlags.ua2MeVFolder() == "": conddb.addFolder("LAR_ONL", "/LAR/ElecCalibFlat/uA2MeV" + forceRN) theLArCondSvc.uA2MeVInput = "/LAR/ElecCalibFlat/uA2MeV" else: #Load from offline database