*********************************************************************** c #include "geant321/pilot.h" SUBROUTINE RPCSTEP c c c Modified on 11/08/2007 by D. Gonzalez-Diaz. c Modified on 19/07/2012 by Alessio Mangiarotti. c Added check that the hit has been stored c correctly after the call to GSAHIT, i.e. c IHIT>0. Added reset of ELOS and LENGTH_IN c after storing the hit. If the volume c dimensions are very small, Geant tracking c may fail to signal the entering. Added a c check that LENGTH_IN is non-zero before c storing the hit. Removed check that the c detector number DETNR is not negative. c This is not a problem if the offset in c the hit packing is selected accordingly. c *********************************************************************** IMPLICIT NONE #include "geant321/gcflag.inc" #include "geant321/gckine.inc" #include "geant321/gcsets.inc" #include "geant321/gctmed.inc" #include "geant321/gctrak.inc" #include "geant321/gcvolu.inc" #include "rpctuple.inc" INTEGER NH PARAMETER (NH=14) REAL HITS(NH) REAL XM(3), XD(3), PM(3), PD(3) CHARACTER*4 CHSET EQUIVALENCE (IHSET,CHSET) INTEGER I, IHIT, DETNR REAL ELOS, LENGTH_IN SAVE ELOS, LENGTH_IN c character*4 namevol integer invol equivalence (namevol,invol) IF(CHSET.NE.'RPCG') RETURN ! are we in an RPC gap(active volume)? DETNR = IDTYPE - 500 ! accumulate the energy deposited by the particle IF(INWVOL.EQ.1) THEN ELOS = 0.0 LENGTH_IN = SLENG ENDIF ELOS = ELOS + DESTEP ! condition for storing a hit in the volume: ! "CHARGED PARTICLE GOING OUT, STOPPED OR DECAYED" (Including the ! two last have no visible effect whatsoever in this case) ! In order to store also NEUTRAL particles that may create a hit in EBOX, *any* particle ! can additionally create a hit "WHEN GOING OUT, STOPPED OR DECAYED" from the virtual box ! (DETNR.EQ.-1). There are plenty of neutral particles just 'punching through' that are filtered ! later on in fillrpc.cc IF(((INWVOL.EQ.2 .OR. ISTOP.GE.1) .AND. CHARGE.NE.0).OR. & ((INWVOL.EQ.2 .OR. ISTOP.GE.1) .AND. DETNR.EQ.-1)) THEN DO I=1,3 XM(I) = VECT(I) PM(I) = VECT(I+3) ENDDO NLEVEL=3 ! Geometry level for transforming to module ref system (EBOX) CALL GMTOD(PM,PD,2) ! transform momentum into module ref system (EBOX) CALL GMTOD(XM,XD,1) ! transform coordinates into module ref system (EBOX) HITS(1) = -XD(1) ! x of hit in detector coordinates (the minus sign is needed) HITS(2) = -XD(2) ! y " (the minus sign is needed) HITS(3) = XD(3) ! z " HITS(4) = TOFG ! tof of hit HITS(5) = FLOAT(ITRA) ! track nb. HITS(6) = ELOS ! deposited energy HITS(7) = FLOAT(DETNR) ! DETECTOR number HITS(8) = VECT(7) ! total momentum of particle HITS(9) = SLENG ! length of the current track HITS(10) = SLENG - LENGTH_IN ! local track length (used for energy loss estimates) HITS(11) = -PD(1) ! Px/P (the minus sign is needed) HITS(12) = -PD(2) ! Py/P (the minus sign is needed) HITS(13) = PD(3) ! Pz/P c if(LENGTH_IN.eq.0.0)then write(6,100) + ' rpcstep.F: a particle exited a gap without entering it' endif IHIT=0 CALL GSAHIT(ISET,IDET,ITRA,NUMBV,HITS,IHIT) ! store hit for geant digitization IF(IHIT.EQ.0) THEN write(6,100)'ERROR: rpc hit not stored!' ENDIF c c If a new particle is created in the ACTIVE volume, ELOS will c not be reset at entrance, so here is the right palce to reset it ! c ELOS=0.0 LENGTH_IN =0.0 ENDIF RETURN *********************************************************************** 100 FORMAT(A) 101 FORMAT(4x,I1,1X,A,1X,I10) ********************************************************************** END