File indexing completed on 2025-12-17 09:23:58
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <g4detectors/PHG4CylinderGeomContainer.h>
0010
0011 #include <micromegas/CylinderGeomMicromegas.h>
0012
0013 #include <trackreco/MakeActsGeometry.h>
0014
0015 #include <ffamodules/CDBInterface.h>
0016
0017 #include <fun4all/Fun4AllRunNodeInputManager.h>
0018 #include <fun4all/Fun4AllServer.h>
0019
0020 #include <micromegas/MicromegasDefs.h>
0021
0022 #include <phool/getClass.h>
0023 #include <phool/recoConsts.h>
0024
0025 #include <Rtypes.h> // for R__LOAD_LIBRARY macro
0026 #include <TVector3.h>
0027
0028 R__LOAD_LIBRARY(libffamodules.so)
0029 R__LOAD_LIBRARY(libfun4all.so)
0030 R__LOAD_LIBRARY(libtrack_reco.so)
0031
0032 namespace
0033 {
0034
0035 class std_precision_restore_t
0036 {
0037 public:
0038
0039
0040 explicit std_precision_restore_t( std::ostream& out = std::cout ):
0041 m_out( out ),
0042 m_precision( out.precision() )
0043 {}
0044
0045
0046 ~std_precision_restore_t()
0047 { m_out << std::setprecision( m_precision ); }
0048
0049 private:
0050 std::ostream& m_out;
0051 int m_precision = 0;
0052 };
0053
0054
0055 class translation_parameters_t
0056 {
0057 public:
0058
0059 translation_parameters_t( TrkrDefs::hitsetkey key, double local_x, double local_y ):
0060 m_hitsetkey( key ),
0061 m_local_x( local_x ),
0062 m_local_y( local_y )
0063 {}
0064
0065
0066 TrkrDefs::hitsetkey m_hitsetkey = 0;
0067 double m_local_x = 0;
0068 double m_local_y = 0;
0069 double m_global_x = 0;
0070 double m_global_y = 0;
0071 double m_global_z = 0;
0072
0073
0074 friend std::ostream& operator << (std::ostream& out, const translation_parameters_t& p )
0075 {
0076 std_precision_restore_t precision_restore(out);
0077 out << p.m_hitsetkey << " 0 0 0 "
0078 << std::setprecision(3)
0079 << p.m_global_x*Acts::UnitConstants::cm << " "
0080 << p.m_global_y*Acts::UnitConstants::cm << " "
0081 << p.m_global_z*Acts::UnitConstants::cm;
0082 return out;
0083 }
0084
0085 using list = std::vector<translation_parameters_t>;
0086
0087 };
0088
0089
0090
0091
0092
0093
0094 translation_parameters_t::list translation_parameters =
0095 {
0096 { 53936384, 1.86, -0.56 },
0097 { 53936385, 1.74, -0.61 },
0098 { 53936386, 1.49, -1.23 },
0099 { 53936387, 1.58, -1.02 },
0100 { 53936388, 0.34, -0.96 },
0101 { 53936389, 0.45, 0.66 },
0102 { 53936390, 2.02, -0.52 },
0103 { 53936391, 2.14, -1.13 },
0104 { 54001664, 1.86, -0.56 },
0105 { 54001665, 1.74, -0.61 },
0106 { 54001666, 1.49, -1.23 },
0107 { 54001667, 1.58, -1.02 },
0108 { 54001668, 0.34, -0.96 },
0109 { 54001669, 0.45, 0.66 },
0110 { 54001670, 2.02, -0.52 },
0111 { 54001671, 2.14, -1.13 }
0112 };
0113
0114 }
0115
0116
0117 void ConvertTpotAlignment()
0118 {
0119
0120
0121 auto *rc = recoConsts::instance();
0122 auto *se = Fun4AllServer::instance();
0123 auto *topNode = se->topNode();
0124
0125
0126 const int runnumber = 52077;
0127
0128 rc->set_IntFlag("RUNNUMBER", runnumber);
0129 rc->set_IntFlag("RUNSEGMENT", 0);
0130 rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0131 rc->set_uint64Flag("TIMESTAMP", runnumber);
0132
0133
0134 std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0135 std::cout << "Geometry - geofile: " << geofile << std::endl;
0136 auto *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0137 ingeo->AddFile(geofile);
0138 ingeo->run(0);
0139
0140
0141 auto *geom = new MakeActsGeometry;
0142 geom->set_mvtx_applymisalign(true);
0143 geom->InitRun( topNode );
0144
0145
0146
0147 auto *m_micromegas_geomcontainer = findNode::getClass<PHG4CylinderGeomContainer>(topNode, "CYLINDERGEOM_MICROMEGAS_FULL");
0148
0149
0150 auto *m_tGeometry = findNode::getClass<ActsGeometry>(topNode, "ActsGeometry");
0151
0152
0153 const auto [begin,end] = m_micromegas_geomcontainer->get_begin_end();
0154 for( auto iter = begin; iter != end; ++iter )
0155 {
0156
0157 auto *layergeom = dynamic_cast<CylinderGeomMicromegas*>(iter->second);
0158
0159
0160 const unsigned int layer = layergeom->get_layer();
0161
0162
0163 const unsigned int tile_count = layergeom->get_tiles_count();
0164
0165
0166 for( unsigned int tileid = 0; tileid < tile_count; ++tileid )
0167 {
0168
0169 const auto center = layergeom->get_world_from_local_coords( tileid, m_tGeometry, {0,0} );
0170 std::cout << "ConvertTpotAlignment - layer: " << layer << " tile: " << tileid << " center: {" << center.x() << "," << center.y() << "," << center.z() << "}" << std::endl;
0171 }
0172 }
0173
0174
0175
0176 for( auto&& p:translation_parameters )
0177 {
0178
0179 const auto layer = TrkrDefs::getLayer(p.m_hitsetkey);
0180 const auto tileid = MicromegasDefs::getTileId(p.m_hitsetkey);
0181
0182
0183 const auto *const layergeom = static_cast<const CylinderGeomMicromegas*>(m_micromegas_geomcontainer->GetLayerGeom(layer));
0184
0185
0186 const auto translation_global = layergeom->get_world_from_local_vect(tileid, m_tGeometry, {p.m_local_x, p.m_local_y, 0} );
0187 p.m_global_x = translation_global.x();
0188 p.m_global_y = translation_global.y();
0189 p.m_global_z = translation_global.z();
0190
0191 }
0192
0193
0194 for( const auto& p:translation_parameters )
0195 { std::cout << p << std::endl; }
0196
0197 std::cout << "All done" << std::endl;
0198
0199 }