REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorReadout.h
1 /*************************************************************************
2  * This file is part of the REST software framework. *
3  * *
4  * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5  * For more information see http://gifna.unizar.es/trex *
6  * *
7  * REST is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * REST is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have a copy of the GNU General Public License along with *
18  * REST in $REST_PATH/LICENSE. *
19  * If not, see http://www.gnu.org/licenses/. *
20  * For the list of contributors see $REST_PATH/CREDITS. *
21  *************************************************************************/
22 
23 #ifndef RestCore_TRestDetectorReadout
24 #define RestCore_TRestDetectorReadout
25 
26 #include <TRestMetadata.h>
27 
28 #include <iostream>
29 
30 #include "TRestDetectorReadoutPlane.h"
31 
34  private:
35  void InitFromConfigFile() override;
36 
37  void Initialize() override;
38 
39  std::vector<TRestDetectorReadoutPlane>
41 
42  Int_t fMappingNodes;
44  std::vector<TRestDetectorReadoutModule> fModuleDefinitions;
46 
47  void ValidateReadout() const;
48 
49  public:
50  TRestDetectorReadoutPlane& operator[](int p) { return fReadoutPlanes[p]; }
51 
53  void AddReadoutPlane(const TRestDetectorReadoutPlane& plane);
54 
60 
61  Int_t GetNumberOfReadoutPlanes() const { return fReadoutPlanes.size(); }
62  Int_t GetNumberOfModules();
63  Int_t GetNumberOfChannels();
64 
65  Int_t GetModuleDefinitionId(const TString& name);
66 
68  TRestDetectorReadoutModule* ParseModuleDefinition(TiXmlElement* moduleDefinition);
69  void GetPlaneModuleChannel(Int_t daqID, Int_t& planeID, Int_t& moduleID, Int_t& channelID);
70  Int_t GetHitsDaqChannel(const TVector3& position, Int_t& planeID, Int_t& moduleID, Int_t& channelID);
71 
73  std::tuple<Int_t, Int_t, Int_t> GetHitsDaqChannelAtReadoutPlane(const TVector3& position,
74  Int_t planeId = 0);
75 
77  Int_t GetDaqId(const TVector3& position, bool check = true);
78 
79  std::string GetTypeForChannelDaqId(Int_t daqId);
80 
81  std::set<Int_t> GetAllDaqIds();
82 
83  Double_t GetX(Int_t signalID);
84  Double_t GetY(Int_t signalID);
86 
87  Double_t GetX(Int_t planeID, Int_t modID, Int_t chID);
88  Double_t GetY(Int_t planeID, Int_t modID, Int_t chID);
89 
90  // Detail Level:
91  // 0->this readout
92  // 1->+all readout plane
93  // 2->+all readout module
94  // 3->+all readout channel
95  // 4->+all readout pixel
96  inline void PrintMetadata() override { PrintMetadata(1); }
97  void PrintMetadata(Int_t DetailLevel);
98 
99  void Draw();
100 
101  void Export(const std::string& fileName);
102 
103  // Constructor
105  explicit TRestDetectorReadout(const char* configFilename);
106  TRestDetectorReadout(const char* configFilename, const std::string& name);
107  // Destructor
109 
110  ClassDefOverride(TRestDetectorReadout, 3);
111 };
112 #endif
A metadata class to generate/store a readout description.
std::vector< TRestDetectorReadoutPlane > fReadoutPlanes
A std::vector storing the TRestDetectorReadoutPlane definitions.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
Int_t GetNumberOfChannels()
Returns the total number of channels implemented in all the readout planes and modules.
~TRestDetectorReadout() override
TRestDetectorReadout default destructor.
void AddReadoutPlane(const TRestDetectorReadoutPlane &plane)
Adds a readout plane to the readout.
TRestDetectorReadoutPlane * GetReadoutPlane(int p)
Returns a pointer to the readout plane by index.
TRestDetectorReadoutPlane * GetReadoutPlaneWithID(int id)
Returns a pointer to the readout plane by ID.
Double_t GetY(Int_t signalID)
It returns the physical Y-coordinate corresponding to a given signal id in plane coordinates.
TRestDetectorReadout()
TRestDetectorReadout default constructor.
void InitFromConfigFile() override
Initializes the readout members using the information given in the TRestDetectorReadout RML section.
void Export(const std::string &fileName)
Export readout to a root file.
TRestDetectorReadoutModule * GetReadoutModuleWithID(int id)
Returns a pointer to the readout module by ID.
Double_t GetX(Int_t signalID)
It returns the physical X-coordinate corresponding to a given signal id in plane coordinates.
Int_t GetNumberOfModules()
Returns the total number of modules implemented in all the readout planes.
std::tuple< Int_t, Int_t, Int_t > GetHitsDaqChannelAtReadoutPlane(const TVector3 &position, Int_t planeId=0)
Returns a tuple with the DaqID, ModuleID, ChannelID.
TRestDetectorReadoutChannel * GetReadoutChannelWithDaqID(int daqId)
Returns a pointer to the readout channel by daq id.
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.
void Draw()
Draws the readout on screen. Not yet implemented.
Int_t GetModuleDefinitionId(const TString &name)
Returns the id of the readout module with a given name.
Int_t GetDaqId(const TVector3 &position, bool check=true)
Returns the DaqID of the channel for position. If no channel is found returns -1.
A base class for any REST metadata class.
Definition: TRestMetadata.h:74