2121// using boost::format;
2222
2323#include " TPCBase/Mapper.h"
24- namespace o2 {
25- namespace tpc {
26- constexpr std::array<double , SECTORSPERSIDE > Mapper::SinsPerSector/* {{
24+ namespace o2
25+ {
26+ namespace tpc
27+ {
28+ constexpr std::array<double , SECTORSPERSIDE > Mapper::SinsPerSector /* {{
2729 0,
2830 0.3420201433256687129080830800376133993268,
2931 0.6427876096865392518964199553010985255241,
@@ -42,11 +44,12 @@ namespace tpc {
4244 -0.8660254037844385965883020617184229195118,
4345 -0.6427876096865395849633273428480606526136,
4446 -0.3420201433256686018857806175219593569636
45- }}*/ ;
47+ }}*/
48+ ;
4649
47- // static constexpr std::array<int, 2> test{1,2};
50+ // static constexpr std::array<int, 2> test{1,2};
4851
49- constexpr std::array<double , SECTORSPERSIDE > Mapper::CosinsPerSector/* {{
52+ constexpr std::array<double , SECTORSPERSIDE > Mapper::CosinsPerSector /* {{
5053 1,
5154 0.9396926207859084279050421173451468348503,
5255 0.7660444431189780134516809084743726998568,
@@ -65,13 +68,14 @@ namespace tpc {
6568 0.5000000000000001110223024625156540423632,
6669 0.7660444431189777914070759834430646151304,
6770 0.9396926207859084279050421173451468348503
68- }}*/ ;
71+ }}*/
72+ ;
6973
7074Mapper::Mapper (const std::string& mappingDir)
7175 : mMapGlobalPadToPadPos (mPadsInSector ),
7276 mMapGlobalPadCentre (mPadsInSector ),
7377 mMapPadPosGlobalPad(),
74- mMapFECIDGlobalPad(FECInfo::globalSAMPAId(91 ,0 , 0 )),
78+ mMapFECIDGlobalPad(FECInfo::globalSAMPAId(91 , 0 , 0 )),
7579 mMapGlobalPadFECInfo(mPadsInSector ),
7680 mMapPadRegionInfo(),
7781 mMapPartitionInfo()
@@ -101,8 +105,8 @@ bool Mapper::readMappingFile(std::string file)
101105 GlobalPadNumber padIndex;
102106 unsigned int padRow;
103107 unsigned int pad;
104- float xPos;
105- float yPos;
108+ float xPos;
109+ float yPos;
106110
107111 // pad plane info
108112 unsigned int connector;
@@ -117,74 +121,67 @@ bool Mapper::readMappingFile(std::string file)
117121 unsigned int sampaChip;
118122 unsigned int sampaChannel;
119123
120- std::string line;
124+ std::string line;
121125 std::ifstream infile (file, std::ifstream::in);
126+ if (!infile.is_open ()) {
127+ std::cout << " could not open file " << file << " \n " ;
128+ exit (1 );
129+ }
122130 while (std::getline (infile, line)) {
123131 std::stringstream streamLine (line);
124132 streamLine
125133 // pad info
126- >> padIndex
127- >> padRow
128- >> pad
129- >> xPos
130- >> yPos
134+ >> padIndex >> padRow >> pad >> xPos >> yPos
131135
132136 // pad plane info
133- >> connector
134- >> pin
135- >> partion
136- >> region
137+ >> connector >> pin >> partion >> region
137138
138139 // FEC info
139- >> fecIndex
140- >> fecConnector
141- >> fecChannel
142- >> sampaChip
143- >> sampaChannel;
144-
145- // the x and y positions are in mm
146- // in the mapping files, the values are given for sector C04 in the global ALICE coordinate system
147- // however, we need it in the local tracking system. Therefore:
148- const float localX=yPos/10 .f ;
149- const float localY=-xPos/10 .f ;
150- // with the pad counting (looking to C-Side pad 0,0 is bottom left -- pad-side front view)
151- // these values are for the C-Side
152- // For the A-Side the localY position must be mirrored
153-
154- mMapGlobalPadToPadPos [padIndex] = PadPos (padRow,pad);
155- mMapPadPosGlobalPad [PadPos (padRow,pad)] = padIndex;
156- mMapGlobalPadFECInfo [padIndex] = FECInfo (fecIndex, /* fecConnector, fecChannel,*/ sampaChip, sampaChannel);
157- mMapFECIDGlobalPad [FECInfo::globalSAMPAId (fecIndex, sampaChip, sampaChannel)] = padIndex;
158- mMapGlobalPadCentre [padIndex] = PadCentre (localX, localY);
159-
160- // std::cout
161- // << padIndex<< " "
162- // << padRow<< " "
163- // << pad<< " "
164- // << xPos<< " "
165- // << yPos<< " "
166- // << " "
167- // // pad plane info<< " "
168- // << connector<< " "
169- // << pin<< " "
170- // << partion<< " "
171- // << region<< " "
172- // << " "
173- // // FEC info<< " "
174- // << fecIndex<< " "
175- // << fecConnector<< " "
176- // << fecChannel<< " "
177- // << sampaChip<< " "
178- // << sampaChannel << std::endl;
140+ >> fecIndex >> fecConnector >> fecChannel >> sampaChip >> sampaChannel;
141+
142+ // the x and y positions are in mm
143+ // in the mapping files, the values are given for sector C04 in the global ALICE coordinate system
144+ // however, we need it in the local tracking system. Therefore:
145+ const float localX = yPos / 10 .f ;
146+ const float localY = -xPos / 10 .f ;
147+ // with the pad counting (looking to C-Side pad 0,0 is bottom left -- pad-side front view)
148+ // these values are for the C-Side
149+ // For the A-Side the localY position must be mirrored
150+
151+ mMapGlobalPadToPadPos [padIndex] = PadPos (padRow, pad);
152+ mMapPadPosGlobalPad [PadPos (padRow, pad)] = padIndex;
153+ mMapGlobalPadFECInfo [padIndex] = FECInfo (fecIndex, /* fecConnector, fecChannel,*/ sampaChip, sampaChannel);
154+ mMapFECIDGlobalPad [FECInfo::globalSAMPAId (fecIndex, sampaChip, sampaChannel)] = padIndex;
155+ mMapGlobalPadCentre [padIndex] = PadCentre (localX, localY);
156+
157+ // std::cout
158+ // << padIndex<< " "
159+ // << padRow<< " "
160+ // << pad<< " "
161+ // << xPos<< " "
162+ // << yPos<< " "
163+ // << " "
164+ // // pad plane info<< " "
165+ // << connector<< " "
166+ // << pin<< " "
167+ // << partion<< " "
168+ // << region<< " "
169+ // << " "
170+ // // FEC info<< " "
171+ // << fecIndex<< " "
172+ // << fecConnector<< " "
173+ // << fecChannel<< " "
174+ // << sampaChip<< " "
175+ // << sampaChannel << std::endl;
179176 }
180177 return true ;
181178}
182179
183180void Mapper::load (const std::string& mappingDir)
184181{
185182
186- // std::string inputDir(std::getenv("ALICEO2"));
187- std::string inputDir= mappingDir;
183+ // std::string inputDir(std::getenv("ALICEO2"));
184+ std::string inputDir = mappingDir;
188185 if (!inputDir.size ()) {
189186 // const char* aliceO2env=std::getenv("ALICEO2");
190187 // if (aliceO2env) inputDir=aliceO2env;
@@ -193,14 +190,15 @@ void Mapper::load(const std::string& mappingDir)
193190 // readMappingFile(inputDir+"/Detectors/TPC/base/files/TABLE-OROC2.txt");
194191 // readMappingFile(inputDir+"/Detectors/TPC/base/files/TABLE-OROC3.txt");
195192
196- const char * aliceO2env=std::getenv (" O2_ROOT" );
197- if (aliceO2env) inputDir=aliceO2env;
198- inputDir+=" /share/Detectors/TPC/files" ;
193+ const char * aliceO2env = std::getenv (" O2_ROOT" );
194+ if (aliceO2env)
195+ inputDir = aliceO2env;
196+ inputDir += " /share/Detectors/TPC/files" ;
199197 }
200- readMappingFile (inputDir+ " /TABLE-IROC.txt" );
201- readMappingFile (inputDir+ " /TABLE-OROC1.txt" );
202- readMappingFile (inputDir+ " /TABLE-OROC2.txt" );
203- readMappingFile (inputDir+ " /TABLE-OROC3.txt" );
198+ readMappingFile (inputDir + " /TABLE-IROC.txt" );
199+ readMappingFile (inputDir + " /TABLE-OROC1.txt" );
200+ readMappingFile (inputDir + " /TABLE-OROC2.txt" );
201+ readMappingFile (inputDir + " /TABLE-OROC3.txt" );
204202
205203 initPadRegionsAndPartitions ();
206204}
@@ -209,28 +207,28 @@ void Mapper::initPadRegionsAndPartitions()
209207{
210208 // original values for pad widht and height and pad row position are in mm
211209 // the ALICE coordinate system is in cm
212- mMapPadRegionInfo [0 ]= PadRegionInfo (0 , 0 , 17 , 7.5 / 10 ., 4.16 / 10 ., 848.5 / 10 ., 0 , 33.20 , 0 );
213- mMapPadRegionInfo [1 ]= PadRegionInfo (0 , 1 , 15 , 7.5 / 10 ., 4.20 / 10 ., 976.0 / 10 ., 17 , 33.00 , 17 );
214- mMapPadRegionInfo [2 ]= PadRegionInfo (1 , 2 , 16 , 7.5 / 10 ., 4.20 / 10 ., 1088.5 / 10 ., 32 , 33.08 , 32 );
215- mMapPadRegionInfo [3 ]= PadRegionInfo (1 , 3 , 15 , 7.5 / 10 ., 4.36 / 10 ., 1208.5 / 10 ., 48 , 31.83 , 48 );
216- mMapPadRegionInfo [4 ]= PadRegionInfo (2 , 4 , 18 , 10 / 10 . , 6.00 / 10 ., 1347.0 / 10 ., 0 , 38.00 , 63 );
217- mMapPadRegionInfo [5 ]= PadRegionInfo (2 , 5 , 16 , 10 / 10 . , 6.00 / 10 ., 1527.0 / 10 ., 18 , 38.00 , 81 );
218- mMapPadRegionInfo [6 ]= PadRegionInfo (3 , 6 , 16 , 12 / 10 . , 6.08 / 10 ., 1708.0 / 10 ., 0 , 47.90 , 97 );
219- mMapPadRegionInfo [7 ]= PadRegionInfo (3 , 7 , 14 , 12 / 10 . , 5.88 / 10 ., 1900.0 / 10 ., 16 , 49.55 , 113 );
220- mMapPadRegionInfo [8 ]= PadRegionInfo (4 , 8 , 13 , 15 / 10 . , 6.04 / 10 ., 2089.0 / 10 ., 0 , 59.39 , 127 );
221- mMapPadRegionInfo [9 ]= PadRegionInfo (4 , 9 , 12 , 15 / 10 . , 6.07 / 10 ., 2284.0 / 10 ., 0 , 64.70 , 140 );
222-
223- mMapPartitionInfo [0 ]= PartitionInfo (15 , 0 , 32 , 0 , 2400 );
224- mMapPartitionInfo [1 ]= PartitionInfo (18 , 15 , 31 , 32 , 2880 );
225- mMapPartitionInfo [2 ]= PartitionInfo (18 , 15 + 18 , 34 , 32 + 31 , 2880 );
226- mMapPartitionInfo [3 ]= PartitionInfo (20 , 15 + 18 + 18 , 30 , 32 + 31 + 34 , 3200 );
227- mMapPartitionInfo [4 ]= PartitionInfo (20 , 15 + 18 + 18 + 20 , 25 , 32 + 31 + 34 + 30 , 3200 );
228-
229- int globalRow= 0 ;
230- int padsInRow= 0 ;
231- int padOffset= 0 ;
210+ mMapPadRegionInfo [0 ] = PadRegionInfo (0 , 0 , 17 , 7.5 / 10 ., 4.16 / 10 ., 848.5 / 10 ., 0 , 33.20 , 0 );
211+ mMapPadRegionInfo [1 ] = PadRegionInfo (0 , 1 , 15 , 7.5 / 10 ., 4.20 / 10 ., 976.0 / 10 ., 17 , 33.00 , 17 );
212+ mMapPadRegionInfo [2 ] = PadRegionInfo (1 , 2 , 16 , 7.5 / 10 ., 4.20 / 10 ., 1088.5 / 10 ., 32 , 33.08 , 32 );
213+ mMapPadRegionInfo [3 ] = PadRegionInfo (1 , 3 , 15 , 7.5 / 10 ., 4.36 / 10 ., 1208.5 / 10 ., 48 , 31.83 , 48 );
214+ mMapPadRegionInfo [4 ] = PadRegionInfo (2 , 4 , 18 , 10 / 10 ., 6.00 / 10 ., 1347.0 / 10 ., 0 , 38.00 , 63 );
215+ mMapPadRegionInfo [5 ] = PadRegionInfo (2 , 5 , 16 , 10 / 10 ., 6.00 / 10 ., 1527.0 / 10 ., 18 , 38.00 , 81 );
216+ mMapPadRegionInfo [6 ] = PadRegionInfo (3 , 6 , 16 , 12 / 10 ., 6.08 / 10 ., 1708.0 / 10 ., 0 , 47.90 , 97 );
217+ mMapPadRegionInfo [7 ] = PadRegionInfo (3 , 7 , 14 , 12 / 10 ., 5.88 / 10 ., 1900.0 / 10 ., 16 , 49.55 , 113 );
218+ mMapPadRegionInfo [8 ] = PadRegionInfo (4 , 8 , 13 , 15 / 10 ., 6.04 / 10 ., 2089.0 / 10 ., 0 , 59.39 , 127 );
219+ mMapPadRegionInfo [9 ] = PadRegionInfo (4 , 9 , 12 , 15 / 10 ., 6.07 / 10 ., 2284.0 / 10 ., 0 , 64.70 , 140 );
220+
221+ mMapPartitionInfo [0 ] = PartitionInfo (15 , 0 , 32 , 0 , 2400 );
222+ mMapPartitionInfo [1 ] = PartitionInfo (18 , 15 , 31 , 32 , 2880 );
223+ mMapPartitionInfo [2 ] = PartitionInfo (18 , 15 + 18 , 34 , 32 + 31 , 2880 );
224+ mMapPartitionInfo [3 ] = PartitionInfo (20 , 15 + 18 + 18 , 30 , 32 + 31 + 34 , 3200 );
225+ mMapPartitionInfo [4 ] = PartitionInfo (20 , 15 + 18 + 18 + 20 , 25 , 32 + 31 + 34 + 30 , 3200 );
226+
227+ int globalRow = 0 ;
228+ int padsInRow = 0 ;
229+ int padOffset = 0 ;
232230 for (const auto & reg : mMapPadRegionInfo ) {
233- for (int row= 0 ; row< reg.getNumberOfPadRows (); ++row) {
231+ for (int row = 0 ; row < reg.getNumberOfPadRows (); ++row) {
234232 mMapPadOffsetPerRow [globalRow] = padOffset;
235233 padsInRow = reg.getPadsInRowRegion (row);
236234 mMapNumberOfPadsPerRow [globalRow] = padsInRow;
@@ -240,5 +238,5 @@ void Mapper::initPadRegionsAndPartitions()
240238 }
241239}
242240
243- }
244- }
241+ } // namespace tpc
242+ } // namespace o2
0 commit comments