35{
36 void AlgSelect ::
37 testInvariant () const
38 {
40
42 for (std::size_t form = 0, end = m_cuts.size(); form != end; ++ form)
44 if (m_skim != 0)
45 {
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 {
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 {
74
76 m_cuts.push_back (cut);
77
79 }
80
81
82
83 const std::string& AlgSelect ::
84 outputStream () const
85 {
87 return m_outputStream;
88 }
89
90
91
92 const std::string& AlgSelect ::
93 histName () const
94 {
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 {
115 m_cuts.push_back (cut);
116 }
117
118
119
120 StatusCode AlgSelect ::
121 setupJob (Job& job)
122 {
125 return StatusCode::SUCCESS;
126 }
127
128
129
130 StatusCode AlgSelect ::
131 initialize ()
132 {
134
135 try
136 {
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
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
166
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:
175 break;
176 case 0:
177 myweight = m_index[form]->value (0);
178 break;
179 case 1:
181 break;
182 default:
183 RCU_THROW_MSG (
"unknown formula dimension: " + m_cuts[form]);
184 }
185
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_CHANGE_INVARIANT(x)
#define RCU_NEW_INVARIANT(x)
#define RCU_REQUIRE_SOFT(x)
#define RCU_READ_INVARIANT(x)
#define RCU_THROW_MSG(message)
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