38 #include "StGlobals.hh"
39 #include "SystemOfUnits.h"
40 #include "StThreeVector.hh"
42 #ifndef ST_NO_NAMESPACES
43 using namespace units;
46 #include "StTrsDeDx.hh"
48 #define HBOOK__DIAGNOSTIC
49 #ifdef HBOOK__DIAGNOSTIC
53 #ifdef HBOOK__DIAGNOSTIC
54 StHbookFile *hbookFile;
55 const int tupleSize1 = 2;
56 const int tupleSize2 = 5;
58 float tuple[tupleSize1];
59 float tuple2[tupleSize2];
61 StHbookTuple *theTuple;
62 StHbookTuple *secTuple;
66 void init_files(
int overWrite,
char* fname)
68 cout <<
"HBOOK file is " << fname << endl;
69 #ifdef HBOOK__DIAGNOSTIC
70 cout <<
"ForceOverwrite: " << overWrite << endl;
72 if (!overWrite && !access(fname,F_OK|R_OK)) {
73 cerr <<
"ERROR: output file '" << fname <<
"' already exists." << endl;
80 hbookFile =
new StHbookFile(fname);
82 theTuple =
new StHbookTuple(
"ionization", tupleSize1);
83 *theTuple <<
"bg" <<
"i" << book;
85 secTuple =
new StHbookTuple(
"dedx", tupleSize2);
86 *secTuple <<
"event" <<
"pri" <<
"sec" <<
"tot" <<
"sub" << book;
96 #ifdef HBOOK__DIAGNOSTIC
97 cout <<
"Save and close " << endl;
98 hbookFile->saveAndClose();
102 int main(
int argc,
char* argv[])
109 int numberOfTracks = 1000;
110 int numberOfSamples = 45;
111 float subSegments = 1.;
112 char* filename =
"hbook";
115 while ((c = getopt(argc, argv,
"s:n:t:fh")) != EOF) {
119 if (argc < ++opt +1) {
122 numberOfSamples = atoi(argv[opt++]);
125 if (argc < ++opt +1) {
128 subSegments = atof(argv[opt++]);
131 if (argc < ++opt +1) {
134 numberOfTracks = atoi(argv[opt++]);
139 forceOverwrite =
true;
142 filename = (
char *)strdup (argv[opt++]);\
145 cerr <<
"Unknown option" << endl;
146 cerr <<
"Exitting..." << endl;
156 cerr <<
"Usage: " << argv[0] <<
" [-s # of samples (1)]\n";
157 cerr <<
" [-n # of subsegments][-t tracks][-f forceOverWrite]\n";
158 cerr <<
" [-h help] [-o hbookfile]" << endl;
169 #ifdef HBOOK__DIAGNOSTIC
170 init_files(forceOverwrite, filename);
173 double padLength = 1.95*centimeter;
174 cout <<
"subSegments= " << subSegments << endl;
179 StTrsDeDx subELoss(gas,(padLength/subSegments));
184 #ifndef ST_NO_TEMPLATE_DEF_ARGS
187 vector<int, allocator<int> > sum;
192 for(jj=1; jj<=5; jj++) {
193 double increment = bg;
194 for(kk=1; kk<10; kk++) {
197 tuple[0] =
static_cast<float>(bg);
198 tuple[1] =
static_cast<float>(myELoss.betheBloch(bg));
200 theTuple->fill(tuple);
207 for(
int itrack=0; itrack<numberOfTracks; itrack++) {
208 for (
int isample=0; isample<numberOfSamples; isample++) {
210 sum.resize((StTrsDeDx::numberOfElectrons),0);
212 myELoss.electrons(sum);
213 tuple2[0] =
static_cast<float>(itrack);
214 tuple2[1] =
static_cast<float>(sum[StTrsDeDx::primaries]);
215 tuple2[2] =
static_cast<float>(sum[StTrsDeDx::secondaries]);
216 tuple2[3] =
static_cast<float>(sum[StTrsDeDx::total]);
218 int totalInSubsegment = 0;
219 for(
int isubsample=0; isubsample<subSegments; isubsample++) {
220 sum.resize((StTrsDeDx::numberOfElectrons),0);
221 subELoss.electrons(sum);
222 totalInSubsegment += sum[StTrsDeDx::total];
225 tuple2[4] =
static_cast<float>(totalInSubsegment);
227 secTuple->fill(tuple2);