diff --git a/LArCalorimeter/LArCabling/python/LArCablingAccess.py b/LArCalorimeter/LArCabling/python/LArCablingAccess.py index e938bdf6859aa213fb8cedf5b20107f692fcc8fc..45b2abda20c183fbcf3710ab1edacb5adb2ffc90 100644 --- a/LArCalorimeter/LArCabling/python/LArCablingAccess.py +++ b/LArCalorimeter/LArCabling/python/LArCablingAccess.py @@ -30,7 +30,8 @@ def LArOnOffIdMapping(): def LArOnOffIdMappingSC(): condSequence = AthSequencer("AthCondSeq") folder="/LAR/IdentifierOfl/OnOffIdMap_SC" - if hasattr(condSequence,"LArOnOffMappingAlg") and condSequence.LArOnOffMappingAlg.ReadKey==folder: + if hasattr(condSequence,"LArOnOffMappingAlgSC") : + if (condSequence.LArOnOffMappingAlgSC.ReadKey==folder): return #Already there.... #for the moment SC mapping is only in MC database diff --git a/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx b/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx index d1a0dd6499c3dbb86d3dba11e19bcc3a91897985..b1ecc56276a72fe4892595d57641efddd359b548 100644 --- a/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx +++ b/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx @@ -311,12 +311,15 @@ StatusCode LArCond2NtupleBase::initialize() { bool LArCond2NtupleBase::fillFromIdentifier(const HWIdentifier& hwid) { ATH_MSG_DEBUG("Starting fillFromIdentifier"); + const LArBadChannelCont *bcCont = nullptr; + if ( m_addBC ) { SG::ReadCondHandle<LArBadChannelCont> readHandle{m_BCKey}; - const LArBadChannelCont *bcCont {*readHandle}; - if(m_addBC && !bcCont) { + bcCont =*readHandle; + if( !bcCont) { ATH_MSG_WARNING( "Do not have Bad chan container " << m_BCKey.key() ); return false; } + } const LArCalibLineMapping *clCont=0; if(m_isSC){ SG::ReadCondHandle<LArCalibLineMapping> clHdl{m_calibMapSCKey}; diff --git a/LArCalorimeter/LArL1Sim/CMakeLists.txt b/LArCalorimeter/LArL1Sim/CMakeLists.txt index 92691271c225c79f3fa616e075c590b861dfd2f2..3f2a01e08d4a41fcfeb537cc0916cdee79ef924b 100644 --- a/LArCalorimeter/LArL1Sim/CMakeLists.txt +++ b/LArCalorimeter/LArL1Sim/CMakeLists.txt @@ -11,7 +11,7 @@ atlas_add_component( LArL1Sim src/*.cxx src/components/*.cxx INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} AthAllocators AthenaBaseComps GaudiKernel GeoModelInterfaces LArDigitizationLib CaloDetDescrLib CaloEvent CaloIdentifier CaloTriggerToolLib AthenaKernel StoreGateLib EventInfo LArCablingLib LArElecCalib LArIdentifier LArRawEvent LArSimEvent PathResolver ) + LINK_LIBRARIES ${CLHEP_LIBRARIES} AthAllocators AthenaBaseComps GaudiKernel GeoModelInterfaces LArDigitizationLib CaloDetDescrLib CaloEvent CaloIdentifier CaloTriggerToolLib AthenaKernel StoreGateLib EventInfo LArCablingLib LArElecCalib LArIdentifier LArRawEvent LArSimEvent LArRawConditions PathResolver ) # Install files from the package: atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) diff --git a/LArCalorimeter/LArL1Sim/python/LArSCL1Getter.py b/LArCalorimeter/LArL1Sim/python/LArSCL1Getter.py index 235f308732c8b95e13184f06ae6053b5dec7701d..9a4ca63b6b1924a9ea8ee2bd005f04a02eb6e62f 100644 --- a/LArCalorimeter/LArL1Sim/python/LArSCL1Getter.py +++ b/LArCalorimeter/LArL1Sim/python/LArSCL1Getter.py @@ -8,6 +8,19 @@ from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() import traceback +from IOVDbSvc.CondDB import conddb + +def addLArFlatFolder (db, obj, calg, folder_base='/LAR/ElecCalibFlat/',qual=''): + from AthenaCommon.AlgSequence import AthSequencer + condSequence = AthSequencer("AthCondSeq") + + folder = folder_base + obj + if not conddb.folderRequested(folder): + conddb.addFolder(db, folder + qual, + className = 'CondAttrListCollection') + condSequence += calg (ReadKey=folder, WriteKey='LAr'+obj+'SC') + return + class LArSCL1Getter ( Configured ) : @@ -39,19 +52,25 @@ class LArSCL1Getter ( Configured ) : traceback.print_exc() return False - theLArSCL1Maker=LArSCL1Maker() - from AthenaCommon.AppMgr import ToolSvc - from LArRecUtils.LArAutoCorrNoiseSCToolDefault import LArAutoCorrNoiseSCToolDefault - theLArAutoCorrNoiseSCTool = LArAutoCorrNoiseSCToolDefault() - ToolSvc+=theLArAutoCorrNoiseSCTool - theLArSCL1Maker.AutoCorrNoiseTool = theLArAutoCorrNoiseSCTool + from LArCabling.LArCablingAccess import LArOnOffIdMappingSC + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArNoiseSC_ as LArNoiseSCCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArPedestalSC_ as LArPedestalSCFlatCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArShapeSC_ as LArShapeSCCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArfSamplSC_ as LArfSamplSCCondAlg + - from LArRecUtils.LArADC2MeVSCToolDefault import LArADC2MeVSCToolDefault - theLArADC2MeVSCTool = LArADC2MeVSCToolDefault() - ToolSvc+=theLArADC2MeVSCTool - theLArSCL1Maker.ADC2MeVTool = theLArADC2MeVSCTool + LArOnOffIdMappingSC() + addLArFlatFolder ('LAR_OFL', 'Shape', LArShapeSCCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'Pedestal', LArPedestalSCFlatCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'Noise', LArNoiseSCCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'fSampl', LArfSamplSCCondAlg,'/LAR/ElecCalibMCSC/') + from LArRecUtils.LArAutoCorrNoiseSCCondAlgDefault import LArAutoCorrNoiseSCCondAlgDefault + LArAutoCorrNoiseSCCondAlgDefault() + from LArRecUtils.LArADC2MeVSCCondAlgDefault import LArADC2MeVSCCondAlgDefault + LArADC2MeVSCCondAlgDefault() + theLArSCL1Maker=LArSCL1Maker() - theLArSCL1Maker.SCL1ContainerName = "LArDigitSCL1" + theLArSCL1Maker.SCL1ContainerName = "LArDigitSCL2" self._LArSCL1Maker = theLArSCL1Maker @@ -66,26 +85,6 @@ class LArSCL1Getter ( Configured ) : mlog.info("digitmaker1 not found in topSequence, using own map in LArSCL1Maker") return False - # now add algorithm to topSequence - # this should always come at the end - from IOVDbSvc.CondDB import conddb - if ( conddb.isMC and not conddb.folderRequested('/LAR/IdentifierOfl/OnOffIdMap_SC') ) : - conddb.addFolder("LAR_OFL","<tag>LARIdentifierOflOnOffIdMap_SC-000</tag>/LAR/IdentifierOfl/OnOffIdMap_SC") - if ( conddb.isMC and not conddb.folderRequested('/LAR/ElecCalibMCSC/fSampl') ) : - conddb.addFolder("LAR_OFL","<tag>LARElecCalibMCSCfSampl-000</tag>/LAR/ElecCalibMCSC/fSampl") - if ( conddb.isMC and not conddb.folderRequested('/LAR/ElecCalibMCSC/Pedestal') ) : - conddb.addFolder("LAR_OFL","<tag>LARElecCalibMCSCPedestal-000</tag>/LAR/ElecCalibMCSC/Pedestal") - if ( conddb.isMC and not conddb.folderRequested('/LAR/ElecCalibMCSC/Noise') ) : - conddb.addFolder("LAR_OFL","<tag>LARElecCalibMCSCNoise-000</tag>/LAR/ElecCalibMCSC/Noise") - if ( conddb.isMC and not conddb.folderRequested('/LAR/ElecCalibMCSC/Shape') ) : - conddb.addFolder("LAR_OFL","<tag>LARElecCalibMCSCShape-000</tag>/LAR/ElecCalibMCSC/Shape") - - from LArRecUtils.LArRecUtilsConf import LArFlatConditionSvc - from AthenaCommon.AppMgr import ServiceMgr as svcMgr - if not hasattr(svcMgr,"LArFlatConditionSvc"): - svcMgr+=LArFlatConditionSvc() - svcMgr.ProxyProviderSvc.ProviderNames += [ "LArFlatConditionSvc" ] - svcMgr.LArFlatConditionSvc.DoSuperCells=True mlog.info(" now adding to topSequence") topSequence += theLArSCL1Maker diff --git a/LArCalorimeter/LArL1Sim/src/LArSCL1Maker.cxx b/LArCalorimeter/LArL1Sim/src/LArSCL1Maker.cxx index a1eab237b7019fb1820ef580ab7a4a35e61c32a3..5b6c751608d013e2be3422c95fe69a970e4eff7a 100755 --- a/LArCalorimeter/LArL1Sim/src/LArSCL1Maker.cxx +++ b/LArCalorimeter/LArL1Sim/src/LArSCL1Maker.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // +======================================================================+ @@ -12,7 +12,7 @@ // // ........ includes // -#include "LArL1Sim/LArSCL1Maker.h" +#include "LArSCL1Maker.h" // .......... utilities // #include <math.h> @@ -22,8 +22,6 @@ #include "AthenaKernel/IAtRndmGenSvc.h" #include "GaudiKernel/ServiceHandle.h" -#include "LArRawEvent/LArDigit.h" -#include "LArRawEvent/LArDigitContainer.h" #include "LArSimEvent/LArHitContainer.h" #include "LArDigitization/LArHitList.h" @@ -53,13 +51,6 @@ #include "StoreGate/StoreGateSvc.h" #include "PathResolver/PathResolver.h" -#include "LArElecCalib/ILArfSampl.h" -#include "LArElecCalib/ILArShape.h" -#include "LArElecCalib/ILArPedestal.h" -#include "LArElecCalib/ILArNoise.h" -#include "LArElecCalib/ILArAutoCorrNoiseTool.h" -#include "LArElecCalib/ILArADC2MeVTool.h" - // trigger time #include "AthenaKernel/ITriggerTime.h" @@ -70,30 +61,17 @@ using CLHEP::RandGaussZiggurat; LArSCL1Maker::LArSCL1Maker(const std::string& name, ISvcLocator* pSvcLocator) : - AthAlgorithm(name, pSvcLocator) + AthReentrantAlgorithm(name, pSvcLocator) , m_atRndmGenSvc("AtRndmGenSvc",name) , m_rndmEngineName("LArSCL1Maker") , m_rndmEngine(0) - , p_triggerTimeTool() + //, p_triggerTimeTool() , m_scidtool("CaloSuperCellIDTool") , m_scHelper(0) , m_OnlSCHelper(0) , m_incSvc("IncidentSvc",name) - , m_shapes(0), m_fracS(0), m_PedestalSC(0), m_NoiseSC(0) - , m_autoCorrNoiseTool("LArAutoCorrNoiseTool") - , m_adc2mevTool("LArADC2MeVTool") - , m_fSamplKey("LARfSamplSC") - , m_shapesKey("LArShapeSC") - , m_noiseKey("LArNoiseSC") - , m_pedestalKey("LArPedestalSC") , m_sem_mgr(nullptr) -// + -------------------------------------------------------------------- + -// + Author ........: Denis O. Damazio + -// + Creation date .: 18/11/2013 + -// + Subject: SCL1 Maker constructor + -// + -------------------------------------------------------------------- + { - m_first=true; // // ........ default values of private data // @@ -124,17 +102,12 @@ LArSCL1Maker::LArSCL1Maker(const std::string& name, ISvcLocator* pSvcLocator) : declareProperty("SubDetectors",m_SubDetectors); declareProperty("RndmSvc", m_atRndmGenSvc); - declareProperty("AutoCorrNoiseTool",m_autoCorrNoiseTool,"Tool handle for electronic noise covariance"); - declareProperty("ADC2MeVTool",m_adc2mevTool,"Tool handle for ADC2MeV Conversion"); - - - declareProperty("SCL1ContainerName",m_SCL1ContainerName); declareProperty("NoiseOnOff",m_NoiseOnOff); declareProperty("PileUp",m_PileUp); declareProperty("UseTriggerTime",m_useTriggerTime); - declareProperty("TriggerTimeTool",p_triggerTimeTool); + //declareProperty("TriggerTimeTool",p_triggerTimeTool); declareProperty("FirstSample",m_firstSample=-1); declareProperty("NSamples",m_nSamples=7); @@ -187,8 +160,8 @@ StatusCode LArSCL1Maker::initialize() // // ......... print the trigger time flag // - if (m_useTriggerTime) { ATH_MSG_INFO("use Trigger Time service " << p_triggerTimeTool.name()); } - else { ATH_MSG_INFO("no Trigger Time used"); } +// if (m_useTriggerTime) { ATH_MSG_INFO("use Trigger Time service " << p_triggerTimeTool.name()); } +// else { ATH_MSG_INFO("no Trigger Time used"); } // // .........retrieve tool computing trigger time if requested @@ -199,12 +172,14 @@ StatusCode LArSCL1Maker::initialize() m_useTriggerTime = false; } +/* if (m_useTriggerTime) { if( p_triggerTimeTool.retrieve().isFailure() ) { ATH_MSG_ERROR("Unable to retrieve trigger time tool. Disabling Trigger time"); m_useTriggerTime=false; } } +*/ // // ..... need LAr and CaloIdManager to retrieve all needed helpers @@ -231,14 +206,18 @@ StatusCode LArSCL1Maker::initialize() // CHECK( m_cablingKeySC.initialize() ); + CHECK( m_shapesKey.initialize() ); + CHECK( m_fracSKey.initialize() ); + CHECK( m_pedestalSCKey.initialize() ); + CHECK( m_noiseSCKey.initialize() ); + CHECK( m_autoCorrNoiseSCKey.initialize() ); + CHECK( m_adc2mevSCKey.initialize() ); CHECK( m_scidtool.retrieve() ); + CHECK( m_sLArDigitsContainerKey.initialize() ); + CHECK( m_hitMapKey.initialize() ); // Incident Service: - CHECK( m_incSvc.retrieve() ); - //start listening to "BeginRun" - m_incSvc->addListener(this, "BeginRun", m_BeginRunPriority); - ATH_MSG_DEBUG( "Initialization completed successfully" ); CHECK( m_atRndmGenSvc.retrieve() ); @@ -249,9 +228,6 @@ StatusCode LArSCL1Maker::initialize() return StatusCode::FAILURE ; } - CHECK( m_autoCorrNoiseTool.retrieve() ); - CHECK( m_adc2mevTool.retrieve() ); - CHECK( detStore()->retrieve (m_sem_mgr, "CaloSuperCellMgr") ); return StatusCode::SUCCESS; @@ -259,15 +235,7 @@ StatusCode LArSCL1Maker::initialize() } - -void LArSCL1Maker::handle(const Incident& /* inc*/ ) -{ - ATH_MSG_DEBUG("LArSCL1Maker handle()"); - if( this->updateConditions().isFailure()) ATH_MSG_ERROR("Failure in updating Conditions"); - return; -} - -StatusCode LArSCL1Maker::execute() +StatusCode LArSCL1Maker::execute(const EventContext& context) const { @@ -276,49 +244,54 @@ StatusCode LArSCL1Maker::execute() // // ....... fill the LArHitEMap // - SG::ReadHandle<LArHitEMap> hitmap(m_hitMapKey); + SG::ReadHandle<LArHitEMap> hitmap(m_hitMapKey,context); // // .....get the trigger time if requested // - double trigtime=0; + //double trigtime=0; +/* if (m_useTriggerTime && !p_triggerTimeTool.empty()) { trigtime = p_triggerTimeTool->time(); } ATH_MSG_DEBUG("Trigger time used : " << trigtime); +*/ + auto fracS = this->retrieve(context,m_fracSKey); + auto pedestal = this->retrieve(context,m_pedestalSCKey); + auto larnoise = this->retrieve(context,m_noiseSCKey); + auto autoCorrNoise = this->retrieve(context,m_autoCorrNoiseSCKey); + auto adc2mev = this->retrieve(context,m_adc2mevSCKey); - LArDigitContainer *scContainer = new LArDigitContainer(); - if ( scContainer == 0 ) { - ATH_MSG_ERROR("Could not allocate a new LArSCDigitContainer" ); - return StatusCode::FAILURE; - } + + SG::WriteHandle<LArDigitContainer> scContainerHandle( m_sLArDigitsContainerKey, context); + auto scContainer = std::make_unique<LArDigitContainer> (SG::VIEW_ELEMENTS); + + unsigned int nbSC = (unsigned int)m_scHelper->calo_cell_hash_max() ; + scContainer->reserve(nbSC); // .... get SC cabling map // - SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKeySC}; - const LArOnOffIdMapping* cabling = *cablingHdl; + const LArOnOffIdMapping* cabling = this->retrieve(context, m_cablingKeySC); if(!cabling) { ATH_MSG_ERROR("Do not have SC cabling map !!!"); return StatusCode::FAILURE; } - // ...... register the TTL1 containers into the TES - // - CHECK( evtStore()->record( scContainer , m_SCL1ContainerName) ); +/* Disable HIT recording for the moment CaloCellContainer *scHitContainer = 0; if(m_saveHitsContainer.size()>0) { scHitContainer = new CaloCellContainer; ATH_CHECK( evtStore()->record(scHitContainer, m_saveHitsContainer) ); } +*/ // // ... initialise vectors for sums of energy in each TT // - unsigned int nbSC = (unsigned int)m_scHelper->calo_cell_hash_max() ; ATH_MSG_DEBUG("Max number of LAr Super-Cell= " << nbSC); std::vector<std::vector<float> > sumEnergy ; // inner index = time slot (from 0 to visEvecSize-1) @@ -334,7 +307,8 @@ StatusCode LArSCL1Maker::execute() int it = 0; int it_end = hitmap->GetNbCells(); scContainer->reserve( nbSC ); //container ordered by hash - scFloatContainerTmp.assign( nbSC, std::vector<float>(0) ); //container ordered by hash + const std::vector<float> base_vec(0); + scFloatContainerTmp.assign( nbSC, base_vec ); //container ordered by hash std::vector<bool> alreadyThere; alreadyThere.resize( nbSC ); alreadyThere.assign( nbSC, false ); @@ -367,31 +341,27 @@ StatusCode LArSCL1Maker::execute() HWIdentifier hwSC = cabling->createSignalChannelID(scId); IdentifierHash scHWHash = m_OnlSCHelper->channel_Hash(hwSC); - if(m_saveHitsContainer.size()>0) { - for(auto itr = timeE.begin(); itr!= timeE.end(); ++itr) { - if(fabs(itr->second) > 12.5) continue; //out of time energy deposit - truthE[scHWHash] += itr->first/m_fracS->FSAMPL(hwSC); - } - } - hwid[scHWHash] = hwSC; float factor = 1.0; - if ( m_first ) { - printConditions(hwSC); + if ( (adc2mev->ADC2MEV(hwSC,scGain)).size() < 2 ) { + continue; } - factor = (m_adc2mevTool->ADC2MEV(hwSC,(CaloGain::CaloGain)1))[1] ; - factor = 1.0/m_fracS->FSAMPL(hwSC)/factor; + factor = (adc2mev->ADC2MEV(hwSC,scGain))[1] ; + factor = 1.0/fracS->FSAMPL(hwSC)/factor; + + ConvertHits2Samples(context,hwSC, scGain, timeE, samples); - ConvertHits2Samples(hwSC, scGain, timeE, samples); std::vector< float >& vec = scFloatContainerTmp.at(scHWHash); if ( !alreadyThere[scHWHash] ){ alreadyThere[scHWHash]=true; - for(unsigned int i=0; i< samples.size(); i++) + for(unsigned int i=0; i< samples.size(); i++){ vec.push_back( factor * samples[i] ); + } } else { - for(unsigned int i=0; i< samples.size(); i++) + for(unsigned int i=0; i< samples.size(); i++){ vec[i]+= ( factor * samples[i] ); + } } } } // it end @@ -410,29 +380,17 @@ StatusCode LArSCL1Maker::execute() else { cc++; } std::vector<float>& vec = *vecPtr; - HWIdentifier id = hwid[it]; + const HWIdentifier id = hwid[it]; if ( id == 0 ) { dd++; continue; } - - - //record the truth hit information - if(m_saveHitsContainer.size()>0) { - Identifier soft_id = cabling->cnvToIdentifier(id); - IdentifierHash idhash = m_sem_mgr->getCaloCell_ID()->calo_cell_hash(soft_id); - const CaloDetDescrElement* dde = m_sem_mgr->get_element(idhash); - CaloGain::CaloGain gain = (CaloGain::CaloGain)1; - - CaloCell* cell = new CaloCell( dde, (float)truthE[it], 0, (uint16_t)0, (uint16_t)0, gain ); - scHitContainer->push_back(cell); - } // reset noise noise.assign(m_nSamples,0); // noise definition if ( m_NoiseOnOff ) { - float SigmaNoise = (m_NoiseSC->noise(id,0)); + float SigmaNoise = (larnoise->noise(id,0)); int index; - const std::vector<float>* CorrGen = &(m_autoCorrNoiseTool->autoCorrSqrt(id,0,m_nSamples)); + const std::vector<float>& CorrGen = (autoCorrNoise->autoCorrSqrt(id,0)); RandGaussZiggurat::shootArray(m_rndmEngine,m_nSamples,Rndm,0.,1.); @@ -440,13 +398,13 @@ StatusCode LArSCL1Maker::execute() noise[i]=0.; for(int j=0;j<=i;j++){ index = i* m_nSamples + j; - noise[i] += Rndm[j] * (*CorrGen)[index]; + noise[i] += Rndm[j] * (CorrGen)[index]; } noise[i]=noise[i]*SigmaNoise; } } - int ped = m_PedestalSC->pedestal(id,0); + int ped = pedestal->pedestal(id,0); samplesInt.assign( m_nSamples, 0 ); for(unsigned int i=0; i< vec.size(); i++) { samplesInt[i]=rint(vec[i]+ped+noise[i]); @@ -457,6 +415,8 @@ StatusCode LArSCL1Maker::execute() scContainer->push_back(dig); } + // record final output container + ATH_CHECK( scContainerHandle.record( std::move(scContainer) ) ); if(m_chronoTest) { m_chronSvc->chronoStop( "LArSCL1Mk hit loop " ); @@ -464,7 +424,6 @@ StatusCode LArSCL1Maker::execute() m_chronSvc->chronoStart( "LArSCL1Mk SC loop " ); } - m_first = false; return StatusCode::SUCCESS; } @@ -480,56 +439,12 @@ StatusCode LArSCL1Maker::finalize() } - - -StatusCode LArSCL1Maker::updateConditions(){ - - ATH_MSG_DEBUG( "Updating conditions" ); - - CHECK( detStore()->retrieve(m_fracS,m_fSamplKey) ); - CHECK( detStore()->retrieve(m_shapes,m_shapesKey) ); - CHECK( detStore()->retrieve(m_NoiseSC,m_noiseKey) ); - CHECK( detStore()->retrieve(m_PedestalSC,m_pedestalKey) ); - - return StatusCode::SUCCESS; - -} - -void LArSCL1Maker::printConditions(const HWIdentifier& hwSC){ - - ATH_MSG_VERBOSE("HW Identifier : " << hwSC.get_identifier32().get_compact() ); - if ( m_shapes ) { - ILArShape::ShapeRef_t shape = m_shapes->Shape(hwSC,0); - ILArShape::ShapeRef_t shapeder = m_shapes->ShapeDer(hwSC,0); - ATH_MSG_VERBOSE( "shape0.size() : " << shape.size() ); - for(unsigned int i=0;i<shape.size();i++) - ATH_MSG_VERBOSE("shape[" << i << "]=" << shape[i] << " - " << shapeder[i] << "; "); - } - if ( m_fracS ) { - ATH_MSG_VERBOSE("fSample : " << m_fracS->FSAMPL(hwSC) ); - } - if ( m_adc2mevTool ) { - ATH_MSG_VERBOSE("Ramp (gain0) : " << (m_adc2mevTool->ADC2MEV(hwSC,(CaloGain::CaloGain)0))[1] ); - ATH_MSG_VERBOSE("Ramp (gain1) : " << (m_adc2mevTool->ADC2MEV(hwSC,(CaloGain::CaloGain)1))[1] ); - ATH_MSG_VERBOSE("Ramp (gain2) : " << (m_adc2mevTool->ADC2MEV(hwSC,(CaloGain::CaloGain)2))[1] ); - } - if ( m_PedestalSC ) { - ATH_MSG_VERBOSE("Pedestal : " << m_PedestalSC->pedestal(hwSC,0) ); - } - if ( m_NoiseSC ) { - ATH_MSG_VERBOSE("Noise : " << m_NoiseSC->noise(hwSC,0) ); - } - if ( m_autoCorrNoiseTool ) { - const std::vector<float>* CorrGen = &(m_autoCorrNoiseTool->autoCorrSqrt(hwSC,0,m_nSamples)); - std::stringstream ss; ss << "Auto : "; - for(size_t ii=0;ii<m_nSamples;++ii) ss << CorrGen->at(ii) << " "; - ATH_MSG_VERBOSE(ss.str()) ; - - } +void LArSCL1Maker::printConditions(const HWIdentifier& /*hwSC*/){ + // will keep it for future implementation } -void LArSCL1Maker::ConvertHits2Samples(const HWIdentifier & hwSC, CaloGain::CaloGain igain, - const std::vector<std::pair<float,float> >& TimeE, std::vector<float>& samples) +void LArSCL1Maker::ConvertHits2Samples(const EventContext& context, const HWIdentifier & hwSC, CaloGain::CaloGain igain, + const std::vector<std::pair<float,float> >& TimeE, std::vector<float>& samples) const { // Converts hits of a particular LAr cell into energy samples // declarations @@ -543,8 +458,9 @@ void LArSCL1Maker::ConvertHits2Samples(const HWIdentifier & hwSC, CaloGain::Calo // ........ retrieve data (1/2) ................................ // - ILArShape::ShapeRef_t Shape = m_shapes->Shape(hwSC,igain); - ILArShape::ShapeRef_t ShapeDer = m_shapes->ShapeDer(hwSC,igain); + auto shapes = this->retrieve(context,m_shapesKey); + ILArShape::ShapeRef_t Shape = shapes->Shape(hwSC,igain); + ILArShape::ShapeRef_t ShapeDer = shapes->ShapeDer(hwSC,igain); nsamples = Shape.size(); nsamples_der = ShapeDer.size(); diff --git a/LArCalorimeter/LArL1Sim/LArL1Sim/LArSCL1Maker.h b/LArCalorimeter/LArL1Sim/src/LArSCL1Maker.h similarity index 70% rename from LArCalorimeter/LArL1Sim/LArL1Sim/LArSCL1Maker.h rename to LArCalorimeter/LArL1Sim/src/LArSCL1Maker.h index ae48f24264aa9a2604e4aae8d6f030545562798a..9dabade38251fbec7f87d165fe529c3f93c7e133 100644 --- a/LArCalorimeter/LArL1Sim/LArL1Sim/LArSCL1Maker.h +++ b/LArCalorimeter/LArL1Sim/src/LArSCL1Maker.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef LARL1SIM_LARSCL1MAKER_H @@ -15,17 +15,24 @@ // ....... include // -#include "AthenaBaseComps/AthAlgorithm.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" #include "Gaudi/Property.h" #include "GaudiKernel/ServiceHandle.h" #include "LArDigitization/LArHitEMap.h" -#include "LArElecCalib/ILArAutoCorrNoiseTool.h" -#include "LArElecCalib/ILArADC2MeVTool.h" +#include "LArRawConditions/LArAutoCorrNoise.h" +#include "LArRawConditions/LArADC2MeV.h" #include "CaloDetDescr/ICaloSuperCellIDTool.h" #include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/ReadHandleKey.h" +#include "StoreGate/WriteHandleKey.h" #include "LArCabling/LArOnOffIdMapping.h" +#include "LArRawEvent/LArDigitContainer.h" +#include "LArElecCalib/ILArfSampl.h" +#include "LArElecCalib/ILArShape.h" +#include "LArElecCalib/ILArPedestal.h" +#include "LArElecCalib/ILArNoise.h" class IAtRndmGenSvc; @@ -33,10 +40,6 @@ class ITriggerTime; class CaloCell_SuperCell_ID; class CaloCell_ID; class LArOnline_SuperCellID; -class ILArShape; -class ILArfSampl; -class ILArPedestal; -class ILArNoise; class CaloSuperCellDetDescrManager; @@ -57,8 +60,7 @@ namespace CLHEP @author Denis O. Damazio (BNL) */ -class LArSCL1Maker : public AthAlgorithm, - public IIncidentListener +class LArSCL1Maker : public AthReentrantAlgorithm { // // >>>>>>>> public methods @@ -73,19 +75,50 @@ class LArSCL1Maker : public AthAlgorithm, // ..... Gaudi algorithm hooks // /** Read ascii files for auxiliary data (puslse shapes, noise, etc...) */ - virtual StatusCode initialize(); + StatusCode initialize(); /** Create LArSCL1 object save in TES (2 containers: 1 EM, 1 hadronic) */ - virtual StatusCode execute(); + StatusCode execute(const EventContext& context) const; - virtual StatusCode finalize(); - virtual void handle(const Incident&); + StatusCode finalize(); private: SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKeySC{this,"ScCablingKey","LArOnOffIdMapSC","SG Key of SC LArOnOffIdMapping object"}; + /// Property: Pulse shape (conditions input). + SG::ReadCondHandleKey<ILArShape> m_shapesKey + {this, "ShapeKey", "LArShapeSC", "SG Key of Shape conditions object"}; + + /// Property: Fraction of Energy Sampled (conditions input). + SG::ReadCondHandleKey<ILArfSampl> m_fracSKey + {this, "FracSKey", "LArfSamplSC", "SG Key of fSamplS conditions object"}; + + /// Property: Pedestal offset (conditions input). + SG::ReadCondHandleKey<ILArPedestal> m_pedestalSCKey + {this, "PedestalKey", "LArPedestalSC", "SGKey of LArPedestal object"}; + + /// Property: Electronics Noise (conditions input). + SG::ReadCondHandleKey<ILArNoise> m_noiseSCKey + {this, "LArNoiseKey", "LArNoiseSC", "SGKey of LArNoise object"}; + + /// Property: AutoCorr Noise (conditions input). + SG::ReadCondHandleKey<LArAutoCorrNoise> m_autoCorrNoiseSCKey + {this, "LArAutoCorrKey", "LArAutoCorrNoiseSC", "SGKey of LArAutoCorrNoise object"}; + + /// Property: ADC2MeV conversion (conditions input). + SG::ReadCondHandleKey<LArADC2MeV> m_adc2mevSCKey + {this, "LArADC2MeVKey", "LArADC2MeVSC", "SGKey of LArADC2MeV object"}; + + template <class T> + const T* retrieve(const EventContext& context, SG::ReadCondHandleKey<T> handleKey) const { + SG::ReadCondHandle<T> handle( handleKey, context); + if ( not handle.isValid() ) { + ATH_MSG_ERROR("could not retrieve : " << handle.key() ); + return nullptr; + } else return handle.cptr(); + } // // >>>>>>>> private algorithm parts @@ -100,18 +133,14 @@ class LArSCL1Maker : public AthAlgorithm, std::vector<float>& inputV) ; - - /** Method to update all conditions */ - StatusCode updateConditions(); - /** Method to print SuperCell Conditions */ void printConditions(const HWIdentifier& hwSC); /** Method for converting Hits from samples (simplified version * of the same method in LarPileUpTool) */ - void ConvertHits2Samples(const HWIdentifier & hwSC, CaloGain::CaloGain igain, + void ConvertHits2Samples(const EventContext& context, const HWIdentifier & hwSC, CaloGain::CaloGain igain, const std::vector<std::pair<float,float> >& TimeE, - std::vector<float>& samples); + std::vector<float>& samples) const; // // >>>>>>>> private data parts @@ -126,7 +155,7 @@ class LArSCL1Maker : public AthAlgorithm, /** Alorithm property: use trigger time or not*/ bool m_useTriggerTime; /** pointer to the TriggerTimeTool */ - ToolHandle<ITriggerTime> p_triggerTimeTool; + //ToolHandle<ITriggerTime> p_triggerTimeTool; int m_BeginRunPriority; @@ -159,6 +188,8 @@ class LArSCL1Maker : public AthAlgorithm, /** hit map */ SG::ReadHandleKey<LArHitEMap> m_hitMapKey{this,"LArHitEMapKey","LArHitEMap"}; + /** output Lar Digits SC container */ + SG::WriteHandleKey<LArDigitContainer> m_sLArDigitsContainerKey {this, "SCL1ContainerName","LArDigitSCL1","Output LArDigit container"}; /** list of hit containers */ @@ -192,33 +223,10 @@ class LArSCL1Maker : public AthAlgorithm, /** algorithm property: switch chrono on */ bool m_chronoTest; -/** Conditions (shape) of SuperCell */ - const ILArShape* m_shapes; -/** Conditions (fSamples) of SuperCell */ - const ILArfSampl* m_fracS; -/** Conditions (LArPedestalSC) of SuperCell */ - const ILArPedestal* m_PedestalSC; -/** Conditions (LArNoiseSC) of SuperCell */ - const ILArNoise* m_NoiseSC; -/** Special Tool for AutoCorrelation sqrt */ - ToolHandle<ILArAutoCorrNoiseTool> m_autoCorrNoiseTool; -/** Special Tool for AutoCorrelation sqrt */ - ToolHandle<ILArADC2MeVTool> m_adc2mevTool; -/** key for fSampl conditions */ - std::string m_fSamplKey; -/** key for Shape conditions */ - std::string m_shapesKey; -/** key for Noise conditions */ - std::string m_noiseKey; -/** key for Pedestal conditions */ - std::string m_pedestalKey; - /** output number of samples */ unsigned int m_nSamples; /** output first samples */ unsigned int m_firstSample; - /** m_first */ - bool m_first; std::string m_saveHitsContainer; diff --git a/LArCalorimeter/LArL1Sim/src/components/LArL1Sim_entries.cxx b/LArCalorimeter/LArL1Sim/src/components/LArL1Sim_entries.cxx index 29d1a86c23f19c6be113c18f0fce8a42c0c3f9a2..012e02e534c5b8a407be35969af4a7bd40f99b6b 100644 --- a/LArCalorimeter/LArL1Sim/src/components/LArL1Sim_entries.cxx +++ b/LArCalorimeter/LArL1Sim/src/components/LArL1Sim_entries.cxx @@ -1,5 +1,5 @@ #include "LArL1Sim/LArTTL1Maker.h" -#include "LArL1Sim/LArSCL1Maker.h" +#include "../LArSCL1Maker.h" #include "LArL1Sim/LArTTL1Calib.h" DECLARE_COMPONENT( LArTTL1Maker ) diff --git a/LArCalorimeter/LArROD/LArROD/LArRawChannelBuilderAlg.h b/LArCalorimeter/LArROD/LArROD/LArRawChannelBuilderAlg.h index 110d90c70253b374b6145467fd00c727d5c74b88..b726e8d1078831848f5d94ea16aa7aae24a3d7ec 100644 --- a/LArCalorimeter/LArROD/LArROD/LArRawChannelBuilderAlg.h +++ b/LArCalorimeter/LArROD/LArROD/LArRawChannelBuilderAlg.h @@ -23,8 +23,10 @@ //Event classes class LArDigitContainer; class LArRawChannelContainer; +class CaloCellContainer; +class CaloSuperCellDetDescrManager; -class LArOnlineID; +class LArOnlineID_Base; class LArRawChannelBuilderAlg : public AthReentrantAlgorithm { @@ -42,7 +44,9 @@ class LArRawChannelBuilderAlg : public AthReentrantAlgorithm { "SG Key of LArDigitContaiiner"}; //Event output: SG::WriteHandleKey<LArRawChannelContainer> m_rawChannelKey{this,"LArRawChannelKey","LArRawChannels", - "SG key of the LArRawChannelContainer"}; + "SG key of the output LArRawChannelContainer"}; + SG::WriteHandleKey<CaloCellContainer> m_cellKey{this,"CaloCellKey","SCellnoBCID", + "SG key of the output CaloCellContainer"}; //Conditions input: SG::ReadCondHandleKey<ILArPedestal> m_pedestalKey{this,"PedestalKey","LArPedestal","SG Key of Pedestal conditions object"}; @@ -67,10 +71,15 @@ class LArRawChannelBuilderAlg : public AthReentrantAlgorithm { //The following matters only in the MC case, when we have a 32 sample shapes Gaudi::Property<int> m_firstSample{this,"firstSample",0,"first of the 32 sampels of the MC shape to be used"}; + // Use the code for SuperCells + Gaudi::Property<bool> m_isSC{this,"IsSuperCell",false,"code should produce SuperCells"}; //Identifier helper - const LArOnlineID* m_onlineId; + const LArOnlineID_Base* m_onlineId; + + /// Geometry manager. + const CaloSuperCellDetDescrManager* m_sem_mgr; }; diff --git a/LArCalorimeter/LArROD/python/LArSCellGetter.py b/LArCalorimeter/LArROD/python/LArSCellGetter.py index 87832c683642278a3e7aa80c6272a598cb0daa88..2ab7f5f3224faf4e7df9daa90efb7c80794984bf 100755 --- a/LArCalorimeter/LArROD/python/LArSCellGetter.py +++ b/LArCalorimeter/LArROD/python/LArSCellGetter.py @@ -14,7 +14,6 @@ class LArSCellGetter ( Configured ) : from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() - from AthenaCommon.AppMgr import ToolSvc # get LArDigitGetter in MC case @@ -32,89 +31,10 @@ class LArSCellGetter ( Configured ) : mlog.error("LArSCL1Getter unusable. Quite") return False - # ADC2MeV tool - from LArRecUtils.LArADC2MeVSCToolDefault import LArADC2MeVSCToolDefault - theADC2MeVSCTool = LArADC2MeVSCToolDefault('LArADC2MeVSCTool') - ToolSvc += theADC2MeVSCTool - - - from AthenaCommon.AppMgr import ServiceMgr as svcMgr - # Only MC case - if True : - from LArROD.LArRODConf import LArSuperCellBuilderDriver - theLArSCellBuilder=LArSuperCellBuilderDriver("LArSuperCellBuilder") - - theLArSCellBuilder.LArRawChannelContainerName="LArSuperCells" - theLArSCellBuilder.DataLocation="LArDigitSCL1" - self._LArSCellBuilder = theLArSCellBuilder - topSequence += theLArSCellBuilder - from LArRecUtils.LArRecUtilsConf import LArFlatConditionSvc - if not hasattr(svcMgr,"LArFlatConditionSvc"): - svcMgr+=LArFlatConditionSvc() - svcMgr.ProxyProviderSvc.ProviderNames += [ "LArFlatConditionSvc" ] - svcMgr.LArFlatConditionSvc.DoSuperCells=True - - # Pulse reconstruction - # main method: OFC iteration - from LArRecUtils.LArOFCSCToolDefault import LArOFCSCToolDefault - theLArOFCSCTool = LArOFCSCToolDefault('LArOFCSCToolDefault') - ToolSvc+=theLArOFCSCTool - from LArROD.LArRODConf import LArRawChannelBuilderToolOFC - theLArRawChannelBuilderToolOFC=LArRawChannelBuilderToolOFC('LArRawChannelBuilderSCToolOFC') - theLArRawChannelBuilderToolOFC.OFCTool=theLArOFCSCTool - theLArRawChannelBuilderToolOFC.ECut=-99999.0 - theLArRawChannelBuilderToolOFC.KeyShape = "LArShapeSC" - ToolSvc+=theLArRawChannelBuilderToolOFC - theLArSCellBuilder.BuilderTools += [theLArRawChannelBuilderToolOFC] - theLArSCellBuilder+=theLArRawChannelBuilderToolOFC - - # no fallback when emulating exactly DSP computation - # fallback(1): cubic method - from LArROD.LArRODConf import LArRawChannelBuilderToolCubic - theLArRawChannelBuilderToolCubic=LArRawChannelBuilderToolCubic('LArRawChannelBuilderSCToolCubic') - theLArRawChannelBuilderToolCubic.minADCforCubic=2 - ToolSvc+=theLArRawChannelBuilderToolCubic - theLArSCellBuilder.BuilderTools += [theLArRawChannelBuilderToolCubic] - theLArSCellBuilder += theLArRawChannelBuilderToolCubic - - - # Pedestal - # main method from database - from LArROD.LArRODConf import LArRawChannelBuilderPedestalDataBase - theLArRawChannelBuilderPedestalDataBase=LArRawChannelBuilderPedestalDataBase('LArRawChannelBuilderPedestalSCDataBase') - theLArRawChannelBuilderPedestalDataBase.LArPedestalKey = "LArPedestalSC" - ToolSvc+=theLArRawChannelBuilderPedestalDataBase - theLArSCellBuilder.PedestalTools = [theLArRawChannelBuilderPedestalDataBase] - theLArSCellBuilder += theLArRawChannelBuilderPedestalDataBase - - # no fallback when emulating exactly DSP computation - # fallback. sample 0 - from LArROD.LArRODConf import LArRawChannelBuilderPedestalSampleZero - theLArRawChannelBuilderPedestalSampleZero=LArRawChannelBuilderPedestalSampleZero() - ToolSvc+= theLArRawChannelBuilderPedestalSampleZero - theLArSCellBuilder.PedestalTools += [theLArRawChannelBuilderPedestalSampleZero] - theLArSCellBuilder += theLArRawChannelBuilderPedestalSampleZero - - # ADC to energy - # main method from database - from LArROD.LArRODConf import LArRawChannelBuilderADC2EDataBase - theLArRawChannelBuilderADC2EDataBase=LArRawChannelBuilderADC2EDataBase(name='LArRawChannelBuilderADC2ESCDataBase',IsSuperCell=True) - theLArRawChannelBuilderADC2EDataBase.RampMaxHighGain=6000 - theLArRawChannelBuilderADC2EDataBase.RampMaxMediumGain=49000 - ToolSvc += theLArRawChannelBuilderADC2EDataBase - theLArSCellBuilder.ADCtoEnergyTools = [theLArRawChannelBuilderADC2EDataBase] - theLArRawChannelBuilderADC2EDataBase.ADC2MeVTool = theADC2MeVSCTool - theLArSCellBuilder += theLArRawChannelBuilderADC2EDataBase - - # no fallback when emulating exactly DSP computation - # fallback, constant conversion factors - from LArROD.LArRODConf import LArRawChannelBuilderADC2EConstants - theLArRawChannelBuilderADC2EConstants=LArRawChannelBuilderADC2EConstants() - ToolSvc+=theLArRawChannelBuilderADC2EConstants - theLArSCellBuilder.ADCtoEnergyTools += [theLArRawChannelBuilderADC2EConstants] - theLArSCellBuilder += theLArRawChannelBuilderADC2EConstants + from LArROD.LArSuperCellBuilderAlgDefault import LArSuperCellBuilderAlgDefault + topSequence+=LArSuperCellBuilderAlgDefault() return True diff --git a/LArCalorimeter/LArROD/python/LArSuperCellBuilderAlgDefault.py b/LArCalorimeter/LArROD/python/LArSuperCellBuilderAlgDefault.py new file mode 100644 index 0000000000000000000000000000000000000000..ab08321454d04f8703b7695eb0a81fb074a0b92c --- /dev/null +++ b/LArCalorimeter/LArROD/python/LArSuperCellBuilderAlgDefault.py @@ -0,0 +1,41 @@ +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + +from LArROD.LArRODConf import LArRawChannelBuilderAlg +from IOVDbSvc.CondDB import conddb + +def addLArFlatFolder (db, obj, calg, folder_base='/LAR/ElecCalibFlat/',qual=''): + from AthenaCommon.AlgSequence import AthSequencer + condSequence = AthSequencer("AthCondSeq") + + folder = folder_base + obj + if not conddb.folderRequested(folder): + conddb.addFolder(db, folder + qual, + className = 'CondAttrListCollection') + condSequence += calg (ReadKey=folder, WriteKey='LAr'+obj+'SC') + return + +def LArSuperCellBuilderAlgDefault(): + + from LArCabling.LArCablingAccess import LArOnOffIdMappingSC + from LArRecUtils.LArADC2MeVSCCondAlgDefault import LArADC2MeVSCCondAlgDefault + from LArRecUtils.LArOFCSCCondAlgDefault import LArOFCSCCondAlgDefault + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArPedestalSC_ as LArPedestalSCFlatCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArShapeSC_ as LArShapeSCCondAlg + LArOnOffIdMappingSC() + addLArFlatFolder ('LAR_OFL', 'Shape', LArShapeSCCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'Pedestal', LArPedestalSCFlatCondAlg,'/LAR/ElecCalibMCSC/') + + LArADC2MeVSCCondAlgDefault() + LArOFCSCCondAlgDefault() + theSelf = LArRawChannelBuilderAlg("LArSuperCellBuilderAlg") + theSelf.CablingKey='LArOnOffIdMapSC' + theSelf.ADC2MeVKey='LArADC2MeVSC' + theSelf.ShapeKey='LArShapeSC' + theSelf.PedestalKey='LArPedestalSC' + theSelf.OFCKey='LArOFCSC' + theSelf.CaloCellKey='TestSCell' + theSelf.LArDigitKey='LArDigitSCL2' + theSelf.useDB=False + theSelf.IsSuperCell=True + theSelf.ECutFortQ = -1024 + return theSelf diff --git a/LArCalorimeter/LArROD/share/LArSuperCellEnable.py b/LArCalorimeter/LArROD/share/LArSuperCellEnable.py index 7825759c94acb579e672d864150899ed582680f6..a9a92da0b0e3b2011d54d671cc41403f1967786a 100644 --- a/LArCalorimeter/LArROD/share/LArSuperCellEnable.py +++ b/LArCalorimeter/LArROD/share/LArSuperCellEnable.py @@ -1,8 +1,4 @@ -from IOVDbSvc.CondDB import conddb -if not conddb.folderRequested('/LAR/IdentifierOfl/OnOffIdMap_SC') : - conddb.addFolder("LAR_OFL","<tag>LARIdentifierOflOnOffIdMap_SC-000</tag>/LAR/IdentifierOfl/OnOffIdMap_SC") - from LArL1Sim.LArSCL1Getter import * theLArSCL1Getter = LArSCL1Getter() digitizationFlags.rndmSeedList.addSeed("LArSCL1Maker", 335242, 7306589 ) @@ -13,7 +9,7 @@ theLArSCL1Maker.RndmSvc = digitizationFlags.rndmSvc.get_Value() from LArROD.LArSCellGetter import LArSCellGetter theLArSCellGetter = LArSCellGetter() -streamRDO.ItemList+=["LArDigitContainer#LArDigitSCL1"] -streamRDO.ItemList+=["CaloCellContainer#SCell"] +streamRDO.ItemList+=["LArDigitContainer#LArDigitSCL2"] +streamRDO.ItemList+=["CaloCellContainer#TestSCell"] topSequence.remove(streamRDO) topSequence += streamRDO diff --git a/LArCalorimeter/LArROD/src/LArRawChannelBuilderAlg.cxx b/LArCalorimeter/LArROD/src/LArRawChannelBuilderAlg.cxx index c134bbf4dce3ce147101880e9c7b6b479f4eebaa..0a08de9227cc71dd143c8bd130b596e43480c77c 100644 --- a/LArCalorimeter/LArROD/src/LArRawChannelBuilderAlg.cxx +++ b/LArCalorimeter/LArROD/src/LArRawChannelBuilderAlg.cxx @@ -5,17 +5,22 @@ #include "LArROD/LArRawChannelBuilderAlg.h" #include "GaudiKernel/SystemOfUnits.h" #include "LArRawEvent/LArRawChannelContainer.h" +#include "CaloEvent/CaloCellContainer.h" +#include "CaloDetDescr/CaloDetDescrManager.h" #include "LArRawEvent/LArDigitContainer.h" +#include "LArIdentifier/LArOnline_SuperCellID.h" #include "LArIdentifier/LArOnlineID.h" #include "LArCOOLConditions/LArDSPThresholdsFlat.h" +#include "AthAllocators/DataPool.h" #include <cmath> LArRawChannelBuilderAlg::LArRawChannelBuilderAlg(const std::string& name, ISvcLocator* pSvcLocator): - AthReentrantAlgorithm(name, pSvcLocator) {} + AthReentrantAlgorithm(name, pSvcLocator), m_sem_mgr(0) {} StatusCode LArRawChannelBuilderAlg::initialize() { ATH_CHECK(m_digitKey.initialize()); - ATH_CHECK(m_rawChannelKey.initialize()); + if ( m_isSC ) ATH_CHECK(m_cellKey.initialize()); + else ATH_CHECK(m_rawChannelKey.initialize()); ATH_CHECK(m_pedestalKey.initialize()); ATH_CHECK(m_adc2MeVKey.initialize()); ATH_CHECK(m_ofcKey.initialize()); @@ -30,7 +35,17 @@ StatusCode LArRawChannelBuilderAlg::initialize() { } } - ATH_CHECK(detStore()->retrieve(m_onlineId,"LArOnlineID")); + if ( m_isSC ) { + const LArOnline_SuperCellID* ll; + ATH_CHECK(detStore()->retrieve(ll,"LArOnline_SuperCellID")); + m_onlineId = (const LArOnlineID_Base*)ll; + ATH_CHECK( detStore()->retrieve (m_sem_mgr, "CaloSuperCellMgr") ); + } + else { + const LArOnlineID* ll; + ATH_CHECK(detStore()->retrieve(ll,"LArOnlineID")); + m_onlineId = (const LArOnlineID_Base*)ll; + } const std::string cutmsg = m_absECutFortQ.value() ? " fabs(E) < " : " E < "; ATH_MSG_INFO("Energy cut for time and quality computation: " << cutmsg << @@ -50,8 +65,18 @@ StatusCode LArRawChannelBuilderAlg::execute(const EventContext& ctx) const { SG::ReadHandle<LArDigitContainer> inputContainer(m_digitKey,ctx); //Write output via write handle - SG::WriteHandle<LArRawChannelContainer>outputContainer(m_rawChannelKey,ctx); - ATH_CHECK(outputContainer.record(std::make_unique<LArRawChannelContainer>())); + + auto outputContainerCellPtr = std::make_unique<CaloCellContainer>(SG::VIEW_ELEMENTS); + auto outputContainerLRPtr = std::make_unique<LArRawChannelContainer>(); + + DataPool<CaloCell> dataPool; + if ( m_isSC ) { + unsigned int hash_max = m_onlineId->channelHashMax(); + if (dataPool.allocated()==0){ + dataPool.reserve (hash_max); + } + outputContainerCellPtr->reserve( hash_max ); + } //Get Conditions input SG::ReadCondHandle<ILArPedestal> pedHdl(m_pedestalKey,ctx); @@ -95,6 +120,7 @@ StatusCode LArRawChannelBuilderAlg::execute(const EventContext& ctx) const { const HWIdentifier id=digit->hardwareID(); const bool connected=(*cabling)->isOnlineConnected(id); + ATH_MSG_VERBOSE("Working on channel " << m_onlineId->channel_name(id)); @@ -111,13 +137,14 @@ StatusCode LArRawChannelBuilderAlg::execute(const EventContext& ctx) const { //Sanity check on input conditions data: // FIXME: fix to get splash test running, should implement the iterations later size_t len=nSamples; - if(ATH_UNLIKELY(ofca.size()<nSamples)) { + if(!m_isSC && ATH_UNLIKELY(ofca.size()<nSamples)) { if (!connected) continue; //No conditions for disconencted channel, who cares? ATH_MSG_DEBUG("Number of OFC a's doesn't match number of samples for conencted channel " << m_onlineId->channel_name(id) << " gain " << gain << ". OFC size=" << ofca.size() << ", nbr ADC samples=" << nSamples); - //return StatusCode::FAILURE; len=ofca.size(); } + if (m_isSC && !connected ) continue; + if (m_isSC ) len = nSamples <= ofca.size() ? nSamples : ofca.size(); if (ATH_UNLIKELY(p==ILArPedestal::ERRORCODE)) { if (!connected) continue; //No conditions for disconencted channel, who cares? @@ -137,9 +164,11 @@ StatusCode LArRawChannelBuilderAlg::execute(const EventContext& ctx) const { //Apply OFCs to get amplitude float A=0; bool saturated=false; + unsigned int init=0; + if (m_isSC) init=1; for (size_t i=0;i<len;++i) { - A+=(samples[i]-p)*ofca[i]; - if (samples[i]==4096 || samples[i]==0) saturated=true; + A+=(samples[i+init]-p)*ofca[i]; + if (samples[i+init]==4096 || samples[i+init]==0) saturated=true; } //Apply Ramp @@ -236,9 +265,32 @@ StatusCode LArRawChannelBuilderAlg::execute(const EventContext& ctx) const { }//end if above cut - outputContainer->emplace_back(id,static_cast<int>(std::floor(E+0.5)), + if ( m_isSC ){ + CaloCell* ss = dataPool.nextElementPtr(); + Identifier offId = cabling->cnvToIdentifier(id); + + const CaloDetDescrElement* dde = m_sem_mgr->get_element (offId); + ss->setCaloDDE(dde); + ss->setEnergy(E); + ss->setTime(tau); + ss->setGain((CaloGain::CaloGain)0); + ss->setProvenance(prov); + ss->setQuality(iquaShort); + outputContainerCellPtr->push_back(ss); + } + else{ + outputContainerLRPtr->emplace_back(id,static_cast<int>(std::floor(E+0.5)), static_cast<int>(std::floor(tau+0.5)), iquaShort,prov,(CaloGain::CaloGain)gain); + } + } + if ( m_isSC ) { + SG::WriteHandle<CaloCellContainer>outputContainer(m_cellKey,ctx); + outputContainerCellPtr->reserve( m_onlineId->channelHashMax() ); + ATH_CHECK(outputContainer.record(std::move(outputContainerCellPtr) ) ); + } else { + SG::WriteHandle<LArRawChannelContainer>outputContainer(m_rawChannelKey,ctx); + ATH_CHECK(outputContainer.record(std::move(outputContainerLRPtr) ) ); } return StatusCode::SUCCESS; diff --git a/LArCalorimeter/LArRawConditions/src/LArAutoCorrNoise.cxx b/LArCalorimeter/LArRawConditions/src/LArAutoCorrNoise.cxx index 6d01a5eabe7446e05dc1a449793d2a99fb5ae253..f5419ea9050baf951db772ea017a4ba4bb4834d4 100644 --- a/LArCalorimeter/LArRawConditions/src/LArAutoCorrNoise.cxx +++ b/LArCalorimeter/LArRawConditions/src/LArAutoCorrNoise.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "LArRawConditions/LArAutoCorrNoise.h" @@ -15,6 +15,13 @@ LArAutoCorrNoise::~LArAutoCorrNoise() {} const std::vector<float>& LArAutoCorrNoise::autoCorrSqrt( const Identifier& id, int gain ) const { - const HWIdentifier hwid = m_larMCsym->ZPhiSymOfl( id ); + HWIdentifier hwid(0); + if ( m_larMCsym ) hwid = m_larMCsym->ZPhiSymOfl( id ); + // Not sure what to do with this method when no larMCsym is available + return m_autoCorrNoise.at( gain ).at( hwid ); +} + +const std::vector<float>& LArAutoCorrNoise::autoCorrSqrt( const HWIdentifier& hwid, int gain ) const +{ return m_autoCorrNoise.at( gain ).at( hwid ); } diff --git a/LArCalorimeter/LArRecUtils/python/LArADC2MeVSCCondAlgDefault.py b/LArCalorimeter/LArRecUtils/python/LArADC2MeVSCCondAlgDefault.py index ec77caa37fbea1873303dc13a3e3e4f4295e3709..33faa1d9b165ebcdff283e3869867fda7c0e9f7d 100644 --- a/LArCalorimeter/LArRecUtils/python/LArADC2MeVSCCondAlgDefault.py +++ b/LArCalorimeter/LArRecUtils/python/LArADC2MeVSCCondAlgDefault.py @@ -3,32 +3,42 @@ from LArRecUtils.LArRecUtilsConf import LArADC2MeVCondAlg from AthenaCommon.AlgSequence import AthSequencer from LArCabling.LArCablingAccess import LArOnOffIdMappingSC -condSeq = AthSequencer("AthCondSeq") +from IOVDbSvc.CondDB import conddb +def addLArFlatFolder (db, obj, calg, folder_base='/LAR/ElecCalibFlat/',qual=''): + from AthenaCommon.AlgSequence import AthSequencer + condSequence = AthSequencer("AthCondSeq") -def LArADC2MeVSCCondAlgDefault(isMC=True): + folder = folder_base + obj + if not conddb.folderRequested(folder): + conddb.addFolder(db, folder + qual, + className = 'CondAttrListCollection') + condSequence += calg (ReadKey=folder, WriteKey='LAr'+obj+'SC') + return - #if isMC: - # include("LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py") - #else: - # include("LArConditionsCommon/LArConditionsCommon_comm_jobOptions.py") +def LArADC2MeVSCCondAlgDefault(isMC=True): - LArOnOffIdMappingSC() condSeq = AthSequencer("AthCondSeq") if hasattr (condSeq,"LArADC2MeVSCCondAlg"): return getattr(condSeq,"LArADC2MeVSCCondAlg") - theADC2MeVCondAlg=LArADC2MeVCondAlg("LArADC2MeVSCCondAlg",LArADC2MeVKey = 'LArADC2MeV') + LArOnOffIdMappingSC() + condSeq = AthSequencer("AthCondSeq") + + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArRampSC_ as LArRampCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LAruA2MeVSC_ as LAruA2MeVCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArDAC2uASC_ as LArDAC2uACondAlg + addLArFlatFolder ('LAR_OFL', 'Ramp', LArRampCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'uA2MeV', LAruA2MeVCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'DAC2uA', LArDAC2uACondAlg,'/LAR/ElecCalibMCSC/') + + + theADC2MeVCondAlg=LArADC2MeVCondAlg("LArADC2MeVSCCondAlg",LArADC2MeVKey = 'LArADC2MeVSC',isSuperCell=True,LArOnOffIdMappingKey='LArOnOffIdMapSC') if isMC: - from LArConditionsCommon.LArCondFlags import larCondFlags - if not larCondFlags.hasMphys(): - theADC2MeVCondAlg.LArMphysOverMcalKey="" #No MphysOVerMcal - else: - theADC2MeVCondAlg.LArMphysOverMcalKey="LArMphysOverMcal" - - if not larCondFlags.hasHVCorr(): - theADC2MeVCondAlg.LArHVScaleCorrKey="" + theADC2MeVCondAlg.LArMphysOverMcalKey="" #No MphysOVerMcal + + theADC2MeVCondAlg.LArHVScaleCorrKey="" theADC2MeVCondAlg.LAruA2MeVKey="LAruA2MeVSC" theADC2MeVCondAlg.LArDAC2uAKey="LArDAC2uASC" @@ -36,9 +46,6 @@ def LArADC2MeVSCCondAlgDefault(isMC=True): theADC2MeVCondAlg.UseFEBGainTresholds=False - else: # not MC: - from LArRecUtils.LArFebConfigCondAlgDefault import LArFebConfigCondAlgDefault - LArFebConfigCondAlgDefault() condSeq+=theADC2MeVCondAlg return theADC2MeVCondAlg diff --git a/LArCalorimeter/LArRecUtils/python/LArADC2MeVSCToolDefault.py b/LArCalorimeter/LArRecUtils/python/LArADC2MeVSCToolDefault.py index 71e8158c095a2694b363b9266bfc5598160471c8..562f8a9adaf5f54fc8bc213fcb294e9600e3fb31 100644 --- a/LArCalorimeter/LArRecUtils/python/LArADC2MeVSCToolDefault.py +++ b/LArCalorimeter/LArRecUtils/python/LArADC2MeVSCToolDefault.py @@ -9,7 +9,7 @@ if conddb.isMC: else: include("LArConditionsCommon/LArConditionsCommon_comm_jobOptions.py") -from LArRecUtils.LArRecUtilsConf import LArADC2MeVSCCondAlg +from LArRecUtils.LArRecUtilsConf import LArADC2MeVCondAlg from AthenaCommon.AlgSequence import AthSequencer from LArCabling.LArCablingAccess import LArOnOffIdMappingSC condSeq = AthSequencer("AthCondSeq") @@ -23,7 +23,7 @@ def LArADC2MeVSCCondAlgDefault (name="LArADC2MeVSCCondAlgDefault"): return getattr(condSeq,"LArADC2MeVSCCondAlg") - theADC2MeVCondAlg=LArADC2MeVSCCondAlg(LArADC2MeVKey = 'LArADC2MeV') + theADC2MeVCondAlg=LArADC2MeVCondAlg(LArADC2MeVKey = 'LArADC2MeV',isSuperCell=True) if conddb.isMC: from LArConditionsCommon.LArCondFlags import larCondFlags diff --git a/LArCalorimeter/LArRecUtils/python/LArAutoCorrNoiseSCCondAlgDefault.py b/LArCalorimeter/LArRecUtils/python/LArAutoCorrNoiseSCCondAlgDefault.py new file mode 100644 index 0000000000000000000000000000000000000000..34102dc39d557fbbd4a6283d8d0e6965faffa86b --- /dev/null +++ b/LArCalorimeter/LArRecUtils/python/LArAutoCorrNoiseSCCondAlgDefault.py @@ -0,0 +1,35 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +from IOVDbSvc.CondDB import conddb +from LArRecUtils.LArRecUtilsConf import LArAutoCorrNoiseCondAlg +from AthenaCommon.AlgSequence import AthSequencer +from LArCabling.LArCablingAccess import LArOnOffIdMappingSC +condSeq = AthSequencer("AthCondSeq") + +def addLArFlatFolder (db, obj, calg, folder_base='/LAR/ElecCalibFlat/',qual=''): + from AthenaCommon.AlgSequence import AthSequencer + condSequence = AthSequencer("AthCondSeq") + + folder = folder_base + obj + if not conddb.folderRequested(folder): + conddb.addFolder(db, folder + qual, + className = 'CondAttrListCollection') + condSequence += calg (ReadKey=folder, WriteKey='LAr'+obj+'SC') + return + +def LArAutoCorrNoiseSCCondAlgDefault(): + + LArOnOffIdMappingSC() + condSeq = AthSequencer("AthCondSeq") + if hasattr (condSeq,"LArAutoCorrNoiseSCCondAlg"): + return getattr(condSeq,"LArAutoCorrNoiseSCCondAlg") + + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArAutoCorrSC_ as LArAutoCorrSCCondAlg + addLArFlatFolder ('LAR_OFL', 'AutoCorr', LArAutoCorrSCCondAlg,'/LAR/ElecCalibMCSC/') + theAutoCorrNoiseCondAlg=LArAutoCorrNoiseCondAlg("LArAutoCorrNoiseSCCondAlg",isSuperCell=True,LArAutoCorrNoiseObjKey="LArAutoCorrNoiseSC",LArAutoCorrObjKey="LArAutoCorrSC",LArOnOffIdMappingObjKey='LArOnOffIdMapSC') + + from LArROD.LArRODFlags import larRODFlags + theAutoCorrNoiseCondAlg.nSampl = larRODFlags.nSamples() + + condSeq+=theAutoCorrNoiseCondAlg + return theAutoCorrNoiseCondAlg diff --git a/LArCalorimeter/LArRecUtils/python/LArAutoCorrTotalCondAlgDefault.py b/LArCalorimeter/LArRecUtils/python/LArAutoCorrTotalCondAlgDefault.py index d50b139d6c6aab5b0fad70c219bf3c480bf9a050..c77ed7f7beb44ff83802bebb5aa2a99f40f58ec1 100644 --- a/LArCalorimeter/LArRecUtils/python/LArAutoCorrTotalCondAlgDefault.py +++ b/LArCalorimeter/LArRecUtils/python/LArAutoCorrTotalCondAlgDefault.py @@ -9,12 +9,7 @@ include("LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py") from LArRecUtils.LArRecUtilsConf import LArAutoCorrTotalCondAlg from AthenaCommon.AlgSequence import AthSequencer -if "SuperCells" not in dir(): - SuperCells = False -if SuperCells: - from LArCabling.LArCablingAccess import LArOnOffIdMappingSC -else: - from LArCabling.LArCablingAccess import LArOnOffIdMapping +from LArCabling.LArCablingAccess import LArOnOffIdMapping condSeq = AthSequencer("AthCondSeq") @@ -22,11 +17,7 @@ def LArAutoCorrTotalCondAlgDefault(): mlog = logging.getLogger( 'LArAutoCorrTotalCondAlg::__init__ ' ) mlog.info("entering LArAutoCorrTotalCondAlgDefault") - - if SuperCells: - LArOnOffIdMappingSC() - else: - LArOnOffIdMapping() + LArOnOffIdMapping() condSeq = AthSequencer("AthCondSeq") if hasattr (condSeq,"LArAutoCorrTotalCondAlg"): return getattr(condSeq,"LArAutoCorrTotalCondAlg") diff --git a/LArCalorimeter/LArRecUtils/python/LArAutoCorrTotalSCCondAlgDefault.py b/LArCalorimeter/LArRecUtils/python/LArAutoCorrTotalSCCondAlgDefault.py new file mode 100644 index 0000000000000000000000000000000000000000..e91dc92e5b58cf2bc4078d1192876aaacf04c3eb --- /dev/null +++ b/LArCalorimeter/LArRecUtils/python/LArAutoCorrTotalSCCondAlgDefault.py @@ -0,0 +1,84 @@ +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.Logging import logging + +from LArRecUtils.LArRecUtilsConf import LArAutoCorrTotalCondAlg +from AthenaCommon.AlgSequence import AthSequencer +from LArCabling.LArCablingAccess import LArOnOffIdMappingSC +condSeq = AthSequencer("AthCondSeq") +from IOVDbSvc.CondDB import conddb + +def addLArFlatFolder (db, obj, calg, folder_base='/LAR/ElecCalibFlat/',qual=''): + from AthenaCommon.AlgSequence import AthSequencer + condSequence = AthSequencer("AthCondSeq") + + folder = folder_base + obj + if not conddb.folderRequested(folder): + conddb.addFolder(db, folder + qual, + className = 'CondAttrListCollection') + condSequence += calg (ReadKey=folder, WriteKey='LAr'+obj+'SC') + return + +def LArAutoCorrTotalSCCondAlgDefault(): + + mlog = logging.getLogger( 'LArAutoCorrTotalSCCondAlg::__init__ ' ) + mlog.info("entering LArAutoCorrTotalSCCondAlgDefault") + + condSeq = AthSequencer("AthCondSeq") + if hasattr (condSeq,"LArAutoCorrTotalSCCondAlg"): + return getattr(condSeq,"LArAutoCorrTotalSCCondAlg") + + LArOnOffIdMappingSC() + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArNoiseSC_ as LArNoiseSCCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArPedestalSC_ as LArPedestalSCFlatCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArShapeSC_ as LArShapeSCCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArfSamplSC_ as LArfSamplSCCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArAutoCorrSC_ as LArAutoCorrSCCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArMinBiasSC_ as LArMinBiasSCCondAlg + + + #include('LArConditionsCommon/LArConditionsCommon_comm_jobOptions') + addLArFlatFolder ('LAR_OFL', 'Shape', LArShapeSCCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'Pedestal', LArPedestalSCFlatCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'Noise', LArNoiseSCCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'fSampl', LArfSamplSCCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'AutoCorr', LArAutoCorrSCCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'MinBias', LArMinBiasSCCondAlg,'/LAR/ElecCalibMCSC/') + + from LArRecUtils.LArADC2MeVSCCondAlgDefault import LArADC2MeVSCCondAlgDefault + LArADC2MeVSCCondAlgDefault() + + theAutoCorrTotalCondAlg=LArAutoCorrTotalCondAlg("LArAutoCorrTotalSCCondAlg",isSuperCell=True) + theAutoCorrTotalCondAlg.LArADC2MeVObjKey='LArADC2MeVSC' + theAutoCorrTotalCondAlg.LArOnOffIdMappingObjKey='LArOnOffIdMapSC' + theAutoCorrTotalCondAlg.LArShapeObjKey='LArShapeSC' + theAutoCorrTotalCondAlg.LArAutoCorrObjKey='LArAutoCorrSC' + theAutoCorrTotalCondAlg.LArNoiseObjKey='LArNoiseSC' + theAutoCorrTotalCondAlg.LArPedestalObjKey='LArPedestalSC' + theAutoCorrTotalCondAlg.LArfSamplObjKey='LArfSamplSC' + theAutoCorrTotalCondAlg.LArMinBiasObjKey='LArMinBiasSC' + theAutoCorrTotalCondAlg.LArAutoCorrTotalObjKey='LArAutoCorrTotalSC' + + + from AthenaCommon.BeamFlags import jobproperties + from LArROD.LArRODFlags import larRODFlags + + from AthenaCommon.SystemOfUnits import ns + theAutoCorrTotalCondAlg.Nsamples = larRODFlags.nSamples() + theAutoCorrTotalCondAlg.firstSample = larRODFlags.firstSample() + theAutoCorrTotalCondAlg.deltaBunch = int(jobproperties.Beam.bunchSpacing()/( 25.*ns)+0.5) + + if larRODFlags.doOFCPileupOptimization(): + if larRODFlags.NumberOfCollisions(): + theAutoCorrTotalCondAlg.Nminbias=larRODFlags.NumberOfCollisions() + mlog.info(" setup for Ncollisions %f deltaBunch %f", larRODFlags.NumberOfCollisions(), jobproperties.Beam.bunchSpacing()) + else: + theAutoCorrTotalCondAlg.Nminbias=jobproperties.Beam.numberOfCollisions() + mlog.info(" setup for Ncollisions %f deltaBunch %f", jobproperties.Beam.numberOfCollisions(), jobproperties.Beam.bunchSpacing()) + else: + theAutoCorrTotalCondAlg.Nminbias=0 + mlog.info(" setup for computing total noise autocorrelation without pileup") + + + condSeq+=theAutoCorrTotalCondAlg + return theAutoCorrTotalCondAlg diff --git a/LArCalorimeter/LArRecUtils/python/LArOFCSCCondAlgDefault.py b/LArCalorimeter/LArRecUtils/python/LArOFCSCCondAlgDefault.py new file mode 100644 index 0000000000000000000000000000000000000000..6bc6a21b3c3b007df7d57578a8d8be10e337ad0f --- /dev/null +++ b/LArCalorimeter/LArRecUtils/python/LArOFCSCCondAlgDefault.py @@ -0,0 +1,81 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.Include import include + +include("LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py") +from AthenaCommon.Logging import logging +from LArRecUtils.LArRecUtilsConf import LArOFCCondAlg +from AthenaCommon.AlgSequence import AthSequencer +from LArCabling.LArCablingAccess import LArOnOffIdMappingSC +from IOVDbSvc.CondDB import conddb + +def addLArFlatFolder (db, obj, calg, folder_base='/LAR/ElecCalibFlat/',qual=''): + from AthenaCommon.AlgSequence import AthSequencer + condSequence = AthSequencer("AthCondSeq") + + folder = folder_base + obj + if not conddb.folderRequested(folder): + conddb.addFolder(db, folder + qual, + className = 'CondAttrListCollection') + condSequence += calg (ReadKey=folder, WriteKey='LAr'+obj+'SC') + return + +def LArOFCSCCondAlgDefault(): + + mlog = logging.getLogger('LArOFCSCCondAlg') + mlog.info("entering LArOFCSCCondAlgDefault") + + condSeq = AthSequencer("AthCondSeq") + if hasattr (condSeq,"LArOFCSCCondAlg"): + return getattr(condSeq,"LArOFCSCCondAlg") + + LArOnOffIdMappingSC() + + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArNoiseSC_ as LArNoiseSCCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArPedestalSC_ as LArPedestalSCFlatCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArShapeSC_ as LArShapeSCCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArfSamplSC_ as LArfSamplSCCondAlg + from LArRecUtils.LArRecUtilsConf import LArFlatConditionsAlg_LArAutoCorrSC_ as LArAutoCorrSCCondAlg + + + #include('LArConditionsCommon/LArConditionsCommon_comm_jobOptions') + addLArFlatFolder ('LAR_OFL', 'Shape', LArShapeSCCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'Pedestal', LArPedestalSCFlatCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'Noise', LArNoiseSCCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'fSampl', LArfSamplSCCondAlg,'/LAR/ElecCalibMCSC/') + addLArFlatFolder ('LAR_OFL', 'AutoCorr', LArAutoCorrSCCondAlg,'/LAR/ElecCalibMCSC/') + + from LArRecUtils.LArAutoCorrTotalSCCondAlgDefault import LArAutoCorrTotalSCCondAlgDefault + LArAutoCorrTotalSCCondAlgDefault() + + theOFCCondAlg=LArOFCCondAlg("LArOFCSCCondAlg") + theOFCCondAlg.isMC = True + theOFCCondAlg.isSuperCell = True + from LArROD.LArRODFlags import larRODFlags + from AthenaCommon.BeamFlags import jobproperties + + theOFCCondAlg.firstSample = larRODFlags.firstSample() + theOFCCondAlg.useHighestGainAutoCorr = larRODFlags.useHighestGainAutoCorr() + theOFCCondAlg.LArOnOffIdMappingObjKey='LArOnOffIdMapSC' + theOFCCondAlg.LArShapeObjKey='LArShapeSC' + theOFCCondAlg.LArNoiseObjKey='LArNoiseSC' + theOFCCondAlg.LArPedestalObjKey='LArPedestalSC' + theOFCCondAlg.LArAutoCorrTotalObjKey='LArAutoCorrTotalSC' + theOFCCondAlg.LArOFCObjKey='LArOFCSC' + + + if larRODFlags.doOFCPileupOptimization(): + if larRODFlags.NumberOfCollisions(): + theOFCCondAlg.Nminbias=larRODFlags.NumberOfCollisions() + mlog.info(" setup for Ncollisions %f ", larRODFlags.NumberOfCollisions()) + else: + theOFCCondAlg.Nminbias=jobproperties.Beam.numberOfCollisions() + mlog.info(" setup for Ncollisions %f ", jobproperties.Beam.numberOfCollisions()) + else: + theOFCCondAlg.Nminbias=0 + mlog.info(" setup for no pileup optimization") + + pass + + condSeq+=theOFCCondAlg + return theOFCCondAlg diff --git a/LArCalorimeter/LArRecUtils/src/LArAutoCorrNoiseCondAlg.cxx b/LArCalorimeter/LArRecUtils/src/LArAutoCorrNoiseCondAlg.cxx index a4d5c77250bb3ea853d20f69a0105481ae54bd9d..252e554f016e03fffd1a6d3475a1344736e90223 100644 --- a/LArCalorimeter/LArRecUtils/src/LArAutoCorrNoiseCondAlg.cxx +++ b/LArCalorimeter/LArRecUtils/src/LArAutoCorrNoiseCondAlg.cxx @@ -57,14 +57,6 @@ StatusCode LArAutoCorrNoiseCondAlg::initialize() m_nGains = ( m_isSuperCell ) ? 1 : 3; - if (m_isSuperCell) { - ATH_MSG_ERROR("This cond-algo doesn't work yet for SuperCells"); - } - //Super-cells are only half-implemented here. - //The produced LArAutoCorrNoise CDO will always use LArMCSym to query the underlying storage but - //we dont' use symmetry for SuperCells. Suggest to implement dedicated CDO for supercells. - - return StatusCode::SUCCESS; } @@ -98,11 +90,13 @@ StatusCode LArAutoCorrNoiseCondAlg::execute() } // MC symmetrization helper const LArMCSym* larMCsym = nullptr; + if ( !m_isSuperCell && m_MCsym ) { SG::ReadCondHandle<LArMCSym> larMCsymHdl{m_LArMCSymObjKey}; larMCsym = *larMCsymHdl; if ( larMCsym == nullptr ) { ATH_MSG_ERROR( "Failed to retrieve LArMCSym object" ); } + } // Get pointers to inputs // Retrieve validity ranges and determine their intersection