33{
34 void UnitTestAlg1 ::
35 testInvariant () const
36 {
38 }
39
40
41
42 UnitTestAlg1 ::
43 UnitTestAlg1 (const std::string& branchName)
44 : makeOutput (true),
46 m_branch (0),
47 m_value (0),
49 m_hasInitialize (false),
50 m_hasHistInitialize (false)
51 {
53 }
54
55
56
58 setupJob (Job& job)
59 {
61
62 if (makeOutput)
63 {
64 OutputStream
out (
"out");
66 }
67 {
68 OutputStream
out (
"out_empty");
70 }
71 return StatusCode::SUCCESS;
72 }
73
74
75
77 changeInput (bool firstFile)
78 {
80
81 if (firstFile)
82 getCallbacks()->Fill (CB_CHANGE_INPUT_FIRST);
83 else
84 getCallbacks()->Fill (CB_CHANGE_INPUT_OTHER);
85
87 m_branch = wk()->tree()->GetBranch (
m_name.c_str());
88 if (m_branch == 0)
90 m_branch->SetAddress (&m_value);
92 m_fileName = wk()->inputFile()->GetName();
93 return StatusCode::SUCCESS;
94 }
95
96
97
99 histInitialize ()
100 {
102
103 getCallbacks()->Fill (CB_HIST_INITIALIZE);
104
106
107 book (TH1F ((m_name +
"2").c_str(),
m_name.c_str(), 50, 0, 50));
108 book (TH1F (
"file_executes",
"file executes", 1, 0, 1));
109 m_hasHistInitialize = true;
110 return StatusCode::SUCCESS;
111 }
112
113
114
116 initialize ()
117 {
119
120 getCallbacks()->Fill (CB_INITIALIZE);
121
124
127
128
129
130
131
132
133
134 wk()->addOutput (
new TH1F (
m_name.c_str(),
m_name.c_str(),
135 50, 0, 50));
136 if (makeOutput)
137 {
138 TFile *
file = wk()->getOutputFile (
"out");
139 m_tree =
new TTree (
"tree",
"test output");
141 m_tree->Branch (
m_name.c_str(), &m_value, (m_name +
"/I").c_str());
142 }
143 m_hasInitialize = true;
144 return StatusCode::SUCCESS;
145 }
146
147
148
150 fileExecute ()
151 {
153
154 getCallbacks()->Fill (CB_FILE_EXECUTE);
155
157 hist (
"file_executes")->Fill (0);
158 return StatusCode::SUCCESS;
159 }
160
161
162
164 execute ()
165 {
167
168 getCallbacks()->Fill (CB_EXECUTE);
169
171
172 m_branch->GetEntry (wk()->treeEntry());
173 hist(m_name)->Fill (m_value);
174 if (makeOutput)
176
177 setMsgLevel (MSG::INFO);
178 if (++ m_calls < 3)
180
181 return StatusCode::SUCCESS;
182 }
183
184
185
187 finalize ()
188 {
190
191 getCallbacks()->Fill (CB_FINALIZE);
192
194 wk()->addOutput (new TH1F ("beta/dir/hist", "directory test", 10, 0, 10));
195 wk()->addOutputList ("alpha", new TObjString ("alpha"));
196 return StatusCode::SUCCESS;
197 }
198
199
200
202 histFinalize ()
203 {
205
206 getCallbacks()->Fill (CB_HIST_FINALIZE);
207
209 wk()->addOutput (new TH1F ("beta/dir/hist", "directory test", 10, 0, 10));
210 wk()->addOutputList ("alpha", new TObjString ("alpha"));
211 return StatusCode::SUCCESS;
212 }
213
214
215
216 TH1 *UnitTestAlg1 ::
217 getCallbacks ()
218 {
219 if (m_callbacks == nullptr)
220 {
221 m_callbacks =
new TH1F (
"callbacks",
"callbacks", CB_HIST_FINALIZE + 1,
222 0, CB_HIST_FINALIZE + 1);
223 wk()->addOutput (m_callbacks);
224 }
225 return m_callbacks;
226 }
227}
#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)