ATLAS Offline Software
Loading...
Searching...
No Matches
AlgSelect.cxx File Reference
Include dependency graph for AlgSelect.cxx:

Go to the source code of this file.

Functions

 ClassImp (EL::AlgSelect) namespace EL

Function Documentation

◆ ClassImp()

ClassImp ( EL::AlgSelect )

Definition at line 32 of file AlgSelect.cxx.

35{
36 void AlgSelect ::
37 testInvariant () const
38 {
39 RCU_INVARIANT (this != 0);
40
41 RCU_INVARIANT (!m_outputStream.empty());
42 for (std::size_t form = 0, end = m_cuts.size(); form != end; ++ form)
43 RCU_INVARIANT (!m_cuts[form].empty());
44 if (m_skim != 0)
45 {
46 RCU_INVARIANT (m_cuts.size() == m_index.size());
47 RCU_INVARIANT (m_hist != 0);
48 RCU_INVARIANT (m_formSvc != 0);
49 }
50 if (m_hist != 0)
51 {
52 RCU_INVARIANT (m_cuts.size() == std::size_t (m_hist->GetNbinsX()));
53 }
54 }
55
56
57
58 AlgSelect ::
59 AlgSelect ()
60 : m_outputStream ("output"),
61 m_hist (0), m_formSvc (0), m_skim (0)
62 {
63 RCU_NEW_INVARIANT (this);
64 }
65
66
67
68 AlgSelect ::
69 AlgSelect (const std::string& val_outputStream, const std::string& cut)
70 : m_outputStream (val_outputStream),
71 m_hist (0), m_formSvc (0), m_skim (0)
72 {
73 RCU_ASSERT (!val_outputStream.empty());
74
75 if (!cut.empty())
76 m_cuts.push_back (cut);
77
78 RCU_NEW_INVARIANT (this);
79 }
80
81
82
83 const std::string& AlgSelect ::
84 outputStream () const
85 {
86 RCU_READ_INVARIANT (this);
87 return m_outputStream;
88 }
89
90
91
92 const std::string& AlgSelect ::
93 histName () const
94 {
95 RCU_READ_INVARIANT (this);
96 return m_histName;
97 }
98
99
100
101 void AlgSelect ::
102 histName (const std::string& val_histName)
103 {
105 m_histName = val_histName;
106 }
107
108
109
110 void AlgSelect ::
111 addCut (const std::string& cut)
112 {
114 RCU_REQUIRE_SOFT (!cut.empty());
115 m_cuts.push_back (cut);
116 }
117
118
119
120 StatusCode AlgSelect ::
121 setupJob (Job& job)
122 {
124 MD::useFormulas (job);
125 return StatusCode::SUCCESS;
126 }
127
128
129
130 StatusCode AlgSelect ::
131 initialize ()
132 {
134
135 try
136 {
137 m_formSvc = MD::formulas (wk());
138 if (!m_cuts.empty() && !m_histName.empty())
139 {
140 m_hist = new TH1D (m_histName.c_str(), 0, m_cuts.size(), 0, m_cuts.size());
141 wk()->addOutput (m_hist);
142 }
143 for (std::size_t form = 0, end = m_cuts.size(); form != end; ++ form)
144 {
145 m_index.push_back (m_formSvc->addForm (m_cuts[form]));
146 m_hist->GetXaxis()->SetBinLabel (1 + form, m_cuts[form].c_str());
147 }
148
149 m_skim = getNTupleSvc (wk(), m_outputStream);
150 } catch (...)
151 {
152 m_index.clear ();
153 throw;
154 }
155 return StatusCode::SUCCESS;
156 }
157
158
159
160 StatusCode AlgSelect ::
161 execute ()
162 {
164
165 RCU_ASSERT (m_hist != 0);
166
167 double weight = 1;
168 for (std::size_t form = 0; form != m_cuts.size() && weight != 0; ++ form)
169 {
170 double myweight = 1;
171 if (m_index[form]) switch (m_index[form]->ndim())
172 {
173 case -1:
174 RCU_THROW_MSG ("formula not valid: " + m_cuts[form]);
175 break;
176 case 0:
177 myweight = m_index[form]->value (0);
178 break;
179 case 1:
180 RCU_THROW_MSG ("formula is an array: " + m_cuts[form]);
181 break;
182 default:
183 RCU_THROW_MSG ("unknown formula dimension: " + m_cuts[form]);
184 }
185
186 weight *= myweight;
187 if (m_hist && weight != 0)
188 m_hist->Fill (form);
189 }
190
191 if (weight)
192 m_skim->setFilterPassed ();
193 return StatusCode::SUCCESS;
194 }
195}
#define RCU_INVARIANT(x)
Definition Assert.h:201
#define RCU_ASSERT(x)
Definition Assert.h:222
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:231
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:233
#define RCU_REQUIRE_SOFT(x)
Definition Assert.h:153
#define RCU_READ_INVARIANT(x)
Definition Assert.h:229
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:58
static const Attributes_t empty
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
NTupleSvc * getNTupleSvc(IWorker *worker, const std::string &outputStream, const std::string &treeName="")
effects: get the skimming algorithm for the given output for this worker guarantee: strong failures: ...
FormulaSvc * formulas(EL::IWorker *worker)
returns: the formula service for this worker guarantee: strong failures: formula service not configur...
void useFormulas(EL::Job &job)
effects: register the formula service for this job guarantee: strong failures: out of memory I