File indexing completed on 2025-08-06 08:22:00
0001 #include "MvtxPrototype2Geom.h"
0002
0003 #include <iostream>
0004
0005
0006 std::unique_ptr<MvtxPrototype2Geom> MvtxPrototype2Geom::s_instance;
0007
0008 void MvtxPrototype2Geom::Build()
0009 {
0010 if (isBuilt()) {
0011 std::cout << "Already built" << std::endl;
0012 return;
0013 }
0014
0015 m_lastChipIndex.resize(m_numOfLayers);
0016 int num_of_chips = 0;
0017 for (int iLay = 0; iLay < m_numOfLayers; ++iLay){
0018 num_of_chips += m_numOfStaves * m_numOfChips;
0019 m_lastChipIndex[iLay] = num_of_chips - 1;
0020 }
0021 setSize(num_of_chips);
0022 fillMatrixCache();
0023 }
0024
0025
0026 void MvtxPrototype2Geom::fillMatrixCache()
0027 {
0028 if (m_size < 1) {
0029 std::cout << "Build was not called yet. Calling now..." << std::endl;
0030 Build();
0031 }
0032 m_l2G.setSize(m_size);
0033 for (int i = 0; i < m_size; i++) {
0034 TGeoHMatrix* hm = extractMatrixSensor(i);
0035 m_l2G.setMatrix(*hm, i);
0036 }
0037
0038 return;
0039 }
0040
0041
0042 TGeoHMatrix* MvtxPrototype2Geom::extractMatrixSensor(int index)
0043 {
0044 int lay = index / getNumberOfChipsInLay();
0045 int indexInLay = index % getNumberOfChipsInLay();
0046 int stv = indexInLay / m_numOfChips;
0047 int indexInStv = indexInLay % m_numOfChips;
0048
0049 float shift_dz = (2 * SegmentationAlpide::PassiveEdgeSide) + \
0050 SegmentationAlpide::ActiveMatrixSizeCols + s_pitchChip_IB;
0051
0052 float dx = 0.f;
0053 float dy = (lay - m_numOfLayers + 1) * s_gapLayers_TB;
0054 float dz = (indexInStv - 4) * shift_dz;
0055
0056 if (Verbose()>0) {
0057 std::cout << "Filling matrix for sensor in chip " << indexInStv << " in stave " << stv;
0058 std::cout << " of layer " << lay << "\n";
0059 std::cout << "shift in z " << dz << " and in dx " << dx << std::endl;
0060 }
0061
0062 static TGeoHMatrix matTmp;
0063 matTmp = TGeoTranslation(dx, dy, dz);
0064 static TGeoTranslation tra(0., -.5 * Segmentation::SensorLayerThicknessEff, 0.);
0065 matTmp *= tra;
0066
0067 return &matTmp;
0068 }