41{
42 void UnitTestAlg2 ::
43 testInvariant () const
44 {
46 }
47
48
49
50 UnitTestAlg2 ::
51 UnitTestAlg2 (const std::string& name,
52 ISvcLocator* pSvcLocator)
53 : AnaAlgorithm (
name, pSvcLocator),
54 makeOutput (true),
55 m_name ("el_n"),
56 m_value (0),
57 m_tree (0),
58 m_hasInitialize (false)
59 {
60 declareProperty ("property", m_property, "test property");
61 declareProperty ("string_property", m_string_property, "test string property");
62 declareProperty ("toolHandle", m_toolHandle, "ToolHandle property");
63
65 }
66
67
68
69 ::StatusCode UnitTestAlg2 ::
70 initialize ()
71 {
73
74 getCallbacks()->Fill (CB_INITIALIZE);
75
77
78
79
80 ANA_CHECK (book (TEfficiency (
"efficiency",
"dummy efficiency hist", 50, 0, 50)));
81 (void) hist<TEfficiency> ("efficiency");
82 (void) histeff ("efficiency");
83
84 ANA_CHECK (book (TH1F ((m_name +
"2_2").c_str(), m_name.c_str(), 50, 0, 50)));
85 ANA_CHECK (book (TH1F (
"file_executes_2",
"file executes", 1, 0, 1)));
86
87 ANA_CHECK (book (TH1F (
"test_property",
"test_property", 1, 0, 1)));
88 hist(
"test_property")->Fill (0.5, m_property);
89
90
91
92
93
94
95
96 wk()->addOutput (new TH1F (m_name.c_str(), m_name.c_str(),
97 50, 0, 50));
98 if (makeOutput)
99 {
100 TFile *
file = wk()->getOutputFile (
"out");
101 m_tree = new TTree ("tree2", "test output");
102 m_tree->SetDirectory (
file);
103 m_tree->Branch (m_name.c_str(), &m_value, (m_name + "/I").c_str());
104 }
105 m_hasInitialize = true;
106 return ::StatusCode::SUCCESS;
107 }
108
109
110
111 ::StatusCode UnitTestAlg2 ::
112 execute ()
113 {
115
116 getCallbacks()->Fill (CB_EXECUTE);
117
119
121
122
124 m_branch = wk()->tree()->GetBranch (m_name.c_str());
125 if (m_branch == 0)
127 m_branch->SetAddress (&m_value);
128
131 m_branch->GetEntry (wk()->treeEntry());
132 hist(m_name)->Fill (m_value);
133 if (makeOutput)
134 m_tree->Fill ();
135
136 msg().setLevel (MSG::INFO);
137 if (++ m_calls < 3)
139
140 return ::StatusCode::SUCCESS;
141 }
142
143
144
145 ::StatusCode UnitTestAlg2 ::
146 finalize ()
147 {
149
150 getCallbacks()->Fill (CB_FINALIZE);
151
153 wk()->addOutput (new TH1F ("beta/dir/hist2", "directory test", 10, 0, 10));
154 wk()->addOutputList ("alpha2", new TObjString ("alpha2"));
155 return ::StatusCode::SUCCESS;
156 }
157
158
159
160 TH1 *UnitTestAlg2 ::
161 getCallbacks ()
162 {
163 if (m_callbacks == nullptr)
164 {
165 m_callbacks =
new TH1F (
"callbacks2",
"callbacks", CB_FINALIZE + 1,
166 0, CB_FINALIZE + 1);
167 wk()->addOutput (m_callbacks);
168 }
169 return m_callbacks;
170 }
171}
#define RCU_CHANGE_INVARIANT(x)
#define RCU_NEW_INVARIANT(x)
#define RCU_ASSERT_SOFT(x)
#define RCU_THROW_MSG(message)
TGraphErrors * GetEntries(TH2F *histo)
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)