From 2126cd401d4b02b228efad0ce5a85fb4e0038879 Mon Sep 17 00:00:00 2001 From: Michael Duehrssen <michael.duehrssen@cern.ch> Date: Tue, 29 May 2018 13:54:56 +0200 Subject: [PATCH] Add option to simulate lateral shapes from a phi symmetric histogram parametrization Former-commit-id: 9c7f794d015d508a6f43c972ffb149344eb2b25a --- .../TFCSHistoLateralShapeParametrization.h | 9 +++++++++ .../src/TFCSHistoLateralShapeParametrization.cxx | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrization.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrization.h index 22533c147ce..e7c96829bc3 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrization.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/ISF_FastCaloSimEvent/TFCSHistoLateralShapeParametrization.h @@ -15,6 +15,15 @@ public: TFCSHistoLateralShapeParametrization(const char* name=nullptr, const char* title=nullptr); ~TFCSHistoLateralShapeParametrization(); + ///Status bit for FCS needs + enum FCSStatusBits { + k_phi_symmetric = BIT(15) ///< Set this bit to simulate phi symmetric histograms + }; + + bool is_phi_symmetric() const {return TestBit(k_phi_symmetric);}; + virtual void set_phi_symmetric() {SetBit(k_phi_symmetric);}; + virtual void reset_phi_symmetric() {ResetBit(k_phi_symmetric);}; + /// set the integral of the histogram to the desired number of hits void set_number_of_hits(float nhits); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/src/TFCSHistoLateralShapeParametrization.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/src/TFCSHistoLateralShapeParametrization.cxx index 750c3f997fb..9c21a9a2f04 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/src/TFCSHistoLateralShapeParametrization.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent/src/TFCSHistoLateralShapeParametrization.cxx @@ -20,6 +20,7 @@ TFCSHistoLateralShapeParametrization::TFCSHistoLateralShapeParametrization(const char* name, const char* title) : TFCSLateralShapeParametrizationHitBase(name,title),m_nhits(0) { + reset_phi_symmetric(); } TFCSHistoLateralShapeParametrization::~TFCSHistoLateralShapeParametrization() @@ -49,7 +50,19 @@ void TFCSHistoLateralShapeParametrization::simulate_hit(Hit& hit,TFCSSimulationS //CLHEP should generate random numbers in (0,1), so this fudge is no longer needed after migrating to CLHEP random numbers rnd1=1-gRandom->Rndm(); rnd2=1-gRandom->Rndm(); - m_hist.rnd_to_fct(alpha,r,rnd1,rnd2); + 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; -- GitLab