File indexing completed on 2025-08-03 08:20:23
0001
0002
0003
0004
0005
0006
0007 #include <ffamodules/CDBInterface.h>
0008
0009 #include <fun4all/Fun4AllRunNodeInputManager.h>
0010 #include <fun4all/Fun4AllServer.h>
0011
0012 #include <micromegas/MicromegasDefs.h>
0013
0014 #include <phool/getClass.h>
0015 #include <phool/recoConsts.h>
0016
0017 #include <trackreco/MakeActsGeometry.h>
0018
0019 R__LOAD_LIBRARY(libffamodules.so)
0020 R__LOAD_LIBRARY(libfun4all.so)
0021 R__LOAD_LIBRARY(libtrack_reco.so)
0022
0023 namespace
0024 {
0025
0026
0027 template<class T> class range_adaptor
0028 {
0029 public:
0030 range_adaptor( const T& range ):m_range(range){}
0031 const typename T::first_type& begin() {return m_range.first;}
0032 const typename T::second_type& end() {return m_range.second;}
0033 private:
0034 T m_range;
0035 };
0036
0037
0038 template<class T, class U>
0039 std::ostream& operator << (std::ostream& out, const std::pair<T, U> pair)
0040 {
0041 out << "{" << pair.first << "," << pair.second << "}";
0042 return out;
0043 }
0044
0045
0046 template<template<typename,typename> class Container, class T, class A>
0047 std::ostream& operator << (std::ostream& out, const Container<T,A>& container)
0048 {
0049 out << "{";
0050 bool first = true;
0051 for( const auto& value:container )
0052 {
0053 if( !first ) { out << ", "; };
0054 first = false;
0055 out << value;
0056 }
0057 out << "}";
0058 return out;
0059 }
0060
0061 }
0062
0063 void ExportTpotAcceptanceRange()
0064 {
0065
0066
0067 auto rc = recoConsts::instance();
0068 auto se = Fun4AllServer::instance();
0069 auto topNode = se->topNode();
0070
0071
0072 const int runnumber = 52077;
0073
0074 rc->set_IntFlag("RUNNUMBER", runnumber);
0075 rc->set_IntFlag("RUNSEGMENT", 0);
0076 rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0077 rc->set_uint64Flag("TIMESTAMP", runnumber);
0078
0079
0080 std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0081 std::cout << "Geometry - geofile: " << geofile << std::endl;
0082 auto ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0083 ingeo->AddFile(geofile);
0084 ingeo->run(0);
0085
0086
0087 auto geom = new MakeActsGeometry;
0088 geom->set_mvtx_applymisalign(true);
0089 geom->InitRun( topNode );
0090
0091
0092
0093 auto m_micromegas_geomcontainer = findNode::getClass<PHG4CylinderGeomContainer>(topNode, "CYLINDERGEOM_MICROMEGAS_FULL");
0094
0095
0096 auto m_tGeometry = findNode::getClass<ActsGeometry>(topNode, "ActsGeometry");
0097
0098 using range_list_t = std::vector<CylinderGeomMicromegas::range_t>;
0099 range_list_t theta_range_list;
0100 range_list_t phi_range_list;
0101
0102
0103 for( const auto& [layer, layergeom] : range_adaptor( m_micromegas_geomcontainer->get_begin_end() ) )
0104 {
0105
0106 assert(layer == layergeom->get_layer());
0107
0108 auto micromegas_layergeom = static_cast<CylinderGeomMicromegas*>(layergeom);
0109
0110
0111 const unsigned int tile_count = micromegas_layergeom->get_tiles_count();
0112
0113
0114 const auto segmentation = micromegas_layergeom->get_segmentation_type();
0115
0116 for( unsigned int itile = 0; itile < tile_count; ++itile )
0117 {
0118 switch(segmentation)
0119 {
0120 case MicromegasDefs::SegmentationType::SEGMENTATION_PHI:
0121 phi_range_list.emplace_back(micromegas_layergeom->get_phi_range(itile, m_tGeometry));
0122 break;
0123
0124 case MicromegasDefs::SegmentationType::SEGMENTATION_Z:
0125 theta_range_list.emplace_back(micromegas_layergeom->get_theta_range(itile, m_tGeometry));
0126 break;
0127 }
0128 }
0129 }
0130
0131
0132 auto get_phi_range = [phi_range_list]( std::vector<int> indexes )
0133 {
0134 CylinderGeomMicromegas::range_t out{0,0};
0135 for(const auto& i:indexes)
0136 {
0137 const auto& window = phi_range_list[i];
0138 if( out.first == 0 || window.first > out.first ) out.first = window.first;
0139 if( out.second == 0 || window.second < out.second ) out.second = window.second;
0140 }
0141 return out;
0142 };
0143
0144 const auto phi_range_central = get_phi_range( {0,1,2,3} );
0145 const auto phi_range_east = get_phi_range( {4,5} );
0146 const auto phi_range_west = get_phi_range( {6,7} );
0147
0148 std::cout << "phi_range_central=" << phi_range_central << std::endl;
0149 std::cout << "phi_range_east=" << phi_range_east << std::endl;
0150 std::cout << "phi_range_west=" << phi_range_west << std::endl;
0151 std::cout << std::endl;
0152
0153 std::cout << "theta_range_central=" << range_list_t{theta_range_list[0], theta_range_list[1], theta_range_list[2], theta_range_list[3]} << std::endl;
0154 std::cout << "theta_range_east=" << range_list_t{theta_range_list[4], theta_range_list[5]} << std::endl;
0155 std::cout << "theta_range_west=" << range_list_t{theta_range_list[6], theta_range_list[7]} << std::endl;
0156
0157 return;
0158 }