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