FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndRestGas Class Reference

#include <PndRestGas.h>

Public Member Functions

 PndRestGas ()
 
 PndRestGas (char DDFname[80])
 
 PndRestGas (char DDFname[80], Double_t zmin, Double_t zmax)
 
virtual ~PndRestGas ()
 
void LoadDD (char DDfname[80])
 
void SetzRange (Double_t zmin, Double_t zmax)
 
TF1 * GetDDFun ()
 

Private Member Functions

Float_t ** ReadDD (char DDFname[80], Int_t *npoints, Double_t *zmin, Double_t *zmax)
 
 ClassDef (PndRestGas, 1)
 

Private Attributes

Double_t fzmin
 
Double_t fzmax
 
Float_t ** fDDvals
 
TF1 * fDensityFun
 

Detailed Description

PndRestGas.h

Author
P.Buehler paul..nosp@m.bueh.nosp@m.ler@o.nosp@m.eaw..nosp@m.ac.at

The PndRestGas provides tools to simulate the distribution of the rest gas (DD: Density Distribution) in the beam tube.

Definition at line 19 of file PndRestGas.h.

Constructor & Destructor Documentation

PndRestGas::PndRestGas ( )

Default constructor (should not be used)

Definition at line 12 of file PndRestGas.cxx.

13 {
14 
15 }
PndRestGas::PndRestGas ( char  DDFname[80])

Standard constructor DDFname: a file name zmin/zmax: minimum/maximum extension of gas distribution along z-axis

Definition at line 18 of file PndRestGas.cxx.

19 {
20 
21  // create DD function from data in DDfname
22  LoadDD(DDfname);
23 
24 }
void LoadDD(char DDfname[80])
Definition: PndRestGas.cxx:56
PndRestGas::PndRestGas ( char  DDFname[80],
Double_t  zmin,
Double_t  zmax 
)

Definition at line 27 of file PndRestGas.cxx.

28 {
29 
30  // create DD function from data in DDfname
31  LoadDD(DDfname);
32 
33  // set min/max considered extension of beam tube along z-axis
34  SetzRange(zmin,zmax);
35 
36 }
void LoadDD(char DDfname[80])
Definition: PndRestGas.cxx:56
void SetzRange(Double_t zmin, Double_t zmax)
Definition: PndRestGas.h:44
PndRestGas::~PndRestGas ( )
virtual

Destructor

Definition at line 39 of file PndRestGas.cxx.

39  {
40 
41  free(fDDvals);
42  fDDvals=NULL;
43 
44 }
Float_t ** fDDvals
Definition: PndRestGas.h:67

Member Function Documentation

PndRestGas::ClassDef ( PndRestGas  ,
 
)
private
TF1* PndRestGas::GetDDFun ( )
inline

Definition at line 48 of file PndRestGas.h.

References fDensityFun.

48  {
49  return fDensityFun;
50  }
TF1 * fDensityFun
Definition: PndRestGas.h:68
void PndRestGas::LoadDD ( char  DDfname[80])

methods LoadDD: read data from file and create DD function SetzRange: set range of zvalues GetDDFun: get the DD function

Definition at line 56 of file PndRestGas.cxx.

References Double_t, fDensityGraph, GetDDValue(), and npoints.

57 {
58 
59  // read gas density values from the file
60  Int_t npoints;
61  Double_t zmin, zmax;
62  fDDvals = ReadDD(DDfname, &npoints, &zmin, &zmax);
63  SetzRange(zmin,zmax);
64 
65  // create function fDensityFun with DD
66  fDensityGraph = new TGraph(npoints,fDDvals[0],fDDvals[1]);
67  fDensityFun = new TF1("Rest Gas DD",GetDDValue,fzmin,fzmax,0);
68 
69 }
TGraph * fDensityGraph
Definition: PndRestGas.cxx:47
Float_t ** fDDvals
Definition: PndRestGas.h:67
Double_t fzmax
Definition: PndRestGas.h:66
Double_t
Float_t ** ReadDD(char DDFname[80], Int_t *npoints, Double_t *zmin, Double_t *zmax)
Definition: PndRestGas.cxx:74
void SetzRange(Double_t zmin, Double_t zmax)
Definition: PndRestGas.h:44
TF1 * fDensityFun
Definition: PndRestGas.h:68
Double_t fzmin
Definition: PndRestGas.h:66
Double_t GetDDValue(Double_t *zval, Double_t *)
Definition: PndRestGas.cxx:48
Float_t ** PndRestGas::ReadDD ( char  DDFname[80],
Int_t *  npoints,
Double_t zmin,
Double_t zmax 
)
private

methods ReadDD : read DD values from file

Definition at line 74 of file PndRestGas.cxx.

References a, b, file, i, x, and y.

76 {
77 
78  Int_t i;
79  Float_t *x, *y;
80  Float_t a, b;
81  Float_t **values;
82 
83  /* BEGIN Ugly piece of code to count the lines ... */
84  Int_t lines=0;
85 
86  FILE *file = fopen(DDfname, "r"); /* Get filename */
87  int ch, prev = '\n' /* so empty files have no lines */;
88  while ( (ch = fgetc(file)) != EOF ) /* Read all chars in the file. */ {
89  if ( ch == '\n' ) {
90  ++lines; /* Bump the counter for every newline. */
91  }
92  prev = ch; /* Keep a copy to later test whether... */
93  }
94  fclose(file);
95  if ( prev != '\n' ) /* ...the last line did not end in a newline. */ {
96  ++lines; /* If so, add one more to the total. */
97  }
98 
99  *npoints = lines;
100 
101  /* END Ugly piece of code to count the lines ... */
102 
103  // allocate memory for density data ...
104  x = (Float_t*) malloc(lines*sizeof(Float_t));
105  y = (Float_t*) malloc(lines*sizeof(Float_t));
106 
107  // and fill with data from file
108  FILE * fp = fopen(DDfname,"r");
109  for(i=0;i<lines;i++) {
110  fscanf(fp,"%f %f",&a,&b);
111  x[i]=a;
112  y[i]=b;
113  }
114  fclose(fp);
115 
116  // copy values to output
117  values = (Float_t**) malloc(sizeof(Float_t*) * 2);
118  values[0] = x;
119  values[1] = y;
120 
121  // set zmin/zmax
122  *zmin = x[0];
123  *zmax = x[*npoints-1];
124 
125  return values;
126 
127 }
Int_t i
Definition: run_full.C:25
TTree * b
TFile * file
Int_t a
Definition: anaLmdDigi.C:126
Double_t x
Double_t y
void PndRestGas::SetzRange ( Double_t  zmin,
Double_t  zmax 
)
inline

Definition at line 44 of file PndRestGas.h.

References fzmax, and fzmin.

44  {
45  fzmin = zmin;
46  fzmax = zmax;
47  }
Double_t fzmax
Definition: PndRestGas.h:66
Double_t fzmin
Definition: PndRestGas.h:66

Member Data Documentation

Float_t** PndRestGas::fDDvals
private

Definition at line 67 of file PndRestGas.h.

TF1* PndRestGas::fDensityFun
private

Definition at line 68 of file PndRestGas.h.

Referenced by GetDDFun().

Double_t PndRestGas::fzmax
private

Definition at line 66 of file PndRestGas.h.

Referenced by SetzRange().

Double_t PndRestGas::fzmin
private

variables fzmin, fzmax: fDDvals: fDensityFun: function representing DD

Definition at line 66 of file PndRestGas.h.

Referenced by SetzRange().


The documentation for this class was generated from the following files: