Skip to content

Commit

Permalink
Merge pull request #96 from rest-for-physics/readout_update
Browse files Browse the repository at this point in the history
Update readout generation
  • Loading branch information
juanangp committed Jul 6, 2023
2 parents 75d4229 + 14854c4 commit 3bb1d12
Show file tree
Hide file tree
Showing 8 changed files with 2,999 additions and 2,886 deletions.
7 changes: 3 additions & 4 deletions inc/TRestDetectorReadout.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ class TRestDetectorReadout : public TRestMetadata {

void Initialize() override;

Bool_t fDecoding; ///< Defines if a decoding file was used to set the relation
///< between a physical readout channel id and a signal daq id

Int_t fNReadoutPlanes; ///< Number of readout planes present on the readout
std::vector<TRestDetectorReadoutPlane>
fReadoutPlanes; ///< A std::vector storing the TRestDetectorReadoutPlane definitions.
Expand Down Expand Up @@ -92,13 +89,15 @@ class TRestDetectorReadout : public TRestMetadata {

void Draw();

void Export(const std::string& fileName);

// Constructor
TRestDetectorReadout();
explicit TRestDetectorReadout(const char* configFilename);
TRestDetectorReadout(const char* configFilename, std::string name);
// Destructor
~TRestDetectorReadout() override;

ClassDefOverride(TRestDetectorReadout, 1);
ClassDefOverride(TRestDetectorReadout, 2);
};
#endif
23 changes: 21 additions & 2 deletions inc/TRestDetectorReadoutModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ class TRestDetectorReadoutModule {
Bool_t showWarnings; //!///< Flag to enable/disable warning outputs. Disabled by
//! default. REST_Warning in TRestDetectorReadout will enable it.

Int_t fFirstDaqChannel = 0; ///< First DAQ channel

std::string fDecodingFile = ""; ///< Decoding file

Int_t fMappingNodes = 0; ///< Number of nodes

Bool_t fDecoding; ///< Defines if a decoding file was used to set the relation
///< between a physical readout channel id and a signal daq id

void Initialize();

/// Converts the coordinates (xPhys,yPhys) in the readout plane reference
Expand Down Expand Up @@ -105,6 +114,12 @@ class TRestDetectorReadoutModule {
/// Sets the tolerance for independent pixel overlaps
inline void SetTolerance(Double_t tolerance) { fTolerance = tolerance; }

/// Sets first DAQ channel
inline void SetFirstDaqChannel(Int_t firstDaqChannel) { fFirstDaqChannel = firstDaqChannel; }

/// Sets number of nodes
inline void SetMappingNodes(Int_t nodes) { fMappingNodes = nodes; }

/// Gets the tolerance for independent pixel overlaps
inline Double_t GetTolerance() const { return fTolerance; }

Expand All @@ -114,6 +129,8 @@ class TRestDetectorReadoutModule {
/// Returns the maximum daq id number
inline Int_t GetMaxDaqID() const { return fDaqIdRange.second; }

inline Int_t GetMappingNodes() const { return fMappingNodes; }

/// Returns the physical readout channel index for a given daq id channel number
inline Int_t DaqToReadoutChannel(Int_t daqChannel) {
for (size_t n = 0; n < GetNumberOfChannels(); n++) {
Expand Down Expand Up @@ -169,7 +186,9 @@ class TRestDetectorReadoutModule {
/// Disables warning output
inline void DisableWarnings() { showWarnings = false; }

void DoReadoutMapping(Int_t nodes = 0);
void DoReadoutMapping();

void SetDecodingFile(const std::string& decodingFile);

Bool_t isInside(const TVector2& position);

Expand Down Expand Up @@ -213,6 +232,6 @@ class TRestDetectorReadoutModule {
// Destructor
virtual ~TRestDetectorReadoutModule();

ClassDef(TRestDetectorReadoutModule, 3);
ClassDef(TRestDetectorReadoutModule, 4);
};
#endif
19 changes: 19 additions & 0 deletions macros/REST_Detector_UpdateDecoding.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
void REST_Detector_UpdateDecoding(const std::string& rootFile, const std::string& readoutName,
const std::string& decodingFile) {
TFile* f = TFile::Open(rootFile.c_str(), "UPDATE");
TRestDetectorReadout* readout = (TRestDetectorReadout*)f->Get(readoutName.c_str());

// readout->PrintMetadata();

for (int p = 0; p < readout->GetNumberOfReadoutPlanes(); p++) {
TRestDetectorReadoutPlane* plane = readout->GetReadoutPlane(p);
for (int m = 0; m < plane->GetNumberOfModules(); m++) {
TRestDetectorReadoutModule* module = &(*plane)[m];
module->SetDecodingFile(decodingFile);
}
}

readout->Write(readoutName.c_str());

f->Close();
}
4 changes: 2 additions & 2 deletions pipeline/readout/PrintReadout.C
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ void PrintReadout(TString fName) {

cout.rdbuf(stream_buffer_file);

TRestRun run(fname);
TRestDetectorReadout* r = (TRestDetectorReadout*)run.GetMetadata("Prototype_2020_06");
TFile* f = TFile::Open(fName);
TRestDetectorReadout* r = (TRestDetectorReadout*)f->Get("Prototype_2020_06");
r->PrintMetadata(3);

cout.rdbuf(stream_buffer_cout); // back to the old buffer
Expand Down
6 changes: 2 additions & 4 deletions pipeline/readout/generateReadout.rml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Finally we call the method TRestRun::FormOutputFile() through TRestManager to sa
<variable name="CHANNELS" value="64" overwrite="false"/>
<!-- The number of pixels per side PxP -->
</globals>
<TRestRun name="readoutrun">
<TRestDetectorReadout name="Prototype_2020_06" title="PANDA readout 7module">
<parameter name="verboseLevel" value="info"/>
<parameter name="mappingNodes" value="0"/>
Expand All @@ -49,7 +48,6 @@ Finally we call the method TRestRun::FormOutputFile() through TRestManager to sa
<addReadoutModule id="9" name="module" origin="(-96.75,-292.175)" rotation="0degrees" decodingFile="dummy.dec" firstDaqChannel="136*0"/>

</readoutPlane>
</TRestDetectorReadout>
</TRestRun>
<addTask command="readoutrun-&gt;FormOutputFile()" value="ON"/>
</TRestDetectorReadout>
<addTask command="Prototype_2020_06-&gt;Export(&#34;readout.root&#34;)" value="ON"/>
</TRestManager>
Loading

0 comments on commit 3bb1d12

Please sign in to comment.