14#include <TCategorizedData.h>
15#include <TRawDataObject.h>
30 : fCategorizedData(nullptr), fOutData(nullptr) {
31 RegisterInputCollection(
"CategorizedDataName",
"name of the segmented data",
33 RegisterOutputCollection(
"OutputCollection",
"name of the output branch",
36 RegisterProcessorParameter(
"CatID",
"Category ID",
fCatID, -1);
64 if (std::holds_alternative<TString>(result)) {
65 SetStateError(std::get<TString>(result));
72 SetStateError(
"CatID must be set in the steering file");
77 fOutData =
new TClonesArray(
"art::crib::TMUXData");
80 Info(
"Init",
"%s -> %s, CatID = %d",
96 Warning(
"Process",
"No CategorizedData object");
100 const auto *cat_array = (*fCategorizedData)->FindCategory(
fCatID);
104 const int nDet = cat_array->GetEntriesFast();
106 for (
int iDet = 0; iDet < nDet; ++iDet) {
107 const auto *det_array =
static_cast<const TObjArray *
>(cat_array->At(iDet));
114 outData->SetID(detID);
127 double raw_data[
TMUXData::kNRAW] = {kInvalidD, kInvalidD, kInvalidD, kInvalidD, kInvalidD};
128 int detID = kInvalidI;
130 const auto *data_array =
static_cast<const TObjArray *
>(det_array->At(iType));
136 if (data_array->GetEntriesFast() != 1) {
137 Warning(
"ProcessDetectorData",
"MUX data [%d] size is not 1", iType);
140 const auto *data =
dynamic_cast<const TRawDataObject *
>(data_array->At(0));
142 raw_data[iType] = data->GetValue();
143 detID = data->GetDetID();
146 const int nData = data_array->GetEntriesFast();
147 for (
int iData = 0; iData < nData; ++iData) {
148 const auto *data =
dynamic_cast<const TRawDataObject *
>(data_array->At(iData));
150 if (!IsValid(raw_data[iType]))
151 raw_data[iType] = data->GetValue();
153 detID = data->GetDetID();
158 mux->
SetE1(raw_data[0]);
159 mux->
SetE2(raw_data[1]);
160 mux->
SetP1(raw_data[2]);
161 mux->
SetP2(raw_data[3]);
ClassImp(art::crib::TMUXDataMappingProcessor)
ROOT macro for class implementation.
Declaration of TMUXDataMappingProcessor class for mapping categorized data to TMUXData objects.
Header file for the TMUXData class.
Utility functions for handling input and parameter objects in TEventCollection.
A processor for mapping categorized data to TMUXData objects.
~TMUXDataMappingProcessor() override
Destructor.
Int_t fCatID
Category ID used for filtering input data.
void Init(TEventCollection *col) override
Initializes the processor with the provided event collection.
TCategorizedData ** fCategorizedData
! Pointer to the categorized data collection.
TString fOutputColName
Name of the output TMUXData collection.
TMUXDataMappingProcessor()
Constructor.
TClonesArray * fOutData
! Pointer to the output TMUXData array.
int ProcessDetectorData(const TObjArray *det_array, TMUXData *mux)
Processes data for a single detector.
void Process() override
Processes the categorized data and maps it to TMUXData.
TString fCategorizedDataName
Name of the input categorized data collection.
Represents data from the MUX module (E1, E2, P1, P2, T).
static const Int_t kNRAW
Number of raw data elements (E1, E2, P1, P2, Trigger).
void SetE2(Double_t value)
Set the second energy value.
void PushTiming(Double_t value)
Add a new timing value.
void SetP1(Double_t value)
Set the first position value.
void SetE1(Double_t value)
Set the first energy value.
void SetTrig(Double_t value)
Set the timing value.
void SetP2(Double_t value)
Set the second position value.
std::enable_if_t< std::is_base_of_v< TObject, T >, std::variant< T **, TString > > GetInputObject(TEventCollection *col, const TString &name, const TString &expectedTypeName, const TString &elementTypeName="TObject")
Retrieve an object from TEventCollection with type validation.