REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Public Member Functions | Private Member Functions | Private Attributes
TRestDetectorReadout Class Reference

Detailed Description

A metadata class to generate/store a readout description.

This is the main metadata readout class of REST. The readout class defines the methods allowing to stablish a relation between the hits inside the TPC and the signals read out by the electronics daq.

A full readout description is composed by at least one readout plane, (TRestDetectorReadoutPlane), where we can place any number of readout modules (TRestDetectorReadoutModule). A readout module is composed by readout channels (TRestDetectorReadoutChannel) which describe the basic active detection area, which can take any complex shape by combinning primitive geometry elements (TRestDetectorReadoutPixel).

REST processes such as TRestDetectorSignalToHitsProcess and TRestDetectorHitsToSignalProcess use the TRestDetectorReadout class to transform the spatial coordinates into raw signal data, and viceversa.

Constructing the readout through an RML file

The readout definition must be initialized through a RML file. The basic metadata structure of a readout follows this scheme

<section TRestDetectorReadout ... >
<parameter name="mappingNodes" value="100" />
// First, we need to construct the different readout modules we will
// use inside the readout plane definition.
<readoutModule name="modName" size="(100,100)" tolerance="1.e-4" >
// Later, when we construct the readout plane we will use "modName"
// to add the module to the readout plane definition.
<readoutChannel id="0">
<addPixel id="0" origin="(0,0)" size="(10,10)" rotation="45" />
<addPixel id="1" origin="(10,10)" size="(10,10)" rotation="45"
/>
...
// Add as many pixel definitions as needed to create the channel
definition
...
</readoutChannel>
// And add as many readout channels as need to construct your
readout module <readoutChannel id="1">
...
...
</readoutChannel>
// The id number given to the readout channel is the physical
readout
// channel used inside the decoding.
<readoutChannel id="n">
...
...
</readoutChannel>
</readoutModule>
// If your readout is composed by modules with different size or channel
topologies,
// you will need add additional <readoutModule ...> definitions here.
// The readout plane allows to define the position, the orientation
(planeVector),
// and the position of the cathode that will define the detector active
volume. <readoutPlane position="(0,0,-990)" units="mm"
planeVector="(0,0,1)" chargeCollection="1"
cathodePosition="(0,0,0)" units="mm" >
// We can then insert the modules inside each readout plane
<addReadoutModule name="modName" // We use the previously defined
readout module
origin="(0,0)" // Position of the left-bottom
corner (rotation point). rotation="0" //
Rotation in degrees around position.
decodingFile="module.dec" // A file describing
the decoding firstDaqChannel="0" > // Offset
introduced to the daq signal channel inside the
decoding file.
<addReadoutModule name="modName"
origin="(0,0)" rotation="0"
decodingFile="module.dec" firstDaqChannel="272"
>
...
// Add as many modules as needed to construct your readout.
</readoutPlane>
// If needed you may add any additional readout layers to your
definition adding new
// readout plane <readoutPlane ...> definitions here.
</section>
A metadata class to generate/store a readout description.

The mappingNodes parameter allows to specify the size of the virtual grid that will be used to map the readout. The mapping allows to speed up the process finding a pixel inside a module for a given x,y coordinates. In general, the number of mapping nodes should be high enough so that every pixel from any readout channel is associated to, or contains, a node in the grid. However, as higher is the number of nodes in the mapping grid, higher will be the required computation time to find a pixel for a given x,y coordinates. If this value is not defined REST will try to find an optimum value for this parameter. Therefore, it is recommended to do not specify this parameter, except for solving readout problems or optimization purposes.

The decoding

The relation between the channel number imposed by the electronic acquisition and the readout channel id defined inside readoutChannel is given to TRestDetectorReadout through a decoding file.

The decodingFile parameter inside each module added to the readout plane allows to set the filename (in the code above, module.dec) of a file used to define the relation between the physical readout id defined at each readout channel, as <readoutChannel id="n"> and the daq channel number defined at the acquisition system. If no decoding file is defined the relation between daq and readout channel is assigned one to one. The decoding file must be a text file defining two columns with as many columns as the number of channels defined in the readout module. The first column is the daq channel number, and the second column is the readout channel defined in the RML file.

An example of contents of a decoding file. Here 0, 1, 2, 3, ... are the physical readout channels corresponding to the daq channels 67, 65, 63, 61, ...

67 0
65 1
63 2
61 3
59 4
57 5
54 6
...
...

The channel number defined on the left column will be shifted by the value firstDaqChannel defined when adding the readout module to the readout plane. This may allow to re-use a decoding file for different readout modules in case we have a repetitive connection pattern.

New method has been added to update the decoding in an already generated readout. The following lines give an example of how to do it:

TFile *f = TFile::Open("myReadout.root", "UPDATE");
TRestDetectorReadout* readout = (TRestDetectorReadout*)f->Get("readoutName");
for( int p = 0; p < readout->GetNumberOfReadoutPlanes(); p++ ){
for( int m = 0; m < plane->GetNumberOfModules(); m++ ) {
TRestDetectorReadoutModule* module = &(*plane)[m];
module->SetDecodingFile(decodingFile);
}
}
readout->Write("newDecoding");
f->Close();
void SetDecodingFile(const std::string &decodingFile)
Set the decoding file in the readout module.
size_t GetNumberOfModules() const
Returns the total number of modules in the readout plane.
TRestDetectorReadoutPlane * GetReadoutPlane(int p)
Returns a pointer to the readout plane by index.
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
overwriting the write() method with fStore considered

Using the readout class

Once TRestDetectorReadout has been initialized, through and RML file or a previously stored TRestDetectorReadout class stored in a ROOT file, we can find the corresponding xy-position for a given readout channel id, module id, and readout plane, or the corresponding coordinates for a given channel inside a module contained in a readout plane.

The following code shows how we can identify the readout plane (planeId), the readout module (moduleId), and the readout channel (chanId) for a given x,y,z coordinates.

for( int p = 0; p < fReadout->GetNumberOfReadoutPlanes(); p++ )
{
// We check if the xyz coordinates are in the volume defined by
the readout plane modId =
fReadout->GetReadoutPlane(p)->isInsideDriftVolume( x, y, z );
// If the hit is contained in the readout, the last function
returns the id of the
// readout module that contains the x,y coordinates.
if( modId >= 0 )
{
// We found the hit at planeId
planeId = p;
// Then we obtain the readoutChannel *id* as defined in the
readout. Int_t chanId = fReadout->GetReadoutPlane( p
)->FindChannel( modId, x, y );
break;
}
}
Int_t FindChannel(Int_t module, const TVector2 &position)
Finds the readout channel index for a given module stored in a given module index stored in the reado...

Once we found the readout channel, we can obtain the associated daq channel number, that was defined using the decoding file.

Int_t daqId = fReadout->GetReadoutPlane( planeId )
->GetModule( modId )
->GetChannel( chanId )->GetDaqID( );

The other way around we can obtain the corresponding x and y coordinates for a given daq channel id. The following code shows the basic idea to find signalId.

@code for( int p = 0; p < fReadout->GetNumberOfReadoutPlanes(); p++ ) { TRestDetectorReadoutPlane *plane = fReadout->GetReadoutPlane( p ); for( int m = 0; m < plane->GetNumberOfModules(); m++ ) { TRestDetectorReadoutModule *mod = plane->GetModule( m ); // We iterate over all readout modules searching for the one that contains our signal id if( mod->IsDaqIDInside( signalID ) ) { // If we find it we use the readoutModule id, and the signalId corresponding // to the physical readout channel and obtain the x,y coordinates. readoutChannelID = mod->DaqToReadoutChannel( signalID ); readoutModuleID = mod->GetModuleID(); x = plane->GetX( readoutModuleID, readoutChannelID ); y = plane->GetY( readoutModuleID, readoutChannelID ); break; } } } \endcode

RESTsoft - Software for Rare Event Searches with TPCs

History of developments:

2015-aug: First concept. Javier Galan

Author
Javier Galan

Definition at line 33 of file TRestDetectorReadout.h.

#include <TRestDetectorReadout.h>

Inheritance diagram for TRestDetectorReadout:
TRestMetadata

Public Member Functions

void AddReadoutPlane (const TRestDetectorReadoutPlane &plane)
 Adds a readout plane to the readout.
 
 ClassDefOverride (TRestDetectorReadout, 3)
 
void Draw ()
 Draws the readout on screen. Not yet implemented.
 
void Export (const std::string &fileName)
 Export readout to a root file.
 
std::set< Int_t > GetAllDaqIds ()
 
Int_t GetDaqId (const TVector3 &position, bool check=true)
 Returns the DaqID of the channel for position. If no channel is found returns -1.
 
Int_t GetHitsDaqChannel (const TVector3 &position, Int_t &planeID, Int_t &moduleID, Int_t &channelID)
 
std::tuple< Int_t, Int_t, Int_t > GetHitsDaqChannelAtReadoutPlane (const TVector3 &position, Int_t planeId=0)
 Returns a tuple with the DaqID, ModuleID, ChannelID. More...
 
Int_t GetModuleDefinitionId (const TString &name)
 Returns the id of the readout module with a given name.
 
Int_t GetNumberOfChannels ()
 Returns the total number of channels implemented in all the readout planes and modules.
 
Int_t GetNumberOfModules ()
 Returns the total number of modules implemented in all the readout planes.
 
Int_t GetNumberOfReadoutPlanes () const
 
void GetPlaneModuleChannel (Int_t daqID, Int_t &planeID, Int_t &moduleID, Int_t &channelID)
 
TRestDetectorReadoutChannelGetReadoutChannelWithDaqID (int daqId)
 Returns a pointer to the readout channel by daq id.
 
TRestDetectorReadoutModuleGetReadoutModuleWithID (int id)
 Returns a pointer to the readout module by ID. More...
 
TRestDetectorReadoutPlaneGetReadoutPlane (int p)
 Returns a pointer to the readout plane by index.
 
TRestDetectorReadoutPlaneGetReadoutPlaneWithID (int id)
 Returns a pointer to the readout plane by ID.
 
std::string GetTypeForChannelDaqId (Int_t daqId)
 
Double_t GetX (Int_t planeID, Int_t modID, Int_t chID)
 It returns the x-coordinate for the given readout plane, plane, a given module, modID, and a given channel, chID.
 
Double_t GetX (Int_t signalID)
 It returns the physical X-coordinate corresponding to a given signal id in plane coordinates.
 
Double_t GetY (Int_t planeID, Int_t modID, Int_t chID)
 It returns the y-coordinate for the given readout plane, plane, a given module, modID, and a given channel, chID.
 
Double_t GetY (Int_t signalID)
 It returns the physical Y-coordinate corresponding to a given signal id in plane coordinates.
 
TRestDetectorReadoutPlaneoperator[] (int p)
 
TRestDetectorReadoutModuleParseModuleDefinition (TiXmlElement *moduleDefinition)
 
void PrintMetadata () override
 Implemented it in the derived metadata class to print out specific metadata information. More...
 
void PrintMetadata (Int_t DetailLevel)
 Prints on screen the details about the readout definition. More...
 
 TRestDetectorReadout ()
 TRestDetectorReadout default constructor.
 
 TRestDetectorReadout (const char *configFilename)
 TRestDetectorReadout constructor loading data from a config file. More...
 
 TRestDetectorReadout (const char *configFilename, const std::string &name)
 TRestDetectorReadout constructor loading data from a config file. More...
 
 ~TRestDetectorReadout () override
 TRestDetectorReadout default destructor.
 

Private Member Functions

void InitFromConfigFile () override
 Initializes the readout members using the information given in the TRestDetectorReadout RML section.
 
void Initialize () override
 Initializes the readout members and defines the section name.
 
*TRestDetectorReadoutModule definitions *void ValidateReadout () const
 This method is not implemented yet. But it could do some checks to help verifying the readout.
 

Private Attributes

Int_t fMappingNodes
 
*coordinate mapping See also TRestDetectorReadoutMapping *std::vector< TRestDetectorReadoutModulefModuleDefinitions
 
std::vector< TRestDetectorReadoutPlanefReadoutPlanes
 A std::vector storing the TRestDetectorReadoutPlane definitions.
 

Additional Inherited Members

Constructor & Destructor Documentation

◆ TRestDetectorReadout() [1/2]

TRestDetectorReadout::TRestDetectorReadout ( const char *  configFilename)
explicit

TRestDetectorReadout constructor loading data from a config file.

If no configuration path was defined using TRestMetadata::SetConfigFilePath the path to the config file must be specified using full path, absolute or relative.

By default the config file must be specified with full path, absolute or relative.

First TRestDetectorReadout section occurrence will be loaded.

Parameters
configFilenameA const char* giving the path to an RML file.

Definition at line 311 of file src/TRestDetectorReadout.cxx.

◆ TRestDetectorReadout() [2/2]

TRestDetectorReadout::TRestDetectorReadout ( const char *  configFilename,
const std::string &  name 
)

TRestDetectorReadout constructor loading data from a config file.

If no configuration path was defined using TRestMetadata::SetConfigFilePath the path to the config file must be specified using full path, absolute or relative.

By default the config file must be specified with full path, absolute or relative.

Parameters
configFilenameA const char* giving the path to an RML file.
nameThe name of the TRestDetectorReadout section to be loaded

Definition at line 331 of file src/TRestDetectorReadout.cxx.

Member Function Documentation

◆ GetHitsDaqChannelAtReadoutPlane()

std::tuple< Int_t, Int_t, Int_t > TRestDetectorReadout::GetHitsDaqChannelAtReadoutPlane ( const TVector3 &  position,
Int_t  planeId = 0 
)

Returns a tuple with the DaqID, ModuleID, ChannelID.

This method recovers the channel daq id corresponding to the (x,y,z) coordinates given by argument. It will fill the value the corresponding moduleID, and channelID where the hit was found, while it will return the value of the daq channel id.

It will search only at the specified readout plane.

This method requires to specify the plane id where the readout channel is to be found. If not given, the default value will be planeId = 0.

Returns
the value of the daq id corresponding to the readout channel

Definition at line 728 of file src/TRestDetectorReadout.cxx.

◆ GetReadoutModuleWithID()

TRestDetectorReadoutModule * TRestDetectorReadout::GetReadoutModuleWithID ( int  id)

Returns a pointer to the readout module by ID.

e.g. micromegas M0 has id 0, M5 has id 5. The ID is Unique of all the readout mudules

Definition at line 409 of file src/TRestDetectorReadout.cxx.

◆ PrintMetadata() [1/2]

void TRestDetectorReadout::PrintMetadata ( )
inlineoverridevirtual

Implemented it in the derived metadata class to print out specific metadata information.

Prints metadata content on screen. Usually overloaded by the derived metadata class.

Reimplemented from TRestMetadata.

Definition at line 96 of file TRestDetectorReadout.h.

◆ PrintMetadata() [2/2]

void TRestDetectorReadout::PrintMetadata ( Int_t  DetailLevel)

Prints on screen the details about the readout definition.

Parameters
fullDetailPrints all modules, channels and pixels info.

Definition at line 825 of file src/TRestDetectorReadout.cxx.


The documentation for this class was generated from the following files: