Skip to content
Snippets Groups Projects
Commit efd9638c authored by John Kenneth Anders's avatar John Kenneth Anders
Browse files

Merge branch 'FastCaloSim_cell_energy_renormalization' into '21.0'

Add class to renormalize cell energies to the energy simulation after the lateral shape simulation

See merge request atlas/athena!23922
parents d2a76ec0 9998069d
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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+;
......
/*
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"
/** The class TFCSEnergyRenormalization ensures that the sum of cell energies in every calorimeter layer
matches the output of energy simulation
*/
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
/*
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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment