ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSParametrizationPDGIDSelectChain.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
10#include <iostream>
11
12//=============================================
13//======= TFCSParametrizationPDGIDSelectChain =========
14//=============================================
15
17 clear();
18 if (size() == 0)
19 return;
20
23
24 chain().shrink_to_fit();
25}
26
28 TFCSSimulationState &simulstate, const TFCSTruthState *truth,
29 const TFCSExtrapolationState *extrapol) const {
30 Int_t retry = 0;
31 Int_t retry_warning = 1;
32
34 for (int i = 0; i <= retry; i++) {
35 if (i >= retry_warning)
36 ATH_MSG_WARNING("TFCSParametrizationPDGIDSelectChain::simulate(): Retry "
37 "simulate call "
38 << i << "/" << retry);
39
40 ATH_MSG_DEBUG("Running for pdgid=" << truth->pdgid());
41 for (const auto &param : chain()) {
42 ATH_MSG_DEBUG("Now testing: "
43 << param->GetName()
44 << ((SimulateOnlyOnePDGID() == true)
45 ? ", abort PDGID loop afterwards"
46 : ", continue PDGID loop afterwards"));
47 if (param->is_match_pdgid(truth->pdgid())) {
48 ATH_MSG_DEBUG("pdgid=" << truth->pdgid()
49 << ", now run: " << param->GetName()
50 << ((SimulateOnlyOnePDGID() == true)
51 ? ", abort PDGID loop afterwards"
52 : ", continue PDGID loop afterwards"));
53 status = simulate_and_retry(param, simulstate, truth, extrapol);
54 if (status >= FCSRetry) {
55 retry = status - FCSRetry;
56 retry_warning = retry >> 1;
57 if (retry_warning < 1)
58 retry_warning = 1;
59 break;
60 }
61 if (status == FCSFatal)
62 return FCSFatal;
63
65 break;
66 }
67 }
68
69 if (status == FCSSuccess)
70 break;
71 }
72
73 if (status != FCSSuccess) {
75 "TFCSParametrizationChain::simulate(): Simulate call failed after "
76 << retry << " retries");
77 return FCSFatal;
78 }
79
80 return FCSSuccess;
81}
82
84 TFCSSimulationState *simulstate, TFCSTruthState *truth,
85 TFCSExtrapolationState *extrapol) {
87 if (!simulstate)
88 simulstate = new TFCSSimulationState();
89 if (!truth)
90 truth = new TFCSTruthState();
91 if (!extrapol)
92 extrapol = new TFCSExtrapolationState();
93
95 chain.setLevel(MSG::DEBUG);
96
98 param = new TFCSInvisibleParametrization("A begin all", "A begin all");
99 param->setLevel(MSG::VERBOSE);
100 param->set_pdgid(0);
101 chain.push_back(param);
102 param = new TFCSInvisibleParametrization("A end all", "A end all");
103 param->setLevel(MSG::VERBOSE);
104 param->set_pdgid(0);
105 chain.push_back(param);
106
107 for (int i = 0; i < 3; ++i) {
108 param = new TFCSInvisibleParametrization(Form("A%d", i), Form("A %d", i));
109 param->setLevel(MSG::VERBOSE);
110 param->set_pdgid(i);
111 chain.push_back(param);
112 }
113
114 for (int i = 3; i > 0; --i) {
115 param = new TFCSParametrization(Form("B%d", i), Form("B %d", i));
116 param->setLevel(MSG::VERBOSE);
117 param->set_pdgid(i);
118 chain.push_back(param);
119 }
120 param = new TFCSInvisibleParametrization("B end all", "B end all");
121 param->setLevel(MSG::VERBOSE);
122 param->set_match_all_pdgid();
123 chain.push_back(param);
124 param = new TFCSInvisibleParametrization("B begin all", "B begin all");
125 param->setLevel(MSG::VERBOSE);
126 param->set_pdgid(1);
127 chain.push_back(param);
128
129 ATH_MSG_NOCLASS(logger, "==== Chain setup ====");
130 chain.Print();
131 ATH_MSG_NOCLASS(logger, "==== Simulate with pdgid=0 ====");
132 truth->set_pdgid(0);
133 chain.simulate(*simulstate, truth, extrapol);
134 ATH_MSG_NOCLASS(logger, "==== Simulate with pdgid=1 ====");
135 truth->set_pdgid(1);
136 chain.simulate(*simulstate, truth, extrapol);
137 ATH_MSG_NOCLASS(logger, "==== Simulate with pdgid=2 ====");
138 truth->set_pdgid(2);
139 chain.set_RetryChainFromStart();
140 chain.simulate(*simulstate, truth, extrapol);
141 chain.reset_RetryChainFromStart();
142 ATH_MSG_NOCLASS(logger, "=====================================" << std::endl);
143
144 ATH_MSG_NOCLASS(logger, "=====================================");
145 ATH_MSG_NOCLASS(logger, "= Now only one simul for each PDGID =");
146 ATH_MSG_NOCLASS(logger, "=====================================");
147 chain.set_SimulateOnlyOnePDGID();
148 ATH_MSG_NOCLASS(logger, "==== Simulate with pdgid=0 ====");
149 truth->set_pdgid(0);
150 chain.simulate(*simulstate, truth, extrapol);
151 ATH_MSG_NOCLASS(logger, "==== Simulate with pdgid=1 ====");
152 truth->set_pdgid(1);
153 chain.simulate(*simulstate, truth, extrapol);
154 ATH_MSG_NOCLASS(logger, "==== Simulate with pdgid=2 ====");
155 truth->set_pdgid(2);
156 chain.set_RetryChainFromStart();
157 chain.simulate(*simulstate, truth, extrapol);
158 chain.reset_RetryChainFromStart();
159}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define ATH_MSG_NOCLASS(logger_name, x)
Definition MLogging.h:52
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
Cut down AthMessaging.
Definition MLogging.h:176
virtual void setLevel(MSG::Level lvl)
Update outputlevel.
Definition MLogging.cxx:105
FCSReturnCode simulate_and_retry(TFCSParametrizationBase *parametrization, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
const Chain_t & chain() const
virtual unsigned int size() const override
Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operat...
static void unit_test(TFCSSimulationState *simulstate=nullptr, TFCSTruthState *truth=nullptr, TFCSExtrapolationState *extrapol=nullptr)
virtual void recalc() override
Default is to call recalc_pdgid_intersect() and recalc_Ekin_eta_intersect()
virtual FCSReturnCode simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Method in all derived classes to do some simulation.
TFCSParametrizationPDGIDSelectChain(const char *name=nullptr, const char *title=nullptr)
TFCSParametrization(const char *name=nullptr, const char *title=nullptr)
virtual void set_pdgid(int id)
int pdgid() const
void set_pdgid(int val)
static Root::TMsgLogger logger("iLumiCalc")