CbmRoot
CbmMuchSegmentManual.h
Go to the documentation of this file.
1 
10 #ifndef CBMMUCHSEGMENTMANUAL_H
11 #define CBMMUCHSEGMENTMANUAL_H 1
12 
13 #include <Rtypes.h> // for THashConsistencyHolder, ClassDef
14 #include <RtypesCore.h> // for Int_t, Double_t, Bool_t, Char_t, Option_t
15 #include <TString.h> // for TString
16 
17 #include <fstream> // for string, getline, char_traits, basic_istream
18 #include <map> // for map
19 #include <typeinfo> // for bad_cast
20 #include <vector> // for vector
21 
22 #include <FairTask.h> // for FairTask, InitStatus
23 
24 class CbmGeoMuchPar;
25 class CbmMuchLayerSide;
28 class TObjArray;
29 
30 class CbmMuchSegmentManual : public FairTask {
31 
32 public:
35 
37  virtual ~CbmMuchSegmentManual();
38 
43  CbmMuchSegmentManual(char* inputFile, char* digiFileName);
44 
46  virtual InitStatus Init();
47 
49  void SegmentMuch();
50 
54  void SetNStations(Int_t nStations) { fNStations = nStations; }
55 
60  void SetNRegions(Int_t iStation, Int_t nRegions);
61 
67  void SetRegionRadius(Int_t iStation, Int_t iRegion, Double_t radius);
68 
73  void SetNChannels(Int_t iStation, Int_t nChannels);
74 
81  void
82  SetSigma(Int_t iStation, Int_t iRegion, Double_t sigmaX, Double_t sigmaY);
83 
90  void
91  SetPadSize(Int_t iStation, Int_t iRegion, Double_t padLx, Double_t padLy);
92 
93  void DebugSwitchOn() { fDebug = 1; }
94 
95 private:
96  CbmGeoMuchPar* fGeoPar; // Geometry parameters container
97  Int_t fNStations; // Number of stations
98  TObjArray* fStations; // Array of stations
99  Char_t* fInputFileName; // Name of the file with input parameters
100  Char_t* fDigiFileName; // Name of the file with segmentation parameters
101  std::map<Int_t, Int_t>
102  fNRegions; // Map from a station index to a number of circled regions in the station
103  std::map<Int_t, std::vector<Double_t>>
104  fRadii; // Map from a station index to a vector of circled regions radii
105  std::map<Int_t, std::vector<Double_t>>
106  fSecLx; // Map from a station index to a vector of sector widths for each region
107  std::map<Int_t, std::vector<Double_t>>
108  fSecLy; // Map from a station index to a vector of sector lengths for each region
109  std::map<Int_t, Int_t>
110  fNChannels; // Map from a station index to a number of channels per sector
111  std::map<Int_t, std::vector<Int_t>>
112  fNCols; // Map from a station index to a vector of number of columns in a sector
113  std::map<Int_t, std::vector<Int_t>>
114  fNRows; // Map from a station index to a vector of number of rows in a sector
115  Int_t fDebug; // Debug info switch
116 
118  virtual void SetParContainers();
119 
127  Int_t IntersectsRad(CbmMuchModuleGemRectangular* module, Double_t radius);
128 
136  Int_t IntersectsRad(CbmMuchSectorRectangular* sector, Double_t radius);
137 
142  void SegmentLayerSide(CbmMuchLayerSide* layerSide);
143 
150  Bool_t useModuleDesign);
151 
158  CbmMuchSectorRectangular* sector);
159 
169  const TString side,
170  Int_t& iRegion);
171 
180  const TString side);
181 
190  const TString direction,
191  Int_t& iRegion);
192 
199 
205 
207  void DrawSegmentation();
208 
210  void Print(Option_t* = "") const;
211 
213  void ReadInputFile();
214 
215 
216  // -------------------- Methods for working with strings --------------------------
217  void Trim(std::string& str) {
218  std::string::size_type pos1 = str.find_first_not_of(' ');
219  std::string::size_type pos2 = str.find_last_not_of(' ');
220  str = str.substr(pos1 == std::string::npos ? 0 : pos1,
221  pos2 == std::string::npos ? str.length() - 1
222  : pos2 - pos1 + 1);
223  }
224 
225  Bool_t IsDummyLine(std::string& str) {
226  Trim(str);
227  return str[0] == '#' || str.length() == 0 || str[0] == '\0'
228  || str[0] == '\n';
229  }
230 
231  void OmitDummyLines(std::ifstream& infile, std::string& str) {
232  getline(infile, str);
233  while (IsDummyLine(str))
234  getline(infile, str);
235  }
236 
237  std::vector<std::string>&
238  Split(const std::string& s, char delim, std::vector<std::string>& elems) {
239  std::stringstream ss(s);
240  std::string item;
241  while (getline(ss, item, delim)) {
242  if (item.length() != 0) elems.push_back(item);
243  }
244  return elems;
245  }
246 
247 
248  std::vector<std::string> Split(const std::string& s, char delim) {
249  std::vector<std::string> elems;
250  return Split(s, delim, elems);
251  }
252 
253  template<class T>
254  void StrToNum(std::string& str, T& number) {
255  try {
256  std::stringstream ss(str);
257  if ((ss >> number).fail() || !(ss >> std::ws).eof())
258  throw std::bad_cast();
259  } catch (std::bad_cast exc) { Fatal("", "Invalid cast.\n"); }
260  }
261  // --------------------------------------------------------------------------------
262 
265 
266  ClassDef(CbmMuchSegmentManual, 1)
267 };
268 
269 #endif
CbmMuchSegmentManual::GetPadMaxSize
Double_t GetPadMaxSize(CbmMuchModuleGemRectangular *module, const TString side)
Definition: CbmMuchSegmentManual.cxx:650
CbmMuchSegmentManual::operator=
CbmMuchSegmentManual & operator=(const CbmMuchSegmentManual &)
CbmMuchSegmentManual::fSecLy
std::map< Int_t, std::vector< Double_t > > fSecLy
Definition: CbmMuchSegmentManual.h:108
CbmMuchSegmentManual::DebugSwitchOn
void DebugSwitchOn()
Definition: CbmMuchSegmentManual.h:93
CbmMuchSegmentManual::GetSectorMaxSize
Double_t GetSectorMaxSize(CbmMuchModuleGemRectangular *module, const TString side, Int_t &iRegion)
Definition: CbmMuchSegmentManual.cxx:630
CbmMuchSegmentManual::ShouldSegment
Bool_t ShouldSegment(CbmMuchSectorRectangular *sector, const TString direction, Int_t &iRegion)
Definition: CbmMuchSegmentManual.cxx:566
CbmMuchSegmentManual::SegmentModule
void SegmentModule(CbmMuchModuleGemRectangular *module, Bool_t useModuleDesign)
Definition: CbmMuchSegmentManual.cxx:297
CbmMuchSegmentManual::SegmentSector
void SegmentSector(CbmMuchModuleGemRectangular *module, CbmMuchSectorRectangular *sector)
Definition: CbmMuchSegmentManual.cxx:415
CbmMuchSegmentManual::fNChannels
std::map< Int_t, Int_t > fNChannels
Definition: CbmMuchSegmentManual.h:110
CbmMuchSegmentManual::Split
std::vector< std::string > & Split(const std::string &s, char delim, std::vector< std::string > &elems)
Definition: CbmMuchSegmentManual.h:238
CbmMuchSegmentManual::ReadInputFile
void ReadInputFile()
Definition: CbmMuchSegmentManual.cxx:897
CbmMuchSegmentManual::DrawSegmentation
void DrawSegmentation()
Definition: CbmMuchSegmentManual.cxx:796
CbmGeoMuchPar
Definition: CbmGeoMuchPar.h:25
CbmMuchSegmentManual::SetNStations
void SetNStations(Int_t nStations)
Definition: CbmMuchSegmentManual.h:54
CbmMuchSegmentManual::fNCols
std::map< Int_t, std::vector< Int_t > > fNCols
Definition: CbmMuchSegmentManual.h:112
CbmMuchModuleGemRectangular
Definition: CbmMuchModuleGemRectangular.h:20
CbmMuchSegmentManual::GetRegionIndex
Int_t GetRegionIndex(CbmMuchSectorRectangular *sector)
Definition: CbmMuchSegmentManual.cxx:600
CbmMuchSegmentManual::Init
virtual InitStatus Init()
Definition: CbmMuchSegmentManual.cxx:214
CbmMuchSegmentManual
Definition: CbmMuchSegmentManual.h:30
CbmMuchSegmentManual::~CbmMuchSegmentManual
virtual ~CbmMuchSegmentManual()
Definition: CbmMuchSegmentManual.cxx:78
CbmMuchSegmentManual::SetNRegions
void SetNRegions(Int_t iStation, Int_t nRegions)
Definition: CbmMuchSegmentManual.cxx:82
CbmMuchSegmentManual::fGeoPar
CbmGeoMuchPar * fGeoPar
Definition: CbmMuchSegmentManual.h:96
CbmMuchSegmentManual::Print
void Print(Option_t *="") const
Definition: CbmMuchSegmentManual.cxx:681
CbmMuchSegmentManual::SetNChannels
void SetNChannels(Int_t iStation, Int_t nChannels)
Definition: CbmMuchSegmentManual.cxx:118
CbmMuchSegmentManual::CbmMuchSegmentManual
CbmMuchSegmentManual(const CbmMuchSegmentManual &)
CbmMuchSectorRectangular
Definition: CbmMuchSectorRectangular.h:24
CbmMuchSegmentManual::SetParContainers
virtual void SetParContainers()
Definition: CbmMuchSegmentManual.cxx:205
CbmMuchSegmentManual::fRadii
std::map< Int_t, std::vector< Double_t > > fRadii
Definition: CbmMuchSegmentManual.h:104
CbmMuchSegmentManual::SegmentMuch
void SegmentMuch()
Definition: CbmMuchSegmentManual.cxx:249
CbmMuchLayerSide
Definition: CbmMuchLayerSide.h:22
CbmMuchSegmentManual::SegmentLayerSide
void SegmentLayerSide(CbmMuchLayerSide *layerSide)
Definition: CbmMuchSegmentManual.cxx:281
CbmMuchSegmentManual::IsIncompleteSector
Bool_t IsIncompleteSector(CbmMuchSectorRectangular *sector)
Definition: CbmMuchSegmentManual.cxx:662
CbmMuchSegmentManual::SetRegionRadius
void SetRegionRadius(Int_t iStation, Int_t iRegion, Double_t radius)
Definition: CbmMuchSegmentManual.cxx:131
CbmMuchSegmentManual::fDigiFileName
Char_t * fDigiFileName
Definition: CbmMuchSegmentManual.h:100
CbmMuchSegmentManual::fSecLx
std::map< Int_t, std::vector< Double_t > > fSecLx
Definition: CbmMuchSegmentManual.h:106
CbmMuchSegmentManual::fNRegions
std::map< Int_t, Int_t > fNRegions
Definition: CbmMuchSegmentManual.h:102
CbmMuchSegmentManual::Split
std::vector< std::string > Split(const std::string &s, char delim)
Definition: CbmMuchSegmentManual.h:248
CbmMuchSegmentManual::Trim
void Trim(std::string &str)
Definition: CbmMuchSegmentManual.h:217
CbmMuchSegmentManual::fStations
TObjArray * fStations
Definition: CbmMuchSegmentManual.h:98
CbmMuchSegmentManual::fNRows
std::map< Int_t, std::vector< Int_t > > fNRows
Definition: CbmMuchSegmentManual.h:114
CbmMuchSegmentManual::IsDummyLine
Bool_t IsDummyLine(std::string &str)
Definition: CbmMuchSegmentManual.h:225
CbmMuchSegmentManual::fDebug
Int_t fDebug
Definition: CbmMuchSegmentManual.h:115
CbmMuchSegmentManual::fInputFileName
Char_t * fInputFileName
Definition: CbmMuchSegmentManual.h:99
CbmMuchSegmentManual::StrToNum
void StrToNum(std::string &str, T &number)
Definition: CbmMuchSegmentManual.h:254
CbmMuchSegmentManual::SetSigma
void SetSigma(Int_t iStation, Int_t iRegion, Double_t sigmaX, Double_t sigmaY)
Definition: CbmMuchSegmentManual.cxx:149
CbmMuchSegmentManual::OmitDummyLines
void OmitDummyLines(std::ifstream &infile, std::string &str)
Definition: CbmMuchSegmentManual.h:231
CbmMuchSegmentManual::CbmMuchSegmentManual
CbmMuchSegmentManual()
Definition: CbmMuchSegmentManual.cxx:41
CbmMuchSegmentManual::fNStations
Int_t fNStations
Definition: CbmMuchSegmentManual.h:97
CbmMuchSegmentManual::IntersectsRad
Int_t IntersectsRad(CbmMuchModuleGemRectangular *module, Double_t radius)
Definition: CbmMuchSegmentManual.cxx:498
CbmMuchSegmentManual::SetPadSize
void SetPadSize(Int_t iStation, Int_t iRegion, Double_t padLx, Double_t padLy)
Definition: CbmMuchSegmentManual.cxx:177