29{
30 void AlgSelect ::
31 testInvariant () const
32 {
34
36 for (std::size_t form = 0, end = m_cuts.size(); form != end; ++ form)
38 if (m_skim != 0)
39 {
43 }
44 if (m_hist != 0)
45 {
46 RCU_INVARIANT (m_cuts.size() == std::size_t (m_hist->GetNbinsX()));
47 }
48 }
49
50
51
52 AlgSelect ::
53 AlgSelect ()
54 : m_outputStream ("output"),
55 m_hist (0), m_formSvc (0), m_skim (0)
56 {
58 }
59
60
61
62 AlgSelect ::
63 AlgSelect (const std::string& val_outputStream, const std::string& cut)
64 : m_outputStream (val_outputStream),
65 m_hist (0), m_formSvc (0), m_skim (0)
66 {
68
70 m_cuts.push_back (cut);
71
73 }
74
75
76
77 const std::string& AlgSelect ::
78 outputStream () const
79 {
81 return m_outputStream;
82 }
83
84
85
86 const std::string& AlgSelect ::
87 histName () const
88 {
90 return m_histName;
91 }
92
93
94
95 void AlgSelect ::
96 histName (const std::string& val_histName)
97 {
99 m_histName = val_histName;
100 }
101
102
103
104 void AlgSelect ::
105 addCut (const std::string& cut)
106 {
109 m_cuts.push_back (cut);
110 }
111
112
113
115 setupJob (Job& job)
116 {
119 return StatusCode::SUCCESS;
120 }
121
122
123
125 initialize ()
126 {
128
129 try
130 {
132 if (!m_cuts.empty() && !m_histName.empty())
133 {
134 m_hist = new TH1D (m_histName.c_str(), 0, m_cuts.size(), 0, m_cuts.size());
135 wk()->addOutput (m_hist);
136 }
137 for (std::size_t form = 0, end = m_cuts.size(); form != end; ++ form)
138 {
139 m_index.push_back (m_formSvc->addForm (m_cuts[form]));
140 m_hist->GetXaxis()->SetBinLabel (1 + form, m_cuts[form].c_str());
141 }
142
144 } catch (...)
145 {
147 throw;
148 }
149 return StatusCode::SUCCESS;
150 }
151
152
153
155 execute ()
156 {
158
160
162 for (std::size_t form = 0; form != m_cuts.size() && weight != 0; ++ form)
163 {
164 double myweight = 1;
165 if (m_index[form]) switch (m_index[form]->ndim())
166 {
167 case -1:
169 break;
170 case 0:
171 myweight =
m_index[form]->value (0);
172 break;
173 case 1:
175 break;
176 default:
177 RCU_THROW_MSG (
"unknown formula dimension: " + m_cuts[form]);
178 }
179
181 if (m_hist && weight != 0)
182 m_hist->Fill (form);
183 }
184
185 if (weight)
186 m_skim->setFilterPassed ();
187 return StatusCode::SUCCESS;
188 }
189}
#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
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: ...
::StatusCode StatusCode
StatusCode definition for legacy code.
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
size_t m_index
The index of this element within its container. Should be 0 if this object is not within a container.