--- DarthVader/TrackerLevel2/src/F77/functionspfa.f 2007/05/24 13:29:09 1.13 +++ DarthVader/TrackerLevel2/src/F77/functionspfa.f 2007/08/07 13:56:29 1.14 @@ -210,7 +210,7 @@ endif - print*,'---- ',riseta,iview,angle +cc print*,'---- ',riseta,iview,angle 100 return end @@ -612,101 +612,101 @@ *** * * * *** * * * *** * * * *** * * * *** * * * *** * * * *** - real function cog0(ncog,ic) -*------------------------------------------------- -* this function returns -* -* - the Center-Of-Gravity of the cluster IC -* evaluated using NCOG strips, -* calculated relative to MAXS(IC) -* -* - zero in case that not enough strips -* have a positive signal -* -* NOTE: -* This is the old definition, used by Straulino. -* The new routine, according to Landi, -* is COG(NCOG,IC) -*------------------------------------------------- - - - include 'commontracker.f' - include 'level1.f' - -* --> signal of the central strip - sc = CLSIGNAL(INDMAX(ic)) !center - -* signal of adjacent strips -* --> left - sl1 = 0 !left 1 - if( - $ (INDMAX(ic)-1).ge.INDSTART(ic) - $ ) - $ sl1 = max(0.,CLSIGNAL(INDMAX(ic)-1)) - - sl2 = 0 !left 2 - if( - $ (INDMAX(ic)-2).ge.INDSTART(ic) - $ ) - $ sl2 = max(0.,CLSIGNAL(INDMAX(ic)-2)) - -* --> right - sr1 = 0 !right 1 - if( - $ (ic.ne.NCLSTR1.and.(INDMAX(ic)+1).lt.INDSTART(ic+1)) - $ .or. - $ (ic.eq.NCLSTR1.and.(INDMAX(ic)+1).le.TOTCLLENGTH) - $ ) - $ sr1 = max(0.,CLSIGNAL(INDMAX(ic)+1)) - - sr2 = 0 !right 2 - if( - $ (ic.ne.NCLSTR1.and.(INDMAX(ic)+2).lt.INDSTART(ic+1)) - $ .or. - $ (ic.eq.NCLSTR1.and.(INDMAX(ic)+2).le.TOTCLLENGTH) - $ ) - $ sr2 = max(0.,CLSIGNAL(INDMAX(ic)+2)) - -************************************************************ -* COG computation -************************************************************ - -c print*,sl2,sl1,sc,sr1,sr2 - - COG = 0. - - if(sl1.gt.sr1.and.sl1.gt.0.)then - - if(ncog.eq.2.and.sl1.ne.0)then - COG = -sl1/(sl1+sc) - elseif(ncog.eq.3.and.sl1.ne.0.and.sr1.ne.0)then - COG = (sr1-sl1)/(sl1+sc+sr1) - elseif(ncog.eq.4.and.sl1.ne.0.and.sr1.ne.0.and.sl2.ne.0)then - COG = (sr1-sl1-2*sl2)/(sl2+sl1+sc+sr1) - else - COG = 0. - endif - - elseif(sl1.le.sr1.and.sr1.gt.0.)then - - if(ncog.eq.2.and.sr1.ne.0)then - COG = sr1/(sc+sr1) - elseif(ncog.eq.3.and.sr1.ne.0.and.sl1.ne.0)then - COG = (sr1-sl1)/(sl1+sc+sr1) - elseif(ncog.eq.4.and.sr1.ne.0.and.sl1.ne.0.and.sr2.ne.0)then - COG = (2*sr2+sr1-sl1)/(sl2+sl1+sc+sr1) - else - COG = 0. - endif - - endif - - COG0 = COG - -c print *,ncog,ic,cog,'/////////////' - - return - end +c$$$ real function cog0(ncog,ic) +c$$$*------------------------------------------------- +c$$$* this function returns +c$$$* +c$$$* - the Center-Of-Gravity of the cluster IC +c$$$* evaluated using NCOG strips, +c$$$* calculated relative to MAXS(IC) +c$$$* +c$$$* - zero in case that not enough strips +c$$$* have a positive signal +c$$$* +c$$$* NOTE: +c$$$* This is the old definition, used by Straulino. +c$$$* The new routine, according to Landi, +c$$$* is COG(NCOG,IC) +c$$$*------------------------------------------------- +c$$$ +c$$$ +c$$$ include 'commontracker.f' +c$$$ include 'level1.f' +c$$$ +c$$$* --> signal of the central strip +c$$$ sc = CLSIGNAL(INDMAX(ic)) !center +c$$$ +c$$$* signal of adjacent strips +c$$$* --> left +c$$$ sl1 = 0 !left 1 +c$$$ if( +c$$$ $ (INDMAX(ic)-1).ge.INDSTART(ic) +c$$$ $ ) +c$$$ $ sl1 = max(0.,CLSIGNAL(INDMAX(ic)-1)) +c$$$ +c$$$ sl2 = 0 !left 2 +c$$$ if( +c$$$ $ (INDMAX(ic)-2).ge.INDSTART(ic) +c$$$ $ ) +c$$$ $ sl2 = max(0.,CLSIGNAL(INDMAX(ic)-2)) +c$$$ +c$$$* --> right +c$$$ sr1 = 0 !right 1 +c$$$ if( +c$$$ $ (ic.ne.NCLSTR1.and.(INDMAX(ic)+1).lt.INDSTART(ic+1)) +c$$$ $ .or. +c$$$ $ (ic.eq.NCLSTR1.and.(INDMAX(ic)+1).le.TOTCLLENGTH) +c$$$ $ ) +c$$$ $ sr1 = max(0.,CLSIGNAL(INDMAX(ic)+1)) +c$$$ +c$$$ sr2 = 0 !right 2 +c$$$ if( +c$$$ $ (ic.ne.NCLSTR1.and.(INDMAX(ic)+2).lt.INDSTART(ic+1)) +c$$$ $ .or. +c$$$ $ (ic.eq.NCLSTR1.and.(INDMAX(ic)+2).le.TOTCLLENGTH) +c$$$ $ ) +c$$$ $ sr2 = max(0.,CLSIGNAL(INDMAX(ic)+2)) +c$$$ +c$$$************************************************************ +c$$$* COG computation +c$$$************************************************************ +c$$$ +c$$$c print*,sl2,sl1,sc,sr1,sr2 +c$$$ +c$$$ COG = 0. +c$$$ +c$$$ if(sl1.gt.sr1.and.sl1.gt.0.)then +c$$$ +c$$$ if(ncog.eq.2.and.sl1.ne.0)then +c$$$ COG = -sl1/(sl1+sc) +c$$$ elseif(ncog.eq.3.and.sl1.ne.0.and.sr1.ne.0)then +c$$$ COG = (sr1-sl1)/(sl1+sc+sr1) +c$$$ elseif(ncog.eq.4.and.sl1.ne.0.and.sr1.ne.0.and.sl2.ne.0)then +c$$$ COG = (sr1-sl1-2*sl2)/(sl2+sl1+sc+sr1) +c$$$ else +c$$$ COG = 0. +c$$$ endif +c$$$ +c$$$ elseif(sl1.le.sr1.and.sr1.gt.0.)then +c$$$ +c$$$ if(ncog.eq.2.and.sr1.ne.0)then +c$$$ COG = sr1/(sc+sr1) +c$$$ elseif(ncog.eq.3.and.sr1.ne.0.and.sl1.ne.0)then +c$$$ COG = (sr1-sl1)/(sl1+sc+sr1) +c$$$ elseif(ncog.eq.4.and.sr1.ne.0.and.sl1.ne.0.and.sr2.ne.0)then +c$$$ COG = (2*sr2+sr1-sl1)/(sl2+sl1+sc+sr1) +c$$$ else +c$$$ COG = 0. +c$$$ endif +c$$$ +c$$$ endif +c$$$ +c$$$ COG0 = COG +c$$$ +c$$$c print *,ncog,ic,cog,'/////////////' +c$$$ +c$$$ return +c$$$ end *** * * * *** * * * *** * * * *** * * * *** * * * *** * * * *** real function cog(ncog,ic) @@ -738,19 +738,19 @@ * --> signal of the central strip sc = CLSIGNAL(INDMAX(ic)) !center * signal of adjacent strips - sl1 = 0 !left 1 + sl1 = -9999. !left 1 if( $ (INDMAX(ic)-1).ge.INDSTART(ic) $ ) $ sl1 = CLSIGNAL(INDMAX(ic)-1) - sl2 = 0 !left 2 + sl2 = -9999. !left 2 if( $ (INDMAX(ic)-2).ge.INDSTART(ic) $ ) $ sl2 = CLSIGNAL(INDMAX(ic)-2) - sr1 = 0 !right 1 + sr1 = -9999. !right 1 if( $ (ic.ne.NCLSTR1.and.(INDMAX(ic)+1).lt.INDSTART(ic+1)) $ .or. @@ -758,7 +758,7 @@ $ ) $ sr1 = CLSIGNAL(INDMAX(ic)+1) - sr2 = 0 !right 2 + sr2 = -9999. !right 2 if( $ (ic.ne.NCLSTR1.and.(INDMAX(ic)+2).lt.INDSTART(ic+1)) $ .or. @@ -770,24 +770,52 @@ c print*,'## ',sl2,sl1,sc,sr1,sr2 +c ============================================================== if(ncog.eq.1)then COG = 0. + if(sr1.gt.sc)cog=1. !NEW + if(sl1.gt.sc.and.sl1.gt.sr1)cog=-1. !NEW +c ============================================================== elseif(ncog.eq.2)then if(sl1.gt.sr1)then if((sl1+sc).ne.0)COG = -sl1/(sl1+sc) - elseif(sl1.le.sr1)then - if((sc+sr1).ne.0)COG = sr1/(sc+sr1) - endif + elseif(sl1.lt.sr1)then + if((sc+sr1).ne.0)COG = sr1/(sc+sr1) + elseif( sl1.eq.sr1.and.sl1.ne.-9999.)then !NEW + if( clsigma(indmax(ic)-1).lt.clsigma(indmax(ic)+1) + $ .and.(sl1+sc).ne.0 )cog = -sl1/(sl1+sc) !NEW + if( clsigma(indmax(ic)-1).gt.clsigma(indmax(ic)+1) + $ .and.(sc+sr1).ne.0 )cog = sr1/(sc+sr1) !NEW + endif +c$$$ if(cog==0)print*,'Strange cluster (2) - @maxs ',MAXS(ic) +c$$$ $ ,VIEW(ic),LADDER(ic) +c$$$ $ ,' : ',sl2,sl1,sc,sr1,sr2 +c ============================================================== elseif(ncog.eq.3)then - if((sl1+sc+sr1).ne.0)COG = (sr1-sl1)/(sl1+sc+sr1) + if( (sl1+sc+sr1).ne.0 )COG = (sr1-sl1)/(sl1+sc+sr1) +c$$$ if(cog==0)print*,'Strange cluster (3) - @maxs ',MAXS(ic) +c$$$ $ ,VIEW(ic),LADDER(ic) +c$$$ $ ,' : ',sl2,sl1,sc,sr1,sr2 +c ============================================================== elseif(ncog.eq.4)then if(sl2.gt.sr2)then if((sl2+sl1+sc+sr1).ne.0) $ COG = (sr1-sl1-2*sl2)/(sl2+sl1+sc+sr1) - elseif(sl2.le.sr2)then - if((sr2+sl1+sc+sr1).ne.0) + elseif(sl2.lt.sr2)then + if((sr2+sl1+sc+sr1).ne.0) $ COG = (2*sr2+sr1-sl1)/(sr2+sl1+sc+sr1) + elseif(sl2.eq.sr2.and.sl2.ne.-9999.)then !NEW + if( clsigma(indmax(ic)-2).lt.clsigma(indmax(ic)+2) + $ .and.(sl2+sl1+sc+sr1).ne.0 ) + $ cog = (sr1-sl1-2*sl2)/(sl2+sl1+sc+sr1) !NEW + if( clsigma(indmax(ic)-2).gt.clsigma(indmax(ic)+2) + $ .and.(sr2+sl1+sc+sr1).ne.0 ) + $ cog = (2*sr2+sr1-sl1)/(sr2+sl1+sc+sr1) !NEW endif +c$$$ if(cog==0)print*,'Strange cluster (4) - @maxs ',MAXS(ic) +c$$$ $ ,VIEW(ic),LADDER(ic) +c$$$ $ ,' : ',sl2,sl1,sc,sr1,sr2 +c ============================================================== else print*,'function COG(NCOG,IC) ==> WARNING!! NCOG=',NCOG $ ,' not implemented'