32{
33 void UnitTestAlg1 ::
34 testInvariant () const
35 {}
36
37
38
39 UnitTestAlg1 ::
40 UnitTestAlg1 (const std::string& branchName)
41 : makeOutput (true),
43 m_branch (0),
44 m_value (0),
46 m_hasInitialize (false),
47 m_hasHistInitialize (false)
48 {
50 }
51
52
53
55 setupJob (Job& job)
56 {
58
59 if (makeOutput)
60 {
61 OutputStream
out (
"out");
63 }
64 {
65 OutputStream
out (
"out_empty");
67 }
68 return StatusCode::SUCCESS;
69 }
70
71
72
74 changeInput (bool firstFile)
75 {
77
78 if (firstFile)
79 getCallbacks()->Fill (CB_CHANGE_INPUT_FIRST);
80 else
81 getCallbacks()->Fill (CB_CHANGE_INPUT_OTHER);
82
84 m_branch = wk()->tree()->GetBranch (
m_name.c_str());
85 if (m_branch == 0)
86 {
88 return StatusCode::FAILURE;
89 }
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 wk()->addOutput (
new TH1F (
m_name.c_str(),
m_name.c_str(),
129 50, 0, 50));
130 if (makeOutput)
131 {
132 TFile *
file = wk()->getOutputFile (
"out");
133 m_tree =
new TTree (
"tree",
"test output");
135 m_tree->Branch (
m_name.c_str(), &m_value, (m_name +
"/I").c_str());
136 }
137 m_hasInitialize = true;
138 return StatusCode::SUCCESS;
139 }
140
141
142
144 fileExecute ()
145 {
147
148 getCallbacks()->Fill (CB_FILE_EXECUTE);
149
151 hist (
"file_executes")->Fill (0);
152 return StatusCode::SUCCESS;
153 }
154
155
156
158 execute ()
159 {
161
162 getCallbacks()->Fill (CB_EXECUTE);
163
165
166 m_branch->GetEntry (wk()->treeEntry());
167 hist(m_name)->Fill (m_value);
168 if (makeOutput)
170
171 setMsgLevel (MSG::INFO);
172 if (++ m_calls < 3)
174
175 return StatusCode::SUCCESS;
176 }
177
178
179
181 finalize ()
182 {
184
185 getCallbacks()->Fill (CB_FINALIZE);
186
188 wk()->addOutput (new TH1F ("beta/dir/hist", "directory test", 10, 0, 10));
189 wk()->addOutputList ("alpha", new TObjString ("alpha"));
190 return StatusCode::SUCCESS;
191 }
192
193
194
196 histFinalize ()
197 {
199
200 getCallbacks()->Fill (CB_HIST_FINALIZE);
201
203 wk()->addOutput (new TH1F ("beta/dir/hist", "directory test", 10, 0, 10));
204 wk()->addOutputList ("alpha", new TObjString ("alpha"));
205 return StatusCode::SUCCESS;
206 }
207
208
209
210 TH1 *UnitTestAlg1 ::
211 getCallbacks ()
212 {
213 if (m_callbacks == nullptr)
214 {
215 m_callbacks =
new TH1F (
"callbacks",
"callbacks", CB_HIST_FINALIZE + 1,
216 0, CB_HIST_FINALIZE + 1);
217 wk()->addOutput (m_callbacks);
218 }
219 return m_callbacks;
220 }
221}
#define RCU_CHANGE_INVARIANT(x)
#define RCU_NEW_INVARIANT(x)
#define RCU_ASSERT_SOFT(x)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
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)