@@ -60,6 +60,7 @@ void RCUTrailer::constructFromRawPayload(const gsl::span<const uint32_t> payload
6060 }
6161 int parCode = (word >> 26 ) & 0xF ;
6262 int parData = word & 0x3FFFFFF ;
63+ // std::cout << "Found trailer word 0x" << std::hex << word << "(Par code: " << std::dec << parCode << ", Par data: 0x" << std::hex << parData << std::dec << ")";
6364 switch (parCode) {
6465 case 1 :
6566 // ERR_REG1
@@ -99,7 +100,7 @@ void RCUTrailer::constructFromRawPayload(const gsl::span<const uint32_t> payload
99100 mIsInitialized = true ;
100101}
101102
102- double RCUTrailer::getTimeSample () const
103+ double RCUTrailer::getTimeSampleNS () const
103104{
104105 uint8_t fq = mAltroConfig .mSampleTime ;
105106 double tSample;
@@ -120,40 +121,40 @@ double RCUTrailer::getTimeSample() const
120121 throw Error (Error::ErrorType_t::SAMPLINGFREQ_INVALID , fmt::format (" Invalid sampling frequency value %d !" , int (fq)).data ());
121122 }
122123
123- return tSample * o2::constants::lhc::LHCBunchSpacingNS * 1 . e - 9 ;
124+ return tSample * o2::constants::lhc::LHCBunchSpacingNS;
124125}
125126
126- void RCUTrailer::setTimeSample ( double timesample)
127+ void RCUTrailer::setTimeSamplePhaseNS ( uint64_t triggertime, uint64_t timesample)
127128{
128- int fq = 0 ;
129- if (std::abs (timesample - 50 ) < DBL_EPSILON ) {
130- fq = 0 ;
131- } else if (std::abs (timesample - 100 ) < DBL_EPSILON ) {
132- fq = 1 ;
133- } else if (std::abs (timesample - 200 ) < DBL_EPSILON ) {
134- fq = 2 ;
135- } else {
136- throw Error (Error::ErrorType_t::SAMPLINGFREQ_INVALID , fmt::format (" invalid time sample: %f" , timesample).data ());
137- }
138- mAltroConfig .mSampleTime = fq;
129+ int sample = 0 ;
130+ switch (timesample) {
131+ case 50 :
132+ sample = 0 ;
133+ break ;
134+ case 100 :
135+ sample = 1 ;
136+ break ;
137+ case 200 :
138+ sample = 2 ;
139+ break ;
140+ default :
141+ throw Error (Error::ErrorType_t::SAMPLINGFREQ_INVALID , fmt::format (" invalid time sample: %f" , timesample).data ());
142+ };
143+ mAltroConfig .mSampleTime = sample;
144+ // calculate L1 phase
145+ mAltroConfig .mL1Phase = (triggertime % timesample) / 25 ;
139146}
140147
141- double RCUTrailer::getL1Phase () const
148+ double RCUTrailer::getL1PhaseNS () const
142149{
143- double tSample = getTimeSample (),
144- phase = static_cast <double >(mAltroConfig .mL1Phase ) * o2::constants::lhc::LHCBunchSpacingNS * 1 . e - 9 ;
150+ double tSample = getTimeSampleNS (),
151+ phase = static_cast <double >(mAltroConfig .mL1Phase ) * o2::constants::lhc::LHCBunchSpacingNS;
145152 if (phase >= tSample) {
146- throw Error (Error::ErrorType_t::L1PHASE_INVALID , fmt::format (" Invalid L1 trigger phase (%e s (phase) >= %e s (sampling time)) !" , phase, tSample).data ());
153+ throw Error (Error::ErrorType_t::L1PHASE_INVALID , fmt::format (" Invalid L1 trigger phase (%e ns (phase) >= %e ns (sampling time)) !" , phase, tSample).data ());
147154 }
148155 return phase;
149156}
150157
151- void RCUTrailer::setL1Phase (double l1phase)
152- {
153- int phase = l1phase / 25 .;
154- mAltroConfig .mL1Phase = phase;
155- }
156-
157158std::vector<uint32_t > RCUTrailer::encode () const
158159{
159160 std::vector<uint32_t > encoded;
@@ -177,12 +178,12 @@ void RCUTrailer::printStream(std::ostream& stream) const
177178 std::vector<std::string> errors;
178179 double timesample = -1 ., l1phase = -1 .;
179180 try {
180- timesample = getTimeSample ();
181+ timesample = getTimeSampleNS ();
181182 } catch (Error& e) {
182183 errors.push_back (e.what ());
183184 }
184185 try {
185- l1phase = getL1Phase ();
186+ l1phase = getL1PhaseNS ();
186187 } catch (Error& e) {
187188 errors.push_back (e.what ());
188189 }
@@ -201,20 +202,22 @@ void RCUTrailer::printStream(std::ostream& stream) const
201202 << " Active FECs (branch A): 0x" << std::hex << mActiveFECsA << " \n "
202203 << " Active FECs (branch B): 0x" << std::hex << mActiveFECsB << " \n "
203204 << " Baseline corr: " << std::hex << getBaselineCorrection () << " \n "
205+ << " Polarity: " << (getPolarity () ? " yes" : " no" ) << " \n "
204206 << " Number of presamples: " << std::dec << getNumberOfPresamples () << " \n "
205207 << " Number of postsamples: " << std::dec << getNumberOfPostsamples () << " \n "
206208 << " Second baseline corr: " << (hasSecondBaselineCorr () ? " yes" : " no" ) << " \n "
207209 << " Glitch filter: " << std::dec << getGlitchFilter () << " \n "
208210 << " Number of non-ZS postsamples: " << std::dec << getNumberOfNonZeroSuppressedPostsamples () << " \n "
209211 << " Number of non-ZS presamples: " << std::dec << getNumberOfNonZeroSuppressedPresamples () << " \n "
212+ << " Zero suppression: " << (hasZeroSuppression () ? " yes" : " no" ) << " \n "
210213 << " Number of ALTRO buffers: " << std::dec << getNumberOfAltroBuffers () << " \n "
211214 << " Number of pretrigger samples: " << std::dec << getNumberOfPretriggerSamples () << " \n "
212215 << " Number of samples per channel: " << std::dec << getNumberOfSamplesPerChannel () << " \n "
213216 << " Sparse readout: " << (isSparseReadout () ? " yes" : " no" ) << " \n "
214217 << " AltroCFG1: 0x" << std::hex << mAltroConfig .mWord1 << " \n "
215218 << " AltroCFG2: 0x" << std::hex << mAltroConfig .mWord2 << " \n "
216- << " Sampling time: " << std::scientific << timesample << " s \n "
217- << " L1 Phase: " << std::scientific << l1phase << " s \n "
219+ << " Sampling time: " << timesample << " ns \n "
220+ << " L1 Phase: " << l1phase << " ns \n "
218221 << std::dec << std::fixed;
219222 if (errors.size ()) {
220223 stream << " Errors: \n "
0 commit comments