CHG: MStripHit cleanup#171
Conversation
|
I'm not sure that |
|
Also, when I do data/sim comparisons, I usually write both The only problem here is that we are inconsistent with types between nuclearizer and MEGAlib: |
| //! DEPRECATED: Set whether the strip is on the low voltage side using IsLowVoltageStrip instead | ||
| void IsXStrip(bool LowVoltageSide) { m_ReadOutElement->IsLowVoltageStrip(LowVoltageSide); } | ||
| //! DEPRECATED: Return whether the strip is on the low voltage side using IsLowVoltageStrip instead | ||
| bool IsXStrip() const { return m_ReadOutElement->IsLowVoltageStrip(); } |
There was a problem hiding this comment.
This can go, as long as it's not used anywhere else in nuclearizer (I see some occurrences in the old DEE files, in apps/ThresholdDeterminator.cxx, and in src/MModuleLoaderMeasurementsROA.cxx -- the latter would need to be updated then).
There was a problem hiding this comment.
I made an issue since a few other parts in the code still use it.
| //! Set the uncorrected ADC units of the strip (before common-mode correction) | ||
| void SetUncorrectedADCUnits(double UncorrectedADCUnits) { m_UncorrectedADCUnits = UncorrectedADCUnits; } | ||
| //! Return the uncorrected ADCUnits of the strip (before common-mode correction) | ||
| //! Return the uncorrected ADC units of the strip (before common-mode correction) | ||
| double GetUncorrectedADCUnits() const { return m_UncorrectedADCUnits; } | ||
|
|
||
| //! Set the ADCUnits of the strip | ||
| //! Set the ADC units of the strip | ||
| void SetADCUnits(double ADCUnits) { m_ADCUnits = ADCUnits; } | ||
| //! Return the ADCUnits of the strip | ||
| //! Return the ADC units of the strip | ||
| double GetADCUnits() const { return m_ADCUnits; } |
There was a problem hiding this comment.
Just from looking at this, I wouldn't know what this is (energy or timing in ADC units, before some common-mode correction?)
| //! Set whether the strip has triggered | ||
| void HasTriggered(bool HasTriggered) { m_HasTriggered = HasTriggered; } | ||
| //! Return whether the strip has triggered | ||
| bool HasTriggered() const { return m_HasTriggered; } |
There was a problem hiding this comment.
"triggered" as in above slow threshold (energy triggered), or could this also be exceeding the fast threshold (timing), without exceeding the slow threshold, what we see for some peak-dip pulse shapes in non-charge-collecting neighbor strips?
I believe its the former, because I also see HasFastTiming, but maybe make this explicit in the comment.
| //! Set the temperature of the relevant preamp (in degrees C) | ||
| void SetPreampTemp(double PreampTemp) { m_PreampTemp = PreampTemp; } | ||
| //! Return the Temperature of the relavent preamp (in degrees C) | ||
| //! Return the temperature of the relevant preamp (in degrees C) | ||
| double GetPreampTemp() const { return m_PreampTemp; } |
| //! Set the calibrated-timing flag | ||
| void HasCalibratedTiming(bool CalibratedTiming) { m_HasCalibratedTiming = CalibratedTiming; } | ||
| //! Return a boolean indicating whether the strip timing has been calibrated; | ||
| //! Return whether the strip timing has been calibrated | ||
| bool HasCalibratedTiming() const { return m_HasCalibratedTiming; } |
There was a problem hiding this comment.
Is this because m_Timing used to first hold uncalibrated TAC and then calibrated TAC. Or is this to flag all strips where we don't have a TAC cal available for example (guard ring for example)?
There was a problem hiding this comment.
I assume this is a hold-over, as you say, but @NicoleRodriguezCavero is using this in the TAC Calibration module. I think we should be using the guard ring and fast threshold flags to determine when we do not have a valid TAC cal, but Nicole can better comment on her intention with this variable.
There was a problem hiding this comment.
I still don't know how this is relates to HasFastTiming.
The comment //! Return whether the strip timing has been calibrated suggests that this flag indicates that m_Timing was calculated from m_TAC, such that we can trust whatever is stored in m_Timing (?)
| //! Flags denoting the type of strip hit | ||
| //! True if the hit is a guard ring | ||
| bool m_IsGuardRing; | ||
| //! True if the hit is a nearest neighbor |
There was a problem hiding this comment.
| //! True if the hit is a nearest neighbor | |
| //! True if the hit is a nearest neighbor hit |
| if (WithTAC == true) { | ||
| S<<m_TAC<<" "; | ||
| } | ||
| if (WithTemperature == true) { | ||
| S<<m_PreampTemp<<" "; | ||
| } | ||
| if (WithEnergy == true) { | ||
| S<<m_Energy<<" "; | ||
| } | ||
| if (WithTiming == true) { | ||
| S<<m_Timing<<" "; |
There was a problem hiding this comment.
This is what I was referring to: we can write both (uncalibrated) m_TAC and (calibrated) m_Timing to ROA files, but currently we cannot READ the Timing because MEGAlib parses it as unsigned int where here in nuclearizer we define it as double.
| // v = Is a nearest neighbor | ||
| // v = Is a guard ring |
There was a problem hiding this comment.
| // v = Is a nearest neighbor | |
| // v = Is a guard ring | |
| // v = Is a nearest neighbor hit | |
| // v = Is a guard ring hit |
There was a problem hiding this comment.
Please resolve this comment if you are not planning on incorporating it
| // v = Is a nearest neighbor | ||
| // v = Is a guard ring |
There was a problem hiding this comment.
| // v = Is a nearest neighbor | |
| // v = Is a guard ring | |
| // v = Is a nearest neighbor hit | |
| // v = Is a guard ring hit |
There was a problem hiding this comment.
Please resolve this comment if you are not planning on incorporating it
| // All three flags -> 7 | ||
| H.IsGuardRing(true); | ||
| H.IsNearestNeighbor(true); | ||
| H.HasFastTiming(true); |
There was a problem hiding this comment.
For the unit tests, this is fine, but I would argue that we never flag a guard ring hit also as nearest neighbor 😉
|
The TAC / timing issues is that for the balloon "timing" was TAC and thus unsigned int. And now we reused is as calibrated TAC... |
|
One question on your change to MEGAlib develop-cosi: The |
|
I did some updates, but we will go through them tomorrow during the calibration meeting |
| // Energy section: | ||
|
|
||
| //! Set the ADCUnits of the strip | ||
| //! REVIEW: Why is this not unsigned int - that is what we measure? |
There was a problem hiding this comment.
Yes, this is what we measure, so unsigned int makes sense.
But is there a reason why we wouldn't want this as unsigned int for the DEE @fhagemann ? I assume we probably don't care about the small loss of accuracy from double -> int if we rounded the ADC value that is calculated in the DEE.
There was a problem hiding this comment.
I mean, if we want to mimic data in the DEE, we want to convert the „uncalibrated“ energy in ADC units to an unsigned int to account for the loss in precision due to the discretization that we have intrinsically in data.
From the DEE side, changing this to unsigned int should not be an issue
| //! Set the uncorrected ADC units of the strip (before common-mode correction) | ||
| void SetUncorrectedADCUnits(double UncorrectedADCUnits) { m_UncorrectedADCUnits = UncorrectedADCUnits; } | ||
| //! Return the uncorrected ADC units of the strip (before common-mode correction) | ||
| double GetUncorrectedADCUnits() const { return m_UncorrectedADCUnits; } |
There was a problem hiding this comment.
Looks like a hold-over from a previous time when common-mode corrections were used. But this isn't something we currently do.
I would also argue for correcting the energy not the ADC, so perhaps we can remove these for now and then implement the temperature correction on the energy at a later time.
| //! Return the measured TAC value of the strip (arrival timing) | ||
| double GetTAC() const { return m_TAC; } | ||
|
|
||
| //! REVIEW: This is not used - timing should have a resolution |
There was a problem hiding this comment.
Yes, I agree we can remove these
|
|
||
| // Timing: | ||
|
|
||
| //! REVIEW: Why is TAC double, when we measure unsigned ints? |
There was a problem hiding this comment.
Same as above for ADC. We're measuring ints, so unless we need double for the DEE (which I don't think is the case) then we should change to int.
|
|
||
| // Temperature: | ||
|
|
||
| //! REVIEW: Hold-over from balloon and balloon temperature calibration |
There was a problem hiding this comment.
Yes, these are old and we'll likely handle the temperature in a different way. I think you can remove these.
| bool HasFastTiming() const { return m_HasFastTiming; } | ||
|
|
||
| //! Set the Calibrated Timing flag | ||
| //! REVIEW: What kind of trigger is this: above slow or above fast? |
There was a problem hiding this comment.
I assume this is the slow threshold since the above fast-timing flag indicates the fast threshold. I don't know if there is a good use case for this flag in the forward pipeline, and it doesn't look like it's currently used.
| //! Set the calibrated-timing flag | ||
| void HasCalibratedTiming(bool CalibratedTiming) { m_HasCalibratedTiming = CalibratedTiming; } | ||
| //! Return a boolean indicating whether the strip timing has been calibrated; | ||
| //! Return whether the strip timing has been calibrated | ||
| bool HasCalibratedTiming() const { return m_HasCalibratedTiming; } |
There was a problem hiding this comment.
I assume this is a hold-over, as you say, but @NicoleRodriguezCavero is using this in the TAC Calibration module. I think we should be using the guard ring and fast threshold flags to determine when we do not have a valid TAC cal, but Nicole can better comment on her intention with this variable.
| //! ADC units before all corrections | ||
| double m_UncorrectedADCUnits; | ||
| //! ADCUnits after any correction | ||
| //! ADC units after any correction |
There was a problem hiding this comment.
I think we should just have a single ADC here and remove the Uncorrected version of the variable.
| //! True if the hit has fast timing | ||
| bool m_HasFastTiming; | ||
| //! Flag indicating whether the hit has calibrated timing | ||
| //! True if the hit has calibrated timing |
There was a problem hiding this comment.
Not sure this is needed.
There was a problem hiding this comment.
--> only reason I see would be to indicate than m_Timing doesn't store a trash value (?), but then we should check if this flag is actually set accordingly.
|
OK. I am done for the moment. |
|
Final, final changes |
| { | ||
| // Stream the read-out assembly in MEGAlib's ROA format | ||
| // | ||
| // WithTemperatures is currently not used, since we don't have that housekeeping info at the moment |
| if (line[0] == 'S' && line[1] == 'H') { | ||
| unsigned int det_id, strip_id; | ||
| int has_triggered; | ||
| double timing, un_adc, adc; | ||
| double timing, adc; | ||
| double energy, energy_res; | ||
| char pos_strip; | ||
| unsigned int flags; | ||
| int N = sscanf(&line[3], "%u %c %u %d %lf %lf %lf %lf %lf %u", | ||
| int N = sscanf(&line[3], "%u %c %u %d %lf %lf %lf %lf %u", | ||
| &det_id, &pos_strip, &strip_id, &has_triggered, | ||
| &timing, &un_adc, &adc, &energy, &energy_res, &flags); | ||
| if (N != 10) { | ||
| if (g_Verbosity >= c_Error) cout<<"Error in MStripHit::Parse: malformed SH line with "<<N<<" fields instead of 10"<<endl; | ||
| &timing, &adc, &energy, &energy_res, &flags); | ||
| if (N != 9) { | ||
| if (g_Verbosity >= c_Error) cout<<"Error in MStripHit::Parse: malformed SH line with "<<N<<" fields instead of 9"<<endl; |
There was a problem hiding this comment.
This means all previously generated files would need to be re-generated?
| //! Set the calibrated-timing flag | ||
| void HasCalibratedTiming(bool CalibratedTiming) { m_HasCalibratedTiming = CalibratedTiming; } | ||
| //! Return a boolean indicating whether the strip timing has been calibrated; | ||
| //! Return whether the strip timing has been calibrated | ||
| bool HasCalibratedTiming() const { return m_HasCalibratedTiming; } |
There was a problem hiding this comment.
I still don't know how this is relates to HasFastTiming.
The comment //! Return whether the strip timing has been calibrated suggests that this flag indicates that m_Timing was calculated from m_TAC, such that we can trust whatever is stored in m_Timing (?)
| //! True if the hit has fast timing | ||
| bool m_HasFastTiming; | ||
| //! Flag indicating whether the hit has calibrated timing | ||
| //! True if the hit has calibrated timing |
There was a problem hiding this comment.
--> only reason I see would be to indicate than m_Timing doesn't store a trash value (?), but then we should check if this flag is actually set accordingly.
| // v = Is a nearest neighbor | ||
| // v = Is a guard ring |
There was a problem hiding this comment.
Please resolve this comment if you are not planning on incorporating it
| // v = Is a nearest neighbor | ||
| // v = Is a guard ring |
There was a problem hiding this comment.
Please resolve this comment if you are not planning on incorporating it

I did the same cleanup for MStripHit.
But here are a few more old member functions around.
I would like to remove:
//! DEPRECATED: Set whether the strip is on the low voltage side using IsLowVoltageStrip instead
void IsXStrip(bool LowVoltageSide) { m_ReadOutElement->IsLowVoltageStrip(LowVoltageSide); }
//! DEPRECATED: Return whether the strip is on the low voltage side using IsLowVoltageStrip instead
bool IsXStrip() const { return m_ReadOutElement->IsLowVoltageStrip(); }
--> That is now IsLowVoltageStrip(..) REMOVE?
//! Set the timing in nanoseconds
void SetTiming(double Timing) { m_Timing = Timing; }
//! Return the timing in nanoseconds
double GetTiming() const { return m_Timing; }
//! Set the timing resolution
void SetTimingResolution(double TimingResolution) { m_TimingResolution = TimingResolution; }
//! Return the timing resolution
double GetTimingResolution() const { return m_TimingResolution; }
--> Has been replaced by the same function with name TAC instead of timing. REMOVE?
//! Set the temperature of the relevant preamp (in degrees C)
void SetPreampTemp(double PreampTemp) { m_PreampTemp = PreampTemp; }
//! Return the temperature of the relevant preamp (in degrees C)
double GetPreampTemp() const { return m_PreampTemp; }
--> What about that - we definitely have no preamps, but maybe some temperature dependence? But do we plan to store the temperature here?