00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <Stiostream.h>
00023 #include <unistd.h>
00024
00025 #include <string>
00026 #include <utility>
00027 #include <algorithm>
00028
00029
00030 #include "Randomize.h"
00031 #include "StHbook.hh"
00032
00033
00034 #include "StCoordinates.hh"
00035 #include "StTpcCoordinateTransform.hh"
00036
00037
00038
00039 #include "StTpcSimpleGeometry.hh"
00040 #include "StTpcSimpleSlowControl.hh"
00041 #include "StTpcSimpleElectronics.hh"
00042 #include "StSimpleMagneticField.hh"
00043 #include "StTrsDeDx.hh"
00044
00045
00046 #include "StTrsFastChargeTransporter.hh"
00047 #include "StTrsSlowAnalogSignalGenerator.hh"
00048 #include "StTrsFastDigitalSignalGenerator.hh"
00049
00050
00051 #include "StTrsAnalogSignal.hh"
00052 #include "StTrsWireBinEntry.hh"
00053 #include "StTrsWireHistogram.hh"
00054
00055 #include "StTrsSector.hh"
00056
00057
00058 #define VERBOSE 1
00059 #define ivb if(VERBOSE)
00060
00061 void printPad(tpcSector& a)
00062 {
00063 ostream_iterator<StTrsAnalogSignal> out(cout,",");
00064
00065 for(int irow=0; irow<a.size(); irow++)
00066 cout << irow << " " << "<" << a[irow].size() << "> ";
00067
00068
00069
00070
00071
00072
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 int main (int argc,char* argv[])
00089 {
00090 const int tupleSize = 4;
00091 StHbookFile hbookFile("hbook");
00092 StHbookTuple theTuple("Transport", tupleSize);
00093 float tuple[tupleSize];
00094 theTuple << "x" << "y" << "z" << "amp" << book;
00095
00096 const int tupleSize2 = 5;
00097 StHbookTuple secTuple("WireHistogram", tupleSize2);
00098 float tuple2[tupleSize2];
00099 secTuple << "x" << "y" << "z" << "wire" << "amp" << book;
00100
00101 int irow, ipad, itbin;
00102
00103
00104
00105
00106
00107
00108 string geoFile("../run/TPCgeo.conf");
00109 if (access(geoFile.c_str(),R_OK)) {
00110 cerr << "ERROR:\n" << geoFile << " cannot be opened" << endl;
00111
00112 cerr << "Exitting..." << endl;
00113 exit(1);
00114 }
00115
00116 string scFile("../run/sc.conf");
00117 if (access(scFile.c_str(),R_OK)) {
00118 cerr << "ERROR:\n" << scFile << " cannot be opened" << endl;
00119 cerr << "Exitting..." << endl;
00120 exit(1);
00121 }
00122
00123 string magFile("../run/example.conf");
00124 if (access(magFile.c_str(),R_OK)) {
00125 cerr << "ERROR:\n" << scFile << " cannot be opened" << endl;
00126 cerr << "Exitting..." << endl;
00127 exit(1);
00128 }
00129
00130 string electronicsFile("../run/electronics.conf");
00131 if (access(electronicsFile.c_str(),R_OK)) {
00132 cerr << "ERROR:\n" << electronicsFile << " cannot be opened" << endl;
00133 cerr << "Exitting..." << endl;
00134 exit(1);
00135 }
00136
00137
00138
00139
00140 StTpcGeometry *geomDb =
00141 StTpcSimpleGeometry::instance(geoFile.c_str());
00142
00143 StTpcSlowControl *scDb =
00144 StTpcSimpleSlowControl::instance(scFile.c_str());
00145
00146 StMagneticField *magDb =
00147 StSimpleMagneticField::instance(magFile.c_str());
00148
00149 StTpcElectronics *electronicsDb =
00150 StTpcSimpleElectronics::instance(electronicsFile.c_str());
00151
00152
00153 string gas("Ar");
00154 StTrsDeDx myEloss(gas);
00155
00156
00157
00158
00159
00160 StTrsSector *sector = new StTrsSector(geomDb);
00161
00162
00163
00164
00165 StTrsChargeTransporter *trsTransporter =
00166 StTrsFastChargeTransporter::instance(geomDb, scDb, &myEloss, magDb);
00167
00168
00169
00170 trsTransporter->setTransverseDiffusion(true);
00171 trsTransporter->setLongitudinalDiffusion(true);
00172
00173
00174 StTrsWireHistogram *myWireHistogram =
00175 StTrsWireHistogram::instance(geomDb, scDb);
00176
00177
00178
00179
00180 StTrsAnalogSignalGenerator *trsSignalGenerator =
00181 StTrsSlowAnalogSignalGenerator::instance(geomDb, scDb, electronicsDb, sector);
00182
00183
00184
00185
00186
00187
00188 StTrsDigitalSignalGenerator *trsDigitalGenerator =
00189 StTrsFastDigitalSignalGenerator::instance(electronicsDb, sector);
00190
00191
00192
00193
00194
00195 float maxDistance = geomDb->lastOuterSectorAnodeWire();
00196 PR(maxDistance);
00197 float zPosition = 1.*meter;
00198 float position = 52.*centimeter;
00199 float dS;
00200 do {
00201 dS = 5.*myEloss.nextInteraction();
00202
00203 position += dS;
00204
00205 if(position>maxDistance) break;
00206
00207 double primaryEnergyDistribution;
00208 int totalElectrons = myEloss.secondary(&primaryEnergyDistribution) + 1;
00209 PR(totalElectrons);
00210
00211
00212 StTrsMiniChargeSegment
00213 aMiniSegment(StThreeVector<double>(0, position, zPosition),
00214 totalElectrons,
00215 0);
00216 PR(aMiniSegment);
00217
00218
00219
00220
00221 trsTransporter->transportToWire(aMiniSegment);
00222 PR(aMiniSegment);
00223
00224 tuple[0] = static_cast<float>(aMiniSegment.position().x());
00225 tuple[1] = static_cast<float>(aMiniSegment.position().y());
00226 tuple[2] = static_cast<float>(aMiniSegment.position().z());
00227 tuple[3] = static_cast<float>(aMiniSegment.charge());
00228
00229 theTuple.fill(tuple);
00230
00231
00232
00233
00234 StTrsWireBinEntry anEntry(aMiniSegment.position(), aMiniSegment.charge());
00235 PR(anEntry);
00236 myWireHistogram->addEntry(anEntry);
00237
00238 cout << "okay..." << endl;
00239 cout << myWireHistogram->lastEntry() << endl;
00240
00241 if(myWireHistogram->lastEntry() != 0) {
00242 tuple2[0] = static_cast<float>(myWireHistogram->lastEntry()->position().x());
00243 tuple2[1] = static_cast<float>(myWireHistogram->lastEntry()->position().y());
00244 tuple2[2] = static_cast<float>(myWireHistogram->lastEntry()->position().z());
00245 tuple2[3] = static_cast<float>(myWireHistogram->lastWire());
00246 tuple2[4] = static_cast<float>(myWireHistogram->lastEntry()->numberOfElectrons());
00247
00248 secTuple.fill(tuple2);
00249 }
00250
00251 cout << "*********" << endl;
00252 }while(true);
00253
00254 hbookFile.saveAndClose();
00255
00256 return 0;
00257 }