9 #include "gVariables.hh" 10 #include "gDataConversionUtilities.hh" 32 vector<string> values;
37 line = (line.find(
"#") != string::npos) ?
38 line.substr(0, line.find_first_of(
"#")) :
41 size_t foundAdress = line.find(a_key);
43 if (foundAdress != string::npos)
45 values =
Split(a_line);
46 values.erase (values.begin());
65 vector<string>
Split(
string a_line)
68 stringstream ss(a_line);
70 vector<string> tokens;
73 tokens.push_back(buf);
93 for(uint16_t i=0; i < ap_v.size(); i++)
97 for (
int j=0; j<i; j++)
119 int WriteVector(ofstream& file,
const string& a_key, vector <T> a_vals)
121 int n = a_vals.size();
126 for (
int i=0; i < n; i++)
131 file << ss.str() << endl;
133 file << ss.str() <<
",";
137 file << a_key <<
"0" <<endl;
142 template int WriteVector(ofstream& file,
const string& a_key, vector <double> a_vals);
158 int WriteVector(ofstream& file,
const string& a_key, vector <string> a_vals)
160 int n = a_vals.size();
165 for (
int i=0; i < n; i++)
168 file << a_vals[i] << endl;
170 file << a_vals[i] <<
",";
174 file << a_key <<
"0" <<endl;
193 int WriteVector(ofstream& file,
const string& a_key, vector <vector<string> > a_vals)
195 int n = a_vals.size();
197 for (
int i=0; i < n; i++)
198 for (
int j=0; j < 3; j++)
199 if (i == n-1 && j == 2)
200 file << a_vals[i][j] << endl;
202 file << a_vals[i][j] <<
",";
223 ifstream mac_file(a_pathMac, ios::in);
229 while(getline(mac_file, quickLine))
231 vector <string> values;
239 char first_char = values[0].at(0);
241 if(first_char ==
'/')
242 ap_pathToMacFiles.push_back(values[0]);
245 ap_pathToMacFiles.push_back(
GetPathOfFile(a_pathMac)+values[0]);
252 Cerr(
"***** GetGATEMacFiles() -> Couldn't open mac file "<< a_pathMac <<
" !" << endl);
278 vector<string> path_mac_files;
279 path_mac_files.push_back(a_pathMac);
283 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
287 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
288 cout << f <<
" : " << path_mac_files[f] << endl;
291 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
293 ifstream mac_file(path_mac_files[f], ios::in);
298 while(getline(mac_file, line))
301 if(line.find(
"/gate/systems/") != string::npos )
303 if(line.find(
"/gate/systems/ecat") != string::npos )
306 if(line.find(
"/gate/systems/cylindricalPET") != string::npos )
309 if(line.find(
"/gate/systems/SPECThead") != string::npos )
312 if(line.find(
"/gate/systems/OPET") != string::npos ||
313 line.find(
"/gate/systems/CTSCANNER") != string::npos ||
314 line.find(
"/gate/systems/CPET") != string::npos ||
315 line.find(
"/gate/systems/ecatAccel") != string::npos ||
316 line.find(
"/gate/systems/OpticalSystem") != string::npos )
318 Cerr(
"unsupported system detected (line = " << line <<
") ! "<< endl);
319 Cerr(
"supported systems for this script are cylindricalPET, SPECThead, and ecat" << endl);
326 Cerr(
"***** GetGATESystemType() -> Error : Couldn't open mac file "<< path_mac_files[f] <<
" !" << endl);
363 string& rsector_name,
365 string& submodule_name,
366 string& crystal_name,
367 vector<string>& layers_name,
372 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
374 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
379 while(getline(mac_file, quickLine))
381 vector <string> values;
383 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/rsector/attach", quickLine);
387 rsector_name = values[0];
391 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/module/attach", quickLine);
394 module_name = values[0];
398 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/submodule/attach", quickLine);
401 submodule_name = values[0];
405 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/crystal/attach", quickLine);
408 crystal_name = values[0];
417 values =
CheckGATECommand(
"/gate/systems/cylindricalPET/layer"+ss.str()+
"/attach", quickLine);
420 layers_name.push_back(values[0]);
429 Cerr(
"***** GetGATEAliasesCylindrical()->Couldn't open mac file "<< path_mac_files[f] <<
" !" << endl);
440 Cout(
"***** GetGATEAliasesCylindrical() :: Error : Missing elements in the system architecture" << endl <<
441 " At least two of the following lines are required :" << endl <<
442 " - /gate/systems/cylindricalPET/rsector/attach" << endl <<
443 " - /gate/systems/cylindricalPET/module/attach" << endl <<
444 " - /gate/systems/cylindricalPET/submodule/attach" << endl <<
445 " - /gate/systems/cylindricalPET/crystal/attach" << endl <<
446 " - /gate/systems/cylindricalPET/layeri[i=0..3]/attach" << endl);
452 if(rsector_name.empty())
454 if(module_name.empty())
457 rsector_name = submodule_name;
463 rsector_name = module_name;
470 if(!rsector_name.empty())
Cout(
"Detected rsector container's name : " << rsector_name << endl);
471 if(!module_name.empty())
Cout(
"Detected module container's name : " << module_name << endl);
472 if(!submodule_name.empty())
Cout(
"Detected submodule container's name : " << submodule_name << endl);
473 if(!crystal_name.empty())
Cout(
"Detected crystal container's name : " << crystal_name << endl);
474 for(
size_t l=0 ; l<layers_name.size() ; l++)
475 if(!layers_name[l].empty())
Cout(
"Detected layer #"<< l <<
" container's name : " << layers_name[l] << endl);
504 string& crystal_name,
509 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
511 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
517 while(getline(mac_file, quickLine))
519 vector <string> values;
524 block_name = values[0];
531 crystal_name = values[0];
538 Cerr(
"***** GetGATEAliasesEcat()-> Couldn't open mac file "<< path_mac_files[f].c_str()<<
" !" << endl);
547 Cerr(
"***** GetGATEAliasesEcat() :: Error : Missing elements in the system architecture" << endl
548 <<
" The following lines are required :" << endl
549 <<
" - /gate/systems/ecat/block/attach" << endl
550 <<
" - /gate/systems/ecat/crystal/attach" << endl);
556 Cout(
"First container's name (usually block) is : " << block_name << endl
557 <<
"Second container's name (usually crystal) is : " << crystal_name << endl);
588 string& crystal_name,
594 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
596 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
603 while(getline(mac_file, quickLine))
605 vector <string> values;
607 values =
CheckGATECommand(
"/gate/systems/SPECThead/base/attach", quickLine);
610 base_name = values[0];
614 values =
CheckGATECommand(
"/gate/systems/SPECThead/crystal/attach", quickLine);
617 crystal_name = values[0];
621 values =
CheckGATECommand(
"/gate/systems/SPECThead/pixel/attach", quickLine);
624 pixel_name = values[0];
632 Cerr(
"***** GetGATEAliasesSPECT()-> Couldn't open mac file "<< path_mac_files[f].c_str()<<
" !" << endl);
640 Cerr(
"***** GetGATEAliasesSPECT() :: Error : Missing elements in the system architecture" << endl
641 <<
" The following line is required :" << endl
642 <<
" - /gate/systems/SPECThead/crystal/attach" << endl);
648 Cout(
"Crystal container's name is : " << crystal_name << endl);
674 int32_t nCrystalsTransaxial,
675 int32_t nCrystalsAxial,
679 int32_t nCrystalsPerRing = nBlocksPerRing * nCrystalsTransaxial;
681 int32_t ringID = (int32_t)( blockID/nBlocksPerRing ) * nCrystalsAxial
682 + (int32_t)( crystalID/nCrystalsTransaxial );
684 int32_t castorID = nCrystalsPerRing * ringID
685 + nCrystalsTransaxial*( blockID % nBlocksPerRing )
686 + crystalID % nCrystalsTransaxial;
709 uint32_t a_nProjectionsByHead)
712 int32_t angID = round(a_rotAngle/a_angStep);
715 int32_t castorID = a_headID*a_nProjectionsByHead + angID;
752 float_t a_headAngPitch,
753 float_t a_crystalSizeAxl,
754 float_t a_crystalSizeTrs,
759 int32_t castorID = 0;
762 if (a_nbSimulatedPixels > 1)
764 castorID = a_pixelID;
771 FLTNB sizePixTrs = a_crystalSizeTrs/a_nPixTrs;
772 FLTNB sizePixAxl = a_crystalSizeAxl/a_nPixAxl;
775 uint32_t axialID = (uint32_t)(( a_gPosZ + a_nPixAxl/2*sizePixAxl) / sizePixAxl);
779 float_t ang = a_headID*a_headAngPitch + a_rotAngle;
782 float_t sin_a = sin(-ang*M_PI/180);
783 float_t cos_a = cos(-ang*M_PI/180);
784 float_t trs_pos = a_gPosX*sin_a + a_gPosY*cos_a ;
787 uint32_t transID = (uint32_t)(( trs_pos + a_nPixTrs/2*sizePixTrs) / sizePixTrs);
789 if ( axialID < a_nPixAxl && transID < a_nPixTrs )
791 castorID = axialID*a_nPixTrs + transID;
795 castorID = a_nPixAxl*a_nPixTrs;
807 uint32_t nRsectorsAxial,
808 bool a_invertDetOrder,
809 int a_rsectorIdOrder,
810 uint32_t nModulesTransaxial,
811 uint32_t nModulesAxial,
812 uint32_t nSubmodulesTransaxial,
813 uint32_t nSubmodulesAxial,
814 uint32_t nCrystalsTransaxial,
815 uint32_t nCrystalsAxial,
817 uint32_t* nCrystalPerLayer,
818 vector<uint32_t> nLayersRptTransaxial,
819 vector<uint32_t> nLayersRptAxial,
827 uint32_t castorID = 0;
831 if(nLayersRptTransaxial.size()==0 && nLayersRptAxial.size()==0)
839 for(
int l=0 ; l<layer; l++)
840 castorID += nCrystalPerLayer[l];
842 int32_t nTrsCrystalsPerSubmodule = nCrystalsTransaxial;
843 int32_t nTrsCrystalsPerModule = nTrsCrystalsPerSubmodule * nSubmodulesTransaxial;
844 int32_t nTrsCrystalsPerRsector = nTrsCrystalsPerModule * nModulesTransaxial;
845 int32_t nCrystalsPerRing = nTrsCrystalsPerRsector * nRsectorsAngPos;
849 int32_t rsectorAxlID = 0 ;
850 int32_t rsectorTrsID = 0 ;
853 if(a_rsectorIdOrder == 0)
855 rsectorAxlID = rsectorID/nRsectorsAngPos ;
856 rsectorTrsID = (int32_t)(rsectorID%nRsectorsAngPos) ;
860 rsectorAxlID = rsectorID%nRsectorsAxial ;
861 rsectorTrsID = (int32_t)(rsectorID/nRsectorsAxial) ;
866 int32_t ringID = rsectorAxlID * nModulesAxial * nSubmodulesAxial * nCrystalsAxial
867 + (int32_t)(moduleID/nModulesTransaxial) * nSubmodulesAxial * nCrystalsAxial
868 + (int32_t)(submoduleID/nSubmodulesTransaxial) * nCrystalsAxial
869 + (int32_t)(crystalID/nCrystalsTransaxial);
872 moduleID = moduleID % nModulesTransaxial;
873 submoduleID = submoduleID % nSubmodulesTransaxial;
874 crystalID = crystalID % nCrystalsTransaxial;
877 if( a_invertDetOrder )
879 moduleID = nModulesTransaxial-1 - moduleID;
880 submoduleID = nSubmodulesTransaxial-1 - submoduleID;
881 crystalID = nCrystalsTransaxial-1 - crystalID;
885 castorID += nCrystalsPerRing * ringID
886 + nTrsCrystalsPerRsector * rsectorTrsID
887 + nTrsCrystalsPerModule * moduleID
888 + nTrsCrystalsPerSubmodule * submoduleID
897 uint32_t sum_detectors_prev_layers = 0;
902 while ( layerID >= (int32_t)( sum_detectors_prev_layers
903 + ( nLayersRptTransaxial[layer]
904 * nLayersRptAxial[layer]) ) )
907 sum_detectors_prev_layers += nLayersRptTransaxial[layer]
908 * nLayersRptAxial[layer];
916 if (layer>0)layerID -= sum_detectors_prev_layers;
920 for(
int l=0 ; l<layer ; l++)
921 castorID += nCrystalPerLayer[l];
923 int32_t nTrsCrystalsPerSubmodule = nCrystalsTransaxial * nLayersRptTransaxial[layer];
924 int32_t nTrsCrystalsPerModule = nTrsCrystalsPerSubmodule * nSubmodulesTransaxial;
925 int32_t nTrsCrystalsPerRsector = nTrsCrystalsPerModule * nModulesTransaxial;
926 int32_t nCrystalsPerRing = nTrsCrystalsPerRsector * nRsectorsAngPos;
930 int32_t rsectorAxlID = 0 ;
931 int32_t rsectorTrsID = 0 ;
934 if(a_rsectorIdOrder == 0)
936 rsectorAxlID = rsectorID/nRsectorsAngPos ;
937 rsectorTrsID = (int32_t)(rsectorID%nRsectorsAngPos) ;
941 rsectorAxlID = rsectorID%nRsectorsAxial ;
942 rsectorTrsID = (int32_t)(rsectorID/nRsectorsAxial) ;
947 int32_t ringID = rsectorAxlID * nModulesAxial * nSubmodulesAxial * nCrystalsAxial * nLayersRptAxial[layer]
948 + (int32_t)(moduleID/nModulesTransaxial) * nSubmodulesAxial * nCrystalsAxial * nLayersRptAxial[layer]
949 + (int32_t)(submoduleID/nSubmodulesTransaxial) * nCrystalsAxial * nLayersRptAxial[layer]
950 + (int32_t)(crystalID/nCrystalsTransaxial) * nLayersRptAxial[layer];
953 if(!nLayersRptTransaxial.empty() )
954 ringID += (int32_t)(layerID/nLayersRptTransaxial[layer]);
958 moduleID = moduleID % nModulesTransaxial;
959 submoduleID = submoduleID % nSubmodulesTransaxial;
960 crystalID = crystalID % nCrystalsTransaxial;
961 layerID = layerID % nLayersRptTransaxial[layer];
964 if( a_invertDetOrder )
966 moduleID = nModulesTransaxial-1 - moduleID;
967 submoduleID = nSubmodulesTransaxial-1 - submoduleID;
968 crystalID = nCrystalsTransaxial-1 - crystalID;
969 layerID = nLayersRptTransaxial[layer]-1 - layerID;
973 castorID += nCrystalsPerRing * ringID
974 + nTrsCrystalsPerRsector * rsectorTrsID
975 + nTrsCrystalsPerModule * moduleID
976 + nTrsCrystalsPerSubmodule * submoduleID
1002 int comptonPhantom1,
int comptonPhantom2,
1003 int rayleighPhantom1,
int rayleighPhantom2)
1005 if ( (eventID1 != eventID2)
1012 if (comptonPhantom1 == 0 && comptonPhantom2 == 0 &&
1013 rayleighPhantom1 == 0 && rayleighPhantom2 == 0)
1018 if (comptonPhantom1 == 1 || comptonPhantom2 == 1 ||
1019 rayleighPhantom1 == 1 || rayleighPhantom2 == 1)
1022 if (comptonPhantom1 > 1 || comptonPhantom2 > 1 ||
1023 rayleighPhantom1 > 1 || rayleighPhantom2 > 1)
1063 uint32_t *nb_crystal_per_layer,
1064 uint32_t &nCrystalsTot,
1065 uint32_t &nCrystalsAxial,
1066 uint32_t &nCrystalsTransaxial,
1067 vector<uint32_t> &nLayersRptAxial,
1068 vector<uint32_t> &nLayersRptTransaxial,
1069 uint32_t &nSubmodulesAxial,
1070 uint32_t &nSubmodulesTransaxial,
1071 uint32_t &nModulesAxial,
1072 uint32_t &nModulesTransaxial,
1073 uint32_t &nRsectorsAxial,
1074 uint32_t &nRsectorsAngPos,
1075 bool &invert_det_order,
1076 int &rsector_id_order,
1077 uint32_t &start_time_ms,
1078 uint32_t &duration_ms,
1079 FLTNB &pet_coinc_window,
1082 vector<string> path_mac_files;
1083 path_mac_files.push_back(a_pathMac);
1088 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
1092 string rsector_name =
"";
1093 string module_name =
"";
1094 string submodule_name =
"";
1095 string crystal_name =
"";
1096 string mod_rptr_type =
"cubicArray";
1097 string smod_rptr_type =
"cubicArray";
1098 string cry_rptr_type =
"cubicArray";
1099 string lay_rptr_type =
"cubicArray";
1102 int mod_linear_nb = 0;
1103 int subm_linear_nb = 0;
1104 int cry_linear_nb = 0;
1105 vector<int> lay_linear_nb;
1107 vector <string> layers_name;
1108 bool is_rsector_Y_axis =
false;
1111 if(
GetGATEAliasesCylindrical(path_mac_files, rsector_name, module_name, submodule_name, crystal_name, layers_name, vb) )
1113 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover aliases for the elements of the cylindricalPET !" << endl);
1118 nLayers = layers_name.size();
1121 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
1123 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
1126 double time_start =-1.,
1130 while(getline(mac_file, line))
1132 vector <string> values;
1138 kword =
"/gate/"+rsector_name+
"/placement/setTranslation";
1142 if (values.size()>0)
1144 FLTNB rsector_pos_X =0.,
1150 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1155 if(rsector_pos_Y!=0) is_rsector_Y_axis =
true;
1161 if(rsector_pos_Y > 0 || rsector_pos_X < 0)
1162 invert_det_order =
true;
1167 kword =
"/gate/"+rsector_name+
"/ring/setRepeatNumber";
1169 if (values.size()>0)
1173 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1180 kword =
"/gate/"+rsector_name+
"/linear/setRepeatNumber";
1182 if (values.size()>0)
1186 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1193 kword =
"/gate/"+rsector_name+
"/cubicArray/setRepeatNumberZ";
1196 if (values.size()>0)
1200 rsector_id_order = nRsectorsAngPos>1 ? 1 : 0 ;
1204 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1215 kword = is_rsector_Y_axis ?
1216 "/gate/"+module_name+
"/cubicArray/setRepeatNumberX":
1217 "/gate/"+module_name+
"/cubicArray/setRepeatNumberY";
1220 if (values.size()>0)
1224 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1229 kword =
"/gate/"+module_name+
"/cubicArray/setRepeatNumberZ";
1231 if (values.size()>0)
1235 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1241 kword =
"/gate/"+module_name+
"/linear/setRepeatNumber";
1243 if (values.size()>0)
1248 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1254 kword =
"/gate/"+module_name+
"/cubicArray/setRepeatNumber ";
1256 if (values.size()>0)
1261 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1267 double module_step_trs=0., module_step_axl=0.;
1269 kword =
"/gate/"+module_name+
"/linear/setRepeatVector";
1271 if (values.size()>0)
1273 string trs_step = is_rsector_Y_axis ?
1280 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1285 if(module_step_trs > 0)
1286 nModulesTransaxial = mod_linear_nb;
1287 else if (module_step_axl > 0)
1288 nModulesAxial = mod_linear_nb;
1291 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with module linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
1299 kword =
"/gate/"+module_name+
"/cubicArray/setRepeatVector";
1301 if (values.size()>0)
1303 string trs_step = is_rsector_Y_axis ?
1310 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1315 if(module_step_trs > 0)
1316 nModulesTransaxial = mod_linear_nb;
1317 else if (module_step_axl > 0)
1318 nModulesAxial = mod_linear_nb;
1321 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with module linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
1333 kword = is_rsector_Y_axis ?
1334 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberX":
1335 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberY";
1338 if (values.size()>0)
1342 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1347 kword =
"/gate/"+submodule_name+
"/cubicArray/setRepeatNumberZ";
1349 if (values.size()>0)
1353 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1359 kword =
"/gate/"+submodule_name+
"/linear/setRepeatNumber";
1361 if (values.size()>0)
1366 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1372 kword =
"/gate/"+submodule_name+
"/cubicArray/setRepeatNumber ";
1374 if (values.size()>0)
1379 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1385 double submodule_step_trs=0., submodule_step_axl=0.;
1387 kword =
"/gate/"+submodule_name+
"/linear/setRepeatVector";
1389 if (values.size()>0)
1391 string trs_step = is_rsector_Y_axis ?
1398 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1403 if(submodule_step_trs > 0)
1404 nSubmodulesTransaxial = subm_linear_nb;
1405 else if (submodule_step_axl > 0)
1406 nSubmodulesAxial = subm_linear_nb;
1409 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with submodule linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
1415 if(subm_linear_nb>0)
1417 kword =
"/gate/"+submodule_name+
"/cubicArray/setRepeatVector";
1419 if (values.size()>0)
1421 string trs_step = is_rsector_Y_axis ?
1428 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1433 if(submodule_step_trs > 0)
1434 nSubmodulesTransaxial = subm_linear_nb;
1435 else if (submodule_step_axl > 0)
1436 nSubmodulesAxial = subm_linear_nb;
1439 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with submodule linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
1448 kword = is_rsector_Y_axis ?
1449 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
1450 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
1453 if (values.size()>0)
1457 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1462 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
1464 if (values.size()>0)
1468 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1475 kword =
"/gate/"+crystal_name+
"/linear/setRepeatNumber";
1477 if (values.size()>0)
1482 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1488 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumber ";
1490 if (values.size()>0)
1495 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1502 double crystal_step_trs=0., crystal_step_axl=0.;
1504 kword =
"/gate/"+crystal_name+
"/linear/setRepeatVector";
1506 if (values.size()>0)
1508 string trs_step = is_rsector_Y_axis ?
1515 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1520 if(crystal_step_trs > 0)
1521 nCrystalsTransaxial = cry_linear_nb;
1522 else if (crystal_step_axl > 0)
1523 nCrystalsAxial = cry_linear_nb;
1526 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with crystal linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
1534 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatVector";
1536 if (values.size()>0)
1538 string trs_step = is_rsector_Y_axis ?
1545 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1550 if(crystal_step_trs > 0)
1551 nCrystalsTransaxial = cry_linear_nb;
1552 else if (crystal_step_axl > 0)
1553 nCrystalsAxial = cry_linear_nb;
1556 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with crystal linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
1565 for(
int l=0 ; l<nLayers ; l++)
1567 kword = is_rsector_Y_axis ?
1568 "/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberX":
1569 "/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberY";
1572 if (values.size()>0)
1577 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1580 nLayersRptTransaxial.push_back(val);
1583 kword =
"/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberZ";
1585 if (values.size()>0)
1590 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1593 nLayersRptAxial.push_back(val);
1597 kword =
"/gate/"+layers_name[l]+
"/linear/setRepeatNumber";
1599 if (values.size()>0)
1604 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1607 lay_linear_nb.push_back(val);
1611 kword =
"/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumber ";
1613 if (values.size()>0)
1618 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1621 lay_linear_nb.push_back(val);
1627 kword =
"/gate/"+layers_name[l]+
"/linear/setRepeatVector";
1629 if (values.size()>0)
1631 string trs_step = is_rsector_Y_axis ?
1635 double step_trs=0., step_axl=0.;
1639 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1644 nLayersRptTransaxial.push_back(lay_linear_nb[l]);
1645 else if (step_axl > 0)
1646 nLayersRptAxial.push_back(lay_linear_nb[l]);
1649 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with layer linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
1656 if((
int)lay_linear_nb.size()>l && lay_linear_nb[ l ]>0)
1658 kword=
"/gate/"+layers_name[l]+
"/cubicArray/setRepeatVector";
1660 if (values.size()>0)
1662 string trs_step = is_rsector_Y_axis ?
1666 double step_trs, step_axl;
1670 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1675 nLayersRptTransaxial.push_back(lay_linear_nb[l]);
1676 else if (step_axl > 0)
1677 nLayersRptAxial.push_back(lay_linear_nb[l]);
1680 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with layer linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
1689 kword =
"/gate/application/setTimeStart";
1691 if (values.size()>0)
1695 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1700 if (values.size()>1)
1702 if(values[1] ==
"s") time_start *= 1000;
1705 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1707 start_time_ms = time_start;
1710 kword =
"/gate/application/setTimeStop";
1712 if (values.size()>0)
1716 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1721 if (values.size()>1)
1723 if(values[1] ==
"s") time_stop *= 1000;
1726 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1729 kword =
"/gate/application/addSlice";
1731 if (values.size()>0)
1733 double time_slice_tmp=0;
1737 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1742 if (values.size()>1)
1744 if(values[1] ==
"s") time_slice_tmp *= 1000;
1747 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1749 time_slices += time_slice_tmp;
1752 kword =
"/gate/digitizer/Coincidences/setWindow";
1754 if (values.size()>0)
1758 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1763 if (values.size()>1)
1765 if(values[1] ==
"ns") pet_coinc_window *= 1000.;
1766 else if (values[1] ==
"us") pet_coinc_window *= 1000000.;
1767 else if (values[1] ==
"ps") ;
1770 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> ERROR : can't read unit of '"<< kword <<
". Must be ns, ps or us !!!");
1776 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in ns");
1783 duration_ms = (time_slices>0) ?
1784 (uint32_t)(time_slices-time_start) :
1787 duration_ms = (time_start>=0 && time_stop>=0) ?
1788 (uint32_t)(time_stop-time_start) :
1797 nCrystalsTot = nRsectorsAngPos * nRsectorsAxial
1798 * nModulesTransaxial * nModulesAxial
1799 * nSubmodulesTransaxial * nSubmodulesAxial
1800 * nCrystalsTransaxial * nCrystalsAxial;
1803 for(
int l=0 ; l<nLayers ; l++)
1805 uint32_t nb_crystals_layer = nRsectorsAngPos * nRsectorsAxial
1806 * nModulesTransaxial * nModulesAxial
1807 * nSubmodulesTransaxial * nSubmodulesAxial
1808 * nCrystalsTransaxial * nCrystalsAxial;
1811 if(nLayersRptTransaxial.size()>0 || nLayersRptAxial.size()>0 )
1812 nb_crystals_layer *= nLayersRptTransaxial[l] * nLayersRptAxial[l];
1814 nb_crystal_per_layer[l] = nb_crystals_layer;
1816 nCrystalsTot += nb_crystals_layer;
1823 Cout(
"-----------------------------------------------------------" << endl);
1824 Cout(
"ReadMacCylindrical()-> Information recovered from mac file:" << endl);
1825 Cout(
"-----------------------------------------------------------" << endl);
1826 Cout(
"Number of rsectors angular position: " << nRsectorsAngPos << endl);
1827 Cout(
"Number of axial rsectors: " << nRsectorsAxial << endl);
1828 Cout(
"Number of axial modules: " << nModulesAxial << endl);
1829 Cout(
"Number of transaxial modules: " << nModulesTransaxial << endl);
1830 Cout(
"Number of axial submodules: " << nSubmodulesAxial << endl);
1831 Cout(
"Number of transaxial submodules: " << nSubmodulesTransaxial << endl);
1832 Cout(
"Number of axial crystals: " << nCrystalsAxial << endl);
1833 Cout(
"Number of transaxial crystals: " << nCrystalsTransaxial << endl);
1836 Cout(
"Number of layers: " << (uint16_t)nLayers << endl);
1837 for(
int l=0 ; l<nLayers ; l++)
1838 Cout(
"Layer "<< l <<
" : Number of crystals: " << nb_crystal_per_layer[l] << endl);
1840 Cout(
"Total number of crystals (including layers): " << nCrystalsTot << endl);
1841 Cout(
"Acquisition start time (ms): " << start_time_ms << endl);
1842 Cout(
"Acquisition duration (ms): " << duration_ms << endl);
1843 Cout(
"-----------------------------------------------------------" << endl << endl);
1870 uint32_t &nCrystalsTot,
1871 uint32_t &nCrystalsAxial,
1872 uint32_t &nCrystalsTransaxial,
1873 uint32_t &nBlocksLine,
1874 uint32_t &nBlocksPerRing,
1875 uint32_t &start_time_ms,
1876 uint32_t &duration_ms,
1877 FLTNB &pet_coinc_window,
1881 vector<string> path_mac_files;
1882 path_mac_files.push_back(a_pathMac);
1885 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
1889 string block_name =
"block";
1890 string crystal_name =
"crystal";
1891 bool is_block_Y_axis =
false;
1896 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover aliases for the elements of the ecat !" << endl);
1902 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
1904 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
1907 double time_start=-1.,
1911 while(getline(mac_file, line))
1913 vector <string> values;
1916 kword =
"/gate/"+block_name+
"/placement/setTranslation";
1918 if (values.size()>0)
1920 FLTNB block_pos_X=0.,
1926 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
1931 if(block_pos_Y!=0) is_block_Y_axis =
true;
1934 kword =
"/gate/"+block_name+
"/ring/setRepeatNumber";
1936 if (values.size()>0)
1940 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1945 kword =
"/gate/"+block_name+
"/linear/setRepeatNumber";
1947 if (values.size()>0)
1951 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1956 kword = is_block_Y_axis ?
1957 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
1958 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
1961 if (values.size()>0)
1965 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1970 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
1972 if (values.size()>0)
1976 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1982 kword =
"/gate/application/setTimeStart";
1984 if (values.size()>0)
1988 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1993 if (values.size()>1)
1995 if(values[1] ==
"s") time_start *= 1000;
1998 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2000 start_time_ms = time_start;
2003 kword =
"/gate/application/setTimeStop";
2005 if (values.size()>0)
2009 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2014 if (values.size()>1)
2016 if(values[1] ==
"s") time_stop *= 1000;
2019 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2022 kword =
"/gate/application/addSlice";
2024 if (values.size()>0)
2026 double time_slice_tmp=0;
2030 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2035 if (values.size()>1)
2037 if(values[1] ==
"s") time_slice_tmp *= 1000;
2040 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2042 time_slices = time_slice_tmp;
2045 kword =
"/gate/digitizer/Coincidences/setWindow";
2047 if (values.size()>0)
2051 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2056 if (values.size()>1)
2058 if(values[1] ==
"ns") pet_coinc_window *= 1000.;
2059 else if (values[1] ==
"us") pet_coinc_window *= 1000000.;
2060 else if (values[1] ==
"ps") ;
2063 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> ERROR : can't read unit of '"<< kword <<
". Must be ns, ps or us !!!");
2069 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in ns");
2075 duration_ms = (time_slices>0) ?
2076 (uint32_t)(time_slices-time_start) :
2079 duration_ms = (time_start>=0 && time_stop>=0) ?
2080 (uint32_t)(time_stop-time_start) :
2087 nCrystalsTot = nCrystalsTransaxial * nCrystalsAxial
2088 * nBlocksLine * nBlocksPerRing;
2094 Cout(
"-----------------------------------------------------" << endl);
2095 Cout(
"ReadMacECAT()-> Information recovered from mac file:" << endl);
2096 Cout(
"-----------------------------------------------------" << endl);
2097 Cout(
"Number of blocks per ring: " << nBlocksPerRing << endl);
2098 Cout(
"Number of axial blocks: " << nBlocksLine << endl);
2099 Cout(
"Number of axial crystals: " << nCrystalsAxial << endl);
2100 Cout(
"Number of transaxial crystals: " << nCrystalsTransaxial << endl);
2101 Cout(
"Total number of crystals: " << nCrystalsTot << endl);
2102 Cout(
"Acquisition start time (ms): " << start_time_ms << endl);
2103 Cout(
"Acquisition duration (ms): " << duration_ms << endl);
2104 Cout(
"-----------------------------------------------------" << endl << endl);
2136 float_t &a_distToDetector,
2138 uint32_t &a_nPixAxl,
2139 uint32_t &a_nPixTrs,
2140 float_t &a_crystalSizeAxl,
2141 float_t &a_crystalSizeTrs,
2142 uint32_t &a_nProjectionsTot,
2143 uint32_t &a_nProjectionsByHead,
2144 float_t &a_head1stAngle,
2145 float_t &a_headAngPitch,
2146 float_t &a_headAngStepDeg,
2147 int &a_headRotDirection,
2148 uint32_t &a_start_time_ms,
2149 uint32_t &a_duration_ms,
2153 vector<string> path_mac_files;
2154 path_mac_files.push_back(a_pathMac);
2158 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
2162 string head_name =
"SPECThead";
2163 string crystal_name =
"crystal";
2164 string pixel_name =
"pixel";
2165 string head_orbit_name =
"";
2166 bool is_head_Y_axis =
false;
2171 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover aliases for the elements of the ecat !" << endl);
2176 double time_start=-1.,
2181 head_rot_speed =-1.;
2184 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
2186 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
2190 while(getline(mac_file, line))
2192 vector <string> values;
2194 kword =
"/gate/"+head_name+
"/placement/setTranslation";
2196 if (values.size()>0)
2198 FLTNB head_pos_X=0.,
2204 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2209 if(head_pos_Y!=0) is_head_Y_axis =
true;
2211 a_distToDetector = is_head_Y_axis ? abs(head_pos_Y) : abs(head_pos_X) ;
2216 kword =
"/gate/"+head_name+
"/ring/setRepeatNumber";
2218 if (values.size()>0)
2222 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2227 kword =
"/gate/"+head_name+
"/ring/setFirstAngle";
2229 if (values.size()>0)
2233 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2238 kword =
"/gate/"+head_name+
"/ring/setAngularPitch";
2240 if (values.size()>0)
2244 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2249 kword =
"/gate/"+head_name+
"/moves/insert";
2251 if (values.size()>0)
2255 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2260 kword =
"/gate/"+head_name+
"/"+head_orbit_name+
"/setSpeed";
2262 if (values.size()>0)
2266 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2271 kword =
"/gate/"+head_name+
"/"+head_orbit_name+
"/setPoint2";
2273 if (values.size()>0)
2278 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2286 kword = is_head_Y_axis ?
2287 "/gate/"+crystal_name+
"/geometry/setXLength":
2288 "/gate/"+crystal_name+
"/geometry/setYLength";
2291 if (values.size()>0)
2295 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2301 kword =
"/gate/"+crystal_name+
"/geometry/setZLength";
2303 if (values.size()>0)
2307 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2314 kword = is_head_Y_axis ?
2315 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberX":
2316 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberY";
2320 if (values.size()>0)
2324 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2329 kword =
"/gate/"+pixel_name+
"/cubicArray/setRepeatNumberZ";
2331 if (values.size()>0)
2335 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2340 kword =
"/gate/application/setTimeStart";
2342 if (values.size()>0)
2346 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2351 if (values.size()>1)
2353 if(values[1] ==
"s") time_start *= 1000;
2356 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2358 a_start_time_ms = time_start;
2361 kword =
"/gate/application/setTimeSlice";
2363 if (values.size()>0)
2367 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2372 if (values.size()>1)
2374 if(values[1] ==
"s") time_slice *= 1000;
2377 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2379 time_slice_ms = time_slice;
2382 kword =
"/gate/application/setTimeStop";
2384 if (values.size()>0)
2388 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2393 if (values.size()>1)
2395 if(values[1] ==
"s") time_stop *= 1000;
2398 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2401 kword =
"/gate/application/addSlice";
2403 if (values.size()>0)
2405 double time_slice_tmp=0;
2409 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2414 if (values.size()>1)
2416 if(values[1] ==
"s") time_slice_tmp *= 1000;
2419 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2421 time_slices = time_slice_tmp;
2428 a_duration_ms = (time_slices>0) ?
2429 (uint32_t)(time_slices-time_start) :
2433 a_duration_ms = (time_start>=0 && time_stop>=0) ?
2434 (uint32_t)(time_stop-time_start) :
2439 a_nProjectionsByHead = a_duration_ms / time_slice_ms;
2440 a_nProjectionsTot = a_nHeads*a_nProjectionsByHead;
2443 a_headAngPitch = (a_headAngPitch<0) ?
2447 a_headAngStepDeg = head_rot_speed*time_slice_ms/1000.;
2449 if(head_rot_speed<0)
2451 Cerr(
"***** GetGATESystemType() -> Error couldn't find line '/gate/"+head_name+
"/"+head_orbit_name+
"/setSpeed' !" << endl);
2452 Cerr(
" This information is mandatory to compute the projection angle step." << endl);
2458 Cerr(
"***** GetGATESystemType() -> Error couldn't find line '/gate/application/setTimeSlice' !" << endl);
2459 Cerr(
" This information is mandatory to compute the projection angle step." << endl);
2463 if(a_duration_ms == 0)
2467 Cerr(
"***** GetGATESystemType() -> Error couldn't compute acquisition find line '/gate/application/setTimeStop' !" << endl);
2468 Cerr(
" This information is mandatory to compute the acquisition duration." << endl);
2473 Cerr(
"***** GetGATESystemType() -> Error couldn't compute acquisition find line '/gate/application/setTimeStart' !" << endl);
2474 Cerr(
" This information is mandatory to compute the acquisition duration." << endl);
2485 Cout(
"-----------------------------------------------------" << endl);
2486 Cout(
"ReadMacSPECT()-> Information recovered from mac file:" << endl);
2487 Cout(
"-----------------------------------------------------" << endl);
2488 Cout(
"Distance to detector: " << a_distToDetector << endl);
2489 Cout(
"Number of heads: " << a_nHeads << endl);
2490 Cout(
"Number of axial pixels: " << a_nPixAxl << endl);
2491 Cout(
"Number of transaxial pixels: " << a_nPixTrs << endl);
2492 Cout(
"Crystal axial size: " << a_crystalSizeAxl << endl);
2493 Cout(
"Crystal transaxial size: " << a_crystalSizeTrs << endl);
2494 Cout(
"Number of projections per head: " << a_nProjectionsByHead << endl);
2495 Cout(
"Total number of projections: " << a_nProjectionsTot << endl);
2496 Cout(
"Head(s) first transaxial angle: " << a_head1stAngle << endl);
2497 Cout(
"Head(s) angular pitch: " << a_headAngPitch << endl);
2498 Cout(
"Angular step between projections (deg): " << a_headAngStepDeg << endl);
2499 Cout(
"Rotation direction (0=CW, 1=CCW): " << a_headRotDirection << endl);
2500 Cout(
"Acquisition start time (ms): " << a_start_time_ms << endl);
2501 Cout(
"Acquisition duration (ms): " << a_duration_ms << endl);
2502 Cout(
"-----------------------------------------------------" << endl << endl);
2535 float_t &a_distToDetector,
2537 uint32_t &a_nPixAxl,
2538 uint32_t &a_nPixTrs,
2539 float_t &a_crystalSizeAxl,
2540 float_t &a_crystalSizeTrs,
2541 uint32_t &a_nProjectionsTot,
2542 uint32_t &a_nProjectionsByHead,
2543 float_t &a_head1stAngle,
2544 float_t &a_headAngPitchDeg,
2545 float_t &a_headAngStepDeg,
2546 int &a_headRotDirection,
2547 uint32_t &a_start_time_ms,
2548 uint32_t &a_duration_ms,
2555 key =
"matrix size [1]";
2558 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2559 Cerr(
" Either key not found or conversion error" << endl);
2563 key =
"matrix size [2]";
2566 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2567 Cerr(
" Either key not found or conversion error" << endl);
2571 FLTNB size_pix_trs = 1.,
2574 key =
"scaling factor (mm/pixel) [1]";
2577 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2578 Cerr(
" Either key not found or conversion error" << endl);
2582 key =
"scaling factor (mm/pixel) [2]";
2585 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2586 Cerr(
" Either key not found or conversion error" << endl);
2590 key =
"total number of images";
2593 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2594 Cerr(
" Either key not found or conversion error" << endl);
2598 key =
"number of projections";
2601 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2602 Cerr(
" Either key not found or conversion error" << endl);
2606 key =
"number of detector heads";
2609 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2610 Cerr(
" Either key not found or conversion error" << endl);
2614 key =
"study duration (sec)";
2617 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2618 Cerr(
" Either key not found or conversion error" << endl);
2622 a_duration_ms *= 1000;
2625 FLTNB size_crystal_X =0.,
2628 key =
"crystal x dimension (cm)";
2631 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2632 Cerr(
" Either key not found or conversion error" << endl);
2636 key =
"crystal y dimension (cm)";
2639 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2640 Cerr(
" Either key not found or conversion error" << endl);
2644 key =
"crystal z dimension (cm)";
2647 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2648 Cerr(
" Either key not found or conversion error" << endl);
2654 if(size_crystal_X>0 && size_crystal_Y>0)
2655 a_crystalSizeTrs = (size_crystal_X>size_crystal_Y) ? size_crystal_X*10. : size_crystal_Y*10.;
2656 a_crystalSizeAxl = (a_crystalSizeAxl>0) ? a_crystalSizeAxl*10. : a_crystalSizeAxl ;
2659 FLTNB head_pos_X =-1.,
2663 key =
"head x translation (cm)";
2666 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2667 Cerr(
" Either key not found or conversion error" << endl);
2671 key =
"head y translation (cm)";
2674 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2675 Cerr(
" Either key not found or conversion error" << endl);
2679 key =
"head z translation (cm)";
2682 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2683 Cerr(
" Either key not found or conversion error" << endl);
2688 if(head_pos_X > head_pos_Y)
2689 a_distToDetector = head_pos_X > head_pos_Z ? head_pos_X*10 : head_pos_Z*10;
2691 a_distToDetector = head_pos_Y > head_pos_Z ? head_pos_Y*10 : head_pos_Z*10;
2694 key =
"direction of rotation";
2698 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2699 Cerr(
" Either key not found or conversion error" << endl);
2707 key =
"start angle";
2710 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2711 Cerr(
" Either key not found or conversion error" << endl);
2715 key =
"extent of rotation";
2716 uint32_t extent_rotation =360;
2719 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2720 Cerr(
" Either key not found or conversion error" << endl);
2724 a_headAngStepDeg = (
FLTNB)extent_rotation / a_nProjectionsByHead;
2726 float_t first_angle = 0;
2727 float_t second_angle = extent_rotation;
2729 key =
"start angle";
2732 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2733 Cerr(
" Either key not found or conversion error" << endl);
2737 key =
"start angle";
2740 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2741 Cerr(
" Either key not found or conversion error" << endl);
2745 a_headAngPitchDeg = second_angle - first_angle;
2770 string scanner_name =
GetFileFromPath(a_pathGeom.substr(0,a_pathGeom.find(
".geom")));
2771 double scanner_radius = 0.;
2772 uint32_t number_of_elements = 0;
2773 string description =
"PET system extracted from GATE macro: " + a_pathMac;
2776 string rsector_name =
"";
2777 uint32_t number_of_rsectors_ang = 1;
2778 uint32_t number_of_rsectors_axl = 1;
2779 double rsector_step_axl = 0.;
2780 double rsector_gap_axl = 0.;
2781 double rsector_first_angle = 0.;
2782 double rsector_angular_span = 360.;
2783 double rsector_pos_X = 0.;
2784 double rsector_pos_Y = 0.;
2785 uint32_t rsector_nb_zshifts = 0;
2786 vector <double> vec_rsector_Z_Shift;
2787 bool is_rsector_Y_axis =
false;
2788 double rsector_size_trs;
2789 double rsector_size_axl;
2792 string module_name =
"";
2793 uint32_t number_of_modules_trs = 1;
2794 uint32_t number_of_modules_axl = 1;
2795 double module_step_trs = 0.;
2796 double module_step_axl = 0.;
2797 double module_gap_trs = 0.;
2798 double module_gap_axl = 0.;
2799 double module_size_trs;
2800 double module_size_axl;
2803 string submodule_name =
"";
2804 uint32_t number_of_submodules_trs = 1;
2805 uint32_t number_of_submodules_axl = 1;
2806 double submodule_step_trs = 0.;
2807 double submodule_step_axl = 0.;
2808 double submodule_gap_trs = 0.;
2809 double submodule_gap_axl = 0.;
2810 double submodule_size_trs;
2811 double submodule_size_axl;
2814 string crystal_name =
"";
2815 uint32_t number_of_crystals_trs = 1;
2816 uint32_t number_of_crystals_axl = 1;
2817 double crystal_step_trs = 0.;
2818 double crystal_step_axl = 0.;
2819 double crystal_gap_trs = 0.;
2820 double crystal_gap_axl = 0.;
2821 double crystal_size_depth = 0.;
2822 double crystal_size_trs = 0.;
2823 double crystal_size_axl = 0.;
2827 uint16_t number_of_layers = 0;
2828 string n_layers =
"1";
2829 vector <uint32_t> number_of_lyr_elts_trs;
2830 vector <uint32_t> number_of_lyr_elts_axl;
2832 vector <string> layers_names;
2833 vector <vector <double> > layers_positions;
2834 vector <double> layers_size_depth;
2835 vector <double> layers_size_trs;
2836 vector <double> layers_size_axl;
2838 vector <double> layers_step_trs;
2839 vector <double> layers_step_axl;
2842 uint32_t voxels_number_trs;
2843 uint32_t voxels_number_axl;
2846 double mean_depth_of_interaction = -1.;
2847 double min_angle_diff = 0.;
2850 int mod_linear_nb = 0;
2851 int subm_linear_nb = 0;
2852 int cry_linear_nb = 0;
2853 vector <int> layer_linear_nb;
2857 vector <string> vec_scanner_radius;
2860 vector <string> vec_number_of_rsectors_ang;
2861 vector <string> vec_number_of_rsectors_axl;
2862 vector <string> vec_rsector_gap_trs;
2863 vector <string> vec_rsector_gap_axl;
2864 vector <string> vec_rsector_first_angle;
2868 vector <string> vec_number_of_modules_trs;
2869 vector <string> vec_number_of_modules_axl;
2870 vector <string> vec_module_gap_trs;
2871 vector <string> vec_module_gap_axl;
2874 vector <string> vec_number_of_submodules_trs;
2875 vector <string> vec_number_of_submodules_axl;
2876 vector <string> vec_submodule_gap_trs;
2877 vector <string> vec_submodule_gap_axl;
2880 vector <string> vec_number_of_crystals_trs;
2881 vector <string> vec_number_of_crystals_axl;
2882 vector <string> vec_crystal_gap_trs;
2883 vector <string> vec_crystal_gap_axl;
2886 vector <string> vec_mean_depth_of_interaction;
2887 vector <string> vec_min_angle_diff;
2889 vector<string> path_mac_files;
2890 path_mac_files.push_back(a_pathMac);
2895 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
2900 if(
GetGATEAliasesCylindrical(path_mac_files, rsector_name, module_name, submodule_name, crystal_name, layers_names, 2) )
2902 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover aliases for the elements of the cylindricalPET !" << endl);
2907 n_layers = layers_names.size();
2911 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
2913 ifstream systemMac(path_mac_files[f].c_str(), ios::in);
2917 while(getline(systemMac, line))
2919 vector <string> values;
2926 entry =
"/gate/"+rsector_name+
"/placement/setTranslation";
2930 if (values.size()>0)
2935 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2941 if(rsector_pos_X!=0 && rsector_pos_Y !=0)
2943 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2944 Cerr(
" Rsector cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
2949 if(rsector_pos_Y!=0) is_rsector_Y_axis =
true;
2952 scanner_radius += is_rsector_Y_axis ? abs(rsector_pos_Y) : abs(rsector_pos_X) ;
2980 entry = is_rsector_Y_axis ?
2981 "/gate/"+rsector_name+
"/geometry/setXLength":
2982 "/gate/"+rsector_name+
"/geometry/setYLength";
2985 if (values.size()>0)
2989 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2998 entry =
"/gate/"+rsector_name+
"/ring/setModuloNumber";
3000 if (values.size()>0)
3004 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3009 entry =
"/gate/"+rsector_name+
"/ring/setRepeatNumber";
3011 if (values.size()>0)
3015 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3030 entry =
"/gate/"+rsector_name+
"/linear/setRepeatNumber";
3032 if (values.size()>0)
3036 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3044 entry =
"/gate/"+rsector_name+
"/linear/setRepeatVector";
3046 if (values.size()>0)
3050 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3060 entry = is_rsector_Y_axis ?
3061 "/gate/"+rsector_name+
"/cubicArray/setRepeatNumberX":
3062 "/gate/"+rsector_name+
"/cubicArray/setRepeatNumberY";
3065 if (values.size()>0)
3067 uint32_t number_of_rsectors_trs;
3071 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3078 if(number_of_rsectors_trs>1)
3080 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Error while trying to parse line: " << line<< endl);
3081 Cerr(
" The GATE system contains more than one 'transaxial' rsector " << endl);
3082 Cerr(
" The current implementation does not support such cylindricalPET model" << endl);
3083 Cerr(
" Manual implementation of the system is required (ex: model the transaxial rsectors as modules)" << endl);
3089 entry =
"/gate/"+rsector_name+
"/cubicArray/setRepeatNumberZ";
3092 if (values.size()>0)
3096 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3102 entry =
"/gate/"+rsector_name+
"/cubicArray/setRepeatVector";
3104 if (values.size()>0)
3108 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3116 entry =
"/gate/"+rsector_name+
"/geometry/setZLength";
3118 if (values.size()>0)
3122 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3129 entry =
"/gate/"+rsector_name+
"/ring/setFirstAngle";
3131 if (values.size()>0)
3135 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3140 entry =
"/gate/"+rsector_name+
"/ring/setAngularSpan";
3142 if (values.size()>0)
3146 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3152 for (
int i=1; i <8; i++)
3154 entry =
"/gate/"+rsector_name+
"/ring/setZShift"+
toString(i);
3156 if (values.size()>0)
3161 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3165 vec_rsector_Z_Shift.push_back(zshift);
3174 entry =
"/gate/"+module_name+
"/placement/setTranslation";
3177 FLTNB module_pos_X =0.,
3181 if (values.size()>0)
3186 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3192 if(module_pos_X!=0 && module_pos_Y !=0)
3194 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3195 Cerr(
" Module cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
3200 scanner_radius += is_rsector_Y_axis ? module_pos_Y : module_pos_X ;
3205 entry = is_rsector_Y_axis ?
3206 "/gate/"+module_name+
"/cubicArray/setRepeatNumberX":
3207 "/gate/"+module_name+
"/cubicArray/setRepeatNumberY";
3210 if (values.size()>0)
3214 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3222 entry =
"/gate/"+module_name+
"/cubicArray/setRepeatNumberZ";
3225 if (values.size()>0)
3229 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3235 entry = is_rsector_Y_axis ?
3236 "/gate/"+module_name+
"/geometry/setXLength":
3237 "/gate/"+module_name+
"/geometry/setYLength";
3240 if (values.size()>0)
3244 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3250 entry =
"/gate/"+module_name+
"/geometry/setZLength";
3252 if (values.size()>0)
3256 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3261 entry =
"/gate/"+module_name+
"/cubicArray/setRepeatVector";
3263 if (values.size()>0)
3265 string trs_step = is_rsector_Y_axis ?
3272 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3281 entry =
"/gate/"+module_name+
"/linear/setRepeatNumber";
3284 if (values.size()>0)
3289 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3295 entry =
"/gate/"+module_name+
"/cubicArray/setRepeatNumber ";
3298 if (values.size()>0)
3303 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3310 entry =
"/gate/"+module_name+
"/linear/setRepeatVector";
3312 if (values.size()>0)
3314 string trs_step = is_rsector_Y_axis ?
3321 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3326 if(module_step_trs > 0)
3327 number_of_modules_trs = mod_linear_nb;
3328 else if (module_step_axl > 0)
3329 number_of_modules_axl = mod_linear_nb;
3332 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with module linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
3341 entry =
"/gate/"+module_name+
"/cubicArray/setRepeatVector";
3343 if (values.size()>0)
3345 string trs_step = is_rsector_Y_axis ?
3352 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3357 if(module_step_trs > 0)
3358 number_of_modules_trs = mod_linear_nb;
3359 else if (module_step_axl > 0)
3360 number_of_modules_axl = mod_linear_nb;
3363 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with module linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
3373 entry =
"/gate/"+submodule_name+
"/placement/setTranslation";
3376 FLTNB submodule_pos_X =0.,
3377 submodule_pos_Y =0.;
3380 if (values.size()>0)
3385 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3391 if(submodule_pos_X!=0 && submodule_pos_Y !=0)
3393 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3394 Cerr(
" Submodule cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
3399 scanner_radius += is_rsector_Y_axis ? submodule_pos_Y : submodule_pos_X ;
3404 entry = is_rsector_Y_axis ?
3405 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberX":
3406 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberY";
3410 if (values.size()>0)
3414 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3419 entry =
"/gate/"+submodule_name+
"/cubicArray/setRepeatNumberZ";
3421 if (values.size()>0)
3425 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3433 entry = is_rsector_Y_axis ?
3434 "/gate/"+submodule_name+
"/geometry/setXLength":
3435 "/gate/"+submodule_name+
"/geometry/setYLength";
3438 if (values.size()>0)
3442 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3447 entry =
"/gate/"+submodule_name+
"/geometry/setZLength";
3449 if (values.size()>0)
3453 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3458 entry =
"/gate/"+submodule_name+
"/cubicArray/setRepeatVector";
3460 if (values.size()>0)
3462 string trs_step = is_rsector_Y_axis ?
3469 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3477 entry =
"/gate/"+submodule_name+
"/linear/setRepeatNumber";
3480 if (values.size()>0)
3485 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3491 entry =
"/gate/"+submodule_name+
"/cubicArray/setRepeatNumber ";
3494 if (values.size()>0)
3499 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3505 entry =
"/gate/"+submodule_name+
"/linear/setRepeatVector";
3507 if (values.size()>0)
3509 string trs_step = is_rsector_Y_axis ?
3516 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3521 if(submodule_step_trs > 0)
3522 number_of_submodules_trs = subm_linear_nb;
3523 else if (submodule_step_axl > 0)
3524 number_of_submodules_axl = subm_linear_nb;
3527 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with submodule linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
3534 if(subm_linear_nb>0)
3536 entry =
"/gate/"+submodule_name+
"/cubicArray/setRepeatVector";
3538 if (values.size()>0)
3540 string trs_step = is_rsector_Y_axis ?
3547 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3553 if(submodule_step_trs > 0)
3554 number_of_submodules_trs = subm_linear_nb;
3555 else if (submodule_step_axl > 0)
3556 number_of_submodules_axl = subm_linear_nb;
3559 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with submodule linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
3573 entry =
"/gate/"+crystal_name+
"/placement/setTranslation";
3576 FLTNB crystal_pos_X =0.,
3580 if (values.size()>0)
3585 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3591 if(crystal_pos_X!=0 && crystal_pos_Y !=0)
3593 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3594 Cerr(
" Crystal cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
3599 scanner_radius += is_rsector_Y_axis ? crystal_pos_Y : crystal_pos_X ;
3604 entry = is_rsector_Y_axis ?
3605 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
3606 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
3609 if (values.size()>0)
3613 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3619 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
3621 if (values.size()>0)
3625 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3631 entry =
"/gate/"+crystal_name+
"/geometry/setXLength";
3633 if (values.size()>0)
3638 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3642 if (is_rsector_Y_axis)
3643 crystal_size_trs = x_length;
3645 crystal_size_depth = x_length;
3648 entry =
"/gate/"+crystal_name+
"/geometry/setYLength";
3650 if (values.size()>0)
3655 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3659 if (is_rsector_Y_axis)
3660 crystal_size_depth = y_length;
3662 crystal_size_trs = y_length;
3666 entry =
"/gate/"+crystal_name+
"/geometry/setZLength";
3668 if (values.size()>0)
3672 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3677 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatVector";
3679 if (values.size()>0)
3681 string trs_step = is_rsector_Y_axis ?
3688 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3694 entry =
"/gate/"+crystal_name+
"/linear/setRepeatNumber";
3697 if (values.size()>0)
3702 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3708 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumber ";
3711 if (values.size()>0)
3716 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3722 entry =
"/gate/"+crystal_name+
"/linear/setRepeatVector";
3724 if (values.size()>0)
3726 string trs_step = is_rsector_Y_axis ?
3733 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3738 if(crystal_step_trs > 0)
3739 number_of_crystals_trs = cry_linear_nb;
3740 else if (crystal_step_axl > 0)
3741 number_of_crystals_axl = cry_linear_nb;
3744 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with crystal linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
3747 cout <<
"number_of_crystals_trs " << number_of_crystals_trs << endl;
3754 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatVector";
3756 if (values.size()>0)
3758 string trs_step = is_rsector_Y_axis ?
3765 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3770 if(crystal_step_trs > 0)
3771 number_of_crystals_trs = cry_linear_nb;
3772 else if (crystal_step_axl > 0)
3773 number_of_crystals_axl = cry_linear_nb;
3776 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with crystal linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
3781 cout <<
"number_of_crystals_trs " << number_of_crystals_trs << endl;
3787 entry =
"/gate/"+crystal_name+
"/daughters/name";
3789 if (values.size()>0)
3791 layers_names.push_back(values[0]);
3796 for (
int i=0; i < number_of_layers; i++)
3799 entry =
"/gate/"+layers_names[i]+
"/placement/setTranslation";
3802 if (values.size()>0)
3804 vector<double> layer_pos;
3805 for(
int d=0 ; d<3 ; d++)
3810 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3813 layer_pos.push_back(pos);
3816 if(is_rsector_Y_axis)
3818 double pos = layer_pos[1];
3819 layer_pos[1] = layer_pos[0];
3823 layers_positions.push_back(layer_pos);
3828 entry =
"/gate/"+layers_names[i]+
"/geometry/setXLength";
3831 if (values.size()>0)
3836 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3840 if (is_rsector_Y_axis)
3841 layers_size_trs.push_back(xlength);
3843 layers_size_depth.push_back(xlength);
3847 entry =
"/gate/"+layers_names[i]+
"/geometry/setYLength";
3849 if (values.size()>0)
3854 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3857 if (is_rsector_Y_axis)
3858 layers_size_depth.push_back(ylength);
3860 layers_size_trs.push_back(ylength);
3863 entry =
"/gate/"+layers_names[i]+
"/geometry/setZLength";
3865 if (values.size()>0)
3870 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3873 layers_size_axl.push_back(zlength);
3879 entry = is_rsector_Y_axis ?
3880 "/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberX":
3881 "/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberY";
3884 if (values.size()>0)
3889 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3892 number_of_lyr_elts_trs.push_back(step_trs);
3895 entry =
"/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberZ";
3897 if (values.size()>0)
3902 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3905 number_of_lyr_elts_axl.push_back(step_axl);
3908 entry =
"/gate/"+layers_names[i]+
"/cubicArray/setRepeatVector";
3910 if (values.size()>0)
3912 string trs_step = is_rsector_Y_axis ?
3916 double step_trs, step_axl;
3920 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3925 layers_step_trs.push_back(step_trs);
3926 layers_step_axl.push_back(step_axl);
3931 entry =
"/gate/"+layers_names[i]+
"/linear/setRepeatNumber";
3934 if (values.size()>0)
3939 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3942 layer_linear_nb.push_back(step_axl);
3946 entry =
"/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumber ";
3949 if (values.size()>0)
3954 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3957 layer_linear_nb.push_back(step_axl);
3961 entry =
"/gate/"+layers_names[i]+
"/linear/setRepeatVector";
3963 if (values.size()>0)
3965 string trs_step = is_rsector_Y_axis ?
3969 double step_trs=0., step_axl=0.;
3973 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3979 number_of_lyr_elts_trs.push_back(layer_linear_nb[ i ]);
3980 layers_step_trs.push_back(step_trs);
3982 else if (step_axl > 0)
3984 number_of_lyr_elts_axl.push_back(layer_linear_nb[ i ]);
3985 layers_step_axl.push_back(step_axl);
3989 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with layer linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
3997 if((
int)layer_linear_nb.size()>i && layer_linear_nb[ i ]>0)
3999 entry =
"/gate/"+layers_names[i]+
"/cubicArray/setRepeatVector";
4001 if (values.size()>0)
4003 string trs_step = is_rsector_Y_axis ?
4007 double step_trs, step_axl;
4011 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4018 number_of_lyr_elts_trs.push_back(layer_linear_nb[ i ]);
4019 layers_step_trs.push_back(step_trs);
4021 else if (step_axl > 0)
4023 number_of_lyr_elts_axl.push_back(layer_linear_nb[ i ]);
4024 layers_step_axl.push_back(step_axl);
4028 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> There seems to be a problem with layer linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
4037 entry =
"/gate/digitizer/Coincidences/minSectorDifference";
4039 if (values.size()>0)
4041 FLTNB min_sector_diff= 0.;
4045 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4049 min_angle_diff = 360./number_of_rsectors_ang*min_sector_diff;
4058 if(number_of_layers == 0)
4060 number_of_elements = number_of_rsectors_ang
4061 * number_of_rsectors_axl
4062 * number_of_modules_trs
4063 * number_of_modules_axl
4064 * number_of_submodules_trs
4065 * number_of_submodules_axl
4066 * number_of_crystals_trs
4067 * number_of_crystals_axl;
4070 for(
int l=0 ; l<number_of_layers ; l++)
4072 int32_t nb_crystals_layer = number_of_rsectors_ang
4073 * number_of_rsectors_axl
4074 * number_of_modules_trs
4075 * number_of_modules_axl
4076 * number_of_submodules_trs
4077 * number_of_submodules_axl
4078 * number_of_crystals_trs
4079 * number_of_crystals_axl;
4082 if(number_of_lyr_elts_trs.size()>0 || number_of_lyr_elts_axl.size()>0 )
4083 nb_crystals_layer *= number_of_lyr_elts_trs[l] * number_of_lyr_elts_axl[l];
4085 number_of_elements += nb_crystals_layer;
4092 if (crystal_step_axl - crystal_size_axl >= 0)
4093 crystal_gap_axl = crystal_step_axl - crystal_size_axl;
4095 if (crystal_step_trs - crystal_size_trs >= 0)
4096 crystal_gap_trs = crystal_step_trs - crystal_size_trs;
4099 submodule_size_axl = crystal_size_axl*number_of_crystals_axl + crystal_gap_axl*(number_of_crystals_axl-1);
4100 submodule_size_trs = crystal_size_trs*number_of_crystals_trs + crystal_gap_trs*(number_of_crystals_trs-1);
4103 if (submodule_step_axl - submodule_size_axl >= 0)
4104 submodule_gap_axl = submodule_step_axl - submodule_size_axl;
4106 if (submodule_step_trs - submodule_size_trs >= 0)
4107 submodule_gap_trs = submodule_step_trs - submodule_size_trs;
4110 module_size_axl = submodule_size_axl*number_of_submodules_axl + submodule_gap_axl*(number_of_submodules_axl-1);
4111 module_size_trs = submodule_size_trs*number_of_submodules_trs + submodule_gap_trs*(number_of_submodules_trs-1);
4114 if (module_step_axl - module_size_axl >= 0)
4115 module_gap_axl = module_step_axl - module_size_axl;
4117 if (module_step_trs - module_size_trs >= 0)
4118 module_gap_trs = module_step_trs - module_size_trs;
4121 rsector_size_axl = module_size_axl*number_of_modules_axl + module_gap_axl*(number_of_modules_axl-1);
4122 rsector_size_trs = module_size_trs*number_of_modules_trs + module_gap_trs*(number_of_modules_trs-1);
4126 if (rsector_step_axl - rsector_size_axl >= 0)
4127 rsector_gap_axl = rsector_step_axl - rsector_size_axl;
4131 fov_axl = rsector_size_axl * number_of_rsectors_axl
4132 + (number_of_rsectors_axl-1)*rsector_gap_axl;
4136 voxels_number_axl = ( number_of_crystals_axl
4137 * number_of_submodules_axl
4138 * number_of_modules_axl
4139 * number_of_rsectors_axl )
4143 fov_trs = (2*scanner_radius ) / 1.5;
4147 voxels_number_trs = ( number_of_crystals_trs
4148 * number_of_submodules_trs
4149 * number_of_modules_trs
4150 * number_of_rsectors_ang )
4156 rsector_first_angle -= round(atan2f(rsector_pos_X , rsector_pos_Y) * 180. / M_PI);
4159 if (number_of_layers > 0)
4161 for (uint16_t l=0; l < number_of_layers ; l++)
4164 double rad = scanner_radius;
4165 if (layers_positions.size()>l) rad += layers_positions[ l ][ 0 ];
4166 if (layers_size_depth.size()>l) rad -= layers_size_depth[ l ] / 2.;
4167 vec_scanner_radius.push_back(
toString( rad ) );
4170 vec_number_of_rsectors_ang.push_back(
toString(number_of_rsectors_ang) );
4171 vec_number_of_rsectors_axl.push_back(
toString(number_of_rsectors_axl) );
4172 vec_rsector_gap_axl.push_back(
toString(rsector_gap_axl) );
4173 vec_rsector_first_angle.push_back(
toString(rsector_first_angle) );
4176 vec_number_of_modules_trs.push_back(
toString(number_of_modules_trs) );
4177 vec_number_of_modules_axl.push_back(
toString(number_of_modules_axl) );
4178 vec_module_gap_trs.push_back(
toString(module_gap_trs) );
4179 vec_module_gap_axl.push_back(
toString(module_gap_axl) );
4182 vec_number_of_submodules_trs.push_back(
toString(number_of_submodules_trs) );
4183 vec_number_of_submodules_axl.push_back(
toString(number_of_submodules_axl) );
4184 vec_submodule_gap_trs.push_back(
toString(submodule_gap_trs) );
4185 vec_submodule_gap_axl.push_back(
toString(submodule_gap_axl) );
4188 uint32_t nb_tot_trs_cry = (number_of_lyr_elts_trs.size()>0) ?
4189 number_of_lyr_elts_trs[l]*number_of_crystals_trs :
4190 number_of_crystals_trs ;
4192 uint32_t nb_tot_axl_cry = (number_of_lyr_elts_axl.size()>0) ?
4193 number_of_lyr_elts_axl[l]*number_of_crystals_axl :
4194 number_of_crystals_axl ;
4196 vec_number_of_crystals_trs.push_back(
toString(nb_tot_trs_cry) );
4197 vec_number_of_crystals_axl.push_back(
toString(nb_tot_axl_cry) );
4202 if(layers_step_trs.size()>0 ||
4203 layers_step_axl.size()>0)
4205 if (layers_step_trs[l] - layers_size_trs[l] >= 0)
4206 crystal_gap_trs = layers_step_trs[l] - layers_size_trs[l];
4208 if (layers_step_axl[l] - layers_size_axl[l] >= 0)
4209 crystal_gap_axl = layers_step_axl[l] - layers_size_axl[l];
4212 vec_crystal_gap_trs.push_back(
toString(crystal_gap_trs) );
4213 vec_crystal_gap_axl.push_back(
toString(crystal_gap_axl) );
4216 vec_mean_depth_of_interaction.push_back(
toString(mean_depth_of_interaction) );
4217 vec_min_angle_diff.push_back(
toString(min_angle_diff) );
4223 layers_size_depth.push_back( crystal_size_depth );
4224 layers_size_trs.push_back( crystal_size_trs );
4225 layers_size_axl.push_back( crystal_size_axl );
4229 vec_scanner_radius.push_back(
toString(scanner_radius - crystal_size_depth/2) );
4232 vec_number_of_rsectors_ang.push_back(
toString(number_of_rsectors_ang) );
4233 vec_number_of_rsectors_axl.push_back(
toString(number_of_rsectors_axl) );
4234 vec_rsector_gap_axl.push_back(
toString(rsector_gap_axl) );
4235 vec_rsector_first_angle.push_back(
toString(rsector_first_angle) );
4238 vec_number_of_modules_trs.push_back(
toString(number_of_modules_trs) );
4239 vec_number_of_modules_axl.push_back(
toString(number_of_modules_axl) );
4240 vec_module_gap_trs.push_back(
toString(module_gap_trs) );
4241 vec_module_gap_axl.push_back(
toString(module_gap_axl) );
4244 vec_number_of_submodules_trs.push_back(
toString(number_of_submodules_trs) );
4245 vec_number_of_submodules_axl.push_back(
toString(number_of_submodules_axl) );
4246 vec_submodule_gap_trs.push_back(
toString(submodule_gap_trs) );
4247 vec_submodule_gap_axl.push_back(
toString(submodule_gap_axl) );
4250 vec_number_of_crystals_trs.push_back(
toString(number_of_crystals_trs) );
4251 vec_number_of_crystals_axl.push_back(
toString(number_of_crystals_axl) );
4252 vec_crystal_gap_trs.push_back(
toString(crystal_gap_trs) );
4253 vec_crystal_gap_axl.push_back(
toString(crystal_gap_axl) );
4256 vec_mean_depth_of_interaction.push_back(
toString(mean_depth_of_interaction) );
4257 vec_min_angle_diff.push_back(
toString(min_angle_diff) );
4260 number_of_layers = 1;
4265 ofstream fileGeom(a_pathGeom.c_str(), ios::out | ios::trunc);
4268 fileGeom <<
"# comments" << endl;
4269 fileGeom <<
"# Y _________ "<< endl;
4270 fileGeom <<
"# | / _ \\ \\ "<< endl;
4271 fileGeom <<
"# | | / \\ | |"<< endl;
4272 fileGeom <<
"# |_____ Z | | | | |"<< endl;
4273 fileGeom <<
"# \\ | | | | |" << endl;
4274 fileGeom <<
"# \\ | \\_/ | |" << endl;
4275 fileGeom <<
"# X \\___/_____/" << endl;
4276 fileGeom <<
"# Left-handed axis orientation"<< endl;
4277 fileGeom <<
"# scanner axis is z" << endl;
4278 fileGeom <<
"# positions in millimeters"<< endl;
4279 fileGeom <<
"# Use comma without space as separator in the tables." << endl;
4281 fileGeom <<
""<< endl;
4284 fileGeom <<
"# MANDATORY FIELDS"<< endl;
4285 fileGeom <<
"modality : " << modality << endl;
4286 fileGeom <<
"scanner name : " << scanner_name << endl;
4287 fileGeom <<
"number of elements : " << number_of_elements << endl;
4288 fileGeom <<
"number of layers : " << number_of_layers << endl;
4289 fileGeom <<
"" << endl;
4290 fileGeom <<
"voxels number transaxial : " << voxels_number_trs << endl;
4291 fileGeom <<
"voxels number axial : " << voxels_number_axl << endl;
4293 fileGeom <<
"field of view transaxial : " << fov_trs << endl;
4294 fileGeom <<
"field of view axial : " << fov_axl << endl << endl;
4295 fileGeom <<
"description : " << description << endl;
4296 fileGeom <<
"" << endl;
4297 WriteVector(fileGeom,
"scanner radius : ",vec_scanner_radius);
4298 WriteVector(fileGeom,
"number of rsectors : ",vec_number_of_rsectors_ang);
4299 WriteVector(fileGeom,
"number of crystals transaxial : ",vec_number_of_crystals_trs);
4300 WriteVector(fileGeom,
"number of crystals axial : ",vec_number_of_crystals_axl);
4301 fileGeom <<
""<< endl;
4302 WriteVector(fileGeom,
"crystals size depth : ", layers_size_depth);
4303 WriteVector(fileGeom,
"crystals size transaxial : ", layers_size_trs);
4304 WriteVector(fileGeom,
"crystals size axial : ", layers_size_axl);
4305 fileGeom <<
""<< endl;
4306 fileGeom <<
""<< endl;
4309 fileGeom <<
"# OPTIONAL FIELDS"<< endl;
4310 WriteVector(fileGeom,
"rsectors first angle : ",vec_rsector_first_angle);
4311 WriteVector(fileGeom,
"number of rsectors axial : ",vec_number_of_rsectors_axl);
4312 WriteVector(fileGeom,
"rsector gap transaxial : ",vec_rsector_gap_trs);
4313 WriteVector(fileGeom,
"rsector gap axial : ",vec_rsector_gap_axl);
4314 WriteVector(fileGeom,
"number of modules transaxial : ",vec_number_of_modules_trs);
4315 WriteVector(fileGeom,
"number of modules axial : ",vec_number_of_modules_axl);
4316 WriteVector(fileGeom,
"module gap transaxial : ",vec_module_gap_trs);
4317 WriteVector(fileGeom,
"module gap axial : ",vec_module_gap_axl);
4318 WriteVector(fileGeom,
"number of submodules transaxial : ",vec_number_of_submodules_trs);
4319 WriteVector(fileGeom,
"number of submodules axial : ",vec_number_of_submodules_axl);
4320 WriteVector(fileGeom,
"submodule gap transaxial : ",vec_submodule_gap_trs);
4321 WriteVector(fileGeom,
"submodule gap axial : ",vec_submodule_gap_axl);
4322 WriteVector(fileGeom,
"crystal gap transaxial : ",vec_crystal_gap_trs);
4323 WriteVector(fileGeom,
"crystal gap axial : ",vec_crystal_gap_axl);
4324 WriteVector(fileGeom,
"mean depth of interaction : ", vec_mean_depth_of_interaction);
4325 fileGeom <<
"rotation direction : CCW " << endl;
4326 fileGeom <<
""<< endl;
4329 if(min_angle_diff > 0.) fileGeom <<
"min angle difference : " << min_angle_diff << endl;
4332 if(rsector_angular_span >= 360.0005 ||
4333 rsector_angular_span <= 359.9995 )
4335 rsector_angular_span *= (double)number_of_rsectors_ang/(
double)(number_of_rsectors_ang-1);
4336 fileGeom <<
"rsectors angular span : " << rsector_angular_span << endl;
4339 if(rsector_nb_zshifts > 0) fileGeom <<
"rsectors nbZShift :" << rsector_nb_zshifts << endl;
4340 if(!vec_rsector_Z_Shift.empty())
WriteVector(fileGeom,
"rsectors ZShift : ", vec_rsector_Z_Shift);
4344 cout <<
"Output geom file written at :" << a_pathGeom << endl;
4348 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Couldn't open geom file for writing "<< a_pathGeom <<
" !" << endl);
4376 string scanner_name =
GetFileFromPath(a_pathGeom.substr(0,a_pathGeom.find_first_of(
".geom")));
4377 double scanner_radius = 0.;
4378 uint32_t number_of_elements = 0;
4379 string description =
"ECAT system extracted from GATE macro: " + a_pathMac;
4382 string block_name =
"block";
4383 uint32_t number_of_blocks = 1;
4384 uint32_t number_of_blocks_trs = 1;
4385 uint32_t number_of_blocks_axl = 1;
4386 double block_step_trs = 0.;
4387 double block_step_axl = 0.;
4388 double block_gap_trs = 0.;
4389 double block_gap_axl = 0.;
4390 double block_size_Y;
4391 double block_size_Z;
4392 double block_pos_X = 0.;
4393 double block_pos_Y = 0.;
4394 double block_first_angle = 0.;
4395 double block_angular_span = 360.;
4396 uint32_t block_nb_zshifts = 0;
4397 vector <double> vec_block_Z_Shift;
4398 bool is_block_Y_axis =
false;
4403 string crystal_name =
"crystal";
4404 uint32_t number_of_crystals_trs = 1;
4405 uint32_t number_of_crystals_axl = 1;
4406 double crystal_step_trs = 0.;
4407 double crystal_step_axl = 0.;
4408 double crystal_gap_trs = 0.;
4409 double crystal_gap_axl = 0.;
4410 double crystal_size_depth = 0.;
4411 double crystal_size_trs = 0.;
4412 double crystal_size_axl = 0.;
4415 uint32_t voxels_number_trs;
4416 uint32_t voxels_number_axl;
4419 double min_angle_diff = 0.;
4421 vector<string> path_mac_files;
4422 path_mac_files.push_back(a_pathMac);
4427 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()->Error occurred when trying to recover paths to GATE macro files !" << endl);
4435 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()->Error occurred when trying to recover aliases for the elements of the ecat !" << endl);
4441 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
4443 ifstream systemMac(path_mac_files[f].c_str(), ios::in);
4446 while(getline(systemMac, line))
4450 vector <string> values;
4454 entry =
"/gate/"+block_name+
"/placement/setTranslation";
4456 if (values.size()>0)
4461 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4467 if(block_pos_X!=0 && block_pos_Y !=0)
4469 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4470 Cerr(
" Block cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
4475 if(block_pos_Y!=0) is_block_Y_axis =
true;
4477 scanner_radius += is_block_Y_axis ? abs(block_pos_Y) : abs(block_pos_X) ;
4504 entry =
"/gate/"+block_name+
"/geometry/setZLength";
4506 if (values.size()>0)
4510 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4514 voxels_number_axl = fov_axl/4 + 1;
4519 entry =
"/gate/"+block_name+
"/ring/setRepeatNumber";
4521 if (values.size()>0)
4525 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4531 entry =
"/gate/"+block_name+
"/ring/setFirstAngle";
4533 if (values.size()>0)
4537 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4543 entry =
"/gate/"+block_name+
"/ring/setAngularSpan";
4545 if (values.size()>0)
4549 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4554 entry =
"/gate/"+block_name+
"/ring/setModuloNumber";
4556 if (values.size()>0)
4560 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4565 for (
int i=1; i<8; i++)
4567 entry =
"/gate/"+block_name+
"/ring/setZShift"+
toString(i);
4569 if (values.size()>0)
4574 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4577 vec_block_Z_Shift.push_back(zshift);
4585 entry =
"/gate/"+block_name+
"/linear/setRepeatNumber";
4587 if (values.size()>0)
4591 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4597 entry =
"/gate/"+block_name+
"/linear/setRepeatVector";
4599 if (values.size()>0)
4603 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4612 entry =
"/gate/"+crystal_name+
"/placement/setTranslation";
4615 FLTNB crystal_pos_X =0.,
4618 if (values.size()>0)
4623 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4629 if(crystal_pos_X!=0 && crystal_pos_Y !=0)
4631 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4632 Cerr(
" Block cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
4636 scanner_radius += is_block_Y_axis ? crystal_pos_Y : crystal_pos_X ;
4640 entry = is_block_Y_axis ?
4641 "/gate/"+crystal_name+
"/geometry/setYLength" :
4642 "/gate/"+crystal_name+
"/geometry/setXLength";
4645 if (values.size()>0)
4647 double crystal_size = 0.;
4650 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4654 scanner_radius -= crystal_size/2;
4660 entry = is_block_Y_axis ?
4661 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
4662 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
4665 if (values.size()>0)
4669 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4674 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
4676 if (values.size()>0)
4680 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4686 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatVector";
4688 if (values.size()>0)
4690 string trs_step = is_block_Y_axis ?
4697 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4704 entry =
"/gate/"+crystal_name+
"/geometry/setXLength";
4706 if (values.size()>0)
4711 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4715 if (is_block_Y_axis)
4716 crystal_size_trs = x_length;
4718 crystal_size_depth = x_length;
4723 entry =
"/gate/"+crystal_name+
"/geometry/setYLength";
4725 if (values.size()>0)
4730 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4734 if (is_block_Y_axis)
4735 crystal_size_depth = y_length;
4737 crystal_size_trs = y_length;
4740 entry =
"/gate/"+crystal_name+
"/geometry/setZLength";
4742 if (values.size()>0)
4746 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4754 entry =
"/gate/digitizer/Coincidences/minSectorDifference";
4756 if (values.size()>0)
4758 double min_sector_diff;
4761 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4764 min_angle_diff = 360/number_of_blocks*min_sector_diff;
4771 number_of_elements = number_of_blocks *
4772 number_of_blocks_axl *
4773 number_of_crystals_trs *
4774 number_of_crystals_axl;
4779 fov_trs = (2*scanner_radius ) / 1.5;
4782 voxels_number_trs = ( number_of_crystals_trs
4783 * number_of_blocks_trs)
4787 if (crystal_step_axl - crystal_size_axl >= 0)
4788 crystal_gap_axl = crystal_step_axl - crystal_size_axl;
4790 if (crystal_step_trs - crystal_size_trs >= 0)
4791 crystal_gap_trs = crystal_step_trs - crystal_size_trs;
4795 block_size_Z = crystal_size_axl*number_of_crystals_axl + crystal_gap_axl*(number_of_crystals_axl-1);
4796 block_size_Y = crystal_size_trs*number_of_crystals_trs + crystal_gap_trs*(number_of_crystals_trs-1);
4799 if (block_step_axl - block_size_Z >= 0)
4800 block_gap_axl = block_step_axl - block_size_Z;
4802 if (block_step_trs - block_size_Y >= 0)
4803 block_gap_trs = block_step_trs - block_size_Y;
4806 block_first_angle -= round(atan2f(block_pos_X , block_pos_Y) * 180. / M_PI);
4810 ofstream fileGeom(a_pathGeom.c_str(), ios::out | ios::trunc);
4814 fileGeom <<
"# comments" << endl;
4815 fileGeom <<
"# Y _________ "<< endl;
4816 fileGeom <<
"# | / _ \\ \\ "<< endl;
4817 fileGeom <<
"# | | / \\ | |"<< endl;
4818 fileGeom <<
"# |_____ Z | | | | |"<< endl;
4819 fileGeom <<
"# \\ | | | | |" << endl;
4820 fileGeom <<
"# \\ | \\_/ | |" << endl;
4821 fileGeom <<
"# X \\___/_____/" << endl;
4822 fileGeom <<
"# Left-handed axis orientation"<< endl;
4823 fileGeom <<
"# scanner axis is z" << endl;
4824 fileGeom <<
"# positions in millimeters"<< endl;
4825 fileGeom <<
"# Use comma without space as separator in the tables." << endl;
4828 fileGeom <<
"modality : " << modality << endl;
4829 fileGeom <<
"scanner name : " << scanner_name << endl;
4830 fileGeom <<
"number of elements : " << number_of_elements << endl;
4831 fileGeom <<
"number of layers : " <<
"1" << endl;
4832 fileGeom <<
"" << endl;
4833 fileGeom <<
"# default reconstruction parameters" << endl;
4834 fileGeom <<
"voxels number transaxial : " << voxels_number_trs << endl;
4835 fileGeom <<
"voxels number axial : " << voxels_number_axl << endl;
4837 fileGeom <<
"field of view transaxial : " << fov_trs << endl;
4838 fileGeom <<
"field of view axial : " << fov_axl << endl;
4839 fileGeom <<
"" << endl;
4840 fileGeom <<
"description : " << description << endl;
4841 fileGeom <<
"" << endl;
4842 fileGeom <<
"scanner radius : " << scanner_radius << endl;
4843 fileGeom <<
"number of rsectors : " << number_of_blocks << endl;
4844 fileGeom <<
"number of crystals transaxial : " << number_of_crystals_trs << endl;
4845 fileGeom <<
"number of crystals axial : " << number_of_crystals_axl << endl;
4847 fileGeom <<
""<< endl;
4848 fileGeom <<
"# The 4 following parameters could be defined in arrays (SizeLayer1,SizeLayer2,SizeLayer3,etc..) if their is more than one layer"<< endl;
4849 fileGeom <<
"crystals size depth : " << crystal_size_depth << endl;
4850 fileGeom <<
"crystals size transaxial : " << crystal_size_trs << endl;
4851 fileGeom <<
"crystals size axial : " << crystal_size_axl << endl;
4852 fileGeom <<
""<< endl;
4855 fileGeom <<
"rsectors first angle : " << block_first_angle << endl;
4856 fileGeom <<
"number of modules transaxial : " << number_of_blocks_trs << endl;
4857 fileGeom <<
"number of modules axial : " << number_of_blocks_axl << endl;
4858 fileGeom <<
"module gap transaxial : " << block_gap_trs << endl;
4859 fileGeom <<
"module gap axial : " << block_gap_axl << endl;
4860 fileGeom <<
"crystal gap transaxial : " << crystal_gap_trs << endl;
4861 fileGeom <<
"crystal gap axial : " << crystal_gap_axl << endl;
4862 fileGeom <<
"rotation direction : CCW " << endl;
4863 fileGeom <<
""<< endl;
4866 if(min_angle_diff > 0.) fileGeom <<
"min angle difference : " << min_angle_diff << endl;
4869 if(block_angular_span >= 360.0005 ||
4870 block_angular_span <= 359.9995 )
4872 block_angular_span *= (double)(number_of_blocks)/(double)(number_of_blocks-1);
4873 fileGeom <<
"rsectors angular span : " << block_angular_span << endl;
4876 if(block_nb_zshifts > 0) fileGeom <<
"rsectors nbZShift :" << block_nb_zshifts << endl;
4877 if(!vec_block_Z_Shift.empty())
WriteVector(fileGeom,
"rsectors ZShift : ", vec_block_Z_Shift);
4881 Cout(
"Output geom file written at :" << a_pathGeom << endl);
4885 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Couldn't open geom file for writing "<< a_pathGeom <<
" !" << endl);
4910 string scanner_name =
GetFileFromPath(a_pathGeom.substr(0,a_pathGeom.find_first_of(
".geom")));
4911 FLTNB scanner_radius = -1.;
4912 string description =
"SPECT camera extracted from GATE macro: " + a_pathMac;
4915 string head_name =
"SPECThead";
4916 uint32_t number_of_heads = 0;
4917 FLTNB head_pos_X = 0.;
4918 FLTNB head_pos_Y = 0.;
4919 FLTNB head_first_angle = 0.;
4920 FLTNB head_angular_pitch = -1.;
4921 string head_orbit_name =
"";
4922 FLTNB head_rotation_speed = 0.;
4923 bool is_head_Y_axis =
false;
4926 string crystal_name =
"crystal";
4927 FLTNB crystal_size_trs = 0.;
4928 FLTNB crystal_size_axl = 0.;
4929 FLTNB crystal_depth = 0;
4932 string pixel_name =
"pixel";
4933 uint32_t number_of_pixels_trs = 1;
4934 uint32_t number_of_pixels_axl = 1;
4935 FLTNB pix_size_trs = 0.;
4936 FLTNB pix_size_axl = 0.;
4937 FLTNB pix_step_trs = 0.;
4938 FLTNB pix_step_axl = 0.;
4939 FLTNB pix_gap_trs = 0.;
4940 FLTNB pix_gap_axl = 0.;
4943 string focal_model_trs =
"constant";
4944 uint16_t nb_coeff_model_trs = 1;
4945 FLTNB coeff_model_trs = 0.;
4946 string focal_model_axl =
"constant";
4947 uint16_t nb_coeff_model_axl = 1;
4948 FLTNB coeff_model_axl = 0.;
4951 uint32_t voxels_number_trs;
4952 uint32_t voxels_number_axl;
4956 vector<string> path_mac_files;
4957 path_mac_files.push_back(a_pathMac);
4962 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()->Error occurred when trying to recover paths to GATE macro files !" << endl);
4970 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()->Error occurred when trying to recover aliases for the elements of the SPECThead !" << endl);
4975 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
4977 ifstream systemMac(path_mac_files[f].c_str(), ios::in);
4980 while(getline(systemMac, line))
4983 modality =
"SPECT_CONVERGENT";
4984 vector <string> values;
4988 entry =
"/gate/"+head_name+
"/placement/setTranslation";
4990 if (values.size()>0)
4995 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5001 if(head_pos_X!=0 && head_pos_Y !=0)
5003 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5004 Cerr(
" Block cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
5009 if(head_pos_Y!=0) is_head_Y_axis =
true;
5011 scanner_radius = is_head_Y_axis ? abs(head_pos_Y) : abs(head_pos_X) ;
5015 entry =
"/gate/"+head_name+
"/geometry/setZLength";
5017 if (values.size()>0)
5021 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5025 voxels_number_axl = fov_axl/4 + 1;
5029 entry =
"/gate/"+head_name+
"/ring/setRepeatNumber";
5031 if (values.size()>0)
5035 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5041 entry =
"/gate/"+head_name+
"/ring/setFirstAngle";
5043 if (values.size()>0)
5047 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5053 entry =
"/gate/"+head_name+
"/ring/setAngularPitch";
5055 if (values.size()>0)
5059 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5064 entry =
"/gate/"+head_name+
"/moves/insert";
5066 if (values.size()>0)
5070 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5075 entry =
"/gate/"+head_orbit_name+
"/setSpeed";
5077 if (values.size()>0)
5081 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5089 entry =
"/gate/"+crystal_name+
"/geometry/setXLength";
5091 if (values.size()>0)
5096 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5101 crystal_size_trs = x_length;
5103 crystal_depth = x_length;
5106 entry =
"/gate/"+crystal_name+
"/geometry/setYLength";
5108 if (values.size()>0)
5113 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5118 crystal_depth = y_length;
5120 crystal_size_trs = y_length;
5124 entry =
"/gate/"+crystal_name+
"/geometry/setZLength";
5126 if (values.size()>0)
5130 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5140 entry = is_head_Y_axis ?
5141 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberX":
5142 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberY";
5146 if (values.size()>0)
5150 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5155 entry =
"/gate/"+pixel_name+
"/cubicArray/setRepeatNumberZ";
5157 if (values.size()>0)
5161 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5167 entry =
"/gate/"+pixel_name+
"/geometry/setXLength";
5169 if (values.size()>0)
5174 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5179 pix_size_trs = x_length;
5182 entry =
"/gate/"+pixel_name+
"/geometry/setYLength";
5184 if (values.size()>0)
5189 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5193 if (!is_head_Y_axis)
5194 pix_size_trs = y_length;
5198 entry =
"/gate/"+pixel_name+
"/geometry/setZLength";
5200 if (values.size()>0)
5204 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5210 entry =
"/gate/"+pixel_name+
"/cubicArray/setRepeatVector";
5212 if (values.size()>0)
5214 string trs_step = is_head_Y_axis ?
5221 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5228 entry = is_head_Y_axis ?
5229 "/gate/fanbeam/geometry/setFocalDistanceY":
5230 "/gate/fanbeam/geometry/setFocalDistanceX";
5232 entry =
"/gate/fanbeam/geometry/setFocalDistanceX";
5234 if (values.size()>0)
5238 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5242 focal_model_trs =
"polynomial";
5250 fov_trs = scanner_radius/2;
5252 voxels_number_trs = fov_trs/2 + 1;
5254 uint32_t nb_pixels = number_of_pixels_axl * number_of_pixels_trs;
5256 pix_size_axl = nb_pixels>1 ? pix_size_axl : crystal_size_axl;
5257 pix_size_trs = nb_pixels>1 ? pix_size_trs : crystal_size_trs;
5260 if (pix_step_axl - pix_size_axl >= 0)
5261 pix_gap_axl = pix_step_axl - pix_size_axl;
5263 if (pix_step_trs - pix_size_trs >= 0)
5264 pix_gap_trs = pix_step_trs - pix_size_trs;
5268 head_first_angle = round(atan2f(head_pos_X , head_pos_Y) * 180. / M_PI)
5273 ofstream fileGeom(a_pathGeom.c_str(), ios::out | ios::trunc);
5277 fileGeom <<
"modality : " << modality << endl;
5278 fileGeom <<
"scanner name : " << scanner_name << endl;
5279 fileGeom <<
"number of detector heads : " << number_of_heads << endl;
5280 fileGeom <<
"trans number of pixels : " << number_of_pixels_trs << endl;
5281 fileGeom <<
"trans pixel size : " << pix_size_trs << endl;
5282 fileGeom <<
"trans gap size : " << pix_gap_trs << endl;
5283 fileGeom <<
"axial number of pixels : " << number_of_pixels_axl << endl;
5284 fileGeom <<
"axial pixel size : " << pix_size_axl << endl;
5285 fileGeom <<
"axial gap size : " << pix_gap_axl << endl;
5287 fileGeom <<
"detector depth : " << crystal_depth << endl;
5289 fileGeom <<
"scanner radius : " << scanner_radius;
5290 for(
size_t h=1 ; h<number_of_heads ; h++)
5291 fileGeom <<
"," << scanner_radius;
5294 fileGeom <<
"# Collimator configuration : "<< endl << endl;
5295 for(
size_t h=0 ; h<number_of_heads ; h++)
5297 fileGeom <<
"head" << h+1 <<
":" << endl;
5298 fileGeom <<
"trans focal model: " << focal_model_trs << endl;
5299 fileGeom <<
"trans number of coef model: " << nb_coeff_model_trs << endl;
5300 fileGeom <<
"trans parameters: " << coeff_model_trs << endl;
5301 fileGeom <<
"axial focal model: " << focal_model_axl << endl;
5302 fileGeom <<
"axial number of coef model: " << nb_coeff_model_axl << endl;
5303 fileGeom <<
"axial parameters: " << coeff_model_axl << endl;
5307 fileGeom <<
"" << endl;
5308 fileGeom <<
"# default reconstruction parameters" << endl;
5309 fileGeom <<
"voxels number transaxial : " << voxels_number_trs << endl;
5310 fileGeom <<
"voxels number axial : " << voxels_number_axl << endl;
5312 fileGeom <<
"field of view transaxial : " << fov_trs << endl;
5313 fileGeom <<
"field of view axial : " << fov_axl << endl << endl ;
5314 fileGeom <<
""<< endl;
5316 fileGeom <<
"# description" << endl;
5317 fileGeom <<
"description : " << description << endl;
5321 Cout(
"Output geom file written at :" << a_pathGeom << endl);
5325 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Couldn't open geom file for writing "<< a_pathGeom <<
" !" << endl);
int WriteVector(ofstream &file, const string &a_key, vector< T > a_vals)
Write the key and its values in the file provided in parameter.
string GetPathOfFile(const string &a_pathToFile)
Simply return the path to the directory of a file path string passed in parameter.
uint32_t ConvertIDSPECTRoot2(uint32_t a_nbSimulatedPixels, uint32_t a_nPixTrs, uint32_t a_nPixAxl, int32_t a_headID, int32_t a_crystalID, int32_t a_pixelID, float_t a_rotAngle, float_t a_headAngPitch, float_t a_crystalSizeAxl, float_t a_crystalSizeTrs, float_t a_gPosX, float_t a_gPosY, float_t a_gPosZ)
Compute a CASToR crystal index of a GATE SPECThead system.
vector< string > CheckGATECommand(const string &a_key, const string &a_line)
Check if the line contains the provided GATE command. In this case, parse the line and returns the va...
uint32_t ConvertIDcylindrical(uint32_t nRsectorsAngPos, uint32_t nRsectorsAxial, bool a_invertDetOrder, int a_rsectorIdOrder, uint32_t nModulesTransaxial, uint32_t nModulesAxial, uint32_t nSubmodulesTransaxial, uint32_t nSubmodulesAxial, uint32_t nCrystalsTransaxial, uint32_t nCrystalsAxial, uint8_t nLayers, uint32_t *nCrystalPerLayer, vector< uint32_t > nLayersRptTransaxial, vector< uint32_t > nLayersRptAxial, int32_t layerID, int32_t crystalID, int32_t submoduleID, int32_t moduleID, int32_t rsectorID)
Compute a CASToR crystal index of a GATE cylindricalPET system from its indexes (rsector/module/submo...
int ComputeKindGATEEvent(int32_t eventID1, int32_t eventID2, int comptonPhantom1, int comptonPhantom2, int rayleighPhantom1, int rayleighPhantom2)
#define GATE_NB_MAX_LAYERS
int CreateGeomWithECAT(string a_pathMac, string a_pathGeom)
Read a GATE macro file containing the description of an ecat system, and convert it to a geom file...
int ReadIntfSPECT(string a_pathIntf, float_t &a_distToDetector, uint32_t &a_nHeads, uint32_t &a_nPixAxl, uint32_t &a_nPixTrs, float_t &a_crystalSizeAxl, float_t &a_crystalSizeTrs, uint32_t &a_nProjectionsTot, uint32_t &a_nProjectionsByHead, float_t &a_head1stAngle, float_t &a_headAngPitchDeg, float_t &a_headAngStepDeg, int &a_headRotDirection, uint32_t &a_start_time_ms, uint32_t &a_duration_ms, int vb)
Recover informations about the scanner element of an ECAT system, and acquisition duration...
uint32_t ConvertIDSPECTRoot1(int32_t a_headID, float_t a_rotAngle, float_t a_angStep, uint32_t a_nProjectionsByHead)
Compute a CASToR projection index of a GATE SPECThead system.
int CreateGeomWithCylindrical(string a_pathMac, string a_pathGeom)
Read a GATE macro file containing the description of a cylindricalPET system, and convert it to a geo...
int GetGATEAliasesCylindrical(vector< string > path_mac_files, string &rsector_name, string &module_name, string &submodule_name, string &crystal_name, vector< string > &layers_name, int vb)
Loop over a list of path to GATE macro files passed in parameter to recover aliases of the different ...
int GetGATEAliasesEcat(vector< string > path_mac_files, string &block_name, string &crystal_name, int vb)
Loop over a list of path to GATE macro files passed in parameter to recover aliases of the different ...
void ConvertValuesTomm(vector< string > &ap_v)
Check if the vector of strings passed in parameter contains the 'cm' unit In this case...
int ReadMacSPECT(string a_pathMac, float_t &a_distToDetector, uint32_t &a_nHeads, uint32_t &a_nPixAxl, uint32_t &a_nPixTrs, float_t &a_crystalSizeAxl, float_t &a_crystalSizeTrs, uint32_t &a_nProjectionsTot, uint32_t &a_nProjectionsByHead, float_t &a_head1stAngle, float_t &a_headAngPitch, float_t &a_headAngStepDeg, int &a_headRotDirection, uint32_t &a_start_time_ms, uint32_t &a_duration_ms, int vb)
Recover informations about the scanner element of an ECAT system, and acquisition duration...
uint32_t ConvertIDecat(int32_t nBlocksPerRing, int32_t nBlocksLine, int32_t nCrystalsTransaxial, int32_t nCrystalsAxial, int32_t crystalID, int32_t blockID)
Compute a CASToR crystal index of a GATE ecat system from its indexes (block/crystal) and the system ...
vector< string > Split(string a_line)
Split the line provided in parameter into a vector of strings (separator is blankspace) ...
#define KEYWORD_MANDATORY
#define GATE_SYS_CYLINDRICAL
int CreateGeomWithSPECT(string a_pathMac, string a_pathGeom)
Read a GATE macro file containing the description of a SPECThead system, and convert it to a geom fil...
int GetGATESystemType(const string &a_pathMac)
Read a GATE macro file and identify the system type from the 'gate/systems/' command lines...
int IntfKeyGetRecurringValueFromFile(const string &a_pathToHeader, const string &a_key, T *ap_return, int a_nbElts, int a_mandatoryFlag, uint16_t a_nbOccurrences)
int ConvertFromString(const string &a_str, string *a_result)
Copy the 'a_str' string in the position pointed by 'a_result'.
int GetGATEMacFiles(const string &a_pathMac, vector< string > &ap_pathToMacFiles)
Extract the paths to each macro file contained in the main macro file.
string toString(T a_val)
Convert a value of any type into string.
string GetFileFromPath(const string &a_pathToFile)
Simply return the file from a path string passed in parameter.
int ReadMacECAT(string a_pathMac, uint32_t &nCrystalsTot, uint32_t &nCrystalsAxial, uint32_t &nCrystalsTransaxial, uint32_t &nBlocksLine, uint32_t &nBlocksPerRing, uint32_t &start_time_ms, uint32_t &duration_ms, FLTNB &pet_coinc_window, int vb)
int GetGATEAliasesSPECT(vector< string > path_mac_files, string &base_name, string &crystal_name, string &pixel_name, int vb)
Loop over a list of path to GATE macro files passed in parameter to recover aliases of the different ...
int IntfKeyGetValueFromFile(const string &a_pathToHeader, const string &a_key, T *ap_return, int a_nbElts, int a_mandatoryFlag)
Look for "a_nbElts" elts in the "a_pathToHeader" interfile header matching the "a_keyword" key passed...
int ReadMacCylindrical(string a_pathMac, uint8_t &nLayers, uint32_t *nb_crystal_per_layer, uint32_t &nCrystalsTot, uint32_t &nCrystalsAxial, uint32_t &nCrystalsTransaxial, vector< uint32_t > &nLayersRptAxial, vector< uint32_t > &nLayersRptTransaxial, uint32_t &nSubmodulesAxial, uint32_t &nSubmodulesTransaxial, uint32_t &nModulesAxial, uint32_t &nModulesTransaxial, uint32_t &nRsectorsAxial, uint32_t &nRsectorsAngPos, bool &invert_det_order, int &rsector_id_order, uint32_t &start_time_ms, uint32_t &duration_ms, FLTNB &pet_coinc_window, int vb)