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