void hitTagger (float xin[4], float xout[4], float pin[5], float pout[5], float dEsum, int track, int stack, int history) { /* read rf_period from calibdb */ if(rf_period < 0.0) { char dbname[] = "/PHOTON_BEAM/RF/rf_period::mc"; unsigned int ndata = 1; if (GetCalib(dbname, &ndata, &rf_period)) { fprintf(stderr,"HDGeant error in hitTagger: %s %s\n", "failed to read RF period ", "from calibdb, cannot continue."); exit (2); } } int micro_chan; int hodo_chan; double Etag = 0; double E = pin[3]; double t = xin[3]*1e9-(xin[2]-REF_TIME_Z_CM)/C_CM_PER_NS; t = floor(t/rf_period+0.5)*rf_period; /* read tagger set endpoint energy from calibdb */ if (endpoint_energy_GeV == 0) { char dbname[] = "/PHOTON_BEAM/endpoint_energy"; unsigned int ndata = 1; if (GetCalib(dbname, &ndata, &endpoint_energy_GeV)) { fprintf(stderr,"HDGeant error in hitTagger: %s %s\n", "failed to read photon beam endpoint energy", "from calibdb, cannot continue."); exit (2); } } /* read microscope channel energy bounds from calibdb */ if (micro_channel_Erange == 0) { char dbname[] = "/PHOTON_BEAM/microscope/scaled_energy_range"; /* table microscope/scaled_energy_range has 3 columns: * column xlow xhigh * which are returned in an array like float[3][ncolumns] */ int ndata = 3*micro_nchannels; mystr_t names[ndata]; micro_channel_Erange = malloc(ndata*sizeof(float)); if (GetArrayConstants(dbname, &ndata, micro_channel_Erange, names) || ndata != 3*micro_nchannels) { fprintf(stderr,"HDGeant error in hitTagger: %s %s\n", "failed to read microscope scaled_energy_range table", "from calibdb, cannot continue."); exit (2); } else { int i; micro_limits_Erange[0] = 0; micro_limits_Erange[1] = 1; for (i=0; i < micro_nchannels; ++i) { if (micro_limits_Erange[0] < micro_channel_Erange[3*i+1]) micro_limits_Erange[0] = micro_channel_Erange[3*i+1]; if (micro_limits_Erange[1] > micro_channel_Erange[3*i+2]) micro_limits_Erange[1] = micro_channel_Erange[3*i+2]; micro_channel_Erange[3*i+1] *= endpoint_energy_GeV; micro_channel_Erange[3*i+2] *= endpoint_energy_GeV; } micro_limits_Erange[0] *= endpoint_energy_GeV; micro_limits_Erange[1] *= endpoint_energy_GeV; } } /* read hodoscope channel energy bounds from calibdb */ if (hodo_channel_Erange == 0) { char dbname[] = "/PHOTON_BEAM/hodoscope/scaled_energy_range"; /* table hodoscope/scaled_energy_range has 3 columns: * counter xlow xhigh * which are returned in an array like float[3][ncolumns] */ int ndata = 3*hodo_nchannels; mystr_t names[ndata]; hodo_channel_Erange = malloc(ndata*sizeof(float)); if (GetArrayConstants(dbname, &ndata, hodo_channel_Erange, names) || ndata != 3*hodo_nchannels) { fprintf(stderr,"HDGeant error in hitTagger: %s %s\n", "failed to read hodoscope scaled_energy_range table", "from calibdb, cannot continue."); exit (2); } else { int i; hodo_limits_Erange[0] = 0; hodo_limits_Erange[1] = 1; for (i=0; i < hodo_nchannels; ++i) { if (hodo_limits_Erange[0] < hodo_channel_Erange[3*i+1]) hodo_limits_Erange[0] = hodo_channel_Erange[3*i+1]; if (hodo_limits_Erange[1] > hodo_channel_Erange[3*i+2]) hodo_limits_Erange[1] = hodo_channel_Erange[3*i+2]; hodo_channel_Erange[3*i+1] *= endpoint_energy_GeV; hodo_channel_Erange[3*i+2] *= endpoint_energy_GeV; } hodo_limits_Erange[0] *= endpoint_energy_GeV; hodo_limits_Erange[1] *= endpoint_energy_GeV; } } if (printDone == 0) { fprintf(stderr,"TAGGER: ALL parameters loaded from Data Base\n"); printDone = 1; } /* look up hit tagger channel, if any */ hodo_chan = -1; micro_chan = -1; if (E < micro_limits_Erange[0] && E > micro_limits_Erange[1]) { int i; for (i=0; i < micro_nchannels; ++i) { if ( E < micro_channel_Erange[3*i+1] && E > micro_channel_Erange[3*i+2] ) { Etag = (micro_channel_Erange[3*i+1] + micro_channel_Erange[3*i+2]) / 2; micro_chan = micro_channel_Erange[3*i]; break; } } } else if (E < hodo_limits_Erange[0] && E > hodo_limits_Erange[1]) { int i; for (i=0; i < hodo_nchannels; ++i) { if ( E < hodo_channel_Erange[3*i+1] && E > hodo_channel_Erange[3*i+2] ) { Etag = (hodo_channel_Erange[3*i+1] + hodo_channel_Erange[3*i+2]) / 2; hodo_chan = hodo_channel_Erange[3*i]; break; } } } /* post the hit to the microscope hits tree, mark channel as hit */ if (micro_chan > -1) { int nhit; s_TaggerTruthHits_t* hits; int mark = micro_chan + 1000; void** twig = getTwig(µTree, mark); if (*twig == 0) { s_Tagger_t* tag = *twig = make_s_Tagger(); s_MicroChannels_t* channels = make_s_MicroChannels(1); hits = make_s_TaggerTruthHits(MICRO_MAX_HITS); hits->mult = 0; channels->in[0].taggerTruthHits = hits; channels->in[0].column = micro_chan; channels->in[0].row = 0; channels->in[0].E = Etag; channels->mult = 1; tag->microChannels = channels; microCount++; } else { s_Tagger_t* tag = *twig; hits = tag->microChannels->in[0].taggerTruthHits; } if (hits != HDDM_NULL) { for (nhit = 0; nhit < hits->mult; nhit++) { if (fabs(hits->in[nhit].t - t) < MICRO_TWO_HIT_RESOL) { break; } } if (nhit < hits->mult) /* ignore second hit */ { } else if (nhit < MICRO_MAX_HITS) /* create new hit */ { hits->in[nhit].bg = track; hits->in[nhit].t = t; hits->in[nhit].E = E; hits->in[nhit].dE += 3.5e-3; // GeV in SciFi hits->mult++; } else { fprintf(stderr,"HDGeant error in hitTagger: "); fprintf(stderr,"max hit count %d exceeded, truncating!\n", MICRO_MAX_HITS); } } } /* post the hit to the hodoscope hits tree, mark channel as hit */ if (hodo_chan > -1) { int nhit; s_TaggerTruthHits_t* hits; int mark = hodo_chan + 1000; void** twig = getTwig(&hodoTree, mark); if (*twig == 0) { s_Tagger_t* tag = *twig = make_s_Tagger(); s_HodoChannels_t* channels = make_s_HodoChannels(1); hits = make_s_TaggerTruthHits(FIXED_MAX_HITS); hits->mult = 0; channels->in[0].taggerTruthHits = hits; channels->in[0].counterId = hodo_chan; channels->in[0].E = Etag; channels->mult = 1; tag->hodoChannels = channels; hodoCount++; } else { s_Tagger_t* tag = *twig; hits = tag->hodoChannels->in[0].taggerTruthHits; } if (hits != HDDM_NULL) { for (nhit = 0; nhit < hits->mult; nhit++) { if (fabs(hits->in[nhit].t - t) < FIXED_TWO_HIT_RESOL) { break; } } if (nhit < hits->mult) /* ignore second hit */ { } else if (nhit < FIXED_MAX_HITS) /* create new hit */ { hits->in[nhit].bg = track; hits->in[nhit].t = t; hits->in[nhit].E = E; hits->in[nhit].dE += 5.5e-4; // GeV in hodo scint. hits->mult++; } else { fprintf(stderr,"HDGeant error in hitTagger: "); fprintf(stderr,"max hit count %d exceeded, truncating!\n", FIXED_MAX_HITS); } } } }
Str GetJetDesc(Str jA) { return GetAlgo(jA)+" "+GetJetR(jA)+", "+GetCalib(jA); }