diff --git a/Calorimeter/CaloCalibHitRec/CMakeLists.txt b/Calorimeter/CaloCalibHitRec/CMakeLists.txt index 3967244aaa3fa2d56bf6305ff07b944b38d7780a..af911c58dec1024241402323c3bd3a8b50ad2936 100644 --- a/Calorimeter/CaloCalibHitRec/CMakeLists.txt +++ b/Calorimeter/CaloCalibHitRec/CMakeLists.txt @@ -32,6 +32,13 @@ atlas_depends_on_subdirs( PUBLIC # External dependencies: find_package( CLHEP ) +# Component(s) in the package: +atlas_add_library( CaloCalibHitRecLib + src/*.cxx + PUBLIC_HEADERS CaloCalibHitRec + INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} + LINK_LIBRARIES ${CLHEP_LIBRARIES} CaloDmDetDescr CaloGeoHelpers CaloIdentifier CaloRecLib CaloSimEvent AthenaBaseComps StoreGateLib SGtests Identifier xAODCaloEvent xAODTruth GaudiKernel CaloDetDescrLib CaloEvent AthenaKernel AtlasDetDescr LArRecEvent McParticleEvent TileEvent PathResolver CxxUtils ) + # Component(s) in the package: atlas_add_component( CaloCalibHitRec src/*.cxx diff --git a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CalibHitIDCheck.h b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CalibHitIDCheck.h index 7b79ceb45969393976f9be8fffd5c8c22025729c..9efc0a97bd3229c069745d61c105c887aca0392b 100755 --- a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CalibHitIDCheck.h +++ b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CalibHitIDCheck.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //*********************************************************************** diff --git a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CalibHitToCaloCell.h b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CalibHitToCaloCell.h index d3ab7413a4329f795e796516639d424955d820f3..6182688974af977bfcc307a69c32442c62c06981 100755 --- a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CalibHitToCaloCell.h +++ b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CalibHitToCaloCell.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //**************************************************************************** diff --git a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CalibHitToCaloCellTool.h b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CalibHitToCaloCellTool.h new file mode 100755 index 0000000000000000000000000000000000000000..cc9694dbddc8adb54e99ccdf0bd6be5b0fb77d28 --- /dev/null +++ b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CalibHitToCaloCellTool.h @@ -0,0 +1,95 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +// ***************************************************************************** +// CalibHitToCaloCellTool.h +// Ioannis Nomidis <ioannis.nomidis@cern.ch> +// Dec 2016 +// Convert energy deposits from calibration hits to CaloCell, xAOD::CaloCluster +// ***************************************************************************** +#ifndef CalibHitToCaloCellTool_H +#define CalibHitToCaloCellTool_H + +//#include "AthenaBaseComps/AthAlgorithm.h" +#include "AthenaBaseComps/AthAlgTool.h" + +#include "xAODCaloEvent/CaloClusterContainer.h" + +#include <string> +#include <vector> + +class CaloCell_ID; +class CaloDM_ID; +class TileID; +class LArEM_ID; +class LArHEC_ID; +class LArFCAL_ID; + +class CaloCell; +class CaloDetDescrManager; +class CaloCellContainer; + +static const InterfaceID IID_CalibHitToCaloCellTool("CalibHitToCaloCellTool", 1, 0); + +namespace CalibHitUtils { + enum EnergyType { EnergyEM=0, EnergyVisible, EnergyTotal, nEnergyTypes }; +} + +class CalibHitToCaloCellTool: virtual public AthAlgTool { + + public: + CalibHitToCaloCellTool(const std::string& t, const std::string& n, const IInterface* p); + ~CalibHitToCaloCellTool(); + StatusCode initialize(); + StatusCode processCalibHitsFromParticle(int barcode=-1) const; + StatusCode finalize(); + + static const InterfaceID& interfaceID() { return IID_CalibHitToCaloCellTool;} + + // inline CaloCellContainer* getTruthCellsCont(CalibHitUtils::EnergyType type) {return m_truthCells[(int)type];} + // inline xAOD::CaloClusterContainer* getTruthClustersCont(CalibHitUtils::EnergyType type) {return m_truthClusters[(int)type];} + + private: + int m_caloGain; + std::vector<std::string> m_calibHitContainerNames; + bool m_writeTruthCellContainers; + bool m_writeTruthClusterContainers; + int m_singleParticleBarcode; + + std::string m_tileActiveHitCnt; + std::string m_tileInactiveHitCnt; + std::string m_tileDMHitCnt; + std::string m_larInactHitCnt; + std::string m_larActHitCnt; + std::string m_larDMHitCnt; + + bool m_store_Tot; + bool m_store_Vis; + bool m_store_Em; + bool m_store_NonEm; + bool m_storeUnknown; + + bool m_doTile; + + std::string m_caloCell_Tot; + std::string m_caloCell_Vis; + std::string m_caloCell_Em; + std::string m_caloCell_NonEm; + + const CaloCell_ID* m_caloCell_ID; + const CaloDM_ID* m_caloDM_ID; + //const TileID* m_tile_ID; + //const LArEM_ID* m_larEm_ID; + //const LArHEC_ID* m_larHec_ID; + //const LArFCAL_ID* m_larFcal_ID; + + const CaloDetDescrManager* m_caloDDMgr; + + std::string m_outputCellContainerName; + std::string m_outputClusterContainerName; + + +}; + +#endif diff --git a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloCalibClusterMomentsMaker.h b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloCalibClusterMomentsMaker.h index e203bf91f2d266598dfd0fb12320e4396107d747..afe4b0a81278fe04644b774126901d4315369282 100644 --- a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloCalibClusterMomentsMaker.h +++ b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloCalibClusterMomentsMaker.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef CALOCALIBCLUSTERMOMENTSMAKER_H diff --git a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloCalibClusterMomentsMaker2.h b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloCalibClusterMomentsMaker2.h index 0ade45821d0f377e0866791d53e8b3c00e2aa8b4..84cce4bca2b670f0fcb8e23b98f3468fac8f0d07 100644 --- a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloCalibClusterMomentsMaker2.h +++ b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloCalibClusterMomentsMaker2.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef CALOCALIBCLUSTERMOMENTSMAKER2_H diff --git a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloCalibDefineTypes.h b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloCalibDefineTypes.h index 1cb37fd1a0ccc0ea91955767dd456ced5768204d..9c8391d557aaa7d9240bfb26d41308b04072deca 100644 --- a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloCalibDefineTypes.h +++ b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloCalibDefineTypes.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef CALOCALIBDEFINETYPES_H diff --git a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloDmEnergy.h b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloDmEnergy.h index f5cca40646f0a8f00c429b290a769c883d864158..77d6c8160b0bd8516d3d6bb816afc88c07930fa2 100644 --- a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloDmEnergy.h +++ b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloDmEnergy.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /* **************************************************************************** diff --git a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloDmNeighbours.h b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloDmNeighbours.h index 496a7e13f81357f3c6544ed1d576b5878865b1cc..39f2f794352ce939c4bc24936fe4e52c64a6ea9f 100644 --- a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloDmNeighbours.h +++ b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/CaloDmNeighbours.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /* **************************************************************************** diff --git a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/ICaloCalibClusterTruthAttributerTool.h b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/ICaloCalibClusterTruthAttributerTool.h index 34a5c29d37766ddf9eee1e0a5d13af2fdd5535c0..7da4b5bb75829553c701fc2463cfb1a2e4a23586 100644 --- a/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/ICaloCalibClusterTruthAttributerTool.h +++ b/Calorimeter/CaloCalibHitRec/CaloCalibHitRec/ICaloCalibClusterTruthAttributerTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef ICALOCALIBCLUSTERTRUTHATTRIBUTERTOOL_H diff --git a/Calorimeter/CaloCalibHitRec/src/CalibHitToCaloCellTool.cxx b/Calorimeter/CaloCalibHitRec/src/CalibHitToCaloCellTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d3a419b00fe10939c0dcbbcbfde37cc13caed99f --- /dev/null +++ b/Calorimeter/CaloCalibHitRec/src/CalibHitToCaloCellTool.cxx @@ -0,0 +1,311 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "CaloCalibHitRec/CalibHitToCaloCellTool.h" + +//Gaudi Includes +#include "StoreGate/StoreGateSvc.h" + +// Calo include +#include "CaloIdentifier/CaloDM_ID.h" +#include "CaloIdentifier/CaloCell_ID.h" +#include "CaloIdentifier/CaloGain.h" +#include "CaloSimEvent/CaloCalibrationHitContainer.h" +#include "CaloEvent/CaloCellContainer.h" +#include "CaloDetDescr/CaloDetDescrManager.h" +#include "CaloDetDescr/CaloDetDescrElement.h" + +#include "CaloUtils/CaloClusterStoreHelper.h" +#include "xAODCaloEvent/CaloClusterKineHelper.h" + +#include "LArRecEvent/LArCell.h" +#include "TileEvent/TileCell.h" + + +CalibHitToCaloCellTool::CalibHitToCaloCellTool(const std::string& t, const std::string& n, const IInterface* p) + : AthAlgTool(t,n,p), + m_caloGain((int)CaloGain::LARLOWGAIN), + m_store_Tot(false), + m_store_Vis(false), + m_store_Em(false), + m_store_NonEm(false), + m_caloCell_Tot("TotalCalibCell"), m_caloCell_Vis("VisCalibCell"), + m_caloCell_Em(""), m_caloCell_NonEm(""), + m_caloCell_ID(0), + m_caloDM_ID(0), + m_caloDDMgr(0) +{ + declareInterface<CalibHitToCaloCellTool>(this); + + declareProperty("CaloGain", m_caloGain); + declareProperty("CalibHitContainers", m_calibHitContainerNames); + declareProperty("SingleParticleBarcode", m_singleParticleBarcode = 10001); + + declareProperty("CellTotEne", m_caloCell_Tot); + declareProperty("CellVisEne", m_caloCell_Vis); + declareProperty("CellEmEne", m_caloCell_Em); + declareProperty("CellNonEmEne", m_caloCell_NonEm); + declareProperty("DoTile", m_doTile=false); + + declareProperty("OutputCellContainerName", m_outputCellContainerName = "TruthCells"); + declareProperty("OutputClusterContainerName", m_outputClusterContainerName = "TruthClusters"); + declareProperty("WriteTruthCellContainers", m_writeTruthCellContainers=false); + declareProperty("WriteTruthClusterContainers", m_writeTruthClusterContainers=false); + + m_tileActiveHitCnt = "TileCalibHitActiveCell"; + m_tileInactiveHitCnt = "TileCalibHitInactiveCell"; + m_tileDMHitCnt = "TileCalibHitDeadMaterial"; + m_larActHitCnt = "LArCalibrationHitActive"; + m_larInactHitCnt = "LArCalibrationHitInactive"; + m_larDMHitCnt = "LArCalibrationHitDeadMaterial"; + +} + + +CalibHitToCaloCellTool::~CalibHitToCaloCellTool() {} + + +//////////////// INITIALIZE /////////////////////// +StatusCode CalibHitToCaloCellTool::initialize() +{ + // retrieve ID helpers from det store + ATH_MSG_INFO("initialisation ID helpers" ); + + ATH_CHECK( detStore()->retrieve(m_caloCell_ID) ); + ATH_CHECK( detStore()->retrieve(m_caloDM_ID) ); + ATH_CHECK( detStore()->retrieve(m_caloDDMgr, "CaloMgr") ); + + ATH_MSG_INFO("initialisation completed" ); + return StatusCode::SUCCESS; +} + + +///////////////// EXECUTE ////////////////////// +StatusCode CalibHitToCaloCellTool::processCalibHitsFromParticle(int barcode) const +{ + ATH_MSG_DEBUG("in calibHitToCaloCellTool"); + + std::string EnergyTypeToStr[] = {"Eem","Evis","Etot"}; + + //protection - tool should run once per event + if (evtStore()->contains<CaloCellContainer>((m_outputCellContainerName+EnergyTypeToStr[0]).c_str()) && + evtStore()->contains<xAOD::CaloClusterContainer>((m_outputClusterContainerName+EnergyTypeToStr[0]).c_str())) { + ATH_MSG_DEBUG("containers for truth calo cells and truth clusters already exist"); + return StatusCode::SUCCESS; + } + + CaloCellContainer* truthCells[3]; + xAOD::CaloClusterContainer* truthClusters[3]; + + // register containers for cells and clusters + for (unsigned int i=0; i<CalibHitUtils::nEnergyTypes; i++) { + truthCells[i] = new CaloCellContainer(); + truthClusters[i] = CaloClusterStoreHelper::makeContainer(&(*evtStore()),(m_outputClusterContainerName+EnergyTypeToStr[i]).c_str(),msg()); + if (!truthClusters[i]) { + ATH_MSG_FATAL("Cannot make cluster container"); + return StatusCode::FAILURE; + } + } + + // retrieve calibration hit containers + const unsigned int nCont = m_calibHitContainerNames.size(); + std::vector<const CaloCalibrationHitContainer*> calibHitContainers(nCont,0); + for (unsigned int i=0; i<nCont; i++) { + ATH_MSG_DEBUG("Retrieving " << m_calibHitContainerNames[i]); + ATH_CHECK( evtStore()->retrieve(calibHitContainers[i], m_calibHitContainerNames[i].c_str()) ); + ATH_MSG_DEBUG(" Retrieved container " << calibHitContainers[i]->Name() << " with size " << calibHitContainers[i]->Size() ); + if( calibHitContainers[i]->Size() == 0 ) { + ATH_MSG_DEBUG("Container " << calibHitContainers[i]->Name() << " is empty"); + } + } + ATH_MSG_DEBUG("CaloCalibrationHitContainers retrieved successfuly" ); + + //count + int nchan=0; + int em_nchan=0; + int hec_nchan=0; + int fcal_nchan=0; + int tile_nchan=0; + int unknown_nchan = 0 ; + + std::vector<Identifier> ID; + if (barcode<0) barcode = m_singleParticleBarcode; // if no barcode is specified for this event, use the default + + + std::vector<CaloCell*> CellsEtot; + std::vector<CaloCell*> CellsEvis; + std::vector<CaloCell*> CellsEem; + + int nhitsInactive = 0; + + for (unsigned int i=0; i<calibHitContainers.size(); i++) { + for( const auto calibhit: *(calibHitContainers[i])) { + //care only for deposits of the given truth particle + if ((int)calibhit->particleID()!=barcode) continue; + + double Etot = calibhit->energyTotal(); + double Eem = calibhit->energy(0); + double Enonem = calibhit->energy(1); + double Evis = Eem + Enonem; + + Identifier id=calibhit->cellID(); + + //merge inactive and active hits from the same cell together + if (i>0) { + //find if have already created cell.. + bool isNewId = true; + for (int n=0; n<nhitsInactive; n++) { + if( id == ID[n] ) { //found + CellsEtot[n]->addEnergy(Etot); + CellsEvis[n]->addEnergy(Evis); + CellsEem[n]->addEnergy(Eem); + isNewId = false; + break; + } + } + if(!isNewId) continue; //go to next hit, else create new cell for this hit + } + + //check if this ID is LAr or Tile + if(m_caloCell_ID->is_lar(id)) { + ATH_MSG_VERBOSE( "Found LAr cell" ); + const CaloDetDescrElement* caloDDE = m_caloDDMgr->get_element(id); + CellsEtot.push_back(new LArCell(caloDDE, id, Etot, 0., 0, 0, (CaloGain::CaloGain)m_caloGain)) ; + CellsEvis.push_back(new LArCell(caloDDE, id, Evis, 0., 0, 0, (CaloGain::CaloGain)m_caloGain)); + CellsEem.push_back(new LArCell(caloDDE, id, Eem, 0., 0, 0, (CaloGain::CaloGain)m_caloGain)); + ID.push_back(id); + ++nchan; + } + else if(m_caloCell_ID->is_tile(id)) { + ATH_MSG_VERBOSE( "Found Tile cell" ); + const CaloDetDescrElement* caloDDE = m_caloDDMgr->get_element(id); + CellsEtot.push_back(new TileCell(caloDDE, id, Etot, 0., 0, 0, (CaloGain::CaloGain)m_caloGain)) ; + CellsEvis.push_back(new TileCell(caloDDE, id, Evis, 0., 0, 0, (CaloGain::CaloGain)m_caloGain)); + CellsEem.push_back(new TileCell(caloDDE, id, Eem, 0., 0, 0, (CaloGain::CaloGain)m_caloGain)); + ID.push_back(id); + ++nchan; + } + else { //other, DeadMaterial + //// FIXME DeadMaterial deposits not used; need to use m_caloDDMg; + ATH_MSG_VERBOSE( "Found unknown cell" ); + continue; + } + } + if (i==0) nhitsInactive = (int)ID.size(); + } + + //Now, put cells in the containers keeping the order. First goes EM, then HEC and so on + // if(CellsEtot.size()==0) { + // ID.clear(); + // return StatusCode::SUCCESS; + // } + + ATH_MSG_DEBUG("N cells : " << nchan ); + + for(int itr=0; itr!=nchan; itr++) { + if(m_caloCell_ID->is_em(CellsEtot[itr]->ID())) { + truthCells[CalibHitUtils::EnergyTotal]->push_back(CellsEtot[itr]); + truthCells[CalibHitUtils::EnergyVisible]->push_back(CellsEvis[itr]); + truthCells[CalibHitUtils::EnergyEM]->push_back(CellsEem[itr]); + ++em_nchan; + } + } + if(em_nchan) { + for (int i=0;i<CalibHitUtils::nEnergyTypes;i++) truthCells[i]->setHasCalo(CaloCell_ID::LAREM); + } + + for(int itr=0; itr!=nchan; itr++) { + if(m_caloCell_ID->is_hec(CellsEtot[itr]->ID())) { + truthCells[CalibHitUtils::EnergyTotal]->push_back(CellsEtot[itr]); + truthCells[CalibHitUtils::EnergyVisible]->push_back(CellsEvis[itr]); + truthCells[CalibHitUtils::EnergyEM]->push_back(CellsEem[itr]); + ++hec_nchan; + } + } + if(hec_nchan){ + for (int i=0;i<CalibHitUtils::nEnergyTypes;i++) truthCells[i]->setHasCalo(CaloCell_ID::LARHEC); + } + + for(int itr=0; itr!=nchan; itr++) { + if(m_caloCell_ID->is_fcal(CellsEtot[itr]->ID())) { + truthCells[CalibHitUtils::EnergyTotal]->push_back(CellsEtot[itr]); + truthCells[CalibHitUtils::EnergyVisible]->push_back(CellsEvis[itr]); + truthCells[CalibHitUtils::EnergyEM]->push_back(CellsEem[itr]); + ++fcal_nchan; + } + } + if(fcal_nchan) { + for (int i=0;i<CalibHitUtils::nEnergyTypes;i++) truthCells[i]->setHasCalo(CaloCell_ID::LARFCAL); + } + + for(int itr=0; itr!=nchan; itr++) { + if((m_caloCell_ID->is_tile(CellsEtot[itr]->ID()))) { + truthCells[CalibHitUtils::EnergyTotal]->push_back(CellsEtot[itr]); + truthCells[CalibHitUtils::EnergyVisible]->push_back(CellsEvis[itr]); + truthCells[CalibHitUtils::EnergyEM]->push_back(CellsEem[itr]); + ++tile_nchan; + } + } + if(tile_nchan) { + for (int i=0;i<CalibHitUtils::nEnergyTypes;i++) truthCells[i]->setHasCalo(CaloCell_ID::TILE); + } + if(unknown_nchan) { + for (int i=0;i<CalibHitUtils::nEnergyTypes;i++) truthCells[i]->setHasCalo(CaloCell_ID::NOT_VALID); + } + ATH_MSG_DEBUG("--- LAr INFO --- "<<nchan ); + ATH_MSG_DEBUG("LArCells = "<<nchan ); + ATH_MSG_DEBUG("EMCells = "<<em_nchan ); + ATH_MSG_DEBUG("HECCells = "<<hec_nchan ); + ATH_MSG_DEBUG("FCALCells = "<<fcal_nchan ); + ATH_MSG_DEBUG("TileCells = "<<tile_nchan ); + ATH_MSG_DEBUG("NOT_VALID = "<<unknown_nchan ); + + ID.clear(); + + ///.......................................................... + + ATH_MSG_DEBUG("making truth cluster"); + xAOD::CaloCluster* truthCluster[3] = {0,0,0}; + for (int i=0;i<CalibHitUtils::nEnergyTypes;i++) { + truthCluster[i] = CaloClusterStoreHelper::makeCluster(truthClusters[i],truthCells[i]); + if (!truthCluster[i]) { + ATH_MSG_FATAL("makeCluster failed"); + return StatusCode::FAILURE; + } + for (const auto cell: *truthCells[i]) { + if(m_caloCell_ID->is_lar(cell->ID()) || m_caloCell_ID->is_tile(cell->ID())) + truthCluster[i]->addCell( truthCells[i]->findIndex(cell->caloDDE()->calo_hash()) , 1.); + } + + truthCluster[i]->setClusterSize(xAOD::CaloCluster::CSize_Unknown); + CaloClusterKineHelper::calculateKine(truthCluster[i], true, true); + ATH_MSG_INFO("Created truth cluster with " << EnergyTypeToStr[i] <<" " << truthCluster[i]->e()); + } + + // record containers + if (m_writeTruthCellContainers) { + for (int i=0;i<3;i++) { + ATH_MSG_DEBUG("recording truth cells container for " << EnergyTypeToStr[i] <<" deposits, size: " << truthCells[i]->size()); + ATH_CHECK(evtStore()->record(truthCells[i], (m_outputCellContainerName+EnergyTypeToStr[i]).c_str())); + } + } + if (m_writeTruthClusterContainers) { + for (int i=0;i<3;i++) { + ATH_MSG_DEBUG("finalizing truth cluster"); + ATH_CHECK( CaloClusterStoreHelper::finalizeClusters(&*evtStore(), truthClusters[i], (m_outputClusterContainerName+EnergyTypeToStr[i]).c_str(), msg()) ); + } + } + + ATH_MSG_DEBUG("execute() completed successfully" ); + return StatusCode::SUCCESS; +} + + +///////////////// FINALIZE ////////////////////// +StatusCode CalibHitToCaloCellTool::finalize() +{ + ATH_MSG_INFO("finalize() successfully" ); + return StatusCode::SUCCESS; +} + diff --git a/Calorimeter/CaloCalibHitRec/src/components/CaloCalibHitRec_entries.cxx b/Calorimeter/CaloCalibHitRec/src/components/CaloCalibHitRec_entries.cxx index 8393dee680f7bde0aeb22a9561e99f99c0e031dc..4a07247dfda85cd021c08400752d18b4ae131404 100644 --- a/Calorimeter/CaloCalibHitRec/src/components/CaloCalibHitRec_entries.cxx +++ b/Calorimeter/CaloCalibHitRec/src/components/CaloCalibHitRec_entries.cxx @@ -5,6 +5,8 @@ #include "CaloCalibHitRec/CaloCalibClusterTruthAttributerTool.h" #include "../CaloCalibClusterTruthMapMakerAlgorithm.h" #include "../CaloCalibClusterDecoratorAlgorithm.h" +#include "CaloCalibHitRec/CalibHitToCaloCellTool.h" + DECLARE_COMPONENT( CalibHitToCaloCell ) DECLARE_COMPONENT( CalibHitIDCheck ) @@ -14,3 +16,6 @@ DECLARE_COMPONENT( CaloCalibClusterMomentsMaker2 ) DECLARE_COMPONENT( CaloCalibClusterTruthAttributerTool ) DECLARE_COMPONENT( CaloCalibClusterTruthMapMakerAlgorithm ) DECLARE_COMPONENT( CaloCalibClusterDecoratorAlgorithm ) +DECLARE_COMPONENT( CalibHitToCaloCellTool ) + +