DUNE / ND_CAFMaker

Code for making CAFs from ND inputs (whether 2x2+MINERvA prototype or full ND simulation)
Apache License 2.0
1 stars 11 forks source link

Total POT not stored properly in flat cafs #62

Closed mcasales closed 5 months ago

mcasales commented 6 months ago

Reading pot of file frommeta.pot works well for cafs, but not for flatcafs. They still have the correct info in rec.beam.pulsepot, but it seems the meta tree is filled incorrectly/empty. See output from opening flatcaf meta tree:

root -l /exp/dune/data/users/noeroy/prod/MiniRun5_1E19_RHC/MiniRun5_1E19_RHC.caf.beta1/CAF.flat/0000000/MiniRun5_1E19_RHC.caf.0000974.CAF.flat.root
root [5] meta->Scan("pot")
************************
*    Row   *       pot *
************************
Error in <TFile::ReadBuffer>: error reading all requested bytes from file /exp/dune/data/users/noeroy/prod/MiniRun5_1E19_RHC/MiniRun5_1E19_RHC.caf.beta1/CAF.flat/0000000/MiniRun5_1E19_RHC.caf.0000974.CAF.flat.root, got 0 of 307
Error in <TFile::ReadBuffer>: error reading all requested bytes from file /exp/dune/data/users/noeroy/prod/MiniRun5_1E19_RHC/MiniRun5_1E19_RHC.caf.beta1/CAF.flat/0000000/MiniRun5_1E19_RHC.caf.0000974.CAF.flat.root, got 0 of 78
Error in <TBranch::GetBasket>: File: /exp/dune/data/users/noeroy/prod/MiniRun5_1E19_RHC/MiniRun5_1E19_RHC.caf.beta1/CAF.flat/0000000/MiniRun5_1E19_RHC.caf.0000974.CAF.flat.root at byte:0, branch:pot, entry:0, badread=1, nerrors=1, basketnumber=0
*        0 *         0 *
************************

and output from meta tree in cafs:

root [1] meta->Scan("pot")
************************
*    Row   *       pot *
************************
*        0 *     1e+16 *
************************
noeroy commented 5 months ago

test.txt test_bad.txt

It seems to be an issue with ROOT when we want to write the same tree with two opened files. I've added two minimal example scripts, one with the current way we fill the CAFs (test_bad.cpp) and one with the fix proposed in the branch iss62_flat_tree_fix

After the fix we get for the FLAT CAF:

root [0]
Attaching file test_cafs3.flat.root as _file0...
(TFile *) 0x29dd0e0
root [1] meta->Scan()
************************************************************
*    Row   *   pot.pot *   run.run * subrun.su * version.v *
************************************************************
*        0 * 1.015e+16 *         1 *         0 *         5 *
************************************************************

And for the CAF:

Attaching file test_cafs3.root as _file0...
(TFile *) 0x3a43120
root [1] meta->Scan()
************************************************************
*    Row   *   pot.pot *   run.run * subrun.su * version.v *
************************************************************
*        0 * 1.015e+16 *         1 *         0 *         5 *
************************************************************