@@ -47,8 +47,8 @@ std::string GeometryTGeo::sInnerVolumeName = "FT3Inner"; ///< Mother inner volum
4747std::string GeometryTGeo::sLayerName = " FT3Layer" ; // /< Layer name
4848std::string GeometryTGeo::sChipName = " FT3Chip" ; // /< Chip name
4949// TODO: this is now only used for the not-segmented version; synchronise?
50- std::string GeometryTGeo::sSensorName = " FT3Sensor" ; // /< Sensor name
51- std::string GeometryTGeo::sPassiveName = " Passive" ; // /< Passive material name
50+ std::string GeometryTGeo::sSensorName = " FT3Sensor" ; // /< Sensor name
51+ std::string GeometryTGeo::sPassiveName = " Passive" ; // /< Passive material name
5252
5353GeometryTGeo::~GeometryTGeo ()
5454{
@@ -86,33 +86,33 @@ void GeometryTGeo::Build(int loadTrans)
8686 }
8787
8888 // Forward discs part
89- // int sensIdx = 0;
89+ // int sensIdx = 0;
9090 int totDiscs = 0 ;
9191 int absStaveIdx = 0 ;
9292 mSize = 0 ;
9393 // TODO: clean up initialisation
94- if (mChipIdxStave .size () == 0 )
95- {
94+ if (mChipIdxStave .size () == 0 ) {
9695 mChipIdxStave .push_back (0 );
9796 }
98- if (mStaveIdxDisc .size () == 0 )
99- {
97+ if (mStaveIdxDisc .size () == 0 ) {
10098 mStaveIdxDisc .push_back (0 );
10199 }
102100 for (int iDir = 0 ; iDir < 2 ; iDir++) {
103101 mNumberOfDiscs .push_back (extractNumberOfDiscs (iDir));
104102 LOG (info) << " direction " << iDir << " has " << mNumberOfDiscs [iDir] << " discs" ;
105103 totDiscs += mNumberOfDiscs [iDir];
106-
104+
107105 for (int iDisc = 0 ; iDisc < mNumberOfDiscs [iDir]; iDisc++) {
108106 TGeoVolume* ft3V = gGeoManager ->GetVolume (getFT3VolPattern ());
109107 if (ft3V == nullptr ) {
110108 LOG (fatal) << getName () << " volume " << getFT3VolPattern () << " is not in the geometry" ;
111109 }
112- auto layerNode = ft3V->GetNode (Form (" %s_1" , composeSymNameLayer (iDir,iDisc)));
113- if (layerNode == nullptr ) LOG (fatal) << " Could not find layer node " << Form (" %s_1" , composeSymNameLayer (iDir,iDisc));
110+ auto layerNode = ft3V->GetNode (Form (" %s_1" , composeSymNameLayer (iDir, iDisc)));
111+ if (layerNode == nullptr )
112+ LOG (fatal) << " Could not find layer node " << Form (" %s_1" , composeSymNameLayer (iDir, iDisc));
114113 auto layerVol = layerNode->GetVolume ();
115- if (layerVol == nullptr ) LOG (fatal) << " Could not find layer volume " << Form (" %s_1" ,composeSymNameLayer (iDir,iDisc));
114+ if (layerVol == nullptr )
115+ LOG (fatal) << " Could not find layer volume " << Form (" %s_1" , composeSymNameLayer (iDir, iDisc));
116116 TObjArray* nodes = layerVol->GetNodes ();
117117 int nNodes = nodes->GetEntriesFast ();
118118 int nStaves = 0 ;
@@ -142,21 +142,23 @@ void GeometryTGeo::Build(int loadTrans)
142142 mChipIdxStave .resize (absStaveIdx + chipsPerStave.size () + 1 );
143143 mNumberOfStavesPerDisc .push_back (chipsPerStave.size ()); // TODO: remove this? Or remove StaveIdxDisc
144144 int totSensor = 0 ;
145- for (int nChips: chipsPerStave) {
145+ for (int nChips : chipsPerStave) {
146146 LOG (debug) << " Absolute Stave ID " << absStaveIdx << " : " << nChips << " sensors" ;
147147 totSensor += nChips;
148- if (absStaveIdx) mChipIdxStave [absStaveIdx + 1 ] = mChipIdxStave [absStaveIdx] + nChips;
148+ if (absStaveIdx)
149+ mChipIdxStave [absStaveIdx + 1 ] = mChipIdxStave [absStaveIdx] + nChips;
149150 absStaveIdx++;
150151 }
151- if (totSensor != nSensor) LOG (info) << " Inconsistency in sensor count " << nSensor << " " << totSensor;
152+ if (totSensor != nSensor)
153+ LOG (info) << " Inconsistency in sensor count " << nSensor << " " << totSensor;
152154 LOG (debug) << " adding stave Idx " << absStaveIdx << " to disc array; element " << mStaveIdxDisc .size ();
153155 mStaveIdxDisc .push_back (absStaveIdx);
154156 mNumberOfChipsPerDisc .push_back (totSensor);
155157 mSize += totSensor;
156158 LOG (info) << " Total sensors so far " << mSize ;
157159 }
158160 }
159- // mSize = mChipStaveIds.size();
161+ // mSize = mChipStaveIds.size();
160162 LOG (info) << " Total sensors " << mSize ;
161163 LOG (info) << " Length of stave-disc array " << mStaveIdxDisc .size ();
162164 fillMatrixCache (loadTrans); // Check whether this causes trouble
@@ -165,7 +167,7 @@ void GeometryTGeo::Build(int loadTrans)
165167// __________________________________________________________________________
166168const char * GeometryTGeo::composeSymNameLayer (int direction, int layerNumber)
167169{
168- return Form (" %s%d_%d" ,GeometryTGeo::getFT3LayerPattern (), direction, layerNumber);
170+ return Form (" %s%d_%d" , GeometryTGeo::getFT3LayerPattern (), direction, layerNumber);
169171}
170172
171173// __________________________________________________________________________
@@ -181,19 +183,23 @@ const char* GeometryTGeo::composeSymNameSensor(Int_t d, Int_t lr)
181183}
182184
183185// __________________________________________________________________________
184- int GeometryTGeo::extractNumberOfDiscs (int dir) {
186+ int GeometryTGeo::extractNumberOfDiscs (int dir)
187+ {
185188 int numDiscs = 0 ;
186- while (gGeoManager ->GetVolume (composeSymNameLayer (dir,numDiscs))) {numDiscs++;} // Check maybe subvolume?
189+ while (gGeoManager ->GetVolume (composeSymNameLayer (dir, numDiscs))) {
190+ numDiscs++;
191+ } // Check maybe subvolume?
187192 return numDiscs; // Assume same # layers on both sides
188193}
189194// __________________________________________________________________________
190- int GeometryTGeo::extractNumberOfChips (int dir, int layer) {
195+ int GeometryTGeo::extractNumberOfChips (int dir, int layer)
196+ {
191197 int numSensors = 0 ;
192198 TGeoVolume* ft3V = gGeoManager ->GetVolume (getFT3VolPattern ());
193199 if (ft3V == nullptr ) {
194200 LOG (fatal) << getName () << " volume " << getFT3VolPattern () << " is not in the geometry" ;
195201 }
196- auto layerVol = ft3V->GetNode (Form (" %s_1" ,composeSymNameLayer (dir,layer)))->GetVolume ();
202+ auto layerVol = ft3V->GetNode (Form (" %s_1" , composeSymNameLayer (dir, layer)))->GetVolume ();
197203 TObjArray* nodes = layerVol->GetNodes ();
198204 int nNodes = nodes->GetEntriesFast ();
199205 int nSensor = 0 ;
@@ -208,27 +214,30 @@ int GeometryTGeo::extractNumberOfChips(int dir, int layer) {
208214 return nSensor;
209215}
210216// __________________________________________________________________________
211- int GeometryTGeo::extractChipId (std::string const volName) {
212- if (volName.find (" FT3Sensor_Active" )==0 ) {
213- return std::stoi (volName.substr (volName.rfind (' _' )+1 ));
217+ int GeometryTGeo::extractChipId (std::string const volName)
218+ {
219+ if (volName.find (" FT3Sensor_Active" ) == 0 ) {
220+ return std::stoi (volName.substr (volName.rfind (' _' ) + 1 ));
214221 }
215222 LOG (error) << " Not a sensor volume " << volName;
216223 return -1 ;
217224}
218- void GeometryTGeo::extractStaveChipId (std::string const volName, int &stave, int &chip) {
219- if (volName.find (" FT3Sensor_Active" )==0 ) {
225+ void GeometryTGeo::extractStaveChipId (std::string const volName, int & stave, int & chip)
226+ {
227+ if (volName.find (" FT3Sensor_Active" ) == 0 ) {
220228 int idx = volName.rfind (' _' );
221- chip = std::stoi (volName.substr (idx+1 ));
222- idx = volName.rfind (' _' ,idx);
223- stave = std::stoi (volName.substr (idx+1 ));
224- }
225- else {
229+ chip = std::stoi (volName.substr (idx + 1 ));
230+ idx = volName.rfind (' _' , idx);
231+ stave = std::stoi (volName.substr (idx + 1 ));
232+ } else {
226233 LOG (error) << " Not a sensor volume " << volName;
227- stave = -1 ; chip = -1 ;
234+ stave = -1 ;
235+ chip = -1 ;
228236 }
229237}
230- void GeometryTGeo::extractChipIds (std::string const volName, int &direction, int &layer, int &stave, int &chip) {
231- if (volName.find (" FT3Sensor_Active" )==0 ) {
238+ void GeometryTGeo::extractChipIds (std::string const volName, int & direction, int & layer, int & stave, int & chip)
239+ {
240+ if (volName.find (" FT3Sensor_Active" ) == 0 ) {
232241 int idx = volName.find (' _' ) + 1 ;
233242 idx = volName.find (' _' , idx) + 1 ;
234243 direction = std::stoi (volName.substr (idx));
@@ -238,30 +247,32 @@ void GeometryTGeo::extractChipIds(std::string const volName, int &direction, int
238247 stave = std::stoi (volName.substr (idx));
239248 idx = volName.find (' _' , idx) + 1 ;
240249 chip = std::stoi (volName.substr (idx));
241- }
242- else {
250+ } else {
243251 LOG (error) << " Not a sensor volume " << volName;
244252 direction = -1 ;
245253 }
246254}
247255
248- int GeometryTGeo::getChipIndex (int dir, int layer, int stave, int chip) const {
256+ int GeometryTGeo::getChipIndex (int dir, int layer, int stave, int chip) const
257+ {
249258 int absDisc = layer;
250- if (dir == 1 ) absDisc += mNumberOfDiscs [0 ];
259+ if (dir == 1 )
260+ absDisc += mNumberOfDiscs [0 ];
251261 return mChipIdxStave [mStaveIdxDisc [absDisc] + stave] + chip;
252262}
253263
254- int GeometryTGeo::getLayer (int chipIdx) const {
264+ int GeometryTGeo::getLayer (int chipIdx) const
265+ {
255266 int lay = mNumberOfDiscs [0 ] + mNumberOfDiscs [1 ] - 1 ;
256267 while (chipIdx < mChipIdxStave [mStaveIdxDisc [lay]] && lay > 0 ) {
257- lay--;
268+ lay--;
258269 }
259270 return lay;
260271}
261-
262272
263273// retrieve local stave number from chip ID
264- int GeometryTGeo::getStave (int chipIdx) const {
274+ int GeometryTGeo::getStave (int chipIdx) const
275+ {
265276 int lay = getLayer (chipIdx);
266277 int absStave = mStaveIdxDisc [lay];
267278 while (chipIdx >= mChipIdxStave [absStave] && absStave < mStaveIdxDisc [lay + 1 ]) {
@@ -271,15 +282,16 @@ int GeometryTGeo::getStave(int chipIdx) const {
271282}
272283
273284// retrieve local chip number on stave from chip ID
274- int GeometryTGeo::getChipOnStave (int chipIdx) const {
285+ int GeometryTGeo::getChipOnStave (int chipIdx) const
286+ {
275287 int lay = getLayer (chipIdx);
276288 int stave = getStave (chipIdx);
277289 return chipIdx - mChipIdxStave [mStaveIdxDisc [lay] + stave];
278290}
279291
280292std::string GeometryTGeo::getMatrixPath (int direction, int layer, int stave, int chip) const
281293{
282-
294+
283295 // PrintChipID(index, subDetID, petalcase, disk, layer, stave, halfstave, mod, chip);
284296
285297 std::string path = Form (" /cave_1/barrel_1/%s_2/" , GeometryTGeo::getFT3VolPattern ());
@@ -290,14 +302,14 @@ std::string GeometryTGeo::getMatrixPath(int direction, int layer, int stave, int
290302 // Sensors directly placed in layer volume?
291303
292304 path += Form (" %s%d_%d_1/" , getFT3LayerPattern (), direction, layer); // TRKLayerx_1
293- // std::string sensorName = std::string("FT3Sensor_") + std::to_string(layer) + "_" + std::to_string(direction) + "_" + std::to_string(mChipStaveIds[index]) + "_" + index;
305+ // std::string sensorName = std::string("FT3Sensor_") + std::to_string(layer) + "_" + std::to_string(direction) + "_" + std::to_string(mChipStaveIds[index]) + "_" + index;
294306 path += Form (" FT3Sensor_Active_%d_%d_%d_%d_%d" , direction, layer, stave, chip, chip);
295307 /*
296308 if (mLayoutMLOT == FT3Layout::kCylindrical) {
297309 // TODO: fix this caser?
298310 path += Form("%s%d_1/", getTRKSensorPattern(), layer); // TRKSensorx_1
299311 } else {
300- path += Form("%s%d_%d/", getFT3StavePattern(), layer, stave);
312+ path += Form("%s%d_%d/", getFT3StavePattern(), layer, stave);
301313 path += Form("%s%d_%d/", getFT3ModulePattern(), layer, mod);
302314 path += Form("%s%d_%d_1", getFT3ChipPattern(), layer, chipID);
303315 }
@@ -340,20 +352,21 @@ void GeometryTGeo::fillMatrixCache(int mask)
340352 layer = absDisc - mNumberOfDiscs [0 ];
341353 }
342354 LOG (info) << " Direction " << direction << " layer " << layer;
343- if (absDisc >= mNumberOfStavesPerDisc .size ()) LOG (fatal) << " Not enough entries in mNumberOfStavesPerDisc " << absDisc << " " << mNumberOfStavesPerDisc .size ();
344- for (int stave = 0 ; stave < mNumberOfStavesPerDisc [absDisc]; stave++ ) {
355+ if (absDisc >= mNumberOfStavesPerDisc .size ())
356+ LOG (fatal) << " Not enough entries in mNumberOfStavesPerDisc " << absDisc << " " << mNumberOfStavesPerDisc .size ();
357+ for (int stave = 0 ; stave < mNumberOfStavesPerDisc [absDisc]; stave++) {
345358 int absStave = mStaveIdxDisc [absDisc] + stave;
346359 if (absStave + 1 >= mChipIdxStave .size ())
347- LOG (fatal) << " Attempting to get absStave + 1 from index array size " << mChipIdxStave .size ();
360+ LOG (fatal) << " Attempting to get absStave + 1 from index array size " << mChipIdxStave .size ();
348361 int nChip = mChipIdxStave [absStave + 1 ] - mChipIdxStave [absStave]; // TODO: this is too often == 0
349362 LOG (debug) << " Getting matrices for direction " << direction << " layer " << layer << " stave " << stave << " : " << nChip << " chips" ;
350- for (int chip = 0 ; chip < nChip; chip++ ) {
351- int chipIdx = getChipIndex (direction, layer, stave, chip);
363+ for (int chip = 0 ; chip < nChip; chip++) {
364+ int chipIdx = getChipIndex (direction, layer, stave, chip);
352365 if (!gGeoManager ->cd (getMatrixPath (direction, layer, stave, chip).c_str ()))
353366 LOG (fatal) << " Geometry path not found " << getMatrixPath (direction, layer, stave, chip);
354367 const TGeoHMatrix* matL2G = gGeoManager ->GetCurrentMatrix ();
355368 if (chipIdx >= mSize )
356- LOG (fatal) << " ChipIdx " << chipIdx << " out of range " << mSize ;
369+ LOG (fatal) << " ChipIdx " << chipIdx << " out of range " << mSize ;
357370 cacheL2G.setMatrix (Mat3D (*matL2G), chipIdx);
358371
359372 matL2G->LocalToMaster (locA, gloA);
@@ -369,10 +382,10 @@ void GeometryTGeo::fillMatrixCache(int mask)
369382
370383 static TGeoHMatrix t2l;
371384 t2l.Clear ();
372- t2l.RotateZ (mCacheRefAlphaDiscs [chipIdx] * TMath::RadToDeg ()); // TODO: do we need this cache?
385+ t2l.RotateZ (mCacheRefAlphaDiscs [chipIdx] * TMath::RadToDeg ()); // TODO: do we need this cache?
373386 const TGeoHMatrix& matL2Gi = matL2G->Inverse ();
374387 t2l.MultiplyLeft (&matL2Gi);
375- cacheT2L.setMatrix (Mat3D (t2l),chipIdx); // TODO: may need deref with *
388+ cacheT2L.setMatrix (Mat3D (t2l), chipIdx); // TODO: may need deref with *
376389 }
377390 }
378391 }
@@ -394,5 +407,5 @@ void GeometryTGeo::Print(Option_t*) const
394407 LOGF (info, " Total number of sensors: %d" , mSize );
395408}
396409
397- }
398- }
410+ } // namespace ft3
411+ } // namespace o2
0 commit comments