StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
trsTransparency.cc
1 //*************************************************************
2 // $Id: trsTransparency.cc,v 1.3 2003/09/02 17:59:15 perev Exp $
3 //
4 // Author: brian, October 1998
5 //
6 // Purpose: Calculation of the transparency for a monostable
7 // switched Gating Grid from the ChargeTransporter
8 // in TRS. Requires the initialization of several
9 // Data Bases.
10 //
11 // $Log: trsTransparency.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/13 00:24:37 lasiuk
16 // TRUE/FALSE, pntrs in Db
17 //
18 // Revision 1.1 1998/11/10 17:12:01 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 <Stiostream.h>
26 #include <unistd.h> // needed for access()
27 
28 #include <string>
29 
30 #include "SystemOfUnits.h"
31 #include "StHbook.hh"
32 
33 #include "StTpcSimpleGeometry.hh"
34 #include "StTpcSimpleSlowControl.hh"
35 #include "StTpcSimpleElectronics.hh"
36 #include "StSimpleMagneticField.hh"
37 #include "StTrsDeDx.hh"
38 
39 #include "StTrsFastChargeTransporter.hh"
40 
41 int main ()
42 {
43  // HBOOK
44  const int tupleSize = 2;
45  StHbookFile hbookFile("hbook");
46  StHbookTuple theTuple("gating grid", tupleSize);
47  float tuple[tupleSize];
48  theTuple << "v" << "t" << book;
49 
50  //
51  // Check File access
52  //
53  string geoFile("../run/TPCgeo.conf");
54  if (access(geoFile.c_str(),R_OK)) {
55  cerr << "ERROR:\n" << geoFile << " cannot be opened" << endl;
56  //shell(pwd);
57  cerr << "Exitting..." << endl;
58  exit(1);
59  }
60 
61  string scFile("../run/sc.conf");
62  if (access(scFile.c_str(),R_OK)) {
63  cerr << "ERROR:\n" << scFile << " cannot be opened" << endl;
64  //shell(pwd);
65  cerr << "Exitting..." << endl;
66  exit(1);
67  }
68 
69  string magFile("../run/example.conf");
70  if (access(magFile.c_str(),R_OK)) {
71  cerr << "ERROR:\n" << magFile << " cannot be opened" << endl;
72  cerr << "Exitting..." << endl;
73  exit(1);
74  }
75 
76  string electronicsFile("../run/electronics.conf");
77  if (access(electronicsFile.c_str(),R_OK)) {
78  cerr << "ERROR:\n" << electronicsFile << " cannot be opened" << endl;
79  cerr << "Exitting..." << endl;
80  exit(1);
81  }
82 
83  //
84  // The DataBases
85  //
86 
87  StTpcGeometry *geomDb =
88  StTpcSimpleGeometry::instance(geoFile.c_str());
89 
90  StTpcElectronics *electronicsDb =
91  StTpcSimpleElectronics::instance(electronicsFile.c_str());
92 
93  StTpcSlowControl *scDb =
94  StTpcSimpleSlowControl::instance(scFile.c_str());
95 
96  StMagneticField *magDb =
97  StSimpleMagneticField::instance(scFile.c_str());
98 
99  string gas("Ar");
100  StTrsDeDx gasDb(gas);
101 
102 
103  //
104  // Make a Transporter!
105 
106  StTrsChargeTransporter* trsTransporter =
107  StTrsFastChargeTransporter::instance(geomDb, scDb, &gasDb, magDb);
108 
109  trsTransporter->setGatingGridTransparency(true);
110 
111 #ifndef ST_NO_NAMESPACES
112  using namespace units;
113 #endif
114  float voltage = -140.*volt;
115  do {
116  voltage += (1.*volt);
117  trsTransporter->setGatingGridVoltage(voltage);
118  double value = trsTransporter->transparencyCalculation();
119 
120  tuple[0] = static_cast<float>(voltage/volt);
121  tuple[1] = static_cast<float>(value);
122 
123  theTuple.fill(tuple);
124 
125  } while (voltage <= (10.*volt));
126 
127  hbookFile.saveAndClose();
128 
129  return 0;
130 }