Skip to content

Commit

Permalink
Add class to hold readout metadata info
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Aug 24, 2023
1 parent 7c6f9b5 commit 45515e5
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
4 changes: 0 additions & 4 deletions inc/TRestRawReadoutAnalysisProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#define RestCore_TRestRawReadoutAnalysisProcess

#include <TH1D.h>

// #include <TCanvas.h>

#include <TRestDetectorGas.h>
#include <TRestDetectorHitsEvent.h>
#include <TRestDetectorReadout.h>
Expand Down Expand Up @@ -44,7 +41,6 @@ class TRestRawReadoutAnalysisProcess : public TRestEventProcess {
std::map<int, TH1D*> fModuleActivityY; //! [MM id, channel activity]
std::map<int, TH2D*> fModuleBSLSigmaX; //! [MM id, channel activity]
std::map<int, TH2D*> fModuleBSLSigmaY; //! [MM id, channel activity]
//

public:
any GetInputEvent() const override { return fSignalEvent; }
Expand Down
10 changes: 10 additions & 0 deletions inc/TRestRawReadoutMetadataProcess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// Created by lobis on 24-Aug-23.
//

#ifndef REST_TRESTRAWREADOUTMETADATAPROCESS_H
#define REST_TRESTRAWREADOUTMETADATAPROCESS_H

#include <TRestRawReadoutMetadata.h>

#endif // REST_TRESTRAWREADOUTMETADATAPROCESS_H
59 changes: 59 additions & 0 deletions src/TRestRawReadoutMetadataProcess.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// Created by lobis on 24-Aug-23.
//

#include "TRestRawReadoutMetadataProcess.h"

#include <TRestDetectorReadout.h>

#include <set>

#include "TRestRawReadoutMetadata.h"

using namespace std;

void TRestRawReadoutMetadata::InitializeFromReadout(TRestDetectorReadout* readout) {
if (!readout) {
cerr << "TRestRawReadoutMetadata::InitializeFromReadout: readout is null" << endl;
exit(1);
}
fChannelInfo.clear();
for (int planeIndex = 0; planeIndex < readout->GetNumberOfReadoutPlanes(); planeIndex++) {
const auto plane = readout->GetReadoutPlane(planeIndex);
for (unsigned int moduleIndex = 0; moduleIndex < plane->GetNumberOfModules(); moduleIndex++) {
const auto module = plane->GetModule(moduleIndex);
for (unsigned int channelIndex = 0; channelIndex < module->GetNumberOfChannels();
channelIndex++) {
const auto channel = module->GetChannel(channelIndex);
const UShort_t channelId = channel->GetChannelId();
// check if channel id is already in the map
if (fChannelInfo.find(channelId) != fChannelInfo.end()) {
cerr << "TRestRawReadoutMetadata::InitializeFromReadout: channel id " << channelId
<< " already in the map. Channels on the readout should be unique" << endl;
exit(1);
}
ChannelInfo info;
info.type = channel->GetChannelType();
info.name = channel->GetChannelName();
fChannelInfo[channel->GetChannelId()] = info;
}
}
}
}

void TRestRawReadoutMetadata::PrintMetadata() const {
cout << "Number of channels: " << fChannelInfo.size() << endl;
map<string, int> typesCount;
for (const auto& channel : fChannelInfo) {
const auto& info = channel.second;
typesCount[info.type]++;
}
cout << "Channel types:" << endl;
for (const auto& type : typesCount) {
cout << type.first << ": " << type.second << endl;
}

for (const auto& [channelId, info] : fChannelInfo) {
cout << "Channel " << channelId << ": " << info.type << " " << info.name << endl;
}
}

0 comments on commit 45515e5

Please sign in to comment.