Skip to content

Commit

Permalink
Merge pull request #168 from FRIBDAQ/rfoxkendo/issue166
Browse files Browse the repository at this point in the history
Rfoxkendo/issue166
  • Loading branch information
rfoxkendo authored Sep 3, 2024
2 parents 851d630 + 8200bfb commit 647b7d2
Show file tree
Hide file tree
Showing 31 changed files with 105 additions and 1,129 deletions.
2 changes: 2 additions & 0 deletions main/Core/AnalysisRingItems.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/
#ifndef ANALYSISRINGITEMS_H
#define ANALYSISRINGITEMS_H


#include <cstdint>
namespace frib {
namespace analysis {
Expand Down
15 changes: 10 additions & 5 deletions main/Core/CAENParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @brief: Implement methods of parsing events with CAEN hits.
*/
#include "CAENParser.h"
#include "FragmentIndex.h"
#include <FragmentIndex.h>
#include <algorithm>
#include <stdexcept>

Expand All @@ -46,14 +46,19 @@ CAENParser::~CAENParser()
* The first long is the size of the event body.
* The event body is assumed to be, and better be,
* an event built event.
*
* NOTE: In ufmt s_itembody points to the body header.
*/
void
CAENParser::operator()(void* pEventBody)
{
FragmentIndex frags(static_cast<uint16_t*>(pEventBody));

ufmt::FragmentIndex frags(static_cast<uint16_t*>(pEventBody));
for (int i =0; i < frags.getNumberFragments(); i++) {
FragmentInfo info = frags.getFragment(i);

ufmt::FragmentInfo info = frags.getFragment(i);
const uint8_t* pBody = reinterpret_cast<const uint8_t*>(info.s_itembody);
const uint32_t* pBhSize = reinterpret_cast<const uint32_t*>(info.s_itembody);
pBody += *pBhSize; // Skip the body headeer.
int sid = info.s_sourceId; // That's what we care about.

// If there's a module in the map we ask it to
Expand All @@ -63,7 +68,7 @@ CAENParser::operator()(void* pEventBody)
auto p = m_modules.find(sid);
if (p != m_modules.end()) {
CAENHit* pHit = makeHit(p->second);
pHit->unpack(info.s_itembody);
pHit->unpack(const_cast<uint16_t*>(reinterpret_cast<const uint16_t*>(pBody)));
if (p->second.s_module.getHits().size() == 0) {
// First hit:

Expand Down
43 changes: 22 additions & 21 deletions main/Core/CAnalysisEventProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
#include <RingFormatHelper10.h>
#include <RingFormatHelper11.h>

namespace DAQ11Format {
#include <DataFormat.h>
}

#include <v11/DataFormat.h>



#include <DataFormatPre11.h>
#include <v10/DataFormat.h>


#include <buffer.h>
Expand All @@ -50,6 +50,7 @@ namespace DAQ11Format {
#include <stdlib.h>
#include <iostream>

using namespace ufmt;
/*---------------------------------------------------------------------------
* Dispatch methods:
*/
Expand Down Expand Up @@ -313,7 +314,7 @@ CAnalysisEventProcessor::computeRingPayloadSize()
unsigned size = pDecoder->getBodySize(); // Already right for 10.x
if (!p10) { // 11.x
if (pDecoder->hasBodyHeader()) {
size -= sizeof(DAQ11Format::BodyHeader);
size -= sizeof(v11::BodyHeader);
} else {
size -= sizeof(uint32_t);
}
Expand Down Expand Up @@ -530,14 +531,14 @@ CAnalysisEventProcessor::getStateChangeAbsTime(CBufferDecoder& rDecoder)
if (dynamic_cast<CRingFormatHelper10*>(pDecoder->getCurrentFormatHelper())) {
// 10.x

NSCLDAQ10::pStateChangeItem pItem =
reinterpret_cast<NSCLDAQ10::pStateChangeItem>(pDecoder->getItemPointer());
v10::pStateChangeItem pItem =
reinterpret_cast<v10::pStateChangeItem>(pDecoder->getItemPointer());
return pItem->s_Timestamp;

} else {

DAQ11Format::pStateChangeItemBody pItem =
reinterpret_cast<DAQ11Format::pStateChangeItemBody>(pDecoder->getBody());
v11::pStateChangeItemBody pItem =
reinterpret_cast<v11::pStateChangeItemBody>(pDecoder->getBody());
return pItem->s_Timestamp;
}
}
Expand Down Expand Up @@ -575,15 +576,15 @@ CAnalysisEventProcessor::getStateChangeRunTime(CBufferDecoder& rDecoder)
if (dynamic_cast<CRingFormatHelper10*>(pDecoder->getCurrentFormatHelper())) {
// 10

NSCLDAQ10::pStateChangeItem pItem =
reinterpret_cast<NSCLDAQ10::pStateChangeItem>(pDecoder->getItemPointer());
v10::pStateChangeItem pItem =
reinterpret_cast<v10::pStateChangeItem>(pDecoder->getItemPointer());
return pItem->s_timeOffset;

} else {
// 11

DAQ11Format::pStateChangeItemBody pItem =
reinterpret_cast<DAQ11Format::pStateChangeItemBody>(pDecoder->getBody());
v11::pStateChangeItemBody pItem =
reinterpret_cast<v11::pStateChangeItemBody>(pDecoder->getBody());
int divisor = pItem->s_offsetDivisor ? pItem->s_offsetDivisor : 1;

return ((double)(pItem->s_timeOffset) )/ divisor;
Expand Down Expand Up @@ -639,8 +640,8 @@ void
CAnalysisEventProcessor::StringBuffer10(CAnalysisBase::StringListType type)
{
CRingBufferDecoder* pDecoder = dynamic_cast<CRingBufferDecoder*>(m_pDecoder);
NSCLDAQ10::pTextItem pItem =
reinterpret_cast<NSCLDAQ10::pTextItem>(pDecoder->getItemPointer());
v10::pTextItem pItem =
reinterpret_cast<v10::pTextItem>(pDecoder->getItemPointer());

// non string data:

Expand All @@ -666,8 +667,8 @@ void
CAnalysisEventProcessor::StringBuffer11(CAnalysisBase::StringListType type)
{
CRingBufferDecoder* pDecoder = dynamic_cast<CRingBufferDecoder*>(m_pDecoder);
DAQ11Format::pTextItemBody pItem =
reinterpret_cast<DAQ11Format::pTextItemBody>(pDecoder->getBody());
v11::pTextItemBody pItem =
reinterpret_cast<v11::pTextItemBody>(pDecoder->getBody());

// Non string data:

Expand All @@ -694,8 +695,8 @@ void
CAnalysisEventProcessor::ScalerBuffer10()
{
CRingBufferDecoder* pDecoder = dynamic_cast<CRingBufferDecoder*>(m_pDecoder);
NSCLDAQ10::pScalerItem pItem =
reinterpret_cast<NSCLDAQ10::pScalerItem>(pDecoder->getItemPointer());
v10::pScalerItem pItem =
reinterpret_cast<v10::pScalerItem>(pDecoder->getItemPointer());
auto pHelper = pDecoder->getCurrentFormatHelper();

// Fish out non scaler info.
Expand Down Expand Up @@ -723,8 +724,8 @@ void
CAnalysisEventProcessor::ScalerBuffer11()
{
CRingBufferDecoder* pDecoder = dynamic_cast<CRingBufferDecoder*>(m_pDecoder);
DAQ11Format::pScalerItemBody pItem =
static_cast<DAQ11Format::pScalerItemBody>(pDecoder->getBody());
v11::pScalerItemBody pItem =
static_cast<v11::pScalerItemBody>(pDecoder->getBody());
auto pHelper = pDecoder->getCurrentFormatHelper();

// Non scaler info:
Expand Down
6 changes: 3 additions & 3 deletions main/Core/CEventBuilderEventProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <config.h>
#include "CEventBuilderEventProcessor.h"
#include "CTreeParameter.h"
#include "FragmentIndex.h"
#include <FragmentIndex.h>

#include <algorithm>
#include <sstream>
Expand Down Expand Up @@ -128,7 +128,7 @@ CEventBuilderEventProcessor::operator()(
)
{
*m_eventNumber = ++m_nEvents;
FragmentIndex frags(reinterpret_cast<uint16_t*>(pEvent));
ufmt::FragmentIndex frags(reinterpret_cast<uint16_t*>(pEvent));

// Source cout will be the number of fragments -- note an event is allowed
// to have more than one fragment from the same source id....this
Expand All @@ -153,7 +153,7 @@ CEventBuilderEventProcessor::operator()(
if (info.s_processor) { // in case we just made an empty.
(*info.s_SourcePresent) = 1;
Bool_t ok = (*info.s_processor)(
pFrag->s_itembody, rEvent, rAnalyzer, rDecoder
const_cast<uint16_t*>(pFrag->s_itembody), rEvent, rAnalyzer, rDecoder
);
if (!ok) throw ok; // Failure.
} else {
Expand Down
1 change: 1 addition & 0 deletions main/Core/CRingBufferDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <stdexcept>

using namespace std;
using namespace ufmt;

// Constants:

Expand Down
Loading

0 comments on commit 647b7d2

Please sign in to comment.