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

#include <TFCSPredictExtrapWeights.h>

Inheritance diagram for TFCSPredictExtrapWeights:
Collaboration diagram for TFCSPredictExtrapWeights:

Public Types

enum  FCSfreemem { kfreemem = BIT(17) }
enum  TFCSPredictExtrapWeightsStatusBits { kUseHardcodedWeight = BIT(15) }
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

 TFCSPredictExtrapWeights (const char *name=nullptr, const char *title=nullptr)
virtual ~TFCSPredictExtrapWeights ()
virtual bool operator== (const TFCSParametrizationBase &ref) const override
 The == operator compares the content of instances.
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.
bool freemem () const
void set_freemem ()
bool initializeNetwork (int pid, const std::string &etaBin, const std::string &FastCaloNNInputFolderName)
bool getNormInputs (const std::string &etaBin, const std::string &FastCaloTXTInputFolderName)
std::map< std::string, double > prepareInputs (TFCSSimulationState &simulstate, const float truthE) const
void Print (Option_t *option="") const override
bool UseHardcodedWeight () const
void set_UseHardcodedWeight ()
void reset_UseHardcodedWeight ()
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 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 numbers and give different results each time.
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_Ekin_bin (int bin) const override
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 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 void set_geometry (ICaloGeometry *geo)
 Method to set the geometry access pointer.
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 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 void test_path (std::string &net_path, std::string const &norm_path, TFCSSimulationState *simulstate=nullptr, const TFCSTruthState *truth=nullptr, const TFCSExtrapolationState *extrapol=nullptr)
static void unit_test (TFCSSimulationState *simulstate=nullptr, const TFCSTruthState *truth=nullptr, const TFCSExtrapolationState *extrapol=nullptr)
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

bool compare (const TFCSParametrizationBase &ref) const

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 Attributes

std::string * m_input = nullptr
std::vector< int > * m_relevantLayers = nullptr
lwt::LightweightNeuralNetwork * m_nn = nullptr
std::vector< int > * m_normLayers
 Do not persistify.
std::vector< float > * m_normMeans
std::vector< float > * m_normStdDevs
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 18 of file TFCSPredictExtrapWeights.h.

Member Typedef Documentation

◆ 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

◆ FCSfreemem

Enumerator
kfreemem 

Set this bit in the TObject bit if the memory for m_input should be freed after reading in athena.

Definition at line 38 of file TFCSPredictExtrapWeights.h.

38 {
39 kfreemem = BIT(17)
41 };
@ kfreemem
Set this bit in the TObject bit if the memory for m_input should be freed after reading in athena.

◆ 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.

◆ TFCSPredictExtrapWeightsStatusBits

Constructor & Destructor Documentation

◆ TFCSPredictExtrapWeights()

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

◆ ~TFCSPredictExtrapWeights()

TFCSPredictExtrapWeights::~TFCSPredictExtrapWeights ( )
virtual

Definition at line 55 of file TFCSPredictExtrapWeights.cxx.

55 {
56 if (m_input != nullptr) {
57 delete m_input;
58 }
59 if (m_relevantLayers != nullptr) {
60 delete m_relevantLayers;
61 }
62 if (m_normLayers != nullptr) {
63 delete m_normLayers;
64 }
65 if (m_normMeans != nullptr) {
66 delete m_normMeans;
67 }
68 if (m_normStdDevs != nullptr) {
69 delete m_normStdDevs;
70 }
71 if (m_nn != nullptr) {
72 delete m_nn;
73 }
74}
std::vector< float > * m_normMeans
lwt::LightweightNeuralNetwork * m_nn
std::vector< float > * m_normStdDevs
std::vector< int > * m_relevantLayers
std::vector< int > * m_normLayers
Do not persistify.

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.

◆ 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; };

◆ 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; };

◆ 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)

◆ freemem()

bool TFCSPredictExtrapWeights::freemem ( ) const
inline

Definition at line 42 of file TFCSPredictExtrapWeights.h.

42{ return TestBit(kfreemem); };

◆ 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_number_of_hits()

int TFCSLateralShapeParametrizationHitBase::get_number_of_hits ( TFCSSimulationState & simulstate,
const TFCSTruthState * truth,
const TFCSExtrapolationState * extrapol ) const
virtualinherited

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 in TFCS2DFunctionLateralShapeParametrization, TFCSBinnedShowerBase, TFCSFlatLateralShapeParametrization, TFCSHistoLateralShapeParametrization, and TFCSLateralShapeParametrizationHitNumberFromE.

Definition at line 25 of file TFCSLateralShapeParametrizationHitBase.cxx.

27 {
28 return -1;
29}

◆ 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}

◆ 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}

◆ getNormInputs()

bool TFCSPredictExtrapWeights::getNormInputs ( const std::string & etaBin,
const std::string & FastCaloTXTInputFolderName )

Definition at line 98 of file TFCSPredictExtrapWeights.cxx.

99 {
100 ATH_MSG_DEBUG(" Getting normalization inputs... ");
101
102 // Open corresponding TXT file and extract mean/std dev for each variable
103 if (m_normLayers != nullptr) {
104 m_normLayers->clear();
105 } else {
106 m_normLayers = new std::vector<int>();
107 }
108 if (m_normMeans != nullptr) {
109 m_normMeans->clear();
110 } else {
111 m_normMeans = new std::vector<float>();
112 }
113 if (m_normStdDevs != nullptr) {
114 m_normStdDevs->clear();
115 } else {
116 m_normStdDevs = new std::vector<float>();
117 }
118 std::string inputFileName = FastCaloTXTInputFolderName +
119 "MeanStdDevEnergyFractions_eta_" + etaBin +
120 ".txt";
121 ATH_MSG_DEBUG(" Opening " << inputFileName);
122 std::ifstream inputTXT(inputFileName);
123 if (inputTXT.is_open()) {
124 std::string line;
125 while (getline(inputTXT, line)) {
126 std::stringstream ss(line);
127 unsigned int counter = 0;
128 while (ss.good()) {
129 std::string substr;
130 getline(ss, substr, ' ');
131 if (counter == 0) { // Get index (#layer or -1 if var == etrue)
132 if (substr != "etrue") {
133 int index = std::stoi(substr.substr(substr.find('_') + 1));
134 m_normLayers->push_back(index);
135 } else { // etrue
136 m_normLayers->push_back(-1);
137 }
138 } else if (counter == 1) {
139 m_normMeans->push_back(std::stof(substr));
140 } else if (counter == 2) {
141 m_normStdDevs->push_back(std::stof(substr));
142 }
143 counter++;
144 }
145 }
146 inputTXT.close();
147 } else {
148 ATH_MSG_ERROR(" Unable to open file " << inputFileName);
149 return false;
150 }
151
152 return true;
153}
#define ATH_MSG_ERROR(x)
static Double_t ss
str index
Definition DeMoScan.py:362
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin

◆ initializeNetwork()

bool TFCSPredictExtrapWeights::initializeNetwork ( int pid,
const std::string & etaBin,
const std::string & FastCaloNNInputFolderName )

Definition at line 298 of file TFCSPredictExtrapWeights.cxx.

300 {
301
303 "Using FastCaloNNInputFolderName: " << FastCaloNNInputFolderName);
304 set_pdgid(pid);
305
306 std::string inputFileName =
307 FastCaloNNInputFolderName + "NN_" + etaBin + ".json";
308 ATH_MSG_DEBUG("Will read JSON file: " << inputFileName);
309 if (inputFileName.empty()) {
310 ATH_MSG_ERROR("Could not find json file " << inputFileName);
311 return false;
312 } else {
313 ATH_MSG_INFO("For pid: " << pid << " and etaBin" << etaBin
314 << ", loading json file " << inputFileName);
315 std::ifstream input(inputFileName);
316 std::stringstream sin;
317 sin << input.rdbuf();
318 input.close();
319 auto config = lwt::parse_json(sin);
320 m_nn = new lwt::LightweightNeuralNetwork(config.inputs, config.layers,
321 config.outputs);
322 if (m_nn == nullptr) {
323 ATH_MSG_ERROR("Could not create LightWeightNeuralNetwork from "
324 << inputFileName);
325 return false;
326 }
327 if (m_input != nullptr) {
328 delete m_input;
329 }
330 m_input = new std::string(sin.str());
331 // Extract relevant layers from the outputs
332 m_relevantLayers = new std::vector<int>();
333 for (auto name : config.outputs) {
334 int layer = std::stoi(
335 name.erase(0, 13)); // remove "extrapWeight_" and convert to int
336 m_relevantLayers->push_back(layer);
337 }
338 }
339 return true;
340}
#define ATH_MSG_INFO(x)
virtual void set_pdgid(int id)
@ layer
Definition HitInfo.h:79

◆ 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()

bool TFCSLateralShapeParametrization::is_match_Ekin_bin ( int bin) const
inlineoverridevirtualinherited

Reimplemented from TFCSParametrizationBase.

Definition at line 15 of file TFCSLateralShapeParametrization.h.

15 {
16 if (Ekin_bin() == -1)
17 return true;
18 return bin == Ekin_bin();
19 };

◆ 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

◆ 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

◆ operator==()

bool TFCSPredictExtrapWeights::operator== ( const TFCSParametrizationBase & ref) const
overridevirtual

The == operator compares the content of instances.

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

Reimplemented from TFCSParametrizationBase.

Definition at line 76 of file TFCSPredictExtrapWeights.cxx.

77 {
78 if (IsA() != ref.IsA()) {
79 ATH_MSG_DEBUG("operator==: different class types "
80 << IsA()->GetName() << " != " << ref.IsA()->GetName());
81 return false;
82 }
83 const TFCSPredictExtrapWeights &ref_typed =
84 static_cast<const TFCSPredictExtrapWeights &>(ref);
85
87 return true;
89 return false;
91 return false;
92
93 return (m_input->compare(*ref_typed.m_input) == 0);
94}
bool compare(const TFCSParametrizationBase &ref) const
bool compare(const TFCSParametrizationBase &ref) const
Do not persistify!
bool compare(const TFCSParametrizationBase &ref) const
TFCSPredictExtrapWeights(const char *name=nullptr, const char *title=nullptr)

◆ 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; };

◆ prepareInputs()

std::map< std::string, double > TFCSPredictExtrapWeights::prepareInputs ( TFCSSimulationState & simulstate,
const float truthE ) const

Definition at line 158 of file TFCSPredictExtrapWeights.cxx.

159 {
160 std::map<std::string, double> inputVariables;
161 for (int ilayer = 0; ilayer < CaloCell_ID_FCS::MaxSample; ++ilayer) {
162 if (std::find(m_relevantLayers->cbegin(), m_relevantLayers->cend(),
163 ilayer) != m_relevantLayers->cend()) {
164 const std::string layer = std::to_string(ilayer);
165 // Find index
166 auto itr =
167 std::find(m_normLayers->cbegin(), m_normLayers->cend(), ilayer);
168 if (itr != m_normLayers->cend()) {
169 const int index = std::distance(m_normLayers->cbegin(), itr);
170 inputVariables["ef_" + layer] =
171 (simulstate.Efrac(ilayer) - std::as_const(m_normMeans)->at(index)) /
172 std::as_const(m_normStdDevs)->at(index);
173 } else {
174 ATH_MSG_ERROR("Normalization information not found for layer "
175 << ilayer);
176 }
177 }
178 }
179 // Find index for truth energy
180 auto itr = std::find(m_normLayers->cbegin(), m_normLayers->cend(), -1);
181 int index = std::distance(m_normLayers->cbegin(), itr);
182 inputVariables["etrue"] = (truthE - std::as_const(m_normMeans)->at(index)) /
183 std::as_const(m_normStdDevs)->at(index);
184 if (is_match_pdgid(22)) {
185 inputVariables["pdgId"] = 1; // one hot enconding
186 } else if (is_match_pdgid(11) || is_match_pdgid(-11)) {
187 inputVariables["pdgId"] = 0; // one hot enconding
188 }
189 return inputVariables;
190}
virtual bool is_match_pdgid(int id) const override
double Efrac(int sample) const

◆ Print()

void TFCSPredictExtrapWeights::Print ( Option_t * option = "") const
override

Definition at line 511 of file TFCSPredictExtrapWeights.cxx.

511 {
512 TString opt(option);
513 bool shortprint = opt.Index("short") >= 0;
514 bool longprint = msgLvl(MSG::DEBUG) || (msgLvl(MSG::INFO) && !shortprint);
515 TString optprint = opt;
516 optprint.ReplaceAll("short", "");
518
519 if (longprint)
520 ATH_MSG_INFO(optprint << " m_input (TFCSPredictExtrapWeights): "
522 if (longprint)
523 ATH_MSG_INFO(optprint << " Address of m_nn: " << (void *)m_nn);
524}
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 override
const T * as_const_ptr(const T *p)
Helper for getting a const version of a pointer.

◆ 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

◆ 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_UseHardcodedWeight()

void TFCSPredictExtrapWeights::reset_UseHardcodedWeight ( )
inline

Definition at line 73 of file TFCSPredictExtrapWeights.h.

73{ ResetBit(kUseHardcodedWeight); };

◆ set_calosample()

void TFCSLateralShapeParametrization::set_calosample ( int cs)
inherited

Definition at line 21 of file TFCSLateralShapeParametrization.cxx.

21 {
22 m_calosample = cs;
23}

◆ 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_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.

17 {
19}

◆ 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_freemem()

void TFCSPredictExtrapWeights::set_freemem ( )
inline

Definition at line 43 of file TFCSPredictExtrapWeights.h.

43{ SetBit(kfreemem); };

◆ set_geometry()

void TFCSParametrizationBase::set_geometry ( ICaloGeometry * geo)
virtualinherited

Method to set the geometry access pointer.

Loops over daughter objects if present

Reimplemented in TFCSBinnedShowerBase, TFCSHistoLateralShapeParametrization, TFCSHitCellMapping, TFCSPhiModulationCorrection, and TFCSVoxelHistoLateralCovarianceFluctuations.

Definition at line 24 of file TFCSParametrizationBase.cxx.

24 {
25 for (unsigned int i = 0; i < size(); ++i)
26 (*this)[i]->set_geometry(geo);
27}

◆ set_match_all_pdgid()

virtual void TFCSParametrizationBase::set_match_all_pdgid ( )
inlinevirtualinherited

Definition at line 83 of file TFCSParametrizationBase.h.

83{ SetBit(kMatchAllPDGID); };

◆ 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)

◆ 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_UseHardcodedWeight()

void TFCSPredictExtrapWeights::set_UseHardcodedWeight ( )
inline

Definition at line 72 of file TFCSPredictExtrapWeights.h.

72{ SetBit(kUseHardcodedWeight); };

◆ 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 TFCSPredictExtrapWeights::simulate ( TFCSSimulationState & simulstate,
const TFCSTruthState * truth,
const TFCSExtrapolationState * extrapol ) const
overridevirtual

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 194 of file TFCSPredictExtrapWeights.cxx.

196 {
197
198 // Get inputs to Neural Network
199 std::map<std::string, double> inputVariables =
200 prepareInputs(simulstate, truth->E() * 0.001);
201
202 // Get predicted extrapolation weights
203 auto outputs = m_nn->compute(inputVariables);
204 for (int ilayer = 0; ilayer < CaloCell_ID_FCS::MaxSample; ++ilayer) {
205 if (std::find(m_relevantLayers->cbegin(), m_relevantLayers->cend(),
206 ilayer) != m_relevantLayers->cend()) {
207 ATH_MSG_DEBUG("TFCSPredictExtrapWeights::simulate: layer: "
208 << ilayer << " weight: "
209 << outputs["extrapWeight_" + std::to_string(ilayer)]);
210 float weight = outputs["extrapWeight_" + std::to_string(ilayer)];
211 // Protections
212 if (weight < 0) {
213 weight = 0;
214 } else if (weight > 1) {
215 weight = 1;
216 }
217 simulstate.setAuxInfo<float>(ilayer, weight);
218 } else { // use weight=0.5 for non-relevant layers
220 "Setting weight=0.5 for layer = " << std::to_string(ilayer));
221 simulstate.setAuxInfo<float>(ilayer, float(0.5));
222 }
223 }
224 return FCSSuccess;
225}
std::map< std::string, double > prepareInputs(TFCSSimulationState &simulstate, const float truthE) const
void setAuxInfo(std::uint32_t index, const T &val)

◆ simulate_hit()

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

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 228 of file TFCSPredictExtrapWeights.cxx.

230 {
231
232 const int cs = calosample();
233
234 // Get corresponding predicted extrapolation weight from simulstate
235 float extrapWeight;
236 if (simulstate.hasAuxInfo(cs)) {
237 extrapWeight = simulstate.getAuxInfo<float>(cs);
238 } else { // missing AuxInfo
240 "Simulstate is not decorated with extrapolation weights for cs = "
241 << std::to_string(cs));
242 return FCSFatal;
243 }
244
245 double eta = (1. - extrapWeight) * extrapol->eta(cs, SUBPOS_ENT) +
246 extrapWeight * extrapol->eta(cs, SUBPOS_EXT);
247 double phi = (1. - extrapWeight) * extrapol->phi(cs, SUBPOS_ENT) +
248 extrapWeight * extrapol->phi(cs, SUBPOS_EXT);
249 float extrapWeight_for_r_z = extrapWeight;
250 if (UseHardcodedWeight()) {
251 extrapWeight_for_r_z = 0.5;
253 "Will use extrapWeight=0.5 for r and z when constructing a hit");
254 } else {
255 ATH_MSG_DEBUG("Will use predicted extrapWeight also for r and z when "
256 "constructing a hit");
257 }
258 double r = (1. - extrapWeight_for_r_z) * extrapol->r(cs, SUBPOS_ENT) +
259 extrapWeight_for_r_z * extrapol->r(cs, SUBPOS_EXT);
260 double z = (1. - extrapWeight_for_r_z) * extrapol->z(cs, SUBPOS_ENT) +
261 extrapWeight_for_r_z * extrapol->z(cs, SUBPOS_EXT);
262
263 if (!std::isfinite(r) || !std::isfinite(z) || !std::isfinite(eta) ||
264 !std::isfinite(phi)) {
265 ATH_MSG_WARNING("Extrapolator contains NaN or infinite number.\nSetting "
266 "center position to calo boundary.");
267 ATH_MSG_WARNING("Before fix: center_r: "
268 << r << " center_z: " << z << " center_phi: " << phi
269 << " center_eta: " << eta << " weight: " << extrapWeight
270 << " cs: " << cs);
271 // If extrapolator fails we can set position to calo boundary
272 r = extrapol->IDCaloBoundary_r();
273 z = extrapol->IDCaloBoundary_z();
274 eta = extrapol->IDCaloBoundary_eta();
275 phi = extrapol->IDCaloBoundary_phi();
276 ATH_MSG_WARNING("After fix: center_r: "
277 << r << " center_z: " << z << " center_phi: " << phi
278 << " center_eta: " << eta << " weight: " << extrapWeight
279 << " cs: " << cs);
280 }
281
282 hit.setCenter_r(r);
283 hit.setCenter_z(z);
284 hit.setCenter_eta(eta);
285 hit.setCenter_phi(phi);
286
287 ATH_MSG_DEBUG("TFCSPredictExtrapWeights: center_r: "
288 << hit.center_r() << " center_z: " << hit.center_z()
289 << " center_phi: " << hit.center_phi()
290 << " center_eta: " << hit.center_eta()
291 << " weight: " << extrapWeight << " cs: " << cs);
292
293 return FCSSuccess;
294}
Scalar phi() const
phi method
#define ATH_MSG_FATAL(x)
#define z
bool hasAuxInfo(std::uint32_t index) const
const T getAuxInfo(std::uint32_t index) const
int r
Definition globals.cxx:22

◆ 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
TFile * file

◆ test_path()

void TFCSPredictExtrapWeights::test_path ( std::string & net_path,
std::string const & norm_path,
TFCSSimulationState * simulstate = nullptr,
const TFCSTruthState * truth = nullptr,
const TFCSExtrapolationState * extrapol = nullptr )
static

Definition at line 390 of file TFCSPredictExtrapWeights.cxx.

393 {
394 ISF_FCS::MLogging logger;
395 ATH_MSG_NOCLASS(logger, "Testing net path ..."
396 << net_path.substr(net_path.length() - 20)
397 << " and norm path ..."
398 << norm_path.substr(norm_path.length() - 20));
399 if (!simulstate) {
400 simulstate = new TFCSSimulationState();
401#if defined(__FastCaloSimStandAlone__)
402 simulstate->setRandomEngine(new CLHEP::TRandomEngine());
403#else
404 simulstate->setRandomEngine(new CLHEP::RanluxEngine());
405#endif
406 }
407 if (!truth) {
408 TFCSTruthState *t = new TFCSTruthState();
409 t->SetPtEtaPhiM(524288000, 0, 0, 130); // 524288 GeV
410 t->set_pdgid(22); // photon
411 truth = t;
412 }
413 if (!extrapol) {
414 TFCSExtrapolationState *e = new TFCSExtrapolationState();
415 e->set_IDCaloBoundary_eta(truth->Eta());
416 for (int i = 0; i < 24; ++i) {
417 e->set_eta(i, TFCSExtrapolationState::SUBPOS_ENT, truth->Eta());
418 e->set_eta(i, TFCSExtrapolationState::SUBPOS_EXT, truth->Eta());
419 e->set_eta(i, TFCSExtrapolationState::SUBPOS_MID, truth->Eta());
423 e->set_r(i, TFCSExtrapolationState::SUBPOS_ENT, 1500 + i * 10);
424 e->set_r(i, TFCSExtrapolationState::SUBPOS_EXT, 1510 + i * 10);
425 e->set_r(i, TFCSExtrapolationState::SUBPOS_MID, 1505 + i * 10);
426 e->set_z(i, TFCSExtrapolationState::SUBPOS_ENT, 3500 + i * 10);
427 e->set_z(i, TFCSExtrapolationState::SUBPOS_EXT, 3510 + i * 10);
428 e->set_z(i, TFCSExtrapolationState::SUBPOS_MID, 3505 + i * 10);
429 }
430 extrapol = e;
431 }
432
433 // Set energy in layers which then will be retrieved in simulate_hit()
434 simulstate->set_E(0, 1028.77124023);
435 simulstate->set_E(1, 68199.0625);
436 simulstate->set_E(2, 438270.78125);
437 simulstate->set_E(3, 3024.02929688);
438 simulstate->set_E(12, 1330.10131836);
439 simulstate->set_E(1028.77124023 + 68199.0625 + 438270.78125 + 3024.02929688 +
440 1330.10131836);
441 simulstate->set_Efrac(0, simulstate->E(0) / simulstate->E());
442 simulstate->set_Efrac(1, simulstate->E(1) / simulstate->E());
443 simulstate->set_Efrac(2, simulstate->E(2) / simulstate->E());
444 simulstate->set_Efrac(3, simulstate->E(3) / simulstate->E());
445 simulstate->set_Efrac(12, simulstate->E(12) / simulstate->E());
446
447 const int pdgId = truth->pdgid();
448 const float Ekin = truth->Ekin();
449 const float eta = truth->Eta();
450
451 ATH_MSG_NOCLASS(logger, "True energy " << Ekin << " pdgId " << pdgId
452 << " eta " << eta);
453
454 // Find eta bin
455 const int Eta = eta * 10;
456 std::string etaBin = "";
457 for (int i = 0; i <= 25; ++i) {
458 int etaTmp = i * 5;
459 if (Eta >= etaTmp && Eta < (etaTmp + 5)) {
460 etaBin = std::to_string(i * 5) + "_" + std::to_string((i + 1) * 5);
461 }
462 }
463
464 ATH_MSG_NOCLASS(logger, "etaBin = " << etaBin);
465
466 TFCSPredictExtrapWeights NN("NN", "NN");
467 NN.setLevel(MSG::INFO);
468 const int pid = truth->pdgid();
469 NN.initializeNetwork(pid, etaBin, net_path);
470 NN.getNormInputs(etaBin, norm_path);
471
472 // Get extrapWeights and save them as AuxInfo in simulstate
473
474 // Get inputs to Neural Network
475 std::map<std::string, double> inputVariables =
476 NN.prepareInputs(*simulstate, truth->E() * 0.001);
477
478 // Get predicted extrapolation weights
479 ATH_MSG_NOCLASS(logger, "computing with m_nn");
480 auto outputs = NN.m_nn->compute(inputVariables);
481 const std::vector<int> layers = {0, 1, 2, 3, 12};
482 for (int ilayer : layers) {
483 simulstate->setAuxInfo<float>(
484 ilayer, outputs["extrapWeight_" + std::to_string(ilayer)]);
485 }
486
487 // Simulate
488 const int layer = 0;
489 NN.set_calosample(layer);
490 TFCSLateralShapeParametrizationHitBase::Hit hit;
491 NN.simulate_hit(hit, *simulstate, truth, extrapol);
492
493 // Write
494 TFile *fNN = new TFile("FCSNNtest.root", "RECREATE");
495 NN.Write();
496 fNN->ls();
497 fNN->Close();
498 delete fNN;
499
500 // Open
501 fNN = TFile::Open("FCSNNtest.root");
502 TFCSPredictExtrapWeights *NN2 = (TFCSPredictExtrapWeights *)(fNN->Get("NN"));
503
504 NN2->setLevel(MSG::INFO);
505 NN2->simulate_hit(hit, *simulstate, truth, extrapol);
506 //simulstate->Print();
507
508 return;
509}
#define ATH_MSG_NOCLASS(logger_name, x)
Definition MLogging.h:52
@ Eta
Definition RPCdef.h:8
virtual void setLevel(MSG::Level lvl)
Update outputlevel.
Definition MLogging.cxx:105
virtual FCSReturnCode simulate_hit(Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) override
simulated one hit position with some energy.
void set_E(int sample, double Esample)
void set_Efrac(int sample, double Efracsample)
void setRandomEngine(CLHEP::HepRandomEngine *engine)
int pdgid() const
double Ekin() const
static Root::TMsgLogger logger("iLumiCalc")
layers(flags, cells_name, *args, **kw)
Here we define wrapper functions to set up all of the standard corrections.

◆ unit_test()

void TFCSPredictExtrapWeights::unit_test ( TFCSSimulationState * simulstate = nullptr,
const TFCSTruthState * truth = nullptr,
const TFCSExtrapolationState * extrapol = nullptr )
static

Definition at line 374 of file TFCSPredictExtrapWeights.cxx.

376 {
377 const std::string this_file = __FILE__;
378 const std::string parent_dir = this_file.substr(0, this_file.find("/src/"));
379 const std::string norm_path = parent_dir + "/share/NormPredExtrapSample/";
380 std::string net_path = "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/"
381 "FastCaloSim/LWTNNPredExtrapSample/";
382 test_path(net_path, norm_path, simulstate, truth, extrapol);
383 //net_path = "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/FastCaloSim/"
384 // "ONNXPredExtrapSample/";
385 //test_path(net_path, norm_path, simulstate, truth, extrapol);
386}
static void test_path(std::string &net_path, std::string const &norm_path, TFCSSimulationState *simulstate=nullptr, const TFCSTruthState *truth=nullptr, const TFCSExtrapolationState *extrapol=nullptr)

◆ UseHardcodedWeight()

bool TFCSPredictExtrapWeights::UseHardcodedWeight ( ) const
inline

Definition at line 71 of file TFCSPredictExtrapWeights.h.

71{ return TestBit(kUseHardcodedWeight); };

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_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_input

std::string* TFCSPredictExtrapWeights::m_input = nullptr
private

Definition at line 80 of file TFCSPredictExtrapWeights.h.

◆ m_nm

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

Message source name.

Definition at line 211 of file MLogging.h.

◆ m_nn

lwt::LightweightNeuralNetwork* TFCSPredictExtrapWeights::m_nn = nullptr
private

Definition at line 82 of file TFCSPredictExtrapWeights.h.

◆ m_normLayers

std::vector<int>* TFCSPredictExtrapWeights::m_normLayers
private
Initial value:
=
nullptr

Do not persistify.

Definition at line 83 of file TFCSPredictExtrapWeights.h.

◆ m_normMeans

std::vector<float>* TFCSPredictExtrapWeights::m_normMeans
private
Initial value:
=
nullptr

Definition at line 85 of file TFCSPredictExtrapWeights.h.

◆ m_normStdDevs

std::vector<float>* TFCSPredictExtrapWeights::m_normStdDevs
private
Initial value:
=
nullptr

Definition at line 88 of file TFCSPredictExtrapWeights.h.

◆ m_pdgid

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

Definition at line 63 of file TFCSParametrization.h.

◆ m_relevantLayers

std::vector<int>* TFCSPredictExtrapWeights::m_relevantLayers = nullptr
private

Definition at line 81 of file TFCSPredictExtrapWeights.h.


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