diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/CMakeLists.txt b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/CMakeLists.txt index c4ee8f78b1ae3ddbd5873a0fdc81a645bb4897e8..8987393052a7cab80a8cf6373dc5928f6427f9e2 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/CMakeLists.txt +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/CMakeLists.txt @@ -76,6 +76,7 @@ atlas_add_root_dictionary( ISF_FastCaloSimEvent _dictSource ISF_FastCaloSimEvent/TFCSHitCellMappingFCal.h ISF_FastCaloSimEvent/TFCSHitCellMappingWiggle.h ISF_FastCaloSimEvent/TFCSHitCellMappingWiggleEMB.h + ISF_FastCaloSimEvent/TFCSEnergyRenormalization.h ISF_FastCaloSimEvent/TFCSExtrapolationState.h ISF_FastCaloSimEvent/TFCSSimulationState.h ISF_FastCaloSimEvent/TFCSTruthState.h diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/ISF_FastCaloSimEvent/LinkDef.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/ISF_FastCaloSimEvent/LinkDef.h index 53260840e54148fdfbc951de30eb62dae61d0e9d..cf6a205e893629cdbe3b52ac82dd201104e99580 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/ISF_FastCaloSimEvent/LinkDef.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/ISF_FastCaloSimEvent/LinkDef.h @@ -55,6 +55,7 @@ #include "ISF_FastCaloSimEvent/TFCSHitCellMappingFCal.h" #include "ISF_FastCaloSimEvent/TFCSHitCellMappingWiggle.h" #include "ISF_FastCaloSimEvent/TFCSHitCellMappingWiggleEMB.h" +#include "ISF_FastCaloSimEvent/TFCSEnergyRenormalization.h" #include "ISF_FastCaloSimEvent/TFCSTruthState.h" #include "ISF_FastCaloSimEvent/TFCSExtrapolationState.h" @@ -214,6 +215,7 @@ #pragma link C++ class TFCSHitCellMappingFCal+; #pragma link C++ class TFCSHitCellMappingWiggle+; #pragma link C++ class TFCSHitCellMappingWiggleEMB+; +#pragma link C++ class TFCSEnergyRenormalization+; #pragma link C++ class TFCSTruthState+; #pragma link C++ class TFCSExtrapolationState+; diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/ISF_FastCaloSimEvent/TFCSEnergyRenormalization.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/ISF_FastCaloSimEvent/TFCSEnergyRenormalization.h new file mode 100644 index 0000000000000000000000000000000000000000..8ad2994154bf23816c3d3b13aabe30e1570c40c7 --- /dev/null +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/ISF_FastCaloSimEvent/TFCSEnergyRenormalization.h @@ -0,0 +1,38 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ISF_FASTCALOSIMEVENT_TFCSEnergyRenormalization_h +#define ISF_FASTCALOSIMEVENT_TFCSEnergyRenormalization_h + +#include "ISF_FastCaloSimEvent/TFCSParametrization.h" + +class TFCSEnergyRenormalization:public TFCSParametrization { +public: + TFCSEnergyRenormalization(const char* name=nullptr, const char* title=nullptr); + virtual ~TFCSEnergyRenormalization(); + + virtual bool is_match_Ekin_bin(int /*Ekin_bin*/) const override; + virtual bool is_match_calosample(int /*calosample*/) const override; + + virtual FCSReturnCode simulate(TFCSSimulationState& simulstate,const TFCSTruthState* /*truth*/, const TFCSExtrapolationState* /*extrapol*/) override; +private: + + ClassDefOverride(TFCSEnergyRenormalization,1) //TFCSEnergyRenormalization +}; + +inline bool TFCSEnergyRenormalization::is_match_Ekin_bin(int /*Ekin_bin*/) const +{ + return true; +} + +inline bool TFCSEnergyRenormalization::is_match_calosample(int /*calosample*/) const +{ + return true; +} + +#if defined(__ROOTCLING__) && defined(__FastCaloSimStandAlone__) +#pragma link C++ class TFCSEnergyRenormalization+; +#endif + +#endif diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/src/TFCSEnergyRenormalization.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/src/TFCSEnergyRenormalization.cxx new file mode 100644 index 0000000000000000000000000000000000000000..daa099180361761fd5b151cb1fb5c44ac22a58cf --- /dev/null +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/src/TFCSEnergyRenormalization.cxx @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "ISF_FastCaloSimEvent/TFCSEnergyRenormalization.h" +#include "ISF_FastCaloSimEvent/TFCSSimulationState.h" +#include "ISF_FastCaloSimEvent/FastCaloSim_CaloCell_ID.h" +#include "CaloDetDescr/CaloDetDescrElement.h" + +//============================================= +//======= TFCSEnergyRenormalization ========= +//============================================= + +TFCSEnergyRenormalization::TFCSEnergyRenormalization(const char* name, const char* title):TFCSParametrization(name,title) +{ +} + +TFCSEnergyRenormalization::~TFCSEnergyRenormalization() +{ +} + +FCSReturnCode TFCSEnergyRenormalization::simulate(TFCSSimulationState& simulstate,const TFCSTruthState* /*truth*/, const TFCSExtrapolationState* /*extrapol*/) +{ + std::vector< float > energies(CaloCell_ID_FCS::MaxSample,0); + + //Loop over all cells and sum up energies + for(const auto& iter : simulstate.cells()) { + const CaloDetDescrElement* theDDE=iter.first; + int layer=theDDE->getSampling(); + energies[layer]+=iter.second; + } + + std::vector< float > scalefactor(CaloCell_ID_FCS::MaxSample,1); + + for(int layer=0;layer<CaloCell_ID_FCS::MaxSample;++layer) { + if(energies[layer]!=0) scalefactor[layer]=simulstate.E(layer)/energies[layer]; + } + + //Loop over all cells and apply the scalefactor + for(auto& iter : simulstate.cells()) { + const CaloDetDescrElement* theDDE=iter.first; + int layer=theDDE->getSampling(); + iter.second*=scalefactor[layer]; + } + + if(msgLvl(MSG::DEBUG)) { + ATH_MSG_DEBUG("Apply scale factors : "); + for (int layer=0;layer<CaloCell_ID_FCS::MaxSample;++layer) { + ATH_MSG_DEBUG(" "<<layer<<" *= "<<scalefactor[layer]<<" : "<<energies[layer]<<" -> "<<simulstate.E(layer)); + } + } + + return FCSSuccess; +} +