//
 
// ********************************************************************
 
// * 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.           *
 
// ********************************************************************
 
//
 
 
 
#ifndef PETProjDataMgr_h
 
#define PETProjDataMgr_h
 
 
 
/*---------------------------------------------------------------------------  
 
ClassName:   PETProjDataMgr
 
Author:      M. Canadas, P. Arce
 
Changes:     01/11: creation 
 
 
 
-------------------------------------------------------------------------
 
// Description
 
         
 
    PET output (List-mode X Y Z) into projection data (sinograms). 
 
 
 
    Output data: Sinograms for PET image reconstruction. Interfile format, STIR compatible (.hs/.s), 
 
                 STIR Software for Tomographic Image Reconstruction: http://stir.sourceforge.net/main.htm     
 
 
 
-----------------------------------------------------------------------*/
 
#include <stdlib.h>
 
#include <stdio.h>
 
#include <stdint.h>
 
#include "H1D.h"  
 
#include "H2D.h"  
 
#include "H3D.h"  
 
 
 
#include "daq.h"  
 
 
 
 
 
 typedef unsigned short SINO_TYPE;  //!!NOTE:  Check "Write_sino3D" (.hv file) if SINO_TYPE changes !!
 
 
 
 struct PETProjDataMgr {
 
        
 
        int m_Debug;            
 
  double m_AxialDistance;
 
  double m_RingDiameter;
 
  int m_NOfPlanes;
 
  int m_NOfBins;
 
  int m_NOfAngles;
 
  int m_MaxRingDifference;
 
  int m_OutFormat;
 
  int m_nch;
 
  int m_TotalAxialPlanes;
 
  char m_Filename;
 
 
 
  //G4bool bDumpCout;
 
  
 
  SINO_TYPE ***m_projections;
 
  SINO_TYPE *m_Buffer;
 
  
 
  unsigned long int m_TotalCoincidences;
 
  unsigned long int m_TotalProjectionCoincidences;
 
 
 
  
 
 
 
        
 
        };
 
//-----------------------------------------------------------------------
 
  int PETProjDataMgrInit();
 
  void PETProjDataMgrFree();
 
 
 
  void AddEvent(const HVector3 pos1, const HVector3 pos2); 
 
  //void ReadFile();
 
  //PETOutput ReadEvent( G4bool& bEof );
 
  void SetProjection(int axialplane, int h2d);
 
  void WriteInterfile(const char *fname);
 
  void SetNPlanes(int n);
 
  void SetNBin(int n);
 
  void SetNAng(int n);
 
  void SetDebug(int n);
 
  void SetNumberOfChannels(int n);
 
 
 
  void SetRingDiameter( double x);
 
  void SetAxialDistance( double x);
 
  int Phantom(int kaj);
 
  int FwdProject2d(int img2d, int h2d);
 
  int FwdProject3d(int img3d, int h3d);
 
 
 
  int FwdProject(double x,double y, double z, int nmax, int h1d);
 
  HVector3 Hits2Digits(const HVector3 r);
 
 
 
        
 
 
 
  struct PETProjDataMgr* GetInstance();
 
#endif