@@ -110,8 +110,6 @@ void testUnfold7b()
110110
111111 TUnfoldBinning * fineBinningRoot ,* coarseBinningRoot ;
112112
113- outputFile -> cd ();
114-
115113 // read binning schemes in XML format
116114
117115 TDOMParser parser ;
@@ -164,6 +162,10 @@ void testUnfold7b()
164162 TH1 * histDataBgrC = coarseBinning -> CreateHistogram ("histDataBgrC" );
165163 TH1 * histDataGen = coarseBinning -> CreateHistogram ("histDataGen" );
166164
165+ for (auto histo : {histDataRecF , histDataRecC , histDataBgrF , histDataBgrC , histDataGen }) {
166+ histo -> SetDirectory (outputFile );
167+ }
168+
167169 TFile * dataFile = new TFile ("testUnfold7_data.root" );
168170 TTree * dataTree = (TTree * ) dataFile -> Get ("data" );
169171
@@ -213,15 +215,16 @@ void testUnfold7b()
213215 // Step 4: book and fill histogram of migrations
214216 // it receives events from both signal MC and background MC
215217
216- outputFile -> cd ();
217-
218218 TH2 * histMcsigGenRecF = TUnfoldBinning ::CreateHistogramOfMigrations
219219 (coarseBinning ,fineBinning ,"histMcsigGenRecF" );
220220 TH2 * histMcsigGenRecC = TUnfoldBinning ::CreateHistogramOfMigrations
221221 (coarseBinning ,coarseBinning ,"histMcsigGenRecC" );
222222 TH1 * histMcsigRecF = fineBinning -> CreateHistogram ("histMcsigRecF" );
223223 TH1 * histMcsigRecC = coarseBinning -> CreateHistogram ("histMcsigRecC" );
224224 TH1 * histMcsigGen = coarseBinning -> CreateHistogram ("histMcsigGen" );
225+ for (auto histo : std ::initializer_list < TH1 * > {histMcsigGenRecF , histMcsigGenRecC , histMcsigRecF , histMcsigRecC , histMcsigGen }) {
226+ histo -> SetDirectory (outputFile );
227+ }
225228
226229 TFile * signalFile = new TFile ("testUnfold7_signal.root" );
227230 TTree * signalTree = (TTree * ) signalFile -> Get ("signal" );
@@ -259,10 +262,10 @@ void testUnfold7b()
259262 delete signalTree ;
260263 delete signalFile ;
261264
262- outputFile -> cd ();
263-
264265 TH1 * histMcbgrRecF = fineBinning -> CreateHistogram ("histMcbgrRecF" );
265266 TH1 * histMcbgrRecC = coarseBinning -> CreateHistogram ("histMcbgrRecC" );
267+ histMcbgrRecF -> SetDirectory (outputFile );
268+ histMcbgrRecC -> SetDirectory (outputFile );
266269
267270 TFile * bgrFile = new TFile ("testUnfold7_background.root" );
268271 TTree * bgrTree = (TTree * ) bgrFile -> Get ("background" );
0 commit comments