ATLAS Offline Software
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,
87  if (!simulstate)
88  simulstate = new TFCSSimulationState();
89  if (!truth)
90  truth = new TFCSTruthState();
91  if (!extrapol)
93 
95  chain.setLevel(MSG::DEBUG);
96 
97  TFCSParametrization *param;
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 }
FCSReturnCode
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
Definition: TFCSParametrizationBase.h:41
ISF_FCS::MLogging
Cut down AthMessaging.
Definition: MLogging.h:176
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
TFCSParametrizationPDGIDSelectChain::simulate
virtual FCSReturnCode simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Method in all derived classes to do some simulation.
Definition: TFCSParametrizationPDGIDSelectChain.cxx:27
TFCSExtrapolationState
Definition: TFCSExtrapolationState.h:13
RunActsMaterialValidation.extrapol
extrapol
Definition: RunActsMaterialValidation.py:91
TFCSParametrizationPDGIDSelectChain::SimulateOnlyOnePDGID
bool SimulateOnlyOnePDGID() const
Definition: TFCSParametrizationPDGIDSelectChain.h:30
TFCSParametrizationPDGIDSelectChain::recalc
virtual void recalc() override
Default is to call recalc_pdgid_intersect() and recalc_Ekin_eta_intersect()
Definition: TFCSParametrizationPDGIDSelectChain.cxx:16
FCSRetry
@ FCSRetry
Definition: TFCSParametrizationBase.h:41
TFCSParametrization::set_pdgid
virtual void set_pdgid(int id)
Definition: TFCSParametrization.cxx:28
lumiFormat.i
int i
Definition: lumiFormat.py:85
TFCSParametrizationChain::chain
const Chain_t & chain() const
Definition: TFCSParametrizationChain.h:53
TFCSParametrization::TFCSParametrization
TFCSParametrization(const char *name=nullptr, const char *title=nullptr)
Definition: TFCSParametrization.cxx:12
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TFCSParametrizationBase::set_match_all_pdgid
virtual void set_match_all_pdgid()
Definition: TFCSParametrizationBase.h:83
FCSFatal
@ FCSFatal
Definition: TFCSParametrizationBase.h:41
FCSSuccess
@ FCSSuccess
Definition: TFCSParametrizationBase.h:41
TFCSParametrization
Definition: TFCSParametrization.h:10
ISF_FCS::MLogging::setLevel
virtual void setLevel(MSG::Level lvl)
Update outputlevel.
Definition: MLogging.cxx:105
TFCSParametrizationPDGIDSelectChain
Definition: TFCSParametrizationPDGIDSelectChain.h:10
TFCSParametrization::clear
void clear()
Definition: TFCSParametrization.cxx:18
TFCSTruthState::pdgid
int pdgid() const
Definition: TFCSTruthState.h:25
TFCSInvisibleParametrization
Definition: TFCSInvisibleParametrization.h:10
TFCSParametrizationPDGIDSelectChain.h
TFCSParametrizationChain::recalc_pdgid_union
void recalc_pdgid_union()
Definition: TFCSParametrizationChain.cxx:33
TFCSTruthState.h
ATH_MSG_NOCLASS
#define ATH_MSG_NOCLASS(logger_name, x)
Definition: MLogging.h:52
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TFCSExtrapolationState.h
DEBUG
#define DEBUG
Definition: page_access.h:11
TFCSParametrizationChain::simulate_and_retry
FCSReturnCode simulate_and_retry(TFCSParametrizationBase *parametrization, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const
TFCSInvisibleParametrization.h
TFCSParametrizationChain::recalc_Ekin_eta_intersect
void recalc_Ekin_eta_intersect()
Definition: TFCSParametrizationChain.cxx:77
merge.status
status
Definition: merge.py:17
TFCSSimulationState.h
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
TFCSTruthState
Definition: TFCSTruthState.h:13
TFCSSimulationState
Definition: TFCSSimulationState.h:32
TFCSParametrizationPDGIDSelectChain::unit_test
static void unit_test(TFCSSimulationState *simulstate=nullptr, TFCSTruthState *truth=nullptr, TFCSExtrapolationState *extrapol=nullptr)
Definition: TFCSParametrizationPDGIDSelectChain.cxx:83
python.iconfTool.gui.pad.logger
logger
Definition: pad.py:14
TFCSTruthState::set_pdgid
void set_pdgid(int val)
Definition: TFCSTruthState.h:18
TFCSParametrizationChain::size
virtual unsigned int size() const override
Some derived classes have daughter instances of TFCSParametrizationBase objects The size() and operat...
Definition: TFCSParametrizationChain.h:41