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

#include <TFCSBinnedShower.h>

Inheritance diagram for TFCSBinnedShower:
Collaboration diagram for TFCSBinnedShower:

Classes

struct  event_t
struct  layer_bins_t
struct  layer_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 50 of file TFCSBinnedShower.cxx.

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

◆ ~TFCSBinnedShower()

TFCSBinnedShower::~TFCSBinnedShower ( )
virtual

Definition at line 53 of file TFCSBinnedShower.cxx.

53{}

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 boost::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 221 of file TFCSBinnedShower.cxx.

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

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

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

◆ 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 333 of file TFCSBinnedShower.cxx.

335 {
336 float R_min = m_coordinates.at(layer_index).R_lower.at(bin_index);
337 float R_max = m_coordinates.at(layer_index).R_size.at(bin_index) +
338 m_coordinates.at(layer_index).R_lower.at(bin_index);
339
340 float alpha_min = m_coordinates.at(layer_index).alpha_lower.at(bin_index);
341 float alpha_max = m_coordinates.at(layer_index).alpha_size.at(bin_index) +
342 m_coordinates.at(layer_index).alpha_lower.at(bin_index);
343
344 if (m_use_upscaling) {
345 upscale(simulstate, R_min, R_max, alpha_min, alpha_max, layer_index,
346 bin_index);
347 }
348 float R;
349 if (TMath::Abs(R_max - R_min) > std::numeric_limits<float>::epsilon()) {
350 R = CLHEP::RandFlat::shoot(simulstate.randomEngine(), R_min, R_max);
351 } else {
352 R = R_min; // If the range is too small, just use the minimum value
353 }
354 float alpha =
355 CLHEP::RandFlat::shoot(simulstate.randomEngine(), alpha_min, alpha_max);
356
357 return std::make_tuple(R, alpha);
358}
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 296 of file TFCSBinnedShower.cxx.

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

◆ 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 179 of file TFCSBinnedShower.cxx.

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

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

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

◆ 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 267 of file TFCSBinnedShower.cxx.

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

◆ 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 652 of file TFCSBinnedShower.cxx.

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

541 {
542
543 if (!only_load_meta_data) {
544 m_eventlibrary.clear();
545 }
546
547 m_coordinates.clear();
548
549 if (m_use_upscaling) {
551 }
552
553 // layer dependent variables
554 for (long unsigned int layer_index : layers) {
555
556 ATH_MSG_INFO("Loading layer " << layer_index << " from file: " << filename);
557
558 // Load the bin boundaries for this layer
559 load_bin_boundaries(filename, layer_index);
560
561 if (!only_load_meta_data) {
562 // Load the layer energies
563 load_layer_energy(filename, layer_index);
564 }
565
566 }
567
569 !only_load_meta_data) {
571 }
572
573 return;
574}
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 577 of file TFCSBinnedShower.cxx.

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

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

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

◆ load_sub_bin_distribution()

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

Definition at line 776 of file TFCSBinnedShower.cxx.

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

◆ 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 76 of file TFCSBinnedShower.cxx.

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

◆ 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 55 of file TFCSBinnedShower.cxx.

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

◆ 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 90 of file TFCSBinnedShower.cxx.

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

◆ 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
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 360 of file TFCSBinnedShower.cxx.

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

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: