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

47 {
48 if (m_input != nullptr) {
49 delete m_input;
50 }
51 if (m_relevantLayers != nullptr) {
52 delete m_relevantLayers;
53 }
54 if (m_normLayers != nullptr) {
55 delete m_normLayers;
56 }
57 if (m_normMeans != nullptr) {
58 delete m_normMeans;
59 }
60 if (m_normStdDevs != nullptr) {
61 delete m_normStdDevs;
62 }
63 if (m_nn != nullptr) {
64 delete m_nn;
65 }
66}
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 90 of file TFCSPredictExtrapWeights.cxx.

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

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

69 {
70 if (IsA() != ref.IsA()) {
71 ATH_MSG_DEBUG("operator==: different class types "
72 << IsA()->GetName() << " != " << ref.IsA()->GetName());
73 return false;
74 }
75 const TFCSPredictExtrapWeights &ref_typed =
76 static_cast<const TFCSPredictExtrapWeights &>(ref);
77
79 return true;
81 return false;
83 return false;
84
85 return (m_input->compare(*ref_typed.m_input) == 0);
86}
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 150 of file TFCSPredictExtrapWeights.cxx.

151 {
152 std::map<std::string, double> inputVariables;
153 for (int ilayer = 0; ilayer < CaloCell_ID_FCS::MaxSample; ++ilayer) {
154 if (std::find(m_relevantLayers->cbegin(), m_relevantLayers->cend(),
155 ilayer) != m_relevantLayers->cend()) {
156 const std::string layer = std::to_string(ilayer);
157 // Find index
158 auto itr =
159 std::find(m_normLayers->cbegin(), m_normLayers->cend(), ilayer);
160 if (itr != m_normLayers->cend()) {
161 const int index = std::distance(m_normLayers->cbegin(), itr);
162 inputVariables["ef_" + layer] =
163 (simulstate.Efrac(ilayer) - std::as_const(m_normMeans)->at(index)) /
164 std::as_const(m_normStdDevs)->at(index);
165 } else {
166 ATH_MSG_ERROR("Normalization information not found for layer "
167 << ilayer);
168 }
169 }
170 }
171 // Find index for truth energy
172 auto itr = std::find(m_normLayers->cbegin(), m_normLayers->cend(), -1);
173 int index = std::distance(m_normLayers->cbegin(), itr);
174 inputVariables["etrue"] = (truthE - std::as_const(m_normMeans)->at(index)) /
175 std::as_const(m_normStdDevs)->at(index);
176 if (is_match_pdgid(22)) {
177 inputVariables["pdgId"] = 1; // one hot enconding
178 } else if (is_match_pdgid(11) || is_match_pdgid(-11)) {
179 inputVariables["pdgId"] = 0; // one hot enconding
180 }
181 return inputVariables;
182}
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 503 of file TFCSPredictExtrapWeights.cxx.

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

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

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

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

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