/*:>-------------------------------------------------------------------- **: FILE: mMvdOccupancy.c **: HISTORY: **: 00jan93-v000a-hpl- Created by stic Version **: Id: idl.y,v 1.17 1997/03/25 19:22:52 ward Exp **:<------------------------------------------------------------------*/ #include "mMvdOccupancy.h" void MvdMess_(char *name_of_function, short ierror, short level, char *message, ...); #define NO_ERROR 0 /* used for message output with no error */ #define LOUD 2 /* messages which are usually output */ #define QUIET 1 /* used for messages which are output at default setting */ #define SILENT 0 /* for messages which are usually not output */ long mMvdOccupancy_( TABLE_HEAD_ST *Clmp_h, DMVDCLMP_ST *Clmp , TABLE_HEAD_ST *cRaw_h, DMVCRAW_ST *cRaw , TABLE_HEAD_ST *bPar_h, DMVBPAR_ST *bPar , TABLE_HEAD_ST *cPar_h, DMVCPAR_ST *cPar, TABLE_HEAD_ST *tPar_h, DMVDTRIGPAR_ST *tPar , TABLE_HEAD_ST *Geo_h, DMVDGEO_ST *Geo , TABLE_HEAD_ST *Cntrl_h,DMVDTRIGCONTROL_ST *Cntrl ) { /*:>-------------------------------------------------------------------- **: ROUTINE: mMvdOccupancy_ **: DESCRIPTION: Physics Analysis Module ANSI C template. **: This is an ANSI C Physics Analysis Module template **: automatically generated by stic from mMvdOccupancy.idl. **: Please edit comments and code. **: **: AUTHOR : J.H.Park, S.S.Ryu (YonSei Univ.) (Nov 10 97) **: Translated from the original Fortran version VER_GETO.f **: written by J.P.Sullivan **: **: ARGUMENTS: **: IN: **: Clmp - **: Clmp_h - header Structure for Clmp **: cRaw - **: cRaw_h - header Structure for cRaw **: bPar - **: bPar_h - header Structure for bPar **: cPar - **: cPar_h - **: tPar - PLEASE FILL IN DESCRIPTION HERE **: tPar_h - header Structure for tPar **: Geo - **: Geo_h - header Structure for Geo **: INOUT: **: OUT: **: Cntrl - **: Cntrl_h - header Structure for Cntrl **: RETURNS: STAF Condition Value **: Revision History **: Name Date Comment **: J.H.Park Feb. 10, 1998 choose vertex finding algorithms **: based on occupancy of inner shell **: **: J.P.Sullivan Apr. 14, 1998 replace printf calls with MvdMess_ **: J.P.Sullivan Apr. 29, 1998 plusZ and minusZ to North and South **: J.P.Sullivan Dec. 1, 1998 fixed error in calculation of **: outer barrel occupancy. **: S.S.Ryu 06-Jul-99 changes the variable "Cntl" to "Cntrl" to make **: this variable consistent throughout the MVD **: codes. **:>------------------------------------------------------------------*/ short clsum_inner=0; short clsum_outer=0; short stripsum_inner=0; short stripsum_outer=0; short hitsum_North=0; short hitsum_South=0; short padsum; short i,j,k; MvdMess_("mMvdOccupancy",NO_ERROR,LOUD,"\nmMvdOccupancy{"); /* for barrel detector */ /* calculate # of strips per shell */ for (j=0;j< bPar->NPHUSE;++j) for( k=0;k< bPar->NCHDIM;++k) { /* inner shell */ stripsum_inner+=Geo->nstrip; /* outer shell */ if ((j>1) && ( ( k>=(Geo->nwperp-Geo->nwhole)/2) || (k < (bPar->NCHDIM-(Geo->nwperp-Geo->nwhole)/2) )) ) ; else stripsum_outer+=Geo->nstrip; } MvdMess_("mMvdOccupancy",NO_ERROR,QUIET, "\tstripsum_inner=%d,\ \n\tstripsum_outer=%d", stripsum_inner, stripsum_outer); /* calculate # of strip hit */ for (i=0;inok;++i){ if (Clmp[i].shell == 0) clsum_inner+=Clmp[i].clsize; else clsum_outer+=Clmp[i].clsize; } MvdMess_("mMvdOccupancy",NO_ERROR,QUIET, "\n\tclsum_inner=%d,\ \n\tclsum_outer=%d", clsum_inner, clsum_outer); Cntrl->foccup[0]=(float)clsum_inner/(float)stripsum_inner; Cntrl->foccup[1]=(float)clsum_outer/(float)stripsum_outer; /* for endcap detector */ padsum=cPar->NVPAD_PHI*cPar->NVPAD_RBINS; /* MvdMess_("mMvdOccupancy",NO_ERROR,SILENT, "\n\tpadsum=%d",padsum); */ for (i=0;inok;++i){ if(cRaw[i].end==0) hitsum_South++; if(cRaw[i].end==1) hitsum_North++; } MvdMess_("mMvdOccupancy",NO_ERROR,QUIET, "\n\thitsum_North=%d\ \n\thitsum_South=%d", hitsum_North, hitsum_South ); Cntrl->foccup[2]=(float)hitsum_South/(float)padsum; Cntrl->foccup[3]=(float)hitsum_North/(float)padsum; MvdMess_("mMvdOccupancy",NO_ERROR,QUIET, "\n\tInner shell : Cntrl->foccup[0] =%f \ \n\tOuter shell : Cntrl->foccup[1] =%f \ \n\tEndcap (S) : Cntrl->foccup[2] =%f \ \n\tEndcap (N) : Cntrl->foccup[3] =%f", Cntrl->foccup[0], Cntrl->foccup[1], Cntrl->foccup[2], Cntrl->foccup[3] ); Cntrl_h->nok=1; /* choose vertex finding algorithm between pseudo-tracking method and correlation method based on occupancy of inner shell*/ if ( tPar->choice != 0) /* 0 for both method */ /* NOT 0 for choosing algorithm */ if (Cntrl->foccup[0] > tPar->OCC_CUT ) Cntrl->choice=1; /* 1 for correaltion method */ else Cntrl->choice=2; /* 2 for pseudo-tracking method */ MvdMess_("mMvdOccupancy",NO_ERROR,QUIET, "\n\ttPar->choice=%d Cntrl->choice=%d", tPar->choice,Cntrl->choice); MvdMess_("mMvdOccupancy",NO_ERROR,LOUD,"}"); return STAFCV_OK; }