CbmRoot
CbmMuchSegmentSector.h
Go to the documentation of this file.
1 
12 #ifndef CbmMuchSegmentSector_H
13 #define CbmMuchSegmentSector_H 1
14 
15 #include <Rtypes.h> // for THashConsistencyHolder, ClassDef
16 #include <RtypesCore.h> // for Int_t, Double_t, Bool_t
17 #include <TString.h> // for TString
18 
19 #include <fstream> // for string, getline, char_traits, basic_istream
20 #include <map> // for map
21 #include <typeinfo> // for bad_cast
22 #include <vector> // for vector
23 
24 #include <FairTask.h> // for FairTask, InitStatus
25 
26 class CbmGeoMuchPar;
27 class CbmMuchLayerSide;
30 class TObjArray;
31 
32 class CbmMuchSegmentSector : public FairTask {
33 
34 public:
37 
39  virtual ~CbmMuchSegmentSector();
40 
46  CbmMuchSegmentSector(TString inputFile, TString digiFileName, Int_t flag);
47 
49  virtual InitStatus Init();
50 
52  void SegmentMuch();
53 
54  void DebugSwitchOn() { fDebug = 1; }
55 
56 private:
57  CbmGeoMuchPar* fGeoPar; // Geometry parameters container
58  Int_t fNStations; // Number of stations
59  Int_t fFlag; // falg for geometry
60  TObjArray* fStations; // Array of stations
61  TString fInputFileName; // Name of the file with input parameters
62  TString fDigiFileName; // Name of the file with segmentation parameters
63  std::map<Int_t, Int_t>
64  fNRegions; // Map from a station index to a number of circled regions in the station
65  std::map<Int_t, std::vector<Double_t>>
66  fRadii; // Map from a station index to a vector of circled regions radii
67  std::map<Int_t, std::vector<Double_t>>
68  fAngles; // Map from a station index to a vector of single pad angles for given regions
69  std::map<Int_t, std::vector<Double_t>>
70  fSecLx; // Map from a station index to a vector of sector widths for each region
71  std::map<Int_t, std::vector<Double_t>>
72  fSecLy; // Map from a station index to a vector of sector lengths for each region
73  std::map<Int_t, Int_t>
74  fNChannels; // Map from a station index to a number of channels per sector
75  std::map<Int_t, std::vector<Int_t>>
76  fNCols; // Map from a station index to a vector of number of columns in a sector
77  std::map<Int_t, std::vector<Int_t>>
78  fNRows; // Map from a station index to a vector of number of rows in a sector
79  Int_t fDebug; // Debug info switch
80 
82  virtual void SetParContainers();
83 
89  Int_t SegmentLayerSide(CbmMuchLayerSide* layerSide);
90 
96  Int_t SegmentModule(CbmMuchModuleGemRadial* module, Bool_t useModuleDesign);
97 
104  CbmMuchSectorRadial* sector);
105 
107  void ReadInputFile();
108 
110  void DrawSegmentation();
111 
112  // -------------------- Methods for working with strings --------------------------
113  void Trim(std::string& str) {
114  std::string::size_type pos1 = str.find_first_not_of(' ');
115  std::string::size_type pos2 = str.find_last_not_of(' ');
116  str = str.substr(pos1 == std::string::npos ? 0 : pos1,
117  pos2 == std::string::npos ? str.length() - 1
118  : pos2 - pos1 + 1);
119  }
120 
121  Bool_t IsDummyLine(std::string& str) {
122  Trim(str);
123  return str[0] == '#' || str.length() == 0 || str[0] == '\0'
124  || str[0] == '\n';
125  }
126 
127  void OmitDummyLines(std::ifstream& infile, std::string& str) {
128  getline(infile, str);
129  while (IsDummyLine(str))
130  getline(infile, str);
131  }
132 
133  std::vector<std::string>&
134  Split(const std::string& s, char delim, std::vector<std::string>& elems) {
135  std::stringstream ss(s);
136  std::string item;
137  while (getline(ss, item, delim)) {
138  if (item.length() != 0) elems.push_back(item);
139  }
140  return elems;
141  }
142 
143 
144  std::vector<std::string> Split(const std::string& s, char delim) {
145  std::vector<std::string> elems;
146  return Split(s, delim, elems);
147  }
148 
149  template<class T>
150  void StrToNum(std::string& str, T& number) {
151  try {
152  std::stringstream ss(str);
153  if ((ss >> number).fail() || !(ss >> std::ws).eof())
154  throw std::bad_cast();
155  } catch (std::bad_cast exc) { Fatal("", "Invalid cast.\n"); }
156  }
157  // --------------------------------------------------------------------------------
158 
161 
162  ClassDef(CbmMuchSegmentSector, 1)
163 };
164 
165 #endif
CbmMuchSegmentSector::DrawSegmentation
void DrawSegmentation()
Definition: CbmMuchSegmentSector.cxx:304
CbmMuchSegmentSector::fAngles
std::map< Int_t, std::vector< Double_t > > fAngles
Definition: CbmMuchSegmentSector.h:68
CbmMuchSegmentSector::StrToNum
void StrToNum(std::string &str, T &number)
Definition: CbmMuchSegmentSector.h:150
CbmMuchSegmentSector::fNChannels
std::map< Int_t, Int_t > fNChannels
Definition: CbmMuchSegmentSector.h:74
CbmMuchSegmentSector::fNStations
Int_t fNStations
Definition: CbmMuchSegmentSector.h:58
CbmMuchSectorRadial
Definition: CbmMuchSectorRadial.h:19
CbmMuchSegmentSector::fRadii
std::map< Int_t, std::vector< Double_t > > fRadii
Definition: CbmMuchSegmentSector.h:66
CbmMuchSegmentSector
Definition: CbmMuchSegmentSector.h:32
CbmMuchSegmentSector::SegmentMuch
void SegmentMuch()
Definition: CbmMuchSegmentSector.cxx:128
CbmMuchSegmentSector::fFlag
Int_t fFlag
Definition: CbmMuchSegmentSector.h:59
CbmMuchSegmentSector::fDigiFileName
TString fDigiFileName
Definition: CbmMuchSegmentSector.h:62
CbmMuchSegmentSector::fStations
TObjArray * fStations
Definition: CbmMuchSegmentSector.h:60
CbmMuchSegmentSector::operator=
CbmMuchSegmentSector & operator=(const CbmMuchSegmentSector &)
CbmMuchSegmentSector::CbmMuchSegmentSector
CbmMuchSegmentSector(const CbmMuchSegmentSector &)
CbmGeoMuchPar
Definition: CbmGeoMuchPar.h:25
CbmMuchSegmentSector::Split
std::vector< std::string > & Split(const std::string &s, char delim, std::vector< std::string > &elems)
Definition: CbmMuchSegmentSector.h:134
CbmMuchSegmentSector::OmitDummyLines
void OmitDummyLines(std::ifstream &infile, std::string &str)
Definition: CbmMuchSegmentSector.h:127
CbmMuchModuleGemRadial
Definition: CbmMuchModuleGemRadial.h:21
CbmMuchSegmentSector::ReadInputFile
void ReadInputFile()
Definition: CbmMuchSegmentSector.cxx:247
CbmMuchSegmentSector::fGeoPar
CbmGeoMuchPar * fGeoPar
Definition: CbmMuchSegmentSector.h:57
CbmMuchSegmentSector::fDebug
Int_t fDebug
Definition: CbmMuchSegmentSector.h:79
CbmMuchSegmentSector::fInputFileName
TString fInputFileName
Definition: CbmMuchSegmentSector.h:61
CbmMuchLayerSide
Definition: CbmMuchLayerSide.h:22
CbmMuchSegmentSector::DebugSwitchOn
void DebugSwitchOn()
Definition: CbmMuchSegmentSector.h:54
CbmMuchSegmentSector::SegmentModule
Int_t SegmentModule(CbmMuchModuleGemRadial *module, Bool_t useModuleDesign)
Definition: CbmMuchSegmentSector.cxx:181
CbmMuchSegmentSector::fNRows
std::map< Int_t, std::vector< Int_t > > fNRows
Definition: CbmMuchSegmentSector.h:78
CbmMuchSegmentSector::SetParContainers
virtual void SetParContainers()
Definition: CbmMuchSegmentSector.cxx:88
CbmMuchSegmentSector::fSecLx
std::map< Int_t, std::vector< Double_t > > fSecLx
Definition: CbmMuchSegmentSector.h:70
CbmMuchSegmentSector::SegmentLayerSide
Int_t SegmentLayerSide(CbmMuchLayerSide *layerSide)
Definition: CbmMuchSegmentSector.cxx:160
CbmMuchSegmentSector::fSecLy
std::map< Int_t, std::vector< Double_t > > fSecLy
Definition: CbmMuchSegmentSector.h:72
CbmMuchSegmentSector::Split
std::vector< std::string > Split(const std::string &s, char delim)
Definition: CbmMuchSegmentSector.h:144
CbmMuchSegmentSector::fNCols
std::map< Int_t, std::vector< Int_t > > fNCols
Definition: CbmMuchSegmentSector.h:76
CbmMuchSegmentSector::SegmentSector
void SegmentSector(CbmMuchModuleGemRadial *module, CbmMuchSectorRadial *sector)
CbmMuchSegmentSector::~CbmMuchSegmentSector
virtual ~CbmMuchSegmentSector()
Definition: CbmMuchSegmentSector.cxx:84
CbmMuchSegmentSector::Trim
void Trim(std::string &str)
Definition: CbmMuchSegmentSector.h:113
CbmMuchSegmentSector::IsDummyLine
Bool_t IsDummyLine(std::string &str)
Definition: CbmMuchSegmentSector.h:121
CbmMuchSegmentSector::Init
virtual InitStatus Init()
Definition: CbmMuchSegmentSector.cxx:97
CbmMuchSegmentSector::fNRegions
std::map< Int_t, Int_t > fNRegions
Definition: CbmMuchSegmentSector.h:64
CbmMuchSegmentSector::CbmMuchSegmentSector
CbmMuchSegmentSector()
Definition: CbmMuchSegmentSector.cxx:42