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

44 {
45 if (m_input != nullptr) {
46 delete m_input;
47 }
48 if (m_relevantLayers != nullptr) {
49 delete m_relevantLayers;
50 }
51 if (m_normLayers != nullptr) {
52 delete m_normLayers;
53 }
54 if (m_normMeans != nullptr) {
55 delete m_normMeans;
56 }
57 if (m_normStdDevs != nullptr) {
58 delete m_normStdDevs;
59 }
60 if (m_nn != nullptr) {
61 delete m_nn;
62 }
63}
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 std::regex ref(r_ef)
#define ATH_MSG_DEBUG(x)
TFCSLateralShapeParametrization(const char *name=nullptr, const char *title=nullptr)
#define IsA
Declare the TObject style functions.

◆ 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)
ClassName()
Default constructor.

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

88 {
89 ATH_MSG_DEBUG(" Getting normalization inputs... ");
90
91 // Open corresponding TXT file and extract mean/std dev for each variable
92 if (m_normLayers != nullptr) {
93 m_normLayers->clear();
94 } else {
95 m_normLayers = new std::vector<int>();
96 }
97 if (m_normMeans != nullptr) {
98 m_normMeans->clear();
99 } else {
100 m_normMeans = new std::vector<float>();
101 }
102 if (m_normStdDevs != nullptr) {
103 m_normStdDevs->clear();
104 } else {
105 m_normStdDevs = new std::vector<float>();
106 }
107 std::string inputFileName = FastCaloTXTInputFolderName +
108 "MeanStdDevEnergyFractions_eta_" + etaBin +
109 ".txt";
110 ATH_MSG_DEBUG(" Opening " << inputFileName);
111 std::ifstream inputTXT(inputFileName);
112 if (inputTXT.is_open()) {
113 std::string line;
114 while (getline(inputTXT, line)) {
115 std::stringstream ss(line);
116 unsigned int counter = 0;
117 while (ss.good()) {
118 std::string substr;
119 getline(ss, substr, ' ');
120 if (counter == 0) { // Get index (#layer or -1 if var == etrue)
121 if (substr != "etrue") {
122 int index = std::stoi(substr.substr(substr.find('_') + 1));
123 m_normLayers->push_back(index);
124 } else { // etrue
125 m_normLayers->push_back(-1);
126 }
127 } else if (counter == 1) {
128 m_normMeans->push_back(std::stof(substr));
129 } else if (counter == 2) {
130 m_normStdDevs->push_back(std::stof(substr));
131 }
132 counter++;
133 }
134 }
135 inputTXT.close();
136 } else {
137 ATH_MSG_ERROR(" Unable to open file " << inputFileName);
138 return false;
139 }
140
141 return true;
142}
#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 287 of file TFCSPredictExtrapWeights.cxx.

289 {
290
292 "Using FastCaloNNInputFolderName: " << FastCaloNNInputFolderName);
293 set_pdgid(pid);
294
295 std::string inputFileName =
296 FastCaloNNInputFolderName + "NN_" + etaBin + ".json";
297 ATH_MSG_DEBUG("Will read JSON file: " << inputFileName);
298 if (inputFileName.empty()) {
299 ATH_MSG_ERROR("Could not find json file " << inputFileName);
300 return false;
301 } else {
302 ATH_MSG_INFO("For pid: " << pid << " and etaBin" << etaBin
303 << ", loading json file " << inputFileName);
304 std::ifstream input(inputFileName);
305 std::stringstream sin;
306 sin << input.rdbuf();
307 input.close();
308 auto config = lwt::parse_json(sin);
309 m_nn = new lwt::LightweightNeuralNetwork(config.inputs, config.layers,
310 config.outputs);
311 if (m_nn == nullptr) {
312 ATH_MSG_ERROR("Could not create LightWeightNeuralNetwork from "
313 << inputFileName);
314 return false;
315 }
316 if (m_input != nullptr) {
317 delete m_input;
318 }
319 m_input = new std::string(sin.str());
320 // Extract relevant layers from the outputs
321 m_relevantLayers = new std::vector<int>();
322 for (auto name : config.outputs) {
323 int layer = std::stoi(
324 name.erase(0, 13)); // remove "extrapWeight_" and convert to int
325 m_relevantLayers->push_back(layer);
326 }
327 }
328 return true;
329}
#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 65 of file TFCSPredictExtrapWeights.cxx.

66 {
67 if (IsA() != ref.IsA()) {
68 ATH_MSG_DEBUG("operator==: different class types "
69 << IsA()->GetName() << " != " << ref.IsA()->GetName());
70 return false;
71 }
72 const TFCSPredictExtrapWeights &ref_typed =
73 static_cast<const TFCSPredictExtrapWeights &>(ref);
74
76 return true;
78 return false;
80 return false;
81
82 return (m_input->compare(*ref_typed.m_input) == 0);
83}
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 147 of file TFCSPredictExtrapWeights.cxx.

148 {
149 std::map<std::string, double> inputVariables;
150 for (int ilayer = 0; ilayer < CaloCell_ID_FCS::MaxSample; ++ilayer) {
151 if (std::find(m_relevantLayers->cbegin(), m_relevantLayers->cend(),
152 ilayer) != m_relevantLayers->cend()) {
153 const std::string layer = std::to_string(ilayer);
154 // Find index
155 auto itr =
156 std::find(m_normLayers->cbegin(), m_normLayers->cend(), ilayer);
157 if (itr != m_normLayers->cend()) {
158 const int index = std::distance(m_normLayers->cbegin(), itr);
159 inputVariables["ef_" + layer] =
160 (simulstate.Efrac(ilayer) - std::as_const(m_normMeans)->at(index)) /
161 std::as_const(m_normStdDevs)->at(index);
162 } else {
163 ATH_MSG_ERROR("Normalization information not found for layer "
164 << ilayer);
165 }
166 }
167 }
168 // Find index for truth energy
169 auto itr = std::find(m_normLayers->cbegin(), m_normLayers->cend(), -1);
170 int index = std::distance(m_normLayers->cbegin(), itr);
171 inputVariables["etrue"] = (truthE - std::as_const(m_normMeans)->at(index)) /
172 std::as_const(m_normStdDevs)->at(index);
173 if (is_match_pdgid(22)) {
174 inputVariables["pdgId"] = 1; // one hot enconding
175 } else if (is_match_pdgid(11) || is_match_pdgid(-11)) {
176 inputVariables["pdgId"] = 0; // one hot enconding
177 }
178 return inputVariables;
179}
virtual bool is_match_pdgid(int id) const override
double Efrac(int sample) const
mapped_type at(key_type key) const
Look up an element in the map.

◆ Print()

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

Definition at line 500 of file TFCSPredictExtrapWeights.cxx.

500 {
501 TString opt(option);
502 bool shortprint = opt.Index("short") >= 0;
503 bool longprint = msgLvl(MSG::DEBUG) || (msgLvl(MSG::INFO) && !shortprint);
504 TString optprint = opt;
505 optprint.ReplaceAll("short", "");
507
508 if (longprint)
509 ATH_MSG_INFO(optprint << " m_input (TFCSPredictExtrapWeights): "
511 if (longprint)
512 ATH_MSG_INFO(optprint << " Address of m_nn: " << (void *)m_nn);
513}
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 183 of file TFCSPredictExtrapWeights.cxx.

185 {
186
187 // Get inputs to Neural Network
188 std::map<std::string, double> inputVariables =
189 prepareInputs(simulstate, truth->E() * 0.001);
190
191 // Get predicted extrapolation weights
192 auto outputs = m_nn->compute(inputVariables);
193 for (int ilayer = 0; ilayer < CaloCell_ID_FCS::MaxSample; ++ilayer) {
194 if (std::find(m_relevantLayers->cbegin(), m_relevantLayers->cend(),
195 ilayer) != m_relevantLayers->cend()) {
196 ATH_MSG_DEBUG("TFCSPredictExtrapWeights::simulate: layer: "
197 << ilayer << " weight: "
198 << outputs["extrapWeight_" + std::to_string(ilayer)]);
199 float weight = outputs["extrapWeight_" + std::to_string(ilayer)];
200 // Protections
201 if (weight < 0) {
202 weight = 0;
203 } else if (weight > 1) {
204 weight = 1;
205 }
206 simulstate.setAuxInfo<float>(ilayer, weight);
207 } else { // use weight=0.5 for non-relevant layers
209 "Setting weight=0.5 for layer = " << std::to_string(ilayer));
210 simulstate.setAuxInfo<float>(ilayer, float(0.5));
211 }
212 }
213 return FCSSuccess;
214}
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 217 of file TFCSPredictExtrapWeights.cxx.

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

382 {
383 ISF_FCS::MLogging logger;
384 ATH_MSG_NOCLASS(logger, "Testing net path ..."
385 << net_path.substr(net_path.length() - 20)
386 << " and norm path ..."
387 << norm_path.substr(norm_path.length() - 20));
388 if (!simulstate) {
389 simulstate = new TFCSSimulationState();
390#if defined(__FastCaloSimStandAlone__)
391 simulstate->setRandomEngine(new CLHEP::TRandomEngine());
392#else
393 simulstate->setRandomEngine(new CLHEP::RanluxEngine());
394#endif
395 }
396 if (!truth) {
397 TFCSTruthState *t = new TFCSTruthState();
398 t->SetPtEtaPhiM(524288000, 0, 0, 130); // 524288 GeV
399 t->set_pdgid(22); // photon
400 truth = t;
401 }
402 if (!extrapol) {
403 TFCSExtrapolationState *e = new TFCSExtrapolationState();
404 e->set_IDCaloBoundary_eta(truth->Eta());
405 for (int i = 0; i < 24; ++i) {
406 e->set_eta(i, TFCSExtrapolationState::SUBPOS_ENT, truth->Eta());
407 e->set_eta(i, TFCSExtrapolationState::SUBPOS_EXT, truth->Eta());
408 e->set_eta(i, TFCSExtrapolationState::SUBPOS_MID, truth->Eta());
412 e->set_r(i, TFCSExtrapolationState::SUBPOS_ENT, 1500 + i * 10);
413 e->set_r(i, TFCSExtrapolationState::SUBPOS_EXT, 1510 + i * 10);
414 e->set_r(i, TFCSExtrapolationState::SUBPOS_MID, 1505 + i * 10);
415 e->set_z(i, TFCSExtrapolationState::SUBPOS_ENT, 3500 + i * 10);
416 e->set_z(i, TFCSExtrapolationState::SUBPOS_EXT, 3510 + i * 10);
417 e->set_z(i, TFCSExtrapolationState::SUBPOS_MID, 3505 + i * 10);
418 }
419 extrapol = e;
420 }
421
422 // Set energy in layers which then will be retrieved in simulate_hit()
423 simulstate->set_E(0, 1028.77124023);
424 simulstate->set_E(1, 68199.0625);
425 simulstate->set_E(2, 438270.78125);
426 simulstate->set_E(3, 3024.02929688);
427 simulstate->set_E(12, 1330.10131836);
428 simulstate->set_E(1028.77124023 + 68199.0625 + 438270.78125 + 3024.02929688 +
429 1330.10131836);
430 simulstate->set_Efrac(0, simulstate->E(0) / simulstate->E());
431 simulstate->set_Efrac(1, simulstate->E(1) / simulstate->E());
432 simulstate->set_Efrac(2, simulstate->E(2) / simulstate->E());
433 simulstate->set_Efrac(3, simulstate->E(3) / simulstate->E());
434 simulstate->set_Efrac(12, simulstate->E(12) / simulstate->E());
435
436 const int pdgId = truth->pdgid();
437 const float Ekin = truth->Ekin();
438 const float eta = truth->Eta();
439
440 ATH_MSG_NOCLASS(logger, "True energy " << Ekin << " pdgId " << pdgId
441 << " eta " << eta);
442
443 // Find eta bin
444 const int Eta = eta * 10;
445 std::string etaBin = "";
446 for (int i = 0; i <= 25; ++i) {
447 int etaTmp = i * 5;
448 if (Eta >= etaTmp && Eta < (etaTmp + 5)) {
449 etaBin = std::to_string(i * 5) + "_" + std::to_string((i + 1) * 5);
450 }
451 }
452
453 ATH_MSG_NOCLASS(logger, "etaBin = " << etaBin);
454
455 TFCSPredictExtrapWeights NN("NN", "NN");
456 NN.setLevel(MSG::INFO);
457 const int pid = truth->pdgid();
458 NN.initializeNetwork(pid, etaBin, net_path);
459 NN.getNormInputs(etaBin, norm_path);
460
461 // Get extrapWeights and save them as AuxInfo in simulstate
462
463 // Get inputs to Neural Network
464 std::map<std::string, double> inputVariables =
465 NN.prepareInputs(*simulstate, truth->E() * 0.001);
466
467 // Get predicted extrapolation weights
468 ATH_MSG_NOCLASS(logger, "computing with m_nn");
469 auto outputs = NN.m_nn->compute(inputVariables);
470 const std::vector<int> layers = {0, 1, 2, 3, 12};
471 for (int ilayer : layers) {
472 simulstate->setAuxInfo<float>(
473 ilayer, outputs["extrapWeight_" + std::to_string(ilayer)]);
474 }
475
476 // Simulate
477 const int layer = 0;
478 NN.set_calosample(layer);
479 TFCSLateralShapeParametrizationHitBase::Hit hit;
480 NN.simulate_hit(hit, *simulstate, truth, extrapol);
481
482 // Write
483 TFile *fNN = new TFile("FCSNNtest.root", "RECREATE");
484 NN.Write();
485 fNN->ls();
486 fNN->Close();
487 delete fNN;
488
489 // Open
490 fNN = TFile::Open("FCSNNtest.root");
491 TFCSPredictExtrapWeights *NN2 = (TFCSPredictExtrapWeights *)(fNN->Get("NN"));
492
493 NN2->setLevel(MSG::INFO);
494 NN2->simulate_hit(hit, *simulstate, truth, extrapol);
495 //simulstate->Print();
496
497 return;
498}
#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 363 of file TFCSPredictExtrapWeights.cxx.

365 {
366 const std::string this_file = __FILE__;
367 const std::string parent_dir = this_file.substr(0, this_file.find("/src/"));
368 const std::string norm_path = parent_dir + "/share/NormPredExtrapSample/";
369 std::string net_path = "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/"
370 "FastCaloSim/LWTNNPredExtrapSample/";
371 test_path(net_path, norm_path, simulstate, truth, extrapol);
372 //net_path = "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/FastCaloSim/"
373 // "ONNXPredExtrapSample/";
374 //test_path(net_path, norm_path, simulstate, truth, extrapol);
375}
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: