40{
41 void UnitTestAlg1 ::
42 testInvariant () const
43 {
45 }
46
47
48
49 UnitTestAlg1 ::
50 UnitTestAlg1 (const std::string& branchName)
51 : makeOutput (true),
53 m_branch (0),
54 m_value (0),
56 m_hasInitialize (false),
57 m_hasHistInitialize (false)
58 {
60 }
61
62
63
65 setupJob (Job& job)
66 {
68
69 if (makeOutput)
70 {
71 OutputStream
out (
"out");
73 }
74 {
75 OutputStream
out (
"out_empty");
77 }
78 return StatusCode::SUCCESS;
79 }
80
81
82
84 changeInput (bool firstFile)
85 {
87
88 if (firstFile)
89 getCallbacks()->Fill (CB_CHANGE_INPUT_FIRST);
90 else
91 getCallbacks()->Fill (CB_CHANGE_INPUT_OTHER);
92
94 m_branch = wk()->tree()->GetBranch (
m_name.c_str());
95 if (m_branch == 0)
97 m_branch->SetAddress (&m_value);
99 m_fileName = wk()->inputFile()->GetName();
100 return StatusCode::SUCCESS;
101 }
102
103
104
106 histInitialize ()
107 {
109
110 getCallbacks()->Fill (CB_HIST_INITIALIZE);
111
113
114 book (TH1F ((m_name +
"2").c_str(),
m_name.c_str(), 50, 0, 50));
115 book (TH1F (
"file_executes",
"file executes", 1, 0, 1));
116 m_hasHistInitialize = true;
117 return StatusCode::SUCCESS;
118 }
119
120
121
123 initialize ()
124 {
126
127 getCallbacks()->Fill (CB_INITIALIZE);
128
131
134
135
136
137
138
139
140
141 wk()->addOutput (
new TH1F (
m_name.c_str(),
m_name.c_str(),
142 50, 0, 50));
143 if (makeOutput)
144 {
145 TFile *
file = wk()->getOutputFile (
"out");
146 m_tree =
new TTree (
"tree",
"test output");
148 m_tree->Branch (
m_name.c_str(), &m_value, (m_name +
"/I").c_str());
149 }
150 m_hasInitialize = true;
151 return StatusCode::SUCCESS;
152 }
153
154
155
157 fileExecute ()
158 {
160
161 getCallbacks()->Fill (CB_FILE_EXECUTE);
162
164 hist (
"file_executes")->Fill (0);
165 return StatusCode::SUCCESS;
166 }
167
168
169
171 execute ()
172 {
174
175 getCallbacks()->Fill (CB_EXECUTE);
176
178
179 m_branch->GetEntry (wk()->treeEntry());
180 hist(m_name)->Fill (m_value);
181 if (makeOutput)
183
184 setMsgLevel (MSG::INFO);
185 if (++ m_calls < 3)
187
188 return StatusCode::SUCCESS;
189 }
190
191
192
194 finalize ()
195 {
197
198 getCallbacks()->Fill (CB_FINALIZE);
199
201 wk()->addOutput (new TH1F ("beta/dir/hist", "directory test", 10, 0, 10));
202 wk()->addOutputList ("alpha", new TObjString ("alpha"));
203 return StatusCode::SUCCESS;
204 }
205
206
207
209 histFinalize ()
210 {
212
213 getCallbacks()->Fill (CB_HIST_FINALIZE);
214
216 wk()->addOutput (new TH1F ("beta/dir/hist", "directory test", 10, 0, 10));
217 wk()->addOutputList ("alpha", new TObjString ("alpha"));
218 return StatusCode::SUCCESS;
219 }
220
221
222
223 TH1 *UnitTestAlg1 ::
224 getCallbacks ()
225 {
226 if (m_callbacks == nullptr)
227 {
228 m_callbacks =
new TH1F (
"callbacks",
"callbacks", CB_HIST_FINALIZE + 1,
229 0, CB_HIST_FINALIZE + 1);
230 wk()->addOutput (m_callbacks);
231 }
232 return m_callbacks;
233 }
234}
#define RCU_CHANGE_INVARIANT(x)
#define RCU_NEW_INVARIANT(x)
#define RCU_ASSERT_SOFT(x)
#define RCU_THROW_MSG(message)
TGraphErrors * GetEntries(TH2F *histo)
std::string m_name
The primary name part of this expression.
virtual StatusCode book()
Declare tuple variables.
ID3PD * m_tree
Pointer to the ID3PD object used.
::StatusCode StatusCode
StatusCode definition for legacy code.
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)