ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSBinnedShower Class Reference

#include <TFCSBinnedShower.h>

Inheritance diagram for TFCSBinnedShower:
Collaboration diagram for TFCSBinnedShower:

Classes

struct  layer_t
struct  event_t
struct  layer_bins_t

Public Types

typedef std::vector< event_teventvector_t
typedef std::vector< layer_bins_tevent_bins_t
enum  FCSEnergyInitializationStatusBits { kOnlyScaleEnergy = }
 Status bit for energy initialization. More...
enum  FCSStatusBits { kMatchAllPDGID }
 Status bit for FCS needs. More...
typedef std::map< TFCSParametrizationBase *, Duplicate_tFindDuplicates_t
typedef std::map< std::string, FindDuplicates_tFindDuplicateClasses_t

Public Member Functions

 TFCSBinnedShower (const char *name=nullptr, const char *title=nullptr)
virtual ~TFCSBinnedShower ()
virtual bool is_match_Ekin_bin (int) const override
void enable_event_matching ()
void disable_event_matching ()
void enable_event_cherry_picking ()
void disable_event_cherry_picking ()
void enable_eta_matching ()
void disable_eta_matching ()
void enable_upscaling ()
void disable_upscaling ()
void set_default_hit_energy (float energy)
float get_default_hit_energy () const
void set_max_hits_per_voxel (int max_hits)
int get_max_hits_per_voxel () const
void load_event_library (const std::string &filename, std::vector< long unsigned int > &layers, bool only_load_meta_data=false)
void load_sub_bin_distribution (const std::string &filename)
void set_hdf5_path (const std::string &filename)
void delete_hdf5_path ()
const std::string & get_hdf5_path () const
void set_layer_energy (long unsigned int event_index, long unsigned int layer_index, const std::vector< unsigned int > &bin_index_vector, const std::vector< float > &E_vector)
void set_bin_boundaries (long unsigned int layer_index, std::vector< float > &R_lower, std::vector< float > &R_size, std::vector< float > &alpha_lower, std::vector< float > &alpha_size)
void set_shower_center_information (long unsigned int event_index, long unsigned int reference_layer_index, float eta_center, float phi_center)
const eventvector_tget_eventlibrary ()
void set_event_library (eventvector_t &eventlibrary)
const event_bins_tget_coordinates ()
void set_coordinates (event_bins_t &coordinates)
const std::vector< std::vector< std::vector< std::vector< float > > > > & get_sub_bin_distribution () const
const std::vector< float > & get_upscaling_energies () const
void set_sub_bin_distribution_and_energies (std::vector< std::vector< std::vector< std::vector< float > > > > &sub_bin_distribution, std::vector< float > &upscaling_energies)
bool OnlyScaleEnergy () const
void set_OnlyScaleEnergy ()
void reset_OnlyScaleEnergy ()
virtual FCSReturnCode simulate (TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
 Method in all derived classes to do some simulation.
virtual FCSReturnCode simulate_hit (Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) override
 simulated one hit position with some energy.
ICaloGeometryget_geometry ()
virtual void set_geometry (ICaloGeometry *geo) override
 Method to set the geometry access pointer.
virtual int get_number_of_hits (TFCSSimulationState &simulstate, const TFCSTruthState *, const TFCSExtrapolationState *) const override
 Call get_number_of_hits() only once per shower simulation, as it could be calculated with random numbers and give different results each time.
virtual double get_sigma2_fluctuation (TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
 Give the effective size sigma^2 of the fluctuations that should be generated by the amount of generated hits.
virtual float get_E_hit (TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
 Get hit energy from layer energy and number of hits.
virtual float getMinWeight () const
 Get minimum and maximum value of weight for hit energy reweighting.
virtual float getMaxWeight () const
bool is_match_calosample (int calosample) const override
virtual bool is_match_all_Ekin_bin () const override
virtual bool is_match_all_calosample () const override
int Ekin_bin () const
void set_Ekin_bin (int bin)
int calosample () const
void set_calosample (int cs)
virtual void set_pdgid_Ekin_eta_Ekin_bin_calosample (const TFCSLateralShapeParametrization &ref)
void Print (Option_t *option="") const override
void clear ()
virtual bool is_match_pdgid (int id) const override
virtual bool is_match_Ekin (float Ekin) const override
virtual bool is_match_eta (float eta) const override
virtual bool is_match_all_Ekin () const override
virtual bool is_match_all_eta () const override
const std::set< int > & pdgid () const override
double Ekin_nominal () const override
double Ekin_min () const override
double Ekin_max () const override
double eta_nominal () const override
double eta_min () const override
double eta_max () const override
virtual void set_pdgid (int id)
virtual void set_pdgid (const std::set< int > &ids)
virtual void add_pdgid (int id)
virtual void clear_pdgid ()
virtual void set_Ekin_nominal (double min)
virtual void set_Ekin_min (double min)
virtual void set_Ekin_max (double max)
virtual void set_eta_nominal (double min)
virtual void set_eta_min (double min)
virtual void set_eta_max (double max)
virtual void set_Ekin (const TFCSParametrizationBase &ref)
virtual void set_eta (const TFCSParametrizationBase &ref)
virtual void set_Ekin_eta (const TFCSParametrizationBase &ref)
virtual void set_pdgid_Ekin_eta (const TFCSParametrizationBase &ref)
virtual bool is_match_all_pdgid () const
virtual void set_match_all_pdgid ()
virtual void reset_match_all_pdgid ()
virtual unsigned int size () const
 Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operator[] methods give general access to these daughters.
virtual const TFCSParametrizationBaseoperator[] (unsigned int) const
 Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operator[] methods give general access to these daughters.
virtual TFCSParametrizationBaseoperator[] (unsigned int)
 Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operator[] methods give general access to these daughters.
virtual void set_daughter (unsigned int, TFCSParametrizationBase *)
 Some derived classes have daughter instances of TFCSParametrizationBase objects The set_daughter method allows to change these daughters - expert use only!
virtual bool operator== (const TFCSParametrizationBase &ref) const
 The == operator compares the content of instances.
virtual void CleanAuxInfo (TFCSSimulationState &) const
 Method in all derived classes to delete objects stored in the simulstate AuxInfo.
void FindDuplicates (FindDuplicateClasses_t &dup)
void RemoveDuplicates ()
void RemoveNameTitle ()
bool msgLvl (const MSG::Level lvl) const
 Check whether the logging system is active at the provided verbosity level.
MsgStream & msg () const
 Return a stream for sending messages directly (no decoration).
MsgStream & msg (const MSG::Level lvl) const
 Return a decorated starting stream for sending messages.
MSG::Level level () const
 Retrieve output level.
virtual void setLevel (MSG::Level lvl)
 Update outputlevel.

Static Public Member Functions

static std::string startMsg (MSG::Level lvl, const std::string &file, int line)
 Make a message to decorate the start of logging.

Protected Member Functions

virtual void get_event (TFCSSimulationState &simulstate, float eta_center, float phi_center, float e_init, long unsigned int reference_layer_index) const override
 do not persistify
virtual long unsigned int get_n_hits (TFCSSimulationState &simulstate, long unsigned int layer_index) const override
virtual void compute_n_hits_and_elayer (TFCSSimulationState &simulstate) const
virtual float get_layer_energy (TFCSSimulationState &simulstate, long unsigned int layer_index) const override
virtual std::tuple< float, float, float > get_hit_position_and_energy (TFCSSimulationState &simulstate, long unsigned int layer_index, long unsigned int hit_index) const override
virtual void delete_event (TFCSSimulationState &simulstate) const override
bool compare (const TFCSParametrizationBase &ref) const

Protected Attributes

ICaloGeometrym_geo {}

Static Protected Attributes

static constexpr double init_Ekin_nominal = 0
static constexpr double init_Ekin_min = 0
 Do not persistify!
static constexpr double init_Ekin_max = 14000000
 Do not persistify!
static constexpr double init_eta_nominal = 0
 Do not persistify!
static constexpr double init_eta_min = -100
 Do not persistify!
static constexpr double init_eta_max = 100
 Do not persistify!

Private Member Functions

long unsigned int find_best_match (float eta_center, float phi_center, float e_init, long unsigned int reference_layer_index, bool phi_mod_matching) const
std::tuple< float, float > get_coordinates (TFCSSimulationState &simulstate, long unsigned int layer_index, int bin_index) const
void upscale (TFCSSimulationState &simulstate, float &R_min, float &R_max, float &alpha_min, float &alpha_max, long unsigned int layer_index, int bin_index) const
long unsigned int get_energy_index (TFCSSimulationState &simulstate, long unsigned int layer_index, long unsigned int hit_index) const
std::tuple< std::vector< float >, std::vector< hsize_t >, bool > load_hdf5_dataset (const std::string &filename, const std::string &datasetname)
void load_layer_energy (const std::string &filename, long unsigned int layer_index)
void load_bin_boundaries (const std::string &filename, long unsigned int layer_index)
void load_shower_center_information (const std::string &filename)

Private Attributes

const long unsigned int m_n_layers
float m_default_hit_energy = 4.
int m_max_hits_per_voxel = 100
std::string m_hdf5_file
eventvector_t m_eventlibrary
event_bins_t m_coordinates
bool m_use_event_matching = false
bool m_use_event_cherry_picking = false
bool m_use_eta_matching = false
bool m_use_upscaling = false
std::vector< std::vector< std::vector< std::vector< float > > > > m_sub_bin_distribution
std::vector< float > m_upscaling_energies
int m_Ekin_bin
int m_calosample
std::set< int > m_pdgid
double m_Ekin_nominal
double m_Ekin_min
double m_Ekin_max
double m_eta_nominal
double m_eta_min
double m_eta_max
std::string m_nm
 Message source name.

Static Private Attributes

static boost::thread_specific_ptr< MsgStream > m_msg_tls ATLAS_THREAD_SAFE
 Do not persistify!

Detailed Description

Definition at line 23 of file TFCSBinnedShower.h.

Member Typedef Documentation

◆ event_bins_t

Definition at line 46 of file TFCSBinnedShower.h.

◆ eventvector_t

Definition at line 37 of file TFCSBinnedShower.h.

◆ FindDuplicateClasses_t

typedef std::map<std::string, FindDuplicates_t> TFCSParametrizationBase::FindDuplicateClasses_t
inherited

Definition at line 142 of file TFCSParametrizationBase.h.

◆ FindDuplicates_t

Member Enumeration Documentation

◆ FCSEnergyInitializationStatusBits

Status bit for energy initialization.

Enumerator
kOnlyScaleEnergy 

Set this bit in the TObject bit field the simulated energy.

should only be scaled by the GAN

Definition at line 24 of file TFCSBinnedShowerBase.h.

24 {
26 BIT(18)
28 };
@ kOnlyScaleEnergy
Set this bit in the TObject bit field the simulated energy.

◆ FCSStatusBits

Status bit for FCS needs.

Enumerator
kMatchAllPDGID 

Set this bit in the TObject bit field if valid for all PDGID.

Definition at line 52 of file TFCSParametrizationBase.h.

52 {
53 kMatchAllPDGID = BIT(
54 14)
55 };
@ kMatchAllPDGID
Set this bit in the TObject bit field if valid for all PDGID.

Constructor & Destructor Documentation

◆ TFCSBinnedShower()

TFCSBinnedShower::TFCSBinnedShower ( const char * name = nullptr,
const char * title = nullptr )

Definition at line 49 of file TFCSBinnedShower.cxx.

50 : TFCSBinnedShowerBase(name, title) {}
TFCSBinnedShowerBase(const char *name=nullptr, const char *title=nullptr)

◆ ~TFCSBinnedShower()

TFCSBinnedShower::~TFCSBinnedShower ( )
virtual

Definition at line 52 of file TFCSBinnedShower.cxx.

52{}

Member Function Documentation

◆ add_pdgid()

void TFCSParametrization::add_pdgid ( int id)
virtualinherited

Reimplemented in TFCSEnergyBinParametrization.

Definition at line 35 of file TFCSParametrization.cxx.

35{ m_pdgid.insert(id); }

◆ calosample()

int TFCSLateralShapeParametrization::calosample ( ) const
inlineinherited

◆ CleanAuxInfo()

virtual void TFCSParametrizationBase::CleanAuxInfo ( TFCSSimulationState & ) const
inlinevirtualinherited

Method in all derived classes to delete objects stored in the simulstate AuxInfo.

Definition at line 130 of file TFCSParametrizationBase.h.

130{};

◆ clear()

void TFCSParametrization::clear ( )
inherited

Definition at line 18 of file TFCSParametrization.cxx.

18 {
19 m_pdgid.clear();
26}
static constexpr double init_Ekin_nominal
static constexpr double init_eta_max
Do not persistify!
static constexpr double init_Ekin_max
Do not persistify!
static constexpr double init_eta_nominal
Do not persistify!
static constexpr double init_eta_min
Do not persistify!
static constexpr double init_Ekin_min
Do not persistify!

◆ clear_pdgid()

void TFCSParametrization::clear_pdgid ( )
virtualinherited

Reimplemented in TFCSEnergyBinParametrization.

Definition at line 37 of file TFCSParametrization.cxx.

37{ m_pdgid.clear(); }

◆ compare()

bool TFCSLateralShapeParametrization::compare ( const TFCSParametrizationBase & ref) const
protectedinherited

Definition at line 32 of file TFCSLateralShapeParametrization.cxx.

33 {
34 if (IsA() != ref.IsA()) {
35 ATH_MSG_DEBUG("compare(): different class types "
36 << IsA()->GetName() << " != " << ref.IsA()->GetName());
37 return false;
38 }
39 const TFCSLateralShapeParametrization &ref_typed =
40 static_cast<const TFCSLateralShapeParametrization &>(ref);
41 if (Ekin_bin() != ref_typed.Ekin_bin()) {
42 ATH_MSG_DEBUG("compare(): different Ekin bin");
43 return false;
44 }
45 if (calosample() != ref_typed.calosample()) {
46 ATH_MSG_DEBUG("compare(): different calosample");
47 return false;
48 }
49
50 return true;
51}
const std::regex ref(r_ef)
#define ATH_MSG_DEBUG(x)
TFCSLateralShapeParametrization(const char *name=nullptr, const char *title=nullptr)
#define IsA
Declare the TObject style functions.

◆ compute_n_hits_and_elayer()

void TFCSBinnedShower::compute_n_hits_and_elayer ( TFCSSimulationState & simulstate) const
protectedvirtual

Definition at line 220 of file TFCSBinnedShower.cxx.

221 {
222
223 event_t *event = static_cast<event_t *>(
224 simulstate.getAuxInfo<void *>("BSEventData"_FCShash));
225 float e_init = simulstate.getAuxInfo<float>("BSEinit"_FCShash);
226
227 // Loop over all layers
228 long unsigned int n_layers = event->event_data.size();
229 std::vector<std::vector<long unsigned int>> hits_per_layer;
230 std::vector<float> elayer;
231 hits_per_layer.resize(n_layers);
232 elayer.resize(n_layers, 0.0f);
233
234 for (long unsigned int layer_index = 0; layer_index < n_layers;
235 ++layer_index) {
236
237 layer_t &layer = event->event_data.at(layer_index);
238
239 // Loop over all voxels in the layer
240 long unsigned int n_hits = 0;
241 for (float e_voxel : layer.E_vector) {
242 long unsigned int hits_per_bin;
243 if (e_voxel > std::numeric_limits<float>::epsilon()) {
244 hits_per_bin =
245 std::min(std::max(int(e_voxel * e_init / m_default_hit_energy), 1),
247 elayer.at(layer_index) += e_voxel * e_init;
248
249 } else {
250 hits_per_bin = 0;
251 }
252 n_hits += hits_per_bin;
253 hits_per_layer.at(layer_index).push_back(n_hits);
254 }
255 }
256 // Store the hits per layer vector
257 std::vector<std::vector<long unsigned int>> *hits_per_layer_ptr =
258 new std::vector<std::vector<long unsigned int>>(std::move(hits_per_layer));
259 simulstate.setAuxInfo<void *>("BSNHits"_FCShash, hits_per_layer_ptr);
260
261 // Store the energy per layer
262 std::vector<float> *elayer_ptr = new std::vector<float>(std::move(elayer));
263 simulstate.setAuxInfo<void *>("BSELayer"_FCShash, elayer_ptr);
264}
const T getAuxInfo(std::uint32_t index) const
void setAuxInfo(std::uint32_t index, const T &val)
@ layer
Definition HitInfo.h:79

◆ delete_event()

void TFCSBinnedShower::delete_event ( TFCSSimulationState & simulstate) const
overrideprotectedvirtual

Implements TFCSBinnedShowerBase.

Definition at line 508 of file TFCSBinnedShower.cxx.

508 {
509 // Delete the event data
510 void *event_ptr = simulstate.getAuxInfo<void *>("BSEventData"_FCShash);
511 if (event_ptr) {
512 delete static_cast<event_t *>(event_ptr);
513 simulstate.setAuxInfo<void *>("BSEventData"_FCShash, nullptr);
514 } else {
515 ATH_MSG_ERROR("No event data found to delete.");
516 }
517
518 void *n_hits_ptr = simulstate.getAuxInfo<void *>("BSNHits"_FCShash);
519 if (n_hits_ptr) {
520 delete static_cast<std::vector<std::vector<long unsigned int>> *>(
521 n_hits_ptr);
522 simulstate.setAuxInfo<void *>("BSNHits"_FCShash, nullptr);
523 } else {
524 ATH_MSG_ERROR("No event hits data found to delete.");
525 }
526
527 void *elayer_ptr = simulstate.getAuxInfo<void *>("BSELayer"_FCShash);
528 if (elayer_ptr) {
529 delete static_cast<std::vector<float> *>(elayer_ptr);
530 simulstate.setAuxInfo<void *>("BSELayer"_FCShash, nullptr);
531 } else {
532 ATH_MSG_ERROR("No event layer energy data found to delete.");
533 }
534
535 return;
536}
#define ATH_MSG_ERROR(x)

◆ delete_hdf5_path()

void TFCSBinnedShower::delete_hdf5_path ( )
inline

Definition at line 102 of file TFCSBinnedShower.h.

102{ m_hdf5_file.clear(); }
std::string m_hdf5_file

◆ disable_eta_matching()

void TFCSBinnedShower::disable_eta_matching ( )
inline

Definition at line 78 of file TFCSBinnedShower.h.

78{ m_use_eta_matching = false; };

◆ disable_event_cherry_picking()

void TFCSBinnedShower::disable_event_cherry_picking ( )
inline

Definition at line 70 of file TFCSBinnedShower.h.

◆ disable_event_matching()

void TFCSBinnedShower::disable_event_matching ( )
inline

Definition at line 62 of file TFCSBinnedShower.h.

62{ m_use_event_matching = false; }

◆ disable_upscaling()

void TFCSBinnedShower::disable_upscaling ( )
inline

Definition at line 81 of file TFCSBinnedShower.h.

81{ m_use_upscaling = false; };

◆ Ekin_bin()

int TFCSLateralShapeParametrization::Ekin_bin ( ) const
inlineinherited

◆ Ekin_max()

double TFCSParametrization::Ekin_max ( ) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 37 of file TFCSParametrization.h.

37{ return m_Ekin_max; };

◆ Ekin_min()

double TFCSParametrization::Ekin_min ( ) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 36 of file TFCSParametrization.h.

36{ return m_Ekin_min; };

◆ Ekin_nominal()

double TFCSParametrization::Ekin_nominal ( ) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 35 of file TFCSParametrization.h.

35{ return m_Ekin_nominal; };

◆ enable_eta_matching()

void TFCSBinnedShower::enable_eta_matching ( )
inline

Definition at line 72 of file TFCSBinnedShower.h.

72 {
73 m_use_eta_matching = true;
76 };

◆ enable_event_cherry_picking()

void TFCSBinnedShower::enable_event_cherry_picking ( )
inline

Definition at line 64 of file TFCSBinnedShower.h.

64 {
67 m_use_eta_matching = false;
68 };

◆ enable_event_matching()

void TFCSBinnedShower::enable_event_matching ( )
inline

Definition at line 56 of file TFCSBinnedShower.h.

56 {
59 m_use_eta_matching = false;
60 };

◆ enable_upscaling()

void TFCSBinnedShower::enable_upscaling ( )
inline

Definition at line 80 of file TFCSBinnedShower.h.

80{ m_use_upscaling = true; };

◆ eta_max()

double TFCSParametrization::eta_max ( ) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 40 of file TFCSParametrization.h.

40{ return m_eta_max; };

◆ eta_min()

double TFCSParametrization::eta_min ( ) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 39 of file TFCSParametrization.h.

39{ return m_eta_min; };

◆ eta_nominal()

double TFCSParametrization::eta_nominal ( ) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 38 of file TFCSParametrization.h.

38{ return m_eta_nominal; };

◆ find_best_match()

long unsigned int TFCSBinnedShower::find_best_match ( float eta_center,
float phi_center,
float e_init,
long unsigned int reference_layer_index,
bool phi_mod_matching ) const
private

Definition at line 114 of file TFCSBinnedShower.cxx.

116 {
117
118 float phi_cell_size, phi_within_cell;
119
120 if (phi_mod_matching) {
121 const CaloDetDescrElement *cellele =
122 m_geo->getDDE(reference_layer_index, eta_center, phi_center);
124 reference_layer_index, eta_center);
125
126 float phi_cell = cellele->phi();
127 phi_within_cell = phi_center - phi_cell;
128
129 phi_within_cell = fmod(phi_within_cell, phi_cell_size);
130 if (phi_within_cell < 0)
131 phi_within_cell += phi_cell_size;
132 }
133
134 // Find the event with the closest eta_center and phi_mod (L2 distance)
135 float best_distance = std::numeric_limits<float>::max();
136 long unsigned int best_match = m_eventlibrary.size() + 1;
137
138 for (long unsigned int event_index = 0; event_index < m_eventlibrary.size();
139 ++event_index) {
140
141 // Absolute eta difference. Normalized by the (usual) eta range of 0.05...
142 float eta_diff =
143 (m_eventlibrary.at(event_index).center_eta - eta_center) / 0.05;
144
145 // Logarithmic energy difference. Use power of two (distance between usual
146 // energy points) as reasonable distance measure.
147 float e_diff =
148 std::log(m_eventlibrary.at(event_index).e_init / e_init) / std::log(2);
149
150 // float dist2 = eta_diff * eta_diff;
151 float dist2 = eta_diff * eta_diff + e_diff * e_diff;
152
153 if (phi_mod_matching) {
154 float phi_mod = m_eventlibrary.at(event_index).phi_mod;
155 float phi_diff = (phi_mod - phi_within_cell) / phi_cell_size;
156 dist2 = dist2 + phi_diff * phi_diff;
157 }
158 float distance = TMath::Sqrt(dist2);
159
160 if (distance < best_distance) {
161 best_distance = distance;
162 best_match = event_index;
163 }
164 }
165
166 if (best_match == m_eventlibrary.size() + 1) {
167 ATH_MSG_ERROR("No best match found");
168 } else {
169 ATH_MSG_INFO("Best match found for eta "
170 << eta_center << " / "
171 << m_eventlibrary.at(best_match).center_eta << " with energy "
172 << e_init << " / " << m_eventlibrary.at(best_match).e_init);
173 }
174
175 return best_match;
176}
#define ATH_MSG_INFO(x)
eventvector_t m_eventlibrary
static float get_phi_cell_size(long unsigned int layer, float eta)
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space

◆ FindDuplicates()

void TFCSParametrizationBase::FindDuplicates ( FindDuplicateClasses_t & dup)
inherited

Definition at line 90 of file TFCSParametrizationBase.cxx.

91 {
92
93 for (unsigned int i = 0; i < size(); ++i)
94 if ((*this)[i]) {
95 TFCSParametrizationBase *param = (*this)[i];
96 FindDuplicates_t &dup = dupclasses[param->GetName()];
97 // If param is already in the duplication list, skip over
98 auto checkexist = dup.find(param);
99 if (checkexist != dup.end()) {
100 ATH_MSG_WARNING(" [TFCSParametrizationBase::FindDuplicates] "
101 "DUPLICATE POINTER DETECTED");
102
103 ATH_MSG_WARNING(" - Pointer : " << param);
104 ATH_MSG_WARNING(" - Name : " << param->GetName());
105 ATH_MSG_WARNING(" - Class : " << param->ClassName());
106 ATH_MSG_WARNING(" - Occurs in parent : " << this
107 << " (" << this->ClassName() << ")"
108 << " index=" << i);
109
110 if (checkexist->second.replace) {
111 TFCSParametrizationBase *refparam = checkexist->second.replace;
112 ATH_MSG_DEBUG("Found duplicate pointer: "
113 << refparam << "=" << refparam->GetName()
114 << ", duplicate is " << param << "=" << param->GetName()
115 << " index " << i << " of " << this);
116 dup[refparam].mother.push_back(this);
117 dup[refparam].index.push_back(i);
118 }
119 continue;
120 }
121 // Add param to duplication list
122 dup[param] = Duplicate_t();
123 for (auto &ref : dup) {
124 TFCSParametrizationBase *refparam = ref.first;
125 // skip itself, as this just added above
126 if (param == refparam)
127 continue;
128 // skip nullptr reference
129 if (refparam == nullptr)
130 continue;
131 // skip reference that is itself going to get replaced
132 if (ref.second.replace)
133 continue;
134 // Check for objects with identical content
135 if (*param == *refparam) {
136 ATH_MSG_DEBUG("Found duplicate: "
137 << refparam << "=" << refparam->GetName()
138 << ", duplicate is " << param << "=" << param->GetName()
139 << " index " << i << " of " << this);
140
141 dup[param].replace = refparam;
142 dup[refparam].mother.push_back(this);
143 dup[refparam].index.push_back(i);
144 break;
145 }
146 }
147 // Continue for child objects in param
148 param->FindDuplicates(dupclasses);
149 }
150}
#define ATH_MSG_WARNING(x)
void FindDuplicates(FindDuplicateClasses_t &dup)
std::map< TFCSParametrizationBase *, Duplicate_t > FindDuplicates_t
virtual unsigned int size() const
Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operat...
TFCSParametrizationBase(const char *name=nullptr, const char *title=nullptr)
ClassName()
Default constructor.

◆ get_coordinates() [1/2]

const event_bins_t & TFCSBinnedShower::get_coordinates ( )
inline

Definition at line 130 of file TFCSBinnedShower.h.

130{ return m_coordinates; }
event_bins_t m_coordinates

◆ get_coordinates() [2/2]

std::tuple< float, float > TFCSBinnedShower::get_coordinates ( TFCSSimulationState & simulstate,
long unsigned int layer_index,
int bin_index ) const
private

Definition at line 332 of file TFCSBinnedShower.cxx.

334 {
335 float R_min = m_coordinates.at(layer_index).R_lower.at(bin_index);
336 float R_max = m_coordinates.at(layer_index).R_size.at(bin_index) +
337 m_coordinates.at(layer_index).R_lower.at(bin_index);
338
339 float alpha_min = m_coordinates.at(layer_index).alpha_lower.at(bin_index);
340 float alpha_max = m_coordinates.at(layer_index).alpha_size.at(bin_index) +
341 m_coordinates.at(layer_index).alpha_lower.at(bin_index);
342
343 if (m_use_upscaling) {
344 upscale(simulstate, R_min, R_max, alpha_min, alpha_max, layer_index,
345 bin_index);
346 }
347 float R;
348 if (TMath::Abs(R_max - R_min) > std::numeric_limits<float>::epsilon()) {
349 R = CLHEP::RandFlat::shoot(simulstate.randomEngine(), R_min, R_max);
350 } else {
351 R = R_min; // If the range is too small, just use the minimum value
352 }
353 float alpha =
354 CLHEP::RandFlat::shoot(simulstate.randomEngine(), alpha_min, alpha_max);
355
356 return std::make_tuple(R, alpha);
357}
void upscale(TFCSSimulationState &simulstate, float &R_min, float &R_max, float &alpha_min, float &alpha_max, long unsigned int layer_index, int bin_index) const
CLHEP::HepRandomEngine * randomEngine()
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)

◆ get_default_hit_energy()

float TFCSBinnedShower::get_default_hit_energy ( ) const
inline

Definition at line 84 of file TFCSBinnedShower.h.

84{ return m_default_hit_energy; }

◆ get_E_hit()

float TFCSLateralShapeParametrizationHitBase::get_E_hit ( TFCSSimulationState & simulstate,
const TFCSTruthState * truth,
const TFCSExtrapolationState * extrapol ) const
virtualinherited

Get hit energy from layer energy and number of hits.

Definition at line 31 of file TFCSLateralShapeParametrizationHitBase.cxx.

33 {
34 const int nhits = get_number_of_hits(simulstate, truth, extrapol);
35 const int sample = calosample();
36 if (nhits <= 0 || sample < 0)
37 return -1.;
38 else
39 return simulstate.E(sample) / nhits;
40}
virtual int get_number_of_hits(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
Call get_number_of_hits() only once per shower simulation, as it could be calculated with random numb...

◆ get_energy_index()

long unsigned int TFCSBinnedShower::get_energy_index ( TFCSSimulationState & simulstate,
long unsigned int layer_index,
long unsigned int hit_index ) const
private

Definition at line 295 of file TFCSBinnedShower.cxx.

297 {
298 std::vector<std::vector<long unsigned int>> *hits_per_layer_ptr =
299 static_cast<std::vector<std::vector<long unsigned int>> *>(
300 simulstate.getAuxInfo<void *>("BSNHits"_FCShash));
301 if (!hits_per_layer_ptr) {
302 ATH_MSG_ERROR("Invalid hits per layer information");
303 return 0;
304 }
305
306 if (layer_index >= hits_per_layer_ptr->size()) {
307 ATH_MSG_ERROR("Layer index out of bounds: " << layer_index << " >= "
308 << hits_per_layer_ptr->size());
309 return 0;
310 }
311
312 // Find the hit index in the hit vector for the given layer
313 const std::vector<long unsigned int> &hits =
314 hits_per_layer_ptr->at(layer_index);
315 auto it = std::upper_bound(hits.begin(), hits.end(), hit_index);
316 long unsigned int energy_index = std::distance(hits.begin(), it);
317
318 if (energy_index >= hits.size()) {
319 ATH_MSG_ERROR("Energy index out of bounds: " << energy_index
320 << " >= " << hits.size());
321 // Print full hits for debugging
322 ATH_MSG_ERROR("Hits per layer: ");
323 for (const auto &hit : hits) {
324 ATH_MSG_ERROR("Hit: " << hit);
325 }
326 return 0;
327 }
328
329 return energy_index;
330}

◆ get_event()

void TFCSBinnedShower::get_event ( TFCSSimulationState & simulstate,
float eta_center,
float phi_center,
float e_init,
long unsigned int reference_layer_index ) const
overrideprotectedvirtual

do not persistify

Implements TFCSBinnedShowerBase.

Definition at line 178 of file TFCSBinnedShower.cxx.

180 {
181
182 if (m_eventlibrary.empty()) {
184 "No event library loaded. Please load an event libray for "
185 "TFCSBinnedShower::get_event.");
186 return;
187 }
188
189 simulstate.setAuxInfo<float>("BSEinit"_FCShash, e_init);
190
191 long unsigned int event_index;
192 if (simulstate.hasAuxInfo("EventNr"_FCShash) && m_use_event_matching) {
193 event_index = simulstate.getAuxInfo<int>("EventNr"_FCShash);
195 // dphi/deta
196 event_index =
197 find_best_match(eta_center, phi_center, e_init, reference_layer_index,
199
200 if (event_index >= m_eventlibrary.size()) {
201 event_index = std::floor(CLHEP::RandFlat::shoot(
202 simulstate.randomEngine(), 0, m_eventlibrary.size()));
203 }
204
205 } else {
206 event_index = std::floor(CLHEP::RandFlat::shoot(simulstate.randomEngine(),
207 0, m_eventlibrary.size()));
208 }
209
210 ATH_MSG_DEBUG("Using event index " << event_index << " for eta " << eta_center
211 << " and phi " << phi_center);
212
213 // Store a pointer to the event
214 event_t *event_ptr = new event_t(m_eventlibrary.at(event_index));
215 simulstate.setAuxInfo<void *>("BSEventData"_FCShash, event_ptr);
216
217 compute_n_hits_and_elayer(simulstate);
218}
virtual void compute_n_hits_and_elayer(TFCSSimulationState &simulstate) const
long unsigned int find_best_match(float eta_center, float phi_center, float e_init, long unsigned int reference_layer_index, bool phi_mod_matching) const
bool hasAuxInfo(std::uint32_t index) const

◆ get_eventlibrary()

const eventvector_t & TFCSBinnedShower::get_eventlibrary ( )
inline

Definition at line 124 of file TFCSBinnedShower.h.

124{ return m_eventlibrary; }

◆ get_geometry()

ICaloGeometry * TFCSBinnedShowerBase::get_geometry ( )
inlineinherited

Definition at line 46 of file TFCSBinnedShowerBase.h.

46{ return m_geo; };

◆ get_hdf5_path()

const std::string & TFCSBinnedShower::get_hdf5_path ( ) const
inline

Definition at line 103 of file TFCSBinnedShower.h.

103{ return m_hdf5_file; }

◆ get_hit_position_and_energy()

std::tuple< float, float, float > TFCSBinnedShower::get_hit_position_and_energy ( TFCSSimulationState & simulstate,
long unsigned int layer_index,
long unsigned int hit_index ) const
overrideprotectedvirtual

Implements TFCSBinnedShowerBase.

Definition at line 466 of file TFCSBinnedShower.cxx.

468 {
469
470 event_t *event = static_cast<event_t *>(
471 simulstate.getAuxInfo<void *>("BSEventData"_FCShash));
472
473 float e_init = simulstate.getAuxInfo<float>("BSEinit"_FCShash);
474
475 if (layer_index >= event->event_data.size()) {
476 ATH_MSG_ERROR("Layer index out of bounds: " << layer_index << " >= "
477 << event->event_data.size());
478 return std::make_tuple(0.0f, 0.0f, 0.0f);
479 }
480
481 long unsigned int energy_index = get_energy_index(
482 simulstate, layer_index, hit_index); // Get the bin index for the hit
483
484 std::vector<std::vector<long unsigned int>> *hits_per_layer_ptr =
485 static_cast<std::vector<std::vector<long unsigned int>> *>(
486 simulstate.getAuxInfo<void *>("BSNHits"_FCShash));
487
488 long unsigned int hits_per_bin;
489 if (energy_index == 0) {
490 hits_per_bin = hits_per_layer_ptr->at(layer_index).at(energy_index);
491 } else {
492 hits_per_bin = hits_per_layer_ptr->at(layer_index).at(energy_index) -
493 hits_per_layer_ptr->at(layer_index).at(energy_index - 1);
494 }
495
496 float r, alpha;
497
498 layer_t &layer = event->event_data.at(layer_index);
499
500 std::tie(r, alpha) = get_coordinates(simulstate, layer_index,
501 layer.bin_index_vector.at(energy_index));
502
503 float E = layer.E_vector.at(energy_index) * e_init / hits_per_bin;
504
505 return std::make_tuple(r, alpha, E);
506}
long unsigned int get_energy_index(TFCSSimulationState &simulstate, long unsigned int layer_index, long unsigned int hit_index) const
const event_bins_t & get_coordinates()
int r
Definition globals.cxx:22

◆ get_layer_energy()

float TFCSBinnedShower::get_layer_energy ( TFCSSimulationState & simulstate,
long unsigned int layer_index ) const
overrideprotectedvirtual

Implements TFCSBinnedShowerBase.

Definition at line 281 of file TFCSBinnedShower.cxx.

282 {
283 std::vector<float> *elayer_ptr = static_cast<std::vector<float> *>(
284 simulstate.getAuxInfo<void *>("BSELayer"_FCShash));
285 if (!elayer_ptr) {
286 ATH_MSG_ERROR("Invalid layer energy information");
287 return 0.0f;
288 }
289 if (layer_index >= elayer_ptr->size()) {
290 return 0.0f;
291 }
292 return elayer_ptr->at(layer_index);
293}

◆ get_max_hits_per_voxel()

int TFCSBinnedShower::get_max_hits_per_voxel ( ) const
inline

Definition at line 86 of file TFCSBinnedShower.h.

86{ return m_max_hits_per_voxel; }

◆ get_n_hits()

long unsigned int TFCSBinnedShower::get_n_hits ( TFCSSimulationState & simulstate,
long unsigned int layer_index ) const
overrideprotectedvirtual

Implements TFCSBinnedShowerBase.

Definition at line 266 of file TFCSBinnedShower.cxx.

267 {
268
269 std::vector<std::vector<long unsigned int>> *hits_per_layer_ptr =
270 static_cast<std::vector<std::vector<long unsigned int>> *>(
271 simulstate.getAuxInfo<void *>("BSNHits"_FCShash));
272
273 if (!hits_per_layer_ptr) {
274 ATH_MSG_ERROR("Invalid hits per layer information");
275 return 0;
276 }
277
278 return hits_per_layer_ptr->at(layer_index).back();
279}

◆ get_number_of_hits()

virtual int TFCSBinnedShowerBase::get_number_of_hits ( TFCSSimulationState & simulstate,
const TFCSTruthState * truth,
const TFCSExtrapolationState * extrapol ) const
inlineoverridevirtualinherited

Call get_number_of_hits() only once per shower simulation, as it could be calculated with random numbers and give different results each time.

Return a value of -1 if this instance can't determine

Reimplemented from TFCSLateralShapeParametrizationHitBase.

Definition at line 53 of file TFCSBinnedShowerBase.h.

55 {
56 long unsigned int nhits = get_n_hits(simulstate, calosample());
57 if (nhits == 0)
58 return -1;
59 return static_cast<int>(nhits);
60 }
virtual long unsigned int get_n_hits(TFCSSimulationState &simulstate, long unsigned int layer_index) const =0

◆ get_sigma2_fluctuation()

double TFCSLateralShapeParametrizationHitBase::get_sigma2_fluctuation ( TFCSSimulationState & simulstate,
const TFCSTruthState * truth,
const TFCSExtrapolationState * extrapol ) const
virtualinherited

Give the effective size sigma^2 of the fluctuations that should be generated by the amount of generated hits.

Return a value <0 if this instance can't determine

Reimplemented in TFCS2DFunctionLateralShapeParametrization, TFCSHistoLateralShapeParametrization, and TFCSLateralShapeParametrizationHitNumberFromE.

Definition at line 19 of file TFCSLateralShapeParametrizationHitBase.cxx.

21 {
22 return -1;
23}

◆ get_sub_bin_distribution()

const std::vector< std::vector< std::vector< std::vector< float > > > > & TFCSBinnedShower::get_sub_bin_distribution ( ) const
inline

Definition at line 137 of file TFCSBinnedShower.h.

137 {
139 }
std::vector< std::vector< std::vector< std::vector< float > > > > m_sub_bin_distribution

◆ get_upscaling_energies()

const std::vector< float > & TFCSBinnedShower::get_upscaling_energies ( ) const
inline

Definition at line 141 of file TFCSBinnedShower.h.

141 {
143 }
std::vector< float > m_upscaling_energies

◆ getMaxWeight()

float TFCSLateralShapeParametrizationHitBase::getMaxWeight ( ) const
virtualinherited

Reimplemented in TFCSHistoLateralShapeWeight.

Definition at line 46 of file TFCSLateralShapeParametrizationHitBase.cxx.

46 {
47 return -1.;
48}

◆ getMinWeight()

float TFCSLateralShapeParametrizationHitBase::getMinWeight ( ) const
virtualinherited

Get minimum and maximum value of weight for hit energy reweighting.

Reimplemented in TFCSHistoLateralShapeWeight.

Definition at line 42 of file TFCSLateralShapeParametrizationHitBase.cxx.

42 {
43 return -1.;
44}

◆ is_match_all_calosample()

virtual bool TFCSLateralShapeParametrization::is_match_all_calosample ( ) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrization.

Definition at line 29 of file TFCSLateralShapeParametrization.h.

29{ return false; };

◆ is_match_all_Ekin()

virtual bool TFCSParametrization::is_match_all_Ekin ( ) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 25 of file TFCSParametrization.h.

25 {
26 return Ekin_min() == init_Ekin_min && Ekin_max() == init_Ekin_max;
27 };
double Ekin_min() const override
double Ekin_max() const override

◆ is_match_all_Ekin_bin()

virtual bool TFCSLateralShapeParametrization::is_match_all_Ekin_bin ( ) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrization.

Definition at line 24 of file TFCSLateralShapeParametrization.h.

24 {
25 if (Ekin_bin() == -1)
26 return true;
27 return false;
28 };

◆ is_match_all_eta()

virtual bool TFCSParametrization::is_match_all_eta ( ) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 28 of file TFCSParametrization.h.

28 {
29 return eta_min() == init_eta_min && eta_max() == init_eta_max;
30 };
double eta_max() const override
double eta_min() const override

◆ is_match_all_pdgid()

virtual bool TFCSParametrizationBase::is_match_all_pdgid ( ) const
inlinevirtualinherited

Definition at line 66 of file TFCSParametrizationBase.h.

66{ return TestBit(kMatchAllPDGID); };

◆ is_match_calosample()

bool TFCSLateralShapeParametrization::is_match_calosample ( int calosample) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 20 of file TFCSLateralShapeParametrization.h.

20 {
21 return calosample == m_calosample;
22 };

◆ is_match_Ekin()

virtual bool TFCSParametrization::is_match_Ekin ( float Ekin) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 18 of file TFCSParametrization.h.

18 {
19 return (Ekin >= m_Ekin_min) && (Ekin < m_Ekin_max);
20 };

◆ is_match_Ekin_bin()

virtual bool TFCSBinnedShower::is_match_Ekin_bin ( int ) const
inlineoverridevirtual

Reimplemented from TFCSParametrizationBase.

Definition at line 52 of file TFCSBinnedShower.h.

52 {
53 return true;
54 };

◆ is_match_eta()

virtual bool TFCSParametrization::is_match_eta ( float eta) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 21 of file TFCSParametrization.h.

21 {
22 return (eta >= m_eta_min) && (eta < m_eta_max);
23 };
Scalar eta() const
pseudorapidity method

◆ is_match_pdgid()

virtual bool TFCSParametrization::is_match_pdgid ( int id) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 15 of file TFCSParametrization.h.

15 {
16 return TestBit(kMatchAllPDGID) || m_pdgid.find(id) != m_pdgid.end();
17 };

◆ level()

MSG::Level ISF_FCS::MLogging::level ( ) const
inlineinherited

Retrieve output level.

Definition at line 201 of file MLogging.h.

201{ return msg().level(); }
MsgStream & msg() const
Return a stream for sending messages directly (no decoration).
Definition MLogging.h:231

◆ load_bin_boundaries()

void TFCSBinnedShower::load_bin_boundaries ( const std::string & filename,
long unsigned int layer_index )
private

Definition at line 651 of file TFCSBinnedShower.cxx.

652 {
653
654 // Assert that the layer index is valid
655 if (layer_index >= m_coordinates.size()) {
656 m_coordinates.resize(layer_index + 1);
657 }
658
659 std::vector<std::string> datasetnames = {
660 "binstart_radius_layer_", "binsize_radius_layer_",
661 "binstart_alpha_layer_", "binsize_alpha_layer_"};
662
663 for (long unsigned int i = 0; i < datasetnames.size(); i++) {
664 std::string datasetname = datasetnames.at(i) + std::to_string(layer_index);
665 std::vector<float> data;
666 std::vector<hsize_t> dims;
667 bool success;
668 std::tie(data, dims, success) = load_hdf5_dataset(filename, datasetname);
669 if (!success) {
670 ATH_MSG_ERROR("Error while extracting the bin boundaries for layer "
671 << layer_index << " from " << filename << "."
672 << "Specifically, the key " << datasetname
673 << " could not be loaded.");
674 return;
675 }
676
677 // Fill the corresponding vector in the layer_bins_t structure
678 auto &event_bins = m_coordinates.at(layer_index);
679 switch (i) {
680 case 0:
681 event_bins.R_lower = std::move(data);
682 break;
683 case 1:
684 event_bins.R_size = std::move(data);
685 break;
686 case 2:
687 event_bins.alpha_lower = std::move(data);
688 break;
689 case 3:
690 event_bins.alpha_size = std::move(data);
691 break;
692 }
693 }
694}
std::tuple< std::vector< float >, std::vector< hsize_t >, bool > load_hdf5_dataset(const std::string &filename, const std::string &datasetname)

◆ load_event_library()

void TFCSBinnedShower::load_event_library ( const std::string & filename,
std::vector< long unsigned int > & layers,
bool only_load_meta_data = false )

Definition at line 538 of file TFCSBinnedShower.cxx.

540 {
541
542 if (!only_load_meta_data) {
543 m_eventlibrary.clear();
544 }
545
546 m_coordinates.clear();
547
548 if (m_use_upscaling) {
550 }
551
552 // layer dependent variables
553 for (long unsigned int layer_index : layers) {
554
555 ATH_MSG_INFO("Loading layer " << layer_index << " from file: " << filename);
556
557 // Load the bin boundaries for this layer
558 load_bin_boundaries(filename, layer_index);
559
560 if (!only_load_meta_data) {
561 // Load the layer energies
562 load_layer_energy(filename, layer_index);
563 }
564
565 }
566
568 !only_load_meta_data) {
570 }
571
572 return;
573}
void load_layer_energy(const std::string &filename, long unsigned int layer_index)
void load_shower_center_information(const std::string &filename)
void load_bin_boundaries(const std::string &filename, long unsigned int layer_index)

◆ load_hdf5_dataset()

std::tuple< std::vector< float >, std::vector< hsize_t >, bool > TFCSBinnedShower::load_hdf5_dataset ( const std::string & filename,
const std::string & datasetname )
private

Definition at line 576 of file TFCSBinnedShower.cxx.

577 {
578
579 // Open the HDF5 file and dataset
580 H5::H5File file(filename, H5F_ACC_RDONLY);
581
582 // check if the dataset exists
583 if (!file.exists(datasetname)) {
584 return std::make_tuple(std::vector<float>{}, std::vector<hsize_t>{}, false);
585 }
586
587 H5::DataSet dataset = file.openDataSet(datasetname);
588
589 // Get the dataspace of the dataset
590 H5::DataSpace dataspace = dataset.getSpace();
591
592 // Get the number of dimensions and the size of each dimension
593 int rank = dataspace.getSimpleExtentNdims();
594 std::vector<hsize_t> dims_out(rank);
595 dataspace.getSimpleExtentDims(dims_out.data(), NULL);
596
597 // Calculate the total number of elements
598 hsize_t totalSize = 1;
599 for (const auto &dim : dims_out) {
600 totalSize *= dim;
601 }
602
603 // Read the dataset into a buffer
604 std::vector<float> data(totalSize);
605 dataset.read(data.data(), H5::PredType::NATIVE_FLOAT);
606 file.close();
607 return std::make_tuple(data, dims_out, true);
608}
static unsigned int totalSize(const MultiDimArray< T, N > &ht)
TFile * file

◆ load_layer_energy()

void TFCSBinnedShower::load_layer_energy ( const std::string & filename,
long unsigned int layer_index )
private

Definition at line 610 of file TFCSBinnedShower.cxx.

611 {
612
613 std::string datasetname = "energy_layer_" + std::to_string(layer_index);
614
615 std::vector<float> data;
616 std::vector<hsize_t> dims;
617 bool success;
618 std::tie(data, dims, success) = load_hdf5_dataset(filename, datasetname);
619 if (!success) {
620 ATH_MSG_ERROR("Error while extracting the layer energy for layer "
621 << layer_index << " from " << filename << ".");
622 return;
623 }
624
625 // Store the data in the event library
626 std::vector<unsigned int> bin_index_vector;
627 std::vector<float> E_vector;
628
629 for (size_t i = 0; i < data.size(); ++i) {
630 long unsigned int event_index = i / dims.at(1);
631 float bin_index = i % dims.at(1);
632
633 if (bin_index == 0) {
634 bin_index_vector.clear();
635 E_vector.clear();
636 }
637
638 if (data.at(i) != 0.0) {
639 bin_index_vector.push_back(bin_index);
640 E_vector.push_back(data.at(i));
641 }
642
643 if (bin_index ==
644 dims.at(1) - 1) // True for the last voxel of the event in this layer
645 {
646 set_layer_energy(event_index, layer_index, bin_index_vector, E_vector);
647 }
648 }
649}
void set_layer_energy(long unsigned int event_index, long unsigned int layer_index, const std::vector< unsigned int > &bin_index_vector, const std::vector< float > &E_vector)

◆ load_shower_center_information()

void TFCSBinnedShower::load_shower_center_information ( const std::string & filename)
private

Definition at line 696 of file TFCSBinnedShower.cxx.

697 {
698
699 // Open the HDF5 file
700 H5::H5File file(filename, H5F_ACC_RDONLY);
701
702 // Open the dataset
703 std::vector<std::string> datasetnames = {"phi_mod", "center_eta",
704 "incident_energy"};
705
706 for (long unsigned int i = 0; i < datasetnames.size(); i++) {
707 std::string datasetname = datasetnames.at(i);
708 std::vector<float> data;
709 std::vector<hsize_t> dims;
710 bool success;
711 std::tie(data, dims, success) = load_hdf5_dataset(filename, datasetname);
712 if (!success) {
713 if (datasetname == "phi_mod" && m_use_eta_matching) {
714 // We do not necessarly need the phi_mod for eta matching, so we can
715 // just skip this dataset
716 continue;
717 } else {
719 "Error while extracting the shower center information from "
720 << filename << "."
721 << "Specifically, the key " << datasetname
722 << " could not be loaded.");
723 }
724 return;
725 }
726
727 for (long unsigned int event_index = 0; event_index < data.size();
728 ++event_index) {
729 switch (i) {
730 case 0:
731 m_eventlibrary.at(event_index).phi_mod = data.at(event_index);
732 break;
733 case 1:
734 m_eventlibrary.at(event_index).center_eta = data.at(event_index);
735 break;
736 case 2:
737 m_eventlibrary.at(event_index).e_init = data.at(event_index);
738 break;
739 }
740 }
741 }
742}

◆ load_sub_bin_distribution()

void TFCSBinnedShower::load_sub_bin_distribution ( const std::string & filename)

Definition at line 775 of file TFCSBinnedShower.cxx.

775 {
776 m_use_upscaling = true;
777 TFile *file = TFile::Open(filename.c_str(), "READ");
778 if (!file || file->IsZombie()) {
779 std::cerr << "Failed to open file: " << filename << std::endl;
780 return;
781 }
782
783 std::regex pattern(R"(probabilities_layer_(\d+)_energy_([0-9.]+))");
784 std::map<float, std::map<int, std::vector<std::vector<float>>>> temp_storage;
785
786 TIter next(file->GetListOfKeys());
787 TKey *key;
788
789 while ((key = (TKey *)next())) {
790 std::string keyname = key->GetName();
791 std::smatch match;
792 if (std::regex_match(keyname, match, pattern)) {
793 int layer = std::stoi(match[1].str());
794 float energy = std::stod(match[2].str());
795
796 TMatrixD *matrix = dynamic_cast<TMatrixD *>(file->Get(keyname.c_str()));
797 if (matrix) {
798 std::vector<std::vector<float>> mat_vec(
799 matrix->GetNrows(), std::vector<float>(matrix->GetNcols()));
800 for (int i = 0; i < matrix->GetNrows(); ++i) {
801 for (int j = 0; j < matrix->GetNcols(); ++j) {
802 mat_vec[i][j] = static_cast<float>((*matrix)(i, j));
803 }
804 }
805 temp_storage[energy][layer] = std::move(mat_vec);
806 }
807 }
808 }
809
810 file->Close();
811 delete file;
812
813 // Output containers
814 std::vector<float> energies;
815 std::vector<std::vector<std::vector<std::vector<float>>>>
816 data; // [energy][layer][row][col]
817
818 for (const auto &[energy, layer_map] : temp_storage) {
819 energies.push_back(energy);
820 int max_layer = 0;
821 for (const auto &[l, _] : layer_map)
822 max_layer = std::max(max_layer, l);
823
824 std::vector<std::vector<std::vector<float>>> layer_vec(max_layer + 1);
825 for (const auto &[layer_idx, mat] : layer_map) {
826 layer_vec[layer_idx] = mat;
827 }
828 data.push_back(std::move(layer_vec));
829 }
830
831 // Example output
832 for (size_t i = 0; i < energies.size(); ++i) {
833 std::cout << "Energy index " << i << ": " << energies[i] << " GeV\n";
834 for (size_t j = 0; j < data[i].size(); ++j) {
835 if (!data[i][j].empty()) {
836 std::cout << " Layer " << j << " Shape: (" << data[i][j].size() << ", "
837 << data[i][j][0].size() << ")\n";
838 }
839 }
840 }
841
842 m_upscaling_energies = std::move(energies);
843 m_sub_bin_distribution = std::move(data);
844}
static const Attributes_t empty
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:359
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)

◆ msg() [1/2]

MsgStream & ISF_FCS::MLogging::msg ( ) const
inlineinherited

Return a stream for sending messages directly (no decoration).

Definition at line 231 of file MLogging.h.

231 {
232 MsgStream *ms = m_msg_tls.get();
233 if (!ms) {
234 ms = new MsgStream(Athena::getMessageSvc(), m_nm);
235 m_msg_tls.reset(ms);
236 }
237 return *ms;
238}
std::string m_nm
Message source name.
Definition MLogging.h:211
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [2/2]

MsgStream & ISF_FCS::MLogging::msg ( const MSG::Level lvl) const
inlineinherited

Return a decorated starting stream for sending messages.

Definition at line 240 of file MLogging.h.

240 {
241 return msg() << lvl;
242}

◆ msgLvl()

bool ISF_FCS::MLogging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Check whether the logging system is active at the provided verbosity level.

Definition at line 222 of file MLogging.h.

222 {
223 if (msg().level() <= lvl) {
224 msg() << lvl;
225 return true;
226 } else {
227 return false;
228 }
229}
MSG::Level level() const
Retrieve output level.
Definition MLogging.h:201

◆ OnlyScaleEnergy()

bool TFCSBinnedShowerBase::OnlyScaleEnergy ( ) const
inlineinherited

Definition at line 30 of file TFCSBinnedShowerBase.h.

30{ return TestBit(kOnlyScaleEnergy); };

◆ operator==()

virtual bool TFCSParametrizationBase::operator== ( const TFCSParametrizationBase & ref) const
inlinevirtualinherited

The == operator compares the content of instances.

The implementation in the base class only returns true for a comparison with itself

Reimplemented in TFCSHitCellMapping, TFCSHitCellMappingWiggle, TFCSLateralShapeParametrizationHitNumberFromE, and TFCSPredictExtrapWeights.

Definition at line 119 of file TFCSParametrizationBase.h.

119 {
120 return compare(ref);
121 };
bool compare(const TFCSParametrizationBase &ref) const
Do not persistify!

◆ operator[]() [1/2]

virtual TFCSParametrizationBase * TFCSParametrizationBase::operator[] ( unsigned int )
inlinevirtualinherited

Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operator[] methods give general access to these daughters.

Reimplemented in TFCSLateralShapeParametrizationHitChain, and TFCSParametrizationChain.

Definition at line 106 of file TFCSParametrizationBase.h.

106 {
107 return nullptr;
108 };

◆ operator[]() [2/2]

virtual const TFCSParametrizationBase * TFCSParametrizationBase::operator[] ( unsigned int ) const
inlinevirtualinherited

Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operator[] methods give general access to these daughters.

Reimplemented in TFCSLateralShapeParametrizationHitChain, and TFCSParametrizationChain.

Definition at line 99 of file TFCSParametrizationBase.h.

99 {
100 return nullptr;
101 };

◆ pdgid()

const std::set< int > & TFCSParametrization::pdgid ( ) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 34 of file TFCSParametrization.h.

34{ return m_pdgid; };

◆ Print()

void TFCSLateralShapeParametrization::Print ( Option_t * option = "") const
overrideinherited

Definition at line 53 of file TFCSLateralShapeParametrization.cxx.

53 {
54 TString opt(option);
55 bool shortprint = opt.Index("short") >= 0;
56 bool longprint = msgLvl(MSG::DEBUG) || (msgLvl(MSG::INFO) && !shortprint);
57 TString optprint = opt;
58 optprint.ReplaceAll("short", "");
60 if (longprint) {
61 if (Ekin_bin() == -1)
62 ATH_MSG_INFO(optprint << " Ekin_bin=all ; calosample=" << calosample());
63 else
64 ATH_MSG_INFO(optprint << " Ekin_bin=" << Ekin_bin()
65 << " ; calosample=" << calosample());
66 }
67}
bool msgLvl(const MSG::Level lvl) const
Check whether the logging system is active at the provided verbosity level.
Definition MLogging.h:222
void Print(Option_t *option="") const
Print object information.

◆ RemoveDuplicates()

void TFCSParametrizationBase::RemoveDuplicates ( )
inherited

Definition at line 152 of file TFCSParametrizationBase.cxx.

152 {
153 FindDuplicateClasses_t dupclasses;
154 FindDuplicates(dupclasses);
155
156 std::set<TFCSParametrizationBase *> dellist;
157 for (auto &dupiter : dupclasses) {
158 FindDuplicates_t &dup = dupiter.second;
159 for (auto onedup : dup) {
160 if (onedup.second.mother.empty())
161 continue;
162 TFCSParametrizationBase *ref = onedup.first;
163 ATH_MSG_DEBUG("Main object " << ref << "=" << ref->GetName());
164 for (unsigned int i = 0; i < onedup.second.mother.size(); ++i) {
165 int index = onedup.second.index[i];
166 TFCSParametrizationBase *mother = onedup.second.mother[i];
167 TFCSParametrizationBase *delparam = mother->operator[](index);
168 unsigned int delcount = dup[delparam].mother.size();
169 if (delcount == 0) {
170 ATH_MSG_DEBUG(" - Delete object "
171 << delparam << "=" << delparam->GetName() << " index "
172 << index << " of " << mother << ", has " << delcount
173 << " other replacements attached. Deleting");
174 mother->set_daughter(index, ref);
175 dellist.insert(delparam);
176 } else {
177 ATH_MSG_WARNING(" - Delete object "
178 << delparam << "=" << delparam->GetName() << " index "
179 << index << " of " << mother << ", has " << delcount
180 << " other replacements attached. Skipping");
181 }
182 }
183 }
184 }
185
186 ATH_MSG_INFO("RERUNNING DUPLICATE FINDING");
187 FindDuplicateClasses_t dupclasses2;
188 FindDuplicates(dupclasses2);
189
190 std::map<std::string, int> ndel;
191 for (auto *delparam : dellist) {
192 FindDuplicates_t &dup2 = dupclasses2[delparam->GetName()];
193 bool present = dup2.find(delparam) != dup2.end();
194 if (present) {
195 ATH_MSG_WARNING("- Delete object " << delparam << "="
196 << delparam->GetName()
197 << " still referenced somewhere!");
198 } else {
199 ATH_MSG_DEBUG("- Delete object " << delparam << "="
200 << delparam->GetName());
201 ++ndel[delparam->ClassName()];
202 delete delparam;
203 }
204 }
205 for (auto &del : ndel)
206 ATH_MSG_INFO("Deleted " << del.second << " duplicate objects of class "
207 << del.first);
208}
virtual void set_daughter(unsigned int, TFCSParametrizationBase *)
Some derived classes have daughter instances of TFCSParametrizationBase objects The set_daughter meth...
std::map< std::string, FindDuplicates_t > FindDuplicateClasses_t
str index
Definition DeMoScan.py:362

◆ RemoveNameTitle()

void TFCSParametrizationBase::RemoveNameTitle ( )
inherited

Definition at line 210 of file TFCSParametrizationBase.cxx.

210 {
211 for (unsigned int i = 0; i < size(); ++i)
212 if ((*this)[i]) {
213 TFCSParametrizationBase *param = (*this)[i];
214 param->SetName("");
215 param->SetTitle("");
216
217 // Continue for child objects in param
218 param->RemoveNameTitle();
219 }
220}

◆ reset_match_all_pdgid()

virtual void TFCSParametrizationBase::reset_match_all_pdgid ( )
inlinevirtualinherited

Definition at line 84 of file TFCSParametrizationBase.h.

84{ ResetBit(kMatchAllPDGID); };

◆ reset_OnlyScaleEnergy()

void TFCSBinnedShowerBase::reset_OnlyScaleEnergy ( )
inlineinherited

Definition at line 34 of file TFCSBinnedShowerBase.h.

34{ ResetBit(kOnlyScaleEnergy); };

◆ set_bin_boundaries()

void TFCSBinnedShower::set_bin_boundaries ( long unsigned int layer_index,
std::vector< float > & R_lower,
std::vector< float > & R_size,
std::vector< float > & alpha_lower,
std::vector< float > & alpha_size )

Definition at line 75 of file TFCSBinnedShower.cxx.

79 {
80 if (layer_index >= m_coordinates.size()) {
81 m_coordinates.resize(layer_index + 1);
82 }
83 m_coordinates.at(layer_index).R_lower = R_lower;
84 m_coordinates.at(layer_index).R_size = R_size;
85 m_coordinates.at(layer_index).alpha_lower = alpha_lower;
86 m_coordinates.at(layer_index).alpha_size = alpha_size;
87}

◆ set_calosample()

void TFCSLateralShapeParametrization::set_calosample ( int cs)
inherited

Definition at line 21 of file TFCSLateralShapeParametrization.cxx.

21 {
22 m_calosample = cs;
23}

◆ set_coordinates()

void TFCSBinnedShower::set_coordinates ( event_bins_t & coordinates)
inline

Definition at line 132 of file TFCSBinnedShower.h.

132 {
133 m_coordinates = coordinates;
134 }

◆ set_daughter()

virtual void TFCSParametrizationBase::set_daughter ( unsigned int ,
TFCSParametrizationBase *  )
inlinevirtualinherited

Some derived classes have daughter instances of TFCSParametrizationBase objects The set_daughter method allows to change these daughters - expert use only!

The original element at this position is not deleted

Reimplemented in TFCSLateralShapeParametrizationHitChain, and TFCSParametrizationChain.

Definition at line 113 of file TFCSParametrizationBase.h.

114 {};

◆ set_default_hit_energy()

void TFCSBinnedShower::set_default_hit_energy ( float energy)
inline

Definition at line 83 of file TFCSBinnedShower.h.

◆ set_Ekin()

void TFCSParametrization::set_Ekin ( const TFCSParametrizationBase & ref)
virtualinherited

Definition at line 55 of file TFCSParametrization.cxx.

55 {
56 set_Ekin_nominal(ref.Ekin_nominal());
57 set_Ekin_min(ref.Ekin_min());
58 set_Ekin_max(ref.Ekin_max());
59}
virtual void set_Ekin_max(double max)
virtual void set_Ekin_min(double min)
virtual void set_Ekin_nominal(double min)

◆ set_Ekin_bin()

void TFCSLateralShapeParametrization::set_Ekin_bin ( int bin)
inherited

Definition at line 17 of file TFCSLateralShapeParametrization.cxx.

◆ set_Ekin_eta()

void TFCSParametrization::set_Ekin_eta ( const TFCSParametrizationBase & ref)
virtualinherited

Definition at line 67 of file TFCSParametrization.cxx.

67 {
69 set_eta(ref);
70}
virtual void set_eta(const TFCSParametrizationBase &ref)
virtual void set_Ekin(const TFCSParametrizationBase &ref)

◆ set_Ekin_max()

void TFCSParametrization::set_Ekin_max ( double max)
virtualinherited

Definition at line 45 of file TFCSParametrization.cxx.

45{ m_Ekin_max = max; }
#define max(a, b)
Definition cfImp.cxx:41

◆ set_Ekin_min()

void TFCSParametrization::set_Ekin_min ( double min)
virtualinherited

Definition at line 43 of file TFCSParametrization.cxx.

43{ m_Ekin_min = min; }
#define min(a, b)
Definition cfImp.cxx:40

◆ set_Ekin_nominal()

void TFCSParametrization::set_Ekin_nominal ( double min)
virtualinherited

Definition at line 39 of file TFCSParametrization.cxx.

39 {
40 m_Ekin_nominal = nominal;
41}

◆ set_eta()

void TFCSParametrization::set_eta ( const TFCSParametrizationBase & ref)
virtualinherited

Definition at line 61 of file TFCSParametrization.cxx.

61 {
62 set_eta_nominal(ref.eta_nominal());
63 set_eta_min(ref.eta_min());
64 set_eta_max(ref.eta_max());
65}
virtual void set_eta_max(double max)
virtual void set_eta_nominal(double min)
virtual void set_eta_min(double min)

◆ set_eta_max()

void TFCSParametrization::set_eta_max ( double max)
virtualinherited

Definition at line 53 of file TFCSParametrization.cxx.

53{ m_eta_max = max; }

◆ set_eta_min()

void TFCSParametrization::set_eta_min ( double min)
virtualinherited

Definition at line 51 of file TFCSParametrization.cxx.

51{ m_eta_min = min; }

◆ set_eta_nominal()

void TFCSParametrization::set_eta_nominal ( double min)
virtualinherited

Definition at line 47 of file TFCSParametrization.cxx.

47 {
48 m_eta_nominal = nominal;
49}

◆ set_event_library()

void TFCSBinnedShower::set_event_library ( eventvector_t & eventlibrary)
inline

Definition at line 126 of file TFCSBinnedShower.h.

126 {
127 m_eventlibrary = eventlibrary;
128 }

◆ set_geometry()

virtual void TFCSBinnedShowerBase::set_geometry ( ICaloGeometry * geo)
inlineoverridevirtualinherited

Method to set the geometry access pointer.

Loops over daughter objects if present

Reimplemented from TFCSParametrizationBase.

Definition at line 48 of file TFCSBinnedShowerBase.h.

48 {
49 m_geo = geo;
51 };
virtual void set_geometry(ICaloGeometry *geo)
Method to set the geometry access pointer.

◆ set_hdf5_path()

void TFCSBinnedShower::set_hdf5_path ( const std::string & filename)
inline

Definition at line 101 of file TFCSBinnedShower.h.

◆ set_layer_energy()

void TFCSBinnedShower::set_layer_energy ( long unsigned int event_index,
long unsigned int layer_index,
const std::vector< unsigned int > & bin_index_vector,
const std::vector< float > & E_vector )

Definition at line 54 of file TFCSBinnedShower.cxx.

57 {
58
59 // Assert that the event index is valid
60 if (event_index >= m_eventlibrary.size()) {
61 m_eventlibrary.resize(event_index + 1);
62 }
63
64 // Assert that the layer index is valid
65 if (layer_index >= m_eventlibrary.at(event_index).event_data.size()) {
66 m_eventlibrary.at(event_index).event_data.resize(layer_index + 1);
67 }
68
69 // Set the layer energy
70 layer_t &layer = m_eventlibrary.at(event_index).event_data.at(layer_index);
71 layer.bin_index_vector = bin_index_vector;
72 layer.E_vector = E_vector;
73}

◆ set_match_all_pdgid()

virtual void TFCSParametrizationBase::set_match_all_pdgid ( )
inlinevirtualinherited

Definition at line 83 of file TFCSParametrizationBase.h.

83{ SetBit(kMatchAllPDGID); };

◆ set_max_hits_per_voxel()

void TFCSBinnedShower::set_max_hits_per_voxel ( int max_hits)
inline

Definition at line 85 of file TFCSBinnedShower.h.

85{ m_max_hits_per_voxel = max_hits; }

◆ set_OnlyScaleEnergy()

void TFCSBinnedShowerBase::set_OnlyScaleEnergy ( )
inlineinherited

Definition at line 32 of file TFCSBinnedShowerBase.h.

32{ SetBit(kOnlyScaleEnergy); };

◆ set_pdgid() [1/2]

void TFCSParametrization::set_pdgid ( const std::set< int > & ids)
virtualinherited

Reimplemented in TFCSEnergyBinParametrization.

Definition at line 33 of file TFCSParametrization.cxx.

◆ set_pdgid() [2/2]

void TFCSParametrization::set_pdgid ( int id)
virtualinherited

Reimplemented in TFCSEnergyBinParametrization.

Definition at line 28 of file TFCSParametrization.cxx.

28 {
29 m_pdgid.clear();
30 m_pdgid.insert(id);
31}

◆ set_pdgid_Ekin_eta()

void TFCSParametrization::set_pdgid_Ekin_eta ( const TFCSParametrizationBase & ref)
virtualinherited

Definition at line 72 of file TFCSParametrization.cxx.

73 {
75 set_pdgid(ref.pdgid());
76}
virtual void set_Ekin_eta(const TFCSParametrizationBase &ref)
virtual void set_pdgid(int id)

◆ set_pdgid_Ekin_eta_Ekin_bin_calosample()

void TFCSLateralShapeParametrization::set_pdgid_Ekin_eta_Ekin_bin_calosample ( const TFCSLateralShapeParametrization & ref)
virtualinherited

Definition at line 25 of file TFCSLateralShapeParametrization.cxx.

26 {
27 set_calosample(ref.calosample());
28 set_Ekin_bin(ref.Ekin_bin());
30}
virtual void set_pdgid_Ekin_eta(const TFCSParametrizationBase &ref)

◆ set_shower_center_information()

void TFCSBinnedShower::set_shower_center_information ( long unsigned int event_index,
long unsigned int reference_layer_index,
float eta_center,
float phi_center )

Definition at line 89 of file TFCSBinnedShower.cxx.

91 {
92
93 // Compute phi_mod
95 reference_layer_index, eta_center);
96 float phi_cell =
97 m_geo->getDDE(reference_layer_index, eta_center, phi_center)->phi();
98 float phi_within_cell = fmod(phi_center - phi_cell, phi_cell_size);
99 if (phi_within_cell < 0) {
100 phi_within_cell += phi_cell_size;
101 }
102
103 if (m_eventlibrary.size() <= event_index) {
104 m_eventlibrary.resize(event_index + 1);
105 }
106 if (m_eventlibrary.at(event_index).event_data.size() <=
107 reference_layer_index) {
108 m_eventlibrary.at(event_index).event_data.resize(reference_layer_index + 1);
109 }
110 m_eventlibrary.at(event_index).center_eta = eta_center;
111 m_eventlibrary.at(event_index).phi_mod = phi_within_cell;
112}

◆ set_sub_bin_distribution_and_energies()

void TFCSBinnedShower::set_sub_bin_distribution_and_energies ( std::vector< std::vector< std::vector< std::vector< float > > > > & sub_bin_distribution,
std::vector< float > & upscaling_energies )
inline

Definition at line 145 of file TFCSBinnedShower.h.

148 {
149 m_sub_bin_distribution = sub_bin_distribution;
150 m_upscaling_energies = upscaling_energies;
151 m_use_upscaling = true;
152 }

◆ setLevel()

void ISF_FCS::MLogging::setLevel ( MSG::Level lvl)
virtualinherited

Update outputlevel.

Definition at line 105 of file MLogging.cxx.

105 {
106 lvl = (lvl >= MSG::NUM_LEVELS) ? MSG::ALWAYS
107 : (lvl < MSG::NIL) ? MSG::NIL
108 : lvl;
109 msg().setLevel(lvl);
110}

◆ simulate()

FCSReturnCode TFCSBinnedShowerBase::simulate ( TFCSSimulationState & simulstate,
const TFCSTruthState * truth,
const TFCSExtrapolationState * extrapol ) const
overridevirtualinherited

Method in all derived classes to do some simulation.

Result should be returned in simulstate.

Simulate all energies in calo layers for energy parametrizations. Simulate cells for shape simulation.

Reimplemented from TFCSParametrizationBase.

Definition at line 29 of file TFCSBinnedShowerBase.cxx.

31 {
32
33 // select a random event from the library
34 float eta_center, phi_center;
35 long unsigned int reference_layer_index = CaloCell_ID_FCS::CaloSample_FCS::EMB2;
36 eta_center =
37 extrapol->eta(reference_layer_index, TFCSExtrapolationState::SUBPOS_MID);
38 if (eta_center > 1.4) { // Endcap becomes more relevant
39 reference_layer_index = CaloCell_ID_FCS::CaloSample_FCS::EME2;
40 }
41 // TODO: What about the endcap?
42 eta_center =
43 extrapol->eta(reference_layer_index, TFCSExtrapolationState::SUBPOS_MID);
44 phi_center =
45 extrapol->phi(reference_layer_index, TFCSExtrapolationState::SUBPOS_MID);
46
47 // Fill the total energy and layer energies into simulstate
48 float Einit;
49 const float Ekin = truth->Ekin();
50
51 if (OnlyScaleEnergy())
52 Einit = simulstate.E();
53 else
54 Einit = Ekin;
55
56 // Reset the total energy
57 simulstate.set_E(0);
58
59 get_event(simulstate, eta_center, phi_center, Einit, reference_layer_index);
60
61 for (long unsigned int layer_index = 0;
62 layer_index < CaloCell_ID_FCS::MaxSample; ++layer_index) {
63
64 float layer_energy = get_layer_energy(simulstate, layer_index);
65
66 // Reset and set the layer energy
67 simulstate.set_E(layer_index, 0);
68 simulstate.add_E(layer_index, layer_energy);
69 }
70
71 if (simulstate.E() > std::numeric_limits<double>::epsilon()) {
72 for (int ilayer = 0; ilayer < CaloCell_ID_FCS::MaxSample; ++ilayer) {
73 simulstate.set_Efrac(ilayer, simulstate.E(ilayer) / simulstate.E());
74 }
75 }
76 return FCSSuccess;
77}
virtual float get_layer_energy(TFCSSimulationState &simulstate, long unsigned int layer_index) const =0
virtual void get_event(TFCSSimulationState &simulstate, float eta_center, float phi_center, float e_init, long unsigned int reference_layer_index) const =0
do not persistify
double phi(int layer, int subpos) const
double eta(int layer, int subpos) const
void set_E(int sample, double Esample)
void add_E(int sample, double Esample)
void set_Efrac(int sample, double Efracsample)
double Ekin() const

◆ simulate_hit()

FCSReturnCode TFCSBinnedShowerBase::simulate_hit ( Hit & hit,
TFCSSimulationState & simulstate,
const TFCSTruthState * truth,
const TFCSExtrapolationState * extrapol )
overridevirtualinherited

simulated one hit position with some energy.

As last step in TFCSLateralShapeParametrizationHitChain::simulate, the hit should be mapped into a cell and this cell recorded in simulstate. All hits/cells should be resacled such that their final sum is simulstate->E(sample)

Reimplemented from TFCSLateralShapeParametrizationHitBase.

Definition at line 79 of file TFCSBinnedShowerBase.cxx.

81 {
82
83 const int pdgId = truth->pdgid();
84 const float charge = HepPDT::ParticleID(pdgId).charge();
85 long unsigned int layer_index = calosample();
86
87 const double center_eta = hit.center_eta();
88 const double center_phi = hit.center_phi();
89 const double center_r = hit.center_r();
90 const double center_z = hit.center_z();
91
92 ATH_MSG_VERBOSE(" Layer " << layer_index << " Extrap eta " << center_eta
93 << " phi " << center_phi << " R " << center_r);
94
95 //next MR: change to std::abs, std::sqrt functions
96 const float dist000 = TMath::Sqrt(center_r * center_r + center_z * center_z);
97 const float eta_jakobi = TMath::Abs(2.0 * TMath::Exp(-center_eta) /
98 (1.0 + TMath::Exp(-2 * center_eta)));
99
100 long unsigned int hit_index = hit.idx();
101
102 // Get necessary the hit information
103 float r, alpha, E;
104 std::tie(r, alpha, E) =
105 get_hit_position_and_energy(simulstate, layer_index, hit_index);
106
107 hit.reset();
108 hit.E() = E;
109
110 if (layer_index <= CaloCell_ID_FCS::CaloSample_FCS::FCAL0) {
111 float delta_eta_mm = r * std::cos(alpha);
112 float delta_phi_mm = r * std::sin(alpha);
113
114 // Particles with negative eta are expected to have the same shape
115 // as those with positive eta after transformation: delta_eta -->
116 // -delta_eta
117 if (center_eta < 0.) {
118 delta_eta_mm = -delta_eta_mm;
119 }
120
121 // We derive the shower shapes for electrons and positively charged
122 // hadrons. Particle with the opposite charge are expected to have the
123 // same shower shape after the transformation: delta_phi -->
124 // -delta_phi
125 if ((charge < 0. && pdgId != 11) || pdgId == -11)
126 delta_phi_mm = -delta_phi_mm;
127
128 const float delta_eta = delta_eta_mm / eta_jakobi / dist000;
129 const float delta_phi = delta_phi_mm / center_r;
130
131 hit.eta() = center_eta + delta_eta;
132 hit.phi() = TVector2::Phi_mpi_pi(center_phi + delta_phi);
133
134 ATH_MSG_VERBOSE(" Hit eta " << hit.eta() << " phi " << hit.phi()
135 << " layer " << layer_index);
136
137 } else { // FCAL is in (x,y,z)
138 const float hit_r = r * std::cos(alpha) + center_r;
139 float delta_phi = r * std::sin(alpha) / center_r;
140 // We derive the shower shapes for electrons and positively charged
141 // hadrons. Particle with the opposite charge are expected to have the
142 // same shower shape after the transformation: delta_phi -->
143 // -delta_phi
144 if ((charge < 0. && pdgId != 11) || pdgId == -11)
146 const float hit_phi = TVector2::Phi_mpi_pi(center_phi + delta_phi);
147 hit.x() = hit_r * std::cos(hit_phi);
148 hit.y() = hit_r * std::sin(hit_phi);
149 hit.z() = center_z;
150 ATH_MSG_VERBOSE(" Hit x " << hit.x() << " y " << hit.y() << " layer "
151 << layer_index);
152 }
153
154 return FCSSuccess;
155}
#define ATH_MSG_VERBOSE(x)
double charge(const T &p)
Definition AtlasPID.h:997
virtual std::tuple< float, float, float > get_hit_position_and_energy(TFCSSimulationState &simulstate, long unsigned int layer_index, long unsigned int hit_index) const =0
int pdgid() const
delta_phi(phi1, phi2)
Definition eFEXNTuple.py:14

◆ size()

virtual unsigned int TFCSParametrizationBase::size ( ) const
inlinevirtualinherited

Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operator[] methods give general access to these daughters.

Reimplemented in TFCSLateralShapeParametrizationHitChain, and TFCSParametrizationChain.

Definition at line 93 of file TFCSParametrizationBase.h.

93{ return 0; };

◆ startMsg()

std::string ISF_FCS::MLogging::startMsg ( MSG::Level lvl,
const std::string & file,
int line )
staticinherited

Make a message to decorate the start of logging.

Print a message for the start of logging.

Definition at line 116 of file MLogging.cxx.

116 {
117 int col1_len = 20;
118 int col2_len = 5;
119 int col3_len = 10;
120 auto last_slash = file.find_last_of('/');
121 int path_len = last_slash == std::string::npos ? 0 : last_slash;
122 int trim_point = path_len;
123 int total_len = file.length();
124 if (total_len - path_len > col1_len)
125 trim_point = total_len - col1_len;
126 std::string trimmed_name = file.substr(trim_point);
127 const char *LevelNames[MSG::NUM_LEVELS] = {
128 "NIL", "VERBOSE", "DEBUG", "INFO", "WARNING", "ERROR", "FATAL", "ALWAYS"};
129 std::string level = LevelNames[lvl];
130 std::string level_string = std::string("(") + level + ") ";
131 std::stringstream output;
132 output << std::setw(col1_len) << std::right << trimmed_name << ":"
133 << std::setw(col2_len) << std::left << line << std::setw(col3_len)
134 << std::right << level_string;
135 return output.str();
136}
output
Definition merge.py:16

◆ upscale()

void TFCSBinnedShower::upscale ( TFCSSimulationState & simulstate,
float & R_min,
float & R_max,
float & alpha_min,
float & alpha_max,
long unsigned int layer_index,
int bin_index ) const
private

Definition at line 359 of file TFCSBinnedShower.cxx.

362 {
363
364 float p = CLHEP::RandFlat::shoot(simulstate.randomEngine(), 0, 1);
365
366 float e_init = simulstate.getAuxInfo<float>("BSEinit"_FCShash);
367 std::vector<float> available_energies = m_upscaling_energies;
368
369 unsigned int e_index = 0;
370
371 std::vector<float> probabilities = {0.25f, 0.5f, 0.75f};
372
373 if (available_energies.size() > 1) {
374 // find closest energy index using binary search
375 auto it = std::upper_bound(available_energies.begin(),
376 available_energies.end(), e_init);
377 if (it != available_energies.end()) {
378 e_index = std::distance(available_energies.begin(), it);
379 } else {
380 e_index = available_energies.size() - 1;
381 }
382
383 float e_high = available_energies.at(e_index);
384 if (e_high < e_init || e_index == 0) {
385 if (m_sub_bin_distribution.at(e_index).size() > layer_index) {
386 probabilities =
387 m_sub_bin_distribution.at(e_index).at(layer_index).at(bin_index);
388 }
389 } else {
390 if (m_sub_bin_distribution.at(e_index).size() > layer_index &&
391 m_sub_bin_distribution.at(e_index - 1).size() > layer_index) {
392 float e_low = available_energies.at(e_index - 1);
393 float f_low = std::log(e_high / e_init) / (std::log(e_high / e_low));
394 float f_high = 1 - f_low;
395 for (unsigned int i = 0; i < 3; ++i) {
396 float p_low = m_sub_bin_distribution.at(e_index - 1)
397 .at(layer_index)
398 .at(bin_index)
399 .at(i);
400 float p_high = m_sub_bin_distribution.at(e_index)
401 .at(layer_index)
402 .at(bin_index)
403 .at(i);
404 probabilities[i] = f_low * p_low + f_high * p_high;
405 }
406 }
407 }
408 }
409
410 else if (available_energies.size() == 1) {
411 probabilities = m_sub_bin_distribution.at(0).at(layer_index).at(bin_index);
412 }
413
414 float p_alpha_low = probabilities[2] - probabilities[1] + probabilities[0];
415 float p_r;
416
417 if (p < p_alpha_low) {
418 alpha_max = (alpha_min + alpha_max) / 2.;
419 p_r = probabilities[0] / (p_alpha_low);
420 } else {
421 alpha_min = (alpha_min + alpha_max) / 2.;
422 p_r = (probabilities[1] - probabilities[0]) / (1 - p_alpha_low);
423 }
424
425 p = CLHEP::RandFlat::shoot(simulstate.randomEngine(), 0, 1);
426 if (layer_index != 2){
427 // if ((layer_index != 2) && (layer_index != 1)) {
428 if (p > p_r) {
429 R_min = (R_min + R_max) / 2.;
430 return;
431 } else {
432 R_max = (R_min + R_max) / 2.;
433 return;
434 }
435 }
436
437
438 // Use linear interpolation for layer 2
439 // It works better than uniform sampling for the second layer...
440 if (p_r < 0.25) {
441 p_r = 0.25; // Values below 0.25 are not allowed for linear pdf
442 } else if (p_r > 0.75) {
443 p_r = 0.75; // Values above 0.75 are not allowed for linear pdf
444 } else if (TMath::Abs(p_r - 0.5) < std::numeric_limits<float>::epsilon()) {
445 return; // Best upscaling is uniform sampling. Nothing to do here.
446 }
447
448 // Inverse CDF for linear pdf
449 float r = (1. - 4. * p_r) / (2. - 4. * p_r) -
450 TMath::Sqrt(((1. - 4. * p_r) / (2. - 4. * p_r)) *
451 ((1. - 4. * p_r) / (2. - 4. * p_r)) +
452 p / ((1. / 2.) - p_r));
453 if (r < 0) {
454 r = (1. - 4. * p_r) / (2. - 4. * p_r) +
455 TMath::Sqrt(((1. - 4. * p_r) / (2. - 4. * p_r)) *
456 ((1. - 4. * p_r) / (2. - 4. * p_r)) +
457 p / ((1. / 2.) - p_r));
458 }
459
460 R_min = R_min + r / 2 * (R_max - R_min);
461 R_max = R_min;
462
463 return;
464}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

boost::thread_specific_ptr<MsgStream> m_msg_tls ISF_FCS::MLogging::ATLAS_THREAD_SAFE
inlinestaticprivateinherited

Do not persistify!

MsgStream instance (a std::cout like with print-out levels)

Definition at line 215 of file MLogging.h.

◆ init_Ekin_max

double TFCSParametrizationBase::init_Ekin_max = 14000000
staticconstexprprotectedinherited

Do not persistify!

Definition at line 155 of file TFCSParametrizationBase.h.

◆ init_Ekin_min

double TFCSParametrizationBase::init_Ekin_min = 0
staticconstexprprotectedinherited

Do not persistify!

Definition at line 154 of file TFCSParametrizationBase.h.

◆ init_Ekin_nominal

double TFCSParametrizationBase::init_Ekin_nominal = 0
staticconstexprprotectedinherited

Definition at line 153 of file TFCSParametrizationBase.h.

◆ init_eta_max

double TFCSParametrizationBase::init_eta_max = 100
staticconstexprprotectedinherited

Do not persistify!

Definition at line 158 of file TFCSParametrizationBase.h.

◆ init_eta_min

double TFCSParametrizationBase::init_eta_min = -100
staticconstexprprotectedinherited

Do not persistify!

Definition at line 157 of file TFCSParametrizationBase.h.

◆ init_eta_nominal

double TFCSParametrizationBase::init_eta_nominal = 0
staticconstexprprotectedinherited

Do not persistify!

Definition at line 156 of file TFCSParametrizationBase.h.

◆ m_calosample

int TFCSLateralShapeParametrization::m_calosample
privateinherited

Definition at line 47 of file TFCSLateralShapeParametrization.h.

◆ m_coordinates

event_bins_t TFCSBinnedShower::m_coordinates
private

Definition at line 198 of file TFCSBinnedShower.h.

◆ m_default_hit_energy

float TFCSBinnedShower::m_default_hit_energy = 4.
private

Definition at line 189 of file TFCSBinnedShower.h.

◆ m_Ekin_bin

int TFCSLateralShapeParametrization::m_Ekin_bin
privateinherited

Definition at line 46 of file TFCSLateralShapeParametrization.h.

◆ m_Ekin_max

double TFCSParametrization::m_Ekin_max
privateinherited

Definition at line 64 of file TFCSParametrization.h.

◆ m_Ekin_min

double TFCSParametrization::m_Ekin_min
privateinherited

Definition at line 64 of file TFCSParametrization.h.

◆ m_Ekin_nominal

double TFCSParametrization::m_Ekin_nominal
privateinherited

Definition at line 64 of file TFCSParametrization.h.

◆ m_eta_max

double TFCSParametrization::m_eta_max
privateinherited

Definition at line 65 of file TFCSParametrization.h.

◆ m_eta_min

double TFCSParametrization::m_eta_min
privateinherited

Definition at line 65 of file TFCSParametrization.h.

◆ m_eta_nominal

double TFCSParametrization::m_eta_nominal
privateinherited

Definition at line 65 of file TFCSParametrization.h.

◆ m_eventlibrary

eventvector_t TFCSBinnedShower::m_eventlibrary
private

Definition at line 197 of file TFCSBinnedShower.h.

◆ m_geo

ICaloGeometry* TFCSBinnedShowerBase::m_geo {}
protectedinherited

Definition at line 63 of file TFCSBinnedShowerBase.h.

63{};

◆ m_hdf5_file

std::string TFCSBinnedShower::m_hdf5_file
private

Definition at line 194 of file TFCSBinnedShower.h.

◆ m_max_hits_per_voxel

int TFCSBinnedShower::m_max_hits_per_voxel = 100
private

Definition at line 191 of file TFCSBinnedShower.h.

◆ m_n_layers

const long unsigned int TFCSBinnedShower::m_n_layers
private
Initial value:

Definition at line 185 of file TFCSBinnedShower.h.

◆ m_nm

std::string ISF_FCS::MLogging::m_nm
privateinherited

Message source name.

Definition at line 211 of file MLogging.h.

◆ m_pdgid

std::set<int> TFCSParametrization::m_pdgid
privateinherited

Definition at line 63 of file TFCSParametrization.h.

◆ m_sub_bin_distribution

std::vector<std::vector<std::vector<std::vector<float> > > > TFCSBinnedShower::m_sub_bin_distribution
private

Definition at line 233 of file TFCSBinnedShower.h.

◆ m_upscaling_energies

std::vector<float> TFCSBinnedShower::m_upscaling_energies
private

Definition at line 234 of file TFCSBinnedShower.h.

◆ m_use_eta_matching

bool TFCSBinnedShower::m_use_eta_matching = false
private

Definition at line 216 of file TFCSBinnedShower.h.

◆ m_use_event_cherry_picking

bool TFCSBinnedShower::m_use_event_cherry_picking = false
private

Definition at line 211 of file TFCSBinnedShower.h.

◆ m_use_event_matching

bool TFCSBinnedShower::m_use_event_matching = false
private

Definition at line 205 of file TFCSBinnedShower.h.

◆ m_use_upscaling

bool TFCSBinnedShower::m_use_upscaling = false
private

Definition at line 228 of file TFCSBinnedShower.h.


The documentation for this class was generated from the following files: