32{
33 void UnitTestAlg ::
34 testInvariant () const
35 {}
36
37
38
39 UnitTestAlg ::
40 UnitTestAlg (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 return StatusCode::SUCCESS;
65 }
66
67
68
70 changeInput (bool firstFile)
71 {
73
75 m_branch = wk()->tree()->GetBranch (
m_name.c_str());
76 if (m_branch == 0)
77 {
79 return StatusCode::FAILURE;
80 }
81 m_branch->SetAddress (&m_value);
83 m_fileName = wk()->inputFile()->GetName();
84 return StatusCode::SUCCESS;
85 }
86
87
88
90 histInitialize ()
91 {
93
95
96 book (TH1F ((m_name +
"2").c_str(),
m_name.c_str(), 50, 0, 50));
97 book (TH1F (
"file_executes",
"file executes", 1, 0, 1));
98 m_hasHistInitialize = true;
99 return StatusCode::SUCCESS;
100 }
101
102
103
105 initialize ()
106 {
108
111
114
115 if (wk()->metaData()->castDouble ("jobOpt") != 42)
116 {
118 return StatusCode::FAILURE;
119 }
120
121 if (wk()->metaData()->castString ("mymeta") != "test")
122 {
124 return StatusCode::FAILURE;
125 }
126
127 wk()->addOutput (
new TH1F (
m_name.c_str(),
m_name.c_str(),
128 50, 0, 50));
129 if (makeOutput)
130 {
131 TFile *
file = wk()->getOutputFile (
"out");
132 m_tree =
new TTree (
"tree",
"test output");
134 m_tree->Branch (
m_name.c_str(), &m_value, (m_name +
"/I").c_str());
135 }
136 m_hasInitialize = true;
137 return StatusCode::SUCCESS;
138 }
139
140
141
143 fileExecute ()
144 {
146
148 hist (
"file_executes")->Fill (0);
149 return StatusCode::SUCCESS;
150 }
151
152
153
155 execute ()
156 {
158
160
161 m_branch->GetEntry (wk()->treeEntry());
162 hist(m_name)->Fill (m_value);
163 if (makeOutput)
165
166 setMsgLevel (MSG::INFO);
167 if (++ m_calls < 3)
169
170 return StatusCode::SUCCESS;
171 }
172
173
174
176 finalize ()
177 {
180 wk()->addOutput (new TH1F ("beta/dir/hist", "directory test", 10, 0, 10));
181 wk()->addOutputList ("alpha", new TObjString ("alpha"));
182 return StatusCode::SUCCESS;
183 }
184
185
186
188 histFinalize ()
189 {
192 wk()->addOutput (new TH1F ("beta/dir/hist", "directory test", 10, 0, 10));
193 wk()->addOutputList ("alpha", new TObjString ("alpha"));
194 return StatusCode::SUCCESS;
195 }
196}
#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.