* * $Id: tpc_add_hit.F,v 1.3 2004/05/28 16:06:58 dpp Exp $ * * $Log: tpc_add_hit.F,v $ * Revision 1.3 2004/05/28 16:06:58 dpp * -> move constants to common, initialized in tpc_init_det_response * -> allow fragmented hit list * * Revision 1.2 2004/01/23 21:07:46 dpp * -> add tag to argument of tpc_add_hit * -> tag hit * * Revision 1.1 2003/03/05 17:51:08 dpp * -> NEW ROUTINE * -> add one hit to the hit list, called from hit sources * -> use EvntHit_OpnHit to indicate usable hits * * #include "sys/CLEO_machine.h" #include "pilot.h" SUBROUTINE TPC_ADD_HIT(ILCD,IADR,Z_HIT,Z_WIDTH,PH_HIT,TAG) C....................................................................... C. C. TPC_ADD_HIT - add one hit to the hit list C. C. COMMON : C. CALLS : C. CALLED : C. AUTHOR : D. Peterson C. C. VERSION : 1.00 C. CREATED : 16-Dec-2002 C. C....................................................................... #if defined(CLEO_TYPCHK) IMPLICIT NONE #endif SAVE #include "doit/duseq/tfconspa.inc" #include "doit/duseq/tfindpar.inc" C which includes C #include "cl3seq/cdgm3/cdgeompa.inc" C #include "doit/duseq/tfgeompa.inc" #include "doit/duseq/tfctlcde.inc" #include "doit/duseq/tfgeomcd.inc" #include "cl3seq/cdgm3/cdgeomcd.inc" #include "doit/duseq/cdscrtcd.inc" #include "doit/duseq/runev.inc" #include "doit/duseq/tpccom.inc" INTEGER ISCAL COMMON/SCALR/ISCAL(80) C ARGUMENTS INTEGER ILCD INTEGER IADR REAL Z_HIT REAL Z_WIDTH REAL PH_HIT INTEGER TAG C LOCAL LOGICAL ALLOW_HIT INTEGER FillLoc INTEGER ILTF INTEGER LastHitMlt REAL PHINOW CHARACTER*1 CDUM c23456789 123456789 123456789 123456789 123456789 123456789 123456789 12 * ----------Executable code starts here--------------------------------- ALLOW_HIT= 1 (IADR.GE.(INDXCD(ILCD))).AND. 2 (IADR.LT.(INDXCD(ILCD)+NWIRCD(ILCD))) IF(ALLOW_HIT)THEN IF(EvntHit_MapDet(IADR).EQ.0)THEN ALLOW_HIT=.TRUE. ELSE ILTF=ILCDTF(ILCD) ALLOW_HIT=MultiHitLayer(ILTF) ENDIF ENDIF IF(ALLOW_HIT)THEN ALLOW_HIT=( 1 (EvntHit_Num.LT.EvntHitMax).AND. 2 (EvntHit_OpnLoc1.GT.0)) ENDIF IF(ALLOW_HIT)THEN C increment number of hits C specify storage location for this hit; update next open location EvntHit_Num=EvntHit_Num+1 if(EvntHit_Num.GT.ISCAL(5))ISCAL(5)=EvntHit_Num FillLoc=EvntHit_OpnLoc1 EvntHit_OpnLoc1=EvntHit_OpnLocN(EvntHit_OpnLoc1) C assign some simple status flags and the layer/wire information EvntHit_OpnHit(FillLoc)=7 EvntHit_Tag(FillLoc)=TAG EvntHit_CDlayr(FillLoc)=ILCD EvntHit_laWire(FillLoc)=IADR-INDXCD(ILCD) C assign the map value, and "layer" link list for first hit in each cell IF(EvntHit_MapDet(IADR).EQ.0)THEN EvntHit_MapDet(IADR )=FillLoc EvntHit_PrvMlt(FillLoc )=0 C for the "layer" link list, insert new elements, into the front of the list C as in Doit/Fortran/doitloaddrhits.F C (1stLyr has beeen zeroed in tpc_hitlist.F) if(EvntHit_1stLyr(ilcd).ne.0)then EvntHit_NxtLyr(FillLoc )=EvntHit_1stLyr(ilcd) EvntHit_PrvLyr(EvntHit_1stLyr(ilcd))=FillLoc else EvntHit_NxtLyr(FillLoc )=0 endif EvntHit_1stLyr(ilcd)=FillLoc EvntHit_PrvLyr(FillLoc )=0 ELSE C many arrays are locked into having EvntHit_MapDet unchanged C so it is dificult to insert into the front on the link list as C in Doit/Fortran/doitloaddrhits.F C bounce up to the last hit in the multi-hit link-list C install pointers to and from new hit LastHitMlt=EvntHit_MapDet(IADR) 151 continue IF(EvntHit_NxtMlt(LastHitMlt).NE.0)THEN LastHitMlt=EvntHit_NxtMlt(LastHitMlt) GO TO 151 endif EvntHit_NxtMlt(LastHitMlt)=FillLoc EvntHit_PrvMlt(FillLoc )=LastHitMlt ENDIF C finish the new last element in the "multiple hits within a cell" link list c it looks like PrimMlt for every hit is initialized to self EvntHit_1stMlt(FillLoc)=EvntHit_MapDet(IADR) EvntHit_NxtMlt(FillLoc)=0 EvntHit_PrimMlt(FillLoc)=FillLoc C these are multihit variables used for a single hit system, like CLEO C these are to count multi-TDC hits, not multi-hits as in a TPC EvntHit_nMult(FillLoc)=1 EvntHit_TimEarly(FillLoc)=0 EvntHit_TimLate(FillLoc)=0 C other simple values PHINOW=PHIFCD(ILCD) 2 +CELLCD(ILCD)*EvntHit_laWire(FillLoc) IF(PHINOW.LT.0.) PHINOW=PHINOW+2.*PI IF(PHINOW.GE.2.*PI)PHINOW=PHINOW-2.*PI EvntHit_X(FillLoc)=COS(PHINOW)*RCD(ILCD) EvntHit_Y(FillLoc)=SIN(PHINOW)*RCD(ILCD) EvntHit_Z(FillLoc)=Z_HIT EvntHit_PhiWir(FillLoc)=PHINOW EvntHit_Drift(FillLoc)=0. EvntHit_NxtCls(FillLoc)=0 EvntHit_PrimCls(FillLoc)=0 EvntHit_NHitDev(FillLoc)=EvntHit_Num C time of the hit in ps EvntHit_rawTIM(FillLoc)=Z_HIT/TPC_DRIFT_VEL C TDC EvntHit_rawTDC(FillLoc)=Z_HIT/3.0*4096 C now using this variable for the time duration of the hit, in ps, C specifically, the duration due to z propogation of the track EvntHit_corTIM(FillLoc)= ABS(Z_WIDTH)/TPC_DRIFT_VEL C EvntHit_Charge is "uncorrected" charge and available in sf_data_access C EvntHit_rawADC is the raw adc and is available in sf_data_access C PWCD used be the "corrected charge" and is not available C do not fill PWCD; this location will be used by EvntHit_corPhi EvntHit_Charge(FillLoc)=PH_HIT EvntHit_rawADC(FillLoc)=.5*PH_HIT c IF( c 2 (current_event.eq.19).and. c 3 (ILCD.eq.25).and. c 4 (IADR.EQ.22839))THEN c print 9901, c 1 IADR,FillLoc, c 2 EvntHit_MapDet(IADR), c 3 EvntHit_CDlayr(FillLoc), c 4 EvntHit_laWire(FillLoc), c 5 EvntHit_Num, FillLoc, c 6 EvntHit_1stMlt(FillLoc), c 7 EvntHit_NxtMlt(EvntHit_1stMlt(FillLoc)), c 8 EvntHit_Charge(FillLoc), c 9 EvntHit_Z(FillLoc), c 1 EvntHit_rawTIM(FillLoc), c 2 EvntHit_corTIM(FillLoc) c c 9901 format(' tpc_add_hit: diag:', c 1 ' IADR=',I6,' Loc=',I8, c 2 ' map=',I6, c 3 ' Layr=',I3, c 4 ' Wire=',I5, c 5 ' this hit num=',I6,' in location ',I6, c 6 ' 1st hit for cell=',I6, c 7 ' next hit for 1st hit=',I6, c 8 ' this PH=',F6.1, c 9 ' z=',F7.3, c 1 ' t(ps)=',F11.0, c 2 ' dt(ps)=',F11.0) c c accept 9902,cdum c 9902 format(a1) c ENDIF ENDIF RETURN END