StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
trsLandau.cc
1 //*********************************************************************
2 // $Id: trsLandau.cc,v 1.3 2003/09/02 17:59:15 perev Exp $
3 //
4 // Author: brian, October 1998
5 //
6 // Purpose: Used to determine and evaluate the functional form
7 // of the ionization process:
8 // -- Landau Distribution
9 // -- Primary Energy Distribution
10 //
11 // $Log: trsLandau.cc,v $
12 // Revision 1.3 2003/09/02 17:59:15 perev
13 // gcc 3.2 updates + WarnOff
14 //
15 // Revision 1.2 1998/11/12 22:39:57 lasiuk
16 // compatibility at BNL
17 //
18 // Revision 1.1 1998/11/10 17:12:00 fisyak
19 // Put Brian trs versin into StRoot
20 //
21 // Revision 1.1 1998/11/08 17:44:57 lasiuk
22 // Initial Revision
23 //
24 //*********************************************************************
25 #include <unistd.h>
26 #include <Stiostream.h>
27 #include "Stiostream.h"
28 #include <string>
29 
30 // SCL
31 #include "SystemOfUnits.h"
32 #ifndef ST_NO_NAMESPACES
33 using namespace units;
34 #endif
35 
36 #define HBOOK
37 #ifdef HBOOK
38 #include "StHbook.hh"
39 #endif
40 #include "Randomize.h"
41 
42 // TRS
43 #include "StTrsDeDx.hh"
44 
45 
46 // --------------------- MAIN -------------------------- //
47 int main()
48 {
49 #ifdef HBOOK
50  const int tupleSize = 3;
51  StHbookFile hbookFile("hbook");
52  StHbookTuple theTuple("dedx", tupleSize);
53  float tuple[tupleSize];
54  theTuple << "pri" << "tot" << "pnt" << book; // position points
55 
56  const int tupleSize2 = 2;
57  StHbookTuple secTuple("distribution", tupleSize2);
58  float tuple2[tupleSize2];
59 
60  secTuple << "energy" << "sec" << book;
61 #endif
62 
63  string gas("Ar");
64  StTrsDeDx myEloss(gas); // default pad Length
65 
66  int primary, secondary;
67  int totalSecondary;
68  int total; // number Of Electrons
69  double xysec; // energy distribution
70 
71  myEloss.print();
72  for(int pnt=0; pnt<10000; pnt++) {
73 
74  // primaries are given by a Poissonian distribution with a mean
75  primary = myEloss.primary(); // bg = 1
76 
77  // loop over all primaries
78  totalSecondary = 0;
79  for(int ii=0; ii<primary; ii++) {
80 
81  secondary = myEloss.secondary(&xysec);
82  totalSecondary += secondary;
83 #ifdef HBOOK
84  tuple2[0] = static_cast<float>(xysec/eV);
85  tuple2[1] = static_cast<float>(secondary);
86  secTuple.fill(tuple2);
87 #endif
88  totalSecondary +=secondary;
89  }
90 
91  // Total number of electrons in the ionization interaction
92  total = primary+totalSecondary;
93 
94 #ifdef HBOOK
95  tuple[0] = static_cast<float>(primary);
96  tuple[1] = static_cast<float>(total);
97  tuple[2] = static_cast<float>(pnt);
98 
99  theTuple.fill(tuple); // write the tuple
100 #endif
101  }
102 
103  cout <<"Done: " << endl;
104 
105 #ifdef HBOOK
106  hbookFile.saveAndClose();
107 #endif
108  return 0;
109 }