Skip to content

Commit 3fea856

Browse files
Dmitri Peresunkoshahor02
authored andcommitted
Fix writing calibDigits tree
1 parent 8302be8 commit 3fea856

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

Detectors/PHOS/calib/src/PHOSEnergyCalibDevice.cxx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,19 @@ void PHOSEnergyCalibDevice::fillOutputTree()
153153
mHistoFileName = mOutputDir + fmt::format("PHOS_CalibHistos_{}.root", mRunNumber);
154154
mHistoFileOut = std::make_unique<TFile>(mHistoFileName.c_str(), "recreate");
155155
mHistoFileMetaData = std::make_unique<o2::dataformats::FileMetaData>();
156+
mFileOut->cd();
156157
}
157158
// else Tree will be memory resident
158-
mTreeOut = std::make_unique<TTree>("phosCalibDig", "O2 PHOS calib tree");
159+
if (!mTreeOut) {
160+
LOG(info) << "Creating new tree for PHOS calib digits";
161+
mTreeOut = std::make_unique<TTree>("phosCalibDig", "O2 PHOS calib tree");
162+
}
159163
}
160164
auto* br = mTreeOut->GetBranch("PHOSCalib");
161-
auto* pptr = &mOutputDigits;
162-
if (br) {
163-
LOG(info) << " Using existing branch";
164-
br->SetAddress(&pptr);
165-
} else {
166-
LOG(info) << " Create new branch";
167-
br = mTreeOut->Branch("PHOSCalib", &pptr);
165+
if (!br) {
166+
br = mTreeOut->Branch("PHOSCalib", &mOutputDigits);
168167
}
169-
mTreeOut->Fill();
170-
br->ResetAddress();
168+
int abits = mTreeOut->Fill();
171169
}
172170

173171
void PHOSEnergyCalibDevice::writeOutFile()
@@ -180,7 +178,7 @@ void PHOSEnergyCalibDevice::writeOutFile()
180178
return;
181179
}
182180
LOG(info) << "Writing calibration digits";
183-
mFileOut->cd();
181+
184182
int nbits = mTreeOut->Write();
185183
LOG(info) << "Wrote " << nbits << " bits";
186184
mTreeOut.reset();

0 commit comments

Comments
 (0)