28{
29 void AlgSelect ::
30 testInvariant () const
31 {
33 for (std::size_t form = 0, end = m_cuts.size(); form != end; ++ form)
35 if (m_skim != 0)
36 {
40 }
41 if (m_hist != 0)
42 {
43 RCU_INVARIANT (m_cuts.size() == std::size_t (m_hist->GetNbinsX()));
44 }
45 }
46
47
48
49 AlgSelect ::
50 AlgSelect ()
51 : m_outputStream ("output"),
52 m_hist (0), m_formSvc (0), m_skim (0)
53 {
55 }
56
57
58
59 AlgSelect ::
60 AlgSelect (const std::string& val_outputStream, const std::string& cut)
61 : m_outputStream (val_outputStream),
62 m_hist (0), m_formSvc (0), m_skim (0)
63 {
65
67 m_cuts.push_back (cut);
68
70 }
71
72
73
74 const std::string& AlgSelect ::
75 outputStream () const
76 {
78 return m_outputStream;
79 }
80
81
82
83 const std::string& AlgSelect ::
84 histName () const
85 {
87 return m_histName;
88 }
89
90
91
92 void AlgSelect ::
93 histName (const std::string& val_histName)
94 {
96 m_histName = val_histName;
97 }
98
99
100
101 void AlgSelect ::
102 addCut (const std::string& cut)
103 {
106 m_cuts.push_back (cut);
107 }
108
109
110
112 setupJob (Job& job)
113 {
116 return StatusCode::SUCCESS;
117 }
118
119
120
122 initialize ()
123 {
125
126 try
127 {
129 if (!m_cuts.empty() && !m_histName.empty())
130 {
131 m_hist = new TH1D (m_histName.c_str(), 0, m_cuts.size(), 0, m_cuts.size());
132 wk()->addOutput (m_hist);
133 }
134 for (std::size_t form = 0, end = m_cuts.size(); form != end; ++ form)
135 {
136 m_index.push_back (m_formSvc->addForm (m_cuts[form]));
137 m_hist->GetXaxis()->SetBinLabel (1 + form, m_cuts[form].c_str());
138 }
139
141 } catch (...)
142 {
144 throw;
145 }
146 return StatusCode::SUCCESS;
147 }
148
149
150
152 execute ()
153 {
155
157
159 for (std::size_t form = 0; form != m_cuts.size() && weight != 0; ++ form)
160 {
161 double myweight = 1;
162 if (m_index[form]) switch (m_index[form]->ndim())
163 {
164 case -1:
166 return StatusCode::FAILURE;
167 case 0:
168 myweight =
m_index[form]->value (0);
169 break;
170 case 1:
172 return StatusCode::FAILURE;
173 default:
174 ATH_MSG_ERROR (
"unknown formula dimension: " << m_cuts[form]);
175 return StatusCode::FAILURE;
176 }
177
179 if (m_hist && weight != 0)
180 m_hist->Fill (form);
181 }
182
183 if (weight)
184 m_skim->setFilterPassed ();
185 return StatusCode::SUCCESS;
186 }
187}
#define RCU_CHANGE_INVARIANT(x)
#define RCU_NEW_INVARIANT(x)
#define RCU_REQUIRE_SOFT(x)
#define RCU_READ_INVARIANT(x)
#define ATH_MSG_ERROR(x,...)
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.