//
//
// Logs:
//
//  $Log: LDataHeader.h,v $
//  Revision 1.16  2004/04/15 12:19:21  cvs
//  bugs...
//
//  Revision 1.15  2004/04/13 15:14:21  cvs
//  bugs...
//
//  Revision 1.14  2004/04/09 09:54:37  cvs
//  found why there are some peaks at bins e.g. 22,63,105,147... when TOF is drawn.
//  This was due to different number of bins in simulation and storage. To avoid this, both numbers of bins are set equal and less than MAX_BINS!
//
//  Revision 1.13  2004/02/09 14:26:25  cvs
//  added new LDataHeader version and force field also in streamer
//
//  Revision 1.12  2003/12/22 14:32:36  cvs
//  added simulation of laser -> LDataHeader version 5
//  modified hoppserver sigint interruption
//
//  Revision 1.11  2003/11/11 17:33:03  cvs
//  LServer upgraded
//
//  Revision 1.10  2003/11/03 13:54:40  cvs
//  TLServer is now threaded, LData and LDataHeader have now right Draw and Paint methods, LIV is controlled and comments were added.
//
//  Revision 1.9  2003/09/25 10:57:40  cvs
//  added force member to LDataHeader class
//
//  Revision 1.8  2003/08/28 14:41:18  cvs
//  corrected the bug in LData::Add(float,float,float,...). Description of bug: position index, that was obtained by simulation, was not shifted by -1 like was shifted the range of position in LDataHeader::SetDefaults.
//
//  Revision 1.7  2003/08/20 10:26:50  cvs
//  Added scripts directory with two utilities now:
//  modify_header which modify existing header and send it database
//  deliver_header program and script which deliver header to clients
//
//  libLComm was made ROOT compatible and GetBias(z) was added to LDataHeader
//
//  Revision 1.6  2003/07/25 11:36:26  cvs
//  simulation of IV measurements is done with iv program
//  some minority fixes to LDisorder - corrected ft to match the recorded position
//
//  Revision 1.5  2003/07/15 14:19:35  cvs
//  corrected ranges when creating histograms. See LDataHeader::Defaults(). Added Draw(".bias.") to draw bias array
//
//  Revision 1.4  2003/07/09 13:27:39  cvs
//  Modified ranges for histograms stored in LData. Ranges are set by LDataHeader->SetDefaults() and MAX_BINS in Config.h
//
//  Revision 1.3  2003/06/26 14:46:16  cvs
//  found a bug in LSpace::GetEnergy() with fbias. Bug successfully resolved :)
//
//  Revision 1.2  2003/06/26 09:27:11  cvs
//  added log fields...
//
#ifndef _LDATA_HEADER__
#define _LDATA_HEADER__

#include "Config.h"

#include <TNamed.h>
#include <TH1.h>
#include "Util.h"

class LDataHeader: public TNamed {
 public:
  Long_t fjobID;       //identification of job
  //SIMULATION PARAMETERS
  Int_t fmax;          //max number of bins
  Int_t fN1;           //number of repetitions at one energy configuration N1
  Int_t force;         //if 1 include only those that do not exit on first jump - see hoppclient.cc

  Int_t fwspacex;      //working space x size
  Int_t fwspacey;      //working space y size
  Int_t fwspacez;      //working space z size

  Int_t fspacex;       //lattice x size
  Int_t fspacey;       //lattice y size
  Int_t fspacez;       //lattice z size (gradient direction)
  
  Float_t fbasex;      //basecell x size
  Float_t fbasey;      //basecell y size
  Float_t fbasez;      //basecell z size
  
  Float_t fresolution; //delta t of a bin
  Float_t ftemperature;//temperature of lattice
  Float_t fgamma;      //intersite wavefunctions cover
  Float_t fsigma;      //lattice energy disorder gaussian width
  Float_t falpha;      //absorption coeficient

  Int_t   flasermode;  //mode of laser simulation 0-none 1-gaus
  Float_t flaserpar;   //parameter for laser mode 

  //LDATA PARAMETERS FOR STORING SIMULATED DATA
  Float_t rtmin;        //time range min 
  Float_t rtmax;        //time range max 
  Float_t rpmin;        //position range min 
  Float_t rpmax;        //position range max 
  Float_t rvmin;        //velocity range min 
  Float_t rvmax;        //velocity range max 
  Float_t remin;        //energy range min 
  Float_t remax;        //energy range max 
  Int_t   nbint;        //number of bins for time
  Int_t   nbinp;        //number of bins for position
  Int_t   nbinv;        //number of bins for velocity
  Int_t   nbine;        //number of bins for energy

 protected:
  Float_t* fbias;      //[fspacez+2] external field in z axis (0-index)
  Bool_t  f_IsDefault;  //Guard for SetDefault()

 private:
  void Recognize(const char* what);


 public:
  LDataHeader();
  LDataHeader(const char* filename);
  LDataHeader(const int argc,const char** argv);
  virtual ~LDataHeader();

  void Add(const char* filename);
  void Add(const int argc,const char** argv);
  void SetDefaults();
  void CorrectRanges(Float_t& low,Float_t& up,Int_t n);
  void SetJobID(const Long_t id){fjobID=id;}
  Long_t GetJobID() const {return fjobID;}
  void GetJobID(char* jobID) const {sprintf(jobID,"%ld",fjobID);return;}

  void SetForce(const int i){force=i;}
  int GetForce() const{return force;}

  TH1F* GetBiasHist();
  Float_t* GetBias()const {return fbias;}
  Float_t  GetBias(const Int_t z);
  Float_t  GetBias(const Float_t z);
  void SetBias(Float_t* bias);
  void ResetBias(){SetBias(0.0,0.0);};
  void SetUo(const Float_t bias) {(!fbias)?:fbias[0]=bias;}
  Float_t GetUo() const {return (!fbias)?0:fbias[0];}
  void SetBias(const Float_t bias,const Float_t Uo=0.0);
  void SetGradient(const Float_t gradient,const Float_t Uo=0.0);
  void SetLaserMode(const Int_t mode,const Float_t par=0);
  
  Float_t CalcIndexToTime(const Int_t idx) const;
  
  virtual void Browse(TBrowser *);
  virtual void PrintARG();
  
  ClassDef(LDataHeader,7)  //Data header of monte carlo simulation 
};

#endif //_LDATA_HEADER__




