Conversation
|
This will take me some time to review. I can look at this after Wednesday. |
fhagemann
left a comment
There was a problem hiding this comment.
Nice PR and thanks for all the work :)
In this review, I only looked at the code, without running it.
Most of my comments are minor / code-style questions.
The biggest questions would be:
- would we still be able to read "old" ROA files with
UF doublesidedstrip adc_tac_flagsor will this PR be breaking in the sense that we MUST addUHas second token:UF UC doublesidedstrip adc-tac-flags
This looks like it might allow to use ROA for simulation files including both the germanium strip detectors and the BGO shields!
I will try playing a bit around with this using simulated data files, when reading/parsing ROA files, and will let you know how that goes in my final review! But this looks like it might close #66 and be a more thorough fix than what #156 was!
| UF UH doublesidedstrip adc-tac-flags | ||
| UF UC voxel3d adc-flags |
There was a problem hiding this comment.
I see: my understanding of this is that the UF lines now have an additional token after UF denoting which two letters are used in the rest of the file to denote a hit in the given detector type.
My question would be:
- do old ROA file formats still work (if the first line was
UF doublesidedstrip adc-tac-flags, would it default toUH, or will we not be able to read "older" ROA files after merging this PR)?
Or in other words: If we do not have any crystal data in this file, do we need this update?
| for (unsigned int d = 0; d < CrystalData.size(); ++d) { | ||
| if (d != 0) CrystalType += "-"; | ||
| CrystalType += CrystalData[d]; | ||
| } |
There was a problem hiding this comment.
Just curious: what made you transition from underscores _ to dashes - to separate the m_Type names in the ROA UF line?
| return false; | ||
| } | ||
| if (CrystalType != "") { | ||
| m_RoaFileFormat.AddReadOutUnit("UC", "voxel3d", CrystalType); |
There was a problem hiding this comment.
Does this also need a if (m_RoaFileFormat.AddReadOutUnit("UC", "voxel3d", CrystalType) == false) + verbosity output? Will this ever NOT work?
| new MXmlNode(Node, "RoaWithTACs", m_RoaWithTACs); | ||
| new MXmlNode(Node, "RoaWithEnergies", m_RoaWithEnergies); | ||
| new MXmlNode(Node, "RoaWithTimings", m_RoaWithTimings); | ||
| new MXmlNode(Node, "RoaWithTemperatures", m_RoaWithTemperatures); |
There was a problem hiding this comment.
This is added back in on purpose (relevant for the shields)?
There was a problem hiding this comment.
I checked this file locally:
it also has the UF UC voxel3d adc-flags line at the top (like the 542-1 tests), but not a single line later that starts with UC (which makes sense because we did not take data with shields yet).
Once we have HDF5 files with both StripHits and CrystalHits, we might want to update/add the unit tests.
|
|
||
| S<<"UH " | ||
| <<m_ReadOutElement->GetDetectorID()<<" "; | ||
| S<<"UC "<<m_ReadOutElement->ToParsableString()<<" "; |
There was a problem hiding this comment.
If I understand correctly, using ToParsableString will now print
UC DetectorID CrystalID VoxelXID VoxelYID VoxelZID .....
instead of just
UH DetectorID .....
| @@ -476,10 +477,8 @@ bool MReadOutAssembly::Parse(MString& Line, int Version) | |||
| return false; | |||
| } | |||
| } | |||
| if (Line.BeginsWith("BD")) { | |||
| // Mark the event as filtered out | |||
| m_FilteredOut = true; | |||
| return true; | |||
| if (Line.BeginsWith("BD") || Line.BeginsWith("QA") || Line.BeginsWith("PQ")) { | |||
| return ParseBDFlags(Line); | |||
| } | |||
|
|
|||
| // Everything else goes to the tolerant base parser, which also consumes unrecognized lines and returns true | |||
| @@ -547,9 +546,9 @@ bool MReadOutAssembly::GetNextFromDatFile(MFile& F) | |||
| } else { | |||
| delete sh; | |||
| } | |||
| } else if (Line.BeginsWith("BD")) { | |||
| } else if (Line.BeginsWith("BD") || Line.BeginsWith("QA") || Line.BeginsWith("PQ")) { | |||
| EventRead = true; | |||
| SetFilteredOut(true); | |||
| ParseBDFlags(Line); | |||
| } | |||
There was a problem hiding this comment.
Ignore if this should become part of future clean-up, but should this be Line.BeginsWith(...) == true instead of just Line.BeginsWith(...).
Not sure if there is a coding convention for evaluating boolean values in if-statements for nuclearizer.
| // The setters ignore an empty text | ||
| if (Texts.empty() == true) Texts.push_back(""); | ||
|
|
||
| if (Line.BeginsWith("BD")) { |
There was a problem hiding this comment.
| if (Line.BeginsWith("BD")) { | |
| if (Line.BeginsWith("BD") == true) { |
?
| return true; | ||
| } | ||
|
|
||
| if (Line.BeginsWith("QA")) { |
There was a problem hiding this comment.
| if (Line.BeginsWith("QA")) { | |
| if (Line.BeginsWith("QA") == true) { |
| return true; | ||
| } | ||
|
|
||
| return false; |
There was a problem hiding this comment.
You're checking with Line.BeginsWith(...) in Parse already, but should we add a warning/error message here, just to be sure, in case it should be used somewhere else where we don't have that check implemented?
| return false; | |
| if (g_Verbosity >= c_Error) cout<<... ? | |
| return false; |
I created an ROA file based on a cosima simulation that ran through the DEE + energy calibration + TAC calibration, this in an example event I get: (so also the crystal ID and voxelX/Y/Z, that right now always seems to be |
| } else if (Flag == "No hits") { | ||
| // Written by StreamRoa for events without hits, nothing to set |
There was a problem hiding this comment.
Not sure if this is relevant, but I'm losing all events with BD No hits when running my own ROARoundTrip (or it can also be that I'm doing something wrong and this is to be blamed on my settings):
- I start with an ROA file (created from cosima + DEE, saved to ROA) which contains:
SE ID 16557 TI 3778504.201794552 BD No hits PQ SE ID 16558 TI 3778761.823754169 BD No hits PQ - I run
nuclearizeronly reading the ROA file and writing the results into a new ROA file. - Those events (
ID 16557andID 16558) do not appear in this new ROA file.
| const MString Input = Header + | ||
| "SE\nID 1\nTI 1.500000000\n" | ||
| "UH 0 41 l 4053 10452 59.5 12.25 4 1;2\n" | ||
| "UH 0 49 h 1780 10251 33.25 11.5 0 -\n" | ||
| "UC BGO1 2 0 1 3 812 511.5 0 3\n" | ||
| "SE\nID 2\nTI 2.250000000\n" | ||
| "UC BGO2 0 1 1 1 900 600.25 0 -\n" | ||
| "EN\n"; | ||
| // The writer adds a blank line before the header, a PQ line to each event, and a blank line at the end | ||
| const MString Expected = "\n" + Header + | ||
| "SE\nID 1\nTI 1.500000000\n" | ||
| "UH 0 41 l 4053 10452 59.5 12.25 4 1;2\n" | ||
| "UH 0 49 h 1780 10251 33.25 11.5 0 -\n" | ||
| "UC BGO1 2 0 1 3 812 511.5 0 3\n" | ||
| "PQ\n" | ||
| "SE\nID 2\nTI 2.250000000\n" | ||
| "UC BGO2 0 1 1 1 900 600.25 0 -\n" | ||
| "PQ\n" | ||
| "EN\n\n"; |
There was a problem hiding this comment.
I can reproduce losing events with BD No hits (plus their event IDs and TI values in the unit tests).
I can add a BD No hits event to the Input and I do not need to modify the Expected for the tests to still pass:
| const MString Input = Header + | |
| "SE\nID 1\nTI 1.500000000\n" | |
| "UH 0 41 l 4053 10452 59.5 12.25 4 1;2\n" | |
| "UH 0 49 h 1780 10251 33.25 11.5 0 -\n" | |
| "UC BGO1 2 0 1 3 812 511.5 0 3\n" | |
| "SE\nID 2\nTI 2.250000000\n" | |
| "UC BGO2 0 1 1 1 900 600.25 0 -\n" | |
| "EN\n"; | |
| // The writer adds a blank line before the header, a PQ line to each event, and a blank line at the end | |
| const MString Expected = "\n" + Header + | |
| "SE\nID 1\nTI 1.500000000\n" | |
| "UH 0 41 l 4053 10452 59.5 12.25 4 1;2\n" | |
| "UH 0 49 h 1780 10251 33.25 11.5 0 -\n" | |
| "UC BGO1 2 0 1 3 812 511.5 0 3\n" | |
| "PQ\n" | |
| "SE\nID 2\nTI 2.250000000\n" | |
| "UC BGO2 0 1 1 1 900 600.25 0 -\n" | |
| "PQ\n" | |
| "EN\n\n"; | |
| const MString Input = Header + | |
| "SE\nID 1\nTI 1.500000000\n" | |
| "UH 0 41 l 4053 10452 59.5 12.25 4 1;2\n" | |
| "UH 0 49 h 1780 10251 33.25 11.5 0 -\n" | |
| "UC BGO1 2 0 1 3 812 511.5 0 3\n" | |
| "SE\nID 2\nTI 2.250000000\n" | |
| "UC BGO2 0 1 1 1 900 600.25 0 -\n" | |
| "SE\nID 3\n TI 4.000000000\n" // added this line | |
| "BD No hits\n" // and this line | |
| "EN\n"; | |
| // The writer adds a blank line before the header, a PQ line to each event, and a blank line at the end | |
| const MString Expected = "\n" + Header + | |
| "SE\nID 1\nTI 1.500000000\n" | |
| "UH 0 41 l 4053 10452 59.5 12.25 4 1;2\n" | |
| "UH 0 49 h 1780 10251 33.25 11.5 0 -\n" | |
| "UC BGO1 2 0 1 3 812 511.5 0 3\n" | |
| "PQ\n" | |
| "SE\nID 2\nTI 2.250000000\n" | |
| "UC BGO2 0 1 1 1 900 600.25 0 -\n" | |
| "PQ\n" | |
| "EN\n\n"; |
Is it ever helpful to keep those events (ID and TI), even if they have no hits in them?
** NEEDS YET ANOTHER MEGALIB UPDATE ***
First version to handle multiple data types in the roa file, e.g.:
TYPE ROA
UF UH doublesidedstrip adc-tac-flags
UF UC voxel3d adc-flags
SE
ID 1
TI 1771332026.007614416
UH 0 64 h 1738 0 5
UC 4 2536 1
Lots of changes in MEGAlib and nuclearizer were necessary to achieve this - and I do not have a data set to fully test it yet.
Please review carefully.