33{
34 void UnitTestAlg2 ::
35 testInvariant () const
36 {}
37
38
39
40 UnitTestAlg2 ::
41 UnitTestAlg2 (const std::string& name,
42 ISvcLocator* pSvcLocator)
43 : AnaAlgorithm (
name, pSvcLocator),
44 makeOutput (true),
46 m_value (0),
48 m_hasInitialize (false)
49 {
50 declareProperty ("property", m_property, "test property");
51 declareProperty ("string_property", m_string_property, "test string property");
52 declareProperty ("toolHandle", m_toolHandle, "ToolHandle property");
53
55 }
56
57
58
59 ::StatusCode UnitTestAlg2 ::
60 initialize ()
61 {
63
64 getCallbacks()->Fill (CB_INITIALIZE);
65
67
68
69
70 ANA_CHECK (book (TEfficiency (
"efficiency",
"dummy efficiency hist", 50, 0, 50)));
71 (void) hist<TEfficiency> ("efficiency");
72 (void) histeff ("efficiency");
73
74 ANA_CHECK (book (TH1F ((m_name +
"2_2").c_str(),
m_name.c_str(), 50, 0, 50)));
75 ANA_CHECK (book (TH1F (
"file_executes_2",
"file executes", 1, 0, 1)));
76
77 ANA_CHECK (book (TH1F (
"test_property",
"test_property", 1, 0, 1)));
78 hist(
"test_property")->Fill (0.5, m_property);
79
80 wk()->addOutput (
new TH1F (
m_name.c_str(),
m_name.c_str(),
81 50, 0, 50));
82 if (makeOutput)
83 {
84 TFile *
file = wk()->getOutputFile (
"out");
85 m_tree =
new TTree (
"tree2",
"test output");
87 m_tree->Branch (
m_name.c_str(), &m_value, (m_name +
"/I").c_str());
88 }
89 m_hasInitialize = true;
90 return ::StatusCode::SUCCESS;
91 }
92
93
94
95 ::StatusCode UnitTestAlg2 ::
96 execute ()
97 {
99
100 getCallbacks()->Fill (CB_EXECUTE);
101
103
105
106
108 m_branch = wk()->tree()->GetBranch (
m_name.c_str());
109 if (m_branch == 0)
110 {
112 return StatusCode::FAILURE;
113 }
114 m_branch->SetAddress (&m_value);
115
118 m_branch->GetEntry (wk()->treeEntry());
119 hist(m_name)->Fill (m_value);
120 if (makeOutput)
122
123 msg().setLevel (MSG::INFO);
124 if (++ m_calls < 3)
126
127 return ::StatusCode::SUCCESS;
128 }
129
130
131
132 ::StatusCode UnitTestAlg2 ::
133 finalize ()
134 {
136
137 getCallbacks()->Fill (CB_FINALIZE);
138
140 wk()->addOutput (new TH1F ("beta/dir/hist2", "directory test", 10, 0, 10));
141 wk()->addOutputList ("alpha2", new TObjString ("alpha2"));
142 return ::StatusCode::SUCCESS;
143 }
144
145
146
147 TH1 *UnitTestAlg2 ::
148 getCallbacks ()
149 {
150 if (m_callbacks == nullptr)
151 {
152 m_callbacks =
new TH1F (
"callbacks2",
"callbacks", CB_FINALIZE + 1,
153 0, CB_FINALIZE + 1);
154 wk()->addOutput (m_callbacks);
155 }
156 return m_callbacks;
157 }
158}
#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.
ID3PD * m_tree
Pointer to the ID3PD object used.
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)