2 #define TRG_VERSION 0x32
9 #include <daqFormats.h>
12 #include <DAQ_READER/daqReader.h>
13 #include <DAQ_READER/daq_det.h>
14 #include <DAQ_READER/daq_dta.h>
15 #include <DAQ_L3/daq_l3.h>
16 #include <DAQ_TRG/daq_trg.h>
17 #include "eventTrackerLib.hh"
23 float g_bfield = 1000;
30 void printL3Info(
l3_t& l3)
32 printf(
"%d tracks, %d clusters: Vertex = (%f, %f %f)\n",l3.tracks_num, l3.cluster_num, l3.xVertex,l3.yVertex,l3.zVertex);
35 for(u_int i=0;i<l3.tracks_num;i++) {
38 printf(
"%5d: pt=%5.3f z0=%7.2f q=%2d nHits=%2d ndedx=%2d ",
39 i, track->pt, track->z0, track->q,
40 track->nHits, track->ndedx);
42 printf(
"flag=0x%04x iRow=%2d oRow=%2d\n",
43 track->flag, track->innerMostRow,
50 void parseArgs(
int argc,
char *argv[])
54 for(
int i=1;i<argc;i++) {
55 if(argv[i][0] !=
'-') {
56 if(g_fn[0] != 0)
goto badargs;
57 strcpy(g_fn, argv[i]);
59 else if(strcmp(argv[i],
"-event") == 0) {
61 g_seq = atoi(argv[i]);
64 else if(strcmp(argv[i],
"-B") == 0) {
66 g_bfield = atof(argv[i]);
67 printf(
"g_bfield = %f\n",g_bfield);
69 else if (strcmp(argv[i],
"-p") == 0) {
72 else if (strcmp(argv[i],
"-nft") == 0) {
75 else if (strcmp(argv[i],
"-nct") == 0) {
78 else if (strcmp(argv[i],
"-pause") == 0) {
81 else if (strcmp(argv[i],
"-vtx") == 0) {
90 if(g_fn[0] == 0)
goto badargs;
95 printf(
"eventTracker <-event #> <-B> <-p> <-nft> <-nct> filename\n");
96 printf(
"\t-event -> event number\n");
97 printf(
"\t-B -> mag field\n");
98 printf(
"\t-p -> print track params\n");
99 printf(
"\t-nft -> don't read tracks from file\n");
100 printf(
"\t-nct -> don't calculate tracks\n");
101 printf(
"\t-pause -> pause before and after\n");
102 printf(
"\t-vtx -> produce output for vtx scan\n");
108 int main(
int argc,
char *argv[])
117 rtsLogOutput(RTS_LOG_STDERR);
119 parseArgs(argc, argv);
127 printf(
"Error getting daqReader\n");
132 L3_P *l3p = (
L3_P *)malloc(szL3_max);
144 printf(
"Enter something: ");
151 char *mem = rdr->get(0,EVP_TYPE_PHYS);
156 if(rdr->status == EVP_STAT_EOR) {
158 printf(
"End of run...\n");
163 printf(
"Error reading an event\n");
175 if(rdr->seq != g_seq)
continue;
180 if(rdr->token == 0)
continue;
184 printf(
"**** Event %d (seq = %d): %d bytes, token %d, triggers = 0x%x\n",
186 rdr->event_number, rdr->seq, rdr->bytes, rdr->token, rdr->daqbits);
191 printf(
"Error reading datap:\n");
199 dd = rdr->det(
"l3")->get(
"legacy");
208 printf(
"This comes from the datafile L3 banks...------ len=%d\n",ret);
210 printf(
"End Datafile L3 banks-------------------------\n");
220 ret = evtTracker->trackEvent(rdr, mem, l3p, szL3_max);
224 printf(
"Error tracking event %d\n",rdr->seq);
231 if(l3p->tracks.off == 0) {
232 LOG(NOTE,
"No tracks produced for event %d\n",rdr->seq);
251 dd = rdr->det(
"trg")->get(
"legacy");
253 printf(
"Invalid trigger reader\n");
258 zdc8 = (
double)pTRG->ZDC[8];
259 zdc9 = (double)pTRG->ZDC[9];
260 zdc_vertex = (zdc9 - zdc8)*0.16*30.0/2.0;
265 bbc_vertex = sum->DSMdata.VTX[3]%512;
270 ret = evtTracker->copyl3_t(l3_legacy, l3p);
276 printf(
"%d %d %lf %lf %lf %lf %lf %lf %lf %d %d\n", rdr->daqbits, l3_legacy.tracks_num, zdc8, zdc9, zdc_vertex, l3_legacy.xVertex, l3_legacy.yVertex,l3_legacy.zVertex, bbc_vertex, zdc0, zdc4);
279 printf(
"This comes from retracking---------------- len=%d\n",ret);
280 printL3Info(l3_legacy);
281 printf(
"End of retracking-------------------------\n");
296 printf(
"Enter something: ");