ADD: Support for loading version 2 of the HDF hit info#100
ADD: Support for loading version 2 of the HDF hit info#100fhagemann merged 10 commits intocositools:develop/emfrom
Conversation
|
Thanks for starting this and taking it off my todo list, but there are a few more things to do: |
|
Thanks for the feedback, I will try to look into this. |
|
I don't have v2.3 but in previous 2.x versions, there was an EventIndices table "Maps each packet in Events to a [start_index, end_index) range in each hit table that contains the hits from that event. An event at index i in the |
|
I think we have to do (1) and the EventIndices if they are still in version 2.3 - because otherwise the output is not correct. And then we can do the rest of the content in a later PR |
|
With the latest commit, I seem to be able to read the polarities from all 3 primary/secondary asics for all 16 detectors in the I still need to implement using this information for strip mapping. |
|
From my understanding: instead of "switching" between strip maps, the ASIC polarities are used to update if an ASIC is on HV or LV side, by ignoring that entry in the strip map and calculating it from
|
|
Ok, the code in this PR still "only" allows reading FEEHits, There is a slight difference between v2.0-v2.1 and v2.2+, (v2.2+ added spacewire timing via |
| // Catch a bug in the HDF5 data (v1) | ||
| if (EventID == 0 && StripID == 0 && ADCs == 0) { | ||
| IsZeroDataBug = true; | ||
| if (g_Verbosity >= c_Error) cout<<m_XmlTag<<": ZERO-DATA-BUG: Found empty data set. Ignoring event."<<endl; | ||
| continue; | ||
| } else { | ||
| if (IsZeroDataBug == true) { // We are now out of the bug and need to recover | ||
| // Clear the strip hits - everything else gets overwritten later | ||
| while (Event->GetNStripHits() > 0) { | ||
| MStripHit* H = Event->GetStripHit(0); | ||
| delete H; | ||
| Event->RemoveStripHit(0); | ||
| } | ||
| } | ||
| IsZeroDataBug = false; | ||
| } |
There was a problem hiding this comment.
Is this something we would also expect in HDF v2?
The file structure has changed completely..
| } else if (m_HDFStripHitVersion >= MHDFStripHitVersion::V2_0) { | ||
| Event->SetTI(TimeCode); | ||
| } | ||
|
|
||
| if (m_StripMap.HasReadOutID(StripID) == true) { | ||
| MStripHit* H = new MStripHit(); | ||
| H->SetDetectorID(m_StripMap.GetDetectorID(StripID)); | ||
| H->SetStripID(m_StripMap.GetStripNumber(StripID)); | ||
| H->IsLowVoltageStrip(m_StripMap.IsLowVoltage(StripID)); | ||
| H->SetADCUnits(ADCs); | ||
| H->SetTAC(TACs); | ||
|
|
||
|
|
||
| // Set boolean flags based on HitType and TimingType | ||
| H->IsGuardRing(HitType == 2); | ||
| if (H->IsGuardRing() == true) { | ||
| Event->SetGuardRingVeto(true); | ||
| } | ||
|
|
||
| H->IsNearestNeighbor(HitType == 1); | ||
| H->HasFastTiming(TimingType == 1); | ||
|
|
||
| // If the user does not want to include Nearest Neighbors in the data, then this is where we remove them | ||
| // NOTE: at some point we will want to remove this code and always include nearest neighbor data | ||
| if (m_IncludeNearestNeighbor == false && HitType == 1) { | ||
| delete H; // Clean up the memory we just allocated | ||
| // Increase counters | ||
| NStripHits = static_cast<unsigned int>(NumberOfHits); | ||
| StripHitIndex++; | ||
| continue; | ||
| if (m_HDFStripHitVersion >= MHDFStripHitVersion::V2_2) { | ||
| Event->SetCL(SPWTimeCode); |
There was a problem hiding this comment.
I'm right now setting the TimeCode (which is GSETimeCode if existent) to TI and the SPWTimeCode to CL.
Is this how it should be?
There was a problem hiding this comment.
I don't know what it actually means.
Those are the times we currently have (Carolyn want to scrub it eventually):
//! TODO Scrub all clock/time variables for COSI SMEX
//! Set the Frame Counter of this event
void SetFC(unsigned int FC) { m_FC = FC; }
//! Return the Frame Counter of this event
unsigned int GetFC() const { return m_FC; }
//! set and get Unix clock time
void SetTI(unsigned long long TI) { m_TI = TI;}
unsigned long long GetTI() const { return m_TI;}
//! set and get clock tick
void SetCL(uint64_t CL) { m_CL = CL;}
uint64_t GetCL() const { return m_CL;}
//! Set and get the Modified Julian Date of this event
void SetMJD(double MJD) { m_MJD = MJD; }
double GetMJD() const { return m_MJD; }
//! Set and get the UTC time of this event
void SetTimeUTC(const MTime& TimeUTC) { m_EventTimeUTC = TimeUTC; }
MTime GetTimeUTC() const { return m_EventTimeUTC; }
There was a problem hiding this comment.
I didn't touch that part of the code with my latest commit, but this goes along with #69.
We should eventually decide how/where we want to store that information (also for DEE output).
|
I tried parsing files in v1.1, v2.1 and v2.3, and I'm not getting any errors at least. |
|
Generally looks good, just a bunch of small things. |
|
Put you name into the copyright notices! |
|
Done (I also added my name to the copyright notices of |
|
Can you check if you initialize or clear everything in the Initialize function? |
|
That should also be done now. The only thing I don't initialize is And |
|
OK. Feel free to merge. |
This is my attempt to implement a HDF loader for the newest version 2 of the HDF hit into.
I'm not claiming that this is perfect, but it seems to give something reasonable at least..
It also fixes #57.
I developed this based on a file that was taken with
HDF v2.3andGSE v7.2.2on the FM assembly at SSL.The changes between versions 1 and 2 addressed in this PR are:
where the HDFVersion is saved in the file
HDFVersionis its own dataset within the file.HDFVersionis an attribute of theEventsdataset.--> If no dataset
HDFVersionexists, check for the existence ofEventsand attributeHDFVersiontherein.Hit and event information are now stored in different datasets
Hits.FEEHitsand the event information is saved in the datasetEvents. Hit entries inFEEHitshave a fieldevent_indexwhich denotes which "row" in theEventsdataset correspond to the given hit.For clarification:
--> use the same buffer logic for hit information, but read in the event information as a whole.
Right now, the handling of
SPWTimeCode(spacewire time code) is commented out to avoid undeclared variable warnings.I would be very grateful for feedback! :)