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,
811 uint32_t nModulesTransaxial,
812 uint32_t nModulesAxial,
813 uint32_t nSubmodulesTransaxial,
814 uint32_t nSubmodulesAxial,
815 uint32_t nCrystalsTransaxial,
816 uint32_t nCrystalsAxial,
818 uint32_t* nCrystalPerLayer,
819 vector<uint32_t> nLayersRptTransaxial,
820 vector<uint32_t> nLayersRptAxial,
828 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
898 uint32_t sum_detectors_prev_layers = 0;
903 while ( layerID >= (int32_t)( sum_detectors_prev_layers
904 + ( nLayersRptTransaxial[layer]
905 * nLayersRptAxial[layer]) ) )
908 sum_detectors_prev_layers += nLayersRptTransaxial[layer]
909 * nLayersRptAxial[layer];
917 if (layer>0)layerID -= sum_detectors_prev_layers;
921 for(
int l=0 ; l<layer ; l++)
922 castorID += nCrystalPerLayer[l];
924 int32_t nTrsCrystalsPerSubmodule = nCrystalsTransaxial * nLayersRptTransaxial[layer];
925 int32_t nTrsCrystalsPerModule = nTrsCrystalsPerSubmodule * nSubmodulesTransaxial;
926 int32_t nTrsCrystalsPerRsector = nTrsCrystalsPerModule * nModulesTransaxial;
927 int32_t nCrystalsPerRing = nTrsCrystalsPerRsector * nRsectorsAngPos;
931 int32_t rsectorAxlID = 0 ;
932 int32_t rsectorTrsID = 0 ;
935 if(a_rsectorIdOrder == 0)
937 rsectorAxlID = rsectorID/nRsectorsAngPos ;
938 rsectorTrsID = (int32_t)(rsectorID%nRsectorsAngPos) ;
942 rsectorAxlID = rsectorID%nRsectorsAxial ;
943 rsectorTrsID = (int32_t)(rsectorID/nRsectorsAxial) ;
948 int32_t ringID = rsectorAxlID * nModulesAxial * nSubmodulesAxial * nCrystalsAxial * nLayersRptAxial[layer]
949 + (int32_t)(moduleID/nModulesTransaxial) * nSubmodulesAxial * nCrystalsAxial * nLayersRptAxial[layer]
950 + (int32_t)(submoduleID/nSubmodulesTransaxial) * nCrystalsAxial * nLayersRptAxial[layer]
951 + (int32_t)(crystalID/nCrystalsTransaxial) * nLayersRptAxial[layer];
954 if(!nLayersRptTransaxial.empty() )
955 ringID += (int32_t)(layerID/nLayersRptTransaxial[layer]);
959 moduleID = moduleID % nModulesTransaxial;
960 submoduleID = submoduleID % nSubmodulesTransaxial;
961 crystalID = crystalID % nCrystalsTransaxial;
962 layerID = layerID % nLayersRptTransaxial[layer];
965 if( a_invertDetOrder )
967 moduleID = nModulesTransaxial-1 - moduleID;
968 submoduleID = nSubmodulesTransaxial-1 - submoduleID;
969 crystalID = nCrystalsTransaxial-1 - crystalID;
970 layerID = nLayersRptTransaxial[layer]-1 - layerID;
974 castorID += nCrystalsPerRing * ringID
975 + nTrsCrystalsPerRsector * rsectorTrsID
976 + nTrsCrystalsPerModule * moduleID
977 + nTrsCrystalsPerSubmodule * submoduleID
1003 int comptonPhantom1,
int comptonPhantom2,
1004 int rayleighPhantom1,
int rayleighPhantom2)
1006 if ( (eventID1 != eventID2)
1013 if (comptonPhantom1 == 0 && comptonPhantom2 == 0 &&
1014 rayleighPhantom1 == 0 && rayleighPhantom2 == 0)
1019 if (comptonPhantom1 == 1 || comptonPhantom2 == 1 ||
1020 rayleighPhantom1 == 1 || rayleighPhantom2 == 1)
1023 if (comptonPhantom1 > 1 || comptonPhantom2 > 1 ||
1024 rayleighPhantom1 > 1 || rayleighPhantom2 > 1)
1065 uint32_t *nb_crystal_per_layer,
1066 uint32_t &nCrystalsTot,
1067 uint32_t &nCrystalsAxial,
1068 uint32_t &nCrystalsTransaxial,
1069 vector<uint32_t> &nLayersRptAxial,
1070 vector<uint32_t> &nLayersRptTransaxial,
1071 uint32_t &nSubmodulesAxial,
1072 uint32_t &nSubmodulesTransaxial,
1073 uint32_t &nModulesAxial,
1074 uint32_t &nModulesTransaxial,
1075 uint32_t &nRsectorsAxial,
1076 uint32_t &nRsectorsAngPos,
1077 bool &invert_det_order,
1078 int &rsector_id_order,
1079 uint32_t &start_time_ms,
1080 uint32_t &duration_ms,
1081 FLTNB &pet_coinc_window,
1085 vector<string> path_mac_files;
1086 path_mac_files.push_back(a_pathMac);
1091 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
1095 string rsector_name =
"";
1096 string module_name =
"";
1097 string submodule_name =
"";
1098 string crystal_name =
"";
1099 string mod_rptr_type =
"cubicArray";
1100 string smod_rptr_type =
"cubicArray";
1101 string cry_rptr_type =
"cubicArray";
1102 string lay_rptr_type =
"cubicArray";
1105 int mod_linear_nb = 0;
1106 int subm_linear_nb = 0;
1107 int cry_linear_nb = 0;
1108 vector<int> lay_linear_nb;
1110 vector <string> layers_name;
1111 vector<uint32_t> nLayersRptDepth;
1112 bool is_rsector_Y_axis =
false;
1115 if(
GetGATEAliasesCylindrical(path_mac_files, rsector_name, module_name, submodule_name, crystal_name, layers_name, vb) )
1117 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover aliases for the elements of the cylindricalPET !" << endl);
1122 nLayers = layers_name.size();
1125 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
1127 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
1130 double time_start =-1.,
1134 while(getline(mac_file, line))
1136 vector <string> values;
1142 kword =
"/gate/"+rsector_name+
"/placement/setTranslation";
1146 if (values.size()>0)
1148 FLTNB rsector_pos_X =0.,
1154 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1159 if(rsector_pos_Y!=0) is_rsector_Y_axis =
true;
1165 if(rsector_pos_Y > 0 || rsector_pos_X < 0)
1166 invert_det_order =
true;
1171 kword =
"/gate/"+rsector_name+
"/ring/setRepeatNumber";
1173 if (values.size()>0)
1177 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1184 kword =
"/gate/"+rsector_name+
"/linear/setRepeatNumber";
1186 if (values.size()>0)
1190 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1197 kword =
"/gate/"+rsector_name+
"/cubicArray/setRepeatNumberZ";
1200 if (values.size()>0)
1204 rsector_id_order = nRsectorsAngPos>1 ? 1 : 0 ;
1208 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1219 kword = is_rsector_Y_axis ?
1220 "/gate/"+module_name+
"/cubicArray/setRepeatNumberX":
1221 "/gate/"+module_name+
"/cubicArray/setRepeatNumberY";
1224 if (values.size()>0)
1228 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1233 kword =
"/gate/"+module_name+
"/cubicArray/setRepeatNumberZ";
1235 if (values.size()>0)
1239 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1245 kword =
"/gate/"+module_name+
"/linear/setRepeatNumber";
1247 if (values.size()>0)
1252 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1258 kword =
"/gate/"+module_name+
"/cubicArray/setRepeatNumber ";
1260 if (values.size()>0)
1265 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1271 double module_step_trs=0., module_step_axl=0.;
1273 kword =
"/gate/"+module_name+
"/linear/setRepeatVector";
1275 if (values.size()>0)
1277 string trs_step = is_rsector_Y_axis ?
1284 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1289 if(module_step_trs > 0)
1290 nModulesTransaxial = mod_linear_nb;
1291 else if (module_step_axl > 0)
1292 nModulesAxial = mod_linear_nb;
1295 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);
1303 kword =
"/gate/"+module_name+
"/cubicArray/setRepeatVector";
1305 if (values.size()>0)
1307 string trs_step = is_rsector_Y_axis ?
1314 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1319 if(module_step_trs > 0)
1320 nModulesTransaxial = mod_linear_nb;
1321 else if (module_step_axl > 0)
1322 nModulesAxial = mod_linear_nb;
1325 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);
1337 kword = is_rsector_Y_axis ?
1338 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberX":
1339 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberY";
1342 if (values.size()>0)
1346 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1351 kword =
"/gate/"+submodule_name+
"/cubicArray/setRepeatNumberZ";
1353 if (values.size()>0)
1357 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1363 kword =
"/gate/"+submodule_name+
"/linear/setRepeatNumber";
1365 if (values.size()>0)
1370 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1376 kword =
"/gate/"+submodule_name+
"/cubicArray/setRepeatNumber ";
1378 if (values.size()>0)
1383 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1389 double submodule_step_trs=0., submodule_step_axl=0.;
1391 kword =
"/gate/"+submodule_name+
"/linear/setRepeatVector";
1393 if (values.size()>0)
1395 string trs_step = is_rsector_Y_axis ?
1402 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1407 if(submodule_step_trs > 0)
1408 nSubmodulesTransaxial = subm_linear_nb;
1409 else if (submodule_step_axl > 0)
1410 nSubmodulesAxial = subm_linear_nb;
1413 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);
1419 if(subm_linear_nb>0)
1421 kword =
"/gate/"+submodule_name+
"/cubicArray/setRepeatVector";
1423 if (values.size()>0)
1425 string trs_step = is_rsector_Y_axis ?
1432 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1437 if(submodule_step_trs > 0)
1438 nSubmodulesTransaxial = subm_linear_nb;
1439 else if (submodule_step_axl > 0)
1440 nSubmodulesAxial = subm_linear_nb;
1443 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);
1452 kword = is_rsector_Y_axis ?
1453 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
1454 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
1457 if (values.size()>0)
1461 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1466 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
1468 if (values.size()>0)
1472 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1479 kword =
"/gate/"+crystal_name+
"/linear/setRepeatNumber";
1481 if (values.size()>0)
1486 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1492 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumber ";
1494 if (values.size()>0)
1499 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1506 double crystal_step_trs=0., crystal_step_axl=0.;
1508 kword =
"/gate/"+crystal_name+
"/linear/setRepeatVector";
1510 if (values.size()>0)
1512 string trs_step = is_rsector_Y_axis ?
1519 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1524 if(crystal_step_trs > 0)
1525 nCrystalsTransaxial = cry_linear_nb;
1526 else if (crystal_step_axl > 0)
1527 nCrystalsAxial = cry_linear_nb;
1530 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);
1538 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatVector";
1540 if (values.size()>0)
1542 string trs_step = is_rsector_Y_axis ?
1549 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1554 if(crystal_step_trs > 0)
1555 nCrystalsTransaxial = cry_linear_nb;
1556 else if (crystal_step_axl > 0)
1557 nCrystalsAxial = cry_linear_nb;
1560 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);
1569 for(
int l=0 ; l<nLayers ; l++)
1576 kword = is_rsector_Y_axis ?
1577 "/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberX":
1578 "/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberY";
1581 if (values.size()>0)
1586 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1589 nLayersRptTransaxial.push_back(val);
1595 kword = is_rsector_Y_axis ?
1596 "/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberY":
1597 "/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberX";
1600 if (values.size()>0)
1605 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1609 nLayersRptDepth.push_back(val);
1613 kword =
"/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumberZ";
1615 if (values.size()>0)
1620 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1623 nLayersRptAxial.push_back(val);
1627 kword =
"/gate/"+layers_name[l]+
"/linear/setRepeatNumber";
1629 if (values.size()>0)
1634 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1637 lay_linear_nb.push_back(val);
1641 kword =
"/gate/"+layers_name[l]+
"/cubicArray/setRepeatNumber ";
1643 if (values.size()>0)
1648 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1651 lay_linear_nb.push_back(val);
1657 kword =
"/gate/"+layers_name[l]+
"/linear/setRepeatVector";
1659 if (values.size()>0)
1661 string trs_step = is_rsector_Y_axis ?
1665 string dph_step = is_rsector_Y_axis ?
1669 double step_trs=0., step_axl=0., step_dph=0.;
1674 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1679 nLayersRptTransaxial.push_back(lay_linear_nb[l]);
1680 else if (step_axl > 0)
1681 nLayersRptAxial.push_back(lay_linear_nb[l]);
1682 else if (step_dph > 0)
1683 nLayersRptDepth.push_back(lay_linear_nb[l]);
1686 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> There seems to be a problem with layer linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
1693 if((
int)lay_linear_nb.size()>l && lay_linear_nb[ l ]>0)
1695 kword=
"/gate/"+layers_name[l]+
"/cubicArray/setRepeatVector";
1697 if (values.size()>0)
1699 string trs_step = is_rsector_Y_axis ?
1703 string dph_step = is_rsector_Y_axis ?
1707 double step_trs=0., step_axl=0., step_dph=0.;
1712 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
1717 nLayersRptTransaxial.push_back(lay_linear_nb[l]);
1718 else if (step_axl > 0)
1719 nLayersRptAxial.push_back(lay_linear_nb[l]);
1720 else if (step_dph > 0)
1721 nLayersRptDepth.push_back(lay_linear_nb[l]);
1724 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> There seems to be a problem with layer linear repeater. Please report the error to the castor mailing-list! At line " << line<< endl);
1732 if (nLayersRptDepth.size() > 0)
1733 lyr_rpt_flag =
true;
1738 kword =
"/gate/application/setTimeStart";
1740 if (values.size()>0)
1744 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1749 if (values.size()>1)
1751 if(values[1] ==
"s") time_start *= 1000;
1754 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1756 start_time_ms = time_start;
1759 kword =
"/gate/application/setTimeStop";
1761 if (values.size()>0)
1765 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1770 if (values.size()>1)
1772 if(values[1] ==
"s") time_stop *= 1000;
1775 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1778 kword =
"/gate/application/addSlice";
1780 if (values.size()>0)
1782 double time_slice_tmp=0;
1786 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1791 if (values.size()>1)
1793 if(values[1] ==
"s") time_slice_tmp *= 1000;
1796 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
1798 time_slices += time_slice_tmp;
1801 kword =
"/gate/digitizer/Coincidences/setWindow";
1803 if (values.size()>0)
1807 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
1812 if (values.size()>1)
1814 if(values[1] ==
"ns") pet_coinc_window *= 1000.;
1815 else if (values[1] ==
"us") pet_coinc_window *= 1000000.;
1816 else if (values[1] ==
"ps") ;
1819 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> ERROR : can't read unit of '"<< kword <<
". Must be ns, ps or us !!!");
1825 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in ns");
1832 duration_ms = (time_slices>0) ?
1833 (uint32_t)(time_slices-time_start) :
1836 duration_ms = (time_start>=0 && time_stop>=0) ?
1837 (uint32_t)(time_stop-time_start) :
1844 if (nLayersRptDepth.size() > 0)
1850 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> Conflicting declaration of layers using both crystal/daughter command and a depth level with a linear or cubic array repeater. Only one approach can be managed"<< endl);
1855 nLayers = nLayersRptDepth[ 0 ];
1858 for (
size_t l=1 ; l<nLayersRptDepth[ 0 ] ; l++)
1860 if( nLayersRptTransaxial.size() > 0 ) nLayersRptTransaxial.push_back( nLayersRptTransaxial[ 0 ] );
1861 if( nLayersRptAxial.size() > 0 ) nLayersRptAxial.push_back( nLayersRptAxial[ 0 ] );
1870 nCrystalsTot = nRsectorsAngPos * nRsectorsAxial
1871 * nModulesTransaxial * nModulesAxial
1872 * nSubmodulesTransaxial * nSubmodulesAxial
1873 * nCrystalsTransaxial * nCrystalsAxial;
1876 for(
int l=0 ; l<nLayers ; l++)
1878 uint32_t nb_crystals_layer = nRsectorsAngPos * nRsectorsAxial
1879 * nModulesTransaxial * nModulesAxial
1880 * nSubmodulesTransaxial * nSubmodulesAxial
1881 * nCrystalsTransaxial * nCrystalsAxial;
1884 if(nLayersRptTransaxial.size()>0 || nLayersRptAxial.size()>0 )
1885 nb_crystals_layer *= nLayersRptTransaxial[l] * nLayersRptAxial[l];
1887 nb_crystal_per_layer[l] = nb_crystals_layer;
1889 nCrystalsTot += nb_crystals_layer;
1896 Cout(
"-----------------------------------------------------------" << endl);
1897 Cout(
"ReadMacCylindrical()-> Information recovered from mac file:" << endl);
1898 Cout(
"-----------------------------------------------------------" << endl);
1899 Cout(
"Number of rsectors angular position: " << nRsectorsAngPos << endl);
1900 Cout(
"Number of axial rsectors: " << nRsectorsAxial << endl);
1901 Cout(
"Number of axial modules: " << nModulesAxial << endl);
1902 Cout(
"Number of transaxial modules: " << nModulesTransaxial << endl);
1903 Cout(
"Number of axial submodules: " << nSubmodulesAxial << endl);
1904 Cout(
"Number of transaxial submodules: " << nSubmodulesTransaxial << endl);
1905 Cout(
"Number of axial crystals: " << nCrystalsAxial << endl);
1906 Cout(
"Number of transaxial crystals: " << nCrystalsTransaxial << endl);
1909 Cout(
"Number of layers: " << (uint16_t)nLayers << endl);
1910 for(
int l=0 ; l<nLayers ; l++)
1911 Cout(
"Layer "<< l <<
" : Number of crystals: " << nb_crystal_per_layer[l] << endl);
1913 Cout(
"Total number of crystals (including layers): " << nCrystalsTot << endl);
1914 Cout(
"Acquisition start time (ms): " << start_time_ms << endl);
1915 Cout(
"Acquisition duration (ms): " << duration_ms << endl);
1916 Cout(
"-----------------------------------------------------------" << endl << endl);
1943 uint32_t &nCrystalsTot,
1944 uint32_t &nCrystalsAxial,
1945 uint32_t &nCrystalsTransaxial,
1946 uint32_t &nBlocksLine,
1947 uint32_t &nBlocksPerRing,
1948 uint32_t &start_time_ms,
1949 uint32_t &duration_ms,
1950 FLTNB &pet_coinc_window,
1954 vector<string> path_mac_files;
1955 path_mac_files.push_back(a_pathMac);
1958 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
1962 string block_name =
"block";
1963 string crystal_name =
"crystal";
1964 bool is_block_Y_axis =
false;
1969 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover aliases for the elements of the ecat !" << endl);
1975 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
1977 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
1980 double time_start=-1.,
1984 while(getline(mac_file, line))
1986 vector <string> values;
1989 kword =
"/gate/"+block_name+
"/placement/setTranslation";
1991 if (values.size()>0)
1993 FLTNB block_pos_X=0.,
1999 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2004 if(block_pos_Y!=0) is_block_Y_axis =
true;
2007 kword =
"/gate/"+block_name+
"/ring/setRepeatNumber";
2009 if (values.size()>0)
2013 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2018 kword =
"/gate/"+block_name+
"/linear/setRepeatNumber";
2020 if (values.size()>0)
2024 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2029 kword = is_block_Y_axis ?
2030 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
2031 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
2034 if (values.size()>0)
2038 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2043 kword =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
2045 if (values.size()>0)
2049 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2055 kword =
"/gate/application/setTimeStart";
2057 if (values.size()>0)
2061 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2066 if (values.size()>1)
2068 if(values[1] ==
"s") time_start *= 1000;
2071 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2073 start_time_ms = time_start;
2076 kword =
"/gate/application/setTimeStop";
2078 if (values.size()>0)
2082 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2087 if (values.size()>1)
2089 if(values[1] ==
"s") time_stop *= 1000;
2092 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2095 kword =
"/gate/application/addSlice";
2097 if (values.size()>0)
2099 double time_slice_tmp=0;
2103 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2108 if (values.size()>1)
2110 if(values[1] ==
"s") time_slice_tmp *= 1000;
2113 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2115 time_slices = time_slice_tmp;
2118 kword =
"/gate/digitizer/Coincidences/setWindow";
2120 if (values.size()>0)
2124 Cerr(
"***** dataConversionUtilities::readMacCylindrical()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2129 if (values.size()>1)
2131 if(values[1] ==
"ns") pet_coinc_window *= 1000.;
2132 else if (values[1] ==
"us") pet_coinc_window *= 1000000.;
2133 else if (values[1] ==
"ps") ;
2136 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> ERROR : can't read unit of '"<< kword <<
". Must be ns, ps or us !!!");
2142 Cerr(
"***** dataConversionUtilities::readMacCylindrical()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in ns");
2148 duration_ms = (time_slices>0) ?
2149 (uint32_t)(time_slices-time_start) :
2152 duration_ms = (time_start>=0 && time_stop>=0) ?
2153 (uint32_t)(time_stop-time_start) :
2160 nCrystalsTot = nCrystalsTransaxial * nCrystalsAxial
2161 * nBlocksLine * nBlocksPerRing;
2167 Cout(
"-----------------------------------------------------" << endl);
2168 Cout(
"ReadMacECAT()-> Information recovered from mac file:" << endl);
2169 Cout(
"-----------------------------------------------------" << endl);
2170 Cout(
"Number of blocks per ring: " << nBlocksPerRing << endl);
2171 Cout(
"Number of axial blocks: " << nBlocksLine << endl);
2172 Cout(
"Number of axial crystals: " << nCrystalsAxial << endl);
2173 Cout(
"Number of transaxial crystals: " << nCrystalsTransaxial << endl);
2174 Cout(
"Total number of crystals: " << nCrystalsTot << endl);
2175 Cout(
"Acquisition start time (ms): " << start_time_ms << endl);
2176 Cout(
"Acquisition duration (ms): " << duration_ms << endl);
2177 Cout(
"-----------------------------------------------------" << endl << endl);
2209 float_t &a_distToDetector,
2211 uint32_t &a_nPixAxl,
2212 uint32_t &a_nPixTrs,
2213 float_t &a_crystalSizeAxl,
2214 float_t &a_crystalSizeTrs,
2215 uint32_t &a_nProjectionsTot,
2216 uint32_t &a_nProjectionsByHead,
2217 float_t &a_head1stAngle,
2218 float_t &a_headAngPitch,
2219 float_t &a_headAngStepDeg,
2220 int &a_headRotDirection,
2221 uint32_t &a_start_time_ms,
2222 uint32_t &a_duration_ms,
2226 vector<string> path_mac_files;
2227 path_mac_files.push_back(a_pathMac);
2231 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
2235 string head_name =
"SPECThead";
2236 string crystal_name =
"crystal";
2237 string pixel_name =
"pixel";
2238 string head_orbit_name =
"";
2239 bool is_head_Y_axis =
false;
2244 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover aliases for the elements of the ecat !" << endl);
2249 double time_start=-1.,
2254 head_rot_speed =-1.;
2257 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
2259 ifstream mac_file(path_mac_files[f].c_str(), ios::in);
2263 while(getline(mac_file, line))
2265 vector <string> values;
2267 kword =
"/gate/"+head_name+
"/placement/setTranslation";
2269 if (values.size()>0)
2271 FLTNB head_pos_X=0.,
2277 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2282 if(head_pos_Y!=0) is_head_Y_axis =
true;
2284 a_distToDetector = is_head_Y_axis ? abs(head_pos_Y) : abs(head_pos_X) ;
2289 kword =
"/gate/"+head_name+
"/ring/setRepeatNumber";
2291 if (values.size()>0)
2295 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2300 kword =
"/gate/"+head_name+
"/ring/setFirstAngle";
2302 if (values.size()>0)
2306 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2311 kword =
"/gate/"+head_name+
"/ring/setAngularPitch";
2313 if (values.size()>0)
2317 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2322 kword =
"/gate/"+head_name+
"/moves/insert";
2324 if (values.size()>0)
2328 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2333 kword =
"/gate/"+head_name+
"/"+head_orbit_name+
"/setSpeed";
2335 if (values.size()>0)
2339 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2344 kword =
"/gate/"+head_name+
"/"+head_orbit_name+
"/setPoint2";
2346 if (values.size()>0)
2351 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
2359 kword = is_head_Y_axis ?
2360 "/gate/"+crystal_name+
"/geometry/setXLength":
2361 "/gate/"+crystal_name+
"/geometry/setYLength";
2364 if (values.size()>0)
2368 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2374 kword =
"/gate/"+crystal_name+
"/geometry/setZLength";
2376 if (values.size()>0)
2380 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2387 kword = is_head_Y_axis ?
2388 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberX":
2389 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberY";
2393 if (values.size()>0)
2397 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2402 kword =
"/gate/"+pixel_name+
"/cubicArray/setRepeatNumberZ";
2404 if (values.size()>0)
2408 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
2413 kword =
"/gate/application/setTimeStart";
2415 if (values.size()>0)
2419 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2424 if (values.size()>1)
2426 if(values[1] ==
"s") time_start *= 1000;
2429 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2431 a_start_time_ms = time_start;
2434 kword =
"/gate/application/setTimeSlice";
2436 if (values.size()>0)
2440 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2445 if (values.size()>1)
2447 if(values[1] ==
"s") time_slice *= 1000;
2450 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2452 time_slice_ms = time_slice;
2455 kword =
"/gate/application/setTimeStop";
2457 if (values.size()>0)
2461 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2466 if (values.size()>1)
2468 if(values[1] ==
"s") time_stop *= 1000;
2471 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2474 kword =
"/gate/application/addSlice";
2476 if (values.size()>0)
2478 double time_slice_tmp=0;
2482 Cerr(
"***** dataConversionUtilities::readMacECAT()->Error occurred while trying to get value from entry '"<< kword <<
"' in file " << path_mac_files[f] <<
"!");
2487 if (values.size()>1)
2489 if(values[1] ==
"s") time_slice_tmp *= 1000;
2492 Cerr(
"***** dataConversionUtilities::readMacECAT()-> WARNING : can't read unit of '"<< kword <<
". Assuming time in seconds");
2494 time_slices = time_slice_tmp;
2501 a_duration_ms = (time_slices>0) ?
2502 (uint32_t)(time_slices-time_start) :
2506 a_duration_ms = (time_start>=0 && time_stop>=0) ?
2507 (uint32_t)(time_stop-time_start) :
2512 a_nProjectionsByHead = a_duration_ms / time_slice_ms;
2513 a_nProjectionsTot = a_nHeads*a_nProjectionsByHead;
2516 a_headAngPitch = (a_headAngPitch<0) ?
2520 a_headAngStepDeg = head_rot_speed*time_slice_ms/1000.;
2522 if(head_rot_speed<0)
2524 Cerr(
"***** GetGATESystemType() -> Error couldn't find line '/gate/"+head_name+
"/"+head_orbit_name+
"/setSpeed' !" << endl);
2525 Cerr(
" This information is mandatory to compute the projection angle step." << endl);
2531 Cerr(
"***** GetGATESystemType() -> Error couldn't find line '/gate/application/setTimeSlice' !" << endl);
2532 Cerr(
" This information is mandatory to compute the projection angle step." << endl);
2536 if(a_duration_ms == 0)
2540 Cerr(
"***** GetGATESystemType() -> Error couldn't compute acquisition find line '/gate/application/setTimeStop' !" << endl);
2541 Cerr(
" This information is mandatory to compute the acquisition duration." << endl);
2546 Cerr(
"***** GetGATESystemType() -> Error couldn't compute acquisition find line '/gate/application/setTimeStart' !" << endl);
2547 Cerr(
" This information is mandatory to compute the acquisition duration." << endl);
2558 Cout(
"-----------------------------------------------------" << endl);
2559 Cout(
"ReadMacSPECT()-> Information recovered from mac file:" << endl);
2560 Cout(
"-----------------------------------------------------" << endl);
2561 Cout(
"Distance to detector: " << a_distToDetector << endl);
2562 Cout(
"Number of heads: " << a_nHeads << endl);
2563 Cout(
"Number of axial pixels: " << a_nPixAxl << endl);
2564 Cout(
"Number of transaxial pixels: " << a_nPixTrs << endl);
2565 Cout(
"Crystal axial size: " << a_crystalSizeAxl << endl);
2566 Cout(
"Crystal transaxial size: " << a_crystalSizeTrs << endl);
2567 Cout(
"Number of projections per head: " << a_nProjectionsByHead << endl);
2568 Cout(
"Total number of projections: " << a_nProjectionsTot << endl);
2569 Cout(
"Head(s) first transaxial angle: " << a_head1stAngle << endl);
2570 Cout(
"Head(s) angular pitch: " << a_headAngPitch << endl);
2571 Cout(
"Angular step between projections (deg): " << a_headAngStepDeg << endl);
2572 Cout(
"Rotation direction (0=CW, 1=CCW): " << a_headRotDirection << endl);
2573 Cout(
"Acquisition start time (ms): " << a_start_time_ms << endl);
2574 Cout(
"Acquisition duration (ms): " << a_duration_ms << endl);
2575 Cout(
"-----------------------------------------------------" << endl << endl);
2608 float_t &a_distToDetector,
2610 uint32_t &a_nPixAxl,
2611 uint32_t &a_nPixTrs,
2612 float_t &a_crystalSizeAxl,
2613 float_t &a_crystalSizeTrs,
2614 uint32_t &a_nProjectionsTot,
2615 uint32_t &a_nProjectionsByHead,
2616 float_t &a_head1stAngle,
2617 float_t &a_headAngPitchDeg,
2618 float_t &a_headAngStepDeg,
2619 int &a_headRotDirection,
2620 uint32_t &a_start_time_ms,
2621 uint32_t &a_duration_ms,
2628 key =
"matrix size [1]";
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 =
"matrix size [2]";
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 FLTNB size_pix_trs = 1.,
2647 key =
"scaling factor (mm/pixel) [1]";
2650 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2651 Cerr(
" Either key not found or conversion error" << endl);
2655 key =
"scaling factor (mm/pixel) [2]";
2658 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2659 Cerr(
" Either key not found or conversion error" << endl);
2663 key =
"total number of images";
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 =
"number of projections";
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 =
"number of detector heads";
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);
2687 key =
"study duration (sec)";
2690 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2691 Cerr(
" Either key not found or conversion error" << endl);
2695 a_duration_ms *= 1000;
2698 FLTNB size_crystal_X =0.,
2701 key =
"crystal x dimension (cm)";
2704 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2705 Cerr(
" Either key not found or conversion error" << endl);
2709 key =
"crystal y dimension (cm)";
2712 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2713 Cerr(
" Either key not found or conversion error" << endl);
2717 key =
"crystal z dimension (cm)";
2720 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2721 Cerr(
" Either key not found or conversion error" << endl);
2727 if(size_crystal_X>0 && size_crystal_Y>0)
2728 a_crystalSizeTrs = (size_crystal_X>size_crystal_Y) ? size_crystal_X*10. : size_crystal_Y*10.;
2729 a_crystalSizeAxl = (a_crystalSizeAxl>0) ? a_crystalSizeAxl*10. : a_crystalSizeAxl ;
2732 FLTNB head_pos_X =-1.,
2736 key =
"head x translation (cm)";
2739 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2740 Cerr(
" Either key not found or conversion error" << endl);
2744 key =
"head y translation (cm)";
2747 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2748 Cerr(
" Either key not found or conversion error" << endl);
2752 key =
"head z translation (cm)";
2755 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2756 Cerr(
" Either key not found or conversion error" << endl);
2761 if(head_pos_X > head_pos_Y)
2762 a_distToDetector = head_pos_X > head_pos_Z ? head_pos_X*10 : head_pos_Z*10;
2764 a_distToDetector = head_pos_Y > head_pos_Z ? head_pos_Y*10 : head_pos_Z*10;
2767 key =
"direction of rotation";
2771 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2772 Cerr(
" Either key not found or conversion error" << endl);
2780 key =
"start angle";
2783 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2784 Cerr(
" Either key not found or conversion error" << endl);
2788 key =
"extent of rotation";
2789 uint32_t extent_rotation =360;
2792 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2793 Cerr(
" Either key not found or conversion error" << endl);
2797 a_headAngStepDeg = (
FLTNB)extent_rotation / a_nProjectionsByHead;
2799 float_t first_angle = 0;
2800 float_t second_angle = extent_rotation;
2802 key =
"start angle";
2805 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2806 Cerr(
" Either key not found or conversion error" << endl);
2810 key =
"start angle";
2813 Cerr(
"***** castor-GATERootToCastor :: Error when trying to read key: '"<< key <<
"' in interfile : " << a_pathIntf <<
"!" << endl);
2814 Cerr(
" Either key not found or conversion error" << endl);
2818 a_headAngPitchDeg = second_angle - first_angle;
2843 string scanner_name =
GetFileFromPath(a_pathGeom.substr(0,a_pathGeom.find(
".geom")));
2844 double scanner_radius = 0.;
2845 uint32_t number_of_elements = 0;
2846 string description =
"PET system extracted from GATE macro: " + a_pathMac;
2849 string rsector_name =
"";
2850 uint32_t number_of_rsectors_ang = 1;
2851 uint32_t number_of_rsectors_axl = 1;
2852 double rsector_step_axl = 0.;
2853 double rsector_gap_axl = 0.;
2854 double rsector_first_angle = 0.;
2855 double rsector_angular_span = 360.;
2856 double rsector_pos_X = 0.;
2857 double rsector_pos_Y = 0.;
2858 uint32_t rsector_nb_zshifts = 0;
2859 vector <double> vec_rsector_Z_Shift;
2860 bool is_rsector_Y_axis =
false;
2861 double rsector_size_trs;
2862 double rsector_size_axl;
2865 string module_name =
"";
2866 uint32_t number_of_modules_trs = 1;
2867 uint32_t number_of_modules_axl = 1;
2868 double module_step_trs = 0.;
2869 double module_step_axl = 0.;
2870 double module_gap_trs = 0.;
2871 double module_gap_axl = 0.;
2872 double module_size_trs;
2873 double module_size_axl;
2876 string submodule_name =
"";
2877 uint32_t number_of_submodules_trs = 1;
2878 uint32_t number_of_submodules_axl = 1;
2879 double submodule_step_trs = 0.;
2880 double submodule_step_axl = 0.;
2881 double submodule_gap_trs = 0.;
2882 double submodule_gap_axl = 0.;
2883 double submodule_size_trs;
2884 double submodule_size_axl;
2887 string crystal_name =
"";
2888 uint32_t number_of_crystals_trs = 1;
2889 uint32_t number_of_crystals_axl = 1;
2890 double crystal_step_trs = 0.;
2891 double crystal_step_axl = 0.;
2892 double crystal_gap_trs = 0.;
2893 double crystal_gap_axl = 0.;
2894 double crystal_size_depth = 0.;
2895 double crystal_size_trs = 0.;
2896 double crystal_size_axl = 0.;
2900 uint16_t number_of_layers = 0;
2901 string n_layers =
"1";
2902 vector <uint32_t> number_of_lyr_elts_trs;
2903 vector <uint32_t> number_of_lyr_elts_axl;
2904 vector <uint32_t> number_of_lyr_elts_dph;
2906 vector <string> layers_names;
2907 vector <vector <double> > layers_positions;
2908 vector <double> layers_size_depth;
2909 vector <double> layers_size_trs;
2910 vector <double> layers_size_axl;
2912 vector <double> layers_step_trs;
2913 vector <double> layers_step_axl;
2914 vector <double> layers_step_dph;
2917 uint32_t voxels_number_trs;
2918 uint32_t voxels_number_axl;
2921 double mean_depth_of_interaction = -1.;
2922 double min_angle_diff = 0.;
2925 int mod_linear_nb = 0;
2926 int subm_linear_nb = 0;
2927 int cry_linear_nb = 0;
2928 vector <int> layer_linear_nb;
2932 vector <string> vec_scanner_radius;
2935 vector <string> vec_number_of_rsectors_ang;
2936 vector <string> vec_number_of_rsectors_axl;
2937 vector <string> vec_rsector_gap_axl;
2938 vector <string> vec_rsector_first_angle;
2942 vector <string> vec_number_of_modules_trs;
2943 vector <string> vec_number_of_modules_axl;
2944 vector <string> vec_module_gap_trs;
2945 vector <string> vec_module_gap_axl;
2948 vector <string> vec_number_of_submodules_trs;
2949 vector <string> vec_number_of_submodules_axl;
2950 vector <string> vec_submodule_gap_trs;
2951 vector <string> vec_submodule_gap_axl;
2954 vector <string> vec_number_of_crystals_trs;
2955 vector <string> vec_number_of_crystals_axl;
2956 vector <string> vec_crystal_gap_trs;
2957 vector <string> vec_crystal_gap_axl;
2960 vector <string> vec_mean_depth_of_interaction;
2961 vector <string> vec_min_angle_diff;
2963 vector<string> path_mac_files;
2964 path_mac_files.push_back(a_pathMac);
2969 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover paths to GATE macro files !" << endl);
2974 if(
GetGATEAliasesCylindrical(path_mac_files, rsector_name, module_name, submodule_name, crystal_name, layers_names, 2) )
2976 Cerr(
"***** GetGATESystemType() ->Error occurred when trying to recover aliases for the elements of the cylindricalPET !" << endl);
2981 n_layers = layers_names.size();
2985 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
2987 ifstream systemMac(path_mac_files[f].c_str(), ios::in);
2991 while(getline(systemMac, line))
2993 vector <string> values;
3000 entry =
"/gate/"+rsector_name+
"/placement/setTranslation";
3004 if (values.size()>0)
3009 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3015 if(rsector_pos_X!=0 && rsector_pos_Y !=0)
3017 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3018 Cerr(
" Rsector cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
3023 if(rsector_pos_Y!=0) is_rsector_Y_axis =
true;
3026 scanner_radius += is_rsector_Y_axis ? abs(rsector_pos_Y) : abs(rsector_pos_X) ;
3054 entry = is_rsector_Y_axis ?
3055 "/gate/"+rsector_name+
"/geometry/setXLength":
3056 "/gate/"+rsector_name+
"/geometry/setYLength";
3059 if (values.size()>0)
3063 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3072 entry =
"/gate/"+rsector_name+
"/ring/setModuloNumber";
3074 if (values.size()>0)
3078 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3083 entry =
"/gate/"+rsector_name+
"/ring/setRepeatNumber";
3085 if (values.size()>0)
3089 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3104 entry =
"/gate/"+rsector_name+
"/linear/setRepeatNumber";
3106 if (values.size()>0)
3110 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3118 entry =
"/gate/"+rsector_name+
"/linear/setRepeatVector";
3120 if (values.size()>0)
3124 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3134 entry = is_rsector_Y_axis ?
3135 "/gate/"+rsector_name+
"/cubicArray/setRepeatNumberX":
3136 "/gate/"+rsector_name+
"/cubicArray/setRepeatNumberY";
3139 if (values.size()>0)
3141 uint32_t number_of_rsectors_trs;
3145 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3152 if(number_of_rsectors_trs>1)
3154 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Error while trying to parse line: " << line<< endl);
3155 Cerr(
" The GATE system contains more than one 'transaxial' rsector " << endl);
3156 Cerr(
" The current implementation does not support such cylindricalPET model" << endl);
3157 Cerr(
" Manual implementation of the system is required (ex: model the transaxial rsectors as modules)" << endl);
3163 entry =
"/gate/"+rsector_name+
"/cubicArray/setRepeatNumberZ";
3166 if (values.size()>0)
3170 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3176 entry =
"/gate/"+rsector_name+
"/cubicArray/setRepeatVector";
3178 if (values.size()>0)
3182 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3190 entry =
"/gate/"+rsector_name+
"/geometry/setZLength";
3192 if (values.size()>0)
3196 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3203 entry =
"/gate/"+rsector_name+
"/ring/setFirstAngle";
3205 if (values.size()>0)
3209 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3214 entry =
"/gate/"+rsector_name+
"/ring/setAngularSpan";
3216 if (values.size()>0)
3220 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3226 for (
int i=1; i <8; i++)
3228 entry =
"/gate/"+rsector_name+
"/ring/setZShift"+
toString(i);
3230 if (values.size()>0)
3235 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3239 vec_rsector_Z_Shift.push_back(zshift);
3248 entry =
"/gate/"+module_name+
"/placement/setTranslation";
3251 FLTNB module_pos_X =0.,
3255 if (values.size()>0)
3260 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3266 if(module_pos_X!=0 && module_pos_Y !=0)
3268 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3269 Cerr(
" Module cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
3274 scanner_radius += is_rsector_Y_axis ? module_pos_Y : module_pos_X ;
3279 entry = is_rsector_Y_axis ?
3280 "/gate/"+module_name+
"/cubicArray/setRepeatNumberX":
3281 "/gate/"+module_name+
"/cubicArray/setRepeatNumberY";
3284 if (values.size()>0)
3288 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3296 entry =
"/gate/"+module_name+
"/cubicArray/setRepeatNumberZ";
3299 if (values.size()>0)
3303 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3309 entry = is_rsector_Y_axis ?
3310 "/gate/"+module_name+
"/geometry/setXLength":
3311 "/gate/"+module_name+
"/geometry/setYLength";
3314 if (values.size()>0)
3318 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3324 entry =
"/gate/"+module_name+
"/geometry/setZLength";
3326 if (values.size()>0)
3330 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3335 entry =
"/gate/"+module_name+
"/cubicArray/setRepeatVector";
3337 if (values.size()>0)
3339 string trs_step = is_rsector_Y_axis ?
3346 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3355 entry =
"/gate/"+module_name+
"/linear/setRepeatNumber";
3358 if (values.size()>0)
3363 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3369 entry =
"/gate/"+module_name+
"/cubicArray/setRepeatNumber ";
3372 if (values.size()>0)
3377 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3384 entry =
"/gate/"+module_name+
"/linear/setRepeatVector";
3386 if (values.size()>0)
3388 string trs_step = is_rsector_Y_axis ?
3395 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3400 if(module_step_trs > 0)
3401 number_of_modules_trs = mod_linear_nb;
3402 else if (module_step_axl > 0)
3403 number_of_modules_axl = mod_linear_nb;
3406 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);
3415 entry =
"/gate/"+module_name+
"/cubicArray/setRepeatVector";
3417 if (values.size()>0)
3419 string trs_step = is_rsector_Y_axis ?
3426 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3431 if(module_step_trs > 0)
3432 number_of_modules_trs = mod_linear_nb;
3433 else if (module_step_axl > 0)
3434 number_of_modules_axl = mod_linear_nb;
3437 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);
3447 entry =
"/gate/"+submodule_name+
"/placement/setTranslation";
3450 FLTNB submodule_pos_X =0.,
3451 submodule_pos_Y =0.;
3454 if (values.size()>0)
3459 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3465 if(submodule_pos_X!=0 && submodule_pos_Y !=0)
3467 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3468 Cerr(
" Submodule cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
3473 scanner_radius += is_rsector_Y_axis ? submodule_pos_Y : submodule_pos_X ;
3478 entry = is_rsector_Y_axis ?
3479 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberX":
3480 "/gate/"+submodule_name+
"/cubicArray/setRepeatNumberY";
3484 if (values.size()>0)
3488 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3493 entry =
"/gate/"+submodule_name+
"/cubicArray/setRepeatNumberZ";
3495 if (values.size()>0)
3499 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3507 entry = is_rsector_Y_axis ?
3508 "/gate/"+submodule_name+
"/geometry/setXLength":
3509 "/gate/"+submodule_name+
"/geometry/setYLength";
3512 if (values.size()>0)
3516 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3521 entry =
"/gate/"+submodule_name+
"/geometry/setZLength";
3523 if (values.size()>0)
3527 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3532 entry =
"/gate/"+submodule_name+
"/cubicArray/setRepeatVector";
3534 if (values.size()>0)
3536 string trs_step = is_rsector_Y_axis ?
3543 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3551 entry =
"/gate/"+submodule_name+
"/linear/setRepeatNumber";
3554 if (values.size()>0)
3559 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3565 entry =
"/gate/"+submodule_name+
"/cubicArray/setRepeatNumber ";
3568 if (values.size()>0)
3573 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3579 entry =
"/gate/"+submodule_name+
"/linear/setRepeatVector";
3581 if (values.size()>0)
3583 string trs_step = is_rsector_Y_axis ?
3590 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3595 if(submodule_step_trs > 0)
3596 number_of_submodules_trs = subm_linear_nb;
3597 else if (submodule_step_axl > 0)
3598 number_of_submodules_axl = subm_linear_nb;
3601 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);
3608 if(subm_linear_nb>0)
3610 entry =
"/gate/"+submodule_name+
"/cubicArray/setRepeatVector";
3612 if (values.size()>0)
3614 string trs_step = is_rsector_Y_axis ?
3621 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3627 if(submodule_step_trs > 0)
3628 number_of_submodules_trs = subm_linear_nb;
3629 else if (submodule_step_axl > 0)
3630 number_of_submodules_axl = subm_linear_nb;
3633 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);
3647 entry =
"/gate/"+crystal_name+
"/placement/setTranslation";
3650 FLTNB crystal_pos_X =0.,
3654 if (values.size()>0)
3659 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3665 if(crystal_pos_X!=0 && crystal_pos_Y !=0)
3667 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3668 Cerr(
" Crystal cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
3673 scanner_radius += is_rsector_Y_axis ? crystal_pos_Y : crystal_pos_X ;
3678 entry = is_rsector_Y_axis ?
3679 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
3680 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
3683 if (values.size()>0)
3687 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3693 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
3695 if (values.size()>0)
3699 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3705 entry =
"/gate/"+crystal_name+
"/geometry/setXLength";
3707 if (values.size()>0)
3712 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3716 if (is_rsector_Y_axis)
3717 crystal_size_trs = x_length;
3719 crystal_size_depth = x_length;
3722 entry =
"/gate/"+crystal_name+
"/geometry/setYLength";
3724 if (values.size()>0)
3729 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3733 if (is_rsector_Y_axis)
3734 crystal_size_depth = y_length;
3736 crystal_size_trs = y_length;
3740 entry =
"/gate/"+crystal_name+
"/geometry/setZLength";
3742 if (values.size()>0)
3746 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3751 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatVector";
3753 if (values.size()>0)
3755 string trs_step = is_rsector_Y_axis ?
3762 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3768 entry =
"/gate/"+crystal_name+
"/linear/setRepeatNumber";
3771 if (values.size()>0)
3776 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3782 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumber ";
3785 if (values.size()>0)
3790 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3796 entry =
"/gate/"+crystal_name+
"/linear/setRepeatVector";
3798 if (values.size()>0)
3800 string trs_step = is_rsector_Y_axis ?
3807 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3812 if(crystal_step_trs > 0)
3813 number_of_crystals_trs = cry_linear_nb;
3814 else if (crystal_step_axl > 0)
3815 number_of_crystals_axl = cry_linear_nb;
3818 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);
3827 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatVector";
3829 if (values.size()>0)
3831 string trs_step = is_rsector_Y_axis ?
3838 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3843 if(crystal_step_trs > 0)
3844 number_of_crystals_trs = cry_linear_nb;
3845 else if (crystal_step_axl > 0)
3846 number_of_crystals_axl = cry_linear_nb;
3849 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);
3858 entry =
"/gate/"+crystal_name+
"/daughters/name";
3860 if (values.size()>0)
3862 layers_names.push_back(values[0]);
3867 for (
int i=0; i < number_of_layers; i++)
3870 entry =
"/gate/"+layers_names[i]+
"/placement/setTranslation";
3873 if (values.size()>0)
3875 vector<double> layer_pos;
3876 for(
int d=0 ; d<3 ; d++)
3881 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3884 layer_pos.push_back(pos);
3887 if(is_rsector_Y_axis)
3889 double pos = layer_pos[1];
3890 layer_pos[1] = layer_pos[0];
3894 layers_positions.push_back(layer_pos);
3899 entry =
"/gate/"+layers_names[i]+
"/geometry/setXLength";
3902 if (values.size()>0)
3907 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3911 if (is_rsector_Y_axis)
3912 layers_size_trs.push_back(xlength);
3914 layers_size_depth.push_back(xlength);
3918 entry =
"/gate/"+layers_names[i]+
"/geometry/setYLength";
3920 if (values.size()>0)
3925 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3928 if (is_rsector_Y_axis)
3929 layers_size_depth.push_back(ylength);
3931 layers_size_trs.push_back(ylength);
3934 entry =
"/gate/"+layers_names[i]+
"/geometry/setZLength";
3936 if (values.size()>0)
3941 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3944 layers_size_axl.push_back(zlength);
3950 entry = is_rsector_Y_axis ?
3951 "/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberX":
3952 "/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberY";
3955 if (values.size()>0)
3960 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3964 number_of_lyr_elts_trs.push_back(step_trs);
3967 entry = is_rsector_Y_axis ?
3968 "/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberY":
3969 "/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberX";
3972 if (values.size()>0)
3977 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3981 number_of_lyr_elts_dph.push_back(step_dph);
3985 entry =
"/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumberZ";
3987 if (values.size()>0)
3992 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
3995 number_of_lyr_elts_axl.push_back(step_axl);
3998 entry =
"/gate/"+layers_names[i]+
"/cubicArray/setRepeatVector";
4000 if (values.size()>0)
4002 string trs_step = is_rsector_Y_axis ?
4006 string dph_step = is_rsector_Y_axis ?
4010 double step_trs=0., step_axl=0., step_dph=0.;
4015 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4021 layers_step_trs.push_back(step_trs);
4023 else if (step_axl > 0)
4025 layers_step_axl.push_back(step_axl);
4027 else if (step_dph > 0)
4028 layers_step_dph.push_back(step_dph);
4031 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);
4038 entry =
"/gate/"+layers_names[i]+
"/linear/setRepeatNumber";
4041 if (values.size()>0)
4046 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4049 layer_linear_nb.push_back(nb);
4053 entry =
"/gate/"+layers_names[i]+
"/cubicArray/setRepeatNumber ";
4056 if (values.size()>0)
4061 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4064 layer_linear_nb.push_back(nb);
4068 entry =
"/gate/"+layers_names[i]+
"/linear/setRepeatVector";
4070 if (values.size()>0)
4072 string trs_step = is_rsector_Y_axis ?
4076 string dph_step = is_rsector_Y_axis ?
4080 double step_trs=0., step_axl=0., step_dph=0.;
4085 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4091 number_of_lyr_elts_trs.push_back(layer_linear_nb[ i ]);
4092 layers_step_trs.push_back(step_trs);
4094 else if (step_axl > 0)
4096 number_of_lyr_elts_axl.push_back(layer_linear_nb[ i ]);
4097 layers_step_axl.push_back(step_axl);
4099 else if (step_dph > 0)
4101 number_of_lyr_elts_dph.push_back(layer_linear_nb[ i ]);
4102 layers_step_dph.push_back(step_dph);
4106 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);
4115 if((
int)layer_linear_nb.size()>i && layer_linear_nb[ i ]>0)
4117 entry =
"/gate/"+layers_names[i]+
"/cubicArray/setRepeatVector";
4119 if (values.size()>0)
4121 string trs_step = is_rsector_Y_axis ?
4125 string dph_step = is_rsector_Y_axis ?
4130 double step_trs=0., step_axl=0., step_dph=0.;
4135 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4142 number_of_lyr_elts_trs.push_back(layer_linear_nb[ i ]);
4143 layers_step_trs.push_back(step_trs);
4145 else if (step_axl > 0)
4147 number_of_lyr_elts_axl.push_back(layer_linear_nb[ i ]);
4148 layers_step_axl.push_back(step_axl);
4150 else if (step_dph > 0)
4152 number_of_lyr_elts_dph.push_back(layer_linear_nb[ i ]);
4153 layers_step_dph.push_back(step_dph);
4157 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);
4166 entry =
"/gate/digitizer/Coincidences/minSectorDifference";
4168 if (values.size()>0)
4170 FLTNB min_sector_diff= 0.;
4174 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4178 min_angle_diff = 360./number_of_rsectors_ang*min_sector_diff;
4186 if (number_of_lyr_elts_dph.size() > 0)
4189 if (number_of_layers>1)
4192 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conflicting declaration of layers using both crystal/daughter command and a depth level with a linear or cubic array repeater. Only one approach can be managed"<< endl);
4199 for (
size_t l=1 ; l<number_of_lyr_elts_dph[ 0 ] ; l++)
4201 if( number_of_lyr_elts_trs.size() > 0 ) number_of_lyr_elts_trs.push_back( number_of_lyr_elts_trs[ 0 ] );
4202 if( number_of_lyr_elts_axl.size() > 0 ) number_of_lyr_elts_axl.push_back( number_of_lyr_elts_axl[ 0 ] );
4204 if( layers_size_depth.size() > 0 ) layers_size_depth.push_back( layers_size_depth[ 0 ] );
4205 if( layers_size_trs.size() > 0 ) layers_size_trs.push_back( layers_size_trs[ 0 ] );
4206 if( layers_size_axl.size() > 0 ) layers_size_axl.push_back( layers_size_axl[ 0 ] );
4208 if( layers_step_trs.size() > 0 ) layers_step_trs.push_back( layers_step_trs[ 0 ] );
4209 if( layers_step_axl.size() > 0 ) layers_step_axl.push_back( layers_step_axl[ 0 ] );
4212 vector<double> layer_pos;
4213 layer_pos.push_back(layers_positions[ 0 ][ 0 ] + l*layers_step_dph[ 0 ]);
4215 layers_positions.push_back(layer_pos);
4218 number_of_layers = number_of_lyr_elts_dph[ 0 ];
4223 if(number_of_layers == 0)
4225 number_of_elements = number_of_rsectors_ang
4226 * number_of_rsectors_axl
4227 * number_of_modules_trs
4228 * number_of_modules_axl
4229 * number_of_submodules_trs
4230 * number_of_submodules_axl
4231 * number_of_crystals_trs
4232 * number_of_crystals_axl;
4235 for(
int l=0 ; l<number_of_layers ; l++)
4237 int32_t nb_crystals_layer = number_of_rsectors_ang
4238 * number_of_rsectors_axl
4239 * number_of_modules_trs
4240 * number_of_modules_axl
4241 * number_of_submodules_trs
4242 * number_of_submodules_axl
4243 * number_of_crystals_trs
4244 * number_of_crystals_axl;
4247 if(number_of_lyr_elts_trs.size()>0 || number_of_lyr_elts_axl.size()>0 )
4248 nb_crystals_layer *= number_of_lyr_elts_trs[l] * number_of_lyr_elts_axl[l];
4250 number_of_elements += nb_crystals_layer;
4256 if (crystal_step_axl - crystal_size_axl >= 0)
4257 crystal_gap_axl = crystal_step_axl - crystal_size_axl;
4259 if (crystal_step_trs - crystal_size_trs >= 0)
4260 crystal_gap_trs = crystal_step_trs - crystal_size_trs;
4263 submodule_size_axl = crystal_size_axl*number_of_crystals_axl + crystal_gap_axl*(number_of_crystals_axl-1);
4264 submodule_size_trs = crystal_size_trs*number_of_crystals_trs + crystal_gap_trs*(number_of_crystals_trs-1);
4267 if (submodule_step_axl - submodule_size_axl >= 0)
4268 submodule_gap_axl = submodule_step_axl - submodule_size_axl;
4270 if (submodule_step_trs - submodule_size_trs >= 0)
4271 submodule_gap_trs = submodule_step_trs - submodule_size_trs;
4274 module_size_axl = submodule_size_axl*number_of_submodules_axl + submodule_gap_axl*(number_of_submodules_axl-1);
4275 module_size_trs = submodule_size_trs*number_of_submodules_trs + submodule_gap_trs*(number_of_submodules_trs-1);
4278 if (module_step_axl - module_size_axl >= 0)
4279 module_gap_axl = module_step_axl - module_size_axl;
4281 if (module_step_trs - module_size_trs >= 0)
4282 module_gap_trs = module_step_trs - module_size_trs;
4285 rsector_size_axl = module_size_axl*number_of_modules_axl + module_gap_axl*(number_of_modules_axl-1);
4286 rsector_size_trs = module_size_trs*number_of_modules_trs + module_gap_trs*(number_of_modules_trs-1);
4290 if (rsector_step_axl - rsector_size_axl >= 0)
4291 rsector_gap_axl = rsector_step_axl - rsector_size_axl;
4295 fov_axl = rsector_size_axl * number_of_rsectors_axl
4296 + (number_of_rsectors_axl-1)*rsector_gap_axl;
4300 voxels_number_axl = ( number_of_crystals_axl
4301 * number_of_submodules_axl
4302 * number_of_modules_axl
4303 * number_of_rsectors_axl )
4307 fov_trs = (2*scanner_radius ) / 1.5;
4311 voxels_number_trs = ( number_of_crystals_trs
4312 * number_of_submodules_trs
4313 * number_of_modules_trs
4314 * number_of_rsectors_ang )
4320 rsector_first_angle -= round(atan2f(rsector_pos_X , rsector_pos_Y) * 180. / M_PI);
4323 if (number_of_layers > 0)
4325 for (uint16_t l=0; l < number_of_layers ; l++)
4328 double rad = scanner_radius;
4329 if (layers_positions.size()>l) rad += layers_positions[ l ][ 0 ];
4330 if (layers_size_depth.size()>l) rad -= layers_size_depth[ l ] / 2.;
4331 vec_scanner_radius.push_back(
toString( rad ) );
4334 vec_number_of_rsectors_ang.push_back(
toString(number_of_rsectors_ang) );
4335 vec_number_of_rsectors_axl.push_back(
toString(number_of_rsectors_axl) );
4336 vec_rsector_gap_axl.push_back(
toString(rsector_gap_axl) );
4337 vec_rsector_first_angle.push_back(
toString(rsector_first_angle) );
4340 vec_number_of_modules_trs.push_back(
toString(number_of_modules_trs) );
4341 vec_number_of_modules_axl.push_back(
toString(number_of_modules_axl) );
4342 vec_module_gap_trs.push_back(
toString(module_gap_trs) );
4343 vec_module_gap_axl.push_back(
toString(module_gap_axl) );
4346 vec_number_of_submodules_trs.push_back(
toString(number_of_submodules_trs) );
4347 vec_number_of_submodules_axl.push_back(
toString(number_of_submodules_axl) );
4348 vec_submodule_gap_trs.push_back(
toString(submodule_gap_trs) );
4349 vec_submodule_gap_axl.push_back(
toString(submodule_gap_axl) );
4352 uint32_t nb_tot_trs_cry = (number_of_lyr_elts_trs.size()>0) ?
4353 number_of_lyr_elts_trs[l]*number_of_crystals_trs :
4354 number_of_crystals_trs ;
4356 uint32_t nb_tot_axl_cry = (number_of_lyr_elts_axl.size()>0) ?
4357 number_of_lyr_elts_axl[l]*number_of_crystals_axl :
4358 number_of_crystals_axl ;
4360 vec_number_of_crystals_trs.push_back(
toString(nb_tot_trs_cry) );
4361 vec_number_of_crystals_axl.push_back(
toString(nb_tot_axl_cry) );
4366 if(layers_step_trs.size()>0 ||
4367 layers_step_axl.size()>0)
4369 if (layers_step_trs[l] - layers_size_trs[l] >= 0)
4370 crystal_gap_trs = layers_step_trs[l] - layers_size_trs[l];
4372 if (layers_step_axl[l] - layers_size_axl[l] >= 0)
4373 crystal_gap_axl = layers_step_axl[l] - layers_size_axl[l];
4376 vec_crystal_gap_trs.push_back(
toString(crystal_gap_trs) );
4377 vec_crystal_gap_axl.push_back(
toString(crystal_gap_axl) );
4380 vec_mean_depth_of_interaction.push_back(
toString(mean_depth_of_interaction) );
4381 vec_min_angle_diff.push_back(
toString(min_angle_diff) );
4387 layers_size_depth.push_back( crystal_size_depth );
4388 layers_size_trs.push_back( crystal_size_trs );
4389 layers_size_axl.push_back( crystal_size_axl );
4393 vec_scanner_radius.push_back(
toString(scanner_radius - crystal_size_depth/2) );
4396 vec_number_of_rsectors_ang.push_back(
toString(number_of_rsectors_ang) );
4397 vec_number_of_rsectors_axl.push_back(
toString(number_of_rsectors_axl) );
4398 vec_rsector_gap_axl.push_back(
toString(rsector_gap_axl) );
4399 vec_rsector_first_angle.push_back(
toString(rsector_first_angle) );
4402 vec_number_of_modules_trs.push_back(
toString(number_of_modules_trs) );
4403 vec_number_of_modules_axl.push_back(
toString(number_of_modules_axl) );
4404 vec_module_gap_trs.push_back(
toString(module_gap_trs) );
4405 vec_module_gap_axl.push_back(
toString(module_gap_axl) );
4408 vec_number_of_submodules_trs.push_back(
toString(number_of_submodules_trs) );
4409 vec_number_of_submodules_axl.push_back(
toString(number_of_submodules_axl) );
4410 vec_submodule_gap_trs.push_back(
toString(submodule_gap_trs) );
4411 vec_submodule_gap_axl.push_back(
toString(submodule_gap_axl) );
4414 vec_number_of_crystals_trs.push_back(
toString(number_of_crystals_trs) );
4415 vec_number_of_crystals_axl.push_back(
toString(number_of_crystals_axl) );
4416 vec_crystal_gap_trs.push_back(
toString(crystal_gap_trs) );
4417 vec_crystal_gap_axl.push_back(
toString(crystal_gap_axl) );
4420 vec_mean_depth_of_interaction.push_back(
toString(mean_depth_of_interaction) );
4421 vec_min_angle_diff.push_back(
toString(min_angle_diff) );
4424 number_of_layers = 1;
4428 ofstream fileGeom(a_pathGeom.c_str(), ios::out | ios::trunc);
4431 fileGeom <<
"# comments" << endl;
4432 fileGeom <<
"# Y _________ "<< endl;
4433 fileGeom <<
"# | / _ \\ \\ "<< endl;
4434 fileGeom <<
"# | | / \\ | |"<< endl;
4435 fileGeom <<
"# |_____ Z | | | | |"<< endl;
4436 fileGeom <<
"# \\ | | | | |" << endl;
4437 fileGeom <<
"# \\ | \\_/ | |" << endl;
4438 fileGeom <<
"# X \\___/_____/" << endl;
4439 fileGeom <<
"# Left-handed axis orientation"<< endl;
4440 fileGeom <<
"# scanner axis is z" << endl;
4441 fileGeom <<
"# positions in millimeters"<< endl;
4442 fileGeom <<
"# Use comma without space as separator in the tables." << endl;
4444 fileGeom <<
""<< endl;
4447 fileGeom <<
"# MANDATORY FIELDS"<< endl;
4448 fileGeom <<
"modality : " << modality << endl;
4449 fileGeom <<
"scanner name : " << scanner_name << endl;
4450 fileGeom <<
"number of elements : " << number_of_elements << endl;
4451 fileGeom <<
"number of layers : " << number_of_layers << endl;
4452 fileGeom <<
"" << endl;
4453 fileGeom <<
"voxels number transaxial : " << voxels_number_trs << endl;
4454 fileGeom <<
"voxels number axial : " << voxels_number_axl << endl;
4456 fileGeom <<
"field of view transaxial : " << fov_trs << endl;
4457 fileGeom <<
"field of view axial : " << fov_axl << endl << endl;
4458 fileGeom <<
"description : " << description << endl;
4459 fileGeom <<
"" << endl;
4460 WriteVector(fileGeom,
"scanner radius : ",vec_scanner_radius);
4461 WriteVector(fileGeom,
"number of rsectors : ",vec_number_of_rsectors_ang);
4462 WriteVector(fileGeom,
"number of crystals transaxial : ",vec_number_of_crystals_trs);
4463 WriteVector(fileGeom,
"number of crystals axial : ",vec_number_of_crystals_axl);
4464 fileGeom <<
""<< endl;
4465 WriteVector(fileGeom,
"crystals size depth : ", layers_size_depth);
4466 WriteVector(fileGeom,
"crystals size transaxial : ", layers_size_trs);
4467 WriteVector(fileGeom,
"crystals size axial : ", layers_size_axl);
4468 fileGeom <<
""<< endl;
4469 fileGeom <<
""<< endl;
4472 fileGeom <<
"# OPTIONAL FIELDS"<< endl;
4473 WriteVector(fileGeom,
"rsectors first angle : ",vec_rsector_first_angle);
4474 WriteVector(fileGeom,
"number of rsectors axial : ",vec_number_of_rsectors_axl);
4475 WriteVector(fileGeom,
"rsector gap axial : ",vec_rsector_gap_axl);
4476 WriteVector(fileGeom,
"number of modules transaxial : ",vec_number_of_modules_trs);
4477 WriteVector(fileGeom,
"number of modules axial : ",vec_number_of_modules_axl);
4478 WriteVector(fileGeom,
"module gap transaxial : ",vec_module_gap_trs);
4479 WriteVector(fileGeom,
"module gap axial : ",vec_module_gap_axl);
4480 WriteVector(fileGeom,
"number of submodules transaxial : ",vec_number_of_submodules_trs);
4481 WriteVector(fileGeom,
"number of submodules axial : ",vec_number_of_submodules_axl);
4482 WriteVector(fileGeom,
"submodule gap transaxial : ",vec_submodule_gap_trs);
4483 WriteVector(fileGeom,
"submodule gap axial : ",vec_submodule_gap_axl);
4484 WriteVector(fileGeom,
"crystal gap transaxial : ",vec_crystal_gap_trs);
4485 WriteVector(fileGeom,
"crystal gap axial : ",vec_crystal_gap_axl);
4486 WriteVector(fileGeom,
"mean depth of interaction : ", vec_mean_depth_of_interaction);
4487 fileGeom <<
"rotation direction : CCW " << endl;
4488 fileGeom <<
""<< endl;
4491 if(min_angle_diff > 0.) fileGeom <<
"min angle difference : " << min_angle_diff << endl;
4494 if(rsector_angular_span >= 360.0005 ||
4495 rsector_angular_span <= 359.9995 )
4497 rsector_angular_span *= (double)number_of_rsectors_ang/(
double)(number_of_rsectors_ang-1);
4498 fileGeom <<
"rsectors angular span : " << rsector_angular_span << endl;
4501 if(rsector_nb_zshifts > 0) fileGeom <<
"rsectors nbZShift :" << rsector_nb_zshifts << endl;
4502 if(!vec_rsector_Z_Shift.empty())
WriteVector(fileGeom,
"rsectors ZShift : ", vec_rsector_Z_Shift);
4506 cout <<
"Output geom file written at :" << a_pathGeom << endl;
4510 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Couldn't open geom file for writing "<< a_pathGeom <<
" !" << endl);
4538 string scanner_name =
GetFileFromPath(a_pathGeom.substr(0,a_pathGeom.find_first_of(
".geom")));
4539 double scanner_radius = 0.;
4540 uint32_t number_of_elements = 0;
4541 string description =
"ECAT system extracted from GATE macro: " + a_pathMac;
4544 string block_name =
"block";
4545 uint32_t number_of_blocks = 1;
4546 uint32_t number_of_blocks_trs = 1;
4547 uint32_t number_of_blocks_axl = 1;
4548 double block_step_trs = 0.;
4549 double block_step_axl = 0.;
4550 double block_gap_trs = 0.;
4551 double block_gap_axl = 0.;
4552 double block_size_Y;
4553 double block_size_Z;
4554 double block_pos_X = 0.;
4555 double block_pos_Y = 0.;
4556 double block_first_angle = 0.;
4557 double block_angular_span = 360.;
4558 uint32_t block_nb_zshifts = 0;
4559 vector <double> vec_block_Z_Shift;
4560 bool is_block_Y_axis =
false;
4565 string crystal_name =
"crystal";
4566 uint32_t number_of_crystals_trs = 1;
4567 uint32_t number_of_crystals_axl = 1;
4568 double crystal_step_trs = 0.;
4569 double crystal_step_axl = 0.;
4570 double crystal_gap_trs = 0.;
4571 double crystal_gap_axl = 0.;
4572 double crystal_size_depth = 0.;
4573 double crystal_size_trs = 0.;
4574 double crystal_size_axl = 0.;
4577 uint32_t voxels_number_trs;
4578 uint32_t voxels_number_axl;
4581 double min_angle_diff = 0.;
4583 vector<string> path_mac_files;
4584 path_mac_files.push_back(a_pathMac);
4589 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()->Error occurred when trying to recover paths to GATE macro files !" << endl);
4597 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()->Error occurred when trying to recover aliases for the elements of the ecat !" << endl);
4603 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
4605 ifstream systemMac(path_mac_files[f].c_str(), ios::in);
4608 while(getline(systemMac, line))
4612 vector <string> values;
4616 entry =
"/gate/"+block_name+
"/placement/setTranslation";
4618 if (values.size()>0)
4623 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4629 if(block_pos_X!=0 && block_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);
4637 if(block_pos_Y!=0) is_block_Y_axis =
true;
4639 scanner_radius += is_block_Y_axis ? abs(block_pos_Y) : abs(block_pos_X) ;
4666 entry =
"/gate/"+block_name+
"/geometry/setZLength";
4668 if (values.size()>0)
4672 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4676 voxels_number_axl = fov_axl/4 + 1;
4681 entry =
"/gate/"+block_name+
"/ring/setRepeatNumber";
4683 if (values.size()>0)
4687 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4693 entry =
"/gate/"+block_name+
"/ring/setFirstAngle";
4695 if (values.size()>0)
4699 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4705 entry =
"/gate/"+block_name+
"/ring/setAngularSpan";
4707 if (values.size()>0)
4711 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4716 entry =
"/gate/"+block_name+
"/ring/setModuloNumber";
4718 if (values.size()>0)
4722 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4727 for (
int i=1; i<8; i++)
4729 entry =
"/gate/"+block_name+
"/ring/setZShift"+
toString(i);
4731 if (values.size()>0)
4736 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4739 vec_block_Z_Shift.push_back(zshift);
4747 entry =
"/gate/"+block_name+
"/linear/setRepeatNumber";
4749 if (values.size()>0)
4753 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4759 entry =
"/gate/"+block_name+
"/linear/setRepeatVector";
4761 if (values.size()>0)
4765 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4774 entry =
"/gate/"+crystal_name+
"/placement/setTranslation";
4777 FLTNB crystal_pos_X =0.,
4780 if (values.size()>0)
4785 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4791 if(crystal_pos_X!=0 && crystal_pos_Y !=0)
4793 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4794 Cerr(
" Block cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
4798 scanner_radius += is_block_Y_axis ? crystal_pos_Y : crystal_pos_X ;
4802 entry = is_block_Y_axis ?
4803 "/gate/"+crystal_name+
"/geometry/setYLength" :
4804 "/gate/"+crystal_name+
"/geometry/setXLength";
4807 if (values.size()>0)
4809 double crystal_size = 0.;
4812 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
4816 scanner_radius -= crystal_size/2;
4822 entry = is_block_Y_axis ?
4823 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberX":
4824 "/gate/"+crystal_name+
"/cubicArray/setRepeatNumberY";
4827 if (values.size()>0)
4831 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4836 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatNumberZ";
4838 if (values.size()>0)
4842 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4848 entry =
"/gate/"+crystal_name+
"/cubicArray/setRepeatVector";
4850 if (values.size()>0)
4852 string trs_step = is_block_Y_axis ?
4859 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4866 entry =
"/gate/"+crystal_name+
"/geometry/setXLength";
4868 if (values.size()>0)
4873 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4877 if (is_block_Y_axis)
4878 crystal_size_trs = x_length;
4880 crystal_size_depth = x_length;
4885 entry =
"/gate/"+crystal_name+
"/geometry/setYLength";
4887 if (values.size()>0)
4892 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4896 if (is_block_Y_axis)
4897 crystal_size_depth = y_length;
4899 crystal_size_trs = y_length;
4902 entry =
"/gate/"+crystal_name+
"/geometry/setZLength";
4904 if (values.size()>0)
4908 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4916 entry =
"/gate/digitizer/Coincidences/minSectorDifference";
4918 if (values.size()>0)
4920 double min_sector_diff;
4923 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Conversion error occurred while trying to parse line: " << line<< endl);
4926 min_angle_diff = 360/number_of_blocks*min_sector_diff;
4933 number_of_elements = number_of_blocks *
4934 number_of_blocks_axl *
4935 number_of_crystals_trs *
4936 number_of_crystals_axl;
4941 fov_trs = (2*scanner_radius ) / 1.5;
4944 voxels_number_trs = ( number_of_crystals_trs
4945 * number_of_blocks_trs)
4949 if (crystal_step_axl - crystal_size_axl >= 0)
4950 crystal_gap_axl = crystal_step_axl - crystal_size_axl;
4952 if (crystal_step_trs - crystal_size_trs >= 0)
4953 crystal_gap_trs = crystal_step_trs - crystal_size_trs;
4957 block_size_Z = crystal_size_axl*number_of_crystals_axl + crystal_gap_axl*(number_of_crystals_axl-1);
4958 block_size_Y = crystal_size_trs*number_of_crystals_trs + crystal_gap_trs*(number_of_crystals_trs-1);
4961 if (block_step_axl - block_size_Z >= 0)
4962 block_gap_axl = block_step_axl - block_size_Z;
4964 if (block_step_trs - block_size_Y >= 0)
4965 block_gap_trs = block_step_trs - block_size_Y;
4968 block_first_angle -= round(atan2f(block_pos_X , block_pos_Y) * 180. / M_PI);
4972 ofstream fileGeom(a_pathGeom.c_str(), ios::out | ios::trunc);
4976 fileGeom <<
"# comments" << endl;
4977 fileGeom <<
"# Y _________ "<< endl;
4978 fileGeom <<
"# | / _ \\ \\ "<< endl;
4979 fileGeom <<
"# | | / \\ | |"<< endl;
4980 fileGeom <<
"# |_____ Z | | | | |"<< endl;
4981 fileGeom <<
"# \\ | | | | |" << endl;
4982 fileGeom <<
"# \\ | \\_/ | |" << endl;
4983 fileGeom <<
"# X \\___/_____/" << endl;
4984 fileGeom <<
"# Left-handed axis orientation"<< endl;
4985 fileGeom <<
"# scanner axis is z" << endl;
4986 fileGeom <<
"# positions in millimeters"<< endl;
4987 fileGeom <<
"# Use comma without space as separator in the tables." << endl;
4990 fileGeom <<
"modality : " << modality << endl;
4991 fileGeom <<
"scanner name : " << scanner_name << endl;
4992 fileGeom <<
"number of elements : " << number_of_elements << endl;
4993 fileGeom <<
"number of layers : " <<
"1" << endl;
4994 fileGeom <<
"" << endl;
4995 fileGeom <<
"# default reconstruction parameters" << endl;
4996 fileGeom <<
"voxels number transaxial : " << voxels_number_trs << endl;
4997 fileGeom <<
"voxels number axial : " << voxels_number_axl << endl;
4999 fileGeom <<
"field of view transaxial : " << fov_trs << endl;
5000 fileGeom <<
"field of view axial : " << fov_axl << endl;
5001 fileGeom <<
"" << endl;
5002 fileGeom <<
"description : " << description << endl;
5003 fileGeom <<
"" << endl;
5004 fileGeom <<
"scanner radius : " << scanner_radius << endl;
5005 fileGeom <<
"number of rsectors : " << number_of_blocks << endl;
5006 fileGeom <<
"number of crystals transaxial : " << number_of_crystals_trs << endl;
5007 fileGeom <<
"number of crystals axial : " << number_of_crystals_axl << endl;
5009 fileGeom <<
""<< endl;
5010 fileGeom <<
"# The 4 following parameters could be defined in arrays (SizeLayer1,SizeLayer2,SizeLayer3,etc..) if their is more than one layer"<< endl;
5011 fileGeom <<
"crystals size depth : " << crystal_size_depth << endl;
5012 fileGeom <<
"crystals size transaxial : " << crystal_size_trs << endl;
5013 fileGeom <<
"crystals size axial : " << crystal_size_axl << endl;
5014 fileGeom <<
""<< endl;
5017 fileGeom <<
"rsectors first angle : " << block_first_angle << endl;
5018 fileGeom <<
"number of modules transaxial : " << number_of_blocks_trs << endl;
5019 fileGeom <<
"number of modules axial : " << number_of_blocks_axl << endl;
5020 fileGeom <<
"module gap transaxial : " << block_gap_trs << endl;
5021 fileGeom <<
"module gap axial : " << block_gap_axl << endl;
5022 fileGeom <<
"crystal gap transaxial : " << crystal_gap_trs << endl;
5023 fileGeom <<
"crystal gap axial : " << crystal_gap_axl << endl;
5024 fileGeom <<
"rotation direction : CCW " << endl;
5025 fileGeom <<
""<< endl;
5028 if(min_angle_diff > 0.) fileGeom <<
"min angle difference : " << min_angle_diff << endl;
5031 if(block_angular_span >= 360.0005 ||
5032 block_angular_span <= 359.9995 )
5034 block_angular_span *= (double)(number_of_blocks)/(double)(number_of_blocks-1);
5035 fileGeom <<
"rsectors angular span : " << block_angular_span << endl;
5038 if(block_nb_zshifts > 0) fileGeom <<
"rsectors nbZShift :" << block_nb_zshifts << endl;
5039 if(!vec_block_Z_Shift.empty())
WriteVector(fileGeom,
"rsectors ZShift : ", vec_block_Z_Shift);
5043 Cout(
"Output geom file written at :" << a_pathGeom << endl);
5047 Cerr(
"***** dataConversionUtilities::CreateGeomWithECAT()-> Couldn't open geom file for writing "<< a_pathGeom <<
" !" << endl);
5072 string scanner_name =
GetFileFromPath(a_pathGeom.substr(0,a_pathGeom.find_first_of(
".geom")));
5073 FLTNB scanner_radius = -1.;
5074 string description =
"SPECT camera extracted from GATE macro: " + a_pathMac;
5077 string head_name =
"SPECThead";
5078 uint32_t number_of_heads = 0;
5079 FLTNB head_pos_X = 0.;
5080 FLTNB head_pos_Y = 0.;
5081 FLTNB head_first_angle = 0.;
5082 FLTNB head_angular_pitch = -1.;
5083 string head_orbit_name =
"";
5084 FLTNB head_rotation_speed = 0.;
5085 bool is_head_Y_axis =
false;
5088 string crystal_name =
"crystal";
5089 FLTNB crystal_size_trs = 0.;
5090 FLTNB crystal_size_axl = 0.;
5091 FLTNB crystal_depth = 0;
5094 string pixel_name =
"pixel";
5095 uint32_t number_of_pixels_trs = 1;
5096 uint32_t number_of_pixels_axl = 1;
5097 FLTNB pix_size_trs = 0.;
5098 FLTNB pix_size_axl = 0.;
5099 FLTNB pix_step_trs = 0.;
5100 FLTNB pix_step_axl = 0.;
5101 FLTNB pix_gap_trs = 0.;
5102 FLTNB pix_gap_axl = 0.;
5105 string focal_model_trs =
"constant";
5106 uint16_t nb_coeff_model_trs = 1;
5107 FLTNB coeff_model_trs = 0.;
5108 string focal_model_axl =
"constant";
5109 uint16_t nb_coeff_model_axl = 1;
5110 FLTNB coeff_model_axl = 0.;
5113 uint32_t voxels_number_trs;
5114 uint32_t voxels_number_axl;
5118 vector<string> path_mac_files;
5119 path_mac_files.push_back(a_pathMac);
5124 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()->Error occurred when trying to recover paths to GATE macro files !" << endl);
5132 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()->Error occurred when trying to recover aliases for the elements of the SPECThead !" << endl);
5137 for(uint16_t f=0 ; f<path_mac_files.size() ; f++)
5139 ifstream systemMac(path_mac_files[f].c_str(), ios::in);
5142 while(getline(systemMac, line))
5145 modality =
"SPECT_CONVERGENT";
5146 vector <string> values;
5150 entry =
"/gate/"+head_name+
"/placement/setTranslation";
5152 if (values.size()>0)
5157 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5163 if(head_pos_X!=0 && head_pos_Y !=0)
5165 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5166 Cerr(
" Block cartesian coordinates on either the X or Y axis expected to be equal to 0 "<< endl);
5171 if(head_pos_Y!=0) is_head_Y_axis =
true;
5173 scanner_radius = is_head_Y_axis ? abs(head_pos_Y) : abs(head_pos_X) ;
5177 entry =
"/gate/"+head_name+
"/geometry/setZLength";
5179 if (values.size()>0)
5183 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5187 voxels_number_axl = fov_axl/4 + 1;
5191 entry =
"/gate/"+head_name+
"/ring/setRepeatNumber";
5193 if (values.size()>0)
5197 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5203 entry =
"/gate/"+head_name+
"/ring/setFirstAngle";
5205 if (values.size()>0)
5209 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5215 entry =
"/gate/"+head_name+
"/ring/setAngularPitch";
5217 if (values.size()>0)
5221 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5226 entry =
"/gate/"+head_name+
"/moves/insert";
5228 if (values.size()>0)
5232 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5237 entry =
"/gate/"+head_orbit_name+
"/setSpeed";
5239 if (values.size()>0)
5243 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Conversion error occurred while trying to parse line: " << line<< endl);
5251 entry =
"/gate/"+crystal_name+
"/geometry/setXLength";
5253 if (values.size()>0)
5258 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5263 crystal_size_trs = x_length;
5265 crystal_depth = x_length;
5268 entry =
"/gate/"+crystal_name+
"/geometry/setYLength";
5270 if (values.size()>0)
5275 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5280 crystal_depth = y_length;
5282 crystal_size_trs = y_length;
5286 entry =
"/gate/"+crystal_name+
"/geometry/setZLength";
5288 if (values.size()>0)
5292 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5302 entry = is_head_Y_axis ?
5303 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberX":
5304 "/gate/"+pixel_name+
"/cubicArray/setRepeatNumberY";
5308 if (values.size()>0)
5312 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5317 entry =
"/gate/"+pixel_name+
"/cubicArray/setRepeatNumberZ";
5319 if (values.size()>0)
5323 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5329 entry =
"/gate/"+pixel_name+
"/geometry/setXLength";
5331 if (values.size()>0)
5336 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5341 pix_size_trs = x_length;
5344 entry =
"/gate/"+pixel_name+
"/geometry/setYLength";
5346 if (values.size()>0)
5351 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5355 if (!is_head_Y_axis)
5356 pix_size_trs = y_length;
5360 entry =
"/gate/"+pixel_name+
"/geometry/setZLength";
5362 if (values.size()>0)
5366 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5372 entry =
"/gate/"+pixel_name+
"/cubicArray/setRepeatVector";
5374 if (values.size()>0)
5376 string trs_step = is_head_Y_axis ?
5383 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5390 entry = is_head_Y_axis ?
5391 "/gate/fanbeam/geometry/setFocalDistanceY":
5392 "/gate/fanbeam/geometry/setFocalDistanceX";
5394 entry =
"/gate/fanbeam/geometry/setFocalDistanceX";
5396 if (values.size()>0)
5400 Cerr(
"***** dataConversionUtilities::CreateGeomWithCylindrical()-> Conversion error occurred while trying to parse line: " << line<< endl);
5404 focal_model_trs =
"polynomial";
5412 fov_trs = scanner_radius/2;
5414 voxels_number_trs = fov_trs/2 + 1;
5416 uint32_t nb_pixels = number_of_pixels_axl * number_of_pixels_trs;
5418 pix_size_axl = nb_pixels>1 ? pix_size_axl : crystal_size_axl;
5419 pix_size_trs = nb_pixels>1 ? pix_size_trs : crystal_size_trs;
5422 if (pix_step_axl - pix_size_axl >= 0)
5423 pix_gap_axl = pix_step_axl - pix_size_axl;
5425 if (pix_step_trs - pix_size_trs >= 0)
5426 pix_gap_trs = pix_step_trs - pix_size_trs;
5430 head_first_angle = round(atan2f(head_pos_X , head_pos_Y) * 180. / M_PI)
5435 ofstream fileGeom(a_pathGeom.c_str(), ios::out | ios::trunc);
5439 fileGeom <<
"modality : " << modality << endl;
5440 fileGeom <<
"scanner name : " << scanner_name << endl;
5441 fileGeom <<
"number of detector heads : " << number_of_heads << endl;
5442 fileGeom <<
"trans number of pixels : " << number_of_pixels_trs << endl;
5443 fileGeom <<
"trans pixel size : " << pix_size_trs << endl;
5444 fileGeom <<
"trans gap size : " << pix_gap_trs << endl;
5445 fileGeom <<
"axial number of pixels : " << number_of_pixels_axl << endl;
5446 fileGeom <<
"axial pixel size : " << pix_size_axl << endl;
5447 fileGeom <<
"axial gap size : " << pix_gap_axl << endl;
5449 fileGeom <<
"detector depth : " << crystal_depth << endl;
5451 fileGeom <<
"scanner radius : " << scanner_radius;
5452 for(
size_t h=1 ; h<number_of_heads ; h++)
5453 fileGeom <<
"," << scanner_radius;
5456 fileGeom <<
"# Collimator configuration : "<< endl << endl;
5457 for(
size_t h=0 ; h<number_of_heads ; h++)
5459 fileGeom <<
"head" << h+1 <<
":" << endl;
5460 fileGeom <<
"trans focal model: " << focal_model_trs << endl;
5461 fileGeom <<
"trans number of coef model: " << nb_coeff_model_trs << endl;
5462 fileGeom <<
"trans parameters: " << coeff_model_trs << endl;
5463 fileGeom <<
"axial focal model: " << focal_model_axl << endl;
5464 fileGeom <<
"axial number of coef model: " << nb_coeff_model_axl << endl;
5465 fileGeom <<
"axial parameters: " << coeff_model_axl << endl;
5469 fileGeom <<
"" << endl;
5470 fileGeom <<
"# default reconstruction parameters" << endl;
5471 fileGeom <<
"voxels number transaxial : " << voxels_number_trs << endl;
5472 fileGeom <<
"voxels number axial : " << voxels_number_axl << endl;
5474 fileGeom <<
"field of view transaxial : " << fov_trs << endl;
5475 fileGeom <<
"field of view axial : " << fov_axl << endl << endl ;
5476 fileGeom <<
""<< endl;
5478 fileGeom <<
"# description" << endl;
5479 fileGeom <<
"description : " << description << endl;
5483 Cout(
"Output geom file written at :" << a_pathGeom << endl);
5487 Cerr(
"***** dataConversionUtilities::CreateGeomWithSPECT()-> Couldn't open geom file for writing "<< a_pathGeom <<
" !" << endl);
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, bool &lyr_rpt_flag, int vb)
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 ...
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.
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...
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...
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 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 ComputeKindGATEEvent(int32_t eventID1, int32_t eventID2, int comptonPhantom1, int comptonPhantom2, int rayleighPhantom1, int rayleighPhantom2)
#define GATE_NB_MAX_LAYERS
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.
uint32_t ConvertIDcylindrical(uint32_t nRsectorsAngPos, uint32_t nRsectorsAxial, bool a_invertDetOrder, int a_rsectorIdOrder, bool a_lyrRptFlag, 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)
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 WriteVector(ofstream &file, const string &a_key, vector< T > a_vals)
Write the key and its values in the file provided in parameter.
vector< string > Split(string a_line)
Split the line provided in parameter into a vector of strings (separator is blankspace) ...
void ConvertValuesTomm(vector< string > &ap_v)
Check if the vector of strings passed in parameter contains the 'cm' unit In this case...
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 ...
int GetGATESystemType(const string &a_pathMac)
Read a GATE macro file and identify the system type from the 'gate/systems/' command lines...
#define KEYWORD_MANDATORY
#define GATE_SYS_CYLINDRICAL
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 ...
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...
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 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 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 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...