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

#include <TFCSEnergyAndHitGANV2.h>

Inheritance diagram for TFCSEnergyAndHitGANV2:
Collaboration diagram for TFCSEnergyAndHitGANV2:

Public Types

enum  FCSGANfreemem { kGANfreemem = BIT(17) }
 Status bit for chain persistency. More...
enum  FCSEnergyInitializationStatusBits { kOnlyScaleEnergy = }
 Status bit for energy initialization. More...
enum  FCSSplitChainObjects { kSplitChainObjects , kRetryChainFromStart = BIT(17) }
 Status bit for chain persistency. More...
typedef std::vector< TFCSParametrizationBase * > Chain_t
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

 TFCSEnergyAndHitGANV2 (const char *name=nullptr, const char *title=nullptr)
virtual ~TFCSEnergyAndHitGANV2 ()
virtual bool is_match_Ekin_bin (int) const override
virtual 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
bool GANfreemem () const
void set_GANfreemem ()
void reset_GANfreemem ()
bool OnlyScaleEnergy () const
void set_OnlyScaleEnergy ()
void reset_OnlyScaleEnergy ()
virtual int get_bin (TFCSSimulationState &simulstate, const TFCSTruthState *, const TFCSExtrapolationState *) const override
 use the layer to be done as binning of the GAN chain
virtual const std::string get_variable_text (TFCSSimulationState &simulstate, const TFCSTruthState *, const TFCSExtrapolationState *) const override
unsigned int get_nr_of_init (unsigned int bin) const
void set_nr_of_init (unsigned int bin, unsigned int ninit)
const TFCSGANXMLParameters::Binningget_Binning () const
const TFCSGANEtaSlice::ExtrapolatorWeights get_ExtrapolationWeights () const
bool initializeNetwork (int const &pid, int const &etaMin, const std::string &FastCaloGANInputFolderName)
bool fillEnergy (TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
virtual FCSReturnCode simulate (TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
 Method in all derived classes to do some simulation.
virtual void Print (Option_t *option="") const override
virtual void push_before_first_bin (TFCSParametrizationBase *param)
virtual void push_back_in_bin (TFCSParametrizationBase *param, unsigned int bin)
virtual unsigned int get_number_of_bins () const
virtual const std::string get_bin_text (int bin) const
 print the range of a bin; for bin -1, print the allowed range
bool SplitChainObjects () const
void set_SplitChainObjects ()
void reset_SplitChainObjects ()
bool RetryChainFromStart () const
void set_RetryChainFromStart ()
void reset_RetryChainFromStart ()
virtual unsigned int size () const override
 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 ind) const override
 Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operator[] methods give general access to these daughters.
virtual TFCSParametrizationBaseoperator[] (unsigned int ind) override
 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 ind, TFCSParametrizationBase *param) override
 Some derived classes have daughter instances of TFCSParametrizationBase objects The set_daughter method allows to change these daughters - expert use only!
const Chain_tchain () const
Chain_tchain ()
void push_back (const Chain_t::value_type &param)
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 bool operator== (const TFCSParametrizationBase &ref) const
 The == operator compares the content of instances.
virtual void CleanAuxInfo (TFCSSimulationState &) const
 Method in all derived classes to delete objects stored in the simulstate AuxInfo.
void FindDuplicates (FindDuplicateClasses_t &dup)
void RemoveDuplicates ()
void RemoveNameTitle ()
bool msgLvl (const MSG::Level lvl) const
 Check whether the logging system is active at the provided verbosity level.
MsgStream & msg () const
 Return a stream for sending messages directly (no decoration).
MsgStream & msg (const MSG::Level lvl) const
 Return a decorated starting stream for sending messages.
MSG::Level level () const
 Retrieve output level.
virtual void setLevel (MSG::Level lvl)
 Update outputlevel.

Static Public Member Functions

static void test_path (const std::string &path, TFCSSimulationState *simulstate=nullptr, const TFCSTruthState *truth=nullptr, const TFCSExtrapolationState *extrapol=nullptr, const std::string &outputname="unnamed", int pid=211)
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

void SetRegionAndSliceFromXML (int pid, int etaMax, std::string FastCaloGANInputFolderName)
void recalc_pdgid_intersect ()
void recalc_pdgid_union ()
void recalc_Ekin_intersect ()
void recalc_eta_intersect ()
void recalc_Ekin_eta_intersect ()
void recalc_Ekin_union ()
void recalc_eta_union ()
void recalc_Ekin_eta_union ()
virtual void recalc ()
 Default is to call recalc_pdgid_intersect() and recalc_Ekin_eta_intersect().
FCSReturnCode simulate_and_retry (TFCSParametrizationBase *parametrization, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
bool compare (const TFCSParametrizationBase &ref) const

Protected Attributes

std::vector< unsigned int > m_bin_start
 Contains the index where the TFCSParametrizationBase* instances to run for a given bin start.

Static Protected Attributes

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

Private Member Functions

int GetAlphaBinsForRBin (const TAxis *x, int ix, int yBinNum) const

Static Private Member Functions

static int GetBinsInFours (double const bins)

Private Attributes

std::vector< int > m_bin_ninit
TFCSGANEtaSlicem_slice = nullptr
TFCSGANXMLParameters m_param
std::mutex m_mutex
Chain_t m_chain
std::vector< std::unique_ptr< TFCSParametrizationBase > > m_writtenBases
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 21 of file TFCSEnergyAndHitGANV2.h.

Member Typedef Documentation

◆ Chain_t

Definition at line 40 of file TFCSParametrizationChain.h.

◆ FindDuplicateClasses_t

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

Definition at line 142 of file TFCSParametrizationBase.h.

◆ FindDuplicates_t

Member Enumeration Documentation

◆ FCSEnergyInitializationStatusBits

Status bit for energy initialization.

Enumerator
kOnlyScaleEnergy 

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

should only be scaled by the GAN

Definition at line 45 of file TFCSEnergyAndHitGANV2.h.

45 {
47 BIT(18)
49 };
@ kOnlyScaleEnergy
Set this bit in the TObject bit field the simulated energy.

◆ FCSGANfreemem

Status bit for chain persistency.

Enumerator
kGANfreemem 

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

Definition at line 35 of file TFCSEnergyAndHitGANV2.h.

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

◆ FCSSplitChainObjects

Status bit for chain persistency.

Enumerator
kSplitChainObjects 

Set this bit in the TObject bit field if the TFCSParametrizationBase objects in the chain should be written as separate keys into the root file instead of directly writing the objects.

This is needed if the sum of all objects in the chain use >1GB of memory, which can't be handeled by TBuffer. Drawback is that identical objects will get stored as multiple instances

kRetryChainFromStart 

Definition at line 20 of file TFCSParametrizationChain.h.

20 {
22 BIT(16),
29 kRetryChainFromStart = BIT(17)
30 };
@ kSplitChainObjects
Set this bit in the TObject bit field if the TFCSParametrizationBase objects in the chain should be w...

◆ FCSStatusBits

Status bit for FCS needs.

Enumerator
kMatchAllPDGID 

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

Definition at line 52 of file TFCSParametrizationBase.h.

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

Constructor & Destructor Documentation

◆ TFCSEnergyAndHitGANV2()

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

Definition at line 36 of file TFCSEnergyAndHitGANV2.cxx.

38 : TFCSParametrizationBinnedChain(name, title) {
40}
TFCSParametrizationBinnedChain(const char *name=nullptr, const char *title=nullptr)

◆ ~TFCSEnergyAndHitGANV2()

TFCSEnergyAndHitGANV2::~TFCSEnergyAndHitGANV2 ( )
virtual

Definition at line 42 of file TFCSEnergyAndHitGANV2.cxx.

42 {
43 if (m_slice != nullptr) {
44 delete m_slice;
45 }
46}

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

◆ chain() [1/2]

Chain_t & TFCSParametrizationChain::chain ( )
inlineinherited

Definition at line 54 of file TFCSParametrizationChain.h.

◆ chain() [2/2]

const Chain_t & TFCSParametrizationChain::chain ( ) const
inlineinherited

Definition at line 53 of file TFCSParametrizationChain.h.

53{ return m_chain; };

◆ 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 TFCSParametrization::compare ( const TFCSParametrizationBase & ref) const
protectedinherited

Definition at line 78 of file TFCSParametrization.cxx.

78 {
79 if (IsA() != ref.IsA()) {
80 ATH_MSG_DEBUG("compare(): different class types "
81 << IsA()->GetName() << " != " << ref.IsA()->GetName());
82 return false;
83 }
84 std::string name(GetName());
85 if (name != ref.GetName()) {
86 ATH_MSG_DEBUG("compare(): different names " << GetName()
87 << " != " << ref.GetName());
88 return false;
89 }
90 std::string title(GetTitle());
91 if (title != ref.GetTitle()) {
92 ATH_MSG_DEBUG("compare(): different titles " << GetTitle()
93 << " != " << ref.GetTitle());
94 return false;
95 }
96 if (is_match_all_pdgid() != ref.is_match_all_pdgid() ||
97 pdgid() != ref.pdgid()) {
98 ATH_MSG_DEBUG("compare(): different pdgids");
99 return false;
100 }
101 if (Ekin_nominal() != ref.Ekin_nominal() || Ekin_min() != ref.Ekin_min() ||
102 Ekin_max() != ref.Ekin_max()) {
103 ATH_MSG_DEBUG("compare(): different Ekin range");
104 return false;
105 }
106 if (eta_nominal() != ref.eta_nominal() || eta_min() != ref.eta_min() ||
107 eta_max() != ref.eta_max()) {
108 ATH_MSG_DEBUG("compare(): different eta range");
109 return false;
110 }
111
112 return true;
113}
const std::regex ref(r_ef)
#define ATH_MSG_DEBUG(x)
virtual bool is_match_all_pdgid() const
double Ekin_nominal() const override
double eta_nominal() const override
double Ekin_min() const override
double eta_max() const override
double Ekin_max() const override
const std::set< int > & pdgid() const override
double eta_min() const override
#define IsA
Declare the TObject style functions.

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

◆ fillEnergy()

bool TFCSEnergyAndHitGANV2::fillEnergy ( TFCSSimulationState & simulstate,
const TFCSTruthState * truth,
const TFCSExtrapolationState * extrapol ) const

Definition at line 114 of file TFCSEnergyAndHitGANV2.cxx.

116 {
117 if (!truth) {
118 ATH_MSG_ERROR("Invalid truth pointer");
119 return false;
120 }
121
122 if (!extrapol) {
123 ATH_MSG_ERROR("Invalid extrapolation pointer");
124 return false;
125 }
126
127 const int pdgId = truth->pdgid();
128 const float charge = MC::charge(pdgId);
129
130 float Einit;
131 const float Ekin = truth->Ekin();
132 if (OnlyScaleEnergy())
133 Einit = simulstate.E();
134 else
135 Einit = Ekin;
136
137 ATH_MSG_VERBOSE("Momentum " << truth->P() << " pdgId " << truth->pdgid());
138 // check that the network exists
139 if (!m_slice->IsGanCorrectlyLoaded()) {
140 ATH_MSG_WARNING("GAN not loaded correctly.");
141 return false;
142 }
143 // This lock is an attempt to fix ATLASSIM-7031. remove if not necessary
144 // Hold until NetworkOutputs goes out of scope
145 std::scoped_lock lock(m_mutex);
147 m_slice->GetNetworkOutputs(truth, extrapol, simulstate);
148 ATH_MSG_VERBOSE("network outputs size: " << outputs.size());
149
150 const TFCSGANXMLParameters::Binning &binsInLayers = m_param.GetBinning();
151 const auto ganVersion = m_param.GetGANVersion();
152 const TFCSGANEtaSlice::FitResultsPerLayer &fitResults =
153 m_slice->GetFitResults(); // used only if GAN version > 1
154
155 ATH_MSG_DEBUG("energy voxels size = " << outputs.size());
156
157 double totalEnergy = 0;
158 for (const auto & output : outputs) {
159 totalEnergy += output.second;
160 }
161 if (totalEnergy < 0) {
162 ATH_MSG_WARNING("Energy from GAN is negative, skipping particle");
163 return false;
164 }
165
166 ATH_MSG_VERBOSE("Get binning");
167
168 simulstate.set_E(0);
169
170 int vox = 0;
171 for (const auto &[layer, h] : binsInLayers) {
172 // attempt to debug intermittent ci issues described in
173 // https://its.cern.ch/jira/browse/ATLASSIM-7031
174 if (*reinterpret_cast<void*const*>(&h) == nullptr || h.IsZombie() || h.IsOnHeap() || dynamic_cast<const TH2D*>(&h) == nullptr) {
175 ATH_MSG_ERROR("Histogram for layer " << layer << " at " << &h <<
176 " is broken; " <<
177 "See ATLASSIM-7031.");
178
179 std::ostringstream ss;
180 ss << "Node dump:\n";
181 CxxUtils::safeHexdump (ss, (reinterpret_cast<const char*>(&h)) - 8*sizeof(void*), 4096);
182 ss << "Map head:\n";
183 CxxUtils::safeHexdump (ss, &binsInLayers, sizeof(binsInLayers));
184 ATH_MSG_INFO(ss.str());
185 ss.str("");
186 ss << "First node:\n";
187 auto it = binsInLayers.begin();
188 CxxUtils::safeHexdump (ss, (reinterpret_cast<const char*>(&*it)) - 8*sizeof(void*), 4096);
189 ATH_MSG_INFO(ss.str());
190 ATH_MSG_INFO("zombie: " << h.IsZombie() <<
191 " on heap: " << h.IsOnHeap());
192 ATH_MSG_INFO(" dynamic type: " << typeid(h).name());
193
194 ATH_MSG_INFO("Got truth state: ");
195 truth->Print();
196
197 ATH_MSG_INFO("Got extrapolation state: ");
198 extrapol->Print();
199
200 ATH_MSG_INFO("Got simulation state: ");
201 simulstate.Print();
202
203 ATH_MSG_INFO("Got GAN XML parameters: ");
204 m_param.Print();
205
206 return false;
207 }
208
209 const int xBinNum = h.GetNbinsX();
210 const int yBinNum = h.GetNbinsY();
211 const TAxis *x = h.GetXaxis();
212
213 // If only one bin in r means layer is empty, no value should be added
214 if (xBinNum == 1) {
215 ATH_MSG_VERBOSE(" Layer "
216 << layer
217 << " has only one bin in r, this means is it not used, "
218 "skipping (this is needed to keep correct "
219 "syncronisation of voxel and layers)");
220 // delete h;
221 continue;
222 }
223
224 ATH_MSG_VERBOSE(" Getting energy for Layer " << layer);
225
226 // First fill energies
227 for (int ix = 1; ix <= xBinNum; ++ix) {
228 double binsInAlphaInRBin = GetAlphaBinsForRBin(x, ix, yBinNum);
229 for (int iy = 1; iy <= binsInAlphaInRBin; ++iy) {
230 const double energyInVoxel = outputs.at(std::to_string(vox));
231 ATH_MSG_VERBOSE(" Vox " << vox << " energy " << energyInVoxel
232 << " binx " << ix << " biny " << iy);
233
234 if (energyInVoxel <= 0) {
235 vox++;
236 continue;
237 }
238
239 simulstate.add_E(layer, Einit * energyInVoxel);
240 vox++;
241 }
242 }
243 }
244
245 for (unsigned int ichain = m_bin_start.back(); ichain < size(); ++ichain) {
246 ATH_MSG_DEBUG("now run for all bins: " << chain()[ichain]->GetName());
247 if (simulate_and_retry(chain()[ichain], simulstate, truth, extrapol) !=
248 FCSSuccess) {
249 return FCSFatal;
250 }
251 }
252
253 vox = 0;
254 for (const auto &[layer, h] : binsInLayers) {
255 const int xBinNum = h.GetNbinsX();
256 const int yBinNum = h.GetNbinsY();
257 const TAxis *x = h.GetXaxis();
258 const TAxis *y = h.GetYaxis();
259
260 simulstate.setAuxInfo<int>("GANlayer"_FCShash, layer);
261 TFCSLateralShapeParametrizationHitBase::Hit hit;
262
263 // If only one bin in r means layer is empty, no value should be added
264 if (xBinNum == 1) {
265 ATH_MSG_VERBOSE(" Layer "
266 << layer
267 << " has only one bin in r, this means is it not used, "
268 "skipping (this is needed to keep correct "
269 "syncronisation of voxel and layers)");
270 // delete h;
271 continue;
272 }
273
274 if (get_number_of_bins() > 0) {
275 const int bin = get_bin(simulstate, truth, extrapol);
276 if (bin >= 0 && bin < (int)get_number_of_bins()) {
277 for (unsigned int ichain = m_bin_start[bin];
278 ichain < TMath::Min(m_bin_start[bin] + get_nr_of_init(bin),
279 m_bin_start[bin + 1]);
280 ++ichain) {
281 ATH_MSG_DEBUG("for " << get_variable_text(simulstate, truth, extrapol)
282 << " run init " << get_bin_text(bin) << ": "
283 << chain()[ichain]->GetName());
284 if (chain()[ichain]->InheritsFrom(
285 TFCSLateralShapeParametrizationHitBase::Class())) {
286 TFCSLateralShapeParametrizationHitBase *sim =
287 static_cast<TFCSLateralShapeParametrizationHitBase *>(chain()[ichain]);
288 if (sim->simulate_hit(hit, simulstate, truth, extrapol) !=
289 FCSSuccess) {
290 ATH_MSG_ERROR("error for "
291 << get_variable_text(simulstate, truth, extrapol)
292 << " run init " << get_bin_text(bin) << ": "
293 << chain()[ichain]->GetName());
294 return false;
295 }
296 } else {
297 ATH_MSG_ERROR("for "
298 << get_variable_text(simulstate, truth, extrapol)
299 << " run init " << get_bin_text(bin) << ": "
300 << chain()[ichain]->GetName()
301 << " does not inherit from "
302 "TFCSLateralShapeParametrizationHitBase");
303 return false;
304 }
305 }
306 } else {
307 ATH_MSG_WARNING("nothing to init for "
308 << get_variable_text(simulstate, truth, extrapol)
309 << ": " << get_bin_text(bin));
310 }
311 }
312
313 int binResolution = 5;
314 if (layer == 1 || layer == 5) {
315 binResolution = 1;
316 }
317
318 const double center_eta = hit.center_eta();
319 const double center_phi = hit.center_phi();
320 const double center_r = hit.center_r();
321 const double center_z = hit.center_z();
322
323 ATH_MSG_VERBOSE(" Layer " << layer << " Extrap eta " << center_eta
324 << " phi " << center_phi << " R " << center_r);
325
326 const float dist000 =
327 TMath::Sqrt(center_r * center_r + center_z * center_z);
328 const float eta_jakobi = TMath::Abs(2.0 * TMath::Exp(-center_eta) /
329 (1.0 + TMath::Exp(-2 * center_eta)));
330
331 int nHitsAlpha{};
332 int nHitsR{};
333
334 // Now create hits
335 for (int ix = 1; ix <= xBinNum; ++ix) {
336 const int binsInAlphaInRBin = GetAlphaBinsForRBin(x, ix, yBinNum);
337
338 // Horrible work around for variable # of bins along alpha direction
339 const int binsToMerge = yBinNum == 32 ? 32 / binsInAlphaInRBin : 1;
340 for (int iy = 1; iy <= binsInAlphaInRBin; ++iy) {
341 const double energyInVoxel = outputs.at(std::to_string(vox));
342 const int lowEdgeIndex = (iy - 1) * binsToMerge + 1;
343
344 ATH_MSG_VERBOSE(" Vox " << vox << " energy " << energyInVoxel
345 << " binx " << ix << " biny " << iy);
346
347 if (energyInVoxel <= 0) {
348 vox++;
349 continue;
350 }
351
352 if (std::abs(pdgId) == 22 || std::abs(pdgId) == 11) {
353 // maximum 10 MeV per hit, equaly distributed in alpha and r
354 int maxHitsInVoxel = energyInVoxel * truth->Ekin() / 10;
355 if (maxHitsInVoxel < 1)
356 maxHitsInVoxel = 1;
357 nHitsAlpha = std::sqrt(maxHitsInVoxel);
358 nHitsR = std::sqrt(maxHitsInVoxel);
359 } else {
360 // One hit per mm along r
361 nHitsR = x->GetBinUpEdge(ix) - x->GetBinLowEdge(ix);
362 if (yBinNum == 1) {
363 // nbins in alpha depend on circumference lenght
364 const double r = x->GetBinUpEdge(ix);
365 nHitsAlpha = ceil(2 * TMath::Pi() * r / binResolution);
366 } else {
367 // d = 2*r*sin (a/2r) this distance at the upper r must be 1mm for
368 // layer 1 or 5, 5mm otherwise.
369 const double angle = y->GetBinUpEdge(iy) - y->GetBinLowEdge(iy);
370 const double r = x->GetBinUpEdge(ix);
371 const double d = 2 * r * sin(angle / 2 * r);
372 nHitsAlpha = ceil(d / binResolution);
373 }
374
375 if (layer != 1 && layer != 5) {
376 // For layers that are not EMB1 or EMEC1 use a maximum of 10 hits
377 // per direction, a higher granularity is needed for the other
378 // layers
379 const int maxNhits = 10;
380 nHitsAlpha = std::min(maxNhits, std::max(1, nHitsAlpha));
381 nHitsR = std::min(maxNhits, std::max(1, nHitsR));
382 }
383 }
384
385 for (int ir = 0; ir < nHitsR; ++ir) {
386 double r =
387 x->GetBinLowEdge(ix) + x->GetBinWidth(ix) / (nHitsR + 1) * ir;
388
389 for (int ialpha = 1; ialpha <= nHitsAlpha; ++ialpha) {
390 if (ganVersion > 1) {
391 if (fitResults.at(layer)[ix - 1] != 0) {
392 int tries = 0;
393 double a = CLHEP::RandFlat::shoot(simulstate.randomEngine(),
394 x->GetBinLowEdge(ix),
395 x->GetBinUpEdge(ix));
396 double rand_r =
397 log((a - x->GetBinLowEdge(ix)) / (x->GetBinWidth(ix))) /
398 fitResults.at(layer)[ix - 1];
399 while ((rand_r < x->GetBinLowEdge(ix) ||
400 rand_r > x->GetBinUpEdge(ix)) &&
401 tries < 100) {
402 a = CLHEP::RandFlat::shoot(simulstate.randomEngine(),
403 x->GetBinLowEdge(ix),
404 x->GetBinUpEdge(ix));
405 rand_r =
406 log((a - x->GetBinLowEdge(ix)) / (x->GetBinWidth(ix))) /
407 fitResults.at(layer)[ix - 1];
408 tries++;
409 }
410 if (tries >= 100) {
411 ATH_MSG_VERBOSE(" Too many tries for bin ["
412 << x->GetBinLowEdge(ix) << "-"
413 << x->GetBinUpEdge(ix) << "] having slope "
414 << fitResults.at(layer)[ix - 1]
415 << " will use grid (old method)");
416 } else {
417 r = rand_r;
418 }
419 }
420 }
421
422 double alpha;
423 if (binsInAlphaInRBin == 1) {
424 alpha = CLHEP::RandFlat::shoot(simulstate.randomEngine(),
425 -TMath::Pi(), TMath::Pi());
426 } else {
427 alpha =
428 y->GetBinLowEdge(lowEdgeIndex) +
429 y->GetBinWidth(iy) * binsToMerge / (nHitsAlpha + 1) * ialpha;
430
431 if (m_param.IsSymmetrisedAlpha()) {
432 if (CLHEP::RandFlat::shoot(simulstate.randomEngine(),
433 -TMath::Pi(), TMath::Pi()) < 0) {
434 alpha = -alpha;
435 }
436 }
437 }
438
439 hit.reset();
440 hit.E() = Einit * energyInVoxel / (nHitsAlpha * nHitsR);
441
442 if (layer <= 20) {
443 float delta_eta_mm = r * cos(alpha);
444 float delta_phi_mm = r * sin(alpha);
445
446 ATH_MSG_VERBOSE("delta_eta_mm " << delta_eta_mm
447 << " delta_phi_mm "
448 << delta_phi_mm);
449
450 // Particles with negative eta are expected to have the same shape
451 // as those with positive eta after transformation: delta_eta -->
452 // -delta_eta
453 if (center_eta < 0.)
454 delta_eta_mm = -delta_eta_mm;
455 // We derive the shower shapes for electrons and positively
456 // charged hadrons. Particle with the opposite charge are expected
457 // to have the same shower shape after the transformation:
458 // delta_phi --> -delta_phi
459 if ((charge < 0. && pdgId != 11) || pdgId == -11)
460 delta_phi_mm = -delta_phi_mm;
461
462 const float delta_eta = delta_eta_mm / eta_jakobi / dist000;
463 const float delta_phi = delta_phi_mm / center_r;
464
465 hit.eta() = center_eta + delta_eta;
466 hit.phi() = TVector2::Phi_mpi_pi(center_phi + delta_phi);
467
468 ATH_MSG_VERBOSE(" Hit eta " << hit.eta() << " phi " << hit.phi()
469 << " layer " << layer);
470 } else { // FCAL is in (x,y,z)
471 const float hit_r = r * cos(alpha) + center_r;
472 float delta_phi = r * sin(alpha) / center_r;
473 // We derive the shower shapes for electrons and positively
474 // charged hadrons. Particle with the opposite charge are expected
475 // to have the same shower shape after the transformation:
476 // delta_phi --> -delta_phi
477 if ((charge < 0. && pdgId != 11) || pdgId == -11)
479 const float hit_phi =
480 TVector2::Phi_mpi_pi(center_phi + delta_phi);
481 hit.x() = hit_r * cos(hit_phi);
482 hit.y() = hit_r * sin(hit_phi);
483 hit.z() = center_z;
484 ATH_MSG_VERBOSE(" Hit x " << hit.x() << " y " << hit.y()
485 << " layer " << layer);
486 }
487
488 if (get_number_of_bins() > 0) {
489 const int bin = get_bin(simulstate, truth, extrapol);
490 if (bin >= 0 && bin < (int)get_number_of_bins()) {
491 for (unsigned int ichain =
492 m_bin_start[bin] + get_nr_of_init(bin);
493 ichain < m_bin_start[bin + 1]; ++ichain) {
495 "for " << get_variable_text(simulstate, truth, extrapol)
496 << " run " << get_bin_text(bin) << ": "
497 << chain()[ichain]->GetName());
498 if (chain()[ichain]->InheritsFrom(
499 TFCSLateralShapeParametrizationHitBase::Class())) {
500 TFCSLateralShapeParametrizationHitBase *sim =
501 static_cast<TFCSLateralShapeParametrizationHitBase
502 *>(chain()[ichain]);
503 if (sim->simulate_hit(hit, simulstate, truth, extrapol) !=
504 FCSSuccess) {
506 "error for "
507 << get_variable_text(simulstate, truth, extrapol)
508 << " run init " << get_bin_text(bin) << ": "
509 << chain()[ichain]->GetName());
510 return false;
511 }
512 } else {
514 "for " << get_variable_text(simulstate, truth, extrapol)
515 << " run init " << get_bin_text(bin) << ": "
516 << chain()[ichain]->GetName()
517 << " does not inherit from "
518 "TFCSLateralShapeParametrizationHitBase");
519 return false;
520 }
521 }
522 } else {
524 "nothing to do for "
525 << get_variable_text(simulstate, truth, extrapol) << ": "
526 << get_bin_text(bin));
527 }
528 } else {
529 ATH_MSG_WARNING("no bins defined, is this intended?");
530 }
531 }
532 }
533 vox++;
534 }
535 }
536
537 ATH_MSG_VERBOSE("Number of voxels " << vox);
538 ATH_MSG_VERBOSE("Done layer " << layer);
539 }
540
541 if (simulstate.E() > std::numeric_limits<double>::epsilon()) {
542 for (int ilayer = 0; ilayer < CaloCell_ID_FCS::MaxSample; ++ilayer) {
543 simulstate.set_Efrac(ilayer, simulstate.E(ilayer) / simulstate.E());
544 }
545 }
546
547 ATH_MSG_VERBOSE("Done particle");
548 return true;
549}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double charge(const T &p)
Definition AtlasPID.h:997
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
static Double_t a
static Double_t ss
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
#define y
#define x
unsigned int get_nr_of_init(unsigned int bin) const
virtual int get_bin(TFCSSimulationState &simulstate, const TFCSTruthState *, const TFCSExtrapolationState *) const override
use the layer to be done as binning of the GAN chain
virtual const std::string get_variable_text(TFCSSimulationState &simulstate, const TFCSTruthState *, const TFCSExtrapolationState *) const override
int GetAlphaBinsForRBin(const TAxis *x, int ix, int yBinNum) const
TFCSGANXMLParameters m_param
void Print(Option_t *option="") const
std::map< int, std::vector< double > > FitResultsPerLayer
std::map< std::string, double > NetworkOutputs
std::map< int, TH2D > Binning
virtual FCSReturnCode simulate_hit(Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol)
simulated one hit position with some energy.
virtual unsigned int size() const
Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operat...
virtual unsigned int get_number_of_bins() const
std::vector< unsigned int > m_bin_start
Contains the index where the TFCSParametrizationBase* instances to run for a given bin start.
virtual const std::string get_bin_text(int bin) const
print the range of a bin; for bin -1, print the allowed range
FCSReturnCode simulate_and_retry(TFCSParametrizationBase *parametrization, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
const Chain_t & chain() const
void Print(Option_t *option="") const
void set_E(int sample, double Esample)
void add_E(int sample, double Esample)
void set_Efrac(int sample, double Efracsample)
void setAuxInfo(std::uint32_t index, const T &val)
CLHEP::HepRandomEngine * randomEngine()
void Print(Option_t *option="") const
int pdgid() const
double Ekin() const
int ir
counter of the current depth
Definition fastadd.cxx:49
int r
Definition globals.cxx:22
const
helper method to get the collection index (into m_inputCollectionsName) and tuple index (into m_tuple...
void safeHexdump(std::ostream &s, const void *addr, size_t n, size_t offset=0)
Make a hex dump of memory, protected against bad reads.
Definition hexdump.cxx:103
double charge(const T &p)
@ layer
Definition HitInfo.h:79
delta_phi(phi1, phi2)
Definition eFEXNTuple.py:14
output
Definition merge.py:16

◆ 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}
void FindDuplicates(FindDuplicateClasses_t &dup)
std::map< TFCSParametrizationBase *, Duplicate_t > FindDuplicates_t
TFCSParametrizationBase(const char *name=nullptr, const char *title=nullptr)
ClassName()
Default constructor.

◆ GANfreemem()

bool TFCSEnergyAndHitGANV2::GANfreemem ( ) const
inline

Definition at line 40 of file TFCSEnergyAndHitGANV2.h.

40{ return TestBit(kGANfreemem); };

◆ get_bin()

virtual int TFCSEnergyAndHitGANV2::get_bin ( TFCSSimulationState & simulstate,
const TFCSTruthState * ,
const TFCSExtrapolationState *  ) const
inlineoverridevirtual

use the layer to be done as binning of the GAN chain

Reimplemented from TFCSParametrizationBinnedChain.

Definition at line 56 of file TFCSEnergyAndHitGANV2.h.

57 {
58 return simulstate.getAuxInfo<int>("GANlayer"_FCShash);
59 };
const T getAuxInfo(std::uint32_t index) const

◆ get_bin_text()

const std::string TFCSParametrizationBinnedChain::get_bin_text ( int bin) const
virtualinherited

print the range of a bin; for bin -1, print the allowed range

Reimplemented in TFCSParametrizationAbsEtaSelectChain, TFCSParametrizationEkinSelectChain, and TFCSParametrizationEtaSelectChain.

Definition at line 60 of file TFCSParametrizationBinnedChain.cxx.

60 {
61 return std::string(Form("bin %d", bin));
62}

◆ get_Binning()

const TFCSGANXMLParameters::Binning & TFCSEnergyAndHitGANV2::get_Binning ( ) const
inline

Definition at line 67 of file TFCSEnergyAndHitGANV2.h.

67 {
68 return m_param.GetBinning();
69 };

◆ get_ExtrapolationWeights()

const TFCSGANEtaSlice::ExtrapolatorWeights TFCSEnergyAndHitGANV2::get_ExtrapolationWeights ( ) const
inline

Definition at line 70 of file TFCSEnergyAndHitGANV2.h.

70 {
71 return m_slice->GetExtrapolatorWeights();
72 };

◆ get_nr_of_init()

unsigned int TFCSEnergyAndHitGANV2::get_nr_of_init ( unsigned int bin) const

Definition at line 56 of file TFCSEnergyAndHitGANV2.cxx.

56 {
57 if (bin >= m_bin_ninit.size())
58 return 0;
59 return m_bin_ninit[bin];
60}
std::vector< int > m_bin_ninit

◆ get_number_of_bins()

virtual unsigned int TFCSParametrizationBinnedChain::get_number_of_bins ( ) const
inlinevirtualinherited

Definition at line 22 of file TFCSParametrizationBinnedChain.h.

22 {
23 return m_bin_start.size() - 1;
24 };

◆ get_variable_text()

const std::string TFCSEnergyAndHitGANV2::get_variable_text ( TFCSSimulationState & simulstate,
const TFCSTruthState * ,
const TFCSExtrapolationState *  ) const
overridevirtual

Reimplemented from TFCSParametrizationBinnedChain.

Definition at line 107 of file TFCSEnergyAndHitGANV2.cxx.

109 {
110 return std::string(
111 Form("layer=%d", simulstate.getAuxInfo<int>("GANlayer"_FCShash)));
112}

◆ GetAlphaBinsForRBin()

int TFCSEnergyAndHitGANV2::GetAlphaBinsForRBin ( const TAxis * x,
int ix,
int yBinNum ) const
private

Definition at line 729 of file TFCSEnergyAndHitGANV2.cxx.

730 {
731 double binsInAlphaInRBin = yBinNum;
732 if (yBinNum == 32) {
733 ATH_MSG_DEBUG("yBinNum is special value 32");
734 const double widthX = x->GetBinWidth(ix);
735 const double radious = x->GetBinCenter(ix);
736 double circumference = radious * 2. * TMath::Pi();
737 if (m_param.IsSymmetrisedAlpha()) {
738 circumference = radious * TMath::Pi();
739 }
740
741 const double bins = circumference / widthX;
742 binsInAlphaInRBin = GetBinsInFours(bins);
743 ATH_MSG_DEBUG("Bin in alpha: " << binsInAlphaInRBin << " for r bin: " << ix
744 << " (" << x->GetBinLowEdge(ix) << "-"
745 << x->GetBinUpEdge(ix) << ")");
746 }
747 return binsInAlphaInRBin;
748}
static const std::vector< std::string > bins
static int GetBinsInFours(double const bins)

◆ GetBinsInFours()

int TFCSEnergyAndHitGANV2::GetBinsInFours ( double const bins)
staticprivate

Definition at line 718 of file TFCSEnergyAndHitGANV2.cxx.

718 {
719 if (bins < 4)
720 return 4;
721 else if (bins < 8)
722 return 8;
723 else if (bins < 16)
724 return 16;
725 else
726 return 32;
727}

◆ initializeNetwork()

bool TFCSEnergyAndHitGANV2::initializeNetwork ( int const & pid,
int const & etaMin,
const std::string & FastCaloGANInputFolderName )

Definition at line 72 of file TFCSEnergyAndHitGANV2.cxx.

74 {
75
76 // initialize all necessary constants
77 // FIXME eventually all these could be stored in the .json file
78
80 "Using FastCaloGANInputFolderName: " << FastCaloGANInputFolderName);
81 // get neural net JSON file as an std::istream object
82 const int etaMax = etaMin + 5;
83
85 set_pdgid(pid);
86 if (pid == 11)
87 add_pdgid(-pid);
88 if (pid == 211)
89 add_pdgid(-pid);
90 set_eta_min(etaMin / 100.0);
91 set_eta_max(etaMax / 100.0);
92 set_eta_nominal((etaMin + etaMax) / 200.0);
93
94 int pidForXml = pid;
95 if (pid != 22 && pid != 11) {
96 pidForXml = 211;
97 }
98
99 const int etaMid = (etaMin + etaMax) / 2;
100 m_param.InitialiseFromXML(pidForXml, etaMid, FastCaloGANInputFolderName);
101 m_param.Print();
102 m_slice = new TFCSGANEtaSlice(pid, etaMin, etaMax, m_param);
103 m_slice->Print();
104 return m_slice->LoadGAN();
105}
virtual void set_eta_max(double max)
virtual void add_pdgid(int id)
virtual void set_eta_nominal(double min)
virtual void set_pdgid(int id)
virtual void set_eta_min(double min)

◆ is_match_all_calosample()

virtual bool TFCSEnergyAndHitGANV2::is_match_all_calosample ( ) const
inlineoverridevirtual

Reimplemented from TFCSParametrization.

Definition at line 32 of file TFCSEnergyAndHitGANV2.h.

32{ 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 };

◆ is_match_all_Ekin_bin()

virtual bool TFCSEnergyAndHitGANV2::is_match_all_Ekin_bin ( ) const
inlineoverridevirtual

Reimplemented from TFCSParametrization.

Definition at line 31 of file TFCSEnergyAndHitGANV2.h.

31{ return true; };

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

◆ 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 TFCSEnergyAndHitGANV2::is_match_calosample ( int calosample) const
overridevirtual

Reimplemented from TFCSParametrizationChain.

Definition at line 48 of file TFCSEnergyAndHitGANV2.cxx.

48 {
49 if (get_Binning().find(calosample) == get_Binning().cend())
50 return false;
51 if (get_Binning().at(calosample).GetNbinsX() == 1)
52 return false;
53 return true;
54}
const TFCSGANXMLParameters::Binning & get_Binning() const
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:140
const_iterator cend() const
Iterator at the end of the map.
mapped_type at(key_type key) const
Look up an element in the map.

◆ is_match_Ekin()

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

Reimplemented from TFCSParametrizationBase.

Definition at line 18 of file TFCSParametrization.h.

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

◆ is_match_Ekin_bin()

virtual bool TFCSEnergyAndHitGANV2::is_match_Ekin_bin ( int ) const
inlineoverridevirtual

Reimplemented from TFCSParametrizationChain.

Definition at line 27 of file TFCSEnergyAndHitGANV2.h.

27 {
28 return true;
29 };

◆ 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

◆ OnlyScaleEnergy()

bool TFCSEnergyAndHitGANV2::OnlyScaleEnergy ( ) const
inline

Definition at line 51 of file TFCSEnergyAndHitGANV2.h.

51{ return TestBit(kOnlyScaleEnergy); };

◆ operator==()

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

The == operator compares the content of instances.

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

Reimplemented in TFCSHitCellMapping, TFCSHitCellMappingWiggle, TFCSLateralShapeParametrizationHitNumberFromE, and TFCSPredictExtrapWeights.

Definition at line 119 of file TFCSParametrizationBase.h.

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

◆ operator[]() [1/2]

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

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

Reimplemented from TFCSParametrizationBase.

Definition at line 43 of file TFCSParametrizationChain.h.

43 {
44 return m_chain[ind];
45 };

◆ operator[]() [2/2]

virtual TFCSParametrizationBase * TFCSParametrizationChain::operator[] ( unsigned int )
inlineoverridevirtualinherited

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

Reimplemented from TFCSParametrizationBase.

Definition at line 46 of file TFCSParametrizationChain.h.

46 {
47 return m_chain[ind];
48 };

◆ pdgid()

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

Reimplemented from TFCSParametrizationBase.

Definition at line 34 of file TFCSParametrization.h.

34{ return m_pdgid; };

◆ Print()

void TFCSEnergyAndHitGANV2::Print ( Option_t * option = "") const
overridevirtual

Definition at line 572 of file TFCSEnergyAndHitGANV2.cxx.

572 {
574 TString opt(option);
575 const bool shortprint = opt.Index("short") >= 0;
576 const bool longprint =
577 msgLvl(MSG::DEBUG) || (msgLvl(MSG::INFO) && !shortprint);
578 TString optprint = opt;
579 optprint.ReplaceAll("short", "");
580
581 TString prefix = "- ";
582 for (unsigned int ichain = 0; ichain < size(); ++ichain) {
583 if (ichain == 0 && ichain != m_bin_start.front()) {
584 prefix = "> ";
585 if (longprint)
586 ATH_MSG_INFO(optprint << prefix << "Run for all bins");
587 }
588 for (unsigned int ibin = 0; ibin < get_number_of_bins(); ++ibin) {
589 if (ichain == m_bin_start[ibin]) {
590 if (ibin < get_number_of_bins() - 1)
591 if (ichain == m_bin_start[ibin + 1])
592 continue;
593 prefix = Form("%-2d", ibin);
594 if (longprint)
595 ATH_MSG_INFO(optprint << prefix << "Run for " << get_bin_text(ibin));
596 }
597 }
598 if (ichain == m_bin_start.back()) {
599 prefix = "< ";
600 if (longprint)
601 ATH_MSG_INFO(optprint << prefix << "Run for all bins");
602 }
603 chain()[ichain]->Print(opt + prefix);
604 }
605}
bool msgLvl(const MSG::Level lvl) const
Check whether the logging system is active at the provided verbosity level.
Definition MLogging.h:222
void Print(Option_t *option="") const
Print object information.
virtual unsigned int size() const override
Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operat...

◆ push_back()

void TFCSParametrizationChain::push_back ( const Chain_t::value_type & param)
inlineinherited

Definition at line 55 of file TFCSParametrizationChain.h.

55 {
56 m_chain.push_back(param);
57 recalc();
58 };
virtual void recalc()
Default is to call recalc_pdgid_intersect() and recalc_Ekin_eta_intersect().

◆ push_back_in_bin()

void TFCSParametrizationBinnedChain::push_back_in_bin ( TFCSParametrizationBase * param,
unsigned int bin )
virtualinherited

Reimplemented in TFCSParametrizationEkinSelectChain, TFCSParametrizationEtaSelectChain, and TFCSParametrizationFloatSelectChain.

Definition at line 31 of file TFCSParametrizationBinnedChain.cxx.

32 {
33 if (m_bin_start.size() <= bin + 1) {
34 m_bin_start.resize(bin + 2, m_bin_start.back());
35 m_bin_start.shrink_to_fit();
36 }
37 if (m_bin_start[bin + 1] == size()) {
38 chain().push_back(param);
39 } else {
40 Chain_t::iterator it(&chain()[m_bin_start[bin + 1]]);
41 chain().insert(it, param);
42 }
43 for (unsigned int ibin = bin + 1; ibin < m_bin_start.size(); ++ibin)
44 m_bin_start[ibin]++;
45 recalc();
46}

◆ push_before_first_bin()

void TFCSParametrizationBinnedChain::push_before_first_bin ( TFCSParametrizationBase * param)
virtualinherited

Definition at line 18 of file TFCSParametrizationBinnedChain.cxx.

19 {
20 if (m_bin_start[0] == size()) {
21 chain().push_back(param);
22 } else {
23 Chain_t::iterator it(&chain()[m_bin_start[0]]);
24 chain().insert(it, param);
25 }
26 for (auto &ele : m_bin_start)
27 ele++;
28 recalc();
29}

◆ recalc()

void TFCSParametrizationChain::recalc ( )
protectedvirtualinherited

◆ recalc_Ekin_eta_intersect()

void TFCSParametrizationChain::recalc_Ekin_eta_intersect ( )
protectedinherited

◆ recalc_Ekin_eta_union()

void TFCSParametrizationChain::recalc_Ekin_eta_union ( )
protectedinherited

◆ recalc_Ekin_intersect()

void TFCSParametrizationChain::recalc_Ekin_intersect ( )
protectedinherited

Definition at line 45 of file TFCSParametrizationChain.cxx.

45 {
46 set_Ekin(*m_chain[0]);
47
48 for (const auto &param : m_chain) {
49 if (param->Ekin_min() > Ekin_min())
50 set_Ekin_min(param->Ekin_min());
51 if (param->Ekin_max() < Ekin_max())
52 set_Ekin_max(param->Ekin_max());
53 if (Ekin_nominal() < Ekin_min() || Ekin_nominal() > Ekin_max())
54 set_Ekin_nominal(param->Ekin_nominal());
55 }
56
57 if (Ekin_nominal() < Ekin_min() || Ekin_nominal() > Ekin_max())
58 set_Ekin_nominal(0.5 * (Ekin_min() + Ekin_max()));
59}
virtual void set_Ekin_max(double max)
virtual void set_Ekin_min(double min)
virtual void set_Ekin(const TFCSParametrizationBase &ref)
virtual void set_Ekin_nominal(double min)

◆ recalc_Ekin_union()

void TFCSParametrizationChain::recalc_Ekin_union ( )
protectedinherited

Definition at line 82 of file TFCSParametrizationChain.cxx.

82 {
83 set_Ekin(*m_chain[0]);
84
85 for (const auto &param : m_chain) {
86 if (param->Ekin_min() < Ekin_min())
87 set_Ekin_min(param->Ekin_min());
88 if (param->Ekin_max() > Ekin_max())
89 set_Ekin_max(param->Ekin_max());
90 if (Ekin_nominal() < Ekin_min() || Ekin_nominal() > Ekin_max())
91 set_Ekin_nominal(param->Ekin_nominal());
92 }
93
94 if (Ekin_nominal() < Ekin_min() || Ekin_nominal() > Ekin_max())
95 set_Ekin_nominal(0.5 * (Ekin_min() + Ekin_max()));
96}

◆ recalc_eta_intersect()

void TFCSParametrizationChain::recalc_eta_intersect ( )
protectedinherited

Definition at line 61 of file TFCSParametrizationChain.cxx.

61 {
62 set_eta(*m_chain[0]);
63
64 for (const auto &param : m_chain) {
65 if (param->eta_min() > eta_min())
66 set_eta_min(param->eta_min());
67 if (param->eta_max() < eta_max())
68 set_eta_max(param->eta_max());
69 if (eta_nominal() < eta_min() || eta_nominal() > eta_max())
70 set_eta_nominal(param->eta_nominal());
71 }
72
73 if (eta_nominal() < eta_min() || eta_nominal() > eta_max())
74 set_eta_nominal(0.5 * (eta_min() + eta_max()));
75}
virtual void set_eta(const TFCSParametrizationBase &ref)

◆ recalc_eta_union()

void TFCSParametrizationChain::recalc_eta_union ( )
protectedinherited

Definition at line 98 of file TFCSParametrizationChain.cxx.

98 {
99 set_eta(*m_chain[0]);
100
101 for (const auto &param : m_chain) {
102 if (param->eta_min() < eta_min())
103 set_eta_min(param->eta_min());
104 if (param->eta_max() > eta_max())
105 set_eta_max(param->eta_max());
106 if (eta_nominal() < eta_min() || eta_nominal() > eta_max())
107 set_eta_nominal(param->eta_nominal());
108 }
109
110 if (eta_nominal() < eta_min() || eta_nominal() > eta_max())
111 set_eta_nominal(0.5 * (eta_min() + eta_max()));
112}

◆ recalc_pdgid_intersect()

void TFCSParametrizationChain::recalc_pdgid_intersect ( )
protectedinherited

Definition at line 20 of file TFCSParametrizationChain.cxx.

20 {
21 set_pdgid(m_chain[0]->pdgid());
22
23 for (const auto &param : m_chain) {
24 std::set<int> tmp;
25
26 std::set_intersection(pdgid().begin(), pdgid().end(),
27 param->pdgid().begin(), param->pdgid().end(),
28 std::inserter(tmp, tmp.begin()));
29 set_pdgid(tmp);
30 }
31}

◆ recalc_pdgid_union()

void TFCSParametrizationChain::recalc_pdgid_union ( )
protectedinherited

Definition at line 33 of file TFCSParametrizationChain.cxx.

33 {
34 set_pdgid(chain()[0]->pdgid());
35
36 for (const auto &param : chain()) {
37 std::set<int> tmp;
38
39 std::set_union(pdgid().begin(), pdgid().end(), param->pdgid().begin(),
40 param->pdgid().end(), std::inserter(tmp, tmp.begin()));
41 set_pdgid(tmp);
42 }
43}

◆ RemoveDuplicates()

void TFCSParametrizationBase::RemoveDuplicates ( )
inherited

Definition at line 152 of file TFCSParametrizationBase.cxx.

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

◆ RemoveNameTitle()

void TFCSParametrizationBase::RemoveNameTitle ( )
inherited

Definition at line 210 of file TFCSParametrizationBase.cxx.

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

◆ reset_GANfreemem()

void TFCSEnergyAndHitGANV2::reset_GANfreemem ( )
inline

Definition at line 42 of file TFCSEnergyAndHitGANV2.h.

42{ ResetBit(kGANfreemem); };

◆ reset_match_all_pdgid()

virtual void TFCSParametrizationBase::reset_match_all_pdgid ( )
inlinevirtualinherited

Definition at line 84 of file TFCSParametrizationBase.h.

84{ ResetBit(kMatchAllPDGID); };

◆ reset_OnlyScaleEnergy()

void TFCSEnergyAndHitGANV2::reset_OnlyScaleEnergy ( )
inline

Definition at line 53 of file TFCSEnergyAndHitGANV2.h.

53{ ResetBit(kOnlyScaleEnergy); };

◆ reset_RetryChainFromStart()

void TFCSParametrizationChain::reset_RetryChainFromStart ( )
inlineinherited

Definition at line 38 of file TFCSParametrizationChain.h.

38{ ResetBit(kRetryChainFromStart); };

◆ reset_SplitChainObjects()

void TFCSParametrizationChain::reset_SplitChainObjects ( )
inlineinherited

Definition at line 34 of file TFCSParametrizationChain.h.

34{ ResetBit(kSplitChainObjects); };

◆ RetryChainFromStart()

bool TFCSParametrizationChain::RetryChainFromStart ( ) const
inlineinherited

Definition at line 36 of file TFCSParametrizationChain.h.

36{ return TestBit(kRetryChainFromStart); };

◆ set_daughter()

virtual void TFCSParametrizationChain::set_daughter ( unsigned int ,
TFCSParametrizationBase *  )
inlineoverridevirtualinherited

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 from TFCSParametrizationBase.

Definition at line 49 of file TFCSParametrizationChain.h.

50 {
51 m_chain.at(ind) = param;
52 };

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

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

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

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

void TFCSEnergyAndHitGANV2::set_GANfreemem ( )
inline

Definition at line 41 of file TFCSEnergyAndHitGANV2.h.

41{ SetBit(kGANfreemem); };

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

void TFCSEnergyAndHitGANV2::set_nr_of_init ( unsigned int bin,
unsigned int ninit )

Definition at line 62 of file TFCSEnergyAndHitGANV2.cxx.

63 {
64 if (bin >= m_bin_ninit.size()) {
65 m_bin_ninit.resize(bin + 1, 0);
66 m_bin_ninit.shrink_to_fit();
67 }
68 m_bin_ninit[bin] = ninit;
69}

◆ set_OnlyScaleEnergy()

void TFCSEnergyAndHitGANV2::set_OnlyScaleEnergy ( )
inline

Definition at line 52 of file TFCSEnergyAndHitGANV2.h.

52{ SetBit(kOnlyScaleEnergy); };

◆ set_pdgid() [1/2]

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

Reimplemented in TFCSEnergyBinParametrization.

Definition at line 33 of file TFCSParametrization.cxx.

◆ set_pdgid() [2/2]

void TFCSParametrization::set_pdgid ( int id)
virtualinherited

Reimplemented in TFCSEnergyBinParametrization.

Definition at line 28 of file TFCSParametrization.cxx.

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

◆ set_pdgid_Ekin_eta()

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

Definition at line 72 of file TFCSParametrization.cxx.

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

◆ set_RetryChainFromStart()

void TFCSParametrizationChain::set_RetryChainFromStart ( )
inlineinherited

Definition at line 37 of file TFCSParametrizationChain.h.

37{ SetBit(kRetryChainFromStart); };

◆ set_SplitChainObjects()

void TFCSParametrizationChain::set_SplitChainObjects ( )
inlineinherited

Definition at line 33 of file TFCSParametrizationChain.h.

33{ SetBit(kSplitChainObjects); };

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

◆ SetRegionAndSliceFromXML()

void TFCSEnergyAndHitGANV2::SetRegionAndSliceFromXML ( int pid,
int etaMax,
std::string FastCaloGANInputFolderName )
protected

◆ simulate()

FCSReturnCode TFCSEnergyAndHitGANV2::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 TFCSParametrizationBinnedChain.

Definition at line 551 of file TFCSEnergyAndHitGANV2.cxx.

553 {
554 for (unsigned int ichain = 0; ichain < m_bin_start[0]; ++ichain) {
555 ATH_MSG_DEBUG("now run for all bins: " << chain()[ichain]->GetName());
556 if (simulate_and_retry(chain()[ichain], simulstate, truth, extrapol) !=
557 FCSSuccess) {
558 return FCSFatal;
559 }
560 }
561
562 ATH_MSG_VERBOSE("Fill Energies");
563 if (!fillEnergy(simulstate, truth, extrapol)) {
564 ATH_MSG_WARNING("Could not fill energies ");
565 // bail out but do not stop the job
566 return FCSSuccess;
567 }
568
569 return FCSSuccess;
570}
bool fillEnergy(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const

◆ simulate_and_retry()

FCSReturnCode TFCSParametrizationChain::simulate_and_retry ( TFCSParametrizationBase * parametrization,
TFCSSimulationState & simulstate,
const TFCSTruthState * truth,
const TFCSExtrapolationState * extrapol ) const
protectedinherited

◆ size()

virtual unsigned int TFCSParametrizationChain::size ( ) const
inlineoverridevirtualinherited

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

Reimplemented from TFCSParametrizationBase.

Definition at line 41 of file TFCSParametrizationChain.h.

41{ return m_chain.size(); };

◆ SplitChainObjects()

bool TFCSParametrizationChain::SplitChainObjects ( ) const
inlineinherited

Definition at line 32 of file TFCSParametrizationChain.h.

32{ return TestBit(kSplitChainObjects); };

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

◆ test_path()

void TFCSEnergyAndHitGANV2::test_path ( const std::string & path,
TFCSSimulationState * simulstate = nullptr,
const TFCSTruthState * truth = nullptr,
const TFCSExtrapolationState * extrapol = nullptr,
const std::string & outputname = "unnamed",
int pid = 211 )
static

Definition at line 625 of file TFCSEnergyAndHitGANV2.cxx.

629 {
630 ISF_FCS::MLogging logger;
631 ATH_MSG_NOCLASS(logger, "Running test on " << path << std::endl);
632 if (!simulstate) {
633 simulstate = new TFCSSimulationState();
634#if defined(__FastCaloSimStandAlone__)
635 simulstate->setRandomEngine(new CLHEP::TRandomEngine());
636#else
637 simulstate->setRandomEngine(new CLHEP::RanluxEngine());
638#endif
639 }
640 if (!truth) {
641 ATH_MSG_NOCLASS(logger, "New particle");
642 TFCSTruthState *t = new TFCSTruthState();
643 t->SetPtEtaPhiM(65536, 0, 0, ParticleConstants::chargedPionMassInMeV);
644 t->set_pdgid(pid);
645 truth = t;
646 }
647 if (!extrapol) {
648 TFCSExtrapolationState *e = new TFCSExtrapolationState();
649 e->set_IDCaloBoundary_eta(truth->Eta());
650 for (int i = 0; i < 24; ++i) {
651 e->set_eta(i, TFCSExtrapolationState::SUBPOS_ENT, truth->Eta());
652 e->set_eta(i, TFCSExtrapolationState::SUBPOS_EXT, truth->Eta());
653 e->set_eta(i, TFCSExtrapolationState::SUBPOS_MID, truth->Eta());
657 e->set_r(i, TFCSExtrapolationState::SUBPOS_ENT, 1500 + i * 10);
658 e->set_r(i, TFCSExtrapolationState::SUBPOS_EXT, 1510 + i * 10);
659 e->set_r(i, TFCSExtrapolationState::SUBPOS_MID, 1505 + i * 10);
660 e->set_z(i, TFCSExtrapolationState::SUBPOS_ENT, 3500 + i * 10);
661 e->set_z(i, TFCSExtrapolationState::SUBPOS_EXT, 3510 + i * 10);
662 e->set_z(i, TFCSExtrapolationState::SUBPOS_MID, 3505 + i * 10);
663 }
664 extrapol = e;
665 }
666
667 TFCSEnergyAndHitGANV2 GAN("GAN", "GAN");
668 GAN.setLevel(MSG::INFO);
669 const int etaMin = 20;
670 const int etaMax = etaMin + 5;
671 ATH_MSG_NOCLASS(logger, "Initialize Networks");
672 GAN.initializeNetwork(pid, etaMin, path);
673 for (int i = 0; i < 24; ++i)
674 if (GAN.is_match_calosample(i)) {
675 TFCSCenterPositionCalculation *c = new TFCSCenterPositionCalculation(
676 Form("center%d", i), Form("center layer %d", i));
677 c->set_calosample(i);
678 c->setExtrapWeight(0.5);
679 c->setLevel(MSG::INFO);
680 c->set_pdgid(pid);
681 if (pid == 11)
682 c->add_pdgid(-pid);
683 if (pid == 211)
684 c->add_pdgid(-pid);
685 c->set_eta_min(etaMin / 100.0);
686 c->set_eta_max(etaMax / 100.0);
687 c->set_eta_nominal((etaMin + etaMax) / 200.0);
688
689 GAN.push_back_in_bin(c, i);
690 GAN.set_nr_of_init(i, 1);
691 }
692
693 GAN.Print();
694
695 ATH_MSG_NOCLASS(logger, "Writing GAN to " << outputname);
696 const std::string outname = "FCSGANtest_" + outputname + ".root";
697 TFile *fGAN = TFile::Open(outname.c_str(), "recreate");
698 fGAN->cd();
699 // GAN.Write();
700 fGAN->WriteObjectAny(&GAN, "TFCSEnergyAndHitGANV2", "GAN");
701
702 fGAN->ls();
703 fGAN->Close();
704 delete fGAN;
705
706 ATH_MSG_NOCLASS(logger, "Open " << outname);
707 fGAN = TFile::Open(outname.c_str());
708 TFCSEnergyAndHitGANV2 *GAN2 = (TFCSEnergyAndHitGANV2 *)(fGAN->Get("GAN"));
709 GAN2->setLevel(MSG::INFO);
710 GAN2->Print();
711
712 ATH_MSG_NOCLASS(logger, "Before running GAN2->simulate()");
713 GAN2->simulate(*simulstate, truth, extrapol);
714 simulstate->Print();
715 delete fGAN;
716}
#define ATH_MSG_NOCLASS(logger_name, x)
Definition MLogging.h:52
virtual void setLevel(MSG::Level lvl)
Update outputlevel.
Definition MLogging.cxx:105
virtual void Print(Option_t *option="") const override
TFCSEnergyAndHitGANV2(const char *name=nullptr, const char *title=nullptr)
virtual FCSReturnCode simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Method in all derived classes to do some simulation.
void setRandomEngine(CLHEP::HepRandomEngine *engine)
static Root::TMsgLogger logger("iLumiCalc")
constexpr double chargedPionMassInMeV
the mass of the charged pion (in MeV)

◆ unit_test()

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

Definition at line 607 of file TFCSEnergyAndHitGANV2.cxx.

609 {
610 ISF_FCS::MLogging logger;
611 ATH_MSG_NOCLASS(logger, "Start lwtnn test" << std::endl);
612 std::string path =
613 "/eos/atlas/atlascerngroupdisk/proj-simul/AF3_Run3/"
614 "InputsToBigParamFiles/FastCaloGANWeightsVer02/";
615 test_path(path, simulstate, truth, extrapol, "lwtnn");
616
617 ATH_MSG_NOCLASS(logger, "Start onnx test" << std::endl);
618 path =
619 "/eos/atlas/atlascerngroupdisk/proj-simul/AF3_Run3/"
620 "InputsToBigParamFiles/FastCaloGANWeightsONNXVer08/";
621 test_path(path, simulstate, truth, extrapol, "onnx");
622 ATH_MSG_NOCLASS(logger, "Finish all tests" << std::endl);
623}
static void test_path(const std::string &path, TFCSSimulationState *simulstate=nullptr, const TFCSTruthState *truth=nullptr, const TFCSExtrapolationState *extrapol=nullptr, const std::string &outputname="unnamed", int pid=211)
path
python interpreter configuration --------------------------------------—
Definition athena.py:130

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_bin_ninit

std::vector<int> TFCSEnergyAndHitGANV2::m_bin_ninit
private

Definition at line 103 of file TFCSEnergyAndHitGANV2.h.

◆ m_bin_start

std::vector<unsigned int> TFCSParametrizationBinnedChain::m_bin_start
protectedinherited

Contains the index where the TFCSParametrizationBase* instances to run for a given bin start.

The last entry of the vector correponds to the index from where on TFCSParametrizationBase* objects should be run again for all bins. This way one can loop over some instances for all bins, then only specific ones for one bin and at the end again over some for all bins

Definition at line 53 of file TFCSParametrizationBinnedChain.h.

◆ m_chain

Chain_t TFCSParametrizationChain::m_chain
privateinherited

Definition at line 99 of file TFCSParametrizationChain.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_mutex

std::mutex TFCSEnergyAndHitGANV2::m_mutex
mutableprivate

Definition at line 112 of file TFCSEnergyAndHitGANV2.h.

◆ m_nm

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

Message source name.

Definition at line 211 of file MLogging.h.

◆ m_param

TFCSGANXMLParameters TFCSEnergyAndHitGANV2::m_param
private

Definition at line 111 of file TFCSEnergyAndHitGANV2.h.

◆ m_pdgid

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

Definition at line 63 of file TFCSParametrization.h.

◆ m_slice

TFCSGANEtaSlice* TFCSEnergyAndHitGANV2::m_slice = nullptr
private

Definition at line 110 of file TFCSEnergyAndHitGANV2.h.

◆ m_writtenBases

std::vector<std::unique_ptr<TFCSParametrizationBase> > TFCSParametrizationChain::m_writtenBases
privateinherited

Definition at line 102 of file TFCSParametrizationChain.h.


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