Skip to content
Snippets Groups Projects
Commit 46c0ca69 authored by James Beacham's avatar James Beacham Committed by Atlas Nightlybuild
Browse files

Merge branch '21.0-FastCaloSim-dev' into '21.0'

21.0-FastCaloSim: Created class TFCSHistoLateralShapeParametrizationFCal (ATLASSIM-3927)

See merge request atlas/athena!16158

(cherry picked from commit 66eb48ab2c02b013a09909e8b9deb01621db6c13)

5c6d9b75 Created class TFCSHistoLateralShapeParametrizationFCal
7af2178d Changing inheratence: TFCSHistoLateralShapeParametrizationFCal inherits from…
67242fa5 Changing inheratence: TFCSHistoLateralShapeParametrizationFCal inherits from…
5a765fca Removing Print function and redundant includes
parent 73fe5d78
No related branches found
No related tags found
No related merge requests found
File mode changed from 100644 to 100755
...@@ -61,6 +61,7 @@ atlas_add_root_dictionary( ISF_FastCaloSimEvent _dictSource ...@@ -61,6 +61,7 @@ atlas_add_root_dictionary( ISF_FastCaloSimEvent _dictSource
ISF_FastCaloSimEvent/TFCSLateralShapeParametrizationHitChain.h ISF_FastCaloSimEvent/TFCSLateralShapeParametrizationHitChain.h
ISF_FastCaloSimEvent/TFCSCenterPositionCalculation.h ISF_FastCaloSimEvent/TFCSCenterPositionCalculation.h
ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrization.h ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrization.h
ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrizationFCal.h
ISF_FastCaloSimEvent/TFCSLateralShapeParametrizationHitNumberFromE.h ISF_FastCaloSimEvent/TFCSLateralShapeParametrizationHitNumberFromE.h
ISF_FastCaloSimEvent/TFCSHitCellMapping.h ISF_FastCaloSimEvent/TFCSHitCellMapping.h
ISF_FastCaloSimEvent/TFCSHitCellMappingFCal.h ISF_FastCaloSimEvent/TFCSHitCellMappingFCal.h
......
/* /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/ */
#include "ISF_FastCaloSimEvent/DoubleArray.h" #include "ISF_FastCaloSimEvent/DoubleArray.h"
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "ISF_FastCaloSimEvent/TFCSLateralShapeParametrizationHitChain.h" #include "ISF_FastCaloSimEvent/TFCSLateralShapeParametrizationHitChain.h"
#include "ISF_FastCaloSimEvent/TFCSCenterPositionCalculation.h" #include "ISF_FastCaloSimEvent/TFCSCenterPositionCalculation.h"
#include "ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrization.h" #include "ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrization.h"
#include "ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrizationFCal.h"
#include "ISF_FastCaloSimEvent/TFCSLateralShapeParametrizationHitNumberFromE.h" #include "ISF_FastCaloSimEvent/TFCSLateralShapeParametrizationHitNumberFromE.h"
#include "ISF_FastCaloSimEvent/TFCSHitCellMapping.h" #include "ISF_FastCaloSimEvent/TFCSHitCellMapping.h"
#include "ISF_FastCaloSimEvent/TFCSHitCellMappingFCal.h" #include "ISF_FastCaloSimEvent/TFCSHitCellMappingFCal.h"
...@@ -148,6 +149,7 @@ ...@@ -148,6 +149,7 @@
#pragma link C++ class TFCSLateralShapeParametrizationHitChain+; #pragma link C++ class TFCSLateralShapeParametrizationHitChain+;
#pragma link C++ class TFCSCenterPositionCalculation+; #pragma link C++ class TFCSCenterPositionCalculation+;
#pragma link C++ class TFCSHistoLateralShapeParametrization+; #pragma link C++ class TFCSHistoLateralShapeParametrization+;
#pragma link C++ class TFCSHistoLateralShapeParametrizationFCal+;
#pragma link C++ class TFCSLateralShapeParametrizationHitNumberFromE+; #pragma link C++ class TFCSLateralShapeParametrizationHitNumberFromE+;
#pragma link C++ class TFCSHitCellMapping+; #pragma link C++ class TFCSHitCellMapping+;
#pragma link C++ class TFCSHitCellMappingFCal+; #pragma link C++ class TFCSHitCellMappingFCal+;
......
...@@ -45,11 +45,13 @@ public: ...@@ -45,11 +45,13 @@ public:
const TFCS2DFunctionHistogram& histogram() const {return m_hist;}; const TFCS2DFunctionHistogram& histogram() const {return m_hist;};
void Print(Option_t *option = "") const override; void Print(Option_t *option = "") const override;
private: protected:
/// Histogram to be used for the shape simulation /// Histogram to be used for the shape simulation
TFCS2DFunctionHistogram m_hist; TFCS2DFunctionHistogram m_hist;
float m_nhits; float m_nhits;
private:
ClassDefOverride(TFCSHistoLateralShapeParametrization,1) //TFCSHistoLateralShapeParametrization ClassDefOverride(TFCSHistoLateralShapeParametrization,1) //TFCSHistoLateralShapeParametrization
}; };
......
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TFCSHistoLateralShapeParametrizationFCal_h
#define TFCSHistoLateralShapeParametrizationFCal_h
#include "ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrization.h"
#include "ISF_FastCaloSimEvent/TFCS2DFunctionHistogram.h"
class TH2;
class TFCSHistoLateralShapeParametrizationFCal:public TFCSHistoLateralShapeParametrization {
public:
TFCSHistoLateralShapeParametrizationFCal(const char* name=nullptr, const char* title=nullptr);
~TFCSHistoLateralShapeParametrizationFCal();
virtual FCSReturnCode simulate_hit(Hit& hit,TFCSSimulationState& simulstate,const TFCSTruthState* truth, const TFCSExtrapolationState* extrapol) override;
private:
ClassDefOverride(TFCSHistoLateralShapeParametrizationFCal,1) //TFCSHistoLateralShapeParametrizationFCal
};
#if defined(__ROOTCLING__) && defined(__FastCaloSimStandAlone__)
#pragma link C++ class TFCSHistoLateralShapeParametrizationFCal+;
#endif
#endif
...@@ -93,10 +93,9 @@ FCSReturnCode TFCSHistoLateralShapeParametrization::simulate_hit(Hit &hit, TFCSS ...@@ -93,10 +93,9 @@ FCSReturnCode TFCSHistoLateralShapeParametrization::simulate_hit(Hit &hit, TFCSS
const float delta_eta = delta_eta_mm / eta_jakobi / dist000; const float delta_eta = delta_eta_mm / eta_jakobi / dist000;
const float delta_phi = delta_phi_mm / center_r; const float delta_phi = delta_phi_mm / center_r;
hit.eta() = center_eta + delta_eta; hit.setEtaPhiZE(center_eta + delta_eta,center_phi + delta_phi,center_z, hit.E());
hit.phi() = center_phi + delta_phi;
ATH_MSG_DEBUG("HIT: E="<<hit.E()<<" cs="<<cs<<" eta="<<hit.eta()<<" phi="<<hit.phi()<<" r="<<r<<" alpha="<<alpha); ATH_MSG_DEBUG("HIT: E="<<hit.E()<<" cs="<<cs<<" eta="<<hit.eta()<<" phi="<<hit.phi()<< " z="<<hit.z()<<" r="<<r<<" alpha="<<alpha);
return FCSSuccess; return FCSSuccess;
} }
......
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#include "CLHEP/Random/RandFlat.h"
#include "CLHEP/Random/RandPoisson.h"
#include "ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrizationFCal.h"
#include "ISF_FastCaloSimEvent/TFCSSimulationState.h"
#include "ISF_FastCaloSimEvent/TFCSExtrapolationState.h"
#include "TMath.h"
//=============================================
//======= TFCSHistoLateralShapeParametrizationFCal =========
//=============================================
TFCSHistoLateralShapeParametrizationFCal::TFCSHistoLateralShapeParametrizationFCal(const char* name, const char* title) :
TFCSHistoLateralShapeParametrization(name,title)
{
}
TFCSHistoLateralShapeParametrizationFCal::~TFCSHistoLateralShapeParametrizationFCal()
{
}
FCSReturnCode TFCSHistoLateralShapeParametrizationFCal::simulate_hit(Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState* /*truth*/, const TFCSExtrapolationState* extrapol)
{
if (!simulstate.randomEngine()) {
return FCSFatal;
}
const int cs=calosample();
const double center_phi=0.5*( extrapol->phi(cs, CaloSubPos::SUBPOS_ENT) + extrapol->phi(cs, CaloSubPos::SUBPOS_EXT) );
const double center_r=0.5*( extrapol->r(cs, CaloSubPos::SUBPOS_ENT) + extrapol->r(cs, CaloSubPos::SUBPOS_EXT) );
const double center_z=0.5*( extrapol->z(cs, CaloSubPos::SUBPOS_ENT) + extrapol->z(cs, CaloSubPos::SUBPOS_EXT) );
const double center_x=center_r*cos(center_phi);
const double center_y=center_r*sin(center_phi);
float alpha, r, rnd1, rnd2;
rnd1 = CLHEP::RandFlat::shoot(simulstate.randomEngine());
rnd2 = CLHEP::RandFlat::shoot(simulstate.randomEngine());
if(is_phi_symmetric()) {
if(rnd2>=0.5) { //Fill negative phi half of shape
rnd2-=0.5;
rnd2*=2;
m_hist.rnd_to_fct(alpha,r,rnd1,rnd2);
alpha=-alpha;
} else { //Fill positive phi half of shape
rnd2*=2;
m_hist.rnd_to_fct(alpha,r,rnd1,rnd2);
}
} else {
m_hist.rnd_to_fct(alpha,r,rnd1,rnd2);
}
if(TMath::IsNaN(alpha) || TMath::IsNaN(r)) {
ATH_MSG_ERROR(" Histogram: "<<m_hist.get_HistoBordersx().size()-1<<"*"<<m_hist.get_HistoBordersy().size()-1<<" bins, #hits="<<m_nhits<<" alpha="<<alpha<<" r="<<r<<" rnd1="<<rnd1<<" rnd2="<<rnd2);
alpha=0;
r=0.001;
ATH_MSG_ERROR(" This error could probably be retried");
return FCSFatal;
}
const float delta_x = r * cos(alpha);
const float delta_y = r * sin(alpha);
hit.setXYZE(center_x+delta_x,center_y+delta_y,center_z,hit.E());
ATH_MSG_DEBUG("HIT: E="<<hit.E()<<" cs="<<cs<<" x="<<hit.x()<<" y="<<hit.y()<<" z="<<hit.z()<<" r=" << r <<" alpha="<<alpha);
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