Commit 492af75d authored by Denis Oliveira Damazio's avatar Denis Oliveira Damazio Committed by Walter Lampl
Browse files

Include algorithm to translate SCells from Raw format to CaloCellContainer format

parent 48b1dd20
/*
* Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*
* Name : LArRAWtoSuperCell.cxx
* PACKAGE : LArCalorimeter/LArCell/LArRAWtoSuperCell
*
* AUTHOR : Denis Oliveira Damazio
*
* PURPOSE : prepares SuperCellContainer in CaloCellContainer formar from LArRawSCContainer
*
* **/
#include "LArRAWtoSuperCell.h"
#include "LArIdentifier/LArOnline_SuperCellID.h"
#include "CaloDetDescr/CaloDetDescrManager.h"
#include "LArCabling/LArOnOffIdMapping.h"
#include "xAODEventInfo/EventInfo.h"
LArRAWtoSuperCell::LArRAWtoSuperCell( const std::string& name, ISvcLocator* pSvcLocator)
: AthReentrantAlgorithm( name, pSvcLocator)//, m_sem_mgr(0)
{
}
StatusCode
LArRAWtoSuperCell::initialize()
{
ATH_CHECK( m_sCellContainerInKey.initialize() );
ATH_CHECK( m_sCellContainerOutKey.initialize() );
ATH_CHECK(detStore()->retrieve(m_laronline_id,"LArOnline_SuperCellID"));
ATH_CHECK( m_caloMgrKey.initialize());
return StatusCode::SUCCESS;
}
StatusCode
LArRAWtoSuperCell::execute(const EventContext& context) const
{
SG::ReadCondHandle<CaloSuperCellDetDescrManager> caloMgrHandle{m_caloMgrKey, context};
const CaloSuperCellDetDescrManager* sem_mgr = *caloMgrHandle;;
auto cellsHandle = SG::makeHandle( m_sCellContainerInKey, context );
if ( not cellsHandle.isValid() ) {
ATH_MSG_ERROR("Did not get CaloCellContainer input");
return StatusCode::FAILURE;
}
const LArRawSCContainer* scells_from_sg = cellsHandle.cptr();
ATH_MSG_DEBUG("Got a CaloCellContainer input with size : "<<scells_from_sg->size());
SG::WriteHandle<CaloCellContainer> scellContainerHandle( m_sCellContainerOutKey, context);
auto new_scell_cont = std::make_unique<CaloCellContainer> ();
const EventIDBase& EIHandle = context.eventID();
const unsigned int bcid = EIHandle.bunch_crossing_id();
new_scell_cont->reserve(scells_from_sg->size());
for(auto sc : *scells_from_sg){
if ( !sc ) continue;
// calculate the BCID for all the cells associated to the SC
// since this is emulation
IdentifierHash hash_id = m_laronline_id->channel_Hash(sc->hardwareID());
const CaloDetDescrElement* dde = sem_mgr ->get_element(hash_id);
CaloCell* cell = new CaloCell();
cell->setCaloDDE(dde);
const std::vector< unsigned short >& bcids = sc->bcids();
const std::vector< int >& energies = sc->energies();
const std::vector< bool>& satur = sc->satur();
float energy(0.);
bool saturation(false);
for(unsigned int i=0;i<bcids.size();i++) if ( bcids[i]==bcid ) {energy=energies[i]; saturation = satur[i];}
cell->setEnergy( energy );
// we probably should soon associate some quality information to the saturation, maybe the bcid to provenance
cell->setQuality((unsigned short)saturation);
new_scell_cont->push_back( std::move(cell) );
}
ATH_CHECK( scellContainerHandle.record( std::move(new_scell_cont) ) );
return StatusCode::SUCCESS;
}
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
/**
* Name : LArRAWtoSuperCell.h
* PACKAGE : LArCalorimeter/LArROD
*
* AUTHOR : Denis Oliveira Damazio
*
* PURPOSE : prepares SuperCellContainer in CaloCellContainer type from RAW SC type
*
* **/
#ifndef LARCELL_LARRAWTOSUPERCELL
#define LARCELL_LARRAWTOSUPERCELL
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "StoreGate/WriteHandleKey.h"
#include "CaloEvent/CaloCellContainer.h"
#include "LArRawEvent/LArRawSCContainer.h"
class LArOnline_SuperCellID;
class LArOnOffIdMapping;
class CaloSuperCellDetDescrManager;
class LArRAWtoSuperCell : public AthReentrantAlgorithm
{
public :
LArRAWtoSuperCell( const std::string& name, ISvcLocator* pSvcLocator);
virtual ~LArRAWtoSuperCell() { }
StatusCode initialize();
StatusCode finalize() { return StatusCode::SUCCESS;}
StatusCode execute(const EventContext& context) const;
private:
/// Property: SG key for the input calorimeter cell container.
SG::ReadHandleKey<LArRawSCContainer> m_sCellContainerInKey
{ this, "SCellContainerIn", "SC_ET",
"SG key for the input supercell LAr channel container"};
/// Property: SG key for the output supercell LAr channel container.
SG::WriteHandleKey<CaloCellContainer> m_sCellContainerOutKey
{ this, "SCellContainerOut", "SCell_ET",
"SG key for the output supercell LAr channel container"};
/// Geometry manager.
SG::ReadCondHandleKey<CaloSuperCellDetDescrManager> m_caloMgrKey
{this, "CaloSuperCellDetDescrManager", "CaloSuperCellDetDescrManager", "SG Key for CaloDetDescrManager in the Condition Store" };
//Identifier helper
const LArOnline_SuperCellID* m_laronline_id = nullptr;
};
#endif
......@@ -14,6 +14,7 @@
#include "../LArTimeVetoAlg.h"
#include "../LArCellContHVCorrTool.h"
#include "../LArHVFraction.h"
#include "../LArRAWtoSuperCell.h"
DECLARE_COMPONENT( LArNoisyROAlg )
DECLARE_COMPONENT( LArNonLinearity )
......@@ -31,3 +32,4 @@ DECLARE_COMPONENT( LArCollisionTimeAlg )
DECLARE_COMPONENT( LArTimeVetoAlg )
DECLARE_COMPONENT( LArCellContHVCorrTool )
DECLARE_COMPONENT( LArHVFraction )
DECLARE_COMPONENT( LArRAWtoSuperCell )
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