CbmRoot
Loading...
Searching...
No Matches
CbmMuchSegmentManual.h
Go to the documentation of this file.
1/* Copyright (C) 2009-2020 St. Petersburg Polytechnic University, St. Petersburg
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Mikhail Ryzhinskiy [committer], Florian Uhlig */
4
14#ifndef CBMMUCHSEGMENTMANUAL_H
15#define CBMMUCHSEGMENTMANUAL_H 1
16
17#include <FairTask.h> // for FairTask, InitStatus
18
19#include <Rtypes.h> // for THashConsistencyHolder, ClassDef
20#include <RtypesCore.h> // for Int_t, Double_t, Bool_t, Char_t, Option_t
21#include <TString.h> // for TString
22
23#include <fstream> // for string, getline, char_traits, basic_istream
24#include <map> // for map
25#include <sstream> // for stringstream
26#include <typeinfo> // for bad_cast
27#include <vector> // for vector
28
29class CbmGeoMuchPar;
33class TObjArray;
34
35class CbmMuchSegmentManual : public FairTask {
36
37public:
40
42 virtual ~CbmMuchSegmentManual();
43
48 CbmMuchSegmentManual(char* inputFile, char* digiFileName);
49
51 virtual InitStatus Init();
52
54 void SegmentMuch();
55
59 void SetNStations(Int_t nStations) { fNStations = nStations; }
60
65 void SetNRegions(Int_t iStation, Int_t nRegions);
66
72 void SetRegionRadius(Int_t iStation, Int_t iRegion, Double_t radius);
73
78 void SetNChannels(Int_t iStation, Int_t nChannels);
79
86 void SetSigma(Int_t iStation, Int_t iRegion, Double_t sigmaX, Double_t sigmaY);
87
94 void SetPadSize(Int_t iStation, Int_t iRegion, Double_t padLx, Double_t padLy);
95
96 void DebugSwitchOn() { fDebug = 1; }
97
98private:
99 CbmGeoMuchPar* fGeoPar; // Geometry parameters container
100 Int_t fNStations; // Number of stations
101 TObjArray* fStations; // Array of stations
102 Char_t* fInputFileName; // Name of the file with input parameters
103 Char_t* fDigiFileName; // Name of the file with segmentation parameters
104 std::map<Int_t, Int_t> fNRegions; // Map from a station index to a number of circled regions in the station
105 std::map<Int_t, std::vector<Double_t>> fRadii; // Map from a station index to a vector of circled regions radii
106 std::map<Int_t, std::vector<Double_t>>
107 fSecLx; // Map from a station index to a vector of sector widths for each region
108 std::map<Int_t, std::vector<Double_t>>
109 fSecLy; // Map from a station index to a vector of sector lengths for each region
110 std::map<Int_t, Int_t> fNChannels; // Map from a station index to a number of channels per sector
111 std::map<Int_t, std::vector<Int_t>> fNCols; // Map from a station index to a vector of number of columns in a sector
112 std::map<Int_t, std::vector<Int_t>> fNRows; // Map from a station index to a vector of number of rows in a sector
113 Int_t fDebug; // Debug info switch
114
116 virtual void SetParContainers();
117
125 Int_t IntersectsRad(CbmMuchModuleGemRectangular* module, Double_t radius);
126
134 Int_t IntersectsRad(CbmMuchSectorRectangular* sector, Double_t radius);
135
140 void SegmentLayerSide(CbmMuchLayerSide* layerSide);
141
147 void SegmentModule(CbmMuchModuleGemRectangular* module, Bool_t useModuleDesign);
148
155
164 Double_t GetSectorMaxSize(CbmMuchModuleGemRectangular* module, const TString side, Int_t& iRegion);
165
173 Double_t GetPadMaxSize(CbmMuchModuleGemRectangular* module, const TString side);
174
182 Bool_t ShouldSegment(CbmMuchSectorRectangular* sector, const TString direction, Int_t& iRegion);
183
190
196
198 void DrawSegmentation();
199
201 void Print(Option_t* = "") const;
202
204 void ReadInputFile();
205
206
207 // -------------------- Methods for working with strings --------------------------
208 void Trim(std::string& str)
209 {
210 std::string::size_type pos1 = str.find_first_not_of(' ');
211 std::string::size_type pos2 = str.find_last_not_of(' ');
212 str =
213 str.substr(pos1 == std::string::npos ? 0 : pos1, pos2 == std::string::npos ? str.length() - 1 : pos2 - pos1 + 1);
214 }
215
216 Bool_t IsDummyLine(std::string& str)
217 {
218 Trim(str);
219 return str[0] == '#' || str.length() == 0 || str[0] == '\0' || str[0] == '\n';
220 }
221
222 void OmitDummyLines(std::ifstream& infile, std::string& str)
223 {
224 getline(infile, str);
225 while (IsDummyLine(str))
226 getline(infile, str);
227 }
228
229 std::vector<std::string>& Split(const std::string& s, char delim, std::vector<std::string>& elems)
230 {
231 std::stringstream ss(s);
232 std::string item;
233 while (getline(ss, item, delim)) {
234 if (item.length() != 0) elems.push_back(item);
235 }
236 return elems;
237 }
238
239
240 std::vector<std::string> Split(const std::string& s, char delim)
241 {
242 std::vector<std::string> elems;
243 return Split(s, delim, elems);
244 }
245
246 template<class T>
247 void StrToNum(std::string& str, T& number)
248 {
249 try {
250 std::stringstream ss(str);
251 if ((ss >> number).fail() || !(ss >> std::ws).eof()) throw std::bad_cast();
252 }
253 catch (const std::bad_cast& exc) {
254 Fatal("", "Invalid cast.\n");
255 }
256 }
257 // --------------------------------------------------------------------------------
258
261
262 ClassDef(CbmMuchSegmentManual, 1)
263};
264
265#endif
void SetNRegions(Int_t iStation, Int_t nRegions)
std::vector< std::string > & Split(const std::string &s, char delim, std::vector< std::string > &elems)
void SetRegionRadius(Int_t iStation, Int_t iRegion, Double_t radius)
void Print(Option_t *="") const
Bool_t IsDummyLine(std::string &str)
Bool_t ShouldSegment(CbmMuchSectorRectangular *sector, const TString direction, Int_t &iRegion)
std::map< Int_t, std::vector< Double_t > > fSecLy
void SetNStations(Int_t nStations)
Bool_t IsIncompleteSector(CbmMuchSectorRectangular *sector)
void StrToNum(std::string &str, T &number)
std::map< Int_t, std::vector< Int_t > > fNCols
std::map< Int_t, Int_t > fNChannels
void SetSigma(Int_t iStation, Int_t iRegion, Double_t sigmaX, Double_t sigmaY)
Int_t IntersectsRad(CbmMuchModuleGemRectangular *module, Double_t radius)
void SegmentSector(CbmMuchModuleGemRectangular *module, CbmMuchSectorRectangular *sector)
void SetNChannels(Int_t iStation, Int_t nChannels)
std::map< Int_t, std::vector< Int_t > > fNRows
CbmMuchSegmentManual(const CbmMuchSegmentManual &)
CbmMuchSegmentManual & operator=(const CbmMuchSegmentManual &)
std::map< Int_t, std::vector< Double_t > > fRadii
void SetPadSize(Int_t iStation, Int_t iRegion, Double_t padLx, Double_t padLy)
void OmitDummyLines(std::ifstream &infile, std::string &str)
void SegmentLayerSide(CbmMuchLayerSide *layerSide)
void SegmentModule(CbmMuchModuleGemRectangular *module, Bool_t useModuleDesign)
std::map< Int_t, std::vector< Double_t > > fSecLx
Int_t GetRegionIndex(CbmMuchSectorRectangular *sector)
Double_t GetSectorMaxSize(CbmMuchModuleGemRectangular *module, const TString side, Int_t &iRegion)
std::vector< std::string > Split(const std::string &s, char delim)
std::map< Int_t, Int_t > fNRegions
void Trim(std::string &str)
Double_t GetPadMaxSize(CbmMuchModuleGemRectangular *module, const TString side)
virtual InitStatus Init()