11#if !defined(__CLING__ ) || defined(__ROOTCLING__ )
22
33#include "MFTBase/GeometryTGeo.h"
4+ #include "ITSMFTReconstruction/ChipMappingMFT.h"
45
56constexpr int NChips = 936 ;
67constexpr int NModules = 280 ;
@@ -10,10 +11,27 @@ constexpr int NConnectors = 5;
1011constexpr int NMaxChipsPerLadder = 5 ;
1112constexpr int NRUTypes = 13 ;
1213
14+ struct MFTChipFullMappingData {
15+ UShort_t globalChipSWID = 0 ; // global software chip ID
16+ UShort_t localChipSWID = 0 ; // local software chip ID
17+ UShort_t localChipHWID = 0 ; // local hardware chip ID
18+ UChar_t chipOnRU = 0 ; // chip within the read-out-unit
19+ UChar_t cableHW = 0 ; // cable in the connector (transceiver)
20+ UChar_t connector = 0 ; // cable connector in a zone
21+ UChar_t zone = 0 ; // read-out zone id
22+ UChar_t ruOnLayer = 0 ; // read-out-unit index on layer
23+ UChar_t ruType = 0 ; // read-out-unit type
24+ UChar_t ruSWID = 0 ; // read-out-unit hardware ID
25+ UChar_t ruHWID = 0 ; // read-out-unit software ID
26+ UChar_t layer = 0 ; // MFT layer
27+ UChar_t disk = 0 ; // MFT disk
28+ UChar_t half = 0 ; // MFT half
29+ };
30+
1331struct MFTChipMappingData {
1432 UShort_t module = 0 ; // global module ID
1533 UChar_t chipOnModule = 0 ; // chip within the module
16- UChar_t cable = 0 ; // cable in the connector
34+ UChar_t cable = 0 ; // cable in the connector (transceiver)
1735 UChar_t chipOnRU = 0 ; // chip within the RU (SW)
1836};
1937
@@ -27,6 +45,7 @@ struct MFTModuleMappingData {
2745 UChar_t half = 0 ; // half id
2846};
2947
48+ std ::array < MFTChipFullMappingData , NChips > ChipFullMappingData ;
3049std ::array < MFTChipMappingData , NChips > ChipMappingData ;
3150std ::array < MFTModuleMappingData , NModules > ModuleMappingData ;
3251
@@ -61,6 +80,7 @@ constexpr Int_t ZoneRUType[NZonesPerLayer / 2][NLayers / 2]{
6180constexpr std ::array < int , NRUTypes > NChipsOnRUType {7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 16 , 17 , 18 , 19 , 14 };
6281
6382void createCXXfile (o2 ::mft ::GeometryTGeo * );
83+ void createCXXfileFullMap (o2 ::mft ::GeometryTGeo * );
6484Int_t getZone (Int_t layer , Int_t ladderID , Int_t & connector );
6585Int_t getZoneRUID (Int_t half , Int_t layer , Int_t zone , Int_t & zoneID );
6686
@@ -71,7 +91,7 @@ Int_t ruHW, zoneID;
7191Int_t nModules ;
7292std ::vector < Int_t > modFirstChip , modNChips , RUNChips ;
7393
74- void extractMFTMapping (const std ::string inputGeom = "" )
94+ void extractMFTMapping (const std ::string inputGeom = "o2sim_geometry.root " )
7595{
7696 o2 ::base ::GeometryManager ::loadGeometry (inputGeom );
7797 auto gm = o2 ::mft ::GeometryTGeo ::Instance (); // geometry manager for mapping
@@ -109,6 +129,109 @@ void extractMFTMapping(const std::string inputGeom = "")
109129
110130 // create again the CXX file with the chipOnRUSW member
111131 createCXXfile (gm );
132+
133+ // write version with full mapping in MFTChipMappingData
134+ createCXXfileFullMap (gm );
135+ }
136+
137+ //__________________________________________________________________________
138+ void createCXXfileFullMap (o2 ::mft ::GeometryTGeo * gm )
139+ {
140+ const o2 ::itsmft ::ChipMappingMFT map ;
141+
142+ int half , disk , layer , zone , module , ladder , ladderID ;
143+ int chipIDglo , chipIDlocSW , chipIDlocHW , chipOnModule ;
144+ int ruSWID , ruHWID , ruType ;
145+ uint16_t ruOnLayer , chipOnRU , link = 0 ;
146+ uint8_t connector , cableHW , cableSW ;
147+ Int_t cnct ;
148+
149+ const o2 ::itsmft ::ChipOnRUInfo * chipOnRUInfo ;
150+ const o2 ::itsmft ::RUInfo * ruInfo ;
151+ o2 ::itsmft ::ChipInfo chipInfo ;
152+
153+ // fill chip full mapping information
154+ for (int iChip = 0 ; iChip < NChips ; ++ iChip ) {
155+ chipIDglo = iChip ;
156+
157+ ChipFullMappingData [iChip ].globalChipSWID = chipIDglo ;
158+
159+ gm -> getSensorID (iChip , half , disk , ladder , chipIDlocSW );
160+
161+ ChipFullMappingData [iChip ].localChipSWID = chipIDlocSW ;
162+ ChipFullMappingData [iChip ].disk = disk ;
163+ ChipFullMappingData [iChip ].half = half ;
164+
165+ module = map .chipID2Module (chipIDglo , chipOnModule );
166+
167+ layer = gm -> getLayer (chipIDglo );
168+ ChipFullMappingData [iChip ].layer = layer ;
169+
170+ ladderID = gm -> getLadderID (disk , ladder );
171+ map .getChipInfoSW (chipIDglo , chipInfo );
172+
173+ ruType = chipInfo .ruType ;
174+ ChipFullMappingData [iChip ].ruType = ruType ;
175+
176+ zone = getZone (layer , ladderID , cnct );
177+ ChipFullMappingData [iChip ].zone = zone ;
178+
179+ ruOnLayer = 4 * half + zone ;
180+ ChipFullMappingData [iChip ].ruOnLayer = ruOnLayer ;
181+
182+ ruSWID = map .getRUIDSW (layer , ruOnLayer );
183+ ChipFullMappingData [iChip ].ruSWID = ruSWID ;
184+
185+ ruHWID = map .RUSW2FEEId (ruSWID );
186+ ChipFullMappingData [iChip ].ruHWID = ruHWID ;
187+
188+ chipIDlocHW = map .chipModuleIDSW2HW (ruType , chipIDlocSW );
189+ ChipFullMappingData [iChip ].localChipHWID = chipIDlocHW ;
190+
191+ chipOnRUInfo = chipInfo .chOnRU ;
192+
193+ chipOnRU = chipOnRUInfo -> id ;
194+ ChipFullMappingData [iChip ].chipOnRU = chipOnRU ;
195+
196+ connector = chipOnRUInfo -> moduleHW ;
197+ ChipFullMappingData [iChip ].connector = connector ;
198+
199+ cableHW = chipOnRUInfo -> cableHW ;
200+ ChipFullMappingData [iChip ].cableHW = cableHW ;
201+ }
202+ FILE * srcFile = fopen ("ChipMappingMFT_full.cxx" , "w" );
203+ fprintf (srcFile , "\n// { module, chipOnModule, cable, chipOnRU, globalChipSWID, localChipSWID, localChipHWID, connector, zone, ruOnLayer, ruType, ruSWID, ruHWID, layer, disk, half }\n\n" );
204+ Int_t ladderP = -1 , layerP = -1 , halfP = -1 ;
205+ for (Int_t iChip = 0 ; iChip < NChips ; iChip ++ ) {
206+ gm -> getSensorID (iChip , half , disk , ladder , sensor );
207+ layer = gm -> getLayer (iChip );
208+ if (layer != layerP || ladder != ladderP || half != halfP ) { // new module
209+ layerP = layer ;
210+ ladderP = ladder ;
211+ halfP = half ;
212+ fprintf (srcFile , "// chip: %3d (%1d), ladder: %2d (%2d), layer: %1d, disk: %1d, half: %1d, zone: %1d \n" , iChip , nChipsPerLadder , ladder , ladderID , layer , disk , half , zone );
213+ }
214+ fprintf (srcFile , "{%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d}%s\n" ,
215+ ChipMappingData [iChip ].module ,
216+ ChipMappingData [iChip ].chipOnModule ,
217+ ChipMappingData [iChip ].cable ,
218+ ChipMappingData [iChip ].chipOnRU ,
219+ ChipFullMappingData [iChip ].globalChipSWID ,
220+ ChipFullMappingData [iChip ].localChipSWID ,
221+ ChipFullMappingData [iChip ].localChipHWID ,
222+ ChipFullMappingData [iChip ].connector ,
223+ ChipFullMappingData [iChip ].zone ,
224+ ChipFullMappingData [iChip ].ruOnLayer ,
225+ ChipFullMappingData [iChip ].ruType ,
226+ ChipFullMappingData [iChip ].ruSWID ,
227+ ChipFullMappingData [iChip ].ruHWID ,
228+ ChipFullMappingData [iChip ].layer ,
229+ ChipFullMappingData [iChip ].disk ,
230+ ChipFullMappingData [iChip ].half ,
231+ (iChip < NChips - 1 ? "," : "" ));
232+ }
233+ fprintf (srcFile , "\n}};\n" );
234+ fclose (srcFile );
112235}
113236
114237//__________________________________________________________________________
@@ -168,9 +291,12 @@ void createCXXfile(o2::mft::GeometryTGeo* gm)
168291 }
169292 Int_t iconnector = connector ;
170293 fprintf (srcFile , "{%d, %d, %d, %d}%s\n" , (nModules - 1 ), sensor , ChipConnectorCable [connector ][sensor ], ChipOnRUSW [ZoneRUType [zone ][layer / 2 ]][iconnector ][sensor ], (iChip < nChips - 1 ? "," : "" ));
294+
295+ // fill MFTChipMappingData
171296 ChipMappingData [iChip ].module = nModules - 1 ;
172297 ChipMappingData [iChip ].chipOnModule = sensor ;
173298 ChipMappingData [iChip ].cable = ChipConnectorCable [connector ][sensor ];
299+ ChipMappingData [iChip ].chipOnRU = ChipOnRUSW [ZoneRUType [zone ][layer / 2 ]][iconnector ][sensor ];
174300 }
175301
176302 fprintf (srcFile , "\n}};\n\n" );
0 commit comments