Commit dad33088 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'master-caloddmgr-trig' into 'master'

Migrated L1CaloHVDummyContainers to reading CaloDetDescrManager from the Condition Store

See merge request atlas/athena!47357
parents 03a95aac 6b5d49fa
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#ifndef L1CALOHVDUMMYCONTAINERS_H
#define L1CALOHVDUMMYCONTAINERS_H
#include "AthenaBaseComps/AthAlgorithm.h"
#include "CaloDetDescr/CaloDetDescrManager.h"
#include "StoreGate/ReadCondHandleKey.h"
#include <string>
......@@ -14,7 +16,6 @@ class CaloIdManager;
class CaloCell_ID;
class CaloDetDescriptor;
class CaloDetDescrElement;
class CaloDetDescrManager;
/**
* This algorithms creates dummy containers so HV job will run without data.
......@@ -28,9 +29,9 @@ class L1CaloHVDummyContainers : public AthAlgorithm
L1CaloHVDummyContainers(const std::string& name, ISvcLocator *pSvcLocator);
virtual ~L1CaloHVDummyContainers();
StatusCode initialize();
StatusCode execute();
StatusCode finalize();
virtual StatusCode initialize() override;
virtual StatusCode execute() override;
virtual StatusCode finalize() override;
private:
std::string m_triggerTowerCollectionName;
......@@ -38,7 +39,11 @@ class L1CaloHVDummyContainers : public AthAlgorithm
const CaloIdManager* m_caloMgr;
const CaloCell_ID* m_caloCellHelper;
const CaloDetDescrManager* m_caloDetDescrMgr;
SG::ReadCondHandleKey<CaloDetDescrManager> m_caloMgrKey { this
, "CaloDetDescrManager"
, "CaloDetDescrManager"
, "SG Key for CaloDetDescrManager in the Condition Store" };
bool m_firstEvent;
};
......
......@@ -12,7 +12,6 @@
#include "CaloEvent/CaloCellContainer.h"
#include "CaloDetDescr/CaloDetDescriptor.h"
#include "CaloDetDescr/CaloDetDescrElement.h"
#include "CaloDetDescr/CaloDetDescrManager.h"
#include "CaloIdentifier/CaloCell_ID.h"
#include "CaloIdentifier/CaloIdManager.h"
......@@ -20,9 +19,8 @@ L1CaloHVDummyContainers::L1CaloHVDummyContainers(const std::string& name, ISvcLo
: AthAlgorithm(name, pSvcLocator),
m_triggerTowerCollectionName("TriggerTowers"),
m_caloCellContainerName("AllCalo"),
m_caloMgr(0),
m_caloCellHelper(0),
m_caloDetDescrMgr(0),
m_caloMgr(nullptr),
m_caloCellHelper(nullptr),
m_firstEvent(true)
{
declareProperty("TriggerTowerCollectionName", m_triggerTowerCollectionName);
......@@ -35,34 +33,24 @@ L1CaloHVDummyContainers::~L1CaloHVDummyContainers()
StatusCode L1CaloHVDummyContainers::initialize()
{
StatusCode sc;
sc = detStore()->retrieve(m_caloMgr);
if (sc.isFailure()) {
msg(MSG::ERROR) << "Cannot retrieve CaloMgr" << endmsg;
return sc;
}
else {
m_caloCellHelper = m_caloMgr->getCaloCell_ID();
if ( !m_caloCellHelper ) {
msg(MSG::ERROR) << "Cannot retrieve CaloCell_ID" << endmsg;
return StatusCode::FAILURE;
}
}
sc = detStore()->retrieve(m_caloDetDescrMgr);
if (sc.isFailure()) {
msg(MSG::ERROR) << "Cannot retrieve CaloDetDescrMgr" << endmsg;
return sc;
}
return StatusCode::SUCCESS;
ATH_CHECK(detStore()->retrieve(m_caloMgr));
m_caloCellHelper = m_caloMgr->getCaloCell_ID();
if ( !m_caloCellHelper ) {
ATH_MSG_ERROR("Cannot retrieve CaloCell_ID");
return StatusCode::FAILURE;
}
ATH_CHECK(m_caloMgrKey.initialize());
return StatusCode::SUCCESS;
}
StatusCode L1CaloHVDummyContainers::execute()
{
if (m_firstEvent) {
StatusCode sc;
SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{m_caloMgrKey};
ATH_CHECK(caloMgrHandle.isValid());
const CaloDetDescrManager* caloDetDescrMgr = *caloMgrHandle;
// Create dummy TriggerTower collection
TriggerTowerCollection* ttCol = new TriggerTowerCollection();
......@@ -85,7 +73,7 @@ StatusCode L1CaloHVDummyContainers::execute()
}
}
}
msg(MSG::INFO) << "Size of TriggerTowerCollection is " << ttCol->size() << endmsg;
ATH_MSG_INFO("Size of TriggerTowerCollection is " << ttCol->size());
// Create dummy CaloCellCollection
CaloCellContainer* ccCol = new CaloCellContainer();
......@@ -95,35 +83,35 @@ StatusCode L1CaloHVDummyContainers::execute()
std::vector<Identifier>::const_iterator cellEnd(m_caloCellHelper->cell_end(CaloCell_ID::LAREM));
for (; cellItr != cellEnd; ++cellItr) {
CaloCell* cell = new CaloCell();
cell->set(m_caloDetDescrMgr->get_element(*cellItr), *cellItr);
cell->set(caloDetDescrMgr->get_element(*cellItr), *cellItr);
ccCol->push_back(cell);
}
cellItr = m_caloCellHelper->cell_begin(CaloCell_ID::LARHEC);
cellEnd = m_caloCellHelper->cell_end(CaloCell_ID::LARHEC);
for (; cellItr != cellEnd; ++cellItr) {
CaloCell* cell = new CaloCell();
cell->set(m_caloDetDescrMgr->get_element(*cellItr), *cellItr);
cell->set(caloDetDescrMgr->get_element(*cellItr), *cellItr);
ccCol->push_back(cell);
}
cellItr = m_caloCellHelper->cell_begin(CaloCell_ID::LARFCAL);
cellEnd = m_caloCellHelper->cell_end(CaloCell_ID::LARFCAL);
for (; cellItr != cellEnd; ++cellItr) {
CaloCell* cell = new CaloCell();
cell->set(m_caloDetDescrMgr->get_element(*cellItr), *cellItr);
cell->set(caloDetDescrMgr->get_element(*cellItr), *cellItr);
ccCol->push_back(cell);
}
msg(MSG::INFO) << "Size of CaloCellContainer is " << ccCol->size() << endmsg;
ATH_MSG_INFO("Size of CaloCellContainer is " << ccCol->size());
// Save in StoreGate
sc = evtStore()->record(ttCol, m_triggerTowerCollectionName);
StatusCode sc = evtStore()->record(ttCol, m_triggerTowerCollectionName);
if (sc.isFailure()) {
msg(MSG::ERROR) << "Failed to store TriggerTowerCollection in StoreGate" << endmsg;
return sc;
ATH_MSG_ERROR("Failed to store TriggerTowerCollection in StoreGate");
return sc;
}
sc = evtStore()->record(ccCol, m_caloCellContainerName);
if (sc.isFailure()) {
msg(MSG::ERROR) << "Failed to store CaloCellContainer in StoreGate" << endmsg;
return sc;
ATH_MSG_ERROR("Failed to store CaloCellContainer in StoreGate");
return sc;
}
m_firstEvent = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment