// // ******************************************************************** // * License and Disclaimer * // * * // * The GAMOS software is copyright of the Copyright Holders of * // * the GAMOS Collaboration. It is provided under the terms and * // * conditions of the GAMOS Software License, included in the file * // * LICENSE and available at http://fismed.ciemat.es/GAMOS/license .* // * These include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GAMOS collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the GAMOS Software license. * // ******************************************************************** // /*------------------------------------------------------- PET Reconstruction. Gamos Collaboration - CIEMAT 2009-11 -- sumProjdata.cc -- mario.canadas@ciemat.es -------------------------------------------------------*/ /*------------------------------------------------------ Description : This program sums a set of projection data files (sino 3D) files. A file_list must include the name of the input files (without extension: the program searchs for *.s (first) and *.v files). Type of data: Ciemat projData (Interfile, .hv .v) and STIR projection data format (Interfile 3.3, .hs .s) \n" Input data: FILE_WITH_LIST_OF_PROJDATA_FILES FILE_OUTPUT. It is useful to merge several simulation output files (under the same conditions but using differet seeds) in a global file which can feed the reconstruction software. --------------------------------------------------------*/ #include "G4UImanager.hh" #include "G4UIterminal.hh" #include "G4UItcsh.hh" #include "../include/sumProjdata.hh" #include "GamosCore/GamosUtils/include/GmFileIn.hh" int main(int argc,char *argv[]) { /* for (int i = 1; i < argc; i++) { // Check for a switch (leading "-"). if (argv[i][0] == '-') { // Use the next character to decide what to do. switch (argv[i][1]) { case 'i': Ni = atoi(argv[++i]); break; case 'e': Ne = atoi(argv[++i]); break; case 'n': fileOUTname=argv[++i]; break; //case 'o': oType = atoi(argv[++i]); //break; break; } } else{ fileINname=argv[i]; } } */ if(argc != 3) { G4Exception("sumProjData", "Wrong argument", FatalErrorInArgument, "YOU MUST SUPPLY TWO ARGUMENTS: FILE_WITH_LIST_OF_PROJDATA_FILES FILE_OUTPUT_(without ext.)"); } G4String fileListName = argv[1]; fileOUTname = argv[2]; // FILE* fout = fopen(fileOUTname,"wb"); std::vector wl; GmFileIn finlis = GmFileIn::GetInstance(fileListName); G4int ii; char theFilename[255]; SINO_TYPE * sino_tmp; unsigned long int posNEW, j; for( ii = 0;; ii++){ if( ! finlis.GetWordsInLine(wl) ) break; G4cout << "### sumProjdata: reading projection data file " << wl[0] << G4endl; if( ii == 0 ) { // -- Init File: FILE *InitFile; sprintf(theFilename,"%s.s",wl[0].c_str()); InitFile=fopen(theFilename, "rb"); if (InitFile==NULL){ sprintf(theFilename,"%s.v",wl[0].c_str()); InitFile=fopen(theFilename, "rb"); oType=0; if (InitFile==NULL){ G4Exception("sumProjData", "Wrong argument", FatalErrorInArgument, "!!! FATAL ERROR: INPUT FILE NOT FOUND"); } } fileINname = wl[0]; fseek(InitFile, 0, SEEK_END); // Locates end file sizeTOT = ftell(InitFile); // dumps file position (bytes) // printf("Size: %d\n", fileSize); rewind(InitFile); posTOT=sizeTOT/sizeof(SINO_TYPE); sino_tmp = (SINO_TYPE*) malloc (sizeTOT); sino_total = (SINO_TYPE*) malloc (sizeTOT); fread(sino_total,1,sizeTOT, InitFile); fclose(InitFile); // -- End Init file (posTOT stored) }else{ oType==1 ? sprintf(theFilename,"%s.s",wl[0].c_str()) : sprintf(theFilename,"%s.v",wl[0].c_str()); posNEW=read_data(theFilename, sino_tmp); if (posNEW==posTOT){ for(j=0;j