ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtMap.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Base class for Active Targets AtMap.h *
3  * Author: Y. Ayyad ayyadlim@frib.msu.edu *
4  * Log: 2/22/2021 *
5  * *
6  *********************************************************************/
7 
8 #ifndef ATMAP_H
9 #define ATMAP_H
10 
11 #include "AtPadReference.h"
12 
13 #include <Math/Point2Dfwd.h> // for XYPoint
14 #include <Rtypes.h>
15 #include <TNamed.h>
16 #include <TString.h>
17 
18 #include <boost/multi_array.hpp>
19 
20 #include <functional>
21 #include <iosfwd>
22 #include <map>
23 #include <string>
24 #include <unordered_map>
25 
26 class TH2Poly;
27 class TXMLNode;
28 class TBuffer;
29 class TCanvas;
30 class TClass;
31 class TMemberInspector;
32 
33 class AtMap : public TNamed {
34 public:
35  enum class InhibitType; // forward declare of enum
36 
37 protected:
38  typedef boost::multi_array<double, 3> multiarray;
39  typedef multiarray::index index;
40 
43  Bool_t kIsParsed = false; //< True if the input file is parsed
44  Bool_t kDebug = false;
45  std::unordered_map<AtPadReference, AtMap::InhibitType> fIniPads;
46  TCanvas *fPadPlaneCanvas{}; // Raw pointer because owned by gROOT
47  TH2Poly *fPadPlane; // Raw pointer because owned by gDirectory
48  UInt_t fNumberPads{};
49 
50  std::unordered_map<AtPadReference, int> fPadMap;
51  std::map<int, AtPadReference> fPadMapInverse;
52  std::unordered_map<AtPadReference, std::string> fAuxPadMap;
53  std::map<int, int> fPadSizeMap;
54 
55  void drawPadPlane();
56 
57 public:
58  AtMap();
59  ~AtMap() = default;
60 
61  virtual void Dump() = 0;
65  virtual void GeneratePadPlane() = 0;
66  virtual ROOT::Math::XYPoint CalcPadCenter(Int_t PadRef) = 0; // units mm
67 
70  TH2Poly *GetPadPlane();
71  virtual Int_t BinToPad(Int_t binval) = 0;
72 
73  UInt_t GetNumPads() const { return fNumberPads; }
74 
75  Int_t GetPadNum(const AtPadReference &PadRef) const;
76  Int_t GetPadNum(ROOT::Math::XYPoint point);
77 
80 
81  Bool_t ParseXMLMap(Char_t const *xmlfile);
82  void ParseMapList(TXMLNode *node);
83  void ParseAtTPCMap(TXMLNode *node);
84  Bool_t DumpAtTPCMap();
85  AtPadReference GetPadRef(int padNum) const;
86  bool AddAuxPad(const AtPadReference &ref, std::string auxName);
87  bool IsAuxPad(const AtPadReference &ref) const;
88  bool IsFPNchannel(const AtPadReference &ref) const;
89  AtPadReference GetNearestFPN(int padNum) const;
91 
92  std::string GetAuxName(const AtPadReference &ref) const;
93 
94  inline void SetDebugMode(Bool_t flag = true) { kDebug = flag; }
95  Bool_t ParseInhibitMap(TString inimap, AtMap::InhibitType type);
96  void InhibitPad(Int_t padNum, AtMap::InhibitType type) { InhibitPad(GetPadRef(padNum), type); }
97  void InhibitPad(AtPadReference padRef, AtMap::InhibitType type);
98  AtMap::InhibitType IsInhibited(Int_t PadNum) { return IsInhibited(GetPadRef(PadNum)); }
100  Int_t GetPadSize(int padNum);
101 
102 #pragma GCC diagnostic push
103  // Ignore shadow warning when we shadow ROOT's global GuiTypes enum
104 #pragma GCC diagnostic ignored "-Wshadow"
105 
106  // The higher the number, the higher the priority
107  // i.e. Adding a pad to the inhibit map with kTotal and kLowGain
108  // will inhibit the pad. kLowGain and kXTalk will be kXTalk
109  enum class InhibitType { kNone = 0, kLowGain = 1, kXTalk = 2, kTotal = 3, kBadPad = 4 };
110 #pragma GCC diagnostic pop
111 
113 };
114 
115 std::ostream &operator<<(std::ostream &os, const AtMap::InhibitType &t);
116 #endif
AtMap::InhibitType::kBadPad
@ kBadPad
AtMap
Definition: AtMap.h:33
AtMap::IsAuxPad
bool IsAuxPad(const AtPadReference &ref) const
Definition: AtMap.cxx:270
AtMap::GetPadPlane
TH2Poly * GetPadPlane()
Definition: AtMap.cxx:70
AtMap::InhibitPad
void InhibitPad(Int_t padNum, AtMap::InhibitType type)
Definition: AtMap.h:96
AtPadReference.h
AtMap::fAtPadCoordPtr
multiarray * fAtPadCoordPtr
Definition: AtMap.h:42
AtMap::AtMap
AtMap()
Definition: AtMap.cxx:43
AtMap::GetPadCoordArr
multiarray GetPadCoordArr()
Definition: AtMap.h:78
AtMap::ParseXMLMap
Bool_t ParseXMLMap(Char_t const *xmlfile)
Definition: AtMap.cxx:219
AtMap::fPadPlaneCanvas
TCanvas * fPadPlaneCanvas
Definition: AtMap.h:46
AtMap::multiarray
boost::multi_array< double, 3 > multiarray
Definition: AtMap.h:35
XYPoint
ROOT::Math::XYPoint XYPoint
Definition: AtPatternCircle2D.cxx:16
AtMap::DumpAtTPCMap
Bool_t DumpAtTPCMap()
Definition: AtMap.cxx:240
AtMap::GetPadNum
Int_t GetPadNum(const AtPadReference &PadRef) const
Definition: AtMap.cxx:89
node
Definition: fastcluster_dm.cxx:213
AtMap::ParseInhibitMap
Bool_t ParseInhibitMap(TString inimap, AtMap::InhibitType type)
Definition: AtMap.cxx:111
AtMap::ParseAtTPCMap
void ParseAtTPCMap(TXMLNode *node)
Definition: AtMap.cxx:158
AtMap::ClassDefOverride
ClassDefOverride(AtMap, 5)
AtMap::fAuxPadMap
std::unordered_map< AtPadReference, std::string > fAuxPadMap
Definition: AtMap.h:52
AtMap::SetDebugMode
void SetDebugMode(Bool_t flag=true)
Definition: AtMap.h:94
AtMap::kDebug
Bool_t kDebug
Definition: AtMap.h:44
operator<<
std::ostream & operator<<(std::ostream &os, const AtMap::InhibitType &t)
Definition: AtMap.cxx:31
AtMap::AtPadCoord
multiarray AtPadCoord
Definition: AtMap.h:41
AtMap::fNumberPads
UInt_t fNumberPads
Definition: AtMap.h:48
AtMap::InhibitType::kLowGain
@ kLowGain
AtMap::kIsParsed
Bool_t kIsParsed
Definition: AtMap.h:43
AtMap::InhibitType
InhibitType
Definition: AtMap.h:109
AtMap::fPadMap
std::unordered_map< AtPadReference, int > fPadMap
Definition: AtMap.h:50
AtMap::drawPadPlane
void drawPadPlane()
Definition: AtMap.cxx:288
AtMap::GetNumPads
UInt_t GetNumPads() const
Definition: AtMap.h:73
AtMap::GetNearestFPN
AtPadReference GetNearestFPN(int padNum) const
Definition: AtMap.cxx:45
AtMap::GetPadCoord
multiarray * GetPadCoord()
Definition: AtMap.h:79
AtMap::fPadSizeMap
std::map< int, int > fPadSizeMap
Definition: AtMap.h:53
AtMap::InhibitType::kXTalk
@ kXTalk
AtMap::InhibitType::kNone
@ kNone
AtMap::InhibitType::kTotal
@ kTotal
AtMap::~AtMap
~AtMap()=default
AtMap::Dump
virtual void Dump()=0
AtMap::index
multiarray::index index
Definition: AtMap.h:39
AtMap::CalcPadCenter
virtual ROOT::Math::XYPoint CalcPadCenter(Int_t PadRef)=0
AtMap::BinToPad
virtual Int_t BinToPad(Int_t binval)=0
AtMap::fIniPads
std::unordered_map< AtPadReference, AtMap::InhibitType > fIniPads
Definition: AtMap.h:45
AtMap::GeneratePadPlane
virtual void GeneratePadPlane()=0
AtMap::IsFPNchannel
bool IsFPNchannel(const AtPadReference &ref) const
Definition: AtMap.cxx:65
AtPadReference
Definition: AtPadReference.h:20
AtMap::fPadMapInverse
std::map< int, AtPadReference > fPadMapInverse
Definition: AtMap.h:51
AtMap::AddAuxPad
bool AddAuxPad(const AtPadReference &ref, std::string auxName)
Definition: AtMap.cxx:262
AtMap::GetAuxName
std::string GetAuxName(const AtPadReference &ref) const
Definition: AtMap.cxx:274
AtMap::ParseMapList
void ParseMapList(TXMLNode *node)
Definition: AtMap.cxx:191
AtMap::GetPadRef
AtPadReference GetPadRef(int padNum) const
Definition: AtMap.cxx:281
AtMap::GetPadSize
Int_t GetPadSize(int padNum)
Definition: AtMap.cxx:152
AtMap::fPadPlane
TH2Poly * fPadPlane
Definition: AtMap.h:47
AtMap::IsInhibited
AtMap::InhibitType IsInhibited(Int_t PadNum)
Definition: AtMap.h:98