/* * clustGams - registers clusters for gams * */ #include #include #include #include #include #include extern s_HDDM_t* thisInputEvent; binTree_t* gamsEMTree = 0; static int clustCount = 0; /* register clusters during tracking (from gustep) */ //void clustGams (float x) { // void clustGams (float E, float x, float y, float z, float xc, float yc, float chi2, int type,int dime, int id, float t) { void clustGams (float E, float x, float y, float z, float xc, float yc, float chi2, int type, int dime, int id, float t) { printf("I am inside cluster Gams 000 \n"); int mark = (1<<30) + clustCount; void** twig = getTwig(&gamsEMTree, mark); if (*twig == 0) { printf("I am inside cluster Gams \n"); s_GamsEMcal_t* stc = *twig = make_s_GamsEMcal(); s_GamsClusts_t* clust = make_s_GamsClusts(1); stc->gamsClusts = clust; clust->in[0].E = E; clust->in[0].x = x; clust->in[0].y = y; clust->in[0].z = z; clust->in[0].xc = xc; clust->in[0].yc = yc; clust->in[0].chi2 = chi2; clust->in[0].type = type; clust->in[0].dime = dime; clust->in[0].id = id; clust->in[0].t = t; clust->mult = 1; clustCount++; } } /* entry point from fortran */ //void clustgams_(float* E, float* x, float* y, float* z, float* xc, float* yc, float* chi2, int* type, int* dime, int* id, float* t) // { // clustGams(*E, *x, *y, *z, *xc, *yc, *chi2, *type, *dime, *id, *t); // } void clustgams_(float* E, float* x, float* y, float* z, float *xc, float *yc, float *chi2, int* type, int* dime, int* id, float* t) { clustGams(*E, *x, *y, *z, *xc, *yc, *chi2, *type, *dime, *id, *t); } //void clustgams_(float* x) //{ // clustGams(*x); //} /* pick and package clusters for shipping */ s_GamsEMcal_t* pickGams () { s_GamsEMcal_t* box; s_GamsEMcal_t* item; printf("clustCount = %d\n",clustCount); if ( clustCount == 0) { return HDDM_NULL; } box = make_s_GamsEMcal(); box->gamsClusts = make_s_GamsClusts(clustCount); while (item = (s_GamsEMcal_t*) pickTwig(&gamsEMTree)) { s_GamsClusts_t* clust = item->gamsClusts; int hit; printf("Mult = %d %f \n",clust->mult, clust->in[0].t); for (hit = 0; hit < clust->mult; ++hit) { int m = box->gamsClusts->mult++; box->gamsClusts->in[m] = clust->in[hit]; } if (clust != HDDM_NULL) { FREE(clust); } FREE(item); } clustCount = 0; if ((box->gamsClusts != HDDM_NULL) && (box->gamsClusts->mult == 0)) { FREE(box->gamsClusts); box->gamsClusts = HDDM_NULL; } if (box->gamsClusts->mult == 0) { FREE(box); box = HDDM_NULL; } return box; }