CbmRoot
Loading...
Searching...
No Matches
CbmMuchSegmentSector.h
Go to the documentation of this file.
1/* Copyright (C) 2012-2020 Petersburg Nuclear Physics Institute named by B.P.Konstantinov of National Research Centre "Kurchatov Institute", Gatchina
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Vikas Singhal, Evgeny Kryshen [committer], Florian Uhlig */
4
16#ifndef CbmMuchSegmentSector_H
17#define CbmMuchSegmentSector_H 1
18
19#include <FairTask.h> // for FairTask, InitStatus
20
21#include <Rtypes.h> // for THashConsistencyHolder, ClassDef
22#include <RtypesCore.h> // for Int_t, Double_t, Bool_t
23#include <TString.h> // for TString
24
25#include <fstream> // for string, getline, char_traits, basic_istream
26#include <map> // for map
27#include <sstream> // for stringstream
28#include <typeinfo> // for bad_cast
29#include <vector> // for vector
30
31class CbmGeoMuchPar;
35class TObjArray;
36
37class CbmMuchSegmentSector : public FairTask {
38
39public:
42
44 virtual ~CbmMuchSegmentSector();
45
51 CbmMuchSegmentSector(TString inputFile, TString digiFileName, Int_t flag);
52
54 virtual InitStatus Init();
55
57 void SegmentMuch();
58
59 void DebugSwitchOn() { fDebug = 1; }
60
61private:
62 CbmGeoMuchPar* fGeoPar; // Geometry parameters container
63 Int_t fNStations; // Number of stations
64 Int_t fFlag; // falg for geometry
65 TObjArray* fStations; // Array of stations
66 TString fInputFileName; // Name of the file with input parameters
67 TString fDigiFileName; // Name of the file with segmentation parameters
68 std::map<Int_t, Int_t> fNRegions; // Map from a station index to a number of circled regions in the station
69 std::map<Int_t, std::vector<Double_t>> fRadii; // Map from a station index to a vector of circled regions radii
70 std::map<Int_t, std::vector<Double_t>>
71 fAngles; // Map from a station index to a vector of single pad angles for given regions
72 std::map<Int_t, std::vector<Double_t>>
73 fSecLx; // Map from a station index to a vector of sector widths for each region
74 std::map<Int_t, std::vector<Double_t>>
75 fSecLy; // Map from a station index to a vector of sector lengths for each region
76 std::map<Int_t, Int_t> fNChannels; // Map from a station index to a number of channels per sector
77 std::map<Int_t, std::vector<Int_t>> fNCols; // Map from a station index to a vector of number of columns in a sector
78 std::map<Int_t, std::vector<Int_t>> 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
106 void ReadInputFile();
107
109 void DrawSegmentation();
110
111 // -------------------- Methods for working with strings --------------------------
112 void Trim(std::string& str)
113 {
114 std::string::size_type pos1 = str.find_first_not_of(' ');
115 std::string::size_type pos2 = str.find_last_not_of(' ');
116 str =
117 str.substr(pos1 == std::string::npos ? 0 : pos1, pos2 == std::string::npos ? str.length() - 1 : pos2 - pos1 + 1);
118 }
119
120 Bool_t IsDummyLine(std::string& str)
121 {
122 Trim(str);
123 return str[0] == '#' || str.length() == 0 || str[0] == '\0' || str[0] == '\n';
124 }
125
126 void OmitDummyLines(std::ifstream& infile, std::string& str)
127 {
128 getline(infile, str);
129 while (IsDummyLine(str))
130 getline(infile, str);
131 }
132
133 std::vector<std::string>& Split(const std::string& s, char delim, std::vector<std::string>& elems)
134 {
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 {
146 std::vector<std::string> elems;
147 return Split(s, delim, elems);
148 }
149
150 template<class T>
151 void StrToNum(std::string& str, T& number)
152 {
153 try {
154 std::stringstream ss(str);
155 if ((ss >> number).fail() || !(ss >> std::ws).eof()) throw std::bad_cast();
156 }
157 catch (const std::bad_cast& exc) {
158 Fatal("", "Invalid cast.\n");
159 }
160 }
161 // --------------------------------------------------------------------------------
162
165
166 ClassDef(CbmMuchSegmentSector, 1)
167};
168
169#endif
void SegmentSector(CbmMuchModuleGemRadial *module, CbmMuchSectorRadial *sector)
void Trim(std::string &str)
std::map< Int_t, std::vector< Double_t > > fSecLy
Bool_t IsDummyLine(std::string &str)
std::vector< std::string > Split(const std::string &s, char delim)
std::vector< std::string > & Split(const std::string &s, char delim, std::vector< std::string > &elems)
void StrToNum(std::string &str, T &number)
std::map< Int_t, std::vector< Double_t > > fAngles
std::map< Int_t, std::vector< Int_t > > fNCols
virtual InitStatus Init()
std::map< Int_t, std::vector< Double_t > > fRadii
std::map< Int_t, Int_t > fNRegions
void OmitDummyLines(std::ifstream &infile, std::string &str)
Int_t SegmentModule(CbmMuchModuleGemRadial *module, Bool_t useModuleDesign)
std::map< Int_t, std::vector< Int_t > > fNRows
std::map< Int_t, Int_t > fNChannels
CbmMuchSegmentSector(const CbmMuchSegmentSector &)
CbmMuchSegmentSector & operator=(const CbmMuchSegmentSector &)
std::map< Int_t, std::vector< Double_t > > fSecLx
Int_t SegmentLayerSide(CbmMuchLayerSide *layerSide)