Skip to content
Snippets Groups Projects
Commit d5ff42cf authored by Jure Bericic's avatar Jure Bericic Committed by Stephen A. Wood
Browse files

Small fixes for THcRawHodoHit and THcTrigRawHit.

- Now throwing an error for invalid signal in THcRawHodoHit::GetRawData and THcRawHodoHit::GetData.
- THcRawHodoHit::GetData now only subtracts reference time for TDC channels.
- THcRawHodoHit::SetReference now prints warning when trying to set reference time for ADC and does not set it.
- Fix in THcTrigRawHit::Clear to set fHasMulti to kFALSE.
- THcTrigRawHit::SetReference now prints warning when trying to set reference time for ADC and does not set it.
parent c16b29f2
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,8 @@ Class representing a single raw hit for a hodoscope paddle ...@@ -17,6 +17,8 @@ Class representing a single raw hit for a hodoscope paddle
#include <cassert> #include <cassert>
#include <stdexcept> #include <stdexcept>
#include "TString.h"
#include "THcRawHodoHit.h" #include "THcRawHodoHit.h"
using namespace std; using namespace std;
...@@ -126,13 +128,13 @@ Int_t THcRawHodoHit::GetData(Int_t signal, UInt_t ihit) { ...@@ -126,13 +128,13 @@ Int_t THcRawHodoHit::GetData(Int_t signal, UInt_t ihit) {
} else if (signal==3) { } else if (signal==3) {
value = fTDC_neg[ihit]; value = fTDC_neg[ihit];
} else { } else {
cout << "THcRawHodoHit::GetData(): requested invalid signal #" TString msg = TString::Format(
<< signal << endl; "THcRawHodoHit::GetData(): requested invalid signal #%d.",
return(-1); // Actually should throw an exception signal
);
throw std::out_of_range(msg.Data());
} }
// We are return -1 as a error, but reference subtracted if(fHasRef[signal] && (signal == 2 || signal == 3)) {
// time can be negative.
if(fHasRef[signal]) {
value -= fReferenceTime[signal]; value -= fReferenceTime[signal];
} }
return(value); return(value);
...@@ -158,16 +160,26 @@ Int_t THcRawHodoHit::GetRawData(Int_t signal, UInt_t ihit) { ...@@ -158,16 +160,26 @@ Int_t THcRawHodoHit::GetRawData(Int_t signal, UInt_t ihit) {
} else if (signal==3) { } else if (signal==3) {
return(fTDC_neg[ihit]); return(fTDC_neg[ihit]);
} else { } else {
cout << "THcRawHodoHit::GetData(): requested invalid signal #" TString msg = TString::Format(
<< signal << endl; "THcRawHodoHit::GetRawData(): requested invalid signal #%d.",
return(-1); // Actually should throw an exception signal
);
throw std::out_of_range(msg.Data());
} }
} }
// Set the reference time // Set the reference time
void THcRawHodoHit::SetReference(Int_t signal, Int_t reference) { void THcRawHodoHit::SetReference(Int_t signal, Int_t reference) {
fReferenceTime[signal] = reference; if (signal == 2 || signal == 3) {
fHasRef[signal] = kTRUE; fReferenceTime[signal] = reference;
fHasRef[signal] = kTRUE;
} else if (signal == 0 || signal == 1) {
std::cerr
<< "Warning:"
<< " THcRawHodoHit::SetReference():"
<< " signals 0 and 1 (ADC) should not have reference time!"
<< " Check map file!";
}
} }
Int_t THcRawHodoHit::GetReference(Int_t signal) { Int_t THcRawHodoHit::GetReference(Int_t signal) {
if(fHasRef[signal]) { if(fHasRef[signal]) {
...@@ -224,8 +236,8 @@ THcRawHodoHit& THcRawHodoHit::operator=( const THcRawHodoHit& rhs ) ...@@ -224,8 +236,8 @@ THcRawHodoHit& THcRawHodoHit::operator=( const THcRawHodoHit& rhs )
for(UInt_t is=0;is<fNRawSamplesNeg;is++) { for(UInt_t is=0;is<fNRawSamplesNeg;is++) {
fADC_Samples_neg[is] = rhs.fADC_Samples_neg[is]; fADC_Samples_neg[is] = rhs.fADC_Samples_neg[is];
} }
} }
return *this; return *this;
} }
......
...@@ -219,6 +219,7 @@ Returns `0` if reference time is not available. ...@@ -219,6 +219,7 @@ Returns `0` if reference time is not available.
#include "THcTrigRawHit.h" #include "THcTrigRawHit.h"
#include <iostream>
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
...@@ -273,7 +274,7 @@ void THcTrigRawHit::Clear(Option_t* opt) { ...@@ -273,7 +274,7 @@ void THcTrigRawHit::Clear(Option_t* opt) {
for (UInt_t i=0; i<fNPlanes; ++i) { for (UInt_t i=0; i<fNPlanes; ++i) {
fHasReference[i] = kFALSE; fHasReference[i] = kFALSE;
fHasReference[i] = kFALSE; fHasMulti[i] = kFALSE;
fNRawHits[i] = 0; fNRawHits[i] = 0;
} }
fNRawSamples = 0; fNRawSamples = 0;
...@@ -346,7 +347,14 @@ void THcTrigRawHit::SetDataTimePedestalPeak( ...@@ -346,7 +347,14 @@ void THcTrigRawHit::SetDataTimePedestalPeak(
void THcTrigRawHit::SetReference(Int_t signal, Int_t reference) { void THcTrigRawHit::SetReference(Int_t signal, Int_t reference) {
if (signal == 0 || signal == 1) { if (signal == 0) {
std::cerr
<< "Warning:"
<< " `THcTrigRawHit::SetReference`:"
<< " signal 0 (ADC) should not have reference time!"
<< " Check map file!";
}
else if (signal == 1) {
fReferenceTime[signal] = reference; fReferenceTime[signal] = reference;
fHasReference[signal] = kTRUE; fHasReference[signal] = kTRUE;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment