diff --git a/LArCalorimeter/LArCafJobs/python/LArSCDumperFlags.py b/LArCalorimeter/LArCafJobs/python/LArSCDumperFlags.py index 06cb6673ca159ecf1efc249f24a7e0723e871fbe..a0f877f30fc7f7ccf573f64859ab99112ddc9a2f 100644 --- a/LArCalorimeter/LArCafJobs/python/LArSCDumperFlags.py +++ b/LArCalorimeter/LArCafJobs/python/LArSCDumperFlags.py @@ -6,6 +6,7 @@ def addSCDumpFlags(flags): flags.addFlag("LArSCDump.digitsKey","SC") flags.addFlag("LArSCDump.nSamples",32) + flags.addFlag("LArSCDump.nEt",3) flags.addFlag("LArSCDump.doSamples",True) flags.addFlag("LArSCDump.doSamplesBas",False) flags.addFlag("LArSCDump.doEt",False) @@ -20,7 +21,4 @@ def addSCDumpFlags(flags): flags.addFlag("LArSCDump.expandId",False) flags.addFlag("LArSCDump.overwriteEvN",False) flags.addFlag("LArSCDump.outputNtup","SCDigits.root") - - - - + flags.addFlag("LArSCDump.doRawChan",False) diff --git a/LArCalorimeter/LArCafJobs/python/LArSCDumperSkeleton.py b/LArCalorimeter/LArCafJobs/python/LArSCDumperSkeleton.py index 17f1832c86889f56633abb26e96feddcb722b6b1..c5ffe8d71346224515e1f124be7e407462b7d715 100644 --- a/LArCalorimeter/LArCafJobs/python/LArSCDumperSkeleton.py +++ b/LArCalorimeter/LArCafJobs/python/LArSCDumperSkeleton.py @@ -1,6 +1,7 @@ # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration import sys +import os from PyJobTransforms.CommonRunArgsToFlags import commonRunArgsToFlags from PyJobTransforms.TransformUtils import processPreExec, processPreInclude, processPostExec, processPostInclude @@ -22,20 +23,38 @@ def fromRunArgs(runArgs): ConfigFlags.Input.Files=runArgs.inputBSFile ConfigFlags.LArSCDump.outputNtup=runArgs.outputNTUP_SCMONFile + # real geom not working yet + ConfigFlags.LArSCDump.doGeom=False + # this should be later deduced from SCRunLog ConfigFlags.LArSCDump.doEt=True ConfigFlags.LArSCDump.nSamples=5 - CKeys=["SC_ET"] + ConfigFlags.LArSCDump.nEt=1 + ConfigFlags.LArSCDump.doRawChan=True + ConfigFlags.LArSCDump.digitsKey="" + CKeys=["SC_ET","LArRawChannels"] ConfigFlags.lock() cfg=MainServicesCfg(ConfigFlags) + from LArGeoAlgsNV.LArGMConfig import LArGMCfg + cfg.merge(LArGMCfg(ConfigFlags)) + + if ConfigFlags.LArSCDump.doBC: + # FIXME should be SC version + from LArBadChannelTool.LArBadChannelConfig import LArBadFebCfg, LArBadChannelCfg + cfg.merge(LArBadChannelCfg(ConfigFlags)) + cfg.merge(LArBadFebCfg(ConfigFlags)) + cfg.merge(LArSC2NtupleCfg(ConfigFlags, AddBadChannelInfo=ConfigFlags.LArSCDump.doBC, AddFEBTempInfo=False, isSC=True, isFlat=False, OffId=ConfigFlags.LArSCDump.doOfflineId, AddHash=ConfigFlags.LArSCDump.doHash, AddCalib=ConfigFlags.LArSCDump.doCalib, RealGeometry=ConfigFlags.LArSCDump.doGeom, ExpandId=ConfigFlags.LArSCDump.expandId, # from LArCond2NtupleBase NSamples=ConfigFlags.LArSCDump.nSamples, FTlist={}, FillBCID=ConfigFlags.LArSCDump.doBCID, ContainerKey=ConfigFlags.LArSCDump.digitsKey, # from LArDigits2Ntuple - SCContainerKeys=CKeys, OverwriteEventNumber = ConfigFlags.LArSCDump.overwriteEvN, # from LArSC2Ntuple - OutputLevel=4)) + SCContainerKeys=CKeys, OverwriteEventNumber = ConfigFlags.LArSCDump.overwriteEvN, Net=ConfigFlags.LArSCDump.nEt, # from LArSC2Ntuple + FillRODEnergy = ConfigFlags.LArSCDump.doRawChan, + OutputLevel=3)) + if os.path.exists(ConfigFlags.LArSCDump.outputNtup): + os.remove(ConfigFlags.LArSCDump.outputNtup) from AthenaConfiguration.ComponentFactory import CompFactory cfg.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+ConfigFlags.LArSCDump.outputNtup+"' OPT='NEW'" ])) cfg.setAppProperty("HistogramPersistency","ROOT") @@ -43,6 +62,10 @@ def fromRunArgs(runArgs): processPostInclude(runArgs, ConfigFlags, cfg) processPostExec(runArgs, ConfigFlags, cfg) + #example how to dump the stores + #cfg.getService("StoreGateSvc").Dump=True + #from AthenaCommon.Constants import DEBUG + #cfg.getService("StoreGateSvc").OutputLevel=DEBUG # Run the final accumulator sc = cfg.run() sys.exit(not sc.isSuccess()) diff --git a/LArCalorimeter/LArCafJobs/python/LArShapeDumperConfig.py b/LArCalorimeter/LArCafJobs/python/LArShapeDumperConfig.py index 6044e65768ca91cd8ca15c2e3d1148ccb1481247..819be42ee7480aeca9dcfa159e51721e1658c5dc 100644 --- a/LArCalorimeter/LArCafJobs/python/LArShapeDumperConfig.py +++ b/LArCalorimeter/LArCafJobs/python/LArShapeDumperConfig.py @@ -99,6 +99,8 @@ if __name__=="__main__": ConfigFlags.Input.Files=defaultTestFiles.RAW ConfigFlags.LAr.ROD.forceIter=True + ConfigFlags.lock() + from AthenaConfiguration.MainServicesConfig import MainServicesCfg cfg=MainServicesCfg(ConfigFlags) diff --git a/LArCalorimeter/LArCafJobs/share/skeleton.LArNoise_fromraw.py b/LArCalorimeter/LArCafJobs/share/skeleton.LArNoise_fromraw.py index 453f01d8e8e4a9266e918b8e44ff82c998d8e867..ad157e7167d2bc10c21f8e8a911682b7fe5acadb 100644 --- a/LArCalorimeter/LArCafJobs/share/skeleton.LArNoise_fromraw.py +++ b/LArCalorimeter/LArCafJobs/share/skeleton.LArNoise_fromraw.py @@ -100,8 +100,8 @@ include("LArConditionsCommon/LArConditionsCommon_comm_jobOptions.py") if not hasattr(runArgs,"conditionsTag") or runArgs.conditionsTag=="CURRENT": printfunc ("Resolving 'CURRENT' express conditions tag ...") - sys.path.append('/afs/cern.ch/user/a/atlcond/utils/python/') - from AtlCoolBKLib import resolveAlias + sys.path.append('/afs/cern.ch/user/a/atlcond/utils22/') + from CondUtilsLib.AtlCoolBKLib import resolveAlias resolver=resolveAlias() currentGlobalES=resolver.getCurrentES().replace("*","ST") printfunc ("Found ",currentGlobalES) diff --git a/LArCalorimeter/LArCafJobs/src/LArShapeDumper.cxx b/LArCalorimeter/LArCafJobs/src/LArShapeDumper.cxx index 6ffcc1c3a2e3123bafc0d83f61a144b6ab1fc07a..147a2bf41a0decbcdba9060d2c44762aeab59d92 100755 --- a/LArCalorimeter/LArCafJobs/src/LArShapeDumper.cxx +++ b/LArCalorimeter/LArCafJobs/src/LArShapeDumper.cxx @@ -301,7 +301,11 @@ StatusCode LArShapeDumper::execute() const LArOFIterResultsContainer* ofIterResult = 0; if (m_doOFCIter) { - ATH_CHECK( evtStore()->retrieve(ofIterResult, "LArOFIterResult") ); + if (evtStore()->contains<LArOFIterResultsContainer> ("LArOFIterResult")) { + ATH_CHECK( evtStore()->retrieve(ofIterResult, "LArOFIterResult") ); + } else { + ATH_MSG_WARNING("Do not have LArOFIterResult in this event"); + } } const LArFebErrorSummary* larFebErrorSummary = 0; @@ -338,15 +342,15 @@ StatusCode LArShapeDumper::execute() } std::map<HWIdentifier, LArOFIterResultsContainer::const_iterator> ofcResultPosition; - if (m_doOFCIter) + if (m_doOFCIter && ofIterResult) { for (LArOFIterResultsContainer::const_iterator ofResult = ofIterResult->begin(); ofResult != ofIterResult->end(); ++ofResult) ofcResultPosition[ofResult->getChannelID()] = ofResult; - ATH_MSG_INFO ( "njpbSizes : " << larDigitContainer->size() + ATH_MSG_INFO ( "njpbSizes : " << larDigitContainer->size() << " " << (ofIterResult ? ofIterResult->size() : 0) << " " << rawChannelContainer->size() << " " << channelsToKeep.size() ); - + } SG::ReadCondHandle<CaloNoise> noiseHdl{m_noiseCDOKey}; const CaloNoise* noiseCDO=*noiseHdl; diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArSC2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArSC2Ntuple.h index 18ab92a45b1c58b4bd5d874be2284a5c61c60c35..b08031754722c1ffd286d21afc325b5e04424e31 100644 --- a/LArCalorimeter/LArCalibTools/LArCalibTools/LArSC2Ntuple.h +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArSC2Ntuple.h @@ -6,6 +6,8 @@ #define LARSC2NTUPLE_H #include "LArCalibTools/LArDigits2Ntuple.h" +#include "CaloDetDescr/ICaloSuperCellIDTool.h" +#include "LArRawEvent/LArRawChannelContainer.h" class LArSC2Ntuple : public LArDigits2Ntuple { @@ -16,21 +18,35 @@ class LArSC2Ntuple : public LArDigits2Ntuple // Standard algorithm methods virtual StatusCode initialize() override; virtual StatusCode execute() override; + protected: + + typedef std::map<HWIdentifier, const LArRawChannel*> rawChanMap_t; + void fillRODEnergy(HWIdentifier SCId, rawChanMap_t &rawChanMap, + const LArOnOffIdMapping* cabling, const LArOnOffIdMapping* cablingROD); + private: - long m_sc2event = 0; + long m_event; Gaudi::Property< std::vector<std::string> > m_contKeys{ this, "SCContainerKeys", {},"which containers to dump"}; Gaudi::Property< bool > m_overwriteEventNumber{this, "OverwriteEventNumber", false, "overwrite the event number from EventInfo ?"}; + Gaudi::Property< unsigned int > m_Net{this, "Net", 5, "number of energies to store"}; + Gaudi::Property< bool > m_fillRawChan{this, "FillRODEnergy", false, "Trying to fill corresponding cells energies"}; + + SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKeyAdditional{this,"CablingKeyAdditional","LArOnOffIdMap","SG Key of LArOnOffIdMapping object for standard cells"}; + ToolHandle<ICaloSuperCellIDTool> m_scidtool{this, "CaloSuperCellIDTool", "CaloSuperCellIDTool", "Offline / SuperCell ID mapping tool"}; + NTuple::Item<short> m_ELVL1Id; NTuple::Item<short> m_latomeChannel; - NTuple::Item<float> m_raw_energy; + NTuple::Array<float> m_ROD_energy; // From LATOME header NTuple::Item<uint16_t> m_bcidLATOMEHEAD; - NTuple::Item<uint32_t> m_latomeidLATOMEHEAD; NTuple::Item<uint32_t> m_l1idLATOMEHEAD; + + NTuple::Item<uint32_t> m_ntNet; + // DigitContainer NTuple::Array<unsigned short> m_bcidVec; NTuple::Item<uint32_t> m_latomeSourceId; @@ -45,7 +61,6 @@ class LArSC2Ntuple : public LArDigits2Ntuple NTuple::Array<unsigned short> m_bcidVec_ET_ID; NTuple::Array<bool> m_saturVec_ET_ID; - bool m_hasRawChan = false; }; #endif diff --git a/LArCalorimeter/LArCalibTools/share/LArDigits2Ntuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArDigits2Ntuple_jobOptions.py index ad131132a3837a0947efd6d3295acf5a976198fa..d255dea1465a56d1edc9e13871084d15d6e6800d 100755 --- a/LArCalorimeter/LArCalibTools/share/LArDigits2Ntuple_jobOptions.py +++ b/LArCalorimeter/LArCalibTools/share/LArDigits2Ntuple_jobOptions.py @@ -53,6 +53,7 @@ if not 'FullFileName' in dir(): else: Trigger = "calibration_"+"*" + from LArCalibProcessing.GetInputFiles import GetInputFilesFromTokens,GetInputFiles FullFileName = [] for RunNumber in RunNumberList : FullFileName+=GetInputFilesFromTokens(InputDir,int(RunNumber),FilePrefix,Trigger) @@ -223,18 +224,7 @@ from LArCalibTools.LArCalibToolsConf import LArDigits2Ntuple LArDigits2Ntuple=LArDigits2Ntuple("LArDigits2Ntuple") contkeys = GainList -if 'rawChannels' not in dir(): - rawChannels = False -if rawChannels is True: - contkeys.append("LArRawChannels") - - -if SuperCells and SCDecodeAllContainers: - contkeys.append("SC_ADC_BAS") - contkeys.append("SC_ET") - contkeys.append("SC_ET_ID") - contkeys.append("SC_LATOME_HEADER") -LArDigits2Ntuple.ContainerKeys = contkeys +LArDigits2Ntuple.ContainerKey = contkeys[0] LArDigits2Ntuple.AddFEBTempInfo=False if 'FTlist' in dir(): LArDigits2Ntuple.FTlist=FTlist diff --git a/LArCalorimeter/LArCalibTools/share/LArPulseShapeRun.py b/LArCalorimeter/LArCalibTools/share/LArPulseShapeRun.py index b27891afa46e99a4ae29a12d6edde676205fd441..5e20879b75abbaf3d3b560dfd973dfbee7591853 100644 --- a/LArCalorimeter/LArCalibTools/share/LArPulseShapeRun.py +++ b/LArCalorimeter/LArCalibTools/share/LArPulseShapeRun.py @@ -71,10 +71,17 @@ theByteStreamAddressProviderSvc.TypeNames += [ "LArDigitContainer/FREE" ] # trigger configuration from AthenaConfiguration.OldFlags2NewFlags import getNewConfigFlags ConfigFlags = getNewConfigFlags() +ConfigFlags.Trigger.readBS = True ConfigFlags.Trigger.doID = False -from TriggerJobOpts.TriggerRecoGetter import TriggerRecoGetter -trig = TriggerRecoGetter() +from TriggerJobOpts.TriggerConfigGetter import TriggerConfigGetter +cfg = TriggerConfigGetter() + +from TriggerJobOpts.Lvl1ResultBuilderGetter import Lvl1ResultBuilderGetter +lvl1 = Lvl1ResultBuilderGetter() + +from TriggerJobOpts.HLTTriggerResultGetter import ByteStreamUnpackGetter +bsu=ByteStreamUnpackGetter() # TDT from AthenaCommon.AppMgr import ToolSvc diff --git a/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx b/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx index 77680aeab711fa65be1f326a8cc845551a2767ce..adf9f2f009539051d9be9c75a8af907dc263316f 100644 --- a/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx +++ b/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx @@ -287,7 +287,7 @@ StatusCode LArCond2NtupleBase::initialize() { bool LArCond2NtupleBase::fillFromIdentifier(const HWIdentifier& hwid) { - ATH_MSG_DEBUG("Starting fillFromIdentifier"); + ATH_MSG_VERBOSE("Starting fillFromIdentifier"); const LArBadChannelCont *bcCont = nullptr; if ( m_addBC ) { SG::ReadCondHandle<LArBadChannelCont> readHandle{m_BCKey}; diff --git a/LArCalorimeter/LArCalibTools/src/LArDigits2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArDigits2Ntuple.cxx index 3f4dd2ca7d8db4b17a9d6aec694922b8dd77468b..8e46d547ee1b9a3b4b92401dc92b66b9d952dc8e 100644 --- a/LArCalorimeter/LArCalibTools/src/LArDigits2Ntuple.cxx +++ b/LArCalorimeter/LArCalibTools/src/LArDigits2Ntuple.cxx @@ -3,6 +3,8 @@ */ #include "LArCalibTools/LArDigits2Ntuple.h" +#include "EventInfo/EventInfo.h" +#include "EventInfo/EventID.h" #include "LArRawEvent/LArDigitContainer.h" #include "Identifier/HWIdentifier.h" #include "LArRawEvent/LArSCDigit.h" @@ -47,6 +49,12 @@ StatusCode LArDigits2Ntuple::initialize() return sc; } + sc = m_nt->addItem("Gain",m_gain,0,4); + if (sc!=StatusCode::SUCCESS) { + ATH_MSG_ERROR( "addItem 'Gain' failed" ); + return sc; + } + if(m_fillBCID){ sc = m_nt->addItem("BCID",m_bcid); if (sc!=StatusCode::SUCCESS) { @@ -63,7 +71,7 @@ StatusCode LArDigits2Ntuple::initialize() } } - ATH_CHECK(m_contKey.initialize() ); + ATH_CHECK(m_contKey.initialize(m_contKey.key().size()) ); ATH_CHECK(m_evtInfoKey.initialize() ); ATH_CHECK(m_LArFebHeaderContainerKey.initialize(!m_isSC) ); @@ -77,6 +85,8 @@ StatusCode LArDigits2Ntuple::initialize() StatusCode LArDigits2Ntuple::execute() { + if(m_contKey.key().empty()) return StatusCode::SUCCESS; + StatusCode sc; ATH_MSG_DEBUG( "LArDigits2Ntuple in execute" ); @@ -115,6 +125,11 @@ StatusCode LArDigits2Ntuple::execute() const LArDigitContainer DigitContainer = *hdlDigit; + if(!hdlDigit.cptr()) { + ATH_MSG_WARNING( "No digits in this event ?"); + return StatusCode::SUCCESS; + } + unsigned cellCounter=0; for( const LArDigit *digi : DigitContainer ){ @@ -122,7 +137,6 @@ StatusCode LArDigits2Ntuple::execute() m_IEvent = thisevent; unsigned int trueMaxSample = digi->nsamples(); - m_ntNsamples = trueMaxSample; if (!m_isSC){ m_gain = digi->gain(); @@ -131,11 +145,18 @@ StatusCode LArDigits2Ntuple::execute() } if(trueMaxSample>m_Nsamples){ if(!m_ipass){ - ATH_MSG_WARNING( "The number of samples in data is larger than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << m_Nsamples << " will be available in the ntuple " ); + ATH_MSG_WARNING( "The number of digi samples in data is larger than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << m_Nsamples << " will be available in the ntuple " ); m_ipass = 1; } trueMaxSample = m_Nsamples; } + else if(trueMaxSample<m_Nsamples){ + if(!m_ipass){ + ATH_MSG_WARNING( "The number of digi samples in data is lower than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << trueMaxSample << " will be available in the ntuple " ); + m_ipass = 1; + } + } + m_ntNsamples = trueMaxSample; fillFromIdentifier(digi->hardwareID()); diff --git a/LArCalorimeter/LArCalibTools/src/LArSC2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArSC2Ntuple.cxx index be49228d1ab64a0607f64addbb54689874e507ad..fc1768ef584c3fee9397478a9fde423dc42a36eb 100644 --- a/LArCalorimeter/LArCalibTools/src/LArSC2Ntuple.cxx +++ b/LArCalorimeter/LArCalibTools/src/LArSC2Ntuple.cxx @@ -4,7 +4,6 @@ #include "LArCalibTools/LArSC2Ntuple.h" #include "LArRawEvent/LArRawSCContainer.h" -#include "LArRawEvent/LArRawChannelContainer.h" #include "LArRawEvent/LArSCDigit.h" #include "LArRawEvent/LArLATOMEHeaderContainer.h" @@ -21,7 +20,10 @@ StatusCode LArSC2Ntuple::initialize() { m_isSC = true; ATH_CHECK( LArDigits2Ntuple::initialize() ); - + ATH_CHECK( m_scidtool.retrieve() ); + + ATH_CHECK( m_cablingKeyAdditional.initialize(m_fillRawChan)); + StatusCode sc=m_nt->addItem("latomeChannel",m_latomeChannel); if (sc.isFailure()) { ATH_MSG_ERROR( "addItem 'latomeChannel' failed" ); @@ -38,15 +40,19 @@ StatusCode LArSC2Ntuple::initialize() { ATH_MSG_ERROR( "addItem 'latomeSourceId' failed" ); return sc; } + sc = m_nt->addItem("Net",m_ntNet); + if (sc.isFailure()) { + ATH_MSG_ERROR( "addItem 'Net' failed" ); + return sc; + } // Loop over container keys for ( const std::string &ck : m_contKeys ){ if ( ck.find("SC") == std::string::npos){ // main readout only - if ( ck == "LArRawChannels" ){ - m_hasRawChan = true; - sc = m_nt->addItem("raw_energy",m_raw_energy); + if ( m_fillRawChan && ck == "LArRawChannels" ){ + sc = m_nt->addItem("ROD_energy", 16, m_ROD_energy); if (sc.isFailure()) { - ATH_MSG_ERROR( "addItem 'raw_energy' failed" ); + ATH_MSG_ERROR( "addItem 'ROD_energy' failed" ); return sc; } } @@ -70,11 +76,7 @@ StatusCode LArSC2Ntuple::initialize() { ATH_MSG_ERROR( "addItem 'bcidLATOMEHEAD' failed" ); return sc; } - sc = m_nt->addItem("latomeidLATOMEHEAD",m_latomeidLATOMEHEAD); - if (sc.isFailure()) { - ATH_MSG_ERROR( "addItem 'latomeidLATOMEHEAD' failed" ); - return sc; - } + sc = m_nt->addItem("l1idLATOMEHEAD",m_l1idLATOMEHEAD); if (sc.isFailure()) { ATH_MSG_ERROR( "addItem 'l1idLATOMEHEAD' failed" ); @@ -82,17 +84,17 @@ StatusCode LArSC2Ntuple::initialize() { } }else if ( ck == "SC_ET" ){ // SC_ET RawSCContainer - sc = m_nt->addItem("energyVec_ET", m_Nsamples, m_energyVec_ET); + sc = m_nt->addItem("energyVec_ET", m_Net, m_energyVec_ET); if (sc.isFailure()) { ATH_MSG_ERROR( "addItem 'energyVec_ET' failed" ); return sc; } - sc = m_nt->addItem("bcidVec_ET", m_Nsamples, m_bcidVec_ET); + sc = m_nt->addItem("bcidVec_ET", m_Net, m_bcidVec_ET); if (sc.isFailure()) { ATH_MSG_ERROR( "addItem 'bcidVec_ET' failed" ); return sc; } - sc = m_nt->addItem("saturVec_ET", m_Nsamples, m_saturVec_ET); + sc = m_nt->addItem("saturVec_ET", m_Net, m_saturVec_ET); if (sc.isFailure()) { ATH_MSG_ERROR( "addItem 'saturVec_ET' failed" ); return sc; @@ -100,17 +102,17 @@ StatusCode LArSC2Ntuple::initialize() { }else if ( ck == "SC_ET_ID" ){ // SC_ET_ID RawSCContainer - sc = m_nt->addItem("energyVec_ET_ID", m_Nsamples, m_energyVec_ET_ID); + sc = m_nt->addItem("energyVec_ET_ID", m_Net, m_energyVec_ET_ID); if (sc.isFailure()) { ATH_MSG_ERROR( "addItem 'energyVec_ET_ID' failed" ); return sc; } - sc = m_nt->addItem("bcidVec_ET_ID", m_Nsamples, m_bcidVec_ET_ID); + sc = m_nt->addItem("bcidVec_ET_ID", m_Net, m_bcidVec_ET_ID); if (sc.isFailure()) { ATH_MSG_ERROR( "addItem 'bcidVec_ET_ID' failed" ); return sc; } - sc = m_nt->addItem("saturVec_ET_ID", m_Nsamples, m_saturVec_ET_ID); + sc = m_nt->addItem("saturVec_ET_ID", m_Net, m_saturVec_ET_ID); if (sc.isFailure()) { ATH_MSG_ERROR( "addItem 'saturVec_ET_ID' failed" ); return sc; @@ -132,7 +134,7 @@ StatusCode LArSC2Ntuple::execute() const EventContext& ctx = Gaudi::Hive::currentContext(); ATH_MSG_DEBUG( "LArSC2Ntuple in execute" ); - m_sc2event++; + m_event++; unsigned long long thisevent = 0; unsigned long thisbcid = 0; @@ -144,14 +146,17 @@ StatusCode LArSC2Ntuple::execute() // /// set it here once and no need to set at each SC/cell bool hasDigitContainer=true; - SG::ReadHandle<LArDigitContainer> hdlDigit(m_contKey, ctx); - if(!hdlDigit.isValid()) { - ATH_MSG_WARNING( "Unable to retrieve LArDigitContainer with key " << m_contKey << " from DetectorStore. " ); - hasDigitContainer=false; - } else - ATH_MSG_DEBUG( "Got LArDigitContainer with key " << m_contKey.key() ); - - const LArDigitContainer DigitContainer = *hdlDigit; + const LArDigitContainer *DigitContainer = nullptr; + if(!m_contKey.key().empty()) { + SG::ReadHandle<LArDigitContainer> hdlDigit(m_contKey, ctx); + if(!hdlDigit.isValid()) { + ATH_MSG_WARNING( "Unable to retrieve LArDigitContainer with key " << m_contKey << " from DetectorStore. " ); + hasDigitContainer=false; + } else { + ATH_MSG_DEBUG( "Got LArDigitContainer with key " << m_contKey.key() ); + DigitContainer = hdlDigit.cptr(); + } + } else hasDigitContainer=false; const LArDigitContainer* DigitContainer_next = nullptr; const LArRawSCContainer* etcontainer = nullptr; @@ -159,7 +164,7 @@ StatusCode LArSC2Ntuple::execute() const LArRawChannelContainer* RawChannelContainer = nullptr; const LArLATOMEHeaderContainer*headcontainer = nullptr; std::map<unsigned int, const LArLATOMEHeader*> LATOMEHeadMap; - std::map<HWIdentifier, const LArRawChannel*> rawChannelMap; + rawChanMap_t rawChannelMap; if ((std::find(m_contKeys.begin(), m_contKeys.end(), "LArRawChannels") != m_contKeys.end()) ){ sc = evtStore()->retrieve(RawChannelContainer,"LArRawChannels"); @@ -185,7 +190,7 @@ StatusCode LArSC2Ntuple::execute() ATH_MSG_WARNING( "Unable to retrieve LArRawSCContainer with key SC_ET from DetectorStore. " ); } else - ATH_MSG_DEBUG( "Got LArDigitContainer with key SC_ET " ); + ATH_MSG_DEBUG( "Got LArRawSCContainer with key SC_ET " ); } if ((std::find(m_contKeys.begin(), m_contKeys.end(), "SC_ET_ID") != m_contKeys.end()) ){ @@ -194,7 +199,7 @@ StatusCode LArSC2Ntuple::execute() ATH_MSG_WARNING( "Unable to retrieve LArRawSCContainer with key SC_ET_ID from DetectorStore. " ); } else - ATH_MSG_DEBUG( "Got LArDigitContainer with key SC_ET_ID" ); + ATH_MSG_DEBUG( "Got LArRawSCContainer with key SC_ET_ID" ); } if ((std::find(m_contKeys.begin(), m_contKeys.end(), "SC_LATOME_HEADER") != m_contKeys.end()) ){ @@ -203,7 +208,7 @@ StatusCode LArSC2Ntuple::execute() ATH_MSG_WARNING( "Unable to retrieve LArLATOMEHeaderContainer with key SC_LATOME_HEADER from DetectorStore. " ); } else - ATH_MSG_DEBUG( "Got LArDigitContainer with key SC_LATOME_HEADER " ); + ATH_MSG_DEBUG( "Got LArLATOMEHeaderContainer with key SC_LATOME_HEADER " ); } if (headcontainer){// loop through header container and fill map @@ -211,11 +216,27 @@ StatusCode LArSC2Ntuple::execute() LATOMEHeadMap.try_emplace ( hit->SourceId(), hit ); } } - if(m_hasRawChan){ + if(m_fillRawChan && RawChannelContainer){ for (const LArRawChannel& raw : *RawChannelContainer) { rawChannelMap.try_emplace( raw.channelID(), &raw ); } } + const LArOnOffIdMapping* cabling=nullptr; + const LArOnOffIdMapping* cablingROD=nullptr; + if(m_fillRawChan){ + SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{cablingKey()}; + cabling=*cablingHdl; + if(!cabling) { + ATH_MSG_ERROR( "Do not have cabling for SC!" ); + return StatusCode::FAILURE; + } + SG::ReadCondHandle<LArOnOffIdMapping> cablingHdlROD{m_cablingKeyAdditional}; + cablingROD=*cablingHdlROD; + if(!cablingROD) { + ATH_MSG_ERROR( "Do not have cabling for ROD!" ); + return StatusCode::FAILURE; + } + } /// set container pointers to nullptr if size is 0 (avoid checking again the size in many places) if( DigitContainer_next && DigitContainer_next->size() == 0 ) DigitContainer_next = nullptr; @@ -225,7 +246,15 @@ StatusCode LArSC2Ntuple::execute() if( etcontainer_next && etcontainer_next->size() == 0 ) etcontainer_next = nullptr; int cellsno = 0; - if (hasDigitContainer && DigitContainer.size() >0) cellsno = DigitContainer.size(); + if (hasDigitContainer) { + if( !DigitContainer->empty() ) cellsno = DigitContainer->size(); + else { + ATH_MSG_WARNING("DigitContainer has zero size, but asked, will be not filled... "); + return StatusCode::SUCCESS; + } + } + ATH_MSG_DEBUG("DigitContainer has size: "<<cellsno); + if (DigitContainer_next){ if ( cellsno == 0 ){ cellsno = DigitContainer_next->size(); @@ -245,13 +274,14 @@ StatusCode LArSC2Ntuple::execute() } } unsigned cellCounter = 0; + ATH_MSG_DEBUG("cellsno size: "<<cellsno); for( int c = 0;c<cellsno;++c ){ if(m_fillBCID) m_bcid = thisbcid; m_IEvent = thisevent; - if(m_overwriteEventNumber) m_IEvent = m_sc2event; + if(m_overwriteEventNumber) m_IEvent = m_event; if( hasDigitContainer ){ - const LArDigit* digi = DigitContainer.at(c); + const LArDigit* digi = DigitContainer->at(c); // ====================== if(m_FTlist.size() > 0) { // should do a selection @@ -261,7 +291,6 @@ StatusCode LArSC2Ntuple::execute() } unsigned int trueMaxSample = digi->nsamples(); - m_ntNsamples = trueMaxSample; if(trueMaxSample>m_Nsamples){ if(!m_ipass){ @@ -270,6 +299,7 @@ StatusCode LArSC2Ntuple::execute() } trueMaxSample = m_Nsamples; } + m_ntNsamples = trueMaxSample; fillFromIdentifier(digi->hardwareID()); @@ -280,28 +310,27 @@ StatusCode LArSC2Ntuple::execute() ATH_MSG_DEBUG(" Can't cast digi to LArSCDigit*"); }else{ if (headcontainer){ + ATH_MSG_DEBUG(" Accessing LATOME header "); const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->SourceId()]; if(headmap){ m_bcidLATOMEHEAD = headmap->BCId(); - m_latomeidLATOMEHEAD = headmap->LatomeId(); m_l1idLATOMEHEAD = headmap->L1Id(); } } m_latomeChannel = scdigi->Channel(); - for( unsigned i = 0; i<scdigi->BCId().size();++i){ - m_bcidVec[i] = scdigi->BCId().at(i); + unsigned int trueMaxBcid = trueMaxSample; + if(trueMaxBcid > scdigi->BCId().size()) trueMaxBcid=scdigi->BCId().size(); + for( unsigned i = 0; i<trueMaxBcid; ++i){ + m_bcidVec[i] = scdigi->BCId().at(i); } m_latomeSourceId = scdigi->SourceId(); } - if( RawChannelContainer ){ - const LArRawChannel* rawchanmap = rawChannelMap[digi->hardwareID()]; - if(rawchanmap){ - m_raw_energy = rawchanmap->energy(); - } + if( m_fillRawChan && RawChannelContainer ){ + fillRODEnergy(digi->hardwareID(), rawChannelMap, cabling, cablingROD); } - } + }//hasDigitContainer @@ -311,69 +340,21 @@ StatusCode LArSC2Ntuple::execute() const LArDigit* digi = DigitContainer_next->at(c); unsigned int trueMaxSample = digi->nsamples(); - m_ntNsamples = trueMaxSample; if(trueMaxSample>m_Nsamples){ if(!m_ipass){ - ATH_MSG_WARNING( "The number of samples in data is larger than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << m_Nsamples << " will be available in the ntuple " ); + ATH_MSG_WARNING( "The number of samples in data BAS is larger than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << m_Nsamples << " will be available in the ntuple " ); m_ipass=1; } trueMaxSample = m_Nsamples; } - - if( !hasDigitContainer){ //// already filled in DigitContainer? - fillFromIdentifier(digi->hardwareID()); - } - - for(unsigned i = 0; i<trueMaxSample;++i) m_samples_ADC_BAS[i] = digi->samples().at(i); - - const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi); - if(!scdigi){ ATH_MSG_DEBUG(" Can't cast digi to LArSCDigit*"); - }else{ - if (headcontainer){ - const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->SourceId()]; - if(headmap){ - m_bcidLATOMEHEAD = headmap->BCId(); - m_latomeidLATOMEHEAD = headmap->LatomeId(); - m_l1idLATOMEHEAD = headmap->L1Id(); - } - } - m_latomeChannel = scdigi->Channel(); - for( unsigned i = 0; i<scdigi->BCId().size();++i){ - m_bcidVec[i] = scdigi->BCId().at(i); - } - m_latomeSourceId = scdigi->SourceId(); - } - - - if( RawChannelContainer ){ - const LArRawChannel* rawchanmap = rawChannelMap[digi->hardwareID()]; - if(rawchanmap){ - m_raw_energy = rawchanmap->energy(); - } - } - } - - - - // DigitContainer 1 -> SC_ADC_BAS - if( DigitContainer_next ){ - - const LArDigit* digi = DigitContainer_next->at(c); - - unsigned int trueMaxSample = digi->nsamples(); m_ntNsamples = trueMaxSample; - - if(trueMaxSample>m_Nsamples){ - if(!m_ipass){ - ATH_MSG_WARNING( "The number of samples in data is larger than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << m_Nsamples << " will be available in the ntuple " ); - m_ipass=1; - } - trueMaxSample = m_Nsamples; - } - if( !hasDigitContainer){ //// already filled in DigitContainer? + if( !hasDigitContainer){ //// already filled in DigitContainer fillFromIdentifier(digi->hardwareID()); + if( m_fillRawChan && RawChannelContainer ){ + fillRODEnergy(digi->hardwareID(), rawChannelMap, cabling, cablingROD); + } } for(unsigned i = 0; i<trueMaxSample;++i) m_samples_ADC_BAS[i] = digi->samples().at(i); @@ -385,7 +366,6 @@ StatusCode LArSC2Ntuple::execute() const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->SourceId()]; if(headmap){ m_bcidLATOMEHEAD = headmap->BCId(); - m_latomeidLATOMEHEAD = headmap->LatomeId(); m_l1idLATOMEHEAD = headmap->L1Id(); } } @@ -395,86 +375,42 @@ StatusCode LArSC2Ntuple::execute() } m_latomeSourceId = scdigi->SourceId(); } - - - if( RawChannelContainer ){ - const LArRawChannel* rawchanmap = rawChannelMap[digi->hardwareID()]; - if(rawchanmap){ - m_raw_energy = rawchanmap->energy(); - } - } } - - // DigitContainer 1 -> SC_ADC_BAS - if( DigitContainer_next ){ - - const LArDigit* digi = DigitContainer_next->at(c); - - unsigned int trueMaxSample = digi->nsamples(); - m_ntNsamples = trueMaxSample; - - if(trueMaxSample>m_Nsamples){ - if(!m_ipass){ - ATH_MSG_WARNING( "The number of samples in data is larger than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << m_Nsamples << " will be available in the ntuple " ); - m_ipass=1; - } - trueMaxSample = m_Nsamples; - } - - if( !hasDigitContainer){ //// already filled in DigitContainer? - fillFromIdentifier(digi->hardwareID()); - } - - for(unsigned i = 0; i<trueMaxSample;++i) m_samples_ADC_BAS[i] = digi->samples().at(i); - - const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi); - if(!scdigi){ ATH_MSG_DEBUG(" Can't cast digi to LArSCDigit*"); - }else{ - if ( !hasDigitContainer){ - if (headcontainer){ - const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->SourceId()]; - if(headmap){ - m_bcidLATOMEHEAD = headmap->BCId(); - m_latomeidLATOMEHEAD = headmap->LatomeId(); - m_l1idLATOMEHEAD = headmap->L1Id(); - } - } - m_latomeChannel = scdigi->Channel(); - m_latomeSourceId = scdigi->SourceId(); - } - - for( unsigned i = 0; i<scdigi->BCId().size();++i){ - m_bcidVec_ADC_BAS[i] = scdigi->BCId().at(i); - } - } - } - // etcontainer -> SC_ET if( etcontainer ){ const LArRawSC*rawSC = etcontainer->at(c); if ( !hasDigitContainer && !DigitContainer_next ){ + fillFromIdentifier(rawSC->hardwareID()); m_latomeChannel = rawSC->chan(); if (headcontainer){ const LArLATOMEHeader*headmap = LATOMEHeadMap[rawSC->SourceId()]; if(headmap){ m_bcidLATOMEHEAD = headmap->BCId(); - m_latomeidLATOMEHEAD = headmap->LatomeId(); m_l1idLATOMEHEAD = headmap->L1Id(); } } + if( m_fillRawChan && RawChannelContainer ){ + fillRODEnergy(rawSC->hardwareID(), rawChannelMap, cabling, cablingROD); + } } - for( unsigned i=0; i<rawSC->bcids().size();++i){ // just use the vector directly? + unsigned int truenet = m_Net; + if(truenet > rawSC->bcids().size()) truenet=rawSC->bcids().size(); + for( unsigned i=0; i<truenet;++i){ // just use the vector directly? m_bcidVec_ET[i] = rawSC->bcids().at(i); } - for( unsigned i=0; i<rawSC->energies().size();++i){ // just use the vector directly? + if(truenet > rawSC->energies().size()) truenet=rawSC->energies().size(); + for( unsigned i=0; i<truenet;++i){ // just use the vector directly? m_energyVec_ET[i] = rawSC->energies().at(i); } - for( unsigned i = 0; i<rawSC->satur().size();++i){ // just use the vector directly? + if(truenet > rawSC->satur().size()) truenet=rawSC->satur().size(); + for( unsigned i = 0; i<truenet;++i){ // just use the vector directly? m_saturVec_ET[i] = rawSC->satur().at(i); } + m_Net=truenet; + m_ntNet=truenet; } // etcontainer_next -> SC_ET_ID @@ -482,15 +418,18 @@ StatusCode LArSC2Ntuple::execute() const LArRawSC*rawSC = etcontainer_next->at(c); if ( !hasDigitContainer && !DigitContainer_next && !etcontainer ){ + fillFromIdentifier(rawSC->hardwareID()); m_latomeChannel = rawSC->chan(); if (headcontainer){ const LArLATOMEHeader*headmap = LATOMEHeadMap[rawSC->SourceId()]; if(headmap){ m_bcidLATOMEHEAD = headmap->BCId(); - m_latomeidLATOMEHEAD = headmap->LatomeId(); m_l1idLATOMEHEAD = headmap->L1Id(); } } + if( m_fillRawChan && RawChannelContainer ){ + fillRODEnergy(rawSC->hardwareID(), rawChannelMap, cabling, cablingROD); + } } for( unsigned i=0; i<rawSC->bcids().size();++i){ // just use the vector directly? m_bcidVec_ET_ID[i] = rawSC->bcids()[i]; @@ -510,7 +449,22 @@ StatusCode LArSC2Ntuple::execute() } cellCounter++; }// over cells - - ATH_MSG_DEBUG( "LArSC2Ntuple has finished." ); + ATH_MSG_DEBUG( "LArSC2Ntuple has finished, filled " << cellCounter << " cells"); return StatusCode::SUCCESS; }// end finalize-method. + +void LArSC2Ntuple::fillRODEnergy(HWIdentifier SCId, rawChanMap_t &rawChanMap, const LArOnOffIdMapping* cabling, const LArOnOffIdMapping* cablingROD) +{ + const Identifier offId = cabling->cnvToIdentifier(SCId); + const std::vector<Identifier> cellIds = m_scidtool->superCellToOfflineID(offId); + std::fill(m_ROD_energy.begin(), m_ROD_energy.end(), 0.); + for(unsigned i=0; i<cellIds.size(); ++i ) { + const HWIdentifier hwcell=cablingROD->createSignalChannelID(cellIds[i]); + if (hwcell.is_valid()) { + m_ROD_energy[i] = rawChanMap[hwcell]->energy(); + } else { + ATH_MSG_WARNING(i<<"-th cell invalid Id"); + } + } + +} diff --git a/LArCalorimeter/LArCnv/LArByteStream/src/LArRodBlockCalibrationV3.cxx b/LArCalorimeter/LArCnv/LArByteStream/src/LArRodBlockCalibrationV3.cxx index 7efb311557b8dae2c05126c8aac45bd1349a0adf..aa59813dfec077e335701a7d24b5bb94364097a6 100644 --- a/LArCalorimeter/LArCnv/LArByteStream/src/LArRodBlockCalibrationV3.cxx +++ b/LArCalorimeter/LArCnv/LArByteStream/src/LArRodBlockCalibrationV3.cxx @@ -134,14 +134,12 @@ int LArRodBlockCalibrationV3::getNextRawData(int& channelNumber, std::vector<sho } gain=RawToOfflineGain(febgain); } - //std::cout << "Gain= " << gain << " Febgain=" << febgain << std::endl; ++m_RawDataCounter; unsigned rearrangeFirstSample=0; if (m_rearrangeFirstSample) rearrangeFirstSample=m_rearrangeFirstSample; //Overwrite by jobOptions else rearrangeFirstSample=getFirstSampleIndex(); - //std::cout << "FebConfig: "<< getFebConfig() << " FirstSampleIndex " << getFirstSampleIndex() <<std::endl; if (rearrangeFirstSample && rearrangeFirstSample<samples.size()) //FIXME: Very ugly hack! See explanation in LArRodDecoder.h file {//Change e.g. 3 0 1 2 4 to 0 1 2 3 4 short movedSample=samples[0]; diff --git a/LArCalorimeter/LArCnv/LArByteStream/src/LArRodBlockPhysicsV6.cxx b/LArCalorimeter/LArCnv/LArByteStream/src/LArRodBlockPhysicsV6.cxx index c9adee0fe8c15a55ac759593cc0e95e7b592f4df..47ba6c8fcf9e3b7c78b22758312d7d63ad131fda 100644 --- a/LArCalorimeter/LArCnv/LArByteStream/src/LArRodBlockPhysicsV6.cxx +++ b/LArCalorimeter/LArCnv/LArByteStream/src/LArRodBlockPhysicsV6.cxx @@ -400,7 +400,7 @@ int LArRodBlockPhysicsV6::getNextRawData(int& channelNumber, std::vector<short>& rearrangeFirstSample=m_rearrangeFirstSample; //Overwrite by jobOptions else rearrangeFirstSample=getFirstSampleIndex(); - //std::cout << "FebConfig: "<< getFebConfig() << " FirstSampleIndex " << getFirstSampleIndex() <<std::endl; + //std::cout << "FebConfig: "<< getFebConfig() << " FirstSampleIndex " << rearrangeFirstSample <<std::endl; if (rearrangeFirstSample && rearrangeFirstSample<samples.size()) //FIXME: Very ugly hack! See explanation in LArRodDecoder.h file {//Change e.g. 3 0 1 2 4 to 0 1 2 3 4 short movedSample=samples[0]; diff --git a/LArCalorimeter/LArExample/LArCalibProcessing/python/LArSC2NtupleConfig.py b/LArCalorimeter/LArExample/LArCalibProcessing/python/LArSC2NtupleConfig.py index 5d75f6a14d744fcb275cc21e6d2f74734d6788f0..c8a4506f08494b8e644dd889d9f278ce681d226e 100644 --- a/LArCalorimeter/LArExample/LArCalibProcessing/python/LArSC2NtupleConfig.py +++ b/LArCalorimeter/LArExample/LArCalibProcessing/python/LArSC2NtupleConfig.py @@ -17,6 +17,12 @@ def LArSC2NtupleCfg(flags, **kwargs): cfg.merge(LArCalibIdMappingSCCfg(flags)) cfg.merge(LArLATOMEMappingCfg(flags)) + if flags.LArSCDump.doRawChan: + from LArByteStream.LArRawDataReadingConfig import LArRawDataReadingCfg + cfg.merge(LArRawDataReadingCfg(flags)) + from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg + cfg.merge(LArOnOffIdMappingCfg(flags)) + alg=CompFactory.LArSC2Ntuple('LArSC2Ntuple',**kwargs) # if debug is needed, uncomment: #from AthenaCommon.Constants import DEBUG