diff --git a/graphics/AtlantisJava/CMakeLists.txt b/graphics/AtlantisJava/CMakeLists.txt deleted file mode 100644 index 7d9ae4dd60085d27fe898ae42a7229607783a2fc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -################################################################################ -# Package: AtlantisJava -################################################################################ - -# Declare the package name: -atlas_subdir( AtlantisJava ) - -# External dependencies: -find_package( Java ) - -# Install files from the package: -atlas_install_joboptions( share/InteractiveServer.py ) -atlas_install_scripts( share/atlantis share/atlantis_online ) -atlas_install_generic( lib/*.jar - DESTINATION "share/AtlantisJava/lib" - EXECUTABLE ) -atlas_install_generic( img/*.gif img/*.png img/*.jpg - DESTINATION "share/AtlantisJava/img" - EXECUTABLE ) -atlas_install_generic( configuration/*.xml configuration/*.csv configuration/PSProlog.txt - DESTINATION "share/AtlantisJava/configuration" - EXECUTABLE ) -atlas_install_generic( events/event.dtd events/*.zip - DESTINATION "share/AtlantisJava/events" - EXECUTABLE ) -atlas_install_generic( geometry/*.xml - DESTINATION "share/AtlantisJava/geometry" - EXECUTABLE ) -atlas_install_generic( help/help.jar help/online.xml help/*.png - DESTINATION "share/AtlantisJava/help" - EXECUTABLE ) diff --git a/graphics/AtlantisJava/ant/build.xml b/graphics/AtlantisJava/ant/build.xml deleted file mode 100755 index 1172e921def862b788bda6e3ae478ea5868a9363..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/ant/build.xml +++ /dev/null @@ -1,469 +0,0 @@ -<?xml version="1.0"?> - -<!-- Main Ant build file for Atlantis --> - -<!-- basedir attribute to be adjusted - target build directory - - - - - --> -<project name="Atlantis" default="usage" basedir=".."> - <!-- begin properties - - - - - - - - - - - - - - - - - - - - - - - - --> - <!-- read in overriden properties from ant.properties file - - - - - --> - <property file="ant.properties"/> - <property name="appName" value="Atlantis"/> - - <!-- Use Java 1.6. - Note that this controls the source code accepted and bytecode generated but - does NOT ensure that the correct libraries are available so in principle you - could still build code that requires different libraries to run. - This was added when we needed to enforve Java 1.5 but 1.6 was already - the most commonly installed version. --> - <property name="ant.build.javac.source" value="1.6"/> - - <!-- webstart codebase with appropriate default --> - <property name="codebase" value="http://www.cern.ch/atlantis/webstart"/> - - <!-- password for webstart certificate - certificate is created in - webstart target, used to sign *.jar files and erased afterwards --> - <property name="password" value="webstart_certificate_atlantis_password"/> - - <!-- list of "specific system configurations" in configurations/config-*.xml --> - <!-- NOT including MINERVA since this needs a slightly different JNLP file to load events from a URL --> - <property name="configs" - value="acr-general,acr-public,l1calo-acr,lar-acr,lar-publications,mbts-acr,mdt-acr,pixel-acr,pixel-publications,sct-acr,sct-publications,tgc-acr,tile-acr,tile-publications,trt-acr,trt-publications"/> - - <!-- timeout in milliseconds for JUnit tests, applies to each forked JVM instance --> - <property name="test.timeout" value="300000"/> - - <!-- directories - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <property name="src.src" value="src"/> - <property name="lib.src" value="lib"/> - <property name="test.src" value="test/src"/> - <property name="test.events" value="test/events"/> - <!-- runtime directories and files --> - <property name="conf" value="configuration"/> - <property name="events" value="events"/> - <property name="geom" value="geometry"/> - <property name="help" value="help"/> - <property name="img" value="img"/> - <property name="share" value="share"/> - - <property name="conf.src" value="${conf}"/> - <property name="events.src" value="${events}"/> - <property name="geom.src" value="${geom}"/> - <property name="help.src" value="${help}"/> - <property name="img.src" value="${img}"/> - <property name="share.src" value="${share}"/> - - <property name="conf.run" value="${targetDir}/${conf}"/> - <property name="events.run" value="${targetDir}/${events}"/> - <property name="geom.run" value="${targetDir}/${geom}"/> - <property name="help.run" value="${targetDir}/${help}"/> - <property name="img.run" value="${targetDir}/${img}"/> - <property name="share.run" value="${targetDir}/${share}"/> - - <property name="class.run" value="${targetDir}/classes"/> - <property name="lib.run" value="${targetDir}/lib"/> - <property name="test.run" value="${targetDir}/classes-test"/> - - <!-- directories for test libraries and output --> - <property name="lib.test" value="${targetDir}/lib/test"/> - <property name="report.test" value="${targetDir}/report"/> - - <!-- Atlantis - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <property name="atlantis.jar" value="${targetDir}/atlantis.jar"/> - <property name="atlantis.main.class" value="atlantis.Atlantis"/> - - <!-- Classpath for manifest in Jar file --> - <path id="classpath.mf"> - <fileset dir="${lib.run}"> - <include name="**/*.jar"/> - </fileset> - <fileset dir="${help.run}"> - <include name="**/*.jar"/> - </fileset> - </path> - - <!-- "foreach" task needed to generate specific system configs, provided by ant-contrib --> - <taskdef resource="net/sf/antcontrib/antcontrib.properties"> - <classpath> - <pathelement location="${lib.src}/build/ant-contrib-1.0b3.jar"/> - </classpath> - </taskdef> - - - <!-- =============================================================== --> - - <!-- targets begin - - - - - - - - - - - - - - - - - - - - - - - - - --> - - <!-- preinit target - - - - - - - - - - - - - - - - - - - - - - - - - --> - <target name="preinit" description="Test if targetDir argument is set"> - <fail unless="targetDir"> - targetDir variable must be set - try: ant usage - example: ant -DtargetDir="test" all - </fail> - <echo>Atlantis build will be made into ${targetDir} directory</echo> - </target> - - - <!-- init target - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <target name="init" depends="preinit" - description="Makes required directories, copies libs"> - <mkdir dir="${lib.run}"/> - <!-- For runtime libraries use include element to take only Jar files from lib directory, - not build subdirectory --> - <copy todir="${lib.run}"> - <fileset dir="${lib.src}"> - <include name="*.jar"/> - </fileset> - </copy> - - <mkdir dir="${conf.run}"/> - <copy todir="${conf.run}"> - <fileset dir="${conf.src}"/> - </copy> - - <mkdir dir="${events.run}"/> - <copy todir="${events.run}"> - <fileset dir="${events.src}"/> - </copy> - - <mkdir dir="${geom.run}"/> - <copy todir="${geom.run}"> - <fileset dir="${geom.src}"/> - </copy> - - <mkdir dir="${help.run}"/> - <copy todir="${help.run}"> - <fileset dir="${help.src}"> - <include name="help.jar"/> - </fileset> - </copy> - - <mkdir dir="${img.run}"/> - <copy todir="${img.run}"> - <fileset dir="${img.src}"/> - </copy> - - <mkdir dir="${share.run}"/> - <copy todir="${share.run}"> - <fileset dir="${share.src}"/> - </copy> - - <mkdir dir="${class.run}"/> - - </target> - - - - <!-- compile target --> - <target name="compile" depends="init" - description="Compiles all source files"> - - <javac includeAntRuntime="false" srcdir="${src.src}" destdir="${class.run}" deprecation="on" verbose="no"> - <!-- <compilerarg value="-Xlint:unchecked"/> --> - <include name="**/*.java"/> - <classpath> - <fileset dir="${lib.run}"> - <include name="**/*.jar"/> - </fileset> - </classpath> - </javac> - </target> - - - <!-- all target - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <target name="all" depends="jar, clean" - description="Copy runtime files, build and clean up"/> - - <!-- jar-atlantis target - - - - - - - - - - - - - - - - - - - - - - --> - <!-- Keep for compatibility with existing CMT requirements file --> - <target name="jar-atlantis" depends="all" - description="Create jar file of Atlantis"> - </target> - - <!-- jar target - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <target name="jar" depends="compile" - description="Create all jar files for deployment"> - <manifestclasspath property="jar.classpath" jarfile="${atlantis.jar}"> - <classpath refid="classpath.mf"/> - </manifestclasspath> - - <!-- jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <jar destfile="${atlantis.jar}"> - <fileset dir="${class.run}" /> - <fileset dir="${targetDir}"> - <exclude name="classes/*"/> - <exclude name="lib/*"/> - <exclude name="help/*"/> - <include name="*/*"/> - </fileset> - <manifest> - <attribute name="Built-By" value="${user.name}"/> - <attribute name="Main-Class" value="${atlantis.main.class}"/> - <attribute name="Class-Path" value="${jar.classpath}"/> - <attribute name="Implementation-Title" value="Atlantis"/> - </manifest> - </jar> - </target> - - <!-- webstartcommon target - - - - - - - - - - - - - - - - - - - - --> - <target name="webstartcommon" depends="compile"> - <manifestclasspath property="jar.classpath" jarfile="${atlantis.jar}"> - <classpath refid="classpath.mf"/> - </manifestclasspath> - - <jar destfile="${atlantis.jar}"> - <fileset dir="${class.run}" /> - - <fileset dir="${targetDir}"> - <exclude name="classes/*"/> - <exclude name="lib/*"/> - <exclude name="help/*"/> - <include name="*/*"/> - </fileset> - - <manifest> - <attribute name="Built-By" value="${user.name}"/> - <attribute name="Main-Class" value="${atlantis.main.class}"/> - <attribute name="Class-Path" value="${jar.classpath}"/> - <attribute name="Implementation-Title" value="Atlantis"/> - </manifest> - </jar> - - <!-- clean up, leave only lib/*.jar, help/*.jar, atlantis.jar --> - <delete dir="${conf.run}"/> - <delete dir="${events.run}"/> - <delete dir="${geom.run}"/> - <delete dir="${img.run}"/> - <delete dir="${share.run}"/> - - <antcall target="clean"/> - <antcall target="webstartjarsigner"/> - </target> - - - <!-- webstart - distribution via webstart (lib/*.jar, help/*.jar and - atlantis.jar (includes all data files) --> - <target name="webstart" depends="webstartcommon" - description="atlantis distribution for Java WebStart"> - - <!-- copy webstart .jnlp files --> - <copy file="${share.src}/atlantis.jnlp" todir="${targetDir}"> - <filterset> - <filter token="CODEBASE" value="${codebase}"/> - </filterset> - </copy> - - </target> - - - <!-- webstart - MINERVA version --> - <target name="webstart-minerva" depends="compile" - description="Atlantis MINERVA distribution for Java WebStart"> - - <!-- copy webstart .jnlp files --> - <copy file="${share.src}/MINERVA.jnlp" todir="${targetDir}"> - <filterset> - <filter token="CODEBASE" value="${codebase}"/> - </filterset> - </copy> - - </target> - - - <target name="webstart-config"> - <!-- copy webstart .jnlp files --> - <copy file="${share.src}/specificconfig.jnlp" tofile="${targetDir}/${config}.jnlp"> - <filterset> - <filter token="CODEBASE" value="${codebase}"/> - <filter token="HREF" value="${config}.jnlp"/> - <filter token="CONFIG" value="config-${config}.xml"/> - </filterset> - </copy> - </target> - - - <!-- webstart including basic atlantis.jnlp and "specific system configurations" --> - <target name="webstart-all" depends="webstart,webstart-specificconfigs,webstart-minerva" - description="Atlantis for Java Webstart including basic atlantis.jnlp and specific system configurations"/> - - - <target name="webstart-specificconfigs"> - <foreach param="config" list="${configs}" target="webstart-config"/> - </target> - - - <!-- webstartjarsigner target - - - - - - - - - - - - - - - - - - - --> - <target name="webstartjarsigner" description="Sign all jar files"> - <delete file="${targetDir}/keystore"/> - <exec executable="${java.home}/bin/keytool"> - <arg line="-genkey -dname 'cn=Atlantis team' -alias Atlantis - -keypass ${password} -keystore ${targetDir}/keystore - -storepass ${password} -validity 180"/> - </exec> - <signjar alias="Atlantis" - keystore="${targetDir}/keystore" - keypass="${password}" - storepass="${password}"> - - <fileset file="${lib.run}/*.jar" /> - <fileset file="${help.run}/*.jar"/> - <fileset file="${atlantis.jar}"/> - </signjar> - <delete file="${targetDir}/keystore"/> - </target> - - - - <!-- updateconfigurations target - - - - - - - - - - - - - - - - - - --> - <!-- update special configurations - jython script performs update of - all special / customised configurations shipped with atlantis and then - runs Atlantis with each configuration file --> - <target name="updateconfigs" depends="jar" - description="Update / synchronise customised configuration files"> - <echo>Requires jython available in PATH, otherwise fails.</echo> - - <!-- arg to exec - arguments to specify atlantis distribution direct. - and where the configuration files for updating are located --> - <!-- exec for unix, mac --> - <exec executable="jython" osfamily="unix" failonerror="true"> - <arg line="share/configupdater.py --atlantis ${targetDir} - --update ${conf.src}"/> - </exec> - <!-- exec for windows --> - <exec executable="cmd" osfamily="windows" failonerror="true"> - <arg value="/c"/> - <arg value="jython.bat"/> - <arg value="share\configupdater.py"/> - <arg value="--atlantis"/> - <arg line="${targetDir}"/> - <arg line="--update"/> - <arg line="${conf.src}"/> - </exec> - - <echo>Deleting build directory ${targetDir}, calling delete ...</echo> - <delete dir="${targetDir}"/> - </target> - - <!-- javadoc target - - - - - - - - - - - - - - - - - - - - - - - - - --> - <target name="javadoc" description="Make Javadoc documentation"> - <mkdir dir="${targetDir}" /> - - <javadoc packagenames="atlantis.*" - sourcepath="${src.src}" - destdir="${targetDir}" - overview="${src.src}/overview.html" - doctitle="Atlantis event display for ATLAS" - > - <classpath> - <fileset dir="${lib.src}"> - <include name="**/*.jar"/> - </fileset> - </classpath> - </javadoc> - </target> - - <!-- clean target - - - - - - - - - - - - - - - - - - - - - - - - - --> - <target name="clean" description="Erase *.class generated files"> - <delete dir="${class.run}"/> - </target> - - <target name="test" depends="unit-tests,gui-tests" description="Run all tests"> - <!-- If testcase is set, specified test is run here. --> - <junit printsummary="yes" haltonerror="no" haltonfailure="no" failureProperty="test.failed" errorProperty="test.failed" - fork="yes" timeout="${test.timeout}"> - <sysproperty key="atlantis.test.events" file="${test.events}"/> - <formatter type="xml"/> - <test name="${testcase}" toDir="${report.test}" if="testcase"/> - <classpath refid="classpath.test"/> - </junit> - - <mkdir dir="${report.test}/html"/> - <junitreport todir="${report.test}"> - <fileset dir="${report.test}"> - <include name="TEST-*.xml"/> - </fileset> - <report todir="${report.test}/html"/> - </junitreport> - - <fail message="Failed JUnit test(s)" if="test.failed"/> - </target> - - <!-- Has to continue on failure or error so report target can run. --> - <!-- Not sure why need haltonerror="no" even if failures occur but no errors --> - <target name="unit-tests" depends="compile-tests,jar" description="Run unit tests"> - <mkdir dir="${report.test}"/> - <junit printsummary="yes" haltonerror="no" haltonfailure="no" failureProperty="test.failed" errorProperty="test.failed" - fork="yes" timeout="${test.timeout}"> - <sysproperty key="atlantis.test.events" file="${test.events}"/> - <formatter type="xml"/> - <!-- If testcase is set, specified test will be run in "test" target. Otherwise run all of them. --> - <batchtest toDir="${report.test}" unless="testcase"> - <fileset dir="${test.run}" includes="atlantis/**/*Test.class"/> - </batchtest> - <classpath refid="classpath.test"/> - </junit> - </target> - - <!-- Has to continue on failure or error so report target can run. --> - <!-- Not sure why need haltonerror="no" even if failures occur but no errors --> - <target name="gui-tests" depends="compile-tests,jar" description="Run GUI tests"> - <mkdir dir="${report.test}"/> - <junit printsummary="yes" haltonerror="no" haltonfailure="no" failureProperty="test.failed" errorProperty="test.failed" - fork="yes" timeout="${test.timeout}"> - <sysproperty key="atlantis.test.events" file="${test.events}"/> - <formatter type="xml"/> - <!-- If testcase is set, specified test will be run in "test" target. Otherwise run all of them. --> - <batchtest toDir="${report.test}" unless="testcase"> - <fileset dir="${test.run}" includes="guitest/**/*Test.class"> - </fileset> - </batchtest> - <classpath refid="classpath.test"/> - </junit> - </target> - - <!-- compile-tests target: compile JUnit tests --> - <target name="compile-tests" depends="compile" - description="Compiles source files for all tests"> - <mkdir dir="${lib.run}/test"/> - <copy todir="${lib.run}/test"> - <fileset dir="${lib.src}/test"> - <include name="*.jar"/> - </fileset> - </copy> - <mkdir dir="${test.run}"/> - <javac includeAntRuntime="false" srcdir="${test.src}" destdir="${test.run}" deprecation="on" verbose="no"> - <include name="**/*.java"/> - <classpath> - <fileset dir="${lib.run}"> - <include name="**/*.jar"/> - </fileset> - <fileset dir="${lib.test}"> - <include name="**/*.jar"/> - </fileset> - <pathelement path="${class.run}"/> - </classpath> - </javac> - <path id="classpath.test"> - <fileset dir="${lib.run}"> - <include name="**/*.jar"/> - </fileset> - <fileset dir="${lib.test}"> - <include name="**/*.jar"/> - </fileset> - <pathelement path="${targetDir}/atlantis.jar"/> - <pathelement path="${test.run}"/> - </path> - </target> - - <!-- usage target - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <target name="usage" description="Prints usage hint"> - <echo level="info" message="Usage:"/> - <echo>targetDir - directory to build atlantis distribution in</echo> - <echo>ant -DtargetDir=[target directory] [all|jar|javadoc|test|report|updateconfigs]</echo> - <echo>and -DtargetDir=[target directory] -Dtestcase=[test-case class] test</echo> - <echo>ant -DtargetDir=[target directory] [-Dcodebase="Webstart codebase URL"] [webstart|webstart-specificconfigs|webstart-all]</echo> - </target> - - <!-- help target - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <target name="help" depends="usage" description="Prints usage hint"/> - -</project> diff --git a/graphics/AtlantisJava/configuration/PSProlog.txt b/graphics/AtlantisJava/configuration/PSProlog.txt deleted file mode 100755 index ca7483a2aebbe15106ede1fbfb41dd836f8063bb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/configuration/PSProlog.txt +++ /dev/null @@ -1,156 +0,0 @@ -100 dict dup begin - -% Author: Charles Loomis - -% Redefinitions which save some space in the output file. These are also -% the same as the PDF operators. -/q {gsave} def -/Q {grestore} def - -/n {newpath} def -/m {moveto} def -/l {lineto} def -/c {curveto} def -/h {closepath} def - -/re {4 -2 roll moveto - dup 0 exch rlineto exch 0 rlineto - neg 0 exch rlineto closepath} def - -/f {fill} def -/f* {eofill} def -/F {gsave vg&FC fill grestore} def -/F* {gsave vg&FC eofill grestore} def - -/s {closepath stroke} def -/S {stroke} def - -/b {closepath gsave vg&FC fill grestore - gsave stroke grestore newpath} def -/B {gsave vg&FC fill grestore gsave stroke grestore newpath} def -/b* {closepath gsave vg&FC eofill grestore - gsave stroke grestore newpath} def -/B* {gsave vg&FC eofill grestore gsave stroke grestore newpath} def - -/g {1 array astore /vg&fcolor exch def} def -/G {setgray} def -/k {4 array astore /vg&fcolor exch def} def -/K {setcmykcolor} def -/rg {3 array astore /vg&fcolor exch def} def -/RG {setrgbcolor} def - -% Initialize the fill color. -0 0 0 rg - -/vg&FC {mark vg&fcolor aload pop - counttomark 1 eq {G} if - counttomark 3 eq {RG} if - counttomark 4 eq {K} if - cleartomark } def - -/vg&DFC {/vg&fcolor exch def} def - -/vg&C {mark exch aload pop - counttomark 1 eq {G} if - counttomark 3 eq {RG} if - counttomark 4 eq {K} if - cleartomark } def - -/w {setlinewidth} def -/j {setlinejoin} def -/J {setlinecap} def -/M {setmiterlimit} def -/d {setdash} def -/i {setflat} def - -/W {clip} def -/W* {eoclip} def - -% Setup the default graphics state. -% (black; 1 pt. linewidth; miter join; butt-ends; solid) -/defaultGraphicsState {0 g 1 w 0 j 0 J [] 0 d} def - -% Emulation of the rectangle operators for PostScript implementations -% which do not implement all Level 2 features. This is an INCOMPLETE -% emulation; only the "x y width height rect..." form is emulated. -/*rf {gsave newpath re fill grestore} def -/*rs {gsave newpath re stroke grestore} def -/*rc {newpath re clip} def -/rf /rectfill where {pop /rectfill}{/*rf} ifelse load def -/rs /rectstroke where {pop /rectstroke}{/*rs} ifelse load def -/rc /rectclip where {pop /rectclip}{/*rc} ifelse load def - -% Emulation of the selectfont operator. This includes a 20% increase in -% the fontsize which is necessary to get sizes similar to the Java fonts. -/*sf {exch findfont exch - dup type /arraytype eq {makefont}{scalefont} ifelse setfont} bind def -/sf /selectfont where {pop {1.2 mul selectfont}}{{1.2 mul *sf}} ifelse def - -% Initialize variables for safety. -/delta 0 def -/xv 0 def /yv 0 def /width 0 def /height 0 def - -% Initialize to portrait A4 page. -/pw 595 def /ph 842 def /po true def /ftp false def - -% Initialize margins to 20 points. -/ml 20 def /mr 20 def /mt 20 def /mb 20 def - -% set page size (usage: <page width><page height> setpagesize) -/setpagesize {/ph exch def /pw exch def} def - -% set page orientation (usage: portrait or landscape) -/portrait {/po true def} def -/landscape {/po false def} def - -% force natural size for image (usage: naturalsize) -/naturalsize {/ftp false def} def - -% resize image to fill page (usage: fittopage) -/fittopage {/ftp true def} def - -% set margins of the page (usage: <left><bottom><top><right> setmargins) -/setmargins {/mr exch def /mt exch def /mb exch def /ml exch def} def - -% set the graphic's size (usage: <width><height> setsize) -/setsize {/gh exch def /gw exch def} def - -% set the graphic's origin (usage: <x0><y0> setorigin) -/setorigin {/gy exch def /gx exch def} def - -% calculate image center -/imagecenter {pw ml sub mr sub 2 div ml add - ph mt sub mb sub 2 div mb add} def - -% calculate the necessary scaling -/imagescale {po {gw}{gh} ifelse pw ml sub mr sub div - po {gh}{gw} ifelse ph mt sub mb sub div - 2 copy lt {exch} if pop - ftp not {1 2 copy lt {exch} if pop} if - 1 exch div /sfactor exch def - /gw gw sfactor mul def /gh gh sfactor mul def} def - -% calculate image origin -/imageorigin {pw ml sub mr sub 2 div ml add - po {gw}{gh} ifelse 2 div sub - ph mt sub mb sub 2 div mb add - po {gh}{gw} ifelse 2 div po {add}{sub} ifelse} def - -% calculate the clipping origin -/cliporigin {pw ml sub mr sub 2 div ml add - po {gw}{gh} ifelse 2 div sub floor - ph mt sub mb sub 2 div mb add - po {gh}{gw} ifelse 2 div sub floor} def - -% Set the clipping region to the bounding box. -/cliptobounds {cliporigin po {gw}{gh} ifelse 1 add - po {gh}{gw} ifelse 1 add rc} def - -% set the base transformation matrix (usage: setbasematrix) -/setbasematrix {imageorigin translate - po {0}{90} ifelse rotate - sfactor sfactor neg scale - /defaultmatrix matrix currentmatrix def} def - - - diff --git a/graphics/AtlantisJava/configuration/colormap.xml b/graphics/AtlantisJava/configuration/colormap.xml deleted file mode 100755 index 1160b07c23b933c56677f2b0e0d4ce4a67feef06..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/configuration/colormap.xml +++ /dev/null @@ -1,369 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE colormap [ - <!ELEMENT colormap (Mapping*)> - <!ATTLIST colormap - numMaps CDATA #REQUIRED - numColors CDATA #REQUIRED> - <!ELEMENT Mapping EMPTY> - <!ATTLIST Mapping - map CDATA #REQUIRED - index CDATA #REQUIRED - r CDATA #REQUIRED - g CDATA #REQUIRED - b CDATA #REQUIRED> -]> - -<colormap numMaps="9" numColors="29" > -<!-- map 0 - Default(1) --> - <!-- white --> - <Mapping map="0" index="0" r="176" g="176" b="176"/> - <!-- geometry --> - <Mapping map="0" index="1" r="58" g="58" b="58"/> - <Mapping map="0" index="2" r="32" g="32" b="32"/> - <Mapping map="0" index="3" r="205" g="92" b="92"/> - <Mapping map="0" index="4" r="55" g="101" b="140"/> - <Mapping map="0" index="5" r="130" g="200" b="130"/> - <Mapping map="0" index="6" r="70" g="130" b="180"/> - <Mapping map="0" index="7" r="200" g="200" b="200"/> - <!-- background --> - <Mapping map="0" index="8" r="255" g="255" b="255"/> - <!-- frames --> - <Mapping map="0" index="9" r="189" g="34" b="50"/> - <Mapping map="0" index="10" r="180" g="180" b="81"/> - <Mapping map="0" index="11" r="33" g="182" b="92"/> - <Mapping map="0" index="12" r="89" g="206" b="223"/> - <Mapping map="0" index="13" r="140" g="40" b="140"/> - <!-- grey --> - <Mapping map="0" index="14" r="153" g="153" b="153"/> - <!-- cells --> - <Mapping map="0" index="15" r="125" g="0" b="0"/> - <Mapping map="0" index="16" r="255" g="255" b="128"/> - <Mapping map="0" index="17" r="0" g="125" b="0"/> - <Mapping map="0" index="18" r="181" g="229" b="251"/> - <Mapping map="0" index="19" r="255" g="128" b="255"/> - <!-- red --> - <Mapping map="0" index="20" r="255" g="0" b="0"/> - <!-- green --> - <Mapping map="0" index="21" r="0" g="255" b="0"/> - <!-- blue --> - <Mapping map="0" index="22" r="0" g="0" b="255"/> - <!-- yellow --> - <Mapping map="0" index="23" r="255" g="255" b="0"/> - <!-- magenta --> - <Mapping map="0" index="24" r="255" g="0" b="255"/> - <!-- cyan --> - <Mapping map="0" index="25" r="0" g="255" b="255"/> - <!-- black --> - <Mapping map="0" index="26" r="0" g="0" b="0"/> - <!-- orange --> - <Mapping map="0" index="27" r="255" g="115" b="0"/> - <!-- cornflower blue --> - <Mapping map="0" index="28" r="135" g="206" b="250"/> -<!-- map 1 - Default(2) --> - <!-- white --> - <Mapping map="1" index="0" r="176" g="176" b="176"/> - <!-- geometry --> - <Mapping map="1" index="1" r="58" g="58" b="58"/> - <Mapping map="1" index="2" r="32" g="32" b="32"/> - <Mapping map="1" index="3" r="254" g="102" b="0"/> - <Mapping map="1" index="4" r="0" g="24" b="71"/> - <Mapping map="1" index="5" r="130" g="200" b="130"/> - <Mapping map="1" index="6" r="0" g="51" b="153"/> - <Mapping map="1" index="7" r="200" g="200" b="200"/> - <!-- background --> - <Mapping map="1" index="8" r="255" g="255" b="255"/> - <!-- frames --> - <Mapping map="1" index="9" r="189" g="34" b="50"/> - <Mapping map="1" index="10" r="180" g="180" b="81"/> - <Mapping map="1" index="11" r="33" g="182" b="92"/> - <Mapping map="1" index="12" r="89" g="206" b="223"/> - <Mapping map="1" index="13" r="140" g="40" b="140"/> - <!-- grey --> - <Mapping map="1" index="14" r="153" g="153" b="153"/> - <!-- cells --> - <Mapping map="1" index="15" r="185" g="0" b="0"/> - <Mapping map="1" index="16" r="255" g="255" b="128"/> - <Mapping map="1" index="17" r="0" g="125" b="0"/> - <Mapping map="1" index="18" r="181" g="229" b="251"/> - <Mapping map="1" index="19" r="255" g="128" b="255"/> - <!-- red --> - <Mapping map="1" index="20" r="255" g="0" b="0"/> - <!-- green --> - <Mapping map="1" index="21" r="0" g="255" b="0"/> - <!-- blue --> - <Mapping map="1" index="22" r="0" g="0" b="255"/> - <!-- yellow --> - <Mapping map="1" index="23" r="255" g="255" b="0"/> - <!-- magenta --> - <Mapping map="1" index="24" r="255" g="0" b="255"/> - <!-- cyan --> - <Mapping map="1" index="25" r="0" g="255" b="255"/> - <!-- black --> - <Mapping map="1" index="26" r="0" g="0" b="0"/> - <!-- orange --> - <Mapping map="1" index="27" r="255" g="170" b="0"/> - <!-- cornflower blue --> - <Mapping map="1" index="28" r="0" g="102" b="255"/> -<!-- map 2 - Default(M4+M5) --> - <!-- white --> - <Mapping map="2" index="0" r="255" g="255" b="255"/> - <!-- geometry --> - <Mapping map="2" index="1" r="40" g="0" b="0"/> - <Mapping map="2" index="2" r="0" g="35" b="0"/> - <Mapping map="2" index="3" r="132" g="39" b="32"/> - <Mapping map="2" index="4" r="138" g="138" b="68"/> - <Mapping map="2" index="5" r="98" g="134" b="122"/> - <Mapping map="2" index="6" r="78" g="139" b="170"/> - <Mapping map="2" index="7" r="97" g="65" b="97"/> - <!-- background --> - <Mapping map="2" index="8" r="44" g="47" b="50"/> - <!-- frames --> - <Mapping map="2" index="9" r="189" g="34" b="50"/> - <Mapping map="2" index="10" r="180" g="180" b="81"/> - <Mapping map="2" index="11" r="33" g="182" b="92"/> - <Mapping map="2" index="12" r="89" g="206" b="223"/> - <Mapping map="2" index="13" r="140" g="40" b="140"/> - <!-- grey --> - <Mapping map="2" index="14" r="153" g="153" b="153"/> - <!-- cells --> - <Mapping map="2" index="15" r="245" g="135" b="138"/> - <Mapping map="2" index="16" r="255" g="255" b="128"/> - <Mapping map="2" index="17" r="123" g="212" b="194"/> - <Mapping map="2" index="18" r="181" g="229" b="251"/> - <Mapping map="2" index="19" r="255" g="128" b="255"/> - <!-- red --> - <Mapping map="2" index="20" r="255" g="0" b="0"/> - <!-- green --> - <Mapping map="2" index="21" r="0" g="255" b="0"/> - <!-- blue --> - <Mapping map="2" index="22" r="0" g="0" b="255"/> - <!-- yellow --> - <Mapping map="2" index="23" r="255" g="255" b="0"/> - <!-- magenta --> - <Mapping map="2" index="24" r="255" g="0" b="255"/> - <!-- cyan --> - <Mapping map="2" index="25" r="0" g="255" b="255"/> - <!-- black --> - <Mapping map="2" index="26" r="0" g="0" b="0"/> - <!-- orange --> - <Mapping map="2" index="27" r="255" g="115" b="0"/> - <!-- cornflower blue --> - <Mapping map="2" index="28" r="102" g="128" b="255"/> -<!-- map 3 - Gray detector --> - <!-- white --> - <Mapping map="3" index="0" r="255" g="255" b="255"/> - <!-- geometry --> - <Mapping map="3" index="1" r="0" g="0" b="0"/> - <Mapping map="3" index="2" r="0" g="0" b="0"/> - <Mapping map="3" index="3" r="32" g="32" b="32"/> - <Mapping map="3" index="4" r="80" g="80" b="80"/> - <Mapping map="3" index="5" r="16" g="16" b="16"/> - <Mapping map="3" index="6" r="48" g="48" b="48"/> - <Mapping map="3" index="7" r="64" g="64" b="64"/> - <!-- background --> - <Mapping map="3" index="8" r="112" g="112" b="112"/> - <!-- frames --> - <Mapping map="3" index="9" r="189" g="34" b="50"/> - <Mapping map="3" index="10" r="180" g="180" b="81"/> - <Mapping map="3" index="11" r="33" g="182" b="92"/> - <Mapping map="3" index="12" r="89" g="206" b="223"/> - <Mapping map="3" index="13" r="140" g="40" b="140"/> - <!-- grey --> - <Mapping map="3" index="14" r="153" g="153" b="153"/> - <!-- cells --> - <Mapping map="3" index="15" r="245" g="135" b="138"/> - <Mapping map="3" index="16" r="255" g="255" b="128"/> - <Mapping map="3" index="17" r="123" g="212" b="194"/> - <Mapping map="3" index="18" r="181" g="229" b="251"/> - <Mapping map="3" index="19" r="255" g="128" b="255"/> - <!-- red --> - <Mapping map="3" index="20" r="255" g="0" b="0"/> - <!-- green --> - <Mapping map="3" index="21" r="0" g="255" b="0"/> - <!-- blue --> - <Mapping map="3" index="22" r="0" g="0" b="255"/> - <!-- yellow --> - <Mapping map="3" index="23" r="255" g="255" b="0"/> - <!-- magenta --> - <Mapping map="3" index="24" r="255" g="0" b="255"/> - <!-- cyan --> - <Mapping map="3" index="25" r="0" g="255" b="255"/> - <!-- black --> - <Mapping map="3" index="26" r="0" g="0" b="0"/> - <!-- orange --> - <Mapping map="3" index="27" r="255" g="115" b="0"/> - <!-- cornflower blue --> - <Mapping map="3" index="28" r="102" g="128" b="255"/> -<!-- map 4 - Original --> - <!-- white --> - <Mapping map="4" index="0" r="255" g="255" b="255"/> - <!-- geometry --> - <Mapping map="4" index="1" r="0" g="0" b="0"/> - <Mapping map="4" index="2" r="0" g="0" b="0"/> - <Mapping map="4" index="3" r="255" g="0" b="0"/> - <Mapping map="4" index="4" r="0" g="0" b="255"/> - <Mapping map="4" index="5" r="0" g="255" b="0"/> - <Mapping map="4" index="6" r="0" g="0" b="0"/> - <Mapping map="4" index="7" r="255" g="0" b="255"/> - <!-- background --> - <Mapping map="4" index="8" r="0" g="204" b="255"/> - <!-- frames --> - <Mapping map="4" index="9" r="189" g="34" b="50"/> - <Mapping map="4" index="10" r="180" g="180" b="81"/> - <Mapping map="4" index="11" r="33" g="182" b="92"/> - <Mapping map="4" index="12" r="89" g="206" b="223"/> - <Mapping map="4" index="13" r="140" g="40" b="140"/> - <!-- grey --> - <Mapping map="4" index="14" r="153" g="153" b="153"/> - <!-- cells --> - <Mapping map="4" index="15" r="245" g="135" b="138"/> - <Mapping map="4" index="16" r="255" g="255" b="128"/> - <Mapping map="4" index="17" r="123" g="212" b="194"/> - <Mapping map="4" index="18" r="181" g="229" b="251"/> - <Mapping map="4" index="19" r="255" g="128" b="255"/> - <!-- red --> - <Mapping map="4" index="20" r="255" g="0" b="0"/> - <!-- green --> - <Mapping map="4" index="21" r="0" g="255" b="0"/> - <!-- blue --> - <Mapping map="4" index="22" r="0" g="0" b="255"/> - <!-- yellow --> - <Mapping map="4" index="23" r="255" g="255" b="0"/> - <!-- magenta --> - <Mapping map="4" index="24" r="255" g="0" b="255"/> - <!-- cyan --> - <Mapping map="4" index="25" r="0" g="255" b="255"/> - <!-- black --> - <Mapping map="4" index="26" r="0" g="0" b="0"/> - <!-- orange --> - <Mapping map="4" index="27" r="255" g="115" b="0"/> - <!-- cornflower blue --> - <Mapping map="4" index="28" r="102" g="128" b="255"/> -<!-- map 5 - Grey --> - <!-- white --> - <Mapping map="5" index="0" r="255" g="255" b="255"/> - <Mapping map="5" index="1" r="255" g="255" b="255"/> - <Mapping map="5" index="2" r="255" g="255" b="255"/> - <Mapping map="5" index="3" r="255" g="255" b="255"/> - <Mapping map="5" index="4" r="255" g="255" b="255"/> - <Mapping map="5" index="5" r="255" g="255" b="255"/> - <Mapping map="5" index="6" r="255" g="255" b="255"/> - <Mapping map="5" index="7" r="255" g="255" b="255"/> - <!-- grey --> - <Mapping map="5" index="8" r="204" g="204" b="204"/> - <!-- black --> - <Mapping map="5" index="9" r="0" g="0" b="0"/> - <Mapping map="5" index="10" r="0" g="0" b="0"/> - <Mapping map="5" index="11" r="0" g="0" b="0"/> - <Mapping map="5" index="12" r="0" g="0" b="0"/> - <Mapping map="5" index="13" r="0" g="0" b="0"/> - <Mapping map="5" index="14" r="0" g="0" b="0"/> - <Mapping map="5" index="15" r="0" g="0" b="0"/> - <Mapping map="5" index="16" r="0" g="0" b="0"/> - <Mapping map="5" index="17" r="0" g="0" b="0"/> - <Mapping map="5" index="18" r="0" g="0" b="0"/> - <Mapping map="5" index="19" r="0" g="0" b="0"/> - <Mapping map="5" index="20" r="0" g="0" b="0"/> - <Mapping map="5" index="21" r="0" g="0" b="0"/> - <Mapping map="5" index="22" r="0" g="0" b="0"/> - <Mapping map="5" index="23" r="0" g="0" b="0"/> - <Mapping map="5" index="24" r="0" g="0" b="0"/> - <Mapping map="5" index="25" r="0" g="0" b="0"/> - <Mapping map="5" index="26" r="0" g="0" b="0"/> - <Mapping map="5" index="27" r="0" g="0" b="0"/> - <Mapping map="5" index="28" r="0" g="0" b="0"/> -<!-- map 6 - BW --> - <!-- white --> - <Mapping map="6" index="0" r="255" g="255" b="255"/> - <Mapping map="6" index="1" r="255" g="255" b="255"/> - <Mapping map="6" index="2" r="255" g="255" b="255"/> - <Mapping map="6" index="3" r="255" g="255" b="255"/> - <Mapping map="6" index="4" r="255" g="255" b="255"/> - <Mapping map="6" index="5" r="255" g="255" b="255"/> - <Mapping map="6" index="6" r="255" g="255" b="255"/> - <Mapping map="6" index="7" r="255" g="255" b="255"/> - <Mapping map="6" index="8" r="255" g="255" b="255"/> - <!-- black --> - <Mapping map="6" index="9" r="0" g="0" b="0"/> - <Mapping map="6" index="10" r="0" g="0" b="0"/> - <Mapping map="6" index="11" r="0" g="0" b="0"/> - <Mapping map="6" index="12" r="0" g="0" b="0"/> - <Mapping map="6" index="13" r="0" g="0" b="0"/> - <Mapping map="6" index="14" r="0" g="0" b="0"/> - <Mapping map="6" index="15" r="0" g="0" b="0"/> - <Mapping map="6" index="16" r="0" g="0" b="0"/> - <Mapping map="6" index="17" r="0" g="0" b="0"/> - <Mapping map="6" index="18" r="0" g="0" b="0"/> - <Mapping map="6" index="19" r="0" g="0" b="0"/> - <Mapping map="6" index="20" r="0" g="0" b="0"/> - <Mapping map="6" index="21" r="0" g="0" b="0"/> - <Mapping map="6" index="22" r="0" g="0" b="0"/> - <Mapping map="6" index="23" r="0" g="0" b="0"/> - <Mapping map="6" index="24" r="0" g="0" b="0"/> - <Mapping map="6" index="25" r="0" g="0" b="0"/> - <Mapping map="6" index="26" r="0" g="0" b="0"/> - <Mapping map="6" index="27" r="0" g="0" b="0"/> - <Mapping map="6" index="28" r="0" g="0" b="0"/> -<!-- map 7 - HITCOL --> - <Mapping map="7" index="0" r="0" g="0" b="85"/> - <Mapping map="7" index="1" r="0" g="0" b="255"/> - <Mapping map="7" index="2" r="85" g="85" b="170"/> - <Mapping map="7" index="3" r="0" g="170" b="255"/> - <Mapping map="7" index="4" r="0" g="255" b="255"/> - <Mapping map="7" index="5" r="0" g="85" b="85"/> - <Mapping map="7" index="6" r="0" g="85" b="0"/> - <Mapping map="7" index="7" r="0" g="170" b="0"/> - <Mapping map="7" index="8" r="0" g="255" b="0"/> - <Mapping map="7" index="9" r="170" g="255" b="0"/> - <Mapping map="7" index="10" r="255" g="255" b="0"/> - <Mapping map="7" index="11" r="255" g="170" b="0"/> - <Mapping map="7" index="12" r="170" g="85" b="0"/> - <Mapping map="7" index="13" r="255" g="85" b="85"/> - <Mapping map="7" index="14" r="255" g="0" b="0"/> - <Mapping map="7" index="15" r="170" g="0" b="0"/> - <Mapping map="7" index="16" r="85" g="0" b="0"/> - <!-- not used --> - <Mapping map="7" index="17" r="0" g="0" b="0"/> - <Mapping map="7" index="18" r="0" g="0" b="0"/> - <Mapping map="7" index="19" r="0" g="0" b="0"/> - <Mapping map="7" index="20" r="0" g="0" b="0"/> - <Mapping map="7" index="21" r="0" g="0" b="0"/> - <Mapping map="7" index="22" r="0" g="0" b="0"/> - <Mapping map="7" index="23" r="0" g="0" b="0"/> - <Mapping map="7" index="24" r="0" g="0" b="0"/> - <Mapping map="7" index="25" r="0" g="0" b="0"/> - <Mapping map="7" index="26" r="0" g="0" b="0"/> - <Mapping map="7" index="27" r="0" g="0" b="0"/> - <Mapping map="7" index="28" r="0" g="0" b="0"/> -<!-- map 8 - GREY HITCOL --> - <Mapping map="8" index="0" r="255" g="255" b="255"/> - <Mapping map="8" index="1" r="240" g="240" b="240"/> - <Mapping map="8" index="2" r="224" g="224" b="224"/> - <Mapping map="8" index="3" r="208" g="208" b="208"/> - <Mapping map="8" index="4" r="192" g="192" b="192"/> - <Mapping map="8" index="5" r="176" g="176" b="176"/> - <Mapping map="8" index="6" r="160" g="160" b="160"/> - <Mapping map="8" index="7" r="144" g="144" b="144"/> - <Mapping map="8" index="8" r="128" g="128" b="128"/> - <Mapping map="8" index="9" r="112" g="112" b="112"/> - <Mapping map="8" index="10" r="96" g="96" b="96"/> - <Mapping map="8" index="11" r="80" g="80" b="80"/> - <Mapping map="8" index="12" r="64" g="64" b="64"/> - <Mapping map="8" index="13" r="48" g="48" b="48"/> - <Mapping map="8" index="14" r="32" g="32" b="32"/> - <Mapping map="8" index="15" r="16" g="16" b="16"/> - <!-- not used --> - <Mapping map="8" index="16" r="0" g="0" b="0"/> - <Mapping map="8" index="17" r="0" g="0" b="0"/> - <Mapping map="8" index="18" r="0" g="0" b="0"/> - <Mapping map="8" index="19" r="0" g="0" b="0"/> - <Mapping map="8" index="20" r="0" g="0" b="0"/> - <Mapping map="8" index="21" r="0" g="0" b="0"/> - <Mapping map="8" index="22" r="0" g="0" b="0"/> - <Mapping map="8" index="23" r="0" g="0" b="0"/> - <Mapping map="8" index="24" r="0" g="0" b="0"/> - <Mapping map="8" index="25" r="0" g="0" b="0"/> - <Mapping map="8" index="26" r="0" g="0" b="0"/> - <Mapping map="8" index="27" r="0" g="0" b="0"/> - <Mapping map="8" index="28" r="0" g="0" b="0"/> -</colormap> diff --git a/graphics/AtlantisJava/configuration/config.dtd b/graphics/AtlantisJava/configuration/config.dtd deleted file mode 100644 index 189f117e0911fd8e93e72c9852be466b9f5df8d4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/configuration/config.dtd +++ /dev/null @@ -1,169 +0,0 @@ -<!ELEMENT AtlantisConfiguration (Initialization, Parameters,ParameterDifferences*, WindowCorners*)> - -<!ELEMENT Initialization (Interactions, Canvas)> - -<!ELEMENT Interactions (Panel*, InteractionControl+)> - -<!ELEMENT InteractionControl (Panel*)> - <!ATTLIST InteractionControl - projectionName CDATA #REQUIRED - availableInDemoMode CDATA "YES" - defaultInDemoMode CDATA "NO" > - -<!ELEMENT Panel EMPTY> - <!ATTLIST Panel - screenName CDATA #REQUIRED - fileName CDATA #REQUIRED - toolTip CDATA ""> - -<!ELEMENT Canvas (UsedWindow+, Layout+)> - <!ATTLIST Canvas - startupLayout CDATA #REQUIRED - aspectRatio CDATA #REQUIRED> - -<!ELEMENT UsedWindow EMPTY> - <!ATTLIST UsedWindow - name CDATA #REQUIRED - projection CDATA "EP" - group CDATA "Data"> - -<!ELEMENT Layout (Window+, Page+)> - <!ATTLIST Layout - name CDATA #REQUIRED - startup CDATA #REQUIRED - startupWindow CDATA #REQUIRED> - -<!ELEMENT Window EMPTY> - <!ATTLIST Window - name CDATA #REQUIRED - hPos CDATA #REQUIRED - vPos CDATA #REQUIRED - width CDATA #REQUIRED - height CDATA #REQUIRED> - -<!ELEMENT Page EMPTY> - <!ATTLIST Page - name CDATA #REQUIRED - content CDATA #REQUIRED> - -<!ELEMENT Parameters (SuperGroup*)> - <!ATTLIST Parameters - userLevel CDATA #REQUIRED> - -<!ELEMENT SuperGroup (Group*)> - <!ATTLIST SuperGroup - name CDATA #REQUIRED - toolTip CDATA "" - userLevel CDATA "0"> - -<!ELEMENT Group (Command*,((ENUM)*, (SENUM)*, (ICUT)*, (SICUT)*, (FCUT)*, (SFCUT)*, (INT)*, (SINT)*,(LINT)*, (SLINT)*, (FLOAT)*, (SFLOAT)*, (COLOR)*, (SCOLOR)*, (StatusRoot)*, (STATUS)*, (LINK)*)* )> - <!ATTLIST Group - name CDATA #REQUIRED - sname CDATA "" - guiUsage (NO_USE|TABLE|PROJECTION|BRAIN_TEST) "NO_USE" - scope (LOCAL|GLOBAL) "GLOBAL" - userLevel CDATA "0" - toolTip CDATA ""> - -<!ELEMENT Command EMPTY> - <!ATTLIST Command - name CDATA #REQUIRED - command CDATA #REQUIRED - ul CDATA "0" - toolTip CDATA ""> - -<!ENTITY none "0"> - -<!ELEMENT ENUM EMPTY> <!ATTLIST ENUM fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" tip CDATA "" ul CDATA "0" scope CDATA ""> -<!ELEMENT SENUM EMPTY> <!ATTLIST SENUM fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" st (ON|OFF) #REQUIRED tip CDATA "" ul CDATA "0" scope CDATA ""> -<!ELEMENT ICUT EMPTY> <!ATTLIST ICUT fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" isMod (YES|NO) "NO" op CDATA #REQUIRED dop CDATA "" tip CDATA "" ul CDATA "0" scope CDATA "" u CDATA "&none;"> -<!ELEMENT SICUT EMPTY> <!ATTLIST SICUT fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" st (ON|OFF) #REQUIRED isMod (YES|NO) "NO" op CDATA #REQUIRED dop CDATA "" tip CDATA "" ul CDATA "0" scope CDATA "" u CDATA "&none;"> -<!ELEMENT FCUT EMPTY> <!ATTLIST FCUT fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" isMod (YES|NO) "NO" op CDATA #REQUIRED dop CDATA "" tip CDATA "" ul CDATA "0" scope CDATA "" u CDATA "&none;"> -<!ELEMENT SFCUT EMPTY> <!ATTLIST SFCUT fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" st (ON|OFF) #REQUIRED isMod (YES|NO) "NO" op CDATA #REQUIRED dop CDATA "" tip CDATA "" ul CDATA "0" scope CDATA "" u CDATA "&none;"> -<!ELEMENT INT EMPTY> <!ATTLIST INT fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" isMod (YES|NO) "NO" tip CDATA "" ul CDATA "0" scope CDATA "" u CDATA "&none;"> -<!ELEMENT SINT EMPTY> <!ATTLIST SINT fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" st (ON|OFF) #REQUIRED isMod (YES|NO) "NO" tip CDATA "" ul CDATA "0" scope CDATA "" u CDATA "&none;"> -<!ELEMENT FLOAT EMPTY> <!ATTLIST FLOAT fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" isMod (YES|NO) "NO" tip CDATA "" ul CDATA "0" scope CDATA "" u CDATA "&none;"> -<!ELEMENT SFLOAT EMPTY> <!ATTLIST SFLOAT fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" st (ON|OFF) #REQUIRED isMod (YES|NO) "NO" tip CDATA "" ul CDATA "0" scope CDATA "" u CDATA "&none;"> -<!ELEMENT LINT EMPTY> <!ATTLIST LINT fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" tip CDATA "" ul CDATA "0" scope CDATA "" u CDATA "&none;"> -<!ELEMENT SLINT EMPTY> <!ATTLIST SLINT fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" st (ON|OFF) #REQUIRED tip CDATA "" ul CDATA "0" scope CDATA "" u CDATA "&none;"> -<!ELEMENT COLOR EMPTY> <!ATTLIST COLOR fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" tip CDATA "" ul CDATA "0" scope CDATA ""> -<!ELEMENT SCOLOR EMPTY> <!ATTLIST SCOLOR fn CDATA #REQUIRED sn CDATA "" va CDATA #REQUIRED pv CDATA "-inf : inf" st (ON|OFF) #REQUIRED tip CDATA "" ul CDATA "0" scope CDATA ""> -<!ELEMENT StatusRoot (StatusGroup*, STATUS*)> <!ATTLIST StatusRoot fn CDATA #REQUIRED sn CDATA "" st (ON|OFF) "OFF" tip CDATA "" ul CDATA "0" scope CDATA ""> -<!ELEMENT StatusGroup (StatusGroup*, STATUS*)> <!ATTLIST StatusGroup fn CDATA #REQUIRED sn CDATA "" st (ON|OFF) "OFF" tip CDATA "" ul CDATA "0" scope CDATA ""> -<!ELEMENT STATUS EMPTY> <!ATTLIST STATUS fn CDATA #REQUIRED sn CDATA "" st (ON|OFF) #REQUIRED tip CDATA "" ul CDATA "0" scope CDATA ""> -<!ELEMENT LINK EMPTY> <!ATTLIST LINK to CDATA #REQUIRED> - -<!ELEMENT ParameterDifferences (DIFFERENCE*)> - -<!ELEMENT DIFFERENCE EMPTY> - <!ATTLIST DIFFERENCE - group CDATA #REQUIRED - name CDATA #REQUIRED - windowName CDATA "*" - va CDATA "" - st CDATA "" - op CDATA ""> - -<!ELEMENT WindowCorners (CORNERS*)> - -<!ELEMENT CORNERS EMPTY> - <!ATTLIST CORNERS - windowName CDATA #REQUIRED - x0 CDATA #REQUIRED - y0 CDATA #REQUIRED - x1 CDATA #REQUIRED - y1 CDATA #REQUIRED - x2 CDATA #REQUIRED - y2 CDATA #REQUIRED> - -<!ENTITY length "1"> -<!ENTITY energy "2"> -<!ENTITY energyMEV "3"> - -<!ENTITY user "0"> -<!ENTITY superuser "1"> -<!ENTITY debug "3"> - -<!ENTITY assocCutOptions "All=0, Connected=1, Unconnected=2"> -<!ENTITY drawTo "Pixels = 0, Silicon Strips = 1, TRT_DriftCircle=2, LAr = 3, TILE = 4, Muon System = 5"> -<!ENTITY colorFn "Constant = 0, Simulated Track = 1, Reconstructed Track = 2, SubDetector = 3, Track Segment = 4"> -<!ENTITY colorFnTRT "Constant = 0, Simulated Track = 1, Reconstructed Track = 2, SubDetector = 3, Track Segment = 4, isOutlier = 5, driftSign = 6, threshold = 7"> -<!ENTITY colorFnMTr "Constant = 0, Index = 1, Pt = 2"> -<!ENTITY colorFnCal "Constant = 0, SubDetector = 1, Cluster = 2, Layer = 3, Energy = 4, Jet = 5, ECAL/HCAL = 6, Time = 7"> -<!ENTITY colorFnS3D "Constant = 0, Simulated Track = 1, Reconstructed Track = 2, SubDetector = 3, Group = 4, Layer = 5"> -<!ENTITY colorFnTrigS3D "Constant = 0, Simulated Track = 1, Reconstructed Track = 2, SubDetector = 3, Layer = 4"> -<!ENTITY colorFnSiCluster "Constant = 0, Simulated Track = 1, Reconstructed Track = 2, SubDetector = 3, Layer = 4, Orientation=5"> -<!ENTITY colorFnPixCluster "Constant = 0, Simulated Track = 1, Reconstructed Track = 2, SubDetector = 3, Layer = 4, Orientation=5, dE/dx=6"> -<!ENTITY colorFnSTr "Constant = 0, Index = 1, Pt = 2, Particle Type = 3, Origin Vertex = 4"> -<!ENTITY colorFnRTr "Constant = 0, Index = 1, Pt = 2, Collection = 3, Simulated Track = 4, RecVertex = 5, Objects = 7"> -<!ENTITY colorFnBasic "Constant = 0, Index = 1"> -<!ENTITY colorFnBasicVtx "Constant = 0, Index = 1 , VertexType = 2"> -<!ENTITY colorFnBasicCollection "Constant = 0, Index = 1, Collection = 2"> -<!ENTITY colorFnBasicCollectionBJets "Constant = 0, Index = 1, Collection = 2, BJets = 3"> - -<!ENTITY energyMode "Sum (Linear) = 0, Max (Linear) = 1, Sum (Logarithmic) = 2, Max (Logarithmic) = 3, Sum (Square Root) = 4, Max (Square Root) = 5"> -<!ENTITY symbol "Filled Square=0,Filled Circle=4,Horizontal Line=1,Vertical Line=2,Plus=3"> -<!ENTITY pickingModes "Event Data=0, Detectors=1"> -<!ENTITY frameCol "0,8:14"> -<!ENTITY detectCol "0:8,14"> -<!ENTITY dataCol "0,8,14:28"> -<!ENTITY histoCol "0,8,14:28"> -<!ENTITY real "<,>"> -<!ENTITY eta "η"> -<!ENTITY rho "ρ"> -<!ENTITY phi "Φ"> -<!ENTITY delta "Δ"> -<!ENTITY lambda "λ"> -<!ENTITY sigma "σ"> -<!ENTITY prime "'"> -<!ENTITY ne "!="> -<!ENTITY le "<="> -<!ENTITY ge ">="> -<!ENTITY int "=,≠,<,≤,>,≥"> -<!ENTITY intEqual "="> -<!ENTITY modesFZ "Standard = 0, RPC Middle 1 = 1, RPC Middle 2 = 2, RPC Outer = 3, MDT Inner and Extension = 4, MDT Middle = 5, MDT Outer = 6"> -<!ENTITY modesYX "Standard = 0, TGC Inner 1 = 1,TGC Middle 1 = 2, TGC Middle 2 = 3, TGC Middle 3 = 4, MDT/CSC Inner 1 = 5, MDT Extension = 6, MDT Middle = 7, MDT Outer = 8, FCAL EM= 9, FCAL HAD 1= 10, FCAL HAD 2= 11, LAr Ecap Presamp= 12, LAr Ecap 1= 13, LAr Ecap 2= 14, LAr Ecap 3= 15, HEC 1= 16, HEC 2= 17, HEC 3= 18, HEC 4= 19, LAr Ecap Summed=20, HEC Summed=21, MBTS=22"> - -<!-- Entities for including blocks of common data --> -<!ENTITY CommonInteractions SYSTEM "common-interactions.xml"> -<!ENTITY CommonParameters SYSTEM "common-parameters.xml"> diff --git a/graphics/AtlantisJava/configuration/epusti.csv b/graphics/AtlantisJava/configuration/epusti.csv deleted file mode 100644 index 0c0b9051835d8c6c1c35fa69c6df0141d3f0a592..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/configuration/epusti.csv +++ /dev/null @@ -1,5 +0,0 @@ -# Event Properties User Selected Trigger Items - -# example: "L1_EM7, L2_e10, EF_e10, L2_g10, EF_g10, L1_J70, EF_tau100" - -"" \ No newline at end of file diff --git a/graphics/AtlantisJava/configuration/pdg.xml b/graphics/AtlantisJava/configuration/pdg.xml deleted file mode 100755 index 20f87414de8996681a5f01779d208cdc48960a0b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/configuration/pdg.xml +++ /dev/null @@ -1,109 +0,0 @@ -<?xml version="1.0"?> - -<!DOCTYPE PDG [ - - <!ELEMENT PDG (Particle*)> - - <!ELEMENT Particle EMPTY> - - <!ATTLIST Particle - charge (-1 | 0 | 1 | 10) #REQUIRED - type CDATA #REQUIRED - code CDATA #REQUIRED - name CDATA #REQUIRED - > - - <!-- - charge = 10 : unknown particle or bug - --> - - <!ENTITY eta "η"> - <!ENTITY rho "ρ"> - <!ENTITY phi "Φ"> - <!ENTITY delta "Δ"> - <!ENTITY pi "π"> - <!ENTITY sigma "Σ"> - <!ENTITY tau "τ"> - <!ENTITY xi "Ξ"> - <!ENTITY omega "Ω"> - <!ENTITY mu "μ"> - <!ENTITY gamma "γ"> - <!ENTITY nu "ν"> - <!ENTITY lambda "Λ"> - <!ENTITY psi "ψ"> - <!ENTITY upsilon "Υ"> - -]> - -<PDG> - - <!-- - 'type' used for InDet selection cuts - --> - - <Particle charge="10" type="0" code="1" name="unknown" /> - <Particle charge="10" type="0" code="0" name="Bug" /> - - <Particle charge="1" type="1" code="211" name="π" /> - <Particle charge="1" type="1" code="2212" name="Proton" /> - <Particle charge="1" type="1" code="321" name="K" /> - <Particle charge="1" type="1" code="3222" name="σ" /> - <Particle charge="-1" type="1" code="3112" name="Anti-σ" /> - <Particle charge="1" type="1" code="411" name="D" /> - <Particle charge="1" type="1" code="431" name="Ds" /> - <Particle charge="-1" type="1" code="3312" name="ξ" /> - <Particle charge="-1" type="1" code="3334" name="ω" /> - <Particle charge="-1" type="2" code="15" name="τ" /> - <Particle charge="-1" type="3" code="11" name="e" /> - <Particle charge="-1" type="4" code="13" name="μ" /> - <Particle charge="0" type="5" code="111" name="π0" /> - <Particle charge="0" type="5" code="2112" name="Neutron" /> - <Particle charge="0" type="5" code="130" name="K0_L" /> - <Particle charge="0" type="5" code="310" name="K0_S" /> - <Particle charge="0" type="5" code="3212" name="σ0" /> - <Particle charge="0" type="5" code="221" name="η" /> - <Particle charge="0" type="5" code="3122" name="λ" /> - <Particle charge="0" type="5" code="3322" name="ξ0" /> - <Particle charge="0" type="5" code="421" name="D0" /> - <Particle charge="0" type="6" code="22" name="γ" /> - <Particle charge="0" type="7" code="12" name="ν" /> - <Particle charge="0" type="7" code="14" name="ν" /> - <Particle charge="0" type="7" code="16" name="ν" /> - <Particle charge="0" type="7" code="1000022" name="neutralino" /> - <Particle charge="0" type="7" code="1000039" name="gravitino" /> - <Particle charge="0" type="8" code="1" name="u" /> - <Particle charge="0" type="8" code="2" name="d" /> - <Particle charge="0" type="8" code="3" name="s" /> - <Particle charge="0" type="8" code="4" name="c" /> - <Particle charge="0" type="8" code="5" name="b" /> - <Particle charge="0" type="8" code="6" name="t" /> - <Particle charge="-1" type="9" code="1000015" name="stau" /> - <Particle charge="-1" type="9" code="2000011" name="selectron" /> - <Particle charge="-1" type="9" code="2000013" name="smuon" /> - <Particle charge="1" type="10" code="24" name="W" /> - <Particle charge="-1" type="11" code="601" name="From Ntuple: d" /> - <Particle charge="1" type="11" code="602" name="From Ntuple: u" /> - <Particle charge="-1" type="11" code="603" name="From Ntuple: s" /> - <Particle charge="1" type="11" code="604" name="From Ntuple: c" /> - <Particle charge="-1" type="11" code="605" name="From Ntuple: b" /> - <Particle charge="1" type="11" code="606" name="From Ntuple: t" /> - <Particle charge="0" type="12" code="21" name="gluon" /> - <Particle charge="0" type="13" code="23" name="Z" /> - - <!-- - fragmentation types - --> - - <Particle charge="0" type="14" code="91" name="cluster fragmentation" /> - <Particle charge="0" type="14" code="92" name="string fragmentation" /> - <Particle charge="0" type="14" code="93" name="independent fragmentation" /> - - <!-- - extra particles (Higgs (h0), J/psi, upsilon) - --> - - <Particle charge="0" type="15" code="25" name="h0" /> - <Particle charge="0" type="15" code="443" name="J/ψ" /> - <Particle charge="0" type="15" code="553" name="υ" /> - -</PDG> diff --git a/graphics/AtlantisJava/configuration/rpsplt_fcal.csv b/graphics/AtlantisJava/configuration/rpsplt_fcal.csv deleted file mode 100644 index f5c29d69492368c1ccc22a696aa4dc0d2eb1d377..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/configuration/rpsplt_fcal.csv +++ /dev/null @@ -1,498 +0,0 @@ -# Real Pulse Shape Plots Lookup Table values for FCAL calorimeter - - -# FCAL, lookup table layer 0, amplitude values -FCAL_LAYER0_AMPLITUDE - "0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.00145f, -0.0002f, -0.00052f, - -9e-05f, 0.00017f, 0.00022f, 3e-05f, -0.00031f, - -0.00061f, -0.00046f, -0.00033f, 0.00012f, -0.00013f, - -0.00025f, -0.0005f, -0.00038f, -0.00035f, -0.0002f, - -0.00042f, -0.00031f, -0.00022f, 0.0001f, -0.00017f, - -0.00033f, 0.00028f, 0.00017f, 2e-05f, 9e-05f, - -0.00018f, -0.00023f, 6e-05f, -3e-05f, -0.00037f, - -0.00029f, -0.00021f, -0.00042f, -0.00047f, -0.00032f, - -0.00041f, -0.0002f, 0.0001f, 0.00032f, 0.0006f, - 0.00147f, 0.00234f, 0.00409f, 0.00701f, 0.01124f, - 0.01704f, 0.02441f, 0.0349f, 0.04655f, 0.06027f, - 0.07674f, 0.09489f, 0.11624f, 0.13948f, 0.16603f, - 0.19516f, 0.22665f, 0.25946f, 0.29534f, 0.3334f, - 0.37421f, 0.41508f, 0.45488f, 0.49473f, 0.53529f, - 0.5759f, 0.61356f, 0.65022f, 0.68584f, 0.72121f, - 0.75454f, 0.78585f, 0.81642f, 0.84443f, 0.8694f, - 0.89244f, 0.9134f, 0.93157f, 0.94811f, 0.96263f, - 0.9756f, 0.98573f, 0.99294f, 0.99721f, 0.99958f, - 0.99937f, 0.99596f, 0.99067f, 0.98339f, 0.97312f, - 0.96037f, 0.94624f, 0.93069f, 0.9126f, 0.89226f, - 0.87097f, 0.84789f, 0.82241f, 0.79715f, 0.7696f, - 0.74111f, 0.713f, 0.68302f, 0.65322f, 0.62221f, - 0.58901f, 0.55499f, 0.52119f, 0.48651f, 0.45161f, - 0.41474f, 0.37863f, 0.34418f, 0.31038f, 0.2759f, - 0.24106f, 0.20725f, 0.17425f, 0.14223f, 0.10914f, - 0.07784f, 0.04664f, 0.01518f, -0.01539f, -0.04403f, - -0.07252f, -0.1007f, -0.12714f, -0.15365f, -0.17955f, - -0.20587f, -0.23009f, -0.25359f, -0.27704f, -0.29989f, - -0.32317f, -0.34403f, -0.3634f, -0.3812f, -0.39806f, - -0.41503f, -0.42994f, -0.4448f, -0.45808f, -0.46945f, - -0.47926f, -0.48934f, -0.50054f, -0.51152f, -0.52073f, - -0.52908f, -0.53691f, -0.5431f, -0.55034f, -0.55776f, - -0.56445f, -0.56952f, -0.57341f, -0.57756f, -0.58138f, - -0.58532f, -0.58718f, -0.58934f, -0.5898f, -0.59049f, - -0.59047f, -0.5886f, -0.58601f, -0.58368f, -0.58009f, - -0.57595f, -0.56963f, -0.55958f, -0.54925f, -0.5387f, - -0.52797f, -0.5171f, -0.50614f, -0.49513f, -0.4841f, - -0.47308f, -0.46212f, -0.45122f, -0.44041f, -0.42973f, - -0.41916f, -0.40875f, -0.39851f, -0.38846f, -0.37862f, - -0.36901f, -0.35965f, -0.35054f, -0.34168f, -0.33306f, - -0.32471f, -0.31661f, -0.30876f, -0.30117f, -0.29382f, - -0.28672f, -0.27987f, -0.27327f, -0.2669f, -0.26077f, - -0.25487f, -0.2492f, -0.24375f, -0.23855f, -0.23358f, - -0.22884f, -0.22433f, -0.22007f, -0.21602f, -0.21221f, - -0.20861f, -0.20521f, -0.20199f, -0.19895f, -0.19609f, - -0.19337f, -0.19079f, -0.18833f, -0.186f, -0.18376f, - -0.1816f, -0.17953f, -0.17753f, -0.17557f, -0.17367f, - -0.1718f, -0.16996f, -0.16814f, -0.16634f, -0.16454f, - -0.16276f, -0.16097f, -0.15917f, -0.15737f, -0.15555f, - -0.15372f, -0.15186f, -0.14997f, -0.14801f, -0.14599f, - -0.14389f, -0.1417f, -0.13943f, -0.13712f, -0.13482f, - -0.13255f, -0.13036f, -0.12824f, -0.12623f, -0.12429f, - -0.12243f, -0.12061f, -0.11882f, -0.11704f, -0.11527f, - -0.11349f, -0.11167f, -0.10983f, -0.10794f, -0.10603f, - -0.10406f, -0.10205f, -0.1f, -0.09791f, -0.09578f, - -0.09361f, -0.09141f, -0.08918f, -0.08694f, -0.08466f, - -0.08238f, -0.08009f, -0.0778f, -0.0755f, -0.07321f, - -0.07093f, -0.06867f, -0.06642f, -0.06421f, -0.06202f, - -0.05986f, -0.05774f, -0.05566f, -0.0536f, -0.05158f, - -0.04959f, -0.04764f, -0.04572f, -0.04385f, -0.04203f, - -0.04025f, -0.03853f, -0.03687f, -0.03526f, -0.0337f, - -0.03218f, -0.03072f, -0.0293f, -0.02794f, -0.02663f, - -0.02536f, -0.02413f, -0.02294f, -0.02181f, -0.0207f, - -0.01964f, -0.01861f, -0.01761f, -0.01665f, -0.01573f, - -0.01484f, -0.01399f, -0.01319f, -0.01242f, -0.01168f, - -0.011f, -0.01034f, -0.00973f, -0.00914f, -0.00861f, - -0.00808f, -0.00761f, -0.00716f, -0.00673f, -0.00632f, - -0.00595f, -0.00559f, -0.00526f, -0.00494f, -0.00464f, - -0.00436f, -0.00409f, -0.00383f, -0.00359f, -0.00335f, - -0.00312f, -0.00291f, -0.00271f, -0.00252f, -0.00234f, - -0.00219f, -0.00204f, -0.0019f, -0.00174f, -0.00158f, - -0.00139f, -0.00118f, -0.00094f, -0.00068f, -0.00042f, - -0.00016f, 8e-05f, 0.00032f, 0.00052f, 0.0007f, - 0.00088f, 0.00102f, 0.00114f, 0.0013f, 0.0014f, - 0.00148f, 0.00159f, 0.00171f, 0.0018f, 0.00191f, - 0.00197f, 0.00207f, 0.00218f, 0.00232f, 0.00243f, - 0.00254f, 0.00267f, 0.0028f, 0.00292f, 0.00305f, - 0.00318f, 0.00331f, 0.00347f, 0.00363f, 0.00376f, - 0.00388f, 0.00405f, 0.00421f, 0.00433f, 0.00446f, - 0.00458f, 0.00473f, 0.00488f, 0.00497f, 0.00514f, - 0.00522f, 0.00538f, 0.00553f, 0.00563f, 0.00573f, - 0.00588f, 0.00596f, 0.00608f, 0.0062f, 0.00629f, - 0.00636f, 0.00646f, 0.00654f, 0.00663f, 0.00669f, - 0.00674f, 0.00679f, 0.00688f, 0.00688f, 0.00696f, - 0.00702f, 0.00704f, 0.00711f, 0.00712f, 0.0072f, - 0.0072f, 0.00727f, 0.00729f, 0.00729f, 0.00737f, - 0.00737f, 0.00737f, 0.00737f, 0.00746f, 0.00746f, - 0.00746f, 0.00746f, 0.00746f, 0.00746f, 0.00746f, - 0.00746f, 0.00746f, 0.00737f, 0.00737f, 0.00737f, - 0.00737f, 0.00737f, 0.00737f, 0.00729f, 0.00729f, - 0.00729f, 0.00729f, 0.00729f, 0.0072f, 0.0072f, - 0.00717f, 0.00712f, 0.00708f, 0.00704f, 0.00704f, - 0.00696f, 0.00696f, 0.00696f, 0.00696f, 0.00696f, - 0.00696f, 0.00696f, 0.00696f, 0.00696f, 0.00696f, - 0.00688f, 0.00688f, 0.00688f, 0.00688f, 0.00688f, - 0.00684f, 0.00679f, 0.00679f, 0.00679f, 0.00671f, - 0.00671f, 0.00671f, 0.00671f, 0.00663f, 0.00663f, - 0.00663f, 0.00663f, 0.00659f, 0.00655f, 0.00655f, - 0.00655f, 0.00655f, 0.00655f, 0.00651f, 0.00646f, - 0.00646f, 0.00646f, 0.00646f, 0.00646f, 0.00646f, - 0.00646f, 0.00646f, 0.00639f, 0.00638f, 0.00638f, - 0.00638f, 0.00638f, 0.00638f, 0.00638f, 0.00638f, - 0.00638f, 0.00638f, 0.00638f, 0.00638f, 0.0063f, - 0.00629f, 0.00629f, 0.00629f, 0.00629f, 0.00629f, - 0.00629f, 0.00629f, 0.00629f, 0.00629f, 0.00622f, - 0.00622f, 0.00622f, 0.00622f, 0.00622f, 0.00622f, - 0.00622f, 0.00622f, 0.00612f, 0.00612f, 0.00612f, - 0.00612f, 0.00612f, 0.00612f, 0.00612f, 0.00612f, - 0.00606f, 0.00605f, 0.00605f, 0.00605f, 0.00605f, - 0.00605f, 0.00605f, 0.00601f, 0.00596f, 0.00596f, - 0.00596f, 0.00596f, 0.00596f, 0.00596f, 0.00596f, - 0.00588f, 0.00588f, 0.00588f, 0.00588f, 0.00588f, - 0.00588f, 0.00585f, 0.00579f, 0.00579f, 0.00579f, - 0.00579f, 0.00579f, 0.00572f, 0.00572f, 0.00572f, - 0.00572f, 0.00572f, 0.00572f, 0.00572f, 0.00572f, - 0.00572f, 0.00563f, 0.00563f, 0.00563f, 0.00563f, - 0.00563f, 0.00563f, 0.00563f, 0.00563f, 0.00563f, - 0.00563f, 0.00563f, 0.00563f, 0.00563f, 0.00563f" - - -# FCAL lookup table layer 1, amplitude values -FCAL_LAYER1_AMPLITUDE - "0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, -0.00014f, - -0.00015f, -0.00019f, -0.00024f, -2e-05f, 8e-05f, - 0.00012f, -3e-05f, -0.00012f, -0.00011f, -0.0002f, - -4e-05f, 7e-05f, 5e-05f, -1e-05f, -9e-05f, - -3e-05f, -0.00012f, -3e-05f, -3e-05f, -1e-05f, - -3e-05f, -1e-05f, -0.00011f, -0.00021f, -0.00017f, - -0.00016f, -6e-05f, 1e-05f, 1e-05f, -3e-05f, - -0.00018f, -0.0002f, -0.00018f, -8e-05f, -2e-05f, - -5e-05f, 0.00011f, 4e-05f, 0.00032f, 0.00076f, - 0.00136f, 0.00271f, 0.00417f, 0.00696f, 0.01099f, - 0.01602f, 0.02229f, 0.02963f, 0.03936f, 0.05282f, - 0.06928f, 0.08819f, 0.10857f, 0.12914f, 0.15221f, - 0.17682f, 0.20343f, 0.23335f, 0.26583f, 0.29864f, - 0.33272f, 0.36835f, 0.40457f, 0.44149f, 0.47595f, - 0.51049f, 0.54648f, 0.5816f, 0.61676f, 0.65114f, - 0.68367f, 0.7141f, 0.74147f, 0.76915f, 0.79855f, - 0.82565f, 0.85105f, 0.87379f, 0.89366f, 0.9111f, - 0.927f, 0.94162f, 0.95496f, 0.96664f, 0.97688f, - 0.98534f, 0.99109f, 0.99601f, 0.99887f, 0.99964f, - 0.99962f, 0.99681f, 0.99299f, 0.98726f, 0.98f, - 0.97158f, 0.96249f, 0.95187f, 0.9393f, 0.92385f, - 0.90628f, 0.88827f, 0.86996f, 0.85269f, 0.83453f, - 0.81503f, 0.79519f, 0.77368f, 0.74984f, 0.72628f, - 0.70228f, 0.67716f, 0.65181f, 0.62399f, 0.59774f, - 0.57129f, 0.54263f, 0.51398f, 0.48417f, 0.45309f, - 0.42268f, 0.39325f, 0.36432f, 0.33302f, 0.29777f, - 0.26282f, 0.22816f, 0.19507f, 0.16394f, 0.13389f, - 0.10437f, 0.07385f, 0.04319f, 0.01199f, -0.01883f, - -0.04912f, -0.07801f, -0.10802f, -0.13734f, -0.16453f, - -0.19169f, -0.2182f, -0.24487f, -0.27109f, -0.29671f, - -0.32083f, -0.34391f, -0.36456f, -0.38568f, -0.40796f, - -0.428f, -0.44835f, -0.46643f, -0.48286f, -0.49816f, - -0.51161f, -0.5248f, -0.5374f, -0.54928f, -0.5608f, - -0.57103f, -0.57868f, -0.58697f, -0.59288f, -0.59803f, - -0.60282f, -0.60532f, -0.60756f, -0.60862f, -0.60882f, - -0.60828f, -0.60572f, -0.60473f, -0.60353f, -0.60196f, - -0.6001f, -0.59736f, -0.59308f, -0.58847f, -0.5836f, - -0.57846f, -0.57308f, -0.56749f, -0.56171f, -0.55576f, - -0.54966f, -0.54343f, -0.5371f, -0.53066f, -0.52415f, - -0.51757f, -0.51094f, -0.50428f, -0.4976f, -0.4909f, - -0.4842f, -0.47749f, -0.47078f, -0.4641f, -0.45745f, - -0.45081f, -0.44422f, -0.43769f, -0.43118f, -0.42475f, - -0.41838f, -0.41207f, -0.40583f, -0.39965f, -0.39355f, - -0.38752f, -0.38156f, -0.37568f, -0.36988f, -0.36414f, - -0.35848f, -0.35292f, -0.34744f, -0.34205f, -0.33676f, - -0.33155f, -0.32642f, -0.32135f, -0.31634f, -0.31139f, - -0.30648f, -0.30164f, -0.29688f, -0.29227f, -0.28779f, - -0.28349f, -0.27937f, -0.27541f, -0.2716f, -0.26792f, - -0.26432f, -0.26084f, -0.25743f, -0.25406f, -0.25074f, - -0.24743f, -0.24413f, -0.24086f, -0.23757f, -0.23428f, - -0.23096f, -0.22764f, -0.22429f, -0.22092f, -0.21754f, - -0.21414f, -0.21072f, -0.20729f, -0.20385f, -0.20038f, - -0.19692f, -0.19344f, -0.18993f, -0.18644f, -0.18293f, - -0.17943f, -0.17592f, -0.17244f, -0.16898f, -0.16553f, - -0.16211f, -0.1587f, -0.15533f, -0.15198f, -0.14866f, - -0.14538f, -0.14213f, -0.13891f, -0.13573f, -0.13259f, - -0.12948f, -0.12641f, -0.1234f, -0.12042f, -0.11747f, - -0.11457f, -0.11173f, -0.10891f, -0.10617f, -0.10345f, - -0.10079f, -0.09819f, -0.09562f, -0.09311f, -0.09065f, - -0.08823f, -0.08586f, -0.08354f, -0.08125f, -0.07903f, - -0.07685f, -0.07471f, -0.07262f, -0.07057f, -0.06857f, - -0.06662f, -0.06471f, -0.06284f, -0.06102f, -0.05926f, - -0.05751f, -0.05582f, -0.05416f, -0.05254f, -0.05096f, - -0.04942f, -0.04792f, -0.04647f, -0.04507f, -0.04369f, - -0.04235f, -0.04104f, -0.03974f, -0.03845f, -0.03717f, - -0.03591f, -0.03467f, -0.03347f, -0.03231f, -0.03119f, - -0.03012f, -0.0291f, -0.02812f, -0.02718f, -0.02629f, - -0.02542f, -0.0246f, -0.02381f, -0.02304f, -0.0223f, - -0.02157f, -0.02088f, -0.0202f, -0.01953f, -0.01888f, - -0.01824f, -0.01761f, -0.017f, -0.0164f, -0.0158f, - -0.01523f, -0.01466f, -0.0141f, -0.01355f, -0.01301f, - -0.01247f, -0.01195f, -0.01141f, -0.0109f, -0.01039f, - -0.00989f, -0.0094f, -0.0089f, -0.00842f, -0.00796f, - -0.0075f, -0.00705f, -0.0066f, -0.00616f, -0.00575f, - -0.00533f, -0.00493f, -0.00452f, -0.00413f, -0.00375f, - -0.00338f, -0.003f, -0.00265f, -0.00228f, -0.00195f, - -0.00162f, -0.00128f, -0.00096f, -0.00064f, -0.00035f, - -5e-05f, 0.00023f, 0.0005f, 0.00079f, 0.00105f, - 0.00131f, 0.00156f, 0.00181f, 0.00201f, 0.0023f, - 0.0025f, 0.00267f, 0.00287f, 0.00315f, 0.00335f, - 0.00346f, 0.00367f, 0.0039f, 0.0041f, 0.00421f, - 0.00441f, 0.00458f, 0.00473f, 0.0049f, 0.00505f, - 0.00516f, 0.00522f, 0.00537f, 0.00551f, 0.00552f, - 0.00569f, 0.00579f, 0.0059f, 0.00601f, 0.00615f, - 0.00628f, 0.00632f, 0.00648f, 0.00653f, 0.00664f, - 0.00679f, 0.0068f, 0.00696f, 0.00696f, 0.007f, - 0.00711f, 0.00711f, 0.00724f, 0.00728f, 0.00728f, - 0.00728f, 0.00743f, 0.00743f, 0.00743f, 0.00743f, - 0.00744f, 0.00759f, 0.00759f, 0.00759f, 0.00759f, - 0.00759f, 0.00759f, 0.00774f, 0.00775f, 0.00775f, - 0.00775f, 0.00775f, 0.00775f, 0.00775f, 0.00775f, - 0.00789f, 0.00791f, 0.00791f, 0.00791f, 0.00791f, - 0.00791f, 0.00791f, 0.00791f, 0.00791f, 0.00791f, - 0.00791f, 0.00792f, 0.00807f, 0.00807f, 0.00807f, - 0.00807f, 0.00807f, 0.00807f, 0.00807f, 0.00807f, - 0.00807f, 0.00807f, 0.00807f, 0.00807f, 0.00807f, - 0.00807f, 0.00807f, 0.00807f, 0.00807f, 0.00807f, - 0.00807f, 0.00807f, 0.00807f, 0.00807f, 0.00807f, - 0.00807f, 0.00807f, 0.00807f, 0.00807f, 0.00807f, - 0.00807f, 0.00807f, 0.00807f, 0.00807f, 0.00807f, - 0.00807f, 0.00807f, 0.00807f, 0.00807f, 0.00807f, - 0.00807f, 0.00807f, 0.00807f, 0.00791f, 0.00791f, - 0.00791f, 0.00791f, 0.00791f, 0.00791f, 0.00791f, - 0.00791f, 0.00791f, 0.00791f, 0.00791f, 0.00791f, - 0.00791f, 0.00791f, 0.00791f, 0.00791f, 0.00791f, - 0.00791f, 0.00775f, 0.00775f, 0.00775f, 0.00775f, - 0.00775f, 0.00775f, 0.00775f, 0.00775f, 0.00775f, - 0.00775f, 0.00775f, 0.00775f, 0.00775f, 0.0076f, - 0.00759f, 0.00759f, 0.00759f, 0.00759f, 0.00759f, - 0.00759f, 0.00759f, 0.00759f, 0.00759f, 0.00759f, - 0.00759f, 0.00753f, 0.00743f, 0.00743f, 0.00743f, - 0.00743f, 0.00743f, 0.00743f, 0.00743f, 0.00743f, - 0.00743f, 0.00743f, 0.00743f, 0.00743f, 0.00743f, - 0.00728f, 0.00728f, 0.00728f, 0.00728f, 0.00728f, - 0.00728f, 0.00728f, 0.00728f, 0.00728f, 0.00728f, - 0.00728f, 0.00728f, 0.00728f, 0.00727f, 0.00711f, - 0.00711f, 0.00711f, 0.00711f, 0.00711f, 0.00711f, - 0.00711f, 0.00711f, 0.00711f, 0.00711f, 0.00711f, - 0.00711f, 0.00711f, 0.00711f, 0.00711f, 0.00711f" - - -# FCAL lookup table layer 2, amplitude values -FCAL_LAYER2_AMPLITUDE - "0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, -0.00128f, -0.00011f, 0.00018f, 2e-05f, - 0.00012f, -6e-05f, -5e-05f, -4e-05f, -4e-05f, - -6e-05f, -0.00031f, 3e-05f, -0.00022f, 7e-05f, - -3e-05f, 2e-05f, 0.00011f, 9e-05f, -0.00025f, - -5e-05f, -0.00026f, -3e-05f, -3e-05f, -5e-05f, - -3e-05f, 8e-05f, 0.00016f, 0.00025f, 0.00015f, - 0.00018f, 9e-05f, -0.00016f, -0.00017f, 0.00012f, - 0.00031f, 0.00061f, 0.00137f, 0.00259f, 0.00487f, - 0.00807f, 0.01106f, 0.01611f, 0.02298f, 0.03195f, - 0.04154f, 0.05328f, 0.06624f, 0.08155f, 0.09926f, - 0.11723f, 0.13765f, 0.16233f, 0.18937f, 0.21701f, - 0.24599f, 0.27675f, 0.30806f, 0.34205f, 0.3763f, - 0.40922f, 0.44335f, 0.47795f, 0.51151f, 0.54584f, - 0.58035f, 0.61246f, 0.64345f, 0.67427f, 0.70516f, - 0.73373f, 0.75953f, 0.78417f, 0.80817f, 0.83037f, - 0.85125f, 0.87108f, 0.88998f, 0.9072f, 0.92291f, - 0.93755f, 0.95053f, 0.96236f, 0.97239f, 0.9802f, - 0.9869f, 0.99293f, 0.99661f, 0.99861f, 0.99968f, - 0.99958f, 0.99822f, 0.99567f, 0.9913f, 0.98539f, - 0.97946f, 0.97165f, 0.96321f, 0.95356f, 0.943f, - 0.93288f, 0.92124f, 0.90748f, 0.8924f, 0.87741f, - 0.86239f, 0.84699f, 0.83096f, 0.81354f, 0.79568f, - 0.77812f, 0.75942f, 0.73898f, 0.71895f, 0.6979f, - 0.67584f, 0.65541f, 0.63427f, 0.61183f, 0.58872f, - 0.56582f, 0.54277f, 0.51966f, 0.49662f, 0.47374f, - 0.45068f, 0.42633f, 0.40063f, 0.37501f, 0.35003f, - 0.32551f, 0.30122f, 0.27643f, 0.2508f, 0.22669f, - 0.2018f, 0.1756f, 0.15017f, 0.12637f, 0.102f, - 0.07617f, 0.05128f, 0.02768f, 0.00478f, -0.01868f, - -0.0427f, -0.06341f, -0.08504f, -0.10568f, -0.12438f, - -0.14567f, -0.16618f, -0.18641f, -0.20502f, -0.22295f, - -0.24012f, -0.2569f, -0.27256f, -0.28823f, -0.30194f, - -0.31542f, -0.33028f, -0.34304f, -0.35301f, -0.36387f, - -0.37478f, -0.38515f, -0.39437f, -0.4023f, -0.41029f, - -0.41949f, -0.42512f, -0.43117f, -0.43628f, -0.44007f, - -0.4454f, -0.45203f, -0.45813f, -0.46382f, -0.46907f, - -0.4739f, -0.47832f, -0.48235f, -0.48597f, -0.4892f, - -0.49207f, -0.49454f, -0.49666f, -0.49841f, -0.49984f, - -0.50092f, -0.50166f, -0.50208f, -0.50221f, -0.50202f, - -0.50155f, -0.50082f, -0.49982f, -0.49856f, -0.49706f, - -0.49533f, -0.49338f, -0.49122f, -0.48885f, -0.48628f, - -0.48354f, -0.48064f, -0.47755f, -0.47432f, -0.47094f, - -0.46742f, -0.46379f, -0.46001f, -0.45611f, -0.45208f, - -0.4479f, -0.44361f, -0.43919f, -0.43467f, -0.43006f, - -0.42543f, -0.42077f, -0.41613f, -0.4115f, -0.4069f, - -0.40233f, -0.39778f, -0.39325f, -0.38873f, -0.38422f, - -0.37971f, -0.37519f, -0.37068f, -0.36616f, -0.36163f, - -0.3571f, -0.35256f, -0.34802f, -0.34347f, -0.33892f, - -0.33436f, -0.32982f, -0.32529f, -0.32077f, -0.31626f, - -0.31179f, -0.30733f, -0.30289f, -0.2985f, -0.29413f, - -0.2898f, -0.28552f, -0.28129f, -0.27709f, -0.27294f, - -0.26885f, -0.26479f, -0.26078f, -0.25685f, -0.25293f, - -0.24906f, -0.24524f, -0.24147f, -0.23772f, -0.23403f, - -0.23038f, -0.22676f, -0.22318f, -0.21964f, -0.21614f, - -0.21268f, -0.20925f, -0.20586f, -0.20249f, -0.19916f, - -0.19588f, -0.19261f, -0.1894f, -0.18622f, -0.18305f, - -0.17994f, -0.17686f, -0.1738f, -0.17078f, -0.16779f, - -0.16484f, -0.1619f, -0.15902f, -0.15615f, -0.15333f, - -0.15054f, -0.14777f, -0.14504f, -0.14234f, -0.13967f, - -0.13704f, -0.13444f, -0.13187f, -0.12934f, -0.12684f, - -0.12439f, -0.12197f, -0.11959f, -0.11724f, -0.11494f, - -0.11265f, -0.1104f, -0.10815f, -0.10592f, -0.10371f, - -0.10151f, -0.09934f, -0.0972f, -0.09509f, -0.09302f, - -0.09099f, -0.08899f, -0.08705f, -0.08514f, -0.08327f, - -0.08145f, -0.07966f, -0.0779f, -0.07617f, -0.07448f, - -0.07282f, -0.07119f, -0.06958f, -0.06801f, -0.06646f, - -0.06493f, -0.06344f, -0.06196f, -0.06051f, -0.05908f, - -0.05768f, -0.05629f, -0.05495f, -0.0536f, -0.05229f, - -0.051f, -0.04974f, -0.04849f, -0.04726f, -0.04607f, - -0.0449f, -0.04375f, -0.04262f, -0.04151f, -0.04044f, - -0.03937f, -0.03834f, -0.03732f, -0.03634f, -0.03536f, - -0.0344f, -0.03347f, -0.03256f, -0.03166f, -0.03079f, - -0.02993f, -0.02908f, -0.02826f, -0.02745f, -0.02666f, - -0.02588f, -0.02512f, -0.02437f, -0.02364f, -0.02293f, - -0.02223f, -0.02154f, -0.02087f, -0.02021f, -0.01957f, - -0.01892f, -0.0183f, -0.01768f, -0.0171f, -0.01651f, - -0.01594f, -0.01536f, -0.01482f, -0.01428f, -0.01375f, - -0.01323f, -0.01271f, -0.01221f, -0.01171f, -0.01123f, - -0.01076f, -0.01029f, -0.00984f, -0.0094f, -0.00898f, - -0.00857f, -0.00817f, -0.00777f, -0.00739f, -0.007f, - -0.00663f, -0.00624f, -0.00587f, -0.00551f, -0.00514f, - -0.00479f, -0.00444f, -0.0041f, -0.00377f, -0.00344f, - -0.00313f, -0.00282f, -0.00252f, -0.00223f, -0.00195f, - -0.00168f, -0.0014f, -0.00114f, -0.00089f, -0.00063f, - -0.00039f, -0.00015f, 9e-05f, 0.00031f, 0.00053f, - 0.00076f, 0.00096f, 0.00117f, 0.00138f, 0.00158f, - 0.00178f, 0.00194f, 0.00216f, 0.00234f, 0.00251f, - 0.00269f, 0.0029f, 0.00298f, 0.00319f, 0.00338f, - 0.00353f, 0.00368f, 0.00383f, 0.00398f, 0.00408f, - 0.00427f, 0.00438f, 0.00447f, 0.00458f, 0.00472f, - 0.00488f, 0.00501f, 0.00512f, 0.00517f, 0.00532f, - 0.00546f, 0.00547f, 0.00561f, 0.00572f, 0.00576f, - 0.0059f, 0.00594f, 0.00606f, 0.0062f, 0.0062f, - 0.00635f, 0.00636f, 0.0065f, 0.0065f, 0.00664f, - 0.00665f, 0.0068f, 0.0068f, 0.00684f, 0.00695f, - 0.00695f, 0.0071f, 0.0071f, 0.00721f, 0.00725f, - 0.00725f, 0.00739f, 0.0074f, 0.0074f, 0.00751f, - 0.00755f, 0.00755f, 0.00759f, 0.00769f, 0.00769f, - 0.00769f, 0.00769f, 0.00783f, 0.00783f, 0.00783f, - 0.00783f, 0.00795f, 0.00799f, 0.00799f, 0.00799f, - 0.00799f, 0.00812f, 0.00813f, 0.00813f, 0.00813f, - 0.00813f, 0.00813f, 0.00828f, 0.00829f, 0.00829f, - 0.00829f, 0.00829f, 0.00829f, 0.00829f, 0.00829f, - 0.00843f, 0.00843f, 0.00843f, 0.00843f, 0.00843f, - 0.00843f, 0.00843f, 0.00843f, 0.00843f, 0.00843f, - 0.00843f, 0.00843f, 0.00843f, 0.00844f, 0.00858f, - 0.00858f, 0.00858f, 0.00858f, 0.00858f, 0.00858f, - 0.00858f, 0.00858f, 0.00858f, 0.00858f, 0.00858f, - 0.00858f, 0.00858f, 0.00858f, 0.00858f, 0.00858f, - 0.00858f, 0.00858f, 0.00858f, 0.00858f, 0.00858f, - 0.00858f, 0.00858f, 0.00858f, 0.00858f, 0.00858f, - 0.00858f, 0.00858f, 0.00858f, 0.00858f, 0.00858f, - 0.00858f, 0.00858f, 0.00858f, 0.00858f, 0.00858f, - 0.00858f, 0.00858f, 0.00854f, 0.00843f, 0.00843f, - 0.00843f, 0.00843f, 0.00843f, 0.00843f, 0.00843f, - 0.00843f, 0.00843f, 0.00843f, 0.00843f, 0.00843f, - 0.00843f, 0.00843f, 0.00843f, 0.00843f, 0.00843f, - 0.00843f, 0.00843f, 0.00843f, 0.00843f, 0.00843f" - - -# FCAL lookup table time values -FCAL_TIME - "0.5f, 1.5f, 2.5f, 3.5f, 4.5f, - 5.5f, 6.5f, 7.5f, 8.5f, 9.5f, - 10.5f, 11.5f, 12.5f, 13.5f, 14.5f, - 15.5f, 16.5f, 17.5f, 18.5f, 19.5f, - 20.5f, 21.5f, 22.5f, 23.5f, 24.5f, - 25.5f, 26.5f, 27.5f, 28.5f, 29.5f, - 30.5f, 31.5f, 32.5f, 33.5f, 34.5f, - 35.5f, 36.5f, 37.5f, 38.5f, 39.5f, - 40.5f, 41.5f, 42.5f, 43.5f, 44.5f, - 45.5f, 46.5f, 47.5f, 48.5f, 49.5f, - 50.5f, 51.5f, 52.5f, 53.5f, 54.5f, - 55.5f, 56.5f, 57.5f, 58.5f, 59.5f, - 60.5f, 61.5f, 62.5f, 63.5f, 64.5f, - 65.5f, 66.5f, 67.5f, 68.5f, 69.5f, - 70.5f, 71.5f, 72.5f, 73.5f, 74.5f, - 75.5f, 76.5f, 77.5f, 78.5f, 79.5f, - 80.5f, 81.5f, 82.5f, 83.5f, 84.5f, - 85.5f, 86.5f, 87.5f, 88.5f, 89.5f, - 90.5f, 91.5f, 92.5f, 93.5f, 94.5f, - 95.5f, 96.5f, 97.5f, 98.5f, 99.5f, - 100.5f, 101.5f, 102.5f, 103.5f, 104.5f, - 105.5f, 106.5f, 107.5f, 108.5f, 109.5f, - 110.5f, 111.5f, 112.5f, 113.5f, 114.5f, - 115.5f, 116.5f, 117.5f, 118.5f, 119.5f, - 120.5f, 121.5f, 122.5f, 123.5f, 124.5f, - 125.5f, 126.5f, 127.5f, 128.5f, 129.5f, - 130.5f, 131.5f, 132.5f, 133.5f, 134.5f, - 135.5f, 136.5f, 137.5f, 138.5f, 139.5f, - 140.5f, 141.5f, 142.5f, 143.5f, 144.5f, - 145.5f, 146.5f, 147.5f, 148.5f, 149.5f, - 150.5f, 151.5f, 152.5f, 153.5f, 154.5f, - 155.5f, 156.5f, 157.5f, 158.5f, 159.5f, - 160.5f, 161.5f, 162.5f, 163.5f, 164.5f, - 165.5f, 166.5f, 167.5f, 168.5f, 169.5f, - 170.5f, 171.5f, 172.5f, 173.5f, 174.5f, - 175.5f, 176.5f, 177.5f, 178.5f, 179.5f, - 180.5f, 181.5f, 182.5f, 183.5f, 184.5f, - 185.5f, 186.5f, 187.5f, 188.5f, 189.5f, - 190.5f, 191.5f, 192.5f, 193.5f, 194.5f, - 195.5f, 196.5f, 197.5f, 198.5f, 199.5f, - 200.5f, 201.5f, 202.5f, 203.5f, 204.5f, - 205.5f, 206.5f, 207.5f, 208.5f, 209.5f, - 210.5f, 211.5f, 212.5f, 213.5f, 214.5f, - 215.5f, 216.5f, 217.5f, 218.5f, 219.5f, - 220.5f, 221.5f, 222.5f, 223.5f, 224.5f, - 225.5f, 226.5f, 227.5f, 228.5f, 229.5f, - 230.5f, 231.5f, 232.5f, 233.5f, 234.5f, - 235.5f, 236.5f, 237.5f, 238.5f, 239.5f, - 240.5f, 241.5f, 242.5f, 243.5f, 244.5f, - 245.5f, 246.5f, 247.5f, 248.5f, 249.5f, - 250.5f, 251.5f, 252.5f, 253.5f, 254.5f, - 255.5f, 256.5f, 257.5f, 258.5f, 259.5f, - 260.5f, 261.5f, 262.5f, 263.5f, 264.5f, - 265.5f, 266.5f, 267.5f, 268.5f, 269.5f, - 270.5f, 271.5f, 272.5f, 273.5f, 274.5f, - 275.5f, 276.5f, 277.5f, 278.5f, 279.5f, - 280.5f, 281.5f, 282.5f, 283.5f, 284.5f, - 285.5f, 286.5f, 287.5f, 288.5f, 289.5f, - 290.5f, 291.5f, 292.5f, 293.5f, 294.5f, - 295.5f, 296.5f, 297.5f, 298.5f, 299.5f, - 300.5f, 301.5f, 302.5f, 303.5f, 304.5f, - 305.5f, 306.5f, 307.5f, 308.5f, 309.5f, - 310.5f, 311.5f, 312.5f, 313.5f, 314.5f, - 315.5f, 316.5f, 317.5f, 318.5f, 319.5f, - 320.5f, 321.5f, 322.5f, 323.5f, 324.5f, - 325.5f, 326.5f, 327.5f, 328.5f, 329.5f, - 330.5f, 331.5f, 332.5f, 333.5f, 334.5f, - 335.5f, 336.5f, 337.5f, 338.5f, 339.5f, - 340.5f, 341.5f, 342.5f, 343.5f, 344.5f, - 345.5f, 346.5f, 347.5f, 348.5f, 349.5f, - 350.5f, 351.5f, 352.5f, 353.5f, 354.5f, - 355.5f, 356.5f, 357.5f, 358.5f, 359.5f, - 360.5f, 361.5f, 362.5f, 363.5f, 364.5f, - 365.5f, 366.5f, 367.5f, 368.5f, 369.5f, - 370.5f, 371.5f, 372.5f, 373.5f, 374.5f, - 375.5f, 376.5f, 377.5f, 378.5f, 379.5f, - 380.5f, 381.5f, 382.5f, 383.5f, 384.5f, - 385.5f, 386.5f, 387.5f, 388.5f, 389.5f, - 390.5f, 391.5f, 392.5f, 393.5f, 394.5f, - 395.5f, 396.5f, 397.5f, 398.5f, 399.5f, - 400.5f, 401.5f, 402.5f, 403.5f, 404.5f, - 405.5f, 406.5f, 407.5f, 408.5f, 409.5f, - 410.5f, 411.5f, 412.5f, 413.5f, 414.5f, - 415.5f, 416.5f, 417.5f, 418.5f, 419.5f, - 420.5f, 421.5f, 422.5f, 423.5f, 424.5f, - 425.5f, 426.5f, 427.5f, 428.5f, 429.5f, - 430.5f, 431.5f, 432.5f, 433.5f, 434.5f, - 435.5f, 436.5f, 437.5f, 438.5f, 439.5f, - 440.5f, 441.5f, 442.5f, 443.5f, 444.5f, - 445.5f, 446.5f, 447.5f, 448.5f, 449.5f, - 450.5f, 451.5f, 452.5f, 453.5f, 454.5f, - 455.5f, 456.5f, 457.5f, 458.5f, 459.5f, - 460.5f, 461.5f, 462.5f, 463.5f, 464.5f, - 465.5f, 466.5f, 467.5f, 468.5f, 469.5f, - 470.5f, 471.5f, 472.5f, 473.5f, 474.5f, - 475.5f, 476.5f, 477.5f, 478.5f, 479.5f, - 480.5f, 481.5f, 482.5f, 483.5f, 484.5f, - 485.5f, 486.5f, 487.5f, 488.5f, 489.5f, - 490.5f, 491.5f, 492.5f, 493.5f, 494.5f, - 495.5f, 496.5f, 497.5f, 498.5f, 499.5f, - 500.5f, 501.5f, 502.5f, 503.5f, 504.5f, - 505.5f, 506.5f, 507.5f, 508.5f, 509.5f, - 510.5f, 511.5f, 512.5f, 513.5f, 514.5f, - 515.5f, 516.5f, 517.5f, 518.5f, 519.5f, - 520.5f, 521.5f, 522.5f, 523.5f, 524.5f, - 525.5f, 526.5f, 527.5f, 528.5f, 529.5f, - 530.5f, 531.5f, 532.5f, 533.5f, 534.5f, - 535.5f, 536.5f, 537.5f, 538.5f, 539.5f, - 540.5f, 541.5f, 542.5f, 543.5f, 544.5f, - 545.5f, 546.5f, 547.5f, 548.5f, 549.5f, - 550.5f, 551.5f, 552.5f, 553.5f, 554.5f, - 555.5f, 556.5f, 557.5f, 558.5f, 559.5f, - 560.5f, 561.5f, 562.5f, 563.5f, 564.5f, - 565.5f, 566.5f, 567.5f, 568.5f, 569.5f, - 570.5f, 571.5f, 572.5f, 573.5f, 574.5f, - 575.5f, 576.5f, 577.5f, 578.5f, 579.5f, - 580.5f, 581.5f, 582.5f, 583.5f, 584.5f, - 585.5f, 586.5f, 587.5f, 588.5f, 589.5f, - 590.5f, 591.5f, 592.5f, 593.5f, 594.5f, - 595.5f, 596.5f, 597.5f, 598.5f, 599.5f" - diff --git a/graphics/AtlantisJava/configuration/rpsplt_hec.csv b/graphics/AtlantisJava/configuration/rpsplt_hec.csv deleted file mode 100644 index 0b1285de75ed53b27ab96a8c5204dd60c747f3bd..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/configuration/rpsplt_hec.csv +++ /dev/null @@ -1,329 +0,0 @@ -# Real Pulse Shape Plots Lookup Table values for HEC calorimeter - - -# HEC lookup table, amplitude values -HEC_AMPLITUDE -"0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0.000101187f, 0.00664058f, 0.00527695f, 0.0002041f, -0.000215028f, 0.000293915f, 0.000490323f, 0.000903528f, 0.00170435f, -0.00314031f, 0.00552285f, 0.00920343f, 0.0145539f, 0.0219273f, -0.0316359f, 0.043942f, 0.059033f, 0.0770143f, 0.0978915f, -0.121549f, 0.147763f, 0.17623f, 0.206609f, 0.238601f, -0.272f, 0.306696f, 0.342649f, 0.379813f, 0.418056f, -0.457117f, 0.496607f, 0.536044f, 0.57493f, 0.612812f, -0.649334f, 0.684243f, 0.717392f, 0.748708f, 0.778165f, -0.805768f, 0.831539f, 0.85551f, 0.877704f, 0.898131f, -0.916774f, 0.933594f, 0.948547f, 0.961595f, 0.972719f, -0.98191f, 0.989184f, 0.994564f, 0.998103f, 0.99988f, -1f, 0.998581f, 0.995722f, 0.991483f, 0.985877f, -0.978879f, 0.970462f, 0.960624f, 0.949425f, 0.936981f, -0.92346f, 0.909059f, 0.893975f, 0.878385f, 0.862425f, -0.846174f, 0.829654f, 0.812831f, 0.795626f, 0.777953f, -0.759737f, 0.740952f, 0.721636f, 0.701896f, 0.681887f, -0.661787f, 0.64177f, 0.621975f, 0.602503f, 0.583422f, -0.564766f, 0.54655f, 0.528765f, 0.511376f, 0.494318f, -0.477505f, 0.460853f, 0.444298f, 0.427826f, 0.411478f, -0.395336f, 0.379494f, 0.364017f, 0.348923f, 0.334176f, -0.319715f, 0.305481f, 0.291443f, 0.277605f, 0.263994f, -0.250654f, 0.237625f, 0.224942f, 0.21263f, 0.200696f, -0.189132f, 0.177913f, 0.166995f, 0.156325f, 0.145848f, -0.135522f, 0.125326f, 0.115279f, 0.105427f, 0.0958465f, -0.0866154f, 0.0777954f, 0.0694189f, 0.0614767f, 0.0539207f, -0.0466707f, 0.0396293f, 0.0327093f, 0.0258526f, 0.0190475f, -0.0123301f, 0.00576636f, -0.000577978f, -0.00665906f, -0.0124708f, --0.0180326f, -0.023372f, -0.0285029f, -0.0334147f, -0.0380814f, --0.0424744f, -0.0465814f, -0.0504199f, -0.0540364f, -0.0574984f, --0.060883f, -0.0642531f, -0.06764f, -0.0710355f, -0.0743926f, --0.0776445f, -0.0807294f, -0.0836115f, -0.0862943f, -0.0888135f, --0.091227f, -0.0935885f, -0.0959315f, -0.0982592f, -0.100547f, --0.102752f, -0.104836f, -0.106781f, -0.108595f, -0.110316f, --0.112001f, -0.113707f, -0.115471f, -0.117302f, -0.119178f, --0.121058f, -0.122894f, -0.124646f, -0.126288f, -0.127819f, --0.129262f, -0.130658f, -0.132056f, -0.133495f, -0.134988f, --0.136514f, -0.138027f, -0.139477f, -0.140829f, -0.142082f, --0.143263f, -0.144417f, -0.145579f, -0.146758f, -0.147944f, --0.149106f, -0.150203f, -0.151199f, -0.152063f, -0.152785f, --0.153383f, -0.153917f, -0.154483f, -0.155185f, -0.156098f, --0.157233f, -0.158526f, -0.159851f, -0.161065f, -0.162059f, --0.162781f, -0.163253f, -0.163543f, -0.163732f, -0.163889f, --0.164059f, -0.164269f, -0.164541f, -0.1649f, -0.165369f, --0.165963f, -0.166671f, -0.167457f, -0.168261f, -0.169021f, --0.169687f, -0.170237f, -0.170686f, -0.171074f, -0.171449f, --0.171844f, -0.172271f, -0.172716f, -0.173152f, -0.173545f, --0.173864f, -0.174091f, -0.174214f, -0.174244f, -0.174208f, --0.174145f, -0.174091f, -0.174075f, -0.174109f, -0.174199f, --0.174347f, -0.174556f, -0.174822f, -0.175124f, -0.175427f, --0.175685f, -0.175868f, -0.175971f, -0.176023f, -0.17607f, --0.17616f, -0.176313f, -0.176514f, -0.176721f, -0.176879f, --0.176951f, -0.176934f, -0.176855f, -0.17676f, -0.176689f, --0.176655f, -0.176648f, -0.176647f, -0.176639f, -0.176628f, --0.176632f, -0.176673f, -0.176754f, -0.176855f, -0.176936f, --0.176952f, -0.176875f, -0.176706f, -0.17647f, -0.176211f, --0.175972f, -0.175794f, -0.175711f, -0.175755f, -0.175946f, --0.176285f, -0.176742f, -0.177258f, -0.177757f, -0.17817f, --0.17845f, -0.178579f, -0.178566f, -0.178437f, -0.178227f, --0.177974f, -0.177712f, -0.177464f, -0.177238f, -0.177031f, --0.176835f, -0.176652f, -0.176495f, -0.176386f, -0.176349f, --0.176395f, -0.176518f, -0.176694f, -0.176894f, -0.177086f, --0.177248f, -0.177368f, -0.177442f, -0.177475f, -0.177466f, --0.177409f, -0.177287f, -0.177085f, -0.176805f, -0.176481f, --0.176177f, -0.175968f, -0.175917f, -0.176041f, -0.176305f, --0.176639f, -0.176956f, -0.177192f, -0.177313f, -0.177318f, --0.17723f, -0.177084f, -0.176912f, -0.176746f, -0.176605f, --0.176497f, -0.176412f, -0.176339f, -0.176273f, -0.176226f, --0.176224f, -0.176294f, -0.176444f, -0.176653f, -0.176876f, --0.177061f, -0.17717f, -0.177187f, -0.177116f, -0.176969f, --0.17676f, -0.176495f, -0.176185f, -0.175846f, -0.175501f, --0.175181f, -0.174914f, -0.174722f, -0.174603f, -0.174535f, --0.174484f, -0.174419f, -0.174334f, -0.174257f, -0.174241f, --0.174339f, -0.174568f, -0.174897f, -0.175247f, -0.175527f, --0.175668f, -0.175649f, -0.175504f, -0.175302f, -0.175115f, --0.17499f, -0.174941f, -0.174946f, -0.174966f, -0.174962f, --0.174908f, -0.174796f, -0.174638f, -0.174464f, -0.174308f, --0.174196f, -0.174135f, -0.174112f, -0.174105f, -0.174099f, --0.1741f, -0.174129f, -0.174211f, -0.174347f, -0.174508f, --0.174639f, -0.174693f, -0.174653f, -0.174547f, -0.17444f, --0.174397f, -0.17446f, -0.174621f, -0.174834f, -0.175026f, --0.175129f, -0.175111f, -0.174973f, -0.174755f, -0.174506f, --0.174263f, -0.174042f, -0.173832f, -0.173617f, -0.173383f, --0.173135f, -0.172888f, -0.172667f, -0.172506f, -0.172432f, --0.172467f, -0.172611f, -0.172834f, -0.173088f, -0.173314f, --0.173464f, -0.173523f, -0.173511f, -0.173469f, -0.17344f, --0.173454f, -0.173512f, -0.173588f, -0.173645f, -0.173641f, --0.173557f, -0.173396f, -0.173188f, -0.172974f, -0.172789f, --0.172649f, -0.172556f, -0.172492f, -0.17244f, -0.172391f, --0.172346f, -0.17231f, -0.172284f, -0.172267f, -0.172255f, --0.172249f, -0.172253f, -0.172273f, -0.17231f, -0.172352f, --0.172388f, -0.172401f, -0.172379f, -0.172311f, -0.172176f, --0.171942f, -0.171573f, -0.17104f, -0.17034f, -0.169499f, --0.168562f, -0.16757f, -0.166543f, -0.165477f, -0.164352f, --0.163143f, -0.161835f, -0.160427f, -0.158922f, -0.157329f, --0.155643f, -0.153858f, -0.15196f, -0.149937f, -0.147782f, --0.145494f, -0.143082f, -0.14057f, -0.137992f, -0.135393f, --0.132824f, -0.130331f, -0.127944f, -0.12568f, -0.123532f, --0.121472f, -0.119454f, -0.117412f, -0.115278f, -0.112998f, --0.110548f, -0.107945f, -0.105239f, -0.102501f, -0.0997942f, --0.0971684f, -0.0946474f, -0.0922345f, -0.0899178f, -0.087684f, --0.0855244f, -0.0834364f, -0.0814211f, -0.0794707f, -0.0775634f, --0.0756617f, -0.0737202f, -0.0717019f, -0.0695945f, -0.0674152f, --0.0652053f, -0.0630127f, -0.0608754f, -0.0588116f, -0.056822f, --0.0549011f, -0.0530426f, -0.0512422f, -0.049497f, -0.0478024f, --0.0461557f, -0.0445622f, -0.0430403f, -0.0416186f, -0.0403259f, --0.0391799f, -0.0381777f, -0.0372926f, -0.0364776f, -0.0356725f, --0.0348179f, -0.0338654f, -0.0327897f, -0.0315966f, -0.0303215f, --0.0290217f, -0.0277614f, -0.0265938f, -0.0255459f, -0.0246139f, --0.0237676f, -0.0229666f, -0.0221815f, -0.0214062f, -0.0206548f, --0.0199489f, -0.0192999f, -0.0186995f, -0.0181225f, -0.0175376f, --0.0169217f, -0.0162671f, -0.015582f, -0.0148865f, -0.0142068f, --0.013571f, -0.0130013f, -0.0125088f, -0.0120878f, -0.0117106f, --0.0113307f, -0.010896f, -0.0103706f, -0.00975524f, -0.00909709f, --0.00847957f, -0.00799095f, -0.00768947f, -0.00757594f, -0.00759465f, --0.007658f, -0.00768306f, -0.00761927f, -0.00745677f, -0.00721301f, --0.0069087f, -0.00655204f, -0.00613803f, -0.00565728f, -0.0051098f, --0.00451485f, -0.00390879f, -0.00333665f, -0.00284016f, -0.00244591f, --0.00216087f, -0.00197292f, -0.00185468f, -0.00177376f, -0.0017025f, --0.00162463f, -0.00153632f, -0.00144381f, -0.00135502f, -0.00127151f, --0.00118363f, -0.00107486f, -0.000933489f, -0.000765153f, -0.000595878f, --0.000462136f, -0.000391149f, -0.000381636f, -0.00039948f, -0.000392457f, --0.00031506f, -0.000148614f, 9.0048e-05f, 0.00035786f, 0.000604245f, -0.000786303f, 0.000878787f, 0.000875978f, 0.000791694f, 0.000657695f, -0.00051893f, 0.000425818f, 0.000426074f, 0.000551054f, 0.000806885f, -0.00117476f, 0.00161695f, 0.00208652f, 0.00253376f, 0.00290882f, -0.00316028f, 0.00323814f, 0.00310475f, 0.00275044f, 0.00220837f, -0.00155712f, 0.000907431f, 0.000374364f, 4.94567e-05f, -2.10426e-05f, -0.000152468f, 0.000507839f, 0.000947469f, 0.00136192f, 0.00165448f, -0.00176273f, 0.00167267f, 0.00141913f, 0.00107273f, 0.000722145f, -0.000454802f, 0.000340469f, 0.000418315f, 0.000688105f, 0.00110894f, -0.00160413f, 0.00207832f, 0.00244585f, 0.00265788f, 0.0027142f, -0.00265461f, 0.00253537f, 0.00240031f, 0.00226566f, 0.00212575f, -0.00197065f, 0.00180602f, 0.00166146f, 0.00158237f, 0.00160939f, -0.00175419f, 0.00198981f, 0.00225835f, 0.00249251f, 0.00264239f, -0.00268974f, 0.00264634f, 0.00253697f, 0.00238428f, 0.00220657f, -0.00202457f, 0.00187327f, 0.00179975f, 0.00184459f, 0.00201759f, -0.00228424f, 0.00257413f, 0.00280859f, 0.00293672f, 0.00295574f, -0.00290479f, 0.0028433f, 0.00282479f, 0.00288132f, 0.00302619f, -0.00326351f, 0.00359044f, 0.00398678f, 0.00440043f, 0.00474437f, -0.00491837f, 0.00484987f, 0.00453341f, 0.00404398f, 0.00351183f, -0.00306889f, 0.00279655f, 0.00270115f, 0.0027279f, 0.00280162f, -0.00286887f, 0.00291904f, 0.00297615f, 0.00307301f, 0.00322684f, -0.00343021f, 0.00365863f, 0.003885f, 0.00409031f, 0.00426691f, -0.00441451f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f, -0f, 0f, 0f, 0f, 0f" - - -# HEC lookup table, time values -HEC_TIME -"0f, 1.03959f, 2.07917f, 3.11876f, 4.15835f, -5.19794f, 6.23752f, 7.27711f, 8.3167f, 9.35629f, -10.3959f, 11.4355f, 12.475f, 13.5146f, 14.5542f, -15.5938f, 16.6334f, 17.673f, 18.7126f, 19.7522f, -20.7917f, 21.8313f, 22.8709f, 23.9105f, 24.9501f, -25.9897f, 27.0293f, 28.0689f, 29.1084f, 30.148f, -31.1876f, 32.2272f, 33.2668f, 34.3064f, 35.346f, -36.3856f, 37.4251f, 38.4647f, 39.5043f, 40.5439f, -41.5835f, 42.6231f, 43.6627f, 44.7023f, 45.7418f, -46.7814f, 47.821f, 48.8606f, 49.9002f, 50.9398f, -51.9794f, 53.019f, 54.0585f, 55.0981f, 56.1377f, -57.1773f, 58.2169f, 59.2565f, 60.2961f, 61.3357f, -62.3752f, 63.4148f, 64.4544f, 65.494f, 66.5336f, -67.5732f, 68.6128f, 69.6524f, 70.6919f, 71.7315f, -72.7711f, 73.8107f, 74.8503f, 75.8899f, 76.9295f, -77.9691f, 79.0086f, 80.0482f, 81.0878f, 82.1274f, -83.167f, 84.2066f, 85.2462f, 86.2858f, 87.3253f, -88.3649f, 89.4045f, 90.4441f, 91.4837f, 92.5233f, -93.5629f, 94.6025f, 95.642f, 96.6816f, 97.7212f, -98.7608f, 99.8004f, 100.84f, 101.88f, 102.919f, -103.959f, 104.998f, 106.038f, 107.078f, 108.117f, -109.157f, 110.196f, 111.236f, 112.275f, 113.315f, -114.355f, 115.394f, 116.434f, 117.473f, 118.513f, -119.553f, 120.592f, 121.632f, 122.671f, 123.711f, -124.75f, 125.79f, 126.83f, 127.869f, 128.909f, -129.948f, 130.988f, 132.028f, 133.067f, 134.107f, -135.146f, 136.186f, 137.226f, 138.265f, 139.305f, -140.344f, 141.384f, 142.423f, 143.463f, 144.503f, -145.542f, 146.582f, 147.621f, 148.661f, 149.701f, -150.74f, 151.78f, 152.819f, 153.859f, 154.899f, -155.938f, 156.978f, 158.017f, 159.057f, 160.096f, -161.136f, 162.176f, 163.215f, 164.255f, 165.294f, -166.334f, 167.374f, 168.413f, 169.453f, 170.492f, -171.532f, 172.572f, 173.611f, 174.651f, 175.69f, -176.73f, 177.769f, 178.809f, 179.849f, 180.888f, -181.928f, 182.967f, 184.007f, 185.047f, 186.086f, -187.126f, 188.165f, 189.205f, 190.245f, 191.284f, -192.324f, 193.363f, 194.403f, 195.442f, 196.482f, -197.522f, 198.561f, 199.601f, 200.64f, 201.68f, -202.72f, 203.759f, 204.799f, 205.838f, 206.878f, -207.917f, 208.957f, 209.997f, 211.036f, 212.076f, -213.115f, 214.155f, 215.195f, 216.234f, 217.274f, -218.313f, 219.353f, 220.393f, 221.432f, 222.472f, -223.511f, 224.551f, 225.59f, 226.63f, 227.67f, -228.709f, 229.749f, 230.788f, 231.828f, 232.868f, -233.907f, 234.947f, 235.986f, 237.026f, 238.066f, -239.105f, 240.145f, 241.184f, 242.224f, 243.263f, -244.303f, 245.343f, 246.382f, 247.422f, 248.461f, -249.501f, 250.541f, 251.58f, 252.62f, 253.659f, -254.699f, 255.739f, 256.778f, 257.818f, 258.857f, -259.897f, 260.936f, 261.976f, 263.016f, 264.055f, -265.095f, 266.134f, 267.174f, 268.214f, 269.253f, -270.293f, 271.332f, 272.372f, 273.412f, 274.451f, -275.491f, 276.53f, 277.57f, 278.609f, 279.649f, -280.689f, 281.728f, 282.768f, 283.807f, 284.847f, -285.887f, 286.926f, 287.966f, 289.005f, 290.045f, -291.084f, 292.124f, 293.164f, 294.203f, 295.243f, -296.282f, 297.322f, 298.362f, 299.401f, 300.441f, -301.48f, 302.52f, 303.56f, 304.599f, 305.639f, -306.678f, 307.718f, 308.757f, 309.797f, 310.837f, -311.876f, 312.916f, 313.955f, 314.995f, 316.035f, -317.074f, 318.114f, 319.153f, 320.193f, 321.233f, -322.272f, 323.312f, 324.351f, 325.391f, 326.43f, -327.47f, 328.51f, 329.549f, 330.589f, 331.628f, -332.668f, 333.708f, 334.747f, 335.787f, 336.826f, -337.866f, 338.906f, 339.945f, 340.985f, 342.024f, -343.064f, 344.103f, 345.143f, 346.183f, 347.222f, -348.262f, 349.301f, 350.341f, 351.381f, 352.42f, -353.46f, 354.499f, 355.539f, 356.579f, 357.618f, -358.658f, 359.697f, 360.737f, 361.776f, 362.816f, -363.856f, 364.895f, 365.935f, 366.974f, 368.014f, -369.054f, 370.093f, 371.133f, 372.172f, 373.212f, -374.251f, 375.291f, 376.331f, 377.37f, 378.41f, -379.449f, 380.489f, 381.529f, 382.568f, 383.608f, -384.647f, 385.687f, 386.727f, 387.766f, 388.806f, -389.845f, 390.885f, 391.924f, 392.964f, 394.004f, -395.043f, 396.083f, 397.122f, 398.162f, 399.202f, -400.241f, 401.281f, 402.32f, 403.36f, 404.4f, -405.439f, 406.479f, 407.518f, 408.558f, 409.597f, -410.637f, 411.677f, 412.716f, 413.756f, 414.795f, -415.835f, 416.875f, 417.914f, 418.954f, 419.993f, -421.033f, 422.073f, 423.112f, 424.152f, 425.191f, -426.231f, 427.27f, 428.31f, 429.35f, 430.389f, -431.429f, 432.468f, 433.508f, 434.548f, 435.587f, -436.627f, 437.666f, 438.706f, 439.746f, 440.785f, -441.825f, 442.864f, 443.904f, 444.943f, 445.983f, -447.023f, 448.062f, 449.102f, 450.141f, 451.181f, -452.221f, 453.26f, 454.3f, 455.339f, 456.379f, -457.418f, 458.458f, 459.498f, 460.537f, 461.577f, -462.616f, 463.656f, 464.696f, 465.735f, 466.775f, -467.814f, 468.854f, 469.894f, 470.933f, 471.973f, -473.012f, 474.052f, 475.091f, 476.131f, 477.171f, -478.21f, 479.25f, 480.289f, 481.329f, 482.369f, -483.408f, 484.448f, 485.487f, 486.527f, 487.567f, -488.606f, 489.646f, 490.685f, 491.725f, 492.764f, -493.804f, 494.844f, 495.883f, 496.923f, 497.962f, -499.002f, 500.042f, 501.081f, 502.121f, 503.16f, -504.2f, 505.24f, 506.279f, 507.319f, 508.358f, -509.398f, 510.437f, 511.477f, 512.517f, 513.556f, -514.596f, 515.635f, 516.675f, 517.715f, 518.754f, -519.794f, 520.833f, 521.873f, 522.913f, 523.952f, -524.992f, 526.031f, 527.071f, 528.11f, 529.15f, -530.19f, 531.229f, 532.269f, 533.308f, 534.348f, -535.388f, 536.427f, 537.467f, 538.506f, 539.546f, -540.585f, 541.625f, 542.665f, 543.704f, 544.744f, -545.783f, 546.823f, 547.863f, 548.902f, 549.942f, -550.981f, 552.021f, 553.061f, 554.1f, 555.14f, -556.179f, 557.219f, 558.258f, 559.298f, 560.338f, -561.377f, 562.417f, 563.456f, 564.496f, 565.536f, -566.575f, 567.615f, 568.654f, 569.694f, 570.734f, -571.773f, 572.813f, 573.852f, 574.892f, 575.931f, -576.971f, 578.011f, 579.05f, 580.09f, 581.129f, -582.169f, 583.209f, 584.248f, 585.288f, 586.327f, -587.367f, 588.407f, 589.446f, 590.486f, 591.525f, -592.565f, 593.604f, 594.644f, 595.684f, 596.723f, -597.763f, 598.802f, 599.842f, 600.882f, 601.921f, -602.961f, 604f, 605.04f, 606.08f, 607.119f, -608.159f, 609.198f, 610.238f, 611.277f, 612.317f, -613.357f, 614.396f, 615.436f, 616.475f, 617.515f, -618.555f, 619.594f, 620.634f, 621.673f, 622.713f, -623.752f, 624.792f, 625.832f, 626.871f, 627.911f, -628.95f, 629.99f, 631.03f, 632.069f, 633.109f, -634.148f, 635.188f, 636.228f, 637.267f, 638.307f, -639.346f, 640.386f, 641.425f, 642.465f, 643.505f, -644.544f, 645.584f, 646.623f, 647.663f, 648.703f, -649.742f, 650.782f, 651.821f, 652.861f, 653.901f, -654.94f, 655.98f, 657.019f, 658.059f, 659.098f, -660.138f, 661.178f, 662.217f, 663.257f, 664.296f, -665.336f, 666.376f, 667.415f, 668.455f, 669.494f, -670.534f, 671.574f, 672.613f, 673.653f, 674.692f, -675.732f, 676.771f, 677.811f, 678.851f, 679.89f, -680.93f, 681.969f, 683.009f, 684.049f, 685.088f, -686.128f, 687.167f, 688.207f, 689.247f, 690.286f, -691.326f, 692.365f, 693.405f, 694.444f, 695.484f, -696.524f, 697.563f, 698.603f, 699.642f, 700.682f, -701.722f, 702.761f, 703.801f, 704.84f, 705.88f, -706.919f, 707.959f, 708.999f, 710.038f, 711.078f, -712.117f, 713.157f, 714.197f, 715.236f, 716.276f, -717.315f, 718.355f, 719.395f, 720.434f, 721.474f, -722.513f, 723.553f, 724.592f, 725.632f, 726.672f, -727.711f, 728.751f, 729.79f, 730.83f, 731.87f, -732.909f, 733.949f, 734.988f, 736.028f, 737.068f, -738.107f, 739.147f, 740.186f, 741.226f, 742.265f, -743.305f, 744.345f, 745.384f, 746.424f, 747.463f, -748.503f, 749.543f, 750.582f, 751.622f, 752.661f, -753.701f, 754.741f, 755.78f, 756.82f, 757.859f, -758.899f, 759.938f, 760.978f, 762.018f, 763.057f, -764.097f, 765.136f, 766.176f, 767.216f, 768.255f, -769.295f, 770.334f, 771.374f, 772.414f, 773.453f, -774.493f, 775.532f, 776.572f, 777.611f, 778.651f, -779.691f, 780.73f, 781.77f, 782.809f, 783.849f, -784.889f, 785.928f, 786.968f, 788.007f, 789.047f, -790.086f, 791.126f, 792.166f, 793.205f, 794.245f, -795.284f, 796.324f, 797.364f, 798.403f, 799.443f, -800.482f, 801.522f, 802.562f, 803.601f, 804.641f, -805.68f, 806.72f, 807.759f, 808.799f, 809.839f, -810.878f, 811.918f, 812.957f, 813.997f, 815.037f, -816.076f, 817.116f, 818.155f, 819.195f, 820.235f, -821.274f, 822.314f, 823.353f, 824.393f, 825.432f, -826.472f, 827.512f, 828.551f, 829.591f, 830.63f" diff --git a/graphics/AtlantisJava/configuration/rpsplt_tile.csv b/graphics/AtlantisJava/configuration/rpsplt_tile.csv deleted file mode 100644 index 213666c43c9fab6638f5d9a93f8705ff0cb14742..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/configuration/rpsplt_tile.csv +++ /dev/null @@ -1,169 +0,0 @@ -# Real Pulse Shape Plots Lookup Table values for TILE calorimeter - -# TILE, time values -TILE_TIME -"-75.5f, -75f, -74.5f, -74f, -73.5f, --73f, -72.5f, -72f, -71.5f, -71f, --70.5f, -70f, -69.5f, -69f, -68.5f, --68f, -67.5f, -67f, -66.5f, -66f, --65.5f, -65f, -64.5f, -64f, -63.5f, --63f, -62.5f, -62f, -61.5f, -61f, --60.5f, -60f, -59.5f, -59f, -58.5f, --58f, -57.5f, -57f, -56.5f, -56f, --55.5f, -55f, -54.5f, -54f, -53.5f, --53f, -52.5f, -52f, -51.5f, -51f, --50.5f, -50f, -49.5f, -49f, -48.5f, --48f, -47.5f, -47f, -46.5f, -46f, --45.5f, -45f, -44.5f, -44f, -43.5f, --43f, -42.5f, -42f, -41.5f, -41f, --40.5f, -40f, -39.5f, -39f, -38.5f, --38f, -37.5f, -37f, -36.5f, -36f, --35.5f, -35f, -34.5f, -34f, -33.5f, --33f, -32.5f, -32f, -31.5f, -31f, --30.5f, -30f, -29.5f, -29f, -28.5f, --28f, -27.5f, -27f, -26.5f, -26f, --25.5f, -25f, -24.5f, -24f, -23.5f, --23f, -22.5f, -22f, -21.5f, -21f, --20.5f, -20f, -19.5f, -19f, -18.5f, --18f, -17.5f, -17f, -16.5f, -16f, --15.5f, -15f, -14.5f, -14f, -13.5f, --13f, -12.5f, -12f, -11.5f, -11f, --10.5f, -10f, -9.5f, -9f, -8.5f, --8f, -7.5f, -7f, -6.5f, -6f, --5.5f, -5f, -4.5f, -4f, -3.5f, --3f, -2.5f, -2f, -1.5f, -1f, --0.5f, 0f, 0.5f, 1f, 1.5f, -2f, 2.5f, 3f, 3.5f, 4f, -4.5f, 5f, 5.5f, 6f, 6.5f, -7f, 7.5f, 8f, 8.5f, 9f, -9.5f, 10f, 10.5f, 11f, 11.5f, -12f, 12.5f, 13f, 13.5f, 14f, -14.5f, 15f, 15.5f, 16f, 16.5f, -17f, 17.5f, 18f, 18.5f, 19f, -19.5f, 20f, 20.5f, 21f, 21.5f, -22f, 22.5f, 23f, 23.5f, 24f, -24.5f, 25f, 25.5f, 26f, 26.5f, -27f, 27.5f, 28f, 28.5f, 29f, -29.5f, 30f, 30.5f, 31f, 31.5f, -32f, 32.5f, 33f, 33.5f, 34f, -34.5f, 35f, 35.5f, 36f, 36.5f, -37f, 37.5f, 38f, 38.5f, 39f, -39.5f, 40f, 40.5f, 41f, 41.5f, -42f, 42.5f, 43f, 43.5f, 44f, -44.5f, 45f, 45.5f, 46f, 46.5f, -47f, 47.5f, 48f, 48.5f, 49f, -49.5f, 50f, 50.5f, 51f, 51.5f, -52f, 52.5f, 53f, 53.5f, 54f, -54.5f, 55f, 55.5f, 56f, 56.5f, -57f, 57.5f, 58f, 58.5f, 59f, -59.5f, 60f, 60.5f, 61f, 61.5f, -62f, 62.5f, 63f, 63.5f, 64f, -64.5f, 65f, 65.5f, 66f, 66.5f, -67f, 67.5f, 68f, 68.5f, 69f, -69.5f, 70f, 70.5f, 71f, 71.5f, -72f, 72.5f, 73f, 73.5f, 74f, -74.5f, 75f, 75.5f, 76f, 76.5f, -77f, 77.5f, 78f, 78.5f, 79f, -79.5f, 80f, 80.5f, 81f, 81.5f, -82f, 82.5f, 83f, 83.5f, 84f, -84.5f, 85f, 85.5f, 86f, 86.5f, -87f, 87.5f, 88f, 88.5f, 89f, -89.5f, 90f, 90.5f, 91f, 91.5f, -92f, 92.5f, 93f, 93.5f, 94f, -94.5f, 95f, 95.5f, 96f, 96.5f, -97f, 97.5f, 98f, 98.5f, 99f, -99.5f, 100f, 100.5f, 101f, 101.5f, -102f, 102.5f, 103f, 103.5f, 104f, -104.5f, 105f, 105.5f, 106f, 106.5f, -107f, 107.5f, 108f, 108.5f, 109f, -109.5f, 110f, 110.5f, 111f, 111.5f, -112f, 112.5f, 113f, 113.5f, 114f, -114.5f, 115f, 115.5f, 116f, 116.5f, -117f, 117.5f, 118f, 118.5f, 119f, -119.5f, 120f, 120.5f, 121f, 121.5f, -122f, 122.5f, 123f, 123.5f, 124f, -124.5f" - -# TILE, amplitude values -TILE_AMPLITUDE -"0f, 2.304e-05f, 5.178e-05f, 8.592e-05f, 0.00012515f, -0.00016918f, 0.0002177f, 0.00027043f, 0.00032705f, 0.00038728f, -0.00045081f, 0.00051733f, 0.00058656f, 0.00065819f, 0.00073193f, -0.00080746f, 0.0008845f, 0.00096275f, 0.0010419f, 0.00112166f, -0.00120172f, 0.00128179f, 0.00136157f, 0.00144076f, 0.00151905f, -0.00159642f, 0.0016754f, 0.00176001f, 0.00185428f, 0.00196225f, -0.00208795f, 0.00223542f, 0.00240868f, 0.00261177f, 0.00284873f, -0.00312358f, 0.00344037f, 0.00380312f, 0.00421586f, 0.00468264f, -0.00520748f, 0.00579479f, 0.00645263f, 0.00719117f, 0.00802059f, -0.00895106f, 0.00999278f, 0.0111559f, 0.0124507f, 0.0138872f, -0.0154757f, 0.0172264f, 0.0191494f, 0.0212549f, 0.0235531f, -0.0260541f, 0.0287667f, 0.0316991f, 0.0348593f, 0.0382556f, -0.041896f, 0.0457887f, 0.0499419f, 0.0543637f, 0.0590621f, -0.0640455f, 0.0693218f, 0.0748993f, 0.0807861f, 0.0869903f, -0.09352f, 0.100383f, 0.107581f, 0.115115f, 0.122983f, -0.131184f, 0.139719f, 0.148586f, 0.157786f, 0.167316f, -0.177177f, 0.187369f, 0.19789f, 0.208739f, 0.219917f, -0.231423f, 0.243248f, 0.255385f, 0.267822f, 0.28055f, -0.29356f, 0.306842f, 0.320385f, 0.334181f, 0.348219f, -0.362489f, 0.376982f, 0.391688f, 0.406597f, 0.421699f, -0.436986f, 0.452445f, 0.46806f, 0.483808f, 0.499668f, -0.515617f, 0.531635f, 0.547698f, 0.563786f, 0.579876f, -0.595946f, 0.611975f, 0.62794f, 0.64382f, 0.659592f, -0.675236f, 0.69073f, 0.706053f, 0.721186f, 0.736109f, -0.7508f, 0.76524f, 0.779408f, 0.793285f, 0.806849f, -0.82008f, 0.832959f, 0.845464f, 0.857576f, 0.869274f, -0.880538f, 0.891349f, 0.901693f, 0.911564f, 0.920954f, -0.929854f, 0.938257f, 0.946156f, 0.953541f, 0.960406f, -0.966742f, 0.972542f, 0.977798f, 0.982501f, 0.986645f, -0.990222f, 0.993234f, 0.995685f, 0.997581f, 0.998929f, -0.999733f, 1f, 0.999735f, 0.998944f, 0.997632f, -0.995806f, 0.99347f, 0.99063f, 0.987293f, 0.983464f, -0.979148f, 0.974352f, 0.969089f, 0.963376f, 0.957231f, -0.95067f, 0.943711f, 0.936371f, 0.928666f, 0.920615f, -0.912235f, 0.903542f, 0.894553f, 0.885287f, 0.875759f, -0.865988f, 0.855985f, 0.845763f, 0.835332f, 0.824704f, -0.81389f, 0.8029f, 0.791746f, 0.780439f, 0.768991f, -0.757412f, 0.745713f, 0.733906f, 0.722002f, 0.710012f, -0.697947f, 0.685818f, 0.673635f, 0.66141f, 0.649153f, -0.636873f, 0.624581f, 0.612288f, 0.600004f, 0.587739f, -0.575503f, 0.563307f, 0.551161f, 0.539076f, 0.527062f, -0.515129f, 0.503286f, 0.491542f, 0.479906f, 0.468386f, -0.456991f, 0.445729f, 0.434609f, 0.42364f, 0.412831f, -0.402189f, 0.391724f, 0.381444f, 0.371358f, 0.361474f, -0.351802f, 0.342348f, 0.333115f, 0.3241f, 0.315301f, -0.306715f, 0.298339f, 0.290172f, 0.282211f, 0.274453f, -0.266897f, 0.259539f, 0.252377f, 0.245409f, 0.238632f, -0.232044f, 0.225642f, 0.219421f, 0.213379f, 0.207511f, -0.201813f, 0.196283f, 0.190915f, 0.185707f, 0.180655f, -0.175755f, 0.171003f, 0.166395f, 0.161928f, 0.157598f, -0.153402f, 0.149335f, 0.145394f, 0.141575f, 0.137874f, -0.134288f, 0.130813f, 0.127445f, 0.12418f, 0.121015f, -0.117947f, 0.11497f, 0.112082f, 0.109278f, 0.106556f, -0.103911f, 0.10134f, 0.0988427f, 0.0964156f, 0.0940569f, -0.0917646f, 0.0895367f, 0.0873709f, 0.0852652f, 0.0832176f, -0.0812259f, 0.0792881f, 0.0774021f, 0.0755657f, 0.0737769f, -0.0720337f, 0.0703338f, 0.0686753f, 0.0670561f, 0.065474f, -0.0639269f, 0.0624129f, 0.0609298f, 0.0594755f, 0.0580479f, -0.0566449f, 0.0552645f, 0.0539046f, 0.052563f, 0.0512377f, -0.0499268f, 0.0486296f, 0.0473466f, 0.0460778f, 0.0448235f, -0.0435841f, 0.0423598f, 0.0411508f, 0.0399573f, 0.0387798f, -0.0376183f, 0.0364732f, 0.0353447f, 0.0342331f, 0.0331386f, -0.0320615f, 0.0310021f, 0.0299605f, 0.0289372f, 0.0279322f, -0.0269459f, 0.0259786f, 0.0250305f, 0.0241018f, 0.0231928f, -0.0223038f, 0.021435f, 0.0205867f, 0.0197591f, 0.0189525f, -0.0181671f, 0.017403f, 0.01666f, 0.0159379f, 0.0152367f, -0.0145562f, 0.0138962f, 0.0132567f, 0.0126374f, 0.0120383f, -0.0114592f, 0.0109f, 0.0103606f, 0.00984081f, 0.00934049f, -0.00885952f, 0.00839776f, 0.00795509f, 0.00753137f, 0.00712647f, -0.00674024f, 0.00637256f, 0.0060233f, 0.00569231f, 0.00537947f, -0.00508463f, 0.00480767f, 0.00454845f, 0.00430684f, 0.0040827f, -0.00387587f, 0.00368583f, 0.00351191f, 0.00335339f, 0.0032096f, -0.00307982f, 0.00296336f, 0.00285953f, 0.00276764f, 0.00268698f, -0.00261686f, 0.00255658f, 0.00250545f, 0.00246277f, 0.00242785f, -0.00239998f, 0.00237849f, 0.00236265f, 0.00235179f, 0.00234521f, -0.0023422f, 0.00234208f, 0.00234415f, 0.0023477f, 0.00235206f, -0.00235651f, 0.00236036f, 0.00236293f, 0.0023635f, 0.00236139f, -0.00235594f, 0.00234693f, 0.00233436f, 0.00231825f, 0.00229862f, -0.00227549f, 0.00224886f, 0.00221876f, 0.0021852f, 0.00214819f, -0.00210775f, 0.0020639f, 0.00201666f, 0.00196603f, 0.00191204f, -0.0018547f" diff --git a/graphics/AtlantisJava/events/event.dtd b/graphics/AtlantisJava/events/event.dtd deleted file mode 100755 index e9937b30976ee0d9d75d92b0a3d3fa54aa143085..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/events/event.dtd +++ /dev/null @@ -1,506 +0,0 @@ -<!-- -kine element is alias to barcode resp. to new-style truth association - using barcodes + numBarcodes (1 hits - to more tracks) at hits - (2006/08), kine should be removed completely on turn 2006/2007 ---> - -<!ENTITY % string.Type "CDATA"> - -<!ENTITY % eventAttributes - "version %string.Type; #IMPLIED - runNumber %string.Type; #IMPLIED - eventNumber %string.Type; #IMPLIED - dateTime %string.Type; #IMPLIED - lumiBlock %string.Type; #IMPLIED - eventProperties %string.Type; #IMPLIED"> - - -<!ELEMENT Event - (BJet|CaloETMis|Cluster|CompositeParticle|CSC|CSCD|Electron|EmTauROI| - ETMis|FCAL|HEC|IDScan|iPat|Jet|JetROI|LAr|LVL1JetElement|LVL1Result| - LVL1TriggerTower|MBTS|MDT|MSeg|Muon|MuonETMis|MuonROI|ParticleJet| - Photon|PixelRDO|RMTr|RPC|RTr|RVx|S3D|SCTRDO|Segment|SiHit|SMTr|STC|STr| - TauJet|TGC|TILE|Track|TrigS3D|TriggerInfo|TRT|xKal)+> -<!ATTLIST Event %eventAttributes;> - -<!ENTITY % attributes 'count CDATA "" storeGateKey CDATA ""'> - -<!ENTITY % type 'type (FLOAT|INT|STRING) #FIXED'> -<!ENTITY % unit 'unit (NONE | CM | RAD | GEV)'> -<!ENTITY % integer - ' %type; "INT" - multiple CDATA "1" - %unit; "NONE" '> -<!ENTITY % float - ' %type; "FLOAT" - multiple CDATA "1" - %unit; "NONE" '> -<!ENTITY % string - ' %type; "STRING" - multiple CDATA "1" - %unit; "NONE" '> - -<!ELEMENT BJet (charge|clusterIndex|clusterKey|clusterLinkCount|energy| - eta|label|lhSig|mass|phi|pt|secVtxCount|secVtxFitProb|secVtxMass| - secVtxMult|secVtxRPhiDist|secVtxTagLh|secVtxTagLhErr| - trackIndex|trackKey|trackLinkCount|weight)+> -<!ATTLIST BJet %attributes;> - -<!ELEMENT CaloETMis (et|etx|ety)+> -<!ATTLIST CaloETMis %attributes;> - -<!ELEMENT Cluster (cells|energy|emfrac|et|eta|id|numCells|phi)+> -<!ATTLIST Cluster %attributes;> - -<!ELEMENT CompositeParticle (author|charge|dataType|daughterIndex|daughterKey| - daughterPdgId|eta|label|pdgId|phi|pt|typeEV)+> -<!ATTLIST CompositeParticle %attributes;> - -<!ELEMENT CSC (barcode|hitsFull|id|identifier|kine|length|numHits|sigma| - x|y|z)+> -<!ATTLIST CSC %attributes;> - -<!ELEMENT CSCD (barcode|charge|id|identifier|kine|length|x|y|z)+> -<!ATTLIST CSCD %attributes;> - -<!ELEMENT Electron (author|clusterIndex|clusterKey|clusterLinkCount|dataType| - emWeight|eOverp|et37|eta|etCone|etCone20|etHad1|f1|fracs1| - hasTrack|hitsBLayer|hitsHighThresTRT|hitsPixel|hitsSCT| - hitsTRT|isEM|isEMString|pdgId|phi|pionWeight|pt|trackIndex|trackKey| - trackLinkCount)+> -<!ATTLIST Electron %attributes;> - -<!ELEMENT EmTauROI (energy|energyEM|energyTAU|eta|phi|roiWord|thrPattern)+> -<!ATTLIST EmTauROI %attributes;> - -<!ELEMENT ETMis (et|etx|ety)+> -<!ATTLIST ETMis %attributes;> - -<!ELEMENT FCAL (adc2Mev|adcCounts|cluster|dx|dy|energy|id|layer|sub| - x|y|channel|feedThrough|slot)+> -<!ATTLIST FCAL %attributes;> - -<!ELEMENT HEC (adc2Mev|adcCounts|energy|eta|id|layer|phi|sub| - cluster|channel|feedThrough|slot)+> -<!ATTLIST HEC %attributes;> - -<!ELEMENT IDScan (barcode|chi2|cotTheta|covMatrix|d0|hits|id|numHits| - phi0|pt|z0)+> -<!ATTLIST IDScan %attributes;> - -<!ELEMENT InDetSegment (hits|numHits|phi|theta|x|y|z)+> -<!ATTLIST InDetSegment %attributes;> - -<!ELEMENT iPat (barcode|chi2|cotTheta|covMatrix|d0|hits| - id|kine|numHits|numPolyline|phi0|polylineX|polylineY| - polylineZ|pt|z0)+> -<!ATTLIST iPat %attributes;> - -<!-- cluster should be an array of calo Cluster IDs, but it's not provided in - the event files nor any processing exists in the Jet handling code --> -<!ELEMENT Jet (OutOfTimeEfrac|bTagName|bTagValue|cells|cluster|clusterIndex|clusterKey|clusterLinkCount| - emfrac|et|eta|fcorCell|fcorDotx|fcorJet|fcorJetForCell|fracSamplingMax|hecf| - isBad|isGood|isUgly|n90cells|n90const|nbadcells|id|jvf|numCells|phi|pt| - quality|qualityLAr|qualityTile|sMax|tileGap3f|time|timeClusters|trackIndex|trackKey| - trackLinkCount|mass|px|py|pz)+> -<!ATTLIST Jet %attributes;> - -<!ELEMENT JetROI (energy|eta|phi)+> -<!ATTLIST JetROI %attributes;> - -<!ELEMENT LAr (adc2Mev|adcCounts|BadCell|cellGain|cellPedestal|cellTime|cluster| - energy|eta|id|layer|phi|sub|channel|feedThrough|slot)+> -<!ATTLIST LAr %attributes;> - -<!ELEMENT LVL1JetElement (energy|eta|phi)+> -<!ATTLIST LVL1JetElement %attributes;> - -<!ELEMENT LVL1Result (ctpItemList|ctpWord0|ctpWord1|ctpWord2| - energyEtMiss|energyEx|energyEy|energySumEt| - itemListEF|itemListL2|passedEF|passedL1|passedL2| - passedTrigger|prescaleListEF|prescaleListL1|prescaleListL2)+> -<!ATTLIST LVL1Result %attributes;> - -<!ELEMENT LVL1TriggerTower (emADC|emBCID|emEnergy|eta|hadADC|hadBCID|hadEnergy| - isEMSaturated|isHadSaturated|numADC|phi|sumEnergy)+> -<!ATTLIST LVL1TriggerTower %attributes;> - -<!ELEMENT MBTS (channel|energy|eta|label|module|phi|quality|sampling|time|type| - adcCounts|cellPedestal|cellRawAmplitude|cellRawTime)+> -<!ATTLIST MBTS %attributes;> - -<!ELEMENT MDT (barcode|driftR|id|identifier|kine|length|x|y|z)+> -<!ATTLIST MDT %attributes;> - -<!ELEMENT MSeg (cotTheta|hits|numHits|phi0|x|y|z)+> -<!ATTLIST MSeg %attributes;> - -<!ELEMENT Muon (author|chi2|dataType|eta|etConeIsol|pdgId|phi|pt| - trackIndex|trackKey|trackLinkCount)+> -<!ATTLIST Muon %attributes;> - -<!ELEMENT MuonETMis (et|etx|ety)+> -<!ATTLIST MuonETMis %attributes;> - -<!ELEMENT MuonROI (energy|eta|phi|roiWord|thrName|thrNumber|thrValue)+> -<!ATTLIST MuonROI %attributes;> - -<!ELEMENT MuonSegment (hits|numHits|phi|theta|x|y|z)+> -<!ATTLIST MuonSegment %attributes;> - -<!ELEMENT ParticleJet (cells|cluster|et|eta|id|numCells|phi|pt)+> -<!ATTLIST ParticleJet %attributes;> - -<!ELEMENT PixCluster (barcode|barcodes|eloss|etaModule|id|numBarcodes| - phiModule|widthx|widthy|x0|y0|z0)+> -<!ATTLIST PixCluster %attributes;> - -<!ELEMENT Photon (clusterIndex|clusterKey|clusterLinkCount|emWeight|et37| - eta|etCone|etHad1|f1|fracs1|isEM|isEMString|phi|pionWeight|pt)+> -<!ATTLIST Photon %attributes;> - -<!-- PixelRDO - object derived from S3D --> -<!ELEMENT PixelRDO (etaModule|id|phiModule|x|y|z)+> -<!ATTLIST PixelRDO %attributes;> - -<!ELEMENT RMTr (barcode|cotTheta|hits|hitsFull|id|kine|numHits| - numPolyline|phi0|polylineX|polylineY|polylineZ|pt| - x|y|z)+> -<!ATTLIST RMTr %attributes;> - -<!ELEMENT RPC (barcode|id|identifier|kine|length|width|x|y|z)+> -<!ATTLIST RPC %attributes;> - -<!ELEMENT RTr (barcode|chi2|cotTheta|covMatrix|d0|kine|phi0|pt|z0)+> -<!ATTLIST RTr %attributes;> - -<!ELEMENT RVx (chi2|covMatrix|numTracks|vertexType|primVxCand| - sgkey|tracks|x|y|z)+> -<!ATTLIST RVx %attributes;> - -<!ELEMENT S3D (barcode|barcodes|clusters|etaModule|kine|numBarcodes|phi| - phiModule|rho|x|y|z)+> -<!ATTLIST S3D %attributes;> - -<!-- SCTRDO - object derived from STC (SiCluster) --> -<!ELEMENT SCTRDO (BCIDError|etaModule|firstHitError|formatterError|id| - lvl1Error|phiModule|preambleError|secondHitError| - syncError|timeBin|x0|x1|y0|y1|z0|z1)+> -<!ATTLIST SCTRDO %attributes;> - -<!ELEMENT Segment (hits|numHits|phi|theta|x|y|z)+> -<!ATTLIST Segment %attributes;> - -<!ELEMENT SiHit (energyloss|trackid|x|y|z)+> -<!ATTLIST SiHit %attributes;> - -<!ELEMENT SMTr (barcode|cotTheta|id|kine|phi0|pt|x|y|z)+> -<!ATTLIST SMTr %attributes;> - -<!ELEMENT STC (barcode|barcodes|etaModule|id|kine|numBarcodes| - phiModule|widthside|x0|x1|y0|y1|z0|z1)+> -<!ATTLIST STC %attributes;> - -<!ELEMENT STr (barcode|code|eta|id|phi|phiEndVertex|phiVertex|pt| - rhoEndVertex|rhoVertex|zVertex|zEndVertex)+> -<!ATTLIST STr %attributes;> - -<!ELEMENT TauJet (author|charge|clusterIndex|clusterKey|clusterLinkCount| - emRadius|eta|etEMCalib|etHadCalib|isolFrac|isTau|isTauString| - logLhRatio|numTracks|phi|pt|stripWidth|trackIndex| - trackKey|trackLinkCount)+> -<!ATTLIST TauJet %attributes;> - -<!ELEMENT TGC (barcode|id|identifier|kine|length|lwidth|swidth| - x|y|z)+> -<!ATTLIST TGC %attributes;> - -<!ELEMENT TILE (adcCounts1|adcCounts2|BadCell|cluster|energy|eta|id|layer|phi| - pmt1Chi2|pmt1Energy|pmt1Gain|pmt1Number|pmt1Pedestal| - pmt1Time|pmt2Chi2|pmt2Energy|pmt2Gain|pmt2Number| - pmt2Pedestal|pmt2Time|sub|pmt1ADCStatus|pmt2ADCStatus| - pmt1RawTime|pmt2RawTime|pmt1RawAmplitude|pmt2RawAmplitude)+> -<!ATTLIST TILE %attributes;> - -<!ELEMENT Track (author|barcode|chi2|cotTheta|covMatrix|d0|driftSign|hits|id| - isOutlier|kine|numHits|numPolyline|numTsos|phi0|polylineX| - polylineY|polylineZ|pt|tsosDetType|tsosPosR|tsosPullLoc1| - tsosPullLoc2|tsosResLoc1|tsosResLoc2|trackAuthor|z0|numDoF| - nBLayerHits|nPixHits|nSCTHits|nTRTHits)+> -<!ATTLIST Track %attributes;> - -<!ELEMENT TrigS3D (barcodes|cluster|dphi|dr|dz|eta|id|layer|numBarcodes|phi| - r|x|y|z)+> -<!ATTLIST TrigS3D %attributes;> - -<!ELEMENT TriggerInfo (energyEtMiss|energyEx|energyEy|energySumEt| - trigInfoEF|trigInfoExtL1ID|trigInfoL1|trigInfoL2| - trigInfoLvl1Type|trigInfoStatus|trigInfoStreamTag)+> -<!ATTLIST TriggerInfo %attributes;> - -<!ELEMENT TRT (barcode|barcodes|driftR|id|kine|numBarcodes|phi|rhoz|sub| - threshold|noise|bitPattern|timeOverThreshold)+> -<!ATTLIST TRT %attributes;> - -<!ELEMENT xKal (barcode|chi2|cotTheta|covMatrix|d0|hits| - id|numHits|numPolyline|phi0|polylineX|polylineY| - polylineZ|pt|z0)+> -<!ATTLIST xKal %attributes;> - -<!ELEMENT OutOfTimeEfrac (#PCDATA)> <!ATTLIST OutOfTimeEfrac %float;> -<!ELEMENT adc2Mev (#PCDATA)> <!ATTLIST adc2Mev %float;> -<!ELEMENT adcCounts (#PCDATA)> <!ATTLIST adcCounts %integer;> -<!ELEMENT adcCounts1 (#PCDATA)> <!ATTLIST adcCounts1 %integer;> -<!ELEMENT adcCounts2 (#PCDATA)> <!ATTLIST adcCounts2 %integer;> -<!ELEMENT author (#PCDATA)> <!ATTLIST author %string;> -<!ELEMENT BadCell (#PCDATA)> <!ATTLIST BadCell %integer;> -<!ELEMENT barcode (#PCDATA)> <!ATTLIST barcode %integer;> -<!ELEMENT barcodes (#PCDATA)> <!ATTLIST barcodes %integer;> -<!ELEMENT bitPattern (#PCDATA)> <!ATTLIST bitPattern %integer;> -<!ELEMENT BCIDError (#PCDATA)> <!ATTLIST BCIDError %integer;> -<!ELEMENT bTagName (#PCDATA)> <!ATTLIST bTagName %string;> -<!ELEMENT bTagValue (#PCDATA)> <!ATTLIST bTagValue %float;> -<!ELEMENT cellTime (#PCDATA)> <!ATTLIST cellTime %float;> -<!ELEMENT cellGain (#PCDATA)> <!ATTLIST cellGain %integer;> -<!ELEMENT cellPedestal (#PCDATA)> <!ATTLIST cellPedestal %float;> -<!ELEMENT cells (#PCDATA)> <!ATTLIST cells %integer;> -<!ELEMENT channel (#PCDATA)> <!ATTLIST channel %integer;> -<!ELEMENT feedThrough (#PCDATA)> <!ATTLIST feedThrough %integer;> -<!ELEMENT slot (#PCDATA)> <!ATTLIST slot %integer;> -<!ELEMENT charge (#PCDATA)> <!ATTLIST charge %float;> -<!ELEMENT chi2 (#PCDATA)> <!ATTLIST chi2 %float;> -<!ELEMENT cluster (#PCDATA)> <!ATTLIST cluster %integer;> -<!ELEMENT clusters (#PCDATA)> <!ATTLIST clusters %integer;> -<!ELEMENT clusterIndex (#PCDATA)> <!ATTLIST clusterIndex %integer;> -<!ELEMENT clusterKey (#PCDATA)> <!ATTLIST clusterKey %string;> -<!ELEMENT clusterLinkCount (#PCDATA)> <!ATTLIST clusterKey %integer;> -<!ELEMENT code (#PCDATA)> <!ATTLIST code %integer;> -<!ELEMENT cotTheta (#PCDATA)> <!ATTLIST cotTheta %float;> -<!ELEMENT covMatrix (#PCDATA)> <!ATTLIST covMatrix %float;> -<!ELEMENT ctpItemList (#PCDATA)> <!ATTLIST ctpItemList %string;> -<!ELEMENT ctpWord0 (#PCDATA)> <!ATTLIST ctpWord0 %integer;> -<!ELEMENT ctpWord1 (#PCDATA)> <!ATTLIST ctpWord1 %integer;> -<!ELEMENT ctpWord2 (#PCDATA)> <!ATTLIST ctpWord2 %integer;> -<!ELEMENT d0 (#PCDATA)> <!ATTLIST d0 %float;> -<!ELEMENT dataType (#PCDATA)> <!ATTLIST dataType %integer;> -<!ELEMENT daughterIndex (#PCDATA)> <!ATTLIST daughterIndex %integer;> -<!ELEMENT daughterKey (#PCDATA)> <!ATTLIST daughterKey %string;> -<!ELEMENT daughterPdgId (#PCDATA)> <!ATTLIST daughterPdgId %integer;> -<!ELEMENT deta (#PCDATA)> <!ATTLIST deta %float;> -<!ELEMENT dphi (#PCDATA)> <!ATTLIST dphi %float;> -<!ELEMENT dr (#PCDATA)> <!ATTLIST dr %float;> -<!ELEMENT driftR (#PCDATA)> <!ATTLIST driftR %float;> -<!ELEMENT driftSign (#PCDATA)> <!ATTLIST driftSign %integer;> -<!ELEMENT dx (#PCDATA)> <!ATTLIST dx %float;> -<!ELEMENT dy (#PCDATA)> <!ATTLIST dy %float;> -<!ELEMENT dz (#PCDATA)> <!ATTLIST dz %float;> -<!ELEMENT eloss (#PCDATA)> <!ATTLIST eloss %float;> -<!ELEMENT emfrac (#PCDATA)> <!ATTLIST emfrac %float;> -<!ELEMENT emADC (#PCDATA)> <!ATTLIST emADC %integer;> -<!ELEMENT emBCID (#PCDATA)> <!ATTLIST emBCID %integer;> -<!ELEMENT emEnergy (#PCDATA)> <!ATTLIST emEnergy %float;> -<!ELEMENT emRadius (#PCDATA)> <!ATTLIST emRadius %float;> -<!ELEMENT emWeight (#PCDATA)> <!ATTLIST emWeight %float;> -<!ELEMENT energy (#PCDATA)> <!ATTLIST energy %float;> -<!ELEMENT energyEM (#PCDATA)> <!ATTLIST energyEM %float;> -<!ELEMENT energyTAU (#PCDATA)> <!ATTLIST energyTAU %float;> -<!ELEMENT energyEtMiss (#PCDATA)> <!ATTLIST energyEtMiss %float;> -<!ELEMENT energyEx (#PCDATA)> <!ATTLIST energyEx %float;> -<!ELEMENT energyEy (#PCDATA)> <!ATTLIST energyEy %float;> -<!ELEMENT energyloss (#PCDATA)> <!ATTLIST energyloss %float;> -<!ELEMENT energySumEt (#PCDATA)> <!ATTLIST energySumEt %float;> -<!ELEMENT eOverp (#PCDATA)> <!ATTLIST eOverp %float;> -<!ELEMENT et (#PCDATA)> <!ATTLIST et %float;> -<!ELEMENT et37 (#PCDATA)> <!ATTLIST et37 %float;> -<!ELEMENT eta (#PCDATA)> <!ATTLIST eta %float;> -<!ELEMENT etaModule (#PCDATA)> <!ATTLIST etaModule %integer;> -<!ELEMENT etCone (#PCDATA)> <!ATTLIST etCone %float;> -<!ELEMENT etCone20 (#PCDATA)> <!ATTLIST etCone20 %float;> -<!ELEMENT etEMCalib (#PCDATA)> <!ATTLIST etEMCalib %float;> -<!ELEMENT etHad1 (#PCDATA)> <!ATTLIST etHad1 %float;> -<!ELEMENT etHadCalib (#PCDATA)> <!ATTLIST etHadCalib %float;> -<!ELEMENT etx (#PCDATA)> <!ATTLIST etx %float;> -<!ELEMENT ety (#PCDATA)> <!ATTLIST ety %float;> -<!ELEMENT etConeIsol (#PCDATA)> <!ATTLIST etConeIsol %float;> -<!ELEMENT f1 (#PCDATA)> <!ATTLIST f1 %float;> -<!ELEMENT firstHitError (#PCDATA)> <!ATTLIST firstHitError %integer;> -<!ELEMENT fcorCell (#PCDATA)> <!ATTLIST fcorCell %float;> -<!ELEMENT fcorDotx (#PCDATA)> <!ATTLIST fcorDotx %float;> -<!ELEMENT fcorJet (#PCDATA)> <!ATTLIST fcorJet %float;> -<!ELEMENT fcorJetForCell (#PCDATA)> <!ATTLIST fcorJetForCell %float;> -<!ELEMENT formatterError (#PCDATA)> <!ATTLIST formatterError %integer;> -<!ELEMENT fracs1 (#PCDATA)> <!ATTLIST fracs1 %float;> -<!ELEMENT fracSamplingMax (#PCDATA)> <!ATTLIST fracSamplingMax %float;> -<!ELEMENT hadADC (#PCDATA)> <!ATTLIST hadADC %integer;> -<!ELEMENT hadBCID (#PCDATA)> <!ATTLIST hadBCID %integer;> -<!ELEMENT hadEnergy (#PCDATA)> <!ATTLIST hadEnergy %float;> -<!ELEMENT hasTrack (#PCDATA)> <!ATTLIST hasTrack %integer;> -<!ELEMENT hecf (#PCDATA)> <!ATTLIST hecf %float;> -<!ELEMENT hits (#PCDATA)> <!ATTLIST hits %integer;> -<!ELEMENT hitsBLayer (#PCDATA)> <!ATTLIST hitsBLayer %integer;> -<!ELEMENT hitsFull (#PCDATA)> <!ATTLIST hitsFull %string;> -<!ELEMENT hitsHighThresTRT (#PCDATA)> <!ATTLIST hitsHighThresTRT %integer;> -<!ELEMENT hitsPixel (#PCDATA)> <!ATTLIST hitsPixel %integer;> -<!ELEMENT hitsSCT (#PCDATA)> <!ATTLIST hitsSCT %integer;> -<!ELEMENT hitsTRT (#PCDATA)> <!ATTLIST hitsTRT %integer;> -<!ELEMENT id (#PCDATA)> <!ATTLIST id %integer;> -<!ELEMENT identifier (#PCDATA)> <!ATTLIST identifier %string;> -<!ELEMENT isBad (#PCDATA)> <!ATTLIST isBad %float;> -<!ELEMENT isEM (#PCDATA)> <!ATTLIST isEM %integer;> -<!ELEMENT isEMString (#PCDATA)> <!ATTLIST isEMString %string;> -<!ELEMENT isEMSaturated (#PCDATA)> <!ATTLIST isEMSaturated %integer;> -<!ELEMENT isGood (#PCDATA)> <!ATTLIST isGood %float;> -<!ELEMENT isHadSaturated (#PCDATA)> <!ATTLIST isHadSaturated %integer;> -<!ELEMENT isTau (#PCDATA)> <!ATTLIST isTau %integer;> -<!ELEMENT isTauString (#PCDATA)> <!ATTLIST isTauString %string;> -<!ELEMENT isUgly (#PCDATA)> <!ATTLIST isUgly %float;> -<!ELEMENT isolated (#PCDATA)> <!ATTLIST isolated %integer;> -<!ELEMENT isolFrac (#PCDATA)> <!ATTLIST isolFrac %float;> -<!ELEMENT isOutlier (#PCDATA)> <!ATTLIST isOutlier %integer;> -<!ELEMENT itemListEF (#PCDATA)> <!ATTLIST itemListEF %string;> -<!ELEMENT itemListL2 (#PCDATA)> <!ATTLIST itemListL2 %string;> -<!ELEMENT jvf (#PCDATA)> <!ATTLIST jvf %float;> -<!ELEMENT kine (#PCDATA)> <!ATTLIST kine %integer;> -<!ELEMENT label (#PCDATA)> <!ATTLIST label %string;> -<!ELEMENT layer (#PCDATA)> <!ATTLIST layer %integer;> -<!ELEMENT length (#PCDATA)> <!ATTLIST length %float;> -<!ELEMENT lhSig (#PCDATA)> <!ATTLIST lhSig %float;> -<!ELEMENT logLhRatio (#PCDATA)> <!ATTLIST logLhRatio %float;> -<!ELEMENT lvl1Error (#PCDATA)> <!ATTLIST lvl1Error %integer;> -<!ELEMENT lwidth (#PCDATA)> <!ATTLIST lwidth %float; > -<!ELEMENT mass (#PCDATA)> <!ATTLIST mass %float;> -<!ELEMENT module (#PCDATA)> <!ATTLIST module %integer;> -<!ELEMENT nbadcells (#PCDATA)> <!ATTLIST nbadcells %integer;> -<!ELEMENT noise (#PCDATA)> <!ATTLIST noise %integer;> -<!ELEMENT nBLayerHits (#PCDATA)> <!ATTLIST nBLayerHits %integer;> -<!ELEMENT nPixHits (#PCDATA)> <!ATTLIST nPixHits %integer;> -<!ELEMENT nSCTHits (#PCDATA)> <!ATTLIST nSCTHits %integer;> -<!ELEMENT nTRTHits (#PCDATA)> <!ATTLIST nTRTHits %integer;> -<!ELEMENT n90cells (#PCDATA)> <!ATTLIST n90cells %integer;> -<!ELEMENT n90const (#PCDATA)> <!ATTLIST n90const %integer;> -<!ELEMENT numADC (#PCDATA)> <!ATTLIST numADC %integer;> -<!ELEMENT numBarcodes (#PCDATA)> <!ATTLIST numBarcodes %integer;> -<!ELEMENT numCells (#PCDATA)> <!ATTLIST numCells %integer;> -<!ELEMENT numDoF (#PCDATA)> <!ATTLIST numDoF %integer;> -<!ELEMENT numHits (#PCDATA)> <!ATTLIST numHits %integer;> -<!ELEMENT numPolyline (#PCDATA)> <!ATTLIST numPolyline %integer;> -<!ELEMENT numTracks (#PCDATA)> <!ATTLIST numTracks %integer;> -<!ELEMENT numTsos (#PCDATA)> <!ATTLIST numTsos %integer;> -<!ELEMENT passedEF (#PCDATA)> <!ATTLIST passedEF %integer;> -<!ELEMENT passedL1 (#PCDATA)> <!ATTLIST passedL1 %integer;> -<!ELEMENT passedL2 (#PCDATA)> <!ATTLIST passedL2 %integer;> -<!ELEMENT passedTrigger (#PCDATA)> <!ATTLIST passedTrigger %integer;> -<!ELEMENT pdgId (#PCDATA)> <!ATTLIST pdgId %integer;> -<!ELEMENT phi (#PCDATA)> <!ATTLIST phi %float;> -<!ELEMENT phi0 (#PCDATA)> <!ATTLIST phi0 %float;> -<!ELEMENT phiEndVertex (#PCDATA)> <!ATTLIST phiEndVertex %float;> -<!ELEMENT phiModule (#PCDATA)> <!ATTLIST phiModule %integer;> -<!ELEMENT phiVertex (#PCDATA)> <!ATTLIST phiVertex %float;> -<!ELEMENT pionWeight (#PCDATA)> <!ATTLIST pionWeight %float;> -<!ELEMENT pmt1Energy (#PCDATA)> <!ATTLIST pmt1Energy %float;> -<!ELEMENT pmt2Energy (#PCDATA)> <!ATTLIST pmt2Energy %float;> -<!ELEMENT pmt1Chi2 (#PCDATA)> <!ATTLIST pmt1Chi2 %float;> -<!ELEMENT pmt2Chi2 (#PCDATA)> <!ATTLIST pmt2Chi2 %float;> -<!ELEMENT pmt1Time (#PCDATA)> <!ATTLIST pmt1Time %float;> -<!ELEMENT pmt2Time (#PCDATA)> <!ATTLIST pmt2Time %float;> -<!ELEMENT cellRawAmplitude (#PCDATA)> <!ATTLIST cellRawAmplitude %float;> -<!ELEMENT cellRawTime (#PCDATA)> <!ATTLIST cellRawTime %float;> -<!ELEMENT pmt1RawTime (#PCDATA)> <!ATTLIST pmt1RawTime %float;> -<!ELEMENT pmt2RawTime (#PCDATA)> <!ATTLIST pmt2RawTime %float;> -<!ELEMENT pmt1RawAmplitude (#PCDATA)> <!ATTLIST pmt1RawAmplitude %float;> -<!ELEMENT pmt2RawAmplitude (#PCDATA)> <!ATTLIST pmt2RawAmplitude %float;> -<!ELEMENT pmt1Gain (#PCDATA)> <!ATTLIST pmt1Gain %integer;> -<!ELEMENT pmt2Gain (#PCDATA)> <!ATTLIST pmt2Gain %integer;> -<!ELEMENT pmt1Pedestal (#PCDATA)> <!ATTLIST pmt1Pedestal %float;> -<!ELEMENT pmt2Pedestal (#PCDATA)> <!ATTLIST pmt2Pedestal %float;> -<!ELEMENT pmt1Number (#PCDATA)> <!ATTLIST pmt1Number %integer;> -<!ELEMENT pmt2Number (#PCDATA)> <!ATTLIST pmt2Number %integer;> -<!ELEMENT pmt1ADCStatus (#PCDATA)> <!ATTLIST pmt1ADCStatus %integer;> -<!ELEMENT pmt2ADCStatus (#PCDATA)> <!ATTLIST pmt2ADCStatus %integer;> -<!ELEMENT polylineX (#PCDATA)> <!ATTLIST polylineX %float;> -<!ELEMENT polylineY (#PCDATA)> <!ATTLIST polylineY %float;> -<!ELEMENT polylineZ (#PCDATA)> <!ATTLIST polylineZ %float;> -<!ELEMENT preambleError (#PCDATA)> <!ATTLIST preambleError %integer;> -<!ELEMENT prescaleListEF (#PCDATA)> <!ATTLIST prescaleListEF %string;> -<!ELEMENT prescaleListL1 (#PCDATA)> <!ATTLIST prescaleListL1 %string;> -<!ELEMENT prescaleListL2 (#PCDATA)> <!ATTLIST prescaleListL2 %string;> -<!ELEMENT vertexType (#PCDATA)> <!ATTLIST vertexType %integer;> -<!ELEMENT primVxCand (#PCDATA)> <!ATTLIST primVxCand %integer;> -<!ELEMENT pt (#PCDATA)> <!ATTLIST pt %float;> -<!ELEMENT px (#PCDATA)> <!ATTLIST px %float;> -<!ELEMENT py (#PCDATA)> <!ATTLIST py %float;> -<!ELEMENT pz (#PCDATA)> <!ATTLIST pz %float;> -<!ELEMENT quality (#PCDATA)> <!ATTLIST quality %float;> -<!ELEMENT qualityLAr (#PCDATA)> <!ATTLIST qualityLAr %float;> -<!ELEMENT qualityTile (#PCDATA)> <!ATTLIST qualityTile %float;> -<!ELEMENT r (#PCDATA)> <!ATTLIST r %float;> -<!ELEMENT rho (#PCDATA)> <!ATTLIST rho %float;> -<!ELEMENT rhoEndVertex (#PCDATA)> <!ATTLIST rhoEndVertex %float;> -<!ELEMENT rhoVertex (#PCDATA)> <!ATTLIST rhoVertex %float;> -<!ELEMENT rhoz (#PCDATA)> <!ATTLIST rhoz %float;> -<!ELEMENT roiWord (#PCDATA)> <!ATTLIST roiWord %float;> -<!ELEMENT sampling (#PCDATA)> <!ATTLIST sampling %integer;> -<!ELEMENT secondHitError (#PCDATA)> <!ATTLIST secondHitError %integer;> -<!ELEMENT secVtxCount (#PCDATA)> <!ATTLIST secVtxCount %float;> -<!ELEMENT secVtxFitProb (#PCDATA)> <!ATTLIST secVtxFitProb %float;> -<!ELEMENT secVtxMass (#PCDATA)> <!ATTLIST secVtxMass %float;> -<!ELEMENT secVtxMult (#PCDATA)> <!ATTLIST secVtxMult %integer;> -<!ELEMENT secVtxRPhiDist (#PCDATA)> <!ATTLIST secVtxRPhiDist %float;> -<!ELEMENT secVtxTagLh (#PCDATA)> <!ATTLIST secVtxTagLh %float;> -<!ELEMENT secVtxTagLhErr (#PCDATA)> <!ATTLIST secVtxTagLhErr %float;> -<!ELEMENT sgkey (#PCDATA)> <!ATTLIST sgkey %string;> -<!ELEMENT side (#PCDATA)> <!ATTLIST side %integer;> -<!ELEMENT sigma (#PCDATA)> <!ATTLIST sigma %float;> -<!ELEMENT sMax (#PCDATA)> <!ATTLIST sMax %float;> -<!ELEMENT stripWidth (#PCDATA)> <!ATTLIST stripWidth %float;> -<!ELEMENT sub (#PCDATA)> <!ATTLIST sub %integer;> -<!ELEMENT sumEnergy (#PCDATA)> <!ATTLIST sumEnergy %float;> -<!ELEMENT swidth (#PCDATA)> <!ATTLIST swidth %float;> -<!ELEMENT syncError (#PCDATA)> <!ATTLIST syncError %integer;> -<!ELEMENT theta (#PCDATA)> <!ATTLIST theta %float;> -<!ELEMENT threshold (#PCDATA)> <!ATTLIST threshold %integer;> -<!ELEMENT timeOverThreshold (#PCDATA)> <!ATTLIST timeOverThreshold %float;> -<!ELEMENT thrName (#PCDATA)> <!ATTLIST thrName %string;> -<!ELEMENT thrNumber (#PCDATA)> <!ATTLIST thrNumber %float;> -<!ELEMENT thrValue (#PCDATA)> <!ATTLIST thrValue %float;> -<!ELEMENT thrPattern (#PCDATA)> <!ATTLIST thrPattern %float;> -<!ELEMENT tileGap3f (#PCDATA)> <!ATTLIST tileGap3f %float;> -<!ELEMENT time (#PCDATA)> <!ATTLIST time %float;> -<!ELEMENT timeClusters (#PCDATA)> <!ATTLIST timeClusters %float;> -<!ELEMENT timeBin (#PCDATA)> <!ATTLIST timeBin %integer;> -<!ELEMENT trackAuthor (#PCDATA)> <!ATTLIST trackAuthor %integer;> -<!ELEMENT trackid (#PCDATA)> <!ATTLIST trackid %integer;> -<!ELEMENT trackIndex (#PCDATA)> <!ATTLIST trackIndex %integer;> -<!ELEMENT trackKey (#PCDATA)> <!ATTLIST trackKey %string;> -<!ELEMENT trackLinkCount (#PCDATA)> <!ATTLIST trackLinkCount %integer;> -<!ELEMENT tracks (#PCDATA)> <!ATTLIST tracks %integer;> -<!ELEMENT trigInfoEF (#PCDATA)> <!ATTLIST trigInfoEF %string;> -<!ELEMENT trigInfoExtL1ID (#PCDATA)> <!ATTLIST trigInfoExtL1ID %string;> -<!ELEMENT trigInfoL1 (#PCDATA)> <!ATTLIST trigInfoL1 %string;> -<!ELEMENT trigInfoL2 (#PCDATA)> <!ATTLIST trigInfoL2 %string;> -<!ELEMENT trigInfoLvl1Type (#PCDATA)> <!ATTLIST trigInfoLvl1Type %string;> -<!ELEMENT trigInfoStatus (#PCDATA)> <!ATTLIST trigInfoStatus %string;> -<!ELEMENT trigInfoStreamTag (#PCDATA)> <!ATTLIST trigInfoStreamTag %string;> -<!ELEMENT tsosDetType (#PCDATA)> <!ATTLIST tsosDetType %string;> -<!ELEMENT tsosPosR (#PCDATA)> <!ATTLIST tsosPosR %float;> -<!ELEMENT tsosPullLoc1 (#PCDATA)> <!ATTLIST tsosPullLoc1 %float;> -<!ELEMENT tsosPullLoc2 (#PCDATA)> <!ATTLIST tsosPullLoc2 %float;> -<!ELEMENT tsosResLoc1 (#PCDATA)> <!ATTLIST tsosResLoc1 %float;> -<!ELEMENT tsosResLoc2 (#PCDATA)> <!ATTLIST tsosResLoc2 %float;> -<!ELEMENT type (#PCDATA)> <!ATTLIST type %integer;> -<!ELEMENT typeEV (#PCDATA)> <!ATTLIST typeEV %string;> -<!ELEMENT weight (#PCDATA)> <!ATTLIST weight %float;> -<!ELEMENT width (#PCDATA)> <!ATTLIST width %float;> -<!ELEMENT widthside (#PCDATA)> <!ATTLIST widthside %float;> -<!ELEMENT widthx (#PCDATA)> <!ATTLIST widthx %float;> -<!ELEMENT widthy (#PCDATA)> <!ATTLIST widthy %float;> -<!ELEMENT x (#PCDATA)> <!ATTLIST x %float;> -<!ELEMENT x0 (#PCDATA)> <!ATTLIST x0 %float;> -<!ELEMENT x1 (#PCDATA)> <!ATTLIST x1 %float;> -<!ELEMENT y (#PCDATA)> <!ATTLIST y %float;> -<!ELEMENT y0 (#PCDATA)> <!ATTLIST y0 %float;> -<!ELEMENT y1 (#PCDATA)> <!ATTLIST y1 %float;> -<!ELEMENT z (#PCDATA)> <!ATTLIST z %float;> -<!ELEMENT z0 (#PCDATA)> <!ATTLIST z0 %float;> -<!ELEMENT z1 (#PCDATA)> <!ATTLIST z1 %float;> -<!ELEMENT zEndVertex (#PCDATA)> <!ATTLIST zEndVertex %float;> -<!ELEMENT zVertex (#PCDATA)> <!ATTLIST zVertex %float;> diff --git a/graphics/AtlantisJava/geometry/AGeometry.xml b/graphics/AtlantisJava/geometry/AGeometry.xml deleted file mode 100755 index 0d903668879fb85de943955618e6a68b80bd1fa3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/geometry/AGeometry.xml +++ /dev/null @@ -1,233 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE AGeometry [ -<!ELEMENT AGeometry (ADisc | ARectangle | ABarrelCalorimeter | - AEndcapCalorimeter | AGapCalorimeter | - ABarrelSiliconDetector | AEndcapSiliconDetector | - ABarrelTRTDetector | AEndcapTRTDetector)* > -<!ELEMENT ADisc EMPTY > -<!ATTLIST ADisc - p CDATA #REQUIRED - c CDATA #REQUIRED - n CDATA #REQUIRED - rIn CDATA #REQUIRED - rOut CDATA #REQUIRED - nIn CDATA "256" - nOut CDATA "256"> -<!ELEMENT ARectangle EMPTY > -<!ATTLIST ARectangle - p CDATA #REQUIRED - c CDATA #REQUIRED - n CDATA #REQUIRED - xMin CDATA #REQUIRED - xMax CDATA #REQUIRED - yMin CDATA #REQUIRED - yMax CDATA #REQUIRED - xR (YES|NO) "YES" - yR (YES|NO) "YES"> -<!ELEMENT ABarrelCalorimeter EMPTY > -<!ATTLIST ABarrelCalorimeter - c CDATA #REQUIRED - n CDATA #REQUIRED - sampling CDATA #REQUIRED - region CDATA #REQUIRED - rMin CDATA #REQUIRED - rMax CDATA #REQUIRED - zMin CDATA #REQUIRED - zMax CDATA #REQUIRED - eta0 CDATA #REQUIRED - deta CDATA #REQUIRED - neta CDATA #REQUIRED - meta CDATA #REQUIRED - phi0 CDATA #REQUIRED - nphi CDATA #REQUIRED> -<!ELEMENT AEndcapCalorimeter EMPTY > -<!ATTLIST AEndcapCalorimeter - c CDATA #REQUIRED - n CDATA #REQUIRED - sampling CDATA #REQUIRED - region CDATA #REQUIRED - rMin CDATA #REQUIRED - rMax CDATA #REQUIRED - zMin CDATA #REQUIRED - zMax CDATA #REQUIRED - eta0 CDATA #REQUIRED - deta CDATA #REQUIRED - neta CDATA #REQUIRED - meta CDATA #REQUIRED - phi0 CDATA #REQUIRED - nphi CDATA #REQUIRED> -<!ELEMENT AGapCalorimeter EMPTY > -<!ATTLIST AGapCalorimeter - c CDATA #REQUIRED - n CDATA #REQUIRED - sampling CDATA #REQUIRED - region CDATA #REQUIRED - rMin CDATA #REQUIRED - rMax CDATA #REQUIRED - zMin CDATA #REQUIRED - zMax CDATA #REQUIRED - eta CDATA #REQUIRED - phi0 CDATA #REQUIRED - nphi CDATA #REQUIRED> -<!ELEMENT AEndcapCryostat EMPTY > -<!ATTLIST AEndcapCryostat - c CDATA #REQUIRED - n CDATA #REQUIRED - sampling CDATA #REQUIRED - region CDATA #REQUIRED - rMin CDATA #REQUIRED - rMax CDATA #REQUIRED - zMin CDATA #REQUIRED - zMax CDATA #REQUIRED - neta CDATA #REQUIRED - nphi CDATA #REQUIRED> -<!ELEMENT ABarrelSiliconDetector EMPTY > -<!ATTLIST ABarrelSiliconDetector - c CDATA #REQUIRED - n CDATA #REQUIRED - layer CDATA #REQUIRED - length CDATA #REQUIRED - width CDATA #REQUIRED - thickness CDATA #REQUIRED - tilt CDATA #REQUIRED - nz CDATA #REQUIRED - nphi CDATA #REQUIRED - r0 CDATA #REQUIRED - phi0 CDATA #REQUIRED - zMin CDATA #REQUIRED - zMax CDATA #REQUIRED> -<!ELEMENT AEndcapSiliconDetector EMPTY > -<!ATTLIST AEndcapSiliconDetector - c CDATA #REQUIRED - n CDATA #REQUIRED - layer CDATA #REQUIRED - length CDATA #REQUIRED - width CDATA #REQUIRED - thickness CDATA #REQUIRED - nz CDATA #REQUIRED - nphi CDATA #REQUIRED - rMin CDATA #REQUIRED - rMax CDATA #REQUIRED - phi0 CDATA #REQUIRED - zMin CDATA #REQUIRED - zMax CDATA #REQUIRED> -<!ELEMENT ABarrelTRTDetector EMPTY > -<!ATTLIST ABarrelTRTDetector - c CDATA #REQUIRED - n CDATA #REQUIRED - layer CDATA #REQUIRED - nphi CDATA #REQUIRED - rMin CDATA #REQUIRED - rMax CDATA #REQUIRED - phiIn CDATA #REQUIRED - phiOut CDATA #REQUIRED - zMin CDATA #REQUIRED - zMax CDATA #REQUIRED> -<!ELEMENT AEndcapTRTDetector EMPTY > -<!ATTLIST AEndcapTRTDetector - c CDATA #REQUIRED - n CDATA #REQUIRED - layer CDATA #REQUIRED - nphi CDATA #REQUIRED - rMin CDATA #REQUIRED - rMax CDATA #REQUIRED - phi0 CDATA #REQUIRED - zMin CDATA #REQUIRED - zMax CDATA #REQUIRED> -]> - -<AGeometry> -<ABarrelSiliconDetector c="PIX" n="Pixel" layer="0" length="2" width="1.9" thickness="0.270702" tilt="-14.0063" nz="20" nphi="14" r0="3.32803" phi0="22.2819" zMin="-33.6323" zMax="33.6323" /> -<ABarrelSiliconDetector c="PIX" n="Pixel" layer="1" length="6.08" width="1.64" thickness="0.306424" tilt="-19.9962" nz="13" nphi="22" r0="5.10491" phi0="-0.391852" zMin="-40.5702" zMax="40.5702" /> -<ABarrelSiliconDetector c="PIX" n="Pixel" layer="2" length="6.08" width="1.64" thickness="0.307646" tilt="-19.9962" nz="13" nphi="38" r0="8.88103" phi0="-0.12952" zMin="-40.5702" zMax="40.5702" /> -<ABarrelSiliconDetector c="PIX" n="Pixel" layer="3" length="6.08" width="1.64" thickness="0.30793" tilt="-19.9962" nz="13" nphi="52" r0="12.2722" phi0="3.38916" zMin="-40.5702" zMax="40.5702" /> -<AEndcapSiliconDetector c="PIX" n="Pixel" layer="0" length="6.08" width="1.64" thickness="1.51617" nz="1" nphi="48" rMin="8.91479" rMax="14.9795" phi0="3.75" zMin="48.79" zMax="49.79" /> -<AEndcapSiliconDetector c="PIX" n="Pixel" layer="1" length="6.08" width="1.64" thickness="1.51617" nz="1" nphi="48" rMin="8.91479" rMax="14.9795" phi0="3.75" zMin="57.29" zMax="58.29" /> -<AEndcapSiliconDetector c="PIX" n="Pixel" layer="2" length="6.08" width="1.64" thickness="1.51617" nz="1" nphi="48" rMin="8.91479" rMax="14.9795" phi0="3.75" zMin="64.29" zMax="65.29" /> -<ABarrelSiliconDetector c="SIL" n="Silicon" layer="0" length="12.609" width="6.144" thickness="0.83814" tilt="11.0677" nz="6" nphi="32" r0="30.134" phi0="3.24616" zMin="-74.8273" zMax="74.8273" /> -<ABarrelSiliconDetector c="SIL" n="Silicon" layer="1" length="12.609" width="6.144" thickness="0.75531" tilt="11.0546" nz="6" nphi="40" r0="37.2063" phi0="2.63207" zMin="-74.8273" zMax="74.8273" /> -<ABarrelSiliconDetector c="SIL" n="Silicon" layer="2" length="12.609" width="6.144" thickness="0.836751" tilt="11.2967" nz="6" nphi="48" r0="44.4326" phi0="2.10644" zMin="-74.8273" zMax="74.8273" /> -<ABarrelSiliconDetector c="SIL" n="Silicon" layer="3" length="12.609" width="6.144" thickness="0.776445" tilt="11.2902" nz="6" nphi="56" r0="51.4693" phi0="1.80488" zMin="-74.8273" zMax="74.8273" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="0" length="12.1235" width="6.2019" thickness="24.7693" nz="1" nphi="52" rMin="43.8426" rMax="56.2272" phi0="-1.03842" zMin="83.5567" zMax="84.6532" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="0" length="11.77" width="6.31592" thickness="24.099" nz="1" nphi="40" rMin="33.7464" rMax="45.7959" phi0="4.46486" zMin="86.5567" zMax="87.6532" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="1" length="12.1235" width="6.2019" thickness="24.7693" nz="1" nphi="52" rMin="43.8426" rMax="56.2272" phi0="-1.01417" zMin="91.5768" zMax="92.6732" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="1" length="11.77" width="6.31592" thickness="36.6061" nz="2" nphi="40" rMin="27.4929" rMax="45.7959" phi0="4.5" zMin="91.5768" zMax="95.6732" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="2" length="12.1235" width="6.2019" thickness="24.7693" nz="1" nphi="52" rMin="43.8426" rMax="56.2272" phi0="-1.03842" zMin="107.327" zMax="108.423" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="2" length="11.77" width="6.31592" thickness="36.6061" nz="2" nphi="40" rMin="27.4929" rMax="45.7959" phi0="4.46486" zMin="107.327" zMax="111.423" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="3" length="12.1235" width="6.2019" thickness="24.7693" nz="1" nphi="52" rMin="43.8426" rMax="56.2272" phi0="-1.01417" zMin="128.167" zMax="129.263" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="3" length="11.77" width="6.31592" thickness="36.6061" nz="2" nphi="40" rMin="27.4929" rMax="45.7959" phi0="4.5" zMin="128.167" zMax="132.263" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="4" length="12.1235" width="6.2019" thickness="24.7693" nz="1" nphi="52" rMin="43.8426" rMax="56.2272" phi0="-1.03842" zMin="138.147" zMax="139.243" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="4" length="11.77" width="6.31592" thickness="36.6061" nz="2" nphi="40" rMin="27.4929" rMax="45.7959" phi0="4.46486" zMin="138.147" zMax="142.243" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="5" length="12.1235" width="6.2019" thickness="24.7693" nz="1" nphi="52" rMin="43.8426" rMax="56.2272" phi0="-1.01417" zMin="175.317" zMax="176.413" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="5" length="11.77" width="6.31592" thickness="36.6061" nz="2" nphi="40" rMin="27.4929" rMax="45.7959" phi0="4.5" zMin="175.317" zMax="179.413" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="6" length="12.1235" width="6.2019" thickness="24.7693" nz="1" nphi="52" rMin="43.8426" rMax="56.2272" phi0="-1.03842" zMin="209.697" zMax="210.793" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="6" length="11.77" width="6.31592" thickness="24.099" nz="1" nphi="40" rMin="33.7464" rMax="45.7959" phi0="4.46486" zMin="212.697" zMax="213.793" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="7" length="12.1235" width="6.2019" thickness="24.7693" nz="1" nphi="52" rMin="43.8426" rMax="56.2272" phi0="-1.01417" zMin="248.677" zMax="249.773" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="7" length="5.2475" width="6.83547" thickness="11.0247" nz="1" nphi="40" rMin="40.2836" rMax="45.7959" phi0="4.5" zMin="251.677" zMax="252.773" /> -<AEndcapSiliconDetector c="SIL" n="Silicon" layer="8" length="12.1235" width="6.2019" thickness="24.7693" nz="1" nphi="52" rMin="43.8426" rMax="56.2272" phi0="1.01417" zMin="273.747" zMax="274.843" /> -<ABarrelTRTDetector c="TRT" n="TRT" layer="0" nphi="32" rMin="56.7302" rMax="69.8248" phiIn="-6.17382" phiOut="-10.7369" zMin="-70.975" zMax="70.975" /> -<ABarrelTRTDetector c="TRT" n="TRT" layer="1" nphi="32" rMin="70.1346" rMax="86.6458" phiIn="-10.7202" phiOut="-5.99874" zMin="-70.975" zMax="70.975" /> -<ABarrelTRTDetector c="TRT" n="TRT" layer="2" nphi="32" rMin="86.9559" rMax="107.232" phiIn="-6.00171" phiOut="-10.9221" zMin="-70.975" zMax="70.975" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="0" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="85.85" zMax="98.55" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="1" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="100.18" zMax="112.88" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="2" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="114.565" zMax="127.265" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="3" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="128.86" zMax="141.56" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="4" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="143.12" zMax="155.82" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="5" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="157.388" zMax="170.088" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="6" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="175.008" zMax="185.408" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="7" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="187.185" zMax="197.585" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="8" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="199.34" zMax="209.74" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="9" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="211.49" zMax="221.89" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="10" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="223.64" zMax="234.04" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="11" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="235.795" zMax="246.195" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="12" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="247.96" zMax="258.36" /> -<AEndcapTRTDetector c="TRT" n="TRT" layer="13" nphi="34" rMin="64.67" rMax="100.1" phi0="0" zMin="260.083" zMax="270.483" /> -<ADisc p="YX" c="Sol" n="Solenoid" rIn="122.9" rOut="127.4" /> -<ARectangle p="RZ" c="Sol" n="Solenoid" xMin="-265" xMax="265" yMin="122.9" yMax="127.4" xR="NO" /> -<ABarrelCalorimeter c="ECAL" n="LAr Presampler" sampling="0" region="0" rMin="142.173" rMax="143.858" zMin="0" zMax="325.0" eta0="3.1225e-17" deta="0.025" neta="61" meta="0" phi0="-0.175783" nphi="64" /> -<ABarrelCalorimeter c="ECAL" n="LAr" sampling="1" region="0" rMin="148.175" rMax="158" zMin="0" zMax="325.0" eta0="0.003125" deta="0.003125" neta="447" meta="1" phi0="-0.175783" nphi="64" /> -<ABarrelCalorimeter c="ECAL" n="LAr" sampling="1" region="1" rMin="148.175" rMax="158" zMin="0" zMax="325.0" eta0="1.4" deta="0.025" neta="3" meta="0" phi0="-0.175783" nphi="256" /> -<ABarrelCalorimeter c="ECAL" n="LAr" sampling="2" region="0" rMin="158" rMax="184" zMin="0" zMax="325.0" eta0="0.0" deta="0.025" neta="56" meta="0" phi0="-0.175783" nphi="256" /> -<ABarrelCalorimeter c="ECAL" n="LAr" sampling="2" region="1" rMin="158" rMax="184" zMin="0" zMax="325.0" eta0="1.4" deta="0.075" neta="1" meta="0" phi0="-0.175783" nphi="256" /> -<ABarrelCalorimeter c="ECAL" n="LAr" sampling="3" region="0" rMin="184" rMax="198.47" zMin="0" zMax="325.0" eta0="0.0" deta="0.05" neta="27" meta="0" phi0="-0.175783" nphi="256" /> -<AEndcapCalorimeter c="ECAL" n="LAr Endcap Presampler" sampling="0" region="0" rMin="29.0" rMax="203.4" zMin="368.075" zMax="371.425" eta0="1.50988" deta="0.025" neta="12" meta="0" phi0="-0.234375" nphi="64" /> -<AEndcapCalorimeter c="ECAL" n="LAr Outer Endcap" sampling="1" region="0" rMin="29.0" rMax="203.4" zMin="375.424" zMax="380.073" eta0="1.38444" deta="0.05" neta="1" meta="0" phi0="-0.234375" nphi="64" /> -<AEndcapCalorimeter c="ECAL" n="LAr Outer Endcap" sampling="1" region="1" rMin="29.0" rMax="203.4" zMin="375.424" zMax="380.073" eta0="1.43452" deta="0.025" neta="3" meta="0" phi0="-0.234375" nphi="64" /> -<AEndcapCalorimeter c="ECAL" n="LAr Outer Endcap" sampling="1" region="2" rMin="29.0" rMax="203.4" zMin="375.424" zMax="380.073" eta0="1.50965" deta="0.003125" neta="96" meta="0" phi0="-0.234375" nphi="64" /> -<AEndcapCalorimeter c="ECAL" n="LAr Outer Endcap" sampling="1" region="3" rMin="29.0" rMax="203.4" zMin="375.424" zMax="380.073" eta0="1.81009" deta="0.00416667" neta="48" meta="0" phi0="-0.234375" nphi="64" /> -<AEndcapCalorimeter c="ECAL" n="LAr Outer Endcap" sampling="1" region="4" rMin="29.0" rMax="203.4" zMin="375.424" zMax="380.073" eta0="2.01027" deta="0.00625" neta="64" meta="0" phi0="-0.234375" nphi="64" /> -<AEndcapCalorimeter c="ECAL" n="LAr Outer Endcap" sampling="1" region="5" rMin="29.0" rMax="203.4" zMin="375.424" zMax="380.073" eta0="2.41048" deta="0.025" neta="4" meta="0" phi0="-0.234375" nphi="64" /> -<AEndcapCalorimeter c="ECAL" n="LAr Inner Endcap" sampling="1" region="0" rMin="29.0" rMax="203.4" zMin="375.424" zMax="420.125" eta0="2.51004" deta="0.1" neta="7" meta="0" phi0="-0.234375" nphi="64" /> -<AEndcapCalorimeter c="ECAL" n="LAr Outer Endcap" sampling="2" region="0" rMin="29.0" rMax="203.4" zMin="380.073" zMax="424.326" eta0="1.38381" deta="0.05" neta="7" meta="0" phi0="-0.234375" nphi="256" /> -<AEndcapCalorimeter c="ECAL" n="LAr Outer Endcap" sampling="2" region="1" rMin="29.0" rMax="203.4" zMin="380.073" zMax="415.624" eta0="1.43388" deta="0.025" neta="43" meta="0" phi0="-0.234375" nphi="256" /> -<AEndcapCalorimeter c="ECAL" n="LAr Inner Endcap" sampling="2" region="0" rMin="29.0" rMax="203.4" zMin="420.125" zMax="424.326" eta0="2.5094" deta="0.1" neta="7" meta="0" phi0="-0.234375" nphi="64" /> -<AEndcapCalorimeter c="ECAL" n="LAr Outer Endcap" sampling="3" region="0" rMin="29.0" rMax="203.4" zMin="415.624" zMax="424.326" eta0="1.50867" deta="0.05" neta="20" meta="0" phi0="-0.234375" nphi="256" /> -<AEndcapCalorimeter c="HCAL" n="HEC" sampling="0" region="0" rMin="37.2" rMax="203.4" zMin="435" zMax="463" eta0="1.50824" deta="0.1" neta="10" meta="0" phi0="0" nphi="64" /> -<AEndcapCalorimeter c="HCAL" n="HEC" sampling="0" region="1" rMin="37.2" rMax="203.4" zMin="435" zMax="463" eta0="2.50892" deta="0.2" neta="4" meta="0" phi0="0" nphi="32" /> -<AEndcapCalorimeter c="HCAL" n="HEC" sampling="1" region="0" rMin="48.5" rMax="203.4" zMin="463" zMax="510" eta0="1.50755" deta="0.1" neta="10" meta="0" phi0="0" nphi="64" /> -<AEndcapCalorimeter c="HCAL" n="HEC" sampling="1" region="1" rMin="48.5" rMax="203.4" zMin="463" zMax="510" eta0="2.50817" deta="0.2" neta="3" meta="0" phi0="0" nphi="32" /> -<AEndcapCalorimeter c="HCAL" n="HEC" sampling="2" region="0" rMin="48.5" rMax="203.4" zMin="513" zMax="559" eta0="1.6" deta="0.1" neta="9" meta="1" phi0="0" nphi="64" /> -<AEndcapCalorimeter c="HCAL" n="HEC" sampling="2" region="1" rMin="48.5" rMax="203.4" zMin="513" zMax="559" eta0="2.5" deta="0.2" neta="3" meta="0" phi0="-7.95139e-16" nphi="32" /> -<AEndcapCalorimeter c="HCAL" n="HEC" sampling="3" region="0" rMin="48.5" rMax="203.4" zMin="559" zMax="605" eta0="1.7" deta="0.1" neta="8" meta="2" phi0="-3.97569e-16" nphi="64" /> -<AEndcapCalorimeter c="HCAL" n="HEC" sampling="3" region="1" rMin="48.5" rMax="203.4" zMin="559" zMax="605" eta0="2.5" deta="0.2" neta="4" meta="0" phi0="-7.95139e-16" nphi="32" /> -<ADisc p="YX" c="ECAL" n="FCAL EM" rIn="7.84392" rOut="47.5" /> -<ARectangle p="RZ" c="ECAL" n="FCAL EM" xMin="466.85" xMax="511.85" yMin="7.84392" yMax="47.5" /> -<ADisc p="YX" c="HCAL" n="FCAL HAD 1" rIn="7.90558" rOut="47.5" /> -<ARectangle p="RZ" c="HCAL" n="FCAL HAD 1" xMin="512.3" xMax="557.3" yMin="7.90558" yMax="47.5" /> -<ADisc p="YX" c="HCAL" n="FCAL HAD 2" rIn="7.96007" rOut="47.5" /> -<ARectangle p="RZ" c="HCAL" n="FCAL HAD 2" xMin="559.75" xMax="604.75" yMin="7.96007" yMax="47.5" /> -<ABarrelCalorimeter c="HCAL" n="TILE Barrel" sampling="0" region="0" rMin="229" rMax="260" zMin="0" zMax="282" eta0="0" deta="0.1" neta="10" meta="0" phi0="0" nphi="64" /> -<ABarrelCalorimeter c="HCAL" n="TILE Barrel" sampling="1" region="0" rMin="260" rMax="344" zMin="0" zMax="282" eta0="0" deta="0.1" neta="9" meta="0" phi0="0" nphi="64" /> -<ABarrelCalorimeter c="HCAL" n="TILE Barrel" sampling="2" region="0" rMin="344" rMax="386" zMin="-36.5199" zMax="282" eta0="-0.1" deta="0.2" neta="4" meta="0" phi0="0" nphi="64" /> -<ABarrelCalorimeter c="HCAL" n="Extended TILE" sampling="0" region="0" rMin="229" rMax="260" zMin="355.95" zMax="615" eta0="1.1" deta="0.1" neta="5" meta="11" phi0="0" nphi="64" /> -<ABarrelCalorimeter c="HCAL" n="Extended TILE" sampling="1" region="0" rMin="260" rMax="314" zMin="355.95" zMax="615" eta0="1" deta="0.1" neta="5" meta="10" phi0="0" nphi="64" /> -<ABarrelCalorimeter c="HCAL" n="Extended TILE" sampling="2" region="0" rMin="314" rMax="386" zMin="355.95" zMax="615" eta0="0.9" deta="0.2" neta="2" meta="10" phi0="0" nphi="64" /> -<AGapCalorimeter c="HCAL" n="ITC Gap" sampling="1" region="0" rMin="299" rMax="344" zMin="346.435" zMax="355.92" eta="9" phi0="0" nphi="64" /> -<AGapCalorimeter c="HCAL" n="ITC Gap" sampling="2" region="0" rMin="344" rMax="386" zMin="325.05" zMax="355.95" eta="8" phi0="0" nphi="64" /> -<AGapCalorimeter c="HCAL" n="ITC Gap" sampling="3" region="0" rMin="264.6" rMax="295.9" zMin="354.45" zMax="355.95" eta="10" phi0="0" nphi="64" /> -<AGapCalorimeter c="HCAL" n="ITC Gap" sampling="3" region="0" rMin="230.5" rMax="264.6" zMin="354.45" zMax="355.95" eta="11" phi0="0" nphi="64" /> -<AGapCalorimeter c="HCAL" n="ITC Gap" sampling="3" region="0" rMin="182.7" rMax="230.5" zMin="353.2" zMax="354" eta="13" phi0="0" nphi="64" /> -<AGapCalorimeter c="HCAL" n="ITC Gap" sampling="3" region="0" rMin="146.5" rMax="182.7" zMin="353.2" zMax="354" eta="15" phi0="0" nphi="64" /> -<AEndcapCryostat c="HCAL" n="Minimum Bias Trigger Scintillators" sampling="0" region="0" rMin="15.3" rMax="42.6" zMin="319.187" zMax="321.187" neta="1" nphi="8" /> -<AEndcapCryostat c="HCAL" n="Minimum Bias Trigger Scintillators" sampling="1" region="0" rMin="42.6" rMax="89" zMin="319.187" zMax="321.187" neta="1" nphi="8" /> -</AGeometry> diff --git a/graphics/AtlantisJava/geometry/AMuonGeometry.xml b/graphics/AtlantisJava/geometry/AMuonGeometry.xml deleted file mode 100755 index bf6ea122c013daecbd829202bb9479a6cbdba8a7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/geometry/AMuonGeometry.xml +++ /dev/null @@ -1,220 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE AMuonGeometry [ -<!ELEMENT AMuonGeometry (ABox | ATBx | ATrd)*> -<!ELEMENT ABox EMPTY > -<!ATTLIST ABox - n CDATA #REQUIRED - zi CDATA #REQUIRED - zo CDATA #REQUIRED - ri CDATA #REQUIRED - ro CDATA #REQUIRED - w CDATA #REQUIRED - eta CDATA #REQUIRED - phi CDATA #REQUIRED - dphi CDATA "0" - sh CDATA "0" - RPCi CDATA "0" - RPCo CDATA "0"> -<!ELEMENT ATBx EMPTY > -<!ATTLIST ATBx - n CDATA #REQUIRED - zi CDATA #REQUIRED - zo CDATA #REQUIRED - ri CDATA #REQUIRED - ro CDATA #REQUIRED - w CDATA #REQUIRED - eta CDATA #REQUIRED - phi CDATA #REQUIRED - sh CDATA "0" - dphi CDATA "0" - RPCi CDATA "0" - RPCo CDATA "0" - zis CDATA #REQUIRED - zos CDATA #REQUIRED - ws CDATA #REQUIRED - or CDATA "0"> -<!ELEMENT ATrd EMPTY > -<!ATTLIST ATrd - n CDATA #REQUIRED - zi CDATA #REQUIRED - zo CDATA #REQUIRED - ri CDATA #REQUIRED - ro CDATA #REQUIRED - wi CDATA #REQUIRED - wo CDATA #REQUIRED - eta CDATA #REQUIRED - phi CDATA #REQUIRED - dphi CDATA "0" - sh CDATA "0" - a CDATA "0"> -]> -<AMuonGeometry> -<ABox n="MDT_BIL" zi="33" zo="124.607" ri="474.091" ro="515.705" w="267.15" eta="1" phi="1 2 3 7" /> -<ABox n="MDT_BIL" zi="51" zo="124.586" ri="474.091" ro="515.705" w="267.15" eta="1" phi="4" /> -<ABox n="MDT_BIL" zi="56" zo="147.607" ri="525.691" ro="567.305" w="267.15" eta="1" phi="5" /> -<ABox n="MDT_BIL" zi="125" zo="234.628" ri="474.091" ro="515.705" w="267.15" eta="2" phi="1 2 3 4 5 7" /> -<ABox n="MDT_BIL" zi="235" zo="326.607" ri="474.091" ro="515.705" w="267.15" eta="3" phi="1 2 4 5 7" /> -<ABox n="MDT_BIL" zi="235" zo="344.628" ri="474.091" ro="515.705" w="267.15" eta="3" phi="3" /> -<ABox n="MDT_BIL" zi="345" zo="454.628" ri="474.091" ro="515.705" w="267.15" eta="4" phi="1 2 3 4 5" /> -<ABox n="MDT_BIL" zi="345" zo="436.607" ri="474.091" ro="515.705" w="267.15" eta="4" phi="7" /> -<ABox n="MDT_BIL" zi="455" zo="546.607" ri="474.091" ro="515.705" w="267.15" eta="5" phi="1 2 3 4 5" /> -<ABox n="MDT_BIL" zi="437" zo="528.607" ri="474.091" ro="515.705" w="267.15" eta="5" phi="7" /> -<ABox n="MDT_BIL" zi="547" zo="656.628" ri="474.091" ro="515.705" w="267.15" eta="6" phi="1 2 3 5" /> -<ABox n="MDT_BIL" zi="547" zo="638.607" ri="474.091" ro="515.705" w="267.15" eta="6" phi="4 7" /> -<ABox n="MDT_BIS" zi="1" zo="110.628" ri="440.793" ro="469.207" w="167.15" eta="1" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ABox n="MDT_BIS" zi="111" zo="202.607" ri="440.793" ro="469.207" w="167.15" eta="2" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ABox n="MDT_BIS" zi="203" zo="294.607" ri="440.793" ro="469.207" w="167.15" eta="3" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ABox n="MDT_BIS" zi="295" zo="386.607" ri="440.793" ro="469.207" w="167.15" eta="4" phi="1 2 3" dphi="22.5" /> -<ABox n="MDT_BIS" zi="313" zo="404.607" ri="440.793" ro="469.207" w="167.15" eta="4" phi="4 5 6 7 8" dphi="22.5" /> -<ABox n="MDT_BIS" zi="387" zo="478.607" ri="440.793" ro="469.207" w="167.15" eta="5" phi="1 2 3" dphi="22.5" /> -<ABox n="MDT_BIS" zi="405" zo="496.607" ri="440.793" ro="469.207" w="167.15" eta="5" phi="4 5 6 7 8" dphi="22.5" /> -<ABox n="MDT_BIS" zi="479" zo="570.607" ri="440.793" ro="469.207" w="167.15" eta="6" phi="1 2 3" dphi="22.5" /> -<ABox n="MDT_BIS" zi="497" zo="588.607" ri="440.793" ro="469.207" w="167.15" eta="6" phi="4 5 6 7 8" dphi="22.5" /> -<ABox n="MDT_BIS" zi="571" zo="680.628" ri="440.793" ro="469.207" w="167.15" eta="7" phi="1 2 3" dphi="22.5" /> -<ABox n="MDT_BIS" zi="589" zo="680.607" ri="440.793" ro="469.207" w="167.15" eta="7" phi="4 5 6 7 8" dphi="22.5" /> -<ABox n="MDT_BIS" zi="681" zo="730.558" ri="454.864" ro="466.145" w="85.15" eta="8" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ABox n="MDT_BML" zi="15" zo="184.698" ri="675.194" ro="754.205" w="357.6" eta="1" phi="1 2" RPCi="15" RPCo="15" /> -<ABox n="MDT_BML" zi="39" zo="184.67" ri="675.194" ro="754.205" w="357.6" eta="1" phi="3 7" RPCi="15" RPCo="15" /> -<ABox n="MDT_BML" zi="87" zo="184.614" ri="675.194" ro="753.005" w="357.6" eta="1" phi="4 5" RPCi="15" RPCo="15" /> -<ABox n="MDT_BML" zi="63" zo="184.642" ri="675.194" ro="753.005" w="357.6" eta="1" phi="6 8" RPCi="15" RPCo="15" /> -<ABox n="MDT_BML" zi="185" zo="354.698" ri="675.194" ro="754.205" w="357.6" eta="2" phi="1 2 3 4 5 6 7 8" RPCi="15" RPCo="15" /> -<ABox n="MDT_BML" zi="355" zo="524.698" ri="675.194" ro="754.205" w="357.6" eta="3" phi="1 2 3 4 5 6 7 8" RPCi="15" RPCo="15" /> -<ABox n="MDT_BML" zi="525" zo="646.642" ri="675.194" ro="753.005" w="357.6" eta="4" phi="1 2 3 4 5 6 8" RPCi="15" RPCo="15" /> -<ABox n="MDT_BML" zi="647" zo="768.642" ri="675.194" ro="753.005" w="357.6" eta="4" phi="7" RPCi="15" RPCo="15" /> -<ABox n="MDT_BML" zi="647" zo="768.642" ri="675.194" ro="753.005" w="357.6" eta="5" phi="1 2 3 4 5 6 8" RPCi="15" RPCo="15" /> -<ABox n="MDT_BML" zi="769" zo="914.67" ri="675.194" ro="754.205" w="357.6" eta="5" phi="7" RPCi="15" RPCo="15" /> -<ABox n="MDT_BML" zi="769" zo="914.67" ri="675.194" ro="754.205" w="357.6" eta="6" phi="1 2 3 4 5 6 8" RPCi="15" RPCo="15" /> -<ABox n="MDT_BML" zi="918" zo="966" ri="743.8" ro="753.8" w="304" eta="6" phi="7" RPCi="15" RPCo="15" /> -<ABox n="MDT_BML" zi="918" zo="966" ri="743.8" ro="753.8" w="304" eta="7" phi="1 2 3 4 5 6 8" RPCi="15" RPCo="15" /> -<ABox n="MDT_BMS" zi="15" zo="184.698" ri="777.694" ro="842.905" w="309.6" eta="1" phi="1 2 3 4 5 8" dphi="22.5" RPCi="15" RPCo="15" /> -<ABox n="MDT_BMS" zi="185" zo="364.5" ri="777.694" ro="845.705" w="309.6" eta="2" phi="1 2 3 4 5 8" dphi="22.5" RPCi="15" RPCo="15" /> -<ABox n="MDT_BMS" zi="368" zo="513.67" ri="777.694" ro="841.705" w="309.6" eta="3" phi="1 2 3 4 5 8" dphi="22.5" RPCi="15" RPCo="15" /> -<ABox n="MDT_BMS" zi="514" zo="691.35" ri="777.694" ro="851.305" w="309.6" eta="4" phi="1 2 3 4 5 8" dphi="22.5" RPCi="15" RPCo="15" /> -<ABox n="MDT_BMS" zi="692.5" zo="790.114" ri="777.694" ro="841.705" w="309.6" eta="5" phi="1 2 3 4 5 8" dphi="22.5" RPCi="15" RPCo="15" /> -<ABox n="MDT_BMS" zi="790.5" zo="936.17" ri="777.694" ro="842.905" w="309.6" eta="6" phi="1 2 3 4 5 8" dphi="22.5" RPCi="15" RPCo="15" /> -<ABox n="MDT_BOL" zi="15" zo="232.754" ri="924.444" ro="989.055" w="498.6" eta="1" phi="1 2" RPCo="15" /> -<ABox n="MDT_BOL" zi="39" zo="232.726" ri="924.444" ro="989.055" w="498.6" eta="1" phi="3" RPCo="15" /> -<ABox n="MDT_BOL" zi="87" zo="232.67" ri="924.444" ro="989.055" w="498.6" eta="1" phi="4 5" RPCo="15" /> -<ABox n="MDT_BOL" zi="63" zo="232.698" ri="924.444" ro="989.055" w="498.6" eta="1" phi="6 7 8" RPCo="15" /> -<ABox n="MDT_BOL" zi="233" zo="450.754" ri="924.444" ro="989.055" w="498.6" eta="2" phi="1 2 3 4 5 6 8" RPCo="15" /> -<ABox n="MDT_BOL" zi="233" zo="378.67" ri="924.444" ro="989.055" w="498.6" eta="2" phi="7" RPCo="15" /> -<ABox n="MDT_BOL" zi="451" zo="620.698" ri="924.444" ro="989.055" w="498.6" eta="3" phi="1 2 3 4 5 6 8" RPCo="15" /> -<ABox n="MDT_BOL" zi="379" zo="524.67" ri="924.444" ro="989.055" w="498.6" eta="3" phi="7" RPCo="15" /> -<ABox n="MDT_BOL" zi="621" zo="838.754" ri="924.444" ro="989.055" w="498.6" eta="4" phi="1 2 3 4 5 6 7 8" RPCo="15" /> -<ABox n="MDT_BOL" zi="839" zo="1056.75" ri="924.444" ro="989.055" w="498.6" eta="5" phi="1 2 3 4 5 6 7 8" RPCo="15" /> -<ABox n="MDT_BOL" zi="1057" zo="1226.7" ri="924.444" ro="989.055" w="498.6" eta="6" phi="1 2 3 4 5 6 7 8" RPCo="15" /> -<ABox n="MDT_BOS" zi="1" zo="218.754" ri="1019.19" ro="1082.46" w="379.6" eta="1" phi="1 2 3 5 8" dphi="22.5" RPCi="15" /> -<ABox n="MDT_BOS" zi="73" zo="218.67" ri="1019.19" ro="1082.46" w="379.6" eta="1" phi="4" dphi="22.5" RPCi="15" /> -<ABox n="MDT_BOS" zi="219" zo="436.754" ri="1019.19" ro="1082.46" w="379.6" eta="2" phi="1 2 3 4 5 8" dphi="22.5" RPCi="15" /> -<ABox n="MDT_BOS" zi="437" zo="654.754" ri="1019.19" ro="1082.46" w="379.6" eta="3" phi="1 2 3 4 5 8" dphi="22.5" RPCi="15" /> -<ABox n="MDT_BOS" zi="655" zo="872.754" ri="1019.19" ro="1082.46" w="379.6" eta="4" phi="1 2 3 4 5 8" dphi="22.5" RPCi="15" /> -<ABox n="MDT_BOS" zi="873" zo="1090.75" ri="1019.19" ro="1082.46" w="379.6" eta="5" phi="1 2 3 4 5 8" dphi="22.5" RPCi="15" /> -<ABox n="MDT_BOS" zi="1091" zo="1284.73" ri="1019.19" ro="1082.46" w="379.6" eta="6" phi="1 2 3 4 5 8" dphi="22.5" RPCi="15" /> -<ABox n="MDT_BEE" zi="877.9" zo="1023.57" ri="433.023" ro="452.33" w="91.15" eta="1" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ABox n="MDT_BEE" zi="1023.9" zo="1169.57" ri="433.023" ro="452.33" w="91.15" eta="2" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ABox n="MDT_BIR" zi="52" zo="143.607" ri="592.407" ro="634.021" w="267.15" eta="1" phi="6" sh="11.65" /> -<ABox n="MDT_BIR" zi="52" zo="143.607" ri="592.407" ro="634.021" w="267.15" eta="1" phi="8" sh="-11.65" /> -<ABox n="MDT_BIR" zi="200" zo="291.607" ri="596.1" ro="637.714" w="153.65" eta="2" phi="6" sh="68.4" /> -<ABox n="MDT_BIR" zi="200" zo="291.607" ri="596.1" ro="637.714" w="153.65" eta="2" phi="8" sh="-68.4" /> -<ABox n="MDT_BIR" zi="292" zo="392.617" ri="594.083" ro="635.697" w="110.55" eta="3" phi="6" sh="46.85" /> -<ABox n="MDT_BIR" zi="292" zo="392.617" ri="594.083" ro="635.697" w="110.55" eta="3" phi="8" sh="-46.85" /> -<ABox n="MDT_BIR" zi="394" zo="485.607" ri="596.1" ro="637.714" w="153.65" eta="4" phi="6" sh="68.4" /> -<ABox n="MDT_BIR" zi="394" zo="485.607" ri="596.1" ro="637.714" w="153.65" eta="4" phi="8" sh="-68.4" /> -<ABox n="MDT_BIR" zi="541" zo="614.586" ri="596.1" ro="637.714" w="153.65" eta="5" phi="6" sh="68.4" /> -<ABox n="MDT_BIR" zi="541" zo="614.586" ri="596.1" ro="637.714" w="153.65" eta="5" phi="8" sh="-68.4" /> -<ABox n="MDT_BIR" zi="616" zo="725.628" ri="594.083" ro="635.697" w="110.55" eta="6" phi="6" sh="46.85" /> -<ABox n="MDT_BIR" zi="616" zo="725.628" ri="594.083" ro="635.697" w="110.55" eta="6" phi="8" sh="-46.85" /> -<ABox n="MDT_BMF" zi="62.5" zo="280.254" ri="777.694" ro="841.705" w="309.6" eta="1" phi="6 7" dphi="22.5" RPCi="15" RPCo="15" /> -<ABox n="MDT_BMF" zi="406" zo="599.726" ri="777.694" ro="841.705" w="309.6" eta="2" phi="6 7" dphi="22.5" RPCi="15" RPCo="15" /> -<ABox n="MDT_BMF" zi="728" zo="873.67" ri="777.694" ro="841.705" w="309.6" eta="3" phi="6 7" dphi="22.5" RPCi="15" RPCo="15" /> -<ABox n="MDT_BOF" zi="62.57" zo="280.324" ri="1028.19" ro="1093.06" w="379.6" eta="1" phi="6 7" dphi="22.5" RPCo="15" /> -<ABox n="MDT_BOF" zi="405.46" zo="599.186" ri="1028.19" ro="1106.21" w="379.6" eta="2" phi="6 7" dphi="22.5" RPCo="15" /> -<ABox n="MDT_BOF" zi="727.92" zo="873.59" ri="1028.19" ro="1107.41" w="379.6" eta="3" phi="6 7" dphi="22.5" RPCo="15" /> -<ABox n="MDT_BOF" zi="1002.6" zo="1124.24" ri="1028.19" ro="1106.21" w="379.6" eta="4" phi="6 7" dphi="22.5" RPCo="15" /> -<ABox n="MDT_BOG" zi="-60.821" zo="60.8208" ri="1028.19" ro="1093.06" w="379.6" eta="0" phi="6 7" dphi="22.5" RPCo="15" /> -<ABox n="MDT_BOG" zi="282.07" zo="403.712" ri="1028.19" ro="1093.06" w="379.6" eta="1" phi="6 7" dphi="22.5" RPCo="15" /> -<ABox n="MDT_BOG" zi="602.75" zo="724.392" ri="1028.19" ro="1093.06" w="379.6" eta="2" phi="6 7" dphi="22.5" RPCo="15" /> -<ABox n="MDT_BOG" zi="877.14" zo="998.782" ri="1028.19" ro="1106.21" w="379.6" eta="3" phi="6 7" dphi="22.5" RPCo="15" /> -<ABox n="MDT_BOG" zi="1147.2" zo="1268.84" ri="1028.19" ro="1106.21" w="379.6" eta="4" phi="6 7" dphi="22.5" RPCo="15" /> -<ATrd n="MDT_EIL1" zi="749.146" zo="785.86" ri="207.6" ro="317.228" wi="132.15" wo="186.9" eta="1" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EIL2" zi="749.146" zo="785.86" ri="319.1" ro="428.728" wi="186.15" wo="240.9" eta="2" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EIL3" zi="749.146" zo="785.86" ri="427.23" ro="464.774" wi="207.15" wo="207.15" eta="3" phi="1 2 3 4 5 7" /> -<ATrd n="MDT_EIL3" zi="749.146" zo="785.86" ri="427.535" ro="465.079" wi="174.15" wo="174.15" eta="3" phi="6" sh="-16.5" /> -<ATrd n="MDT_EIL3" zi="749.146" zo="785.86" ri="427.535" ro="465.079" wi="174.15" wo="174.15" eta="3" phi="8" sh="16.5" /> -<ATrd n="MDT_EIL4" zi="745.796" zo="782.51" ri="472" ro="509.544" wi="153.65" wo="153.65" eta="4" phi="1 5" /> -<ATrd n="MDT_EIL4" zi="745.796" zo="782.51" ri="472" ro="635.691" wi="235.15" wo="316.9" eta="4" phi="2 3 7" /> -<ATrd n="MDT_EIL4" zi="745.796" zo="782.51" ri="473.105" ro="636.796" wi="165.15" wo="246.9" eta="4" phi="4" sh="35" /> -<ATrd n="MDT_EIL4" zi="745.796" zo="782.51" ri="511.445" ro="639.094" wi="128.15" wo="191.9" eta="4" phi="6" sh="-62.5" /> -<ATrd n="MDT_EIL4" zi="745.796" zo="782.51" ri="511.445" ro="639.094" wi="128.15" wo="191.9" eta="4" phi="8" sh="62.5" /> -<ATrd n="MDT_EIL5" zi="745.796" zo="782.51" ri="508.04" ro="635.689" wi="253.15" wo="316.9" eta="5" phi="1 5" /> -<ATrd n="MDT_EEL1" zi="1116.5" zo="1148.11" ri="651.3" ro="772.942" wi="336.15" wo="396.9" eta="1" phi="1 2 4 5 6 7 8" /> -<ATrd n="MDT_EEL1" zi="1066.09" zo="1097.7" ri="671.8" ro="817.47" wi="244.65" wo="288.3" eta="1" phi="3" /> -<ATrd n="MDT_EEL2" zi="1116.5" zo="1148.11" ri="774.97" ro="896.612" wi="396.15" wo="456.9" eta="2" phi="1 2 4 5 6 7 8" /> -<ATrd n="MDT_EES1" zi="1011.9" zo="1043.51" ri="589.3" ro="734.97" wi="201.45" wo="245.1" eta="1" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EES2" zi="1011.9" zo="1043.51" ri="737" ro="858.642" wi="244.65" wo="281.1" eta="2" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EML1" zi="1411.25" zo="1447.66" ri="177" ro="346.698" wi="118.65" wo="203.4" eta="1" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EML2" zi="1411.25" zo="1447.66" ri="348.5" ro="542.226" wi="202.65" wo="299.4" eta="2" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EML3" zi="1411.25" zo="1447.66" ri="544" ro="737.726" wi="298.65" wo="395.4" eta="3" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EML4" zi="1411.25" zo="1447.66" ri="739.5" ro="933.226" wi="394.65" wo="491.4" eta="4" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EML5" zi="1411.25" zo="1447.66" ri="935" ro="1128.73" wi="490.65" wo="587.4" eta="5" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EMS1" zi="1369.65" zo="1406.06" ri="177" ro="370.726" wi="83.55" wo="141.6" eta="1" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EMS2" zi="1369.65" zo="1406.06" ri="372.5" ro="566.226" wi="141.15" wo="199.2" eta="2" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EMS3" zi="1369.65" zo="1406.06" ri="568" ro="761.726" wi="198.75" wo="256.8" eta="3" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EMS4" zi="1369.65" zo="1406.06" ri="763.5" ro="957.226" wi="256.35" wo="314.4" eta="4" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EMS5" zi="1369.65" zo="1406.06" ri="959" ro="1152.73" wi="313.95" wo="372" eta="5" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EOL1" zi="2124.25" zo="2160.66" ri="277" ro="446.698" wi="168.15" wo="252.9" eta="1" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EOL2" zi="2124.25" zo="2160.66" ri="448.5" ro="618.198" wi="264.15" wo="348.9" eta="2" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EOL3" zi="2124.25" zo="2160.66" ri="620" ro="765.67" wi="348.15" wo="420.9" eta="3" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EOL4" zi="2124.25" zo="2160.66" ri="767.5" ro="913.17" wi="420.15" wo="492.9" eta="4" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EOL5" zi="2124.25" zo="2160.66" ri="915" ro="1060.67" wi="492.15" wo="564.9" eta="5" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EOL6" zi="2124.25" zo="2160.66" ri="1062.5" ro="1208.17" wi="564.15" wo="636.9" eta="6" phi="1 2 3 4 5 6 7 8" /> -<ATrd n="MDT_EOS1" zi="2165.85" zo="2202.26" ri="277" ro="446.698" wi="124.95" wo="175.8" eta="1" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EOS2" zi="2165.85" zo="2202.26" ri="448.5" ro="618.198" wi="175.35" wo="226.2" eta="2" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EOS3" zi="2165.85" zo="2202.26" ri="620" ro="789.698" wi="225.75" wo="276.6" eta="3" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EOS4" zi="2165.85" zo="2202.26" ri="791.5" ro="937.17" wi="276.15" wo="319.8" eta="4" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EOS5" zi="2165.85" zo="2202.26" ri="939" ro="1084.67" wi="319.35" wo="363" eta="5" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EOS6" zi="2165.85" zo="2202.26" ri="1086.5" ro="1232.17" wi="362.55" wo="406.2" eta="6" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="TGC_T1F1" zi="1327.15" zo="1334.15" ri="190" ro="397.54" wi="57.69" wo="112.34" eta="1" phi="1 3 5 7 9 11 13 15 17 19 21 23" dphi="7.5" /> -<ATrd n="TGC_T1F1" zi="1345.05" zo="1352.05" ri="190" ro="397.54" wi="57.69" wo="112.34" eta="1" phi="2 4 6 8 10 12 14 16 18 20 22 24" dphi="7.5" /> -<ATrd n="TGC_T1E1" zi="1345.05" zo="1359.95" ri="388" ro="1068.2" wi="64.49" wo="154.85" eta="1" phi="1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47" dphi="3.75" /> -<ATrd n="TGC_T1E1" zi="1327.15" zo="1342.05" ri="388" ro="1068.2" wi="64.49" wo="154.85" eta="1" phi="2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48" dphi="3.75" /> -<ATrd n="TGC_T2F1" zi="1460.05" zo="1464.42" ri="252.59" ro="432.15" wi="75.51" wo="122.78" eta="1" phi="1 3 5 7 9 11 13 15 17 19 21 23" dphi="7.5" /> -<ATrd n="TGC_T2F1" zi="1475.55" zo="1479.92" ri="252.59" ro="432.15" wi="75.51" wo="122.78" eta="1" phi="2 4 6 8 10 12 14 16 18 20 22 24" dphi="7.5" /> -<ATrd n="TGC_T2E1" zi="1475.55" zo="1485.42" ri="418.4" ro="1191.7" wi="68.47" wo="170.84" eta="1" phi="1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47" dphi="3.75" /> -<ATrd n="TGC_T2E1" zi="1460.05" zo="1469.92" ri="418.4" ro="1191.7" wi="68.47" wo="170.84" eta="1" phi="2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48" dphi="3.75" /> -<ATrd n="TGC_T3F1" zi="1502.05" zo="1506.42" ri="261" ro="440.56" wi="75.51" wo="122.79" eta="1" phi="1 3 5 7 9 11 13 15 17 19 21 23" dphi="7.5" /> -<ATrd n="TGC_T3F1" zi="1517.55" zo="1521.92" ri="261" ro="440.56" wi="75.51" wo="122.79" eta="1" phi="2 4 6 8 10 12 14 16 18 20 22 24" dphi="7.5" /> -<ATrd n="TGC_T3E1" zi="1517.55" zo="1527.42" ri="436.56" ro="1191.7" wi="70.84" wo="170.84" eta="1" phi="1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47" dphi="3.75" /> -<ATrd n="TGC_T3E1" zi="1502.05" zo="1511.92" ri="436.56" ro="1191.7" wi="70.84" wo="170.84" eta="1" phi="2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48" dphi="3.75" /> -<ATrd n="TGC_T4F1" zi="698.06" zo="702.43" ri="217" ro="443.4" wi="62.38" wo="121.99" eta="1" phi="1 3 4 6 7 9 10 12 13 15 16 18 19 21 22 24" dphi="7.5" /> -<ATrd n="TGC_T4F1" zi="693.04" zo="697.41" ri="217" ro="433.4" wi="62.38" wo="119.36" eta="1" phi="2 5 8 11 14 17 20 23" dphi="7.5" /> -<ATrd n="TGC_T4E1" zi="730.87" zo="735.24" ri="470" ro="619" wi="83.33" wo="108.09" eta="1" phi="1 4 7" /> -<ATrd n="TGC_T4E1" zi="737.53" zo="741.9" ri="520" ro="619" wi="91.64" wo="108.09" eta="1" phi="2" dphi="-5.5" /> -<ATrd n="TGC_T4E1" zi="737.53" zo="741.9" ri="470" ro="619" wi="83.33" wo="108.09" eta="1" phi="3 6" dphi="5.5" /> -<ATrd n="TGC_T4E1" zi="737.53" zo="741.9" ri="470" ro="619" wi="83.33" wo="108.09" eta="1" phi="5 8" dphi="-5.5" /> -<ATrd n="TGC_T4E1" zi="730.87" zo="735.24" ri="470" ro="619" wi="83.33" wo="108.09" eta="1" phi="9 12" dphi="15" /> -<ATrd n="TGC_T4E1" zi="737.53" zo="741.9" ri="470" ro="619" wi="83.33" wo="108.09" eta="1" phi="10" dphi="9.5" /> -<ATrd n="TGC_T4E1" zi="737.53" zo="741.9" ri="520" ro="619" wi="91.64" wo="108.09" eta="1" phi="11 14" dphi="20.5" /> -<ATrd n="TGC_T4E1" zi="737.53" zo="741.9" ri="520" ro="619" wi="91.64" wo="108.09" eta="1" phi="13" dphi="9.5" /> -<ATrd n="TGC_T4E1" zi="730.87" zo="735.24" ri="520" ro="619" wi="91.64" wo="108.09" eta="1" phi="15" dphi="15" /> -<ATrd n="TGC_T4E1" zi="737.53" zo="741.9" ri="470" ro="619" wi="83.33" wo="108.09" eta="1" phi="16" dphi="35.5" /> -<ATrd n="TGC_T4E1" zi="730.87" zo="735.24" ri="470" ro="619" wi="83.33" wo="108.09" eta="1" phi="17" dphi="30" /> -<ATrd n="TGC_T4E1" zi="737.53" zo="741.9" ri="470" ro="619" wi="83.33" wo="108.09" eta="1" phi="18" dphi="24.5" /> -<ATrd n="TGC_T4E1" zi="730.87" zo="735.24" ri="520" ro="619" wi="91.64" wo="108.09" eta="1" phi="19" dphi="45" /> -<ATrd n="TGC_T4E1" zi="737.53" zo="741.9" ri="520" ro="619" wi="91.64" wo="108.09" eta="1" phi="20" dphi="39.5" /> -<ATrd n="TGC_T4E1" zi="737.53" zo="741.9" ri="520" ro="619" wi="91.64" wo="108.09" eta="1" phi="21" dphi="50.5" /> -<ATrd n="MDT_EIS1" zi="707.746" zo="744.46" ri="207.6" ro="335.249" wi="89.85" wo="128.1" eta="1" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="MDT_EIS2" zi="707.746" zo="744.46" ri="337.1" ro="446.728" wi="127.65" wo="160.5" eta="2" phi="1 2 3 4 5 6 7 8" dphi="22.5" /> -<ATrd n="CSC_CSS1" zi="708.102" zo="738.022" ri="86.6016" ro="207.832" wi="40.29" wo="75.7865" eta="1" phi="1 2 3 4 5 6 7 8" dphi="22.5" a="-11.587" /> -<ATrd n="CSC_CSL1" zi="744.539" zo="774.459" ri="92.0422" ro="206.732" wi="61.01" wo="117.027" eta="1" phi="1 2 3 4 5 6 7 8" a="-11.587" /> -<ABox n="MDT_BIM" zi="107" zo="216.628" ri="519.465" ro="561.079" w="153.65" eta="1" phi="6" sh="-56.6" /> -<ABox n="MDT_BIM" zi="107" zo="216.628" ri="519.465" ro="561.079" w="153.65" eta="1" phi="8" sh="56.6" /> -<ABox n="MDT_BIM" zi="217" zo="326.628" ri="519.465" ro="561.079" w="153.65" eta="2" phi="6" sh="-56.6" /> -<ABox n="MDT_BIM" zi="217" zo="326.628" ri="519.465" ro="561.079" w="153.65" eta="2" phi="8" sh="56.6" /> -<ABox n="MDT_BIM" zi="327" zo="436.628" ri="519.465" ro="561.079" w="153.65" eta="3" phi="6" sh="-56.6" /> -<ABox n="MDT_BIM" zi="327" zo="436.628" ri="519.465" ro="561.079" w="153.65" eta="3" phi="8" sh="56.6" /> -<ABox n="MDT_BIM" zi="437" zo="546.628" ri="519.465" ro="561.079" w="153.65" eta="4" phi="6" sh="-56.6" /> -<ABox n="MDT_BIM" zi="437" zo="546.628" ri="519.465" ro="561.079" w="153.65" eta="4" phi="8" sh="56.6" /> -<ABox n="MDT_BIM" zi="547" zo="656.628" ri="519.465" ro="561.079" w="153.65" eta="5" phi="6" sh="-56.6" /> -<ABox n="MDT_BIM" zi="547" zo="656.628" ri="519.465" ro="561.079" w="153.65" eta="5" phi="8" sh="56.6" /> -</AMuonGeometry> diff --git a/graphics/AtlantisJava/geometry/ATLAS_IDS.xml b/graphics/AtlantisJava/geometry/ATLAS_IDS.xml deleted file mode 100755 index 81f4d7c3a445165a6d37202e8752316a53a36d98..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/geometry/ATLAS_IDS.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE IdDict SYSTEM "IdDict.dtd" [ - <!ENTITY InnerDetector SYSTEM "IdDictInnerDetector.xml"> - <!ENTITY LArCalorimeter SYSTEM "IdDictLArCalorimeter.xml"> - <!ENTITY TileCalorimeter SYSTEM "IdDictTileCalorimeter.xml"> - <!ENTITY Calorimeter SYSTEM "IdDictCalorimeter.xml"> - <!ENTITY MuonSpectrometer SYSTEM "IdDictMuonSpectrometer.xml"> - <!ENTITY ATLAS SYSTEM "IdDictATLAS.xml"> - <!ENTITY LArHighVoltage SYSTEM "IdDictLArHighVoltage.xml"> - <!ENTITY LArElectrode SYSTEM "IdDictLArElectrode.xml"> - <!ENTITY ForwardDetectors SYSTEM "IdDictForwardDetectors.xml"> -]> - -<IdDict IdDictVersion="v1"> - -&InnerDetector; -&LArCalorimeter; -&TileCalorimeter; -&Calorimeter; -&MuonSpectrometer; -&ATLAS; -&LArHighVoltage; -&LArElectrode; -&ForwardDetectors; - -</IdDict> - diff --git a/graphics/AtlantisJava/geometry/IdDict.dtd b/graphics/AtlantisJava/geometry/IdDict.dtd deleted file mode 100755 index 5077ec98a6362888c719f4eb4d034ebdad43b40d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/geometry/IdDict.dtd +++ /dev/null @@ -1,118 +0,0 @@ -<?xml encoding="US-ASCII"?> - -<!-- IdDict: Identifier Dictionary - ========================== - - o This describes the possible identifier ranges. - - o One may describe several identifier dictionaries, each by a IdDictionary element. - A dictionary is identified by its name. - - o Each dictionary may describe : - - + individual identifier fields ("field"). - - - This is useful when the field values are individually labelled. - - purely numeric fields do not need to be explicitly - described, in which case, their possible ranges will be deduced from the defined - regions. - - + identifier regions ("region"). - - - they are the alternate identifier ranges for this dictionary. - - a region specifies a contiguous range of identifiers, complete for the dictionary. - - it may be labelled with a "name". - - it may also have a "tag" (see alternate regions) - - it contains the ordered list of fields with their explicit value range. - - each entry in this list may be - - a range assigned to a given field ("range") - - a reference to a subregion ("reference") (see below) - - a reference to a complete identifier domain ("identifiers") - - a list of alternative ranges which are differentiated according - to their tag ("alternate_ranges") - - + alternate regions ("alternate_regions"). - - - this contains two or more alternate region specifications - which are differentiated by their "tag". An empty tag is - default. This allows at generation time to select a specific - tag. - - + subregions ("subregion") - - - A subregion speficies a contiguous range of identifiers, describing a - subset of the identifier fields in the dictionary. - - it must identified by a name. - - the role of subregions is to be referenced by regions, and they typically describe - the parts that are common to several regions. - ---> - - - -<!ENTITY % DTD_constraint 'IdDictVersion ( v1 ) #REQUIRED'> - -<!ELEMENT IdDict ( IdDictionary )* > -<!ATTLIST IdDict - %DTD_constraint;> - -<!ELEMENT IdDictionary ( field | subregion | region | alternate_regions )* > -<!ATTLIST IdDictionary - name ID #REQUIRED - version CDATA #IMPLIED - date CDATA #IMPLIED - author CDATA #IMPLIED> - - -<!ELEMENT field ( label )* > -<!ATTLIST field - name CDATA #REQUIRED > - -<!ELEMENT label EMPTY> -<!ATTLIST label - name CDATA #REQUIRED - value CDATA #IMPLIED> - -<!ELEMENT alternate_regions ( region )* > -<!ATTLIST alternate_regions - name CDATA #IMPLIED> - -<!ELEMENT region ( range | reference | dictionary )* > -<!ATTLIST region - name CDATA #IMPLIED - group CDATA #IMPLIED - tag CDATA #IMPLIED - next_abs_eta CDATA #IMPLIED - prev_samp CDATA #IMPLIED - next_samp CDATA #IMPLIED - prev_subdet CDATA #IMPLIED - next_subdet CDATA #IMPLIED - eta0 CDATA #IMPLIED - deta CDATA #IMPLIED - phi0 CDATA #IMPLIED - dphi CDATA #IMPLIED> - -<!ELEMENT range EMPTY> -<!ATTLIST range - field CDATA #REQUIRED - value CDATA #IMPLIED - minvalue CDATA #IMPLIED - maxvalue CDATA #IMPLIED - values CDATA #IMPLIED - prev_value CDATA #IMPLIED - next_value CDATA #IMPLIED - wraparound (TRUE | false) "false"> - -<!ELEMENT reference EMPTY> -<!ATTLIST reference - subregion IDREF #REQUIRED> - -<!ELEMENT dictionary EMPTY> -<!ATTLIST dictionary - name IDREF #REQUIRED> - -<!ELEMENT subregion ( range | reference | dictionary )* > -<!ATTLIST subregion - name ID #REQUIRED> - - diff --git a/graphics/AtlantisJava/geometry/IdDictATLAS.xml b/graphics/AtlantisJava/geometry/IdDictATLAS.xml deleted file mode 100755 index 95314ee2c0db033f750c4050786018c930893017..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/geometry/IdDictATLAS.xml +++ /dev/null @@ -1,56 +0,0 @@ - -<IdDictionary name="ATLAS"> - - <field name="subdet"> - <label name="InnerDetector" value="2" /> - <label name="LArCalorimeter" value="4" /> - <label name="TileCalorimeter" value="5" /> - <label name="MuonSpectrometer" value="7" /> - <label name="Calorimeter" value="10" /> - <label name="LArHighVoltage" value="11" /> - <label name="LArElectrode" value="12" /> - <label name="ForwardDetectors" value="13" /> - </field> - - <region> - <range field="subdet" value="InnerDetector" /> - <dictionary name="InnerDetector" /> - </region> - - <region> - <range field="subdet" value="LArCalorimeter" /> - <dictionary name="LArCalorimeter" /> - </region> - - <region> - <range field="subdet" value="TileCalorimeter" /> - <dictionary name="TileCalorimeter" /> - </region> - - <region> - <range field="subdet" value="MuonSpectrometer" /> - <dictionary name="MuonSpectrometer" /> - </region> - - <region> - <range field="subdet" value="Calorimeter" /> - <dictionary name="Calorimeter" /> - </region> - - <region> - <range field="subdet" value="LArHighVoltage" /> - <dictionary name="LArHighVoltage" /> - </region> - - <region> - <range field="subdet" value="LArElectrode" /> - <dictionary name="LArElectrode" /> - </region> - - <region> - <range field="subdet" value="ForwardDetectors" /> - <dictionary name="ForwardDetectors" /> - </region> - -</IdDictionary> - diff --git a/graphics/AtlantisJava/geometry/IdDictCalorimeter.xml b/graphics/AtlantisJava/geometry/IdDictCalorimeter.xml deleted file mode 100755 index f94f801d91ea8eb220722a139cc9d7e0d4c8f782..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/geometry/IdDictCalorimeter.xml +++ /dev/null @@ -1,731 +0,0 @@ - -<IdDictionary name="Calorimeter" > - - -<field name="DetZside" > - <label name="negative_DMTile_side" value="-5" /> - <label name="negative_DMLar_side" value="-4" /> - <label name="negative_eta_side" value="-2" /> - <label name="negative_lvl1_side" value="-1" /> - <label name="positive_lvl1_side" value="+1" /> - <label name="positive_eta_side" value="+2" /> - <label name="positive_DMLar_side" value="+4" /> - <label name="positive_DMTile_side" value="+5" /> -</field> - - -<!-- Dead Material Types --> -<!-- xxxxxxxxxxxxxxxxxxxx --> - -<!-- 3 types of LAr Dead Material --> - - <subregion name="DMLArOutside" > - <range field="DetZside" values="negative_DMLar_side positive_DMLar_side" /> - <range field="DMvalue" value="1" /> - </subregion> - - <subregion name="DMLarInside" > - <range field="DetZside" values="negative_DMLar_side positive_DMLar_side" /> - <range field="DMvalue" value="2" /> - </subregion> - - <subregion name="DMLArBeamTest"> - <range field="DetZside" values="negative_DMLar_side positive_DMLar_side" /> - <range field="DMvalue" value="3" /> - </subregion> - -<!-- 2 types of Tile Dead Material --> - - <subregion name="DMTileOutside" > - <range field="DetZside" values="negative_DMTile_side positive_DMTile_side" /> - <range field="DMvalue" value="1" /> - </subregion> - - <subregion name="DMTileDefHits" > - <range field="DetZside" values="negative_DMTile_side positive_DMTile_side" /> - <range field="DMvalue" value="2" /> - </subregion> - - <subregion name="DMTileBeamTest" > - <range field="DetZside" values="negative_DMTile_side positive_DMTile_side" /> - <range field="DMvalue" value="3" /> - </subregion> - - - -<!-- Dead Material Phi regions --> -<!-- xxxxxxxxxxxxxxxxxxxxxxxxxx --> - -<!-- 3 types of Phi region --> - - <subregion name="DMPhi-1" > - <range field="phivalue" minvalue="0" maxvalue="63" wraparound="TRUE" /> - </subregion> - - <subregion name="DMPhi-2" > - <range field="phivalue" minvalue="0" maxvalue="31" wraparound="TRUE" /> - </subregion> - - <subregion name="DMPhi-3" > - <range field="phivalue" value="0" wraparound="TRUE" /> - </subregion> - - - -<!-- LAr DM Samplings --> -<!-- xxxxxxxxxxxxxxxxx --> - - -<!-- 4 sampling region: 0 to 3 --> - - <subregion name="DMLArSampling-0" > - <range field="samplingvalue" value="0" /> - </subregion> - - <subregion name="DMLArSampling-1" > - <range field="samplingvalue" value="1" /> - </subregion> - - <subregion name="DMLArSampling-2" > - <range field="samplingvalue" value="2" /> - </subregion> - - <subregion name="DMLArSampling-3" > - <range field="samplingvalue" value="3" /> - </subregion> - - -<!-- Tile DM Samplings --> -<!-- xxxxxxxxxxxxxxxxx --> - - -<!-- 4 sampling region: 0 to 3 --> - - - <subregion name="DMTileSampling-0" > - <range field="samplingvalue" value="0" /> - </subregion> - - <subregion name="DMTileSampling-1" > - <range field="samplingvalue" value="1" /> - </subregion> - - <subregion name="DMTileSampling-2" > - <range field="samplingvalue" value="2" /> - </subregion> - - <subregion name="DMTileSampling-3" > - <range field="samplingvalue" value="3" /> - </subregion> - - - -<!-- LAr DM regions --> -<!-- xxxxxxxxxxxxxx --> - -<!-- type 1, sampling 0, regions 0 to 5 --> - - <region group="DM_Reg" name="DM_4_1_0_0" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-0" /> - <range field="DMregion" minvalue="0" maxvalue="5" /> - <range field="DMEta" minvalue="0" maxvalue="49" /> - <reference subregion="DMPhi-1" /> - </region> - -<!-- type 1, sampling 1, region 0 to 7--> - - <region group="DM_Reg" name="DM_4_1_1_0" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="0" /> - <range field="DMEta" minvalue="0" maxvalue="14" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_1_1" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="1" /> - <range field="DMEta" minvalue="0" maxvalue="14" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_1_2" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="2" /> - <range field="DMEta" minvalue="0" maxvalue="15" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_1_3" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="3" /> - <range field="DMEta" minvalue="0" maxvalue="15" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_1_4" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="4" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_1_5" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="5" /> - <range field="DMEta" minvalue="0" maxvalue="2" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_1_6" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="6" /> - <range field="DMEta" minvalue="0" maxvalue="18" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_1_7" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="7" /> - <range field="DMEta" minvalue="0" maxvalue="17" /> - <reference subregion="DMPhi-1" /> - </region> - -<!-- type 1, sampling 2, region 0 to 5--> - - <region group="DM_Reg" name="DM_4_1_2_0" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-2" /> - <range field="DMregion" value="0" /> - <range field="DMEta" minvalue="0" maxvalue="9" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_2_1" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-2" /> - <range field="DMregion" value="1" /> - <range field="DMEta" minvalue="0" maxvalue="9" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_2_2" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-2" /> - <range field="DMregion" value="2" /> - <range field="DMEta" minvalue="0" maxvalue="4" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_2_3" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-2" /> - <range field="DMregion" value="3" /> - <range field="DMEta" minvalue="0" maxvalue="17" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_2_4" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-2" /> - <range field="DMregion" value="4" /> - <range field="DMEta" minvalue="0" maxvalue="17" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_2_5" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-2" /> - <range field="DMregion" value="5" /> - <range field="DMEta" minvalue="0" maxvalue="6" /> - <reference subregion="DMPhi-1" /> - </region> - - -<!-- type 1, sampling 3, region 0 to 2--> - - <region group="DM_Reg" name="DM_4_1_3_0" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-3" /> - <range field="DMregion" value="0" /> - <range field="DMEta" minvalue="0" maxvalue="32" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_3_1" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-3" /> - <range field="DMregion" value="1" /> - <range field="DMEta" minvalue="0" maxvalue="14" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_1_3_2" > - <reference subregion="DMLArOutside" /> - <reference subregion="DMLArSampling-3" /> - <range field="DMregion" value="2" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-3" /> - </region> - - -<!-- type 2, sampling [0,3], region 0 to 5--> - - <region group="DM_Reg" name="DM_4_2_0_0" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-0" /> - <range field="DMregion" value="0" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_2_0_1" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-0" /> - <range field="DMregion" value="1" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - - <region group="DM_Reg" name="DM_4_2_0_2" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-0" /> - <range field="DMregion" value="2" /> - <range field="DMEta" minvalue="0" maxvalue="9" /> - <reference subregion="DMPhi-2" /> - </region> - - <region group="DM_Reg" name="DM_4_2_0_3" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-0" /> - <range field="DMregion" value="3" /> - <range field="DMEta" minvalue="0" maxvalue="3" /> - <reference subregion="DMPhi-2" /> - </region> - - <region group="DM_Reg" name="DM_4_2_0_4" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-0" /> - <range field="DMregion" value="4" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_2_0_5" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-0" /> - <range field="DMregion" value="5" /> - <range field="DMEta" minvalue="0" maxvalue="19" /> - <reference subregion="DMPhi-1" /> - </region> - - - <region group="DM_Reg" name="DM_4_2_1_0" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="0" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_2_1_1" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="1" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_2_1_2" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="2" /> - <range field="DMEta" minvalue="0" maxvalue="9" /> - <reference subregion="DMPhi-2" /> - </region> - - <region group="DM_Reg" name="DM_4_2_1_3" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="3" /> - <range field="DMEta" minvalue="0" maxvalue="3" /> - <reference subregion="DMPhi-2" /> - </region> - - <region group="DM_Reg" name="DM_4_2_1_4" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="4" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_2_1_5" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-1" /> - <range field="DMregion" value="5" /> - <range field="DMEta" minvalue="0" maxvalue="19" /> - <reference subregion="DMPhi-1" /> - </region> - - - <region group="DM_Reg" name="DM_4_2_2_0" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-2" /> - <range field="DMregion" value="0" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_2_2_1" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-2" /> - <range field="DMregion" value="1" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_2_2_2" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-2" /> - <range field="DMregion" value="2" /> - <range field="DMEta" minvalue="0" maxvalue="9" /> - <reference subregion="DMPhi-2" /> - </region> - - <region group="DM_Reg" name="DM_4_2_2_3" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-2" /> - <range field="DMregion" value="3" /> - <range field="DMEta" minvalue="0" maxvalue="3" /> - <reference subregion="DMPhi-2" /> - </region> - - <region group="DM_Reg" name="DM_4_2_2_4" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-2" /> - <range field="DMregion" value="4" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_2_2_5" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-2" /> - <range field="DMregion" value="5" /> - <range field="DMEta" minvalue="0" maxvalue="19" /> - <reference subregion="DMPhi-1" /> - </region> - - - <region group="DM_Reg" name="DM_4_2_3_0" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-3" /> - <range field="DMregion" value="0" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_2_3_1" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-3" /> - <range field="DMregion" value="1" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_2_3_2" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-3" /> - <range field="DMregion" value="2" /> - <range field="DMEta" minvalue="0" maxvalue="9" /> - <reference subregion="DMPhi-2" /> - </region> - - <region group="DM_Reg" name="DM_4_2_3_3" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-3" /> - <range field="DMregion" value="3" /> - <range field="DMEta" minvalue="0" maxvalue="3" /> - <reference subregion="DMPhi-2" /> - </region> - - <region group="DM_Reg" name="DM_4_2_3_4" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-3" /> - <range field="DMregion" value="4" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_4_2_3_5" > - <reference subregion="DMLarInside" /> - <reference subregion="DMLArSampling-3" /> - <range field="DMregion" value="5" /> - <range field="DMEta" minvalue="0" maxvalue="19" /> - <reference subregion="DMPhi-1" /> - </region> - - -<!-- TILE DM regions --> -<!-- xxxxxxxxxxxxxxx --> - -<!-- type 1, sampling 0, region 0 to 1 --> - - <region group="DM_Reg" name="DM_5_1_0_0" > - <reference subregion="DMTileOutside" /> - <reference subregion="DMTileSampling-0" /> - <range field="DMregion" value="0" /> - <range field="DMEta" minvalue="0" maxvalue="9" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_5_1_0_1" > - <reference subregion="DMTileOutside" /> - <reference subregion="DMTileSampling-0" /> - <range field="DMregion" value="1" /> - <range field="DMEta" minvalue="0" maxvalue="4" /> - <reference subregion="DMPhi-1" /> - </region> - -<!-- type 1, sampling 1, region 0 to 2 --> - - <region group="DM_Reg" name="DM_5_1_1_0" > - <reference subregion="DMTileOutside" /> - <reference subregion="DMTileSampling-1" /> - <range field="DMregion" value="0" /> - <range field="DMEta" minvalue="0" maxvalue="3" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_5_1_1_1" > - <reference subregion="DMTileOutside" /> - <reference subregion="DMTileSampling-1" /> - <range field="DMregion" value="1" /> - <range field="DMEta" minvalue="0" maxvalue="2" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_5_1_1_2" > - <reference subregion="DMTileOutside" /> - <reference subregion="DMTileSampling-1" /> - <range field="DMregion" value="2" /> - <range field="DMEta" minvalue="0" maxvalue="3" /> - <reference subregion="DMPhi-1" /> - </region> - - -<!-- type 1, sampling 2, region 0 to 2 --> - - <region group="DM_Reg" name="DM_5_1_2_0" > - <reference subregion="DMTileOutside" /> - <reference subregion="DMTileSampling-2" /> - <range field="DMregion" value="0" /> - <range field="DMEta" minvalue="0" maxvalue="7" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_5_1_2_1" > - <reference subregion="DMTileOutside" /> - <reference subregion="DMTileSampling-2" /> - <range field="DMregion" value="1" /> - <range field="DMEta" minvalue="0" maxvalue="4" /> - <reference subregion="DMPhi-1" /> - </region> - - <region group="DM_Reg" name="DM_5_1_2_2" > - <reference subregion="DMTileOutside" /> - <reference subregion="DMTileSampling-2" /> - <range field="DMregion" value="2" /> - <range field="DMEta" minvalue="0" maxvalue="1" /> - <reference subregion="DMPhi-1" /> - </region> - -<!-- type 1, sampling 3, region 0 --> - - <region group="DM_Reg" name="DM_5_1_3_0" > - <reference subregion="DMTileOutside" /> - <reference subregion="DMTileSampling-3" /> - <range field="DMregion" value="0" /> - <range field="DMEta" minvalue="0" maxvalue="16" /> - <reference subregion="DMPhi-1" /> - </region> - -<!-- type 2, sampling 0, region 0 --> - - <region group="DM_Reg" name="DM_5_2_0_0" > - <reference subregion="DMTileDefHits" /> - <reference subregion="DMTileSampling-0" /> - <range field="DMregion" value="0" /> - <range field="DMEta" value="0" /> - <reference subregion="DMPhi-3" /> - </region> - - -<!-- LVL1 part --> -<!-- xxxxxxxxxxxxxxxxx --> - - <field name="LVL1sampling" > - <label name="EM" value="0" /> - <label name="Hadronic" value="1" /> - </field> - - <subregion name="LVL1" > - <range field="DetZside" values="negative_lvl1_side positive_lvl1_side" /> - <range field="LVL1sampling" values="EM Hadronic" /> - </subregion> - - - <region group="Reg_Lvl1" name="Lvl1_0" > - <reference subregion="LVL1" /> - <range field="region" value="0" /> - <range field="eta" minvalue="0" maxvalue="24" /> - <range field="phi" minvalue="0" maxvalue="63" wraparound="TRUE" /> - <range field="layer" minvalue="0" maxvalue="3" /> - </region> - - <region group="Reg_Lvl1" name="Lvl1_1" > - <reference subregion="LVL1" /> - <range field="region" value="1" /> - <range field="eta" minvalue="0" maxvalue="2" /> - <range field="phi" minvalue="0" maxvalue="31" wraparound="TRUE" /> - <range field="layer" minvalue="0" maxvalue="3" /> - </region> - - <region group="Reg_Lvl1" name="Lvl1_2" > - <reference subregion="LVL1" /> - <range field="region" value="2" /> - <range field="eta" value="0" /> - <range field="phi" minvalue="0" maxvalue="31" wraparound="TRUE" /> - <range field="layer" minvalue="0" maxvalue="3" /> - </region> - - - <region group="Reg_Lvl1" name="Lvl1_3" > - <reference subregion="LVL1" /> - <range field="region" value="3" /> - <range field="eta" minvalue="0" maxvalue="3"/> - <range field="phi" minvalue="0" maxvalue="15" wraparound="TRUE" /> - <range field="layer" minvalue="0" maxvalue="1" /> - </region> - - - -<!-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --> -<!-- Online L1 Trigger Tower regions --> -<!-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --> - - -<!-- Fields used to describe a TTower --> - - <field name="barrel_endcap_fcal" > - <label name="barrel" value="0" /> - <label name="endcap" value="1" /> - <label name="fcal" value="2" /> - </field> - - <field name="em_had" > - <label name="em" value="0" /> - <label name="had" value="1" /> - </field> - - -<!-- Subregion definition --> - - <subregion name="OnlineL1-barrel" > - <range field="DetZside" values="negative_eta_side positive_eta_side" /> - <range field="barrel_endcap_fcal" value="barrel" /> - </subregion> - - <subregion name="OnlineL1-endcap" > - <range field="DetZside" values="negative_eta_side positive_eta_side" /> - <range field="barrel_endcap_fcal" value="endcap" /> - </subregion> - - <subregion name="OnlineL1-fcal" > - <range field="DetZside" values="negative_eta_side positive_eta_side" /> - <range field="barrel_endcap_fcal" value="fcal" /> - </subregion> - - -<!-- Online L1 EM-Barrel --> -<!-- xxxxxxxxxxxxxxxxxxxx --> - -<region group="Online_L1" name="l1_barrel" > - <reference subregion="OnlineL1-barrel" /> - <range field="em_had" value="em" /> - <range field="tower_eta" minvalue="1" maxvalue="15" /> - <range field="tower_phi" minvalue="1" maxvalue="64" /> - <range field="tower_layer" minvalue="0" maxvalue="3" /> - </region> - - -<!-- Online L1 EM Endcap --> -<!-- xxxxxxxxxxxxxxxxxxxx --> - -<region group="Online_L1" name="l1_emec_region1" > - <reference subregion="OnlineL1-endcap" /> - <range field="em_had" value="em" /> - <range field="tower_eta" minvalue="1" maxvalue="11" /> - <range field="tower_phi" minvalue="1" maxvalue="64" /> - <range field="tower_layer" minvalue="0" maxvalue="3" /> -</region> - -<region group="Online_L1" name="l1_emec_region2" > - <reference subregion="OnlineL1-endcap" /> - <range field="em_had" value="em" /> - <range field="tower_eta" minvalue="12" maxvalue="15" /> - <range field="tower_phi" minvalue="1" maxvalue="32" /> - <range field="tower_layer" minvalue="0" maxvalue="3" /> -</region> - -<!-- Online L1 HEC Endcap --> -<!-- xxxxxxxxxxxxxxxxxxxxx --> - -<region group="Online_L1" name="l1_hec_region1" > - <reference subregion="OnlineL1-endcap" /> - <range field="em_had" value="had" /> - <range field="tower_eta" minvalue="2" maxvalue="11" /> - <range field="tower_phi" minvalue="1" maxvalue="64" /> - <range field="tower_layer" minvalue="0" maxvalue="3" /> -</region> - -<region group="Online_L1" name="l1_hec_region2" > - <reference subregion="OnlineL1-endcap" /> - <range field="em_had" value="had" /> - <range field="tower_eta" minvalue="12" maxvalue="15" /> - <range field="tower_phi" minvalue="1" maxvalue="32" /> - <range field="tower_layer" minvalue="0" maxvalue="3" /> -</region> - - -<!-- Online L1 FCAL --> -<!-- xxxxxxxxxxxxxxx --> - -<region group="Online_L1" name="l1_fcal_em" > - <reference subregion="OnlineL1-fcal" /> - <range field="em_had" value="em" /> - <range field="tower_eta" minvalue="1" maxvalue="4" /> - <range field="tower_phi" minvalue="1" maxvalue="16" /> - <range field="tower_layer" value="0" /> -</region> - -<region group="Online_L1" name="l1_fcal_had" > - <reference subregion="OnlineL1-fcal" /> - <range field="em_had" value="had" /> - <range field="tower_eta" minvalue="1" maxvalue="4" /> - <range field="tower_phi" minvalue="1" maxvalue="16" /> - <range field="tower_layer" minvalue="0" maxvalue="1" /> -</region> - - -</IdDictionary> diff --git a/graphics/AtlantisJava/geometry/IdDictForwardDetectors.xml b/graphics/AtlantisJava/geometry/IdDictForwardDetectors.xml deleted file mode 100644 index 588eb81db1c635085b9c09a21f5076eb78e6d937..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/geometry/IdDictForwardDetectors.xml +++ /dev/null @@ -1,140 +0,0 @@ - - -<!-- - - The ForwardDetectors identifier is arranged as follows - - ForwardDetectors - part=BCM - <to be defined> - - part=BCM_Online - <to be defined> - - part=LUCID - <to be defined> - - part=LUCID_Online - <to be defined> - - part=ZDC - side module type channel - - part=ZDC_Online - side module type channel gain delay - - --> - -<IdDictionary name="ForwardDetectors" > - - <!-- - Start by defining some symbolic labels used for some fields - (other fields will be specified by numeric ranges) - --> - - <field name="part" > - <label name="ALFA" value="1" /> - <label name="ALFA_Online" value="2" /> - <label name="BCM" value="3" /> - <label name="BCM_Online" value="4" /> - <label name="LUCID" value="5" /> - <label name="LUCID_Online" value="6" /> - <label name="ZDC" value="7" /> - <label name="ZDC_Online" value="8" /> - <label name="Extra" value="9" /> - <label name="Extra_Online" value="10" /> - </field> - - <field name="side"> - <label name="negative" value="-1" /> - <label name="positive" value="+1" /> - </field> - - - <!-- - - ALFA - to do - - --> - - <region group="ALFA" name = "alfa"> - <range field="part" value="ALFA" /> - </region> - - <region group="ALFA_Online" name = "alfa"> - <range field="part" value="ALFA_Online" /> - </region> - - <!-- - - BCM - to do - - --> - - <region group="BCM" name = "bcm"> - <range field="part" value="BCM" /> - </region> - - <region group="BCM_Online" name = "bcm"> - <range field="part" value="BCM_Online" /> - </region> - - <!-- - - LUCID - to do - - --> - - <region group="LUCID" name = "lucid"> - <range field="part" value="LUCID" /> - </region> - - <region group="LUCID_Online" name = "lucid"> - <range field="part" value="LUCID_Online" /> - </region> - - <!-- - - ZDC - - --> - - <!-- ZDC - offline --> - - <region group="ZDC" name = "zdc"> - <range field="part" value="ZDC" /> - <range field="side" values="negative positive"/> - <range field="module" minvalue="0" maxvalue="3"/> - <range field="type" minvalue="0" maxvalue="1" /> - <range field="channel" minvalue="0" maxvalue="63" /> - </region> - - <!-- ZDC - online --> - - <region group="ZDC_Online" name = "zdc_online"> - <range field="part" value="ZDC_Online" /> - <range field="side" values="negative positive"/> - <range field="module" minvalue="0" maxvalue="3"/> - <range field="type" minvalue="0" maxvalue="1" /> - <range field="channel" minvalue="0" maxvalue="63" /> - <range field="gain" minvalue="0" maxvalue="1" /> - <range field="delay" minvalue="0" maxvalue="1" /> - </region> - - <!-- - - EXTRA - to do - - --> - - <region group="EXTRA" name = "extra"> - <range field="part" value="Extra" /> - </region> - - <region group="EXTRA_Online" name = "extra"> - <range field="part" value="Extra_Online" /> - </region> - - -</IdDictionary> - diff --git a/graphics/AtlantisJava/geometry/IdDictInnerDetector.xml b/graphics/AtlantisJava/geometry/IdDictInnerDetector.xml deleted file mode 100755 index 98c405c193ab543bb28f7f837b27879d3a79420c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/geometry/IdDictInnerDetector.xml +++ /dev/null @@ -1,559 +0,0 @@ - - -<!-- - - The InnerDetector identifier is arranged as follows - - InnerDetector - part=Pixel - side=barrel - layer phi_module eta_module phi_index eta_index - side=endcap - disk phi_module eta_module phi_index eta_index - - part=SCT - side=barrel - layer phi_module eta_module side strip - side=endcap - disk phi_module eta_module side strip - - part=TRT - side=barrel - layer phi_module straw_layer straw - side=endcap - wheel phi_module straw_layer straw - - - --> - -<IdDictionary name="InnerDetector" > - - <!-- - Start by defining some symbolic labels used for some fields - (other fields will be specified by numeric ranges) - --> - - <field name="part" > - <label name="Pixel" value="1" /> - <label name="SCT" value="2" /> - <label name="TRT" value="3" /> - </field> - - <field name="barrel_endcap"> - <label name="negative_endcap" value="-2" /> - <label name="negative_barrel" value="-1" /> - <label name="barrel" value="0" /> - <label name="positive_barrel" value="+1" /> - <label name="positive_endcap" value="+2" /> - </field> - - - - <!-- - - Pixel - - --> - - <!-- Dummy region: This forces the bit packing to be the same for all layouts --> - - <region group="pixel" name = "dummy"> - <range field="part" value="Pixel" /> - <range field="barrel_endcap" values="negative_endcap barrel positive_endcap"/> - <range field="layer" minvalue="0" maxvalue="2"/> - <range field="phi_module" minvalue="0" maxvalue="51" /> - <range field="eta_module" minvalue="-6" maxvalue="+6" /> - <range field="phi_index" minvalue="0" maxvalue="327" /> - <range field="eta_index" minvalue="0" maxvalue="191" /> - </region> - - - <!-- - Define few subregions which are re-used in several id-ranges. - --> - - <subregion name="pixel_barrel"> - <range field="part" value="Pixel" /> - <range field="barrel_endcap" value="barrel" /> - </subregion> - - <subregion name="pixel_endcap"> - <range field="part" value="Pixel" /> - <range field="barrel_endcap" values="negative_endcap positive_endcap" /> - </subregion> - - <subregion name="pixel_default_eta_module"> - <range field="phi_index" minvalue="0" maxvalue="327" /> - <range field="eta_index" minvalue="0" maxvalue="143" /> - </subregion> - - <subregion name="pixel_phi_barrel_module"> - <range field="eta_module" minvalue="-6" maxvalue="+6" /> - <reference subregion="pixel_default_eta_module" /> - </subregion> - - <subregion name="pixel_phi_endcap_module"> - <range field="eta_module" value="0" /> - <reference subregion="pixel_default_eta_module" /> - </subregion> - - <!-- - Then enumerate all the possible regions of the Pixel subdetector. - Each region corresponds to an identifier range. - --> - - <!-- - The follow region is the pixel b-layer. Normally, the correct - phi_index max should be 319, but we set it to 327 as for the other - layers to allow to calculate the pixel_id from SiDigit, i.e. using - the G3 numbering which is not completely correct. This should be a - temporary fix. Correct specif: - <range field="phi_index" minvalue="0" maxvalue="319" /> - --> - <alternate_regions> - <region group="pixel" > - <reference subregion="pixel_barrel" /> - <range field="layer" value="0" /> - <range field="phi_module" minvalue="0" maxvalue="21" wraparound="TRUE" /> - <range field="eta_module" minvalue="-6" maxvalue="+6" /> - <range field="phi_index" minvalue="0" maxvalue="327" /> - <range field="eta_index" minvalue="0" maxvalue="191" /> - </region> - <region group="pixel" tag="initial_layout" > - <reference subregion="pixel_barrel" /> - <range field="layer" value="0" /> - <range field="phi_module" minvalue="0" maxvalue="21" wraparound="TRUE" /> - <reference subregion="pixel_phi_barrel_module" /> - </region> - <region group="pixel" tag="final_layout" > - <reference subregion="pixel_barrel" /> - <range field="layer" value="0" /> - <range field="phi_module" minvalue="0" maxvalue="21" wraparound="TRUE" /> - <reference subregion="pixel_phi_barrel_module" /> - </region> - <region group="pixel" tag="destaged_layout" > - <reference subregion="pixel_barrel" /> - <range field="layer" value="0" /> - <range field="phi_module" minvalue="0" maxvalue="21" wraparound="TRUE" /> - <reference subregion="pixel_phi_barrel_module" /> - </region> - </alternate_regions> - - <alternate_regions> - <region group="pixel" > - <reference subregion="pixel_barrel" /> - <range field="layer" value="1" /> - <range field="phi_module" minvalue="0" maxvalue="37" wraparound="TRUE" /> - <reference subregion="pixel_phi_barrel_module" /> - </region> - <region group="pixel" tag="initial_layout" /> - <region group="pixel" tag="final_layout" > - <reference subregion="pixel_barrel" /> - <range field="layer" value="1" /> - <range field="phi_module" minvalue="0" maxvalue="37" wraparound="TRUE" /> - <reference subregion="pixel_phi_barrel_module" /> - </region> - <region group="pixel" tag="destaged_layout" > - <reference subregion="pixel_barrel" /> - <range field="layer" value="1" /> - <range field="phi_module" minvalue="0" maxvalue="37" wraparound="TRUE" /> - <reference subregion="pixel_phi_barrel_module" /> - </region> - </alternate_regions> - - <region group="pixel" > - <reference subregion="pixel_barrel" /> - <range field="layer" value="2" /> - <range field="phi_module" minvalue="0" maxvalue="51" wraparound="TRUE" /> - <reference subregion="pixel_phi_barrel_module" /> - </region> - - <alternate_regions> - <region group="pixel" > - <reference subregion="pixel_endcap" /> - <range field="disk" minvalue="0" maxvalue="2" /> - <range field="phi_module" minvalue="0" maxvalue="47" wraparound="TRUE" /> - <reference subregion="pixel_phi_endcap_module" /> - </region> - <region group="pixel" tag="initial_layout" > - <reference subregion="pixel_endcap" /> - <range field="disk" values="0 2" /> - <range field="phi_module" minvalue="0" maxvalue="47" wraparound="TRUE" /> - <reference subregion="pixel_phi_endcap_module" /> - </region> - <region group="pixel" tag="final_layout" > - <reference subregion="pixel_endcap" /> - <range field="disk" minvalue="0" maxvalue="2" /> - <range field="phi_module" minvalue="0" maxvalue="47" wraparound="TRUE" /> - <reference subregion="pixel_phi_endcap_module" /> - </region> - <region group="pixel" tag="destaged_layout" > - <reference subregion="pixel_endcap" /> - <range field="disk" minvalue="0" maxvalue="2" /> - <range field="phi_module" minvalue="0" maxvalue="47" wraparound="TRUE" /> - <reference subregion="pixel_phi_endcap_module" /> - </region> - </alternate_regions> - - - - <!-- - - SCT - - --> - - - <subregion name="SCT_barrel"> - <range field="part" value="SCT" /> - <range field="barrel_endcap" value="barrel" /> - </subregion> - - <subregion name="SCT_endcap"> - <range field="part" value="SCT" /> - <range field="barrel_endcap" values="negative_endcap positive_endcap" /> - </subregion> - - <subregion name="SCT_eta_module"> - <range field="side" minvalue="0" maxvalue="1" /> - <range field="strip" minvalue="0" maxvalue="767" /> - </subregion> - - - - - <subregion name="SCT_phi_negative_barrel_module"> - <range field="eta_module" minvalue="-6" maxvalue="-1" next_value="1" /> - <reference subregion="SCT_eta_module" /> - </subregion> - - <region group="sct" > - <reference subregion="SCT_barrel" /> - <range field="layer" value="0" /> - <range field="phi_module" minvalue="0" maxvalue="31" wraparound="TRUE" /> - <reference subregion="SCT_phi_negative_barrel_module" /> - </region> - - <region group="sct" > - <reference subregion="SCT_barrel" /> - <range field="layer" value="1" /> - <range field="phi_module" minvalue="0" maxvalue="39" wraparound="TRUE" /> - <reference subregion="SCT_phi_negative_barrel_module" /> - </region> - - <region group="sct" > - <reference subregion="SCT_barrel" /> - <range field="layer" value="2" /> - <range field="phi_module" minvalue="0" maxvalue="47" wraparound="TRUE" /> - <reference subregion="SCT_phi_negative_barrel_module" /> - </region> - - <region group="sct" > - <reference subregion="SCT_barrel" /> - <range field="layer" value="3" /> - <range field="phi_module" minvalue="0" maxvalue="55" wraparound="TRUE"/> - <reference subregion="SCT_phi_negative_barrel_module" /> - </region> - - - - - - <subregion name="SCT_phi_positive_barrel_module"> - <range field="eta_module" minvalue="+1" maxvalue="+6" prev_value="-1" /> - <reference subregion="SCT_eta_module" /> - </subregion> - - <region group="sct" > - <reference subregion="SCT_barrel" /> - <range field="layer" value="0" /> - <range field="phi_module" minvalue="0" maxvalue="31" wraparound="TRUE" /> - <reference subregion="SCT_phi_positive_barrel_module" /> - </region> - - <region group="sct" > - <reference subregion="SCT_barrel" /> - <range field="layer" value="1" /> - <range field="phi_module" minvalue="0" maxvalue="39" wraparound="TRUE" /> - <reference subregion="SCT_phi_positive_barrel_module" /> - </region> - - <region group="sct" > - <reference subregion="SCT_barrel" /> - <range field="layer" value="2" /> - <range field="phi_module" minvalue="0" maxvalue="47" wraparound="TRUE" /> - <reference subregion="SCT_phi_positive_barrel_module" /> - </region> - - <region group="sct" > - <reference subregion="SCT_barrel" /> - <range field="layer" value="3" /> - <range field="phi_module" minvalue="0" maxvalue="55" wraparound="TRUE" /> - <reference subregion="SCT_phi_positive_barrel_module" /> - </region> - - <subregion name="SCT_ring_0"> - <range field="phi_module" minvalue="0" maxvalue="51" wraparound="TRUE" /> - <range field="eta_module" value="0" /> - <reference subregion="SCT_eta_module" /> - </subregion> - - <subregion name="SCT_ring_1"> - <range field="phi_module" minvalue="0" maxvalue="39" wraparound="TRUE" /> - <range field="eta_module" value="1" /> - <reference subregion="SCT_eta_module" /> - </subregion> - - <subregion name="SCT_ring_1_2"> - <range field="phi_module" minvalue="0" maxvalue="39" wraparound="TRUE" /> - <range field="eta_module" minvalue="1" maxvalue="2" /> - <reference subregion="SCT_eta_module" /> - </subregion> - - <region group="sct" name="SCT_endcap_ring0_disks08"> - <reference subregion="SCT_endcap" /> - <range field="disk" minvalue="0" maxvalue="8" /> - <reference subregion="SCT_ring_0" /> - </region> - - - <region group="sct" name="SCT_endcap_ring1_disk0"> - <reference subregion="SCT_endcap" /> - <range field="disk" value="0" /> - <reference subregion="SCT_ring_1" /> - </region> - - <region group="sct" name="SCT_endcap_rings12_disks15"> - <reference subregion="SCT_endcap" /> - <range field="disk" minvalue="1" maxvalue="5" /> - <reference subregion="SCT_ring_1_2" /> - </region> - - <region group="sct" name="SCT_endcap_ring1_disks67"> - <reference subregion="SCT_endcap" /> - <range field="disk" minvalue="6" maxvalue="7" /> - <reference subregion="SCT_ring_1" /> - </region> - - <!-- - - TRT - - --> - - <subregion name="TRT_barrel"> - <range field="part" value="TRT" /> - <range field="barrel_endcap" values="negative_barrel positive_barrel" /> - </subregion> - - <subregion name="TRT_endcap"> - <range field="part" value="TRT" /> - <range field="barrel_endcap" values="negative_endcap positive_endcap" /> - </subregion> - - - - <subregion name="TRT_layer_0"> - <reference subregion="TRT_barrel" /> - <range field="phi_sector" minvalue="0" maxvalue="31" wraparound="TRUE" /> - <range field="layer_or_wheel" value="0" /> - </subregion> - - <region group="trt" > - <reference subregion="TRT_layer_0" /> - <range field="straw_layer" value="0" /> - <range field="straw" minvalue="0" maxvalue="14" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_0" /> - <range field="straw_layer" minvalue="1" maxvalue="4" /> - <range field="straw" minvalue="0" maxvalue="15" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_0" /> - <range field="straw_layer" minvalue="5" maxvalue="9" /> - <range field="straw" minvalue="0" maxvalue="16" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_0" /> - <range field="straw_layer" minvalue="10" maxvalue="14" /> - <range field="straw" minvalue="0" maxvalue="17" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_0" /> - <range field="straw_layer" minvalue="15" maxvalue="17" /> - <range field="straw" minvalue="0" maxvalue="18" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_0" /> - <range field="straw_layer" value="18" /> - <range field="straw" minvalue="0" maxvalue="17" /> - </region> - - - - - - <subregion name="TRT_layer_1"> - <reference subregion="TRT_barrel" /> - <range field="phi_sector" minvalue="0" maxvalue="31" wraparound="TRUE" /> - <range field="layer_or_wheel" value="1" /> - </subregion> - - <region group="trt" > - <reference subregion="TRT_layer_1" /> - <range field="straw_layer" value="0" /> - <range field="straw" minvalue="0" maxvalue="18" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_1" /> - <range field="straw_layer" minvalue="1" maxvalue="5" /> - <range field="straw" minvalue="0" maxvalue="19" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_1" /> - <range field="straw_layer" minvalue="6" maxvalue="10" /> - <range field="straw" minvalue="0" maxvalue="20" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_1" /> - <range field="straw_layer" minvalue="11" maxvalue="15" /> - <range field="straw" minvalue="0" maxvalue="21" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_1" /> - <range field="straw_layer" minvalue="16" maxvalue="20" /> - <range field="straw" minvalue="0" maxvalue="22" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_1" /> - <range field="straw_layer" minvalue="21" maxvalue="22" /> - <range field="straw" minvalue="0" maxvalue="23" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_1" /> - <range field="straw_layer" value="23" /> - <range field="straw" minvalue="0" maxvalue="22" /> - </region> - - - - - - <subregion name="TRT_layer_2"> - <reference subregion="TRT_barrel" /> - <range field="phi_sector" minvalue="0" maxvalue="31" wraparound="TRUE" /> - <range field="layer_or_wheel" value="2" /> - </subregion> - - <region group="trt" > - <reference subregion="TRT_layer_2" /> - <range field="straw_layer" value="0" /> - <range field="straw" minvalue="0" maxvalue="22" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_2" /> - <range field="straw_layer" minvalue="1" maxvalue="4" /> - <range field="straw" minvalue="0" maxvalue="23" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_2" /> - <range field="straw_layer" minvalue="5" maxvalue="9" /> - <range field="straw" minvalue="0" maxvalue="24" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_2" /> - <range field="straw_layer" minvalue="10" maxvalue="14" /> - <range field="straw" minvalue="0" maxvalue="25" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_2" /> - <range field="straw_layer" minvalue="15" maxvalue="19" /> - <range field="straw" minvalue="0" maxvalue="26" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_2" /> - <range field="straw_layer" minvalue="20" maxvalue="24" /> - <range field="straw" minvalue="0" maxvalue="27" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_2" /> - <range field="straw_layer" minvalue="25" maxvalue="28" /> - <range field="straw" minvalue="0" maxvalue="28" /> - </region> - - <region group="trt" > - <reference subregion="TRT_layer_2" /> - <range field="straw_layer" value="29" /> - <range field="straw" minvalue="0" maxvalue="27" /> - </region> - - - - - <region group="trt" > - <reference subregion="TRT_endcap" /> - <range field="phi_sector" minvalue="0" maxvalue="31" wraparound="TRUE" /> - <range field="layer_or_wheel" minvalue="0" maxvalue="5" /> - <range field="straw_layer" minvalue="0" maxvalue="15" /> - <range field="straw" minvalue="0" maxvalue="23" /> - </region> - - <region group="trt" > - <reference subregion="TRT_endcap" /> - <range field="phi_sector" minvalue="0" maxvalue="31" wraparound="TRUE" /> - <range field="layer_or_wheel" minvalue="6" maxvalue="13" /> - <range field="straw_layer" minvalue="0" maxvalue="7" /> - <range field="straw" minvalue="0" maxvalue="23" /> - </region> - - <alternate_regions> - <region group="trt" > - <reference subregion="TRT_endcap" /> - <range field="phi_sector" minvalue="0" maxvalue="31" wraparound="TRUE" /> - <range field="layer_or_wheel" minvalue="14" maxvalue="17" /> - <range field="straw_layer" minvalue="0" maxvalue="15" /> - <range field="straw" minvalue="0" maxvalue="17" /> - </region> - <region group="trt" tag="initial_layout" /> - <region group="trt" tag="final_layout" > - <reference subregion="TRT_endcap" /> - <range field="phi_sector" minvalue="0" maxvalue="31" wraparound="TRUE" /> - <range field="layer_or_wheel" minvalue="14" maxvalue="17" /> - <range field="straw_layer" minvalue="0" maxvalue="15" /> - <range field="straw" minvalue="0" maxvalue="17" /> - </region> - <region group="trt" tag="destaged_layout" /> - </alternate_regions> - - <!-- Dummy region: This forces the bit packing to be the same for all layouts --> - - <region group="trt" name = "dummy"> - <range field="part" value="TRT" /> - <range field="barrel_endcap" values="negative_endcap negative_barrel positive_barrel positive_endcap"/> - <range field="phi_sector" minvalue="0" maxvalue="31" /> - <range field="layer_or_wheel" minvalue="0" maxvalue="17" /> - <range field="straw_layer" minvalue="0" maxvalue="29" /> - <range field="straw" minvalue="0" maxvalue="28" /> - </region> - - -</IdDictionary> - diff --git a/graphics/AtlantisJava/geometry/IdDictLArCalorimeter.xml b/graphics/AtlantisJava/geometry/IdDictLArCalorimeter.xml deleted file mode 100755 index 9eac43e86363c4204fac23074fcd89c805420974..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/geometry/IdDictLArCalorimeter.xml +++ /dev/null @@ -1,694 +0,0 @@ -<IdDictionary name="LArCalorimeter" version="fullAtlas" > - - <field name="part" > - <label name="LArEM" value="1" /> - <label name="LArHEC" value="2" /> - <label name="LArFCAL" value="3" /> - <label name="LArOnline" value="4" /> - <label name="LArOnlineCalib" value="5" /> - <label name="LArEMdisc" value="-1" /> - <label name="LArHECdisc" value="-2" /> - <label name="LArFCALdisc" value="-3" /> - </field> - - <field name="barrel-endcap"> - <label name="negative-endcap-inner-wheel" value="-3" /> - <label name="negative-endcap-outer-wheel" value="-2" /> - <label name="negative-barrel" value="-1" /> - <label name="barrel" value="0" /> - <label name="positive-barrel" value="+1" /> - <label name="positive-endcap-outer-wheel" value="+2" /> - <label name="positive-endcap-inner-wheel" value="+3" /> - </field> - - <field name="barrel-ec"> - <label name="barrel" value="0" /> - <label name="endcap" value="1" /> - </field> - - <field name="pos_neg"> - <label name="negative-side" value="0" /> - <label name="positive-side" value="1" /> - </field> - - <subregion name="LArFCAL-module" > - <range field="phi-fcal" minvalue="0" maxvalue="15" wraparound="TRUE" /> - </subregion> - - <subregion name="LArEM-extralarge-module" > - <range field="phi" minvalue="0" maxvalue="31" wraparound="TRUE" /> - </subregion> - - <subregion name="LArEM-large-module" > - <range field="phi" minvalue="0" maxvalue="63" wraparound="TRUE" /> - </subregion> - - <subregion name="LArEM-thin-module" > - <range field="phi" minvalue="0" maxvalue="255" wraparound="TRUE" /> - </subregion> - - - - <!-- EM Barrel --> - - <subregion name="LArEM-barrel" > - <range field="part" value="LArEM" /> - <range field="barrel-endcap" values="negative-barrel positive-barrel" /> - </subregion> - - <region group="lar_em" name="LArEM-barrel-00" - next_samp="LArEM-barrel-10 LArEM-barrel-11" - next_subdet="LArEM-outer-wheel-10 LArEM-outer-wheel-00" - eta0="0.0" deta="0.025" phi0="0.0" dphi="64" > - <reference subregion="LArEM-barrel" /> - <range field="sampling" value="0" /> - <range field="region" value="0" /> - <range field="eta" minvalue="0" maxvalue="60" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-barrel-10" next_abs_eta="LArEM-barrel-11" - prev_samp="LArEM-barrel-00" - next_samp="LArEM-barrel-20" - eta0="0.003125" deta="0.003125" phi0="0.0" dphi="64" > - <reference subregion="LArEM-barrel" /> - <range field="sampling" value="1" /> - <range field="region" value="0" /> - <range field="eta" minvalue="1" maxvalue="447" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-barrel-11" - prev_samp="LArEM-barrel-00" - next_samp="LArEM-barrel-21" - eta0="1.4" deta="0.025" phi0="0.0" dphi="256" > - <reference subregion="LArEM-barrel" /> - <range field="sampling" value="1" /> - <range field="region" value="1" /> - <range field="eta" minvalue="0" maxvalue="2" /> - <reference subregion="LArEM-thin-module" /> - </region> - - <region group="lar_em" name="LArEM-barrel-20" next_abs_eta="LArEM-barrel-21" - prev_samp="LArEM-barrel-10" - next_samp="LArEM-barrel-30" - eta0="0.0" deta="0.025" phi0="0.0" dphi="256" > - <reference subregion="LArEM-barrel" /> - <range field="sampling" value="2" /> - <range field="region" value="0" /> - <range field="eta" minvalue="0" maxvalue="55" /> - <reference subregion="LArEM-thin-module" /> - </region> - - <region group="lar_em" name="LArEM-barrel-21" - prev_samp="LArEM-barrel-11" - next_subdet="LArEM-outer-wheel-10" - eta0="1.4" deta="0.075" phi0="0.0" dphi="256" > - <reference subregion="LArEM-barrel" /> - <range field="sampling" value="2" /> - <range field="region" value="1" /> - <range field="eta" value="0" /> - <reference subregion="LArEM-thin-module" /> - </region> - - <region group="lar_em" name="LArEM-barrel-30" - prev_samp="LArEM-barrel-20" eta0="0.0" deta="0.05" phi0="0.0" dphi="256" > - <reference subregion="LArEM-barrel" /> - <range field="sampling" value="3" /> - <range field="region" value="0" /> - <range field="eta" minvalue="0" maxvalue="26" /> - <reference subregion="LArEM-thin-module" /> - </region> - - - - <!-- EM outer wheel --> - - <subregion name="LArEM-outer-wheel" > - <range field="part" value="LArEM" /> - <range field="barrel-endcap" values="negative-endcap-outer-wheel positive-endcap-outer-wheel" /> - </subregion> - - <region group="lar_em" name="LArEM-outer-wheel-00" - next_samp="LArEM-outer-wheel-12" - prev_subdet="LArEM-barrel-00" - eta0="1.5" deta="0.025" phi0="0.0" dphi="64" > - <reference subregion="LArEM-outer-wheel" /> - <range field="sampling" value="0" /> - <range field="region" value="0" /> - <range field="eta" minvalue="0" maxvalue="11" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-outer-wheel-10" next_abs_eta="LArEM-outer-wheel-11" - next_samp="LArEM-outer-wheel-20" - prev_subdet="LArEM-barrel-00 LArEM-barrel-21" - eta0="1.375" deta="0.05" phi0="0.0" dphi="64" > - <reference subregion="LArEM-outer-wheel" /> - <range field="sampling" value="1" /> - <range field="region" value="0" /> - <range field="eta" value="0" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-outer-wheel-11" next_abs_eta="LArEM-outer-wheel-12" - next_samp="LArEM-outer-wheel-21" eta0="1.425" deta="0.025" phi0="0.0" dphi="64" > - <reference subregion="LArEM-outer-wheel" /> - <range field="sampling" value="1" /> - <range field="region" value="1" /> - <range field="eta" minvalue="0" maxvalue="2" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-outer-wheel-12" next_abs_eta="LArEM-outer-wheel-13" - prev_samp="LArEM-outer-wheel-00" - next_samp="LArEM-outer-wheel-21" eta0="1.5" deta="0.003125" phi0="0.0" dphi="64" > - <reference subregion="LArEM-outer-wheel" /> - <range field="sampling" value="1" /> - <range field="region" value="2" /> - <range field="eta" minvalue="0" maxvalue="95" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-outer-wheel-13" next_abs_eta="LArEM-outer-wheel-14" - next_samp="LArEM-outer-wheel-21" eta0="1.8" deta="0.0041666666667" phi0="0.0" dphi="64" > - <reference subregion="LArEM-outer-wheel" /> - <range field="sampling" value="1" /> - <range field="region" value="3" /> - <range field="eta" minvalue="0" maxvalue="47" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-outer-wheel-14" next_abs_eta="LArEM-outer-wheel-15" - next_samp="LArEM-outer-wheel-21" eta0="2.0" deta="0.00625" phi0="0.0" dphi="64" > - <reference subregion="LArEM-outer-wheel" /> - <range field="sampling" value="1" /> - <range field="region" value="4" /> - <range field="eta" minvalue="0" maxvalue="63" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-outer-wheel-15" - next_samp="LArEM-outer-wheel-21" eta0="2.4" deta="0.025" phi0="0.0" dphi="64" > - <reference subregion="LArEM-outer-wheel" /> - <range field="sampling" value="1" /> - <range field="region" value="5" /> - <range field="eta" minvalue="0" maxvalue="3" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-outer-wheel-20" next_abs_eta="LArEM-outer-wheel-21" - prev_samp="LArEM-outer-wheel-10" eta0="1.375" deta="0.05" phi0="0.0" dphi="256" > - <reference subregion="LArEM-outer-wheel" /> - <range field="sampling" value="2" /> - <range field="region" value="0" /> - <range field="eta" value="0" /> - <reference subregion="LArEM-thin-module" /> - </region> - - <region group="lar_em" name="LArEM-outer-wheel-21" next_abs_eta="LArEM-inner-wheel-10" - prev_samp="LArEM-outer-wheel-11 LArEM-outer-wheel-12 LArEM-outer-wheel-13 LArEM-outer-wheel-14 LArEM-outer-wheel-15" - next_samp="LArEM-outer-wheel-30" eta0="1.425" deta="0.025" phi0="0.0" dphi="256" > - <reference subregion="LArEM-outer-wheel" /> - <range field="sampling" value="2" /> - <range field="region" value="1" /> - <range field="eta" minvalue="0" maxvalue="42" /> - <reference subregion="LArEM-thin-module" /> - </region> - - <region group="lar_em" name="LArEM-outer-wheel-30" next_abs_eta="LArEM-inner-wheel-20" - prev_samp="LArEM-outer-wheel-21" eta0="1.5" deta="0.05" phi0="0.0" dphi="256" > - <reference subregion="LArEM-outer-wheel" /> - <range field="sampling" value="3" /> - <range field="region" value="0" /> - <range field="eta" minvalue="0" maxvalue="19" /> - <reference subregion="LArEM-thin-module" /> - </region> - - - - - - - <!-- EM inner wheel --> - - <subregion name="LArEM-inner-wheel" > - <range field="part" value="LArEM" /> - <range field="barrel-endcap" values="negative-endcap-inner-wheel positive-endcap-inner-wheel" /> - </subregion> - - <region group="lar_em" name="LArEM-inner-wheel-10" - next_samp="LArEM-inner-wheel-20" eta0="2.5" deta="0.1" phi0="0.0" dphi="64" > - <reference subregion="LArEM-inner-wheel" /> - <range field="sampling" value="1" /> - <range field="region" value="0" /> - <range field="eta" minvalue="0" maxvalue="6" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-inner-wheel-20" - prev_samp="LArEM-inner-wheel-10" eta0="2.5" deta="0.1" phi0="0.0" dphi="64" > - <reference subregion="LArEM-inner-wheel" /> - <range field="sampling" value="2" /> - <range field="region" value="0" /> - <range field="eta" minvalue="0" maxvalue="6" /> - <reference subregion="LArEM-large-module" /> - </region> - - - - - - <!-- - - LArHEC - - --> - - <subregion name="LArHEC" > - <range field="part" value="LArHEC" /> - <range field="barrel-endcap" values="negative-endcap-outer-wheel positive-endcap-outer-wheel" /> - </subregion> - - <region group="lar_hec" name="LArHEC-00" next_abs_eta="LArHEC-01" - next_samp="LArHEC-10" eta0="1.5" deta="0.1" phi0="0.0" dphi="64" > - <reference subregion="LArHEC" /> - <range field="sampling" value="0" /> - <range field="region" value="0" /> - <range field="eta" minvalue="0" maxvalue="9" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_hec" name="LArHEC-10" next_abs_eta="LArHEC-11" - next_samp="LArHEC-20" prev_samp="LArHEC-00" eta0="1.5" deta="0.1" phi0="0.0" dphi="64" > - <reference subregion="LArHEC" /> - <range field="sampling" value="1" /> - <range field="region" value="0" /> - <range field="eta" minvalue="0" maxvalue="9" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_hec" name="LArHEC-20" next_abs_eta="LArHEC-21" - next_samp="LArHEC-30" prev_samp="LArHEC-10" eta0="1.6" deta="0.1" phi0="0.0" dphi="64" > - <reference subregion="LArHEC" /> - <range field="sampling" values="2" /> - <range field="region" value="0" /> - <range field="eta" minvalue="1" maxvalue="9" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_hec" name="LArHEC-30" next_abs_eta="LArHEC-31" - prev_samp="LArHEC-20" eta0="1.7" deta="0.1" phi0="0.0" dphi="64" > - <reference subregion="LArHEC" /> - <range field="sampling" values="3" /> - <range field="region" value="0" /> - <range field="eta" minvalue="2" maxvalue="9" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_hec" name="LArHEC-01" - next_samp="LArHEC-11" eta0="2.5" deta="0.2" phi0="0.0" dphi="32" > - <reference subregion="LArHEC" /> - <range field="sampling" value="0" /> - <range field="region" value="1" /> - <range field="eta" minvalue="0" maxvalue="3" /> - <reference subregion="LArEM-extralarge-module" /> - </region> - - <region group="lar_hec" name="LArHEC-11" next_abs_eta="LArFCAL-1" - next_samp="LArHEC-21" prev_samp="LArHEC-01" eta0="2.5" deta="0.2" phi0="0.0" dphi="32" > - <reference subregion="LArHEC" /> - <range field="sampling" value="1" /> - <range field="region" value="1" /> - <range field="eta" minvalue="0" maxvalue="2" /> - <reference subregion="LArEM-extralarge-module" /> - </region> - - <region group="lar_hec" name="LArHEC-21" - next_samp="LArHEC-31" prev_samp="LArHEC-11" eta0="2.5" deta="0.2" phi0="0.0" dphi="32" > - <reference subregion="LArHEC" /> - <range field="sampling" value="2" /> - <range field="region" value="1" /> - <range field="eta" minvalue="0" maxvalue="2" /> - <reference subregion="LArEM-extralarge-module" /> - </region> - - <region group="lar_hec" name="LArHEC-31" - prev_samp="LArHEC-21" eta0="2.5" deta="0.2" phi0="0.0" dphi="32" > - <reference subregion="LArHEC" /> - <range field="sampling" value="3" /> - <range field="region" value="1" /> - <range field="eta" minvalue="0" maxvalue="3" /> - <reference subregion="LArEM-extralarge-module" /> - </region> - - - - - <!-- - - LArFCAL - - --> - - <subregion name="LArFCAL" > - <range field="part" value="LArFCAL" /> - <range field="barrel-endcap" values="negative-endcap-outer-wheel positive-endcap-outer-wheel" /> - </subregion> - - <region group="lar_fcal" name="LArFCAL-1" - eta0="3.2" deta="0.025" phi0="0.0" dphi="16" > - <reference subregion="LArFCAL" /> - <range field="module" value="1" /> - <range field="eta-fcal" minvalue="0" maxvalue="62" /> - <reference subregion="LArFCAL-module" /> - </region> - - <region group="lar_fcal" name="LArFCAL-2a" - eta0="3.2" deta="0.05" phi0="0.0" dphi="16" > - <reference subregion="LArFCAL" /> - <range field="module" value="2" /> - <range field="eta-fcal" minvalue="0" maxvalue="29" /> - <range field="phi-fcal" values="0 7 8 15" /> - </region> - - <region group="lar_fcal" name="LArFCAL-2b" - eta0="3.2" deta="0.05" phi0="0.0" dphi="16" > - <reference subregion="LArFCAL" /> - <range field="module" value="2" /> - <range field="eta-fcal" minvalue="0" maxvalue="30" /> - <range field="phi-fcal" values="3 4 11 12" /> - </region> - - <region group="lar_fcal" name="LArFCAL-2c" - eta0="3.2" deta="0.05" phi0="0.0" dphi="16" > - <reference subregion="LArFCAL" /> - <range field="module" value="2" /> - <range field="eta-fcal" minvalue="0" maxvalue="31" /> - <range field="phi-fcal" values="1 2 5 6 9 10 13 14" /> - </region> - - <region group="lar_fcal" name="LArFCAL-3a" - eta0="3.2" deta="0.1" phi0="0.0" dphi="16" > - <reference subregion="LArFCAL" /> - <range field="module" value="3" /> - <range field="eta-fcal" minvalue="0" maxvalue="14" /> - <range field="phi-fcal" values="2 10" /> - </region> - - <region group="lar_fcal" name="LArFCAL-3b" - eta0="3.2" deta="0.1" phi0="0.0" dphi="16" > - <reference subregion="LArFCAL" /> - <range field="module" value="3" /> - <range field="eta-fcal" minvalue="0" maxvalue="15" /> - <range field="phi-fcal" values="0 1 3 4 5 6 7 8 9 11 12 13 14 15" /> - </region> - - - - <!-- - - Disconnected Channels - - --> - - <subregion name="LArEM-barreldisc" > - <range field="part" value="LArEMdisc" /> - <range field="barrel-endcap" values="negative-barrel positive-barrel" /> - </subregion> - - <region group="lar_em" name="LArEM-barrel-00disconnected" > - <reference subregion="LArEM-barreldisc" /> - <range field="sampling" value="0" /> - <range field="region" value="0" /> - <range field="eta" minvalue="61" maxvalue="63" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-barrel-10disconnected" > - <reference subregion="LArEM-barreldisc" /> - <range field="sampling" value="1" /> - <range field="region" value="0" /> - <range field="eta" value="0" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-barrel-30disconnected" > - <reference subregion="LArEM-barreldisc" /> - <range field="sampling" value="3" /> - <range field="region" value="0" /> - <range field="eta" value="27" /> - <reference subregion="LArEM-thin-module" /> - </region> - - - <subregion name="LArEM-outer-wheeldisc" > - <range field="part" value="LArEMdisc" /> - <range field="barrel-endcap" values="negative-endcap-outer-wheel positive-endcap-outer-wheel" /> - </subregion> - - <region group="lar_em" name="LArEM-outer-wheel-00disconnected" > - <reference subregion="LArEM-outer-wheeldisc" /> - <range field="sampling" value="0" /> - <range field="region" value="0" /> - <range field="eta" minvalue="12" maxvalue="19" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-outer-wheel-11disconnected" > - <reference subregion="LArEM-outer-wheeldisc" /> - <range field="sampling" value="1" /> - <range field="region" value="1" /> - <range field="eta" minvalue="3" maxvalue="6" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-outer-wheel-13disconnected" > - <reference subregion="LArEM-outer-wheeldisc" /> - <range field="sampling" value="1" /> - <range field="region" value="3" /> - <range field="eta" minvalue="48" maxvalue="63" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-outer-wheel-15disconnected" > - <reference subregion="LArEM-outer-wheeldisc" /> - <range field="sampling" value="1" /> - <range field="region" value="5" /> - <range field="eta" minvalue="4" maxvalue="7" /> - <reference subregion="LArEM-large-module" /> - </region> - - - <subregion name="LArEM-inner-wheeldisc" > - <range field="part" value="LArEMdisc" /> - <range field="barrel-endcap" values="negative-endcap-inner-wheel positive-endcap-inner-wheel" /> - </subregion> - - <region group="lar_em" name="LArEM-inner-wheel-10disconnected" > - <reference subregion="LArEM-inner-wheeldisc" /> - <range field="sampling" value="1" /> - <range field="region" value="0" /> - <range field="eta" value="7" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_em" name="LArEM-inner-wheel-20disconnected" > - <reference subregion="LArEM-inner-wheeldisc" /> - <range field="sampling" value="2" /> - <range field="region" value="0" /> - <range field="eta" value="7" /> - <reference subregion="LArEM-large-module" /> - </region> - - - - <subregion name="LArHECdisc" > - <range field="part" value="LArHECdisc" /> - <range field="barrel-endcap" values="negative-endcap-outer-wheel positive-endcap-outer-wheel" /> - </subregion> - - <region group="lar_hec" name="LArHEC-20disconnected" > - <reference subregion="LArHECdisc" /> - <range field="sampling" values="2" /> - <range field="region" value="0" /> - <range field="eta" value="0" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_hec" name="LArHEC-30disconnected" > - <reference subregion="LArHECdisc" /> - <range field="sampling" values="3" /> - <range field="region" value="0" /> - <range field="eta" minvalue="0" maxvalue="1" /> - <reference subregion="LArEM-large-module" /> - </region> - - <region group="lar_hec" name="LArHEC-11disconnected" > - <reference subregion="LArHECdisc" /> - <range field="sampling" value="1" /> - <range field="region" value="1" /> - <range field="eta" value="3" /> - <reference subregion="LArEM-extralarge-module" /> - </region> - - <region group="lar_hec" name="LArHEC-21disconnected" > - <reference subregion="LArHECdisc" /> - <range field="sampling" value="2" /> - <range field="region" value="1" /> - <range field="eta" value="3" /> - <reference subregion="LArEM-extralarge-module" /> - </region> - - - <subregion name="LArFCALdisc" > - <range field="part" value="LArFCALdisc" /> - <range field="barrel-endcap" values="negative-endcap-outer-wheel positive-endcap-outer-wheel" /> - </subregion> - - <region group="lar_fcal" name="LArFCAL-1disconnected" > - <reference subregion="LArFCALdisc" /> - <range field="module" value="1" /> - <range field="eta-fcal" value="63" /> - <reference subregion="LArFCAL-module" /> - </region> - - <region group="lar_fcal" name="LArFCAL-2adisconnected" > - <reference subregion="LArFCALdisc" /> - <range field="module" value="2" /> - <range field="eta-fcal" minvalue="30" maxvalue="31" /> - <range field="phi-fcal" values="0 7 8 15" /> - </region> - - <region group="lar_fcal" name="LArFCAL-2bdisconnected" - eta0="3.2" deta="0.05" phi0="0.0" dphi="0.4" > - <reference subregion="LArFCALdisc" /> - <range field="module" value="2" /> - <range field="eta-fcal" value="31" /> - <range field="phi-fcal" values="3 4 11 12" /> - </region> - - <region group="lar_fcal" name="LArFCAL-3adisconnected" > - <reference subregion="LArFCALdisc" /> - <range field="module" value="3" /> - <range field="eta-fcal" value="15" /> - <range field="phi-fcal" values="2 10" /> - </region> - - - <!-- LAr Online --> - - - <!-- LArOnline -Barrel --> - - <subregion name="LArOnline-Barrel"> - <range field="part" value="LArOnline" /> - <range field="barrel-ec" values="barrel" /> - </subregion> - - <region group="LArOnline" name="laronline-barrel"> - <reference subregion="LArOnline-Barrel" /> - <range field="pos_neg" values="negative-side positive-side" /> - <range field="feedthrough" minvalue="0" maxvalue="31" /> - <range field="slot" minvalue="1" maxvalue="14" /> - <range field="channel_in_slot" minvalue="0" maxvalue="127" /> - </region> - - <!-- LArOnline-EndCap Standard --> - - <subregion name="LArOnline-Endcap"> - <range field="part" value="LArOnline" /> - <range field="barrel-ec" values="endcap" /> - </subregion> - - <region group="LArOnline" name="laronline-endcap-standard"> - <reference subregion="LArOnline-Endcap" /> - <range field="pos_neg" values="negative-side positive-side" /> - <range field="feedthrough" values="0 1 4 5 7 8 11 12 13 14 17 18 19 20 23 24" /> - <range field="slot" minvalue="1" maxvalue="13" /> - <range field="channel_in_slot" minvalue="0" maxvalue="127" /> - </region> - - <!-- LArOnline-Endcap-Special --> - - <region group="LArOnline" name="laronline-endcap-special" > - <reference subregion="LArOnline-Endcap" /> - <range field="pos_neg" values="negative-side positive-side" /> - <range field="feedthrough" values="2 9 15 21" /> - <range field="slot" minvalue="1" maxvalue="15" /> - <range field="channel_in_slot" minvalue="0" maxvalue="127" /> - </region> - - <!-- LArOnline-HEC--> - - <region group="LArOnline" name="laronline-hec"> - <reference subregion="LArOnline-Endcap" /> - <range field="pos_neg" values="negative-side positive-side" /> - <range field="feedthrough" values="3 10 16 22" /> - <range field="slot" values="1 2 5 6 7 8 9 10" /> - <range field="channel_in_slot" minvalue="0" maxvalue="127" /> - </region> - - <!-- LArOnline-FCAL--> - - <region group="LArOnline" name="laronlinefcal" > - <reference subregion="LArOnline-Endcap" /> - <range field="pos_neg" values="negative-side positive-side" /> - <range field="feedthrough" value="6" /> - <range field="slot" minvalue="1" maxvalue="14" /> - <range field="channel_in_slot" minvalue="0" maxvalue="127" /> - </region> - - <!-- LArOnline -Barrel Calib --> - - <subregion name="LArOnline-Barrel-Calib"> - <range field="part" value="LArOnlineCalib" /> - <range field="barrel-ec" values="barrel" /> - </subregion> - - <region group="LArOnline" name="laronline-barrel-calib"> - <reference subregion="LArOnline-Barrel-Calib" /> - <range field="pos_neg" values="negative-side positive-side" /> - <range field="feedthrough" minvalue="0" maxvalue="31" /> - <range field="slot" value="15" /> - <range field="channel_in_slot" minvalue="0" maxvalue="127" /> - </region> - - <!-- LArOnline-EndCap Standard Calib --> - - <subregion name="LArOnline-Endcap-Calib"> - <range field="part" value="LArOnlineCalib" /> - <range field="barrel-ec" values="endcap" /> - </subregion> - - <region group="LArOnline" name="laronline-endcap-standard"> - <reference subregion="LArOnline-Endcap-Calib" /> - <range field="pos_neg" values="negative-side positive-side" /> - <range field="feedthrough" values="0 1 4 5 7 8 11 12 13 14 17 18 19 20 23 24" /> - <range field="slot" value="15" /> - <range field="channel_in_slot" minvalue="0" maxvalue="127" /> - </region> - - <!-- LArOnline-HEC CALIB --> - - <region group="LArOnline" name="laronline-hec-calib"> - <reference subregion="LArOnline-Endcap-Calib" /> - <range field="pos_neg" values="negative-side positive-side" /> - <range field="feedthrough" values="3 10 16 22" /> - <range field="slot" values="3 4 12" /> - <range field="channel_in_slot" minvalue="0" maxvalue="127" /> - </region> - - <!-- LArOnline-FCAL CALIB --> - - <region group="LArOnline" name="laronline-fcal-calib"> - <reference subregion="LArOnline-Endcap-Calib" /> - <range field="pos_neg" values="negative-side positive-side" /> - <range field="feedthrough" values="6" /> - <range field="slot" value="16" /> - <range field="channel_in_slot" minvalue="0" maxvalue="127" /> - </region> - - -</IdDictionary> - diff --git a/graphics/AtlantisJava/geometry/IdDictLArElectrode.xml b/graphics/AtlantisJava/geometry/IdDictLArElectrode.xml deleted file mode 100755 index 948ccf3d09965521af0cd7eb2cd3f1c7a0714d88..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/geometry/IdDictLArElectrode.xml +++ /dev/null @@ -1,327 +0,0 @@ -<IdDictionary name="LArElectrode" version="fullAtlas" > - - <field name="detector" > - <label name="EMB" value="0" /> - <label name="EMBPS" value="1" /> - <label name="EMEC" value="2" /> - <label name="EMECPS" value="3" /> - <label name="HEC" value="4" /> - <label name="FCAL" value="5" /> - <label name="EMBPUR" value="6" /> - <label name="ECPUR" value="7" /> - </field> - - <field name="configuration" > - <label name="Atlas" value="1" /> - <label name="TestBeam" value="2" /> - </field> - - <field name="zside"> - <label name="A" value="0" /> - <label name="C" value="1" /> - </field> - - <field name="module"> - </field> - - <field name="hvphi" > - </field> - - <field name="hveta" > - </field> - - <field name="hvgap" > - </field> - - <field name="electrode"> - </field> - - - <!-- LAr Electrodes--> - - <subregion name="AtlasLArElectrode"> - <range field="configuration" value="Atlas" /> - </subregion> - - <!--EMB-FT=-1 --> - <region group="LArElec" name="EM-BARREL-ALL"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMB" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="15" /> - <range field="hvphi" values="1" /> - <range field="hveta" minvalue="1" maxvalue="7" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="0" maxvalue="31" /> - </region> - - <!--EMB-FT=0 --> - <region group="LArElec" name="EM-BARREL-FT0"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMB" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="15" /> - <range field="hvphi" values="0" /> - <range field="hveta" minvalue="1" maxvalue="7" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="32" maxvalue="63" /> - </region> - - <!--EMBPS --> - <region group="LArElec" name="EM-BARREL-PS"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMBPS" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="31" /> - <range field="hvphi" values="0 1" /> - <range field="hveta" minvalue="1" maxvalue="4" /> - <range field="hvgap" values="0 1" /> - <!--note that this value 'electrode' is DUMMY until confirmation by Hostachy--> - <range field="electrode" value="0" /> - </region> - - <!--EMEC-INNER-WHEEL--> - <region group="LArElec" name="EM-ENDCAP-INNER-S1"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="1" /> - <range field="hveta" minvalue="7" maxvalue="8" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="0" maxvalue="3" /> - </region> - <region group="LArElec" name="EM-ENDCAP-INNER-S2"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="2" /> - <range field="hveta" minvalue="7" maxvalue="8" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="4" maxvalue="7" /> - </region> - <region group="LArElec" name="EM-ENDCAP-INNER-S3"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="3" /> - <range field="hveta" minvalue="7" maxvalue="8" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="8" maxvalue="11" /> - </region> - <region group="LArElec" name="EM-ENDCAP-INNER-S4"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="4" /> - <range field="hveta" minvalue="7" maxvalue="8" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="12" maxvalue="15" /> - </region> - <region group="LArElec" name="EM-ENDCAP-INNER-S5"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="5" /> - <range field="hveta" minvalue="7" maxvalue="8" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="16" maxvalue="19" /> - </region> - <region group="LArElec" name="EM-ENDCAP-INNER-S6"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="6" /> - <range field="hveta" minvalue="7" maxvalue="8" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="20" maxvalue="23" /> - </region> - <region group="LArElec" name="EM-ENDCAP-INNER-S7"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="7" /> - <range field="hveta" minvalue="7" maxvalue="8" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="24" maxvalue="27" /> - </region> - <region group="LArElec" name="EM-ENDCAP-INNER-S8"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="8" /> - <range field="hveta" minvalue="7" maxvalue="8" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="28" maxvalue="31" /> - </region> - - <!--EMEC-OUTER-WHEEL--> - <region group="LArElec" name="EM-ENDCAP-OUTER-S1"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="1" /> - <range field="hveta" minvalue="0" maxvalue="6" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="0" maxvalue="23" /> - </region> - <region group="LArElec" name="EM-ENDCAP-OUTER-S2"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="2" /> - <range field="hveta" minvalue="0" maxvalue="6" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="24" maxvalue="47" /> - </region> - <region group="LArElec" name="EM-ENDCAP-OUTER-S3"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="3" /> - <range field="hveta" minvalue="0" maxvalue="6" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="48" maxvalue="71" /> - </region> - <region group="LArElec" name="EM-ENDCAP-OUTER-S4"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="4" /> - <range field="hveta" minvalue="0" maxvalue="6" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" minvalue="72" maxvalue="95" /> - </region> - - <!--EMEC-PS--> - <region group="LArElec" name="EM-ENDCAP-PS"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMECPS" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="31" /> - <range field="hvphi" value="0" /> - <range field="hveta" value="0" /> - <range field="hvgap" values="0 1" /> - <range field="electrode" value="0" /> - </region> - - <!--HEC--> - <region group="LArElec" name="HEC-ETA1"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="HEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="31" /> - <range field="hvphi" value="0" /> - <range field="hveta" value="1" /> - <range field="hvgap" minvalue="0" maxvalue="3" /> - <range field="electrode" minvalue="1" maxvalue="8" /> - </region> - - <region group="LArElec" name="HEC-ETA2"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="HEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="31" /> - <range field="hvphi" value="0" /> - <range field="hveta" value="2" /> - <range field="hvgap" minvalue="0" maxvalue="3" /> - <range field="electrode" minvalue="9" maxvalue="24" /> - </region> - - <region group="LArElec" name="HEC-ETA3"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="HEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="31" /> - <range field="hvphi" value="0" /> - <range field="hveta" value="3" /> - <range field="hvgap" minvalue="0" maxvalue="3" /> - <range field="electrode" minvalue="25" maxvalue="32" /> - </region> - - <region group="LArElec" name="HEC-ETA4"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="HEC" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="31" /> - <range field="hvphi" value="0" /> - <range field="hveta" value="4" /> - <range field="hvgap" minvalue="0" maxvalue="3" /> - <range field="electrode" minvalue="33" maxvalue="40" /> - </region> - - <!--FCAL--> - - <!--FCAL1--> - <region group="LArElec" name="FCAL-S1"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="FCAL" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="15" /> - <range field="hvphi" value="0" /> - <range field="hveta" value="1" /> - <range field="hvgap" minvalue="0" maxvalue="3" /> - <range field="electrode" value="0" /> - </region> - - <region group="LArElec" name="FCAL-S2"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="FCAL" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="7" /> - <range field="hvphi" value="0" /> - <range field="hveta" value="2" /> - <range field="hvgap" minvalue="0" maxvalue="3" /> - <range field="electrode" value="0" /> - </region> - - <region group="LArElec" name="FCAL-S3"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="FCAL" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="0" maxvalue="3" /> - <range field="hvphi" value="0" /> - <range field="hveta" value="3" /> - <range field="hvgap" minvalue="0" maxvalue="3" /> - <range field="electrode" value="0" /> - </region> - - - <!--EMBPUR--> - <region group="LArElec" name="EMB-PUR"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="EMBPUR" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="1" maxvalue="5" /> - <range field="hvphi" value="0" /> - <range field="hveta" minvalue="0" /> - <range field="hvgap" minvalue="0" maxvalue="1" /> - <range field="electrode" value="0" /> - </region> - - <!--ECPUR--> - <region group="LArElec" name="EC-PUR"> - <reference subregion="AtlasLArElectrode" /> - <range field="detector" value="ECPUR" /> - <range field="zside" values="0 1" /> - <range field="module" minvalue="1" maxvalue="10" /> - <range field="hvphi" value="0" /> - <range field="hveta" minvalue="0" /> - <range field="hvgap" minvalue="0" maxvalue="1" /> - <range field="electrode" value="0" /> - </region> - - -</IdDictionary> - diff --git a/graphics/AtlantisJava/geometry/IdDictLArHighVoltage.xml b/graphics/AtlantisJava/geometry/IdDictLArHighVoltage.xml deleted file mode 100755 index b0a26c9558edf6fc52d55398f940e8fec0aa658b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/geometry/IdDictLArHighVoltage.xml +++ /dev/null @@ -1,222 +0,0 @@ - -<IdDictionary name="LArHighVoltage" version="fullAtlas" > - - <field name="configuration" > - <label name="Atlas" value="1" /> - <label name="TestBeam" value="2" /> - </field> - - <field name="cannode"> - </field> - - <field name="hvline"> - </field> - - <field name="partition" > - </field> - - <field name="canline"> - </field> - - - <!-- HighVoltage Lines--> - - <subregion name="AtlasHighVoltage"> - <range field="configuration" value="Atlas" /> - </subregion> - - - <!-- LArHV HEC --> - - <region group="LArHV" name="LArHV-HEC-A"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="48" maxvalue="79" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - - <region group="LArHV" name="LArHV-HEC-C"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="148" maxvalue="179" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - - <!-- LArHV FCAL --> - - <region group="LArHV" name="LArHV-FCAL-A"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="80" maxvalue="93" /> - <range field="hvline" minvalue="0" maxvalue="7" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - - <region group="LArHV" name="LArHV-FCAL-C"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="180" maxvalue="193" /> - <range field="hvline" minvalue="0" maxvalue="7" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - - - <!-- LArHV EMB --> - - <!-- EMB-A-SIDE--> - <region group="LArHV" name="LArHV-EMB-A-STD"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="200" maxvalue="231" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - <region group="LArHV" name="LArHV-EMB-C-STD"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="232" maxvalue="263" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - <region group="LArHV" name="LArHV-EMB-A-SPE"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" values="296 297 306 307" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - <region group="LArHV" name="LArHV-EMB-C-SPE"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" values="299 304 305 308 309" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - - - - <!-- LArHV EMBPS --> - - <region group="LArHV" name="LArHV-EMBPS-A"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="264" maxvalue="279" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - - <region group="LArHV" name="LArHV-EMBPS-C"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="280" maxvalue="295" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - - - <!-- LArHV EMEC --> - - <region group="LArHV" name="LArHV-EMEC-A1"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="0" maxvalue="47" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - <region group="LArHV" name="LArHV-EMEC-A2"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="320" maxvalue="322" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - <region group="LArHV" name="LArHV-EMEC-C1"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="100" maxvalue="147" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - <region group="LArHV" name="LArHV-EMEC-C2"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" values="324 325" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - - - <!-- LArHV EMECPS --> - - <region group="LArHV" name="LArHV-EMECPS-A"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="312" maxvalue="315" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - - <region group="LArHV" name="LArHV-EMECPS-C"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="316" maxvalue="319" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - - - <!-- LArHV EMPUR --> - - <region group="LArHV" name="LArEMBPUR-A"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="300" maxvalue="303" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - - - <!-- All these lines are free to use --> - - <region group="LArHV" name="NOCONN-NEW"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" values="310 311" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - <region group="LArHV" name="NOCONN-A"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" values="323" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - <region group="LArHV" name="NOCONN-C"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" values="326 327" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - <region group="LArHV" name="FREE-A"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="94" maxvalue="99" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - <region group="LArHV" name="FREE-B"> - <reference subregion="AtlasHighVoltage" /> - <range field="cannode" minvalue="194" maxvalue="199" /> - <range field="hvline" minvalue="0" maxvalue="15" /> - <range field="partition" value="1" /> - <range field="canline" value="1" /> - </region> - - - -</IdDictionary> - diff --git a/graphics/AtlantisJava/geometry/IdDictTileCalorimeter.xml b/graphics/AtlantisJava/geometry/IdDictTileCalorimeter.xml deleted file mode 100755 index 76ab90dd0d52d69db648d69c47d44125c9b504a6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/geometry/IdDictTileCalorimeter.xml +++ /dev/null @@ -1,398 +0,0 @@ -<IdDictionary name="TileCalorimeter" version="fullAtlasAndTestBeam" > - - <field name="section" > - <label name="Online" value="0" /> - <label name="Barrel" value="1" /> - <label name="Extended-barrel" value="2" /> - <label name="ITC-gap-scintillator" value="3" /> - <label name="Testbeam" value="4" /> - </field> - - <field name="side" > - <label name="positive" value="+1" /> - <label name="negative" value="-1" /> - </field> - - <subregion name="cylinder-pos" > - <range field="side" value="positive" /> - <range field="module" minvalue="0" maxvalue="63" /> - </subregion> - - <subregion name="cylinder-neg" > - <range field="side" value="negative" /> - <range field="module" minvalue="0" maxvalue="63" /> - </subregion> - - <subregion name="cylinder" > - <range field="side" /> - <range field="module" minvalue="0" maxvalue="63" /> - </subregion> - - <subregion name="pmt1" > - <range field="pmt" value="0" /> - <range field="adc" minvalue="0" maxvalue="1" /> - </subregion> - - <subregion name="pmt2" > - <range field="pmt" minvalue="0" maxvalue="1" /> - <range field="adc" minvalue="0" maxvalue="1" /> - </subregion> - - <subregion name="tower0AB" > - <range field="tower" value="0" /> - <range field="sampling" minvalue="0" maxvalue="1" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower0" > - <range field="tower" value="0" /> - <range field="sampling" minvalue="0" maxvalue="2" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower1" > - <range field="tower" value="1" /> - <range field="sampling" minvalue="0" maxvalue="1" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower2" > - <range field="tower" value="2" /> - <range field="sampling" minvalue="0" maxvalue="2" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower3" > - <range field="tower" value="3" /> - <range field="sampling" minvalue="0" maxvalue="1" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower4" > - <range field="tower" value="4" /> - <range field="sampling" minvalue="0" maxvalue="2" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower5" > - <range field="tower" value="5" /> - <range field="sampling" minvalue="0" maxvalue="1" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower6" > - <range field="tower" value="6" /> - <range field="sampling" minvalue="0" maxvalue="2" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower7" > - <range field="tower" value="7" /> - <range field="sampling" minvalue="0" maxvalue="1" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower8" > - <range field="tower" value="8" /> - <range field="sampling" minvalue="0" maxvalue="1" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower9" > - <range field="tower" value="9" /> - <range field="sampling" value="0" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower10" > - <range field="tower" value="10" /> - <range field="sampling" minvalue="1" maxvalue="2" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower11" > - <range field="tower" value="11" /> - <range field="sampling" minvalue="0" maxvalue="1" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower12" > - <range field="tower" value="12" /> - <range field="sampling" minvalue="0" maxvalue="2" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower13" > - <range field="tower" value="13" /> - <range field="sampling" minvalue="0" maxvalue="1" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower14" > - <range field="tower" value="14" /> - <range field="sampling" minvalue="0" maxvalue="1" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="tower15" > - <range field="tower" value="15" /> - <range field="sampling" value="0" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="D4" > - <range field="tower" value="8" /> - <range field="sampling" value="2" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="C10" > - <range field="tower" value="9" /> - <range field="sampling" value="1" /> - <reference subregion="pmt2" /> - </subregion> - - <subregion name="E1" > - <range field="tower" value="10" /> - <range field="sampling" value="3" /> - <reference subregion="pmt1" /> - </subregion> - - <subregion name="E2" > - <range field="tower" value="11" /> - <range field="sampling" value="3" /> - <reference subregion="pmt1" /> - </subregion> - - <subregion name="E3" > - <range field="tower" value="13" /> - <range field="sampling" value="3" /> - <reference subregion="pmt1" /> - </subregion> - - <subregion name="E4" > - <range field="tower" value="15" /> - <range field="sampling" value="3" /> - <reference subregion="pmt1" /> - </subregion> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-neg" /> - <reference subregion="tower0AB" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-pos" /> - <reference subregion="tower0" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-neg" /> - <reference subregion="tower1" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-pos" /> - <reference subregion="tower1" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-neg" /> - <reference subregion="tower2" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-pos" /> - <reference subregion="tower2" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-neg" /> - <reference subregion="tower3" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-pos" /> - <reference subregion="tower3" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-neg" /> - <reference subregion="tower4" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-pos" /> - <reference subregion="tower4" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-neg" /> - <reference subregion="tower5" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-pos" /> - <reference subregion="tower5" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-neg" /> - <reference subregion="tower6" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-pos" /> - <reference subregion="tower6" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-neg" /> - <reference subregion="tower7" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-pos" /> - <reference subregion="tower7" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-neg" /> - <reference subregion="tower8" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-pos" /> - <reference subregion="tower8" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-neg" /> - <reference subregion="tower9" /> - </region> - - <region> - <range field="section" value="Barrel" /> - <reference subregion="cylinder-pos" /> - <reference subregion="tower9" /> - </region> - - <region> - <range field="section" value="Extended-barrel" /> - <reference subregion="cylinder" /> - <reference subregion="tower10" /> - </region> - - <region> - <range field="section" value="Extended-barrel" /> - <reference subregion="cylinder" /> - <reference subregion="tower11" /> - </region> - - <region> - <range field="section" value="Extended-barrel" /> - <reference subregion="cylinder" /> - <reference subregion="tower12" /> - </region> - - <region> - <range field="section" value="Extended-barrel" /> - <reference subregion="cylinder" /> - <reference subregion="tower13" /> - </region> - - <region> - <range field="section" value="Extended-barrel" /> - <reference subregion="cylinder" /> - <reference subregion="tower14" /> - </region> - - <region> - <range field="section" value="Extended-barrel" /> - <reference subregion="cylinder" /> - <reference subregion="tower15" /> - </region> - - <region> - <range field="section" value="ITC-gap-scintillator" /> - <reference subregion="cylinder" /> - <reference subregion="D4" /> - </region> - - <region> - <range field="section" value="ITC-gap-scintillator" /> - <reference subregion="cylinder" /> - <reference subregion="C10" /> - </region> - - <region> - <range field="section" value="ITC-gap-scintillator" /> - <reference subregion="cylinder" /> - <reference subregion="E1" /> - </region> - - <region> - <range field="section" value="ITC-gap-scintillator" /> - <reference subregion="cylinder" /> - <reference subregion="E2" /> - </region> - - <region> - <range field="section" value="ITC-gap-scintillator" /> - <reference subregion="cylinder" /> - <reference subregion="E3" /> - </region> - - <region> - <range field="section" value="ITC-gap-scintillator" /> - <reference subregion="cylinder" /> - <reference subregion="E4" /> - </region> - - - <region> - <range field="section" value="Online" /> - <range field="ros" minvalue="1" maxvalue="4" /> - <range field="drawer" minvalue="0" maxvalue="63" /> - <range field="channel" minvalue="0" maxvalue="47" /> - <range field="gain" minvalue="0" maxvalue="1" /> - </region> - - <region> - <range field="section" value="Online" /> - <range field="ros" value="0" /> - <range field="drawer" values="0 1 2 3 4 5 6 7 8 9 10 11 16 17 18 19 20 21 22 255" /> - <range field="channel" minvalue="0" maxvalue="15" /> - <range field="gain" minvalue="0" maxvalue="0" /> - </region> - - <region> - <range field="section" value="Testbeam" /> - <range field="type" minvalue="-1" maxvalue="10" /> - <range field="tbmodule" minvalue="0" maxvalue="255" /> - <range field="tbchannel" minvalue="0" maxvalue="63" /> - <range field="tbdummy1" minvalue="0" maxvalue="15" /> - <range field="tbdummy2" minvalue="0" maxvalue="3" /> - <range field="tbdummy3" minvalue="0" maxvalue="3" /> - </region> - -</IdDictionary> diff --git a/graphics/AtlantisJava/img/atlantis_icon.gif b/graphics/AtlantisJava/img/atlantis_icon.gif deleted file mode 100755 index ea1ad1a27796918182df08347719cf5efdfb8723..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/atlantis_icon.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/atlantis_log.gif b/graphics/AtlantisJava/img/atlantis_log.gif deleted file mode 100755 index 7afe0dde1b99cc58b127f5ffb0c12f622a5f6326..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/atlantis_log.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/atlas.jpg b/graphics/AtlantisJava/img/atlas.jpg deleted file mode 100755 index fc381ca49e94fa5a0cfa5a3c64aa925e9239c761..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/atlas.jpg and /dev/null differ diff --git a/graphics/AtlantisJava/img/atlas_logo_big.png b/graphics/AtlantisJava/img/atlas_logo_big.png deleted file mode 100644 index b41fa2deb8cbd1f2cf2163c921f70966e684c3ba..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/atlas_logo_big.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_DnD_invalid_32x32.gif b/graphics/AtlantisJava/img/cursor_DnD_invalid_32x32.gif deleted file mode 100755 index 64c265d3e9f3f1d8e9486b0c6562beb6249452e5..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_DnD_invalid_32x32.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_DnD_invalid_64x64.gif b/graphics/AtlantisJava/img/cursor_DnD_invalid_64x64.gif deleted file mode 100755 index f0da1d0b3a4529cc22d74c22e7e9c64b174ab157..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_DnD_invalid_64x64.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_DnD_valid_32x32.gif b/graphics/AtlantisJava/img/cursor_DnD_valid_32x32.gif deleted file mode 100755 index a2d986bab98db68aec96f8a155c2bc7079ad7486..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_DnD_valid_32x32.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_DnD_valid_64x64.gif b/graphics/AtlantisJava/img/cursor_DnD_valid_64x64.gif deleted file mode 100755 index 167754d0f3c04bc1c9e24829957dd640c15b7a2f..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_DnD_valid_64x64.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_fisheye_32x32.gif b/graphics/AtlantisJava/img/cursor_fisheye_32x32.gif deleted file mode 100644 index 274cae270ef0f05f0ffe6e2c4bb40f2ab81d9121..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_fisheye_32x32.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_fisheye_64x64.gif b/graphics/AtlantisJava/img/cursor_fisheye_64x64.gif deleted file mode 100644 index bd9f9e8f6fe33b42f1bad61e8ae8f64970c5a51f..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_fisheye_64x64.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_fisheye_bw_32x32.gif b/graphics/AtlantisJava/img/cursor_fisheye_bw_32x32.gif deleted file mode 100644 index 31b8d566e033c12980fea7c35d4814ffc71832f3..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_fisheye_bw_32x32.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_fisheye_bw_64x64.gif b/graphics/AtlantisJava/img/cursor_fisheye_bw_64x64.gif deleted file mode 100644 index 817fee3d0bc475f0c82ed063cc40d8d994ff2b00..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_fisheye_bw_64x64.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_move_32x32.gif b/graphics/AtlantisJava/img/cursor_move_32x32.gif deleted file mode 100644 index fb4d30e49177e62158f4e654cc3d6ac44ca82995..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_move_32x32.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_move_64x64.gif b/graphics/AtlantisJava/img/cursor_move_64x64.gif deleted file mode 100644 index 1312c63e98e5b27e17c32c04111bbc8880568a17..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_move_64x64.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_pick_32x32.gif b/graphics/AtlantisJava/img/cursor_pick_32x32.gif deleted file mode 100644 index 381e8e27aeeebf84f1b6d6b308471777ca4917c4..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_pick_32x32.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_pick_64x64.gif b/graphics/AtlantisJava/img/cursor_pick_64x64.gif deleted file mode 100644 index 933ee9025e4ffa057890de5c5681cb3faa9e6ef8..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_pick_64x64.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_rectsel_32x32.gif b/graphics/AtlantisJava/img/cursor_rectsel_32x32.gif deleted file mode 100644 index 735e03ad7ed142cfc3c718381ecc73112c91a385..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_rectsel_32x32.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_rectsel_64x64.gif b/graphics/AtlantisJava/img/cursor_rectsel_64x64.gif deleted file mode 100644 index 6af540579930f5b3fe343ccb10159401343bf607..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_rectsel_64x64.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_rotate_32x32.gif b/graphics/AtlantisJava/img/cursor_rotate_32x32.gif deleted file mode 100644 index 61b6efdc627f8271344f4822dfbc560f0bdea2b9..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_rotate_32x32.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_rotate_64x64.gif b/graphics/AtlantisJava/img/cursor_rotate_64x64.gif deleted file mode 100644 index a376b6b532e11f4472aab2b577d2da106b4c0601..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_rotate_64x64.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_rotate_bw_32x32.gif b/graphics/AtlantisJava/img/cursor_rotate_bw_32x32.gif deleted file mode 100644 index 6833e4bb8a3619f0bb523896726efb0ed8713672..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_rotate_bw_32x32.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_rotate_bw_64x64.gif b/graphics/AtlantisJava/img/cursor_rotate_bw_64x64.gif deleted file mode 100644 index 5ba49f2c75c5ea37270b345b1bdb4505dea40816..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_rotate_bw_64x64.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_sync_32x32.gif b/graphics/AtlantisJava/img/cursor_sync_32x32.gif deleted file mode 100644 index c383ec1293a38aa62b98f1fb5095a73eceb8b700..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_sync_32x32.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_sync_64x64.gif b/graphics/AtlantisJava/img/cursor_sync_64x64.gif deleted file mode 100644 index 1853af35b54f06708257342985a282853ba158e1..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_sync_64x64.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_zoom_32x32.gif b/graphics/AtlantisJava/img/cursor_zoom_32x32.gif deleted file mode 100644 index 6880193d449f3c7f2e895ed742024d78d2bc460c..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_zoom_32x32.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_zoom_64x64.gif b/graphics/AtlantisJava/img/cursor_zoom_64x64.gif deleted file mode 100644 index 72d75f2a100a07b6a5173a1461dde5d071718b17..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_zoom_64x64.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_zoom_bw_32x32.gif b/graphics/AtlantisJava/img/cursor_zoom_bw_32x32.gif deleted file mode 100644 index 9e2afd655574cbbe2991ba2b52ca0e71a7ddff91..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_zoom_bw_32x32.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/cursor_zoom_bw_64x64.gif b/graphics/AtlantisJava/img/cursor_zoom_bw_64x64.gif deleted file mode 100644 index 2efd87e0d4d1a5f4cb08e46a16fe2bd9199564a2..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/cursor_zoom_bw_64x64.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/downarrow.png b/graphics/AtlantisJava/img/downarrow.png deleted file mode 100644 index 17b7273d22a682f1fe269ed260d78559fe342144..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/downarrow.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/interaction_clock.png b/graphics/AtlantisJava/img/interaction_clock.png deleted file mode 100644 index 0078909d9bd3ec15a13d2c8fe542faa1618e61d5..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/interaction_clock.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/interaction_fisheye.png b/graphics/AtlantisJava/img/interaction_fisheye.png deleted file mode 100644 index 6ddbd1b556a528d332b6e98e3272b4ed832b56d8..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/interaction_fisheye.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/interaction_pick.png b/graphics/AtlantisJava/img/interaction_pick.png deleted file mode 100644 index 5bb9411ccf89581a77f9a6a4ddec694bb70562c9..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/interaction_pick.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/interaction_rotate.png b/graphics/AtlantisJava/img/interaction_rotate.png deleted file mode 100644 index 511c2837239dc8849ab31e74e1a9a3178ad12a86..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/interaction_rotate.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/interaction_rubberband.png b/graphics/AtlantisJava/img/interaction_rubberband.png deleted file mode 100644 index c101f8ccd9fb2b067b6debd4d7bff251884d6dc0..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/interaction_rubberband.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/interaction_rubberbandyx.png b/graphics/AtlantisJava/img/interaction_rubberbandyx.png deleted file mode 100644 index eefdf1e4425d59f0b758beef4d94654db23d5f22..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/interaction_rubberbandyx.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/interaction_scale.png b/graphics/AtlantisJava/img/interaction_scale.png deleted file mode 100644 index 6a4699d2530b7a1ecc737e10e23055bd2be2e433..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/interaction_scale.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/interaction_skew.png b/graphics/AtlantisJava/img/interaction_skew.png deleted file mode 100644 index db0c357a0f7014f917abe4dd102b4fdedcc0b886..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/interaction_skew.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/interaction_synccursors.png b/graphics/AtlantisJava/img/interaction_synccursors.png deleted file mode 100644 index d19b2253e87ad4b95163fd50e26c924cd322f7c2..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/interaction_synccursors.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/interaction_zmr.png b/graphics/AtlantisJava/img/interaction_zmr.png deleted file mode 100644 index 06e95704d7442d5bdc2f7606e93ca4badc0bd7c0..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/interaction_zmr.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/interaction_zr.png b/graphics/AtlantisJava/img/interaction_zr.png deleted file mode 100644 index c6f46cc29f0c9381097e522bebaef22c65ce5b1e..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/interaction_zr.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/left.gif b/graphics/AtlantisJava/img/left.gif deleted file mode 100755 index 279e6710d4961d7644ea2e3e39e6afd300147aa8..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/left.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/minerva_log.gif b/graphics/AtlantisJava/img/minerva_log.gif deleted file mode 100644 index b7ba3677b6b3ad098bbbbf5c7b639d41de2aac10..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/minerva_log.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/mode_loop.png b/graphics/AtlantisJava/img/mode_loop.png deleted file mode 100644 index c4573849c5c3555e80b5f91df2659d592a11d9ba..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/mode_loop.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/mode_loop_on.png b/graphics/AtlantisJava/img/mode_loop_on.png deleted file mode 100644 index 1a6b5bed230293c52fa71d78d228a3a7fc2ac3e8..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/mode_loop_on.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/mode_random.png b/graphics/AtlantisJava/img/mode_random.png deleted file mode 100644 index d7861bd112a56079c81778995267ee6d15259878..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/mode_random.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/mode_random_on.png b/graphics/AtlantisJava/img/mode_random_on.png deleted file mode 100644 index 19c332640d439e2f44b055430f1326603626be51..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/mode_random_on.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/mode_sequential.png b/graphics/AtlantisJava/img/mode_sequential.png deleted file mode 100644 index e4c2d857205282a26b8e45ca5427cf8d14d47acb..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/mode_sequential.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/mode_sequential_on.png b/graphics/AtlantisJava/img/mode_sequential_on.png deleted file mode 100644 index c083bef019f8924502fcfff9cce53910dbcfb8b2..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/mode_sequential_on.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/right.gif b/graphics/AtlantisJava/img/right.gif deleted file mode 100755 index b256e5f75fb1f5467251abbf9442f338892e6ab5..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/right.gif and /dev/null differ diff --git a/graphics/AtlantisJava/img/toolbar_next.png b/graphics/AtlantisJava/img/toolbar_next.png deleted file mode 100755 index bd1b428684b001ef8ebe6fad7b5d10b3271953eb..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/toolbar_next.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/toolbar_open.png b/graphics/AtlantisJava/img/toolbar_open.png deleted file mode 100755 index c2d8efa7b0707f148900b981c51a5fc9adc92067..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/toolbar_open.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/toolbar_previous.png b/graphics/AtlantisJava/img/toolbar_previous.png deleted file mode 100755 index 940797b8a588cd4a74ce79ffd8c3957041c319e6..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/toolbar_previous.png and /dev/null differ diff --git a/graphics/AtlantisJava/img/uparrow.png b/graphics/AtlantisJava/img/uparrow.png deleted file mode 100644 index 339e331a52746b8c5d30b968cacbe4e6745576be..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/img/uparrow.png and /dev/null differ diff --git a/graphics/AtlantisJava/lib/Jama.jar b/graphics/AtlantisJava/lib/Jama.jar deleted file mode 100755 index 4c76beca1d5499cd3f996b3e3f30d77b02c7d319..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/Jama.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/batik-anim.jar b/graphics/AtlantisJava/lib/batik-anim.jar deleted file mode 100644 index 6913e421c916241b2c96081e5402191b6e18e1db..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/batik-anim.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/batik-ext.jar b/graphics/AtlantisJava/lib/batik-ext.jar deleted file mode 100644 index 8c904e1f2ab5de46eec36952299a181769e867c1..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/batik-ext.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/batik-extension.jar b/graphics/AtlantisJava/lib/batik-extension.jar deleted file mode 100644 index 106e4ac3cbd922d89f6b08087a30485ad0d2799b..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/batik-extension.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/batik-parser.jar b/graphics/AtlantisJava/lib/batik-parser.jar deleted file mode 100644 index 286b3799c3f922a0ddf66a99eec096f4ab01429b..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/batik-parser.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/batik-script.jar b/graphics/AtlantisJava/lib/batik-script.jar deleted file mode 100644 index 433f02e67c5561b54ae05161e9578cc6f474bbee..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/batik-script.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/batik-xml.jar b/graphics/AtlantisJava/lib/batik-xml.jar deleted file mode 100644 index d05eb25f7778d3463f07380cf5ec1df675d534bd..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/batik-xml.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/commons-cli-1.0.jar b/graphics/AtlantisJava/lib/commons-cli-1.0.jar deleted file mode 100755 index 22a004e14e16720cae9af97d4d1475b12d2388aa..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/commons-cli-1.0.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/commons-codec-1.4.jar b/graphics/AtlantisJava/lib/commons-codec-1.4.jar deleted file mode 100644 index 458d432da88b0efeab640c229903fb5aad274044..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/commons-codec-1.4.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/commons-logging-1.1.jar b/graphics/AtlantisJava/lib/commons-logging-1.1.jar deleted file mode 100644 index 2ff9bbd90d63f92cdffea944869ed9bea7ead49c..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/commons-logging-1.1.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/jas-aida-dev.jar b/graphics/AtlantisJava/lib/jas-aida-dev.jar deleted file mode 100755 index a698fcb714e42754a7e62a44c5934d5767d1aac4..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/jas-aida-dev.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/jas-aida.jar b/graphics/AtlantisJava/lib/jas-aida.jar deleted file mode 100755 index b539738f665293379179708c453af1b88deb7d95..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/jas-aida.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/jas-jel.jar b/graphics/AtlantisJava/lib/jas-jel.jar deleted file mode 100755 index 384f9eeb7a4e3652719925331a5f94fc0d1e0def..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/jas-jel.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/jlibeps.jar b/graphics/AtlantisJava/lib/jlibeps.jar deleted file mode 100644 index 6d049b27ce2c17e20455e390b0c554680c49808a..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/jlibeps.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/oncrpc.jar b/graphics/AtlantisJava/lib/oncrpc.jar deleted file mode 100644 index 3910ab9f555e0a3cf6f8bcc3d2ef7fbacc09e6e3..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/oncrpc.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/ostermillerutils_1_05_00.jar b/graphics/AtlantisJava/lib/ostermillerutils_1_05_00.jar deleted file mode 100644 index 79be1c0549dbce8d17fe99aa94815a442b81dc33..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/ostermillerutils_1_05_00.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/test/fest-assert-1.2.jar b/graphics/AtlantisJava/lib/test/fest-assert-1.2.jar deleted file mode 100644 index dcd667e53566009670eb087365eb064727f1525a..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/test/fest-assert-1.2.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/test/fest-reflect-1.2.jar b/graphics/AtlantisJava/lib/test/fest-reflect-1.2.jar deleted file mode 100644 index d33ddb65349ebd5b6ee159a2cf7d569bf7f5d4ef..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/test/fest-reflect-1.2.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/test/fest-util-1.1.2.jar b/graphics/AtlantisJava/lib/test/fest-util-1.1.2.jar deleted file mode 100644 index c5f608bfabb4b04653c0c6384e9a4ad28aba2d08..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/test/fest-util-1.1.2.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/test/jcip-annotations-1.0.jar b/graphics/AtlantisJava/lib/test/jcip-annotations-1.0.jar deleted file mode 100644 index 9ca41331f9d84cd668a8620850fdc5b1724a10b8..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/test/jcip-annotations-1.0.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/ws-commons-util-1.0.2.jar b/graphics/AtlantisJava/lib/ws-commons-util-1.0.2.jar deleted file mode 100644 index 3fc364e7f605b580850530c281998a1f861cc0c5..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/ws-commons-util-1.0.2.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/xml-apis-ext.jar b/graphics/AtlantisJava/lib/xml-apis-ext.jar deleted file mode 100644 index a7869d68aacd655c782bb373c7334e5ff667ca58..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/xml-apis-ext.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/xmlrpc-client-3.1.jar b/graphics/AtlantisJava/lib/xmlrpc-client-3.1.jar deleted file mode 100644 index a76e6ec96dd62265a199eb3ab72c54b7ebb99368..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/xmlrpc-client-3.1.jar and /dev/null differ diff --git a/graphics/AtlantisJava/lib/xmlrpc-server-3.1.jar b/graphics/AtlantisJava/lib/xmlrpc-server-3.1.jar deleted file mode 100644 index bb64a504ee8997cca1f08ae0814b6cdf90d0cdbb..0000000000000000000000000000000000000000 Binary files a/graphics/AtlantisJava/lib/xmlrpc-server-3.1.jar and /dev/null differ diff --git a/graphics/AtlantisJava/share/InteractiveServer.py b/graphics/AtlantisJava/share/InteractiveServer.py deleted file mode 100755 index 1b1adeb2a9cda9b8cf2de0d12915fa7fb67e5dd3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/share/InteractiveServer.py +++ /dev/null @@ -1,483 +0,0 @@ -#!/usr/bin/env python - -# InteractiveServer.py -# -# author: Zdenek Maxa, UCL HEP group (zdenek.maxa --at-- hep.ucl.ac.uk) -# -# CVS location: offline/graphics/AtlantisJava/share/InteractiveServer.py -# -# Interface between the Athena Python interactive prompt and the Atlantis -# event display. This server script takes over the interactive prompt of -# Athena. The Atlantis user can then type Athena commands directly in the -# Atlantis dialog from where they are sent to Athena through this server. -# Commands: e.g. changing/querying job options and executing .initialize(), -# .execute() and .finalize() methods of algorithms, etc. -# -# -# setting up Atlantis - Interactive Athena: -# 0) get_files InteractiveServer.py [from 'run' directory] -# 1) athena -i <job_options.py> [launch Athena in the interactive mode] -# 2) theApp.initialize() -# 3) execfile ("InteractiveServer.py") -# 4) if the server started successfully an info message is printed and -# denoted string has to be copied into the Atlantis Interactive Athena -# dialog (Atlantis menu: File -> Interactive Athena) -# -# Once the InteractiveServer is started, the Athena prompt is taken over -# by the server and the user can no longer access it. The server can be -# shut down by Ctrl+C after which the interactive prompt should be given -# back to the user. -# -# -# setting up for Athenaeum: -# argumentInteractiveServerNoAlgTools = True -# argumentInteractiveServerServerPort = 2323 -# argumentInteractiveServerServerKey = "someKey" -# execfile ("InteractiveServer.py") - -# Multithreaded version, modification made by Julius.Hrivnac -- at -- cern.ch -# Athenaeum commands can be executed in several parallel threads. -# Unlike in the single-thread version, all stdout and stderr output -# goes into system streams, so into the server log file. The result -# of the "remote script" should be put into answer array so that -# they are given to the client. - - -# --------------------------------------------------------------------------- - -import os, sys, math, traceback, random, time, StringIO, getopt, md5, base64 -import SocketServer -from SimpleXMLRPCServer import SimpleXMLRPCServer,SimpleXMLRPCRequestHandler -import cppyy - -class AsyncXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer): pass - -# --------------------------------------------------------------------------- -class InteractiveServer: - """ """ - - # <configuration attributes --------> - debug = False # debug messages to print (False / True) - keyLength = 15 - minCharValue = 33 # ascii table range (generating key) - maxCharValue = 126 # ascii table range (generating key) - minPortNumber = 2000 - maxPortNumber = 20000 - maxAttempts = 5 # number of attempts when creating the server - resultLengthLimit = 400 - # </configuration attributes --------> - - # other attributes - serverName = "" - serverPort = 0 - key = "" - server = None # XMLRPC server instance - - vxTool = None # access to vertexing tool (Athena AlgTool) - visTool = None # access to JiveXML (EventData2XML) (Athena AlgTool) - - keyForbiddenChars = ("'", '"', ':') - noAlgTools = False # if False, AlgTools will be initialised - - # answer in a multhreaded invironment are passed in the global array - global answer - answer = {} - - # ----------------------------------------------------------------------- - def __init__(self, noAlgTools = False, serverPort = 0, key = ""): - """ """ - - self.serverName = os.uname()[1] - self.noAlgTools = noAlgTools - self.serverPort = serverPort - self.key = key - SocketServer.ThreadingTCPServer.daemon_threads = True - - # __init__() ------------------------------------------------------------ - - - # ----------------------------------------------------------------------- - def makeServer(self): - """ """ - - try: - SimpleXMLRPCServer.allow_reuse_address = 1 - self.server = AsyncXMLRPCServer((self.serverName, self.serverPort), SimpleXMLRPCRequestHandler) - - except Exception, why: - print "\n%s\nCould not create the server on '%s' port: " \ - "'%s'" % (why, self.serverName, self.serverPort) - if self.debug: - trace = traceback.format_exception(*sys.exc_info()) - traceString = '\n '.join(trace) - errorMsg = "ERROR:\n%s\n" % (traceString) - print errorMsg - raise - else: - print "XMLRPC server created" - - # makeServer() ---------------------------------------------------------- - - - # ----------------------------------------------------------------------- - def generatePortAndMakeServer(self): - """ """ - - alreadyTriedPorts = [] # already tried port numbers - - for i in range(self.maxAttempts): - while 1: - self.serverPort = random.randint(self.minPortNumber, - self.maxPortNumber) - if self.serverPort not in alreadyTriedPorts: - break - alreadyTriedPorts.append(self.serverPort) - - try: - self.makeServer() - except: - continue - else: - break - else: - # for loop iterated through exhaustion of the list and wasn't - # terminated by the break, so the server wasn't created, notify - # the caller by raising an exception - raise - - # generatePortAndMakeServer() ------------------------------------------- - - - # ----------------------------------------------------------------------- - def registerMethod(self, name): - """ """ - - methodName = name.__name__ - try: - self.server.register_function(name) - except Exception, why: - print "%s\nCould not register method (%s)" % (why, methodName) - raise - else: - if self.debug: - print "method '%s()' registered" % methodName - - # registerMethod() ------------------------------------------------------ - - - # ----------------------------------------------------------------------- - def runServer(self): - """ """ - # this will probably have to be in a thread if the interactive - # prompt is to remain at the user's disposal - - print "Waiting for requests..." - try: - self.server.serve_forever() - except KeyboardInterrupt: - try: - print "Stopped from keyboard, exit" - print "Closing InteractiveServer:", - self.server.server_close() - except: - print "can't close the server" - else: - print "server closed" - except Exception, why: - print "%s\nException occured" % why - raise - - # runServer() ----------------------------------------------------------- - - - # ----------------------------------------------------------------------- - def execute(self, param = "<empty>"): - - print "execute(param = '%s')" % param - resultMsg = "SUCCESS" - - try: - exec param - except Exception, why: - trace = traceback.format_exception(*sys.exc_info()) - traceString = '\n '.join(trace) - resultMsg = "ERROR:\n%s\n%s\n" % (traceString, why) - print resultMsg - - return str(resultMsg) - - # execute() ------------------------------------------------------------- - - - # ----------------------------------------------------------------------- - def get(self, name = "<empty>"): - """ """ - - print "get(name = '%s')" % name - resultMsg = "SUCCESS" - - try: - result = eval(name) - except Exception, why: - trace = traceback.format_exception(*sys.exc_info()) - traceString = '\n '.join(trace) - resultMsg = "ERROR:\n%s\n%s\n" % (traceString, why) - print resultMsg - return str(resultMsg) - else: - return str(result) - - # get() ----------------------------------------------------------------- - - - - # ----------------------------------------------------------------------- - def callVertexFit(self, tracksId): - """Track IDs (tracksId array) are passed to vertex fit algtool""" - - print "callVertexFit(tracksId = '%s')" % tracksId - - cppyy.loadDictionary('SealSTLDict') - - g.std.vector(int) - vi = g.std.vector(int)(0) - - for i in tracksId: - vi.push_back(i) - - print " calling vertexing tool: vxTool.fitAtlantisTracks(",vi,")" - - r = self.vxTool.fitAtlantisTracks(vi) - if r: - resultMsg = "SUCCESS (get updated event data)" - else: - resultMsg = "ERROR while calling vertexing tool" - - return resultMsg - - # callVertexFit() ------------------------------------------------------- - - - # ----------------------------------------------------------------------- - def executeScript(self, param = "<empty>", pid = ""): - """Execute Python code snippets from Athenaeum plugin""" - - errorMsg = "SUCCESS" - resultMsg = "" - - try: - exec param - global answer - try: - resultMsg = answer[pid] - del answer[pid] - except: - resultMsg = "No resultMsg" - except Exception, why: - trace = traceback.format_exception(*sys.exc_info()) - traceString = '\n '.join(trace) - errorMsg = "ERROR:\n%s\n%s\n" % (traceString, why) - - return resultMsg + "\n" + str(errorMsg) - - # executeScript() ------------------------------------------------------- - - - # ----------------------------------------------------------------------- - # the only method which is exposed (registred) for remote calling - def process(self, digest = "", request = "<empty>", tracksId = ''): - """ """ - - print "\n\n<incoming request> " + 50 * '-' - if self.debug: - print "process(request = '%s', tracksId = '%s')" % (request, - tracksId) - result = "<empty_result>" - - # generate message digest and compare - md5My = md5.new() - md5My.update(request) - md5My.update(self.key) - myDigest = md5My.digest() - # received digest is BAE64 encoded, so encode mine as well - myDigest = base64.encodestring(myDigest)[:-1] # without list '\n' - - if digest == myDigest: - # determine the nature of the request - # request 'runVertexFit' -> pass tracksId to the algorithm - if str(request) == "runVertexFit": - result = self.callVertexFit(tracksId) - - # request to process Python code snippet (e.g. from Athenaeum) - # multiline request - # tracksId is the client identifier - elif len(str(request).split('\n')) > 1: - result = self.executeScript(request, tracksId) - - # get event data from JiveXML - elif str(request) == "eventData": - self.visTool.execute() - result = self.visTool.getXML() - - # two last characters must be '()' if it's a method to execute - elif request[-2:] == "()": - result = self.execute(request) - - # if the request contains '=' - it's an assignment to execute - elif request.find('=') > -1: - result = self.execute(request) - - # it's likely name of a variable to evaluate (or wrong request) - else: - result = self.get(request) - else: - result = "Request not processed, keys (digests) don't match" - - - # don't print out result messages longer than resultLengthLimit chars - # in such a case print just the beginning and the end of the message - limit = self.resultLengthLimit - print "result to send:" - if len(result) < limit: - print "%s" % result - else: - print "%s" % result[:limit/2] - print "\n+++ %s other characters +++\n" % (len(result) - limit) - print "%s" % result[-limit/2:] - - print "</incoming request> " + 50 * '-' - return result - - # process() ------------------------------------------------------------- - - - # ----------------------------------------------------------------------- - def generateKey(self): - """ """ - - # generate keyLength characters long key - random.seed() - while len(self.key) < self.keyLength: - k = str(chr(random.randint(self.minCharValue, self.maxCharValue))) - if k in self.keyForbiddenChars: - continue - self.key += k - - # generateKey() --------------------------------------------------------- - - # ----------------------------------------------------------------------- - def printInfo(self): - """ """ - - print "String between the quotation marks to copy & paste", - print "into the dialog:" - print "\t '%s:%s:%s'" % (self.serverName, self.serverPort, self.key) - - # printInfo() ----------------------------------------------------------- - - - # ----------------------------------------------------------------------- - def createAlgTools(self): - - print "Getting vertexing AlgTool (ToolSvc.VxWrapperTool)" - # self.vxTool = \ - # theApp.toolsvc().retrieve('ToolSvc.VxWrapperTool')._itool - self.vxTool = \ - theApp.toolsvc().create('VxWrapperTool','VxWrapperTool', - cppyy.Pointer(g.IInterface)(0))._itool - - print "Getting JiveXML AlgTool (ToolSvc.EventData2XML)" - # self.visTool = \ - # theApp.toolsvc().retrieve('ToolSvc.EventData2XML')._itool - self.visTool = \ - theApp.toolsvc().create('EventData2XML','EventData2XML', - cppyy.Pointer(g.IInterface)(0))._itool - - # createAlgTools() ------------------------------------------------------ - - - # ----------------------------------------------------------------------- - def start(self): - """ """ - - print "Starting Multithreaded InteractiveServer:", - try: - # generate key if it wasn't specified as a command line option - if self.key == "": - self.generateKey() - - # choose random port before creating the server if the port number - # wasn't specified as a command line option - if self.serverPort == 0: - self.generatePortAndMakeServer() - else: - self.makeServer() - - self.registerMethod(self.process) - # self.server.register_introspection_functions() # what for? - - # don't initialise algtools if --no_algtools command line argument - if self.noAlgTools == False: - self.createAlgTools() - - self.printInfo() - self.runServer() - except Exception, why: - print "Exception occured." - print "Reason: %s" % why - - # start() --------------------------------------------------------------- - - -# class InteractiveServer =================================================== - - -# --------------------------------------------------------------------------- -def getArguments(): - """Reading arguments when executing by execfile()""" - - # default values - noAlgTools = False - serverPort = 0 - serverKey = "" - - if globals().has_key("argumentInteractiveServerNoAlgTools"): - if argumentInteractiveServerNoAlgTools: - noAlgTools = True - - if globals().has_key("argumentInteractiveServerServerPort"): - port = argumentInteractiveServerServerPort - try: - serverPort = int(port) - except ValueError: - msg = "Incorrectly specified port number: %s" % port - raise Exception(msg) - - if globals().has_key("argumentInteractiveServerServerKey"): - serverKey = argumentInteractiveServerServerKey - - return (noAlgTools, serverPort, serverKey) - -# getArguments() ------------------------------------------------------------ - - -# --------------------------------------------------------------------------- -def main(): - - try: - (noAlgTools, serverPort, key) = getArguments() - except Exception, why: - print "Exception occured while reading variable arguments, exit" - print "Reason: %s" % why - return - - server = InteractiveServer(noAlgTools, serverPort, key) - server.start() - -# main() -------------------------------------------------------------------- - - -# --------------------------------------------------------------------------- -if __name__ == "__main__": - main() -# --------------------------------------------------------------------------- diff --git a/graphics/AtlantisJava/share/MINERVA.jnlp b/graphics/AtlantisJava/share/MINERVA.jnlp deleted file mode 100644 index f3e3897fe74fe40a8cbb6ad812370fc91b5bb1c9..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/share/MINERVA.jnlp +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- JNLP webstart file for Atlantis event display for ATLAS --> -<!-- MINERVA version --> -<jnlp - spec="1.0+" - codebase="@CODEBASE@" - href="MINERVA.jnlp"> - <information> - <title>Atlantis event display for ATLAS</title> - <vendor>Atlantis team</vendor> - <homepage href=""/> <!-- should be used from codebase --> - <description>Atlantis event display for ATLAS</description> - <!-- <icon href="files/goofy_favicon.ico"/> - <icon kind="splash" href="files/logo.gif"/> --> - <offline-allowed/> - <shortcut online="false"> - <desktop/> - <menu submenu="Atlantis event display"/> - </shortcut> - </information> - <security> - <all-permissions/> - </security> - <resources> - <j2se version="1.6+" max-heap-size="512m"/> - - <jar href="lib/commons-cli-1.0.jar"/> - <jar href="lib/Jama.jar"/> - <jar href="lib/jas-aida-dev.jar"/> - <jar href="lib/jas-aida.jar"/> - <jar href="lib/jas-freehep-base.jar"/> - <jar href="lib/jas-freehep-hep.jar"/> - <jar href="lib/jas-jas-plotter.jar"/> - <jar href="lib/jas-jel.jar"/> - <jar href="lib/jas-JMinuit.jar"/> - <jar href="lib/jogl.jar"/> - <jar href="lib/jh.jar"/> - <jar href="lib/oncrpc.jar"/> - <jar href="lib/log4j-1.2.15.jar"/> - <jar href="lib/ostermillerutils_1_05_00.jar"/> - <jar href="lib/wired-base-4.0.beta.3-SNAPSHOT.jar"/> - <jar href="lib/ws-commons-util-1.0.2.jar"/> - <jar href="lib/xercesImpl.jar"/> - <jar href="lib/xml-apis.jar"/> - <jar href="lib/xmlrpc-client-3.1.jar"/> - <jar href="lib/xmlrpc-common-3.1.jar"/> - <jar href="lib/jlibeps.jar"/> - <jar href="lib/xmlrpc-server-3.1.jar"/> - <jar href="lib/commons-logging-1.1.jar"/> - <jar href="lib/commons-codec-1.4.jar"/> - <jar href="lib/xml-apis-ext.jar"/> - <jar href="lib/batik-dom.jar"/> - <jar href="lib/batik-anim.jar"/> - <jar href="lib/batik-svggen.jar"/> - <jar href="lib/batik-css.jar"/> - <jar href="lib/batik-bridge.jar"/> - <jar href="lib/batik-parser.jar"/> - <jar href="lib/batik-xml.jar"/> - <jar href="lib/batik-gui-util.jar"/> - <jar href="lib/batik-script.jar"/> - <jar href="lib/batik-transcoder.jar"/> - <jar href="lib/batik-svg-dom.jar"/> - <jar href="lib/batik-extension.jar"/> - <jar href="lib/batik-codec.jar"/> - <jar href="lib/batik-util.jar"/> - <jar href="lib/batik-swing.jar"/> - <jar href="lib/batik-ext.jar"/> - <jar href="lib/batik-gvt.jar"/> - <jar href="lib/batik-awt-util.jar"/> - <jar href="help/help.jar"/> - - <jar href="atlantis.jar" main="true"/> <!-- look for main class here --> - </resources> - - <application-desc main-class="atlantis.Atlantis"> - <argument>--config</argument> - <argument>configuration/config-MINERVA.xml</argument> - <argument>--debug</argument> - <argument>DEBUG</argument> - <argument>--source</argument> - <argument>http://www.cern.ch/atlas-minerva/MINERVA_tutorial_events.zip</argument> - </application-desc> - -</jnlp> diff --git a/graphics/AtlantisJava/share/atlantis b/graphics/AtlantisJava/share/atlantis deleted file mode 100755 index d9e99ce0a1c3f5931f2891874270afe4f0978d17..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/share/atlantis +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# running Atlantis in the Athena environment - -# Check JRE version. Workaround because "java -version:1.6+" does not work on lxplus -JAVAVERSION=`java -version 2>&1 | grep "java version" | awk '{print $3}' | tr -d \" | awk '{split($0, array, ".")} END{print array[2]}'` -if [[ $JAVAVERSION -lt 6 ]]; then - echo "Atlantis required Java version 1.6 or greater" - exit 1 -fi - -ATLANTISJAVA_HOME=`dirname $0`/../AtlantisJava -java -Xms128m -Xmx1024m -jar $ATLANTISJAVA_HOME/atlantis.jar $* diff --git a/graphics/AtlantisJava/share/atlantis.jnlp b/graphics/AtlantisJava/share/atlantis.jnlp deleted file mode 100644 index 39612b50c59d7fd86926ee348439d76f3235db26..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/share/atlantis.jnlp +++ /dev/null @@ -1,81 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- JNLP webstart file for Atlantis event display for ATLAS --> -<jnlp - spec="1.0+" - codebase="@CODEBASE@" - href="atlantis.jnlp"> - <information> - <title>Atlantis event display for ATLAS</title> - <vendor>Atlantis team</vendor> - <homepage href=""/> <!-- should be used from codebase --> - <description>Atlantis event display for ATLAS</description> - <!-- <icon href="files/goofy_favicon.ico"/> - <icon kind="splash" href="files/logo.gif"/> --> - <offline-allowed/> - <shortcut online="false"> - <desktop/> - <menu submenu="Atlantis event display"/> - </shortcut> - </information> - <security> - <all-permissions/> - </security> - <resources> - <j2se version="1.6+" max-heap-size="512m"/> - - <jar href="lib/commons-cli-1.0.jar"/> - <jar href="lib/Jama.jar"/> - <jar href="lib/jas-aida-dev.jar"/> - <jar href="lib/jas-aida.jar"/> - <jar href="lib/jas-freehep-base.jar"/> - <jar href="lib/jas-freehep-hep.jar"/> - <jar href="lib/jas-jas-plotter.jar"/> - <jar href="lib/jas-jel.jar"/> - <jar href="lib/jas-JMinuit.jar"/> - <jar href="lib/jogl.jar"/> - <jar href="lib/jh.jar"/> - <jar href="lib/oncrpc.jar"/> - <jar href="lib/log4j-1.2.15.jar"/> - <jar href="lib/ostermillerutils_1_05_00.jar"/> - <jar href="lib/wired-base-4.0.beta.3-SNAPSHOT.jar"/> - <jar href="lib/ws-commons-util-1.0.2.jar"/> - <jar href="lib/xercesImpl.jar"/> - <jar href="lib/xml-apis.jar"/> - <jar href="lib/xmlrpc-client-3.1.jar"/> - <jar href="lib/xmlrpc-common-3.1.jar"/> - <jar href="lib/jlibeps.jar"/> - <jar href="lib/xmlrpc-server-3.1.jar"/> - <jar href="lib/commons-logging-1.1.jar"/> - <jar href="lib/commons-codec-1.4.jar"/> - <jar href="lib/xml-apis-ext.jar"/> - <jar href="lib/batik-dom.jar"/> - <jar href="lib/batik-anim.jar"/> - <jar href="lib/batik-svggen.jar"/> - <jar href="lib/batik-css.jar"/> - <jar href="lib/batik-bridge.jar"/> - <jar href="lib/batik-parser.jar"/> - <jar href="lib/batik-xml.jar"/> - <jar href="lib/batik-gui-util.jar"/> - <jar href="lib/batik-script.jar"/> - <jar href="lib/batik-transcoder.jar"/> - <jar href="lib/batik-svg-dom.jar"/> - <jar href="lib/batik-extension.jar"/> - <jar href="lib/batik-codec.jar"/> - <jar href="lib/batik-util.jar"/> - <jar href="lib/batik-swing.jar"/> - <jar href="lib/batik-ext.jar"/> - <jar href="lib/batik-gvt.jar"/> - <jar href="lib/batik-awt-util.jar"/> - - <jar href="help/help.jar"/> - - <jar href="atlantis.jar" main="true"/> <!-- look for main class here --> - </resources> - - <application-desc main-class="atlantis.Atlantis"> - <argument>--debug</argument> - <argument>DEBUG</argument> - </application-desc> - -</jnlp> - diff --git a/graphics/AtlantisJava/share/atlantis_online b/graphics/AtlantisJava/share/atlantis_online deleted file mode 100755 index 1d9cace7cfa0cddb791ac5e5592237ef9a0a2ec9..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/share/atlantis_online +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# running Atlantis in the TDAQ online environment -# This requires the TDAQ_JAVA_HOME to be defined in the enviroment - -JAVA=$TDAQ_JAVA_HOME/bin/java - -# Check JRE version. Workaround because "java -version:1.6+" does not work on lxplus -JAVAVERSION=`$JAVA -version 2>&1 | grep "java version" | awk '{print $3}' | tr -d \" | awk '{split($0, array, ".")} END{print array[2]}'` -if [[ $JAVAVERSION -lt 6 ]]; then - echo "Atlantis required Java version 1.6 or greater" - exit 1 -fi - -exec $JAVA -Xms128m -Xmx1024m -jar $EVENTDISPLAY_SW_INST_PATH/share/AtlantisJava/atlantis.jar $* diff --git a/graphics/AtlantisJava/share/ntupleXML.h b/graphics/AtlantisJava/share/ntupleXML.h deleted file mode 100644 index c1282f14004b8db1647ea47e58a02576c4f43358..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/share/ntupleXML.h +++ /dev/null @@ -1,1351 +0,0 @@ -//ntupleXML v1.0 - Tim Martin - Aug 07 - tamartin@cern.ch -//Classes TopViewXML and EventViewXML to output ntuple -//events to a Atlantis readable xml file - -#include "TXMLEngine.h" -#include <TChain.h> -#include <TFriendElement.h> -#include <TFile.h> - -#include <iostream> -#include <string> -#include <sstream> -#include <vector> -#include <iomanip> - -//Main class, TopView and EventView classes inherit from this -class ntupleXML { - protected: - std::string dataTypeCon, etaCon, labelCon, pdgIdCon, phiCon, ptCon, typeEVCon, mainTreeName; - Bool_t FR_Active, TR_Active, FRA_Active, TRA_Active, TA_Active, isTopView; - Int_t nParticles, Warn, truthPref, Append; - TChain* activeFile; - vector<TChain*> fileStore; - TTree* activeTree; - TFriendElement* friendTree; - TXMLEngine* TVXMLEng; - XMLNodePointer_t event; - Int_t FR_eventNumber; - Int_t FR_runNumber; - Double_t FR_MET_Final_ex; - Double_t FR_MET_Final_ey; - Double_t FR_MET_Final_et; - Double_t TR_MET_Truth_ex; - Double_t TR_MET_Truth_ey; - Double_t TR_MET_Truth_et; - Int_t FR_El_N; - vector<double>* FR_El_pdgId; - vector<double>* FR_El_p_T; - vector<double>* FR_El_phi; - vector<double>* FR_El_eta; - Int_t FR_Mu_N; - vector<double>* FR_Mu_pdgId; - vector<double>* FR_Mu_p_T; - vector<double>* FR_Mu_phi; - vector<double>* FR_Mu_eta; - Int_t FR_Tau_N; - vector<double>* FR_Tau_pdgId; - vector<double>* FR_Tau_p_T; - vector<double>* FR_Tau_phi; - vector<double>* FR_Tau_eta; - Int_t FR_Ph_N; - vector<double>* FR_Ph_pdgId; - vector<double>* FR_Ph_p_T; - vector<double>* FR_Ph_phi; - vector<double>* FR_Ph_eta; - Int_t FR_PJet_N; - vector<double>* FR_PJet_pdgId; - vector<double>* FR_PJet_p_T; - vector<double>* FR_PJet_phi; - vector<double>* FR_PJet_eta; - vector<int>* FR_PJet_BTagged; - Int_t FRA_El_N; - vector<double>* FRA_El_pdgId; - vector<double>* FRA_El_p_T; - vector<double>* FRA_El_phi; - vector<double>* FRA_El_eta; - Int_t FRA_Mu_N; - vector<double>* FRA_Mu_pdgId; - vector<double>* FRA_Mu_p_T; - vector<double>* FRA_Mu_phi; - vector<double>* FRA_Mu_eta; - Int_t FRA_Nu_N; - vector<double>* FRA_Nu_pdgId; - vector<double>* FRA_Nu_p_T; - vector<double>* FRA_Nu_phi; - vector<double>* FRA_Nu_eta; - Int_t FRA_HadW_N; - vector<double>* FRA_HadW_pdgId; - vector<double>* FRA_HadW_p_T; - vector<double>* FRA_HadW_phi; - vector<double>* FRA_HadW_eta; - Int_t FRA_LepW_N; - vector<double>* FRA_LepW_pdgId; - vector<double>* FRA_LepW_p_T; - vector<double>* FRA_LepW_phi; - vector<double>* FRA_LepW_eta; - Int_t FRA_HadTop_N; - vector<double>* FRA_HadTop_pdgId; - vector<double>* FRA_HadTop_p_T; - vector<double>* FRA_HadTop_phi; - vector<double>* FRA_HadTop_eta; - Int_t FRA_LepTop_N; - vector<double>* FRA_LepTop_pdgId; - vector<double>* FRA_LepTop_p_T; - vector<double>* FRA_LepTop_phi; - vector<double>* FRA_LepTop_eta; - Int_t FRA_Lepb_N; - vector<double>* FRA_Lepb_pdgId; - vector<double>* FRA_Lepb_p_T; - vector<double>* FRA_Lepb_phi; - vector<double>* FRA_Lepb_eta; - Int_t FRA_Hadb_N; - vector<double>* FRA_Hadb_pdgId; - vector<double>* FRA_Hadb_p_T; - vector<double>* FRA_Hadb_phi; - vector<double>* FRA_Hadb_eta; - Int_t FRA_Hadj_N; - vector<double>* FRA_Hadj_pdgId; - vector<double>* FRA_Hadj_p_T; - vector<double>* FRA_Hadj_phi; - vector<double>* FRA_Hadj_eta; - Int_t TRA_El_N; - vector<double>* TRA_El_pdgId; - vector<double>* TRA_El_p_T; - vector<double>* TRA_El_phi; - vector<double>* TRA_El_eta; - Int_t TRA_Mu_N; - vector<double>* TRA_Mu_pdgId; - vector<double>* TRA_Mu_p_T; - vector<double>* TRA_Mu_phi; - vector<double>* TRA_Mu_eta; - Int_t TRA_Tau_N; - vector<double>* TRA_Tau_pdgId; - vector<double>* TRA_Tau_p_T; - vector<double>* TRA_Tau_phi; - vector<double>* TRA_Tau_eta; - Int_t TRA_HadW_N; - vector<double>* TRA_HadW_pdgId; - vector<double>* TRA_HadW_p_T; - vector<double>* TRA_HadW_phi; - vector<double>* TRA_HadW_eta; - Int_t TRA_LepW_N; - vector<double>* TRA_LepW_pdgId; - vector<double>* TRA_LepW_p_T; - vector<double>* TRA_LepW_phi; - vector<double>* TRA_LepW_eta; - Int_t TRA_HadTop_N; - vector<double>* TRA_HadTop_pdgId; - vector<double>* TRA_HadTop_p_T; - vector<double>* TRA_HadTop_phi; - vector<double>* TRA_HadTop_eta; - Int_t TRA_LepTop_N; - vector<double>* TRA_LepTop_pdgId; - vector<double>* TRA_LepTop_p_T; - vector<double>* TRA_LepTop_phi; - vector<double>* TRA_LepTop_eta; - Int_t TRA_Bot_N; - vector<double>* TRA_Bot_pdgId; - vector<double>* TRA_Bot_p_T; - vector<double>* TRA_Bot_phi; - vector<double>* TRA_Bot_eta; - Int_t TRA_LQ_N; - vector<double>* TRA_LQ_pdgId; - vector<double>* TRA_LQ_p_T; - vector<double>* TRA_LQ_phi; - vector<double>* TRA_LQ_eta; - vector<double>* TA_Tru_p_T; - vector<double>* TA_Tru_phi; - vector<double>* TA_Tru_eta; - vector<double>* TA_Tru_pdgId; - vector<int>* TA_Tru_barcode; - TBranch* b_FR_eventNumber; - TBranch* b_FR_runNumber; - TBranch* b_FR_MET_Final_ex; - TBranch* b_FR_MET_Final_ey; - TBranch* b_FR_MET_Final_et; - TBranch* b_TR_MET_Truth_ex; - TBranch* b_TR_MET_Truth_ey; - TBranch* b_TR_MET_Truth_et; - TBranch* b_FR_El_N; - TBranch* b_FR_El_pdgId; - TBranch* b_FR_El_p_T; - TBranch* b_FR_El_phi; - TBranch* b_FR_El_eta; - TBranch* b_FR_Mu_N; - TBranch* b_FR_Mu_pdgId; - TBranch* b_FR_Mu_p_T; - TBranch* b_FR_Mu_phi; - TBranch* b_FR_Mu_eta; - TBranch* b_FR_Tau_N; - TBranch* b_FR_Tau_pdgId; - TBranch* b_FR_Tau_p_T; - TBranch* b_FR_Tau_phi; - TBranch* b_FR_Tau_eta; - TBranch* b_FR_Ph_N; - TBranch* b_FR_Ph_pdgId; - TBranch* b_FR_Ph_p_T; - TBranch* b_FR_Ph_phi; - TBranch* b_FR_Ph_eta; - TBranch* b_FR_PJet_N; - TBranch* b_FR_PJet_pdgId; - TBranch* b_FR_PJet_p_T; - TBranch* b_FR_PJet_phi; - TBranch* b_FR_PJet_eta; - TBranch* b_FR_PJet_BTagged; - TBranch* b_FRA_El_N; - TBranch* b_FRA_El_pdgId; - TBranch* b_FRA_El_p_T; - TBranch* b_FRA_El_phi; - TBranch* b_FRA_El_eta; - TBranch* b_FRA_Mu_N; - TBranch* b_FRA_Mu_pdgId; - TBranch* b_FRA_Mu_p_T; - TBranch* b_FRA_Mu_phi; - TBranch* b_FRA_Mu_eta; - TBranch* b_FRA_Nu_N; - TBranch* b_FRA_Nu_pdgId; - TBranch* b_FRA_Nu_p_T; - TBranch* b_FRA_Nu_phi; - TBranch* b_FRA_Nu_eta; - TBranch* b_FRA_HadW_N; - TBranch* b_FRA_HadW_pdgId; - TBranch* b_FRA_HadW_p_T; - TBranch* b_FRA_HadW_phi; - TBranch* b_FRA_HadW_eta; - TBranch* b_FRA_LepW_N; - TBranch* b_FRA_LepW_pdgId; - TBranch* b_FRA_LepW_p_T; - TBranch* b_FRA_LepW_phi; - TBranch* b_FRA_LepW_eta; - TBranch* b_FRA_HadTop_N; - TBranch* b_FRA_HadTop_pdgId; - TBranch* b_FRA_HadTop_p_T; - TBranch* b_FRA_HadTop_phi; - TBranch* b_FRA_HadTop_eta; - TBranch* b_FRA_LepTop_N; - TBranch* b_FRA_LepTop_pdgId; - TBranch* b_FRA_LepTop_p_T; - TBranch* b_FRA_LepTop_phi; - TBranch* b_FRA_LepTop_eta; - TBranch* b_FRA_Lepb_N; - TBranch* b_FRA_Lepb_pdgId; - TBranch* b_FRA_Lepb_p_T; - TBranch* b_FRA_Lepb_phi; - TBranch* b_FRA_Lepb_eta; - TBranch* b_FRA_Hadb_N; - TBranch* b_FRA_Hadb_pdgId; - TBranch* b_FRA_Hadb_p_T; - TBranch* b_FRA_Hadb_phi; - TBranch* b_FRA_Hadb_eta; - TBranch* b_FRA_Hadj_N; - TBranch* b_FRA_Hadj_pdgId; - TBranch* b_FRA_Hadj_p_T; - TBranch* b_FRA_Hadj_phi; - TBranch* b_FRA_Hadj_eta; - TBranch* b_TRA_El_N; - TBranch* b_TRA_El_pdgId; - TBranch* b_TRA_El_p_T; - TBranch* b_TRA_El_phi; - TBranch* b_TRA_El_eta; - TBranch* b_TRA_Mu_N; - TBranch* b_TRA_Mu_pdgId; - TBranch* b_TRA_Mu_p_T; - TBranch* b_TRA_Mu_phi; - TBranch* b_TRA_Mu_eta; - TBranch* b_TRA_Tau_N; - TBranch* b_TRA_Tau_pdgId; - TBranch* b_TRA_Tau_p_T; - TBranch* b_TRA_Tau_phi; - TBranch* b_TRA_Tau_eta; - TBranch* b_TRA_HadW_N; - TBranch* b_TRA_HadW_pdgId; - TBranch* b_TRA_HadW_p_T; - TBranch* b_TRA_HadW_phi; - TBranch* b_TRA_HadW_eta; - TBranch* b_TRA_LepW_N; - TBranch* b_TRA_LepW_pdgId; - TBranch* b_TRA_LepW_p_T; - TBranch* b_TRA_LepW_phi; - TBranch* b_TRA_LepW_eta; - TBranch* b_TRA_HadTop_N; - TBranch* b_TRA_HadTop_pdgId; - TBranch* b_TRA_HadTop_p_T; - TBranch* b_TRA_HadTop_phi; - TBranch* b_TRA_HadTop_eta; - TBranch* b_TRA_LepTop_N; - TBranch* b_TRA_LepTop_pdgId; - TBranch* b_TRA_LepTop_p_T; - TBranch* b_TRA_LepTop_phi; - TBranch* b_TRA_LepTop_eta; - TBranch* b_TRA_Bot_N; - TBranch* b_TRA_Bot_pdgId; - TBranch* b_TRA_Bot_p_T; - TBranch* b_TRA_Bot_phi; - TBranch* b_TRA_Bot_eta; - TBranch* b_TRA_LQ_N; - TBranch* b_TRA_LQ_pdgId; - TBranch* b_TRA_LQ_p_T; - TBranch* b_TRA_LQ_phi; - TBranch* b_TRA_LQ_eta; - TBranch* b_TA_Tru_p_T; - TBranch* b_TA_Tru_phi; - TBranch* b_TA_Tru_eta; - TBranch* b_TA_Tru_pdgId; - TBranch* b_TA_Tru_barcode; - //Protected memeber functions - template<typename TYPE> - std::string asString(const TYPE&); - void SetBranches(void); - void FillBranches(Int_t entryNumber); - void SetActiveFile(Int_t fileNumber); - void GetFullReco(void); - void GetFullRecoAna(void); - void GetTruthAll(Bool_t onlyMuons); - void GetTruthAna(Bool_t onlyMuons); - void GetMET(Bool_t getTruth); - void StartXML(void); - void FillXML_ParticleDump(Char_t* nodeName, Char_t* storeGateKey); - void FillXML_TruthDump(Char_t* nodeName, Char_t* storeGateKey); - void FillXML_MET(Char_t* storeGateKey); - void EndXML(Char_t* outputFilename); - public: - Bool_t ntuple2XML(Char_t* outputFilename, UInt_t entryNumber, UInt_t fileNumber); - void Add(Char_t* fileLocation); - void Clear(void); - Int_t GetNfiles(void) { return fileStore.size(); } - Int_t GetNentries(UInt_t fileNumber); - Bool_t SetWarnLevel(UInt_t warnLevel); - Bool_t SetTruthPreference(UInt_t truthPreference); - Bool_t SetFilenameAppend(UInt_t filenameAppend); - -}; - -struct TopViewXML: public ntupleXML { - TopViewXML(Char_t* fileLocation); - TopViewXML(void); - ~TopViewXML(void) {} -}; - -struct EventViewXML: public ntupleXML { - EventViewXML(Char_t* fileLocation); - EventViewXML(void); - ~EventViewXML(void) {} -}; - -//Constructors// - -TopViewXML::TopViewXML(Char_t* fileLocation) { - isTopView=1; - Append=1; Warn=1; truthPref=2; - mainTreeName = "FullReco0"; - ntupleXML::Add(fileLocation); -} - -TopViewXML::TopViewXML(void) { - isTopView=1; - Append=1; Warn=1; truthPref=2; - mainTreeName = "FullReco0"; -} - -EventViewXML::EventViewXML(Char_t* fileLocation) { - isTopView=0; - Append=1; Warn=1; truthPref=2; - mainTreeName = "CollectionTree"; - ntupleXML::Add(fileLocation); -} - -EventViewXML::EventViewXML(void) { - isTopView=0; - Append=1; Warn=1; truthPref=2; - mainTreeName = "CollectionTree"; -} - -//Inherited public methods// - -//ntuple2XML takes an entry from a file loaded in the internal File Chain and writes an -//atlantis xml file for the event. -Bool_t ntupleXML::ntuple2XML(Char_t* outputFilename, UInt_t entryNumber, UInt_t fileNumber) { - - if (fileNumber >= fileStore.size()) { - if (Warn>0) { std::cout << "\nntupleXML: Error cannot access file #" << fileNumber - << ", " << fileStore.size() << " file(s) currently loaded. "; - } - return 0; - } - - //Set the required file as activeFile, main tree as activeTree & associate branches - ntupleXML::SetActiveFile(fileNumber); - - if (entryNumber >= activeTree->GetEntries()) { - if (Warn>0) { std::cout << "\nntupleXML: Error cannot access entry #" << entryNumber - << ", file #" << fileNumber << " contains " << activeTree->GetEntries() << " entries. "; - } - return 0; - } - - //Cannot proceed without FullReco/CollectionTree branches set - if (!FR_Active) { - if (Warn>0) { std::cout << "\nntupleXML: Error unable to access " << mainTreeName << " Tree. "; } - return 0; - } - - //Retrieve event - ntupleXML::FillBranches(entryNumber); - nParticles=0; - - //Prepare XML document - ntupleXML::StartXML(); - - ntupleXML::GetFullReco(); - if (nParticles) { ntupleXML::FillXML_ParticleDump("CompositeParticle","RecoView"); } - - ntupleXML::GetMET(0); - ntupleXML::FillXML_MET("MET_Final"); - if (TR_Active) { - ntupleXML::GetMET(1); - ntupleXML::FillXML_MET("MET_Truth"); - } else if (Warn>1) { std::cout << "\nntupleXML: Warning unable to output MET_Truth. "; } - - if (FRA_Active) { - ntupleXML::GetFullRecoAna(); - if (nParticles) { ntupleXML::FillXML_ParticleDump("CompositeParticle","RecoAnaView"); } - } else if (Warn>1 && isTopView) { std::cout << "\nntupleXML: Warning unable to output FullRecoAna Tree. "; } - - if (TA_Active && truthPref == 1) { - ntupleXML::GetTruthAll(0); - if (nParticles) { ntupleXML::FillXML_TruthDump("STr",""); } - ntupleXML::GetTruthAll(1); //Get only muons - if (nParticles) { ntupleXML::FillXML_TruthDump("SMTr",""); } - } else if (TRA_Active && truthPref) { - ntupleXML::GetTruthAna(0); - if (nParticles) { ntupleXML::FillXML_TruthDump("STr",""); } - ntupleXML::GetTruthAna(1); - if (nParticles) { ntupleXML::FillXML_TruthDump("SMTr",""); } - } else if (Warn>1 && truthPref && isTopView) { - std::cout << "\nntupleXML: Warning unable to output TruthAna or TruthAll Tree. "; - } - - //Construct filename - std::string filenameStr(outputFilename), ext; - ext = filenameStr.substr(filenameStr.length() - 4, 4); - if (Append) { - if (ext == ".xml" || ext == ".Xml" || ext == ".XML") { - filenameStr = filenameStr.substr(0, filenameStr.length() - 4) ; - if (Append==1) { filenameStr += "_" + asString(FR_eventNumber) + ext; } - else { filenameStr += "_" + asString(entryNumber) + ext; } - } else { - if (Append==1) { filenameStr += "_" + asString(FR_eventNumber) + ".xml"; } - else { filenameStr += "_" + asString(entryNumber) + ".xml"; } - } - } else { - if (!(ext == ".xml" || ext == ".Xml" || ext == ".XML")) { - filenameStr += ".xml"; - } - } - - //Write .xml file - ntupleXML::EndXML((Char_t*) filenameStr.c_str()); - if (Warn>1) { std::cout << "\nntupleXML: Output to " << filenameStr; } - - //Return success - return 1; -} - -Bool_t ntupleXML::SetWarnLevel(UInt_t warnLevel) { - if (warnLevel <= 2) { - Warn=warnLevel; - return 1; - } else { return 0; } -} - -Bool_t ntupleXML::SetTruthPreference(UInt_t truthPreference) { - if (truthPreference <= 2) { - truthPref=truthPreference; - return 1; - } else { return 0; } -} - -Bool_t ntupleXML::SetFilenameAppend(UInt_t filenameAppend) { - if (filenameAppend <= 2) { - Append=filenameAppend; - return 1; - } else { return 0; } -} - -Int_t ntupleXML::GetNentries(UInt_t fileNumber) { - if (fileNumber >= fileStore.size()) { - if (Warn>0) { std::cout << "\nntupleXML: Error cannot access file #" << fileNumber - << ", " << fileStore.size() << " file(s) currently loaded. "; - } - return 0; - } else { - ntupleXML::SetActiveFile(fileNumber); - return activeTree->GetEntries(); - } -} - -void ntupleXML::Add(Char_t* fileLocation) { - TChain* tf; - if (isTopView) { - tf = new TChain("FullReco0"); - tf->Add(fileLocation); - tf->AddFriend("FullRecoAna0"); - tf->AddFriend("TruthAna0"); - tf->AddFriend("TruthAll0"); - tf->AddFriend("Truth0"); - if ( tf->LoadTree(0) < 0 ) { - if (Warn>0) { std::cout << "\nntupleXML: Error, file was not added. "; } - return; - } - } else { - tf = new TChain("CollectionTree"); - tf->Add(fileLocation); - if ( tf->LoadTree(0) < 0 ) { - if (Warn>0) { std::cout << "\nntupleXML: Error, file was not added. "; } - return; - } - - } - fileStore.push_back(tf); -} - -void ntupleXML::Clear(void) { - for (UInt_t i=0; i<fileStore.size(); i++) { - delete fileStore[i]; - } - fileStore.clear(); - activeFile = NULL; -} - -//XML File Construction Members// - -void ntupleXML::StartXML(void) { - //Create XML engine - TVXMLEng = new TXMLEngine(); - event = TVXMLEng->NewChild(0, 0, "Event"); - TVXMLEng->NewAttr(event, 0, "version", "ntuple"); - TVXMLEng->NewIntAttr(event, "runNumber", FR_runNumber); - TVXMLEng->NewIntAttr(event, "eventNumber", FR_eventNumber); - TDatime* makeTime = new TDatime(); - Char_t makeTimeStr[26]; - makeTime->AsString(makeTimeStr); //This 'AsString' is member of TDatime - delete makeTime; - TVXMLEng->NewAttr(event, 0, "dateTime", makeTimeStr); -} - -void ntupleXML::FillXML_ParticleDump(Char_t* nodeName, Char_t* storeGateKey) { - //Create Composite particle subnode - XMLNodePointer_t compPart = TVXMLEng->NewChild(event, 0, nodeName); - TVXMLEng->NewIntAttr(compPart, "count", nParticles); - TVXMLEng->NewAttr(compPart, 0, "storeGateKey", storeGateKey); - TVXMLEng->NewChild(compPart, 0, "dataType", dataTypeCon.c_str()); - TVXMLEng->NewChild(compPart, 0, "eta", etaCon.c_str()); - TVXMLEng->NewChild(compPart, 0, "label", labelCon.c_str()); - TVXMLEng->NewChild(compPart, 0, "pdgId", pdgIdCon.c_str()); - TVXMLEng->NewChild(compPart, 0, "phi", phiCon.c_str()); - TVXMLEng->NewChild(compPart, 0, "pt", ptCon.c_str()); - TVXMLEng->NewChild(compPart, 0, "typeEV", typeEVCon.c_str()); - dataTypeCon=""; etaCon=""; phiCon=""; labelCon=""; pdgIdCon=""; ptCon=""; typeEVCon=""; - nParticles=0; -} - -void ntupleXML::FillXML_TruthDump(Char_t* nodeName, Char_t* storeGateKey) { - //Create truth subnode - XMLNodePointer_t truBlock = TVXMLEng->NewChild(event, 0, nodeName); - TVXMLEng->NewIntAttr(truBlock, "count", nParticles); - TVXMLEng->NewAttr(truBlock, 0, "storeGateKey", storeGateKey); - TVXMLEng->NewChild(truBlock, 0, "code", pdgIdCon.c_str()); - TVXMLEng->NewChild(truBlock, 0, "eta", etaCon.c_str()); - TVXMLEng->NewChild(truBlock, 0, "id", labelCon.c_str()); - TVXMLEng->NewChild(truBlock, 0, "phi", phiCon.c_str()); - TVXMLEng->NewChild(truBlock, 0, "phiVertex", dataTypeCon.c_str()); - TVXMLEng->NewChild(truBlock, 0, "pt", ptCon.c_str()); - TVXMLEng->NewChild(truBlock, 0, "rhoVertex", dataTypeCon.c_str()); - TVXMLEng->NewChild(truBlock, 0, "zVertex", dataTypeCon.c_str()); - dataTypeCon=""; etaCon=""; phiCon=""; labelCon=""; pdgIdCon=""; ptCon=""; - nParticles=0; -} - -void ntupleXML::FillXML_MET(Char_t* storeGateKey) { - //Create MET subnode - XMLNodePointer_t MET = TVXMLEng->NewChild(event, 0, "ETMis"); - TVXMLEng->NewIntAttr(MET, "count", 1); - TVXMLEng->NewAttr(MET, 0, "storeGateKey", storeGateKey); - TVXMLEng->NewChild(MET, 0, "et", etaCon.c_str()); - TVXMLEng->NewChild(MET, 0, "etx", phiCon.c_str()); - TVXMLEng->NewChild(MET, 0, "ety", ptCon.c_str()); - etaCon=""; phiCon=""; ptCon=""; -} - -void ntupleXML::EndXML(Char_t* outputFilename) { - //Create document - XMLDocPointer_t xmldoc = TVXMLEng->NewDoc(); - TVXMLEng->DocSetRootElement(xmldoc, event); - TVXMLEng->AddDocRawLine(xmldoc, "<?ATLAS Release: \"RELEASE#\"?>"); - TVXMLEng->AddDocRawLine(xmldoc, "<!DOCTYPE Event SYSTEM \"event.dtd\">"); - // Save document to file - TVXMLEng->SaveDoc(xmldoc, outputFilename); - // Release memory before exit - TVXMLEng->FreeDoc(xmldoc); - delete TVXMLEng; -} - -//String Filling Members// - -void ntupleXML::GetFullReco(void) { - std::string id; - if (isTopView) { id = "FR_"; } - else { id = "EV_"; } - for (Int_t i=0; i<FR_El_N; i++) { - nParticles++; - dataTypeCon += "1 "; - typeEVCon += "EVElectron "; - labelCon += id + "Electron "; - etaCon += asString(FR_El_eta->at(i)) + " "; - phiCon += asString(FR_El_phi->at(i)) + " "; - ptCon += asString(FR_El_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)FR_El_pdgId->at(i)) + " "; - } - for (Int_t i=0; i<FR_Mu_N; i++) { - nParticles++; - dataTypeCon += "1 "; - typeEVCon += "EVMuon "; - labelCon += id + "Muon "; - etaCon += asString(FR_Mu_eta->at(i)) + " "; - phiCon += asString(FR_Mu_phi->at(i)) + " "; - ptCon += asString(FR_Mu_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)FR_Mu_pdgId->at(i)) + " "; - } - for (Int_t i=0; i<FR_Tau_N; i++) { - nParticles++; - dataTypeCon += "1 "; - typeEVCon += "EVTauJet "; - labelCon += id + "Tau "; - etaCon += asString(FR_Tau_eta->at(i)) + " "; - phiCon += asString(FR_Tau_phi->at(i)) + " "; - ptCon += asString(FR_Tau_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)FR_Tau_pdgId->at(i)) + " "; - } - for (Int_t i=0; i<FR_Ph_N; i++) { - nParticles++; - dataTypeCon += "1 "; - typeEVCon += "EVPhoton "; - labelCon += id + "Photon "; - etaCon += asString(FR_Ph_eta->at(i)) + " "; - phiCon += asString(FR_Ph_phi->at(i)) + " "; - ptCon += asString(FR_Ph_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)FR_Ph_pdgId->at(i)) + " "; - } - for (Int_t i=0; i<FR_PJet_N; i++) { - if (isTopView) { - if (FR_PJet_BTagged->at(i)) { - typeEVCon += "EVBJet "; - labelCon += id + "BTaggedJet "; - pdgIdCon += "5 "; - } else { - typeEVCon += "EVParticleJet "; - labelCon += id + "ParticleJet "; - pdgIdCon += "0 "; - } - } else { - typeEVCon += "EVParticleJet "; - labelCon += id + "ParticleJet "; - pdgIdCon += "5 "; - } - nParticles++; - dataTypeCon += "1 "; - etaCon += asString(FR_PJet_eta->at(i)) + " "; - phiCon += asString(FR_PJet_phi->at(i)) + " "; - ptCon += asString(FR_PJet_p_T->at(i)/1000.) + " "; - } -} - -void ntupleXML::GetMET(Bool_t getTruth) { - if (!getTruth) { - etaCon += asString(FR_MET_Final_et/1000.) + " "; - phiCon += asString(FR_MET_Final_ex/1000.) + " "; - ptCon += asString(FR_MET_Final_ey/1000.) + " "; - } else { - etaCon += asString(TR_MET_Truth_et/1000.) + " "; - phiCon += asString(TR_MET_Truth_ex/1000.) + " "; - ptCon += asString(TR_MET_Truth_ey/1000.) + " "; - } -} - -void ntupleXML::GetFullRecoAna(void) { - for (Int_t i=0; i<FRA_El_N; i++) { - nParticles++; - dataTypeCon += "1 "; - typeEVCon += "EVElectron "; - labelCon += "FRA_Electron "; - etaCon += asString(FRA_El_eta->at(i)) + " "; - phiCon += asString(FRA_El_phi->at(i)) + " "; - ptCon += asString(FRA_El_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)FRA_El_pdgId->at(i)) + " "; - } - for (Int_t i=0; i<FRA_Mu_N; i++) { - nParticles++; - dataTypeCon += "1 "; - typeEVCon += "EVMuon "; - labelCon += "FRA_Muon "; - etaCon += asString(FRA_Mu_eta->at(i)) + " "; - phiCon += asString(FRA_Mu_phi->at(i)) + " "; - ptCon += asString(FRA_Mu_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)FRA_Mu_pdgId->at(i)) + " "; - } - for (Int_t i=0; i<FRA_Nu_N; i++) { - nParticles++; - dataTypeCon += "1 "; - typeEVCon += "EVNeutrino "; - labelCon += "FRA_Neutrino "; - etaCon += asString(FRA_Nu_eta->at(i)) + " "; - phiCon += asString(FRA_Nu_phi->at(i)) + " "; - ptCon += asString(FRA_Nu_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)FRA_Nu_pdgId->at(i)) + " "; - } - for (Int_t i=0; i<FRA_HadW_N; i++) { - nParticles++; - dataTypeCon += "0 "; - typeEVCon += "EVCompositeParticle "; - labelCon += "FRA_HadronicW "; - etaCon += asString(FRA_HadW_eta->at(i)) + " "; - phiCon += asString(FRA_HadW_phi->at(i)) + " "; - ptCon += asString(FRA_HadW_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)FRA_HadW_pdgId->at(i)) + " "; - } - for (Int_t i=0; i<FRA_LepW_N; i++) { - nParticles++; - dataTypeCon += "0 "; - typeEVCon += "EVCompositeParticle "; - labelCon += "FRA_LeptonicW "; - etaCon += asString(FRA_LepW_eta->at(i)) + " "; - phiCon += asString(FRA_LepW_phi->at(i)) + " "; - ptCon += asString(FRA_LepW_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)FRA_LepW_pdgId->at(i)) + " "; - } - for (Int_t i=0; i<FRA_HadTop_N; i++) { - nParticles++; - dataTypeCon += "0 "; - typeEVCon += "EVCompositeParticle "; - labelCon += "FRA_HadronicTop "; - etaCon += asString(FRA_HadTop_eta->at(i)) + " "; - phiCon += asString(FRA_HadTop_phi->at(i)) + " "; - ptCon += asString(FRA_HadTop_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)FRA_HadTop_pdgId->at(i)) + " "; - } - for (Int_t i=0; i<FRA_LepTop_N; i++) { - nParticles++; - dataTypeCon += "0 "; - typeEVCon += "EVCompositeParticle "; - labelCon += "FRA_LeptonicTop "; - etaCon += asString(FRA_LepTop_eta->at(i)) + " "; - phiCon += asString(FRA_LepTop_phi->at(i)) + " "; - ptCon += asString(FRA_LepTop_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)FRA_LepTop_pdgId->at(i)) + " "; - } - for (Int_t i=0; i<FRA_Lepb_N; i++) { - nParticles++; - dataTypeCon += "1 "; - typeEVCon += "EVBJet "; - labelCon += "FRA_LeptonicBJet "; - etaCon += asString(FRA_Lepb_eta->at(i)) + " "; - phiCon += asString(FRA_Lepb_phi->at(i)) + " "; - ptCon += asString(FRA_Lepb_p_T->at(i)/1000.) + " "; - pdgIdCon += "5 "; - } - for (Int_t i=0; i<FRA_Hadb_N; i++) { - nParticles++; - dataTypeCon += "1 "; - typeEVCon += "EVBJet "; - labelCon += "FRA_HadronicBJet "; - etaCon += asString(FRA_Hadb_eta->at(i)) + " "; - phiCon += asString(FRA_Hadb_phi->at(i)) + " "; - ptCon += asString(FRA_Hadb_p_T->at(i)/1000.) + " "; - pdgIdCon += "5 "; - } - for (Int_t i=0; i<FRA_Hadj_N; i++) { - nParticles++; - dataTypeCon += "1 "; - typeEVCon += "EVParticleJet "; - labelCon += "FRA_HadronicParticleJet "; - etaCon += asString(FRA_Hadj_eta->at(i)) + " "; - phiCon += asString(FRA_Hadj_phi->at(i)) + " "; - ptCon += asString(FRA_Hadj_p_T->at(i)/1000.) + " "; - pdgIdCon += "0 "; - } -} - -//onlyMouns is set true when filling SMTr -void ntupleXML::GetTruthAna(Bool_t onlyMuons) { - Int_t sign; - for (Int_t i=0; i<TRA_Mu_N; i++) { - nParticles++; - etaCon += asString(TRA_Mu_eta->at(i)) + " "; - phiCon += asString(TRA_Mu_phi->at(i)) + " "; - ptCon += asString(TRA_Mu_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)TRA_Mu_pdgId->at(i)) + " "; - labelCon += "0 "; //Barcode - dataTypeCon += "0.000001 "; //Used to fill vertexes - } - - if (onlyMuons) { return; } - - for (Int_t i=0; i<TRA_El_N; i++) { - nParticles++; - etaCon += asString(TRA_El_eta->at(i)) + " "; - phiCon += asString(TRA_El_phi->at(i)) + " "; - ptCon += asString(TRA_El_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)TRA_El_pdgId->at(i)) + " "; - labelCon += "0 "; - dataTypeCon += " 0.000001 "; - } - for (Int_t i=0; i<TRA_Tau_N; i++) { - nParticles++; - etaCon += asString(TRA_Tau_eta->at(i)) + " "; - phiCon += asString(TRA_Tau_phi->at(i)) + " "; - ptCon += asString(TRA_Tau_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)TRA_Tau_pdgId->at(i)) + " "; - labelCon += "0 "; - dataTypeCon += "0.000001 "; - } - for (Int_t i=0; i<TRA_HadW_N; i++) { - nParticles++; - etaCon += asString(TRA_HadW_eta->at(i)) + " "; - phiCon += asString(TRA_HadW_phi->at(i)) + " "; - ptCon += asString(TRA_HadW_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)TRA_HadW_pdgId->at(i)) + " "; - labelCon += "0 "; - dataTypeCon += "0.000001 "; - } - for (Int_t i=0; i<TRA_LepW_N; i++) { - nParticles++; - etaCon += asString(TRA_LepW_eta->at(i)) + " "; - phiCon += asString(TRA_LepW_phi->at(i)) + " "; - ptCon += asString(TRA_LepW_p_T->at(i)/1000.) + " "; - pdgIdCon += asString((Int_t)TRA_LepW_pdgId->at(i)) + " "; - labelCon += "0 "; - dataTypeCon += "0.000001 "; - } - for (Int_t i=0; i<TRA_HadTop_N; i++) { - nParticles++; - etaCon += asString(TRA_HadTop_eta->at(i)) + " "; - phiCon += asString(TRA_HadTop_phi->at(i)) + " "; - ptCon += asString(TRA_HadTop_p_T->at(i)/1000.) + " "; - sign = (Int_t) (fabs(TRA_HadTop_pdgId->at(i))/TRA_HadTop_pdgId->at(i)); - pdgIdCon += asString((Int_t)(TRA_HadTop_pdgId->at(i)+(600*sign))) + " "; - labelCon += "0 "; - dataTypeCon += "0.000001 "; - } - for (Int_t i=0; i<TRA_LepTop_N; i++) { - nParticles++; - etaCon += asString(TRA_LepTop_eta->at(i)) + " "; - phiCon += asString(TRA_LepTop_phi->at(i)) + " "; - ptCon += asString(TRA_LepTop_p_T->at(i)/1000.) + " "; - sign = (Int_t) (fabs(TRA_LepTop_pdgId->at(i))/TRA_LepTop_pdgId->at(i)); - pdgIdCon += asString((Int_t)(TRA_LepTop_pdgId->at(i)+(600*sign))) + " "; - labelCon += "0 "; - dataTypeCon += "0.000001 "; - } - for (Int_t i=0; i<TRA_Bot_N; i++) { - nParticles++; - etaCon += asString(TRA_Bot_eta->at(i)) + " "; - phiCon += asString(TRA_Bot_phi->at(i)) + " "; - ptCon += asString(TRA_Bot_p_T->at(i)/1000.) + " "; - sign = (Int_t) (fabs(TRA_Bot_pdgId->at(i))/TRA_Bot_pdgId->at(i)); - pdgIdCon += asString((Int_t)(TRA_Bot_pdgId->at(i)+(600*sign))) + " "; - labelCon += "0 "; - dataTypeCon += "0.000001 "; - } - for (Int_t i=0; i<TRA_LQ_N; i++) { //LQ - Light Quarks - nParticles++; - etaCon += asString(TRA_LQ_eta->at(i)) + " "; - phiCon += asString(TRA_LQ_phi->at(i)) + " "; - ptCon += asString(TRA_LQ_p_T->at(i)/1000.) + " "; - sign = (Int_t) (fabs(TRA_LQ_pdgId->at(i))/TRA_LQ_pdgId->at(i)); - pdgIdCon += asString((Int_t)(TRA_LQ_pdgId->at(i)+(600*sign))) + " "; - labelCon += "0 "; - dataTypeCon += "0.000001 "; - } -} - -void ntupleXML::GetTruthAll(Bool_t onlyMuons) { - //Loop over entire truth block (if present) - Int_t id, sign; - for (UInt_t i=0; i<TA_Tru_p_T->size(); i++) { - if (!onlyMuons || (onlyMuons && fabs(TA_Tru_pdgId->at(i)) == 13)) { - nParticles++; - etaCon += asString(TA_Tru_eta->at(i)) + " "; - phiCon += asString(TA_Tru_phi->at(i)) + " "; - ptCon += asString(TA_Tru_p_T->at(i)/1000.) + " "; - id = (Int_t) TA_Tru_pdgId->at(i); - sign = (Int_t) (fabs(TA_Tru_pdgId->at(i))/TA_Tru_pdgId->at(i)); - //Atlantis' True Particle Simulation ignores quarks, however with TopView - //we are interested in t and b quarks, 6 special pdgIds have therefore - //been set up in Atlantis (601-606) so as to display quarks from ntuples - if (abs(id) <= 6) { id += (600 * sign); } - pdgIdCon += asString(id) + " "; - labelCon += asString(TA_Tru_barcode->at(i)) + " "; - dataTypeCon += "0.000001 "; //If zero, Atlantis crashes on eta-phi plot due to rhoVertex - } - } -} - -//Branch Association// - -void ntupleXML::SetBranches(void) { - FR_El_pdgId = 0; - FR_El_p_T = 0; - FR_El_phi = 0; - FR_El_eta = 0; - FR_Mu_pdgId = 0; - FR_Mu_p_T = 0; - FR_Mu_phi = 0; - FR_Mu_eta = 0; - FR_Tau_pdgId = 0; - FR_Tau_p_T = 0; - FR_Tau_phi = 0; - FR_Tau_eta = 0; - FR_Ph_pdgId = 0; - FR_Ph_p_T = 0; - FR_Ph_phi = 0; - FR_Ph_eta = 0; - FR_PJet_pdgId = 0; - FR_PJet_p_T = 0; - FR_PJet_phi = 0; - FR_PJet_eta = 0; - FR_PJet_BTagged = 0; - FRA_El_pdgId = 0; - FRA_El_p_T = 0; - FRA_El_phi = 0; - FRA_El_eta = 0; - FRA_Mu_pdgId = 0; - FRA_Mu_p_T = 0; - FRA_Mu_phi = 0; - FRA_Mu_eta = 0; - FRA_Nu_pdgId = 0; - FRA_Nu_p_T = 0; - FRA_Nu_phi = 0; - FRA_Nu_eta = 0; - FRA_HadW_pdgId = 0; - FRA_HadW_p_T = 0; - FRA_HadW_phi = 0; - FRA_HadW_eta = 0; - FRA_LepW_pdgId = 0; - FRA_LepW_p_T = 0; - FRA_LepW_phi = 0; - FRA_LepW_eta = 0; - FRA_HadTop_pdgId = 0; - FRA_HadTop_p_T = 0; - FRA_HadTop_phi = 0; - FRA_HadTop_eta = 0; - FRA_LepTop_pdgId = 0; - FRA_LepTop_p_T = 0; - FRA_LepTop_phi = 0; - FRA_LepTop_eta = 0; - FRA_Lepb_pdgId = 0; - FRA_Lepb_p_T = 0; - FRA_Lepb_phi = 0; - FRA_Lepb_eta = 0; - FRA_Hadb_pdgId = 0; - FRA_Hadb_p_T = 0; - FRA_Hadb_phi = 0; - FRA_Hadb_eta = 0; - FRA_Hadj_pdgId = 0; - FRA_Hadj_p_T = 0; - FRA_Hadj_phi = 0; - FRA_Hadj_eta = 0; - TRA_El_pdgId = 0; - TRA_El_p_T = 0; - TRA_El_phi = 0; - TRA_El_eta = 0; - TRA_Mu_pdgId = 0; - TRA_Mu_p_T = 0; - TRA_Mu_phi = 0; - TRA_Mu_eta = 0; - TRA_Tau_pdgId = 0; - TRA_Tau_p_T = 0; - TRA_Tau_phi = 0; - TRA_Tau_eta = 0; - TRA_HadW_pdgId = 0; - TRA_HadW_p_T = 0; - TRA_HadW_phi = 0; - TRA_HadW_eta = 0; - TRA_LepW_pdgId = 0; - TRA_LepW_p_T = 0; - TRA_LepW_phi = 0; - TRA_LepW_eta = 0; - TRA_HadTop_pdgId = 0; - TRA_HadTop_p_T = 0; - TRA_HadTop_phi = 0; - TRA_HadTop_eta = 0; - TRA_LepTop_pdgId = 0; - TRA_LepTop_p_T = 0; - TRA_LepTop_phi = 0; - TRA_LepTop_eta = 0; - TRA_Bot_pdgId = 0; - TRA_Bot_p_T = 0; - TRA_Bot_phi = 0; - TRA_Bot_eta = 0; - TRA_LQ_pdgId = 0; - TRA_LQ_p_T = 0; - TRA_LQ_phi = 0; - TRA_LQ_eta = 0; - TA_Tru_p_T = 0; - TA_Tru_phi = 0; - TA_Tru_eta = 0; - TA_Tru_pdgId = 0; - TA_Tru_barcode = 0; - FR_Active=0; - TR_Active=0; - FRA_Active=0; - TRA_Active=0; - TA_Active=0; - - activeTree = activeFile->GetTree(); - - if (activeTree) { - FR_Active = 1; - activeTree->SetBranchAddress("eventNumber", &FR_eventNumber, &b_FR_eventNumber); - activeTree->SetBranchAddress("runNumber", &FR_runNumber, &b_FR_runNumber); - activeTree->SetBranchAddress("MET_Final_ex", &FR_MET_Final_ex, &b_FR_MET_Final_ex); - activeTree->SetBranchAddress("MET_Final_ey", &FR_MET_Final_ey, &b_FR_MET_Final_ey); - activeTree->SetBranchAddress("MET_Final_et", &FR_MET_Final_et, &b_FR_MET_Final_et); - if (!isTopView) { - //With EventView ntuples, MET Truth is in the CollectionTree - activeTree->SetBranchAddress("MET_Truth_ex", &TR_MET_Truth_ex, &b_TR_MET_Truth_ex); - activeTree->SetBranchAddress("MET_Truth_ey", &TR_MET_Truth_ey, &b_TR_MET_Truth_ey); - activeTree->SetBranchAddress("MET_Truth_et", &TR_MET_Truth_et, &b_TR_MET_Truth_et); - TR_Active=1; - } - activeTree->SetBranchAddress("El_N", &FR_El_N, &b_FR_El_N); - activeTree->SetBranchAddress("El_p_T", &FR_El_p_T, &b_FR_El_p_T); - activeTree->SetBranchAddress("El_pdgId", &FR_El_pdgId, &b_FR_El_pdgId); - activeTree->SetBranchAddress("El_phi", &FR_El_phi, &b_FR_El_phi); - activeTree->SetBranchAddress("El_eta", &FR_El_eta, &b_FR_El_eta); - activeTree->SetBranchAddress("Mu_N", &FR_Mu_N, &b_FR_Mu_N); - activeTree->SetBranchAddress("Mu_p_T", &FR_Mu_p_T, &b_FR_Mu_p_T); - activeTree->SetBranchAddress("Mu_pdgId", &FR_Mu_pdgId, &b_FR_Mu_pdgId); - activeTree->SetBranchAddress("Mu_phi", &FR_Mu_phi, &b_FR_Mu_phi); - activeTree->SetBranchAddress("Mu_eta", &FR_Mu_eta, &b_FR_Mu_eta); - activeTree->SetBranchAddress("Tau_N", &FR_Tau_N, &b_FR_Tau_N); - activeTree->SetBranchAddress("Tau_p_T", &FR_Tau_p_T, &b_FR_Tau_p_T); - activeTree->SetBranchAddress("Tau_pdgId", &FR_Tau_pdgId, &b_FR_Tau_pdgId); - activeTree->SetBranchAddress("Tau_phi", &FR_Tau_phi, &b_FR_Tau_phi); - activeTree->SetBranchAddress("Tau_eta", &FR_Tau_eta, &b_FR_Tau_eta); - activeTree->SetBranchAddress("Ph_N", &FR_Ph_N, &b_FR_Ph_N); - activeTree->SetBranchAddress("Ph_p_T", &FR_Ph_p_T, &b_FR_Ph_p_T); - activeTree->SetBranchAddress("Ph_pdgId", &FR_Ph_pdgId, &b_FR_Ph_pdgId); - activeTree->SetBranchAddress("Ph_phi", &FR_Ph_phi, &b_FR_Ph_phi); - activeTree->SetBranchAddress("Ph_eta", &FR_Ph_eta, &b_FR_Ph_eta); - activeTree->SetBranchAddress("PJet_N", &FR_PJet_N, &b_FR_PJet_N); - activeTree->SetBranchAddress("PJet_p_T", &FR_PJet_p_T, &b_FR_PJet_p_T); - activeTree->SetBranchAddress("PJet_pdgId", &FR_PJet_pdgId, &b_FR_PJet_pdgId); - activeTree->SetBranchAddress("PJet_phi", &FR_PJet_phi, &b_FR_PJet_phi); - activeTree->SetBranchAddress("PJet_eta", &FR_PJet_eta, &b_FR_PJet_eta); - if (isTopView) { activeTree->SetBranchAddress("PJet_BTagged", &FR_PJet_BTagged, &b_FR_PJet_BTagged); } - } else if (Warn>1) { std::cout << "\nntupleXML: Warning cannot find " << mainTreeName << " tree. "; } - - //Stop here with EventView - if (!isTopView) { return; } - - friendTree = (TFriendElement*) (activeFile->GetListOfFriends()->FindObject("FullRecoAna0")); - activeTree = friendTree->GetTree(); - if (activeTree) { - FRA_Active=1; - activeTree->SetBranchAddress("El_N", &FRA_El_N, &b_FRA_El_N); - activeTree->SetBranchAddress("El_p_T", &FRA_El_p_T, &b_FRA_El_p_T); - activeTree->SetBranchAddress("El_pdgId", &FRA_El_pdgId, &b_FRA_El_pdgId); - activeTree->SetBranchAddress("El_phi", &FRA_El_phi, &b_FRA_El_phi); - activeTree->SetBranchAddress("El_eta", &FRA_El_eta, &b_FRA_El_eta); - activeTree->SetBranchAddress("Mu_N", &FRA_Mu_N, &b_FRA_Mu_N); - activeTree->SetBranchAddress("Mu_p_T", &FRA_Mu_p_T, &b_FRA_Mu_p_T); - activeTree->SetBranchAddress("Mu_pdgId", &FRA_Mu_pdgId, &b_FRA_Mu_pdgId); - activeTree->SetBranchAddress("Mu_phi", &FRA_Mu_phi, &b_FRA_Mu_phi); - activeTree->SetBranchAddress("Mu_eta", &FRA_Mu_eta, &b_FRA_Mu_eta); - activeTree->SetBranchAddress("Nu_N", &FRA_Nu_N, &b_FRA_Nu_N); - activeTree->SetBranchAddress("Nu_p_T", &FRA_Nu_p_T, &b_FRA_Nu_p_T); - activeTree->SetBranchAddress("Nu_pdgId", &FRA_Nu_pdgId, &b_FRA_Nu_pdgId); - activeTree->SetBranchAddress("Nu_phi", &FRA_Nu_phi, &b_FRA_Nu_phi); - activeTree->SetBranchAddress("Nu_eta", &FRA_Nu_eta, &b_FRA_Nu_eta); - activeTree->SetBranchAddress("HadW_N", &FRA_HadW_N, &b_FRA_HadW_N); - activeTree->SetBranchAddress("HadW_p_T", &FRA_HadW_p_T, &b_FRA_HadW_p_T); - activeTree->SetBranchAddress("HadW_pdgId", &FRA_HadW_pdgId, &b_FRA_HadW_pdgId); - activeTree->SetBranchAddress("HadW_phi", &FRA_HadW_phi, &b_FRA_HadW_phi); - activeTree->SetBranchAddress("HadW_eta", &FRA_HadW_eta, &b_FRA_HadW_eta); - activeTree->SetBranchAddress("LepW_N", &FRA_LepW_N, &b_FRA_LepW_N); - activeTree->SetBranchAddress("LepW_p_T", &FRA_LepW_p_T, &b_FRA_LepW_p_T); - activeTree->SetBranchAddress("LepW_pdgId", &FRA_LepW_pdgId, &b_FRA_LepW_pdgId); - activeTree->SetBranchAddress("LepW_phi", &FRA_LepW_phi, &b_FRA_LepW_phi); - activeTree->SetBranchAddress("LepW_eta", &FRA_LepW_eta, &b_FRA_LepW_eta); - activeTree->SetBranchAddress("HadTop_N", &FRA_HadTop_N, &b_FRA_HadTop_N); - activeTree->SetBranchAddress("HadTop_p_T", &FRA_HadTop_p_T, &b_FRA_HadTop_p_T); - activeTree->SetBranchAddress("HadTop_pdgId", &FRA_HadTop_pdgId, &b_FRA_HadTop_pdgId); - activeTree->SetBranchAddress("HadTop_phi", &FRA_HadTop_phi, &b_FRA_HadTop_phi); - activeTree->SetBranchAddress("HadTop_eta", &FRA_HadTop_eta, &b_FRA_HadTop_eta); - activeTree->SetBranchAddress("LepTop_N", &FRA_LepTop_N, &b_FRA_LepTop_N); - activeTree->SetBranchAddress("LepTop_p_T", &FRA_LepTop_p_T, &b_FRA_LepTop_p_T); - activeTree->SetBranchAddress("LepTop_pdgId", &FRA_LepTop_pdgId, &b_FRA_LepTop_pdgId); - activeTree->SetBranchAddress("LepTop_phi", &FRA_LepTop_phi, &b_FRA_LepTop_phi); - activeTree->SetBranchAddress("LepTop_eta", &FRA_LepTop_eta, &b_FRA_LepTop_eta); - activeTree->SetBranchAddress("Lepb_N", &FRA_Lepb_N, &b_FRA_Lepb_N); - activeTree->SetBranchAddress("Lepb_p_T", &FRA_Lepb_p_T, &b_FRA_Lepb_p_T); - activeTree->SetBranchAddress("Lepb_pdgId", &FRA_Lepb_pdgId, &b_FRA_Lepb_pdgId); - activeTree->SetBranchAddress("Lepb_phi", &FRA_Lepb_phi, &b_FRA_Lepb_phi); - activeTree->SetBranchAddress("Lepb_eta", &FRA_Lepb_eta, &b_FRA_Lepb_eta); - activeTree->SetBranchAddress("Hadb_N", &FRA_Hadb_N, &b_FRA_Hadb_N); - activeTree->SetBranchAddress("Hadb_p_T", &FRA_Hadb_p_T, &b_FRA_Hadb_p_T); - activeTree->SetBranchAddress("Hadb_pdgId", &FRA_Hadb_pdgId, &b_FRA_Hadb_pdgId); - activeTree->SetBranchAddress("Hadb_phi", &FRA_Hadb_phi, &b_FRA_Hadb_phi); - activeTree->SetBranchAddress("Hadb_eta", &FRA_Hadb_eta, &b_FRA_Hadb_eta); - activeTree->SetBranchAddress("Hadj_N", &FRA_Hadj_N, &b_FRA_Hadj_N); - activeTree->SetBranchAddress("Hadj_p_T", &FRA_Hadj_p_T, &b_FRA_Hadj_p_T); - activeTree->SetBranchAddress("Hadj_pdgId", &FRA_Hadj_pdgId, &b_FRA_Hadj_pdgId); - activeTree->SetBranchAddress("Hadj_phi", &FRA_Hadj_phi, &b_FRA_Hadj_phi); - activeTree->SetBranchAddress("Hadj_eta", &FRA_Hadj_eta, &b_FRA_Hadj_eta); - } else if (Warn>1) { std::cout << "\nntupleXML: Warning, cannot find FullRecoAna tree. "; } - - friendTree = (TFriendElement*) (activeFile->GetListOfFriends()->FindObject("TruthAna0")); - activeTree = friendTree->GetTree(); - if (activeTree) { - TRA_Active=1; - activeTree->SetBranchAddress("El_N", &TRA_El_N, &b_TRA_El_N); - activeTree->SetBranchAddress("El_p_T", &TRA_El_p_T, &b_TRA_El_p_T); - activeTree->SetBranchAddress("El_pdgId", &TRA_El_pdgId, &b_TRA_El_pdgId); - activeTree->SetBranchAddress("El_phi", &TRA_El_phi, &b_TRA_El_phi); - activeTree->SetBranchAddress("El_eta", &TRA_El_eta, &b_TRA_El_eta); - activeTree->SetBranchAddress("Mu_N", &TRA_Mu_N, &b_TRA_Mu_N); - activeTree->SetBranchAddress("Mu_p_T", &TRA_Mu_p_T, &b_TRA_Mu_p_T); - activeTree->SetBranchAddress("Mu_pdgId", &TRA_Mu_pdgId, &b_TRA_Mu_pdgId); - activeTree->SetBranchAddress("Mu_phi", &TRA_Mu_phi, &b_TRA_Mu_phi); - activeTree->SetBranchAddress("Mu_eta", &TRA_Mu_eta, &b_TRA_Mu_eta); - activeTree->SetBranchAddress("Tau_N", &TRA_Tau_N, &b_TRA_Tau_N); - activeTree->SetBranchAddress("Tau_p_T", &TRA_Tau_p_T, &b_TRA_Tau_p_T); - activeTree->SetBranchAddress("Tau_pdgId", &TRA_Tau_pdgId, &b_TRA_Tau_pdgId); - activeTree->SetBranchAddress("Tau_phi", &TRA_Tau_phi, &b_TRA_Tau_phi); - activeTree->SetBranchAddress("Tau_eta", &TRA_Tau_eta, &b_TRA_Tau_eta); - activeTree->SetBranchAddress("HadW_N", &TRA_HadW_N, &b_TRA_HadW_N); - activeTree->SetBranchAddress("HadW_p_T", &TRA_HadW_p_T, &b_TRA_HadW_p_T); - activeTree->SetBranchAddress("HadW_pdgId", &TRA_HadW_pdgId, &b_TRA_HadW_pdgId); - activeTree->SetBranchAddress("HadW_phi", &TRA_HadW_phi, &b_TRA_HadW_phi); - activeTree->SetBranchAddress("HadW_eta", &TRA_HadW_eta, &b_TRA_HadW_eta); - activeTree->SetBranchAddress("LepW_N", &TRA_LepW_N, &b_TRA_LepW_N); - activeTree->SetBranchAddress("LepW_p_T", &TRA_LepW_p_T, &b_TRA_LepW_p_T); - activeTree->SetBranchAddress("LepW_pdgId", &TRA_LepW_pdgId, &b_TRA_LepW_pdgId); - activeTree->SetBranchAddress("LepW_phi", &TRA_LepW_phi, &b_TRA_LepW_phi); - activeTree->SetBranchAddress("LepW_eta", &TRA_LepW_eta, &b_TRA_LepW_eta); - activeTree->SetBranchAddress("HadTop_N", &TRA_HadTop_N, &b_TRA_HadTop_N); - activeTree->SetBranchAddress("HadTop_p_T", &TRA_HadTop_p_T, &b_TRA_HadTop_p_T); - activeTree->SetBranchAddress("HadTop_pdgId", &TRA_HadTop_pdgId, &b_TRA_HadTop_pdgId); - activeTree->SetBranchAddress("HadTop_phi", &TRA_HadTop_phi, &b_TRA_HadTop_phi); - activeTree->SetBranchAddress("HadTop_eta", &TRA_HadTop_eta, &b_TRA_HadTop_eta); - activeTree->SetBranchAddress("LepTop_N", &TRA_LepTop_N, &b_TRA_LepTop_N); - activeTree->SetBranchAddress("LepTop_p_T", &TRA_LepTop_p_T, &b_TRA_LepTop_p_T); - activeTree->SetBranchAddress("LepTop_pdgId", &TRA_LepTop_pdgId, &b_TRA_LepTop_pdgId); - activeTree->SetBranchAddress("LepTop_phi", &TRA_LepTop_phi, &b_TRA_LepTop_phi); - activeTree->SetBranchAddress("LepTop_eta", &TRA_LepTop_eta, &b_TRA_LepTop_eta); - activeTree->SetBranchAddress("Bot_N", &TRA_Bot_N, &b_TRA_Bot_N); - activeTree->SetBranchAddress("Bot_p_T", &TRA_Bot_p_T, &b_TRA_Bot_p_T); - activeTree->SetBranchAddress("Bot_pdgId", &TRA_Bot_pdgId, &b_TRA_Bot_pdgId); - activeTree->SetBranchAddress("Bot_phi", &TRA_Bot_phi, &b_TRA_Bot_phi); - activeTree->SetBranchAddress("Bot_eta", &TRA_Bot_eta, &b_TRA_Bot_eta); - activeTree->SetBranchAddress("LQ_N", &TRA_LQ_N, &b_TRA_LQ_N); - activeTree->SetBranchAddress("LQ_p_T", &TRA_LQ_p_T, &b_TRA_LQ_p_T); - activeTree->SetBranchAddress("LQ_pdgId", &TRA_LQ_pdgId, &b_TRA_LQ_pdgId); - activeTree->SetBranchAddress("LQ_phi", &TRA_LQ_phi, &b_TRA_LQ_phi); - activeTree->SetBranchAddress("LQ_eta", &TRA_LQ_eta, &b_TRA_LQ_eta); - } else if (Warn>1) { std::cout << "\nntupleXML: Warning, cannot find TruthAna tree. "; } - - friendTree = (TFriendElement*) (activeFile->GetListOfFriends()->FindObject("TruthAll0")); - activeTree = friendTree->GetTree(); - if (activeTree) { - TA_Active=1; - activeTree->SetBranchAddress("Tru_p_T", &TA_Tru_p_T, &b_TA_Tru_p_T); - activeTree->SetBranchAddress("Tru_phi", &TA_Tru_phi, &b_TA_Tru_phi); - activeTree->SetBranchAddress("Tru_eta", &TA_Tru_eta, &b_TA_Tru_eta); - activeTree->SetBranchAddress("Tru_pdgId", &TA_Tru_pdgId, &b_TA_Tru_pdgId); - activeTree->SetBranchAddress("Tru_barcode", &TA_Tru_barcode, &b_TA_Tru_barcode); - } else if (Warn>1) { std::cout << "\nntupleXML: Warning, cannot find TruthAll tree. "; } - - //If using TopView ntuples, MET_Truth must be fetched from Truth0 - friendTree = (TFriendElement*) (activeFile->GetListOfFriends()->FindObject("Truth0")); - activeTree = friendTree->GetTree(); - if (activeTree) { - TR_Active=1; - activeTree->SetBranchAddress("MET_Truth_ex", &TR_MET_Truth_ex, &b_TR_MET_Truth_ex); - activeTree->SetBranchAddress("MET_Truth_ey", &TR_MET_Truth_ey, &b_TR_MET_Truth_ey); - activeTree->SetBranchAddress("MET_Truth_et", &TR_MET_Truth_et, &b_TR_MET_Truth_et); - } else if (Warn>1) { std::cout << "\nntupleXML: Warning, cannot find Truth tree. "; } -} - -void ntupleXML::FillBranches(Int_t entryNumber) { - if (FR_Active) { - b_FR_eventNumber->GetEntry(entryNumber); - b_FR_runNumber->GetEntry(entryNumber); - b_FR_MET_Final_ex->GetEntry(entryNumber); - b_FR_MET_Final_ey->GetEntry(entryNumber); - b_FR_MET_Final_et->GetEntry(entryNumber); - if (TR_Active) { - b_TR_MET_Truth_ex->GetEntry(entryNumber); - b_TR_MET_Truth_ey->GetEntry(entryNumber); - b_TR_MET_Truth_et->GetEntry(entryNumber); - } - b_FR_El_N->GetEntry(entryNumber); - b_FR_El_pdgId->GetEntry(entryNumber); - b_FR_El_p_T->GetEntry(entryNumber); - b_FR_El_phi->GetEntry(entryNumber); - b_FR_El_eta->GetEntry(entryNumber); - b_FR_Mu_N->GetEntry(entryNumber); - b_FR_Mu_pdgId->GetEntry(entryNumber); - b_FR_Mu_p_T->GetEntry(entryNumber); - b_FR_Mu_phi->GetEntry(entryNumber); - b_FR_Mu_eta->GetEntry(entryNumber); - b_FR_Tau_N->GetEntry(entryNumber); - b_FR_Tau_pdgId->GetEntry(entryNumber); - b_FR_Tau_p_T->GetEntry(entryNumber); - b_FR_Tau_phi->GetEntry(entryNumber); - b_FR_Tau_eta->GetEntry(entryNumber); - b_FR_Ph_N->GetEntry(entryNumber); - b_FR_Ph_pdgId->GetEntry(entryNumber); - b_FR_Ph_p_T->GetEntry(entryNumber); - b_FR_Ph_phi->GetEntry(entryNumber); - b_FR_Ph_eta->GetEntry(entryNumber); - b_FR_PJet_N->GetEntry(entryNumber); - b_FR_PJet_pdgId->GetEntry(entryNumber); - b_FR_PJet_p_T->GetEntry(entryNumber); - b_FR_PJet_phi->GetEntry(entryNumber); - b_FR_PJet_eta->GetEntry(entryNumber); - } - - if (!isTopView) { return; } - - if (FR_Active) { b_FR_PJet_BTagged->GetEntry(entryNumber); } - - if (FRA_Active) { - b_FRA_El_N->GetEntry(entryNumber); - b_FRA_El_pdgId->GetEntry(entryNumber); - b_FRA_El_p_T->GetEntry(entryNumber); - b_FRA_El_phi->GetEntry(entryNumber); - b_FRA_El_eta->GetEntry(entryNumber); - b_FRA_Mu_N->GetEntry(entryNumber); - b_FRA_Mu_pdgId->GetEntry(entryNumber); - b_FRA_Mu_p_T->GetEntry(entryNumber); - b_FRA_Mu_phi->GetEntry(entryNumber); - b_FRA_Mu_eta->GetEntry(entryNumber); - b_FRA_Nu_N->GetEntry(entryNumber); - b_FRA_Nu_pdgId->GetEntry(entryNumber); - b_FRA_Nu_p_T->GetEntry(entryNumber); - b_FRA_Nu_phi->GetEntry(entryNumber); - b_FRA_Nu_eta->GetEntry(entryNumber); - b_FRA_HadW_N->GetEntry(entryNumber); - b_FRA_HadW_pdgId->GetEntry(entryNumber); - b_FRA_HadW_p_T->GetEntry(entryNumber); - b_FRA_HadW_phi->GetEntry(entryNumber); - b_FRA_HadW_eta->GetEntry(entryNumber); - b_FRA_LepW_N->GetEntry(entryNumber); - b_FRA_LepW_pdgId->GetEntry(entryNumber); - b_FRA_LepW_p_T->GetEntry(entryNumber); - b_FRA_LepW_phi->GetEntry(entryNumber); - b_FRA_LepW_eta->GetEntry(entryNumber); - b_FRA_HadTop_N->GetEntry(entryNumber); - b_FRA_HadTop_pdgId->GetEntry(entryNumber); - b_FRA_HadTop_p_T->GetEntry(entryNumber); - b_FRA_HadTop_phi->GetEntry(entryNumber); - b_FRA_HadTop_eta->GetEntry(entryNumber); - b_FRA_LepTop_N->GetEntry(entryNumber); - b_FRA_LepTop_pdgId->GetEntry(entryNumber); - b_FRA_LepTop_p_T->GetEntry(entryNumber); - b_FRA_LepTop_phi->GetEntry(entryNumber); - b_FRA_LepTop_eta->GetEntry(entryNumber); - b_FRA_Lepb_N->GetEntry(entryNumber); - b_FRA_Lepb_pdgId->GetEntry(entryNumber); - b_FRA_Lepb_p_T->GetEntry(entryNumber); - b_FRA_Lepb_phi->GetEntry(entryNumber); - b_FRA_Lepb_eta->GetEntry(entryNumber); - b_FRA_Hadb_N->GetEntry(entryNumber); - b_FRA_Hadb_pdgId->GetEntry(entryNumber); - b_FRA_Hadb_p_T->GetEntry(entryNumber); - b_FRA_Hadb_phi->GetEntry(entryNumber); - b_FRA_Hadb_eta->GetEntry(entryNumber); - b_FRA_Hadj_N->GetEntry(entryNumber); - b_FRA_Hadj_pdgId->GetEntry(entryNumber); - b_FRA_Hadj_p_T->GetEntry(entryNumber); - b_FRA_Hadj_phi->GetEntry(entryNumber); - b_FRA_Hadj_eta->GetEntry(entryNumber); - } - if (TRA_Active) { - b_TRA_El_N->GetEntry(entryNumber); - b_TRA_El_pdgId->GetEntry(entryNumber); - b_TRA_El_p_T->GetEntry(entryNumber); - b_TRA_El_phi->GetEntry(entryNumber); - b_TRA_El_eta->GetEntry(entryNumber); - b_TRA_Mu_N->GetEntry(entryNumber); - b_TRA_Mu_pdgId->GetEntry(entryNumber); - b_TRA_Mu_p_T->GetEntry(entryNumber); - b_TRA_Mu_phi->GetEntry(entryNumber); - b_TRA_Mu_eta->GetEntry(entryNumber); - b_TRA_Tau_N->GetEntry(entryNumber); - b_TRA_Tau_pdgId->GetEntry(entryNumber); - b_TRA_Tau_p_T->GetEntry(entryNumber); - b_TRA_Tau_phi->GetEntry(entryNumber); - b_TRA_Tau_eta->GetEntry(entryNumber); - b_TRA_HadW_N->GetEntry(entryNumber); - b_TRA_HadW_pdgId->GetEntry(entryNumber); - b_TRA_HadW_p_T->GetEntry(entryNumber); - b_TRA_HadW_phi->GetEntry(entryNumber); - b_TRA_HadW_eta->GetEntry(entryNumber); - b_TRA_LepW_N->GetEntry(entryNumber); - b_TRA_LepW_pdgId->GetEntry(entryNumber); - b_TRA_LepW_p_T->GetEntry(entryNumber); - b_TRA_LepW_phi->GetEntry(entryNumber); - b_TRA_LepW_eta->GetEntry(entryNumber); - b_TRA_HadTop_N->GetEntry(entryNumber); - b_TRA_HadTop_pdgId->GetEntry(entryNumber); - b_TRA_HadTop_p_T->GetEntry(entryNumber); - b_TRA_HadTop_phi->GetEntry(entryNumber); - b_TRA_HadTop_eta->GetEntry(entryNumber); - b_TRA_LepTop_N->GetEntry(entryNumber); - b_TRA_LepTop_pdgId->GetEntry(entryNumber); - b_TRA_LepTop_p_T->GetEntry(entryNumber); - b_TRA_LepTop_phi->GetEntry(entryNumber); - b_TRA_LepTop_eta->GetEntry(entryNumber); - b_TRA_Bot_N->GetEntry(entryNumber); - b_TRA_Bot_pdgId->GetEntry(entryNumber); - b_TRA_Bot_p_T->GetEntry(entryNumber); - b_TRA_Bot_phi->GetEntry(entryNumber); - b_TRA_Bot_eta->GetEntry(entryNumber); - b_TRA_LQ_N->GetEntry(entryNumber); - b_TRA_LQ_pdgId->GetEntry(entryNumber); - b_TRA_LQ_p_T->GetEntry(entryNumber); - b_TRA_LQ_phi->GetEntry(entryNumber); - b_TRA_LQ_eta->GetEntry(entryNumber); - } - if (TA_Active) { - b_TA_Tru_p_T->GetEntry(entryNumber); - b_TA_Tru_phi->GetEntry(entryNumber); - b_TA_Tru_eta->GetEntry(entryNumber); - b_TA_Tru_pdgId->GetEntry(entryNumber); - b_TA_Tru_barcode->GetEntry(entryNumber); - } -} - -void ntupleXML::SetActiveFile(Int_t fileNumber) { - if (activeFile != fileStore[fileNumber]) { - activeFile = fileStore[fileNumber]; - if (Warn>1) { std::cout << "\nntupleXML: Setting New Active Tree. "; } - //Associates branches with their variables - ntupleXML::SetBranches(); - } -} - -template<typename TYPE> -std::string ntupleXML::asString(const TYPE& x) { - std::ostringstream o; - o << std::setiosflags(ios::fixed); - if (!(o << x)) { - if (Warn>0) { std::cout << "\nntupleXML: Error in toString Conversion Function. "; } - return "ERROR"; - } - return o.str(); -} - diff --git a/graphics/AtlantisJava/share/specificconfig.jnlp b/graphics/AtlantisJava/share/specificconfig.jnlp deleted file mode 100644 index 46f896703eedf76ed13f010518defebe4945c995..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/share/specificconfig.jnlp +++ /dev/null @@ -1,83 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Template JNLP webstart file for Atlantis event display for ATLAS - with specific configuration file. --> -<jnlp - spec="1.0+" - codebase="@CODEBASE@" - href="@HREF@"> - <information> - <title>Atlantis event display for ATLAS</title> - <vendor>Atlantis team</vendor> - <homepage href=""/> <!-- should be used from codebase --> - <description>Atlantis event display for ATLAS</description> - <!-- <icon href="files/goofy_favicon.ico"/> - <icon kind="splash" href="files/logo.gif"/> --> - <offline-allowed/> - <shortcut online="false"> - <desktop/> - <menu submenu="Atlantis event display"/> - </shortcut> - </information> - <security> - <all-permissions/> - </security> - <resources> - <j2se version="1.6+" max-heap-size="512m"/> - - <jar href="lib/commons-cli-1.0.jar"/> - <jar href="lib/Jama.jar"/> - <jar href="lib/jas-aida-dev.jar"/> - <jar href="lib/jas-aida.jar"/> - <jar href="lib/jas-freehep-base.jar"/> - <jar href="lib/jas-freehep-hep.jar"/> - <jar href="lib/jas-jas-plotter.jar"/> - <jar href="lib/jas-jel.jar"/> - <jar href="lib/jas-JMinuit.jar"/> - <jar href="lib/jogl.jar"/> - <jar href="lib/jh.jar"/> - <jar href="lib/oncrpc.jar"/> - <jar href="lib/log4j-1.2.15.jar"/> - <jar href="lib/ostermillerutils_1_05_00.jar"/> - <jar href="lib/wired-base-4.0.beta.3-SNAPSHOT.jar"/> - <jar href="lib/ws-commons-util-1.0.2.jar"/> - <jar href="lib/xercesImpl.jar"/> - <jar href="lib/xml-apis.jar"/> - <jar href="lib/xmlrpc-client-3.1.jar"/> - <jar href="lib/xmlrpc-common-3.1.jar"/> - <jar href="lib/jlibeps.jar"/> - <jar href="lib/xmlrpc-server-3.1.jar"/> - <jar href="lib/commons-logging-1.1.jar"/> - <jar href="lib/commons-codec-1.4.jar"/> - <jar href="lib/xml-apis-ext.jar"/> - <jar href="lib/batik-dom.jar"/> - <jar href="lib/batik-anim.jar"/> - <jar href="lib/batik-svggen.jar"/> - <jar href="lib/batik-css.jar"/> - <jar href="lib/batik-bridge.jar"/> - <jar href="lib/batik-parser.jar"/> - <jar href="lib/batik-xml.jar"/> - <jar href="lib/batik-gui-util.jar"/> - <jar href="lib/batik-script.jar"/> - <jar href="lib/batik-transcoder.jar"/> - <jar href="lib/batik-svg-dom.jar"/> - <jar href="lib/batik-extension.jar"/> - <jar href="lib/batik-codec.jar"/> - <jar href="lib/batik-util.jar"/> - <jar href="lib/batik-swing.jar"/> - <jar href="lib/batik-ext.jar"/> - <jar href="lib/batik-gvt.jar"/> - <jar href="lib/batik-awt-util.jar"/> - <jar href="help/help.jar"/> - - <jar href="atlantis.jar" main="true"/> <!-- look for main class here --> - </resources> - - <application-desc main-class="atlantis.Atlantis"> - <argument>--config</argument> - <argument>configuration/@CONFIG@</argument> - <argument>--debug</argument> - <argument>DEBUG</argument> - </application-desc> - -</jnlp> - diff --git a/graphics/AtlantisJava/src/atlantis/ACommandLine.java b/graphics/AtlantisJava/src/atlantis/ACommandLine.java deleted file mode 100644 index 3c87dcf910629763dc4915c2b03cefc53a71339e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/ACommandLine.java +++ /dev/null @@ -1,399 +0,0 @@ -package atlantis; - -import atlantis.event.AEpsImageProducer; -import atlantis.event.AImageProducer; -import atlantis.event.AEventSource; -import atlantis.event.APngImageProducer; -import atlantis.event.ASvgImageProducer; -import atlantis.globals.AGlobals; -import atlantis.gui.AGUI; -import atlantis.utils.ALogger; -import atlantis.utils.AMath; -import java.awt.Dimension; -import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.GnuParser; -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.OptionBuilder; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.ParseException; - -/** - * This package-private class holds all the command line options - * as well as providing verification - * @author Sebastian Boeser - */ -class ACommandLine { - - //A help formatter - private final HelpFormatter formatter = new HelpFormatter(); - - private AGlobals globals = AGlobals.instance(); - - //The set of command-line options - private final Options options = new Options(); - - //The usage line - private static final String usage = "Atlantis [OPTIONS] [[-s]SOURCE]"; - - //The help message header and footer - private final String headerMsg; - private final String footerMsg; - - - /** - * Create all the options in the constructor. Options are sorted alphabetically in here. - */ - ACommandLine(){ - - //show HLTAutokey tracks - options.addOption(new Option("a", false, "show HLTAutoKey tracks")); - - //configuration file - options.addOption(OptionBuilder.withArgName("file") - .hasArg() - .withDescription("read configuration from specified file") - .withLongOpt("config") - .create("c") - ); - - - //debug - String debugDescr = "log messages of level to " + - "'stdout', optionally to file destination. " + - "Message levels are "+ ALogger.getStringLevels() + " (INFO is default)"; - options.addOption(OptionBuilder - .hasArg() - .hasOptionalArg() - .withArgName("level [destination]") - .withDescription(debugDescr) - .withLongOpt("debug") - .create('d') - ); - - - //help/usage - options.addOption(new Option("h", "help", false, "display this help message")); - - //demo mode - options.addOption(OptionBuilder.withArgName("projections") - .hasOptionalArg() - .withDescription("colon seperated list of projections for the demo mode (e.g \"-j YX:VP\"). " - + "Available projections/actions are YX, " - + "VP(" + AMath.PHI + AMath.ETA + "), " - + "RZ(" + AMath.RHO + "Z), " - + "FR(" + AMath.PHI + AMath.RHO + "), " - + "FZ(" + AMath.PHI + "Z), " - + "XZ(X'Z), " - + "YZ(Y'Z), " - + "LegoPlot, " - + "NE(next event)") - .withLongOpt("projection") - .create("j") - ); - - //loop mode - String loopDescr = "Set event navigation mode, supported values are " - +AEventSource.NavigationMode.LOOP.toString()+", " - +AEventSource.NavigationMode.RANDOM.toString()+", " - +AEventSource.NavigationMode.SEQUENTIAL.toString(); - options.addOption(OptionBuilder.withArgName("mode") - .hasArg() - .withDescription(loopDescr) - .withLongOpt("loop") - .create("l") - ); - - //color map - options.addOption(OptionBuilder.withArgName("file") - .hasArg() - .withDescription("read colourmap from specified file") - .withLongOpt("colormap") - .create("m") - ); - - // output image files - String outputDescr = "Output event image " + - "into directory dir (default: current directory) "+ - "of dimensions width x height (default: 800x828). "+ - "If height is not specified the aspect ratio of the canvas is used. " + - "If scale is given, images will be scaled by that factor (use for thumbnails). "+ - "If a filename is given, that file will be overwritten, "+ - "otherwise a new file will be created for each event. "+ - "The output format may be specified as PNG (the default) or EPS using" + - "the --outputformat option."; - options.addOption(OptionBuilder.hasOptionalArgs(4) - .withArgName("[dir] [width[xheight]] [scale] [filename]") - .withDescription(outputDescr) - .withLongOpt("output") - .create('o') - ); - - String outputFormatDescr = "output format for -o option (eps or png, default is png)"; - options.addOption(OptionBuilder.hasArg() - .withArgName("format") - .withDescription(outputFormatDescr) - .withLongOpt("outputformat") - .create('f') - ); - - //event loop intervall - options.addOption(OptionBuilder.withArgName("seconds") - .hasArg() - .withDescription("pause inbetween events and/or projections options") - .withLongOpt("pause") - .create("p") - ); - - //default source - String sourceDescr = "Set initial event source, e.g\n"+ - "* [file://]<filename>\n"+ - "* http://<url>\n"+ - "* xmlrpc://<server>:<port>\n"+ - "* oncrpc://<server>[:port][:stream]"; - options.addOption(OptionBuilder.withArgName("source") - .hasArg() - .withDescription(sourceDescr) - .withLongOpt("source") - .create("s") - ); - - //update config - options.addOption(new Option("x", "updateconfig", false, "update user's configuration file")); - - //max GUI width - options.addOption(OptionBuilder.withArgName("maxwidth") - .hasArg() - .withDescription("maximum screen width used by Atlantis") - .withLongOpt("maxwidth") - .create("w") - ); - - - //image server - options.addOption(OptionBuilder.hasArgs(1) - .withArgName("port") - .withDescription("Run a server on port <port> which accepts " + - "event data from a client and returns images") - .withLongOpt("imgserver") - .create('I') - ); - - - /** - * Now create header and footer Messages - */ - headerMsg = "\nMandatory arguments to long options are " + - "mandatory for short options too.\n"; - footerMsg = "\nAtlFast objects were supported up to " + - "AtlantisJava-09-05-28 via \"Fast\" option.\n" + - "Beginner simplified GUI was supported up to " + - "AtlantisJava-09-05-28 via \"Beginner\" option.\n" + - "CTB 2004 geometry was supported up to " + - "AtlantisJava-09-07-42 via -t, --testbeam option.\n"; - - } - - /** - * Parse and validate the command line options - */ - void process(String[] args){ - - //Create GNU style parse - CommandLineParser parser = new GnuParser(); - - //Now try parsing the options - try { - - //invoke GNU parser - CommandLine cmdLine = parser.parse(options, args); - - /** - * Now validate and process all options - */ - - //auto-keys - if(cmdLine.hasOption('a')) globals.setHLTAutoKeys(true); - - //config - if(cmdLine.hasOption('c')){ - Atlantis.configCommandLine = cmdLine.getOptionValue('c', null); - } - - //debug - if(cmdLine.hasOption('d')){ - //Get option values - String[] vals = cmdLine.getOptionValues('d'); - //this arg will always be there - String level = vals[0]; - if (! ALogger.getStringLevels().contains(level)) - throw new ParseException("Invalid logging level "+level); - //Check if there was also another argument - String destination = null; - if(vals.length == 2) destination = vals[1]; - - //Finally initialize the logger - ALogger.initialize(level,destination); - } - - //help - if(cmdLine.hasOption('h')) { - formatter.printHelp(usage, headerMsg, options, footerMsg); - System.exit(0); - } - - //image server - if(cmdLine.hasOption('I')){ - Atlantis.imageServerPort = Integer.parseInt(cmdLine.getOptionValue('I')); - if (Atlantis.imageServerPort < 0) - throw new ParseException("Port number "+cmdLine.getOptionValue('I')+ - " is not valid for -I option"); - //Check for other mutual exclusive options - if (cmdLine.hasOption('j') || cmdLine.hasOption('p')) - throw new ParseException("Can not use option -I with -j or -p options"); - } - - //demo mode projections - if(cmdLine.hasOption('j')){ - //NOTE: default is not null but "", so we can distinguish inbetween - //this flag being set or not w/o introducing more parameters - Atlantis.selectedProjections = cmdLine.getOptionValue('j', ""); - } - - //navigation mode - if(cmdLine.hasOption('l')){ - //Get arguments - String loopMode = cmdLine.getOptionValue('l',null); - if (loopMode == null) - throw new ParseException("Option -l needs an argument"); - Atlantis.initialMode = AEventSource.NavigationMode.valueOf(loopMode); - } - - - //color map - if(cmdLine.hasOption('m')){ - // retrieve the argument for options or assign default value - Atlantis.colormapCommandLine = cmdLine.getOptionValue('m', null); - } - - // generate PNG/EPS output files - if(cmdLine.hasOption('o')) - { - String format = "PNG"; - if (cmdLine.hasOption('f')) { - String formatVal = cmdLine.getOptionValue('f'); - format = formatVal.toUpperCase(); - if (!("EPS".equals(format)||"PNG".equals(format))) { - throw new ParseException("Invalid output format "+formatVal); - } - } - String[] vals = cmdLine.getOptionValues('o'); - this.processImageOutputOptions(vals,format); - } - - // generate PNG output files - if(cmdLine.hasOption('e')) - { - String[] vals = cmdLine.getOptionValues('e'); - this.processImageOutputOptions(vals,"EPS"); - } - - //source - if (cmdLine.hasOption('s')){ - //Simply set this as default event source - Atlantis.initialEventSource = cmdLine.getOptionValue('s'); - } - - //pause - if (cmdLine.hasOption('p')){ - //Check for integer value - String val = cmdLine.getOptionValue('p', null); - try { - Atlantis.loopInterval = Integer.parseInt(val); - } catch (NumberFormatException nfe) { - throw new ParseException("Invalid seconds value "+val+" for -p option"); - } - } - - //GUI width - if(cmdLine.hasOption('w')){ - String val = cmdLine.getOptionValue('w', null); - try { - int maxWidth = Integer.parseInt(val); - AGUI.getGUI().setMaxWidth(maxWidth); - } catch (NumberFormatException e) { - throw new ParseException("Invalid width value "+val+" for -w option"); - } - } - - //update config - if(cmdLine.hasOption('x')) Atlantis.updateConfig = true; - - //finally check for positional options (i.e w/o --opt) - String[] unspecifiedOpts=cmdLine.getArgs(); - if (unspecifiedOpts.length > 0){ - //We accept only one, which is a single string for the event source - if ((unspecifiedOpts.length != 1) - || cmdLine.hasOption('s') - || cmdLine.hasOption('I')){ - throw new ParseException("Can only specify one event source"); - } - Atlantis.initialEventSource = unspecifiedOpts[0]; - } - - } catch(ParseException ex) { - //Every error above should have thrown a parse exception - //Show help message and exit - System.err.println("\n" + ex.getMessage() + "\n"); - formatter.printHelp(usage, headerMsg, options, footerMsg); - System.exit(1); - } - - } - - private void processImageOutputOptions(String[] vals, String fileFormat) throws ParseException { - try - { - //vals[0] - directory to store events and png into - //Use current directory as default - String dir=System.getProperty("user.dir"); - if ((vals!=null)&&(vals.length > 0)) dir = vals[0]; - // vals[1] - WidthxHeight string - Dimension dim=new Dimension(800,828); - if ((vals!=null)&&(vals.length > 1)){ - short width = Short.parseShort(vals[1].split("x")[0]); - short height =-1; - if (vals[1].split("x").length > 1) - height = Short.parseShort(vals[1].split("x")[1]); - dim = new Dimension(width,height); - } - // vals[2] - scale factor, default is one - double scale = 1; - if ((vals!=null)&&(vals.length > 2)) scale = Double.parseDouble(vals[2]); - // vals[3] - fixed filename, default is null - String fixedFile = null; - if ((vals!=null)&&(vals.length > 3)) fixedFile = vals[3]; - //Now create a new image generator - if ("EPS".equals(fileFormat)) { - Atlantis.imageProducer = new AEpsImageProducer(dir,dim,scale,fixedFile); - } - else if ("PNG".equals(fileFormat)) { - Atlantis.imageProducer = new APngImageProducer(dir,dim,scale,fixedFile); - } - else if ("SVG".equals(fileFormat)) { - Atlantis.imageProducer = new ASvgImageProducer(dir,dim,scale,fixedFile); - } - else { - throw new Error("Invalid file format for output: "+fileFormat); - } - } catch (NumberFormatException nfe){ - throw new ParseException("Invalid parameters to option -o"); - } catch (IndexOutOfBoundsException iob){ - throw new ParseException("Invalid dimension parameter to option -o"); - } catch (AImageProducer.InstantiationException iex){ - throw new ParseException("Invalid configuration for option -o: "+iex.getMessage()); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/AOpenGLTools.java b/graphics/AtlantisJava/src/atlantis/AOpenGLTools.java deleted file mode 100644 index 02cbf863cc997c6425eceea6d89f7b19151f4ebd..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/AOpenGLTools.java +++ /dev/null @@ -1,22 +0,0 @@ -package atlantis; - -import javax.media.opengl.GLCanvas; -import javax.media.opengl.GLCapabilities; - -/** - * Provides utility method to check if OpenGL is available. - * @author Adam - */ -public class AOpenGLTools { - - public static boolean isOpenGLAvailable() { - try { - GLCapabilities cap = new GLCapabilities(); - GLCanvas canv = new GLCanvas(cap); - } catch (Error e) { - // Expect some kind of hard exception if the class can't be loaded - return false; - } - return true; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/Atlantis.java b/graphics/AtlantisJava/src/atlantis/Atlantis.java deleted file mode 100644 index e54be406c3aa9f2bc4c629ff9db544b39ea18beb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/Atlantis.java +++ /dev/null @@ -1,770 +0,0 @@ -package atlantis; - -import java.awt.Toolkit; -import java.io.File; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; - -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.dom.Node; -import org.w3c.dom.Document; - -import atlantis.canvas.ACanvas; -import atlantis.config.ADefaultValues; -import atlantis.config.AConfigUpdater; -import atlantis.event.AEventManager; -import atlantis.event.AEventSource.InvalidEventSourceException; -import atlantis.event.AEventSource.NoMoreEventsException; -import atlantis.event.AEventSource.ReadEventException; - -import atlantis.geometry.AAtlasDetector; -import atlantis.geometry.ADetectorSystem; -import atlantis.globals.AGlobals; -import atlantis.graphics.colormap.AColorMap; -import atlantis.gui.ADemoDialog; -import atlantis.gui.AEventQueue; -import atlantis.gui.AGUI; -import atlantis.gui.AStartupWindow; -import atlantis.gui.AEventLoopDialog; -import atlantis.output.AExceptionHandler; -import atlantis.parameters.APar; -import atlantis.projection.AProjectionsManager; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AUtilities; -import atlantis.utils.xml.AXMLErrorHandler; -import atlantis.utils.xml.AXMLEntityResolver; -import atlantis.utils.xml.AXMLUtils; -import atlantis.event.AImageProducer; -import atlantis.event.AEventSource; -import atlantis.utils.ALogger; -import atlantis.event.xmlrpc.AServerXMLRPC; -import atlantis.event.xmlrpc.AServerXMLRPCEventSource; -import atlantis.gui.ACrashReporter; -import atlantis.gui.ADemoLoop; -import atlantis.interactions.AInteractionsConfigReader; -import atlantis.utils.ANewIdHelper; -import atlantis.utils.xml.AXMLEntityResolver; - -import java.util.Arrays; -import java.util.Vector; -import javax.swing.JOptionPane; - - -/** - * Main class of Atlantis application. - * Initialises the application's main components and provides access to them. - */ -public class Atlantis -{ - // The main class logger gets initialized after command line options - // are processed. All other classes will just do - // logger = ALogger.getLogger(Class.class) in their attribute definitions - private static ALogger logger = null; - - /** Store for Atlantis global state. */ - private static AGlobals globals = AGlobals.instance(); - - // expands into SVN tag - private static String versionAtlantisJava = "$HeadURL: file:///atlas/scratch0/graemes/ao-mirror/graphics/AtlantisJava/tags/AtlantisJava-09-16-05-18/src/atlantis/Atlantis.java $"; - - private static final String FILE_SEPAR = System.getProperty("file.separator"); - private static final String USER_HOME_DIR = System.getProperty("user.home"); - - // This is the URL that is used as default for "Read events from URL" - // The stream is set to "Default" as this is the only one guaranteed to be there. - private static final String LIVE_POINT_1_EVENTS_URL = - "http://atlas-live.cern.ch/event_files/Default"; - - // expected file name of the user customised configuration file - // (stored in the user's home directory) - private static final String USER_CONFIG_FILE_PATH = - USER_HOME_DIR + FILE_SEPAR + ".Atlantis-config.xml"; - - // configuration file from the Atlantis distribution (default config) - private static final String DISTRIB_DEFAULT_CONFIG_FILE = - "configuration" + FILE_SEPAR + "config.xml"; - - // this is checksum file of the distribution's main configuration file - // if it doesn't match, Atlantis tries to update user's configuration - // or the --config <configfile> configuration - // it is an indicator that the master config.xml changed - private static final String CONFIG_CHECKSUM_FILE_PATH = - USER_HOME_DIR + FILE_SEPAR + ".Atlantis-config.chk"; - - // limit the total width of Atlantis to this number of pixels (0 = screen width) - private static int MAX_WIDTH = 0; - - /** - * The list of parameters that can be set from the command line - */ - // force Atlantis to update the personal configuration file - protected static boolean updateConfig = false; - // configuration file specified as command line argument - protected static String configCommandLine = null; - // colormap file specified as command line argument - protected static String colormapCommandLine = null; - // selected projections specified as command line argument for demo mode - protected static String selectedProjections = null; - // timer delay from command line for reading events in a loop - protected static Integer loopInterval = null; - // navigation mode from command line - protected static AEventSource.NavigationMode initialMode = null; - // initial event source, may be specified from command line - protected static String initialEventSource = "events"+FILE_SEPAR+"test_events.zip"; - // Object for saving event images in a directory - protected static AImageProducer imageProducer = null; - // Port number for image server from command line - protected static int imageServerPort = -1; - - private static final boolean atlantisWithOpenGL = false; - - private static final String INIT_ERROR_MSG = - "Error during Atlantis initialization.\n" + - "(configuration file related issues might be\n" + - "corrected by running with -x (updating customised configuration)).\n" + - "See console output for more information."; - - // main Atlantis components - private static APar parameterStore = null; - private static AEventManager eventManager = null; - private static ADetectorSystem detector = null; - private static ACanvas canvas = null; - private static AGUI gui = null; - - /** - * Returns the delay for timer for automatic event reading from server - * when this option was specified as command line argument - * @return the delay in seconds - */ - private static Integer getLoopInterval() - { - return loopInterval; - } - - - /** - * Set the default java look and feel ("metal") - */ - private static void setLookAndFeel() - { - try { - UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); - } catch(Exception e) { - AExceptionHandler.processException("Error setting default Look and Feel", e); - } - } - - - /** - * Check if the checksum file CONFIG_CHECKSUM_FILE_PATH is up-to-date. - * Create one if it does not exist or update it if it is not up-to-date. - */ - private static void checkAndUpdateConfigCheckSumFile(String distribFile) - throws AAtlantisException - { - if(Atlantis.updateConfig) - { - logger.info("Checksum not checked, run with -x, configuration update " + - "forced anyway."); - return; - } - - logger.info("Checking if the used configuration is up-to-date ..."); - - logger.debug("Checking checksum of the configuration file from the " + - "Atlantis distribution: " + distribFile); - logger.debug("Checksum file: " + CONFIG_CHECKSUM_FILE_PATH); - - boolean checkSumExists = new File(CONFIG_CHECKSUM_FILE_PATH).exists(); - - if(checkSumExists) - { - boolean comparison = AConfigUpdater.compareChecksums(distribFile, - CONFIG_CHECKSUM_FILE_PATH); - if(comparison) - { - logger.debug("Checksum file - checksum match, no update necessary."); - Atlantis.updateConfig = false; - return; - } - } - - // doesn't match, force update of custom configuration - // and re-generate checksum - AConfigUpdater.createChecksumFile(distribFile, CONFIG_CHECKSUM_FILE_PATH); - logger.debug("Checksum didn't match, updating customised " + - "configuration forced."); - Atlantis.updateConfig = true; - - } // checkAndUpdateConfigCheckSumFile() --------------------------------- - - - - /** - * Returns InputStream to read XML application configuration from. - * - * Evaluates sources from which Atlantis XML configuration is - * possibly loaded from (prioritised): - * 1) -c, --config <configfile.xml> specified on the command line - * here available in configCommandLine variable - * 2) if USER_CONFIG_FILE_PATH exists, read that one - * 3) or eventually read <ATLANTIS_DIRECTORY>/DISTRIB_DEFAULT_CONFIG_FILE - * - * User's customised (in the home directory) or --config <configfile> are - * also tried to be updated when the checksum configuration file doesn't - * match. Atlantis calculates checksum of the main distribution - * configuration file and stores that checksum in CONFIG_CHECKSUM_FILE_PATH. - * If this checksum doesn't match when Atlantis is run on the user's - * home directory configuration or --config <configfile> configuration, - * automatic configuration file update process is executed. - * - * Updating means that config.xml (main, base) contains some changes - * which are not consistent with the user's config or custom config - * and they need to be propagated there. - * Update process: - * AConfigUpdater.updateConfigurationFile(distribFilePath, configToUse) - * is then executed. - * - * Do not try to update custom configuration which is located in the same - * directory as the base config file - it means that such custom config - * comes with AtlantisJava distribution - no need updating this one. - */ - private static InputStream getXMLConfigAsStream() throws Exception - { - String configToUse = null; - - logger.info("Reading the XML configuration ..."); - - // configuration file from the Atlantis distribution - String distribFilePath = getHomeDirectory() + DISTRIB_DEFAULT_CONFIG_FILE; - - // distribution config file checksum only taken into account when having - // --config command line argument or when running from user's (home - // directory) configuration - - // option / source 1) - command line argument - highest priority - if(configCommandLine != null) - { - logger.info("Using configuration file specified on the command " + - "line: " + configCommandLine); - // sets Atlantis.updateConfig = true; accordingly - checkAndUpdateConfigCheckSumFile(distribFilePath); - configToUse = configCommandLine; - } - else - { - // check if we can read the user configuration file (in home dir.) - // option / source 2) - if(new File(USER_CONFIG_FILE_PATH).exists()) - { - logger.info("Using user's configuration file: " + - USER_CONFIG_FILE_PATH); - // sets Atlantis.updateConfig = true; accordingly - checkAndUpdateConfigCheckSumFile(distribFilePath); - configToUse = USER_CONFIG_FILE_PATH; - } - else - { - // // option / source 3) - logger.info("Using distribution configuration file: " + - distribFilePath); - if(Atlantis.updateConfig) - { - logger.warn("Update custom configuration flag is set, " + - "that doesn't make sence - no custom config " + - "file available, ignored."); - Atlantis.updateConfig = false; - } - configToUse = distribFilePath; - } - } - - - try - { - // try to update custom configuration before loading it - if(Atlantis.updateConfig) - { - logger.info("Updating customised configuration file ..."); - // check if configToUse comes from atlantis home directory, if - // so, then configToUse is from AtlantisJava distribution, should - // already be up-to-date and no automatic update will be performed - String atlantisHome = Atlantis.getHomeDirectory(); - String customConfigDir = new File(configToUse).getAbsolutePath(); - - logger.info("Updating configuration - customised config directory: " + - customConfigDir); - // if configToUse comes from AtlantisJava distribution, customConfigDir - // path start with atlantisHome path plus 'configuration' directory - // (does not filter off webstart since .getHomeDirectory() - // returns user's home directory when running via webstart, - // the condition below should be improved to cover webstart situation - // as well ...) - if(customConfigDir.startsWith(atlantisHome)) - { - logger.debug("Updating configuration - Atlantis home: " + atlantisHome); - logger.info("Updating configuration - customised config directory " + - "is in the Atlantis home, no need updating it."); - } - else - { - AConfigUpdater.updateConfigurationFile(distribFilePath, - configToUse); - } - } - } - catch(AAtlantisException aae) - { - logger.error(aae.getMessage()); - } - - - InputStream isConfig = null; // configuration file input stream - try - { - isConfig = AUtilities.getFileAsStream(configToUse); - } - catch(AAtlantisException aae) - { - String m = "Could not read " + configToUse + " reason: " + - aae.getMessage(); - throw new Exception(m); - } - - logger.info("Going to parse XML configuration: " + configToUse); - return isConfig; - - } // getXMLConfigAsStream() --------------------------------------------- - - - - private static void initAtlantis() { - - String homeDirectory = Atlantis.getHomeDirectory(); - globals.setHomeDirectory(homeDirectory); - - //Create startup window and set how often - //the progress bar will get update below - AStartupWindow startupWin = new AStartupWindow(9); - - try { - System.setProperty("sun.awt.exception.handler", - "AExceptionHandler"); - - startupWin.updateText("Atlantis initialisation"); - - //Show atlantis home - logger.info("Atlantis home: "+homeDirectory); - - //Create an event manager - eventManager = AEventManager.instance(); - - // reading Atlantis runtime configuration (text file in the home directory) - logger.info("Reading Atlantis runtime configuration, file: " + - ADefaultValues.CONFIGFILE); - ADefaultValues.readRuntimeValues(); - - - // read the configuration xml files ------------------------- - startupWin.updateText("Reading Atlantis configuration"); - - // evaluate configuration sources options and get the configuration - InputStream isConfig = getXMLConfigAsStream(); - - // prepare XML parser for parsing the XML configuration - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setValidating(true); - DocumentBuilder parser = factory.newDocumentBuilder(); - parser.setErrorHandler(new AXMLErrorHandler()); - parser.setEntityResolver(new AXMLEntityResolver()); - - // parse the XML configuration - String configBase = homeDirectory + FILE_SEPAR + "configuration" + FILE_SEPAR; - Document xmlConfigDoc = parser.parse(isConfig, configBase); - Node rootNode = xmlConfigDoc.getDocumentElement(); - // read the XML initialization node, and performs initialization - Node initializationNode = AXMLUtils.getChild(rootNode, "Initialization"); - - // parse the ID dictionary - String geometryBase = homeDirectory + FILE_SEPAR + "geometry" + FILE_SEPAR; - InputStream isIdDict = AUtilities.getFileAsStream(geometryBase+"ATLAS_IDS.xml"); - Document xmlDictDoc = parser.parse(isIdDict, geometryBase); - ANewIdHelper.construct(xmlDictDoc.getDocumentElement()); - - - // read colour map (colormap.xml) configuration ----------------- - startupWin.updateText( "Reading colour map"); - AColorMap.readColorMap(Atlantis.colormapCommandLine); - - - // creating canvas ---------------------------------------------- - startupWin.updateText("Building canvas and projections"); - Node canvasNode = AXMLUtils.getChild(initializationNode, "Canvas"); - canvas = ACanvas.construct(canvasNode); - - // reading parameters ------------------------------------------ - logger.info("Building parameters"); - parameterStore = APar.construct(AXMLUtils.getChild(rootNode, "Parameters")); - parameterStore.update(AXMLUtils.getChild(rootNode, "ParameterDifferences")); - eventManager.addNewEventListener(parameterStore); - // creating the Projections Manager (reading the projections) - Node interactionsNode = - AXMLUtils.getChild(initializationNode, "Interactions"); - AInteractionsConfigReader.readInteractions(interactionsNode); - AProjectionsManager.initialise(); - - //set the output flag: 0 normal 1 eta/phi/pt 2 px/py/pz 3 eta/phi/pt/px/py/pz - if(parameterStore.get("Minerva","alternativesimpleoutput").getStatus()){ - if(parameterStore.get("Minerva","simpleoutput").getStatus()){ - globals.setSimpleOutput(3); - }else{ - globals.setSimpleOutput(2); - } - }else if(parameterStore.get("Minerva","simpleoutput").getStatus()){ - globals.setSimpleOutput(1); - } - - // reading the geometry ---------------------------------------- - startupWin.updateText("Reading geometry"); - String geomPrefix = Atlantis.getHomeDirectory() + "geometry" + - Atlantis.FILE_SEPAR; - String geomName = ADefaultValues.get("GeometryName"); - if (!"".equals(geomName)) { - // name of the geometry considered after underscore - geomName = "_" + geomName; - - // do the geometry files exist - just try loading the files - String geomNameFull1 = geomPrefix + "AGeometry" + geomName + ".xml"; - String geomNameFull2 = geomPrefix + "AMuonGeometry" + geomName + ".xml"; - try { - // just accessibility test - @SuppressWarnings("unused") - InputStream i = AUtilities.getFileAsStream(geomNameFull1); - i = AUtilities.getFileAsStream(geomNameFull2); - i = null; - } catch (AAtlantisException ae) { - geomName = ""; // will fall back to default geometry - } - } - String geomIdCalo = geomPrefix + "AGeometry" + geomName + ".xml"; - String geomMuon = geomPrefix + "AMuonGeometry" + geomName + ".xml"; - detector = new AAtlasDetector(geomIdCalo, geomMuon); - AAtlasDetector.setDetector(detector); - - canvas.finalizeConstruction(); - canvas.readCorners(AXMLUtils.getChild(rootNode, "WindowCorners")); - // This is needed here, design should be changed to remove this problem - canvas.setCurrentWindow(canvas.getCurrentWindowName()); - - //Add the canvas as a NewEvent event listener - eventManager.addNewEventListener(canvas); - - // reading the first event -------------------------------------- - startupWin.updateText("Reading initial event"); - getInitialEvent(); - - // displaying GUI, Canvas --------------------------------------- - startupWin.updateText("Displaying GUI and Canvas"); - - // update colors to those selected in the config file - AColorMap.setColorMap(parameterStore.get("Prefs", "ColorMap").getI()); - // NB: must calculate the size of GUI after calling - // canvas.setVisible(true), in which the real final size of Canvas - // will be calculated - canvas.setCanvasVisible(true); - - // Now the canvas is on the screen and have a size, check if we need - // to rework the aspect ratio on YX projections at all as is the case - // when going to control room projectors for example - AD - canvas.correctAspectRatios(); - - //Create the GUI - gui = AGUI.getGUI(); - - //If we got one, show it (e.g. not in headless mode) - if (gui != null){ - gui.setMaxWidth(MAX_WIDTH); - gui.setName("Atlantis GUI"); // Name is used by JUnit/FEST tests - // Tell the parameter store about the GUI so it can inform the GUI of parameter changes - parameterStore.addParameterChangeListener(gui); - //Display it - gui.setVisible(true); - // and register as a layout change listener - canvas.addOverlay(); - canvas.addLayoutChangeListener(gui); - } - - //Before starting any loops, inform user we are ready to go - startupWin.updateText("Atlantis Ready"); - - // Set the navigation mode if given on the command line. - // Use SwingUtilities.invokeLater() to "defer until all pending events - // have been processed", avoiding the deadlock that otherwise occurs. - if (Atlantis.initialMode != null){ - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - try { - eventManager.setNavigationMode(initialMode); - } catch (InvalidEventSourceException e) { - logger.error("Invalid event source", e); - } - } - }); - } - - //Set up event loop if requested - if ((Atlantis.loopInterval != null) - && (Atlantis.selectedProjections == null ) - && (!AGlobals.isAtlantisHeadless()) ) { - // A loop interval has been given, but no projections - - // so create an event loop dialog, but not in headless mode - AEventLoopDialog dialog = AEventLoopDialog.getInstance(); - - //set all properties - dialog.setUpdateInterval(getLoopInterval()); - dialog.showDialog(); - dialog.startEventLoop(); - } - - //setup demo loop if requested - if (Atlantis.selectedProjections != null) { - //If user just gave -j, use default settings - if (Atlantis.selectedProjections.equals("")) - ADemoDialog.getInstance().setDefaultSequence(); - //User may also give the update interval - if (getLoopInterval() != null) - ADemoDialog.getInstance().setTimerInterval(getLoopInterval()); - ADemoDialog.getInstance().setVisible(true); - ADemoDialog.getInstance().startDemo(); - } - - //Add an image server if requested on the command line - if (imageServerPort >= 0) { - AServerXMLRPC serv = new AServerXMLRPC(imageServerPort, AServerXMLRPCEventSource.class); - serv.start(); - } - - //If we have a image saver, add it now as new event listener - if (imageProducer != null){ - eventManager.addNewEventListener(imageProducer); - //if we are also running in headless mode, add an automatic event loop - if (AGlobals.isAtlantisHeadless()){ - //Check whether the event source is a file or an ONCRPC server - //For a server, start the loop in a "try hard" mode, i.e only stop on ReadEventException - boolean stopOnFailure = !(eventManager.getEventSource() instanceof atlantis.event.oncrpc.AONCRPCEventSource ); - //If a loop interval is given on the command line, use it, - //otherwise, run in "as fast as can mode" - int sleepTime = (Atlantis.loopInterval != null) ? Atlantis.loopInterval*1000 : 0; - //Show warning in case of "as fast as we can mode" - if (sleepTime == 0) logger.info("No loop intervall given - processing events as fast as possible"); - //Now create the loop - ADemoLoop loop = new ADemoLoop(sleepTime,new Vector<String>(Arrays.asList("NE")),stopOnFailure); - //And start it right away - loop.startDemoLoop(); - //also wait for it to finish before the program finishes - synchronized (loop) { loop.wait(); } - } - } - - } catch (Exception e) { - logger.fatal(INIT_ERROR_MSG); - logger.fatal(e.getMessage(), e); - AExceptionHandler.processException(INIT_ERROR_MSG, e); - } finally { - if (startupWin != null) { - startupWin.dispose(); - } - } - - } // initAtlantis() ----------------------------------------------------- - - - protected static String getHomeDirectory() - { - // where was this class loaded from - String temp = Atlantis.class.getResource("Atlantis.class").getFile(); - - // remove "file://" or "file:" - if (temp.startsWith("file://")) { - temp = temp.substring(7); - } else if (temp.startsWith("file:")) { - temp = temp.substring(5); - } - - if(temp.indexOf("!") > -1) - { - // atlantis is in a .jar file - temp = temp.substring(0, temp.indexOf("!")); - temp = temp.replaceAll("%20", " "); - return temp.substring(0, temp.lastIndexOf('/') + 1); - } - // must be the current working directory of the user - return System.getProperty("user.dir") + FILE_SEPAR; - - } // getHomeDirectory() ------------------------------------------------- - - /** - * Process the options passed on the command line - * @param args the command line arguments - */ - private static void processCommandLineParameters(String args[]) - { - - //echo the given command line options - System.out.println("Command line arguments:"); - for(String arg : args) System.out.print(arg + " "); - System.out.println("\n"); - - //Then go and process the command line - (new ACommandLine()).process(args); - - } // processCommandLineParameters() ------------------------------------- - - - /** - * Try to read the initial event - * - from the given event source - * - from the default event - */ - private static void getInitialEvent() - { - //Get the file where the default event is stored - //if not a special source - String eventPath = Atlantis.initialEventSource; - - // if this is not a special source then consider it - // a) to be a file with relative or absolute path - // b) to be a file relative to the Atlantis directory - if (! eventPath.contains("://") ) { - //This should be a file, see if it exists - if(! new File(eventPath).exists()) { - //try prepending atlantis home directory - logger.info("File "+eventPath+" does not exist - trying in "+Atlantis.getHomeDirectory()); - eventPath = Atlantis.getHomeDirectory()+eventPath; - } - - //All non specified sources are assumed to be files - eventPath = "file://" + eventPath; - } - - //be verbose - logger.info("Reading the default event from " + eventPath); - //set the event source and read an event - try { - eventManager.setEventSource(eventPath); - eventManager.nextEvent(); - } catch (InvalidEventSourceException ies){ - //Write error message - String msg = "Can not access "+eventPath+": "+ies.getMessage(); - logger.error(msg); - //Show error dialog - if (AGlobals.isAtlantisHeadless()) return; - JOptionPane.showMessageDialog(ACanvas.getCanvas(), msg, - "Invalid Event Source",JOptionPane.ERROR_MESSAGE); - } catch (NoMoreEventsException nme){ - String msg = "No events in "+eventPath+": "+nme.getMessage(); - logger.error(msg); - //Show error dialog - if (AGlobals.isAtlantisHeadless()) return; - JOptionPane.showMessageDialog(ACanvas.getCanvas(), msg, - "No Events found",JOptionPane.ERROR_MESSAGE); - } catch (ReadEventException rex){ - String msg = "Can not read events from "+eventPath+": "+rex.getMessage(); - logger.error(msg); - //Show error dialog - if (AGlobals.isAtlantisHeadless()) return; - JOptionPane.showMessageDialog(ACanvas.getCanvas(), msg, - "Can not read event",JOptionPane.ERROR_MESSAGE); - } - } - - /** - * Get the SVN tag version from the HeadURL, which is automatically - * substituted by SVN. - */ - private static void setSVNTagInfo() - { - // SVN expands into $HeadURL: file:///atlas/scratch0/graemes/ao-mirror/graphics/AtlantisJava/tags/AtlantisJava-09-16-05-18/src/atlantis/Atlantis.java $, - // we only want the tag name - String s = Atlantis.versionAtlantisJava; - // 0) Check we are in a tagged version - if (!s.contains("tags")){ - Atlantis.versionAtlantisJava = "AtlantisJava (SVN tag n/a)"; - return; - } - // 1) Replace anything after src - s=s.substring(0,s.indexOf("/src")); - // 2) Next find the "tags" subdir and cut after that - s=s.substring(s.indexOf("tags/")+5); - //this should be the version - Atlantis.versionAtlantisJava = s; - } - - public static void main(String[] args) - { - - /** - * First thing always: say hello with a version number - */ - //Retrieve the SVN version tag number - setSVNTagInfo(); - globals.setVersion(versionAtlantisJava); - globals.setLivePoint1EventsURL(LIVE_POINT_1_EVENTS_URL); - globals.setUserConfigFile(USER_CONFIG_FILE_PATH); - globals.setUseOpenGL(atlantisWithOpenGL); - System.out.println("AtlantisJava version (SVN tag): " + Atlantis.versionAtlantisJava); - - // Any uncaught exception should be reported to the developers - Thread.setDefaultUncaughtExceptionHandler(new ACrashReporter()); - - /** - * Now run all the checks for system properties - */ - - //Now set the default look and feel - setLookAndFeel(); - - // Disable rename file/make new directory from the file chooser - UIManager.put("FileChooser.readOnly", Boolean.TRUE); - - /** - * Process the command line parameters - */ - //process args - processCommandLineParameters(args); - - //Logger can be created only after cmdl opts to catch settings - logger = ALogger.getLogger(Atlantis.class); - - //Do some OGL checks - if (Atlantis.atlantisWithOpenGL) { - logger.info("Testing for OpenGL"); - logger.info(AOpenGLTools.isOpenGLAvailable() ? "Open GL Available" : "Open GL Unavailable"); - } - - /** - * Now go and create the manifold Atlantis classes and singletons. - * Has to run on main thread so display is updated during initialization. - */ - initAtlantis(); - // Replace event queue by AEventQueue, but only after initialization. - try { - SwingUtilities.invokeAndWait(new Runnable() { - @Override - public void run() { - logger.debug("Waiting for AWT event queue to be empty."); - } - }); - } catch (InterruptedException e) { - logger.error("Interrupted while waiting for event queue.", e); - } catch (InvocationTargetException e) { - logger.error("Error while waiting for event queue.",e); - } - Toolkit.getDefaultToolkit().getSystemEventQueue().push(new AEventQueue()); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/canvas/ACanvas.java b/graphics/AtlantisJava/src/atlantis/canvas/ACanvas.java deleted file mode 100755 index 41b32a59cbc3272084d1ee6527673e673b6f0972..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/ACanvas.java +++ /dev/null @@ -1,1113 +0,0 @@ -package atlantis.canvas; - -import atlantis.event.AEvent; -import atlantis.event.ANewEventListener; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Rectangle; -import java.awt.Insets; -import java.awt.Toolkit; -import java.awt.geom.Point2D; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Stack; -import java.util.Vector; -import java.util.Set; - -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JLayeredPane; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import atlantis.globals.AGlobals; -import atlantis.graphics.ACursorFactory; -import atlantis.graphics.AIcon; -import atlantis.graphics.layout.AGridLayout; -import atlantis.parameters.APar; -import atlantis.projection.AProjectionLegoPlot; -import atlantis.utils.xml.AXMLUtils; -import atlantis.gui.AClosingConfirmationDialog; -import atlantis.gui.AInteractionToolBar; -import atlantis.gui.APreferencesControl; -import atlantis.interactions.AZMRInteraction; -import atlantis.projection.AProjection; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionEventInfo; -import atlantis.utils.ALogger; -import java.awt.Graphics; -import java.awt.event.WindowFocusListener; -import java.util.Iterator; -import javax.swing.JMenuBar; -import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -/** - * ACanvas is a singleton class that acts as a sort of WindowManager It knows the currentLayout (of the - * windows), their history and the currentWindow. It also contains the title (Menu Bar). - * Window changes are given via two letter commands e.g. "W5" inserted into the - * CommandProcessor (static). The command processor informs ACanvas. - * Each window also has its own layer that is stored in a JLayeredPane object. - */ -public class ACanvas extends JPanel implements ANewEventListener { - - //Singleton instance - private static ACanvas instance; - - private final static ALogger logger = ALogger.getLogger(ACanvas.class); - - /** The fraction of the screen width used by default. */ - public final double SCREEN_USAGE = 0.73; - /** Temporary flag to set the window corners from config file. */ - protected boolean customisedCorner = false; - - //the layeredPane - private JLayeredPane layeredPane; - //from some reason we count or layers from 1000 on? - private final int baseLayer = 1000; - - //A list of layout names and layouts - private Hashtable<String, ALayout> layouts = new Hashtable<String, ALayout>(); - //The current canvas layout - private ALayout currentLayout; - //The name of the startup layout - private String startupLayoutName; - //Everyone that should get informed if the layout is changed - private Vector<ALayoutChangeListener> layoutChangeListeners = new Vector<ALayoutChangeListener>(); - - //Save a history of the windows layouts - // - this is used for "Zoom/Unzoom colorimters" in VPlot - private Stack<ALayout> windowLayoutHistory = new Stack<ALayout>(); //History of ALayout objects - private Stack<String> windowNameHistory = new Stack<String>(); //History of the selected window - private Stack<Vector<String>> windowsActive = new Stack<Vector<String>>(); //History of active (i.e. visible windows) - - private Hashtable<String,AWindow> windowsList; // A list of all window <name,object> pairs - private AWindow currentWindow; // The currently selected window - private AWindow paintingWindow; // The window we are currently painting in - //Everyone that should get informed about changes of the active window - private Vector<ChangeListener> windowChangeListeners = new Vector<ChangeListener>(); - //Everyone that should get informed about window freeze/unfreeze changes - private Vector<ChangeListener> lockChangeListeners = new Vector<ChangeListener>(); - - //The title bar showing Event/Run numbers etc. - private ATitleMenuBar title; - - //If constructed from a config file, this stores the aspect ratio of the - //canvas layout which was saved into the config file, this is then used - //later to correct if the current screen is different - private double oldaspect = 1.0; - - private JFrame parentWindow = null; - - private APar parameterStore; - - /** - * Get the singleton instance. - * @return - */ - public static synchronized ACanvas getCanvas() { - if (instance==null) throw new Error("Attempted to access ACanvas instance before initialization."); - return instance; - } - - /** - * Create and return the singleton instance. - * @param parameters - */ - public static synchronized ACanvas construct(Node node) { - instance = new ACanvas(node); - return instance; - } - - /** - * Constructs the singleton instance by reading the config file. - */ - private ACanvas(Node node) { - - if (!AGlobals.isAtlantisHeadless()) { - // Create parent window - parentWindow = new JFrame("Atlantis Canvas"); - parentWindow.add(this); - } - - //Create the title bar - title = new ATitleMenuBar(); - - if (!AGlobals.isAtlantisHeadless()) { - parentWindow.setJMenuBar(title); - } - - //instanciate instance pointer for singleton class - instance = this; - - if (!AGlobals.isAtlantisHeadless()) { - // AClosingConfirmationDialog class handles closing Atlantis - parentWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - parentWindow.addWindowListener(new AClosingConfirmationDialog(parentWindow)); - - //Set the window icon - AIcon.setIconImage(parentWindow); - } - - // building the Layered Pane - layeredPane = new JLayeredPane(); - - // reading all the content of Canvas configuration node - windowsList = new Hashtable<String,AWindow>(); - // Allow null Node to generate partially initialized instance for unit tests of - // other classes that depend on ACanvas. - if (node!=null) readConfig(node); - - } // ACanvas() ---------------------------------------------------------- - - /** - * For testing only: create instance without initializing. - * @return - */ - public static synchronized ACanvas constructDummyForTesting() { - instance = new ACanvas(null); - return instance; - } - - void addParentWindowFocusListener(WindowFocusListener wfl) { - if (parentWindow != null) { - parentWindow.addWindowFocusListener(wfl); - } - } - - public void setCanvasVisible(boolean v) { - if (parentWindow != null) { - parentWindow.setVisible(v); - } else { - setVisible(v); - } - } - - public Rectangle getScreenSize() { - if (parentWindow != null) { - return parentWindow.getGraphicsConfiguration().getBounds(); - } else { - // If we're headless then make up a size! - return new Rectangle(1024, 768); - } - } - - public Rectangle getStartupCanvasSize() { - if (parentWindow == null) { - return null; - } - Rectangle canvpos = parentWindow.getBounds(); - Dimension canvlayoutdim = parentWindow.getPreferredSize(); - Rectangle canvbound = new Rectangle(canvpos.x, canvpos.y, - canvlayoutdim.width, canvlayoutdim.height); - - return canvbound; - } - - public JMenuBar getTitleBar() { - if (parentWindow == null) { - return null; - } - return parentWindow.getJMenuBar(); - } - - public void bringToFront() { - if (parentWindow != null) { - parentWindow.toFront(); - } - } - - /*public JFrame getParentWindow() { - return parentWindow; - }*/ - - private void readConfig(Node node){ - - //Get a list of subnodes - NodeList children = node.getChildNodes(); - - //Loop over all subnodes - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - //Check wether subnode is a Window or a Layout - if (child.getNodeType() == Node.ELEMENT_NODE) { - String nodeName = child.getNodeName(); - //Add a Window or a layout - if (nodeName.equals("UsedWindow")) readWindow(child); - else if (nodeName.equals("Layout")) readLayout(child); - } - } - - // reading all the attributes of Canvas node - NamedNodeMap attributes = node.getAttributes(); - // The startupLayout: - startupLayoutName = attributes.getNamedItem("startupLayout").getNodeValue().trim(); - - // Aspect ratio stuff: - oldaspect = Double.NaN; - Node n = attributes.getNamedItem("aspectRatio"); - - if (n != null) { - oldaspect = Double.parseDouble( - attributes.getNamedItem("aspectRatio").getNodeValue().trim()); - } - - logger.debug("Read config file with aspectRatio: " + oldaspect); - } - - //Read window configuration - private void readWindow(Node node) { - AWindow w = AWindow.createFromXMLConfigNode(node, getWindowsCount()); - - if (!windowsList.containsKey(w.getName())) { - windowsList.put(w.getName(), w); - } else - throw new Error("Redefinition of window: " + w.getName()); - } - - //Read layout configuration - private void readLayout(Node node) { - ALayout layout = new ALayout(node); - - if (!layouts.containsKey(layout.getName())) - layouts.put(layout.getName(), layout); - else - throw new Error("Redefinition of layout: " + layout.getName()); - } - - //Read window corners - public void readCorners(Node corners) { - if (corners == null) - return; - //Set flag to set default corners - customisedCorner = true; - //Get list of corners - NodeList children = corners.getChildNodes(); - //Loop over corners - for (int i = 0; i < children.getLength(); i++) { - Node corner = children.item(i); - if (corner.getNodeType() == Node.ELEMENT_NODE) { - //Get corner attributes - NamedNodeMap attributes = corner.getAttributes(); - String windowName = AXMLUtils.tryAttribut(attributes, "windowName"); - double x0 = Double.parseDouble(AXMLUtils.tryAttribut(attributes, "x0")); - double y0 = Double.parseDouble(AXMLUtils.tryAttribut(attributes, "y0")); - double x1 = Double.parseDouble(AXMLUtils.tryAttribut(attributes, "x1")); - double y1 = Double.parseDouble(AXMLUtils.tryAttribut(attributes, "y1")); - double x2 = Double.parseDouble(AXMLUtils.tryAttribut(attributes, "x2")); - double y2 = Double.parseDouble(AXMLUtils.tryAttribut(attributes, "y2")); - //Create an array with new window corners - Point2D.Double[] c = new Point2D.Double[] { new Point2D.Double(x0, y0), new Point2D.Double(x1, y1), new Point2D.Double(x2, y2) }; - //Set the corners for this window - - getWindow(windowName).setUserCorners(c); - } - } - customisedCorner = false; - } - - - //Finalize the canvas construction - public void finalizeConstruction() { - parameterStore = APar.instance(); - - if (!parameterStore.get("Prefs", "CanvasTitle").getStatus()) { - title.setVisible(false); - } - - //Bring the startup layout on screen - setCurrentLayout(startupLayoutName); - } - - public void addOverlay() { - - AOverlay overlay = new AOverlay(); - if(parentWindow != null) - parentWindow.setGlassPane(overlay); - overlay.setVisible(true); - } - - public void correctAspectRatios() { - - // If we didn't have a saved aspect ratio or didn't know it when - // the config was written - if (Double.isNaN(oldaspect)) { - return; - } - - // Only correct aspect ratio for the full screen layout, the other - // layouts have fixed aspect ratios and should always be okay - if (!currentLayout.getName().equals("FULL SCREEN")) { - return; - } - - // If aspect ratios are the same, we can stop - if (java.lang.Math.abs(getAspectRatio() - oldaspect) < 1e-2) { - logger.debug("Aspect ratio of config file same as this display, no correction required"); - return; - } - - logger.info("Aspect ratio of config file (" + oldaspect + ") does not match this display (" + getAspectRatio() + ") attempting to correct"); - - // Else, iterate over all windows - Iterator<AWindow> it = windowsList.values().iterator(); - while(it.hasNext()) { - AWindow w = (AWindow)(it.next()); - AProjection p = w.getProjection(); - if (p instanceof AProjection2D) { - ((AProjection2D)p).aspectRatioChange(w, oldaspect, getAspectRatio()); - } - } - } - - /** - * Mimics the behavior of a normal canvas paint, but with the canvas scaled to a predefined size. - * @param g Graphics object to draw on - * @param imageWidth width of the image - * @param imageHeight height of the image - * @param type extension of image - */ - public void drawScaledCanvas(Graphics g, int imageWidth, int imageHeight, String type) - { - //hide red ZMR center dot - AZMRInteraction.setPaintCenterDot(false); - - //anti-alias pictures by default - boolean aastatus = APreferencesControl.getAliasMenuItem(); - if(!aastatus) - APreferencesControl.setAliasMenuItem(true); - - // Calculate the scale factors. - double factorX = ((double)imageWidth) / (double)getWidth(); - double factorY = ((double)imageHeight) / (double)getHeight(); - - // Add the title bar, if required. - if (title != null && parameterStore.get("Prefs", "CanvasTitle").getStatus()) { - - //Get old dimensions - int titleWidth = title.getWidth(); - int titleHeight = title.getHeight(); - - if (AGlobals.isAtlantisHeadless()) { - Dimension d = title.getLayout().preferredLayoutSize(title); - titleWidth = (int)d.getWidth(); - titleHeight = (int)d.getHeight(); - } - - //Scale to image width (height is constant) and draw - title.setSize(imageWidth, titleHeight); - title.paint(g); - //restore old - title.setSize(titleWidth, titleHeight); - g.translate(0, titleHeight); - //Re-adjust y-scale for title height - factorY = ((double)(imageHeight-titleHeight))/(double)getHeight(); - } - - // Loop over all windows. - String[] windows = getCurrentLayout().getWindowNames(); - for (int i=0; i<windows.length; i++) - { - AWindow window = getWindow(windows[i]); - int x = window.getX(); - int y = window.getY(); - int width = window.getWidth(); - int height = window.getHeight(); - // If the window is visible resize it temporarily and then draw it. - if (isReallyOnScreen(window)){ - - g.translate((int)(factorX*x), (int)(factorY*y)); - - // Perhaps I should override window.setSize to automatically validate - // This is because AWindow is now a container with a view inside - // - Adam - window.setSize((int)(factorX*width), (int)(factorY*height)); - window.validate(); - - // Needed in headless mode because normally components don't - // do layout until they're really drawn - if (AGlobals.isAtlantisHeadless()) { - window.getLayout().layoutContainer(window); - window.invalidateQuietly(); - } - - //Now print the actual windows - window.print(g); - - // Show ATLAS logo only on the top left window if there's - // enough room and if the checkbox is selected - if(x == 0 && y == 0 && (imageWidth > 300 || imageHeight > 250) && - APreferencesControl.getAtlasLogoMenuItem()){ - g.drawImage(ACursorFactory.getInstance().getAtlasLogo(),32,4,null); - } - //reset old dimensions - window.setSize(width, height); - window.validate(); - g.translate(-(int)(factorX*x), -(int)(factorY*y)); - } - } - - // Overlay does not work in XMLRPC mode (no parentWindow) - if (this.parentWindow != null) { - //get the overlay, resize to our desired canvas size, draw it, then set it back to normal - AOverlay overlay = (AOverlay) this.parentWindow.getGlassPane(); - int width = overlay.getWidth(); - int height = overlay.getHeight(); - overlay.setSize(imageWidth, imageHeight); - overlay.paintComponent(g); - overlay.setSize(width, height); - } - - //do reset - AZMRInteraction.setPaintCenterDot(true); - if(!aastatus) - APreferencesControl.setAliasMenuItem(aastatus); - } - - - //Restore canvas defaults - public void restoreDefaults() { - //Current layout should never be null - if (currentLayout != null) { - if (!currentLayout.getName().equals(startupLayoutName)) { - setCurrentLayout(startupLayoutName); - } - String[] frontWindows = currentLayout.getStartupSequence(); - String[] windows = this.getKnownWindowNames(); - for (String window : windows) windowsList.get(window).restoreDefaults(); - for (String window : frontWindows) this.moveToFrontWindow(window); - setCurrentWindow(currentLayout.getStartupWindow()); - } else - throw new Error("Current layout is not defined"); - - // If an aspect ratio correction took place when we loaded this config - // make sure it is reapplied on a reset - AD - correctAspectRatios(); - } - - /* - * Return a string containing the list of currently visible windows - * that is then written to the config file by AConfigWriter - */ - public String getStartupString() { - StringBuilder s = new StringBuilder(); - //Loop over all windows in all layers - int maxLayer = baseLayer + currentLayout.getWindowNames().length; - for (int i = baseLayer; i <= maxLayer; i++) { - Component[] c = layeredPane.getComponentsInLayer(i); - for (int j = 0; j < c.length; j++) - if (c[j] instanceof AWindow) - if (isReallyOnScreen((AWindow) c[j])) - s.append(((AWindow) c[j]).getName()); - } - return s.toString(); - } - - /* - * Bring this window to the front, i.e. make it the topmost window - */ - public void moveToFrontWindow(String windowName) { - //Make sure the window exists - if (windowsList.containsKey(windowName)) { - //Get the window - AWindow w = windowsList.get(windowName); - //Get the current layer of the window - int layer = JLayeredPane.getLayer(w); - //Get the other components int the same layer - Component[] cc = layeredPane.getComponentsInLayer(layer); - //Check for the current uppermost window - int maxLayer = baseLayer + currentLayout.getWindowNames().length; - - //Now loop over all layers above the one the object is in - for (int i = layer + 1; i <= maxLayer; i++) { - //Get all components from this layers - Component[] c = layeredPane.getComponentsInLayer(i); - //Move them down one layer - for (int j = 0; j < c.length; j++) - layeredPane.setLayer(c[j], i - 1); - } - //Finaly move all component from the current layer to the top - for (int j = 0; j < cc.length; j++) - layeredPane.setLayer(cc[j], maxLayer); - //validate and repaint - this.validate(); - if (!w.isVisible()) { - w.setVisible(true); - } - hideNonVisible(); - w.repaintFromScratch(); - } else - throw new Error("Cannot find window: " + windowName); - } - - /* - * Return window by name - */ - public AWindow getWindow(String windowName) { - //Search for the window in the list an return it - if (windowsList.containsKey(windowName)) - return (AWindow) windowsList.get(windowName); - else - throw new Error("Cannot find window: " + windowName); - } - - /* - * Repaint all but the current window - * Used to update SynchroCursor in all windows. - */ - public void repaintOthers(Component current) { - //Fill all windows in an enumeration object - Enumeration<AWindow> myenum = windowsList.elements(); - - //Loop over windows - while (myenum.hasMoreElements()) { - AWindow window = (AWindow) myenum.nextElement(); - //repaint those that are visible - if ((window != current) && this.isReallyOnScreen(window)) - window.repaint(); - } - } - - private void hideNonVisible() { - for (AWindow window : windowsList.values()) { - if (this.isValidWindowName(window.getName())) { - if (!this.isReallyOnScreen(window)) { - if (window.isVisible()) { - window.setVisible(false); - } - } - } - } - } - - /* - * Repaint all windows from Scratch - */ - public void repaintAllFromScratch() { - Enumeration<AWindow> myenum = windowsList.elements(); - - hideNonVisible(); - - while (myenum.hasMoreElements()) { - AWindow window = (AWindow) myenum.nextElement(); - - if (this.isReallyOnScreen(window)) { - if (!window.isVisible()) { - window.setVisible(true); - } - window.repaintFromScratch(); - } - } - title.repaint(); - } - - /* - * Return a string will the names of all layouts - * to be shown in the layout dialog - */ - public String[] getLayoutNames() { - Enumeration<String> myenum = layouts.keys(); - String[] s = new String[layouts.size()]; - //Loop over all layouts and concatenate their names - for (int i = 0; i < s.length; i++) - s[i] = (String) myenum.nextElement(); - - return s; - } - - /* - * Get Layout by name - */ - public ALayout getLayout(String name) { - if (layouts.containsKey(name)) - return layouts.get(name); - else - throw new Error("getLayout, unknown: " + name); - } - - /* - * Return the current layout - */ - public ALayout getCurrentLayout() { - return currentLayout; - } - - /* - * Set the current layout and apply the changes right away - */ - public void setCurrentLayout(String newLayout) { - //Make sure the new layout exists - if (layouts.containsKey(newLayout)) { - - //get current layout and its dimension - currentLayout = layouts.get(newLayout); - Dimension dim = currentLayout.getSize(); - - // clear the frame - setLayout(null); - removeAll(); - layeredPane.removeAll(); - - //Toolkit is not aware of multi-screens, but "adds them all together". - // Dimension ScreenSize = Toolkit.getDefaultToolkit().getScreenSize(); - //getMaxWindowBounds gets max bounds, again added up over multiple screens. In contrast to the above, - //it will account for MenuBars, StatusBars, etc from the the WindowManager - // Rectangle ScreenSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); - //This is how to get the default screen, we should rather use the one we are on - // GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); - // GraphicsDevice gscreen = genv.getDefaultScreenDevice(); - // GraphicsConfiguration gconf = gscreen.getDefaultConfiguration(); - - //Final total Width, Height and position of the Canvas - int W, H, X, Y; - - //First get the screen size of the current screen - Rectangle ScreenSize = getScreenSize(); - - //This is not a real full screen mode, rather a maximised Window mode. - //In proper full screen, some window managers (such as Cacao) will allow - //to have the title bar/menues disappear, etc. - if(newLayout.equals("FULL SCREEN")) { - //Really take the full screen in this mode - W = ScreenSize.width; - H = ScreenSize.height; - X = ScreenSize.x; - Y = ScreenSize.y; - } else { - //if not full screen then have to take account of task bars - //First gets the insets (borders) from all sides - Insets borders = new Insets(0, 0, 0, 0); - if (!AGlobals.isAtlantisHeadless()) { - borders = Toolkit.getDefaultToolkit() - .getScreenInsets(parentWindow.getGraphicsConfiguration()); - } - //calculate new usable screen size - ScreenSize.width -= borders.left+borders.right; - ScreenSize.height -= borders.top+borders.bottom; - ScreenSize.x += borders.left; - ScreenSize.y += borders.top; - - W = (int) (ScreenSize.width * SCREEN_USAGE); - H = ScreenSize.height; - X = ScreenSize.x; - Y = ScreenSize.y; - } - - //Apply the new layout dimensions - layeredPane.setLayout(new AGridLayout(dim, null)); - - //Now check for the existing windows - String[] usedWindowNames = currentLayout.getWindowNames(); - - //Loop over windows and add them to the new layout - for (int i = 0; i < usedWindowNames.length; i++) { - //Get the window dimensions - Rectangle constraint = currentLayout.getWindowConstraints(usedWindowNames[i]); - //Get the window itself - AWindow window = windowsList.get(usedWindowNames[i]); - //Make sure its finalized - if (!window.finalized) { - window.finalizeConstruction(); - } - //Add window to a new layer with the given dimensions - layeredPane.setLayer(window, baseLayer + i); - layeredPane.add(window, constraint); - } - // adding the layeredPane to the frame - setLayout(new BorderLayout()); - add(layeredPane); - - if (parentWindow != null) { - //Set the new window dimensions and position - parentWindow.setLocation(X, Y); - parentWindow.setSize(W, H); - - //Validate and update - parentWindow.validate(); - parentWindow.repaint(); - - } else { - - // This is real voodoo to make the canvas lay itself out in the - // right way in headless mode - // It seems that because there's no repaint events things like - // layouts often don't work in the way you expect. I'm fully - // willing to believe I don't understand the best way to do this. - // This is rather a scattergun approach that seems to work... - // - Adam - - setSize(W, H); - layeredPane.setSize(W, H); - - Dimension d = layeredPane.getLayout().preferredLayoutSize(layeredPane); - - validate(); - repaint(); - - setSize(d); - layeredPane.setSize(d); - layeredPane.getLayout().layoutContainer(layeredPane); - } - - fireLayoutChange(); - - //Now apply window ordering - String[] ss = currentLayout.getStartupSequence(); - for (int i = 0; i < ss.length; i++) this.moveToFrontWindow(ss[i]); - - //Finally set the current window to the same it was before, if it exists - if ((currentWindow != null) && (currentLayout.hasWindow(currentWindow.getName()))) - setCurrentWindow(currentWindow.getName()); - else - setCurrentWindow(currentLayout.getStartupWindow()); - } else - throw new Error("setCurrentLayout: unknown layout name !?"); - } - - /* - * Inform everyone on the LayoutChangeListener list about the layout change - */ - private void fireLayoutChange() { - for (ALayoutChangeListener changeListener : layoutChangeListeners) { - changeListener.layoutChanged(getCanvas()); - } - } - - /* - * Store the current layout in the stack - * This is need for layout history, used by e.g. "Zoom/Unzoom LAr/Calorimeters" - */ - public void saveLayout() { - //Add the current layout and active window name - windowLayoutHistory.push(getCurrentLayout()); - windowNameHistory.push(currentWindow.getName()); - - //Also store all windows that are actually on screen - Vector<String> windowsOnScreen = new Vector<String>(); - String[] usedWindowNames = currentLayout.getWindowNames(); - for (String windowName : usedWindowNames) { - AWindow window = windowsList.get(windowName); - if(isReallyOnScreen(window)) { - windowsOnScreen.add(windowName); - } - } - windowsActive.push(windowsOnScreen); - } - - /* - * Revert to the previous layout in the layout history - */ - void unlayout() { - //Make sure there is a previous one - if(windowLayoutHistory.size() > 0) { - //Get the old layout and active window - ALayout newLayout=windowLayoutHistory.pop(); - String windowName=windowNameHistory.pop(); - //Only change layout if it has actually changed - if(!newLayout.getName().equals(currentLayout.getName())) { - //Set new layout and current window - setCurrentLayout(newLayout.getName()); - setCurrentWindow(windowName); - } - //now bring windows in the proper order - Vector<String> windowsOnScreen = windowsActive.pop(); - - for (String winName : windowsOnScreen) { - this.moveToFrontWindow(winName); - } - } - } - - /* - * Add objects that shall be informed if there is a change in the lock status - */ - public void addLockChangeListener(ChangeListener listener) { - lockChangeListeners.addElement(listener); - listener.stateChanged(new ChangeEvent(this)); - } - /* - * Add objects that shall be informed if there is a change in the layout - */ - public void addLayoutChangeListener(ALayoutChangeListener listener) { - layoutChangeListeners.addElement(listener); - listener.layoutChanged(getCanvas()); - } - - /* - * Add objects that shall be informed if there is a - * change in the current window - */ - public void addWindowChangeListener(ChangeListener listener) { - windowChangeListeners.addElement(listener); - listener.stateChanged(new ChangeEvent(this)); - } - - /* - * Check if the given window name exists in the list of windows - */ - public boolean isValidWindowName(String name) { - return windowsList.containsKey(name); - } - - /* - * Get a string with all the existing windows - */ - public String[] getKnownWindowNames() { - Set<String> windowNames = windowsList.keySet(); - return windowNames.toArray(new String[windowNames.size()]); - } - - /* - * Returns the name of the current window - */ - public String getCurrentWindowName() { - return currentWindow.getName(); - } - - /* - * Return the current window - */ - public AWindow getCurrentWindow() { - return currentWindow; - } - - /* - * Return the window we are currently painting in - */ - public AWindow getPaintingWindow() { - return paintingWindow; - } - - /* - * Notify everyone about a change in the active window - */ - private void fireWindowChange() { - ChangeEvent changeEvent = new ChangeEvent(this); - for (ChangeListener changeListener : windowChangeListeners) { - changeListener.stateChanged(changeEvent); - } - } - - /* - * Notify everyone about a change in the lock status - */ - void fireLockChange() { - ChangeEvent changeEvent = new ChangeEvent(this); - for (ChangeListener changeListener : lockChangeListeners) { - changeListener.stateChanged(changeEvent); - } - } - - /* - * Get number of windows - */ - public int getWindowsCount() { - return windowsList.size(); - } - - /** - * Sets the current window. Informs all registered listeners. - * - * @param newWindowName The name of the window to be set to current. - */ - public void setCurrentWindow(String newWindowName) { - //Make sure window does exist - if (windowsList.containsKey(newWindowName)) { - //Deselect the current window - if (currentWindow != null) currentWindow.deselect(); - //Get the new window - currentWindow = (AWindow) windowsList.get(newWindowName); - //Select it - currentWindow.select(); - //Inform APar class about the new current window - parameterStore.setCurrentWindowIndex(currentWindow.getIndex()); - //Move the current window on top of all others - moveToFrontWindow(currentWindow.getName()); - //Inform everyone about the change - fireWindowChange(); - } else - throw new Error("setCurrentWindow, window: " + newWindowName + " , doesn't exist !?"); - } - - /** - * Sets the currently window currently being painted - * - * @param window the window being painted - */ - public void setPaintingWindow(AWindow window) { - paintingWindow = window; - } - - /** - * Copy settings from one window to another window - * - * @param from the window to copy settings from - * @param to the window to copy settings to - */ - public void copyWindowSettings(String from, String to) { - AWindow fromW = getWindow(from); - AWindow toW = getWindow(to); - - parameterStore.copyParameters(from, to); - - // IMPORTANT! Do not change the order - // setCurrentWindow() should be always before setProjection() - setCurrentWindow(to); - - // copy the projection, group and scales - toW.setProjection(fromW.getProjection()); - toW.setGroup(fromW.getGroupName()); - toW.setScaleStatus(fromW.getScaleStatus()); - - // copy the interaction (no interactions valid for EventInfo projection) - if(!(fromW.getProjection() instanceof AProjectionEventInfo)) - { - AInteractionToolBar fromI = fromW.getInteractionToolBar(); - AInteractionToolBar toI = toW.getInteractionToolBar(); - - toI.setSelectedGroup(fromI.getSelectedGroupName()); - // copy the state of the panel - toI.getSelectedGroup().setGroupState(fromI.getSelectedGroup()); - } - // for LegoPlot windows we need to set the (x,y,z)-corners from the projection - // TODO: Check and understand this. Previously there was no check that toW was - // an instance of AProjectionLegoPlot, put perhaps this works because only - // ever copy settings from one projection to another of the same type? - if(fromW.getProjection() instanceof AProjectionLegoPlot - && toW.getProjection() instanceof AProjectionLegoPlot) { - AProjectionLegoPlot.setxz(toW.getIndex(), AProjectionLegoPlot.getxz(fromW.getIndex())); - AProjectionLegoPlot.setyz(toW.getIndex(), AProjectionLegoPlot.getyz(fromW.getIndex())); - //reset the center of detector dot on ZMR - toW.getInteractionManager().setContext(toW.getInteractionToolBar().getSelectedGroup()); - } - //copy the user corners - toW.setUserCorners(fromW.getUserCorners()); - } - - /** - * As each window has its own layer, find the window that is in this window - * - * @param layer the layer which the window is in - */ - private AWindow getWindowForLayer(int layer) { - //Get all the components in this layer - Component[] c = layeredPane.getComponentsInLayer(layer); - //Return the first instance of AWindow - for (int i = 0; i < c.length; i++) - if (c[i] instanceof AWindow) return (AWindow) c[i]; - //Otherwise return 0 - return null; - } - - /** - * Get the associated tile menu bar - */ - public ATitleMenuBar getATitle() { - return title; - } - - /** - * Get the top-most window at a certain point - * - * @param x x-coordinate in pixels - * @param y y-coordinate in pixels - */ - private AWindow getWindowForPoint(double x, double y) { - //Loop over all layers - int maxLayer = baseLayer + currentLayout.getWindowNames().length; - for (int lay = maxLayer; lay >= 0; lay--) { - //Get the window that is in this layer - AWindow w = getWindowForLayer(lay); - if (w == null || currentLayout == null) { - continue; - } - //Get the window rectangle - Rectangle r = currentLayout.getWindowConstraints(w.getName()); - //Check if x,y is inside the rectangle - if (r.contains(x, y)) - return w; - } - - return null; - } - - /** - * Check if a given window is partially visible - * - * @param window the window to check - */ - public boolean isReallyOnScreen(AWindow window) { - //The full area covered by the canvas - Dimension layoutSize = currentLayout.getSize(); - - //Run over every single point on the canvas - //until we hit one that belongs to the window -- aaaaaarrrrggghhh!!! (SB?) - - //This function almost always exits on the first pixel - //Profiling indicates it takes only a few miliseconds - //even in very rare worst cases - AD - for (int j = 0; j < layoutSize.height; j++) - for (int i = 0; i < layoutSize.width; i++) - if (getWindowForPoint(i + 0.5, j + 0.5).equals(window)) - return true; - - return false; - } - - /** - * Implementation of the new event listener: gets called for each new event - * and repaints all the windows. - * - * @param evt the new event - */ - @Override - public void newEvent(AEvent evt) { - repaintAllFromScratch(); - } - - /** Return the aspect ratio of the canvas drawing area (hopefully) as h/w. - * Sorry if this is usually defined as w/h? - AD */ - public double getAspectRatio() { - Dimension d = layeredPane.getSize(); - return d.getHeight() / d.getWidth(); - } - - /** - * Calculates the image height that will result if one resizes the current canvas to the given width. - * @param width target width - * @return corresponding height - */ - public int getRespectiveHeight(int width){ - - //Get rootpane dimensions - int canvasWidth = getWidth(); - int canvasHeight = getHeight(); - - //calculate factor - double factor = ((double)width) / canvasWidth; - - //Account for menu bar if its there - if (title != null && parameterStore.get("Prefs", "CanvasTitle").getStatus()) { - //if (getTitleBar() != null && getTitleBar().isVisible()){ - int height = title.getHeight(); - - if (AGlobals.isAtlantisHeadless()) { - // In headless mode the menu bar isn't really enabled - // So get the size it would be if it was - height = (int) (title.getLayout().preferredLayoutSize(title).getHeight()); - } - - return (int) (factor * canvasHeight) + height; - - } - - //Otherwise just scale - return (int)(factor*canvasHeight); - } - -} //ACanvas diff --git a/graphics/AtlantisJava/src/atlantis/canvas/ADrawCalorimeterSummedEndcaps.java b/graphics/AtlantisJava/src/atlantis/canvas/ADrawCalorimeterSummedEndcaps.java deleted file mode 100755 index c7b6a307a49229133e5608b9b6be6e051f292df3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/ADrawCalorimeterSummedEndcaps.java +++ /dev/null @@ -1,937 +0,0 @@ -package atlantis.canvas; - -import java.awt.Color; - -import atlantis.data.ACalorimeterData; -import atlantis.geometry.ACalorimeterDetector; -import atlantis.graphics.ACoord; -import atlantis.graphics.ADrawParameters; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionFR; -import atlantis.utils.AMath; -import atlantis.utils.APolygon; - -/** - * Contains the function for drawing the summed LAr and HEC endcaps - * - * @author Mark Stockton - */ -public class ADrawCalorimeterSummedEndcaps -{ - static int minEtaIndex,minPhiIndex,maxEtaIndex,maxPhiIndex,numCombinedCells,binvalue=1,SmallestEtaBinNumber,LargestEtaBinNumber; - static double etaBin, phiBin, SmallestZMin,maxCellEnergy,minCellEnergy; - static String name; - - protected static APar parameterStore = APar.instance(); - - /** - * Draws the summed endcaps. This method is called - * from drawCalorimeters and should not be used directly. - * - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - * @param projection AProjection2D current projection - * @param calorimeter ACalorimeterData current calorimeter - * @param etaIndex short[] index of eta values - * @param phiIndex short[] index of phi values - * @param side byte[] side of detector - */ - public static void drawCalorimeterSummedEndcaps(AWindow window, AGraphics ag, AProjection2D projection, ACalorimeterData calorimeter, short[] etaIndex, short[] phiIndex, byte[] side) - { - resetGlobalValues(calorimeter.getName()); - ACoord data; - double[][] EndcapBinnedEnergy = new double[(36/binvalue)][(64/binvalue)]; - calorimeter.makeDrawList(); - //loop over drawlist to find z of first plane and smallest and largest eta - setSmallestAndLargest(calorimeter); - //now loop over drawlist to draw - for (int k = 0; k < calorimeter.getNumDraw(); k++) - { - int j = calorimeter.getDrawIndex(k); - short detectorIndex = (short) ACalorimeterDetector.getDetectorIndex(calorimeter.getIdFromIndex(j)); - ACalorimeterDetector currentDetector=ACalorimeterDetector.get(detectorIndex); - if (detectorIndex >= 0) - { - ACoord coord = currentDetector.getCell(projection, etaIndex[j], phiIndex[j], side[j]); - if (coord.hv[0].length > 0) - { - //has a cell so get its energy - double cellEnergy=calorimeter.getEnergy(j); - //find the eta min and max of each cell - double[] etaminmax=findEtaMinAndMax(currentDetector,etaIndex[j],side[j]); - //test to see if the cell overlaps the eta border - if(etaminmax[2]==1) - { - //Only want cells upto the eta split - double middle=parameterStore.get("YX", "SplitEta").getD()-(0.5*etaBin); - //find the min and max of each cell - double[] minmax1=findMinAndMax(currentDetector,etaminmax[0],middle,phiIndex[j]); - //has to find out how many cells overlap new binning border - int totNumOfCells1 =findNumberOfCells(minmax1); - //Only want cells above the eta split - middle=parameterStore.get("YX", "SplitEta").getD()+(0.5*etaBin); - //find the min and max of each cell - double[] minmax2=findMinAndMax(currentDetector,middle,etaminmax[1],phiIndex[j]); - //has to find out how many cells overlap new binning border - int totNumOfCells2 =findNumberOfCells(minmax1); - //check found positive number of cells - int NumOfCellsTotal=0; - if(totNumOfCells1>0) - NumOfCellsTotal+=totNumOfCells1; - else - System.out.println("Found negative amount of cells!?!"); - if(totNumOfCells2>0) - NumOfCellsTotal+=totNumOfCells2; - else - System.out.println("Found negative amount of cells!?!"); - if(NumOfCellsTotal>0) - { - //split energy between the cells - cellEnergy/=NumOfCellsTotal; - //now add on energy - if(totNumOfCells1>0) - { - EndcapBinnedEnergy=AddOnToEnergy(EndcapBinnedEnergy, cellEnergy, minmax1); - } - if(totNumOfCells2>0) - { - EndcapBinnedEnergy=AddOnToEnergy(EndcapBinnedEnergy, cellEnergy, minmax2); - } - } - } - else - { - //find the min and max of each cell - double[] minmax=findMinAndMax(currentDetector,etaminmax[0],etaminmax[1],phiIndex[j]); - //has to find out how many cells overlap new binning border - int totNumOfCells =findNumberOfCells(minmax); - //if found cells - if(totNumOfCells>0) - { - //split energy between the cells - cellEnergy/=totNumOfCells; - //not overlapping eta split so just add on energy - EndcapBinnedEnergy=AddOnToEnergy(EndcapBinnedEnergy, cellEnergy, minmax); - } - else - System.out.println("Found negative amount of cells!?!"); - } - } - } - } - //if no cells then don't need to draw - if(numCombinedCells==0) - return; - //now need to order energy into a list aswell as get the geometry of cells with energy - double[] EndcapBinnedEnergyList; - double[] YXBinnedEnergyList=new double[numCombinedCells];//needed as could be FR projection - double[][][] YXhv=new double[2][numCombinedCells][0]; - int currentCount=0; - for(int a=minEtaIndex; a<=maxEtaIndex;a++) - { - for(int b=minPhiIndex; b<=maxPhiIndex;b++) - { - if(EndcapBinnedEnergy[a][b]>0.0) - { - //has an energy so store its cell coordinates - ACoord coord = calculateCellGeometry(a,b); - YXhv[0][currentCount]=coord.hv[0][0]; - YXhv[1][currentCount]=coord.hv[1][0]; - //sorts energy into a list less blank cells - YXBinnedEnergyList[currentCount]=EndcapBinnedEnergy[a][b]; - currentCount++; - //check if is largest/smallest cell energy - if(EndcapBinnedEnergy[a][b]>maxCellEnergy) - maxCellEnergy=EndcapBinnedEnergy[a][b]; - if(EndcapBinnedEnergy[a][b]<minCellEnergy) - minCellEnergy=EndcapBinnedEnergy[a][b]; - } - } - } - //store coords and scale for display - ACoord YXData = new ACoord(YXhv); - //now need to alter to FR projection if needed otherwise will continue with temp - if(projection instanceof AProjectionFR) - { - //convert data to FR and add data to loop in phi - data=convertToFR(YXData, window); - //now need to loop the energies - EndcapBinnedEnergyList=new double[3*numCombinedCells]; - for(int j=0; j<numCombinedCells;j++) - { - EndcapBinnedEnergyList[j]=YXBinnedEnergyList[j]; - EndcapBinnedEnergyList[j+numCombinedCells]=YXBinnedEnergyList[j]; - EndcapBinnedEnergyList[j+(2*numCombinedCells)]=YXBinnedEnergyList[j]; - } - numCombinedCells*=3;//now have 3 lots of cells - } - else - { - //If not FR then the YX values are correct - EndcapBinnedEnergyList=YXBinnedEnergyList; - data=YXData; - } - data = window.calculateDisplay(projection.nonLinearTransform(data)); - // Draw the cell frames - boolean drawCells = parameterStore.get( name, "Cells").getStatus(); - if (drawCells) - drawCells(window, ag, data, EndcapBinnedEnergyList); - // Draw the histograms. - ACalorimeterData.drawEndcapHistogram(calorimeter, window, ag, projection); - } - - /** - * Resets gobal values - * @param CalName name of calorimeter - */ - protected static void resetGlobalValues(String CalName) - { - name=CalName; - minEtaIndex=999; - minPhiIndex=999; - maxEtaIndex=0; - maxPhiIndex=0; - numCombinedCells=0; - SmallestZMin = 99999.0; - SmallestEtaBinNumber = 99999; - LargestEtaBinNumber = 0; - maxCellEnergy=0.0; - minCellEnergy = 99999.0; - //check if using 0.1 binning or 0.2 binning - if(name.equals("HEC")) - binvalue = parameterStore.get("YX", "HECBin").getI(); - else - binvalue = parameterStore.get("YX", "LArBin").getI(); - if(binvalue==3) - { - etaBin=0.1; - phiBin=(2*Math.PI/64); - binvalue=1; - } - else - { - etaBin=0.1*binvalue; - phiBin=(2*Math.PI/64)*binvalue;//(2*Math.PI/64)=0.098 - } - } - - /** - * Set the smallest Z, smallest and largest eta - * - * @param calorimeter ACalorimeterData current calorimeter - */ - protected static void setSmallestAndLargest(ACalorimeterData calorimeter) - { - double largestRho=0.0,smallestRho=99999.0; - double largestEtaValue=0.0,smallestEtaValue=99999.0; - //to shorten detectors to loop over - short prevDetectorIndex=999; - //loop over drawlist - for (int k = 0; k < calorimeter.getNumDraw(); k++) - { - int j = calorimeter.getDrawIndex(k); - short detectorIndex = (short) ACalorimeterDetector.getDetectorIndex(calorimeter.getIdFromIndex(j)); - ACalorimeterDetector currentDetector=ACalorimeterDetector.get(detectorIndex); - String detectorName=currentDetector.getName(); - if (detectorIndex!=prevDetectorIndex && detectorIndex >= 0 - && (detectorName.indexOf("Endcap")>0 || detectorName.indexOf("EC")>=0 || detectorName.equals("HEC"))) - { - //in a different detector - prevDetectorIndex=detectorIndex; - //find z of the first plane - if(currentDetector.getZMin()<SmallestZMin) - { - SmallestZMin=currentDetector.getZMin(); - } - //find smallest rho - if(currentDetector.getRMin()<smallestRho) - { - smallestRho=currentDetector.getRMin(); - largestEtaValue=AMath.etaAbs(currentDetector.getZMin(), smallestRho); - } - //find largest rho - if(currentDetector.getRMax()>largestRho) - { - largestRho=currentDetector.getRMax(); - smallestEtaValue=AMath.etaAbs(currentDetector.getZMin(), largestRho); - } - } - } - //if drawing cell outlines then this will have already been done - if (splitBinning() && !parameterStore.getUnknown("Det", "CaloDetail").getStatus()) - ACalorimeterDetector.setEtaSplit(); - //if using split binning and eta is in inner section - if(splitBinning() && smallestEtaValue>=parameterStore.get("YX", "SplitEta").getD()) - { - double belowSplit=parameterStore.get("YX", "SplitEta").getD()/0.1; - double aboveSplit=(smallestEtaValue-parameterStore.get("YX", "SplitEta").getD())/0.2; - SmallestEtaBinNumber=(int)Math.floor(belowSplit+aboveSplit); - } - else - { - SmallestEtaBinNumber=(int)Math.floor(smallestEtaValue/etaBin); - } - if(splitBinning() && largestEtaValue>=parameterStore.get("YX", "SplitEta").getD()) - { - double belowSplit=parameterStore.get("YX", "SplitEta").getD()/0.1; - double aboveSplit=(largestEtaValue-parameterStore.get("YX", "SplitEta").getD())/0.2; - LargestEtaBinNumber=(int)Math.floor(belowSplit+aboveSplit); - } - else - { - LargestEtaBinNumber=(int)Math.floor(largestEtaValue/etaBin); - } - } - - /** - * Test to see if using split binning - * - * @return Status of if using split binning - */ - protected static boolean splitBinning() - { - int test=0; - if(name.equals("HEC")) - test = parameterStore.get("YX", "HECBin").getI(); - else - test = parameterStore.get("YX", "LArBin").getI(); - if(test==3) - return true; - else - return false; - } - - /** - * Finds the max and min values of the hit cell - * Also tests and sets the min and max indicies for eta and phi - * - * @param currentDetector ACalorimeterDetector current detector - * @param etaIndex short index of eta values - * @param side byte side of detector - * - * @return minAndMax[0] double minEta of cell - * @return minAndMax[1] double maxEta of cell - * @return minAndMax[2] double status of if is an overlapping cell - */ - protected static double[] findEtaMinAndMax(ACalorimeterDetector currentDetector, short etaIndex, byte side) - { - double realEtaBin=etaBin; - //if using split binning and eta is in outer section - if(splitBinning() && Math.abs(currentDetector.getEtaMin(etaIndex, side))>=parameterStore.get("YX", "SplitEta").getD()) - { - realEtaBin=0.2; - } - //used for x when taking arsinh(x)=ln(x+sqrt(x*x+1)) - double asinhOf; - //have to alter eta so can be drawn at the front layer - double zFactor = SmallestZMin/currentDetector.getZMin(); - //do for minimum of cell - double calcEtaMin=Math.abs(currentDetector.getEtaMin(etaIndex, side)); - asinhOf = zFactor*Math.sinh(calcEtaMin); - calcEtaMin = Math.log(asinhOf + Math.sqrt(asinhOf*asinhOf+1)); - //do for center of cell - double calcEta=Math.abs(currentDetector.getEta(etaIndex, side)); - asinhOf = zFactor*Math.sinh(calcEta); - calcEta= Math.log(asinhOf + Math.sqrt(asinhOf*asinhOf+1)); - //find cell size in eta and phi - double deta=currentDetector.getDeltaEta(); - double minEta,maxEta; - //check for overlaping cells in eta and phi - if(deta>realEtaBin) - { - minEta=calcEtaMin; - maxEta=minEta+deta; - } - else - { - minEta=calcEta; - maxEta=minEta;//there is only 1 cell - } - - //make minEta in detector otherwise causes problems if SplitEta=SmallestEtaBinNumber*0.1 - if(minEta<SmallestEtaBinNumber*0.1) - { - minEta=SmallestEtaBinNumber*0.1; - } - - //now store in variable to return - double[] minAndMax=new double[3]; - minAndMax[0]= minEta; - minAndMax[1]= maxEta; - - if(splitBinning()) - { - if(minEta<parameterStore.get("YX", "SplitEta").getD() && - maxEta>parameterStore.get("YX", "SplitEta").getD()) - { - minAndMax[2]=1;//overlapping cell - } - else - minAndMax[2]=0; - } - else - minAndMax[2]=0; - return minAndMax; - } - - /** - * Finds the max and min values of the hit cell - * Also tests and sets the min and max indicies for eta and phi - * - * @param currentDetector ACalorimeterDetector current detector - * @param minEta double min eta of cell to draw - * @param maxEta double max eta of cell to draw - * @param phiIndex short index of phi values - * - * @return minAndMax[0] double minEta of cell - * @return minAndMax[1] double maxEta of cell - * @return minAndMax[2] double minPhi of cell - * @return minAndMax[3] double maxPhi of cell - */ - protected static double[] findMinAndMax(ACalorimeterDetector currentDetector, double minEta, double maxEta, short phiIndex) - { - double realEtaBin=etaBin, realPhiBin=phiBin; - //if using split binning - if(splitBinning()) - { - //if eta is in inner section - if(minEta>=parameterStore.get("YX", "SplitEta").getD()) - { - realEtaBin=0.2; - realPhiBin=(2*Math.PI/32); - } - } - //find cell size in eta and phi - double deta=currentDetector.getDeltaEta(); - double dphi=currentDetector.getDeltaPhi(); - double minPhi,maxPhi; - //check for overlaping cells in eta and phi - if(deta>realEtaBin) - { - if(realEtaBin==etaBin) - { - minEta=Math.floor(minEta/realEtaBin); - maxEta=Math.floor(maxEta/realEtaBin); - } - else - { - //inside split binning - double belowSplit=parameterStore.get("YX", "SplitEta").getD()/0.1; - double aboveSplit=(minEta-parameterStore.get("YX", "SplitEta").getD())/0.2; - minEta=Math.floor(belowSplit+aboveSplit); - aboveSplit=(maxEta-parameterStore.get("YX", "SplitEta").getD())/0.2; - maxEta=Math.floor(belowSplit+aboveSplit); - } - } - else - { - if(realEtaBin==etaBin) - { - minEta=Math.floor(minEta/realEtaBin); - } - else - { - //split binning - double belowSplit=parameterStore.get("YX", "SplitEta").getD()/0.1; - double aboveSplit=(minEta-parameterStore.get("YX", "SplitEta").getD())/0.2; - minEta=Math.floor(belowSplit+aboveSplit); - } - maxEta=minEta;//there is only 1 cell - } - if(dphi>realPhiBin) - { - minPhi=Math.abs(currentDetector.getPhiMin(phiIndex)); - minPhi=Math.floor(minPhi/realPhiBin); - maxPhi=Math.floor(minPhi+(dphi/realPhiBin)); - } - else - { - minPhi=Math.abs(currentDetector.getPhi(phiIndex)); - minPhi=Math.floor(minPhi/realPhiBin); - maxPhi=minPhi;//there is only 1 cell - } - //check for exceeding array limits - if(maxPhi>=(64/binvalue)) - { - maxPhi=(64/binvalue)-1; - if(minPhi>=(64/binvalue)-1) - minPhi=(64/binvalue)-1; - } - if(minPhi<0) - { - minPhi=0; - if(maxPhi<0) - maxPhi=0; - } - //check not out of eta array size range - if(maxEta>=(36/binvalue)) - { - maxEta=(36/binvalue)-1; - if(minEta>=(36/binvalue)) - minEta=(36/binvalue)-1; - } - //check physical eta conditions - if(maxEta>LargestEtaBinNumber) - { - maxEta=LargestEtaBinNumber; - if(minEta>LargestEtaBinNumber) - minEta=LargestEtaBinNumber; - } - if(minEta<SmallestEtaBinNumber) - { - minEta=SmallestEtaBinNumber; - if(maxEta<SmallestEtaBinNumber) - maxEta=SmallestEtaBinNumber; - } - //find min and max eta and phi indices - if(minEta<minEtaIndex) - minEtaIndex=(int)minEta; - if(maxEta>maxEtaIndex) - maxEtaIndex=(int)maxEta; - if(minPhi<minPhiIndex) - minPhiIndex=(int)minPhi; - if(maxPhi>maxPhiIndex) - maxPhiIndex=(int)maxPhi; - //now store in variable to return - double[] minAndMax=new double[4]; - minAndMax[0]= minEta; - minAndMax[1]= maxEta; - minAndMax[2]= minPhi; - minAndMax[3]= maxPhi; - return minAndMax; - } - - /** - * Finds the number of cells in the new binning - * - * @param minmax array containing: minEta, maxEta, minPhi, maxPhi - */ - protected static int findNumberOfCells(double[] minmax) - { - int numOfEtaCells=0; - int numOfPhiCells=0; - double minEta=minmax[0]; - double maxEta=minmax[1]; - double minPhi=minmax[2]; - double maxPhi=minmax[3]; - //calculate the number of cells - //add one as difference in index is 1 less than number of cells - numOfEtaCells+=maxEta-minEta+1; - numOfPhiCells+=maxPhi-minPhi+1; - //get total number of cells - int totNumOfCells = numOfEtaCells*numOfPhiCells; - return totNumOfCells; - } - - /** - * Adds on the energy to EndcapBinnedEnergy and then returns it - * - * @param EndcapBinnedEnergy double[][] energy listing of cells [eta][phi] - * @param cellEnergy double energy of each new cell - * @param minmax double[] min and max of cell in eta and phi - * - * @return EndcapBinnedEnergy double[][] altered energy listing of cells [eta][phi] - */ - protected static double[][] AddOnToEnergy(double[][] EndcapBinnedEnergy, double cellEnergy, double[] minmax) - { - //now loop over the min to max for eta and phi - for(int a= (int) minmax[0]; a<=(int) minmax[1]; a++) - { - for(int b=(int) minmax[2]; b<=(int) minmax[3]; b++) - { - //add to cell count if no energy already stored in cell - if(EndcapBinnedEnergy[a][b]==0.0) - numCombinedCells++; - //add energy to cell - EndcapBinnedEnergy[a][b]+= cellEnergy; - } - } - return EndcapBinnedEnergy; - } - - /** - * Calculates the cell geometry from its eta and phi bin numbers - * - * @param a int eta bin number - * @param b int phi bin number - * - * @return coord Acoord cell coords - */ - protected static ACoord calculateCellGeometry(int a, int b) - { - double realEtaBin=etaBin, realPhiBin=phiBin; - double eta=a*etaBin; - double phi=b*phiBin; - //if using split binning and eta is in inner section - if(splitBinning() && eta>=parameterStore.get("YX", "SplitEta").getD()) - { - realEtaBin=0.2; - realPhiBin=(2*Math.PI/32); - double belowSplit=parameterStore.get("YX", "SplitEta").getD()/0.1; - double aboveSplit=a-belowSplit; - eta=aboveSplit*0.2+belowSplit*0.1; - phi=b*realPhiBin; - } - double[][] temphv = new double[2][]; - - //all drawn on the front plane of the detector - double newrMax=SmallestZMin/Math.sinh(eta); - double newrMin=SmallestZMin/Math.sinh(eta+realEtaBin); - //store the cell coords - temphv[0] = new double[] {newrMax*Math.cos(phi), newrMax*Math.cos(phi+realPhiBin), - newrMin*Math.cos(phi+realPhiBin), newrMin*Math.cos(phi)}; - temphv[1] = new double[] {newrMax*Math.sin(phi), newrMax*Math.sin(phi+realPhiBin), - newrMin*Math.sin(phi+realPhiBin), newrMin*Math.sin(phi)}; - return new ACoord(temphv); - } - - /** - * Converts cells to FR using normal convertYXtoFR - * Then adds on data above and below so loops in phi - * - * @param YXData ACoord data in YX projection - * @param window AWindow current window - * - * @return coord Acoord cell coords - */ - protected static ACoord convertToFR(ACoord YXData, AWindow window) - { - //convert to FR then have to loop data - YXData.convertYXToFR(); - //new hv to store the values at + and - 2pi - double[][][] FRhv=new double[2][3*numCombinedCells][YXData.hv[0][0].length]; - //get corners and then shift data to be inside corners - double phiTop = window.getUserCorners()[0].y; - double phiBottom = window.getUserCorners()[2].y; - int factor=0; - if(phiTop>720.0) - //-2 as already draws upto 720 so doensn't need this extra 2*360 - factor=(int) Math.ceil(phiTop/360.0)-2; - if(phiBottom<-360.0) - //-1 as already draws down to -360 so doensn't need this extra -1*360 - factor=(int) Math.floor(phiBottom/360.0)-1; - for(int j=0; j<numCombinedCells;j++) - for(int k=0; k<YXData.hv[0][j].length; k++) - { - FRhv[1][j][k]=YXData.hv[1][j][k]+360.0*(factor-1); - FRhv[1][numCombinedCells+j][k]=YXData.hv[1][j][k]+360.0*factor; - FRhv[1][(2*numCombinedCells)+j][k]=YXData.hv[1][j][k]+360.0*(factor+1); - FRhv[0][j][k]=YXData.hv[0][j][k]; - FRhv[0][numCombinedCells+j][k]=YXData.hv[0][j][k]; - FRhv[0][(2*numCombinedCells)+j][k]=YXData.hv[0][j][k]; - } - //now store into data to be used to draw - return new ACoord(FRhv); - } - - /** - * Draws the cells - * - * @param ag AGraphics graphics to draw on - * @param data ACoord cell geometries - * @param EndcapBinnedEnergyList double[] energy of each cell - */ - protected static void drawCells(AWindow window, AGraphics ag, ACoord data, double[] EndcapBinnedEnergyList) - { - //Storage of parameters to be used later - Color[] colorMap = AColorMap.getColors(); - //AParameter frame = parameterStore.get(name, "Frame"); - boolean drawFrame = parameterStore.get(name, "Frame").getStatus(); - int frameColor = parameterStore.get(name, "Frame").getI(); - //only draw frames for Grey/BW color maps if is selected to draw frames - if(drawFrame && AColorMap.drawFrames()) - drawFrame=true; - else - drawFrame=false; - AParameter cellGeometry = parameterStore.get(name, "CellGeometry"); - // Draw frames for the filled cells. - if (drawFrame && cellGeometry.getStatus()) - { - for (int j = 0; j < numCombinedCells; j++) - { - ag.setColor(colorMap[frameColor]); - ag.drawPolygon(data.hv[0][j], data.hv[1][j], data.hv[0][j].length); - } - } - // Draw the cell geometry. - AParameter cellOutline = parameterStore.get(name, "CellOutline"); - // Draw filled cells. - if (cellGeometry.getStatus()) - { - for (int j = 0; j < numCombinedCells; j++) - { - ag.setColor(colorMap[cellGeometry.getI()]); - ag.fillPolygon(data.hv[0][j], data.hv[1][j], data.hv[0][j].length); - } - } - // Draw cell outlines. - if (cellOutline.getStatus()) - { - ag.updateDrawParameters(new ADrawParameters(true, cellOutline.getI(), 0, 1, 0, 0, false, 1, 0)); - for (int j = 0; j < numCombinedCells; ++j) - { - ag.drawPolygon(data.hv[0][j], data.hv[1][j], data.hv[0][j].length); - } - } - //Scale the cell polygons. - data = scaleEndcapPolygons(EndcapBinnedEnergyList, data, minCellEnergy, maxCellEnergy); - //Get the colours of the cells - byte[] EndcapColor= internalEndcapColor(EndcapBinnedEnergyList, minCellEnergy, maxCellEnergy); - // And draw them. - AParameter colorFunction = parameterStore.get(name, "ColorFunction"); - if (colorFunction.getI() == ACalorimeterData.COLOR_FUNC_ENERGY) - { - switch (AColorMap.getColorMap()) - { - case AColorMap.COLOR_MAP_DEFAULT1: - case AColorMap.COLOR_MAP_DEFAULT2: - case AColorMap.COLOR_MAP_M4M5: - case AColorMap.COLOR_MAP_GRAYDET: - case AColorMap.COLOR_MAP_ORIGINAL: - // Use colors. - colorMap = AColorMap.getColors(AColorMap.COLOR_MAP_HITCOL); - break; - case AColorMap.COLOR_MAP_GRAY: - case AColorMap.COLOR_MAP_BW: - // Use grayscale. - colorMap = AColorMap.getColors(AColorMap.COLOR_MAP_GRAY_HITCOL); - break; - } - //draw the legend - if(ALegendWindow.exists()) - { - if (AColorMap.getColorMap() != AColorMap.COLOR_MAP_BW) - { - double[] colorEnergy = energyOfEndcapColor(minCellEnergy,maxCellEnergy); - ALegendWindow.getInstance().addEnergyText(window, colorEnergy,maxCellEnergy, colorMap); - } - else - ALegendWindow.getInstance().addEnergyText(window, minCellEnergy,maxCellEnergy); - } - } - else if(ALegendWindow.exists()) - ALegendWindow.getInstance().clearText(window); - //draw filled cell - for (int j = 0; j < numCombinedCells; j++) - { - ag.setColor(colorMap[EndcapColor[j]]); - ag.fillPolygon(data.hv[0][j],data.hv[1][j], data.hv[0][j].length); - } - //draw frame around cell - if (drawFrame && !cellGeometry.getStatus()) - { - for (int j = 0; j < numCombinedCells; j++) - { - ag.setColor(colorMap[frameColor]); - ag.drawPolygon(data.hv[0][j], data.hv[1][j], data.hv[0][j].length); - } - } - } - - /** - * Scales a series of polygons according to the user settings. - * Used for summing over layer in the Endcaps in the YX projection - * - * @param cellEnergy double[] list of each cells energy - * @param coord ACoord polygons to be scaled - * @param minEnergy double min Energy in a cell - * @param maxEnergy double max Energy in a cell - * - * @return ACoord scaled polygons - */ - protected static ACoord scaleEndcapPolygons(double[] cellEnergy, ACoord coord, double minEnergy, double maxEnergy) - { - int energyMode = parameterStore.get(name, "EnergyMode").getI(); - - for (int i = 0; i < cellEnergy.length; i++) - { - if (cellEnergy[i] == 0) - continue; - - double factor; - if (parameterStore.get(name, "ColorFunction").getI() != ACalorimeterData.COLOR_FUNC_ENERGY) - { - // The user has (implicitly) selected energy scaling. - - //each cell is scaled to the new 0.1*0.1 binning so - //density for each just depends on energy - double density = cellEnergy[i]; - double minDensity = minEnergy; - double maxDensity = maxEnergy; - - switch (energyMode) - { - case ACalorimeterData.ENERGY_MODE_MAX_LIN: - case ACalorimeterData.ENERGY_MODE_SUM_LIN: - factor = Math.sqrt(density / maxDensity); - break; - - case ACalorimeterData.ENERGY_MODE_MAX_LOG: - case ACalorimeterData.ENERGY_MODE_SUM_LOG: - double magnitude = Math.floor(Math.log10(Math.sqrt(maxDensity / minDensity)) + 1.0); - factor = (Math.log10(Math.sqrt(density / maxDensity)) + magnitude) / magnitude; - break; - - case ACalorimeterData.ENERGY_MODE_MAX_SQRT: - case ACalorimeterData.ENERGY_MODE_SUM_SQRT: - factor = Math.sqrt(Math.sqrt(density / maxDensity)); - break; - - default: - factor = ACalorimeterData.getNonScalingFactor(); - } - } - else - { - // No energy scaling, scale all cells by the same factor. - factor = ACalorimeterData.getNonScalingFactor(); - } - - if (factor <= 1.0) - { - APolygon.scale(coord.hv[0][i], coord.hv[1][i], factor); - } - } - return coord; - } - - /** - * Determines the color for each hit according to the color function set by - * the user. Used for summing over layer in the Endcaps in the YX projection - * - * @param cellEnergy double[] list of each cells energy - * @param minEnergy double min Energy in a cell - * @param maxEnergy double max Energy in a cell - * - * @return byte[] colors for each energy - */ - protected static byte[] internalEndcapColor(double[] cellEnergy, double minEnergy, double maxEnergy) - { - byte[] EndcapColor= new byte[cellEnergy.length]; - - int colorFunction = parameterStore.get(name, "ColorFunction").getI(); - int constantColor = parameterStore.get(name, "Constant").getI(); - switch (colorFunction) - { - case ACalorimeterData.COLOR_FUNC_CONSTANT: - //colorByConstant(); - for(int i = 0; i < cellEnergy.length; i++) - EndcapColor[i] = (byte) constantColor; - break; -/* case COLOR_FUNC_SUBDET: - colorBy(sub); - break; - - case COLOR_FUNC_CLUSTER: - colorBy(getClusters()); - break; - - case COLOR_FUNC_SAMPLING: - colorBy(sampling); - break; -*/ - case ACalorimeterData.COLOR_FUNC_ENERGY: - EndcapColor=colorEndcapByEnergy( cellEnergy, minEnergy, maxEnergy); - break; -/* - case COLOR_FUNC_JET: - colorBy(getJets()); - break; -*/ - default: - for(int i = 0; i < cellEnergy.length; i++) - EndcapColor[i] = (byte) constantColor; - } - - return EndcapColor; - } - - /** - * Color cells by energy. - * Used for summing over layer in the Endcaps in the YX projection - * - * @param cellEnergy double[] list of each cells energy - * @param minEnergy double min Energy in a cell - * @param maxEnergy double max Energy in a cell - * - * @return byte[] colors for each energy - */ - protected static byte[] colorEndcapByEnergy(double[] cellEnergy, double minEnergy, double maxEnergy) - { - byte[] EndcapColor= new byte[cellEnergy.length]; - int numColors = 17; - for (int i = 0; i < cellEnergy.length; i++) - { - if (AColorMap.getColorMap() == AColorMap.COLOR_MAP_BW) - { - // Black and white colormap. - EndcapColor[i] = AColorMap.BK; - } - else - { - // We have numColors colors available. - switch (parameterStore.get(name, "EnergyMode").getI()) - { - case ACalorimeterData.ENERGY_MODE_MAX_LIN: - case ACalorimeterData.ENERGY_MODE_SUM_LIN: - EndcapColor[i] = (byte) (numColors * (cellEnergy[i] - minEnergy) / (maxEnergy - minEnergy)); - break; - case ACalorimeterData.ENERGY_MODE_MAX_LOG: - case ACalorimeterData.ENERGY_MODE_SUM_LOG: - EndcapColor[i] = (byte) (numColors * (Math.log(cellEnergy[i]) - Math.log(minEnergy)) / (Math.log(maxEnergy) - Math.log(minEnergy))); - break; - case ACalorimeterData.ENERGY_MODE_MAX_SQRT: - case ACalorimeterData.ENERGY_MODE_SUM_SQRT: - EndcapColor[i] = (byte) (numColors * Math.sqrt((cellEnergy[i] - minEnergy) / (maxEnergy - minEnergy))); - break; - } - if (EndcapColor[i] >= numColors) - EndcapColor[i] = (byte) (numColors - 1); - } - } - return EndcapColor; - } - - /** - * Energy of each color. - * Used for summing over layer in the Endcaps in the YX projection - * - * @param minEnergy double min Energy in a cell - * @param maxEnergy double max Energy in a cell - * - * @return byte[] colors for each energy - */ - protected static double[] energyOfEndcapColor(double minEnergy, double maxEnergy) - { - int numColors = 17; - double[] colorEnergy= new double[numColors]; - for (int i = 0; i < numColors; i++) - { - // We have numColors colors available. - switch (parameterStore.get(name, "EnergyMode").getI()) - { - case ACalorimeterData.ENERGY_MODE_MAX_LIN: - case ACalorimeterData.ENERGY_MODE_SUM_LIN: - colorEnergy[i] = ((i * (maxEnergy - minEnergy))/numColors)+minEnergy; - break; - case ACalorimeterData.ENERGY_MODE_MAX_LOG: - case ACalorimeterData.ENERGY_MODE_SUM_LOG: - colorEnergy[i] = Math.exp(((i * (Math.log(maxEnergy) - Math.log(minEnergy)))/numColors)+Math.log(minEnergy)); - break; - case ACalorimeterData.ENERGY_MODE_MAX_SQRT: - case ACalorimeterData.ENERGY_MODE_SUM_SQRT: - colorEnergy[i] = (Math.pow(i/numColors,2) * (maxEnergy - minEnergy))+minEnergy; - break; - } - //may need check to see if lower or higher than min or max - if (colorEnergy[i] >= numColors) - colorEnergy[i] = (byte) (numColors -1); - } - return colorEnergy; - } - -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/canvas/AGLGraphics.java b/graphics/AtlantisJava/src/atlantis/canvas/AGLGraphics.java deleted file mode 100644 index ee0c032ad052d752fcc214b43c40737f0bf640c9..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/AGLGraphics.java +++ /dev/null @@ -1,486 +0,0 @@ -package atlantis.canvas; - -import atlantis.graphics.AAbstractGraphics2D; -import com.sun.opengl.util.BufferUtil; -import java.awt.*; -import java.awt.RenderingHints.Key; -import java.awt.color.ColorSpace; -import java.awt.geom.AffineTransform; -import java.awt.geom.PathIterator; -import java.awt.geom.Rectangle2D; -import java.awt.image.BufferedImage; -import java.awt.image.ComponentColorModel; -import java.awt.image.DataBuffer; -import java.awt.image.DataBufferByte; -import java.awt.image.ImageObserver; -import java.awt.image.Raster; -import java.awt.image.WritableRaster; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; -import java.text.AttributedCharacterIterator; -import javax.media.opengl.*; - -/** - * - * This class is an implementation of Graphics2D (although it actually subclasses - * AAbstractGraphics2D). It wraps a GLAutoDrawable object to allow Swing based - * components to paint and have their calls translated into OpenGL calls on the - * underlying context. - * - * Obviously emulating all the functionality of Graphics2D is a challenge - * so expect some visual issues initially... - * - * @author Adam Davison - */ -public class AGLGraphics extends AAbstractGraphics2D { - - private int m_clipx = 0; - private int m_clipy = 0; - private int m_clipw = 0; - private int m_cliph = 0; - private Color m_color = Color.BLACK; - private GLAutoDrawable m_d; - private GL m_gl; - private int m_depth = 1; - private ComponentColorModel m_colorModel = - new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), - new int[]{8, 8, 8, 8}, true, false, ComponentColorModel.TRANSLUCENT, - DataBuffer.TYPE_BYTE); - - public AGLGraphics(AGLGraphics old) { - m_d = old.m_d; - m_gl = m_d.getGL(); - } - - /* - * Draw shapes, don't actually implement cubic or quadratic curves yet. - * For now we only draw straight lines. - * Having said that Atlantis uses such a huge number of segments that this - * doesn't seem to be an issue for visual quality as of yet... - */ - @Override - public void draw(Shape z) { - PathIterator pi = z.getPathIterator(null); - float[] c = new float[6]; - float xpos = 0.0f; - float ypos = 0.0f; - while (!pi.isDone()) { - int type = pi.currentSegment(c); - switch (type) { - case PathIterator.SEG_MOVETO: - xpos = c[0]; - ypos = c[1]; - break; - case PathIterator.SEG_CLOSE: - // Ignoring close lines for now I guess... - break; - case PathIterator.SEG_CUBICTO: - drawLine(c[2], c[3], c[4], c[5]); - case PathIterator.SEG_QUADTO: - drawLine(c[0], c[1], c[2], c[3]); - case PathIterator.SEG_LINETO: - // Just do lines... - drawLine(xpos, ypos, c[0], c[1]); - xpos = c[0]; - ypos = c[1]; - break; - } - pi.next(); - } - //super.draw(z); - } - - public AGLGraphics(GLAutoDrawable d) { - m_d = d; - m_gl = m_d.getGL(); - } - - /* - * This implementation of create()/dispose() is highly thread unsafe - * Since it's not trivial to duplicate the GL context we do the best we can - * and hopefully it's ok for Atlantis. - * - * Essentially where Java2D would create a whole new object which would then - * have it's own state, we push the modelview stack. This means that - * we can perform transformations and then pop the modelview stack in dispose - * to emulate this functionality. - * - * Obviously if you call create twice in two separate threads then one of - * you is destroying the other one's modelview matrix... - */ - @Override - public Graphics create() { - m_gl.glMatrixMode(GL.GL_MODELVIEW_MATRIX); - m_gl.glPushMatrix(); - m_depth++; - //System.err.println("PUSH: " + depth); - //return new AGLGraphics(this); //????? - return this; - } - - @Override - public void translate(int x, int y) { - m_gl.glMatrixMode(GL.GL_MODELVIEW_MATRIX); - m_gl.glTranslatef(x, y, 0.0f); - return; - } - - @Override - public Color getColor() { - return m_color; - } - - @Override - public void setColor(Color c) { - m_color = c; - //System.out.println(c.toString()); - float r = ((float) c.getRed()) / 255.0f; - float g = ((float) c.getGreen()) / 255.0f; - float b = ((float) c.getBlue()) / 255.0f; - float a = ((float) c.getAlpha()) / 255.0f; - m_d.getGL().glColor4f(r, g, b, a); - } - - @Override - public void setPaintMode() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setXORMode(Color c1) { - throw new UnsupportedOperationException("Not supported yet."); - } - - private Font m_font = Font.decode("Arial-BOLD-18"); - - @Override - public Font getFont() { - return m_font; - } - - @Override - public void setFont(Font font) { - m_font = font; - } - - @Override - public FontMetrics getFontMetrics(Font f) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Rectangle getClipBounds() { - return new Rectangle(m_clipx, m_clipy, m_clipw, m_cliph); - } - - @Override - public void clipRect(int x, int y, int width, int height) { - throw new UnsupportedOperationException("Not supported yet."); - } - - /* - * Sort of ignoring clip here... - */ - @Override - public void setClip(int x, int y, int width, int height) { - m_clipx = x; - m_clipy = y; - m_clipw = width; - m_cliph = height; - //System.out.println("Who cares about clip for now??"); - //throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Shape getClip() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setClip(Shape clip) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void copyArea(int x, int y, int width, int height, int dx, int dy) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void drawLine(int x1, int y1, int x2, int y2) { - drawLine((float) x1, (float) y1, (float) x2, (float) y2); - } - - public void drawLine(float x1, float y1, float x2, float y2) { - m_gl.glBegin(m_gl.GL_LINES); - m_gl.glVertex2f(x1, y1); - m_gl.glVertex2f(x2, y2); - m_gl.glEnd(); - } - - @Override - public void fillRect(int x, int y, int width, int height) { - GL gl = m_d.getGL(); - - gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL); - - gl.glBegin(gl.GL_QUADS); - gl.glVertex2f(x, y); - gl.glVertex2f(x + width, y); - gl.glVertex2f(x + width, y + height); - gl.glVertex2f(x, y + height); - gl.glEnd(); - } - - @Override - public void clearRect(int x, int y, int width, int height) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void drawOval(int x, int y, int width, int height) { - throw new UnsupportedOperationException("Not supported yet."); - - } - - @Override - public void fillOval(int x, int y, int width, int height) { - //throw new UnsupportedOperationException("Not supported yet."); - return; - } - - @Override - public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) { - m_gl.glPolygonMode(m_gl.GL_FRONT_AND_BACK, m_gl.GL_LINE); - - m_gl.glBegin(m_gl.GL_POLYGON); - - for (int i = 0; i < nPoints; i++) { - m_gl.glVertex2f(xPoints[i], yPoints[i]); - } - - m_gl.glEnd(); - } - - public void fillPolygon(double[] xPoints, double[] yPoints, int nPoints) { - - m_gl.glPolygonMode(m_gl.GL_FRONT_AND_BACK, m_gl.GL_FILL); - - m_gl.glBegin(m_gl.GL_POLYGON); - - for (int i = 0; i < nPoints; i++) { - m_gl.glVertex2d(xPoints[i], yPoints[i]); - } - - m_gl.glEnd(); - } - - /* - * Bear in mind that although Java2D is capable of filling arbitrary - * polygons, OpenGL/graphics cards in general use a very simple fill - * algorithm which is only guaranteed to be valid for convex polygons - * If you want to render a concave polygon you have to tessellate it down - * into convex ones. - * - * So far I've been able to do this by modifying the way geometry is - * represented but you can also have a go at tessellating automatically - * using GLUT if you really need to... - */ - @Override - public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) { - - // Prototype code for vertex arrays, actually slower for single polys - // but will definitely improve importance if we start passing in big - // arrays of polygons, say for complex geometry - if (false) { - IntBuffer ib = BufferUtil.newIntBuffer(nPoints * 2); - for (int i = 0; i < nPoints; i++) { - ib.put(xPoints[i]); - ib.put(yPoints[i]); - } - ib.rewind(); - m_gl.glEnableClientState(GL.GL_VERTEX_ARRAY); - m_gl.glVertexPointer(2, GL.GL_INT, 0, ib); - m_gl.glDrawArrays(GL.GL_POLYGON, 0, nPoints); - } else { - // Draw the simple way - - m_gl.glPolygonMode(m_gl.GL_FRONT_AND_BACK, m_gl.GL_FILL); - m_gl.glBegin(m_gl.GL_POLYGON); - - for (int i = 0; i < nPoints; i++) { - m_gl.glVertex2f(xPoints[i], yPoints[i]); - } - - m_gl.glEnd(); - } - } - - @Override - public Stroke getStroke() { - return null; - } - - @Override - public void setStroke(Stroke z) { - //super.setStroke(z); - } - - @Override - public void drawString(String str, int x, int y) { - //FontRenderContext frc = new FontRenderContext(null, true, true); - //GlyphVector gv = m_font.layoutGlyphVector(frc, str.toCharArray(), - // 0, str.length(), Font.LAYOUT_LEFT_TO_RIGHT); - //int ng = gv.getNumGlyphs(); - //Rectangle2D r = gv.getVisualBounds(); - //m_gl.glColor3f(1.0f, 0.0f, 0.0f); - //this.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight()); - //this.setColor(m_color); - - WritableRaster test = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, - 32, 32, 4, null); - BufferedImage testi = new BufferedImage(m_colorModel, test, false, null); - Graphics testg = testi.getGraphics(); - FontMetrics fm = testg.getFontMetrics(m_font); - Rectangle2D r = fm.getStringBounds(str, testg); - - WritableRaster raster = - Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, - (int)r.getWidth(), (int)r.getHeight(), 4, null); - - BufferedImage bi = new BufferedImage(m_colorModel, raster, false, null); - - Graphics big = bi.getGraphics(); - //big.setColor(Color.GREEN); - //big.fillRect(0, 0, bi.getWidth(), bi.getHeight()); - big.setColor(m_color); - big.setFont(m_font); - big.drawString(str, -(int)r.getX(), -(int)r.getY()); - drawImage(bi, x, (int)(y - r.getHeight()), null); - } - - @Override - public void drawString(AttributedCharacterIterator iterator, int x, int y) { - //throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean drawImage(Image img, int x, int y, ImageObserver observer) { - WritableRaster raster = - Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, - img.getWidth(observer), img.getHeight(observer), 4, null); - - BufferedImage bi = new BufferedImage(m_colorModel, raster, false, null); - - Graphics2D g = bi.createGraphics(); - //g.setColor(Color.WHITE); - //g.drawLine(0, 0, bi.getWidth(), bi.getHeight()); - AffineTransform gt = new AffineTransform(); - gt.translate(0, img.getHeight(observer)); - gt.scale(1, -1d); - g.transform(gt); - g.drawImage(img, null, null); - - DataBufferByte imgbuf = (DataBufferByte) raster.getDataBuffer(); - - m_gl.glRasterPos2i(x, y + bi.getHeight()); - //System.out.println(img.getWidth(observer) + ":" + img.getHeight(observer)); - m_gl.glDrawPixels(img.getWidth(observer), img.getHeight(observer), - m_gl.GL_RGBA, m_gl.GL_UNSIGNED_BYTE, ByteBuffer.wrap(imgbuf.getData())); - - //System.out.println("Ignoring drawImage for now..."); - return true; - //throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) { - // Needed to render JComponent backgrounds - //throw new UnsupportedOperationException("Not supported yet."); - return true; - } - - @Override - public Object getRenderingHint(Key z) { - return null; - } - - @Override - public void setRenderingHint(Key a, Object z) { - return; - } - - @Override - public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void dispose() { - m_depth--; - if (m_depth == 0) { - m_depth = 1; - // This happens when the object is really finally destroyed... - // When this is actually happening if we pop we'll cause a crash... - //System.err.println("DISPOSE CALLED TWICE ON ONE OBJECT!!!"); - //(new Exception()).printStackTrace(); - } else { - m_gl.glMatrixMode(GL.GL_MODELVIEW_MATRIX); - m_gl.glPopMatrix(); - } - return; - // We didn't create so no need to dispose... probably bad... - //throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void rotate(double a, double b, double z) { - super.rotate(a, b, z); - } - - @Override - public void rotate(double z) { - m_gl.glMatrixMode(GL.GL_MODELVIEW_MATRIX); - m_gl.glRotated(z * 360 / (2 * Math.PI), 0.0, 0.0, 1.0); - } -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/canvas/ALayout.java b/graphics/AtlantisJava/src/atlantis/canvas/ALayout.java deleted file mode 100755 index 7710aff90f88b177e9c0f9c89e0effae2fc23056..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/ALayout.java +++ /dev/null @@ -1,231 +0,0 @@ -package atlantis.canvas; - - -import java.util.Hashtable; -import java.util.Enumeration; -import java.awt.Rectangle; -import java.awt.Dimension; -import org.w3c.dom.*; - - -/** - * This class is not an Layout Manager! It contains the possible window - * configuration - i.e. the possible subdivision of the canvas area in windows. - * Layouts are identified by names such as "SQUARE","FULL_SCREEN". - * Windows are identified by single characters such as "W","1", etc. - * Windows are furthermore grouped in pages such that they do not overlap. - * Pages are identified by the sum of the windows they contain, such as "Full","Vert" - * This class is used mainly by ACanvas and AWindowControl. - */ - -public class ALayout { - //The name of the layout - private String name; - //A table of the window constraints (i.e. corners) for all windows - private Hashtable windowConstraints; - //A table of the pages - private Hashtable pages; - //The default top window for this layout - private String startupWindow; - //The list of window names that by default are - //on the top in this layout - private String[] startupSequence; - - - /** - * Default constructor - * - * @param node XML node with the configuration - */ - public ALayout(Node node) { - //Create new hashtables for window corners and pages - windowConstraints=new Hashtable(); - pages=new Hashtable(); - - // reading the layout attributes - NamedNodeMap attributes=node.getAttributes(); - name=attributes.getNamedItem("name").getNodeValue(); - startupWindow=attributes.getNamedItem("startupWindow").getNodeValue(); - startupSequence=decompose(attributes.getNamedItem("startup").getNodeValue()); - - // reading all the content of Layout node - // - i.e pages and window settings - NodeList childrens=node.getChildNodes(); - for(int i=0; i<childrens.getLength(); i++) { - //get the subnode - Node child=childrens.item(i); - //read in window or page information - if(child.getNodeType()==Node.ELEMENT_NODE) { - //check wether it is a window or page configuration - String nodeName=child.getNodeName(); - if(nodeName.equals("Window")) - readWindow(child); - else if(nodeName.equals("Page")) - readPage(child); - } - } - } - - /** - * Read the window configuration (name/size/position) from an XML node - * - * @param node XML node with the configuration - */ - private void readWindow(Node child) { - //Get the nodes attributes - NamedNodeMap attributes=child.getAttributes(); - //retrieve window information - String name=attributes.getNamedItem("name").getNodeValue(); - int hPos=Integer.parseInt(attributes.getNamedItem("hPos").getNodeValue()); - int vPos=Integer.parseInt(attributes.getNamedItem("vPos").getNodeValue()); - int width=Integer.parseInt(attributes.getNamedItem("width").getNodeValue()); - int height=Integer.parseInt(attributes.getNamedItem("height").getNodeValue()); - //Check if this is a valid window name - if(!ACanvas.getCanvas().isValidWindowName(name)) - throw new Error("Undefined window name: "+name); - //Check if this window has been defined before - if(windowConstraints.containsKey(name)) - throw new Error("Multiple usage of window name: "+name); - //Validate window size and position - if((hPos<0)||(vPos<0)||(width<0)||(height<0)) - throw new Error("Wrong window constraints"); - //Add window constraints to the list - windowConstraints.put(name, new Rectangle(hPos, vPos, width, height)); - } - - /** - * Read the page configuration (windows it contains) from the XML node - */ - private void readPage(Node child) { - //get the attributes - NamedNodeMap attributes=child.getAttributes(); - //retrieve page configuration - String name=attributes.getNamedItem("name").getNodeValue(); - String content=attributes.getNamedItem("content").getNodeValue(); - - //Check if this page exists before - if(pages.containsKey(name)) - throw new Error("Redefinition of page: "+name); - //Split the list of windows in single window names - //('S789' -> 'S','7','8','9') - String[] wContent=decompose(content); - - //Check that each of this is a valid window - for(int i=0; i<wContent.length; i++) - if(!ACanvas.getCanvas().isValidWindowName(wContent[i])) - throw new Error("Unknown window name: "+wContent[i]); - //Add this page - pages.put(name, wContent); - } - - /** - * Break up a string of window names into a list of single window names - * - * @param s the string to break up - */ - private String[] decompose(String s) { - String[] strings=new String[s.length()]; - char[] characters=s.toCharArray(); - - for(int i=0; i<characters.length; i++) - strings[i]=new String(new char[] {characters[i]}); - - return strings; - } - - /** - * Return the layout name - */ - public String getName() { - return name; - } - - /** - * Return the window selected on startup - */ - public String getStartupWindow() { - return startupWindow; - } - - /** - * Return the list of window names that are on top by default - */ - public String[] getStartupSequence() { - return startupSequence; - } - - /** - * Check if window is part of this layout - */ - public boolean hasWindow(String wName) { - return windowConstraints.containsKey(wName); - } - - /** - * Return window names in this layout - */ - public String[] getWindowNames() { - // Loop over the window constraints and retrieve - // window names. - Enumeration wn=windowConstraints.keys(); - int size=windowConstraints.size(); - String[] names=new String[size]; - //Add them all to the array - for(int i=0; i<size; i++) - names[i]=(String)wn.nextElement(); - - return names; - } - - /** - * Return the constraints (i.e. position and size) - * for a particular window - * - * @param wName the name of the window - */ - public Rectangle getWindowConstraints(String wName) { - return(Rectangle)windowConstraints.get(wName); - } - - /** - * Calculate the size of the layout from all its subwindows - */ - public Dimension getSize() { - - Enumeration myenum=windowConstraints.elements(); - int w=0, h=0; - //Loop over all windows - while(myenum.hasMoreElements()) { - Rectangle r=(Rectangle)myenum.nextElement(); - //Check if they exceed the current size - if(r.x+r.width>w) - w=r.x+r.width; - if(r.y+r.height>h) - h=r.y+r.height; - } - - return new Dimension(w, h); - } - - /** - * Return a list of the page names - */ - public String[] getPageNames() { - Enumeration myenum=pages.keys(); - int size=pages.size(); - String[] names=new String[size]; - - for(int i=0; i<size; i++) - names[i]=(String)myenum.nextElement(); - - return names; - } - - /** - * Return a list of the windows that a certain page consists of - */ - public String[] getPageContent(String pageName) { - return(String[])pages.get(pageName); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/canvas/ALayoutChangeListener.java b/graphics/AtlantisJava/src/atlantis/canvas/ALayoutChangeListener.java deleted file mode 100644 index 521e31440d1ea790441437d484726acddc565620..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/ALayoutChangeListener.java +++ /dev/null @@ -1,16 +0,0 @@ -package atlantis.canvas; - -/** - * Interface for all LayoutChangeListener classes. Each time the layout is - * changed, the layoutChanged method is called with the layout as an argument - * @author maillard - */ -public interface ALayoutChangeListener { - - /** - * This method gets called each time the layout is changed. - * @param canvas the canvas - */ - abstract public void layoutChanged(ACanvas canvas); - -} diff --git a/graphics/AtlantisJava/src/atlantis/canvas/ALegendWindow.java b/graphics/AtlantisJava/src/atlantis/canvas/ALegendWindow.java deleted file mode 100755 index b6397cf61f94e11d3aa99fd57ef5b97448ae7ead..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/ALegendWindow.java +++ /dev/null @@ -1,197 +0,0 @@ -package atlantis.canvas; - -import java.awt.Color; -import java.awt.Component; -import java.awt.GridLayout; -import java.awt.Toolkit; - -import javax.swing.JFrame; -import javax.swing.JTextField; - -import atlantis.globals.AGlobals; -import atlantis.graphics.AIcon; -import atlantis.graphics.colormap.AColorMap; - -/** - * The legend window appears when selected in the preferences menu - * It displays the energy scale for the summed endcaps as these do not - * have the pick interaction. - * - * Moved from package atlantis.gui to atlantis.canvas because of closer - * coupling with classes in atlantis.canvas and atlantis.data. Could move - * back later if can be decoupled. (Ben Waugh, 2011-10-01) - * - * @author Mark Stockton - */ -public class ALegendWindow extends JFrame -{ - private static JTextField[] titleField = new JTextField[2]; - private static JTextField[] textField; - private static ALegendWindow instance = null; - - public static ALegendWindow getInstance() - { - if (instance == null) - instance = new ALegendWindow(); - return instance; - } - - /** - * Check if ALegendWindow instance exists, without creating it if not. - * @return true if ALegendWindow instance exists - */ - public static boolean exists() { - return (instance != null); - } - - public void addEnergyText(AWindow window, double[] Energies, double Energy, Color[] colorMap) - { - if(window.equals(ACanvas.getCanvas().getCurrentWindow())) - { - getContentPane().removeAll(); - validate(); - getContentPane().setLayout(new GridLayout(Energies.length+titleField.length,1)); - - titleField[0].setText("Color Energy thresholds:"); - getContentPane().add(titleField[0]); - if(titleField[1]==null) - titleField[1]=new JTextField(); - titleField[1].setEditable(false); - titleField[1].setBackground(Color.white); - titleField[1].setForeground(Color.black); - titleField[1].setText("Maximum Cell Energy: " + (Math.rint(1000. * Energy)/1000) + " GeV "); - getContentPane().add(titleField[1]); - - String s=""; - for(int i=Energies.length-1;i>=0;i--) - { - if(textField[i]==null) - textField[i]=new JTextField(); - textField[i].setEditable(false); - //to even out the line spacing - if(i<10) - s="0" + i; - else - s="" + i; - s ="Color " + s + " Energy from: " + (Math.rint(1000. * Energies[i])/1000) + " GeV"; - textField[i].setText(s); - textField[i].setBackground(colorMap[i]); - //find out if too dark for black text - if( colorMap[i].getRed() + colorMap[i].getGreen() + - colorMap[i].getBlue()<=128) - textField[i].setForeground(Color.white); - else - textField[i].setForeground(Color.black); - getContentPane().add(textField[i]); - } - invalidate(); - pack(); - setVisible(true); - } - } - - public void addEnergyText(AWindow window, double minEnergy, double maxEnergy) - { - if(window.equals(ACanvas.getCanvas().getCurrentWindow())) - { - getContentPane().removeAll(); - validate(); - getContentPane().setLayout(new GridLayout(3,1)); - titleField[0].setText("Color Energy thresholds:"); - getContentPane().add(titleField[0]); - if(titleField[1]==null) - titleField[1]=new JTextField(); - titleField[1].setEditable(false); - titleField[1].setBackground(Color.white); - titleField[1].setForeground(Color.black); - titleField[1].setText("Maximum Cell Energy: " + (Math.rint(1000. * maxEnergy)/1000) + " GeV "); - getContentPane().add(titleField[1]); - - if(textField[0]==null) - textField[0]=new JTextField(); - textField[0].setEditable(false); - textField[0].setText("Minimum Cell Energy: " + (Math.rint(1000. * minEnergy)/1000) + " GeV "); - textField[0].setBackground(Color.white); - textField[0].setForeground(Color.black); - getContentPane().add(textField[0]); - invalidate(); - pack(); - setVisible(true); - } - } - - public void clearText(AWindow window) - { - if(!titleField[0].getText().equals("Select colour by Energy to bring up scale") - && window.equals(ACanvas.getCanvas().getCurrentWindow())) - { - getContentPane().removeAll(); - validate(); - getContentPane().setLayout(new GridLayout(1,1)); - titleField[0].setText("Select colour by Energy to bring up scale"); - getContentPane().add(titleField[0]); - invalidate(); - pack(); - setVisible(true); - } - } - - public void nothingToDisplay(AWindow window) - { - if(!titleField[0].getText().equals("Select LAr/HEC Summed and colour by Energy to bring up scale") - && window.equals(ACanvas.getCanvas().getCurrentWindow())) - { - getContentPane().removeAll(); - validate(); - getContentPane().setLayout(new GridLayout(1,1)); - titleField[0].setText("Select LAr/HEC Summed and colour by Energy to bring up scale"); - getContentPane().add(titleField[0]); - invalidate(); - pack(); - setVisible(true); - } - - } - - private ALegendWindow() - { - this.setTitle("Legend"); - AIcon.setIconImage(this); - this.setResizable(false); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - int numColors = AColorMap.getNumColors(); - getContentPane().setLayout(new GridLayout(1,1)); - textField = new JTextField[numColors]; - titleField[0] =new JTextField(); - titleField[0].setEditable(false); - titleField[0].setBackground(Color.white); - titleField[0].setForeground(Color.black); - titleField[0].setText("Select LAr/HEC Summed and colour by Energy to bring up scale"); - getContentPane().add(titleField[0]); - - // set the initial location - Component gui = AGlobals.instance().getGuiFrame(); - int guiWidth = gui.getWidth(); - int guiHeight = gui.getHeight(); - int guiX = gui.getX(); - int dialogWidth = (int) this.getPreferredSize().getWidth(); - int dialogHeight = (int) this.getPreferredSize().getHeight(); - int screenWidth = Math.round((float) Toolkit.getDefaultToolkit() - .getScreenSize().getWidth()); - if (guiX + guiWidth + (dialogWidth - guiWidth) / 2 > screenWidth) - this.setLocation(Math.max(0, screenWidth - dialogWidth), Math.max( - 0, (guiHeight - dialogHeight) / 3)); - else - this.setLocation(Math.max(0, guiX + (guiWidth - dialogWidth) / 2), - Math.max(0, (guiHeight - dialogHeight) / 3)); - - pack(); - setVisible(true); - } - - public void dispose() - { - instance = null; - super.dispose(); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/canvas/AOverlay.java b/graphics/AtlantisJava/src/atlantis/canvas/AOverlay.java deleted file mode 100644 index f4147695a9134eb8fcc278f04284205469b518f7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/AOverlay.java +++ /dev/null @@ -1,193 +0,0 @@ -package atlantis.canvas; - -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; - -import javax.swing.ImageIcon; -import javax.swing.JPanel; - -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.globals.AGlobals; -import atlantis.graphics.AGraphics; -import atlantis.parameters.APar; -import atlantis.utils.AUtilities; - -/** - * AOverlay should be used within a GlassPane in the ACanvas. - * The overlay acts as a canvas on which images can be drawn over the existing display. - * This is currently only used to draw the ATLAS logo and Run/Event info as a floating image. - * Any drawing should be done with the paintComponent method, which is called as the Canvas is drawn. - * @author Tom McLaughlan - */ -public class AOverlay extends JPanel { - - protected static APar parameterStore = APar.instance(); - - public AOverlay() { - setOpaque(false); - } - - /** - * When the ACanvas GlassPane contains an Overlay instance, this is called - * after the Canvas is drawn. - */ - @Override public void paintComponent(Graphics g) { - super.paintComponent(g); - if(parameterStore.get("Logo","ShowATLAS").getStatus()) - drawATLASLogo(g); - } - - /** - * Draws a scaled version of the ATLAS PNG in the Overlay - * @param g The Graphics instance to draw to - */ - protected void drawATLASLogo(Graphics g) { - - int windowWidth = getWidth(); - int windowHeight = getHeight(); - - int logoWidth = 0; - int logoHeight = 0; - - double size = parameterStore.get("Logo", "LogoSize").getD(); - - logoWidth = (int) (windowWidth*size); - logoHeight = (int) (logoWidth*0.6); - - int logoX = 0; - int logoY = 0; - - double hpos = parameterStore.get("Logo", "LogoHPos").getD(); - logoX = (int) ((hpos * (windowWidth-logoWidth))); - - double vpos = parameterStore.get("Logo", "LogoVPos").getD(); - - int heightOffset = 0; - if(parameterStore.get("Prefs", "CanvasTitle").getStatus()) { - windowHeight = this.getParent().getHeight() - 40; - heightOffset = 40; - } - logoY = (int) ((vpos * (windowHeight-logoHeight))) + heightOffset; - - - long EventNumber = 0; - long RunNumber = 0; - String DateTime = ""; - Color textColor = Color.white, - backgroundColor = Color.black; - - AEvent event = AEventManager.instance().getCurrentEvent(); - - if (event != null) { - RunNumber = event.getRunNumber(); - EventNumber = event.getEventNumber(); - DateTime = event.getDateTime(); - } - - // Begin drawing - AGraphics ag = AGraphics.makeAGraphics(g); - // Fill the background - ag.setColor(backgroundColor); - //ag.fillRect(logoX, logoY, logoWidth, logoHeight); - - String iconPath = AGlobals.instance().getHomeDirectory() + "img" + System.getProperty("file.separator"); - - ImageIcon i = AUtilities.getFileAsImageIcon(iconPath + "atlas_logo_shadow.png"); - - - // Determine height and width of current window, and width of ATLAS logo - // These are then used to determine a scaling factor which is used in the - // scale function. - // - - int iwidth = i.getIconWidth(); - double factor = (double) logoWidth / (double) iwidth; - - // Call scale function to scale image to window size - ImageIcon iscale = AUtilities.scale(i.getImage(), factor, parameterStore.get("Prefs", "AntiAlias").getStatus()); - // x, y calculated to position image exactly centred - int x = (logoWidth / 2) - (iscale.getIconWidth() / 2); - int y = (logoHeight / 2) - ((3 * iscale.getIconHeight()) / 4); - - x += logoX; - y += logoY; - - int dpi = 72; - - // Set a scaling font size with window width - int fontSize = (int) Math.round(3.0 * logoWidth / (double) dpi) - 2; - - Font f = new Font("SansSerif", Font.PLAIN, fontSize); - - ag.drawImage(iscale.getImage(), x, y); - - ag.setColor(textColor); // Set colour for text - ag.updateColor(); // Update current colour for drawing - - String DateString = "", RunEventString = ""; - if (event != null) { - DateString = "Date: " + DateTime; - RunEventString = "Run Number: " + RunNumber + ", Event Number: " + EventNumber; - } else { - RunEventString = "No event data available"; - } - - FontMetrics fm = g.getFontMetrics(f); - int DateWidth = fm.stringWidth(DateString); - int RunEventWidth = fm.stringWidth(RunEventString); - - // Check if font is wider than the window and scale down til it fits. - while ((RunEventWidth > logoWidth - 20) || (DateWidth > logoWidth - 20)) - { - - fontSize = fontSize - 1; - f = new Font("SansSerif", Font.PLAIN, fontSize); - fm = g.getFontMetrics(f); - RunEventWidth = fm.stringWidth(RunEventString); - DateWidth = fm.stringWidth(DateString); - } - - ag.setFont(f); // set font as defined above - - if (event != null) { - drawStrokedString(ag, RunEventString, logoX + (logoWidth / 2) - RunEventWidth / 2, (int) (y + (1.1 * iscale.getIconHeight())), Color.WHITE, Color.BLACK); - //ag.drawString(RunEventString, - // logoX + (logoWidth / 2) - RunEventWidth / 2, y + (1.1 * iscale.getIconHeight())); - - if(!DateTime.equals("") && !DateTime.equals("n/a")) { - // If event contains Date/Time data, draw Run Number, Event Number and Date/Time - // and position text in centre of window - drawStrokedString(ag, DateString, logoX + (logoWidth / 2) - DateWidth / 2, (int) (y + (1.3 * iscale.getIconHeight())), Color.WHITE, Color.BLACK); - - //ag.drawString(DateString, - // logoX + (logoWidth / 2) - DateWidth / 2, y + (1.3 * iscale.getIconHeight())); - } - } - } - - /** - * Draws text with an outline, crudely. - * @param ag The AGraphics instance to draw to - * @param str The String to draw - * @param x x position of the string - * @param y y position of the string - * @param fg Text foreground colour - * @param bg Text outline colour - */ - protected void drawStrokedString(AGraphics ag, String str, int x, int y, Color fg, Color bg) { - ag.setColor(Color.BLACK); - ag.updateColor(); - ag.drawString(str, x-1, y-1); - ag.drawString(str, x+1, y+1); - ag.drawString(str, x+1, y-1); - ag.drawString(str, x-1, y+1); - ag.setColor(fg); - ag.updateColor(); - ag.drawString(str, x, y); - } - - -} diff --git a/graphics/AtlantisJava/src/atlantis/canvas/AScale.java b/graphics/AtlantisJava/src/atlantis/canvas/AScale.java deleted file mode 100644 index 8359fe7cc7cc3e197bef5bab380a767d8dd8d127..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/AScale.java +++ /dev/null @@ -1,356 +0,0 @@ -package atlantis.canvas; - -import java.awt.geom.GeneralPath; - -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjection; - -/** - * This class contains static methods which are useful for the - * AScaleBorder class and any potential subclasses. - * - * @author Charles Loomis, Ben Waugh - **/ -public class AScale { - final GeneralPath primaryTicks; - final GeneralPath secondaryTicks; - final double[] labelValues; // units are cm - final double[] labelPositions; // after transform - - final static public int LEFT_TICKS=0; - final static public int RIGHT_TICKS=1; - final static public int BOTH_TICKS=2; - - /** - * The size in pixels of the primary tick marks. This is a global - * property for all scales. */ - private static float primaryTickSize=8.f; - - /** - * The size in pixels of the secondary tick marks. This is a - * global property for all scales. */ - private static float secondaryTickSize=5.f; - - private AScale(GeneralPath primaryTicks, GeneralPath secondaryTicks, - double[] label, double[] position) { - this.primaryTicks = primaryTicks; - this.secondaryTicks = secondaryTicks; - this.labelValues = label; - this.labelPositions = position; - } - - /** - * Set the tick sizes (in pixels) for the primary and secondary - * tick marks. */ - static public void setTickSizes(float primaryTickSize, - float secondaryTickSize) { - AScale.primaryTickSize=primaryTickSize; - AScale.secondaryTickSize=secondaryTickSize; - } - - /** - * Get the primary tick size (in pixels). */ - static public float getPrimaryTickSize() { - return AScale.primaryTickSize; - } - - /** - * Get the secondary tick size (in pixels). */ - static public float getSecondaryTickSize() { - return AScale.secondaryTickSize; - } - - /** - * A utility method to add a tick mark to the given GeneralPath at - * the given position. */ - static private void addTickMark(GeneralPath gp, - int location, - float tickPosition, - float tickLength) { - - switch(location) { - - case(AScale.RIGHT_TICKS): - gp.moveTo(tickPosition, 0.f); - gp.lineTo(tickPosition, tickLength); - break; - - case(AScale.LEFT_TICKS): - gp.moveTo(tickPosition, 0.f); - gp.lineTo(tickPosition, -tickLength); - break; - - case(AScale.BOTH_TICKS): - gp.moveTo(tickPosition, -tickLength); - gp.lineTo(tickPosition, tickLength); - break; - } - } - - /** - * Get scale with given parameters. - * - * @param minValueTransformed min value after (fish-eye) transformation - * @param maxValueTransformed max value after (fish-eye) transformation - * @param scaleSize length of the scale border - * @param minPrimary minimum number of primary tick marks - * @param minSeparation minimum separation between tick marks - * @param location left,right,top,bottom - * @param isVertical whether this is a horizontal or vertical scale - * @param proj the projection this scale is drawn for - * @return - */ - public static AScale calculateScale( - double minValueTransformed, - double maxValueTransformed, - int scaleSize, - int minPrimary, - int minSeparation, - int location, - int isVertical, - AProjection proj - ){ - // Setup the two paths which will contain the primary and secondary tick marks. - GeneralPath primaryTicks = new GeneralPath(); - GeneralPath secondaryTicks = new GeneralPath(); - resetScale(primaryTicks,scaleSize); - resetScale(secondaryTicks,scaleSize); - - double minValue = invertTransformation(minValueTransformed,proj,isVertical); - double maxValue = invertTransformation(maxValueTransformed,proj,isVertical); - - double[] labelValues; - double[] labelPositions; - double[] intervals = getScaleIntervals(minValue,maxValue); - if (intervals!=null) { - double labelInterval = intervals[0]; - double primarySpacing = intervals[1]; - double secondarySpacing = intervals[2]; - addTickMarks(primaryTicks, proj, minValue, maxValue, primarySpacing, isVertical, location, primaryTickSize, scaleSize); - addTickMarks(secondaryTicks, proj, minValue, maxValue, secondarySpacing, isVertical, location, secondaryTickSize, scaleSize); - - // Now the labels with the correct precision must be made. - labelValues = getScaleValues(minValue,maxValue,labelInterval); - int numLabels = labelValues.length; - labelPositions = new double[numLabels]; - int ndigits=(int)(Math.floor(Math.log10(primarySpacing))); - ndigits=-Math.min(ndigits, 0); - - for (int i=0; i<labelValues.length; ++i) { - double valueTrans = applyTransformation(labelValues[i],proj,isVertical); - labelPositions[i] = (double) interpolate(valueTrans, scaleSize, minValueTransformed, maxValueTransformed); - } - } else { - labelValues = new double[] {}; - labelPositions = new double[] {}; - } - - return new AScale(primaryTicks,secondaryTicks,labelValues,labelPositions); - } - - /** - * Add tick marks at multiples of given spacing. - * - * @param path - * @param proj - * @param min - * @param max - * @param spacing - * @param isVertical - * @param location - * @param tickSize - * @param scaleSize - */ - private static void addTickMarks(GeneralPath path, - AProjection proj, double min, double max, double spacing, int isVertical, int location, float tickSize, double scaleSize) { - int minMultiplier = (int) Math.ceil(min/spacing); - int maxMultiplier = (int) Math.floor(max/spacing); - double minTrans = applyTransformation(min,proj,isVertical); - double maxTrans = applyTransformation(max,proj,isVertical); - for (int i=minMultiplier; i<=maxMultiplier; ++i) { - double value = i * spacing; - double valTrans = applyTransformation(value,proj,isVertical); - float tickPosition=interpolate(valTrans, scaleSize, minTrans, maxTrans); - addTickMark(path, location, tickPosition, tickSize); - } - - } - - private static void resetScale(GeneralPath path, double length) { - path.reset(); - path.moveTo(0.f, 0.f); - path.lineTo((float)length, 0.f); - } - - /** - * Convert from physical detector coordinate to transformed (fish-eye) coordinate. - * - * @param value - * @param proj - * @param isVertical - * @return - */ - private static double applyTransformation(double value, AProjection proj, int isVertical) { - double valueTransformed = value; - //Apply non-linear transforms if necessary - if (proj instanceof AProjection2D) { - if (isVertical==1) { - valueTransformed = ((AProjection2D)proj).nonLinearTransform(0,value).getY(); - } else { - valueTransformed = ((AProjection2D)proj).nonLinearTransform(value,0).getX(); - } - } - return valueTransformed; - } - - /** - * Convert from transformed (fish-eye) coordinate back to physical detector coordinate. - * - * @param valueTransformed - * @param proj - * @param isVertical - * @return - */ - private static double invertTransformation(double valueTransformed, AProjection proj, int isVertical) { - double value = valueTransformed; - //Apply non-linear transforms if necessary - if (proj instanceof AProjection2D) { - if (isVertical==1) { - value = ((AProjection2D)proj).inverseNonLinearTransform(0,valueTransformed).getY(); - } else { - value = ((AProjection2D)proj).inverseNonLinearTransform(valueTransformed,0).getX(); - } - } - return value; - } - - static float interpolate(double value, double size, - double value0, double value1) { - return(float)(size*(value-value0)/(value1-value0)); - } - - /** - * Title is put between last two value labels on axis. - * @return the position for the title on the scale - */ - public double getTitlePosition() { - double axisPosition; - int numLabels = labelPositions.length; - if (numLabels>=2) { - axisPosition = 0.5 * (labelPositions[numLabels-1] + labelPositions[numLabels-2]); - } else { - axisPosition = 0.0; // default to 0 if only one label (shouldn't happen) - } - return axisPosition; - } - - /** - * Get array of three intervals to use on scale. - * @param min minimum value on scale - * @param max maximum value on scale - * @return intervals to use for [labels, primary tick marks, secondary tick marks] - */ - static double[] getScaleIntervals(double min, double max) { - if (min>=max) return null; - boolean rangeIncludesZero = (min<0.0 && max>0.0); - double labelInterval; - double labelIntervalUnit; - int labelIntervalMultiplier; - if (rangeIncludesZero) { - double maxAbsValue = Math.max(Math.abs(min), Math.abs(max)); - double m=Math.floor(Math.log10(maxAbsValue)); - labelIntervalUnit = Math.pow(10., m); - labelInterval = getRoundNumber(maxAbsValue); - labelIntervalMultiplier = (int) Math.round(labelInterval / labelIntervalUnit); - if (labelIntervalMultiplier==2 && 2*labelInterval<maxAbsValue) { - labelIntervalMultiplier = 4; - labelInterval = labelIntervalMultiplier * labelIntervalUnit; - } - } else { - double range = Math.abs(max-min); - labelInterval = getRoundNumber(range); - int minMultiplier = (int) Math.ceil(min/labelInterval); - int maxMultiplier = (int) Math.floor(max/labelInterval); - while (maxMultiplier==minMultiplier) { - labelInterval = getRoundNumber(labelInterval*0.99); - minMultiplier = (int) Math.ceil(min/labelInterval); - maxMultiplier = (int) Math.floor(max/labelInterval); - } - double m=Math.floor(Math.log10(labelInterval)); - labelIntervalUnit = Math.pow(10., m); - minMultiplier = (int) Math.ceil(min/labelInterval); - maxMultiplier = (int) Math.floor(max/labelInterval); - labelIntervalMultiplier = (int) (labelInterval/labelIntervalUnit); - } - - double primaryInterval, secondaryInterval; - switch (labelIntervalMultiplier) { - case 1: - primaryInterval = labelIntervalUnit * 0.5; - secondaryInterval = labelIntervalUnit * 0.1; - break; - case 2: - primaryInterval = labelIntervalUnit * 1.0; - secondaryInterval = labelIntervalUnit * 0.2; - break; - case 3: - primaryInterval = labelIntervalUnit * 0.2; - secondaryInterval = labelIntervalUnit * 0.1; - break; - case 4: - primaryInterval = labelIntervalUnit * 2.0; - secondaryInterval = labelIntervalUnit * 0.5; - break; - case 5: - primaryInterval = labelIntervalUnit * 1.0; - secondaryInterval = labelIntervalUnit * 0.5; - break; - default: // Should not happen - primaryInterval = labelIntervalUnit * 0.5; - secondaryInterval = labelIntervalUnit * 0.1; - } - return new double[] {labelInterval, primaryInterval, secondaryInterval}; - } - - /** - * Get array of multiples of the given interval that lie in the given range. - * @param minValue minimum value on scale - * @param maxValue maximum value on scale - * @param labelInterval interval between values - * @return array of calculate values - */ - static double[] getScaleValues(double minValue, double maxValue, - double interval) { - int min = (int) Math.ceil(minValue/interval); - int max = (int) Math.floor(maxValue/interval); - int numValues = 1 + max - min; - double[] values = new double[numValues]; - for (int i=0; i<numValues; ++i) { - values[i] = (min + i) * interval; - } - return values; - } - - /** - * Rounds number towards zero to nearest "round number", i.e. a power of ten - * multiplied by 1, 2 or 5. - * - * @param d number to round - * @return next round number towards zero from input - */ - static double getRoundNumber(double d) { - double magnitude = Math.abs(d); - double m=Math.floor(Math.log10(magnitude)); - double unit = Math.pow(10., m); - double multIn = magnitude / unit; - double multOut; - if (multIn >= 5.0) multOut = 5.0; - else if (multIn >= 2.0) multOut = 2.0; - else multOut = 1.0; - double magRound = unit * multOut; - double round; - if (d<0.0) round = -magRound; - else round = magRound; - return round; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/canvas/AScaleBorder.java b/graphics/AtlantisJava/src/atlantis/canvas/AScaleBorder.java deleted file mode 100755 index 8610ee38bfa55cee552847b4b0a56a3d7c213547..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/AScaleBorder.java +++ /dev/null @@ -1,1282 +0,0 @@ -package atlantis.canvas; - -import atlantis.graphics.AAbstractGraphics2D; -import atlantis.graphics.ACursorFactory; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Component; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Insets; -import java.awt.Rectangle; -import java.awt.Stroke; -import java.awt.Image; -import java.awt.geom.AffineTransform; -import java.awt.geom.NoninvertibleTransformException; -import java.awt.geom.Point2D; - -import javax.swing.border.Border; - -import atlantis.gui.APreferencesControl; -import atlantis.parameters.AEnumeratorParameter; -import atlantis.parameters.ALinkParameter; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection; -import atlantis.projection.AProjectionLegoPlot; -import atlantis.projection.AProjectionEventInfo; -import atlantis.projection.AProjectionNGE; -import atlantis.projection.AProjectionTrackResidual; -import atlantis.utils.AMath; -import java.awt.RenderingHints; - -/** - * This class implements a Border in which the left and bottom sides contain - * numerical scales. - * - * @author Charles Loomis, Sebastian Boeser - */ -public class AScaleBorder implements Border -{ - // Constants giving horizontal and vertical index of the data arrays. - final static private int HORIZONTAL = 0; - final static private int VERTICAL = 1; - - /** - * Constant describing a transform in which the transformed x and y axes are - * parallel (or antiparallel) to the original axes. - */ - final static public int TYPE_PARALLEL_TRANSFORM = 0; - - /** - * Constant describing a transform in which the transformed x and y axes are - * parallel (or antiparallel) to the original y and x axes, respectively. - */ - final static public int TYPE_SWITCHED_TRANSFORM = 1; - - /** - * Constant describing a transform in which the transformed x-axis is - * parallel (or antiparallel) to the original x-axis and the transformed - * y-axis forms a non-zero angle with the original one. - */ - final static public int TYPE_X_SKEW_TRANSFORM = 2; - - /** - * Constant describing a transform in which the transformed y-axis is - * parallel (or antiparallel) to the original y-axis and the transformed - * x-axis forms a non-zero angle with the original one. - */ - final static public int TYPE_Y_SKEW_TRANSFORM = 3; - - /** - * Constant describing a transform in which the transformed x-axis is - * parallel (or antiparallel) to the original y-axis and the transformed - * y-axis forms a non-zero angle with the original x-axis. - */ - final static public int TYPE_SWITCHED_X_SKEW_TRANSFORM = 4; - - /** - * Constant describing a transform in which the transformed y-axis is - * parallel (or antiparallel) to the original x-axis and the transformed - * x-axis forms a non-zero angle with the original y-axis. - */ - final static public int TYPE_SWITCHED_Y_SKEW_TRANSFORM = 5; - - /** - * Constant describing a transform which does not fall into one of the other - * categories. - */ - final static public int TYPE_GENERAL_TRANSFORM = 6; - - /** - * Constant indicating that a string should be aligned vertically with the - * baseline of the text. This is the default in drawString calls which do - * not specify an alignment. - */ - public static final int TEXT_BASELINE = 0; - - /** - * Constant indicating that a string should be aligned vertically with the - * top of the text. - */ - public static final int TEXT_TOP = 1; - - /** - * Constant indicating that a string should be aligned vertically with the - * bottom of the text. - */ - public static final int TEXT_BOTTOM = 3; - - /** - * Constant indicating that a string should be aligned by the center. This - * is used for both horizontal and vertical alignment. - */ - public static final int TEXT_CENTER = 2; - - /** - * Constant indicating that a string should be aligned horizontally with the - * left side of the text. This is the default for drawString calls which do - * not specify an alignment. - */ - public static final int TEXT_LEFT = 1; - - /** - * Constant indicating that the string should be aligned horizontally with - * the right side of the text. - */ - public static final int TEXT_RIGHT = 3; - - private AScale horizontalScale; // holds tick marks and labels - private AScale verticalScale; - - /** - * String giving the axis labels. - */ - private String[] axisLabels = new String[2]; - - /** - * String giving the axis units. - */ - private String[] axisUnits = new String[2]; - - /** - * The initial font size for labeling. - */ - private int fontSize = 12; - - /** - * The initial font to use. - */ - private Font labelFont = new Font("SansSerif", Font.BOLD, 12); - - /** - * The width of the line used for the secondary tick marks. - */ - final static private Stroke thinStroke = new BasicStroke(1.f); - - /** - * The width of the line used for the primary tick marks. - */ - final static private Stroke thickStroke = new BasicStroke(2.f); - - /** - * An array to hold temporary point values for transformation. - */ - private double[] axisPts = new double[6]; - - /** - * Flag to indicate that the scale has changed and that it needs to be - * redrawn. - */ - private boolean scaleChanged; - - - /** - * The current width of the horizontal scale. - */ - private int currentWidth; - - /** - * The current width of the vertical scale. - */ - private int currentHeight; - - /** - * Minimum value on the horizontal axis. - */ - private double minHoriz; - - /** - * Maximum value of the horizontal axis. - */ - private double maxHoriz; - - /** - * Minimum value of the vertical axis. - */ - private double minVert; - - /** - * Maximum value on the vertical axis. - */ - private double maxVert; - - /** - * The calculated Insets for this border. - */ - private Insets insets; - - private boolean selected; - - /** - * Wether to draw the scales for this window or not - */ - private boolean drawScaleBorder; - - /** - * Wether to draw the scales for this window or not - * independant of the projection being displayed - */ - private boolean drawScaleBorder_preference; - - - /** - * The window this scale is drawn in. - */ - private final AWindow aWindow; - - /** - * Constructs a AScaleBorder - * @param theWindow the window this scale belongs to - */ - public AScaleBorder(AWindow theWindow) - { - aWindow = theWindow; - - // Give default values for the size of the axes. - minHoriz = 0.; - maxHoriz = 0.; - minVert = 0.; - maxVert = 0.; - - // Make the new insets. - resetInsets(); - - // Set the current width and height. - currentWidth = 0; - currentHeight = 0; - scaleChanged = false; - - selected = false; - drawScaleBorder = true; - drawScaleBorder_preference = true; - } - - public void forceDraw() - { - scaleChanged = true; - } - - public void toggleScale() - { - drawScaleBorder_preference = !drawScaleBorder_preference; - //only actually toggle scale if on a window with scale - AProjection p = aWindow.getProjection(); - - if(p instanceof AProjectionLegoPlot || p instanceof AProjectionNGE || p instanceof AProjectionEventInfo) - return; - - drawScaleBorder = !drawScaleBorder; - scaleChanged = true; - resetInsets(); - } - - public void hideScale() - { - //upon window change of projection check if scales need to hide or not - AProjection p = aWindow.getProjection(); - - // Check global 'Hide Scales' option (in preferences menu) - // If hiding scales, set all scales to false - // - if(APreferencesControl.getHideScalesMenuItem()) - { - drawScaleBorder=false; - resetInsets(); - } - else - if(p instanceof AProjectionLegoPlot || p instanceof AProjectionNGE || p instanceof AProjectionEventInfo){ - if(drawScaleBorder){ - drawScaleBorder=false; - resetInsets(); - } - }else if(drawScaleBorder!=drawScaleBorder_preference){ - drawScaleBorder=drawScaleBorder_preference; - resetInsets(); - } - } - - public boolean getScaleStatus() - { - return drawScaleBorder_preference; - } - - /** - * Set the font for the labels. - */ - public void setLabelFont(Font labelFont) - { - this.labelFont = labelFont; - fontSize = labelFont.getSize(); - resetInsets(); - } - - public void setSelected() - { - selected = true; - } - - public void setDeselected() - { - selected = false; - } - - /** - * Get the current font for the labels. - */ - public Font getLabelFont() - { - return labelFont; - } - - /** - * Set the horizontal and vertical limits for the scales. - */ - public void setLimits(double minHoriz, double maxHoriz, double minVert, double maxVert) - { - this.minHoriz = minHoriz; - this.maxHoriz = maxHoriz; - this.minVert = minVert; - this.maxVert = maxVert; - scaleChanged = true; - } - - /** - * Set the axis labels. - */ - public void setAxisLabels(String horizontalLabel, String verticalLabel) - { - axisLabels[HORIZONTAL] = horizontalLabel; - axisLabels[VERTICAL] = verticalLabel; - } - - public String getHorizontalAxisLabel() - { - return axisLabels[HORIZONTAL]; - } - - public String getVerticalAxisLabel() - { - return axisLabels[VERTICAL]; - } - - /** - * Set the axis units. - */ - public void setAxisUnits(String horizontalUnits, String verticalUnits) - { - if (horizontalUnits != null) - { - axisUnits[HORIZONTAL] = horizontalUnits; - } - else - { - axisUnits[HORIZONTAL] = ""; - } - - if (verticalUnits != null) - { - axisUnits[VERTICAL] = verticalUnits; - } - else - { - axisUnits[VERTICAL] = ""; - } - } - - /** - * Returns the insets of this border. - */ - @Override - public Insets getBorderInsets(Component c) - { - return (Insets) insets.clone(); - } - - /** - * Returns whether or not the border is opaque. This always returns true. - */ - @Override - public boolean isBorderOpaque() {return true;} - - /** - * Paints the border and window decorations for the specified component with the specified graphics - * context, position, and size. - */ - @Override - public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) - { - //Get the graphics context - Graphics2D vg = (Graphics2D) g; - //Sanity check - if (vg==null) return; - - //Select background and frame colors - Color bg = AWindow.BORDER_BACKGROUND_COLOR ; - - //Paint the border frame - paintBorderFrame(vg,bg,width,height); - - //If drawing the border draw scales - if (drawScaleBorder) - { - //Now check which projection we have - AProjection p = aWindow.getProjection(); - - // Set the flag indicating that the scales must be remade. - scaleChanged = (scaleChanged || width != currentWidth || height != currentHeight); - - //set the Scales - setScales(p.getXLabel(), p.getYLabel(), p.getXUnits(), p.getYUnits(), makeTransform(aWindow.getUserCorners()), aWindow.getWidth(), aWindow.getHeight()); - - //Paint the grid if there is one for this projection - paintGrid(vg,p,width,height); - - //Paint the scales themselves - paintScales(vg,p,width,height); - - // Reset the current width and height. - currentWidth = width; - currentHeight = height; - scaleChanged = false; - } - - //Check whether Window Title needs to be drawn - if(APreferencesControl.getWindowTitleMenuItem()) { - paintWindowTitle(g, width, height,true); - } - - //Check whether FishEye Indicator needs to be drawn - if(APreferencesControl.getFisheyeIndicatorMenuItem()) { - paintFishEyeIndicator(g, false, width, height); - } - } - - /** - * Paints the part of the border that appears when the window is printed - */ - void printBorder(Component c, Graphics g, int x, int y, int width, int height) - { - paintBorder(c,g,x,y,width,height); - } - - - /** - * Draw the part of the scales that shows up in printing - */ - private void paintScales(Graphics2D g, AProjection p, int width, int height){ - APar parameterStore = APar.instance(); - - // Make our own graphics contex, so we don't cause trouble elsewhere - Graphics2D svg = (Graphics2D) g.create(); - - Color foregroundColour = selected ? AWindow.BORDER_SELECTED_FOREGROUND_COLOR : AWindow.BORDER_FOREGROUND_COLOR; - - // Get the horizontal scale. - if (scaleChanged) - { - int scaleLength = width - (insets.left + insets.right); - horizontalScale = AScale.calculateScale(minHoriz, maxHoriz, scaleLength, 3, 7, AScale.RIGHT_TICKS, - HORIZONTAL, p); - } - - svg.translate(insets.left, height - insets.bottom + 2); - - svg.setColor(foregroundColour); - svg.setFont(new Font("SansSerif", Font.BOLD, 12)); - - // Draw the primary and secondary tick marks. - svg.setStroke(thickStroke); - svg.draw(horizontalScale.primaryTicks); - svg.setStroke(thinStroke); - svg.draw(horizontalScale.secondaryTicks); - - ScaleUnits hScaleUnits = new ScaleUnits(axisUnits[HORIZONTAL],minHoriz,maxHoriz); - double factorH = hScaleUnits.scaleFactor; - String unitsH = hScaleUnits.units; - - ScaleUnits vScaleUnits = new ScaleUnits(axisUnits[VERTICAL],minVert,maxVert); - double factorV = vScaleUnits.scaleFactor; - String unitsV = vScaleUnits.units; - - // Paint the tick labels. - int numLabelsH = horizontalScale.labelValues.length; - for (int i = 0; i < numLabelsH; i++) - { - double valueScaled = horizontalScale.labelValues[i] * factorH; - int nDecPlaces = getNumDecimalPlaces(valueScaled); - String label = String.format("%."+nDecPlaces+"f", valueScaled); - drawString(svg, label, - (float) horizontalScale.labelPositions[i], AScale.getPrimaryTickSize() + 0.2f * fontSize, TEXT_CENTER, TEXT_TOP, width - insets.left - insets.right); - } - - // Paint the axis label. - float axisPositionX = (float) horizontalScale.getTitlePosition(); - drawString(svg, axisLabels[HORIZONTAL] + " " + unitsH, axisPositionX, AScale.getPrimaryTickSize() + 0.2f * fontSize, TEXT_CENTER, TEXT_TOP, width - insets.left - insets.right); - - // End this context. - svg.dispose(); - - // Now create a new graphics context for the vertical axis. - svg = (Graphics2D) (g.create()); - - // Create the vertical scale. - if (scaleChanged) - { - int scaleLength = height - (insets.top + insets.bottom); - verticalScale = AScale.calculateScale(minVert, maxVert, scaleLength, 3, 7, AScale.LEFT_TICKS, - VERTICAL, p); - } - - svg.translate(insets.left - 2, height - insets.bottom); - svg.rotate(-Math.PI / 2.); - - svg.setColor(foregroundColour); - svg.setFont(new Font("SansSerif", Font.BOLD, 12)); - - // Draw the primary and secondary tick marks. - svg.setStroke(thickStroke); - svg.draw(verticalScale.primaryTicks); - svg.setStroke(thinStroke); - svg.draw(verticalScale.secondaryTicks); - - // Paint the tick labels. - int numLabelsV = verticalScale.labelValues.length; - for (int i = 0; i < numLabelsV; i++) - { - double valueScaled = verticalScale.labelValues[i] * factorV; - int nDecPlaces = getNumDecimalPlaces(valueScaled); - String label = String.format("%."+nDecPlaces+"f", valueScaled); - if(p instanceof AProjectionTrackResidual && parameterStore.get("TrackResidual", "Scale").getI() == 1) - { - if(!label.equals("0")) - { - long tmp = Math.round(((AProjectionTrackResidual)p).getResidual().getLogMagnitudeMin() + Math.abs(Double.parseDouble(label))); - if(label.indexOf("-") == -1) //positive - label = "1E" + tmp; - else - label = "-1E" + tmp; - } - } - drawString(svg, label, (float) verticalScale.labelPositions[i], -(AScale.getPrimaryTickSize() + 0.2f * fontSize), TEXT_CENTER, TEXT_BOTTOM, height - insets.top - insets.bottom); - } - - // Paint the axis label. - float axisPositionY = (float) verticalScale.getTitlePosition(); - drawString(svg, axisLabels[VERTICAL] + " " + unitsV, axisPositionY, -(AScale.getPrimaryTickSize() + 0.2f * fontSize), TEXT_CENTER, TEXT_BOTTOM, height - insets.top - insets.bottom); - - // End this context. - svg.dispose(); - - } - - /** - * Calculate number of decimal places needed in formatting number. - * @param x number to format - * @return number of decimal places needed - */ - static int getNumDecimalPlaces(double x) { - int m = - (int) Math.floor(Math.log10(Math.abs(x))); - return Math.max(0, m); - } - - /** - * Draw the grid for the V-Plot - **/ - private void paintGrid(Graphics2D g, AProjection p, int width, int height){ - - // Make our own graphics contex, so we don't cause trouble elsewhere - Graphics2D svg = (Graphics2D) g.create(); - - // next part draws the grid for the V-plot - if (p.getName().equals("VP")) - { - //Set color for grid lines - svg.setColor(Color.LIGHT_GRAY); - - // eta grid projections values - these particular values - // will be useful for calo people to see the eta grid lines at - float[] etaGridPositions = { -4.9f, -3.2f, -2.5f, -1.375f, -0.8f, - 0.8f, 1.375f, 2.5f, 3.2f, 4.9f }; - - for(int i = 0; i < etaGridPositions.length; i++) - { - if (etaGridPositions[i] > minHoriz && etaGridPositions[i] < maxHoriz) { - Point2D.Double startp = aWindow.calculateDisplay(etaGridPositions[i],minVert); - Point2D.Double endp = aWindow.calculateDisplay(etaGridPositions[i],maxVert); - svg.drawLine((int)startp.x,(int)startp.y,(int)endp.x,(int)endp.y); - } - } - - for (int i = (int)Math.ceil(minVert/90.)*90; i <= maxVert; i += 90) - { - Point2D.Double startp = aWindow.calculateDisplay(minHoriz,i); - Point2D.Double endp = aWindow.calculateDisplay(maxHoriz,i); - if (Math.abs(i) % 360 == 0) { - svg.setColor(Color.WHITE); - svg.setStroke(thickStroke); - } else { - svg.setColor(Color.LIGHT_GRAY); - svg.setStroke(thinStroke); - } - svg.drawLine((int)startp.x,(int)startp.y,(int)endp.x,(int)endp.y); - } - } - - svg.dispose(); - - } - - /** - * This bit of the frame that is drawn when printing (appart from scales) - */ - private void printBorderFrame(Graphics2D g, Color bg, int width, int height){ - - // Make our own graphics contex, so we don't cause trouble elsewhere - Graphics2D svg = (Graphics2D) g.create(); - - svg.setColor(bg); - //simply draw rectangles all around window - svg.fillRect(0, 0, width, insets.top); - // Added -insets.bottom because sometimes this stuff is transparent -Adam - svg.fillRect(0, 0, insets.left, height - insets.bottom); - svg.fillRect(width - insets.right, 0, insets.right, height); - svg.fillRect(0, height - insets.bottom, width, insets.bottom); - - svg.dispose(); - } - - /** - * Paint the Frame of the border with the given colors - */ - private void paintBorderFrame(Graphics2D g, Color bg, int width, int height){ - //Draw the frame same as for printing - printBorderFrame(g,bg,width,height); - - // Make our own graphics contex, so we don't cause trouble elsewhere - Graphics2D svg = (Graphics2D) g.create(); - - // Add a bit of GUI-look-and-feel frame - if (selected){ - //white triangle bottom left corner - clears any background colour - svg.setColor(AWindow.BORDER_SELECTED_FRAMELIGHT_COLOR); - int xp[]={0,0,11,0}; - int yp[]={height-12,height,height,height-12}; - svg.fillPolygon(xp,yp,4); - //blue border around window - svg.setColor(AWindow.BORDER_SELECTED_FRAME_COLOR); - svg.drawLine(0, 0, width-1, 0); - svg.drawLine(0, 0, 0, height-10); - svg.drawLine(width-1, 0, width-1, height-1); - svg.drawLine(10, height-1, width-1, height-1); - svg.drawLine(0, height-10, 9, height-1); - //white inner border - svg.setColor(AWindow.BORDER_SELECTED_FRAMELIGHT_COLOR); - svg.drawLine(10, height-2, width-2, height-2); - svg.drawLine(1, 1, 1, height-10); - //grey triangle bottom left corner - svg.setColor(AWindow.BORDER_BACKGROUND_COLOR); - xp[2]=8; - yp[0]=height-9; - yp[3]=height-9; - svg.fillPolygon(xp,yp,4); - } - - svg.dispose(); - } - - /** - * Paint a small box at the top of each window to describe what is on the window - */ - private void paintWindowTitle(Graphics g, int width, int height, boolean highlight) - { - APar parameterStore = APar.instance(); - - // Make our own graphics contex, so we don't cause trouble elsewhere - Graphics2D svg = (Graphics2D) g.create(); - //Get Mode parameter - String s=aWindow.getProjection().getName(); - parameterStore.selectWindowParameters(aWindow.getName()); - AParameter param=parameterStore.get(s, "Mode"); - int mode=param.getI(); - s=aWindow.getProjection().getScreenName(); - s+=" Projection"; - //Add mode text if not on standard view - if (param != null) - { - if(mode != 0) - { - s+=" viewing: "; - if(param instanceof ALinkParameter){ - s+=((ALinkParameter) param).getCurrentText(); - }else{ - s+=((AEnumeratorParameter) param).getCurrentText(); - } - } - } - parameterStore.restoreWindowParameters(); - //Offset if indicator to window frame - int Offset=2; - - int boxsize,y; - // get the width of the text - boxsize = svg.getFontMetrics().stringWidth(s)+Offset*2; - //Get y position from offset - y = Offset+svg.getFontMetrics().getHeight(); - - //Get the x position from width of window - int x = insets.left + (int) Math.round(((width-insets.left-boxsize)/2.0)); - //Draw background box and set text color - //highlighting the active window if desired - if(selected&&highlight) - { - //If selected and not printing eps - //add a bit of GUI-look-and-feel frame - svg.setColor(AWindow.BORDER_SELECTED_BACKGROUND_COLOR); - svg.fillRect(x-2, 1, boxsize+4, y+1); - svg.setColor(AWindow.BORDER_SELECTED_FRAME_COLOR); - svg.fillRect(x-1, 0, boxsize+2, y+1); - svg.setColor(AWindow.BORDER_SELECTED_FRAMELIGHT_COLOR); - svg.fillRect(x, 1, boxsize, y-1); - svg.setColor(AWindow.BORDER_SELECTED_BACKGROUND_COLOR); - svg.fillRect(x+1, 1, boxsize-1, y-2); - svg.setColor(AWindow.BORDER_SELECTED_FOREGROUND_COLOR); - } - else - { - //If not selected draw background box - svg.setColor(AWindow.BORDER_BACKGROUND_COLOR); - svg.fillRect(x-2, 0, boxsize+4, y+2); - svg.setColor(AWindow.BORDER_FOREGROUND_COLOR); - } - //Draw text - svg.drawString(s, x+Offset, y-3); - //cleanup - svg.dispose(); - } - - /** - * Paint a small FishEye Indicator if FishEye projection is active. - * At the moment, the indicator is drawn in the top right corner of the canvas. - * One might as well put it in on the scale. Eventually, if the scales shows - * proper fisheyed coordinates, it might not be needed anymore at all. - */ - private void paintFishEyeIndicator(Graphics g, boolean forceText, int width, int height){ - APar parameterStore = APar.instance(); - - //Probe for fishEye status - boolean fishEyeStatus=false; - - //Check if FishEye is on for this particular window - parameterStore.selectWindowParameters(aWindow.getName()); - - //Get FishEye parameter - AParameter fishEyePar = parameterStore.get(aWindow.getProjection().getName(), "FishEye"); - - //Check if there is a fish-eye parameter for this projection, and get status (enabled or not) - if (fishEyePar != null) fishEyeStatus=fishEyePar.getStatus(); - - //Restore to active window - parameterStore.restoreWindowParameters(); - - // Now draw indicator if fisheye was on - if (fishEyeStatus){ - - // Make our own graphics contex, so we don't cause trouble elsewhere - Graphics2D svg = (Graphics2D) g.create(); - //Offset if indicator to window frame - int Offset=4; - //Check if we have custom cursors - only then use indicator image - if (!forceText ){ - //FishEye indicator image is provided by ACursorFactory as it is the same - //as the cursor used in FishEye transformation. - Image IndicatorImg = ACursorFactory.getInstance().getFishEyeIndicator(); - //Get the x position from width of window and width of image - int x = width-Offset-IndicatorImg.getWidth(null); - //Get y position from offset - int y = Offset; - //Draw an fisheye indicator in top right corner with some space - svg.drawImage(IndicatorImg,x,y,null); - } else { - int x,y; - //Get the x position from width of window and width of image - x = width-Offset-svg.getFontMetrics().stringWidth("FishEye"); - //Get y position from offset - y = Offset+svg.getFontMetrics().getHeight(); - //Set color to red - svg.setColor(Color.red); - //Use small label to indicate fisheye - svg.drawString("FishEye",x,y); - - } - //cleanup - svg.dispose(); - } - } - - /** - * Recalculate the insets based on the current font size. - */ - private void resetInsets() - { - int lb = (int) (2 + 2 + AScale.getPrimaryTickSize() + 1.5 * fontSize); - // int tr = (int) (2+2+AScale.getPrimaryTickSize()); - int tr = 2; - - if (drawScaleBorder) - insets = new Insets(tr, lb, lb, tr); - else - insets = new Insets(tr, tr, tr, tr); - } - - /** - * Set the scale labels taking into account the given linear transformation. - */ - public void setScales(String horizLabel, String vertLabel, String horizUnits, String vertUnits, AffineTransform transform, int panelWidth, int panelHeight) - { - - // Determine the type of the tranform. - int type = classifyTransform(transform); - - switch (type) - { - case TYPE_PARALLEL_TRANSFORM: - setAxisLabels(horizLabel, vertLabel); - setAxisUnits(horizUnits, vertUnits); - break; - - case TYPE_SWITCHED_TRANSFORM: - setAxisLabels(vertLabel, horizLabel); - setAxisUnits(vertUnits, horizUnits); - break; - - case TYPE_Y_SKEW_TRANSFORM: - setAxisLabels(horizLabel + AMath.PRIME, AMath.DELTA + vertLabel); - if (horizUnits.equals(vertUnits)) - { - setAxisUnits(horizUnits, vertUnits); - } - else - { - setAxisUnits(horizUnits + AMath.DOT + vertUnits, vertUnits); - } - break; - - case TYPE_X_SKEW_TRANSFORM: - setAxisLabels(AMath.DELTA + horizLabel, vertLabel + AMath.PRIME); - if (vertUnits.equals(horizUnits)) - { - setAxisUnits(horizUnits, vertUnits); - } - else - { - setAxisUnits(horizUnits, vertUnits + AMath.DOT + horizUnits); - } - break; - - case TYPE_SWITCHED_Y_SKEW_TRANSFORM: - setAxisLabels(vertLabel + AMath.PRIME, AMath.DELTA + horizLabel); - if (vertUnits.equals(horizUnits)) - { - setAxisUnits(vertUnits, horizUnits); - } - else - { - setAxisUnits(vertUnits + AMath.DOT + horizUnits, horizUnits); - } - break; - - case TYPE_SWITCHED_X_SKEW_TRANSFORM: - setAxisLabels(AMath.DELTA + vertLabel, horizLabel + AMath.PRIME); - if (horizUnits.equals(vertUnits)) - { - setAxisUnits(vertUnits, horizUnits); - } - else - { - setAxisUnits(vertUnits, horizUnits + AMath.DOT + vertUnits); - } - break; - - default: - setAxisLabels(horizLabel + AMath.PRIME, vertLabel + AMath.PRIME); - if (horizUnits.equals(vertUnits)) - { - setAxisUnits(horizUnits, vertUnits); - } - else - { - setAxisUnits(horizUnits + AMath.DOT + vertUnits, vertUnits + AMath.DOT + horizUnits); - } - break; - } - - // Get the size of the scales. - axisPts[0] = 0.; - axisPts[1] = panelHeight; - axisPts[2] = 0.; - axisPts[3] = panelHeight; - axisPts[4] = panelWidth; - axisPts[5] = 0.; - try - { - // Avoid using the following call because of a bug in - // AffineTransform. Instead create the inverse matrix - // explicitly as done below. - // transform.inverseTransform(physicsPt,0,physicsPt,0,3); - AffineTransform ixform = transform.createInverse(); - - ixform.transform(axisPts, 0, axisPts, 0, 1); - ixform.deltaTransform(axisPts, 2, axisPts, 2, 2); - - // Calculate the values for the vertical axis and the distance. - double vdy = axisPts[3]; - double vdx = axisPts[2]; - double vdist = Math.sqrt(vdx * vdx + vdy * vdy); - - // Calculate the values for the horizontal axis and the distance. - double hdy = axisPts[5]; - double hdx = axisPts[4]; - double hdist = Math.sqrt(hdx * hdx + hdy * hdy); - - // Initialize the endpoints of the axes. - double vmin = 0.; - double vmax = 0.; - double hmin = 0.; - double hmax = 0.; - - // Do what is necessary for the different types of transformations. - switch (type) - { - case (TYPE_PARALLEL_TRANSFORM): - { - double vsign = (vdy < 0.) ? 1. : -1.; - - vmin = axisPts[1]; - vmax = axisPts[1] + vsign * vdist; - - double hsign = (hdx > 0.) ? 1. : -1.; - - hmin = axisPts[0]; - hmax = axisPts[0] + hsign * hdist; - break; - } - - case (TYPE_SWITCHED_TRANSFORM): - { - double hsign = (hdy > 0.) ? 1. : -1.; - - hmin = axisPts[1]; - hmax = axisPts[1] + hsign * hdist; - - double vsign = (vdx < 0.) ? 1. : -1.; - - vmin = axisPts[0]; - vmax = axisPts[0] + vsign * vdist; - break; - } - - case (TYPE_Y_SKEW_TRANSFORM): - { - double vsign = (vdy > 0.) ? 1. : -1.; - - vmax = -vsign * vdist / 2.; - vmin = -vmax; - - hmin = 0.; - hmax = hdist; - break; - } - - case (TYPE_X_SKEW_TRANSFORM): - { - double hsign = (hdx > 0.) ? 1. : -1.; - - hmax = hsign * hdist / 2.; - hmin = -hmax; - - vmin = 0.; - vmax = vdist; - break; - } - - case (TYPE_SWITCHED_Y_SKEW_TRANSFORM): - { - double vsign = (vdx > 0.) ? 1. : -1.; - - vmax = -vsign * vdist / 2.; - vmin = -vmax; - - hmin = 0.; - hmax = hdist; - break; - } - - case (TYPE_SWITCHED_X_SKEW_TRANSFORM): - { - double hsign = (hdy > 0.) ? 1. : -1.; - - hmax = hsign * hdist / 2.; - hmin = -hmax; - - vmin = 0.; - vmax = vdist; - break; - } - - default: - { - vmin = 0.; - vmax = 0.; - hmin = 0.; - hmax = 0.; - break; - } - } - - // Actually set the limits. - setLimits(hmin, hmax, vmin, vmax); - } - catch (NoninvertibleTransformException e) - { - setLimits(0., 0., 0., 0.); - } - } - - /** - * This is a protected utility method which classifies the given transform - * into seven categories: parallel, switched, x-skew, y-skew, switched - * x-skew, switched y-skew, and general. The parallel category describes - * transformations in which the transformed x and y axes are parallel or - * antiparallel to the original x and y axes, respectively. The switched - * category describes transformations in which the transformed x and y axes - * are parallel or antiparallel to the original y and x axes, respectively. - * That is, the x and y axes have been switched. The x-skew describes - * transformations in which the transformed x-axis is parallel (or - * antiparallel) to the original one while the transformed y-axis forms some - * non-zero angle to the original one. The y-skew is similar; the switch - * skews are just rotated (counter)clockwise by 90 degrees. The general - * category encompasses all transforms not falling into one of the other - * categories. - */ - static protected int classifyTransform(AffineTransform xform) - { - // Set the default return type to a general matrix. - int category = TYPE_GENERAL_TRANSFORM; - - // Get the four non-translation quantities from the transformation. - double sx = xform.getScaleX(); - double sy = xform.getScaleY(); - double kx = xform.getShearX(); - double ky = xform.getShearY(); - - // Check the type. - if (kx == 0. && ky == 0.) - { - category = TYPE_PARALLEL_TRANSFORM; - } - else if (sx == 0. && sy == 0.) - { - category = TYPE_SWITCHED_TRANSFORM; - } - else if (kx == 0.) - { - category = TYPE_Y_SKEW_TRANSFORM; - } - else if (ky == 0.) - { - category = TYPE_X_SKEW_TRANSFORM; - } - else if (sx == 0.) - { - category = TYPE_SWITCHED_Y_SKEW_TRANSFORM; - } - else if (sy == 0.) - { - category = TYPE_SWITCHED_X_SKEW_TRANSFORM; - } - - // Return the transformtion type. - return category; - } - - /** - * A utility which makes an AffineTransform given three corner - * points. The first point must be the upper, left-hand corner - * point, the second, the upper, right-hand corner point, and the - * third, the lower, right-hand corner point. - * - * @return AffineTransform which does the appropriate mapping */ - protected AffineTransform makeTransform(Point2D.Double[] corners) - { - double x0 = corners[0].x; - double y0 = corners[0].y; - double x1 = corners[1].x; - double y1 = corners[1].y; - double x2 = corners[2].x; - double y2 = corners[2].y; - - double sx = 0.; - double kx = 0.; - double tx = 0.; - double sy = 0.; - double ky = 0.; - double ty = 0.; - - double delta = (x2 * (y1 - y0) - x1 * (y2 - y0) + x0 * (y2 - y1)); - - if (delta == 0) - { - // cannot successfully create an AffineTransform - System.err.println("Fatal Error: AffineTransform creating failed."); - System.err.println("Possible cause: wrong user corner values are set."); - System.exit(1); - return null; - } - else - { - delta = 1. / delta; - - double w = aWindow.getWidth(); - double h = aWindow.getHeight(); - - sx = -(delta * w) * (y2 - y1); - kx = (delta * w) * (x2 - x1); - tx = -(x0 * sx + y0 * kx); - - ky = (delta * h) * (y1 - y0); - sy = -(delta * h) * (x1 - x0); - ty = -(x0 * ky + y0 * sy); - - return new AffineTransform(sx, ky, kx, sy, tx, ty); - } - - } - - public void drawString(Graphics2D g, String str, double x, double y, int horizontal, int vertical, int maxSize) - { - drawString(g, str, x, y, horizontal, vertical, false, null, 0, false, null, maxSize); - } - - private void drawString(Graphics2D g, String str, double x, double y, int horizontal, int vertical, boolean framed, Color frameColor, double frameWidth, boolean banner, Color bannerColor, int maxSize) - { - Font sf = g.getFont(); - int width = sf.getSize(); - int descent = 0; - int height = sf.getSize(); - int adjustment = 0; - - // The metrics stuff did not work, so I made a work around and now - // even ps-printing works (CT 27/7/2004) - double xx = Math.min(x, maxSize - width / 2); - Rectangle textSize = new Rectangle(0, descent - height, width, height); - Point2D textUL = drawFrameAndBanner(xx, y, textSize, adjustment, framed, frameColor, frameWidth, banner, bannerColor, horizontal, vertical); - - if (g instanceof AAbstractGraphics2D) { - // No antialiasing support needed for EPS output. - g.drawString(str, (int) textUL.getX(), (int) textUL.getY()); - } else { - // For pixel graphics, switch on antialiasing for text. - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g.drawString(str, (int) textUL.getX(), (int) textUL.getY()); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - } - - /** Draws frame and banner around a string. The method calculates and returns - * the point to which the text curser should be set before drawing the string. */ - private Point2D drawFrameAndBanner(double x, double y, Rectangle textSize, int adjustment, boolean framed, Color frameColor, double frameWidth, boolean banner, Color bannerColor, int horizontal, int vertical) - { - double descent = textSize.y + textSize.height; - x = getXalignment(x, textSize.width, horizontal); - y = getYalignment(y, textSize.height, (int) descent, vertical); - return new Point2D.Double(x, y); - } - - private static double getYalignment(double y, int ascent, int descent, int alignment) - { - // vertical alignment - switch (alignment) - { - case TEXT_TOP: - y = y + ascent - descent; - break; - - case TEXT_CENTER: - y = y + ((ascent + descent) / 2) - descent; - break; - - case TEXT_BOTTOM: - y = y - descent; - break; - - case TEXT_BASELINE: - default: - break; - } - return y; - } - - private static double getXalignment(double x, int width, int alignment) - { - // horizontal alignment - switch (alignment) - { - case TEXT_CENTER: - x = x - (width / 2); - break; - - case TEXT_RIGHT: - x = x - width; - break; - - case TEXT_LEFT: - default: - break; - } - return x; - } - - /** - * Encapsulates units and range for an axis. - * Used for m->cm->mm->um autoscaling. - */ - private static class ScaleUnits { - final String units; - final double scaleFactor; - - ScaleUnits(String units, double min, double max) { - double maxMod = Math.max(Math.abs(max), Math.abs(min)); - if (!units.equals("(cm)")) { - this.units = units; - this.scaleFactor = 1.0; - return; - } - else { - if (maxMod > 200.) - { - this.scaleFactor= 0.01; - this.units = "(m) "; - } - else if (maxMod > 2.) - { - this.scaleFactor = 1.0; - this.units = "(cm)"; - } - else if (maxMod > .2) - { - this.scaleFactor = 10.; - this.units = "(mm)"; - } - else - { - this.scaleFactor = 10000.; - this.units = "(" + AMath.MICRO + "m)"; - } - } - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/canvas/ATitleMenuBar.java b/graphics/AtlantisJava/src/atlantis/canvas/ATitleMenuBar.java deleted file mode 100755 index 85ad9daab256de493a9ca669c9f36ce0b9402d6b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/ATitleMenuBar.java +++ /dev/null @@ -1,92 +0,0 @@ -package atlantis.canvas; - -import javax.swing.JLabel; -import javax.swing.JMenuBar; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; - -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.graphics.AGraphics; -import atlantis.parameters.APar; - - -public class ATitleMenuBar extends JMenuBar -{ - - public ATitleMenuBar() - { - // just to set the height of the title bar - - JLabel atlas = new JLabel(" Atlantis "); - atlas.setFont(new Font("Courier", Font.PLAIN, 25)); - add(atlas); - } - - @Override - public void paint(Graphics g) - { - AEventManager eventManager = AEventManager.instance(); - AEvent event = eventManager.getCurrentEvent(); - Font titleFont=new Font("Dialog", Font.BOLD, 15); - int availableSpace = (int) Math.floor(getWidth()-10); - FontMetrics fm = ACanvas.getCanvas().getFontMetrics(titleFont); - - AGraphics ag=AGraphics.makeAGraphics(g); - ag.setColor(AWindow.BORDER_BACKGROUND_COLOR); - ag.fillRect(0, 0, getWidth(), getHeight()); - ag.setColor(AWindow.BORDER_FOREGROUND_COLOR); - ag.updateColor(); - ag.setFont(titleFont); - availableSpace -= fm.stringWidth("ATLAS Atlantis"); - ag.drawString("ATLAS ", 5, getHeight()-10); - ag.drawString(" Atlantis", getWidth()-fm.stringWidth(" Atlantis")-5, getHeight()-10); - - String[] titleSections = new String[6]; - if(event != null) - { - titleSections[0] = !event.getDateTime().equals("n/a") ? event.getDateTime() : ""; - titleSections[1] = " source:" + event.getSourceName(); - int extension_dot = titleSections[1].toLowerCase().lastIndexOf("."); - if(extension_dot > 0) - titleSections[1] = titleSections[1].substring(0,extension_dot); - titleSections[2] = " run:" + event.getRunNumber(); - titleSections[3] = " ev:" + event.getEventNumber(); - titleSections[4] = " lumiBlock:" + event.getLumiBlock(); - titleSections[5] = " eventProperties: " + event.getEventProperties(); - } - else - { - titleSections[0]=""; - titleSections[1]=" event:n/a"; - titleSections[2]=" run:n/a"; - titleSections[3]=" ev:n/a"; - titleSections[4]=""; - titleSections[5]=""; - } - - - //for masterclass turn off some of the canvas title parts - APar parameterStore = APar.instance(); - if(parameterStore.get("Minerva","hiderun").getStatus()) - titleSections[2]=""; - if(parameterStore.get("Minerva","hideev").getStatus()) - titleSections[3]=""; - - - StringBuilder outputString = new StringBuilder(); - int titleSectionSize=0; - for(int i=0; i<6; i++) - { - if(titleSectionSize+fm.stringWidth(titleSections[i])<availableSpace) - { - if(!titleSections[i].endsWith("default")){ - titleSectionSize+=fm.stringWidth(titleSections[i]); - outputString.append(titleSections[i]); - } - } - } - ag.drawString(outputString.toString(), (getWidth()-titleSectionSize)/2, getHeight()-10); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/canvas/AWindow.java b/graphics/AtlantisJava/src/atlantis/canvas/AWindow.java deleted file mode 100755 index 159623e227c79fbe81e025864ac519a3d2c160c8..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/AWindow.java +++ /dev/null @@ -1,1549 +0,0 @@ -package atlantis.canvas; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.GraphicsEnvironment; -import java.awt.Insets; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DragGestureEvent; -import java.awt.dnd.DragGestureListener; -import java.awt.dnd.DragSource; -import java.awt.dnd.DragSourceDragEvent; -import java.awt.dnd.DragSourceDropEvent; -import java.awt.dnd.DragSourceEvent; -import java.awt.dnd.DragSourceListener; -import java.awt.dnd.DropTarget; -import java.awt.dnd.DropTargetDragEvent; -import java.awt.dnd.DropTargetDropEvent; -import java.awt.dnd.DropTargetEvent; -import java.awt.dnd.DropTargetListener; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.geom.Point2D; -import java.awt.geom.Point2D.Double; -import java.awt.image.BufferedImage; -import java.awt.image.DataBuffer; - -import java.util.Hashtable; -import java.util.LinkedList; -import java.util.Stack; -import java.util.Vector; - -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JSeparator; -import javax.swing.JToolTip; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; - -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.graphics.dnd.ACallBack; -import atlantis.graphics.dnd.ADnDLabel; -import atlantis.graphics.dnd.AObjectTransferable; -import atlantis.gui.AColorHelpDialog; -import atlantis.gui.AInteractionToolBar; -import atlantis.gui.APreferencesControl; -import atlantis.interactions.AInteraction; -import atlantis.interactions.AInteractionsManager; -import atlantis.interactions.ASelection; -import atlantis.interactions.ARectangleVPSelection; -import atlantis.interactions.ARectangleYXSelection; -import atlantis.interactions.AZMRInteraction; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.APar; -import atlantis.projection.AProjection; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionNPhysics; -import atlantis.projection.AProjectionTrackResidual; -import atlantis.projection.AProjectionsManager; -import atlantis.utils.AMath; - -import atlantis.utils.ALogger; -import java.awt.BorderLayout; -import javax.swing.JComponent; - -/** - * The objects of this class are single windows managed by ACanvas - * This class manages the painting of each picture and is always - * called by the java awt event thread. Programatic requests for - * picture updates are handled by calls to repaintFromScratch() which - * adds requests to the awt event thread. - * It paints first into an off-screen buffer which is then copied - * onto the screen. - * It handles the linear transformation from user to display - * coordinates and vice-versa. Non-linear transformations are handled by - * by the projections. Windows have a scale (and scale border) which - * may be visible or not. Each window has an associated projection - * and an interactionManager which knows about the current interaction - * and the state of all other interactions for this window. - * - * @author taylorg - */ -public class AWindow extends JPanel implements DropTargetListener, - DragSourceListener, DragGestureListener, ACallBack -{ - - private static ALogger logger = ALogger.getLogger(AWindow.class); - private static AGlobals globals = AGlobals.instance(); - - //Whether horizontal or vertical scale is copied when window is dragged - private static enum dragActionType { COPY_VERTICAL_SCALE, COPY_HORIZONTAL_SCALE }; - - //these colors are used on the scale border and title bar - static final Color BORDER_FOREGROUND_COLOR = new Color(48,48,48); - static final Color BORDER_SELECTED_FOREGROUND_COLOR = new Color(48,48,48); - static final Color BORDER_SELECTED_FRAME_COLOR = new Color(99,130,191); - static final Color BORDER_SELECTED_FRAMELIGHT_COLOR = new Color(255,255,255); - // These ones must be public and cannot be final because AOpenGLControl messes with them. - public static Color BORDER_BACKGROUND_COLOR = new Color(224,224,224); - public static Color BORDER_SELECTED_BACKGROUND_COLOR = new Color(200,221,242); - private dragActionType dragAction; - private boolean canCopyScales = false; - private DragSource dragSource = null; - private Graphics2D backingGraphics = null; - private BufferedImage backingImage = null; - private Dimension backingDimension = new Dimension(); - - /** - * The border of the window holds a scale with units - **/ - private AScaleBorder scaleBorder; - - private boolean bufferValid = false; - private boolean borderValid = false; - private Insets insets = new Insets(0, 0, 0, 0); - private double m00, m01, m02, m10, m11, m12, n00, n01, n02, n10, n11, n12; - private AInteractionsManager interactionsManager; - private Hashtable<String, Double[]> corners; - private Point2D.Double[] userCorners; - private Point2D.Double[] defaultCorners; - private AProjection projection; - private String group; - private String defaultGroup; - private String defaultProjectionName; - private int index; - boolean finalized; - private Stack<Point2D.Double[]> cornersHistory = new Stack<Point2D.Double[]>(); - private AProjection projectionHistory = null; - private Stack<Integer> zoomSummed = new Stack<Integer>(); - private Stack<Integer> zoomLayers = new Stack<Integer>(); - private Stack<Integer> zoomCalo = new Stack<Integer>(); - private Stack<Integer> zoomCaloLAr = new Stack<Integer>(); - private Stack<Integer> modeHistory = new Stack<Integer>(); - private Stack<Integer> cutHistoryLAr = new Stack<Integer>(); - private Stack<Integer> cutHistoryHEC = new Stack<Integer>(); - private Stack<Integer> layoutHistory = new Stack<Integer>(); - private boolean locked; - private static JPopupMenu popupMenu; - private final static String LOCK = "Freeze"; - private final static String UNLOCK = "Unfreeze"; - private final static String HORIZONTAL_FLIP = "Horizontal Flip"; - private final static String VERTICAL_FLIP = "Vertical Flip"; - private final static String ROTATE_BY_90_CLOCKWISE = "Rotate by 90"; - private final static String ROTATE_BY_90_ANTICLOCKWISE = "Rotate by -90"; - private final static String TOGGLE_SCALE = "Toggle Scale"; - private final static String RESTORE_DEFAULTS = "Restore Initial Size"; - - private JComponent m_view = null; - - static - { - popupMenu = new JPopupMenu(); - ActionListener actionListener = new PopupMenuActionListener(); - popupMenu.add(HORIZONTAL_FLIP).addActionListener(actionListener); - popupMenu.add(VERTICAL_FLIP).addActionListener(actionListener); - popupMenu.add(new JSeparator()); - popupMenu.add(ROTATE_BY_90_CLOCKWISE).addActionListener(actionListener); - popupMenu.add(ROTATE_BY_90_ANTICLOCKWISE).addActionListener( - actionListener); - popupMenu.add(new JSeparator()); - popupMenu.add(TOGGLE_SCALE).addActionListener(actionListener); - popupMenu.add(RESTORE_DEFAULTS).addActionListener(actionListener); - popupMenu.add(LOCK).addActionListener(actionListener); - popupMenu.add(UNLOCK).addActionListener(actionListener); - } - - - private static class PopupMenuActionListener - implements ActionListener - { - public void actionPerformed(ActionEvent e) - { - String action = e.getActionCommand(); - AWindow window = ACanvas.getCanvas().getCurrentWindow(); - if(action.equals(LOCK)) - { - window.setLocked(true); - } - else if(action.equals(UNLOCK)) - { - window.setLocked(false); - } - else if(action.equals(TOGGLE_SCALE)) - { - window.toggleScale(); - } - // temporary fix to avoid crashes - if(window.getProjection() instanceof AProjection2D) - { - if(action.equals(RESTORE_DEFAULTS)) - { - window.unzoomFull(); - } - else if(action.equals(HORIZONTAL_FLIP)) - { - AZMRInteraction.performFlip(AZMRInteraction. - getMiddleVerticalLine(window), - window); - } - else if(action.equals(VERTICAL_FLIP)) - { - AZMRInteraction.performFlip(AZMRInteraction. - getMiddleHorizontalLine(window), - window); - } - else if(action.equals(ROTATE_BY_90_CLOCKWISE)) - { - AZMRInteraction.performPlus90Rotation(window); - } - else if(action.equals(ROTATE_BY_90_ANTICLOCKWISE)) - { - AZMRInteraction.performMinus90Rotation(window); - } - } - } - } - - /** - * Construct AWindow using information in XML configuration file. - * - * @param node the XML configuration node for this window - * @param index identifier for the window - * @return the constructed window - */ - static AWindow createFromXMLConfigNode(Node node, int index) { - NamedNodeMap attributes = node.getAttributes(); - String name = attributes.getNamedItem("name").getNodeValue(); - String defaultProjectionName = attributes.getNamedItem("projection"). - getNodeValue(); - String defaultGroup = attributes.getNamedItem("group").getNodeValue(); - return new AWindow(name,defaultProjectionName,defaultGroup,index); - } - - /** - * Construct AWindow with given name, default projection and group name. - * Only non-private in order to allow test code to create an AWindow instance. - * - * @param name title of window - * @param defaultProjection name of default projection - * @param defaultGroup name of group - * @param index identifier for window - */ - AWindow(String name, String defaultProjection, String defaultGroup, int index) - { - super(new BorderLayout()); - setName(name); - this.defaultProjectionName = defaultProjection; - this.defaultGroup = defaultGroup; - setOpaque(false); - if (!globals.getUseOpenGL()) { - m_view = new AWindowSwingView(this); - } else { - m_view = new AWindowGLView(this); - } - this.index = index; - scaleBorder = new AScaleBorder(this); - scaleBorder.setLabelFont(new Font("Dialog", Font.PLAIN, 12)); - m_view.setBorder(scaleBorder); - add(m_view, BorderLayout.CENTER); - finalized = false; - - if (!AGlobals.isAtlantisHeadless()) { - dragSource = new DragSource(); - dragSource.createDefaultDragGestureRecognizer(this, - DnDConstants.ACTION_MOVE, this); - - this.setDropTarget(new DropTarget(this, this)); - } - } - - /** - * Perform the steps that have to follow the ACanvas initialization. - * Despite its name, this method is called from ACanvas.setCurrentLayout() - * so may be called multiple times on the same window. - */ - void finalizeConstruction() - { - setInteractionManager(new AInteractionsManager(this)); - corners = new Hashtable<String, Double[]>(); - String[] pName = AProjectionsManager.getKnownProjectionNames(); - Point2D.Double[] pCorners; - ALayout l = ACanvas.getCanvas().getCurrentLayout(); - Dimension size = l.getWindowConstraints(getName()).getSize(); - for(int i = 0; i < pName.length; i++) - { - AProjection proj = AProjectionsManager.getProjection(pName[i]); - if(proj instanceof AProjection2D) - { - pCorners = ((AProjection2D) proj).calculateNoZoomCorners(size); - corners.put(pName[i], pCorners); - } - } - AProjection defaultProjection = AProjectionsManager.getProjection( - defaultProjectionName); - setGroup(defaultGroup); - setProjection(defaultProjection); - - if (!AGlobals.isAtlantisHeadless()) { - interactionsManager.setContext(getInteractionToolBar().getSelectedGroup()); - } - - finalized = true; - } - - - void restoreDefaults() - { - if(finalized) - { - corners = new Hashtable<String, Double[]>(); - String[] pName = AProjectionsManager.getKnownProjectionNames(); - Point2D.Double[] pCorners; - ALayout l = ACanvas.getCanvas().getCurrentLayout(); - Rectangle r = l.getWindowConstraints(getName()); - Dimension size = new Dimension(1, 1); - if(r != null) - size = r.getSize(); - for(int i = 0; i < pName.length; i++) - { - AProjection proj = AProjectionsManager.getProjection(pName[i]); - if(proj instanceof AProjection2D) - { - if(pName[i].equals(defaultProjectionName) && defaultCorners != null) - pCorners = getDefaultCorners(); - else - pCorners = ((AProjection2D) proj).calculateNoZoomCorners(size); - corners.put(pName[i], pCorners); - } - } - AProjection defaultProjection = AProjectionsManager.getProjection( - defaultProjectionName); - setGroup(defaultGroup); - projection = null; - setProjection(defaultProjection); - getInteractionManager().forgetContext(); - AInteractionToolBar itb = getInteractionToolBar(); - if (itb != null) { - itb.setDefaultGroup(); - interactionsManager.setContext(itb.getSelectedGroup()); - } - setScaleStatus(true); - } - } - - - public boolean isCurrent() - { - return ACanvas.getCanvas().getCurrentWindowName().equals(getName()); - } - - - public static JPopupMenu getPopupMenu() - { - return popupMenu; - } - - - public int getIndex() - { - return index; - } - - - public String getGroupName() - { - return group; - } - - - public void setGroup(String group) - { - this.group = group; - this.fireGroupChange(); - } - - - public synchronized AProjection getProjection() - { - return projection; - } - - - public AInteractionToolBar getInteractionToolBar() - { - return AInteractionToolBar.getInteractionToolBar(getName(), - projection.getName()); - } - - - public synchronized void setProjection(AProjection newProjection) - { - if((projection == null) || (!newProjection.equals(projection)) - || (newProjection instanceof AProjectionTrackResidual) - || (newProjection instanceof AProjectionNPhysics)) - { - if(projection != null && projection instanceof AProjection2D) - corners.put(projection.getName(), userCorners); - this.projection = newProjection; - if(projection instanceof AProjection2D) - userCorners = (Point2D.Double[]) corners.get(projection.getName()); - //check to see if the scales need hiding or not - this.scaleBorder.hideScale(); - this.repaintFromScratch(); - this.fireProjectionChange(); - } - } - - - private Point2D.Double[] clonedCopy(Point2D.Double[] corners) - { - if(corners == null)return null; - Point2D.Double[] newCorners = new Point2D.Double[corners.length]; - for(int i = 0; i < corners.length; i++) - newCorners[i] = new Point2D.Double(corners[i].x, corners[i].y); - return newCorners; - } - - - public synchronized void setUserCorners(Point2D.Double[] corners) - { - if(projection != null) - { - Point2D.Double[] validCorners = null; - try - { - validCorners = ((AProjection2D) projection).validateCorners( - clonedCopy(corners)); - } - catch(ClassCastException e) - { - logger.error("Not a 2D projection..."); - validCorners = corners; - } - if(validCorners != null) - { - this.userCorners = validCorners; - if(ACanvas.getCanvas().customisedCorner) - { - this.defaultCorners = validCorners; - } - repaintFromScratch(); - } - } - } - - - public boolean getUnzoomPossible() - { - if(zoomSummed.size()>0 && ((Integer) zoomSummed.peek()).intValue()==cornersHistory.size()) - return false; - else if(zoomLayers.size()>0 && ((Integer) zoomLayers.peek()).intValue()==cornersHistory.size()) - return false; - else if(zoomCalo.size()>0 && ((Integer) zoomCalo.peek()).intValue()==cornersHistory.size()) - return false; - else if(zoomCaloLAr.size()>0 && ((Integer) zoomCaloLAr.peek()).intValue()==cornersHistory.size()) - return false; - else - return projection == projectionHistory && cornersHistory.size() > 0; - } - - public boolean getUnzoomFullPossible() - { - return projection == projectionHistory && cornersHistory.size() > 0; - } - - - public boolean getUnzoomAllPossible(String typeOfZoom) - { - if(cornersHistory.size()<=0) - return false; - else if(ARectangleVPSelection.ZOOM_LAR.equals(typeOfZoom) || - ARectangleVPSelection.ZOOM_CALORIMETERS.equals(typeOfZoom)) - { - int indexOfZoomCalo=-1; - if(zoomCalo.size()>0) - indexOfZoomCalo=((Integer) zoomCalo.peek()).intValue(); - int indexOfZoomCaloLAr=-1; - if(zoomCaloLAr.size()>0) - indexOfZoomCaloLAr=((Integer) zoomCaloLAr.peek()).intValue(); - //make sure summed/layers is last in list - if(ARectangleVPSelection.ZOOM_CALORIMETERS.equals(typeOfZoom) && - indexOfZoomCalo > indexOfZoomCaloLAr) - { - return true; - } - else if(typeOfZoom.equals(ARectangleVPSelection.ZOOM_LAR) && - indexOfZoomCaloLAr > indexOfZoomCalo) - { - return true; - } - else - return false; - } - else - { - int indexOfZoomSummed=-1; - if(zoomSummed.size()>0) - indexOfZoomSummed=((Integer) zoomSummed.peek()).intValue(); - int indexOfZoomLayers=-1; - if(zoomLayers.size()>0) - indexOfZoomLayers=((Integer) zoomLayers.peek()).intValue(); - //make sure summed/layers is last in list - if(typeOfZoom.equals(ARectangleYXSelection.ZOOM_SUMMED) && indexOfZoomSummed>indexOfZoomLayers) - { - return true; - } - else if(typeOfZoom.equals(ARectangleYXSelection.ZOOM_LAYERS) && indexOfZoomLayers>indexOfZoomSummed) - { - return true; - } - else - return false; - } - } - - - public void unzoom(String typeOfZoom) - { - //do unzoom of which item is selected - int numberOfWindows=0,indexOfZoom; - if(typeOfZoom.equals(ARectangleVPSelection.ZOOM_LAR) || - typeOfZoom.equals(ARectangleYXSelection.ZOOM_SUMMED)) - { - numberOfWindows=4; - } - else if(ARectangleVPSelection.ZOOM_CALORIMETERS.equals(typeOfZoom) || - typeOfZoom.equals(ARectangleYXSelection.ZOOM_LAYERS)) - { - numberOfWindows=8; - } - int numberOfUnlayouts=0; - for (int i = 0; i < numberOfWindows; i++) - { - String wName = Integer.toString(i+1); - AWindow w = ACanvas.getCanvas().getWindow(wName); - //find if can do unzoom and what index it is - indexOfZoom=findUnzoomIndex(typeOfZoom, w); - if(indexOfZoom>0) - { - //do all unzooms upto and including index of this zoom to unzoom - while(w.cornersHistory.size()>=indexOfZoom) - w.unzoom(); - //also need to reset parameters - setParameters(typeOfZoom, w, wName); - //find out how many unlayouts to do - int count=0; - while(w.layoutHistory.size()>0 && ((Integer)w.layoutHistory.peek()).intValue()>=indexOfZoom) - { - w.layoutHistory.pop(); - count++; - } - if(count>numberOfUnlayouts) - numberOfUnlayouts=count; - } - } - //do as many unlayouts as needed - for(int i=0; i<numberOfUnlayouts; i++) - ACanvas.getCanvas().unlayout(); - } - - - private int findUnzoomIndex(String typeOfZoom, AWindow w) - { - int indexOfZoom=0;//if returns 0 then no unzoom is to be performed - if(ARectangleVPSelection.ZOOM_CALORIMETERS.equals(typeOfZoom)) - { - if(w.zoomCalo.size()==0) - indexOfZoom=0; - else - { - indexOfZoom=((Integer) w.zoomCalo.pop()).intValue(); - //check if other zooms done on this window - while(w.zoomCaloLAr.size()>0 && ((Integer) w.zoomCaloLAr.peek()).intValue()>indexOfZoom) - { - w.zoomCaloLAr.pop(); - w.modeHistory.pop(); - } - } - } - else if(typeOfZoom.equals(ARectangleVPSelection.ZOOM_LAR)) - { - if(w.zoomCaloLAr.size()==0) - indexOfZoom=0; - else - { - indexOfZoom=((Integer) w.zoomCaloLAr.pop()).intValue(); - while(w.zoomCalo.size()>0 && ((Integer) w.zoomCalo.peek()).intValue()>indexOfZoom) - { - w.zoomCalo.pop(); - w.modeHistory.pop(); - } - } - } - if(typeOfZoom.equals(ARectangleYXSelection.ZOOM_SUMMED)) - { - if(w.zoomSummed.size()==0) - indexOfZoom=0; - else - { - indexOfZoom=((Integer) w.zoomSummed.pop()).intValue(); - //check if other zooms done on this window - while(w.zoomLayers.size()>0 && ((Integer) w.zoomLayers.peek()).intValue()>indexOfZoom) - { - w.zoomLayers.pop(); - w.modeHistory.pop(); - w.cutHistoryHEC.pop(); - w.cutHistoryLAr.pop(); - } - } - } - else if(typeOfZoom.equals(ARectangleYXSelection.ZOOM_LAYERS)) - { - if(w.zoomLayers.size()==0) - indexOfZoom=0; - else - { - indexOfZoom=((Integer) w.zoomLayers.pop()).intValue(); - while(w.zoomSummed.size()>0 && ((Integer) w.zoomSummed.peek()).intValue()>indexOfZoom) - { - w.zoomSummed.pop(); - w.modeHistory.pop(); - w.cutHistoryHEC.pop(); - w.cutHistoryLAr.pop(); - } - } - } - return indexOfZoom; - } - - - private void setParameters(String typeOfZoom, AWindow w, String wName) - { - APar parameterStore = APar.instance(); - parameterStore.selectWindowParameters(wName); - if(ARectangleVPSelection.ZOOM_LAR.equals(typeOfZoom) || - ARectangleVPSelection.ZOOM_CALORIMETERS.equals(typeOfZoom)) - { - parameterStore.get("VP", "Mode").setI( w.modeHistory.pop() ); - } - else - { - parameterStore.get("YX", "Mode").setI( w.modeHistory.pop() ); - parameterStore.get("CutsCalo","HEC").setI( w.cutHistoryHEC.pop() ); - parameterStore.get("CutsCalo","LAr").setI( w.cutHistoryLAr.pop() ); - } - parameterStore.restoreWindowParameters(); - } - - - public void saveParameters(String typeOfZoom) - { - APar parameterStore = APar.instance(); - //save window parameters of current windows - if(typeOfZoom.equals(ARectangleYXSelection.ZOOM_SUMMED) || typeOfZoom.equals(ARectangleYXSelection.ZOOM_LAYERS)) - { - parameterStore.selectWindowParameters(this.getName()); - this.modeHistory.push(new Integer(parameterStore.get("YX", "Mode").getI())); - this.cutHistoryHEC.push(new Integer(parameterStore.get("CutsCalo","HEC").getI())); - this.cutHistoryLAr.push(new Integer(parameterStore.get("CutsCalo","LAr").getI())); - parameterStore.restoreWindowParameters(); - } - else if(ARectangleVPSelection.ZOOM_CALORIMETERS.equals(typeOfZoom) || - ARectangleVPSelection.ZOOM_LAR.equals(typeOfZoom)) - { - parameterStore.selectWindowParameters(this.getName()); - this.modeHistory.push(new Integer(parameterStore.get("VP", "Mode").getI())); - parameterStore.restoreWindowParameters(); - } - } - - - public void unzoomFull() - { - //perform unzoom to initial state - setUserCorners(((AProjection2D) getProjection()).calculateNoZoomCorners(getSize())); - //clear all variables for this window - cornersHistory.clear(); - zoomSummed.clear(); - zoomLayers.clear(); - zoomCaloLAr.clear(); - zoomCalo.clear(); - layoutHistory.clear(); - modeHistory.clear(); - cutHistoryHEC.clear(); - cutHistoryLAr.clear(); - } - - - public void unzoom() - { - if(projection == projectionHistory && cornersHistory.size() > 0) - { - setUserCorners((Point2D.Double[]) (cornersHistory.pop())); - } - } - - - public void saveLayout() - { - if(userCorners != null) - { - ACanvas.getCanvas().saveLayout(); - } - } - - - public void saveCorners() - { - if(projection != projectionHistory) - { - cornersHistory.clear(); - String wName = this.getName(); - int temp; - if(wName.equals("1") || wName.equals("2") || wName.equals("3") || wName.equals("4") || - wName.equals("5") || wName.equals("6") || wName.equals("7") || wName.equals("8")) - { - zoomSummed.clear(); - zoomLayers.clear(); - zoomCaloLAr.clear(); - zoomCalo.clear(); - layoutHistory.clear(); - //will have already done saveParameters so only - //want the last saved parameters of mode and cuts - if(modeHistory.size()>0) - { - temp = ((Integer) modeHistory.pop()).intValue(); - modeHistory.clear(); - modeHistory.push(new Integer(temp)); - } - - if(cutHistoryHEC.size()>0) - { - temp = ((Integer) cutHistoryHEC.pop()).intValue(); - cutHistoryHEC.clear(); - cutHistoryHEC.push(new Integer(temp)); - } - - if(cutHistoryLAr.size()>0) - { - temp = ((Integer) cutHistoryLAr.pop()).intValue(); - cutHistoryLAr.clear(); - cutHistoryLAr.push(new Integer(temp)); - } - } - } - projectionHistory = projection; - if(userCorners != null) - { - cornersHistory.push(clonedCopy(userCorners)); - } - } - - - public void saveCorners(String typeOfZoom) - { - saveCorners(); - //save zoom just done - if(userCorners != null) - { - if(typeOfZoom.equals(ARectangleYXSelection.ZOOM_SUMMED)) - { - zoomSummed.push(new Integer(cornersHistory.size())); - } - else if(typeOfZoom.equals(ARectangleYXSelection.ZOOM_LAYERS)) - { - zoomLayers.push(new Integer(cornersHistory.size())); - } - else if(ARectangleVPSelection.ZOOM_CALORIMETERS.equals(typeOfZoom)) - { - zoomCalo.push(new Integer(cornersHistory.size())); - } - else if(ARectangleVPSelection.ZOOM_LAR.equals(typeOfZoom)) - { - zoomCaloLAr.push(new Integer(cornersHistory.size())); - } - layoutHistory.push(new Integer(cornersHistory.size())); - } - } - - - public void setUserCornersNoRepaint(Point2D.Double[] corners) - { - Point2D.Double[] validCorners = ((AProjection2D) projection). - validateCorners(clonedCopy(corners)); - if(validCorners != null) - { - this.userCorners = validCorners; - } - } - - - public void setUserCorners(double x0, double x1, double y0, double y1) - { - Point2D.Double[] corners = new Point2D.Double[3]; - corners[0] = new Point2D.Double(x0, y1); - corners[1] = new Point2D.Double(x1, y1); - corners[2] = new Point2D.Double(x1, y0); - if(projection instanceof AProjection2D) corners = ((AProjection2D) - projection).validateCorners(corners); - if(corners != null) - this.userCorners = corners; - } - - - public Point2D.Double[] getDefaultCorners() - { - return clonedCopy(defaultCorners); - } - - - public Point2D.Double[] getUserCorners() - { - return clonedCopy(userCorners); - } - - - public void setInteractionManager(AInteractionsManager interactionsManager) - { - this.interactionsManager = interactionsManager; - //Make the interactions Manager aware of canvas changes - ACanvas.getCanvas().addParentWindowFocusListener(interactionsManager); - } - - - public void setScaleStatus(boolean statusWanted) - { - if(getScaleStatus() != statusWanted) toggleScale(); - } - - - public boolean getScaleStatus() - { - return scaleBorder.getScaleStatus(); - } - - - private void toggleScale() - { - scaleBorder.toggleScale(); - repaintFromScratch(); - } - - - public AInteractionsManager getInteractionManager() - { - return interactionsManager; - } - - - public void paintComponent(Graphics g) { - // Don't draw anything for ourself - } - - void paintWindow(Graphics g, boolean doubleBuffer) - { - if(!ACanvas.getCanvas().isReallyOnScreen(this)) - return; - //Why is this checked in paintComponent, and not already in - //setProjection() ? FIXIT / CLEANUP S.B - if(projection instanceof AProjectionTrackResidual) - { - if (((AProjectionTrackResidual) projection).getResidual() != null) - userCorners = ((AProjectionTrackResidual)projection).calculateNoZoomCorners(); - else - { - AOutput.append("\nTrackResidual Projection is not available, using YX instead in window " - + this.getName() + ".\n", ALogInterface.WARNING); - projection = AProjectionsManager.getProjection("YX"); - userCorners = (Point2D.Double[]) corners.get(projection.getName()); - } - } - - //Make sure the offscreen buffer is there if we need one - Graphics paint = g; - if (doubleBuffer) { - createOffScreenBuffer(); - paint = backingGraphics; - } - - // Means either we're using g or backingGraphics was something valid - if (paint != null) - { - if(!bufferValid) - { - setLocked(false); - paintWindowFromScratch(paint); - LinkedList<AInteraction> interactions = interactionsManager.getInteractions(); - for (int i = 0; i < interactions.size(); i++) { - if (interactions.get(i) instanceof ASelection) { - ((ASelection) interactions.get(i)).invalidate(); - } - } - bufferValid = true; - - } - - if (!isLocked() && !borderValid) { - //m_view.getBorder().paintBorder(paint); - borderValid = true; - } - - } - - // If we painted into a context which wasn't the target graphics context - // then we need to paint our buffer to the screen - if (g != paint) { - imageComponent(g); - } - - LinkedList<AInteraction> interactions = interactionsManager.getInteractions(); - for(int i = 0; i < interactions.size(); i++) - ((AInteraction) interactions.get(i)).paint((Graphics2D) g); - } - - // I suppose this function is intended to be called before every printing, - // but it is actually only called for EPS printing!!! FIX / CLEANUP S.B. - public void printComponent(Graphics g) - { - setLocked(false); - if(!ACanvas.getCanvas().isReallyOnScreen(this)) - return; - ((AScaleBorder) getView().getBorder()).forceDraw(); - //Double border painting needed here for EPS - probably something wrong in - //projection drawing -> graphics context left unclean? FIXIT. S.B. - ((AScaleBorder) getView().getBorder()).printBorder(this,g,this.getX(),this.getY(),this.getWidth(),this.getHeight()); - paintWindowFromScratch(g); - ((AScaleBorder) getView().getBorder()).printBorder(this,g,this.getX(),this.getY(),this.getWidth(),this.getHeight()); - borderValid = true; - LinkedList<AInteraction> interactions = interactionsManager.getInteractions(); - for(int i = 0; i < interactions.size(); i++) - { - AInteraction inter = (AInteraction) interactions.get(i); - if(inter.isPrintable()) - inter.paint((Graphics2D) g); - } - } - - - public void printBorder(Graphics g){} - - - // must call paint border myself since the border is backed too - public void paintBorder(Graphics g) - {} - - - public void repaintFromScratch() - { - if(locked)return; - bufferValid = false; - borderValid = false; - - // Check whether to draw scales on repaint - scaleBorder.hideScale(); - - // For some reason need to repaint the view too when using heavyweight - // component inside... - Adam - repaint(); - m_view.repaint(); - - } - - - // Attention: for efficiency this routine overwrites and returns its input - public ACoord calculateUser(ACoord user) - { - double[] h; - double[] v; - double hTemp; - double vTemp; - if(validTransform()) - { - for(int j = 0; j < user.hv[0].length; ++j) - { - h = user.hv[0][j]; - v = user.hv[1][j]; - for(int i = 0; i < h.length; ++i) - { - hTemp = h[i]; - vTemp = v[i]; - h[i] = m00 * hTemp + m01 * vTemp + m02; - v[i] = m10 * hTemp + m11 * vTemp + m12; - } - } - } - else - { - for(int j = 0; j < user.hv[0].length; ++j) - { - h = user.hv[0][j]; - v = user.hv[1][j]; - for(int i = 0; i < h.length; ++i) - { - h[i] = 0.; - v[i] = 0.; - } - } - } - return user; - } - - - public Point2D.Double calculateUser(double x, double y) - { - double[][][] hv = new double[2][1][1]; - hv[0][0][0] = x; - hv[1][0][0] = y; - ACoord p = calculateUser(new ACoord(hv)); - return new Point2D.Double(p.hv[0][0][0], p.hv[1][0][0]); - } - - - public Point2D.Double calculateUser(Point2D.Double p) - { - return calculateUser(p.x, p.y); - } - - - public Point2D.Double calculateUser(Point p) - { - return calculateUser(p.x, p.y); - } - - - // Attention! For efficiency this routine overwrites and returns its input - public ACoord calculateDisplay(ACoord user) - { - if(user == null) - return null; - double[] h; - double[] v; - double hTemp; - double vTemp; - if(validTransform()) - { - for(int j = 0; j < user.hv[0].length; ++j) - { - h = user.hv[0][j]; - v = user.hv[1][j]; - for(int i = 0; i < h.length; ++i) - { - hTemp = h[i]; - vTemp = v[i]; - h[i] = n00 * hTemp + n01 * vTemp + n02; - v[i] = n10 * hTemp + n11 * vTemp + n12; - } - } - } - else - { - for(int j = 0; j < user.hv[0].length; ++j) - { - h = user.hv[0][j]; - v = user.hv[1][j]; - for(int i = 0; i < h.length; ++i) - { - h[i] = 0.; - v[i] = 0.; - } - } - } - return user; - } - - - public Point2D.Double calculateDisplay(double x, double y) - { - double[][][] hv = new double[2][1][1]; - hv[0][0][0] = x; - hv[1][0][0] = y; - ACoord p = calculateDisplay(new ACoord(hv)); - return new Point2D.Double(p.hv[0][0][0], p.hv[1][0][0]); - } - - - public Point2D.Double calculateDisplay(Point2D.Double p) - { - return calculateDisplay(p.x, p.y); - } - - /** - * Called when the window is selected - */ - void select() - { - scaleBorder.setSelected(); - //redraw border to indicate this window is selected - borderValid = false; - repaint(); - } - - /** - * Called when the window is deselected - */ - void deselect() - { - scaleBorder.setDeselected(); - //redraw border to indicate this window is deselected - borderValid = false; - repaint(); - } - - /** - * Draws the image from the backup buffer on screen - */ - private void imageComponent(Graphics g) - { - Graphics2D g2d = (Graphics2D) g; - if(g2d != null) - { - Rectangle clipRect = g2d.getClipBounds(); - // Repaint only what is necessary. Except when running on MacOSX Tiger. - // (see http://lists.apple.com/archives/Java-dev/2005/Jun/msg00611.html) - if(clipRect != null && !(System.getProperty("os.name").equals("Mac OS X") - && System.getProperty("os.version").startsWith("10.4."))) - { - int x = clipRect.x; - int y = clipRect.y; - int w = clipRect.width; - int h = clipRect.height; - BufferedImage subImage = backingImage.getSubimage(x, y, w, h); - g2d.drawImage(subImage, x, y, this); - } - else - { - g2d.drawImage(backingImage, 0, 0, this); - } - } - } - - - public Rectangle getCurrDisp() - { - int width = m_view.getWidth(); - int height = m_view.getHeight(); - insets = m_view.getInsets(insets); - int x = insets.left; - int y = insets.top; - int w = width - insets.left - insets.right; - int h = height - insets.top - insets.bottom; - return new Rectangle(x, y, w, h); - } - - - public void paintWindowFromScratch(Graphics g) - { - APar parameterStore = APar.instance(); - ACanvas.getCanvas().setPaintingWindow(this); - parameterStore.selectWindowParameters(getName()); - Rectangle currDisp = getCurrDisp(); - int x = (int) Math.rint(currDisp.getX()); - int y = (int) Math.rint(currDisp.getY()); - int width = (int) Math.rint(currDisp.getWidth()); - int height = (int) Math.rint(currDisp.getHeight()); - g.setClip(x, y, width, height); - Graphics2D g2 = (Graphics2D)g; - if(APreferencesControl.getAliasMenuItem()) - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - else - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - - projection.paint(this, g); - - g.setClip(0, 0, m_view.getWidth(), m_view.getHeight()); - parameterStore.restoreWindowParameters(); - ACanvas.getCanvas().setPaintingWindow(null); - - if(AColorHelpDialog.getInstance() != null && AColorHelpDialog.getInstance().isVisible()) - AColorHelpDialog.getInstance().update(); - } - - - private void createOffScreenBuffer() - { - int w = m_view.getWidth(); - int h = m_view.getHeight(); - Dimension dim = new Dimension(w, h); - // Check that the current size is positive. - if(w > 0 && h > 0) - { - if(!backingDimension.equals(dim)) - { - // Usinig ABufferedPixelGraphics is not a good idea in MacOSX Tiger. - // So instead we use createGraphics() to create a normal Graphics2D - // object to draw on. - if(System.getProperty("os.name").equals("Mac OS X") - && System.getProperty("os.version").startsWith("10.4.")) - { - backingImage = getGraphicsConfiguration().createCompatibleImage(w, h); - } else if(GraphicsEnvironment.getLocalGraphicsEnvironment(). - getDefaultScreenDevice().getDefaultConfiguration(). - getColorModel().getTransferType() - == DataBuffer.TYPE_USHORT) - { - backingImage = new BufferedImage(w, h, - BufferedImage.TYPE_USHORT_565_RGB); - } - else - { - if(System.getProperty("os.name").equals("Mac OS X")) - backingImage = new BufferedImage(w, h, - BufferedImage.TYPE_INT_ARGB_PRE); - else - backingImage = new BufferedImage(w, h, - BufferedImage.TYPE_INT_RGB); - } - backingGraphics = backingImage.createGraphics(); - backingDimension.setSize(dim); - bufferValid = false; - borderValid = false; - } - } - else - { - backingImage = null; - backingGraphics = null; - } - } - - - public Point2D.Double[] getDisplayCorners() - { - Point2D.Double[] corners = new Point2D.Double[3]; - insets = m_view.getInsets(insets); - int x = insets.left; - int y = insets.top; - int w = m_view.getWidth() - insets.left - insets.right; - int h = m_view.getHeight() - insets.top - insets.bottom; - Point2D.Double upperLeft = new Point2D.Double(x, y); - Point2D.Double lowerRight = new Point2D.Double(x + w, y + h); - Point2D.Double upperRight = new Point2D.Double(x + w, y); - corners[0] = upperLeft; - corners[1] = upperRight; - corners[2] = lowerRight; - return corners; - } - - - private boolean validTransform() - { - double x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3; - x1 = userCorners[0].x; - y1 = userCorners[0].y; - x2 = userCorners[1].x; - y2 = userCorners[1].y; - x3 = userCorners[2].x; - y3 = userCorners[2].y; - Point2D.Double[] displayCorners = getDisplayCorners(); - u1 = displayCorners[0].x; - v1 = displayCorners[0].y; - u2 = displayCorners[1].x; - v2 = displayCorners[1].y; - u3 = displayCorners[2].x; - v3 = displayCorners[2].y; - if(v1 * (u3 - u2) + v2 * (u1 - u3) + v3 * (u2 - u1) == 0.)return false; - if((u1 - u2) == 0.)return false; - m01 = (u1 * (x2 - x3) + u2 * (x3 - x1) + u3 * (x1 - x2)) / - (v1 * (u3 - u2) + v2 * (u1 - u3) + v3 * (u2 - u1)); - m00 = ((x1 - x2) - m01 * (v1 - v2)) / (u1 - u2); - m02 = x1 - m00 * u1 - m01 * v1; - m11 = (u1 * (y2 - y3) + u2 * (y3 - y1) + u3 * (y1 - y2)) / - (v1 * (u3 - u2) + v2 * (u1 - u3) + v3 * (u2 - u1)); - m10 = ((y1 - y2) - m11 * (v1 - v2)) / (u1 - u2); - m12 = y1 - m10 * u1 - m11 * v1; - if((x1 - x2) == 0.) - { - n01 = (u2 - u1) / (y2 - y1); - n11 = (v2 - v1) / (y2 - y1); - n00 = ((u3 - u2) - n01 * (y3 - y2)) / (x3 - x1); - n10 = ((v3 - v2) - n11 * (y3 - y2)) / (x3 - x1); - n02 = u1 - n00 * x1 - n01 * y1; - n12 = v1 - n10 * x1 - n11 * y1; - return true; - } - else - { - if(y1 * (x3 - x2) + y2 * (x1 - x3) + y3 * (x2 - x1) == 0.)return false; - n01 = (x1 * (u2 - u3) + x2 * (u3 - u1) + x3 * (u1 - u2)) / - (y1 * (x3 - x2) + y2 * (x1 - x3) + y3 * (x2 - x1)); - n00 = ((u1 - u2) - n01 * (y1 - y2)) / (x1 - x2); - n02 = u1 - n00 * x1 - n01 * y1; - n11 = (x1 * (v2 - v3) + x2 * (v3 - v1) + x3 * (v1 - v2)) / - (y1 * (x3 - x2) + y2 * (x1 - x3) + y3 * (x2 - x1)); - n10 = ((v1 - v2) - n11 * (y1 - y2)) / (x1 - x2); - n12 = v1 - n10 * x1 - n11 * y1; - return true; - } - } - - - public JToolTip createToolTip() - { - JToolTip tip = new JToolTip(); - tip.setFont(new Font(null, Font.PLAIN, 20)); - return tip; - } - - - // implementation of DropTargetListener - - // Called when a drag operation has encountered the DropTarget. - public void dragEnter(DropTargetDragEvent dtde) - { - dtde.acceptDrag(DnDConstants.ACTION_MOVE); - } - - - // The drag operation has departed the DropTarget without dropping. - public void dragExit(DropTargetEvent dte) - {} - - - // Called when a drag operation is ongoing on the DropTarget. - public void dragOver(DropTargetDragEvent dtde) - {} - - - // The drag operation has terminated with a drop on this DropTarget. - public void drop(DropTargetDropEvent dtde) - { - try - { - Transferable transferable = dtde.getTransferable(); - DataFlavor javaObjectDataFlavor = new DataFlavor(DataFlavor. - javaJVMLocalObjectMimeType); - if(transferable.isDataFlavorSupported(javaObjectDataFlavor)) - { - dtde.acceptDrop(DnDConstants.ACTION_MOVE); - Object object = transferable.getTransferData( - javaObjectDataFlavor); - if(object instanceof ACallBack) - ((ACallBack) object).callBack(this); - else - ACanvas.getCanvas().copyWindowSettings(((ADnDLabel) object).getText(), - getName()); - dtde.getDropTargetContext().dropComplete(true); - } - else - AOutput.append("Cannot accept drop\n", ALogInterface.BAD_COMMAND); - } - catch(Exception e) - { - e.printStackTrace(); - dtde.rejectDrop(); - } - } - - - // Called if the user has modified the current drop gesture. - public void dropActionChanged(DropTargetDragEvent dtde) - {} - - - private Vector<ChangeListener> projectionChangeListeners = new Vector<ChangeListener>(); - public void addProjectionChangeListener(ChangeListener listener) - { - projectionChangeListeners.addElement(listener); - listener.stateChanged(new ChangeEvent(this)); - } - - - private void fireProjectionChange() - { - ChangeEvent changeEvent = new ChangeEvent(this); - for(int i = 0; i < projectionChangeListeners.size(); i++) - { - ChangeListener changeListener = (ChangeListener) - projectionChangeListeners.elementAt( - i); - changeListener.stateChanged(changeEvent); - } - } - - - private Vector<ChangeListener> groupChangeListeners = new Vector<ChangeListener>(); - public void addGroupChangeListener(ChangeListener listener) - { - groupChangeListeners.addElement(listener); - listener.stateChanged(new ChangeEvent(this)); - } - - - private void fireGroupChange() - { - ChangeEvent changeEvent = new ChangeEvent(this); - for(int i = 0; i < groupChangeListeners.size(); i++) - { - ChangeListener changeListener = (ChangeListener) - groupChangeListeners.elementAt(i); - changeListener.stateChanged(changeEvent); - } - } - - - // implementation of DragSourceListener - - // This method is invoked to signify that the Drag and Drop operation is complete. - public void dragDropEnd(DragSourceDropEvent dsde) - {} - - - // Called as the hotspot enters a platform dependent drop site. - public void dragEnter(DragSourceDragEvent dsde) - { - dsde.getDragSourceContext().setCursor(ADnDLabel.DROP_INVALID); - } - - - // Called as the hotspot exits a platform dependent drop site. - public void dragExit(DragSourceEvent dse) - { - dse.getDragSourceContext().setCursor(ADnDLabel.DROP_INVALID); - } - - - // Called as the hotspot moves over a platform dependent drop site. - public void dragOver(DragSourceDragEvent dsde) - { - dsde.getDragSourceContext().setCursor(ADnDLabel.DROP_VALID); - } - - - // Called when the user has modified the drop gesture. - public void dropActionChanged(DragSourceDragEvent dsde) - {} - - - // implementation of DragGestureListener - - public void dragGestureRecognized(DragGestureEvent dge) - { - if(!canCopyScales)return; - Point p = dge.getDragOrigin(); - Insets i = m_view.getInsets(); - int w = m_view.getWidth(); - int h = m_view.getHeight(); - Rectangle vScale = new Rectangle(0, 0, i.left, h - i.bottom); - Rectangle hScale = new Rectangle(i.left, h - i.bottom, w - i.left, - i.bottom); - if(vScale.contains(p)) - dragAction = dragActionType.COPY_VERTICAL_SCALE; - else if(hScale.contains(p)) - dragAction = dragActionType.COPY_HORIZONTAL_SCALE; - else - return; - dragSource.startDrag(dge, ADnDLabel.DROP_INVALID, - new AObjectTransferable(this), this); - } - - - public void setScaleCopyStatus(boolean canCopyScales) - { - this.canCopyScales = canCopyScales; - } - - - public void callBack(Object to) - { - AWindow targetWindow; - if(to instanceof ADnDLabel) - targetWindow = ACanvas.getCanvas().getWindow(((ADnDLabel) to). - getText()); - else if(to instanceof AWindow) - targetWindow = (AWindow) to; - else - return; - if(dragAction == dragActionType.COPY_VERTICAL_SCALE) - { - String labelSource = ((AScaleBorder) getBorder()). - getVerticalAxisLabel(); - String labelTarget = ((AScaleBorder) (targetWindow.getBorder())). - getVerticalAxisLabel(); - if(labelSource.equals(labelTarget) && labelSource.equals(AMath.PHI)) - { - Point2D.Double[] sourceCorners = getUserCorners(); - Point2D.Double[] targetCorners = targetWindow.getUserCorners(); - for(int i = 0; i < sourceCorners.length; ++i) - targetCorners[i].setLocation(targetCorners[i].getX(), - sourceCorners[i].getY()); - targetWindow.setUserCorners(targetCorners); - AOutput.append("Copy " + AMath.PHI + " Scale from " + getName() + - " to " + targetWindow.getName() + "\n", - ALogInterface.NORMAL); - } - } - else if(dragAction == dragActionType.COPY_HORIZONTAL_SCALE) - { - String labelSource = ((AScaleBorder) getBorder()). - getHorizontalAxisLabel(); - String labelTarget = ((AScaleBorder) targetWindow.getBorder()). - getHorizontalAxisLabel(); - if(labelSource.equals(labelTarget) && labelSource.equals("Z")) - { - Point2D.Double[] sourceCorners = getUserCorners(); - Point2D.Double[] targetCorners = targetWindow.getUserCorners(); - for(int i = 0; i < sourceCorners.length; ++i) - targetCorners[i].setLocation(sourceCorners[i].getX(), - targetCorners[i].getY()); - targetWindow.setUserCorners(targetCorners); - AOutput.append("Copy Z Scale from " + getName() + " to " + - targetWindow.getName() + "\n", - ALogInterface.NORMAL); - } - } - } - - - private void setLocked(boolean locked) - { - if(locked == this.locked)return; - boolean wasLocked = this.locked; - this.locked = locked; - ACanvas.getCanvas().fireLockChange(); - if(wasLocked && !locked) - this.repaintFromScratch(); - ACanvas.getCanvas().fireLockChange(); - } - - - public boolean isLocked() - { - return locked; - } - - public JComponent getView() { - return m_view; - } - - public void invalidateQuietly() { - // When you get told to paint in OpenGL you better paint otherwise - // you're going to get your empty backbuffer painted to screen a lot - // of the time ... could fix this by managing our buffer swaps by hand - // see AWindowGLView.display() for more... - Adam - bufferValid = false; - borderValid = false; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/canvas/AWindowGLView.java b/graphics/AtlantisJava/src/atlantis/canvas/AWindowGLView.java deleted file mode 100644 index bd94b9013755d517b2199317a710a124cd235008..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/AWindowGLView.java +++ /dev/null @@ -1,337 +0,0 @@ -package atlantis.canvas; - -import atlantis.interactions.AInteractionsManager; -import atlantis.utils.ALogger; -import java.awt.BorderLayout; -import java.awt.BufferCapabilities; -import java.awt.Canvas; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.GraphicsEnvironment; -import java.awt.event.MouseListener; -import java.lang.ref.WeakReference; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import javax.media.opengl.AWTGraphicsDevice; -import javax.media.opengl.DefaultGLCapabilitiesChooser; -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCanvas; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLCapabilitiesChooser; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLJPanel; -import javax.media.opengl.glu.GLU; -import javax.swing.JPanel; -import javax.swing.border.Border; - -/** - * This class provides an OpenGL context. When the parent AWindow repaints - * this is propagated down to this view component, which then calls back to - * the parent AWindow requesting everything be copied in. - * - * @author Adam Davison - */ -public class AWindowGLView extends JPanel implements GLEventListener { - - private static ALogger logger = ALogger.getLogger(AWindowGLView.class); - - private GLCanvas m_panel; - //private JPanel m_children; - private long m_start = 0; - private int m_count = 0; - private AWindow m_parent; - private Graphics m_g = null; - - private static GLContext m_ocontext; - - // Keep track of all initialized OpenGL contexts without forcing them - // to stay in memory when we aren't using them any more... - // This is a debugging thing - private static ArrayList<WeakReference> m_all = new ArrayList<WeakReference>(); - - private static int m_maxFSAA = -1; - private static int m_FSAA = 0; - - public static int getCurrentFSAA() { - return m_FSAA; - } - - public static void setCurrentFSAA(int FSAA) { - logger.info("Changing anti-aliasing to " + FSAA + "x"); - m_FSAA = FSAA; - for (int i = 0; i < m_all.size(); i++) { - AWindowGLView v = (AWindowGLView)(m_all.get(i).get()); - if (v != null) { - v.restartDisplay(); - } - } - } - - public static int getMaxFSAA() { - return m_maxFSAA; - } - - public void restartDisplay() { - System.out.println("RESTART DISPLAY!"); - remove(m_panel); - m_panel = null; - startDisplay(); - validate(); - m_panel.setBounds(0, 0, getWidth(), getHeight()); - } - - private void startDisplay() { - GLCapabilities cap = new GLCapabilities(); - - if (m_FSAA > 0) { - cap.setSampleBuffers(true); - cap.setNumSamples(m_FSAA); - logger.info("Requesting " + m_FSAA + "x"); - } - - cap.setDoubleBuffered(true); - - if (m_ocontext != null) { - m_panel = new GLCanvas(cap, null, m_ocontext, null); - } else { - m_panel = new GLCanvas(cap); - } - - m_ocontext = m_panel.getContext(); - - m_panel.addGLEventListener(this); - - //m_FSAA = m_panel.getChosenGLCapabilities().getNumSamples(); - - //m_children = new JPanel(); - - add(m_panel, BorderLayout.CENTER); - - } - - public AWindowGLView(AWindow parent) { - m_parent = parent; - setLayout(null); - - startDisplay(); - //m_panel.add(m_but); - //add(m_but, BorderLayout.NORTH); - - - m_all.add(new WeakReference(this)); - - } - - private void checkListeners() { - AInteractionsManager lt = m_parent.getInteractionManager(); - MouseListener[] lr = m_panel.getMouseListeners(); - boolean found = false; - for (int i = 0; i < lr.length; i++) { - if (lr[i] == lt) { - found = true; - } - } - - if (!found) { - m_panel.addMouseListener(lt); - m_panel.addMouseMotionListener(lt); - } - } - - public void init(GLAutoDrawable drawable) { - - System.out.println("INIT CALLED!"); - System.out.println(getWidth() + ":" + getHeight()); - //(new Exception()).printStackTrace(); - - checkListeners(); - - //drawable.setGL(new TraceGL(drawable.getGL(), System.err)); - GL gl = drawable.getGL(); - logger.debug("INIT GL IS: " + gl.getClass().getName()); - - int[] buffer = new int[2]; - gl.glGetIntegerv(GL.GL_MAX_SAMPLES_EXT, buffer, 0); - m_maxFSAA = buffer[0]; - logger.debug("Graphics card supports max anti-alias of: " + buffer[0] + "x"); - - BufferCapabilities bc = m_panel.getGraphicsConfiguration().getBufferCapabilities(); - boolean frontacc = bc.getFrontBufferCapabilities().isAccelerated(); - boolean backacc = bc.getBackBufferCapabilities().isAccelerated(); - logger.info("OpenGL Acceleration Status: Front - " + frontacc + " and Back - " + backacc); - - // All polygons in Atlantis are uniformly coloured, this speeds things up in theory at least... - gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - gl.glShadeModel(GL.GL_FLAT); - - // Old style antialiasing like this is apparently not supported by - // modern graphics cards although we may want to enable it on older - // hardware where people do not have FSAA but still want AA - /*gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); - gl.glEnable(gl.GL_POLYGON_SMOOTH); - gl.glHint(gl.GL_LINE_SMOOTH_HINT, gl.GL_NICEST); - gl.glEnable(gl.GL_LINE_SMOOTH);*/ - - // We do our own Z-ordering - gl.glDisable(gl.GL_DEPTH_TEST); - - // Enable transparency, even if nothing in Atlantis is actually - // transparent yet... - gl.glEnable(gl.GL_BLEND); - gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA); - - } - - private static int countContexts() { - int count = 0; - for (int i = 0; i < m_all.size(); i++) { - if (m_all.get(i).get() != null) { - count++; - } - // Could throw away dead weak refs here... - } - return count; - } - - public void display(GLAutoDrawable d) { - - /*if (m_parent.isValid()) { - System.out.println("VALID PARENT - RETURNING"); - return; - }*/ - // Perhaps we could not do this and turn off buffer swaps? - // Currently we're probably doing some unnecessary repaints when - // you change window - m_parent.invalidateQuietly(); - - GL gl = d.getGL(); - //System.out.println("DISPLAY " + this); - //System.out.println("ACTIVE: " + countContexts()); - gl.glMatrixMode(GL.GL_MODELVIEW); - gl.glLoadIdentity(); - - // Can we avoid this? We probably fill with bg colour later anyway... - gl.glColor4f(1.0f, 1.0f, 1.0f, 0.5f); - gl.glClear(gl.GL_COLOR_BUFFER_BIT); - - if (m_parent != null) { - AGLGraphics glg = new AGLGraphics(d); - m_parent.paintWindow(glg, false); - super.paintBorder(glg); - /*for (int i = 0; i < m_panel.getComponentCount(); i++) { - m_panel.getComponent(i).paint(glg); - }*/ - } - - gl.glFlush(); - - m_count++; - long tnow = System.currentTimeMillis(); - if (tnow - 1000 > m_start) { - logger.info("OpenGL FPS: " + m_count); - m_count = 0; - m_start = tnow; - } - } - - /*@Override - public Graphics getGraphics() { - if (m_g == null) { - System.out.println("PAINT OUT OF VALID"); - return new ADummyGraphics2D(); - } else { - return m_g; - } - }*/ - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - //System.out.println("GLRESIZE: " + x + ":" + y + ":" + width + ":" + height); - GL gl = drawable.getGL(); - GLU glu = new GLU(); - - if (height <= 0) // avoid a divide by zero error! - { - height = 1; - } - final float h = (float) width / (float) height; - gl.glViewport(0, 0, width, height); - gl.glMatrixMode(GL.GL_PROJECTION); - gl.glLoadIdentity(); - gl.glOrtho(x, x + width, y + height, y, -100.0, 100.0); - //gl.glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0); - - gl.glMatrixMode(GL.GL_MODELVIEW); - gl.glLoadIdentity(); - - m_count = 0; - m_start = System.currentTimeMillis(); - } - - // Should implement this for multi-screen people some time... - public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) { - //throw new UnsupportedOperationException("Not supported yet."); - } - - public void setBounds(int x, int y, int width, int height) { - //Border b = getBorder(); - //setBorder(null); - super.setBounds(x, y, width, height); - m_panel.setBounds(0, 0, getWidth(), getHeight()); - //setBorder(b); - //System.out.println("RESIZE " + x + ":" + y + ":" + width + ":" + height); - } - - // Need to paint our own border to make sure it gets drawn in GL - public void paintBorder(Graphics g) { - - } - - // Need to make sure our heavyweight child is invalidated - public void repaint() { - super.repaint(); - if (m_panel != null) { - m_panel.repaint(); - } - } - - public Component getRealPanel() { - return m_panel; - } -} - -class OurGLCapChooser implements GLCapabilitiesChooser { - - private int m_maxAA; - private boolean m_canAA; - - public OurGLCapChooser() { - } - - public int chooseCapabilities(GLCapabilities req, GLCapabilities[] all, int recommended) { - System.out.println("CALLED!"); - m_canAA = false; - m_maxAA = 0; - - for (int i = 0; i < all.length; i++) { - System.out.println(all[i]); - if (all[i].getSampleBuffers()) { - m_canAA = true; - if (all[i].getNumSamples() > m_maxAA) { - m_maxAA = all[i].getNumSamples(); - } - } - } - - return (new DefaultGLCapabilitiesChooser()).chooseCapabilities(req, all, recommended); - } - - public boolean getCanAA() { - return m_canAA; - } - - public int getMaxAA() { - return m_maxAA; - } -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/canvas/AWindowSwingView.java b/graphics/AtlantisJava/src/atlantis/canvas/AWindowSwingView.java deleted file mode 100644 index cc27fad13af3f42f8d1f6300cc7cec8ff5ac1691..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/AWindowSwingView.java +++ /dev/null @@ -1,57 +0,0 @@ -package atlantis.canvas; - -import atlantis.globals.AGlobals; - -import java.awt.Graphics; -import javax.swing.JPanel; - -/** - * - * This class provides an Java2D/Swing context. When the parent AWindow repaints - * this is propagated down to this view component, which then calls back to - * the parent AWindow requesting everything be copied in. - * - * @author Adam Davison - */ -public class AWindowSwingView extends JPanel { - - private AWindow m_parent; - - public AWindowSwingView(AWindow parent) { - setLayout(null); - m_parent = parent; - } - - @Override - protected void paintComponent(Graphics g) { - //System.out.println(getX() + ":" + getY() + ":" + getWidth() + ":" + getHeight()); - g.setClip(0, 0, getWidth(), getHeight()); - //g.setColor(Color.RED); - //g.fillRect(10, 10, getWidth() - 10, getHeight() - 10); - if (AGlobals.isAtlantisHeadless()) { - // Don't need to paint to a backing buffer ever in headless - // since we're already painting offscreen - m_parent.paintWindow(g, false); - } else { - m_parent.paintWindow(g, true); - } - } - - @Override - protected void printComponent(Graphics g) { - //System.out.println(getX() + ":" + getY() + ":" + getWidth() + ":" + getHeight()); - g.setClip(0, 0, getWidth(), getHeight()); - //g.setColor(Color.RED); - //g.fillRect(10, 10, getWidth() - 10, getHeight() - 10); - m_parent.printComponent(g); - } - - @Override - public void setBounds(int x, int y, int width, int height) { - super.setBounds(x, y, width, height); - //System.out.println("RESIZE " + x + ":" + y + ":" + width + ":" + height); - } - - - -} diff --git a/graphics/AtlantisJava/src/atlantis/canvas/package.html b/graphics/AtlantisJava/src/atlantis/canvas/package.html deleted file mode 100644 index c09fd6d63f20e9be844c81cea3d2da0a24e2a85c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/canvas/package.html +++ /dev/null @@ -1,23 +0,0 @@ -<html> -<head></head> -<body> -<p>Provides classes representing the Atlantis canvas and the windows - displayed within it.</p> -<p>The ACanvas is a JFrame containing a JlayeredPane of AWindows. Windows -are placed into the JLayeredPane depending on the current layout. The -canvas class contains a HashTable of all possible windows and a -HashTable of all available layouts. Windows needed by the current -layout are added to the JLayeredPane according to the size and the -order defined by the layout. An AWindow is a JPanel into which the -Atlantis graphics are drawn. Each window has an associated projection -and also an interaction manager. The interaction manager is a mouse -listener which deals with all mouse events on the window. The window -manages the drawing of the Atlantis picture and deals with the linear -transformations from user to display co-ordinates. Non-linear -transformations are dealt with by the projection. ALayout defines the -size and position (in the 3x3 grid layout scheme of the layered pane) -of each window, and also describes combinations of these windows -called pages. pages is an array of characters where each character -represents a window.</p> -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/config/AConfig.java b/graphics/AtlantisJava/src/atlantis/config/AConfig.java deleted file mode 100755 index f35dbb07ed52727d10d1806a96c76bfd1116fdcb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/config/AConfig.java +++ /dev/null @@ -1,432 +0,0 @@ -package atlantis.config; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Iterator; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import atlantis.Atlantis; -import atlantis.utils.xml.AXMLErrorHandler; -import atlantis.utils.ALogger; -import atlantis.utils.AUtilities; - -/** - * AConfig acts as a container of the configuration file. - * The whole file can be accessed through a tree structure. - * - * @author ql - * - */ - -// by Zdenek, remark, 2008-08-14 -// since the attributes are stored in something like HashMap -// their order is not ensured?, e.g. having in WindowCorners source -// configuration (master copy according to which synchronization is done) -// <CORNERS windowName="W" x0="-1320.0" y0="1320.0" x1="1320.0" y1="1320.0" x2="1320.0" y2="-1320.0"/> -// line order this way, after updating it result in something like this -// <CORNERS x2="1320.0" windowName="W" y0="1320.0" x1="1320.0" y2="-1320.0" y1="1320.0" x0="-1320.0"/> -// the same data, but the order of attributes is not the same -public class AConfig -{ - private static ALogger logger = ALogger.getLogger(AConfig.class); - - // A map defining the key attribute for each modifiable element - static Hashtable keyMap; - - // Define modifiable attributes - public static String[] CANVAS_ATT = {"startupLayout", "aspectRatio"}; //<Canvas> - public static String[] WINDOW_ATT = {"projection", "group"}; //<UsedWindow> - public static String[] LAYOUT_ATT = {"startup", "startupWindow"}; //<Layout> - public static String[] PAR_ATT = {"va", "st", "dop", "scope", "ul"}; //<Others> - public static String[] GROUP_ATT = {"userLevel"}; //<Group> - - // Define used greek letters in configuration file - static String[] GREEK_LETTER = {"\u03B7", "\u03C1", "\u03A6", "\u0394", "\u03BB", "\u03C3"}; - static String[] GREEK_ENTITY = {"η", "ρ", "φ", "δ", "λ", "σ"}; - - // The name of the configuration file - private String filename; - - // If isCustomised is true, the configuration file contains two exclusive - // blocks, <ParameterDifferences> and <WindowCorners>. - private boolean isCustomised; - - // This field contains the whole DTD section of the configuration file. - private String dtdSection = null; - - // Root node of the configuration tree - private AConfigNode rootNode; - - // A list containing all element nodes in the file - private ArrayList nodeList; - - // A list containing all user exclusive element nodes in the file - // <ParameterDifferences> and <WindowCorners> - private ArrayList userExclusiveNodeList; - - public AConfig(String configFilename, boolean isCustomised) throws Exception - { - if(AConfig.keyMap == null) - AConfig.createKeyMap(); - this.filename = configFilename; - this.isCustomised = isCustomised; - parseXML(); - } - - /** - * @return Returns the dtdSection. - */ - public String getDtdSection() throws Exception - { - if(this.dtdSection == null) - createDTDSection(this.filename); - return this.dtdSection; - } - - public Iterator getIterator() - { - return nodeList.iterator(); - } - - void addNode(AConfigNode node) - { - nodeList.add(node); - } - - void addUserExclusiveNode(AConfigNode node) - { - userExclusiveNodeList.add(node); - } - - /** - * initialise <code>keyMap</code>. - */ - private static void createKeyMap() - { - keyMap = new Hashtable(); - keyMap.put("Canvas", "startupLayout"); - keyMap.put("UsedWindow", "name"); - keyMap.put("Layout", "name"); - keyMap.put("ENUM", "fn"); - keyMap.put("SENUM", "fn"); - keyMap.put("ICUT", "fn"); - keyMap.put("SICUT", "fn"); - keyMap.put("FCUT", "fn"); - keyMap.put("SFCUT", "fn"); - keyMap.put("INT", "fn"); - keyMap.put("SINT", "fn"); - keyMap.put("FLOAT", "fn"); - keyMap.put("SFLOAT", "fn"); - keyMap.put("LINT", "fn"); - keyMap.put("SLINT", "fn"); - keyMap.put("COLOR", "fn"); - keyMap.put("SCOLOR", "fn"); - keyMap.put("STATUS", "fn"); - } - - /** - * initialise <code>dtdSection</code> based on the dtd part from the - * configuration file. - */ - private void createDTDSection(String configFilename) throws Exception - { - String dtdStart = "<?xml version=\"1.0\"?>"; - String dtdEnd = "]>"; - String LINE_SEPAR = System.getProperty("line.separator"); - - this.dtdSection = ""; - try - { - - InputStream is = AUtilities.getFileAsStream(configFilename); - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr); - - String currentLine; - boolean isInsideDTD = false; - while(true) - { - currentLine = br.readLine(); - if(currentLine == null) return; - if(dtdStart.equals(currentLine.trim())) - { - isInsideDTD = true; - this.dtdSection += currentLine + LINE_SEPAR; - } - else if(dtdEnd.equals(currentLine.trim())) - { - isInsideDTD = false; - this.dtdSection += currentLine + LINE_SEPAR; - } - else if(isInsideDTD) - { - this.dtdSection += currentLine + LINE_SEPAR; - } - } - } - catch(FileNotFoundException e) - { - String m = "File " + configFilename + " not found, fatal."; - throw new Exception(m); - } - catch(IOException e) - { - String m = "I/O exception while reading file " + configFilename; - throw new Exception(m); - } - } - - public void createConfigTree(Element rootElement) - { - this.nodeList = new ArrayList(); - if(this.isCustomised) - this.userExclusiveNodeList = new ArrayList(); - this.rootNode = new AConfigNode(null, rootElement, 0, this); - } - - public void parseXML() throws Exception - { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setValidating(true); - DocumentBuilder parser; - try - { - parser = factory.newDocumentBuilder(); - parser.setErrorHandler(new AXMLErrorHandler()); - - InputStream isConfig = AUtilities.getFileAsStream(this.filename); - Document xmlConfigDoc = parser.parse(isConfig); - createConfigTree(xmlConfigDoc.getDocumentElement()); - } - catch (Exception e) - { - throw e; - } - } - - // Find a node match the sampleNode in the configuration file - // Return the node if found, null otherwise - public AConfigNode find(AConfigNode sampleNode) - { - for(int i=0; i<nodeList.size(); ++i) - { - AConfigNode testNode = (AConfigNode) nodeList.get(i); - if("Canvas".equals(sampleNode.getNodeName()) - && (testNode.getFullNodeName().equals(sampleNode.getFullNodeName()))) - { - return testNode; - } - else if((testNode.getFullNodeName().equals(sampleNode.getFullNodeName())) - && (testNode.getKeyValue().equals(sampleNode.getKeyValue()))) - { - return testNode; - } - } - return null; - } - - // Find a node based on the node name, attribute name and value - // Return the node if found, null otherwise - public AConfigNode find(String name, String attName, String attValue) - { - for(int i=0; i<nodeList.size(); ++i) - { - AConfigNode testNode = (AConfigNode) nodeList.get(i); - if(name.equals(testNode.getNodeName()) - && attValue.equals(testNode.getAttValue(attName))) - return testNode; - } - return null; - } - - // Find a node based on the node name, attribute name and value, - // and its parent's node name, attribute name and value. - // Return the node if found, null otherwise - public AConfigNode find(String name, String attName, String attValue, - String parName, String parAttName, String parAttValue) - { - for(int i=0; i<nodeList.size(); ++i) - { - AConfigNode testNode = (AConfigNode) nodeList.get(i); - if(name.equals(testNode.getNodeName()) - && attValue.equals(testNode.getAttValue(attName))) - { - AConfigNode parNode = testNode.getParent(); - - if(parName.equals(parNode.getNodeName()) - && parAttValue.equals(parNode.getAttValue(parAttName))) - return testNode; - } - } - return null; - } - - // Find a parameter node based on the attribute name and value, - // and its group's name - // Return the node if found, null otherwise - // - // NB: This method is for finding a parameter node with uncertain - // parameter type, but with a certain parent node name - public AConfigNode findPar(String attName, String attValue, String parAttValue) - { - for(int i=0; i<nodeList.size(); ++i) - { - AConfigNode testNode = (AConfigNode) nodeList.get(i); - if(attValue.equals(testNode.getAttValue(attName))) - { - AConfigNode parNode = testNode.getParent(); - - // <StatusRoot> and <StatusGroup> are skipped when finding parent node - while("StatusRoot".equals(parNode.getNodeName()) - || "StatusGroup".equals(parNode.getNodeName())) - { - parNode = parNode.getParent(); - } - - if("Group".equals(parNode.getNodeName()) - && parAttValue.equals(parNode.getAttValue("name"))) - return testNode; - } - } - return null; - } - - /** - * validate the attribute value - */ - public boolean validate(AConfigNode node, String attName, String attValue) - { - if("Canvas".equals(node.getNodeName()) && "startupLayout".equals(attName)) - { - if(find("Layout", "name", attValue) == null) - return false; - } - else if("UsedWindow".equals(node.getNodeName()) && "projection".equals(attName)) - { - if(find("Group", "name", attValue, "SuperGroup", "name", "Projection") == null) - return false; - } - else if("UsedWindow".equals(node.getNodeName()) && "group".equals(attName)) - { - if(find("Group", "name", attValue) == null) - return false; - } - else if("Layout".equals(node.getNodeName())) - { - int numWindows = attValue.length(); - for(int i=0; i<numWindows; ++i) - { - String windowName = attValue.substring(i, i+1); - if(find("Window", "name", windowName, "Layout", "name", node.getKeyValue()) == null) - return false; - } - } - return true; - } - - public void validateUserExclusiveNode(AConfigNode node) - { - if("ParameterDifferences".equals(node.getNodeName())) - { - // check validity of each child of <ParameterDifferences> - Iterator it = node.getChildren().iterator(); - while(it.hasNext()) - { - // a <DIFFERENCE> node - AConfigNode childNode = (AConfigNode) it.next(); - String group = childNode.getAttValue("group"); - String window = childNode.getAttValue("windowName"); - String parameter = childNode.getAttValue("name"); - if(find("UsedWindow", "name", window) == null) - it.remove(); - else - { - if(find("Group", "name", group) == null) - it.remove(); - else - { - if(findPar("fn", parameter, group) == null) - it.remove(); - } - } - } - } - else if("WindowCorners".equals(node.getNodeName())) - { - // check validity of each child of <WindowCorners> - Iterator it = node.getChildren().iterator(); - while(it.hasNext()) - { - // a <CORNERS> node - AConfigNode childNode = (AConfigNode) it.next(); - String window = childNode.getAttValue("windowName"); - if(find("UsedWindow", "name", window) == null) - it.remove(); - } - } - } - - /** - * Replace the greek letters in the source string with UTF entities - * - * @param testStr a source string - * @return the resulting string - */ - static String replaceGreekLetter(String testStr) - { - for (int i=0; i<GREEK_LETTER.length; ++i) - { - if (testStr.indexOf(GREEK_LETTER[i]) >= 0) - testStr = testStr.replaceAll(GREEK_LETTER[i], GREEK_ENTITY[i]); - } - - return testStr; - } - - /** - * Converts to a string representing the xml data in this configuration - * file. - */ - public String convertToString() throws Exception - { - return getDtdSection() + "\n\n" + this.rootNode.toString(); - } - - /** - * Converts to a string representing the xml data in this configuration - * file plus the user exclusive section fom <code>userConfig</code>. - */ - public String convertToString(AConfig userConfig) throws Exception - { - if(!this.isCustomised && userConfig.isCustomised) - { - StringBuffer str = new StringBuffer("\n"); - for(int i=0; i<userConfig.userExclusiveNodeList.size(); ++i) - { - AConfigNode userExclusiveNode = (AConfigNode) userConfig.userExclusiveNodeList.get(i); - validateUserExclusiveNode(userExclusiveNode); - str.append(userExclusiveNode.toString()); - str.append("\n"); - } - return getDtdSection() + "\n\n" + this.rootNode.toString(str.toString()); - } - else - { - // only add user exclusive section to non-customized configuration - return toString(); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/config/AConfigNode.java b/graphics/AtlantisJava/src/atlantis/config/AConfigNode.java deleted file mode 100755 index 751ae988505664ed71488abf93ef865147bd4290..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/config/AConfigNode.java +++ /dev/null @@ -1,263 +0,0 @@ -package atlantis.config; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.jar.Attributes; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class AConfigNode -{ - private String nodeName; - - // use fullNodeName combined with keyValue to uniquely identify a parameter - // in the configuration file - // NB: keyValue is not empty only if attributes is not empty - private String fullNodeName; - private String keyValue = null; - - // Layer 0 represents the root node of the xml file, - // and layer 1 reprensents the layer inside layer 0, - // and so on. - private int layer; - - private Attributes attributes = null; - private ArrayList children = null; - private AConfigNode parent = null; - - // if parent is null, elementNode is the root node - AConfigNode(AConfigNode parent, Node elementNode, int layer, AConfig configObject) - { - // add this node into the node list - configObject.addNode(this); - this.layer = layer; - - // set the full name - this.parent = parent; - String parentName = (this.parent != null) ? this.parent.getFullNodeName() + "-" : ""; - this.nodeName = elementNode.getNodeName(); - if("ParameterDifferences".equals(this.nodeName) - || "WindowCorners".equals(this.nodeName)) - configObject.addUserExclusiveNode(this); - this.fullNodeName = parentName + this.nodeName; - - // set the attributes map - if(elementNode.hasAttributes()) - { - NamedNodeMap attMap = elementNode.getAttributes(); - int numAttributes = attMap.getLength(); - this.attributes = new Attributes(numAttributes); - for(int i=0; i<numAttributes; ++i) - { - // each node returned from item(i) is an Attr - String name = attMap.item(i).getNodeName(); - String value = attMap.item(i).getNodeValue(); - // replace special math operator characters with entity references - if("=".equals(value)) - value = "&intEqual;"; - else if(">".equals(value)) - value = ">"; - else if("<".equals(value)) - value = "<"; - else if("<,>".equals(value)) - value = "ℜ"; - else if("<=".equals(value)) - value = "≤"; - else if(">=".equals(value)) - value = "≥"; - else if("=,!=,<,<=,>,>=".equals(value)) - value = "∫"; - - // replace greek letters with entity references - value = AConfig.replaceGreekLetter(value); - - this.attributes.putValue(name, value); - } - } - - // set the key value - String keyAttr = (String) AConfig.keyMap.get(this.nodeName); - if(keyAttr != null) - { - String groupName = this.parent.getAttValue("name"); - this.keyValue = ((groupName == null) ? "" : (groupName + "-")) + this.attributes.getValue(keyAttr); - } - - // set the children list - if(elementNode.hasChildNodes()) - { - NodeList childList = elementNode.getChildNodes(); - int numChildren = childList.getLength()/2; - this.children = new ArrayList(numChildren); - int idx = 0; - for(int i=0; i<childList.getLength(); ++i) - { - // each node returned from item(i) is an Attr - Node childNode = childList.item(i); - if (childNode.getNodeType() == Node.ELEMENT_NODE) - { - this.children.add(idx++, new AConfigNode(this, childNode, this.layer+1, configObject)); - } - } - } - } - - /** - * @return Returns the nodeName. - */ - public String getNodeName() - { - return this.nodeName; - } - - /** - * @return Returns the fullNodeName. - */ - public String getFullNodeName() - { - return this.fullNodeName; - } - - /** - * @return Returns the parent. - */ - public AConfigNode getParent() - { - return this.parent; - } - - /** - * @return Returns the children. - */ - public List getChildren() - { - return this.children; - } - - /** - * @return Returns the keyValue. - */ - public String getKeyValue() - { - return this.keyValue; - } - - /** - * @return Returns the string value of the specified attribute name, - * or null if not found. - */ - public String getAttValue(String name) - { - if(this.attributes != null) - return this.attributes.getValue(name); - else - return null; - } - - public String setAttValue(String name, String value) - { - return this.attributes.putValue(name, value); - } - - // the start line of this xml node - // e.g. <Nodename att1="value1" att2="value2"> - private String selfStartString() - { - StringBuffer str = new StringBuffer(); - for(int i=0; i<this.layer; ++i) - { - str.append("\t"); - } - str.append("<"); - str.append(this.nodeName); - if(this.attributes != null) - { - Set attSet = this.attributes.keySet(); - Iterator it = attSet.iterator(); - while(it.hasNext()) - { - String attName = it.next().toString(); - String attValue = this.attributes.getValue(attName); - str.append(" "); - str.append(attName); - str.append("=\""); - str.append(attValue); - str.append("\""); - } - } - if(this.children == null) - { - str.append("/>"); - } - return str.toString(); - } - - private String selfEndString() - { - StringBuffer str = new StringBuffer(); - if(this.children == null) - { - // if no children, use simplified format (<.../>) - // so selfStartString contains everything about this node - return ""; - } - else - { - for(int i=0; i<this.layer; ++i) - { - str.append("\t"); - } - str.append("</"); - str.append(this.nodeName); - str.append(">"); - } - return str.toString(); - } - - private String childrenString() - { - StringBuffer str = new StringBuffer(); - if(this.children == null) - { - return ""; - } - else - { - str.append(">\n"); - for(int i=0; i<this.children.size(); ++i) - { - AConfigNode child = (AConfigNode) this.children.get(i); - str.append(child.toString()); - str.append("\n"); - } - } - return str.toString(); - } - - /** - * Converts to a string representing the xml data containing this node and - * all its children. - */ - public String toString() - { - return selfStartString()+childrenString()+selfEndString(); - } - - // userExclusiveSection is noly under root node (layer 0) - public String toString(String userExclusiveSection) - { - if(this.layer == 0) - { - return selfStartString()+childrenString()+userExclusiveSection+selfEndString(); - } - else - { - return toString(); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/config/AConfigUpdater.java b/graphics/AtlantisJava/src/atlantis/config/AConfigUpdater.java deleted file mode 100644 index ee87efb78bcd3723b7463e77976caf13621e038e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/config/AConfigUpdater.java +++ /dev/null @@ -1,405 +0,0 @@ -package atlantis.config; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStream; -import java.io.InputStream; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import java.util.Iterator; - -import atlantis.utils.AUtilities; -import atlantis.utils.AAtlantisException; -import atlantis.utils.ALogger; - - - -/** - * This class encapsulates a few static methods which ensure updating - * of the user's customised Atlantis configuration (or special Atlantis - * configurations) according to the base Atlantis configuration file - * configuration/config.xml - * - * Updating means synchronising special / customised configurations if - * XML elements were added/removed from the base configuration file while - * keeping unchanged specially defined user cuts, views, projections, etc. - * - * Methods in this class are also called by an external configuration - * synchronization tool, so methods should remain static, special treatment - * of logger, etc. - * - * @author - * Zdenek Maxa - initial update mechanism, creating this extra class, refactoring - * Qiang Lu - improved reliable updating mechanism as done in AConfig - * - */ -public final class AConfigUpdater -{ - // when AConfigUpdater is called from Atlantis code, logger would behave - // as configured there. If AConfigUpdater is called externally, logger - // should be initialised with default values from ALogger - private static ALogger logger = ALogger.getLogger(AConfigUpdater.class); - - - - - /** - * Methods creates checksum file (name in fileNameChk) of a given file - * (file name in fileName). - */ - public static void createChecksumFile(String fileName, String fileNameChk) - throws AAtlantisException - { - try - { - logger.debug("Creating checksum file " + fileNameChk + - " of a file " + fileName); - byte[] chk = calculateChecksum(fileName); - File fileChk = new File(fileNameChk); - OutputStream os = new FileOutputStream(fileChk); - os.write(chk); - os.close(); - } - catch(AAtlantisException ae) - { - String m = "Error while creating MD5 checksum file, reason: " + - ae.getMessage(); - throw new AAtlantisException(m); - } - catch(FileNotFoundException fnfe) - { - String m = "File not found exception: " + fnfe.getMessage(); - throw new AAtlantisException(m); - } - catch(IOException ioe) - { - String m = "I/O error while creating file " + fileNameChk; - throw new AAtlantisException(m); - } - - } // createChecksumFile() ----------------------------------------------- - - - - /** - * Calculates checksum of a file fileName. - */ - private static byte[] calculateChecksum(String fileName) - throws AAtlantisException - { - InputStream fis = null; - try - { - logger.debug("Calculating checksum of file: " + fileName); - fis = AUtilities.getFileAsStream(fileName); - } - catch(AAtlantisException ae) - { - throw ae; - } - - MessageDigest complete = null; - - try - { - byte[] buffer = new byte[1024]; - complete = MessageDigest.getInstance("MD5"); - int numRead; - do - { - numRead = fis.read(buffer); - if (numRead > 0) - { - complete.update(buffer, 0, numRead); - } - } while (numRead != -1); - - fis.close(); - } - catch(IOException ioe) - { - throw new AAtlantisException("Error while reading data from file " + - fileName); - } - catch(NoSuchAlgorithmException nsae) - { - throw new AAtlantisException(nsae.getMessage()); - } - - logger.debug("Checksum calculated."); - return complete.digest(); - - } // calculateChecksum() ------------------------------------------------ - - - - /** - * Method checks the checksum of input file fileName if its checksum matches - * checksum stored in the checksum file fileNameChk. - * Return true if matches, false otherwise. - */ - public static boolean compareChecksums(String fileName, String fileNameChk) - throws AAtlantisException - { - boolean result = false; - try - { - // checksum of the input file - byte[] inputFileChecksum = calculateChecksum(fileName); - // checksum to read stored checksum from file fileNameChk - // assume the lenght is the same as of the input data file - byte[] storedChecksum = new byte[inputFileChecksum.length]; - File fileChk = new File(fileNameChk); - InputStream is = new FileInputStream(fileChk); - is.read(storedChecksum); - - // compare both checksums - if(new String(storedChecksum).equals(new String(inputFileChecksum))) - { - result = true; - } - else - { - result = false; - } - - is.close(); - } - catch(Exception e) - { - String m = "Error while checking MD5 checksum file, reason: " + - e.getMessage(); - throw new AAtlantisException(m); - } - - return result; - - } // compareChecksums() ------------------------------------------------- - - - - /** - * @param distConfig - configuration instance from Atlantis distribution - * (master copy) - * @param userConfig - user's customised or special configuration which - * gets updated according to distribution configuration - */ - private static void updateConfiguration(AConfig distConfig, AConfig userConfig) - { - logger.debug("Updating customised configuration ..."); - Iterator distIt = distConfig.getIterator(); - while(distIt.hasNext()) - { - // For each key node (keyValue is not empty) inside distConfig, - // test if there is a same node in userConfig. - AConfigNode testDistNode = (AConfigNode) distIt.next(); - if(testDistNode.getKeyValue() != null) - { - AConfigNode matchUserNode = userConfig.find(testDistNode); - if(matchUserNode != null) - { - // update testDistNode based on matchUserNode - updateNode(distConfig, testDistNode, matchUserNode); - } - } - } - - logger.debug("Update finished."); - - } // updateConfiguration() ---------------------------------------------- - - - - /** - * Update a node from configuration. - */ - private static void updateNode(AConfig distConfig, - AConfigNode distNode, AConfigNode userNode) - { - String[] attStrArray = null; - if("Canvas".equals(distNode.getNodeName())) - { - attStrArray = AConfig.CANVAS_ATT; - } - else if("UsedWindow".equals(distNode.getNodeName())) - { - attStrArray = AConfig.WINDOW_ATT; - } - else if("Layout".equals(distNode.getNodeName())) - { - attStrArray = AConfig.LAYOUT_ATT; - } - else - { - //check the parent Group values - if(distNode.getParent().getNodeName().equals("Group")){ - attStrArray = AConfig.GROUP_ATT; - //update the value - for(int i = 0; i < attStrArray.length; ++i) - { - String att = attStrArray[i]; - String distValue = distNode.getParent().getAttValue(att); - String userValue = userNode.getParent().getAttValue(att); - - if(distValue != null && userValue != null && !distValue.equals(userValue)) - { - if(distConfig.validate(distNode.getParent(), att, userValue)) - { - distNode.getParent().setAttValue(att, userValue); - } - } - } - } - - //now update parameters inside the Group - attStrArray = AConfig.PAR_ATT; - } - - // update the value - for(int i = 0; i < attStrArray.length; ++i) - { - String att = attStrArray[i]; - String distValue = distNode.getAttValue(att); - String userValue = userNode.getAttValue(att); - if(distValue != null && userValue != null && !distValue.equals(userValue)) - { - if(distConfig.validate(distNode, att, userValue)) - { - distNode.setAttValue(att, userValue); - } - } - } - - } // updateNode() ------------------------------------------------------- - - - - private static void writeUpdatedConfigurationFile(AConfig distConfig, - AConfig userConfig, - String filename) - throws Exception - { - FileOutputStream fo = null; - fo = new FileOutputStream(filename); - String updatedConfiguration = distConfig.convertToString(userConfig); - fo.write(updatedConfiguration.getBytes()); - fo.close(); - - } // writeUpdatedConfigurationFile() ------------------------------------ - - - - /** - * Updates customised configuration file to be consistent with the - * distribution configuration file. - * @param fileNameDist - distribution configuration file path - * @param fileNameCustom - customised configuration file path - * @throws AAException - */ - public static void updateConfigurationFile(String fileNameDist, - String fileNameCustom) - throws AAtlantisException - { - - logger.info("Updating configuration - master " + - "configuration: " + fileNameDist); - logger.info("Updating configuration - customised (being updated) " + - "configuration: " + fileNameCustom); - - AConfig distConfig = null; - AConfig customConfig = null; - - // read master (distribution) and customised configurations - try - { - distConfig = new AConfig(fileNameDist, false); // false - is not customised - } - catch(Exception e) - { - // these however seem to be never thrown because of AXMLErrorHandler - // in AConfig - String m = "Could not read/parse distribution configuration " + - fileNameDist + " reason: " + e.getMessage(); - throw new AAtlantisException(m); - } - - try - { - customConfig = new AConfig(fileNameCustom, true); // true - is customised - } - catch(Exception e) - { - // these however seem to be never thrown because of AXMLErrorHandler - // in AConfig - String m = "Could not read/parse customised configuration " + - fileNameCustom + " reason: " + e.getMessage(); - throw new AAtlantisException(m); - } - - - // actual update - try - { - updateConfiguration(distConfig, customConfig); - } - catch(Throwable t) - { - String m = "Updating customised configuration failed, reason: " + - t.getMessage(); - logger.debug(m, t); - throw new AAtlantisException(m); - } - - - // write updated data, first create backup of the source file - - logger.info("Creating backup of the customised configuration file ..."); - // file name to backup (rename) the file to - String fileNameUserBackup = fileNameCustom + "-backup_on_" + - AUtilities.getDateTimeString(); - File fileCustom = new File(fileNameCustom); - File fileBackup = new File(fileNameUserBackup); - boolean renameResult = fileCustom.renameTo(fileBackup); - if(! renameResult) - { - String m = "Could not backup customised configuration " + - "file, updating configuration failed."; - - // if fileNameDist path starts with "//", then it is run from within - // JAR archive via webstart. update process can't be performed in this - // case - can't create a backup copy of the fileNameCustom (and can't - // create an updated file when all is packed in a single JAR file either) - if(fileNameDist.startsWith("//")) - { - m += " Running via webstart, update can't be perfomed in this mode."; - } - throw new AAtlantisException(m); - } - logger.info(fileNameCustom + " backup created: " + fileNameUserBackup); - - - try - { - writeUpdatedConfigurationFile(distConfig, customConfig, - fileNameCustom); - } - catch(Throwable t) - { - String m = "Saving updated customised configuration into file " + - "failed, reason: " + t.getMessage(); - logger.debug(m, t); - throw new AAtlantisException(m); - } - - - logger.info(fileNameCustom + " configuration was successfully updated."); - - } // updateConfigurationFile() ------------------------------------------ - - -} // class AConfigUpdater =================================================== \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/config/ADefaultValues.java b/graphics/AtlantisJava/src/atlantis/config/ADefaultValues.java deleted file mode 100755 index b2e764499cd2bed428170c5679a81b2c81a8d034..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/config/ADefaultValues.java +++ /dev/null @@ -1,206 +0,0 @@ -package atlantis.config; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.io.FileReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Hashtable; -import java.util.Enumeration; -import java.util.regex.Pattern; -import java.util.regex.Matcher; - -import atlantis.globals.AGlobals; -import atlantis.utils.ALogger; - -/** - * The class maintains a few values which are to be remembered - * from session to session. The class tries to read in values from runtime - * configuration file $HOME/.Atlantis-runtime_values.txt. The values are - * stored in a Hashtable and are used as default initialize values. This - * Hashtable is updated whenever user changes these values. Values are - * into file at the end of Atlantis session. - * - * TODO: - * last used geometry (will be simpler when TB mode (and Atlantis.mode in - * general is discontinued), geometry names will be considered - * after '_' up to the file extension (.xml) - * last event file - * - * @author Zdenek Maxa - */ -public class ADefaultValues -{ - // file where the cross-session runtime values are stored - public static final String CONFIGFILE = System.getProperty("user.home") + - System.getProperty("file.separator") + - ".Atlantis-runtime_values.txt"; - // main attribute which holds all data - private static Hashtable v = new Hashtable(); - - private static ALogger logger = ALogger.getLogger(ADefaultValues.class); - - private ADefaultValues() {} - - - - /** - * Variables controled by this class and their default values if the - * runtime config does not exist or if some values are missing in the file. - */ - private static void setDefaultValues() - { - String FILE_SEPAR = System.getProperty("file.separator"); - String homeDirectory = AGlobals.instance().getHomeDirectory(); - v.put("LastEventFilesSourceDir", homeDirectory + "events" + FILE_SEPAR); - v.put("LastEventFilesSaveDir", homeDirectory); - v.put("LastCanvasPlotSaveDir", homeDirectory); - v.put("JiveXMLServerName", ""); - v.put("JiveXMLServerPort", "48965"); - v.put("GeometryName", ""); - - } // setDefaultValues() ------------------------------------------------- - - - - private static Hashtable readRuntimeConfigFile() - { - Hashtable helpTable = null; - String line = null; - String[] l = null; - String patternLine = ".*=.*"; - Pattern pattern = Pattern.compile(patternLine); - - try - { - BufferedReader in = new BufferedReader(new FileReader(CONFIGFILE)); - helpTable = new Hashtable(); - logger.info("Atlantis runtime configuration file: " + CONFIGFILE); - - while((line = in.readLine()) != null) - { - Matcher matcher = pattern.matcher(line); - if(matcher.matches()) - { - l = line.split("="); - if(l != null && l.length == 2) - { - logger.debug("Configuration value: " + - l[0] + " : " + l[1] + " read in"); - - // remove quotes - l[1] = l[1].replaceAll("\"", ""); - helpTable.put(l[0].trim(), l[1].trim()); - } - else - { - logger.warn("Line: " + line + " from runtime " + - "configuration file: " + CONFIGFILE + - " does not match, line is ignored"); - } - } - } // while - - // file is successfully read in a helper Hash table - in.close(); - - return helpTable; - - } // try - catch(FileNotFoundException ex) - { - logger.warn("Runtime configuration file: " + CONFIGFILE + - " not found, using default runtime values"); - } - catch(IOException ex) - { - logger.error("I/O error while reading " + CONFIGFILE + - " file, using default runtime values"); - } - - return null; - - } // readRuntimeConfigFile() -------------------------------------------- - - - - public static void readRuntimeValues() - { - setDefaultValues(); - Hashtable help = readRuntimeConfigFile(); - if(help != null) - { - for(Enumeration e = v.keys() ; e.hasMoreElements() ;) - { - String s = (String) e.nextElement(); - if(help.containsKey(s)) - { - // keys match, update the value - v.remove(s); - v.put(s, help.get(s)); - } - } - } - - } // readRuntimeValues() ------------------------------------------------ - - - - public static void saveRuntimeValues() - { - try - { - // if exists, shall be overwritten - BufferedWriter out = new BufferedWriter(new FileWriter(CONFIGFILE)); - - for(Enumeration e = v.keys() ; e.hasMoreElements() ;) - { - String s = (String) e.nextElement(); - out.write(s + " = \"" + v.get(s) + "\"\n"); - } - out.close(); - } - catch(IOException ex) - { - logger.error("Can't open " + CONFIGFILE + " for writing, runtime " + - "configuration values not saved"); - } - - } // saveRuntimeValues() ------------------------------------------------ - - - - public static String get(String key) - { - if(v.containsKey(key)) - { - return(String) v.get(key); - } - else - { - logger.warn("Runtime configuration value: " + key + " does not exist", new Exception()); - return null; - } - - } // get() -------------------------------------------------------------- - - - - public static void set(String key, String value) - { - if(v.containsKey(key)) - { - v.remove(key); - v.put(key, value); - } - else - { - logger.warn("Runtime configuration value: " + key + " does not exist", new Exception()); - } - - } // set() -------------------------------------------------------------- - - - -} // class ADefaultValues =================================================== diff --git a/graphics/AtlantisJava/src/atlantis/config/package.html b/graphics/AtlantisJava/src/atlantis/config/package.html deleted file mode 100644 index 96bd70b4cacf27b711bac576fffc0029c639f737..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/config/package.html +++ /dev/null @@ -1,6 +0,0 @@ -<html> -<head></head> -<body> -<p>Classes for handling the configuration file and its contents.</p> -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/data/A3DPointData.java b/graphics/AtlantisJava/src/atlantis/data/A3DPointData.java deleted file mode 100755 index b4354b3e564f3a797a189848c3d5b954e84a23b9..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/A3DPointData.java +++ /dev/null @@ -1,254 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.graphics.ACoord; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.*; -import atlantis.utils.*; - - -public abstract class A3DPointData extends AHitData { - - protected float[] rho; - protected float[] phi; - protected float[] z; - protected float[] x; - protected float[] y; - - - A3DPointData(AHashMap p, AEvent e) { - super(p,e); - if(p.get("x")!=null) { - x=p.getFloatArray("x"); - y=p.getFloatArray("y"); - z=p.getFloatArray("z"); - rho=new float[numData]; - phi=new float[numData]; - - // this is needed for the moment so that S3D sub and layer can be - // calculated from rph,phi,z rho phi from x y - for(int i=0; i<rho.length; ++i) { - double dx=x[i]; - double dy=y[i]; - - rho[i]=(float)(Math.sqrt(dx*dx+dy*dy)); - phi[i]=(float)(Math.atan2(dy, dx)); - if(phi[i]<0.) phi[i]+=AMath.TWO_PI; - } - } else { - rho=p.getFloatArray("rho"); - phi=p.getFloatArray("phi"); - z=p.getFloatArray("z"); - x=new float[numData]; - y=new float[numData]; - calculateXY(rho, phi, x, y); - } - } - - - public float[] getRho() - { - return rho; - } - - - public float[] getPhi() - { - return phi; - } - - - public float[] getX() - { - return x; - } - - - public float[] getY() - { - return y; - } - - - public float[] getZ() - { - return z; - } - - - protected void calculateRhoPhi() - { - calculateRhoPhi(x, y, rho, phi); - } - - protected ACoord getYXUser() { - makeDrawList(); - double[] h=new double[numDraw]; - double[] v=new double[numDraw]; - int[] index=new int[numDraw]; - - for(int i=0; i<numDraw; i++) { - int list=listdl[i]; - h[i]=x[list]; - v[i]=y[list]; - index[i]=list; - } - return new ACoord(h, v, index, this); - } - - protected ACoord getRZUser() { - makeDrawList(); - double[] h=new double[numDraw]; - double[] v=new double[numDraw]; - int[] index=new int[numDraw]; - - double phiMid=Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - if(phiMid>AMath.TWO_PI) phiMid-=AMath.TWO_PI; - - for(int i=0; i<numDraw; i++) { - int list=listdl[i]; - h[i]=z[list]; - double phiDiff=Math.abs(phi[list]-phiMid); - if(phiDiff<Math.PI/2.||phiDiff>3*Math.PI/2.) - { - v[i] = rho[list]; - } - else - { - v[i] = -rho[list]; - } - index[i]=list; - - } - return new ACoord(h, v, index, this); - } - - protected ACoord getXZUser() { - makeDrawList(); - double[] h=new double[numDraw]; - double[] v=new double[numDraw]; - int[] index=new int[numDraw]; - - double phi0=Math.toRadians(AProjectionXZ.getPhi()); - double cosPhi0=Math.cos(phi0); - double sinPhi0=Math.sin(phi0); - - for(int i=0; i<numDraw; i++) { - int list=listdl[i]; - h[i]=z[list]; - v[i]=x[list]*cosPhi0+y[list]*sinPhi0; - index[i]=list; - } - return new ACoord(h, v, index, this); - } - - protected ACoord getYZUser() { - makeDrawList(); - double[] h=new double[numDraw]; - double[] v=new double[numDraw]; - int[] index=new int[numDraw]; - - double phi0=Math.toRadians(AProjectionXZ.getPhi()); - double cosPhi0=Math.cos(phi0); - double sinPhi0=Math.sin(phi0); - - for(int i=0; i<numDraw; i++) { - int list=listdl[i]; - h[i]=z[list]; - v[i]=y[list]*cosPhi0-x[list]*sinPhi0; - index[i]=list; - } - return new ACoord(h, v, index, this); - } - - protected ACoord get3DUser() { - makeDrawList(); - double[][] hvo=AProjection3D.getRotated(numDraw, listdl, x, y, z); - double[] h=hvo[0]; - double[] v=hvo[1]; - int[] index=new int[numDraw]; - for(int i=0; i<numDraw; i++) { - int list=listdl[i]; - index[i]=list; - } - return new ACoord(h, v, index, this); - } - -// does not fit in normal scheme - public double[][] get3DPoints() { - makeDrawList(); - double[][] xyz =new double[numDraw][3]; - for(int i=0; i<numDraw; i++) { - int list=listdl[i]; - xyz[i][0]=x[list]; - xyz[i][1]=y[list]; - xyz[i][2]=z[list]; - } - return xyz; - } - -// does not fit in normal scheme - public int[] get3DPointsIndex() { - makeDrawList(); - int[] index=new int[numDraw]; - for(int i=0; i<numDraw; i++) - index[i]=listdl[i]; - return index; - } - - protected ACoord getFZUser() { - makeDrawList(); - double[] h=new double[numDraw]; - double[] v=new double[numDraw]; - int[] index=new int[numDraw]; - - for(int i=0; i<numDraw; i++) { - int list=listdl[i]; - h[i]=z[list]; - v[i]=Math.toDegrees(phi[list]); - index[i]=list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("FZ"); - } - - protected ACoord getFRUser() { - makeDrawList(); - double[] h=new double[numDraw]; - double[] v=new double[numDraw]; - int[] index=new int[numDraw]; - - for(int i=0; i<numDraw; i++) { - int list=listdl[i]; - h[i]=rho[list]; - v[i]=Math.toDegrees(phi[list]); - index[i]=list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("FR"); - } - - protected ACoord getVPUser() { - makeDrawList(); - // each point is drawn twice - int numTotal=2*numDraw; - double[] h=new double[numTotal]; - double[] v=new double[numTotal]; - int[] index=new int[numTotal]; - - double[] sign=new double[] {-1., 1.}; - int num=0; - - for(int i=0; i<numDraw; i++) { - int list=listdl[i]; - double eta=AParameterUtilities.eta(z[list], rho[list]); - double delEta=AProjectionVP.getDeltaEta(rho[list], z[list]); - for(int j=0; j<2; j++) { - h[num]=eta+sign[j]*delEta; - v[num]=AParameterUtilities.phi(x[list], y[list]); - index[num]=list; - num++; - } - } - return new ACoord(h, v, index, this).includePhiWrapAround("VP"); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AAODData.java b/graphics/AtlantisJava/src/atlantis/data/AAODData.java deleted file mode 100644 index 8c412fd11398eba62070ac531a4ff2dc0c14bb9c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AAODData.java +++ /dev/null @@ -1,359 +0,0 @@ -package atlantis.data; - -import atlantis.event.AData; -import atlantis.event.*; -import java.util.Vector; - -import atlantis.canvas.AWindow; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionVP; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - -public abstract class AAODData extends AData -{ - protected float[] eta; - protected float[] phi; - protected float[] pT; - - AAODData(AHashMap p, AEvent e) - { - super(p,e); - eta = p.getFloatArray("eta"); - phi = p.getFloatArray("phi"); - pT = p.getFloatArray("pt"); - int[] pdgId = p.getUnsureIntArray("pdgId"); - if(pdgId != null) - { - for(int i=0; i<pT.length; i++) - pT[i] *= -AMath.getSign(pdgId[i]); - } - - if (p.get("clusterKey") != null) - { - int[] clusterLinkCount = p.getUnsureIntArray("clusterLinkCount"); - event.getAssociationManager().add(new AObjectsAssociation(getFullName(), "Cluster", - p.getStringArray("clusterKey"), p.getIntArray("clusterIndex"), clusterLinkCount, event)); - } - if (p.get("trackKey") != null) - { - int[] trackLinkCount = p.getUnsureIntArray("trackLinkCount"); - event.getAssociationManager().add(new AObjectsAssociation(getFullName(), "Track", - p.getStringArray("trackKey"), p.getIntArray("trackIndex"), trackLinkCount, event)); - } - } - - - public float getEta(int index) - { - return eta[index]; - } - - - public float getPhi(int index) - { - return phi[index]; - } - - - public float getPT(int index) - { - return pT[index]; - } - - - public float[] getEta() - { - return eta; - } - - - public float[] getPhi() - { - return phi; - } - - - public float[] getPT() - { - return pT; - } - - - protected int internalColor() - { - int colorFunction=parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - if(colorFunction==0) - colorByConstant(); - else if(colorFunction==1) - colorByIndex(); - - return 1; - } - - public String getNameScreenName() - { - return getParameterGroup(); - } - - protected int getDrawOrFill() - { - return AGraphics.FILL; - } - - protected void applyCuts() - { - cutIndex(); - cutPhi(phi); - cutEta(eta); - } - - // info on AOD data contained in V-Plot rubberband selection - public String getVPHitInfo() - { - makeDrawList(); - if (numDraw == 0) - return ""; - double sumP = 0.; - double sumPt = 0.; - - for (int i = 0; i < numDraw; ++i) - { - sumPt += Math.abs(pT[listdl[i]]); - sumP += Math.abs(pT[listdl[i]] / Math.cos(AMath.lambda(eta[listdl[i]]))); - } - - StringBuffer msg = new StringBuffer(""); - msg.append(numDraw); - msg.append(" "); - msg.append(getFullName()); - msg.append(" sum(PT) = "); - msg.append(String.format("%.1f", sumPt)); - msg.append(" sum(P) = "); - msg.append(String.format("%.1f",sumP)); - - return msg.toString(); - } - - public void draw(AWindow window, AGraphics ag, AProjection2D projection) - { - if(projection instanceof AProjectionVP) - { - drawVP(window, ag, projection); - } - else - { - super.draw(window, ag, projection); - } - } - - protected ACoord getYXUser() - { - makeDrawList(); - double[][][] hv = new double[2][numDraw][4]; - int[] index = new int[numDraw]; - - double dphi = Math.toRadians(0.5); - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - double phiPlus = phi[list] + dphi; - double phiMinus = phi[list] - dphi; - double cosPlus = Math.cos(phiPlus); - double sinPlus = Math.sin(phiPlus); - double cosMinus = Math.cos(phiMinus); - double sinMinus = Math.sin(phiMinus); - //same rhoMax/Minus values used in AJetData - double rhoMax = 1200; - double rhoMinus = 400; - //if no composite particles increase AOD size - Vector<String> keys = event.getCollections().get("CompositeParticle"); - if(keys == null || !parameterStore.get("Data", "CompositeParticle").getStatus()) - rhoMax=1200; - else if(PARAMETER_GROUP.equals("CompositeParticle")) - { - // display composite particle outside of normal AOD data - rhoMax=1200; - rhoMinus=800; - } - - double maxEnergy = parameterStore.get("Projection", "EnergyMax").getD(); - double rhoPlus = rhoMax; - double s = 10; - if(Math.abs(pT[list]) < maxEnergy) - rhoPlus = rhoMinus + (rhoMax - rhoMinus) * s *Math.abs(pT[list]) / maxEnergy; - - // 4 corners of the cell area - // x0, y0 - hv[0][i][0] = rhoMinus * cosPlus; - hv[1][i][0] = rhoMinus * sinPlus; - // x1, y1 - hv[0][i][1] = rhoPlus * cosPlus; - hv[1][i][1] = rhoPlus * sinPlus; - // x2, y2 - hv[0][i][2] = rhoPlus * cosMinus; - hv[1][i][2] = rhoPlus * sinMinus; - // x3, y3 - hv[0][i][3] = rhoMinus * cosMinus; - hv[1][i][3] = rhoMinus * sinMinus; - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYGONS); - } - - protected ACoord getFRUser() - { - ACoord coordFR = getYXUser().convertYXToFR().includePhiWrapAround("FR"); - return coordFR; - } - - protected ACoord getRZUser() - { - makeDrawList(); - double[][][] hv = new double[2][numDraw][4]; - int[] index = new int[numDraw]; - - double dtheta = Math.toRadians(0.5); - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(phi[list]-phiMid); - double rSign; - if (phiDiff > Math.PI/2. && phiDiff <= 3*Math.PI/2.) - rSign = -1; - else - rSign = 1; - - // calculate theta based on the eta value - double theta = Math.atan(Math.exp(-Math.abs(eta[list]))) * 2.0; - if ((eta[list] > 0.) && (rSign == -1)) - theta = 2 * Math.PI - theta; - else if ((eta[list] < 0.) && (rSign == -1)) - theta += Math.PI; - else if ((eta[list] < 0.) && (rSign == 1)) - theta = Math.PI - theta; - - double thetaPlus = theta + dtheta; - double thetaMinus = theta - dtheta; - double cosPlus = Math.cos(thetaPlus); - double sinPlus = Math.sin(thetaPlus); - double cosMinus = Math.cos(thetaMinus); - double sinMinus = Math.sin(thetaMinus); - - // decide the region based on the theta value - final byte TOP_BOTTOM = 0; - final byte LEFT_RIGHT = 1; - byte region = TOP_BOTTOM; - // hard-coded value is based on the values in Geometry - if(Math.abs(Math.tan(theta)) < 0.8) - region = LEFT_RIGHT; - - double radiusMinus = 0.; - switch(region) - { - case TOP_BOTTOM: - if(PARAMETER_GROUP.equals("CompositeParticle")) - radiusMinus = 750 / Math.abs(Math.sin(theta)); - else - radiusMinus = 550 / Math.abs(Math.sin(theta)); - break; - case LEFT_RIGHT: - if(PARAMETER_GROUP.equals("CompositeParticle")) - radiusMinus = 850 / Math.abs(Math.cos(theta)); - else - radiusMinus = 700 / Math.abs(Math.cos(theta)); - break; - } - //same rhoMax/Minus values used in AJetData - double radiusMax = radiusMinus + 500; - //if no composite particles increase AOD size - Vector keys = (Vector) event.getCollections().get("CompositeParticle"); - if(keys == null || !parameterStore.get("Data", "CompositeParticle").getStatus()) - radiusMax+=200; - double maxEnergy = parameterStore.get("Projection", "EnergyMax").getD(); - double radiusPlus = radiusMax; - double s = 10; - if(Math.abs(pT[list]) < maxEnergy) - radiusPlus = radiusMinus + (radiusMax - radiusMinus) * s * Math.abs(pT[list]) / maxEnergy; - - // 4 corners of the cell area - // x0, y0 - hv[0][i][0] = radiusMinus * cosPlus; - hv[1][i][0] = radiusMinus * sinPlus; - // x1, y1 - hv[0][i][1] = radiusPlus * cosPlus; - hv[1][i][1] = radiusPlus * sinPlus; - // x2, y2 - hv[0][i][2] = radiusPlus * cosMinus; - hv[1][i][2] = radiusPlus * sinMinus; - // x3, y3 - hv[0][i][3] = radiusMinus * cosMinus; - hv[1][i][3] = radiusMinus * sinMinus; - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYGONS); - } - - protected ACoord getVPUser() - { - makeDrawList(); - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index=new int[numDraw]; - - for(int i=0; i<numDraw; i++) - { - int list=listdl[i]; - h[i]=eta[list]; - v[i]=Math.toDegrees(phi[list]); - index[i]=list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("VP"); - } - - private void drawVP(AWindow window, AGraphics ag, AProjection2D projection) - { - ACoord centers = window.calculateDisplay(getUser(projection)); - int[] drawlist = centers.index; - double eLimit = 0.025; - int numPoints = 25; - if(PARAMETER_GROUP.equals("CompositeParticle")) - numPoints = 5; - double[][][] hv = new double[2][drawlist.length][numPoints]; //circle - // a cross at centre - double[][][] hv_cross1 = new double[2][drawlist.length][2]; - double[][][] hv_cross2 = new double[2][drawlist.length][2]; - int crossLength = 6; - - for(int i=0; i<drawlist.length; ++i) - { - int list = drawlist[i]; - double e; - e = Math.abs(pT[list]); - int d = (int)(Math.sqrt((e/eLimit)/Math.PI)); - if(d == 0) d = 1; - for(int j=0; j<numPoints; j++) - { - hv[0][i][j]=centers.hv[0][0][i]+d*Math.cos(Math.PI*2*j/(numPoints-1)); - hv[1][i][j]=centers.hv[1][0][i]+d*Math.sin(Math.PI*2*j/(numPoints-1)); - } - for(int j=0; j<2; j++) - { - hv_cross1[0][i][j]=centers.hv[0][0][i]+crossLength/2*Math.cos(Math.PI*(1+4*j)/4); - hv_cross1[1][i][j]=centers.hv[1][0][i]+crossLength/2*Math.sin(Math.PI*(1+4*j)/4); - hv_cross2[0][i][j]=centers.hv[0][0][i]+crossLength/2*Math.cos(Math.PI*(3+4*j)/4); - hv_cross2[1][i][j]=centers.hv[1][0][i]+crossLength/2*Math.sin(Math.PI*(3+4*j)/4); - } - } - ag.draw(new ACoord(hv, drawlist, this, ACoord.POLYLINES)); - ag.draw(new ACoord(hv_cross1, drawlist, this, ACoord.POLYLINES)); - ag.draw(new ACoord(hv_cross2, drawlist, this, ACoord.POLYLINES)); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ABJetData.java b/graphics/AtlantisJava/src/atlantis/data/ABJetData.java deleted file mode 100755 index 7c047a26efa95e7928e03b5903b05ba7db29419f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ABJetData.java +++ /dev/null @@ -1,134 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; -import atlantis.utils.A3Vector; -import atlantis.utils.A4Vector; - -/** - * Reconstructed B-Jet - */ -public class ABJetData extends AAODData -{ - private float[] lhSig; - private float[] weight; - private String[] label; - private float[] mass; - //Variable to ensure backwards compatability - protected boolean has4Vect = false; - - ABJetData(AHashMap p, AEvent e) - { - super(p,e); - lhSig=p.getFloatArray("lhSig"); - weight=p.getFloatArray("weight"); - label=p.getUnsureStringArray("label"); - if (p.get("mass") != null) { - mass=p.getFloatArray("mass"); - has4Vect = true; - } - } - - public String getParameterGroup() - { - return "BJet"; - } - - public float getweight(int index) - { - return weight[index]; - } - - public float getlhSig(int index) - { - return lhSig[index]; - } - - public String getLabel(int index) - { - return label[index]; - } - - public A4Vector get4Vector(int num, int[] list) - { - A4Vector sum = new A4Vector(); - if(has4Vect){ - for (int i = 0; i < num; ++i) - { - int k = list[i]; - A4Vector start = new A4Vector(); - start.setPtEtaPhiM(pT[k],eta[k],phi[k],mass[k]); - sum.add(start); - } - }else{ - for (int i = 0; i < num; ++i) - { - int k = list[i]; - A3Vector start = A3Vector.fromRhoPhiZ(0., 0., 0.); - double tL = AMath.tanLambda(eta[k]); - A3Vector stop = A3Vector.fromRhoPhiZ(1., phi[k], tL); - A3Vector v = (stop.subtract(start)).normalize(); - double p = pT[k] / Math.sqrt(1. - v.z * v.z); - sum.add(new A4Vector(v.scale(p), 0.)); - } - } - return sum; - } - - - protected void applyCuts() - { - super.applyCuts(); - cut("CutsObjects", "BJetPt", " |ET|", pT); - cut("CutsObjects", "BJetlhSig", " |lhSig|", lhSig); - cut("CutsObjects", "BJetweight", " |weight|", weight); - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n PT="+String.format("%.3f",pT[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",phi[index])+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Px="+String.format("%.3f",pT[index]*Math.cos(phi[index]))+" GeV "+ - "\n Py="+String.format("%.3f",pT[index]*Math.sin(phi[index]))+" GeV "+ - "\n Pz="+String.format("%.3f",pT[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (id: " + id[index] + " index: " + index + ")"); - if(label != null) - { - msg.append("\n label = "); - msg.append(label[index]); - } - msg.append("\n PT = "); - msg.append(String.format("%.3f",pT[index])); - msg.append(" GeV\n P = "); - msg.append(String.format("%.3f",Math.abs(pT[index]/Math.cos(AMath.lambda(eta[index]))))); - msg.append(" GeV\n "); - msg.append(AMath.ETA); - msg.append(" = "); - msg.append(String.format("%.3f",eta[index])); - msg.append("\n "); - msg.append(AMath.PHI); - msg.append(" = "); - msg.append(String.format("%.3f",phi[index])); - msg.append(AMath.DEGREES); - msg.append(" (" + String.format("%.3f",phi[index]) + " rad)"); - msg.append("\n lhSig = "); - msg.append(lhSig[index]); - msg.append("\n weight = "); - msg.append(weight[index]); - - return msg.toString(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ACSCDData.java b/graphics/AtlantisJava/src/atlantis/data/ACSCDData.java deleted file mode 100755 index d724dfe7fc75a4d4af42dd257477295d9e02bbd9..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ACSCDData.java +++ /dev/null @@ -1,304 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.AIdHelper; -import atlantis.utils.ALogger; - -public class ACSCDData extends AMuonHitData -{ - private static final double CSC_TILT_ANGLE = Math.toRadians(-11.59); - - float[] charge; - float[] length; - int[] gasGap; - - private static ALogger logger = ALogger.getLogger(ACSCDData.class); - - public String getParameterGroup() - { - return "CSC"; - } - - public String getName() - { - return "CSCD"; - } - - public String getNameScreenName() - { - return "CSC Digits"; - } - - ACSCDData(AHashMap p, AEvent e) - { - super(p,e); - - if (p.get("length") != null) { - length=p.getFloatArray("length"); - } else { - // If no length is given, just use an arbitrary minimum length - length = new float[numData]; - for (int i=0; i<numData; i++) - length[i] = 10.f; - } - - charge=p.getFloatArray("charge"); - - gasGap = new int[numData]; - for (int i=0; i<numData; i++) { - try { - gasGap[i] = AIdHelper.cscWireLayer(id[i]); - } catch (AAtlantisException aex) { - gasGap[i] = 0; - } - } - } - - protected int getStation(int index) - { - return 0; - } - - protected int getSub(int index) - { - try { - if (AIdHelper.stationEta(id[index]) < 0) { - return 0; - } else { - return 1; - } - - } catch (AAtlantisException e) { - logger.error("Problem decoding TGC identifier", e); - } - - return 0; - } - - public int getSector(int index) - { - try { - String stationName = AIdHelper.stationName(id[index]); - - if (stationName.charAt(2) == 'L') { - return 2 * (AIdHelper.stationPhi(id[index]) - 1); - } else { - return 2 * (AIdHelper.stationPhi(id[index]) - 1) + 1; - } - } catch (AAtlantisException e) { - logger.error("Problem decoding CSCD identifier", e); - } - - return 0; - } - - protected boolean getMeasuresPhi(int index) - { - try { - if (AIdHelper.cscMeasuresPhi(id[index]) == 1) { - return true; - } - } catch (AAtlantisException e) { - logger.error("Problem decoding CSCD identifier", e); - } - - return false; - } - - protected void applyCuts() - { - super.applyCuts(); - cut("CutsMuon", "Charge", " Charge", charge); - cutPhi(phi); - cutEta(rho, z); - } - - protected int getDrawOrFill() - { - return AGraphics.FILL; - } - - protected ACoord getYXUser() - { - makeDrawList(); - if (parameterStore.get("YX", "Mode").getI() != AProjectionYX.MODE_MDT_INNER) - return ACoord.NO_DATA; - - AParameter cscGasGap = parameterStore.get("YX", "CSCGasGap"); - if (cscGasGap.getStatus()) - cutArray(gasGap, cscGasGap.getI(), "CSC Gas Gap"); - - double[][][] hv = new double[2][numDraw][2]; - int index[] = new int[numDraw]; - - try { - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - index[i] = j; - - if (AIdHelper.cscMeasuresPhi(id[j]) == 1) { - double phi = Math.atan2(y[j], x[j]); - double rho = Math.sqrt(x[j]*x[j] + y[j]*y[j]); - double drho = length[j]/2.; - - hv[0][i][0] = (rho - Math.cos(CSC_TILT_ANGLE) * drho) * Math.cos(phi); - hv[1][i][0] = (rho - Math.cos(CSC_TILT_ANGLE) * drho) * Math.sin(phi); - hv[0][i][1] = (rho + Math.cos(CSC_TILT_ANGLE) * drho) * Math.cos(phi); - hv[1][i][1] = (rho + Math.cos(CSC_TILT_ANGLE) * drho) * Math.sin(phi); - } else { - double phi = Math.atan2(y[j], x[j]); - double rho = Math.sqrt(x[j]*x[j] + y[j]*y[j] + length[j]*length[j]/4.); - double dphi = Math.asin((length[j]/2.) / rho); - - hv[0][i][0] = rho * Math.cos(phi - dphi); - hv[1][i][0] = rho * Math.sin(phi - dphi); - hv[0][i][1] = rho * Math.cos(phi + dphi); - hv[1][i][1] = rho * Math.sin(phi + dphi); - } - } - - return new ACoord(hv, index, this); - } catch (AAtlantisException e) { - AOutput.append("Error decoding CSC identifier: " + e.getMessage(), ALogInterface.BAD_COMMAND); - return ACoord.NO_DATA; - } - } - - protected ACoord getFRUser() - { - return getYXUser().convertYXToFR().includePhiWrapAround("FR"); - } - - protected ACoord getXZRZUser(int sign[]) - { - double[][][] hv = new double[2][numDraw][]; - int index[] = new int[numDraw]; - - try { - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - index[i] = j; - - double rho = Math.sqrt(x[j]*x[j] + y[j]*y[j]); - - if (AIdHelper.cscMeasuresPhi(id[j]) == 1) { - double drho = length[j]/2.; - if(z[j] < 0){ - hv[0][i] = new double[] {z[j] - sign[i]*Math.sin(CSC_TILT_ANGLE) * drho, - z[j] + sign[i]*Math.sin(CSC_TILT_ANGLE) * drho }; - - hv[1][i] = new double[] { sign[i] * (rho + sign[i]*Math.cos(CSC_TILT_ANGLE) * drho), - sign[i] * (rho - sign[i]*Math.cos(CSC_TILT_ANGLE) * drho) }; - - }else{ - hv[0][i] = new double[] {z[j] - Math.sin(CSC_TILT_ANGLE) * drho, - z[j] + Math.sin(CSC_TILT_ANGLE) * drho }; - - - hv[1][i] = new double[] { sign[i] * (rho - Math.cos(CSC_TILT_ANGLE) * drho), - sign[i] * (rho + Math.cos(CSC_TILT_ANGLE) * drho) }; - } - - - - } else { - hv[0][i] = new double[] { z[j] }; - hv[1][i] = new double[] { sign[i] * rho }; - } - - } - - return new ACoord(hv, index, this); - } - catch (AAtlantisException e) { - AOutput.append("Error decoding CSC identifier: " + e.getMessage(), ALogInterface.BAD_COMMAND); - return ACoord.NO_DATA; - } - - } - - - - - protected ACoord getXZUser() { - makeDrawList(); - cutMuonSector(sector); - - int[] sign = new int[numDraw]; - int sect = (int) Math.round(parameterStore.get("XZ", "Phi").getD() / 22.5); - - for(int i=0; i<numDraw; i++) { - if (sector[listdl[i]] == sect) - sign[i] = 1; - else - sign[i] = -1; - } - - return getXZRZUser(sign); - } - - protected ACoord getRZUser() { - makeDrawList(); - - int[] sign = new int[numDraw]; - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - sign[i] = AParameterUtilities.getRhoSign(x[j], y[j]); - } - - return getXZRZUser(sign); - } - - protected ACoord getFZUser() - { - double[][][] hv = new double[2][numDraw][]; - int index[] = new int[numDraw]; - - try { - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - index[i] = j; - - double rho = Math.sqrt(x[j]*x[j] + y[j]*y[j]); - double phi = Math.toDegrees(Math.atan2(y[j], x[j])); - - if (AIdHelper.cscMeasuresPhi(id[j]) == 1) { - double drho = length[j]/2.; - - hv[0][i] = new double[] { z[j] - Math.sin(CSC_TILT_ANGLE) * drho, - z[j] + Math.sin(CSC_TILT_ANGLE) * drho }; - hv[1][i] = new double[] { phi, phi }; - } else { - double dphi = Math.toDegrees(Math.atan2(length[j]/2., rho)); - - hv[0][i] = new double[] { z[j], z[j] }; - hv[1][i] = new double[] { phi-dphi, phi+dphi }; - } - } - - return new ACoord(hv, index, this); - } catch (AAtlantisException e) { - AOutput.append("Error decoding CSCD identifier: " + e.getMessage(), ALogInterface.BAD_COMMAND); - return ACoord.NO_DATA; - } - } - - // only constant color possible for the strips - protected int internalColor() - { - int constantColor=parameterStore.get(PARAMETER_GROUP, "Strip").getI(); - for(int i=0; i<numData; i++) - color[i]=(byte)constantColor; - return 0; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ACSCData.java b/graphics/AtlantisJava/src/atlantis/data/ACSCData.java deleted file mode 100755 index 5149a5133bd3d52cbb6e3a3d21d006eec96de89d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ACSCData.java +++ /dev/null @@ -1,197 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.AIdHelper; -import atlantis.utils.ALogger; - -public class ACSCData extends AMuonHitData -{ - float[] sigma; - - private static ALogger logger = ALogger.getLogger(ACSCData.class); - - public String getParameterGroup() - { - return "CSC"; - } - - public String getName() - { - return "CSC"; - } - - public String getNameScreenName() - { - return "CSC"; - } - - ACSCData(AHashMap p, AEvent e) - { - super(p,e); - sigma=p.getFloatArray("sigma"); - } - - protected int getStation(int index) - { - return 0; - } - - protected int getSub(int index) - { - try { - if (AIdHelper.stationEta(id[index]) < 0) { - return 0; - } else { - return 1; - } - - } catch (AAtlantisException e) { - logger.error("Problem decoding TGC identifier", e); - } - - return 0; - } - - public int getSector(int index) - { - try { - String stationName = AIdHelper.stationName(id[index]); - - if (stationName.charAt(2) == 'L') { - return 2 * (AIdHelper.stationPhi(id[index]) - 1); - } else { - return 2 * (AIdHelper.stationPhi(id[index]) - 1) + 1; - } - } catch (AAtlantisException e) { - logger.error("Problem decoding CSC identifier", e); - } - - return 0; - } - - protected boolean getMeasuresPhi(int index) - { - try { - if (AIdHelper.cscMeasuresPhi(id[index]) == 1) { - return true; - } - } catch (AAtlantisException e) { - logger.error("Problem decoding CSC identifier", e); - } - - return false; - } - - protected void applyCuts() - { - super.applyCuts(); - cutPhi(phi); - cutEta(rho, z); - } - - protected ACoord getYXUser() - { - makeDrawList(); - int mode=parameterStore.get("YX", "Mode").getI(); - if(mode!=5) - numDraw=0; - - double[] h=new double[numDraw]; - double[] v=new double[numDraw]; - int[] index=new int[numDraw]; - - for(int i=0; i<numDraw; i++) - { - int list=listdl[i]; - h[i]=x[list]; - v[i]=y[list]; - index[i]=list; - } - return new ACoord(h, v, index, this); - } - - protected ACoord getXZRZUser(int[] sign) - { - int numPoints=2; - - double[][][] hv=new double[2][numDraw][numPoints]; - int[] index=new int[numDraw]; - - // space point resolution is 60um in rz and 5mm in rphi (due to no uniform b field) - // from muonTDR page 201 - // double dRho=0.254; - // double dZMax=1.25; - - double alpha=-11.59; - double sinAlphaCopy=Math.sin(Math.toRadians(alpha)); - double cosAlphaCopy=Math.cos(Math.toRadians(alpha)); - - for(int i=0; i<numDraw; i++) - { - int list=listdl[i]; - - double rMid=sign[i]*getSectorRho(sector[list], rho[list], phi[list]); - double zMid=z[list]; - // double dZ = 2. * dZMax * Math.min(charge[list] / (25. * 75000.), 0.9); - double dRho=sigma[list]; - - double sinAlpha=sinAlphaCopy; - double cosAlpha=cosAlphaCopy; - - if(zMid>0.) - cosAlpha*=-1.; - if(rMid<0.) - sinAlpha*=-1.; - - hv[0][i][0]=zMid-sinAlpha*dRho; - hv[0][i][1]=zMid+sinAlpha*dRho; - hv[1][i][0]=rMid+cosAlpha*dRho; - hv[1][i][1]=rMid-cosAlpha*dRho; - index[i]=list; - } - return new ACoord(hv, index, this, ACoord.POLYLINES); - } - - protected int getDrawOrFill() - { - return AGraphics.DRAW; - } - - protected ACoord getRZUser() - { - makeDrawList(); - int[] sign=new int[numDraw]; - double phiMid=Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - - for(int i=0; i<numDraw; i++) - { - double phiDiff=Math.abs(phi[listdl[i]]-phiMid); - - sign[i]=-1; - if(phiDiff<Math.PI/2.||phiDiff>3*Math.PI/2.) - sign[i]=1; - } - return getXZRZUser(sign); - } - - protected ACoord getXZUser() - { - makeDrawList(); - cutMuonSector(sector); - int[] sign=new int[numDraw]; - int sect=(int)Math.round(parameterStore.get("XZ", "Phi").getD() / 22.5); - - for(int i=0; i<numDraw; i++) - { - sign[i]=1; - if(sector[listdl[i]]!=sect) - sign[i]=-1; - } - return getXZRZUser(sign); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ACalorimeterData.java b/graphics/AtlantisJava/src/atlantis/data/ACalorimeterData.java deleted file mode 100644 index e82e3d4a07efb99304969748103bfd430b79a138..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ACalorimeterData.java +++ /dev/null @@ -1,2662 +0,0 @@ -package atlantis.data; - -import atlantis.event.AEvent; -import java.awt.Color; -import java.util.Vector; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.ADrawCalorimeterSummedEndcaps; -import atlantis.canvas.ALegendWindow; -import atlantis.canvas.AWindow; -import atlantis.event.AData; -import atlantis.geometry.ABarrelCalorimeterDetector; -import atlantis.geometry.ACalorimeterDetector; -import atlantis.geometry.AEndcapCalorimeterDetector; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.graphics.ADrawParameters; -import atlantis.graphics.ADrawnGraphics2D; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjection; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionYX; -import atlantis.utils.A4Vector; -import atlantis.utils.AHashMap; -import atlantis.utils.AIdHelper; -import atlantis.utils.AMath; -import atlantis.utils.APolygon; -import atlantis.utils.AAtlantisException; -import atlantis.utils.ALogger; - -/** - * The superclass of all the ATLAS calorimeters. Contains also methods for - * drawing groups of calorimeters together. Calorimeters can not be drawn - * individually due to coupling of energy scale and the standard v-plot picture. - * Each calorimeter also provides histograms. - * - * @author Eric Jansen - */ -public abstract class ACalorimeterData extends AHitData implements AHistogramData -{ - private static ALogger logger = ALogger.getLogger(ACalorimeterData.class); - - // Constants as defined in the configuration file. - // Energy mode options. - public static final int ENERGY_MODE_SUM_LIN = 0; - public static final int ENERGY_MODE_MAX_LIN = 1; - public static final int ENERGY_MODE_SUM_LOG = 2; - public static final int ENERGY_MODE_MAX_LOG = 3; - public static final int ENERGY_MODE_SUM_SQRT = 4; - public static final int ENERGY_MODE_MAX_SQRT = 5; - - // Energy calibration options. - public static final int ENERGY_CALIB_UNKNOWN = -1; - public static final int ENERGY_CALIB_OVERALL = 0; - public static final int ENERGY_CALIB_BY_TYPE = 1; - public static final int ENERGY_CALIB_BY_CALO = 2; - - // Color functions. - public static final int COLOR_FUNC_CONSTANT = 0; - public static final int COLOR_FUNC_SUBDET = 1; - public static final int COLOR_FUNC_CLUSTER = 2; - public static final int COLOR_FUNC_SAMPLING = 3; - public static final int COLOR_FUNC_ENERGY = 4; - public static final int COLOR_FUNC_JET = 5; - public static final int COLOR_FUNC_TYPE = 6; - public static final int COLOR_FUNC_TIME = 7; - - private static final float SCALE_FACTOR_VPLOT = 20; - - public String CALORIMETER_NAME; - - // Properties needed for the histograms. - protected double innerR; - protected double outerR; - protected double innerZ; - protected double outerZ; - protected double outerEta; - - protected double phiGranularity = 0.0; - protected double etaGranularity = 0.0; - protected AParameter histoScale; - - // This constant contains the highest phi or eta index for this data type. - // Its value determines the amount of memory that is allocated for certain - // data structures. - protected short MAX_HIT_INDEX = 512; - protected static final double NON_SCALING_FACTOR = 0.85; - - protected float[] phi; - protected float[] eta; - protected float[] dphi; - protected float[] deta; - protected float[] energy; - protected float[] et; - protected float[] etSum; - - // Et is more useful than pure Energy, so use Et to replace Energy - // protected float[] energySum; - - protected byte[] side; - protected short[] etaIndex; - protected short[] phiIndex; - protected int[] sampling; - protected short[] detector; - - private int[][] cellTable; - - protected double minDensityECAL; - protected double maxDensityECAL; - protected double minDensityHCAL; - protected double maxDensityHCAL; - - // following attributes occur at majority of calorimeter subdetectors - // which inherit from here, but not at all of them (TILE is usually - // the exception), checks are always done, so it's save ; - // retrieving the data from XML is pre-checked so that not to spit out - // unnecessary complaints - protected int[] feedThrough = null; - protected int[] channel = null; - protected int[] slot = null; - protected int[] BadCell = null; - - - ACalorimeterData(AHashMap p, AEvent e) - { - super(p,e); - - CALORIMETER_NAME = getName(); - - energy = p.getFloatArray("energy"); - et = new float[numData]; - - phi = new float[numData]; - eta = new float[numData]; - deta = new float[numData]; - dphi = new float[numData]; - - // energySum = new float[numData]; - etSum = new float[numData]; - - side = new byte[numData]; - etaIndex = new short[numData]; - phiIndex = new short[numData]; - sampling = new int[numData]; - detector = new short[numData]; - - histoScale = parameterStore.get(CALORIMETER_NAME, "HistoScale"); - - // using AHashMap.getUnsureIntArray() does not complain if key is - // not found - these parameters may not be present in all calorimetry - // classes inherited from ACalorimeterData and using this call - // also covers backwards compatibility, and is safe - null is returned - // if key does not exist - feedThrough = p.getUnsureIntArray("feedThrough"); - channel = p.getUnsureIntArray("channel"); - slot = p.getUnsureIntArray("slot"); - BadCell = p.getUnsureIntArray("BadCell"); - - } - - /** - * Get the name used for associating this datatype/collection. For the - * calorimeter cells no storegate key is used. - * @return - */ - public String getFullName() { - return getName(); - } - - /** - * getADCCountsData() - * reads in adcCounts array from XML data. This method is currently used - * for LAr, FCAL, HEC and MBTS (TILE has two adcCounts arrays) - * @param p AHashMap - */ - protected int[][] getADCCountsData(AHashMap p) - { - int[][] adcCounts = null; - int[] adc = (p.get("adcCounts") != null) ? p.getIntArray("adcCounts") : null; - if(adc != null) - { - adcCounts = new int[numData][0]; - // multiple numbers are associated with each cell - int multiple = adc.length / numData; - int num = 0; - for(int i = 0; i < numData; i++) - { - adcCounts[i] = new int[multiple]; - for (int j = 0; j < multiple; j++) - { - adcCounts[i][j] = adc[num]; // fill in array for each cell - num++; - } - } - } // if(adc != null) - - return adcCounts; - - } // getADCCountsData() ------------------------------------------------- - - - - /** - * Class used to merge ACoord[] objects. - */ - public static class ACoordArray - { - private Vector<ACoord> v = new Vector<ACoord>(); - - public void add(ACoord[] c) - { - for (int i = 0; i < c.length; i++) - { - v.addElement(c[i]); - } - } - - public ACoord[] getArray() - { - ACoord[] c = new ACoord[v.size()]; - for (int i = 0; i < v.size(); i++) - { - c[i] = (ACoord) v.elementAt(i); - } - return c; - } - } - - - - /** - * Assigns the hits to a geometry object. - */ - public void makeHitToGeometryMapping() - { - int numNotFound = 0; - - // In detector[] we store the hit-to-geometry object mapping. - for (int i = 0; i < numData; i++) - { - detector[i] = (short) ACalorimeterDetector.getDetectorIndex(id[i]); - - if (detector[i] >= 0) - { - eta[i] = (float) ACalorimeterDetector.get(detector[i]).getEta(etaIndex[i], side[i]); - deta[i] = (float) ACalorimeterDetector.get(detector[i]).getDeltaEta(); - phi[i] = (float) ACalorimeterDetector.get(detector[i]).getPhi(phiIndex[i]); - dphi[i] = (float) ACalorimeterDetector.get(detector[i]).getDeltaPhi(); - } - else if (!CALORIMETER_NAME.equals("FCAL")) - { - eta[i] = 0.0f; - deta[i] = 0.0f; - phi[i] = 0.0f; - dphi[i] = 0.0f; - numNotFound++; - } - } - if (numNotFound > 0) - { - System.err.println(numNotFound + "/" + numData + " cells in " + - CALORIMETER_NAME + " not mapped to a geometry object. These will not be drawn."); - } - - // This depends on the number of geometry objects. - cellTable = new int[2 * ACalorimeterDetector.count()][2 * MAX_HIT_INDEX]; - } - - /** - * Returns the name of the calorimeter this data object belongs to. - * - * @return calorimeter name - */ - public String getCalorimeterName() - { - return CALORIMETER_NAME; - } - - - /** - * Method is called from APickInteraction and plots pulse shapes plots - * for a cell when picked. - * @param index int - */ - public void plotPulseShapes(int index, boolean withcurve) { - int[][] adc = getADCCounts(index); - if (adc == null) { - logger.warn("Pulse shape plot requested but no adc data available"); - return; - } - - if (!withcurve) { - APulseShapePlot.plotADCCounts(adc, getPulseTitleString(index), null); - } else { - double[][] ps = getPulseShape(index); - if (ps == null) { - logger.warn("No pulse shape information available, just plotting adc instead"); - APulseShapePlot.plotADCCounts(adc, getPulseTitleString(index), null); - } else { - APulseShapePlot.plotRealPulseShapes(adc, ps, - getPulseStep(index), getPulseSubtitle(index), getPulseTitleString(index)); - } - } - } - - /** - * - */ - protected int[][] getADCCounts(int index) { return null; } - - protected double[][] getPulseShape(int index) { return null; } - - protected double getPulseStep(int index) { return 1.0; } - - protected String[] getPulseSubtitle(int index) { return null; } - - /** - * Returns calorimeter type (ECAL or HCAL) of a certain hit. - * - * @param index int hit index - * @return String calorimeter type - */ - public abstract String getCalorimeterType(int index); - - /** - * Returns the ACalorimeterDetector of a certain hit. - * - * @param index int hit index - * @return ACalorimeterDetector - */ - public ACalorimeterDetector getDetector(int index) { - return ACalorimeterDetector.get(detector[index]); - } - - /** - * Recalculates eta from r and z in case the user wants to have their eta - * with respect to the primary vertex instead of 0. The calculation is a - * little different from the other calorimeter classes because this one - * contains both barrel and endcap data. - * - * @param index int index of hit in data - * @return double eta value - */ - public double getEta(int index) - { - double r, z; - - if (!parameterStore.get("VP", "EtaVertex").getStatus() || detector[index] < 0) - { - return this.eta[index]; - } - - if (ACalorimeterDetector.get(detector[index]) instanceof ABarrelCalorimeterDetector) - { - r = ACalorimeterDetector.get(detector[index]).getR(); - z = r * AMath.tanLambda(eta[index]); - } - else - { - z = ACalorimeterDetector.get(detector[index]).getZ(); - r = z / AMath.tanLambda(eta[index]); - } - - return AParameterUtilities.eta(z, r); - } - - /** - * Returns the calorimeter sampling (or layer) of a certain hit. - * - * @param index int hit index - * @return int sampling/layer - */ - public int getSampling(int index) - { - return sampling[index]; - } - - /** - * Returns the side of the calorimeter of a certain hit. - * - * @param index int hit index - * @return int side - */ - public int getSide(int index) - { - return side[index]; - } - - /** - * Returns the cell size in eta of a certain hit. - * - * @param index int hit index - * @return double cell size in eta - */ - public double getdEta(int index) - { - return deta[index]; - } - - /** - * Returns the cell size in phi of a certain hit. - * - * @param index int hit index - * @return double cell size in phi - */ - public double getdPhi(int index) - { - return dphi[index]; - } - - /** - * Returns the phi coordinate of a certain hit. - * - * @param index int hit index - * @return double phi coordinate. - */ - public double getPhi(int index) - { - return phi[index]; - } - - /** - * Returns the transverse energy of a hit. - * - * @param index int hit index - * @return float transverse energy - */ - public float getET(int index) - { - return et[index]; - } - - /** - * Returns the transverse energy of a list of hits. - * - * @param index int[] list of hit indices - * @return float[] list of transverse energies - */ - public float[] getET(int[] index) - { - float[] temp = new float[index.length]; - - for (int i = 0; i < index.length; i++) - { - temp[i] = et[index[i]]; - } - return temp; - } - - /** - * Returns the calorimeter sampling (or layer) of a list of hits. - * - * @param index int[] list of hit indices - * @return int[] list of samplings - */ - public int[] getSampling(int[] index) - { - int[] temp = new int[index.length]; - - for (int i = 0; i < index.length; i++) - { - temp[i] = sampling[index[i]]; - } - return temp; - } - - /** - * Returns the energy of a hit. - * - * @param index int hit index - * @return float energy - */ - public float getEnergy(int index) - { - return energy[index]; - } - - /** - * Returns the depositied energy of a list of hits. - * - * @param index int[] list of hit indices - * @return float[] list of energies - */ - public float[] getEnergy(int[] index) - { - float[] temp = new float[index.length]; - - for (int i = 0; i < index.length; i++) - { - temp[i] = energy[index[i]]; - } - return temp; - } - - public static double getNonScalingFactor() - { - return NON_SCALING_FACTOR; - } - - /** - * Returns the lowest density for the cell type of the specified hit. - * - * @param index int hit index - * @return double minimum density - */ - protected double getMinDensity(int index) - { - return getMinDensity(getCalorimeterType(index)); - } - - /** - * Returns the lowest densityfor the specified calorimeter type. - * - * @param type String either "ECAL", "HCAL" or "ALL" - * @return double minimum density - */ - protected double getMinDensity(String type) - { - if (type.equals("ECAL")) - { - return minDensityECAL; - } - else if (type.equals("HCAL")) - { - return minDensityHCAL; - } - else if (type.equals("ALL")) - { - // Return the lowest non-zero value. - if (minDensityECAL == 0.0 || minDensityHCAL == 0.0) - { - return Math.max(minDensityECAL, minDensityHCAL); - } - else - { - return Math.min(minDensityECAL, minDensityHCAL); - } - } - else - { - return 0.0; - } - } - - /** - * Returns the highest density for the cell type of the specified hit. - * - * @param index int hit index - * @return double maximum density - */ - protected double getMaxDensity(int index) - { - return getMaxDensity(getCalorimeterType(index)); - } - - /** - * Returns the highest densityfor the specified calorimeter type. - * - * @param type String either "ECAL", "HCAL" or "ALL" - * @return double maximum density - */ - protected double getMaxDensity(String type) - { - if (type.equals("ECAL")) - { - return maxDensityECAL; - } - else if (type.equals("HCAL")) - { - return maxDensityHCAL; - } - else if (type.equals("ALL")) - { - return Math.max(maxDensityECAL, maxDensityHCAL); - } - else - { - return 0.0; - } - } - - /** - * Sets the minimum density for the specified calorimeter type. - * - * @param type String either "ECAL", "HCAL" or "ALL" - * @param density double minimum density to set - */ - protected void setMinDensity(String type, double density) - { - if (type.equals("ECAL")) - { - minDensityECAL = density; - } - else if (type.equals("HCAL")) - { - minDensityHCAL = density; - } - else if (type.equals("ALL")) - { - minDensityECAL = density; - minDensityHCAL = density; - } - } - - /** - * Sets the maximum density for the specified calorimeter type. - * - * @param type String either "ECAL", "HCAL" or "ALL" - * @param density double maximum density to set - */ - protected void setMaxDensity(String type, double density) - { - if (type.equals("ECAL")) - { - maxDensityECAL = density; - } - else if (type.equals("HCAL")) - { - maxDensityHCAL = density; - } - else if (type.equals("ALL")) - { - maxDensityECAL = density; - maxDensityHCAL = density; - } - - parameterStore.get(CALORIMETER_NAME, "Area/Energy").setD(1. / Math.max(maxDensityECAL, maxDensityHCAL)); - } - - /** - * Returns the data that needs to be drawn in the specificied projection. - * - * @param projection AProjection projection - * @return ACoord data to be drawn - */ - protected ACoord getUserNoTransform(AProjection projection) - { - if (CALORIMETER_NAME.equals("FCAL") || CALORIMETER_NAME.equals("MBTS")) - { - // FCAL and MBTS data are not linked to the geometry objects, so use the old method. - return super.getUserNoTransform(projection); - } - else - { - // For all the other types we can simply get the geometry from the - // geometry objects. - makeDrawList(); - filterDrawList(projection); - double[][][] hv = new double[2][numDraw][0]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - if (detector[j] >= 0) - { - ACoord coord = ACalorimeterDetector.get(detector[j]).getCell(projection, etaIndex[j], phiIndex[j], side[j]); - if (coord.hv[0].length > 0) - { - hv[0][i] = coord.hv[0][0]; - hv[1][i] = coord.hv[1][0]; - } - } - else - { - // Alternative setups compatibility mode based on eta, deta, - // r or z, dr or dz, phi, dphi from event file could be - // implemented here. - } - index[i] = j; - } - - // Apply the wrap arounds for phi in certain projections. - if (projection instanceof AProjectionVP) - { - return new ACoord(hv, index, this).includePhiWrapAround("VP"); - } - else if (projection instanceof AProjectionFR) - { - return new ACoord(hv, index, this).includePhiWrapAround("FR"); - } - else if (projection instanceof AProjectionFZ) - { - return new ACoord(hv, index, this).includePhiWrapAround("FZ"); - } - else - { - return new ACoord(hv, index, this); - } - } - } - - /** - * Returns the data points for the "standard" mode v-plot. - * - * @return ACoord v-plot points - */ - public ACoord getVPPoints() - { - makeDrawList(); - double[][] hv = new double[2][numDraw]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - hv[0][i] = getEta(j); - hv[1][i] = Math.toDegrees(phi[j]); - index[i] = j; - } - return new ACoord(hv, index, this, ACoord.SYMBOLS).includePhiWrapAround("VP"); - } - - /** - * Cleans up the drawList. From all cells that are drawn at a certain place - * only the one that has the highest deposited transverse energy will remain. - * It also sums the transverse energy of the cells it removes. This is stored - * in etSum[] at the index of the "most energetic" cell. - * - * @param projection AProjection projection to be drawn - */ - protected void filterDrawList(AProjection projection) - { - // In the v-plot every cell is drawn, unless we're in one of the special - // modes. - if (projection instanceof AProjectionVP) - { - switch (parameterStore.get("VP", "Mode").getI()) - { - case AProjectionVP.MODE_STANDARD: - // Everything is drawn in the standard mode v-plot. - return; - case AProjectionVP.MODE_ECAL_LAYER_0: - case AProjectionVP.MODE_ECAL_LAYER_1: - case AProjectionVP.MODE_ECAL_LAYER_2: - case AProjectionVP.MODE_ECAL_LAYER_3: - if (!CALORIMETER_NAME.equals("LAr")) - { - // Don't draw HCAL in ECAL mode. - numDraw = 0; - } - return; - case AProjectionVP.MODE_HCAL_LAYER_0: - case AProjectionVP.MODE_HCAL_LAYER_1: - case AProjectionVP.MODE_HCAL_LAYER_2: - case AProjectionVP.MODE_HCAL_LAYER_3: - if (!CALORIMETER_NAME.equals("TILE") && !CALORIMETER_NAME.equals("HEC")) - { - // Don't draw ECAL in HCAL mode. - numDraw = 0; - } - return; - default: - numDraw = 0; - return; - } - } - - // The phi-z projection has special modes as well. - if (projection instanceof AProjectionFZ) - { - if (parameterStore.get(projection.getName(), "Mode").getI() != AProjectionYX.MODE_STANDARD) - { - numDraw = 0; - return; - } - } - // Also the y-x and phi-rho projections have special modes (they share the same mode list). - int mode = parameterStore.get("YX", "Mode").getI(); - if (projection instanceof AProjectionYX || projection instanceof AProjectionFR) - { - if (mode != AProjectionYX.MODE_STANDARD && - (mode < AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER || mode > AProjectionYX.MODE_HEC_SUMMED)) - { - numDraw = 0; - return; - } - else if (mode >= AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER && mode <= AProjectionYX.MODE_HEC_SUMMED) - { - if ((mode >= AProjectionYX.MODE_HEC_1 && mode <= AProjectionYX.MODE_HEC_4 && !CALORIMETER_NAME.equals("HEC")) || - (mode < AProjectionYX.MODE_HEC_1 && !CALORIMETER_NAME.equals("LAr")) || - (mode == AProjectionYX.MODE_HEC_SUMMED && !CALORIMETER_NAME.equals("HEC")) || - (mode == AProjectionYX.MODE_LAR_ENDCAP_SUMMED && !CALORIMETER_NAME.equals("LAr"))) - { - numDraw = 0; - return; - } - } - else if(mode == AProjectionYX.MODE_MBTS && !CALORIMETER_NAME.equals("MBTS")) - { - numDraw = 0; - return; - } - } - - float[][] etTable = new float[2 * ACalorimeterDetector.count()][2 * MAX_HIT_INDEX]; - for (int i = 0; i < 2 * ACalorimeterDetector.count(); i++) - { - for (int j = 0; j < 2 * MAX_HIT_INDEX; j++) - { - cellTable[i][j] = -1; - etTable[i][j] = 0.0f; - } - } - - for (int i = 0; i < numDraw; i++) - { - int detIndex = getDetectorIndex(listdl[i]); - int hitIndex = getHitIndex(listdl[i], projection); - - if (detIndex >= 0 && hitIndex >= 0) - { - etTable[detIndex][hitIndex] += et[listdl[i]]; - if (cellTable[detIndex][hitIndex] < 0 || et[cellTable[detIndex][hitIndex]] < et[listdl[i]]) - cellTable[detIndex][hitIndex] = listdl[i]; - } - } - - numDraw = 0; - for (int i = 0; i < 2 * ACalorimeterDetector.count(); i++) - { - for (int j = 0; j < 2 * MAX_HIT_INDEX; j++) - { - if (cellTable[i][j] > 0) - { - listdl[numDraw] = cellTable[i][j]; - etSum[listdl[numDraw]] = etTable[i][j]; - numDraw++; - } - } - } - } - - /** - * This function maps a hit to an index. This index is such that two hits - * get the same index when they are in the same detector and on the same - * side. - * - * @param index int number of the hit in the current dataset - * @return int detector index - */ - protected int getDetectorIndex(int index) - { - if (detector[index] >= 0) - { - if (side[index] > 0) - { - return ACalorimeterDetector.count() + detector[index]; - } - else - { - return detector[index]; - } - } - return -1; - } - - /** - * This function maps a hit to an index. This index is such that two hits in - * the same detector will receive the same index if they will be drawn in - * the same place. - * - * @param index int number of the hit in the current dataset - * @param projection AProjection projection the hit index should be - * calculated for - * @return int hit index - */ - protected int getHitIndex(int index, AProjection projection) - { - if (detector[index] >= 0) - { - if (projection instanceof AProjectionYX) - { - return phiIndex[index]; - } - else if (projection instanceof AProjectionRZ) - { - if (ACalorimeterDetector.get(detector[index]).getRSign(phiIndex[index]) > 0) - { - return MAX_HIT_INDEX + etaIndex[index]; - } - else - { - return etaIndex[index]; - } - } - else if (projection instanceof AProjectionFR) - { - return phiIndex[index]; - } - else if (projection instanceof AProjectionFZ) - { - return phiIndex[index]; - } - } - return -1; - } - - /** - * Returns the histograms for this projection. - * - * @param projection AProjection2D current projection - * @return ACoord[] polygons representing histograms - */ - protected ACoord[] getUserHistograms(AProjection2D projection) - { - return ACoord.NO_HISTOGRAMS; - } - - /** - * Returns the histograms in the YX projection. - * - * @return ACoord[] histograms - */ - public ACoord[] getYXHistograms() - { - AHistogram hist = new AHistogram(0., 2. * Math.PI, phiGranularity, histoScale.getD(), this); - int mode = parameterStore.get("YX", "Mode").getI(); - double newInnerR = innerR; - boolean hasAddedToHistogram = false; - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - if (detector[j] >= 0) - { - if ((mode == AProjectionYX.MODE_STANDARD && ACalorimeterDetector.get(detector[j]) instanceof ABarrelCalorimeterDetector) || - (mode != AProjectionYX.MODE_STANDARD && ACalorimeterDetector.get(detector[j]) instanceof AEndcapCalorimeterDetector)) - { - String name = ACalorimeterDetector.get(detector[j]).getName(); - if (mode == AProjectionYX.MODE_STANDARD || (mode == AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER && (name.equals("LAr Endcap Presampler")||name.equals("LAr_EC_Presampler"))) || - (name.equals("LAr Outer Endcap") && getSampling(j) == mode - AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER) || - (name.equals("LAr Inner Endcap") && getSampling(j) == mode - AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER - 1) || - (name.equals("HEC") && getSampling(j) == mode - AProjectionYX.MODE_HEC_1) || - (mode == AProjectionYX.MODE_LAR_ENDCAP_SUMMED && name.indexOf("LAr") >= 0) || (mode == AProjectionYX.MODE_HEC_SUMMED && name.equals("HEC"))) - { - hasAddedToHistogram = true; - double phiMin = ACalorimeterDetector.get(detector[j]).getPhiMin(phiIndex[j]); - double phiMax = ACalorimeterDetector.get(detector[j]).getPhiMax(phiIndex[j]); - - if (phiMin < -1e-9 && phiMax > 1e-9) - { - hist.fill(phiMin + 2. * Math.PI, 2. * Math.PI, etSum[j] / 2.); - hist.fill(0., phiMax, etSum[j] / 2.); - } - else - { - hist.fill(phiMin, phiMax, etSum[j]); - } - if (mode != AProjectionYX.MODE_STANDARD) - { - if (name.equals("HEC")) - { - if (mode != AProjectionYX.MODE_HEC_SUMMED) - { - //can use the get RMin accurately for the HEC - newInnerR = ACalorimeterDetector.get(detector[j]).getRMin(); - } - else if (ACalorimeterDetector.get(detector[j]).getRMin() < newInnerR) - { - //only want to assign HEC ALL minimum if is smaller - newInnerR = ACalorimeterDetector.get(detector[j]).getRMin(); - } - } - else - { - //calculate RMin as not accurate in geometry file - double etaMax = ACalorimeterDetector.get(detector[j]).getEtaMax(); - double zMin = ACalorimeterDetector.get(detector[j]).getZMin(); - double temp = zMin / Math.sinh(etaMax); - //save calculated if smallest - if (temp < newInnerR) - newInnerR = temp; - } - } - } - } - } - } - if (hasAddedToHistogram) - return new ACoord[] { hist.getYXUser(newInnerR) }; - else - return ACoord.NO_HISTOGRAMS; - } - - /** - * Returns the histograms in the phi-rho projection. - * - * @return ACoord[] histograms - */ - public ACoord[] getFRHistograms() - { - AHistogram hist = new AHistogram(0., 2. * Math.PI, phiGranularity, histoScale.getD(), this); - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - if (detector[j] >= 0) - { - if (ACalorimeterDetector.get(detector[j]) instanceof ABarrelCalorimeterDetector) - { - double phiMin = ACalorimeterDetector.get(detector[j]).getPhiMin(phiIndex[j]); - double phiMax = ACalorimeterDetector.get(detector[j]).getPhiMax(phiIndex[j]); - - if (phiMin < -1e-9 && phiMax > 1e-9) - { - hist.fill(phiMin + 2. * Math.PI, 2. * Math.PI, etSum[j] / 2.); - hist.fill(0., phiMax, etSum[j] / 2.); - } - else - { - hist.fill(phiMin, phiMax, etSum[j]); - } - } - } - } - return new ACoord[] { hist.getFRUser(innerR).includePhiWrapAround("FR") }; - } - - /** - * Returns the histograms in the RZ projection. - * - * @return ACoord[] histograms - */ - public ACoord[] getRZHistograms() - { - AHistogram histUp = new AHistogram(-outerEta, outerEta, etaGranularity, histoScale.getD(), this); - AHistogram histDown = new AHistogram(-outerEta, outerEta, etaGranularity, histoScale.getD(), this); - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - if (detector[j] >= 0) - { - int sign = ACalorimeterDetector.get(detector[j]).getRSign(phiIndex[j]); - double etaMin = ACalorimeterDetector.get(detector[j]).getEtaMin(etaIndex[j], side[j]); - double etaMax = ACalorimeterDetector.get(detector[j]).getEtaMax(etaIndex[j], side[j]); - - if (sign > 0) - { - histUp.fill(etaMin, etaMax, etSum[j]); - } - else - { - histDown.fill(etaMin, etaMax, etSum[j]); - } - } - } - - ACoordArray c = new ACoordArray(); - c.add(histUp.getRZUser(outerZ, outerR, AHistogram.UP)); - c.add(histDown.getRZUser(outerZ, outerR, AHistogram.DOWN)); - return c.getArray(); - } - - /** - * Returns the histograms in the phi-z projection. - * - * @return ACoord[] histograms - */ - public ACoord[] getFZHistograms() - { - AHistogram hist; - AHistogram histLeft = new AHistogram(0., 2. * Math.PI, phiGranularity, histoScale.getD(), this); - AHistogram histRight = new AHistogram(0., 2. * Math.PI, phiGranularity, histoScale.getD(), this); - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - if (detector[j] >= 0) - { - if (ACalorimeterDetector.get(detector[j]) instanceof AEndcapCalorimeterDetector) - { - double phiMin = ACalorimeterDetector.get(detector[j]).getPhiMin(phiIndex[j]); - double phiMax = ACalorimeterDetector.get(detector[j]).getPhiMax(phiIndex[j]); - - if (side[j] > 0) - { - hist = histRight; - } - else - { - hist = histLeft; - } - - if (phiMin < -1e-9 && phiMax > 1e-9) - { - hist.fill(phiMin + 2. * Math.PI, 2. * Math.PI, etSum[j] / 2.); - hist.fill(0., phiMax, etSum[j] / 2.); - } - else - { - hist.fill(phiMin, phiMax, etSum[j]); - } - } - } - } - - return new ACoord[] { histLeft.getFZUser(innerZ, AHistogram.LEFT).includePhiWrapAround("FZ"), - histRight.getFZUser(innerZ, AHistogram.RIGHT).includePhiWrapAround("FZ") }; - } - - /** - * Returns the histograms in the x'-z projection. - * - * @return ACoord[] histograms - */ - public ACoord[] getXZHistograms() - { - return ACoord.NO_HISTOGRAMS; - } - - /** - * Returns the histograms in the y'-z projection. - * - * @return ACoord[] histograms - */ - public ACoord[] getYZHistograms() - { - return ACoord.NO_HISTOGRAMS; - } - - /** - * Returns the histograms in the eta-phi projection. - * - * @return ACoord[] histograms - */ - public ACoord[] getVPHistograms() - { - return ACoord.NO_HISTOGRAMS; - } - - /** - * Sets the type of the hits (associated, unassociated). - */ - protected void setType() - { - int[][] cluster = event.getAssociationManager().get(getName(), "Cluster"); - for (int i = 0; i < numData; i++) - { - if (cluster != null && cluster[i] != null) - { - type[i] = 1; - } - else - { - type[i] = 0; - } - } - } - - /** - * Determines if the cells need to be scaled by energy or not. This will be - * true for most cases, but not if the user has selected the color by energy - * color function. - * - * @return boolean true for energy scaling, false for constant cell size - */ - protected boolean energyScaling() - { - return parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI() != COLOR_FUNC_ENERGY; - } - - /** - * Determines the color for each hit according to the color function set by - * the user. - * - * @return int number of coloring options? - */ - protected int internalColor() - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - switch (colorFunction) - { - case COLOR_FUNC_CONSTANT: - colorByConstant(); - break; - - case COLOR_FUNC_SUBDET: - colorBy(sub); - break; - - case COLOR_FUNC_CLUSTER: - colorBy(getClusters()); - break; - - case COLOR_FUNC_SAMPLING: - colorBy(sampling); - break; - - case COLOR_FUNC_ENERGY: - colorByEnergy(); - break; - - case COLOR_FUNC_JET: - if(parameterStore.get("Jet", "ColorFunction").getI()!=1) - { - parameterStore.get("Jet", "ColorFunction").setI(1); - String msg = "Coloring Calo by jet so "; - msg += "ATLAS->Jet->Color Function changed to color by index"; - AOutput.append("\n" + msg + "\n", ALogInterface.WARNING); - } - colorBy(getJets()); - break; - - case COLOR_FUNC_TYPE: - colorByType(); - break; - - case COLOR_FUNC_TIME: - colorByTime(); - break; - } - - return colorFunction + 8; - } - - /** - * Colors cells by energy. - */ - protected void colorByEnergy() - { - double min = 0.0, max = 0.0; - boolean first = true; - int numColors = 17; - float[] en = null; - - switch (parameterStore.get(CALORIMETER_NAME, "EnergyMode").getI()) - { - case ENERGY_MODE_SUM_LIN: - case ENERGY_MODE_SUM_LOG: - case ENERGY_MODE_SUM_SQRT: - en = etSum; - break; - - case ENERGY_MODE_MAX_LIN: - case ENERGY_MODE_MAX_LOG: - case ENERGY_MODE_MAX_SQRT: - en = et; - break; - } - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - if (first) - { - min = en[j]; - max = en[j]; - first = false; - } - - if (en[j] > max) - max = en[j]; - if (en[j] < min) - min = en[j]; - } - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - if (AColorMap.getColorMap() == AColorMap.COLOR_MAP_BW) - { - // Black and white colormap. - color[j] = AColorMap.BK; - } - else - { - int colorIndex = 0; - - // We have numColors colors available. - switch (parameterStore.get(CALORIMETER_NAME, "EnergyMode").getI()) - { - case ENERGY_MODE_MAX_LIN: - case ENERGY_MODE_SUM_LIN: - colorIndex = (int) (numColors * (en[j] - min) / (max - min)); - break; - case ENERGY_MODE_MAX_LOG: - case ENERGY_MODE_SUM_LOG: - colorIndex = (int) (numColors * (Math.log(en[j]) - Math.log(min)) / (Math.log(max) - Math.log(min))); - break; - case ENERGY_MODE_MAX_SQRT: - case ENERGY_MODE_SUM_SQRT: - colorIndex = (int) (numColors * Math.sqrt((en[j] - min) / (max - min))); - break; - } - - if (colorIndex >= numColors) - colorIndex = (byte) (numColors - 1); - - color[j] = (byte) colorIndex; - } - } - } - - /** - * Colors cells by type (ECAL/HCAL). - */ - protected void colorByType() - { - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - String cellType = getCalorimeterType(j); - //Use detector color but add on 12 to get different shade of same color - color[j] = (byte) (parameterStore.get("Det", cellType + "Fill").getI() + 12); - } - } - - //Gets the measured time for a calorimeter cell. - //It's 0 by default, but can and should be overriden by subclasses. - protected double getTime(int hit) - { - return 0.0; - } - - //Color cells by their measured time, on a blue-red scale. - //Unmeasured cells are grey. - protected void colorByTime() - { - double min = 0.0, max = 0.0; - boolean first = true; - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - double t=getTime(j); - if (t==0.0) continue;//ignore unmeasured hits - if (first) - { - min = t; max = t; - first = false; - } - - if (t > max) max = t; - if (t < min) min = t; - } - - int numColors = 127; - double scale = (max - min); - if (scale<5) scale=5;//smallest scale is 5 ns - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - double t = getTime(j); - - int colorIndex = (int) (numColors * (t-min) / scale); - if (colorIndex >= numColors) { - colorIndex = numColors;//red - } - if (colorIndex < 1) { - colorIndex = 1;//blue - } - - if (t==0.0) colorIndex=0;//gets grey color - color[j] = (byte) colorIndex; - - } - } - - /** - * Applies cuts to the data. - */ - protected void applyCuts() - { - cutIndex(); - cut("CutsCalo", "Layer", "Layer", sampling); - cut("CutsCalo", "CellQuality", "CellQuality", BadCell); - cutPhi(phi, dphi); - cutEtaDEta(eta, deta); - } - - /** - * Performs the local density calibration. This function determines the - * highest and lowest energy density values ans stores them. - * - * @param index int[] hits to be used in calibration - * @param area double[] cell areas - */ - public void calibrateLocalDensity(int[] index, double[] area) - { - float[] en = null; - double density; - boolean firstECAL = true; - boolean firstHCAL = true; - - AParameter par = parameterStore.get(CALORIMETER_NAME, "Area/Energy"); - if (par.getStatus() && par.getD() > 0) - { - minDensityECAL = 0.0; - minDensityHCAL = 0.0; - maxDensityECAL = 1. / par.getD(); - maxDensityHCAL = 1. / par.getD(); - } - else - { - // Otherwise we need to do calculate it ourselves. - switch (parameterStore.get(CALORIMETER_NAME, "EnergyMode").getI()) - { - case ENERGY_MODE_SUM_LIN: - case ENERGY_MODE_SUM_LOG: - case ENERGY_MODE_SUM_SQRT: - en = etSum; - break; - - case ENERGY_MODE_MAX_LIN: - case ENERGY_MODE_MAX_LOG: - case ENERGY_MODE_MAX_SQRT: - en = et; - break; - } - - // The default for an empty list of cells or only zero area cells is - // 0.0. - minDensityECAL = 0.0; - maxDensityECAL = 0.0; - minDensityHCAL = 0.0; - maxDensityHCAL = 0.0; - - // Calculate density and determine the highest and lowest values. - for (int i = 0; i < index.length; i++) - { - if (area[i] > 0) - { - density = (en[index[i]] / area[i]); - - if (density > 0) - { - if (getCalorimeterType(index[i]).equals("ECAL")) - { - if (firstECAL) - { - // First cell with a sensible density, take this - // as initial value. - minDensityECAL = density; - maxDensityECAL = density; - firstECAL = false; - } - - if (density < minDensityECAL) - minDensityECAL = density; - if (density > maxDensityECAL) - maxDensityECAL = density; - - } - else if (getCalorimeterType(index[i]).equals("HCAL")) - { - if (firstHCAL) - { - // First cell with a sensible density, take this - // as initial value. - minDensityHCAL = density; - maxDensityHCAL = density; - firstHCAL = false; - } - - if (density < minDensityHCAL) - minDensityHCAL = density; - if (density > maxDensityHCAL) - maxDensityHCAL = density; - } - } - } - } - } - } - - /** - * - */ - public double[] getScaleFactors(int[] dl, double[] area) { - double[] factors = new double[area.length]; - - float[] en = null; - int energyMode = parameterStore.get(CALORIMETER_NAME, "EnergyMode").getI(); - - switch (energyMode) - { - case ENERGY_MODE_SUM_LIN: - case ENERGY_MODE_SUM_LOG: - case ENERGY_MODE_SUM_SQRT: - en = etSum; - break; - - case ENERGY_MODE_MAX_LIN: - case ENERGY_MODE_MAX_LOG: - case ENERGY_MODE_MAX_SQRT: - en = et; - break; - } - - for (int i = 0; i < area.length; i++) - { - factors[i] = 1.0f; - - if (area[i] == 0) - continue; - - if (energyScaling()) - { - // The user has (implicitly) selected energy scaling. - double density = en[dl[i]] / area[i]; - double minDensity = getMinDensity(dl[i]); - double maxDensity = getMaxDensity(dl[i]); - - switch (energyMode) - { - case ENERGY_MODE_MAX_LIN: - case ENERGY_MODE_SUM_LIN: - factors[i] = Math.sqrt(density / maxDensity); - break; - - case ENERGY_MODE_MAX_LOG: - case ENERGY_MODE_SUM_LOG: - double magnitude = Math.floor(Math.log10(Math.sqrt(maxDensity / minDensity)) + 1.0); - factors[i] = (Math.log10(Math.sqrt(density / maxDensity)) + magnitude) / magnitude; - break; - - case ENERGY_MODE_MAX_SQRT: - case ENERGY_MODE_SUM_SQRT: - factors[i] = Math.sqrt(Math.sqrt(density / maxDensity)); - break; - - default: - factors[i] = NON_SCALING_FACTOR; - } - } - else - { - // No energy scaling, scale all cells by the same factor. - factors[i] = NON_SCALING_FACTOR; - } - - if (factors[i] > 1.0) { - factors[i] = 1.0; - } - } - - return factors; - } - - /** - * Scales a series of polygons according to the user settings. - * - * @param coord ACoord polygons to be scaled - * @param area double[] surface area of these polygons - * @return ACoord scaled polygons - */ - protected ACoord scalePolygons(ACoord coord, double[] area) - { - double[] factors = getScaleFactors(coord.index, area); - - for (int i = 0; i < area.length; i++) - { - if (area[i] == 0) - continue; - - APolygon.scale(coord.hv[0][i], coord.hv[1][i], factors[i]); - } - return coord; - } - - private String getCellString(int index, String idstr) { - StringBuffer msg = new StringBuffer(); - msg.append(CALORIMETER_NAME + " cell"); - msg.append(" (id: " + idstr + " index: " + index + ")"); - return msg.toString(); - } - - private String getHitString(int index) { - StringBuffer msg = new StringBuffer(); - - msg.append("\n E Max = "); - msg.append(String.format("%.2f",energy[index])); - msg.append(" GeV\n ET Max = "); - msg.append(String.format("%.2f",et[index])); - msg.append(" GeV\n ET Sum = "); - msg.append(String.format("%.2f",etSum[index])); - msg.append(" GeV\n "); - msg.append(AMath.ETA); - msg.append(" = "); - msg.append(String.format("%.4f",eta[index])); - msg.append(" "); - msg.append(AMath.PLUSMINUS); - msg.append(" "); - // deta is step (i.e. size of a cell), with +- we want to see half of it - msg.append(String.format("%.3f",deta[index] / 2.0)); - msg.append("\n "); - msg.append(AMath.PHI); - msg.append(" = "); - msg.append(String.format("%.1f",Math.toDegrees(phi[index]))); - msg.append(" " + AMath.PLUSMINUS + " "); - // dphi is step (i.e. size of a cell), with +- we want to see half of it - msg.append(String.format("%.1f",Math.toDegrees(dphi[index] / 2.0))); - msg.append(AMath.DEGREES); - msg.append(" (" + String.format("%.1f",phi[index]) + " "); - msg.append(AMath.PLUSMINUS + " " + String.format("%.1f",dphi[index] / 2.0) + " rad)"); - - if(feedThrough != null && slot != null && channel != null) - { - String s = "\n feed through/slot/channel = " + - feedThrough[index] + "/" + slot[index] + "/" + - channel[index]; - msg.append(s); - } - if(BadCell != null){ - if(BadCell[index] == 0) - msg.append("\n Cell is good"); - if(BadCell[index] == 1) - msg.append("\n Cell is bad"); - if(BadCell[index] == -1) - msg.append("\n Cell is below 50 MeV"); - } - - return msg.toString(); - } - - /** - * Getting title string for pulse shape windows - * - * Relies on decodedId[1] being some useful high level string describing - * the calorimeter part. This isn't the case for ATILEData where this function - * is overridden to do something different. - * - * Maybe this is a slightly unreasonable plan... but then the first thing - * you decode out of the id should usually be the "biggest" sort of division... - * - Adam - */ - protected String getPulseTitleString(int index) { - - String[] decodedId = AIdHelper.getFullIdentifier(id[index]); - - String title = null; - - if (feedThrough == null || slot == null || channel == null) { - // Old style title - logger.warn("Calo FT/slot/channel info not available, using old style title"); - title = decodedId[1] + " cell: " + decodedId[0]; - } else { - // New title as requested by Andre N. Aug 09 - title = decodedId[1] + " cell: " + - this.feedThrough[index] + "/" + this.slot[index] + - "/" + this.channel[index]; - } - - return title; - } - - // Some calo stuff wants to decode the id it's own way... - public String getHitInfoNoDecode(int index) { - - String[] decodedId = AIdHelper.getFullIdentifier(id[index]); - return getCellString(index, decodedId[0]) + getHitString(index); - - } - - /** - * Returns information about a certain hit for display in the information - * box. - * - * @param index int hit index - * @return String hit information - */ - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n ET="+String.format("%.3f",et[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Ex="+String.format("%.3f",et[index]*Math.cos(phi[index]))+" GeV "+ - "\n Ey="+String.format("%.3f",et[index]*Math.sin(phi[index]))+" GeV "+ - "\n Ez="+String.format("%.3f",et[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - String[] decodedId = AIdHelper.getFullIdentifier(id[index]); - StringBuffer msg = new StringBuffer(); - msg.append(getCellString(index, decodedId[0])); - // iterate over decodedId to get further details (if available), - // first item [0] was already printed out above, thus start from 1 - for(int i = 1; i < decodedId.length; i++) - { - msg.append("\n " + decodedId[i]); - } - - msg.append(getHitString(index)); - // by zdenek 2009-01-20 - // layer is already present as sampling in the decodedId - // sub[] should gradually be removed, don't print it for now - // (see mess in AHashMap - !name.equals("sub")) grrrr - /* - msg.append("\n "); - msg.append("layer = " + sampling[index]); - msg.append("\n "); - msg.append("subdetector = " + sub[index]); - */ - - return msg.toString(); - } - - /** - * Returns the total transverse energy for this data type. - * - * @return double total transverse energy - */ - public double getTotalTransverseEnergy() - { - double sumEt = 0.; - for (int i = 0; i < numData; i++) - { - sumEt += et[i]; - } - return sumEt; - } - - /** - * Returns information about the drawn hits, used for the v-plot. - * - * @return String information - */ - public String getVPHitInfo() - { - applyCuts(); - if (numDraw == 0) - return ""; - double sumE = 0.; - double sumEt = 0.; - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - sumEt += et[j]; - sumE += energy[j]; - } - - String msg = numDraw + " " + getNameScreenName(); - msg += " sum(ET) = " + String.format("%.1f",sumEt) + " sum(E) = " + String.format("%.1f",sumE); - return msg; - } - - /** - * Returns the specified hits in the form of a four vector. Used by the list - * manager. - * - * @param num int number of hits - * @param list int[] indices of the hits - * @return A4Vector four vector - */ - public A4Vector get4Vector(int num, int[] list) - { - A4Vector sum = new A4Vector(); - - for (int i = 0; i < num; ++i) - { - int j = list[i]; - double lambda = AMath.lambda(eta[j]); - - double pt = energy[j] * Math.cos(lambda); - double pz = energy[j] * Math.sin(lambda); - - double px = pt * Math.cos(phi[j]); - double py = pt * Math.sin(phi[j]); - - sum.add(px, py, pz, 0.); - } - return sum; - } - - /** - * Calorimeter cells can be drawn either explicitly or implicitly. In most - * views cells that are located behind eachother are consolidated and only - * the most energetic one is drawn explicitly. The other cells are drawn - * implicitly, since their energy value is still added to the energy sum of - * the explicitly drawn cell. The list manager does not know about the - * implicitly drawn cells though, so this poses a problem when the user - * requests information about a certain area of the canvas. This is solved - * using this method. This function receives the list of explicitly drawn - * cells and then adds the ones that were implicitly drawn in this - * selection. - * - * @param drawn boolean[] initial drawn list containing only the explicitly - * drawn cells - * @return boolean[] drawn list containing the explicitly and the implicitly - * drawn cells. - */ - public boolean[] expandDrawn(boolean[] drawn) - { - makeDrawList(); - AProjection projection = ACanvas.getCanvas().getCurrentWindow().getProjection(); - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - - if (drawn[j]) - continue; - - int detIndex = getDetectorIndex(j); - int hitIndex = getHitIndex(j, projection); - - if (detIndex >= 0 && hitIndex >= 0) { - if (cellTable != null && detIndex < cellTable.length - && hitIndex < cellTable[detIndex].length) { - - int mappedTo = cellTable[detIndex][hitIndex]; - - if (mappedTo >= 0 && drawn[mappedTo] == true) { - drawn[j] = true; - } - } - } - } - - return drawn; - } - - /** - * Rebuilds the hit to geometry mapping for all calorimeters. Used when the - * user has loaded a different geometry file. - */ - public static void remakeHitToGeometryMapping() - { - //Get current event - AEvent event = eventManager.getCurrentEvent(); - if (event != null){ - ACalorimeterData[] calorimeters = new ACalorimeterData[event.getCalorimeters().size()]; - event.getCalorimeters().toArray(calorimeters); - for (int i = 0; i < calorimeters.length; i++) - { - calorimeters[i].makeHitToGeometryMapping(); - } - } - } - - /** - * Draws the calorimeters. This method is called from AProjection2D.paint(). - * - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - * @param projection AProjection2D current projection - * @param event AEvent drawn event reference - */ - public static void drawCalorimeters(AWindow window, AGraphics ag, AProjection2D projection, AEvent event) - { - int mode = parameterStore.get(projection.getName(), "Mode").getI(); - - if(projection instanceof AProjectionYX || projection instanceof AProjectionFR) - { - //only grey out the GUI if relevant for the current window - boolean changeGUI = false; - if(window.equals(ACanvas.getCanvas().getCurrentWindow())) - changeGUI = true; - - //grey out draw FCAL option if not on right layer of HEC - AParameter drawFCAL = parameterStore.get("YX", "DrawFCAL"); - if(changeGUI) - { - if(!drawFCAL.isInitialized()) - drawFCAL.initialize(); - if(mode < AProjectionYX.MODE_HEC_2 || mode > AProjectionYX.MODE_HEC_4) - drawFCAL.getNameComponent().setEnabled(false); - else - drawFCAL.getNameComponent().setEnabled(true); - } - - - //grey out split ETA, LAr bin and HEC bin options if not on summed endcaps option - AParameter splitEta = parameterStore.get("YX", "SplitEta"); - AParameter LArBin = parameterStore.get("YX", "LArBin"); - AParameter HECBin = parameterStore.get("YX", "HECBin"); - if(changeGUI) - { - if(!HECBin.isInitialized()) - HECBin.initialize(); - if(!LArBin.isInitialized()) - LArBin.initialize(); - if(!splitEta.isInitialized()) - splitEta.initialize(); - } - //Summed Endcaps has a different draw method - if(mode == AProjectionYX.MODE_LAR_ENDCAP_SUMMED || mode == AProjectionYX.MODE_HEC_SUMMED) - { - if(changeGUI) - { - LArBin.getValueComponent().setEnabled(true); - HECBin.getValueComponent().setEnabled(true); - LArBin.getNameComponent().setEnabled(true); - HECBin.getNameComponent().setEnabled(true); - if(LArBin.getI()==3 || HECBin.getI()==3) - { - splitEta.getValueComponent().setEnabled(true); - splitEta.getNameComponent().setEnabled(true); - } - else - { - splitEta.getValueComponent().setEnabled(false); - splitEta.getNameComponent().setEnabled(false); - } - } - ACalorimeterData[] calorimeters = new ACalorimeterData[event.getCalorimeters().size()]; - event.getCalorimeters().toArray(calorimeters); - for (int i = 0; i < calorimeters.length; i++) - { - //check if in right calorimeter - if ((mode == AProjectionYX.MODE_LAR_ENDCAP_SUMMED && !calorimeters[i].getName().equals("LAr")) || - (mode == AProjectionYX.MODE_HEC_SUMMED && !calorimeters[i].getName().equals("HEC"))) - continue; - ADrawCalorimeterSummedEndcaps.drawCalorimeterSummedEndcaps(window, - ag, projection, calorimeters[i], calorimeters[i].etaIndex, - calorimeters[i].phiIndex, calorimeters[i].side); - } - return; - } - else - { - if(changeGUI) - { - LArBin.getValueComponent().setEnabled(false); - HECBin.getValueComponent().setEnabled(false); - splitEta.getValueComponent().setEnabled(false); - LArBin.getNameComponent().setEnabled(false); - HECBin.getNameComponent().setEnabled(false); - splitEta.getNameComponent().setEnabled(false); - } - if (ALegendWindow.exists()) - ALegendWindow.getInstance().nothingToDisplay(window); - } - } - else if (ALegendWindow.exists()) - ALegendWindow.getInstance().nothingToDisplay(window); - - if (projection instanceof AProjectionVP && mode == 0) - { - // The standard mode of the v-plot uses a different function. - drawCalorimetersVPlot(window, ag, projection, event); - return; - } - - ACalorimeterData[] calorimeters = new ACalorimeterData[event.getCalorimeters().size()]; - event.getCalorimeters().toArray(calorimeters); - ACoord[] data = new ACoord[calorimeters.length]; - double[][] area = new double[calorimeters.length][]; - - for (int i = 0; i < calorimeters.length; i++) - { - // Retrieve the cell coordinates. - data[i] = calorimeters[i].getUserNoTransform(projection); - - // Calculate the cell areas. - area[i] = new double[data[i].index.length]; - for (int j = 0; j < data[i].index.length; j++) - { - area[i][j] = APolygon.getArea(data[i].hv[0][j], data[i].hv[1][j]); - } - - // Let the calorimeter determine its minimum and maximum energy - // density. - calorimeters[i].calibrateLocalDensity(data[i].index, area[i]); - } - - if (window.getProjection() instanceof AProjectionVP) - { - // In case of the v-plot we force the overall energy density - // calibration. - calibrateDensity(calorimeters, ENERGY_CALIB_OVERALL); - } - else - { - // Calibrate the energy density according to the user settings. - calibrateDensity(calorimeters, ENERGY_CALIB_UNKNOWN); - } - - for (int i = 0; i < calorimeters.length; i++) - { - // Apply the non linear transforms and convert to screen - // coordinates. - data[i] = window.calculateDisplay(projection.nonLinearTransform(data[i])); - - // Draw the cell frames. - if (parameterStore.get(calorimeters[i].getName(), "Cells").getStatus()) - { - drawFrames(calorimeters[i], data[i], window, ag); - } - } - - for (int i = 0; i < calorimeters.length; i++) - { - // Draw the cell geometry. - if (parameterStore.get(calorimeters[i].getName(), "Cells").getStatus()) - { - drawGeometry(calorimeters[i], data[i], window, ag); - } - } - - String[] histograms = { "TILE", "HEC", "LAr", "FCAL", "MBTS" }; - for (int j = 0; j < histograms.length; j++) - { - for (int i = 0; i < calorimeters.length; i++) - { - if (calorimeters[i].getCalorimeterName().equals(histograms[j])) - { - // Draw the histograms. - drawHistogram(calorimeters[i], window, ag, projection); - } - } - } - for (int j = 0; j < histograms.length; j++) - { - for (int i = 0; i < calorimeters.length; i++) - { - if (calorimeters[i].getCalorimeterName().equals(histograms[j])) - { - // Draw the frames for the histograms. - frameHistogram(calorimeters[i], window, ag, projection); - } - } - } - - for (int i = 0; i < calorimeters.length; i++) - { - if (parameterStore.get(calorimeters[i].getName(), "Cells").getStatus()) - { - // Scale the cell polygons. - data[i] = calorimeters[i].scalePolygons(data[i], area[i]); - // And draw them. - drawHits(calorimeters[i], data[i], window, ag); - } - } - - } - - /** - * Draws the calorimeters in the standard mode v-plot. This method is called - * from drawCalorimeters and should not be used directly. - * - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - * @param projection AProjection2D current projection - * @param event AEvent drawn event reference - */ - private static void drawCalorimetersVPlot(AWindow window, AGraphics ag, AProjection2D projection, AEvent event) - { - ACalorimeterData[] calorimeters = new ACalorimeterData[event.getCalorimeters().size()]; - event.getCalorimeters().toArray(calorimeters); - - float[][] energies = new float[calorimeters.length][]; - int[] sizes = new int[calorimeters.length]; - ACoord[] points = new ACoord[calorimeters.length]; - Color[] colorMap = AColorMap.getColors(); - //if color by energy use different colormap - for (int i = 0; i < calorimeters.length; i++) - { - if(calorimeters[i].CALORIMETER_NAME.equals("MBTS")) continue; - if (parameterStore.get(calorimeters[i].getParameterGroup(), "ColorFunction").getI() - == ACalorimeterData.COLOR_FUNC_ENERGY) { - switch (AColorMap.getColorMap()) { - case AColorMap.COLOR_MAP_DEFAULT1: - case AColorMap.COLOR_MAP_DEFAULT2: - case AColorMap.COLOR_MAP_M4M5: - case AColorMap.COLOR_MAP_GRAYDET: - case AColorMap.COLOR_MAP_ORIGINAL: - // Use colors. - colorMap = AColorMap.getColors(AColorMap.COLOR_MAP_HITCOL); - break; - case AColorMap.COLOR_MAP_GRAY: - case AColorMap.COLOR_MAP_BW: - // Use grayscale. - colorMap = AColorMap.getColors(AColorMap.COLOR_MAP_GRAY_HITCOL); - break; - } - } else if (parameterStore.get(calorimeters[i].getParameterGroup(), "ColorFunction").getI() == COLOR_FUNC_TIME) { - colorMap = AColorMap.getShades(128); - } - - points[i] = window.calculateDisplay(calorimeters[i].getVPPoints()); - energies[i] = calorimeters[i].getET(points[i].index); - sizes[i] = energies[i].length; - calorimeters[i].color(); - } - - for (int i = 0; i < calorimeters.length; i++) - { - for (int j = 0; j < sizes[i]; j++) - { - int size = (int) Math.sqrt(energies[i][j] * SCALE_FACTOR_VPLOT); - if (size == 0) - size++; - - int cellColor = calorimeters[i].color[points[i].index[j]]; - ag.setColor(colorMap[cellColor]); - ag.drawPoint(calorimeters[i], points[i].index[j], points[i].hv[0][0][j], - points[i].hv[1][0][j], size, size); - } - } - - } - - /** - * Calibrating involves finding the minimum and maximum energy density - * values. This function takes the local (per calorimeter) values and - * calculates the overall values (if needed). - * - * @param calorimeters ACalorimeterData[] calorimeter data objects - * @param mode int calibration mode, use APar.EN_CALIB_UNKNOWN to retrieve - * the user setting - */ - protected static void calibrateDensity(ACalorimeterData[] calorimeters, int mode) - { - if (mode == ENERGY_CALIB_UNKNOWN) - { - mode = parameterStore.get("LAr", "EnergyCalibration").getI(); - } - - // This array contains the calorimeter "types" to combine in the - // calibration. - String types[]; - switch (mode) - { - case ENERGY_CALIB_OVERALL: - types = new String[] { "ALL" }; - break; - - case ENERGY_CALIB_BY_TYPE: - types = new String[] { "ECAL", "HCAL" }; - break; - - case ENERGY_CALIB_BY_CALO: - default: - // Nothing to be done here. - types = new String[0]; - break; - } - - for (int i = 0; i < types.length; i++) - { - boolean first = true; - double min = 0.0; - double max = 0.0; - for (int j = 0; j < calorimeters.length; j++) - { - if (calorimeters[j].getMaxDensity(types[i]) > 0) - { - if (first) - { - min = calorimeters[j].getMinDensity(types[i]); - max = calorimeters[j].getMaxDensity(types[i]); - first = false; - } - - if (calorimeters[j].getMinDensity(types[i]) < min) - { - min = calorimeters[j].getMinDensity(types[i]); - } - if (calorimeters[j].getMaxDensity(types[i]) > max) - { - max = calorimeters[j].getMaxDensity(types[i]); - } - } - } - for (int j = 0; j < calorimeters.length; j++) - { - calorimeters[j].setMinDensity(types[i], min); - calorimeters[j].setMaxDensity(types[i], max); - } - } - } - - /** - * Draws the frame for the cell geometry of a calorimeter. All frames are - * drawn before drawing the cells themselves. This way a frame can never be - * put on top of a cell from another calorimeter. - * - * @param calorimeter ACalorimeterData data collection to which this - * function applies - * @param display ACoord cell coordinates to be drawn - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - */ - protected static void drawFrames(ACalorimeterData calorimeter, ACoord display, AWindow window, AGraphics ag) - { - - String name = calorimeter.getCalorimeterName(); - Color[] colorMap = AColorMap.getColors(); - int[] index = display.index; - int[] type = calorimeter.getType(index); - - boolean drawCellGeometry = parameterStore.get(name, "CellGeometry").getStatus(); - boolean drawFrame = parameterStore.get(name, "Frame").getStatus(); - int frameColor = parameterStore.get(name, "Frame").getI(); - //only draw frames for Grey/BW color maps if is selected to draw frames - if(drawFrame && AColorMap.drawFrames()) - drawFrame=true; - else - drawFrame=false; - - // For the v-plot we override these settings. - if (window.getProjection() instanceof AProjectionVP) - { - drawCellGeometry = parameterStore.get("VP", "VPlotIsland").getStatus(); - drawFrame = true; - frameColor = AColorMap.WH; - } - - // Draw frames for the filled cells. - if (drawFrame && drawCellGeometry) - { - for (int i = 0; i < index.length; i++) - { - ag.updateDrawParameters(calorimeter.getDrawParameters(0, type[i])); - ag.setColor(colorMap[frameColor]); - ag.drawPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - } - } - - /** - * Draws the frame for the cell geometry and outline of a calorimeter. All - * frames are drawn before drawing the cells themselves. This way a frame - * can never be put on top of a cell from another calorimeter. - * - * @param calorimeter ACalorimeterData data collection to which this - * function applies - * @param display ACoord cell coordinates to be drawn - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - */ - protected static void drawGeometry(ACalorimeterData calorimeter, ACoord display, AWindow window, AGraphics ag) - { - String name = calorimeter.getCalorimeterName(); - Color[] colorMap = AColorMap.getColors(); - int[] index = display.index; - int[] type = calorimeter.getType(index); - - boolean drawCellGeometry = parameterStore.get(name, "CellGeometry").getStatus(); - boolean drawCellOutline = parameterStore.get(name, "CellOutline").getStatus(); - boolean cutByLayer = false; - int cellGeometryColor = parameterStore.get(name, "CellGeometry").getI(); - int cellOutlineColor = parameterStore.get(name, "CellOutline").getI(); - int cutLayer = 0; - - // For the v-plot we override some of these settings. - if (window.getProjection() instanceof AProjectionVP) - { - drawCellGeometry = parameterStore.get("VP", "VPlotIsland").getStatus(); - cellGeometryColor = parameterStore.get("VP", "VPlotIsland").getI(); - - int mode = parameterStore.get("VP", "Mode").getI(); - - if (mode >= AProjectionVP.MODE_HCAL_LAYER_0) - { - cutByLayer = true; - cutLayer = mode - AProjectionVP.MODE_HCAL_LAYER_0; - } - else if (mode >= AProjectionVP.MODE_ECAL_LAYER_0) - { - cutByLayer = true; - cutLayer = mode - AProjectionVP.MODE_ECAL_LAYER_0; - } - } - - // Draw filled cells. - if (drawCellGeometry) - { - for (int i = 0; i < index.length; i++) - { - ag.updateDrawParameters(calorimeter.getDrawParameters(1, type[i])); - ag.setColor(colorMap[cellGeometryColor]); - ag.fillPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - } - - // Draw cell outlines. - if (drawCellOutline) - { - ag.updateDrawParameters(new ADrawParameters(true, cellOutlineColor, 0, 1, 0, 0, false, 1, 0)); - for (int i = 0; i < index.length; ++i) - { - if (!cutByLayer || calorimeter.getSampling(index[i]) == cutLayer) - { - ag.drawPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - } - } - } - - /** - * Draws the calorimeter hits. - * - * @param calorimeter ACalorimeterData calorimeter object the hits belong to - * @param display ACoord cell coordinates to be drawn - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - */ - protected static void drawHits(ACalorimeterData calorimeter, ACoord display, AWindow window, AGraphics ag) - { - String name = calorimeter.getCalorimeterName(); - int[] index = display.index; - int[] color = calorimeter.getColor(index); - int[] type = calorimeter.getType(index); - int[] sampling = calorimeter.getSampling(index); - - // This cut is performed just before drawing the hits, the geometry has - // been drawn already. - // This results in the irregular v-plot islands that help the user - // locate a certain position in different views. - boolean cutByLayer = false; - int cutLayer = 0; - - if (window.getProjection() instanceof AProjectionVP) - { - int mode = parameterStore.get("VP", "Mode").getI(); - - if (mode >= AProjectionVP.MODE_HCAL_LAYER_0) - { - cutByLayer = true; - cutLayer = mode - AProjectionVP.MODE_HCAL_LAYER_0; - } - else if (mode >= AProjectionVP.MODE_ECAL_LAYER_0) - { - cutByLayer = true; - cutLayer = mode - AProjectionVP.MODE_ECAL_LAYER_0; - } - } - - AParameter cellGeometry = parameterStore.get(name, "CellGeometry"); - AParameter colorFunction = parameterStore.get(name, "ColorFunction"); - boolean drawFrame = parameterStore.get(name, "Frame").getStatus(); - int frameColor = parameterStore.get(name, "Frame").getI(); - //only draw frames for Grey/BW color maps if is selected to draw frames - if(drawFrame && AColorMap.drawFrames()) - drawFrame=true; - else - drawFrame=false; - - Color[] colorMap = AColorMap.getColors(); - if (colorFunction.getI() == COLOR_FUNC_ENERGY) - { - switch (AColorMap.getColorMap()) - { - case AColorMap.COLOR_MAP_DEFAULT1: - case AColorMap.COLOR_MAP_DEFAULT2: - case AColorMap.COLOR_MAP_M4M5: - case AColorMap.COLOR_MAP_GRAYDET: - case AColorMap.COLOR_MAP_ORIGINAL: - // Use colors. - colorMap = AColorMap.getColors(AColorMap.COLOR_MAP_HITCOL); - break; - case AColorMap.COLOR_MAP_GRAY: - case AColorMap.COLOR_MAP_BW: - // Use grayscale. - colorMap = AColorMap.getColors(AColorMap.COLOR_MAP_GRAY_HITCOL); - break; - } - } - else if (colorFunction.getI() == COLOR_FUNC_TIME) - { - colorMap = AColorMap.getShades(128); - } - - if (drawFrame && !cellGeometry.getStatus()) - { - for (int i = 0; i < index.length; i++) - { - if (!cutByLayer || sampling[i] == cutLayer) - { - ag.updateDrawParameters(calorimeter.getDrawParameters(0, type[i])); - ag.setColor(colorMap[frameColor]); - ag.drawPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - } - } - - for (int i = 0; i < index.length; i++) - { - if (!cutByLayer || sampling[i] == cutLayer) - { - ag.updateDrawParameters(calorimeter.getDrawParameters(1, type[i])); - ag.setColor(colorMap[color[i]]); - ag.fillPolygon(calorimeter, index[i], display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - } - } - - /** - * Draws the calorimeter histograms. - * - * @param calorimeter ACalorimeterData calorimeter object the histograms - * belong to - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - * @param projection AProjection2D current projection - */ - protected static void drawHistogram(ACalorimeterData calorimeter, AWindow window, AGraphics ag, AProjection2D projection) - { - String name = calorimeter.getCalorimeterName(); - if (!parameterStore.get(name, "Histogram").getStatus()) - return; - - ACoord[] histograms = calorimeter.getUserHistograms(projection); - for (int i = 0; i < histograms.length; i++) - { - ACoord display = window.calculateDisplay(histograms[i]); - AHistogram hist = (AHistogram) histograms[i].source; - hist.completeTowers(display); - - // for rubberband "new list" or "summarize" feature - if (ag.getGraphics2D() instanceof ADrawnGraphics2D) - ((ADrawnGraphics2D) ag.getGraphics2D()).addHistogramData(hist); - - boolean onTop; - if (parameterStore.getUnknown(name, "OnTopHistoFrame") != null) - { - onTop = parameterStore.get(name, "OnTopHistoFrame").getStatus(); - } - else - { - onTop = false; - } - - // Draw frame for the histogram. - if (parameterStore.get(name, "HistoFrame").getStatus() && !onTop) - { - int frameColor = parameterStore.get(name, "HistoFrame").getI(); - - ag.updateDrawParameters(new ADrawParameters(true, frameColor, 0, 0, 1, 0)); - for (int j = 0; j < display.hv[0].length; j++) - { - ag.drawPolygon(display.hv[0][j], display.hv[1][j], display.hv[0][j].length); - } - } - - // Draw histogram towers. - int fillColor = parameterStore.get(name, "Histogram").getI(); - ag.updateDrawParameters(new ADrawParameters(true, fillColor, 0, 1, 0, 0)); - for (int j = 0; j < display.hv[0].length; j++) - { - ag.fillPolygon(hist, display.index[j], display.hv[0][j], display.hv[1][j], display.hv[0][j].length); - } - } - } - - /** - * Draws the calorimeter histogram frames. - * - * @param calorimeter ACalorimeterData calorimeter object the histograms - * belong to - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - * @param projection AProjection2D current projection - */ - protected static void frameHistogram(ACalorimeterData calorimeter, AWindow window, AGraphics ag, AProjection2D projection) - { - String name = calorimeter.getCalorimeterName(); - if (!parameterStore.get(name, "Histogram").getStatus()) - return; - - ACoord[] histograms = calorimeter.getUserHistograms(projection); - for (int i = 0; i < histograms.length; i++) - { - ACoord display = window.calculateDisplay(histograms[i]); - AHistogram hist = (AHistogram) display.source; - - hist.completeTowers(display); - - boolean onTop = false; - if (parameterStore.getUnknown(name, "OnTopHistoFrame") != null) - { - onTop = parameterStore.get(name, "OnTopHistoFrame").getStatus(); - } - - // Draw frame for the histogram. - if (parameterStore.get(name, "HistoFrame").getStatus() && onTop) - { - int frameColor = parameterStore.get(name, "HistoFrame").getI(); - - ag.updateDrawParameters(new ADrawParameters(true, frameColor, 0, 1, 0, 0)); - for (int j = 0; j < display.hv[0].length; j++) - { - ag.drawPolygon(display.hv[0][j], display.hv[1][j], display.hv[0][j].length); - } - } - } - } - - public static void drawEndcapHistogram(ACalorimeterData calorimeter, AWindow window, AGraphics ag, AProjection2D projection) - { - //filter the draw list for the histograms - calorimeter.filterDrawList(projection); - //Draw the histograms. - drawHistogram(calorimeter, window, ag, projection); - // Draw the frames for the histograms. - frameHistogram(calorimeter, window, ag, projection); - } - - - - /** - * getLookupTableArray() parses String[][] s with comma separated values - * (CSV) and converts each number to float lookup table value which is used - * for calorimeter real pulse shapes plots - * @param s String[][] - * @param numLookupTableValues int - * @return float[] - * @throws AAtlantisException - */ - protected static float[] getLookupTableArray(String[][] s, int numLookupTableValues) - throws AAtlantisException - { - float[] r = new float[numLookupTableValues]; - int i = 0; - for(int k = 0; k < s.length; k++) - { - for(int l = 0; l < s[k].length; l++) - { - if("".equals(s[k][l])) - { - // command and new line results into empty value - ignore - continue; - } - try - { - // there shouldn't be more than NUMBER_OF_LOOKUP_VALUES - // i.e. numLookupTableValues - if(i >= numLookupTableValues) - { - String m = "more lookup values than NUMBER_OF_LOOKUP_VALUES: " + - i + " >= " + numLookupTableValues; - throw new AAtlantisException(m); - } - r[i] = Float.valueOf(s[k][l]).floatValue(); - i++; - } - catch(NumberFormatException ex) - { - throw new AAtlantisException("number format exception: " + s[k][l]); - } - } - } - - // now the i counter shall be equal to numLookupTableValues - if(i != numLookupTableValues) - { - throw new AAtlantisException("incorrect number to items (" + i + ") " + - "in the lookup table, should be " + numLookupTableValues); - } - - // all right, return the result float array - return r; - - } // getLookupTableArray() ---------------------------------------------- - - - - /** - * Calculate real pulse shapes values based on the values in the - * lookup tables (parameters amplitude and time, etc) - - * @param xTime double - * @param cellTime double - * @param cellPedestal double - * @param energy double - * @param amplitude float[] lookup table - * @param time float[] lookup table - * @param numerOfLookupValues int - * @return double - * @throws AAtlantisException - */ - protected double getPhysicsPulseShape(double localTime, - double cellPedestal, double energy, - float[] amplitude, float[] time, - int numerOfLookupValues) - throws AAtlantisException - { - double tdiv = 0.0; - int lookup = 0; - double xpulse = 0.0; - - tdiv = time[1] - time[0]; - lookup = (int) ((localTime - time[0]) / tdiv); - - if(lookup < 0) - { - lookup = 0; - } - if(lookup >= numerOfLookupValues - 1) - { - lookup = numerOfLookupValues - 2; // -1 was off by 1 - } - - try - { - if(lookup == 0 || lookup == numerOfLookupValues - 2) - { - xpulse = amplitude[lookup]; - } - else - { - xpulse = amplitude[lookup] + ((amplitude[lookup + 1] - - amplitude[lookup]) / tdiv) * (localTime - time[lookup]); - } - } - catch(ArrayIndexOutOfBoundsException ex) - { - String m = CALORIMETER_NAME + " getPhysicsPulseShape():\n" + - " lookup index out of bound: lookup = " + lookup; - throw new AAtlantisException(m); - } - - return (xpulse * energy) + cellPedestal; - - } // getPhysicsPulseShape() --------------------------------------------- - - - - /** - * - * Events from DPD don't contain all necessary data - * if all adc counts are 0, then print info message and - * no pulse shape plot window as it may lead to confusion. - * This method is aimed to check availability of adc counts digits. - * - * @param adcCountsLocal - * @return true if any ADC counts are non-zero - */ - protected static boolean checkADCCountsAvailability(int[][] adcCountsLocal) - { - boolean adcCountsAvailable = false; - - for(int x = 0; x < adcCountsLocal.length; x++) - { - for(int y = 0; y < adcCountsLocal[0].length; y++) - { - if(adcCountsLocal[x][y] != 0) - { - adcCountsAvailable = true; - break; - } - } - if(adcCountsAvailable) - { - break; - } - } - - return adcCountsAvailable; - - } // checkADCCountsAvailability() --------------------------------------- - - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ACalorimeterRPSPLT.java b/graphics/AtlantisJava/src/atlantis/data/ACalorimeterRPSPLT.java deleted file mode 100644 index 9f8890bec80c96dc8d1c5bd907ca875c132382a8..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ACalorimeterRPSPLT.java +++ /dev/null @@ -1,260 +0,0 @@ -package atlantis.data; - -import java.util.HashMap; - -import atlantis.utils.ALogger; -import atlantis.utils.AAtlantisException; - -/** - * - * Calorimeter Real Pulse Shape Plot Lookup - * Tables. The class accommodates lookup tables (arrays) for the Tile and LAr, - * FCAL and HEC calorimeters. If the real pulse shape plots data are found in - * the event files, the corresponding arrays within this class are initialised - * from A[TILE|LAr|FCAL|HEC]Data class(es). The arrays are initialised from - * CSV (comma separated values files) just once per Atlantis session. - * - * @author Zdenek Maxa - */ -public final class ACalorimeterRPSPLT -{ - private static ALogger logger = ALogger.getLogger(ACalorimeterRPSPLT.class); - - // TILE calorimeter, lookup table time values - protected static float[] TILE_TIME = null; - // TILE calorimeter, lookup table amplitude values - protected static float[] TILE_AMPLITUDE = null; - - - // FCAL calorimeter, lookup table time values - protected static float[] FCAL_TIME = null; - // FCAL calorimeter, lookup table layer 0, amplitude values - protected static float[] FCAL_LAYER0_AMPLITUDE = null; - // FCAL calorimeter, lookup table layer 1, amplitude values - protected static float[] FCAL_LAYER1_AMPLITUDE = null; - // FCAL calorimeter, lookup table layer 2, amplitude values - protected static float[] FCAL_LAYER2_AMPLITUDE = null; - - - // HEC calorimeter, lookup table time values - protected static float[] HEC_TIME = null; - // HEC calorimeter, lookup table amplitude values - protected static float[] HEC_AMPLITUDE = null; - - - - - // LAr calorimeter, lookup tables - // for time (the same array for both - // barrel/endcap, all layer and regions and eta ranges - // currently (2009-02-11) there are 58 various arrays for LAr, it - // is not sustainable to have all these in separate arrays - for LAr - // there will be defined a container - keys are lookup tables names - // as defined in the lookup table file and values are float[] arrays - private static HashMap<String, float[]> larTables = null; - - // set the LAr table keys in a static block - // explanation of the LAr lookup tables names (the names are identical - // to comma separated values array names as in the look up table file): - // LAR_TIME - time constants - used for barrel/endcap, all layers, - // all regions, all eta ranges - // LAR_BARREL_L1_R0_AMPLITUDE - barrel, layer 1, region 0, etc, etc - // LAR_ENDCAP_L0_R0_ETA0_AMPLITUDE - endcap, layer 0, region 0, eta - // range 0 - very many of these - // bother to define the array names here to be really safe ... otherwise - // could just rely on the CSV file ... - static - { - larTables = new HashMap<String, float[]>(70); // not more arrays than 70 - - larTables.put("LAR_TIME", null); - larTables.put("LAR_BARREL_LAYER1_REGION0_AMPLITUDE", null); - larTables.put("LAR_BARREL_LAYER1_REGION1_AMPLITUDE", null); - larTables.put("LAR_BARREL_LAYER2_REGION0_AMPLITUDE", null); - larTables.put("LAR_BARREL_LAYER2_REGION1_AMPLITUDE", null); - larTables.put("LAR_BARREL_LAYER3_REGION0_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER0_REGION0_ETA0_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION0_ETA0_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION0_ETA1_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION0_ETA2_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION0_ETA3_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION0_ETA4_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION0_ETA5_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION0_ETA6_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION0_ETA7_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION1_ETA0_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION2_ETA0_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION2_ETA1_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION2_ETA2_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION2_ETA3_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION3_ETA0_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION3_ETA1_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION3_ETA2_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION4_ETA0_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION4_ETA1_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION4_ETA2_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION4_ETA3_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION4_ETA4_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER1_REGION5_ETA0_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION0_ETA0_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION0_ETA1_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION0_ETA2_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION0_ETA3_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION0_ETA4_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION0_ETA5_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION0_ETA6_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION0_ETA7_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION1_ETA0_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION1_ETA1_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION1_ETA2_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION1_ETA3_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION1_ETA4_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION1_ETA5_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION1_ETA6_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION1_ETA7_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION1_ETA8_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION1_ETA9_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER2_REGION1_ETA10_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER3_REGION0_ETA0_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER3_REGION0_ETA1_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER3_REGION0_ETA2_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER3_REGION0_ETA3_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER3_REGION0_ETA4_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER3_REGION0_ETA5_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER3_REGION0_ETA6_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER3_REGION0_ETA7_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER3_REGION0_ETA8_AMPLITUDE", null); - larTables.put("LAR_ENDCAP_LAYER3_REGION0_ETA9_AMPLITUDE", null); - } - - - - - public static boolean areFCALLookupTablesInitialized() - { - if(FCAL_LAYER0_AMPLITUDE != null && - FCAL_LAYER1_AMPLITUDE != null && - FCAL_LAYER2_AMPLITUDE != null && - FCAL_TIME != null) - { - return true; - } - else - { - return false; - } - - } // areFCALLookupTablesInitialized() ----------------------------------- - - - - public static boolean areHECLookupTablesInitialized() - { - if(HEC_TIME != null && HEC_AMPLITUDE != null) - { - return true; - } - else - { - return false; - } - - } // areHECLookupTablesInitialized() ------------------------------------ - - - - public static boolean areTileLookupTablesInitialized() - { - if(TILE_TIME != null && TILE_AMPLITUDE != null) - { - return true; - } - else - { - return false; - } - - } // areTileLookupTablesInitialized() ----------------------------------- - - - - /** - * Method is called at LAr constructor, i.e. at the beginning of each - * event to check if all lookup tables for LAr are properly initialised. - * The check is performed only when other necessary LAr are is available - * in a given event file. - * @return true if all float arrays were properly initialised - */ - public static boolean areLarLookupTablesInitialized() - { - // iterate over all keys in the container and check if all - // float arrays were properly initialised - for(String key : larTables.keySet()) - { - if(larTables.get(key) == null) - { - logger.error("LAr real pulse shapes plots lookup table " + - "\"" + key + "\" was not initialised."); - return false; - } - } - - return true; - - } // areLarLookupTablesInitialized() ------------------------------------ - - - - public static void setLarTable(String key, float[] array) throws AAtlantisException - { - logger.debug("Setting LAr pulse shapes lookup table \"" + key + "\""); - - if(larTables.containsKey(key)) - { - // it certainly already should contain the key (defined above) - if(larTables.get(key) != null) - { - throw new AAtlantisException("LAr pulse shapes lookup table \"" + - key + "\" has already been defined."); - } - else - { - larTables.put(key, array); - } - } - else - { - throw new AAtlantisException("LAr pulse shapes lookup table - " + - "entry \"" + key + "\" has not been created."); - } - - } // setLarTable() ------------------------------------------------------ - - - - public static float[] getLarTable(String key) throws AAtlantisException - { - logger.debug("Getting LAr pulse shapes lookup table \"" + key + "\""); - if(larTables.containsKey(key)) - { - float[] r = larTables.get(key); - if(r == null) - { - throw new AAtlantisException("LAr pulse shape lookup table " + - "key \"" + key + "\" is null."); - } - else - { - return r; - } - } - else - { - throw new AAtlantisException("LAr pulse shape lookup table " + - "entry \"" + key + "\" has not been created."); - } - - } // getLarTable() ------------------------------------------------------ - - -} // class ACalorimeterRPSPLT =============================================== diff --git a/graphics/AtlantisJava/src/atlantis/data/AClusterData.java b/graphics/AtlantisJava/src/atlantis/data/AClusterData.java deleted file mode 100644 index 9428320eec970424e373db4c04bb5ad156c50025..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AClusterData.java +++ /dev/null @@ -1,385 +0,0 @@ -package atlantis.data; - -import atlantis.canvas.AWindow; -import atlantis.event.AAssociation; -import atlantis.event.AData; -import atlantis.event.AEvent; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionVP; -import atlantis.utils.A3Vector; -import atlantis.utils.A4Vector; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - -/** - * Calo Clusters for the moment made from LAr cells - * - * Also contain AOD Calo Clusters from 24/10/2006 - */ -public class AClusterData extends AData -{ - protected float[] eT; - protected float[] eta; - protected float[] phi; - - public String getParameterGroup() - { - return "Cluster"; - } - - @Override - public String getName() - { - return "Cluster"; - } - - public String getNameScreenName() - { - return "Cluster"; - } - - public float getET(int index) - { - return eT[index]; - } - - public float getEta(int index) - { - return eta[index]; - } - - public float getPhi(int index) - { - return phi[index]; - } - - AClusterData(AHashMap p, AEvent e) - { - super(p,e); - - eta = p.getFloatArray("eta"); - phi = p.getFloatArray("phi"); - if (p.get("et") != null) - eT = p.getFloatArray("et"); - else - { - float[] energy = p.getFloatArray("energy"); - eT = new float[numData]; - for (int i = 0; i < numData; ++i) - eT[i] = (float) Math.abs(energy[i] * Math.cos(AMath.lambda(eta[i]))); - } - - String assocKey = getName() + getStoreGateKey(); - if (p.get("numCells") != null) - { - event.getAssociationManager().add(new AAssociation(assocKey, "LAr", p.getIntArray("numCells"), p.getIntArray("cells"),event)); - event.getAssociationManager().add(new AAssociation(assocKey, "TILE", p.getIntArray("numCells"), p.getIntArray("cells"),event)); - } - } - - protected int getDrawOrFill() - { - return AGraphics.FILL; - } - - protected void applyCuts() - { - cutIndex(); - cut("CutsCalo", "ClusterET", " |ET|", eT); - cutPhi(phi); - cutEta(eta); - } - - protected int internalColor() - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - switch (colorFunction) - { - case 0: // by constant - colorByConstant(); - break; - case 1: // by index - colorByIndex(); - break; - case 2: // by objects - colorByObjects(); - break; - } - return 3; - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n ET="+String.format("%.3f",eT[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Ex="+String.format("%.3f",eT[index]*Math.cos(phi[index]))+" GeV "+ - "\n Ey="+String.format("%.3f",eT[index]*Math.sin(phi[index]))+" GeV "+ - "\n Ez="+String.format("%.3f",eT[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - String k = this.getStoreGateKey(); - String sgKey = k != null ? k : "n/a"; - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (id: " + id[index] + " index: " + index + ")"); - msg.append("\n storegate key: "); - msg.append(sgKey); - msg.append("\n ET = "); - msg.append(String.format("%.3f",eT[index])); - msg.append(" GeV\n E = "); - msg.append(String.format("%.3f",Math.abs(eT[index]/Math.cos(AMath.lambda(eta[index]))))); - msg.append(" GeV\n "); - msg.append(AMath.ETA); - msg.append(" = "); - msg.append(String.format("%.3f",eta[index])); - msg.append("\n "); - msg.append(AMath.PHI); - msg.append(" = "); - msg.append(String.format("%.3f",Math.toDegrees(phi[index])) + AMath.DEGREES); - msg.append(" (" + String.format("%.3f",phi[index]) + " rad)"); - - return msg.toString(); - } - - public String getVPHitInfo() - { - makeDrawList(); - if (numDraw == 0) - return ""; - double sumE = 0.; - double sumET = 0.; - - for (int i = 0; i < numDraw; ++i) - { - sumET += Math.abs(eT[listdl[i]]); - sumE += Math.abs(eT[listdl[i]] / Math.cos(AMath.lambda(eta[listdl[i]]))); - } - - StringBuffer msg = new StringBuffer(""); - msg.append(numDraw); - msg.append(" "); - msg.append(getStoreGateKey() != null ? getStoreGateKey() : getNameScreenName()); - msg.append(" sum(ET) = "); - msg.append(String.format("%.1f",sumET)); - msg.append(" sum(E) = "); - msg.append(String.format("%.1f",sumE)); - - return msg.toString(); - } - - public A4Vector get4Vector(int num, int[] list) - { - A4Vector sum = new A4Vector(); - for (int i = 0; i < num; ++i) - { - int k = list[i]; - A3Vector start = A3Vector.fromRhoPhiZ(0., 0., 0.); - double tL = AMath.tanLambda(eta[k]); - A3Vector stop = A3Vector.fromRhoPhiZ(1., phi[k], tL); - A3Vector v = (stop.subtract(start)).normalize(); - double p = eT[k] / Math.sqrt(1. - v.z * v.z); - sum.add(new A4Vector(v.scale(p), 0.)); - } - - return sum; - } - - public void draw(AWindow window, AGraphics ag, AProjection2D projection) - { - if(projection instanceof AProjectionVP) - { - drawVP(window, ag, projection); - } - else - { - super.draw(window, ag, projection); - } - } - - private void drawVP(AWindow window, AGraphics ag, AProjection2D projection) - { - ACoord centers=window.calculateDisplay(getUser(projection)); - int[] drawlist=centers.index; - double eLimit=0.025; - int numPoints=25; - double[][][] hv=new double[2][drawlist.length][numPoints]; //circle - - for(int i=0; i<drawlist.length; ++i) - { - int list=drawlist[i]; - double e; - e = Math.abs(eT[list]); - int d=(int)(Math.sqrt((e/eLimit)/Math.PI)); - if(d==0) d=1; - for(int j=0; j<numPoints; j++) - { - hv[0][i][j]=centers.hv[0][0][i]+d*Math.cos(Math.PI*2*j/(numPoints-1)); - hv[1][i][j]=centers.hv[1][0][i]+d*Math.sin(Math.PI*2*j/(numPoints-1)); - } - } - ag.draw(new ACoord(hv, drawlist, this, ACoord.POLYLINES)); - } - - protected ACoord getVPUser() - { - makeDrawList(); - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index=new int[numDraw]; - - for(int i=0; i<numDraw; i++) - { - int list=listdl[i]; - h[i]=eta[list]; - v[i]=Math.toDegrees(phi[list]); - index[i]=list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("VP"); - } - - protected ACoord getYXUser() - { - makeDrawList(); - double[][][] hv = new double[2][numDraw][4]; - int[] index = new int[numDraw]; - - double dphi = Math.toRadians(0.5); - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - double phiPlus = phi[list] + dphi; - double phiMinus = phi[list] - dphi; - double cosPlus = Math.cos(phiPlus); - double sinPlus = Math.sin(phiPlus); - double cosMinus = Math.cos(phiMinus); - double sinMinus = Math.sin(phiMinus); - - // Rho range of LAr Detector (EM) is about between [148.175, 198.47] - // Rho range of TILE Detector (Had) is about between [229, 386] - double rhoMax = 380; - double rhoMinus = 155; - - double maxEnergy = parameterStore.get("Projection", "EnergyMax").getD(); - double rhoPlus = rhoMax; - if(Math.abs(eT[list]) < maxEnergy) - rhoPlus = rhoMinus + (rhoMax - rhoMinus) * Math.abs(eT[list]) / maxEnergy; - - // 4 corners of the cell area - // x0, y0 - hv[0][i][0] = rhoMinus * cosPlus; - hv[1][i][0] = rhoMinus * sinPlus; - // x1, y1 - hv[0][i][1] = rhoPlus * cosPlus; - hv[1][i][1] = rhoPlus * sinPlus; - // x2, y2 - hv[0][i][2] = rhoPlus * cosMinus; - hv[1][i][2] = rhoPlus * sinMinus; - // x3, y3 - hv[0][i][3] = rhoMinus * cosMinus; - hv[1][i][3] = rhoMinus * sinMinus; - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYGONS); - } - - protected ACoord getFRUser() - { - return getYXUser().convertYXToFR().includePhiWrapAround("FR"); - } - - protected ACoord getRZUser() - { - makeDrawList(); - double[][][] hv = new double[2][numDraw][4]; - int[] index = new int[numDraw]; - - double dtheta = Math.toRadians(0.5); - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(phi[list]-phiMid); - double rSign; - if (phiDiff > Math.PI/2. && phiDiff <= 3*Math.PI/2.) - rSign = -1; - else - rSign = 1; - - // calculate theta based on the eta value - double theta = Math.atan(Math.exp(-Math.abs(eta[list]))) * 2.0; - if ((eta[list] > 0.) && (rSign == -1)) - theta = 2 * Math.PI - theta; - else if ((eta[list] < 0.) && (rSign == -1)) - theta += Math.PI; - else if ((eta[list] < 0.) && (rSign == 1)) - theta = Math.PI - theta; - - double thetaPlus = theta + dtheta; - double thetaMinus = theta - dtheta; - double cosPlus = Math.cos(thetaPlus); - double sinPlus = Math.sin(thetaPlus); - double cosMinus = Math.cos(thetaMinus); - double sinMinus = Math.sin(thetaMinus); - - // decide the region based on the theta value - final byte LAR = 0; - final byte LAR_ENDCAP = 1; - final byte FCAL_EM = 2; - byte region = LAR; - // hard-coded value is based on the values in AGeometry.xml - if(Math.abs(Math.tan(theta)) >= 0.0778 && Math.abs(Math.tan(theta)) < 0.4828) - region = LAR_ENDCAP; - else if(Math.abs(Math.tan(theta)) < 0.0778) - region = FCAL_EM; - - double radiusMinus = 0.; - switch(region) - { - // use fixed rho/z to determine the lower radius value - case LAR: - radiusMinus = 155 / Math.abs(Math.sin(theta)); - break; - case LAR_ENDCAP: - radiusMinus = 380 / Math.abs(Math.cos(theta)); - break; - case FCAL_EM: - radiusMinus = 470 / Math.abs(Math.cos(theta)); - break; - } - double radiusMax = radiusMinus + 200; - double maxEnergy = parameterStore.get("Projection", "EnergyMax").getD(); - double radiusPlus = radiusMax; - if(Math.abs(eT[list]) < maxEnergy) - radiusPlus = radiusMinus + (radiusMax - radiusMinus) * Math.abs(eT[list]) / maxEnergy; - - // 4 corners of the cell area - // x0, y0 - hv[0][i][0] = radiusMinus * cosPlus; - hv[1][i][0] = radiusMinus * sinPlus; - // x1, y1 - hv[0][i][1] = radiusPlus * cosPlus; - hv[1][i][1] = radiusPlus * sinPlus; - // x2, y2 - hv[0][i][2] = radiusPlus * cosMinus; - hv[1][i][2] = radiusPlus * sinMinus; - // x3, y3 - hv[0][i][3] = radiusMinus * cosMinus; - hv[1][i][3] = radiusMinus * sinMinus; - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYGONS); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ACompositeParticleData.java b/graphics/AtlantisJava/src/atlantis/data/ACompositeParticleData.java deleted file mode 100755 index 5537e5b0331f2416d521b5b01c8c236319ecab1b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ACompositeParticleData.java +++ /dev/null @@ -1,114 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - -/** - * Reconstructed CompositeParticle - */ -public class ACompositeParticleData extends AAODData -{ - private int[] pdgId; - private float[] charge; - private String[] label; - private String[] typeEV; - - ACompositeParticleData(AHashMap p, AEvent e) - { - super(p,e); - pdgId = p.getUnsureIntArray("pdgId"); - charge=p.getUnsureFloatArray("charge"); - label=p.getStringArray("label"); - typeEV=p.getStringArray("typeEV"); - } - - public String getParameterGroup() - { - return "CompositeParticle"; - } - - @Override - public String getName() - { - return "CompositeParticle"; - } - - public int getPdgId(int index) - { - return pdgId[index]; - } - - public float getCharge(int index) - { - return charge[index]; - } - - public String getLabel(int index) - { - return label[index]; - } - - public String getTypeEV(int index) - { - return typeEV[index]; - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n PT="+String.format("%.3f",pT[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Px="+String.format("%.3f",pT[index]*Math.cos(phi[index]))+" GeV "+ - "\n Py="+String.format("%.3f",pT[index]*Math.sin(phi[index]))+" GeV "+ - "\n Pz="+String.format("%.3f",pT[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - String k = this.getStoreGateKey(); - String sgKey = k != null ? k : "n/a"; - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" = "); - msg.append(id[index]); - msg.append("\n storegate key: "); - msg.append(sgKey); - msg.append("\n PT = "); - msg.append(String.format("%.3f",pT[index])); - msg.append(" GeV\n P = "); - msg.append(String.format("%.3f",Math.abs(pT[index]/Math.cos(AMath.lambda(eta[index]))))); - msg.append(" GeV\n "); - msg.append(AMath.ETA); - msg.append(" = "); - msg.append(String.format("%.3f",eta[index])); - msg.append("\n "); - msg.append(AMath.PHI); - msg.append(" = "); - msg.append(String.format("%.3f",Math.toDegrees(phi[index]))); - msg.append(AMath.DEGREES); - msg.append(" (" + String.format("%.3f",phi[index]) + " rad)"); - - if (charge != null) - { - msg.append("\n Charge = "); - msg.append(charge[index]); - } - if(pdgId != null) - { - if(pdgId[index]!=0) - msg.append("\n Type = " + APDGTable.getName(pdgId[index]) + " (type code " + pdgId[index] + ")" ); - else - msg.append("\n Type = unknown (type code " + pdgId[index] + ")" ); - } - msg.append("\n TypeEV = " + typeEV[index]); - if (label != null) - msg.append("\n Label = " + label[index]); - return msg.toString(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ADHelix.java b/graphics/AtlantisJava/src/atlantis/data/ADHelix.java deleted file mode 100755 index 6e1228528da961a623534f83a5a4e259dfb17823..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ADHelix.java +++ /dev/null @@ -1,539 +0,0 @@ -package atlantis.data; - -import java.awt.geom.Point2D; -import java.util.Vector; -import java.awt.Rectangle; - -import atlantis.canvas.AWindow; -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.graphics.ACoord; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjection3D; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionXZ; -import atlantis.utils.ALogger; -import atlantis.utils.AMath; - -/** - * Helix in a format suitable for drawing given as a circle with - * centre point and radius etc. - * - * phi is the angle seen from the primary vertex - * a = alpha = the angle as seen for the center of the circle - * - */ -public class ADHelix -{ - private final static ALogger logger = ALogger.getLogger(ADHelix.class); - - // parameters used internally - private static final APar parameterStore = APar.instance(); - private static final AParameter rToPar = parameterStore.get("RTr", "RadiusTr"); - private static final AParameter lToPar = parameterStore.get("RTr", "LineTr"); - private static final AParameter zToPar = parameterStore.get("RTr", "ZTr"); - private static final int callDepthCut = parameterStore.get("RTr", "CallDepth").getI();; - - /** The associated helix object. */ - public final AHelix helix; - - // description of helix - private final double rC, xC, yC, ch, a0, x0, y0, z0, bz, cosA0, sinA0; - // position along helix - private final double aStart, aEnd; - - /** Attempt to encapsulate the "current position" variables. */ - private static class HelixPoint { - double x, y, z, rho, phi; - } - - private double startPhi; // the phi value of starting point of "v" - // TODO: Would prefer this not to be part of the state of the helix object. - private boolean startMark; // true when calculating start point, false otherwise - - ADHelix(AOldHelix h) { - this(new AHelix(h)); - } - - ADHelix(AHelix h) - { - helix = h; - double[] perigee = h.getPar(); // d0, z0, phi0, cotanTheta, q/pT - - AParameter curvatureParameter = parameterStore.get("Event", "Curvature"); - if (curvatureParameter != null) { - rC = curvatureParameter.getD() / Math.abs(perigee[4]); - } else { - rC = (100/0.6) / Math.abs(perigee[4]); - } - ch = AMath.getSign(perigee[4]); - a0 = Math.toDegrees(perigee[2]) + ch * 90.; - double a0Rad = Math.toRadians(a0); - cosA0 = Math.cos(a0Rad); - sinA0 = Math.sin(a0Rad); - z0 = perigee[1]; - double d0 = perigee[0]; - double signD0 = ch; - d0 *= signD0; - x0 = d0 * cosA0; - y0 = d0 * sinA0; - double SD0 = 1.; - double SRC = 1.; - double r0 = SD0 * d0 - SRC * rC; - xC = r0 * cosA0; - yC = r0 * sinA0; - bz = rC * Math.toRadians(perigee[3]); - double rTo = rToPar.getD(); - //Check if track is limited by end vertex - if ( helix.getRhoEndVertex() > 0. ) - rTo = Math.min(rTo,helix.getRhoEndVertex()); - double zTo = zToPar.getD(); - /*******************************************************************************/ - //Adrian Vatchinsky, Andy Haas (NYU) - //Import the coordinates of the primary vertex in order to calculate new starting angle - AEventManager eventManager = AEventManager.instance(); - AEvent currentEvent = eventManager.getCurrentEvent(); - if (helix.getRho(helix.getAlphaMin())!=0 || currentEvent==null) { // FIXME: doubles compared for equality - aStart = helix.getAlphaMin(); // old, DCA to 0,0 - } else { // new, DCA to PV - double[] primaryVertex = currentEvent.getPrimaryVertex(); - double xV = primaryVertex[0]; double yV = primaryVertex[1]; - aStart = helix.getAlphaMin() + ch*Math.toDegrees(Math.atan2(yC,xC)-Math.atan2(yC-yV,xC-xV)); - } - /*******************************************************************************/ - HelixPoint point = pointAt(aStart); - // don't draw tracks starting outside the tracking region - if(Math.abs(point.rho) > rTo || Math.abs(point.z) > zTo) - { - this.aEnd = aStart; - return; - } - //Calculate max phi angle -> no track can have more than 180 deg - double aEndMax = Math.min(aStart + 180., 180.); - //Also the track should not stick out of the rTo zylinder - double aEndR = intersectWithRadialCylinder(rTo, aStart, aEndMax); - // nor should it go beyond the max. z-extension - double aEndZ = intersectWithZPlanes(zTo, aStart, aEndMax); // or beyond the end-vertex radius, if given - double aEndTmp = Math.min(aEndMax, aEndR); - if(aEndZ > aStart) aEndTmp = Math.min(aEndTmp, aEndZ); - this.aEnd = Math.min(aEndTmp, aEndMax); - } - - - // calculate phi on track at intersection - // Cylinder is infinite in Z direction - public double intersectWithRadialCylinder(double rCyl, double aStart, - double aEnd) - { - if(rC <= 0.) return aStart; - double r0 = Math.sqrt(xC * xC + yC * yC); - double bb = (rCyl * rCyl - rC * rC - r0 * r0) / (2. * rC * r0); - double rhoStart = getRho(aStart); - double rhoEnd = getRho(aEnd); - if(rCyl >= rhoStart && rCyl >= rhoEnd) return aEnd; - if(rCyl <= rhoStart && rCyl <= rhoEnd) return aStart; - if(Math.abs(bb) > 1.) - { - // needs to be understood better (Hans) - // event file: acr_muontrack_problem_event.xml - logger.warn("Bug in ADHelix " + rCyl + " " + rhoStart + " " + rhoEnd); - return aEnd; - } - double cc = Math.toDegrees(Math.acos(bb)); - if(Math.abs(cc) > 360) - throw new Error("error in cc in dhelix"); - double gA = Math.toDegrees(Math.atan2(yC, xC)); - double a1 = ch * (a0 - gA + cc); - double a2 = ch * (a0 - gA - cc); - if(a1 < 0.) a1 += 360.; - if(a2 < 0.) a2 += 360.; - if(a1 >= 360.) a1 -= 360.; - if(a2 >= 360.) a2 -= 360.; - return Math.min(a1, a2); - } - - - // calculate phi on track at intersection - public double intersectWithZPlanes(double zCyl, double aStart, double aEnd) - { - double zMin = 20.; - double aZ = aEnd; - if(zCyl >= zMin && bz != 0.) - { - double aZPlus = (zCyl - z0) / bz; - double aZMinus = ( -zCyl - z0) / bz; - if(aZPlus < aZ && aZPlus > aStart) aZ = aZPlus; - if(aZMinus < aZ && aZMinus > aStart) aZ = aZMinus; - } - return aZ; - } - - - // calculate phi on track at intersection - // cylinder finite in Z - public double intersectWithCylinder(boolean useR, double rCyl, boolean useZ, - double zCyl) - { - double aStart = 0.; - double aEndMax = 180.; - double zMin = 20.; - double aEndR = 0.; - if(useR) - aEndR = intersectWithRadialCylinder(rCyl, aStart, aEndMax); - double aEndZ = 0.; - if(useZ && zCyl >= zMin && bz != 0.) - { - aEndZ = intersectWithZPlanes(zCyl, aStart, aEndMax); - return Math.min(aEndR, aEndZ); - } - else - return aEndR; - } - - - // a... angle in deg starting with 0 meaning point of closest approach - private HelixPoint pointAt(double a) - { - HelixPoint point = new HelixPoint(); - double aRad = Math.toRadians(a0 - ch * a); - point.x = x0 + rC * (Math.cos(aRad) - cosA0); - point.y = y0 + rC * (Math.sin(aRad) - sinA0); - point.z = z0 + bz * a; - double[] primaryVtx = AParameterUtilities.getPrimaryVertex(); - double dx = point.x - primaryVtx[0]; - double dy = point.y - primaryVtx[1]; - point.rho = Math.sqrt(dx * dx + dy * dy); - double phi0 = Math.toDegrees(Math.atan2(dy, dx)); - double phiMid2 = parameterStore.get("RZ", "Phi").getD(); - point.phi = AMath.nearestPhiDegrees(phi0,phiMid2); - return point; - } - - - // s1 and s2 are the extreme values of phi - // used to avoid tracks being drawn with phi discontinuity - // in phi projections - // = FiMid in atlantis fortran ask Hans Drevermann - public double setPhiStart(double s1, double s2) - { - double phi1 = getPhi(s1); - double phi2 = getPhi(s2); - double phiM = getPhi((s1 + s2) / 2); - // doesn't work for all tracks but for most - if(Math.abs(phi1 - phi2) > 180. || Math.abs(phi1 - phiM) > 180. || - Math.abs(phi2 - phiM) > 180.) - { - if(phi1 - phiM > 180.) phi1 -= 360.; - if(phi2 - phiM > 180.) phi2 -= 360.; - if(phi1 - phiM < -180.) phi1 += 360.; - if(phi2 - phiM < -180.) phi2 += 360.; - - // must be something wrong here, phiM is the same using the - // following code, then why use if ... else ... - if(phi1 < phiM && phiM < phi2) - phiM = (phi1 + phi2) / 2.; - else if(phi1 > phiM && phiM > phi2) - phiM = (phi1 + phi2) / 2.; - else - { - phiM = (phi1 + phi2) / 2.; - } - } - if(phiM > 360.) - phiM -= 360.; - if(phiM < 0.) - phiM += 360.; - return phiM; - } - - - public double getAStart() - { - return aStart; - } - - - public double getAEnd() - { - return aEnd; - } - - - public ACoord getYXPoint(double a) - { - HelixPoint point = pointAt(a); - return new ACoord(point.x, point.y, -1); - } - - - public ACoord getRZPoint(double a) - { - HelixPoint point = pointAt(a); - double phiMid2 = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(Math.toRadians(point.phi) - phiMid2); - if(phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - return new ACoord(point.z, point.rho, -1); - else - return new ACoord(point.z, -point.rho, -1); - } - - - public ACoord get3DPoint(double a) - { - HelixPoint point = pointAt(a); - double[] point3D = {point.x,point.y,point.z}; - point3D = AProjection3D.getRotated(point3D); - return new ACoord(point3D[0], point3D[1], -1); - } - - - public double[] get3DPointAsArray(double a) - { - HelixPoint point = pointAt(a); - double[] point3D = new double[] {point.x, point.y, point.z }; - point3D = AProjection3D.getRotated(point3D); - return point3D; - } - - - public ACoord getXZPoint(double a) - { - HelixPoint point = pointAt(a); - double phiC = AProjectionXZ.getPhi(); - return new ACoord(point.z, point.rho * Math.cos(Math.toRadians(point.phi - phiC)), -1); - } - - - public ACoord getYZPoint(double a) - { - HelixPoint point = pointAt(a); - double phiC = AProjectionXZ.getPhi(); - return new ACoord(point.z, point.rho * Math.sin(Math.toRadians(point.phi - phiC)), -1); - } - - - public ACoord getFZPoint(double a) - { - HelixPoint point = pointAt(a); - double temp = Math.toDegrees(AParameterUtilities.getPhiStereo(point.rho, Math.toRadians(point.phi), point.z)); - return new ACoord(point.z, temp, -1); - } - - - public ACoord getFRPoint(double a) - { - HelixPoint point = pointAt(a); - double temp = Math.toDegrees(AParameterUtilities.getPhiStereo(point.rho, Math.toRadians(point.phi), point.z)); - return new ACoord(point.rho, temp, -1); - } - - - public ACoord getVPPoint(double a, int sign) - { - HelixPoint point = pointAt(a); - if(startMark) // start point - { - startPhi = point.phi; // phi is between 0 and 360 - } - else - { - point.phi = AMath.nearestPhiDegrees(point.phi, startPhi); - } - return new ACoord(AParameterUtilities.eta(point.z, point.rho) + - sign * AProjectionVP.getDeltaEta(point.rho, point.z), point.phi, -1); - } - - - public ACoord getLEGOPoint(double a) - { - //added by Mark Stockton - HelixPoint point = pointAt(a); - double temp = Math.toDegrees(AParameterUtilities.getPhiStereo(point.rho, Math.toRadians(point.phi), point.z)); - return new ACoord(AParameterUtilities.eta(point.z, point.rho), temp, -1); - } - - - public double getPhi(double a) - { - HelixPoint point = pointAt(a); - return point.phi; - } - - - public double getEta(double a) - { - HelixPoint point = pointAt(a); - return AParameterUtilities.eta(point.z, point.rho); - } - - - private double getRho(double a) - { - HelixPoint point = pointAt(a); - return point.rho; - } - - - /** Draw helix in display space in an iterative manner. */ - public ACoord drawHelix(AWindow window, AProjection2D projection, double s1, double s2) - { - Vector<Point2D.Double> pointsOnHelix = new Vector<Point2D.Double>(100); - double dPrevious = 999.; - int callDepth = 0; - // get the point at the beginning and end of the helix, defined by the phi-values (s1,s2) - startMark = true; - ACoord d1 = window.calculateDisplay(projection.getUserPoint(this, s1)); - double h1 = d1.hv[0][0][0]; - double v1 = d1.hv[1][0][0]; - startMark = false; - ACoord d2 = window.calculateDisplay(projection.getUserPoint(this, s2)); - double h2 = d2.hv[0][0][0]; - double v2 = d2.hv[1][0][0]; - pointsOnHelix.add(new Point2D.Double(h1, v1)); - // We are simply adding points here, in the end the helix is drawn as a polyline - drawHelix(pointsOnHelix, window, projection, s1, h1, v1, s2, h2, v2, - dPrevious, callDepth); - int numPoints; - if(projection instanceof AProjectionVP) - { - numPoints = pointsOnHelix.size(); - } - else - { - numPoints = pointsOnHelix.size() + 1; // add 1 to add a point for the line - } - double[][][] hv = new double[2][1][numPoints]; - int[] index = new int[1]; - Point2D.Double p; - if(projection instanceof AProjectionVP) - { - for(int k = 0; k < numPoints; ++k) - { - p = (Point2D.Double) pointsOnHelix.elementAt(k); - hv[0][0][k] = p.getX(); - hv[1][0][k] = p.getY(); - } - } - else - { - for(int k = 0; k < numPoints - 1; ++k) - { - p = (Point2D.Double) pointsOnHelix.elementAt(k); - hv[0][0][k] = p.getX(); - hv[1][0][k] = p.getY(); - } // first attempt for line... - if(numPoints > 2) - { - double dx = hv[0][0][numPoints - 2] - hv[0][0][numPoints - 3]; - double dy = hv[1][0][numPoints - 2] - hv[1][0][numPoints - 3]; - double x0 = hv[0][0][numPoints - 2] - hv[0][0][0]; - double y0 = hv[1][0][numPoints - 2] - hv[1][0][0]; - - // InDet -> Track -> Rho Track linearly is 0 by default - // and the value is meant beyond Rho Track as Helix parameter, - // hence rToPar + lToPar is used instead of former lToPar only - double dtopar = ( (rToPar.getD() + lToPar.getD()) / rToPar.getD()) * - Math.sqrt(x0 * x0 + y0 * y0); - double cophi = dx / Math.sqrt(dx * dx + dy * dy); - double siphi = dy / Math.sqrt(dx * dx + dy * dy); - double addl = Math.sqrt((y0 * siphi + x0 * cophi) * - (y0 * siphi + x0 * cophi) - - x0 * x0 - y0 * y0 + dtopar * dtopar); - double addlen = Math.min(Math.abs( -(y0 * siphi + x0 * cophi) + - addl), - Math.abs( -(y0 * siphi + x0 * cophi) - - addl)); - hv[0][0][numPoints - 1] = x0 + addlen * cophi + hv[0][0][0]; - hv[1][0][numPoints - 1] = y0 + addlen * siphi + hv[1][0][0]; - } - } - return new ACoord(hv, index); - } - - - /** Called recursively. */ - private void drawHelix(Vector<Point2D.Double> pointsOnHelix, AWindow window, AProjection2D projection, - double s1, double h1, double v1, double s2, double h2, double v2, - double dPrevious, int callDepth) - { - double D_MAX = 1.; - double h21 = h2 - h1; - double v21 = v2 - v1; - // nothing left to draw - if(h21 == 0. && v21 == 0.) - return; - // calculate midpoint - double sM = 0.5 * (s1 + s2); - ACoord dispM = window.calculateDisplay(projection.getUserPoint(this, sM)); - double hM = dispM.hv[0][0][0]; - double vM = dispM.hv[1][0][0]; - - // For speed reasons we make sure we aren't doing a lot of subdivison - // on helix segments outside the view area - boolean isinview = true; - - if (callDepth > 2) { - // Check if bounding box of segment is on the screen anywhere - // Don't try this until we've divided a few times just in case we - // have a really curly helix to deal with - Rectangle wdim = window.getCurrDisp(); - - int left = (int)h1; - int top = (int)v1; - int width = (int)(h2 - h1); - int height = (int)(v2 - v1); - - // Make sure the box isn't upside down or zero in size as this - // seemed to be causing a few problems - if (width < 0) { left += width; width = -width; } - if (height < 0) { top += height; height = -height; } - if (width == 0) { width = 1; } - if (height == 0) { height = 1; } - - Rectangle bound = new Rectangle(left, top, width, height); - - if (!wdim.intersects(bound)) { - // Prevent any further sub-division - isinview = false; - } - } - - // calculate distance of midpoint from straight line approximation - double hM1 = hM - h1; - double vM1 = vM - v1; - double temp = (v21 * hM1 - h21 * vM1); - double dM = temp * temp / (v21 * v21 + h21 * h21); - // this iteration and previous one within tolerance - if(dPrevious < D_MAX && dM < D_MAX) - { - pointsOnHelix.add(new Point2D.Double(h2, v2)); - } - else - { - if(callDepth < callDepthCut && isinview) - { - // split track in two and iterate - drawHelix(pointsOnHelix, window, projection, s1, h1, v1, sM, hM, - vM, dM, callDepth + 1); - drawHelix(pointsOnHelix, window, projection, sM, hM, vM, s2, h2, - v2, dM, callDepth + 1); - } - else - { - pointsOnHelix.add(new Point2D.Double(hM, vM)); - pointsOnHelix.add(new Point2D.Double(h2, v2)); - } - } - } - - public double getxC() { - return xC; - } - - public double getyC() { - return yC; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AETMisData.java b/graphics/AtlantisJava/src/atlantis/data/AETMisData.java deleted file mode 100644 index 2bba9e11185bc0f365dba5192f7e5658cce25e72..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AETMisData.java +++ /dev/null @@ -1,562 +0,0 @@ -package atlantis.data; - -import atlantis.event.AData; -import atlantis.canvas.AWindow; -import atlantis.event.AEvent; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - -import java.awt.Stroke; -import java.awt.BasicStroke; -import java.awt.geom.Point2D; - -/** - * AETMisData - Missing ET class implementation. Although it is always - * supposed that there will be only 1 item of the datatype, it's now done - * generically as a normal datatype (assuming there is numData items, this - * numData shall always be 1 for ETMis) - */ -public class AETMisData extends AData { - // data read in from the event file - - protected float[] et; - protected float[] etx; - protected float[] ety; - // calculated data - protected float[] sumet; - protected float[] phi; // in radians - protected final int YX_NUMPOINTS = 200; - - AETMisData(AHashMap p, AEvent e) throws AAtlantisException { - super(p, e); - - sumet = p.getFloatArray("et"); - etx = p.getFloatArray("etx"); - ety = p.getFloatArray("ety"); - - et = new float[numData]; - phi = new float[numData]; - for (int i = 0; i < numData; i++) { - et[i] = (float) Math.sqrt(etx[i] * etx[i] + ety[i] * ety[i]); - - phi[i] = (float) Math.atan2(ety[i], etx[i]); - if (phi[i] < 0.0) { - phi[i] += AMath.TWO_PI; - } - } - - } // AETMisData() ------------------------------------------------------- - - /** - * Assuming there is only one item in the ETMis datatype which shall - * always be, but the rest of the class is more generic (the 0 index) - * @return float - */ - public float getET() { - return et[0]; - - } // getET() ------------------------------------------------------------ - - /** - * Assuming there is only one item in the ETMis datatype which shall - * always be, but the rest of the class is more generic (the 0 index) - * @return float - */ - public float getETx() { - return etx[0]; - - } // getETx() ----------------------------------------------------------- - - /** - * Assuming there is only one item in the ETMis datatype which shall - * always be, but the rest of the class is more generic (the 0 index) - * @return float - */ - public float getETy() { - return ety[0]; - - } // getETy() ----------------------------------------------------------- - - /** - * Assuming there is only one item in the ETMis datatype which shall - * always be, but the rest of the class is more generic (the 0 index) - * @return float - */ - public float getPhi() { - return phi[0]; - - } // getPhi() ----------------------------------------------------------- - - /** - * Returns info string for picking. - * @param index - * @return info string - */ - public String getHitInfo(int index) { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if (simpleOutput > 0) { - String output = getNameScreenName() + " index: " + index; - if (simpleOutput == 1 || simpleOutput == 3) { - output += "\n ET=" + String.format("%.3f", et[index]) + " GeV\n " - + AMath.PHI + " = " + String.format("%.3f", Math.toDegrees(phi[index])) + AMath.DEGREES; - } - if (simpleOutput == 2 || simpleOutput == 3) { - output += "\n Ex=" + String.format("%.3f", et[index] * Math.cos(phi[index])) + " GeV " - + "\n Ey=" + String.format("%.3f", et[index] * Math.sin(phi[index])) + " GeV "; - } - return output; - } - - String msg; - - msg = getNameScreenName() + "\n"; - msg += " storegate key: "; - msg += (storeGateKey == null ? "n/a" : storeGateKey) + "\n"; - msg += " Sum-ET = " + String.format("%.3f", sumet[index]) + " GeV" + "\n" - + " ET-Mis = " + String.format("%.3f", et[index]) + " GeV" + "\n" - + " ETx-Mis = " + String.format("%.3f", etx[index]) + " GeV" + "\n" - + " ETy-Mis = " + String.format("%.3f", ety[index]) + " GeV" + "\n" - + " " + AMath.PHI + " = " - + String.format("%.3f", Math.toDegrees(phi[index])) - + AMath.DEGREES + " (" + String.format("%.3f", phi[index]) + " rad)"; - - return msg; - - } // getHitInfo() ------------------------------------------------------- - - /** - * Info on ETMis contained in v-plot rubberband selection - * @return String - */ - public String getVPHitInfo() { - makeDrawList(); - if (numDraw == 0) { - return ""; - } - - double sumEt = 0.0; - for (int i = 0; i < numDraw; i++) { - sumEt += Math.abs(et[i]); - } - - String key = getStoreGateKey(); - String msg = numDraw + " " + (key != null ? "" + key : getNameScreenName()); - msg += " ET = " + String.format("%.1f", sumEt); - return msg; - - } // getVPHitInfo() ----------------------------------------------------- - - /** - * getParameterGroup() - * @return parameter group - */ - public String getParameterGroup() { - return "ETMis"; - - } // getParameterGroup() ------------------------------------------------ - - public String getName() { - return "ETMis"; - - } // getName() ---------------------------------------------------------- - - public String getNameScreenName() { - return "ETMis"; - - } // getNameScreenName() ------------------------------------------------ - - /** - * internalColor() - * Implement this atlantis.event.AData method - * Coloring of the graphical object on the canvas - * @return number of color types - */ - protected int internalColor() { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - if (colorFunction == 0) { - colorByConstant(); - } else if (colorFunction == 1) { - colorByIndex(); - } else if (colorFunction == 2) { - colorByCollection(); - } - - return 3; - - } // internalColor() ---------------------------------------------------- - - - public void draw(AWindow window, AGraphics ag, AProjection2D projection) - { - //option to scale line width by energy - Stroke origStroke = ag.getGraphics2D().getStroke(); - if(parameterStore.getUnknown("ETMis", "LineWidth").getI()==0){ - float factor=0.f; - if(et[0]<5){ - factor=1.0f; - }else if(et[0]<10.){ - factor=1.5f; - }else if(et[0]<15.){ - factor=2.0f; - }else if(et[0]<20.){ - factor=2.5f; - }else if(et[0]<25.){ - factor=3.0f; - }else if(et[0]<30.){ - factor=3.5f; - }else if(et[0]<35.){ - factor=4.0f; - }else if(et[0]<40.){ - factor=4.5f; - }else{ - factor=5.0f; - } - ag.getGraphics2D().setStroke(new BasicStroke(factor)); - } - - if(projection instanceof AProjectionYX) - { - // check config whether to draw as arrow or dashed line.. - if(parameterStore.get("ETMis", "Drawas").getI() == 0) // Arrow = 0, Dashed = 1 - { - drawArrow(window, ag, projection); - } - else - { - drawDashed(window, ag, projection); - } - } - else if(projection instanceof AProjectionVP) - { - // Draw ETMis in VPlot... - ACoord centers = window.calculateDisplay(getUser(projection)); - int[] drawlist = centers.index; - double eLimit = 0.05; - final int numPoints = 25; - // hv will contain all the coordinates - // [2] - x and y value - // [drawlist.length] - should be "3" for ET Miss object by default - // after the PhiWrap - // [numPoints] - number of points required for drawing Et missing - // object in V-Plot - double[][][] hv = new double[2][drawlist.length][numPoints]; - - for(int i = 0; i < drawlist.length; ++i) - { - int list = drawlist[i]; - - int d = (int) (Math.sqrt((this.et[list] / eLimit) / Math.PI)); - if(d == 0) - { - d = 1; - } - - for(int j = 0; j < numPoints; j++) - { - hv[0][i][j] = centers.hv[0][list][i] + - d * Math.cos(Math.PI * 2 * j / (numPoints - 1)); - hv[1][i][j] = centers.hv[1][list][i] + - d * Math.sin(Math.PI * 2 * j / (numPoints - 1)); - } - } - ag.draw(new ACoord(hv, drawlist, this, ACoord.DOTTED_POLYGONS)); - } - else - { - super.draw(window, ag, projection); - } - //reset stroke if have changed to scale with energy - if(parameterStore.getUnknown("ETMis", "LineWidth").getI()==0) - ag.getGraphics2D().setStroke(origStroke); - } - - /** - * drawArrow() - * Method performs the drawing of the object on the canvas as arrow. - * @param window - * @param ag - * @param projection - */ - public void drawArrow(AWindow window, AGraphics ag, AProjection2D projection) - { - ACoord centers = window.calculateDisplay(getUser(projection)); - - int[] drawlist = centers.index; // draw everything in array - - // scale the arrowhead with zoom... - double zoomScaling=0; - Point2D.Double[] corners = window.getUserCorners(); - double widthx=corners[1].x-corners[0].x; - double widthy=corners[0].y-corners[2].y; - //average width of window - double width=Math.sqrt(widthx*widthx+widthy*widthy); - //calculate scaling (100 is arbitrary constant) - zoomScaling=100/width; - double arrowheadScale = 10+10*zoomScaling*Math.log(et[0]+1); - - // phiPrime represents the angle of the missingET arrow - double phiPrime = -1*Math.atan2(ety[0],etx[0]); - - // arrowMain contains the start point and end point of the arrow - double[][][]arrowMain = new double[2][drawlist.length][2]; - - // scale arrow length with etmiss - double arrowScale = et[0]*et[0]/250.0; //arbitrary scaling factor - double arrowCenter = 2.02; // this sets the starting point of the arrow. 2.02 ~ edge of ID - if (arrowScale > 8) { - arrowScale = 8; - } - for (int i = 0; i < drawlist.length; i++) { - for (int j = 0; j < 2; j++) { - arrowMain[0][i][j] = centers.hv[0][i][0] + (arrowCenter + arrowScale * j)*(centers.hv[0][i][1]-centers.hv[0][i][0]); - arrowMain[1][i][j] = centers.hv[1][i][0] + (arrowCenter + arrowScale * j)*(centers.hv[1][i][1]-centers.hv[1][i][0]); - } - } - double[][][]arrowHead1 = new double[2][drawlist.length][2]; - double[][][]arrowHead2 = new double[2][drawlist.length][2]; - for(int i = 0; i < drawlist.length; i++) - { - for(int j=0;j<2;j++) - { - // set the points for the two parts of the arrow head - // 2.591 and 3.691 are the factors to add to the arrow's angle for the correct arrowhead orientation... - arrowHead1[0][i][j] = arrowMain[0][0][1] + j*(arrowheadScale*Math.cos(2.591+phiPrime)); - arrowHead1[1][i][j] = arrowMain[1][0][1] + j*(arrowheadScale*Math.sin(2.591+phiPrime)); - arrowHead2[0][i][j] = arrowMain[0][0][1] + j*(arrowheadScale*Math.cos(3.691+phiPrime)); - arrowHead2[1][i][j] = arrowMain[1][0][1] + j*(arrowheadScale*Math.sin(3.691+phiPrime)); - } - } - // draw arrow, 3 parts, main arrow body and two lines for arrowhead - ag.draw(new ACoord(arrowMain, drawlist, this, ACoord.DOTTED_POLYGONS)); - ag.draw(new ACoord(arrowHead1, drawlist, this, ACoord.DOTTED_POLYGONS)); - ag.draw(new ACoord(arrowHead2, drawlist, this, ACoord.DOTTED_POLYGONS)); - - } // drawArrow() ------------------------------------------------------------- - - /** - * drawDashed() - * Method performs the drawing of the object on the canvas as a dashed line. - * @param window - * @param ag - * @param projection - */ - public void drawDashed(AWindow window, AGraphics ag, AProjection2D projection) - { - //Stop Etmiss being scaled by Fisheye - boolean origStatus = parameterStore.get(projection.getName(), "FishEye").getStatus(); - parameterStore.get(projection.getName(), "FishEye").setStatus(false); - ACoord centers = window.calculateDisplay(getUser(projection)); - if(origStatus) parameterStore.get(projection.getName(), "FishEye").setStatus(origStatus); - - int[] drawlist = centers.index; // draw everything in array - // hv will contain all the the coordinates - // [2] - x and y value - // [numData] - should be "1" for ETMis datatype - // [YX_NUMPOINTS] - number of points required for ET Miss object - - // length of drawlist should always be 1 -> only 1 iteration - double[][][] hv = new double[2][drawlist.length][YX_NUMPOINTS]; - for(int i = 0; i < drawlist.length; i++) - { - for(int j = 0; j < YX_NUMPOINTS; j++) - { - hv[0][i][j] = centers.hv[0][i][j]; // x - hv[1][i][j] = centers.hv[1][i][j]; // y - } - } - ag.draw(new ACoord(hv, drawlist, this, ACoord.DOTTED_POLYGONS)); - - } // drawDashed() ------------------------------------------------------------- - /** - * getYXUser() - * calculates coordinates for the Et missing graphical object which - * consists of one arrowed line, i.e. one line and two smaller lines - * forming the arrow, all together NUM_POINTS points - * @return coordinates - */ - protected ACoord getYXUser() - { - if (etx[0] == 0.f && ety[0] == 0.f) return ACoord.NO_DATA; - - makeDrawList(); // applycuts will be called here - - // Et missing graphical object consists of one dashed line from center - // to the border of canvas, or an arrow. - - // hv will contain all the coordinates - // [2] - x and y value - // [numData] - should be "1" for ETMis datatype - // YX_NUMPOINTS - number of points required for ET Miss object - double[][][] hv = new double[2][numDraw][YX_NUMPOINTS]; - int[] index = new int[numDraw]; - // i counter, here should have just one item in the coordinate array - // (index.length = 1), numDraw should be 1 - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - // main line (dashed) - // to be properly done: geting border values over canvas/window - double inc = 10000 / YX_NUMPOINTS; - double x = Math.cos(phi[list]); - double y = Math.sin(phi[list]); - for(int ii = 0; ii < YX_NUMPOINTS; ii++) - { - hv[0][i][ii] = x * (inc * ii); - hv[1][i][ii] = y * (inc * ii); - } - - index[i] = list; - } - return new ACoord(hv, index, this); - - } // getYXUser() -------------------------------------------------------- - - @Override - protected ACoord getRZUser() { - if (etx[0] == 0.f && ety[0] == 0.f) return ACoord.NO_DATA; - - double s = 1+Math.sqrt(et[0]);//4*parameterStore.get("ETMis", "Scale").getD(); - if (0 == s || parameterStore.get("ETMis", "Drawas").getI() == 1) { - return ACoord.NO_DATA; - } - makeDrawList(); // applycuts will be called here - double[][][] hv = new double[2][numDraw][YX_NUMPOINTS + 4]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) { - int list = listdl[i]; - double rhoMinus = 500; - double rhoMax = 1500; - double inc = 1. / YX_NUMPOINTS; - double maxEnergy = parameterStore.get("Projection", "EnergyMax").getD(); - double rhoPlus = rhoMax; - if (Math.abs(et[list]) < maxEnergy) { - rhoPlus = (rhoMax - rhoMinus) * s * Math.abs(et[list]) / maxEnergy; - } - - double updown = 0; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - if (phiMid > AMath.TWO_PI) { - phiMid -= AMath.TWO_PI; - } - double phiDiff = Math.abs(phi[list] - phiMid); - if (phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) { - updown = 1; - } else { - updown = -1; - } - - //double y = rhoPlus*Math.cos(phiDiff);//to change with cos of phiDiff - double y = rhoPlus * updown;//to change just by up or down - for (int ii = 0; ii <= YX_NUMPOINTS; ii++) { - hv[0][i][ii] = 0; - hv[1][i][ii] = rhoMinus * updown + y * (inc * ii); - } - hv[0][i][YX_NUMPOINTS + 1] = rhoMinus * .1; - hv[1][i][YX_NUMPOINTS + 1] = rhoMinus * updown + 0.8 * y; - hv[0][i][YX_NUMPOINTS + 2] = -rhoMinus * .1; - hv[1][i][YX_NUMPOINTS + 2] = rhoMinus * updown + 0.8 * y; - hv[0][i][YX_NUMPOINTS + 3] = 0; - hv[1][i][YX_NUMPOINTS + 3] = rhoMinus * updown + y; - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYLINES); - - } // getRZUser() -------------------------------------------------------- - - /** - * calculate coordinates for the Et missing graphical object - * in V-Plot (eta-phi projection) - * @return coordinates - */ - protected ACoord getVPUser() - { - if (etx[0] == 0.f && ety[0] == 0.f) return ACoord.NO_DATA; - - makeDrawList(); // applycuts will be called here - - // numDraw for ET Miss object should be 1 - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - h[0] = 0.0; // h[0] is the eta value, ETMis always drawn in the - // centre of VPlot - at eta 0 - v[0] = Math.toDegrees(phi[list]); // v[0] is the phi value - index[i] = list; - } - - return new ACoord(h, v, index, this).includePhiWrapAround("VP"); - - } // getVPUser() -------------------------------------------------------- - - /** - * this method is defined as an abstract method in AData, so must be - * implemented in this child class - */ - protected void applyCuts() { - - // no need to cut index (always 0), and transverse momentum for ET Miss - // assuming only 1 item in the ETMis datatype, thus index 0 - cutPhi(phi[0]); - - // eta value for ET Miss is 0 - cutEta(0.0f); - - // cut on ETMiss (default cut of 15 GeV) - cut("CutsObjects", "ETMis", " |ETMis|", et); - - } // applyCuts() -------------------------------------------------------- - - /** - * phi cut implementation for ETMis object - * @param phi float - */ - protected void cutPhi(float phi) { - AParameter par = parameterStore.get("CutsATLAS", "CutPhi"); - boolean usePhiCut = par.getStatus(); - if (usePhiCut) { - double phiCut = Math.toRadians(Math.abs(par.getD())); - double phiMid = Math.toRadians( - AMath.nearestPhiDegrees(parameterStore.get("CutsATLAS", "PhiMiddle").getD())); - double phiDiff = Math.abs(AMath.nearestPhiRadians(phi, phiMid) - - phiMid); - - if (phiDiff - phiCut > 1.0e-6) { - numDraw = 0; - } - } - - } // cutPhi() ----------------------------------------------------------- - - /** - * eta cut implementation for ETMis object - * @param eta float - */ - protected void cutEta(float eta) { - AParameter par = parameterStore.get("CutsATLAS", "CutEta"); - boolean useEtaCut = par.getStatus(); - if (useEtaCut) { - double etaCut = Math.abs(par.getD()); - double etaMid = parameterStore.get("CutsATLAS", "EtaMiddle").getD(); - double etaDiff = Math.abs(eta - etaMid); - if (etaDiff - etaCut > 1.0e-6) { - numDraw = 0; - } - } - - } // cutEta() ----------------------------------------------------------- -} // class AETMisData ======================================================= - diff --git a/graphics/AtlantisJava/src/atlantis/data/AElectronData.java b/graphics/AtlantisJava/src/atlantis/data/AElectronData.java deleted file mode 100755 index 29967a8fc3411f177c4c74da3d18e541abdfed8e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AElectronData.java +++ /dev/null @@ -1,180 +0,0 @@ -package atlantis.data; - -import java.util.Vector; -import atlantis.utils.A4Vector; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - -/** - * Reconstructed Electron - */ -public class AElectronData extends AHelixAODData -{ - private enum isEMe { TightPP, Tight, Medium, Loose, none } - - private int[] isEM; - private Vector<Enum> isEMEnum = new Vector<Enum>(); - private String[] label; - private float[] eOverp; - private int[] hasTrack; - - AElectronData(AHashMap p, AEvent e) - { - super(p,e); - isEM=p.getUnsureIntArray("isEM"); - String[] isEMString=p.getUnsureStringArray("isEMString"); - eOverp = p.getUnsureFloatArray("eOverp"); - hasTrack=p.getUnsureIntArray("hasTrack"); - label=p.getUnsureStringArray("label"); - - if(isEMString!=null) - { - for(String s : isEMString) - { - try { - isEMEnum.add(isEMe.valueOf(s)); - } - catch(IllegalArgumentException q) { - isEMEnum.add(isEMe.none); - } - } - } - else - { - for(int i=0;i<numData;i++) - { - isEMEnum.add(isEMe.none); - } - } - } - - public String getParameterGroup() - { - return "Electron"; - } - - public float geteOverp(int index) - { - return eOverp[index]; - } - - public String getisEMEnum(int index) - { - return isEMEnum.get(index).toString(); - } - - public int getisEM(int index) - { - return isEM[index]; - } - - public A4Vector get4Vector(int num, int[] list) - { - A4Vector sum = new A4Vector(); - for (int i = 0; i < num; ++i) - { - int k = list[i]; - A4Vector start = new A4Vector(); - start.setPtEtaPhiM((double)pT[k],(double)eta[k],(double)phi[k],0.00051); - sum.add(start); - } - - return sum; - } - - protected void applyCuts() - { - super.applyCuts(); - cut("CutsObjects", "ElectronPt", " |ET|", pT); - - // because of the retriever bug, currently 2048 means 0 for isEM - // remove this for block when the bug is fixed - if(isEM != null) - { - for(int i=0; i<isEM.length; i++) - { - if(isEM[i]==2048) - isEM[i] = 0; - } - } - - cut("CutsObjects", "ElectronisEM", " isEM", isEM); - - if (parameterStore.get("CutsObjects", "ElectronisEMString").getStatus()) - { - int cutSub = parameterStore.get("CutsObjects", "ElectronisEMString").getI(); - - cutArrayEnum(isEMEnum, cutSub, "Electron isEMString"); - } - - cut("CutsObjects", "ElectroneOverp", " |eOverp|", eOverp); - if (parameterStore.get("CutsObjects", "ElectronhasTrack").getStatus() && hasTrack!=null) - cutArray(hasTrack, 1, "hasTrack"); - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n PT="+String.format("%.3f",pT[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Px="+String.format("%.3f",pT[index]*Math.cos(phi[index]))+" GeV "+ - "\n Py="+String.format("%.3f",pT[index]*Math.sin(phi[index]))+" GeV "+ - "\n Pz="+String.format("%.3f",pT[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - String k = this.getStoreGateKey(); - String sgKey = k != null ? k : "n/a"; - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (id: " + id[index] + " index: " + index + ")"); - msg.append("\n storegate key: "); - msg.append(sgKey); - msg.append("\n PT = "); - msg.append(String.format("%.3f",pT[index])); - msg.append(" GeV\n P = "); - msg.append(String.format("%.3f",Math.abs(pT[index]/Math.cos(AMath.lambda(eta[index]))))); - msg.append(" GeV\n "); - msg.append(AMath.ETA); - msg.append(" = "); - msg.append(String.format("%.3f",eta[index])); - msg.append("\n "); - msg.append(AMath.PHI); - msg.append(" = "); - msg.append(String.format("%.3f",Math.toDegrees(phi[index]))); - msg.append(AMath.DEGREES); - msg.append(" (" + String.format("%.3f",phi[index]) + " rad)"); - - - if (isEM != null) - { - msg.append("\n isEM = "); - msg.append(isEM[index]); - } - if (label != null) - { - msg.append("\n label = "); - msg.append(label[index]); - } - if (eOverp != null) - { - msg.append("\n eOverp = "); - msg.append(eOverp[index]); - } - if (hasTrack != null) - { - msg.append("\n hasTrack = "); - msg.append(hasTrack[index]); - } - - return msg.toString(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AEmTauROIData.java b/graphics/AtlantisJava/src/atlantis/data/AEmTauROIData.java deleted file mode 100755 index a2c8dc64699b95ff9b80ec461486eb653ab06c75..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AEmTauROIData.java +++ /dev/null @@ -1,34 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.utils.AHashMap; - -/** - * - * Em Tau Region Of Interest - * - * @author Zdenek Maxa, Qiang Lu - */ -public class AEmTauROIData extends AROIData -{ - AEmTauROIData(AHashMap p, AEvent e) - { - super(p,e); - } // AEmTauROIData() ---------------------------------------------------- - - public String getParameterGroup() - { - return "EmTauROI"; - } - - public String getName() - { - return "EmTauROI"; - } - - public String getNameScreenName() - { - return "EmTauROI"; - } - -} // class AEmTauROIData ==================================================== diff --git a/graphics/AtlantisJava/src/atlantis/data/AEventFromXML.java b/graphics/AtlantisJava/src/atlantis/data/AEventFromXML.java deleted file mode 100755 index b89196931d3d2553d5c42c785dfb85515d587945..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AEventFromXML.java +++ /dev/null @@ -1,786 +0,0 @@ -package atlantis.data; - -import java.io.InputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import javax.xml.parsers.SAXParserFactory; - -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.DefaultHandler; - -import atlantis.event.AData; -import atlantis.event.AEvent; -import atlantis.event.AEventSource.ReadEventException; -import atlantis.globals.AGlobals; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; -import atlantis.utils.AAtlantisException; -import atlantis.utils.ALogger; -import atlantis.utils.AUtilities; -import atlantis.utils.xml.AArrayParser; -import atlantis.utils.xml.AFloatArrayParser; -import atlantis.utils.xml.AIntArrayParser; -import atlantis.utils.xml.AStringArrayParser; -import atlantis.utils.xml.AXMLErrorHandler; -import atlantis.utils.xml.AXMLErrorHandler.ErrorState; -import java.util.Iterator; -import javax.xml.parsers.ParserConfigurationException; -import org.xml.sax.SAXNotRecognizedException; - - -/** - * The reader which is used to read XML Event Files. The reader function creates - * and returns an AEvent class. Event comes with tags which are arrays of - * numbers. These arrays are treated by xml as character strings. The conversion - * of the character strings to arrays of number is done here. - */ -public class AEventFromXML extends DefaultHandler { - - //the logger - private final static ALogger logger = ALogger.getLogger(AEventFromXML.class); - - // Create an instance of this object - this makes sure the constructor is called. - // FIXME: should not use constructor to initialize static state. - private static final AEventFromXML instance = new AEventFromXML(); - - //We also have our private error handler - private static final AXMLErrorHandler xmlErrorHandler = new AXMLErrorHandler(); - - //Parsing states at different XML levels - private enum ParseState { - WAITING_EVENT, - WAITING_DATA, - WAITING_ARRAY - } - private static ParseState parseState; - - //The XMLReader object - private static XMLReader xmlReader; - //The event that is being build - private static AEvent event = null; - //the source name - private static String sourceName = null; - - //non-static parsing data members - private AHashMap parameters = null; - private String currentDataName = null; - private String currentArrayName = null; - private String currentFullName = null; - private int arrayLength = 0; - private int currentArraySize = 0; - private String storeGateKey = null; - private AArrayParser arrayParser = null; - - private static boolean HLTIgnoredWarning = false; - - - /** - * Constructor - * Creates an instance of AEventFromXML. It just sets up the XML reading - * stuff but does not do any parsing of any XML file. - */ - private AEventFromXML() { - - try { - //setup all the xml reader stuff - SAXParserFactory factory = SAXParserFactory.newInstance(); - factory.setValidating(true); - factory.setNamespaceAware(true); - xmlReader = factory.newSAXParser().getXMLReader(); - xmlReader.setErrorHandler(xmlErrorHandler); - xmlReader.setEntityResolver(this); - xmlReader.setContentHandler(this); - } catch (ParserConfigurationException pce){ - logger.error("Unable to initialize XML reader!", pce); - } catch (SAXException sxe){ - logger.error("Unable to initialize XML reader!", sxe); - } - } // AEventFromXML() ---------------------------------------------------- - - - /** - * Checks if there was an error. - * @return true or false - */ - private boolean hasError() { - return (xmlErrorHandler.getErrorState() != ErrorState.NO_ERROR); - } - - - /** - * Reads an XML event data (from files, from string converted to stream) and - * returns the coresponding AEvent object. - * - * @param eventInputStream the XML data input stream. - * @param sourceName the name of the event source that provided this data - * @return an AEvent object containing all the data found in the file. - * @throws ReadEventException - */ - public static AEvent read(InputStream eventInputStream, String sourceName) throws ReadEventException { - - //be verbose - logger.info("Parsing event from " + sourceName); - - //set the initial error state - xmlErrorHandler.setError(ErrorState.NO_ERROR,null); - - //store the source Name - AEventFromXML.sourceName = sourceName; - - //Try to parse input stream - try { - xmlReader.parse(new InputSource(eventInputStream)); - } catch (Exception e) { - //In case of an error repackage as ReadEventException - logger.error("Parsing exception " + e.getMessage(),e); - throw new ReadEventException("XML parsing exception", e); - } - - //Finally construct the full event (including associations, etc.) - //Check for runtime exceptions here in case we fail to finalize the event - try { - event.finalizeEvent(); - } catch (RuntimeException rte) { - //rethrow as can not read event exception - throw new ReadEventException("Inconsistent event data",rte); - } - - return event; - } - - /** - * DefaultHandler Implementation (have a look at - * org.xml.sax.helpers.DefaultHandler for more info) - */ - @Override - public void startDocument() { - - //if we are already in error state return immediately - if (hasError()) return; - - //Clean up all local variables - event = null; - parameters = null; - currentDataName = null; - currentArrayName = null; - currentFullName = null; - arrayLength = 0; - currentArraySize = 0; - storeGateKey = null; - arrayParser = null; - - //Set parse state to new event - parseState = ParseState.WAITING_EVENT; - - //be verbose - logger.debug("Start parsing document"); - - } // startDocument() ---------------------------------------------------- - - @Override - public void endDocument() { - - //if we are already in error state return immediatly - if (hasError()) return; - - //be verbose - logger.debug("Finished parsing document w/o error"); - - } - - /** - * Implementation of DefaultHandler: start a new xml element - * @param namespaceURI the namespace - * @param localName the local name - * @param qName the qualified name - * @param atts the default or specified attributes - */ - @Override - public void startElement(String namespaceURI, String localName, - String qName, Attributes atts) throws SAXException { - - //stop here if errors have occured before - if (hasError()) return; - - try { - //Now act depending on parse state - switch (parseState) { - - //Waiting for an event to begin - case WAITING_EVENT: - //Try to read in event data - if (localName.equals("Event")) { - - //Create a new event - event = new AEvent(atts.getValue("eventNumber"), - atts.getValue("runNumber"), - atts.getValue("dateTime"), - sourceName, - atts.getValue("lumiBlock"), - atts.getValue("eventProperty")); - - - //create a new data hashmap - parameters = new AHashMap(15); - - //Advance to next parsing state - parseState = ParseState.WAITING_DATA; - - } else { - //The Event tag does not seem to be the first tag in this event - logger.warn("Encountered tag "+localName+ " while waiting for <event/>!"); - } - //Done waiting for event - break; - - //Waiting for a data tag - case WAITING_DATA: - - //Store the current object name - currentDataName = localName; - //Get number of entries expected here - arrayLength = Integer.parseInt(atts.getValue("count")); - - // if storegate key doesn't exists as an attribute - // at datatype, an empty string "" is retrieved (not null) - storeGateKey = atts.getValue("storeGateKey"); - //Construct full name from datatype name and storeGateKey - currentFullName = currentDataName + "-" + storeGateKey; - - // ignore data with storeGateKey containing "HLTAutoKey" - // Its important that parseState is not set before, - // so we arrive waiting for a new data tag when this error is cleared - if (!AGlobals.instance().showHLTAutoKeys() && storeGateKey.indexOf("HLTAutoKey") >= 0) { - //Set appropiate error state and continue - xmlErrorHandler.setError(ErrorState.IGNORED_DATA, new Exception("Ignored HLTAutoKey data "+currentFullName)); - return; - } - - parameters.clear(); - // add numData - number of data within the subtags, - // extracted from count attribute - parameters.put("numData", new Integer(arrayLength)); - parameters.put("storeGateKey", storeGateKey); - parseState = ParseState.WAITING_ARRAY; - break; - - //Waiting for an data value array - case WAITING_ARRAY: - - //store name of the array we are looking at - currentArrayName = localName; - - if ((atts.getValue("type") == null) || - (atts.getValue("multiple") == null)) - throw new SAXNotRecognizedException("No array type or multiplicity available for "+localName); - - String type = atts.getValue("type"); - - //get multiplicity if needed - float multiple = Float.parseFloat(atts.getValue("multiple")); - currentArraySize = Math.round(arrayLength * multiple); - - - //Instanciate a new array parser - if (type.equals("FLOAT")) { - arrayParser = new AFloatArrayParser(currentArraySize); - } else if (type.equals("INT")) { - arrayParser = new AIntArrayParser(currentArraySize); - } else if (type.equals("STRING")) { - arrayParser = new AStringArrayParser(currentArraySize); - } else { - throw new SAXNotRecognizedException("Invalid array type: " + type); - } - - break; - - } // switch - } catch (SAXNotRecognizedException sre){ - //Catch unknown array tags - xmlErrorHandler.setError(ErrorState.INVALID_DATA,sre); - logger.debug("Encountered invalid subtag "+localName, sre); - } catch (Exception e) { - //Catch any other error here: - String msg = "Error reading file at " + currentFullName + ":" + currentArrayName; - xmlErrorHandler.setError(ErrorState.FATAL_ERROR,e); - logger.debug(msg, e); - //Rethrow readevent exception with proper cause - throw new SAXException(msg, e); - } - - } - - /** - * Called at the end of each tag - this is where we actually construct the data - * @param namespaceURI - the current namespace - * @param localName - the local element name - * @param qName - the qualified element name - */ - @Override - public void endElement(String namespaceURI, String localName, String qName) throws SAXException { - - /** - * Check if an error had occured reading this element - */ - if (hasError()) { - - String msg = null; - - switch (xmlErrorHandler.getErrorState()) { - - case UNKNOWN_TAG: - //Ignore unknown tags, but show an error - - if (parseState == ParseState.WAITING_DATA) - msg = "Unknown or obsolete data type <" + currentDataName + "> found"; - else if (parseState == ParseState.WAITING_ARRAY) - //rely on exception error message for this one - msg = xmlErrorHandler.getErrorCause().getMessage(); - else - //unknown tag at event level - msg = "Unknown tag <" + currentDataName + "> while waiting for event."; - - //Clear the error state and continue - xmlErrorHandler.setError(ErrorState.NO_ERROR, null); - break; - - case INVALID_DATA: - msg = "Invalid data encountered reading "+currentDataName; - //Clear the error state and continue - xmlErrorHandler.setError(ErrorState.NO_ERROR, null); - break; - - case IGNORED_DATA: - - //Only show warning message in the LogPane once - if (!HLTIgnoredWarning) { - AOutput.append("\"HLTAutoKey\" data is hidden, option '-a' to see them.", - ALogInterface.WARNING); - //tell about each one also in the log - logger.warn(xmlErrorHandler.getErrorCause().getMessage()); - HLTIgnoredWarning = true; - } - - //Clear the error only when we reach the end of the data tag - if (localName.equals(currentDataName)) - xmlErrorHandler.setError(ErrorState.NO_ERROR, null); - - break; - } - - //If there was a message, show it - if (msg != null){ - // Now show this error in the log pane and console output - logger.warn(msg,xmlErrorHandler.getErrorCause()); - } - //Return to parsing (if error cleared) or stop - return; - } - - /** - * No error so far - check what we have been parsing - */ - switch (parseState) { - - case WAITING_ARRAY: - - /** - * End of data array - add to parameter list - */ - if (localName.equals(currentArrayName)) { - - //Check for proper Array size - if (arrayParser.getCount() != currentArraySize) { - - xmlErrorHandler.setError(ErrorState.INVALID_DATA, new Exception("Invalid array size")); - - String msg = "The number of data in <" + currentFullName + ">-<" + currentArrayName + "> is different than declared"; - logger.error(msg); - AOutput.append("\n"+msg+"\n", ALogInterface.WARNING); - return; - } - //Otherwise add to parameter list - parameters.put(currentArrayName, arrayParser.getArray()); - - //done with that, return - return; - } - - /** - * End of data tag - construct object - */ - if (localName.equals(currentDataName)) { - try { - // Calo and muon datatypes sometimes provide a - // storeGateKey, thus are (incorrectly !) - // regarded as multiple collection datatypes - // -> remove this storeGateKey - if ("TILE".equals(currentDataName) || - "LAr".equals(currentDataName) || - "HEC".equals(currentDataName) || - "FCAL".equals(currentDataName) || - "MBTS".equals(currentDataName) || - "MDT".equals(currentDataName) || - "CSC".equals(currentDataName) || - "RPC".equals(currentDataName) || - "TGC".equals(currentDataName)) { - parameters.put("storeGateKey", null); - } - - // RDOs originally implemented as multiple collections, - // then changed to non-mul-col. this is for backwards - // compatibility with events where storeGateKey is - // provided for PixelRDO and SCTRDO - if ("PixelRDO".equals(currentDataName) || - "SCTRDO".equals(currentDataName)) { - parameters.put("storeGateKey", null); - } - - checkPhiRange(parameters, currentFullName); - - if (currentDataName.equals("STr")) { - event.add(new ASVxData(ASVxData.createSVx(parameters), event)); - event.add(new ASTrData(ASTrData.createSTr(parameters), event)); - event.add(new ASNPData(ASNPData.createSNP(parameters), event)); - } // STC - silicon cluster datatype - else if (currentDataName.equals("STC")) { - event.add(new ASiClusterData(parameters, event)); - } // SCTRDO - silicon cluster raw data object - // discrepancy in naming STC x SCT ... - else if (currentDataName.equals("SCTRDO")) { - event.add(new ASiClusterRDOData(parameters, event)); - } // PixCluster - pixel cluster datatype - else if (currentDataName.equals("PixCluster")) { - event.add(new APixelClusterData(parameters, event)); - } - // ETMis backwards compatibility (after ETMis collections) - // datatypes ETMis, CaloETMis, MuonETMis - storeGateKey - // attribute is added here - else if (currentDataName.equals("ETMis") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "ETMis"); - event.add(new AETMisData(parameters, event)); - } else if (currentDataName.equals("CaloETMis")) { - parameters.put("storeGateKey", "CaloETMis"); - event.add(new AETMisData(parameters, event)); - } else if (currentDataName.equals("MuonETMis")) { - parameters.put("storeGateKey", "MuonETMis"); - event.add(new AETMisData(parameters, event)); - } // Track collections, backwards compatibility for - // IDScan, iPat, xKal datatypes - storeGateKey attribute - // is added here - else if (currentDataName.equals("Track")) { - - String key = (String) parameters.get("storeGateKey"); - if (key != null) { - if (key.toLowerCase().indexOf("mboy") >= 0 || key.toLowerCase().indexOf("mugirl") >=0 || key.toLowerCase().indexOf("moore") >= 0 || key.toLowerCase().indexOf("momu") >= 0 || key.toLowerCase().indexOf("muon") >= 0 || key.toLowerCase().indexOf("staco") >= 0 || key.toLowerCase().indexOf("muid") >= 0 || key.toLowerCase().indexOf("mutag") >= 0 ) { - event.add(new AMuonTrackData(parameters, event)); - } else { - event.add(new AInDetTrackData(parameters, event)); - } - } else { - int[] trackAuthor = parameters.getUnsureIntArray("trackAuthor"); - if (trackAuthor != null && trackAuthor.length > 0) { - if ((trackAuthor[0] >= 7 && trackAuthor[0] <= 9) || (trackAuthor[0] >= 13 && trackAuthor[0] <= 17)) { - event.add(new AMuonTrackData(parameters, event)); - } else { - event.add(new AInDetTrackData(parameters, event)); - } - } else { - event.add(new AInDetTrackData(parameters, event)); - } - } - } else if (currentDataName.equals("IDScan")) { - parameters.put("storeGateKey", "TrigInDetTrack"); - event.add(new AInDetTrackData(parameters, event)); - } else if (currentDataName.equals("iPat")) { - parameters.put("storeGateKey", "iPatTrack"); - event.add(new AInDetTrackData(parameters, event)); - } else if (currentDataName.equals("xKal")) { - parameters.put("storeGateKey", "xKalTrack"); - event.add(new AInDetTrackData(parameters, event)); - } else if (currentDataName.equals("RTr")) // old tag - { - parameters.put("storeGateKey", "RTrTrack"); - event.add(new AInDetTrackData(parameters, event)); - } else if (currentDataName.equals("RMTr")) // old tag - { - parameters.put("storeGateKey", "RMTrTrack"); - event.add(new AMuonTrackData(parameters, event)); - } // ParticleJet backwards compatibility - else if (currentDataName.equals("ParticleJet") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "ParticleJet cone4"); - // treat PatricleJet as Jet (JetRecJet) - event.add(new AJetData(parameters, event)); - } else if (currentDataName.equals("Jet") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "JetRecJet"); - event.add(new AJetData(parameters, event)); - } // MSeg backwards compatibility - else if (currentDataName.equals("MSeg")) { - parameters.put("storeGateKey", "MooreSegment"); - - // Instead of cotan(theta) we store theta itself. - float[] cotTheta = parameters.getFloatArray("cotTheta"); - float[] theta = new float[cotTheta.length]; - for (int i = 0; i < cotTheta.length; i++) { - theta[i] = (float) Math.atan(1. / cotTheta[i]); - } - parameters.put("theta", theta); - - // And phi0 is now called phi - parameters.put("phi", parameters.getFloatArray("phi0")); - - event.add(new AMuonSegmentData(parameters, event)); - } // Segment backwards compatibility - else if (currentDataName.equals("Segment")) { - String key = (String) parameters.get("storeGateKey"); - if (key != null) { - if (key.toLowerCase().indexOf("mboy") >= 0 || key.toLowerCase().indexOf("moore") >= 0 || key.toLowerCase().indexOf("momu") >= 0 || key.toLowerCase().indexOf("mdt") >= 0 || key.toLowerCase().indexOf("muon") >= 0) { - event.add(new AMuonSegmentData(parameters, event)); - } else { - event.add(new AInDetSegmentData(parameters, event)); - } - } - } // Cluster backwards compatibility - // datatypes Cluster - storeGateKey attribute is added - else if (currentDataName.equals("Cluster") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "DefaultCluster"); - event.add(new AClusterData(parameters, event)); - } //Electron backwards compatibility - else if (currentDataName.equals("Electron") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "ElectronCollection"); - event.add(new AElectronData(parameters, event)); - } //Muon backwards compatibility - else if (currentDataName.equals("Muon") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "MuonCollection"); - event.add(new AMuonData(parameters, event)); - } //Photon backwards compatibility - else if (currentDataName.equals("Photon") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "PhotonCollection"); - event.add(new APhotonData(parameters, event)); - } //BJet backwards compatibility - else if (currentDataName.equals("BJet") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "BJetCollection"); - event.add(new ABJetData(parameters, event)); - } //TauJet backwards compatibility - else if (currentDataName.equals("TauJet") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "TauJetCollection"); - event.add(new ATauJetData(parameters, event)); - } //CompositeParticle backwards compatibility - else if (currentDataName.equals("CompositeParticle") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "CompositeParticleCollection"); - event.add(new ACompositeParticleData(parameters, event)); - } //LVL1Result backwards compatibility - else if (currentDataName.equals("LVL1Result") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "LVL1Result"); - event.add(new ALVL1ResultData(parameters, event)); - } //LVL1TriggerTower backwards compatibility - else if (currentDataName.equals("LVL1TriggerTower") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "LVL1TriggerTower"); - event.add(new ALVL1TriggerTowerData(parameters, event)); - } //LVL1JetElement backwards compatibility - else if (currentDataName.equals("LVL1JetElement") && - "".equals(storeGateKey)) { - parameters.put("storeGateKey", "LVL1JetElement"); - event.add(new ALVL1JetElementData(parameters, event)); - } else { - //try to autoconstruct the corresponding data type - //First of all get all constructors for this class name - Constructor[] cons = Class.forName("atlantis.data.A" + currentDataName + "Data").getDeclaredConstructors(); - //Flag if we found on - boolean foundConstructor = false; - //Now loop over constructors and pick the one that fits - for (Constructor constructor : cons) { - //Check for parameters - Class[] params = constructor.getParameterTypes(); - if (params.length != 2) { - continue; - //Check both types - } - if (!params[0].getName().endsWith("AHashMap")) { - continue; - } - if (!params[1].getName().endsWith("AEvent")) { - continue; - //seems we found the proper constructor - go and build the class - } - foundConstructor = true; - event.add((AData) constructor.newInstance(new Object[]{parameters, event})); - //also end the loop here - break; - } - if (!foundConstructor) { - throw new ClassNotFoundException("Found no valid constructor for data type " + currentDataName); - } - } // End of autoconstructor - - - //Collect all possible errors here - } catch (Throwable t) { - //Will hold the error message - String msg = null; - - //Could not find a class for this data type - if (t instanceof ClassNotFoundException) { - msg = "Class handling the type " + currentDataName + " not found"; - xmlErrorHandler.setError(ErrorState.INVALID_DATA, t); - //Ran out ouf memory - } else if (t instanceof OutOfMemoryError) { - msg = "Atlantis ran out of memory while\n" + "reading in event data"; - xmlErrorHandler.setError(ErrorState.FATAL_ERROR, t); - //Some weird Atlantis exception - check its error state - } else if (t instanceof AAtlantisException) { - msg = t.getMessage(); - //check Atlantis exception level - if (((AAtlantisException)t).isFatal()) - xmlErrorHandler.setError(ErrorState.FATAL_ERROR, t); - else - xmlErrorHandler.setError(ErrorState.OTHER_ERROR, t); - } else if (t instanceof InvocationTargetException) { - msg = "Error when constructing " + currentFullName; - xmlErrorHandler.setError(ErrorState.OTHER_ERROR, t); - } else { - msg = "Caught exception "+t.toString()+ " while constructing "+currentFullName; - xmlErrorHandler.setError(ErrorState.OTHER_ERROR, t); - } - - AOutput.append("\n" + msg + "\n", ALogInterface.WARNING); - logger.error(msg, t); - } - - /** - * Now handle potential errors - */ - //if we can proceed processing, throw an error - if (xmlErrorHandler.getErrorState() == ErrorState.FATAL_ERROR) - throw new SAXException("Error parsing event at tag <"+currentDataName+">", - (Exception)xmlErrorHandler.getErrorCause()); - - //Otherwise clear error state and continue - xmlErrorHandler.setError(ErrorState.NO_ERROR, null); - parseState = ParseState.WAITING_DATA; - return; - } - - } - } - - /** - * xml calls this routine whenever it finds CONTENT of type character array - * (CDATA) this routine fills an array stored in the arrayParser * - * - * @param ch char[] - * @param start int - * @param length int - */ - @Override - public void characters(char[] ch, int start, int length) { - - //return immediately if we had an error before - if (hasError()) return; - - //Make sure an arrayParser has been set before - if (arrayParser == null){ - xmlErrorHandler.setError(ErrorState.FATAL_ERROR,new NullPointerException("ArrayParser object not defined")); - logger.error("arrayParser is NULL in SAX DefaultHandler:characters"); - return; - } - - //try to parse the value array - try { - arrayParser.parse(ch, start, length); - } catch (NumberFormatException nfe) { - xmlErrorHandler.setError(ErrorState.INVALID_DATA,nfe); - String msg = "Data in <" + currentFullName + ">-<" + currentArrayName + - "> contains invalid character \'" + nfe.getMessage() + "\'"; - logger.error(msg); - - } catch (IndexOutOfBoundsException oob) { - xmlErrorHandler.setError(ErrorState.INVALID_DATA,oob); - String msg = "The number of data in <" + currentFullName + ">-<" - + currentArrayName + "> is more than declared"; - logger.error(msg); - } - - } // characters() -------------------------------------------------------- - - /** - * Returns an entity resolver - should be event.dtd in case we read an event file - * otherwise return null to use the default - * @param publicId - * @param systemId - * @return an input source for the entity resolver - */ - @Override - public InputSource resolveEntity(String publicId, String systemId) { - InputSource inputSource = null; - String FILE_SEPAR = System.getProperty("file.separator"); - - if (systemId.endsWith("event.dtd")) { - String dtdFile = AGlobals.instance().getHomeDirectory() + "events" + FILE_SEPAR + "event.dtd"; - try { - InputStream is = AUtilities.getFileAsStream(dtdFile); - inputSource = new InputSource(is); - } catch (AAtlantisException ae) { - logger.error("reading " + dtdFile + " error: " + ae.getMessage(), ae); - } - } - - return inputSource; - - } // resolveEntity() ---------------------------------------------------- - - /** - * Corrects the Phi values to be in the range (0:2pi). - * NOTE: This can still be done much nicer - but have you seen what it looked like before?! - * @param p The AHashMap containing the float arrays to be checked. - */ - private static void checkPhiRange(AHashMap p, String fullDataName) { - - //Loop over all keys in the Hashmap - Iterator keyIter = p.keySet().iterator(); - while (keyIter.hasNext()) { - //Check if this is a phi collection - String keyName = (String) keyIter.next(); - //Only run on phi value arrays - if (!keyName.startsWith("phi")) { - continue; - //Now get the actual array of values - } - float[] phi = null; - try { - phi = (float[]) p.get(keyName); - } catch (ClassCastException cce) { - //ignore any non-floar arrays that start with "phi" - continue; - } - //Check that we didn't get an empty entry - if (phi == null) { - continue; //Now loop over all entries and correct them - } - for (int i = 0; i < phi.length; i++) { - //Bring it down to the modulus of 2*Pi - phi[i] = phi[i] % (float)AMath.TWO_PI; - //Smaller zero is still possible - if (phi[i] < 0.) phi[i] += AMath.TWO_PI; - } - } - } // checkPhiRange() ----------------------------------------------------- -} // class AEventFromXML ==================================================== diff --git a/graphics/AtlantisJava/src/atlantis/data/AFCALData.java b/graphics/AtlantisJava/src/atlantis/data/AFCALData.java deleted file mode 100755 index 9e8d233d12e200e64df10fd6ed1ff6b014416841..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AFCALData.java +++ /dev/null @@ -1,1228 +0,0 @@ -package atlantis.data; - -import atlantis.canvas.ACanvas; -import atlantis.event.AEvent; -import atlantis.geometry.ACalorimeterDetector; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjection; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.AIdHelper; -import atlantis.utils.AMath; -import atlantis.utils.AUtilities; -import atlantis.utils.ALogger; -import java.io.IOException; -import com.Ostermiller.util.CSVParser; -import java.io.StringReader; -import java.io.InputStream; -import java.io.FileNotFoundException; - -/** - * The Forward calorimeter implementation. - * - * @author Eric Jansen - */ -public class AFCALData extends ACalorimeterData -{ - private static ALogger logger = ALogger.getLogger(AFCALData.class); - - protected float[] x; - protected float[] y; - protected float[] z; - protected float[] r; - protected float[] dx; - protected float[] dy; - protected float[] dz; - protected float[] dr; - - private int[][] cellTable; - - // data for real pulse shapes plots - private int numSamplings = 0; - private int[][] adcCounts = null; - private float[] cellTime = null; - private int[] cellGain = null; - private float[] cellPedestal = null; - private float[] adc2Mev = null; - private static boolean pulseShapesDataAvailable = false; - private static final String LOOKUP_TABLE_FILE = - AGlobals.instance().getHomeDirectory() + "configuration" + - System.getProperty("file.separator") + - "rpsplt_fcal.csv"; - // number of lookup table values for real pulse shapes plots calculation - private static final short NUMBER_OF_LOOKUP_VALUES = 600; - - - - AFCALData(AHashMap p, AEvent e) - { - super(p,e); - - x = p.getFloatArray("x"); - dx = p.getFloatArray("dx"); - y = p.getFloatArray("y"); - dy = p.getFloatArray("dy"); - - r = new float[numData]; - dr = new float[numData]; - - cellTable = new int[MAX_HIT_INDEX][MAX_HIT_INDEX]; - - for (int i = 0; i < numData; i++) - { - try - { - side[i] = (byte) AIdHelper.larBarrelEndcap(id[i]); - etaIndex[i] = (short) AIdHelper.larEta(id[i]); - phiIndex[i] = (short) AIdHelper.larPhi(id[i]); - sampling[i] = 0; //AIdHelper.larSampling(id[i]); - } - catch (AAtlantisException ex) - { - logger.error("Problem decoding ID " + id[i] + " in " + - CALORIMETER_NAME + ": " + ex.getMessage()); - side[i] = 0; - etaIndex[i] = -1; - phiIndex[i] = -1; - sampling[i] = -1; - } - } - - // Events produced by older JiveXML versions don't have z and dz yet. - // Use the old hardcoded values in that case for backwards - // compatibility. - if (p.get("z") == null || p.get("dz") == null) - { - z = new float[numData]; - dz = new float[numData]; - for (int i = 0; i < numData; i++) - { - switch (sampling[i]) - { - case 0: - z[i] = (side[i] / Math.abs(side[i])) * 489.4f; - dz[i] = 45.2f; - break; - case 1: - z[i] = (side[i] / Math.abs(side[i])) * 534.8f; - dz[i] = 45.0f; - break; - case 2: - z[i] = (side[i] / Math.abs(side[i])) * 582.2f; - dz[i] = 45.0f; - break; - } - } - } - else - { - z = p.getFloatArray("z"); - dz = p.getFloatArray("dz"); - } - - float drMin = 0.0f, zMin = 0.0f, zMax = 0.0f, rMin = 0.0f, rMax = 0.0f; - for (int i = 0; i < numData; i++) - { - - if (side[i] < 0) - { - sub[i] = 0; - } - else - { - sub[i] = 1; - } - - float etaMin = (float) AMath.etaAbs(z[i], Math.sqrt(Math.pow(Math.abs(x[i]) - dx[i], 2) + - Math.pow(Math.abs(y[i]) - dy[i], 2))); - float etaMax = (float) AMath.etaAbs(z[i], Math.sqrt(Math.pow(Math.abs(x[i]) + dx[i], 2) + - Math.pow(Math.abs(y[i]) + dy[i], 2))); - eta[i] = (etaMin + etaMax) / 2.f; - //TODO check calculation original: deta[i] = etaMax - etaMin; - deta[i] = Math.abs(etaMax - etaMin); - phi[i] = (float) Math.atan2(y[i], x[i]); - dphi[i] = (float) Math.abs(Math.atan2(y[i] + dy[i], x[i] - dx[i]) - - Math.atan2(y[i] - dy[i], x[i] + dx[i])); - if (phi[i] < 0) - { - phi[i] += 2. * Math.PI; - } - - r[i] = (float) Math.sqrt(x[i] * x[i] + y[i] * y[i]); - dr[i] = (float) Math.sqrt(dx[i] * dx[i] + dy[i] * dy[i]); - - // Collect some constants needed for binning the histograms. - if (rMin == 0.0 || Math.abs(r[i]) - dr[i] / 2. < rMin) - { - rMin = Math.abs(r[i]) - dr[i] / 2.f; - } - if (rMax == 0.0 || Math.abs(r[i]) + dr[i] / 2. > rMax) - { - rMax = Math.abs(r[i]) + dr[i] / 2.f; - } - if (zMax == 0.0 || Math.abs(z[i]) + dz[i] / 2. > zMax) - { - zMax = Math.abs(z[i]) + dz[i] / 2.f; - } - if (zMin == 0.0 || Math.abs(z[i]) - dz[i] / 2. < zMin) - { - zMin = Math.abs(z[i]) - dz[i] / 2.f; - } - if (drMin == 0.0 || dr[i] < drMin) - { - drMin = dr[i]; - } - } - - etaGranularity = AParameterUtilities.eta(zMin, rMax - drMin) - AParameterUtilities.eta(zMin, rMax); - outerEta = AParameterUtilities.eta(zMax, rMin); - - // Collect some constants needed for drawing the histograms. - for (int i = 0; i < ACalorimeterDetector.count(); i++) - { - if (outerR == 0.0 || ACalorimeterDetector.get(i).getRMax() > outerR) - { - outerR = ACalorimeterDetector.get(i).getRMax(); - } - if (outerZ == 0.0 || ACalorimeterDetector.get(i).getZMax() > outerZ) - { - outerZ = ACalorimeterDetector.get(i).getZMax(); - } - } - - for (int i = 0; i < et.length; ++i) - { - et[i] = Math.abs(energy[i] / (float) Math.cosh(eta[i])); - } - - // read in FCAL data from real pulse shapes plots - readPulseShapePlotData(p); - - } - - - - /** - * readLookupTableFile() reads in comma separated values (CSV) file - * with FCAL real pulse shapes plots time and amplitude lookup values - * @param fileName String - * @throws AAtlantisException - */ - private void readLookupTableFile() throws AAtlantisException - { - try - { - InputStream is = AUtilities.getFileAsStream(LOOKUP_TABLE_FILE); - CSVParser parser = new CSVParser(is); - parser.setCommentStart("#"); - String arrayName = null; - - while((arrayName = parser.nextValue()) != null) - { - String valueArray = parser.nextValue(); // shall now contain all values - CSVParser parserArray = new CSVParser(new StringReader(valueArray)); - String[][] s = parserArray.getAllValues(); - - if("FCAL_LAYER0_AMPLITUDE".equals(arrayName)) - { - ACalorimeterRPSPLT.FCAL_LAYER0_AMPLITUDE = - getLookupTableArray(s, NUMBER_OF_LOOKUP_VALUES); - } - else if("FCAL_LAYER1_AMPLITUDE".equals(arrayName)) - { - ACalorimeterRPSPLT.FCAL_LAYER1_AMPLITUDE = - getLookupTableArray(s, NUMBER_OF_LOOKUP_VALUES); - } - else if("FCAL_LAYER2_AMPLITUDE".equals(arrayName)) - { - ACalorimeterRPSPLT.FCAL_LAYER2_AMPLITUDE = - getLookupTableArray(s, NUMBER_OF_LOOKUP_VALUES); - } - else if("FCAL_TIME".equals(arrayName)) - { - ACalorimeterRPSPLT.FCAL_TIME = - getLookupTableArray(s, NUMBER_OF_LOOKUP_VALUES); - } - } // while - } - catch(FileNotFoundException e) - { - throw new AAtlantisException("could not find file: " + - LOOKUP_TABLE_FILE); - } - catch(IOException e) - { - throw new AAtlantisException("exception while reading file: " + - LOOKUP_TABLE_FILE); - } - catch(AAtlantisException e) - { - throw e; - } - - } // readLookupTableFile() ---------------------------------------------- - - - - private void readPulseShapePlotData(AHashMap p) - { - // read ADCCounts and cell data for real pulse shapes plots - adcCounts = super.getADCCountsData(p); - - // read LAr digits (cell data) for real pulse shapes plots - cellTime = (p.get("cellTime") != null) ? p.getFloatArray("cellTime") : null; - cellGain = (p.get("cellGain") != null) ? p.getIntArray("cellGain") : null; - cellPedestal = (p.get("cellPedestal") != null) ? p.getFloatArray("cellPedestal") : null; - adc2Mev = (p.get("adc2Mev") != null) ? p.getFloatArray("adc2Mev") : null; - - pulseShapesDataAvailable = false; - if(adcCounts != null && cellTime != null && cellGain != null && - cellPedestal != null && adc2Mev != null) - { - pulseShapesDataAvailable = true; - numSamplings = adcCounts[0].length; - - logger.debug(CALORIMETER_NAME + - ": data for real pulse shape plots available"); - - - if(ACalorimeterRPSPLT.areFCALLookupTablesInitialized()) - { - logger.debug(CALORIMETER_NAME + - ": lookup tables have already been read in"); - } - else - { - logger.debug(CALORIMETER_NAME + - ": lookup table values have not been read in yet\n" + - " trying to read file: " + LOOKUP_TABLE_FILE); - try - { - readLookupTableFile(); - - logger.debug(CALORIMETER_NAME + - ": values from " + LOOKUP_TABLE_FILE + - " successfully read in"); - - } - catch(AAtlantisException ex) - { - logger.debug(CALORIMETER_NAME + - ": reading " + LOOKUP_TABLE_FILE + - " failed, real pulse shapes plots will not " + - "be available, reason: " + ex.getMessage(), ex); - pulseShapesDataAvailable = false; - } - } - } - - } // readPulseShapePlotData() ------------------------------------------- - - - - - /** - * Returns the name of the parameter group. - * - * @return String parameter group - */ - public String getParameterGroup() - { - return "FCAL"; - } - - /** - * Returns the name of the datatype. - * - * @return String datatype - */ - public String getName() - { - return "FCAL"; - } - - /** - * Returns the name of the datatype. - * - * @return String datatype - */ - public String getNameScreenName() - { - return "FCAL"; - } - - /** - * Returns the type of calorimeter (ECAL/HCAL) for a hit. - * - * @param index int hit index - * @return String calorimeter type - */ - public String getCalorimeterType(int index) - { - if (sampling[index] == 0) - { - return "ECAL"; - } - else - { - return "HCAL"; - } - } - - /** - * Calorimeter cells can be drawn either explicitly or implicitly. In most - * views cells that are located behind eachother are consolidated and only - * the most energetic one is drawn explicitly. The other cells are drawn - * implicitly, since their energy value is still added to the energy sum of - * the explicitly drawn cell. The list manager does not know about the - * implicitly drawn cells though, so this poses a problem when the user - * requests information about a certain area of the canvas. This is solved - * using this method. This function receives the list of explicitly drawn - * cells and then adds the ones that were implicitly drawn in this - * selection. - * - * @param drawn boolean[] initial drawn list containing only the explicitly - * drawn cells - * @return boolean[] drawn list containing the explicitly and the implicitly - * drawn cells. - */ - public boolean[] expandDrawn(boolean[] drawn) - { - AProjection projection = ACanvas.getCanvas().getCurrentWindow().getProjection(); - - if (projection instanceof AProjectionYX) - { - return expandDrawnYX(drawn); - } - else if (projection instanceof AProjectionRZ) - { - return expandDrawnRZ(drawn); - } - else - { - return drawn; - } - } - - /** - * Filters the drawList for the y-x projection. Hits from both endcaps are - * combined. - */ - protected void filterDrawListYX() - { - float etTable[][] = new float[MAX_HIT_INDEX][MAX_HIT_INDEX]; - for (int i = 0; i < MAX_HIT_INDEX; i++) - { - for (int j = 0; j < MAX_HIT_INDEX; j++) - { - cellTable[i][j] = -1; - etTable[i][j] = 0.0f; - } - } - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - int eta = etaIndex[j]; - int phi = phiIndex[j]; - etTable[eta][phi] += et[j]; - if (cellTable[eta][phi] < 0 || et[cellTable[eta][phi]] < et[j]) - cellTable[eta][phi] = j; - } - - numDraw = 0; - for (int i = 0; i < MAX_HIT_INDEX; i++) - { - for (int j = 0; j < MAX_HIT_INDEX; j++) - { - if (cellTable[i][j] > 0) - { - listdl[numDraw] = cellTable[i][j]; - etSum[listdl[numDraw]] = etTable[i][j]; - numDraw++; - } - } - } - } - - /** - * See expandDrawn. - * - * @param drawn boolean[] initial drawn list containing only the explicitly - * drawn cells - * @return boolean[] drawn list containing the explicitly and the implicitly - * drawn cells. - */ - private boolean[] expandDrawnYX(boolean[] drawn) - { - makeDrawList(); - - int mode = parameterStore.get("YX", "Mode").getI(); - if (parameterStore.get("YX", "DrawFCAL").getStatus() && mode >= AProjectionYX.MODE_HEC_2 && - mode <= AProjectionYX.MODE_HEC_4) - { - cutArray(sampling, mode - AProjectionYX.MODE_HEC_2, "Layer"); - } - else if (mode >= AProjectionYX.MODE_FCAL_EM || mode <= AProjectionYX.MODE_FCAL_HAD_2) - { - cutArray(sampling, mode - AProjectionYX.MODE_FCAL_EM, "Layer"); - } - else - { - return drawn; - } - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - - if (drawn[j]) - continue; - - int eta = etaIndex[j]; - int phi = phiIndex[j]; - - if (eta >= 0 && phi >= 0) - { - int mappedTo = cellTable[eta][phi]; - - if (mappedTo >= 0 && drawn[mappedTo] == true) - { - drawn[j] = true; - } - } - } - - return drawn; - } - - /** - * The rho-z projection is a bit difficult for FCAL. Because of the y-x - * geometry of the cells there isn't really a nice way to project them in - * rho-z. This prodedure takes the most energetic cell and the consolidates - * it with all cells that overlap it. This is repeated until all cells are - * assigned to such a most energetic cell. We are then left with a series of - * "important" cells that do not overlap in rho-z. These can be drawn - * nicely. - */ - protected void filterDrawListRZ() - { - boolean available[] = new boolean[numDraw]; - int numCells = numDraw; - int newNumDraw = 0; - - // Initialize the variables. - for (int i = 0; i < numDraw; i++) - { - available[i] = true; - } - for (int i = 0; i < numData; i++) - { - etSum[i] = 0.0f; - } - - while (numCells > 0) - { - - // Loop through all available cells and find the highest energy. - int max = -1; - for (int i = 0; i < numDraw; i++) - { - if (available[i]) - { - if (max < 0 || et[listdl[i]] > et[listdl[max]]) - max = i; - } - } - - // This is a cell we want to draw, store it and remove it from the - // available cells list. - available[max] = false; - numCells--; - listdl[newNumDraw++] = listdl[max]; - - // Now find all available cells that overlap this one. This loop - // will be processed - // quite a lot, so it is very important to do the "easy" rejects - // first. - for (int i = 0; i < numDraw; i++) - { - if (available[i]) - { - int j = listdl[i]; - - double zDist = Math.abs(z[j] - z[listdl[max]]); - if (zDist >= (dz[j] + dz[listdl[max]]) / 2.) - continue; - - double rDist = Math.abs(r[j] - r[listdl[max]]); - if (rDist >= (dr[j] + dr[listdl[max]]) / 2.) - continue; - - if (AParameterUtilities.getRhoSign(x[j], y[j]) != AParameterUtilities.getRhoSign(x[listdl[max]], y[listdl[max]])) - continue; - - available[i] = false; - etSum[listdl[max]] += et[j]; - numCells--; - } - } - } - - numDraw = newNumDraw; - } - - /** - * See expandDrawn. - * - * @param drawn boolean[] initial drawn list containing only the explicitly - * drawn cells - * @return boolean[] drawn list containing the explicitly and the implicitly - * drawn cells. - */ - private boolean[] expandDrawnRZ(boolean[] drawn) - { - makeDrawList(); - - boolean available[] = new boolean[numDraw]; - int numCells = numDraw; - - // Initialize the variables. - for (int i = 0; i < numDraw; i++) - { - available[i] = true; - } - - while (numCells > 0) - { - - // Loop through all available cells and find the highest energy. - int max = -1; - for (int i = 0; i < numDraw; i++) - { - if (available[i]) - { - if (max < 0 || et[listdl[i]] > et[listdl[max]]) - max = i; - } - } - - // This is a cell we want to draw, store it and remove it from the - // available cells list. - available[max] = false; - numCells--; - - // Now find all available cells that overlap this one. This loop - // will be processed - // quite a lot, so it is very important to do the "easy" rejects - // first. - for (int i = 0; i < numDraw; i++) - { - if (available[i]) - { - int j = listdl[i]; - - double zDist = Math.abs(z[j] - z[listdl[max]]); - if (zDist >= (dz[j] + dz[listdl[max]]) / 2.) - continue; - - double rDist = Math.abs(r[j] - r[listdl[max]]); - if (rDist >= (dr[j] + dr[listdl[max]]) / 2.) - continue; - - if (AParameterUtilities.getRhoSign(x[j], y[j]) != AParameterUtilities.getRhoSign(x[listdl[max]], y[listdl[max]])) - continue; - - available[i] = false; - if (drawn[listdl[max]]) - drawn[j] = true; - numCells--; - } - } - } - - return drawn; - } - - /** - * Draws the FCAL data in the y-x projection. - * - * @return ACoord cell geometry polygons - */ - protected ACoord getYXUser() - { - makeDrawList(); - - int mode = parameterStore.get("YX", "Mode").getI(); - if (parameterStore.get("YX", "DrawFCAL").getStatus() && mode >= AProjectionYX.MODE_HEC_2 && - mode <= AProjectionYX.MODE_HEC_4) - { - cutArray(sampling, mode - AProjectionYX.MODE_HEC_2, "Layer"); - } - else if (mode >= AProjectionYX.MODE_FCAL_EM || mode <= AProjectionYX.MODE_FCAL_HAD_2) - { - cutArray(sampling, mode - AProjectionYX.MODE_FCAL_EM, "Layer"); - } - else - { - return ACoord.NO_DATA; - } - - filterDrawListYX(); - - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - double xMin = x[j] - dx[j] / 2.; - double xMax = x[j] + dx[j] / 2.; - double yMin = y[j] - dy[j] / 2.; - double yMax = y[j] + dy[j] / 2.; - - hv[0][i] = new double[] { xMax, xMin, xMin, xMax }; - hv[1][i] = new double[] { yMax, yMax, yMin, yMin }; - - index[i] = j; - } - - return new ACoord(hv, index, this); - } - - /** - * Draws the FCAL data in the rho-z projection. See the description of - * filterDrawListRZ() for an explanation of the drawing method. - * - * @return ACoord cell geometry polygons - */ - protected ACoord getRZUser() - { - makeDrawList(); - filterDrawListRZ(); - - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - - double zMin = z[j] - dz[j] / 2.; - double zMax = z[j] + dz[j] / 2.; - double rMin = Math.sqrt(Math.pow(Math.abs(x[j]) - Math.abs(dx[j] / 2.), 2) + Math.pow(Math.abs(y[j]) - Math.abs(dy[j] / 2.), 2)); - double rMax = Math.sqrt(Math.pow(Math.abs(x[j]) + Math.abs(dx[j] / 2.), 2) + Math.pow(Math.abs(y[j]) + Math.abs(dy[j] / 2.), 2)); - - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(phi[j] - phiMid); - if (phiDiff > Math.PI / 2. && phiDiff <= 3 * Math.PI / 2.) - { - rMin *= -1; - rMax *= -1; - } - - hv[0][i] = new double[] { zMax, zMin, zMin, zMax }; - hv[1][i] = new double[] { rMax, rMax, rMin, rMin }; - - index[i] = j; - } - - return new ACoord(hv, index, this); - } - - /** - * Applies cuts to the data. - */ - protected void applyCuts() - { - super.applyCuts(); - cut("CutsCalo", "FCALET", "FCALET", et); - cut("CutsCalo", "FCALEnergy", "FCALEnergy", energy); - - int cutSub = parameterStore.get("CutsCalo", "FCAL").getI(); - if(cutSub != -1) - { - cutArray(sub, cutSub, "Endcap"); - } - } - - /** - * Returns the data in the phi-rho projection. - * - * @return ACoord polygons representing calorimeter cells - */ - public ACoord getFRUser() - { - return getYXUser().convertYXToFR().includePhiWrapAround("FR"); - } - - /** - * Returns the data in the phi-eta projection. - * - * @return ACoord polygons representing calorimeter cells - */ - protected ACoord getVPUser() - { - makeDrawList(); - - switch (parameterStore.get("VP", "Mode").getI()) - { - case AProjectionVP.MODE_ECAL_LAYER_0: - case AProjectionVP.MODE_ECAL_LAYER_1: - case AProjectionVP.MODE_ECAL_LAYER_2: - case AProjectionVP.MODE_ECAL_LAYER_3: - cutArray(sampling, 0, "EM"); - break; - case AProjectionVP.MODE_HCAL_LAYER_0: - case AProjectionVP.MODE_HCAL_LAYER_1: - case AProjectionVP.MODE_HCAL_LAYER_2: - case AProjectionVP.MODE_HCAL_LAYER_3: - cutArrayOR(sampling, 1, 2, "Hadronic"); - break; - default: - return ACoord.NO_DATA; - } - - double[][][] hv = new double[2][numDraw][4]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - etSum[j] = et[j]; - - double eta0 = AMath.etaAbs(z[j], (float) Math.sqrt(Math.pow(x[j] + dx[j] / 2., 2) + Math.pow(y[j] + dy[j] / 2., 2))); - double eta1 = AMath.etaAbs(z[j], (float) Math.sqrt(Math.pow(x[j] - dx[j] / 2., 2) + Math.pow(y[j] + dy[j] / 2., 2))); - double eta2 = AMath.etaAbs(z[j], (float) Math.sqrt(Math.pow(x[j] - dx[j] / 2., 2) + Math.pow(y[j] - dy[j] / 2., 2))); - double eta3 = AMath.etaAbs(z[j], (float) Math.sqrt(Math.pow(x[j] + dx[j] / 2., 2) + Math.pow(y[j] - dy[j] / 2., 2))); - - // Calculate phi between 0 and 360. - double phi0 = Math.toDegrees(Math.atan2(y[j] + dy[j] / 2., x[j] + dx[j] / 2.) + 360.) % 360.; - double phi1 = Math.toDegrees(Math.atan2(y[j] + dy[j] / 2., x[j] - dx[j] / 2.) + 360.) % 360.; - double phi2 = Math.toDegrees(Math.atan2(y[j] - dy[j] / 2., x[j] - dx[j] / 2.) + 360.) % 360.; - double phi3 = Math.toDegrees(Math.atan2(y[j] - dy[j] / 2., x[j] + dx[j] / 2.) + 360.) % 360.; - - // Some code to prevent problems with cells going across the 0/360 - // border. - if (phi1 - phi0 > 180.) - phi1 -= 360.; - else if (phi0 - phi1 > 180.) - phi1 += 360; - if (phi2 - phi1 > 180.) - phi2 -= 360.; - else if (phi1 - phi2 > 180.) - phi2 += 360; - if (phi3 - phi2 > 180.) - phi3 -= 360.; - else if (phi2 - phi3 > 180.) - phi3 += 360; - - hv[0][i] = new double[] { eta0, eta1, eta2, eta3 }; - hv[1][i] = new double[] { phi0, phi1, phi2, phi3 }; - - index[i] = j; - } - - return new ACoord(hv, index, this).includePhiWrapAround("VP"); - } - - /** - * Returns the histograms in the RZ projection. - * - * @return ACoord[] histograms - */ - public ACoord[] getRZHistograms() - { - AHistogram histUp = new AHistogram(-outerEta, outerEta, etaGranularity, histoScale.getD(), this); - AHistogram histDown = new AHistogram(-outerEta, outerEta, etaGranularity, histoScale.getD(), this); - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - int sign = AParameterUtilities.getRhoSign(x[j], y[j]); - double etaMin; - double etaMax; - - if (side[j] < 0) - { - etaMin = AParameterUtilities.eta(z[j] + dz[j] / 2.f, r[j] - dr[j] / 2.f); - etaMax = AParameterUtilities.eta(z[j] - dz[j] / 2.f, r[j] + dr[j] / 2.f); - } - else - { - etaMin = AParameterUtilities.eta(z[j] - dz[j] / 2.f, r[j] + dr[j] / 2.f); - etaMax = AParameterUtilities.eta(z[j] + dz[j] / 2.f, r[j] - dr[j] / 2.f); - } - - if (sign > 0) - { - histUp.fill(etaMin, etaMax, etSum[j]); - } - else - { - histDown.fill(etaMin, etaMax, etSum[j]); - } - } - - ACoordArray c = new ACoordArray(); - c.add(histUp.getRZUser(outerZ, outerR, AHistogram.UP)); - c.add(histDown.getRZUser(outerZ, outerR, AHistogram.DOWN)); - return c.getArray(); - } - - - -// /** -// * Determines adc2Mev factor value for a cell. The number either comes -// * with the event file (adc2Mev subtag), but sometimes is not available -// * in Athena (in the database) which is indicated by -1 in the event file -// * for a particular cell. In this case, use predefined constant in this -// * method. -// * -// * zdenek (2008-09-15): -// * These predefined values (which are used if adc2Mev factor is -1) should -// * no longer be used. if the factor is not present, do not plot the pulse -// * shape, just the ADC counts as these values are non-sense. The method -// * and references to it should be removed after some time (if calo people -// * don't change their mind to pre-define some other values and use those) -// * -// * @param index int -// * @return String -// */ - /* - private float getADC2MevFactorPredefined(int index) - { - int layer = sampling[index]; - float r = Float.NaN; - switch(layer) - { - case 0: r = 87.0f; - break; - case 1: r = 117.0f; - break; - case 2: r = 193.0f; - break; - } - - return r; - - } // getADC2MevFactorPredefined() --------------------------------------- - */ - - - /** - * Returns info about a selected hit (for picking) - * - * @param index int hit index - * @return String info - */ - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n ET="+String.format("%.3f",et[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Ex="+String.format("%.3f",et[index]*Math.cos(phi[index]))+" GeV "+ - "\n Ey="+String.format("%.3f",et[index]*Math.sin(phi[index]))+" GeV "+ - "\n Ez="+String.format("%.3f",et[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - String t = ""; - String cellInfo = ""; - - t = super.getHitInfo(index); - cellInfo += "\n x = " + x[index] + " cm"; - cellInfo += "\n y = " + y[index] + " cm"; - - cellInfo += "\n cell time = "; - cellInfo += (cellTime != null) ? Float.toString(cellTime[index]) + - " ns" : "n/a"; - cellInfo += "\n cell gain = "; - cellInfo += (cellGain != null) ? Integer.toString(cellGain[index]) : "n/a"; - cellInfo += "\n cell pedestal = "; - cellInfo += (cellPedestal != null) ? Float.toString(cellPedestal[index]) + - " ADC counts" : "n/a"; - - cellInfo += "\n ADC 2 MeV = "; - if(adc2Mev == null) - { - cellInfo += "n/a"; - } - else - { - // subtag adc2Mev was available in the event file - if(adc2Mev[index] != -1) - { - // other than -1: the factor was available in - // Athena (database) for this particular cell - cellInfo += Float.toString(adc2Mev[index]) + " (from database)"; - } - else - { - // -1 -> the factor wasn't available in Athena (database), - // use hardcoded constant for this particular cell - cellInfo += "-1 (n/a in database)"; - // see comment at the getADC2MevFactorPredefined() method - // (was printing the predefined value) using predefined " + - // Float.toString(getADC2MevFactorPredefined(index)); - } - } - - cellInfo += pulseShapesDataAvailable ? "" : - "\n data for real pulse shapes plot n/a"; - - return t + cellInfo; - - } // getHitInfo() ------------------------------------------------------- - - @Override //ACalorimeterData - //Gives the hit time for this cell - protected double getTime(int hit) - { - if (cellTime == null) return 0.0; - else return cellTime[hit]; - } - - /** - * Recalculates eta from r and z in case the user wants to have their eta - * with respect to the primary vertex instead of 0. The calculation is a - * little different from the other calorimeter classes because this one - * contains both barrel and endcap data. - * - * @param index int index of hit in data - * @return double eta value - */ - public double getEta(int index) - { - if (!parameterStore.get("VP", "EtaVertex").getStatus()) - { - return this.eta[index]; - } - - return AParameterUtilities.eta(z[index], Math.sqrt(x[index] * x[index] + y[index] * y[index])); - } - - /** - * Returns the histograms for this projection. - * - * @param projection AProjection2D current projection - * @return ACoord[] polygons representing histograms - */ - protected ACoord[] getUserHistograms(AProjection2D projection) - { - ACoord[] data = ACoord.NO_HISTOGRAMS; - if (projection instanceof AProjectionRZ) - data = getRZHistograms(); - return projection.nonLinearTransform(data); - } - - - -// /** -// * Call util class which plots cell pulse shapes provided that -// * all real pulse shapes data is available -// * Functions calculates values of real pulse shape calculated in the method -// * getPhysicsPulseShape(). -// * This method is called from pick interaction. -// * -// * @param index int -// */ - /*public void plotPulseShapes(int index) - { - - if(pulseShapesDataAvailable) - { - String title = getPulseTitleString(index); - - int[][] adcCountsLocal = new int[][] { adcCounts[index] }; - - if(super.checkADCCountsAvailability(adcCountsLocal)) - { - // adc counts are available - logger.debug(CALORIMETER_NAME + " adc counts (digits) are " + - "available for pulse shapes plots for this cell."); - } - else - { - AOutput.append("\nADC counts are not available for this cell, " + - "can't plot pulse shapes.", ALogPane.WARNING); - return; - } - - - float[] time = ACalorimeterRPSPLT.FCAL_TIME; // lookup tables - float[] amplitude = null; // lookup tables - switch(sampling[index]) - { - // use correct amplitude lookup table for this layer (sampling) - case 0: amplitude = ACalorimeterRPSPLT.FCAL_LAYER0_AMPLITUDE; - break; - case 1: amplitude = ACalorimeterRPSPLT.FCAL_LAYER1_AMPLITUDE; - break; - case 2: amplitude = ACalorimeterRPSPLT.FCAL_LAYER2_AMPLITUDE; - break; - default: AOutput.append("\nADC counts plot only, pulse shape " + - "plot not implemented for " + - CALORIMETER_NAME + " layer " + - sampling[index] + "\n", ALogPane.WARNING); - APulseShapePlot.plotADCCounts(adcCountsLocal, title, null); - return; - } - - // step - starting from 1, need to get step numbers within - // number of ADC samples (adcCounts[0].length) - double step = (adcCounts[0].length - 1) / (float) NUMBER_OF_LOOKUP_VALUES; - double[][] realPulse = new double[1][NUMBER_OF_LOOKUP_VALUES]; // 1 channel - double d = 1.0; - // if adc2Mev != -1 -> use value from event file, otherwise predefined value - // see comment at the getADC2MevFactorPredefined() method - // factor variable is used as a flag whether or not to plot pulse shape, - // if is -1 (adc2Mev not available), then want to see only the adc counts - // and don't calculate the pulse shapes - // getADC2MevFactorPredefined(index) is no longer in use, see comment at it - float factor = adc2Mev[index]; - - double energyLocal = energy[index] * 1000.0 / factor; - try - { - if(factor != -1) - { - for(int i = 0; i < NUMBER_OF_LOOKUP_VALUES; i++) - { - d += step; - realPulse[0][i] = super.getPhysicsPulseShape(d, cellTime[index], - cellPedestal[index], energyLocal, - amplitude, time, NUMBER_OF_LOOKUP_VALUES); - } - } - } - catch(AAtlantisException aaex) - { - AOutput.append(aaex.getMessage(), ALogPane.WARNING); - return; - } - - if(factor != -1) - { - logger.debug("adc2Mev factor available, plotting full plot."); - APulseShapePlot.plotRealPulseShapes(adcCountsLocal, realPulse, - step, null, title); - } - else - { - logger.debug("adc2Mev factor not available, plotting just adc counts."); - APulseShapePlot.plotADCCounts(adcCountsLocal, title, null); - } - - } // if(pulseShapesDataAvailable) - else - { - return; - } - - }*/ // plotPulseShapes() -------------------------------------------------- - - @Override - protected int[][] getADCCounts(int index) { - - if (pulseShapesDataAvailable) { - return new int[][]{adcCounts[index]}; - } else { - return null; - } - } - - /** - * Calculate local time for pulse shape plots - */ - protected double getLocalTime(double xTime, double cellTime, int numSamplings) { - int nominalPeakSample = (int)(numSamplings / 2.); - return ((xTime - nominalPeakSample + 3) * 25.0) - cellTime; - } - - @Override - protected double[][] getPulseShape(int index) { - - float[] time = ACalorimeterRPSPLT.FCAL_TIME; // lookup tables - float[] amplitude = null; // lookup tables - switch(sampling[index]) - { - // use correct amplitude lookup table for this layer (sampling) - case 0: amplitude = ACalorimeterRPSPLT.FCAL_LAYER0_AMPLITUDE; - break; - case 1: amplitude = ACalorimeterRPSPLT.FCAL_LAYER1_AMPLITUDE; - break; - case 2: amplitude = ACalorimeterRPSPLT.FCAL_LAYER2_AMPLITUDE; - break; - default: AOutput.append("\nADC counts plot only, pulse shape " + - "plot not implemented for " + - CALORIMETER_NAME + " layer " + - sampling[index] + "\n", ALogInterface.WARNING); - return null; - } - - // step - starting from 1, need to get step numbers within - // number of ADC samples (adcCounts[0].length) - double step = getPulseStep(index); - double[][] realPulse = new double[1][NUMBER_OF_LOOKUP_VALUES]; // 1 channel - double d = 1.0; - // if adc2Mev != -1 -> use value from event file, otherwise predefined value - // see comment at the getADC2MevFactorPredefined() method - // factor variable is used as a flag whether or not to plot pulse shape, - // if is -1 (adc2Mev not available), then want to see only the adc counts - // and don't calculate the pulse shapes - // getADC2MevFactorPredefined(index) is no longer in use, see comment at it - float factor = adc2Mev[index]; - - double energyLocal = energy[index] * 1000.0 / factor; - try - { - if(factor != -1) - { - for(int i = 0; i < NUMBER_OF_LOOKUP_VALUES; i++) - { - d += step; - double localTime = getLocalTime(d, cellTime[index], this.numSamplings); - realPulse[0][i] = super.getPhysicsPulseShape(localTime, - cellPedestal[index], energyLocal, - amplitude, time, NUMBER_OF_LOOKUP_VALUES); - } - } - } - catch(AAtlantisException aaex) - { - AOutput.append(aaex.getMessage(), ALogInterface.WARNING); - return null; - } - - if(factor != -1) - { - logger.debug("adc2Mev factor available, plotting full plot."); - return realPulse; - } - else - { - logger.debug("adc2Mev factor not available, plotting just adc counts."); - return null; - } - - } - - @Override - protected double getPulseStep(int index) { - return (adcCounts[0].length - 1) / (float) NUMBER_OF_LOOKUP_VALUES; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AG4StepData.java b/graphics/AtlantisJava/src/atlantis/data/AG4StepData.java deleted file mode 100755 index 7f962718d03bc8bb297d4b621cb90215a61ebee7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AG4StepData.java +++ /dev/null @@ -1,559 +0,0 @@ -package atlantis.data; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.InputStreamReader; -import java.util.Enumeration; -import java.util.Scanner; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import atlantis.parameters.AParameterUtilities; -import atlantis.canvas.ACanvas; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.utils.AAtlantisException; -import atlantis.event.ABufferedEventSource; -import atlantis.event.AData; -import atlantis.event.AEvent; -import atlantis.utils.AHashMap; - -/** - * This class holds the data from GEANT4 (G4) steps which - * represent the path of simulated particles. The steps - * are read in from a (zipped) text file via the File menu - * or by pressing "/". - * The file (named "G4Atlantis_run_event.txt(.zip)") can be - * made by running AtlasG4 with a special plugin: - * AtlasG4_trf.py postInitInclude="G4UserActions/G4AtlantisDumper_options.py" - * - * @author Andy Haas (ahaas) - */ -public class AG4StepData extends AData { - - protected int[] nsteps; - protected int[] gid; - protected int[] pid; - protected int[] fs; - protected int[] ls; - protected int[] stepn; - protected String[] pn; - protected int[] nsec; - protected float[] tedep; - protected float[] tnedep; - protected float[] length; - protected int[] pdg; - protected float[] mass; - protected float[] charge; - protected float[] x1; - protected float[] y1; - protected float[] z1; - protected float[] t1; - protected float[] x2; - protected float[] y2; - protected float[] z2; - protected float[] t2; - protected float[] px1; - protected float[] py1; - protected float[] pz1; - protected float[] ke1; - protected float[] px2; - protected float[] py2; - protected float[] pz2; - protected float[] ke2; - - protected float[] eta1; - protected float[] p1; - - public AG4StepData(AHashMap p, AEvent e) { - super(p, e); - - nsteps = p.getIntArray("nsteps"); - gid = p.getIntArray("id"); - pid = p.getIntArray("pid"); - fs = p.getIntArray("fs"); - ls = p.getIntArray("ls"); - stepn = p.getIntArray("stepn"); - pn = p.getStringArray("pn"); - nsec= p.getIntArray("nsec"); - tedep = p.getFloatArray("tedep"); - tnedep = p.getFloatArray("tnedep"); - length = p.getFloatArray("length"); - pdg = p.getIntArray("pdg"); - mass = p.getFloatArray("mass"); - charge = p.getFloatArray("charge"); - x1 = p.getFloatArray("x1"); - y1 = p.getFloatArray("y1"); - z1 = p.getFloatArray("z1"); - t1 = p.getFloatArray("t1"); - x2 = p.getFloatArray("x2"); - y2 = p.getFloatArray("y2"); - z2 = p.getFloatArray("z2"); - t2 = p.getFloatArray("t2"); - px1 = p.getFloatArray("px1"); - py1 = p.getFloatArray("py1"); - pz1 = p.getFloatArray("pz1"); - ke1 = p.getFloatArray("ke1"); - px2 = p.getFloatArray("px2"); - py2 = p.getFloatArray("py2"); - pz2 = p.getFloatArray("pz2"); - ke2 = p.getFloatArray("ke2"); - - eta1 = new float[numData]; - p1 = new float[numData]; - for (int i=0; i<numData; ++i) { - eta1[i]=(float)(-1.0*Math.log(Math.tan( - Math.acos( z1[i]/Math.sqrt(x1[i]*x1[i]+y1[i]*y1[i]+z1[i]*z1[i]) )/2.0 - ))); - p1[i]=(float)Math.sqrt(px1[i]*px1[i]+py1[i]*py1[i]+pz1[i]*pz1[i]); - } - } - - /** - * The color of the step displayed... mostly determined - * by the particle type (pdgid) for now. - */ - @Override - protected void colorByIndex() { - int numColors = parameterStore.get("HitColors", "Number").getI(); - if (numColors<6) return;//not enough colors! - int[] col = parameterStore.getArray("HitColors", "C1", numColors); - for (int i = 0; i < numData; i++) { - - if (charge[i]==0) color[i] = (byte)col[0];//neutral - else color[i] = (byte)col[1];//charged - - if (pdg[i]==22) color[i] = (byte)col[2];//photons - if (Math.abs(pdg[i])==11) color[i] = (byte)col[3];//electrons - if (Math.abs(pdg[i])==13) color[i] = (byte)col[4];//muons - if (Math.abs(pdg[i])>=1000000000) color[i] = (byte)col[5];//nuclei - } - } - - /** - * Can choose to color by constant color, or using the - * function above (by type / index). - */ - protected int internalColor() { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - switch (colorFunction) { - case 0: - colorByConstant(); - break; - case 1: - colorByIndex(); - break; - } - return 1; - } - - /** - * Cuts on the particle type, energy, etc. - * Adjusted via the gui, and in the config-G4.xml file. - */ - protected void applyCuts() { - cutIndex(); - - cut("CutsObjects", "G4StepKE1", " ke1", ke1);//starting kinetic energy (MeV) - cut("CutsObjects", "G4StepP1", " p1", p1);//starting momentum (MeV) - - cut("CutsObjects", "G4StepPhotons", " |pdg|", pdg);//22 - cut("CutsObjects", "G4StepElectrons", " |pdg|", pdg);//11 - cut("CutsObjects", "G4StepMuons", " |pdg|", pdg);//13 - cut("CutsObjects", "G4StepPions", " |pdg|", pdg);//211 - cut("CutsObjects", "G4StepProtons", " |pdg|", pdg);//2212 - cut("CutsObjects", "G4StepNeutrons", " |pdg|", pdg);//2112 - - // Nuclear codes are given as 10-digit numbers +-10LZZZAAAI. - // For a nucleus consisting of np protons and nn neutrons - // A = np + nn +nlambda and Z = np and L = nlambda - // I gives the isomer level, with I = 0 corresponding to the ground state and I >0 to excitations - cut("CutsObjects", "G4StepNuclei", " |pdg|", pdg);//1000000000 - - } - - /** - * Prints out stuff when you select a step using the hand. - */ - public String getHitInfo(int index) { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if (simpleOutput > 0) { - return getNameScreenName() + " index: " + index + "\n"; - } - - String name = "none"; - try { - name = APDGTable.getName(pdg[index]); - - } catch(APDGTable.ParticleNotFoundError e) { - name = "unknown"; - } - - return getName() + " (index: " + index + ") : " - + " storegate key = " + storeGateKey + "\n" - + " total step # = " + nsteps[index] + " \n" - + " geant/parent id = " + gid[index]+"/"+ pid[index] + " \n" - + " first/last step? " + fs[index] +"/"+ ls[index] + " / step#="+stepn[index]+"\n" - + " process = " + pn[index] + " / # secondaries = " + nsec[index] + " \n" - + " energy/NI deposited = " + tedep[index]+" / "+tnedep[index]+" MeV\n" - + " length = " + length[index] + " cm / " +"eta1 = "+eta1[index]+"\n" - + " pdg = " + pdg[index] + " ("+name+")\n" - + " mass / charge = " + mass[index]+" MeV"+" / "+charge[index]+"\n" - + " x1 y1 z1 = " + String.format("%.3f", x1[index])+" "+String.format("%.3f", y1[index])+" "+String.format("%.3f", z1[index])+" cm\n" - + " t1 = " + String.format("%.3f", t1[index]) + " ns\n" - + " x2 y2 z2 = " + String.format("%.3f", x2[index])+" "+String.format("%.3f", y2[index])+" "+String.format("%.3f", z2[index])+" cm\n" - + " t2 = " + String.format("%.3f", t2[index]) + " ns\n" - + " px1 py1 pz1 = " + String.format("%.3f", px1[index])+" "+String.format("%.3f", py1[index])+" "+String.format("%.3f", pz1[index])+" MeV\n" - + " ke1 = " + String.format("%.3f", ke1[index]) + " MeV\n" - + " px2 py2 pz2 = " + String.format("%.3f", px2[index])+" "+String.format("%.3f", py2[index])+" "+String.format("%.3f", pz2[index])+" MeV\n" - + " ke2 = " + String.format("%.3f", ke2[index]) + " MeV\n" - + " p1 = " + String.format("%.3f", p1[index]) + " MeV\n" - ; - } - - /** - * Make some cuts for drawing in the YX view. - */ - @Override - protected ACoord getYXUser() { - //System.out.print("numData="+numData+", numDraw="+numDraw); - makeDrawList(); - //System.out.print(" "+numDraw); - - //cut on |eta1| - int num = 0; - double AbsEtaXYcut = parameterStore.get(PARAMETER_GROUP, "AbsEtaXYcut").getD(); - if (AbsEtaXYcut >= 0.0) { - for (int i = 0; i < numDraw; i++) { - if (Math.abs(eta1[listdl[i]]) < AbsEtaXYcut) { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - //System.out.print(" "+numDraw); - - //cut on |z1| - num = 0; - double AbszXYcut = parameterStore.get(PARAMETER_GROUP, "AbszXYcut").getD(); - if (AbszXYcut >= 0.0) { - for (int i = 0; i < numDraw; i++) { - if (Math.abs(z1[listdl[i]]) < AbszXYcut) { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - //System.out.println(" "+numDraw); - - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - //double length = parameterStore.get(PARAMETER_GROUP, "SegmentLength").getD(); - for (int i = 0; i < numDraw; i++) { - int j = listdl[i]; - hv[0][i] = new double[]{x1[j], x2[j]}; - hv[1][i] = new double[]{y1[j], y2[j]}; - index[i] = j; - } - return new ACoord(hv, index, this, ACoord.SMOOTH_POLYLINES); - } - - /** - * Make some cuts for drawing in the FR view. - */ - @Override - protected ACoord getFRUser() { - return getYXUser().convertYXToFR().includePhiWrapAround("FR"); - } - - /** - * Make some cuts for drawing in the RZ view. - */ - @Override - protected ACoord getRZUser() { - makeDrawList(); - - //cut on |eta1| - int num = 0; - double AbsEtaRZcut = parameterStore.get(PARAMETER_GROUP, "AbsEtaRZcut").getD(); - if (AbsEtaRZcut >= 0.0) { - for (int i = 0; i < numDraw; i++) { - if (Math.abs(eta1[listdl[i]]) < AbsEtaRZcut) { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - //cut on |z1| - num = 0; - double AbszRZcut = parameterStore.get(PARAMETER_GROUP, "AbszRZcut").getD(); - if (AbszRZcut >= 0.0) { - for (int i = 0; i < numDraw; i++) { - if ( - Math.abs(z1[listdl[i]]) < AbszRZcut && - Math.sqrt(x1[listdl[i]]*x1[listdl[i]]+y1[listdl[i]]*y1[listdl[i]]) < 1200 - ) { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - //double length = parameterStore.get(PARAMETER_GROUP, "SegmentLength").getD(); - for (int i = 0; i < numDraw; i++) { - int j = listdl[i]; - double s = AParameterUtilities.getRhoSign(x1[j], y1[j]);//use same for both points to avoid ugliness - double r1 = s * Math.sqrt(x1[j] * x1[j] + y1[j] * y1[j]); - double r2 = s * Math.sqrt(x2[j] * x2[j] + y2[j] * y2[j]); - hv[0][i] = new double[]{z1[j], z2[j]}; - hv[1][i] = new double[]{r1, r2}; - index[i] = j; - } - return new ACoord(hv, index, this, ACoord.POLYLINES); - } - - @Override - public String getName() { - return "G4Step"; - } - - @Override - public String getNameScreenName() { - return "G4Step"; - } - - @Override - public String getParameterGroup() { - return "G4Step"; - } - - /** - * Read in the corresponding G4Atlantis_run_event.txt(.zip) file. - * It needs to be in the same directory as the JiveXML_run_event.xml file - * that is currently being viewed. - */ - public static void ReadG4Steps(){ - AEvent ev = eventManager.getCurrentEvent(); - String source = eventManager.getEventSource().getSourceName(); - System.out.println("Source="+source); - String filename = source; - if (source.contains("\\")) filename+="\\G4Atlantis_"+ev.getRunNumber()+"_"+ev.getEventNumber()+".txt"; - else filename += "/G4Atlantis_" + ev.getRunNumber() + "_" + ev.getEventNumber() + ".txt"; - System.out.println("Reading G4 file: " + filename); - Scanner inFile = null; - int maxnstepsinthisevent = 4000000;//max allowed - int nstepsinfile = maxnstepsinthisevent;//will be set to actual number of steps in file, if lower than maximum - try { - inFile = new Scanner(new FileReader(filename)); - - //try to get the number of steps that are in the file - try { - FileInputStream in = new FileInputStream(filename); - BufferedReader br = new BufferedReader(new InputStreamReader(in)); - String strLine = null, tmp; - while ((tmp = br.readLine()) != null) { strLine = tmp; } - String lastLine = strLine; - System.out.println(lastLine); - in.close(); - - Scanner lastlinescanner = new Scanner(lastLine); - String llach = lastlinescanner.next(); - String _llach = "ACH_G4Step"; - if (!llach.equals(_llach)) { - System.out.println("??ach in lastline = " + llach); - } - nstepsinfile = lastlinescanner.nextInt()+1; - - } catch (IOException ex) { - Logger.getLogger(AG4StepData.class.getName()).log(Level.SEVERE, null, ex); - } - - } catch (FileNotFoundException ex) { - //Logger.getLogger(AEventQueue.class.getName()).log(Level.SEVERE, null, ex); - System.out.println("Could not open "+filename); - } - - if (inFile == null) { - ZipFile zipfile = null; - try { - System.out.println("Reading G4 file: " + filename+".zip"); - zipfile = new ZipFile(filename + ".zip"); - } catch (IOException ex) { - //Logger.getLogger(AEventQueue.class.getName()).log(Level.SEVERE, null, ex); - System.out.println("Could not open "+filename+".zip either"); - } - if (zipfile != null) { - BufferedInputStream is = null; - ZipEntry entry; - Enumeration e = zipfile.entries(); - while (e.hasMoreElements()) { - entry = (ZipEntry) e.nextElement(); - System.out.println("Extracting: " + entry); - try { - is = new BufferedInputStream(zipfile.getInputStream(entry)); - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - String strLine = null, tmp; - while ((tmp = br.readLine()) != null) { - strLine = tmp; - } - String lastLine = strLine; - System.out.println(lastLine); - - Scanner lastlinescanner = new Scanner(lastLine); - String llach = lastlinescanner.next(); - String _llach = "ACH_G4Step"; - if (!llach.equals(_llach)) { - System.out.println("??ach in lastline = " + llach); - } - nstepsinfile = lastlinescanner.nextInt() + 1; - - is = new BufferedInputStream(zipfile.getInputStream(entry)); - inFile = new Scanner(is); - } catch (IOException ex) { - Logger.getLogger(AG4StepData.class.getName()).log(Level.SEVERE, null, ex); - } - - } - } - } - - if (inFile != null) { - - System.out.print("nsteps in file should be "+nstepsinfile+"... "); - if (nstepsinfile>maxnstepsinthisevent) nstepsinfile=maxnstepsinthisevent; - System.out.println(" and will read "+nstepsinfile+" steps."); - - try { - AHashMap para = new AHashMap(100); - float[] x1 = new float[nstepsinfile]; - float[] y1 = new float[nstepsinfile]; - float[] z1 = new float[nstepsinfile]; - float[] t1 = new float[nstepsinfile]; - float[] x2 = new float[nstepsinfile]; - float[] y2 = new float[nstepsinfile]; - float[] z2 = new float[nstepsinfile]; - float[] t2 = new float[nstepsinfile]; - float[] px1 = new float[nstepsinfile]; - float[] py1 = new float[nstepsinfile]; - float[] pz1 = new float[nstepsinfile]; - float[] ke1 = new float[nstepsinfile]; - float[] px2 = new float[nstepsinfile]; - float[] py2 = new float[nstepsinfile]; - float[] pz2 = new float[nstepsinfile]; - float[] ke2 = new float[nstepsinfile]; - int[] nsteps = new int[nstepsinfile]; - int[] id = new int[nstepsinfile]; - int[] pid = new int[nstepsinfile]; - int[] fs = new int[nstepsinfile]; - int[] ls = new int[nstepsinfile]; - int[] stepn = new int[nstepsinfile]; - String[] pn = new String[nstepsinfile]; - int[] nsec = new int[nstepsinfile]; - float[] tedep = new float[nstepsinfile]; - float[] tnedep = new float[nstepsinfile]; - float[] length = new float[nstepsinfile]; - int[] pdg = new int[nstepsinfile]; - float[] mass = new float[nstepsinfile]; - float[] charge = new float[nstepsinfile]; - - int n = 0; - String _ach = "ACH_G4Step"; - while (inFile.hasNext() && n<nstepsinfile){ - String ach = inFile.next(); - if (!ach.equals(_ach)) { - System.out.println("??ach = " + ach); - } - nsteps[n] = inFile.nextInt(); - id[n] = inFile.nextInt(); - pid[n] = inFile.nextInt(); - fs[n] = inFile.nextInt(); - ls[n] = inFile.nextInt(); - stepn[n] = inFile.nextInt(); - pn[n] = inFile.next(); - nsec[n] = inFile.nextInt(); - tedep[n] = inFile.nextFloat(); - tnedep[n] = inFile.nextFloat(); - length[n] = inFile.nextFloat()/10.0f; - pdg[n] = inFile.nextInt(); - //System.out.println("pdg="+pdg); - mass[n] = inFile.nextFloat(); - charge[n] = inFile.nextFloat(); - x1[n] = inFile.nextFloat()/10.0f; - y1[n] = inFile.nextFloat()/10.0f; - z1[n] = inFile.nextFloat()/10.0f; - t1[n] = inFile.nextFloat(); - px1[n] = inFile.nextFloat(); - py1[n] = inFile.nextFloat(); - pz1[n] = inFile.nextFloat(); - ke1[n] = inFile.nextFloat(); - x2[n] = inFile.nextFloat()/10.0f; - y2[n] = inFile.nextFloat()/10.0f; - z2[n] = inFile.nextFloat()/10.0f; - t2[n] = inFile.nextFloat(); - px2[n] = inFile.nextFloat(); - py2[n] = inFile.nextFloat(); - pz2[n] = inFile.nextFloat(); - ke2[n] = inFile.nextFloat(); - ++n; - if (n%100000==0) System.out.println("Read "+n+" steps"); - } - System.out.println("Read "+n+" steps"); - inFile.close(); - System.out.println("Closed file."); - - para.put("nsteps",nsteps); - para.put("id",id); - para.put("pid",pid); - para.put("fs",fs); - para.put("ls",ls); - para.put("stepn",stepn); - para.put("pn",pn); - para.put("nsec",nsec); - para.put("tedep",tedep); - para.put("tnedep",tnedep); - para.put("length",length); - para.put("pdg",pdg); - para.put("mass",mass); - para.put("charge",charge); - para.put("x1", x1); - para.put("y1", y1); - para.put("z1", z1); - para.put("t1", t1); - para.put("x2", x2); - para.put("y2", y2); - para.put("z2", z2); - para.put("t2", t2); - para.put("px1", px1); - para.put("py1", py1); - para.put("pz1", pz1); - para.put("ke1", ke1); - para.put("px2", px2); - para.put("py2", py2); - para.put("pz2", pz2); - para.put("ke2", ke2); - para.put("numData", n); - //para.put("storeGateKey", "G4"); - - ABufferedEventSource.maxNumberOfEvents=1;//otherwise we run out of heap - AG4StepData g4d = new AG4StepData(para, ev); - ev.add(g4d); - } catch (AAtlantisException ex) { - Logger.getLogger(AG4StepData.class.getName()).log(Level.SEVERE, null, ex); - } - catch (OutOfMemoryError oom) { - Logger.getLogger(AG4StepData.class.getName()).log(Level.SEVERE,"Ran out of memory while trying to read G4Step data"); - } - ACanvas.getCanvas().repaintAllFromScratch(); - }//inFile!=null - - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AHECData.java b/graphics/AtlantisJava/src/atlantis/data/AHECData.java deleted file mode 100755 index 2b1efe56a62558ca5441439232d1ae8abe16cecf..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AHECData.java +++ /dev/null @@ -1,574 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.geometry.ACalorimeterDetector; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.AIdHelper; -import atlantis.utils.AMath; -import atlantis.utils.AUtilities; -import atlantis.utils.ALogger; -import java.io.IOException; -import com.Ostermiller.util.CSVParser; - -import java.io.InputStream; -import java.io.StringReader; -import java.io.FileNotFoundException; - - -/** - * The Hadronic End Cap calorimeter. - * - * @author Eric Jansen - */ -public class AHECData extends ACalorimeterData -{ - private static ALogger logger = ALogger.getLogger(AHECData.class); - - // data for real pulse shapes plots - private int numSamplings = 0; - private int[][] adcCounts = null; - private float[] cellTime = null; - private int[] cellGain = null; - private float[] cellPedestal = null; - private float[] adc2Mev = null; - private static boolean pulseShapesDataAvailable = false; - private static final String LOOKUP_TABLE_FILE = - AGlobals.instance().getHomeDirectory() + "configuration" + - System.getProperty("file.separator") + - "rpsplt_hec.csv"; - // number of lookup table values for real pulse shapes plots calculation - private static final short NUMBER_OF_LOOKUP_VALUES = 800; - - - - AHECData(AHashMap p, AEvent e) - { - super(p,e); - - for (int i = 0; i < numData; i++) - { - try - { - side[i] = (byte) AIdHelper.larBarrelEndcap(id[i]); - etaIndex[i] = (short) AIdHelper.larEta(id[i]); - phiIndex[i] = (short) AIdHelper.larPhi(id[i]); - sampling[i] = AIdHelper.larSampling(id[i]); - } - catch (AAtlantisException ex) - { - logger.error("Problem decoding ID " + id[i] + " in " + CALORIMETER_NAME + ": " + ex.getMessage()); - side[i] = 0; - etaIndex[i] = -1; - phiIndex[i] = -1; - sampling[i] = -1; - } - } - - makeHitToGeometryMapping(); - for (int i = 0; i < et.length; ++i) - { - et[i] = Math.abs(energy[i] / (float) Math.cosh(eta[i])); - } - - // Collect some constants we need for the histograms. - for (int i = 0; i < ACalorimeterDetector.count(); i++) - { - - if (ACalorimeterDetector.get(i).getName().indexOf(CALORIMETER_NAME) >= 0) - { - if (innerR == 0.0 || ACalorimeterDetector.get(i).getRMin() < innerR) - { - innerR = ACalorimeterDetector.get(i).getRMin(); - } - if (innerZ == 0.0 || ACalorimeterDetector.get(i).getZMin() < innerZ) - { - innerZ = ACalorimeterDetector.get(i).getZMin(); - } - if (phiGranularity == 0.0 || ACalorimeterDetector.get(i).getDeltaPhi() < phiGranularity) - { - phiGranularity = ACalorimeterDetector.get(i).getDeltaPhi(); - } - if (etaGranularity == 0.0 || ACalorimeterDetector.get(i).getDeltaEta() < etaGranularity) - { - etaGranularity = ACalorimeterDetector.get(i).getDeltaEta(); - } - if (outerEta == 0.0 || ACalorimeterDetector.get(i).getEtaMax() > outerEta) - { - outerEta = ACalorimeterDetector.get(i).getEtaMax(); - } - } - - if (outerR == 0.0 || ACalorimeterDetector.get(i).getRMax() > outerR) - { - outerR = ACalorimeterDetector.get(i).getRMax(); - } - if (outerZ == 0.0 || ACalorimeterDetector.get(i).getZMax() > outerZ) - { - outerZ = ACalorimeterDetector.get(i).getZMax(); - } - } - - // Add a little bit of extra margin to prevent binning errors due to - // rounding of numbers. - outerEta += etaGranularity; - - // read in HEC data from real pulse shapes plots - readPulseShapePlotData(p); - - } - - - - private void readPulseShapePlotData(AHashMap p) - { - // read ADCCounts and cell data for real pulse shapes plots - adcCounts = super.getADCCountsData(p); - - // read LAr digits (cell data) for real pulse shapes plots - cellTime = (p.get("cellTime") != null) ? p.getFloatArray("cellTime") : null; - cellGain = (p.get("cellGain") != null) ? p.getIntArray("cellGain") : null; - cellPedestal = (p.get("cellPedestal") != null) ? p.getFloatArray("cellPedestal") : null; - adc2Mev = (p.get("adc2Mev") != null) ? p.getFloatArray("adc2Mev") : null; - - pulseShapesDataAvailable = false; - if(adcCounts != null && cellTime != null && cellGain != null && - cellPedestal != null && adc2Mev != null) - { - pulseShapesDataAvailable = true; - numSamplings = adcCounts[0].length; - - logger.debug(CALORIMETER_NAME + - ": data for real pulse shape plots available"); - - if(ACalorimeterRPSPLT.areHECLookupTablesInitialized()) - { - logger.debug(CALORIMETER_NAME + - ": lookup tables have already been read in"); - } - else - { - logger.debug(CALORIMETER_NAME + - ": lookup table values have not been read in yet\n" + - " trying to read file: " + LOOKUP_TABLE_FILE); - - try - { - readLookupTableFile(); - logger.debug(CALORIMETER_NAME + - ": values from " + LOOKUP_TABLE_FILE + - " successfully read in"); - } - catch(AAtlantisException ex) - { - logger.debug(CALORIMETER_NAME + - ": reading " + LOOKUP_TABLE_FILE + - " failed, real pulse shapes plots will not " + - "be available, reason: " + ex.getMessage(), ex); - pulseShapesDataAvailable = false; - } - } - } - - } // readPulseShapePlotData() ------------------------------------------- - - - - /** - * Returns info about a selected hit (for picking) - * - * @param index int hit index - * @return String info - */ - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n ET="+String.format("%.3f",et[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Ex="+String.format("%.3f",et[index]*Math.cos(phi[index]))+" GeV "+ - "\n Ey="+String.format("%.3f",et[index]*Math.sin(phi[index]))+" GeV "+ - "\n Ez="+String.format("%.3f",et[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - String t = ""; - String cellInfo = ""; - - t = super.getHitInfo(index); - - cellInfo += "\n cell time = "; - cellInfo += (cellTime != null) ? Float.toString(cellTime[index]) + - " ns" : "n/a"; - cellInfo += "\n cell gain = "; - cellInfo += (cellGain != null) ? Integer.toString(cellGain[index]) : "n/a"; - cellInfo += "\n cell pedestal = "; - cellInfo += (cellPedestal != null) ? Float.toString(cellPedestal[index]) + - " ADC counts" : "n/a"; - - cellInfo += "\n ADC 2 MeV = "; - if(adc2Mev == null) - { - cellInfo += "n/a"; - } - else - { - // subtag adc2Mev was available in the event file - if(adc2Mev[index] != -1) - { - // other than -1: the factor was available in - // Athena (database) for this particular cell - cellInfo += Float.toString(adc2Mev[index]) + " (from database)"; - } - else - { - // -1 -> the factor wasn't available in Athena (database), - // use hardcoded constant for this particular cell - cellInfo += "-1 (n/a in database)"; - // see comment at the getADC2MevFactorPredefined() method - //, using predefined " + - // Float.toString(getADC2MevFactorPredefined()); - } - } - - cellInfo += pulseShapesDataAvailable ? "" : - "\n data for real pulse shapes plot n/a"; - - return t + cellInfo; - - } // getHitInfo() ------------------------------------------------------- - - @Override //ACalorimeterData - //Gives the hit time for this cell - protected double getTime(int hit) - { - if (cellTime == null) return 0.0; - else return cellTime[hit]; - } - -// /** -// * Determines adc2Mev factor value for a cell. The number either comes -// * with the event file (adc2Mev subtag), but sometimes is not available -// * in Athena (in the database) which is indicated by -1 in the event file -// * for a particular cell. In this case, use predefined constant in this -// * method. -// * -// * zdenek (2008-09-15): -// * These predefined values (which are used if adc2Mev factor is -1) should -// * no longer be used. if the factor is not present, do not plot the pulse -// * shape, just the ADC counts as these values are non-sense. The method -// * and references to it should be removed after some time (if calo people -// * don't change their mind to pre-define some other values and use those) -// -// * @param index int -// * @return String -// */ - /* - private float getADC2MevFactorPredefined() - { - - float r = 13.9f; - return r; - - } // getADC2MevFactorPredefined() --------------------------------------- - */ - - - - /** - * readLookupTableFile() reads in comma separated values (CSV) file - * with HEC real pulse shapes plots time and amplitude lookup values - * @param fileName String - * @throws AAtlantisException - */ - private void readLookupTableFile() throws AAtlantisException - { - try - { - InputStream is = AUtilities.getFileAsStream(LOOKUP_TABLE_FILE); - CSVParser parser = new CSVParser(is); - parser.setCommentStart("#"); - String arrayName = null; - - while((arrayName = parser.nextValue()) != null) - { - String valueArray = parser.nextValue(); // shall now contain all values - CSVParser parserArray = new CSVParser(new StringReader(valueArray)); - String[][] s = parserArray.getAllValues(); - if("HEC_AMPLITUDE".equals(arrayName)) - { - ACalorimeterRPSPLT.HEC_AMPLITUDE = - getLookupTableArray(s, NUMBER_OF_LOOKUP_VALUES); - } - else if("HEC_TIME".equals(arrayName)) - { - ACalorimeterRPSPLT.HEC_TIME = - getLookupTableArray(s, NUMBER_OF_LOOKUP_VALUES); - } - } - } - catch(FileNotFoundException e) - { - throw new AAtlantisException("could not find file: " + - LOOKUP_TABLE_FILE); - } - catch(IOException e) - { - throw new AAtlantisException("exception while reading file: " + - LOOKUP_TABLE_FILE); - } - catch(AAtlantisException e) - { - throw e; - } - - } // readLookupTableFile() ---------------------------------------------- - - - - protected void applyCuts() - { - super.applyCuts(); - cut("CutsCalo", "HECET", "HECET", et); - cut("CutsCalo", "HECEnergy", "HECEnergy", energy); - - int cutSub = parameterStore.get("CutsCalo", "HEC").getI(); - if(cutSub != -1) - { - cutArray(side, cutSub, "Endcap"); - } - - } - - /** - * Returns the name of the parameter group. - * - * @return String parameter group - */ - public String getParameterGroup() - { - return "HEC"; - } - - /** - * Returns the name of the datatype. - * - * @return String datatype - */ - public String getName() - { - return "HEC"; - } - - /** - * Returns the displayed name of datatype - * - * @return String screen name - */ - public String getNameScreenName() - { - return "HEC"; - } - - /** - * Returns the type of calorimeter (ECAL/HCAL) for a hit. - * - * @param index int hit index - * @return String calorimeter type - */ - public String getCalorimeterType(int index) - { - return "HCAL"; - } - - /** - * Returns the histograms for this projection. - * - * @param projection AProjection2D current projection - * @return ACoord[] polygons representing histograms - */ - protected ACoord[] getUserHistograms(AProjection2D projection) - { - ACoord[] data = ACoord.NO_HISTOGRAMS; - int mode = parameterStore.get("YX", "Mode").getI(); - if (projection instanceof AProjectionRZ) - data = getRZHistograms(); - else if (projection instanceof AProjectionFZ) - data = getFZHistograms(); - else if ((projection instanceof AProjectionYX) && (mode == AProjectionYX.MODE_HEC_1 || - mode == AProjectionYX.MODE_HEC_2 || mode == AProjectionYX.MODE_HEC_3 || - mode == AProjectionYX.MODE_HEC_4 || mode == AProjectionYX.MODE_HEC_SUMMED)) - data = getYXHistograms(); - return projection.nonLinearTransform(data); - } - - - -// /** -// * Call util class which plots cell pulse shapes provided that -// * all real pulse shapes data is available -// * Functions calculates values of real pulse shape calculated in the method -// * getPhysicsPulseShape(). -// * This method is called from pick interaction. -// * -// * @param index int -// */ - /*public void plotPulseShapes(int index) - { - - if(pulseShapesDataAvailable) - { - String title = getPulseTitleString(index); - - int[][] adcCountsLocal = new int[][] { adcCounts[index] }; - - if(super.checkADCCountsAvailability(adcCountsLocal)) - { - // adc counts are available - logger.debug(CALORIMETER_NAME + " adc counts (digits) are " + - "available for pulse shapes plots for this cell."); - } - else - { - AOutput.append("\nADC counts are not available for this cell, " + - "can't plot pulse shapes.", ALogPane.WARNING); - return; - } - - - float[] time = ACalorimeterRPSPLT.HEC_TIME; // lookup tables - float[] amplitude = ACalorimeterRPSPLT.HEC_AMPLITUDE; // lookup tables - - // step - starting from 1, need to get step numbers within - // number of ADC samples (adcCounts[0].length) - double step = (adcCounts[0].length - 1) / (float) NUMBER_OF_LOOKUP_VALUES; - double[][] realPulse = new double[1][NUMBER_OF_LOOKUP_VALUES]; // 1 channel - double d = 1.0; - // if adc2Mev != -1 -> use value from event file, otherwise predefined value - // see comment at the getADC2MevFactorPredefined() method - // factor variable is used as a flag whether or not to plot pulse shape, - // if is -1 (adc2Mev not available), then want to see only the adc counts - // and don't calculate the pulse shapes - // getADC2MevFactorPredefined(index) is no longer in use, see comment at it - float factor = adc2Mev[index]; - - double energyLocal = energy[index] * 1000.0 / factor; - try - { - if(factor != -1) - { - for(int i = 0; i < NUMBER_OF_LOOKUP_VALUES; i++) - { - d += step; - realPulse[0][i] = super.getPhysicsPulseShape(d, cellTime[index], - cellPedestal[index], energyLocal, - amplitude, time, NUMBER_OF_LOOKUP_VALUES); - } - } - } - catch(AAtlantisException aaex) - { - AOutput.append(aaex.getMessage(), ALogPane.WARNING); - return; - } - - if(factor != -1) - { - logger.debug("adc2Mev factor available, plotting full plot."); - APulseShapePlot.plotRealPulseShapes(adcCountsLocal, realPulse, - step, null, title); - } - else - { - logger.debug("adc2Mev factor not available, plotting just adc counts."); - APulseShapePlot.plotADCCounts(adcCountsLocal, title, null); - } - - } // if(pulseShapesDataAvailable) - else - { - return; - } - - }*/ // plotPulseShapes() -------------------------------------------------- - - @Override - protected int[][] getADCCounts(int index) { - - if (pulseShapesDataAvailable) { - return new int[][]{adcCounts[index]}; - } else { - return null; - } - } - - /** - * Calculate local time for pulse shape plots - */ - protected double getLocalTime(double xTime, double cellTime, int numSamplings) { - int nominalPeakSample = (int)(numSamplings / 2.); - return ((xTime - nominalPeakSample + 3) * 25.0) - cellTime; - } - - @Override - protected double[][] getPulseShape(int index) { - - float[] time = ACalorimeterRPSPLT.HEC_TIME; // lookup tables - float[] amplitude = ACalorimeterRPSPLT.HEC_AMPLITUDE; // lookup tables - - // step - starting from 1, need to get step numbers within - // number of ADC samples (adcCounts[0].length) - double step = getPulseStep(index); - double[][] realPulse = new double[1][NUMBER_OF_LOOKUP_VALUES]; // 1 channel - double d = 1.0; - // if adc2Mev != -1 -> use value from event file, otherwise predefined value - // see comment at the getADC2MevFactorPredefined() method - // factor variable is used as a flag whether or not to plot pulse shape, - // if is -1 (adc2Mev not available), then want to see only the adc counts - // and don't calculate the pulse shapes - // getADC2MevFactorPredefined(index) is no longer in use, see comment at it - float factor = adc2Mev[index]; - - double energyLocal = energy[index] * 1000.0 / factor; - try { - if (factor != -1) { - for (int i = 0; i < NUMBER_OF_LOOKUP_VALUES; i++) { - d += step; - double localTime = getLocalTime(d, cellTime[index], this.numSamplings); - realPulse[0][i] = super.getPhysicsPulseShape(localTime, - cellPedestal[index], energyLocal, - amplitude, time, NUMBER_OF_LOOKUP_VALUES); - } - } - } catch (AAtlantisException aaex) { - AOutput.append(aaex.getMessage(), ALogInterface.WARNING); - return null; - } - - if (factor != -1) { - logger.debug("adc2Mev factor available, plotting full plot."); - return realPulse; - } else { - logger.debug("adc2Mev factor not available, plotting just adc counts."); - return null; - } - } - - @Override - protected double getPulseStep(int index) { - return (adcCounts[0].length - 1) / (float) NUMBER_OF_LOOKUP_VALUES; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AHelix.java b/graphics/AtlantisJava/src/atlantis/data/AHelix.java deleted file mode 100644 index 98e397b2275ee38e5be6ffcb0f4b946e1afc6a3a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AHelix.java +++ /dev/null @@ -1,854 +0,0 @@ -package atlantis.data; - -import atlantis.globals.AGlobals; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjectionVP; -import atlantis.utils.A3Vector; -import atlantis.utils.ALogger; -import atlantis.utils.AMath; - -/** - * Base class for tracks with perigee parameters. Includes code for drawing - * helices as a function of the helix angle alpha. - * - * @author Eric Jansen - */ -public class AHelix { - - private final static ALogger logger = ALogger.getLogger(AHelix.class); - - // Constants - public static final double MIN_RADIUS_PHI = 2.; - public static final double TRACKER_RADIUS = 108.; - public static final double TRACKER_LENGTH = 270.; - public static final double SOLENOID_RADIUS = 125.; - public static final double SOLENOID_LENGTH = 280.; - protected static final int NUM_HELIX_POINTS = 30; - - // Parameters from the config/GUI we need - private static double curvature = -1; - - // Vertex w.r.t. which we define the perigee parameters - private float xVtx, yVtx, zVtx; - - // Perigee parameters for the track - private float d0, phi0, z0, cotanTheta, pt; - - // Additional space points outside the solenoid (muon tracks) - private float extraX[] = null; - private float extraY[] = null; - private float extraZ[] = null; - - // Covariance matrix - private double[][] cov = null; - - // Center point, radius and correction factors for the helix - private double xC, yC, R, dr1, dr2, dz1; - - // Sign of alpha, determines direction of curvature of the helix - private float S; - - // Alpha value where the helix crosses MIN_RADIUS_PHI. This is the starting - // value for all the phi-based projections, since phi is undefined at rho=0. - private double alphaMin = 0.; - - // Alpha value at which the helix meets its last space point or where it - // exits the tracker if no space points were defined. - private double alphaMax = Math.PI; - - // Alpha value at which the helix leaves the solenoidal field. When helices - // are drawn beyond this value, for example when extrapolating to the - // calorimeters, they switch from a helix to a straight line here. - private double alphaSolenoid = Math.PI; - - private static final APar parameterStore = APar.instance(); - - AHelix(AOldHelix helix) { - this((float)helix.d0, (float)helix.z0, (float)helix.phi0, (float)helix.tL, (float)helix.pT); - } - - AHelix(float rhoVertex, float phiVertex, float zVertex, - float pTTrack, float phiTrack, float etaTrack, int charge, float rhoEndVertex) { - - this(rhoVertex, phiVertex, zVertex, pTTrack, phiTrack, etaTrack, charge); - this.alphaMax = getAlphaExtrapolated(rhoEndVertex, TRACKER_LENGTH); - } - - AHelix(float rhoVertex, float phiVertex, float zVertex, - float pTTrack, float phiTrack, float eta, int charge) { - - this(0.f, 0.f, phiTrack, (float)AMath.tanLambda(eta), charge*Math.abs(pTTrack), - (float)(rhoVertex*Math.cos(phiVertex)), (float)(rhoVertex*Math.sin(phiVertex)), zVertex); - } - - AHelix(float d0, float z0, float phi0, float tL, float pT, float[][] cov) { - this(d0, z0, phi0, tL, pT); - this.setCovariance(cov); - } - - AHelix(float d0, float z0, float phi0, float cotanTheta, float pt) { - this(d0, z0, phi0, cotanTheta, pt, 0.f, 0.f, 0.f); - } - - /** - * Construct a new track from its perigee parameters. - * @param d0 transverse impact parameter - * @param z0 longitudinal impact parameter - * @param phi0 phi of the point of closest approach in degrees - * @param cotanTheta cotan(theta), angle of the track in the RZ-plane - * @param pt signed transverse momentum, sign encodes charge - * @param xVtx vertex x-coordinate - * @param yVtx vertex y-coordinate - * @param zVtx vertex z-coordinate - */ - AHelix(float d0, float z0, float phi0, float cotanTheta, float pt, - float xVtx, float yVtx, float zVtx) { - - this.xVtx = xVtx; - this.yVtx = yVtx; - this.zVtx = zVtx; - this.d0 = d0; - this.z0 = z0; - this.phi0 = (float)Math.toRadians(phi0); - this.cotanTheta = cotanTheta; // cotan(theta) = tan(lambda) - this.pt = Math.abs(pt); - this.S = -Math.signum(pt); - this.dr1 = 0; - this.dr2 = 0; - this.dz1 = 0; - - // Curvature/pT relation, magnetic field strength. - if (AHelix.curvature <= 0) { - AParameter curvatureParameter = parameterStore.get("Event", "Curvature"); - if (curvatureParameter != null) { - AHelix.curvature = curvatureParameter.getD(); - } else { - AHelix.curvature = 100/0.6; - logger.error("Curvature parameter not found," - + " defaulting to " + AHelix.curvature); - } - } - - // Radius and center point of the helix. The radius is limited to 1e6, - // which on the scale of our tracker corresponds to a straight line. - // This allows cosmics without B-field to be drawn with the same code. - this.R = Math.min(AHelix.curvature * this.pt, 1e6); - this.xC = xVtx - (this.S*this.R + this.d0) * Math.sin(this.phi0); - this.yC = yVtx + (this.S*this.R + this.d0) * Math.cos(this.phi0); - - // The alpha value from which the helix start. - this.alphaMin = 0.; - - // Calculate when this helix leaves the tracker. This is either (1) - // through the barrel or (2) through the endcap. The endcap expression - // is just the function getZ(alpha) reversed. Take the minumum of the - // two, so whatever happens first. - this.alphaMax = getAlphaCylinder(TRACKER_RADIUS, TRACKER_LENGTH); - - // Same as above, but now for the solenoid. - this.alphaSolenoid = getAlphaCylinder(SOLENOID_RADIUS, SOLENOID_LENGTH); - } - - /** - * Fit the radius of the helix to the given points. The radius is described - * by R + dr1 * alpha + dr2 * alpha^2. - * @param x array of x coordinates of points on the helix - * @param y array of y coordinates of points on the helix - * @param z array of z coordinates of points on the helix - */ - public double setPoints(float[] x, float[] y, float[] z, int numPoints) { - - this.dr1 = 0.; - this.dr2 = 0.; - this.dz1 = 0.; - - // Points outside the solenoid are taken as is and added to the end of the track - while (numPoints > 0 && (z[numPoints-1] > SOLENOID_LENGTH - || Math.hypot(x[numPoints-1], y[numPoints-1]) > SOLENOID_RADIUS)) { - - numPoints--; - } - - if (x.length > numPoints) { - extraX = new float[x.length - numPoints]; - extraY = new float[y.length - numPoints]; - extraZ = new float[z.length - numPoints]; - - for(int i=0; i<x.length - numPoints; i++) { - extraX[i] = x[numPoints+i]; - extraY[i] = y[numPoints+i]; - extraZ[i] = z[numPoints+i]; - } - } - - if (numPoints == 1) { - - // Just one point, only do a linear in/decrease of R and Z - double alpha = getAlpha(x[0], y[0]); - this.dr1 = (getRadius(x[0], y[0]) - this.R) / alpha; - this.dz1 = (z[0] - getZ(alpha)) / alpha; - - // Draw helix until this point - this.alphaMax = alpha; - - } else { - - // Several points, perform a least-squares fit using the functions - // R = R + dr1 * alpha + dr2 * alpha^2 and Z = Z + dz1 * alpha. - double a2 = 0., a3 = 0., a4 = 0.; - double dRa = 0., dRa2 = 0., dZa = 0.; - for (int i=0; i<numPoints; i++) { - double alpha = getAlpha(x[i], y[i]); - double rho = getRadius(x[i], y[i]); - - //a1 += alpha; - a2 += Math.pow(alpha, 2.); - a3 += Math.pow(alpha, 3.); - a4 += Math.pow(alpha, 4.); - dRa += (rho - this.R) * alpha; - dRa2 += (rho - this.R) * alpha * alpha; - - dZa += (z[i] - getZ(alpha)) * alpha; - - if (i == 0 || alpha > this.alphaMax) { - this.alphaMax = alpha; - } - } - - // Quadratic - this.dr1 = (dRa / a3 - dRa2 / a4) / (a2 / a3 - a3 / a4); - this.dr2 = (dRa / a2 - dRa2 / a3) / (a3 / a2 - a4 / a3); - - // Linear - this.dz1 = dZa / a2; - - } - - // Return relative correction; distance from the original position at - // the end point, divided by the length of the curve. - double change = Math.hypot(this.dr1 + this.alphaMax*this.dr2, this.dz1) / this.R; - logger.debug("Fitting changed R(maxAlpha) by " + change); - return change; - } - - /** - * Sets the covariance matrix of the track. - * @param cov new covariance matrix - */ - public final void setCovariance(float[][] cov) { - - // Covariance needs to be double[][] for the fitting classes - this.cov = new double[cov.length][cov[0].length]; - - for (int i=0; i<cov.length; i++) { - for (int j=0; j<cov[i].length; j++) { - this.cov[i][j] = cov[i][j]; - } - } - } - - /** - * Sets the covariance matrix of the track. - * @param cov new covariance matrix - */ - public final void setCovariance(double[][] cov) { - this.cov = cov; - } - - /** - * Returns the starting alpha value for the phi-based projections. - * @return alpha value - */ - public double getAlphaMin() { - return alphaMin; - } - - /** - * Returns the alpha value at the end of the helix - * @return alpha value - */ - public double getAlphaMax() { - return alphaMax; - } - - /** - * Returns the alpha value at which the track exits the solenoidal field - * @return alpha value - */ - public double getAlphaSolenoid() { - return alphaSolenoid; - } - - /** - * Calculates the alpha coordinate for a specific point. Alpha is the angle - * from the center point of the helix to the point. For the helix The angle - * should be positive and alpha=0 is the perigee. Returns negative values - * for points before the perigee point. - * @param x x coordinate of a point - * @param y y coordinate of a point - * @return alpha - */ - public double getAlpha(double x, double y) { - // Get the alpha parameter for this point, in the range 0-2*pi - double alpha = AMath.nearestPhiRadians(this.S * (Math.atan2((y - this.yC), (x - this.xC)) - this.phi0) + Math.PI/2.); - - // When dealing with a real space point, alpha can of course be slightly negative - if (alpha > 3./2. * Math.PI) alpha -= 2.*Math.PI; - - return alpha; - } - - /** - * Calculates the alpha coordinate where the helix has the given distance - * from the origin. Alpha is the angle from the center point of the helix to - * the point. The angle is always positive and alpha=0 is the perigee. - * @param rho radius with respect to the origin - * @return alpha - */ - public final double getAlphaCylinder(double rho, double z) { - - double alphaZ, alphaRho; - if (this.cotanTheta == 0) { - alphaZ = Math.PI; - } else { - alphaZ = zVtx + (Math.signum(this.cotanTheta)*z - this.z0) / (this.cotanTheta * this.R + this.dz1); - } - - // We take a circle centered around (0,0) with the requested radius - // (rho) and intersect it with the helix (circle around (xC,yC) with - // radius R. The distance between the centers of the two circles is D. - double D = Math.hypot(this.xC, this.yC); - - // By equating the intersection points in both circles we obtain the - // position of the intersection points as a distance d from (xC,yC) - // along the line from center to center. - double d = (this.R * this.R - rho * rho + D * D) / (2 * D); - - if (d >= this.R) { - // Helix is fully outside the requested radius, return 0. - alphaRho = 0; - } else if (d <= -this.R) { - // Helix is fully inside the requested radius, return pi. - alphaRho = Math.PI; - } else { - // Helix needs to be stopped when it reaches requested radius. - // Now the angle alpha is just the angle between the center-center - // line and the line from (xC,yC) to the intersection point. The - // helix is such that alpha is always taken positive, so it doesn't - // matter which of the two intersection points we take. The cosine - // of alpha is then simply the division of d by the radius of the - // circle R. This method should never return an alpha outside the - // solenoid, for the extrapolation there is getAlphaExtrapolated(). - alphaRho = Math.min(Math.acos(d / this.R), alphaSolenoid); - } - - return Math.min(alphaRho, alphaZ); - } - - /** - * Calculates the pseudo alpha coordinate and if necessary extrapolates - * beyond the curved part up to the given radius. Inside the solenoid this - * method falls back to getAlphaCylinder, so it can be used for any radius. - * The pseudo alpha coordinate is such that the distance along the curve is - * R*alpha also for the straight part. This parameterization allow the - * description of z to remain the same for any alpha. - * @param rho radius to extrapolate to - * @param z distance along the beam axis to extrapolate to - * @return alpha - */ - public final double getAlphaExtrapolated(double rho, double z) { - - // Check if the track actually makes it to the solenoid. - if (this.alphaSolenoid >= Math.PI) { - // If not, return the max alpha inside the tracker instead. - return getAlphaCylinder(rho, z); - } - - // Calculate the coordinates (xL,yL) of the last point inside the solenoid. - double xL = getX(this.alphaSolenoid); - double yL = getY(this.alphaSolenoid); - - // Check if we are actually outside the solenoid at this rho value - if (rho < Math.hypot(xL, yL)) { - // If not, return the normal alpha instead. For tracks that exit the - // solenoid through the endcap this is also fine, z(alpha) is the - // same inside and outside the field. So the max value returned is - // valid either way. - return getAlphaCylinder(rho, z); - } - - double alphaZ, alphaRho; - if (this.cotanTheta == 0) { - alphaZ = Math.PI; - } else { - alphaZ = zVtx + (Math.signum(this.cotanTheta)*z - this.z0) / (this.cotanTheta * this.R + this.dz1); - } - - // Calculate the direction of the track at the last point inside the solenoid, - // this is the direction in which it will be extrapolated through the calorimeters. - double dx = Math.cos(this.phi0 + this.S * this.alphaSolenoid); - double dy = Math.sin(this.phi0 + this.S * this.alphaSolenoid); - - // Now we have for a point on the extrapolated track - // x(alpha) = xL + dx * (alpha-this.alphaCurve) - // y(alpha) = yL + dy * (alpha-this.alphaCurve) - // Setting x^2+y^2 = rho^2 and solving for alpha then gives: - double D = rho*rho - (xL*dy - yL*dx)*(xL*dy - yL*dx); - if (D > 0) { - alphaRho = this.alphaSolenoid - (xL*dx + yL*dy)/this.R + Math.sqrt(D)/this.R; - } else { - return Math.PI; - } - - return Math.min(alphaRho, alphaZ); - } - - /** - * Calculate the distance between a point and the center of the helix. - * @param x x coordinate of the point - * @param y y coordinate of the point - * @return distance between (x,y) and the center of the helix - */ - private double getRadius(double x, double y) { - return Math.hypot(x - xC, y - yC); - } - - /** - * Returns the x coordinate for a point on the helix parameterized by alpha. - * @param alpha helix angular parameter - * @return x coordinate - */ - public double getX(double alpha) { - // Correct the radius using the values obtained from the fit and calculate x - double localR = R + dr1 * alpha + dr2 * alpha * alpha; - if (alpha <= alphaSolenoid) { - return xC - S * localR * Math.cos(phi0 + S * alpha + Math.PI/2.); - } else { - double xL = xC - S * localR * Math.cos(phi0 + S * alphaSolenoid + Math.PI/2.); - return xL + R*Math.cos(phi0 + this.S * alphaSolenoid) * (alpha-alphaSolenoid); - } - } - - /** - * Returns the y coordinate for a point on the helix parameterized by alpha. - * @param alpha helix angular parameter - * @return y coordinate - */ - public double getY(double alpha) { - // Correct the radius using the values obtained from the fit and calculate y - double localR = R + dr1 * alpha + dr2 * alpha * alpha; - if (alpha <= alphaSolenoid) { - return yC - S * localR * Math.sin(phi0 + S * alpha + Math.PI/2.); - } else { - double yL = yC - this.S * localR * Math.sin(phi0 + this.S * alphaSolenoid + Math.PI/2.); - return yL + R*Math.sin(phi0 + S * alphaSolenoid) * (alpha-alphaSolenoid); - } - } - - /** - * Returns the rho coordinate for a point on the helix parameterized by alpha. - * @param alpha helix angular parameter - * @return rho coordinate - */ - public double getRho(double alpha) { - return Math.hypot(getX(alpha), getY(alpha)); - } - - public double getRhoVtx() { - return Math.hypot(xVtx, yVtx); - } - - /** - * Returns the z coordinate for a point on the helix parameterized by alpha. - * @param alpha helix angular parameter - * @return z coordinate - */ - public double getZ(double alpha) { - // For z we don't use the corrected R, since it was calculated against - // the uncorrected one. - return z0 + cotanTheta * R * alpha + dz1 * alpha; - } - - public double getZVtx() { - return zVtx; - } - - /** - * Returns the phi coordinate of a point on the helix parameterized by alpha. - * @param alpha helix angular parameter - * @param useVertex calculate phi w.r.t. the primary vertex - * @return phi coordinate - */ - public double getPhi(double alpha, boolean useVertex) { - if (useVertex) { - return AParameterUtilities.phi(getX(alpha), getY(alpha)); - } else { - return Math.toDegrees(Math.atan2(getY(alpha), getX(alpha))); - } - } - - /** - * Return eta coordinate for a point on the helix parameterized by alpha. - * @param alpha helix angular parameter - * @param vsign side (-1/+1) of the split track in the v-plot, 0 for true eta - * @return eta coordinate - */ - public double getEta(double alpha, int vsign) { - double rho = getRho(alpha); - double z = getZ(alpha); - double deta = Math.abs(AProjectionVP.getDeltaEta(rho, z)); - - return AParameterUtilities.eta(z, rho) + vsign*deta; - } - - /** - * Returns an array representing the x coordinates of the helix between - * alpha1 and alpha2. - * @param alpha1 start alpha - * @param alpha2 end alpha - * @return x coordinates - */ - public double[] getX(double alpha1, double alpha2) { - int numPoints = NUM_HELIX_POINTS; - if (alpha2 >= alphaMax && extraX != null) { - numPoints += extraX.length; - } - double[] x = new double[numPoints]; - - double dalpha = (alpha2 - alpha1) / (NUM_HELIX_POINTS-1); - for (int i=0; i<NUM_HELIX_POINTS; i++) { - x[i] = getX(alpha1 + i*dalpha); - } - - for (int i=0; i<numPoints-NUM_HELIX_POINTS; i++) { - x[NUM_HELIX_POINTS+i] = extraX[i]; - } - - return x; - } - - /** - * Returns an array representing the y coordinates of the helix between - * alpha1 and alpha2. - * @param alpha1 start alpha - * @param alpha2 end alpha - * @return y coordinates - */ - public double[] getY(double alpha1, double alpha2) { - int numPoints = NUM_HELIX_POINTS; - if (alpha2 >= alphaMax && extraY != null) { - numPoints += extraY.length; - } - double[] y = new double[numPoints]; - - double dalpha = (alpha2 - alpha1) / (NUM_HELIX_POINTS-1); - for (int i=0; i<NUM_HELIX_POINTS; i++) { - y[i] = getY(alpha1 + i*dalpha); - } - - for (int i=0; i<numPoints-NUM_HELIX_POINTS; i++) { - y[NUM_HELIX_POINTS+i] = extraY[i]; - } - - return y; - } - - /** - * Returns an array representing the z coordinates of the helix between - * alpha1 and alpha2. - * @param alpha1 start alpha - * @param alpha2 end alpha - * @return z coordinates - */ - public double[] getZ(double alpha1, double alpha2) { - int numPoints = NUM_HELIX_POINTS; - if (alpha2 >= alphaMax && extraZ != null) { - numPoints += extraZ.length; - } - double[] z = new double[numPoints]; - - double dalpha = (alpha2 - alpha1) / (NUM_HELIX_POINTS-1); - for (int i=0; i<NUM_HELIX_POINTS; i++) { - z[i] = getZ(alpha1 + i*dalpha); - } - - for (int i=0; i<numPoints-NUM_HELIX_POINTS; i++) { - z[NUM_HELIX_POINTS+i] = extraZ[i]; - } - return z; - } - - /** - * Returns an array representing the rho coordinates of the helix between - * alpha1 and alpha2. - * @param alpha1 start alpha - * @param alpha2 end alpha - * @param signed return signed rho values for use in RZ - * @return rho coordinates - */ - public double[] getRho(double alpha1, double alpha2, boolean signed) { - int numPoints = NUM_HELIX_POINTS; - if (alpha2 >= alphaMax && extraX != null && extraY != null) { - numPoints += extraX.length; - } - double[] rho = new double[numPoints]; - - double sign = 1.; - if (signed) { - AParameter phiPar = parameterStore.get("RZ", "Phi"); - if (phiPar != null) { - double phi = getPhi((alpha1+alpha2)/2, false); - double diff = Math.toRadians(Math.abs(phi - phiPar.getD())); - if (diff > Math.PI / 2. && diff <= 3 * Math.PI / 2.) { - sign = -1.; - } - } else { - logger.error("Could not read RZ cutting plane parameter"); - } - } - - double dalpha = (alpha2 - alpha1) / (NUM_HELIX_POINTS-1); - for (int i=0; i<NUM_HELIX_POINTS; i++) { - rho[i] = sign * getRho(alpha1 + i*dalpha); - } - - for (int i=0; i<numPoints-NUM_HELIX_POINTS; i++) { - rho[NUM_HELIX_POINTS+i] = sign * Math.hypot(extraX[i], extraY[i]); - } - - return rho; - } - - /** - * Returns an array representing the phi coordinates of the helix between - * alpha1 and alpha2. - * @param alpha1 start alpha - * @param alpha2 end alpha - * @param vplot return all points twice for use in the v-plot - * @return phi coordinates - */ - public double[] getPhi(double alpha1, double alpha2, boolean vplot) { - int numPoints = NUM_HELIX_POINTS; - if (vplot) { - numPoints += NUM_HELIX_POINTS-1; - } else if (alpha2 >= alphaMax && extraX != null && extraY != null) { - numPoints += extraX.length; - } - double[] phi = new double[numPoints]; - - double dalpha = (alpha2 - alpha1) / (NUM_HELIX_POINTS-1); - for (int i=0; i<NUM_HELIX_POINTS; i++) { - phi[i] = getPhi(alpha1 + i*dalpha, true); - if (vplot) phi[numPoints-i-1] = phi[i]; - } - - if (!vplot) { - for (int i=0; i<numPoints-NUM_HELIX_POINTS; i++) { - phi[NUM_HELIX_POINTS+i] = AParameterUtilities.phi(extraX[i], extraY[i]); - } - } - - // Minimise distance from one point to the next to avoid phi wrapping - // around: use {25, 10, -5} and not {25, 10, 355}. - for (int i=1; i<phi.length; i++) { - phi[i] = AMath.nearestPhiDegrees(phi[i], phi[i-1]); - } - - return phi; - } - - /** - * Returns an array representing the eta coordinates of the helix between - * alpha1 and alpha2. - * @param alpha1 start alpha - * @param alpha2 end alpha - * @return eta coordinates - */ - public double[] getEta(double alpha1, double alpha2) { - double[] eta = new double[2*NUM_HELIX_POINTS - 1]; - double dalpha = (alpha2 - alpha1) / (NUM_HELIX_POINTS-1); - - for (int i=0; i<NUM_HELIX_POINTS; i++) { - double alpha = alpha1 + i*dalpha; - eta[i] = getEta(alpha, -1); - eta[2*NUM_HELIX_POINTS-2-i] = getEta(alpha, +1); - } - - return eta; - } - - /** - * Track momentum at perigee, x component - * @return px - */ - public double pX() { - return this.pt * Math.cos(this.phi0); - } - - /** - * Track momentum at perigee, y component - * @return py - */ - public double pY() { - return this.pt * Math.sin(this.phi0); - } - - /** - * Track momentum at perigee, z component - * @return pz - */ - public double pZ() { - return this.pt * this.cotanTheta; - } - - /** - * Signed transverse momentum at perigee - * @return pt - */ - public double pT() { - return -this.S * this.pt; - } - - public A3Vector p() { - return new A3Vector(pX(), pY(), pZ()); - } - - /** - * Pseudorapidity of track from perigee - * @return eta - */ - public double eta() { - return -Math.log(Math.hypot(cotanTheta, 1.) - cotanTheta); - } - - /** - * Phi of perigee - * @return phi0 - */ - public double phi0() { - return (float)Math.toDegrees(phi0); - } - - /** - * Returns the parameters of this helix in the "old" format. This is still - * used by the AFit class to fit secondary vertices in Atlantis. - * @return helix parameters - */ - public double[] getPar() { // Used by unit tests and AVertexFit - return new double[] { - d0, - z0, - phi0 < 0 ? phi0 + 2*Math.PI : phi0, - cotanTheta, - -S/pt - }; - } - - /** - * Returns the covariance matrix of this helix as a an array of double. - * @return covariance matrix - */ - public double[][] getCovariance() { - return cov; - } - - public double getRhoEndVertex() { - return getRho(alphaMax); - } - - public void setPhiStartByXYPoint(double Vx, double Vy) { - alphaMin = this.getAlpha(Vx, Vy); - } - - public float d0() { - return d0; - } - - public float z0() { - return z0; - } - - public float cotanTheta() { - return cotanTheta; - } - - public double getXc() { - return xC; - } - - public double getYc() { - return yC; - } - - /** - * Helper method for toString, formats a single line of information. - * @param name variable name - * @param value variable value - * @param uncertainty variable uncertainty - * @param units variable units - * @return formatted string - */ - private String formatInfo(String name, double value, double uncertainty, String units) { - return formatInfo(name, String.format("%.3f", value), - uncertainty > 0 ? String.format("%.3f", uncertainty) : null, units); - } - - /** - * Helper method for toString, formats a single line of information. - * @param name variable name - * @param value variable value - * @param uncertainty variable uncertainty - * @param units variable units - * @return formatted string - */ - private String formatInfo(String name, String value, String uncertainty, String units) { - String output = "\n "; - output += name + " = " + value; - if (uncertainty != null) - output += " " + AMath.PLUSMINUS + " " + uncertainty; - if (units != null) - output += " " + units; - - return output; - } - - @Override - public String toString() { - String output = ""; - - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if (simpleOutput > 0) { - if (simpleOutput == 1 || simpleOutput == 3) { - output += formatInfo("PT", pt, 0., "GeV"); - output += formatInfo(AMath.ETA, eta(), 0., null); - output += formatInfo(AMath.PHI, phi0(), 0., AMath.DEGREES); - } - if (simpleOutput == 2 || simpleOutput == 3) { - output += formatInfo("Px", pt*Math.cos(phi0), 0., "GeV"); - output += formatInfo("Py", pt*Math.sin(phi0), 0., "GeV"); - output += formatInfo("Pz", pt*Math.sinh(eta()), 0., "GeV"); - output += formatInfo("Charge", S < 0 ? "+1" : "-1", null, null); - } - - return output; - - } else { - - output += formatInfo("d0", d0, cov != null ? Math.sqrt(cov[0][0]) : 0., "cm"); - output += formatInfo("z0", z0, cov != null ? Math.sqrt(cov[1][1]) : 0., "cm"); - - double pv[] = AParameterUtilities.getPrimaryVertex(); - output += formatInfo("|z0-zVtx|", Math.abs(z0-pv[2]), 0., "cm"); - output += formatInfo("phi0", phi0(), cov != null ? Math.toDegrees(Math.sqrt(cov[2][2])) : 0., AMath.DEGREES); - output += formatInfo(" ", phi0, cov != null ? Math.sqrt(cov[2][2]) : 0., "rad"); - output += formatInfo("cotan(theta)", cotanTheta, cov != null ? Math.sqrt(cov[3][3]) : 0., null); - output += formatInfo(AMath.ETA, eta(), cov != null ? Math.sqrt(cov[3][3] / (cotanTheta * cotanTheta + 1.0)) : 0., null); - output += formatInfo("pT", pT(), 0., "GeV"); - output += formatInfo("p", AMath.getPFromPttL(pt, cotanTheta), 0., "GeV"); - - return output; - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AHelixAODData.java b/graphics/AtlantisJava/src/atlantis/data/AHelixAODData.java deleted file mode 100755 index 0c3934033e960b39a77fae73f635639ba0d443fe..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AHelixAODData.java +++ /dev/null @@ -1,178 +0,0 @@ -package atlantis.data; - -import atlantis.canvas.AWindow; -import atlantis.event.AEvent; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionVP; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - -public abstract class AHelixAODData extends AAODData -{ - protected AHelix[] h = null; - - AHelixAODData(AHashMap p, AEvent e) - { - super(p,e); - h = new AHelix[numData]; - float[] d0 = new float[numData]; - float[] z0 = new float[numData]; - float[] tl = new float[numData]; - for (int i = 0; i < numData; i++) - { - d0[i] = 0.0f; - z0[i] = 0.0f; - tl[i] = (float) AMath.tanLambda((double)eta[i]); - h[i] = new AHelix(d0[i], z0[i], (float) Math.toDegrees(phi[i]), tl[i], pT[i]); - } - } - - private void drawHelix(AWindow window, AGraphics ag, AProjection2D projection) - { - int drawnAs = parameterStore.get("InDetTrack", "DrawnAs").getI(); - if (drawnAs == ATrackData.DRAW_NEWHELIX) { - - boolean showS3D = parameterStore.get("Data", "S3D").getStatus(); - AParameter shortV = parameterStore.get("VP", "ShortV"); - - makeDrawList(); - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - index[i] = j; - - double alphaMin = h[j].getAlphaExtrapolated(projection.getMinRho(), AHelix.TRACKER_LENGTH); - double alphaMax = h[j].getAlphaExtrapolated(AProjectionVP.getRhoVPlot(), AHelix.TRACKER_LENGTH); - if (shortV.getStatus() && !showS3D) { - alphaMin = alphaMax - shortV.getD() * (alphaMax - alphaMin); - } - - hv[0][i] = h[j].getEta(alphaMin, alphaMax); - hv[1][i] = h[j].getPhi(alphaMin, alphaMax, true); - } - - ag.draw(window.calculateDisplay(new ACoord(hv, index, this, ACoord.POLYLINES))); - - } else { - // borrow the implementation in for tracks - // phi wrap around is done in user coordinates, so we convert to user coordinates, - // do the phi wrap around and convert back to display coordinates - ag.draw(window.calculateDisplay(window.calculateUser( - getVPDisplayHelices(window, projection)).includePhiWrapAround(projection.getName()) - )); - } - } - - // give back Drawable helices - private ADHelix[] getHelices() - { - makeDrawList(); - ADHelix[] tempList = new ADHelix[numDraw]; - - for (int i = 0; i < numDraw; i++) - if (h != null && h[listdl[i]] != null) - { - tempList[i] = new ADHelix(h[listdl[i]]); - if (tempList[i].getAStart() == tempList[i].getAEnd()) - { - tempList[i] = null; - } - } - else - tempList[i] = null; - return tempList; - } - - private ACoord getVPDisplayHelices(AWindow window, AProjection2D projection) - { - boolean drawApex = parameterStore.get("VP", "DrawApex").getStatus(); - ADHelix[] dhelix = getHelices(); - int size = 2 * dhelix.length; - if (drawApex) - size = 3 * dhelix.length; - double[][][] hv = new double[2][size][0]; - int[] index = new int[size]; - int[] indexIn = getDrawList(); - int num = 0; - - for (int j = 0; j < dhelix.length; ++j) - if (dhelix[j] != null) - { - double s1 = dhelix[j].getAStart(); - double s2 = 179.; - - s1 = dhelix[j].intersectWithRadialCylinder(projection.getMinRho(), s1, s2); - double sEnd = dhelix[j].intersectWithCylinder(true, AProjectionVP.getRhoVPlot(), true, AProjectionVP.getZVPlot()); - - s2 = Math.max(Math.min(s2, sEnd), s1); - // if the whole helix is to be drawn (which are unusual - // helices, shorten it a little to avoid wraparound problems - if (s1 == 0. && s2 == 180.) - s2 = 179.; - if (parameterStore.get("VP", "ShortV").getStatus() && !parameterStore.get("Data", "S3D").getStatus()) - s1 = s2 - parameterStore.get("VP", "ShortV").getD() * (s2 - s1); - if (s2 > s1) - { - int signMin = -1; - int signMax = 1; - double h = 0; - double v = 0; - for (int sign = signMin; sign <= signMax; sign += 2) - { - // ugly must change structure at some point - AProjectionVP.sign = sign; - ACoord pointsOnHelix = dhelix[j].drawHelix(window, projection, s1, s2); - hv[0][num] = pointsOnHelix.hv[0][0]; - hv[1][num] = pointsOnHelix.hv[1][0]; - index[num] = indexIn[j]; - h = hv[0][num][hv[0][num].length - 1]; - v = hv[1][num][hv[0][num].length - 1]; - num++; - } - if (drawApex) - { - int a = 3; - int b = 7; - hv[0][num] = new double[] { h - a, h + a, h, h, h - a, h + a }; - hv[1][num] = new double[] { v - b, v - b, v - b, v + b, v + b, v + b }; - index[num] = indexIn[j]; - num++; - } - } - } - return new ACoord(hv, index, this, ACoord.POLYLINES); - } - - public void draw(AWindow window, AGraphics ag, AProjection2D projection) - { - if(projection instanceof AProjectionVP) - { - // since no d0 and z0 data is provided for AOD Electron and Muon - // from event file, they are set to 0 manually, which is not - // compatible with the primary vertex calculated in Atlantis, and - // it will cause a wide and bizarre shape of 'v' drawn in V-Plot. - // So the temparary solution is to set primary vertex to (0,0,0) - // before drawing AOD Electron and Muon in V-Plot, and then restore - // their values after. - double[] primaryVtx=event.getPrimaryVertex(); - parameterStore.get("Event", "XVtx").setD(0.0); - parameterStore.get("Event", "YVtx").setD(0.0); - parameterStore.get("Event", "ZVtx").setD(0.0); - // super.draw(window, ag, projection); - drawHelix(window, ag, projection); - parameterStore.get("Event", "XVtx").setD(primaryVtx[0]); - parameterStore.get("Event", "YVtx").setD(primaryVtx[1]); - parameterStore.get("Event", "ZVtx").setD(primaryVtx[2]); - } - else - { - super.draw(window, ag, projection); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AHistogram.java b/graphics/AtlantisJava/src/atlantis/data/AHistogram.java deleted file mode 100755 index 082b97de978d590dc2c6f5e47bbc7f64def64473..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AHistogram.java +++ /dev/null @@ -1,422 +0,0 @@ -package atlantis.data; - -import atlantis.event.AData; -import atlantis.graphics.ACoord; -import atlantis.utils.AHashMap; -import atlantis.utils.ALogger; -import atlantis.utils.AVector; - -/** - * Used to create, fill, and draw the calorimeter histograms. - */ -public class AHistogram extends AData -{ - private static ALogger logger = ALogger.getLogger(AHistogram.class); - - public static final int UP = 0; - public static final int DOWN = 1; - - public static final int HORIZONTAL = 0; - public static final int VERTICAL = 1; - - public final static int RIGHT = 0; - public final static int LEFT = 1; - - private float leftLimit; - private float rightLimit; - private float gran; - private float granSafety; - private float[] towers; - - private double eta0, z, r; - private double factor; - private AData detector; - - - AHistogram(double leftLimit, double rightLimit, double gran, double factor, AData detector) - { - super(new AHashMap(1).put("numData", 0),detector.getEvent()); - - this.leftLimit = (float) leftLimit; - this.rightLimit = (float) rightLimit; - this.gran = (float) gran; - this.factor = factor; - this.detector = detector; - granSafety = (float) (this.gran * 0.1); - towers = new float[(int) Math.abs(Math.round((rightLimit - leftLimit) / gran))]; - numData = towers.length; - } - - public float getGranularity() - { - return gran; - } - - public int getTowersCount() - { - return towers.length; - } - - public float[] getTowers() - { - return towers; - } - - public void fill(double v1, double v2, double q) - { - int t1 = (int) ((v1 + granSafety - leftLimit) / gran); - int t2 = (int) ((v2 - granSafety - leftLimit) / gran); - int i = -999; - - if (Math.min(t1, t2) < 0 || Math.max(t1, t2) >= towers.length) - { - logger.error("Histogram binning problem " + t1 + " " + t2 + " " + towers.length + " " + v1 + " " + v2); - return; - } - - if (t1 == t2) - towers[t1] += q; - else - for (i = t1; i <= t2; i++) - towers[i] += q / (t2 - t1 + 1); - } - - public void setGranularity(double newGran) - { - AHistogram newHist = new AHistogram(leftLimit, rightLimit, newGran, factor, detector); - - for (int i = 0; i < towers.length; i++) - newHist.fill(leftLimit + i * gran, leftLimit + (i + 1) * gran, towers[i]); - gran = (float) newGran; - towers = newHist.towers; - } - - public void add(AHistogram h) - { - float min = Math.min(leftLimit, h.leftLimit); - float max = Math.max(rightLimit, h.rightLimit); - - AHistogram sum = new AHistogram(min, max, gran, factor, detector); - - // first I add this histogram - for (int i = 0; i < towers.length; i++) - sum.fill(leftLimit + i * gran, leftLimit + (i + 1) * gran, towers[i]); - - // and the "h" histogram - for (int i = 0; i < h.towers.length; i++) - sum.fill(h.leftLimit + i * h.gran, h.leftLimit + (i + 1) * h.gran, h.towers[i]); - - // copy the sum histogram parameters into old ones - towers = sum.towers; - leftLimit = min; - rightLimit = max; - } - - public AHistogram getRegion(double v1, double v2) - { - AHistogram hRegion = new AHistogram(v1, v2, gran, factor, detector); - - int n1 = (int) Math.round((v1 - leftLimit) / gran); - int n2 = (int) Math.round((v2 - leftLimit) / gran); - - for (int i = n1; i < n2; i++) - hRegion.fill(v1 + (i - n1) * gran, v1 + (i - n1 + 1) * gran, towers[i]); - - return hRegion; - } - - private int getCode() - { - int c1, c2; - - if (leftLimit < -eta0) - c1 = 1; - else if (leftLimit > +eta0) - c1 = 3; - else - c1 = 2; - - if (rightLimit < -eta0) - c2 = 1; - else if (rightLimit > +eta0) - c2 = 3; - else - c2 = 2; - - return c1 * c2; - } - - public ACoord[] getRZUser(double z1, double r1, int upORdown) - { - this.z = z1; - this.r = r1; - double expEta0, k = z / r; - int N; - - eta0 = Math.abs(Math.log(k + Math.sqrt(k * k + 1))); - - switch (getCode()) - { - case 1: - return new ACoord[] { getRZVerticalUser(z, upORdown) }; - - case 4: - return new ACoord[] { getRZHorizontalUser(r, upORdown) }; - - case 9: - return new ACoord[] { getRZVerticalUser(z, upORdown) }; - - case 2: - N = (int) Math.abs(Math.round((eta0 - leftLimit) / gran)); - eta0 = leftLimit + N * gran; - expEta0 = Math.exp(eta0); - this.r = 2 * this.z / (expEta0 - 1 / expEta0); - - return new ACoord[] { getRegion(leftLimit, -eta0).getRZVerticalUser(z, upORdown), getRegion(-eta0, rightLimit).getRZHorizontalUser(r, upORdown) }; - - case 6: - N = (int) Math.abs(Math.round((eta0 - leftLimit) / gran)); - eta0 = leftLimit + N * gran; - expEta0 = Math.exp(eta0); - this.r = 2 * this.z / (expEta0 - 1 / expEta0); - - return new ACoord[] { getRegion(leftLimit, +eta0).getRZHorizontalUser(r, upORdown), getRegion(+eta0, rightLimit).getRZVerticalUser(z, upORdown) }; - - case 3: - // FIXME -- round() replaced by floor() here to make sure - // histograms do not end up inside the calorimeter outline. - // They should be right at the edge regardless of the binning - // though. This should be changed. -- EJ - N = (int) Math.abs(Math.floor((eta0 - leftLimit) / gran)); - eta0 = leftLimit + N * gran; - expEta0 = Math.exp(eta0); - this.r = 2 * this.z / (expEta0 - 1 / expEta0); - - return new ACoord[] { getRegion(leftLimit, -eta0).getRZVerticalUser(z, upORdown), getRegion(-eta0, +eta0).getRZHorizontalUser(r, upORdown), getRegion(+eta0, rightLimit).getRZVerticalUser(z, upORdown) }; - - default: - return null; - } - } - - public ACoord getRZHorizontalUser(double r, int place) - { - double[][][] hv = new double[2][towers.length][4]; - int[] index = new int[towers.length]; - double eta, exp1, exp2, zSign, rSign; - - for (int i = 0; i < towers.length; i++) - { - exp1 = Math.exp(leftLimit + i * gran); - exp2 = Math.exp(leftLimit + (i + 1) * gran); - rSign = (int) Math.pow(-1, place); - - eta = leftLimit + (i + 0.5) * gran; - if (eta != 0) - zSign = eta / Math.abs(eta); - else - zSign = 1; - - hv[0][i][0] = zSign * Math.abs(r * (exp1 - 1 / exp1) / 2); - hv[1][i][0] = rSign * r; - - hv[0][i][1] = zSign * Math.abs(r * (exp2 - 1 / exp2) / 2); - hv[1][i][1] = rSign * r; - - hv[0][i][2] = 0; - hv[1][i][2] = 0; - - index[i] = i; - } - - ACoord c = new ACoord(hv, index); - - c.source = this; - return c; - } - - public ACoord getRZVerticalUser(double z, int place) - { - double[][][] hv = new double[2][towers.length][4]; - int[] index = new int[towers.length]; - double exp1, exp2, zSign, rSign; - - for (int i = 0; i < towers.length; i++) - { - exp1 = Math.exp(leftLimit + i * gran); - exp2 = Math.exp(leftLimit + (i + 1) * gran); - rSign = (int) Math.pow(-1, place); - - if ((leftLimit > 0) && (rightLimit > 0)) - zSign = +1; - else - zSign = -1; - - hv[0][i][0] = zSign * z; - hv[1][i][0] = rSign * Math.abs(2 * z / (exp2 - 1 / exp2)); - - hv[0][i][1] = zSign * z; - hv[1][i][1] = rSign * Math.abs(2 * z / (exp1 - 1 / exp1)); - - hv[0][i][2] = 0; - hv[1][i][2] = 0; - - index[i] = i; - } - - ACoord c = new ACoord(hv, index); - - c.source = this; - return c; - } - - protected ACoord getYXUser(double r) - { - int n = towers.length; - double[][][] hv = new double[2][n][4]; - int[] index = new int[n]; - - for (int i = 0; i < n; i++) - { - double phi1 = leftLimit + i * gran; - double phi2 = leftLimit + (i + 1) * gran; - - // first point - hv[0][i][0] = r * Math.cos(phi1); - hv[1][i][0] = r * Math.sin(phi1); - - // second point - hv[1][i][1] = r * Math.sin(phi2); - hv[0][i][1] = r * Math.cos(phi2); - - // third point (the center) - hv[0][i][2] = 0; - hv[1][i][2] = 0; - - index[i] = i; - } - - ACoord c = new ACoord(hv, index); - - c.source = this; - return c; - } - - public ACoord completeTowers(ACoord c) - { - AVector u = new AVector(0, 0); - - for (int i = 0; i < c.hv[0].length; i++) - { - double x0 = (c.hv[0][i][0] + c.hv[0][i][1]) / 2; - double y0 = (c.hv[1][i][0] + c.hv[1][i][1]) / 2; - double f = factor * towers[c.index[i]]; - - u.set(x0 - c.hv[0][i][2], y0 - c.hv[1][i][2]).makeUnitary().scale(f); - - c.hv[0][i][2] = c.hv[0][i][1] + u.dx; - c.hv[1][i][2] = c.hv[1][i][1] + u.dy; - - c.hv[0][i][3] = c.hv[0][i][0] + u.dx; - c.hv[1][i][3] = c.hv[1][i][0] + u.dy; - } - - return c; - } - - protected ACoord getFRUser(double r) - { - int n = towers.length; - double[][][] hv = new double[2][n][4]; - int[] index = new int[n]; - - for (int i = 0; i < n; i++) - { - hv[0][i][0] = r; - hv[1][i][0] = Math.toDegrees(leftLimit + i * gran); - - hv[0][i][1] = r; - hv[1][i][1] = Math.toDegrees(leftLimit + (i + 1) * gran); - - hv[0][i][2] = 0; - hv[1][i][2] = Math.toDegrees(leftLimit + (i + 0.5) * gran); - - index[i] = i; - } - - ACoord c = new ACoord(hv, index); - - c.source = this; - return c; - } - - protected ACoord getFZUser(double z, int alignment) - { - int n = towers.length; - double[][][] hv = new double[2][n][4]; - int[] index = new int[n]; - - double zSign = Math.pow(-1, alignment); - - for (int i = 0; i < n; i++) - { - hv[0][i][0] = zSign * z; - hv[1][i][0] = Math.toDegrees(leftLimit + i * gran); - - hv[0][i][1] = zSign * z; - hv[1][i][1] = Math.toDegrees(leftLimit + (i + 1) * gran); - - hv[0][i][2] = 0; - hv[1][i][2] = Math.toDegrees(leftLimit + (i + 0.5) * gran); - - index[i] = i; - } - - ACoord c = new ACoord(hv, index); - - c.source = this; - return c; - } - - // implementation of AData - public String getParameterGroup() - { - return null; - } - - public String getName() - { - return null; - } - - public String getNameScreenName() - { - return detector.getParameterGroup() + " Histogram Tower"; - } - - protected int internalColor() - { - return 0; - } - - protected void applyCuts() - {} - - public String getHitInfo(int index) - { - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (index: " + index + ")"); - msg.append("\n ET = "); - msg.append(String.format("%.2f",towers[index])); - msg.append(" GeV"); - - return msg.toString(); - } - - public int getIdFromIndex(int index) - { - // Histograms have only an internal ID, override this method here to avoid problems - return index; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AHistogramData.java b/graphics/AtlantisJava/src/atlantis/data/AHistogramData.java deleted file mode 100644 index c216d458266702b4f20d4590a1e8833903553d21..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AHistogramData.java +++ /dev/null @@ -1,15 +0,0 @@ -package atlantis.data; - - -import atlantis.graphics.ACoord; - - -public interface AHistogramData { - ACoord[] getYXHistograms(); - ACoord[] getRZHistograms(); - ACoord[] getFRHistograms(); - ACoord[] getFZHistograms(); - ACoord[] getXZHistograms(); - ACoord[] getYZHistograms(); - ACoord[] getVPHistograms(); -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AHitData.java b/graphics/AtlantisJava/src/atlantis/data/AHitData.java deleted file mode 100644 index b27c824660afbb8ea174f4bff73af4d654156675..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AHitData.java +++ /dev/null @@ -1,487 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.graphics.colormap.AColorMap; -import atlantis.list.AListManager; -import atlantis.parameters.AEnumeratorParameter; -import atlantis.utils.AHashMap; -import java.util.Vector; -import atlantis.utils.ALogger; - -public abstract class AHitData extends AData -{ - private static ALogger logger = ALogger.getLogger(AHitData.class); - - protected byte[] type; - // sub should be removed at some point - protected int[] sub; - // linked list - protected int[] ll; - protected int[] llStart; - protected int[] llNum; - - // for "new Truth" (2006-08-08) implementation of barcode management - // (association to truth tracks) - protected int[] barcode = null; // old style barcode - protected int[] barcodes = null; // new style barcodes - protected int[] numBarcodes = null; // new style numBarcodes - - @Override - public final int getNumTypes(){ - return 2; - } - - private static final int NOISE = 0; - private static final int GOOD = 1; - - - - AHitData(AHashMap p, AEvent e) - { - super(p,e); - - sub = p.getUnknownIntArray("sub"); - type = new byte[numData]; - ll = new int[numData]; - llStart = new int[getNumTypes()]; - llNum = new int[getNumTypes()]; - - AAssociation assoc = null; - if (p.get("barcode") != null) - { - // old style truth (1-to-1 barcode association) - barcode = p.getUnknownIntArray("barcode"); - - assoc = new AAssociation(getFullName(), "STr", null, barcode, event); - event.getAssociationManager().add(assoc); - } - else if(p.get("barcodes") != null && p.get("numBarcodes") != null) - { - // new style truth (1-to-n barcodes, numBarcodes association) - barcodes = p.getUnknownIntArray("barcodes"); - numBarcodes = p.getUnknownIntArray("numBarcodes"); - - // getFullName() should return hit datatype name + storegate key - assoc = new AAssociation(getFullName(), "STr", numBarcodes, barcodes,event); - event.getAssociationManager().add(assoc); - } - - } // AHitData() --------------------------------------------------------- - - - - public String getHitInfo(int index) - { - StringBuilder r = new StringBuilder(); - if(this.barcode != null) - { - // old style truth association - 1 barcode associated with a hit - r.append("\n barcode = " + barcode[index]); - } - else if(this.barcodes != null && this.numBarcodes != null) - { - // new style truth association - N barcodes associated with a hit - - int[][] barcodes = event.getAssociationManager().get(getFullName(), "STr"); - if(barcodes[index] != null) - { - r.append("\n barcode(s) = "); - for(int i = 0; i < barcodes[index].length; i++) - { - r.append(barcodes[index][i] + " "); - } - } - else - { - r.append("\n no STr associated"); - } - } - - return r.toString(); - - } // getHitInfo() ------------------------------------------------------- - - - - /** - * Calculates actual association via - SiCluster for the datatype - * (SpacePoint (S3D) and TrigSpacePoint) to InDetTrack* (inner detector - * reconstructed track collection) - * @param to String - * @param via String - * @return int[][] - */ - private int[][] calculateAssociation(String to, String via) - { - String infoMsg = " association from: " + this.getName() + " to: " + - to + " via: " + via; - - logger.debug("AData.calculateAssociation()\n" + infoMsg); - - int[][] clusters = event.getAssociationManager().get(getFullName(), via); - int[][] recon = event.getAssociationManager().get(via, to); - AData source = event.get(via); - if(clusters == null || recon == null || source == null) - { - return null; - } - - int[][] ass = new int[numData][]; - - // iterate over all data items of this datatype - for(int i = 0; i < numData; ++i) - { - if(clusters[i] != null && clusters[i].length == 2) - { - // this is a SCT hit which has two clusters - int index1 = source.getIndexFromId(clusters[i][0]); - int index2 = source.getIndexFromId(clusters[i][1]); - if(index1 != -1 && index2 != -1 && - recon[index1] != null && recon[index2] != null) - { - int[] temp = new int[recon[index1].length]; - int matches = 0; - for(int k = 0; k < recon[index1].length; ++k) - { - for(int j = 0; j < recon[index2].length; ++j) - { - if(recon[index1][k] == recon[index2][j]) - { - // IndexOutOfBound protection - if(matches < recon[index1].length) - { - temp[matches] = recon[index1][k]; - matches++; - } - else - { - logger.warn("Association problem:\n" + infoMsg); - } - } - } - } - if(matches == 0) - { - ass[i] = null; - } - else if(matches == temp.length) - { - ass[i] = temp; - } - else - { - int[] dest = new int[matches]; - System.arraycopy(temp, 0, dest, 0, matches); - ass[i] = dest; - } - } - } - else if(clusters[i] != null && clusters[i].length == 1) - { - // this is pixel hit which has one cluster only (second number was - // -1 and was ignored in the datatypes (S3D, TrigS3D) constuctor - - // although this method calculates association via SiCluster - // there are no SiClusters for Pixel and this is a Pixel hit - // -> need to calculate the SpacePoint - Track association directly - // based on Track:hits (which has got id of non-existing SiCluster - // hits) and SpacePoint:cluster which also has Pixel cluster - // references (more see email on 2007-09-20 association problems ...) - // can't use above block as source (SiCluster) doesn't exists, there - // are no SiCluster in Pixel, thus source.getIndexFromId(clusters[i][0]) - // can't work ... - - // AAssociationManager.get(via, to); would return recalculated - // inverted association containing indices. - - // this returns the direct array saved in InDetTrackData() constructor - // AAssociationManager.add(new AAssociation(assocKey, "SiCluster", numHits, hits)); - int[][] directRecon = event.getAssociationManager().getAssociation(to, via).getData(); - - for(int x = 0; x < directRecon.length; x++) - { - if(directRecon[x] != null) - { - for(int y = 0; y < directRecon[x].length; y++) - { - // if the SpacePoint cluster ID is the same as id in - // Track:hits, then it's an associated hit - if(clusters[i][0] == directRecon[x][y]) - { - if(ass[i] == null) - { - // current association, x is associated track index - ass[i] = new int[] { x }; - } - else - { - // some tracks before were already associated - // copy the array and add current track index - int[] temp = new int[ass[i].length + 1]; - System.arraycopy(ass[i], 0, temp, 0, ass[i].length); - temp[ass[i].length] = x; // current association - ass[i] = new int[temp.length]; - System.arraycopy(temp, 0, ass[i], 0, temp.length); - } - - } - } // for(int y = 0; y < directRecon[x].length; y++) - } - } // loop over x (x is all track indices) - } // else - pixel cluster found - - } // for(int i = 0; i < numData; ++i) - loop over all current datatype items - - return ass; - - } // calculateAssociation() --------------------------------------------- - - - - /* - * This method uses clusters array (association with SiCluster) which - * is accessed in calculateAssociation() and creates - * TrigS3D - Track association and S3D - Track association (via SiCluster) - */ - protected void calculateAssociationViaClusters() - { - Vector<String> keys = event.getCollections().get("InDetTrack"); - int[][] recon = null; - int[][] recon2 = null; - AAssociation assoc = null; - String[] trackCollec = null; - - if(keys != null) - { - trackCollec = (String[]) keys.toArray(new String[keys.size()]); - for(int j = 0; j < trackCollec.length; j++) - { - String trackCollecFull = "InDetTrack" + trackCollec[j]; - recon = event.getAssociationManager().get(getFullName(), trackCollecFull); - recon2 = calculateAssociation(trackCollecFull, "SiCluster"); - if(recon != null && recon2 != null) - { - for(int i = 0; i< numData; i++) - { - if(recon2[i] != null) - { - // using array reference here - association array is corrected - recon[i] = recon2[i]; - } - } - assoc = event.getAssociationManager().getAssociation(getName(), trackCollecFull); - event.getAssociationManager().add(assoc.invert()); - } - } - } - - } // calculateAssociationViaClusters() --------------------------------- - - - - protected int internalColor() - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - if (colorFunction == 0) - { - colorByConstant(); - } - else if (colorFunction == 1) - { - colorBy("STr"); - } - else if (colorFunction == 2) - { - colorBy(getReconstructedTracks()); - } - else if (colorFunction == 3) - { - colorBy(sub); - } - - return 3; - - } // internalColor() ---------------------------------------------------- - - - - protected String getSegments() - { - AEnumeratorParameter key = (AEnumeratorParameter) parameterStore.get("InDetSegment", "InDetSegmentCollections"); - - return "InDetSegment" + key.getCurrentText(); - } - - - - public void constructDefaultDrawlist() - { - // make seperate lists of noise and good hits - makeNoiseList(0, 0); - - if (!parameterStore.get("CutsATLAS", "ByList").getStatus()) - { - // put noise and/or good hits in drawlist according to HitType - // parameter - // if both are drawn noise is drawn first - makeDrawList(parameterStore.get("CutsInDet", "HitType").getI()); - - // if some hits are on a list they must be drawn last - int[][] temp = AListManager.getInstance().getColorMapping(this); - int[] index = temp[0]; - int[] ctemp = temp[1]; - if (index.length > 0) - { - int[] c = new int[numData]; - final int NONE = -999; - // color is not used at this time - for (int i = 0; i < c.length; ++i) - c[i] = NONE; - - for (int i = 0; i < index.length; ++i) - c[index[i]] = ctemp[i]; - - int[] newListdl = new int[numData]; - int num = 0; - for (int t = 0; t < getNumTypes(); t++) - { - for (int i = 0; i < numDraw; ++i) - if (t == type[listdl[i]] && c[listdl[i]] == NONE) - newListdl[num++] = listdl[i]; - for (int i = 0; i < numDraw; ++i) - if (t == type[listdl[i]] && c[listdl[i]] != NONE && c[listdl[i]] != AColorMap.INVISIBLE) - newListdl[num++] = listdl[i]; - } - listdl = newListdl; - numDraw = num; - } - } - else - { - boolean[] selected = AListManager.getInstance().getSelection(this); - numDraw = 0; - for (int t = 0; t < getNumTypes(); t++) - for (int i = 0; i < numData; ++i) - if (t == type[i] && selected[i]) - listdl[numDraw++] = i; - } - } - - - /** - * define noise and good hits type = 0 means noise - * noise hits - hits associated neither with Track not STr - * good hits - hits associated either with Track or with STr - */ - protected void setType() - { - int[][] assocSTr = event.getAssociationManager().get(getFullName(), "STr"); - int[][] assocRTr = event.getAssociationManager().get(getName(), getReconstructedTracks()); - - for (int i = 0; i < numData; i++) - { - if((assocSTr != null && assocSTr[i] != null) || - (assocRTr != null && assocRTr[i] != null)) - { - type[i] = 1; - } - else - { - type[i] = 0; - } - } - - } // setType() ---------------------------------------------------------- - - - - protected void makeNoiseList(int a, int b) - { - setType(); - - for (int i = 0; i < getNumTypes(); i++) - { - llStart[i] = -1; - llNum[i] = 0; - } - - for (int i = numData - 1; i >= 0; i--) - { - ll[i] = llStart[type[i]]; - llStart[type[i]] = i; - llNum[type[i]]++; - } - } - - private void makeDrawList(int hitType) - { - int start, end; - - numDraw = 0; - if (hitType == 0) - { - start = end = NOISE; - } - else if (hitType == 1) - { - start = end = GOOD; - } - else - { - start = NOISE; - end = GOOD; - } - - for (int i = start; i <= end; i++) - { - int n = llStart[i]; - - for (int j = 0; j < llNum[i]; j++) - { - listdl[numDraw++] = n; - n = ll[n]; - } - } - } - - - - public int[] getType(int[] dl) - { - int[] temp = new int[dl.length]; - - for (int i = 0; i < temp.length; i++) - temp[i] = type[dl[i]]; - return temp; - } - - - - /** - * cut hits if connected/unconnected to simulated tracks - */ - protected void cutSimulatedTracks() - { - int cutOption = parameterStore.get("CutsInDet", "HitsBySTr").getI(); - cutByAssociationTo("STr", getFullName(), cutOption); - } - - /** - * cut hits if connected/unconnected to reconstructed tracks - */ - protected void cutReconstructedTracks() - { - int cutOption = parameterStore.get("CutsInDet", "HitsByRTr").getI(); - cutByAssociationTo(getReconstructedTracks(), getName(), cutOption); - } - - /** - * cut hits if connected/unconnected to reconstructed segments - */ - protected void cutSegments() - { - int cutOption = parameterStore.get("CutsInDet", "HitsBySegment").getI(); - cutByAssociationTo(getSegments(), getName(), cutOption); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AInDetSegmentData.java b/graphics/AtlantisJava/src/atlantis/data/AInDetSegmentData.java deleted file mode 100755 index e7d97508d648ffba5052ae2712caca2114824bb3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AInDetSegmentData.java +++ /dev/null @@ -1,30 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.utils.AHashMap; - -/** - * - * @author Eric Jansen - */ -public class AInDetSegmentData extends ASegmentData { - - /** Creates a new instance of AInDetSegmentData */ - AInDetSegmentData(AHashMap p, AEvent e) { - super(p,e); - - event.getAssociationManager().add(new AAssociation(getFullName(), "TRT", numHits, hits,event)); - } - - public String getParameterGroup() { - return "InDetSegment"; - } - - public String getName() { - return "InDetSegment"; - } - - public String getNameScreenName() { - return "InDetSegment"; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AInDetTrackData.java b/graphics/AtlantisJava/src/atlantis/data/AInDetTrackData.java deleted file mode 100644 index 05e5bda343d26eb202e652816d406df4bb1d31ad..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AInDetTrackData.java +++ /dev/null @@ -1,164 +0,0 @@ -package atlantis.data; - -import atlantis.event.AAssociation; -import atlantis.event.AEvent; -import atlantis.event.AData; -import atlantis.globals.AGlobals; -import atlantis.utils.AHashMap; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AIdHelper; -import atlantis.utils.ALogger; - -/** - * - * @author Eric Jansen - */ - -public class AInDetTrackData extends ATrackData { - - private int[] author = null; - - protected int numBLayerHits[] = null; - protected int numPixelHits[] = null; - protected int numSCTHits[] = null; - protected int numTRTHits[] = null; - - private static ALogger logger = ALogger.getLogger(ATrackData.class); - - /** Creates a new instance of AInDetTrackData */ - AInDetTrackData(AHashMap p, AEvent e) throws AAtlantisException { - super(p,e); - - author = p.getUnsureIntArray("trackAuthor"); //Change added 17/02/2010 - - numBLayerHits = p.getUnsureIntArray("nBLayerHits"); - numPixelHits = p.getUnsureIntArray("nPixHits"); - numSCTHits = p.getUnsureIntArray("nSCTHits"); - numTRTHits = p.getUnsureIntArray("nTRTHits"); - - String assocKey = getFullName(); - if (p.get("numHits") != null) { - int[] numHits = p.getIntArray("numHits"); - int[] hits = p.getIntArray("hits"); - - // This was added into TrkJiveXML-00-01-24, July 2010. For backwards - // compatibilty, we can also fill these arrays from the association - if (numPixelHits == null && numSCTHits == null && numTRTHits == null) { - numPixelHits = new int[numData]; - numSCTHits = new int[numData]; - numTRTHits = new int[numData]; - for (int i=0, num=0; i<numData; i++) { - numPixelHits[i] = numSCTHits[i] = numTRTHits[i] = 0; - - for (int j=0; j<numHits[i]; j++, num++) { - try { - // Negative identifiers are pixels, the rest we can decode using AIdHelper - if (numHits[i] > 0 && (hits[num] < 0 || AIdHelper.subDetector(hits[num]) == 2)) { - switch(hits[num] < 0 ? 1 : AIdHelper.indetPart(hits[num])) { - case 1: - numPixelHits[i]++; - break; - case 2: - numSCTHits[i]++; - break; - case 3: - numTRTHits[i]++; - break; - } - } - } catch (AAtlantisException ex) { - logger.warn("Problem decoding hit identifier: " + ex.getMessage()); - } - } - } - } - - int[] driftSign = null; - int[] isOutlier = null; - if (p.get("driftSign") != null && p.get("isOutlier") != null) { - driftSign = p.getIntArray("driftSign"); - isOutlier = p.getIntArray("isOutlier"); - } - - event.getAssociationManager().add(new AAssociation(assocKey, "TRT", numHits, hits,event)); - if (driftSign != null) { - event.getAssociationManager().add(new AAssociation(assocKey + "Drift", "TRT", numHits, driftSign,event)); - } - if (isOutlier != null) { - event.getAssociationManager().add(new AAssociation(assocKey + "Outlier", "TRT", numHits, isOutlier,event)); - } - event.getAssociationManager().add(new AAssociation(assocKey, "SiCluster", numHits, hits,event)); - event.getAssociationManager().add(new AAssociation(assocKey, "PixelCluster", numHits, hits,event)); - - - // although these two following associations directly doesn't exist - // in the event file (e.g. Track:numHits,hits - S3D:id) because it - // is calculated over SiCluster, the association has to be - // established here and corrected later on in - // AS3D.finalizeConstruction() -> AHitData.calculateAssociationViaClusters() - event.getAssociationManager().add(new AAssociation(assocKey, "S3D", numHits, hits,event)); - event.getAssociationManager().add(new AAssociation(assocKey, "TrigS3D", numHits, hits,event)); - } - } - - public String getParameterGroup() { - return "InDetTrack"; - } - - public String getName() { - return "InDetTrack"; - } - - public String getNameScreenName() { - return "InDetTrack"; - } - - public String getHitInfo(int index) { - String msg = super.getHitInfo(index); - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) - return getNameScreenName()+" index: " + index + ((h!=null)?h[index].toString():""); // output for Minerva - if (numBLayerHits != null) { - msg += "\n numBLayerHits = " + numBLayerHits[index]; - } - if (numPixelHits != null) { - msg += "\n numPixelHits = " + numPixelHits[index]; - } - if (numSCTHits != null) { - msg += "\n numSCTHits = " + numSCTHits[index]; - } - if (numTRTHits != null) { - msg += "\n numTRTHits = " + numTRTHits[index]; - } - return msg; - } - - protected void applyCuts() { - cut("CutsInDet", "RTrIndex", " RTr id", id); - cut("CutsInDet", "trackAuthor", " Author", author); - - if (numBLayerHits != null) { - cut("CutsInDet", "NumBLayer", "Num BLayer", numBLayerHits); - } - if (numPixelHits != null) { - cut("CutsInDet", "NumPixel", "Num Pixel", numPixelHits); - } - if (numSCTHits != null) { - cut("CutsInDet", "NumSCT", "Num SCT", numSCTHits); - } - if (numTRTHits != null) { - cut("CutsInDet", "NumTRT", "Num TRT", numTRTHits); - } - - super.applyCuts(); - - if (polylinedTrack && parameterStore.get(PARAMETER_GROUP, "DrawnAs").getI() == DRAW_HELIX) { - // if reconstructed tracks are drawn as helices, check for tracks - // with rhoVertex beyond the diameter of InDet and don't draw those - // super.rhoVertex array was calculated only if Track provided - // polyline data, otherwise rhoVertex is null and this method would - // cause NullPointerException - super.cutRhoVertexAfterInDetRadius(); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AJetData.java b/graphics/AtlantisJava/src/atlantis/data/AJetData.java deleted file mode 100644 index d2e1743a92b33ce864e74ff4865fa88fa1bae0b9..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AJetData.java +++ /dev/null @@ -1,782 +0,0 @@ -package atlantis.data; - -import java.util.ArrayList; -import java.util.List; - -import atlantis.event.AAssociation; -import atlantis.event.AData; -import atlantis.event.AEvent; -import atlantis.event.AObjectsAssociation; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.parameters.APar; -import atlantis.utils.AMath; -import atlantis.utils.A3Vector; -import atlantis.utils.A4Vector; -import atlantis.utils.AHashMap; -import atlantis.canvas.AWindow; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionVP; -import atlantis.graphics.AGraphics; - -/** - * Jet class - class handling multiple Jet datatypes - * (multiple collections) from various Jet alrogithms - * (JetRecJet, ParticleJet, etc) - */ -public class AJetData extends AData -{ - protected float[] eT; - protected float[] eta; - protected float[] phi; - protected float[] mass; - protected float[] pT; - protected float[] px; - protected float[] py; - protected float[] pz; - //Transition variable to ensure backwards compatability - protected boolean has4Vect = false; - //variables for jet quality information - protected float[] quality = null; - protected float[] qualityLAr = null; - protected float[] qualityTile = null; - protected float[] time = null; - protected float[] timeClusters = null; - protected int[] n90cells = null; - protected int[] n90const = null; - protected float[] hecf = null; - protected float[] emfrac = null; - protected float[] tileGap3f = null; - protected float[] fcorCell = null; - protected float[] fcorDotx = null; - protected float[] fcorJet = null; - protected float[] fcorJetForCell = null; - protected int[] nbadcells = null; - protected float[] fracSamplingMax = null; - protected float[] sMax = null; - protected float[] OutOfTimeEfrac = null; - protected float[] isGood = null; - protected float[] isBad = null; - protected float[] isUgly = null; - protected String[] bTagName = null; //new bTagname variable - protected float[] bTagValue = null; //new bTagValue variable - protected float[] weight = null; - protected float[] jvf = null; - //Transition variable to ensure backwards compatability - protected boolean hasJvf = true; - - String[] caloSample = { "EMB0", "EMB1", "EMB2", "EMB3", "EME0", "EME1", "EME2", "EME3", "HEC0", "HEC1", "HEC2", "HEC3", "TileBar0", "TileBar1", "TileBar2", "TileGap1", "TileGap2", "TileGap3", "TileExt0", "TileExt1", "TileExt2", "FCAL0", "FCAL1", "FCAL2", "Unknown" }; - - - AJetData(AHashMap p, AEvent e) - { - super(p,e); - if (p.get("et") != null) - { - eT = p.getFloatArray("et"); - } - else - { - eT = p.getFloatArray("pt"); - } - - - if(p.get("mass") != null) - { - mass = p.getFloatArray("mass"); - px = p.getFloatArray("px"); - py = p.getFloatArray("py"); - pz = p.getFloatArray("pz"); - has4Vect = true; - } - eta = p.getFloatArray("eta"); - phi = p.getFloatArray("phi"); - - if(p.get("emfrac") != null) - { - emfrac = p.getFloatArray("emfrac"); - } - - float forwardJVF = 10.0f; - float initJVF = 1.0f; - if(p.get("jvf") != null) - { - jvf = p.getFloatArray("jvf"); - for(int i=0; i<(jvf.length); i++) - { - if( jvf[i] == -1.0 ) - jvf[i] = forwardJVF; // forward-jets have jvf=-1 - } - } - else // dummy values for older xml-files - { - hasJvf = false; - jvf = new float[eta.length]; // for array size - for(int i=0; i<(jvf.length); i++) - { - jvf[i] = initJVF; // need to assign dummy value to allow cut - } - } - - //Getting BTagNames and BTagValues from xml - if(p.get("bTagValue") != null) - { - bTagValue = p.getFloatArray("bTagValue"); - bTagName = p.getUnsureStringArray("bTagName"); - weight = new float[eta.length]; - for(int i=0; i<(eta.length); i++) - weight[i] = bTagValue[i*(bTagValue.length/eta.length) + 0]; - // 0 is the first instance of JetFitterNNComb - // we take this as default for now... - } - - if(has4Vect) - { - float[] pTtemp = new float[mass.length]; - for(int i = 0; i < mass.length; i++){ - pTtemp[i] = (float) (new A4Vector(px[i],py[i],pz[i],mass[i]) ).getPt(); - } - pT = pTtemp; - } - - if(p.get("quality") != null) - quality = p.getFloatArray("quality"); - if(p.get("qualityLAr") != null){ - qualityLAr = p.getFloatArray("qualityLAr"); - qualityTile = p.getFloatArray("qualityTile"); - time = p.getFloatArray("time"); - timeClusters = p.getFloatArray("timeClusters"); - n90cells = p.getIntArray("n90cells"); - n90const = p.getIntArray("n90const"); - hecf = p.getFloatArray("hecf"); - tileGap3f = p.getFloatArray("tileGap3f"); - fcorCell = p.getFloatArray("fcorCell"); - fcorDotx = p.getFloatArray("fcorDotx"); - fcorJet = p.getFloatArray("fcorJet"); - fcorJetForCell = p.getFloatArray("fcorJetForCell"); - nbadcells = p.getIntArray("nbadcells"); - fracSamplingMax = p.getFloatArray("fracSamplingMax"); - sMax = p.getFloatArray("sMax"); - OutOfTimeEfrac = p.getFloatArray("OutOfTimeEfrac"); - isGood = p.getFloatArray("isGood"); - isBad = p.getFloatArray("isBad"); - isUgly = p.getFloatArray("isUgly"); - } - - String assocKey = getFullName(); - // create Jet - Calo associations if cells information is available - if(p.get("numCells") != null) - { - event.getAssociationManager().add(new AAssociation(assocKey, "LAr", p.getIntArray("numCells"), p.getIntArray("cells"),event)); - event.getAssociationManager().add(new AAssociation(assocKey, "TILE", p.getIntArray("numCells"), p.getIntArray("cells"),event)); - event.getAssociationManager().add(new AAssociation(assocKey, "HEC", p.getIntArray("numCells"), p.getIntArray("cells"),event)); - event.getAssociationManager().add(new AAssociation(assocKey, "FCAL", p.getIntArray("numCells"), p.getIntArray("cells"),event)); - } - - if (p.get("clusterKey") != null) - { - int[] clusterLinkCount = p.getUnsureIntArray("clusterLinkCount"); - event.getAssociationManager().add(new AObjectsAssociation(assocKey, "Cluster", - p.getStringArray("clusterKey"), p.getIntArray("clusterIndex"), clusterLinkCount, event)); - } - if (p.get("trackKey") != null) - { - int[] trackLinkCount = p.getUnsureIntArray("trackLinkCount"); - event.getAssociationManager().add(new AObjectsAssociation(assocKey, "Track", - p.getStringArray("trackKey"), p.getIntArray("trackIndex"), trackLinkCount, event)); - } - } - - - public String getParameterGroup() - { - return "Jet"; - } - - - public String getName() - { - return "Jet"; - } - - - public String getNameScreenName() - { - return "Jet"; - } - - - public float getET(int index) - { - return eT[index]; - } - - - public float getEta(int index) - { - return eta[index]; - } - - - public float getPhi(int index) - { - return phi[index]; - } - - - public float[] getET() - { - return eT; - } - - - public float[] getEta() - { - return eta; - } - - - public float[] getPhi() - { - return phi; - } - - public float[] getPt() - { - if(has4Vect){ - return pT; - }else{ - return eT; - } - } - - @SuppressWarnings("unused") - // TODO: these cuts are from Nikolina - // using the wrong indices? - private float[] getfCorJetLevel() - { - // Tom - problem here with inconsistent indices? - // this code is not used yet, but the Jet people want it eventually - // i is the total data index, but we need to get that from the draw list, listdl[i]. - float[] temp = new float[numDraw]; - for (int i = 0; i < numDraw; i++) - temp[i] = (float) (fcorCell[i] - fcorJet[i]); - return temp; - } - - @SuppressWarnings("unused") - // TODO: these cuts are from Nikolina - // using the wrong indices? - private float[] getHECfQ() - { - float[] temp = new float[numDraw]; - for (int i = 0; i < numDraw; i++) - temp[i] = (float) (Math.abs(hecf[i]) + Math.abs(quality[i])); - return temp; - } - - /* - * Return an ordered list of the btaggers available in the event. - * If using an older XML file without btaggers available, an empty list is returned. - * Ordering is important to be consistent with the BTag Weights, which are ordered the same. - */ - public List<String> getBTaggers() { - - List<String> taggers = new ArrayList<String>(); - - if(bTagName == null) - return taggers; - - for(String tagger : bTagName) { - if(!taggers.contains(tagger)) { - taggers.add(tagger); - } - } - - return taggers; - } - - protected void applyCuts() - { - cutIndex(); - cut("CutsObjects", "JetET", " |ET|", eT); - cutPhi(phi); - cutEta(eta); - cut("CutsObjects", "JetEMfraction", " |EM fraction|", emfrac); - cut("CutsObjects", "JetVxFraction", " |Vx Fraction|", jvf); - - /* Placeholder for jet quality cuts (added by Nikolina Ilic) - cut("CutsObjects", "JetTime", " |dt(jet,coll)|", time); - cut("CutsObjects", "JetTileGap3F", " TileGap3F", tileGap3f); - cut("CutsObjects", "JetfCORRcell", " Already corrected cell level correction", fcorCell); - cut("CutsObjects", "JetfCORRjetLevel", " Correction by jet level estimation", getfCorJetLevel()); - cut("CutsObjects", "JetHECfQ", " HECf-Quality", getHECfQ()); - cut("CutsObjects", "JetOOTEf", " Out-Of-Time Energy frac", OutOfTimeEfrac); - */ - } - - public void colorbyBJets() { - //Initialy color all jets with constant color - for (int i = 0; i < numData; i++) { - int constantColor2 = parameterStore.get("Jet", "Constant").getI(); - color[i] = (byte) constantColor2; - } - - //Read necessary information to colour Jets - int bTagValue_user = parameterStore.get("CutsObjects", "JetBTagger").getI(); //getting user B-tagger preference - int constantColor = parameterStore.get("BJet", "Constant").getI(); - int constantColor2 = parameterStore.get("Jet", "Constant").getI(); - - //if b-tagging information is contained in xml file - if(bTagValue != null) { - int mod = bTagValue.length / eta.length; //Number of Btaggers - eta.length is the number of Jets - double s = parameterStore.get("CutsObjects", "JetBTagweight").getD(); - for (int i = 0; i < eta.length; i++) { - color[i] = (byte) constantColor2; - if(bTagValue[bTagValue_user + i*mod]>s){ - color[i] = (byte) constantColor; - } - } - } - } - - - - - protected int internalColor() - { - int colorFunction = APar.instance().get(PARAMETER_GROUP, "ColorFunction").getI(); - - if (colorFunction == 0) - { - colorByConstant(); - } - else if(colorFunction == 1) - { - colorByIndex(); - } - else if(colorFunction == 2) - { - colorByCollection(); - } - else if (colorFunction == 3) - { - colorbyBJets(); - } - return 3; - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n ET="+String.format("%.3f",eT[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Ex="+String.format("%.3f",eT[index]*Math.cos(phi[index]))+" GeV "+ - "\n Ey="+String.format("%.3f",eT[index]*Math.sin(phi[index]))+" GeV "+ - "\n Ez="+String.format("%.3f",eT[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - String msg; - String k = this.getStoreGateKey(); - String sgKey = k != null ? k : "n/a"; - String printPt = ""; - if(has4Vect){ - printPt = "\n PT = " + String.format("%.3f",pT[index]) + " GeV"; - } - msg = getNameScreenName() + " (id: " + id[index] + " index: " + index + ")\n" + - " storegate key: " + sgKey + printPt + "\n ET = " + - String.format("%.3f",eT[index]) + " GeV" + "\n E = " + - String.format("%.3f",Math.abs(eT[index] / Math.cos(AMath.lambda(eta[index])))) + - " GeV" + "\n " + AMath.ETA + " = " + String.format("%.3f",eta[index]) + "\n " + - AMath.PHI + " = " + String.format("%.3f",Math.toDegrees(phi[index])) + - AMath.DEGREES + " (" + String.format("%.3f",phi[index]) + " rad)"; - - if(isGood != null) msg += "\n Selection: isGood =" + isGood[index] + "(isBad = " + isBad[index] + ", isUgly = " + isUgly[index] + ")"; - if(hecf != null) msg += "\n hecf = " + String.format("%.2f",hecf[index])+ ", n90cells = " + n90cells[index] + " (n90const = " + n90const[index] + ")"; - if (emfrac != null) msg += "\n emfrac = " + String.format("%.2f",emfrac[index]); - if (quality != null) msg += "\n quality = " + String.format("%.2f",quality[index]); - if (qualityLAr != null) msg += "(qLAr = " + String.format("%.2f",qualityLAr[index]) + ")"; - - if (hasJvf) - { - msg += "\n jvf = " + String.format("%.2f",jvf[index]); - } - else - { - msg += "\n jvf n/a "; - } - if (weight != null) msg += " b-weight = " + String.format("%.2f",weight[index]); - // Displaying bTagValues and bTagnames to the outputscreen - if(bTagValue != null) - { - //calculating "multiple" number - int Div = (bTagValue.length)/(eta.length); - msg += "\n b-Taggers: "; - for (int s=0;s<Div;s++) - { - msg += bTagName[index*Div + s] + "=" + String.format("%.2f",bTagValue[index*Div + s]) + ", "; - } - } - if (time != null) msg += "\n time = " + String.format("%.2f",time[index]) + " ns (clus time = " + String.format("%.2f",timeClusters[index]) + " ns)"; - if (OutOfTimeEfrac != null) msg += "\n Out-Of-Time Energy fraction = " + String.format("%.2f", OutOfTimeEfrac[index]); - if (fracSamplingMax != null) msg += "\n fracSamplingMax = " + String.format("%.2f",fracSamplingMax[index]) + " (sMax = " + caloSample[(int) sMax[index]] + ")"; - if (tileGap3f != null) msg += "\n tileGap3f = " + String.format("%.2f",tileGap3f[index]) + ", fcorCell=" + String.format("%.2f",fcorCell[index]) + ", fcorJet=" + String.format("%.2f",fcorJet[index]); - if (fcorDotx != null) msg += "\n fcorDotx=" + String.format("%.2f",fcorDotx[index]) + " (not implemented yet)"; - - return msg; - } - - // info on Jet collections contained in v-plot rubberband selection - public String getVPHitInfo() - { - makeDrawList(); - if (numDraw == 0) - return ""; - double sumE = 0.; - double sumEt = 0.; - - for (int i = 0; i < numDraw; ++i) - { - sumEt += Math.abs(eT[listdl[i]]); - sumE += Math.abs(eT[listdl[i]] / Math.cos(AMath.lambda(eta[listdl[i]]))); - } - - String key = getFullName(); - String msg = numDraw + " " + (key != null ? "" + key : getNameScreenName()); - msg += " sum(ET) = " + String.format("%.1f",sumEt) + " sum(E) = " + String.format("%.1f",sumE); - - return msg; - } - - public A4Vector get4Vector(int num, int[] list) - { - A4Vector sum = new A4Vector(); - if(has4Vect){ - for (int i = 0; i < num; ++i) - { - int k = list[i]; - A4Vector start = new A4Vector(); - start.setPtEtaPhiM(pT[k],eta[k],phi[k],mass[k]); - sum.add(start); - } - }else{ - for (int i = 0; i < num; ++i) - { - int k = list[i]; - A3Vector start = A3Vector.fromRhoPhiZ(0., 0., 0.); - double tL = AMath.tanLambda(eta[k]); - A3Vector stop = A3Vector.fromRhoPhiZ(1., phi[k], tL); - A3Vector v = (stop.subtract(start)).normalize(); - double p = eT[k] / Math.sqrt(1. - v.z * v.z); - sum.add(new A4Vector(v.scale(p), 0.)); - } - } - return sum; - } - - public void draw(AWindow window, AGraphics ag, AProjection2D projection) - { - if (projection instanceof AProjectionVP) - { - ACoord centers = window.calculateDisplay(getUser(projection)); - int[] drawlist = centers.index; - double eLimit = 0.05; - int numPoints = 25; - double[][][] hv = new double[2][drawlist.length][numPoints]; - - for (int i = 0; i < drawlist.length; ++i) - { - int list = drawlist[i]; - int jetMode = parameterStore.get("VP", "Jet").getI(); - double e; - if (jetMode == 0) - // showing jet in ET - e = Math.abs(eT[list]); - else - // showing jet in E - e = Math.abs(eT[list] / Math.cos(AMath.lambda(eta[list]))); - int d = (int) (Math.sqrt((e / eLimit) / Math.PI)); - if (d == 0) - d = 1; - for (int j = 0; j < numPoints; j++) - { - hv[0][i][j] = centers.hv[0][0][i] + d * Math.cos(Math.PI * 2 * j / (numPoints - 1)); - hv[1][i][j] = centers.hv[1][0][i] + d * Math.sin(Math.PI * 2 * j / (numPoints - 1)); - } - } - ag.draw(new ACoord(hv, drawlist, this, ACoord.POLYLINES)); - } - else - { - super.draw(window, ag, projection); - } - } - - protected int getDrawOrFill() - { - return AGraphics.FILL; - } - - protected ACoord getVPUser() - { - makeDrawList(); - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - h[i] = eta[list]; - v[i] = Math.toDegrees(phi[list]); - index[i] = list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("VP"); - } - - @Override - protected ACoord getYXUser() - { - int coneSmooth = 20; - makeDrawList(); - double[][][] hv = new double[2][numDraw][(2*coneSmooth)]; - int[] index = new int[numDraw]; - - String k = this.getStoreGateKey(); - String sgKey = k != null ? k : "n/a"; - - double dphi = 0.4; - - if(sgKey.contains("Kt6")) - dphi = 0.6; - if(sgKey.contains("Kt1")) - dphi = 1.0; - - double rhoMinus = parameterStore.get("Jet","Innerdrawradius").getD(); - double maxEnergy = parameterStore.get("Projection", "EnergyMax").getD(); - double s = parameterStore.get("Jet", "Scale").getD(); - double rhoMax = s*1000; - if (0==s) return ACoord.NO_POLYLINES; - - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - double phiPlus = phi[list] + dphi; - double phiMinus = phi[list] - dphi; - - //if no composite particles increase jet size - //Vector keys = (Vector) event.getCollections().get("CompositeParticle"); - //if (keys == null || !parameterStore.get("Data", "CompositeParticle").getStatus()) rhoMax=1000;//1800; - - double rhoPlus = rhoMax; - if(Math.abs(eT[list]) < maxEnergy) { - if(parameterStore.get("Jet", "ScaleType").getI() == 1) //sq root - rhoPlus = rhoMinus + rhoMax * (Math.sqrt (Math.abs(eT[list])/maxEnergy)); - if(parameterStore.get("Jet", "ScaleType").getI() == 0) // linear - rhoPlus = rhoMinus + rhoMax * (Math.abs(eT[list])/maxEnergy); - } - - double vx = parameterStore.get("Event", "XVtx").getD(); - double vy = parameterStore.get("Event", "YVtx").getD(); - - double h_shift = vx; - double v_shift = vy; - - // the loop interpolates between the inner and outer edge of the jet to draw the arc - - // draw the outer arc - for(int j=0; j<coneSmooth; j++){ - float f = ((float)j)/(coneSmooth-1); - hv[0][i][j] = h_shift + (rhoPlus) * Math.cos(((1-f)*phiPlus + (f)*phiMinus)); - hv[1][i][j] = v_shift + (rhoPlus) * Math.sin(((1-f)*phiPlus + (f)*phiMinus)); - } - - // draw the inner arc - for(int j=coneSmooth; j<(2*coneSmooth); j++){ - float f = ((float)j-coneSmooth)/(coneSmooth-1); - hv[0][i][j] = h_shift + (rhoMinus) * Math.cos(((1-f)*phiMinus + (f)*phiPlus)); - hv[1][i][j] = v_shift + (rhoMinus) * Math.sin(((1-f)*phiMinus + (f)*phiPlus)); - } - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.TRANSPARENT_POLYGONS); - } - - protected ACoord getFRUser() - { - makeDrawList(); - double[][][] hv = new double[2][numDraw][4]; - int[] index = new int[numDraw]; - - String k = this.getStoreGateKey(); - String sgKey = k != null ? k : "n/a"; - - double dphi = 0.4; - - if(sgKey.contains("Kt6")) - dphi = 0.6; - if(sgKey.contains("Kt1")) - dphi = 1.0; - - double s = parameterStore.get("Jet", "Scale").getD(); - double rhoMax = s*1500; - double rhoMinus = parameterStore.get("Jet","Innerdrawradius").getD(); - double maxEnergy = parameterStore.get("Projection", "EnergyMax").getD(); - if (0==s) return ACoord.NO_POLYLINES; - - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - double phiPlus = phi[list] + dphi; - double phiMinus = phi[list] - dphi; - - //if no composite particles increase jet size - //Vector keys = (Vector) event.getCollections().get("CompositeParticle"); - //if (keys == null || !parameterStore.get("Data", "CompositeParticle").getStatus()) rhoMax=1000;//1800; - - double rhoPlus = rhoMinus + rhoMax; - if(Math.abs(eT[list]) < maxEnergy) { - if(parameterStore.get("Jet", "ScaleType").getI() == 1) //sq root - rhoPlus = rhoMinus + rhoMax * (Math.sqrt (Math.abs(eT[list])/maxEnergy)); - if(parameterStore.get("Jet", "ScaleType").getI() == 0) // linear - rhoPlus = rhoMinus + rhoMax * (Math.abs(eT[list])/maxEnergy); - } - - hv[0][i][0] = rhoMinus; - hv[1][i][0] = Math.toDegrees(phiMinus); - - hv[0][i][1] = rhoMinus; - hv[1][i][1] = Math.toDegrees(phiPlus); - - hv[0][i][2] = rhoPlus; - hv[1][i][2] = Math.toDegrees(phiPlus); - - hv[0][i][3] = rhoPlus; - hv[1][i][3] = Math.toDegrees(phiMinus); - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.TRANSPARENT_POLYGONS).includePhiWrapAround("FR"); - } - - protected double Theta (double eta, int rSign) - { - // calculate theta based on the eta value - double theta = Math.atan(Math.exp(-Math.abs(eta))) * 2.0; - if ((eta > 0.) && (rSign == -1)) - theta = 2 * Math.PI - theta; - else if ((eta < 0.) && (rSign == -1)) - theta += Math.PI; - else if ((eta < 0.) && (rSign == 1)) - theta = Math.PI - theta; - - return theta; - } - - protected ACoord getRZUser() - { - int coneSmooth = 20; - double s = parameterStore.get("Jet", "Scale").getD(); - if (0==s) return ACoord.NO_POLYLINES; - makeDrawList(); - double[][][] hv = new double[2][numDraw][(2*coneSmooth)]; - int[] index = new int[numDraw]; - - double innerRadius = parameterStore.get("Jet","Innerdrawradius").getD(); - - String k = this.getStoreGateKey(); - String sgKey = k != null ? k : "n/a"; - - double deta = 0.4; - - if(sgKey.contains("Kt6")) - deta = 0.6; - if(sgKey.contains("Kt1")) - deta = 1.0; - - - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(phi[list]-phiMid); - int rSign; - if (phiDiff > Math.PI/2. && phiDiff <= 3*Math.PI/2.) - rSign = -1; - else - rSign = 1; - - double theta = Theta(eta[list],rSign); - double thetaPlus = Theta(eta[list] + deta, rSign); - double thetaMinus = Theta(eta[list] - deta, rSign); - - // decide the region based on the theta value - final byte TOP_BOTTOM = 0; - final byte LEFT_RIGHT = 1; - byte region = TOP_BOTTOM; - // hard-coded value is based on the values in Geometry - if(Math.abs(Math.tan(theta)) < 0.8) - region = LEFT_RIGHT; - - double radiusMinus = 0.; - - switch(region) - { - case TOP_BOTTOM: - radiusMinus = innerRadius / Math.abs(Math.sin(theta)); - break; - case LEFT_RIGHT: - radiusMinus = innerRadius / Math.abs(Math.cos(theta)); - break; - } - //compare to AAODData for rhoMax/Minus values - double radiusMax = s*2500.; - - //if no composite particles increase jet size - //Vector keys = (Vector) event.getCollections().get("CompositeParticle"); - //if (keys == null || !parameterStore.get("Data", "CompositeParticle").getStatus()) radiusMax+=200; - - double maxEnergy = parameterStore.get("Projection", "EnergyMax").getD(); - double radiusPlus = radiusMinus + radiusMax; - if(Math.abs(eT[list] / Math.cos(AMath.lambda(eta[list]))) < maxEnergy) - { - if(parameterStore.get("Jet", "ScaleType").getI() == 1) //sq root - radiusPlus = radiusMinus + radiusMax * (Math.sqrt (Math.abs(eT[list] / Math.cos(AMath.lambda(eta[list])))/maxEnergy)); - if(parameterStore.get("Jet", "ScaleType").getI() == 0) // linear - radiusPlus = radiusMinus + radiusMax *((Math.abs(eT[list] / Math.cos(AMath.lambda(eta[list]))))/maxEnergy); - } - - double vx = parameterStore.get("Event", "XVtx").getD(); - double vy = parameterStore.get("Event", "YVtx").getD(); - double vz = parameterStore.get("Event", "ZVtx").getD(); - - double h_shift = vz; - double v_shift = Math.sqrt(vx*vx + vy*vy); - - // the loop interpolates between the inner and outer edge of the jet to draw the arc - // draw the outer arc - for(int j=0; j<coneSmooth; j++){ - float f = ((float)j)/(coneSmooth-1); - hv[0][i][j] = h_shift + (radiusPlus) * Math.cos(((1-f)*thetaPlus + (f)*thetaMinus)); - hv[1][i][j] = v_shift + (radiusPlus) * Math.sin(((1-f)*thetaPlus + (f)*thetaMinus)); - } - - // draw the inner arc - for(int j=coneSmooth; j<(2*coneSmooth); j++){ - float f = ((float)j-coneSmooth)/(coneSmooth-1); - hv[0][i][j] = h_shift + (radiusMinus) * Math.cos(((1-f)*thetaMinus + (f)*thetaPlus)); - hv[1][i][j] = v_shift + (radiusMinus) * Math.sin(((1-f)*thetaMinus + (f)*thetaPlus)); - } - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.TRANSPARENT_POLYGONS); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AJetROIData.java b/graphics/AtlantisJava/src/atlantis/data/AJetROIData.java deleted file mode 100755 index c47c2ce92990478ddf6bff81848c09bd0a838d83..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AJetROIData.java +++ /dev/null @@ -1,38 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.utils.AHashMap; - -/** - * - * Jet Region Of Interest - * - * @author Zdenek Maxa, Qiang Lu - */ -public class AJetROIData extends AROIData -{ - - AJetROIData(AHashMap p, AEvent e) - { - super(p,e); - } // AJetROIData() ------------------------------------------------------ - - - public String getParameterGroup() - { - return "JetROI"; - } // getParameterGroup() ------------------------------------------------ - - - public String getName() - { - return "JetROI"; - } // getName() ---------------------------------------------------------- - - - public String getNameScreenName() - { - return "JetROI"; - } // getNameScreenName() ------------------------------------------------ - -} // class AJetROIData ====================================================== diff --git a/graphics/AtlantisJava/src/atlantis/data/ALArData.java b/graphics/AtlantisJava/src/atlantis/data/ALArData.java deleted file mode 100644 index 7b0efc9cd77c6bd3aa91666db1e9b5d34b358ab8..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ALArData.java +++ /dev/null @@ -1,1032 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import com.Ostermiller.util.CSVParser; - -import java.io.IOException; -import java.io.InputStream; -import java.io.StringReader; -import java.io.FileNotFoundException; - -import atlantis.geometry.ABarrelCalorimeterDetector; -import atlantis.geometry.ACalorimeterDetector; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.AIdHelper; -import atlantis.utils.AMath; -import atlantis.utils.AUtilities; -import atlantis.parameters.AParameter; -import atlantis.utils.ALogger; - - -/** - * The Liquid Argon ElectroMagnetic Calorimeter - * - * @author Eric Jansen - */ -public class ALArData extends ACalorimeterData -{ - private static ALogger logger = ALogger.getLogger(ALArData.class); - - // data for real pulse shapes plots - private int numSamplings = 0; - private int[][] adcCounts = null; - private float[] cellTime = null; - private int[] cellGain = null; - private float[] cellPedestal = null; - private float[] adc2Mev = null; - private static boolean pulseShapesDataAvailable = false; - private static final String LOOKUP_TABLE_FILE = - AGlobals.instance().getHomeDirectory() + "configuration" + - System.getProperty("file.separator") + - "rpsplt_lar.csv"; - // number of lookup table values for real pulse shapes plots calculation - private static final short NUMBER_OF_LOOKUP_VALUES = 799; - - - - ALArData(AHashMap p, AEvent e) - { - super(p,e); - - for (int i = 0; i < numData; i++) - { - try - { - side[i] = (byte) AIdHelper.larBarrelEndcap(id[i]); - etaIndex[i] = (short) AIdHelper.larEta(id[i]); - phiIndex[i] = (short) AIdHelper.larPhi(id[i]); - sampling[i] = AIdHelper.larSampling(id[i]); - } - catch (AAtlantisException aex) - { - logger.warn("Problem decoding ID " + id[i] + " in " + - CALORIMETER_NAME + ": " + aex.getMessage(), aex); - side[i] = 0; - etaIndex[i] = -1; - phiIndex[i] = -1; - sampling[i] = -1; - } - } - - makeHitToGeometryMapping(); - for (int i = 0; i < et.length; ++i) - { - et[i] = Math.abs(energy[i] / (float) Math.cosh(eta[i])); - } - - // Collect some constants we need for the histograms. - for (int i = 0; i < ACalorimeterDetector.count(); i++) - { - - if (ACalorimeterDetector.get(i).getName().indexOf(CALORIMETER_NAME) >= 0) - { - if (ACalorimeterDetector.get(i) instanceof ABarrelCalorimeterDetector) - { - if (innerR == 0.0 || ACalorimeterDetector.get(i).getRMin() < innerR) - { - innerR = ACalorimeterDetector.get(i).getRMin(); - } - } - else - { - if (innerZ == 0.0 || ACalorimeterDetector.get(i).getZMin() < innerZ) - { - innerZ = ACalorimeterDetector.get(i).getZMin(); - } - } - if (outerR == 0.0 || ACalorimeterDetector.get(i).getRMax() > outerR) - { - outerR = ACalorimeterDetector.get(i).getRMax(); - } - if (outerZ == 0.0 || ACalorimeterDetector.get(i).getZMax() > outerZ) - { - outerZ = ACalorimeterDetector.get(i).getZMax(); - } - if (outerEta == 0.0 || ACalorimeterDetector.get(i).getEtaMax() > outerEta) - { - outerEta = ACalorimeterDetector.get(i).getEtaMax(); - } - if (phiGranularity == 0.0 || ACalorimeterDetector.get(i).getDeltaPhi() < phiGranularity) - { - phiGranularity = ACalorimeterDetector.get(i).getDeltaPhi(); - } - if (etaGranularity == 0.0 || ACalorimeterDetector.get(i).getDeltaEta() < etaGranularity) - { - etaGranularity = ACalorimeterDetector.get(i).getDeltaEta(); - } - } - } - - // Add a little bit of extra margin to prevent binning errors due to - // rounding of numbers. - outerEta += etaGranularity; - - readPulseShapePlotData(p); - - } // ALArData() --------------------------------------------------------- - - - - private void readPulseShapePlotData(AHashMap p) - { - // read ADCCounts and cell data for real pulse shapes plots - adcCounts = super.getADCCountsData(p); - - // read LAr digits (cell data) for real pulse shapes plots - cellTime = (p.get("cellTime") != null) ? p.getFloatArray("cellTime") : null; - cellGain = (p.get("cellGain") != null) ? p.getIntArray("cellGain") : null; - cellPedestal = (p.get("cellPedestal") != null) ? p.getFloatArray("cellPedestal") : null; - adc2Mev = (p.get("adc2Mev") != null) ? p.getFloatArray("adc2Mev") : null; - - pulseShapesDataAvailable = false; - if(adcCounts != null && cellTime != null && cellGain != null && - cellPedestal != null && adc2Mev != null) - { - pulseShapesDataAvailable = true; - numSamplings = adcCounts[0].length; - - logger.debug(CALORIMETER_NAME + - ": data for real pulse shape plots available"); - - if(ACalorimeterRPSPLT.areLarLookupTablesInitialized()) - { - logger.debug(CALORIMETER_NAME + - ": lookup tables have already been read in"); - } - else - { - logger.debug(CALORIMETER_NAME + - ": lookup table values have not been read in yet\n" + - " trying to read file: " + LOOKUP_TABLE_FILE); - - try - { - readLookupTableFile(); - - logger.debug(CALORIMETER_NAME + - ": values from " + LOOKUP_TABLE_FILE + - " successfully read in"); - } - catch(AAtlantisException ex) - { - logger.error(CALORIMETER_NAME + - ": reading " + LOOKUP_TABLE_FILE + - " failed, real pulse shapes plots will not " + - "be available, reason: " + ex.getMessage(), ex); - pulseShapesDataAvailable = false; - } - } - } - - } // readPulseShapePlotData() ------------------------------------------- - - - - /** - * readLookupTableFile() reads in comma separated values (CSV) file - * with LAr real pulse shapes plots time and amplitude lookup values - * @param fileName String - * @throws AAtlantisException - */ - private void readLookupTableFile() throws AAtlantisException - { - try - { - InputStream is = AUtilities.getFileAsStream(LOOKUP_TABLE_FILE); - CSVParser parser = new CSVParser(is); - parser.setCommentStart("#"); - String arrayName = null; - - while((arrayName = parser.nextValue()) != null) - { - String valueArray = parser.nextValue(); // shall now contain all values - CSVParser parserArray = new CSVParser(new StringReader(valueArray)); - String[][] s = parserArray.getAllValues(); - - float[] array = getLookupTableArray(s, NUMBER_OF_LOOKUP_VALUES); - ACalorimeterRPSPLT.setLarTable(arrayName, array); - } // while - } - catch(FileNotFoundException e) - { - throw new AAtlantisException("could not find file: " + - LOOKUP_TABLE_FILE); - } - catch(IOException e) - { - throw new AAtlantisException("exception while reading file: " + - LOOKUP_TABLE_FILE); - } - catch(AAtlantisException e) - { - throw e; - } - - } // readLookupTableFile() ---------------------------------------------- - - - - /** - * - * @param index int - * @param lookupTablesInfo String - * Debug info method in order to make sure that correct lookup table - * is used given barrel/endcap, sampling and region of LAr. - */ - private void pulseShapePlotsDebugInfo(int index, String lookupTableName) - { - String msg = null; - try { - msg = "\n barrel/endcap value: " + - AIdHelper.larBarrelEndcap(id[index]); - msg += " is "; - msg += AIdHelper.larIsBarrel(id[index]) ? "barrel" : "endcap"; - msg += "\n sampling/layer: " + sampling[index]; - msg += "\n region: " + AIdHelper.larRegion(id[index]); - msg += "\n lookup table used: " + lookupTableName; - logger.debug(msg + "\n"); - } catch (AAtlantisException aaex) { - logger.debug("\n exception: " + aaex.getMessage(), aaex); - } - } // pulseShapePlotsDebugInfo() ----------------------------------------- - - - - /** - * This method is used when calculating real pulse shapes plots. - * It is called from getLookupTableForPulseShapesPlots() - * It calculates index of the 0.1 eta bin the argument eta - * (eta of a cell) falls into. Thus it determines which eta - * range a cell belongs to (eta ranges are last level of cells - * division from barrel/endcap, layer, region. - * startIndex argument tells which eta range we start counting from - * (given the eta ranges division it may not necessarily be from 0). - * If eta doesn't fall into a specified interval, empty String - * is returned - then missing ETAx suffix will cause retrieving - * of the float[] will fail. - * - * @param etaFrom - * @param etaTo - * @return - */ - private static String getEtaBinIndex(float etaFrom, float etaTo, - float cellEta, int startIndex) - { - float step = 0.1f; // step, size of the eta bins - float absEta = Math.abs(cellEta); - int index = startIndex; - - for(float f = etaFrom; f < etaTo; f += step, index++) - { - if(absEta > f && absEta < f + step) - { - logger.debug("eta range calculation: cell eta = " + cellEta + " " + - "etaFrom = " + etaFrom + " etaTo = " + etaTo); - logger.debug("eta range index result: " + index + - " (index offset was: " + startIndex + ")"); - return "ETA" + index + "_" ; - } - } - - // calculating bin failed, retrieving the array will fail later - return ""; - - } // calculateEtaBinIndex() --------------------------------------------- - - - - /** - * Method returns correct float[] array for amplitude lookup table - * depending whether a cell (determined by index, resp. id[index]) is in - * barrel, endcap, which layer and which region or which eta range. - * This method accesses ACalorimeterRPSPLT - * Methods contains constant value defining parts of LAr detector - * (as used in AIdHelper) and also eta range constants provided by - * the LAr community. - * - * @param index int - * @return float[] - */ - private float[] getLookupTableForPulseShapesPlots(int index) throws AAtlantisException - { - float[] amplitude = null; // lookup table amplitude values - - // helper variable - absolute value of eta - for checking of the eta range - float absEta = Math.abs(eta[index]); - - // the key for ACalorimeterRPSPLT.getLarTable(key) will gradually be - // constructed depending on barrel/endcap, layer, region and eta range - String lookupTableKey = "LAR_"; // start of the name all LAR_ tables - - - if(AIdHelper.larIsBarrel(id[index])) - { - // it is barrel - lookupTableKey += "BARREL_"; - switch(sampling[index]) - { - case 0: // layer 0 - // plot ADC counts only for this layer - String[] decodedId = AIdHelper.getFullIdentifier(id[index]); - String title = "LAr cell: " + decodedId[0]; - int[][] data = { adcCounts[index] }; - APulseShapePlot.plotADCCounts(data, title, null); - throw new AAtlantisException("ADC counts plot only, pulse shape plot not " + - "implemented for LAr barrel, layer 0"); - case 1: - lookupTableKey += "LAYER1_"; // layer 1 - switch(AIdHelper.larRegion(id[index])) - { - case 0: - lookupTableKey += "REGION0_"; - break; - case 1: - lookupTableKey += "REGION1_"; - break; - default: - AOutput.append("\npulse shape plots - LAr barrel, " + - "layer 1, region > 1. Using layer 1, " + - "region 1 lookup table\n", ALogInterface.WARNING); - lookupTableKey += "REGION1_"; - } - break; - case 2: // layer 2 - lookupTableKey += "LAYER2_"; // layer 2 - switch(AIdHelper.larRegion(id[index])) - { - case 0: - lookupTableKey += "REGION0_"; - break; - case 1: - lookupTableKey += "REGION1_"; - break; - default: - AOutput.append("\npulse shape plots - LAr barrel, " + - "layer 2, region > 1. Using layer 2, " + - "region 1 lookup table\n", ALogInterface.WARNING); - lookupTableKey += "REGION1_"; - } - break; - case 3: // layer 3 - lookupTableKey += "LAYER3_REGION0_"; - break; - } - } // if(AIdHelper.larIsBarrel(id[index])) - else - { - // we are in the endcap - lookupTableKey += "ENDCAP_"; - switch(sampling[index]) - { - case 0: // layer 0 - // only one region and one eta range on this layer - lookupTableKey += "LAYER0_REGION0_ETA0_"; - break; - case 1: // layer 1 - lookupTableKey += "LAYER1_"; - switch(AIdHelper.larRegion(id[index])) - { - case 0: - lookupTableKey += "REGION0_"; - if(absEta > 1.375f && absEta < 1.425f) - { - lookupTableKey += "ETA0_"; // first eta range - } - else - { - // eta ranges with step 0.1 provided by Andre - // start index counting from 1, 0 range is used above - lookupTableKey += getEtaBinIndex(2.5f, 3.2f, eta[index], 1); - } - break; - case 1: - lookupTableKey += "REGION1_ETA0_"; // no eta subdivision - break; - case 2: - lookupTableKey += "REGION2_"; - // starting from first range, startIndex 0 - lookupTableKey += getEtaBinIndex(1.5f, 1.8f, eta[index], 0); - break; - case 3: - lookupTableKey += "REGION3_"; - lookupTableKey += getEtaBinIndex(1.8f, 2.0f, eta[index], 0); - break; - case 4: - lookupTableKey += "REGION4_"; - lookupTableKey += getEtaBinIndex(2.0f, 2.4f, eta[index], 0); - break; - case 5: - lookupTableKey += "REGION5_"; - if(absEta > 2.4f && absEta < 2.5f) - { - lookupTableKey += "ETA0_"; - } - break; - default: - AOutput.append("\npulse shape plots - LAr endcap, " + - "layer 1, region > 5. Using layer 1, " + - "region 5, eta range 0 lookup table\n", - ALogInterface.WARNING); - lookupTableKey += "REGION5_ETA0_"; - } - break; - case 2: // layer 2 - lookupTableKey += "LAYER2_"; - switch(AIdHelper.larRegion(id[index])) - { - case 0: - lookupTableKey += "REGION0_"; - if(absEta > 1.375f && absEta < 1.425f) - { - lookupTableKey += "ETA0_"; // first eta range - } - else - { - // eta ranges with step 0.1 provided by Andre - // start index counting from 1, 0 range is used above - lookupTableKey += getEtaBinIndex(2.5f, 3.2f, eta[index], 1); - } - break; - case 1: - lookupTableKey += "REGION1_"; - lookupTableKey += getEtaBinIndex(1.425f, 2.5f, eta[index], 0); - break; - } - break; - case 3: // layer 3 - lookupTableKey += "LAYER3_"; - lookupTableKey += "REGION0_"; - lookupTableKey += getEtaBinIndex(1.5f, 2.5f, eta[index], 0); - break; - } - } // else (endcap) - - lookupTableKey += "AMPLITUDE"; - pulseShapePlotsDebugInfo(index, lookupTableKey); - amplitude = ACalorimeterRPSPLT.getLarTable(lookupTableKey); - - return amplitude; - - } // getLookupTableForPulseShapesPlots() ------------------------------- - - - - /** - * This method plots only the ADC counts and no pulse shape plot for a - * given cell. This is useful when the pulse shape plot is not correct - * but ADC count plot is still needed. The method is called from pick - * interaction with D (digits only), see APickInteraction.pressed() - * It is supposedly a temporary solution until LAr real pulse shapes - * lookup tables are corrected / finalized and propagated to Atlantis. - * @param index - */ - public void plotADCCounts(int index) - { - if(pulseShapesDataAvailable) - { - String title = getPulseTitleString(index); - - int[][] adcCountsLocal = new int[][] { adcCounts[index] }; - - logger.debug("Plotting only ADC counts plot ... "); - APulseShapePlot.plotADCCounts(adcCountsLocal, title, null); - - } // if(pulseShapesDataAvailable) - else - { - return; - } - - } // plotADCCounts() ---------------------------------------------------- - - - -// /** -// * Call util class which plots cell pulse shapes provided that -// * all real pulse shapes data is available -// * Functions calculates values of real pulse shape calculated in the method -// * getPhysicsPulseShape(). -// * This method is called from pick interaction. -// * -// * @param index int -// */ - /*public void plotPulseShapes(int index) - { - if(pulseShapesDataAvailable) - { - String title = getPulseTitleString(index); - - int[][] adcCountsLocal = new int[][] { adcCounts[index] }; - - - if(super.checkADCCountsAvailability(adcCountsLocal)) - { - // adc counts are available - logger.debug(CALORIMETER_NAME + " adc counts (digits) are " + - "available for pulse shapes plots for this cell."); - } - else - { - String m = "ADC counts are not available for this cell, " + - "can't plot pulse shapes."; - AOutput.append("\n" + m, ALogPane.WARNING); - logger.warn(m); - return; - } - - - float[] amplitude = null; // amplitude lookup table - float[] time = null; // time lookup table - try - { - time = ACalorimeterRPSPLT.getLarTable("LAR_TIME"); - amplitude = getLookupTableForPulseShapesPlots(index); - } - catch(AAtlantisException ex) - { - AOutput.append("\n" + ex.getMessage(), ALogPane.WARNING); - logger.error(ex.getMessage()); - return; - } - - // 1 .. 32 range (32 values of ADC counts, i.e. 32 samples), need to - // get NUMBER_OF_LOOKUP_VALUES (769) within this range (starts from 1!). - // Real data will have (probably) only 5 samples per cell - double step = (adcCounts[0].length - 1) / (float) NUMBER_OF_LOOKUP_VALUES; - double[][] realPulse = new double[1][NUMBER_OF_LOOKUP_VALUES]; // 1 channel - double d = 1.0; - // if adc2Mev != -1 -> use value from event file, otherwise predefined value - // see comment at the getADC2MevFactorPredefined() method - // factor variable is used as a flag whether or not to plot pulse shape, - // if is -1 (adc2Mev not available), then want to see only the adc counts - // and don't calculate the pulse shapes - // getADC2MevFactorPredefined(index) is no longer in use, see comment at it - float factor = adc2Mev[index]; - - double energyLocal = energy[index] * 1000.0 / factor; - try - { - if(factor != -1) - { - for(int i = 0; i < NUMBER_OF_LOOKUP_VALUES; i++) - { - d += step; - realPulse[0][i] = super.getPhysicsPulseShape(d, cellTime[index], - cellPedestal[index], energyLocal, - amplitude, time, NUMBER_OF_LOOKUP_VALUES); - } - } - } - catch(AAtlantisException aaex) - { - AOutput.append(aaex.getMessage(), ALogPane.WARNING); - logger.error(aaex.getMessage()); - return; - } - - if(factor != -1) - { - logger.debug("adc2Mev factor available, plotting full plot."); - APulseShapePlot.plotRealPulseShapes(adcCountsLocal, realPulse, - step, null, title); - } - else - { - logger.debug("adc2Mev factor not available, plotting just adc counts."); - APulseShapePlot.plotADCCounts(adcCountsLocal, title, null); - } - - } // if(pulseShapesDataAvailable) - else - { - return; - } - - } */// plotPulseShapes() -------------------------------------------------- - - @Override - protected int[][] getADCCounts(int index) { - if (pulseShapesDataAvailable) { - for (int adc : adcCounts[index]) { - // Only return something if it is non-zero - if (adc != 0) return new int[][] { adcCounts[index] }; - } - } - return null; - } - - /** - * Calculate local time for pulse shape plots - */ - protected double getLocalTime(double xTime, double cellTime, int numSamplings) { - int nominalPeakSample = (int)(numSamplings / 2.); - return ((xTime - nominalPeakSample + 3) * 25.0) - cellTime; - } - - @Override - protected double[][] getPulseShape(int index) { - - float[] amplitude = null; // amplitude lookup table - float[] time = null; // time lookup table - try - { - time = ACalorimeterRPSPLT.getLarTable("LAR_TIME"); - amplitude = getLookupTableForPulseShapesPlots(index); - } - catch(AAtlantisException ex) - { - AOutput.append("\n" + ex.getMessage(), ALogInterface.WARNING); - logger.error(ex.getMessage()); - return null; - } - - // 1 .. 32 range (32 values of ADC counts, i.e. 32 samples), need to - // get NUMBER_OF_LOOKUP_VALUES (769) within this range (starts from 1!). - // Real data will have (probably) only 5 samples per cell - double step = getPulseStep(index); - double[][] realPulse = new double[1][NUMBER_OF_LOOKUP_VALUES]; // 1 channel - double d = 1.0; - // if adc2Mev != -1 -> use value from event file, otherwise predefined value - // see comment at the getADC2MevFactorPredefined() method - // factor variable is used as a flag whether or not to plot pulse shape, - // if is -1 (adc2Mev not available), then want to see only the adc counts - // and don't calculate the pulse shapes - // getADC2MevFactorPredefined(index) is no longer in use, see comment at it - float factor = adc2Mev[index]; - - double energyLocal = energy[index] * 1000.0 / factor; - try - { - if(factor != -1) - { - for(int i = 0; i < NUMBER_OF_LOOKUP_VALUES; i++) - { - d += step; - double localTime = getLocalTime(d, cellTime[index], this.numSamplings); - realPulse[0][i] = super.getPhysicsPulseShape(localTime, - cellPedestal[index], energyLocal, - amplitude, time, NUMBER_OF_LOOKUP_VALUES); - } - } - } - catch(AAtlantisException aaex) - { - AOutput.append(aaex.getMessage(), ALogInterface.WARNING); - logger.error(aaex.getMessage()); - return null; - } - - if(factor != -1) - { - logger.debug("adc2Mev factor available, plotting full plot."); - return realPulse; - } - else - { - return null; - } - } - - @Override - protected double getPulseStep(int index) { - return (adcCounts[0].length - 1) / (float) NUMBER_OF_LOOKUP_VALUES; - } - -// /** -// * Determines adc2Mev factor value for a cell. The number either comes -// * with the event file (adc2Mev subtag), but sometimes is not available -// * in Athena (in the database) which is indicated by -1 in the event file -// * for a particular cell. In this case, use predefined constant in this -// * method. -// * -// * zdenek (2008-09-15): -// * These predefined values (which are used if adc2Mev factor is -1) should -// * no longer be used. if the factor is not present, do not plot the pulse -// * shape, just the ADC counts as these values are non-sense. The method -// * and references to it should be removed after some time (if calo people -// * don't change their mind to pre-define some other values and use those) -// -// * @param index int -// * @return String -// */ - /* - private float getADC2MevFactorPredefined(int index) - { - boolean barrel = false; - int layer = sampling[index]; - - try - { - barrel = AIdHelper.larIsBarrel(id[index]); - } - catch (AAtlantisException e) - { - AOutput.append("Problem decoding ID " + id[index] + - " in " + CALORIMETER_NAME + ": " + e.getMessage(), - ALogPane.WARNING); - return Float.NEGATIVE_INFINITY; - } - - float r = Float.NEGATIVE_INFINITY; - if(barrel) - { - switch(layer) - { - case 0: r = 7.0f; - break; - case 1: r = 2.5f; - break; - case 2: r = Math.abs(this.eta[index]) < 0.8 ? 10.0f : 18.0f; - break; - case 3: r = 9.0f; - break; - } - } - else - { - r = 16.0f; - } - - return r; - - } // getADC2MevFactor() ------------------------------------------------- - */ - - - /** - * Returns calo hit info - * - * @param index int - * @return String - */ - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n ET="+String.format("%.3f",et[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Ex="+String.format("%.3f",et[index]*Math.cos(phi[index]))+" GeV "+ - "\n Ey="+String.format("%.3f",et[index]*Math.sin(phi[index]))+" GeV "+ - "\n Ez="+String.format("%.3f",et[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - String t = ""; - String cellInfo = ""; - - // if decoded ID is required and implemented for LAr ... - // String decodedId = AIdHelper.getDecodedTileIndentifier(id[index]); - // t = decodedId + " " + super.getHitInfo(index); - t = super.getHitInfo(index); - - cellInfo += "\n cell time = "; - cellInfo += (cellTime != null) ? Float.toString(cellTime[index]) + - " ns" : "n/a"; - cellInfo += "\n cell gain = "; - cellInfo += (cellGain != null) ? Integer.toString(cellGain[index]) : "n/a"; - cellInfo += "\n cell pedestal = "; - cellInfo += (cellPedestal != null) ? Float.toString(cellPedestal[index]) + - " ADC counts" : "n/a"; - - cellInfo += "\n ADC 2 MeV = "; - if(adc2Mev == null) - { - cellInfo += "n/a"; - } - else - { - // subtag adc2Mev was available in the event file - if(adc2Mev[index] != -1) - { - // other than -1: the factor was available in - // Athena (database) for this particular cell - cellInfo += Float.toString(adc2Mev[index]) + " (from database)"; - } - else - { - // -1 -> the factor wasn't available in Athena (database), - // use hardcoded constant for this particular cell - cellInfo += "-1 (n/a in database)"; - // see comment at getADC2MevFactorPredefined() method - // using predefined " + - // Float.toString(getADC2MevFactorPredefined(index)); - } - } - - cellInfo += pulseShapesDataAvailable ? "" : - "\n data for real pulse shapes plot n/a"; - - return t + cellInfo; - - } // getHitInfo() ------------------------------------------------------- - - @Override //ACalorimeterData - //Gives the hit time for this cell - protected double getTime(int hit) - { - if (cellTime == null) return 0.0; - else return cellTime[hit]; - } - - private void cutEnergyByLayer(String groupName, String parameterName, - String text, float[] array, int[] sampling, int currSampling) - { - AParameter par = parameterStore.get(groupName, parameterName); - - if(par.getStatus() && array != null) - { - double value = par.getD(); - String operator = par.getOperator(); - int num = 0; - - // this special cut shall have isMod="YES" attribute set, so - // par.isModulus() is true, thus only Math.abs() values are considered - if(operator.equals("<")) - { - for(int i = 0; i < numDraw; i++) - { - if(sampling[listdl[i]] == currSampling) - { - if(Math.abs(array[listdl[i]]) < value) - { - listdl[num++] = listdl[i]; - } - } - else - { - // don't check energy for other layers and don't cut - listdl[num++] = listdl[i]; - } - } - } - else if(operator.equals(">")) - { - // '>' really means '>=' for reals since they are real in - // from ascii file and don't have full precison - for(int i = 0; i < numDraw; i++) - { - if(sampling[listdl[i]] == currSampling) - { - if(Math.abs(array[listdl[i]]) >= value) - { - listdl[num++] = listdl[i]; - } - } - else - { - // don't check energy for other layers and don't cut - listdl[num++] = listdl[i]; - } - } - } - else - { - throw new Error(operator + " operator not sensible for floats"); - } - - numDraw = num; - } - - } // cutEnergyByLayer() ------------------------------------------------- - - - - protected void applyCuts() - { - super.applyCuts(); - cut("CutsCalo", "LArET", "LArET", et); - cut("CutsCalo", "LArEnergy", "LArEnergy", energy); - - // energy cut (E) per layers - cutEnergyByLayer("CutsCalo", "LArEnergyLayer0", "LArEnergyLayer0", - energy, sampling, 0); - cutEnergyByLayer("CutsCalo", "LArEnergyLayer1", "LArEnergyLayer1", - energy, sampling, 1); - cutEnergyByLayer("CutsCalo", "LArEnergyLayer2", "LArEnergyLayer2", - energy, sampling, 2); - cutEnergyByLayer("CutsCalo", "LArEnergyLayer3", "LArEnergyLayer3", - energy, sampling, 3); - - // cut by LAr region (+- EndCap, All) - int cutSub = parameterStore.get("CutsCalo", "LAr").getI(); - if(cutSub != -1) - { - - int num = 0; - for(int i = 0; i < numDraw; i++) - { - - switch(cutSub){ - case 0: - if(side[listdl[i]] == -2 || side[listdl[i]] == -3){ - listdl[num++] = listdl[i]; - } - break; - case 1: - if(side[listdl[i]] == 2 || side[listdl[i]] == 3){ - listdl[num++] = listdl[i]; - } - break; - case 2: - if(Math.abs(side[listdl[i]]) != 1){ - listdl[num++] = listdl[i]; - } - break; - case 3: - if(Math.abs(side[listdl[i]]) == 1){ - listdl[num++] = listdl[i]; - } - break; - default: - break; - - - } - } - numDraw = num; - - } - } // applyCuts() -------------------------------------------------------- - - - /** - * Returns the name of the parameter group. - * - * @return String parameter group - */ - public String getParameterGroup() - { - return "LAr"; - } - - /** - * Returns the name of the datatype. - * - * @return String datatype - */ - public String getName() - { - return "LAr"; - } - - /** - * Returns the name of the datatype. - * - * @return String datatype - */ - public String getNameScreenName() - { - return "LAr"; - } - - /** - * Returns the type of calorimeter (ECAL/HCAL) for a hit. - * - * @param index int hit index - * @return String calorimeter type - */ - public String getCalorimeterType(int index) - { - return "ECAL"; - } - - /** - * Returns the histograms for this projection. - * - * @param projection AProjection2D current projection - * @return ACoord[] polygons representing histograms - */ - protected ACoord[] getUserHistograms(AProjection2D projection) - { - ACoord[] data = ACoord.NO_HISTOGRAMS; - int mode = parameterStore.get("YX", "Mode").getI(); - if ((projection instanceof AProjectionYX) && (mode == AProjectionYX.MODE_STANDARD || - mode == AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER || - mode == AProjectionYX.MODE_LAR_ENDCAP_1 || - mode == AProjectionYX.MODE_LAR_ENDCAP_2 || - mode == AProjectionYX.MODE_LAR_ENDCAP_3 || - mode == AProjectionYX.MODE_LAR_ENDCAP_SUMMED)) - data = getYXHistograms(); - else if (projection instanceof AProjectionFR) - data = getFRHistograms(); - else if (projection instanceof AProjectionRZ) - data = getRZHistograms(); - else if (projection instanceof AProjectionFZ) - data = getFZHistograms(); - return projection.nonLinearTransform(data); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ALVL1JetElementData.java b/graphics/AtlantisJava/src/atlantis/data/ALVL1JetElementData.java deleted file mode 100644 index a4aa50b1eaa69d4f8fbec6cb8b3355fe79f37b57..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ALVL1JetElementData.java +++ /dev/null @@ -1,446 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import java.awt.Color; - -import atlantis.canvas.AWindow; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.graphics.ADrawParameters; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionVP; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; -import atlantis.utils.APolygon; - -public class ALVL1JetElementData extends AData -{ - private float[] energy; - private float[] eta; - private float[] deta; - private float[] phi; - private float[] dphi; - - ALVL1JetElementData(AHashMap p, AEvent e) - { - super(p,e); - - phi = p.getFloatArray("phi"); - eta = p.getFloatArray("eta"); - // here energy is actually Et - energy = p.getFloatArray("energy"); - - deta = new float[numData]; - dphi = new float[numData]; - - fillGranularity(); - } - - private void fillGranularity() - { - for(int i = 0; i < numData; ++i) - { - float positiveEta = Math.abs(eta[i]); - if(positiveEta <= 2.4) - { - deta[i] = 0.1f; - dphi[i] = (float) (Math.PI / 32.); - } - else if(positiveEta <= 2.7) - { - deta[i] = 0.15f; - dphi[i] = (float) (Math.PI / 32.); - } - else if(positiveEta <= 2.9) - { - deta[i] = 0.1f; - dphi[i] = (float) (Math.PI / 32.); - } - else if(positiveEta <= 3.2) - { - deta[i] = 0.15f; - dphi[i] = (float) (Math.PI / 32.); - } - else - { - deta[i] = 0.9f; - dphi[i] = (float) (Math.PI / 16.); - } - } - } - - public double getEta(int index) - { - return eta[index]; - } - - public double getdEta(int index) - { - return deta[index]; - } - - public double getPhi(int index) - { - return phi[index]; - } - - public double getdPhi(int index) - { - return dphi[index]; - } - - public double getET(int index) - { - return energy[index]; - } - - public String getNameScreenName() - { - return "LVL1JetElement"; - } - - public String getParameterGroup() - { - return "LVL1JetElement"; - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+ - "\n E="+String.format("%.3f",energy[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (id: " + id[index] + " index: " + index + ")"); - msg.append("\n Energy = "); - msg.append(String.format("%.3f",energy[index])); - msg.append(" GeV\n "); - msg.append(AMath.ETA); - msg.append(" = "); - msg.append(String.format("%.3f",eta[index])); - msg.append("\n "); - msg.append(AMath.PHI); - msg.append(" = "); - msg.append(String.format("%.3f",phi[index])); - msg.append(AMath.DEGREES); - msg.append(" (" + String.format("%.3f",phi[index]) + " rad)"); - - return msg.toString(); - } - - protected void applyCuts() - { - cutIndex(); - cut("CutsCalo", "LVL1TriggerET", " ET", energy); - cutPhi(phi, dphi); - cutEtaDEta(eta, deta); - } - - protected int internalColor() - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - if(colorFunction == 0) - colorByConstant(); - - return 1; - } - - protected int getDrawOrFill() - { - return AGraphics.FILL; - } - - protected ACoord getYXUser() - { - makeDrawList(); - - double[][][] hv = new double[2][numDraw][4]; - int[] index = new int[numDraw]; - - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - double phiPlus = phi[list] + dphi[list]; - double phiMinus = phi[list] - dphi[list]; - double cosPlus = Math.cos(phiPlus); - double sinPlus = Math.sin(phiPlus); - double cosMinus = Math.cos(phiMinus); - double sinMinus = Math.sin(phiMinus); - - // Rho range of Calo Detector is about between [148.175, 386] - double rhoMax = 380; - double rhoMinus = 155; - - double maxEnergy = parameterStore.get("Projection", "EnergyMax").getD(); - double rhoPlus = rhoMax; - if(Math.abs(energy[list]) < maxEnergy) - rhoPlus = rhoMinus + (rhoMax - rhoMinus) * Math.abs(energy[list]) / maxEnergy; - - // 4 corners of the cell area - // x0, y0 - hv[0][i][0] = rhoMinus * cosPlus; - hv[1][i][0] = rhoMinus * sinPlus; - // x1, y1 - hv[0][i][1] = rhoPlus * cosPlus; - hv[1][i][1] = rhoPlus * sinPlus; - // x2, y2 - hv[0][i][2] = rhoPlus * cosMinus; - hv[1][i][2] = rhoPlus * sinMinus; - // x3, y3 - hv[0][i][3] = rhoMinus * cosMinus; - hv[1][i][3] = rhoMinus * sinMinus; - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYGONS); - } - - protected ACoord getFRUser() - { - ACoord coordFR = getYXUser().convertYXToFR().includePhiWrapAround("FR"); - return coordFR; - } - - protected ACoord getRZUser() - { - makeDrawList(); - double[][][] hv = new double[2][numDraw][4]; - int[] index = new int[numDraw]; - - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(phi[list]-phiMid); - double rSign; - if (phiDiff > Math.PI/2. && phiDiff <= 3*Math.PI/2.) - rSign = -1; - else - rSign = 1; - - // calculate theta based on the eta value - double theta = Math.atan(Math.exp(-Math.abs(eta[list]))) * 2.0; - double thetaPlus = Math.atan(Math.exp(-(Math.abs(eta[list]) - deta[list]))) * 2.0; - double thetaMinus = Math.atan(Math.exp(-(Math.abs(eta[list]) + deta[list]))) * 2.0; - - if ((eta[list] > 0.) && (rSign == -1)) - { - theta = 2 * Math.PI - theta; - thetaPlus = 2 * Math.PI - thetaPlus; - thetaMinus = 2 * Math.PI - thetaMinus; - } - else if ((eta[list] < 0.) && (rSign == -1)) - { - theta += Math.PI; - thetaPlus += Math.PI; - thetaMinus += Math.PI; - } - else if ((eta[list] < 0.) && (rSign == 1)) - { - theta = Math.PI - theta; - thetaPlus = Math.PI - thetaPlus; - thetaMinus = Math.PI - thetaMinus; - } - - double cosPlus = Math.cos(thetaPlus); - double sinPlus = Math.sin(thetaPlus); - double cosMinus = Math.cos(thetaMinus); - double sinMinus = Math.sin(thetaMinus); - - // decide the region based on the theta value - final byte LAR = 0; - final byte LAR_ENDCAP = 1; - final byte FCAL_EM = 2; - byte region = LAR; - // hard-coded value is based on the values in AGeometry.xml - if(Math.abs(Math.tan(theta)) >= 0.0778 && Math.abs(Math.tan(theta)) < 0.4828) - region = LAR_ENDCAP; - else if(Math.abs(Math.tan(theta)) < 0.0778) - region = FCAL_EM; - - double radiusMinus = 0.; - switch(region) - { - // use fixed rho/z to determine the lower radius value - case LAR: - radiusMinus = 155 / Math.abs(Math.sin(theta)); - break; - case LAR_ENDCAP: - radiusMinus = 380 / Math.abs(Math.cos(theta)); - break; - case FCAL_EM: - radiusMinus = 470 / Math.abs(Math.cos(theta)); - break; - } - double radiusMax = radiusMinus + 200; - double maxEnergy = parameterStore.get("Projection", "EnergyMax").getD(); - double radiusPlus = radiusMax; - if(Math.abs(energy[list]) < maxEnergy) - radiusPlus = radiusMinus + (radiusMax - radiusMinus) * Math.abs(energy[list]) / maxEnergy; - - // 4 corners of the cell area - // x0, y0 - hv[0][i][0] = radiusMinus * cosPlus; - hv[1][i][0] = radiusMinus * sinPlus; - // x1, y1 - hv[0][i][1] = radiusPlus * cosPlus; - hv[1][i][1] = radiusPlus * sinPlus; - // x2, y2 - hv[0][i][2] = radiusPlus * cosMinus; - hv[1][i][2] = radiusPlus * sinMinus; - // x3, y3 - hv[0][i][3] = radiusMinus * cosMinus; - hv[1][i][3] = radiusMinus * sinMinus; - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYGONS); - } - - protected ACoord getVPUser() - { - makeDrawList(); - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index=new int[numDraw]; - - for(int i=0; i<numDraw; i++) - { - int list=listdl[i]; - h[i]=eta[list]; - v[i]=Math.toDegrees(phi[list]); - index[i]=list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("VP"); - } - - public void draw(AWindow window, AGraphics ag, AProjection2D projection) - { - if(projection instanceof AProjectionVP) - { - ACoord centers=getUser(projection); - - int[] drawlist=centers.index; - double[] density = new double[drawlist.length]; - double maxDensity = 0.0; - double[][][] hv=new double[2][drawlist.length][4]; // cell - int[] index = new int[drawlist.length]; - ACoord geoCell; - - for(int i=0; i<drawlist.length; ++i) - { - int list=drawlist[i]; - // y coordinate of four cell corners - hv[1][i][0] = centers.hv[1][0][i] + Math.toDegrees(getdPhi(list)); - hv[1][i][1] = centers.hv[1][0][i] - Math.toDegrees(getdPhi(list)); - hv[1][i][2] = centers.hv[1][0][i] - Math.toDegrees(getdPhi(list)); - hv[1][i][3] = centers.hv[1][0][i] + Math.toDegrees(getdPhi(list)); - // x coordinate of four cell corners - hv[0][i][0] = centers.hv[0][0][i] - getdEta(list); - hv[0][i][1] = centers.hv[0][0][i] - getdEta(list); - hv[0][i][2] = centers.hv[0][0][i] + getdEta(list); - hv[0][i][3] = centers.hv[0][0][i] + getdEta(list); - - index[i] = list; - - // calculate density for all cells, and find min and max density - density[i] = Math.abs(energy[list]) / (getdPhi(list) * getdEta(list)); - if(i == 0) - maxDensity = density[i]; - else - { - if (density[i] > maxDensity) - maxDensity = density[i]; - } - } - - geoCell = window.calculateDisplay(new ACoord(hv, index, this, ACoord.POLYGONS)); - drawGeometry(geoCell, window, ag); - for (int i = 0; i < density.length; i++) - { - double factor = Math.sqrt(density[i] / maxDensity); - APolygon.scale(geoCell.hv[0][i], geoCell.hv[1][i], factor); - } - - drawHits(geoCell, window, ag); - } - else - { - super.draw(window, ag, projection); - } - } - - private void drawGeometry(ACoord display, AWindow window, AGraphics ag) - { - Color[] colorMap = AColorMap.getColors(); - boolean drawCellGeometry = parameterStore.get(getParameterGroup(), "CellGeometry").getStatus(); - boolean drawCellOutline = parameterStore.get(getParameterGroup(), "CellOutline").getStatus(); - int cellGeometryColor = parameterStore.get(getParameterGroup(), "CellGeometry").getI(); - int cellOutlineColor = parameterStore.get(getParameterGroup(), "CellOutline").getI(); - boolean drawFrame = parameterStore.get(getParameterGroup(), "Frame").getStatus(); - int frameColor = parameterStore.get(getParameterGroup(), "Frame").getI(); - int frameWidth = parameterStore.get(getParameterGroup(), "FrameWidth").getI(); - //only draw frames for Grey/BW color maps if is selected to draw frames - if(drawFrame && AColorMap.drawFrames()) - drawFrame=true; - else - drawFrame=false; - - if(!drawCellGeometry && !drawCellOutline) - return; - - // Draw geometry - for(int i=0; i<display.hv[0].length; ++i) - { - if(drawCellGeometry) - { - if(drawFrame) - { - ag.updateDrawParameters(new ADrawParameters(true, frameColor, 1, 0, frameWidth, 0)); - ag.drawPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - ag.updateDrawParameters(new ADrawParameters(true, cellGeometryColor, 1, 0, 0, 0)); - ag.fillPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - if(drawCellOutline) - { - ag.setColor(colorMap[cellOutlineColor]); - ag.drawPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - } - } - - private void drawHits(ACoord display, AWindow window, AGraphics ag) - { - int[] color = this.getColor(display.index); - - boolean drawCellGeometry = parameterStore.get(getParameterGroup(), "CellGeometry").getStatus(); - boolean drawFrame = parameterStore.get(getParameterGroup(), "Frame").getStatus(); - int frameColor = parameterStore.get(getParameterGroup(), "Frame").getI(); - int frameWidth = parameterStore.get(getParameterGroup(), "FrameWidth").getI(); - - // draw frame - if (drawFrame && !drawCellGeometry) - { - for (int i = 0; i < display.hv[0].length; i++) - { - ag.updateDrawParameters(new ADrawParameters(true, frameColor, 1, 0, frameWidth, 0)); - ag.drawPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - } - - // draw hits - for(int i=0; i<display.hv[0].length; ++i) - { - int lineWidth = parameterStore.get(getParameterGroup(), "LineWidth").getI(); - ag.updateDrawParameters(new ADrawParameters(true, color[i], 1, lineWidth, 0, 0)); - ag.fillPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ALVL1ResultData.java b/graphics/AtlantisJava/src/atlantis/data/ALVL1ResultData.java deleted file mode 100755 index db7dc97e2b1d1fe2c907aa4e87f0df8f1b634aef..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ALVL1ResultData.java +++ /dev/null @@ -1,292 +0,0 @@ -package atlantis.data; - -import atlantis.event.AData; -import atlantis.event.*; -import atlantis.utils.AHashMap; - -public class ALVL1ResultData extends AData -{ - private String[] ctpItemList; - private String[] itemListL2; - private String[] itemListEF; - private int[] ctpWord0; - private int[] ctpWord1; - private int[] ctpWord2; - private float[] energyEtMiss; - //private float[] energyEx; - //private float[] energyEy; - private float[] energySumEt; - private int[] passedL1; - private int[] passedL2; - private int[] passedEF; - private int[] passedTrigger; - private String[] prescaleListEF; - private String[] prescaleListL1; - private String[] prescaleListL2; - - ALVL1ResultData(AHashMap p, AEvent e) - { - super(p,e); - - ctpItemList = p.getStringArray("ctpItemList"); - itemListL2 = p.getStringArray("itemListL2"); - itemListEF = p.getStringArray("itemListEF"); - ctpWord0 = p.getUnknownIntArray("ctpWord0"); - ctpWord1 = p.getUnknownIntArray("ctpWord1"); - ctpWord2 = p.getUnknownIntArray("ctpWord2"); - energyEtMiss = p.getUnknownFloatArray("energyEtMiss"); - //energyEx = p.getUnknownFloatArray("energyEx"); - //energyEy = p.getUnknownFloatArray("energyEy"); - energySumEt = p.getUnknownFloatArray("energySumEt"); - passedL1 = p.getUnknownIntArray("passedL1"); - passedL2 = p.getUnknownIntArray("passedL2"); - passedEF = p.getUnknownIntArray("passedEF"); - passedTrigger = p.getUnknownIntArray("passedTrigger"); - //check for backward compatibility - prescaleListEF = (p.get("prescaleListEF") != null) ? p.getStringArray("prescaleListEF"): null; - prescaleListL1 = (p.get("prescaleListL1") != null) ? p.getStringArray("prescaleListL1"): null; - prescaleListL2 = (p.get("prescaleListL2") != null) ? p.getStringArray("prescaleListL2"): null; - } - - protected void applyCuts() - {} - - public String getHitInfo(int index) - { - return "LVL1Result"; - } - - protected int internalColor() - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - if(colorFunction == 0) - colorByConstant(); - - return 3; - } - - public String getParameterGroup() - { - return "LVL1Result"; - } - - public String getNameScreenName() - { - return "LVL1Result"; - } - - public String getCtpItemList(int index) - { - return ctpItemList[index]; - } - - /** - * Returns the individual parts of the list seperated by - - * By using cleanup removes L1 from the item - */ - public String[] getCtpItemListSplit(int index, boolean cleanUp) - { - if(ctpItemList!=null) - { - if(cleanUp) - return splitItems(ctpItemList[index], "L1"); - else - return splitItems(ctpItemList[index]); - } - else - return null; - } - - public String getitemListL2(int index) - { - return itemListL2[index]; - } - - /** - * Returns the individual parts of the list seperated by - - * By using cleanup removes L2 from the item - */ - public String[] getitemListL2Split(int index, boolean cleanUp) - { - if(itemListL2!=null) - { - if(cleanUp) - return splitItems(itemListL2[index], "L2"); - else - return splitItems(itemListL2[index]); - } - else - return null; - } - - public String getitemListEF(int index) - { - return itemListEF[index]; - } - - /** - * Returns the individual parts of the list seperated by - - * By using cleanup removes EF from the item - */ - public String[] getitemListEFSplit(int index, boolean cleanUp) - { - if(itemListEF!=null) - { - if(cleanUp) - return splitItems(itemListEF[index], "EF"); - else - return splitItems(itemListEF[index]); - } - else - return null; - } - - public int getCtpWord0(int index) - { - return ctpWord0[index]; - } - - public String getBinaryCtpWord0(int index) - { - return Integer.toBinaryString(ctpWord0[index]); - } - - public int getCtpWord1(int index) - { - return ctpWord1[index]; - } - - public int getCtpWord2(int index) - { - return ctpWord2[index]; - } - - /** - * This method is needed for backward compatibility - * New xml files store this in ATriggerInfoData - */ - public float getEnergyEtMiss(int index) - { - return energyEtMiss[index]; - } - - /*public float getEnergyEx(int index) - { - return energyEx[index]; - } - public float getEnergyEy(int index) - { - return energyEy[index]; - }*/ - - /** - * This method is needed for backward compatibility - * New xml files store this in ATriggerInfoData - */ - public float getEnergySumEt(int index) - { - return energySumEt[index]; - } - - public int getPassedL1(int index) - { - return passedL1[index]; - } - - public int getPassedL2(int index) - { - return passedL2[index]; - } - - public int getPassedEF(int index) - { - return passedEF[index]; - } - - public int getPassedTrigger(int index) - { - return passedTrigger[index]; - } - - public String getPrescaleListEF(int index) - { - return prescaleListEF[index]; - } - - /** - * Returns the individual parts of the list seperated by - - */ - public String[] getPrescaleListEFSplit(int index) - { - if(prescaleListEF!=null) - return splitItems(prescaleListEF[index]); - else - return null; - } - - public String getPrescaleListL1(int index) - { - return prescaleListL1[index]; - } - - /** - * Returns the individual parts of the list seperated by - - */ - public String[] getPrescaleListL1Split(int index) - { - if(prescaleListL1!=null) - return splitItems(prescaleListL1[index]); - else - return null; - } - - public String getPrescaleListL2(int index) - { - return prescaleListL2[index]; - } - - /** - * Returns the individual parts of the list seperated by - - */ - public String[] getPrescaleListL2Split(int index) - { - if(prescaleListL2!=null) - return splitItems(prescaleListL2[index]); - else - return null; - } - - /** - * Function that seperates an item list and carries out cleanup - */ - private String[] splitItems(String origItems, String level) - { - //string array to hold individual items - String[] newItems=splitItems(origItems); - //remove letters from start of item and duplicated names - char[] levelChar = level.toCharArray(); - for(int i=0; i<newItems.length; i++) - { - char[] newItemsChar = newItems[i].toCharArray(); - if(newItemsChar[0]==levelChar[0] && newItemsChar[1]==levelChar[1]) - { - if(newItemsChar[2]=='_') - newItems[i]=newItems[i].substring(3); - else - newItems[i]=newItems[i].substring(2); - //get rid of duplicated parts of name - char[] newItemsChar2 = newItems[i].toCharArray(); - for(int j=0; j<newItemsChar2.length-1; j++) - { - if(newItemsChar2[j]==levelChar[0] && newItemsChar2[j+1]==levelChar[1]) - { - newItems[i]=newItems[i].substring(0, j); - break; - } - } - } - } - return newItems; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ALVL1TriggerTowerData.java b/graphics/AtlantisJava/src/atlantis/data/ALVL1TriggerTowerData.java deleted file mode 100644 index 9cfef10134281a7ee7345217f497c1b4c6f6bc0c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ALVL1TriggerTowerData.java +++ /dev/null @@ -1,800 +0,0 @@ -package atlantis.data; - -import java.util.Arrays; - -import atlantis.canvas.AWindow; -import atlantis.event.AData; -import atlantis.event.AEvent; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.graphics.ADrawParameters; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.list.AListManager; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; -import atlantis.utils.APolygon; - -public class ALVL1TriggerTowerData extends AData -{ - public static final boolean ELECTROMAGNETIC = true; - public static final boolean HADRONIC = false; - - // here energy is actually Et - private float[] emEnergy; - private float[] hadEnergy; - private float[] sumEnergy; - private float[] eta; - private float[] deta_em; - private float[] deta_had; - private float[] phi; - private float[] dphi_em; - private float[] dphi_had; - private int[] numADC; - private int[][] hadADC; - private int[][] emADC; - private int[] emBCID; - private int[] hadBCID; - private int[] isEMSaturated; - private int[] isHadSaturated; - - ALVL1TriggerTowerData(AHashMap p, AEvent e) - { - super(p,e); - - phi = p.getFloatArray("phi"); - eta = p.getFloatArray("eta"); - emEnergy = p.getFloatArray("emEnergy"); - hadEnergy = p.getFloatArray("hadEnergy"); - sumEnergy = p.getFloatArray("sumEnergy"); - - deta_em = new float[numData]; - deta_had = new float[numData]; - dphi_em = new float[numData]; - dphi_had = new float[numData]; - - fillGranularity(); - - numADC = p.getIntArray("numADC"); - emADC = fillADC(p.getIntArray("emADC")); - hadADC = fillADC(p.getIntArray("hadADC")); - emBCID = p.getIntArray("emBCID"); - hadBCID = p.getIntArray("hadBCID"); - isEMSaturated = p.getIntArray("isEMSaturated"); - isHadSaturated = p.getIntArray("isHadSaturated"); - } - - private void fillGranularity() - { - for(int i = 0; i < numData; ++i) - { - float positiveEta = Math.abs(eta[i]); - if(positiveEta <= 2.4) - { - deta_em[i] = 0.05f; - dphi_em[i] = (float) (Math.PI / 64.); - deta_had[i] = 0.05f; - dphi_had[i] = (float) (Math.PI / 64.); - } - else if(positiveEta <= 2.5) - { - deta_em[i] = 0.05f; - dphi_em[i] = (float) (Math.PI / 64.); - deta_had[i] = 0.1f; - dphi_had[i] = (float) (Math.PI / 32.); - } - else if(positiveEta <= 3.0) - { - deta_em[i] = 0.1f; - dphi_em[i] = (float) (Math.PI / 32.); - deta_had[i] = 0.1f; - dphi_had[i] = (float) (Math.PI / 32.); - } - else if(positiveEta <= 3.1) - { - deta_em[i] = 0.1f; - dphi_em[i] = (float) (Math.PI / 32.); - deta_had[i] = 0.05f; - dphi_had[i] = (float) (Math.PI / 32.); - } - else if(positiveEta <= 3.2) - { - deta_em[i] = 0.05f; - dphi_em[i] = (float) (Math.PI / 32.); - deta_had[i] = 0.2f; - dphi_had[i] = (float) (Math.PI / 16.); - } - else if(positiveEta <= 4.3) - { - deta_em[i] = 0.2f; - dphi_em[i] = (float) (Math.PI / 16.); - deta_had[i] = 0.2f; - dphi_had[i] = (float) (Math.PI / 16.); - } - else if(positiveEta <= 4.4) - { - deta_em[i] = 0.2f; - dphi_em[i] = (float) (Math.PI / 16.); - deta_had[i] = 0.35f; - dphi_had[i] = (float) (Math.PI / 16.); - } - else - { - deta_em[i] = 0.3f; - dphi_em[i] = (float) (Math.PI / 16.); - deta_had[i] = 0.35f; - dphi_had[i] = (float) (Math.PI / 16.); - } - } - } - - public int[][] fillADC(int[] tempADC) - { - int[][] ADC=null; - if(tempADC!=null) - { - ADC= new int[numADC.length][0]; - int num=0; - for(int i=0; i<numADC.length; i++) - { - // multiple numbers are associated with each cell - ADC[i]=new int[numADC[i]]; - for(int j=0; j<numADC[i]; j++) - { - ADC[i][j]=tempADC[num]; // fill in array for each cell - num++; - } - } - } // if(ADC != null) - return ADC; - } - - public void plotPulseShapes(int index) - { - if(emADC!=null && hadADC!=null) - { - //int[][] data={hadADC[index],emADC[index]}; - String[] labels={"EM trigger ADC counts","HAD trigger ADC counts","Sum trigger ADC counts"}; - int[] sumADC= new int[emADC[index].length]; - String[] axis= new String[3]; - String[] colors = new String[3]; - //EM plot - if(isEMSaturated[index]==0) - colors[0]="blue"; - else - colors[0]="red"; - axis[0]="index (BCID="+emBCID[index]+")"; - //HAD plot - if(isHadSaturated[index]==0) - colors[1]="blue"; - else - colors[0]="red"; - axis[1]="index (BCID="+hadBCID[index]+")"; - //Sum plot - colors[2]="blue"; - axis[2]="index"; - for(int i=0; i<emADC[index].length; i++) - { - sumADC[i]=emADC[index][i]+hadADC[index][i]; - } - int[][] data={emADC[index],hadADC[index],sumADC}; - String title="LVL1TriggerTower " + id[index] + " ADC counts"; - APulseShapePlot.plotADCCounts(data, title, axis, labels, colors); - } - else - { - if(emADC!=null) - { - int[][] data={emADC[index]}; - String[] axis={"index"}; - APulseShapePlot.plotADCCounts(data, "EM trigger ADC counts", axis); - } - if(hadADC!=null) - { - int[][] data={hadADC[index]}; - String[] axis={"index"}; - APulseShapePlot.plotADCCounts(data, "HAD trigger ADC counts", axis); - } - } - } - - public double getEta(int index) - { - return eta[index]; - } - - public double getdEta(int index, boolean emOrHad) - { - if(emOrHad == ELECTROMAGNETIC) - return deta_em[index]; - else - return deta_had[index]; - } - - public double getPhi(int index) - { - return phi[index]; - } - - public double getdPhi(int index, boolean emOrHad) - { - if(emOrHad == ELECTROMAGNETIC) - return dphi_em[index]; - else - return dphi_had[index]; - } - - public double getET(int index, boolean emOrHad) - { - if(emOrHad == ELECTROMAGNETIC) - return emEnergy[index]; - else - return hadEnergy[index]; - } - - public double getSumET(int index) - { - return sumEnergy[index]; - } - - public String getNameScreenName() - { - return "LVL1TriggerTower"; - } - - public String getParameterGroup() - { - return "LVL1TriggerTower"; - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+ - "\n E="+String.format("%.3f",sumEnergy[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (id: " + id[index] + " index: " + index + ")"); - msg.append("\n EM Energy = "); - msg.append(String.format("%.3f",emEnergy[index])); - msg.append(" GeV\n Had Energy = "); - msg.append(String.format("%.3f",hadEnergy[index])); - msg.append(" GeV\n Sum Energy = "); - msg.append(String.format("%.3f",sumEnergy[index])); - msg.append(" GeV\n "); - msg.append(AMath.ETA); - msg.append(" = "); - msg.append(String.format("%.3f",eta[index])); - msg.append("\n "); - msg.append(AMath.PHI); - msg.append(" = "); - msg.append(String.format("%.3f",Math.toDegrees(phi[index]))); - msg.append(AMath.DEGREES); - msg.append(" (" + String.format("%.3f",phi[index]) + " rad)"); - - return msg.toString(); - } - - protected void applyCuts() - { - cutIndex(); - cut("CutsCalo", "LVL1TriggerET", " ET", sumEnergy); - } - - public void applyEMCuts() - { - cutPhi(phi, dphi_em); - cutEtaDEta(eta, deta_em); - } - - public void applyHadCuts() - { - cutPhi(phi, dphi_had); - cutEtaDEta(eta, deta_had); - } - - public byte[] getColor(boolean emOrHad) - { - internalColor(emOrHad); - coloring(); - byte[] temp = new byte[id.length]; - for(int i = 0; i < temp.length; i++) - temp[i] = color[getIndexFromId(id[i])]; - return temp; - } - - /* - * Returns the colours of the trigger tower cells - * If this method is used then internalColor(boolean emOrHad) - * must be called first elsewhere - */ - public int[] getColor(int[] dl) - { - coloring(); - int[] temp = new int[dl.length]; - - for(int i = 0; i < temp.length; i++) - temp[i] = color[dl[i]]; - return temp; - } - - /* - * Colour the cells if in lists or picked - * If this method is used then internalColor(boolean emOrHad) - * must be called first elsewhere - */ - public void coloring() - { - int[][] temp = AListManager.getInstance().getColorMapping(this); - int[] index = temp[0]; - int[] c = temp[1]; - // now add in colours specified in lists - - for(int i = 0; i < index.length; ++i) - if(c[i] >= 0) - color[index[i]] = (byte) c[i]; - int others = AListManager.getInstance().getColorOfOthers(); - // need to check if this data could have been picked - // so that colouring of hits by STr works even if STr - // is not in list because it wasn't on.... - if(others >= 0 && parameterStore.get("Data", getName()).getStatus()) - { - boolean[] inList = new boolean[numData]; - for(int i = 0; i < index.length; ++i) - inList[index[i]] = true; - - for(int i = 0; i < numData; ++i) - if(!inList[i]) - color[i] = (byte) others; - } - } - - protected int internalColor() - { - colorByConstant(); - return 1; - } - - protected int internalColor(boolean emOrHad) - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - if(colorFunction == 0) - colorByConstant(); - else if(colorFunction ==1) - { - if(emOrHad == ELECTROMAGNETIC) - Arrays.fill(color, (byte) (parameterStore.get("Det", "ECALFill").getI() + 12)); - else - Arrays.fill(color, (byte) (parameterStore.get("Det", "HCALFill").getI() + 12)); - } - return 1; - } - - protected int getDrawOrFill() - { - return AGraphics.FILL; - } - - private void drawVP(AWindow window, AGraphics ag, boolean emOrHad) - { - ACoord centers = getVPUser(emOrHad); - - if(centers == null) - return; - - int[] drawlist = centers.index; - double[] density = new double[drawlist.length]; - double[] sumDensity = new double[drawlist.length]; - double maxDensity = 0.0; - double[][][] hv = new double[2][drawlist.length][4]; // cell - int[] index = new int[drawlist.length]; - ACoord geoCell; - - for(int i=0; i<drawlist.length; ++i) - { - int list = drawlist[i]; - // y coordinate of four cell corners - hv[1][i][0] = centers.hv[1][0][i] + Math.toDegrees(getdPhi(list, emOrHad)); - hv[1][i][1] = centers.hv[1][0][i] - Math.toDegrees(getdPhi(list, emOrHad)); - hv[1][i][2] = centers.hv[1][0][i] - Math.toDegrees(getdPhi(list, emOrHad)); - hv[1][i][3] = centers.hv[1][0][i] + Math.toDegrees(getdPhi(list, emOrHad)); - // x coordinate of four cell corners - hv[0][i][0] = centers.hv[0][0][i] - getdEta(list, emOrHad); - hv[0][i][1] = centers.hv[0][0][i] - getdEta(list, emOrHad); - hv[0][i][2] = centers.hv[0][0][i] + getdEta(list, emOrHad); - hv[0][i][3] = centers.hv[0][0][i] + getdEta(list, emOrHad); - - index[i] = list; - - // calculate density for all cells, and find min and max density - density[i] = Math.abs(getET(list, emOrHad)) / (getdPhi(list, emOrHad) * getdEta(list, emOrHad)); - sumDensity[i] = Math.abs(getSumET(list)) / (getdPhi(list, emOrHad) * getdEta(list, emOrHad)); - if(i == 0) - maxDensity = sumDensity[i]; - else - { - if (sumDensity[i] > maxDensity) - maxDensity = sumDensity[i]; - } - } - - geoCell = window.calculateDisplay(new ACoord(hv, index, this, ACoord.POLYGONS)); - drawGeometry(geoCell, window, ag, density); - for (int i = 0; i < density.length; i++) - { - double factor = Math.sqrt(density[i] / maxDensity); - APolygon.scale(geoCell.hv[0][i], geoCell.hv[1][i], factor); - } - - drawHits(geoCell, window, ag, density); - } - - public void draw(AWindow window, AGraphics ag, AProjection2D projection) - { - int energyType = parameterStore.get(PARAMETER_GROUP, "EnergyType").getI(); - if(projection instanceof AProjectionYX) - { - if(energyType == 0 || energyType == 2) - { - internalColor(ELECTROMAGNETIC); - ag.draw(window.calculateDisplay(projection.nonLinearTransform(getYXUser(ELECTROMAGNETIC)))); - } - if(energyType == 1 || energyType == 2) - { - internalColor(HADRONIC); - ag.draw(window.calculateDisplay(projection.nonLinearTransform(getYXUser(HADRONIC)))); - } - } - else if(projection instanceof AProjectionFR) - { - if(energyType == 0 || energyType == 2) - { - internalColor(ELECTROMAGNETIC); - ag.draw(window.calculateDisplay(projection.nonLinearTransform(getFRUser(ELECTROMAGNETIC)))); - } - if(energyType == 1 || energyType == 2) - { - internalColor(HADRONIC); - ag.draw(window.calculateDisplay(projection.nonLinearTransform(getFRUser(HADRONIC)))); - } - } - else if(projection instanceof AProjectionRZ) - { - if(energyType == 0 || energyType == 2) - { - internalColor(ELECTROMAGNETIC); - ag.draw(window.calculateDisplay(projection.nonLinearTransform(getRZUser(ELECTROMAGNETIC)))); - } - if(energyType == 1 || energyType == 2) - { - internalColor(HADRONIC); - ag.draw(window.calculateDisplay(projection.nonLinearTransform(getRZUser(HADRONIC)))); - } - } - else if(projection instanceof AProjectionVP) - { - if(energyType == 0 || energyType == 2) - { - internalColor(ELECTROMAGNETIC); - drawVP(window, ag, ELECTROMAGNETIC); - } - if(energyType == 1 || energyType == 2) - { - internalColor(HADRONIC); - drawVP(window, ag, HADRONIC); - } - } - else - { - super.draw(window, ag, projection); - } - } - - private ACoord getYXUser(boolean emOrHad) - { - makeDrawList(); - if(emOrHad == ELECTROMAGNETIC) - applyEMCuts(); - else - applyHadCuts(); - - double[][][] hv = new double[2][numDraw][4]; - int[] index = new int[numDraw]; - - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - double et = getET(list, emOrHad); - if(et == 0.0) - continue; - double dphi = getdPhi(list, emOrHad); - double phiPlus = phi[list] + dphi; - double phiMinus = phi[list] - dphi; - double cosPlus = Math.cos(phiPlus); - double sinPlus = Math.sin(phiPlus); - double cosMinus = Math.cos(phiMinus); - double sinMinus = Math.sin(phiMinus); - - double rhoMax; - double rhoMinus; - - if(emOrHad == ELECTROMAGNETIC) - { - // Rho range of LAr Detector (EM) is about between [148.175, 198.47] - rhoMax = 195; - rhoMinus = 155; - } - else - { - // Rho range of TILE Detector (Had) is about between [229, 386] - rhoMax = 380; - rhoMinus = 235; - } - double maxEnergy = parameterStore.get("Projection", "EnergyMax").getD(); - double rhoPlus = rhoMax; - if(Math.abs(et) < maxEnergy) - rhoPlus = rhoMinus + (rhoMax - rhoMinus) * Math.abs(et) / maxEnergy; - - // 4 corners of the cell area - // x0, y0 - hv[0][i][0] = rhoMinus * cosPlus; - hv[1][i][0] = rhoMinus * sinPlus; - // x1, y1 - hv[0][i][1] = rhoPlus * cosPlus; - hv[1][i][1] = rhoPlus * sinPlus; - // x2, y2 - hv[0][i][2] = rhoPlus * cosMinus; - hv[1][i][2] = rhoPlus * sinMinus; - // x3, y3 - hv[0][i][3] = rhoMinus * cosMinus; - hv[1][i][3] = rhoMinus * sinMinus; - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYGONS); - } - - protected ACoord getFRUser(boolean emOrHad) - { - ACoord coordFR = getYXUser(emOrHad).convertYXToFR().includePhiWrapAround("FR"); - return coordFR; - } - - protected ACoord getRZUser(boolean emOrHad) - { - makeDrawList(); - if(emOrHad == ELECTROMAGNETIC) - applyEMCuts(); - else - applyHadCuts(); - - double[][][] hv = new double[2][numDraw][4]; - int[] index = new int[numDraw]; - - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - double et = getET(list, emOrHad); - if(et == 0.0) - continue; - - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(phi[list]-phiMid); - double rSign; - if (phiDiff > Math.PI/2. && phiDiff <= 3*Math.PI/2.) - rSign = -1; - else - rSign = 1; - - // calculate theta based on the eta value - double theta = Math.atan(Math.exp(-Math.abs(eta[list]))) * 2.0; - double deta = getdEta(list, emOrHad); - double thetaPlus = Math.atan(Math.exp(-(Math.abs(eta[list]) - deta))) * 2.0; - double thetaMinus = Math.atan(Math.exp(-(Math.abs(eta[list]) + deta))) * 2.0; - - if ((eta[list] > 0.) && (rSign == -1)) - { - theta = 2 * Math.PI - theta; - thetaPlus = 2 * Math.PI - thetaPlus; - thetaMinus = 2 * Math.PI - thetaMinus; - } - else if ((eta[list] < 0.) && (rSign == -1)) - { - theta += Math.PI; - thetaPlus += Math.PI; - thetaMinus += Math.PI; - } - else if ((eta[list] < 0.) && (rSign == 1)) - { - theta = Math.PI - theta; - thetaPlus = Math.PI - thetaPlus; - thetaMinus = Math.PI - thetaMinus; - } - - double cosPlus = Math.cos(thetaPlus); - double sinPlus = Math.sin(thetaPlus); - double cosMinus = Math.cos(thetaMinus); - double sinMinus = Math.sin(thetaMinus); - - // decide the region based on the theta value - final byte LAR = 0; - final byte LAR_ENDCAP = 1; - final byte FCAL_EM = 2; - byte region = LAR; - // hard-coded value is based on the values in AGeometry.xml - if(Math.abs(Math.tan(theta)) >= 0.0778 && Math.abs(Math.tan(theta)) < 0.4828) - region = LAR_ENDCAP; - else if(Math.abs(Math.tan(theta)) < 0.0778) - region = FCAL_EM; - - double radiusMinus = 0.; - double radiusMax = 0.; - switch(region) - { - // use fixed rho/z to determine the lower radius value - case LAR: - if(emOrHad == ELECTROMAGNETIC) - { - radiusMax = 195 / Math.abs(Math.sin(theta)); - radiusMinus = 155 / Math.abs(Math.sin(theta)); - } - else - { - radiusMax = 380 / Math.abs(Math.sin(theta)); - radiusMinus = 235 / Math.abs(Math.sin(theta)); - } - break; - case LAR_ENDCAP: - if(emOrHad == ELECTROMAGNETIC) - { - radiusMax = 420 / Math.abs(Math.cos(theta)); - radiusMinus = 380 / Math.abs(Math.cos(theta)); - } - else - { - radiusMax = 585 / Math.abs(Math.cos(theta)); - radiusMinus = 440 / Math.abs(Math.cos(theta)); - } - break; - case FCAL_EM: - if(emOrHad == ELECTROMAGNETIC) - { - radiusMax = 510 / Math.abs(Math.cos(theta)); - radiusMinus = 470 / Math.abs(Math.cos(theta)); - } - else - { - radiusMax = 600 / Math.abs(Math.cos(theta)); - radiusMinus = 520 / Math.abs(Math.cos(theta)); - } - break; - } - - double maxEnergy = parameterStore.get("Projection", "EnergyMax").getD(); - double radiusPlus = radiusMax; - if(Math.abs(et) < maxEnergy) - radiusPlus = radiusMinus + (radiusMax - radiusMinus) * Math.abs(et) / maxEnergy; - - // 4 corners of the cell area - // x0, y0 - hv[0][i][0] = radiusMinus * cosPlus; - hv[1][i][0] = radiusMinus * sinPlus; - // x1, y1 - hv[0][i][1] = radiusPlus * cosPlus; - hv[1][i][1] = radiusPlus * sinPlus; - // x2, y2 - hv[0][i][2] = radiusPlus * cosMinus; - hv[1][i][2] = radiusPlus * sinMinus; - // x3, y3 - hv[0][i][3] = radiusMinus * cosMinus; - hv[1][i][3] = radiusMinus * sinMinus; - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYGONS); - } - - protected ACoord getVPUser(boolean emOrHad) - { - makeDrawList(); - if(emOrHad == ELECTROMAGNETIC) - applyEMCuts(); - else - applyHadCuts(); - - if(numDraw == 0) - return null; - - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index=new int[numDraw]; - - for(int i=0; i<numDraw; i++) - { - int list=listdl[i]; - h[i]=eta[list]; - v[i]=Math.toDegrees(phi[list]); - index[i]=list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("VP"); - } - - private void drawGeometry(ACoord display, AWindow window, AGraphics ag, double[] density) - { - boolean drawCellGeometry = parameterStore.get(getParameterGroup(), "CellGeometry").getStatus(); - boolean drawCellOutline = parameterStore.get(getParameterGroup(), "CellOutline").getStatus(); - int cellGeometryColor = parameterStore.get(getParameterGroup(), "CellGeometry").getI(); - int cellOutlineColor = parameterStore.get(getParameterGroup(), "CellOutline").getI(); - boolean drawFrame = parameterStore.get(getParameterGroup(), "Frame").getStatus(); - int frameColor = parameterStore.get(getParameterGroup(), "Frame").getI(); - int frameWidth = parameterStore.get(getParameterGroup(), "FrameWidth").getI(); - //only draw frames for Grey/BW color maps if is selected to draw frames - if(drawFrame && AColorMap.drawFrames()) - drawFrame = true; - else - drawFrame = false; - - if(!drawCellGeometry && !drawCellOutline) - return; - - // Draw geometry - for(int i=0; i<display.hv[0].length; ++i) - { - if(density[i] == 0.0) - continue; - - if(drawCellGeometry) - { - if(drawFrame) - { - ag.updateDrawParameters(new ADrawParameters(true, frameColor, 1, 0, frameWidth, 0)); - ag.drawPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - ag.updateDrawParameters(new ADrawParameters(true, cellGeometryColor, 1, 0, 0, 0)); - ag.fillPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - if(drawCellOutline) - { - ag.updateDrawParameters(new ADrawParameters(true, cellOutlineColor, 0, 1, 0, 0, false, 1, 0)); - ag.drawPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - } - } - - private void drawHits(ACoord display, AWindow window, AGraphics ag, double[] density) - { - int[] color = this.getColor(display.index); - - boolean drawCellGeometry = parameterStore.get(getParameterGroup(), "CellGeometry").getStatus(); - boolean drawFrame = parameterStore.get(getParameterGroup(), "Frame").getStatus(); - int frameColor = parameterStore.get(getParameterGroup(), "Frame").getI(); - int frameWidth = parameterStore.get(getParameterGroup(), "FrameWidth").getI(); - int lineWidth = parameterStore.get(getParameterGroup(), "LineWidth").getI(); - - for(int i=0; i<display.hv[0].length; ++i) - { - if(density[i] == 0.0) - continue; - - // draw frame - if (drawFrame && !drawCellGeometry) - { - ag.updateDrawParameters(new ADrawParameters(true, frameColor, 1, 0, frameWidth, 0)); - ag.drawPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - } - - // draw hits - ag.updateDrawParameters(new ADrawParameters(true, color[i], 1, lineWidth, 0, 0)); - ag.setCurrentDataAndIndex(this, display.index[i]); - ag.fillPolygon(display.hv[0][i], display.hv[1][i], display.hv[0][i].length); - ag.clearCurrentDataAndIndex(); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ALegoData.java b/graphics/AtlantisJava/src/atlantis/data/ALegoData.java deleted file mode 100755 index 9c2593e53eda8073c9157b2fbdd3d3ae64f7ed89..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ALegoData.java +++ /dev/null @@ -1,1042 +0,0 @@ -package atlantis.data; - -import atlantis.event.AData; -import atlantis.event.*; -import java.awt.Color; -import java.awt.geom.Point2D; - -import java.util.Iterator; -import java.util.List; -import java.util.Stack; - -import atlantis.canvas.AWindow; -import atlantis.graphics.AGraphics; -import atlantis.graphics.ALegoDraw; -import atlantis.parameters.APar; -import atlantis.projection.AProjectionLegoPlot; -import atlantis.utils.ALogger; -import atlantis.utils.AMath; - -public class ALegoData -{ - private static ALogger logger = ALogger.getLogger(ALegoData.class); - - private static APar parameterStore = APar.instance(); - - /** - * This function loops over the cell data to find the maxEt. - * It also rescales the height of the cells if different scales are selected - * @param lego the tower heights - * @return maxEt the heighest tower height - */ - public static double findMaxEt(double[][][] lego) - { - double maxEt = 0.0; - double[][] legosum = new double[lego.length][lego[0].length]; - //find colors to loop over - int largestColourIndex=0; - int lowestColourIndex=AProjectionLegoPlot.nLayers; - Iterator colorIterator = AProjectionLegoPlot.colorset.iterator(); - while(colorIterator.hasNext()) - { - int currentColor = ((Integer) colorIterator.next()).intValue(); - if(currentColor>largestColourIndex) - largestColourIndex=currentColor; - if(currentColor<lowestColourIndex) - lowestColourIndex=currentColor; - } - for (int x = AProjectionLegoPlot.nPhiCells - 1; x >= 0; --x) - { - for (int y = 0; y < AProjectionLegoPlot.nEtaCells; ++y) - { - for(int z=largestColourIndex; z>=lowestColourIndex; z--) - { - legosum[x][y] += lego[x][y][z]; - } - if(legosum[x][y] > maxEt) - maxEt = legosum[x][y]; - } - } - if(maxEt>0) - { - if (AProjectionLegoPlot.defaultScale ==1 ) - { - for (int x = AProjectionLegoPlot.nPhiCells - 1; x >= 0; --x) - { - for (int y = 0; y < AProjectionLegoPlot.nEtaCells; ++y) - { - for(int z=largestColourIndex; z>=lowestColourIndex; z--) - { - if(Math.log10(legosum[x][y])>=AProjectionLegoPlot.minimumofLogScale) - { - //if multiple colors then each take linear amount of full log - double fraction=(lego[x][y][z]/legosum[x][y]); - lego[x][y][z]=fraction*(Math.log10(legosum[x][y])-AProjectionLegoPlot.minimumofLogScale); - } - else - { - //if not above minimum of log scale then don't draw - lego[x][y][z]=0.0; - } - } - } - } - } - else if (AProjectionLegoPlot.defaultScale ==2 ) - { - for (int x = AProjectionLegoPlot.nPhiCells - 1; x >= 0; --x) - { - for (int y = 0; y < AProjectionLegoPlot.nEtaCells; ++y) - { - for(int z=largestColourIndex; z>=lowestColourIndex; z--) - { - //if multiple colors then each take linear amount of full sqrt - double fraction=(lego[x][y][z]/legosum[x][y]); - lego[x][y][z]=fraction*Math.sqrt(legosum[x][y]); - } - } - } - } - } - return maxEt; - } - - public static double findAODMaxEt(AEvent event) - { - double AODmaxEt = 0.0; - //From the caloCluster - String[] colCluster=event.getActiveCollectionNames("Cluster"); - for(int i=0;i<colCluster.length;i++) - { - AClusterData cluster = (AClusterData) event.get(colCluster[i]); - if (!parameterStore.get("Data", "Cluster").getStatus()) - cluster = null; - if (cluster != null) - { - cluster.makeDrawList(); - for (int m = 0; m < cluster.getNumDraw(); ++m) - { - int list = cluster.getDrawIndex(m); - float et = Math.abs(cluster.getET(list)); - if (et > AODmaxEt) - AODmaxEt = et; - } - } - } - //From the Jets - Added code to make th e jet considered in the AOD scaling - String[] colJet=event.getActiveCollectionNames("Jet"); - for(int i=0;i<colJet.length;i++) - { - AJetData jets = (AJetData) event.get(colJet[i]); - if (!parameterStore.get("Data", "Jet").getStatus()) - jets = null; - if (jets != null) - { - jets.makeDrawList(); - for (int m = 0; m < jets.getNumDraw(); ++m) - { - int list = jets.getDrawIndex(m); - float pt = Math.abs(jets.getPt()[list]); - if (pt > AODmaxEt) - AODmaxEt = pt; - } - } - } - // From the muons - String[] colMuon=event.getActiveCollectionNames("Muon"); - for(int i=0;i<colMuon.length;i++) - { - AMuonData muons = (AMuonData) event.get(colMuon[i]); - if (!parameterStore.get("Data", "Muon").getStatus()) - muons = null; - if (muons != null) - { - muons.makeDrawList(); - for (int m = 0; m < muons.getNumDraw(); ++m) - { - int list = muons.getDrawIndex(m); - float pt = Math.abs(muons.getPT(list)); - if (pt > AODmaxEt) - AODmaxEt = pt; - } - } - } - // From the electrons - String[] colElectron=event.getActiveCollectionNames("Electron"); - for(int i=0;i<colElectron.length;i++) - { - AElectronData electrons = (AElectronData) event.get(colElectron[i]); - if (!parameterStore.get("Data", "Electron").getStatus()) - electrons = null; - if (electrons != null) - { - - electrons.makeDrawList(); - for (int e = 0; e < electrons.getNumDraw(); ++e) - { - int list = electrons.getDrawIndex(e); - float pt = Math.abs(electrons.getPT(list)); - if (pt > AODmaxEt) - AODmaxEt = pt; - } - } - } - // From the photons - String[] colPhoton=event.getActiveCollectionNames("Photon"); - for(int i=0;i<colPhoton.length;i++) - { - APhotonData photons = (APhotonData) event.get(colPhoton[i]); - if (!parameterStore.get("Data", "Photon").getStatus()) - photons = null; - if (photons != null) - { - photons.makeDrawList(); - for (int p = 0; p < photons.getNumDraw(); ++p) - { - int list = photons.getDrawIndex(p); - float pt = Math.abs(photons.getPT(list)); - if (pt > AODmaxEt) - AODmaxEt = pt; - } - } - } - //From the compositeParticles - String[] colCompPart=event.getActiveCollectionNames("CompositeParticle"); - for(int i=0;i<colCompPart.length;i++) - { - ACompositeParticleData compositeParticles = (ACompositeParticleData) event.get(colCompPart[i]); - if (!parameterStore.get("Data", "CompositeParticle").getStatus()) - compositeParticles = null; - if (compositeParticles != null) - { - compositeParticles.makeDrawList(); - for (int e = 0; e < compositeParticles.getNumDraw(); ++e) - { - int list = compositeParticles.getDrawIndex(e); - float pt = Math.abs(compositeParticles.getPT(list)); - if (pt > AODmaxEt) - AODmaxEt = pt; - } - } - } - - return AODmaxEt; - } - - public static double findMissingEt(AWindow window, double[][][] lego, AEvent event) - { - double met = 0.; - List hitsAndTracks = event.getHitsAndTracks(window.getProjection()); - for (int h = 0; h < hitsAndTracks.size(); h++) - { - AData datatype = ((AData) hitsAndTracks.get(h)); - if (datatype.getName().equals("ETMis")) - { - AETMisData mis = (AETMisData) datatype; - mis.makeDrawList(); - if (mis.getNumDraw() > 0) - { - double temp = Math.sqrt(mis.getETx() * mis.getETx() + mis.getETy() * mis.getETy()); - if(temp>met) - met=temp; - } - } - } - return met; - } - - public static void fillHistograms(AEvent event, double[][][] lego) - { - AProjectionLegoPlot.colorset.clear(); - if (AProjectionLegoPlot.mode == 0) - { - // Calorimeter Lego - fillCaloLego(event, lego); - } - else if (AProjectionLegoPlot.mode == 1) - { - // Trigger Tower Lego - fillTriggerTowerLego(event, lego); - } - else - { - // Jet Elements Lego - fillJetElementLego(event, lego); - } - } - - private static void fillCaloLego(AEvent event, double[][][] lego) - { - List detectors = event.getCalorimeters(); - for (int det = 0; det < detectors.size(); det++) - { - ACalorimeterData calorimeter = (ACalorimeterData) detectors.get(det); - String calname=calorimeter.getName(); - if (!calname.equals("TILE") && !calname.equals("FCAL") - && !calname.equals("HEC") && !calname.equals("LAr") - && !calname.equals("MBTS")) - { - logger.warn("Unknown calorimeter name for LegoPlot: " + calorimeter.getName()); - } - - calorimeter.makeDrawList(); - // for coloring - byte[] c = calorimeter.getColor(); - for (int i = 0; i < calorimeter.getNumDraw(); ++i) - { - int list = calorimeter.getDrawIndex(i); - double et = calorimeter.getET(list); - //MBTS energy is in MeV not GeV - if(calname.equals("MBTS")) et/=1000.; - double phi = calorimeter.getPhi(list); - double eta = calorimeter.getEta(list); - if (eta > 5 || eta < -5 || et == 0.0) - continue; - double dphi = calorimeter.getdPhi(list); - double deta = calorimeter.getdEta(list); - phietabinsLoop("calo", phi, dphi, eta, deta, c[list], et, lego); - }// loop over that calorimeter's cells - }// loop over the calorimeters - } - - private static void fillTriggerTowerLego(AEvent event, double[][][] lego) - { - //will draw even if data status is off - String[] colTT=event.getCollectionNames("LVL1TriggerTower"); - for(int k=0;k<colTT.length;k++) - { - ALVL1TriggerTowerData lvl1TriggerTower = (ALVL1TriggerTowerData) event.get(colTT[k]); - if (lvl1TriggerTower == null) - continue; - - byte[] ttColor; - for (int j = 0; j < 2; ++j) - { - int energyType = parameterStore.get(lvl1TriggerTower.getParameterGroup(), "EnergyType").getI(); - if((j == 0 && energyType == 1) || (j == 1 && energyType == 0)) - continue; - lvl1TriggerTower.makeDrawList(); - - boolean emOrHad; - if (j == 0) - { - emOrHad = ALVL1TriggerTowerData.ELECTROMAGNETIC; - lvl1TriggerTower.applyEMCuts(); - } - else - { - emOrHad = ALVL1TriggerTowerData.HADRONIC; - lvl1TriggerTower.applyHadCuts(); - } - ttColor = lvl1TriggerTower.getColor(emOrHad); - for (int i = 0; i < lvl1TriggerTower.getNumDraw(); ++i) - { - int list = lvl1TriggerTower.getDrawIndex(i); - double et = lvl1TriggerTower.getET(list, emOrHad); - double phi = lvl1TriggerTower.getPhi(list); - double eta = lvl1TriggerTower.getEta(list); - if (eta > 5 || eta < -5 || et == 0.0) - continue; - double dphi = lvl1TriggerTower.getdPhi(list, emOrHad); - double deta = lvl1TriggerTower.getdEta(list, emOrHad); - phietabinsLoop("trigger", phi, dphi, eta, deta, ttColor[list], et, lego); - }// loop over that triggerTower's cells - } - } - } - - private static void fillJetElementLego(AEvent event, double[][][] lego) - { - //will draw even if data status is off - String[] colJE=event.getCollectionNames("LVL1JetElement"); - for(int k=0;k<colJE.length;k++) - { - ALVL1JetElementData lvl1JetElement = (ALVL1JetElementData) event.get(colJE[k]); - if (lvl1JetElement == null) - continue; - byte[] jeColor = lvl1JetElement.getColor(); - lvl1JetElement.makeDrawList(); - for (int i = 0; i < lvl1JetElement.getNumDraw(); ++i) - { - int list = lvl1JetElement.getDrawIndex(i); - double et = lvl1JetElement.getET(list); - double phi = lvl1JetElement.getPhi(list); - double eta = lvl1JetElement.getEta(list); - if (eta > 5 || eta < -5 || et == 0.0) - continue; - double dphi = lvl1JetElement.getdPhi(list); - double deta = lvl1JetElement.getdEta(list); - phietabinsLoop("jetElement", phi, dphi, eta, deta, jeColor[list], et, lego); - }// loop over that jetElement's cells - } - } - - /** - * Is used to loop over the phi and eta bins to fill the lego "sender" - * histogram - * - * @param sender name of histogram that was sent for output message - * @param phi - * @param dphi - * @param eta - * @param deta - * @param color - * @param et - * @param lego - */ - private static void phietabinsLoop(String sender, double phi, double dphi, double eta, double deta, byte color, double et, double[][][] lego) - { - if (color >= AProjectionLegoPlot.nLayers) - color = (byte) (color % AProjectionLegoPlot.nLayers); - AProjectionLegoPlot.colorset.add(new Integer(color)); - - int highphibin = 0, lowphibin = 0; - - double phibinsize = (AMath.TWO_PI / AProjectionLegoPlot.nPhiCells); - highphibin = (int) ((phi + dphi) /phibinsize); - lowphibin = (int) ((phi - dphi) /phibinsize); - - int highetabin = 0, lowetabin = 0; - double etabinsize = 10.0 / AProjectionLegoPlot.nEtaCells; - highetabin = (int) ((eta + deta + 5.0) /etabinsize); - lowetabin = (int) ((eta - deta + 5.0) /etabinsize); - //check eta values - if (lowetabin < 0) - { - lowetabin=0; - if (highetabin < 0) - highetabin=0; - } - if (highetabin >= AProjectionLegoPlot.nEtaCells) - { - highetabin =AProjectionLegoPlot.nEtaCells-1; - if (lowetabin >= AProjectionLegoPlot.nEtaCells) - lowetabin =AProjectionLegoPlot.nEtaCells-1; - } - - for (int phibin = lowphibin; phibin <= highphibin; ++phibin) - { - double phiweight = 0; - if (lowphibin == highphibin) - phiweight = 1.0; - else if (phibin == lowphibin) - phiweight = (lowphibin + 1 - ((phi - dphi) / phibinsize)) * (phibinsize/(2 * dphi)); - else if (phibin == highphibin) - phiweight = (((phi + dphi) / phibinsize) - highphibin) * (phibinsize/(2 * dphi)); - else - phiweight = phibinsize/(2 * dphi); - if (phiweight > 1 || phiweight < 0) - { - logger.error("huh(" + sender + ")? how is phiweight...? " + phiweight); - } - - for (int etabin = lowetabin; etabin <= highetabin; ++etabin) - { - double etaweight = 0; - if (lowetabin == highetabin) - etaweight = 1.0; - else if (etabin == lowetabin) - etaweight = (lowetabin + 1 - ((eta - deta + 5.0) / etabinsize)) * (etabinsize/(2 * deta)); - else if (etabin == highetabin) - etaweight = (((eta + deta + 5.0) / etabinsize) - highetabin) * (etabinsize/(2 * deta)); - else - etaweight = etabinsize/(2 * deta); - if (etaweight > 1 || etaweight < 0) - { - logger.error("huh(" + sender + ")? how is etaweight...? " + etaweight); - } - - int wphibin = phibin;// for phi wrapping - while (wphibin >= AProjectionLegoPlot.nPhiCells) - wphibin -= AProjectionLegoPlot.nPhiCells; - while (wphibin < 0) - wphibin += AProjectionLegoPlot.nPhiCells; - int retabin = etabin; - if (AProjectionLegoPlot.reverse) - retabin = AProjectionLegoPlot.nEtaCells - etabin - 1; - - // add to the legoplot - lego[wphibin][retabin][color] += et * phiweight * etaweight; - }// loop over etabins - }// loop over phibins - }// end of phietabinsloop - - /** - * If the user has a different scale selected then this updates the value - */ - public static double scaleValue(double value) - { - if(value==0) - return 0; - if (AProjectionLegoPlot.defaultScale == 2) - { - value = Math.sqrt(value); - } - else if (AProjectionLegoPlot.defaultScale == 1) - { - value = Math.log10(value) - AProjectionLegoPlot.minimumofLogScale; - } - return value; - } - - public static void drawHistograms(AWindow window, AGraphics ag, AEvent event, double[][][] lego, double maxEt, double met, double AODmaxEt) - { - // Draw the other stuff in the event: jets, missing Et, etc. - double _jetcircleradius = parameterStore.get("LegoPlot", "JetCircleRadius").getD(); - double _legocut = parameterStore.get("LegoPlot", "LegoCut").getD(); - _legocut=scaleValue(_legocut); - boolean doAOD = false; - if (AODmaxEt!=0) - doAOD = true; - - //for ordering of ROIs - Stack jetROI = new Stack(), emTauROI = new Stack(), muonROI = new Stack(); - - List hitsAndTracks = event.getHitsAndTracks(window.getProjection()); - for (int h = 0; h < hitsAndTracks.size(); h++) - { - AData datatype = ((AData) hitsAndTracks.get(h)); - if (datatype.getName().equals("Jet")) - { - AJetData jet = (AJetData) datatype; - jet.makeDrawList(); - byte[] colors = jet.getColor(); - for (int j = 0; j < jet.getNumDraw(); ++j) - { - int list = jet.getDrawIndex(j); - double et = jet.getET(list); - Color _colorJet = AProjectionLegoPlot.defaultColorMap[colors[list]]; - ALegoDraw.drawJet(et, jet.getEta(list), jet.getPhi(list), _colorJet, window, ag, _jetcircleradius); - } - } - else if (datatype.getName().equals("ETMis")) - { - AETMisData mis = (AETMisData) datatype; - mis.makeDrawList(); - if (mis.getNumDraw() > 0) - { - byte[] colors = mis.getColor(); - int phib = (int) ((mis.getPhi()) * AProjectionLegoPlot.nPhiCells / AMath.TWO_PI); - if (phib < 0) - phib += AProjectionLegoPlot.nPhiCells; - if (phib >= AProjectionLegoPlot.nPhiCells) - phib -= AProjectionLegoPlot.nPhiCells; - Color _colorMis = AProjectionLegoPlot.defaultColorMap[colors[0]]; - ALegoDraw.drawMissEt(window, ag, phib, mis.getET(), _colorMis, maxEt); - } - } - //save the ROIs so they can be drawn jet-em-muon - else if (datatype.getName().equals("JetROI")) - { - jetROI.push(h); - } - else if (datatype.getName().equals("EmTauROI")) - { - emTauROI.push(h); - } - else if (datatype.getName().equals("MuonROI")) - { - muonROI.push(h); - } - }//end of loop over hitsandtracks - - //now draw the ROIs in the correct order - drawROIs(jetROI, window, ag, event); - drawROIs(emTauROI, window, ag, event); - drawROIs(muonROI, window, ag, event); - - - //for towers find colors to loop over - int largestColourIndex=0; - int lowestColourIndex=AProjectionLegoPlot.nLayers; - Iterator colorIterator = AProjectionLegoPlot.colorset.iterator(); - while(colorIterator.hasNext()) - { - int currentColor = ((Integer) colorIterator.next()).intValue(); - if(currentColor>largestColourIndex) - largestColourIndex=currentColor; - if(currentColor<lowestColourIndex) - lowestColourIndex=currentColor; - } - // Draw the EM and HAD towers - for (int y = 0; y < AProjectionLegoPlot.nEtaCells; ++y) - { - for (int x = AProjectionLegoPlot.nPhiCells - 1; x >= 0; --x) - { - double binheight = 0; - if(AProjectionLegoPlot.getDrawEMHAD() && AProjectionLegoPlot.colorset.size()==2) - { - //for Em/had option should only have 2 colors - int z=AProjectionLegoPlot.colorEM; - binheight=lego[x][y][z]; - if (binheight > _legocut) - { - ALegoDraw.drawBox(window, ag, x, y, z, 0.0, binheight, maxEt, 0.5); - if(lego[x][y][AProjectionLegoPlot.colorHad]> _legocut) - { - z=AProjectionLegoPlot.colorHad; - ALegoDraw.drawBox(window, ag, x, y, z, binheight, lego[x][y][z], maxEt, 0.5); - } - } - else if(lego[x][y][AProjectionLegoPlot.colorHad]> _legocut) - { - z=AProjectionLegoPlot.colorHad; - ALegoDraw.drawBox(window, ag, x, y, z, 0.0, lego[x][y][z], maxEt, 0.5); - } - } - else - { - //if not Em/Had then loop over colors - for(int z=largestColourIndex; z>=lowestColourIndex; z--) - { - if (lego[x][y][z] > _legocut) - { - ALegoDraw.drawBox(window, ag, x, y, z, binheight, lego[x][y][z], maxEt, 0.5); - binheight += lego[x][y][z]; - } - } - } - } - } - - //loop again and draw things that need to be on top of histogram - for (int h = 0; h < hitsAndTracks.size(); h++) - { - AData datatype = ((AData) hitsAndTracks.get(h)); - if (datatype.getName().equals("Jet")) - { - AJetData jet = (AJetData) datatype; - jet.makeDrawList(); - byte[] colors = jet.getColor(); - for (int j = 0; j < jet.getNumDraw(); ++j) - { - int list = jet.getDrawIndex(j); - double et = jet.getET(list); - Color _colorJet = AProjectionLegoPlot.defaultColorMap[colors[list]]; - if (parameterStore.get("LegoPlot", "JetText").getStatus()) - ALegoDraw.drawJetText(et, jet.getEta(list), jet.getPhi(list), _colorJet, window, ag, _jetcircleradius); - } - } - } - - if (doAOD) - { - //Draw the new jet Towers - String[] colJet=event.getActiveCollectionNames("Jet"); - for(int i=0;i<colJet.length;i++) - { - AJetData jets = (AJetData) event.get(colJet[i]); - - if (!parameterStore.get("Data", "Jet").getStatus()) - jets = null; - if (jets != null) - { - jets.makeDrawList(); - byte[] colors = jets.getColor(); - for (int j = 0; j < jets.getNumDraw(); ++j) - { - int list = jets.getDrawIndex(j); - Color _colorJet = AProjectionLegoPlot.defaultColorMap[colors[list]]; - int etabin = (int) ((jets.getEta(list) + 5.0) * AProjectionLegoPlot.nEtaCells / 10.0); - if (AProjectionLegoPlot.reverse) - etabin = AProjectionLegoPlot.nEtaCells - etabin; - int phibin = (int) ((jets.getPhi(list)) * AProjectionLegoPlot.nPhiCells / AMath.TWO_PI); - double pt = Math.abs(jets.getPt()[list]); - pt=scaleValue(pt); - ALegoDraw.drawBox(window, ag, phibin, etabin, AProjectionLegoPlot.DRAW_JET,_colorJet, 0, pt, maxEt, 2.0); - } - } - } - - // Draw the caloClusters - String[] colCluster=event.getActiveCollectionNames("Cluster"); - for(int i=0;i<colCluster.length;i++) - { - AClusterData cluster = (AClusterData) event.get(colCluster[i]); - if (!parameterStore.get("Data", "Cluster").getStatus()) - cluster = null; - if (cluster != null) - { - cluster.makeDrawList(); - for (int m = 0; m < cluster.getNumDraw(); ++m) - { - int list = cluster.getDrawIndex(m); - int etabin = (int) ((cluster.getEta(list) + 5.0) * AProjectionLegoPlot.nEtaCells / 10.0); - if (AProjectionLegoPlot.reverse) - etabin = AProjectionLegoPlot.nEtaCells - etabin; - int phibin = (int) ((cluster.getPhi(list)) * AProjectionLegoPlot.nPhiCells / AMath.TWO_PI); - double et = Math.abs(cluster.getET(list)); - et=scaleValue(et); - ALegoDraw.drawBox(window, ag, phibin, etabin, AProjectionLegoPlot.DRAW_CLUSTER, 0, et, maxEt, .5); - } - } - } - - // Draw the bjets - String[] colBjets=event.getActiveCollectionNames("BJet"); - for(int i=0;i<colBjets.length;i++) - { - ABJetData bjets = (ABJetData) event.get(colBjets[i]); - if (!parameterStore.get("Data", "BJet").getStatus()) - bjets = null; - if (bjets != null) - { - bjets.makeDrawList(); - for (int bj = 0; bj < bjets.getNumDraw(); ++bj) - { - int list = bjets.getDrawIndex(bj); - double et = bjets.getPT(list); - ALegoDraw.drawJet(et, bjets.getEta(list), bjets.getPhi(list), AProjectionLegoPlot.defaultColorMap[parameterStore.get("BJet", "Constant").getI()], window, ag, _jetcircleradius + _jetcircleradius / 5.0); - } - } - } - - // Draw the taujets - String[] colTau=event.getActiveCollectionNames("TauJet"); - for(int i=0;i<colTau.length;i++) - { - ATauJetData tjets = (ATauJetData) event.get(colTau[i]); - if (!parameterStore.get("Data", "TauJet").getStatus()) - tjets = null; - if (tjets != null) - { - tjets.makeDrawList(); - for (int tj = 0; tj < tjets.getNumDraw(); ++tj) - { - int list = tjets.getDrawIndex(tj); - double et = tjets.getPT(list); - ALegoDraw.drawJet(et, tjets.getEta(list), tjets.getPhi(list), AProjectionLegoPlot.defaultColorMap[parameterStore.get("TauJet", "Constant").getI()], window, ag, _jetcircleradius / 2.0); - } - } - } - - //Draw the muons - String[] colMuon=event.getActiveCollectionNames("Muon"); - for(int i=0;i<colMuon.length;i++) - { - AMuonData muons = (AMuonData) event.get(colMuon[i]); - if (!parameterStore.get("Data", "Muon").getStatus()) - muons = null; - if (muons != null) - { - muons.makeDrawList(); - for (int m = 0; m < muons.getNumDraw(); ++m) - { - int list = muons.getDrawIndex(m); - int etabin = (int) ((muons.getEta(list) + 5.0) * AProjectionLegoPlot.nEtaCells / 10.0); - if (AProjectionLegoPlot.reverse) - etabin = AProjectionLegoPlot.nEtaCells - etabin; - int phibin = (int) ((muons.getPhi(list)) * AProjectionLegoPlot.nPhiCells / AMath.TWO_PI); - double pt = Math.abs(muons.getPT(list)); - pt=scaleValue(pt); - ALegoDraw.drawBox(window, ag, phibin, etabin, AProjectionLegoPlot.DRAW_MUON, 0, pt, maxEt, 0.5); - } - } - } - - //Draw the electrons - String[] colElectron=event.getActiveCollectionNames("Electron"); - for(int i=0;i<colElectron.length;i++) - { - AElectronData electrons = (AElectronData) event.get(colElectron[i]); - - if (!parameterStore.get("Data", "Electron").getStatus()) - electrons = null; - if (electrons != null) - { - electrons.makeDrawList(); - for (int e = 0; e < electrons.getNumDraw(); ++e) - { - int list = electrons.getDrawIndex(e); - int etabin = (int) ((electrons.getEta(list) + 5.0) * AProjectionLegoPlot.nEtaCells / 10.0); - if (AProjectionLegoPlot.reverse) - etabin = AProjectionLegoPlot.nEtaCells - etabin; - int phibin = (int) ((electrons.getPhi(list)) * AProjectionLegoPlot.nPhiCells / AMath.TWO_PI); - double pt = Math.abs(electrons.getPT(list)); - pt=scaleValue(pt); - ALegoDraw.drawBox(window, ag, phibin, etabin, AProjectionLegoPlot.DRAW_ELECTRON, 0, pt, maxEt, 0.5); - } - } - } - - //Draw the photons - String[] colPhoton=event.getActiveCollectionNames("Photon"); - for(int i=0;i<colPhoton.length;i++) - { - APhotonData photons = (APhotonData) event.get(colPhoton[i]); - if (!parameterStore.get("Data", "Photon").getStatus()) - photons = null; - if (photons != null) - { - photons.makeDrawList(); - for (int p = 0; p < photons.getNumDraw(); ++p) - { - int list = photons.getDrawIndex(p); - int etabin = (int) ((photons.getEta(list) + 5.0) * AProjectionLegoPlot.nEtaCells / 10.0); - if (AProjectionLegoPlot.reverse) - etabin = AProjectionLegoPlot.nEtaCells - etabin; - int phibin = (int) ((photons.getPhi(list)) * AProjectionLegoPlot.nPhiCells / AMath.TWO_PI); - double pt = Math.abs(photons.getPT(list)); - pt=scaleValue(pt); - ALegoDraw.drawBox(window, ag, phibin, etabin, AProjectionLegoPlot.DRAW_PHOTON, 0, pt, maxEt, 0.5); - } - } - } - - //Draw the compositeParticles - String[] colCompPart=event.getActiveCollectionNames("CompositeParticle"); - for(int i=0;i<colCompPart.length;i++) - { - ACompositeParticleData compositeParticles = (ACompositeParticleData) event.get(colCompPart[i]); - if (!parameterStore.get("Data", "CompositeParticle").getStatus()) - compositeParticles = null; - if (compositeParticles != null) - { - compositeParticles.makeDrawList(); - for (int e = 0; e < compositeParticles.getNumDraw(); ++e) - { - int list = compositeParticles.getDrawIndex(e); - int etabin = (int) ((compositeParticles.getEta(list) + 5.0) * AProjectionLegoPlot.nEtaCells / 10.0); - if (AProjectionLegoPlot.reverse) - etabin = AProjectionLegoPlot.nEtaCells - etabin; - int phibin = (int) ((compositeParticles.getPhi(list)) * AProjectionLegoPlot.nPhiCells / AMath.TWO_PI); - double pt = Math.abs(compositeParticles.getPT(list)); - pt=scaleValue(pt); - //change how drawn depending on type - if(Math.abs(compositeParticles.getPdgId(list))==13) - ALegoDraw.drawBox(window, ag, phibin, etabin, AProjectionLegoPlot.DRAW_MUON, 0, pt, maxEt, 0.5); - else if(Math.abs(compositeParticles.getPdgId(list))==11) - ALegoDraw.drawBox(window, ag, phibin, etabin, AProjectionLegoPlot.DRAW_ELECTRON, 0, pt, maxEt, 0.5); - else if(Math.abs(compositeParticles.getPdgId(list))==22) - ALegoDraw.drawBox(window, ag, phibin, etabin, AProjectionLegoPlot.DRAW_PHOTON, 0, pt, maxEt, 0.5); - else if(Math.abs(compositeParticles.getPdgId(list))==5) - ALegoDraw.drawBox(window, ag, phibin, etabin, AProjectionLegoPlot.DRAW_BJET, 0, pt, maxEt, 0.5); - else if(Math.abs(compositeParticles.getPdgId(list))==15) - ALegoDraw.drawBox(window, ag, phibin, etabin, AProjectionLegoPlot.DRAW_TAUJET, 0, pt, maxEt, 0.5); - else if(compositeParticles.getTypeEV(list).equals("EVParticleJet")) - ALegoDraw.drawBox(window, ag, phibin, etabin, AProjectionLegoPlot.DRAW_JET, 0, pt, maxEt, 0.5); - else - ALegoDraw.drawBox(window, ag, phibin, etabin, AProjectionLegoPlot.DRAW_COMPOSITEPARTICLE, 0, pt, maxEt, 0.5); - } - } - } - }//if doAOD - }//drawHistograms - - public static void drawROIs(Stack ROIstack, AWindow window, AGraphics ag, AEvent event) - { - List hitsAndTracks = event.getHitsAndTracks(window.getProjection()); - //loop over ROIs - while(ROIstack.size()>0) - { - int h = (Integer) ROIstack.pop(); - AData datatype = ((AData) hitsAndTracks.get(h)); - - byte[] ROIColor; - double deltaPhi; - double deltaEta; - AROIData ROIData = (AROIData) datatype; - ROIData.makeDrawList(); - ROIColor = datatype.getColor(); - deltaEta = parameterStore.get(datatype.getName(), "deta").getD(); - deltaPhi = parameterStore.get(datatype.getName(), "dphi").getD(); - // deltaEta and deltaPhi should not be too large - for (int j = 0; j < ROIData.getNumDraw(); ++j) - { - int numPoints = 4; - int list = ROIData.getDrawIndex(j); - double ROIphi = ROIData.getPhi(list); - double ROIeta = ROIData.getEta(list); - if (AProjectionLegoPlot.reverse) - ROIeta = -ROIeta; - double leftPhi = ROIphi - deltaPhi; - double rightPhi = ROIphi + deltaPhi; - double topEta = ROIeta + deltaEta; - double bottomEta = ROIeta - deltaEta; - if ((ROIColor[list] < AProjectionLegoPlot.defaultColorMap.length) && (ROIColor[list] >= 0)) - ag.setColor(AProjectionLegoPlot.defaultColorMap[ROIColor[list]]); - ag.setLineWidth(3); - double ROIx = 0.0; - double ROIy = 0.0; - double[][] hv = new double[2][numPoints]; - if ((rightPhi <= AMath.TWO_PI) && (leftPhi >= 0.0)) - { - for (int p = 0; p < numPoints; p++) - { - switch (p) - { - case 0: - ROIx = rightPhi * 360.0 / AMath.TWO_PI; - ROIy = bottomEta; - break; - case 1: - ROIx = leftPhi * 360.0 / AMath.TWO_PI; - ROIy = bottomEta; - break; - case 2: - ROIx = leftPhi * 360.0 / AMath.TWO_PI; - ROIy = topEta; - break; - case 3: - ROIx = rightPhi * 360.0 / AMath.TWO_PI; - ROIy = topEta; - break; - } - if(ROIy <= -5.0) - ROIy = -5.0; - if(ROIy >= 5.0) - ROIy = 5.0; - //move phi value due to slant of eta axis - ROIx=AProjectionLegoPlot.adjustPhi(window,ROIx,ROIy); - hv[0][p] = ROIx; - hv[1][p] = ROIy; - } - } - else if ((rightPhi > AMath.TWO_PI) && (leftPhi < 0.0)) - { - for (int p = 0; p < numPoints; p++) - { - switch (p) - { - case 0: - ROIx = 360.0; - ROIy = bottomEta; - break; - case 1: - ROIx = 0.0; - ROIy = bottomEta; - break; - case 2: - ROIx = 0.0; - ROIy = topEta; - break; - case 3: - ROIx = 360.0; - ROIy = topEta; - break; - } - if(ROIy <= -5.0) - ROIy = -5.0; - if(ROIy >= 5.0) - ROIy = 5.0; - //move phi value due to slant of eta axis - ROIx=AProjectionLegoPlot.adjustPhi(window,ROIx,ROIy); - hv[0][p] = ROIx; - hv[1][p] = ROIy; - } - } - else if (rightPhi > AMath.TWO_PI) - { - double[][] hvWrap = new double[2][numPoints]; - double ROIxWrap = 0.0; - for (int p = 0; p < numPoints; p++) - { - switch (p) - { - case 0: - ROIx = 360.0; - ROIxWrap = (rightPhi - AMath.TWO_PI) * 360.0 / AMath.TWO_PI; - ROIy = bottomEta; - break; - case 1: - ROIx = leftPhi * 360.0 / AMath.TWO_PI; - ROIxWrap = 0.0; - ROIy = bottomEta; - break; - case 2: - ROIx = leftPhi * 360.0 / AMath.TWO_PI; - ROIxWrap = 0.0; - ROIy = topEta; - break; - case 3: - ROIx = 360.0; - ROIxWrap = (rightPhi - AMath.TWO_PI) * 360.0 / AMath.TWO_PI; - ROIy = topEta; - break; - } - if(ROIy <= -5.0) - ROIy = -5.0; - if(ROIy >= 5.0) - ROIy = 5.0; - //move phi value due to slant of eta axis - ROIx=AProjectionLegoPlot.adjustPhi(window,ROIx,ROIy); - hv[0][p] = ROIx; - hv[1][p] = ROIy; - //move phi value due to slant of eta axis - ROIxWrap=AProjectionLegoPlot.adjustPhi(window,ROIxWrap,ROIy); - hvWrap[0][p] = ROIxWrap; - hvWrap[1][p] = ROIy; - } - Point2D.Double p= new Point2D.Double(0,0); - for(int i=0; i<numPoints; i++) - { - p = window.calculateDisplay(hvWrap[0][i],hvWrap[1][i]); - hvWrap[0][i]=p.x; - hvWrap[1][i]=p.y; - } - ag.fillPolygon(hvWrap[0], hvWrap[1], numPoints); - } - else - { - double[][] hvWrap = new double[2][numPoints]; - double ROIxWrap = 0.0; - for (int p = 0; p < numPoints; p++) - { - switch (p) - { - case 0: - ROIx = rightPhi * 360.0 / AMath.TWO_PI; - ROIxWrap = 360.0; - ROIy = bottomEta; - break; - case 1: - ROIx = 0.0; - ROIxWrap = (leftPhi + AMath.TWO_PI) * 360.0 / AMath.TWO_PI; - ROIy = bottomEta; - break; - case 2: - ROIx = 0.0; - ROIxWrap = (leftPhi + AMath.TWO_PI) * 360.0 / AMath.TWO_PI; - ROIy = topEta; - break; - case 3: - ROIx = rightPhi * 360.0 / AMath.TWO_PI; - ROIxWrap = 360.0; - ROIy = topEta; - break; - } - if(ROIy <= -5.0) - ROIy = -5.0; - if(ROIy >= 5.0) - ROIy = 5.0; - //move phi value due to slant of eta axis - ROIx=AProjectionLegoPlot.adjustPhi(window,ROIx,ROIy); - hv[0][p] = ROIx; - hv[1][p] = ROIy; - //move phi value due to slant of eta axis - ROIxWrap=AProjectionLegoPlot.adjustPhi(window,ROIxWrap,ROIy); - hvWrap[0][p] = ROIxWrap; - hvWrap[1][p] = ROIy; - } - Point2D.Double p= new Point2D.Double(0,0); - for(int i=0; i<numPoints; i++) - { - p = window.calculateDisplay(hvWrap[0][i],hvWrap[1][i]); - hvWrap[0][i]=p.x; - hvWrap[1][i]=p.y; - } - ag.fillPolygon(hvWrap[0], hvWrap[1], numPoints); - } - Point2D.Double p= new Point2D.Double(0,0); - for(int i=0; i<numPoints; i++) - { - p = window.calculateDisplay(hv[0][i],hv[1][i]); - hv[0][i]=p.x; - hv[1][i]=p.y; - } - ag.fillPolygon(hv[0], hv[1], numPoints); - }//end of loop over ROI data - } - - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AMBTSData.java b/graphics/AtlantisJava/src/atlantis/data/AMBTSData.java deleted file mode 100644 index 931b749640d510e8e0a940a3dfd83c73b5b3fa0f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AMBTSData.java +++ /dev/null @@ -1,595 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.geometry.ACalorimeterDetector; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.ALogger; - - -/** - * The Minimum Bias Trigger Scintillator implementation. - * - * @author Mark Stockton - */ -public class AMBTSData extends ACalorimeterData -{ - private static ALogger logger = ALogger.getLogger(AMBTSData.class); - - - /* - * For Rz histograms may/will need: - * - * private int[][] cellTable; - * - * phiIndex[i] - * etaIndex[i] - * outerEta -> use -> detector.getEtaMax() - * outerR -> use -> detector.getRMax() - * outerZ -> use -> detector.getZMax() - * etaGranularity - */ - - protected float[] quality; - protected float[] time; - //label not needed at present as is just a string made - // from type, module and channel - //protected String[] label; - - // data for real pulse shapes plots - private int[][] adcCounts = null; - private float[] cellPedestal = null; - private float[] cellRawTime = null; - private float[] cellRawAmplitude = null; - private static boolean pulseShapesDataAvailable = false; - private static final String LOOKUP_TABLE_FILE = - AGlobals.instance().getHomeDirectory() + "configuration" + - System.getProperty("file.separator") + - "rpsplt_tile.csv"; - // number of lookup table values for real pulse shapes plots calculation - private static final short NUMBER_OF_LOOKUP_VALUES = 401; - - - - - protected ACalorimeterDetector[] MBTSlayers = new ACalorimeterDetector[2]; - - AMBTSData(AHashMap p, AEvent e) - { - super(p,e); - - channel = p.getIntArray("channel"); - /* - * this energy is in MeV not GeV - */ - et = p.getFloatArray("energy"); - etSum = p.getFloatArray("energy"); - //label = p.getStringArray("label"); - quality = p.getFloatArray("quality"); - sampling = p.getIntArray("sampling"); - time = p.getFloatArray("time"); - - /* - * The phi and eta coordinates used here are actually not phi and eta - * - * Instead: - phi refers to the module number 0-8 - * - eta refers to which side of the detector - * - * The actual phi and eta are then calculated from the geometry object - */ - int[] inteta; - int[] intphi; - if( p.containsKey("module")) - { - //phi new version - intphi = p.getIntArray("module"); - } - else - { - //phi first version - float[] tempphi = p.getFloatArray("phi"); - intphi = new int[numData]; - for(int i=0; i<numData; i++) - { - intphi[i]=(int) (( (8*tempphi[i])/(2*Math.PI))-(1/2)); - } - } - - if( p.containsKey("type")) - { - //eta new version - inteta = p.getIntArray("type"); - } - else - { - //eta first version - float[] tempeta = p.getFloatArray("eta"); - inteta = new int[numData]; - for(int i=0; i<numData; i++) - { - if(tempeta[i]<0) - { - inteta[i] = -1; - } - else - { - inteta[i] = 1; - } - } - } - eta = new float[numData]; - phi = new float[numData]; - for(int i=0; i<numData; i++) - { - eta[i]=inteta[i]; - phi[i]=intphi[i]; - } - - //now define sub and side depending on eta value - for(int i=0; i<numData; i++) - { - if(eta[i]<0) - { - sub[i] = 0; - side[i] = -1; - } - else - { - sub[i] = 1; - side[i] = 1; - } - } - - //store the two sampling of the MBTS geometry - for (int i=0; i<ACalorimeterDetector.count(); i++) - { - ACalorimeterDetector detector = ACalorimeterDetector.get(i); - if(detector.getName().equals("Minimum Bias Trigger Scintillators")) - { - MBTSlayers[detector.getSampling()] = detector; - } - } - - // read in MBTS data for real pulse shapes plots - readPulseShapePlotData(p); - - } - - - - private void readPulseShapePlotData(AHashMap p) - { - // read ADCCounts and cell data for real pulse shapes plots - adcCounts = super.getADCCountsData(p); - - // read other MBTS data for real pulse shapes plots - cellPedestal = (p.get("cellPedestal") != null) ? p.getFloatArray("cellPedestal") : null; - cellRawTime = (p.get("cellRawTime") != null) ? p.getFloatArray("cellRawTime") : null; - cellRawAmplitude = (p.get("cellRawAmplitude") != null) ? p.getFloatArray("cellRawAmplitude") : null; - - pulseShapesDataAvailable = false; - if(adcCounts != null && cellPedestal != null && cellRawTime != null && - cellRawAmplitude != null) - { - pulseShapesDataAvailable = true; - - logger.debug(CALORIMETER_NAME + - ": data for real pulse shape plots available"); - - if(ACalorimeterRPSPLT.areTileLookupTablesInitialized()) - { - logger.debug(CALORIMETER_NAME + - ": lookup tables have already been read in"); - } - else - { - logger.debug(CALORIMETER_NAME + - ": lookup table values have not been read in yet\n" + - " trying to read file: " + LOOKUP_TABLE_FILE); - - try - { - ATILEData.readLookupTableFile(); - logger.debug(CALORIMETER_NAME + - ": values from " + LOOKUP_TABLE_FILE + - " successfully read in"); - } - catch(AAtlantisException ex) - { - logger.debug(CALORIMETER_NAME + - ": reading " + LOOKUP_TABLE_FILE + - " failed, real pulse shapes plots will not " + - "be available, reason: " + ex.getMessage(), ex); - pulseShapesDataAvailable = false; - } - } - } - - } // readPulseShapePlotData() ------------------------------------------- - - - - /** - * Returns the name of the parameter group. - * - * @return String parameter group - */ - public String getParameterGroup() - { - return "TILE"; - } - - /** - * Returns the name of the datatype. - * - * @return String datatype - */ - public String getName() - { - return "MBTS"; - } - - /** - * Returns the name of the datatype. - * - * @return String datatype - */ - public String getNameScreenName() - { - return "MBTS"; - } - - /** - * Returns the type of calorimeter (ECAL/HCAL) for a hit. - * - * @param index int hit index - * @return String calorimeter type - */ - public String getCalorimeterType(int index) - { - return "HCAL"; - } - - /** - * Draws the MBTS data in the y-x projection. - * - * @return ACoord cell geometry polygons - */ - protected ACoord getYXUser() - { - makeDrawList(); - - int mode = parameterStore.get("YX", "Mode").getI(); - if (mode != AProjectionYX.MODE_MBTS) - { - return ACoord.NO_DATA; - } - - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - double rMax = MBTSlayers[sampling[j]].getRMax(); - double rMin = MBTSlayers[sampling[j]].getRMin(); - int numPhi = MBTSlayers[sampling[j]].getNumPhi(); - double phiMin = Math.PI*2*phi[j]/numPhi; - double phiMax = Math.PI*2*(1+phi[j])/numPhi; - hv[0][i] = new double[] {rMax*Math.cos(phiMin), rMax*Math.cos(phiMax), - rMin*Math.cos(phiMax), rMin*Math.cos(phiMin)}; - hv[1][i] = new double[] {rMax*Math.sin(phiMin), rMax*Math.sin(phiMax), - rMin*Math.sin(phiMax), rMin*Math.sin(phiMin)}; - index[i] = j; - } - - return new ACoord(hv, index, this); - } - - /** - * Draws the MBTS data in the rho-z projection. See the description of - * filterDrawListRZ() for an explanation of the drawing method. - * - * @return ACoord cell geometry polygons - */ - protected ACoord getRZUser() - { - makeDrawList(); - - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int j = listdl[i]; - int sign = MBTSlayers[sampling[j]].getRSign((int) phi[j]); - double zMax = MBTSlayers[sampling[j]].getZMax() * side[j]; - double zMin = MBTSlayers[sampling[j]].getZMin() * side[j]; - double rMax = MBTSlayers[sampling[j]].getRMax() * sign; - double rMin = MBTSlayers[sampling[j]].getRMin() * sign; - hv[0][i] = new double[] {zMax, zMin, zMin, zMax}; - hv[1][i] = new double[] {rMax, rMax, rMin, rMin}; - index[i] = j; - } - - return new ACoord(hv, index, this); - } - - /** - * Applies cuts to the data. - */ - protected void applyCuts() - { - super.applyCuts(); - - cut("CutsCalo", "MBTSEnergy", "MBTSEnergy", et); - int cutSub = parameterStore.get("CutsCalo", "MBTS").getI(); - if(cutSub != -1) - { - cutArray(sub, cutSub, "Endcap"); - } - } - - /** - * Returns the data in the phi-rho projection. - * - * @return ACoord polygons representing calorimeter cells - */ - public ACoord getFRUser() - { - return getYXUser().convertYXToFR().includePhiWrapAround("FR"); - } - - /** - * Returns info about a selected hit (for picking) - * - * @param index int hit index - * @return String info - */ - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+ - "\n Energy="+correctEnergy(energy[index])+" GeV\n "; - - //find the cell energy on the opposite MBTS layer - String cellminus, cellplus; - double tempEnergy=0.0; - for(int i=0; i<energy.length; i++) - { - if(eta[i]==(-1.0*eta[index]) && phi[i]==phi[index] && sampling[i]==sampling[index]) - { - tempEnergy=energy[i]; - } - } - - if(eta[index]<0) - { - cellminus = correctEnergy(energy[index]); - cellplus = correctEnergy(tempEnergy); - } - else - { - cellplus = correctEnergy(energy[index]); - cellminus = correctEnergy(tempEnergy); - } - StringBuffer msg = new StringBuffer(CALORIMETER_NAME + " cell "); - - // calling AIdHelper.getFullIdentifier(id[index])[0] - does not work, - // id array is not present in the event data. it is arbitrarily created - // in Atlantis, however, but contains only indices, thus currently - // (2008-11-25) index and id[index] are the same values - msg.append(" (id: " + id[index] + " index: " + index + ")"); - - msg.append("\n Energy = " + correctEnergy(energy[index])); - msg.append("\n (MBTS + = " + cellplus + " MBTS - = " + cellminus + ")"); - msg.append("\n time = " + time[index]); - msg.append("\n quality = " + quality[index]); - msg.append("\n type = " + String.format("%.4f",eta[index])); - msg.append("\n module = " + String.format("%.1f",phi[index])); - msg.append("\n sampling = " + sampling[index]); - msg.append("\n channel = " + channel[index]); - - // real pulse shapes plots - msg.append("\n cell pedestal = "); - String m = (cellPedestal != null) ? Float.toString(cellPedestal[index]) + - " ADC counts" : "n/a"; - msg.append(m); - - m = pulseShapesDataAvailable ? "" : "\n data for real pulse shapes plot n/a"; - msg.append(m); - - return msg.toString(); - - } // getHitInfo() ------------------------------------------------------- - - private String correctEnergy(double energy) - { - String energyOutput; - if(energy>1.) - { - energyOutput = String.format("%.2f",energy) + " MeV"; - } - else if(energy>0.001) - { - energy*=1000.; - energyOutput = String.format("%.2f",energy) + " KeV"; - } - else - { - energy*=1000.*1000.; - energyOutput = String.format("%.2f",energy) + " eV"; - } - return energyOutput; - } - - - /** - * Returns the histograms for this projection. - * - * @param projection AProjection2D current projection - * @return ACoord[] polygons representing histograms - */ - protected ACoord[] getUserHistograms(AProjection2D projection) - { - ACoord[] data = ACoord.NO_HISTOGRAMS; - //TODO add MBTS RZ Histograms option turned off in gui - //if (projection instanceof AProjectionRZ) - // data = getRZHistograms(); - return projection.nonLinearTransform(data); - } - - - - // calculate real pulse shapes values based on the values in the lookup tables - // taken from ATILEData. This function can't be shared from ACalorimeterData - // (shared by LAr, FCAL, HEC) since the calculation is different and can't - // call it directly from TILE since there are two channels. - // Should likely be refactored (so that method is somewhat shared) - after - // discussion with someone from TILE/MBTS/LAr ... - private double getPhysicsPulseShape(double xTime, double pmtTime, - double pmtPedestal, double pmtEnergy, - float[] amplitude, float[] time) - throws AAtlantisException - { - double tdiv = 0.0; - int lookup = 0; - double localTime = 0.0; - double xpulse = 0.0; - - // need to get "multiple" parameter ( = number of values in adcCounts - // for each cell - adcCounts.length), shall be the same for all the - // cells - taking the length of the first array (for the first cell) - // no NullPointer or ArrayIndexBound checks are necessary here as this - // method shall only be called when the relevant data is available - double centerOfSamples = (adcCounts[0].length + 1.0) / 2.0; - - tdiv = time[1] - time[0]; - localTime = (xTime - centerOfSamples) * 25.0 - pmtTime; - lookup = (int) ((localTime - time[0]) / tdiv); - - if(lookup < 0) - { - lookup = 0; - } - if(lookup >= NUMBER_OF_LOOKUP_VALUES - 1) - { - lookup = NUMBER_OF_LOOKUP_VALUES - 2; // -1 was off by 1 - } - - try - { - if(lookup == 0 || lookup == NUMBER_OF_LOOKUP_VALUES - 2) - { - xpulse = amplitude[lookup]; - } - else - { - xpulse = amplitude[lookup] + ((amplitude[lookup + 1] - - amplitude[lookup]) / tdiv) * (localTime - time[lookup]); - } - } - catch(ArrayIndexOutOfBoundsException ex) - { - String m = "AMBTSData.getPhysicsPulseShape():\n" + - " lookup index out of bound: lookup = " + lookup; - throw new AAtlantisException(m); - } - return (xpulse * pmtEnergy) + pmtPedestal; - - } // getPhysicsPulseShape() --------------------------------------------- - - - - /** - * Utility method APulseShapePlot.plotRealPulseShapes() is called from - * here. - * Physics pulse is calculated here: getPhysicsPulseShape(). - * This method is called from APickInteraction via ACalorimeterData - * which defines abstract plotPulseShapes(). - * Method more or less copied & pasted from ATILEData, but here is - * for just one channel. - * - * @param index int - */ - public void plotPulseShapes(int index) - { - if(pulseShapesDataAvailable) - { - String title = CALORIMETER_NAME + " cell index: " + index; - - // one channel for MBTS - int[][] adcCountsLocal = new int[][] { adcCounts[index] }; - - if(super.checkADCCountsAvailability(adcCountsLocal)) - { - // adc counts are available - logger.debug(CALORIMETER_NAME + " adc counts (digits) are " + - "available for pulse shapes plots for this cell."); - } - else - { - AOutput.append("\nADC counts are not available for this cell, " + - "can't plot pulse shapes.", ALogInterface.WARNING); - return; - } - - - // step - starting from 1, need to get step numbers within - // number of ADC samples (adcCounts[0].length) - double step = (adcCounts[0].length - 1) / (float) NUMBER_OF_LOOKUP_VALUES; - double[][] realPulse = new double[1][NUMBER_OF_LOOKUP_VALUES]; // 1 channel - double d = 1.0; - - // by zdenek 2008-12-02 - // DPD (slimed version of ESD) sometimes don't have cellPedestal - // for a cell (the tag exists, values are there, but are 0). check - // if pedestal is 0 and if so, take as pedestal value the first - // adc count digit - float cellPedestalLocal = cellPedestal[index]; - if(cellPedestalLocal == 0.0f) - { - logger.debug("MBTS cellPedestal is not available (i.e. " + - "are 0.0f), using first adcCount digit as pedestal."); - cellPedestalLocal = adcCounts[index][0]; - } - - try - { - for(int i = 0; i < NUMBER_OF_LOOKUP_VALUES; i++) - { - d += step; - realPulse[0][i] = - this.getPhysicsPulseShape(d, cellRawTime[index], - cellPedestalLocal, - cellRawAmplitude[index], - ACalorimeterRPSPLT.TILE_AMPLITUDE, - ACalorimeterRPSPLT.TILE_TIME); - } - } - catch(AAtlantisException aaex) - { - AOutput.append(aaex.getMessage(), ALogInterface.WARNING); - return; - } - - APulseShapePlot.plotRealPulseShapes(adcCountsLocal, realPulse, - step, null, title); - } - else - { - logger.warn(CALORIMETER_NAME + " plotPulseShapes() method called, " + - "but data is not available."); - return; - } - - } // plotPulseShapes() -------------------------------------------------- - - - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AMDTData.java b/graphics/AtlantisJava/src/atlantis/data/AMDTData.java deleted file mode 100755 index 0074b2c5a161fd28d5e9ba25a99a1c8405f4b319..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AMDTData.java +++ /dev/null @@ -1,338 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.AIdHelper; -import atlantis.utils.ALogger; -import atlantis.utils.AMath; - -public class AMDTData extends AMuonHitData -{ - protected float[] driftR; - protected float[] length; - private static final int BARREL = 1; - - private static ALogger logger = ALogger.getLogger(AMDTData.class); - - public String getParameterGroup() - { - return "MDT"; - } - - public String getName() - { - return "MDT"; - } - - public String getNameScreenName() - { - return "MDT"; - } - - AMDTData(AHashMap p, AEvent e) - { - super(p,e); - driftR = p.getFloatArray("driftR"); - length = p.getFloatArray("length"); - // removed the fudge (CT 27/7/2004), and replaced with another - // for(int i=0; i<numData; i++) - // driftR[i]*=500./700.; - for (int i = 0; i < numData; i++) - if (driftR[i] > 1.46) - driftR[i] = (float) 1.46; // don't go out of the drifttube ! - } - - protected int getStation(int index) - { - try { - String stationName = AIdHelper.stationName(id[index]); - - if (stationName.charAt(1) == 'I') { - return 0; - } else if (stationName.charAt(1) == 'E') { - return 1; - } else if (stationName.charAt(1) == 'M') { - return 2; - } else if (stationName.charAt(1) == 'O') { - return 3; - } - } catch (AAtlantisException e) { - logger.error("Problem decoding MDT identifier", e); - } - - return 0; - } - - protected int getSub(int index) - { - try { - if (AIdHelper.stationName(id[index]).charAt(0) == 'B') { - return 1; - } else if (AIdHelper.stationEta(id[index]) < 0) { - return 0; - } else { - return 2; - } - } catch (AAtlantisException e) { - logger.error("Problem decoding MDT identifier", e); - } - - return 1; - } - - public int getSector(int index) - { - try { - String stationName = AIdHelper.stationName(id[index]); - - if (stationName.charAt(2) == 'L') { - return 2 * (AIdHelper.stationPhi(id[index]) - 1); - } else { - return 2 * (AIdHelper.stationPhi(id[index]) - 1) + 1; - } - } catch (AAtlantisException e) { - logger.error("Problem decoding MDT identifier", e); - } - - return 0; - } - - protected boolean getMeasuresPhi(int index) - { - return false; - } - - protected void applyCuts() - { - super.applyCuts(); - if (parameterStore.get("CutsATLAS", "CutPhi").getStatus()) - cutPhi(phi, getDPhi()); - cutEta(rho, z); - } - - // used to make phi cut - - private float[] getDPhi() - { - // only roughly correct for some special sectors - // must create all - float[] dphi = new float[numData]; - - // need only fill for those in draw list - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - dphi[list] = (float) Math.abs(Math.atan2(length[list] / 2., rho[list])); - } - return dphi; - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+"\n"+ - AMath.RHO+" = "+String.format("%.3f",rho[index])+"\n "+ - "z = " + String.format("%.3f",z[index]) + " cm\n"+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - - String temp = getNameScreenName() + " (id: " + identifier[index] + - " index: " + index + ")\n " + - AMath.RHO + " = " + String.format("%.3f",rho[index]) + " cm" + "\n " + - AMath.PHI + " = " + String.format("%.3f",Math.toDegrees(phi[index])) + - AMath.DEGREES + " (" + String.format("%.3f",phi[index]) + " rad)\n " + - "z = " + String.format("%.3f",z[index]) + " cm\n " + - "driftR = " + String.format("%.3f",driftR[index]) + " cm"; - if (sector[index] != -1) - { - temp += "\n sector = " + sector[index]; - } - - return temp; - } - - private void makeDrawListYX() - { - int mode = parameterStore.get("YX", "Mode").getI(); - - if (mode > 0 && mode < 5) - { - numDraw = 0; - } - else - { - makeDrawList(); - if (mode == 0) - cut(" Barrel ", sub, "==", BARREL); - else - { - cut(" Endcaps", sub, "!=", BARREL); - cut(" Station", station, "==", mode - 5); - } - } - } - - private void makeDrawListFZ() - { - int mode = parameterStore.get("FZ", "Mode").getI(); - - if (mode > 0 && mode < 4) - { - numDraw = 0; - } - else - { - makeDrawList(); - if (mode == 0) - cut(" Endcaps", sub, "!=", BARREL); - else - { - cut(" Barrel ", sub, "==", BARREL); - if (mode == 4) - cut(" Station", station, "<=", mode - 3); - else - cut(" Station", station, "==", mode - 3); - } - } - } - - protected ACoord getYXUser() - { - return getYXUser(0); - } - - private ACoord getYXUser(int flag) - { - makeDrawListYX(); - int numPieces = 13; - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double r = rho[list]; - double cosPhi = Math.cos(phi[list]); - double sinPhi = Math.sin(phi[list]); - double phiM = Math.rint(phi[list] / AMath.PI_BY_8) * AMath.PI_BY_8; - double cosPhiM = Math.cos(phiM); - double sinPhiM = Math.sin(phiM); - double d = length[list] / 2.; - double x = r * cosPhi; - double y = r * sinPhi; - - hv[0][i] = AMath.splitLineIntoPieces(new double[] { x + d * sinPhiM, x - d * sinPhiM }, numPieces); - hv[1][i] = AMath.splitLineIntoPieces(new double[] { y - d * cosPhiM, y + d * cosPhiM }, numPieces); - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYLINES); - } - - protected ACoord getFRUser() - { - return getYXUser(1).convertYXToFR().includePhiWrapAround("FR"); - } - - protected ACoord getRZUser() - { - makeDrawList(); - int[] sign = new int[numDraw]; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - - for (int i = 0; i < numDraw; i++) - { - double phiDiff = Math.abs(phi[listdl[i]] - phiMid); - - sign[i] = -1; - if (phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - sign[i] = 1; - } - return getXZRZUser(sign); - } - - protected ACoord getXZUser() - { - makeDrawList(); - cutMuonSector(sector); - int[] sign = new int[numDraw]; - int sect=(int)Math.round(parameterStore.get("XZ", "Phi").getD() / 22.5); - - for (int i = 0; i < numDraw; i++) - { - sign[i] = 1; - if (sector[listdl[i]] != sect) - sign[i] = -1; - } - return getXZRZUser(sign); - } - - protected ACoord getXZRZUser(int[] sign) - { - // int muonMode=APar.get("Data.MDT").getI(); - int muonMode = parameterStore.get("MDT", "Mode").getI(); - int numPoints; - - if (muonMode == 0) // circles - numPoints = 48; - else - numPoints = 2; // lines - - double[][][] hv = new double[2][numDraw][numPoints]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double rC = sign[i] * getSectorRho(sector[list], rho[list], phi[list]); - double zC = z[list]; - double d = driftR[list]; - - if (muonMode == 0) - { // circles - for (int j = 0; j < numPoints; j++) - { - hv[0][i][j] = zC + d * Math.cos(Math.PI * 2 * j / (numPoints - 1)); - hv[1][i][j] = rC + d * Math.sin(Math.PI * 2 * j / (numPoints - 1)); - } - } - else - { // lines - double radius = Math.sqrt(rC * rC + zC * zC); - double sinTheta = rC / radius; - double cosTheta = zC / radius; - - hv[0][i][0] = zC + d * sinTheta; - hv[1][i][0] = rC - d * cosTheta; - hv[0][i][1] = zC - d * sinTheta; - hv[1][i][1] = rC + d * cosTheta; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYLINES); - } - - protected ACoord getFZUser() - { - makeDrawListFZ(); - double[][][] hv = new double[2][numDraw][2]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - index[i] = list; - hv[0][i][0] = z[list]; - hv[0][i][1] = z[list]; - double deltaPhi = Math.atan2(length[list] / 2., rho[list]); - - hv[1][i][0] = Math.toDegrees(phi[list] - deltaPhi); - hv[1][i][1] = Math.toDegrees(phi[list] + deltaPhi); - } - return new ACoord(hv, index, this, ACoord.POLYLINES).includePhiWrapAround("FZ"); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AMuonData.java b/graphics/AtlantisJava/src/atlantis/data/AMuonData.java deleted file mode 100755 index 368a6a039886a4bb4a09bb6c4c1cd9e6a3f45b7b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AMuonData.java +++ /dev/null @@ -1,95 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; -import atlantis.utils.A4Vector; - -/** - * Reconstructed Muon - */ -public class AMuonData extends AHelixAODData -{ - private float[] chi2; - - AMuonData(AHashMap p, AEvent e) - { - super(p,e); - chi2=p.getFloatArray("chi2"); - } - - public String getParameterGroup() - { - return "Muon"; - } - - public float getchi2(int index) - { - return chi2[index]; - } - - public A4Vector get4Vector(int num, int[] list) - { - A4Vector sum = new A4Vector(); - for (int i = 0; i < num; ++i) - { - int k = list[i]; - A4Vector start = new A4Vector(); - start.setPtEtaPhiM(pT[k],eta[k],phi[k],0.1057); - sum.add(start); - } - - return sum; - } - - protected void applyCuts() - { - super.applyCuts(); - cut("CutsObjects", "MuonPt", " |ET|", pT); - cut("CutsObjects", "Muonchi2", " |chi2|", chi2); - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n PT="+String.format("%.3f",pT[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Px="+String.format("%.3f",pT[index]*Math.cos(phi[index]))+" GeV "+ - "\n Py="+String.format("%.3f",pT[index]*Math.sin(phi[index]))+" GeV "+ - "\n Pz="+String.format("%.3f",pT[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - String k = this.getStoreGateKey(); - String sgKey = k != null ? k : "n/a"; - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (id: " + id[index] + " index: " + index + ")"); - msg.append("\n storegate key: "); - msg.append(sgKey); - msg.append("\n PT = "); - msg.append(String.format("%.3f",pT[index])); - msg.append(" GeV\n P = "); - msg.append(String.format("%.3f",Math.abs(pT[index]/Math.cos(AMath.lambda(eta[index]))))); - msg.append(" GeV\n "); - msg.append(AMath.ETA); - msg.append(" = "); - msg.append(String.format("%.3f",eta[index])); - msg.append("\n "); - msg.append(AMath.PHI); - msg.append(" = "); - msg.append(String.format("%.3f",Math.toDegrees(phi[index]))); - msg.append(AMath.DEGREES); - msg.append(" (" + String.format("%.3f",phi[index]) + " rad)"); - msg.append("\n chi2 = "); - msg.append(chi2[index]); - - return msg.toString(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AMuonHitData.java b/graphics/AtlantisJava/src/atlantis/data/AMuonHitData.java deleted file mode 100644 index 85717f5fa904875fbcd9923d451a9688dc4dd853..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AMuonHitData.java +++ /dev/null @@ -1,192 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.utils.*; -import atlantis.parameters.*; - -public abstract class AMuonHitData extends AHitData { - - protected float[] rho; - protected float[] phi; - protected float[] x; - protected float[] y; - protected float[] z; - protected int[] sector; - protected int[] station; - protected boolean[] measuresPhi; - - public static final int DOES_NOT_MEASURE_PHI=0; - public static final int MEASURES_PHI=1; - - // remove when go to compact id ( if compact id was in a sensible form) - String[] identifier; - - AMuonHitData(AHashMap p, AEvent e) { - super(p,e); - x=p.getFloatArray("x"); - y=p.getFloatArray("y"); - z=p.getFloatArray("z"); - rho=new float[numData]; - phi=new float[numData]; - for(int i=0; i<numData; ++i) { - rho[i]=(float)Math.sqrt(x[i]*x[i]+y[i]*y[i]); - phi[i]=(float)Math.atan2(y[i], x[i]); - if(phi[i]<0.) phi[i]+=AMath.TWO_PI; - } - identifier=p.getStringArray("identifier"); - station=new int[numData]; - sector=new int[numData]; - measuresPhi=new boolean[numData]; - for(int i=0; i<numData; ++i) { - // should be moved to AHitData - sub[i]=getSub(i); - sector[i]=getSector(i); - station[i]=getStation(i); - measuresPhi[i]=getMeasuresPhi(i); - } - } - - /** - * Get the name used for associating this datatype/collection. For the - * muon hits no storegate key is used. - * @return - */ - public String getFullName() { - return getName(); - } - - protected int internalColor() - { - int numColorTypes = super.internalColor(); - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - if(colorFunction == numColorTypes + 1) // colour by Track Segment - { - colorBy(getSegments()); - } - return numColorTypes + 1; - - } // internalColor() ---------------------------------------------------- - - - abstract protected int getStation(int index); - - abstract public int getSector(int index); - - abstract protected int getSub(int index); - - abstract protected boolean getMeasuresPhi(int index); - - protected String getSegments() { - AEnumeratorParameter key = (AEnumeratorParameter) parameterStore.get("MuonSegment", "MuonSegmentCollections"); - - return "MuonSegment" + key.getCurrentText(); - } - - public int getRZSign(int index) { - double phiMid=Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff=Math.abs(phi[index]-phiMid); - - int sign=-1; - if(phiDiff<Math.PI/2.||phiDiff>3*Math.PI/2.) - sign=1; - return sign; - } - - protected String getReconstructedTracks() { - AData tracks = event.getTrackData("MuonTrack"); - if (tracks == null) { - return null; - } else { - return tracks.getName() + tracks.getStoreGateKey(); - } - } - - // get the distance of closest approach of the inifinite line representing the - // drift tube axis to Z axis - // Normal this is rho of the hit, but need not be for non standard modules - // (e.g. near feet) - static double getSectorRho(int sector, double rho, double phi) { - return rho*Math.abs(Math.cos(phi-sector*AMath.PI_BY_8)); - } - - protected void applyCuts() { - cutIndex(); - cutSimulatedTracks(); - cutReconstructedTracks(); - cutSegments(); - } - - // keep only muon hits in the input muon sectors - protected void cutMuonSector(int[] sector) { - AParameter p=parameterStore.get("XZ", "Phi"); - - // display muon data when phi is in the middle of a sector - if(p.getD() % 22.5 < 1e-2) { - int sect=(int)Math.round((p.getD() % 360.) / 22.5); - - int num=0; - - for(int i=0; i<numDraw; i++) { - int s=sector[listdl[i]]; - - if(s==sect||s==sect-8||s==sect+8) - listdl[num++]=listdl[i]; - } - numDraw=num; - } else { - numDraw=0; - } - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+"\n"+ - AMath.RHO+" = "+String.format("%.3f",rho[index])+"\n "+ - "z = " + String.format("%.3f",z[index]) + "cm\n"+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - - String temp = getNameScreenName() + " (id: " + identifier[index] + " index: " + index + ")" + - "\n " + AMath.RHO + " = " + String.format("%.3f",rho[index]) + " cm" + - "\n " + AMath.PHI + " = " + String.format("%.3f",Math.toDegrees(phi[index])) + - AMath.DEGREES + " (" + String.format("%.3f",phi[index]) + " rad)" + - "\n z = " + String.format("%.3f",z[index]) + " cm"; - - if(sector[index]!=-1) - { - temp += "\n sector = " + sector[index]; - } - - return temp; - } - - protected void setType() { //What is this doing?? - int[][] recon=event.getAssociationManager().get(getName(),getReconstructedTracks()); - for(int i=0; i<numData; i++) { - if( (recon!=null&&recon[i]!=null)) - type[i]=1; - else - type[i]=0; - } - } - - /** - * cut hits if connected/unconnected to reconstructed tracks - */ - protected void cutReconstructedTracks() - { - int cutOption = parameterStore.get("CutsMuon", "HitsByRTr").getI(); - cutByAssociationTo(getReconstructedTracks(), getName(), cutOption); - } - - /** - * cut hits if connected/unconnected to reconstructed segments - */ - protected void cutSegments() - { - int cutOption = parameterStore.get("CutsMuon", "HitsBySegment").getI(); - cutByAssociationTo(getSegments(), getName(), cutOption); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AMuonROIData.java b/graphics/AtlantisJava/src/atlantis/data/AMuonROIData.java deleted file mode 100755 index 567f2f9cf5ab7e116a4d34c6adf708bf3cf97a23..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AMuonROIData.java +++ /dev/null @@ -1,34 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.utils.AHashMap; - -/** - * - * Muon Region Of Interest - * - * @author Zdenek Maxa, Qiang Lu, Juergen Thomas - */ -public class AMuonROIData extends AROIData -{ - AMuonROIData(AHashMap p, AEvent e) - { - super(p,e); - } // AMuonROIData() ------------------------------------------------------ - - public String getParameterGroup() - { - return "MuonROI"; - } // getParameterGroup() ------------------------------------------------ - - public String getName() - { - return "MuonROI"; - } // getName() ---------------------------------------------------------- - - public String getNameScreenName() - { - return "MuonROI"; - } // getNameScreenName() ------------------------------------------------ - -} // class AMuonROIData ====================================================== diff --git a/graphics/AtlantisJava/src/atlantis/data/AMuonSegmentData.java b/graphics/AtlantisJava/src/atlantis/data/AMuonSegmentData.java deleted file mode 100755 index 96adc598bcf40afe35e5ef93f34f84ad63f244f3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AMuonSegmentData.java +++ /dev/null @@ -1,56 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AHashMap; - -/** - * - * @author Eric Jansen - */ -public class AMuonSegmentData extends ASegmentData { - - /** Creates a new instance of AMuonSegmentData */ - AMuonSegmentData(AHashMap p, AEvent e) { - super(p,e); - String assocKey = getName() + getStoreGateKey(); - event.getAssociationManager().add(new AAssociation(assocKey, "MDT", numHits, hits, event)); - event.getAssociationManager().add(new AAssociation(assocKey, "RPC", numHits, hits, event)); - event.getAssociationManager().add(new AAssociation(assocKey, "TGC", numHits, hits, event)); - event.getAssociationManager().add(new AAssociation(assocKey, "CSC", numHits, hits, event)); - } - - public void makeDrawList() { - super.makeDrawList(); - - if (currentProjection instanceof AProjectionYX) { - if (parameterStore.get("YX", "Mode").getI() != AProjectionYX.MODE_STANDARD) { - numDraw = 0; - } else { - int num = 0; - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - - // Anything beyond z=13m or below r=6.5m is endcap - if (Math.sqrt(x[j]*x[j] + y[j]*y[j]) > 650. - && Math.abs(z[j]) < 1300.) { - listdl[num++] = j; - } - } - numDraw = num; - } - } - } - - public String getParameterGroup() { - return "MuonSegment"; - } - - public String getName() { - return "MuonSegment"; - } - - public String getNameScreenName() { - return "MuonSegment"; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AMuonTrackData.java b/graphics/AtlantisJava/src/atlantis/data/AMuonTrackData.java deleted file mode 100644 index cd768ea2a38db3f71b06166f98315ff02c4657f4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AMuonTrackData.java +++ /dev/null @@ -1,200 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.canvas.AWindow; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjection; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionVP; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; -import atlantis.utils.AAtlantisException; -import atlantis.utils.ALogger; - - -/** - * - * @author Eric Jansen - */ -public class AMuonTrackData extends ATrackData { - - private static ALogger logger = ALogger.getLogger(AMuonTrackData.class); - - protected float[] phi0; - protected float[] pT; - protected float[] cotTheta; - protected int[] author; - - /** Creates a new instance of AMuonTrackData */ - AMuonTrackData(AHashMap p, AEvent e) throws AAtlantisException { - super(p,e); - String assocKey = getName() + getStoreGateKey(); - if(p.get("numHits") != null) { - int[] numHits = p.getIntArray("numHits"); - int[] hits = p.getIntArray("hits"); - - event.getAssociationManager().add(new AAssociation(assocKey, "MDT", numHits, hits,event)); - event.getAssociationManager().add(new AAssociation(assocKey, "RPC", numHits, hits,event)); - event.getAssociationManager().add(new AAssociation(assocKey, "TGC", numHits, hits,event)); - event.getAssociationManager().add(new AAssociation(assocKey, "CSC", numHits, hits,event)); - } - - phi0 = p.getFloatArray("phi0"); - pT = p.getFloatArray("pt"); - cotTheta = p.getFloatArray("cotTheta"); - author = p.getUnsureIntArray("trackAuthor"); - } - - public String getParameterGroup() { - return "MuonTrack"; - } - - public String getName() { - return "MuonTrack"; - } - - public String getNameScreenName() { - return "MuonTrack"; - } - - protected void finalizeConstruction() { - super.finalizeConstruction(); -/* - // needs ZVTx - h = new AHelix[numData]; - for(int i = 0; i < numData; ++i) { - double p = AMath.getPFromPttL(pT[i], cotTheta[i]); - double xVtx = parameterStore.get("Event", "XVtx").getD(); - double yVtx = parameterStore.get("Event", "YVtx").getD(); - double phiVtx = Math.atan2(yVtx, xVtx); - double rho = Math.sqrt(xVtx * xVtx + yVtx * yVtx); - double d0 = -rho * Math.sin(phi0[i] - phiVtx); - // correct for average energy loss - double pTCorrected = pT[i] * (p + 3.7) / p; - - h[i] = new AHelix((float)d0, - (float)(parameterStore.get("Event", "ZVtx").getD()), - (float)Math.toDegrees(phi0[i]), cotTheta[i], (float)pTCorrected); - //calculatePhiCorrection(i); - } -*/ - } - - public void draw(AWindow window, AGraphics ag, AProjection2D projection) - { - if(projection instanceof AProjectionVP - && parameterStore.get(PARAMETER_GROUP, "DrawnAs").getI() != DRAW_NEWHELIX) - { - ag.draw(window.calculateDisplay(getVPUser(window, projection))); - } - else - super.draw(window, ag, projection); - } - - protected ACoord getVPUser(AWindow window, AProjection projection) - { - makeDrawList(); - double[][][] hv = new double[2][2*numDraw][]; - int[] index = new int[2 * numDraw]; - int num = 0; - for (int j=0; j<numDraw; j++) { - int list = listdl[j]; - ADHelix dhelix = new ADHelix(h[list]); - double s1 = dhelix.getAStart(); - double s2 = 179.; - // hardwire projection.getMinRho() == 2. for now - s1 = dhelix.intersectWithRadialCylinder(((AProjection2D)projection).getMinRho(), s1, s2); - double sEnd = dhelix.intersectWithCylinder(true, AProjectionVP.getRhoVPlot(), - true, AProjectionVP.getZVPlot()); - s2 = Math.max(Math.min(s2, sEnd), s1); - // if the whole helix is to be drawn (which are unusual - // helices, shorten it a little to avoid wraparound problems - if (s1 == 0. && s2 == 180.) s2 = 179.; - - if (parameterStore.get("VP", "ShortV").getStatus() && !parameterStore.get("Data", "S3D").getStatus()) { - s1 = s2 - parameterStore.get("VP", "ShortV").getD() * (s2 - s1); - } - - // by Zdenek: - // if this condition is not entered, hv array containing coordinates - // remains empty and Atlantis will crash with NullPointerException - // in AWindow.calculateUser(ACoord user) - // magic constants here (e.g. s2) need to be understood and this - // method best reimplemented - for(int sign=-1; sign<=1; sign+=2) { - // ugly must change structure at some point - AProjectionVP.sign = sign; - ACoord pointsOnHelix; - if (s2 > s1) { - pointsOnHelix = dhelix.drawHelix(window, (AProjection2D) projection, s1, s2); - hv[0][num] = pointsOnHelix.hv[0][0]; - hv[1][num] = pointsOnHelix.hv[1][0]; - } else { - hv[0][num] = new double[0]; - hv[1][num] = new double[0]; - } - index[num] = list; - num++; - } - } - - // by Zdenek: - // condition to prevent NullPointerException in AWindow.calculateUser() - // see previous comment ... - // this condition should be removed completely 'bug in helix' - // problem is understood - ACoord coord = null; - if(hv[0].length > 0 && hv[0][0] == null) - { - logger.warn("AMuonTrackData.getVPUser(): \"" + this.getName() + - ":" + this.getStoreGateKey() + "\" can't be drawn in eta-phi"); - coord = ACoord.NO_DATA; - } - else - { - coord = new ACoord(hv, index, this, ACoord.SMOOTH_POLYLINES); - } - return window.calculateUser(coord).includePhiWrapAround(projection.getName()); - } - - - - private float[] getEta() - { - float[] eta = new float[numData]; - if(polylinedTrack) - { - for(int i = 0; i < numData; i++) - { - if(h!=null && h[i]!=null) eta[i] = (float) h[i].eta(); - else eta[i] = (float) AParameterUtilities.eta(z[i][0], rho[i][0]); - } - } - else - { - for(int i = 0; i < numData; i++) - { - eta[i] = (float) h[i].eta(); - } - - } - - return eta; - } - - - - protected void applyCuts() { - cutIndex(); - cut("CutsInDet", "Pt", " |Pt|", pT); - cut("CutsMuon", "Pt", " |Pt|", pT); - cut("CutsInDet", "trackAuthor", " Author", author); - cutPhi(phi0); - if(parameterStore.get("CutsATLAS", "CutEta").getStatus()) - { - cutEta(getEta()); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AOldHelix.java b/graphics/AtlantisJava/src/atlantis/data/AOldHelix.java deleted file mode 100755 index a3f490c571707dba7a2a690cdbf460e2f5972913..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AOldHelix.java +++ /dev/null @@ -1,338 +0,0 @@ -package atlantis.data; - -import atlantis.globals.AGlobals; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.utils.AMath; -import atlantis.utils.A3Vector; -import atlantis.utils.ALogger; - -import static java.lang.Math.PI; - -/** - * This is a convenience class to group together the six helix parameters. - */ -public class AOldHelix { - - private final static ALogger logger = ALogger.getLogger(AOldHelix.class); - - private static final int SIZE=5; - private static final boolean DEBUG = false; - private static final APar parameterStore = APar.instance(); - // C - constant depending on the magnetic field, constant proportional - // to curvature in the magnetic field - private static final double C; - static { - AParameter curvatureParameter = parameterStore.get("Event", "Curvature"); - if (curvatureParameter!=null) { - C = curvatureParameter.getD(); - } - else { - C = 100/0.6;; - logger.error("Curvature parameter not found, defaulting to "+C); - } - } - - // These fields are public but final so cannot be altered. - /** Distance between circle and (0,0) at point of closest approach (PCA). */ - public final double d0; - /** Z of circle at PCA. */ - public final double z0; - /** phi0 of track at PCA [degrees] */ - public final double phi0; - /** Dip of track = Pz/pTTrack =0.5 * ( E - 1/E ) : constant along the helix */ - public final double tL; - /** Transverse momentum * charge. */ - public final double pT; - /** ln( Pz/pTTrack + SQRT[(Pz/pTTrack)**2 +1 ] */ - public final double eta; - /** Angle between (0,0) and vertex as seen from the circle center [degrees]? - * For helices starting at PCA, startPhi=0. This is the case for reconstructed - * helices that are not yet associated to a secondary vertex or are - * drawn to PCA. - * Mutable because it is changed when tracks are used to fit a vertex. */ - double startPhi; - - // negative end vertex means none exits - double rhoVertex = 0.0; - private double rhoEndVertex = -1.0; - - private int numHits; - - double[][] cov=null; - - AOldHelix() { - this(0, 0, 0, 0, 0); - }; - - /** Standard Helix constructor without end vertex */ - AOldHelix(float rhoVertex, float phiVertex, float zVertex, - float pTTrack, float phiTrack, float etaTrack, int charge ) { - this(rhoVertex,phiVertex,zVertex,pTTrack,phiTrack,etaTrack,charge,-1); - } - - /** - * Standard Helix constructor with end vertex. - * - * Note: this method is not called when creating helix representation of - * reconstructed InDet tracks, but is called for simulated InDet tracks. - * - * @param rhoVertex rho of vertex from which track starts - * @param phiVertex phi of vertex from which track starts - * @param zVertex Z of vertex from which track starts - * @param pTTrack transverse track momentum > 0 - * @param phiTrack phi of track seen from vertex - * @param etaTrack eta = -ln(tg(theta/2)), theta = arctg(pTTrack/Pz) = 2*arctg( e**(-eta)) - * @param charge charge = +1 or -1 - * @param rhoEndVertex - */ - AOldHelix(float rhoVertex, float phiVertex, float zVertex, - float pTTrack, float phiTrack, float etaTrack, int charge, float rhoEndVertex ) { - /* - * Derived: - * rC = signed radius of circle (positive for positive particle, which - * loops in the clockwise direction in the standard xy projection, - * given that Bz is positive in the ATLAS solenoid) - * xC = x position of center of circle - * yC = y position of center of circle - * E = E**eta - * charge=1 if icode>=0 else charge=-1 - * - * Calculation: - * rC = C*pTTrack C = 100./0.6 - * xC = rhoVertex*cos(phiVertex) + rC*sin(phiTrack) - * yC = rhoVertex*sin(phiVertex) - rC*cos(phiTrack) - * tl = Pz/pTTrack = 0.5 * ( E - 1/E ) - * d0 = rC - sqrt(xC*xC + yC*yC) - * startPhi = pi/2 - phiTrack + atan2(yC,xC) modify startPhi to: -pi/2 < startPhi < pi/2 - * z0 = zVertex - rC*startPhi*tl - * phi0 = phiTrack + startPhi - * pCharge = charge*pTTrack - * Change startPhi and phi0 from radians to degrees. - * - */ - double rC=C*pTTrack*charge; - if (DEBUG) logger.debug("AOldHelix: charge, rC = "+charge+", "+rC); - double xC=rhoVertex*Math.cos(phiVertex)+rC*Math.sin(phiTrack); - double yC=rhoVertex*Math.sin(phiVertex)-rC*Math.cos(phiTrack); - if (DEBUG) logger.debug("AOldHelix: xCyC"+" "+xC+" "+yC); - double e=Math.exp(etaTrack); - tL=0.5*(e-1./e); - eta = etaTrack; - d0=rC-charge*Math.sqrt(xC*xC+yC*yC); - phiTrack = (float) AMath.nearestPhiRadians(phiTrack); - double temp=Math.atan2(yC, xC); - temp = AMath.nearestPhiRadians(temp); - double startPhiRad=charge*(PI/2)-phiTrack+temp; - startPhiRad = AMath.nearestPhiRadians(startPhiRad, 0); - z0=zVertex-rC*startPhiRad*tL; - phi0=Math.toDegrees(phiTrack+startPhiRad); - startPhi=charge*Math.toDegrees(startPhiRad); - pT=charge*pTTrack; - - // keep rhoEndVertex for simulated tracks with a daughter - this.rhoVertex=rhoVertex; - this.rhoEndVertex = rhoEndVertex; - } - - /** - * Construct AOldHelix object. - * @param d0 - * @param z0 - * @param phi0 [degrees] - * @param tL - * @param pT - */ - AOldHelix(float d0, float z0, float phi0, - float tL, float pT) { - this.d0=d0; - this.z0=z0; - this.phi0=AMath.nearestPhiDegrees(phi0); - this.tL=tL; - this.eta = calculateEta(this.tL); - this.pT=pT; - startPhi=0.; - } - - AOldHelix(float d0, float z0, float phi0, - float tL, float pT, int numHits) { - this(d0, z0, phi0, tL, pT); - this.numHits=numHits; - } - - AOldHelix(float d0, float z0, float phi0, - float tL, float pT, float[][] c) { - this.d0=d0; - this.z0=z0; - this.phi0=phi0; - this.tL=tL; - this.eta = calculateEta(this.tL); - this.pT=pT; - this.startPhi=0.; - - cov=new double[c.length][]; - if(c.length!=SIZE) - logger.error("Helix error "+c.length); - for(int i=0; i<c.length; ++i) { - if(c[i].length!=SIZE) - logger.error("Helix error "+c.length); - cov[i]=new double[c[i].length]; - } - for(int i=0; i<c.length; ++i) - for(int j=0; j<c[i].length; ++j) - cov[i][j]=c[i][j]; - } - - AOldHelix(float d0, float z0, float phi0, - float tL, float pT, int numHits, float[][] c) { - this(d0, z0, phi0, tL, pT, c); - this.numHits=numHits; - } - - public double[] getPar() { - return new double[] {d0, z0, Math.toRadians(phi0), tL, 1./pT}; - } - - public double[][] getCov() { - return cov; - } - - public double getRhoEndVertex(){ - return rhoEndVertex; - } - -/** - * Set Phi start so that the track will originate from the point on the - * reconstructed track in the YX plane which is closest to the point (Vx,Vy). - * Only used when drawing tracks originating from a reconstructed vertex. - */ - public void setPhiStartByXYPoint(double Vx, double Vy) { - //construct a local super object to get the xC and yC numbers - ADHelix Dh=new ADHelix(this); - // do the calculation to find the starting angle - double Xc=Dh.getxC(); - double Yc=Dh.getyC(); - - double a=-1.*(Vx-Xc); - double b=-1.*(Vy-Yc); - - double pTTrack=pT; - double phiTrack=Math.toRadians(phi0); - - double charge=1; - if(pTTrack<0.0) charge=-1.; - - double temp=Math.atan2(b, a); - temp = AMath.nearestPhiRadians(temp); - double sPhi=charge*(PI/2)-phiTrack+temp; - sPhi = AMath.nearestPhiRadians(sPhi, 0); - sPhi=charge*Math.toDegrees(sPhi); - startPhi=Math.abs(sPhi); - } - - public String toString() { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = ""; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n PT="+String.format("%.3f",Math.abs(pT))+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta)+"\n "+ - AMath.PHI+" = "+String.format("%.3f",phi0)+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Px="+String.format("%.3f",Math.abs(pT)*Math.cos(Math.toRadians(phi0)))+" GeV "+ - "\n Py="+String.format("%.3f",Math.abs(pT)*Math.sin(Math.toRadians(phi0)))+" GeV "+ - "\n Pz="+String.format("%.3f",Math.abs(pT)*Math.sinh(eta))+" GeV "+ - "\n Charge = " + (int)(pT/Math.abs(pT)); - return output; - } - - String s=""; - double f=1.; - - if(numHits>0) - s+="\n numHits = "+numHits; - // if(Math.abs(d0)<0.1) f=10000.; - s+="\n d0 = "+String.format("%.3f",f*d0); - if(cov!=null) s+=" "+AMath.PLUSMINUS+" "+String.format("%.3f",f*Math.sqrt(cov[0][0])); - if(f>100) - s+=" um"; - else - s+=" cm"; - f=1.; - // if(Math.abs(z0)<0.1) f=10000.; - s+="\n z0 = "+String.format("%.3f",f*z0); - if(cov!=null) s+=" "+AMath.PLUSMINUS+" "+String.format("%.3f",Math.sqrt(f*cov[1][1])); - if(f>100) - s+=" um"; - else - s+=" cm"; - - double zVtx = parameterStore.get("Event", "ZVtx").getD(); - //if(Math.abs(z0-zVtx) < 0.1) f=10000.; - s+="\n |z0-zVtx| = "+String.format("%.3f",f*Math.abs(z0-zVtx)); - if(f>100) - s+=" um"; - else - s+=" cm"; - - s+="\n phi0 = "+String.format("%.3f",phi0); - if(cov!=null) - { - s += " " + AMath.PLUSMINUS + " " + - String.format("%.3f",Math.toDegrees(Math.sqrt(cov[2][2]))) + - AMath.DEGREES; - } - else - { - s += AMath.DEGREES; - - } - s+= " (" + String.format("%.3f",Math.toRadians(phi0)); - if(cov != null) - { - s += " " + AMath.PLUSMINUS + " " + - String.format("%.3f",Math.toRadians(Math.sqrt(cov[2][2]))) + " rad)"; - } - else - { - s += " rad)"; - } - - s+="\n "+AMath.ETA+" = "+String.format("%.3f",eta); - if(cov!=null) { - // based on the relation between eta and ctgTheta - double etaError = Math.sqrt(cov[3][3] / (tL * tL + 1.0)); - s+=" "+AMath.PLUSMINUS+" "+String.format("%.3f",etaError); - } - s+="\n tL = "+String.format("%.3f",tL); - if(cov!=null) s+=" "+AMath.PLUSMINUS+" "+String.format("%.3f",Math.sqrt(cov[3][3])); - s+="\n pT = "+String.format("%.2f",pT) + " GeV"; - if(cov!=null) { - double sigmaPt=Math.abs(1./(Math.abs(1./pT)+Math.sqrt(cov[4][4]))-Math.abs(pT)); - - s+=" "+AMath.PLUSMINUS+" "+String.format("%.3f",sigmaPt)+" GeV"; - } - if(pT<0.) - s+="\n p = "+String.format("%.2f",-AMath.getPFromPttL(pT,tL)); - else - s+="\n p = "+String.format("%.2f",AMath.getPFromPttL(pT,tL)); - s+= " GeV"; - - return s; - } - - public A3Vector getP() { - double pTrans=Math.abs(pT); - double phi=Math.toRadians(phi0); - return new A3Vector(pTrans*Math.cos(phi), pTrans*Math.sin(phi), pTrans*tL); - } - - /** eta = -ln(tg theta/2), so eta = -ln(sqrt(ctgtheta*ctgtheta+1)-ctgtheta) */ - private static double calculateEta(double ctgTheta) { - double eta; - eta = -Math.log(Math.sqrt(ctgTheta * ctgTheta + 1.0) - ctgTheta); - return eta; - } - -} - diff --git a/graphics/AtlantisJava/src/atlantis/data/APDGTable.java b/graphics/AtlantisJava/src/atlantis/data/APDGTable.java deleted file mode 100755 index 5fde73d3136128d50e24313b7a2b4be61ef7f152..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/APDGTable.java +++ /dev/null @@ -1,107 +0,0 @@ -package atlantis.data; - -import atlantis.globals.AGlobals; -import atlantis.utils.ALogger; -import atlantis.utils.AUtilities; -import atlantis.utils.xml.*; -import java.util.*; -import java.io.File; -import java.io.InputStream; -import org.w3c.dom.*; -import javax.xml.parsers.*; - -/** - * Read a PDG table from the file pdg.xml and provide - * basic accessor functions to its particles - */ -public final class APDGTable { - - //The logger - private final static ALogger logger = ALogger.getLogger(APDGTable.class); - - //Wether to validate the XML document - private final static boolean VALIDATION=true; - - //The particle table linked by PDG code - private final static Map<Integer, AParticle> particles = new HashMap<Integer, AParticle>(100); - - //Always read in the Hashmap - static { - readPDG(APDGTable.getFileInCurrentUserThenAtlantisHome("configuration","pdg.xml")); - } - - //Read in the PDG table from a file - private static void readPDG(String fileName) { - try { - DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); - - factory.setValidating(VALIDATION); - DocumentBuilder parser=factory.newDocumentBuilder(); - - parser.setErrorHandler(new AXMLErrorHandler()); - InputStream is = AUtilities.getFileAsStream(fileName); - Node pdg=parser.parse(is).getDocumentElement(); - NodeList particlesList=pdg.getChildNodes(); - int particlesCount=particlesList.getLength(); - - for(int i=0; i<particlesCount; i++) { - Node particle=particlesList.item(i); - - if(particle.getNodeType()==Node.ELEMENT_NODE) { - AParticle p=new AParticle(particle); - - particles.put(new Integer(p.getCode()), p); - } - } - } catch(Exception e) { - logger.error("Failed reading PDG table", e); - } - } - - public static int getCharge(int code) { - int sign=code/Math.abs(code); - AParticle p=particles.get(new Integer(Math.abs(code))); - - if(p!=null) - return p.getCharge()*sign; - else throw new ParticleNotFoundError(code); - } - - public static String getName(int code) { - AParticle p=particles.get(new Integer(Math.abs(code))); - int sign=1; - - if(code<0) sign=-1; - if(p!=null) - return p.getName(sign); - else throw new ParticleNotFoundError(code); - } - - public static int getParticleType(int code) { - AParticle p=particles.get(new Integer(Math.abs(code))); - - if(p!=null) - return p.getType(); - else throw new ParticleNotFoundError(code); - } - - //Declare our own error type here - no special implementation - public static class ParticleNotFoundError extends Error { - - //Only implement Error constructor with particle code - ParticleNotFoundError(int code){ - super("Particle with code "+code+" not found in PDG table"); - } - } - -public static String getFileInCurrentUserThenAtlantisHome(String directory, String name) -{ - File user = new File(name); - if (!user.canRead()) - { - return AGlobals.instance().getHomeDirectory() + directory + - System.getProperty("file.separator") + name; - } - return name; -}; -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AParticle.java b/graphics/AtlantisJava/src/atlantis/data/AParticle.java deleted file mode 100755 index 8007ae2c46f0413ce84712d629335e5c5a42873d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AParticle.java +++ /dev/null @@ -1,57 +0,0 @@ -package atlantis.data; - - -import atlantis.output.AExceptionHandler; - -import org.w3c.dom.*; - - -/** - * This class is used to store the properties of a particle. Used by APDGTable. - */ -public class AParticle { - private String name; - private int charge; - private int type; - private int code; - - private String[] chargeRep=new String[] { "-", "0", "+"}; - - public AParticle(Node node) { - NamedNodeMap atts=node.getAttributes(); - - try { - charge=Integer.parseInt(atts.getNamedItem("charge").getNodeValue()); - type=Integer.parseInt(atts.getNamedItem("type").getNodeValue()); - code=Integer.parseInt(atts.getNamedItem("code").getNodeValue()); - name=atts.getNamedItem("name").getNodeValue(); - } catch(NumberFormatException e) { - AExceptionHandler.processException("PDG error in Particle Node: "+node, e); - } - } - - public int getCharge() { - return charge; - } - - public int getType() { - return type; - } - - public int getCode() { - return code; - } - - public String getName() { - return name; - } - - public String getName(int sign) { - if(charge!=0) { - if(name.equals("Proton")&&sign==1) return "Proton"; - if(name.equals("Proton")&&sign==-1) return "Antiproton"; - return name+chargeRep[charge*sign+1]; - } else - return name; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/APhotonData.java b/graphics/AtlantisJava/src/atlantis/data/APhotonData.java deleted file mode 100755 index 7f942031f0969beac7441c980b5573667a1f4db3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/APhotonData.java +++ /dev/null @@ -1,166 +0,0 @@ -package atlantis.data; - -import java.util.Vector; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; -import atlantis.utils.A4Vector; - -/** - * Reconstructed Photon - */ -public class APhotonData extends AAODData -{ - private enum isEMe { Tight, Loose, none } - - private int[] isEM; - - private Vector<Enum> isEMEnum = new Vector<Enum>(); - private String[] label; - - APhotonData(AHashMap p, AEvent e) - { - super(p,e); - String[] isEMString=p.getUnsureStringArray("isEMString"); - label=p.getUnsureStringArray("label"); - isEM=p.getUnsureIntArray("isEM"); - - if(isEMString!=null) - { - for(String s : isEMString) - { - try { - isEMEnum.add(isEMe.valueOf(s)); - } - catch(IllegalArgumentException q) { - isEMEnum.add(isEMe.none); - } - } - } - else - { - for(int i=0;i<numData;i++) - { - isEMEnum.add(isEMe.none); - } - } - } - - public String getParameterGroup() - { - return "Photon"; - } - - public String getName() - { - return "Photon"; - } - - public String getisEMEnum(int index) - { - return isEMEnum.get(index).toString(); - } - - public int getisEM(int index) - { - return isEM[index]; - } - - public String getlabel(int index) - { - return label[index]; - } - - public A4Vector get4Vector(int num, int[] list) - { - A4Vector sum = new A4Vector(); - for (int i = 0; i < num; ++i) - { - int k = list[i]; - A4Vector start = new A4Vector(); - start.setPtEtaPhiM(pT[k],eta[k],phi[k],0); - sum.add(start); - } - return sum; - } - - protected void applyCuts() - { - super.applyCuts(); - cut("CutsObjects", "PhotonPt", " |ET|", pT); - - // because of the retriever bug, currently 2048 means 0 for isEM - // remove this for block when the bug is fixed - if(isEM != null) - { - for(int i=0; i<isEM.length; i++) - { - if(isEM[i]==2048) - isEM[i] = 0; - } - } - - cut("CutsObjects", "PhotonisEM", " isEM", isEM); - - if (parameterStore.get("CutsObjects", "PhotonisEMString").getStatus()) - { - int cutSub = parameterStore.get("CutsObjects", "PhotonisEMString").getI(); - cutArrayEnum(isEMEnum, cutSub, "Photon isEMString"); - } - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n PT="+String.format("%.3f",pT[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Px="+String.format("%.3f",pT[index]*Math.cos(phi[index]))+" GeV "+ - "\n Py="+String.format("%.3f",pT[index]*Math.sin(phi[index]))+" GeV "+ - "\n Pz="+String.format("%.3f",pT[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - String k = this.getStoreGateKey(); - String sgKey = k != null ? k : "n/a"; - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (id: " + id[index] + " index: " + index + ")"); - msg.append("\n storegate key: "); - msg.append(sgKey); - msg.append("\n PT = "); - msg.append(String.format("%.3f",pT[index])); - msg.append(" GeV\n P = "); - msg.append(String.format("%.3f",Math.abs(pT[index]/Math.cos(AMath.lambda(eta[index]))))); - msg.append(" GeV\n "); - msg.append(AMath.ETA); - msg.append(" = "); - msg.append(String.format("%.3f",eta[index])); - msg.append("\n "); - msg.append(AMath.PHI); - msg.append(" = "); - msg.append(String.format("%.3f",Math.toDegrees(phi[index]))); - msg.append(AMath.DEGREES); - msg.append(" (" + String.format("%.3f",phi[index]) + " rad)"); - - if (isEM != null) - { - msg.append("\n isEM = "); - msg.append(isEM[index]); - } - if (label != null) - { - msg.append("\n label = "); - msg.append(label[index]); - } - - return msg.toString(); - } - -} - diff --git a/graphics/AtlantisJava/src/atlantis/data/APixelClusterData.java b/graphics/AtlantisJava/src/atlantis/data/APixelClusterData.java deleted file mode 100644 index acbe38d5856d632137ceeb4f9ccd4891e4b0deb9..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/APixelClusterData.java +++ /dev/null @@ -1,403 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjectionVP; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - -/** - * PixelCluster - Pixel clusters, as SiCluster but for Pixels - * reads in PixelCluster datatype - */ -public class APixelClusterData extends AHitData -{ - // read in from event file - private float[] x; - private float[] y; - private float[] z; - private float[] widthx; - private float[] widthy; - private int[] etaModule; - private int[] phiModule; - private float[] eloss; - - // calculated - private float[][] rho; - private float[][] phi; - private int[] layer; - - public static final int U_CLUSTER = -1; - public static final int PHI_CLUSTER = 0; - public static final int V_CLUSTER = 1; - public static final int ENDCAP_MINUS = 0; - public static final int BARREL = 1; - public static final int ENDCAP_PLUS = 2; - - - public String getParameterGroup() - { - return "PixelCluster"; - } - - public String getName() - { - return "PixelCluster"; - } - - public String getNameScreenName() - { - return "PixelCluster"; - } - - public float[] getX() - { - return x; - } - - public float[] getY() - { - return y; - } - - public float[] getZ() - { - return z; - } - - APixelClusterData(AHashMap p, AEvent e) - { - super(p,e); - x = p.getFloatArray("x0"); - y = p.getFloatArray("y0"); - z = p.getFloatArray("z0"); - widthx = p.getFloatArray("widthx"); - widthy = p.getFloatArray("widthy"); - eloss = p.getFloatArray("eloss"); - - rho = new float[2][numData]; - phi = new float[2][numData]; - - layer = new int[numData]; - for (int i = 0; i < numData; ++i) - { - sub[i] = getSub(id[i]); - layer[i] = getLayer(id[i]); - } - - etaModule = (p.get("etaModule") != null) ? p.getIntArray("etaModule") : null; - phiModule = (p.get("phiModule") != null) ? p.getIntArray("phiModule") : null; - - } // APixelClusterData() --------------------------------------------------- - - - - protected void calculateRhoPhi() - { - calculateRhoPhi(x, y, rho[0], phi[0]); - // treat wraparound - for (int i = 0; i < numData; ++i) - { - if (Math.abs(0 - phi[0][i]) > Math.PI) - { - if (0 - phi[0][i] > 0) - { - phi[0][i] += AMath.TWO_PI; - } - } - } // for - } // calculateRhoPhi() -------------------------------------------------- - - private void cutSubdetector() - { - AParameter par = parameterStore.get("CutsInDet", "SCT"); - if (par.getI() != -1) - { - cutArray(sub, par.getI(), "Barrel/Endcap"); - } - } // cutSubdetector() --------------------------------------------------- - - - protected void applyCuts() - { - cutIndex(); - cutOrientation(); - cutSubdetector(); - cut("CutsInDet", "Layer", "Layer", layer); - cutSimulatedTracks(); - cutReconstructedTracks(); - cutPhi(phi[0]); - cutEta(); - } // applyCuts() -------------------------------------------------------- - - private void cutEta() - { - AParameter par = parameterStore.get("CutsATLAS", "CutEta"); - if (!par.getStatus()) - return; - double etaCut = par.getD(); - double etaMid = parameterStore.get("CutsATLAS", "EtaMiddle").getD(); - double etaLowerCut = etaMid - etaCut; - double etaUpperCut = etaMid + etaCut; - int num = 0; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double eta1 = AParameterUtilities.eta(z[list], rho[0][list]); - if (eta1 > etaLowerCut && eta1 < etaUpperCut) - listdl[num++] = list; - } - numDraw = num; - } // cutEta() ----------------------------------------------------------- - - public int getLayer(int id) - { - int layer = (id >> 27) & 0x3; - int sub = getSub(id); - if (sub != BARREL) - { - layer += 7; - } - return layer; - } // getLayer() --------------------------------------------------------- - - public int getSub(int id) - { - // bitwise operation to determine cluster position from id (1,0,2 -> endcap-,barrel,endcap+) - return(id >> 29) & 0x3; - } // getSub() ----------------------------------------------------------- - - public int getOrientation(int id) - { - int side = (id & 0x400) >> 10; - int sub = getSub(id); - if ((side == 1 && sub == BARREL) || (side == 0 && sub != BARREL)) - { - return PHI_CLUSTER; - } - - int layer = getLayer(id); - if (layer % 2 == 1) - { - return U_CLUSTER; - } - - return V_CLUSTER; - } // getOrientation() --------------------------------------------------- - - protected void cutOrientation() - { - int num = 0; - AParameter stereoAnglePar = parameterStore.get("PixelCluster", "Stereo"); - if (!stereoAnglePar.getStatus()) - { - return; - } - int orientation = stereoAnglePar.getI(); - for (int i = 0; i < numDraw; i++) - { - if (orientation == getOrientation(id[listdl[i]])) - { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } // cutOrientation() --------------------------------------------------- - - protected int internalColor() - { - int numColorTypes = super.internalColor(); - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - if (colorFunction == numColorTypes + 1) - { - colorBy(layer); - } - else if (colorFunction == numColorTypes + 2) - { - colorByOrientation(); - } - else if (colorFunction == numColorTypes + 3) - { - colorByEloss(); - } - - return numColorTypes + 2; - } // internalColor() ---------------------------------------------------- - - protected void colorByOrientation() - { - int numColors = parameterStore.get("HitColors", "Number").getI(); - numColors = Math.min(7, numColors); - int[] col = parameterStore.getArray("HitColors", "C1", numColors); - for (int i = 0; i < numData; i++) - { - color[i] = (byte) col[getOrientation(id[i]) + 1 % numColors]; - } - } // colorByOrientation() ----------------------------------------------- - - protected void colorByEloss() - { - // This method currently uses the uncorrected value for eloss as an approximation to dE/dx - // Need to either loop over one track collection for associated tracks in Atlantis, or do this in JiveXML.. - - int numColors = parameterStore.get("HitColors", "Number").getI(); - numColors = Math.min(7, numColors); - int[] col = parameterStore.getArray("HitColors", "C1", numColors); - for (int i = 0; i < numData; i++) - { - if(eloss[i] < 0.5) - { - color[i] = (byte) col[1 + 1 % numColors]; // blue - } - else if(eloss[i] >=0.5 && eloss[i] < 2) - { - color[i] = (byte) col[5 + 1 % numColors]; // yellow - } - else if(eloss[i] >=2) - { - color[i] = (byte) col[2 + 1 % numColors]; // red/orange - } - } - } // colorByEloss() ----------------------------------------------------- - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index; - - String temp = getNameScreenName() + " (id: " + id[index] + " index: " + index +")\n" + - " orientation = " + getOrientation(id[index]); - temp += "\n x = " + x[index]; - temp += "\n y = " + y[index]; - temp += "\n z = " + z[index]; - temp += "\n " + AMath.RHO + " = " + rho[0][index] + " " + rho[1][index]; - temp += "\n " + AMath.ETA + " module = "; - temp += (etaModule != null) ? Integer.toString(etaModule[index]) : "n/a"; - temp += "\n " + AMath.PHI + " module = "; - temp += (phiModule != null) ? Integer.toString(phiModule[index]) : "n/a"; - temp += "\n widthx = "; - temp += (widthx != null) ? Float.toString(widthx[index]) : "n/a"; - temp += "\n widthy = "; - temp += (widthy != null) ? Float.toString(widthx[index]) : "n/a"; - temp += "\n eloss = "; - temp += (eloss != null) ? Float.toString(eloss[index]) : "n/a"; - - temp += super.getHitInfo(index); // finds barcode information - - return temp; - } // getHitInfo() ------------------------------------------------------- - - protected ACoord getYXUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for (int j = 0; j < 1; j++) - { - hv[0][j][i] = x[list]; - hv[1][j][i] = y[list]; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.SYMBOLS); - } // getYXUser() -------------------------------------------------------- - - protected ACoord getRZUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double phiDiff = Math.abs(phi[0][list] - phiMid); - double sign; - if (phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - { - sign = +1.; - } - else - { - sign = -1.; - } - - for (int j = 0; j < 1; j++) - { - hv[0][j][i] = z[list]; - hv[1][j][i] = sign * rho[j][list]; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.SYMBOLS); - } // getRZUser() -------------------------------------------------------- - - protected ACoord getFRUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for (int j = 0; j < 1; j++) - { - hv[0][j][i] = rho[j][list]; - hv[1][j][i] = Math.toDegrees(AParameterUtilities.getPhiStereo(rho[j][list], phi[j][list], z[list])); - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.SYMBOLS).includePhiWrapAround("FR"); - } // getFRUser() -------------------------------------------------------- - - protected ACoord getFZUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for (int j = 0; j < 1; j++) - { - hv[0][j][i] = z[list]; - hv[1][j][i] = Math.toDegrees(AParameterUtilities.getPhiStereo(rho[j][list], phi[j][list], z[list])); - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.SYMBOLS).includePhiWrapAround("FZ"); - } // getFZUser() -------------------------------------------------------- - - protected ACoord getVPUser() - { - makeDrawList(); - int numTotal = 2 * numDraw; - double[][][] hv = new double[2][numTotal][2]; - int[] index = new int[numTotal]; - double[] sign = new double[] { -1., 1. }; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - double deltaEta = AProjectionVP.getDeltaEta(rho[0][list], z[list]); - double eta = AParameterUtilities.eta(z[list], rho[0][list]); - for (int j = 0; j < 2; j++) - { - // pixels displayed halfway in phi and eta, for some reason - // quick fix = multiply by 2 - hv[0][2 * i + j][0] = 2*(eta + sign[j] * deltaEta); - hv[1][2 * i + j][0] = 2*Math.toDegrees(phi[0][list]); - index[2 * i + j] = list; - } - - } - return new ACoord(hv, index, this, ACoord.POLYLINES).includePhiWrapAround("VP"); - } // getVPUser() -------------------------------------------------------- - -} // class APixelClusterData =================================================== diff --git a/graphics/AtlantisJava/src/atlantis/data/APixelRDOData.java b/graphics/AtlantisJava/src/atlantis/data/APixelRDOData.java deleted file mode 100644 index f9c78bd7bf8e2e1a0778eb0b5482c8d8e15a4e6a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/APixelRDOData.java +++ /dev/null @@ -1,160 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterUtilities; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - - -/* - * PixelRDO - Pixel Raw Data object (SpacePoint Raw Data Objects) - * The class is derived from AS3DData class (SpacePoint) - * Parameters expected in the event file for the PixelRDO datatype - * id x y z etaModule phiModule - */ -public class APixelRDOData extends AS3DData -{ - private int[] etaModule = null; - private int[] phiModule = null; - - - public String getParameterGroup() - { - return "PixelRDO"; - - } // getParameterGroup() ------------------------------------------------ - - - - public String getName() - { - return "PixelRDO"; - - } // getName() ---------------------------------------------------------- - - - - public String getNameScreenName() - { - return "PixelRDO"; - - } // getNameScreenName() ------------------------------------------------ - - - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+"\n"+ - AMath.RHO+" = "+String.format("%.3f",rho[index])+"\n "+ - "z = "+String.format("%.3f",z[index])+" cm\n"+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - - String temp = getNameScreenName() + " (id: " + id[index] + " index: " + index + ")" + - "\n " + AMath.RHO + " = " + String.format("%.3f",rho[index]) + " cm" + - "\n " + AMath.PHI + " = " + - String.format("%.3f",Math.toDegrees(phi[index])) + - AMath.DEGREES + " (" + String.format("%.3f",phi[index]) + " rad)" + - "\n z = " + String.format("%.3f",z[index]) + " cm"; - - temp += "\n " + AMath.ETA + " module = "; - temp += (etaModule != null) ? Integer.toString(etaModule[index]) : "n/a"; - temp += "\n " + AMath.PHI + " module = "; - temp += (phiModule != null) ? Integer.toString(phiModule[index]) : "n/a"; - - return temp; - - } // getHitInfo() ------------------------------------------------------- - - - - APixelRDOData(AHashMap p, AEvent e) - { - super(p,e); - id = p.getIntArray("id"); - etaModule = (p.get("etaModule") != null) ? p.getIntArray("etaModule") : null; - phiModule = (p.get("phiModule") != null) ? p.getIntArray("phiModule") : null; - - } // APixelRDOData() ---------------------------------------------------- - - - - protected int internalColor() - { - int numColorTypes = super.internalColor(); - // int colorFunction=APar.get(PARAMETER_GROUP, "ColorFunction").getI(); - // color by error will go here - // if(colorFunction==numColorTypes+1) - // colorByError() - to implement - - return numColorTypes + 1; - - } // internalColor() ---------------------------------------------------- - - - - protected void applyCuts() - { - cutIndex(); - cutPhi(phi); - cutEta(rho, z); - if(etaModule != null) - { - cut("CutsInDet", "EtaModule", " EtaModule", etaModule); - } - if(phiModule != null) - { - cut("CutsInDet", "PhiModule", " PhiModule", phiModule); - } - - cutSubdetector(); - } // applyCuts() -------------------------------------------------------- - - private void cutSubdetector() - { - AParameter subPar = parameterStore.get("CutsInDet", "SCT"); - if(subPar.getI() != -1) - cutArray(sub, subPar.getI(), "Barrel/Endcap"); - } - - protected ACoord getFRUser() - { - makeDrawList(); - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index = new int[numDraw]; - - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - h[i] = rho[list]; - v[i] = Math.toDegrees(AParameterUtilities.getPhiStereo(rho[list], phi[list], z[list])); - index[i] = list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("FR"); - - } // getFRUser() -------------------------------------------------------- - - - - protected ACoord getFZUser() - { - makeDrawList(); - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - h[i] = z[list]; - v[i] = Math.toDegrees(AParameterUtilities.getPhiStereo(rho[list], phi[list], z[list])); - index[i] = list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("FZ"); - - } // getFZUser() -------------------------------------------------------- - -} // class APixelRDOData ==================================================== diff --git a/graphics/AtlantisJava/src/atlantis/data/APulseShapePlot.java b/graphics/AtlantisJava/src/atlantis/data/APulseShapePlot.java deleted file mode 100644 index 8f1279d0fd0a36f53ed3e75952c2d0cc1ad9bc10..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/APulseShapePlot.java +++ /dev/null @@ -1,513 +0,0 @@ -package atlantis.data; - -import java.util.Vector; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.event.WindowEvent; -import java.awt.event.WindowAdapter; - -import javax.swing.JFrame; -import javax.swing.JPanel; - -// JAS libraries used by Plot class below -import hep.aida.IAnalysisFactory; -import hep.aida.ITree; -import hep.aida.IPlotter; -import hep.aida.IDataPoint; -import hep.aida.IDataPointSet; -import hep.aida.IDataPointSetFactory; -import hep.aida.IPlotterStyle; -import hep.aida.ref.plotter.PlotterUtilities; - -import atlantis.globals.AGlobals; -import atlantis.graphics.AIcon; - - -/** - * Plotting pulse shapes and ADC counts for calorimeters - * - * @author Zdenek Maxa - - */ -public class APulseShapePlot -{ - protected static Component guiComponent = AGlobals.instance().getGuiFrame(); - private static Vector<JFrame> frameVector = new Vector<JFrame>(); - - private APulseShapePlot() {} - - - /** - * Plot real pulse shapes plots - ADC counts and calculated values of the - * real pulse shape plot over it. Works for multiple channels (TILE) as - * well as for a single channel e.g. LAr - * - * @param adcCounts int[][] - * @param realPulse double[][] - * @param step double - * @param subTitle String[] - * @param title String - */ - public static void plotRealPulseShapes(int[][] adcCounts, double[][] realPulse, - double step, String[] subTitle, String title) - { - JFrame frame = new JFrame(title); - frame.setTitle(title); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - AIcon.setIconImage(frame); - frame.setLocation(guiComponent.getLocation()); - Plot p = new Plot(); - frame.setContentPane(p); - p.plotRealPulseShapes(adcCounts, realPulse, step, subTitle); - frame.pack(); - int windowWidth = 330 + ((adcCounts.length - 1) * 110); - int windowHeight = 300; - frame.setSize(windowWidth, windowHeight); - frame.setVisible(true); - - frame.addWindowListener(new AllWindowsDisposer()); - frameVector.add(frame); - - } // plotRealPulseShapes() ---------------------------------------------- - - public static void plotRawCellPulseShapes(int[][] adcCounts, double[][] rawPulse, - double[][] cellPulse, double step, - String[] subTitle, String title) - { - JFrame frame = new JFrame(title); - frame.setTitle(title); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - AIcon.setIconImage(frame); - frame.setLocation(guiComponent.getLocation()); - Plot p = new Plot(); - frame.setContentPane(p); - p.plotRawCellPulseShapes(adcCounts, rawPulse, cellPulse, step, subTitle); - frame.pack(); - int windowWidth = 440 + ((adcCounts.length - 1) * 140); - int windowHeight = 400; - frame.setSize(windowWidth, windowHeight); - frame.setVisible(true); - - frame.addWindowListener(new AllWindowsDisposer()); - frameVector.add(frame); - - } // plotRealPulseShapes() ---------------------------------------------- - - /** - * Plots only ADC counts, used as follows: - * APulseShapePlot.plotADCCounts(adcCounts[index], title) - * still used for instance when real pulse shapes plot data is not - * available, e.g. LAr presampler (layer 0) - - * @param data int[][] - * @param title String title of window - * @param axis String[] title for the horizontal axis on each plot (if null uses "bunch crossing") - */ - public static void plotADCCounts(int[][] data, String title, String[] axis) - { - String[] labels = new String[data.length]; - String[] colors = new String[data.length]; - for(int i=0; i<data.length; i++) - { - labels[i]="ADC counts"; - colors[i]="blue"; - } - String[] newAxis; - if(axis!=null) - { - newAxis=axis; - } - else - { - newAxis= new String[data.length]; - for(int i=0; i<data.length; i++) - { - newAxis[i] = "bunch crossing"; - } - } - plotADCCounts(data, title, newAxis, labels, colors); - } - - - - /** - * Plots only ADC counts, used as follows: - * APulseShapePlot.plotADCCounts(adcCounts[index], title) - * still used for instance when real pulse shapes plot data is not - * available, e.g. LAr presampler (layer 0) - - * @param data int[][] - * @param title String title of window - * @param axis String[] titles for the horizontal axis on each plot - * @param labels String[] titles for each plot - * @param colors String[] color of datapoints for each plot - */ - public static void plotADCCounts(int[][] data, String title, String[] axis, String[] labels, String[] colors) - { - JFrame frame = new JFrame(title); - AIcon.setIconImage(frame); - frame.setLocation(guiComponent.getLocation()); - Plot p = new Plot(); - frame.setContentPane(p); - p.plotADCCounts(data, axis, labels, colors); - frame.pack(); - int windowWidth = 330+ ((data.length - 1) * 110); - int windowHeight = 300; - frame.setSize(windowWidth, windowHeight); - frame.setVisible(true); - - frame.addWindowListener(new AllWindowsDisposer()); - frameVector.add(frame); - - } // plotADCCounts() -------------------------------------------------- - - - - static class AllWindowsDisposer extends WindowAdapter - { - public void windowClosing(WindowEvent e) - { - for(int i = 0; i < frameVector.size(); i++) - { - JFrame cf = frameVector.get(i); - cf.dispose(); - } - frameVector.removeAllElements(); - } - - } // class AllWindowsDisposer =========================================== - - -} // class ACaloPulseShapePlot ============================================== - - - -/** - * - * <p>Title: Plot</p> - * - * <p>Description: Plotting class using JAS library </p> - * - */ -class Plot extends JPanel -{ - - public Plot() - { - super(new BorderLayout()); - - } // Plot() ------------------------------------------------------------- - - - - protected void plotRealPulseShapes(int[][] adcCounts, double[][] realPulse, - double step, String[] subTitle) - { - - IAnalysisFactory af = IAnalysisFactory.create(); - ITree tree = af.createTreeFactory().create(); - IDataPointSetFactory dpsf = af.createDataPointSetFactory(tree); - - // Create a two dimensional IDataPointSet - IDataPointSet[] dataPointSet = new IDataPointSet[adcCounts.length]; - for(int i = 0; i < adcCounts.length; i++) - { - String myTitle = (subTitle != null) ? subTitle[i] : "Real pulse shape"; - - double[] x = new double[adcCounts[i].length]; - double[] y = new double[adcCounts[i].length]; - double[] e = new double[adcCounts[i].length]; - - for(int ii = 0; ii < adcCounts[i].length; ii++) - { - x[ii] = ii + 1.0; // counting from 1 (to 9 for TILE) - y[ii] = (double) adcCounts[i][ii]; - e[ii] = 0.0; // arrays with errors - } - - // first parameter must be path - what for here? - dataPointSet[i] = dpsf.createXY(myTitle, x, y, e, e); - dataPointSet[i].setTitle(myTitle); - } // over number of channels - - // Create a two dimensional IDataPointSet - IDataPointSet[] dataPointSetReal = new IDataPointSet[realPulse.length]; - for(int i = 0; i < realPulse.length; i++) - { - String myTitle = (subTitle != null) ? subTitle[i] : "Real pulse shape"; - - double[] x = new double[realPulse[i].length]; - double[] y = new double[realPulse[i].length]; - double[] e = new double[realPulse[i].length]; - - double d = 1.0; - for(int ii = 0; ii < realPulse[i].length; ii++) - { - x[ii] = d; - y[ii] = realPulse[i][ii]; - e[ii] = 0.0; // arrays with errors - d += step; - } - - // first parameter must be path - what for here? - dataPointSetReal[i] = dpsf.createXY(myTitle, x, y, e, e); - dataPointSetReal[i].setTitle(myTitle); - - } // over number of channels - - - IPlotter plotter = af.createPlotterFactory().create(""); - - plotter.createRegions(adcCounts.length, 1); // regions 1x1, 1x2, ... - - // set common style parameters for both regions - IPlotterStyle style = af.createPlotterFactory().createPlotterStyle(); - style.xAxisStyle().setLabel("bunch crossing"); - style.yAxisStyle().setLabel("ADC counts"); - style.titleStyle().textStyle().setColor("black"); - style.titleStyle().textStyle().setBold(true); - style.xAxisStyle().labelStyle().setColor("black"); - style.yAxisStyle().labelStyle().setColor("black"); - - // set no legend at plots - style.statisticsBoxStyle().setVisible(false); // statistical legend - style.legendBoxStyle().setVisible(false); // legend for function fit - - for(int i = 0; i < adcCounts.length; i++) - { - // set style parameters different for regions - style.dataStyle().markerStyle().setParameter("size", "2"); - style.dataStyle().markerStyle().setShape("box"); // "square" - plotter.region(i).style().dataStyle().markerStyle().setColor("red"); - plotter.region(i).plot(dataPointSetReal[i], style); - - style.dataStyle().markerStyle().setParameter("size", "7"); - style.dataStyle().markerStyle().setShape("dot"); // "circle" - plotter.region(i).style().dataStyle().markerStyle().setColor("blue"); - plotter.region(i).plot(dataPointSet[i], style); - } - - // now embed the plotter - add(PlotterUtilities.componentForPlotter(plotter), BorderLayout.CENTER); - - } // plotRealPulseShapes() ---------------------------------------------- - - - - - /** - * Method creates multiple plots of ADC counts only. - * multiple channels, no fit, no pulse shapes. - * or plots of ADC Counts pulse shapes. - * - * @param data int[][] - * @param labels String[] titles for each plot - */ - public void plotADCCounts(int[][] data, String[] axis, String[] labels, String[] colors) - { - IAnalysisFactory af = IAnalysisFactory.create(); - ITree tree = af.createTreeFactory().create(); - IDataPointSetFactory dpsf = af.createDataPointSetFactory(tree); - - // Create a IDataPointSet (one dimension) - IDataPointSet[] dataPointSet = new IDataPointSet[data.length]; - for(int j = 0; j < data.length; j++) - { - - dataPointSet[j] = dpsf.create("plot", labels[j], 2); - - for(int i = 0; i < data[j].length; i++) - { - dataPointSet[j].addPoint(); - IDataPoint dp = dataPointSet[j].point(i); - - dp.coordinate(0).setValue(i); - dp.coordinate(1).setValue(data[j][i]); - } - } - - - IPlotter plotter = af.createPlotterFactory().create(""); - - plotter.createRegions(data.length, 1); // regions 1x1, 1x2, ... - - IPlotterStyle style = af.createPlotterFactory().createPlotterStyle(); - style.yAxisStyle().setLabel("ADC counts"); - style.dataStyle().markerStyle().setParameter("size", "7"); - style.dataStyle().markerStyle().setShape("dot"); - style.titleStyle().textStyle().setColor("black"); - style.titleStyle().textStyle().setBold(true); - style.xAxisStyle().labelStyle().setColor("black"); - style.yAxisStyle().labelStyle().setColor("black"); - - // set no legend at plots - style.statisticsBoxStyle().setVisible(false); // statistical legend - style.legendBoxStyle().setVisible(false); // legend for function fit - - for(int j = 0; j < data.length; j++) - { - plotter.region(j).style().xAxisStyle().setLabel(axis[j]); - plotter.region(j).style().dataStyle().markerStyle().setColor(colors[j]); - plotter.region(j).style().dataStyle().outlineStyle().setColor(colors[j]); - - // plot the data - points ('style' parameter is optional for plotter) - plotter.region(j).plot(dataPointSet[j], style); - } - // now embed the plotter - add(PlotterUtilities.componentForPlotter(plotter), BorderLayout.CENTER); - - } // plotADCCounts() ------------ --------------------------------------- - - - protected void plotRawCellPulseShapes(int[][] adcCounts, double[][] rawPulse, - double[][] cellPulse, - double step, String[] subTitle) - { - - IAnalysisFactory af = IAnalysisFactory.create(); - ITree tree = af.createTreeFactory().create(); - IDataPointSetFactory dpsf = af.createDataPointSetFactory(tree); - - // Create a two dimensional IDataPointSet - IDataPointSet[] dataPointSet = new IDataPointSet[adcCounts.length]; - for(int i = 0; i < adcCounts.length; i++) - { - String myTitle = "ADC counts"; - - double[] x = new double[adcCounts[i].length]; - double[] y = new double[adcCounts[i].length]; - double[] e = new double[adcCounts[i].length]; - - for(int ii = 0; ii < adcCounts[i].length; ii++) - { - x[ii] = ii + 1.0; // counting from 1 (to 9 for TILE) - y[ii] = (double) adcCounts[i][ii]; - e[ii] = 0.0; // arrays with errors - } - - // first parameter must be path - what for here? - dataPointSet[i] = dpsf.createXY(myTitle, x, y, e, e); - dataPointSet[i].setTitle(myTitle); - } // over number of channels - - // Create a two dimensional IDataPointSet - IDataPointSet[] dataPointSetCell = new IDataPointSet[cellPulse.length]; - for(int i = 0; i < cellPulse.length; i++) - { - String myTitle = "Cell time"; - - double[] x = new double[cellPulse[i].length]; - double[] y = new double[cellPulse[i].length]; - double[] e = new double[cellPulse[i].length]; - - double d = 1.0; - for(int ii = 0; ii < cellPulse[i].length; ii++) - { - x[ii] = d; - y[ii] = cellPulse[i][ii]; - e[ii] = 0.0; // arrays with errors - d += step; - } - - // first parameter must be path - what for here? - dataPointSetCell[i] = dpsf.createXY(myTitle, x, y, e, e); - dataPointSetCell[i].setTitle(myTitle); - - } // over number of channels - - - // Create a two dimensional IDataPointSet - IDataPointSet[] dataPointSetRaw = new IDataPointSet[rawPulse.length]; - for(int i = 0; i < rawPulse.length; i++) - { - String myTitle = "Raw time"; - - double[] x = new double[rawPulse[i].length]; - double[] y = new double[rawPulse[i].length]; - double[] e = new double[rawPulse[i].length]; - - double d = 1.0; - for(int ii = 0; ii < rawPulse[i].length; ii++) - { - x[ii] = d; - y[ii] = rawPulse[i][ii]; - e[ii] = 0.0; // arrays with errors - d += step; - } - - // first parameter must be path - what for here? - dataPointSetRaw[i] = dpsf.createXY(myTitle, x, y, e, e); - dataPointSetRaw[i].setTitle(myTitle); - - } // over number of channels - - - IPlotter plotter = af.createPlotterFactory().create(""); - - plotter.createRegions(adcCounts.length, 1); // regions 1x1, 1x2, ... - - // set common style parameters for both regions - IPlotterStyle style = af.createPlotterFactory().createPlotterStyle(); - style.xAxisStyle().setLabel("bunch crossing"); - style.yAxisStyle().setLabel("ADC counts"); - style.titleStyle().textStyle().setColor("black"); - style.titleStyle().textStyle().setBold(true); - style.xAxisStyle().labelStyle().setColor("black"); - style.yAxisStyle().labelStyle().setColor("black"); - - style.statisticsBoxStyle().setVisible(false); // statistical legend - style.legendBoxStyle().setVisible(true); // legend for function fit - - for(int i = 0; i < adcCounts.length; i++) - { - // set style parameters different for regions - style.dataStyle().markerStyle().setParameter("size", "4"); - style.dataStyle().markerStyle().setShape("box"); // "square" - style.dataStyle().showInLegendBox(true); - plotter.region(i).style().dataStyle().markerStyle().setColor("red"); - plotter.region(i).plot(dataPointSetRaw[i], style); - - style.dataStyle().markerStyle().setParameter("size", "2"); - style.dataStyle().markerStyle().setShape("box"); // "square" - style.dataStyle().showInLegendBox(true); - plotter.region(i).style().dataStyle().markerStyle().setColor("green"); - plotter.region(i).plot(dataPointSetCell[i], style); - - style.dataStyle().markerStyle().setParameter("size", "7"); - style.dataStyle().markerStyle().setShape("dot"); // "circle" - style.dataStyle().showInLegendBox(false); - plotter.region(i).style().dataStyle().markerStyle().setColor("blue"); - plotter.region(i).plot(dataPointSet[i], style); - - //plotter.region(i).style().legendBoxStyle().boxStyle().borderStyle().setVisible(false); - - plotter.region(i).setTitle((subTitle != null) ? subTitle[i] : "Real pulse shape"); - } - - // now embed the plotter - add(PlotterUtilities.componentForPlotter(plotter), BorderLayout.CENTER); - - } // plotRealPulseShapes() ---------------------------------------------- - - - -} // class Plot ============================================================= - - - -/* following lines for hints only (futher JAS plotting styles settings) - - IPlotterStyle style = plotterFactory.createPlotterStyle(); - style.xAxisStyle().tickLabelStyle().setFontSize(14); - style.xAxisStyle().tickLabelStyle().setBold(true); - style.xAxisStyle().tickLabelStyle().setColor("blue"); - style.xAxisStyle().labelStyle().setFontSize(24); - style.xAxisStyle().labelStyle().setItalic(true); - style.titleStyle().textStyle().setFontSize(30); - style.dataStyle().markerStyle().setParameter("size","12"); - style.dataStyle().markerStyle().setParameter("shape","3"); - style.dataStyle().markerStyle().setParameter("color","blue"); - plotter.region(0).plot(h1); - plotter.region(0).plot(h2, style); - plotter.show(); -*/ diff --git a/graphics/AtlantisJava/src/atlantis/data/AROIData.java b/graphics/AtlantisJava/src/atlantis/data/AROIData.java deleted file mode 100644 index 0b3a539e2505db1d8058c99251cd31d2399f3cda..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AROIData.java +++ /dev/null @@ -1,334 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - -/** - * Base class for EmTauROI, JetROI and MuonROI - * - * @author Gary Taylor, Zdenek Maxa, Qiang Lu - */ - -abstract public class AROIData extends AData -{ - protected float[] eta; - protected float[] phi; - protected float[] energy; - // energy variables for EmTauROIs - protected float[] energyEM; - protected float[] energyTAU; - - private int drawOrFill = AGraphics.FILL; - - AROIData(AHashMap p, AEvent e) - { - super(p,e); - eta = p.getFloatArray("eta"); - phi = p.getFloatArray("phi"); - energy = p.getFloatArray("energy"); - if(this instanceof AEmTauROIData) - { - energyEM = p.getFloatArray("energyEM"); - energyTAU = p.getFloatArray("energyTAU"); - } - } - - public float getEnergy(int index) - { - return energy[index]; - } - public float getEnergyEM(int index) - { - return energyEM[index]; - } - public float getEnergyTAU(int index) - { - return energyTAU[index]; - } - - public float getEta(int index) - { - return eta[index]; - } - - public float getPhi(int index) - { - return phi[index]; - } - - public float[] getEnergy() - { - return energy; - } - - public float[] getEnergyEM() - { - return energyEM; - } - - public float[] getEnergyTAU() - { - return energyTAU; - } - - public float[] getEta() - { - return eta; - } - - public float[] getPhi() - { - return phi; - } - - protected int getDrawOrFill() - { - return drawOrFill; - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+ - "\n Energy="+String.format("%.3f",energy[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - - double deta = parameterStore.get(PARAMETER_GROUP, "deta").getD(); - double dphi = parameterStore.get(PARAMETER_GROUP, "dphi").getD(); - - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (id: " + id[index] + " index: " + index + ")"); - msg.append("\n energy = "); - msg.append(String.format("%.3f",energy[index])); - msg.append(" GeV\n "); - if(this instanceof AEmTauROIData) - { - if(energyEM != null) - { - msg.append("energyEM = "); - msg.append(String.format("%.3f",energyEM[index])); - msg.append(" GeV\n "); - } - if(energyTAU != null) - { - msg.append("energyTAU = "); - msg.append(String.format("%.3f",energyTAU[index])); - msg.append(" GeV\n "); - } - } - msg.append(AMath.ETA); - msg.append(" = "); - msg.append(String.format("%.3f",eta[index])); - msg.append("\n "); - msg.append(AMath.PHI); - msg.append(" = "); - msg.append(String.format("%.3f",Math.toDegrees(phi[index]))); - msg.append(AMath.DEGREES); - msg.append(" (" + String.format("%.3f",phi[index]) + " rad)"); - msg.append("\n deta = "); - msg.append(String.format("%.3f",deta)); - msg.append("\n dphi = "); - msg.append(String.format("%.3f",Math.toDegrees(dphi))); - msg.append(AMath.DEGREES); - msg.append(" (" + String.format("%.3f",dphi) + " rad)"); - - return msg.toString(); - } - - protected int internalColor() - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - if (colorFunction == 0) - { - colorByConstant(); - } - else if (colorFunction == 1) - { - colorByIndex(); - } - - return 1; - } - - protected void applyCuts() - { - cutIndex(); - cutPhi(phi); - cutEta(eta); - } - - protected ACoord getVPUser() - { - drawOrFill = AGraphics.DRAW; - - double deta = parameterStore.get(PARAMETER_GROUP, "deta").getD() / 2; - double dphiDeg = Math.toDegrees(parameterStore.get(PARAMETER_GROUP, "dphi").getD()) / 2; - double phiDeg = 0; - - makeDrawList(); - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - phiDeg = Math.toDegrees(phi[list]); - - // without the cross in the middle - // hv[0][i] = AMath.xBox(eta[list], deta); // x-dx,x-dx,x+dx,x+dx - // hv[1][i] = AMath.yBox(phiDeg, dphiDeg); // y-dy,y+dy,y+dy,y-dy - - hv[0][i] = new double[] { eta[list] - deta, eta[list] - deta, - eta[list] + deta, eta[list] - deta, eta[list] + deta, - eta[list] - deta, eta[list] + deta, eta[list] + deta }; - hv[1][i] = new double[] { phiDeg - dphiDeg, phiDeg + dphiDeg, - phiDeg - dphiDeg, phiDeg - dphiDeg, phiDeg + dphiDeg, - phiDeg + dphiDeg, phiDeg - dphiDeg, phiDeg + dphiDeg }; - index[i] = list; - } - - return new ACoord(hv, index, this).includePhiWrapAround("VP"); - } - - protected ACoord getYXUser() - { - drawOrFill = AGraphics.FILL; - double dphi = parameterStore.get(PARAMETER_GROUP, "dphi").getD() / 2; - - makeDrawList(); - double[][][] hv = new double[2][numDraw][4]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double phiPlus = phi[list] + dphi; - double phiMinus = phi[list] - dphi; - double cosPlus = Math.cos(phiPlus); - double sinPlus = Math.sin(phiPlus); - double cosMinus = Math.cos(phiMinus); - double sinMinus = Math.sin(phiMinus); - - double rhoPlus = 1150; - double rhoMinus = 1130; - - // 4 corners of the cell area - // x0, y0 - hv[0][i][0] = rhoMinus * cosPlus; - hv[1][i][0] = rhoMinus * sinPlus; - // x1, y1 - hv[0][i][1] = rhoPlus * cosPlus; - hv[1][i][1] = rhoPlus * sinPlus; - // x2, y2 - hv[0][i][2] = rhoPlus * cosMinus; - hv[1][i][2] = rhoPlus * sinMinus; - // x3, y3 - hv[0][i][3] = rhoMinus * cosMinus; - hv[1][i][3] = rhoMinus * sinMinus; - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYGONS); - } - - protected ACoord getFRUser() - { - ACoord coordFR = getYXUser().convertYXToFR().includePhiWrapAround("FR"); - return coordFR; - } - - protected ACoord getRZUser() - { - drawOrFill = AGraphics.FILL; - double deta = parameterStore.get(PARAMETER_GROUP, "deta").getD() / 2; - - makeDrawList(); - double[][][] hv = new double[2][numDraw][4]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(phi[list] - phiMid); - double rSign; - if (phiDiff > Math.PI / 2. && phiDiff <= 3 * Math.PI / 2.) - rSign = -1; - else - rSign = 1; - - // calculate theta based on the eta value - double theta = Math.atan(Math.exp(-Math.abs(eta[list]))) * 2.0; - double thetaPlus = Math.atan(Math.exp(-(Math.abs(eta[list]) - deta))) * 2.0; - double thetaMinus = Math.atan(Math.exp(-(Math.abs(eta[list]) + deta))) * 2.0; - - if ((eta[list] > 0.) && (rSign == -1)) - { - theta = 2 * Math.PI - theta; - thetaPlus = 2 * Math.PI - thetaPlus; - thetaMinus = 2 * Math.PI - thetaMinus; - } - else if ((eta[list] < 0.) && (rSign == -1)) - { - theta += Math.PI; - thetaPlus += Math.PI; - thetaMinus += Math.PI; - } - else if ((eta[list] < 0.) && (rSign == 1)) - { - theta = Math.PI - theta; - thetaPlus = Math.PI - thetaPlus; - thetaMinus = Math.PI - thetaMinus; - } - - double cosPlus = Math.cos(thetaPlus); - double sinPlus = Math.sin(thetaPlus); - double cosMinus = Math.cos(thetaMinus); - double sinMinus = Math.sin(thetaMinus); - - // decide the region based on the theta value - final byte TOP_BOTTOM = 0; - final byte LEFT_RIGHT = 1; - byte region = TOP_BOTTOM; - // hard-coded value is based on the values in Geometry - if (Math.abs(Math.tan(theta)) < 0.8) - region = LEFT_RIGHT; - - double radiusMinus = 0.; - switch (region) - { - case TOP_BOTTOM: - radiusMinus = 1330 / Math.abs(Math.sin(theta)); - break; - case LEFT_RIGHT: - radiusMinus = 1630 / Math.abs(Math.cos(theta)); - break; - } - double radiusPlus = radiusMinus + 20; - - // 4 corners of the cell area - // x0, y0 - hv[0][i][0] = radiusMinus * cosPlus; - hv[1][i][0] = radiusMinus * sinPlus; - // x1, y1 - hv[0][i][1] = radiusPlus * cosPlus; - hv[1][i][1] = radiusPlus * sinPlus; - // x2, y2 - hv[0][i][2] = radiusPlus * cosMinus; - hv[1][i][2] = radiusPlus * sinMinus; - // x3, y3 - hv[0][i][3] = radiusMinus * cosMinus; - hv[1][i][3] = radiusMinus * sinMinus; - - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.POLYGONS); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ARPCData.java b/graphics/AtlantisJava/src/atlantis/data/ARPCData.java deleted file mode 100755 index de50662cfd6d5cb7e71a236f975bf912240d1afe..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ARPCData.java +++ /dev/null @@ -1,311 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.graphics.ACoord; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.AIdHelper; -import atlantis.utils.ALogger; -import atlantis.utils.AMath; - -/** - * for comments see AMDTData - */ - -public class ARPCData extends AMuonHitData -{ - protected float[] width; - protected float[] length; - protected int[] gasGap; - - private static ALogger logger = ALogger.getLogger(ARPCData.class); - - public String getParameterGroup() - { - return "RPC"; - } - - public String getName() - { - return "RPC"; - } - - public String getNameScreenName() - { - return "RPC"; - } - - ARPCData(AHashMap p, AEvent e) - { - super(p,e); - length = p.getFloatArray("length"); - width = p.getFloatArray("width"); - gasGap = new int[numData]; - for (int i = 0; i < numData; ++i) - gasGap[i] = getGasGap(i); - } - - protected int getStation(int index) - { - try { - String stationName = AIdHelper.stationName(id[index]); - - if (stationName.charAt(1) == 'M') { - return AIdHelper.rpcDoubletR(id[index]) - 1; - } else { - return AIdHelper.rpcDoubletR(id[index]) + 1; - } - } catch (AAtlantisException e) { - logger.error("Problem decoding RPC identifier", e); - } - - return 0; - } - - protected int getSub(int index) - { - return 0; - } - - public int getSector(int index) - { - try { - String stationName = AIdHelper.stationName(id[index]); - - if (stationName.charAt(2) == 'L') { - return 2 * (AIdHelper.stationPhi(id[index]) - 1); - } else { - return 2 * (AIdHelper.stationPhi(id[index]) - 1) + 1; - } - } catch (AAtlantisException e) { - logger.error("Problem decoding RPC identifier", e); - } - - return 0; - } - - protected int getGasGap(int index) - { - try { - return AIdHelper.rpcGasGap(id[index]); - } catch (AAtlantisException e) { - logger.error("Problem decoding RPC identifier", e); - } - - return 0; - } - - protected boolean getMeasuresPhi(int index) - { - try { - if (AIdHelper.rpcMeasuresPhi(id[index]) == 1) { - return true; - } - } catch (AAtlantisException e) { - logger.error("Problem decoding RPC identifier", e); - } - - return false; - } - - protected void applyCuts() - { - super.applyCuts(); - if (parameterStore.get("CutsATLAS", "CutPhi").getStatus()) - cutPhi(phi, getDPhi()); - if (parameterStore.get("CutsATLAS", "CutEta").getStatus()) - cutEtaDZ(rho, z, getDZ()); - } - - private float[] getDPhi() - { - // only roughly correct - // must create all - float[] dphi = new float[numData]; - - // need only fill for those in draw list - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - if (measuresPhi[list]) - dphi[list] = (float) Math.abs(Math.atan2(width[list] / 2., rho[list])); - else - dphi[list] = (float) Math.abs(Math.atan2(length[list] / 2., rho[list])); - } - return dphi; - } - - private float[] getDZ() - { - // must create all - float[] dz = new float[numData]; - - // need only fill for those in draw list - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - if (measuresPhi[list]) - dz[list] = (float) (length[list] / 2.); - else - dz[list] = (float) (width[list] / 2.); - } - return dz; - } - - protected ACoord getYXUser() - { - makeDrawList(); - cutArray(measuresPhi, true, " Strip"); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double r = rho[list]; - double cosPhi = Math.cos(phi[list]); - double sinPhi = Math.sin(phi[list]); - double phiSector = sector[list] * AMath.PI_BY_8; - double cosPhiSector = Math.cos(phiSector); - double sinPhiSector = Math.sin(phiSector); - double d = width[list] / 2.; - if (!measuresPhi[list]) - d = length[list] / 2.; - double x = r * cosPhi; - double y = r * sinPhi; - double dx = d * sinPhiSector; - double dy = d * cosPhiSector; - - hv[0][0][i] = x + dx; - hv[1][0][i] = y - dy; - hv[0][1][i] = x - dx; - hv[1][1][i] = y + dy; - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } - - protected ACoord getRZUser() - { - makeDrawList(); - cutArray(measuresPhi, false, " Strip"); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double phiDiff = Math.abs(phi[list] - phiMid); - int sign = -1; - - if (phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - sign = 1; - double rC = sign * AMDTData.getSectorRho(sector[list], rho[list], phi[list]); - double zC = z[list]; - double w = width[list] / 2.; - - hv[0][0][i] = zC - w; - hv[1][0][i] = rC; - hv[0][1][i] = zC + w; - hv[1][1][i] = rC; - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } - - protected ACoord getXZUser() - { - makeDrawList(); - cutMuonSector(sector); - cutArray(measuresPhi, false, " Strip"); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - int sect=(int)Math.round(parameterStore.get("XZ", "Phi").getD() / 22.5); - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int sign = 1; - - if (sector[list] != sect) - sign = -1; - double rC = sign * AMDTData.getSectorRho(sector[list], rho[list], phi[list]); - double zC = z[list]; - double w = width[list] / 2.; - - hv[0][0][i] = zC - w; - hv[1][0][i] = rC; - hv[0][1][i] = zC + w; - hv[1][1][i] = rC; - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } - - protected ACoord getFRUser() - { - makeDrawList(); - cutArray(measuresPhi, true, " Strip"); - return getYXUser().convertYXToFR().includePhiWrapAround("FR"); - } - - private void makeDrawListFZ() - { - int mode = parameterStore.get("FZ", "Mode").getI(); - - if (mode == 0 || mode >= 4) - { - numDraw = 0; - } - else - { - makeDrawList(); - cut(" Station", station, "==", mode - 1); - } - cut("FZ", "RPCGasGap", " RPC Gas Gap", gasGap); - } - - protected ACoord getFZUser() - { - makeDrawListFZ(); - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - index[i] = list; - if (measuresPhi[list]) - { - hv[0][i] = AMath.xBox(z[list], length[list] / 2.); - hv[1][i] = AMath.yBox(Math.toDegrees(phi[list]), Math.toDegrees((width[list] / 2.) / rho[list])); - } - else - { - double zC = z[list]; - double r = rho[list]; - double cosPhi = Math.cos(phi[list]); - double sinPhi = Math.sin(phi[list]); - double phiSector = sector[list] * AMath.PI_BY_8; - double cosPhiSector = Math.cos(phiSector); - double sinPhiSector = Math.sin(phiSector); - double d = length[list] / 2.; - double w = width[list] / 2.; - double x = r * cosPhi; - double y = r * sinPhi; - double dx = d * sinPhiSector; - double dy = d * cosPhiSector; - double phi1 = Math.toDegrees(Math.atan2(y - dy, x + dx)); - double phi2 = Math.toDegrees(Math.atan2(y + dy, x - dx)); - hv[0][i] = AMath.xBox(zC, w); - hv[1][i] = AMath.yBox((phi1 + phi2) / 2., (phi1 - phi2) / 2.); - - } - } - return new ACoord(hv, index, this).includePhiWrapAround("FZ"); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ARVxData.java b/graphics/AtlantisJava/src/atlantis/data/ARVxData.java deleted file mode 100644 index 6d27099259a8cdc297fe0ba625d27834b159320f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ARVxData.java +++ /dev/null @@ -1,1043 +0,0 @@ -/* - * CAUTION: When working on this class, remember that the number of vertices - * is not a fixed number for an event. If the user fits additional - * vertices in Atlantis, they will be appended to the list. For this - * reason everything is using ArrayList and not simple arrays. - */ - -package atlantis.data; - -import java.awt.event.ActionEvent; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.Vector; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.tree.DefaultMutableTreeNode; - -import atlantis.canvas.ACanvas; -import atlantis.event.AEvent; -import atlantis.event.AData; -import atlantis.event.AAssociation; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.list.AList; -import atlantis.list.AListManager; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjection3D; -import atlantis.projection.AProjectionVP; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.ALogger; - -import static atlantis.data.AVertex.Type.*; - -/** - * Stores Reconstructed vertices formed for fitting groups - * of tracks. There may not be any reconstructed vertices when a new event - * is read in. However, empty datatype ARVxData is always created within - * the AEvent instance. RVx instances may be added at run time by the user - * when the vertex fitter algorithm is run inside Atlantis. - * - * @author Gary Taylor - */ -public class ARVxData extends AData -{ - private static ALogger logger = ALogger.getLogger(ARVxData.class); - - // size of the arrays with coordinates of the RVx ellipse, - // size of martices - private static final int SIZE = 3; - - // vertices - saved reconstructed vertices, instances of AVertex - private ArrayList<AVertex> vertices = new ArrayList<AVertex>(); - // tracksIndex - indices of tracks (starting from 0) - private ArrayList<int[]> tracksIndex = new ArrayList<int[]>(); - // tracksId - IDs of tracks (as read from event file) - private ArrayList<int[]> tracksId = new ArrayList<int[]>(); - private ArrayList<String> tracksCollection = new ArrayList<String>(); - private ArrayList<Boolean> drawFlag = new ArrayList<Boolean>(); - // false - RVx calculated in Atlantis, true - RVx calculated in Athena - private ArrayList<Boolean> athenaOrigin = new ArrayList<Boolean>(); - - // array of flags 1 - is primary vertex candidate, this - // attribute should be accessed only during event finalise phase - private int[] primVxCand = null; - - /** Vertex type from Athena: for types see - * http://alxr.usatlas.bnl.gov/lxr/source/atlas/Tracking/TrkEvent/TrkEventPrimitives/TrkEventPrimitives/VertexType.h */ - private int[] vertexType = null; - - /** Array containing number of tracks associated with each vertex. */ - private int[] numTracks = null; - - /** Flag whether track numbers are consistent: see Trac bug #551 */ - private boolean hasConsistentTrackNumbers; - - // numData (as at all other datatypes) is used instead of numVertices - // numData variable is referenced from ADrawnGraphics2D (by .getNumData - // method) and since it wasn't set properly in case of RVx it was crashing - // in ADrawnGraphics2D.drawLine() [when rubberbanding over RVx object] - - public String getParameterGroup() - { - return "RVx"; - } - - @Override - public String getName() - { - return "RVx"; - } - - public String getNameScreenName() - { - return "RecVertex"; - } - - /** - * This constructor is called when RVx datatype is found in the event file. - * This RVx data was produced in Athena. - * @param p elements within RVx element in JiveXML input: map of names to values - * @param e parent event - * @throws AAtlantisException if failing to create data - */ - ARVxData(AHashMap p, AEvent e) throws AAtlantisException - { - super(p,e); - - int[] tracks = p.getIntArray("tracks"); - numTracks = p.getUnsureIntArray("numTracks"); - if (numTracks == null) numTracks = new int[numData]; - float[] z = p.getFloatArray("z"); - float[] y = p.getFloatArray("y"); - float[] x = p.getFloatArray("x"); - float[] covMatrix = p.getFloatArray("covMatrix"); - float[] chi2 = p.getFloatArray("chi2"); - String[] storegateKeys = null; - - // Check whether numbers of tracks agree. - hasConsistentTrackNumbers = false; - if (tracks!=null) { - int numTrackIds = tracks.length; - int numTracksFromVertices = 0; - for (int numTracksFromVertex : numTracks) { - numTracksFromVertices += numTracksFromVertex; - } - if (numTracksFromVertices == numTrackIds) { - hasConsistentTrackNumbers = true; - } - } - if (!hasConsistentTrackNumbers) { - logger.error("RVx: numbers of tracks are inconsistent."); - } - - if(p.getStringArray("sgkey") != null) - { - storegateKeys = p.getStringArray("sgkey"); - } - else - { - storegateKeys = new String[numData]; - for (int i = 0; i < numData; i++) - { - storegateKeys[i] = "n/a"; - } - } - - // Allowed to be null if element not in JiveXML. - vertexType = p.getUnsureIntArray("vertexType"); - - primVxCand = p.getUnsureIntArray("primVxCand"); - if (primVxCand == null) primVxCand = new int[numData]; - - if (hasConsistentTrackNumbers) createVertexTrackAssociations(tracks, storegateKeys); - - double[] pos = new double[SIZE]; - double[][] cov = new double[SIZE][SIZE]; - int[] tracksIdArray = null; - int[] tracksIndexArray = null; - - int n = 0; - int m = 0; - for (int i = 0; i < numData; i++) - { - // x, y, z coordinates of the RVx ellipse - pos[0] = x[i]; - pos[1] = y[i]; - pos[2] = z[i]; - - // covMatrix, resp. 3x3 cov array - // numbers are too small, so JiveXML multiplies by 10k, here inverse - // [the same happens with covMatrix for tracks - AHelixData class] - for (int j = 0; j < SIZE; j++) - { - for (int k = 0; k < j + 1; k++) - { - cov[j][k] = covMatrix[n] / 10000; - cov[k][j] = cov[j][k]; - n++; - } - } - - AVertex vertex = new AVertex(chi2[i], pos, cov); - vertices.add(vertex); // new vertex - - // Only save track details if data are consistent. - if (hasConsistentTrackNumbers) { - tracksIdArray = new int[numTracks[i]]; - tracksIndexArray = new int[numTracks[i]]; - for (int j = 0; j < numTracks[i]; j++) - { - tracksIdArray[j] = tracks[m]; - // should be removed - problem that IDs run from 1 and indices - // from 0 - will be fixed - tracksIndexArray[j] = tracks[m] - 1; - m++; - } - tracksIndex.add(tracksIndexArray.clone()); // save indices of tracks - tracksId.add(tracksIdArray.clone()); // save IDs of tracks - } - - // save storeGateKey of the Tracks which form this vertex - tracksCollection.add(storegateKeys[i]); - drawFlag.add(new Boolean(true)); - athenaOrigin.add(new Boolean(true)); - } // for(int i = 0; i < numData; i++) - } // ARVxData() --------------------------------------------------------- - - - /** - * Create vertex-track associations. and adds them to the event's association manager. - * @param tracks array of track ID numbers - * @param storegateKeys array of storegate keys, one per vertex - * Also uses numTracks: number of tracks associated with each vertex. - */ - private void createVertexTrackAssociations(int[] tracks, String[] storegateKeys) { - // Create a list of unique storegate keys. - Vector<String> uniqueStoregateKeys = new Vector<String>(); - if(!storegateKeys[0].equals("n/a")){ - uniqueStoregateKeys.add(storegateKeys[0]); - } - for(int i = 0; i < storegateKeys.length; i++){ - if(storegateKeys[i].equals("n/a")){ - continue; - } - // Check if track particle type already added to list of storegate keys - boolean inVector = false; - for (String sgKey : uniqueStoregateKeys) { - if (sgKey.equals(storegateKeys[i])) { - inVector = true; - break; - } - } - // If storegate key is not in the list, it is added. - if(!inVector){ - uniqueStoregateKeys.add(storegateKeys[i]); - } - } - // Create new association int array for each unique storegate key. - for(int i = 0; i < uniqueStoregateKeys.size(); i++){ - int trackCount = 0; - Vector<Integer> TrkNum = new Vector<Integer>(); - Vector<Integer> Track = new Vector<Integer>(); - // Creating vectors of the 'number of tracks associated to each list' and 'track Ids' - for(int j = 0; j < storegateKeys.length; j++){ - if(uniqueStoregateKeys.get(i).equals(storegateKeys[j])){ - TrkNum.add(numTracks[j]); - for(int k = trackCount; k < trackCount + numTracks[j]; k++){ - Track.add(tracks[k]); - } - } - trackCount += numTracks[j]; - } - //Converting vectors to int[] - int[] assocTracks = new int[Track.size()]; - for(int j = 0; j < Track.size(); j++){ - assocTracks[j] = Track.get(j); - } - int[] numTrks = new int[TrkNum.size()]; - for(int j = 0; j < TrkNum.size(); j++){ - numTrks[j] = TrkNum.get(j); - } - //Creating associations - AAssociation assoc = new AAssociation("RVx" + getStoreGateKey(), - "InDetTrack" + uniqueStoregateKeys.get(i), numTrks, - assocTracks, event); - event.getAssociationManager().add(assoc); - } - } - - /** - * Redefined inherited method AData.getIdFromIndex() - * the array int[] id is not used in this class (unlike other types) so - * AData.getIdFromIndex() was crashing at RVx since this array was empty - * listdl[] array (also inherited from AData) should be properly handled - * in this class (used to crash when rubberbanding over displayed RVx) - * @param index int - * @return int - */ - @Override - public int getIdFromIndex(int index) - { - return listdl[index]; - } // getIdFromIndex() ----------------------------------------------------- - - /** - * - * @param listOfTracksToVertex int[] - list of track indices (internal - * Atlantis indices starting from 0) - * @param key - Track collection storeGateKey - */ - private void createVertexFromTracks(int[] listOfTracksToVertex, String key) - { - - //Retrieving/checking for pre-existing assocation - int[][] assoc = event.getAssociationManager().get("RVx","InDetTrack" + key); - if(assoc == null){ - //Create new association for the between selected tracks and the new vertex - int[] numTracks2 = new int[1]; - numTracks2[0] = listOfTracksToVertex.length; - event.getAssociationManager().add(new AAssociation("RVx","InDetTrack" + key, numTracks2, listOfTracksToVertex, event)); - }else{//if assocation already exists add new one to it - //Remove old assocation - event.getAssociationManager().remove("InDetTrack" + key + "RVx"); - //Create new assocation by copying old one and adding extra line at the end. - int[][] newAssoc = new int[assoc.length + 1][]; - for(int i = 0; i < newAssoc.length; i++){ - if(i == assoc.length){ - newAssoc[i] = listOfTracksToVertex; - }else{ - newAssoc[i] = assoc[i]; - } - } - //recreating assocation - event.getAssociationManager().add(new AAssociation("RVx","InDetTrack" + key, newAssoc, event)); - } - - - - ATrackData aRTr = null; - aRTr = event.getTrackData("InDetTrack", key); - if (aRTr == null) - { - return; - } - // get helices of the appropriate tracks, helices are access by indices - // save the IDs of tracks into trackIdLocal which will be copied to tracksId - int[] trackIdLocal = new int[listOfTracksToVertex.length]; - AHelix[] thisHelGoToFitter = new AHelix[listOfTracksToVertex.length]; - for (int j = 0; j < listOfTracksToVertex.length; j++) - { - AHelix helix = aRTr.getModifiableHelix(listOfTracksToVertex[j]); - if (helix == null) { - AOutput.alwaysAppend("\nOne or more of the selected tracks do not have perigee parameters, " - + "the vertex cannot be created\n", ALogInterface.BAD_COMMAND); - return; - } - thisHelGoToFitter[j] = helix; - trackIdLocal[j] = aRTr.getIdFromIndex(listOfTracksToVertex[j]); - } - - - double xVtx = parameterStore.get("Event", "XVtx").getD(); - double yVtx = parameterStore.get("Event", "YVtx").getD(); - double zVtx = parameterStore.get("Event", "ZVtx").getD(); - AVertex startingPoint = new AVertex(new double[] { xVtx, yVtx, zVtx }); - try - { - // RuntimeException is thrown - no vertex found or goes on (new vertex) - AVertex vertex = AVertexFit.fitVertex(startingPoint, thisHelGoToFitter); - vertices.add(vertex); // new vertex - tracksIndex.add(listOfTracksToVertex.clone()); // save indices of tracks - tracksId.add(trackIdLocal.clone()); // save IDs of tracks - tracksCollection.add(key); - drawFlag.add(new Boolean(true)); - athenaOrigin.add(new Boolean(false)); - - int[] newNumTracks = new int[numData+1]; - int[] newPrimVxCand = new int[numData+1]; - for (int i=0; i<numData; i++) { - newNumTracks[i] = numTracks[i]; - newPrimVxCand[i] = primVxCand[i]; - } - numTracks = newNumTracks; - primVxCand = newPrimVxCand; - numTracks[numData] = listOfTracksToVertex.length; - primVxCand[numData] = 2; - - if (vertexType != null) { - int[] newVertexType = new int[numData+1]; - for (int i=0; i<numData; i++) { - newVertexType[i] = vertexType[i]; - } - vertexType = newVertexType; - vertexType[numData] = 2; - } - - double[] par = vertex.getPosition(); - double Vx = par[0]; - double Vy = par[1]; - // temp set axis and orientation of 3D rotation wrt last vertex - // adjust the starting point of the tracks according to the vertex - double Vz = par[2]; - for (int j = 0; j < thisHelGoToFitter.length; j++) - { - double a = Vx - xVtx; - double b = Vy - yVtx; - double c = Vz - zVtx; - double size = Math.sqrt(a * a + b * b + c * c); - parameterStore.get("3D", "xAxis").setD(a / size); - parameterStore.get("3D", "yAxis").setD(b / size); - parameterStore.get("3D", "zAxis").setD(c / size); - thisHelGoToFitter[j].setPhiStartByXYPoint(Vx, Vy); - } - AOutput.alwaysAppend("\n" + getHitInfo(numData) + "\n", ALogInterface.NORMAL); - numData++; - makeDrawList(); - } - catch (RuntimeException e) - { - StringBuilder temp = new StringBuilder("\nRVx: tracks ("); - for (int i = 0; i < listOfTracksToVertex.length; i++) - { - if (i > 0) - { - temp.append(", "); - } - // the tracks were accessed by indices but user wants to see - // IDs like pick prints (listOfTracksToVertex[] - indices) - temp.append(aRTr.getIdFromIndex(listOfTracksToVertex[i])); - } - AOutput.alwaysAppend(temp + ")\n not originating from a common vertex\n", ALogInterface.NORMAL); - throw e; - } - } // createVertexFromTracks() ------------------------------------------- - - /** - * 'Colour by vertex type' option, that allows to colour the vertices depending on whether they are primary, - * secondary or other vertices. - */ - protected void colorbyVertexType() { - - int pri = parameterStore.get("RVx", "PriVxColor").getI(); - int sec = parameterStore.get("RVx", "SecVxColor").getI(); - int res = parameterStore.get("RVx", "RestVxColor").getI(); - - if (vertexType!=null) { - for (int i=0; i<numData; ++i) { - int typeId = vertexType[i]; - AVertex.Type type = AVertex.Type.typeFromId(typeId); - switch (type) { - case PRIMARY: - case DUMMY: - color[i] = (byte) pri; - break; - case SECONDARY: - color[i] = (byte) sec; - break; - case TEMPV0LAMBDA: - color[i] = (byte) sec; - break; - case TEMPV0LAMBDABAR: - color[i] = (byte) sec; - break; - case TEMPKSHORT: - color[i] = (byte) sec; - break; - case PILEUP: - case CONVERSION: - case V0: - case KINK: - color[i] = (byte) res; - break; - default: - color[i] = (byte) res; - - } - } - } - else if (primVxCand!=null) { // use primary vertex candidate flag as fall-back if vertex type not available - for (int i=0; i<numData; ++i) { - if (primVxCand[i]==1) { - color[i] = (byte) pri; - } - else { - color[i] = (byte) res; - } - } - } - else { // if no vertex type information, use constant colour - colorByConstant(); - } - } - - protected int internalColor() - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - // The number of vertices can increase when the user fits a vertex in - // Atlantis, make sure the color array also increases in size then - if (numData > color.length) - color = new byte[numData]; - - if (colorFunction == 0) - { - colorByConstant(); - } - else if(colorFunction == 1) - { - colorByIndex(); - } - else if (colorFunction == 2) - { - colorbyVertexType(); - } - return 0; - } // internalColor() ---------------------------------------------------- - - @Override - public void makeDrawList() - { - numDraw = 0; - listdl = new int[numData]; - for (int i = 0; i < numData; i++) { - if (drawFlag.get(i).booleanValue()) { - listdl[numDraw] = i; - numDraw++; - } - } - this.cutTracksByVertexType(); - this.applyCuts(); - } - - private void cutTracksByVertexType() { - numDraw = 0; - listdl = new int[numData]; - for (int i = 0; i < numData; i++) { - if (drawFlag.get(i).booleanValue()) { - // All=0, Primary=1, Secondary=2, Rest=3 - int vertexTypeSelected = parameterStore.get("CutsObjects", "vertextype").getI(); - if (vertexTypeSelected==0) { - listdl[numDraw] = i; - numDraw++; - } - if (vertexTypeSelected==1) { // primary - if (vertexType!=null) { - int typeId = vertexType[i]; - AVertex.Type type = AVertex.Type.typeFromId(typeId); - if (type == PRIMARY || type == DUMMY){ - listdl[numDraw] = i; - numDraw++; - } - } - } - if (vertexTypeSelected==2){ - if (vertexType!=null) { - int typeId = vertexType[i]; - AVertex.Type type = AVertex.Type.typeFromId(typeId); - if (type == SECONDARY || type == TEMPV0LAMBDA || type == TEMPV0LAMBDABAR || type == TEMPKSHORT){ - listdl[numDraw] = i; - numDraw++; - } - } - } - if (vertexTypeSelected==3){ - if (vertexType!=null) { - int typeId = vertexType[i]; - AVertex.Type type = AVertex.Type.typeFromId(typeId); - if (type == PILEUP || type == CONVERSION || type == V0 || type == KINK){ - listdl[numDraw] = i; - numDraw++; - } - } - } - } - } - } - - public String getHitInfo(int index) - { - boolean athenaOriginBoolean = athenaOrigin.get(index).booleanValue(); - String origin = (athenaOriginBoolean == true) ? "Athena" : "Atlantis"; - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+ - "\n calculated in "+origin; - - StringBuilder temp = new StringBuilder(); - temp.append("\n" + getNameScreenName() + " (index: " + index + ") (calculated in " + origin + ")\n" + " type of Track: " + tracksCollection.get(index) + "\n"); - temp.append(" tracks IDs = "); - boolean tracksIDsKnown = false; - if (tracksId.size() > 0) { - int[] tracksIdInVertex = (tracksId.get(index)); - for (int i = 0; i < tracksIdInVertex.length; i++) - { - int id2 = tracksIdInVertex[i]; - // if the JiveXML knows that vertex creates X number of - // tracks but doesn't know the ID, -1 is put as tracks ID - // list of -1 doesn't need to be printed - if (id2 > -1) - { - tracksIDsKnown = true; - if (i > 0) - { - temp.append(","); - } - temp.append(tracksIdInVertex[i]); - } - } - } - if (!tracksIDsKnown) temp.append("n/a"); - //To display in the output screen the vertex type number and description when this is selected - if (vertexType!=null) { - int typeId = vertexType[index]; - AVertex.Type type = AVertex.Type.typeFromId(typeId); - String vertexInfo = String.format("%nVertex type = %d (%s)", typeId, type.description); - temp.append(vertexInfo); - } - temp.append("\nPrimary candidate status = " + primVxCand[index]); - temp.append("\nnumTracks = " + numTracks[index]); - temp.append("\n" + vertices.get(index)); - return temp.toString(); - } // getHitInfo() ------------------------------------------------------- - - @Override - public ACoord getYXUser() - { - makeDrawList(); - double hv[][][] = new double[2][numDraw][]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - AVertex vertex = vertices.get(listdl[i]); - double[][] p = vertex.getYXEllipse(); - hv[0][i] = p[0]; - hv[1][i] = p[1]; - - index[i] = listdl[i]; - } - return new ACoord(hv, index, this); - } // getYXUser() -------------------------------------------------------- - - @Override - public ACoord getXZUser() - { - makeDrawList(); - double hv[][][] = new double[2][numDraw][]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - AVertex vertex = vertices.get(listdl[i]); - double[][] p = vertex.getXZEllipse(); - hv[0][i] = p[0]; - hv[1][i] = p[1]; - index[i] = listdl[i]; - } - return new ACoord(hv, index, this); - } // getXZUser() -------------------------------------------------------- - - @Override - public ACoord getYZUser() - { - makeDrawList(); - double hv[][][] = new double[2][numDraw][]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - AVertex vertex = vertices.get(listdl[i]); - double[][] p = vertex.getYZEllipse(); - hv[0][i] = p[0]; - hv[1][i] = p[1]; - index[i] = listdl[i]; - } - return new ACoord(hv, index, this); - } // getYZUser() -------------------------------------------------------- - - @Override - public ACoord getRZUser() - { - makeDrawList(); - double hv[][][] = new double[2][numDraw][]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - AVertex vertex = vertices.get(listdl[i]); - //TODO: make "RZ ellipse" - double[][] p = vertex.getRZEllipse(); - hv[0][i] = p[0]; - hv[1][i] = p[1]; - index[i] = listdl[i]; - } - return new ACoord(hv, index, this); - } // getRZUser() -------------------------------------------------------- - - @Override - protected ACoord get3DUser() - { - makeDrawList(); - double h[] = new double[numDraw]; - double v[] = new double[numDraw]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - double[] hvo = AProjection3D.getRotated(vertices.get(listdl[i]).getPosition()); - h[i] = hvo[0]; - v[i] = hvo[1]; - index[i] = listdl[i]; - } - return new ACoord(h, v, index, this); - } // get3DUser() -------------------------------------------------------- - - @Override - public ACoord getFZUser() - { - makeDrawList(); - double h[] = new double[numDraw]; - double v[] = new double[numDraw]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - AVertex vertex = vertices.get(listdl[i]); - double[] xyz = vertex.getPosition(); - double phi = vertex.getPhi(); - double z = xyz[2]; - h[i] = z; - v[i] = Math.toDegrees(phi); - index[i] = listdl[i]; - } - return new ACoord(h, v, index, this).includePhiWrapAround("FZ"); - } // getFZUser() -------------------------------------------------------- - - @Override - public ACoord getFRUser() - { - makeDrawList(); - double h[] = new double[numDraw]; - double v[] = new double[numDraw]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - AVertex vertex = vertices.get(listdl[i]); - double rho = vertex.getRho(); - double phi = vertex.getPhi(); - h[i] = rho; - v[i] = Math.toDegrees(phi); - index[i] = listdl[i]; - } - return new ACoord(h, v, index, this).includePhiWrapAround("FR"); - } // getFRUser() -------------------------------------------------------- - - @Override - public ACoord getVPUser() - { - makeDrawList(); - double h[] = new double[numDraw * 2]; - double v[] = new double[numDraw * 2]; - int[] index = new int[numDraw * 2]; - double[] sign = new double[] { -1., 1. }; - int num = 0; - - for (int i = 0; i < numDraw; i++) - { - AVertex vertex = vertices.get(listdl[i]); - double[] xyz = vertex.getPosition(); - // if rho is 0, AMath.eta() divides by 0, since it's real type, - // Infinity is returned, program doesn't crash, vertex is not drawn - // proper would be to test all rho > 0.01cm values in advance - double rho = vertex.getRho(); - double phi = vertex.getPhi(); - double z = xyz[2]; - double eta = AParameterUtilities.eta(z, rho); - double delEta = AProjectionVP.getDeltaEta(rho, z); - for (int j = 0; j < 2; j++) - { - h[num] = eta + sign[j] * delEta; - v[num] = Math.toDegrees(phi); - index[num] = listdl[i]; - num++; - } - } - return new ACoord(h, v, index, this).includePhiWrapAround("VP"); - } // getVPUser() -------------------------------------------------------- - - protected void applyCuts() - { - cutIndex(); - - float[] phi = new float[numDraw]; - float[] eta = new float[numDraw]; - for(int i=0; i<numDraw; i++) - { - AVertex vertex = vertices.get(listdl[i]); - phi[i] = (float) vertex.getPhi(); - double z = vertex.getPosition()[2]; - eta[i] = (float) AParameterUtilities.eta(z, vertex.getRho()); - } - cutPhi(phi); - cutEta(eta); - - cut("CutsInDet", "NumRVxTracks", " Ntrack", numTracks); - cut("CutsInDet", "PrimaryRVx", " Primary", primVxCand); - - } // applyCuts() -------------------------------------------------------- - - /** - * @param nodes Collection - * @return Action[] - * Method returns either empty list of Actions or Vertex item after the - * right mouse click on the list (in the list dialog) - * Vertex only appear if there is one type of reconstructed tracks in the - * list and no other datatype - */ - @Override - public Action[] getActions(Collection nodes) - { - if (nodes.size() != 1) - { - return new Action[0]; - } - final DefaultMutableTreeNode node = (DefaultMutableTreeNode) (nodes.iterator().next()); - if (!node.getAllowsChildren()) - { - return new Action[0]; - } - AList[] list = AListManager.getInstance().getChildren(node); - if (list == null) - { - return new Action[0]; - } - Set<Integer> tracks = new HashSet<Integer>(); - Set<Integer> tracksID = new HashSet<Integer>(); - // iterate over the items in the list (set of whichever datatypes) - // condition in this loop assures that 'Vertex *' action appears only - // if there is/are set(s) of one type of reconstructed tracks and no - // other types. the condition used to be - // list[i].getSource() == ... .event.getRTrData() which was - // a method depending on the current selected Hits-to-RTr association - for (int i = 0; i < list.length; i++) - { - // tests that there is either type of reconstructed tracks in the list - if (list[i].getSource() instanceof ATrackData) - { - // test that there is just one type of reconstructed tracks if - // there are more than one item in list - if (i > 0) - { - String key1 = list[i - 1].getSource().getStoreGateKey(); - String key2 = list[i].getSource().getStoreGateKey(); - if (!(key1 == null && key2 == null) && !key1.equals(key2)) - { - String msg = "info: Vertexing is available if only one " + - "Track collection is chosen in the list. " + - " (select: InDet->Track->Track Collections)\n"; - AOutput.alwaysAppend(msg, ALogInterface.NORMAL); - return new Action[0]; - } - } - // tests passed - save indices of the tracks from the hashtable - for (int j = 0; j < list[i].getItems().length; j++) - { - int index = list[i].getItems()[j]; - int id2 = list[i].getSource().getIdFromIndex(index); - tracks.add(new Integer(index)); - tracksID.add(new Integer(id2)); - } - } - else - { - return new Action[0]; - } - } // for - int numTracks2 = tracks.size(); - if (numTracks2 < 2) - { - return new Action[0]; - } - final String trackName = list[0].getSource().getNameScreenName(); - final String trackStoreGateKey = list[0].getSource().getStoreGateKey(); - final int[] trackNumbers = new int[numTracks2]; // indices of tracks - final int[] trackIDs = new int[numTracks2]; // IDs of tracks - Iterator<Integer> i = tracks.iterator(); - int n = 0; - while (i.hasNext()) - { - trackNumbers[n++] = (i.next()).intValue(); - } - i = tracksID.iterator(); - n = 0; - while (i.hasNext()) - { - trackIDs[n++] = (i.next()).intValue(); - } - Action[] action = new Action[1]; // only one action will be displayed - // after removing interactive Athena - action[0] = new AbstractAction("Vertex " + trackName + " " + trackStoreGateKey + " in Atlantis") - { - public void actionPerformed(ActionEvent e) - { - try - { - createVertexFromTracks(trackNumbers, trackStoreGateKey); - // maybe should be all windows - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - node.setUserObject(new AList(ARVxData.this, numData - 1)); - } - catch (Exception ee) - { - // this exception was initially completely ignored (empty - // block) - can't actually see the reason why it is thrown - // at the end of createVertexFromTracks since it should be - // ignored. whether or not the exception occures tells - // whether the tracks are coming from the common vertex - - logger.debug("ARVxData.getActions() exception: " + ee.getMessage(), ee); - } - } - }; - - return action; - } // getActions() ------------------------------------------------------- - - - /** - * The method is called when Remove action is selected after right-click - * on the list item. There may be vertices coming from different types of - * tracks, trackType variable assures that the current reconstructed track - * instance is retrieved and the helix paremeters set on corrent tracks - * @param index int[] - */ - @Override - public void remove(int[] index) - { - String key = null; - ATrackData aRTr = null; - for (int i = 0; i < index.length; ++i) - { - drawFlag.set(index[i], new Boolean(false)); - key = tracksCollection.get(index[i]); - aRTr = event.getTrackData("InDetTrack", key); - if (aRTr != null) - { - int[] tracksInVertex = (tracksIndex.get(index[i])); - for (int j = 0; j < tracksInVertex.length; ++j) - { - aRTr.getModifiableHelix(tracksInVertex[j]).setPhiStartByXYPoint(0., 0.); - } - } // if - } // for - } // remove() ----------------------------------------------------------- - - /** - * if RVx (with numData > 0) is present in this event, cut Tracks - * forming vertices when tracks are drawn as polylines - */ - public void cutTracksToRVx(AEvent event) - { - if (!hasConsistentTrackNumbers) return; - for (int i = 0; i < numData; i++) - { - boolean origin = athenaOrigin.get(i).booleanValue(); - if (origin) - { - // true - RVx coming from Athena -> cut the track if its - // storeGateKey is known (was saved into tracksCollection) - String trackKey = tracksCollection.get(i); - ATrackData tracks = event.getTrackData("InDetTrack", trackKey); - if (tracks != null) - { - int[] tracksIdInVertex = (tracksId.get(i)); - if (tracksIdInVertex.length < 2) //ACH - put some more cuts on this? - continue; - AHelix[] thisHelGoToFitter = new AHelix[tracksIdInVertex.length]; - AVertex vertex = vertices.get(i); - double[] par = vertex.getPosition(); - double Vx = par[0]; - double Vy = par[1]; - for (int j = 0; j < tracksIdInVertex.length; j++) - { - int id2 = tracksIdInVertex[j]; - // if the JiveXML knows that vertex creates X number of - // tracks but doesn't know the ID, -1 is put as tracks ID - // skip cutting tracks - ID is actually unknown - if (id2 > -1) - { - thisHelGoToFitter[j] = tracks.getModifiableHelix(id2); - thisHelGoToFitter[j].setPhiStartByXYPoint(Vx, Vy); - } - } - } // if(tracks != null) - } - } - } // cutTracksToRVx() ---------------------------------------------------- - - - - /** - * Returns the values of primary vertex for the current event using the - * first vertex in this RVx data if it exists. - * @return double[3] or null - */ - public double[] getPrimaryVertex() - { - double[] vtx = null; // vertex position (x, y, z order) - - if (!(numData > 0)) - { - // Check this? If we have no vertices, want to get a primary vertex - // from somewhere else - return vtx; // null - } - - // if datatype contains primVxCand subtag, then take first item - // flagged 1 (primary vertex candidate) otherwise first item of - // the whole datatype - if(primVxCand != null) - { - for(int i = 0; i < numData; i++) - { - if(primVxCand[i] == 1) - { - vtx = vertices.get(i).getPosition(); - break; - } - } - if(vtx == null) - { - // none of the vetices had flag 1, take the first one anyway - vtx = vertices.get(0).getPosition(); - } - } - else - { - // primVxCand is not available, take the first item - vtx = vertices.get(0).getPosition(); - } - - return vtx; - - } // getPrimaryVertex() ------------------------------------------------- - - - - /** - * - * @param index int - * @return double[] - * Returns double array with x, y, z positions of the vertex - */ - public double[] getVertex(int index) - { - double[] vtx = null; - vtx = vertices.get(index).getPosition(); - return vtx; - - } // getVertex() -------------------------------------------------------- - - -} // class ARVxData ========================================================= diff --git a/graphics/AtlantisJava/src/atlantis/data/AS3DData.java b/graphics/AtlantisJava/src/atlantis/data/AS3DData.java deleted file mode 100644 index 62929b6f6b8a6be49713b401657a1e8d139475fc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AS3DData.java +++ /dev/null @@ -1,486 +0,0 @@ -package atlantis.data; - -import atlantis.event.AAssociation; -import atlantis.event.AData; -import atlantis.event.AEvent; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterUtilities; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - - -/* - * The input array clusters is being used to contain two types of information - * for pixel clusters - * clusters[i][0] = identifier - * clusters[i][1] = -1 - * for space points from 2 strip clusters it contains the identifiers of the - * individual strips - * clusters[i][0] = identifier of first strip - * clusters[i][1] = identifier of second strip - */ -public class AS3DData extends A3DPointData -{ - private int[][] clusters = null; - // read from the event file - protected int[] layer = null; - private int[] etaModule = null; - private int[] phiModule = null; - - // for use by the filter loop, group[] is filled in by hit filter, other - // classes contain group functionality as well but currently (2006/08) - // hit filter takes into account only S3D (SiSpacePoint) data - protected int[] group = null; - private double[] eta = null; - - private boolean[] pixel = null; - public static final int PIXEL = -1; - public static final int CUT_INDET_SCT_ALL = -1; - public static final int CUT_INDET_SCT_EC_NEG = 0; - public static final int CUT_INDET_SCT_BARREL = 1; - public static final int CUT_INDET_SCT_EC_POS = 2; - - - - public String getParameterGroup() - { - return "S3D"; - } - - - public String getName() - { - return "S3D"; - } - - - public String getNameScreenName() - { - return "SpacePoint"; - } - - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+"\n"+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - - String clId = clusters[index][0] + ", " + clusters[index][1]; - String type = pixel[index] ? " (Pixel hit)" : " (SCT hit)"; - - String temp = getNameScreenName() + " (id: " + id[index] + " index: " + index + ")" + - type + - "\n cluster identifiers: " + clId + - "\n x = " + String.format("%.3f",x[index]) + " cm" + - "\n y = " + String.format("%.3f",y[index]) + " cm" + - "\n z = " + String.format("%.3f",z[index]) + " cm" + - "\n " + AMath.RHO + " = " + String.format("%.3f",rho[index]) + - " cm" + - "\n " + AMath.PHI + " = " + - String.format("%.3f",Math.toDegrees(phi[index])) + - AMath.DEGREES + " (" + String.format("%.3f",phi[index]) + " rad)" + - "\n z = " + String.format("%.3f",z[index]) + " cm" + - "\n group = " + group[index]; - temp += "\n " + AMath.ETA + " module = "; - temp += (etaModule != null) ? Integer.toString(etaModule[index]) : "n/a"; - temp += "\n " + AMath.PHI + " module = "; - temp += (phiModule != null) ? Integer.toString(phiModule[index]) : "n/a"; - temp += super.getHitInfo(index); // finds barcode information - - return temp; - - } // getHitInfo() --------------------------------------------------------- - - - - AS3DData(AHashMap p, AEvent e) - { - super(p,e); - - etaModule = (p.get("etaModule") != null) ? p.getIntArray("etaModule") : null; - phiModule = (p.get("phiModule") != null) ? p.getIntArray("phiModule") : null; - - // use this for now as pixel id have bug i.e. sometimes > 0 - layer = p.getUnknownIntArray("layer"); - if(p.get("layer") == null || p.get("sub") == null) - { - calculateLayerSubdetector(); - } - group = new int[numData]; - eta = new double[numData]; - - if(p.get("clusters") != null) - { - // can only distinguish between SCT and Pixel hits if clusters - // subtag is available - pixel = new boolean[numData]; - // save IDs from event file to be available with pick info - clusters = new int[numData][]; - int[][] assocClusters = new int[numData][]; - int[] temp = p.getIntArray("clusters"); - for(int i = 0; i < numData; i++) - { - // save all clusters IDs - clusters[i] = new int[] { temp[2 * i], temp[2 * i + 1] }; - - // check if the second number, PIXEL (-1) designates pixel hit - if(temp[2 * i + 1] != PIXEL) - { - // this is SCT spacepoint - has got two clusters - assocClusters[i] = new int[] { temp[2 * i], temp[2 * i + 1] }; - } - else - { - // this is a pixel spacepoint (second cluster number is -1) - pixel[i] = true; - - // to ignore associtiation between pixel clusters and spacepoints: - // assocClusters[i] = null; - - // taking pixel cluster into account (pixel spacepoint has got - // only one cluster) (where as SCT spacepoint has got two clusters) - assocClusters[i] = new int[] { temp[2 * i] }; - } - } - event.getAssociationManager().add(new AAssociation(getFullName(), "SiCluster", assocClusters, event)); - event.getAssociationManager().add(new AAssociation(getFullName(), "PixelCluster", assocClusters, event)); - } - } - - - - protected void finalizeConstruction() - { - super.finalizeConstruction(); - super.calculateAssociationViaClusters(); - - } // finalizeConstruction() ---------------------------------------------- - - - - protected int internalColor() - { - int numColorTypes = super.internalColor(); - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - if(colorFunction == numColorTypes + 1) - { - colorByGroup(); - } - else if(colorFunction == numColorTypes + 2) - { - colorBy(layer); - } - return numColorTypes + 2; - - } // internalColor() ---------------------------------------------------- - - - protected void colorByGroup() - { - byte ungroupedColor; - if(parameterStore.get(PARAMETER_GROUP, "Ungrouped").getStatus()) - ungroupedColor = (byte) parameterStore.get(PARAMETER_GROUP, "Ungrouped").getI(); - else - ungroupedColor = (byte) parameterStore.get(PARAMETER_GROUP, "Unconnected"). - getI(); - int numColors = (byte) parameterStore.get("HitColors", "Number").getI(); - numColors = Math.min(7, numColors); - int[] col = parameterStore.getArray("HitColors", "C1", numColors); - for(int i = 0; i < numData; i++) - { - if(group[i] == 0) - color[i] = ungroupedColor; - else - color[i] = (byte) col[(group[i] - 1) % numColors]; - } - } - - - - /** - * define noise and good hits type = 0 means noise - * noise hits - hits associated neither with Track not STr - * good hits - hits associated either with Track or with STr plus - * group information - set by the AFilter (hit filter) - */ - protected void setType() - { - int[][] assocSTr = event.getAssociationManager().get(getFullName(), "STr"); - int[][] assocRTr = event.getAssociationManager().get(getFullName(), getReconstructedTracks()); - for(int i = 0; i < numData; i++) - { - if((assocSTr != null && assocSTr[i] != null) || - (assocRTr != null && assocRTr[i] != null) || group[i] > 0) - { - type[i] = 1; - } - else - { - type[i] = 0; - } - } - - } // setType() ---------------------------------------------------------- - - - - protected void applyCuts() - { - cutIndex(); - cutSubdetector(); - cut("CutsInDet", "Layer", " Layer", layer); - cutPhi(phi); - cutEta(rho, z); - cutSimulatedTracks(); - cutReconstructedTracks(); - cut("CutsInDet", "Group", " Group", group); - if(etaModule != null) - { - cut("CutsInDet", "EtaModule", " EtaModule", etaModule); - } - if(phiModule != null) - { - cut("CutsInDet", "PhiModule", " PhiModule", phiModule); - } - } - - private void cutSubdetector() - { - AParameter subPar = parameterStore.get("CutsInDet", "SCT"); - if(subPar.getI() != -1) - cutArray(sub, subPar.getI(), "Barrel/Endcap"); - } - - - public int getLayer(int id) - { - int layer; - if(id > -1) - layer = (id >> 21) & 0xF; - else - layer = (id >> 27) & 0x3; - int sub = getSub(id); - if(id > -1) - { - // strips - if(sub == ASiClusterData.BARREL) - layer += 3; - else - layer += 11; - } - else - { - // pixels - if(sub != ASiClusterData.BARREL) - layer += 7; - } - return layer; - } - - - public int getSub(int id) - { - if(id > -1) - return(id >> 25) & 0x3; - else - return(id >> 29) & 0x3; - } - - - private void calculateLayerSubdetector() - { - final double rhoPixelMax = 24.; - final double zBarrelPixelMax = 41.; - final double zBarrelStripsMax = 78.; - final double[] zEndcapPixel = - {51., 64., 90.}; - final double[] zEndcapStrips = - {88., 98., 116., 134., 156., 190., 233., - 263.}; - final double[] rhoBarrel = - {6.74, 11.5, 23., 34., 40., 48.}; - for(int i = 0; i < numData; i++) - { - double z = Math.abs(this.z[i]); - double r = rho[i]; - if(r < rhoPixelMax) - { - // .............................................. pixels - if(z < zBarrelPixelMax) - { - // ............................................ barrel - sub[i] = 1; - for(int l = 0; l < rhoBarrel.length; l++) - if(r < rhoBarrel[l]) - { - layer[i] = l; - break; - } - } - else - { - // ............................................ end cap - layer[i] = 10; - for(int l = 0; l < zEndcapPixel.length; l++) - { - if(z < zEndcapPixel[l]) - { - layer[i] = 7 + l; - break; - } - } - if(this.z[i] < 0) - sub[i] = 0; - else - sub[i] = 2; - } - } - else - { - // .............................................. strips - - if(z < zBarrelStripsMax) - { - // ............................................ BARREL - sub[i] = 1; - layer[i] = 6; - for(int l = 0; l < rhoBarrel.length; l++) - if(r < rhoBarrel[l]) - { - layer[i] = l; - break; - } - } - else - { - // ............................................ end cap - layer[i] = 19; - for(int l = 0; l < zEndcapStrips.length; l++) - { - if(z < zEndcapStrips[l]) - { - layer[i] = 11 + l; - break; - } - } - if(this.z[i] < 0) - sub[i] = 0; - else - sub[i] = 2; - } - } - } - } - - - // drawlist to be used as input to the filter - public int makeFilterDrawList(double etaRange) - { - calculateRhoPhi(); - - // overwrite the input array to improve speed - numDraw = 0; - for(int i = 0; i < numData; i++) - { - double eta = AParameterUtilities.eta(z[i], rho[i]); - this.eta[i] = eta; - if(eta > -etaRange && eta < etaRange) - { - listdl[numDraw++] = i; - } - } - - return numDraw; - } - - - public int[] getIntegerEta(int numBins, double etaRange, int[] integerEta) - { - // overwrite the input array to improve speed - double binWidth = 2 * etaRange / numBins; - double etaRangeOptimised = etaRange + binWidth; - for(int i = 0; i < numDraw; i++) - // implicit (int) conversion only does correct thing if positive - integerEta[i] = (int) ((eta[listdl[i]] + etaRangeOptimised) / - binWidth); - return integerEta; - } - - - public int[] getIntegerPhi(int numBins, double skew, int[] integerPhi) - { - calculateRhoPhi(); - // overwrite the input array to improve speed - double binWidth = 2 * Math.PI / numBins; - for(int i = 0; i < numDraw; i++) - { - // can only be positive - // add one to treat wraparound efficiently - double p = phi[listdl[i]] - skew * rho[listdl[i]]; - if(p < 0.) - p += 2 * Math.PI; - else if(p > 2 * Math.PI) - p -= 2 * Math.PI; - integerPhi[i] = (int) (p / binWidth) + 1; - } - return integerPhi; - } - - - public int[] getLayer(int[] layer) - { - for(int i = 0; i < numDraw; i++) - layer[i] = this.layer[listdl[i]]; - return layer; - } - - - public void setGroup(int[] group) - { - for(int i = 0; i < numData; i++) - this.group[i] = 0; - for(int i = 0; i < numDraw; i++) - this.group[listdl[i]] = group[i]; - } - - - protected ACoord getFRUser() - { - if(!parameterStore.get("SiCluster", "Stereo").getStatus())return super.getFRUser(); - makeDrawList(); - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - h[i] = rho[list]; - v[i] = Math.toDegrees(AParameterUtilities.getPhiStereo(rho[list], phi[list], z[list])); - index[i] = list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("FR"); - } - - - protected ACoord getFZUser() - { - if(!parameterStore.get("SiCluster", "Stereo").getStatus())return super.getFZUser(); - makeDrawList(); - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - h[i] = z[list]; - v[i] = Math.toDegrees(AParameterUtilities.getPhiStereo(rho[list], phi[list], z[list])); - index[i] = list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("FZ"); - } - -} // class AS3DData ========================================================= diff --git a/graphics/AtlantisJava/src/atlantis/data/ASMTrData.java b/graphics/AtlantisJava/src/atlantis/data/ASMTrData.java deleted file mode 100644 index dfd4eb8c63d4214452baee66bd8eb6201c66bd39..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ASMTrData.java +++ /dev/null @@ -1,626 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.canvas.AWindow; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjection; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionXZ; -import atlantis.utils.A3Vector; -import atlantis.utils.A4Vector; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - -/** - * Simulated particle in the muon system - */ - -public class ASMTrData extends AData -{ - private static final double START_RADIUS = 2.; - protected int[] code; - protected int[] particleType; - protected int[] originVertex; - protected float[] pT; - protected float[][] rho; - protected float[][] phi; - protected float[][] z; - protected float[][] x; - protected float[][] y; - AHelix[] innerTrack; - protected int[] type; - private int[] index; - - - public String getParameterGroup() - { - return "SMTr"; - } - - - public String getName() - { - return "SMTr"; - } - - - public String getNameScreenName() - { - return "SimMuonTrack"; - } - - - ASMTrData(AHashMap p, AEvent e) - { - super(p,e); - rho = new float[2][]; - phi = new float[2][]; - z = new float[2][]; - x = new float[2][]; - y = new float[2][]; - x[0] = new float[numData]; - y[0] = new float[numData]; - rho[0] = p.getFloatArray("rhoVertex"); - phi[0] = p.getFloatArray("phiVertex"); - z[0] = p.getFloatArray("zVertex"); - for(int i = 0; i < numData; ++i) - { - x[0][i] = (float) (rho[0][i] * Math.cos(phi[0][i])); - y[0][i] = (float) (rho[0][i] * Math.sin(phi[0][i])); - } - x[1] = (float[]) x[0].clone(); - y[1] = (float[]) y[0].clone(); - z[1] = (float[]) z[0].clone(); - phi[1] = (float[]) phi[0].clone(); - rho[1] = (float[]) rho[0].clone(); - pT = p.getFloatArray("pt"); - code = p.getIntArray("code"); - type = new int[numData]; - particleType = new int[numData]; - originVertex = p.getIntArray("simulatedVertex"); - for(int i = 0; i < numData; i++) - { - if(Math.abs(code[i]) > 10) - // code is being used to store particle code - particleType[i] = APDGTable.getParticleType(code[i]); - } - calculateReasonableEndpoints(p.getFloatArray("phi"), - p.getFloatArray("eta")); - double[] phiD = new double[numData]; - float[] phiF = p.getFloatArray("phi"); - for(int i = 0; i < numData; i++) - phiD[i] = phiF[i]; - index = indexBy(phiD); - } - - - protected void calculateRhoPhi() - { - calculateRhoPhi(x[0], y[0], rho[0], phi[0]); - calculateRhoPhi(x[1], y[1], rho[1], phi[1]); - } - - private void calculateReasonableEndpoints(float[] phiDir, float[] eta) - { - double rhoTo = 1500.; - double zTo = 2500.; - int maxPoints = 5; - double[] d = new double[maxPoints]; - for(int i = 0; i < numData; i++) - { - int numPoints = 0; - //initial point inside volume - if(rho[0][i] < rhoTo && Math.abs(z[0][i]) < zTo) - { - d[numPoints++] = 0.; - } - double lambda = AMath.lambda(eta[i]); - double x0 = x[0][i]; - double y0 = y[0][i]; - double z0 = z[0][i]; - x[1][i] = (float) x0; - y[1][i] = (float) y0; - z[1][i] = (float) z0; - double u = Math.cos(lambda) * Math.cos(phiDir[i]); - double v = Math.cos(lambda) * Math.sin(phiDir[i]); - double w = Math.sin(lambda); - //intersections with cylinder walls - if(w != 0.) - { - d[numPoints++] = (zTo - z0) / w; - d[numPoints++] = ( -zTo - z0) / w; - } - double a = u * u + v * v; - double c = x0 * x0 + y0 * y0 - rhoTo * rhoTo; - double b = 2 * (u * x0 + v * y0); - double squared = b * b - 4 * a * c; - if(squared >= 0.) - { - d[numPoints++] = ( -b + Math.sqrt(squared)) / (2 * a); - d[numPoints++] = ( -b - Math.sqrt(squared)) / (2 * a); - } - //bubble sort points by increasing path length - for(int j = 0; j < numPoints - 1; ++j) - for(int k = j + 1; k < numPoints; ++k) - if(d[k] < d[j]) - { - double temp = d[k]; - d[k] = d[j]; - d[j] = temp; - } - for(int j = 0; j < numPoints; ++j) - if(d[j] >= 0. && j < numPoints - 1) - { - x[0][i] = (float) (x0 + d[j] * u); - y[0][i] = (float) (y0 + d[j] * v); - z[0][i] = (float) (z0 + d[j] * w); - x[1][i] = (float) (x0 + d[j + 1] * u); - y[1][i] = (float) (y0 + d[j + 1] * v); - z[1][i] = (float) (z0 + d[j + 1] * w); - break; - } - } - } - - - protected void finalizeConstruction() - { - super.finalizeConstruction(); - // needs ZVTx - innerTrack = new AHelix[numData]; - for(int i = 0; i < numData; ++i) - { - double p = AMath.getPFromPttL(pT[i], - AMath.tanLambda(AParameterUtilities.eta(z[0][i], - rho[0][i]))); - // correct for average energy loss - double pTCorrected = pT[i] * (p + 3.7) / p; - innerTrack[i] = new AHelix((float) 0., - (float) (parameterStore.get("Event", "ZVtx").getD()), ( - float) (Math.toDegrees(phi[0][i])), - (float) AMath.tanLambda(AParameterUtilities.eta(z[0][i], - rho[0][i])), (float) pTCorrected); - // calculatePhiCorrection(i); - } - } - - - protected void applyCuts() - { - cutIndex(); - cut("CutsInDet", "STrType", " STr Type", particleType); - cut("CutsInDet", "STr", " STr id", id); - cut("CutsInDet", "Pt", " |Pt|", pT); - cut("CutsInDet", "SVx", " Vertex", originVertex); - cutPhi(phi[1]); - float[] phiStart = new float[numData]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int iMax = 0; - if(rho[1][list] > rho[0][list]) - iMax = 1; - int iMin = 1 - iMax; - phiStart[list] = (float) phi[iMin][list]; - } - cutPhi(phiStart); - cutEta(rho[1], z[1]); - } - - - protected int internalColor() - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - if(colorFunction == 0) - colorByConstant(); - else if(colorFunction == 1) - colorByIndex(index); - else if(colorFunction == 2) - colorBy("ParticleColors", particleType); - return 2; - } - - - public String getHitInfo(int index) - { - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (id: " + id[index] + " index: " + index + ")"); - msg.append("\n Type = "); - msg.append(APDGTable.getName(code[index])); - if (innerTrack != null) - msg.append(innerTrack[index].toString()); - msg.append("\n pT (muon spectrometer) = "); - msg.append(String.format("%.3f",pT[index])); - msg.append(" GeV"); - - return msg.toString(); - } - - - protected void cutStartRadius() - { - int num = 0; - for(int i = 0; i < numDraw; i++) - if(Math.min(Math.abs(z[0][listdl[i]] / rho[0][listdl[i]]), - Math.abs(z[1][listdl[i]] / rho[1][listdl[i]])) - < 12.3 / 9.2) - listdl[num++] = listdl[i]; - numDraw = num; - } - - - protected void cutStartRadius2() - { - int num = 0; - for(int i = 0; i < numDraw; i++) - if(Math.max(Math.abs(z[0][listdl[i]] / rho[0][listdl[i]]), - Math.abs(z[1][listdl[i]] / rho[1][listdl[i]])) - > 12.3 / 9.2) - listdl[num++] = listdl[i]; - numDraw = num; - } - - - protected ACoord getYXUser() - { - makeDrawList(); - cutStartRadius(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for(int j = 0; j < 2; j++) - { - hv[0][j][i] = x[j][list]; - hv[1][j][i] = y[j][list]; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } - - - protected ACoord getRZUser() - { - makeDrawList(); - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - int numSplit = 0; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double phiDiff = Math.abs(phi[0][list] - phiMid); - double sign0 = -1.; - if(phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - sign0 = +1.; - phiDiff = Math.abs(phi[1][list] - phiMid); - double sign1 = -1.; - if(phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - sign1 = +1.; - if(sign0 != sign1) numSplit++; - } - int numPoints = 100; - double[][][] hv = new double[2][numDraw + numSplit][]; - int[] index = new int[numDraw + numSplit]; - int num = 0; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double phiDiff = Math.abs(phi[0][list] - phiMid); - double sign0 = -1.; - if(phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - sign0 = +1.; - phiDiff = Math.abs(phi[1][list] - phiMid); - double sign1 = -1.; - if(phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - sign1 = +1.; - if(sign0 == sign1) - { - hv[0][num] = AMath.splitLineIntoPieces(new double[] - {z[1][list], z[0][list]}, numPoints); - double[] xx = AMath.splitLineIntoPieces(new double[] - {x[1][list], x[0][list]}, numPoints); - double[] yy = AMath.splitLineIntoPieces(new double[] - {y[1][list], y[0][list]}, numPoints); - hv[1][num] = new double[xx.length]; - for(int j = 0; j < xx.length; ++j) - hv[1][num][j] = sign0 * - Math.sqrt(xx[j] * xx[j] + yy[j] * yy[j]); - index[num++] = list; - } - else - { - //just for now.... - double a = Math.cos(phiMid); - double b = Math.sin(phiMid); - double x0 = x[0][list]; - double y0 = y[0][list]; - double z0 = z[0][list]; - double dx = x[1][list] - x0; - double dy = y[1][list] - y0; - double dz = z[1][list] - z0; - double mag = Math.sqrt(dx * dx + dy * dy + dz * dz); - dx /= mag; - dy /= mag; - dz /= mag; - double d = -(a * x0 + b * y0) / (a * dx + b * dy); - double xMid = x0 + d * dx; - double yMid = y0 + d * dy; - double zMid = z0 + d * dz; - hv[0][num] = AMath.splitLineIntoPieces(new double[] - {zMid, z[0][list]}, numPoints); - double[] xx = AMath.splitLineIntoPieces(new double[] - {xMid, x[0][list]}, numPoints); - double[] yy = AMath.splitLineIntoPieces(new double[] - {yMid, y[0][list]}, numPoints); - hv[1][num] = new double[xx.length]; - for(int j = 0; j < xx.length; ++j) - hv[1][num][j] = sign0 * - Math.sqrt(xx[j] * xx[j] + yy[j] * yy[j]); - index[num++] = list; - hv[0][num] = AMath.splitLineIntoPieces(new double[] - {z[1][list], zMid}, numPoints); - xx = AMath.splitLineIntoPieces(new double[] - {x[1][list], xMid}, numPoints); - yy = AMath.splitLineIntoPieces(new double[] - {y[1][list], yMid}, numPoints); - hv[1][num] = new double[xx.length]; - for(int j = 0; j < xx.length; ++j) - hv[1][num][j] = sign1 * - Math.sqrt(xx[j] * xx[j] + yy[j] * yy[j]); - index[num++] = list; - } - } - return new ACoord(hv, index, this, ACoord.SMOOTH_POLYLINES); - } - - - protected ACoord getFRUser() - { - makeDrawList(); - cutStartRadius(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int iMax = 0; - if(rho[1][list] > rho[0][list]) - iMax = 1; - int iMin = 1 - iMax; - double rho1 = rho[iMin][list]; - double rho2 = rho[iMax][list]; - if(rho1 > START_RADIUS) - { - hv[0][0][i] = rho1; - hv[1][0][i] = Math.toDegrees(phi[iMin][list]); - } - else - { - double[] rpz = calculateRhoPhiZAtStart(list); - hv[0][0][i] = rpz[0]; - hv[1][0][i] = Math.toDegrees(rpz[1]); - } - hv[0][1][i] = rho2; - hv[1][1][i] = Math.toDegrees(phi[iMax][list]); - index[i] = list; - } - return new ACoord(hv, index, this, - ACoord.LINES).includePhiWrapAround("FR"); - } - - - protected ACoord getXZUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - double phi0 = Math.toRadians(AProjectionXZ.getPhi()); - double cosPhi0 = Math.cos(phi0); - double sinPhi0 = Math.sin(phi0); - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for(int j = 0; j < 2; j++) - { - hv[0][j][i] = z[j][list]; - hv[1][j][i] = x[j][list] * cosPhi0 + y[j][list] * sinPhi0; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } - - - protected ACoord getYZUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - double phi0 = Math.toRadians(AProjectionXZ.getPhi()); - double cosPhi0 = Math.cos(phi0); - double sinPhi0 = Math.sin(phi0); - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for(int j = 0; j < 2; j++) - { - hv[0][j][i] = z[j][list]; - hv[1][j][i] = y[j][list] * cosPhi0 - x[j][list] * sinPhi0; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } - - - protected ACoord getFZUser() - { - makeDrawList(); - cutStartRadius2(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int iMax = 0; - if(rho[1][list] > rho[0][list]) - iMax = 1; - int iMin = 1 - iMax; - double rho1 = rho[iMin][list]; - if(rho1 > START_RADIUS) - { - hv[0][0][i] = z[iMin][list]; - hv[1][0][i] = Math.toDegrees(phi[iMin][list]); - } - else - { - double[] rpz = calculateRhoPhiZAtStart(list); - hv[0][0][i] = rpz[2]; - hv[1][0][i] = Math.toDegrees(rpz[1]); - } - hv[0][1][i] = z[iMax][list]; - hv[1][1][i] = Math.toDegrees(phi[iMax][list]); - index[i] = list; - } - return new ACoord(hv, index, this, - ACoord.LINES).includePhiWrapAround("FZ"); - } - - - public void draw(AWindow window, AGraphics ag, AProjection2D projection) - { - if(projection instanceof AProjectionVP) - { - ag.draw(window.calculateDisplay(getVPUser(window, projection))); - } - else - super.draw(window, ag, projection); - } - - - // a track has two arms in the VPlot - - protected ACoord getVPUser(AWindow window, AProjection projection) - { - makeDrawList(); - - // make a copy of the points to draw: both arms * ??? - double[][][] hv = new double[2][2 * numDraw][]; - int[] index = new int[2 * numDraw]; - int num = 0; - - //loop over drawn objects? - for(int j = 0; j < numDraw; ++j) - { - // get list item from draw index list? - int list = listdl[j]; - // get the helix that should be drawn - ADHelix dhelix = new ADHelix(innerTrack[list]); - // get the helix start and end - double s1 = dhelix.getAStart(); - double s2 = 179.; - // hardwire projection.getMinRho() == 2. for now - s1 = dhelix.intersectWithRadialCylinder(((AProjection2D) projection). - getMinRho(), s1, s2); - double sEnd = dhelix.intersectWithCylinder(true, - AProjectionVP.getRhoVPlot(), true, - AProjectionVP.getZVPlot()); - s2 = Math.max(Math.min(s2, sEnd), s1); - // if the whole helix is to be drawn (which are unusual - // helices, shorten it a little to avoid wraparound problems - if(s1 == 0. && s2 == 180.) s2 = 179.; - if(parameterStore.get("VP", "ShortV").getStatus() && - !parameterStore.get("Data", "S3D").getStatus()) - s1 = s2 - parameterStore.get("VP", "ShortV").getD() * (s2 - s1); - if(s2 > s1) - { - int signMin = -1; - int signMax = 1; - for(int sign = signMin; sign <= signMax; sign += 2) - { - // ugly must change structure at some point - AProjectionVP.sign = sign; - ACoord pointsOnHelix = dhelix.drawHelix(window, - (AProjection2D) projection, s1, s2); - hv[0][num] = pointsOnHelix.hv[0][0]; - hv[1][num] = pointsOnHelix.hv[1][0]; - index[num] = list; - num++; - } - } - } - return window.calculateUser(new ACoord(hv, index, this, - ACoord.SMOOTH_POLYLINES)). - includePhiWrapAround(projection.getName()); - } - - - private double[] calculateRhoPhiZAtStart(int index) - { - double[] rpz = new double[3]; - double rho1 = rho[0][index]; - double phi1 = phi[0][index]; - double z1 = z[0][index]; - double rho2 = rho[1][index]; - double phi2 = phi[1][index]; - double z2 = z[1][index]; - double x1 = rho1 * Math.cos(phi1); - double y1 = rho1 * Math.sin(phi1); - double x2 = rho2 * Math.cos(phi2); - double y2 = rho2 * Math.sin(phi2); - double fract = (START_RADIUS - rho1) / (rho2 - rho1); - double x = x1 + fract * (x2 - x1); - double y = y1 + fract * (y2 - y1); - double z = z1 + fract * (z2 - z1); - double phi = Math.atan2(y, x); - if(phi < 0.) phi += 2 * Math.PI; - rpz[0] = START_RADIUS; - rpz[1] = phi; - rpz[2] = z; - return rpz; - } - - - public String getVPHitInfo() - { - makeDrawList(); - if (numDraw == 0) - return ""; - double sumP = 0.; - double sumPt = 0.; - for(int i = 0; i < numDraw; ++i) - { - sumPt += Math.abs(pT[listdl[i]]); - double invLambda = (rho[1][listdl[i]] - rho[0][listdl[i]]) / - (z[1][listdl[i]] - z[0][listdl[i]]); - sumP += Math.abs(pT[listdl[i]] / Math.cos(Math.atan(1. / invLambda))); - } - - String msg = numDraw + " " + getNameScreenName(); - msg += " sum(PT) = " + String.format("%.1f",sumPt) + " sum(P) = " + String.format("%.1f",sumP); - - return msg; - } - - - public A4Vector get4Vector(int num, int[] list) - { - A4Vector sum = new A4Vector(); - for(int i = 0; i < num; ++i) - { - int k = list[i]; - A3Vector start = A3Vector.fromRhoPhiZ(rho[0][k], phi[0][k], - z[0][k]); - A3Vector stop = A3Vector.fromRhoPhiZ(rho[1][k], phi[1][k], - z[1][k]); - A3Vector v = (stop.subtract(start)).normalize(); - double p = pT[k] / Math.sqrt(1. - v.z * v.z); - sum.add(new A4Vector(v.scale(p), 0.)); - } - return sum; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ASNPData.java b/graphics/AtlantisJava/src/atlantis/data/ASNPData.java deleted file mode 100644 index 4c6602479950fc2da6ebc1769c5661b812137557..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ASNPData.java +++ /dev/null @@ -1,659 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.graphics.ACoord; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjectionXZ; -import atlantis.utils.A3Vector; -import atlantis.utils.A4Vector; -import atlantis.utils.AHashMap; -import atlantis.utils.ALogger; -import atlantis.utils.AMath; - -/** - * Simulated Neutral Particle - */ - -public class ASNPData extends AData -{ - private static ALogger logger = ALogger.getLogger(ASNPData.class); - - private static final double START_RADIUS = 2.; - - protected int[] code; - protected int[] particleType; - protected int[] originVertex; - protected float[] pT; - protected float[][] rho; - protected float[][] phi; - protected float[][] z; - protected float[][] x; - protected float[][] y; - protected int[] type; - private float[] temp; - private int[] index; - - public float[] getPt() - { - return pT; - } - - public String getParameterGroup() - { - return "SNP"; - } - - public String getName() - { - return "SNP"; - } - - public String getNameScreenName() - { - return "SimNeutralTrack"; - } - - ASNPData(AHashMap p, AEvent e) - { - super(p,e); - rho = new float[2][]; - phi = new float[2][]; - z = new float[2][]; - x = new float[2][numData]; - y = new float[2][numData]; - rho[0] = p.getFloatArray("rhoVertex"); - phi[0] = p.getFloatArray("phiVertex"); - z[0] = p.getFloatArray("zVertex"); - - pT = p.getFloatArray("pt"); - code = p.getIntArray("code"); - type = new int[numData]; - particleType = new int[numData]; - originVertex = p.getIntArray("simulatedVertex"); - temp = new float[numData]; - for (int i = 0; i < numData; i++) - { - if (Math.abs(code[i]) > 10) - { - // code is being used to store particle code - particleType[i] = APDGTable.getParticleType(code[i]); - } - } - calculateReasonableEndpoints(p.getFloatArray("phi"), p.getFloatArray("eta")); - - double[] phiD = new double[numData]; - float[] phiF = p.getFloatArray("phi"); - - for (int i = 0; i < numData; i++) - phiD[i] = phiF[i]; - index = indexBy(phiD); - calculateXY(rho[0], phi[0], x[0], y[0]); - calculateXY(rho[1], phi[1], x[1], y[1]); - } - - protected void calculateRhoPhi() - { - calculateRhoPhi(x[0], y[0], rho[0], phi[0]); - calculateRhoPhi(x[1], y[1], rho[1], phi[1]); - } - - public static AHashMap createSNP(AHashMap p) - { - float[] pt = p.getFloatArray("pt"); - float[] phi = p.getFloatArray("phi"); - float[] eta = p.getFloatArray("eta"); - float[] rhoVertex = p.getFloatArray("rhoVertex"); - float[] phiVertex = p.getFloatArray("phiVertex"); - float[] zVertex = p.getFloatArray("zVertex"); - int[] id = p.getIntArray("id"); - - int[] code = p.getIntArray("code"); - - int numNeutral = 0; - - for (int i = 0; i < code.length; ++i) - { - int charge = code[i]; - - try - { - if (Math.abs(code[i]) >= 10) - - // code is being used to store particle code - charge = APDGTable.getCharge(code[i]); - if (charge == 0) - numNeutral++; - } - catch (APDGTable.ParticleNotFoundError pnf){ - logger.debug(pnf.getMessage()); - } - } - - int[] simulatedVertex = ASVxData.assignVertexNumbers(phiVertex, rhoVertex, zVertex); - - int[] idN = new int[numNeutral]; - float[] rhoVertexN = new float[numNeutral]; - float[] phiVertexN = new float[numNeutral]; - float[] zVertexN = new float[numNeutral]; - float[] ptN = new float[numNeutral]; - float[] phiN = new float[numNeutral]; - float[] etaN = new float[numNeutral]; - int[] codeN = new int[numNeutral]; - int[] simulatedVertexN = new int[numNeutral]; - - numNeutral = 0; - for (int i = 0; i < code.length; ++i) - { - double charge = code[i]; - - try - { - if (Math.abs(code[i]) >= 10) - { - // code is being used to store particle code - charge = APDGTable.getCharge(code[i]); - } - if (charge == 0) - { - idN[numNeutral] = id[i]; - rhoVertexN[numNeutral] = (float) Math.sqrt(rhoVertex[i]*rhoVertex[i]-zVertex[i]*zVertex[i]); - phiVertexN[numNeutral] = phiVertex[i]; - zVertexN[numNeutral] = zVertex[i]; - ptN[numNeutral] = pt[i]; - phiN[numNeutral] = phi[i]; - etaN[numNeutral] = eta[i]; - codeN[numNeutral] = code[i]; - simulatedVertexN[numNeutral] = simulatedVertex[i]; - numNeutral++; - } - } - catch (APDGTable.ParticleNotFoundError pnf){ - logger.debug(pnf.getMessage()); - } - } - - AHashMap newP = new AHashMap(10); - - newP.put("numData", new Integer(numNeutral)); - newP.put("id", idN); - newP.put("rhoVertex", rhoVertexN); - newP.put("phiVertex", phiVertexN); - newP.put("zVertex", zVertexN); - newP.put("pt", ptN); - newP.put("phi", phiN); - newP.put("eta", etaN); - newP.put("code", codeN); - newP.put("simulatedVertex", simulatedVertexN); - return newP; - } - - private void calculateReasonableEndpoints(float[] dirPhi, float[] dirEta) - { - double rhoTo = parameterStore.get("RTr", "RadiusTr").getD(); - double zTo = parameterStore.get("RTr", "ZTr").getD(); - - rho[1] = (float[]) rho[0].clone(); - phi[1] = (float[]) phi[0].clone(); - z[1] = (float[]) z[0].clone(); - for (int i = 0; i < numData; i++) - { - if (particleType[i] == 5) - { - // photon -> ecal entrance - rhoTo = 150.; - zTo = 370.; - } - else - { - // neutral hadron -> hcal entrance - rhoTo = 228.; - zTo = 426.2; - } - if (rho[0][i] > rhoTo || Math.abs(z[0][i]) > zTo) - continue; - double rho2 = rhoTo; - double tanLambda = AMath.tanLambda(dirEta[i]); - double zz = z[0][i] + (rho2 - rho[0][i]) * tanLambda; - - if (zz > zTo) - rho2 = (zTo - z[0][i]) / tanLambda + rho[0][i]; - if (zz < -zTo) - rho2 = (-zTo - z[0][i]) / tanLambda + rho[0][i]; - double x = rho[0][i] * Math.cos(phi[0][i]); - double y = rho[0][i] * Math.sin(phi[0][i]); - // y=mx+c, x*x+y*y=rho2*rho2 - double m = Math.tan(dirPhi[i]); - double c = y - m * x; - // ax^2+bx+cc=0 - double a = m * m + 1.; - double b = 2. * m * c; - double cc = c * c - rho2 * rho2; - double d = Math.sqrt(b * b - 4 * a * cc); - double x1 = (-b + d) / (a * 2); - double x2 = (-b - d) / (a * 2); - double y1 = m * x1 + c; - double y2 = m * x2 + c; - double xx = x1; - double yy = y1; - - if ((x2 - x) * Math.cos(dirPhi[i]) + (y2 - y) * Math.sin(dirPhi[i]) > 0.) - { - xx = x2; - yy = y2; - } - zz = z[0][i] + (rho2 - rho[0][i]) * tanLambda; - rho[1][i] = (float) Math.sqrt(xx * xx + yy * yy); - phi[1][i] = (float) Math.atan2(yy, xx); - if (phi[1][i] < 0.) - phi[1][i] += 2 * Math.PI; - z[1][i] = (float) zz; - } - } - - protected void applyCuts() - { - cutIndex(); - cut("CutsInDet", "STrType", " STr Type", particleType); - cut("CutsInDet", "STr", " STr id", id); - cut("CutsInDet", "Pt", " |Pt|", pT); - cut("CutsInDet", "SVx", " Vertex", originVertex); - cut("CutsInDet", "d0", " |d0|", getD0()); - cut("CutsInDet", "d0Loose", " |d0Loose|", getD0()); - cut("CutsInDet", "z0-zVtx", " |z0-zVtx|", getZ0Primary()); - cut("CutsInDet", "z0", " |z0|", getZ0()); - cutPhi(phi[1]); - float[] phiStart = new float[numData]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int iMax = 0; - - if (rho[1][list] > rho[0][list]) - iMax = 1; - int iMin = 1 - iMax; - - if (rho[iMin][list] > START_RADIUS) - phiStart[list] = phi[iMin][list]; - else - { - double[] rpz = calculateRhoPhiZAtStart(list); - - phiStart[list] = (float) rpz[1]; - } - } - cutPhi(phiStart); - cutEta(rho[1], z[1]); - } - - protected int internalColor() - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - if (colorFunction == 0) - colorByConstant(); - else if (colorFunction == 1) - colorByIndex(index); - else if (colorFunction == 2) - colorBy(getPt()); - else if (colorFunction == 3) - colorBy("ParticleColors", particleType); - else if (colorFunction == 4) - colorBy(originVertex); - return 3; - } - - public String getHitInfo(int index) - { - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (id: " + id[index] + " index: " + index + ")"); - msg.append("\n Type = "); - msg.append(APDGTable.getName(code[index])); - msg.append("\n PT = "); - msg.append(String.format("%.3f",pT[index])); - msg.append(" GeV"); - - return msg.toString(); - } - - protected void cutStartRadius() - { - int num = 0; - - for (int i = 0; i < numDraw; i++) - if (Math.max(rho[0][listdl[i]], rho[1][listdl[i]]) > START_RADIUS) - listdl[num++] = listdl[i]; - numDraw = num; - } - - protected ACoord getYXUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - for (int j = 0; j < 2; j++) - { - hv[0][j][i] = x[j][list]; - hv[1][j][i] = y[j][list]; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } - - protected ACoord getRZUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double phiDiff = Math.abs(phi[1][list] - phiMid); - double sign; - - // this is not quite correct need to split some tracks - if (phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - sign = +1.; - else - sign = -1.; - for (int j = 0; j < 2; j++) - { - hv[0][j][i] = z[j][list]; - hv[1][j][i] = sign * rho[j][list]; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } - - protected ACoord getFRUser() - { - makeDrawList(); - cutStartRadius(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int iMax = 0; - - if (rho[1][list] > rho[0][list]) - iMax = 1; - int iMin = 1 - iMax; - double rho1 = rho[iMin][list]; - double rho2 = rho[iMax][list]; - - if (rho1 > START_RADIUS) - { - hv[0][0][i] = rho1; - hv[1][0][i] = Math.toDegrees(phi[iMin][list]); - } - else - { - double[] rpz = calculateRhoPhiZAtStart(list); - - hv[0][0][i] = rpz[0]; - hv[1][0][i] = Math.toDegrees(rpz[1]); - } - hv[0][1][i] = rho2; - hv[1][1][i] = Math.toDegrees(phi[iMax][list]); - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES).includePhiWrapAround("FR"); - } - - protected ACoord getXZUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - double phi0 = Math.toRadians(AProjectionXZ.getPhi()); - double cosPhi0 = Math.cos(phi0); - double sinPhi0 = Math.sin(phi0); - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - for (int j = 0; j < 2; j++) - { - hv[0][j][i] = z[j][list]; - hv[1][j][i] = x[j][list] * cosPhi0 + y[j][list] * sinPhi0; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } - - protected ACoord getYZUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - double phi0 = Math.toRadians(AProjectionXZ.getPhi()); - double cosPhi0 = Math.cos(phi0); - double sinPhi0 = Math.sin(phi0); - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - for (int j = 0; j < 2; j++) - { - hv[0][j][i] = z[j][list]; - hv[1][j][i] = y[j][list] * cosPhi0 - x[j][list] * sinPhi0; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } - - protected ACoord getFZUser() - { - makeDrawList(); - cutStartRadius(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int iMax = 0; - - if (rho[1][list] > rho[0][list]) - iMax = 1; - int iMin = 1 - iMax; - double rho1 = rho[iMin][list]; - - if (rho1 > START_RADIUS) - { - hv[0][0][i] = z[iMin][list]; - hv[1][0][i] = Math.toDegrees(phi[iMin][list]); - } - else - { - double[] rpz = calculateRhoPhiZAtStart(list); - - hv[0][0][i] = rpz[2]; - hv[1][0][i] = Math.toDegrees(rpz[1]); - } - hv[0][1][i] = z[iMax][list]; - hv[1][1][i] = Math.toDegrees(phi[iMax][list]); - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES).includePhiWrapAround("FZ"); - } - - protected ACoord getVPUser() - { - makeDrawList(); - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - h[i] = AParameterUtilities.eta(z[1][list], rho[1][list]); - v[i] = Math.toDegrees(phi[1][list]); - index[i] = list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("VP"); - } - - private double[] calculateRhoPhiZAtStart(int index) - { - double[] rpz = new double[3]; - double rho1 = rho[0][index]; - double phi1 = phi[0][index]; - double z1 = z[0][index]; - double rho2 = rho[1][index]; - double phi2 = phi[1][index]; - double z2 = z[1][index]; - double x1 = rho1 * Math.cos(phi1); - double y1 = rho1 * Math.sin(phi1); - double x2 = rho2 * Math.cos(phi2); - double y2 = rho2 * Math.sin(phi2); - double fract = (START_RADIUS - rho1) / (rho2 - rho1); - double x = x1 + fract * (x2 - x1); - double y = y1 + fract * (y2 - y1); - double z = z1 + fract * (z2 - z1); - double phi = Math.atan2(y, x); - - if (phi < 0.) - phi += 2 * Math.PI; - rpz[0] = START_RADIUS; - rpz[1] = phi; - rpz[2] = z; - return rpz; - } - - public String getVPHitInfo() - { - makeDrawList(); - if (numDraw == 0) - return ""; - double sumP = 0.; - double sumPt = 0.; - - for (int i = 0; i < numDraw; ++i) - { - sumPt += Math.abs(pT[listdl[i]]); - double invLambda = (rho[1][listdl[i]] - rho[0][listdl[i]]) / (z[1][listdl[i]] - z[0][listdl[i]]); - sumP += Math.abs(pT[listdl[i]] / Math.cos(Math.atan(1. / invLambda))); - } - - String msg = numDraw + " " + getNameScreenName(); - msg += " sum(PT) = " + String.format("%.1f",sumPt) + " sum(P) = " + String.format("%.1f",sumP); - - return msg; - } - - public A4Vector get4Vector(int num, int[] list) - { - A4Vector sum = new A4Vector(); - for (int i = 0; i < num; ++i) - { - int k = list[i]; - A3Vector start = A3Vector.fromRhoPhiZ(rho[0][k], phi[0][k], z[0][k]); - A3Vector stop = A3Vector.fromRhoPhiZ(rho[1][k], phi[1][k], z[1][k]); - A3Vector v = (stop.subtract(start)).normalize(); - double p = pT[k] / Math.sqrt(1. - v.z * v.z); - sum.add(new A4Vector(v.scale(p), 0.)); - } - - return sum; - } - - private float[] getZ0() - { - for (int i = 0; i < numDraw; ++i) - { - int list = listdl[i]; - double[] poca = getPoca(list); - temp[list] = (float) poca[2]; - } - return temp; - } - - private float[] getZ0Primary() - { - double[] primary = event.getPrimaryVertex(); - double c = primary[2]; - for (int i = 0; i < numDraw; ++i) - { - int list = listdl[i]; - double[] poca = getPoca(list); - temp[list] = (float) (poca[2] - c); - } - return temp; - } - - private float[] getD0() - { - double[] primary = event.getPrimaryVertex(); - double a = primary[0]; - double b = primary[1]; - for (int i = 0; i < numDraw; ++i) - { - int list = listdl[i]; - double[] poca = getPoca(list); - temp[list] = (float) Math.hypot(a-poca[0], b-poca[1]); - } - return temp; - } - - private double[] getPoca(int i) - { - double[] primary = event.getPrimaryVertex(); - double a = primary[0]; - double b = primary[1]; - double xMin; - double yMin; - double zMin; - double dx = x[1][i] - x[0][i]; - if (dx == 0.) - { - xMin = x[0][i]; - yMin = b; - } - else - { - double m = (y[1][i] - y[0][i]) / dx; - double c = y[0][i] - m * x[0][i]; - xMin = (a + (b - c) * m) / (m * m + 1); - yMin = m * xMin + c; - } - double dz = z[1][i] - z[0][i]; - if (dz == 0.) - { - zMin = z[0][i]; - } - else - { - double mx = (x[1][i] - x[0][i]) / dz; - if (mx != 0.) - zMin = z[0][i] + (xMin - x[0][i]) / mx; - else - { - double my = (y[1][i] - y[0][i]) / dz; - if (my != 0.) - zMin = z[0][i] + (yMin - y[0][i]) / my; - else - zMin = z[0][i]; - } - } - return new double[] { xMin, yMin, zMin }; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ASTrData.java b/graphics/AtlantisJava/src/atlantis/data/ASTrData.java deleted file mode 100644 index aa8f6caa5d799ad6afbf18fd94eef53fb58441d2..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ASTrData.java +++ /dev/null @@ -1,254 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.utils.AHashMap; -import atlantis.utils.AAtlantisException; -import atlantis.utils.ALogger; - -public class ASTrData extends ATrackData -{ - private static ALogger logger = ALogger.getLogger(ASTrData.class); - - public static final int UNDERLYING_EVENT = 0; - public static final int NORMAL = 1; - - protected int[] code; - protected int[] type; - protected int[] particleType; - protected int[] originVertex; - - public String getParameterGroup() - { - return "STr"; - } - - public String getName() - { - return "STr"; - } - - public String getNameScreenName() - { - return "SimChargedTrack"; - } - - ASTrData(AHashMap p, AEvent e) throws AAtlantisException - { - super(p,e); - code = p.getIntArray("code"); - originVertex = p.getIntArray("originVertex"); - type = p.getIntArray("type"); - particleType = new int[numData]; - for(int i = 0; i < numData; i++) - particleType[i] = APDGTable.getParticleType(code[i]); - } - - - public static AHashMap createSTr(AHashMap p) - { - float[] pt = p.getFloatArray("pt"); - float[] phi = p.getFloatArray("phi"); - float[] eta = p.getFloatArray("eta"); - float[] rhoVertex = p.getFloatArray("rhoVertex"); - float[] phiVertex = p.getFloatArray("phiVertex"); - float[] zVertex = p.getFloatArray("zVertex"); - int[] id = p.getIntArray("id"); - int[] code = p.getIntArray("code"); - //rhoEndVertex not available in older xml files - check that it exists first. - float[] rhoEndVertex = (p.get("rhoEndVertex") != null) ? p.getFloatArray("rhoEndVertex") : null; - //float[] phiEndVertex = (p.get("phiEndVertex") != null) ? p.getFloatArray("phiEndVertex") : null; - float[] zEndVertex = (p.get("zEndVertex") != null) ? p.getFloatArray("zEndVertex") : null; - - int numCharged = 0; - for(int i = 0; i < code.length; ++i) - { - int charge = code[i]; - - try - { - if(Math.abs(code[i]) >= 10 || Math.abs(code[i]) == 1) - // code is being used to store particle code - charge = APDGTable.getCharge(code[i]); - if(charge == 1 || charge == -1) - numCharged++; - } - catch(APDGTable.ParticleNotFoundError pnf){ - logger.debug(pnf.getMessage()); - } - } - - //Assign the vertices to the particle tracks - int[] simulatedVertex = ASVxData.assignVertexNumbers(phiVertex, rhoVertex, zVertex); - - //Now build subsets of the charged tracks only - int[] idC = new int[numCharged]; - int[] typeC = new int[numCharged]; - float[] rhoVertexC = new float[numCharged]; - float[] rhoEndVertexC = new float[numCharged]; - float[] phiVertexC = new float[numCharged]; - float[] zVertexC = new float[numCharged]; - float[] ptC = new float[numCharged]; - float[] phiC = new float[numCharged]; - float[] etaC = new float[numCharged]; - int[] chargeC = new int[numCharged]; - int[] codeC = new int[numCharged]; - int[] simulatedVertexC = new int[numCharged]; - - numCharged = 0; - for(int i = 0; i < code.length; ++i) - { - int charge = code[i]; - try - { - if(Math.abs(code[i]) >= 10 || Math.abs(code[i]) == 1) - // code is being used to store particle code - charge = APDGTable.getCharge(code[i]); - if(charge == 1 || charge == -1) - { - if(id[i] > 0) - { - idC[numCharged] = id[i]; - typeC[numCharged] = NORMAL; - } - else - { - // negative id is used to flag tracks belong to a second - // track bank which correspond to the underlyingEvent - // set id to zero as it is not a kine number - idC[numCharged] = 0; - typeC[numCharged] = UNDERLYING_EVENT; - } - //copy all the information - rhoVertexC[numCharged] = (float)(Math.sqrt(rhoVertex[i]*rhoVertex[i]-zVertex[i]*zVertex[i])); - //if there is no end vertex, fill with 0.0 as in XML file - rhoEndVertexC[numCharged] = (rhoEndVertex != null) ? (float)(Math.sqrt(rhoEndVertex[i]*rhoEndVertex[i]-zEndVertex[i]*zEndVertex[i])) : 0 ; - phiVertexC[numCharged] = phiVertex[i]; - zVertexC[numCharged] = zVertex[i]; - ptC[numCharged] = pt[i]; - //if (pt[i]>5) System.out.println(zVertex[i]); - phiC[numCharged] = phi[i]; - etaC[numCharged] = eta[i]; - codeC[numCharged] = code[i]; - chargeC[numCharged] = charge; - simulatedVertexC[numCharged] = simulatedVertex[i]; - numCharged++; - } - } - catch(APDGTable.ParticleNotFoundError pnf) - { - logger.debug(pnf.getMessage()); - } - } - - //Build a new hash map with the information for the - //charged tracks only - AHashMap newP = new AHashMap(12); - newP.put("numData", new Integer(numCharged)); - newP.put("id", idC); - newP.put("type", typeC); - newP.put("rhoVertex", rhoVertexC); - newP.put("rhoEndVertex", rhoEndVertexC); - newP.put("phiVertex", phiVertexC); - newP.put("zVertex", zVertexC); - newP.put("pt", ptC); - newP.put("phi", phiC); - newP.put("eta", etaC); - newP.put("code", codeC); - newP.put("charge", chargeC); - newP.put("originVertex", simulatedVertexC); - //return the new hasp map - return newP; - } - - - /** - * Get the vertex for which sum|Pt| is maximum - * @return the index of that vertex - */ - public int getMaxSumPtVertex() - { - /*** - * Triple loop can be avoided, e.g using hashmap, - * to tired to fix all this - S.B. - */ - - //get the highest vertex number - int maxVertex = 0; - - //by looping over all tracks and looking at the vertex number - for(int i = 0; i < numData; i++) - if(type[i] == NORMAL) - if(originVertex[i] > maxVertex) - maxVertex = originVertex[i]; - - //Now make an array to hold the sumPT for all vertices - double[] sumPt = new double[maxVertex + 1]; - - //Now loop again to add up all the pT - for(int i = 0; i < numData; i++) - if(type[i] == NORMAL && Math.abs(h[i].d0()) < 2.0) - sumPt[originVertex[i]] += Math.abs(h[i].pT()); - - //Yippee - lets loop once more to find the highest pT one - int VtxIndex = 0; - for(int i = 0; i < sumPt.length; i++) - if(sumPt[i] > sumPt[VtxIndex]) - VtxIndex = i; - - return VtxIndex; - } - - - - protected void applyCuts() - { - super.applyCuts(); - - // STr are always drawn as helices, check for tracks with rhoVertex - // beyond the diameter of InDet and don't draw those - super.cutRhoVertexAfterInDetRadius(); - - cut("CutsInDet", "STr", " STr id", id); - cut("CutsInDet", "STrCode", " STr code", code); - cut("CutsInDet", "STrType", " STr Type", particleType); - cut("CutsInDet", "SVx", " Vertex", originVertex); - } - - protected int internalColor() - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - switch (colorFunction) - { - case 0: - colorByConstant(); - break; - case 1: - colorByIndex(index); - break; - case 2: - colorBy(getPt()); - break; - case 3: - colorBy("ParticleColors", particleType); - break; - case 4: - colorBy(originVertex); - break; - } - - return 4; - } - - public String getHitInfo(int index) - { - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (barcode/id: " + id[index] + " index: " + index + ")"); - msg.append("\n Type = "+APDGTable.getName(code[index])); - msg.append(" (type code "); msg.append(code[index]); - msg.append(")"); msg.append(h[index].toString()); - - return msg.toString(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ASVxData.java b/graphics/AtlantisJava/src/atlantis/data/ASVxData.java deleted file mode 100644 index 87481919d2ad5c98d3f012fc36fd8667061ad691..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ASVxData.java +++ /dev/null @@ -1,167 +0,0 @@ -package atlantis.data; - - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.utils.*; -import java.util.*; - - -/** - * Simulated vertices - */ -public class ASVxData extends A3DPointData { - - // protected final String PARAMETER_GROUP = getParameterGroup(); - - - public String getParameterGroup() - { - return "SVx"; - } - - - public String getName() - { - return "SVx"; - } - - - public String getNameScreenName() - { - return "SimVertex"; - - } - - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+"\n"+ - AMath.RHO+" = "+String.format("%.3f",rho[index])+"\n "+ - "z = "+String.format("%.3f",z[index])+" cm\n"+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - - return getNameScreenName() + " (id: " + id[index] + " index: " + index + ")" + - "\n x = " + String.format("%.5f",x[index]) + " cm" + - "\n y = " + String.format("%.5f",y[index]) + " cm" + - "\n z = " + String.format("%.5f",z[index]) + " cm" + - "\n " + AMath.RHO + " = " + String.format("%.5f",rho[index]) + " cm" + - "\n " + AMath.PHI + " = " + - String.format("%.5f",Math.toDegrees(phi[index])) + AMath.DEGREES + - " (" + String.format("%.5f",phi[index]) + " rad)"; - - } // getHitInfo() -------------------------------------------------------- - - - - ASVxData(AHashMap p, AEvent e) { - super(p,e); - } - - // SVx do not come correctly in input xml file - // must create them from STr data in xml file - public static AHashMap createSVx(AHashMap p) { - float[] rhoVertex=p.getFloatArray("rhoVertex"); - float[] phiVertex=p.getFloatArray("phiVertex"); - float[] zVertex=p.getFloatArray("zVertex"); - int[] sv=ASVxData.assignVertexNumbers(phiVertex, rhoVertex, zVertex); - int numVertex=0; - - for(int i=0; i<sv.length; i++) - if(sv[i]>=numVertex) numVertex=sv[i]+1; - - float[] rho=new float[numVertex]; - float[] phi=new float[numVertex]; - float[] z=new float[numVertex]; - - for(int i=0; i<sv.length; i++) { - rho[sv[i]]=(float)(Math.sqrt(rhoVertex[i]*rhoVertex[i]-zVertex[i]*zVertex[i])); - phi[sv[i]]=phiVertex[i]; - z[sv[i]]=zVertex[i]; - } - - AHashMap newP=new AHashMap(4); - - newP.put("numData", new Integer(numVertex)); - newP.put("rho", rho); - newP.put("phi", phi); - newP.put("z", z); - return newP; - } - - public static int[] assignVertexNumbers(float[] phi, float[] rho, float[] z) { - int[] sv=new int[phi.length]; - Vertex[] key=new Vertex[phi.length]; - - HashMap vertices=new HashMap(); - -// this is ugly, related to the fact that id[i]=i+1 by default; - int num=1; - for(int i=0; i<sv.length; i++) { - key[i]=new Vertex(rho[i], phi[i], z[i]); - Object value=vertices.get(key[i]); - if(value==null) { - sv[i]=num; - vertices.put(key[i], new Integer(num++)); - } else { - sv[i]=((Integer)value).intValue(); - } - } - return sv; - } - - protected int internalColor() { - colorByConstant(); - return 1; - } - - protected void applyCuts() { - cutIndex(); - cutPhi(phi); - cutEta(rho, z); - cut("CutsInDet", "SVx", " Vertex", id); - } - - - public double[] getVertex(int index) { - - double[] vertex=new double[3]; - - if(index>-1&&index<numData) { - vertex[0]=x[index]; - vertex[1]=y[index]; - vertex[2]=z[index]; - } - return vertex; - } - -} - - -class Vertex { - float x; - float y; - float z; - int hashcode; - - Vertex(float x, float y, float z) { - this.x=x; - this.y=y; - this.z=z; - hashcode=Float.floatToIntBits(z); - } - - @Override - public int hashCode() { - return hashcode; - } - - @Override - public boolean equals(Object a) { - if(!(a instanceof Vertex)) return false; - Vertex b=(Vertex)a; - return x==b.x&&y==b.y&&z==b.z; - } -} - diff --git a/graphics/AtlantisJava/src/atlantis/data/ASegmentData.java b/graphics/AtlantisJava/src/atlantis/data/ASegmentData.java deleted file mode 100755 index d999effdb0b26e65b6743d6086a05ec077f14d16..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ASegmentData.java +++ /dev/null @@ -1,164 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjectionXZ; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - -/** - * Generic track segment class. - * - * @author Eric Jansen - */ -public abstract class ASegmentData extends AData { - - protected float[] x; - protected float[] y; - protected float[] z; - protected float[] theta; - protected float[] phi; - protected int[] hits; - protected int[] numHits; - - ASegmentData(AHashMap p, AEvent e) { - super(p,e); - - x = p.getFloatArray("x"); - y = p.getFloatArray("y"); - z = p.getFloatArray("z"); - phi = p.getFloatArray("phi"); - theta = p.getFloatArray("theta"); - numHits = p.getIntArray("numHits"); - - hits = p.getIntArray("hits"); - } - - protected int internalColor() { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - switch(colorFunction) { - case 0: - colorByConstant(); - break; - case 1: - colorByIndex(); - break; - } - - return 1; - } - - - protected void applyCuts() - { - cutIndex(); - - } - - - public String getHitInfo(int index) { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+"\n"+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - - - return getName() + " (index: " + index + ")\n" - + " storegate key = " + storeGateKey + "\n" - + " " + AMath.PHI + " = " + String.format("%.3f",Math.toDegrees(phi[index])) - + " (" + String.format("%.3f",phi[index]) + " rad)" + "\n" - + " tL = " + String.format("%.3f",Math.toDegrees(1./Math.tan(theta[index]))) + "\n" - + " x = " + String.format("%.3f",x[index]) + " cm\n" - + " y = " + String.format("%.3f",y[index]) + " cm\n" - + " z = " + String.format("%.3f",z[index]) + " cm\n" - + " hits = " + numHits[index] + "\n"; - } - - protected ACoord getYXUser() { - makeDrawList(); - - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - double length = parameterStore.get(PARAMETER_GROUP, "SegmentLength").getD(); - - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - - double dx = length * Math.sin(theta[j]) * Math.cos(phi[j]); - double dy = length * Math.sin(theta[j]) * Math.sin(phi[j]); - - hv[0][i] = new double [] {x[j]-dx, x[j]-dx/2., x[j], x[j]+dx/2., x[j]+dx}; - hv[1][i] = new double [] {y[j]-dy, y[j]-dy/2., y[j], y[j]+dy/2., y[j]+dy}; - - index[i] = j; - } - - return new ACoord(hv, index, this, ACoord.SMOOTH_POLYLINES); - } - - protected ACoord getFRUser() { - return getYXUser().convertYXToFR().includePhiWrapAround("FR"); - } - - protected ACoord getRZUser() { - makeDrawList(); - - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - double length = parameterStore.get(PARAMETER_GROUP, "SegmentLength").getD(); - - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - - double dx = length * Math.sin(theta[j]) * Math.cos(phi[j]); - double dy = length * Math.sin(theta[j]) * Math.sin(phi[j]); - double dz = length * Math.cos(theta[j]); - - int sign = AParameterUtilities.getRhoSign(x[j], y[j]); - - hv[0][i] = new double [] {z[j]-dz, z[j]+dz}; - hv[1][i] = new double [] { - sign * Math.hypot(x[i]-dx, y[i]-dy), - sign * Math.hypot(x[i]+dx, y[i]+dy) - }; - - index[i] = j; - } - - return new ACoord(hv, index, this, ACoord.POLYLINES); - } - - protected ACoord getXZUser() { - makeDrawList(); - - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - double length = parameterStore.get(PARAMETER_GROUP, "SegmentLength").getD(); - double phi0 = Math.toRadians(AProjectionXZ.getPhi()); - - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - - double dx = length * Math.sin(theta[j]) * Math.cos(phi[j]); - double dy = length * Math.sin(theta[j]) * Math.sin(phi[j]); - double dz = length * Math.cos(theta[j]); - - double s = x[j] * Math.cos(phi0) + y[j] * Math.sin(phi0); - double ds = dx * Math.cos(phi0) + dy * Math.sin(phi0); - - if (z[j] < 0) { - hv[0][i] = new double [] {z[j]+dz, z[j]-dz}; - hv[1][i] = new double [] {s-ds, s+ds}; - } else { - hv[0][i] = new double [] {z[j]-dz, z[j]+dz}; - hv[1][i] = new double [] {s-ds, s+ds}; - } - - index[i] = j; - } - - return new ACoord(hv, index, this, ACoord.POLYLINES); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ASiClusterData.java b/graphics/AtlantisJava/src/atlantis/data/ASiClusterData.java deleted file mode 100644 index 83cc0f98026120928d389a12a654025319c5ee52..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ASiClusterData.java +++ /dev/null @@ -1,385 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjectionVP; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - -/** - * SiCluster - Silicon clusters, reads in STC datatype from event file - */ -public class ASiClusterData extends AHitData -{ - // read in from event file - private float[][] x; - private float[][] y; - private float[][] z; - private float[] width; - private int[] etaModule; - private int[] phiModule; - private int[] side; - - // calculated - private float[][] rho; - private float[][] phi; - private int[] layer; - - public static final int U_CLUSTER = -1; - public static final int PHI_CLUSTER = 0; - public static final int V_CLUSTER = 1; - public static final int ENDCAP_MINUS = 0; - public static final int BARREL = 1; - public static final int ENDCAP_PLUS = 2; - - - public String getParameterGroup() - { - return "SiCluster"; - } - - public String getName() - { - return "SiCluster"; - } - - public String getNameScreenName() - { - return "SCT_Cluster"; - } - - public float[][] getX() - { - return x; - } - - public float[][] getY() - { - return y; - } - - public float[][] getZ() - { - return z; - } - - - - ASiClusterData(AHashMap p, AEvent e) - { - super(p,e); - x = new float[][] { p.getFloatArray("x0"), p.getFloatArray("x1") }; - y = new float[][] { p.getFloatArray("y0"), p.getFloatArray("y1") }; - z = new float[][] { p.getFloatArray("z0"), p.getFloatArray("z1") }; - width = p.getFloatArray("width"); - - rho = new float[2][numData]; - phi = new float[2][numData]; - - layer = new int[numData]; - for (int i = 0; i < numData; ++i) - { - sub[i] = getSub(id[i]); - layer[i] = getLayer(id[i]); - } - - etaModule = (p.get("etaModule") != null) ? p.getIntArray("etaModule") : null; - phiModule = (p.get("phiModule") != null) ? p.getIntArray("phiModule") : null; - side = (p.get("side") != null) ? p.getIntArray("side") : null; - - } // ASiClusterData() --------------------------------------------------- - - - - protected void calculateRhoPhi() - { - - calculateRhoPhi(x[0], y[0], rho[0], phi[0]); - calculateRhoPhi(x[1], y[1], rho[1], phi[1]); - // treat wraparound - for (int i = 0; i < numData; ++i) - { - if (Math.abs(phi[1][i] - phi[0][i]) > Math.PI) - { - if (phi[1][i] - phi[0][i] > 0) - { - phi[0][i] += AMath.TWO_PI; - } - else - { - phi[1][i] += AMath.TWO_PI; - } - } - } // for - } // calculateRhoPhi() -------------------------------------------------- - - private void cutSubdetector() - { - AParameter par = parameterStore.get("CutsInDet", "SCT"); - if (par.getI() != -1) - { - cutArray(sub, par.getI(), "Barrel/Endcap"); - } - } // cutSubdetector() --------------------------------------------------- - - - protected void applyCuts() - { - cutIndex(); - cutOrientation(); - cutSubdetector(); - cut("CutsInDet", "Layer", "Layer", layer); - cutSimulatedTracks(); - cutReconstructedTracks(); - cutPhi(phi[0]); - cutEta(); - } // applyCuts() -------------------------------------------------------- - - private void cutEta() - { - AParameter par = parameterStore.get("CutsATLAS", "CutEta"); - if (!par.getStatus()) - return; - double etaCut = par.getD(); - double etaMid = parameterStore.get("CutsATLAS", "EtaMiddle").getD(); - double etaLowerCut = etaMid - etaCut; - double etaUpperCut = etaMid + etaCut; - int num = 0; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double eta1 = AParameterUtilities.eta(z[0][list], rho[0][list]); - double eta2 = AParameterUtilities.eta(z[1][list], rho[1][list]); - double etaLower = Math.min(eta1, eta2); - double etaUpper = Math.max(eta1, eta2); - if (etaUpper > etaLowerCut && etaLower < etaUpperCut) - listdl[num++] = list; - } - numDraw = num; - } // cutEta() ----------------------------------------------------------- - - public int getLayer(int id) - { - int layer = (id & 0x01e00000) >> 21; - int sub = getSub(id); - if (sub == BARREL) - { - layer += 3; - } - else - { - layer += 11; - } - return layer; - } // getLayer() --------------------------------------------------------- - - public int getSub(int id) - { - return (id & 0x06000000) >> 25; - } // getSub() ----------------------------------------------------------- - - public int getOrientation(int id) - { - int side = (id & 0x400) >> 10; - int sub = getSub(id); - if ((side == 1 && sub == BARREL) || (side == 0 && sub != BARREL)) - { - return PHI_CLUSTER; - } - - int layer = getLayer(id); - if (layer % 2 == 1) - { - return U_CLUSTER; - } - - return V_CLUSTER; - } // getOrientation() --------------------------------------------------- - - protected void cutOrientation() - { - int num = 0; - AParameter stereoAnglePar = parameterStore.get("SiCluster", "Stereo"); - if (!stereoAnglePar.getStatus()) - { - return; - } - int orientation = stereoAnglePar.getI(); - for (int i = 0; i < numDraw; i++) - { - // only works for barrel for now !!!! - // if( getSub(id[listdl[i]])==BARREL && - // orientation==getOrientation(id[listdl[i]])) - if (orientation == getOrientation(id[listdl[i]])) - { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } // cutOrientation() --------------------------------------------------- - - protected int internalColor() - { - int numColorTypes = super.internalColor(); - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - if (colorFunction == numColorTypes + 1) - { - colorBy(layer); - } - else if (colorFunction == numColorTypes + 2) - { - colorByOrientation(); - } - - return numColorTypes + 2; - } // internalColor() ---------------------------------------------------- - - protected void colorByOrientation() - { - int numColors = parameterStore.get("HitColors", "Number").getI(); - numColors = Math.min(7, numColors); - int[] col = parameterStore.getArray("HitColors", "C1", numColors); - for (int i = 0; i < numData; i++) - { - color[i] = (byte) col[getOrientation(id[i]) + 1 % numColors]; - } - } // colorByOrientation() ----------------------------------------------- - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index; - - String temp = getNameScreenName() + " (id: " + id[index] + " index: " + index +")\n" + - " orientation = " + getOrientation(id[index]); - temp += "\n x = " + x[0][index] + " " + x[1][index]; - temp += "\n y = " + y[0][index] + " " + y[1][index]; - temp += "\n z = " + z[0][index] + " " + z[1][index]; - temp += "\n " + AMath.RHO + " = " + rho[0][index] + " " + rho[1][index]; - temp += "\n " + AMath.ETA + " module = "; - temp += (etaModule != null) ? Integer.toString(etaModule[index]) : "n/a"; - temp += "\n " + AMath.PHI + " module = "; - temp += (phiModule != null) ? Integer.toString(phiModule[index]) : "n/a"; - temp += "\n side = "; - temp += (side != null) ? Integer.toString(side[index]) : "n/a"; - temp += "\n width = "; - temp += (width != null) ? Float.toString(width[index]) : "n/a"; - - temp += super.getHitInfo(index); // finds barcode information - - return temp; - } // getHitInfo() ------------------------------------------------------- - - protected ACoord getYXUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for (int j = 0; j < 2; j++) - { - hv[0][j][i] = x[j][list]; - hv[1][j][i] = y[j][list]; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } // getYXUser() -------------------------------------------------------- - - protected ACoord getRZUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double phiDiff = Math.abs(phi[1][list] - phiMid); - double sign; - if (phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - { - sign = +1.; - } - else - { - sign = -1.; - } - - for (int j = 0; j < 2; j++) - { - hv[0][j][i] = z[j][list]; - hv[1][j][i] = sign * rho[j][list]; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } // getRZUser() -------------------------------------------------------- - - protected ACoord getFRUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for (int j = 0; j < 2; j++) - { - hv[0][j][i] = rho[j][list]; - hv[1][j][i] = Math.toDegrees(AParameterUtilities.getPhiStereo(rho[j][list], phi[j][list], z[j][list])); - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES).includePhiWrapAround("FR"); - } // getFRUser() -------------------------------------------------------- - - protected ACoord getFZUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for (int j = 0; j < 2; j++) - { - hv[0][j][i] = z[j][list]; - hv[1][j][i] = Math.toDegrees(AParameterUtilities.getPhiStereo(rho[j][list], phi[j][list], z[j][list])); - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES).includePhiWrapAround("FZ"); - } // getFZUser() -------------------------------------------------------- - - protected ACoord getVPUser() - { - makeDrawList(); - int numTotal = 2 * numDraw; - double[][][] hv = new double[2][numTotal][2]; - int[] index = new int[numTotal]; - double[] sign = new double[] { -1., 1. }; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for (int k = 0; k < 2; k++) - { - double deltaEta = AProjectionVP.getDeltaEta(rho[k][list], z[k][list]); - double eta = AParameterUtilities.eta(z[k][list], rho[k][list]); - for (int j = 0; j < 2; j++) - { - hv[0][2 * i + j][k] = eta + sign[j] * deltaEta; - hv[1][2 * i + j][k] = Math.toDegrees(phi[k][list]); - index[2 * i + j] = list; - } - } - } - return new ACoord(hv, index, this, ACoord.POLYLINES).includePhiWrapAround("VP"); - } // getVPUser() -------------------------------------------------------- - -} // class ASiClusterData =================================================== diff --git a/graphics/AtlantisJava/src/atlantis/data/ASiClusterRDOData.java b/graphics/AtlantisJava/src/atlantis/data/ASiClusterRDOData.java deleted file mode 100644 index ac1806b4cb14bb43cd6cebbaef579ffe3bf2ce7f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ASiClusterRDOData.java +++ /dev/null @@ -1,481 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjectionVP; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - - -/** - * Silicon clusters RDO Raw Data Objects (class derived from ASiClusterData) - * Parameters expected in the event file for SCTRDO datatype: - * x0|x1|y0|y1|z0|z1|phiModule|etaModule|id|BCIDError|firstHitError| - * formatterError|lvl1Error|preambleError|secondHitError|syncError|timeBin - * - */ -public class ASiClusterRDOData extends AHitData -{ - private float[][] x = null; - private float[][] y = null; - private float[][] z = null; - private int[] etaModule = null; - private int[] phiModule = null; - private int[] BCIDError = null; - private int[] firstHitError = null; - private int[] formatterError = null; - private int[] lvl1Error = null; - private int[] preambleError = null; - private int[] secondHitError = null; - private int[] syncError = null; - private int[] timeBin = null; - // calculated here - private int[] layer; - private float[][] rho; - private float[][] phi; - - public static final int U_CLUSTER = -1; - public static final int PHI_CLUSTER = 0; - public static final int V_CLUSTER = 1; - public static final int ENDCAP_MINUS = 0; - public static final int BARREL = 1; - public static final int ENDCAP_PLUS = 2; - - - - public String getParameterGroup() - { - return "SiClusterRDO"; - - } // getParameterGroup() ------------------------------------------------ - - - - public String getName() - { - return "SiClusterRDO"; - - } // getName() ---------------------------------------------------------- - - - - public String getNameScreenName() - { - return "SiClusterRDO"; - - } // getNameScreenName() ------------------------------------------------ - - - - ASiClusterRDOData(AHashMap p, AEvent e) - { - super(p,e); - x = new float[][] - { p.getFloatArray("x0"), p.getFloatArray("x1") }; - y = new float[][] - { p.getFloatArray("y0"), p.getFloatArray("y1") }; - z = new float[][] - { p.getFloatArray("z0"), p.getFloatArray("z1") }; - etaModule = p.getIntArray("etaModule"); - phiModule = p.getIntArray("phiModule"); - BCIDError = p.getIntArray("BCIDError"); - firstHitError = p.getIntArray("firstHitError"); - formatterError = p.getIntArray("formatterError"); - lvl1Error = p.getIntArray("lvl1Error"); - preambleError = p.getIntArray("preambleError"); - secondHitError = p.getIntArray("secondHitError"); - syncError = p.getIntArray("syncError"); - timeBin = p.getIntArray("timeBin"); - rho = new float[2][numData]; - phi = new float[2][numData]; - layer = new int[numData]; - - for(int i = 0; i < numData; ++i) - { - sub[i] = getSub(id[i]); - layer[i] = getLayer(id[i]); - } - - } // ASiClusterRDOData() ------------------------------------------------ - - - protected void calculateRhoPhi() - { - calculateRhoPhi(x[0], y[0], rho[0], phi[0]); - calculateRhoPhi(x[1], y[1], rho[1], phi[1]); - // treat wraparound - for(int i = 0; i < numData; ++i) - { - if(Math.abs(phi[1][i] - phi[0][i]) > Math.PI) - { - if(phi[1][i] - phi[0][i] > 0) - { - phi[0][i] += AMath.TWO_PI; - } - else - { - phi[1][i] += AMath.TWO_PI; - } - } - } - - } // calculateRhoPhi() -------------------------------------------------- - - - - private void cutSubdetector() - { - AParameter par = parameterStore.get("CutsInDet", "SCT"); - if(par.getI() != -1) - { - cutArray(sub, par.getI(), "Barrel/Endcap"); - } - - } // cutSubdetector() --------------------------------------------------- - - - protected void applyCuts() - { - cutIndex(); - cutOrientation(); - cutSubdetector(); - cut("CutsInDet", "Layer", "Layer", layer); - cutPhi(phi[0]); - cutEta(); - - } // applyCuts() -------------------------------------------------------- - - - - private void cutEta() - { - AParameter par = parameterStore.get("CutsATLAS", "CutEta"); - if(!par.getStatus())return; - double etaCut = par.getD(); - double etaMid = parameterStore.get("CutsATLAS", "EtaMiddle").getD(); - double etaLowerCut = etaMid - etaCut; - double etaUpperCut = etaMid + etaCut; - int num = 0; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double eta1 = AParameterUtilities.eta(z[0][list], rho[0][list]); - double eta2 = AParameterUtilities.eta(z[1][list], rho[1][list]); - double etaLower = Math.min(eta1, eta2); - double etaUpper = Math.max(eta1, eta2); - if(etaUpper > etaLowerCut && etaLower < etaUpperCut) - listdl[num++] = list; - } - numDraw = num; - - } // cutEta() ----------------------------------------------------------- - - - - public int getLayer(int id) - { - int layer = (id & 0x01e00000) >> 21; - int sub = getSub(id); - if(sub == BARREL) - layer += 3; - else - layer += 11; - return layer; - - } // getLayer() --------------------------------------------------------- - - - - public int getSub(int id) - { - return(id & 0x06000000) >> 25; - - } // getSub() ----------------------------------------------------------- - - - - public int getOrientation(int id) - { - int side = (id & 0x400) >> 10; - int sub = getSub(id); - if((side == 1 && sub == BARREL) || (side == 0 && sub != BARREL)) - { - return PHI_CLUSTER; - } - int layer = getLayer(id); - if(layer % 2 == 1)return U_CLUSTER; - return V_CLUSTER; - - } // getOrientation() --------------------------------------------------- - - - - protected void cutOrientation() - { - int num = 0; - AParameter stereoAnglePar = parameterStore.get("SiCluster", "Stereo"); - if(!stereoAnglePar.getStatus()) - { - return; - } - int orientation = stereoAnglePar.getI(); - for(int i = 0; i < numDraw; i++) - // only works for barrel for now !!!! - // if( getSub(id[listdl[i]])==BARREL && orientation==getOrientation(id[listdl[i]])) - if(orientation == getOrientation(id[listdl[i]])) - { - listdl[num++] = listdl[i]; - } - numDraw = num; - - } // cutOrientation() --------------------------------------------------- - - - - /** - * parameter InDet -> SiClusterRDO -> Color Function: - * pv="Constant = 0, Error = 1, Orientation = 2" - */ - protected int internalColor() - { - // it's usual to call this method from mother class, but in this case - // it uses it's own colour types co we don't care about AHitData - // int numColorTypes = super.internalColor(); - - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - if(colorFunction == 0) - { - colorByConstant(); - } - else if(colorFunction == 1) - { - colorByError(); - } - else if(colorFunction == 2) - { - colorByOrientation(); - } - - // 3 colour schemes exist here - return 3; - - } // internalColor() ---------------------------------------------------- - - - - /** - * colour elements by error (error subtags from the event file): - * BCIDError, firstHitError, formatterError, lvl1Error, preambleError, - * secondHitError, syncError ] - * if any of these flags is set to true, the element is considered erroneous - * (next iteration may be to colour by error type, if they want it ...) - */ - protected void colorByError() - { - int constantColor = parameterStore.get(PARAMETER_GROUP, "Constant").getI(); - int errorColor = parameterStore.get(PARAMETER_GROUP, "Error").getI(); - - for(int i = 0; i < numData; i++) - { - if(BCIDError[i] != 0 || firstHitError[i] != 0 || - formatterError[i] != 0 || lvl1Error[i] != 0 || - preambleError[i] != 0 || secondHitError[i] != 0 || - syncError[i] != 0) - { - // element is erroneous - color[i] = (byte) errorColor; - } - else - { - color[i] = (byte) constantColor; - } - } - - } // colorByError() ----------------------------------------------------- - - - - protected void colorByOrientation() - { - int numColors = parameterStore.get("HitColors", "Number").getI(); - numColors = Math.min(7, numColors); - int[] col = parameterStore.getArray("HitColors", "C1", numColors); - for(int i = 0; i < numData; i++) - { - color[i] = (byte) col[getOrientation(id[i]) + 1 % numColors]; - } - - } // colorByOrientation() ----------------------------------------------- - - - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index; - - String temp = getNameScreenName() + " (id: " + id[index] + " index: " + index + ")\n" + - " orientation = " + getOrientation(id[index]) + "\n" + - " x = " + x[0][index] + " " + x[1][index] + "\n" + - " y = " + y[0][index] + " " + y[1][index] + "\n" + - " z = " + z[0][index] + " " + z[1][index] + "\n" + - " " + AMath.RHO + " = " + rho[0][index] + " " + - rho[1][index] + "\n" + - " " + AMath.ETA + " module = " + etaModule[index] + "\n" + - " " + AMath.PHI + " module = " + phiModule[index] + "\n" + - " BCID error = " + BCIDError[index] + "\n" + - " first hit error = " + firstHitError[index] + "\n" + - " formatter error = " + formatterError[index] + "\n" + - " lvl1 error = " + lvl1Error[index] + "\n" + - " preamble error = " + preambleError[index] + "\n" + - " second hit error = " + secondHitError[index] + "\n" + - " sync error = " + syncError[index] + "\n" + - " time bin = " + timeBin[index]; - return temp; - - } // getHitInfo() ------------------------------------------------------- - - - - protected ACoord getYXUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for(int j = 0; j < 2; j++) - { - hv[0][j][i] = x[j][list]; - hv[1][j][i] = y[j][list]; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - - } // getYXUser() -------------------------------------------------------- - - - - protected ACoord getRZUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double phiDiff = Math.abs(phi[1][list] - phiMid); - double sign; - if(phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - { - sign = +1.; - } - else - { - sign = -1.; - } - for(int j = 0; j < 2; j++) - { - hv[0][j][i] = z[j][list]; - hv[1][j][i] = sign * rho[j][list]; - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - - } // getRZUser() -------------------------------------------------------- - - - - protected ACoord getFRUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for(int j = 0; j < 2; j++) - { - hv[0][j][i] = rho[j][list]; - hv[1][j][i] = Math.toDegrees(AParameterUtilities.getPhiStereo(rho[j][list], phi[j][list], - z[j][list])); - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES).includePhiWrapAround("FR"); - - } // getFRUser() -------------------------------------------------------- - - - - protected ACoord getFZUser() - { - makeDrawList(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - for(int j = 0; j < 2; j++) - { - hv[0][j][i] = z[j][list]; - hv[1][j][i] = Math.toDegrees(AParameterUtilities.getPhiStereo(rho[j][list], phi[j][list], - z[j][list])); - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES).includePhiWrapAround("FZ"); - - } // getFZUser() -------------------------------------------------------- - - - - protected ACoord getVPUser() - { - makeDrawList(); - int numTotal = 2 * numDraw; - int numPoints = 10; - double[][][] hv = new double[2][numTotal][numPoints]; - int[] index = new int[numTotal]; - double[] sign = new double[] - { -1., 1.}; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double xx = x[0][list]; - double delx = (x[1][list] - x[0][list]) / (numPoints - 1); - double yy = y[0][list]; - double dely = (y[1][list] - y[0][list]) / (numPoints - 1); - double zz = z[0][list]; - double delz = (z[1][list] - z[0][list]) / (numPoints - 1); - for(int k = 0; k < numPoints; k++) - { - double xxx = xx + k * delx; - double yyy = yy + k * dely; - double zzz = zz + k * delz; - double rrr = Math.sqrt(xxx * xxx + yyy * yyy); - double ppp = Math.atan2(yyy, xxx); - double deltaEta = AProjectionVP.getDeltaEta(rrr, zzz); - double eta = AParameterUtilities.eta(zzz, rrr); - for(int j = 0; j < 2; j++) - { - hv[0][2 * i + j][k] = eta + sign[j] * deltaEta; - hv[1][2 * i + j][k] = Math.toDegrees(ppp); - index[2 * i + j] = list; - } - } - } - return new ACoord(hv, index, this, ACoord.POLYLINES). includePhiWrapAround("VP"); - - } // getVPUser() -------------------------------------------------------- - - -} // class ASiClusterRDOData ================================================ diff --git a/graphics/AtlantisJava/src/atlantis/data/ATGCData.java b/graphics/AtlantisJava/src/atlantis/data/ATGCData.java deleted file mode 100755 index e0005dce948e227e049bb0d254a529a05e5c7a8e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ATGCData.java +++ /dev/null @@ -1,340 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.graphics.ACoord; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.AParameterUtilities; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.AIdHelper; -import atlantis.utils.ALogger; -import atlantis.utils.AMath; - -public class ATGCData extends AMuonHitData -{ - float[] swidth; - float[] lwidth; - float[] length; - int[] gasGap; - - private static ALogger logger = ALogger.getLogger(ATGCData.class); - - public String getParameterGroup() - { - return "TGC"; - } - - public String getName() - { - return "TGC"; - } - - public String getNameScreenName() - { - return "TGC"; - } - - ATGCData(AHashMap p, AEvent e) - { - super(p,e); - swidth = p.getFloatArray("swidth"); - length = p.getFloatArray("length"); - lwidth = p.getFloatArray("lwidth"); - gasGap = new int[numData]; - for (int i = 0; i < numData; i++) - gasGap[i] = getGasGap(i); - } - - protected int getStation(int index) - { - try { - String stationName = AIdHelper.stationName(id[index]); - return (stationName.charAt(1) - '0') % 4; - } catch (AAtlantisException e) { - logger.error("Problem decoding TGC identifier", e); - } - - return 0; - } - - protected int getSub(int index) - { - try { - if (AIdHelper.stationEta(id[index]) < 0) { - return 0; - } else { - return 1; - } - - } catch (AAtlantisException e) { - logger.error("Problem decoding TGC identifier", e); - } - - return 0; - } - - public int getSector(int index) - { - try { - String stationName = AIdHelper.stationName(id[index]); - int stationPhi = AIdHelper.stationPhi(id[index]); - - int retval; - if (stationName.equals("T4E")) { - int temp = stationPhi % 24; - retval = 2 * (temp / 3); - } else if (stationName.charAt(2) == 'F') { - int temp = stationPhi % 24; - retval = 2 * (temp / 3); - if (temp % 3 > 1) retval += 1; - } else { - int temp = (stationPhi + 1) % 48; - retval = 2 * (temp / 6); - if (temp % 6 > 3) retval += 1; - } - return retval; - - } catch (AAtlantisException e) { - logger.error("Problem decoding TGC identifier", e); - } - - return 0; - - } - - protected int getGasGap(int index) - { - try { - return AIdHelper.tgcGasGap(id[index]); - } catch (AAtlantisException e) { - logger.error("Problem decoding TGC identifier", e); - } - - return 0; - } - - protected boolean getMeasuresPhi(int index) - { - try { - if (AIdHelper.tgcIsStrip(id[index]) == 1) { - return true; - } - } catch (AAtlantisException e) { - logger.error("Problem decoding TGC identifier", e); - } - - return false; - } - - public void applyCuts() - { - super.applyCuts(); - if (parameterStore.get("CutsATLAS", "CutPhi").getStatus()) - cutPhi(phi, getDPhi()); - if (parameterStore.get("CutsATLAS", "CutEta").getStatus()) - cutEtaDRho(rho, z, getDRho()); - } - - // used for cuts - - private float[] getDPhi() - { - // only roughly correct - // must create all - float[] dphi = new float[numData]; - - // need only fill for those in draw list - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - dphi[list] = (float) Math.abs(Math.atan2((swidth[list] + lwidth[list]) / 4., rho[list])); - } - return dphi; - } - - // used for cuts - - private float[] getDRho() - { - // only roughly correct - // must create all - float[] drho = new float[numData]; - - // need only fill for those in draw list - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - drho[list] = (float) (length[list] / 2.); - } - return drho; - } - - protected ACoord getFZUser() - { - makeDrawList(); - cutArray(measuresPhi, true, " Strip"); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - index[i] = list; - double deltaPhi = ((swidth[list] + lwidth[list]) / 4.) / rho[list]; - - hv[0][0][i] = z[list]; - hv[1][0][i] = Math.toDegrees(phi[list] - deltaPhi); - hv[0][1][i] = z[list]; - hv[1][1][i] = Math.toDegrees(phi[list] + deltaPhi); - } - return new ACoord(hv, index, this, ACoord.LINES).includePhiWrapAround("FZ"); - } - - private void makeDrawListYX() - { - int mode = parameterStore.get("YX", "Mode").getI(); - - if (mode == 0 || mode >= 5) - { - numDraw = 0; - } - else - { - makeDrawList(); - int num = 0; - - for (int i = 0; i < numDraw; ++i) - if (mode == station[listdl[i]] + 1) - listdl[num++] = listdl[i]; - numDraw = num; - } - cut("YX", "TGCGasGap", " TGC Gas Gap", gasGap); - } - - protected ACoord getYXUser() - { - return getYXUser(0); - } - - protected ACoord getYXUser(int flag) - { - makeDrawListYX(); - int[] split = { 6, 1, 6, 1 }; - int numPoints = 4; - boolean splitIt = parameterStore.get("YX", "FishEye").getStatus() || flag == 1; - - if (splitIt) - numPoints = 14; - double[] temp = new double[4]; - double[][][] hv = new double[2][numDraw][numPoints]; - int[] index = new int[numDraw]; - - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - - index[i] = list; - double cosPhi = Math.cos(phi[list]); - double sinPhi = Math.sin(phi[list]); - double rMid = rho[list]; - double dR = length[list] / 2.; - double r = rMid - dR; - double d = swidth[list] / 2.; - double x = r * cosPhi; - double y = r * sinPhi; - double dx = d * sinPhi; - double dy = d * cosPhi; - - hv[0][i][0] = x + dx; - hv[1][i][0] = y - dy; - hv[0][i][1] = x - dx; - hv[1][i][1] = y + dy; - r = rMid + dR; - x = r * cosPhi; - y = r * sinPhi; - d = lwidth[list] / 2.; - dx = d * sinPhi; - dy = d * cosPhi; - hv[0][i][2] = x - dx; - hv[1][i][2] = y + dy; - hv[0][i][3] = x + dx; - hv[1][i][3] = y - dy; - if (splitIt) - for (int j = 0; j < 2; ++j) - { - for (int k = 0; k < 4; ++k) - temp[k] = hv[j][i][k]; - AMath.splitArrayIntoPieces(temp, hv[j][i], split); - } - } - return new ACoord(hv, index, this); - } - - protected ACoord getFRUser() - { - return getYXUser(1).convertYXToFR().includePhiWrapAround("FR"); - } - - protected ACoord getXZRZUser(int sign[]) - { - double[][][] hv = new double[2][numDraw][]; - int index[] = new int[numDraw]; - - try { - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - index[i] = j; - - double rho = Math.sqrt(x[j]*x[j] + y[j]*y[j]); - - if (AIdHelper.tgcIsStrip(id[j]) == 1) { - double drho = length[j]/2.; - hv[0][i] = new double[] { z[j], z[j] }; - hv[1][i] = new double[] { sign[i] * (rho - drho), - sign[i] * (rho + drho) }; - } else { - hv[0][i] = new double[] { z[j] }; - hv[1][i] = new double[] { sign[i] * rho }; - } - } - - return new ACoord(hv, index, this); - } catch (AAtlantisException e) { - AOutput.append("Error decoding TGC identifier: " + e.getMessage(), ALogInterface.BAD_COMMAND); - return ACoord.NO_DATA; - } - } - - protected ACoord getXZUser() { - makeDrawList(); - cutMuonSector(sector); - - int[] sign = new int[numDraw]; - int sect = (int) Math.round(parameterStore.get("XZ", "Phi").getD() / 22.5); - - for(int i=0; i<numDraw; i++) { - if (sector[listdl[i]] == sect) - sign[i] = 1; - else - sign[i] = -1; - } - - return getXZRZUser(sign); - } - - protected ACoord getRZUser() { - makeDrawList(); - - int[] sign = new int[numDraw]; - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - sign[i] = AParameterUtilities.getRhoSign(x[j], y[j]); - } - - return getXZRZUser(sign); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ATILEData.java b/graphics/AtlantisJava/src/atlantis/data/ATILEData.java deleted file mode 100755 index 99bc22c7daacb2b21f8d7f53dfaf8cbddb9ce6c6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ATILEData.java +++ /dev/null @@ -1,843 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringReader; -import java.io.FileNotFoundException; - -import com.Ostermiller.util.CSVParser; - -import atlantis.geometry.ACalorimeterDetector; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.AIdHelper; -import atlantis.utils.AMath; -import atlantis.utils.AUtilities; -import atlantis.utils.ALogger; - - -/** - * The TILE hadronic calorimeter. - * - * @author Eric Jansen - */ -public class ATILEData extends ACalorimeterData -{ - private static ALogger logger = ALogger.getLogger(ATILEData.class); - - // data for real pulse shapes plots - private float[] pmt1Energy = null; - private float[] pmt2Energy = null; - private float[] pmt1Chi2 = null; - private float[] pmt2Chi2 = null; - private float[] pmt1Time = null; - private float[] pmt2Time = null; - private float[] pmt1RawTime = null; - private float[] pmt2RawTime = null; - private float[] pmt1RawAmplitude = null; - private float[] pmt2RawAmplitude = null; - private int[][] adcCounts1 = null; - private int[][] adcCounts2 = null; - private int[] pmt1Gain = null; - private int[] pmt2Gain = null; - private float[] pmt1Pedestal = null; - private float[] pmt2Pedestal = null; - private int[] pmt1Number = null; - private int[] pmt2Number = null; - private int[] pmt1ADCStatus = null; - private int[] pmt2ADCStatus = null; - private static boolean pulseShapesDataAvailable = false; - private static final String LOOKUP_TABLE_FILE = - AGlobals.instance().getHomeDirectory() + "configuration" + - System.getProperty("file.separator") + - "rpsplt_tile.csv"; - // number of lookup table values for real pulse shapes plots calculation - private static final short NUMBER_OF_LOOKUP_VALUES = 401; - - - ATILEData(AHashMap p, AEvent e) - { - super(p,e); - - - for (int i = 0; i < numData; i++) - { - try - { - side[i] = (byte) AIdHelper.tileSide(id[i]); - etaIndex[i] = (short) AIdHelper.tileTower(id[i]); - phiIndex[i] = (short) AIdHelper.tileModule(id[i]); - sampling[i] = AIdHelper.tileSampling(id[i]); - } - catch (AAtlantisException ex) - { - System.out.println("Problem decoding ID " + id[i] + " in " + - CALORIMETER_NAME + ": " + ex.getMessage()); - side[i] = 0; - etaIndex[i] = -1; - phiIndex[i] = -1; - sampling[i] = -1; - } - } - - makeHitToGeometryMapping(); - for (int i = 0; i < et.length; ++i) - { - et[i] = Math.abs(energy[i] / (float) Math.cosh(eta[i])); - } - - // Collect some constants needed for the histograms. - for (int i = 0; i < ACalorimeterDetector.count(); i++) - { - if (ACalorimeterDetector.get(i).getName().indexOf(CALORIMETER_NAME) >= 0) - { - if (innerR == 0.0 || ACalorimeterDetector.get(i).getRMin() < innerR) - { - innerR = ACalorimeterDetector.get(i).getRMin(); - } - if (phiGranularity == 0.0 || ACalorimeterDetector.get(i).getDeltaPhi() < phiGranularity) - { - phiGranularity = ACalorimeterDetector.get(i).getDeltaPhi(); - } - if (etaGranularity == 0.0 || ACalorimeterDetector.get(i).getDeltaEta() < etaGranularity) - { - etaGranularity = ACalorimeterDetector.get(i).getDeltaEta(); - } - if (outerEta == 0.0 || ACalorimeterDetector.get(i).getEtaMax() > outerEta) - { - outerEta = ACalorimeterDetector.get(i).getEtaMax(); - } - } - - if (outerR == 0.0 || ACalorimeterDetector.get(i).getRMax() > outerR) - { - outerR = ACalorimeterDetector.get(i).getRMax(); - } - if (outerZ == 0.0 || ACalorimeterDetector.get(i).getZMax() > outerZ) - { - outerZ = ACalorimeterDetector.get(i).getZMax(); - } - } - - // Add a little bit of extra margin to prevent binning errors due to - // rounding of numbers. - outerEta += etaGranularity; - - readPulseShapePlotData(p); - - pmt1ADCStatus = (p.get("pmt1ADCStatus") != null) ? p.getIntArray("pmt1ADCStatus") : null; - pmt2ADCStatus = (p.get("pmt2ADCStatus") != null) ? p.getIntArray("pmt2ADCStatus") : null; - - - } // ATILEData() -------------------------------------------------------- - - - - /** - * readLookupTableFile() reads in comma separated values (CSV) file - * with TILE real pulse shapes plots time and amplitude lookup values - * @throws AAtlantisException - */ - protected static void readLookupTableFile() throws AAtlantisException - { - try - { - InputStream is = AUtilities.getFileAsStream(LOOKUP_TABLE_FILE); - CSVParser parser = new CSVParser(is); - parser.setCommentStart("#"); - String arrayName = null; - - while((arrayName = parser.nextValue()) != null) - { - String valueArray = parser.nextValue(); // shall now contain all values - CSVParser parserArray = new CSVParser(new StringReader(valueArray)); - String[][] s = parserArray.getAllValues(); - if("TILE_AMPLITUDE".equals(arrayName)) - { - ACalorimeterRPSPLT.TILE_AMPLITUDE = - getLookupTableArray(s, NUMBER_OF_LOOKUP_VALUES); - } - else if("TILE_TIME".equals(arrayName)) - { - ACalorimeterRPSPLT.TILE_TIME = - getLookupTableArray(s, NUMBER_OF_LOOKUP_VALUES); - } - } - } - catch(FileNotFoundException e) - { - throw new AAtlantisException("could not find file: " + - LOOKUP_TABLE_FILE); - } - catch(IOException e) - { - throw new AAtlantisException("exception while reading file: " + - LOOKUP_TABLE_FILE); - } - catch(AAtlantisException e) - { - throw e; - } - - } // readLookupTableFile() ---------------------------------------------- - - - - private void readPulseShapePlotData(AHashMap p) - { - pmt1Energy = (p.get("pmt1Energy") != null) ? p.getFloatArray("pmt1Energy") : null; - pmt2Energy = (p.get("pmt2Energy") != null) ? p.getFloatArray("pmt2Energy") : null; - pmt1Chi2 = (p.get("pmt1Chi2") != null) ? p.getFloatArray("pmt1Chi2") : null; - pmt2Chi2 = (p.get("pmt2Chi2") != null) ? p.getFloatArray("pmt2Chi2") : null; - pmt1Time = (p.get("pmt1Time") != null) ? p.getFloatArray("pmt1Time") : null; - pmt2Time = (p.get("pmt2Time") != null) ? p.getFloatArray("pmt2Time") : null; - - pmt1Gain = (p.get("pmt1Gain") != null) ? p.getIntArray("pmt1Gain") : null; - pmt2Gain = (p.get("pmt2Gain") != null) ? p.getIntArray("pmt2Gain") : null; - - pmt1Pedestal = (p.get("pmt1Pedestal") != null) ? p.getFloatArray("pmt1Pedestal") : null; - pmt2Pedestal = (p.get("pmt2Pedestal") != null) ? p.getFloatArray("pmt2Pedestal") : null; - - pmt1Number = (p.get("pmt1Number") != null) ? p.getIntArray("pmt1Number") : null; - pmt2Number = (p.get("pmt2Number") != null) ? p.getIntArray("pmt2Number") : null; - - int[] adc1 = (p.get("adcCounts1") != null) ? p.getIntArray("adcCounts1") : null; - int[] adc2 = (p.get("adcCounts2") != null) ? p.getIntArray("adcCounts2") : null; - - // by zdenek (2008-09-15): - // raw time: later additions to tilecal pulse shapes, doens't necessarily - // have to be in the event files, will not be in the old ones - pmt1RawTime = (p.get("pmt1RawTime") != null) ? p.getFloatArray("pmt1RawTime") : null; - pmt2RawTime = (p.get("pmt2RawTime") != null) ? p.getFloatArray("pmt2RawTime") : null; - - // by zdenek (2008-11-24): - // pmt1RawAmplitude, pmt2RawAmplitude now used to calculate pulse shape - // this is made now obligatory, without this data, the pulse shapes will - // not be available - pmt1RawAmplitude = (p.get("pmt1RawAmplitude") != null) ? p.getFloatArray("pmt1RawAmplitude") : null; - pmt2RawAmplitude = (p.get("pmt2RawAmplitude") != null) ? p.getFloatArray("pmt2RawAmplitude") : null; - - // read in ADCCounts - if(adc1 != null && adc2 != null) - { - adcCounts1 = new int[numData][0]; - adcCounts2 = new int[numData][0]; - // amount of numbers associated with each cells (i.e. with each data item) - int multiple = adc1.length / numData; - int num = 0; - for (int i = 0; i < numData; i++) - { - adcCounts1[i] = new int[multiple]; - adcCounts2[i] = new int[multiple]; - for (int j = 0; j < multiple; j++) - { - adcCounts1[i][j] = adc1[num]; // fill in array for each cell - adcCounts2[i][j] = adc2[num]; // fill in array for each cell - num++; - } - } - } - - pulseShapesDataAvailable = false; - if(adcCounts1 != null && adcCounts2 != null && adcCounts1.length != 0 && - adcCounts2.length != 0 && adcCounts1[0].length != 0 && - adcCounts2[0].length != 0 && pmt1Number != null && - pmt2Number != null && pmt1Energy != null && pmt2Energy != null && - pmt1Time != null && pmt2Time != null && pmt1Pedestal != null && - pmt2Pedestal != null && pmt1Gain != null && pmt2Gain != null && - pmt1RawAmplitude != null && pmt2RawAmplitude != null) - { - pulseShapesDataAvailable = true; - - logger.debug(CALORIMETER_NAME + - ": data for real pulse shape plots available"); - - if(ACalorimeterRPSPLT.areTileLookupTablesInitialized()) - { - logger.debug(CALORIMETER_NAME + - ": lookup tables have already been read in"); - } - else - { - - logger.debug(CALORIMETER_NAME + - ": lookup table values have not been read in yet\n" + - " trying to read file: " + LOOKUP_TABLE_FILE); - - try - { - readLookupTableFile(); - logger.debug(CALORIMETER_NAME + - ": values from " + LOOKUP_TABLE_FILE + - " successfully read in"); - } - catch(AAtlantisException ex) - { - logger.error(CALORIMETER_NAME + - ": reading " + LOOKUP_TABLE_FILE + - " failed, real pulse shapes plots will not " + - "be available, reason: " + ex.getMessage(), ex); - pulseShapesDataAvailable = false; - } - } - } - - } // readPulseShapePlotData() ------------------------------------------- - - - - protected void applyCuts() - { - super.applyCuts(); - cut("CutsCalo", "TileET", "TileET", et); - cut("CutsCalo", "TileEnergyBottom", "TileEnergyBottom", energy); - cut("CutsCalo", "TileEnergyUp", "TileEnergyUp", energy); - - // following cut is based on pmt1ADCStatus, resp. pmt2ADCStatus - if(pmt1ADCStatus != null && pmt2ADCStatus != null) - { - cut("CutsCalo", "TilePMTADC", "TilePMTADC", pmt1ADCStatus); - cut("CutsCalo", "TilePMTADC", "TilePMTADC", pmt2ADCStatus); - } - } - - - - /** - * Returns the name of the parameter group. - * @return String parameter group - */ - public String getParameterGroup() - { - return "TILE"; - } - - /** - * Returns the name of the datatype. - * @return String datatype - */ - public String getName() - { - return "TILE"; - } - - /** - * Returns the displayed name of datatype - * @return String screen name - */ - public String getNameScreenName() - { - return "TILE"; - } - - /** - * Returns the type of calorimeter (ECAL/HCAL) for a hit. - * @param index int hit index - * @return String calorimeter type - */ - public String getCalorimeterType(int index) - { - return "HCAL"; - } - - @Override //ACalorimeterData - //Gives the hit time for this Tile cell based on the PMT times - protected double getTime(int hit) - { - if (pmt1Time == null) return 0.0; - else if (pmt2Time == null) return 0.0; - else { - if (pmt1Time[hit]!=0.0 && pmt2Time[hit]!=0.0){ - return (pmt1Time[hit]+pmt2Time[hit])/2.; - } - if (pmt1Time[hit]==0.0 && pmt2Time[hit]!=0.0){ - return pmt2Time[hit]; - } - if (pmt1Time[hit]!=0.0 && pmt2Time[hit]==0.0){ - return pmt1Time[hit]; - } - } - return 0.0; - } - - /** - * Returns calo hit info, most of the parameters are taken from from - * (mother) ACalorimeterData class. - * @param index int - * @return String - */ - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n ET="+String.format("%.3f",et[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Ex="+String.format("%.3f",et[index]*Math.cos(phi[index]))+" GeV "+ - "\n Ey="+String.format("%.3f",et[index]*Math.sin(phi[index]))+" GeV "+ - "\n Ez="+String.format("%.3f",et[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - String t = ""; - String pmt1Info = ""; - String pmt2Info = ""; - - String decodedId = AIdHelper.getDecodedTileIndentifier(id[index]); - t = decodedId + " " + super.getHitInfoNoDecode(index); - - - pmt1Info += "\n PMT1 ADC status = "; - pmt1Info += (pmt1ADCStatus != null) ? Integer.toString(pmt1ADCStatus[index]) : "n/a"; - - pmt1Info += "\n PMT1 energy = "; - pmt1Info += (pmt1Energy != null) ? Float.toString(pmt1Energy[index]) + - " GeV" : "n/a"; - pmt1Info += "\n PMT1 chi2 = "; - pmt1Info += (pmt1Chi2 != null) ? Float.toString(pmt1Chi2[index]) : "n/a"; - pmt1Info += "\n PMT1 time = "; - pmt1Info += (pmt1Time != null) ? Float.toString(pmt1Time[index]) + - " ns" : "n/a"; - pmt1Info += "\n PMT1 gain = "; - pmt1Info += (pmt1Gain != null) ? Integer.toString(pmt1Gain[index]) : "n/a"; - pmt1Info += "\n PMT1 pedestal = "; - pmt1Info += (pmt1Pedestal != null) ? Float.toString(pmt1Pedestal[index]) + - " ADC counts" : "n/a"; - - - pmt2Info += "\n PMT2 ADC status = "; - pmt2Info += (pmt2ADCStatus != null) ? Integer.toString(pmt2ADCStatus[index]) : "n/a"; - - pmt2Info += "\n PMT2 energy = "; - pmt2Info += (pmt2Energy != null) ? Float.toString(pmt2Energy[index]) + - " GeV" : "n/a"; - pmt2Info += "\n PMT2 chi2 = "; - pmt2Info += (pmt2Chi2 != null) ? Float.toString(pmt2Chi2[index]) : "n/a"; - pmt2Info += "\n PMT2 time = "; - pmt2Info += (pmt2Time != null) ? Float.toString(pmt2Time[index]) + - " ns" : "n/a"; - pmt2Info += "\n PMT2 gain = "; - pmt2Info += (pmt2Gain != null) ? Integer.toString(pmt2Gain[index]) : "n/a"; - pmt2Info += "\n PMT2 pedestal = "; - pmt2Info += (pmt2Pedestal != null) ? Float.toString(pmt2Pedestal[index]) + - " ADC counts" : "n/a"; - - pmt2Info += pulseShapesDataAvailable ? "" : - "\n data for real pulse shapes plot n/a"; - - pmt2Info += "\n calc time = "+getTime(index); - - return t + pmt1Info + pmt2Info; - - } // getHitInfo() ------------------------------------------------------- - - - - // calculate real pulse shapes values based on the values in the lookup tables - private double getPhysicsPulseShape(double xTime, double pmtTime, - double pmtPedestal, double pmtEnergy, - float[] amplitude, float[] time) - throws AAtlantisException - { - double tdiv = 0.0; - int lookup = 0; - double localTime = 0.0; - double xpulse = 0.0; - - // need to get "multiple" parameter ( = number of values in adcCounts - // for each cell - adcCounts1[0].length), shall be the same for all the - // cells - taking the length of the first array (for the first cell) - // [currently (2007-05-23) is this multiple 9 but to change in real data] - // no NullPointer or ArrayIndexBound checks are necessary here as this - // method shall only be called when the relevant data is available - double centerOfSamples = (adcCounts1[0].length + 1.0) / 2.0; - - tdiv = time[1] - time[0]; - localTime = (xTime - centerOfSamples) * 25.0 - pmtTime; - lookup = (int) ((localTime - time[0]) / tdiv); - - if(lookup < 0) - { - lookup = 0; - } - if(lookup >= NUMBER_OF_LOOKUP_VALUES - 1) - { - lookup = NUMBER_OF_LOOKUP_VALUES - 2; // -1 was off by 1 - } - - try - { - if(lookup == 0 || lookup == NUMBER_OF_LOOKUP_VALUES - 2) - { - xpulse = amplitude[lookup]; - } - else - { - xpulse = amplitude[lookup] + ((amplitude[lookup + 1] - - amplitude[lookup]) / tdiv) * (localTime - time[lookup]); - } - } - catch(ArrayIndexOutOfBoundsException ex) - { - String m = "ATILEData.getPhysicsPulseShape():\n" + - " lookup index out of bound: lookup = " + lookup; - throw new AAtlantisException(m); - } - return (xpulse * pmtEnergy) + pmtPedestal; - - } // getPhysicsPulseShape() --------------------------------------------- - - - -// /** -// * Call util class which plots cell pulse shapes provided that -// * all real pulse shapes data is available -// * Functions calculates values of real pulse shape calculated in the method -// * getPhysicsPulseShape(). -// * This method is called from pick interaction. -// * -// * @param index int -// */ - /*public void plotPulseShapes(int index) - { - - if(pulseShapesDataAvailable) - { - String title = getPulseTitleString(index); - - // two channels for a TILE cell (two arrays of ADC counts) - int[][] adcCounts = new int[][] { adcCounts1[index], adcCounts2[index] }; - - if(super.checkADCCountsAvailability(adcCounts)) - { - // adc counts are available - logger.debug(CALORIMETER_NAME + " adc counts (digits) are " + - "available for pulse shapes plots for this cell."); - } - else - { - AOutput.append("\nADC counts are not available for this cell, " + - "can't plot pulse shapes.", ALogPane.WARNING); - return; - } - - - String cap1 = "Real pulse shape " + "PMT " + pmt1Number[index] + - " gain " + pmt1Gain[index]; - String cap2 = "Real pulse shape " + "PMT " + pmt2Number[index] + - " gain " + pmt2Gain[index]; - String[] subTitle = new String[] { cap1, cap2 }; - - // by zdenek (2008-11-24): - // energy calculations (lowGainFactor, highGainFactor) and related - // magic constants removed - now using pmt1RawAmplitude, pmt2RawAmplitude - // instead of pmt[1,2]Energy, resp. former local variables - // energy1, energy2 when calling getPhysicsPulseShape() further down - - // 1 .. 9 range (9 values of ADC counts, 9 samples (starts from 1!)), - // need to get 401 values within this range. number of samples will - // likely decrease in real data from 9 to 7 - double step = (adcCounts1[index].length - 1) / (float) NUMBER_OF_LOOKUP_VALUES; - double[][] realPulse = new double[2][NUMBER_OF_LOOKUP_VALUES]; // 2 channels - double[][] realPulseForRawTime = null; - double d = 1.0; - - // if pmt1RawTime and pmt2RawTime are present, use those for - // calculating data for real pulse shape plot based on these time values - boolean showPlotForRawTime = false; - if(pmt1RawTime != null && pmt2RawTime != null) - { - logger.debug("TILE pmt[1,2]RawTime are present, showing another plot."); - showPlotForRawTime = true; - realPulseForRawTime = new double[2][NUMBER_OF_LOOKUP_VALUES]; // 2 channels - } - - - // by zdenek 2008-11-25 - // DPD (slimed version of ESD) sometimes don't have pmt[1,2]Pedestal - // for a cell (the tag exists, values are there, but are 0). check - // if pedestal is 0 and if so, take as pedestal value the first - // adc count digit - float pmt1PedestalLocal = pmt1Pedestal[index]; - float pmt2PedestalLocal = pmt2Pedestal[index]; - if(pmt1PedestalLocal == 0.0f && pmt2PedestalLocal == 0.0f) - { - logger.debug("TILE pmt[1,2]Pedestal are not available (i.e. " + - "are 0.0f), using minimum of first and last " + - "adcCount digit as pedestal."); - float last1 = adcCounts1[index][adcCounts1[index].length - 1]; - float last2 = adcCounts2[index][adcCounts2[index].length - 1]; - pmt1PedestalLocal = Math.min(adcCounts1[index][0], last1); - pmt2PedestalLocal = Math.min(adcCounts2[index][0], last2); - } - - - try - { - for(int i = 0; i < NUMBER_OF_LOOKUP_VALUES; i++) - { - d += step; - realPulse[0][i] = - getPhysicsPulseShape(d, pmt1Time[index], pmt1PedestalLocal, - pmt1RawAmplitude[index], - ACalorimeterRPSPLT.TILE_AMPLITUDE, - ACalorimeterRPSPLT.TILE_TIME); - realPulse[1][i] = - getPhysicsPulseShape(d, pmt2Time[index], pmt2PedestalLocal, - pmt2RawAmplitude[index], - ACalorimeterRPSPLT.TILE_AMPLITUDE, - ACalorimeterRPSPLT.TILE_TIME); - if(showPlotForRawTime) - { - realPulseForRawTime[0][i] = - getPhysicsPulseShape(d, pmt1RawTime[index], pmt1PedestalLocal, - pmt1RawAmplitude[index], - ACalorimeterRPSPLT.TILE_AMPLITUDE, - ACalorimeterRPSPLT.TILE_TIME); - realPulseForRawTime[1][i] = - getPhysicsPulseShape(d, pmt2RawTime[index], pmt2PedestalLocal, - pmt2RawAmplitude[index], - ACalorimeterRPSPLT.TILE_AMPLITUDE, - ACalorimeterRPSPLT.TILE_TIME); - } - } - } - catch(AAtlantisException aaex) - { - AOutput.append(aaex.getMessage(), ALogPane.WARNING); - return; - } - - if(realPulseForRawTime != null) - { - APulseShapePlot.plotRealPulseShapes(adcCounts, realPulse, - step, subTitle, title + " (cell time)"); - APulseShapePlot.plotRealPulseShapes(adcCounts, realPulseForRawTime, - step, subTitle, title + " (raw time)"); - } - else - { - // if RawTime stuff is to be removed, there will remain only - // one such call to plot real pulse shapes - this one - APulseShapePlot.plotRealPulseShapes(adcCounts, realPulse, - step, subTitle, title); - } - } - else - { - logger.warn(CALORIMETER_NAME + " plotPulseShapes() method called, " + - "but data is not available."); - return; - } - - } */// plotPulseShapes() -------------------------------------------------- - - - - /** - * Returns the histograms for this projection. - * - * @param projection AProjection2D current projection - * @return ACoord[] polygons representing histograms - */ - protected ACoord[] getUserHistograms(AProjection2D projection) - { - ACoord[] data = ACoord.NO_HISTOGRAMS; - if (projection instanceof AProjectionYX && parameterStore.get("YX", "Mode").getI() == AProjectionYX.MODE_STANDARD) - data = getYXHistograms(); - else if (projection instanceof AProjectionFR) - data = getFRHistograms(); - else if (projection instanceof AProjectionRZ) - data = getRZHistograms(); - return projection.nonLinearTransform(data); - } - - @Override - protected String getPulseTitleString(int index) { - String[] decodedId = AIdHelper.getFullIdentifier(id[index]); - - String title = CALORIMETER_NAME + " cell: " + decodedId[0]; - - return title; - } - - @Override - protected int[][] getADCCounts(int index) { - - if (pulseShapesDataAvailable) { - // two channels for a TILE cell (two arrays of ADC counts) - return new int[][]{adcCounts1[index], adcCounts2[index]}; - } else { - return null; - } - } - - @Override - protected double[][] getPulseShape(int index) { - - if (!pulseShapesDataAvailable) return null; - - // by zdenek (2008-11-24): - // energy calculations (lowGainFactor, highGainFactor) and related - // magic constants removed - now using pmt1RawAmplitude, pmt2RawAmplitude - // instead of pmt[1,2]Energy, resp. former local variables - // energy1, energy2 when calling getPhysicsPulseShape() further down - - // 1 .. 9 range (9 values of ADC counts, 9 samples (starts from 1!)), - // need to get 401 values within this range. number of samples will - // likely decrease in real data from 9 to 7 - double step = getPulseStep(index); - double[][] realPulseRaw = new double[2][NUMBER_OF_LOOKUP_VALUES]; // 2 channels - double d = 1.0; - - // if pmt1RawTime and pmt2RawTime are present, use those for - // calculating data for real pulse shape plot based on these time values - if (pmt1RawTime == null || pmt2RawTime == null) { - logger.warn("No raw time values available"); - return null; - } - - - // by zdenek 2008-11-25 - // DPD (slimed version of ESD) sometimes don't have pmt[1,2]Pedestal - // for a cell (the tag exists, values are there, but are 0). check - // if pedestal is 0 and if so, take as pedestal value the first - // adc count digit - float pmt1PedestalLocal = pmt1Pedestal[index]; - float pmt2PedestalLocal = pmt2Pedestal[index]; - if (pmt1PedestalLocal == 0.0f && pmt2PedestalLocal == 0.0f) { - logger.debug("TILE pmt[1,2]Pedestal are not available (i.e. " + - "are 0.0f), using minimum of first and last " + - "adcCount digit as pedestal."); - float last1 = adcCounts1[index][adcCounts1[index].length - 1]; - float last2 = adcCounts2[index][adcCounts2[index].length - 1]; - pmt1PedestalLocal = Math.min(adcCounts1[index][0], last1); - pmt2PedestalLocal = Math.min(adcCounts2[index][0], last2); - } - - try { - for (int i = 0; i < NUMBER_OF_LOOKUP_VALUES; i++) { - d += step; - realPulseRaw[0][i] = - getPhysicsPulseShape(d, pmt1RawTime[index], pmt1PedestalLocal, - pmt1RawAmplitude[index], - ACalorimeterRPSPLT.TILE_AMPLITUDE, - ACalorimeterRPSPLT.TILE_TIME); - realPulseRaw[1][i] = - getPhysicsPulseShape(d, pmt2RawTime[index], pmt2PedestalLocal, - pmt2RawAmplitude[index], - ACalorimeterRPSPLT.TILE_AMPLITUDE, - ACalorimeterRPSPLT.TILE_TIME); - } - } catch (AAtlantisException aaex) { - AOutput.append(aaex.getMessage(), ALogInterface.WARNING); - return null; - } - - return realPulseRaw; - } - - protected double[][] getPulseShapeCellTime(int index) { - - if (!pulseShapesDataAvailable) return null; - - double step = getPulseStep(index); - double[][] realPulse = new double[2][NUMBER_OF_LOOKUP_VALUES]; // 2 channels - double d = 1.0; - - // by zdenek 2008-11-25 - // DPD (slimed version of ESD) sometimes don't have pmt[1,2]Pedestal - // for a cell (the tag exists, values are there, but are 0). check - // if pedestal is 0 and if so, take as pedestal value the first - // adc count digit - float pmt1PedestalLocal = pmt1Pedestal[index]; - float pmt2PedestalLocal = pmt2Pedestal[index]; - if (pmt1PedestalLocal == 0.0f && pmt2PedestalLocal == 0.0f) { - logger.debug("TILE pmt[1,2]Pedestal are not available (i.e. " + - "are 0.0f), using minimum of first and last " + - "adcCount digit as pedestal."); - float last1 = adcCounts1[index][adcCounts1[index].length - 1]; - float last2 = adcCounts2[index][adcCounts2[index].length - 1]; - pmt1PedestalLocal = Math.min(adcCounts1[index][0], last1); - pmt2PedestalLocal = Math.min(adcCounts2[index][0], last2); - } - - try { - for (int i = 0; i < NUMBER_OF_LOOKUP_VALUES; i++) { - d += step; - realPulse[0][i] = - getPhysicsPulseShape(d, pmt1Time[index], pmt1PedestalLocal, - pmt1RawAmplitude[index], - ACalorimeterRPSPLT.TILE_AMPLITUDE, - ACalorimeterRPSPLT.TILE_TIME); - realPulse[1][i] = - getPhysicsPulseShape(d, pmt2Time[index], pmt2PedestalLocal, - pmt2RawAmplitude[index], - ACalorimeterRPSPLT.TILE_AMPLITUDE, - ACalorimeterRPSPLT.TILE_TIME); - } - } catch (AAtlantisException aaex) { - AOutput.append(aaex.getMessage(), ALogInterface.WARNING); - return null; - } - - return realPulse; - } - - - @Override - protected double getPulseStep(int index) { - return (adcCounts1[index].length - 1) / (float) NUMBER_OF_LOOKUP_VALUES; - } - - @Override - protected String[] getPulseSubtitle(int index) { - String cap1 = "Real pulse shape " + "PMT " + pmt1Number[index] + - " gain " + pmt1Gain[index]; - String cap2 = "Real pulse shape " + "PMT " + pmt2Number[index] + - " gain " + pmt2Gain[index]; - return new String[]{cap1, cap2}; - } - - public void plotPulseShapesWithTiming(int index) { - - int[][] adc = getADCCounts(index); - double[][] raw = getPulseShape(index); - double[][] cell = getPulseShapeCellTime(index); - - if (adc == null || raw == null || cell == null) { - logger.warn("Pulse shapes with raw/cell times requested but no " + - "data available, falling back to regular pulse shapes"); - plotPulseShapes(index, true); - } else { - APulseShapePlot.plotRawCellPulseShapes(adc, raw, cell, - getPulseStep(index), getPulseSubtitle(index), - getPulseTitleString(index)); - } - - /*if (!withcurve) { - APulseShapePlot.plotADCCounts(adc, getPulseTitleString(index), null); - } else { - double[][] ps = getPulseShape(index); - if (ps == null) { - logger.warn("No pulse shape information available, just plotting adc instead"); - APulseShapePlot.plotADCCounts(adc, getPulseTitleString(index), null); - } else { - APulseShapePlot.plotRealPulseShapes(adc, ps, - getPulseStep(index), getPulseSubtitle(index), getPulseTitleString(index)); - } - }*/ - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ATRTData.java b/graphics/AtlantisJava/src/atlantis/data/ATRTData.java deleted file mode 100644 index c77849df8a980a43d9566c0a08154891e52ab5fb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ATRTData.java +++ /dev/null @@ -1,752 +0,0 @@ -package atlantis.data; - -import java.awt.event.ActionEvent; -import java.awt.geom.Point2D; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.Vector; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.tree.DefaultMutableTreeNode; - -import atlantis.canvas.ACanvas; -import atlantis.event.AData; -import atlantis.event.AEvent; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.graphics.colormap.AColorMap; -import atlantis.list.AList; -import atlantis.list.AListManager; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.AEnumeratorParameter; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterUtilities; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AHashMap; -import atlantis.utils.AIdHelper; -import atlantis.utils.AMath; - - -/** - * - * Transition Radiation Tracker data - * - * data from the event file - * id - processed by AData - * barcode (old) / barcodes and numBarcodes (new) - processed by AHitData - * phi - * rhoz - rho (for barrel) or z (for endcap) - * driftR - drift radius - * threshold - * sub - subdetector - * - * still need to have correct phi calculated from pVtx for cuts - * still need to have correct rho calculated from pVtx for cuts - * - */ -public class ATRTData extends AHitData -{ - protected float[] phi = null; - protected float[] rhoz = null; - protected float[] driftR = null; - protected int[] threshold = null; - protected int[] noise = null; - // bitPattern subtag information implemented in the retriever but - // currently (2009-01-21) not used or necessary but - // said to may become useful later - protected int[] bitPattern = null; - protected float[] timeOverThreshold = null; - protected HashMap<String, int[]> driftSign = new HashMap<String, int[]>(); - protected HashMap<String, int[]> isOutlier = new HashMap<String, int[]>(); - //error code for when driftSign/isOutlier is not present - private static final int NO_DATA =-99; - - - - public String getParameterGroup() - { - return "TRT"; - } - - - public String getName() - { - return "TRT"; - } - - - public String getNameScreenName() - { - return "TRT_DriftCircle"; - } - - - public int getDriftSign(int index) - { - //find current selection of track - AEnumeratorParameter listBox = (AEnumeratorParameter) parameterStore.get("InDetTrack", "InDetTrackCollections"); - String currentSelection = listBox.getCurrentText(); - if(driftSign!=null && !currentSelection.equals("All")) - { - //find data from current track - int[] data = (int[]) driftSign.get(currentSelection); - if(data!=null) - return data[index]; - } - //no present so return error code - return NO_DATA; - } - - - public int getIsOutlier(int index) - { - //find current selection of track - AEnumeratorParameter listBox = (AEnumeratorParameter) parameterStore.get("InDetTrack", "InDetTrackCollections"); - String currentSelection = listBox.getCurrentText(); - if(isOutlier!=null && !currentSelection.equals("All")) - { - //find data from current track - int[] data = (int[]) isOutlier.get(currentSelection); - if(data!=null) - return data[index]; - } - //no present so return error code - return NO_DATA; - } - - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+"\n"+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - - StringBuilder s = new StringBuilder(); - String[] decodedId = AIdHelper.getFullIdentifier(id[index]); - s.append(getNameScreenName() + " (id: " + decodedId[0] + - " index: " + index + ")"); - // iterate over decodedId to get further details (if available), - // first item [0] was already printed out above - for(int i = 1; i < decodedId.length; i++) - { - s.append("\n " + decodedId[i]); - } - if(sub[index] == 1 || sub[index] == 2) - { - s.append("\n " + AMath.RHO + " = " + String.format("%.1f",rhoz[index]) + " cm"); - } - else - { - s.append("\n z = " + String.format("%.1f",rhoz[index]) + " cm"); - } - s.append("\n " + AMath.PHI + " = " + - String.format("%.1f",Math.toDegrees(phi[index])) + AMath.DEGREES + - " (" + String.format("%.3f",phi[index]) + " rad)" + - "\n drift radius = " + String.format("%.3f",driftR[index]) + " cm" + - "\n threshold = " + threshold[index] + - "\n sub = " + sub[index]); - - s.append(super.getHitInfo(index)); // finds barcode information - - int d = getDriftSign(index); - s.append((d!=NO_DATA) ? ("\n driftSign = " + d) : "\n driftSign = n/a"); - int o = getIsOutlier(index); - s.append((o!=NO_DATA) ? ("\n isOutlier = " + o) : "\n isOutlier = n/a"); - s.append("\n noise = " + (noise != null ? noise[index] : "n/a")); - s.append("\n time over threshold = " + - (timeOverThreshold != null ? timeOverThreshold[index] : "n/a")); - - return s.toString(); - - } // getHitInfo() ------------------------------------------------------- - - - public ATRTData(AHashMap p, AEvent e) - { - super(p,e); - phi = p.getFloatArray("phi"); - rhoz = p.getFloatArray("rhoz"); - driftR = p.getFloatArray("driftR"); - threshold = p.getUnknownIntArray("threshold"); - noise = p.getUnsureIntArray("noise"); - if(p.getIntArray("sub") == null) - { - for(int i=0; i<numData; i++) - { - sub[i] = getSub(id[i]); - } - } - // the way to retrieve bitPattern subtag information - // currently (2009-01-21) not used or necessary but - // said to may become useful later - // bitPattern = p.getIntArray("bitPattern"); - timeOverThreshold = p.getFloatArray("timeOverThreshold"); - - } // ATRTData() --------------------------------------------------------- - - - protected int internalColor() - { - int numColorTypes = super.internalColor(); - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - if(colorFunction == numColorTypes + 1) // colour by Track Segment - { - colorBy(getSegments()); - } - else if(colorFunction == numColorTypes + 2) // colour by isOutlier - { - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - int iO = getIsOutlier(list); - if(iO==0) - color[list]= AColorMap.GN;//green - else if(iO==1) - color[list]= AColorMap.RD;//red - else - color[list]= (byte) parameterStore.get(PARAMETER_GROUP, "Constant").getI(); - } - } - else if(colorFunction == numColorTypes + 3) // colour by driftSign - { - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - int ds = getDriftSign(list); - if(ds==-1) - color[list]= AColorMap.GN;//green - else if(ds==1) - color[list]= AColorMap.RD;//red - else - color[list]= (byte) parameterStore.get(PARAMETER_GROUP, "Constant").getI(); - } - } - else if(colorFunction == numColorTypes + 4) // colour by threshold - { - for(int i=0; i<numDraw; i++) - { - int list = listdl[i]; - if(threshold[list]==1) - color[list]= AColorMap.RD; // red is preferable then previous green - else - color[list]= (byte) parameterStore.get(PARAMETER_GROUP, "Constant").getI(); - } - } - return numColorTypes + 1; - - } // internalColor() ---------------------------------------------------- - - - - public int getLayer(int id) - { - try { - return AIdHelper.trtLayerWheel(id); - } catch (AAtlantisException e) { - return 0; - } - //return(id & 0x01F00000) >> 20; before using IDHelper - } - - - - public int getSub(int id) - { - try { - return AIdHelper.trtBarrelEndcap(id); - } catch (AAtlantisException e) { - return 0; - } - //return(id & 0x06000000) >> 25; before using IDHelper - } - - - - protected void applyCuts() - { - cutIndex(); - cut("CutsInDet", "Threshold", " Threshold", threshold); - cutSimulatedTracks(); - cutReconstructedTracks(); - cutSegments(); - cutPhi(phi); - cutEta(); - - // cut noise - if(noise != null && parameterStore.get("CutsInDet", "Noise").getStatus()) - { - cutArray(noise, 0, "TRT Noise Cut"); - } - - // cut TimeOverThreshold - // method takes care that the cut is actually turned on - // or if the timeOverThreshold array is null (n/a in the event file) - cut("CutsInDet", "TRTTimeOverThreshold", - "TRTTimeOverThreshold", timeOverThreshold); - } - - - - private void keepBarrel() - { - int num = 0; - int cutSub = parameterStore.get("CutsInDet", "TRT").getI(); - for(int i = 0; i < numDraw; i++) - { - // sub values 1 and 2 - barrel - if(sub[listdl[i]] == 1 || sub[listdl[i]] == 2) - { - if(cutSub == -1 || sub[listdl[i]] == cutSub) - { - listdl[num++] = listdl[i]; - } - } - } - numDraw = num; - } - - - - private void keepEndcap() - { - int num = 0; - for(int i = 0; i < numDraw; i++) - { - // sub values 0 and 3 - endcaps - if(sub[listdl[i]] == 0 || sub[listdl[i]] == 3) - { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - - - - private void cutEta() - { - AParameter par = parameterStore.get("CutsATLAS", "CutEta"); - if(!par.getStatus())return; - double etaCut = par.getD(); - double etaMid = parameterStore.get("CutsATLAS", "EtaMiddle").getD(); - double etaLowerCut = etaMid - etaCut; - double etaUpperCut = etaMid + etaCut; - int num = 0; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double z1, z2, r1, r2; - if(sub[list] == 0 || sub[list] == 3) - { - // endcap - z1 = rhoz[list]; - z2 = rhoz[list]; - r1 = 64.; - if(Math.abs(rhoz[list]) > 280.) r1 = 48.; - r2 = 103.; - } - else - { - // barrel - z1 = 0.35; - if(rhoz[list] < 62) z1 = 40.; - z2 = 74.2; - if(sub[list] == 1) - { - z1 *= -1.; - z2 *= -1.; - } - r1 = rhoz[list]; - r2 = rhoz[list]; - } - double eta1 = AParameterUtilities.eta(z1, r1); - double eta2 = AParameterUtilities.eta(z2, r2); - double etaLower = Math.min(eta1, eta2); - double etaUpper = Math.max(eta1, eta2); - if(etaUpper > etaLowerCut && etaLower < etaUpperCut) - listdl[num++] = list; - } - numDraw = num; - } - - - // in XY only TRT barrel data are displayed - protected ACoord getYXUser() - { - makeDrawList(); - keepBarrel(); - double zoomScaling=0; - //check if zoomed in enough to display circles/drift sign arrows - Point2D.Double[] corners = ACanvas.getCanvas().getPaintingWindow().getUserCorners(); - double widthx=corners[1].x-corners[0].x; - double widthy=corners[0].y-corners[2].y; - //average width of window - double width=Math.sqrt(widthx*widthx+widthy*widthy); - //calculate scaling (100 is arbitrary constant) - zoomScaling=100/width; - //now return relevant user coords depending on the zoom - //(0.25 is arbitrary constant increase to turn on drawing - // circles and arrows at a more zoomed in state) - if(zoomScaling>0.25) - return getYXUserCircle(); - else - return getYXUserNormal(); - } - - - /** - * Will give coords for a line along the TRT drift - */ - private ACoord getYXUserNormal() - { - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double r = rhoz[list]; - double cosPhi = Math.cos(phi[list]); - double sinPhi = Math.sin(phi[list]); - double d = driftR[list]; - double x = r * cosPhi; - double y = r * sinPhi; - hv[0][0][i] = x + d * sinPhi; - hv[1][0][i] = y - d * cosPhi; - hv[0][1][i] = x - d * sinPhi; - hv[1][1][i] = y + d * cosPhi; - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } - - - /** - * Will give coords for the drift circle and arrow showing the drift - */ - private ACoord getYXUserCircle() - { - int numPoints = 48; - int[] index = new int[numDraw]; - double[][][] hv = new double[2][numDraw][]; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int ds = getDriftSign(list); - //adjust ds if z<0 - if(sub[list] == 1) - { - ds *= -1; - } - if(ds==1 || ds==-1) - { - //has drift sign so has extra points for arrow - hv[0][i] = new double[numPoints+3]; - hv[1][i] = new double[numPoints+3]; - } - else - { - hv[0][i] = new double[numPoints]; - hv[1][i] = new double[numPoints]; - ds=0; - } - double r = rhoz[list]; - double cosPhi = Math.cos(phi[list]); - double sinPhi = Math.sin(phi[list]); - double d = driftR[list]; - double x = r * cosPhi; - double y = r * sinPhi; - int jstart=0; - //calculate starting point of circle - if(ds==1 || ds ==-1) - { - jstart = (int) (phi[list]/(Math.PI * 2 / (numPoints - 1))); - d*=ds; - } - //store points of circle - int count=0; - for (int j = jstart; j < numPoints; j++) - { - hv[0][i][count] = x + d * Math.sin(Math.PI * 2 * j / (numPoints - 1)); - hv[1][i][count] = y - d * Math.cos(Math.PI * 2 * j / (numPoints - 1)); - count++; - } - for (int j = 0; j < jstart; j++) - { - hv[0][i][count] = x + d * Math.sin(Math.PI * 2 * (j+1) / (numPoints - 1)); - hv[1][i][count] = y - d * Math.cos(Math.PI * 2 * (j+1) / (numPoints - 1)); - count++; - } - index[i] = list; - //if has drift show arrow - if(ds==1 || ds==-1) - { - //first line - hv[0][i][numPoints] = hv[0][i][2*(numPoints-1)/5]; - hv[1][i][numPoints] = hv[1][i][2*(numPoints-1)/5]; - //back to end point of circle - hv[0][i][numPoints+1] = hv[0][i][numPoints-1]; - hv[1][i][numPoints+1] = hv[1][i][numPoints-1]; - //second line - hv[0][i][numPoints+2] = hv[0][i][3*(numPoints-1)/5]; - hv[1][i][numPoints+2] = hv[1][i][3*(numPoints-1)/5]; - } - } - return new ACoord(hv, index, this, ACoord.POLYLINES); - } - - - protected ACoord getRZUser() - { - // correction for primary vertex - if(!parameterStore.get("RZ", "TRT").getStatus())return ACoord.NO_DATA; - makeDrawList(); - // line size was found using findRZActiveArea(){ - // may need to be found again if geometry changes... - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - if(sub[list] == 0 || sub[list] == 3) - { - // endcap - hv[0][0][i] = rhoz[list]; - hv[0][1][i] = rhoz[list]; - double phiDiff = Math.abs(phi[list] - phiMid); - double r1 = 64.; - if(Math.abs(rhoz[list]) > 280.) r1 = 48.; - double r2 = 103.; - if(phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - { - hv[1][0][i] = r1; - hv[1][1][i] = r2; - } - else - { - hv[1][0][i] = -r1; - hv[1][1][i] = -r2; - } - } - else - { - // barrel - double z1 = 0.35; - if(rhoz[list] < 62) z1 = 40.; - double z2 = 74.2; - if(sub[list] == 1) - { - z1 *= -1.; - z2 *= -1.; - } - hv[0][0][i] = z1; - hv[0][1][i] = z2; - double phiDiff = Math.abs(phi[list] - phiMid); - if(phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - { - hv[1][0][i] = rhoz[list]; - hv[1][1][i] = rhoz[list]; - } - else - { - hv[1][0][i] = -rhoz[list]; - hv[1][1][i] = -rhoz[list]; - } - } - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES); - } - - - protected ACoord getFRUser() - { - makeDrawList(); - keepBarrel(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - double[] pVtx = event.getPrimaryVertex(); - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double r = rhoz[list]; - double p = phi[list]; - double x = r * Math.cos(p); - double y = r * Math.sin(p); - double dx = x - pVtx[0]; - double dy = y - pVtx[1]; - r = Math.sqrt(dx * dx + dy * dy); - p = Math.atan2(dy, dx); - if(p < 0.) p += AMath.TWO_PI; - double delPhi = driftR[list] / r; - hv[0][0][i] = r; - hv[1][0][i] = Math.toDegrees(p - delPhi); - hv[0][1][i] = r; - hv[1][1][i] = Math.toDegrees(p + delPhi); - index[i] = list; - } - return new ACoord(hv, index, this, ACoord.LINES).includePhiWrapAround("FR"); - } - - - - protected ACoord getFZUser() - { - makeDrawList(); - keepEndcap(); - double[][][] hv = new double[2][2][numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double z = rhoz[list]; - // average rho from findRZActiveArea() - double averageRho = 81.; - if(Math.abs(z) > 280.) - averageRho = 70.; - double p = phi[list]; - double delPhi = driftR[list] / averageRho; - hv[0][0][i] = z; - hv[1][0][i] = Math.toDegrees(p - delPhi); - hv[0][1][i] = z; - hv[1][1][i] = Math.toDegrees(p + delPhi); - index[i] = list; - } - return new ACoord(hv, index, this, - ACoord.LINES).includePhiWrapAround("FZ"); - } - - - public Action[] getActions(Collection nodes) - { - if(nodes.size() != 1) - return new Action[0]; - final DefaultMutableTreeNode node = (DefaultMutableTreeNode) (nodes. - iterator().next()); - AList[] list = AListManager.getInstance().getChildren(node); - if(list == null)return new Action[0]; - Set hits = new HashSet(); - for(int i = 0; i < list.length; ++i) - { - if(list[i].getSource() == this) - { - for(int j = 0; j < list[i].getItems().length; j++) - { - hits.add(new Integer(list[i].getItems()[j])); - } - } - else - { - return new Action[0]; - } - } - int numHits = hits.size(); - if(numHits < 2) - return new Action[0]; - final int[] h = new int[numHits]; - Iterator i = hits.iterator(); - int n = 0; - while(i.hasNext()) - { - h[n++] = ((Integer) (i.next())).intValue(); - } - Action[] action = new Action[1]; - action[0] = new AbstractAction("Find Eta") - { - public void actionPerformed(ActionEvent e) - { - final double MIN = 9999.; - final double MAX = -9999.; - double minRho = MIN; - double maxRho = MAX; - double minZ = MIN; - double maxZ = MAX; - for(int i = 0; i < h.length; ++i) - { - if(sub[h[i]] == 1 || sub[h[i]] == 2) - { - minRho = Math.min(minRho, rhoz[h[i]]); - maxRho = Math.max(maxRho, rhoz[h[i]]); - } - else - { - minZ = Math.min(minZ, rhoz[h[i]]); - maxZ = Math.max(maxZ, rhoz[h[i]]); - } - } - AOutput.append("Eta results:\n minRho = " + - String.format("%.3f",minRho) + - " maxRho = " + String.format("%.3f",maxRho) + "\n" + - " minZ = " + String.format("%.3f",minZ) + - " maxZ = " + String.format("%.3f",maxZ) + "\n", - ALogInterface.NORMAL); - } - }; - return action; - } - - - @Override - protected void finalizeConstruction() { - super.finalizeConstruction(); - Vector keys = (Vector) event.getCollections().get("InDetTrack"); - if(keys != null) - { - Iterator keysIterator = keys.iterator(); - //loop over collections - while(keysIterator.hasNext()) - { - String trackCollec = (String) keysIterator.next(); - AInDetTrackData data = (AInDetTrackData) (event.get("InDetTrack" + trackCollec)); - int[][] hits = event.getAssociationManager().get("InDetTrack" + trackCollec, getName()); - int[][] drifts = event.getAssociationManager().get("InDetTrack" + trackCollec + "Drift", getName()); - int[][] outliers = event.getAssociationManager().get("InDetTrack" + trackCollec + "Outlier", getName()); - - if(drifts!=null || outliers!=null) - { - int[] driftSignData = new int[numData]; - int[] isOutlierData = new int[numData]; - //set to noData to distinguish from a 0 returned if the data is present - for(int i=0; i<this.numData; i++) - { - driftSignData[i]=NO_DATA; - isOutlierData[i]=NO_DATA; - } - //loop over alll hits in track collection - for(int i=0; i<data.getNumData(); i++) - { - for(int j=0; j<hits[i].length; j++) - { - //check if current hit matches a TRT index - int list=getIndexFromId(hits[i][j]); - if(list!=-1) - { - //found match so save value if not null - if(drifts!=null) - driftSignData[list] = drifts[i][j]; - if(outliers!=null) - isOutlierData[list] = outliers[i][j]; - } - } - } - //if has data in file then save array of values - if(drifts!=null) - driftSign.put(trackCollec, driftSignData); - if(outliers!=null) - isOutlier.put(trackCollec, isOutlierData); - } - //no data for this collection in file so save null to vector - if(drifts==null) - driftSign.put(trackCollec, null); - if(outliers==null) - isOutlier.put(trackCollec, null); - } - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ATauJetData.java b/graphics/AtlantisJava/src/atlantis/data/ATauJetData.java deleted file mode 100755 index 91ebb9af7757f2edcc796ee86e483f739d0062bf..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ATauJetData.java +++ /dev/null @@ -1,198 +0,0 @@ -package atlantis.data; - -import java.util.Vector; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; -import atlantis.utils.A4Vector; - -/** - * Reconstructed Tau Jet - */ -public class ATauJetData extends AAODData -{ - // Note: This is a hierarchy list ! I.e. TauCutTight is assumed to have passed - // all other criteria as well. This is strictly not completely correct but - // good enough for Atlantis purposes. - private enum isTau { TauCutTight, TauCutMedium, TauCutLoose, TauLlhTight, TauLlhMedium, TauLlhLoose, none } - - private float[] charge; - private int[] integerCharge; - private int[] numTracks; - private float[] isolFrac; - private float[] logLhRatio; - private String[] label; - private Vector<Enum> isTauEnum = new Vector<Enum>(); - - ATauJetData(AHashMap p, AEvent e) - { - super(p,e); - charge=p.getFloatArray("charge"); - integerCharge = new int[charge.length]; - - // The recommended default cut for Tau charge is to equal to 1/-1, - // but the cut for float value has no "=" operator in the - // implementation, so change float[] to int[] to make it possible - // to use "=". - for(int i=0; i<charge.length; ++i) - { - integerCharge[i] = (int) charge[i]; - } - numTracks=p.getUnknownIntArray("numTracks"); - isolFrac=p.getUnsureFloatArray("isolFrac"); - logLhRatio=p.getUnsureFloatArray("logLhRatio"); - label=p.getUnsureStringArray("label"); - String[] isTauString=p.getUnsureStringArray("isTauString"); - - if(isTauString!=null){ - for(String s : isTauString) - { - try { - isTauEnum.add(isTau.valueOf(s)); - } - catch(IllegalArgumentException q) { - isTauEnum.add(isTau.none); - } - } - } - else - { - for(int i=0;i<numData;i++) - { - isTauEnum.add(isTau.none); - } - } - } - - public String getParameterGroup() - { - return "TauJet"; - } - - public String getName() - { - return "TauJet"; - } - - public float getCharge(int index) - { - return charge[index]; - } - - public int getNumTracks(int index) - { - return numTracks[index]; - } - - public float getIsolFrac(int index) - { - if(isolFrac != null) return isolFrac[index]; - else return -100; - } - - public float getLogLhRatio(int index) - { - if(logLhRatio != null) return logLhRatio[index]; - else return -100; - } - - public String getisTau(int index) - { - return isTauEnum.get(index).toString(); - } - - public A4Vector get4Vector(int num, int[] list) - { - A4Vector sum = new A4Vector(); - for (int i = 0; i < num; ++i) - { - int k = list[i]; - A4Vector start = new A4Vector(); - start.setPtEtaPhiM(pT[k],eta[k],phi[k],1.77682); - sum.add(start); - } - - return sum; - } - - protected void applyCuts() - { - super.applyCuts(); - cut("CutsObjects", "TauJetPt", " |ET|", pT); - cut("CutsObjects", "TauJetCharge", " |Charge|", integerCharge); - cut("CutsObjects", "TauJetNumTracks", " |NumTracks|", numTracks); - if(isolFrac != null) - cut("CutsObjects", "TauJetisolFrac", " isolFrac", isolFrac); - if(logLhRatio != null) - cut("CutsObjects", "TauJetlogLhRatio", " logLhRatio", logLhRatio); - - if (parameterStore.get("CutsObjects", "TauJetisTauString").getStatus()) - { - int cutSub = parameterStore.get("CutsObjects", "TauJetisTauString").getI(); - cutArrayEnum(isTauEnum, cutSub, "TauJet isTauString"); - } - } - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0){ - String output = getNameScreenName()+" index: " + index; - if(simpleOutput==1 || simpleOutput==3) - output+= "\n PT="+String.format("%.3f",pT[index])+" GeV\n "+ - AMath.ETA+" = "+String.format("%.3f",eta[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - if(simpleOutput==2 || simpleOutput==3) - output+= "\n Px="+String.format("%.3f",pT[index]*Math.cos(phi[index]))+" GeV "+ - "\n Py="+String.format("%.3f",pT[index]*Math.sin(phi[index]))+" GeV "+ - "\n Pz="+String.format("%.3f",pT[index]*Math.sinh(eta[index]))+" GeV "; - return output; - } - - String k = this.getStoreGateKey(); - String sgKey = k != null ? k : "n/a"; - StringBuffer msg = new StringBuffer(getNameScreenName()); - msg.append(" (id: " + id[index] + " index: " + index + ")"); - msg.append("\n storegate key: "); - msg.append(sgKey); - msg.append("\n PT = "); - msg.append(String.format("%.3f",pT[index])); - msg.append(" GeV\n P = "); - msg.append(String.format("%.3f",Math.abs(pT[index]/Math.cos(AMath.lambda(eta[index]))))); - msg.append(" GeV\n Charge = "); - msg.append(integerCharge[index]); - msg.append("\n "); - msg.append(AMath.ETA); - msg.append(" = "); - msg.append(String.format("%.3f",eta[index])); - msg.append("\n "); - msg.append(AMath.PHI); - msg.append(" = "); - msg.append(String.format("%.3f",Math.toDegrees(phi[index]))); - msg.append(AMath.DEGREES); - msg.append(" (" + String.format("%.3f",phi[index]) + " rad)"); - msg.append("\n numTracks = "); - msg.append(numTracks[index]); - - if (label != null) - { - msg.append("\n label = "); - msg.append(label[index]); - } - if (isolFrac != null) - { - msg.append("\n isolFrac = "); - msg.append(isolFrac[index]); - } - if (logLhRatio != null) - { - msg.append("\n logLhRatio = "); - msg.append(logLhRatio[index]); - } - - return msg.toString(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ATrackData.java b/graphics/AtlantisJava/src/atlantis/data/ATrackData.java deleted file mode 100644 index bc680fdd7b15fe415c6b2ec54a2681b1529748d4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ATrackData.java +++ /dev/null @@ -1,1389 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.canvas.ACanvas; -import atlantis.utils.AMath; -import atlantis.utils.AHashMap; -import atlantis.utils.AAtlantisException; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.AParameterUtilities; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.projection.AProjectionXZ; -import atlantis.graphics.AGraphics; -import atlantis.canvas.AWindow; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjection3D; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjectionLegoPlot; -import atlantis.projection.AProjectionPhi; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionYX; -import atlantis.projection.AProjectionYZ; -import atlantis.projection.AProjectionsManager; -import atlantis.utils.A4Vector; -import atlantis.utils.ALogger; - -/** - * - * base class for ASTrData - Simulated Track - * AInDetTrackData - Reconstructed Inner Detector Track - * AMuonTrackData - Reconstructed Muon Detector Track - * - */ -public abstract class ATrackData extends AData -{ - private static final ALogger logger = ALogger.getLogger(ATrackData.class); - - public static final int DRAW_HELIX = 0; - public static final int DRAW_POLYLINE = 1; - public static final int DRAW_SMOOTH = 2; - public static final int DRAW_NEWHELIX = 3; - public static final int ADD_HELIX_POINTS = 0; - - /** True if track residual is available */ - private boolean hasResidual = false; - - protected ATrackResidualData[] residuals = null; - - /** True if reconstructed track event data contains polyline information */ - protected boolean polylinedTrack = false; - - // these attributes are used to store polyline coordinates of tracks - protected float x[][] = null; - protected float y[][] = null; - protected float z[][] = null; - protected float rho[][] = null; - protected float phi[][] = null; - - protected int numHelix[] = null; - protected boolean cosmic[] = null; - - protected AHelix[] h = null; - - /** - * rhoVertex value - for STr provided in the event file, for reconstructed - * track (Track) it is calculated from first polyline coordinates. - * This value is tested in cutRhoVertexAfterInDetRadius() method. - */ - protected float[] rhoVertex = null; - - protected int[] index = null; - - protected float chi2[] = null; - protected int numDoF[] = null; - private int[] vertexType = null; - - // methods -------------------------------------------------------------- - - ATrackData(AHashMap p, AEvent e) throws AAtlantisException - { - super(p,e); - - String assocKey = getName() + getStoreGateKey(); - if (p.get("barcode") != null) - { - int[] barcode = p.getUnknownIntArray("barcode"); - AAssociation assoc = new AAssociation(assocKey, "STr", null, barcode, event); - event.getAssociationManager().add(assoc); - } - //Get vertex type numbers - vertexType = p.getUnsureIntArray("vertexType"); - // if residual information is provided, second check is a workaround for a JiveXML bug -- EJ - if(p.get("numTsos")!=null && p.get("tsosPullLoc1")!=null) - { - hasResidual = true; - residuals = new ATrackResidualData[numData]; - int[] numTsos = p.getIntArray("numTsos"); - float[] tsosPullLoc1 = p.getFloatArray("tsosPullLoc1"); - float[] tsosResLoc1 = p.getFloatArray("tsosResLoc1"); - float[] tsosPullLoc2 = p.getFloatArray("tsosPullLoc2"); - float[] tsosResLoc2 = p.getFloatArray("tsosResLoc2"); - String[] tsosDetType = p.getUnsureStringArray("tsosDetType"); - - int num = 0; - for(int i=0; i<numData; i++) - { - int numPoints = numTsos[i]; - float[] pullLoc1 = new float[numPoints]; - float[] resLoc1 = new float[numPoints]; - float[] pullLoc2 = new float[numPoints]; - float[] resLoc2 = new float[numPoints]; - String[] detType = null; - if(tsosDetType != null) - detType = new String[numPoints]; - - for(int j=0; j<numPoints; j++) - { - pullLoc1[j] = tsosPullLoc1[num]; - resLoc1[j] = tsosResLoc1[num]; - pullLoc2[j] = tsosPullLoc2[num]; - resLoc2[j] = tsosResLoc2[num]; - if(tsosDetType != null) - detType[j] = tsosDetType[num]; - num++; - } - residuals[i] = new ATrackResidualData(this, i, numPoints, pullLoc1, - resLoc1, pullLoc2, resLoc2, detType); - } - } - - // helix may come in different formats: - // * helix track from reconstructed track ? - if (p.get("d0") != null) - { - h = new AHelix[numData]; - - float[] d0 = p.getFloatArray("d0"); - float[] phi0 = p.getFloatArray("phi0"); - float[] tl = p.getFloatArray("cotTheta"); - float[] pt = p.getFloatArray("pt"); - float[] z0 = p.getFloatArray("z0"); - - // this patch is useful when reading old event files generated by - // some older version of JiveXML, in which cotTheta is set to inf by - // error when eta equals to 0 for IDScan Tracks - if ("TrigInDetTrack".equals((String) p.get("storeGateKey"))) - { - for(int i = 0; i < tl.length; i++) - { - if(Float.isInfinite(tl[i])) - tl[i] = 0.0f; - } - } // end of the patch - - // 2005-11-16 - numbers in event file in covMatrix too small, a lot - // of them were 0.00000 hence multiplied by 10000 in JiveXML and - // divided here by 10000. only Vertex fitter affected, didn't work - // before anyway, so numbers are divided for all events - if (p.get("covMatrix") != null) - { - float[][][] cov = new float[numData][5][5]; - float[] covMatrix = p.getFloatArray("covMatrix"); - // dividing numbers - for (int i = 0; i < covMatrix.length; i++) - { - covMatrix[i] = covMatrix[i] / 10000; - } - - int n = 0; - for (int i = 0; i < numData; i++) - { - for (int j = 0; j < 5; j++) - { - for (int k = 0; k < j + 1; k++) - { - cov[i][j][k] = covMatrix[n++]; - cov[i][k][j] = cov[i][j][k]; - } - } - - h[i] = new AHelix(d0[i], z0[i], (float) Math.toDegrees(phi0[i]), tl[i], pt[i], cov[i]); - } - } - else - { - for (int i = 0; i < numData; i++) { - h[i] = new AHelix(d0[i], z0[i], (float) Math.toDegrees(phi0[i]), tl[i], pt[i]); - } - } - } - // * helix track from simulated charged tracks ? - else if (p.get("rhoVertex") != null) - { - h = new AHelix[numData]; - - // STr - save rhoVertex value for tests - rhoVertex = p.getFloatArray("rhoVertex"); - float[] rhoEndVertex = p.getFloatArray("rhoEndVertex"); - float[] pt = p.getFloatArray("pt"); - float[] phi = p.getFloatArray("phi"); - float[] eta = p.getFloatArray("eta"); - float[] phiVertex = p.getFloatArray("phiVertex"); - float[] zVertex = p.getFloatArray("zVertex"); - // charge is calculated in ASTrData, based on code subtag - // information and pdg.xml data - int[] charge = p.getIntArray("charge"); - for (int i = 0; i < numData; i++) - { - //Create helix w/ end vertex information if rhoEndVertex is set - if ( rhoEndVertex[i] != 0.0 ) - h[i] = new AHelix(rhoVertex[i], phiVertex[i], zVertex[i], pt[i], - (float)Math.toDegrees(phi[i]), eta[i], charge[i], rhoEndVertex[i]); - //Otherwise create helix w/o end vertex information - else - h[i] = new AHelix(rhoVertex[i], phiVertex[i], zVertex[i], pt[i], - (float)Math.toDegrees(phi[i]), eta[i], charge[i] ); - } - } - - // if polyline information is provided for tracks - if(p.get("numPolyline") != null) - { - int[] numPolyline = p.getIntArray("numPolyline"); - - boolean hasPolyline = false; - for (int i=0; i<numData; i++) { - if (numPolyline[i] > 0) { - hasPolyline = true; - break; - } - } - - if (hasPolyline) { - polylinedTrack = true; - x = new float[numData][]; - y = new float[numData][]; - z = new float[numData][]; - rho = new float[numData][]; - phi = new float[numData][]; - rhoVertex = new float[numData]; - numHelix = new int[numData]; - cosmic = new boolean[numData]; - - float[] polyX = p.getFloatArray("polylineX"); - float[] polyY = p.getFloatArray("polylineY"); - float[] polyZ = p.getFloatArray("polylineZ"); - int num = 0; - - for(int i = 0; i < numData; ++i) - { - numHelix[i] = 0; - cosmic[i] = false; - - // Do some checks on the track, decide what drawing we enable/disable for it. - if (numPolyline[i] >= 2) { - int first = num; - int next = num+1; - - // Find the next different point on the track. - while (next < numPolyline[i]-1 && polyX[next]==polyX[first] && polyY[next]==polyY[first]) next++; - - // Determine what direction the track has in rho and z. - float rStart = (float)Math.sqrt(polyX[first]*polyX[first] + polyY[first]*polyY[first]); - float rDir = (float)Math.sqrt(polyX[next]*polyX[next] + polyY[next]*polyY[next]) - rStart; - float zDir = Math.abs(polyZ[next]) - Math.abs(polyZ[first]); - - // Now in order to extrapolate to the IP we the track to: - // - go radially outwards - // - go away from the IP in z - // - have perigee parameters - // - have its first polyline point some distance from the perigee - // - be an InDetTrack - if (rDir > 0 && zDir > 0 && h != null && h[i] != null && rStart-Math.abs(h[i].d0()) > 1 - && this instanceof AInDetTrackData) { - numHelix[i] = ADD_HELIX_POINTS; - } - - // Check if this is perhaps a cosmic. Cosmics are allowed - // to be drawn on both sides in the rho-z projection - if (rDir < 0) { - cosmic[i] = true; - } - } else if (h != null && h[i] != null && this instanceof AInDetTrackData) { - - // In case of a track with only perigee parameters, draw it also as a helix. - numHelix[i] = ADD_HELIX_POINTS; - } - - x[i] = new float[numPolyline[i]+numHelix[i]]; - y[i] = new float[numPolyline[i]+numHelix[i]]; - z[i] = new float[numPolyline[i]+numHelix[i]]; - rho[i] = new float[numPolyline[i]+numHelix[i]]; - phi[i] = new float[numPolyline[i]+numHelix[i]]; - - for(int j = 0; j < numPolyline[i]; ++j) - { - x[i][j+numHelix[i]] = polyX[num]; - y[i][j+numHelix[i]] = polyY[num]; - z[i][j+numHelix[i]] = polyZ[num]; - rho[i][j+numHelix[i]] = (float)Math.sqrt(polyX[num]*polyX[num]+polyY[num]*polyY[num]); - num++; - - if(j == 0) - { - // first coordinate of a track - calculate rhoVertex - rhoVertex[i] = (float) Math.sqrt( x[i][numHelix[i]] * x[i][numHelix[i]] + - y[i][numHelix[i]] * y[i][numHelix[i]] ); - } - } - - if (h != null && h[i] != null) { - h[i].setPoints(x[i], y[i], z[i], numPolyline[i]); - } - - // When perigee parameters are available we extend the track all the way down to the IP - if (numHelix[i] > 0) { - // Radius of curvature of this track in the magnetic field - double R = parameterStore.get("Event", "Curvature").getD() * Math.abs(h[i].pT()); - - // +1/-1 for a clockwise/anti-clockwise helix - double S = AMath.getSign(h[i].pT()); - - // Coordinates of the center point for the helix - double xC = (S * h[i].d0() - R) * Math.cos(Math.toRadians(h[i].phi0()) + S * Math.PI / 2.); - double yC = (S * h[i].d0() - R) * Math.sin(Math.toRadians(h[i].phi0()) + S * Math.PI / 2.); - - // Determine to what radius we have to draw this track based on its - // perigee parameters. When space points are available for the track - // we stop before the first space point and make a smooth connection. - // If no space points are available we draw all the way through the - // inner detector. Not any further though, because the track will stop - // curving when it leaves the magnetic field. - double Rmax; - if (numPolyline[i] > 0) { - Rmax = Math.min(parameterStore.get("RTr", "RadiusTr").getD(), - Math.abs(Math.sqrt(x[i][numHelix[i]]*x[i][numHelix[i]] - + y[i][numHelix[i]]*y[i][numHelix[i]]) - 1)); - } else { - Rmax = parameterStore.get("RTr", "RadiusTr").getD(); - } - - // Calculate the phi value at which our helix intersects the maximum - // radius determined above. We have one circle (detector) centered at - // the origin with radius Rmax. The other circle (helix) we imagine to - // be at x=d with a radius R. Now we can easily calculate the coordinates - // (xI,+/-yI) of the intersection points. The curving direction of the - // helix determines which value of yI we have to use. Finally, the phiMax - // we're interested in is the polar angle with respect to the center of the - // helix at x=d. Calculation is straightforward. By adding phi0+S*PI/2 - // (as we do below) this solution is also valid for helices centered - // around y!=0. - double d = Math.sqrt(xC * xC + yC * yC); - double xI = (Rmax * Rmax - R * R + d * d) / (2 * d); - double yI = Math.sqrt(Rmax * Rmax - xI * xI); - double phiMax = Math.atan2(S * yI, d - xI); - - // This spreads the number of helix points evenly across the part of the - // helix we're going to draw - double dphi = phiMax / numHelix[i]; - - for (int j=0; j<numHelix[i]; j++) { - // Points on the helix in user coordinates - x[i][j] = (float) (xC + R * Math.cos(Math.toRadians(h[i].phi0()) + S * Math.PI/2. - j * dphi)); - y[i][j] = (float) (yC + R * Math.sin(Math.toRadians(h[i].phi0()) + S * Math.PI/2. - j * dphi)); - - // In R-Z the track is just a straight line - rho[i][j] = (float) Math.sqrt(x[i][j]*x[i][j] + y[i][j]*y[i][j]); - z[i][j] = (float) (h[i].z0() + h[i].cotanTheta() * (rho[i][j] - h[i].d0())); - } - } - - for (int j=0; j<numPolyline[i]+numHelix[i]; j++) { - phi[i][j] = (float)Math.atan2(y[i][j], x[i][j]); - - if (j>0 && Math.abs(phi[i][j-1]-phi[i][j]) > Math.PI) { - - // Don't let phi wrap around - if (phi[i][j] > phi[i][j-1]) { - phi[i][j] -= 2*Math.PI; - } else { - phi[i][j] += 2*Math.PI; - } - } - } - } - } - } // if(p.get("numPolyline") - - if (h != null) - { - double[] phi = new double[numData]; - for (int i = 0; i < numData; i++) - phi[i] = h[i].phi0(); - index = indexBy(phi); - } - else if(x != null && y != null) - { - double[] phi = new double[numData]; - for(int i = 0; i < numData; i++) - { - // if number of polylines for a track is 0 - Atlantis used - // to crash here with IndexOutOfBoundException - // check to avoid crashes with old events, from some point - // JiveXML doesn't output tracks with number of polylines - // coordinates less then 2 - if(x[i].length > 0 && y[i].length > 0) - { - phi[i] = Math.toDegrees(Math.atan2(y[i][0], x[i][0])); - } - else - { - String m = getName() + ":" + getStoreGateKey() + - " datatype rejected\n" + - "(no polyline coordinates)."; - throw new AAtlantisException(m, false); // non fatal - } - } - index = indexBy(phi); - } - - if (p.get("chi2") != null) chi2 = p.getFloatArray("chi2"); - if (p.get("numDoF") != null) numDoF = p.getIntArray("numDoF"); - } // ATrackData() ------------------------------------------------------- - - - public float[][] getX() - { - return x; - } - - public float[][] getY() - { - return y; - } - - public float[][] getZ() - { - return z; - } - - public float[][] getRho() - { - return rho; - } - - public float[][] getPhi() - { - return phi; - } - - public boolean getResidualStatus() - { - return hasResidual; - } - - public ATrackResidualData getTrackResidual(int index) - { - return residuals[index]; - } - - // moved from the former iPatData class where it was without the condition - protected void calculateRhoPhi() - { - if(!polylinedTrack) { - super.calculateRhoPhi(); - } - } // calculateRhoPhi() -------------------------------------------------- - - - - protected void applyCuts() - { - cutIndex(); - if (h != null) - { - cut("CutsInDet", "z0-zVtx", " |z0-zVtx|", getZ0Primary()); - cut("CutsInDet", "z0", " |z0|", getZ0()); - cut("CutsInDet", "Pt", " |Pt|", getPt()); - cut("CutsInDet", "d0", " |d0|", getD0()); - cut("CutsInDet", "d0Loose", " |d0Loose|", getD0()); - } - cutPhi(); - cutEta(); - cutNextInDrawList(); - cutReconstructedVertex(); - } // applyCuts() -------------------------------------------------------- - - - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+ - ((h!=null)?h[index].toString():""); - - - String msg = getNameScreenName() + " (id: " + id[index] + " index: " + index + ")"; - msg += "\n storegate key: "; - msg += (storeGateKey == null ? "n/a" : storeGateKey); - if (h != null) - msg += h[index].toString(); - if (chi2 != null && numDoF != null) - msg += "\n chi2/numDoF = " + chi2[index]/numDoF[index]; - return msg; - - } // getHitInfo() ------------------------------------------------------- - - - // all get**User() methods which are only called when tracks are drawn - // as polylines - protected ACoord getYXUser() - { - makeDrawList(); - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int numPoints = x[list].length; - hv[0][i] = new double[numPoints]; - hv[1][i] = new double[numPoints]; - for(int j = 0; j < numPoints; j++) - { - hv[0][i][j] = x[list][j]; - hv[1][i][j] = y[list][j]; - } - index[i] = list; - } - - if (parameterStore.get(PARAMETER_GROUP, "DrawnAs").getI() == DRAW_SMOOTH) - return new ACoord(hv, index, this, ACoord.SMOOTH_POLYLINES); - else - return new ACoord(hv, index, this, ACoord.POLYLINES); - - } // getYXUser() -------------------------------------------------------- - - - - protected ACoord getFRUser() - { - makeDrawList(); - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int numPoints = x[list].length; - int skip = 0; - - // Skip points with very small R, phi changes rapidly here - for (skip=0; skip<numPoints; skip++) - if (rho[list][skip] > 2.) break; - - hv[0][i] = new double[numPoints-skip]; - hv[1][i] = new double[numPoints-skip]; - - double phiStart = 0.; - if(numPoints > 0) phiStart = phi[list][0]; - for(int j = skip; j < numPoints; j++) - { - double phiTemp = phi[list][j]; - if(phiTemp - phiStart > Math.PI) phiTemp -= AMath.TWO_PI; - if(phiTemp - phiStart < -Math.PI) phiTemp += AMath.TWO_PI; - - hv[0][i][j-skip] = rho[list][j]; - hv[1][i][j-skip] = Math.toDegrees(phiTemp); - } - index[i] = list; - } - - if (parameterStore.get(PARAMETER_GROUP, "DrawnAs").getI() == DRAW_SMOOTH) - return new ACoord(hv, index, this, ACoord.SMOOTH_POLYLINES).includePhiWrapAround("FR"); - else - return new ACoord(hv, index, this, ACoord.POLYLINES).includePhiWrapAround("FR"); - - } // getFRUser() -------------------------------------------------------- - - - - protected ACoord getFZUser() - { - makeDrawList(); - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int numPoints = x[list].length; - int skip = 0; - - // Skip points with very small R, phi changes rapidly here - for (skip=0; skip<numPoints; skip++) - if (rho[list][skip] > 2.) break; - - hv[0][i] = new double[numPoints-skip]; - hv[1][i] = new double[numPoints-skip]; - // treat phi wraparound - double phiStart = 0.; - if(numPoints > 0) phiStart = phi[list][0]; - for(int j = skip; j < numPoints; j++) - { - hv[0][i][j-skip] = z[list][j]; - double phiTemp = phi[list][j]; - if(phiTemp - phiStart > Math.PI) phiTemp -= AMath.TWO_PI; - if(phiTemp - phiStart < -Math.PI) phiTemp += AMath.TWO_PI; - hv[1][i][j-skip] = Math.toDegrees(phiTemp); - } - index[i] = list; - } - - if (parameterStore.get(PARAMETER_GROUP, "DrawnAs").getI() == DRAW_SMOOTH) - return new ACoord(hv, index, this, ACoord.SMOOTH_POLYLINES).includePhiWrapAround("FZ"); - else - return new ACoord(hv, index, this, ACoord.POLYLINES).includePhiWrapAround("FZ"); - - } // getFZUser() -------------------------------------------------------- - - - - protected ACoord getRZUser() - { - // not quite correct need to split tracks crossing phi boundary - makeDrawList(); - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int numPoints = rho[list].length; - hv[0][i] = new double[numPoints]; - hv[1][i] = new double[numPoints]; - - if (numPoints > 0) { - int sign = AParameterUtilities.getRhoSign(x[list][numPoints-1], y[list][numPoints-1]); - for(int j = 0; j < numPoints; j++) - { - if (cosmic != null && cosmic[i]) { - sign = AParameterUtilities.getRhoSign(x[list][j], y[list][j]); - } - hv[0][i][j] = z[list][j]; - hv[1][i][j] = rho[list][j] * sign; - } - } - index[i] = list; - } - - if (parameterStore.get(PARAMETER_GROUP, "DrawnAs").getI() == DRAW_SMOOTH) - return new ACoord(hv, index, this, ACoord.SMOOTH_POLYLINES); - else - return new ACoord(hv, index, this, ACoord.POLYLINES); - - } // getRZUser() -------------------------------------------------------- - - - - protected ACoord getXZUser() - { - makeDrawList(); - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - double phi0 = Math.toRadians(AProjectionXZ.getPhi()); - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int numPoints = rho[list].length; - hv[0][i] = new double[numPoints]; - hv[1][i] = new double[numPoints]; - for(int j = 0; j < numPoints; j++) - { - hv[0][i][j] = z[list][j]; - hv[1][i][j] = rho[list][j] * Math.cos(phi[list][j] - phi0); - } - index[i] = list; - } - - if (parameterStore.get(PARAMETER_GROUP, "DrawnAs").getI() == DRAW_SMOOTH) - return new ACoord(hv, index, this, ACoord.SMOOTH_POLYLINES); - else - return new ACoord(hv, index, this, ACoord.POLYLINES); - - } // getXZUser() -------------------------------------------------------- - - protected ACoord getYZUser() - { - makeDrawList(); - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - double phi0 = Math.toRadians(AProjectionXZ.getPhi()); - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - int numPoints = rho[list].length; - hv[0][i] = new double[numPoints]; - hv[1][i] = new double[numPoints]; - for(int j = 0; j < numPoints; j++) - { - hv[0][i][j] = z[list][j]; - hv[1][i][j] = rho[list][j] * Math.sin(phi[list][j] - phi0); - } - index[i] = list; - } - - if (parameterStore.get(PARAMETER_GROUP, "DrawnAs").getI() == DRAW_SMOOTH) - return new ACoord(hv, index, this, ACoord.SMOOTH_POLYLINES); - else - return new ACoord(hv, index, this, ACoord.POLYLINES); - - } // getYZUser() -------------------------------------------------------- - - - - public void draw(AWindow window, AGraphics ag, AProjection2D projection) - { - if(h != null && (projection instanceof AProjectionVP || projection instanceof AProjection3D)) - { - // in VPlot only helices are drawn, so try to draw tracks as helices - // in VPlot by default ignoring Track->DrawAs option for VPlot - drawHelix(window, ag, projection); - } - else - { - AParameter drawPar = parameterStore.get(PARAMETER_GROUP, "DrawnAs"); - int drawnAs = drawPar != null ? drawPar.getI() : DRAW_HELIX; - if (polylinedTrack && (h == null || drawnAs == DRAW_POLYLINE || drawnAs == DRAW_SMOOTH)) - { - // draw as polyline - ag.draw(window.calculateDisplay(getUser(projection))); - } - else if (h != null) - { - // draw as helix - drawHelix(window, ag, projection); - } - } - - } // draw() ------------------------------------------------------------- - - protected void cutRhoVertexAfterInDetRadius() - { - int num = 0; - int wrong = 0; - int list = 0; - double rho = 108; // 1.08m - double parRhoTr = parameterStore.get("RTr", "RadiusTr").getD(); - for(int i = 0; i < numDraw; i++) - { - list = listdl[i]; - if(this.rhoVertex[list] > Math.min(rho, parRhoTr)) - { - wrong++; - } - else - { - // include into drawlist - listdl[num++] = list; - } - } - - if(wrong > 0) - { - logger.debug("AHelix.cutRhoVertexAfterInDetRadius()"); - String key = this.getStoreGateKey(); - key = key != null ? ":" + key : ""; - logger.debug(" " + numDraw + " " + this.getName() + key + - " before test, " + wrong + " removed\n"); - } - numDraw = num; - } // cutRhoVertexAfterInDetRadius() ------------------------------------- - - protected int internalColor() - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - switch (colorFunction) - { - case 0: - colorByConstant(); - break; - case 1: - colorByIndex(index); - break; - case 2: - colorBy(getPt()); - break; - case 3: - colorByCollection(); - break; - case 4: - colorBy("STr"); - break; - case 5: - colorBy(getRVx()); - break; - case 6: - colorBy(getJets()); - break; - case 7: // by objects - colorByObjects(); - break; - } - - return 7; - } - - public int[] getDrawList() - { - int[] temp = new int[numDraw]; - System.arraycopy(listdl, 0, temp, 0, numDraw); - return temp; - } - - protected void cutNextInDrawList() - { - AParameter nextTrkPar = parameterStore.get(PARAMETER_GROUP, "NextTrack"); - if(!nextTrkPar.getStatus()) - { - return; - } - if(numDraw == 0) - { - return; - } - - int nextTrk = nextTrkPar.getI() % numData; - int nextTrkIndex = nextTrk; - boolean hasFound = false; - while (!hasFound) - { - for (int i=0; i<numDraw; ++i) - { - if(listdl[i] == nextTrk) - { - nextTrkIndex = nextTrk; - hasFound = true; - } - } - if(!hasFound) - nextTrk = (nextTrk + 1) % numData; - } - nextTrkPar.setI(nextTrkIndex); - numDraw = 1; - listdl[0] = nextTrkIndex; - } - - protected void cutPhi() - { - AParameter par = parameterStore.get("CutsATLAS", "CutPhi"); - boolean usePhiCut = par.getStatus(); - - if (usePhiCut) - { - // use degrees for tracks - double phiCut = par.getD(); - double phiMid = AMath.nearestPhiDegrees(parameterStore.get("CutsATLAS", "PhiMiddle").getD()); - // use vplot as projection - AProjection2D projection = (AProjection2D) AProjectionsManager.getProjection("VP"); - - int num = 0; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - ADHelix dH = new ADHelix(h[list]); - double s1 = dH.getAStart(); - double s2 = dH.getAEnd(); - s1 = dH.intersectWithRadialCylinder(projection.getMinRho(), s1, s2); - double sEnd = dH.intersectWithCylinder(true, AProjectionVP.getRhoVPlot(), true, AProjectionVP.getZVPlot()); - s2 = Math.max(Math.min(s2, sEnd), s1); - - double phiDiffStart = Math.abs(AMath.nearestPhiDegrees(dH.getPhi(s1), phiMid) - phiMid); - double phiDiffEnd = Math.abs(AMath.nearestPhiDegrees(dH.getPhi(s2), phiMid) - phiMid); - double phiDiffMiddle = Math.abs(AMath.nearestPhiDegrees(dH.getPhi((s1 + s2) / 2), phiMid) - phiMid); - // treats wrap around - int numPointsInside = 0; - - if (phiDiffStart < phiCut) - numPointsInside++; - if (phiDiffMiddle < phiCut) - numPointsInside++; - if (phiDiffEnd < phiCut) - numPointsInside++; - if (numPointsInside > 1) - listdl[num++] = list; - } - numDraw = num; - } - } - - /** - * Cut tracks if connected/unconnected to reconstructed vertices. - */ - protected void cutReconstructedVertex() - { - int cutOption = parameterStore.get("CutsObjects", "RTrsByRVtx").getI(); - cutByAssociationTo( "RVx", getReconstructedTracks(), cutOption); - } - - - protected void cutEta() - { - AParameter par = parameterStore.get("CutsATLAS", "CutEta"); - - if (par.getStatus()) - { - // use vplot as projection - AProjection2D projection = (AProjection2D) AProjectionsManager.getProjection("VP"); - - double etaCut = par.getD(); - double etaMid = parameterStore.get("CutsATLAS", "EtaMiddle").getD(); - double etaC1 = etaMid - etaCut; - double etaC2 = etaMid + etaCut; - int num = 0; - for (int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - ADHelix dH = new ADHelix(h[list]); - double s1 = dH.getAStart(); - double s2 = dH.getAEnd(); - s1 = dH.intersectWithRadialCylinder(projection.getMinRho(), s1, s2); - double sEnd = dH.intersectWithCylinder(true, AProjectionVP.getRhoVPlot(), true, AProjectionVP.getZVPlot()); - s2 = Math.max(Math.min(s2, sEnd), s1); - double[] etaPoints = new double[] { dH.getEta(s1), dH.getEta((s1 + s2) / 2), dH.getEta(s2) }; - - int numPointsInside = 0; - for (int j = 0; j < etaPoints.length; ++j) - if (etaC1 < etaPoints[j] && etaPoints[j] < etaC2) - numPointsInside++; - if (numPointsInside > 1) - listdl[num++] = list; - } - numDraw = num; - } - } - - // does not work correctly if primary vertex is displaced in YX plane - private float[] getZ0Primary() - { - double[] pVtx = event.getPrimaryVertex(); - float[] temp = new float[numData]; - double zVertex = pVtx[2]; - for (int i = 0; i < numDraw; i++) - temp[listdl[i]] = (float) (h[listdl[i]].z0() - zVertex); - return temp; - } - - private float[] getZ0() - { - float[] temp = new float[numData]; - for (int i = 0; i < numDraw; i++) - temp[listdl[i]] = (float) h[listdl[i]].z0(); - return temp; - } - - protected float[] getPt() - { - float[] temp = new float[numData]; - for (int i = 0; i < numDraw; i++) - temp[listdl[i]] = (float) h[listdl[i]].pT(); - return temp; - } - - - // d0 is calculated w.r.t. to XY position of the primary vertex - private float[] getD0() - { - double[] pVtx = event.getPrimaryVertex(); - float[] temp = new float[numData]; - for (int i = 0; i < numDraw; i++) - { - double phi0 = Math.toRadians(h[listdl[i]].phi0()); - - temp[listdl[i]] = (float) (-h[listdl[i]].d0() + pVtx[1] * Math.cos(phi0) - pVtx[0] * Math.sin(phi0)); - - } - return temp; - } - - - // give back Drawable helices - public ADHelix[] getHelices() - { - makeDrawList(); - ADHelix[] tempList = new ADHelix[numDraw]; - - for (int i = 0; i < numDraw; i++) - if (h != null && h[listdl[i]] != null) - { - tempList[i] = new ADHelix(h[listdl[i]]); - if (tempList[i].getAStart() == tempList[i].getAEnd()) - { - tempList[i] = null; - } - } - else - tempList[i] = null; - return tempList; - } - - // used by vertex package when changing the position on the helix from which - // to start drawing - public AHelix getModifiableHelix(int i) - { - if (h != null) - return h[i]; - else - return null; - } - - // info on tracks contained in vplot rubberband - public String getVPHitInfo() - { - makeDrawList(); - if (numDraw == 0) - return ""; - double sumP = 0.; - double sumPt = 0.; - - for (int i = 0; i < numDraw; ++i) - { - sumPt += Math.abs(h[listdl[i]].pT()); - sumP += AMath.getPFromPttL(h[listdl[i]].pT(), h[listdl[i]].cotanTheta()); - } - - String msg = numDraw + " " + getFullName(); - msg += " sum(PT) = " + String.format("%.1f",sumPt) + " sum(P) = " + String.format("%.1f",sumP); - return msg; - } - - public A4Vector get4Vector(int num, int[] list) - { - A4Vector sum = new A4Vector(); - for (int i = 0; i < num; ++i) { - if (h == null || h[list[i]] == null) continue; - // Use the pion mass (~140 MeV) here - sum.add(new A4Vector(h[list[i]].p(), 0.14)); - } - return sum; - } - - public A4Vector get4Vector(int num, int[] list, double mass) - { - A4Vector sum = new A4Vector(); - for (int i = 0; i < num; ++i) { - if (h == null || h[list[i]] == null) continue; - sum.add(new A4Vector(h[list[i]].p(), mass)); - - - } - return sum; - } - - public void zoomAroundTracks() - { - AWindow window = ACanvas.getCanvas().getCurrentWindow(); - AProjection projection = window.getProjection(); - if (projection instanceof AProjectionLegoPlot) - { - AOutput.append("Zoom Next Track unavailable for LegoPlot\n", ALogInterface.NORMAL); - } - else if (projection instanceof AProjection2D) - { - ACoord user; - if (projection instanceof AProjectionVP) - user = window.calculateUser(getVPDisplayHelices(window, (AProjection2D) projection)); - else if (polylinedTrack) - user = getUser((AProjection2D) projection); - else - user = window.calculateUser(getDisplayHelices(window, (AProjection2D) projection)); - double[] min = new double[2]; - double[] max = new double[2]; - min[0] = min[1] = 100000.; - max[0] = max[1] = -100000.; - for (int i = 0; i < 2; ++i) - for (int j = 0; j < user.hv[i].length; ++j) - for (int k = 0; k < user.hv[i][j].length; ++k) - { - if (user.hv[i][j][k] < min[i]) - min[i] = user.hv[i][j][k]; - if (user.hv[i][j][k] > max[i]) - max[i] = user.hv[i][j][k]; - } - // increase by 10% to improve appearence - for (int i = 0; i < 2; ++i) - { - double diff = (max[i] - min[i]) / 2.; - double middle = (max[i] + min[i]) / 2.; - if (diff > 0.) - { - max[i] = middle + 1.1 * diff; - min[i] = middle - 1.1 * diff; - } - } - // ensure entire trt hits included - if (projection instanceof AProjectionPhi) - { - min[1] -= 0.5; - max[1] += 0.5; - } - - if (max[0] - min[0] > 0 && max[1] - min[1] > 0) - { - window.setUserCorners(min[0], max[0], min[1], max[1]); - } - } - } - - public void drawHelix(AWindow window, AGraphics ag, AProjection2D projection) - { - if (projection instanceof AProjectionVP) - { - // phi wrap around is done in user coordinates, so we convert to user coordinates, - // do the phi wrap around and convert back to display coordinates - ag.draw(window.calculateDisplay(window.calculateUser( - getVPDisplayHelices(window, projection)).includePhiWrapAround(projection.getName()) - )); - } - else if (projection instanceof AProjectionRZ) - { - ag.draw(getRZDisplayHelices(window, projection)); - } - else if (projection instanceof AProjectionPhi) - { - // phi wrap around in user coordinates, see above - ag.draw(window.calculateDisplay(window.calculateUser( - getDisplayHelices(window, projection)).includePhiWrapAround(projection.getName()) - )); - - } - else - { - ag.draw(getDisplayHelices(window, projection)); - } - } - - // treat discontinuity when RZ sign changes crossing the phi boundary - private ACoord getRZDisplayHelices(AWindow window, AProjection2D projection) - { - ACoord display = getDisplayHelices(window, projection); - ACoord user = projection.inverseNonLinearTransform(window.calculateUser(display)); - - double[][] rho = user.hv[1]; - - int extraTrackSegments = 0; - - for (int i = 0; i < rho.length; i++) - for (int j = 1; j < rho[i].length - 2; j++) - if (rho[i][j] * rho[i][j + 1] < 0. && Math.abs(rho[i][j]) > 2.) - extraTrackSegments++; - - double hv[][][] = new double[2][rho.length + extraTrackSegments][]; - int index[] = new int[rho.length + extraTrackSegments]; - - extraTrackSegments = 0; - for (int i = 0; i < rho.length; i++) - { - int startOfSegment = 0; - int endOfLastSegment = rho[i].length - 1; - - for (int j = 0; j < rho[i].length - 1; j++) - if (rho[i][j] * rho[i][j + 1] < 0. && Math.abs(rho[i][j]) > 2.) - { - if (j == 0) - { - if (Math.abs(rho[i][0]) > 1.) - startOfSegment = 1; - } - else if (j == rho[i].length - 2) - endOfLastSegment = rho[i].length - 2; - else - { - for (int k = 0; k < hv.length; ++k) - { - hv[k][i + extraTrackSegments] = new double[j + 1 - startOfSegment]; - System.arraycopy(user.hv[k][i], startOfSegment, hv[k][i + extraTrackSegments], 0, j + 1 - startOfSegment); - } - index[i + extraTrackSegments] = user.index[i]; - startOfSegment = j + 1; - extraTrackSegments++; - } - } - if (startOfSegment == 0 && endOfLastSegment == rho[i].length - 1) - { - for (int k = 0; k < hv.length; ++k) - hv[k][i + extraTrackSegments] = user.hv[k][i]; - index[i + extraTrackSegments] = user.index[i]; - } - else - { - for (int k = 0; k < hv.length; ++k) - { - hv[k][i + extraTrackSegments] = new double[endOfLastSegment - startOfSegment + 1]; - System.arraycopy(user.hv[k][i], startOfSegment, hv[k][i + extraTrackSegments], 0, endOfLastSegment - startOfSegment + 1); - } - index[i + extraTrackSegments] = user.index[i]; - } - } - - rho = hv[1]; - for (int i = 0; i < rho.length; i++) - { - int j = 0; - - while (j < rho[i].length && Math.abs(rho[i][j]) < 2.) - j++; - if (j < rho[i].length) - if (rho[i][j] > 0.) - for (int k = 0; k < j; k++) - rho[i][k] = Math.abs(rho[i][k]); - else - for (int k = 0; k < j; k++) - rho[i][k] = -Math.abs(rho[i][k]); - } - - return window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv, index, this, ACoord.POLYLINES))); - } - - protected ACoord getDisplayHelices(AWindow window, AProjection2D projection) - { - AParameter drawPar = parameterStore.get(PARAMETER_GROUP, "DrawnAs"); - int drawnAs = drawPar != null ? drawPar.getI() : DRAW_HELIX; - - if (drawnAs == DRAW_HELIX) { - ADHelix[] dhelix = getHelices(); - double[][][] hv = new double[2][dhelix.length][0]; - int[] index = getDrawList(); - - for (int j = 0; j < dhelix.length; ++j) { - if (dhelix[j] != null) { - double s1 = dhelix[j].getAStart(); // Get start phi-angle - double s2 = dhelix[j].getAEnd(); // Get end phi-angle - - // s1 becomes phi at the intersection of the minimal radius - s1 = dhelix[j].intersectWithRadialCylinder(projection.getMinRho(), s1, s2); // minrho = 0 - // avoid drawing discontinuous in phi - dhelix[j].setPhiStart(s1, s2); - // returning a set of points to be drawn for this helix - ACoord pointsOnHelix = dhelix[j].drawHelix(window, projection, s1, s2); - - hv[0][j] = pointsOnHelix.hv[0][0]; - hv[1][j] = pointsOnHelix.hv[1][0]; - } - } - return new ACoord(hv, index, this, ACoord.POLYLINES); - } else { // DRAW_NEW_HELIX - - // V-plot needs some additional settings - boolean showS3D = parameterStore.get("Data", "S3D").getStatus(); - AParameter shortV = parameterStore.get("VP", "ShortV"); - - makeDrawList(); - double[][][] hv = new double[2][numDraw][]; - int[] index = new int[numDraw]; - - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - index[i] = j; - - if (projection instanceof AProjectionYX) { - - hv[0][i] = h[j].getX(h[j].getAlphaMin(), h[j].getAlphaMax()); - hv[1][i] = h[j].getY(h[j].getAlphaMin(), h[j].getAlphaMax()); - - } else if (projection instanceof AProjectionRZ - || projection instanceof AProjectionXZ - || projection instanceof AProjectionYZ) { - - double alphaMin = h[j].getAlphaCylinder(projection.getMinRho(), AHelix.TRACKER_LENGTH); - hv[0][i] = h[j].getZ(alphaMin, h[j].getAlphaMax()); - hv[1][i] = h[j].getRho(alphaMin, h[j].getAlphaMax(), true); - - if (projection instanceof AProjectionXZ || projection instanceof AProjectionYZ) { - double phiC = AProjectionXZ.getPhi(); - if (projection instanceof AProjectionYZ) phiC += 90; - - double phi[] = h[j].getPhi(alphaMin, h[j].getAlphaMax(), false); - for (int k=0; k<hv[1][i].length; k++) { - hv[1][i][k] = Math.abs(hv[1][i][k]) * Math.cos(Math.toRadians(phi[k] - phiC)); - } - } - } else if (projection instanceof AProjectionFR) { - - double alphaMin = h[j].getAlphaCylinder(projection.getMinRho(), AHelix.TRACKER_LENGTH); - hv[0][i] = h[j].getRho(alphaMin, h[j].getAlphaMax(), false); - hv[1][i] = h[j].getPhi(alphaMin, h[j].getAlphaMax(), false); - - } else if (projection instanceof AProjectionFZ) { - - double alphaMin = h[j].getAlphaCylinder(projection.getMinRho(), AHelix.TRACKER_LENGTH); - hv[0][i] = h[j].getZ(alphaMin, h[j].getAlphaMax()); - hv[1][i] = h[j].getPhi(alphaMin, h[j].getAlphaMax(), false); - - } else if (projection instanceof AProjectionVP) { - - double alphaMin = h[j].getAlphaCylinder(projection.getMinRho(), AHelix.TRACKER_LENGTH); - double alphaMax = h[j].getAlphaExtrapolated(AProjectionVP.getRhoVPlot(), AHelix.TRACKER_LENGTH); - if (shortV.getStatus() && !showS3D) { - alphaMin = alphaMax - shortV.getD() * (alphaMax - alphaMin); - } - - hv[0][i] = h[j].getEta(alphaMin, alphaMax); - hv[1][i] = h[j].getPhi(alphaMin, alphaMax, true); - - } - } - - return window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv, index, this, ACoord.POLYLINES))); - } - } - - // a track has two arms in the VPlot - protected ACoord getVPDisplayHelices(AWindow window, AProjection2D projection) - { - boolean drawApex = parameterStore.get("VP", "DrawApex").getStatus(); - AParameter drawPar = parameterStore.get(PARAMETER_GROUP, "DrawnAs"); - int drawnAs = drawPar != null ? drawPar.getI() : DRAW_HELIX; - - if (drawnAs == DRAW_HELIX) { - ADHelix[] dhelix = getHelices(); - int size = 2 * dhelix.length; - if (drawApex) - size = 3 * dhelix.length; - double[][][] hv = new double[2][size][0]; - int[] index = new int[size]; - int[] indexIn = getDrawList(); - int num = 0; - - for (int j = 0; j < dhelix.length; ++j) - if (dhelix[j] != null) - { - double s1 = dhelix[j].getAStart(); - double s2 = dhelix[j].getAEnd(); - - int mode = parameterStore.get("VP", "Mode").getI(); - if(mode <= AProjectionVP.MODE_HCAL_LAYER_3 - && mode >= AProjectionVP.MODE_ECAL_LAYER_0) { - s2 = 179; - } - - s1 = dhelix[j].intersectWithRadialCylinder(projection.getMinRho(), s1, s2); - double sEnd = dhelix[j].intersectWithCylinder(true, AProjectionVP.getRhoVPlot(), true, AProjectionVP.getZVPlot()); - - s2 = Math.max(Math.min(s2, sEnd), s1); - // if the whole helix is to be drawn (which are unusual - // helices, shorten it a little to avoid wraparound problems - if (s1 == 0. && s2 == 180.) - s2 = 179.; - if (parameterStore.get("VP", "ShortV").getStatus() && !parameterStore.get("Data", "S3D").getStatus()) - s1 = s2 - parameterStore.get("VP", "ShortV").getD() * (s2 - s1); - if (s2 > s1) - { - int signMin = -1; - int signMax = 1; - double h = 0; - double v = 0; - for (int sign = signMin; sign <= signMax; sign += 2) - { - // ugly must change structure at some point - AProjectionVP.sign = sign; - ACoord pointsOnHelix = dhelix[j].drawHelix(window, projection, s1, s2); - hv[0][num] = pointsOnHelix.hv[0][0]; - hv[1][num] = pointsOnHelix.hv[1][0]; - index[num] = indexIn[j]; - h = hv[0][num][hv[0][num].length - 1]; - v = hv[1][num][hv[0][num].length - 1]; - num++; - } - if (drawApex) - { - int a = 3; - int b = 7; - hv[0][num] = new double[] { h - a, h + a, h, h, h - a, h + a }; - hv[1][num] = new double[] { v - b, v - b, v - b, v + b, v + b, v + b }; - index[num] = indexIn[j]; - num++; - } - } - } - return new ACoord(hv, index, this, ACoord.POLYLINES); - } else { // DRAW_NEW_HELIX is handled by the normal method - return getDisplayHelices(window, projection); - } - } -} - diff --git a/graphics/AtlantisJava/src/atlantis/data/ATrackResidualData.java b/graphics/AtlantisJava/src/atlantis/data/ATrackResidualData.java deleted file mode 100644 index 6f630c066367a7370eac720adc3b64dff3a5b372..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ATrackResidualData.java +++ /dev/null @@ -1,323 +0,0 @@ -package atlantis.data; - -import java.awt.Color; -import java.awt.Point; -import java.awt.geom.Point2D; - -import atlantis.canvas.AWindow; -import atlantis.globals.AGlobals; -import atlantis.graphics.AGraphics; -import atlantis.graphics.APickingGraphics2D; -import atlantis.graphics.colormap.AColorMap; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjectionTrackResidual; - -/** - * Contains residual data for a single track - * - * @author Qiang Lu - */ -public class ATrackResidualData -{ - public static String PULL_X = "P_X"; - public static String RESIDUAL_X = "R_X"; - - private ATrackData track; - private int trackIndex; - private String showType = RESIDUAL_X; - private int numPoints; - private float[] pullLoc1; - private float[] resLoc1; - private float[] pullLoc2; - private float[] resLoc2; - private String[] detType; - - private double logMagnitudeMin; - private int pickedIndex; - private byte pickedGroup; // 1 for loc1/pull1, 2 for loc2/pull2 - private double minDiff; - - private static APar parameterStore = APar.instance(); - - /** - * @param theTrack track collection to which this residual belongs to - * @param trackIndex index of the associated track - * @param points number of residuals points - * @param pullLoc1 residuals pull data 1 - * @param resLoc1 residuals data 1 - * @param pullLoc2 residuals pull data 2 (only for Pixel) - * @param resLoc2 residuals data 2 (only for Pixel) - * @param detType detector type of each residual - */ - ATrackResidualData(ATrackData track, int trackIndex, int points, - float[] pullLoc1, float[] resLoc1, float[] pullLoc2, float[] resLoc2, - String[] detType) - { - this.track = track; - this.trackIndex = trackIndex; - numPoints = points; - this.pullLoc1 = pullLoc1; - this.resLoc1 = resLoc1; - this.pullLoc2 = pullLoc2; - this.resLoc2 = resLoc2; - this.detType = detType; - } - - /** - * @return Returns the number of residual points. - */ - public int getNumPoints() - { - return numPoints; - } - - public float[] getPullLoc1() - { - return pullLoc1; - } - - public float[] getResLoc1() - { - return resLoc1; - } - - public float[] getPullLoc2() - { - return pullLoc2; - } - - public float[] getResLoc2() - { - return resLoc2; - } - - public void setLogMagnitudeMin(double logMagnitudeMin) - { - this.logMagnitudeMin = logMagnitudeMin; - } - - public double getLogMagnitudeMin() - { - return logMagnitudeMin; - } - - public void draw(AWindow window, AGraphics ag, AProjectionTrackResidual projection) - { - Color[] colorMap=AColorMap.getColors(); - - // draw horizontal axis through 0 - double x1 = 0., y1 = 0., x2 = projection.getXLength(), y2 = 0.0; - Point2D.Double from = window.calculateDisplay(x1, y1); - Point2D.Double to = window.calculateDisplay(x2, y2); - ag.setColor(colorMap[AColorMap.BL]); - ag.drawLine(from.x, from.y, to.x, to.y); - - float[] temp1; - AParameter showExtraPar = parameterStore.get("TrackResidual", "ShowExtra"); - if(projection.getResidualType().equals(RESIDUAL_X)) - { - showType = RESIDUAL_X; - temp1 = this.resLoc1; - float[] temp2 = this.pullLoc1; // needed when drawing error bar - drawResidual(window, ag, temp1, temp2, colorMap, false); - if(showExtraPar.getStatus()) - { - temp1 = this.resLoc2; - temp2 = this.pullLoc2; - drawResidual(window, ag, temp1, temp2, colorMap, true); - } - } - else - { - showType = PULL_X; - temp1 = this.pullLoc1; - drawResidual(window, ag, temp1, null, colorMap, false); - if(showExtraPar.getStatus()) - { - temp1 = this.pullLoc2; - drawResidual(window, ag, temp1, null, colorMap, true); - } - } - - if(ag.getGraphics2D() instanceof APickingGraphics2D - && parameterStore.get("Event", "PickingMode").getI() == APickingGraphics2D.PICK_HITS_AND_TRACKS) // pick residula - { - APickingGraphics2D.mode = APickingGraphics2D.PICK_RESIDUAL; - APickingGraphics2D.setPicked(this); - } - } - - public void drawResidual(AWindow window, AGraphics ag, float[] res, - float[] pull, Color[] colorMap, boolean drawExtra) - { - // every residual is drawn as a small square with 2 pixels * 2 pixels - // N.B. when showType=PULL_X, res actually represents pull, and pull=null - double[] h = new double[4]; - double[] v = new double[4]; - int pixelOffset = 1; - - Point clickedPoint = null; - if(ag.getGraphics2D() instanceof APickingGraphics2D - && parameterStore.get("Event", "PickingMode").getI() == APickingGraphics2D.PICK_HITS_AND_TRACKS) // pick residual - { - clickedPoint = ((APickingGraphics2D)ag.getGraphics2D()).pickedPoint; - } - - Color colValid = colorMap[AColorMap.RD]; //for backward compatibility - Color colInvalid = colorMap[AColorMap.BK]; - for(int i=0; i<numPoints; i++) - { - double y; - if(res[i] == -99.0f) // unavailable - { - ag.setColor(colInvalid); - y = 0.0; - } - else - { - if(detType != null) - { - String det = detType[i]; - if("unident".equals(det)) - ag.setColor(colorMap[AColorMap.GY]); - else - { - AParameter detColor = parameterStore.get("Det", det+"Fill"); - if(detColor != null) - ag.setColor(colorMap[detColor.getI()]); - else - ag.setColor(colValid); - } - } - else // for old files that don't have <tsosDetType> - ag.setColor(colValid); - - if(parameterStore.get("TrackResidual", "Scale").getI() == 0) // linear - y = res[i]; - else // logarithmic scale - { - if(res[i] != 0.0f) - y = Math.log10(Math.abs(res[i])) - logMagnitudeMin; - else - y = res[i]; - if(res[i] < 0.0f) - y = -y; - } - } - - double tempX, tempY; - if(!drawExtra) - tempX = window.calculateDisplay(i, y).x; - else - tempX = window.calculateDisplay(i+0.25, y).x; - tempY = window.calculateDisplay(i, y).y; - - // when shape is a square, calculate the corners - // x0, y0 - h[0] = tempX - pixelOffset; - v[0] = tempY + pixelOffset; - // x1, y1 - h[1] = tempX - pixelOffset; - v[1] = tempY - pixelOffset; - // x2, y2 - h[2] = tempX + pixelOffset; - v[2] = tempY - pixelOffset; - // x3, y3 - h[3] = tempX + pixelOffset; - v[3] = tempY + pixelOffset; - - ag.fillPolygon(h, v, h.length); - - // draw error bar only for residual - AParameter showErrorBarPar = parameterStore.get("TrackResidual", "ErrorBar"); - if(showType.equals(RESIDUAL_X) && showErrorBarPar.getStatus() && - pull != null) - { - double error = 0.0; - if(pull[i] != 0.0f && pull[i] != -99.0f && y != 0.0) - error = res[i] / pull[i]; - - if(error != 0.0) // draw the error bar by linear scale always - { - double[][] vLine = new double[2][2]; - vLine[0][0] = tempX; - vLine[0][1] = tempX; - vLine[1][0] = window.calculateDisplay(i, y+error).y; - vLine[1][1] = window.calculateDisplay(i, y-error).y; - ag.drawPolyline(vLine[0], vLine[1], vLine[0].length); // verticle line - - double xMinus = tempX - 2 * pixelOffset; - double xPlus = tempX + 2 * pixelOffset; - double yTop = vLine[1][0]; - double yBottom = vLine[1][1]; - ag.drawLine(xMinus, yTop, xPlus, yTop); - ag.drawLine(xMinus, yBottom, xPlus, yBottom); - } - } - - // find the picked residual - if(ag.getGraphics2D() instanceof APickingGraphics2D - && parameterStore.get("Event", "PickingMode").getI() == APickingGraphics2D.PICK_HITS_AND_TRACKS) // pick residula - { - if(i==0 && !drawExtra) - { - pickedIndex = i; - pickedGroup = 1; - minDiff = Math.abs(clickedPoint.x - tempX); - APickingGraphics2D.pickedH = tempX; - APickingGraphics2D.pickedV = tempY; - } - else - { - double diff = Math.abs(clickedPoint.x - tempX); - if(minDiff > diff) - { - pickedIndex = i; - if(drawExtra) - pickedGroup = 2; - else - pickedGroup = 1; - minDiff = diff; - APickingGraphics2D.pickedH = tempX; - APickingGraphics2D.pickedV = tempY; - } - } - } - } - } - - public String getHitInfo() - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return track.getNameScreenName()+ - " index: "+trackIndex+"\n storegate key: "+ - (track.getStoreGateKey() == null ? "n/a" : track.getStoreGateKey()); - - StringBuffer msg = new StringBuffer(track.getNameScreenName() + " (index: "); - msg.append(trackIndex); - msg.append(")"); - msg.append("\n storegate key: "); - msg.append(track.getStoreGateKey() == null ? "n/a" : track.getStoreGateKey()); - if(showType.equals(RESIDUAL_X)) - { - msg.append("\n Residual" + pickedGroup + "(" + "index: " + pickedIndex + ") = "); - if (pickedGroup == 1) - msg.append((this.resLoc1[pickedIndex]==-99.0f)?"unavailable":this.resLoc1[pickedIndex] + "(mm)"); - else - msg.append((this.resLoc2[pickedIndex]==-99.0f)?"unavailable":this.resLoc2[pickedIndex] + "(mm)"); - } - else - { - msg.append("\n Pull" + pickedGroup + "(" + "index: " + pickedIndex + ") = "); - if (pickedGroup == 1) - msg.append((this.pullLoc1[pickedIndex]==-99.0f)?"unavailable":this.pullLoc1[pickedIndex] + "(mm)"); - else - msg.append((this.pullLoc2[pickedIndex]==-99.0f)?"unavailable":this.pullLoc2[pickedIndex] + "(mm)"); - } - - return msg.toString(); - - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/data/ATrigS3DData.java b/graphics/AtlantisJava/src/atlantis/data/ATrigS3DData.java deleted file mode 100644 index 2a20340f4ea354910d96c40769b2a624c07e6b79..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ATrigS3DData.java +++ /dev/null @@ -1,252 +0,0 @@ -package atlantis.data; - -import atlantis.event.*; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterUtilities; -import atlantis.utils.AHashMap; -import atlantis.utils.AMath; - - -/** - * - * Trigger SpacePoints - * - * barcodes + numBarcodes - associations with Truth (STr) - * clusters - associations with SiClusters and over it with reconstructed - * tracks (Track) - * - * cleanup notes: - * methods makeFilterDrawList(), getIntegerEta(), getIntegerPhi() were removed - * as these were only used by AFilter in S3D (this class was obviously the - * origin for the others) but AFilter doesn't work with TrigS3D - * other also unused methods are getLayer() and getSub() - what are these - * used for? - * - */ -public class ATrigS3DData extends A3DPointData -{ - private int[][] clusters = null; - - // data from the event file - protected int[] layer = null; - - private boolean[] pixel = null; - public static final int PIXEL = -1; - - - - public String getParameterGroup() - { - return "TrigS3D"; - } - - - - public String getName() - { - return "TrigS3D"; - } - - - - public String getNameScreenName() - { - return "TrigSiSpacePoint"; - } - - - - public String getHitInfo(int index) - { - int simpleOutput = AGlobals.instance().getSimpleOutput(); - if(simpleOutput>0) return getNameScreenName()+" index: " + index+"\n"+ - AMath.RHO+" = "+String.format("%.3f",rho[index])+"\n "+ - AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phi[index]))+AMath.DEGREES; - - String clId = " (" + clusters[index][0] + ", " + - clusters[index][1] + ")"; - String type = pixel[index] ? " (Pixel)" : " (SCT)"; - - String r = ""; - r += getNameScreenName() + " (id: " + id[index] + " index: " + index + ")" + - clId + type + "\n " + - "x = " + String.format("%.3f",x[index]) + " cm\n " + - "y = " + String.format("%.3f",y[index]) + " cm\n " + - "z = " + String.format("%.3f",z[index]) + " cm\n " + - AMath.RHO + " = " + String.format("%.3f",rho[index]) + " cm\n " + - AMath.PHI + " = " + - String.format("%.3f",Math.toDegrees(phi[index])) + - AMath.DEGREES + " (" + String.format("%.3f",phi[index]) + " rad)\n " + - " layer = " + layer[index]; - r += super.getHitInfo(index); // finds barcode information - - return r; - - } // getHitInfo() ------------------------------------------------------- - - - - ATrigS3DData(AHashMap p, AEvent e) - { - super(p,e); - layer = p.getUnknownIntArray("layer"); - - if(p.get("clusters") != null) - { - // can only distinguish between SCT and Pixel hits if clusters - // subtag is available - pixel = new boolean[numData]; - // save IDs from event file to be availeble with pick info - clusters = new int[numData][]; - - int[][] assocClusters = new int[numData][]; - int[] temp = p.getIntArray("clusters"); - for(int i = 0; i < numData; ++i) - { - // save all clusters IDs - clusters[i] = new int[] { temp[2 * i], temp[2 * i + 1] }; - - // check if the second number, PIXEL (-1) designates pixel hit - if(temp[2 * i + 1] != PIXEL) - { - // this is SCT spacepoint - has got two clusters - assocClusters[i] = new int[] { temp[2 * i], temp[2 * i + 1] }; - } - else - { - // this is a pixel spacepoint (second cluster number is -1) - pixel[i] = true; - - // to ignore associtiation between pixel clusters and spacepoints: - // assocClusters[i] = null; - - // taking pixel cluster into account (pixel spacepoint has got - // only one cluster) (where as SCT spacepoint has got two clusters) - assocClusters[i] = new int[] { temp[2 * i] }; - } - } - AAssociation assoc = new AAssociation(getName(), "SiCluster", - assocClusters,event); - event.getAssociationManager().add(assoc); - } - - } // ATrigS3DData() ----------------------------------------------------- - - - - protected void finalizeConstruction() - { - super.finalizeConstruction(); - super.calculateAssociationViaClusters(); - - } // finalizeConstruction() --------------------------------------------- - - - - protected int internalColor() - { - int numColorTypes = super.internalColor(); - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - if(colorFunction == numColorTypes + 1) - { - colorBy(layer); - } - - return numColorTypes + 1; - - } // internalColor() ---------------------------------------------------- - - - protected void applyCuts() - { - cutIndex(); - cutSubdetector(); - cut("CutsInDet", "Layer", "Layer", layer); - cutPhi(phi); - cutEta(rho, z); - cutSimulatedTracks(); - cutReconstructedTracks(); - - } // applyCuts() -------------------------------------------------------- - - - private void cutSubdetector() - { - AParameter subPar = parameterStore.get("CutsInDet", "SCT"); - if(subPar.getI() != -1) - { - cutArray(sub, subPar.getI(), "Barrel/Endcap"); - } - - } // cutSubdetector() --------------------------------------------------- - - - - public int[] getLayer(int[] layer) - { - for(int i = 0; i < numDraw; i++) - { - layer[i] = this.layer[listdl[i]]; - } - return layer; - - } // getLayer() --------------------------------------------------------- - - - - public int getSub(int id) - { - if(id > -1) - { - return(id >> 25) & 0x3; - } - else - { - return(id >> 29) & 0x3; - } - - } // getSub() ----------------------------------------------------------- - - - - protected ACoord getFRUser() - { - if(!parameterStore.get("SiCluster", "Stereo").getStatus())return super.getFRUser(); - makeDrawList(); - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - h[i] = rho[list]; - v[i] = Math.toDegrees(AParameterUtilities.getPhiStereo(rho[list], phi[list], z[list])); - index[i] = list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("FR"); - - } // getFRUser() -------------------------------------------------------- - - - - protected ACoord getFZUser() - { - if(!parameterStore.get("SiCluster", "Stereo").getStatus())return super.getFZUser(); - makeDrawList(); - double[] h = new double[numDraw]; - double[] v = new double[numDraw]; - int[] index = new int[numDraw]; - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - h[i] = z[list]; - v[i] = Math.toDegrees(AParameterUtilities.getPhiStereo(rho[list], phi[list], z[list])); - index[i] = list; - } - return new ACoord(h, v, index, this).includePhiWrapAround("FZ"); - - } // getFZUser() -------------------------------------------------------- - -} // class ATrigS3DData ===================================================== diff --git a/graphics/AtlantisJava/src/atlantis/data/ATriggerInfoData.java b/graphics/AtlantisJava/src/atlantis/data/ATriggerInfoData.java deleted file mode 100644 index 4e9b000c650c3481ff8d4bc1b8365899d721eac8..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/ATriggerInfoData.java +++ /dev/null @@ -1,213 +0,0 @@ -package atlantis.data; - -import atlantis.event.AData; -import atlantis.event.AEvent; -import atlantis.utils.AHashMap; - -public class ATriggerInfoData extends AData -{ - private float[] energyEtMiss; - //private float[] energyEx; - //private float[] energyEy; - private float[] energySumEt; - private String[] trigInfoEF; - private String[] trigInfoExtL1ID; - private String[] trigInfoL1; - private String[] trigInfoL2; - private String[] trigInfoLvl1Type; - private String[] trigInfoStatus; - private String[] trigInfoStreamTag; - - ATriggerInfoData(AHashMap p, AEvent e) - { - super(p,e); - energyEtMiss = p.getUnknownFloatArray("energyEtMiss"); - //energyEx = p.getUnknownFloatArray("energyEx"); - //energyEy = p.getUnknownFloatArray("energyEy"); - energySumEt = p.getUnknownFloatArray("energySumEt"); - trigInfoEF = p.getStringArray("trigInfoEF"); - trigInfoExtL1ID = p.getStringArray("trigInfoExtL1ID"); - trigInfoL1 = p.getStringArray("trigInfoL1"); - trigInfoL2 = p.getStringArray("trigInfoL2"); - trigInfoLvl1Type = p.getStringArray("trigInfoLvl1Type"); - trigInfoStatus = p.getStringArray("trigInfoStatus"); - trigInfoStreamTag = p.getStringArray("trigInfoStreamTag"); - } - - protected void applyCuts() - {} - - public String getHitInfo(int index) - { - return "TriggerInfo"; - } - - protected int internalColor() - { - int colorFunction = parameterStore.get(PARAMETER_GROUP, "ColorFunction").getI(); - - if(colorFunction == 0) - colorByConstant(); - - return 3; - } - - public String getParameterGroup() - { - return "TriggerInfo"; - } - - public String getNameScreenName() - { - return "TriggerInfo"; - } - - /** - * For backward compatibility if this is null or -1 - * also check the value returned from ALVL1ResultData - */ - public float getEnergyEtMiss(int index) - { - return energyEtMiss[index]; - } - - /*public float getEnergyEx(int index) - { - return energyEx[index]; - } - public float getEnergyEy(int index) - { - return energyEy[index]; - }*/ - - /** - * For backward compatibility if this is null or -1 - * also check the value returned from ALVL1ResultData - */ - public float getEnergySumEt(int index) - { - return energySumEt[index]; - } - - public String getTrigInfoEF(int index) - { - return trigInfoEF[index]; - } - - /** - * Returns the individual parts of the list seperated by - - */ - public String[] getTrigInfoEFSplit(int index) - { - if(trigInfoEF!=null) - return splitItems(trigInfoEF[index]); - else - return null; - } - - /** - * Returns the hex values of the - * individual parts of the list seperated by - - */ - public String[] getTrigInfoEFSplitHex(int index) - { - return hexValues(splitItems(trigInfoEF[index])); - } - - public String getTrigInfoExtL1ID(int index) - { - return trigInfoExtL1ID[index]; - } - - public String getTrigInfoL1(int index) - { - return trigInfoL1[index]; - } - - /** - * Returns the individual parts of the list seperated by - - */ - public String[] getTrigInfoL1Split(int index) - { - if(trigInfoL1!=null) - return splitItems(trigInfoL1[index]); - else - return null; - } - - /** - * Returns the hex values of the - * individual parts of the list seperated by - - */ - public String[] getTrigInfoL1SplitHex(int index) - { - return hexValues(splitItems(trigInfoL1[index])); - } - - public String getTrigInfoL2(int index) - { - return trigInfoL2[index]; - } - - /** - * Returns the individual parts of the list seperated by - - */ - public String[] getTrigInfoL2Split(int index) - { - if(trigInfoL2!=null) - return splitItems(trigInfoL2[index]); - else - return null; - } - - /** - * Returns the hex values of the - * individual parts of the list seperated by - - */ - public String[] getTrigInfoL2SplitHex(int index) - { - return hexValues(splitItems(trigInfoL2[index])); - } - - public String getTrigInfoLvl1Type(int index) - { - return trigInfoLvl1Type[index]; - } - - public String getTrigInfoStatus(int index) - { - return trigInfoStatus[index]; - } - - - public String getTrigInfoStreamTag(int index) - { - return trigInfoStreamTag[index]; - } - - /** - * Returns the individual parts of the list seperated by - - */ - public String[] getTrigInfoStreamTagSplit(int index) - { - if(trigInfoStreamTag!=null) - return splitItems(trigInfoStreamTag[index]); - else - return null; - } - - - /** - * Returns the hex values of each element in the string - * string[] items represents a long[] - */ - private String[] hexValues(String[] items) - { - for(int i=0; i<items.length; i++) - { - long longvalue= Long.valueOf(items[i]).longValue(); - items[i] = "0x"+Long.toString(longvalue, 16).toUpperCase(); - } - return items; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/data/AVertex.java b/graphics/AtlantisJava/src/atlantis/data/AVertex.java deleted file mode 100755 index ed4ea9643d782384c3d03051a3282b32e41c4221..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AVertex.java +++ /dev/null @@ -1,328 +0,0 @@ -package atlantis.data; - -import Jama.Matrix; - -import java.util.HashMap; -import java.util.Map; -import atlantis.parameters.APar; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjectionXZ; -import atlantis.projection.AProjectionYX; -import atlantis.projection.AProjectionYZ; -import atlantis.utils.AMath; -import atlantis.utils.AAtlantisException; - -/** - * - * Reconstructed vertex instance. Either calculated in - * Atlantis (atlantis.utils.AVertexFit class) or read in from the event data as - * RVx datatype. RVx class keeps track of all the reconstructed vertices - * and contains instances of this class Avertex. - * (2005-08-08 refactoring and clean-ups) - * (2006-01-10 covMatrix, errMatrix variables were messed up (covMatrix - * numbers were huge - was actually the inverse - the weight matrix. AVertexFit - * code didn't give any ideas, very unclear code - covFittedMatrix there - * was used to initialize errMatrix here ...)) - * - * - * variables names renaming: - * covMatrix -> weightMatrix - * errMatrix -> covErrorMatrix - * - * @author Gary Taylor - */ -public class AVertex -{ - // size of the arrays with coordinates of the RVx ellipse and matrices - private static final int SIZE = 3; - - // basic RVx data - private double[] position = null; // x, y, z centre of the ellipse - private double chi2 = 1.e+10; - private Matrix covErrMatrix = null; // covariance error matrix - private Matrix weightMatrix = null; // inverse matrix of covErrMatrix - private double phi; // phi of the ellipse - private double rho; // rho of the ellipse - - private static APar parameterStore = APar.instance(); - - public AVertex(double[] p) - { - position = new double[SIZE]; - - if (p.length != SIZE) - { - throw new IllegalArgumentException("p.length=" + p.length); - } - for (int i = 0; i < SIZE; ++i) - { - position[i] = p[i]; - } - } // AVertex() ---------------------------------------------------------- - - /** - * @param p double[] - x, y, z positions of the centre of the ellipse - * @param c double[][] - input for covErrMatrix - * @param chiSquared double - */ - public AVertex(double[] p, double[][] c, double chiSquared) - { - testInputArrays(p, c); - - position = new double[SIZE]; - double[][] covErr = new double[SIZE][SIZE]; - - for (int i = 0; i < SIZE; ++i) - { - position[i] = p[i]; - } - phi = Math.atan2(p[1], p[0]); - if (phi < 0.) - phi += AMath.TWO_PI; - rho = Math.sqrt(p[0] * p[0] + p[1] * p[1]); - for (int i = 0; i < SIZE; ++i) - { - for (int j = 0; j < SIZE; ++j) - { - covErr[i][j] = c[i][j]; - } - } - - covErrMatrix = new Matrix(covErr); - weightMatrix = covErrMatrix.inverse(); - this.chi2 = chiSquared; - } // AVertex() ---------------------------------------------------------- - - /** - * - * @param chiSquared double - * @param p double[] - x, y, z positions of the centre of the ellipse - * @param c double[][] - input for covErrMatrix - */ - public AVertex(double chiSquared, double[] p, double[][] c) throws AAtlantisException - { - testInputArrays(p, c); - - chi2 = chiSquared; - - position = new double[SIZE]; - - for (int i = 0; i < SIZE; ++i) - { - position[i] = p[i]; - } - - phi = Math.atan2(p[1], p[0]); - if (phi < 0.) - phi += AMath.TWO_PI; - rho = Math.sqrt(p[0] * p[0] + p[1] * p[1]); - - double[][] covErr = new double[SIZE][SIZE]; - for (int x = 0; x < SIZE; x++) - { - covErr[x] = (double[]) c[x].clone(); - } - - try - { - covErrMatrix = new Matrix(covErr); - weightMatrix = covErrMatrix.inverse(); - } - catch (Exception ex) - { - String msg = "Error when creating covariance and/or weight\n" + "matrix in AVertex class.\nReason: " + ex.getMessage(); - throw new AAtlantisException(msg); - } - } // AVertex() ---------------------------------------------------------- - - private void testInputArrays(double[] p, double[][] c) throws IllegalArgumentException - { - if (p.length != SIZE) - { - throw new IllegalArgumentException("p.length = " + p.length); - } - - if (c.length != SIZE) - { - throw new IllegalArgumentException("c.length = " + c.length); - } - - for (int i = 0; i < SIZE; ++i) - { - if (c[i].length != SIZE) - { - throw new IllegalArgumentException("c[" + i + "].length = " + c[i].length); - } - } - } // testInputArrays() -------------------------------------------------- - - public double[] getPosition() - { - return (double[]) position.clone(); - } // getPosition() ------------------------------------------------------ - - public Matrix getCovErrMatrix() - { - return covErrMatrix; - } // getCovErrMatrix() -------------------------------------------------- - - public double getRho() - { - return rho; - } - - public double getPhi() - { - return phi; - } - - public String toString() - { - StringBuffer msg = new StringBuffer(" x = "); - msg.append(String.format("%.5f",position[0])); - msg.append(" "); - msg.append(AMath.PLUSMINUS); - msg.append(" "); - msg.append(String.format("%.3f",Math.sqrt(covErrMatrix.get(0, 0)))); - msg.append(" cm\n y = "); - msg.append(String.format("%.5f",position[1])); - msg.append(" "); - msg.append(AMath.PLUSMINUS); - msg.append(" "); - msg.append(String.format("%.3f",Math.sqrt(covErrMatrix.get(1, 1)))); - msg.append(" cm\n z = "); - msg.append(String.format("%.5f",position[2])); - msg.append(" "); - msg.append(AMath.PLUSMINUS); - msg.append(" "); - msg.append(String.format("%.3f",Math.sqrt(covErrMatrix.get(2, 2)))); - msg.append(" cm\n "); - msg.append(AMath.ETA); - msg.append(" = "); - msg.append(String.format("%.4f",AParameterUtilities.eta(position[2], rho))); - msg.append("\n "); - msg.append(AMath.PHI); - msg.append(" = "); - msg.append(String.format("%.1f",Math.toDegrees(phi))); - msg.append(AMath.DEGREES); - msg.append("\n chi2 = "); - msg.append(String.format("%.1f",chi2)); - - return msg.toString(); - } // toString() --------------------------------------------------------- - - // Ask Alan Litke to explain this calculation - private double[][] getEllipse(Matrix rM, int[] axisMapping) - { - Matrix parPrime = rM.times(new Matrix(position, position.length)); - - double a1 = weightMatrix.get(axisMapping[0], axisMapping[0]); - double a2 = weightMatrix.get(axisMapping[1], axisMapping[1]); - double a3 = weightMatrix.get(axisMapping[2], axisMapping[2]); - double a4 = 2. * weightMatrix.get(axisMapping[0], axisMapping[1]); - double a5 = 2. * weightMatrix.get(axisMapping[0], axisMapping[2]); - double a6 = 2. * weightMatrix.get(axisMapping[1], axisMapping[2]); - double b1 = a1 - a5 * a5 / (4. * a3); - double b2 = a2 - a6 * a6 / (4. * a3); - double b3 = a4 - 2 * a5 * a6 / (4. * a3); - double[][] hv = new double[2][360]; - double sigma = parameterStore.get("RVx", "NumSigma").getD(); - for (int i = 0; i < 360; ++i) - { - double thetat = Math.toRadians(i); - double tt = Math.tan(thetat); - double x = Math.sqrt(sigma * sigma / (b1 + b2 * tt * tt + b3 * tt)); - if (i > 90 && i <= 270) - x *= -1.; - hv[0][i] = x + parPrime.get(axisMapping[0], 0); - hv[1][i] = x * tt + parPrime.get(axisMapping[1], 0); - } - return hv; - } // getEllipse() ------------------------------------------------------- - - public double[][] getYXEllipse() - { - Matrix rM = new Matrix(AProjectionYX.getRotationMatrix()); - int[] axisMapping = AProjectionYX.getAxisMapping(); - - return getEllipse(rM, axisMapping); - } // getYXEllipse() ----------------------------------------------------- - - public double[][] getYZEllipse() - { - Matrix rM = new Matrix(AProjectionYZ.getRotationMatrix()); - int[] axisMapping = AProjectionYZ.getAxisMapping(); - - return getEllipse(rM, axisMapping); - } // getYZEllipse() ----------------------------------------------------- - - public double[][] getXZEllipse() - { - Matrix rM = new Matrix(AProjectionXZ.getRotationMatrix()); - int[] axisMapping = AProjectionXZ.getAxisMapping(); - - return getEllipse(rM, axisMapping); - } // getXZEllipse() ----------------------------------------------------- - - public double[][] getRZEllipse() - { - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(phi-phiMid); - int rSign; if (phiDiff > Math.PI/2. && phiDiff <= 3*Math.PI/2.) rSign = -1; else rSign = 1; - - double[][] hv = new double[2][360]; - double sigma = parameterStore.get("RVx", "NumSigma").getD(); - for (int i = 0; i < 360; ++i) - { - double thetat = Math.toRadians(i); - double ey = Math.sqrt(Math.sqrt(covErrMatrix.get(0,0)*covErrMatrix.get(0,0)+covErrMatrix.get(1,1)*covErrMatrix.get(1,1))); - double ex = Math.sqrt(covErrMatrix.get(2,2)); - hv[1][i] = rSign * Math.sqrt(position[0]*position[0]+position[1]*position[1]) + sigma*ey*Math.sin(thetat); - hv[0][i] = position[2] + sigma*ex*Math.cos(thetat); - //System.out.println(i+" "+thetat+" "+hv[0][i]+" "+hv[1][i]); - } - return hv; - } // getXZEllipse() ----------------------------------------------------- - - // Vertex type - enum same as in Athena - - enum Type { - DUMMY (0, "Dummy. Track particle was not used in vertex fit."), - PRIMARY (1, "Primary"), - SECONDARY (2, "Secondary"), - PILEUP (3, "Pile-up"), - CONVERSION (4, "Conversion"), - V0 (5, "V0 decay"), - KINK (6, "Kink"), - TEMPV0LAMBDA (7, "Temporary Addition for V0 Lambda"), - TEMPV0LAMBDABAR (8, "Temporary Addition for V0 LambdaBar"), - TEMPKSHORT (9, "Temporary Addition for KShort"), - DEFAULT (99, "Not specified"); - - public final int id; - public final String description; - - private static Map<Integer,Type> typeMap = new HashMap<Integer,Type>(); - static { - for (Type type : Type.values()) { - typeMap.put(type.id, type); - } - } - - /** - * Get vertex type corresponding to given integer type identifier. - * @param id type identifier - * @return vertex type - */ - public static Type typeFromId(int id) { - return typeMap.get(id); - } - - private Type (int id, String description) { - this.id = id; - this.description = description; - } - } - -} - \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/data/AVertexFit.java b/graphics/AtlantisJava/src/atlantis/data/AVertexFit.java deleted file mode 100755 index 09fba478e39342e1128813250c93b2bc54fc847f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/AVertexFit.java +++ /dev/null @@ -1,289 +0,0 @@ -package atlantis.data; - -import atlantis.parameters.APar; -import atlantis.utils.ALogger; - -import Jama.*; - - -/** - * This class provide a java implementation of the ALEPH vertex fitting - * routine YTOPOL. At the moment the only functionality is the fitting - * of ATLAS helices to a common vertex. A reasonable starting vertex for the - * fit must be given. For B decays the primary vertex should be good enough. - * Future improvements in functionality could include estimation of a - * starting vertex and including in the fitting also already calculated - * vertices and charged and neutral particles - */ - -public class AVertexFit { - private static ALogger logger = ALogger.getLogger(AVertexFit.class); - private static APar parameterStore = APar.instance(); - - private static final int MXITR=8; - private static final double CHISC=1.E-2; - private static final double CHISR=0.01; - private static final double PARCR=0.01; - private static final boolean DEBUG=false; - - private AVertexFit() {} - - public static AVertex fitVertex(AVertex estimatedVertex, AHelix[] helix) { - Matrix[] measuredHelix=new Matrix[helix.length]; - Matrix[] covHelix=new Matrix[helix.length]; - Matrix[] errHelix=new Matrix[helix.length]; - - for(int k=0; k<helix.length; ++k) { - double[] par=helix[k].getPar(); - double[][] cov=helix[k].getCovariance(); - double signD0=-1.; - double signPt=1.; - - par[0]*=signD0; - par[4]*=signPt; - - for(int i=0; i<5; ++i) { - cov[0][i]*=signD0; - cov[i][0]*=signD0; - cov[4][i]*=signPt; - cov[i][4]*=signPt; - } - - measuredHelix[k]=new Matrix(par, par.length); - covHelix[k]=new Matrix(cov); - errHelix[k]=covHelix[k].inverse(); - - // AOutput.logln( "measuredHelix "+k+" "+measuredHelix[k]); - // AOutput.logln( measuredHelix[k].toString()); - // AOutput.logln( covHelix[k].toString()); - - } - - int numFreeParam=3+3*helix.length; - Matrix fitted=new Matrix(numFreeParam, 1); - double[] estVertex=estimatedVertex.getPosition(); - int ipar; - - for(ipar=0; ipar<3; ++ipar) - fitted.set(ipar, 0, estVertex[ipar]); - ipar=3; - for(int k=0; k<helix.length; ++k) { - fitted.set(ipar++, 0, parameterStore.get("Event", "Curvature").getD()/measuredHelix[k].get(4, 0)-measuredHelix[k].get(0, 0)); - - fitted.set(ipar++, 0, measuredHelix[k].get(3, 0)); - fitted.set(ipar++, 0, measuredHelix[k].get(2, 0)); - } - - logger.debug("fittedHelix "+0+" "+new Transformation(fitted, 0).helixFromFitted()); - logger.debug("fittedHelix "+1+" "+new Transformation(fitted, 1).helixFromFitted()); - - // AOutput.logln( fitted.toString()); - - Matrix g=new Matrix(numFreeParam, 1); - Matrix gg=new Matrix(numFreeParam, numFreeParam); - int iteration=0; - double chiso=0.; - double chisq=0.; - boolean converged; - - FITTINGLOOP: - do { - g.timesEquals(0.); - gg.timesEquals(0.); - for(int k=0; k<helix.length; ++k) { - Transformation t=new Transformation(fitted, k); - - Matrix fittedHelix=t.helixFromFitted(); - - logger.debug("fittedHelix "+k+" "+fittedHelix); - Matrix dMdF=t.getHelixdMdF(); - Matrix delFM=fittedHelix.minus(measuredHelix[k]); - // helices are independent of each other so can - // use temporary matrices to avoid large matrix multiplications - Matrix gtemp=(errHelix[k].times(dMdF)).transpose().times(delFM); - Matrix ggtemp=dMdF.transpose().times(errHelix[k].times(dMdF)); - - // now put these into the large matrices - for(int i=0; i<3; ++i) { - int ix=3+3*k; - - g.set(i, 0, g.get(i, 0)+gtemp.get(i, 0)); - g.set(ix+i, 0, g.get(ix+i, 0)+gtemp.get(3+i, 0)); - for(int j=0; j<3; ++j) { - gg.set(i, j, gg.get(i, j)+ggtemp.get(i, j)); - gg.set(ix+i, j, gg.get(ix+i, j)+ggtemp.get(3+i, j)); - gg.set(i, ix+j, gg.get(i, ix+j)+ggtemp.get(i, 3+j)); - gg.set(ix+i, ix+j, gg.get(ix+i, ix+j)+ggtemp.get(3+i, 3+j)); - } - } - if(iteration==0) { - double chih=delFM.transpose().times(errHelix[k].times(delFM)).get(0, 0); - - chiso+=Math.min(chih, 1.0e+10); - // AOutput.logln( "initial chi2"+chih); - } - } - - // AOutput.logln( gg.toString()); - - gg=gg.inverse(); - Matrix delFitted=gg.times(g); - - logger.debug("DELFITTED "+iteration+" "+delFitted.toString()); - - fitted.minusEquals(delFitted); - - int jter=0; - int kter=0; - - while(true) { - if(kter>10) break FITTINGLOOP; - if(jter>100) break FITTINGLOOP; - - double chish=0.; - - chisq=0.; - for(int k=0; k<helix.length; ++k) { - Transformation t=new Transformation(fitted, k); - Matrix fittedHelix=t.helixFromFitted(); - Matrix delFM=fittedHelix.minus(measuredHelix[k]); - double chih=delFM.transpose().times(errHelix[k].times(delFM)).get(0, 0); - - chish+=Math.min(chih, 1.0e+10); - } - chisq+=chish; - - double chis1=0.; - - if((chisq>chiso+0.0001&&jter==0)||chisq>1.1*chiso) { - delFitted.timesEquals(0.5); - fitted.plusEquals(delFitted); - jter++; - chis1=chisq; - continue; - } else { - if(jter>0) { - // estimate best parameters - double chtrm=chis1+chiso-2.*chisq; - double fx; - - if(chtrm>0.) { - // concave chisq dependance - fx=(chis1-chiso)/(2.*(chis1+chiso-2.*chisq)); - fx=Math.max(fx, -2.); - fx=Math.min(fx, 2.); - } else { - // convex chisq dependance - fx=-2.; - } - delFitted.timesEquals(fx); - - jter=0; - kter++; - continue; - } - } - break; - } - - double dchi2=chiso-chisq; - - chiso=chisq; - converged=true; - // check for change in chisq - if(dchi2>CHISC&&dchi2>CHISR*chisq) converged=false; - // check for change in parameters - for(int i=0; i<numFreeParam; i++) - if(delFitted.get(i, 0)*delFitted.get(i, 0)>PARCR*gg.get(i, i)) - converged=false; - } while((!converged)&&iteration++<MXITR); - - double[] fittedVertex=new double[3]; - double[][] fittedVertexCov=new double[3][]; - - for(int i=0; i<3; i++) { - fittedVertex[i]=fitted.get(i, 0); - fittedVertexCov[i]=new double[3]; - for(int j=0; j<3; j++) - fittedVertexCov[i][j]=gg.get(i, j); - } - - return new AVertex(fittedVertex, fittedVertexCov, chisq); - } - - private static class Transformation { - double rho, tau, phi0, d0, z0, sinPhi, cosPhi, sinDPhi, cosDPhi, eta, s, r, dPhi; - - Transformation(Matrix fitted, int iHelix) { - int index=3+3*iHelix; - - eta=fitted.get(index++, 0); - tau=fitted.get(index++, 0); - phi0=fitted.get(index++, 0); - double sinPhi0=Math.sin(phi0); - double cosPhi0=Math.cos(phi0); - double xC=-eta*sinPhi0; - double yC=eta*cosPhi0; - - // if(DEBUG) AOutput.logln(" Afit xCyC"+iHelix+" "+xC+" "+yC+" "+eta); - - double xVxC=fitted.get(0, 0)-xC; - double yVyC=fitted.get(1, 0)-yC; - - r=0.; - if(eta>0.) - r=Math.sqrt(xVxC*xVxC+yVyC*yVyC); - else - r=-Math.sqrt(xVxC*xVxC+yVyC*yVyC); - - d0=r-eta; - sinPhi=xVxC/r; - cosPhi=-yVyC/r; - double phi=Math.atan2(sinPhi, cosPhi); - - if(phi-phi0<-Math.PI) phi+=2.*Math.PI; - dPhi=phi-phi0; - s=dPhi*r; - z0=fitted.get(2, 0)-s*tau; - sinDPhi=Math.sin(dPhi); - cosDPhi=Math.cos(dPhi); - rho=1./r; - } - - Matrix getHelixdMdF() { - Matrix dMdF=new Matrix(5, 6); - - double curvature = parameterStore.get("Event", "Curvature").getD(); - dMdF.set(4, 0, -curvature*rho*rho*sinPhi); - dMdF.set(4, 1, curvature*rho*rho*cosPhi); - dMdF.set(4, 3, -curvature*rho*rho*cosDPhi); - dMdF.set(4, 5, -curvature*rho*rho*eta*sinDPhi); - dMdF.set(3, 4, 1.); - dMdF.set(2, 5, 1.); - dMdF.set(0, 0, sinPhi); - dMdF.set(0, 1, -cosPhi); - dMdF.set(0, 3, cosDPhi-1.); - dMdF.set(0, 5, eta*sinDPhi); - dMdF.set(1, 0, -tau*(sinPhi*dPhi+cosPhi)); - dMdF.set(1, 1, tau*(cosPhi*dPhi-sinPhi)); - dMdF.set(1, 2, 1.); - dMdF.set(1, 3, -tau*(dPhi*cosDPhi-sinDPhi)); - dMdF.set(1, 4, -s); - dMdF.set(1, 5, -tau*(eta*(dPhi*sinDPhi+cosDPhi)-r)); - return dMdF; - } - - Matrix helixFromFitted() { - Matrix helix=new Matrix(5, 1); - - helix.set(4, 0, rho*parameterStore.get("Event", "Curvature").getD()); - helix.set(3, 0, tau); - helix.set(2, 0, phi0); - helix.set(0, 0, d0); - helix.set(1, 0, z0); - return helix; - } - - } -} - diff --git a/graphics/AtlantisJava/src/atlantis/data/package.html b/graphics/AtlantisJava/src/atlantis/data/package.html deleted file mode 100644 index 15056059d098ac41aee4c8219ef71d6b9a98fb44..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/data/package.html +++ /dev/null @@ -1,8 +0,0 @@ -<html> -<head></head> -<body> -<p>All classes handling particular datatypes are part of this package. -They all implement AData from the atlantis.event package.</p> -</body> -</html> - diff --git a/graphics/AtlantisJava/src/atlantis/event/AAssociation.java b/graphics/AtlantisJava/src/atlantis/event/AAssociation.java deleted file mode 100755 index b2338def707a30c8dc8525182ea06481e47b7ddc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AAssociation.java +++ /dev/null @@ -1,298 +0,0 @@ -package atlantis.event; - -import atlantis.utils.ALogger; - -/** - * Representation of the association between two data types. The association is - * stored using the string name+storeGateKey for both data types. - * - * The actual association is a an array of arrays of integers. The first index - * of this array is the index of an element in the first datatype. The array - * then contains the Athena IDs of the element in the second datatype that are - * associated to it. This is necessary because the second datatype might not - * have been read from the XML file yet, so the indices are unknown. - * - * @todo Modify this class to perform a translation of Athena ID to Atlantis ID - * for the identifiers of "b". This can be done together with purgeIDNotInData() - * and avoids the need for continuously looking up Athena IDs when drawing. - */ -public class AAssociation { - - /** Logger */ - private static final ALogger logger = ALogger.getLogger(AAssociation.class); - - /** Event this association belongs to */ - private final AEvent event; - - /** Identifying the datatype this association if from */ - private final String a; - - /** Identifying the datatype this association is to */ - private final String b; - - /** - * Association, the first index is the index of an element of "a", the - * second index then loops over the Athena IDs in "b" to which the element - * of "a" is associated. - */ - private final int[][] assoc; - - /** - * Constructor, taking as input a flat array (btoa) and an array that - * specifies how many entries correspond to each object in "a". - * - * For example: - * - * from = "Jet"; - * to = "Track"; - * numbtoa = {2, 0, 3}; - * btoa = {1, 5, 3, 4, 6}; - * - * This means that the first jet in the event (index=0) is associated - * to 2 tracks, namely index 1 and 5. The second jet has no associated - * tracks and the third jet (index=2) is associated to 3 tracks, indices - * 3, 4 and 6. - * - * Alternatively, numbtoa can be null. In that case the length of btoa has - * to be equal to the number of entries in "a". Every object in "a" will be - * associated to exactly one object in "b". - * - * @param from name+key this association is from, "a" - * @param to name+key this association is to, "b" - * @param numbtoa number of elements in "b" that each element in "a" is associated to - * @param btoa contents of the association in flat array - * @param e event object this association belongs to - */ - public AAssociation(String from, String to, int[] numbtoa, int[] btoa, AEvent e) { - - // Association to STr is done using barcodes, this is the only exception - // here: for barcodes ID=0 means no association. So we skip those entries. - boolean skipZero = to.startsWith("STr") && numbtoa == null; - - event = e; - a = from; - b = to; - - if (btoa == null) { - - assoc = null; - - } else { - - if (numbtoa != null) { - - // Multiple "b" entries associated to an "a" entry - assoc = new int[numbtoa.length][]; - - int num = 0; - for (int i = 0; i < numbtoa.length; ++i) { - if (numbtoa[i] <= 0) { - assoc[i] = new int[0]; - } else { - assoc[i] = new int[numbtoa[i]]; - } - - for (int j=0; j<numbtoa[i]; ++j) { - assoc[i][j] = btoa[num++]; - } - } - - } else { - - // Simple 1-on-1 association - assoc = new int[btoa.length][]; - - for (int i=0; i<btoa.length; i++) { - if (skipZero && btoa[i] <= 0) { - assoc[i] = new int[0]; - } else { - assoc[i] = new int[] { btoa[i] }; - } - } - } - - } - } - - /** - * Copy constructor - * - * @param from source datatype - * @param to target datatype - * @param associations association index arrays - * @param e event the association belongs to - */ - public AAssociation(String from, String to, int[][] associations, AEvent e) { - event = e; - a = from; - b = to; - assoc = associations; - } - - /** - * Get the name of association - * @return association name, concatenation of the two data types it associates - */ - public String getName() { - return a + b; - } - - /** - * Get source data type of association - * @return name of source data type - */ - public String getFrom() { - return a; - } - - /** - * Get target data type of association - * @return name of target data type - */ - public String getTo() { - return b; - } - - /** - * Get association array - * @return association array - */ - public int[][] getData() { - return assoc; - } - - /** - * Method that constructs the association b->a when only an association a->b - * currently exists. The complication here is due to the fact that "a" uses - * Atlantis indices (0, 1, ...), while "b" uses Athena IDs (1611690048, - * 1635282976, etc.). - * - * @return inverted association - */ - public AAssociation invert() { - - AData aData = event.get(a); - AData bData = event.get(b); - - if (aData == null || bData == null) { - logger.debug(getClass().getName() - + ": No association found between " + a + " and " + b); - return null; - - } else { - - try { - // New assoc will have the same number of entries as "b" - int[][] inv = new int[bData.getNumData()][]; - - // Athena IDs of object "a" - int[] ida = aData.getID(); - - // Loop over all entries in "a", the current association array - for (int i=0; i<assoc.length; ++i) { - if (assoc[i] != null) { - for (int j=0; j<assoc[i].length; ++j) { - - // For each associated entry in "b", we need to find - // the index from the Athena ID - int index = bData.getIndexFromId(assoc[i][j]); - - if (index != AData.NO_INVERSE) { - - if (inv[index] == null) { - - // The object in "a" is the first object that - // this object in "b" is associated to. Create - // a new array and add this entry. - inv[index] = new int[] { ida[i] }; - - } else { - - // The object in "b" is already associated to - // other objects in "a". Retrieve the other - // objects, increment the size and add the - // current object in "a". - int[] temp = new int[inv[index].length + 1]; - for (int k=0; k<inv[index].length; ++k) { - temp[k] = inv[index][k]; - } - temp[inv[index].length] = ida[i]; - inv[index] = temp; - } - } - } - } - } - return new AAssociation(b, a, inv, event); - - } catch (Exception e) { - logger.error("Unable to invert association.", e); - return null; - } - } - } // invert() --------------------------------------------------------------- - - /** - * Remove associations between items that are not present in the event data - */ - void purgeIDNotInData() { - // remove inconsistencies - // TRT hits from RTr<->SiCluster - // Association to an STr which does not exist in STr - - AData source = event.get(b); - if (assoc == null || source == null) { - return; - } - int INVALID_ID = -1; // (i hope!) - for (int i = 0; i < assoc.length; i++) { - if (assoc[i] != null) { - int num = 0; - for (int j = 0; j < assoc[i].length; j++) { - if (source.getIndexFromId(assoc[i][j]) == AData.NO_INVERSE) { - assoc[i][j] = INVALID_ID; - num++; - } - } - if (num > 0) { - if (num == assoc[i].length) { - assoc[i] = null; - } else { - int[] temp = new int[assoc[i].length - num]; - num = 0; - for (int j = 0; j < assoc[i].length; j++) { - if (assoc[i][j] != INVALID_ID) { - temp[num++] = assoc[i][j]; - } - } - assoc[i] = temp; - } - } - } - } - } - - /** - * Convert association into an informational message for the user - */ - @Override - public String toString() { - StringBuilder s = new StringBuilder(); - s.append(a).append(" to ").append(this.b); - if (assoc == null) { - s.append(" is empty\n"); - return s.toString(); - } else { - s.append("\n"); - for (int i = 0; i < assoc.length; i++) { - if (assoc[i] != null) { - for (int j = 0; j < assoc[i].length; j++) { - s.append(assoc[i][j]).append(" "); - } - s.append("\n"); - } - } - } - return s.toString(); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AAssociationManager.java b/graphics/AtlantisJava/src/atlantis/event/AAssociationManager.java deleted file mode 100755 index cc1cbedaf47ba988e74f623ea4708d5000a382c3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AAssociationManager.java +++ /dev/null @@ -1,118 +0,0 @@ -package atlantis.event; - - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import atlantis.utils.ALogger; - -public class AAssociationManager -{ - private static ALogger logger = ALogger.getLogger(AAssociationManager.class); - - private Map<String, AAssociation> associations = new HashMap<String, AAssociation>(); - - public AAssociationManager() {} - - public void clear() - { - associations = new HashMap<String, AAssociation>(); - } - - public void add(AAssociation a) - { - associations.put(a.getName(), a); - } - - public void remove(String key) - { - associations.remove(key); - } - - public int[][] get(String a, String b) - { - Object o = associations.get(a + b); - if(o != null) - { - return((AAssociation) o).getData(); - } - else - { - o = associations.get(b + a); - if(o != null) - { - //AOutput.logln("AAssociationManager.get()\n" + - // "querying non-existing association from-" + a + "-to-" + b + - // "\ncalculating inverse association ...") ; - AAssociation ass = ((AAssociation) o).invert(); - // following test prevents Atlantis from crashing if there - // is something wrong with the association between clusters - // and cells - if(ass != null) - { - add(ass); - return ass.getData(); - } - else - { - String name = "AAssociationManager.get(): "; - logger.debug(name + "No association " + - "found between " + a + " and " + b); - return null; - } - } - } - return null; - } // get() -------------------------------------------------------------- - - - public AAssociation getAssociation(String a, String b) - { - return (AAssociation) associations.get(a + b); - } - - public void correct() - { - Collection<AAssociation> c = associations.values(); - for (AAssociation a : c) { - a.purgeIDNotInData(); - } - } - - - public String[] getKnownAssociations(String a) - { - Collection<AAssociation> c = associations.values(); - Set<String> list = new TreeSet<String>(); - for (AAssociation ass : c) { - if(ass.getFrom().equals(a)) - { - list.add(ass.getTo()); - } - else if(ass.getTo().equals(a)) - { - list.add(ass.getFrom()); - } - } - return (String[]) list.toArray(new String[list.size()]); - } - - - public String getAllKnownAssociations() - { - Collection<AAssociation> col = associations.values(); - StringBuilder r = new StringBuilder(); - int c = 0; - - for (AAssociation ass : col) { - c++; - r.append(c + " association from " + ass.getFrom() + " to " + - ass.getTo() + " (name: " + ass.getName() + ")\n"); - } - - return r.toString(); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/event/ABufferedEventSource.java b/graphics/AtlantisJava/src/atlantis/event/ABufferedEventSource.java deleted file mode 100644 index 7d089cf7ce8d8661d3f4b5c5f690bd559cb4a79a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/ABufferedEventSource.java +++ /dev/null @@ -1,263 +0,0 @@ -package atlantis.event; - -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.utils.ALogger; -import java.util.Vector; - -/** - * Extension class to AEventSource providing buffering for a fixed number of events. - * @author sboeser - */ -public abstract class ABufferedEventSource implements AEventSource { - - //Logging interface - private final static ALogger logger = ALogger.getLogger(ABufferedEventSource.class); - - //The index of the currently selected event in the list - private static int currentEvent = -1; - //The maximum number of events to save - public static int maxNumberOfEvents = 1; - //A vector of available events - private static Vector<AEvent> eventContainer = new Vector<AEvent>(); - // the current event navigation mode - private NavigationMode eventNavigationMode = NavigationMode.SEQUENTIAL; - - /** - * Abstract read next event method to be implemented by all subclasses - * @return the next event - * @throws NoMoreEventsException - * @throws InvalidEventSourceException - * @throws ReadEventException - */ - protected abstract AEvent readNext(AEventInfo currentEvent) throws NoMoreEventsException, - InvalidEventSourceException, - ReadEventException; - /** - * Abstract read previous event method to be implemented by all subclasses - * @return the previous event - * @throws NoMoreEventsException - * @throws InvalidEventSourceException - * @throws ReadEventException - */ - protected abstract AEvent readPrevious(AEventInfo currentEvent) throws NoMoreEventsException, - InvalidEventSourceException, - ReadEventException; - - /** - * Get the next event, either from the buildin buffer or by reading it in - * @return the next event - * @throws atlantis.event.AEventSource.NoMoreEventsException - * @throws atlantis.event.AEventSource.InvalidEventSourceException - * @throws atlantis.event.AEventSource.ReadEventException - */ - public AEvent nextEvent() throws NoMoreEventsException, - InvalidEventSourceException, - ReadEventException - { - //Check if we are already at the last event - if (currentEvent == eventContainer.size()-1){ - - //if so, try to get another event - AEvent event = null; - try{ - event = readNext(getCurrentEventInfo()); - } catch ( OutOfMemoryError oom ) { - - //throw an error message - logger.error("Ran out of memory while reading event data"); - - //See if we can clear memory by removing events - if ( getNumberOfEvents() > 0) { - //be verbose - logger.info("Clearing event cache and retry..."); - //remove events - clearEventContainer(); - //Call garbage collector to free resources - System.gc(); - //Now retry (no current event) - event = readNext(null); - } - } - - //Add it to the eventContainer as last one - addEvent(event,false); - - } else { - // simply increase event counter - setCurrentEvent(currentEvent+1); - } - - //Now return the new current event - return eventContainer.get(currentEvent); - } - - public AEvent previousEvent() throws NoMoreEventsException, - InvalidEventSourceException, - ReadEventException { - - //Check if we are already at the first event - if (currentEvent <= 0 ){ - - //if so, try to get another event - AEvent event = null; - try{ - event = readPrevious(getCurrentEventInfo()); - } catch ( OutOfMemoryError oom ) { - - //throw an error message - logger.error("Ran out of memory while reading event data"); - - //See if we can clear memory by removing events - if ( getNumberOfEvents() > 0) { - //be verbose - logger.info("Clearing event cache and retry..."); - //remove events - clearEventContainer(); - //Call garbage collector to free resources - System.gc(); - //Now retry (no current event) - event = readPrevious(null); - } - } - - //Add it to the eventContainer as first one - addEvent(event,true); - - } else { - // simply decrease event counter - setCurrentEvent(currentEvent-1); - } - - //Now return the new current event - return eventContainer.get(currentEvent); - - } - - /** - * Get the event navigation mode for the current source. - * @return current event navigation mode - */ - public NavigationMode getNavigationMode() { - return eventNavigationMode; - } - - /** - * Set the event navigation mode for the current source, - * clears the buffer and reads the first event. - * Throws InvalidEventSourceException if the current - * source does not support the requested mode - * @param mode requested event navigation mode - */ - public void setNavigationMode(NavigationMode mode) throws InvalidEventSourceException - { - if(supportsNavigationMode(mode)) { - NavigationMode oldMode = getNavigationMode(); - eventNavigationMode = mode; - - // empty the buffer - clearEventContainer(); - } else - throw new InvalidEventSourceException("Mode '"+mode.name()+"' not supported by current source"); - } - - /** - * Checks whether the current event source supports - * a particular display mode. - * @return true if the mode is supported - * @param mode requested event navigation mode - */ - public abstract boolean supportsNavigationMode(NavigationMode mode); - - /** - * Returns number of events saved in the eventContainer - * @return int - */ - public int getNumberOfEvents() - { - return eventContainer != null ? eventContainer.size() : 0; - - } - - /** - * Add the given even to the event container. By default, events are added - * to the end of the container. If skipping backward, it may be necessary to - * add to the beginning of the container, as indicated by the asFirst flag - * The new event will also be set as default event - * - * @param event the event to add - * @param asFirst whether to add the event at the beginning (default is end) - */ - private synchronized void addEvent(AEvent event, boolean asFirst) - { - //create event container if it does not exist - if(eventContainer == null) eventContainer = new Vector<AEvent>(); - - //Make sure container does not get too large - while (eventContainer.size() >= maxNumberOfEvents){ - // remove at the side at which we are not adding event - if (asFirst) eventContainer.remove(eventContainer.lastElement()); - else eventContainer.remove(0); - } - - //At the end or at the beginning - int index = (asFirst) ? 0 : eventContainer.size(); - - //add the event - eventContainer.add(index,event); - - //be verbose - logger.debug(eventContainer.size() + " event(s) in memory"); - - //set as current event - setCurrentEvent(index); - } - - - /** - * Clear the event container, reset the current event - */ - protected synchronized void clearEventContainer() - { - //Make sure the event container exits before clearing it - if(eventContainer != null){ - // let the user know - String msg = "Clearing event container with "+getNumberOfEvents()+" events."; - logger.warn(msg); - AOutput.append(msg, ALogInterface.WARNING); - - //Clear the container - eventContainer.clear(); - } - - //Alse reset current event - currentEvent = -1; - - //Run the garbage collector to free space immediately - System.gc(); - - } - - private void setCurrentEvent(int index) { - //Check for out-of-bounds - if ((index < 0) || ( index >= eventContainer.size())) - throw new ArrayIndexOutOfBoundsException("Cannot set index "+index+" in event container of size "+eventContainer.size()); - currentEvent = index; - } - - /** - * @return the curent event or null if there is none - */ - private AEventInfo getCurrentEventInfo(){ - - //Check if the current event is there - try { - //get the current events name - return eventContainer.get(currentEvent); - } catch (ArrayIndexOutOfBoundsException ex){ - //return an empty string if there is no current event - return null; - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AData.java b/graphics/AtlantisJava/src/atlantis/event/AData.java deleted file mode 100644 index 6bf4541ac22d44d3c6423be44e28e0498615b0c7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AData.java +++ /dev/null @@ -1,1661 +0,0 @@ -package atlantis.event; - -import java.awt.Component; -import java.util.Vector; -import java.util.Collection; -import javax.swing.Action; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import atlantis.canvas.AWindow; -import atlantis.data.ACompositeParticleData; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.graphics.ADrawParameters; -import atlantis.graphics.ADrawable; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.list.AListManager; -import atlantis.output.AExceptionHandler; -import atlantis.parameters.AEnumeratorParameter; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjection; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjection3D; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionXZ; -import atlantis.projection.AProjectionYX; -import atlantis.projection.AProjectionYZ; -import atlantis.utils.A4Vector; -import atlantis.utils.AHashMap; -import atlantis.utils.AIntHashtable; -import atlantis.utils.AMath; -import atlantis.list.AListProcessor; -import atlantis.utils.ALogger; - -/** - * Base class which holds the data from a subdetector (e.g. TRT) This - * representation is appropriate for data with a static number of entries but - * not for example for reconstructed vertices the number of which may be changed - * interactively by the user. AData should perhaps become an interface. - */ -abstract public class AData implements ADrawable, AListProcessor { - private static final ALogger logger = ALogger.getLogger(AData.class); //the event that this data belongs to - protected static AEventManager eventManager = AEventManager.instance(); - protected static APar parameterStore = APar.instance(); - protected static Component guiComponent = AGlobals.instance().getGuiFrame(); - protected final AEvent event; - protected static final int NO_INVERSE = -1; - protected int numData; - protected int numDraw; - protected int[] listdl; - protected byte[] color; - protected int[] id; - protected AIntHashtable indexFromId; - protected String storeGateKey = null; - protected final String PARAMETER_GROUP = getParameterGroup(); - - abstract protected int internalColor(); - - abstract protected void applyCuts(); - - abstract public String getNameScreenName(); - - abstract public String getHitInfo(int index); // pick info - - abstract public String getParameterGroup(); - // Holds the projection object that we are currently drawing on. This is *NOT* the same - // as ACanvas.getCanvas().getCurrentWindow().getProjection(), since this function gives - // the projection in the active window. Particularly at startup windows will be redrawn - // without being the active window. Hence this variable. - // - // By the way: this is also inherently bad design. Why does the data need - // to know about the projection? The main flaw is that the data draws itself, - // rather then the graphics context drawing the data - S.B. - protected AProjection2D currentProjection; - - // dummy version, only applies to dynamic data sources (e.g. RecVertex (RVx)) - public void remove(int[] index) {} - - // used to finalize the state of this object - // after all other AData objects are essentially built - // e.g. calculate the number of S3D hits on a track after both are read - protected void finalizeConstruction() {} - - // x y and z are now stored - // rho and phi arrays are only correct after a call to this function - protected void calculateRhoPhi() {} - - // used by rubberband in V-Plot - public String getVPHitInfo() { - return ""; - } - - public AData(AHashMap p, AEvent e) { - //save reference to the event this data belongs to - event = e; - - numData = p.getInt("numData"); - numDraw = numData; - listdl = new int[numData]; - color = new byte[numData]; - - storeGateKey = (String) p.get("storeGateKey"); - if ("".equals(storeGateKey) || storeGateKey == null) { - storeGateKey = null; - } - - if (p.get("id") != null) { - id = p.getIntArray("id"); - } else { - id = new int[numData]; - for (int i = 0; i < numData; i++) { - // start IDs calculated in Atlantis from 0, should be the same - // as in JiveXML - id[i] = i; - } - } - - indexFromId = new AIntHashtable(id); - } // AData() - - AData(Node node, AEvent e) { - //save reference to the event this data belongs to - event = e; - numData = 0; - NodeList children = node.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { - numData++; - } - } - numDraw = numData; - listdl = new int[numData]; - color = new byte[numData]; - id = new int[numData]; - for (int i = 0; i < numData; i++) { - id[i] = i; - } - indexFromId = new AIntHashtable(id); - } - - public AEvent getEvent(){ - return event; - } - - public int getIndexFromId(int id) { - return indexFromId.get(id); - } - - public final A4Vector get4Vector() { - makeDrawList(); - return get4Vector(numDraw, listdl); - } - - // only applies to data which can provide 4 vectors - public A4Vector get4Vector(int num, int[] list) { - return null; - } - - // only applies to data which can provide 4 vectors - public A4Vector get4Vector(int num, int[] list, double mass) { - return null; - } - - public int getNumData() { - return numData; - } - - public int getNumDraw() { - return numDraw; - } - - public int getDrawIndex(int index) { - return this.listdl[index]; - } - - public int[] getID() { - return id; - } - - protected int getNum(String name, int index) { - int[][] ass = event.getAssociationManager().get(getFullName(), name); - if (ass != null && ass[index] != null) { - return ass[index].length; - } else { - return 0; - } - } - - protected int[] getNum(String name) { - int[][] ass = event.getAssociationManager().get(getFullName(), name); - int[] num = new int[numData]; - if (ass != null) { - for (int i = 0; i < ass.length; ++i) { - if (ass[i] != null) { - num[i] = ass[i].length; - } - } - } - return num; - } - - public byte[] getColor() { - color(); - byte[] temp = new byte[id.length]; - - for (int i = 0; i < temp.length; i++) { - temp[i] = color[getIndexFromId(id[i])]; - } - return temp; - } - - public int[] getColor(int[] dl) { - color(); - int[] temp = new int[dl.length]; - - for (int i = 0; i < temp.length; i++) { - temp[i] = color[dl[i]]; - } - return temp; - } - - public int getColor(int index){ - return color[index]; - } - - public void makeDrawList() { - calculateRhoPhi(); - constructDefaultDrawlist(); - applyCuts(); - } - - public void constructDefaultDrawlist() { - if (!parameterStore.get("CutsATLAS", "ByList").getStatus()) { - // if some hits are on a list they must be drawn last - int[][] temp = AListManager.getInstance().getColorMapping(this); - int[] index = temp[0]; - int[] ctemp = temp[1]; - if (index.length > 0) { - // AOutput.logln("AData.constructDefaultDrawlist() numData = " + - // numData); - int[] c = new int[numData]; - final int NONE = -999; - for (int i = 0; i < numData; ++i) { - c[i] = NONE; - } - for (int i = 0; i < index.length; ++i) { - c[index[i]] = ctemp[i]; - } - numDraw = 0; - for (int i = 0; i < numData; ++i) { - if (c[i] == NONE) { - listdl[numDraw++] = i; - } - } - for (int i = 0; i < numData; ++i) { - if (c[i] != NONE && c[i] != AColorMap.INVISIBLE) { - listdl[numDraw++] = i; - // nb invisible are not in the drawlist - } - } - } else { - // this is the standard case - numDraw = numData; - for (int i = 0; i < numDraw; ++i) { - listdl[i] = i; - } - } - } else { - // drawlist set by cuts..... - boolean[] selected = AListManager.getInstance().getSelection(this); - numDraw = 0; - for (int i = 0; i < selected.length; ++i) { - if (selected[i]) { - listdl[numDraw++] = i; - } - } - } - } - - // provides the draw list as a boolean array parallel to the data array - protected boolean[] isDrawn() { - boolean[] drawn = new boolean[numData]; - - for (int i = 0; i < numDraw; i++) { - drawn[listdl[i]] = true; - } - return drawn; - } - - public void cut(String groupName, String parameterName, String text, float[] array) { - AParameter par = parameterStore.get(groupName, parameterName); - - if (par != null && par.getStatus() && array != null) { - double value = par.getD(); - String operator = par.getOperator(); - int num = 0; - - if (par.isModulus()) { - if (operator.equals("<")) { - for (int i = 0; i < numDraw; i++) { - if (Math.abs(array[listdl[i]]) < value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals(">")) { - // '>' really means '>=' for reals since they are real in - // from ascii file and don't have full precison - for (int i = 0; i < numDraw; i++) { - if (Math.abs(array[listdl[i]]) >= value) { - listdl[num++] = listdl[i]; - } - } - } else { - throw new Error(operator + " operator not sensible for floats"); - } - } else { - if (operator.equals("<")) { - for (int i = 0; i < numDraw; i++) { - if (array[listdl[i]] < value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals(">")) { - // '>' really means '>=' for reals since they are real in - // from ascii file - // and don't have full precison - for (int i = 0; i < numDraw; i++) { - if (array[listdl[i]] >= value) { - listdl[num++] = listdl[i]; - } - } - } else { - throw new Error(operator + " operator not sensible for floats"); - } - } - numDraw = num; - } - } - - protected void cut(String groupName, String parameterName, String text, int[] array) { - AParameter par = parameterStore.get(groupName, parameterName); - - if (par != null && par.getStatus() && array != null) { - int value = par.getI(); - - // consider two special cases: Electron/isEM and Photon/isEM - if (parameterName.endsWith("isEM")) { - if (!isEMValidate(value)) { - return; - } - String binaryString = Integer.toBinaryString(value); - Vector<String> possibleValues = getPossibleValues(binaryString); - cutIsEM(text, array, possibleValues); - } else { - String operator = par.getOperator(); - boolean modulus = par.isModulus(); - - cut(text, modulus, array, operator, value); - } - } - } - - protected void cut(String text, int[] array, String operator, int value) { - cut(text, false, array, operator, value); - } - - protected void cut(String text, boolean modulus, int[] array, String operator, int value) { - int num = 0; - - if (modulus) { - if (operator.equals("<")) { - for (int i = 0; i < numDraw; i++) { - if (Math.abs(array[listdl[i]]) < value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals(">")) { - for (int i = 0; i < numDraw; i++) { - if (Math.abs(array[listdl[i]]) > value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals("=") || operator.equals("==")) { - for (int i = 0; i < numDraw; i++) { - if (Math.abs(array[listdl[i]]) == value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals("!=") || operator.equals(AMath.NOTEQUAL)) { - for (int i = 0; i < numDraw; i++) { - if (Math.abs(array[listdl[i]]) != value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals("<=") || operator.equals(AMath.LESSEQUAL)) { - for (int i = 0; i < numDraw; i++) { - if (Math.abs(array[listdl[i]]) <= value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals(">=") || operator.equals(AMath.GREATEREQUAL)) { - for (int i = 0; i < numDraw; i++) { - if (Math.abs(array[listdl[i]]) >= value) { - listdl[num++] = listdl[i]; - } - } - } else { - throw new Error(operator + " operator not sensible for integers"); - } - } else { - if (operator.equals("<")) { - for (int i = 0; i < numDraw; i++) { - if (array[listdl[i]] < value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals(">")) { - for (int i = 0; i < numDraw; i++) { - if (array[listdl[i]] > value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals("=") || operator.equals("==")) { - for (int i = 0; i < numDraw; i++) { - if (array[listdl[i]] == value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals("!=") || operator.equals(AMath.NOTEQUAL)) { - for (int i = 0; i < numDraw; i++) { - if (array[listdl[i]] != value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals("<=") || operator.equals(AMath.LESSEQUAL)) { - for (int i = 0; i < numDraw; i++) { - if (array[listdl[i]] <= value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals(">=") || operator.equals(AMath.GREATEREQUAL)) { - for (int i = 0; i < numDraw; i++) { - if (array[listdl[i]] >= value) { - listdl[num++] = listdl[i]; - } - } - } else { - throw new Error(operator + " operator not sensible for integers"); - } - } - numDraw = num; - } - - // cut based on the i'th item in the data array - public void cutIndex() { - AParameter par = parameterStore.get("CutsATLAS", "Index"); - - if (par.getStatus()) { - int value = par.getI(); - String operator = par.getOperator(); - int num = 0; - - if (operator.equals("<")) { - for (int i = 0; i < numDraw; i++) { - if (listdl[i] < value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals(">")) { - for (int i = 0; i < numDraw; i++) { - if (listdl[i] > value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals("=") || operator.equals("==")) { - for (int i = 0; i < numDraw; i++) { - if (listdl[i] == value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals("!=") || operator.equals(AMath.NOTEQUAL)) { - for (int i = 0; i < numDraw; i++) { - if (listdl[i] != value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals("<=") || operator.equals(AMath.LESSEQUAL)) { - for (int i = 0; i < numDraw; i++) { - if (listdl[i] <= value) { - listdl[num++] = listdl[i]; - } - } - } else if (operator.equals(">=") || operator.equals(AMath.GREATEREQUAL)) { - for (int i = 0; i < numDraw; i++) { - if (listdl[i] >= value) { - listdl[num++] = listdl[i]; - } - } - } else { - throw new Error(operator + " operator not sensible for integers"); - } - numDraw = num; - } - } - - protected void cutArray(int[] value, int cutValue, String description) { - int num = 0; - - for (int i = 0; i < numDraw; i++) { - - if (value[listdl[i]] == cutValue) { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - - protected void cutArray(byte[] value, int cutValue, String description) { - int num = 0; - - for (int i = 0; i < numDraw; i++) { - - if (value[listdl[i]] == cutValue) { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - - //isEMString cut declaration - // - // Clone of above cut, but to allow values less than or equal to the cut value - // At the moment, Specific to isEMString for Electrons and Photons, and isTauString. - // - protected void cutArrayEnum(Vector<Enum> value, int cutValue, String description) { - int num = 0; - - for (int i = 0; i < numDraw; i++) { - if ((value.get(listdl[i]).ordinal()) <= cutValue) { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - // End isEMString cut declaration - - protected void cutArray(boolean[] value, boolean cutValue, String description) { - int num = 0; - - for (int i = 0; i < numDraw; i++) { - if (value[listdl[i]] == cutValue) { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - - protected void cutArrayOR(int[] value, int cutValue1, int cutValue2, - String description) { - int num = 0; - - for (int i = 0; i < numDraw; i++) { - if (value[listdl[i]] == cutValue1 || value[listdl[i]] == cutValue2) { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - - // apply phi+-deltaphi cut to lines (e.g. TRT) - protected void cutPhi(float[] phi, float[] dphi) { - AParameter par = parameterStore.get("CutsATLAS", "CutPhi"); - - if (!par.getStatus()) { - return; - } - double phiCut = Math.toRadians(par.getD()); - double phiMid = Math.toRadians(AMath.nearestPhiDegrees(parameterStore.get("CutsATLAS", "PhiMiddle").getD())); - double phiLowerCut = phiMid - phiCut; - double phiUpperCut = phiMid + phiCut; - int num = 0; - - for (int i = 0; i < numDraw; i++) { - int list = listdl[i]; - double phiHit = AMath.nearestPhiRadians(phi[list], phiMid); - double phiLower = phiHit - dphi[list]; - double phiUpper = phiHit + dphi[list]; - - if (phiUpper - phiLowerCut > 1.0e-6 && phiUpperCut - phiLower > 1.0e-6) { - listdl[num++] = list; - } - } - numDraw = num; - } - - /** Apply phi+-deltaphi cut to points (e.g. S3D) */ - public void cutPhi(float[] phi) { - AParameter par = parameterStore.get("CutsATLAS", "CutPhi"); - boolean usePhiCut = par.getStatus(); - - if (usePhiCut) { - double phiCut = Math.toRadians(Math.abs(par.getD())); - double phiMid = Math.toRadians(AMath.nearestPhiDegrees(parameterStore.get("CutsATLAS", "PhiMiddle").getD())); - int num = 0; - - for (int i = 0; i < numDraw; i++) { - double phiDiff = Math.abs(AMath.nearestPhiRadians(phi[listdl[i]], phiMid) - phiMid); - - if (phiCut - phiDiff > 1.0e-6) { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - - } - - /** apply eta+-deltaeta cut to points (e.g. S3D) */ - public void cutEta(float[] eta) { - AParameter par = parameterStore.get("CutsATLAS", "CutEta"); - boolean useEtaCut = par.getStatus(); - - if (useEtaCut) { - double etaCut = Math.abs(par.getD()); - double etaMid = parameterStore.get("CutsATLAS", "EtaMiddle").getD(); - int num = 0; - - for (int i = 0; i < numDraw; i++) { - double etaDiff = Math.abs(eta[listdl[i]] - etaMid); - - if (etaCut - etaDiff > 1.0e-6) { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - } - - protected void colorByConstant() { - if (!PARAMETER_GROUP.equals("CompositeParticle")) { - int constantColor = parameterStore.get(PARAMETER_GROUP, "Constant").getI(); - - for (int i = 0; i < numData; i++) { - color[i] = (byte) constantColor; - } - } else { - ACompositeParticleData compositeParticles = (ACompositeParticleData) this; - compositeParticles.makeDrawList(); - for (int e = 0; e < compositeParticles.getNumDraw(); ++e) { - int list = compositeParticles.getDrawIndex(e); - switch (Math.abs(compositeParticles.getPdgId(list))) { - case 13: - color[list] = (byte) parameterStore.get("Muon", "Constant").getI(); - break; - case 11: - color[list] = (byte) parameterStore.get("Electron", "Constant").getI(); - break; - case 22: - color[list] = (byte) parameterStore.get("Photon", "Constant").getI(); - break; - case 5: - color[list] = (byte) parameterStore.get("BJet", "Constant").getI(); - break; - case 15: - color[list] = (byte) parameterStore.get("TauJet", "Constant").getI(); - break; - case 24: - color[list] = (byte) parameterStore.get("CompositeParticle", "ConstantW").getI(); - break; - case 6: - color[list] = (byte) parameterStore.get("CompositeParticle", "ConstantTop").getI(); - break; - case 25: - color[list] = (byte) parameterStore.get("CompositeParticle", "ConstantH").getI(); - break; - - default: - if (compositeParticles.getTypeEV(list).equals("EVParticleJet")) { - color[list] = (byte) parameterStore.get("Jet", "Constant").getI(); - } else { - color[list] = (byte) parameterStore.get("CompositeParticle", "Constant").getI(); - } - } - } - } - } - - - /** Colour by index. - * e.g. colorByIndex(indexBy(phi)); - * will allow nearby phi tracks to be coloured differently. - * @param index - */ - protected void colorByIndex(int[] index) { - int numColors = parameterStore.get("HitColors", "Number").getI(); - - numColors = Math.min(7, numColors); - int[] col = parameterStore.getArray("HitColors", "C1", numColors); - for (int i = 0; i < numData; i++) { - color[index[i]] = (byte) col[i % numColors]; - } - } - - protected void colorByIndex() { - int numColors = parameterStore.get("HitColors", "Number").getI(); - - numColors = Math.min(7, numColors); - int[] col = parameterStore.getArray("HitColors", "C1", numColors); - for (int i = 0; i < numData; i++) { - color[i] = (byte) col[i % numColors]; - } - } - - protected void colorByCollection() { - int constantColor = parameterStore.get(PARAMETER_GROUP, "Constant").getI(); - int numColors = parameterStore.get("HitColors", "Number").getI(); - int[] col = parameterStore.getArray("HitColors", "C1", numColors); - AEvent ev = eventManager.getCurrentEvent(); - // vector with store gate keys for a particular datatype name: this.getName() - Vector<String> v = ev.getCollections().get(this.getName()); - int keyIndex = 0; - if (v != null && (keyIndex = v.indexOf(this.getStoreGateKey())) != -1) { - // v is null - requested datatype name doesn't exists in the current - // event - - // if keyIndex is -1 it means the current - // store gate key doesn't exists in the current event (for a datatype - // which exists in the current event) - // previous event(s) are being drawn and this colouring function - // won't work for them but only for the current event - - // constant colour index is used purely as modifier so as all datatypes - // coloured by colletictions don't start at the same colour ... - keyIndex += constantColor; - for (int i = 0; i < numData; i++) { - color[i] = (byte) col[keyIndex % numColors]; - } - } else { - logger.debug("colorByCollection(): can't colour by collection"); - } - - } // colorByCollection() ------------------------------------------------ - - /** - * Colour another class by association. This class is providing the colour, - * we assign colours from the local class to the target using col[] and id[][]. - * - * @param col target class colour array - * @param id association array from this class to the target class - * @param unconnectedColor colour for unconnected hits - * @param sharedColor colour for shared hits - */ - protected void colorByAssociation(AData target, int[][] id, - byte unconnectedColor, byte sharedColor) { - - // All hits are unconnected by default - for (int i=0; i<target.color.length; i++) { - target.color[i] = unconnectedColor; - } - - if (id == null) return; - - // Loop over drawn objects in this class, then colour the other elements - // that are associated. i iterates over the drawn items, j is the true - // index and k refers to an associated item in the target class, with true - // index l. - for (int i=0; i<numDraw; i++) { - int j = listdl[i]; - - if (id[j] != null) { - for (int k = 0; k < id[j].length; k++) { - int l = target.getIndexFromId(id[j][k]); - - if (l < 0) continue; - - if (target.color[l] != unconnectedColor) { - // If item l was already connected, that means it is shared - target.color[l] = sharedColor; - } else { - // Assign associated item l the colour of item j in the local class - target.color[l] = this.color[j]; - } - } - } - } - } // colorByAssociation() ----------------------------------------------- - - protected void setColor(int index, byte color) { - if (index >= 0 && index < this.color.length) { - this.color[index] = color; - } else { - logger.debug(getClass().getName() + ": Set color for data with index = " + index); - } - } - - protected void setColor(byte color) { - for (int i = 0; i < this.color.length; i++) { - this.color[i] = color; - } - } - - protected void colorBy(int[] coloringVariable) { - int numColors = parameterStore.get("HitColors", "Number").getI(); - - numColors = Math.min(7, numColors); - int[] col = parameterStore.getArray("HitColors", "C1", numColors); - - for (int i = 0; i < numData; i++) { - color[i] = (byte) col[coloringVariable[i] % numColors]; - } - } - - protected void colorBy(String colorGroup, int[] coloringVariable) { - int numColors = parameterStore.get(colorGroup, "Number").getI(); - - numColors = Math.min(7, numColors); - int[] col = parameterStore.getArray(colorGroup, "C1", numColors); - - for (int i = 0; i < numData; i++) { - color[i] = (byte) col[coloringVariable[i] % numColors]; - } - } - - protected void colorBy(float[] Pt) { - int numColors = parameterStore.get("HitColors", "Number").getI(); - - numColors = Math.min(7, numColors); - int[] col = parameterStore.getArray("HitColors", "C1", numColors); - for (int i = 0; i < numData; i++) { - int icol = 0; - if (Math.abs(Pt[i]) < 2) { - icol = 4; //lichtblauw - } else if (Math.abs(Pt[i]) < 4) { - icol = 2; //blauw - } else if (Math.abs(Pt[i]) < 10) { - icol = 5; //paars - } else if (Math.abs(Pt[i]) < 40) { - icol = 3; //oranje - } else { - icol = 0; //rood - } - color[i] = (byte) col[icol]; - } - } - - public String getName() { - return getParameterGroup(); - } - - public String getStoreGateKey() { - return storeGateKey; - } - - // x y from rho phi - protected void calculateXY(float[] rho, float[] phi, float[] x, float[] y) { - for (int i = 0; i < x.length; ++i) { - x[i] = (float) (rho[i] * Math.cos(phi[i])); - y[i] = (float) (rho[i] * Math.sin(phi[i])); - } - } - - /** Calculate rho phi from x y */ - protected void calculateRhoPhi(float[] x, float[] y, float[] rho, float[] phi) { - // [2007-07-20] method is again always called from AData.makeDrawList() - // but reference to primary vertex is removed, it's not taken into account now - // double[] pVtx = Atlantis.getEventManager().getCurrentEvent().getPrimaryVertex(); - // double dx = x[i] - pVtx[0]; - // double dy = y[i] - pVtx[1]; - - for (int i = 0; i < rho.length; i++) { - double dx = x[i]; - double dy = y[i]; - - rho[i] = (float) (Math.sqrt(dx * dx + dy * dy)); - phi[i] = (float) (Math.atan2(dy, dx)); - if (phi[i] < 0.) { - phi[i] += AMath.TWO_PI; - } - } - } - - /** Draw the data form this detector on this window and projection */ - public void draw(AWindow window, AGraphics ag, AProjection2D projection) { - ag.draw(window.calculateDisplay(getUser(projection))); - } - - /** Get the data from a projection without non linear transform applied. - * @param projection - * @return - */ - protected ACoord getUserNoTransform(AProjection projection) { - ACoord data = ACoord.NO_DATA; - // don't use reflection as debugging is then harder - if (projection instanceof AProjectionYX) { - data = getYXUser(); - } else if (projection instanceof AProjectionFR) { - data = getFRUser(); - } else if (projection instanceof AProjectionRZ) { - data = getRZUser(); - } else if (projection instanceof AProjectionXZ) { - data = getXZUser(); - } else if (projection instanceof AProjectionYZ) { - data = getYZUser(); - } else if (projection instanceof AProjectionFZ) { - data = getFZUser(); - } else if (projection instanceof AProjectionVP) { - data = getVPUser(); - } else if (projection instanceof AProjection3D) { - data = get3DUser(); - } - - return data; - } - - /** Get the data form a projection with non linear transform applied. */ - protected ACoord getUser(AProjection2D projection) { - currentProjection = projection; - return projection.nonLinearTransform(getUserNoTransform(projection)); - } - - /** Should the polygon from this detector be drawn or filled? */ - protected int getDrawOrFill() { - return AGraphics.DRAW; - } - - /** - * Prints info about association in which AData:index participates - * (pick + n (navigate) - * @param index int - * @return String - */ - public String navigate(int index) { - StringBuilder temp = new StringBuilder(); - String assocKey = getFullName(); - String[] knownAssoc = event.getAssociationManager().getKnownAssociations(assocKey); - temp.append(" associated to:\n"); - for (int i = 0; i < knownAssoc.length; i++) { - AData source = eventManager.getCurrentEvent().get(knownAssoc[i]); - if (source == null) continue; - int[][] ass = event.getAssociationManager().get(assocKey, knownAssoc[i]); - if (ass != null && ass[index] != null) { - for (int x = 0; x < ass[index].length; x++) { - temp.append(" " + knownAssoc[i] + " id: " + ass[index][x] + - " index: " + source.getIndexFromId(ass[index][x]) + "\n"); - } - } - } - return temp.toString(); - - } // navigate() --------------------------------------------------------- - - private boolean isEMValidate(int inputValue) { - if (inputValue > 65535) { - String displayMessage = "isEM is a 16-bit binary data, maximum is 65535"; - AExceptionHandler.processException("warning", displayMessage.toString()); - return false; - } - return true; - } - - // "1" means a wildcard, can be "0" or "1" - private Vector<String> getPossibleValues(String bStr) { - Vector<String> possibleValues = new Vector<String>(); - if (bStr.length() == 1) { - possibleValues.add("0"); - if (bStr.charAt(0) == '1') { - possibleValues.add("1"); - } - } else { - Vector<String> possibleValuesWithoutFirstChar = getPossibleValues(bStr.substring(1)); - for (int i = 0; i < possibleValuesWithoutFirstChar.size(); i++) { - String str = possibleValuesWithoutFirstChar.get(i); - possibleValues.add("0" + str); - if (bStr.charAt(0) == '1') { - possibleValues.add("1" + str); - } - } - - } - return possibleValues; - } - - private void cutIsEM(String text, int[] array, Vector<String> possibleValues) { - int num = 0; - - for (int i = 0; i < numDraw; i++) { - for (int j = 0; j < possibleValues.size(); j++) { - String str = possibleValues.get(j); - int value = Integer.parseInt(str, 2); - if (array[listdl[i]] == value) { - listdl[num++] = listdl[i]; - break; - } - } - } - - numDraw = num; - } - - /** - * Track name + Track storeGateKey is returned according to selected - * Track collection in InDet -> Track -> TrackCollection listbox - * @return String - */ - protected String getReconstructedTracks() { - AData tracks = eventManager.getCurrentEvent().getTrackData("InDetTrack"); - String r = null; - if (tracks != null) { - r = tracks.getName() + tracks.getStoreGateKey(); - } - - return r; - - } // getReconstructedTracks() --------------------------------------------- - - /** - * Jet + Jet storeGateKey is returned according to selected - * Jet collection in ATLAS -> Jet -> JetCollection listbox - * @return String - */ - protected String getJets() { - AData jets = eventManager.getCurrentEvent().getJetData(); - String r = null; - if (jets != null) { - r = jets.getName() + jets.getStoreGateKey(); - } - - return r; - - } // getJets() ---------------------------------------------------------- - - /** - * RVx + RVx storeGateKey is returned according to selected - * vertex collection in InDet -> RecVertex -> VerteCollection listbox - * @return String - */ - protected String getRVx() { - AData rvx = eventManager.getCurrentEvent().getRVxData(); - String r = null; - if (rvx != null) { - r = rvx.getName() + rvx.getStoreGateKey(); - } - - return r; - - } // getRVx() ---------------------------------------------------------- - - protected AData getObjectCollection(String type) { - return eventManager.getCurrentEvent().getData(type); - } - - /** - * Cluster + Cluster storeGateKey is returned according to selected - * Cluster collection in Calo -> Cluster -> Cluster listbox - * @return String - */ - protected String getClusters() { - AData clusters = eventManager.getCurrentEvent().getClusterData(); - String r = null; - if (clusters != null) { - r = clusters.getName() + clusters.getStoreGateKey(); - } - - return r; - - } // getClusters() ------------------------------------------------------ - - public int[] getDrawList() { - return listdl; - - } // getDrawList() ------------------------------------------------------ - - /** Apply eta+-deltaEta cut to points (e.g. S3D) */ - protected void cutEta(float[] rho, float[] z) - { - AParameter par = parameterStore.get("CutsATLAS", "CutEta"); - boolean useEtaCut = par.getStatus(); - - if(useEtaCut) - { - double etaCut = Math.abs(par.getD()); - double etaMid = parameterStore.get("CutsATLAS", "EtaMiddle").getD(); - double etaLower = etaMid - etaCut; - double etaUpper = etaMid + etaCut; - int num = 0; - - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double eta = AParameterUtilities.eta(z[list], rho[list]); - - if(eta - etaLower > 1.0e-6 && etaUpper - eta > 1.0e-6) - listdl[num++] = list; - } - numDraw = num; - } - } - - - /** Apply eta+-deltaEta cut to lines perpendicular to beam axis */ - protected void cutEtaDRho(float[] rho, float[] z, float[] drho) - { - AParameter par = parameterStore.get("CutsATLAS", "CutEta"); - boolean useEtaCut = par.getStatus(); - - if(useEtaCut) - { - double etaCut = Math.abs(par.getD()); - double etaMid = parameterStore.get("CutsATLAS", "EtaMiddle").getD(); - double etaLowerCut = etaMid - etaCut; - double etaUpperCut = etaMid + etaCut; - int num = 0; - - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double eta1 = AParameterUtilities.eta(z[list], rho[list] + drho[list]); - double eta2 = AParameterUtilities.eta(z[list], rho[list] - drho[list]); - double etaLower = Math.min(eta1, eta2); - double etaUpper = Math.max(eta1, eta2); - - if(etaUpper - etaLowerCut > 1.0e-6 - && etaUpperCut - etaLower > 1.0e-6) - listdl[num++] = list; - } - numDraw = num; - } - } - - /** Apply eta+- deltaEta cut to lines parallel to beam axis */ - protected void cutEtaDZ(float[] rho, float[] z, float[] dz) - { - AParameter par = parameterStore.get("CutsATLAS", "CutEta"); - boolean useEtaCut = par.getStatus(); - - if(useEtaCut) - { - double etaCut = Math.abs(par.getD()); - double etaMid = parameterStore.get("CutsATLAS", "EtaMiddle").getD(); - double etaLowerCut = etaMid - etaCut; - double etaUpperCut = etaMid + etaCut; - int num = 0; - - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double etaLower = AParameterUtilities.eta(z[list] - dz[list], rho[list]); - double etaUpper = AParameterUtilities.eta(z[list] + dz[list], rho[list]); - - if(etaUpper - etaLowerCut > 1.0e-6 - && etaUpperCut - etaLower > 1.0e-6) - listdl[num++] = list; - } - numDraw = num; - } - } - - /** apply eta+-deltaeta cut to lines (e.g. TRT) */ - protected void cutEtaDEta(float[] eta, float[] deta) - { - AParameter par = parameterStore.get("CutsATLAS", "CutEta"); - - if(!par.getStatus()) - return; - double etaCut = Math.abs(par.getD()); - double etaMid = parameterStore.get("CutsATLAS", "EtaMiddle").getD(); - double etaLowerCut = etaMid - etaCut; - double etaUpperCut = etaMid + etaCut; - int num = 0; - - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - double etaLower = eta[list] - deta[list]; - double etaUpper = eta[list] + deta[list]; - - if(etaUpper - etaLowerCut > 1.0e-6 - && etaUpperCut - etaLower > 1.0e-6) - listdl[num++] = list; - } - numDraw = num; - - } - - - - /** - * - * @param sourceDatatype name of the datatype according to - * which the cut is being done - * @param beingCutDatatype name of the datatype which is - * being cut - * @param cutOption integer value of the cut option in GUI - */ - protected void cutByAssociationTo(String sourceDatatype, - String beingCutDatatype, int cutOption) - { - if(cutOption == 0) - { - // SA select all - // do nothing, draw everything - return; - } - - AEvent ev = eventManager.getCurrentEvent(); - AData source = ev.get(sourceDatatype); - int[][] assoc = event.getAssociationManager().get(beingCutDatatype, sourceDatatype); - if (assoc == null || source == null) { - AData being = ev.get(beingCutDatatype); - String screenName; - if(being!=null)screenName= being.getNameScreenName(); - else screenName="null"; - logger.warn(screenName + " - null (" + beingCutDatatype + " - " - + sourceDatatype +") association, nothing to draw"); - // if 'connected' or 'unconnected' is selected and association - // or datatype to associate with doesn't exist, draw nothing - // (numDraw = 0) - numDraw = 0; - return; - } - - if(cutOption == 1) - { - // SC select connected - int num = 0; - // first remove those not connected to anything - for(int i = 0; i < numDraw; i++) - { - if(assoc[listdl[i]] != null) - { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - // if tracks exist apply cuts to them - numDraw = source.cutByAssociation(numDraw, listdl, assoc); - } - else if(cutOption == 2) - { - // SU select unconnected - int num = 0; - for(int i = 0; i < numDraw; i++) - { - if(assoc[listdl[i]] == null) - { - listdl[num++] = listdl[i]; - } - } - numDraw = num; - } - - } // cutByAssociationTo() ----------------------------------------------- - - - - private int cutByAssociation(int numDraw, int[] listdl, int[][] id) - { - // aaargh danger modifies input listdl - makeDrawList(); - boolean[] drawn = isDrawn(); - int num = 0; - - for(int i = 0; i < numDraw; i++) - { - int list = listdl[i]; - if(id[list] != null) - { - for(int j = 0; j < id[list].length; ++j) - { - int inverse = indexFromId.get(id[list][j]); - if(inverse != NO_INVERSE && drawn[inverse]) - listdl[num++] = list; - break; - } - } - } - numDraw = num; - return numDraw; - } - - /** - * return graphics attributes corresponding to layer =0 frame layer =1 hits - * or tracks type=0 noise type=1 non-noise - */ - public ADrawParameters getDrawParameters(int layer, int type) - { - boolean draw = true; - int singleColor = -1; - int size = 10; - int lineWidth = 1; - int symbol = 0; - int frameWidth = 0; - boolean forceSymbols = false; - int minSize = 0; - - AParameter forceSymbolsPar = parameterStore.getUnknown(PARAMETER_GROUP, "ForceSymbols"); - AParameter symbolSize = parameterStore.getUnknown(PARAMETER_GROUP, "SymbolSize"); - AParameter symbolType = parameterStore.getUnknown(PARAMETER_GROUP, "Symbol"); - AParameter lineWidthPar = parameterStore.getUnknown(PARAMETER_GROUP, "LineWidth"); - - if(forceSymbolsPar != null) - { - forceSymbols = forceSymbolsPar.getStatus(); - if(forceSymbols && symbolSize != null) - minSize = Math.max(symbolSize.getI(), 1); - } - - if(symbolSize != null) - size = symbolSize.getI(); - if(symbolType != null) - symbol = symbolType.getI(); - if(lineWidthPar != null) - lineWidth = lineWidthPar.getI(); - //for etmiss, line width scaled by energy by using the stroke setting - if(lineWidth<=0) - lineWidth = 1; - - if(type == 0) - { - AParameter noiseSymbolType = parameterStore.getUnknown(PARAMETER_GROUP, "Noise"); - - if(noiseSymbolType != null && noiseSymbolType.getStatus()) - { - AParameter noiseSymbolSize = parameterStore.getUnknown(PARAMETER_GROUP, "NoiseSize"); - AParameter noiseWidth = parameterStore.getUnknown(PARAMETER_GROUP, "NoiseWidth"); - - if(noiseSymbolSize != null) - size = noiseSymbolSize.getI(); - if(noiseWidth != null) - lineWidth = noiseWidth.getI(); - symbol = noiseSymbolType.getI(); - } - else - { - AParameter noiseWidth = parameterStore.getUnknown(PARAMETER_GROUP, "NoiseWidth"); - - if(noiseWidth != null && noiseWidth.getStatus()) - lineWidth = noiseWidth.getI(); - } - } - - if(layer == 0) - { - AParameter frameWidthPar = parameterStore.getUnknown(PARAMETER_GROUP, "FrameWidth"); - if(parameterStore.get(PARAMETER_GROUP, "Frame")!=null) - { - boolean drawFrame = parameterStore.get(PARAMETER_GROUP, "Frame").getStatus(); - singleColor = parameterStore.get(PARAMETER_GROUP, "Frame").getI(); - //only draw frames for Grey/BW color maps if is selected to draw frames - if(drawFrame && AColorMap.drawFrames()) - { - if(frameWidthPar != null) - frameWidth = frameWidthPar.getI(); - } - } - } - return new ADrawParameters(draw, singleColor, size, lineWidth, - frameWidth, symbol, forceSymbols, minSize, getDrawOrFill()); - } - - /** Provide an array of indices with increasing a, - * used e.g. by coloring. - * @param a - * @return - */ - protected int[] indexBy(double[] a) - { - int[] index = new int[a.length]; - - for(int i = 0; i < a.length; i++) - index[i] = i; - // this is only cosmetic improvement in appearance so if input data too - // large simply return null - if(a.length > 1000) - return index; - - for(int i = 0; i < a.length - 1; i++) - for(int j = i + 1; j < a.length; j++) - if(a[index[i]] > a[index[j]]) - { - int temp = index[i]; - index[i] = index[j]; - index[j] = temp; - } - return index; - } - - /** - * Colour items in this class by the associated class that is given by - * association. The difference with the method colorByAssociation is that - * colorBy is called on the target class, while colorByAssociation is called - * on the source class of the colour. (i.e. colour hits by tracks invokes - * AHitData.colorBy("Tracks"), calling ATrackData.colourByAssociation(...) - * internally. - * - * @param otherClass source class for the colours - */ - protected void colorBy(String otherClass) - { - AData source = eventManager.getCurrentEvent().get(otherClass); - byte unconnected = (byte) parameterStore.get(PARAMETER_GROUP, "Unconnected").getI(); - if(source != null) - { - byte shared = (byte) parameterStore.get(PARAMETER_GROUP, "Shared").getI(); - String assocKey = getFullName(); - int[][] assoc = event.getAssociationManager().get(otherClass, assocKey); - source.makeDrawList(); - source.color(); - source.colorByAssociation(this, assoc, unconnected, shared); - - } - else - { - /* - * given association doesn't exist. for instance, there are only - * hits in the event file and nothing to associate them with. - * if some 'association colouring' (e.g. colour by reconstructed - * track) is selected in that case, the items appear all in - * 'unconnected' colour. another option is to colour them in - * constant colour, simply by calling only colorByConstant(); - */ - for(int i = 0; i < numData; i++) - { - color[i] = (byte) unconnected; - } - } - - } // colorBy() ---------------------------------------------------------- - - protected void colorByObjects() - { - // initially set all with unconnected color, connected will be changed later - byte unconnectedColor = (byte) parameterStore.get(PARAMETER_GROUP, "Unconnected").getI(); - setColor(unconnectedColor); - String[] objectList = new String[] {"Jet", "BJet", "TauJet", "Photon", "Electron", "Muon"}; - for(int i=0; i<objectList.length; ++i) - { - if (parameterStore.get("Data", objectList[i]).getStatus()) - colorByObject(getObjectCollection(objectList[i])); - } - } - - private void colorByObject(AData objectData) - { - if(objectData == null) - { - return; - } - - AEnumeratorParameter listBox = (AEnumeratorParameter) parameterStore.get(getName(), getName() + "Collections"); - String selectedCollection = listBox.getCurrentText(); - if(!("All".equals(selectedCollection) || "None".equals(selectedCollection))) - { - String assName = getName(); - if(getName().indexOf("Track") >= 0) - assName = "Track"; - AAssociation assoc = event.getAssociationManager().getAssociation(objectData.getName()+objectData.getStoreGateKey(), assName); - if(assoc != null) - { - if(!(assoc instanceof AObjectsAssociation)) - { - logger.warn(getClass().getName() + ": no objects association is found!"); - return; - } - int[][] associatedIndex = ((AObjectsAssociation) assoc).getData(); - String[] associatedKey = ((AObjectsAssociation) assoc).getKey(); - - // if currently selected collection is included in associatedKey, show associations - // otherwise using the color set for unconnected cluster/track - int objectIndex = 0; - for(int i=0; i<associatedKey.length;) - { - // objectIndex is the index of the associated object (e.g. Electron) - // associatedIndex[objectIndex][] contain the index of the associated Cluster/Track - if ("none".equals(associatedKey[i])) - { - i++; - objectIndex++; - } - else - { - if (associatedKey[i].equals(selectedCollection)) - for(int j=0; j<associatedIndex[objectIndex].length; ++j) - setColor(associatedIndex[objectIndex][j], objectData.getColor()[objectIndex]); - i+=associatedIndex[objectIndex++].length; - } - } - } - } - } - - /** - * The same as name, but if it's multiple collection datatype, the full - * name is getName() + getStoreGateKey() - * @return String - */ - public String getFullName() - { - String k = this.getStoreGateKey(); - String full = this.getName() + (k != null ? k : ""); - return full; - } - - public int getIdFromIndex(int index) - { - return id[index]; - } - - // sets the color of each hit - protected final void color() - { - // standard scheme - internalColor(); - int[][] temp = AListManager.getInstance().getColorMapping(this); - int[] index = temp[0]; - int[] c = temp[1]; - // now add in colors specified in lists - - for(int i = 0; i < index.length; ++i) - if(c[i] >= 0) - color[index[i]] = (byte) c[i]; - int others = AListManager.getInstance().getColorOfOthers(); - // need to check if this data could have been picked - // so that coloring of hits by STr works even if STr - // is not in list because it wasn't on.... - if(others >= 0 && parameterStore.get("Data", getName()).getStatus()) - { - boolean[] inList = new boolean[numData]; - for(int i = 0; i < index.length; ++i) - inList[index[i]] = true; - - for(int i = 0; i < numData; ++i) - if(!inList[i]) - color[i] = (byte) others; - } - - - - } - - - /** Type = e.g. noise/good */ - public int[] getType(int[] dl) - { - return new int[dl.length]; - } - - // get data representation in user space in different projections - // empty by default - protected ACoord getYXUser() - { - return ACoord.NO_DATA; - } - - protected ACoord getRZUser() - { - return ACoord.NO_DATA; - } - - protected ACoord getYZUser() - { - return ACoord.NO_DATA; - } - - protected ACoord getXZUser() - { - return ACoord.NO_DATA; - } - - protected ACoord get3DUser() - { - return ACoord.NO_DATA; - } - - protected ACoord getUserUser() - { - return ACoord.NO_DATA; - } - - protected ACoord getUserUser2() - { - return ACoord.NO_DATA; - } - - protected ACoord getFRUser() - { - return ACoord.NO_DATA; - } - - protected ACoord getFZUser() - { - return ACoord.NO_DATA; - } - - protected ACoord getVPUser() - { - return ACoord.NO_DATA; - } - - public int getNumTypes() - { - return 1; - } - - - /** The only method from AListProcessor interface. */ - @Override - public Action[] getActions(Collection nodes) - { - return new Action[0]; - } // getActions() ------------------------------------------------------- - - /** - * Function to split a list of items seperated by - - */ - public String[] splitItems(String origItems) - { - char[] origItemsChar = origItems.toCharArray(); - int origItemsLength = origItems.length(); - int spacePosition=0, noOfItems=0, count=0; - //calculate the number of items - for(int i=0;i<origItemsLength;i++) - if((i!=0 && origItemsChar[i]=='-') || (i==origItemsLength-1 && origItemsChar[i]!='-')) - noOfItems++; - //split up the array into newItems - if(noOfItems>0) - { - //string array to hold individual items - String[] newItems=new String[noOfItems]; - for(int i=0;i<origItemsLength;i++) - { - if(i==0 && origItemsChar[i]=='-') - spacePosition=i+1;//ignore first'-' - else if(i==origItemsLength-1 && origItemsChar[i]!='-') - { - //store the text from previous '-' upto end if doesn't end with '-' - newItems[count]=origItems.substring(spacePosition,i+1); - spacePosition=i+1; - count++; - } - else if(origItemsChar[i]=='-' && i!=0) - { - //store the text from previous '-' upto current '-' - newItems[count]=origItems.substring(spacePosition,i); - spacePosition=i+1; - count++; - } - } - return newItems; - } - else - return null; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AEpsImageProducer.java b/graphics/AtlantisJava/src/atlantis/event/AEpsImageProducer.java deleted file mode 100644 index eef4e9615f1f0c40179c97dde9f1eb44d311f220..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AEpsImageProducer.java +++ /dev/null @@ -1,117 +0,0 @@ -package atlantis.event; - -import java.io.File; -import java.io.IOException; - -import atlantis.utils.*; -import atlantis.canvas.ACanvas; -import atlantis.graphics.encoders.AImageEncoder; -import java.awt.Dimension; - - -/** - * Implements ANewEventListener and creates EPS files - * upon each newEvent call. A scale factor allows to e.g. produce thumbnails by - * scaling down image. The image producer works in two modes: - * a) If no file name is given, a file name will be generated from run and event - * number. In case the output file exists, no file is created but a warning is written out. - * b) If a file name is given, a temporary file is generated first, and then - * renamed to the given file name. If renaming fails, a warning is written out - * and the temporary file is deleted. - * - * @author Sebastian Boeser - */ - -public class AEpsImageProducer extends AImageProducer -{ - // the logger - private static final ALogger logger = ALogger.getLogger(AEpsImageProducer.class); - - // Our image encode - private final AImageEncoder imageEncoder = new AImageEncoder(); - - /** - * Fully qualified constructor, - * intializing all the attributes and check the parameters validity - * @param dir the directory in which to save all the files - * @param size the dimensions of the images - * @param scale the factor by which to scale the images - * @param fileName if not null, that file will be overwritten for each event - * @throws InstantiationException if we fail to create the object - */ - public AEpsImageProducer(String dir, Dimension size, double scale, String fileName) throws InstantiationException - { - super(dir, size, scale, fileName); - } - - /** - * Called whenever a new event appears. Store an EPS in the directory, - * either with a generated file name (no overwrite) or with a fixed file name (overwrite) - * @param event the event from which to generate the EPS - */ - public void newEvent(AEvent event) - { - - //If auto had been set for size (height is negative), get height from Canvas - if (imageSize.height < 0) imageSize.setSize(imageSize.width, ACanvas.getCanvas().getRespectiveHeight(imageSize.width)); - - //Create the file to write the data into - File outFile; - //If we don't have a fixed file name, - //generate a unique one based on run- and event number - if (fixedFileName==null){ - - //Now construct all the full path for the file we want to save - String outFileName = String.format("%s%s%s.eps",directory, - System.getProperty("file.separator"), - getEventFileName(event)); - - // Create file handles to the file and check if it exists - outFile = new File(outFileName); - //Do not overwrite any existing files - if (outFile.exists()) { - logger.warn("File "+ outFileName +" already exists - will not overwrite"); - return; - } - //otherwise generate a temporary file first, - //then move it in place later - } else { - //make a temporary file in the final directory - try { - outFile = File.createTempFile(filePrefix+"_", ".eps",directory); - } catch (IOException ex) { - logger.warn("Failed to create temporary file in "+directory.getAbsolutePath()); - return; - } - } - - //Now try saving the acquired data, - //and if it shall go to a fixed file, move it there - try { - imageEncoder.saveEPS(imageSize.width, imageSize.height, outFile); - - //move to fixed file name if requested - if (fixedFileName != null){ - - //Get a handle to the final destination - File fixedFile = new File(directory,fixedFileName); - - //delete target if exits - if (fixedFile.exists() && (!fixedFile.delete())) - throw new IOException("Failed to delete existing file "+fixedFile.getAbsolutePath()); - - //And move the new file in place - if (!outFile.renameTo(fixedFile)) - throw new IOException("Failed to rename temporary file to "+fixedFile.getAbsolutePath()); - } - } catch (IOException ioe) { - //If we fail, throw a warning - logger.warn("Could not save EPS files for history\n"+ioe.toString()); - } finally { - //In any case, delete the pngFile, if it was just temporary - if (fixedFileName != null) outFile.delete(); - } - - - } -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AEvent.java b/graphics/AtlantisJava/src/atlantis/event/AEvent.java deleted file mode 100755 index beeae482f160b77d55d6ec05024e5945bb5d019b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AEvent.java +++ /dev/null @@ -1,1051 +0,0 @@ -package atlantis.event; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Vector; -import java.util.TreeMap; -import java.util.LinkedHashMap; -import java.util.Set; - -import atlantis.list.AListManager; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.AEnumeratorParameter; -import atlantis.parameters.APar; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjection; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjectionLegoPlot; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AAtlantisException; -import atlantis.utils.ALogger; -import atlantis.utils.AMath; -import atlantis.data.*; -import atlantis.globals.AGlobals; - -/** - * AEvent is the Container for an ATLAS physics event. - * It is identified by deriving from AEventInfo and holds a map of all the - * data that is available in the event. - * - */ -public class AEvent extends AEventInfo -{ - private static ALogger logger = ALogger.getLogger(AEvent.class); - - // container with all datatypes within the event - private Map<String,AData> data = new HashMap<String,AData>(); - // storegate keys for collections-aware datatypes - // Use parameterized type but keep Hashtable and Vector instead of HashMap - // and ArrayList until I work out if thread safety is an issue. - Ben 31/1/11 - private Hashtable<String,Vector<String>> collections = new Hashtable<String,Vector<String>>(); - - private AAssociationManager assocmgr = new AAssociationManager(); - - private static APar parameterStore = APar.instance(); - - /** - * @param eventNumber the event number - * @param runNumber the run number - * @param dateTime the date and time of the event - * @param sourceName the name of the event source - * @param lumiBlock the lumiBlock number - */ - public AEvent(String eventNumber, String runNumber, String dateTime, String sourceName, String lumiBlock, String eventProperties) { - - //Initialize event information - super(Integer.parseInt(eventNumber), Integer.parseInt(runNumber), dateTime, sourceName, lumiBlock, eventProperties); - - } // AEvent() ----------------------------------------------------------- - - /** - * @return the hashtable of available collections - */ - public Hashtable<String,Vector<String>> getCollections(){ - return collections; - } // getCollections() --------------------------------------------------- - - - public void add(AData dataSet) throws AAtlantisException - { - String name = dataSet.getClass().getName(); - - int index = name.lastIndexOf('.'); - if(index >= 0 && index < name.length() - 1) - { - name = name.substring(index + 1); - } - - // remove the "A" and "Data" - name = name.substring(1, name.length() - 4); - String newKey = dataSet.getStoreGateKey(); - - if(newKey == null) - { - // no storegatekey comes with this dataset (datatype) - // hash data shouldn't contain entry under sourceName key, if it does - // the old one is replaced - data.put(name, dataSet); - } - else - { - // just checking for the same key at the datatypes in the event - if(data.containsKey(name + newKey)) - { - String msg = "Error - datatype " + name + " with storeGateKey\n" + - newKey + " already exists in this event."; - AAtlantisException aaex = new AAtlantisException(msg); - // Stuck the trace in the logging for good measure - AD - logger.error("\n" + msg, aaex); - throw aaex; - } - else - { - data.put(name + newKey, dataSet); - // saving key of a particular sourceName (datatype) - Vector<String> keys = new Vector<String>(); - if(collections.containsKey(name)) - { - keys = collections.get(name); - if(keys.contains(newKey)) - { - String msg = "Previously read datatype " + name + "\n" + - "(different collection) contained " + - "storeGateKey " + newKey + ". Error."; - AAtlantisException aaex = new AAtlantisException(msg); - logger.error(msg, aaex); - throw aaex; - } - else - { - keys.add(newKey); - collections.put(name, keys); - } - } - else - { - keys.add(newKey); - collections.put(name, keys); - } - } - } - - } // add() --------------------------------------------------------------- - - - - - - // < get<DATA_TYPE> methods > ------------------------------------------- - - - public AData get(String name) - { - return data.get(name); - } - - public AData[] getData() - { - AData[] aData = new AData[data.size()]; - Collection<AData> collection = data.values(); - return collection.toArray(aData); - } - - - /** - * AJetData getJetData() - * returns collection of Jet datatype according to selected - * collection (Jet storeGateKey) in ATLAS -> Jet -> Jet Collection - * if 'all' (or 'none') is selected - returns null (no association will - * be taken into account) - * @return AJetData - */ - public AJetData getJetData() - { - AEnumeratorParameter listBox = - (AEnumeratorParameter) parameterStore.get("Jet", "JetCollections"); - String selectedKey = listBox.getCurrentText(); - if("All".equals(selectedKey) || "None".equals(selectedKey)) -{ - logger.debug("AEvent.getJetData(): " + selectedKey + - " is selected in Jet->JetCollection, no association " + - " to Jet is taken into account, null is returned"); - return null; - } - else - { - AJetData jet = (AJetData) data.get("Jet" + selectedKey); - return jet; - } - } - - - // can combine with the other methods (e.g. getClusterData) - public AData getData(String type) - { - AEnumeratorParameter listBox = - (AEnumeratorParameter) parameterStore.get(type, type+"Collections"); - String selectedKey = (listBox == null) ? "" : listBox.getCurrentText(); - if("All".equals(selectedKey) || "None".equals(selectedKey)) { - - logger.debug("AEvent.getData(String type): " + selectedKey + - " is selected in " + type + "->" + type + " Collections, " + - "no association to " + type + " is taken into account."); - - return null; - } - else - { - return data.get(type + selectedKey); - } - } - - /** - * AClusterData getClusterData() - * returns collection of Cluster datatype according to selected - * collection (Cluster storeGateKey) in ATLAS -> Cluster -> Cluster Collection - * if 'all' (or 'none') is selected - returns null (no association will - * be taken into account) - * @return AClusterData - */ - public AClusterData getClusterData() - { - AEnumeratorParameter listBox = - (AEnumeratorParameter) parameterStore.get("Cluster", "ClusterCollections"); - String selectedKey = listBox.getCurrentText(); - if ("All".equals(selectedKey) || "None".equals(selectedKey)) { - - logger.debug("AEvent.getClusterData(): " + selectedKey + - " is selected in Cluster->ClusterCollection, no association " + - " to Cluster is taken into account, null is returned"); - - return null; - } - else - { - AClusterData cluster = (AClusterData) data.get("Cluster" + selectedKey); - return cluster; - } - } - - - /** - * ATrackData getTrackData(String type) - * type is InDetTrack, MuonTrack - the internal datatype sourceName for Track - * returns collection of Track datatype according to selected - * collection (Track storeGateKey) in InDet -> Track -> TrackCollection - * if 'all' (or 'none') is selected - returns null (no association will - * be taken into account) - * @param type String - * @return ATrackData - */ - public ATrackData getTrackData(String type) - { - AEnumeratorParameter listBox = - (AEnumeratorParameter) parameterStore.get(type, type + "Collections"); - String selectedKey = listBox.getCurrentText(); - if("All".equals(selectedKey) || "None".equals(selectedKey)) - { - logger.debug("AEvent.getTrackData(" + type + "): " + selectedKey + - " is selected in Track->TrackCollection, no association " + - " to Track is taken into account, null is returned"); - return null; - } - else - { - ATrackData track = (ATrackData) data.get(type + selectedKey); - return track; - } - } - - - /** - * ATrackData getTrackData(String type, String key) - * returns specified collection of Track datatype if it exists - * @param type String - * @param key String - * @return ATrackData - */ - public ATrackData getTrackData(String type, String key) - { - Vector<String> keys = collections.get(type); - if(keys == null) { - logger.warn("AEvent: " + type + " datatype doesn't exist " + - "in current event"); - return null; - } - else - { - if(keys.contains(key)) - { - return (ATrackData) data.get(type + key); - } - else { - - logger.warn("AEvent: " + type + " datatype: storeGateKey " + - key + " doesn't exist in current event"); - return null; - } - } - } - - - - - public ASTrData getSTrData() - { - return (ASTrData) data.get("STr"); - } - - public ASNPData getSNPData() - { - return (ASNPData) data.get("SNP"); - } - - public APixelClusterData getPixelClusterData() - { - return (APixelClusterData) data.get("PixelCluster"); - } - - public ASiClusterData getSiClusterData() - { - return (ASiClusterData) data.get("SiCluster"); - } - - public AS3DData getS3DData() - { - return (AS3DData) data.get("S3D"); - } - - public ATRTData getTRTData() - { - return (ATRTData) data.get("TRT"); - } - - public ALArData getLArData() - { - return (ALArData) data.get("LAr"); - } - - public ATILEData getTILEData() - { - return (ATILEData) data.get("TILE"); - } - - public AHECData getHECData() - { - return (AHECData) data.get("HEC"); - } - - public AFCALData getFCALData() - { - return (AFCALData) data.get("FCAL"); - } - - public AMBTSData getMBTSData() - { - return (AMBTSData) data.get("MBTS"); - } - - //Because some things need to access the data before the parameters are filled, another method - //for accessing the data has been added. This method first checks the list of available storegate keys - //and see's if there is one starting with MDT. As the dataType + storegatekey is hard coded into how - //the hash map keys are created this should be a stable way of doing it. If there are multiple - //results for the search, it then checks which one is currently selected by the user. - - public AMDTData getMDTData() - { - Vector<String> storeGateKeys = new Vector<String>(); - Set<String> keys = data.keySet(); - for(String entry : keys){ - if(entry.startsWith("MDT")){ - storeGateKeys.add(entry); - } - } - if(storeGateKeys.size() == 1){ - return (AMDTData) data.get(storeGateKeys.get(0)); - }else{ - - AEnumeratorParameter listBox = - (AEnumeratorParameter) parameterStore.get("MDT", "MDTCollections"); - String selectedKey = listBox.getCurrentText(); - if("All".equals(selectedKey) || "None".equals(selectedKey)) - { - logger.debug("AEvent.getMDTata(): " + selectedKey + - " is selected in MDT->MDTCollection, no association " + - " to MDT is taken into account, null is returned"); - return null; - - } - else{ - AMDTData mdt = (AMDTData) data.get("MDT" + selectedKey); - return mdt; - } - - - } - - } - - //See description for getMDTData - - public ARPCData getRPCData() - { - - Vector<String> storeGateKeys = new Vector<String>(); - Set<String> keys = data.keySet(); - for(String entry : keys){ - if(entry.startsWith("RPC")){ - storeGateKeys.add(entry); - } - } - if(storeGateKeys.size() == 1){ - return (ARPCData) data.get(storeGateKeys.get(0)); - }else{ - - AEnumeratorParameter listBox = - (AEnumeratorParameter) parameterStore.get("RPC", "RPCCollections"); - String selectedKey = listBox.getCurrentText(); - if("All".equals(selectedKey) || "None".equals(selectedKey)) - { - logger.debug("AEvent.getRPCData(): " + selectedKey + - " is selected in RPC->RPCCollection, no association " + - " to RPC is taken into account, null is returned"); - return null; - - } - else{ - ARPCData rpc = (ARPCData) data.get("RPC" + selectedKey); - return rpc; - } - - - } - } - //See description for getMDTData - - public ATGCData getTGCData() - { - Vector<String> storeGateKeys = new Vector<String>(); - Set<String> keys = data.keySet(); - for(String entry : keys){ - if(entry.startsWith("TGC")){ - storeGateKeys.add(entry); - } - } - if(storeGateKeys.size() == 1){ - return (ATGCData) data.get(storeGateKeys.get(0)); - }else{ - - AEnumeratorParameter listBox = - (AEnumeratorParameter) parameterStore.get("TGC", "TGCCollections"); - String selectedKey = listBox.getCurrentText(); - if("All".equals(selectedKey) || "None".equals(selectedKey)) - { - logger.debug("AEvent.getTGCData(): " + selectedKey + - " is selected in TGC->TGCCollection, no association " + - " to TGC is taken into account, null is returned"); - return null; - - } - else{ - ATGCData tgc = (ATGCData) data.get("TGC" + selectedKey); - return tgc; - } - - - } - } - //See description for getMDTData - - public ACSCDData getCSCDData() - { - Vector<String> storeGateKeys = new Vector<String>(); - Set<String> keys = data.keySet(); - for(String entry : keys){ - if(entry.startsWith("CSC")){ - storeGateKeys.add(entry); - } - } - if(storeGateKeys.size() == 1){ - return (ACSCDData) data.get(storeGateKeys.get(0)); - }else{ - - AEnumeratorParameter listBox = - (AEnumeratorParameter) parameterStore.get("CSC", "CSCCollections"); - String selectedKey = listBox.getCurrentText(); - if("All".equals(selectedKey) || "None".equals(selectedKey)) - { - logger.debug("AEvent.getCSCData(): " + selectedKey + - " is selected in CSC->CSCCollection, no association " + - " to CSC is taken into account, null is returned"); - return null; - - } - else{ - ACSCDData csc = (ACSCDData) data.get("CSC" + selectedKey); - return csc; - } - - - } - } - - public ASVxData getSVxData() - { - return (ASVxData) data.get("SVx"); - } - - public ARVxData getRVxData() - { - AEnumeratorParameter listBox = - (AEnumeratorParameter) parameterStore.get("RVx", "RVxCollections"); - String selectedKey = listBox.getCurrentText(); - if ("All".equals(selectedKey)) { - - logger.debug("AEvent.getRVxData(): " + selectedKey + - " is selected in InDet->RecVertex, no association " + - " to vertex is taken into account, null is returned"); - - return null; - } else if ("None".equals(selectedKey)) { - // Return collection without for backwards compatibility - return (ARVxData) data.get("RVx"); - } else - { - ARVxData rvx = (ARVxData) data.get("RVx" + selectedKey); - return rvx; - } - } - - public ATrigS3DData getTrigS3DData() - { - return (ATrigS3DData) data.get("TrigS3D"); - } - - public ALVL1TriggerTowerData getLvl1TriggerTowerData() - { - return (ALVL1TriggerTowerData) data.get("LVL1TriggerTower"); - } - - public ALVL1ResultData getLvl1ResultData() - { - return (ALVL1ResultData) data.get("LVL1Result"); - } - - public ALVL1JetElementData getLvl1JetElementData() - { - return (ALVL1JetElementData) data.get("LVL1JetElement"); - } - - public ATriggerInfoData getTriggerInfoData() - { - return (ATriggerInfoData) data.get("TriggerInfo"); - } - - /** - * This function returns the names currently selected for a certain collection - * which has its data draw status set to true - * @param collectionType String sourceName of the collection - * @return string of collection names length 0 if none in event - */ - public String[] getActiveCollectionNames(String collectionType) - { - //LVL1Result is not on the Data list as it is always on hence check this first - boolean collectionStatus = collectionType.equals("LVL1Result"); - if(!collectionStatus) - collectionStatus=parameterStore.get("Data", collectionType).getStatus(); - if (collectionStatus) - { - return getCollectionNames(collectionType); - } - else - return new String[0]; - } - - /** - * This function returns the names currently selected for a certain collection - * @param collectionType String sourceName of the collection - * @return string of collection names length 0 if none in event - */ - public String[] getCollectionNames(String collectionType) - { - String[] col; - Vector<String> keys = collections.get(collectionType); - if (keys != null) - { - String[] collec = keys.toArray(new String[keys.size()]); - AEnumeratorParameter listBox = (AEnumeratorParameter) parameterStore.get(collectionType, collectionType + "Collections"); - String currentSelection = listBox.getCurrentText(); - int count=0; - //count how many items in list - for (int i = 0; i < collec.length; i++) - { - if ("All".equals(currentSelection) || collec[i].equals(currentSelection)) - count++; - } - col=new String[count]; - count=0; - //now save items into string array - for (int i = 0; i < collec.length; i++) - { - if ("All".equals(currentSelection) || collec[i].equals(currentSelection)) - { - col[count] = collectionType + collec[i]; - count++; - } - } - return col; - } - else - return new String[0]; - } - - // </ get<DATA_TYPE> methods > -------------------------------------------- - - public List<ACalorimeterData> getCalorimeters() - { - List<ACalorimeterData> v = new ArrayList<ACalorimeterData>(); - Iterator<AData> i = data.values().iterator(); - while(i.hasNext()) - { - AData data = i.next(); - if(data instanceof ACalorimeterData) - { - ACalorimeterData calorimeter = (ACalorimeterData) data; - if(parameterStore.get("Data", calorimeter.getCalorimeterName()).getStatus() && - (parameterStore.getUnknown("Det", calorimeter.getCalorimeterName() + "Fill") == null - || parameterStore.get("Det", calorimeter.getCalorimeterName() + "Fill").getStatus())) - { - v.add(calorimeter); - } - } - } - return v; - - } // getCalorimeters() --------------------------------------------------- - - - - public List<AData> getHitsAndTracks(AProjection projection) - { - int mode = parameterStore.get(projection.getName(), "Mode").getI(); - String[][] det = new String[0][0]; - String[] simTr = new String[0]; - String[] recTr = new String[0]; - String[] hits = new String[0]; - String[] aod = new String[0]; - - if(mode == 0 || projection instanceof AProjectionVP - || projection instanceof AProjectionLegoPlot) - { - simTr = new String[] { "STr", "SNP", "SMTr" }; - recTr = new String[] { "InDetSegment", "MuonSegment", "G4Step", - "InDetTrack", "MuonTrack" }; - - aod = new String[] {"CompositeParticle", "BJet", "TauJet", "Photon", "Electron", "Muon" }; - - if(parameterStore.get("InDetDrawingOrder", "SpacePoints").getI() == 0) - { - hits = new String[] {"UserHit", "RVx", "TRT", "SiCluster", - "SiClusterRDO", "S3D", "PixelCluster", "PixelRDO", "TrigS3D", - "MDT", "CSCD", "CSC", "RPC", "R3D", "TGC", "T3D", "SVx", - "Jet", "EmTauROI", "Particle", "Cluster", "ETMis", - "JetROI", "MuonROI", "LVL1TriggerTower", "LVL1JetElement"}; - } - else - { - hits = new String[] {"UserHit", "RVx", "TRT", "SiCluster", - "SiClusterRDO", "TrigS3D", "S3D", "PixelCluster", "PixelRDO", - "MDT", "CSCD", "CSC", "RPC", "R3D", "TGC", "T3D", "SVx", - "Jet", "EmTauROI", "Particle", "Cluster", "ETMis", - "JetROI", "MuonROI", "LVL1TriggerTower", "LVL1JetElement"}; - } - } - else if(projection instanceof AProjectionYX - || projection instanceof AProjectionFR) - { - if(mode >= AProjectionYX.MODE_MDT_INNER && mode <= AProjectionYX.MODE_MDT_OUTER) - { - simTr = new String[] { "SMTr", "SMTr" }; - recTr = new String[] { "MuonTrack", "MuonSegment" }; - if(mode == AProjectionYX.MODE_MDT_INNER) - { - hits = new String[] { "MDT", "CSCD", "CSC" }; - } - else - { - hits = new String[] { "MDT" }; - } - } - else if(mode < AProjectionYX.MODE_MDT_INNER) - { - simTr = new String[] { "SMTr", "SMTr" }; - recTr = new String[] { "MuonTrack", "MuonSegment" }; - hits = new String[] { "TGC", "T3D" }; - } - } - else if(projection instanceof AProjectionFZ) - { - if(mode >= 4) - { - simTr = new String[] { "SMTr", "SMTr" }; - recTr = new String[] { "MuonTrack", "MuonSegment" }; - hits = new String[] { "MDT" }; - } - else - { - simTr = new String[] { "SMTr", "SMTr" }; - recTr = new String[] { "MuonTrack", "MuonSegment" }; - hits = new String[] { "RPC", "R3D" }; - } - } - - if(parameterStore.get("InDetDrawingOrder", "SpacePointsTracks").getI() == 0) - { - // Simulated tracks, reconstructed tracks, hits - det = new String[][] { simTr, recTr, hits, aod }; - } - else if(parameterStore.get("InDetDrawingOrder", "SpacePointsTracks").getI() == 1) - { - // Simulated tracks, hits, reconstructed tracks - det = new String[][] { simTr, hits, recTr, aod }; - } - else - { - // Reconstructed tracks, hits, simulated tracks - det = new String[][] { recTr, hits, simTr, aod }; - } - - AEnumeratorParameter listBox = null; - List<AData> v = new ArrayList<AData>(); - for(int i = 0; i < det.length; ++i) - { - for(int j = 0; j < det[i].length; ++j) - { - if(collections.containsKey(det[i][j])) - { - Vector<String> keys = collections.get(det[i][j]); - String[] array; - array = keys.toArray(new String[keys.size()]); - // GUI listbox sourceName datatype + "Collections" - listBox = (AEnumeratorParameter) parameterStore.get(det[i][j], - det[i][j] + "Collections"); - String currentSelection = listBox.getCurrentText(); - for(int c = 0; c < array.length; c++) - { - if("All".equals(currentSelection) || - array[c].equals(currentSelection)) - { - AData a = data.get(det[i][j] + array[c]); - processDataSet(v, a); - } - } - } - else - { - AData a = data.get(det[i][j]); - processDataSet(v, a); - } - } - } - return v; - - } // getHitsAndTracks() ------------------------------------------------- - - - private static void processDataSet(List<AData> v, AData a) - { - if(a != null) - { - if(parameterStore.getUnknown("Data", a.getName()) != null && - parameterStore.get("Data", a.getName()).getStatus() && - (parameterStore.getUnknown("Det", a.getName() + "Fill") == null || - parameterStore.get("Det", a.getName() + "Fill").getStatus())) - { - v.add(a); - } - } - - } // processDataSet() --------------------------------------------------- - - - - public List<ACalorimeterData> getElectromagneticCalorimeters() - { - List<ACalorimeterData> v = new ArrayList<ACalorimeterData>(); - Iterator<AData> i = data.values().iterator(); - while(i.hasNext()) - { - AData a = i.next(); - if(a instanceof ALArData || a instanceof AFCALData) - { - v.add((ACalorimeterData)a); - } - } - return v; - - } // getElectromagneticCalorimeters() ------------------------------------ - - - - public List<ACalorimeterData> getHadronicCalorimeters() - { - List<ACalorimeterData> v = new ArrayList<ACalorimeterData>(); - Iterator<AData> i = data.values().iterator(); - while(i.hasNext()) - { - AData a = i.next(); - if(a instanceof ATILEData || a instanceof AHECData - || a instanceof AFCALData || a instanceof AMBTSData) - { - v.add((ACalorimeterData)a); - } - } - return v; - - } // getHadronicCalorimeters() ------------------------------------------- - - - - /** - * setPrimaryVertex() called during event finalisation - * sets Event: XVtx, YVtx, ZVtx in the internal parameter store - * (in GUI: Projection -> eta-phi -> XVtx, YVtx, ZVtx) - - * 1) gets values from RecVertex (RVx) - see conditions in ARVxData class - * 2) gets values from simulated vertices with highest pt sum (STr) - * 3) if above fail, sets 0.0, 0.0, 0.0 - * - * (taking primary vertex from reconstructed tracks was removed) - * - */ - public void setPrimaryVertex() - { - double[] vtx = null; - - // (1) - if(getRVxData() != null) - { - // RVx data exists, try to retrieve primary vertex information - vtx = getRVxData().getPrimaryVertex(); - } - // (2) - if(vtx == null && getSTrData() != null) - { - // STr data exists, try to get primary vertex information - int vtxIndex = getSTrData().getMaxSumPtVertex(); - - //retrieve that vertex - vtx = getSVxData().getVertex(vtxIndex); - - //Completely unclear to me... why 4? - if(vtx[0] * vtx[0] + vtx[1] * vtx[1] > 4.) - { - logger.info("replacing primary with first"); - logger.info(" was " + vtx[0] + " " + vtx[1] + " " + vtx[2]); - vtx = getSVxData().getVertex(0); - if(vtx[0] * vtx[0] + vtx[1] * vtx[1] > 4.) - { - vtx[0] = 0.; - vtx[1] = 0.; - vtx[2] = 0.; - } - logger.info(" now is " + vtx[0] + " " + vtx[1] + " " + vtx[2]); - } - } - - if(vtx == null) - { - vtx = new double[] { 0.0, 0.0, 0.0 }; - } - - parameterStore.get("Event", "XVtx").setD(vtx[0]); - parameterStore.get("Event", "YVtx").setD(vtx[1]); - parameterStore.get("Event", "ZVtx").setD(vtx[2]); - - AOutput.append("\n\nPrimary vertex set for projection " + - AMath.PHI + AMath.ETA + ":\n" + - " XVtx = " + String.format("%.5f",vtx[0]) + " cm\n" + - " YVtx = " + String.format("%.5f",vtx[1]) + " cm\n" + - " ZVtx = " + String.format("%.5f",vtx[2]) + " cm\n", ALogInterface.NORMAL); - - } // setPrimaryVertex() ------------------------------------------------- - - - - /** - * Finalize event construction: - * - finalize all data objects - * - set primary vertex - * - calculate the number of hits on a track - * - create associations - * - update collections - * @return the event - */ - public AEvent finalizeEvent() - { - - // setting primary vertex must be done before finalizeConstruction() - // happens on datatypes! - setPrimaryVertex(); - - Iterator<AData> iter = data.values().iterator(); - while(iter.hasNext()) - { - AData data = iter.next(); - if(data instanceof AData) - { - try { - ((AData) data).finalizeConstruction(); - } catch ( Exception e ){ - //Get sourceName of the object where the error occured - String ObjName = ((AData)data).getFullName(); - logger.error("Exception while finalizing construction of "+ObjName,e); - AOutput.append("\n\nError while constructing " + ObjName +"\n", ALogInterface.WARNING); - AOutput.append(" - object will not be shown!\n",ALogInterface.WARNING); - iter.remove(); - - } - } - } - - if (!AGlobals.isAtlantisHeadless()) { - AListManager.getInstance().resetAndPreserveInvisible(); - } - - // are there any RVx read in from the event file? if so, cut the tracks - // which form vertices (when drawn as helices) to the reconstructed - // vertices. - ARVxData rvxData = this.getRVxData(); - if(rvxData != null) - { - rvxData.cutTracksToRVx(this); - } - - assocmgr.correct(); - - return this; - - } // AEvent finalizeEvent() --------------------------------------------- - - - /** - * Returns information about datatypes and number of items datatypes in - * the current event - * First item of the result array is the datatype sourceName followed - * by ":<storeGateKey>" if that exists for a datatype and second item is - * integer number (numData). - * The array is alphabetically sorted. - * - * @return String[][] - */ - public String[][] getInfo() - { - AData[] sources = getData(); - Map<String,String> m = new LinkedHashMap<String,String>(); - m.clear(); - for(int i = 0; i < sources.length; i++) - { - String sg = sources[i].getStoreGateKey(); - String a = sources[i].getNameScreenName(); - a += sg != null ? ":" + sg : ""; - m.put(a, String.valueOf(sources[i].getNumData())); - } - - TreeMap<String,String> tm = new TreeMap<String,String>(String.CASE_INSENSITIVE_ORDER); - tm.clear(); - tm.putAll(m); - - String[][] s = new String[tm.size()][2]; - int i = 0; - for(Iterator<String> iter = tm.keySet().iterator() ; iter.hasNext() ; i++) - { - String key = iter.next(); - s[i][0] = key; - s[i][1] = tm.get(key); - } - - return s; - - } // getInfo() ----------------------------------------------------------- - - - /** - * Returns information about datatypes and number of items datatypes in - * the current event drawn for all event data, and data passing cuts - * First item of the result array is the datatype sourceName followed - * by ":<storeGateKey>" if that exists for a datatype and second/third items are - * integer number (numData, numDraw). - * The array is alphabetically sorted. - * - * @return String[][] - */ - public String[][] getInfoDraw() - { - AData[] sources = getData(); - Map<String,String> m = new LinkedHashMap<String,String>(); - m.clear(); - Map<String,String> mDraw = new LinkedHashMap<String,String>(); - mDraw.clear(); - - for(int i = 0; i < sources.length; i++) - { - String sg = sources[i].getStoreGateKey(); - String a = sources[i].getNameScreenName(); - a += sg != null ? ":" + sg : ""; - m.put(a, String.valueOf(sources[i].getNumData())); - mDraw.put(a, String.valueOf(sources[i].getNumDraw())); - } - - TreeMap<String,String> tm = new TreeMap<String,String>(String.CASE_INSENSITIVE_ORDER); - tm.clear(); - tm.putAll(m); - TreeMap<String,String> tmDraw = new TreeMap<String,String>(String.CASE_INSENSITIVE_ORDER); - tmDraw.clear(); - tmDraw.putAll(mDraw); - - - String[][] s = new String[tm.size()][3]; - int i = 0; - for(Iterator<String> iter = tm.keySet().iterator() ; iter.hasNext() ; i++) - { - String key = iter.next(); - - s[i][0] = key; - s[i][1] = tm.get(key); - s[i][2] = tmDraw.get(key); - } - - return s; - - } // getInfoDraw() ----------------------------------------------------------- - - - /** - * Get coordinates of event vertex. - * - * The coordinates are obtained from the parameter store rather than - * from the event itself, since the vertex position can be changed by the - * user through the GUI. - * - * @return (x,y,z) of vertex - */ - public double[] getPrimaryVertex() - { - return AParameterUtilities.getPrimaryVertex(); - } - - public AAssociationManager getAssociationManager() { - return assocmgr; - } - - -} // class AEvent ------------------------------------------------------------ diff --git a/graphics/AtlantisJava/src/atlantis/event/AEventInfo.java b/graphics/AtlantisJava/src/atlantis/event/AEventInfo.java deleted file mode 100644 index 0fe0aca7a014cacdda8674e19ec5c05e707bd00c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AEventInfo.java +++ /dev/null @@ -1,212 +0,0 @@ -package atlantis.event; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Comparator; -import java.util.Date; - -/** - * The AEventInfo class summarizes the information that uniquely identifies a event. - * It also provides an "equals" function allowing to compare if two events are identical. - * @author sboeser - */ -public class AEventInfo { - - // number of the run of the event - private final long runNumber; - // event number in a run - private final long eventNumber; - // Athena time when XML event file was made in JiveXML - private final String dateTime; - // the name of the source this event was coming from (filename, servername, ...) - private final String sourceName; - // the lumiBlock number - private final String lumiBlock; - // Any additional eventProperties that may be important - private final String eventProperties; - // any additional info that is needed - - //the date format to use with the event info - public final static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); - - /** - * Fully qualified constructor - * @param run the run number - * @param event the event number - * @param time the date and time of the event - */ - AEventInfo(long event, long run, String time, String source, String lumiBlock, String eventProperties){ - this.runNumber = run; - this.eventNumber = event; - this.dateTime = time != null ? time : "n/a"; - this.sourceName = source != null ? source : "n/a"; - this.lumiBlock = checkString(lumiBlock); - this.eventProperties = checkString(eventProperties); - } - - /** - * Copy constructor - * @param the evenInfo object to copy - */ - AEventInfo(AEventInfo event){ - this(event.getEventNumber(),event.getRunNumber(), - event.getDateTime(),event.getSourceName(), - event.getLumiBlock(),event.getEventProperties()); - } - - /** - * @return the run number - */ - public long getRunNumber() { - return runNumber; - } // getRunNumber() ----------------------------------------------------- - - /** - * @return the event number - */ - public long getEventNumber(){ - return eventNumber; - } // getEventNumber() --------------------------------------------------- - - - /** - * @return the date and time of the event - */ - public String getDateTime() { - return dateTime; - } // getEventNumber() --------------------------------------------------- - - /** - * @return the name of the event source - */ - public String getSourceName() { - return sourceName; - } // getSourceName() ---------------------------------------------------------- - - /** - * @return the lumiBlock - */ - public String getLumiBlock() { - return lumiBlock; - } // getSourceName() ---------------------------------------------------------- - - /** - * @return the eventProperties - */ - public String getEventProperties() { - return eventProperties; - } // getSourceName() ---------------------------------------------------------- - - - - /** - * Performs test to see if there is a valid value for send string - */ - private String checkString(String receivedString){ - String temp; - if(receivedString == null || receivedString.endsWith("-1")){ - temp = "default"; - }else{ - temp = receivedString; - } - return temp; - } - - - - - /** - * Check whether this event is identical to the event described by info - * @param info the event information for the event to compare to - * @return true if identical - */ - // FIXME: Should take Object as argument. Need to consider how to deal with - // subclasses like AEvent. - public boolean equals(AEventInfo info){ - //check if info is valid - if (info == null) return false; - //Only compare run- and event number and time, source may be different - return ((info.getRunNumber() == runNumber)&& - (info.getEventNumber() == eventNumber)); - } - -// Need to override hashCode() to guarantee correct behaviour of equals() -@Override -public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (eventNumber ^ (eventNumber >>> 32)); - result = prime * result + (int) (runNumber ^ (runNumber >>> 32)); - return result; -} - - -/** - * Implementation of Comparable interface - sort events by run- and event number - */ - public static class RunEventNumberComparator implements Comparator { - - /** - * @param o1 , o2 the two eventInfo objects to compare - * @return negative/zero/positive int if o1 is less/equal/larger than o2 - */ - public int compare(Object o1, Object o2) { - - /** - * Cast to an event info object - if this fails, someone has mixed this with - * another class in a collection and we better crash with ClassCastException than catch - */ - AEventInfo info1 = (AEventInfo)o1; - AEventInfo info2 = (AEventInfo)o2; - - //compare by run number first - Long run = info1.getRunNumber(); - if (run.compareTo(info2.getRunNumber()) != 0) - return run.compareTo(info2.getRunNumber()); - - //otherwise return by event number - Long event = info2.getEventNumber(); - return event.compareTo(info2.getEventNumber()); - } - } - - /** - * Implementation of Comparable interface - sort events by date and time - */ - public static class DateTimeComparator implements Comparator { - - /** - * @param o1 , o2 the two eventInfo objects to compare - * @return negative/zero/positive int if o1 is less/equal/larger than o2 - */ - public int compare(Object o1, Object o2) { - - /** - * Cast to an event info object - if this fails, someone has mixed this with - * another class in a collection and we better crash with ClassCastException than catch - */ - AEventInfo info1 = (AEventInfo)o1; - AEventInfo info2 = (AEventInfo)o2; - - //return zero for events that are equal - if (info1.equals(info2)) return 0; - - //Now get date and time objects - Date date1 = null; Date date2=null; - try { - date1 = dateTimeFormat.parse(info1.getDateTime()); - date2 = dateTimeFormat.parse(info2.getDateTime()); - } catch (ParseException pex) { - throw new ClassCastException("Parse exception when comparing dates"); - } - - //If there is not date assoicated with any of these, throw an exception - if ((date1==null)||(date2==null)) - throw new ClassCastException("Could not parse valid date comparing " - +info1.getDateTime()+" to "+info2.getDateTime()); - - //Finally, compare the two dates - return date1.compareTo(date2); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AEventInfoPrinter.java b/graphics/AtlantisJava/src/atlantis/event/AEventInfoPrinter.java deleted file mode 100644 index 174eed015a787e842b4c5269fdee7d4ae4294458..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AEventInfoPrinter.java +++ /dev/null @@ -1,60 +0,0 @@ -package atlantis.event; - -import atlantis.globals.AGlobals; -import atlantis.output.ALogInterface; - -/** - * Print event information for each new event to the log pane - * @author sboeser - */ -public class AEventInfoPrinter implements ANewEventListener { - - private ALogInterface logPane = null; - - /** - * Constructor with the log pane where the information shall be printed - * @param output the output pane to which to write - */ - public AEventInfoPrinter(ALogInterface output){ - logPane = output; - } - - private void printEventInfo(AEvent event, ALogInterface dest) - { - //For Minerva just output name and coded event and run numbers - //Not on canvas title, but teachers may want to see the number to help - //with recognising difficult events - if(AGlobals.instance().getSimpleOutput()>0) - { - String r = "\n" + event.getSourceName() + - " (" + event.getRunNumber() + "00"+ event.getEventNumber() + ")\n"; - dest.append(r + "\n", ALogInterface.NORMAL); - return; - } - - int lineLen = 39; - String r = "\n" + event.getSourceName() + "\n" + - "run number: " + event.getRunNumber() + - " event number: " + event.getEventNumber() + "\n" + - "--------------------------------------\n"; - - String[][] s = event.getInfo(); - - for(int i = 0; i < s.length; i++) - { - r += String.format("%-"+lineLen+"s", s[i][0]) + ": " + s[i][1] + "\n"; - } - dest.append(r + "\n", ALogInterface.NORMAL); - - } // printEventInfo() ---------------------------------------------------*/ - - /** - * For each new event print log information to the log pane - * @param event the change event - */ - public void newEvent(AEvent event) { - //simply print it - printEventInfo(event,logPane); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AEventManager.java b/graphics/AtlantisJava/src/atlantis/event/AEventManager.java deleted file mode 100755 index ba5b27b035be0b364b1e0e7fcc5218d3e892afb1..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AEventManager.java +++ /dev/null @@ -1,319 +0,0 @@ -package atlantis.event; - -import atlantis.event.AEventSource.InvalidEventSourceException; -import atlantis.event.AEventSource.NoMoreEventsException; -import atlantis.event.AEventSource.ReadEventException; -import atlantis.event.AEventSource.NavigationMode; -import atlantis.event.oncrpc.AONCRPCEventSource; -import atlantis.event.xmlrpc.AXMLRPCEventSource; -import java.util.Vector; - -import atlantis.utils.ALogger; - -/** - * All new physics events come into Atlantis via the AEventManager - * The AEventManager may hold a list of event, has the index of the - * current event int the list and informs its listeners about new events. - * Only one event can be active at one time. - * - * @author sboeser - */ -public class AEventManager -{ - private final static ALogger logger = ALogger.getLogger(AEventManager.class); - private static AEventManager instance; - - /** Private constructor for singleton. */ - private AEventManager() {} - - /** Get the singleton instance. */ - public synchronized static AEventManager instance() { - if (instance==null) instance = new AEventManager(); - return instance; - } - - //The current event source - private AEventSource eventSource = null; - - //The current event - i.e. the last delivered by any event source - private AEvent currentEvent = null; - - //A list of listeners for new events - private Vector<ANewEventListener> NewEventListeners = new Vector<ANewEventListener>(); - - //A list of listeners for new events sources - private Vector<ANewEventSourceListener> NewEventSourceListeners = new Vector<ANewEventSourceListener>(); - - /** - * Return the currently active event - * @return AEvent - */ - public synchronized AEvent getCurrentEvent() - { - //simply return the current event - return currentEvent; - } - - - /** - * Set the event with the given index as the current event - * @param index the index of the new event - */ - private synchronized void setCurrentEvent(AEvent event) - { - //Now simply set the current event - currentEvent = event; - //Inform all listeners - fireNewEvent(getCurrentEvent()); - } - - - /** - * @return the current active event source - */ - public synchronized AEventSource getEventSource(){ - return eventSource; - } - - /** - * Set a new already constructed event source. Note that this constructor - * does not throw InvalidEventSource exception as the AEventSource object - * is already constructed. - * @param source the AEventSource object - */ - public synchronized void setEventSource( AEventSource source ) - { - //Simply set the source and we are done - eventSource = source; - fireNewEventSource(getEventSource()); - } - - - /** - * Set the source given by name as new event source. If the event source is - * not valid (e.g invalid file name) we rely on the constructor to fail, throwing - * an InvalidEventSourceException. Thus, the old source is retained if the new one - * can not be created. - * @param sourceName the name of the source (e.g. file name, url, server name,...) - * @throws InvalidEventSourceException - */ - public synchronized void setEventSource(String sourceName) throws InvalidEventSourceException - { - //Make a nice string out of it - String theSourceName = sourceName.toLowerCase().trim(); - - // XMLRPC Server source given as "xmlrpc://server:port" - if(theSourceName.startsWith("xmlrpc://")) { - eventSource = new AXMLRPCEventSource(sourceName); - // ONCRPC Server source given as "oncrpc://server[:port]" - } else if(theSourceName.startsWith("oncrpc://")) { - eventSource = new AONCRPCEventSource(sourceName); - // Metwork sources possibilities - // .xml, .zip or web directory containing event files - } else if(theSourceName.startsWith("http://")) { - // normal xml file - if(theSourceName.endsWith(".xml")){ - eventSource = new AURLEventSource(sourceName); - // zip file on the web - } else if(theSourceName.endsWith(".zip")) { - eventSource = new AZipEventSource(sourceName); - //Anything else should be a web directory - } else { - eventSource = new AURLEventSource(sourceName); - } - - // local disk access possibilities (.xml, .zip, .gz, .gzip) - // event source starts with file:// - } else if(theSourceName.startsWith("file://")) { - // normal xml file - if (theSourceName.endsWith(".xml")) { - eventSource = new AFileEventSource(sourceName); - // normal zip file - } else if (theSourceName.endsWith(".zip")) { - eventSource = new AZipEventSource(sourceName); - // compressed single xml file - } else if (theSourceName.endsWith(".gz") || theSourceName.endsWith(".gzip")) { - eventSource = new AFileEventSource(sourceName); - } else { - String msg = "Could not identify event source: "+sourceName; - logger.error(msg); - throw new InvalidEventSourceException(msg); - } - } else { - String msg = "Could not identify event source: "+sourceName; - logger.error(msg); - throw new InvalidEventSourceException(msg); - } - fireNewEventSource(getEventSource()); - } - - /** - * Sets event navigation mode: random, push, loop or sequential. - * Throws InvalidEventSourceException if there is no source - * or if it doesn't support the requested mode. - * @throws InvalidEventSourceException - */ - public synchronized void setNavigationMode(NavigationMode mode) throws InvalidEventSourceException - { - if(eventSource == null) throw new InvalidEventSourceException("Current event source is NULL"); - - NavigationMode oldMode = eventSource.getNavigationMode(); - - // check if we're really setting a new mode, or if - // the user just clicked on the same button twice - if(oldMode != mode) { - if(eventSource.supportsNavigationMode(mode)) { - eventSource.setNavigationMode(mode); - fireNewEventSource(getEventSource()); - // go to the next event - try { - nextEvent(); - } catch (NoMoreEventsException nme) { - String msg = "No more events from current source"; - logger.error(msg); - } catch (ReadEventException re) { - String msg = "Error while reading the event"; - logger.error(msg); - } - } else throw new InvalidEventSourceException("Current event source does not support the selected display mode"); - } - } - - /** - * Gets the current event navigation mode. - * @return event navigation mode - */ - public synchronized NavigationMode getNavigationMode() throws InvalidEventSourceException - { - if(eventSource == null) throw new InvalidEventSourceException("Current event source is NULL"); - return eventSource.getNavigationMode(); - } - - /** - * Check if the current source supports a specific event navigation mode. - * @param mode the requested event navigation mode - * @return true if the event navigation mode is supported - */ - public boolean supportseventNavigationMode(NavigationMode mode) throws InvalidEventSourceException - { - if(eventSource == null) throw new InvalidEventSourceException("Current event source is NULL"); - return eventSource.supportsNavigationMode(mode); - } - - /** - * Read the next event from the current event source. - * Throws NoMoreEvents if there is none. - * @throws NoMoreEventsException - * @throws InvalidEventSourceException - * @throws ReadEventException - */ - public void nextEvent() throws NoMoreEventsException, - InvalidEventSourceException, - ReadEventException - { - - // Check for valid event source. - if (eventSource==null) - throw new InvalidEventSourceException("Current event source is NULL"); - - // Simply read next event from it. - AEvent event = eventSource.nextEvent(); - setCurrentEvent(event); - - } - - - /** - * Read previous event from current event source. - * Throws NoMoreEvents if there is none. - * @throws NoMoreEventsException - * @throws InvalidEventSourceException - * @throws ReadEventException - */ - public void previousEvent() throws NoMoreEventsException, - InvalidEventSourceException, - ReadEventException - { - - // Check for valid event source. - if (eventSource==null) - throw new InvalidEventSourceException("Current event source is NULL"); - - // Simply read previous event from it. - setCurrentEvent(eventSource.previousEvent()); - - } - - /** - * Add a new listener for newEvent incidents - * @param listener to be added to list - */ - public void addNewEventListener(ANewEventListener listener) - { - //Add this listener - NewEventListeners.addElement(listener); - //If there are already some events - if (getCurrentEvent() == null) return; - //Make the new listener aware of the current event - listener.newEvent(getCurrentEvent()); - } - - /** - * Remove a listener from the list. - * @param listener to be removed from list - */ - public void removeNewEventListener(ANewEventListener listener) - { - //Remove this listener - NewEventListeners.removeElement(listener); - } - - /** - * Call stateChanges of all newEvent listeners - * @param event the new event passed on to all listeners - */ - private synchronized void fireNewEvent(AEvent event) - { - - // Loop over all listeners - for ( ANewEventListener listener : NewEventListeners ) - // give them the new event - listener.newEvent(event); - } - - /** - * Add a new listener for newEventSource incidents - * @param listener to be added to list - */ - public void addNewEventSourceListener(ANewEventSourceListener listener) - { - //Add this listener - NewEventSourceListeners.addElement(listener); - //If there are already some events - if (getEventSource() == null) return; - //Make the new listener aware of the current event - listener.newEventSource(getEventSource()); - } - - /** - * Remove a listener from the list - * @param listener to be removed from list - */ - public void removeNewEventSourceListener(ANewEventSourceListener listener) - { - NewEventSourceListeners.removeElement(listener); - } - - /** - * Call eventSourceChanged of all event source changes listeners - * @param eventSource the new event source - */ - private synchronized void fireNewEventSource(AEventSource eventSource) - { - // Loop over all listeners - for ( ANewEventSourceListener listener : NewEventSourceListeners ) - // give them the new event - listener.newEventSource(eventSource); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AEventSource.java b/graphics/AtlantisJava/src/atlantis/event/AEventSource.java deleted file mode 100755 index 01fef1e727de90d8e2f5c443bb55946e95f5fcbe..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AEventSource.java +++ /dev/null @@ -1,114 +0,0 @@ -package atlantis.event; - -/** - * Basic interface class to be implemented by all event sources - * @author sboeser - */ - -public interface AEventSource -{ - - /*** - * Exception that is thrown if an event can not be read from this source - */ - public class ReadEventException extends AEventSourceException - { - //Default constructor - public ReadEventException() { super(); } - //Constructor with a string - public ReadEventException( String message ){ super( message ); } - //Constructor with a description and cause - public ReadEventException( String message, Throwable cause ){ super( message, cause ); } - } - - /*** - * Exception that is thrown if there are no more events from this source - */ - public class NoMoreEventsException extends AEventSourceException - { - //Default constructor - public NoMoreEventsException() { super(); } - //Constructor with a string - public NoMoreEventsException( String message ){ super( message ); } - //Constructor with a description and cause - public NoMoreEventsException( String message, Throwable cause ){ super( message, cause ); } - } - - /** - * Exception that is thrown if the event source is invalid - */ - public class InvalidEventSourceException extends AEventSourceException - { - //Default constructor - public InvalidEventSourceException() { super(); } - //Constructor with a string - public InvalidEventSourceException( String message ){ super( message ); } - //Constructor with a description and cause - public InvalidEventSourceException( String message, Throwable cause ){ super( message, cause ); } - } - - /** - * Read the next event from the source, throws NoMoreEvents - * if no next event is available - * @return the next event - * @throws NoMoreEventsException - * @throws InvalidEventSourceException - * @throws ReadEventException - */ - AEvent nextEvent() throws NoMoreEventsException, - InvalidEventSourceException, - ReadEventException; - - /** - * Read the previous event from the source, throws NoMoreEvents - * if no previous event is available - * @return the previous event - * @throws NoMoreEventsException - * @throws InvalidEventSourceException - * @throws ReadEventException - */ - AEvent previousEvent() throws NoMoreEventsException, - InvalidEventSourceException, - ReadEventException; - /** - * Get a string uniquly identifying the event source, e.g the URL, the zip - * archive name or the server:port string - * @return a unique name describing the source - */ - String getSourceName(); - - /*** - * Enum that stores the possible event navigation modes - */ - public enum NavigationMode { - SEQUENTIAL, //go through events in their natural order - LOOP, //start from beginning when reaching the end - RANDOM, //take a random event - PUSH //event loop is driven from outside (see AServerXMLRPC) - } - - /** - * Get the event navigation mode for the current source. - * @return current navigation mode - */ - NavigationMode getNavigationMode(); - - /** - * Set the event navigation mode for the current source. - * Throws InvalidEventSourceException if the current - * source does not support the requested mode - * @param mode requested event navigation mode - * @throws InvalidEventSourceException if the mode is not supported - */ - void setNavigationMode(NavigationMode mode) throws InvalidEventSourceException; - - /** - * Checks whether the current event source supports - * a particular display mode. - * @return true if the mode is supported - * @param mode requested event navigation mode - */ - boolean supportsNavigationMode(NavigationMode mode); - -} - diff --git a/graphics/AtlantisJava/src/atlantis/event/AEventSourceException.java b/graphics/AtlantisJava/src/atlantis/event/AEventSourceException.java deleted file mode 100644 index 94061279df36cc27d31dbef8549ab28f43a17d73..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AEventSourceException.java +++ /dev/null @@ -1,65 +0,0 @@ - -package atlantis.event; - -/** - * All exceptions occuring while attempting to read events shall be chaught - * and converted into one of the three generic event source exceptions: - * - * -NoMoreEventsException: there is no next/previous event - * -InvalidEventSourceException: the specified event source is invalid - * -ReadEventException: there was an error reading in the event - * - * All three of them derive from AEventSourceException which provides printing methods. - * - * These three exceptions are then handed up to the GUI level, where they are treated - * differently, depending on the current reading mode (e.g. NoMoreEvents can be ignored - * when waiting for events to appear on a server, web-dir, etc..) - * - * @author sboeser - */ -public class AEventSourceException extends Exception{ - - //Default constructor - public AEventSourceException() { super(); } - //Constructor with a string - public AEventSourceException( String message ){ super( message ); } - //Constructor with a description and cause - public AEventSourceException( String message, Throwable cause ){ super( message, cause ); } - - /** - * Generates a string with the cause of this message and all causing ones - * @return the generated string - */ - public String getCauseMessages(){ - - //Create the string buffer - StringBuffer msg = new StringBuffer(); - - //Add all cause messages starting from this exception - addCauseMessage(this,msg); - - //return string - return msg.toString(); - } - - /** - * Recursively add cause messages to string buffer - * @param t the exception - * @param msg the string buffer - */ - private void addCauseMessage(Throwable t, StringBuffer msg){ - - //Add the name of the exception class - msg.append(t.getClass().getName()); - //Add the description of the exception - msg.append(": "); - msg.append(t.getMessage()); - - //Check if there has been a cause given - if (t.getCause() != null){ - //Add cause messages in next line - msg.append("\n caused by "); - addCauseMessage(t.getCause(),msg); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AFileEventSource.java b/graphics/AtlantisJava/src/atlantis/event/AFileEventSource.java deleted file mode 100644 index 51625ac86d35349bdf4b12e9df1c4785c62a78b6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AFileEventSource.java +++ /dev/null @@ -1,309 +0,0 @@ -package atlantis.event; - -import atlantis.data.AEventFromXML; -import java.io.File; -import java.io.FilenameFilter; -import java.io.InputStream; - -import java.util.Arrays; -import java.util.zip.GZIPInputStream; -import java.util.Random; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; - - -/** - * Read a single event from an XML file in a directory - * @author sboeser - */ -public class AFileEventSource extends ABufferedEventSource -{ - - //The current directory - private File directory = null; - - //A filter for valid files in the current directory - private final XMLFilenameFilter filter = new XMLFilenameFilter(); - - // needed for random mode - private Random randomGenerator = new Random(); - - /** - * Constructor with file name given - * @param sourceName - * @throws AEventSource.InvalidEventSourceException - */ - public AFileEventSource(String sourceName) throws AEventSource.InvalidEventSourceException - { - // check if it's a well-formed event path - if(sourceName.startsWith("file://")) { - // strip file:// from the sourceName - sourceName = sourceName.substring(7); - //Check if the current file name is valid - directory = new File(sourceName); - - //Check that we can read that file or directory - if (!directory.canRead()) - throw new InvalidEventSourceException("Can not read from "+sourceName); - } else throw new InvalidEventSourceException(sourceName+" is not in the form file://path"); - } - - /** - * @return the full name of the file or directory - */ - public String getSourceName() { - return directory.getAbsolutePath(); - } - - /** - * @param mode event navigation mode - * @return true if the requested mode is supported by this source - */ - public boolean supportsNavigationMode(NavigationMode mode) { - if(mode == NavigationMode.SEQUENTIAL || - mode == NavigationMode.RANDOM || - mode == NavigationMode.LOOP) - return true; - return false; - } - - /** - * Read an event from the current file and directory - * @return the event - * @throws ReadEventException - * @throws InvalidEventSourceException - */ - protected AEvent readEventFromFile(File file) throws ReadEventException, - InvalidEventSourceException - { - //Reassemble full file name - String FullFileName = file.getAbsolutePath(); - - try{ - - //Use full path and name to specify the file - InputStream is = new FileInputStream(FullFileName); - - //Check if this might be a gzip stream - if ((file.getName().toLowerCase().endsWith(".gz"))|| - (file.getName().toLowerCase().endsWith(".gzip"))){ - - //Run through GZIPInput for decoding - is = new GZIPInputStream(is); - } - //Read file from stream - return AEventFromXML.read(is, file.getName()); - - } catch( OutOfMemoryError oom ) { - - //Check if we can clear the event container - if( getNumberOfEvents() > 0) clearEventContainer(); - - //Run garbage collector - System.gc(); - - //Retry reading the event - return readEventFromFile(file); - - } catch(FileNotFoundException fnfe){ - //rethrow - throw new InvalidEventSourceException("File not found: "+FullFileName,fnfe); - } catch(IOException ioe){ - //rethrow - throw new ReadEventException("I/O error readding file: "+FullFileName,ioe); - } - } - - /** - *Get a sorted list of files in the directory of the current file - */ - private String[] getListOfFiles(){ - - //get a list of files in the same directory using the filter - String[] FileList = directory.list(filter); - - //Sort the list - Arrays.sort(FileList); - - return FileList; - - } - - protected AEvent readRandom() throws ReadEventException, InvalidEventSourceException { - - //The file we want to pass on to the reading routine - File file = null; - //On the first encounter "directory" might be a file - if (directory.isFile()){ - //set this as the file we want to read - file = directory.getAbsoluteFile(); - //store its parent directory - directory = file.getParentFile(); - } else { - //Get a list of files - String[] FileList = getListOfFiles(); - //Check there are more files - if (FileList.length == 0) - throw new InvalidEventSourceException("No valid files in directory " - +directory.getAbsolutePath()); - //Loop over file list - int iName = randomGenerator.nextInt(FileList.length); - - //Now get the new file - file = new File(directory,FileList[iName]); - } - - //Should now have a file in any case, try to read from it - return readEventFromFile(file); - - } - - - /** - * Read the next event from the next XML file in the same directory - * @return the next event - * @throws NoMoreEventsException - * @throws ReadEventException - * @throws InvalidEventSourceException - */ - public AEvent readNext(AEventInfo currentEvent) throws NoMoreEventsException, - ReadEventException, - InvalidEventSourceException - { - // if random mode is set, return a random event - if(getNavigationMode() == NavigationMode.RANDOM) return readRandom(); - - //The file we want to pass on to the reading routine - File file = null; - //On the first encounter "directory" might be a file - if (directory.isFile()){ - //set this as the file we want to read - file = directory.getAbsoluteFile(); - //store its parent directory - directory = file.getParentFile(); - } else { - //Get a list of files - String[] FileList = getListOfFiles(); - //Check there are more files - if (FileList.length == 0) - throw new NoMoreEventsException("No valid files in directory " - +directory.getAbsolutePath()); - //Loop over file list - int iName = 0; - //search for next entry that is lexicographically larger - //taking first one if there is no current event to compare to - while ((currentEvent != null ) && - (currentEvent.getSourceName().compareTo(FileList[iName]) >= 0)){ - //Go to next file - ++iName; - // if we have reached the end of the list - if (iName == FileList.length) { - // if in loop mode, go back to the first file - if(getNavigationMode() == NavigationMode.LOOP) { - iName = 0; - break; - } - // if not in loop mode, abort - else throw new NoMoreEventsException("No more files after" - + currentEvent.getSourceName() + " in directory "+directory.getAbsolutePath()); - } - } - - //Now get the new file - file = new File(directory,FileList[iName]); - } - - //Should now have a file in any case, try to read from it - return readEventFromFile(file); - - } - - /** - * Read the next event from the previous XML file in the same directory - * @return the previous event - * @throws NoMoreEventsException - * @throws ReadEventException - * @throws InvalidEventSourceException - */ - public AEvent readPrevious(AEventInfo currentEvent) throws NoMoreEventsException, - ReadEventException, - InvalidEventSourceException - { - // in random mode there's no looking back - if(getNavigationMode() == NavigationMode.RANDOM) throw new NoMoreEventsException("No more random events left in the buffer"); - //The file we want to pass on to the reading routine - File file = null; - //On the first encounter "directory" might be a file - if (directory.isFile()){ - //set this as the file we want to read - file = directory.getAbsoluteFile(); - //store its parent directory - directory = file.getParentFile(); - } else { - //Get a list fo files - String[] FileList = getListOfFiles(); - //Check there are more files - if (FileList.length == 0) - throw new NoMoreEventsException("No valid files in directory " - +directory.getAbsolutePath()); - //Loop over file list - int iName = FileList.length-1; - //search for next entry that is lexicographically smaller - //taking last one if there is no current one to compare to - while ((currentEvent != null) && - (currentEvent.getSourceName().compareTo(FileList[iName]) <= 0)){ - //Go to next file - --iName; - // if we have reached the end of the list - if (iName < 0) { - // if in loop mode, go to the last event - if(getNavigationMode() == NavigationMode.LOOP) { - iName = FileList.length - 1; - break; - } - // if not in loop mode, abort - else throw new NoMoreEventsException("No more files before" - + currentEvent.getSourceName() + " in directory "+directory.getName()); - } - } - - //Now get the new file - file = new File(directory,FileList[iName]); - } - - //Should now have a file in any case, try to read from it - return readEventFromFile(file); - } -} -/** - * Filter helper class only accepting file names ending in .xml, .gz or .gzip - * @author sboeser - */ -class XMLFilenameFilter implements FilenameFilter -{ - - // accept all readable .xml .gz and .gzip files, no directories - public boolean accept(File dir, String name) - { - //First check the name - if ( ! name.toLowerCase().endsWith(".xml")) - if ( ! name.toLowerCase().endsWith(".gzip")) - if ( ! name.toLowerCase().endsWith(".gz")) - //invalid ending - return false; - - //Check file properties - File f = new File(dir, name); - - //Reject directories - if(! f.isFile()) return false; - //Reject unreadable files - if(! f.canRead()) return false; - - //Finally accept - return true; - - } -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AFilter.java b/graphics/AtlantisJava/src/atlantis/event/AFilter.java deleted file mode 100755 index e6293cba5dfca344c4bcb303e6de1d927e9198bf..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AFilter.java +++ /dev/null @@ -1,275 +0,0 @@ -package atlantis.event; - - -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.APar; -import atlantis.data.AS3DData; - - -/** - * Filter of S3D hits ask Hans Drevermann - */ - -public class AFilter { - - final static int FILTER_GROUP=76; - - static int[] h=null; - static int[] eta=null; - static int[] phi=null; - static int[] layer=null; - static int[] group=null; - static int[] skewGroup=null; - static int[] groupMapping=null; - - static int[] bin=null; - static int[] ll=null; - static int[] hitLayers=null; - static int[] id=null; - static boolean[] good=null; - static int numEtaBins=0; - - private static APar parameterStore = APar.instance(); - - final static int[] layerAsBits=new int[32]; - static { - layerAsBits[0]=1; - for(int i=1; i<32; i++) - layerAsBits[i]=2*layerAsBits[i-1]; - } - - - public static void filter(AS3DData aS3DData) { - if(aS3DData==null) { - AOutput.append("AS3DData not found can't filter\n", ALogInterface.BAD_COMMAND); - return; - } - - int numUsefulPhiBins=parameterStore.get("Fil", "NumPhi").getI(); - int numUsefulEtaBins=parameterStore.get("Fil", "NumEta").getI(); - // +2 for wrap around and edge effect - int numPhiBins=numUsefulPhiBins+2; - - // +2 for edge effects - numEtaBins=numUsefulEtaBins+2; - - double etaRange=parameterStore.get("Fil", "EtaRange").getD(); - int requiredHitsInBin=parameterStore.get("Fil", "NumHits").getI(); - int numSkewSteps=parameterStore.get("Fil", "NumSkew").getI(); - double skewStepSize=parameterStore.get("Fil", "SkewStep").getD(); - - int numHits=aS3DData.makeFilterDrawList(etaRange); - int maxBins=numHits+1; - - if(h==null||h.length<numPhiBins*numEtaBins) h=new int[numPhiBins*numEtaBins]; - if(layer==null||layer.length<numHits) layer=new int[numHits]; - if(eta==null||eta.length<numHits) eta=new int[numHits]; - if(phi==null||phi.length<numHits) phi=new int[numHits]; - if(group==null||group.length<numHits) group=new int[numHits]; - if(skewGroup==null||skewGroup.length<numHits) skewGroup=new int[numHits]; - if(groupMapping==null||groupMapping.length<numHits) groupMapping=new int[numHits]; - // - if(bin==null||bin.length<maxBins) bin=new int[maxBins]; - if(hitLayers==null||hitLayers.length<maxBins) hitLayers=new int[maxBins]; - if(id==null||id.length<maxBins) id=new int[maxBins]; - if(ll==null||ll.length<maxBins) ll=new int[maxBins]; - if(good==null||good.length<maxBins) good=new boolean[maxBins]; - - layer=aS3DData.getLayer(layer); - eta=aS3DData.getIntegerEta(numUsefulEtaBins, etaRange, eta); - - // initialise - for(int i=0; i<numHits; ++i) - group[i]=0; - - if(!parameterStore.get("Fil", "Loop").getStatus()) numSkewSteps=0; - - int numGroups=0; - - for(int step=-numSkewSteps; step<=numSkewSteps; step++) { - double skew=0.; - - // TODO: Check if 166.666 should be the curvature parameter from the parameter store - if(numSkewSteps!=0) - skew=(1./skewStepSize)*step/(numSkewSteps*2*166.666); - - for(int i=0; i<maxBins; ++i) { - hitLayers[i]=0; - good[i]=false; - } - - phi=aS3DData.getIntegerPhi(numUsefulPhiBins, skew, phi); - - int numBins=1; - - for(int i=0; i<numHits; ++i) { - int b=phi[i]*numEtaBins+eta[i]; - - if(h[b]==0) { - h[b]=numBins; - bin[numBins]=b; - numBins++; - } - hitLayers[h[b]]|=layerAsBits[layer[i]]; - } - - // must treat the phi wraparound here...... - - for(int e=0; e<numEtaBins; e++) { - h[(0)*numEtaBins+e]=h[(numUsefulPhiBins)*numEtaBins+e]; - h[(numUsefulPhiBins+1)*numEtaBins+e]=h[(1)*numEtaBins+e]; - } - - int ngood=0; - - for(int i=1; i<numBins; i++) { - int b=bin[i]; - int hitLayersSummed=0; - - // add hits from 3x3 region around this bin - for(int p=b-numEtaBins; p<b+2*numEtaBins; p+=numEtaBins) - for(int e=p-1; e<p+2; ++e) { - int ibin=h[e]; - - if(ibin>0) - hitLayersSummed|=hitLayers[ibin]; - } - if(countBits(hitLayersSummed)>=requiredHitsInBin) { - good[i]=true; - ll[ngood++]=i; - } - } - - for(int i=0; i<ngood; ++i) - id[ll[i]]=0; - - int firstGroup=numGroups+1; - - for(int i=0; i<ngood; ++i) - if(id[ll[i]]==0) - add(ll[i], ++numGroups); - - for(int j=firstGroup; j<=numGroups; ++j) { - int hls=0; - - for(int i=0; i<ngood; i++) - if(id[ll[i]]==j) { - hls|=hitLayers[ll[i]]; - } - if(countBits(hls)<requiredHitsInBin) - for(int i=0; i<ngood; i++) - if(id[ll[i]]==j) - good[ll[i]]=false; - } - - for(int i=0; i<numHits; ++i) { - int b=h[phi[i]*numEtaBins+eta[i]]; - - if(good[b]) - skewGroup[i]=id[b]; - else - skewGroup[i]=0; - } - - // now zero the histogram for next call - for(int i=1; i<numBins; i++) - h[bin[i]]=0; - // wrap around - for(int e=0; e<numEtaBins; e++) { - h[(0)*numEtaBins+e]=0; - h[(numPhiBins-1)*numEtaBins+e]=0; - } - - group=mergeGroups(numHits, numGroups, group, skewGroup); - - } - - group=renumberGroups(numHits, group); - - int num=0; - - for(int i=0; i<numHits; ++i) - if(group[i]>0) num++; - - AOutput.alwaysAppend("\nFiltering:\n Input hits = "+numHits+"\n Num grouped = "+num+"\n",ALogInterface.NORMAL_BOLD); - - aS3DData.setGroup(group); - } - - public static void add(int i, int numGroup) { - id[i]=numGroup; - int b=bin[i]; - - // add hits from 3x3 region around this bin - for(int p=b-numEtaBins; p<b+2*numEtaBins; p+=numEtaBins) - for(int e=p-1; e<p+2; ++e) { - int ibin=h[e]; - - if(good[ibin]&&id[ibin]==0) - add(ibin, numGroup); - } - } - - public static int[] mergeGroups(int numHits, int numGroups, int[] group, int[] skewgroup) { - - for(int i=1; i<=numGroups; ++i) - groupMapping[i]=i; - - for(int i=0; i<numHits; ++i) - if(skewGroup[i]>0&&group[i]>0) { - int g1=groupMapping[group[i]]; - int g2=groupMapping[skewGroup[i]]; - - if(g1!=g2) - for(int g=1; g<=numGroups; ++g) - if(groupMapping[g]==g1||groupMapping[g]==g2) groupMapping[g]=g1; - } - - for(int i=0; i<numHits; ++i) - if(skewGroup[i]>0||group[i]>0) { - int g=skewGroup[i]; - - if(g==0) - g=group[i]; - group[i]=groupMapping[g]; - } - return group; - } - - public static int[] renumberGroups(int numHits, int[] group) { - int numGroups=0; - - for(int i=0; i<numHits; ++i) - if(group[i]>0) { - int g=group[i]; - - numGroups++; - for(int j=i; j<numHits; ++j) - if(group[j]==g) - group[j]=-numGroups; - } - for(int i=0; i<numHits; ++i) - group[i]=-group[i]; - return group; - } - - // Return the number of bits currently set. This is done via a lookup table - - final static int[] countLUT= {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, - 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, - 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, - 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, - 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, - 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, - 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, - 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, - 7, 5, 6, 6, 7, 6, 7, 7, 8}; - - final static int maskByte=255; - - public static int countBits(int bits) { - return countLUT[bits&maskByte]+countLUT[(bits>>>8)&maskByte]+countLUT[(bits>>>16)&maskByte]; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AImageProducer.java b/graphics/AtlantisJava/src/atlantis/event/AImageProducer.java deleted file mode 100644 index 74615cbd896c7140eac9b0e336dd6e199f8f9348..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AImageProducer.java +++ /dev/null @@ -1,129 +0,0 @@ -package atlantis.event; - -import atlantis.utils.*; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -import atlantis.Atlantis; -import atlantis.canvas.ACanvas; -import atlantis.graphics.encoders.AImageEncoder; -import java.awt.Dimension; - - -/** - * Implements ANewEventListener and creates image files - * upon each newEvent call. A scale factor allows to e.g. produce thumbnails by - * scaling down image. The image producer works in two modes: - * a) If no file name is given, a file name will be generated from run and event - * number. In case the output file exists, no file is created but a warning is written out. - * b) If a file name is given, a temporary file is generated first, and then - * renamed to the given file name. If renaming fails, a warning is written out - * and the temporary file is deleted. - * - * @author Sebastian Boeser - */ - -public abstract class AImageProducer implements ANewEventListener -{ - /** File name prefix */ - protected static final String filePrefix = "atlantis"; - /** Minimum number of digits for event- and run-number when writing files */ - protected static final int encodeNumberDigits = 6; - - /** directory to store files in */ - protected final File directory ; - /** Default image dimensions */ - protected final Dimension imageSize; - /** The thumbnail scale */ - protected final double scaleFactor; - /** A fixed filename if given on the command line */ - protected final String fixedFileName; - - /** - * Inner exception class - */ - public static class InstantiationException extends Exception { - //only declare constructor - InstantiationException(String what){ - super(what); - } - }; - - /** - * Fully qualified constructor, - * intializing all the attributes and check the parameters validity - * @param dir the directory in which to save all the files - * @param size the dimensions of the images - * @param scale the factor by which to scale the images - * @param fileName if not null, that file will be overwritten for each event - * @throws InstantiationException if we fail to create the object - */ - protected AImageProducer(String dir, Dimension size, double scale, String fileName) throws InstantiationException - { - // First check the directory parameter - directory = new File(dir); - - //That it exists - if(! directory.exists()) throw new InstantiationException("Directory "+dir+" doesn't exist"); - - //That it is a directory - if(! directory.isDirectory()) throw new InstantiationException(dir + " is not a directory"); - - //And that we can write in it - if(! directory.canWrite()) throw new InstantiationException("Cannot write to directory "+dir); - - //Check frequency and history length arguments - if (scale <= 0) throw new InstantiationException("Negative or zero scale factor"); - - // store all parameters - imageSize = size; - scaleFactor = scale; - fixedFileName = fileName; - - } - - - /** - * Return the string build from this events file name - * @param evt the event info from which to build the filename - * @param minDigit minimum number of digits for run- and event-number - * @return the file name - */ - protected String getEventFileName(AEventInfo evt){ - String nameFormat = String.format("%%s_%%0%dd_%%0%dd",encodeNumberDigits,encodeNumberDigits); - return String.format(nameFormat, - filePrefix,evt.getRunNumber(),evt.getEventNumber()); - } - - - /** - * Safes a byteArray of data into a file given by a fileName - * @param data the data - * @param file the file to write into - * @throws Exception in case of saving fails - */ - protected void saveDataIntoFile(byte[] data, File file) throws IOException - { - - //Sanity check - if ((data == null) ||(file == null)) return; - - //Open output stream and write to output stream - FileOutputStream fos = new FileOutputStream(file); - OutputStream os = new BufferedOutputStream(fos); - os.write(data); - os.flush(); - os.close(); - - } - - /** - * Called whenever a new event appears. Store an image in the directory, - * either with a generated file name (no overwrite) or with a fixed file name (overwrite) - * @param event the event from which to generate the image - */ - public abstract void newEvent(AEvent event); -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/event/ANewEventListener.java b/graphics/AtlantisJava/src/atlantis/event/ANewEventListener.java deleted file mode 100644 index 7657cbe48392accd572107947a1c5cf18ba85308..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/ANewEventListener.java +++ /dev/null @@ -1,18 +0,0 @@ - -package atlantis.event; - -/** - * Interface for all NewEventListener classes. Each time a new event is - * brought to the event manager, the NewEvent:isteners newEvent method is - * called with the new event as an argument - * @author sboeser - */ -public interface ANewEventListener { - - /** - * This method gets called each time a new new is available. - * @param event the new event - */ - abstract public void newEvent(AEvent event); - -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/event/ANewEventSourceListener.java b/graphics/AtlantisJava/src/atlantis/event/ANewEventSourceListener.java deleted file mode 100644 index 6101f3a4f1b900bf3a1ff25760fdc5fb6931a55f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/ANewEventSourceListener.java +++ /dev/null @@ -1,16 +0,0 @@ -package atlantis.event; - -/** - * Interface for all NewEventSourceListener classes. Each time the event source - * is changed, the newEventSourcemethod is called. - * @author maillard - */ -public interface ANewEventSourceListener { - - /** - * This method gets called each time the layout is changed. - * @param eventSource the new event source - */ - abstract public void newEventSource(AEventSource eventSource); - -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AObjectsAssociation.java b/graphics/AtlantisJava/src/atlantis/event/AObjectsAssociation.java deleted file mode 100644 index 6f4b148b43689dd6e9976a2441e68b1b378e3e41..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AObjectsAssociation.java +++ /dev/null @@ -1,26 +0,0 @@ -package atlantis.event; - -/** - * @author Qiang Lu - * - */ -public class AObjectsAssociation extends AAssociation -{ - private String[] key; - - public AObjectsAssociation(String a, String b, String[] associatedKey, - int[] associatedIndex, int[] associatedLinkCount, AEvent e) - { - super(a, b, associatedLinkCount, associatedIndex,e); - this.key = new String[associatedKey.length]; - for (int i=0; i<associatedKey.length; i++) - { - this.key[i] = associatedKey[i]; - } - } - - public String[] getKey() - { - return key; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/event/APngImageProducer.java b/graphics/AtlantisJava/src/atlantis/event/APngImageProducer.java deleted file mode 100644 index 21cd4d7199bf99186a3a39534ebed8edaa08030e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/APngImageProducer.java +++ /dev/null @@ -1,119 +0,0 @@ -package atlantis.event; - -import atlantis.utils.*; -import java.io.File; -import java.io.IOException; - -import atlantis.canvas.ACanvas; -import atlantis.graphics.encoders.AImageEncoder; -import java.awt.Dimension; - - -/** - * Implements ANewEventListener and creates PNG files - * upon each newEvent call. A scale factor allows to e.g. produce thumbnails by - * scaling down image. The image producer works in two modes: - * a) If no file name is given, a file name will be generated from run and event - * number. In case the PNG file exists, no file is created but a warning is written out. - * b) If a file name is given, a temporary file is generated first, and then - * renamed to the given file name. If renaming fails, a warning is written out - * and the temporary file is deleted. - * - * @author Sebastian Boeser - */ - -public class APngImageProducer extends AImageProducer -{ - // the logger - private static final ALogger logger = ALogger.getLogger(APngImageProducer.class); - - // Our image encode - private final AImageEncoder imageEncoder = new AImageEncoder(); - - /** - * Fully qualified constructor, - * intializing all the attributes and check the parameters validity - * @param dir the directory in which to save all the files - * @param size the dimensions of the images - * @param scale the factor by which to scale the images - * @param fileName if not null, that file will be overwritten for each event - * @throws InstantiationException if we fail to create the object - */ - public APngImageProducer(String dir, Dimension size, double scale, String fileName) throws InstantiationException - { - super(dir, size, scale, fileName); - } - - /** - * Called whenever a new event appears. Store a PNG in the directory, - * either with a generated file name (no overwrite) or with a fixed file name (overwrite) - * @param event the event from which to generate the PNG - */ - public void newEvent(AEvent event) - { - - //If auto had been set for size (height is negative), get height from Canvas - if (imageSize.height < 0) imageSize.setSize(imageSize.width, ACanvas.getCanvas().getRespectiveHeight(imageSize.width)); - - //Create the file to write the data into - File pngFile; - //If we don't have a fixed file name, - //generate a unique one based on run- and event number - if (fixedFileName==null){ - - //Now construct all the full path for the file we want to save - String pngName = String.format("%s%s%s.png",directory, - System.getProperty("file.separator"), - getEventFileName(event)); - - // Create file handles to the file and check if it exists - pngFile = new File(pngName); - //Do not overwrite any existing files - if (pngFile.exists()) { - logger.warn("File "+ pngName +" already exists - will not overwrite"); - return; - } - //otherwise generate a temporary file first, - //then move it in place later - } else { - //make a temporary file in the final directory - try { - pngFile = File.createTempFile(filePrefix+"_", ".png",directory); - } catch (IOException ex) { - logger.warn("Failed to create temporary file in "+directory.getAbsolutePath()); - return; - } - } - - //Now create the image. If the scaleFactor equals 1, no scaling will happen. - byte[] pngData = imageEncoder.getScaledPNGData(imageSize.width,imageSize.height,scaleFactor); - - //Now try saving the acquired data, - //and if it shall go to a fixed file, move it there - try { - //Save the PNG - saveDataIntoFile(pngData, pngFile); - //move to fixed file name if requested - if (fixedFileName != null){ - - //Get a handle to the final destination - File fixedFile = new File(directory,fixedFileName); - - //delete target if exits - if (fixedFile.exists() && (!fixedFile.delete())) - throw new IOException("Failed to delete existing file "+fixedFile.getAbsolutePath()); - - //And move the new file in place - if (!pngFile.renameTo(fixedFile)) - throw new IOException("Failed to rename temporary file to "+fixedFile.getAbsolutePath()); - } - } catch (IOException ioe) { - //If we fail, throw a warning - logger.warn("Could not save PNG files for history\n"+ioe.toString()); - } finally { - //In any case, delete the pngFile, if it was just temporary - if (fixedFileName != null) pngFile.delete(); - } - - } -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AStreamedEventSource.java b/graphics/AtlantisJava/src/atlantis/event/AStreamedEventSource.java deleted file mode 100644 index b41e007072f92bc62610ea8c9d065ba3dd61647d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AStreamedEventSource.java +++ /dev/null @@ -1,52 +0,0 @@ -package atlantis.event; - -import atlantis.event.AEventSource.InvalidEventSourceException; -import atlantis.event.AEventSource.NoMoreEventsException; -import java.util.Vector; - -/** - * This interface shall be implemented by all event sources that support event - * streams. Only provides simple get and set methods. - * @author sboeser - */ -public interface AStreamedEventSource extends AEventSource { - - /** - * Exception that is thrown if the stream is invalid - */ - public class InvalidStreamException extends AEventSourceException - { - //Default constructor - public InvalidStreamException() { super(); } - //Constructor with a string - public InvalidStreamException( String message ){ super( message ); } - //Constructor with a description and cause - public InvalidStreamException( String message, Throwable cause ){ super( message, cause ); } - } - - /** - * Get an array of names of all available streams - * @return the array of stream names - * @throws InvalidEventSourceException if the list of streams can not be obtained - */ - Vector<String> getAvailableStreams() throws InvalidEventSourceException; - - /** - * Set the stream from which to provide events - * @param streamName the stream from which to get events - * @throws InvalidStreamException if the given name does not specify a valid stream - * @throws InvalidEventSourceException if the server cannot be contacted to get the stream names - */ - void setStream(String streamName) throws InvalidStreamException, - InvalidEventSourceException; - - /** - * Get the currently selected stream, or the default stream if none is selected - * @return the name of the currently selected stream - * @throws InvalidEventSourceException if the list of streams can not be obtained - * @throws NoMoreEventsException if no stream is available - * - */ - String getStream() throws InvalidEventSourceException, - NoMoreEventsException; -} diff --git a/graphics/AtlantisJava/src/atlantis/event/ASvgImageProducer.java b/graphics/AtlantisJava/src/atlantis/event/ASvgImageProducer.java deleted file mode 100644 index a27830547d92048bb0df102dd37c8a4c96027c74..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/ASvgImageProducer.java +++ /dev/null @@ -1,117 +0,0 @@ -package atlantis.event; - -import java.io.File; -import java.io.IOException; - -import atlantis.utils.*; -import atlantis.canvas.ACanvas; -import atlantis.graphics.encoders.AImageEncoder; -import java.awt.Dimension; - - -/** - * Implements ANewEventListener and creates SVG files - * upon each newEvent call. A scale factor allows to e.g. produce thumbnails by - * scaling down image. The image producer works in two modes: - * a) If no file name is given, a file name will be generated from run and event - * number. In case the output file exists, no file is created but a warning is written out. - * b) If a file name is given, a temporary file is generated first, and then - * renamed to the given file name. If renaming fails, a warning is written out - * and the temporary file is deleted. - * - * @author Tom McLaughlan - */ - -public class ASvgImageProducer extends AImageProducer -{ - // the logger - private static final ALogger logger = ALogger.getLogger(ASvgImageProducer.class); - - // Our image encode - private final AImageEncoder imageEncoder = new AImageEncoder(); - - /** - * Fully qualified constructor, - * intializing all the attributes and check the parameters validity - * @param dir the directory in which to save all the files - * @param size the dimensions of the images - * @param scale the factor by which to scale the images - * @param fileName if not null, that file will be overwritten for each event - * @throws InstantiationException if we fail to create the object - */ - public ASvgImageProducer(String dir, Dimension size, double scale, String fileName) throws InstantiationException - { - super(dir, size, scale, fileName); - } - - /** - * Called whenever a new event appears. Store an SVG in the directory, - * either with a generated file name (no overwrite) or with a fixed file name (overwrite) - * @param event the event from which to generate the SVG - */ - public void newEvent(AEvent event) - { - - //If auto had been set for size (height is negative), get height from Canvas - if (imageSize.height < 0) imageSize.setSize(imageSize.width, ACanvas.getCanvas().getRespectiveHeight(imageSize.width)); - - //Create the file to write the data into - File outFile; - //If we don't have a fixed file name, - //generate a unique one based on run- and event number - if (fixedFileName==null){ - - //Now construct all the full path for the file we want to save - String outFileName = String.format("%s%s%s.svg",directory, - System.getProperty("file.separator"), - getEventFileName(event)); - - // Create file handles to the file and check if it exists - outFile = new File(outFileName); - //Do not overwrite any existing files - if (outFile.exists()) { - logger.warn("File "+ outFileName +" already exists - will not overwrite"); - return; - } - //otherwise generate a temporary file first, - //then move it in place later - } else { - //make a temporary file in the final directory - try { - outFile = File.createTempFile(filePrefix+"_", ".svg",directory); - } catch (IOException ex) { - logger.warn("Failed to create temporary file in "+directory.getAbsolutePath()); - return; - } - } - - //Now try saving the acquired data, - //and if it shall go to a fixed file, move it there - try { - imageEncoder.saveSVG(imageSize.width, imageSize.height, outFile); - - //move to fixed file name if requested - if (fixedFileName != null){ - - //Get a handle to the final destination - File fixedFile = new File(directory,fixedFileName); - - //delete target if exits - if (fixedFile.exists() && (!fixedFile.delete())) - throw new IOException("Failed to delete existing file "+fixedFile.getAbsolutePath()); - - //And move the new file in place - if (!outFile.renameTo(fixedFile)) - throw new IOException("Failed to rename temporary file to "+fixedFile.getAbsolutePath()); - } - } catch (IOException ioe) { - //If we fail, throw a warning - logger.warn("Could not save SVG files for history\n"+ioe.toString()); - } finally { - //In any case, delete the pngFile, if it was just temporary - if (fixedFileName != null) outFile.delete(); - } - - - } -} diff --git a/graphics/AtlantisJava/src/atlantis/event/AURLEventSource.java b/graphics/AtlantisJava/src/atlantis/event/AURLEventSource.java deleted file mode 100644 index 530a3793cd81c0b9e3d728bf2ca2cf64a555e7d3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AURLEventSource.java +++ /dev/null @@ -1,385 +0,0 @@ -package atlantis.event; - -import atlantis.data.AEventFromXML; - -import java.util.ArrayList; - -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.FileNotFoundException; -import java.net.URL; -import java.net.MalformedURLException; - -import java.util.regex.Pattern; -import java.util.regex.Matcher; -import java.util.Random; - -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.utils.ALogger; - -import java.util.Collections; - - -/** - * This class obtains an event from an XML file which is read from - * URL address (from a remote source). - * - * Once the file is read the classes tries to create an internal - * list of XML event files from this remote source which is utilised - * when the user accesses next, resp. previous event from this address. - * - * It is dependent on the fact that the web server supports directory - * listings - i.e. it returns an HTML page which this class parses - * and gets all files conforming ".*\.xml" regular expression. - * - * It is possible to specify only URL with a directory where the event - * files are. - * - * @author sboeser - */ -public class AURLEventSource extends ABufferedEventSource -{ - // get the logger - private static final ALogger logger = ALogger.getLogger(AURLEventSource.class); - // the name of the event source - private String directoryURL = null; - - // needed for random mode - private Random randomGenerator = new Random(); - - /** - * @param mode event navigation mode - * @return true if the requested mode is supported by this source - */ - public boolean supportsNavigationMode(NavigationMode mode) { - if(mode == NavigationMode.SEQUENTIAL || - mode == NavigationMode.RANDOM || - mode == NavigationMode.LOOP) - return true; - return false; - } - - /** - * Constructor with the URL of the directory - * @param sourceName - * @throws atlantis.event.AEventSource.InvalidEventSourceException - */ - public AURLEventSource(String sourceName) throws InvalidEventSourceException - { - - //Make sure the event source starts with http:// - if( ! sourceName.toLowerCase().startsWith("http://")) - throw new InvalidEventSourceException("URL event source name does"+ - "not start with \"http://\""); - - //Store event source - directoryURL = sourceName; - } - - /** - * @return the directory URL string - */ - public String getSourceName() { - return directoryURL; - } - - /** - * Get a list of files in a directory given by a URL - * @param url the url of the directory - * @return a list of urls to the individual files - * @throws atlantis.event.AEventSource.InvalidEventSourceException - */ - private ArrayList<String> getEventListForURL(String url) throws InvalidEventSourceException { - - //the url of the directory we are searching - String baseUrl = url; - //trim any file endings from url - if (url.endsWith(".xml")) - baseUrl = url.substring(0, url.lastIndexOf('/')); - - - //The input stream - need to be closed in the end - InputStreamReader urlStream = null; - BufferedReader br = null; - - //be a bit verbose - logger.info("Trying to get directory listing from " + baseUrl); - - //Create an array to return - ArrayList<String> eventList = new ArrayList<String>(); - - //Now try reading stuff from the web - try { - //Get an input stream reader - urlStream = new InputStreamReader(new URL(baseUrl).openStream()); - //get a buffered reader for that stream - br = new BufferedReader(urlStream); - - // input is the whole line from HTML directory listing - // example to match: <a href="atlantis_event_70417_93.xml"> - // We use regular expressions patterns to catch the lines of interest - // ( ) defines group, group 0 is the whole match and group 1 is - // just the desired file name within the parentheses - Pattern pattern = Pattern.compile("<a href=\"(.*\\.xml)\">"); - - //Loop over all lines - String line = null; - while ((line = br.readLine()) != null) { - //try to match the patter - Matcher matcher = pattern.matcher(line); - if (matcher.find()) // not .match() (!) - { - //Get the first group from the pattern - //i.e the file name and add to our event list - eventList.add(matcher.group(1)); - } - } - - //be a bit verbose - logger.debug("List of " + eventList.size() + " events loaded from " + baseUrl); - - - } catch (MalformedURLException mue) { - String msg = "Incorrect URL address: " + baseUrl; - logger.error(msg); - AOutput.alwaysAppend("\n" + msg + "\n", ALogInterface.WARNING); - throw new InvalidEventSourceException(msg, mue); - } catch (IOException ioe) { - String msg = "IO error while reading URL: " + baseUrl; - logger.error(msg); - AOutput.alwaysAppend("\n" + msg + "\n", ALogInterface.WARNING); - throw new InvalidEventSourceException(msg, ioe); - } finally { - //In any case close everything - try { - br.close(); - urlStream.close(); - } catch (Throwable t) { - //do nothing here - } - } - - //check if there were at least some events - if (eventList.size()==0) - throw new InvalidEventSourceException("No events found at "+baseUrl); - - //In the end sort the event list - Collections.sort(eventList); - - //and return it - return eventList; - - } - - /** - * Read in an event from a fully specified path - * @param fileName the URL to the file - * @param directoryURL the name of the event source - * @return the event - */ - private AEvent readEventFromURL(String fileName, String directoryURL) - throws ReadEventException { - //Things we need to close in the end - InputStream urlStream = null; - BufferedInputStream buffStream = null; - AEvent event = null; - - try { - //Open the url as stream - String fullURL = directoryURL + "/" + fileName; - URL eventURL = new URL(fullURL); - urlStream = eventURL.openStream(); - buffStream = new BufferedInputStream(urlStream); - //then read the event from there - logger.debug("Reading event data stream from " + eventURL.toString() + "..."); - event = AEventFromXML.read(buffStream, fileName); - - } catch (FileNotFoundException fnfe) { - //Show as a warning and rethrow - String msg = "File not found at " + directoryURL+"/"+fileName; - logger.error(msg); - AOutput.alwaysAppend("\n" + msg + "\n", ALogInterface.WARNING); - throw new ReadEventException(msg, fnfe); - } catch (IOException ioe) { - //Show as an error and rethrow - String msg = "IO error when reading " + directoryURL; - logger.error(msg); - AOutput.alwaysAppend("\n" + msg + "\n", ALogInterface.WARNING); - throw new ReadEventException(msg, ioe); - } finally { - try { - if (urlStream != null) { - urlStream.close(); - } - if (buffStream != null) { - buffStream.close(); - } - } catch (Throwable t) { - //Ignore all errors - } - } - return event; - } - - /** - * Read a random event - * @return the random event - * @throws InvalidEventSourceException - * @throws ReadEventException - */ - protected AEvent readRandom() throws InvalidEventSourceException, ReadEventException - { - - String fileName = null; - - //Check if we have been given a fully specified file url - if(directoryURL.endsWith(".xml")){ - //Store the file name from the url - fileName = directoryURL.substring(directoryURL.lastIndexOf('/')+1,directoryURL.length()); - //trim file endings from url - directoryURL = directoryURL.substring(0, directoryURL.lastIndexOf('/')); - - } else { - - //Update event list every time, so we get new files - ArrayList<String> eventList=getEventListForURL(directoryURL); - - //Check there are more files - if (eventList.size() == 0) - throw new InvalidEventSourceException("No valid files at "+directoryURL); - - //Pick a random event - int iName = randomGenerator.nextInt(eventList.size()); - - //Now get the new file - fileName = eventList.get(iName); - } - - //Now read exactly that event and return it - return readEventFromURL(fileName,directoryURL); - } - - - /** - * Read the previous event from the URL directory - * @return the previous event - * @throws NoMoreEventsException - * @throws InvalidEventSourceException - * @throws ReadEventException - */ - public AEvent readNext(AEventInfo currentEvent) throws NoMoreEventsException, - InvalidEventSourceException, - ReadEventException - { - // if random mode is set, return a random event - if(getNavigationMode() == NavigationMode.RANDOM) return readRandom(); - - String fileName = null; - - //Check if we have been given a fully specified file url - if(directoryURL.endsWith(".xml")){ - //Store the file name from the url - fileName = directoryURL.substring(directoryURL.lastIndexOf('/')+1,directoryURL.length()); - //trim file endings from url - directoryURL = directoryURL.substring(0, directoryURL.lastIndexOf('/')); - - } else { - - //Update event list every time, so we get new files - ArrayList<String> eventList=getEventListForURL(directoryURL); - - //Check there are more files - if (eventList.size() == 0) - throw new NoMoreEventsException("No valid files at "+directoryURL); - //Loop over file list - int iName = 0; - //search for next entry that is lexicographically larger - //taking first one if there is no current one to compare to - while ((currentEvent != null) && - (currentEvent.getSourceName().compareTo(eventList.get(iName)) >= 0)){ - //Go to next file - ++iName; - // if we have reached the end of the list... - if (iName == eventList.size()) - // if in loop mode go to the first event - if(getNavigationMode() == NavigationMode.LOOP) { - iName = 0; - break; - } - // if not in loop mode, abort - else throw new NoMoreEventsException("No more files after " - + currentEvent.getSourceName() + " in directory "+directoryURL); - } - - //Now get the new file - fileName = eventList.get(iName); - } - - //Now read exactly that event and return it - return readEventFromURL(fileName,directoryURL); - } - - /** - * Read the previous event from the current URL directory - * @return the previous event - * @throws NoMoreEventsException - * @throws InvalidEventSourceException - * @throws ReadEventException - */ - public AEvent readPrevious(AEventInfo currentEvent) throws NoMoreEventsException, - InvalidEventSourceException, - ReadEventException - { - // in random mode there's no looking back - if(getNavigationMode() == NavigationMode.RANDOM) throw new NoMoreEventsException("No more random events left in the buffer"); - - String fileName = null; - - //Check if we have been given a fully specified file url - if(directoryURL.endsWith(".xml")){ - //Store the file name from the url - fileName = directoryURL.substring(directoryURL.lastIndexOf('/')+1,directoryURL.length()); - //trim file endings from url - directoryURL = directoryURL.substring(0, directoryURL.lastIndexOf('/')); - - } else { - - //Update event list every time, so we get new files - ArrayList<String> eventList=getEventListForURL(directoryURL); - - //Check there are more files - if (eventList.size() == 0) - throw new NoMoreEventsException("No valid files at "+directoryURL); - //Loop over file list - int iName = eventList.size()-1; - //search from the end for the first entry that is lexicographically smaller - //taking last one if there is no previous one to compare to - while ((currentEvent != null) && - (currentEvent.getSourceName().compareTo(eventList.get(iName)) <= 0)){ - //Go to next file - --iName; - // if we have reached the end of the list... - if (iName < 0) - // if in loop mode, go to the last file - if(getNavigationMode() == NavigationMode.LOOP) { - iName = eventList.size()-1; - break; - } - // if not in loop mode, abort - else throw new NoMoreEventsException("No more files before " - + currentEvent.getSourceName() + " in directory "+directoryURL); - } - - //Now get the new file - fileName = eventList.get(iName); - } - - //Now read exactly that event and return it - return readEventFromURL(fileName,directoryURL); - } - -} // class AURLEventSource diff --git a/graphics/AtlantisJava/src/atlantis/event/AZipEventSource.java b/graphics/AtlantisJava/src/atlantis/event/AZipEventSource.java deleted file mode 100644 index 16aeb4d0f5e6b94295701217395b3dfd336a3a0d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/AZipEventSource.java +++ /dev/null @@ -1,478 +0,0 @@ -package atlantis.event; - -import atlantis.data.AEventFromXML; - -import java.io.IOException; -import java.io.File; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.ArrayList; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.util.zip.ZipInputStream; - -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AUtilities; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.zip.ZipException; -import java.util.Random; - -/** - * Reading zip archives from local or network files or from zip files stored within .jar file - */ -public class AZipEventSource implements AEventSource -{ - - //define the source type - private enum SourceType { - JAR_FILE, - ZIP_FILE, - ZIP_NETWORK_FILE - }; - - // current event navigation mode - private NavigationMode eventNavigationMode = NavigationMode.SEQUENTIAL; - - // needed for random mode - private Random randomGenerator = new Random(); - - // A list of entries in the zip file - ArrayList<ZipEntry> ZipEntries = new ArrayList<ZipEntry>(); - // pointer to the current zip entry - int eventIndex = -1; - // flag if zip file is read from jar file (as stream) - SourceType sourceType = null; - // event file name (or event archive name) - String eventSource = null; - - /** - * @return current event navigation mode - */ - public NavigationMode getNavigationMode() { - return eventNavigationMode; - } - - /** - * @param mode sets the event navigation mode - */ - public void setNavigationMode(NavigationMode mode) throws InvalidEventSourceException { - if(supportsNavigationMode(mode)) { - eventNavigationMode = mode; - // go to the first event - eventIndex = -1; - } - else - throw new InvalidEventSourceException("Mode '"+mode+"' not supported by current source"); - } - - /** - * @param mode event navigation mode - * @return true if the requested mode is supported by this source - */ - public boolean supportsNavigationMode(NavigationMode mode) { - if(mode == NavigationMode.SEQUENTIAL || - mode == NavigationMode.RANDOM || - mode == NavigationMode.LOOP) - return true; - return false; - } - - /** - * Constructor with event source - * @param sourceName the name of the source - * @throws InvalidEventSourceException - */ - public AZipEventSource(String sourceName) throws InvalidEventSourceException - { - //Locally opened things - ZipFile zipfile = null; - ZipInputStream stream = null; - - try { - // first check if it is an network file - if (sourceName.startsWith("http://")) { - - //open network zip file input stream - stream = openNetworkStream(sourceName); - //try to read entries from network file - readEntriesFromStream(stream); - //set the source type - sourceType = SourceType.ZIP_NETWORK_FILE; - - } else if (sourceName.startsWith("file://")) { - - // strip the file:// from the source name - sourceName = sourceName.substring(7); - - // Check if this is a regular file - File file = new File(sourceName); - - //Read entries from regular file - if( (file.exists() && file.canRead())){ - - //Now try to open as a zipfile - zipfile = new ZipFile(sourceName); - //Try to read the entries from that file - readEntriesFromFile(zipfile); - //set the source type - sourceType = SourceType.ZIP_FILE; - - - } else { - //might still be a zip file in a jar archive - stream = openJarStream(sourceName); - //try to read entries from jar file - readEntriesFromStream(stream); - //set the source type - sourceType = SourceType.JAR_FILE; - } - } - } catch(AAtlantisException ae) { - //Rethrow - throw new InvalidEventSourceException("Atlantis exception reading from: "+eventSource,ae); - } catch(MalformedURLException mue) { - //Rethrow - throw new InvalidEventSourceException("An unknown protocol is specified: "+eventSource,mue); - } catch(ZipException zfe) { - //Rethrow - throw new InvalidEventSourceException("ZIP format error has occurred: "+eventSource,zfe); - } catch(IOException ioe) { - //Rethrow - throw new InvalidEventSourceException("I/O error has occurred reading: "+eventSource,ioe); - } finally { - //Try to close everthing that has been opened - try { - if (zipfile != null) zipfile.close(); - if (stream != null) stream.close(); - } catch (Throwable t){ - //Do nothing if closing fails - } - } - - //If we have not got a valid source type, throw an error - if (sourceType == null) - throw new InvalidEventSourceException("Could not identify source type of "+sourceName); - - //Make sure there are valid events in the file - if (ZipEntries.size() == 0) - throw new InvalidEventSourceException("No entries in ZIP archive: "+sourceName); - - //Store source name - eventSource=sourceName; - //Otherwise set counter to first event - eventIndex = -1; - } - - /** - * @return the name of the event file or archive - */ - public String getSourceName() { - return eventSource; - } - - /** - * Try to open a zip file in a jar file as input stream - * @param sourceName the name of the zip file - * @return the zip stream - */ - private ZipInputStream openJarStream(String sourceName) throws AAtlantisException - { - //Open as zip input stream - return new ZipInputStream(AUtilities.getFileAsStream(sourceName)); - } - - /** - * Try to open a zip file on the net as input stream - * @param sourceName the URL of the zip file - * @return the zip stream - */ - private ZipInputStream openNetworkStream(String sourceName) throws ZipException, - MalformedURLException, - IOException - { - //Open a network zip file as input stream - return new ZipInputStream(new URL(sourceName).openStream()); - } - - - /** - * Check if this is a valid name of an entry in a zip file or stream - * @param entryName the name of the entry - * @return true if valid - */ - private boolean checkZipEntry(ZipEntry entry){ - //Make sure it is not a directory - if(entry.isDirectory()) return false; - //Make sure it ends with .xml - if (! entry.getName().toLowerCase().endsWith(".xml")) return false; - //everthing fine - return true; - } - - /** - * Get a list of all valid entries from a zip stream - * @param zis the input stream - */ - private void readEntriesFromStream(ZipInputStream zis) throws InvalidEventSourceException - { - try { - //Loop over zip entries - ZipEntry next = null; - while((next = zis.getNextEntry()) != null){ - //If it is valid add it to our list fo entries - if (checkZipEntry(next)) ZipEntries.add(next); - } - } catch(ZipException ze) { - //Rethrow - throw new InvalidEventSourceException("ZIP exception reading entry from zip stream",ze); - } catch(IOException ioe){ - //rethrow - throw new InvalidEventSourceException("I/O exception reading entry from zip stream",ioe); - } - } - - /** - * Get a list of all valid XML file entries from a zip file - * @param file the zip input file - * @throws InvalidEventSourceException - */ - private void readEntriesFromFile(ZipFile file) throws InvalidEventSourceException{ - - //Seems to be a regular file - try{ - //Get the zip file entries - Enumeration<? extends ZipEntry> myenum = file.entries(); - //Loop over zip entries - while(myenum.hasMoreElements()){ - //get the entry - ZipEntry next = (ZipEntry) myenum.nextElement(); - //If it is valid add it to our list fo entries - if (checkZipEntry(next)) ZipEntries.add(next); - } - } catch(IllegalStateException ise){ - //rethrow - throw new InvalidEventSourceException("Zip file was cleased while trying to read entries: "+file.getName()); - } - } - /** - * Read a particular event from a stream. - * Since the file is read as stream, it's not possible to reference a - * particular zip entry. However, we know the number of a zip entry - * we want to get (eventIndex), so we seek (getNextEntry()) to the - * zip entry of interest and then read it. - * @return the event - */ - private AEvent readEventFromStream() throws ReadEventException - { - //Things we need to close in the end - ZipInputStream zis = null; - AEvent event = null; - - try{ - //Check which kind of stream we have and open it - if (sourceType == SourceType.JAR_FILE) - zis = openJarStream(eventSource); - else if (sourceType == SourceType.ZIP_NETWORK_FILE) - zis = openNetworkStream(eventSource); - else - throw new ReadEventException("Trying to read stream from neither jar file nor network file:" +eventSource); - - //Now seek through file to current entry - ZipEntry entry = null; - for(int i = 0; i <= eventIndex; i++) - entry = zis.getNextEntry(); - - //Check if we have reached EOF while skipping - if (entry == null) - throw new ReadEventException("Reached EOF while skippeng to entry #"+eventIndex - +" with name "+ZipEntries.get(eventIndex).getName()+ " in "+eventSource); - - //Next check if this is the entry we wanted to have - if (! entry.getName().equals(ZipEntries.get(eventIndex).getName())) - throw new ReadEventException("Content of zip stream changed since opening it:"+eventSource); - - //Finally read-in this entry - event = AEventFromXML.read(zis, entry.getName()); - } catch (AAtlantisException ae) { - throw new ReadEventException("Atlantis exception reading from: " + eventSource, ae); - } catch (ZipException ze) { - throw new ReadEventException("A ZIP format error has occurred reading entry " + - ZipEntries.get(eventIndex).getName() + " from " + eventSource, ze); - } catch (IllegalStateException ise) { - throw new ReadEventException("The zip file has been closed while reading entry" + - ZipEntries.get(eventIndex).getName() + " from " + eventSource, ise); - } catch (IOException ioe) { - throw new ReadEventException("I/O exception reading from: " + eventSource, ioe); - - } finally { - try { - //Always close the files in the end; - if (zis != null) { - zis.close(); - } - } catch (Throwable t) { - //Do nothing if closing the stream fails - } - } - - //Evertthing is fine, return the event - return event; - } - - /** - * Read a particular event from a zip file - * @param file the zip file - * @return the event - * @throws ReadEventException - */ - private AEvent readEventFromFile() throws ReadEventException - { - ZipFile file = null; - AEvent event = null; - try { - //Open the zip file - file = new ZipFile(eventSource); - //Get the input stream for the requested entry - InputStream stream = file.getInputStream(ZipEntries.get(eventIndex)); - //Get the entry name - String eventName = ZipEntries.get(eventIndex).getName(); - //Read the event - event = AEventFromXML.read(stream,eventName); - } catch (ZipException ze){ - throw new ReadEventException("A ZIP format error has occurred reading entry "+ - ZipEntries.get(eventIndex).getName() + " from "+ eventSource, ze); - } catch (IllegalStateException ise){ - throw new ReadEventException("The zip file has been closed while reading entry"+ - ZipEntries.get(eventIndex).getName() + " from "+ eventSource, ise); - } catch(IOException ioe){ - throw new ReadEventException("I/O error reading entry "+ - ZipEntries.get(eventIndex).getName() + " from "+ eventSource, ioe); - } finally { - //Always close the input stream - try { - if(file != null) file.close(); - } catch (Throwable t) { - //Ignore all errors here - } - } - - //Everything fine so we can return the event - return event; - } - - /** - * Reads a random event from a zipped source - * @return the event - * @throws InvalidEventSourceException - * @throws ReadEventException - */ - protected AEvent randomEvent() throws InvalidEventSourceException, - ReadEventException - { - //Check if we have a valid source - if(( sourceType == null ) || ( eventSource==null )) - throw new InvalidEventSourceException("No valid input source"); - - //Now go to next event - eventIndex = randomGenerator.nextInt(ZipEntries.size()); - - //Now get this stream from its proper source - switch (sourceType){ - case JAR_FILE: return readEventFromStream(); - case ZIP_NETWORK_FILE: return readEventFromStream(); - case ZIP_FILE: return readEventFromFile(); - default: throw new ReadEventException("Unknown event source type"); - } - } - - /** - * Read the next event from a zipped source - * @return the event - * @throws InvalidEventSourceException - * @throws NoMoreEventsException - * @throws ReadEventException - */ - public AEvent nextEvent() throws InvalidEventSourceException, - NoMoreEventsException, - ReadEventException - { - // if random mode is selected, return a random event - if(getNavigationMode() == NavigationMode.RANDOM) return randomEvent(); - - //Check if we have a valid source - if(( sourceType == null ) || ( eventSource==null )) - throw new InvalidEventSourceException("No valid input source"); - - // if we're in loop mode and at the last event, go to the first one - if(getNavigationMode() == NavigationMode.LOOP && eventIndex >= ZipEntries.size() - 1) - eventIndex = 0; - // if we're not in loop mode and at the last event... - else { - // check that there are still some events - if(eventIndex >= ZipEntries.size() - 1){ - String msg="Already at last event in archive"; - // inform user - AOutput.alwaysAppend("\n" + msg+"\n", ALogInterface.WARNING); - throw new NoMoreEventsException(msg); - } - // go to next event. - eventIndex++; - } - - //Now get this stream from its proper source - switch (sourceType){ - case JAR_FILE: return readEventFromStream(); - case ZIP_NETWORK_FILE: return readEventFromStream(); - case ZIP_FILE: return readEventFromFile(); - default: throw new ReadEventException("Unknown event source type"); - } - } - - - /** - * Read the previous event from a zipped source - * @return the event - * @throws InvalidEventSourceException - * @throws NoMoreEventsException - * @throws ReadEventException - */ - public AEvent previousEvent() throws InvalidEventSourceException, - NoMoreEventsException, - ReadEventException - { - - // in random mode there's no looking back - if(getNavigationMode() == NavigationMode.RANDOM) throw new NoMoreEventsException("Cannot go back in random mode"); - - //Check if we have a valid source - if(( sourceType == null ) || ( eventSource==null )) - throw new InvalidEventSourceException("No valid input source"); - - // if we're in loop mode and we're at the first event, go to the last one - if(getNavigationMode() == NavigationMode.LOOP && eventIndex == 0) - eventIndex = ZipEntries.size() -1; - // if we're not il loop mode and at the first event... - else { - // check that there are still some events - if(eventIndex == 0){ - String msg="Already at first event in archive"; - // inform user - AOutput.alwaysAppend("\n" + msg+"\n", ALogInterface.WARNING); - throw new NoMoreEventsException(msg); - } - // go to previous event. - eventIndex--; - } - - //Now get this stream from its proper source - switch (sourceType){ - case JAR_FILE: return readEventFromStream(); - case ZIP_NETWORK_FILE: return readEventFromStream(); - case ZIP_FILE: return readEventFromFile(); - default: throw new ReadEventException("Unknown event source type"); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/event/oncrpc/AONCRPCEventSource.java b/graphics/AtlantisJava/src/atlantis/event/oncrpc/AONCRPCEventSource.java deleted file mode 100644 index 42410d71941835d35f8333275d14bb71c34c0351..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/oncrpc/AONCRPCEventSource.java +++ /dev/null @@ -1,304 +0,0 @@ - -package atlantis.event.oncrpc; - -import atlantis.data.AEventFromXML; -import atlantis.utils.ALogger; - -import atlantis.event.ABufferedEventSource; -import atlantis.event.AEvent; -import atlantis.event.AEventInfo; -import atlantis.event.AStreamedEventSource; -import atlantis.event.AEventSource.InvalidEventSourceException; -import atlantis.event.AEventSource.NoMoreEventsException; -import atlantis.event.AEventSource.ReadEventException; - -import org.acplt.oncrpc.XdrVoid; -import org.acplt.oncrpc.OncRpcTcpClient; -import org.acplt.oncrpc.OncRpcException; -import org.acplt.oncrpc.OncRpcProgramNotRegisteredException; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.net.ConnectException; -import java.net.InetAddress; -import java.util.Arrays; -import java.util.Vector; - -/** - * Implements an event source retrieving events from an ONC/RPC server. - * By implementing a ABufferedEventSource, a number of previous events will be - * available to the user. Care is taken to clear the buffer in case we run into - * memory problems. This event source also provides event streams by implementing - * AStreamedEventSource. - * - * @author sboeser - */ - -public class AONCRPCEventSource extends ABufferedEventSource implements AStreamedEventSource { - - //The logger - private static final ALogger logger = ALogger.getLogger(AONCRPCEventSource.class); - - //The ONC/RPC client - private OncRpcTcpClient client = null; - - //The default timeout value in milliseconds for calling the server - private static final int DEFAULT_TIMEOUT = 2000; - //The name of the stream to read events from - private String currentStream = null; - - /** - * Constructor with the server name and port as a string value - * @param sourceName - * @throws InvalidEventSourceException - */ - public AONCRPCEventSource(String sourceName) throws InvalidEventSourceException { - - //Remove any leading "oncrpc://" indicator - sourceName = sourceName.replaceFirst("oncrpc://", ""); - - //Check if we can split the sourceName in hostName:port pair - String[] sourceParams = sourceName.split(":"); - //Do some sanity check - if (sourceParams.length > 3) - throw new InvalidEventSourceException("Invalid <server[:port][:stream]> specification: "+sourceName); - - //Now try to get the port number if it was given, - //Otherwise get port from portmapper by using 0; - int port = 0; - if ((sourceParams.length > 1)&&(sourceParams[1].length() > 0)){ - try { - port = Integer.decode(sourceParams[1]); - } catch (NumberFormatException nfe){ - throw new InvalidEventSourceException("Invalid port number: "+sourceParams[1]); - } - } - - //More sanity checks - if (port < 0) - throw new InvalidEventSourceException("Invalid port number: "+port); - - //If a stream name was given, set it now - if (sourceParams.length > 2) currentStream = sourceParams[2]; - - - //Now call the fully qualified constructor with the defaul timeout value - createClient(sourceParams[0],port,DEFAULT_TIMEOUT); - - } - - /** - * Constructor with server name, port number and timeout - * @param hostName the name or IP-address of the remote server - * @param port the port number to which the request is send - can be 0 - * @param timeout a timeout value in milliseconds - * @throws InvalidEventSourceException - */ - public AONCRPCEventSource(String hostName, int port, int timeout) throws InvalidEventSourceException { - //Call common constructor entry - createClient(hostName,port,timeout); - } - - /** - * @return a string of the form oncrpc://hostName:port:stream - */ - public String getSourceName() { - return "oncrpc://"+client.getHost().getHostName()+":"+ client.getPort()+ - ((currentStream != null) ? ":"+currentStream : ""); - } - - /** - * This source only supports sequential mode. - * @param mode event navigation mode to test - * @return true if the requested mode is supported by this source - */ - public boolean supportsNavigationMode(NavigationMode mode) { - if(mode == NavigationMode.SEQUENTIAL) - return true; - return false; - } - - /** - * Common entry point for all constructors - * @param hostName the name or IP-address of the remote server - * @param port the port number to which the request is send - * @param timeout a timeout value in milliseconds - * @throws InvalidEventSourceException - */ - private void createClient(String hostName, int port, int timeout) throws InvalidEventSourceException { - - //Now try to create the client - try { - client = new OncRpcTcpClient(InetAddress.getByName(hostName), - Server.ONCRPCSERVERPROG,Server.ONCRPCSERVERVERS,port); - } catch ( ConnectException e ) { - throw new InvalidEventSourceException("Could not connect to "+hostName,e); - } catch ( OncRpcProgramNotRegisteredException e ) { - throw new InvalidEventSourceException("Server not (yet) registered on "+hostName,e); - } catch ( OncRpcException e ) { - throw new InvalidEventSourceException("ONC/RPC exception while connecting to "+hostName,e); - } catch ( IOException e ) { - throw new InvalidEventSourceException("I/O Exception while connecting to "+hostName,e); - } - - //Set the requested timeout - client.setTimeout(timeout); - } - - /** - * Read the next event from the server - * @param currentEvent the current event - * @return the next event - * @throws NoMoreEventsException - * @throws InvalidEventSourceException - * @throws ReadEventException - */ - @Override - protected synchronized AEvent readNext(AEventInfo currentEvent) throws NoMoreEventsException, - InvalidEventSourceException, - ReadEventException { - - //Be verbose - logger.info("Call to remote server "+getSourceName()); - - //Ping the server to make sure it is alive, otherwise try to recreate client - try { - client.call(Server.ONCRPC_NULL_PROC,XdrVoid.XDR_VOID, XdrVoid.XDR_VOID); - } catch (OncRpcException e) { - //Server does not respond to ping, try to recreate client - logger.info("Failed to ping server "+getSourceName()+", trying to recreate client"); - //Use setting from old client to create new client, but allow new port number - createClient(client.getHost().getHostName(),0,client.getTimeout()); - } - - //Create an event request - this may als set the default stream - EventRequest eventReq = new EventRequest(-1,-1,getStream()); - - - //use information from existing event if there is - if (currentEvent != null){ - eventReq.EventNumber = currentEvent.getEventNumber(); - eventReq.RunNumber = currentEvent.getRunNumber(); - } - - //Also prepare the return structure - Event event = new Event(); - - //record calling time - long startTime = System.currentTimeMillis(); - - - // perform the remote call - try { - client.call(Server.ONCRPC_GETEVENT_PROC, eventReq, event); - } catch (OncRpcException e) { - throw new InvalidEventSourceException("Failed to get new event from server",e); - } - - //do some statistics - long callDuration = System.currentTimeMillis() - startTime; - logger.debug("Received " + event.EventData.length + " bytes in " + callDuration + " ms"); - - //Now analyze the event we got - //Check if we already have the event - if (event.isIdentical) - //already have this event - throw new NoMoreEventsException("Already have event "+event.EventNumber + - " from run "+event.RunNumber); - //Check if the stream was available - if (!event.isAvailable) - //make event source invalid - throw new InvalidEventSourceException("No event available for stream "+eventReq.StreamName); - - //Check if the event is compressed - if (event.isCompressed) - //not supported yet - throw new UnsupportedOperationException("Support for compressed events not yet implemented"); - - //It seems we got something worth processing - //Strip the trailing null character - event.EventData=(new String(event.EventData)).trim().getBytes(); - //Wrap the data as an inputstream - ByteArrayInputStream bais = new ByteArrayInputStream(event.EventData); - - //Finally construct a new event and return it - return AEventFromXML.read(bais, currentStream); - } - -/** - * Requesting to read the previouse event from the server only appears - * if we have already reached the beginning of the event buffer. - * Only one current events are provided by the server at any time, thus we - * will always throw a NoMoreEventsException. Handling of the exception is left - * to the GUI interface. - * @param currentEvent will be ignored - * @return nothing as it will always raise an exception - * @throws NoMoreEventsException - */ - @Override - protected AEvent readPrevious(AEventInfo currentEvent) throws NoMoreEventsException - { - throw new NoMoreEventsException("ONC/RPC server does not provide a previous event"); - } - - /** - * Get a list of available streams from the server - * @return the list of stream names - * @throws InvalidEventSourceException if the server cannot be contacted - */ - public synchronized Vector<String> getAvailableStreams() throws InvalidEventSourceException { - - //Prepare response structure - Streams streams = new Streams(); - - - //Call the server - try { - client.call(Server.ONCRPC_GETSTREAMS_PROC, XdrVoid.XDR_VOID, streams); - } catch (OncRpcException e) { - throw new InvalidEventSourceException("Failed to get new stream list from server",e); - } - //We got stream names, so just return them - return new Vector(Arrays.asList(streams.StreamNames)); - } - - /** - * Set a new stream as current stream - * @param streamName the name of the stream - * @throws InvalidStreamException if the stream does not exist at the server - */ - public synchronized void setStream(String streamName) throws InvalidStreamException, - InvalidEventSourceException{ - //Check if the requested stream is available - if (! getAvailableStreams().contains(streamName)) - throw new InvalidStreamException("Stream \""+streamName+"\" not available at server"); - - //Store this as the new current stream - currentStream = streamName; - } - - /** - * Get the currently selected stream - * @return the name of the currently selected stream - * @throws NoMoreEventsException if no streams are available - * @throws InvalidEventSourceException if the list of streams can not be obtained - */ - public synchronized String getStream() throws InvalidEventSourceException, - NoMoreEventsException - { - - //If stream name is not set, set it to first available by default - if (currentStream==null){ - //Get list of streams - Vector<String> streams = getAvailableStreams(); - //If there are none throw a "NoMoreEventsException" - if (streams.size()<1) throw new NoMoreEventsException("No streams available"); - //Now set current stream as first one in list - currentStream=streams.firstElement(); - //be verbose - logger.info("Stream not set, using '"+currentStream+"'"); - } - - return currentStream; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/event/oncrpc/Event.java b/graphics/AtlantisJava/src/atlantis/event/oncrpc/Event.java deleted file mode 100644 index cf34cf74cb0f4f28d38ec18e475252976a64fd1f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/oncrpc/Event.java +++ /dev/null @@ -1,86 +0,0 @@ -package atlantis.event.oncrpc; -import org.acplt.oncrpc.*; -import java.io.IOException; - -/** - * This structure declares the event as returned from a call - * to the ONCRPC_GETEVENT_PROC. - * @author Sebastian Boeser - */ -public class Event implements XdrAble { - - - /** False if no event exists for the requested stream at the server*/ - public boolean isAvailable; - /** True if no new event exists at the server */ - public boolean isIdentical; - /** True if the event data is compressed */ - public boolean isCompressed; - /** The name fo the stream this event belongs to */ - public String StreamName; - /** The number of the event */ - public long EventNumber; - /** The number of the run */ - public long RunNumber; - /** The event data as byte array */ - public byte [] EventData; - - /** - * Constructor - */ - public Event() { - //Initialize variables - isAvailable = false ; - isIdentical = false ; - isCompressed = false ; - StreamName = ""; - EventNumber = -1; - RunNumber = -1; - EventData = null; - } - - /** - * Constructor that can be used with RPC client call - * @param xdr the stream that holds the encoded event - * @throws OncRpcException if decoding fails - * @throws IOException - */ - public Event(XdrDecodingStream xdr) throws OncRpcException, IOException { - xdrDecode(xdr); - } - - /** - * Encode the information in XDR representation - * @param xdr the stream to encode into - * @throws OncRpcException if encoding fails - * @throws IOException - */ - public void xdrEncode(XdrEncodingStream xdr) throws OncRpcException, IOException { - //Encode all fields in proper order into the stream - xdr.xdrEncodeBoolean(isAvailable); - xdr.xdrEncodeBoolean(isIdentical); - xdr.xdrEncodeBoolean(isCompressed); - xdr.xdrEncodeString(StreamName); - xdr.xdrEncodeLong(EventNumber); - xdr.xdrEncodeLong(RunNumber); - xdr.xdrEncodeByteVector(EventData); - } - - /** - * Decode the information from XDR representation - * @param xdr the stream to decode from - * @throws OncRpcException if decoding fails - * @throws IOException - */ - public void xdrDecode(XdrDecodingStream xdr) throws OncRpcException, IOException { - //Decode all fields in proper order from stream - isAvailable = xdr.xdrDecodeBoolean(); - isIdentical = xdr.xdrDecodeBoolean(); - isCompressed = xdr.xdrDecodeBoolean(); - StreamName = xdr.xdrDecodeString(); - EventNumber = xdr.xdrDecodeLong(); - RunNumber = xdr.xdrDecodeLong(); - EventData = xdr.xdrDecodeDynamicOpaque(); - } - -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/event/oncrpc/EventRequest.java b/graphics/AtlantisJava/src/atlantis/event/oncrpc/EventRequest.java deleted file mode 100644 index fa60d7828576b939e7eba61f7d8e74bc8accad39..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/oncrpc/EventRequest.java +++ /dev/null @@ -1,79 +0,0 @@ -package atlantis.event.oncrpc; -import org.acplt.oncrpc.*; -import java.io.IOException; - -/** - * Data structure as passed to the ONCRPC_GETEVENT_PROC - * When sending an event request to the server, we have to specify the stream name, - * along with informatian about events we already have. Negative event and run number - * indicates we don't have any events yet. - * @author Sebastian Boeser - */ -public class EventRequest implements XdrAble { - - /** The event number of the event we already have */ - public long EventNumber; - /** The run number of the event we already have */ - public long RunNumber; - /** The name of the stream we are asking events from */ - public String StreamName; - - /** - * Constructor - */ - public EventRequest() { - //Initialize values - EventNumber = -1; - RunNumber = -1; - StreamName = ""; - } - - /** - * Fully qualified constructor - * @param eventNumber the event number of the event we already have - * @param runNumber the run number of the event we already have - * @param streamName the stream we are asking events from - */ - public EventRequest(long eventNumber, long runNumber, String streamName){ - EventNumber = eventNumber; - RunNumber = runNumber; - StreamName = streamName; - } - - /** - * Construct an event request returned from an rpc call - * @param xdr the stream to construct the request from - * @throws OncRpcException if decoding fails - * @throws IOException - */ - public EventRequest(XdrDecodingStream xdr) throws OncRpcException, IOException { - xdrDecode(xdr); - } - - /** - * Encode the information in XDR representation - * @param xdr the stream to encode into - * @throws OncRpcException if encoding fails - * @throws IOException - */ - public void xdrEncode(XdrEncodingStream xdr) throws OncRpcException, IOException { - //Encode into stream in proper order - xdr.xdrEncodeLong(EventNumber); - xdr.xdrEncodeLong(RunNumber); - xdr.xdrEncodeString(StreamName); - } - - /** - * Decode the information in XDR representation - * @param xdr the stream to decode from - * @throws OncRpcException if decoding fails - * @throws IOException - */ - public void xdrDecode(XdrDecodingStream xdr) throws OncRpcException, IOException { - //Decode from stream in proper order - EventNumber = xdr.xdrDecodeLong(); - RunNumber = xdr.xdrDecodeLong(); - StreamName = xdr.xdrDecodeString(); - } - -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/event/oncrpc/Server.java b/graphics/AtlantisJava/src/atlantis/event/oncrpc/Server.java deleted file mode 100644 index be83e8e71c9fc90f572950e9b216522ea2feab19..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/oncrpc/Server.java +++ /dev/null @@ -1,47 +0,0 @@ -package atlantis.event.oncrpc; - -/** - * A collection of constants used by the "ONCRPCServer" ONC/RPC program. - * These constants need to match the respective definitons on the C++ server - * side, where they are defined in JiveXML/JiveXML/ONCRPCServer.h - * @author Sebastian Boeser - */ -public interface Server { - - /** - * The ID by which the server is identified - */ - public static final int ONCRPCSERVERPROG = 200048965; - - /** - * The version of the current server interface - */ - public static final int ONCRPCSERVERVERS = 2; - - /** - * The ID of the void procdure - */ - public static final int ONCRPC_NULL_PROC = 0; - - /** - * The ID of the getStatus procedure - */ - public static final int ONCRPC_GETSTATUS_PROC = 1; - - /** - * The ID of the getStreams procedure - */ - public static final int ONCRPC_GETSTREAMS_PROC = 2; - - - /** - * The ID of the getEvent procedure - */ - public static final int ONCRPC_GETEVENT_PROC = 3; - - /** - * The ID of the SetNewEvent procedure - is not implemented in this client - */ - //public static final int ONCRPC_SETEVENT_PROC = 4; -} - diff --git a/graphics/AtlantisJava/src/atlantis/event/oncrpc/Streams.java b/graphics/AtlantisJava/src/atlantis/event/oncrpc/Streams.java deleted file mode 100644 index b61d84cb9732befcf307554de160ac1cd1e40cac..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/oncrpc/Streams.java +++ /dev/null @@ -1,53 +0,0 @@ -package atlantis.event.oncrpc; -import org.acplt.oncrpc.*; -import java.io.IOException; - -/** - * Data structure as returned from ONCRPC_GETSTREAMS_PROC is a list of stream names - * available at the server. - * @author Sebastian Boeser - */ -public class Streams implements XdrAble { - - /** The array of stream names */ - public String [] StreamNames; - - /** - * Constructor - */ - public Streams() { - //Array is empty by default, nothing to initialize - } - - /** - * Constructure that can be passed to an RPC client call - * @param xdr the stream to decode from - * @throws OncRpcException if decoding fails - * @throws IOException - */ - public Streams(XdrDecodingStream xdr) throws OncRpcException, IOException { - xdrDecode(xdr); - } - - /** - * Encode the information in XDR representation - * @param xdr the XDR stream to encode into - * @throws OncRpcException if encoding fails - * @throws IOException - */ - public void xdrEncode(XdrEncodingStream xdr) throws OncRpcException, IOException { - //Encode the stream name - xdr.xdrEncodeStringVector(StreamNames); - } - - /** - * Decode the information from XDR representation - * @param xdr the XDR stream to decode from - * @throws OncRpcException if decoding fails - * @throws IOException - */ - public void xdrDecode(XdrDecodingStream xdr) throws OncRpcException, IOException { - //Encode stream names - StreamNames = xdr.xdrDecodeStringVector(); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/event/package.html b/graphics/AtlantisJava/src/atlantis/event/package.html deleted file mode 100644 index b6788c40f433dd2fc0f0a279918517f57222e121..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/package.html +++ /dev/null @@ -1,9 +0,0 @@ -<html> -<head></head> -<body> -<p>This package holds all the main event base classes, such as - the data type base AData or the event class AEvent. It also hold the event - sourc managers and interfaces, as well as their concrete implementations. -</p> -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/event/xmlrpc/AClientXMLRPC.java b/graphics/AtlantisJava/src/atlantis/event/xmlrpc/AClientXMLRPC.java deleted file mode 100755 index 2e795e433c13e7686a6207568cd94105993d9e96..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/xmlrpc/AClientXMLRPC.java +++ /dev/null @@ -1,244 +0,0 @@ -package atlantis.event.xmlrpc; - -import atlantis.utils.*; -import java.net.URL; -import java.net.MalformedURLException; -import java.util.Vector; - -import org.apache.xmlrpc.client.XmlRpcClient; -import org.apache.xmlrpc.client.AsyncCallback; -import org.apache.xmlrpc.XmlRpcException; -import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; -import org.apache.xmlrpc.client.TimingOutCallback; - - -/** - * Implementation of XMLRPC client communicating to the - * server side running within the Athena framework - JiveXML C++ ulxmlrpcpp server, - * Python Interactive server. - * - * @author Zdenek Maxa - */ -public class AClientXMLRPC -{ - private final static ALogger logger = ALogger.getLogger(AClientXMLRPC.class); - - private String methodName = ""; - private AsyncCallback caller = null; - - // timeout - default timeout delay for synchronous calls [ms] - private int timeout = 6000; - - - - - /** - * Constructor for synchronous XMLRPC calls - * @param method - */ - public AClientXMLRPC(String method) - { - this.methodName = method; - this.caller = null; // synchronous calls will be demanded - - } // AClientXMLRPC() ---------------------------------------------------- - - - - /** - * Constructor for asynchronous XMLRPC calls - * @param method - * @param caller - */ - public AClientXMLRPC(String method, AsyncCallback caller) - { - this.methodName = method; - this.caller = caller; // asynchronous calls - - } // AClientXMLRPC() ---------------------------------------------------- - - - - public void setTimeout(int value) - { - this.timeout = value; - - } // setTimeout() ------------------------------------------------------- - - - - /** - * Asynchronous XMLRPC call, returns immediately and callback - * caller is later invoked when result is available. - * @param client - * @param params - * @throws ARemoteCallerException - */ - private void asynchronousCallXMLRPCServer(XmlRpcClient client, Vector params) - throws ARemoteCallerException - { - String msg = ""; - - logger.debug("Asynchronous XMLRPC call ..."); - try - { - client.executeAsync(methodName, params, caller); - - } - catch(Throwable t) - { - if(t instanceof XmlRpcException) - { - msg = "XMLRPC exception occured, performing the remote call failed."; - } - else - { - msg = "Unspecified exception occured, reason: " + t.getMessage(); - } - logger.debug(msg, t); - throw new ARemoteCallerException(msg); - } - - } // asynchronousCallXMLRPCServer() ------------------------------------- - - - - /** - * Synchronous XMLRPC call. Implemented as asynchronous but timing-out - * call so that we wait until the result is available. This way it prevents - * Atlantis from hanging if remote server (Athena) crashes. - * @param client - * @param params - * @return - * @throws ARemoteCallerException - */ - private String synchronousCallXMLRPCServer(XmlRpcClient client, Vector params) - throws ARemoteCallerException - { - String msg = ""; - String result = null; - - logger.debug("Synchronous timing-out XMLRPC call (timeout " + - timeout / 1000 + "s) ..."); - - TimingOutCallback callback = new TimingOutCallback(timeout); - try - { - client.executeAsync(methodName, params, callback); - } - catch(XmlRpcException xmle) - { - msg = "XMLRPC exception occured, performing the remote call failed."; - logger.debug(msg, xmle); - throw new ARemoteCallerException(msg); - } - - - try - { - result = (String) callback.waitForResponse(); - - // no error, result should be event data - all well - logger.debug("Performing timing out XMLRPC call successful."); - } - catch(Throwable t) - { - if(t instanceof InterruptedException) - { - msg = "The request was interrupted, timed out after " + - timeout / 1000 + "s, try increasing the timer."; - } - else if(t instanceof TimingOutCallback.TimeoutException) - { - msg = "No response was received after waiting " + - timeout / 1000 + "s, try increasing the timer."; - } - else - { - msg = "An error was returned by the server, reason: " + t.getMessage(); - } - logger.debug(msg, t); - throw new ARemoteCallerException(msg); - } - - return result; - - } // synchronousCallXMLRPCServer() -------------------------------------- - - - - /** - * Main method calling remote server methods via XMLRPC - * - * @param serverName - name of the XMLRPC server to call method on - * @param port - where XMLRPC runs - * @param params - Vector containing either command to execute, - * name of a remote variable to get its value or expression to - * process (to change some variables's value) - * @return String - result - * @throws ARemoteCallerException - */ - public String callXMLRPCServer(String serverName, int port, Vector params) - throws ARemoteCallerException - { - - XmlRpcClient client = null; - String result = null; - String msg = null; // logging temporary variable - - msg = "Calling " + serverName + ":" + port; - logger.info(msg); - - - // create instance of XMLRPC client - try - { - // Vector type is only acceptable for XmlRpcClient.execute() / - // .executeAsync() - // String is expected on the remote side by C++ ulxmlrpcpp server - // String, among others, is accepted by Python server as well - - // throws MalformedURLException - XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); - config.setServerURL(new URL(serverName + ":" + port)); - client = new XmlRpcClient(); - client.setConfig(config); - logger.debug("XMLRPC client instantiated successfully."); - } - catch(Throwable t) - { - if(t instanceof MalformedURLException) - { - msg = "Could not create XMLRPC client, bad address " + - serverName + ":" + port + "\n" + - "reason: " + t.getMessage(); - } - else - { - msg = "Unspecified exception occured\n" + - "reason: " + t.getMessage(); - } - - logger.debug(msg, t); - throw new ARemoteCallerException(msg); - } - - - if(caller != null) - { - // perform asynchronous XMLRPC call, returns immediately - asynchronousCallXMLRPCServer(client, params); - } - else - { - // synchronous call, timing out synchronous call - result = synchronousCallXMLRPCServer(client, params); - } - - client = null; - return result; - - } // callXMLRPCServer() ------------------------------------------------- - - -} // class AClientXMLRPC ==================================================== \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/event/xmlrpc/ARemoteCallerException.java b/graphics/AtlantisJava/src/atlantis/event/xmlrpc/ARemoteCallerException.java deleted file mode 100755 index b6958f4d1ea06b061a145f4e1c6d2d4def78442a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/xmlrpc/ARemoteCallerException.java +++ /dev/null @@ -1,22 +0,0 @@ -package atlantis.event.xmlrpc; - -import atlantis.utils.*; - - -/** - * - * Exception thrown after errors occured during calls - * to remote server methods (within Athena) via XMLRPC - * - * @author Zdenek Maxa - */ -public class ARemoteCallerException extends AAtlantisException -{ - public ARemoteCallerException(String msg) - { - super("Exception while calling remote procedure.\n" + msg); - - } // ARemoteCallerException() ------------------------------------------- - - -} // class ARemoteCallerException =========================================== diff --git a/graphics/AtlantisJava/src/atlantis/event/xmlrpc/AServerXMLRPC.java b/graphics/AtlantisJava/src/atlantis/event/xmlrpc/AServerXMLRPC.java deleted file mode 100644 index 8d481b260b6e3973522d8dc73703ebdf40c95773..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/xmlrpc/AServerXMLRPC.java +++ /dev/null @@ -1,43 +0,0 @@ -package atlantis.event.xmlrpc; - -import atlantis.utils.*; -import java.io.IOException; -import org.apache.xmlrpc.XmlRpcException; -import org.apache.xmlrpc.webserver.WebServer; -import org.apache.xmlrpc.server.XmlRpcServer; -import org.apache.xmlrpc.server.PropertyHandlerMapping; - -/** - * - * @author Adam Davison - */ -public class AServerXMLRPC { - - private static ALogger logger = ALogger.getLogger(AServerXMLRPC.class); - - private WebServer m_ws; - - public AServerXMLRPC(int port, Class handler) throws XmlRpcException { - - logger.debug("Attempting to create XMLRPC server on port " + port); - logger.debug("Serving requests to handler of type " + handler.getName()); - - m_ws = new WebServer(port); - XmlRpcServer xmlRpcServer = m_ws.getXmlRpcServer(); - PropertyHandlerMapping phm = new PropertyHandlerMapping(); - phm.addHandler(handler.getName(), handler); - xmlRpcServer.setHandlerMapping(phm); - - logger.debug("XMLRPC server created successfully"); - - } - - public void start() throws IOException { - - logger.debug("Attempting to start XMLRPC server"); - m_ws.start(); - logger.info("XMLRPC server started"); - - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/event/xmlrpc/AServerXMLRPCEventSource.java b/graphics/AtlantisJava/src/atlantis/event/xmlrpc/AServerXMLRPCEventSource.java deleted file mode 100644 index f3bf0fe2c6840549d5ec4d88c0af8298c051f9bc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/xmlrpc/AServerXMLRPCEventSource.java +++ /dev/null @@ -1,146 +0,0 @@ -package atlantis.event.xmlrpc; - -import atlantis.utils.*; -import atlantis.canvas.ACanvas; -import atlantis.data.AEventFromXML; -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.event.AEventSource; -import atlantis.globals.AGlobals; -import atlantis.graphics.encoders.AImageEncoder; -import java.io.ByteArrayInputStream; - -/** - * - * @author Adam Davison - */ -public class AServerXMLRPCEventSource implements AEventSource{ - - private static ALogger logger = ALogger.getLogger(AServerXMLRPCEventSource.class); - - private AEventManager m_aem; - private ACanvas m_canv; - private AImageEncoder m_ie; - - private AEvent m_event = null; // Current event - private String m_sourcename = ""; // Source name - - private NavigationMode eventNavigationMode = NavigationMode.PUSH; - - public AServerXMLRPCEventSource() { - m_aem = AEventManager.instance(); - m_canv = ACanvas.getCanvas(); - m_ie = new AImageEncoder(); - } - - public String getVersion() { - return AGlobals.instance().getVersion(); - } - - public boolean isReady() { - return true; - } - - public boolean shutdown() { - logger.info("Exiting atlantis..."); - System.exit(0); - return true; - } - - public NavigationMode getNavigationMode() { - return eventNavigationMode; - } - - public boolean supportsNavigationMode(NavigationMode mode) { - if(mode == NavigationMode.PUSH) - return true; - return false; - } - - public void setNavigationMode(NavigationMode mode) throws InvalidEventSourceException { - if(mode != NavigationMode.PUSH) - throw new InvalidEventSourceException("Mode '"+mode.name()+"' not supported by current source"); - eventNavigationMode = mode; - } - - private void setEventFromBytes(byte[] eventdata, String sourcename) throws Exception { - AEvent e = AEventFromXML.read(new ByteArrayInputStream(eventdata), sourcename); - - m_event = e; - m_sourcename = sourcename; - - // Force update from event manager - m_aem.setEventSource(this); - m_aem.nextEvent(); - } - - private byte[] getSingleImage(int w, int h, String type, double s) throws Exception { - if (type.equalsIgnoreCase("png")) { - return m_ie.getPNGData(w, h); - } else if (type.equalsIgnoreCase("scaledpng")) { - return m_ie.getScaledPNGData(w, h, s); - } - - throw new Exception("Unknown image format: " + type); - } - - private byte[] getSingleImageAspect(int w, String type, double s) throws Exception { - int h = m_canv.getRespectiveHeight(w); - return getSingleImage(w, h, type, s); - } - - public byte[][] generateDefaultImages(byte[] eventdata, String sourcename, - int width, double thumb_scale) { - - byte ret[][] = new byte[2][]; - - try { - setEventFromBytes(eventdata, sourcename); - ret[0] = getSingleImageAspect(width, "png", 0.0); - ret[1] = getSingleImageAspect(width, "scaledpng", thumb_scale); - } catch (Exception e) { - logger.error("Error while handling request to generateDefaultImages()", e); - return null; - } - - return ret; - } - - public AEvent nextEvent() throws NoMoreEventsException, InvalidEventSourceException, ReadEventException { - if (m_event == null) { - throw new InvalidEventSourceException(); - } - return m_event; - } - - public AEvent previousEvent() throws NoMoreEventsException, InvalidEventSourceException, ReadEventException { - throw new NoMoreEventsException(); - } - - public String getSourceName() { - return m_sourcename; - } - - /*public byte[][] generateImages(byte[] eventdata, String sourcename, - Integer nimgs, Object[] w, Object[] h, Object[] type, Object[] s) { - - byte ret[][] = new byte[nimgs][]; - - try { - setEventFromBytes(eventdata, sourcename); - - for (int i = 0; i < nimgs; i++) { - // Handle cast of s better here - ret[i] = getSingleImage((Integer) (w[i]), (Integer) (h[i]), - (String) (type[i]), (Double) (s[i])); - } - - } catch (Exception e) { - logger.error("Error while handling request to generateImages()", e); - return null; - } - - return ret; - }*/ - -} diff --git a/graphics/AtlantisJava/src/atlantis/event/xmlrpc/AXMLRPCEventSource.java b/graphics/AtlantisJava/src/atlantis/event/xmlrpc/AXMLRPCEventSource.java deleted file mode 100644 index 29967b6e31068802992ea9c0dd1d6631d78738d5..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/event/xmlrpc/AXMLRPCEventSource.java +++ /dev/null @@ -1,238 +0,0 @@ - -package atlantis.event.xmlrpc; - -import atlantis.event.*; -import atlantis.data.AEventFromXML; -import atlantis.Atlantis; -import atlantis.event.AEventSource.InvalidEventSourceException; -import atlantis.event.AEventSource.NoMoreEventsException; -import atlantis.event.AEventSource.ReadEventException; - -import atlantis.utils.ALogger; - -import java.io.ByteArrayInputStream; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.Vector; - - -/** - * Implements an event source retrieving events from an XMLRCP server. - * By implementing a ABufferedEventSource, a number of previous events will be - * available to the user. Care is taken to clear the buffer in case we run into - * memory problems. - * - * @author sboeser - */ - -public class AXMLRPCEventSource extends ABufferedEventSource { - - //The logger - private static final ALogger logger = ALogger.getLogger(AXMLRPCEventSource.class); - - //The XMLRPC client - private AClientXMLRPC XMLRPCClient = null; - //The Method to call on the server side - private static final String GETEVENTDATA = "getEventData"; - //The default timeout value in milliseconds for calling the server - private static final int DEFAULT_TIMEOUT = 2000; - //The name of the local machine (send along with event request) - private String localMachineName = "<unknown>"; - //The name and port number of the remote host - private String remoteMachineName = null; - //The port number to which we should connect - private Integer portNumber = null; - //The timeout for a request - private Integer timeOut = null; - - /** - * Constructor with the server name and port as a string value - * @param sourceName - * @throws InvalidEventSourceException - */ - public AXMLRPCEventSource(String sourceName) throws InvalidEventSourceException { - - //Remove any leading "xmlrpc://" indicator - sourceName = sourceName.replaceFirst("xmlrpc://", ""); - //try to split sourceName in serverName:port pair - String[] sourceParams = sourceName.split(":"); - //Do some checks - if (sourceParams.length != 2) - throw new InvalidEventSourceException("Invalid <server:port> specification: "+sourceName); - - //Try to get the port number - int port = -1; - try { - port = Integer.decode(sourceParams[1]); - } catch (NumberFormatException nfe){ - throw new InvalidEventSourceException("Invalid port number: "+sourceParams[1]); - } - - if (port < 0) - throw new InvalidEventSourceException("Invalid port number: "+port); - - //Now call the fully qualified constructor with the defaul timeout value - CreateXMLRPCEventSource(sourceParams[0],port,DEFAULT_TIMEOUT); - - } - - /** - * Constructor with server name, port number and timeout - * @param serverName the name or IP-address of the remote server - * @param port the port number to which the request is send - * @param timeout a timeout value in milliseconds - * @throws InvalidEventSourceException - */ - public AXMLRPCEventSource(String serverName, int port, int timeout) - throws InvalidEventSourceException { - //Call common constructor entry - CreateXMLRPCEventSource(serverName,port,timeout); - } - - /** - * @return a string of the form xmlrpc://servername:port - */ - public String getSourceName() { - return "xmlrpc://"+remoteMachineName+":"+portNumber; - } - - /** - * @param mode event navigation mode - * @return true if the requested mode is supported by this source - */ - public boolean supportsNavigationMode(NavigationMode mode) { - if(mode == NavigationMode.SEQUENTIAL) - return true; - return false; - } - - /** - * Common entry point for all constructors - * @param serverName the name or IP-address of the remote server - * @param port the port number to which the request is send - * @param timeout a timeout value in milliseconds - * @throws InvalidEventSourceException - */ - private void CreateXMLRPCEventSource(String serverName, int port, int timeout) - throws InvalidEventSourceException { - - //Store the input values - remoteMachineName = serverName; - portNumber = port; - timeOut = timeout; - - //try to obtain the name of the local machine - try { - localMachineName = InetAddress.getLocalHost().getHostName(); - } catch (UnknownHostException ex) { - //Can't get name of local host - String msg = "Unable to obtain local machine name, using \"" - + localMachineName +"\" instead"; - logger.error(msg); - } catch(Exception ex) { - //Rethrow everything else as invalid source exception - throw new InvalidEventSourceException("Exception trying to obtain local machine name",ex); - } - - //Finally create a new AClientXMLRPC object - XMLRPCClient = new AClientXMLRPC(GETEVENTDATA); - - } - - /** - * Read the next event from the server - * @param currentEvent the current event - * @return the next event - * @throws NoMoreEventsException - * @throws InvalidEventSourceException - * @throws ReadEventException - */ - @Override - protected AEvent readNext(AEventInfo currentEvent) throws NoMoreEventsException, - InvalidEventSourceException, - ReadEventException { - //Be verbose - logger.info("Call to remote server xmlrpc://" + remoteMachineName + ":" + portNumber.toString()); - - //send the name of the local machine to the JiveXML server - Vector<String> parameters = new Vector(); - parameters.add(localMachineName); - - //record calling time - long startTime = System.currentTimeMillis(); - - //The XMLRPC client will return data as a string - String eventXMLData = null; - - // perform the remote call - try { - eventXMLData = XMLRPCClient.callXMLRPCServer("http://"+remoteMachineName, portNumber, parameters); - } catch (ARemoteCallerException ex) { - //An error occured - String msg = "readNext(): Exception while calling remote server"; - logger.error(msg,ex); - //rethrow - throw new InvalidEventSourceException(msg, ex); - } - - //do some statistics - long callDuration = System.currentTimeMillis() - startTime; - logger.debug("Received " + eventXMLData.length() + " bytes in " + callDuration + " ms"); - - - //If there is just no new event, we should get back an empty string - if (eventXMLData.length() == 0) { - throw new NoMoreEventsException("No event available from the server (yet)"); // something was received, going to process the result - } - if (!(eventXMLData.startsWith("<?xml"))) { - String msg = "Invalid event data received from JiveXML server"; - logger.error(msg); - throw new ReadEventException(msg); - } - - - - //So it seems we got something worth processing - logger.info("Received data from remote server, going to process it ..."); - - // Wrap the string as an inputstream - ByteArrayInputStream bais = new ByteArrayInputStream(eventXMLData.getBytes()); - - //Construct a new event - AEvent event = AEventFromXML.read(bais, remoteMachineName+":"+portNumber); - - /** - * The XMLRPC server is not clever enough to return no event if there is no - * new one. In order to avoid filling the buffer with identical events, we - * therefore check here if we don't already have that event, and throw a - * NoMoreEventsException in case we do. - */ - if (event.equals(currentEvent)){ - String msg = "Already have event "+event.getEventNumber()+" in run " - + event.getRunNumber() + " - ignored!"; - throw new NoMoreEventsException(msg); - } - - - //Now we are sure we have a next event, return it - return event; - - } - -/** - * Requesting to read the previous event from the server only appears - * if we have already reached the beginning of the event buffer. - * Only one current events are provided by the server at any time, thus we - * will always throw a NoMoreEventsException. Handling of the exception is left - * to the GUI interface, and may e.g be ignored in loop mode. - * @param currentEvent will be ignored - * @return nothing as it will always raise an exception - * @throws NoMoreEventsException - */ - @Override - protected AEvent readPrevious(AEventInfo currentEvent) throws NoMoreEventsException - { - throw new NoMoreEventsException("XMLRPC server does not provide a previous event"); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/AAtlasDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/AAtlasDetector.java deleted file mode 100755 index bf8b9a267fbf1e30513cf28aacc2ab8d5102833d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/AAtlasDetector.java +++ /dev/null @@ -1,119 +0,0 @@ -package atlantis.geometry; - -import java.util.regex.Pattern; - -import atlantis.config.ADefaultValues; -import atlantis.utils.ALogger; - - -/** - * AAtlasDetector - * contains one instance of - * ABoxDetectors (which contains all instances of ABoxDetector) (MDT,RPC in barrel) - * ATrapezoidDetectors (which contains all instances of ATrapezoidDetector) (MDT,TGC endcap) - * AGeneralDetectors (which contains all instances of AGeneralPathDetector, - * ADiscDetector, ARectangleDetector) (all others) - */ -public class AAtlasDetector extends ADetectorSystem -{ - private static ALogger logger = ALogger.getLogger(AAtlasDetector.class); - private static ADetectorSystem theDetector; - - public AAtlasDetector(String geomIdCalo) - { - super(new ADetectors[] - { - new AGeneralDetectors( - new AGeometryFromXMLReader().readDetectorGeometryFromXML(geomIdCalo)) - }); - - logger.info("Using geometry file: " + geomIdCalo); - - setGeometryName(geomIdCalo); - - } // AAtlasDetector(String fileName) ------------------------------------ - - - - public AAtlasDetector(String geomIdCalo, String geomMuon) - { - super(new ADetectors[] - { - new ABoxDetectors( - new AGeometryFromXMLReader().readDetectorGeometryFromXML(geomMuon)), - new ATrapezoidDetectors( - new AGeometryFromXMLReader().readDetectorGeometryFromXML(geomMuon)), - new AGeneralDetectors( - new AGeometryFromXMLReader().readDetectorGeometryFromXML(geomMuon)), - new AGeneralDetectors( - new AGeometryFromXMLReader().readDetectorGeometryFromXML(geomIdCalo)) - }); - - logger.info("Using geometry file: " + geomIdCalo); - logger.info("Using geometry file: " + geomMuon); - - setGeometryName(geomIdCalo); - - } // AAtlasDetector(String fileName, String muFileName) ----------------- - - - - private static void setGeometryName(String absFileName) - { - // default geometry file, shall always be AGeometry.xml - // arbitrary, named geometry file, geometry name after '_' character - // (but there is also AGeometryTB.xml) - String name = "AGeometry"; - String ext = ".xml"; - String pattern = ".*" + name + "_?.*" + ext; - - if(Pattern.compile(pattern).matcher(absFileName).matches()) - { - int s = absFileName.lastIndexOf(name); - int e = absFileName.lastIndexOf(ext); - String r = absFileName.substring(s + name.length(), e); - if(r.startsWith("_")) - { - // arbitrary, named geometry - geometryName = r.substring(1); // without leading _ - ADefaultValues.set("GeometryName", geometryName); - } - else if("".equals(r)) - { - // default geometry (no name given: "") - geometryName = "<default>"; - ADefaultValues.set("GeometryName", ""); - } - else - { - geometryName = r; - ADefaultValues.set("GeometryName", geometryName); - } - } - else - { - logger.warn("Geometry name not matching regular expression: " + - pattern + "\n geometry name will be: n/a"); - geometryName = "n/a"; - } - - } // setGeometryName() -------------------------------------------------- - - - /** - * @return the detector - */ - public static ADetectorSystem getDetector() { - return theDetector; - } - - - /** - * @param theDetector the ATLAS detector geometry to be used - */ - public static void setDetector(ADetectorSystem theDetector) { - AAtlasDetector.theDetector = theDetector; - } - - -} // class class AAtlasDetector ============================================= diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ABarrelCalorimeterDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/ABarrelCalorimeterDetector.java deleted file mode 100755 index 870a7d46f7efaad662fde89ff511a6c20fcadb8d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ABarrelCalorimeterDetector.java +++ /dev/null @@ -1,284 +0,0 @@ -package atlantis.geometry; - -import atlantis.graphics.ACoord; -import atlantis.graphics.AClipper; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AMath; - -/** - * Class representing a calorimeter part in the barrel section of ATLAS. - * - * @author Eric Jansen - */ -public class ABarrelCalorimeterDetector extends ACalorimeterDetector { - - /** - * Constructs a new barrel calorimeter object. - * @param name String name of the object - * @param color String name of the color used to draw this object - * @param sampling int sampling of this calorimeter part - * @param region int region of this calorimeter part - * @param rMin double inner radius - * @param rMax double outer radius - * @param zMin double inner z - * @param zMax double outer z - * @param eta0 double start of the first cell in eta - * @param deta double size of a cell in eta - * @param neta int number of cells in eta - * @param meta int eta index of the first cell - * @param phi0 double start of the first cell in phi - * @param nphi int number of cells in phi - */ - public ABarrelCalorimeterDetector(String name, String color, int sampling, int region, - double rMin, double rMax, double zMin, double zMax, - double eta0, double deta, int neta, int meta, - double phi0, int nphi) { - super(name, color); - - // Just to be sure we take absolute values here. - this.sampling = Math.abs(sampling); - this.region = Math.abs(region); - - this.rMin = rMin; - this.rMax = rMax; - this.zMin = zMin; - this.zMax = zMax; - this.eta0 = eta0; - this.deltaEta = deta; - this.numEta = neta; - this.minEta = meta; - this.phi0 = Math.toRadians(phi0); - this.numPhi = nphi; - this.deltaPhi = 2.*Math.PI/numPhi; - - this.detEtaMin = AMath.etaAbs(this.zMax, this.rMax); - this.detEtaMax = AMath.etaAbs(this.zMin, this.rMin); - - if (this.eta0 <= 0.0) { - this.zMin = -this.zMax; - this.detEtaMin = -this.detEtaMax; - } - - // This one is used for clipping the cell geometry in rho-z. - this.clipper = new AClipper(this.zMin, this.zMax, this.rMin, this.rMax); - - // These arrays are used by the getDetectorIndex() method in ACalorimeterData. - // They provide fast mapping of hits to detectors. - if (this.name.indexOf("LAr") >= 0 && this.sampling < lar[1].length - && this.region < lar[1][this.sampling].length) { - - lar[1][this.sampling][this.region] = detectors.indexOf(this); - } else if (this.name.equals("TILE Barrel") && this.sampling < tile.length) { - tile[this.sampling] = detectors.indexOf(this); - - } else if (this.name.equals("Extended TILE") && this.sampling < tile_ext.length) { - tile_ext[this.sampling] = detectors.indexOf(this); - - } else { - System.out.println("Unknown calorimeter object: '" + this.name + "'" - + " some hits might not be displayed correctly."); - } - } - - /** - * Returns the y-x geometry of the full calorimeter part. - * @return ACoord polygons representing geometry - */ - protected ACoord getYXUser() { - if (!globals.getUseOpenGL()) { - int numPoints = 2 * (numPhi + 1); - double[][] hv = new double[2][numPoints]; - for (int i = 0; i < numPhi + 1; i++) { - hv[0][i] = rMin * Math.cos(phi0 + i * deltaPhi); - hv[1][i] = rMin * Math.sin(phi0 + i * deltaPhi); - hv[0][numPhi + 1 + i] = rMax * Math.cos(phi0 - i * deltaPhi); - hv[1][numPhi + 1 + i] = rMax * Math.sin(phi0 - i * deltaPhi); - } - return new ACoord(hv); - } else { - return new ACoord(generateAnnulusTris(numPhi, phi0, rMin, rMax)); - } - } - - /** - * Returns the rho-z geometry of the full calorimeter part. - * @return ACoord polygons representing geometry - */ - protected ACoord getRZUser() { - double[] h, v; - - double etaMax = eta0 + numEta * deltaEta; - double etaMin; - if (eta0 <= 0.0) { - etaMin = -etaMax; - } else { - etaMin = eta0; - } - - // Calculate the polygon in the positive h and v. - if (name.indexOf("TILE") >= 0) { - h = new double[] {zMax, zMin, zMin, zMax}; - v = new double[] {rMax, rMax, rMin, rMin}; - } else { - double z0 = rMax*Math.sinh(etaMax); - double z1 = rMax*Math.sinh(etaMin); - double z2 = rMin*Math.sinh(etaMin); - double z3 = rMin*Math.sinh(etaMax); - - h = new double[] {z0, z1, z2, z3}; - v = new double[] {rMax, rMax, rMin, rMin}; - } - - // Clip the polygon. - ACoord coord = clipper.clipPolygon(h, v, h.length); - - // Copy it to negative v. - coord = new ACoord(coord, coord.mirrorV()); - if (eta0 > 0.0) { - // If it doesn't continue through h=0, copy it to negative h. - coord = new ACoord(coord, coord.mirrorH()); - } - - return coord; - } - - /** - * Returns the phi-rho geometry of the full calorimeter part. - * @return ACoord polygons representing geometry - */ - protected ACoord getFRUser() { - double[][] hv = new double[2][]; - - hv[0] = new double[] {rMin, rMax, rMax, rMin}; - hv[1] = new double[] {360., 360., 0., 0.}; - - return new ACoord(hv); - } - - /** - * Returns the y-x geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getYXCell(int eta, int phi) { - if (parameterStore.get("YX", "Mode").getI() != AProjectionYX.MODE_STANDARD) return ACoord.NO_DATA; - double[][] hv = new double[2][]; - double phiMin = phi0+phi*deltaPhi; - double phiMax = phiMin+deltaPhi; - - hv[0] = new double[] {rMax*Math.cos(phiMin), rMax*Math.cos(phiMax), - rMin*Math.cos(phiMax), rMin*Math.cos(phiMin)}; - hv[1] = new double[] {rMax*Math.sin(phiMin), rMax*Math.sin(phiMax), - rMin*Math.sin(phiMax), rMin*Math.sin(phiMin)}; - - return new ACoord(hv); - } - - /** - * Returns the rho-z geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @param side int sign of the z coordinate of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getRZCell(int eta, int phi, int side) { - double[][] hv = new double[2][]; - int sign = getRSign(phi); - - if (side != 0) side /= Math.abs(side); - - if (name.indexOf("TILE") >= 0) { - // Outer layer of TILE has eta increments of two. - if (sampling == 2) eta = minEta + (eta-minEta)/2; - - double etaMin = eta0+(eta-minEta)*deltaEta; - double etaMax = etaMin+deltaEta; - - if (name.indexOf("Barrel") >= 0 && sampling == 1) { - double dr = (rMax-rMin); - double r0 = rMin; - double r1 = rMin+dr/2.; - double r2 = rMax; - double z0 = (rMin+dr/4.) * Math.sinh(etaMin); - double z1 = (rMax-dr/4.) * Math.sinh(etaMin); - double z2 = (rMin+dr/4.) * Math.sinh(etaMax); - double z3 = (rMax-dr/4.) * Math.sinh(etaMax); - - if (eta == this.minEta && this.zMin > 0) z0 = z1 = this.zMin; - if (eta == this.minEta + this.numEta - 1) z2 = z3 = this.zMax; - - hv[0] = new double[] {z3, z1, z1, z0, z0, z2, z2, z3}; - hv[1] = new double[] {r2, r2, r1, r1, r0, r0, r1, r1}; - } else { - double zMin = (rMin+rMax)/2. * Math.sinh(etaMin); - double zMax = (rMin+rMax)/2. * Math.sinh(etaMax); - - if (eta == this.minEta && this.zMin > 0)zMin = this.zMin; - if (eta == this.minEta + this.numEta - 1) zMax = this.zMax; - - hv[0] = new double[] {zMax, zMin, zMin, zMax}; - hv[1] = new double[] {rMax, rMax, rMin, rMin}; - } - } else if (name.indexOf("LAr") >= 0) { - double etaMin = eta0+(eta-minEta)*deltaEta; - double etaMax = etaMin+deltaEta; - - hv[0] = new double[] {rMax*Math.sinh(etaMax), rMax*Math.sinh(etaMin), - rMin*Math.sinh(etaMin), rMin*Math.sinh(etaMax)}; - hv[1] = new double[] {rMax, rMax, rMin, rMin}; - } else { - return ACoord.NO_DATA; - } - - // Clip the cell and send it to the right quadrant. - ACoord coord = clipper.clipPolygon(hv[0], hv[1], hv[0].length); - for (int i=0; i<coord.hv[0][0].length; i++) { - coord.hv[0][0][i] *= side; - coord.hv[1][0][i] *= sign; - } - - return coord; - } - - /** - * Returns the eta-phi geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @param side int sign of the z coordinate of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getVPCell(int eta, int phi, int side) { - double[][] hv = new double[2][]; - double etaMin = eta0+(eta-minEta)*deltaEta; - double etaMax = etaMin+deltaEta; - double phiMin = Math.toDegrees(phi0 + phi*deltaPhi); - double phiMax = phiMin + Math.toDegrees(deltaPhi); - - side /= Math.abs(side); - - hv[0] = new double[] {side*etaMax, side*etaMin, side*etaMin, side*etaMax}; - hv[1] = new double[] { phiMax, phiMax, phiMin, phiMin}; - - return new ACoord(hv); - } - - /** - * Returns the eta value of the center (in eta) of a cell. - * @param eta int eta index of the cell - * @param side int sign of the z coordinate of the cell - * @return double eta value - */ - public double getEta(int eta, int side) { - if (side < 0) { - return -getEta(eta, -side); - } else { - if (name.indexOf("TILE") >= 0) { - // Outer layer of TILE has eta increments of two. - if (sampling == 2) eta = minEta + (eta-minEta)/2; - } - - return eta0 + (eta - minEta + 0.5) * deltaEta; - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ABarrelSiliconDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/ABarrelSiliconDetector.java deleted file mode 100755 index 14e53e77d059237b6cb5c277a5d2783d89234cd3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ABarrelSiliconDetector.java +++ /dev/null @@ -1,276 +0,0 @@ -package atlantis.geometry; - -import atlantis.canvas.AWindow; -import atlantis.data.AS3DData; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionYX; -import java.awt.Color; -import java.util.ArrayList; -import java.util.List; - -/** - * Class representing a pixel/SCT barrel detector part. - * Also implements methods to draw more detailed structure of the detector. - * - * @author Eric Jansen - */ -public class ABarrelSiliconDetector extends ADetector { - - private static List detectors = null; - - protected int layer; - protected double length; - protected double width; - protected double thickness; - protected int numZ; - protected int numPhi; - protected double tilt; - protected double r0; - protected double phi0; - protected double zMin; - protected double zMax; - - protected double deltaPhi; - protected double deltaZ; - protected double rMin; - protected double rMax; - - public ABarrelSiliconDetector(String name, String color, int layer, double length, double width, double thickness, - int numZ, int numPhi, double tilt, double r0, double phi0, double zMin, double zMax) { - super(name, " ", color); - - if (detectors == null) { - detectors = new ArrayList(); - } - detectors.add(this); - - this.layer = layer; - this.length = length; - this.width = width; - this.thickness = thickness; - this.numZ = numZ; - this.numPhi = numPhi; - this.tilt = Math.toRadians(tilt); - this.r0 = r0; - this.phi0 = Math.toRadians(phi0); - this.zMin = zMin; - this.zMax = zMax; - - this.deltaPhi = 2.*Math.PI / this.numPhi; - this.deltaZ = (this.zMax - this.zMin) / this.numZ; - - // We do not take thickness/2 and width/2 to have some extra margin - this.rMin = this.r0 - Math.abs(this.thickness*Math.cos(this.tilt)) - - Math.abs(this.width*Math.sin(this.tilt)); - this.rMax = this.r0 + Math.abs(this.thickness*Math.cos(this.tilt)) - + Math.abs(this.width*Math.sin(this.tilt)); - } - - /** - * Empties the list of instances of this class. - */ - public static void clear() { - if (detectors != null) { - detectors.clear(); - } - } - - /** - * This function draws the wafer/stave structure of the silicon detectors. It is called - * from ADetectorSystem.draw(). - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - * @param projection AProjection2D current projection - */ - public static void drawAdditionalItems(AWindow window, AGraphics ag, AProjection2D projection) { - AParameter inDetDetail = parameterStore.getUnknown("Det", "SiliconDetail"); - if (inDetDetail != null && detectors != null && inDetDetail.getStatus()) { - for (int i=0; i<detectors.size(); i++) { - ACoord coord = ACoord.NO_DATA; - ABarrelSiliconDetector detector = (ABarrelSiliconDetector) detectors.get(i); - if (projection instanceof AProjectionYX) { - coord = detector.getYXDetail(); - } else if (projection instanceof AProjectionRZ) { - coord = detector.getRZDetail(); - } else if (projection instanceof AProjectionFZ) { - coord = detector.getFZDetail(); - } else if (projection instanceof AProjectionFR) { - coord = detector.getYXDetail().convertYXToFR().includePhiWrapAround("FR"); - } - - if (coord != ACoord.NO_DATA) { - Color[] colorMap = AColorMap.getColors(); - ag.setColor(colorMap[parameterStore.get("Det", "SiliconDetail").getI()]); - - ACoord display = window.calculateDisplay(projection.nonLinearTransform(coord)); - for (int j=0; j<display.hv[0].length; j++) { - ag.drawPolygon(display.hv[0][j], display.hv[1][j], display.hv[0][j].length); - } - } - } - } - } - - /** - * Determines if this element should be visible or not. - * @return visibility - */ - protected boolean isVisible() { - int cut = parameterStore.get("CutsInDet", "SCT").getI(); - - if (cut == AS3DData.CUT_INDET_SCT_ALL || cut == AS3DData.CUT_INDET_SCT_BARREL) { - return true; - } else { - return false; - } - } - - /** - * Returns the detector outline in the y-x projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getYXUser() { - if (!isVisible()) { - return ACoord.NO_DATA; - } - if (parameterStore.get("YX", "Mode").getI() != AProjectionYX.MODE_STANDARD) { - return ACoord.NO_DATA; - } - - if (!globals.getUseOpenGL()) { - int numPoints = 2 * (numPhi + 1); - double[][] hv = new double[2][numPoints]; - - for (int i = 0; i < numPhi + 1; i++) { - hv[0][i] = rMin * Math.cos(phi0 + (i + 0.5) * deltaPhi); - hv[1][i] = rMin * Math.sin(phi0 + (i + 0.5) * deltaPhi); - - hv[0][numPhi + 1 + i] = rMax * Math.cos(phi0 - (i + 0.5) * deltaPhi); - hv[1][numPhi + 1 + i] = rMax * Math.sin(phi0 - (i + 0.5) * deltaPhi); - } - return new ACoord(hv); - } else { - return new ACoord(generateAnnulusTris(numPhi, phi0, rMin, rMax)); - } - } - - /** - * Returns the detector outline in the rho-z projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getRZUser() { - //if (!isVisible()) return ACoord.NO_DATA; - - double[][][] hv = new double[2][2][]; - - hv[0][0] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][0] = new double[] { rMax, rMax, rMin, rMin}; - hv[0][1] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][1] = new double[] {-rMin, -rMin, -rMax, -rMax}; - - return new ACoord(hv); - } - - /** - * Returns the detector outline in the phi-z projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getFZUser() { - if (!isVisible()) return ACoord.NO_DATA; - - double[][] hv = new double[2][]; - - hv[0] = new double[] {zMax, zMin, zMin, zMax}; - hv[1] = new double[] {360., 360., 0., 0.}; - - return new ACoord(hv); - } - - /** - * Returns the detector outline in the phi-rho projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getFRUser() { - if (!isVisible()) return ACoord.NO_DATA; - - double[][] hv = new double[2][]; - - hv[0] = new double[] {rMin, rMax, rMax, rMin}; - hv[1] = new double[] {360., 360., 0., 0.}; - - return new ACoord(hv); - } - - /** - * Returns the wafer/stave structure in the y-x projection. - * @return ACoord polygons representing the wafers/staves - */ - protected ACoord getYXDetail() { - if (parameterStore.get("YX", "Mode").getI() != AProjectionYX.MODE_STANDARD) return ACoord.NO_DATA; - if (!isVisible()) return ACoord.NO_DATA; - - double[][][] hv = new double[2][numPhi][]; - for (int i=0; i<numPhi; i++) { - double phi = phi0 + i*deltaPhi; - - double x1 = r0*Math.cos(phi) + width/2.*Math.sin(phi+tilt) + thickness/2.*Math.cos(phi+tilt); - double x2 = r0*Math.cos(phi) - width/2.*Math.sin(phi+tilt) + thickness/2.*Math.cos(phi+tilt); - double x3 = r0*Math.cos(phi) - width/2.*Math.sin(phi+tilt) - thickness/2.*Math.cos(phi+tilt); - double x4 = r0*Math.cos(phi) + width/2.*Math.sin(phi+tilt) - thickness/2.*Math.cos(phi+tilt); - - double y1 = r0*Math.sin(phi) - width/2.*Math.cos(phi+tilt) + thickness/2.*Math.sin(phi+tilt); - double y2 = r0*Math.sin(phi) + width/2.*Math.cos(phi+tilt) + thickness/2.*Math.sin(phi+tilt); - double y3 = r0*Math.sin(phi) + width/2.*Math.cos(phi+tilt) - thickness/2.*Math.sin(phi+tilt); - double y4 = r0*Math.sin(phi) - width/2.*Math.cos(phi+tilt) - thickness/2.*Math.sin(phi+tilt); - - hv[0][i] = new double[] {x1, x2, x3, x4}; - hv[1][i] = new double[] {y1, y2, y3, y4}; - } - return new ACoord(hv); - } - - /** - * Returns the wafer/stave structure in the rho-z projection. - * @return ACoord polygons representing the wafers/staves - */ - protected ACoord getRZDetail() { - // if (!isVisible()) return ACoord.NO_DATA; - - double[][][] hv = new double[2][2*numZ][]; - - for (int i=0; i<numZ; i++) { - hv[0][i] = new double[] {zMin+(i+1)*deltaZ, zMin+i*deltaZ, zMin+i*deltaZ, zMin+(i+1)*deltaZ}; - hv[1][i] = new double[] {rMax, rMax, rMin, rMin}; - - hv[0][numZ+i] = new double[] {zMin+(i+1)*deltaZ, zMin+i*deltaZ, zMin+i*deltaZ, zMin+(i+1)*deltaZ}; - hv[1][numZ+i] = new double[] {-rMin, -rMin, -rMax, -rMax}; - } - return new ACoord(hv); - } - - /** - * Returns the wafer/stave structure in the phi-z projection. - * @return ACoord polygons representing the wafers/staves - */ - protected ACoord getFZDetail() { - if (!isVisible()) return ACoord.NO_DATA; - - // Phi geometry is a mess, draw only the staves in this projection. - double[][][] hv = new double[2][numZ+1][2]; - for (int i=0; i<=numZ; i++) { - hv[0][i][0] = zMin + i*deltaZ; - hv[1][i][0] = 360.; - hv[0][i][1] = zMin + i*deltaZ; - hv[1][i][1] = 0.; - } - - return new ACoord(hv).includePhiWrapAround("FZ"); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ABarrelTRTDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/ABarrelTRTDetector.java deleted file mode 100755 index 8ccd0a795285c91a4e653b02023f28a55470d2f7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ABarrelTRTDetector.java +++ /dev/null @@ -1,184 +0,0 @@ -package atlantis.geometry; - -import atlantis.canvas.AWindow; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionYX; -import java.awt.Color; -import java.util.ArrayList; -import java.util.List; - -/** - * Class representing a TRT barrel detector part. - * Also implements methods to draw more detailed structure of the detector. - * - * @author Eric Jansen - */ -public class ABarrelTRTDetector extends ADetector { - - private static List detectors = null; - - protected int layer; - protected int numPhi; - protected double rMin; - protected double rMax; - protected double phiIn; - protected double phiOut; - protected double zMin; - protected double zMax; - protected double deltaPhi; - - public ABarrelTRTDetector(String name, String color, int layer, int numPhi, double rMin, double rMax, - double phiIn, double phiOut, double zMin, double zMax) { - super(name, " ", color); - - if (detectors == null) { - detectors = new ArrayList(); - } - detectors.add(this); - - this.layer = layer; - this.numPhi = numPhi; - this.rMin = rMin; - this.rMax = rMax; - this.phiIn = Math.toRadians(phiIn); - this.phiOut = Math.toRadians(phiOut); - this.zMin = zMin; - this.zMax = zMax; - - this.deltaPhi = 2.*Math.PI / numPhi; - } - - /** - * Empties the list of instances of this class. - */ - public static void clear() { - if (detectors != null) { - detectors.clear(); - } - } - - /** - * This function draws the module structure of the TRT detector. It is called - * from ADetectorSystem.draw(). - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - * @param projection AProjection2D current projection - */ - public static void drawAdditionalItems(AWindow window, AGraphics ag, AProjection2D projection) { - AParameter inDetDetail = parameterStore.getUnknown("Det", "TRTDetail"); - if (inDetDetail != null && detectors != null && inDetDetail.getStatus()) { - for (int i=0; i<detectors.size(); i++) { - ACoord coord = ACoord.NO_DATA; - ABarrelTRTDetector detector = (ABarrelTRTDetector) detectors.get(i); - if (projection instanceof AProjectionYX) { - coord = detector.getYXDetail(); - } else if (projection instanceof AProjectionFR) { - coord = detector.getYXDetail().convertYXToFR().includePhiWrapAround("FR"); - } - - if (coord != ACoord.NO_DATA) { - Color[] colorMap = AColorMap.getColors(); - ag.setColor(colorMap[parameterStore.get("Det", "TRTDetail").getI()]); - - ACoord display = window.calculateDisplay(projection.nonLinearTransform(coord)); - for (int j=0; j<display.hv[0].length; j++) { - ag.drawPolygon(display.hv[0][j], display.hv[1][j], display.hv[0][j].length); - } - } - } - } - } - - /** - * Returns the detector outline in the y-x projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getYXUser() { - if (parameterStore.get("YX", "Mode").getI() != AProjectionYX.MODE_STANDARD) return ACoord.NO_DATA; - - if (!globals.getUseOpenGL()) { - int numPoints = 2 * (numPhi + 1); - double[][] hv = new double[2][numPoints]; - - for (int i = 0; i < numPhi + 1; i++) { - hv[0][i] = rMin * Math.cos(phiIn + i * deltaPhi); - hv[1][i] = rMin * Math.sin(phiIn + i * deltaPhi); - - hv[0][numPhi + 1 + i] = rMax * Math.cos(phiOut - i * deltaPhi); - hv[1][numPhi + 1 + i] = rMax * Math.sin(phiOut - i * deltaPhi); - } - return new ACoord(hv); - } else { - return new ACoord(generateAnnulusTris(numPhi, phiIn, rMin, rMax)); - } - } - - /** - * Returns the detector outline in the rho-z projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getRZUser() { - double[][][] hv = new double[2][2][]; - - hv[0][0] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][0] = new double[] { rMax, rMax, rMin, rMin}; - hv[0][1] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][1] = new double[] {-rMin, -rMin, -rMax, -rMax}; - - return new ACoord(hv); - } - - /** - * Returns the detector outline in the phi-z projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getFZUser() { - return ACoord.NO_DATA; - } - - /** - * Returns the detector outline in the phi-rho projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getFRUser() { - double[][] hv = new double[2][]; - - hv[0] = new double[] {rMin, rMax, rMax, rMin}; - hv[1] = new double[] {360., 360., 0., 0.}; - - return new ACoord(hv); - } - - /** - * Returns the module structure in the y-x projection. - * @return ACoord polygons representing the modules - */ - protected ACoord getYXDetail() { - if (parameterStore.get("YX", "Mode").getI() != AProjectionYX.MODE_STANDARD) return ACoord.NO_DATA; - - double[][][] hv = new double[2][numPhi][]; - for (int i=0; i<numPhi; i++) { - double phiMin = i*deltaPhi; - double phiMax = (i+1)*deltaPhi; - - double x1 = rMax*Math.cos(phiMin+phiOut); - double x2 = rMax*Math.cos(phiMax+phiOut); - double x3 = rMin*Math.cos(phiMax+phiIn); - double x4 = rMin*Math.cos(phiMin+phiIn); - - double y1 = rMax*Math.sin(phiMin+phiOut); - double y2 = rMax*Math.sin(phiMax+phiOut); - double y3 = rMin*Math.sin(phiMax+phiIn); - double y4 = rMin*Math.sin(phiMin+phiIn); - - hv[0][i] = new double[] {x1, x2, x3, x4}; - hv[1][i] = new double[] {y1, y2, y3, y4}; - } - return new ACoord(hv); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ABoxDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/ABoxDetector.java deleted file mode 100755 index 68fda4c768eb77b2d176fbbd15a43521a9e04d1d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ABoxDetector.java +++ /dev/null @@ -1,172 +0,0 @@ -package atlantis.geometry; - -import atlantis.utils.AMath; -import atlantis.parameters.*; -import atlantis.graphics.ACoord; - -/** - * in ATLAS boxes are RPC and MDT in the barrel - */ - -public class ABoxDetector extends ADetector { - - double zMin; - double zMax; - double rMin; - double rMax; - double phi; - double excl; - double size; - String stationName; - int stationEta; - int stationPhi; - int sector; - - public ABoxDetector(String name, double zMin, double zMax, double rMin, - double rMax, double phi, double excl, double size, int stationEta, int stationPhi) { - super(name, " ", name.substring(0, 3)); - this.zMin=zMin; - this.zMax=zMax; - this.rMin=rMin; - this.rMax=rMax; - this.phi=phi; - this.excl=excl; - this.size=size; - this.stationName=name.substring(4, 7); - this.stationEta=stationEta; - this.stationPhi=stationPhi; - this.sector=((int)((phi+Math.PI/16)/(Math.PI/8)))%16; - } - - protected ACoord getFZUser() { - double cosPhi=Math.cos(phi); - double sinPhi=Math.sin(phi); - double d=size/2.; - double r=rMin; - double x=r*cosPhi-excl*sinPhi; - double y=r*sinPhi+excl*cosPhi; - double dsinPhi=d*sinPhi; - double dcosPhi=d*cosPhi; - double phi1=Math.toDegrees(Math.atan2(y-dcosPhi, x+dsinPhi)); - double phi2=Math.toDegrees(Math.atan2(y+dcosPhi, x-dsinPhi)); - - if(phi1<0.) phi1+=360.; - if(phi2<0.) phi2+=360.; - if(phi1-phi2>180.) phi1-=360.; - if(phi2-phi1>180.) phi2-=360.; - - return new ACoord(AMath.xBox((zMin+zMax)/2.,(zMax-zMin)/2.), - AMath.yBox((phi1+phi2)/2.,(phi1-phi2)/2.)); - } - - protected ACoord getRZUser() { - double phiMid=Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff=Math.abs(phi-phiMid); - double sign=-1.; - if(phiDiff<Math.PI/2.||phiDiff>3*Math.PI/2.) - sign=+1.; - return getXZRZUser(sign); - } - - protected ACoord getXZUser() { - AParameter p=parameterStore.get("XZ", "Phi"); - - // display muon data when phi is in the middle of a sector - if(p.getD() % 22.5 < 1e-2) { - int sect=(int)Math.round((p.getD() % 360.) / 22.5); - if(sector==sect) { - return getXZRZUser(1.); - } else if(sector==sect-8||sector==sect+8) { - return getXZRZUser(-1.); - } - } - return ACoord.NO_DATA; - } - - protected ACoord getXZRZUser(double sign) { - return new ACoord( - AMath.xBox( (zMin + zMax) / 2., (zMax - zMin) / 2.), - AMath.yBox( sign*(rMin + rMax) / 2., sign*(rMax - rMin) / 2.)); - } - - - protected ACoord getYXUser() { - return getYXUser(0); - } - - protected ACoord getFRUser() { - return convertYXToFR(getYXUser(1)); - } - - private ACoord getYXUser(int flag) { - int[] split= {12, 1, 12, 1}; - int numPoints=4; - boolean splitIt=parameterStore.get("YX", "FishEye").getStatus()||parameterStore.get("YX", "Clock").getStatus() - ||flag==1; - - if(splitIt) - numPoints=26; - double[] temp=new double[4]; - double[][] hv=new double[2][numPoints]; - double cosPhi=Math.cos(phi); - double sinPhi=Math.sin(phi); - double d=size/2.; - double r=rMin; - double x=r*cosPhi-excl*sinPhi; - double y=r*sinPhi+excl*cosPhi; - double dx=d*sinPhi; - double dy=d*cosPhi; - - hv[0][0]=x+dx; - hv[1][0]=y-dy; - hv[0][1]=x-dx; - hv[1][1]=y+dy; - r=rMax; - x=r*cosPhi-excl*sinPhi; - y=r*sinPhi+excl*cosPhi; - - hv[0][3]=x+dx; - hv[1][3]=y-dy; - hv[0][2]=x-dx; - hv[1][2]=y+dy; - if(splitIt) - for(int j=0; j<2; ++j) { - for(int k=0; k<4; ++k) - temp[k]=hv[j][k]; - AMath.splitArrayIntoPieces(temp, hv[j], split); - } - return new ACoord(hv); - } - - protected boolean equalsYX(ADetector o) { - if (o instanceof ABoxDetector) { - ABoxDetector that = (ABoxDetector) o; - return this.rMin == that.rMin && - this.rMax == that.rMax && - this.phi == that.phi && - this.size == that.size && - this.excl == that.excl; - } else - return false; - } - - protected boolean equalsRZ(ADetector o) { - if (o instanceof ABoxDetector) { - ABoxDetector that = (ABoxDetector) o; - return this.rMin == that.rMin && - this.rMax == that.rMax && - this.zMin == that.zMin && - this.zMax == that.zMax; - } else - return false; - } - - public double getZMin() { return zMin; } - public double getZMax() { return zMax; } - public double getRMin() { return rMin; } - public double getRMax() { return rMax; } - public double getPhi() { return phi; } - public double getSize() { return size; } - -} - diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ABoxDetectors.java b/graphics/AtlantisJava/src/atlantis/geometry/ABoxDetectors.java deleted file mode 100755 index a4b10b150709f791392c024e0f668109dc660c1f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ABoxDetectors.java +++ /dev/null @@ -1,168 +0,0 @@ -package atlantis.geometry; - -import atlantis.parameters.AParameter; -import atlantis.parameters.APar; -import atlantis.utils.AMath; -import java.util.*; - - -/** - * ABoxDetector's contains all instances of ABoxDetector. - * In different projections not all Boxes need to be drawn - * as they may exactly overlap. Filling of these areas is - * slow, so only the Boxes needed are drawn in each projection. - * (That is why boxes are group into ABoxDetectors) - * This is achieved by making a drawlist before drawing. - */ -public final class ABoxDetectors extends ADetectors { - - private int numRZTypes; - private int[] typeRZ; - private int numYXTypes; - private int[] typeYX; - - private ABoxDetector[] box; - - public ABoxDetectors(List detectors) { - super(filterBoxDetectors(detectors)); - box= new ABoxDetector[det.length]; - for(int i=0;i<box.length;++i) - box[i]=(ABoxDetector)det[i]; - - typeYX=new int[numData]; - for(int i=0; i<numData; ++i) - typeYX[i]=-1; - - numYXTypes=0; - for(int i=0; i<numData; ++i) - if(typeYX[i]==-1) { - typeYX[i]=numYXTypes; - for(int j=i+1; j<numData; ++j) - if(typeYX[j]==-1&&det[i].equalsYX(det[j])) - typeYX[j]=numYXTypes; - numYXTypes++; - } - - typeRZ=new int[numData]; - for(int i=0; i<numData; ++i) - typeRZ[i]=-1; - - numRZTypes=0; - for(int i=0; i<numData; ++i) - if(typeRZ[i]==-1) { - typeRZ[i]=numRZTypes; - for(int j=i+1; j<numData; ++j) - if(typeRZ[j]==-1&&det[i].equalsRZ(det[j])) - typeRZ[j]=numRZTypes; - numRZTypes++; - } - } - - private static ADetector[] filterBoxDetectors(List detectors) { - - List tempDetectors=new ArrayList(detectors.size()); - Iterator it=detectors.iterator(); - - while(it.hasNext()) { - Object o=it.next(); - if(o instanceof ABoxDetector || o instanceof ATBxDetector) tempDetectors.add(o); - } - return (ADetector[])tempDetectors.toArray(new ADetector[tempDetectors.size()]); - } - - private void makeDrawListYX() { - int mode=parameterStore.get("YX", "Mode").getI(); - - if(mode==0) { - numDraw=numYXTypes; - for(int i=0; i<numData; ++i) - listdl[typeYX[i]]=i; - } else - numDraw=0; - } - - private void makeDrawListXZ() { - AParameter p=parameterStore.get("XZ", "Phi"); - - // display muon data when phi is in the middle of a sector - if(p.getD() % 22.5 < 1e-2) { - int sect=(int)Math.round((p.getD() % 360.) / 22.5); - int num=0; - for(int i=0; i<numData; i++) { - int s=box[i].sector; - if(s==sect||s==sect-8||s==sect+8) { - listdl[num++]=i; - } - } - numDraw=num; - } else { - numDraw=0; - } - } - - private void makeDrawListRZ() { - // first make the draw list - // for each type find out if it has both +ve and negative sign - int[] pos=new int[typeRZ.length]; - int[] neg=new int[typeRZ.length]; - double phiMid=Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - - for(int i=0; i<numRZTypes; ++i) - neg[i]=pos[i]=-1; - - for(int i=0; i<numData; ++i) { - double phiDiff=Math.abs(box[i].phi-phiMid); - - if(phiDiff<Math.PI/2.||phiDiff>3*Math.PI/2.) - pos[typeRZ[i]]=i; - else - neg[typeRZ[i]]=i; - } - - int num=0; - for(int i=0; i<numRZTypes; ++i) { - if(pos[i]!=-1) - listdl[num++]=pos[i]; - if(neg[i]!=-1) - listdl[num++]=neg[i]; - } - numDraw=num; - } - - private void makeDrawListFZ() { - int mode=parameterStore.get("FZ", "Mode").getI(); - - if(mode==0) - numDraw=0; - else { - int num=0; - - for(int i=0; i<numData; ++i) { - char type=det[i].getName().charAt(0); - char station=det[i].getName().charAt(5); - char io=det[i].getName().charAt(det[i].getName().length()-1); - - if((mode==1&&station=='M'&&io=='I'&&type=='R')||(mode==2&&station=='M'&&io=='O'&&type=='R') - ||(mode==3&&station=='O'&&type=='R')||(mode==4&&(station=='I'||station=='E')&&type=='M') - ||(mode==5&&station=='M'&&type=='M')||(mode==6&&station=='O'&&type=='M')) - listdl[num++]=i; - numDraw=num; - } - } - } - - protected void makeDrawList(String projection) { - if (projection.equals("YX") || projection.equals("FR") ) - makeDrawListYX(); - else if (projection.equals("FZ")) - makeDrawListFZ(); - else if (projection.equals("RZ")) - makeDrawListRZ(); - else if (projection.equals("XZ")) - makeDrawListXZ(); - else - numDraw=0; - } - -} - diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ACalorimeterDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/ACalorimeterDetector.java deleted file mode 100755 index da80146936d7ec90dfccee3994b0d0733d299dd4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ACalorimeterDetector.java +++ /dev/null @@ -1,699 +0,0 @@ -package atlantis.geometry; - -import atlantis.canvas.AWindow; -import atlantis.graphics.ACoord; -import atlantis.graphics.AClipper; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AIdHelper; -import atlantis.utils.AMath; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionYX; -import java.awt.Color; -import java.util.List; -import java.util.ArrayList; - -/** - * Abstract class representing a region of a certain sampling of a ATLAS - * calorimeter. Based on the parameters given to the constructor, the - * derived classes should be able to calculate the geometrical properties - * of the cells they contain. This behavior is required for drawing the data. - * - * @author Eric Jansen - */ -abstract public class ACalorimeterDetector extends ADetector { - - // Keep a static list of instances for easy access - protected static List detectors = null; - - // These arrays are used for fast cell to detector mapping. - protected static int[][][] lar = null; - protected static int[][] hec = null; - protected static int[] tile = null; - protected static int[] tile_ext = null; - protected static int[][] tile_gap = null; - protected static int[] mbts = null; - - protected int sampling; - protected int region; - protected double rMin; - protected double rMax; - protected double zMin; - protected double zMax; - protected double phi0; - protected int numPhi; - protected double deltaPhi; - protected double eta0; - protected double deltaEta; - protected int numEta; - protected int minEta; - - protected double detEtaMin; - protected double detEtaMax; - protected AClipper clipper; - - /** - * Constructs a new calorimeter object. - * @param name String name of the object - * @param color String name of the color used to draw this object - */ - public ACalorimeterDetector(String name, String color) { - super(name, " ", color); - - if (detectors == null) { - detectors = new ArrayList(40); - - // These numbers correspond to the maximum number of values that can - // be encoded in the identifier. - lar = new int[4][4][8]; - hec = new int[4][2]; - tile = new int[16]; - tile_ext = new int[16]; - tile_gap = new int[16][64]; - mbts = new int[2]; - - // Initialize them to -1, which means no detector element known. - for (int i=0; i<lar.length; i++) - for (int j=0; j<lar[i].length; j++) - for (int k=0; k<lar[i][j].length; k++) - lar[i][j][k] = -1; - - for (int i=0; i<hec.length; i++) - for (int j=0; j<hec[i].length; j++) - hec[i][j] = -1; - - for (int i=0; i<tile.length; i++) - tile[i] = -1; - - for (int i=0; i<tile_ext.length; i++) - tile_ext[i] = -1; - - for (int i=0; i<tile_gap.length; i++) - for (int j=0; j<tile_gap[i].length; j++) - tile_gap[i][j] = -1; - - for (int i=0; i<mbts.length; i++) - mbts[i] = -1; - } - - detectors.add(this); - } - - /** - * Returns one of the instances of this class. - * @param index int index of instance - * @return ACalorimeterDetector instance at the requested index - */ - public static ACalorimeterDetector get(int index) { - return (ACalorimeterDetector) detectors.get(index); - } - - /** - * Shows the number of instances of this class that have been created. - * @return int number of instances - */ - public static int count() { - if (detectors != null) { - return detectors.size(); - } else { - return 0; - } - } - - /** - * This functions maps the calorimeter cells to a geometry object. In principle we could - * compare every cell to every geometry object, but that would be too slow. Therefore we - * organize the geometry in an array structure. - * @param id int identifier of a cell - * @return int index of the geometry object in the detector array - */ - public static int getDetectorIndex(int id) { - if (detectors == null) return -1; - - try { - switch (AIdHelper.subDetector(id)) { - case 4: - switch (AIdHelper.larPart(id)) { - case 1: - // LAr EM - return lar[Math.abs(AIdHelper.larBarrelEndcap(id))] - [AIdHelper.larSampling(id)][AIdHelper.larRegion(id)]; - case 2: - // HEC - return hec[AIdHelper.larSampling(id)][AIdHelper.larRegion(id)]; - case 3: - // FCAL - return -1; - default: - return -1; - } - case 5: - switch (AIdHelper.tileSection(id)) { - case 1: - // TILE barrel - return tile[AIdHelper.tileSampling(id)]; - case 2: - // TILE extended barrel - return tile_ext[AIdHelper.tileSampling(id)]; - case 3: - // ITC gap/crack - return tile_gap[AIdHelper.tileSampling(id)][AIdHelper.tileTower(id)]; - case 4: - // MBTS - return -1; - default: - return -1; - } - default: - return -1; - } - } catch (AAtlantisException e) { - return -1; - } - } - - /** - * Clear the list of instances. This is called before reading another geometry file. - */ - public static void clear() { - if (detectors != null) { - detectors.clear(); - } - detectors = null; - lar = null; - hec = null; - tile = null; - tile_ext = null; - tile_gap = null; - mbts = null; - } - - /** - * Get the outline of a certain cell in a certain projection. - * @param projection AProjection projection - * @param eta int eta index of the cell - * @param phi int phi index of the cell - * @param side int side sign of the z coordinate of the cell - * @return ACoord cell outline - */ - public ACoord getCell(AProjection projection, int eta, int phi, int side) { - if (projection instanceof AProjectionYX) { - return getYXCell(eta, phi); - } else if (projection instanceof AProjectionRZ) { - return getRZCell(eta, phi, side); - } else if (projection instanceof AProjectionFR) { - return getFRCell(eta, phi); - } else if (projection instanceof AProjectionFZ) { - return getFZCell(eta, phi, side); - } else if (projection instanceof AProjectionVP) { - return getVPCell(eta, phi, side); - } else { - return ACoord.NO_DATA; - } - } - - /** - * Returns the y-x geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getYXCell(int eta, int phi) { - return ACoord.NO_DATA; - } - - /** - * Returns the rho-z geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @param side int sign of the z coordinate of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getRZCell(int eta, int phi, int side) { - return ACoord.NO_DATA; - } - - /** - * Returns the phi-rho geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getFRCell(int eta, int phi) { - return convertYXToFR(getYXCell(eta, phi)); - } - - /** - * Returns the phi-z geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @param side int sign of the z coordinate of cell - * @return ACoord - */ - public ACoord getFZCell(int eta, int phi, int side) { - return ACoord.NO_DATA; - } - - /** - * Returns the eta-phi geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @param side int sign of the z coordinate of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getVPCell(int eta, int phi, int side) { - return ACoord.NO_DATA; - } - - /** - * Returns the eta value of the center (in eta) of a cell. - * @param eta int eta index of the cell - * @param side int sign of the z coordinate of the cell - * @return double eta value - */ - public double getEta(int eta, int side) { - if (side < 0) { - return -getEta(eta, -side); - } else { - return eta0 + (eta - minEta + 0.5) * deltaEta; - } - } - - /** - * Returns the lowest eta value of a cell. - * @param eta int eta index of the cell - * @param side int sign of the z coordinate of the cell - * @return double lowest eta value - */ - public double getEtaMin(int eta, int side) { - if (side < 0) { - return -getEtaMax(eta, -side); - } else { - return eta0 + (eta - minEta) * deltaEta; - } - } - - /** - * Returns the highest eta value of a cell. - * @param eta int eta index of the cell - * @param side int sign of the z coordinate of the cell - * @return double highest eta value - */ - public double getEtaMax(int eta, int side) { - if (side < 0) { - return -getEtaMin(eta, -side); - } else { - return eta0 + (eta - minEta + 1) * deltaEta; - } - } - - /** - * Returns the phi value of the center of a cell. - * @param phi int phi index of the cell - * @return double phi value - */ - public double getPhi(int phi) { - return phi0 + (phi + 0.5) * deltaPhi; - } - - /** - * Returns the lowest phi value of a cell. - * @param phi int phi index of the cell - * @return double lowest phi value - */ - public double getPhiMin(int phi) { - return phi0 + phi * deltaPhi; - } - - /** - * Returns the highest phi value of a cell. - * @param phi int phi index of the cell - * @return double highest phi value - */ - public double getPhiMax(int phi) { - return phi0 + (phi + 1) * deltaPhi; - } - - /** - * Determines on which side a certain cell should be drawn in the RZ projection, - * based on the phi angle the user has set in the menu. - * @param phi int phi index of the cell - * @return int 1 or -1, meaning top or bottom repectively - */ - public int getRSign(int phi) { - double cellPhi = phi0 + phi*deltaPhi + deltaPhi/2.; - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(cellPhi-phiMid); - if (phiDiff <= Math.PI/2.|| phiDiff > 3*Math.PI/2.) { - return 1; - } else { - return -1; - } - } - - /** - * Returns the number of cells in phi for this calorimeter part. - * @return int number of cells in phi - */ - public int getNumPhi() { - return numPhi; - } - - /** - * Returns the size of a cell in phi for this calorimeter part (this is the same for all cells). - * @return double size of a cell in radians - */ - public double getDeltaPhi() { - return deltaPhi; - } - - /** - * Returns the number of cells in eta for this calorimeter part. - * @return double number of cells in eta - */ - public int getNumEta() { - return numEta; - } - - /** - * Returns the size of a cell in eta for this calorimeter part (this is the same for all cells). - * @return double size of a cell in eta - */ - public double getDeltaEta() { - return deltaEta; - } - - /** - * Returns the center radius of the calorimeter part. - * @return double center radius - */ - public double getR() { - return (rMin+rMax)/2.; - } - - /** - * Returns the inner radius of the calorimter part. - * @return double inner radius - */ - public double getRMin() { - return rMin; - } - - /** - * Returns the outer radius of the calorimeter part. - * @return double outer radius - */ - public double getRMax() { - return rMax; - } - - /** - * Returns the center z of the calorimeter part. - * @return double center z - */ - public double getZ() { - return (zMin+zMax)/2.f; - } - - /** - * Returns the inner z of the calorimeter part. - * @return double inner z - */ - public double getZMin() { - return zMin; - } - - /** - * Returns the outer z of the calorimter part. - * @return double outer z - */ - public double getZMax() { - return zMax; - } - - /** - * Returns the inner eta of the calorimeter part. - * @return double inner eta - */ - public double getEtaMin() { - return eta0; - } - - /** - * Returns the outer eta of the calorimeter part. - * @return double outer eta - */ - public double getEtaMax() { - return eta0 + numEta*deltaEta; - } - - /** - * Returns the sampling of the calorimeter part. This corresponds to the layers of the calorimeter. - * @return int sampling - */ - public int getSampling() { - return sampling; - } - - /** - * Returns the region of this calorimeter part. Within a layer a new region is started when the - * size of the cells changes. - * @return int region - */ - public int getRegion() { - return region; - } - - /** - * Returns the eta index of the first cell in eta for this calorimeter part. - * @return int eta - */ - public int getFirstEta() { - return minEta; - } - - /** - * Returns the eta index of the last cell in eta for this calorimeter part. - * @return int eta - */ - public int getLastEta() { - if (sampling == 2 && name.indexOf("TILE") >= 0) - return minEta + 2*numEta; - else - return minEta + numEta-1; - } - - /** - * Returns the phi index of the first cell in phi for this calorimeter part. - * @return int phi - */ - public int getFirstPhi() { - // This is always 0, still we provide this method for consistency. - return 0; - } - - /** - * Returns the phi index of the last cell in phi for this calorimeter part. - * @return int phi - */ - public int getLastPhi() { - return numPhi-1; - } - - /** - * This function draws the module structure of the calorimeter. It is called - * from ADetectorSystem.draw(). - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - * @param projection AProjection2D current projection - */ - public static void drawAdditionalItems(AWindow window, AGraphics ag, AProjection2D projection) { - AParameter caloDetail = parameterStore.getUnknown("Det", "CaloDetail"); - if (caloDetail != null && detectors != null && caloDetail.getStatus()) - { - for (int i=0; i<detectors.size(); i++) - { - ACalorimeterDetector detector = (ACalorimeterDetector) detectors.get(i); - - // Only draw region 0 in YX, not the few different cells at the ends - if ((projection instanceof AProjectionYX && detector.getRegion() == 0) || projection instanceof AProjectionFR) - { - int start; - int mode = parameterStore.get("YX", "Mode").getI(); - if(mode==AProjectionYX.MODE_STANDARD) - //only needs one eta for standard view - start = detector.getFirstEta(); - else if(mode>=AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER && mode <=AProjectionYX.MODE_HEC_4) - //need to loop over eta for endcaps - start = detector.getLastEta(); - else - start=0; - if(mode==AProjectionYX.MODE_STANDARD || (mode>=AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER && mode <=AProjectionYX.MODE_HEC_4) || mode==AProjectionYX.MODE_MBTS) - { - for (int eta=start; eta>=detector.getFirstEta(); eta--) - { - for (int phi=detector.getFirstPhi(); phi<=detector.getLastPhi(); phi++) - { - ACoord coord = detector.getCell(projection, eta, phi, 1); - if (coord != ACoord.NO_DATA) { - ACoord display; - if (projection instanceof AProjectionYX) - display = window.calculateDisplay(projection.nonLinearTransform(coord)); - else - display = window.calculateDisplay(projection.nonLinearTransform( - coord.includePhiWrapAround("FR")) - ); - - Color[] colorMap = AColorMap.getColors(); - ag.setColor(colorMap[parameterStore.get("Det", "CaloDetail").getI()]); - - for (int j=0; j<display.hv[0].length; j++) - ag.drawPolygon(display.hv[0][j], display.hv[1][j], display.hv[0][j].length); - } - } - } - } - else if((mode==AProjectionYX.MODE_LAR_ENDCAP_SUMMED && (detector.getName().equals("LAr Endcap Presampler")||detector.getName().equals("LAr_EC_Presampler"))) - || (mode==AProjectionYX.MODE_HEC_SUMMED && detector.getName().equals("HEC") && detector.getSampling()==0)) - { - //For summed endcaps only need to do this once - //The cells match the bining used but are not specific to the detector - //hence they do not all lie inside the detector - double etaBin=0.1,phiBin=(2*Math.PI/64); - int binvalue; - if(mode==AProjectionYX.MODE_HEC_SUMMED) - { - binvalue = parameterStore.get("YX", "HECBin").getI(); - } - else - { - binvalue = parameterStore.get("YX", "LArBin").getI(); - } - if(binvalue==3) - { - etaBin=0.1; - phiBin=(2*Math.PI/64); - } - else - { - etaBin*=binvalue; - phiBin*=binvalue; - } - Color[] colorMap = AColorMap.getColors(); - ag.setColor(colorMap[parameterStore.get("Det", "CaloDetail").getI()]); - double firstZMin=detector.getZMin(); - //check etaSplit is set correct - if(binvalue==3) - { - setEtaSplit(); - } - //loop between values greater and less than the actual size - for(double Eta=1.2; Eta<3.3; Eta+=etaBin) - { - if(binvalue==3 && Eta>=parameterStore.get("YX", "SplitEta").getD()) - { - etaBin=0.2; - phiBin=(2*Math.PI/32); - } - double RMax=firstZMin/Math.sinh(Eta); - double RMin=firstZMin/Math.sinh(Eta+etaBin); - for(double Phi=0.0; Phi<(2*Math.PI); Phi+=phiBin) - { - double[][] hv = new double[2][]; - hv[0] = new double[] {RMax*Math.cos(Phi), RMax*Math.cos(Phi+phiBin), - RMin*Math.cos(Phi+phiBin), RMin*Math.cos(Phi)}; - hv[1] = new double[] {RMax*Math.sin(Phi), RMax*Math.sin(Phi+phiBin), - RMin*Math.sin(Phi+phiBin), RMin*Math.sin(Phi)}; - - ACoord coord = new ACoord(hv); - ACoord display; - - if (projection instanceof AProjectionYX) - display = window.calculateDisplay(projection.nonLinearTransform(coord)); - else - display = window.calculateDisplay(projection.nonLinearTransform( - coord.convertYXToFR().includePhiWrapAround("FR")) - ); - for(int j=0; j<display.hv[0].length; j++) - ag.drawPolygon(display.hv[0][j], display.hv[1][j], display.hv[0][j].length); - } - } - } - - } - else if (projection instanceof AProjectionRZ) - { - for (int eta=detector.getFirstEta(); eta<=detector.getLastEta(); eta++) - { - - for (int phi=detector.getFirstPhi(); - phi<=detector.getFirstPhi()+detector.getNumPhi()/2; - phi+=detector.getNumPhi()/2) - { - - for (int side=-1; side<=1; side+=2) { - ACoord coord = detector.getCell(projection, eta, phi, side); - - if (coord != ACoord.NO_DATA) - { - ACoord display = window.calculateDisplay(projection.nonLinearTransform(coord)); - Color[] colorMap = AColorMap.getColors(); - ag.setColor(colorMap[parameterStore.get("Det", "CaloDetail").getI()]); - ag.drawPolygon(display.hv[0][0], display.hv[1][0], display.hv[0][0].length); - } - } - } - } - } - else if (projection instanceof AProjectionFZ) - { - int eta = detector.getFirstEta(); - - for (int phi=detector.getFirstPhi(); phi<=detector.getLastPhi(); phi++) - { - for (int side=-1; side<=1; side+=2) - { - ACoord coord = detector.getCell(projection, eta, phi, side).includePhiWrapAround("FZ"); - - if (coord != ACoord.NO_DATA) - { - ACoord display = window.calculateDisplay(projection.nonLinearTransform(coord)); - Color[] colorMap = AColorMap.getColors(); - ag.setColor(colorMap[parameterStore.get("Det", "CaloDetail").getI()]); - - for (int j=0; j<display.hv[0].length; j++) - { - ag.drawPolygon(display.hv[0][j], display.hv[1][j], display.hv[0][j].length); - } - } - } - } - } - } - } - } - - /** - * This function sets the value of EtaSplit to a minimum of 1.2 and - * to an accuracy of 1 decimal place - * 1.2 is minimum as is minimum of where cells outline is drawn - */ - public static void setEtaSplit() { - if(parameterStore.get("YX", "SplitEta").getD()<1.2) - parameterStore.get("YX", "SplitEta").setD(1.2); - else - { - int temp=(int) Math.floor(parameterStore.get("YX", "SplitEta").getD()*10.0); - parameterStore.get("YX", "SplitEta").setD(temp/10.0); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ADetector.java b/graphics/AtlantisJava/src/atlantis/geometry/ADetector.java deleted file mode 100755 index b7196bfe34a709856fc65bc4567e3e3f500f3e85..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ADetector.java +++ /dev/null @@ -1,157 +0,0 @@ -package atlantis.geometry; - -import atlantis.parameters.AParameter; -import atlantis.parameters.APar; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; - -/** - * Base class of all individual detectors - */ - -public abstract class ADetector { - - String name; - String projection; - String color; - AParameter fillColorParameter; - - protected static APar parameterStore = APar.instance(); - protected static AGlobals globals = AGlobals.instance(); - - final static protected double[][] NO_DETECTORS=new double[2][0]; - - ADetector(String name, String projection, String color) { - this.name=name; - this.projection=projection; - this.color=color; - fillColorParameter=APar.instance().get("Det", color+"Fill"); - } - - protected ACoord getYXUser() { - return ACoord.NO_DATA; - } - - protected ACoord getRZUser() { - return ACoord.NO_DATA; - } - - protected ACoord getYZUser() { - return ACoord.NO_DATA; - } - - protected ACoord getXZUser() { - return ACoord.NO_DATA; - } - - protected ACoord getFRUser() { - return ACoord.NO_DATA; - } - - protected ACoord getFZUser() { - return ACoord.NO_DATA; - } - - protected ACoord getVPUser() { - return ACoord.NO_DATA; - } - - protected ACoord getUser(String projection) { - if (projection.equals("YX")) - return getYXUser(); - else if (projection.equals("RZ")) - return getRZUser(); - else if (projection.equals("XZ")) - return getXZUser(); - else if (projection.equals("YZ")) - return getYZUser(); - else if (projection.equals("FZ")) - return getFZUser(); - else if (projection.equals("FR")) - return getFRUser(); - else if (projection.equals("VP")) - return getVPUser(); - else - return ACoord.NO_DATA; - } - - public String getName() { - return name; - } - - public int getFillColor() { - return fillColorParameter.getI(); - } - - protected boolean getDraw() { - return fillColorParameter.getStatus(); - } - - protected boolean equalsYX(ADetector that) { - return false; - } - - protected boolean equalsRZ(ADetector that) { - return false; - } - - protected ACoord convertYXToFR(ACoord coord) { - double phiLast=0.; - - for (int i=0; i<coord.hv[0].length; i++) { - for (int j=0; j<coord.hv[0][i].length; j++) { - double xx=coord.hv[0][i][j]; - double yy=coord.hv[1][i][j]; - double rho=Math.sqrt(xx*xx+yy*yy); - double phi=Math.toDegrees(Math.atan2(yy, xx)); - - if(phi<0.) - phi+=360.; - if(j>0) { - if(phi-phiLast>180.) phi-=360.; - if(phi-phiLast<-180.) phi+=360.; - } - coord.hv[0][i][j]=rho; - coord.hv[1][i][j]=phi; - phiLast=phi; - } - } - - return coord; - } - - protected double[][][] generateAnnulusTris(int numPhi, double phi0, - double rMin, double rMax) { - - //rMin *= 1.02; - - int numTris = 2 * (numPhi); - double[][][] hv = new double[2][numTris][3]; - - double deltaPhi = 2. * Math.PI / numPhi; - - for (int i = 0; i < numPhi; i++) { - hv[0][i][0] = rMax * Math.cos(phi0 + i * deltaPhi); - hv[1][i][0] = rMax * Math.sin(phi0 + i * deltaPhi); - - hv[0][i][1] = rMax * Math.cos(phi0 + (i + 1) * deltaPhi); - hv[1][i][1] = rMax * Math.sin(phi0 + (i + 1) * deltaPhi); - - float midi = ((float) i) + 0.5f; - hv[0][i][2] = rMin * Math.cos(phi0 + midi * deltaPhi); - hv[1][i][2] = rMin * Math.sin(phi0 + midi * deltaPhi); - - int offi = i + (numPhi); - hv[0][offi][0] = rMin * Math.cos(phi0 + midi * deltaPhi); - hv[1][offi][0] = rMin * Math.sin(phi0 + midi * deltaPhi); - - hv[0][offi][1] = rMax * Math.cos(phi0 + (i + 1) * deltaPhi); - hv[1][offi][1] = rMax * Math.sin(phi0 + (i + 1) * deltaPhi); - - hv[0][offi][2] = rMin * Math.cos(phi0 + (midi + 1) * deltaPhi); - hv[1][offi][2] = rMin * Math.sin(phi0 + (midi + 1) * deltaPhi); - } - - return hv; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ADetectorSystem.java b/graphics/AtlantisJava/src/atlantis/geometry/ADetectorSystem.java deleted file mode 100755 index e0c93a93856d7b4062e47e6d5a834f46482a6fe8..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ADetectorSystem.java +++ /dev/null @@ -1,122 +0,0 @@ -package atlantis.geometry; - - -import java.awt.*; - -import atlantis.canvas.*; -import atlantis.graphics.*; -import atlantis.graphics.colormap.AColorMap; -import atlantis.gui.*; -import atlantis.parameters.*; -import atlantis.projection.*; - - -public class ADetectorSystem -{ - - private ADetectors[] detectors; - protected static String geometryName = null; - - protected static APar parameterStore = APar.instance(); - - ADetectorSystem(ADetectors[] detectors) - { - this.detectors=detectors; - } - - public ADetectors[] getDetectors() - { - return detectors; - } - - // The whole of atlas is drawn in one loop to avoid problem with frames - // overlapping - - - public void draw(AWindow window, AGraphics ag, AProjection2D projection) - { - if(!parameterStore.get("Det", "Detectors").getStatus()) return; - boolean drawFrames=parameterStore.get("Det", "HideDetectors").getStatus(); - //also draw frames for Grey/BW color maps - boolean colorBW=AColorMap.drawFrames(); - Color[] colorMap=AColorMap.getColors(); - ADetectors[] detectors=getDetectors(); - ACoord[] display=new ACoord[detectors.length]; - int[][] index=new int[detectors.length][]; - int[][] detColor=new int[detectors.length][]; - boolean[][] draw=new boolean[detectors.length][]; - int bkgColor = parameterStore.get("Color","BkgFill").getI(); - - for(int det=0; det<detectors.length; ++det) { - display[det]=window.calculateDisplay(detectors[det].getUser(projection)); - index[det]=display[det].index; - detColor[det]=detectors[det].getColor(index[det]); - draw[det]=detectors[det].getDraw(index[det]); - } - - boolean modeSelection = parameterStore.get(projection.getName(), "Mode").getI()==0 - ||(parameterStore.get(projection.getName(), "Mode").getI()>8 - &&(projection instanceof AProjectionYX||projection instanceof AProjectionFR)); - - for(int layer=0; layer<2; ++layer) - { - for(int det=0; det<detectors.length; ++det) - { - ADrawParameters dp=detectors[det].getDrawParameters(layer, 0); - ag.updateDrawParameters(dp); - for(int i=0; i<display[det].hv[0].length; ++i) - { - int numPoints=display[det].hv[0][i].length; - ag.setColor(colorMap[detColor[det][i]]); - if(draw[det][i]&& numPoints>0) - { - if(modeSelection) - { - if(layer==0 && (drawFrames||colorBW)) - { - if(colorBW) - ag.setColor(colorMap[AColorMap.BK]); - ag.drawPolygon(display[det].hv[0][i], display[det].hv[1][i], numPoints); - } - else if(layer==1) - { - if(drawFrames) - ag.setColor(colorMap[bkgColor]); - ag.fillPolygon(detectors[det], index[det][i], display[det].hv[0][i], - display[det].hv[1][i], numPoints); - } - } - else - { - if(layer==0) - { - if(drawFrames) - ag.setColor(colorMap[bkgColor]); - ag.fillPolygon(detectors[det], index[det][i], display[det].hv[0][i], - display[det].hv[1][i], numPoints); - } - else if(layer==1 && (drawFrames||colorBW)) - { - if(colorBW) - ag.setColor(colorMap[AColorMap.BK]); - ag.drawPolygon(display[det].hv[0][i], display[det].hv[1][i], numPoints); - } - } - } - } - } - } - ABarrelSiliconDetector.drawAdditionalItems(window, ag, projection); - AEndcapSiliconDetector.drawAdditionalItems(window, ag, projection); - ABarrelTRTDetector.drawAdditionalItems(window, ag, projection); - AEndcapTRTDetector.drawAdditionalItems(window, ag, projection); - ACalorimeterDetector.drawAdditionalItems(window, ag, projection); - } - - public static String getGeometryName() - { - return geometryName == null ? "n/a" : geometryName; - - } // getName() ------------------------------------------------------------ - -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ADetectors.java b/graphics/AtlantisJava/src/atlantis/geometry/ADetectors.java deleted file mode 100755 index 1f11913e80d18965ea1ab08ef6c10f3fe5154282..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ADetectors.java +++ /dev/null @@ -1,114 +0,0 @@ -package atlantis.geometry; - -import atlantis.graphics.*; -import atlantis.parameters.APar; -import atlantis.projection.*; - -/** - * Base class of all collections of detectors - * All non muon geometry is in AGeometry.xml - * All muon geometry is in AMuonGeometry.xml - * ADetectors is the interface to the rest of the program and contains - * collections of detectors. - * When a line in our XML file describes several detectors these are stored - * individually. - */ -public abstract class ADetectors { - - protected ADetector[] det=null; - - protected int[] listdl; - protected int numDraw; - protected int numData; - - protected static APar parameterStore = APar.instance(); - - public ADetectors(ADetector[] det) { - this.det=det; - numData=det.length; - numDraw=0; - listdl=new int[numData]; - } - - public ADetector[] getDetectors() { - return det; - } - - protected void constructDefaultDrawList() { - numDraw=numData; - for(int i=0; i<numDraw; ++i) - listdl[i]=i; - } - - protected void makeDrawList(String projection){ - constructDefaultDrawList(); - } - - protected ACoord getUser(String projection) { - makeDrawList(projection); - int[] numPoly = new int[numDraw]; - int numTotal = 0; - for (int i=0; i<numDraw; i++) { - int len = det[listdl[i]].getUser(projection).hv[0].length; - numPoly[i] = len; - numTotal += len; - } - double[][][] hv = new double[2][numTotal][]; - int[] index = new int[numTotal]; - for (int i=0, k=0; i<numDraw; i++) { - double temp[][][] = det[listdl[i]].getUser(projection).hv; - for(int j = 0; j < numPoly[i]; j++, k++) { - hv[0][k] = temp[0][j]; - hv[1][k] = temp[1][j]; - index[k] = listdl[i]; - } - } - return new ACoord(hv, index); - } - - protected int[] getColor(int[] dl) { - int[] col=new int[dl.length]; - - for(int i=0; i<dl.length; ++i) - col[i]=det[dl[i]].getFillColor(); - return col; - } - - protected boolean[] getDraw(int[] dl) { - boolean[] draw=new boolean[dl.length]; - - for(int i=0; i<dl.length; ++i) - draw[i]=det[dl[i]].getDraw(); - return draw; - } - - public String getInfo(int index) { - return det[index].getName(); - } - - protected ADrawParameters getDrawParameters(int layer, int type) { - if(layer==0) - return new ADrawParameters(true, 0, 0, 0, 1, 0); - else - return new ADrawParameters(true, 0, 0, 1, 0, 0); - } - - protected ACoord getUserNoTransform(AProjection projection) { - String name=projection.getName(); - ACoord data=getUser(name); - if(name.charAt(0)=='F') - data.includePhiWrapAround(name); - return data; - } - - protected ACoord getUser(AProjection2D projection) { - return projection.nonLinearTransform(getUserNoTransform(projection)); - } - - /* - protected void draw(AWindow window,AGraphics ag,AProjection2D projection) { - // in a simple world the implementation would be here - throw new RuntimeException(); - } - */ -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ADiscDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/ADiscDetector.java deleted file mode 100755 index a8241c1889ce547f843598fbe243586cb2a37dd6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ADiscDetector.java +++ /dev/null @@ -1,57 +0,0 @@ -package atlantis.geometry; - -import atlantis.utils.*; -import atlantis.graphics.ACoord; - -public class ADiscDetector extends ADetector { - - double rInner; - double rOuter; - int nInner; - int nOuter; - - ADiscDetector(String name, String projection, String color, double rInner, double rOuter, int nInner, int nOuter) { - super(name, projection, color); - this.rInner=rInner; - this.nInner=nInner; - this.rOuter=rOuter; - this.nOuter=nOuter; - } - - protected ACoord getYXUser() { - if (!projection.equals("YX")) { - return ACoord.NO_DATA; - } - - if (!globals.getUseOpenGL()) { - int numPoints = nInner + nOuter + 2; - double[][] hv = new double[2][numPoints]; - - for (int j = 0; j < nInner + 1; j++) { - hv[0][j] = rInner * Math.cos(Math.PI * 2 * j / nInner); - hv[1][j] = rInner * Math.sin(Math.PI * 2 * j / nInner); - } - for (int j = 0; j < nOuter + 1; j++) { - hv[0][j + nInner + 1] = rOuter * Math.cos(Math.PI * 2 * (nOuter - j) / nOuter); - hv[1][j + nInner + 1] = rOuter * Math.sin(Math.PI * 2 * (nOuter - j) / nOuter); - } - return new ACoord(hv); - } else { - //FIXME: - //Note that generateAnnulusTris can't really handle this different number - //of inner and outer points thing so we're just going to take the mean here - //Maybe one day we fix this somehow or just remove one of the ns - //All the other round detectors get along fine without it... - // -- Adam - return new ACoord(generateAnnulusTris((nInner + nOuter) / 2, 0.0, rInner, rOuter)); - } - } - - protected ACoord getFRUser() { - if(!projection.equals("FR")) return ACoord.NO_DATA; - return new ACoord (AMath.xBox((rInner+rOuter)/2.,(rOuter-rInner)/2.), - AMath.yBox(180.,180.)); - } - -} - diff --git a/graphics/AtlantisJava/src/atlantis/geometry/AEndcapCalorimeterDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/AEndcapCalorimeterDetector.java deleted file mode 100755 index a5df48ac54f2c79f97694ab3ccad411522340a52..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/AEndcapCalorimeterDetector.java +++ /dev/null @@ -1,328 +0,0 @@ -package atlantis.geometry; - -import atlantis.graphics.ACoord; -import atlantis.graphics.AClipper; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AMath; - -/** - * Class representing a calorimeter part in the endcap section of ATLAS. - */ -public class AEndcapCalorimeterDetector extends ACalorimeterDetector { - - /** - * Constructs a new endcap calorimeter object - * @param name String name of the object - * @param color String name of the color used to draw this object - * @param sampling int sampling of this calorimeter part - * @param region int region of this calorimeter part - * @param rMin double inner radius - * @param rMax double outer radius - * @param zMin double inner z - * @param zMax double outer z - * @param eta0 double start of the first cell in eta - * @param deta double size of a cell in eta - * @param neta int number of cells in eta - * @param meta int eta index of the first cell - * @param phi0 double start of the first cell in phi - * @param nphi int number of cells in phi - */ - public AEndcapCalorimeterDetector(String name, String color, int sampling, int region, - double rMin, double rMax, double zMin, double zMax, - double eta0, double deta, int neta, int meta, - double phi0, int nphi) { - super(name, color); - - this.sampling = sampling; - this.region = region; - this.rMin = rMin; - this.rMax = rMax; - this.zMin = zMin; - this.zMax = zMax; - this.eta0 = eta0; - this.deltaEta = deta; - this.numEta = neta; - this.minEta = meta; - this.phi0 = Math.toRadians(phi0); - this.numPhi = nphi; - this.deltaPhi = 2.*Math.PI / numPhi; - - this.detEtaMin = AMath.etaAbs(this.zMin, this.rMax); - this.detEtaMax = AMath.etaAbs(this.zMax, this.rMax); - - // This one is used for clipping the cell geometry in rho-z. - this.clipper = new AClipper(zMin, zMax, rMin, rMax); - - // These arrays are used by the getDetectorIndex() method in ACalorimeterData. - // They provide fast mapping of hits to detectors. - if (this.name.indexOf("LAr") >= 0 && this.name.indexOf("Inner") >= 0 - && this.sampling < lar[3].length && this.region < lar[3][this.sampling].length) { - - lar[3][this.sampling][this.region] = detectors.indexOf(this); - } else if (this.name.indexOf("LAr") >= 0 && this.sampling < lar[2].length - && this.region < lar[2][this.sampling].length) { - - lar[2][this.sampling][this.region] = detectors.indexOf(this); - } else if (this.name.equals("HEC") && this.sampling < hec.length - && this.region < hec[this.sampling].length) { - - hec[this.sampling][this.region] = detectors.indexOf(this); - } else { - System.out.println("Unknown calorimeter object: '" + this.name + "'" - + " some hits might not be displayed correctly."); - } - } - - /** - * Returns the y-x geometry of the full calorimeter part. - * @return ACoord polygons representing geometry - */ - protected ACoord getYXUser() { - int mode = parameterStore.get("YX", "Mode").getI(); - if ( mode < AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER) - return ACoord.NO_DATA; - else if((mode==AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER && (name.equals("LAr Endcap Presampler")||name.equals("LAr_EC_Presampler"))) - || (name.equals("LAr Outer Endcap") && sampling==mode-AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER) - || (name.equals("LAr Inner Endcap") && sampling==mode-AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER-1) - || (name.equals("HEC") && sampling==mode-AProjectionYX.MODE_HEC_1) - || (mode==AProjectionYX.MODE_LAR_ENDCAP_SUMMED && name.indexOf("LAr")>=0) - || (mode==AProjectionYX.MODE_HEC_SUMMED && name.equals("HEC"))) - { - - double etaMax = eta0 + numEta * deltaEta; - double etaMin = eta0; - double r1, r2; - if (name.equals("HEC")) - { - r1=rMax; - r2=rMin; - } - else - { - if (name.indexOf("Inner") >= 0 || name.indexOf("Presampler") >= 0) - r1 = zMin/Math.sinh(etaMin); - else - r1=rMax; - r2 = zMin/Math.sinh(etaMax); - } - - if (!globals.getUseOpenGL()) { - int numPoints = 2 * (numPhi + 1); - double[][] hv = new double[2][numPoints]; - for (int i = 0; i < numPhi + 1; i++) { - hv[0][i] = r2 * Math.cos(phi0 + i * deltaPhi); - hv[1][i] = r2 * Math.sin(phi0 + i * deltaPhi); - hv[0][numPhi + 1 + i] = r1 * Math.cos(phi0 - i * deltaPhi); - hv[1][numPhi + 1 + i] = r1 * Math.sin(phi0 - i * deltaPhi); - } - return new ACoord(hv); - } else { - return new ACoord(generateAnnulusTris(numPhi, phi0, r1, r2)); - } - } - else - return ACoord.NO_DATA; - } - - /** - * Returns the rho-z geometry of the full calorimeter part. - * @return ACoord polygons representing geometry - */ - protected ACoord getRZUser() { - double h[], v[]; - double etaMax = eta0 + numEta * deltaEta; - double etaMin = eta0; - - // Calculate the polygon in the positive h and v. - if (name.indexOf("HEC") >= 0) { - h = new double[] {zMax, zMin, zMin, zMax}; - v = new double[] {rMax, rMax, rMin, rMin}; - } else { - double r0 = zMax/Math.sinh(etaMin); - double r1 = zMin/Math.sinh(etaMin); - double r2 = zMin/Math.sinh(etaMax); - double r3 = zMax/Math.sinh(etaMax); - - h = new double[] {zMax, zMin, zMin, zMax}; - v = new double[] {r0, r1, r2, r3}; - } - - // Clip the polygon. - ACoord coord = clipper.clipPolygon(h, v, h.length); - - // Copy it to negative v. - coord = new ACoord(coord, coord.mirrorV()); - // Copy it to negative h. - coord = new ACoord(coord, coord.mirrorH()); - - return coord; - } - - /** - * Returns the phi-rho geometry of the full calorimeter part. - * @return ACoord polygons representing geometry - */ - protected ACoord getFRUser() { - return getYXUser().convertYXToFR(); - } - - /** - * Returns the phi-z geometry of the full calorimeter part. - * @return ACoord polygons representing geometry - */ - protected ACoord getFZUser() { - double[][][] hv = new double[2][2][]; - double phiMin = 0.; - double phiMax = 360.; - hv[0][0] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][0] = new double[] {phiMax, phiMax, phiMin, phiMin}; - hv[0][1] = new double[] { -zMax, -zMin, -zMin, -zMax}; - hv[1][1] = new double[] {phiMax, phiMax, phiMin, phiMin}; - return new ACoord(hv); - } - - /** - * Returns the y-x geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getYXCell(int eta, int phi) - { - int mode = parameterStore.get("YX", "Mode").getI(); - if(mode < AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER || mode > AProjectionYX.MODE_HEC_SUMMED) - return ACoord.NO_DATA; - else if((mode==AProjectionYX.MODE_LAR_ENDCAP_SUMMED && name.indexOf("LAr")>=0) - || (mode==AProjectionYX.MODE_HEC_SUMMED && name.equals("HEC"))) - { - //don't need to carry out calculation just needs return a blank ACoord - double[][] hv = new double[2][]; - hv[0] = new double[] {0}; - hv[1] = new double[] {0}; - return new ACoord(hv); - } - else if((mode==AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER && (name.equals("LAr Endcap Presampler") || name.equals("LAr_EC_Presampler"))) - || (name.equals("LAr Outer Endcap") && sampling==mode-AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER) - || (name.equals("LAr Inner Endcap") && sampling==mode-AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER-1) - || (name.equals("HEC") && sampling==mode-AProjectionYX.MODE_HEC_1)) - { - double[][] hv = new double[2][]; - double phiMin = phi0+phi*deltaPhi; - double phiMax = phiMin+deltaPhi; - double newrMax=0, newrMin=0; - double etaMin = eta0+(eta-minEta)*deltaEta; - double etaMax = etaMin+deltaEta; - newrMax=zMin/Math.sinh(etaMin); - newrMin=zMin/Math.sinh(etaMax); - if (name.equals("HEC")) - { - if(newrMax>rMax) - newrMax=rMax; - if(newrMin<rMin) - newrMin=rMin; - } - hv[0] = new double[] {newrMax*Math.cos(phiMin), newrMax*Math.cos(phiMax), - newrMin*Math.cos(phiMax), newrMin*Math.cos(phiMin)}; - hv[1] = new double[] {newrMax*Math.sin(phiMin), newrMax*Math.sin(phiMax), - newrMin*Math.sin(phiMax), newrMin*Math.sin(phiMin)}; - return new ACoord(hv); - } - else - return ACoord.NO_DATA; - } - - /** - * Returns the rho-z geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @param side int sign of the z coordinate of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getRZCell(int eta, int phi, int side) { - double[][] hv = new double[2][]; - int sign = getRSign(phi); - - // This shouldn't be 0, but just to be on the safe side. - if (side != 0) side /= Math.abs(side); - - double etaMin = eta0+(eta-minEta)*deltaEta; - double etaMax = etaMin+deltaEta; - - if (name.indexOf("HEC") >= 0) { - if (sampling == 0) { - double rMin = (zMin+zMax)/2. / Math.sinh(etaMax); - double rMax = (zMin+zMax)/2. / Math.sinh(etaMin); - - hv[0] = new double[] {zMax, zMin, zMin, zMax}; - hv[1] = new double[] {rMax, rMax, rMin, rMin}; - } else { - double dz = (zMax-zMin); - double z0 = zMin; - double z1 = zMin+dz/2.; - double z2 = zMax; - double r0 = (zMin+dz/4.) / Math.sinh(etaMax); - double r1 = (zMax-dz/4.) / Math.sinh(etaMax); - double r2 = (zMin+dz/4.) / Math.sinh(etaMin); - double r3 = (zMax-dz/4.) / Math.sinh(etaMin); - - hv[0] = new double[] {z2, z1, z1, z0, z0, z1, z1, z2}; - hv[1] = new double[] {r3, r3, r2, r2, r0, r0, r1, r1}; - } - } else { - hv[0] = new double[] {zMax, zMin, zMin, zMax}; - hv[1] = new double[] {zMax/Math.sinh(etaMin), zMin/Math.sinh(etaMin), - zMin/Math.sinh(etaMax), zMax/Math.sinh(etaMax)}; - } - - // Clip the cell and send it to the right quadrant. - ACoord coord = clipper.clipPolygon(hv[0], hv[1], hv[0].length); - for (int i=0; i<coord.hv[0][0].length; i++) { - coord.hv[0][0][i] *= side; - coord.hv[1][0][i] *= sign; - } - - return coord; - } - - /** - * Returns the phi-z geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @param side int sign of the z coordinate of cell - * @return ACoord - */ - public ACoord getFZCell(int eta, int phi, int side) { - double[][] hv = new double[2][]; - double phiMin = Math.toDegrees(phi0 + phi*deltaPhi); - double phiMax = phiMin + Math.toDegrees(deltaPhi); - - side /= Math.abs(side); - - hv[0] = new double[] {side*zMax, side*zMin, side*zMin, side*zMax}; - hv[1] = new double[] { phiMax, phiMax, phiMin, phiMin}; - - return new ACoord(hv); - } - - /** - * Returns the eta-phi geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @param side int sign of the z coordinate of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getVPCell(int eta, int phi, int side) { - double[][] hv = new double[2][]; - double etaMin = eta0+(eta-minEta)*deltaEta; - double etaMax = etaMin+deltaEta; - double phiMin = Math.toDegrees(phi0 + phi*deltaPhi); - double phiMax = phiMin + Math.toDegrees(deltaPhi); - - side /= Math.abs(side); - - hv[0] = new double[] {side*etaMax, side*etaMin, side*etaMin, side*etaMax}; - hv[1] = new double[] { phiMax, phiMax, phiMin, phiMin}; - - return new ACoord(hv); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/AEndcapCryostatDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/AEndcapCryostatDetector.java deleted file mode 100755 index 8d1122eba4bf2f89214d8c143c0e5d394bdd1236..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/AEndcapCryostatDetector.java +++ /dev/null @@ -1,158 +0,0 @@ -package atlantis.geometry; - -import atlantis.graphics.ACoord; -import atlantis.graphics.AClipper; -import atlantis.projection.AProjectionYX; -import atlantis.utils.AMath; - -/** - * Class representing a detector part in the endcap cryostat section of ATLAS. - */ -public class AEndcapCryostatDetector extends ACalorimeterDetector { - - /** - * Constructs a new endcap calorimeter object - * @param name String name of the object - * @param color String name of the color used to draw this object - * @param sampling int sampling of this calorimeter part - * @param region int region of this calorimeter part - * @param rMin double inner radius - * @param rMax double outer radius - * @param zMin double inner z - * @param zMax double outer z - * @param neta int number of cells in eta - * @param nphi int number of cells in phi - */ - public AEndcapCryostatDetector(String name, String color, int sampling, int region, double rMin, - double rMax, double zMin, double zMax, int neta, int nphi) { - super(name, color); - - this.sampling = sampling; - this.region = region; - this.rMin = rMin; - this.rMax = rMax; - this.zMin = zMin; - this.zMax = zMax; - this.numEta = neta; - this.numPhi = nphi; - this.deltaPhi = 2.*Math.PI / numPhi; - this.phi0 = 0.0; - this.eta0 = AMath.etaAbs(this.zMin, this.rMin); - - this.detEtaMin = AMath.etaAbs(this.zMin, this.rMax); - this.detEtaMax = AMath.etaAbs(this.zMax, this.rMax); - - // This one is used for clipping the cell geometry in rho-z. - this.clipper = new AClipper(zMin, zMax, rMin, rMax); - - // These arrays are used by the getDetectorIndex() method in ACalorimeterData. - // They provide fast mapping of hits to detectors. - if (this.name.equals("Minimum Bias Trigger Scintillators")) { - mbts[this.sampling] = detectors.indexOf(this); - } else { - System.out.println("Unknown calorimeter object: '" + this.name + "'" - + " some hits might not be displayed correctly."); - } - } - - /** - * Returns the y-x geometry of the full calorimeter part. - * @return ACoord polygons representing geometry - */ - protected ACoord getYXUser() { - int mode = parameterStore.get("YX", "Mode").getI(); - if (mode!=AProjectionYX.MODE_MBTS) - return ACoord.NO_DATA; - else - { - if (!globals.getUseOpenGL()) { - int numPoints = 2 * (numPhi + 1); - double[][] hv = new double[2][numPoints]; - for (int j = 0; j < numPhi + 1; j++) { - hv[0][j] = rMin * Math.cos(Math.PI * 2 * j / numPhi); - hv[1][j] = rMin * Math.sin(Math.PI * 2 * j / numPhi); - } - for (int j = 0; j < numPhi + 1; j++) { - hv[0][j + numPhi + 1] = rMax * Math.cos(Math.PI * 2 * (numPhi - j) / numPhi); - hv[1][j + numPhi + 1] = rMax * Math.sin(Math.PI * 2 * (numPhi - j) / numPhi); - } - return new ACoord(hv); - } else { - return new ACoord(generateAnnulusTris(numPhi, phi0, rMin, rMax)); - } - } - } - - /** - * Returns the rho-z geometry of the full calorimeter part. - * @return ACoord polygons representing geometry - */ - protected ACoord getRZUser() { - double h[], v[]; - // Calculate the polygon in the positive h and v. - h = new double[] {zMax, zMin, zMin, zMax}; - v = new double[] {rMax, rMax, rMin, rMin}; - // Clip the polygon. - ACoord coord = clipper.clipPolygon(h, v, h.length); - // Copy it to negative v. - coord = new ACoord(coord, coord.mirrorV()); - // Copy it to negative h. - coord = new ACoord(coord, coord.mirrorH()); - return coord; - } - - /** - * Returns the phi-rho geometry of the full calorimeter part. - * @return ACoord polygons representing geometry - */ - protected ACoord getFRUser() { - return getYXUser().convertYXToFR(); - } - - /** - * Returns the y-x geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getYXCell(int eta, int phi) - { - int mode = parameterStore.get("YX", "Mode").getI(); - if(mode!=AProjectionYX.MODE_MBTS) - return ACoord.NO_DATA; - else - { - double[][] hv = new double[2][]; - double phiMin = Math.PI*2*phi/numPhi; - double phiMax = Math.PI*2*(1+phi)/numPhi; - hv[0] = new double[] {rMax*Math.cos(phiMin), rMax*Math.cos(phiMax), - rMin*Math.cos(phiMax), rMin*Math.cos(phiMin)}; - hv[1] = new double[] {rMax*Math.sin(phiMin), rMax*Math.sin(phiMax), - rMin*Math.sin(phiMax), rMin*Math.sin(phiMin)}; - return new ACoord(hv); - } - } - - /** - * Returns the rho-z geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @param side int sign of the z coordinate of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getRZCell(int eta, int phi, int side) { - double[][] hv = new double[2][]; - int sign = getRSign(phi); - // This shouldn't be 0, but just to be on the safe side. - if (side != 0) side /= Math.abs(side); - hv[0] = new double[] {zMax, zMin, zMin, zMax}; - hv[1] = new double[] {rMax, rMax, rMin, rMin}; - // Clip the cell and send it to the right quadrant. - ACoord coord = clipper.clipPolygon(hv[0], hv[1], hv[0].length); - for (int i=0; i<coord.hv[0][0].length; i++) { - coord.hv[0][0][i] *= side; - coord.hv[1][0][i] *= sign; - } - return coord; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/AEndcapSiliconDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/AEndcapSiliconDetector.java deleted file mode 100755 index e28c5f168695aa81f115e9194ac08f280272cf6f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/AEndcapSiliconDetector.java +++ /dev/null @@ -1,220 +0,0 @@ -package atlantis.geometry; - -import atlantis.canvas.AWindow; -import atlantis.data.AS3DData; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionYX; -import java.awt.Color; -import java.util.ArrayList; -import java.util.List; - -/** - * Class representing a pixel/SCT endcap detector part. - * Also implements methods to draw more detailed structure of the detector. - * - * @author Eric Jansen - */ -public class AEndcapSiliconDetector extends ADetector { - - private static List detectors = null; - - protected int layer; - protected double length; - protected double width; - protected double thickness; - protected int numZ; - protected int numPhi; - protected double phi0; - protected double zMin; - protected double zMax; - - protected double deltaPhi; - protected double deltaZ; - protected double rMin; - protected double rMax; - - public AEndcapSiliconDetector(String name, String color, int layer, double length, double width, double thickness, - int numZ, int numPhi, double rMin, double rMax, double phi0, double zMin, double zMax) { - super(name, " ", color); - - if (detectors == null) { - detectors = new ArrayList(); - } - detectors.add(this); - - this.layer = layer; - this.length = length; - this.width = width; - this.thickness = thickness; - this.numZ = numZ; - this.numPhi = numPhi; - this.rMin = rMin; - this.rMax = rMax; - this.phi0 = Math.toRadians(phi0); - this.zMin = zMin; - this.zMax = zMax; - - this.deltaPhi = 2.*Math.PI / this.numPhi; - this.deltaZ = (this.zMax - this.zMin) / this.numZ; - } - - /** - * Empties the list of instances of this class. - */ - public static void clear() { - if (detectors != null) { - detectors.clear(); - } - } - - /** - * This function draws the wafer/stave structure of the silicon detectors. It is called - * from ADetectorSystem.draw(). - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - * @param projection AProjection2D current projection - */ - public static void drawAdditionalItems(AWindow window, AGraphics ag, AProjection2D projection) { - AParameter inDetDetail = parameterStore.getUnknown("Det", "SiliconDetail"); - if (inDetDetail != null && detectors != null && inDetDetail.getStatus()) { - for (int i=0; i<detectors.size(); i++) { - ACoord coord = ACoord.NO_DATA; - AEndcapSiliconDetector detector = (AEndcapSiliconDetector) detectors.get(i); - if (projection instanceof AProjectionYX) { - coord = detector.getYXDetail(); - } else if (projection instanceof AProjectionFR) { - coord = detector.getYXDetail().convertYXToFR().includePhiWrapAround("FR"); - } - - if (coord != ACoord.NO_DATA) { - Color[] colorMap = AColorMap.getColors(); - ag.setColor(colorMap[parameterStore.get("Det", "SiliconDetail").getI()]); - - ACoord display = window.calculateDisplay(projection.nonLinearTransform(coord)); - for (int j=0; j<display.hv[0].length; j++) { - ag.drawPolygon(display.hv[0][j], display.hv[1][j], display.hv[0][j].length); - } - } - } - } - } - - /** - * Determines if this element should be visible or not. - * @return visibility - */ - protected boolean isVisible() { - int cut = parameterStore.get("CutsInDet", "SCT").getI(); - - if (cut == AS3DData.CUT_INDET_SCT_ALL || cut == AS3DData.CUT_INDET_SCT_EC_NEG - || cut == AS3DData.CUT_INDET_SCT_EC_POS) { - return true; - } else { - return false; - } - } - - /** - * Returns the detector outline in the y-x projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getYXUser() { - if (parameterStore.get("YX", "Mode").getI() != AProjectionYX.MODE_STANDARD) return ACoord.NO_DATA; - if (!isVisible()) return ACoord.NO_DATA; - - if (!globals.getUseOpenGL()) { - int numPoints = 2 * (numPhi + 1); - double[][] hv = new double[2][numPoints]; - - for (int i = 0; i < numPhi + 1; i++) { - hv[0][i] = rMin * Math.cos(phi0 + (i + 0.5) * deltaPhi); - hv[1][i] = rMin * Math.sin(phi0 + (i + 0.5) * deltaPhi); - - hv[0][numPhi + 1 + i] = rMax * Math.cos(phi0 - (i + 0.5) * deltaPhi); - hv[1][numPhi + 1 + i] = rMax * Math.sin(phi0 - (i + 0.5) * deltaPhi); - } - return new ACoord(hv); - } else { - return new ACoord(generateAnnulusTris(numPhi, phi0, rMin, rMax)); - } - } - - /** - * Returns the detector outline in the rho-z projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getRZUser() { - double[][][] hv = new double[2][4][]; - - hv[0][0] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][0] = new double[] { rMax, rMax, rMin, rMin}; - hv[0][1] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][1] = new double[] {-rMin, -rMin, -rMax, -rMax}; - - hv[0][2] = new double[] {-zMax, -zMin, -zMin, -zMax}; - hv[1][2] = new double[] { rMax, rMax, rMin, rMin}; - hv[0][3] = new double[] {-zMax, -zMin, -zMin, -zMax}; - hv[1][3] = new double[] {-rMin, -rMin, -rMax, -rMax}; - - return new ACoord(hv); - } - - /** - * Returns the detector outline in the phi-z projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getFZUser() { - if (!isVisible()) return ACoord.NO_DATA; - - double[][][] hv = new double[2][2][]; - - hv[0][0] = new double[] {zMax, zMin, zMin, zMax}; - hv[1][0] = new double[] {360., 360., 0., 0.}; - hv[0][1] = new double[] {-zMax, -zMin, -zMin, -zMax}; - hv[1][1] = new double[] {360., 360., 0., 0.}; - - return new ACoord(hv); - } - - /** - * Returns the detector outline in the phi-rho projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getFRUser() { - if (!isVisible()) return ACoord.NO_DATA; - - return getYXUser().convertYXToFR(); - } - - /** - * Returns the wafer/stave structure in the y-x projection. - * @return ACoord polygons representing the wafers/staves - */ - protected ACoord getYXDetail() { - if (parameterStore.get("YX", "Mode").getI() != AProjectionYX.MODE_STANDARD) return ACoord.NO_DATA; - if (!isVisible()) return ACoord.NO_DATA; - - double[][][] hv = new double[2][numPhi][]; - for (int i=0; i<numPhi; i++) { - hv[0][i] = new double[] { - rMax*Math.sin(phi0+(i-0.5)*deltaPhi), - rMax*Math.sin(phi0+(i+0.5)*deltaPhi), - rMin*Math.sin(phi0+(i+0.5)*deltaPhi), - rMin*Math.sin(phi0+(i-0.5)*deltaPhi) - }; - hv[1][i] = new double[] { - rMax*Math.cos(phi0+(i-0.5)*deltaPhi), - rMax*Math.cos(phi0+(i+0.5)*deltaPhi), - rMin*Math.cos(phi0+(i+0.5)*deltaPhi), - rMin*Math.cos(phi0+(i-0.5)*deltaPhi) - }; - } - - return new ACoord(hv); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/AEndcapTRTDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/AEndcapTRTDetector.java deleted file mode 100755 index a23bfaf0d0221be8770250642a8503cf60b10355..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/AEndcapTRTDetector.java +++ /dev/null @@ -1,173 +0,0 @@ -package atlantis.geometry; - -import atlantis.canvas.AWindow; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjectionRZ; -import java.awt.Color; -import java.util.ArrayList; -import java.util.List; - -/** - * Class representing a TRT endcap detector part. - * Also implements methods to draw more detailed structure of the detector. - * - * @author Eric Jansen - */ -public class AEndcapTRTDetector extends ADetector { - - private static List detectors = null; - - protected int layer; - protected int numPhi; - protected double rMin; - protected double rMax; - protected double phi0; - protected double zMin; - protected double zMax; - protected double deltaPhi; - - public AEndcapTRTDetector(String name, String color, int layer, int numPhi, double rMin, double rMax, - double phi0, double zMin, double zMax) { - super(name, " ", color); - - if (detectors == null) { - detectors = new ArrayList(); - } - detectors.add(this); - - this.layer = layer; - this.numPhi = numPhi; - this.rMin = rMin; - this.rMax = rMax; - this.phi0 = Math.toRadians(phi0); - this.zMin = zMin; - this.zMax = zMax; - - this.deltaPhi = 2.*Math.PI / numPhi; - } - - /** - * Empties the list of instances of this class. - */ - public static void clear() { - if (detectors != null) { - detectors.clear(); - } - } - - /** - * This function draws the module structure of the TRT detector. It is called - * from ADetectorSystem.draw(). - * @param window AWindow window to use - * @param ag AGraphics graphics object to draw onto - * @param projection AProjection2D current projection - */ - public static void drawAdditionalItems(AWindow window, AGraphics ag, AProjection2D projection) { - AParameter inDetDetail = parameterStore.getUnknown("Det", "TRTDetail"); - if (inDetDetail != null && detectors != null && inDetDetail.getStatus()) { - for (int i=0; i<detectors.size(); i++) { - ACoord coord = ACoord.NO_DATA; - AEndcapTRTDetector detector = (AEndcapTRTDetector) detectors.get(i); - if (projection instanceof AProjectionRZ) { - coord = detector.getRZDetail(); - } else if (projection instanceof AProjectionFZ) { - coord = detector.getFZDetail(); - } - - if (coord != ACoord.NO_DATA) { - Color[] colorMap = AColorMap.getColors(); - ag.setColor(colorMap[parameterStore.get("Det", "TRTDetail").getI()]); - - ACoord display = window.calculateDisplay(projection.nonLinearTransform(coord)); - for (int j=0; j<display.hv[0].length; j++) { - ag.drawPolygon(display.hv[0][j], display.hv[1][j], display.hv[0][j].length); - } - } - } - } - } - - /** - * Returns the detector outline in the y-x projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getYXUser() { - return ACoord.NO_DATA; - } - - /** - * Returns the detector outline in the rho-z projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getRZUser() { - double[][][] hv = new double[2][4][]; - - hv[0][0] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][0] = new double[] { rMax, rMax, rMin, rMin}; - hv[0][1] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][1] = new double[] {-rMin, -rMin, -rMax, -rMax}; - hv[0][2] = new double[] {-zMax, -zMin, -zMin, -zMax}; - hv[1][2] = new double[] { rMax, rMax, rMin, rMin}; - hv[0][3] = new double[] {-zMax, -zMin, -zMin, -zMax}; - hv[1][3] = new double[] {-rMin, -rMin, -rMax, -rMax}; - - return new ACoord(hv); - } - - /** - * Returns the detector outline in the phi-z projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getFZUser() { - double[][][] hv = new double[2][2][]; - - hv[0][0] = new double[] {zMax, zMin, zMin, zMax}; - hv[1][0] = new double[] {360., 360., 0., 0.}; - hv[0][1] = new double[] {-zMax, -zMin, -zMin, -zMax}; - hv[1][1] = new double[] {360., 360., 0., 0.}; - - return new ACoord(hv); - } - - /** - * Returns the detector outline in the phi-rho projection. - * @return ACoord polygon representing the detector - */ - protected ACoord getFRUser() { - return ACoord.NO_DATA; - } - - /** - * Returns the module structure in the rho-z projection. - * @return ACoord polygons representing the modules - */ - protected ACoord getRZDetail() { - return ACoord.NO_DATA; - } - - /** - * Returns the module structure in the phi-z projection. - * @return ACoord polygons representing the modules - */ - protected ACoord getFZDetail() { - double[][][] hv = new double[2][2*numPhi][2]; - for (int i=0; i<numPhi; i++) { - hv[0][i][0] = zMin; - hv[1][i][0] = Math.toDegrees(phi0 + i*deltaPhi); - hv[0][i][1] = zMax; - hv[1][i][1] = Math.toDegrees(phi0 + i*deltaPhi); - hv[0][numPhi+i][0] = -zMax; - hv[1][numPhi+i][0] = Math.toDegrees(phi0 + i*deltaPhi); - hv[0][numPhi+i][1] = -zMin; - hv[1][numPhi+i][1] = Math.toDegrees(phi0 + i*deltaPhi); - } - - return new ACoord(hv).includePhiWrapAround("FZ"); - } -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/geometry/AGapCalorimeterDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/AGapCalorimeterDetector.java deleted file mode 100755 index a27a9872377ab9ab57c9988cdf9c3a51d4011fb0..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/AGapCalorimeterDetector.java +++ /dev/null @@ -1,179 +0,0 @@ -package atlantis.geometry; - -import atlantis.graphics.ACoord; -import atlantis.parameters.AParameterUtilities; - -/** - * Class representing a calorimeter in the gap region between TILE and extended TILE. - * This is a fairly straightforward implementation of ACalorimeterDetector with only - * one cell per object. - * - * @author Eric Jansen - */ -public class AGapCalorimeterDetector extends ACalorimeterDetector { - - protected int eta; - - /** - * Constructs a new gap calorimeter object (one cell in eta). - * @param name String name of the object - * @param color String name of the color used to draw this object - * @param sampling int sampling of this calorimeter part - * @param region int region of this calorimeter part - * @param rMin double inner radius - * @param rMax double outer radius - * @param zMin double inner z - * @param zMax double outer z - * @param eta int eta index of this cell - * @param phi0 double start of the first cell in phi - * @param nphi int number of cells in phi - */ - public AGapCalorimeterDetector(String name, String color, int sampling, int region, - double rMin, double rMax, double zMin, double zMax, - int eta, double phi0, int nphi) { - super(name, color); - - // Just to be sure we take absolute values here. - this.sampling = Math.abs(sampling); - this.region = Math.abs(region); - this.eta = Math.abs(eta); - - this.rMin = rMin; - this.rMax = rMax; - this.zMin = zMin; - this.zMax = zMax; - this.phi0 = Math.toRadians(phi0); - this.numPhi = nphi; - this.deltaPhi = 2.*Math.PI/numPhi; - - // These arrays are used by the getDetectorIndex() method in ACalorimeterData. - // They provide fast mapping of hits to detectors. - if (this.name.indexOf("ITC") >= 0 && this.sampling < tile_gap.length - && this.eta < tile_gap[this.sampling].length) { - - tile_gap[this.sampling][this.eta] = detectors.indexOf(this); - } else { - System.out.println("Unknown calorimeter object: '" + this.name + "'" - + " some hits might not be displayed correctly."); - } - } - - /** - * Returns the eta value of the center (in eta) of a cell. - * @param eta int eta index of the cell - * @param side int sign of the z coordinate of the cell - * @return double eta value - */ - public double getEta(int eta, int side) { - if (side < 0) { - return -getEta(eta, -side); - } else { - return AParameterUtilities.eta((zMin+zMax)/2.f, (rMin+rMax)/2.f); - } - } - - /** - * Returns the lowest eta value of a cell. - * @param eta int eta index of the cell - * @param side int sign of the z coordinate of the cell - * @return double lowest eta value - */ - public double getEtaMin(int eta, int side) { - if (side < 0) { - return -getEtaMax(eta, -side); - } else { - return AParameterUtilities.eta((zMin+zMax)/2.f, rMax); - } - } - - /** - * Returns the highest eta value of a cell. - * @param eta int eta index of the cell - * @param side int sign of the z coordinate of the cell - * @return double highest eta value - */ - public double getEtaMax(int eta, int side) { - if (side < 0) { - return -getEtaMin(eta, -side); - } else { - return AParameterUtilities.eta((zMin+zMax)/2.f, rMin); - } - } - - /** - * Returns the rho-z geometry of the full calorimeter part. - * @return ACoord polygons representing geometry - */ - protected ACoord getRZUser() { - double[][][] hv; - if (zMin < 0) { - hv = new double[2][2][]; - hv[0][0] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][0] = new double[] { rMax, rMax, rMin, rMin}; - hv[0][1] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][1] = new double[] {-rMin, -rMin, -rMax, -rMax}; - } else { - hv = new double[2][4][]; - hv[0][0] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][0] = new double[] { rMax, rMax, rMin, rMin}; - hv[0][1] = new double[] { zMax, zMin, zMin, zMax}; - hv[1][1] = new double[] {-rMin, -rMin, -rMax, -rMax}; - hv[0][2] = new double[] {-zMin, -zMax, -zMax, -zMin}; - hv[1][2] = new double[] { rMax, rMax, rMin, rMin}; - hv[0][3] = new double[] {-zMin, -zMax, -zMax, -zMin}; - hv[1][3] = new double[] {-rMin, -rMin, -rMax, -rMax}; - } - return new ACoord(hv); - } - - /** - * Returns the rho-z geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @param side int sign of the z coordinate of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getRZCell(int eta, int phi, int side) { - double[][] hv = new double[2][]; - int sign = getRSign(phi); - - // This shouldn't be 0, but just to be on the safe side. - if (side != 0) { - side /= Math.abs(side); - } - - hv[0] = new double[] {zMax, zMin, zMin, zMax}; - hv[1] = new double[] {rMax, rMax, rMin, rMin}; - - // Send it to the right quadrant. - ACoord coord = new ACoord(hv); - for (int i=0; i<coord.hv[0][0].length; i++) { - coord.hv[0][0][i] *= side; - coord.hv[1][0][i] *= sign; - } - - return coord; - } - - /** - * Returns the eta-phi geometry of a specific cell in this calorimeter part. - * @param eta int eta index of cell - * @param phi int phi index of cell - * @param side int sign of the z coordinate of cell - * @return ACoord polygon representing cell geometry - */ - public ACoord getVPCell(int eta, int phi, int side) { - double[][] hv = new double[2][]; - double etaMin = AParameterUtilities.eta((zMin+zMax)/2.f, rMax); - double etaMax = AParameterUtilities.eta((zMin+zMax)/2.f, rMin); - double phiMin = Math.toDegrees(phi0 + phi*deltaPhi); - double phiMax = phiMin + Math.toDegrees(deltaPhi); - - side /= Math.abs(side); - - hv[0] = new double[] {side*etaMax, side*etaMin, side*etaMin, side*etaMax}; - hv[1] = new double[] { phiMax, phiMax, phiMin, phiMin}; - - return new ACoord(hv); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/AGeneralDetectors.java b/graphics/AtlantisJava/src/atlantis/geometry/AGeneralDetectors.java deleted file mode 100755 index bb939996da5013f63d3f8cd39cd9e77537274bde..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/AGeneralDetectors.java +++ /dev/null @@ -1,71 +0,0 @@ -package atlantis.geometry; - -import atlantis.parameters.APar; -import java.util.*; - -/** - * Used to store all detectors which are not part of the muon system - * these may be of different types. - */ - -public final class AGeneralDetectors extends ADetectors { - - public AGeneralDetectors(List detectors) { - super(filterGeneralDetectors(detectors)); - } - - private static ADetector[] filterGeneralDetectors(List detectors) { - - List tempDetectors=new ArrayList(detectors.size()); - Iterator it=detectors.iterator(); - - while(it.hasNext()) { - Object o=it.next(); - if((o instanceof ADetector)&&!(o instanceof ABoxDetector)&&!(o instanceof ATrapezoidDetector)) tempDetectors.add(o); - } - return (ADetector[])tempDetectors.toArray(new ADetector[tempDetectors.size()]); - } - - private void makeDrawListYX() { - int mode=parameterStore.get("YX", "Mode").getI(); - if(mode==0) { - int num=0; - for(int i=0; i<numData; ++i) - if(det[i].getName().indexOf("FCAL")<0) - listdl[num++]=i; - numDraw=num; - } - else if(mode>8) - { - int num=0; - for(int i=0; i<numData; ++i) - if((mode==9 && det[i].getName().equals("FCAL EM")) - ||(mode==10 && det[i].getName().equals("FCAL HAD 1")) - ||(mode==11 && det[i].getName().equals("FCAL HAD 2")) - ||(mode==12 && (det[i].getName().equals("LAr Endcap Presampler"))||det[i].getName().equals("LAr_EC_Presampler")) - ||(mode>=13 && mode<= 15 && (det[i].getName().equals("LAr Outer Endcap") || det[i].getName().equals("LAr Inner Endcap"))) - ||(mode>=16 && mode<= 19 && det[i].getName().equals("HEC")) - ||(parameterStore.get("YX", "DrawFCAL").getStatus() && mode==17 && det[i].getName().equals("FCAL EM")) - ||(parameterStore.get("YX", "DrawFCAL").getStatus() && mode==18 && det[i].getName().equals("FCAL HAD 1")) - ||(parameterStore.get("YX", "DrawFCAL").getStatus() && mode==19 && det[i].getName().equals("FCAL HAD 2")) - ||(mode==20 && (det[i].getName().indexOf("LAr")>=0 || det[i].getName().indexOf("Endcap")>=0 || det[i].getName().indexOf("EC")>=0)) - ||(mode==21 && det[i].getName().equals("HEC")) - ||(mode==22)&& det[i].getName().equals("Minimum Bias Trigger Scintillators")) - listdl[num++]=i; - numDraw=num; - } else - numDraw=0; - } - - protected void makeDrawList(String projection) { - if (projection.equals("YX") || projection.equals("FR")) - makeDrawListYX(); - else { - if(parameterStore.get(projection, "Mode").getI()==0) - constructDefaultDrawList(); - else - numDraw=0; - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/AGeometryFromXMLReader.java b/graphics/AtlantisJava/src/atlantis/geometry/AGeometryFromXMLReader.java deleted file mode 100755 index 8b7eb48bf4891a0fd4501d7e3692a9a5dc820338..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/AGeometryFromXMLReader.java +++ /dev/null @@ -1,286 +0,0 @@ -package atlantis.geometry; - -import java.io.InputStream; -import java.util.List; -import java.util.ArrayList; - -import atlantis.output.AExceptionHandler; -import atlantis.utils.xml.AXMLErrorHandler; -import atlantis.utils.AUtilities; -import org.xml.sax.helpers.*; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import org.xml.sax.Attributes; - - -class AGeometryFromXMLReader extends DefaultHandler { - - private static final boolean VALIDATION=false; - private SAXParser parser; - - private static List<ADetector> detectors; - - public AGeometryFromXMLReader() { - try { - SAXParserFactory factory=SAXParserFactory.newInstance(); - - factory.setValidating(true); - factory.setNamespaceAware(true); - parser=factory.newSAXParser(); - if(VALIDATION) - parser.getXMLReader().setErrorHandler(new AXMLErrorHandler()); - } catch(Exception e) { - AExceptionHandler.processException("Cannot create AGeometryFromXMLReader", e); - } - } - - protected List<ADetector> readDetectorGeometryFromXML(String fileName) - { - detectors = new ArrayList<ADetector>(2500); - try - { - InputStream isGeom = AUtilities.getFileAsStream(fileName); - parser.parse(isGeom, this); - } - catch(Exception e) - { - String msg = "Error when reading geometry file:\n" + e.getMessage(); - AExceptionHandler.processException(msg, e); - } - - return detectors; - } - - static private double calculatePhi(String name, double phi0, int phiIndex) { - String technology = name.substring(0, 3); - if (technology.equals("TGC")) { - if (name.charAt(6) == 'E' && name.charAt(5) != '4') - return Math.toRadians(phi0) + (phiIndex - 1) * Math.PI / 24.; - else - return Math.toRadians(phi0) + (phiIndex - 1) * Math.PI / 12.; - } else { - return Math.toRadians(phi0) + (phiIndex - 1) * Math.PI / 4.; - } - } - - // ContentHandler Implementation - - public void startElement(String namespaceURI, String localName, String qName, Attributes atts) { - if(localName.equals("ABox")||localName.equals("ATBx")) { - String name=atts.getValue("n"); - double zi=Double.parseDouble(atts.getValue("zi")); - double zo=Double.parseDouble(atts.getValue("zo")); - double ri=Double.parseDouble(atts.getValue("ri")); - double ro=Double.parseDouble(atts.getValue("ro")); - double w=Double.parseDouble(atts.getValue("w")); - double dPhi=Double.parseDouble(atts.getValue("dphi")); - double rpci=Double.parseDouble(atts.getValue("RPCi")); - double rpco=Double.parseDouble(atts.getValue("RPCo")); - double s=Double.parseDouble(atts.getValue("sh")); - int stationEta=Integer.parseInt(atts.getValue("eta")); - String[] phis=atts.getValue("phi").split(" "); - - if(localName.equals("ABox")) { - for(int i=0; i<phis.length; ++i) - for(int zSide=-1; zSide<=1; zSide+=2) { - int stationPhi = Integer.parseInt(phis[i]); - double phi = calculatePhi(name, dPhi, stationPhi); - detectors.add(new ABoxDetector(name, zSide*zi, zSide*zo, ri+rpci, ro-rpco, phi, s, w, - zSide*stationEta, stationPhi)); - if(rpci>0.) - detectors.add(new ABoxDetector("RPC"+name.substring(3)+"_I", zSide*zi, zSide*zo, ri, - ri+rpci, phi, s, w, zSide*stationEta, stationPhi)); - if(rpco>0.) - detectors.add(new ABoxDetector("RPC"+name.substring(3)+"_O", zSide*zi, zSide*zo, - ro-rpco, ro, phi, s, w, zSide*stationEta, stationPhi)); - } - } else if(localName.equals("ATBx")) { - double zis=Double.parseDouble(atts.getValue("zis")); - double zos=Double.parseDouble(atts.getValue("zos")); - double ws=Double.parseDouble(atts.getValue("ws")); - double or=Double.parseDouble(atts.getValue("or")); - for(int i=0; i<phis.length; ++i) - for(int zSide=-1; zSide<=1; zSide+=2) { - int stationPhi = Integer.parseInt(phis[i]); - double phi = calculatePhi(name, dPhi, stationPhi); - detectors.add(new ATBxDetector(name, zSide*zi, zSide*zo, ri+rpci, ro-rpco, phi, s, w, - zSide*zis, zSide*zos, ws, or, zSide*stationEta, stationPhi)); - if(rpci>0.) - detectors.add(new ATBxDetector("RPC"+name.substring(3)+"_I", zSide*zi, zSide*zo, ri, - ri+rpci, phi, s, w, zSide*zis, zSide*zos, ws, or, zSide*stationEta, stationPhi)); - if(rpco>0.) - detectors.add(new ATBxDetector("RPC"+name.substring(3)+"_O", zSide*zi, zSide*zo, - ro-rpco, ro, phi, s, w, zSide*zis, zSide*zos, ws, or, zSide*stationEta, stationPhi)); - } - } - - } else if(localName.equals("ATrd")) { - String name=atts.getValue("n"); - double zi=Double.parseDouble(atts.getValue("zi")); - double zo=Double.parseDouble(atts.getValue("zo")); - double ri=Double.parseDouble(atts.getValue("ri")); - double ro=Double.parseDouble(atts.getValue("ro")); - - double wi=Double.parseDouble(atts.getValue("wi")); - double wo=Double.parseDouble(atts.getValue("wo")); - double dPhi=Double.parseDouble(atts.getValue("dphi")); - double alpha=Double.parseDouble(atts.getValue("a")); - int stationEta=Integer.parseInt(atts.getValue("eta")); - String[] phis=atts.getValue("phi").split(" "); - - for(int i=0; i<phis.length; ++i) { - for(int zSide = -1; zSide <= 1; zSide += 2) { - int stationPhi = Integer.parseInt(phis[i]); - double phi = calculatePhi(name, dPhi, stationPhi); - detectors.add(new ATrapezoidDetector(name, zSide*zi, zSide*zo, ri, ro, phi, wi, wo, - alpha, zSide*stationEta, stationPhi)); - } - } - } else if(localName.equals("ABarrelCalorimeter")) { - String name = atts.getValue("n"); - String color = atts.getValue("c"); - int sampling = Integer.parseInt(atts.getValue("sampling")); - int region = Integer.parseInt(atts.getValue("region")); - double rMin = Double.parseDouble(atts.getValue("rMin")); - double rMax = Double.parseDouble(atts.getValue("rMax")); - double zMin = Double.parseDouble(atts.getValue("zMin")); - double zMax = Double.parseDouble(atts.getValue("zMax")); - double eta0 = Double.parseDouble(atts.getValue("eta0")); - double deta = Double.parseDouble(atts.getValue("deta")); - int neta = Integer.parseInt(atts.getValue("neta")); - int meta = Integer.parseInt(atts.getValue("meta")); - double phi0 = Double.parseDouble(atts.getValue("phi0")); - int nphi = Integer.parseInt(atts.getValue("nphi")); - detectors.add(new ABarrelCalorimeterDetector(name, color, sampling, region, rMin, rMax, - zMin, zMax, eta0, deta, neta, meta, phi0, nphi)); - } else if(localName.equals("AEndcapCalorimeter")) { - String name = atts.getValue("n"); - String color = atts.getValue("c"); - int sampling = Integer.parseInt(atts.getValue("sampling")); - int region = Integer.parseInt(atts.getValue("region")); - double rMin = Double.parseDouble(atts.getValue("rMin")); - double rMax = Double.parseDouble(atts.getValue("rMax")); - double zMin = Double.parseDouble(atts.getValue("zMin")); - double zMax = Double.parseDouble(atts.getValue("zMax")); - double eta0 = Double.parseDouble(atts.getValue("eta0")); - double deta = Double.parseDouble(atts.getValue("deta")); - int neta = Integer.parseInt(atts.getValue("neta")); - int meta = Integer.parseInt(atts.getValue("meta")); - double phi0 = Double.parseDouble(atts.getValue("phi0")); - int nphi = Integer.parseInt(atts.getValue("nphi")); - detectors.add(new AEndcapCalorimeterDetector(name, color, sampling, region, rMin, rMax, - zMin, zMax, eta0, deta, neta, meta, phi0, nphi)); - } else if(localName.equals("AEndcapCryostat")) { - String name = atts.getValue("n"); - String color = atts.getValue("c"); - int sampling = Integer.parseInt(atts.getValue("sampling")); - int region = Integer.parseInt(atts.getValue("region")); - double rMin = Double.parseDouble(atts.getValue("rMin")); - double rMax = Double.parseDouble(atts.getValue("rMax")); - double zMin = Double.parseDouble(atts.getValue("zMin")); - double zMax = Double.parseDouble(atts.getValue("zMax")); - int neta = Integer.parseInt(atts.getValue("neta")); - int nphi = Integer.parseInt(atts.getValue("nphi")); - detectors.add(new AEndcapCryostatDetector(name, color, sampling, region, rMin, rMax, zMin, - zMax, neta, nphi)); - } else if(localName.equals("AGapCalorimeter")) { - String name = atts.getValue("n"); - String color = atts.getValue("c"); - int sampling = Integer.parseInt(atts.getValue("sampling")); - int region = Integer.parseInt(atts.getValue("region")); - double rMin = Double.parseDouble(atts.getValue("rMin")); - double rMax = Double.parseDouble(atts.getValue("rMax")); - double zMin = Double.parseDouble(atts.getValue("zMin")); - double zMax = Double.parseDouble(atts.getValue("zMax")); - int eta = Integer.parseInt(atts.getValue("eta")); - double phi0 = Double.parseDouble(atts.getValue("phi0")); - int nphi = Integer.parseInt(atts.getValue("nphi")); - detectors.add(new AGapCalorimeterDetector(name, color, sampling, region, rMin, rMax, - zMin, zMax, eta, phi0, nphi)); - } else if(localName.equals("ABarrelSiliconDetector")) { - String name = atts.getValue("n"); - String color = atts.getValue("c"); - int layer = Integer.parseInt(atts.getValue("layer")); - double length = Double.parseDouble(atts.getValue("length")); - double width = Double.parseDouble(atts.getValue("width")); - double thickness = Double.parseDouble(atts.getValue("thickness")); - int nphi = Integer.parseInt(atts.getValue("nphi")); - int nz = Integer.parseInt(atts.getValue("nz")); - double tilt = Double.parseDouble(atts.getValue("tilt")); - double r0 = Double.parseDouble(atts.getValue("r0")); - double phi0 = Double.parseDouble(atts.getValue("phi0")); - double zMin = Double.parseDouble(atts.getValue("zMin")); - double zMax = Double.parseDouble(atts.getValue("zMax")); - detectors.add(new ABarrelSiliconDetector(name, color, layer, length, width, thickness, nz, - nphi, tilt, r0, phi0, zMin, zMax)); - } else if(localName.equals("AEndcapSiliconDetector")) { - String name = atts.getValue("n"); - String color = atts.getValue("c"); - int layer = Integer.parseInt(atts.getValue("layer")); - double length = Double.parseDouble(atts.getValue("length")); - double width = Double.parseDouble(atts.getValue("width")); - double thickness = Double.parseDouble(atts.getValue("thickness")); - int nphi = Integer.parseInt(atts.getValue("nphi")); - int nz = Integer.parseInt(atts.getValue("nz")); - double rMin = Double.parseDouble(atts.getValue("rMin")); - double rMax = Double.parseDouble(atts.getValue("rMax")); - double phi0 = Double.parseDouble(atts.getValue("phi0")); - double zMin = Double.parseDouble(atts.getValue("zMin")); - double zMax = Double.parseDouble(atts.getValue("zMax")); - detectors.add(new AEndcapSiliconDetector(name, color, layer, length, width, thickness, nz, - nphi, rMin, rMax, phi0, zMin, zMax)); - } else if(localName.equals("ABarrelTRTDetector")) { - String name = atts.getValue("n"); - String color = atts.getValue("c"); - int layer = Integer.parseInt(atts.getValue("layer")); - int nphi = Integer.parseInt(atts.getValue("nphi")); - double rMin = Double.parseDouble(atts.getValue("rMin")); - double rMax = Double.parseDouble(atts.getValue("rMax")); - double phiIn = Double.parseDouble(atts.getValue("phiIn")); - double phiOut = Double.parseDouble(atts.getValue("phiOut")); - double zMin = Double.parseDouble(atts.getValue("zMin")); - double zMax = Double.parseDouble(atts.getValue("zMax")); - detectors.add(new ABarrelTRTDetector(name, color, layer, nphi, rMin, rMax, phiIn, phiOut, zMin, zMax)); - } else if(localName.equals("AEndcapTRTDetector")) { - String name = atts.getValue("n"); - String color = atts.getValue("c"); - int layer = Integer.parseInt(atts.getValue("layer")); - int nphi = Integer.parseInt(atts.getValue("nphi")); - double rMin = Double.parseDouble(atts.getValue("rMin")); - double rMax = Double.parseDouble(atts.getValue("rMax")); - double phi0 = Double.parseDouble(atts.getValue("phi0")); - double zMin = Double.parseDouble(atts.getValue("zMin")); - double zMax = Double.parseDouble(atts.getValue("zMax")); - detectors.add(new AEndcapTRTDetector(name, color, layer, nphi, rMin, rMax, phi0, zMin, zMax)); - } else if(localName.equals("ADisc")) { - String name=atts.getValue("n"); - String projection=atts.getValue("p"); - String color=atts.getValue("c"); - double rInner=Double.parseDouble(atts.getValue("rIn")); - double rOuter=Double.parseDouble(atts.getValue("rOut")); - int nInner=Integer.parseInt(atts.getValue("nIn")); - int nOuter=Integer.parseInt(atts.getValue("nOut")); - - detectors.add(new ADiscDetector(name, projection, color, rInner, rOuter, nInner, nOuter)); - } else if(localName.equals("ARectangle")) { - String name=atts.getValue("n"); - String projection=atts.getValue("p"); - String color=atts.getValue("c"); - double xMin=Double.parseDouble(atts.getValue("xMin")); - double xMax=Double.parseDouble(atts.getValue("xMax")); - double yMin=Double.parseDouble(atts.getValue("yMin")); - double yMax=Double.parseDouble(atts.getValue("yMax")); - boolean xReflect=atts.getValue("xR").equals("YES"); - boolean yReflect=atts.getValue("yR").equals("YES"); - - detectors.add(new ARectangleDetector(name, projection, color, xMin, xMax, yMin, yMax)); - if(xReflect) detectors.add(new ARectangleDetector(name, projection, color, -xMin, -xMax, yMin, - yMax)); - if(yReflect) detectors.add(new ARectangleDetector(name, projection, color, xMin, xMax, -yMin, - -yMax)); - if(xReflect&&yReflect) detectors.add(new ARectangleDetector(name, projection, color, -xMin, - -xMax, -yMin, -yMax)); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ARectangleDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/ARectangleDetector.java deleted file mode 100755 index 3af8f2f9b901ad263996e5e419a585908317c19a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ARectangleDetector.java +++ /dev/null @@ -1,49 +0,0 @@ -package atlantis.geometry; - -import atlantis.graphics.ACoord; -import atlantis.utils.AMath; - -public class ARectangleDetector extends ADetector -{ - double xMin; - double xMax; - double yMin; - double yMax; - - ARectangleDetector(String name, String projection, String color, double xMin, double xMax, double yMin, double yMax) - { - super(name, projection, color); - this.xMin = xMin; - this.xMax = xMax; - this.yMin = yMin; - this.yMax = yMax; - } - - protected ACoord getRZUser() - { - return getUser("RZ"); - } - - protected ACoord getFZUser() - { - return getUser("FZ"); - } - - protected ACoord getXZUser() - { - return getUser("XZ"); - } - - protected ACoord getYZUser() - { - return getUser("YZ"); - } - - protected ACoord getUser(String proj) - { - if (!projection.equals(proj)) - return ACoord.NO_DATA; - return new ACoord(AMath.xBox((xMin + xMax) / 2., (xMax - xMin) / 2.), AMath.yBox((yMin + yMax) / 2., (yMax - yMin) / 2.)); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ATBxDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/ATBxDetector.java deleted file mode 100755 index e4c3dc8204e58032c93698c0e45022a15ea43c66..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ATBxDetector.java +++ /dev/null @@ -1,81 +0,0 @@ -package atlantis.geometry; - -import atlantis.graphics.ACoord; -import atlantis.utils.AMath; - -/** - * Special t shape Box used for MDT chambers near the feet. - * These are only different in th FZ projection - */ - -public class ATBxDetector extends ABoxDetector { - - double zis; - double zos; - double ws; - double or; - - public ATBxDetector(String name, double zMin, double zMax, double rMin, - double rMax, double phi, double excl, double size, double zis, double zos, - double ws, double or, int etaIndex, int phiIndex) { - super(name, zMin, zMax, rMin, rMax, phi, excl, size, etaIndex, phiIndex); - this.zis=zis; - this.zos=zos; - this.ws=ws; - this.or=or; - } - - protected ACoord getFZUser() { - double[][] hv=new double[2][8]; - double cosPhi=Math.cos(phi); - double sinPhi=Math.sin(phi); - double d=size/2.; - double r=rMin; - double x=r*cosPhi-excl*sinPhi; - double y=r*sinPhi+excl*cosPhi; - double dsinPhi=d*sinPhi; - double dcosPhi=d*cosPhi; - double phi1=Math.toDegrees(Math.atan2(y-dcosPhi, x+dsinPhi)); - double phi2=Math.toDegrees(Math.atan2(y+dcosPhi, x-dsinPhi)); - - if(phi1<0.) phi1+=360.; - if(phi2<0.) phi2+=360.; - if(phi1-phi2>180.) phi1-=360.; - if(phi2-phi1>180.) phi2-=360.; - double phiLower=Math.min(phi1, phi2); - double phiUpper=Math.max(phi1, phi2); - double phiMid=phiLower+ws/size*(phiUpper-phiLower); - hv[0][0]=zMin; - hv[0][1]=zMin; - hv[0][2]=zis; - hv[0][3]=zis; - hv[0][4]=zos; - hv[0][5]=zos; - hv[0][6]=zMax; - hv[0][7]=zMax; - if(or>90.) { - phiMid=phiLower+ws/size*(phiUpper-phiLower); - hv[1][0]=phiUpper; - hv[1][1]=phiMid; - hv[1][2]=phiMid; - hv[1][3]=phiLower; - hv[1][4]=phiLower; - hv[1][5]=phiMid; - hv[1][6]=phiMid; - hv[1][7]=phiUpper; - } else { - phiMid=phiUpper-ws/size*(phiUpper-phiLower); - hv[1][0]=phiLower; - hv[1][1]=phiMid; - hv[1][2]=phiMid; - hv[1][3]=phiUpper; - hv[1][4]=phiUpper; - hv[1][5]=phiMid; - hv[1][6]=phiMid; - hv[1][7]=phiLower; - } - - return new ACoord(hv); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ATrapezoidDetector.java b/graphics/AtlantisJava/src/atlantis/geometry/ATrapezoidDetector.java deleted file mode 100755 index 7850795a05c0e4cfa84775766b8f5d5d7a6296df..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ATrapezoidDetector.java +++ /dev/null @@ -1,211 +0,0 @@ -package atlantis.geometry; - - -import atlantis.utils.AMath; -import atlantis.parameters.*; -import atlantis.graphics.ACoord; - -/** - * In ATLAS Trapezoids are TGC and MDT in the endcap. - */ - -public class ATrapezoidDetector extends ADetector { - - double zMin; - double zMax; - double rMin; - double rMax; - double phi; - double sizeS; - double sizeL; - double alpha; - int stationEta; - int stationPhi; - int sector; - - public ATrapezoidDetector(String name, double zMin, double zMax, double rMin, - double rMax, double phi, double sizeS, double sizeL, - double alpha, int stationEta, int stationPhi) { - super(name, " ", name.substring(0, 3)); - this.zMin = zMin; - this.zMax = zMax; - this.rMin = rMin; - this.rMax = rMax; - this.phi = phi; - this.sizeS = sizeS; - this.sizeL = sizeL; - this.alpha = alpha; - this.stationEta = stationEta; - this.stationPhi = stationPhi; - this.sector = ( (int) ( (phi + Math.PI / 16) / (Math.PI / 8))) % 16; - } - - protected boolean equalsYX(ADetector o) { - if (o instanceof ATrapezoidDetector) { - ATrapezoidDetector that = (ATrapezoidDetector) o; - return this.rMin == that.rMin && - this.rMax == that.rMax && - this.phi == that.phi && - this.sizeS == that.sizeS && - this.sizeL == that.sizeL; - } else - return false; - } - - protected boolean equalsRZ(ADetector o) { - if (o instanceof ATrapezoidDetector) { - ATrapezoidDetector that = (ATrapezoidDetector) o; - return this.rMin == that.rMin && - this.rMax == that.rMax && - this.zMin == that.zMin && - this.zMax == that.zMax && - this.alpha == that.alpha; - } - else - return false; - } - - protected ACoord getRZUser() { - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(phi - phiMid); - double sign = -1.; - if (phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) - sign = +1.; - return getXZRZUser(sign); - } - - protected ACoord getXZUser() { - AParameter p=parameterStore.get("XZ", "Phi"); - - // display muon data when phi is in the middle of a sector - if(p.getD() % 22.5 < 1e-2) { - int sect=(int)Math.round((p.getD() % 360.) / 22.5); - if (sector == sect) { - return getXZRZUser(1.); - } - else if (sector == sect - 8 || sector == sect + 8) { - return getXZRZUser( -1.); - } - } - return ACoord.NO_DATA; - } - - protected ACoord getXZRZUser(double sign) { - if (alpha == 0.) { - return new ACoord( - AMath.xBox( (zMin + zMax) / 2., (zMax - zMin) / 2.), - AMath.yBox(sign * (rMin + rMax) / 2., sign * (rMax - rMin) / 2.)); - } - else { - double[][] hv = new double[2][]; - double zMid = (zMin + zMax) / 2.; - double rMid = (rMin + rMax) / 2.; - double dRho = (rMax - rMin) / 2; - double dZ = (zMax - zMin) / 2; - double sinAlpha = Math.sin(Math.toRadians(alpha)); - double cosAlpha = Math.cos(Math.toRadians(alpha)); - - if (zMid * rMid > 0.) - sinAlpha *= -1.; - - hv[0] = new double[] { - zMid - sinAlpha * dRho - cosAlpha * dZ, - zMid - sinAlpha * dRho + cosAlpha * dZ, - zMid + sinAlpha * dRho + cosAlpha * dZ, - zMid + sinAlpha * dRho - cosAlpha * dZ}; - hv[1] = new double[] { - sign * (rMid + cosAlpha * dRho - sinAlpha * dZ), - sign * (rMid + cosAlpha * dRho + sinAlpha * dZ), - sign * (rMid - cosAlpha * dRho + sinAlpha * dZ), - sign * (rMid - cosAlpha * dRho - sinAlpha * dZ)}; - return new ACoord(hv); - } - } - - protected ACoord getFZUser() { - double deltaPhi = Math.max(Math.atan2(sizeL / 2., rMax), - Math.atan2(sizeS / 2., rMin)); - - if (alpha == 0.) { - return new ACoord( - AMath.xBox( (zMin + zMax) / 2., (zMax - zMin) / 2.), - AMath.yBox( Math.toDegrees(phi), Math.toDegrees(deltaPhi) )); - } - else { - double[][] hv = new double[2][]; - double zMid = (zMin + zMax) / 2.; - double rMid = (rMin + rMax) / 2.; - double dRho = (rMax - rMin) / 2; - double dZ = (zMax - zMin) / 2; - double sinAlpha = Math.sin(Math.toRadians(alpha)); - double cosAlpha = Math.cos(Math.toRadians(alpha)); - - if (zMid * rMid > 0.) - sinAlpha *= -1.; - - hv[0] = new double[] { - zMid - sinAlpha * dRho - cosAlpha * dZ, - zMid - sinAlpha * dRho - cosAlpha * dZ, - zMid + sinAlpha * dRho + cosAlpha * dZ, - zMid + sinAlpha * dRho + cosAlpha * dZ}; - hv[1] = new double[] { - Math.toDegrees(phi - deltaPhi), - Math.toDegrees(phi + deltaPhi), - Math.toDegrees(phi + deltaPhi), - Math.toDegrees(phi - deltaPhi)}; - return new ACoord(hv); - } - } - - protected ACoord getYXUser() { - return getYXUser(0); - } - - protected ACoord getFRUser() { - return convertYXToFR(getYXUser(1)); - } - - private ACoord getYXUser(int flag) { - int[] split= {12, 1, 12, 1}; - int numPoints=4; - boolean splitIt=parameterStore.get("YX", "FishEye").getStatus()||parameterStore.get("YX", "Clock").getStatus() - ||flag==1; - - if(splitIt) - numPoints=26; - double[] temp=new double[4]; - double[][] hv=new double[2][numPoints]; - double cosPhi=Math.cos(phi); - double sinPhi=Math.sin(phi); - double d=sizeS/2.; - double r=rMin; - double x=r*cosPhi; - double y=r*sinPhi; - double dx=d*sinPhi; - double dy=d*cosPhi; - - hv[0][0]=x+dx; - hv[1][0]=y-dy; - hv[0][1]=x-dx; - hv[1][1]=y+dy; - r=rMax; - x=r*cosPhi; - y=r*sinPhi; - d=sizeL/2.; - dx=d*sinPhi; - dy=d*cosPhi; - - hv[0][3]=x+dx; - hv[1][3]=y-dy; - hv[0][2]=x-dx; - hv[1][2]=y+dy; - if(splitIt) - for(int j=0; j<2; ++j) { - for(int k=0; k<4; ++k) - temp[k]=hv[j][k]; - AMath.splitArrayIntoPieces(temp, hv[j], split); - } - return new ACoord(hv); - } -} - diff --git a/graphics/AtlantisJava/src/atlantis/geometry/ATrapezoidDetectors.java b/graphics/AtlantisJava/src/atlantis/geometry/ATrapezoidDetectors.java deleted file mode 100755 index 943c34722fa6ea73c4f65b3f3ead298d0b8ab574..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/ATrapezoidDetectors.java +++ /dev/null @@ -1,163 +0,0 @@ -package atlantis.geometry; - -// not quite correct for CSC (alpha!=0.) in YX and FR - -import atlantis.parameters.AParameter; -import atlantis.parameters.APar; -import atlantis.utils.AMath; -import java.util.*; - -/** - * see comments in ABoxDetectors - */ - -public final class ATrapezoidDetectors extends ADetectors { - - private int numRZTypes; - private int[] typeRZ; - private int numYXTypes; - private int[] typeYX; - - private ATrapezoidDetector[] trapezoid; - - public ATrapezoidDetectors(List detectors) { - super(filterTrapezoidDetectors(detectors)); - trapezoid= new ATrapezoidDetector[det.length]; - for(int i=0;i<trapezoid.length;++i) - trapezoid[i]=(ATrapezoidDetector)det[i]; - - - typeYX=new int[numData]; - for(int i=0; i<numData; ++i) - typeYX[i]=-1; - - numYXTypes=0; - for(int i=0; i<numData; ++i) - if(typeYX[i]==-1) { - typeYX[i]=numYXTypes; - for(int j=i+1; j<numData; ++j) - if(typeYX[j]==-1&&det[i].equalsYX(det[j])) - typeYX[j]=numYXTypes; - numYXTypes++; - } - - typeRZ=new int[numData]; - for(int i=0; i<numData; ++i) - typeRZ[i]=-1; - - numRZTypes=0; - for(int i=0; i<numData; ++i) - if(typeRZ[i]==-1) { - typeRZ[i]=numRZTypes; - for(int j=i+1; j<numData; ++j) - if(typeRZ[j]==-1&&det[i].equalsRZ(det[j])) - typeRZ[j]=numRZTypes; - numRZTypes++; - } - } - - private static ADetector[] filterTrapezoidDetectors(List detectors) { - - List tempDetectors=new ArrayList(detectors.size()); - Iterator it=detectors.iterator(); - - while(it.hasNext()) { - Object o=it.next(); - if(o instanceof ATrapezoidDetector) tempDetectors.add(o); - } - return (ADetector[])tempDetectors.toArray(new ADetector[tempDetectors.size()]); - } - - private void makeDrawListYX() { - int mode=parameterStore.get("YX", "Mode").getI(); - - if(mode==0) - numDraw=0; - else { - int num=0; - for(int i=0; i<numData; ++i) { - double z=trapezoid[i].zMin; - String name=det[i].getName().substring(4, 6); - if(z>0.) - if((mode==1&&name.equals("T4"))||(mode==2&&name.equals("T1")) - ||(mode==3&&name.equals("T2"))||(mode==4&&name.equals("T3")) - ||(mode==5&&(name.equals("EI")||name.equals("CS")))||(mode==6&&name.equals("EE")) - ||(mode==7&&name.equals("EM"))||(mode==8&&name.equals("EO"))) - listdl[num++]=i; - numDraw=num; - } - } - } - - private void makeDrawListXZ() { - AParameter p=parameterStore.get("XZ", "Phi"); - - // display muon data when phi is in the middle of a sector - if(p.getD() % 22.5 < 1e-2) { - int sect=(int)Math.round((p.getD() % 360.) / 22.5); - int num=0; - for(int i=0; i<numData; i++) { - int s=trapezoid[i].sector; - - if(s==sect||s==sect-8||s==sect+8) { - listdl[num++]=i; - } - } - numDraw=num; - } else { - numDraw=0; - } - } - - private void makeDrawListRZ() { - // first make the draw list - // for each type find out if it has both +ve and negative sign - int[] pos=new int[typeRZ.length]; - int[] neg=new int[typeRZ.length]; - double phiMid=Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - - for(int i=0; i<numRZTypes; ++i) - neg[i]=pos[i]=-1; - - for(int i=0; i<numData; ++i) { - double phiDiff=Math.abs(trapezoid[i].phi-phiMid); - - if(phiDiff<Math.PI/2.||phiDiff>3*Math.PI/2.) - pos[typeRZ[i]]=i; - else - neg[typeRZ[i]]=i; - } - - int num=0; - for(int i=0; i<numRZTypes; ++i) { - if(pos[i]!=-1) - listdl[num++]=pos[i]; - if(neg[i]!=-1) - listdl[num++]=neg[i]; - } - numDraw=num; - } - - private void makeDrawListFZ() { - if(parameterStore.get("FZ", "Mode").getI()==0) { - constructDefaultDrawList(); - } else { - numDraw=0; - } - } - - protected void makeDrawList(String projection) { - if (projection.equals("YX") || projection.equals("FR") ) - makeDrawListYX(); - else if (projection.equals("FZ")) - makeDrawListFZ(); - else if (projection.equals("RZ")) - makeDrawListRZ(); - else if (projection.equals("XZ")) - makeDrawListXZ(); - else - numDraw=0; - } - -} - diff --git a/graphics/AtlantisJava/src/atlantis/geometry/package.html b/graphics/AtlantisJava/src/atlantis/geometry/package.html deleted file mode 100644 index 8c66987e1f11e98c22a2e5ac0188377c515be57d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/geometry/package.html +++ /dev/null @@ -1,8 +0,0 @@ -<html> -<head></head> -<body> -<p>Classes handling the detector description - ADetectorSystem -contains the information used to draw detector components on the -screen.</p> -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/globals/AGlobals.java b/graphics/AtlantisJava/src/atlantis/globals/AGlobals.java deleted file mode 100644 index ce6bce2447e285bd0d72daf92093fe9ec8b8402a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/globals/AGlobals.java +++ /dev/null @@ -1,202 +0,0 @@ -/** - * - */ -package atlantis.globals; - -import java.awt.Frame; -import java.awt.GraphicsEnvironment; - - -/** - * Provides access to Atlantis global variables in a slightly less bad way than - * using the main atlantis.Atlantis class. - * - * @author waugh - * - */ -public class AGlobals { - /** The singleton instance. No point in lazy instantiation. */ - private static AGlobals globals = new AGlobals(); - - /** Get the singleton instance */ - public static AGlobals instance() {return globals;} - - /** Prevent instantiation except through singleton accessor. */ - private AGlobals() {} - - /** Normally the directory that Atlantis was loaded from. */ - private String homeDirectory; - - /** The version of AtlantisJava from Svn. */ - private String version; - - /** Flag for displaying HLTAutoKey data. */ - private boolean showHLTAutoKeys = false; - - /** Flag for using simple output, used by Minerva. */ - private int SIMPLE_OUTPUT = 0; - - /** This is the URL that is used as default for "Read events from URL". */ - private String LIVE_POINT_1_EVENTS_URL; - - /** The path to the user's configuration file. */ - private String userConfigFile; - - /** Whether to use OpenGL. */ - private boolean useOpenGL; - - /** Whether we are in demo mode. */ - private boolean demoMode; - - /** Component representing the GUI, if any. */ - private Frame guiFrame; - - /** - * Set the Atlantis home directory, normally the directory that Atlantis was loaded from. - * - * @param homeDirectory the Atlantis home directory - */ - public void setHomeDirectory(String homeDirectory) { - this.homeDirectory = homeDirectory; - } - - /** - * Get the Atlantis home directory, normally the directory that Atlantis was loaded from. - * - * @return the Atlantis home directory - */ - public String getHomeDirectory() { - return homeDirectory; - } - - /** - * Get AtlantisJava version. - * @return the Svn version, set in Atlantis.main() - */ - public String getVersion() { - return version; - } - - /** - * Set AtlantisJava version, called from Atlantis.main(). - * @param version the version to set - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * Whether to show data with storeGateKey containing "HLTAutoKey". - * - * @return true to show, false to ignore - */ - public boolean showHLTAutoKeys() { - return showHLTAutoKeys; - } - - /** - * Whether to show data with storeGateKey containing "HLTAutoKey". - * - * @param showHLTAutoKeys true to show, false to ignore - */ - public void setHLTAutoKeys(boolean showHLTAutoKeys) { - this.showHLTAutoKeys = showHLTAutoKeys; - } - - /** - * @return the sIMPLE_OUTPUT - */ - public int getSimpleOutput() { - return SIMPLE_OUTPUT; - } - - /** - * @param sIMPLE_OUTPUT the sIMPLE_OUTPUT to set - */ - public void setSimpleOutput(int sIMPLE_OUTPUT) { - SIMPLE_OUTPUT = sIMPLE_OUTPUT; - } - - /** - * @return the URL for the Point 1 live events server - */ - public String getLivePoint1EventsURL() { - return LIVE_POINT_1_EVENTS_URL; - } - - /** - * @param livePoint1EventsURL the URL for the Point 1 live events server - */ - public void setLivePoint1EventsURL(String livePoint1EventsURL) { - LIVE_POINT_1_EVENTS_URL = livePoint1EventsURL; - } - - /** - * @param userConfigFilePath the path to the user's configuration file - */ - public void setUserConfigFile(String userConfigFilePath) { - this.userConfigFile = userConfigFilePath; - } - - /** - * @return the path to the user's configuration file - */ - public String getUserConfigFile() { - return this.userConfigFile; - } - - /** - * @return true if we should be using OpenGL - */ - public boolean getUseOpenGL() { - return useOpenGL; - } - - /** - * @param useOpenGL true to use OpenGL, false otherwise - */ - public void setUseOpenGL(boolean useOpenGL) { - this.useOpenGL = useOpenGL; - } - - /** - * Check whether we are in headless mode - * @return true if headless (no graphics available) - */ - public static boolean isAtlantisHeadless() { - return GraphicsEnvironment.isHeadless(); - } - - /** - * Whether the demo mode loop is running. - * @return true if in demo mode - */ - public boolean isDemoMode() { - return demoMode; - } - - /** - * Signal whether the demo loop is running. - * @param demoMode true when starting loop, false when stopping - */ - public void setDemoMode(boolean demoMode) { - this.demoMode = demoMode; - } - - /** - * For use as parent of dialogues, avoiding dependency on AGUI class itself. - * @return the GUI frame - */ - public Frame getGuiFrame() { - return guiFrame; - } - - /** - * Set the GUI frame, called from AGUI when the instance is created. - * @param guiFrame the GUI frame - */ - public void setGuiFrame(Frame guiFrame) { - this.guiFrame = guiFrame; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/globals/package.html b/graphics/AtlantisJava/src/atlantis/globals/package.html deleted file mode 100644 index e763965d1afb43aaddc28398c98d1edf8af58d7c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/globals/package.html +++ /dev/null @@ -1,13 +0,0 @@ -<html> -<head></head> -<body> -<p>Provides access to Atlantis global variables.</p> -<p>This has been introduced as part of a process of breaking unwanted - dependencies between packages. This package can contain any required - global state so that other packages (atlantis.data etc.) do not need - to depend on the "atlantis" package that contains the main Atlantis - class, and which unavoidably depends on the rest of the - packages.</p> -<p>With luck this will prove not to be necessary in the long term!</p> -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/graphics/AAbstractGraphics2D.java b/graphics/AtlantisJava/src/atlantis/graphics/AAbstractGraphics2D.java deleted file mode 100755 index ddfeba3edb9c0ba8c12dd4caf7c7919b1c213db3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/AAbstractGraphics2D.java +++ /dev/null @@ -1,315 +0,0 @@ -package atlantis.graphics; - -import java.awt.*; -import java.awt.font.*; -import java.awt.geom.*; -import java.awt.image.*; -import java.awt.image.renderable.*; - -/** - * This graphics is used when nothing should really be drawn on the screen - */ - -public abstract class AAbstractGraphics2D extends Graphics2D { - - public void transform(AffineTransform z) { - if(true) throw new RuntimeException(); - } - - public void fill(Shape z) { - if(true) throw new RuntimeException(); - } - - public void draw(Shape z) { - if(true) throw new RuntimeException(); - } - - public void drawImage(BufferedImage a, BufferedImageOp b, int c, int z) { - if(true) throw new RuntimeException(); - } - - public boolean drawImage(Image a, AffineTransform b, ImageObserver z) { - if(true) throw new RuntimeException(); - return false; - } - - public void drawRenderedImage(RenderedImage a, AffineTransform z) { - if(true) throw new RuntimeException(); - } - - public void drawRenderableImage(RenderableImage a, AffineTransform z) { - if(true) throw new RuntimeException(); - } - - public void drawString(java.text.AttributedCharacterIterator a, float b, float z) { - if(true) throw new RuntimeException(); - } - - public void drawString(String a, int b, int z) { - if(true) throw new RuntimeException(); - } - - public void drawString(String a, float b, float z) { - if(true) throw new RuntimeException(); - } - - public void drawString(java.text.AttributedCharacterIterator a, int b, int z) { - if(true) throw new RuntimeException(); - } - - public void drawGlyphVector(GlyphVector a, float b, float z) { - if(true) throw new RuntimeException(); - } - - public boolean hit(Rectangle a, Shape b, boolean z) { - if(true) throw new RuntimeException(); - return false; - } - - public GraphicsConfiguration getDeviceConfiguration() { - if(true) throw new RuntimeException(); - return null; - } - - public void setComposite(Composite z) { - if(true) throw new RuntimeException(); - } - - public void setPaint(Paint z) { - if(true) throw new RuntimeException(); - } - - public void setStroke(Stroke z) { - if(true) throw new RuntimeException(); - } - - public void setRenderingHint(RenderingHints.Key a, Object z) { - if(true) throw new RuntimeException(); - } - - public Object getRenderingHint(RenderingHints.Key z) { - if(true) throw new RuntimeException(); - return null; - } - - public void setRenderingHints(java.util.Map z) { - if(true) throw new RuntimeException(); - } - - public void addRenderingHints(java.util.Map z) { - if(true) throw new RuntimeException(); - } - - public RenderingHints getRenderingHints() { - if(true) throw new RuntimeException(); - return null; - } - - public void translate(double a, double z) { - if(true) throw new RuntimeException(); - } - - public void translate(int a, int z) { - if(true) throw new RuntimeException(); - } - - public void rotate(double a, double b, double z) { - if(true) throw new RuntimeException(); - } - - public void rotate(double z) { - if(true) throw new RuntimeException(); - } - - public void scale(double a, double z) { - if(true) throw new RuntimeException(); - } - - public void shear(double a, double z) { - if(true) throw new RuntimeException(); - } - - public void setTransform(AffineTransform z) { - if(true) throw new RuntimeException(); - } - - public AffineTransform getTransform() { - if(true) throw new RuntimeException(); - return null; - } - - public Paint getPaint() { - if(true) throw new RuntimeException(); - return null; - } - - public Composite getComposite() { - if(true) throw new RuntimeException(); - return null; - } - - public void setBackground(Color z) { - if(true) throw new RuntimeException(); - } - - public Color getBackground() { - if(true) throw new RuntimeException(); - return null; - } - - public Stroke getStroke() { - if(true) throw new RuntimeException(); - return null; - } - - public void clip(Shape z) { - if(true) throw new RuntimeException(); - } - - public FontRenderContext getFontRenderContext() { - if(true) throw new RuntimeException(); - return null; - } - - public void setColor(Color z) { - if(true) throw new RuntimeException(); - } - - public Graphics create() { - if(true) throw new RuntimeException(); - return null; - } - - public boolean drawImage(Image a, int b, int c, int d, int e, int f, int g, int h, int i, ImageObserver z) { - if(true) throw new RuntimeException(); - return false; - } - - public boolean drawImage(Image a, int b, int c, ImageObserver z) { - if(true) throw new RuntimeException(); - return false; - } - - public boolean drawImage(Image a, int b, int c, Color d, ImageObserver z) { - if(true) throw new RuntimeException(); - return false; - } - - public boolean drawImage(Image a, int b, int c, int d, int e, Color f, ImageObserver z) { - if(true) throw new RuntimeException(); - return false; - } - - public boolean drawImage(Image a, int b, int c, int d, int e, ImageObserver z) { - if(true) throw new RuntimeException(); - return false; - } - - public boolean drawImage(Image a, int b, int c, int d, int e, int f, int g, int h, int i, Color j, ImageObserver z) { - if(true) throw new RuntimeException(); - return false; - } - - public Color getColor() { - if(true) throw new RuntimeException(); - return null; - } - - public void fillRect(int a, int b, int c, int z) { - if(true) throw new RuntimeException(); - } - - public void setPaintMode() { - if(true) throw new RuntimeException(); - } - - public void setXORMode(Color z) { - if(true) throw new RuntimeException(); - } - - public Font getFont() { - if(true) throw new RuntimeException(); - return null; - } - - public void setFont(Font z) { - if(true) throw new RuntimeException(); - } - - public FontMetrics getFontMetrics(Font z) { - if(true) throw new RuntimeException(); - return null; - } - - public Rectangle getClipBounds() { - if(true) throw new RuntimeException(); - return null; - } - - public void clipRect(int a, int b, int c, int z) { - if(true) throw new RuntimeException(); - } - - public void setClip(int a, int b, int c, int z) { - if(true) throw new RuntimeException(); - } - - public void setClip(Shape z) { - if(true) throw new RuntimeException(); - } - - public Shape getClip() { - if(true) throw new RuntimeException(); - return null; - } - - public void copyArea(int a, int b, int c, int d, int e, int z) { - if(true) throw new RuntimeException(); - } - - // public void drawLine(int a,int b,int c,int z) { if (true) throw new RuntimeException(); } - public void clearRect(int a, int b, int c, int z) { - if(true) throw new RuntimeException(); - } - - public void drawRoundRect(int a, int b, int c, int d, int e, int z) { - if(true) throw new RuntimeException(); - } - - public void fillRoundRect(int a, int b, int c, int d, int e, int z) { - if(true) throw new RuntimeException(); - } - - public void drawOval(int a, int b, int c, int z) { - if(true) throw new RuntimeException(); - } - - public void fillOval(int a, int b, int c, int z) { - if(true) throw new RuntimeException(); - } - - public void drawArc(int a, int b, int c, int d, int e, int z) { - if(true) throw new RuntimeException(); - } - - public void fillArc(int a, int b, int c, int d, int e, int z) { - if(true) throw new RuntimeException(); - } - - public void drawPolyline(int[] a, int[] b, int z) { - if(true) throw new RuntimeException(); - } - - public void drawPolygon(int[] a, int[] b, int z) { - if(true) throw new RuntimeException(); - } - - public void fillPolygon(int[] a, int[] b, int z) { - if(true) throw new RuntimeException(); - } - - public void dispose() { - if(true) throw new RuntimeException(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/AClipper.java b/graphics/AtlantisJava/src/atlantis/graphics/AClipper.java deleted file mode 100755 index c525102c7021f33142f198b5800391a768b9ef5f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/AClipper.java +++ /dev/null @@ -1,226 +0,0 @@ -package atlantis.graphics; - -import atlantis.utils.AClipPolygon; -import atlantis.utils.APolygon; -import java.awt.Rectangle; - - -/** - * Implement uniform treatment of Clipping for screen, - * postscript and picking. - */ - -public class AClipper { - double[] upper; - double[] lower; - double[][] x; - boolean[][] below; - boolean[][] within; - boolean[][] above; - double hLower; - double hUpper; - double vLower; - double vUpper; - - public static final int NONE_WITHIN=0; - public static final int MAYBE_WITHIN=1; - public static final int ALL_WITHIN=2; - - public AClipper(double hLower, double hUpper, double vLower, double vUpper) { - - x=new double[2][2]; - upper=new double[2]; - lower=new double[2]; - below=new boolean[2][2]; - within=new boolean[2][2]; - above=new boolean[2][2]; - upper[0]=hUpper; - upper[1]=vUpper; - lower[0]=hLower; - lower[1]=vLower; - this.hUpper=hUpper; - this.hLower=hLower; - this.vUpper=vUpper; - this.vLower=vLower; - } - - public AClipper(Rectangle clipBounds) { - this(clipBounds.getX(), clipBounds.getX()+clipBounds.getWidth(), clipBounds.getY(), - clipBounds.getY()+clipBounds.getHeight()); - } - - public boolean isPointWithin(double h0, double v0) { - return hLower<=h0&&h0<=hUpper&&vLower<=v0&&v0<=vUpper; - } - - public boolean isLineWithin(double h0, double v0, double h1, double v1) { - int roughCheck=fastWithin(h0, v0, h1, v1); - - if(roughCheck==0) return false; - x[0][0]=h0; - x[1][0]=v0; - x[0][1]=h1; - x[1][1]=v1; - if(roughCheck==2) return true; - - update(0); - update(1); - - outer: - while(!lineFullyInside()) { - if(lineFullyOutside()) return false; - - for(int i=0; i<2; i++) - for(int point=0; point<2; point++) { - if(!within[i][point]) { - if(below[i][point]) { - x[1-i][point]+=((x[1-i][1-point]-x[1-i][point])/(x[i][1-point]-x[i][point])) - *(lower[i]-x[i][point]); - x[i][point]=lower[i]; - } else if(above[i][point]) { - x[1-i][point]+=((x[1-i][1-point]-x[1-i][point])/(x[i][1-point]-x[i][point])) - *(upper[i]-x[i][point]); - x[i][point]=upper[i]; - } - update(point); - continue outer; - } - } - } - // don't allow non-zero length line to be given zero length - // by th clipper - if((x[0][0]==x[0][1])&&(x[1][0]==x[1][1])) - return false; - return true; - } - - private void update(int p) { - for(int i=0; i<2; i++) { - below[i][p]=false; - within[i][p]=false; - above[i][p]=false; - if(x[i][p]<lower[i]) - below[i][p]=true; - else if(x[i][p]>upper[i]) - above[i][p]=true; - else - within[i][p]=true; - } - } - - public boolean lineFullyInside() { - boolean inside=true; - - for(int i=0; i<2; i++) - for(int j=0; j<2; j++) - inside=inside&&within[i][j]; - return inside; - } - - public boolean lineFullyOutside() { - boolean outside=false; - - for(int i=0; i<2; i++) { - outside=outside||(below[i][0]&&below[i][1]); - outside=outside||(above[i][0]&&above[i][1]); - } - return outside; - } - - public double[][] getHV() { - return x; - } - - public double getH0() { - return x[0][0]; - } - - public double getV0() { - return x[1][0]; - } - - public double getH1() { - return x[0][1]; - } - - public double getV1() { - return x[1][1]; - } - - public int fastWithin(double h0, double v0, double h1, double v1) { - if(h0<hLower&&h1<hLower) return NONE_WITHIN; - if(h0>hUpper&&h1>hUpper) return NONE_WITHIN; - if(v0<vLower&&v1<vLower) return NONE_WITHIN; - if(v0>vUpper&&v1>vUpper) return NONE_WITHIN; - if(hLower<=h0&&h0<=hUpper&&hLower<=h1&&h1<=hUpper&&vLower<=v0&&v0<=vUpper&&vLower<=v1 - &&v1<=vUpper) return ALL_WITHIN; - return MAYBE_WITHIN; - } - - public int fastWithin(double[] h, double[] v, int numPoints) { - if(numPoints==0) return NONE_WITHIN; - boolean firstWithin=hLower<=h[0]&&h[0]<=hUpper&&vLower<=v[0]&&v[0]<=vUpper; - - if(firstWithin) { - for(int i=1; i<numPoints; ++i) - if(!(hLower<=h[i]&&h[i]<=hUpper&&vLower<=v[i]&&v[i]<=vUpper)) return MAYBE_WITHIN; - return ALL_WITHIN; - } else { - if(h[0]<hLower) { - int num=1; - - for(int i=1; i<numPoints; ++i) - if(h[i]<hLower) - num++; - else - break; - if(num==numPoints) return NONE_WITHIN; - } - if(h[0]>hUpper) { - int num=1; - - for(int i=1; i<numPoints; ++i) - if(h[i]>hUpper) - num++; - else - break; - if(num==numPoints) return NONE_WITHIN; - } - if(v[0]<vLower) { - int num=1; - - for(int i=1; i<numPoints; ++i) - if(v[i]<vLower) - num++; - else - break; - if(num==numPoints) return NONE_WITHIN; - } - if(v[0]>vUpper) { - int num=1; - - for(int i=1; i<numPoints; ++i) - if(v[i]>vUpper) - num++; - else - break; - if(num==numPoints) return NONE_WITHIN; - } - return MAYBE_WITHIN; - } - } - - public ACoord clipPolygon(double[] h, double[] v, int numPoints) { - double[] clipH=new double[] { lower[0], upper[0], upper[0], lower[0] }; - double[] clipV=new double[] { lower[1], lower[1], upper[1], upper[1] }; - AClipPolygon clipArea=new AClipPolygon(clipH, clipV); - APolygon badPolygon=new APolygon(h, v); - - badPolygon.clip(clipArea); - h=badPolygon.getX(); - v=badPolygon.getY(); - return new ACoord(h, v); - } - -} - diff --git a/graphics/AtlantisJava/src/atlantis/graphics/ACoord.java b/graphics/AtlantisJava/src/atlantis/graphics/ACoord.java deleted file mode 100755 index 71aa2156379203e4df32bd188cd9f70c17abe275..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/ACoord.java +++ /dev/null @@ -1,355 +0,0 @@ -package atlantis.graphics; - -import atlantis.parameters.APar; -import atlantis.utils.*; - -/** - * Used to store a collection of User or display 2D coordinates of hits or tracks - * together with their indices in the corresponding AData - * (used for picking, colors etc.). N.B. the storage model is different for - * SYMBOLS/LINES(with two end points) than for POLYLINES/POLYGONS for - * efficiency reasons. Transformations between user/display coordinaates are based - * on ACoords. - */ -public class ACoord { - - private static ALogger logger = ALogger.getLogger(ACoord.class); - - public double[][][] hv; - public int[] index; - protected int type=POLYGONS; - public ADrawable source; - - final static public int SYMBOLS=1; - final static public int LINES=2; - final static public int POLYLINES=3; - final static public int POLYGONS=4; - final static public int DOTTED_POLYGONS=5; // for drawing missing ET in V-Plot - final static public int SMOOTH_POLYLINES=6; - final static public int TRANSPARENT_POLYGONS=7; - - final static public ACoord NO_DATA=new ACoord(new double[2][0][0], new int[0]); - final static public ACoord NO_POLYGONS=new ACoord(new double[2][0][0], new int[0]); - final static public ACoord NO_POLYLINES=new ACoord(new double[2][0][0], new int[0]); - final static public ACoord[] NO_HISTOGRAMS=new ACoord[0]; - - protected static APar parameterStore = APar.instance(); - - public ACoord(double h, double v, int index) { - this(h, v); - this.index=new int[] {index}; - } - - public ACoord(double h, double v) { - this.hv=new double[2][1][1]; - this.hv[0][0][0]=h; - this.hv[1][0][0]=v; - this.index=null; - this.type=SYMBOLS; - } - - public ACoord(double[] h, double[] v) { - this.hv=new double[2][1][]; - this.hv[0][0]=h; - this.hv[1][0]=v; - this.index=new int[] {0}; - } - - private ACoord(double[][] hv, int[] index) { - if(hv.length!=2) throw new IllegalArgumentException("hv.length="+hv.length); - this.hv = new double[2][1][0]; - this.hv[0][0]=hv[0]; - this.hv[1][0]=hv[1]; - this.index=index; - } - - private ACoord(double[][] hv, int[] index, ADrawable source) { - this(hv, index); - this.source=source; - } - - public ACoord(double[][] hv) { - if(hv.length!=2) throw new IllegalArgumentException("hv.length="+hv.length); - this.hv = new double[2][1][]; - this.hv[0][0]=hv[0]; - this.hv[1][0]=hv[1]; - this.index=null; - } - - public ACoord(double[][][] hv, int[] index) { - if(hv.length!=2) throw new IllegalArgumentException("hv.length="+hv.length); - this.hv=hv; - this.index=index; - } - - public ACoord(double[][][] hv, int[] index, ADrawable source) { - this(hv, index); - this.source=source; - } - - public ACoord(double[][][] hv) { - if(hv.length!=2) throw new IllegalArgumentException("hv.length="+hv.length); - this.hv=hv; - this.index=null; - } - - private ACoord(ACoord a) { - this.hv=new double[a.hv.length][][]; - for(int i=0; i<a.hv.length; i++) { - this.hv[i]=new double[a.hv[i].length][]; - for(int j=0; j<a.hv[i].length; j++) { - this.hv[i][j]=new double[a.hv[i][j].length]; - for(int k=0; k<a.hv[i][j].length; k++) - this.hv[i][j][k]=a.hv[i][j][k]; - } - } - this.index=new int[a.index.length]; - for(int i=0; i<a.index.length; i++) - this.index[i]=a.index[i]; - this.type=a.type; - this.source=a.source; - } - - public ACoord(double[][] hv, int[] index, ADrawable source, int type) { - this(hv, index, source); - this.type=type; - } - - public ACoord(double[][][] hv, int[] index, ADrawable source, int type) { - this(hv, index, source); - this.type=type; - } - - public ACoord(double[] h, double[] v, int[] index, ADrawable source) { - if(h.length!=v.length) - throw new IllegalArgumentException("h.length "+h.length+" !=v.length "+v.length); - if(h.length!=index.length) - throw new IllegalArgumentException("h.length "+h.length+" !=index.length "+index.length); - this.hv=new double[2][1][]; - this.hv[0][0]=h; - this.hv[1][0]=v; - this.index=index; - this.type=SYMBOLS; - this.source=source; - } - - public void print() { - for(int j=0; j<hv[0].length; j++) { - logger.debug(" index = "+index[j]); - for(int i=0; i<2; i++) { - if(i==0) - logger.debug("h "); - else - logger.debug("v "); - for(int k=0; k<hv[0][j].length; k++) - logger.debug((float)hv[i][j][k]+"\t"); - } - } - } - - // careful this does not make an independent copy - public ACoord(ACoord a, ACoord b) { - this.hv=new double[2][a.hv[0].length+b.hv[0].length][]; - this.index=new int[a.hv[0].length+b.hv[0].length]; - this.type=a.type; - this.source=a.source; - - for(int i=0; i<2; i++) { - int num=0; - - for(int j=0; j<a.hv[i].length; j++) { - this.hv[i][num]=a.hv[i][j]; - this.index[num]=a.index[j]; - num++; - } - for(int j=0; j<b.hv[i].length; j++) { - this.hv[i][num]=b.hv[i][j]; - this.index[num]=b.index[j]; - num++; - } - } - } - - public ACoord convertYXToFR() { - if(type==SYMBOLS||type==LINES) { - for(int j=0; j<hv[0][0].length; j++) { - double phiLast=0.; - - for(int i=0; i<hv[0].length; i++) { - double xx=hv[0][i][j]; - double yy=hv[1][i][j]; - double rho=Math.sqrt(xx*xx+yy*yy); - double phi=Math.toDegrees(Math.atan2(yy, xx)); - - if(phi<0.) - phi+=360.; - if(i>0) { - if(phi-phiLast>180.) phi-=360.; - if(phi-phiLast<-180.) phi+=360.; - } - hv[0][i][j]=rho; - hv[1][i][j]=phi; - phiLast=phi; - } - } - - } else { - for(int i=0; i<hv[0].length; i++) { - double phiLast=0.; - - for(int j=0; j<hv[0][i].length; j++) { - double xx=hv[0][i][j]; - double yy=hv[1][i][j]; - double rho=Math.sqrt(xx*xx+yy*yy); - double phi=Math.toDegrees(Math.atan2(yy, xx)); - - if(phi<0.) - phi+=360.; - if(j>0) { - if(phi-phiLast>180.) phi-=360.; - if(phi-phiLast<-180.) phi+=360.; - } - hv[0][i][j]=rho; - hv[1][i][j]=phi; - phiLast=phi; - } - } - } - return this; - } - - public ACoord includePhiWrapAround(String projectionName) { - // assumes phi is always the v coordinaate - int numFrames=parameterStore.get(projectionName, "FramesCount").getI(); - int initialFrame=parameterStore.get(projectionName, "InitialFrame").getI(); - - if(type==SYMBOLS||type==LINES) { - int numPoints=hv[1].length; - int numInitialData=hv[1][0].length; - - double[][][] hvtemp=new double[2][numPoints][numFrames*numInitialData]; - int[] indextemp=new int[numFrames*numInitialData]; - - int num=0; - - for(int f=initialFrame; f<initialFrame+numFrames; f++) { - for(int i=0; i<numInitialData; i++) { - if(index!=null) indextemp[num]=index[i]; - for(int j=0; j<numPoints; ++j) { - hvtemp[0][j][num]=this.hv[0][j][i]; - hvtemp[1][j][num]=this.hv[1][j][i]+f*360.; - } - num++; - } - } - hv=hvtemp; - if (index!=null) index=indextemp; - } else { - int numInitialData=hv[1].length; - double[][][] hvtemp=new double[2][numFrames*numInitialData][]; - int[] indextemp=new int[numFrames*numInitialData]; - - int num=0; - - for(int f=initialFrame; f<initialFrame+numFrames; f++) { - for(int i=0; i<numInitialData; i++) { - int numPoints=hv[1][i].length; - - hvtemp[0][num]=new double[numPoints]; - hvtemp[1][num]=new double[numPoints]; - for(int j=0; j<numPoints; j++) { - hvtemp[0][num][j]=this.hv[0][i][j]; - hvtemp[1][num][j]=this.hv[1][i][j]+f*360.; - } - if (index!=null) indextemp[num]=index[i]; - num++; - } - } - hv=hvtemp; - if (index!=null) index=indextemp; - } - return this; - } - - /** - * used in ATLAS context for the TRT - * Force data to be drawn as symbols if - * forceSymbols=true - * or - * all lines are smaller than minSize - */ - public ACoord toSymbols(boolean forceSymbols, int minSize) { - if(type==LINES) { - double dmax2=0.; - - for(int i=0; i<hv[0][0].length; i++) { - double dh=(hv[0][0][i]-hv[0][1][i]); - double dv=(hv[1][0][i]-hv[1][1][i]); - double d=dh*dh+dv*dv; - - if(d>dmax2) dmax2=d; - } - if(Math.sqrt(dmax2)<minSize||forceSymbols) { - type=SYMBOLS; - for(int i=0; i<hv[0][0].length; i++) { - hv[0][0][i]=(hv[0][0][i]+hv[0][1][i])/2.; - hv[1][0][i]=(hv[1][0][i]+hv[1][1][i])/2.; - } - } - } else if(type==POLYLINES||type==POLYGONS||type==TRANSPARENT_POLYGONS) { - double dmax2=0.; - - for(int j=0; j<hv[0].length; j++) { - for(int i=0; i<hv[0][j].length; i++) { - double dh=(hv[0][j][0]-hv[0][j][i]); - double dv=(hv[1][j][0]-hv[1][j][i]); - double d=dh*dh+dv*dv; - - if(d>dmax2) dmax2=d; - } - } - - if(Math.sqrt(dmax2)<minSize||forceSymbols) { - type=SYMBOLS; - double[][][] hvnew=new double[2][1][hv[0].length]; - - for(int j=0; j<hv[0].length; j++) { - double h=0.; - double v=0.; - - for(int i=0; i<hv[0][j].length; i++) { - h+=hv[0][j][i]; - v+=hv[1][j][i]; - } - h/=hv[0][j].length; - v/=hv[0][j].length; - hvnew[0][0][j]=h; - hvnew[1][0][j]=v; - } - hv=hvnew; - } - } - return this; - } - - public ACoord mirrorH () { - ACoord coord = new ACoord(this); - for(int i=0; i<coord.hv[0].length; i++) { - for(int j=0; j<coord.hv[0][i].length; j++) { - coord.hv[0][i][j] *= -1; - } - } - return coord; - } - - public ACoord mirrorV () { - ACoord coord = new ACoord(this); - for(int i=0; i<coord.hv[1].length; i++) { - for(int j=0; j<coord.hv[1][i].length; j++) { - coord.hv[1][i][j] *= -1; - } - } - return coord; - } -} - diff --git a/graphics/AtlantisJava/src/atlantis/graphics/ACursorFactory.java b/graphics/AtlantisJava/src/atlantis/graphics/ACursorFactory.java deleted file mode 100755 index 133abd8f8d49737f849ed25198804a4a9ee3784c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/ACursorFactory.java +++ /dev/null @@ -1,227 +0,0 @@ -package atlantis.graphics; - - -import java.awt.Toolkit; -import java.awt.Dimension; -import java.awt.Cursor; -import java.awt.Point; -import java.awt.Image; -import java.awt.dnd.DragSource; - -import atlantis.globals.AGlobals; -import atlantis.utils.ALogger; -import atlantis.utils.AUtilities; - -/** - * Singleton class factory for producing cursors. - * Due to difference in the default cursors provided by the different OSs, - * all cursors are generated by Atlantis itself. - */ - -public class ACursorFactory { - - private static ALogger logger = ALogger.getLogger(ACursorFactory.class); - - /** singleton class, pointer to this instance */ - private static ACursorFactory instance; - - /** Cursor size string, either "64x64" or "32x32" */ - private String cursorSize; - - /** Cursor color string, either "bw" or "" */ - private String bAndW=""; - - /** - * @return true if if system supports custom cursors - */ - public boolean getCustomCursors() { return customCursors; } - private final boolean customCursors; - - /** - * @return the default Cursor - */ - public Cursor getDefaultCursor() { return defaultCursor; } - private Cursor defaultCursor = null; - - /** Drag-and-drop valid cursor */ - private Cursor dragValidCursor=null; - public Cursor getDragValidCursor() { return dragValidCursor; } - /** Drag-and-drop invalid cursor */ - private Cursor dragInvalidCursor=null; - public Cursor getDragInvalidCursor() { return dragValidCursor; } - - /** Zoom cursor */ - public Cursor getZoomCursor() { return zoomCursor; } - private Cursor zoomCursor=null; - /** Move cursor */ - public Cursor getMoveCursor() { return moveCursor; } - private Cursor moveCursor=null; - /** Rotate cursor */ - public Cursor getRotateCursor() { return rotateCursor; } - private Cursor rotateCursor=null; - - /** Pick cursor */ - public Cursor getPickCursor() { return pickCursor; } - private Cursor pickCursor=null; - /** Rectangular selection cursor */ - public Cursor getRectSelectCursor() { return rectSelectCursor; } - private Cursor rectSelectCursor=null; - - /** Syncro cursor */ - public Cursor getSyncCursor() { return syncCursor; } - private Cursor syncCursor=null; - /** FishEye cursor */ - public Cursor getFishEyeCursor() { return fishEyeCursor; } - private Cursor fishEyeCursor=null; - - /** FishEye symbol also needed as a FishEye on/off indicator */ - public Image getFishEyeIndicator() { return fishEyeIndicator; } - private Image fishEyeIndicator=null; - - /** ATLAS logo can be printed on canvas */ - public Image getAtlasLogo() { return atlasLogo; } - private Image atlasLogo=null; - - /** - * Public singleton instantiation accessor - * @return the singleton instance - */ - public static ACursorFactory getInstance() { - - //Check if we already have an instance - if (instance == null) instance = new ACursorFactory(); - - //Return the singleton instance - return instance; - } - - - /** Constructor */ - private ACursorFactory(){ - - logger.debug("Creating cursor and image factory ..."); - String FILE_SEPAR = System.getProperty("file.separator"); - String homeDirectory = AGlobals.instance().getHomeDirectory(); - - //Provide images and indicators even in headless mode - //Fisheye - String path = homeDirectory + "img" + FILE_SEPAR + - "cursor_fisheye_"+bAndW+"32x32.gif"; - fishEyeIndicator = AUtilities.getFileAsImageIcon(path).getImage(); - - //Atlas logo - path = homeDirectory + "img" + FILE_SEPAR + - "atlas_logo_big.png"; - atlasLogo = AUtilities.getFileAsImageIcon(path).getImage(); - - - //Don't create any cursors in headless mode - if (AGlobals.isAtlantisHeadless()){ - //Custom cursors not supported on this platform - customCursors=false; - return; - } - - //Check for best cursor size on this system - trying largest - Dimension bestCursorSize=Toolkit.getDefaultToolkit().getBestCursorSize(64,64); - - //Check if custom cursors are allowed - if (bestCursorSize.width > 0){ - - customCursors=true; - - //We only support 32x32 and 64x64 cursors. Check which one we are closer to - if (bestCursorSize.width < 48) cursorSize="32x32"; - else cursorSize="64x64"; - - //Check if we have enough colours for greyscale cursors - if (Toolkit.getDefaultToolkit().getMaximumCursorColors() < 255) - bAndW="bw_"; - else bAndW=""; - - logger.info("Using "+bAndW+cursorSize+" cursors"); - - //Now create the individual cursors - Toolkit tools = Toolkit.getDefaultToolkit(); - - - //Drag and drop cursors ----------------------------------------------- - - //Valid DnD - path = homeDirectory + "img" + FILE_SEPAR + - "cursor_DnD_valid_" + cursorSize+ ".gif"; - Image validDnDImg = AUtilities.getFileAsImageIcon(path).getImage(); - - dragValidCursor=tools.createCustomCursor(validDnDImg, new Point(1, 1),"ValidDnD"); - - //Invalid Dnd - path = homeDirectory + "img" + FILE_SEPAR + - "cursor_DnD_invalid_" + cursorSize + ".gif"; - Image invalidDnDImg = AUtilities.getFileAsImageIcon(path).getImage(); - dragInvalidCursor=tools.createCustomCursor(invalidDnDImg,new Point(9, 9),"InvalidDnD"); - - //Zoom, move and rotate cursors ----------------------------------------------- - //Zoom - path = homeDirectory + "img" + FILE_SEPAR + - "cursor_zoom_"+bAndW+cursorSize+".gif"; - Image zoomImg = AUtilities.getFileAsImageIcon(path).getImage(); - zoomCursor=tools.createCustomCursor(zoomImg, new Point(9, 9),"Zoom"); - - //Move - path = homeDirectory + "img" + FILE_SEPAR + - "cursor_move_" + cursorSize+".gif"; - Image moveImg = AUtilities.getFileAsImageIcon(path).getImage(); - moveCursor=tools.createCustomCursor(moveImg,new Point(10, 10),"Move"); - - //Rotate - path = homeDirectory + "img" + FILE_SEPAR + - "cursor_rotate_"+bAndW+cursorSize+".gif"; - Image rotateImg = AUtilities.getFileAsImageIcon(path).getImage(); - rotateCursor=tools.createCustomCursor(rotateImg,new Point(11, 11),"Rotate"); - - //Pick and RectSelect cursors ----------------------------------------------- - //Pick - path = homeDirectory + "img" + FILE_SEPAR + - "cursor_pick_"+cursorSize+".gif"; - Image pickImg = AUtilities.getFileAsImageIcon(path).getImage(); - pickCursor=tools.createCustomCursor(pickImg, new Point(6, 1),"Pick"); - - //Rectangle select - path = homeDirectory + "img" + FILE_SEPAR + - "cursor_rectsel_"+cursorSize+".gif"; - Image rectSelectImg = AUtilities.getFileAsImageIcon(path).getImage(); - rectSelectCursor=tools.createCustomCursor(rectSelectImg,new Point(12, 12),"RectSelect"); - - //Syncro and FishEye cursors ----------------------------------------------------- - //Sync - path = homeDirectory + "img" + FILE_SEPAR + - "cursor_sync_" + cursorSize + ".gif"; - Image syncImg = AUtilities.getFileAsImageIcon(path).getImage(); - syncCursor=tools.createCustomCursor(syncImg, new Point(10, 10),"Sync"); - - //FishEye - path = homeDirectory + "img" + FILE_SEPAR + - "cursor_fisheye_"+bAndW+cursorSize+".gif"; - Image fishEyeImg = AUtilities.getFileAsImageIcon(path).getImage(); - fishEyeCursor=tools.createCustomCursor(fishEyeImg, new Point(1, 8),"FishEye"); - - } else customCursors=false; - - - //Now check for any cursors that have not been set yet - //And set them to system defaults - if (defaultCursor == null) defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR); - - if (dragValidCursor == null) dragValidCursor = DragSource.DefaultMoveDrop; - if (dragInvalidCursor == null) dragInvalidCursor = DragSource.DefaultMoveNoDrop; - - if (zoomCursor == null) zoomCursor = new Cursor(Cursor.DEFAULT_CURSOR); - if (moveCursor == null) moveCursor = new Cursor(Cursor.MOVE_CURSOR); - if (rotateCursor == null) rotateCursor = new Cursor(Cursor.DEFAULT_CURSOR); - - if (pickCursor == null) pickCursor = new Cursor(Cursor.HAND_CURSOR); - if (rectSelectCursor == null) rectSelectCursor = new Cursor(Cursor.NW_RESIZE_CURSOR); - if (syncCursor == null) syncCursor = new Cursor(Cursor.CROSSHAIR_CURSOR); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/ADrawParameters.java b/graphics/AtlantisJava/src/atlantis/graphics/ADrawParameters.java deleted file mode 100755 index 214b6e05b459a381afb0b5952328ecad50e3e299..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/ADrawParameters.java +++ /dev/null @@ -1,98 +0,0 @@ -package atlantis.graphics; - -import atlantis.graphics.colormap.AColorMap; - -import java.awt.Color; - -/** - * Contains graphics attributes of a collection of data - */ -public class ADrawParameters { - - boolean draw; - Color color; - int size; - int minSize=0; - boolean forceSymbols=false; - int lineWidth; - int frameWidth; - int symbol; - int drawOrFill=AGraphics.DRAW; - - public ADrawParameters(boolean draw, int color, int size, int lineWidth, int frameWidth, int symbol) { - Color[] colorMap=AColorMap.getColors(); - - this.draw=draw; - if(color!=-1) - this.color=colorMap[color]; - else - this.color=null; - this.size=size; - this.lineWidth=lineWidth; - this.frameWidth=frameWidth; - this.symbol=symbol; - } - - public ADrawParameters(boolean draw, int color, int size, int lineWidth, int frameWidth, int symbol, - boolean forceSymbols, int minSize, int drawOrFill) { - Color[] colorMap=AColorMap.getColors(); - - this.draw=draw; - if(color!=-1) - this.color=colorMap[color]; - else - this.color=null; - this.size=size; - this.lineWidth=lineWidth; - this.frameWidth=frameWidth; - this.symbol=symbol; - this.forceSymbols=forceSymbols; - this.minSize=minSize; - this.drawOrFill=drawOrFill; - } - - public ADrawParameters(boolean draw, Color color, int size, int lineWidth, int frameWidth, int symbol, int drawOrFill) { - this.draw=draw; - this.color=color; - this.size=size; - this.lineWidth=lineWidth; - this.frameWidth=frameWidth; - this.symbol=symbol; - this.drawOrFill=drawOrFill; - } - - public void setColor(int color) { - Color[] colorMap=AColorMap.getColors(); - - this.color=colorMap[color]; - } - - public void setFrameWidth(int width) { - this.frameWidth=width; - } - - public void setSize(int size) { - this.size=size; - } - - public boolean toBeDrawn() { - return draw; - } - - public int getSize() { - return size; - } - - public int getMinSize() { - return minSize; - } - - public boolean getForceSymbols() { - return forceSymbols; - } - - public int getDrawOrFill() { - return drawOrFill; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/ADrawable.java b/graphics/AtlantisJava/src/atlantis/graphics/ADrawable.java deleted file mode 100755 index bf36d13b60e756b2fb09890f64984b750892c1d7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/ADrawable.java +++ /dev/null @@ -1,24 +0,0 @@ -package atlantis.graphics; - - -import atlantis.canvas.AWindow; -import atlantis.projection.AProjection2D; - - -public interface ADrawable { - void draw(AWindow window, AGraphics ag, AProjection2D projection); - int[] getColor(int[] dl); - int[] getType(int[] dl); - int getNumTypes(); - - /** - * The data are normally drawn in two layers - * (layer=0 is for frames) - * (layer=1 is the data) - * The data may be of more than 1 type which are drawn in sequence - * e.g. type=0 noise - * type=1 others - */ - ADrawParameters getDrawParameters(int layer, int type); -} - diff --git a/graphics/AtlantisJava/src/atlantis/graphics/ADrawnGraphics2D.java b/graphics/AtlantisJava/src/atlantis/graphics/ADrawnGraphics2D.java deleted file mode 100755 index 5cd633a5e933910fad11cc646ea8d4f4dbe88c40..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/ADrawnGraphics2D.java +++ /dev/null @@ -1,149 +0,0 @@ -package atlantis.graphics; - -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Shape; -import java.awt.geom.PathIterator; -import java.util.ArrayList; -import java.util.HashMap; - -import atlantis.data.ACalorimeterData; -import atlantis.event.AData; -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.data.AHistogram; -import atlantis.list.AList; -import atlantis.list.AListManager; -import atlantis.utils.ALogger; - -/** - * Simple graphics context simply decides whether something was drawn or not - */ - -public class ADrawnGraphics2D extends ATemplateGraphics2D -{ - private static ALogger logger = ALogger.getLogger(ADrawnGraphics2D.class); - private static AEventManager eventManager = AEventManager.instance(); - - private static HashMap map; - private static ArrayList histogramList; - - public ADrawnGraphics2D(Rectangle bounds) - { - super(bounds); - map = new HashMap(); - histogramList = new ArrayList(); - AEvent event = eventManager.getCurrentEvent(); - if (event != null) - { - AData[] data = event.getData(); - for (int i = 0; i < data.length; ++i) - { - map.put(data[i], new boolean[data[i].getNumData()]); - } - } - } // ADrawnGraphics2D() ---------------------------------------------------- - - ADrawnGraphics2D(ADrawnGraphics2D a) - { - super(a); - } // ADrawnGraphics2D() ---------------------------------------------------- - - public static void updateLastDrawn() - { - AListManager.getInstance().clearLastDrawn(); - AEvent event = eventManager.getCurrentEvent(); - if (event != null) - { - AData[] data = event.getData(); - for (int i = 0; i < data.length; ++i) - { - boolean[] drawn = (boolean[]) map.get(data[i]); - if (data[i] instanceof ACalorimeterData) - { - drawn = ((ACalorimeterData) data[i]).expandDrawn(drawn); - } - AListManager.getInstance().addLastDrawn(new AList(data[i], drawn)); - } - for (int i = 0; i < histogramList.size(); ++i) - { - boolean[] drawn = (boolean[]) map.get(histogramList.get(i)); - AListManager.getInstance().addLastDrawn(new AList((AData)histogramList.get(i), drawn)); - } - } - } // updateLastDrawn() ----------------------------------------------------- - - public Graphics create() - { - return new ADrawnGraphics2D(this); - } - - public void drawLine(double h0, double v0, double h1, double v1) - { - if (AGraphics.currentData != null) - { - ((boolean[]) map.get(AGraphics.currentData))[AGraphics.currentIndex] = true; - } - } - - public void fillRect(int h, int v, int width, int height) - { - double dh = width / 2.; - double dv = height / 2.; - drawLine(h - dh, v - dv, h + dh, v - dv); - drawLine(h + dh, v - dv, h + dh, v + dv); - drawLine(h + dh, v + dv, h - dh, v + dv); - drawLine(h - dh, v + dv, h - dh, v - dv); - } - - public void draw(Shape s) - { - PathIterator path = s.getPathIterator(null); - double[] coords = new double[6]; - double h0 = 0.; - double v0 = 0.; - double h1 = 0.; - double v1 = 0.; - while (!path.isDone()) - { - int segType = path.currentSegment(coords); - - switch (segType) - { - case PathIterator.SEG_MOVETO: - h0 = coords[0]; - v0 = coords[1]; - break; - - case PathIterator.SEG_LINETO: - case PathIterator.SEG_CUBICTO: - h1 = coords[0]; - v1 = coords[1]; - drawLine(h0, v0, h1, v1); - h0 = h1; - v0 = v1; - break; - - case PathIterator.SEG_CLOSE: - break; - - default: - logger.error(" Error unknown segment type"); - break; - } - path.next(); - } - } - - public void fill(Shape s) - { - draw(s); - } - - public void addHistogramData(AHistogram data) - { - histogramList.add(data); - map.put(data, new boolean[data.getNumData()]); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/ADummyGraphics2D.java b/graphics/AtlantisJava/src/atlantis/graphics/ADummyGraphics2D.java deleted file mode 100755 index 9c8cded5a0a8a442307039e4aaa88e084ebbf62e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/ADummyGraphics2D.java +++ /dev/null @@ -1,215 +0,0 @@ -package atlantis.graphics; - -import java.awt.*; -import java.awt.image.*; -import java.awt.image.renderable.*; -import java.awt.geom.*; -import java.awt.font.*; - -/** - * This graphics is used when nothing should really be drawn on the screen - */ - -public class ADummyGraphics2D extends Graphics2D { - - private int x; - private int y; - private int width; - private int height; - - public ADummyGraphics2D() {} - - public Rectangle getClipBounds() { - return new Rectangle(x, y, width, height); - } - - public void setClip(int x, int y, int width, int height) { - this.x=x; - this.y=y; - this.width=width; - this.height=height; - } - - public void transform(AffineTransform z) {} - - public void fill(Shape z) {} - - public void draw(Shape z) {} - - public void drawImage(BufferedImage a, BufferedImageOp b, int c, int z) {} - - public boolean drawImage(Image a, AffineTransform b, ImageObserver z) { - return false; - } - - public void drawRenderedImage(RenderedImage a, AffineTransform z) {} - - public void drawRenderableImage(RenderableImage a, AffineTransform z) {} - - public void drawString(java.text.AttributedCharacterIterator a, float b, float z) {} - - public void drawString(String a, int b, int z) {} - - public void drawString(String a, float b, float z) {} - - public void drawString(java.text.AttributedCharacterIterator a, int b, int z) {} - - public void drawGlyphVector(GlyphVector a, float b, float z) {} - - public boolean hit(Rectangle a, Shape b, boolean z) { - return false; - } - - public GraphicsConfiguration getDeviceConfiguration() { - return null; - } - - public void setComposite(Composite z) {} - - public void setPaint(Paint z) {} - - public void setStroke(Stroke z) {} - - public void setRenderingHint(RenderingHints.Key a, Object z) {} - - public Object getRenderingHint(RenderingHints.Key z) { - return null; - } - - public void setRenderingHints(java.util.Map z) {} - - public void addRenderingHints(java.util.Map z) {} - - public RenderingHints getRenderingHints() { - return null; - } - - public void translate(double a, double z) {} - - public void translate(int a, int z) {} - - public void rotate(double a, double b, double z) {} - - public void rotate(double z) {} - - public void scale(double a, double z) {} - - public void shear(double a, double z) {} - - public void setTransform(AffineTransform z) {} - - public AffineTransform getTransform() { - return null; - } - - public Paint getPaint() { - return null; - } - - public Composite getComposite() { - return null; - } - - public void setBackground(Color z) {} - - public Color getBackground() { - return null; - } - - public Stroke getStroke() { - return null; - } - - public void clip(Shape z) {} - - public FontRenderContext getFontRenderContext() { - return null; - } - - public void setColor(Color z) {} - - public Graphics create() { - return null; - } - - public boolean drawImage(Image a, int b, int c, int d, int e, int f, int g, int h, int i, ImageObserver z) { - return false; - } - - public boolean drawImage(Image a, int b, int c, ImageObserver z) { - return false; - } - - public boolean drawImage(Image a, int b, int c, Color d, ImageObserver z) { - return false; - } - - public boolean drawImage(Image a, int b, int c, int d, int e, Color f, ImageObserver z) { - return false; - } - - public boolean drawImage(Image a, int b, int c, int d, int e, ImageObserver z) { - return false; - } - - public boolean drawImage(Image a, int b, int c, int d, int e, int f, int g, int h, int i, Color j, ImageObserver z) { - return false; - } - - public Color getColor() { - return null; - } - - public void fillRect(int a, int b, int c, int z) {} - - public void setPaintMode() {} - - public void setXORMode(Color z) {} - - public Font getFont() { - return null; - } - - public void setFont(Font z) {} - - public FontMetrics getFontMetrics(Font z) { - return null; - } - - // public Rectangle getClipBounds () { return null;} - public void clipRect(int a, int b, int c, int z) {} - - // public void setClip(int a,int b,int c,int z) { } - public void setClip(Shape z) {} - - public Shape getClip() { - return null; - } - - public void copyArea(int a, int b, int c, int d, int e, int z) {} - - public void drawLine(int a, int b, int c, int z) {} - - public void clearRect(int a, int b, int c, int z) {} - - public void drawRoundRect(int a, int b, int c, int d, int e, int z) {} - - public void fillRoundRect(int a, int b, int c, int d, int e, int z) {} - - public void drawOval(int a, int b, int c, int z) {} - - public void fillOval(int a, int b, int c, int z) {} - - public void drawArc(int a, int b, int c, int d, int e, int z) {} - - public void fillArc(int a, int b, int c, int d, int e, int z) {} - - public void drawPolyline(int[] a, int[] b, int z) {} - - public void drawPolygon(int[] a, int[] b, int z) {} - - public void fillPolygon(int[] a, int[] b, int z) {} - - public void dispose() {} - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/AGLPixelGraphics.java b/graphics/AtlantisJava/src/atlantis/graphics/AGLPixelGraphics.java deleted file mode 100644 index 299aa5fd26b0b229d4edf90356e9e0d3cc8a62ea..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/AGLPixelGraphics.java +++ /dev/null @@ -1,47 +0,0 @@ -package atlantis.graphics; - -import atlantis.canvas.AGLGraphics; - -/* - * This class subclasses APixelGraphics to allow some optimisations slightly - * higher up the graphics chain in cases where OpenGL renders faster in - * certain ways - * - * @author Adam Davison - */ - -public class AGLPixelGraphics extends APixelGraphics { - - protected AGLGraphics m_glg; - - public AGLPixelGraphics(AGLGraphics g) { - super(g); - m_glg = g; - } - - @Override - public void fillPolygon(double[] h, double[] v, int numPoints) { - /*int type = getContainmentType(h, v, numPoints, POLYGON); - if (type == FULLY_INSIDE || type == INTERSECTS) { - if (type == INTERSECTS) { - ACoord clipped = clipper.clipPolygon(h, v, numPoints); - h = clipped.hv[0][0]; - v = clipped.hv[1][0]; - numPoints = h.length; - }*/ - /*int[] hInt = new int[numPoints]; - int[] vInt = new int[numPoints]; - for (int i = 0; i < numPoints; ++i) { - hInt[i] = (int) h[i]; - vInt[i] = (int) v[i]; - }*/ - updateColor(); - m_glg.fillPolygon(h, v, numPoints); - //g.drawPolygon(hInt, vInt, numPoints); - /*} else if (type == CONTAINS) { - Rectangle bounds = g.getClipBounds(); - updateColor(); - g.fillRect((int) Math.rint(bounds.getX()), (int) Math.rint(bounds.getY()), (int) Math.rint(bounds.getWidth()), (int) Math.rint(bounds.getHeight())); - }*/ - } -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/AGraphics.java b/graphics/AtlantisJava/src/atlantis/graphics/AGraphics.java deleted file mode 100755 index 225eb608a8870edd3dd666872678473496ab5189..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/AGraphics.java +++ /dev/null @@ -1,407 +0,0 @@ -package atlantis.graphics; - -import atlantis.canvas.AGLGraphics; -import java.awt.Color; -import java.awt.AlphaComposite; -import java.awt.Composite; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.Shape; -import java.awt.Image; -import java.awt.Stroke; - -import atlantis.event.AData; -import atlantis.geometry.ADetectors; -import atlantis.graphics.colormap.AColorMap; -import atlantis.parameters.APar; -import atlantis.utils.APolygon; - -import org.sourceforge.jlibeps.epsgraphics.*; -import org.apache.batik.svggen.SVGGraphics2D; - -/** - * Normally all drawing should be done on an AGraphics. For special uses, e.g. - * Braintest projections, standard Java Graphics may be used. To allow this, - * projections are always given a graphics which they must convert to an - * AGraphics with AGraphics.makeAGraphics. AGraphics provides picking of drawn - * objects. - */ - -public abstract class AGraphics -{ - protected Graphics2D g; - AClipper clipper = null; - Color currentColor; - Color lastDrawnColor = null; - Rectangle bounds; - int lineWidth = 1; - int size; - int symbol; - ADrawParameters lastDrawParameters = null; - - static AData currentData = null; - static ADetectors currentDetector = null; - static int currentIndex; - - public static final int SYMBOL_FILLED_BOX = 0; - public static final int SYMBOL_HORIZONTAL_LINE = 1; - public static final int SYMBOL_VERTICAL_LINE = 2; - public static final int SYMBOL_PLUS = 3; - public static final int SYMBOL_FILLED_CIRCLE = 4; - - public static final int DRAW = 0; - public static final int FILL = 1; - - protected static final int NUM_LAYERS = 2; - - protected static final int FULLY_INSIDE = 0; - protected static final int FULLY_OUTSIDE = 1; - protected static final int CONTAINS = 2; - protected static final int INTERSECTS = 3; - - protected static final int POLYGON = 0; - protected static final int POLYLINE = 1; - - AGraphics(Graphics g) - { - this.g = (Graphics2D) g; - if (g.getClipBounds() != null) - clipper = new AClipper(g.getClipBounds()); - currentColor = g.getColor(); - } - - public Graphics2D getGraphics2D() - { - return g; - } - - public static AGraphics makeAGraphics(Graphics g) - { - if (g instanceof EpsGraphics2D || g instanceof APickingGraphics2D || - g instanceof ADrawnGraphics2D || g instanceof SVGGraphics2D) - { - return new AVectorGraphics(g); - } - else if (g instanceof AGLGraphics) - { - return new AGLPixelGraphics((AGLGraphics)g); - } - else - { - return new APixelGraphics(g); - } - } - - public static void setCurrentDataAndIndex(AData current, int index) - { - currentData = current; - currentIndex = index; - } - - public static void setCurrentDetectorAndIndex(ADetectors current, int index) - { - currentDetector = current; - currentIndex = index; - } - - public static void clearCurrentDetectorAndIndex() - { - currentDetector = null; - currentIndex = -1; - } - - public static void clearCurrentDataAndIndex() - { - currentData = null; - currentIndex = -1; - } - - public void setFont(Font f) - { - g.setFont(f); - } - - public void setStroke(Stroke s) - { - g.setStroke(s); - } - - public void setColor(Color c) - { - currentColor = c; - } - - public void updateColor() - { - if (currentColor != lastDrawnColor) - { - g.setColor(currentColor); - lastDrawnColor = currentColor; - } - } - - public abstract void setLineWidth(int lineWidth); - - public void updateDrawParameters(ADrawParameters dp) - { - if (dp != lastDrawParameters) - { - setColor(dp.color); - lineWidth = Math.max(dp.lineWidth, 1) + 2 * dp.frameWidth; - setLineWidth(lineWidth); - size = dp.size + 2 * dp.frameWidth; - symbol = dp.symbol; - lastDrawParameters = dp; - } - } - - public void drawString(String str, double x, double y) - { - g.drawString(str, (int) x, (int) y); - } - - public void draw(Shape s) - { - g.draw(s); - } - - public void drawPoint(AData detector, int index, double h, double v, int pixelsH, int pixelsV) - { - setCurrentDataAndIndex(detector, index); - drawPoint(h, v, pixelsH, pixelsV); - clearCurrentDataAndIndex(); - } - - public void drawPoint(double h, double v, int pixelsH, int pixelsV) - { - if (clipper.isPointWithin(h, v)) - fillRect(h, v, pixelsH, pixelsV); - } - - public void drawSymbol(double h, double v) - { - if (clipper.isPointWithin(h, v)) - { - if (symbol == SYMBOL_FILLED_BOX) - { - fillRect(h, v, size, size); - } - else if (symbol == SYMBOL_HORIZONTAL_LINE) - { - fillRect(h, v, size, lineWidth); - } - else if (symbol == SYMBOL_VERTICAL_LINE) - { - fillRect(h, v, lineWidth, size); - } - else if (symbol == SYMBOL_PLUS) - { - fillRect(h, v, size, lineWidth); - fillRect(h, v, lineWidth, size); - } - else if (symbol == SYMBOL_FILLED_CIRCLE) - { - fillOval(h, v, size, size); - } - } - } - - //Draw an image at postion x,y of this graphics context - //Introduced for FishEye symbol showing FishEye status - public void drawImage(Image img, int x, int y){ - //Draw the image on screen - g.drawImage(img,x,y,null); - } - - - public void fillPolygon(AData detector, int index, double[] h, double[] v, int numPoints) - { - setCurrentDataAndIndex(detector, index); - fillPolygon(h, v, numPoints); - clearCurrentDataAndIndex(); - } - - public void fillRect(int h, int v, int width, int height) - { - updateColor(); - g.fillRect(h, v, width, height); - } - - public void fillOval(int h, int v, int width, int height) - { - g.fillOval(h, v, width, height); - } - - public abstract void drawPolyline(double[] h, double[] v, int numPoints); - - public abstract void drawDottedPolyline(double[] h, double[] v, int numPoints); - - public abstract void drawSmoothPolyline(double[] h0, double[] v0, int numPoints0); - - public abstract void drawLine(double h0, double v0, double h1, double v1); - - public abstract void drawPolygon(double[] h, double[] v, int numPoints); - - protected abstract void fillRect(double h, double v, int width, int height); - - protected abstract void fillOval(double h, double v, int width, int height); - - public void fillPolygon(ADetectors det, int index, double[] h, double[] v, int numPoints) - { - setCurrentDetectorAndIndex(det, index); - fillPolygon(h, v, numPoints); - clearCurrentDetectorAndIndex(); - } - - public void fillPolygon(double[] h, double[] v, int numPoints, float alpha) - { - Composite originalComposite = g.getComposite(); - int ACtype = AlphaComposite.SRC_OVER; - g.setComposite(AlphaComposite.getInstance(ACtype, alpha)); - fillPolygon(h, v, numPoints); - g.setComposite(originalComposite); - } - - protected int getContainmentType(double[] h, double[] v, int numPoints, int shape) - { - int within = clipper.fastWithin(h, v, numPoints); - if (within == AClipper.NONE_WITHIN) - return FULLY_OUTSIDE; - if (within == AClipper.ALL_WITHIN) - return FULLY_INSIDE; - for (int i = 0; i < numPoints - 1; ++i) - if (clipper.isLineWithin(h[i], v[i], h[i + 1], v[i + 1])) - return INTERSECTS; - if (shape == POLYGON && numPoints > 1) - if (clipper.isLineWithin(h[numPoints - 1], v[numPoints - 1], h[0], v[0])) - return INTERSECTS; - Rectangle bounds = g.getClipBounds(); - double xCentreClipped = bounds.getX() + bounds.getWidth() / 2.; - double yCentreClipped = bounds.getY() + bounds.getHeight() / 2.; - if (isPointInside(h, v, numPoints, xCentreClipped, yCentreClipped)) - return CONTAINS; - return FULLY_OUTSIDE; - } - - public abstract void fillPolygon(double[] h, double[] v, int numPoints); - - public void drawPolygon(APolygon p) - { - drawPolygon(p.getX(), p.getY(), p.nrNodes()); - } - - public static boolean isPointInside(double[] h, double[] v, int numPoints, double hP, double vP) - { - double[] a = new double[numPoints]; - - for (int i = 0; i < numPoints; ++i) - { - a[i] = Math.atan2(v[i] - vP, h[i] - hP); - } - double[] d = new double[numPoints]; - - for (int i = 0; i < numPoints; ++i) - { - if (i < numPoints - 1) - d[i] = a[i + 1] - a[i]; - else - d[i] = a[0] - a[i]; - if (d[i] > Math.PI) - d[i] -= 2. * Math.PI; - else if (d[i] < -Math.PI) - d[i] += 2. * Math.PI; - } - double sum = 0.; - - for (int i = 0; i < numPoints; ++i) - { - sum += d[i]; - } - if (Math.abs(sum) > Math.PI) - return true; - else - return false; - } - - public void draw(ACoord display) - { - ADrawable source = display.source; - - if (source == null) - return; - ADrawParameters adp = source.getDrawParameters(0, 0); - - if (adp.getForceSymbols() == true || adp.getMinSize() > 0) - display.toSymbols(adp.getForceSymbols(), adp.getMinSize()); - Color[] colorMap = AColorMap.getColors(); - int[] index = display.index; - int[] c = source.getColor(index); - int[] t = source.getType(index); - double[][] h = display.hv[0]; - double[][] v = display.hv[1]; - - for (int layer = 0; layer < NUM_LAYERS; layer++) - { - for (int type = 0; type < source.getNumTypes(); type++) - { - ADrawParameters dp = source.getDrawParameters(layer, type); - int drawType = dp.getDrawOrFill(); - updateDrawParameters(dp); - if (dp.draw) - { - for (int j = 0; j < t.length; j++) - { - if (t[j] == type) - { - if (layer == NUM_LAYERS - 1) - { - setColor(colorMap[c[j]]); - if (source instanceof AData) - setCurrentDataAndIndex((AData) source, index[j]); - } - if (display.type == ACoord.SYMBOLS) - drawSymbol(h[0][j], v[0][j]); - else if (display.type == ACoord.POLYGONS && h[j].length == 1) - drawSymbol(h[j][0], v[j][0]); - else if (display.type == ACoord.LINES) - drawLine(h[0][j], v[0][j], h[1][j], v[1][j]); - else if (display.type == ACoord.POLYLINES) - drawPolyline(h[j], v[j], h[j].length); - else if (display.type == ACoord.SMOOTH_POLYLINES) - drawSmoothPolyline(h[j], v[j], h[j].length); - else if (display.type == ACoord.DOTTED_POLYGONS) - drawDottedPolyline(h[j], v[j], h[j].length); - else if (display.type == ACoord.POLYGONS) - { - if (drawType == DRAW) - drawPolygon(h[j], v[j], h[j].length); - else if (drawType == FILL) - fillPolygon(h[j], v[j], h[j].length); - } - else if (display.type == ACoord.TRANSPARENT_POLYGONS) - { - if(g instanceof EpsGraphics2D){ - // setComposite is currently unsupported for EpsGraphics2D - // for now just draw as an outline, so we can still see - // jets and the underlying objects - drawPolygon(h[j], v[j], h[j].length); - } - else { - Composite originalComposite = g.getComposite(); - int ACtype = AlphaComposite.SRC_OVER; - g.setComposite(AlphaComposite.getInstance(ACtype, (float)APar.instance().get("Jet","Alpha").getD())); - fillPolygon(h[j], v[j], h[j].length); - g.setComposite(originalComposite); - } - } - clearCurrentDataAndIndex(); - } - } - } - } - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/AIcon.java b/graphics/AtlantisJava/src/atlantis/graphics/AIcon.java deleted file mode 100644 index a2add88871f92442620d9e123aa7f1f9ba630e08..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/AIcon.java +++ /dev/null @@ -1,28 +0,0 @@ -package atlantis.graphics; - -import java.awt.Frame; - -import javax.swing.ImageIcon; - -import atlantis.globals.AGlobals; -import atlantis.utils.AUtilities; - -/** - * - * @author waugh - * - */ -public class AIcon { - /** Set icon image for a frame to be the Atlantis icon. */ - public static void setIconImage(Frame f) - { - String path = AGlobals.instance().getHomeDirectory() + "img" + - System.getProperty("file.separator") + - "atlantis_icon.gif"; - ImageIcon ii = AUtilities.getFileAsImageIcon(path); - f.setIconImage(ii.getImage()); - - } // setIconImage() ----------------------------------------------------- - - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/ALegoDraw.java b/graphics/AtlantisJava/src/atlantis/graphics/ALegoDraw.java deleted file mode 100755 index ab9137ea80ad3a4cb9c9a65e53e6729ff7c04ac4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/ALegoDraw.java +++ /dev/null @@ -1,1150 +0,0 @@ -package atlantis.graphics; -import java.awt.BasicStroke; - -import java.awt.Color; -import java.awt.Font; -import java.awt.Stroke; -import java.awt.geom.Point2D; - -import atlantis.canvas.AWindow; -import atlantis.event.AEvent; -import atlantis.data.ALVL1ResultData; -import atlantis.data.ATriggerInfoData; -import atlantis.graphics.colormap.AColorMap; -import atlantis.parameters.AEnumeratorParameter; -import atlantis.parameters.APar; -import atlantis.projection.AProjectionLegoPlot; -import atlantis.utils.AMath; - -public class ALegoDraw -{ - - protected static APar parameterStore = APar.instance(); - - private static int legendHeight=0; - private static int lineHeight = 17;//seperation of lines - //colors to use in legend - - //width of lines in lego grid - private static float legoGridWidth = 1.6f; - private static float legoTowersWidth = 1.0f; - - private static Color textColor=Color.white, - backgroundColor=AColorMap.getColors()[parameterStore.get("Color", "BkgFill").getI()], - borderColor=Color.lightGray; - - public static Color getBackgroundColor() - { - return backgroundColor; - } - - public static void fillBackground(AWindow window, AGraphics ag) - { - - backgroundColor = AColorMap.getColors()[parameterStore.get("Color", "BkgFill").getI()]; // inherit bkg colour from main background colour - - ag.setColor(backgroundColor); - ag.fillRect(0, 0, window.getWidth(), window.getHeight()); - } - - public static void drawLegend(AWindow window, AGraphics ag, AEvent event, double met, double maxEt, double AODmaxEt) - { - //colors to use - textColor=Color.black; - if(backgroundColor.getBlue()+backgroundColor.getGreen()+backgroundColor.getRed() < 400) - textColor=Color.white; - //change the font size (reset at end) - float originalFontSize= ag.g.getFont().getSize2D(); - float newFontSize= (float) 0.9*originalFontSize; - ag.g.setFont(ag.g.getFont().deriveFont(newFontSize)); - //variables to locate where to write/draw - legendHeight = lineHeight+2;//distance from top of legend - int indent = window.getWidth()- 200;//distance from left of legend - int pos = 90;//distance to start writing second half of line - //loop over Lvl1resultdata collections - String[] colLvl1=event.getActiveCollectionNames("LVL1Result"); - ALVL1ResultData lvl1ResultData[] = null; - if(colLvl1.length>0) - lvl1ResultData = new ALVL1ResultData[colLvl1.length]; - for(int i=0;i<colLvl1.length;i++) - { - lvl1ResultData[i] = (ALVL1ResultData) event.get(colLvl1[i]); - } - ATriggerInfoData triggerInfoData = event.getTriggerInfoData(); - - //check window is large enough - if(window.getWidth()<250 || window.getHeight()<250) - { - drawWindowTooSmall(window, ag, indent); - //reset font size - ag.g.setFont(ag.g.getFont().deriveFont(originalFontSize)); - return; - } - - //draw main legend - if(parameterStore.get("LegoPlot", "MainLegend").getStatus()) - drawLegendMain(window, ag, event, met, maxEt, AODmaxEt, lvl1ResultData, indent, pos); - //draw lvl1 sumEt and missEt - if(parameterStore.get("LegoPlot", "L1EtLegend").getStatus()) - drawLegendL1ET(ag, lvl1ResultData, triggerInfoData, indent); - //draw the item list - boolean drawLegend=false; - if(!drawLegend && parameterStore.get("LegoPlot", "L1Items").getStatus())drawLegend=true; - if(!drawLegend && parameterStore.get("LegoPlot", "L2Items").getStatus())drawLegend=true; - if(!drawLegend && parameterStore.get("LegoPlot", "EFItems").getStatus())drawLegend=true; - if(drawLegend) - drawLegendItems(window, ag, lvl1ResultData, indent); - - //reset font size - ag.g.setFont(ag.g.getFont().deriveFont(originalFontSize)); - } - - public static void drawWindowTooSmall(AWindow window, AGraphics ag, int indent) - { - - //change indent to make legend smaller - indent+=135; - // create legend boarder with two concentric rectangles - // outer rectangle: - ag.setColor(borderColor); - ag.fillRect(indent - 4, 5, 65, 3*lineHeight); - // inner rectangle: - ag.setColor(backgroundColor); - ag.fillRect(indent - 4 + 2, 7, 65 - 4, 3*lineHeight-4); - ag.setColor(textColor); - ag.updateColor(); - - ag.drawString("Window", indent + 6, legendHeight); - legendHeight += lineHeight; - ag.drawString("too small", indent + 6, legendHeight); - legendHeight += lineHeight; - ag.drawString("for legend", indent + 6, legendHeight); - legendHeight += lineHeight; - } - - public static void drawLegendMain(AWindow window, AGraphics ag, AEvent event, double met, double maxEt, double AODmaxEt, ALVL1ResultData lvl1ResultData[], int indent, int pos) - { - - // create legend boarder with two concentric rectangles - // outer rectangle: - ag.setColor(borderColor); - //ag.fillRect(/*indent - 4*/window.getWidth()/1.8, /*5*/window.getHeight()/3.0, (int)(1-(window.getWidth()/1.8)), (int)(1-(window.getHeight()/3.0))); - ag.fillRect(indent - 4, 5, 200, 105); - - // inner rectangle: - ag.setColor(backgroundColor); - ag.fillRect(indent - 4 + 2, 7, 200 - 4, 105 - 4); - //ag.fillRect(/*indent - 4*/window.getWidth()/1.8 +2, /*5*/window.getHeight()/3.0 +2, (int)(1-(window.getWidth()/1.8))+4, (int)(1-(window.getHeight()/3.0))+4); - - ag.setColor(textColor); - ag.updateColor(); - - //First item Missing ET (may remove met box from plot later) - if(met!=0) - drawLegendPartMain1(ag, event, met, indent, pos); - else - ag.drawString("No Missing Et", indent + 6, legendHeight); - legendHeight += lineHeight; - ag.setColor(textColor); - ag.updateColor(); - - //Second item colourby - //make sure there are cells by checking the maximum energy - //and that there have been colours added to the colourset - //(can have maxE and no colours when scaling to AOD) - if(maxEt!=0 && AProjectionLegoPlot.colorset.size()>0) - drawLegendMain2(ag, indent, pos); - else - { - ag.setColor(textColor); - ag.updateColor(); - ag.drawString("No cells", indent + 6, legendHeight); - } - legendHeight += lineHeight; - ag.setColor(textColor); - ag.updateColor(); - - //Third item maximum height of towers - if(maxEt!=0 || AODmaxEt!=0) - drawLegendMain3(ag, maxEt, AODmaxEt, indent, pos); - else - { - ag.drawString("No towers", indent + 6, legendHeight); - legendHeight += lineHeight; - } - legendHeight += lineHeight; - ag.setColor(textColor); - ag.updateColor(); - - //Fourth item lvl1 result - if (lvl1ResultData == null){ - ag.drawString("Trigger Decision N/A", indent+6, legendHeight); - legendHeight+=lineHeight;//move by a line to keep same spacing - }else if (lvl1ResultData.length>1){ - ag.drawString(">1 LVL1Result collections selected", indent+6, legendHeight); - legendHeight+=lineHeight; - ag.drawString("View on event properties or choose 1", indent+6, legendHeight); - }else{ - drawLegendMain4(ag, lvl1ResultData[0], indent, pos); - } - legendHeight+=lineHeight; - ag.setColor(textColor); - ag.updateColor(); - } - - public static void drawLegendPartMain1(AGraphics ag, AEvent event, double met, int indent, int pos) - { - ag.setColor(AProjectionLegoPlot.defaultColorMap[parameterStore.get("ETMis", "Constant").getI()]); - //draw dashed line - ag.fillRect(indent + 6, 11, 5, 3); - ag.fillRect(indent + 6 + 10, 11, 5, 3); - ag.fillRect(indent + 6 + 20, 11, 5, 3); - ag.fillRect(indent + 6 + 30, 11, 5, 3); - ag.setColor(textColor); - ag.updateColor(); - String[] names = event.getActiveCollectionNames("ETMis"); - if(names.length==1) - ag.drawString("Missing ET= " + Math.round(met) + " GeV" , indent + 0.6*pos, legendHeight); - else - ag.drawString("Max Missing ET= " + Math.round(met) + " GeV" , indent + 0.6*pos, legendHeight); - } - - public static void drawLegendMain2(AGraphics ag, int indent, int pos) - { - String modeName; - if (AProjectionLegoPlot.mode == 0) - { - modeName="LAr"; - } - else if (AProjectionLegoPlot.mode == 1) - { - modeName="LVL1TriggerTower"; - } - else - { - modeName="LVL1JetElement"; - } - AEnumeratorParameter param = (AEnumeratorParameter) parameterStore.get(modeName, "ColorFunction"); - String colorFunction = param.getText(param.getI()); - ag.drawString(colorFunction + " (1-" + AProjectionLegoPlot.colorset.size() + ")",indent + pos, legendHeight); - int barwidth = 6, barheight = 6; - if(AProjectionLegoPlot.getDrawEMHAD()) - { - if(AProjectionLegoPlot.colorset.size()==2) - { - //for Em/had option should only have 2 colors - ag.setColor(AProjectionLegoPlot.defaultColorMap[AProjectionLegoPlot.colorEM]); - ag.fillRect(indent + barwidth * 2, 28, barwidth * 2, barheight); - ag.setColor(AProjectionLegoPlot.defaultColorMap[AProjectionLegoPlot.colorHad]); - ag.fillRect(indent + 2 * barwidth* 2, 28, barwidth * 2, barheight); - } - else - { - //if more colors then lists must be in use - int c = 0; - ++c; - ag.setColor(AProjectionLegoPlot.defaultColorMap[AProjectionLegoPlot.colorEM]); - ag.fillRect(indent + c * barwidth, 28, barwidth, barheight); - ++c; - ag.setColor(AProjectionLegoPlot.defaultColorMap[AProjectionLegoPlot.colorHad]); - ag.fillRect(indent + c * barwidth, 28, barwidth, barheight); - for (int i = 0; i <AProjectionLegoPlot.caloColorMap.length ; i++) - { - if (!AProjectionLegoPlot.colorset.contains(new Integer(i))) - continue; - if(i==AProjectionLegoPlot.colorEM || i==AProjectionLegoPlot.colorHad) - continue; - ++c; - ag.setColor(AProjectionLegoPlot.caloColorMap[i]); - ag.fillRect(indent + c * barwidth, 28, barwidth, barheight); - } - } - } - else - { - //if not Em/Had then loop over colors - int c = 0; - barwidth = 90/AProjectionLegoPlot.caloColorMap.length; - for (int i = 0; i <AProjectionLegoPlot.caloColorMap.length ; i++) - { - if (!AProjectionLegoPlot.colorset.contains(new Integer(i))) - continue; - ++c; - ag.setColor(AProjectionLegoPlot.caloColorMap[i]); - ag.fillRect(indent + c * barwidth, 28, barwidth, barheight); - } - } - } - - public static void drawLegendMain3(AGraphics ag, double maxEt, double AODmaxEt, int indent, int pos) - { - ag.drawString( "Height of tallest tower:", indent + 6, legendHeight); - //next line has the values - legendHeight += lineHeight; - if (parameterStore.get("LegoPlot", "ETAxisHeight").getD() > 0.0) - ag.drawString("User selection: " + Math.round(maxEt) + " GeV ", indent +6, legendHeight); - else if (parameterStore.get("LegoPlot", "ScaleToAOD").getStatus()) - ag.drawString("Scale to AOD: " + Math.round(maxEt) + " GeV ", indent +6, legendHeight); - else - { - if(maxEt!=0) - { - ag.drawString("Cells: " + Math.round(maxEt) + " GeV ", indent +6, legendHeight); - if(AODmaxEt!=0) - ag.drawString("AOD: " + Math.round(AODmaxEt) + " GeV ", indent + pos, legendHeight); - } - else - ag.drawString("AOD: " + Math.round(AODmaxEt) + " GeV ", indent + 6, legendHeight); - } - } - - public static void drawLegendMain4(AGraphics ag, ALVL1ResultData lvl1ResultData, int indent, int pos) - { - ag.drawString("Trigger Decision:", indent +6, legendHeight); - legendHeight+=lineHeight; - String[] trigRes={"NA","NA","NA"}; - int[] temp=new int[3]; - temp[0]=lvl1ResultData.getPassedL1(0); - temp[1]=lvl1ResultData.getPassedL2(0); - temp[2]=lvl1ResultData.getPassedEF(0); - for(int i=0;i<3;i++) - { - switch(temp[i]) - { - case -1: - trigRes[i]="N/C"; - break; - case 0: - trigRes[i]="failed"; - break; - case 1: - trigRes[i]="passed"; - break; - default: - trigRes[i]="NA"; - } - } - ag.drawString("L1:" + trigRes[0] +" L2:" + trigRes[1]+" EF:" + trigRes[2], indent +6, legendHeight); - } - - public static void drawLegendL1ET(AGraphics ag, ALVL1ResultData lvl1ResultData[], ATriggerInfoData triggerInfoData, int indent) - { - // create legend boarder with two concentric rectangles - // outer rectangle: - ag.setColor(borderColor); - ag.fillRect(indent - 4, legendHeight, 200, (int) (lineHeight*1.5)); - // inner rectangle: - ag.setColor(backgroundColor); - ag.fillRect(indent - 4 + 2, legendHeight + 2, 200 - 4, (int) (lineHeight*1.5 - 4)); - ag.setColor(textColor); - ag.updateColor(); - legendHeight+=lineHeight; - //if no trigger info and "All" Lvlresult selected display warning - if(triggerInfoData==null && lvl1ResultData!=null && lvl1ResultData.length>1){ - ag.drawString(">1 LVL1Result collections selected", indent+6, legendHeight); - legendHeight+=lineHeight; - return; - } - - float LVL1EtMiss=-1.0f,LVL1SumEt=-1.0f; - if(triggerInfoData!=null) - { - LVL1EtMiss=triggerInfoData.getEnergyEtMiss(0); - LVL1SumEt=triggerInfoData.getEnergySumEt(0); - } - else if(lvl1ResultData!=null && lvl1ResultData.length==1) - { - LVL1EtMiss=lvl1ResultData[0].getEnergyEtMiss(0); - LVL1SumEt=lvl1ResultData[0].getEnergySumEt(0); - } - String LVL1EtMissOutput,LVL1SumEtOutput; - if(LVL1EtMiss>0) - LVL1EtMissOutput=""+LVL1EtMiss; - else - LVL1EtMissOutput="N/A"; - if(LVL1SumEt>0) - LVL1SumEtOutput=""+LVL1SumEt; - else - LVL1SumEtOutput="N/A"; - - ag.drawString("L1-EtMiss: "+LVL1EtMissOutput+" L1-SumEt: "+LVL1SumEtOutput, indent , legendHeight); - legendHeight+=lineHeight; - } - - public static void drawLegendItems(AWindow window, AGraphics ag, ALVL1ResultData lvl1ResultData[], int indent) - { - // ag.setStroke(new BasicStroke(legoTowersWidth)); returning to original line width - - if(lvl1ResultData!=null && lvl1ResultData.length>1){ - //create legend boarder with two concentric rectangles - //outer rectangle: - ag.setColor(borderColor); - ag.fillRect(indent - 4, legendHeight, 200, (int) (lineHeight*5.5)); - // inner rectangle: - ag.setColor(backgroundColor); - ag.fillRect(indent - 4 + 2, legendHeight + 2, 200 - 4, (int) (lineHeight*5.5 - 4)); - ag.setColor(textColor); - ag.updateColor(); - legendHeight+=lineHeight; - ag.drawString(">1 LVL1Result collections selected", indent+6, legendHeight); - legendHeight+=lineHeight; - ag.drawString("Either select 1 LVL1Result collection", indent+6, legendHeight); - legendHeight+=lineHeight; - ag.drawString("from: Calo->LVL1Result", indent+6, legendHeight); - legendHeight+=lineHeight; - ag.drawString("or to see all items select:", indent+6, legendHeight); - legendHeight+=lineHeight; - ag.drawString("file->Event Properties", indent+6, legendHeight); - legendHeight+=lineHeight; - return; - } - - //output message to say no lvl1result - if(lvl1ResultData==null){ - ag.setColor(borderColor); - ag.updateColor(); - ag.fillRect(window.getWidth() -200 - 4, legendHeight+4, 200, (int) Math.round(1.5*lineHeight)); - ag.setColor(backgroundColor); - ag.updateColor(); - ag.fillRect(window.getWidth() -200 - 4 + 2, legendHeight +4+ 2, 200 - 4, (int) Math.round(1.5*lineHeight)-4); - ag.setColor(textColor); - ag.updateColor(); - legendHeight+=lineHeight; - ag.drawString("No LVL1Result collection in event", window.getWidth() - 200 + 2, legendHeight+4); - return; - } - - int origlineHeight =lineHeight;//save lineheight to be reset at end of function - lineHeight*=0.8;//for item list bunch together - int startrowHeight =legendHeight; - - //now output items in columns in new legend box - - //lists to draw - int dolist1 = parameterStore.get("LegoPlot", "L1Items").getStatus()?1:0; - int dolist2 = parameterStore.get("LegoPlot", "L2Items").getStatus()?1:0; - int dolist3 = parameterStore.get("LegoPlot", "EFItems").getStatus()?1:0; - - //number of items per column and number of columns - int maxItems=(int) Math.round(((0.8*window.getHeight()-legendHeight)/lineHeight )-0.5); - int columnWidth= 72; - int maxColumns=(int) Math.floor((0.9*window.getWidth())/columnWidth); - - // store items and headers - String[][] items=new String[3][]; - if(dolist1>0) items[0]=newList("---L1 items---", lvl1ResultData[0].getCtpItemListSplit(0,true)); - if(dolist2>0) items[1]=newList("---L2 items---", lvl1ResultData[0].getitemListL2Split(0,true)); - if(dolist3>0) items[2]=newList("---EF items---", lvl1ResultData[0].getitemListEFSplit(0,true)); - - //number of columns for each list - int[] num=new int[3]; - num[0]= (dolist1==0)? 0 : (int) Math.ceil(items[0].length/((double)maxItems)); - num[1]= (dolist2==0)? 0 : (int) Math.ceil(items[1].length/((double)maxItems)); - num[2]= (dolist3==0)? 0 : (int) Math.ceil(items[2].length/((double)maxItems)); - - boolean doWarning=false;//for printing see event properties message - //calculate total number of columns - if(num[0]+num[1]+num[2]>maxColumns){ - //too many in list so each can just have the average - int av = (int) Math.floor(maxColumns/((double)(dolist1+dolist2+dolist3))); - if(dolist1>0) num[0]=av; - if(dolist2>0) num[1]=av; - if(dolist3>0) num[2]=av; - doWarning=true; - } - int noOfColumns=num[0]+num[1]+num[2]; - - //now store each column into an array [column][row] - String[][] list=new String[noOfColumns][maxItems]; - int list_counter=0; - //loop over each list - for(int i=0; i<3; i++){ - //loop over items in a list - int item_counter=0; - //only loop over columns can display for each list - for(int j=0; j<num[i]; j++){ - //loop over all items for a column - for(int k=0; k<maxItems; k++){ - if(item_counter<items[i].length) - list[list_counter][k]=items[i][item_counter]; - else - list[list_counter][k]=""; - item_counter++; - } - //next column - list_counter++; - } - } - - // makes outer and inner borders of table: - ag.setColor(borderColor); - ag.fillRect(window.getWidth() -noOfColumns*columnWidth - 4, legendHeight, (int)(noOfColumns*columnWidth), (int) Math.round((maxItems+0.5)*lineHeight)); - - //draw columns - for(int i=0; i<noOfColumns; i++){ - //draw column to draw onto - legendHeight=startrowHeight; - ag.setColor(backgroundColor); - ag.updateColor(); - ag.fillRect(window.getWidth() -(noOfColumns-i)*columnWidth - 4 + 2, legendHeight + 2, columnWidth - 4, (int) Math.round((maxItems+0.5)*lineHeight)-4); - ag.setColor(textColor); - ag.updateColor(); - //draw item - for(int j=0; j<maxItems; j++){ - legendHeight+=lineHeight; - ag.drawString(list[i][j], window.getWidth() - (noOfColumns-i)*columnWidth + 2, legendHeight); - } - } - - //output warning if too many items - if(doWarning){ - legendHeight+=lineHeight; - //draw under columns - ag.setColor(borderColor); - ag.updateColor(); - ag.fillRect(window.getWidth() -90 - 4, legendHeight+4, 90, (int) Math.round(2.5*lineHeight)); - ag.setColor(backgroundColor); - ag.updateColor(); - ag.fillRect(window.getWidth() -90 - 4 + 2, legendHeight +4+ 2, 90 - 4, (int) Math.round(2.5*lineHeight)-4); - ag.setColor(textColor); - ag.updateColor(); - legendHeight+=lineHeight; - ag.drawString(" more items in", window.getWidth() - 90 + 2, legendHeight+4); - legendHeight+=lineHeight; - ag.drawString("event properties", window.getWidth() - 90 + 2, legendHeight+4); - } - lineHeight=origlineHeight;//reset line height - } - - static String[] newList(String first, String[] rest){ - int counter = 2;//1 for title 1 for N/A if needed - if(rest!=null) counter+=rest.length-1;//now don't need N/A - - String[] editedList=new String[counter]; - editedList[0]=first; - if(rest!=null){ - System.arraycopy(rest, 0, editedList, 1, rest.length); - }else{ - editedList[1]="N/A"; - } - - return editedList; - } - - static void drawline(AWindow window, AGraphics ag, Point2D.Double from, Point2D.Double to) - { - from=window.calculateDisplay(from); - to=window.calculateDisplay(to); - ag.drawLine( from.x,from.y,to.x,to.y); - } - - static void drawline(AWindow window, AGraphics ag, double fromX, double fromY, double toX, double toY) - { - Point2D.Double from= new Point2D.Double(fromX,fromY); - Point2D.Double to= new Point2D.Double(toX,toY); - drawline(window, ag, from, to); - } - - //converts from energy into eta coords - static void drawline(AWindow window, AGraphics ag, double fromX, double fromY, double toX, double toY, int etAxisMaximum) - { - fromY=-5-(1-AProjectionLegoPlot.getyz(window.getIndex()))*50*(fromY/etAxisMaximum)*0.9; - toY=-5-(1-AProjectionLegoPlot.getyz(window.getIndex()))*50*(toY/etAxisMaximum)*0.9; - Point2D.Double from= new Point2D.Double(fromX,fromY); - Point2D.Double to= new Point2D.Double(toX,toY); - drawline(window, ag, from, to); - } - - static void drawstring(AWindow window, AGraphics ag, String str, double hereX, double hereY) - { - Point2D.Double here= new Point2D.Double(hereX,hereY); - here=window.calculateDisplay(here); - ag.drawString(str, here.x,here.y); - } - - //converts from energy into eta coords - static void drawstring(AWindow window, AGraphics ag, String str, double hereX, double hereY, int etAxisMaximum) - { - hereY=-5-(1-AProjectionLegoPlot.getyz(window.getIndex()))*50*(hereY/etAxisMaximum)*0.9; - Point2D.Double here= new Point2D.Double(hereX,hereY); - here=window.calculateDisplay(here); - ag.drawString(str, here.x,here.y); - } - - public static void drawGrid(AWindow window, AGraphics ag, double maxEt) - { - ag.setStroke(new BasicStroke(legoGridWidth)); //setting grid line width - int width = window.getSize().width; - int dpi = 72; - // Set a scaling font size with window width (sqrt prevents text from going too small in the small window) - int newFontSize = (int) Math.round(35.0 * Math.sqrt(width) / (double) dpi); - - //change the font size (reset at end) - float originalFontSize= ag.g.getFont().getSize2D(); - Font f = new Font("SansSerif", Font.PLAIN, newFontSize); - ag.setFont(f); - - // Draw the scale and labels on Et axis - ag.setColor(Color.darkGray); - if(backgroundColor.getBlue()+backgroundColor.getGreen()+backgroundColor.getRed() < 400) - ag.setColor(Color.lightGray); - ag.updateColor(); - int etAxisMaximum=(int) maxEt;//convert to int for use later on - int etAxisScale = 10;//seperation of ticks in ET - if (AProjectionLegoPlot.defaultScale ==1 ) - { - etAxisScale=1; - } - else if (maxEt > 10.0) - { - //set scale to 0.1 of nearest hundred to maximum - etAxisScale = 10 * ((int) Math.ceil(maxEt / 100.0)); - } - else if (maxEt == 10.0) - { - etAxisScale = 5; - } - else if (maxEt < 10.0) - { - etAxisScale = 2; - } - double lowPhi=-360*AProjectionLegoPlot.getxz(window.getIndex()); - //lowPhi = 1; - int ticksizex = 10; - double ticksizey = 0.5; - //Draw Et axis - drawline(window,ag,lowPhi,0.0,lowPhi,etAxisMaximum, etAxisMaximum); - //Draw the ticks - for(int s = etAxisMaximum-etAxisScale; s >= 0.0; s-=etAxisScale) - { - drawline(window,ag,lowPhi, s,lowPhi + ticksizex,s, etAxisMaximum); - if (AProjectionLegoPlot.defaultScale ==1 ) - drawstring(window,ag,"10^" + Integer.toString( s + AProjectionLegoPlot.minimumofLogScale ),lowPhi + 2*ticksizex,s,etAxisMaximum); - else - drawstring(window,ag,Integer.toString( s ),lowPhi + 2*ticksizex,s,etAxisMaximum); - } - // Draw the title on Et axis - drawline(window,ag,lowPhi, etAxisMaximum,lowPhi + ticksizex,etAxisMaximum, etAxisMaximum); - if (AProjectionLegoPlot.defaultScale ==1) - drawstring(window,ag,"10^" + Integer.toString( etAxisMaximum + AProjectionLegoPlot.minimumofLogScale) + " ET (GeV)",lowPhi + 2*ticksizex,etAxisMaximum,etAxisMaximum); - else if(AProjectionLegoPlot.defaultScale ==2) - drawstring(window,ag,Integer.toString( etAxisMaximum ) + " ET (GeV)^1/2",lowPhi + 2*ticksizex,etAxisMaximum,etAxisMaximum); - else - drawstring(window,ag,Integer.toString( etAxisMaximum ) + " ET (GeV)",lowPhi + 2*ticksizex,etAxisMaximum,etAxisMaximum); - - // Draw a grid - int t = -1; - for (double p = 0.; p <= 1.; p += 1. / 8.) - { - // parallel to the right side - drawline(window, ag, 360*p+lowPhi, -5.0, 360*p, 5.0); - if (++t % 2 == 0) - { - // a tick - drawline(window,ag,360*p,5.0,360*p,5.0+ticksizey); - String str = new Integer(((int) (360. * p))).toString(); - drawstring(window,ag,str,360*p-7.0,5.0+2.0*Math.sqrt(ticksizey)); - } - } - //Draw the title on phi axis - drawstring(window,ag,AMath.PHI,0.6*360,5.0+3.0*Math.sqrt(ticksizey)); - - for (double e = 0.; e <= 1.; e += 1. / 10.) - { - // parallel to the bottom - drawline(window, ag, lowPhi*(1-e), 10.0*e-5.0, 360.0+lowPhi*(1-e), 10.0*e-5.0); - // a tick - drawline(window, ag, lowPhi*(1-e), 10.0*e-5.0, lowPhi*(1-e), 10.0*e-5.0+ticksizey); - String str = new Integer((int)Math.round(e*10)-5).toString(); - if (AProjectionLegoPlot.reverse) - str = new Integer((int)Math.round(-e*10)+5).toString(); - drawstring(window,ag,str,lowPhi*(1-e)-20, 10.0*e-5.0+3.0*Math.sqrt(ticksizey)); - } - //Draw the title on eta axis - drawstring(window,ag,AMath.ETA,0.5*lowPhi-30,+5.0*Math.sqrt(ticksizey)); - - //reset font size - ag.g.setFont(ag.g.getFont().deriveFont(originalFontSize)); - } - - public static void drawJet(double et, double eta, double phi, Color color, AWindow window, AGraphics ag, double radius) - { - ag.setStroke(new BasicStroke(legoTowersWidth)); //Setting Lego Towers Width - double x = (phi*360)/ AMath.TWO_PI;//x is phi converted from rad to deg - int numPoints = 128;//points around circumference of circle - double[][] hj = new double[2][numPoints]; - double[][] vj = new double[2][numPoints]; - int phiwrap = 0; - double old_jetx = -1; - int[] pj = new int[2]; - pj[0] = pj[1] = 0; - for (int p = 0; p < numPoints; p++) - { - //add on fraction of diameter of circle in phi - double jetx = x + radius*36 * Math.cos(AMath.TWO_PI * p / (numPoints - 1)); - if (jetx < 0) - jetx += 360; - if(jetx >= 360) - jetx -= 360; - if(old_jetx > 0) - { - double jetx_diff = Math.abs(jetx - old_jetx); - if(jetx_diff > 360 / 2) - phiwrap = (phiwrap + 1) % 2; - } - // remember the last jetx, to see if we've wrapped around next time - old_jetx = jetx; - double y = eta; - if (AProjectionLegoPlot.reverse) - y = -y; - //add on fraction of diameter of circle in eta - double jety = y + radius * Math.sin(AMath.TWO_PI * p / (numPoints - 1)); - jetx=AProjectionLegoPlot.adjustPhi(window,jetx,jety);//move phi value due to slant of eta axis - Point2D.Double[] corners=window.getUserCorners(); - if(jetx < corners[0].x || jetx > corners[1].x || jety < corners[1].y || jety > corners[2].y) - continue;//exits loop if not in limits of drawn plot - hj[phiwrap][pj[phiwrap]] = jetx; - vj[phiwrap][pj[phiwrap]] = jety; - ++pj[phiwrap]; - } - - Point2D.Double p= new Point2D.Double(0,0); - for(int i=0; i<pj[0]; i++) - { - p = window.calculateDisplay(hj[0][i],vj[0][i]); - hj[0][i]=p.x; - vj[0][i]=p.y; - } - p.x=0; p.y=0; - for(int i=0; i<pj[1]; i++) - { - p = window.calculateDisplay(hj[1][i],vj[1][i]); - hj[1][i]=p.x; - vj[1][i]=p.y; - } - Stroke origStroke = ag.getGraphics2D().getStroke(); - boolean drawFrames = AColorMap.drawFrames(); - //if drawing frames this part draws the frame otherwise draws the fill - ag.setStroke(new BasicStroke(3)); - if(drawFrames) - ag.setColor(AProjectionLegoPlot.defaultColorMap[AColorMap.BK]); - else - ag.setColor(color); - - if (pj[0] > 2) - { - ag.drawPolygon(hj[0], vj[0], pj[0]); - } - if (pj[1] > 2) - { - ag.drawPolygon(hj[1], vj[1], pj[1]); - } - - //this part will draw the fill color inside the frame if is not black otherwise already drawn - if(drawFrames && !color.equals(AProjectionLegoPlot.defaultColorMap[AColorMap.BK])) - { - ag.setStroke(new BasicStroke(1)); - ag.setColor(color); - - if (pj[0] > 2) - { - ag.drawPolygon(hj[0], vj[0], pj[0]); - } - if (pj[1] > 2) - { - ag.drawPolygon(hj[1], vj[1], pj[1]); - } - } - - //reset stroke - ag.setStroke(origStroke); - } - - public static void drawJetText(double et, double eta, double phi, Color color, AWindow window, AGraphics ag, double radius) - { - double x = (phi*360)/ AMath.TWO_PI;//x is phi converted from rad to deg - int numPoints = 128;//points around circumference of circle - double[][] hj = new double[2][numPoints]; - double[][] vj = new double[2][numPoints]; - int phiwrap = 0; - double old_jetx = -1; - int[] pj = new int[2]; - pj[0] = pj[1] = 0; - for (int p = 0; p < numPoints; p++) - { - //add on fraction of diameter of circle in phi - double jetx = x + radius*36 * Math.cos(AMath.TWO_PI * p / (numPoints - 1)); - if (jetx < 0) - jetx += 360; - if(jetx >= 360) - jetx -= 360; - if(old_jetx > 0) - { - double jetx_diff = Math.abs(jetx - old_jetx); - if(jetx_diff > 360 / 2) - phiwrap = (phiwrap + 1) % 2; - } - // remember the last jetx, to see if we've wrapped around next time - old_jetx = jetx; - double y = eta; - if (AProjectionLegoPlot.reverse) - y = -y; - //add on fraction of diameter of circle in eta - double jety = y + radius * Math.sin(AMath.TWO_PI * p / (numPoints - 1)); - jetx=AProjectionLegoPlot.adjustPhi(window,jetx,jety);//move phi value due to slant of eta axis - Point2D.Double[] corners=window.getUserCorners(); - if(jetx < corners[0].x || jetx > corners[1].x || jety < corners[1].y || jety > corners[2].y) - continue;//exits loop if not in limits of drawn plot - hj[phiwrap][pj[phiwrap]] = jetx; - vj[phiwrap][pj[phiwrap]] = jety; - ++pj[phiwrap]; - } - - Point2D.Double p= new Point2D.Double(0,0); - for(int i=0; i<pj[0]; i++) - { - p = window.calculateDisplay(hj[0][i],vj[0][i]); - hj[0][i]=p.x; - vj[0][i]=p.y; - } - - //draw the jet et as text - String s = Double.toString(et); - int dot = s.indexOf('.'); - String ss = s.substring(0, dot+0); - float originalFontSize= ag.g.getFont().getSize2D(); - float newFontSize= (float) 25.; - ag.g.setFont(ag.g.getFont().deriveFont(newFontSize)); - ag.g.setColor(color); - ag.drawString(" "+ss, hj[0][0], vj[0][0]); - ag.g.setFont(ag.g.getFont().deriveFont(originalFontSize)); - } - - public static void drawMissEt(AWindow window, AGraphics ag, int phi, double pt, Color color, double maxEt) - { - //color - ag.setColor(color); - - drawBox(window, ag, phi, 0, AProjectionLegoPlot.DRAW_MET, 0, pt, maxEt, 0.5); - - double phibinsize=360.0/AProjectionLegoPlot.nPhiCells; - double[] h = new double[4]; - double[] v = new double[4]; - double etaChange = 0.5; - for(double etaStart=-5.0; etaStart<5.0; etaStart+=2*etaChange) - { - v[0] = etaStart; - h[0] = AProjectionLegoPlot.adjustPhi(window,phi*phibinsize,v[0]); - v[1] = v[0]+etaChange; - h[1] = AProjectionLegoPlot.adjustPhi(window,phi*phibinsize,v[1]); - v[2] = v[1]; - h[2] = h[1] + phibinsize; - v[3] = v[0]; - h[3] = h[0] + phibinsize; - //convert to window coords - Point2D.Double p= new Point2D.Double(0,0); - for(int i=0; i<4; i++) - { - p = window.calculateDisplay(h[i],v[i]); - h[i]=p.x; - v[i]=p.y; - } - //draw - ag.fillPolygon(h, v, 4); - } - } - - public static void drawBox(AWindow window, AGraphics ag, int phi, int eta, int colouring, double et1, double et2, double maxEt, double boxsize) - { - Color drawingColor; - //if colouring < 0 ->AOD object, otherwise its cells - switch(colouring){ - case AProjectionLegoPlot.DRAW_MET: - drawingColor=AProjectionLegoPlot.defaultColorMap[parameterStore.get("ETMis", "Constant").getI()]; - break; - case AProjectionLegoPlot.DRAW_MUON: - drawingColor=AProjectionLegoPlot.defaultColorMap[parameterStore.get("Muon", "Constant").getI()]; - break; - case AProjectionLegoPlot.DRAW_ELECTRON: - drawingColor=AProjectionLegoPlot.defaultColorMap[parameterStore.get("Electron", "Constant").getI()]; - break; - case AProjectionLegoPlot.DRAW_PHOTON: - drawingColor=AProjectionLegoPlot.defaultColorMap[parameterStore.get("Photon", "Constant").getI()]; - break; - case AProjectionLegoPlot.DRAW_CLUSTER: - drawingColor=AProjectionLegoPlot.defaultColorMap[parameterStore.get("Cluster", "Constant").getI()]; - break; - case AProjectionLegoPlot.DRAW_COMPOSITEPARTICLE: - drawingColor=AProjectionLegoPlot.defaultColorMap[parameterStore.get("CompositeParticle", "Constant").getI()]; - break; - case AProjectionLegoPlot.DRAW_BJET: - drawingColor=AProjectionLegoPlot.defaultColorMap[parameterStore.get("BJet", "Constant").getI()]; - break; - case AProjectionLegoPlot.DRAW_TAUJET: - drawingColor=AProjectionLegoPlot.defaultColorMap[parameterStore.get("TauJet", "Constant").getI()]; - break; - case AProjectionLegoPlot.DRAW_JET: - drawingColor=AProjectionLegoPlot.defaultColorMap[parameterStore.get("Jet", "Constant").getI()]; - break; - default: drawingColor=AProjectionLegoPlot.caloColorMap[colouring]; - } - - int object = -colouring;//should be positive for "objects" and negative for calo cells - - //now check transparency option - //result is transparent if colouring is < 0 - switch(parameterStore.get("LegoPlot", "TowerOutlines").getI()){ - //AOD: colouring is already correct - case 0: break; - //cells: reverse so now AOD solid - case 1: colouring*=-1; break; - //both - case 2: colouring=-1; break; - //neither - case 3: colouring=1; break; - } - double phibinsize=360.0/AProjectionLegoPlot.nPhiCells; - double etabinsize=10.0/AProjectionLegoPlot.nEtaCells; - double x = phi*phibinsize;//x is real phi position - double y = eta*etabinsize-5;//y is real eta position - if (object>0) {phibinsize=360./64.; etabinsize=10./100.;} - double x1 = AProjectionLegoPlot.adjustPhi(window,x, y);//x1 is real phi position - double x2 = AProjectionLegoPlot.adjustPhi(window,x, y-etabinsize);//shifted x due to eta bin size - double[][] h = new double[3][4]; - double[][] v = new double[3][4]; - //adjust the values of the energies - et1=(1-AProjectionLegoPlot.getyz(window.getIndex()))*50*(et1/maxEt)*0.9; - et2=et1+(1-AProjectionLegoPlot.getyz(window.getIndex()))*50*(et2/maxEt)*0.9; - - double phishift = boxsize * (phibinsize/2); //to center towers with recpt eta-phi coordinates x1 and x2 - double etashift = boxsize * ((etabinsize)/2); - - //front - h[0][0] = x1 - phishift; - v[0][0] = y-et1 - etashift; // (bottom front) - h[0][1] = x1 - phishift; - v[0][1] = y-et2 - etashift; - h[0][2] = x1 + phishift; - v[0][2] = y-et2 - etashift; - h[0][3] = x1 + phishift; - v[0][3] = y-et1 - etashift; - //top - h[1][0] = x2 - phishift; - v[1][0] = y-et2- etashift-etashift; //SHIFT to make top squared - h[1][1] = x1 - phishift; - v[1][1] = y-et2 - etashift; - h[1][2] = x1 + phishift; - v[1][2] = y-et2 - etashift; - h[1][3] = x2 + phishift; - v[1][3] = y-et2- etashift-etashift; //SHIFT to make top squared - //side - h[2][0] = x2 - (phishift); - v[2][0] = y-(et2)- etashift -etashift; // top back SHIFT to make top squared - h[2][1] = x1 - phishift; - v[2][1] = y-et2 - etashift; // top front - h[2][2] = x1 - phishift; - v[2][2] = y-(et1) - etashift; // bottom front - h[2][3] = x2 - (phishift); - v[2][3] = y-et1 -(etashift); // bottom back - - - //convert to window coords - Point2D.Double p= new Point2D.Double(0,0); - for(int i=0; i<4; i++) - { - p = window.calculateDisplay(h[0][i],v[0][i]); - h[0][i]=p.x; - v[0][i]=p.y; - p.x=0; p.y=0; - p = window.calculateDisplay(h[1][i],v[1][i]); - h[1][i]=p.x; - v[1][i]=p.y; - p.x=0; p.y=0; - p = window.calculateDisplay(h[2][i],v[2][i]); - h[2][i]=p.x; - v[2][i]=p.y; - } - - //draw sides - ag.setColor(drawingColor); - if (colouring>=0) - ag.fillPolygon(h[2], v[2], 4); - else if(colouring == AProjectionLegoPlot.DRAW_JET){ - ag.fillPolygon(h[2], v[2], 4, (float)APar.instance().get("Jet","AlphaJets").getD()); //f specifies transparency fraction - } - else - ag.fillPolygon(h[2], v[2], 4, 0.8f); //f specifies transparency fraction - - //colour front - ag.setColor(drawingColor); - //draw front - if (colouring>=0) - ag.fillPolygon(h[0], v[0], 4); - else if(colouring == AProjectionLegoPlot.DRAW_JET){ - ag.fillPolygon(h[0], v[0], 4, (float)APar.instance().get("Jet","AlphaJets").getD()); //f specifies transparency fraction - } - else - ag.fillPolygon(h[0], v[0], 4, 0.8f); //f specifies transparency fraction - - //colour top - Color ddc = drawingColor.darker().darker(); - ag.setColor(new Color(ddc.getRed(),ddc.getGreen(),ddc.getBlue())); - //draw top - if (colouring>=0) - ag.fillPolygon(h[1], v[1], 4); - else if(colouring == AProjectionLegoPlot.DRAW_JET){ - ag.fillPolygon(h[1], v[1], 4, (float)APar.instance().get("Jet","AlphaJets").getD()); //f specifies transparency fraction - } - else - ag.fillPolygon(h[1], v[1], 4, 0.8f); //f specifies transparency fraction - - } - - //draw box method that can be used when not all the towers of certain object have assigned the same colour - the parameter color specifies the i color component - public static void drawBox(AWindow window, AGraphics ag, int phi, int eta, int colouring, Color color, double et1, double et2, double maxEt, double boxsize) - { - Color drawingColor; - switch(colouring){ - case AProjectionLegoPlot.DRAW_MET: - drawingColor= color; - break; - case AProjectionLegoPlot.DRAW_MUON: - drawingColor= color; - break; - case AProjectionLegoPlot.DRAW_ELECTRON: - drawingColor= color; - break; - case AProjectionLegoPlot.DRAW_PHOTON: - drawingColor= color; - break; - case AProjectionLegoPlot.DRAW_CLUSTER: - drawingColor= color; - break; - case AProjectionLegoPlot.DRAW_COMPOSITEPARTICLE: - drawingColor= color; - break; - case AProjectionLegoPlot.DRAW_BJET: - drawingColor= color; - break; - case AProjectionLegoPlot.DRAW_TAUJET: - drawingColor= color; - break; - case AProjectionLegoPlot.DRAW_JET: - drawingColor= color; - break; - default: drawingColor=AProjectionLegoPlot.caloColorMap[colouring]; - } - - int object = -colouring;//should be positive for "objects" and negative for calo cells - - //now check transparency option - //result is transparent if colouring is < 0 - switch(parameterStore.get("LegoPlot", "TowerOutlines").getI()){ - //AOD: colouring is already correct - case 0: break; - //cells: reverse so now AOD solid - case 1: colouring*=-1; break; - //both - case 2: colouring=-1; break; - //neither - case 3: colouring=1; break; - } - double phibinsize=360.0/AProjectionLegoPlot.nPhiCells; - double etabinsize=10.0/AProjectionLegoPlot.nEtaCells; - double x = phi*phibinsize;//x is real phi position - double y = eta*etabinsize-5;//y is real eta position - if (object>0) {phibinsize=360./64.; etabinsize=10./100.;} - double x1 = AProjectionLegoPlot.adjustPhi(window,x, y);//x1 is real phi position - double x2 = AProjectionLegoPlot.adjustPhi(window,x, y-etabinsize);//shifted x due to eta bin size - double[][] h = new double[3][4]; - double[][] v = new double[3][4]; - //adjust the values of the energies - et1=(1-AProjectionLegoPlot.getyz(window.getIndex()))*50*(et1/maxEt)*0.9; - et2=et1+(1-AProjectionLegoPlot.getyz(window.getIndex()))*50*(et2/maxEt)*0.9; - - double phishift = boxsize * (phibinsize/2); //to center towers with recpt eta-phi coordinates x1 and x2 - double etashift = boxsize * ((etabinsize)/2); - - //front - h[0][0] = x1 - phishift; - v[0][0] = y-et1 - etashift; // (bottom front) - h[0][1] = x1 - phishift; - v[0][1] = y-et2 - etashift; - h[0][2] = x1 + phishift; - v[0][2] = y-et2 - etashift; - h[0][3] = x1 + phishift; - v[0][3] = y-et1 - etashift; - //top - h[1][0] = x2 - phishift; - v[1][0] = y-et2- etashift-etashift; //SHIFT to make top squared - h[1][1] = x1 - phishift; - v[1][1] = y-et2 - etashift; - h[1][2] = x1 + phishift; - v[1][2] = y-et2 - etashift; - h[1][3] = x2 + phishift; - v[1][3] = y-et2- etashift-etashift; //SHIFT to make top squared - //side - h[2][0] = x2 - (phishift); - v[2][0] = y-(et2)- etashift -etashift; // top back SHIFT to make top squared - h[2][1] = x1 - phishift; - v[2][1] = y-et2 - etashift; // top front - h[2][2] = x1 - phishift; - v[2][2] = y-(et1) - etashift; // bottom front - h[2][3] = x2 - (phishift); - v[2][3] = y-et1 -(etashift); // bottom back - - //convert to window coords - Point2D.Double p= new Point2D.Double(0,0); - for(int i=0; i<4; i++) - { - p = window.calculateDisplay(h[0][i],v[0][i]); - h[0][i]=p.x; - v[0][i]=p.y; - p.x=0; p.y=0; - p = window.calculateDisplay(h[1][i],v[1][i]); - h[1][i]=p.x; - v[1][i]=p.y; - p.x=0; p.y=0; - p = window.calculateDisplay(h[2][i],v[2][i]); - h[2][i]=p.x; - v[2][i]=p.y; - } - - //draw sides - ag.setColor(drawingColor); - if (colouring>=0) - ag.fillPolygon(h[2], v[2], 4); - else if(colouring == AProjectionLegoPlot.DRAW_JET){ - ag.fillPolygon(h[2], v[2], 4, (float)APar.instance().get("Jet","AlphaJets").getD()); - }else if (colouring == AProjectionLegoPlot.DRAW_BJET) { - ag.fillPolygon(h[2], v[2], 4, 0.4f); - }else - ag.fillPolygon(h[2], v[2], 4, 0.8f); //f specifies transparency fraction - - //colour front - ag.setColor(drawingColor); - //draw front - if (colouring>=0) - ag.fillPolygon(h[0], v[0], 4); - else if(colouring == AProjectionLegoPlot.DRAW_JET){ - ag.fillPolygon(h[0], v[0], 4, (float)APar.instance().get("Jet","AlphaJets").getD()); - }else if(colouring == AProjectionLegoPlot.DRAW_BJET) { - ag.fillPolygon(h[0], v[0], 4, 0.4f); - }else - ag.fillPolygon(h[0], v[0], 4, 0.8f); //f specifies transparency fraction - - //colour top - Color ddc = drawingColor.darker().darker(); - ag.setColor(new Color(ddc.getRed(),ddc.getGreen(),ddc.getBlue())); - //draw top - if (colouring>=0) - ag.fillPolygon(h[1], v[1], 4); - else if(colouring == AProjectionLegoPlot.DRAW_JET){ - ag.fillPolygon(h[1], v[1], 4, (float)APar.instance().get("Jet","AlphaJets").getD()); //f specifies transparency fraction - }else if(colouring == AProjectionLegoPlot.DRAW_BJET) { - ag.fillPolygon(h[1], v[1], 4, 0.4f); //f specifies transparency fraction - } - else - ag.fillPolygon(h[1], v[1], 4, 0.8f); //f specifies transparency fraction - } -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/graphics/APickingGraphics2D.java b/graphics/AtlantisJava/src/atlantis/graphics/APickingGraphics2D.java deleted file mode 100755 index 9757b84ccdd1e9a8934d449ef2d79e569b97b2dc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/APickingGraphics2D.java +++ /dev/null @@ -1,432 +0,0 @@ -package atlantis.graphics; - -import java.awt.Graphics; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Shape; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.geom.PathIterator; -import java.util.ArrayList; - -import javax.swing.JPopupMenu; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.event.AData; -import atlantis.data.ATrackData; -import atlantis.data.ATrackResidualData; -import atlantis.list.AList; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.projection.AProjectionTrackResidual; -import atlantis.projection.AProjectionsManager; -import atlantis.utils.ALogger; - -/** - * A very limited PostScript graphics context for output of Atlantis functions - * Any call to a none implemented will throw an exception - */ - -public class APickingGraphics2D extends ATemplateGraphics2D -{ - private static ALogger logger = ALogger.getLogger(APickingGraphics2D.class); - - public final static int PICK_HITS_AND_TRACKS = 0; - public final static int PICK_DETECTORS = 1; - public final static int MOVE = 2; - public final static int PICK_RESIDUAL = 3; - - public static int mode; - - static AData pickedData = null; - static ATrackResidualData pickedResidual = null; - static ArrayList pickedDetectors; - static int pickedIndex; - - public static Point pickedPoint; - static double minDist; - public static double pickedH; - public static double pickedV; - - private static JPopupMenu residualPopupMenu; - private static final String SHOW_RESIDUALS_X = "Show Residual X"; - private static final String SHOW_PULLS_X = "Show Pull X"; - - static - { - residualPopupMenu = new JPopupMenu(); - ActionListener residualPopupActionListener = - new APickingGraphics2D.ResidualPopupMenuActionListener(); - residualPopupMenu.add(SHOW_RESIDUALS_X).addActionListener(residualPopupActionListener); - residualPopupMenu.add(SHOW_PULLS_X).addActionListener(residualPopupActionListener); - } - - static class ResidualPopupMenuActionListener implements ActionListener - { - public void actionPerformed(ActionEvent e) - { - String action = e.getActionCommand(); - - // Use window "B" to show track residual - String residualWindowName = "B"; - if(ACanvas.getCanvas().isValidWindowName(residualWindowName)) - { - AWindow residualWindow = ACanvas.getCanvas().getWindow(residualWindowName); - AProjectionTrackResidual residualProj = - (AProjectionTrackResidual) AProjectionsManager.getProjection("TrackResidual"); - if (action.equals(SHOW_RESIDUALS_X)) - residualProj.setResidualType(ATrackResidualData.RESIDUAL_X); - else if (action.equals(SHOW_PULLS_X)) - residualProj.setResidualType(ATrackResidualData.PULL_X); - - // when this action is activated, the pickedData must be a track - ATrackData trackData = (ATrackData) pickedData; - residualProj.setResidual(trackData.getTrackResidual(pickedIndex)); - ACanvas.getCanvas().moveToFrontWindow(residualWindowName); - residualWindow.setProjection(residualProj); - } - else - AOutput.append("\nWindow " + residualWindowName + " is not available in current layout" - + "\n", ALogInterface.WARNING); - } - } - - public APickingGraphics2D(Rectangle bounds, int m, Point p) - { - super(bounds); - mode = m; - pickedPoint = p; - minDist = 10000000.; - if (mode != MOVE) - { - pickedData = null; - pickedIndex = -1; - } - if (pickedDetectors == null) - { - pickedDetectors = new ArrayList(); - } - else - { - pickedDetectors.clear(); - } - } - - APickingGraphics2D(APickingGraphics2D a) - { - super(a); - } - - public Graphics create() - { - return new APickingGraphics2D(this); - } - - public void drawLine(double h0, double v0, double h1, double v1) - { - if (mode == PICK_DETECTORS) - return; - if (AGraphics.currentData == null) - return; - if (mode == MOVE && - !(AGraphics.currentData == pickedData && AGraphics.currentIndex == pickedIndex)) - return; - double hPicked = pickedPoint.getX(); - double vPicked = pickedPoint.getY(); - // treat first two endpoints - double delH = h0 - hPicked; - double delV = v0 - vPicked; - double dist = delH * delH + delV * delV; - - if (dist < minDist) - { - minDist = dist; - setPicked(h0, v0); - } - delH = h1 - hPicked; - delV = v1 - vPicked; - dist = delH * delH + delV * delV; - if (dist < minDist) - { - minDist = dist; - setPicked(h1, v1); - } - // now treat point within line being closest - double h10 = h1 - h0; - double v10 = v1 - v0; - double hp0 = hPicked - h0; - double vp0 = vPicked - v0; - double size = h10 * h10 + v10 * v10; - - if (size > 0.0) - { - double u = (h10 * hp0 + v10 * vp0) / size; - - if (u > 0. && u < 1.) - { - double hClosest = h0 + u * h10; - double vClosest = v0 + u * v10; - - delH = hClosest - hPicked; - delV = vClosest - vPicked; - dist = delH * delH + delV * delV; - if (dist < minDist) - { - minDist = dist; - setPicked(hClosest, vClosest); - } - } - } - } - - public void fillRect(int h, int v, int width, int height) - { - if (mode == PICK_DETECTORS && AGraphics.currentDetector != null) - { - // Collect the different detector names. - String info = AGraphics.currentDetector.getInfo(AGraphics.currentIndex); - if (!pickedDetectors.contains(info)) - { - pickedDetectors.add(info); - } - } - double dh = width / 2.; - double dv = height / 2.; - drawLine(h - dh, v - dv, h + dh, v - dv); - drawLine(h + dh, v - dv, h + dh, v + dv); - drawLine(h + dh, v + dv, h - dh, v + dv); - drawLine(h - dh, v + dv, h - dh, v - dv); - } - - public void draw(Shape s) - { - PathIterator path = s.getPathIterator(null); - double[] coords = new double[6]; - double h0 = 0.; - double v0 = 0.; - double h1 = 0.; - double v1 = 0.; - double hInit = 0.; - double vInit = 0.; - while (!path.isDone()) - { - int segType = path.currentSegment(coords); - - switch (segType) - { - case PathIterator.SEG_MOVETO: - h0 = coords[0]; - v0 = coords[1]; - hInit = h0; - vInit = v0; - break; - - case PathIterator.SEG_LINETO: - case PathIterator.SEG_CUBICTO: - h1 = coords[0]; - v1 = coords[1]; - drawLine(h0, v0, h1, v1); - h0 = h1; - v0 = v1; - break; - - case PathIterator.SEG_CLOSE: - drawLine(h0, v0, hInit, vInit); - break; - - default: - logger.error(" Error unknown segment type"); - break; - } - path.next(); - } - } - - public void fill(Shape s) - { - if (mode == PICK_DETECTORS && AGraphics.currentDetector != null) - { - double[][] hv = getPolygon(s); - if (AGraphics.isPointInside(hv[0], hv[1], hv[0].length, pickedPoint.getX(), pickedPoint.getY())) - { - // Collect the different detector names. - String info = AGraphics.currentDetector.getInfo(AGraphics.currentIndex); - if (!pickedDetectors.contains(info)) - { - pickedDetectors.add(info); - } - } - } - else - { - draw(s); - } - } - - public double[][] getPolygon(Shape s) - { - double[] coords = new double[6]; - - int numPoints = 0; - PathIterator path = s.getPathIterator(null); - while (!path.isDone()) - { - int segType = path.currentSegment(coords); - switch (segType) - { - case PathIterator.SEG_MOVETO: - numPoints++; - break; - - case PathIterator.SEG_LINETO: - case PathIterator.SEG_CUBICTO: - numPoints++; - break; - - case PathIterator.SEG_CLOSE: - // numPoints++; - break; - - default: - break; - } - path.next(); - } - double[][] hv = new double[2][numPoints]; - numPoints = 0; - path = s.getPathIterator(null); - while (!path.isDone()) - { - int segType = path.currentSegment(coords); - - switch (segType) - { - case PathIterator.SEG_MOVETO: - hv[0][numPoints] = coords[0]; - hv[1][numPoints] = coords[1]; - numPoints++; - break; - - case PathIterator.SEG_LINETO: - case PathIterator.SEG_CUBICTO: - hv[0][numPoints] = coords[0]; - hv[1][numPoints] = coords[1]; - numPoints++; - break; - - case PathIterator.SEG_CLOSE: - // drawLine(h0,v0,hInit,vInit); - break; - - default: - logger.error(" Error unknown segment type"); - break; - } - path.next(); - } - return hv; - } - - private static void setPicked(double h, double v) - { - pickedData = AGraphics.currentData; - pickedIndex = AGraphics.currentIndex; - pickedH = h; - pickedV = v; - } - - public static AData getPickedData() - { - return pickedData; - - } // getPickedData() - - public static ATrackResidualData getPickedResidual() - { - return pickedResidual; - } - - public static int getPickedH() - { - return (int) Math.rint(pickedH); - } - - public static int getPickedV() - { - return (int) Math.rint(pickedV); - } - - public static AList getPickedHit() - { - if (pickedData != null) - return new AList(pickedData, pickedIndex); - else - return null; - } - - public static Integer getPickedHitIndex() - { - if (pickedData != null) - { - return new Integer(pickedIndex); - } - else - { - return null; - } - } - - public static void setPicked(AData data, int index) - { - pickedData = data; - pickedIndex = index; - } - - public static void setPicked(ATrackResidualData data) - { - pickedResidual = data; - } - - public static void printPicked() - { - if(mode == APickingGraphics2D.PICK_RESIDUAL) - { - AOutput.alwaysAppend("\n\n" + pickedResidual.getHitInfo(), ALogInterface.PICK); - mode = APickingGraphics2D.PICK_HITS_AND_TRACKS; - } - else - { - if (pickedData != null) - { - AOutput.alwaysAppend("\n\n" + pickedData.getHitInfo(pickedIndex), ALogInterface.PICK); - } - else if (pickedDetectors != null && pickedDetectors.size() > 0) - { - AOutput.alwaysAppend("\n\nYou are inside:\n", ALogInterface.PICK); - for (int i = 0; i < pickedDetectors.size(); i++) - { - AOutput.alwaysAppend(" " + pickedDetectors.get(i) + "\n", ALogInterface.PICK); - } - } - } - } - - /** - * Method is called after pick+n (navigate = show data associations) - */ - public static void navigatePicked() - { - if(pickedData != null) - { - String navigateInfo = pickedData.navigate(pickedIndex); - AOutput.alwaysAppend("\n" + navigateInfo + "\n", ALogInterface.PICK); - } - } - - public static void showTrackResiduals(AWindow window, int x, int y) - { - APickingGraphics2D.residualPopupMenu.show(window, x, y); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/APixelGraphics.java b/graphics/AtlantisJava/src/atlantis/graphics/APixelGraphics.java deleted file mode 100755 index 44a5136d93c11ac6a96add448645ea65e180318f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/APixelGraphics.java +++ /dev/null @@ -1,304 +0,0 @@ -package atlantis.graphics; - -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.geom.GeneralPath; - -/** - * This graphics is used for drawing on the screen and making pixel based - * images. In the end all drawing is done in pixels(integers). Picking is - * implemented here. Provide high quality pixel based drawing of thin frames - * around lines and areas, in the method draw. - */ -// When drawing borders could speed things up by only drawing what is needed -public class APixelGraphics extends AGraphics -{ - APixelGraphics(Graphics g) - { - super(g); - } - - public void setLineWidth(int lineWidth) - {} - - public void drawLine(double h0, double v0, double h1, double v1) - { - if (clipper.isLineWithin(h0, v0, h1, v1)) - { - double[][] hvClipped = clipper.getHV(); - double h0Clipped = hvClipped[0][0]; - double v0Clipped = hvClipped[1][0]; - double h1Clipped = hvClipped[0][1]; - double v1Clipped = hvClipped[1][1]; - if (lineWidth == 1) - { - updateColor(); - g.drawLine((int) h0Clipped, (int) v0Clipped, (int) h1Clipped, (int) v1Clipped); - } - else - { - drawThickLine(h0Clipped, v0Clipped, h1Clipped, v1Clipped); - } - } - - } // drawLine() - - private void drawThickLine(double h0, double v0, double h1, double v1) - { - // Drawing thick line this way is quicker than using setLine width - // correct for Postscipt - // pretty good for pixel device (assume java line drawing is Bresenhams - // or similar) - double h = Math.abs(h1 - h0); - double v = Math.abs(v1 - v0); - - for (int i = 0; i < lineWidth; ++i) - { - // 101/50 to avoid rounding toward 0 problem - int d = i + (101 - lineWidth) / 2 - 50; - - int h0new = (int) h0; - int v0new = (int) v0; - int h1new = (int) h1; - int v1new = (int) v1; - - if (h > v) - { - v0new += d; - v1new += d; - } - else - { - h0new += d; - h1new += d; - } - - // Caution!!! - // When point (h0, v0) or (h1, v1) is close to the border of the - // drawing area, after +/- d, the (h0new, v0new) or (h1new, v1new) - // might beyond the valid value range, which will cause an - // IndexArrayOutOfBound error thrown from g.drawLine method. - if(clipper.isLineWithin(h0new, v0new, h1new, v1new)) - { - updateColor(); - h0new = (int) clipper.getH0(); - v0new = (int) clipper.getV0(); - h1new = (int) clipper.getH1(); - v1new = (int) clipper.getV1(); - g.drawLine(h0new, v0new, h1new, v1new); - } - } - } - - public void drawSmoothLine(double h0, double v0, double ch0, double cv0, - double ch1, double cv1, double h1, double v1) - { - GeneralPath curve = new GeneralPath(); - for (int i=0; i<lineWidth; ++i) { - // 101/50 to avoid rounding toward 0 problem - int d = i + (101 - lineWidth) / 2 - 50; - float dh, dv; - - if (Math.abs(h1 - h0) > Math.abs(v1 - v0)) { - dh = 0; - dv = d; - } else { - dh = d; - dv = 0; - } - - curve.moveTo((float)h0+dh, (float)v0+dv); - curve.curveTo((float)ch0+dh, (float)cv0+dv, (float)ch1+dh, (float)cv1+dv, (float)h1+dh, (float)v1+dv); - } - updateColor(); - g.draw(curve); - } - - protected void fillRect(double h, double v, int width, int height) - { - updateColor(); - g.fillRect((int) (h - width / 2.), (int) (v - height / 2.), width, height); - } - - @Override - protected void fillOval(double h, double v, int width, int height) { - - g.fillOval((int) (h - width / 2.), (int) (v - height / 2.), width, height); - g.drawOval((int) (h - width / 2.), (int) (v - height / 2.), width, height); - } - - public void drawPolygon(double[] h, double[] v, int numPoints) - { - int type = getContainmentType(h, v, numPoints, POLYGON); - - if (type == FULLY_INSIDE || type == INTERSECTS) - { - for (int i = 0; i < numPoints - 1; ++i) - { - drawLine(h[i], v[i], h[i + 1], v[i + 1]); - } - if (numPoints > 1) - { - drawLine(h[numPoints - 1], v[numPoints - 1], h[0], v[0]); - } - } - } // drawPolygon() - - public void drawPolyline(double[] h, double[] v, int numPoints) - { - int type = getContainmentType(h, v, numPoints, POLYLINE); - if (type == FULLY_INSIDE || type == INTERSECTS) - { - // Some code here to simplify polylines by only drawing segments - // at least 1 pixel long, speeds up the ellipses for recvertices - // quite a lot since they're often very small but have thousands - // of line segments - AD - double lasth = 0.0; - double lastv = 0.0; - - for (int i = 0; i < numPoints - 1; ++i) { - if (i == 0) { - // Always draw something - lasth = h[1]; - lastv = v[1]; - drawLine(h[0], v[0], h[1], v[1]); - } - - double diffh = h[i+1] - lasth; - double diffv = v[i+1] - lastv; - - if ((diffh*diffh + diffv*diffv) > 1.0) { - drawLine(lasth, lastv, h[i + 1], v[i + 1]); - lasth = h[i+1]; - lastv = v[i+1]; - } - } - } - } // drawPolyline() - - public void drawDottedPolyline(double[] h, double[] v, int numPoints) - { - int type = getContainmentType(h, v, numPoints, POLYLINE); - if (type == FULLY_INSIDE || type == INTERSECTS) - { - for (int i = 0; i < numPoints - 1; i += 2) - drawLine(h[i], v[i], h[i + 1], v[i + 1]); - } - } // drawDottedPolyline() - - public void drawSmoothPolyline(double[] h0, double[] v0, int numPoints0) { - - // For curves having less than 3 points and for picking use the normal polyline. - if (numPoints0 < 3 || g instanceof APickingGraphics2D) { - drawPolyline(h0, v0, numPoints0); - return; - } - - int type = getContainmentType(h0, v0, numPoints0, POLYLINE); - if (type == FULLY_INSIDE || type == INTERSECTS) { - - int numPoints = 3 * numPoints0 - 2; - - // Add the control points to the array, at 1/3 and 2/3 - // between the already existing points. - float[] h = new float[numPoints]; - float[] v = new float[numPoints]; - for (int i=0; i<numPoints; i++) { - - switch (i%3) { - case 0: - // One of the fixed points. - h[i] = (float)h0[i/3]; - v[i] = (float)v0[i/3]; - break; - case 1: - // First control point. - h[i] = (float)(2./3. * h0[i/3] + 1./3. * h0[i/3+1]); - v[i] = (float)(2./3. * v0[i/3] + 1./3. * v0[i/3+1]); - break; - case 2: - // Second control point. - h[i] = (float)(1./3. * h0[i/3] + 2./3. * h0[i/3+1]); - v[i] = (float)(1./3. * v0[i/3] + 2./3. * v0[i/3+1]); - break; - } - } - - // Now we have a normal polyline (straight line segments between fixed points), - // but as a cubic Bezier curve. All we need to do to make it smooth is to move - // the control points away from the curve, in such a way that [control point 2] - - // [fixed point] - [control point 1] is a straight line for every fixed point. - // We do this by averaging the angles of the line segments on either side of a - // fixed point. - for (int i=3; i<numPoints-2; i+=3) { - double lenLeft = Math.sqrt(Math.pow(h[i]-h[i-1], 2) + Math.pow(v[i]-v[i-1], 2)); - double lenRight = Math.sqrt(Math.pow(h[i+1]-h[i], 2) + Math.pow(v[i+1]-v[i], 2)); - - // Without length we cannot define an angle, so skip the point. - if (lenLeft < 1e-6 || lenRight < 1e-6) continue; - - double phiLeft = Math.atan2(v[i]-v[i-1], h[i]-h[i-1]); - double phiRight = Math.atan2(v[i+1]-v[i], h[i+1]-h[i]); - - if (phiLeft-phiRight > Math.PI) { - phiRight += 2.*Math.PI; - } else if (phiRight-phiLeft > Math.PI) { - phiLeft += 2.*Math.PI; - } - - if (Math.abs(phiLeft-phiRight) > Math.PI/2.) { - // The line turns more than 90 degrees, this is wrong. Move the control points - // back in so they are the same as the point on the line. This disables the smooth - // curve locally, reverting to a normal connect-the-dots polyline. - h[i-1] = h[i+1] = h[i]; - v[i-1] = v[i+1] = v[i]; - } else { - // Calculate the desired angle for the tangent by weighting the angle on each side, - // the weight is inverse proportional to the distance to the next point. - double phi = (lenRight*phiLeft + lenLeft*phiRight) / (lenLeft+lenRight); - - h[i-1] = h[i] - (float)(lenLeft*Math.cos(phi)); - v[i-1] = v[i] - (float)(lenLeft*Math.sin(phi)); - h[i+1] = h[i] + (float)(lenRight*Math.cos(phi)); - v[i+1] = v[i] + (float)(lenRight*Math.sin(phi)); - } - } - - for (int i=0; i<numPoints-1; i+=3) { - drawSmoothLine(h[i], v[i], h[i+1], v[i+1], h[i+2], v[i+2], h[i+3], v[i+3]); - } - } - } - - public void fillPolygon(double[] h, double[] v, int numPoints) - { - int type = getContainmentType(h, v, numPoints, POLYGON); - if (type == FULLY_INSIDE || type == INTERSECTS) - { - if (type == INTERSECTS) - { - ACoord clipped = clipper.clipPolygon(h, v, numPoints); - h = clipped.hv[0][0]; - v = clipped.hv[1][0]; - numPoints = h.length; - } - int[] hInt = new int[numPoints]; - int[] vInt = new int[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - hInt[i] = (int) h[i]; - vInt[i] = (int) v[i]; - } - updateColor(); - g.fillPolygon(hInt, vInt, numPoints); - drawPolygon(h, v, numPoints); - } - else if (type == CONTAINS) - { - Rectangle bounds = g.getClipBounds(); - updateColor(); - g.fillRect((int) Math.rint(bounds.getX()), (int) Math.rint(bounds.getY()), (int) Math.rint(bounds.getWidth()), (int) Math.rint(bounds.getHeight())); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/ATemplateGraphics2D.java b/graphics/AtlantisJava/src/atlantis/graphics/ATemplateGraphics2D.java deleted file mode 100755 index 12dcf005ccc476942dc760297c3e6cb5e8f188d2..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/ATemplateGraphics2D.java +++ /dev/null @@ -1,47 +0,0 @@ -package atlantis.graphics; - -import java.awt.*; - -/** - * A very limited template graphics which implements the default behaviour - * of the clip region. - */ - -public abstract class ATemplateGraphics2D extends ADummyGraphics2D { - - private Rectangle currentClip; - private Rectangle imageBounds; - - public ATemplateGraphics2D(Rectangle bounds) { - currentClip=new Rectangle(bounds); - imageBounds=new Rectangle(bounds); - } - - protected ATemplateGraphics2D(ATemplateGraphics2D parent) { - currentClip=new Rectangle(parent.currentClip); - imageBounds=new Rectangle(parent.imageBounds); - } - - public abstract Graphics create(); - - public Rectangle getClipBounds() { - return new Rectangle(currentClip); - } - - public void setClip(int x, int y, int width, int height) { - currentClip=new Rectangle(x, y, width, height); - } - - public void clipRect(int x, int y, int width, int height) { - currentClip=currentClip.intersection(new Rectangle(x, y, width, height)); - } - - public void translate(int x, int y) { - translate((double)x, (double)y); - } - - public void translate(double x, double y) { - currentClip.setLocation((int)Math.round(currentClip.x-x), (int)Math.round(currentClip.y-y)); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/AVectorGraphics.java b/graphics/AtlantisJava/src/atlantis/graphics/AVectorGraphics.java deleted file mode 100755 index 058f8c075aa079288306b8d3b0b9630a029f3d92..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/AVectorGraphics.java +++ /dev/null @@ -1,309 +0,0 @@ -package atlantis.graphics; - -import java.awt.*; -import java.awt.geom.Ellipse2D; -import java.awt.geom.GeneralPath; - -/** - * Used when drawing to postscript - */ -public class AVectorGraphics extends AGraphics { - - private GeneralPath path=new GeneralPath(); - - AVectorGraphics(Graphics g) { - super(g); - } - - public void setLineWidth(int lineWidth) { - setStroke(new BasicStroke(lineWidth)); - } - - public void drawLine(int h0, int v0, int h1, int v1) { - drawLine((double)h0, (double)v0, (double)h1, (double)v1); - } - - public void drawLine(double h0, double v0, double h1, double v1) { - if(clipper.isLineWithin(h0, v0, h1, v1)) { - double[][] hvClipped=clipper.getHV(); - double h0Clipped=hvClipped[0][0]; - double v0Clipped=hvClipped[1][0]; - double h1Clipped=hvClipped[0][1]; - double v1Clipped=hvClipped[1][1]; - - path.reset(); - path.moveTo((float)h0Clipped, (float)v0Clipped); - path.lineTo((float)h1Clipped, (float)v1Clipped); - updateColor(); - g.draw(path); - } - } - - protected void fillRect(double h, double v, int width, int height) { - path.reset(); - float h0=(float)h; - float v0=(float)v; - float dh=(float)(width/2.); - float dv=(float)(height/2.); - - path.moveTo(h0-dh, v0-dv); - path.lineTo(h0+dh, v0-dv); - path.lineTo(h0+dh, v0+dv); - path.lineTo(h0-dh, v0+dv); - path.closePath(); - updateColor(); - g.fill(path); - } - - protected void fillOval(double h, double v, int width, int height) { - - Ellipse2D oval = new Ellipse2D.Float((float)(h-width/2.), (float)(v-height/2.), width, height); - updateColor(); - g.fill(oval); - } - - public void drawPolygon(double[] h, double[] v, int numPoints) { - - int type=getContainmentType(h, v, numPoints, POLYGON); - if(type==FULLY_INSIDE||type==INTERSECTS) { - if(type==INTERSECTS) { - ACoord clipped=clipper.clipPolygon(h, v, numPoints); - h=clipped.hv[0][0]; - v=clipped.hv[1][0]; - numPoints=h.length; - } - - path.reset(); - for(int i=0; i<numPoints; ++i) { - if(i==0) - path.moveTo((float)h[i], (float)v[i]); - else - path.lineTo((float)h[i], (float)v[i]); - } - if(numPoints>0) { - path.closePath(); - updateColor(); - g.draw(path); - } - } - } - - public void drawPolyline(double[] h, double[] v, int numPoints) { - int type=getContainmentType(h, v, numPoints, POLYLINE); - if(type==FULLY_INSIDE||type==INTERSECTS) { - int start=0; - int end=numPoints-1; - - if(type==INTERSECTS) { - // clip polylines if there is only one interval - for(int i=0; i<numPoints-1; i++) { - if(clipper.isLineWithin(h[i], v[i], h[i+1], v[i+1])) { - start=i; - break; - } - } - for(int i=numPoints-1; i>start; i--) { - if(clipper.isLineWithin(h[i], v[i], h[i-1], v[i-1])) { - end=i; - break; - } - } - for(int i=start; i<end; i++) { - if(!clipper.isLineWithin(h[i], v[i], h[i+1], v[i+1])) { - start=0; - end=numPoints-1; - break; - } - } - } - - /* - if (type == INTERSECTS) { - ACoord clipped = clipper.clipPolygon(h, v, numPoints); - h = clipped.hv[0][0]; - v = clipped.hv[1][0]; - numPoints = h.length; - } - */ - - path.reset(); - for(int i=start; i<=end; ++i) { - if(i==start) - path.moveTo((float)h[i], (float)v[i]); - else - path.lineTo((float)h[i], (float)v[i]); - } - if(end-start>0) { - updateColor(); - g.draw(path); - } - } - } - - // very similar with drawPolyline, but draw a dotted instead - public void drawDottedPolyline(double[] h, double[] v, int numPoints) { - int type=getContainmentType(h, v, numPoints, POLYLINE); - if(type==FULLY_INSIDE||type==INTERSECTS) { - int start=0; - int end=numPoints-1; - - if(type==INTERSECTS) { - // clip polylines if there is only one interval - for(int i=0; i<numPoints-1; i++) { - if(clipper.isLineWithin(h[i], v[i], h[i+1], v[i+1])) { - start=i; - break; - } - } - for(int i=numPoints-1; i>start; i--) { - if(clipper.isLineWithin(h[i], v[i], h[i-1], v[i-1])) { - end=i; - break; - } - } - for(int i=start; i<end; i++) { - if(!clipper.isLineWithin(h[i], v[i], h[i+1], v[i+1])) { - start=0; - end=numPoints-1; - break; - } - } - } - - path.reset(); - boolean drawFlag = false; - for(int i=start; i<=end; ++i) { - if(drawFlag) - path.lineTo((float)h[i], (float)v[i]); - else - path.moveTo((float)h[i], (float)v[i]); - drawFlag = !drawFlag; - } - if(end-start>0) { - updateColor(); - g.draw(path); - } - } - - } - - public void drawSmoothPolyline(double[] h0, double[] v0, int numPoints0) { - - // For curves having less than 3 points and for picking use the normal polyline. - if (numPoints0 < 3 || g instanceof APickingGraphics2D) { - drawPolyline(h0, v0, numPoints0); - return; - } - - int type = getContainmentType(h0, v0, numPoints0, POLYLINE); - if (type == FULLY_INSIDE || type == INTERSECTS) { - - GeneralPath curve = new GeneralPath(); - int numPoints = 3 * numPoints0 - 2; - - // Add the control points to the array, at 1/3 and 2/3 - // between the already existing points. - float[] h = new float[numPoints]; - float[] v = new float[numPoints]; - for (int i=0; i<numPoints; i++) { - - switch (i%3) { - case 0: - // One of the fixed points. - h[i] = (float)h0[i/3]; - v[i] = (float)v0[i/3]; - break; - case 1: - // First control point. - h[i] = (float)(2./3. * h0[i/3] + 1./3. * h0[i/3+1]); - v[i] = (float)(2./3. * v0[i/3] + 1./3. * v0[i/3+1]); - break; - case 2: - // Second control point. - h[i] = (float)(1./3. * h0[i/3] + 2./3. * h0[i/3+1]); - v[i] = (float)(1./3. * v0[i/3] + 2./3. * v0[i/3+1]); - break; - } - } - - // Now we have a normal polyline (straight line segments between fixed points), - // but as a cubic Bezier curve. All we need to do to make it smooth is to move - // the control points away from the curve, in such a way that [control point 2] - - // [fixed point] - [control point 1] is a straight line for every fixed point. - // We do this by averaging the angles of the line segments on either side of a - // fixed point. - for (int i=3; i<numPoints-2; i+=3) { - double lenLeft = Math.sqrt(Math.pow(h[i]-h[i-1], 2) + Math.pow(v[i]-v[i-1], 2)); - double lenRight = Math.sqrt(Math.pow(h[i+1]-h[i], 2) + Math.pow(v[i+1]-v[i], 2)); - - // Without length we cannot define an angle, so skip the point. - if (lenLeft < 1e-6 || lenRight < 1e-6) continue; - - double phiLeft = Math.atan2(v[i]-v[i-1], h[i]-h[i-1]); - double phiRight = Math.atan2(v[i+1]-v[i], h[i+1]-h[i]); - - if (phiLeft-phiRight > Math.PI) { - phiRight += 2.*Math.PI; - } else if (phiRight-phiLeft > Math.PI) { - phiLeft += 2.*Math.PI; - } - - if (Math.abs(phiLeft-phiRight) > Math.PI/2.) { - // The line turns more than 90 degrees, this is wrong. Move the control points - // back in so they are the same as the point on the line. This disables the smooth - // curve locally, reverting to a normal connect-the-dots polyline. - h[i-1] = h[i+1] = h[i]; - v[i-1] = v[i+1] = v[i]; - } else { - // Calculate the desired angle for the tangent by weighting the angle on each side, - // the weight is inverse proportional to the distance to the next point. - double phi = (lenRight*phiLeft + lenLeft*phiRight) / (lenLeft+lenRight); - - h[i-1] = h[i] - (float)(lenLeft*Math.cos(phi)); - v[i-1] = v[i] - (float)(lenLeft*Math.sin(phi)); - h[i+1] = h[i] + (float)(lenRight*Math.cos(phi)); - v[i+1] = v[i] + (float)(lenRight*Math.sin(phi)); - } - } - - curve.moveTo(h[0], v[0]); - for (int i=3; i<numPoints; i+=3) { - curve.curveTo(h[i-2], v[i-2], h[i-1], v[i-1], h[i], v[i]); - } - - updateColor(); - g.draw(curve); - } - } - - public void fillPolygon(double[] h, double[] v, int numPoints) { - int type=getContainmentType(h, v, numPoints, POLYGON); - if(type==FULLY_INSIDE||type==INTERSECTS) { - if(type==INTERSECTS) { - ACoord clipped=clipper.clipPolygon(h, v, numPoints); - h=clipped.hv[0][0]; - v=clipped.hv[1][0]; - numPoints=h.length; - } - path.reset(); - - for(int i=0; i<numPoints; ++i) - if(i==0) - path.moveTo((float)h[i], (float)v[i]); - else - path.lineTo((float)h[i], (float)v[i]); - if(numPoints>0) { - path.closePath(); - updateColor(); - g.fill(path); - g.draw(path); - } - } else if(type==CONTAINS) { - Rectangle bounds=g.getClipBounds(); - updateColor(); - g.fillRect((int)Math.rint(bounds.getX()), (int)Math.rint(bounds.getY()), - (int)Math.rint(bounds.getWidth()), (int)Math.rint(bounds.getHeight())); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/colormap/AColorMap.java b/graphics/AtlantisJava/src/atlantis/graphics/colormap/AColorMap.java deleted file mode 100755 index 423a613163a37a9d59f4793f023bc78b5f33ca11..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/colormap/AColorMap.java +++ /dev/null @@ -1,365 +0,0 @@ -package atlantis.graphics.colormap; - -import java.io.File; -import java.io.InputStream; -import java.awt.Color; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.NamedNodeMap; - -import atlantis.globals.AGlobals; -import atlantis.output.AExceptionHandler; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.APar; -import atlantis.utils.AUtilities; -import atlantis.utils.ALogger; -import atlantis.utils.xml.AXMLErrorHandler; - - -public final class AColorMap -{ - private static ALogger logger = ALogger.getLogger(AColorMap.class); - - private static final boolean VALIDATION = true; - final public static int NO_COLOR = -1; - final public static int INVISIBLE = -2; - static final public int BG = 8; //background - static final public int WH = 0; //white - static final public int GY = 14; //grey - static final public int RD = 20; //red - static final public int GN = 21; //green - static final public int BL = 22; //blue - static final public int YE = 23; //yellow - static final public int MA = 24; //magenta - static final public int CY = 25; //cyan - static final public int BK = 26; //black - static final public int OR = 27; //orange - static final public int CB = 28; //cornflower blue - private static final String[] mapNames = {"Default(1)", "Default(2)", "M4+M5", "GrayDet", - "Original", "Gray", "B/W", "HitCol", "GrayHitCol"}; - private static final String[] mapNamesPS = {"default1","default2","m4m5", "graydet", - "original", "gray", "bw", "hitcol", "grayhitcol"}; - private static MappedColor[][] maps; - private static int numColors; - private static int numMaps; - - // Color map indices. - public static final int COLOR_MAP_DEFAULT1 = 0; - public static final int COLOR_MAP_DEFAULT2 = 1; - public static final int COLOR_MAP_M4M5 = 2; - public static final int COLOR_MAP_GRAYDET = 3; - public static final int COLOR_MAP_ORIGINAL = 4; - public static final int COLOR_MAP_GRAY = 5; - public static final int COLOR_MAP_BW = 6; - public static final int COLOR_MAP_HITCOL = 7; - public static final int COLOR_MAP_GRAY_HITCOL = 8; - - //color map used if wrong value in config file - static int currentMap = COLOR_MAP_DEFAULT1; - - - public static void readColorMap(String name) - { - String fileName = null; - String FILE_SEPAR = System.getProperty("file.separator"); - - if(name != null && new File(name).canRead()) - { - // color map file specified as command line argument - fileName = name; - } - else - { - if(name != null) - { - logger.warn("Can't read color map file: " + name); - } - // color map file wasn't specified as command line argument - fileName = ".Atlantis-colormap.xml"; // default name - String fileNameFull = System.getProperty("user.home") + FILE_SEPAR + fileName; - if(new File(fileNameFull).canRead()) - { - // use existing user's color map file - fileName = fileNameFull; - } - else - { - // use default color map file from Atlantis distribution - fileName = AGlobals.instance().getHomeDirectory() + "configuration" + - FILE_SEPAR + "colormap.xml"; - } - } - - logger.info("Using color map file: " + fileName); - try - { - InputStream isColorMap = AUtilities.getFileAsStream(fileName); - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setValidating(VALIDATION); - DocumentBuilder parser = factory.newDocumentBuilder(); - parser.setErrorHandler(new AXMLErrorHandler()); - Node colormap = parser.parse(isColorMap).getDocumentElement(); - NamedNodeMap cm = colormap.getAttributes(); - numMaps = Integer.parseInt(cm.getNamedItem("numMaps").getNodeValue(). - trim()); - numColors = Integer.parseInt(cm.getNamedItem("numColors"). - getNodeValue().trim()); - maps = new MappedColor[numMaps][numColors]; - NodeList list = colormap.getChildNodes(); - int count = list.getLength(); - for(int i = 0; i < count; i++) - { - Node mapping = list.item(i); - if(mapping.getNodeType() == Node.ELEMENT_NODE) - { - NamedNodeMap atts = mapping.getAttributes(); - try - { - int map = Integer.parseInt(atts.getNamedItem("map"). - getNodeValue().trim()); - int index = Integer.parseInt(atts.getNamedItem("index"). - getNodeValue().trim()); - int r = Integer.parseInt(atts.getNamedItem("r"). - getNodeValue().trim()); - int g = Integer.parseInt(atts.getNamedItem("g"). - getNodeValue().trim()); - int b = Integer.parseInt(atts.getNamedItem("b"). - getNodeValue().trim()); - if(map < maps.length) - { - if(index < maps[map].length) - { - maps[map][index] = new MappedColor(r, g, b, - index); - } - } - } - catch(NumberFormatException e) - { - AExceptionHandler.processException("Colour map error:\n" + - mapping, e); - } - } // if - } // for - } - catch(Exception e) - { - AExceptionHandler.processException("Error while reading colour map:\n" + - fileName, e); - } - for(int i = 0; i < maps.length; i++) - { - for(int j = 0; j < maps[i].length; j++) - { - if(maps[i][j] == null) - { - AOutput.append("\nColorMap (" + i + "," + j + - ") is not present", - ALogInterface.BAD_COMMAND); - } - } - } - - } // readColorMap() ----------------------------------------------------- - - - - public static int getNumMaps() - { - return numMaps; - } - - - public static int getNumColors() - { - return numColors; - } - - - /** - * Returns color map in the XML format. - * [Former method writeColorMap() was writing the XML data directly into - * the file.] - * @return String - */ - public static String getColorMapXML() - { - StringBuffer buffer = new StringBuffer(); - // color map DTD - buffer.append( - "<?xml version=\"1.0\"?>\n" + - "<!DOCTYPE colormap [\n" + - " <!ELEMENT colormap (Mapping*)>" + - " <!ATTLIST colormap\n" + - " numMaps CDATA #REQUIRED\n" + - " numColors CDATA #REQUIRED>\n" + - " <!ELEMENT Mapping EMPTY>\n" + - " <!ATTLIST Mapping\n" + - " map CDATA #REQUIRED\n" + - " index CDATA #REQUIRED\n" + - " r CDATA #REQUIRED\n" + - " g CDATA #REQUIRED\n" + - " b CDATA #REQUIRED>\n" + - "]>\n\n\n"); - buffer.append("<colormap numMaps=\"" + maps.length + - "\" numColors=\"" + maps[0].length + "\" >\n"); - for(int i = 0; i < maps.length; i++) - { - for(int j = 0; j < maps[i].length; j++) - { - int r = maps[i][j].getRed(); - int g = maps[i][j].getGreen(); - int b = maps[i][j].getBlue(); - buffer.append(" <Mapping map=\"" + i + "\" index=\"" + j + - "\" r=\"" + r + "\" g=\"" + g + "\" b=\"" + - b + "\"/>\n"); - } - } - buffer.append("</colormap>\n"); - return buffer.toString(); - - } // getColorMapXML() --------------------------------------------------- - - - - public static String getPSPrologColorMap() - { - StringBuffer s = new StringBuffer(); - String newLine = System.getProperty("line.separator"); - s.append(newLine); - for(int i = 0; i < maps.length; ++i) - { - s.append("/" + mapNamesPS[i] + "ColorMap" + newLine); - s.append("<<" + newLine); - for(int j = 0; j < maps[i].length; ++j) - s.append(" /C" + j + " [" + - String.format("%.3f",maps[i][j].getRed() / 255.) + " " - + String.format("%.3f",maps[i][j].getGreen() / 255.) + " " + - String.format("%.3f",maps[i][j].getBlue() / 255.) - + "]" + newLine); - s.append(">> def" + newLine); - s.append(newLine); - } - return s.toString(); - - } // getPSPrologColorMap() ---------------------------------------------- - - - - public static Color[] getColors(int map) - { - Color[] col = new Color[maps[map].length]; - for(int i = 0; i < col.length; ++i) - col[i] = (Color) maps[map][i]; - return col; - } - - //From hot (red), index 255, to cold (blue), index 0 - public static Color[] getShades(int num) - { - assert (num>=2); - Color[] col = new Color[num]; - col[0]=new Color(170,170,170);//grey for "other" - for(int i = 1; i < num-1; ++i) - col[i] = new Color(((255*i)/num),80,255-((255*i)/num)); - return col; - } - - public static Color[] getColors() - { - return getColors(currentMap); - } - - - public static void setColorMap(int map) - { - if(map >= 0 && map < maps.length) - { - currentMap = map; - APar parameterStore = APar.instance(); - parameterStore.get("Prefs","ColorMap").setI(map); - } - } - - - public static void setColorMap(String mapName) - { - for(int i = 0; i < mapNames.length; i++) - if(mapNames[i].equals(mapName)) - setColorMap(i); - } - - - public static int getColorMap() - { - return currentMap; - } - - public static boolean drawFrames() - { - if(currentMap==COLOR_MAP_GRAY || currentMap==COLOR_MAP_BW) - return true; - else - return false; - } - - public static String getPSColorMapName() - { - return mapNamesPS[getColorMap()]; - - } // getPSColorMapName() ------------------------------------------------ - - - public MappedColor getMappedColor(int colorIndex) - { - if(colorIndex < 0 && colorIndex >= maps[currentMap].length) - { - return null; - } - else - { - return maps[currentMap][colorIndex]; - } - } - - - public Color getColor(int colorIndex) - { - if(colorIndex < 0 && colorIndex >= maps[currentMap].length) - { - return null; - } - else - { - return(Color) maps[currentMap][colorIndex]; - } - } - - - public static String getTag(int colorIndex) - { - if(colorIndex < 0 && colorIndex >= maps[0].length) - { - return null; - } - else - { - return "C" + colorIndex; - } - } - - - public static String[] getMapNames() - { - return(String[]) mapNames.clone(); - } - - public static MappedColor[][] getMaps() { - return maps; - } - -} // class AColorMap ======================================================== diff --git a/graphics/AtlantisJava/src/atlantis/graphics/colormap/MappedColor.java b/graphics/AtlantisJava/src/atlantis/graphics/colormap/MappedColor.java deleted file mode 100755 index 53ace099fe82ef30ec9b4688dccd3dafca1fbdaf..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/colormap/MappedColor.java +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2000, CERN, Geneva, Switzerland and University of Santa Cruz, California, U.S.A. -package atlantis.graphics.colormap; - - -import java.awt.Color; - - -/** - * - * @author Charles Loomis - **/ -public class MappedColor extends java.awt.Color { - - /** - * Index of the color in the color map. */ - protected int colorIndex; - - /** - * Value of the brightness/darkness of this color. Larger values - * indicate darker colors and vice versa. */ - protected int brightness; - - /** - * Constructor takes the RGB color components and the color index. */ - public MappedColor(int r, int g, int b, - int colorIndex) { - - // Call the Color constructor. - super(r, g, b); - - // Set the color index and brightness. - this.colorIndex=colorIndex; - brightness=0; - } - - /** - * Constructor takes the RGB color components, the color index, - * and the brightness. */ - public MappedColor(int r, int g, int b, - int colorIndex, - int brightness) { - - // Call the Color constructor. - super(r, g, b); - - // Set the color index and brightness. - this.colorIndex=colorIndex; - this.brightness=brightness; - } - - /** - * Make a brightened color based on this color. */ - public Color brighter() { - - int r=getRed()*10/7; - int g=getGreen()*10/7; - int b=getBlue()*10/7; - - r=Math.max(0, Math.min(255, r)); - g=Math.max(0, Math.min(255, g)); - b=Math.max(0, Math.min(255, b)); - - return (Color)new MappedColor(r, g, b, colorIndex, brightness-1); - } - - /** - * Make a darkened color based on this color. */ - public Color darker() { - - int r=getRed()*7/10; - int g=getGreen()*7/10; - int b=getBlue()*7/10; - - r=Math.max(0, Math.min(255, r)); - g=Math.max(0, Math.min(255, g)); - b=Math.max(0, Math.min(255, b)); - - return (Color)new MappedColor(r, g, b, colorIndex, brightness-1); - } - - /** - * Get the brightness of this color. */ - public int getBrightness() { - return brightness; - } - - /** - * Get the tag associated with this color. */ - public String getColorTag() { - return AColorMap.getTag(colorIndex); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/dnd/ACallBack.java b/graphics/AtlantisJava/src/atlantis/graphics/dnd/ACallBack.java deleted file mode 100755 index 5cc4ec0a64c44f2e55b3694531f89eb1124bfb50..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/dnd/ACallBack.java +++ /dev/null @@ -1,9 +0,0 @@ -package atlantis.graphics.dnd; - - -/** - * Used in the Drag and Drop operations. - */ -public interface ACallBack { - void callBack(Object from); -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/dnd/ADnDButton.java b/graphics/AtlantisJava/src/atlantis/graphics/dnd/ADnDButton.java deleted file mode 100755 index f637b28172b4b5529eb3964fe8fc0af8d01a17ef..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/dnd/ADnDButton.java +++ /dev/null @@ -1,88 +0,0 @@ -package atlantis.graphics.dnd; - -import java.awt.Point; -import java.awt.Graphics; -import javax.swing.JButton; -import java.awt.image.BufferedImage; -import java.awt.dnd.DragSourceDropEvent; -import java.awt.dnd.DragSourceListener; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DragGestureListener; -import java.awt.dnd.DragGestureEvent; -import java.awt.dnd.DragSource; -import java.awt.dnd.DragSourceDragEvent; -import java.awt.dnd.DragSourceEvent; -import java.util.Vector; - -/** - * A button wich has Drag and Drop support ( see java.awt.dnd.*) - * Used by the rubberbands. - */ - -public class ADnDButton extends JButton - implements DragSourceListener, DragGestureListener, ACallBack { - - private DragSource dragSource; - private Vector dragListeners; - - public ADnDButton(String name) { - super(name); - setName(name); - - dragSource=DragSource.getDefaultDragSource(); - dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this); - - dragListeners=new Vector(); - } - - // implementation of DragSourceListener - - // This method is invoked to signify that the Drag and Drop operation is complete. - public void dragDropEnd(DragSourceDropEvent dsde) {} - - // Called as the hotspot enters a platform dependent drop site. - public void dragEnter(DragSourceDragEvent dsde) { - dsde.getDragSourceContext().setCursor(ADnDLabel.DROP_VALID); - } - - // Called as the hotspot exits a platform dependent drop site. - public void dragExit(DragSourceEvent dse) { - dse.getDragSourceContext().setCursor(ADnDLabel.DROP_INVALID); - } - - // Called as the hotspot moves over a platform dependent drop site. - public void dragOver(DragSourceDragEvent dsde) { - dsde.getDragSourceContext().setCursor(ADnDLabel.DROP_VALID); - } - - // Called when the user has modified the drop gesture. - public void dropActionChanged(DragSourceDragEvent dsde) {} - - // implementation of DragGestureListener - - public void dragGestureRecognized(DragGestureEvent dge) { - BufferedImage resizeCursorImage=new BufferedImage(64, 64, BufferedImage.TYPE_4BYTE_ABGR); - - Graphics g=resizeCursorImage.getGraphics(); - - g.drawLine(0, 0, 64, 64); - g.dispose(); - - // return Toolkit.getDefaultToolkit().createCustomCursor(resizeCursorImage, center, "resize") - - - AObjectTransferable cbt=new AObjectTransferable(this); - - dragSource.startDrag(dge, ADnDLabel.DROP_INVALID, resizeCursorImage, new Point(0, 0), cbt, this); - } - - public void callBack(Object to) { - for(int i=0; i<dragListeners.size(); i++) - ((ADragListener)dragListeners.get(i)).dragPerformed(this, to, -1); - } - - public void addDragListener(ADragListener l) { - dragListeners.addElement(l); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/dnd/ADnDLabel.java b/graphics/AtlantisJava/src/atlantis/graphics/dnd/ADnDLabel.java deleted file mode 100755 index 2b1873f55637307b2d0a3f268accf21cbc92bf91..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/dnd/ADnDLabel.java +++ /dev/null @@ -1,184 +0,0 @@ -package atlantis.graphics.dnd; - -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DragGestureEvent; -import java.awt.dnd.DragGestureListener; -import java.awt.dnd.DragSource; -import java.awt.dnd.DragSourceDragEvent; -import java.awt.dnd.DragSourceDropEvent; -import java.awt.dnd.DragSourceEvent; -import java.awt.dnd.DragSourceListener; -import java.awt.dnd.DropTarget; -import java.awt.dnd.DropTargetDragEvent; -import java.awt.dnd.DropTargetDropEvent; -import java.awt.dnd.DropTargetEvent; -import java.awt.dnd.DropTargetListener; -import java.util.Vector; - -import javax.swing.JLabel; - -import atlantis.graphics.ACursorFactory; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; - -/** - * A label which has Drag and Drop support. - * Used in the Window Control. - */ -public class ADnDLabel extends JLabel -implements DropTargetListener, DragSourceListener, DragGestureListener { - - private DragSource dragSource=null; - private Vector dragListeners; - private boolean dragHighlight; - private String[] page; - - public JLabel getLabel() { - return this; - } - - public static final Cursor DROP_VALID; - public static final Cursor DROP_INVALID; - - static { - /* if(Toolkit.getDefaultToolkit().getBestCursorSize(64, 64).equals(new Dimension(64, 64))) { - DROP_VALID=Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit().getImage(Atlantis.getHomeDirectory() - +"img"+Atlantis.fileSep+"cursor_DnD_valid_64x64.gif"), - new Point(1, 1), "ValidDnD"); - DROP_INVALID=Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit().getImage(Atlantis.getHomeDirectory() - +"img"+Atlantis.fileSep+"cursor_DnD_invalid_64x64.gif"), - new Point(9, 9), "InvalidDnD"); - } else { - DROP_VALID=DragSource.DefaultMoveDrop; - DROP_INVALID=DragSource.DefaultMoveNoDrop; - } */ - DROP_VALID = ACursorFactory.getInstance().getDragValidCursor(); - DROP_INVALID = ACursorFactory.getInstance().getDragInvalidCursor(); - } - - public ADnDLabel(String name, boolean dragHighlight) { - super(name, JLabel.CENTER); - setName(name); - setOpaque(true); - page=null; - this.dragHighlight=dragHighlight; - - dragSource=new DragSource(); - dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this); - this.setDropTarget(new DropTarget(this, this)); - dragListeners=new Vector(); - } - - public ADnDLabel(String name, String[] wnames, boolean dragHighlight) { - super(name, JLabel.CENTER); - setName(name); - setOpaque(true); - page=wnames; - this.dragHighlight=dragHighlight; - - dragSource=new DragSource(); - dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this); - this.setDropTarget(new DropTarget(this, this)); - dragListeners=new Vector(); - } - - public Dimension getPreferredSize() { - return new Dimension(15, 15); - } - - // implementation of DropTargetListener - - private Color old; - - // Called when a drag operation has encountered the DropTarget. - public void dragEnter(DropTargetDragEvent dtde) { - dtde.acceptDrag(DnDConstants.ACTION_MOVE); - if(dragHighlight) { - old=getBackground(); - setBackground(new Color(150, 150, 150)); - } - } - - // The drag operation has departed the DropTarget without dropping. - public void dragExit(DropTargetEvent dte) { - if(dragHighlight) - setBackground(old); - } - - // Called when a drag operation is ongoing on the DropTarget. - public void dragOver(DropTargetDragEvent dtde) { - } - - // The drag operation has terminated with a drop on this DropTarget. - public void drop(DropTargetDropEvent dtde) { - try { - Transferable transferable=dtde.getTransferable(); - DataFlavor javaObjectDataFlavor=new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType); - - if(transferable.isDataFlavorSupported(javaObjectDataFlavor)) { - dtde.acceptDrop(DnDConstants.ACTION_MOVE); - Object object=transferable.getTransferData(javaObjectDataFlavor); - - if(object instanceof ACallBack) - ((ACallBack)object).callBack(this); - else - fireDragEvent(object); - dtde.getDropTargetContext().dropComplete(true); - } else - AOutput.append("Cannot accept drop\n", ALogInterface.BAD_COMMAND); - } catch(Exception e) { - e.printStackTrace(); - dtde.rejectDrop(); - } - } - - private void fireDragEvent(Object from) { - for(int i=0; i<dragListeners.size(); i++) - ((ADragListener)dragListeners.get(i)).dragPerformed(from, this, -1); - } - - // Called if the user has modified the current drop gesture. - public void dropActionChanged(DropTargetDragEvent dtde) {} - - // implementation of DragSourceListener - - // This method is invoked to signify that the Drag and Drop operation is complete. - public void dragDropEnd(DragSourceDropEvent dsde) {} - - // Called as the hotspot enters a platform dependent drop site. - public void dragEnter(DragSourceDragEvent dsde) { - dsde.getDragSourceContext().setCursor(DROP_VALID); - } - - // Called as the hotspot exits a platform dependent drop site. - public void dragExit(DragSourceEvent dse) { - dse.getDragSourceContext().setCursor(DROP_INVALID); - } - - // Called as the hotspot moves over a platform dependent drop site. - public void dragOver(DragSourceDragEvent dsde) { - dsde.getDragSourceContext().setCursor(DROP_VALID); - } - - // Called when the user has modified the drop gesture. - public void dropActionChanged(DragSourceDragEvent dsde) {} - - // implementation of DragGestureListener - public void dragGestureRecognized(DragGestureEvent dge) { - dragSource.startDrag(dge, DROP_VALID, new AObjectTransferable(this), this); - } - - public void addDragListener(ADragListener l) { - dragListeners.addElement(l); - } - - public String[] returnPageName() - { - return page; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/dnd/ADragListener.java b/graphics/AtlantisJava/src/atlantis/graphics/dnd/ADragListener.java deleted file mode 100755 index 429b9a0af1441242ac757d288cfec4c33e52b93d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/dnd/ADragListener.java +++ /dev/null @@ -1,9 +0,0 @@ -package atlantis.graphics.dnd; - - -/** - * The listener to drag operations. It is suported by ADnDLabel and ADnDButton. - */ -public interface ADragListener { - void dragPerformed(Object from, Object to, int action); -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/dnd/AObjectTransferable.java b/graphics/AtlantisJava/src/atlantis/graphics/dnd/AObjectTransferable.java deleted file mode 100755 index d823077f674bc9013561559c8867629d230e4a09..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/dnd/AObjectTransferable.java +++ /dev/null @@ -1,62 +0,0 @@ -package atlantis.graphics.dnd; - - -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; - - -/** - * Used by Drag and Drop - * A implementation of a transferable which - * transfers an Java object (really an pointer to it). - */ -public class AObjectTransferable implements Transferable { - private Object object; - - /** - * Creates the Transferable which will transfer the specified object. - * @param object The object to be transferred - */ - public AObjectTransferable(Object object) { - this.object=object; - } - - /** - * Returns the transferred for a specific DataFlavor. - * @param flavor The DataFlavor for which to get the transferred object. - * @return The transferred object. - */ - public Object getTransferData(DataFlavor flavor) { - return object; - } - - /** - * Returns an array of DataFlavor objects indicating the flavors the - * data can be provided in. - * @return The set of available flavors. - */ - public DataFlavor[] getTransferDataFlavors() { - DataFlavor df=null; - - try { - df=new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType); - } catch(ClassNotFoundException e) { - throw new Error("Cannot create DataFlavor.javaJVMLocalObjectMimeType "+e.getMessage()); - } - return new DataFlavor[] {df}; - } - - /** - * Returns whether or not the specified data flavor is - * supported by this transferable. - * @param flavor The data flavor that needs to be checked - * @return True if the flavor is supported. False Otherwise. - */ - public boolean isDataFlavorSupported(DataFlavor flavor) { - if(flavor.getHumanPresentableName().equals(DataFlavor.javaJVMLocalObjectMimeType)) - return true; - else - return false; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/encoders/AImageEncoder.java b/graphics/AtlantisJava/src/atlantis/graphics/encoders/AImageEncoder.java deleted file mode 100644 index a27b4f07d8b19157278619cbd10a522a1ef1df20..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/encoders/AImageEncoder.java +++ /dev/null @@ -1,167 +0,0 @@ -package atlantis.graphics.encoders; - -import atlantis.canvas.ACanvas; -import atlantis.utils.ALogger; - -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.File; -import java.io.FileOutputStream; -import java.io.BufferedOutputStream; - -import org.apache.batik.dom.svg.SVGDOMImplementation; -import org.apache.batik.svggen.SVGGraphics2D; - -import org.sourceforge.jlibeps.epsgraphics.*; -import org.w3c.dom.*; -import org.w3c.dom.svg.SVGDocument; - -/** - * Takes the image drawn on the canvas and encodes it in the given format - * @author sboeser - */ -public class AImageEncoder { - - //The logger - private final static ALogger logger = ALogger.getLogger(AImageEncoder.class); - - /** - * Grabs canvas and encodes the data in PNG format. - * @param imageWidth resulting image width - * @param imageHeight resulting image height - * @return byte[] - */ - public byte[] getPNGData(int imageWidth, int imageHeight){ - - // Draw image - Image image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_ARGB); - ACanvas.getCanvas().drawScaledCanvas(image.getGraphics(), imageWidth, imageHeight, "png"); - - // Encode as PNG. - PngEncoder encoder = new PngEncoder(image, true, PngEncoder.FILTER_NONE, 9); - byte[] data = encoder.pngEncode(); - return data; - - } - - /** - * Get a scaled version of the PNG image - mostly used to create thumbnails - * NOTE: in contrast to getPNGData, this will first create the image with given - * width and height and then scale everything (including window - * borders, title bar, etc...) - * @param width image width before scaling - * @param height image height before scaling - * @param scale the scale factor - * @return the PNG data - */ - public byte[] getScaledPNGData(int width, int height, double scale){ - - // Draw a temporary full-size image - Image inputImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - ACanvas.getCanvas().drawScaledCanvas(inputImage.getGraphics(), width, height, "png"); - - //Calculate target height keeping aspect ratio - int targetHeight = (int)(scale*height); - int targetWidth = (int)(scale*width); - - - /** - * Now rescale the image in steps - do not use Image.getScaledInstance, - * which is outdated and way to slow! - */ - - while (inputImage.getWidth(null) != targetWidth){ - - //Resize by no more than a factor of two in one step - if (inputImage.getWidth(null)/targetWidth > 2. ){ - width = (int)(inputImage.getWidth(null)/2.); - height = (int)(inputImage.getHeight(null)/2.); - } else { - width = targetWidth; - height = targetHeight; - } - - //log for debugging - logger.debug("Rescaling image from "+inputImage.getWidth(null)+"x"+inputImage.getHeight(null)+ - " to "+width+"x"+height); - - //Now redraw that to the scaled image - BufferedImage scaledImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Graphics2D scaledGraphics = scaledImage.createGraphics(); - scaledGraphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BICUBIC); - scaledGraphics.drawImage(inputImage, 0, 0, width, height, null); - scaledGraphics.dispose(); - - //Provide the scaled image as new input in case we need to rescale once more - inputImage = scaledImage; - } - - // Encode as PNG. - PngEncoder encoder = new PngEncoder(inputImage, true, PngEncoder.FILTER_NONE, 9); - byte[] data = encoder.pngEncode(); - return data; - - } - - - /** - * Grab canvas, encode the information as EPS and save to a file - * @param imageWidth image width - * @param imageHeight image height - * @param saveFile save file - */ - - public void saveEPS(int imageWidth, int imageHeight, File saveFile) throws IOException{ - - //Create the output stream - FileOutputStream fos = new FileOutputStream(saveFile); - BufferedOutputStream bos = new BufferedOutputStream(fos); - - // Create a new postscript graphics object - EpsGraphics2D g = new EpsGraphics2D("Atlantis",bos,0,0,imageWidth,imageHeight); - // Draw text as shapes - g.setAccurateTextMode(true); - // Draw into the postscript graphics - ACanvas.getCanvas().drawScaledCanvas(g, imageWidth, imageHeight, "eps"); - g.flush(); - g.close(); - fos.close(); - bos.close(); - - } - - /** - * Grab canvas, encode the information as SVG and save to a file - * @param imageWidth image width - * @param imageHeight image height - * @param saveFile save file - */ - - public void saveSVG(int imageWidth, int imageHeight, File saveFile) throws IOException{ - - // Document Object Model to define our SVG Document - DOMImplementation domImpl = - SVGDOMImplementation.getDOMImplementation(); - - // We need to write the SVG into a Document - String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; - SVGDocument doc = (SVGDocument) domImpl.createDocument(svgNS, "svg", null); - - // Construct an SVGGraphics2D from our Document - SVGGraphics2D g = new SVGGraphics2D(doc); - - g.setSVGCanvasSize(new Dimension(imageWidth, imageHeight)); - - // Paint the scaled Canvas onto our SVG Graphics2D - ACanvas.getCanvas().drawScaledCanvas(g, imageWidth, imageHeight, "svg"); - - // Stream the output into our chosen file - g.stream(saveFile.getAbsolutePath()); - - - } -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/encoders/PngEncoder.java b/graphics/AtlantisJava/src/atlantis/graphics/encoders/PngEncoder.java deleted file mode 100755 index a9c7b5aa61b30677fea0d3996970d8d60bb155df..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/encoders/PngEncoder.java +++ /dev/null @@ -1,582 +0,0 @@ -package atlantis.graphics.encoders; - -// package com.keypoint; - - -import java.awt.*; -import java.awt.image.*; -import java.util.zip.*; -import java.io.*; - -/** - * PngEncoder takes a Java Image object and creates a byte string which can be saved as a PNG file. - * The Image is presumed to use the DirectColorModel. - * - * Thanks to Jay Denny at KeyPoint Software - * http://www.keypoint.com/ - * who let me develop this code on company time. - * - * You may contact me with (probably very-much-needed) improvements, - * comments, and bug fixes at: - * - * david@catcode.com - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * A copy of the GNU LGPL may be found at - * http://www.gnu.org/copyleft/lesser.html, - * - * @author J. David Eisenberg - * @version 1.4, 31 March 2000 - * - * Added ImageObserver so that getHeight, getWidth calls work properly. - * - * @author M.Donszelmann - */ -public class PngEncoder extends Object implements ImageObserver { - - /** Constant specifying that alpha channel should be encoded. */ - public static final boolean ENCODE_ALPHA=true; - - /** Constant specifying that alpha channel should not be encoded. */ - public static final boolean NO_ALPHA=false; - - /** Constants for filters */ - public static final int FILTER_NONE=0; - public static final int FILTER_SUB=1; - public static final int FILTER_UP=2; - public static final int FILTER_LAST=2; - - protected byte[] pngBytes; - protected byte[] priorRow; - protected byte[] leftBytes; - protected Image image; - protected int width, height; - protected int bytePos, maxPos; - protected int hdrPos, dataPos, endPos; - protected CRC32 crc=new CRC32(); - protected long crcValue; - protected boolean encodeAlpha; - protected int filter; - protected int bytesPerPixel; - protected int compressionLevel; - - public PngEncoder() { - this(null, false, FILTER_NONE, 0); - } - - /** - * Class constructor specifying Image to encode, with no alpha channel encoding. - * - * @param image A Java Image object which uses the DirectColorModel - * @see java.awt.Image - */ - public PngEncoder(Image image) { - this(image, false, FILTER_NONE, 0); - } - - /** - * Class constructor specifying Image to encode, and whether to encode alpha. - * - * @param image A Java Image object which uses the DirectColorModel - * @param encodeAlpha Encode the alpha channel? false=no; true=yes - * @see java.awt.Image - */ - public PngEncoder(Image image, boolean encodeAlpha) { - this(image, encodeAlpha, FILTER_NONE, 0); - } - - /** - * Class constructor specifying Image to encode, whether to encode alpha, and filter to use. - * - * @param image A Java Image object which uses the DirectColorModel - * @param encodeAlpha Encode the alpha channel? false=no; true=yes - * @param whichFilter 0=none, 1=sub, 2=up - * @see java.awt.Image - */ - public PngEncoder(Image image, boolean encodeAlpha, int whichFilter) { - this(image, encodeAlpha, whichFilter, 0); - } - - /** - * Class constructor specifying Image source to encode, whether to encode alpha, filter to use, and compression level. - * - * @param image A Java Image object - * @param encodeAlpha Encode the alpha channel? false=no; true=yes - * @param whichFilter 0=none, 1=sub, 2=up - * @param compLevel 0..9 - * @see java.awt.Image - */ - public PngEncoder(Image image, boolean encodeAlpha, int whichFilter, - int compLevel) { - this.image=image; - this.encodeAlpha=encodeAlpha; - setFilter(whichFilter); - if(compLevel>=0&&compLevel<=9) { - this.compressionLevel=compLevel; - } - } - - /** - * Set the image to be encoded - * - * @param image A Java Image object which uses the DirectColorModel - * @see java.awt.Image - */ - public void setImage(Image image) { - this.image=image; - pngBytes=null; - } - - /** method to wait for image */ - private int imageStatus; - - public boolean imageUpdate(Image image, int flags, int x, int y, int width, int height) { - imageStatus=flags; - if(((flags&ALLBITS)==ALLBITS)||((flags&(ABORT|ERROR))!=0)) { - return false; - } - return true; - } - - /** - * Creates an array of bytes that is the PNG equivalent of the current image, specifying whether to encode alpha or not. - * - * @param encodeAlpha boolean false=no alpha, true=encode alpha - * @return an array of bytes, or null if there was a problem - */ - public byte[] pngEncode(boolean encodeAlpha) { - byte[] pngIdBytes= { -119, 80, 78, 71, 13, 10, 26, 10 }; - - if(image==null) { - return null; - } - - imageStatus=0; - boolean status=Toolkit.getDefaultToolkit().prepareImage(image, -1, -1, this); - - if(!status) { - while(((imageStatus&(ALLBITS))==0)&&((imageStatus&(ABORT|ERROR))==0)) { - try { - Thread.sleep(100); - } catch(Exception e) {} - } - // FIXED: moved this inside the "if (!status)" area - if((imageStatus&(ALLBITS))==0) { - return null; - } - } - - width=image.getWidth(null); - height=image.getHeight(null); - - /* - * start with an array that is big enough to hold all the pixels - * (plus filter bytes), and an extra 200 bytes for header info - */ - pngBytes=new byte[((width+1)*height*3)+200]; - - /* - * keep track of largest byte written to the array - */ - maxPos=0; - - bytePos=writeBytes(pngIdBytes, 0); - hdrPos=bytePos; - writeHeader(); - dataPos=bytePos; - if(writeImageData()) { - writeEnd(); - pngBytes=resizeByteArray(pngBytes, maxPos); - } else { - pngBytes=null; - } - return pngBytes; - } - - /** - * Creates an array of bytes that is the PNG equivalent of the current image. - * Alpha encoding is determined by its setting in the constructor. - * - * @return an array of bytes, or null if there was a problem - */ - public byte[] pngEncode() { - return pngEncode(encodeAlpha); - } - - /** - * Set the alpha encoding on or off. - * - * @param encodeAlpha false=no, true=yes - */ - public void setEncodeAlpha(boolean encodeAlpha) { - this.encodeAlpha=encodeAlpha; - } - - /** - * Retrieve alpha encoding status. - * - * @return boolean false=no, true=yes - */ - public boolean getEncodeAlpha() { - return encodeAlpha; - } - - /** - * Set the filter to use - * - * @param whichFilter from constant list - */ - public void setFilter(int whichFilter) { - this.filter=FILTER_NONE; - if(whichFilter<=FILTER_LAST) { - this.filter=whichFilter; - } - } - - /** - * Retrieve filtering scheme - * - * @return int (see constant list) - */ - public int getFilter() { - return filter; - } - - /** - * Set the compression level to use - * - * @param level 0 through 9 - */ - public void setCompressionLevel(int level) { - if(level>=0&&level<=9) { - this.compressionLevel=level; - } - } - - /** - * Retrieve compression level - * - * @return int in range 0-9 - */ - public int getCompressionLevel() { - return compressionLevel; - } - - /** - * Increase or decrease the length of a byte array. - * - * @param array The original array. - * @param newLength The length you wish the new array to have. - * @return Array of newly desired length. If shorter than the - * original, the trailing elements are truncated. - */ - protected byte[] resizeByteArray(byte[] array, int newLength) { - byte[] newArray=new byte[newLength]; - int oldLength=array.length; - - System.arraycopy(array, 0, newArray, 0, Math.min(oldLength, newLength)); - return newArray; - } - - /** - * Write an array of bytes into the pngBytes array. - * Note: This routine has the side effect of updating - * maxPos, the largest element written in the array. - * The array is resized by 1000 bytes or the length - * of the data to be written, whichever is larger. - * - * @param data The data to be written into pngBytes. - * @param offset The starting point to write to. - * @return The next place to be written to in the pngBytes array. - */ - protected int writeBytes(byte[] data, int offset) { - maxPos=Math.max(maxPos, offset+data.length); - if(data.length+offset>pngBytes.length) { - pngBytes=resizeByteArray(pngBytes, pngBytes.length+Math.max(1000, data.length)); - } - System.arraycopy(data, 0, pngBytes, offset, data.length); - return offset+data.length; - } - - /** - * Write an array of bytes into the pngBytes array, specifying number of bytes to write. - * Note: This routine has the side effect of updating - * maxPos, the largest element written in the array. - * The array is resized by 1000 bytes or the length - * of the data to be written, whichever is larger. - * - * @param data The data to be written into pngBytes. - * @param nBytes The number of bytes to be written. - * @param offset The starting point to write to. - * @return The next place to be written to in the pngBytes array. - */ - protected int writeBytes(byte[] data, int nBytes, int offset) { - maxPos=Math.max(maxPos, offset+nBytes); - if(nBytes+offset>pngBytes.length) { - pngBytes=resizeByteArray(pngBytes, pngBytes.length+Math.max(1000, nBytes)); - } - System.arraycopy(data, 0, pngBytes, offset, nBytes); - return offset+nBytes; - } - - /** - * Write a two-byte integer into the pngBytes array at a given position. - * - * @param n The integer to be written into pngBytes. - * @param offset The starting point to write to. - * @return The next place to be written to in the pngBytes array. - */ - protected int writeInt2(int n, int offset) { - byte[] temp= { (byte)((n>>8)&0xff), (byte)(n&0xff) }; - return writeBytes(temp, offset); - } - - /** - * Write a four-byte integer into the pngBytes array at a given position. - * - * @param n The integer to be written into pngBytes. - * @param offset The starting point to write to. - * @return The next place to be written to in the pngBytes array. - */ - protected int writeInt4(int n, int offset) { - byte[] temp= { (byte)((n>>24)&0xff), (byte)((n>>16)&0xff), (byte)((n>>8)&0xff), (byte)(n&0xff) }; - return writeBytes(temp, offset); - } - - /** - * Write a single byte into the pngBytes array at a given position. - * - * @param b The integer to be written into pngBytes. - * @param offset The starting point to write to. - * @return The next place to be written to in the pngBytes array. - */ - protected int writeByte(int b, int offset) { - byte[] temp= { (byte)b }; - return writeBytes(temp, offset); - } - - /** - * Write a string into the pngBytes array at a given position. - * This uses the getBytes method, so the encoding used will - * be its default. - * - * @param s The string to be written into pngBytes. - * @param offset The starting point to write to. - * @return The next place to be written to in the pngBytes array. - * @see java.lang.String#getBytes() - */ - protected int writeString(String s, int offset) { - return writeBytes(s.getBytes(), offset); - } - - /** - * Write a PNG "IHDR" chunk into the pngBytes array. - */ - protected void writeHeader() { - int startPos; - - startPos=bytePos=writeInt4(13, bytePos); - bytePos=writeString("IHDR", bytePos); - width=image.getWidth(null); - height=image.getHeight(null); - bytePos=writeInt4(width, bytePos); - bytePos=writeInt4(height, bytePos); - bytePos=writeByte(8, bytePos); // bit depth - bytePos=writeByte((encodeAlpha)?6:2, bytePos); // direct model - bytePos=writeByte(0, bytePos); // compression method - bytePos=writeByte(0, bytePos); // filter method - bytePos=writeByte(0, bytePos); // no interlace - crc.reset(); - crc.update(pngBytes, startPos, bytePos-startPos); - crcValue=crc.getValue(); - bytePos=writeInt4((int)crcValue, bytePos); - } - - /** - * Perform "sub" filtering on the given row. - * Uses temporary array leftBytes to store the original values - * of the previous pixels. The array is 16 bytes long, which - * will easily hold two-byte samples plus two-byte alpha. - * - * @param pixels The array holding the scan lines being built - * @param startPos Starting position within pixels of bytes to be filtered. - * @param width Width of a scanline in pixels. - */ - protected void filterSub(byte[] pixels, int startPos, int width) { - int i; - int offset=bytesPerPixel; - int actualStart=startPos+offset; - int nBytes=width*bytesPerPixel; - int leftInsert=offset; - int leftExtract=0; - - for(i=actualStart; i<startPos+nBytes; i++) { - leftBytes[leftInsert]=pixels[i]; - pixels[i]=(byte)((pixels[i]-leftBytes[leftExtract])%256); - leftInsert=(leftInsert+1)%0x0f; - leftExtract=(leftExtract+1)%0x0f; - } - } - - /** - * Perform "up" filtering on the given row. - * Side effect: refills the prior row with current row - * - * @param pixels The array holding the scan lines being built - * @param startPos Starting position within pixels of bytes to be filtered. - * @param width Width of a scanline in pixels. - */ - protected void filterUp(byte[] pixels, int startPos, int width) { - int i, nBytes; - byte current_byte; - - nBytes=width*bytesPerPixel; - - for(i=0; i<nBytes; i++) { - current_byte=pixels[startPos+i]; - pixels[startPos+i]=(byte)((pixels[startPos+i]-priorRow[i])%256); - priorRow[i]=current_byte; - } - } - - /** - * Write the image data into the pngBytes array. - * This will write one or more PNG "IDAT" chunks. In order - * to conserve memory, this method grabs as many rows as will - * fit into 32K bytes, or the whole image; whichever is less. - * - * - * @return true if no errors; false if error grabbing pixels - */ - protected boolean writeImageData() { - int rowsLeft=height; // number of rows remaining to write - int startRow=0; // starting row to process this time through - int nRows; // how many rows to grab at a time - - byte[] scanLines; // the scan lines to be compressed - int scanPos; // where we are in the scan lines - int startPos; // where this line's actual pixels start (used for filtering) - - byte[] compressedLines; // the resultant compressed lines - int nCompressed; // how big is the compressed area? - - PixelGrabber pg; - - bytesPerPixel=(encodeAlpha)?4:3; - - Deflater scrunch=new Deflater(compressionLevel); - ByteArrayOutputStream outBytes=new ByteArrayOutputStream(1024); - - DeflaterOutputStream compBytes=new DeflaterOutputStream(outBytes, scrunch); - try { - while(rowsLeft>0) { - nRows=Math.min(32767/(width*(bytesPerPixel+1)), rowsLeft); - // nRows = rowsLeft; - int[] pixels=new int[width*nRows]; - - pg=new PixelGrabber(image, 0, startRow, width, nRows, pixels, 0, width); - try { - pg.grabPixels(); - } catch(Exception e) { - System.err.println("interrupted waiting for pixels!"); - return false; - } - if((pg.getStatus()&ImageObserver.ABORT)!=0) { - System.err.println("image fetch aborted or errored"); - return false; - } - - /* - * Create a data chunk. scanLines adds "nRows" for - * the filter bytes. - */ - scanLines=new byte[width*nRows*bytesPerPixel+nRows]; - - if(filter==FILTER_SUB) { - leftBytes=new byte[16]; - } - if(filter==FILTER_UP) { - priorRow=new byte[width*bytesPerPixel]; - } - - scanPos=0; - startPos=1; - for(int i=0; i<width*nRows; i++) { - if(i%width==0) { - scanLines[scanPos++]=(byte)filter; - startPos=scanPos; - } - scanLines[scanPos++]=(byte)((pixels[i]>>16)&0xff); - scanLines[scanPos++]=(byte)((pixels[i]>>8)&0xff); - scanLines[scanPos++]=(byte)((pixels[i])&0xff); - if(encodeAlpha) { - scanLines[scanPos++]=(byte)((pixels[i]>>24)&0xff); - } - if((i%width==width-1)&&(filter!=FILTER_NONE)) { - if(filter==FILTER_SUB) { - filterSub(scanLines, startPos, width); - } - if(filter==FILTER_UP) { - filterUp(scanLines, startPos, width); - } - } - } - - /* - * Write these lines to the output area - */ - compBytes.write(scanLines, 0, scanPos); - - startRow+=nRows; - rowsLeft-=nRows; - } - compBytes.close(); - - /* - * Write the compressed bytes - */ - compressedLines=outBytes.toByteArray(); - nCompressed=compressedLines.length; - - crc.reset(); - bytePos=writeInt4(nCompressed, bytePos); - bytePos=writeString("IDAT", bytePos); - crc.update("IDAT".getBytes()); - bytePos=writeBytes(compressedLines, nCompressed, bytePos); - crc.update(compressedLines, 0, nCompressed); - - crcValue=crc.getValue(); - bytePos=writeInt4((int)crcValue, bytePos); - scrunch.finish(); - return true; - } catch(IOException e) { - System.err.println(e.toString()); - return false; - } - } - - /** - * Write a PNG "IEND" chunk into the pngBytes array. - */ - protected void writeEnd() { - bytePos=writeInt4(0, bytePos); - bytePos=writeString("IEND", bytePos); - crc.reset(); - crc.update("IEND".getBytes()); - crcValue=crc.getValue(); - bytePos=writeInt4((int)crcValue, bytePos); - } -} - diff --git a/graphics/AtlantisJava/src/atlantis/graphics/layout/AFlowLayout.java b/graphics/AtlantisJava/src/atlantis/graphics/layout/AFlowLayout.java deleted file mode 100755 index 1d391e05e845e478a4585df9d7c4504da0c8952c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/layout/AFlowLayout.java +++ /dev/null @@ -1,115 +0,0 @@ -package atlantis.graphics.layout; - -import java.awt.Container; -import java.awt.Insets; -import java.awt.LayoutManager; -import java.awt.Component; -import java.awt.Dimension; - -/** - * This Layout manager aranges the components in a flow like awt.FlowLayout. - * The difference is that this layout resizes the container to the minimum - * size after every layout operation, and therefore ensures that all components - * it laysout are visible. Nothing to do with the layout of the Atlantis canvas. - */ - -public class AFlowLayout implements LayoutManager { - private int hgap; - private int vgap; - - public AFlowLayout(int hgap, int vgap) { - this.hgap=hgap; - this.vgap=vgap; - } - - public void addLayoutComponent(String name, Component comp) {} - - public void removeLayoutComponent(Component comp) {} - - public Dimension minimumLayoutSize(Container target) { - return preferredLayoutSize(target); - } - - public Dimension preferredLayoutSize(Container target) { - Insets insets=target.getInsets(); - Dimension D=target.getSize(); - int W=D.width-insets.left-insets.right; - int L=hgap; - int y=vgap; - int w, h, hmax=0; - - for(int i=0; i<target.getComponentCount(); i++) { - Dimension d=target.getComponent(i).getPreferredSize(); - - w=d.width; - h=d.height; - - if(L+w+hgap<W) { - L+=w+hgap; - if(h>hmax) hmax=h; - } else { - L=hgap+w+hgap; - y+=hmax+vgap; - hmax=0; - if(h>hmax) hmax=h; - } - } - if(target.getComponentCount()>0) - y+=hmax+vgap; - - return new Dimension(W, y); - } - - public void layoutContainer(Container target) { - Insets insets=target.getInsets(); - Dimension D=target.getSize(); - int W=D.width-insets.left-insets.right; - int L=hgap; - int y=vgap; - int from=0; - int to=0; - int w, h, hmax=0; - - for(int i=0; i<target.getComponentCount(); i++) { - Dimension d=target.getComponent(i).getPreferredSize(); - - w=d.width; - h=d.height; - - if(L+w+hgap<W) { - L+=w+hgap; - to=i; - if(h>hmax) hmax=h; - } else { - layout(target, hgap+insets.left+(W/2-L/2), y, from, to); - L=hgap+w+hgap; - from=i; - to=i; - y+=hmax+vgap; - hmax=0; - if(h>hmax) hmax=h; - } - } - - if(target.getComponentCount()>0) - layout(target, hgap+insets.left+(W/2-L/2), y, from, to); - - /* - if (y + hmax + vgap != D.height) - SwingUtilities.invokeLater(new ARunAnotherLayout(target)); - */ - } - - public void layout(Container target, int x, int y, int from, int to) { - int xi=x; - - for(int i=from; i<=to; i++) { - Component comp=target.getComponent(i); - Dimension d=comp.getPreferredSize(); - - comp.setBounds(xi, y, d.width, d.height); - xi+=d.width+hgap; - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/layout/AGridLayout.java b/graphics/AtlantisJava/src/atlantis/graphics/layout/AGridLayout.java deleted file mode 100755 index 034287a49e1f92d4d91090a08d58d1df79b3b7bb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/layout/AGridLayout.java +++ /dev/null @@ -1,214 +0,0 @@ -package atlantis.graphics.layout; - -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.LayoutManager2; -import java.awt.Rectangle; - -import javax.swing.JComponent; -import javax.swing.SwingUtilities; - -import atlantis.canvas.ACanvas; - -/** - * This layout manager is a simplification of the - * <code>ConstrainedGridLayout</code> layout manager written by Charles A. - * Loomis. This layout manager hase two modes of operation: 1) CONSTRAINED - - * cell size is calculated by dividing the container size acording to aspect - * ratio. 2) PREFERRED - cell size is given at creation time - * - * @author Dumitru Petrusca. - */ -public class AGridLayout implements LayoutManager2 -{ - private Dimension gridSize; - private int cellSize; - private Dimension initialSize; - - public final static int CONSTRAINED = 0; - public final static int PREFERRED = 1; - private int layoutType; - private boolean secondLayout; - - final public static String GRID_SIZE_ERROR = "Grid size must have width and height > 0."; - - final public static String ASPECT_RATIO_ERROR = "Aspect ratio must have width and height > 0."; - - final public static String CONSTRAINT_ERROR = "Constraint must be a Rectangle with positive width and height."; - - final public static String AGRID_LAYOUT_CONSTRAINT = "ConstrainedGridLayout.RectangularConstraint"; - - /** - * Creates a new GridLayout of type CONSTRAINNED. - */ - public AGridLayout(Dimension gridSize, Dimension initialSize) - { - layoutType = CONSTRAINED; - setGridSize(gridSize); - secondLayout = true; - this.initialSize = initialSize; - } - - /** - * Creates a new GridLayout of type PREFERRED - */ - public AGridLayout(Dimension gridSize, int cellSize) - { - layoutType = PREFERRED; - setGridSize(gridSize); - this.cellSize = cellSize; - secondLayout = false; - initialSize = null; - } - - private void setGridSize(Dimension gridSize) - { - // Check that all of the dimensions given are reasonable. - if (gridSize.width <= 0 || gridSize.height <= 0 || gridSize.width > 100 || gridSize.height > 100) - throw new IllegalArgumentException(GRID_SIZE_ERROR); - - // Copy the information into the layout manager. - this.gridSize = new Dimension(0, 0); - this.gridSize.setSize(gridSize); - } - - public Dimension getGridSize() - { - return new Dimension(gridSize); - } - - /** - * Set (or reset) the constraints for the given component. - */ - public void setConstraints(Component comp, Rectangle constraints) - { - if (comp instanceof JComponent) - { - Rectangle copy = new Rectangle(constraints); - JComponent jc = (JComponent) comp; - - jc.putClientProperty(AGRID_LAYOUT_CONSTRAINT, copy); - } - } - - /** - * Get the constraints being used for the given component. - */ - public Rectangle getConstraints(Component comp) - { - Rectangle r = null; - - if (comp instanceof JComponent) - { - JComponent jc = (JComponent) comp; - Object constraint = jc.getClientProperty(AGRID_LAYOUT_CONSTRAINT); - - if (constraint instanceof Rectangle) - r = (Rectangle) constraint; - } - - return (r != null) ? new Rectangle(r) : null; - } - - // implementation of LayoutMamager interface - - public void addLayoutComponent(String name, Component comp) - {} - - public void removeLayoutComponent(Component comp) - {} - - public Dimension preferredLayoutSize(Container parent) - { - if (layoutType == CONSTRAINED) - { - Dimension d = parent.getSize(); - if (initialSize != null) - { - d = new Dimension(initialSize); - initialSize = null; - } - - int hCellSize = d.width / gridSize.width; - int vCellSize = d.height / gridSize.height; - if(ACanvas.getCanvas().getCurrentLayout().getName().equals("FULL SCREEN")) - { - return new Dimension(gridSize.width * hCellSize, gridSize.height * vCellSize); - } - cellSize = Math.min(hCellSize, vCellSize); - } - - return new Dimension(gridSize.width * cellSize, gridSize.height * cellSize); - } - - public Dimension minimumLayoutSize(Container parent) - { - return preferredLayoutSize(parent); - } - - public void layoutContainer(Container parent) - { - Dimension d = parent.getSize(); - int hCellSize = d.width / gridSize.width; - int vCellSize = d.height / gridSize.height; - int compCount = parent.getComponentCount(); - - for (int i = 0; i < compCount; i++) - { - Component comp = parent.getComponent(i); - Rectangle r = getConstraints(comp); - - if (r != null) - { - if(ACanvas.getCanvas().getCurrentLayout().getName().equals("FULL SCREEN")) - comp.setBounds(r.x * hCellSize, r.y * vCellSize, r.width * hCellSize, r.height * vCellSize); - else - comp.setBounds(r.x * cellSize, r.y * cellSize, r.width * cellSize, r.height * cellSize); - } - } - - if (secondLayout) - SwingUtilities.invokeLater(new ARunAnotherLayout(parent)); - } - - // implementation of LayoutMamager2 interface - - /** - * Adds the specified component to the layout, using the specified - * constraint object. - */ - public void addLayoutComponent(Component comp, Object constraints) - { - if (constraints instanceof Rectangle) - { - Rectangle r = (Rectangle) constraints; - - if (r.width <= 0 || r.height <= 0) - throw new IllegalArgumentException(CONSTRAINT_ERROR); - - setConstraints(comp, r); - } - else if (constraints != null) - throw new IllegalArgumentException(CONSTRAINT_ERROR); - } - - public Dimension maximumLayoutSize(Container target) - { - return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); - } - - public float getLayoutAlignmentX(Container target) - { - return 0.5f; - } - - public float getLayoutAlignmentY(Container target) - { - return 0.5f; - } - - public void invalidateLayout(Container target) - {} - -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/layout/ARunAnotherLayout.java b/graphics/AtlantisJava/src/atlantis/graphics/layout/ARunAnotherLayout.java deleted file mode 100755 index ce1330374e3fba8fcfce39fb94225e97187f38b3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/layout/ARunAnotherLayout.java +++ /dev/null @@ -1,26 +0,0 @@ -package atlantis.graphics.layout; - - -import java.awt.Container; -import java.awt.Window; -import javax.swing.SwingUtilities; - - -/** - * Used by the Layout Managers to invoke another layout operation. - * Needed to resize the canvas preserving aspect ratio. - */ - -public class ARunAnotherLayout implements Runnable { - private Container parent; - - public ARunAnotherLayout(Container parent) { - this.parent=parent; - } - - public void run() { - Window window=SwingUtilities.getWindowAncestor(parent); - - if(window!=null) window.pack(); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/graphics/package.html b/graphics/AtlantisJava/src/atlantis/graphics/package.html deleted file mode 100644 index 0d498ed42593055703f002fbf16519819c5c1cae..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/graphics/package.html +++ /dev/null @@ -1,6 +0,0 @@ -<html> -<head></head> -<body> -<p>2D graphical classes, graphical primitives.</p> -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/gui/AAboutDialog.java b/graphics/AtlantisJava/src/atlantis/gui/AAboutDialog.java deleted file mode 100755 index 62546b209703960e740782fd91204402c58fb6cb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AAboutDialog.java +++ /dev/null @@ -1,214 +0,0 @@ -package atlantis.gui; - -import java.awt.BorderLayout; -import java.awt.GridLayout; -import java.awt.Font; -import java.awt.Color; -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; - -import javax.swing.JPanel; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JTextPane; -import javax.swing.BorderFactory; -import javax.swing.JFrame; - -import atlantis.globals.AGlobals; -import atlantis.graphics.AIcon; -import atlantis.utils.AUtilities; - - -/** - * - * About information dialog (Help -> About) - * - * @author Zdenek Maxa, Mark Stockton - */ -public class AAboutDialog extends JFrame -{ - - private static JPanel a_panel1 = null; - private static JPanel a_panel2 = null; - private static JPanel a_panel3 = null; - private static JPanel a_panel4 = null; - private static JPanel a_textPanel = null; - private static JLabel a_label1 = null; - private static JTextPane a_label2 = null; - private static JLabel a_label3 = null; - private static JTextPane a_label4 = null; - - private static JPanel m_panel1 = null; - private static JPanel m_panel2 = null; - private static JPanel m_panel3 = null; - private static JPanel m_panel4 = null; - private static JPanel m_textPanel = null; - private static JLabel m_label1 = null; - private static JTextPane m_label2 = null; - private static JTextPane m_label3 = null; - private static JTextPane m_label4 = null; - - private static JPanel c_panel1 = null; - - private static JPanel mainPanel = null; - - - private static JButton closeButton = null; - - private static AAboutDialog instance = null; - - private static final AGlobals globals = AGlobals.instance(); - - - private AAboutDialog(String title) - { - super(title); - try - { - createGUI(); - pack(); - } - catch(Exception ex) - { - ex.printStackTrace(); - } - - AIcon.setIconImage(this); - - } // AAboutDialog() ----------------------------------------------------- - - - - private void createGUI() - { - // top panel - atlantis - a_panel1 = new JPanel(); - a_panel1.setLayout(new GridLayout(1,2)); - - // top left text panel (4 lines of text) - a_panel2 = new JPanel(); - a_label2 = new JTextPane(); - Font font = new Font(a_panel2.getFont().getName(), - Font.BOLD, - a_panel2.getFont().getSize() + 6); - a_label2.setFont(font); - a_label2.setEditable(false); - a_label2.setBackground(a_panel2.getBackground()); - a_label2.setText(AGlobals.instance().getVersion()); - a_panel2.add(a_label2); - - a_panel3 = new JPanel(); - a_label3 = new JLabel("Event display for ATLAS"); - a_panel3.add(a_label3); - - a_panel4 = new JPanel(); - a_label4 = new JTextPane(); - a_label4.setBackground(a_panel4.getBackground()); - a_label4.setForeground(Color.blue); - a_label4.setText("http://www.cern.ch/atlantis" + "\n" + - "hn-atlas-AtlantisDisplay@cern.ch"); - a_label4.setEditable(false); - a_panel4.add(a_label4); - - a_textPanel = new JPanel(); - a_textPanel.setLayout(new GridLayout(3,1)); - a_textPanel.add(a_panel2); - a_textPanel.add(a_panel3); - a_textPanel.add(a_panel4); - - a_panel1.add(a_textPanel); - - String FILE_SEPAR = System.getProperty("file.separator"); - String homeDirectory = AGlobals.instance().getHomeDirectory(); - - // top right atlantis image - String path = homeDirectory + "img" + FILE_SEPAR + - "atlantis_log.gif"; - a_label1 = new JLabel(AUtilities.getFileAsImageIcon(path)); - a_panel1.add(a_label1); - - // middle panel - minerva - m_panel1 = new JPanel(); - m_panel1.setLayout(new GridLayout(1,2)); - - // middle left minerva image - path = homeDirectory + "img" + FILE_SEPAR + - "minerva_log.gif"; - m_label1 = new JLabel(AUtilities.getFileAsImageIcon(path)); - m_panel1.add(m_label1); - - // middle right text panel - m_panel2 = new JPanel(); - m_label2 = new JTextPane(); - m_label2.setFont(font); - m_label2.setEditable(false); - m_label2.setBackground(m_panel2.getBackground()); - m_label2.setText("MINERVA"); - m_panel2.add(m_label2); - - m_panel3 = new JPanel(); - m_label3 = new JTextPane(); - m_label3.setBackground(m_panel3.getBackground()); - m_label3.setEditable(false); - m_label3.setText(" Masterclass INvolving Event \n Recognition Visualised with Atlantis"); - m_panel3.add(m_label3); - - m_panel4 = new JPanel(); - m_label4 = new JTextPane(); - m_label4.setBackground(m_panel4.getBackground()); - m_label4.setForeground(Color.blue); - m_label4.setText("http://www.cern.ch/atlas-minerva"); - m_label4.setEditable(false); - m_panel4.add(m_label4); - - m_textPanel = new JPanel(); - m_textPanel.setLayout(new GridLayout(3,1)); - m_textPanel.add(m_panel2); - m_textPanel.add(m_panel3); - m_textPanel.add(m_panel4); - - m_panel1.add(m_textPanel); - - // bottom panel - close button - c_panel1 = new JPanel(new BorderLayout()); - closeButton = new JButton("Close"); - closeButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - AAboutDialog.getInstance().dispose(); - } - }); - c_panel1.add(closeButton, BorderLayout.EAST); - c_panel1.setBorder(BorderFactory.createEmptyBorder(15, 0, 15, 15)); - - - // main panel - mainPanel = new JPanel(); - mainPanel.setLayout(new BorderLayout()); - mainPanel.add(a_panel1, BorderLayout.NORTH); - mainPanel.add(m_panel1, BorderLayout.CENTER); - mainPanel.add(c_panel1, BorderLayout.SOUTH); - - this.getContentPane().add(mainPanel, BorderLayout.CENTER); - - this.setResizable(false); - - this.setLocation(globals.getGuiFrame().getLocation()); - - } // createGUI() -------------------------------------------------------- - - - public static AAboutDialog getInstance() - { - if(instance == null) - { - instance = new AAboutDialog("About Atlantis"); - } - return instance; - - } // getInstance() ------------------------------------------------------ - - - -} // class AAboutDialog ===================================================== diff --git a/graphics/AtlantisJava/src/atlantis/gui/ACheckBox.java b/graphics/AtlantisJava/src/atlantis/gui/ACheckBox.java deleted file mode 100755 index f4af0033a9fa61693959ee66f03977555151e6ad..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ACheckBox.java +++ /dev/null @@ -1,33 +0,0 @@ -package atlantis.gui; - -import java.awt.event.ActionListener; -import javax.swing.JCheckBox; - -/** - * This class does not generate an ActionEvent - * when the setSelected() method is called. - */ -public class ACheckBox extends JCheckBox { - ActionListener listener; - - public ACheckBox(String text) { - super(text); - } - - public ACheckBox() { - super(); - } - - public void addActionListener(ActionListener l) { - if(listener==null) { - super.addActionListener(listener); - listener=l; - } - } - - public void setSelected(boolean b) { - if(listener!=null) super.removeActionListener(listener); - super.setSelected(b); - if(listener!=null) super.addActionListener(listener); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ACheckNode.java b/graphics/AtlantisJava/src/atlantis/gui/ACheckNode.java deleted file mode 100755 index e2bac2cf8a3ce042ded701f7f3ed6d86719a1ce4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ACheckNode.java +++ /dev/null @@ -1,86 +0,0 @@ -package atlantis.gui; - -import java.util.Iterator; -import atlantis.parameters.AParameter; -import atlantis.parameters.AStatusParameter; -import atlantis.parameters.ACommandProcessor; -import hep.wired.util.DefaultTristateTreeNode; -import hep.wired.util.TristateCheckBox; - -/** - * - * @author Qiang - */ - -public class ACheckNode extends DefaultTristateTreeNode { - - public static final byte SINGLE_SELECTION = 0; - - public static final byte MULTI_SELECTION = 1; - - private byte selectionMode; - - private AParameter parameter; - - public ACheckNode(Object userObject, boolean selectionValue, byte selectionMode, AParameter parameter) { - super(userObject, selectionValue, true); - setSelectionMode(selectionMode); - this.parameter = parameter; - } - - public void setSelectionMode(byte selectionMode) { - this.selectionMode = selectionMode; - } - - public byte getSelectionMode() { - return this.selectionMode; - } - - public AParameter getParameter(){ - return this.parameter; - } - - public void updateState(){ - if(children!=null){ - int checkedNumber = 0; - for(Iterator it=children.iterator(); it.hasNext();){ - ACheckNode aChildNode = (ACheckNode)it.next(); - aChildNode.updateState(); - if(aChildNode.isSelected()) - checkedNumber++; - } - if(checkedNumber==0) - this.setSelected(false); - else - this.setSelected(true); - } else{ - ACheckBox cellComponent = (ACheckBox)getUserObject(); - cellComponent.setSelected(getParameter().getStatus()); - setSelected(cellComponent.isSelected()); - } - } - - public void getClicked(boolean selectionFlag, boolean statusChange) { - setSelected(selectionFlag); - if((parameter instanceof AStatusParameter) && statusChange){ - // a leaf node is found here - AStatusParameter theStatusParameter = (AStatusParameter)parameter; - ACommandProcessor.receive(theStatusParameter.getName()); - theStatusParameter.apply(); - } else{ - // parameter is either AStatusRootParameter or AStatusGroupParameter - if((selectionMode==MULTI_SELECTION) && (children!=null)){ - ((TristateCheckBox)this.getUserObject()).setSelected(selectionFlag); - for(Iterator it=children.iterator(); it.hasNext();){ - ACheckNode aChildNode = (ACheckNode)it.next(); - // either AStatusGrooupParameter node or AStatusParameter node - aChildNode.getClicked(selectionFlag, !(aChildNode.isSelected()==selectionFlag)); - } - } - } - if(parent!=null){ - ((ACheckNode)parent).updateState(); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AClosingConfirmationDialog.java b/graphics/AtlantisJava/src/atlantis/gui/AClosingConfirmationDialog.java deleted file mode 100755 index 3872b0960e51e0d6d736e10498e3fa759917d4a5..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AClosingConfirmationDialog.java +++ /dev/null @@ -1,63 +0,0 @@ -package atlantis.gui; - -import java.awt.Frame; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import javax.swing.JOptionPane; - -import atlantis.config.ADefaultValues; -import atlantis.utils.ALogger; - -/** - * - * Atlantis application closing confirmation dialog. - * All Atlantis closing actions can be added here and this - * class shall be used for closing the application. - * - */ -public class AClosingConfirmationDialog extends WindowAdapter -{ - private static ALogger logger = ALogger.getLogger(AClosingConfirmationDialog.class); - - private Frame adaptee; - - - public AClosingConfirmationDialog(Frame adaptee) - { - this.adaptee = adaptee; - - } // AClosingConfirmationDialog() --------------------------------------- - - - - public void windowClosing(WindowEvent e) - { - exitApp(); - - } // windowClosing() ---------------------------------------------------- - - - - public void exitApp() - { - - String msg = "Do you really want to quit Atlantis?"; - int i = JOptionPane.showConfirmDialog(adaptee, msg, "Exit Atlantis", - JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null); - if(i == JOptionPane.YES_OPTION) - { - logger.debug("Shutting down, going to save runtime values..."); - ADefaultValues.saveRuntimeValues(); - logger.warn("Shutting down, calling System.exit(0)"); - System.exit(0); - } - else - { - return; - } - - } // exitApp() ---------------------------------------------------------- - - - -} // class AClosingConfirmationDialog ======================================= diff --git a/graphics/AtlantisJava/src/atlantis/gui/AColorComboBoxRenderer.java b/graphics/AtlantisJava/src/atlantis/gui/AColorComboBoxRenderer.java deleted file mode 100755 index d0eed9427aafb559b3e7a7ea8c0ab14148d5c7f7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AColorComboBoxRenderer.java +++ /dev/null @@ -1,126 +0,0 @@ -package atlantis.gui; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Graphics; -import javax.swing.Icon; -import javax.swing.JLabel; -import javax.swing.ToolTipManager; -import javax.swing.BorderFactory; -import javax.swing.JList; -import javax.swing.ListCellRenderer; -import javax.swing.border.Border; - -import atlantis.graphics.colormap.AColorMap; - -/** - * The class used as a renderer when displaying the colors in the UI. - */ -public class AColorComboBoxRenderer extends JLabel - implements ListCellRenderer { - - private ColorIcon icon=new ColorIcon(); - private Border selectedBorder; - private Border deselectedBorder=BorderFactory.createEmptyBorder(2, 2, 2, 2); - - public Component getListCellRendererComponent( - JList list, Object value, int index, - boolean isSelected, boolean cellHasFocus) { - - int colorIndex=((Integer)value).intValue(); - Color[] colorMap=AColorMap.getColors(); - Color color=colorMap[colorIndex]; - - icon.setColor(color); - setIcon(icon); - setText(""+((Integer)value).intValue()); - - if(isSelected) { - selectedBorder=BorderFactory.createLineBorder(list.getSelectionBackground(), 2); - - setBorder(selectedBorder); - - ToolTipManager.sharedInstance().setInitialDelay(1); - ToolTipManager.sharedInstance().setReshowDelay(1); - - String message; - - if(color.equals(Color.black)) - message="Black: "; - else if(color.equals(Color.blue)) - message="Blue: "; - else if(color.equals(Color.cyan)) - message="Cyan: "; - else if(color.equals(Color.darkGray)) - message="DarkGray: "; - else if(color.equals(Color.gray)) - message="Gray: "; - else if(color.equals(Color.green)) - message="Green: "; - else if(color.equals(Color.lightGray)) - message="LightGray: "; - else if(color.equals(Color.magenta)) - message="Magenta: "; - else if(color.equals(Color.orange)) - message="Orange: "; - else if(color.equals(Color.pink)) - message="Pink: "; - else if(color.equals(Color.red)) - message="Red: "; - else if(color.equals(Color.white)) - message="White: "; - else if(color.equals(Color.yellow)) - message="Yellow: "; - else - message=""; - - list.setToolTipText(message+color.getRed()+", "+color.getGreen()+", "+color.getBlue()); - } else setBorder(deselectedBorder); - - return this; - } - - private static class ColorIcon implements Icon { - private int w, h; - private Color color; - - public ColorIcon() { - this(Color.gray, 50, 15); - } - - public ColorIcon(Dimension d) { - this.w=d.width; - this.h=d.height; - } - - public ColorIcon(Color color, int w, int h) { - this.color=color; - this.w=w; - this.h=h; - } - - public void paintIcon(Component c, Graphics g, int x, int y) { - g.setColor(Color.black); - g.drawRect(x, y, w-1, h-1); - g.setColor(color); - g.fillRect(x+1, y+1, w-2, h-2); - } - - public Color getColor() { - return color; - } - - public void setColor(Color color) { - this.color=color; - } - - public int getIconWidth() { - return w; - } - - public int getIconHeight() { - return h; - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AColorHelpDialog.java b/graphics/AtlantisJava/src/atlantis/gui/AColorHelpDialog.java deleted file mode 100755 index 695a2814bd378d10d51506b293e3262167f41280..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AColorHelpDialog.java +++ /dev/null @@ -1,260 +0,0 @@ -package atlantis.gui; - -import java.awt.Color; -import java.awt.GridLayout; -import java.awt.Toolkit; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; - -import javax.swing.JFrame; -import javax.swing.JTextField; - -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.globals.AGlobals; -import atlantis.graphics.AIcon; -import atlantis.graphics.colormap.AColorMap; -import atlantis.parameters.APar; - -/** - * The help dialog displays the current color of objects - * - * @author Mark Stockton - */ -public class AColorHelpDialog extends JFrame implements WindowListener -{ - private static JTextField[] textField; - public static Color[] colorMap = AColorMap.getColors(); - private static AColorHelpDialog instance = null; - - private static APar parameterStore = APar.instance(); - private static AEventManager eventManager = AEventManager.instance(); - - public static AColorHelpDialog getInstance() - { - if (AGlobals.isAtlantisHeadless()) { - return null; - } - if (instance == null) - instance = new AColorHelpDialog(); - return instance; - } - - public void update() - { - if(!this.isVisible()) - return; - getContentPane().removeAll(); - validate(); - - String[] dataObjectsToDisplay={"RVx", "TRT", "SiCluster", "SiClusterRDO", "S3D", "PixelCluster", "PixelRDO", "TrigS3D", - "MDT", "CSC", "RPC", "TGC", - "EmTauROI", "JetROI", "MuonROI", "LVL1TriggerTower", "LVL1JetElement", - "STr", "SNP", "SMTr", "SVx"}; - String[] dataObjectsWithCollectionsToDisplay={"InDetTrack", "InDetSegment", "Cluster", "MuonTrack", - "MuonSegment", "Jet", "ETMis", "BJet","Electron","Muon","Photon","TauJet","CompositeParticle"}; - String[] geometryObjectsToDisplay={"PIXFill", "SILFill", "TRTFill", "SolFill", "ECALFill", - "HCALFill", "RPCFill", "TGCFill", "MDTFill", "CSCFill", "BkgFill"}; - - int numObjects = Math.max(dataObjectsWithCollectionsToDisplay.length,dataObjectsToDisplay.length); - int numOfColumns = 4; - getContentPane().setLayout(new GridLayout(numObjects+1,numOfColumns)); - textField = new JTextField[(numObjects+1)*4]; - AEvent event = eventManager.getCurrentEvent(); - - //table column titles - fillTextField(0, Color.white, Color.black, " Geometry color"); - fillTextField(1, Color.white, Color.black, " Color of objects without collections"); - fillTextField(2, Color.white, Color.black, " Color of objects with collections"); - fillTextField(3, Color.white, Color.black, " Object Collection"); - - //loop over objects - for(int j=0; j<numObjects; j++) - { - int i=4*j + 4; - //display geometry color - if(j<geometryObjectsToDisplay.length) - { - String source = "Det"; - if(geometryObjectsToDisplay[j].equals("BkgFill")) - source = "Color"; - Color backgroundColor=colorMap[parameterStore.get(source, geometryObjectsToDisplay[j]).getI()]; - //display screen name - String text=parameterStore.get(source, geometryObjectsToDisplay[j]).getScreenName(); - fillTextField(i, backgroundColor, text); - }else{ - fillTextField(i);//nothing to display - } - - i++; - //display object without collection color - if(j<dataObjectsToDisplay.length){ - fillTextField(i,dataObjectsToDisplay[j]); - }else{ - fillTextField(i);//nothing to display - } - - i++; - //display object with collection color - if(j<dataObjectsWithCollectionsToDisplay.length){ - fillTextField(i,dataObjectsWithCollectionsToDisplay[j]); - }else{ - fillTextField(i);//nothing to display - } - - //display object collection - i++; - if(j<dataObjectsWithCollectionsToDisplay.length){ - //get collections - String[] collections=event.getActiveCollectionNames(dataObjectsWithCollectionsToDisplay[j]); - String text; - //check is on/has collectons/not all selected - if(!parameterStore.get("Data", dataObjectsWithCollectionsToDisplay[j]).getStatus() || - collections==null || collections.length==0) - text = "n/a"; - else if(collections.length>1) - text = ">1 selected"; - else - { - text = collections[0].substring(dataObjectsWithCollectionsToDisplay[j].length()); - } - fillTextField(i, Color.white, Color.black, text); - - }else{ - fillTextField(i);//nothing to display - } - } - - invalidate(); - pack(); - } - - /** - * Fills the text field with chosen colours and text - * foreground colour and text can be null to just fill background - * - * @param index - textfield index - * @param background - background colour - * @param foreground - foreground color - * @param text - text to display - */ - private void fillTextField(int index, Color background, Color foreground, String text) - { - if(textField[index]==null) - textField[index]=new JTextField(); - textField[index].setEditable(false); - textField[index].setBackground(background); - if(foreground!=null) - textField[index].setForeground(foreground); - if(text!=null) - textField[index].setText(text); - getContentPane().add(textField[index]); - } - - /** - * Will fill a blank text field - * - * @param index - textfield index - */ - private void fillTextField(int index) - { - //nothing to display so set color to be the - //same as the outline color of the text boxes - fillTextField(index, (new Color(184,207,229)), null, null); - } - - /** - * Automatically decides the forground text colour - * depending on the background color - * - * @param index - textfield index - * @param background - background colour - * @param text - text to display - */ - private void fillTextField(int index, Color background, String text) - { - //find out if too dark for black text - if( background.getBlue()==background.getRed() - && background.getBlue()==background.getGreen() - && background.getBlue()<=128) - fillTextField(index, background, Color.white, text); - else - fillTextField(index, background, Color.black, text); - } - - /** - * Get information from object for background - * colour and objedct name + status gives the text - * - * @param index - textfield index - * @param object - name of object - */ - private void fillTextField(int index, String object) - { - //if color by constant or has no colour option (e.g. vertex) - if(parameterStore.get(object, "ColorFunction")==null - || parameterStore.get(object, "ColorFunction").getI()==0) - { - Color backgroundColor=colorMap[parameterStore.get(object, "Constant").getI()]; - String text = object; - if(!parameterStore.get("Data", object).getStatus()) - text += " - data type not active"; - fillTextField(index, backgroundColor, text); - } - else - { - String text = object; - if(parameterStore.get("Data", object).getStatus()) - text += " is not being colored constant"; - else - text += " - data type not active"; - fillTextField(index, Color.white, Color.black, text); - } - } - - private AColorHelpDialog() - { - this.setTitle("Current window Geometry and Object colors and Object Collection"); - AIcon.setIconImage(this); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - - this.update(); - this.setResizable(false); - addWindowListener(this); - - // set the initial location - int screenWidth = Math.round((float) Toolkit.getDefaultToolkit().getScreenSize().getWidth()); - int screenHeight = Math.round((float) Toolkit.getDefaultToolkit().getScreenSize().getHeight()); - this.setLocation((int) Math.max(0, 0.1*screenWidth), (int) Math.max(0, 0.1*screenHeight)); - } - - public void dispose() - { - instance = null; - super.dispose(); - } - - public void windowOpened(WindowEvent e) - { - this.update(); - } - - public void windowClosing(WindowEvent e) - {} - - public void windowClosed(WindowEvent e) - {} - - public void windowIconified(WindowEvent e) - {} - - public void windowDeiconified(WindowEvent e) - {} - - public void windowActivated(WindowEvent e) - {} - - public void windowDeactivated(WindowEvent e) - {} - -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/gui/AColorMapDialog.java b/graphics/AtlantisJava/src/atlantis/gui/AColorMapDialog.java deleted file mode 100755 index e0b91297e22988e67daa2aefa09df9c047382d15..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AColorMapDialog.java +++ /dev/null @@ -1,109 +0,0 @@ -package atlantis.gui; - -import java.awt.BorderLayout; -import java.awt.Frame; -import java.awt.GridLayout; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JPanel; -import javax.swing.JRadioButton; - -import atlantis.canvas.ACanvas; -import atlantis.globals.AGlobals; -import atlantis.graphics.colormap.AColorMap; - -/** - * This dialog is displayed when the user wants to change the current color set. - */ -public class AColorMapDialog extends JDialog implements ActionListener -{ - private JPanel choosePanel; - private JPanel buttonsPanel; - private JButton okButton, cancelButton; - private JRadioButton selected; - - private static final AGlobals globals = AGlobals.instance(); - - public AColorMapDialog() - { - super(globals.getGuiFrame(), "Select Map Dialog", true); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - setResizable(false); - - choosePanel = new JPanel(); - choosePanel.setBorder(BorderFactory.createTitledBorder(" Select Color Map ")); - - ButtonGroup group = new ButtonGroup(); - - choosePanel.setLayout(new GridLayout(5, 1)); - for (int i = 0; i < AColorMap.getMapNames().length - 2; i++) - { // quick fix to not select hitcolor CT - JRadioButton r = new JRadioButton(AColorMap.getMapNames()[i]); - - r.addActionListener(this); - if (AColorMap.getColorMap() == i) - { - selected = r; - r.setSelected(true); - } - else - r.setSelected(false); - group.add(r); - choosePanel.add(r); - } - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(choosePanel, BorderLayout.CENTER); - - okButton = new JButton("OK"); - okButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - AColorMap.setColorMap(selected.getText()); - ACanvas.getCanvas().repaintAllFromScratch(); - dispose(); - } - }); - - cancelButton = new JButton("Cancel"); - cancelButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - dispose(); - } - }); - - buttonsPanel = new JPanel(); - buttonsPanel.add(okButton); - buttonsPanel.add(cancelButton); - getContentPane().add(buttonsPanel, BorderLayout.SOUTH); - pack(); - - // set the initial location - Frame owner = globals.getGuiFrame(); - int guiWidth = owner.getWidth(); - int guiHeight = owner.getHeight(); - int guiX = owner.getX(); - int dialogWidth = (int) this.getPreferredSize().getWidth(); - int dialogHeight = (int) this.getPreferredSize().getHeight(); - int screenWidth = Math.round((float) Toolkit.getDefaultToolkit().getScreenSize().getWidth()); - if(guiX+guiWidth+(dialogWidth-guiWidth)/2>screenWidth) - this.setLocation(Math.max(0, screenWidth - dialogWidth), Math.max(0, (guiHeight - dialogHeight) / 3)); - else - this.setLocation(Math.max(0, guiX + (guiWidth - dialogWidth) / 2), Math.max(0, (guiHeight - dialogHeight) / 3)); - setVisible(true); - } - - public void actionPerformed(ActionEvent e) - { - selected = (JRadioButton) e.getSource(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AColorMapEditor.java b/graphics/AtlantisJava/src/atlantis/gui/AColorMapEditor.java deleted file mode 100755 index 1c534d12967718f01a955398bfdad4db14433e99..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AColorMapEditor.java +++ /dev/null @@ -1,281 +0,0 @@ -package atlantis.gui; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Font; -import java.awt.Frame; -import java.awt.GridLayout; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JColorChooser; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; - -import atlantis.canvas.ACanvas; -import atlantis.globals.AGlobals; -import atlantis.graphics.colormap.AColorMap; -import atlantis.graphics.colormap.MappedColor; -import atlantis.graphics.layout.AFlowLayout; -import atlantis.graphics.dnd.ADnDLabel; -import atlantis.graphics.dnd.ADragListener; -import atlantis.utils.AUtilities; - -/** - * The dialog allows the user to edit the colors maps (at runtime). - */ -public class AColorMapEditor extends JDialog implements ADragListener -{ - private static AColorMapEditor instance; - private ADnDLabel[][] labels = new ADnDLabel[AColorMap.getNumMaps()][AColorMap.getNumColors()]; - private int colorMap; - private int index; - private MappedColor previousColor; - private ADnDLabel source; - - private JPanel colorPanel, buttonsPanel; - private JButton okButton, applyButton, cancelButton; - - private static final AGlobals globals = AGlobals.instance(); - - private AColorMapEditor() - { - super(globals.getGuiFrame(), "Color Map Editor", false); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - setResizable(false); - colorPanel = new JPanel(); - colorPanel.setLayout(new GridLayout(AColorMap.getNumColors() + 1, AColorMap.getNumMaps() + 1, 0, 0)); - - // creating the names row - JLabel padding = new JLabel(""); - colorPanel.add(padding); - for (int i = 0; i < AColorMap.getNumMaps(); i++) - { - JLabel label = new JLabel(" " + AColorMap.getMapNames()[i] + " ", JLabel.CENTER); - label.setFont(new Font("Dialog", Font.BOLD, 14)); - colorPanel.add(label); - } - - // creating the color table - Color[] col; - MouseListener labelMouseListener = new LabelMouseListener(); - - for (int j = 0; j < AColorMap.getNumColors(); j++) - { - JLabel label = new JLabel("" + j, JLabel.CENTER); - label.setFont(new Font("Dialog", Font.BOLD, 14)); - colorPanel.add(label); - for (int i = 0; i < AColorMap.getNumMaps(); i++) - { - col = AColorMap.getColors(i); - labels[i][j] = new ADnDLabel("text", false); - labels[i][j].addDragListener(this); - labels[i][j].setOpaque(true); - labels[i][j].setBackground(col[j]); - labels[i][j].setForeground(col[j]); - labels[i][j].setToolTipText(col[j].getRed() + ", " + col[j].getGreen() + ", " + col[j].getBlue()); - setLineBorder(labels[i][j]); - labels[i][j].addMouseListener(labelMouseListener); - colorPanel.add(labels[i][j]); - } - } - - buttonsPanel = new JPanel(); - buttonsPanel.setLayout(new AFlowLayout(10, 10)); - - okButton = new JButton("OK"); - okButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - applyColors(); - dispose(); - instance = null; - } - }); - buttonsPanel.add(okButton); - - applyButton = new JButton("Apply"); - applyButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - applyColors(); - } - }); - buttonsPanel.add(applyButton); - - cancelButton = new JButton("Cancel"); - cancelButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - dispose(); - instance = null; - } - }); - buttonsPanel.add(cancelButton); - - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(colorPanel, BorderLayout.CENTER); - getContentPane().add(buttonsPanel, BorderLayout.SOUTH); - pack(); - - // set the initial location - Frame owner = globals.getGuiFrame(); - int guiWidth = owner.getWidth(); - int guiHeight = owner.getHeight(); - int guiX = owner.getX(); - int dialogWidth = (int) this.getPreferredSize().getWidth(); - int dialogHeight = (int) this.getPreferredSize().getHeight(); - int screenWidth = Math.round((float) Toolkit.getDefaultToolkit().getScreenSize().getWidth()); - if(guiX+guiWidth+(dialogWidth-guiWidth)/2>screenWidth) - this.setLocation(Math.max(0, screenWidth - dialogWidth), Math.max(0, (guiHeight - dialogHeight) / 3)); - else - this.setLocation(Math.max(0, guiX + (guiWidth - dialogWidth) / 2), Math.max(0, (guiHeight - dialogHeight) / 3)); - setVisible(true); - } - - public static AColorMapEditor getInstance() - { - if (instance == null) - { - instance = new AColorMapEditor(); - } - return instance; - } - - public void updateColors() - { - if (instance != null) - { - MappedColor[][] maps = AColorMap.getMaps(); - for (int i = 0; i < maps.length; i++) - for (int j = 0; j < maps[i].length; j++) - { - Color c = maps[i][j]; - - labels[i][j].setBackground(c); - labels[i][j].setForeground(c); - labels[i][j].setToolTipText(c.getRed() + ", " + c.getGreen() + ", " + c.getBlue()); - } - repaint(); - } - } - - public void dragPerformed(Object from, Object to, int action) - { - ADnDLabel fromLabel = (ADnDLabel) from; - ADnDLabel toLabel = (ADnDLabel) to; - - toLabel.setBackground(fromLabel.getBackground()); - } - - class LabelMouseListener extends MouseAdapter - { - public void mouseClicked(MouseEvent e) - { - if (SwingUtilities.isLeftMouseButton(e)) - { - source = (ADnDLabel) e.getSource(); - Color color = JColorChooser.showDialog(instance, "Color Map Editor - Chooser", source.getBackground()); - if (color != null) - { - source.setBackground(color); - source.setForeground(color); - setLineBorder(source); - source.setToolTipText(color.getRed() + ", " + color.getGreen() + ", " + color.getBlue()); - } - } - } - - public void mousePressed(MouseEvent e) - { - source = (ADnDLabel) e.getSource(); - getPosition(); - - if (AUtilities.isRightMouseButton(e)) - { - if (index < 8) - for (int j = 8; j < AColorMap.getNumColors(); j++) - labels[colorMap][j].setBackground(labels[colorMap][index].getBackground()); - else - for (int j = 0; j < 8; j++) - labels[colorMap][j].setForeground(labels[colorMap][index].getForeground()); - - } - else if (SwingUtilities.isMiddleMouseButton(e)) - { - MappedColor[][] maps = AColorMap.getMaps(); - previousColor = maps[colorMap][index]; - MappedColor c = maps[colorMap][index]; - - if (c.getGreen() > 128) - maps[colorMap][index] = maps[colorMap][AColorMap.BK]; - else - maps[colorMap][index] = maps[colorMap][AColorMap.WH]; - ACanvas.getCanvas().repaintAllFromScratch(); - } - } - - public void mouseReleased(MouseEvent e) - { - if (AUtilities.isRightMouseButton(e)) - { - if (index < 8) - for (int j = 8; j < AColorMap.getNumColors(); j++) - labels[colorMap][j].setBackground(labels[colorMap][j].getForeground()); - else - for (int j = 0; j < 8; j++) - labels[colorMap][j].setForeground(labels[colorMap][j].getBackground()); - } - else if (SwingUtilities.isMiddleMouseButton(e)) - { - MappedColor[][] maps = AColorMap.getMaps(); - maps[colorMap][index] = previousColor; - ACanvas.getCanvas().repaintAllFromScratch(); - } - } - } - - private void setLineBorder(JComponent comp) - { - comp.setBorder(BorderFactory.createLineBorder(new Color(207, 207, 207), 3)); - } - - private void getPosition() - { - for (int i = 0; i < AColorMap.getNumMaps(); i++) - for (int j = 0; j < AColorMap.getNumColors(); j++) - if (labels[i][j] == source) - { - colorMap = i; - index = j; - break; - } - } - - private void applyColors() - { - MappedColor[][] maps = AColorMap.getMaps(); - for (int i = 0; i < maps.length; i++) - for (int j = 0; j < maps[i].length; j++) - { - Color c = labels[i][j].getBackground(); - - maps[i][j] = new MappedColor(c.getRed(), c.getGreen(), c.getBlue(), j); - } - AGUI.getGUI().repaintTable(); - ACanvas.getCanvas().repaintAllFromScratch(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AComboBox.java b/graphics/AtlantisJava/src/atlantis/gui/AComboBox.java deleted file mode 100755 index d91a35879b6ea5a3c0afac1d54c6bfda7777976c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AComboBox.java +++ /dev/null @@ -1,51 +0,0 @@ -package atlantis.gui; - - -import java.awt.event.ItemListener; -import javax.swing.JComboBox; - - -/** - * This class does not generate an ItemEvent - * when the setSelectedItem() method is called. - */ - -public class AComboBox extends JComboBox { - private ItemListener listener; - - /** - * Just calls the superclass constructor. - */ - public AComboBox() { - super(); - } - - /** - * Set the GUIItemListener to be informed of ItemEvents. - * Only one listener is allowed. - * @param aListener - */ - public void setGUIItemListener(ItemListener aListener) { - // Remove any existing listeners. - for (ItemListener listener : this.getItemListeners()) this.removeItemListener(listener); - super.addItemListener(aListener); - listener=aListener; - } - - /** - * Check whether the GUIItemListener has already been set. - * @return true if this AComboBox has a GUIItemListener - */ - public boolean hasGUIItemListener() {return (listener!=null);} - - /** - * Set the selected item without telling any item listeners. - * @param item - */ - public void setGUISelectedItem(Object item) { - if(listener!=null) super.removeItemListener(listener); - super.setSelectedItem(item); - if(listener!=null) super.addItemListener(listener); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AConfigWriter.java b/graphics/AtlantisJava/src/atlantis/gui/AConfigWriter.java deleted file mode 100755 index a903e939ef449a46908060ed74ad625319f82aa5..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AConfigWriter.java +++ /dev/null @@ -1,417 +0,0 @@ -package atlantis.gui; - -import java.awt.geom.Point2D; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.util.Vector; - -import javax.swing.JOptionPane; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParametersGroup; -import atlantis.utils.AAtlantisException; -import atlantis.utils.ALogger; -import atlantis.utils.AUtilities; - -/** - * - * <ul><li>Reads the configuration file (given file name) and makes the corrections - * according to the actual configuration which might have been changed by the - * user.</li> - * <li>Reads parameters differences (values from the parameters store).</li> - * <li>Reads canvas / window configuration.</li> - * <li>Creates XML config files from three above parts.</li></ul> - * - * <p>Writes out the current status. This is not a robust piece of code and make - * break if the format of config.xml is changed by hand. - * This class should throw an exception if there is a problem. - * </p> - * - * @author Gary Taylor, Zdenek Maxa - */ -public class AConfigWriter -{ - - private static ALogger logger = ALogger.getLogger(AConfigWriter.class); - - protected static APar parameterStore = APar.instance(); - - private AConfigWriter() - { - } - - /** - * Main method from the class - * @param sourceFile String - * @return String - */ - public static String getConfiguration(String sourceFile) - { - logger.trace("Trying to read the distribution configuration ..."); - String config = null; - StringBuffer output = new StringBuffer(""); - - config = readConfiguration(sourceFile); - - if(config != null) - { - logger.debug("Loading source configuration successful."); - output.append(config); - output.append(getParametersDifferences()); - output.append(getWindowCorners()); - output.append("\n</AtlantisConfiguration>\n"); - return output.toString(); - } - else - { - logger.error("Loading source configuration failed."); - return null; - } - } // getConfiguration() ------------------------------------------------- - - - - private static String getParametersDifferences() - { - StringBuffer output = new StringBuffer(""); - - output.append("\n\n"); - output.append("\t<ParameterDifferences>\n"); - - AParametersGroup[][] group = parameterStore.getUIGroups(); - for(int i = 0; i < group.length; i++) - { - for(int j = 0; j < group[i].length; j++) - { - Vector v = group[i][j].getParameters(999); - for(int k = 0; k < v.size(); ++k) - { - output.append(((AParameter)v.elementAt(k)).getDifferences(group[i][j].getGroupName())); - } - } - } - output.append("\t</ParameterDifferences>\n\n"); - - return output.toString(); - - } // getParametersDifferences() ----------------------------------------- - - - - private static String getWindowCorners() - { - StringBuffer output = new StringBuffer(""); - - output.append("\n\n"); - output.append("\t<WindowCorners>\n"); - - String[] windowNames = ACanvas.getCanvas().getKnownWindowNames(); - - for(int i = 0; i < windowNames.length; i++) - { - Point2D.Double[] corners = - ACanvas.getCanvas().getWindow(windowNames[i]).getUserCorners(); - if(corners != null) - { - output.append("\t\t<CORNERS windowName=\"" + - windowNames[i] + "\""); - for(int j = 0; j < corners.length; ++j) - { - output.append(" x" + j + "=\"" + corners[j].getX() + "\""); - output.append(" y" + j + "=\"" + corners[j].getY() + "\""); - } - output.append("/>\n"); - } - } - - output.append("\t</WindowCorners>\n\n\n"); - - return output.toString(); - } // getWindowCorners() ------------------------------------------------- - - - // Read one logic line from xml file - // contain <....> or <..../> - private static String readLogicLine(BufferedReader reader) throws IOException - { - String startLine = reader.readLine(); - if(startLine == null) - return null; - - StringBuffer logicLine = new StringBuffer(startLine); - - while(logicLine.indexOf("<") >= 0 && logicLine.indexOf(">") < 0) - { - logicLine.append("\n"); - logicLine.append(reader.readLine()); - } - return logicLine.toString(); - } - - - private static String readConfiguration(String fileName) - { - String groupName = ""; - String parameterName = ""; - AParameter aParam = null; - BufferedReader curr = null; - String str; - StringBuffer buffer = new StringBuffer(""); // working buffer - StringBuffer output = new StringBuffer(""); // final result - boolean inComment = false; - - try - { - logger.debug("Trying to open configuration file: " + fileName); - InputStream fis = AUtilities.getFileAsStream(fileName); - InputStreamReader isr = new InputStreamReader(fis); - curr = new BufferedReader(isr, 10000); - - while((str = readLogicLine(curr)) != null) - { - buffer = new StringBuffer(str); - // in a comment ? - if(buffer.indexOf("<!--") >= 0) - { - inComment = true; - } - if(buffer.indexOf("-->") >= 0) - { - inComment = false; - } - if(!inComment) - { - // nearly finished writing - if(buffer.indexOf("</Parameters>") >= 0) - { - output.append(buffer); - output.append("\n"); - break; - } - - // modification in the initialisation - if(buffer.indexOf("<Canvas") >= 0) { - buffer = replace(buffer, "startupLayout", ACanvas.getCanvas().getCurrentLayout().getName()); - String ar = Double.toString(ACanvas.getCanvas().getAspectRatio()); - buffer = replace(buffer, "aspectRatio", ar); - } - - if(buffer.indexOf("<UsedWindow") >= 0) - { - String name = get(buffer, "name"); - if(name != null) - { - AWindow w = ACanvas.getCanvas().getWindow(name); - if(w != null) - { - if(w.getProjection() != null) - { - buffer = replace(buffer, "projection", w.getProjection().getName()); - } - buffer = replace(buffer, "group", w.getGroupName()); - } - } - } - - if(buffer.indexOf("<Layout") >= 0) - { - String name = get(buffer, "name"); - if(name != null && name.equals(ACanvas.getCanvas().getCurrentLayout().getName())) - { - buffer = replace(buffer, "startupWindow", ACanvas.getCanvas().getCurrentWindowName()); - buffer = replace(buffer, "startup", ACanvas.getCanvas().getStartupString()); - } - } - - // new group encountered - if(buffer.indexOf("<Group") >= 0) - { - groupName = get(buffer, "name"); - } - - // new parameter encountered - aParam = null; - if(buffer.indexOf(" fn=\"") >= 0 && - buffer.indexOf("<StatusRoot") < 0 && - buffer.indexOf("<StatusGroup") < 0) - { - parameterName = removeSpaces(get(buffer, "fn")); - aParam = parameterStore.getUnknown(groupName, parameterName); - } - if(aParam != null) - { - // replacing status - if(buffer.indexOf(" st=\"") >= 0) - { - String status = "OFF"; - if(aParam.getStatus()) - { - status = "ON"; - } - buffer = replace(buffer, "st", status); - } - - // replacing value - if(buffer.indexOf(" va=\"") >= 0) - { - String value = aParam.getValue(); - - if(parameterName.equals("Area/Energy")) - { - value = "0.0"; - } - // for instance Track Collections listbox should - // always remain: - // sn="Track Collections" va="0" pv="none=0" - // current 'value' mustn't be put there - else if(parameterName.endsWith("Collections")) - { - value = "0"; - } - buffer = replace(buffer, "va", value); - - } - - // replacing operator - if(buffer.indexOf(" dop=\"") >= 0) - { - String dop = aParam.getOperator(); - if(dop.equals("<")) - { - dop = "<"; - } - if(dop.equals("<=")) - { - dop = "≤"; - } - if(dop.equals(">")) - { - dop = ">"; - } - if(dop.equals(">=")) - { - dop = "≥"; - } - buffer = replace(buffer, "dop", dop); - } - - // replacing scope - if(buffer.indexOf(" scope=\"") >= 0) - { - if(aParam.getScope() == AParameter.GLOBAL) - { - buffer = replace(buffer, "scope", "GLOBAL"); - } - else if(aParam.getScope() == AParameter.LOCAL) - { - buffer = replace(buffer, "scope", "LOCAL"); - } - } - else if(buffer.indexOf(" fn=\"") > 0) - { - // in a parameter - adding scope if needed - if(aParam.getScope() != parameterStore.getGroup(groupName).getScope()) - { - int index = buffer.indexOf("/>"); - if(index > 0) - { - if(aParam.getScope() == AParameter.GLOBAL) - { - buffer.insert(index, - " scope=\"GLOBAL\""); - } - else - { - buffer.insert(index, - " scope=\"LOCAL\""); - } - } - } - } - } // aParam != null - } // !inComment - output.append(buffer); - output.append("\n"); - } // while - curr.close(); - } // try - catch(IOException ex) - { - String m = "I/O error occured when reading the source " + - "configuration file: " + fileName; - logger.error(m); - logger.debug(m, ex); - output = null; - } - catch(AAtlantisException ae) - { - //throw ae; - } - - - return (output != null) ? output.toString() : null; - - } // readConfiguration() ------------------------------------------------ - - - - /** - * Removing spaces from the parameter name - * @param name String - * @return String - */ - private static String removeSpaces(String name) - { - StringBuffer strBuffer = new StringBuffer(name); - int i = 0; - while(i < strBuffer.length()) - { - if(Character.isWhitespace(strBuffer.charAt(i))) - { - strBuffer.deleteCharAt(i); - } - else - { - i++; - } - } - return new String(strBuffer); - } // removeSpaces() ----------------------------------------------------- - - - private static StringBuffer replace(StringBuffer s, String variable, String text) - { - int name = s.indexOf(variable + "=\""); - if(name >= 0) - { - int start = s.indexOf("\"", name); - int stop = s.indexOf("\"", start + 1); - s.delete(start + 1, stop); - s.insert(start + 1, text); - } - - return s; - } // replace() ---------------------------------------------------------- - - - private static String get(StringBuffer s, String variable) - { - // insert a space before the variable name to prevent from the variable - // name is a substring of another variable name - int name = s.indexOf(" " + variable + "=\""); - if(name >= 0) - { - int start = s.indexOf("\"", name); - int stop = s.indexOf("\"", start + 1); - return s.substring(start + 1, stop); - } - return null; - } // get() -------------------------------------------------------------- - -} // class AConfigWriter ==================================================== diff --git a/graphics/AtlantisJava/src/atlantis/gui/AControlButton.java b/graphics/AtlantisJava/src/atlantis/gui/AControlButton.java deleted file mode 100755 index 007cd04275719ba024d9bead8fd30f42993a5d80..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AControlButton.java +++ /dev/null @@ -1,84 +0,0 @@ -package atlantis.gui; - -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.Timer; -import javax.swing.JButton; - -/** - * This class is not used at the moment. - * Was used to control animation. - */ -public class AControlButton extends JButton { - - public static final int STANDARD_ACTION=0; - public static final int ACCELERATED_ACTION=1; - - private ActionListener controlListener; - private ActionEvent standardAction, acceleratedAction; - private long ticks; - private Timer timer; - private int initialDelay; - private int tickLength; - private int accelerationLimit; - private boolean ignoreClick=false; - - public AControlButton(String text, int initialDelay, int tickLength, int accelerationLimit) { - super(text); - this.initialDelay=initialDelay; - this.tickLength=tickLength; - this.accelerationLimit=accelerationLimit; - initialize(); - } - - private void initialize() { - standardAction=new ActionEvent(this, 0, "", STANDARD_ACTION); - acceleratedAction=new ActionEvent(this, 0, "", ACCELERATED_ACTION); - - timer=new Timer(tickLength, new ActionListener() { - public void actionPerformed(ActionEvent e) { - ticks++; - fireControlActionPerformed(); - ignoreClick=true; - } - }); - timer.setInitialDelay(initialDelay); - - addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - ticks=0; - timer.restart(); - } - - public void mouseReleased(MouseEvent e) { - timer.stop(); - } - - public void mouseClicked(MouseEvent e) { - if(ignoreClick) - ignoreClick=false; - else - fireControlActionPerformed(); - } - }); - - } - - private void fireControlActionPerformed() { - if(controlListener!=null) { - if(ticks>accelerationLimit) - controlListener.actionPerformed(acceleratedAction); - else - controlListener.actionPerformed(standardAction); - } - } - - public void addControlActionListener(ActionListener controlListener) { - if(this.controlListener!=null) - throw new Error("AControlButton supports only 1 listener"); - this.controlListener=controlListener; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ACrashReporter.java b/graphics/AtlantisJava/src/atlantis/gui/ACrashReporter.java deleted file mode 100644 index d47949481a8fca9bdf66d845d3895f41872e2a52..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ACrashReporter.java +++ /dev/null @@ -1,232 +0,0 @@ -// NOTE: revert to previous version once support for Java 1.5 is dropped - -package atlantis.gui; - -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.globals.AGlobals; -import java.awt.Desktop; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.lang.Thread.UncaughtExceptionHandler; -import java.net.URI; -import java.net.URLEncoder; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; - -/** - * This class handles any unhandled exception (program crash). It asks the user for - * permission to submit a crash report by e-mail and pre-formats the message. It then - * fires the default system mail client with this message to allow the user to add - * additional commands and send it. - * - * @author Eric Jansen - */ -public class ACrashReporter implements UncaughtExceptionHandler { - - // Dialog asking for permission to report the crash - private static final String title = "An uncaught exception occured"; - private static final String msg = - "An uncaught exception occured!\n\n" - + "Please help us prevent this in the future by reporting this incident.\n" - + "If you click yes, Atlantis will try to open your mail client and create\n" - + "a preformatted crash report for you. You can review the information\n" - + "and add additional comments before it is sent.\n\n" - + "Do you want to report this crash?"; - - // Address that receives crash reports, chopped up in case spiders go through this code - private static final String address = "atlas-atlantis-developers" + "@" + "cern" + "." + "ch"; - - // Tag for easy filtering, prefix for the mail subject - private static final String tag = "[crash-report] "; - - // System properties included in the report - private static final String[] properties = { - "java.version", "java.vendor", "java.vm.specification.version", - "java.vm.specification.vendor", "java.vm.specification.name", "java.vm.version", - "java.vm.vendor", "java.vm.name", "java.specification.version", "java.specification.vendor", - "java.specification.name", "os.name", "os.arch", "os.version"}; - - /** Flag indicating whether CrashReporter has already been shown */ - private static boolean shownCrashReporter = false; - - /** - * Exception handler for uncaught exceptions in Atlantis. The only way to - * "handle" such an exception is to tell the developers that they failed. - * So that is what we will do. - * @param t thread - * @param e uncaught exception - */ - public void uncaughtException(Thread t, Throwable e) { - // Ensure this only happens once - if (shownCrashReporter) return; - shownCrashReporter = true; - - int confirm = JOptionPane.showConfirmDialog(null, msg, title, - JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null); - - if (confirm == JOptionPane.YES_OPTION) { - String report = "### Please explain briefly what you did when the problem occured (optional)\n\n"; - - report += "\n### Exception information\n\n"; - report += getExceptionInformation(e); - - report += "\n### General information\n\n"; - report += getGeneralInformation(); - - report += "\n### Event information\n\n"; - report += getEventInformation(); - - // If possible, we open the mail client and create a new message - if (Desktop.isDesktopSupported()) { - Desktop desktop = Desktop.getDesktop(); - - if (desktop.isSupported(Desktop.Action.MAIL)) { - String subject = getSubject(e); - try { - URI uri = new URI("mailto:" + address + "?SUBJECT=" - + encode(subject) + "&BODY=" + encode(report)); - desktop.mail(uri); - } catch (Throwable ex) { - // Something went wrong, save report to file instead - saveToFile(report); - } - } else { - // No mail support, save report to file instead - saveToFile(report); - } - } else { - // No desktop support, save report to file instead - saveToFile(report); - } - } - } - - /** - * Provides mail encoding of a string (URLEncoding but with %20 for space) - * @param s string to encode - * @return encoded string - */ - private static String encode(String s) { - try { - return URLEncoder.encode(s, "utf-8").replaceAll("\\+", "%20"); - } catch (Throwable ex) { - return s; - } - } - - /** - * This provides is the backup option if starting the mail client doesn't - * work. The report will be saved to a local file and we ask the user to - * send it. - * @param report crash report contents - */ - private void saveToFile(String report) { - String directory = AGlobals.instance().getHomeDirectory(); - JFileChooser chooser = new JFileChooser(directory); - chooser.setDialogTitle("Save crash report"); - chooser.setSelectedFile(new File("crash-report.txt")); - - // Remind people where this report should go at the top of the file - report = "### Atlantis crash report, please send to " + address + "\n\n" - + report; - - // Continue asking until the user chooses a valid file or cancels - while (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { - File file = chooser.getSelectedFile(); - try { - OutputStream out = new FileOutputStream(file.getAbsolutePath()); - out.write(report.getBytes()); - out.close(); - - JOptionPane.showMessageDialog(null, "The crash report has been saved successfully.\n" - + "Please send the file to " + address); - return; - } catch (Throwable ex) { - JOptionPane.showMessageDialog(null, "Cannot write file: " + ex.toString()); - } - } - } - - /** - * Takes the exception and finds the most helpful mail subject, in general - * the exact location of the crash should be helpful when dealing with a - * lot of reports. - * @param e uncaught exception - * @return subject string - */ - private static String getSubject(Throwable e) { - StackTraceElement[] st = e.getStackTrace(); - if (st.length > 0) { - return tag + st[0].toString(); - } else { - return tag + e.toString(); - } - } - - /** - * Formats general information about the system, Java and Atlantis - * @return information string - */ - private static String getGeneralInformation() { - StringBuilder s = new StringBuilder(); - s.append("Atlantis version = " + AGlobals.instance().getVersion() + "\n"); - - for (String property : properties) { - String value = System.getProperty(property); - if (value == null) { - value = "(not set)"; - } - s.append(property + " = " + value + "\n"); - } - - return s.toString(); - } - - /** - * Formats stack trace and exception information - * @param e unhandled exception - * @return information string - */ - private static String getExceptionInformation(Throwable e) { - StringBuilder s = new StringBuilder(); - String pad = ""; - - s.append(e.toString() + "\n\n"); - - StackTraceElement[] st = e.getStackTrace(); - for (StackTraceElement traceline : st) { - s.append(pad + traceline + "\n"); - pad = " "; - } - - return s.toString(); - } - - /** - * Formats event information, such as source, file, run/event and datatypes - * @return information string - */ - private static String getEventInformation() { - StringBuilder s = new StringBuilder(); - AEventManager eventManager = AEventManager.instance(); - AEvent event = eventManager.getCurrentEvent(); - if (event == null) { - return "(no current event)"; - } - - s.append("Source = " + event.getSourceName() + "\n"); - s.append("Run = " + event.getRunNumber() + "\n"); - s.append("Event = " + event.getEventNumber() + "\n"); - - s.append("\nData types present:\n"); - String[][] info = event.getInfo(); - for (String[] item : info) { - s.append(" " + item[0] + " (" + item[1] + ")\n"); - } - - return s.toString(); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ADefaultCellAttribute.java b/graphics/AtlantisJava/src/atlantis/gui/ADefaultCellAttribute.java deleted file mode 100755 index 1a17ebd0ef9781dbd990f94c82ac52c7b062c993..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ADefaultCellAttribute.java +++ /dev/null @@ -1,129 +0,0 @@ -package atlantis.gui; - -import java.awt.Dimension; - -public class ADefaultCellAttribute -{ - public static final int ROW = 0; - public static final int COLUMN = 1; - - // - // !!!! CAUTION !!!!! - // these values must be synchronized to Table data - // - protected int rowSize; - protected int columnSize; - protected int[][][] span; - - public ADefaultCellAttribute() - { - this(1, 1); - } - - public ADefaultCellAttribute(int numRows, int numColumns) - { - setSize(new Dimension(numColumns, numRows)); - } - - protected void initValue() - { - for (int i = 0; i < span.length; i++) - { - for (int j = 0; j < span[i].length; j++) - { - span[i][j][COLUMN] = 1; - span[i][j][ROW] = 1; - } - } - } - - public int[] getSpan(int row, int column) - { - if (isOutOfBounds(row, column)) - { - int[] ret_code = { 1, 1 }; - return ret_code; - } - return span[row][column]; - } - - public boolean isVisible(int row, int column) - { - if (isOutOfBounds(row, column)) - return false; - if ((span[row][column][COLUMN] < 1) - || (span[row][column][ROW] < 1)) - return false; - return true; - } - - public void combine(int[] rows, int[] columns) - { - if (isOutOfBounds(rows, columns)) - return; - int rowSpan = rows.length; - int columnSpan = columns.length; - int startRow = rows[0]; - int startColumn = columns[0]; - for (int i = 0; i < rowSpan; i++) - { - for (int j = 0; j < columnSpan; j++) - { - if ((span[startRow + i][startColumn + j][COLUMN] != 1) - || (span[startRow + i][startColumn + j][ROW] != 1)) - { - return; - } - } - } - for (int i = 0, ii = 0; i < rowSpan; i++, ii--) - { - for (int j = 0, jj = 0; j < columnSpan; j++, jj--) - { - span[startRow + i][startColumn + j][COLUMN] = jj; - span[startRow + i][startColumn + j][ROW] = ii; - } - } - span[startRow][startColumn][COLUMN] = columnSpan; - span[startRow][startColumn][ROW] = rowSpan; - } - - public Dimension getSize() - { - return new Dimension(rowSize, columnSize); - } - - public void setSize(Dimension size) - { - columnSize = size.width; - rowSize = size.height; - span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW - initValue(); - } - - protected boolean isOutOfBounds(int row, int column) - { - if ((row < 0) || (rowSize <= row) || (column < 0) - || (columnSize <= column)) - { - return true; - } - return false; - } - - protected boolean isOutOfBounds(int[] rows, int[] columns) - { - for (int i = 0; i < rows.length; i++) - { - if ((rows[i] < 0) || (rowSize <= rows[i])) - return true; - } - for (int i = 0; i < columns.length; i++) - { - if ((columns[i] < 0) || (columnSize <= columns[i])) - return true; - } - return false; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ADemoDialog.java b/graphics/AtlantisJava/src/atlantis/gui/ADemoDialog.java deleted file mode 100755 index be69b6c21e26ecb79846586f4f3dca471762322e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ADemoDialog.java +++ /dev/null @@ -1,434 +0,0 @@ -package atlantis.gui; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Toolkit; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JSeparator; -import javax.swing.JSpinner; -import javax.swing.JTextField; -import javax.swing.SpinnerNumberModel; -import javax.swing.SwingConstants; -import javax.swing.WindowConstants; -import javax.swing.border.Border; - -import java.util.Arrays; -import java.util.Vector; - -import atlantis.globals.AGlobals; -import atlantis.graphics.AIcon; -import atlantis.projection.AProjectionsManager; -import atlantis.parameters.ACommandProcessor; -import atlantis.utils.ALogger; - - - - - -/** - * A Dialog in which user can set parameters for demo mode, as well as start and - * stop the demo mode. This class holds and controls the demo loop thread. - * This is a singleton, but there is no point why it needs to be. - * - * @author Sebastian Boeser (with traces from Qiang Lu) - */ -public class ADemoDialog extends JFrame implements ActionListener -{ - //Get a logger - private final static ALogger logger = ALogger.getLogger(ADemoDialog.class); - - //Some GUI elements - private JSpinner timerSpinner; - private SpinnerNumberModel timerSpinnerModel; - private static final Integer TIMER_MIN = new Integer(1); - private static final Integer TIMER_MAX = new Integer(120); - private static final Integer TIMER_INIT = new Integer(3); - - //The text label showing the projection sequence - private JTextField sequenceTextField = null; - //And the panel housing these - private JPanel projControlPanel=null; - - //The action buttons - private JButton startButton = null; - private JButton stopButton = null; - private JButton closeButton = null; - - - //The thread that is runing the loop - private ADemoLoop demo = null; - - private static final AGlobals globals = AGlobals.instance(); - - //The singleton instance - private static ADemoDialog instance = null; - - /** - * Public access-instantiation accessor - * @return the singleton instance - */ - public static ADemoDialog getInstance(){ - //Create instance if needed - if (instance == null) instance = new ADemoDialog(); - //and return it - return instance; - } - - /** - * Private Constructor - */ - private ADemoDialog() { - super("Demo"); - createGUI(); - pack(); - } - - // initialize the GUI - private void createGUI() - { - JPanel timerControlPanel = createTimeControlPanel(); - projControlPanel = createProjControlPanel(); - JPanel buttonControlPanel = createButtonControlPanel(); - - JPanel contentPane = new JPanel(new GridBagLayout()); - contentPane.setOpaque(true); - GridBagConstraints c = new GridBagConstraints(); - c.weightx = 1; - c.weighty = 1; - c.gridwidth = GridBagConstraints.REMAINDER; - c.fill=GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - contentPane.add(timerControlPanel, c); - contentPane.add(projControlPanel, c); - contentPane.add(buttonControlPanel, c); - this.setResizable(false); - this.setContentPane(contentPane); - this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - this.setAlwaysOnTop(true); - - // set the initial location - Frame gui = globals.getGuiFrame(); - int guiWidth = gui.getWidth(); - int guiHeight = gui.getHeight(); - int guiX = gui.getX(); - int dialogWidth = (int) this.getPreferredSize().getWidth(); - int dialogHeight = (int) this.getPreferredSize().getHeight(); - int screenWidth = Math.round((float) Toolkit.getDefaultToolkit().getScreenSize().getWidth()); - if(guiX + guiWidth + (dialogWidth - guiWidth) / 2 > screenWidth) - this.setLocation(Math.max(0, screenWidth - dialogWidth), - Math.max(0, (guiHeight - dialogHeight) / 3)); - else - this.setLocation(Math.max(0, guiX + (guiWidth - dialogWidth) / 2), - Math.max(0, (guiHeight - dialogHeight) / 3)); - AIcon.setIconImage(this); - } - - private JPanel createTimeControlPanel() - { - - JPanel aPanel = new JPanel(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - aPanel.setOpaque(true); - //aPanel.setPreferredSize(new Dimension(FRAME_WIDTH, PANEL_HEIGHT)); - aPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); - - //Add timer label - JLabel timerLabel= new JLabel("Interval"); - c.gridwidth = 1; - c.fill = GridBagConstraints.HORIZONTAL; - c.weightx=1; - c.gridx=0; - aPanel.add(timerLabel,c); - //Add timer spinner - timerSpinner = new JSpinner(); - timerSpinner.setEnabled(true); - timerSpinnerModel = new SpinnerNumberModel(TIMER_INIT, TIMER_MIN, - TIMER_MAX, new Integer(1)); - timerSpinner.setModel(timerSpinnerModel); - c.gridwidth = 1; - c.weightx=1; - c.fill = GridBagConstraints.HORIZONTAL; - c.gridx=1; - aPanel.add(timerSpinner,c); - //Add units label - c.weightx = 0.5; - c.gridwidth = GridBagConstraints.REMAINDER; - c.gridx=2; - aPanel.add(new JLabel(" sec"),c); - - - //Add the labels for th selected projections - c.gridx=GridBagConstraints.RELATIVE; - c.weightx=1; - c.gridwidth=1; - aPanel.add(new JLabel("Sequence:"), c); - - //Now generate the sequence label and make it span the remaining columns - sequenceTextField = new JTextField(); - c.gridwidth=GridBagConstraints.REMAINDER; - c.fill=GridBagConstraints.HORIZONTAL; - aPanel.add(sequenceTextField,c); - - return aPanel; - } - - private JPanel createProjControlPanel() - { - - JPanel aPanel = new JPanel(new GridLayout(3,4)); - aPanel.setOpaque(true); - Border outerBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5); - Border innerBorder = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.GRAY), - "Add Projection / Action"); - aPanel.setBorder(BorderFactory.createCompoundBorder(outerBorder, innerBorder)); - - //Create the list of check boxes - for (String projName : AProjectionsManager.getKnownProjectionNames()){ - - //Check wether this projection name should be used in the demo dialog - if (AProjectionsManager.useProjectionInDemoMode(projName)){ - - //Create the respective button with the screen name of the projection - String projScreenName = AProjectionsManager.getProjection(projName).getScreenName(); - JButton projButton = new JButton(projScreenName); - //Store the name of the projection as the name of the JCheckBox - //Where we can retrieve it once the demo dialog is started - projButton.setName(projName); - projButton.setFocusPainted(false); - - //Add ourselves as action listener of this button - projButton.addActionListener(this); - aPanel.add(projButton); - } - } - //Also add a "next event" button - JButton nextEvtBut = new JButton("Next event"); - nextEvtBut.setName("NE"); - nextEvtBut.addActionListener(this); - aPanel.add(nextEvtBut); - - return aPanel; - } - - private JPanel createButtonControlPanel() - { - //final int PANEL_HEIGHT = 40; - Dimension buttonDimension = new Dimension(100,25); - - JPanel aPanel = new JPanel(new GridBagLayout()); - aPanel.setOpaque(true); - //aPanel.setPreferredSize(new Dimension(FRAME_WIDTH, PANEL_HEIGHT)); - aPanel.setBorder(BorderFactory.createEmptyBorder(5,5,10,5)); - - GridBagConstraints c = new GridBagConstraints(); - startButton = new JButton("Start"); - //startButton.setFocusPainted(false); - startButton.setEnabled(true); - startButton.setPreferredSize(buttonDimension); - startButton.addActionListener(this); - c.weightx = 1; - c.weighty = 1; - c.anchor = GridBagConstraints.CENTER; - aPanel.add(startButton, c); - stopButton = new JButton("Stop"); - stopButton.setFocusPainted(false); - stopButton.setEnabled(false); - stopButton.setPreferredSize(buttonDimension); - stopButton.addActionListener(this); - aPanel.add(stopButton, c); - JSeparator aSeparator = new JSeparator(SwingConstants.VERTICAL); - //aSeparator.setPreferredSize(new Dimension(5, PANEL_HEIGHT)); - aPanel.add(aSeparator, c); - closeButton = new JButton("Close"); - closeButton.setFocusPainted(false); - closeButton.setEnabled(true); - closeButton.setPreferredSize(buttonDimension); - closeButton.addActionListener(this); - c.gridwidth = GridBagConstraints.REMAINDER; - aPanel.add(closeButton, c); - - return aPanel; - } - - /** - * @return true if demo thread is running, otherwise false - */ - boolean isRunning(){ - //no thread -> false - if (demo == null) return false; - //otherwise use thread status - return demo.isRunning(); - } - - - // return interval in millisecond - int getTimerInterval() - { - return 1000 * timerSpinnerModel.getNumber().intValue(); - } - - public void setTimerInterval(Integer intervalInSec) - { - try { - timerSpinnerModel.setValue(intervalInSec); - } catch (IllegalArgumentException iae){ - //Just ignore in case of illegal argument - } - } - - - /** - * Set the sequence of projections - * @param projNames colon seperated list of projection names - */ - public void setSequence(String projNames){ - //store this in our text entry - sequenceTextField.setText(projNames); - } - - /** - * Set the default sequence - */ - public void setDefaultSequence(){ - //Create default sequence - StringBuilder sequence = new StringBuilder(); - //Add all default projections - for (String projName : AProjectionsManager.getKnownProjectionNames()){ - if (AProjectionsManager.defaultProjectionInDemoMode(projName)) - sequence.append(projName+":"); - } - //End sequence with next event - sequence.append("NE"); - //And set this in the text field - sequenceTextField.setText(sequence.toString()); - } - - /** - * @return a vector with the names of the projections - */ - private Vector<String> getSequence() - { - return new Vector<String>(Arrays.asList(sequenceTextField.getText().split(":"))); - } - - /** - * Validate whether the given sequence is valid - * @return the number of selected projections - */ - private boolean validateSequence() - { - //Get the projections sequence - Vector<String> sequence = getSequence(); - - //Check on number of projections - if(sequence.size() < 1){ - JOptionPane.showMessageDialog(this, - "No projection/event is selected, please select at least select one", - "Warning", JOptionPane.WARNING_MESSAGE); - return false; - } - - //Now check each item of the sequence for validity - for (String projName : sequence){ - //The "new event" action is an exception here - if (projName.equals("NE")) continue; - //check wether this is a known and allowed projection - if ((! Arrays.asList(AProjectionsManager.getKnownProjectionNames()).contains(projName)) || - (! AProjectionsManager.useProjectionInDemoMode(projName))) - { - JOptionPane.showMessageDialog(this, - "Not a valid projection name: '"+projName+"'", - "Warning", JOptionPane.WARNING_MESSAGE); - return false; - } - - } - - //Seems all okay - return true; - } - - - - /** - * Start the demo thread - */ - public void startDemo() - { - - //First make sure some projections have been selected - if (!validateSequence()) return; - - //Set single full window mode - ACommandProcessor.receive("WW"); - - //Start the demo, setting "stopOnNoMoreEvents" to false - //TODO: make stopOnNoMoreEvents a checkbox in the Dialog - demo = new ADemoLoop(getTimerInterval(),getSequence(),false); - demo.startDemoLoop(); - //Now disable all GUI elements - timerSpinner.setEnabled(false); - sequenceTextField.setEnabled(false); - for (Component comp: projControlPanel.getComponents()) comp.setEnabled(false); - startButton.setEnabled(false); - stopButton.setEnabled(true); - closeButton.setEnabled(false); - //Do not allowe the user to close the window, so he doesn't loose access - this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); - } - - /** - * Stop the demo thread - */ - synchronized void stopDemo() - { - //exit the demo - demo.stopDemoLoop(); - //Now reenable all GUI elements - timerSpinner.setEnabled(true); - sequenceTextField.setEnabled(true); - for (Component comp: projControlPanel.getComponents()) comp.setEnabled(true); - stopButton.setEnabled(false); - startButton.setEnabled(true); - closeButton.setEnabled(true); - - this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - } - - /** - * Implementation of the Action listener - * - gets called for every button that is pressed - * @param e the action event - */ - public void actionPerformed(ActionEvent e) { - //Check for action buttons first - if (e.getSource() == startButton ) startDemo(); - else if (e.getSource() == stopButton) stopDemo(); - else if (e.getSource() == closeButton ) dispose(); - //this should be one of the projection buttons - else { - //get the projectio name to append - String projName = ((JButton)e.getSource()).getName(); - //get the existing sequence - String sequence = sequenceTextField.getText(); - //append new projection - sequence += ((sequence.length()!=0) ? ":" : "") + projName; - //Set this as new sequence - sequenceTextField.setText(sequence); - } - - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ADemoFileChooser.java b/graphics/AtlantisJava/src/atlantis/gui/ADemoFileChooser.java deleted file mode 100755 index c9768ef7aab889827c054a0eb3421a22b969fc16..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ADemoFileChooser.java +++ /dev/null @@ -1,41 +0,0 @@ -package atlantis.gui; - -import java.awt.Component; -import java.io.File; - -import atlantis.config.ADefaultValues; - -/** -* A dialog which appears when a user asks to read a new event. -* -* @author Qiang Lu -*/ -public class ADemoFileChooser extends AXMLFileChooser -{ - private File fileSelected; - - public ADemoFileChooser(String path, Component parent) - { - super(path, parent); - } - - public boolean processSelectedFile(File file) - { - if (file.canRead()) - { - // save last visited location - ADefaultValues.set("LastEventFilesSourceDir", file.getParent() + - System.getProperty("file.separator")); - - fileSelected = file; - return true; - } - return false; - } - - public File getFileSelected() - { - return fileSelected; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ADemoLoop.java b/graphics/AtlantisJava/src/atlantis/gui/ADemoLoop.java deleted file mode 100755 index 85f387a9708008ffbedef8bf2b73c178ab12b5e9..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ADemoLoop.java +++ /dev/null @@ -1,200 +0,0 @@ -package atlantis.gui; - -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.util.ArrayList; - -import atlantis.canvas.ACanvas; -import atlantis.event.AEventManager; -import atlantis.event.AEventSource.InvalidEventSourceException; -import atlantis.event.AEventSource.NoMoreEventsException; -import atlantis.event.AEventSource.ReadEventException; -import atlantis.globals.AGlobals; -import atlantis.projection.AProjection; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionsManager; -import atlantis.parameters.ACommandProcessor; -import atlantis.utils.ALogger; -import java.awt.event.ActionListener; -import java.util.Iterator; -import java.util.Vector; -import javax.swing.JOptionPane; - -import javax.swing.Timer; - -/** - * A class to automatically loop over different projections given in a - * colon-seperated list. The special projection name "NE" stands for next event. - * This is also used in headless mode to generate an event loop. The stopOnNoMoreEvents - * allows to control wether the loop ends if no more events can be obtained. - * - * NOTE: The previous implementation of this was using java.awt.Thread - we are - * far from providing the standards of a thread-safe application. - * - * @author Sebastian Boeser - */ -public class ADemoLoop extends Timer implements ActionListener -{ - //The logger - private static ALogger logger = ALogger.getLogger(ADemoLoop.class); - - //whether to stop the loop if there are no more events - private boolean stopOnNoMoreEvents = false; - - //A list of projections to show - private final ArrayList<String> projectionList = new ArrayList<String>(); - - //An iterator that loops through the list above - private Iterator<String> projIter = null; - - private static final AGlobals globals = AGlobals.instance(); - - /** - * Fully specified Constructor - * @param sleepTime time to sleep inbetween projections in milliseconds - * @param projectionList list of projections to loop through - * @param stopOnNoMoreEvents wether to stop loop if there are no more events - */ - public ADemoLoop(int sleepTime, Vector<String> projectionList, boolean stopOnNoMoreEvents){ - - //Initialize the timer - super(sleepTime,null); - addActionListener(this); - - //Initialize the timer to start immediately only on first event - setInitialDelay(0); - - //Store the list of projections - for (String projName : projectionList) - this.projectionList.add(projName); - - //Set the stop on no more events flag - this.stopOnNoMoreEvents = stopOnNoMoreEvents; - - } - - - /*** - * prepare the demo loop and start the timer thread - */ - public void startDemoLoop(){ - AGlobals.instance().setDemoMode(true); - - //be verbose - logger.trace("Starting demo loop with interval "+Integer.toString(getDelay())+ - " ms and projections "+projectionList.toString()); - - //Generate the list iterator to point to the start of the list - projIter = projectionList.listIterator(0); - - //Finally start the loop - start(); - } - - /** - * stop the demo loop - */ - public void stopDemoLoop(){ - stop(); - globals.setDemoMode(true); - } - - /** - * This gets fired by the timer every time after it returns from sleep - * @param event the action event - */ - public void actionPerformed(ActionEvent event) { - - //If we have reached the end, start from beginning - if (! projIter.hasNext()) projIter = projectionList.listIterator(0); - - //proceed to next element in list - String projName = projIter.next(); - - //add debugging output - logger.trace("Next in demo loop: "+projName); - - //Check if this is a next event tag - if (projName.equals("NE")) { - //Change the event or stop loop if this did not succeed - if (!changeEvent()) { - //stop the loop - stop(); - //notify everyone that we are done (so the application can finish) - synchronized(this) { notifyAll(); } - } - - //Immediatly go to the next projection if this is not just a nextEvent again - Iterator<String> nextProjIter = projIter; - if (nextProjIter.hasNext() && (!nextProjIter.next().equals("NE"))) restart(); - //be verbose - logger.trace("Timer is"+(isRunning()?" running":" stopped")+" with "+getDelay()+" ms delay"); - } - //else just change the projection - else changeProjection(projName); - - } - - - /** - * Change the current projection to the one given by projName - * and select that as active projeciton in the GUI - * @param projName the name of the projection - */ - private void changeProjection(String projName) - { - //First get the projection object - AProjection p = AProjectionsManager.getProjection(projName); - //And set the projection - ACanvas.getCanvas().getCurrentWindow().setProjection(p); - //Make sure aspect ratio is always okay - if(projName.equals("YX")||projName.equals("RZ")||projName.equals("XZ")||projName.equals("YZ")) - ((AProjection2D) p).setAspectRatio1(ACanvas.getCanvas().getCurrentWindow()); - //Finally Change the current GUI selection by signaling the command processor - ACommandProcessor.receive(projName + "."); - } - - /** - * Switch to the next event - * @return if the return value is true, the loop will be continued, otherwise not - */ - private boolean changeEvent(){ - Frame gui = globals.getGuiFrame(); - //try reading the next event - try{ - //Then get next event - AEventManager eventManager = AEventManager.instance(); - eventManager.nextEvent(); - return true; - } catch (NoMoreEventsException ex) { - //Just wait for next event - logger.info("No next event for demo - "+((stopOnNoMoreEvents)?"stopping loop":"keeping same")); - //return wether loop shall be stopped due to this or not. - return (!stopOnNoMoreEvents); - } catch (InvalidEventSourceException ex) { - //log warning - logger.warn("Invalid event source for demo - " - +((stopOnNoMoreEvents)?"stopping loop":"will try again") - +"\n"+ex.getCauseMessages()); - //quit here in headless mode - if (AGlobals.isAtlantisHeadless()) return (!stopOnNoMoreEvents); - //Otherwise give a user warning - JOptionPane.showMessageDialog(gui, - "Invalid event source for demo - stopping loop", - "Warning", JOptionPane.WARNING_MESSAGE); - //Always quit the loop if not in headless mode - return false; - } catch (ReadEventException ex) { - //log warning - logger.warn("Received invalid event - stopping loop:\n"+ex.getCauseMessages()); - //and tell user unless we are in headless - if (AGlobals.isAtlantisHeadless()) return false; - //in headless mode, don't show a dialog - JOptionPane.showMessageDialog(gui, - "Received invalid event for demo - stopping loop", - "Warning", JOptionPane.WARNING_MESSAGE); - return false; - } - } -} - diff --git a/graphics/AtlantisJava/src/atlantis/gui/AEventLoopDialog.java b/graphics/AtlantisJava/src/atlantis/gui/AEventLoopDialog.java deleted file mode 100755 index 152bc9f5c2cd408a41b126f96c773a9751c3f451..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AEventLoopDialog.java +++ /dev/null @@ -1,346 +0,0 @@ -package atlantis.gui; - -import java.util.Date; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.event.WindowListener; -import java.awt.event.WindowEvent; -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; -import java.awt.BorderLayout; -import java.awt.Dimension; - -import java.text.SimpleDateFormat; - -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.border.Border; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JSpinner; -import javax.swing.SpinnerNumberModel; -import javax.swing.Timer; - -import atlantis.event.AEventManager; -import atlantis.event.AEventSource.NoMoreEventsException; -import atlantis.event.AEventSource.InvalidEventSourceException; -import atlantis.event.AEventSource.ReadEventException; -import atlantis.globals.AGlobals; -import atlantis.graphics.AIcon; -import atlantis.output.ALogInterface; -import atlantis.utils.ALogger; - - -/** - * Read events in a loop using a given timer intervall - * This is a singleton class using the getInstance pattern. - * - * @author Sebastian Boeser - */ -public class AEventLoopDialog extends JFrame - implements WindowListener, ActionListener, ChangeListener -{ - // the logger - private static ALogger logger = ALogger.getLogger(AEventLoopDialog.class); - - private static final AGlobals globals = AGlobals.instance(); - - //create singleton instance - private static AEventLoopDialog instance; - - // some GUI attributes - private static final String TITLE = "Event loop"; - private static final Integer SPINNER_INIT = new Integer(4); - private static final Integer SPINNER_MIN = new Integer(1); - private static final Integer SPINNER_MAX = new Integer(120); - private static final Integer SPINNER_STEP = new Integer(2); - - // We don't need more than one button - private static JButton button = null; - - //The update time in seconds - private static JSpinner updateIntervalSpinner = null; - //A logging pane - private static ALogPane log = null; - - // The update timer - private static final Timer timer = new Timer(SPINNER_INIT*1000,null); - - - private AEventLoopDialog() - { - //Create dialog with title - super(TITLE); - - //Construct GUI - createGUI(); - - } // AReadEventFromServerDialog() --------------------------------------- - - /** - * @return the singleton instance - */ - public static AEventLoopDialog getInstance(){ - if (instance == null) instance = new AEventLoopDialog(); - return instance; - } // getInstance() ------------------------------------------------------ - - - /** - * Non-static set functions so user is forced to obtain an instance first - * @param UpdateInterval the update intervall - */ - public void setUpdateInterval(int UpdateInterval) { - try { - updateIntervalSpinner.setValue(UpdateInterval); - } catch (IllegalArgumentException iae){ - //Just ignore in case of an invalid argument - } - } - - /** - * Design of the dialog - panels, buttons, etc - */ - private void createGUI() { - - //Definde default component gap - final int defaultGap = 5; - final Border defaultBorder = BorderFactory.createEmptyBorder(5, 10, 5, 10); - - /** - * Looping panel - */ - //Create a spinner for the update time - SpinnerNumberModel numberModel = new SpinnerNumberModel(SPINNER_INIT, SPINNER_MIN, SPINNER_MAX, SPINNER_STEP); - updateIntervalSpinner = new JSpinner(numberModel); - updateIntervalSpinner.addChangeListener(this); - - // looping panel - JPanel loopingPanel = new JPanel(); - loopingPanel.setLayout(new BorderLayout(defaultGap, 0)); - loopingPanel.setBorder(defaultBorder); - loopingPanel.add(updateIntervalSpinner, BorderLayout.CENTER); - loopingPanel.add(new JLabel("[secs]"), BorderLayout.EAST); - - - /** - * Main action buttons - */ - // action button panel - JPanel buttonsPanel = new JPanel(); - buttonsPanel.setLayout(new BorderLayout(0, 0)); - buttonsPanel.setBorder(defaultBorder); - button = new JButton("Start"); - //Set a preferred size so it doesn't change if we change its label - button.setPreferredSize(new Dimension(100,25)); - buttonsPanel.add(button, BorderLayout.CENTER); - //React when button is pressed - button.addActionListener(this); - - //the top row panel - JPanel topRowPanel = new JPanel(); - topRowPanel.setLayout(new BorderLayout(defaultGap, 0)); - topRowPanel.add(loopingPanel, BorderLayout.CENTER); - topRowPanel.add(buttonsPanel, BorderLayout.EAST); - - - - /** - * Logging panel - */ - // the logging panel at the bottom - JPanel logPanel = new JPanel(); - logPanel.setLayout(new BorderLayout(0, 0)); - logPanel.setBorder(defaultBorder); - //Add a logpane to it - log = new ALogPane(); - log.setEnabled(true); - log.setBorder(BorderFactory.createLineBorder(Color.black)); - log.setRequestFocusEnabled(false); - log.setPreferredSize(new Dimension(350, 200)); - logPanel.add(log, BorderLayout.CENTER); - - - // main panel - JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new BorderLayout(0, 0)); - // logPanel must be CENTER to be resisable vertically (otherwise, - // it keeps its size), hence upper part must be extra panel for - // NORTH position to accommodate topRowPanel and loopingPanel - JPanel upperMainPanel = new JPanel(); - upperMainPanel.setLayout(new BorderLayout(0, 0)); - upperMainPanel.add(topRowPanel, BorderLayout.NORTH); - mainPanel.add(upperMainPanel, BorderLayout.NORTH); - mainPanel.add(logPanel, BorderLayout.CENTER); - - // Finally add this MainPanel - getContentPane().add(mainPanel, BorderLayout.CENTER); - - //arrange all GUI items - pack(); - - //Set location to top left GUI corner so it does not hide Canvas - setLocation(globals.getGuiFrame().getLocation()); - - //give it a nice icon when minimized - AIcon.setIconImage(this); - - - /** - * end of dialog design, set listeners and handlers - */ //add ourselfs as state listeners to catch closing - addWindowListener(this); - - //also set ourselfs as action handler for the timer - timer.addActionListener(this); - //And have the timer start immediately on the first event - timer.setInitialDelay(0); - - - - } // createGUI() -------------------------------------------------------- - - /** - * State change events are only generated by the updateIntervalSpinner - * @param e the Change event - */ - public void stateChanged(ChangeEvent e) { - //Set timer delay to new value - timer.setDelay((Integer)updateIntervalSpinner.getValue()*1000); - } - - /** - * Stop event loop when closing the window - * @param e the Window event - */ - public void windowClosing(WindowEvent e){ - - //Make sure the timer is not running anymore - if (timer.isRunning()) stopEventLoop(); - - } // closeActionsAndDispose() ------------------------------------------ - - /** - * Small helper to print a message with timestamp to the log - * @param msg the message - */ - private void timeStampedLog(String msg){ - - //Record the time of the incident - SimpleDateFormat dateForm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - log.append("\n"+dateForm.format(new Date())+" ",ALogInterface.NORMAL_BOLD); - log.append(msg); - } - - - /** - * Try to read the next event from the server, handle all exceptions - */ - private void getNextEvent() { - - //try reading the next event - try{ - //tell the user - timeStampedLog("Reading next event..."); - //Then get next event - AEventManager.instance().nextEvent(); - } catch (NoMoreEventsException ex) { - //Just wait for next event - log.append("\n -- No next event available"); - logger.info("No next event available:\n"+ex.getCauseMessages()); - } catch (InvalidEventSourceException ex) { - //Do not break loop on invalid event source -- good for ACR - log.append("\n -- Invalid event source"); - logger.warn("Invalid event source:\n"+ex.getCauseMessages()); - } catch (ReadEventException ex) { - //Don't break loop on invalid events - log.append("\n -- Received invalid event"); - logger.warn("Received invalid event:\n"+ex.getCauseMessages()); - } - } - - /** - * Stop the event loop, reenabling all GUI elements - */ - private void stopEventLoop(){ - - //Stop the timer loop - timer.stop(); - - //Reset button label and states - button.setText("Start"); - updateIntervalSpinner.setEnabled(true); - - //tell the user - timeStampedLog("Stopped event loop..."); - } - - /** - * Start the event loop, disable all GUI elements - is public to facilitate - * automated start of event loop (e.g with command-line options) - */ - public void startEventLoop(){ - - //tell the user - timeStampedLog("Starting event loop..."); - - //enable/disable buttons - updateIntervalSpinner.setEnabled(false); - button.setText("Stop"); - - //Stop the timer loop - timer.start(); - - } - - /** - * Called every time the button is hit or we get a callback from the timer - * @param e the action event - */ - public void actionPerformed(ActionEvent e) { - - //Check if we got called from the timer loop - if (e.getSource() == timer){ - //If so just read next event and return - getNextEvent(); - return; - } - - //Being called because button was hit. - //Check if event loop is running - stop it - if (timer.isRunning()) { - stopEventLoop(); - } else { - startEventLoop(); - } - } - - - /** - * Show the dialog - */ - public void showDialog() { - - // clear the iconified bit (no matter whether or not it is iconified) - setExtendedState(getExtendedState() & ~Frame.ICONIFIED); - setVisible(true); - - } // show() ---------------------------------------------------- - - - /** - * Empty default implementation of WindowListeners - * @param e - */ - public void windowOpened(WindowEvent e) {} - public void windowClosed(WindowEvent e) {} - public void windowIconified(WindowEvent e) {} - public void windowDeiconified(WindowEvent e) {} - public void windowActivated(WindowEvent e) {} - public void windowDeactivated(WindowEvent e) {} - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AEventPropertiesDialog.java b/graphics/AtlantisJava/src/atlantis/gui/AEventPropertiesDialog.java deleted file mode 100755 index 8b7a7a332781aa3a6cefe049101a4ce28c509c2d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AEventPropertiesDialog.java +++ /dev/null @@ -1,721 +0,0 @@ -package atlantis.gui; - -import java.awt.BorderLayout; -import java.awt.Font; -import java.awt.Frame; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringReader; -import java.util.List; -import java.util.Vector; - -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import javax.swing.JTable; -import javax.swing.JScrollPane; - -import com.Ostermiller.util.CSVParser; - -import atlantis.data.ACalorimeterData; -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.data.ALVL1ResultData; -import atlantis.event.ANewEventListener; -import atlantis.globals.AGlobals; -import atlantis.graphics.AIcon; -import atlantis.graphics.layout.AFlowLayout; -import atlantis.data.ATriggerInfoData; -import atlantis.utils.AAtlantisException; -import atlantis.utils.ALogger; -import atlantis.utils.AUtilities; - -/** - * The dialog which is used to display the current event properties. - */ -public class AEventPropertiesDialog extends JFrame implements ANewEventListener -{ - private static ALogger logger = ALogger.getLogger(AEventPropertiesDialog.class); - private static AEventManager eventManager = AEventManager.instance(); - - private JTable table, propertiesTable, level1Table, level2Table, - eventFilterTable, trigInfoItemsTable, trigInfoStreamTable, - userSelectedTable, mbtsTable; - private JPanel buttonsPanel; - private JTabbedPane tabbedPane; - private JButton okButton; - private JButton refreshButton; - private static AEventPropertiesDialog instance = null; - protected static String[] USER_ITEMS = null; - private static final String LOOKUP_FILENAME = "epusti.csv"; - private static final AGlobals globals = AGlobals.instance(); - private static final String LOOKUP_FILE = - globals.getHomeDirectory() + "configuration" + - System.getProperty("file.separator") + - LOOKUP_FILENAME; - - public static boolean isInUse() - { - if(instance ==null || !instance.isVisible()) - return false; - else - return true; - } - - public static AEventPropertiesDialog getInstance() - { - if (instance == null) - instance = new AEventPropertiesDialog(); - return instance; - } - - public AEventPropertiesDialog() - { - Frame gui = globals.getGuiFrame(); - eventManager.addNewEventListener(this); - this.setTitle("Event Properties Dialog"); - AIcon.setIconImage(this); - // setResizable(false); - - // From Java 1.5 we can tell the window to be always on top - this.setAlwaysOnTop(true); - - // check whether there is any event data are present - if (eventManager.getCurrentEvent() == null) - { - JOptionPane.showMessageDialog(gui, - "Current event is null\n" + "(no event data currently present)", - "Event null", JOptionPane.WARNING_MESSAGE); - return; - } - - try - { - readFromLookupFile(); - } - catch(AAtlantisException ex) - { - logger.warn(": reading " + LOOKUP_FILE + - " failed, user trigger items will not " + - "be available, reason: " + ex.getMessage(), ex); - } - - fillTabbedPane(0); - addButtonPane(); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - pack(); - - // set the initial location - int guiWidth = gui.getWidth(); - int guiHeight = gui.getHeight(); - int guiX = gui.getX(); - int dialogWidth = (int) this.getPreferredSize().getWidth(); - int dialogHeight = (int) this.getPreferredSize().getHeight(); - int screenWidth = Math.round((float) Toolkit.getDefaultToolkit() - .getScreenSize().getWidth()); - if (guiX + guiWidth + (dialogWidth - guiWidth) / 2 > screenWidth) - this.setLocation(Math.max(0, screenWidth - dialogWidth), Math.max( - 0, (guiHeight - dialogHeight) / 3)); - else - this.setLocation(Math.max(0, guiX + (guiWidth - dialogWidth) / 2), - Math.max(0, (guiHeight - dialogHeight) / 3)); - - setVisible(true); - } - - private void readFromLookupFile() throws AAtlantisException - { - if(USER_ITEMS==null) - { - try - { - InputStream is = AUtilities.getFileAsStream(LOOKUP_FILE); - CSVParser parser = new CSVParser(is); - parser.setCommentStart("#"); - String valueArray = parser.nextValue(); // shall now contain all values - CSVParser parserArray = new CSVParser(new StringReader(valueArray)); - String[][] s = parserArray.getAllValues(); - if(s!=null) - { - USER_ITEMS = s[0]; - } - } - catch (IOException e) - { - throw new AAtlantisException("exception while reading file: " + - LOOKUP_FILE); - } - catch (AAtlantisException e) - { - throw e; - } - } - } - - - public void dispose() - { - instance = null; - super.dispose(); - } - - public void updatePane() - { - - JTabbedPane currentTabbedPane = (JTabbedPane) getContentPane().getComponent(0); - int currentIndex = currentTabbedPane.getSelectedIndex(); - getContentPane().removeAll(); - validate(); - - fillTabbedPane(currentIndex); - addButtonPane(); - - pack(); - } - - private void addButtonPane() - { - okButton = new JButton("OK"); - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) - { - dispose(); - } - }); - - // Add button to refresh data after cuts have been applied - refreshButton = new JButton("Refresh Cuts"); - refreshButton.setToolTipText("Display data passing cuts for active window"); - refreshButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) - { - updatePane(); - } - }); - - buttonsPanel = new JPanel(new AFlowLayout(10, 5)); - buttonsPanel.add(okButton); - buttonsPanel.add(refreshButton); - getContentPane().add(buttonsPanel, BorderLayout.SOUTH); - - - - } - - /** fills the tabbed pane with the event information - * @param index the currently selected index - */ - private void fillTabbedPane(int index) - { - fillTablePane(); - AEvent event = eventManager.getCurrentEvent(); - - //now need to loop over the lvl1result collections - Vector<String> keys = event.getCollections().get("LVL1Result"); - ALVL1ResultData lvl1ResultData[]=null; - if(keys!=null){ - lvl1ResultData = new ALVL1ResultData[keys.size()]; - for(int i=0; i<keys.size();i++) - { - String colLvl1= "LVL1Result" + (String)keys.elementAt(i); - lvl1ResultData[i] = (ALVL1ResultData) event.get(colLvl1); - } - } - - ATriggerInfoData triggerInfoData = event.getTriggerInfoData(); - fillPropertiesPane(lvl1ResultData, triggerInfoData); - String[][] L1_items = fillLevel1Pane(lvl1ResultData); - String[][] L2_items = fillLevel2Pane(lvl1ResultData); - String[][] EF_items = fillEventFilterPane(lvl1ResultData); - fillTrigInfoItemsPane(triggerInfoData); - fillTrigInfoStreamPane(triggerInfoData); - fillUserSelectedPane(L1_items, L2_items, EF_items); - fillmbtsPane(); - - tabbedPane = new JTabbedPane(); - tabbedPane.addTab("Number of Hits", new JScrollPane(table)); - tabbedPane.addTab("Properties", new JScrollPane(propertiesTable)); - tabbedPane.addTab("Level 1 Trigger Items", new JScrollPane(level1Table)); - tabbedPane.addTab("Level 2 Trigger Items", new JScrollPane(level2Table)); - tabbedPane.addTab("Event Filter Trigger Items", new JScrollPane(eventFilterTable)); - tabbedPane.addTab("Trigger Info Items", new JScrollPane(trigInfoItemsTable)); - tabbedPane.addTab("Trigger Info Stream Tag", new JScrollPane(trigInfoStreamTable)); - tabbedPane.addTab("User Selected Trigger Items", new JScrollPane(userSelectedTable)); - tabbedPane.addTab("All MBTS cell details", new JScrollPane(mbtsTable)); - tabbedPane.setSelectedIndex(index); - - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(tabbedPane, BorderLayout.CENTER); - } - - private void fillTablePane() - { - // For total data and data passing cuts, use .getInfoDraw() - // for total event data, use getInfo() - table = new JTable(eventManager.getCurrentEvent().getInfoDraw(), - new String[] { "detector / datatype", "data items", "passing cuts" }) { - public boolean isCellEditable(int row, int column) { return false; } - }; - table.setRowHeight(20); - table.setFont(new Font("Monospaced", Font.PLAIN, 16)); - table.getColumnModel().getColumn(0).setPreferredWidth(350); - table.getColumnModel().getColumn(1).setPreferredWidth(100); - table.getColumnModel().getColumn(2).setPreferredWidth(100); - } - - private void fillPropertiesPane(ALVL1ResultData lvl1ResultData[], ATriggerInfoData triggerInfoData) - { - double et = 0; - List<ACalorimeterData> calo = eventManager.getCurrentEvent().getCalorimeters(); - - for (int i = 0; i < calo.size(); i++) - et += calo.get(i).getTotalTransverseEnergy(); - - String[][] properties; - - if (lvl1ResultData == null) - { - if(triggerInfoData==null) - { - properties = new String[2][2]; - properties[1][0] = "Trigger Decision"; - properties[1][1] = "N/A"; - } - else - { - properties = new String[7][2]; - properties[1][0] = "Trigger Decision"; - properties[1][1] = "N/A"; - properties[2][0] = "Trigger Info: Level 1 EtMiss"; - properties[2][1] = String.valueOf(triggerInfoData.getEnergyEtMiss(0)); - properties[3][0] = "Trigger Info: Level 1 SumEt"; - properties[3][1] = String.valueOf(triggerInfoData.getEnergyEtMiss(0)); - properties[4][0] = "Trigger Info: ExtL1ID"; - properties[4][1] = triggerInfoData.getTrigInfoExtL1ID(0); - properties[5][0] = "Trigger Info: Lvl1Type"; - properties[5][1] = triggerInfoData.getTrigInfoLvl1Type(0); - properties[6][0] = "Trigger Info: Status"; - properties[6][1] = triggerInfoData.getTrigInfoStatus(0); - - } - } - else - { - properties = new String[5*lvl1ResultData.length+6][2]; - - //output the trigger info: - properties[1][0] = "Trigger Info: Level 1 EtMiss"; - properties[2][0] = "Trigger Info: Level 1 SumEt"; - properties[3][0] = "Trigger Info: ExtL1ID"; - properties[4][0] = "Trigger Info: Lvl1Type"; - properties[5][0] = "Trigger Info: Status"; - - if(triggerInfoData!=null) - { - properties[1][1] = String.valueOf(triggerInfoData.getEnergyEtMiss(0)); - properties[2][1] = String.valueOf(triggerInfoData.getEnergySumEt(0)); - properties[3][1] = triggerInfoData.getTrigInfoExtL1ID(0); - properties[4][1] = triggerInfoData.getTrigInfoLvl1Type(0); - properties[5][1] = triggerInfoData.getTrigInfoStatus(0); - }else{ - properties[1][1] = "N/A"; - properties[2][1] = "N/A"; - properties[3][1] = "N/A"; - properties[4][1] = "N/A"; - properties[5][1] = "N/A"; - } - - for(int j=0; j<lvl1ResultData.length;j++){ - int ref=j*5;//reference to allow >1 collection in the list - String name=lvl1ResultData[j].getStoreGateKey(); - - properties[6+ref][0] = name + ": Level 1 result"; - properties[7+ref][0] = name + ": Level 2 result"; - properties[8+ref][0] = name + ": Event Filter result"; - properties[9+ref][0] = name + ": Level 1 EtMiss"; - properties[10+ref][0] = name + ": Level 1 SumEt"; - - int[] temp=new int[3]; - temp[0]=lvl1ResultData[j].getPassedL1(0); - temp[1]=lvl1ResultData[j].getPassedL2(0); - temp[2]=lvl1ResultData[j].getPassedEF(0); - for(int i=0;i<3;i++) - { - switch(temp[i]) - { - case -1: - properties[i+6+ref][1]="N/C"; - break; - case 0: - properties[i+6+ref][1]="failed"; - break; - case 1: - properties[i+6+ref][1]="passed"; - break; - default: - properties[i+6+ref][1]="N/A"; - } - } - float LVL1EtMiss=lvl1ResultData[j].getEnergyEtMiss(0); - float LVL1SumEt=lvl1ResultData[j].getEnergySumEt(0); - if(LVL1EtMiss>0) - properties[9+ref][1] = String.valueOf(LVL1EtMiss); - else - properties[9+ref][1] = "N/A"; - if(LVL1SumEt>0) - properties[10+ref][1] = String.valueOf(LVL1SumEt); - else - properties[10+ref][1] = "N/A"; - } - } - - //first item always Transv. Energy - properties[0][0] = "Transv. Energy (GeV)"; - properties[0][1] = String.format("%.2f",et); - - propertiesTable = new JTable(properties, new String[] { "Name", "Value" }) { - public boolean isCellEditable(int row, int column) { return false; } - }; - propertiesTable.setRowHeight(20); - propertiesTable.setFont(new Font("Monospaced", Font.PLAIN, 16)); - propertiesTable.getColumnModel().getColumn(0).setPreferredWidth(350); - propertiesTable.getColumnModel().getColumn(1).setPreferredWidth(100); - } - - private String[][] fillLevel1Pane(ALVL1ResultData lvl1ResultData[]) - { - String[][] properties; - - if (lvl1ResultData == null) - { - properties = new String[1][2]; - properties[0][0] = "N/A"; - properties[0][1] = "N/A"; - } - else - { - String[][] items=new String[lvl1ResultData.length][]; - String[][] prescales=new String[lvl1ResultData.length][]; - int numItems=0; - for(int j=0; j<lvl1ResultData.length;j++){ - items[j]=lvl1ResultData[j].getCtpItemListSplit(0,false); - prescales[j]=lvl1ResultData[j].getPrescaleListL1Split(0); - numItems+=items[j].length; - } - properties = new String[numItems][2]; - numItems=0; - for(int j=0; j<lvl1ResultData.length;j++){ - String name=lvl1ResultData[j].getStoreGateKey(); - for(int i=0; i<items[j].length; i++) - { - properties[numItems][0]= name + ": " + items[j][i]; - properties[numItems][1]=(prescales[j] != null && i<prescales[j].length) ? prescales[j][i]: "N/A"; - numItems++; - } - } - } - level1Table = new JTable(properties, new String[] { "Item passed", "Prescale"}) { - public boolean isCellEditable(int row, int column) { return false; } - }; - level1Table.setRowHeight(20); - level1Table.setFont(new Font("Monospaced", Font.PLAIN, 16)); - level1Table.getColumnModel().getColumn(0).setPreferredWidth(350); - level1Table.getColumnModel().getColumn(1).setPreferredWidth(100); - - return properties; - } - - private String[][] fillLevel2Pane(ALVL1ResultData lvl1ResultData[]) - { - String[][] properties; - - if (lvl1ResultData == null) - { - properties = new String[1][2]; - properties[0][0] = "N/A"; - properties[0][1] = "N/A"; - } - else - { - String[][] items=new String[lvl1ResultData.length][]; - String[][] prescales=new String[lvl1ResultData.length][]; - int numItems=0; - for(int j=0; j<lvl1ResultData.length;j++){ - items[j]=lvl1ResultData[j].getitemListL2Split(0,false); - prescales[j]=lvl1ResultData[j].getPrescaleListL2Split(0); - numItems+=items[j].length; - } - properties = new String[numItems][2]; - numItems=0; - for(int j=0; j<lvl1ResultData.length;j++){ - String name=lvl1ResultData[j].getStoreGateKey(); - for(int i=0; i<items[j].length; i++) - { - properties[numItems][0]= name + ": " + items[j][i]; - properties[numItems][1]=(prescales[j] != null && i<prescales[j].length) ? prescales[j][i]: "N/A"; - numItems++; - } - } - } - level2Table = new JTable(properties, new String[] { "Item passed", "Prescale" }) { - public boolean isCellEditable(int row, int column) { return false; } - }; - level2Table.setRowHeight(20); - level2Table.setFont(new Font("Monospaced", Font.PLAIN, 16)); - level2Table.getColumnModel().getColumn(0).setPreferredWidth(350); - level2Table.getColumnModel().getColumn(1).setPreferredWidth(100); - - return properties; - } - - private String[][] fillEventFilterPane(ALVL1ResultData lvl1ResultData[]) - { - String[][] properties; - - if (lvl1ResultData == null) - { - properties = new String[1][2]; - properties[0][0] = "N/A"; - properties[0][1] = "N/A"; - } - else - { - String[][] items=new String[lvl1ResultData.length][]; - String[][] prescales=new String[lvl1ResultData.length][]; - int numItems=0; - for(int j=0; j<lvl1ResultData.length;j++){ - items[j]=lvl1ResultData[j].getitemListEFSplit(0,false); - prescales[j]=lvl1ResultData[j].getPrescaleListEFSplit(0); - numItems+=items[j].length; - } - properties = new String[numItems][2]; - numItems=0; - for(int j=0; j<lvl1ResultData.length;j++){ - String name=lvl1ResultData[j].getStoreGateKey(); - for(int i=0; i<items[j].length; i++) - { - properties[numItems][0]= name + ": " + items[j][i]; - properties[numItems][1]=(prescales[j] != null && i<prescales[j].length) ? prescales[j][i]: "N/A"; - numItems++; - } - } - } - eventFilterTable = new JTable(properties, new String[] { "Item passed", "Prescale" }) { - public boolean isCellEditable(int row, int column) { return false; } - }; - eventFilterTable.setDefaultEditor(String.class, null); - eventFilterTable.setRowHeight(20); - eventFilterTable.setFont(new Font("Monospaced", Font.PLAIN, 16)); - eventFilterTable.getColumnModel().getColumn(0).setPreferredWidth(350); - eventFilterTable.getColumnModel().getColumn(1).setPreferredWidth(100); - - return properties; - } - - private void fillTrigInfoItemsPane(ATriggerInfoData triggerInfoData) - { - String[][] properties; - - if (triggerInfoData == null) - { - properties = new String[1][3]; - properties[0][0] = "N/A"; - properties[0][1] = "N/A"; - properties[0][2] = "N/A"; - } - else - { - String[] itemsL1=triggerInfoData.getTrigInfoL1SplitHex(0); - String[] itemsL2=triggerInfoData.getTrigInfoL2SplitHex(0); - String[] itemsEF=triggerInfoData.getTrigInfoEFSplitHex(0); - //find list with largest amount of items - int items = Math.max(Math.max(itemsL1.length, itemsL2.length),itemsEF.length); - properties = new String[items][3]; - for(int i=0; i<items; i++) - { - properties[i][0]= (i<itemsL1.length) ? itemsL1[i] : ""; - properties[i][1]= (i<itemsL2.length) ? itemsL2[i] : ""; - properties[i][2]= (i<itemsEF.length) ? itemsEF[i] : ""; - } - } - trigInfoItemsTable = new JTable(properties, new String[] { "L1", "L2", "EF" }) { - public boolean isCellEditable(int row, int column) { return false; } - }; - trigInfoItemsTable.setRowHeight(20); - trigInfoItemsTable.setFont(new Font("Monospaced", Font.PLAIN, 16)); - trigInfoItemsTable.getColumnModel().getColumn(0).setPreferredWidth(100); - trigInfoItemsTable.getColumnModel().getColumn(1).setPreferredWidth(100); - trigInfoItemsTable.getColumnModel().getColumn(1).setPreferredWidth(100); - - } - - private void fillTrigInfoStreamPane(ATriggerInfoData triggerInfoData) - { - String[][] properties; - - if (triggerInfoData == null) - { - properties = new String[1][1]; - properties[0][0] = "N/A"; - } - else - { - String[] items=triggerInfoData.getTrigInfoStreamTagSplit(0); - properties = new String[items.length][1]; - for(int i=0; i<items.length; i++) - { - properties[i][0]=items[i]; - } - } - trigInfoStreamTable = new JTable(properties, new String[] { "Stream Tag"}) { - public boolean isCellEditable(int row, int column) { return false; } - }; - trigInfoStreamTable.setRowHeight(20); - trigInfoStreamTable.setFont(new Font("Monospaced", Font.PLAIN, 16)); - trigInfoStreamTable.getColumnModel().getColumn(0).setPreferredWidth(450); - } - - private void fillUserSelectedPane(String[][] L1_items, String[][] L2_items, String[][] EF_items) - { - String[][] properties; - if (USER_ITEMS==null) - { - properties = new String[1][2]; - properties[0][0] = "Please add items to: " + LOOKUP_FILENAME; - properties[0][1] = "N/A"; - } - else - { - Vector<String> v_c1 = new Vector<String>();//column 1 - item - Vector<String> v_c2 = new Vector<String>();//column 2 - prescales - Vector<String> v_u = new Vector<String>();//user items - for(int i=0; i<USER_ITEMS.length; i++) - { - v_u.add(USER_ITEMS[i]); - } - //loop over L1 items - for(int j=0; j<L1_items.length; j++) - { - for(int i=0; i<v_u.size(); i++) - { - if(v_u.elementAt(i).equals(L1_items[j][0])) - { - v_c1.add(L1_items[j][0]); - v_c2.add(L1_items[j][1]); - v_u.remove(i); - } - } - } - //if still have user items left loop over L2 - if(v_u.size()>0) - { - for(int j=0; j<L2_items.length; j++) - { - for(int i=0; i<v_u.size(); i++) - { - if(v_u.elementAt(i).equals(L2_items[j][0])) - { - v_c1.add(L2_items[j][0]); - v_c2.add(L2_items[j][1]); - v_u.remove(i); - } - } - } - } - //if still have user items left loop over EF - if(v_u.size()>0) - { - for(int j=0; j<EF_items.length; j++) - { - for(int i=0; i<v_u.size(); i++) - { - if(v_u.elementAt(i).equals(EF_items[j][0])) - { - v_c1.add(EF_items[j][0]); - v_c2.add(EF_items[j][1]); - v_u.remove(i); - } - } - } - } - //now store items in String[][] - properties = new String[v_c1.size()][2]; - for(int i=0; i<v_c1.size(); i++) - { - properties[i][0]=v_c1.elementAt(i).toString(); - properties[i][1]=v_c2.elementAt(i).toString(); - } - } - userSelectedTable = new JTable(properties, new String[] { "Item passed", "Prescale" }) { - public boolean isCellEditable(int row, int column) { return false; } - }; - userSelectedTable.setRowHeight(20); - userSelectedTable.setFont(new Font("Monospaced", Font.PLAIN, 16)); - userSelectedTable.getColumnModel().getColumn(0).setPreferredWidth(350); - userSelectedTable.getColumnModel().getColumn(1).setPreferredWidth(100); - } - - private void fillmbtsPane() - { - ACalorimeterData calorimeter=null; - List<ACalorimeterData> detectors = eventManager.getCurrentEvent().getCalorimeters(); - for (int det = 0; det < detectors.size(); det++) - { - ACalorimeterData testcalorimeter = detectors.get(det); - if (!testcalorimeter.getName().equals("MBTS")) continue; - if(testcalorimeter.getNumData()>0) calorimeter=testcalorimeter; - } - - - String[][] properties; - if (calorimeter==null) - { - properties = new String[1][5]; - properties[0][0] = "N/A"; - properties[0][1] = "N/A"; - properties[0][2] = "N/A"; - properties[0][3] = "N/A"; - properties[0][4] = "N/A"; - } - else - { - properties = new String[calorimeter.getNumData()][5]; - //AMBTSData mbtsdata = calorimeter.eta[i]; - for (int i = 0; i < calorimeter.getNumData(); ++i) - { - properties[i][0] = "" + i; - properties[i][1] = "" + String.format("%.3f",(calorimeter.getET(i))); - properties[i][2] = "" + String.format("%.1f",calorimeter.getEta(i)); - properties[i][3] = "" + String.format("%.1f",calorimeter.getPhi(i)); - properties[i][4] = "" + calorimeter.getSampling(i); - } - } - mbtsTable = new JTable(properties, new String[] { "Index", "Energy (MeV)", "Type", "Module", "Channel" }) { - public boolean isCellEditable(int row, int column) { return false; } - }; - mbtsTable.setRowHeight(20); - mbtsTable.setFont(new Font("Monospaced", Font.PLAIN, 16)); - mbtsTable.getColumnModel().getColumn(0).setPreferredWidth(90); - mbtsTable.getColumnModel().getColumn(1).setPreferredWidth(90); - mbtsTable.getColumnModel().getColumn(2).setPreferredWidth(90); - mbtsTable.getColumnModel().getColumn(3).setPreferredWidth(90); - mbtsTable.getColumnModel().getColumn(4).setPreferredWidth(90); - } - - /** - * Implementing NewEvent listener - * @param event the new event - */ - public void newEvent(AEvent event) { - if (isInUse()) updatePane(); - } - - - - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AEventQueue.java b/graphics/AtlantisJava/src/atlantis/gui/AEventQueue.java deleted file mode 100755 index 081e214dd295f4d6caab58c7c78e15292a577e9c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AEventQueue.java +++ /dev/null @@ -1,165 +0,0 @@ -package atlantis.gui; - -import java.awt.EventQueue; -import java.awt.AWTEvent; -import java.awt.Frame; -import java.awt.event.KeyEvent; -import atlantis.parameters.APar; -import atlantis.canvas.ACanvas; -import atlantis.data.AG4StepData; -import atlantis.event.AEventManager; -import atlantis.event.AEventSource.InvalidEventSourceException; -import atlantis.event.AEventSource.NoMoreEventsException; -import atlantis.event.AEventSource.ReadEventException; -import atlantis.globals.AGlobals; -import atlantis.interactions.AModifier; -import javax.swing.JOptionPane; -import atlantis.utils.ALogger; - -/** - * Because we use Mouse Actions and Keyboard Modifiers (letters) we need a way of - * getting all the keyboard events independent of the focussed compenent. This is - * done by catching them directly from the Event Queue. So, we just replace the - * default Java Queue by this one. - */ -public class AEventQueue extends EventQueue { - - /** - * Contains the code of the key (is some key is pressed) - * or KeyEvent.VK_UNDEFINED if no key is holded down. - */ - private static int keyboardState; - private static AModifier defInt = new AModifier(KeyEvent.VK_UNDEFINED, false, ""); - - private KeyEvent keyEvent; - - private final static ALogger logger = ALogger.getLogger(AEventQueue.class); - private static AEventManager eventManager = AEventManager.instance(); - - private static boolean isRightMouseButton; - - protected static APar parameterStore = APar.instance(); - - private static final AGlobals globals = AGlobals.instance(); - - public static int getKeyboardState() { - int ret = 0; - - if (keyboardState == KeyEvent.VK_UNDEFINED) { - ret = defInt.getKeyCode(); - } else { - ret = keyboardState; - } - - // Bit of a hack because fastzoom is handled differently from other - // interactions - if (ret == KeyEvent.VK_F) { - parameterStore.get("Projection", "SkipData").setStatus(true); - } else { - parameterStore.get("Projection", "SkipData").setStatus(false); - } - - return ret; - } - - public static AModifier getDefault() { - return defInt; - } - - public static void setDefault(AModifier mod) { - defInt = mod; - - } - - public static int getKeyboardDefault() { - return defInt.getKeyCode(); - } - - public static boolean getIntRightMouseButton() { - if (keyboardState == KeyEvent.VK_UNDEFINED) { - // Non-default action selected, use the right click option from it - return defInt.getRightClick() || isRightMouseButton; - } else { - return isRightMouseButton; - } - } - - // FIXME: isRightMouseButton sometimes has spurious true value: see Trac #488 - protected void dispatchEvent(AWTEvent event) { - Frame gui = globals.getGuiFrame(); - super.dispatchEvent(event); - - if(event instanceof KeyEvent) { - keyEvent=(KeyEvent)event; -// this is the right mouse click on single mouse button mac's - switch(keyEvent.getID()) { - case KeyEvent.KEY_PRESSED: - if(keyEvent.getKeyCode()==17) { - isRightMouseButton=true; - return; - } - keyboardState=keyEvent.getKeyCode(); - //atlantis.utils.AOutput.append(" key pressed :" + keyboardState + ":\n", atlantis.utils.ALogPane.NORMAL_BOLD); - - if (keyEvent.getKeyCode()==33){//page up - System.out.println("Go to previous event"); - try { - eventManager.previousEvent(); - } catch (NoMoreEventsException nme) { - String msg = "Already at first event from this source!"; - JOptionPane.showMessageDialog(gui, msg, "No more events", JOptionPane.ERROR_MESSAGE); - logger.warn(nme.getCauseMessages()); - } catch (InvalidEventSourceException ies) { - String msg = "Not a valid event source - please select one!"; - JOptionPane.showMessageDialog(gui, msg, "Invalid source", JOptionPane.ERROR_MESSAGE); - logger.warn(ies.getCauseMessages()); - } catch (ReadEventException ree) { - String msg = "Can not read event(s)!"; - JOptionPane.showMessageDialog(gui, msg, "Read error", JOptionPane.ERROR_MESSAGE); - logger.warn(ree.getCauseMessages()); - } - } - if (keyEvent.getKeyCode()==34) {//page down - System.out.println("Go to next event"); - try { - eventManager.nextEvent(); - } catch (NoMoreEventsException nme) { - String msg = "Already at last event from this source!"; - JOptionPane.showMessageDialog(gui, msg, "No more events", JOptionPane.ERROR_MESSAGE); - logger.warn(nme.getCauseMessages()); - } catch (InvalidEventSourceException ies) { - String msg = "Not a valid event source - please select one!"; - JOptionPane.showMessageDialog(gui, msg, "Invalid source", JOptionPane.ERROR_MESSAGE); - logger.warn(ies.getCauseMessages()); - } catch (ReadEventException ree) { - String msg = "Can not read event(s)!"; - JOptionPane.showMessageDialog(gui, msg, "Read error", JOptionPane.ERROR_MESSAGE); - logger.warn(ree.getCauseMessages()); - } - } - - if (keyEvent.getKeyCode()==47) {// "/" - AG4StepData.ReadG4Steps(); - }//key "/" - - if (keyEvent.getKeyCode() == KeyEvent.VK_F) { - parameterStore.get("Projection", "SkipData").setStatus(true); - } - break; - - case KeyEvent.KEY_RELEASED: - if (keyEvent.getKeyCode() == 17) { - isRightMouseButton = false; - return; - } - keyboardState = KeyEvent.VK_UNDEFINED; - if (keyEvent.getKeyCode() == KeyEvent.VK_F) { - parameterStore.get("Projection", "SkipData").setStatus(false); - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - } - break; - } - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AEventSourceToolBar.java b/graphics/AtlantisJava/src/atlantis/gui/AEventSourceToolBar.java deleted file mode 100644 index 8f5534a6dd52396dbb6be2d4926f16266500c50c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AEventSourceToolBar.java +++ /dev/null @@ -1,523 +0,0 @@ - -package atlantis.gui; - -import atlantis.config.ADefaultValues; -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.event.AEventSource; -import atlantis.event.ANewEventSourceListener; -import atlantis.event.AURLEventSource; -import atlantis.event.AEventSource.InvalidEventSourceException; -import atlantis.event.AEventSource.NavigationMode; -import atlantis.event.AEventSource.NoMoreEventsException; -import atlantis.event.AEventSource.ReadEventException; -import atlantis.event.AStreamedEventSource; -import atlantis.event.AStreamedEventSource.InvalidStreamException; -import atlantis.globals.AGlobals; -import atlantis.utils.ALogger; -import atlantis.utils.AUtilities; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Vector; -import javax.swing.Box; -import javax.swing.ButtonGroup; -import javax.swing.DefaultComboBoxModel; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JRadioButton; -import javax.swing.JTextField; -import javax.swing.JToolBar; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; - -/** - * This toolbar contains all the elements to set a new event source or stream, - * browse through the events or set the event navigation mode - * @author maillard - * @author sboeser - */ -class AEventSourceToolBar extends JToolBar implements ANewEventSourceListener { - - /** The text field that allows us to enter a new event source */ - private JTextField addressBar; - - /** The event stream selection combo box */ - private JComboBox eventStreamComboBox; - - /** The radio buttons that allow to select the event navigation mode */ - private JRadioButton randomButton, sequentialButton, loopButton; - - /** The logger */ - private final static ALogger logger = ALogger.getLogger(AEventSourceToolBar.class); - - private static AEventManager eventManager = AEventManager.instance(); - - /** Spacing between components in the toolbar */ - private static int SPACE = 4; - - /** - * Constructor - */ - public AEventSourceToolBar() { - - //call parent constructor - super(); - - setFloatable(false); - - //Get the path to the icon files - String iconPath = AGlobals.instance().getHomeDirectory()+"img"+System.getProperty("file.separator"); - - // setting up the 'open file' button - ImageIcon openIcon = AUtilities.getFileAsImageIcon(iconPath+"toolbar_open.png"); - JButton openFile = new JButton(openIcon); - openFile.setVerticalTextPosition(JButton.BOTTOM); - openFile.setHorizontalTextPosition(JButton.CENTER); - openFile.setMargin(new Insets(2, 2, 2, 2)); - openFile.setToolTipText("Open local file"); - // And add an action listener for it - openFile.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - openFileButtonAction(); - } - }); - // adding the open file button to the toolbar - - add(Box.createHorizontalStrut(SPACE)); - add(openFile); - add(Box.createHorizontalStrut(SPACE)); - - // setting up the address bar - addressBar = new JTextField(30); - // and an action listener - addressBar.addActionListener( new ActionListener() { - public void actionPerformed(ActionEvent e) { - addressBarAction((JTextField)e.getSource()); - } - }); - // adding the address bar to the toolbar - add(addressBar); - - //Set up previous and next buttons - ImageIcon nextIcon = AUtilities.getFileAsImageIcon(iconPath+"toolbar_next.png"); - ImageIcon previousIcon = AUtilities.getFileAsImageIcon(iconPath+"toolbar_previous.png"); - - JButton nextButton = new JButton(nextIcon); - JButton previousButton = new JButton(previousIcon); - - //customize and add action listener for next - nextButton.setName("nextButton"); - nextButton.setVerticalTextPosition(JButton.BOTTOM); - nextButton.setHorizontalTextPosition(JButton.CENTER); - nextButton.setMargin(new Insets(2, 2, 2, 2)); - nextButton.setToolTipText("Next event (PageDown)"); - nextButton.addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent e){ - nextButtonAction(); - } - }); - - //customize and add action listener for previous - previousButton.setName("previousButton"); - previousButton.setVerticalTextPosition(JButton.BOTTOM); - previousButton.setHorizontalTextPosition(JButton.CENTER); - previousButton.setMargin(new Insets(2, 2, 2, 2)); - previousButton.setToolTipText("Previous event (PageUp)"); - previousButton.addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent e){ - previousButtonAction(); - } - }); - //Add both to toolbar - add(Box.createHorizontalStrut(SPACE)); - add(previousButton); - add(nextButton); - add(Box.createHorizontalStrut(SPACE)); - - //Next add a seperator - addSeparator(); - - //Add a combo box, but set it to invisble - String[] streamNames = { "--n/a--" }; - eventStreamComboBox = new JComboBox(streamNames); - eventStreamComboBox.setVisible(false); - add(eventStreamComboBox); - - // set up the navigation mode button icons - ImageIcon sequentialIcon = AUtilities.getFileAsImageIcon(iconPath+"mode_sequential.png"); - ImageIcon loopIcon = AUtilities.getFileAsImageIcon(iconPath+"mode_loop.png"); - ImageIcon randomIcon = AUtilities.getFileAsImageIcon(iconPath+"mode_random.png"); - ImageIcon sequentialIconOn = AUtilities.getFileAsImageIcon(iconPath+"mode_sequential_on.png"); - ImageIcon loopIconOn = AUtilities.getFileAsImageIcon(iconPath+"mode_loop_on.png"); - ImageIcon randomIconOn = AUtilities.getFileAsImageIcon(iconPath+"mode_random_on.png"); - - //put these buttons in a group - ButtonGroup group = new ButtonGroup(); - // sequential mode - sequentialButton = new JRadioButton(sequentialIcon); - sequentialButton.setOpaque(false); - sequentialButton.setSelectedIcon(sequentialIconOn); - sequentialButton.setToolTipText("Sequential mode"); - sequentialButton.setName("Sequential mode"); - // loop mode - loopButton = new JRadioButton(loopIcon); - loopButton.setSelectedIcon(loopIconOn); - loopButton.setOpaque(false); - loopButton.setToolTipText("Loop mode"); - loopButton.setName("Loop mode"); - // random mode - randomButton = new JRadioButton(randomIcon); - randomButton.setOpaque(false); - randomButton.setSelectedIcon(randomIconOn); - randomButton.setToolTipText("Random mode"); - randomButton.setName("Random mode"); - // the mode buttons are initially disabled, since we - // don't know which event source will be loaded first - sequentialButton.setEnabled(false); - loopButton.setEnabled(false); - randomButton.setEnabled(false); - - // when one of the buttons is pressed, set the required display mode - sequentialButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - navigationModeAction(NavigationMode.SEQUENTIAL); - } - }); - - loopButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - navigationModeAction(NavigationMode.LOOP); - } - }); - - randomButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - navigationModeAction(NavigationMode.RANDOM); - } - }); - //Add all buttons to the group - group.add(sequentialButton); - group.add(loopButton); - group.add(randomButton); - - add(sequentialButton); - add(loopButton); - add(randomButton); - } - - /** - * Called whenever the event text field changed - */ - private synchronized void addressBarAction(JTextField tf){ - - //Get the new text - String sourceName = tf.getText(); - - // if sourceName is a local path but doesn't provide an [type]://, - // prepend file:// as default - if(! sourceName.contains("://")) sourceName = "file://" + sourceName; - try { - eventManager.setEventSource(sourceName); - eventManager.nextEvent(); - } catch (NoMoreEventsException nme) { - JOptionPane.showMessageDialog(this, "No more events found from this source!", "No more events", JOptionPane.ERROR_MESSAGE); - logger.warn(nme.getCauseMessages()); - } catch (InvalidEventSourceException ies) { - JOptionPane.showMessageDialog(this, "Not a valid event source: "+sourceName, "Invalid event source", JOptionPane.ERROR_MESSAGE); - logger.error(ies.getCauseMessages()); - } catch (ReadEventException ree ){ - JOptionPane.showMessageDialog(this, "Cannot read event(s).", "Read error", JOptionPane.ERROR_MESSAGE); - logger.warn(ree.getCauseMessages()); - } - } - - /** - * Called whenever the previous button is pressed - */ - private synchronized void previousButtonAction(){ - - try { - eventManager.previousEvent(); - } catch (NoMoreEventsException nme) { - String msg = "Already at first event from this source!"; - JOptionPane.showMessageDialog(this, msg, "No more events", JOptionPane.ERROR_MESSAGE); - logger.warn(nme.getCauseMessages()); - } catch (InvalidEventSourceException ies ){ - String msg = "Not a valid event source - please select one!"; - JOptionPane.showMessageDialog(this, msg, "Invalid source", JOptionPane.ERROR_MESSAGE); - logger.warn(ies.getCauseMessages()); - } catch (ReadEventException ree ){ - String msg = "Can not read event(s)!"; - JOptionPane.showMessageDialog(this, msg, "Read error", JOptionPane.ERROR_MESSAGE); - logger.warn(ree.getCauseMessages()); - } - refreshAddressBar(); - } - - /** - * Called whenever the next button is pressed - */ - private synchronized void nextButtonAction(){ - try { - eventManager.nextEvent(); - } catch (NoMoreEventsException nme) { - String msg = "Already at last event from this source!"; - JOptionPane.showMessageDialog(this, msg, "No more events", JOptionPane.ERROR_MESSAGE); - logger.warn(nme.getCauseMessages()); - } catch (InvalidEventSourceException ies ){ - String msg = "Not a valid event source - please select one!"; - JOptionPane.showMessageDialog(this, msg, "Invalid source", JOptionPane.ERROR_MESSAGE); - logger.warn(ies.getCauseMessages()); - } catch (ReadEventException ree ){ - String msg = "Can not read event(s)!"; - JOptionPane.showMessageDialog(this, msg, "Read error", JOptionPane.ERROR_MESSAGE); - logger.warn(ree.getCauseMessages()); - } - refreshAddressBar(); - } - - /** - * Update the address bar to show the current event source - */ - private synchronized void refreshAddressBar(){ - AEventSource source = eventManager.getEventSource(); - AEvent event = eventManager.getCurrentEvent(); - if (source != null && event != null) { - // if the source is a URL, we should always use '/' as the separator - // else we'll use the system file separator - if (source instanceof AURLEventSource) { - addressBar.setText(source.getSourceName() + "/" + event.getSourceName()); - } else { - addressBar.setText(source.getSourceName() + System.getProperty("file.separator") + event.getSourceName()); - } - } - } - - /** - * Open a file dialog and read the selected event or directory - */ - private synchronized void openFileButtonAction(){ - //get the last location from the default values - String lastLoc = ADefaultValues.get("LastEventFilesSourceDir"); - //Create a file chooser dialog - AReadFileChooser fileDialog = new AReadFileChooser(lastLoc); - //Check if the user pressed ok in the dialog - if ( fileDialog.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { - //Get the selected file path, prepend file:// - String fullFilePath = "file://" + fileDialog.getSelectedFile().getPath(); - - try { - //Now set this as a new event source - eventManager.setEventSource(fullFilePath); - eventManager.nextEvent(); - } catch (NoMoreEventsException nme) { - String msg = "No events found from this source!"; - JOptionPane.showMessageDialog(this, msg, "No more events", JOptionPane.ERROR_MESSAGE); - logger.warn(nme.getCauseMessages()); - } catch (InvalidEventSourceException ies ){ - String msg = "Not a valid event source"; - JOptionPane.showMessageDialog(this, msg, "Invalid source", JOptionPane.ERROR_MESSAGE); - logger.warn(ies.getCauseMessages()); - } catch (ReadEventException ree ){ - String msg = "Can not read event(s)"; - JOptionPane.showMessageDialog(this, msg, "Read error", JOptionPane.ERROR_MESSAGE); - logger.warn(ree.getCauseMessages()); - } - } // okay pressed - otherwise do nothing - } // openFileButtonAction() ---------------------------------------------------- - - /** - * Called whenever the navigation mode is changed in the GUI - */ - private synchronized void navigationModeAction( NavigationMode mode ){ - try { - eventManager.setNavigationMode(mode); } - catch (InvalidEventSourceException ies) { - JOptionPane.showMessageDialog(this, ies.getCauseMessages(), "Invalid navigation mode", JOptionPane.ERROR_MESSAGE); - } - } - - /** - * Called whenever the event stream is changed in the GUI - */ - private synchronized void selectedStreamAction(AStreamedEventSource source){ - - //Get the newly selected stream - String stream = (String) eventStreamComboBox.getSelectedItem(); - - try { - //Try to set a new stream - source.setStream(stream); - //Also get a new event - eventManager.nextEvent(); - //And update the event source field - refreshAddressBar(); - - } catch (NoMoreEventsException nme){ - //In case we already have the latest event from this stream - ignore - } catch (InvalidStreamException ise) { - //This can happen if the stream list changes inbetween - //opening the popup and selecting an item - String msg = "Cannot set stream '"+stream+"' for event source"; - JOptionPane.showMessageDialog(this, msg, "Invalid stream", JOptionPane.ERROR_MESSAGE); - logger.error(msg+"\n"+ise.getCauseMessages()); - //Also clear the stream list - eventStreamComboBox.removeAllItems(); - } catch (InvalidEventSourceException ies) { - //This can happen if the source turned invalid inbetween - //opening the popup and selecting an item - String msg = "Invalid event source when setting new stream"; - JOptionPane.showMessageDialog(this, msg, "Invalid source", JOptionPane.ERROR_MESSAGE); - logger.error(msg+"\n"+ies.getCauseMessages()); - //Also clear the stream list - eventStreamComboBox.removeAllItems(); - } catch (ReadEventException ree){ - //Do nothing special with stream list in this case - String msg = "Can not read event from new stream '"+stream+"'"; - JOptionPane.showMessageDialog(this, msg, "Invalid event", JOptionPane.ERROR_MESSAGE); - logger.error(msg+"\n"+ree.getCauseMessages()); - } - - } - - /** - * This is called whenever the event stream combo is poped up - * Use this to update the event list every time - */ - private synchronized void updateEventStreamCombo(AStreamedEventSource eventSource){ - /** - * NOTE: We are NOT using "removeAllItems" + "addItems" to update the - * combo box as this will always fire a new ActionEvent with the first - * added Item. The proper way to do is to change the data model, as the - * new data model will only fire AFTER the user selected from the open - * ComboBox. - */ - - //Create an empty list - Vector<String> streamNames = new Vector<String>(); - - try { - //Get the stream names - streamNames = eventSource.getAvailableStreams(); - } catch (InvalidEventSourceException ies) { - //If we fail to update the list show some messages - //NOTE: we can not show dialog here, as this will steal the focus - // from the combo box, so it does not pop-down later on - String msg = "Invalid event source when getting stream list"; - //JOptionPane.showMessageDialog(this, msg, "Invalid source", JOptionPane.ERROR_MESSAGE); - logger.error(msg+"\n"+ies.getCauseMessages()); - } - - //In any case update the stream list by setting a new data model - // -- even if it is empty - finally { - //Create a new data model - DefaultComboBoxModel newDataModel = new DefaultComboBoxModel(streamNames); - //Select the same stream we had before, if its still there - newDataModel.setSelectedItem(eventStreamComboBox.getSelectedItem()); - //Now install the new DataModel - eventStreamComboBox.setModel(newDataModel); - } - } - - /** - * This implementation of the ANewEventSourceListener gets called whenever - * the event source changes in AEventManager - * @param eventSource the new event source (final as being bound by combo action listener) - */ - public synchronized void newEventSource(final AEventSource eventSource) { - - //Stream selection is off by default - eventStreamComboBox.setVisible(false); - - //Check if this event source supports streams - if (eventSource instanceof AStreamedEventSource){ - - AStreamedEventSource streamedSource = (AStreamedEventSource) eventSource; - - //Update the list in the event stream combo box - updateEventStreamCombo(streamedSource); - - //Temporarily remove all the update handler - for (ActionListener al : eventStreamComboBox.getActionListeners()) - eventStreamComboBox.removeActionListener(al); - for (PopupMenuListener pml : eventStreamComboBox.getPopupMenuListeners()) - eventStreamComboBox.removePopupMenuListener(pml); - - try { - //Now right away select the stream given by the event source - eventStreamComboBox.setSelectedItem(((AStreamedEventSource) eventSource).getStream()); - } catch (InvalidEventSourceException ies) { - //If we fail to update the list show some messages - String msg = "Invalid event source when getting stream list"; - JOptionPane.showMessageDialog(this, msg, "Invalid source", JOptionPane.ERROR_MESSAGE); - logger.error(msg+"\n"+ies.getCauseMessages()); - } catch (NoMoreEventsException nme) { - //If we fail to update the list show some messages - String msg = "No streams (yet) available for this source"; - JOptionPane.showMessageDialog(this, msg, "Invalid source", JOptionPane.ERROR_MESSAGE); - logger.error(msg+"\n"+nme.getCauseMessages()); - } - - //(Re-)set the update handler - eventStreamComboBox.addActionListener( new ActionListener () { - public void actionPerformed(ActionEvent e) { - selectedStreamAction((AStreamedEventSource)eventSource); - } - }); - - //Also have the combobox update its item list every time the - //popup is selected - eventStreamComboBox.addPopupMenuListener(new PopupMenuListener(){ - //update stream list when popup appears - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - updateEventStreamCombo((AStreamedEventSource)eventSource); - } - //Do nothing in other cases - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {} - public void popupMenuCanceled(PopupMenuEvent e) {} - } - ); - - //Finally make it visible - eventStreamComboBox.setVisible(true); - } - - //And repaint to show/hide the combo box - repaint(); - - // disable all the mode buttons - sequentialButton.setEnabled(false); - loopButton.setEnabled(false); - randomButton.setEnabled(false); - - // enable the modes that are supported by the current event source - // and mark the current display mode as active - if(eventSource.supportsNavigationMode(NavigationMode.SEQUENTIAL)) { - if(eventSource.getNavigationMode() == NavigationMode.SEQUENTIAL) - sequentialButton.setSelected(true); - sequentialButton.setEnabled(true); - } - - if(eventSource.supportsNavigationMode(NavigationMode.LOOP)) { - if(eventSource.getNavigationMode() == NavigationMode.LOOP) - loopButton.setSelected(true); - loopButton.setEnabled(true); - } - - if(eventSource.supportsNavigationMode(NavigationMode.RANDOM)) { - if(eventSource.getNavigationMode() == NavigationMode.RANDOM) - randomButton.setSelected(true); - randomButton.setEnabled(true); - } - - // change the address in the address bar to the current event source - refreshAddressBar(); - - } // newEventSource() ----------------------------------------------------- -} - diff --git a/graphics/AtlantisJava/src/atlantis/gui/AFileControl.java b/graphics/AtlantisJava/src/atlantis/gui/AFileControl.java deleted file mode 100755 index 7cf12548f0ecfed6bd15980e5783473dea6e849b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AFileControl.java +++ /dev/null @@ -1,210 +0,0 @@ -package atlantis.gui; - -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenu; -import javax.swing.JOptionPane; -import javax.swing.JSeparator; - -import atlantis.config.ADefaultValues; -import atlantis.data.AG4StepData; -import atlantis.event.AEventManager; -import atlantis.event.AEventSource.InvalidEventSourceException; -import atlantis.event.AEventSource.NoMoreEventsException; -import atlantis.event.AEventSource.ReadEventException; -import atlantis.globals.AGlobals; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.APar; -import atlantis.utils.ALogger; -import javax.swing.JFileChooser; - - -/** - * The File menu in the GUI. - */ -public class AFileControl extends JMenu -{ - private static ALogger logger = ALogger.getLogger(AFileControl.class); - private static AEventManager eventManager = AEventManager.instance(); - private static final AGlobals globals = AGlobals.instance(); - - public AFileControl() - { - super("File"); - - add("Read Event Locally").addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - readEventLocally(); - - } - }); // add("Read Event Locally") - - add("Read Event From URL (live)").addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - readEventFromURL(); - } - }); // add("Read Event From URL") - - add(new JSeparator()); - - add("Loop over events").addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - AEventLoopDialog.getInstance().showDialog(); - } - }); - - add(new JSeparator()); - - add("Save Image of Canvas").addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) - { - //Create a new dialog - ASaveCanvasDialog dialog = new ASaveCanvasDialog(); - //And show it - dialog.showDialog(); - } - }); - - add(new JSeparator()); - - add("Event Properties").addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) - { - AEventPropertiesDialog.getInstance().setVisible(true); - } - }); // add("Event Properties") - - add(new JSeparator()); - - add("Read Geometry").addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) - { - new AReadGeometryChooser(); - } - }); // add("Read Geometry") - - add("Read G4Steps").addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) - { - AG4StepData.ReadG4Steps(); - } - }); // add ("Read G4Steps") - - int userLevel = APar.instance().getUserLevel(); - if(userLevel>=3) // TODO: Use name for "debug" instead of magic number - { - add("Memory information").addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - System.gc(); - long total = Runtime.getRuntime().totalMemory(); - long free = Runtime.getRuntime().freeMemory(); - long max = Runtime.getRuntime().maxMemory(); - int fac = 1024 * 1024; // Mega factor - String newLine = System.getProperty("line.separator"); - AOutput.append("\nMemory information:"+newLine, ALogInterface.NORMAL); - AOutput.append(" total: " + total + " B " + total / fac + " MB"+newLine, ALogInterface.NORMAL); - AOutput.append(" free : " + free + " B " + free / fac + " MB"+newLine, ALogInterface.NORMAL); - AOutput.append(" max : " + max + " B " + max / fac + " MB"+newLine, ALogInterface.NORMAL); - } - }); - - } // if(logger.isDebugEnabled()) - - add(new JSeparator()); - - add("Exit").addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - new AClosingConfirmationDialog(globals.getGuiFrame()).exitApp(); - } - }); - - } // AFileControl() ----------------------------------------------------- - - - /** - * Open a file dialog and read the selected event or directory - */ - private static void readEventLocally(){ - Frame gui = globals.getGuiFrame(); - //get the last location from the default values - String lastLoc = ADefaultValues.get("LastEventFilesSourceDir"); - //Create a file chooser dialog - AReadFileChooser fileDialog = new AReadFileChooser(lastLoc); - //Check if the user pressed ok in the dialog - if ( fileDialog.showOpenDialog(gui) == JFileChooser.APPROVE_OPTION) { - //Get the selected file path, prepend file:// - String fullFilePath = "file://" + fileDialog.getSelectedFile().getPath(); - - try { - //Now set this as a new event source - eventManager.setEventSource(fullFilePath); - eventManager.nextEvent(); - } catch (NoMoreEventsException nme) { - String msg = "No events found from this source!"; - JOptionPane.showMessageDialog(gui, msg, "No more events", JOptionPane.ERROR_MESSAGE); - logger.warn(nme.getCauseMessages()); - } catch (InvalidEventSourceException ies ){ - String msg = "Not a valid event source"; - JOptionPane.showMessageDialog(gui, msg, "Invalid source", JOptionPane.ERROR_MESSAGE); - logger.warn(ies.getCauseMessages()); - } catch (ReadEventException ree ){ - String msg = "Can not read event(s)"; - JOptionPane.showMessageDialog(gui, msg, "Read error", JOptionPane.ERROR_MESSAGE); - logger.warn(ree.getCauseMessages()); - } - } // okay pressed - otherwise do nothing - } - - - private static void readEventFromURL() - { - // URL may end with .zip - archive of event files, .xml - single - // XML event file (in this case Read Next, Previous works on the web - // directory starting from this single file) or URL only of a web - // directory (string input considered to end with whatever else) - - // in this case Atlantis gets the first event in the directory, - // Read Next, Previous work as expected - // this URL should always start with http:// - - Frame gui = globals.getGuiFrame(); - String urlString = JOptionPane.showInputDialog(gui, - "Enter URL:", AGlobals.instance().getLivePoint1EventsURL()); - - //Make sure this is a proper string - otherwise abort - if(urlString == null || urlString.trim().length()==0) return; - - // event manager further distinguishes the particular event - // reader whether URL ends with .zip or .xml - try { - //Now set this as a new event source - eventManager.setEventSource(urlString); - eventManager.nextEvent(); - } catch (NoMoreEventsException nme) { - String msg = "No events found from this source!"; - JOptionPane.showMessageDialog(gui, msg, "No more events", JOptionPane.ERROR_MESSAGE); - logger.warn(nme.getCauseMessages()); - } catch (InvalidEventSourceException ies ){ - String msg = "Not a valid event source"; - JOptionPane.showMessageDialog(gui, msg, "Invalid source", JOptionPane.ERROR_MESSAGE); - logger.warn(ies.getCauseMessages()); - } catch (ReadEventException ree ){ - String msg = "Can not read event(s)"; - JOptionPane.showMessageDialog(gui, msg, "Read error", JOptionPane.ERROR_MESSAGE); - logger.warn(ree.getCauseMessages()); - } - } // readEventFromURL() ------------------------------------------------- - -} // class AFileControl ===================================================== diff --git a/graphics/AtlantisJava/src/atlantis/gui/AGUI.java b/graphics/AtlantisJava/src/atlantis/gui/AGUI.java deleted file mode 100644 index a4327b379589db6f727544e09266201cd026f364..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AGUI.java +++ /dev/null @@ -1,572 +0,0 @@ -package atlantis.gui; - -import java.awt.BorderLayout; - -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.JFrame; -import javax.swing.JMenuBar; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; - -import java.net.Authenticator; -import java.util.List; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.ALayoutChangeListener; -import atlantis.canvas.AWindow; -import atlantis.event.AEventInfoPrinter; -import atlantis.event.AEventManager; -import atlantis.event.AEventSource.InvalidEventSourceException; -import atlantis.event.AEventSource.NoMoreEventsException; -import atlantis.event.AEventSource.ReadEventException; -import atlantis.globals.AGlobals; -import atlantis.graphics.AIcon; -import atlantis.graphics.dnd.ADnDLabel; -import atlantis.graphics.dnd.ADragListener; -import atlantis.list.AListManager; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.ACommandProcessor; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParameterChangeListener; -import atlantis.parameters.AParameterSuperGroup; -import atlantis.parameters.AParametersGroup; -import atlantis.projection.AProjection; -import atlantis.projection.AProjectionsManager; -import atlantis.utils.ALogger; -import atlantis.utils.AUtilities; -import javax.swing.*; - -/** - * The Atlantis Graphical User Interface - * This is a singleton class (and probably one of the few cases where this is - * justified!). By implementing the ALayoutChangeListener it adjusts its size to - * the canvas size. - */ -public class AGUI extends JFrame implements ChangeListener, -ALayoutChangeListener, -AParameterChangeListener -{ - private final static ALogger logger = ALogger.getLogger(AGUI.class); - private final static AGlobals globals = AGlobals.instance(); - public AEventManager eventManager = AEventManager.instance(); - - private static AGUI instance; - - private static APar parameterStore = APar.instance(); - - /** Limit the total width of Atlantis to this number of pixels (0 = screen width). */ - private int maxWidth = 0; - - private AItemTabbedPane[] tabbedPane; - private AParametersPage[][] pages; - private AParametersGroup[][] groups; - private ChangeListener[] tabChangeListener; - private ChangeListener outerTabChangeListener; - private JPanel panel; - private JSplitPane split; - private JTabbedPane outerTabbedPane; - private AInteractionToolBar interactionToolBar; - - /** - * Public singleton instantian-accessor - * @return the singleton instance - */ - public static AGUI getGUI() - { - //Don't create any GUI in headless mode - if (AGlobals.isAtlantisHeadless()) return null; - //Create the GUI if it does not exist - if (instance == null) { - instance = new AGUI(); - globals.setGuiFrame(instance); - } - //return the singleton instance - return instance; - } - - /** - * Private singleton constructor - */ - private AGUI() - { - //intialize parent - super("Atlantis GUI"); - - //be verbose - logger.debug("Creating GUI..."); - - // AClosingConfirmationDialog class handles closing Atlantis - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - this.addWindowListener(new AClosingConfirmationDialog(this)); - - getContentPane().setLayout(new BorderLayout()); - AIcon.setIconImage(this); - - // Creating all menu bar items - JMenuBar menuBar = constructAndGetMenuBar(); - setJMenuBar(menuBar); // set menubar to this frame - - // Create a new toolbar for the event sources - AEventSourceToolBar toolBar = new AEventSourceToolBar(); - toolBar.setName("Atlantis event source toolbar"); - //Does not go into main panel as it need BorderLayout - add(toolBar, BorderLayout.PAGE_START); - // register as an event source listener - eventManager.addNewEventSourceListener(toolBar); - - // building the panel with our own layout manager - // Why do we actually need it?? - panel = new JPanel(new AGUILayoutManager()); - - // setting the Window Control - AWindowControl windowControl = new AWindowControl(); - windowControl.setName("windowControl"); - panel.add(windowControl, AGUILayoutManager.AVAILABLExPREFERRED); - - // setting the Parameters Table - groups = parameterStore.getUIGroups(); - pages = new AParametersPage[groups.length][]; - tabbedPane = new AItemTabbedPane[groups.length]; - tabChangeListener = new TabChangeListener[groups.length]; - - for(int i = 0; i < groups.length; i++) - { - pages[i] = new AParametersPage[groups[i].length]; - tabbedPane[i] = new AItemTabbedPane(JTabbedPane.LEFT); - - for(int j = 0; j < groups[i].length; j++) - { - pages[i][j] = new AParametersPage(groups[i][j]); - String title = groups[i][j].getScreenName(); - tabbedPane[i].addTab(title, null, - pages[i][j], groups[i][j].getToolTip()); - pages[i][j].setName(title); - if(groups[i][j].getScreenName().equals("Residual") || - groups[i][j].getScreenName().equals("Physics") ) - tabbedPane[i].setEnabledAt(tabbedPane[i].getTabCount()-1, false); - } - tabbedPane[i].setSelectedIndex(-1); - tabChangeListener[i] = new TabChangeListener(); - tabbedPane[i].addChangeListener(tabChangeListener[i]); - tabbedPane[i].addMouseListener(new MouseAdapter() - { - public void mousePressed(MouseEvent e) - { - if(AUtilities.isRightMouseButton(e)) - { - JTabbedPane tabbedPane = (JTabbedPane) e.getSource(); - int tab = tabbedPane.getUI().tabForCoordinate(tabbedPane, e.getX(), e.getY()); - int parentTab = ((JTabbedPane) tabbedPane.getParent()).getSelectedIndex(); - if(tab != -1) - { - String helpName = groups[parentTab][tab]. - getGroupName(); - AHelpSystem.getInstance().showPage(helpName); - } - } - } - }); - } - // for loop - setting the outer Table - - outerTabbedPane = new AItemTabbedPane(JTabbedPane.TOP); - outerTabbedPane.setName("parameterGroups"); - List<AParameterSuperGroup> superGroups = parameterStore.getUISuperGroups(); - for(int i = 0; i < superGroups.size(); i++) { - AParameterSuperGroup superGroup = superGroups.get(i); - String title = superGroup.getName(); - String toolTip = superGroup.getToolTip(); - outerTabbedPane.addTab(title, null, tabbedPane[i], toolTip); - tabbedPane[i].setName(title); - } - outerTabChangeListener = new OuterTabChangeListener(); - outerTabbedPane.addChangeListener(outerTabChangeListener); - outerTabbedPane.addMouseListener(new MouseAdapter() - { - public void mousePressed(MouseEvent e) - { - if(AUtilities.isRightMouseButton(e)) - { - JTabbedPane tabbedPane = (JTabbedPane) e.getSource(); - int tab = tabbedPane.getUI().tabForCoordinate(tabbedPane, e.getX(), e.getY()); - if(tab != -1) - { - String helpName = tabbedPane.getTitleAt(tab); - AHelpSystem.getInstance().showPage(helpName); - } - } - } - }); - panel.add(outerTabbedPane, AGUILayoutManager.AVAILABLExAVAILABLE); - - // Set up the output (log) pane. - AMainLogPane outputDisplay = new AMainLogPane(); - // Make it available to all - AOutput.setOutput(outputDisplay); - // Display details of each new event - AEventInfoPrinter eventInfoPrinter = new AEventInfoPrinter(outputDisplay); - eventManager.addNewEventListener(eventInfoPrinter); - // Put it in the GUI - split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panel, outputDisplay); - split.setOneTouchExpandable(true); - split.setResizeWeight(0.75); //Give 25% to the log pane by default - getContentPane().add(split); - - // setting the window, projection and group listeners - ACanvas.getCanvas().addWindowChangeListener(this); - String[] wName = ACanvas.getCanvas().getKnownWindowNames(); - for(int i = 0; i < wName.length; i++) { - AWindow w = ACanvas.getCanvas().getWindow(wName[i]); - w.addProjectionChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - AWindow window = (AWindow) e.getSource(); - if(window.equals(ACanvas.getCanvas().getCurrentWindow())) { - if(interactionToolBar != null) panel.remove(interactionToolBar); - interactionToolBar = window.getInteractionToolBar(); - if(interactionToolBar == null) - window.getInteractionManager().forgetContext(); - else { - // the interactions tabpanes are added here - panel.add(interactionToolBar, AGUILayoutManager.AVAILABLExPREFERRED, 0); - interactionToolBar.connect(); - validate(); - } - } - } - }); - - w.addGroupChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - AWindow window = (AWindow) e.getSource(); - if(window.equals(ACanvas.getCanvas().getCurrentWindow())) - setSelectedTab(window.getGroupName()); - } - }); - } - - // Set Authenticator for password-protected URL access to use - // APasswordDialog. - Authenticator.setDefault(APasswordDialog.getAuthenticator(this)); - - } // AGUI() ------------------------------------------------------------- - - - - /** - * Limit the total width of Atlantis to this number of pixels. - * - * @param maxWidth the maximum allowed width in pixels (0 = screen width) - */ - public void setMaxWidth(int maxWidth) { - this.maxWidth = maxWidth; - } - - /** - * Constructs all menu bar (master) items and returns its instance - * @return JMenuBar - */ - private JMenuBar constructAndGetMenuBar() - { - JMenuBar menuBar = new JMenuBar(); - menuBar.add(new AFileControl()); // File menu bar item - menuBar.add(new APreferencesControl()); // Preferences menu bar item - menuBar.add(new AListsControl()); // List manager - - // Spacing, remaining buttons are aligned to the right - menuBar.add(Box.createHorizontalGlue()); - - // Reset button - AMenuButton defaults = new AMenuButton("Reset"); - defaults.setToolTipText("Reload default settings"); - defaults.setBorder(null); - defaults.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - restoreDefaults(); - } - }); - menuBar.add(defaults); - - // Demo button - AMenuButton demoButton = new AMenuButton("Demo"); - demoButton.setToolTipText("Start Demo mode"); - demoButton.setBorder(null); - demoButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - ADemoDialog.getInstance().setVisible(true); - } - }); - menuBar.add(demoButton); - - // Help menu item - menuBar.add(new AHelpControl()); - - return menuBar; - - } // constructAndGetMenuBar() ------------------------------------------- - - - - /** - * This gets called when the current layout changes in ACanvas - */ - public void layoutChanged(ACanvas canvas) { - - // adapt the width of the GUI - Rectangle screenSize = canvas.getScreenSize(); - - int useWidth = screenSize.width; - if (maxWidth > 0 && useWidth > maxWidth) { - useWidth = maxWidth; - } - - Rectangle canvbound = canvas.getStartupCanvasSize(); - int guiHeight = canvbound.height; - if (canvas.getCurrentLayout().getName().equals("FULL SCREEN")) { - int guiWidth = useWidth / 4; - setBounds(useWidth * 3 / 4, 0, guiWidth, guiHeight); - // minimise the gui in fullscreen mode - int state = getExtendedState(); - state |= JFrame.ICONIFIED; - setExtendedState(state); - } else { - int guiWidth = useWidth - canvbound.width - canvbound.x; - setBounds(canvbound.x + canvbound.width, canvbound.y, guiWidth, guiHeight); - } - } // layoutChanged() ----------------------------------------------------- - - /** - * This gets called when the current window changes in ACanvas - * @param e The ChangeEvent from the Window - */ - public void stateChanged(ChangeEvent e) - { - setSelectedTab(ACanvas.getCanvas().getCurrentWindow().getGroupName()); - if(interactionToolBar != null) panel.remove(interactionToolBar); - interactionToolBar = ACanvas.getCanvas().getCurrentWindow().getInteractionToolBar(); - // if there is an InteractionToolBar for this window (and projection) - // add it to the GUI. - if(interactionToolBar != null) - { - interactionToolBar.setName("Atlantis interaction toolbar"); - panel.add(interactionToolBar, AGUILayoutManager.AVAILABLExPREFERRED, 0); - interactionToolBar.connect(); - } - validate(); - } // stateChanged() ----------------------------------------------------- - - - - private void setSelectedTab(String newTabName) - { - for(int i = 0; i < groups.length; i++) - for(int j = 0; j < groups[i].length; j++) - if(groups[i][j].getGroupName().equals(newTabName)) - { - for(int k = 0; k < groups.length; k++) - if(k != i) - { - if(tabbedPane[k].getSelectedIndex() != -1) - { - tabbedPane[k].removeChangeListener(tabChangeListener[k]); - tabbedPane[k].setSelectedIndex( -1); - tabbedPane[k].addChangeListener(tabChangeListener[k]); - } - } - tabbedPane[i].removeChangeListener(tabChangeListener[i]); - tabbedPane[i].setSelectedIndex(j); - tabbedPane[i].addChangeListener(tabChangeListener[i]); - outerTabbedPane.setSelectedIndex(i); - if(pages[i][j].pTable != null) - pages[i][j].pTable.refresh(); - break; - } - } // setSelectedTab() --------------------------------------------------- - - - - public String getCurrentGroup() - { - return ACanvas.getCanvas().getCurrentWindow().getGroupName(); - } // getCurrentGroup() -------------------------------------------------- - - - - public void refresh() - { - if(groups != null) - { - for(int i = 0; i < groups.length; i++) - for(int j = 0; j < groups[i].length; j++) - if(pages[i][j].pTable != null) - pages[i][j].pTable.refresh(); - } - } // refresh() ---------------------------------------------------------- - - - public void repaintTable() - { - if(tabbedPane != null) - for(int i = 0; i < tabbedPane.length; i++) - if(tabbedPane[i] != null) - tabbedPane[i].repaint(); - } // repaintTable() ----------------------------------------------------- - - - - /** - * Restore all the default configuration - */ - public void restoreDefaults() - { - //restore default parameters - parameterStore.restoreDefaults(); - //reset primary vertex in current event if there is one - if (eventManager.getCurrentEvent() != null) { - eventManager.getCurrentEvent().setPrimaryVertex(); - } - //reset all list - AListManager.getInstance().reset(); - //Finally refresh GUI and canvas - this.refresh(); - ACanvas.getCanvas().restoreDefaults(); - - } // restoreDefaults() -------------------------------------------------- - - - - class TabChangeListener implements ChangeListener - { - public void stateChanged(ChangeEvent e) - { - JTabbedPane tabbedPane = (JTabbedPane) e.getSource(); - int index = tabbedPane.getSelectedIndex(); - if(index > -1) - { - int parentIndex = ((JTabbedPane) tabbedPane.getParent()). - getSelectedIndex(); - String name = groups[parentIndex][index].getGroupName(); - ACommandProcessor.receive(name + "."); - pages[parentIndex][index].repaint(); - pages[parentIndex][index].pTable.refresh(); - if(groups[parentIndex][index].getUIUsage() == - AParametersGroup.PROJECTION) - { - AProjection p = AProjectionsManager.getProjection(name); - ACanvas.getCanvas().getCurrentWindow().setProjection(p); - } - } - - } // stateChanged() ------------------------------------------------- - - } // class TabChangeListener ============================================ - - - - class OuterTabChangeListener implements ChangeListener - { - public void stateChanged(ChangeEvent e) - { - JTabbedPane tabbedPane = (JTabbedPane) e.getSource(); - int parentIndex = tabbedPane.getSelectedIndex(); - if(parentIndex > -1) - { - JTabbedPane child = (JTabbedPane) tabbedPane.getSelectedComponent(); - if(child.getTabCount() == 0) - { - child.setSelectedIndex( -1); - } - else - { - int index = 0; - String name = groups[parentIndex][index].getGroupName(); - // for projections don't change the current one - if(groups[parentIndex][index].getUIUsage() == - AParametersGroup.PROJECTION) - { - name = ACanvas.getCanvas().getCurrentWindow().getProjection(). - getName(); - for(int i = 0; i < groups[parentIndex].length; ++i) - { - if(groups[parentIndex][i].getGroupName().equals(name)) - index = i; - } - } - ACommandProcessor.receive(name + "."); - pages[parentIndex][index].repaint(); - pages[parentIndex][index].pTable.refresh(); - if(groups[parentIndex][index].getUIUsage() == - AParametersGroup.PROJECTION) - { - AProjection p = AProjectionsManager.getProjection(name); - ACanvas.getCanvas().getCurrentWindow().setProjection(p); - } - } - } - - } // stateChanged() ------------------------------------------------- - - } // class OuterTabChangeListener ======================================= - - - - static class TabDragListener implements ADragListener - { - public void dragPerformed(Object from, Object to, int action) - { - String wName; - if(to instanceof ADnDLabel) - wName = ((ADnDLabel) to).getText(); - else if(to instanceof AWindow) - wName = ((AWindow) to).getName(); - else - wName = "???"; - JTabbedPane tp = (JTabbedPane) from; - String tabName = tp.getTitleAt(tp.getSelectedIndex()); - AOutput.append("Drag of " + tabName + " into window " + wName + "\n", - ALogInterface.COMMAND); - parameterStore.copyCurrentGroupLocalsTo(wName); - ACanvas.getCanvas().getWindow(wName).repaintFromScratch(); - - } // dragPerformed() ------------------------------------------------ - - } // class TabDragListener ============================================== - - @Override - public void parameterChanged(AParameter parameter) { - this.repaintTable(); - - if(parameter.getName().equals("Mode")){ - int calomode = parameterStore.get("LegoPlot", "Mode").getI(); - - //set different nphicells and netacells combinations depending on the <calo view> selection as it is used in the L1Calo configuration file - if (calomode== 0){ - parameterStore.get("LegoPlot", "nphicells").setI(128); - parameterStore.get("LegoPlot", "netacells").setI(200); - } - else if (calomode== 1){ - parameterStore.get("LegoPlot", "nphicells").setI(64); - parameterStore.get("LegoPlot", "netacells").setI(100); - } - else if (calomode== 2){ - parameterStore.get("LegoPlot", "nphicells").setI(32); - parameterStore.get("LegoPlot", "netacells").setI(50); - } - } - } - -} // class AGUI ============================================================= diff --git a/graphics/AtlantisJava/src/atlantis/gui/AGUILayoutManager.java b/graphics/AtlantisJava/src/atlantis/gui/AGUILayoutManager.java deleted file mode 100755 index f7959d5155e9e39e00c55e694f7e6b597bce1e9d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AGUILayoutManager.java +++ /dev/null @@ -1,131 +0,0 @@ -package atlantis.gui; - -import java.awt.Container; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.LayoutManager2; -import javax.swing.JComponent; -import javax.swing.JToolBar; - -/** - * The layout manager used by the GUI. It arranges the componets in a column. - * The width is set to that of the window. - * The height is set to the preffered height of the component. - * One of the components will take all the remaining space. - */ -public class AGUILayoutManager implements LayoutManager2 { - - private final static int PxP=0; - private final static int AxP=1; - private final static int AxA=2; - - public final static Integer PREFERREDxPREFERRED=new Integer(PxP); - public final static Integer AVAILABLExPREFERRED=new Integer(AxP); - public final static Integer AVAILABLExAVAILABLE=new Integer(AxA); - - private final static String AGUI_LAYOUT_CONSTRAINT="AGUILayoutManager.StringConstraint"; - - /** - * Get the constraints registered for given component. - */ - public Integer getConstraints(Component comp) { - JComponent jc=(JComponent)comp; - - Integer constraint=(Integer)jc.getClientProperty(AGUI_LAYOUT_CONSTRAINT); - - return constraint; - } - - public void addLayoutComponent(Component comp, Object constraint) { - if(!(comp instanceof JComponent)) - throw new Error("AGUILayoutManager: not a JComponent"); - - if(!(constraint instanceof Integer)) - throw new Error("AGUILayoutManager: not a Integer"); - - JComponent jc=(JComponent)comp; - - jc.putClientProperty(AGUI_LAYOUT_CONSTRAINT, constraint); - } - - public void layoutContainer(Container parent) { - int W=parent.getSize().width; - int H=parent.getSize().height; - - Component[] comp=parent.getComponents(); - int[] constraint=new int[comp.length]; - - int AxA_Index=comp.length; - - for(int i=0; i<comp.length; i++) { - constraint[i]=getConstraints(comp[i]).intValue(); - if(constraint[i]==AxA) AxA_Index=i; - } - - int hi=0; - - for(int i=0; i<AxA_Index; i++) { - comp[i].setSize(W, 0); - Dimension cSize=comp[i].getPreferredSize(); - - switch(constraint[i]) { - case PxP: - comp[i].setBounds((W-cSize.width)/2, hi, cSize.width, cSize.height); - break; - - case AxP: - comp[i].setBounds(0, hi, W, cSize.height); - break; - } - hi+=cSize.height; - } - - int hi2=H; - - for(int i=comp.length-1; i>AxA_Index; i--) { - comp[i].setSize(W, 0); - Dimension cSize=comp[i].getPreferredSize(); - - hi2-=cSize.height; - switch(constraint[i]) { - case PxP: - comp[i].setBounds((W-cSize.width)/2, hi2, cSize.width, cSize.height); - break; - - case AxP: - comp[i].setBounds(0, hi2, W, cSize.height); - break; - } - } - - if(AxA_Index!=comp.length) - comp[AxA_Index].setBounds(0, hi, W, hi2-hi); - } - - public Dimension minimumLayoutSize(Container parent) { - return new Dimension(0, 0); - } - - public Dimension preferredLayoutSize(Container parent) { - return new Dimension(0, 0); - } - - public float getLayoutAlignmentX(Container target) { - return 0.5f; - } - - public float getLayoutAlignmentY(Container target) { - return 0.5f; - } - - public Dimension maximumLayoutSize(Container target) { - return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); - } - - public void addLayoutComponent(String name, Component comp) {} - - public void removeLayoutComponent(Component comp) {} - - public void invalidateLayout(Container target) {} - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AGUIUtilities.java b/graphics/AtlantisJava/src/atlantis/gui/AGUIUtilities.java deleted file mode 100644 index e699def52ebc27a83a33a17af428c1ff48dd2865..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AGUIUtilities.java +++ /dev/null @@ -1,167 +0,0 @@ -package atlantis.gui; - -import java.awt.Component; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.filechooser.FileFilter; - -import atlantis.globals.AGlobals; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AUtilities; - -/** - * Utility methods related to the GUI. Moved from utils.Utilities. - * - * @author waugh - */ -public class AGUIUtilities { - - private static final AGlobals globals = AGlobals.instance(); - - /** - * Save file dialog. Show the dialog with prepared name of the file in - * the directory. Returns the selected directory. - * - * @param component JDialog - * @param directory String - * @param fileName String - * @param data byte[] - * @param title String - * @param ext extension for file filter - * return selectedDirectory String - */ - public static String chooseFileAndWrite(Component component, String directory, - String fileName, byte[] data, String title, String ext) - throws AAtlantisException - { - String selectedDirectory = directory; - - if(directory == null) - { - directory = AGlobals.instance().getHomeDirectory(); - } - - JFileChooser chooser = new JFileChooser(directory); - chooser.setDialogTitle(title); - chooser.setSelectedFile(new File(fileName)); - SaveDialogFileFilter filter = new SaveDialogFileFilter(ext); - chooser.setFileFilter(filter); - - int returnVal = chooser.showSaveDialog(component); - - if(returnVal == JFileChooser.APPROVE_OPTION) - { - String absPath = chooser.getSelectedFile().getAbsolutePath(); - File f = new File(absPath); - if(f.exists()) - { - try - { - renameFile(absPath, title); - } - catch(Exception ex) - { - throw new AAtlantisException(ex.getMessage()); - } - } - // the selected file either existed and is now successfully - // renamed, or didn't exist so can proceed to store data - try - { - OutputStream s = - new BufferedOutputStream(new FileOutputStream(absPath)); - s.write(data); - s.close(); - selectedDirectory = chooser.getSelectedFile().getParent(); - } - catch(FileNotFoundException ex) - { - String msg = "Couldn't create the file.\nInsufficient permissions."; - throw new AAtlantisException(msg); - } - catch(IOException ex) - { - String msg = "IO Error when writing the\ndata into the file."; - throw new AAtlantisException(msg); - } - } - return selectedDirectory; - - } // chooseFileAndWrite() ----------------------------------------------- - - - /** - * renames file (backup when saving configuration, canvas plot, etc) - * to 'name' + backup suffix - */ - private static void renameFile(String name, String title) throws Exception - { - String backupSuffix = "-backup_on_" + AUtilities.getDateTimeString(); - String dstName = name + backupSuffix; - String errorMsg = "Renaming\n" + name + "\nto\n" + dstName + "\nfailed."; - String msg = name + "\nexists and was successfully renamed to\n" + dstName; - - try - { - AUtilities.logger.debug("Renaming file " + name + " to " + dstName + " ..."); - File f = new File(name); - if(! f.renameTo(new File(dstName))) - { - AUtilities.logger.error(errorMsg); - throw new Exception(errorMsg); - } - AUtilities.logger.debug(msg); - JOptionPane.showMessageDialog(globals.getGuiFrame(), msg, title, - JOptionPane.INFORMATION_MESSAGE); - } - catch(Exception ex) - { - AUtilities.logger.debug(ex.getMessage(), ex); - throw new Exception(errorMsg); - } - - } // renameFile() ------------------------------------------------------- - - - private static class SaveDialogFileFilter extends FileFilter - { - private String extension = null; - - public SaveDialogFileFilter(String acceptedExtension) - { - extension = acceptedExtension; - } - - // accept all directories and all files of "extension" - public boolean accept(File f) - { - if (f.isDirectory()) - { - return true; - } - - String s = f.getName(); - - if(s.toLowerCase().endsWith(extension)) - { - return true; - } - - return false; - } - - public String getDescription() - { - return extension; - } - - } // SaveDialogFileFilter =================================================== - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AHelpControl.java b/graphics/AtlantisJava/src/atlantis/gui/AHelpControl.java deleted file mode 100755 index 787c56609d767f1c3a32c446842806e751aac24c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AHelpControl.java +++ /dev/null @@ -1,45 +0,0 @@ -package atlantis.gui; - -import javax.swing.JMenu; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -/** - * The Help menu in the GUI. - */ -public class AHelpControl extends JMenu -{ - public AHelpControl() - { - super("Help"); - add("Online Help System").addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - AHelpSystem.getInstance().showPage("HelpHowTo"); - } - }); - add("Modifier Keys").addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - AMouseHelpDialog.getInstance().setVisible(true); - } - }); - add("Current color and collection summary").addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - AColorHelpDialog.getInstance().setVisible(true); - } - }); - add("About...").addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - AAboutDialog.getInstance().setVisible(true); - } - }); - - } // AHelpControl() ----------------------------------------------------- -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AHelpSystem.java b/graphics/AtlantisJava/src/atlantis/gui/AHelpSystem.java deleted file mode 100755 index 43ee7551bd73e4491c591fba0e498f78167ad5e9..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AHelpSystem.java +++ /dev/null @@ -1,118 +0,0 @@ -package atlantis.gui; - -import atlantis.graphics.AIcon; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.utils.ALogger; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Toolkit; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.net.URL; - -import javax.help.BadIDException; -import javax.help.HelpSet; -import javax.help.JHelp; -import javax.swing.JFrame; - - - -public class AHelpSystem extends JFrame -{ - private static ALogger logger = ALogger.getLogger(AHelpSystem.class); - - private static AHelpSystem instance = null; - private static String hsPath = "jhelpset.hs"; - private static JHelp helpViewer = null; - - - static - { - HelpSet hs = getHelpSet(hsPath); - // HelpBroker hb = hs.createHelpBroker(); - helpViewer = new JHelp(hs); - helpViewer.setCurrentID("HelpHowTo"); - } - - - private AHelpSystem() - { - super("Atlantis Online Help"); - addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent e) - { - dispose(); - instance = null; - } - }); - this.getContentPane().add(helpViewer); - this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - AIcon.setIconImage(this); - this.setSize(900, 600); - - } // AHelpSystem() ------------------------------------------------------ - - - - public static AHelpSystem getInstance() - { - if(instance == null) - { - instance = new AHelpSystem(); - } - return instance; - - } // getInstance() ------------------------------------------------------ - - - - public void showPage(String pageName) - { - try - { - helpViewer.setCurrentID(pageName); - // clear the iconified bit (no matter whether or not it is - // current iconified) - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((int)(Math.max(0, (screenSize.getWidth()-this.getWidth())/2)), (int)((screenSize.getHeight()-this.getHeight())/3)); - this.setExtendedState(this.getExtendedState() & ~Frame.ICONIFIED); - this.setVisible(true); - } - catch(BadIDException ex) - { - AOutput.alwaysAppend("\nNo help for \"" + pageName + "\", sorry.\n", - ALogInterface.BAD_COMMAND); - } - - } // showPage() --------------------------------------------------------- - - - - private static HelpSet getHelpSet(String helpSetFile) - { - HelpSet hs = null; - // ClassLoader cl = this.getClass().getClassLoader(); // if not static - ClassLoader cl = AHelpSystem.class.getClassLoader(); - try - { - // helpSetFile must contain just the name of HelpSet file (.hs), - // .jar file containing the whole help must be in the classpath - // then the file is successfully found. returns null if helpSetFile - // contains the whole absolute / relative path - URL hsURL = HelpSet.findHelpSet(cl, helpSetFile); - // hs = new HelpSet(null, hsURL); - hs = new HelpSet(cl, hsURL); - } - catch(Exception ee) - { - logger.error("AHelpSystem: " + ee.getMessage(), ee); - logger.error("AHelpSystem: " + helpSetFile + " not found"); - } - return hs; - - } // getHelpSet() ------------------------------------------------------- - - -} // class AHelpSystem ====================================================== diff --git a/graphics/AtlantisJava/src/atlantis/gui/AInteractionToolBar.java b/graphics/AtlantisJava/src/atlantis/gui/AInteractionToolBar.java deleted file mode 100755 index ff7e0e6523445c4e6b4bdd6827fb66bb0b856a17..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AInteractionToolBar.java +++ /dev/null @@ -1,429 +0,0 @@ -package atlantis.gui; - -import java.awt.FlowLayout; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import java.lang.reflect.Constructor; -import java.util.Hashtable; -import java.util.Vector; - -import javax.swing.ButtonGroup; -import javax.swing.ImageIcon; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JToggleButton; -import javax.swing.JToolBar; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.globals.AGlobals; -import atlantis.graphics.layout.AFlowLayout; -import atlantis.interactions.AInteractionGroup; -import atlantis.interactions.AInteractionsConfigReader; -import atlantis.interactions.AInteractionsManager; -import atlantis.output.AExceptionHandler; -import atlantis.projection.AProjectionsManager; -import atlantis.utils.AUtilities; -import javax.swing.*; - -/** - * The ToolBar that appears in the GUI and shows the set of interactions for a - * window. - * @author maillard - */ - -public class AInteractionToolBar extends JToolBar { - // the interactionsmanager this toolbar talks to - private AInteractionsManager iManager; - - // currently selected group - private AInteractionGroup currentGroup; - - /* previously selected group, needed for the history feature: - * when we select a global interaction (eg SyncCursors), then all windows will use it. - * If then we deselect it, all the windows will go back to their previous interactions */ - private AInteractionGroup previousGroup; - - // a panel that displays the additional controls needed by some interaction groups - private JPanel controls; - - // base path for all radio button icons - private final static String iconBasePath = - AGlobals.instance().getHomeDirectory()+"img"+System.getProperty("file.separator")+"interaction_"; - - // button group for all radio buttons - private ButtonGroup buttonGroup; - - // vector containing all interactionsgroups belonging to this toolbar - Vector<AInteractionGroup> groups; - - // make the pool for holding the Interactions Control and the projections Menus - private static Hashtable<String, Hashtable<String, AInteractionToolBar>> interactionControlsPool = - new Hashtable<String, Hashtable<String, AInteractionToolBar>>(20); - - public static Hashtable<String, Hashtable<String, JPopupMenu>> interactionMenusPool = - new Hashtable<String, Hashtable<String, JPopupMenu>>(20); - - /** - * Creates an InteractionToolBar to work with a particular - * InteractionsManager. - * - * @param iManager The InteractionsManager. - */ - public AInteractionToolBar(AInteractionsManager iManager) { - // call parent constructor - super(); - this.setLayout(new AFlowLayout(5, 5)); - - //make the toolbar non-detachable (can not be detachable - //as long as it does not sit inside an BorderLayout) - this.setFloatable(false); - this.setOpaque(false); - - this.iManager = iManager; - - groups = new Vector<AInteractionGroup>(); - controls = new JPanel(); - buttonGroup = new ButtonGroup(); - } - - /** - * Returns the InteractionsManager associated with this InteractionToolBar. - * - * @return The InteractionsManager - */ - public AInteractionsManager getInteractionsManager() { - return iManager; - } - - /** - * Called each time by the InteractionsManager when the ToolBar is connected - * to it. Should be used to perform some initializations. - */ - public void connect() { - iManager.setContext(getSelectedGroup()); - if (getSelectedGroup() != null) - AMouseHelpDialog.getInstance().processInteractionChange(getSelectedGroup().getInteractions()); - } - - /** - * Adds the group to the InteractionToolBar. The group can - * register some interactions. - * @param group the group to be added. - */ - public void addGroup(AInteractionGroup group, String toolTipText) { - groups.addElement(group); - final String groupName = group.getGroupName(); - - // set up a button for the interaction group - String iconPath = iconBasePath + groupName.toLowerCase() + ".png"; - - ImageIcon newIcon = AUtilities.getFileAsImageIcon(iconPath); - JToggleButton newButton = new JToggleButton(newIcon); - newButton.setName(group.getGroupName()); - newButton.setToolTipText(toolTipText); - - // add the action listener - newButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - buttonClicked(groupName); - } - }); - - // add the mouse listener for the help system - newButton.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - // if the user right clicks on a button - if (AUtilities.isRightMouseButton(e)) { - JToggleButton butt = (JToggleButton) e.getSource(); - // find the corresponding interactions group - if(findGroup(butt.getName()) != null) { - String className = findGroup(butt.getName()).getClass().getName(); - String temp = className.substring(className.lastIndexOf('.') + ".A".length()); - className = temp.substring(0, temp.length() - "Group".length()); - // show the help page for the group - AHelpSystem.getInstance().showPage(className); - } - } - } - }); - - // remove the controls panel so that the new button will - // not appear after it - this.remove(controls); - - // add the button to the ButtonGroup and to the ToolBar - buttonGroup.add(newButton); - this.add(newButton); - - // now we can put the controls panel back - this.add(controls,-1); - - // repaint the toolbar - this.validate(); - this.repaint(); - } - - /** - * Returns an array containing all the groups registered in this ToolBar. - * @return the groups - */ - public AInteractionGroup[] getGroups() { - return (AInteractionGroup[]) groups.toArray(new AInteractionGroup[0]); - } - - /** - * Returns the current interactionsgroup. - * @return the selected group. - */ - public AInteractionGroup getSelectedGroup() { - return currentGroup; - } - - /** - * Returns the name of the current interactionsgroup. - * - * @return the selected group name. - */ - public String getSelectedGroupName() { - return currentGroup.getGroupName(); - } - - /** - * Sets the interactionsgroup given its name, by - * performing a click on it. - * @param groupName the name of the group. - */ - public void setSelectedGroup(String groupName) { - // loop through the interaction groups - for(AInteractionGroup iG : groups) { - // find the one with the corresponding name - if(iG.getGroupName().equals(groupName)) { - // click the corresponding button - for(int i = 0; i < groups.size(); i++) { - if(this.getComponentAtIndex(i) instanceof JToggleButton - && this.getComponentAtIndex(i).getName().equals(groupName)) { - ((JToggleButton) this.getComponentAtIndex(i)).doClick(); - return; - } - } - } - } - } - - /** - * Returns a group based on its name - * @return the interactionsgroup (if found) or null - */ - public AInteractionGroup findGroup(String screenName) { - for(AInteractionGroup iG : groups) { - if(iG.getGroupName().equals(screenName)) return iG; - } - return null; - } - - /** - * Activate the default interactionsgroup (the first one) - */ - public void setDefaultGroup() { - // if there are any interaction groups - if (groups.size() > 0) { - // select the first one - setSelectedGroup(groups.elementAt(0).getGroupName()); - } - } - - /** - * Restore the previously selected group, if there was one. - */ - public void restorePreviousGroup() { - if (previousGroup != null) - this.setSelectedGroup(previousGroup.getGroupName()); - } - - /** - * This gets called when one of the buttons in the toolbar - * is clicked. It notifies the InteractionManager. - * @param groupName the name of the InteractionGroup to be activated - */ - public void buttonClicked(String groupName) { - AInteractionGroup deselectedGroup = currentGroup; - // loop through the groups - for(AInteractionGroup iG : groups) { - // find the one with the corresponding name - if(iG.getGroupName().equals(groupName)) { - // notify the interactionsmanager of the change - iManager.setContext(iG); - - // remove the old additional controls panel, add the new one - this.remove(controls); - if(iG.hasAdditionalControls()) controls = iG.getAdditionalControls(); - else controls = new JPanel(); - this.add(controls,-1); - if (this.getParent() != null) { - this.getParent().validate(); - } - - // take care of the history (previousGroup remembers the last non-global group) - AMouseHelpDialog.getInstance().processInteractionChange(iG.getInteractions()); - if (currentGroup != null && currentGroup.isWindowGroup()) { - previousGroup = currentGroup; - } - currentGroup = iG; - - if(ACanvas.getCanvas().getCurrentWindow() != null) - // if the interactionsgroup is global, update the other windows - if ((iG.isCanvasGroup()) && iManager.getWindow().isCurrent()) { - String[] wName = ACanvas.getCanvas().getCurrentLayout().getWindowNames(); - for (int i = 0; i < wName.length; i++) - if (!wName[i].equals(iManager.getWindow().getName())) { - ACanvas.getCanvas().getWindow(wName[i]) - .getInteractionToolBar().setSelectedGroup(iG.getGroupName()); - } - } - // if a global interactionsgroup was deselected, restore the - // previous groups in all the other windows - if(deselectedGroup != null && deselectedGroup.isCanvasGroup() - && iManager.getWindow().isCurrent()) { - String[] wName = ACanvas.getCanvas().getCurrentLayout().getWindowNames(); - for (int i = 0; i < wName.length; i++) - if (!wName[i].equals(iManager.getWindow().getName())) - ACanvas.getCanvas().getWindow(wName[i]) - .getInteractionToolBar().restorePreviousGroup(); - } - } - } - } - - /** - * Used to get the InteractionControl object for a specific window and projection. - * @param wName The name of the window - * @param pName The name of the projection - * @return The AInteractionToolBar for that window and projection - */ - public static AInteractionToolBar getInteractionToolBar(String wName, String pName) { - if(!ACanvas.getCanvas().isValidWindowName(wName)) - throw new Error("Invalid window name"); - - if(!AProjectionsManager.isValidProjection(pName)) - throw new Error("Invalid projection name"); - - Hashtable<String, AInteractionToolBar> list = interactionControlsPool.get(wName); - - if(list==null) { - list=new Hashtable<String, AInteractionToolBar>(10); - interactionControlsPool.put(wName, list); - } - - AInteractionToolBar control=list.get(pName); - - if(control==null) { - control=makeInteractionToolBar(ACanvas.getCanvas().getWindow(wName), - AInteractionsConfigReader.getNode(pName)); - // if there really existed an InteractionControl register it. - if(control!=null) - list.put(pName, control); - } - - return control; - } - - /** - * Returns the Interaction's PopupMenu. - * @param window - * @return the new popup menu object - */ - public static JPopupMenu getInteractionMenu(AWindow window) { - String wName=window.getName(); - String pName=window.getProjection().getName(); - - if(!ACanvas.getCanvas().isValidWindowName(wName)) - throw new Error("Invalid window name"); - - if(!AProjectionsManager.isValidProjection(pName)) - throw new Error("Invalid projection name"); - - Hashtable<String, JPopupMenu> list=interactionMenusPool.get(wName); - - if(list==null) { - list=new Hashtable<String, JPopupMenu>(10); - interactionMenusPool.put(wName, list); - } - - JPopupMenu menu=list.get(pName); - - if(menu==null) { - menu=makePopupMenu(getInteractionToolBar(wName, pName)); - list.put(pName, menu); - } - - return menu; - } - - /** Creates the AInteractionToolBar and returns a pointer to it - * - * @param window - * @param node - * @return the interaction tool bar - */ - public static AInteractionToolBar makeInteractionToolBar(AWindow window, Node node) { - // check whether we really got a Node with information. If not return null; - if(node==null) return null; - - AInteractionToolBar root=new AInteractionToolBar(window.getInteractionManager()); - - NodeList childs=node.getChildNodes(); - - for(int i=0; i<childs.getLength(); i++) { - Node child=childs.item(i); - - if(child.getNodeType()==Node.ELEMENT_NODE) { - String fileName=child.getAttributes().getNamedItem("fileName").getNodeValue(); - String screenName=child.getAttributes().getNamedItem("screenName").getNodeValue(); - String toolTip=child.getAttributes().getNamedItem("toolTip").getNodeValue(); - - if(child.getNodeName().equals("Panel")) - root.addGroup(makeInteractionGroup(window, fileName, screenName), toolTip); - } - } - - //Also select the default interaction group - root.setDefaultGroup(); - - return root; - } - - private static AInteractionGroup makeInteractionGroup( - AWindow window, String fileName, String screenName) { - Object group=null; - - try { - Constructor[] c=Class.forName("atlantis.interactions.A"+fileName+"Group").getDeclaredConstructors(); - - group=c[0].newInstance(new Object[] {window.getInteractionManager()}); - } catch(Exception e) { - e.printStackTrace(); - AExceptionHandler.processException("Cannot make interaction group "+"A"+fileName+"Group", e); - } - ((AInteractionGroup)group).setGroupName(screenName); - return(AInteractionGroup)group; - } - - private static JPopupMenu makePopupMenu(AInteractionToolBar root) { - JPopupMenu menu=new JPopupMenu(); - - AInteractionGroup[] panels=root.getGroups(); - - for(int i=0; i<panels.length; i++) - menu.add(panels[i].getPopupItem()); - - return menu; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AItemTabbedPane.java b/graphics/AtlantisJava/src/atlantis/gui/AItemTabbedPane.java deleted file mode 100755 index 901642ad4d732d717f7b5c119690aaee84351117..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AItemTabbedPane.java +++ /dev/null @@ -1,144 +0,0 @@ -package atlantis.gui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; - -// Gary- DnD facility commented out as it does not fully work -// ( Window control is left in funny state) -// and is not something i have ever used..... - -/** - * A TabbedPane which generates events when a tab is selected - * and when a tab is deselected. - * Provides DnD support. - */ -public class AItemTabbedPane extends JTabbedPane - implements // for Item Selectability - ItemSelectable, ChangeListener { -// // for drag and drop -// DragSourceListener, DragGestureListener, ACallBack { - - private Component current; - private Component previous; - private ItemListener itemListener; - private ItemEvent itemEvent; - -// private DragSource dragSource=null; -// private Vector dragListeners; - - public AItemTabbedPane(int tabPlacement) { - super(tabPlacement); - // tabs don't change on right click rather help appears. - setUI(new ATabbedPaneUI()); - - current=null; - previous=null; - this.addChangeListener(this); - -// // initializing drag and drop -// dragSource=new DragSource(); -// dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this); - -// dragListeners=new Vector(); - } - - public Component getPreviousSelectedComponent() { - if(previous==null) - return getSelectedComponent(); - else - return previous; - } - - public void stateChanged(ChangeEvent e) { - previous=current; - - if((current!=null)&&(itemListener!=null)) { - itemEvent=new ItemEvent(this, 0, current, ItemEvent.DESELECTED); - itemListener.itemStateChanged(itemEvent); - } - - current=getSelectedComponent(); - - if(itemListener!=null) { - itemEvent=new ItemEvent(this, 0, current, ItemEvent.SELECTED); - itemListener.itemStateChanged(itemEvent); - } - } - - // Add a listener to recieve item events when the state of an tab changes. - public void addItemListener(ItemListener l) { - itemListener=l; - } - - // Returns the selected items or null if no items are selected. - public Object[] getSelectedObjects() { - return null; - } - - // Removes an item listener. - public void removeItemListener(ItemListener l) { - if(itemListener.equals(l)) - itemListener=null; - } - - public Dimension getPreferredSize() { - this.getLayout().layoutContainer(this); - return super.getPreferredSize(); - } - -/* - // implementation of DragSourceListener - - // This method is invoked to signify that the Drag and Drop operation is complete. - public void dragDropEnd(DragSourceDropEvent dsde) {} - - // Called as the hotspot enters a platform dependent drop site. - public void dragEnter(DragSourceDragEvent dsde) { - dsde.getDragSourceContext().setCursor(ADnDLabel.DROP_VALID); - } - - // Called as the hotspot exits a platform dependent drop site. - public void dragExit(DragSourceEvent dse) { - dse.getDragSourceContext().setCursor(ADnDLabel.DROP_INVALID); - } - - // Called as the hotspot moves over a platform dependent drop site. - public void dragOver(DragSourceDragEvent dsde) { - dsde.getDragSourceContext().setCursor(ADnDLabel.DROP_VALID); - } - - // Called when the user has modified the drop gesture. - public void dropActionChanged(DragSourceDragEvent dsde) {} - - // implementation of DragGestureListener - - public void dragGestureRecognized(DragGestureEvent dge) { - Point p=dge.getDragOrigin(); - - if(getSelectedIndex()==getUI().tabForCoordinate(this, p.x, p.y)) { - AObjectTransferable cbt=new AObjectTransferable(this); - - dragSource.startDrag(dge, ADnDLabel.DROP_INVALID, cbt, this); - } - } - - public void callBack(Object to) { - for(int i=0; i<dragListeners.size(); i++) - ((ADragListener)dragListeners.get(i)).dragPerformed(this, to, -1); - } - - public void addDragListener(ADragListener l) { - dragListeners.addElement(l); - } - - public void addChangeListener(ChangeListener l) { - super.addChangeListener(l); - } - - public void removeChangeListener(ChangeListener l) { - super.removeChangeListener(l); - } -*/ -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ALayoutDialog.java b/graphics/AtlantisJava/src/atlantis/gui/ALayoutDialog.java deleted file mode 100755 index 93e07f52794a9f911b179c286b097d3c7ff4c37e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ALayoutDialog.java +++ /dev/null @@ -1,109 +0,0 @@ -package atlantis.gui; - -import java.awt.BorderLayout; -import java.awt.GridLayout; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JPanel; -import javax.swing.JRadioButton; - -import atlantis.canvas.ACanvas; -import atlantis.globals.AGlobals; - -/** - * A dialog which lets the user to select between the different layouts of the - * canvas. - */ -public class ALayoutDialog extends JDialog implements ActionListener -{ - private JPanel choosePanel; - private JPanel buttonsPanel; - private JButton okButton, cancelButton; - private JRadioButton selected; - - private static final AGlobals globals = AGlobals.instance(); - - public ALayoutDialog() - { - super(globals.getGuiFrame(), "Layout Properties Dialog", true); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - setResizable(false); - - choosePanel = new JPanel(); - choosePanel.setBorder(BorderFactory.createTitledBorder(" Select Layout ")); - - String[] layoutNames = ACanvas.getCanvas().getLayoutNames(); - ButtonGroup group = new ButtonGroup(); - - choosePanel.setLayout(new GridLayout(layoutNames.length, 1)); - for (int i = 0; i < layoutNames.length; i++) - { - JRadioButton r = new JRadioButton(layoutNames[i]); - - r.addActionListener(this); - if (ACanvas.getCanvas().getCurrentLayout().getName().equals(layoutNames[i])) - { - selected = r; - r.setSelected(true); - } - else - r.setSelected(false); - group.add(r); - choosePanel.add(r); - } - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(choosePanel, BorderLayout.CENTER); - - okButton = new JButton("OK"); - okButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - ACanvas.getCanvas().setCurrentLayout(selected.getText()); - dispose(); - ACanvas.getCanvas().bringToFront(); - } - }); - - cancelButton = new JButton("Cancel"); - cancelButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - dispose(); - } - }); - - buttonsPanel = new JPanel(); - buttonsPanel.add(okButton); - buttonsPanel.add(cancelButton); - getContentPane().add(buttonsPanel, BorderLayout.SOUTH); - pack(); - - // set the initial location - AGUI gui = AGUI.getGUI(); - int guiWidth = gui.getWidth(); - int guiHeight = gui.getHeight(); - int guiX = gui.getX(); - int dialogWidth = (int) this.getPreferredSize().getWidth(); - int dialogHeight = (int) this.getPreferredSize().getHeight(); - int screenWidth = Math.round((float) Toolkit.getDefaultToolkit().getScreenSize().getWidth()); - if(guiX+guiWidth+(dialogWidth-guiWidth)/2>screenWidth) - this.setLocation(Math.max(0, screenWidth - dialogWidth), Math.max(0, (guiHeight - dialogHeight) / 3)); - else - this.setLocation(Math.max(0, guiX + (guiWidth - dialogWidth) / 2), Math.max(0, (guiHeight - dialogHeight) / 3)); - setVisible(true); - } - - public void actionPerformed(ActionEvent e) - { - selected = (JRadioButton) e.getSource(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ALazyPanel.java b/graphics/AtlantisJava/src/atlantis/gui/ALazyPanel.java deleted file mode 100755 index d6caed6c259b74b2d13c21ab8edbf8040f799169..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ALazyPanel.java +++ /dev/null @@ -1,109 +0,0 @@ -package atlantis.gui; - -import java.awt.Graphics; -import javax.swing.JPanel; - -/** - * LazyPanel is an abstract base class that provides functionality - * to defer populating a Panel object until it is actually viewed. - * This is extremely useful when using CardLayout and tab panel - * views because it allows the construction of the subviews to - * be done on a pay-as-you-go basis instead of absorbing all the cost - * of construction up front. - * - * If subclasses choose to override any of the following methods, - * it is their responsibility to ensure their overridden methods - * call the parent's method first. The methods are: - * - * public void paint (Graphics) - * public void paintComponents(Graphics) - * public void paintAll (Graphics) - * public void repaint () - * public void repaint (long) - * public void repaint (int, int, int, int) - * public void repaint (long, int, int, int, int) - * public void update (Graphics) - * - * Each of these methods ensures the panel is constructed - * and then simply forwards the call to the parent class. - * - * You use this class by extending it and moving as much of the - * constructor code as possible from the child class into the method - * lazyConstructor. - */ - -public abstract class ALazyPanel extends JPanel { - - // We want to call the lazyConstructor only once. - private boolean lazyConstructorCalled=false; - - public void paint(Graphics g) { - callLazyConstructor(); - super.paint(g); - } - - public void paintAll(Graphics g) { - callLazyConstructor(); - super.paintAll(g); - } - - public void paintComponents(Graphics g) { - callLazyConstructor(); - super.paintComponents(g); - } - - public void repaint() { - callLazyConstructor(); - super.repaint(); - } - - public void repaint(long l) { - callLazyConstructor(); - super.repaint(l); - } - - public void repaint(int i1, int i2, int i3, int i4) { - callLazyConstructor(); - super.repaint(i1, i2, i3, i4); - } - - public void repaint(long l, int i1, int i2, int i3, int i4) { - callLazyConstructor(); - super.repaint(l, i1, i2, i3, i4); - } - - public void update(Graphics g) { - callLazyConstructor(); - super.update(g); - } - - /** - * Force the lazyConstructor() method implemented in the child class - * to be called. If this method is called more than once on - * a given object, all calls but the first do nothing. - */ - public synchronized final void callLazyConstructor() { - // The general idea below is as follows: - // 1) See if this method has already been successfully called. - // If so, return without doing anything. - // - // 2) Otherwise ... call the lazy constructor. - // 3) Call validate so that any components added are visible. - // 4) Note that we have run. - - if((lazyConstructorCalled==false)&&(getParent()!=null)) { - lazyConstructor(); - lazyConstructorCalled=true; - validate(); - } - } - - /** - * This method must be implemented by any child class. Most of - * the component creation code that would have gone in the constructor - * of the child goes here instead. See the example - * at the top. - */ - abstract protected void lazyConstructor(); - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AListsControl.java b/graphics/AtlantisJava/src/atlantis/gui/AListsControl.java deleted file mode 100755 index 4e8810bc05c4111829ebcd179ba57310dfa7ef38..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AListsControl.java +++ /dev/null @@ -1,28 +0,0 @@ -package atlantis.gui; - -import atlantis.list.AListManager; -import atlantis.utils.AUtilities; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -/** - * The preferences menu. - */ -public class AListsControl extends AMenuButton { - - public AListsControl() { - super("Lists"); - this.setToolTipText("List control dialog" ); - this.setBorder(null); - this.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - if (AUtilities.isRightMouseButton(e)) { - AHelpSystem.getInstance().showPage("Lists"); - } else { - AListManager.getInstance().showLists(); - } - } - }); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ALogPane.java b/graphics/AtlantisJava/src/atlantis/gui/ALogPane.java deleted file mode 100644 index 693c6f4be771470ca93590de1523574f3b9cf10d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ALogPane.java +++ /dev/null @@ -1,205 +0,0 @@ -package atlantis.gui; - -import java.awt.Color; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTextPane; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Style; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyleContext; - -import atlantis.output.ALogInterface; -import atlantis.utils.ALogger; - -/** - * This class is a subclass of JTextPane which can be used for any kind of - * logging/text output window in Atlantis. It unifies the old AOutput and - * ALogOutput classes - * - * @author Adam Davison - */ -public class ALogPane extends JScrollPane implements ALogInterface { - - private static ALogger logger = ALogger.getLogger(ALogPane.class); - private Style m_systemDefaultStyle = null; - - private JTextPane m_textPane; - private JPopupMenu m_popupMenu; - private JMenuItem m_menuItemClearTextPane; - - public ALogPane() { - m_textPane = new JTextPane(); - m_textPane.setEditable(false); - m_textPane.setBackground(Color.white); - - setViewportView(m_textPane); - setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); - - // popup menu at text pane (info output at the bottom of the GUI) - m_popupMenu = new JPopupMenu(); - m_menuItemClearTextPane = new JMenuItem("Erase info output"); - m_menuItemClearTextPane.addActionListener(new PopupMenuActionListener(this)); - m_popupMenu.add(m_menuItemClearTextPane); - - m_textPane.addMouseListener(new PopupMenuListener_textPane(m_popupMenu)); - - // create style which are used to add text to the document - StyleContext context = StyleContext.getDefaultStyleContext(); - Style defaultStyle = context.getStyle(StyleContext.DEFAULT_STYLE); - - Style newStyle = m_textPane.addStyle(NORMAL, defaultStyle); - - StyleConstants.setFontFamily(newStyle, "Courier"); - StyleConstants.setFontSize(newStyle, 14); - - newStyle = m_textPane.addStyle(NORMAL_BOLD, defaultStyle); - StyleConstants.setFontFamily(newStyle, "Courier"); - StyleConstants.setFontSize(newStyle, 14); - StyleConstants.setBold(newStyle, true); - - newStyle = m_textPane.addStyle(COMMAND, defaultStyle); - StyleConstants.setFontFamily(newStyle, "Courier"); - StyleConstants.setFontSize(newStyle, 14); - StyleConstants.setForeground(newStyle, Color.blue); - - newStyle = m_textPane.addStyle(BAD_COMMAND, defaultStyle); - StyleConstants.setFontFamily(newStyle, "Courier"); - StyleConstants.setFontSize(newStyle, 14); - StyleConstants.setForeground(newStyle, Color.red); - - newStyle = m_textPane.addStyle(WARNING, defaultStyle); - // was Courier - didn't print some greek letters under Linux - StyleConstants.setFontFamily(newStyle, "Arial"); - StyleConstants.setFontSize(newStyle, 15); - StyleConstants.setBold(newStyle, true); - StyleConstants.setForeground(newStyle, Color.red); - - newStyle = m_textPane.addStyle(TITLE, defaultStyle); - StyleConstants.setFontFamily(newStyle, "Courier"); - StyleConstants.setFontSize(newStyle, 16); - StyleConstants.setItalic(newStyle, true); - StyleConstants.setForeground(newStyle, Color.blue); - - newStyle = m_textPane.addStyle(PICK, defaultStyle); - // was Courier - didn't print some greek letters under Linux - StyleConstants.setFontFamily(newStyle, "Arial"); - - StyleConstants.setFontSize(newStyle, 13); - StyleConstants.setItalic(newStyle, true); - StyleConstants.setForeground(newStyle, Color.blue); - - // This is the way ALogOutput styled it's text, perhaps we should - // use NORMAL instead to unify the look of all the output boxes? - AD - m_systemDefaultStyle = context.getStyle(StyleContext.DEFAULT_STYLE); - } - - @Override - public synchronized void append(String s) { - append(s, m_systemDefaultStyle); - } - - @Override - public synchronized void append(String s, String style) { - append(s, m_textPane.getStyle(style)); - } - - private synchronized void append(String s, Style style) { - Document document = m_textPane.getDocument(); - try { - int size = document.getLength(); - - // if the string being appended gets too long, which happens in the - // demo mode runs and leads to OutOfMemory here, cut off the first - // half of the string in the information output - if (size > 51200) // 50kB - { - document.remove(0, size / 2); - - // another option of cutting the string would be - // (but it doesn't preserve styles): - // String text = textPane.getText(); - // textPane.setText(""); // clear all - // s = text.substring(size / 2, size - 1) + s; - - size = document.getLength(); - } - - document.insertString(size, s, style); - - // set the scrollbar to the bottom of the window - // previous solution: - // scrollPane.getViewport().setViewPosition(new Point(0, 9999999)); - // was sometimes crashing with IndexOutOfBoundException - m_textPane.setCaretPosition(document.getLength()); - - if (style.equals(ALogInterface.BAD_COMMAND) || style.equals(ALogInterface.WARNING)) { - Toolkit.getDefaultToolkit().beep(); - } - } catch (BadLocationException e) { - logger.error("Problem in ALogPane", e); - } - } - - @Override - public void clear() { - m_textPane.setText(""); - } - -} - -class PopupMenuListener_textPane extends MouseAdapter -{ - private JPopupMenu popupMenu; - - PopupMenuListener_textPane(JPopupMenu popupMenu) - { - this.popupMenu = popupMenu; - } - - public void mousePressed(MouseEvent evt) - { - showPopupMenu(evt); - } - - public void mouseReleased(MouseEvent evt) - { - showPopupMenu(evt); - } - - private void showPopupMenu(MouseEvent evt) - { - // decides whether right 'trigger' action was performed to show - // the popup menu (on the text pane - info output in GUI) - if (evt.isPopupTrigger()) - { - popupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); - } - } - -} // class PopupMenuListener_textPane ======================================= - -class PopupMenuActionListener implements ActionListener -{ - ALogInterface adaptee; - - PopupMenuActionListener(ALogInterface adaptee) - { - this.adaptee = adaptee; - } - - // clear info output if the popup menu item was pressed - public void actionPerformed(ActionEvent e) - { - adaptee.clear(); - } - -} // class PopupMenuActionListener ========================================== diff --git a/graphics/AtlantisJava/src/atlantis/gui/AMainLogPane.java b/graphics/AtlantisJava/src/atlantis/gui/AMainLogPane.java deleted file mode 100644 index c493fad653f5a7ad13b0871618e85774abb15b86..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AMainLogPane.java +++ /dev/null @@ -1,13 +0,0 @@ -package atlantis.gui; - -/** - * The main logging pane showing user information - * @author Adam Davison - */ -public class AMainLogPane extends ALogPane { - - public AMainLogPane() { - super(); - append("Welcome to Atlantis !\n", TITLE); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AMenuButton.java b/graphics/AtlantisJava/src/atlantis/gui/AMenuButton.java deleted file mode 100644 index 3a939230f0dc8f0146fd0ebd3a2d5349f6b0f170..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AMenuButton.java +++ /dev/null @@ -1,46 +0,0 @@ -package atlantis.gui; - -import java.awt.Dimension; -import java.awt.FontMetrics; -import javax.swing.JMenuItem; - -/** - * AMenuButton is an object that acts like a JMenuItem but looks like a JMenu. - * This is for the buttons that we add directly to the menu bar. It does not - * allow the layout manager to change it size. - * - * @author Eric Jansen - */ -public class AMenuButton extends JMenuItem { - - /** Extra space needed to make JMenuItem and JMenu look the same */ - private static int EXTRA_SPACE = 6; - - /** Initial preferred size */ - private Dimension size; - - public AMenuButton(String title) { - super(title); - setOpaque(false); - - FontMetrics fm = getFontMetrics(getFont()); - size = super.getPreferredSize(); - size.width = getMargin().left + fm.stringWidth(title) - + getMargin().right + EXTRA_SPACE; - } - - @Override - public Dimension getMinimumSize() { - return size; - } - - @Override - public Dimension getMaximumSize() { - return size; - } - - @Override - public Dimension getPreferredSize() { - return size; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AMouseHelpDialog.java b/graphics/AtlantisJava/src/atlantis/gui/AMouseHelpDialog.java deleted file mode 100755 index c8c691abe24cfefdae7c08dd8f028fc9a9aa843d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AMouseHelpDialog.java +++ /dev/null @@ -1,312 +0,0 @@ -package atlantis.gui; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Font; -import java.awt.Frame; -import java.awt.Toolkit; -import java.util.ArrayList; -import java.util.EventObject; -import java.util.Iterator; -import java.util.Vector; - -import javax.swing.JFrame; -import javax.swing.JTable; -import javax.swing.event.CellEditorListener; -import javax.swing.table.AbstractTableModel; -import javax.swing.ButtonGroup; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableModel; -import javax.swing.table.TableCellRenderer; -import javax.swing.JRadioButton; - -import atlantis.canvas.ACanvas; -import atlantis.globals.AGlobals; -import atlantis.graphics.AIcon; -import atlantis.interactions.AInteraction; -import atlantis.interactions.AModifier; - -import java.awt.event.*; - -/** - * This dialog is used to display the mouse modifiers which are currently active - * Once more a singleton, but at least a proper one (private constructor) - */ -public class AMouseHelpDialog extends JFrame { - - private static JTable table; - static Object[][] rowData; - static Object[] columnNames; - private static AMouseHelpDialog instance; - private static final AGlobals globals = AGlobals.instance(); - - /** - * Private singleton constructor - */ - private AMouseHelpDialog() { - super("Help - Modifier Keys"); - - AIcon.setIconImage(this); - - table = new JTable() { - public TableCellRenderer getCellRenderer(int row, int column) { - if (column == 0) { - return new RadioRenderer(); - } - // else... - return super.getCellRenderer(row, column); - } - - public TableCellEditor getCellEditor(int row, int column) { - if (column == 0) { - return new RadioEditor(); - } else { - return super.getCellEditor(row, column); - } - } - }; - - table.setRowHeight(20); - - table.setFont(new Font("Monospaced", Font.PLAIN, table.getFont().getSize())); - table.setRowSelectionAllowed(false); - - getContentPane().add(table.getTableHeader(), BorderLayout.NORTH); - getContentPane().add(table, BorderLayout.CENTER); - setResizable(false); - - // From Java 1.5 we can tell the window to be always on top - this.setAlwaysOnTop(true); - - this.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - // Reset key modifier when closing the window - AEventQueue.setDefault(AModifier.nothing); - } - }); - - pack(); - - } - - /** - * Get an instance of this singleton - * @return the AMouseHelpDialog instance - */ - public static AMouseHelpDialog getInstance() { - //Make sure no GUI object is created in headless mode - if (AGlobals.isAtlantisHeadless()) return null; - - //Create instance if it does not exist - if (instance == null) instance = new AMouseHelpDialog(); - return instance; - } - - - /** - * Overwrite setVisible to ensure proper placement of the dialog - * @param visible wether the dialog should be visible - */ - @Override - public void setVisible(boolean visible){ - - //Set the proper location on the screen - Frame gui = globals.getGuiFrame(); - int guiWidth = gui.getWidth(); - int guiX = gui.getX(); - int guiY = gui.getY(); - int dialogWidth = (int) instance.getPreferredSize().getWidth(); - int screenWidth = Math.round((float) Toolkit.getDefaultToolkit().getScreenSize().getWidth()); - if (guiX + guiWidth + (dialogWidth - guiWidth) / 2 > screenWidth) - instance.setLocation(Math.max(0, screenWidth - dialogWidth), Math.max(0, guiY)); - else - instance.setLocation(Math.max(0, guiX + (guiWidth - dialogWidth) / 2), Math.max(0, guiY)); - - //And finally do set it visible! - super.setVisible(visible); - } - - public static void processInteractionChange(Vector interactions) { - if (ACanvas.getCanvas().getCurrentWindow() == null) - return; - - AModifier[] modifiers = ACanvas.getCanvas().getCurrentWindow().getInteractionManager().getMouseModifiers(); - ArrayList<AModifier> m = new ArrayList<AModifier>(); - for (int i = 0; i < modifiers.length; ++i) - m.add(modifiers[i]); - for (int i = 0; i < interactions.size(); ++i) { - AModifier[] mod = ((AInteraction) interactions.get(i)).getModifiers(); - for (int j = 0; j < mod.length; ++j) - m.add(mod[j]); - } - - // remove duplicates - for (int i = 0; i < m.size(); ++i) - for (int j = i + 1; j < m.size(); ++j) - if (m.get(i) != null && m.get(j) != null && ((AModifier)m.get(i)).sameAs((AModifier)m.get(j))) { - m.set(i, null); - } - - Iterator<AModifier> it = m.iterator(); - while (it.hasNext()) - if (it.next() == null) - it.remove(); - - // sort - for (int i = 0; i < m.size(); ++i) - for (int j = i + 1; j < m.size(); ++j) { - String n = m.get(i).toKeyString(); - String o = m.get(j).toKeyString(); - if (o.length() > n.length() || (o.length() == n.length() && (o.length() > 0 && (o.charAt(0) < n.charAt(0))))) { - AModifier temp = m.get(i); - m.set(i, m.get(j)); - m.set(j, temp); - } - } - - int foundnull = -1; - for (int i = 0; i < m.size(); i++) { - AModifier mod = (AModifier)m.get(i); - if (mod.sameAs(AModifier.nothing)) { - foundnull = i; - } - } - - if (foundnull == -1) { - m.add(AModifier.nothing); - } - - ButtonGroup bgroup = new ButtonGroup(); - - rowData = new Object[m.size()][3]; - for (int i = 0; i < rowData.length; ++i) { - AModifier mod = (AModifier)m.get(i); - JRadioButton but = new MouseHelpRadio(mod); - - if (mod.sameAs(AEventQueue.getDefault())) { - but.setSelected(true); - } - - if (mod.sameAs(AModifier.nothing)) { - foundnull = i; - } - - bgroup.add(but); - - rowData[i][0] = but; - rowData[i][1] = mod.toKeyString(); - rowData[i][2] = mod.toDescString(); - } - - columnNames = new String[] { "", "Key", "Action" }; - TableModel model = new AbstractTableModel() { - public String getColumnName(int column) { - return columnNames[column].toString(); - } - - public int getRowCount() { - return rowData.length; - } - - public int getColumnCount() { - return columnNames.length; - } - - public Object getValueAt(int row, int col) { - return rowData[row][col]; - } - - public boolean isCellEditable(int row, int column) { - if (column == 0) { - return true; - } else { - return false; - } - } - - public void setValueAt(Object value, int row, int col) { - rowData[row][col] = value; - fireTableCellUpdated(row, col); - } - }; - - table.setModel(model); - table.getColumnModel().getColumn(0).setPreferredWidth(22); - table.getColumnModel().getColumn(1).setPreferredWidth(80); - table.getColumnModel().getColumn(2).setPreferredWidth(300); - instance.pack(); - } - - private static class MouseHelpRadio extends JRadioButton { - - AModifier m_mod; - - public MouseHelpRadio(AModifier mod) { - m_mod = mod; - - this.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (isSelected()) { - AEventQueue.setDefault(m_mod); - } - // Previously selected radio button doesn't always paint it's - // unselection if you aren't careful - getParent().repaint(); - } - }); - } - - } - - private static class RadioRenderer implements TableCellRenderer { - - public RadioRenderer() { - } - - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) { - - return (JRadioButton)value; - } - - } - - private static class RadioEditor implements TableCellEditor { - - private JRadioButton button; - - public RadioEditor() { - - } - - public Object getCellEditorValue() { - return button; - } - - public boolean shouldSelectCell(EventObject anEvent) { - return false; - } - - public boolean isCellEditable(EventObject anEvent) { - return true; - } - - public void removeCellEditorListener(CellEditorListener l) { - } - - public void addCellEditorListener(CellEditorListener l) { - } - - public boolean stopCellEditing() { - return true; - } - - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - button = (JRadioButton)value; - return button; - } - - public void cancelCellEditing() { - } - } -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/gui/AMultiSpanCellTableUI.java b/graphics/AtlantisJava/src/atlantis/gui/AMultiSpanCellTableUI.java deleted file mode 100755 index cf0054cee6d72c3cd79345fe44b00bfa6ec23d90..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AMultiSpanCellTableUI.java +++ /dev/null @@ -1,81 +0,0 @@ -package atlantis.gui; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Rectangle; - -import javax.swing.JComponent; -import javax.swing.plaf.basic.BasicTableUI; -import javax.swing.table.TableCellRenderer; - -public class AMultiSpanCellTableUI extends BasicTableUI -{ - public void paint(Graphics g, JComponent c) - { - for (int index = 0; index < table.getRowCount(); index++) - { - paintRow(g, index); - } - } - - private void paintRow(Graphics g, int row) - { - AParamGUIDataModel tableModel = (AParamGUIDataModel) table.getModel(); - ADefaultCellAttribute cellAtt = tableModel.getCellAttribute(); - int numColumns = table.getColumnCount(); - - for (int column = 0; column < numColumns; column++) - { - Rectangle cellRect = table.getCellRect(row, column, true); - int cellRow, cellColumn; - if (cellAtt.isVisible(row, column)) - { - cellRow = row; - cellColumn = column; - } - else - { - cellRow = row + cellAtt.getSpan(row, column)[ADefaultCellAttribute.ROW]; - cellColumn = column + cellAtt.getSpan(row, column)[ADefaultCellAttribute.COLUMN]; - } - paintCell(g, cellRect, cellRow, cellColumn); - } - } - - private void paintCell(Graphics g, Rectangle cellRect, int row, int column) - { - int spacingHeight = table.getRowMargin(); - int spacingWidth = table.getColumnModel().getColumnMargin(); - - Color c = g.getColor(); - g.setColor(table.getGridColor()); - g.drawRect(cellRect.x, cellRect.y, cellRect.width - 1, - cellRect.height - 1); - g.setColor(c); - - cellRect.setBounds(cellRect.x + spacingWidth / 2, cellRect.y - + spacingHeight / 2, cellRect.width - spacingWidth, - cellRect.height - spacingHeight); - - if (table.isEditing() && table.getEditingRow() == row - && table.getEditingColumn() == column) - { - Component component = table.getEditorComponent(); - component.setBounds(cellRect); - component.validate(); - } - else - { - TableCellRenderer renderer = table.getCellRenderer(row, column); - Component component = table.prepareRenderer(renderer, row, column); - - if (component.getParent() == null) - { - rendererPane.add(component); - } - rendererPane.paintComponent(g, component, table, cellRect.x, - cellRect.y, cellRect.width, cellRect.height, true); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AMutableCheckBox.java b/graphics/AtlantisJava/src/atlantis/gui/AMutableCheckBox.java deleted file mode 100755 index 92390995e52ebf912cb78924c25266c988b156a6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AMutableCheckBox.java +++ /dev/null @@ -1,183 +0,0 @@ -package atlantis.gui; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.LayoutManager; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Vector; - -import javax.swing.BorderFactory; -import javax.swing.JLabel; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.LookAndFeel; - -import atlantis.utils.AUtilities; - -/** - * Used to display the status and the operator(<,>,=..etc) of a Cut Parameter. - */ -public class AMutableCheckBox extends JPanel { - private JLabel label; - private ACheckBox checkBox; - private javax.swing.Timer timer; - private JPopupMenu popup; - private String selectedText; - private ActionListener statusActionListener, textActionListener; - private Vector oper=new Vector(); - - public AMutableCheckBox(String name) { - setLayout(new AMutableCheckBoxLayout()); - setBorder(null); - - checkBox=new ACheckBox(name); - checkBox.setBackground(new Color(204, 204, 204)); - checkBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if(statusActionListener!=null) - statusActionListener.actionPerformed(new ActionEvent(get(), 0, "")); - } - }); - add("CHECKBOX", checkBox); - - popup=new JPopupMenu(); - } - - // must be called after all the parameters whose added - public void finalizeConstruction() { - label=new JLabel("", JLabel.CENTER); - label.setBorder(BorderFactory.createLineBorder(new Color(153, 153, 153), 1)); - LookAndFeel.installColorsAndFont(label, "CheckBox.background", "CheckBox.foreground", - "CheckBox.font"); - add("LABEL", label); - - // setting the timmer and popup (if more than 2 supportedOperators) - if(oper.size()>2) { - timer=new javax.swing.Timer(50, new ActionListener() { - public void actionPerformed(ActionEvent e) { - Dimension d=label.getSize(); - - popup.show(label, 0, d.height); - } - }); - timer.setRepeats(false); - } - - // setting the mouse listeners - if(oper.size()<=2) - label.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - if(AUtilities.isRightMouseButton(e)||oper.size()==1){ - return; - } - String text0=(String)oper.elementAt(0); - String text1=(String)oper.elementAt(1); - - if(selectedText.equals(text0)) setSelectedText(text1); - else if(selectedText.equals(text1)) setSelectedText(text0); - - if(textActionListener!=null) - textActionListener.actionPerformed(new ActionEvent(get(), 0, "")); - } - }); - else - label.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - if(!AUtilities.isRightMouseButton(e)) - timer.start(); - } - - public void mouseReleased(MouseEvent e) { - if(!AUtilities.isRightMouseButton(e)) - timer.stop(); - } - }); - } - - private JPanel get() { - return this; - } - - public ACheckBox getCheckBox(){ - return checkBox; - } - - public void addItem(String s) { - oper.addElement(s); - - popup.add(s).addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - JMenuItem item=(JMenuItem)e.getSource(); - - setSelectedText(item.getText()); - if(textActionListener!=null) - textActionListener.actionPerformed(new ActionEvent(get(), 0, "")); - } - }); - } - - public void setSelectedText(String text) { - selectedText=text; - label.setText(selectedText); - } - - public String getSelectedText() { - return selectedText; - } - - public boolean getStatus() { - return checkBox.isSelected(); - } - - public void setStatus(boolean status) { - checkBox.setSelected(status); - } - - public void addTextActionListener(ActionListener listener) { - textActionListener=listener; - } - - public void addStatusActionListener(ActionListener listener) { - statusActionListener=listener; - } - - public void setForeground(Color color) { - if(checkBox!=null) - checkBox.setForeground(color); - } -} - -class AMutableCheckBoxLayout implements LayoutManager { - private Component checkBox, label; - - public void addLayoutComponent(String name, Component comp) { - if(name.equals("CHECKBOX")) checkBox=comp; - else if(name.equals("LABEL")) label=comp; - } - - public void layoutContainer(Container parent) { - Dimension p=parent.getSize(); - Dimension l=label.getPreferredSize(); - Dimension c=checkBox.getPreferredSize(); - - checkBox.setBounds(0, (p.height-c.height)/2, p.width-l.width-10, c.height); - label.setBounds(p.width-l.width-10, -1, l.width+10+1, p.height+2); - } - - public Dimension minimumLayoutSize(Container parent) { - return new Dimension(10, 10); - } - - public Dimension preferredLayoutSize(Container parent) { - return new Dimension(100, 100); - } - - // Removes the specified component from the layout. - public void removeLayoutComponent(Component comp) {} -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AOpenGLControl.java b/graphics/AtlantisJava/src/atlantis/gui/AOpenGLControl.java deleted file mode 100644 index 3df9c139c0167525380641e86d8ce1049f31d8d1..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AOpenGLControl.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package atlantis.gui; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.canvas.AWindowGLView; -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.ButtonGroup; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JRadioButtonMenuItem; -import javax.swing.JSeparator; -import javax.swing.event.MenuEvent; -import javax.swing.event.MenuListener; - -/** - * - * @author Adam - */ -public class AOpenGLControl extends JMenu implements MenuListener, ActionListener { - - private ButtonGroup m_bg = new ButtonGroup(); - private JRadioButtonMenuItem m_fsaa0 = new JRadioButtonMenuItem("No AA"); - private JRadioButtonMenuItem m_fsaa2 = new JRadioButtonMenuItem("2x FSAA"); - private JRadioButtonMenuItem m_fsaa4 = new JRadioButtonMenuItem("4x FSAA"); - private JRadioButtonMenuItem m_fsaa6 = new JRadioButtonMenuItem("6x FSAA"); - private JRadioButtonMenuItem m_fsaa8 = new JRadioButtonMenuItem("8x FSAA"); - private JCheckBoxMenuItem m_blendborder = new JCheckBoxMenuItem("Blend Border"); - private boolean m_updating = false; - - public AOpenGLControl() { - super("OpenGL"); - - m_bg.add(m_fsaa0); - m_bg.add(m_fsaa2); - m_bg.add(m_fsaa4); - m_bg.add(m_fsaa6); - m_bg.add(m_fsaa8); - - add(m_fsaa0); - add(m_fsaa2); - add(m_fsaa4); - add(m_fsaa6); - add(m_fsaa8); - add(new JSeparator()); - add(m_blendborder); - - m_fsaa0.addActionListener(this); - m_fsaa2.addActionListener(this); - m_fsaa4.addActionListener(this); - m_fsaa6.addActionListener(this); - m_fsaa8.addActionListener(this); - - m_blendborder.addActionListener(this); - - addMenuListener(this); - } - - public void menuSelected(MenuEvent e) { - m_updating = true; - - int maxFSAA = AWindowGLView.getMaxFSAA(); - - m_fsaa2.setEnabled(false); - m_fsaa4.setEnabled(false); - m_fsaa6.setEnabled(false); - m_fsaa8.setEnabled(false); - - if (maxFSAA >= 2) { - m_fsaa2.setEnabled(true); - - if (maxFSAA >= 4) { - m_fsaa4.setEnabled(true); - - if (maxFSAA >= 6) { - m_fsaa6.setEnabled(true); - - if (maxFSAA >= 8) { - m_fsaa8.setEnabled(true); - } - } - } - } - - int currentFSAA = AWindowGLView.getCurrentFSAA(); - - switch (currentFSAA) { - case 0: - m_fsaa0.setSelected(true); - break; - case 2: - m_fsaa2.setSelected(true); - break; - case 4: - m_fsaa4.setSelected(true); - break; - case 6: - m_fsaa6.setSelected(true); - break; - case 8: - m_fsaa8.setSelected(true); - break; - default: - break; - } - - m_updating = false; - } - - public void menuDeselected(MenuEvent e) { - //throw new UnsupportedOperationException("Not supported yet."); - } - - public void menuCanceled(MenuEvent e) { - //throw new UnsupportedOperationException("Not supported yet."); - } - - public void actionPerformed(ActionEvent e) { - if (m_updating) { - return; - } - - JMenuItem src = (JMenuItem) (e.getSource()); - - if (src == m_fsaa0) { - AWindowGLView.setCurrentFSAA(0); - } else if (src == m_fsaa2) { - AWindowGLView.setCurrentFSAA(2); - } else if (src == m_fsaa4) { - AWindowGLView.setCurrentFSAA(4); - } else if (src == m_fsaa6) { - AWindowGLView.setCurrentFSAA(6); - } else if (src == m_fsaa8) { - AWindowGLView.setCurrentFSAA(8); - } else if (src == m_blendborder) { - int oldr = AWindow.BORDER_BACKGROUND_COLOR.getRed(); - int oldg = AWindow.BORDER_BACKGROUND_COLOR.getGreen(); - int oldb = AWindow.BORDER_BACKGROUND_COLOR.getBlue(); - int oldselr = AWindow.BORDER_SELECTED_BACKGROUND_COLOR.getRed(); - int oldselg = AWindow.BORDER_SELECTED_BACKGROUND_COLOR.getGreen(); - int oldselb = AWindow.BORDER_SELECTED_BACKGROUND_COLOR.getBlue(); - if (m_blendborder.getState()) { - AWindow.BORDER_BACKGROUND_COLOR = new Color(oldr, oldg, oldb, 127); - AWindow.BORDER_SELECTED_BACKGROUND_COLOR = new Color( - oldselr, oldselg, oldselb, 127); - } else { - AWindow.BORDER_BACKGROUND_COLOR = new Color(oldr, oldg, oldb, 255); - AWindow.BORDER_SELECTED_BACKGROUND_COLOR = new Color( - oldselr, oldselg, oldselb, 255); - } - ACanvas.getCanvas().repaintAllFromScratch(); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AParamGUIDataModel.java b/graphics/AtlantisJava/src/atlantis/gui/AParamGUIDataModel.java deleted file mode 100755 index b1b03a9a1ebf9ed63be66b001737c8960721121d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AParamGUIDataModel.java +++ /dev/null @@ -1,173 +0,0 @@ -package atlantis.gui; - -import java.awt.Component; -import java.util.EventObject; -import java.util.Vector; - -import javax.swing.JTable; -import javax.swing.JTree; -import javax.swing.event.CellEditorListener; -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; - -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.parameters.AParametersGroup; -import atlantis.parameters.AStatusRootParameter; - -/** - * The data model used to create the custom tables which contain parameters. - */ -class AParamGUIDataModel extends AbstractTableModel implements - TableCellEditor, TableCellRenderer -{ - private Vector<AParameter> parametersList; - // if there is a tree in a cell, the height of the cell should be decided by the tree - private int[] rowHeight; - // indicate if there is a tree in this table - private boolean isTree = false; - private JTree tree = null; - private int treeRowNumber = -1; - private ADefaultCellAttribute cellAtt; - - AParamGUIDataModel(AParametersGroup group) - { - parametersList = group.getParameters(APar.instance().getUserLevel()); - rowHeight = new int[parametersList.size()]; - - cellAtt = new ADefaultCellAttribute(rowHeight.length, 2); - - for (int i = 0; i < parametersList.size(); i++) - { - AParameter p = (AParameter) parametersList.elementAt(i); - if (!p.isInitialized()) - p.initialize(); - if (p instanceof AStatusRootParameter) - { - isTree = true; - tree = (JTree) ((AStatusRootParameter) p).getNameComponent(); - treeRowNumber = i; - rowHeight[i] = tree.getRowCount() - * (int) (tree.getRowBounds(0).getHeight()); - int[] columns = { 0, 1 }; - int[] rows = { i }; - cellAtt.combine(rows, columns); - } - else - rowHeight[i] = 25; - } - } - - public ADefaultCellAttribute getCellAttribute() - { - return cellAtt; - } - - int getRowHeight(int rowIndex) - { - return rowHeight[rowIndex]; - } - - public int getTreeRow() - { - return treeRowNumber; - } - - public boolean hasTree() - { - return isTree; - } - - public JTree getTree() - { - return tree; - } - - public int getRowCount() - { - return parametersList.size(); - } - - public int getColumnCount() - { - return 2; - } - - public Object getValueAt(int rowIndex, int columnIndex) - { - return new Integer(0); - } - - public boolean isCellEditable(int rowIndex, int columnIndex) - { - return true; - } - - public void refresh() - { - for (int i = 0; i < parametersList.size(); i++) - { - AParameter p = (AParameter) parametersList.elementAt(i); - p.refresh(); - } - } - - // TableCellRenderer implementation - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) - { - return getTableCellEditorComponent(table, value, isSelected, row, - column); - } - - // TableCellEditor implementation - public Component getTableCellEditorComponent(JTable table, Object value, - boolean isSelected, int row, int column) - { - AParameter p = (AParameter) parametersList.elementAt(row); - switch (column) - { - case 0: - return p.getNameComponent(); - case 1: - return p.getValueComponent(); - default: - return null; - } - } - - public AParameter getParameter(int row) - { - return (AParameter) parametersList.elementAt(row); - } - - public Object getCellEditorValue() - { - return new Integer(0); - } - - public boolean isCellEditable(EventObject anEvent) - { - return true; - } - - public boolean shouldSelectCell(EventObject anEvent) - { - return true; - } - - public boolean stopCellEditing() - { - return true; - } - - public void cancelCellEditing() - {} - - public void addCellEditorListener(CellEditorListener l) - {} - - public void removeCellEditorListener(CellEditorListener l) - {} -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AParametersPage.java b/graphics/AtlantisJava/src/atlantis/gui/AParametersPage.java deleted file mode 100755 index 6217ed42aa08a0dd1af069897e10b9bea75f25f2..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AParametersPage.java +++ /dev/null @@ -1,44 +0,0 @@ -package atlantis.gui; - -import atlantis.graphics.layout.AFlowLayout; -import atlantis.parameters.ACommand; -import atlantis.parameters.AParametersGroup; -import javax.swing.JScrollPane; -import javax.swing.JPanel; - -/** - * Used to display a table of parameters together with their associated - * commands in the Parameters Control. - */ -public class AParametersPage extends ALazyPanel { - private AParametersGroup group; - AParametersTable pTable; - - public AParametersPage(AParametersGroup group) { - this.group=group; - } - - protected void lazyConstructor() { - setLayout(new AGUILayoutManager()); - setBorder(null); - - add(createCommandsPanel(group), AGUILayoutManager.AVAILABLExPREFERRED); - - pTable=new AParametersTable(group); - pTable.setName(group.getScreenName()); - add(new JScrollPane(pTable), AGUILayoutManager.AVAILABLExAVAILABLE); - } - - private JPanel createCommandsPanel(AParametersGroup group) { - JPanel commandPanel=new JPanel(new AFlowLayout(5, 5)); - - commandPanel.setBorder(null); - ACommand[] commands=group.getCommands(); - - for(int j=0; j<commands.length; j++) - commandPanel.add(commands[j]); - - return commandPanel; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AParametersTable.java b/graphics/AtlantisJava/src/atlantis/gui/AParametersTable.java deleted file mode 100755 index 869510eaf7ff7cc02d9b7a28f97f4c79620ded8c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AParametersTable.java +++ /dev/null @@ -1,253 +0,0 @@ -package atlantis.gui; - -import java.awt.Dimension; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.Enumeration; - -import javax.swing.JPopupMenu; -import javax.swing.JTable; -import javax.swing.JTree; -import javax.swing.event.ListSelectionEvent; -import javax.swing.table.TableColumn; - -import atlantis.parameters.AParameter; -import atlantis.parameters.AParametersGroup; -import atlantis.parameters.AStatusRootParameter; -import atlantis.utils.AUtilities; - -/** - * The graphical object which contains all the parameter of a single group. - * Appears in the GUI. - */ -public class AParametersTable extends JTable -{ - private TableColumn column; - private AParamGUIDataModel dataModel; - public final static String SET_GLOBAL = "Set Global"; - public final static String SET_LOCAL = "Set Local"; - public final static String SET_ALL_GLOBAL = "Set All Global"; - public final static String SET_ALL_LOCAL = "Set All Local"; - - public AParametersTable(AParametersGroup g) - { - super(); - dataModel = new AParamGUIDataModel(g); - setModel(dataModel); - for (int i = 0; i < dataModel.getRowCount(); i++) - this.setRowHeight(i, dataModel.getRowHeight(i)); - if (dataModel.hasTree()) - { - JTree theTree = dataModel.getTree(); - theTree.addTreeExpansionListener(new ATreeExpansionListener( - theTree, this, dataModel.getTreeRow())); - } - column = getColumnModel().getColumn(0); - column.setHeaderValue("Name"); - column.setCellEditor(dataModel); - column.setCellRenderer(dataModel); - column.setPreferredWidth(110); - column = getColumnModel().getColumn(1); - column.setHeaderValue("Value"); - column.setCellEditor(dataModel); - column.setCellRenderer(dataModel); - column.setPreferredWidth(100); - setUI(new AMultiSpanCellTableUI()); - setCellSelectionEnabled(true); - - addMouseListener(new MouseAdapter() { - private int pressedX; - private int pressedY; - - public void mousePressed(MouseEvent e) - { - int clickedRow = rowAtPoint(e.getPoint()); - int clickedCol = columnAtPoint(e.getPoint()); - final AParameter p = ((AParamGUIDataModel) getModel()) - .getParameter(clickedRow); - if ((p instanceof AStatusRootParameter) && (clickedCol == 0)) - { - MouseListener[] theMLs = ((JTree) p.getNameComponent()) - .getMouseListeners(); - for (int i = 0; i < theMLs.length; i++) - { - if (theMLs[i] instanceof AStatusRootParameter.NodeSelectionListener) - { - Rectangle clickedRec = getCellRect(clickedRow, - clickedCol, false); - ((AStatusRootParameter.NodeSelectionListener) theMLs[i]) - .setOffset(clickedRec.x, clickedRec.y); - e.translatePoint(-clickedRec.x, -clickedRec.y); - if (AUtilities.isRightMouseButton(e)) - theMLs[i].mousePressed(e); - else - { - pressedX = e.getX(); - pressedY = e.getY(); - } - } - } - return; - } - if (AUtilities.isRightMouseButton(e) && (clickedCol == 0)) - { - JPopupMenu popupMenu = new JPopupMenu(); - if (p.getScope() == AParameter.LOCAL) - { - popupMenu.add(SET_GLOBAL).addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) - { - p.changeScope(AParameter.GLOBAL); - refresh(); - } - }); - } - else - { - popupMenu.add(SET_LOCAL).addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) - { - p.changeScope(AParameter.LOCAL); - refresh(); - } - }); - } - popupMenu.show(AParametersTable.this, e.getX(), e.getY()); - } - } - - // have no idea why mouseClicked cannot be invoked when clicking the - // table - // only mousePressed & mouseReleased can be invoked - public void mouseReleased(MouseEvent e) - { - int clickedRow = rowAtPoint(e.getPoint()); - // when the position of mouse releasing is out of the table, - // clickedRow = -1 - // e.g. when you change a value of a combo box, and the list of - // this combo box is rather long - if (clickedRow < 0) - return; - int clickedCol = columnAtPoint(e.getPoint()); - final AParameter p = ((AParamGUIDataModel) getModel()) - .getParameter(clickedRow); - if ((p instanceof AStatusRootParameter) && (clickedCol == 0)) - { - MouseListener[] theMLs = ((JTree) p.getNameComponent()) - .getMouseListeners(); - for (int i = 0; i < theMLs.length; i++) - { - if (theMLs[i] instanceof AStatusRootParameter.NodeSelectionListener) - { - Rectangle clickedRec = getCellRect(clickedRow, - clickedCol, false); - ((AStatusRootParameter.NodeSelectionListener) theMLs[i]) - .setOffset(clickedRec.x, clickedRec.y); - e.translatePoint(-clickedRec.x, -clickedRec.y); - if ((pressedX == e.getX()) - && (pressedY == e.getY())) - theMLs[i].mouseClicked(e); - } - } - return; - } - } - }); - // needed but I don't know why gary 25/10/2002 - refresh(); - } - - public void refresh() - { - dataModel.refresh(); - setEditingColumn(2); - setEditingRow(0); - } - - public Rectangle getCellRect(int row, int column, boolean includeSpacing) - { - Rectangle sRect = super.getCellRect(row, column, includeSpacing); - if ((row < 0) || (column < 0) || (getRowCount() <= row) - || (getColumnCount() <= column)) - { - return sRect; - } - ADefaultCellAttribute cellAtt = ((AParamGUIDataModel) getModel()).getCellAttribute(); - if (!cellAtt.isVisible(row, column)) - { - int temp_row = row; - int temp_column = column; - row += cellAtt.getSpan(temp_row, temp_column)[ADefaultCellAttribute.ROW]; - column += cellAtt.getSpan(temp_row, temp_column)[ADefaultCellAttribute.COLUMN]; - } - int[] n = cellAtt.getSpan(row, column); - - int index = 0; - int columnMargin = getColumnModel().getColumnMargin(); - Rectangle cellFrame = new Rectangle(); - int aCellHeight = sRect.height + rowMargin; - cellFrame.y = sRect.y; - cellFrame.height = n[ADefaultCellAttribute.ROW] * aCellHeight; - - Enumeration enumeration = getColumnModel().getColumns(); - while (enumeration.hasMoreElements()) - { - TableColumn aColumn = (TableColumn) enumeration.nextElement(); - cellFrame.width = aColumn.getWidth() + columnMargin; - if (index == column) - break; - cellFrame.x += cellFrame.width; - index++; - } - for (int i = 0; i < n[ADefaultCellAttribute.COLUMN] - 1; i++) - { - TableColumn aColumn = (TableColumn) enumeration.nextElement(); - cellFrame.width += aColumn.getWidth() + columnMargin; - } - - if (!includeSpacing) - { - Dimension spacing = getIntercellSpacing(); - cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y - + spacing.height / 2, cellFrame.width - spacing.width, - cellFrame.height - spacing.height); - } - return cellFrame; - } - - public void columnSelectionChanged(ListSelectionEvent e) - { - repaint(); - } - - public void valueChanged(ListSelectionEvent e) - { - int firstIndex = e.getFirstIndex(); - int lastIndex = e.getLastIndex(); - if (firstIndex == -1 && lastIndex == -1) - { - repaint(); - } - Rectangle dirtyRegion = getCellRect(firstIndex, 0, false); - int numCoumns = getColumnCount(); - int index = firstIndex; - for (int i = 0; i < numCoumns; i++) - { - dirtyRegion.add(getCellRect(index, i, false)); - } - index = lastIndex; - for (int i = 0; i < numCoumns; i++) - { - dirtyRegion.add(getCellRect(index, i, false)); - } - repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, - dirtyRegion.height); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/APasswordDialog.java b/graphics/AtlantisJava/src/atlantis/gui/APasswordDialog.java deleted file mode 100755 index eb54cbf2ec8c8ed66aee64094763041579c19d3c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/APasswordDialog.java +++ /dev/null @@ -1,203 +0,0 @@ -package atlantis.gui; - -import java.awt.Frame; -import java.awt.Container; -import java.awt.BorderLayout; -import java.awt.GridLayout; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.JPasswordField; -import javax.swing.JLabel; -import javax.swing.BoxLayout; - -import java.net.PasswordAuthentication; -import java.net.Authenticator; - -import atlantis.utils.ALogger; - -/** - * Provides a dialogue to prompt the user for a username and password for - * reading events from a password-protected URL. - * - * @author waugh - */ -public class APasswordDialog extends JDialog -{ - private static final long serialVersionUID = 1L; - - private static ALogger logger = ALogger.getLogger(APasswordDialog.class); - // input fields - protected JTextField userField; - protected JPasswordField passwordField; - // authentication object containing username and password - protected PasswordAuthentication pwAuth; - - /** - * Create APasswordDialog belonging to given frame - * @param frame owner of dialogue - */ - protected APasswordDialog(Frame frame, String prompt) { - // There is almost certainly a better way to do the layout... - super(frame,"Password Dialogue",true); - Container contentPane = getContentPane(); - - // Create panels to place in content pane - JPanel mainPanel = new JPanel(); - JPanel labelPanel = new JPanel(); - JPanel inputPanel = new JPanel(); - JPanel buttonPanel = new JPanel(); - - // Create components (labels, inputs) to put in panels - JLabel label = new JLabel(prompt); - JLabel userLabel = new JLabel("User name"); - JLabel passwordLabel = new JLabel("Password"); - userField = new JTextField(15); - passwordField = new JPasswordField(15); - JButton okButton = new JButton("OK"); - JButton cancelButton = new JButton("Cancel"); - - // Associate labels with corresponding input fields - userLabel.setLabelFor(userField); - passwordLabel.setLabelFor(passwordField); - - // Specify layout of dialogue - contentPane.setLayout(new BoxLayout(contentPane,BoxLayout.Y_AXIS)); - mainPanel.setLayout(new BoxLayout(mainPanel,BoxLayout.X_AXIS)); - labelPanel.setLayout(new BoxLayout(labelPanel,BoxLayout.Y_AXIS)); - inputPanel.setLayout(new BoxLayout(inputPanel,BoxLayout.Y_AXIS)); - buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS)); - - // Put everything together: components in panels... - contentPane.add(label); - contentPane.add(mainPanel); - contentPane.add(buttonPanel); - - mainPanel.add(labelPanel); - mainPanel.add(inputPanel); - - labelPanel.add(userLabel); - labelPanel.add(passwordLabel); - - inputPanel.add(userField); - inputPanel.add(passwordField); - - buttonPanel.add(okButton); - buttonPanel.add(cancelButton); - - // click OK: construct authentication object from given name/password - okButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) { - String userName = userField.getText(); - char[] password = passwordField.getPassword(); - pwAuth = new PasswordAuthentication(userName,password); - dispose(); - } - } - ); - - // click cancel: dispose of dialogue with no authentication object - cancelButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) { - pwAuth = null; - dispose(); - } - } - ); - pack(); - - // set position on screen (otherwise defaults to top left) - int guiWidth = frame.getWidth(); - int guiHeight = frame.getHeight(); - int guiX = frame.getX(); - int dialogWidth = (int) this.getPreferredSize().getWidth(); - int dialogHeight = (int) this.getPreferredSize().getHeight(); - int screenWidth = Math.round((float) Toolkit.getDefaultToolkit().getScreenSize().getWidth()); - if(guiX+guiWidth+(dialogWidth-guiWidth)/2>screenWidth) - this.setLocation(Math.max(0, screenWidth - dialogWidth), Math.max(0, (guiHeight - dialogHeight) / 3)); - else - this.setLocation(Math.max(0, guiX + (guiWidth - dialogWidth) / 2), Math.max(0, (guiHeight - dialogHeight) / 3)); - - } - - /** - * Create APasswordDialog belonging to given frame, with default prompt - * @param frame owner of dialogue - */ - protected APasswordDialog(Frame frame) { - this(frame,"Authentication required"); - } - - /** Gets authentication object - * - * @return PasswordAuthentication object required by Authenticator - */ - protected PasswordAuthentication getPasswordAuthentication() { - return pwAuth; - } - - /** - * Displays username/password dialogue and returns authentication object. - * @param frame owner of dialogue, e.g. Atlantis GUI - * @prompt prompt to show user - * @return authentication object constructed from entered username/password, - * or null if dialogue cancelled - */ - public static PasswordAuthentication showDialog(Frame frame, String prompt) { - APasswordDialog d = new APasswordDialog(frame,prompt); - d.setVisible(true); - return d.getPasswordAuthentication(); - } - - /** - * Displays username/password dialogue with default prompt and returns authentication object. - * @param frame owner of dialogue, e.g. Atlantis GUI - * @return authentication object constructed from entered username/password, - * or null if dialogue cancelled - */ - public static PasswordAuthentication showDialog(Frame frame) { - APasswordDialog d = new APasswordDialog(frame); - d.setVisible(true); - return d.getPasswordAuthentication(); - } - - /** - * Constructs and returns Authenticator object as required by - * java.net.Authenticator.setDefault() - * @param f owner of dialogue, e.g. Atlantis GUI - * @return Authenticator that will create APasswordDialog when called - */ - public static Authenticator getAuthenticator(Frame f) { - return new PasswordAuthenticator(f); - } - - /** - * Private nested Authenticator subclass to be instantiated and returned - * by getAuthenticator(). - * @author waugh - */ - private static class PasswordAuthenticator extends Authenticator { - protected Frame f; - public PasswordAuthenticator(Frame frame) {f=frame;} - protected PasswordAuthentication getPasswordAuthentication() { - logger.info("Authentication required: requesting host:"+getRequestingHost()); - logger.info("Authentication required: requesting site:"+getRequestingSite()); - logger.info("Authentication required: requesting protocol:"+getRequestingProtocol()); - logger.info("Authentication required: requesting prompt:"+getRequestingPrompt()); - logger.info("Authentication required: requesting scheme:"+getRequestingScheme()); - // logger.info("Authentication required: requesting URL:"+getRequestingURL()); - String prompt = "Authentication required by host "+getRequestingHost()+ - " with prompt \""+getRequestingPrompt()+"\""; - return APasswordDialog.showDialog(f,prompt); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/APointerPositionWindow.java b/graphics/AtlantisJava/src/atlantis/gui/APointerPositionWindow.java deleted file mode 100755 index dffdc697ca1db5048ed45a270f80af17f885a28c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/APointerPositionWindow.java +++ /dev/null @@ -1,175 +0,0 @@ -package atlantis.gui; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; - -import javax.swing.JFrame; -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTextPane; - -import atlantis.globals.AGlobals; -import atlantis.graphics.AIcon; - -import java.awt.BorderLayout; -import java.awt.event.MouseListener; -import javax.swing.JLabel; - - -/** - * The pointer postion window apears when selected in the preferences menu or - * by using o+right click. - * - * @author Sebastian Boeser - */ -public class APointerPositionWindow extends JFrame - implements WindowListener, ActionListener, MouseListener - -{ - private static JLabel infoLabel; - private static JPopupMenu popupMenu; - private static JMenuItem menuItemClearTextPane; - private static JTextPane textPane; - private static JScrollPane scrollPane; - private static APointerPositionWindow instance = null; - private static final AGlobals globals = AGlobals.instance(); - - public static APointerPositionWindow getInstance() - { - if (instance == null) - instance = new APointerPositionWindow(); - return instance; - } - - private APointerPositionWindow() - { - this.setTitle("Your Pointer Position"); - AIcon.setIconImage(this); - - //delete window if closed - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - addWindowListener(this); - - //Tell user how to use this - infoLabel = new JLabel(); - infoLabel.setText("To output your pointer position use: O + Right click\n"); - - // popup menu at text pane (info output at bottom half of window) - popupMenu = new JPopupMenu(); - menuItemClearTextPane = new JMenuItem("Erase output"); - menuItemClearTextPane.addActionListener(this); - popupMenu.add(menuItemClearTextPane); - - // Text panel to show coordinates - textPane = new JTextPane(); - textPane.setEditable(false); - textPane.setBackground(Color.white); - textPane.setText("Coordinates will be displayed here\n"); - textPane.addMouseListener(this); - - // Embedd in a scroll frame - scrollPane = new JScrollPane(textPane); - scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); - - add(infoLabel,BorderLayout.NORTH); - add(scrollPane,BorderLayout.CENTER); - - // set the initial location - Frame gui = globals.getGuiFrame(); - int guiWidth = gui.getWidth(); - int guiHeight = gui.getHeight(); - int guiX = gui.getX(); - int dialogWidth = (int) this.getPreferredSize().getWidth(); - int dialogHeight = (int) this.getPreferredSize().getHeight(); - int screenWidth = Math.round((float) Toolkit.getDefaultToolkit() - .getScreenSize().getWidth()); - if (guiX + guiWidth + (dialogWidth - guiWidth) / 2 > screenWidth) - this.setLocation(Math.max(0, screenWidth - dialogWidth), Math.max( - 0, (guiHeight - dialogHeight) / 3)); - else - this.setLocation(Math.max(0, guiX + (guiWidth - dialogWidth) / 2), - Math.max(0, (guiHeight - dialogHeight) / 3)); - //Layout the window - pack(); - } - - public static void append(String s) - { - String text = textPane.getText(); - int size = text.length(); - //just as a precaution incase too many coordinates output - if(size > 51200) // 50kB - { - textPane.setText(""); // clear all - text = text.substring(size / 2, size - 1) + "\n"; - } - s = text + "\n" + s; - textPane.setText(s); - } - - void clearTextPane(ActionEvent e) - { - textPane.setText("Coordinates will be displayed here\n"); - } - - public void dispose() - { - instance = null; - super.dispose(); - } - - // clear info output if the popup menu item was pressed - public void actionPerformed(ActionEvent e) - { - clearTextPane(e); - } - - - public void windowClosed(WindowEvent e) - { - // when this window is disposed, the menu item is switched off - APreferencesControl.setPosMenuItem(false); - } - - public void mousePressed(MouseEvent evt) - { - showPopupMenu(evt); - } - - public void mouseReleased(MouseEvent evt) - { - showPopupMenu(evt); - } - - private void showPopupMenu(MouseEvent evt) - { - // decides whether right 'trigger' action was performed to show - // the popup menu (on the text pane - info output in GUI) - if (evt.isPopupTrigger()) - { - popupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); - } - } - - // Empty implementations of unused windows events - public void windowOpened(WindowEvent e){} - public void windowClosing(WindowEvent e){} - public void windowIconified(WindowEvent e){} - public void windowDeiconified(WindowEvent e){} - public void windowActivated(WindowEvent e){} - public void windowDeactivated(WindowEvent e){} - - // Empty implementation of unused mouse events - public void mouseClicked(MouseEvent e) {} - public void mouseEntered(MouseEvent e) {} - public void mouseExited(MouseEvent e) {} - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/APopupHelper.java b/graphics/AtlantisJava/src/atlantis/gui/APopupHelper.java deleted file mode 100644 index ef1dd510ce04ca7977fec43311a3cc0fdd4a4cd4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/APopupHelper.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * APopupHelper.java - * - * Created on 24 October 2007, 09:12 - * - * @author Adam Davison - */ - -package atlantis.gui; - -import javax.swing.JPopupMenu; -import javax.swing.JMenuItem; -import java.awt.Point; -import java.awt.Component; - -/** - * - * @author Adam Davison - */ - -public class APopupHelper { - - public static void showPopupMenu(Point p, Component window, JMenuItem[] items) { - JPopupMenu pop = getPopupMenu(items); - - if (pop == null) { - return; - } - - pop.show(window, (int)p.getX(), (int)p.getY()); - } - - public static JPopupMenu getPopupMenu(JMenuItem[] items) { - - if (items == null) { - return null; - } - - JPopupMenu jp = new JPopupMenu(); - - for (int i = 0; i < items.length; i++) { - jp.add(items[i]); - } - - return jp; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/APreferencesControl.java b/graphics/AtlantisJava/src/atlantis/gui/APreferencesControl.java deleted file mode 100755 index f329c437e38348a9f58060eab5629384d2a143f4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/APreferencesControl.java +++ /dev/null @@ -1,429 +0,0 @@ -package atlantis.gui; - -import java.io.File; -import java.awt.Frame; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JMenu; -import javax.swing.JOptionPane; -import javax.swing.JSeparator; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.ALegendWindow; -import atlantis.globals.AGlobals; -import atlantis.graphics.colormap.AColorMap; -import atlantis.parameters.APar; -import atlantis.utils.AAtlantisException; -import atlantis.utils.ALogger; - - -/** - * Preferences menu item - * - * @author Gary Taylor, Zdenek Maxa - */ -public class APreferencesControl extends JMenu implements ActionListener, ItemListener -{ - private static ALogger logger = ALogger.getLogger(APreferencesControl.class); - - private static AGlobals globals = AGlobals.instance(); - - protected static APar parameterStore = APar.instance(); - - private static final String LAYOUT = "Change Canvas Layout"; - private static final String SELECT_COLOR_MAP = "Select Color Map"; - private static final String COLOR_MAP_EDITOR = "Color Map Editor"; - private static final String READ_COLOR_MAP = "Read Color Map"; - private static final String WRITE_COLOR_MAP = "Save Current Color Map"; - private static final String WRITE_CONFIG = "Save Current Configuration"; - private static final String POINTER_POSITION = "Show Pointer Position Window"; - private static final String LEGEND = "Show Legend Window"; - private static final String CANVAS_TITLE = "Show Canvas Title"; - private static final String WINDOW_TITLES = "Show Window Titles"; - private static final String FISHEYE_LOGO = "Show Fisheye Indicator"; - private static final String HIDE_SCALES = "Hide Scales"; - private static final String ATLAS_LOGO = "Show ATLAS logo on saved images"; - private static final String ANTI_ALIASING = "Use Anti-Aliasing"; - private static final String OPEN_GL = "Use OpenGL"; - - private static JCheckBoxMenuItem posMenuItem; - private static JCheckBoxMenuItem legMenuItem; - private static JCheckBoxMenuItem canvasTitleMenuItem; - private static JCheckBoxMenuItem windowTitleMenuItem; - private static JCheckBoxMenuItem fisheyeIndicatorMenuItem; - private static JCheckBoxMenuItem hideScalesMenuItem; - private static JCheckBoxMenuItem atlasLogoMenuItem; - private static JCheckBoxMenuItem aliasMenuItem; - private static JCheckBoxMenuItem openglMenuItem; - - // ---------------------------------------------------------------------- - - public APreferencesControl() - { - super("Preferences"); - this.setToolTipText("Preferences"); - - add(SELECT_COLOR_MAP).addActionListener(this); - add(COLOR_MAP_EDITOR).addActionListener(this); - add(READ_COLOR_MAP).addActionListener(this); - add(WRITE_COLOR_MAP).addActionListener(this); - - add(new JSeparator()); - - add(LAYOUT).addActionListener(this); - add(WRITE_CONFIG).addActionListener(this); - - add(new JSeparator()); - - posMenuItem = new JCheckBoxMenuItem(POINTER_POSITION, false); - posMenuItem.addItemListener(this); - add(posMenuItem); - - legMenuItem = new JCheckBoxMenuItem(LEGEND, false); - legMenuItem.addItemListener(this); - add(legMenuItem); - - add(new JSeparator()); - - canvasTitleMenuItem = new JCheckBoxMenuItem(CANVAS_TITLE, parameterStore.get("Prefs", "CanvasTitle").getStatus()); - canvasTitleMenuItem.addItemListener(this); - add(canvasTitleMenuItem); - - windowTitleMenuItem = new JCheckBoxMenuItem(WINDOW_TITLES, parameterStore.get("Prefs", "WindowTitle").getStatus()); - windowTitleMenuItem.addItemListener(this); - add(windowTitleMenuItem); - - fisheyeIndicatorMenuItem = new JCheckBoxMenuItem(FISHEYE_LOGO, parameterStore.get("Prefs", "FisheyeIndicator").getStatus()); - fisheyeIndicatorMenuItem.addItemListener(this); - add(fisheyeIndicatorMenuItem); - - hideScalesMenuItem = new JCheckBoxMenuItem(HIDE_SCALES, parameterStore.get("Prefs", "HideScales").getStatus()); - hideScalesMenuItem.addItemListener(this); - add(hideScalesMenuItem); - - atlasLogoMenuItem = new JCheckBoxMenuItem(ATLAS_LOGO, parameterStore.get("Prefs", "AtlasLogo").getStatus()); - atlasLogoMenuItem.addItemListener(this); - add(atlasLogoMenuItem); - - - add(new JSeparator()); - - aliasMenuItem = new JCheckBoxMenuItem(ANTI_ALIASING, parameterStore.get("Prefs", "AntiAlias").getStatus()); - aliasMenuItem.addItemListener(this); - add(aliasMenuItem); - - openglMenuItem = new JCheckBoxMenuItem(OPEN_GL, parameterStore.get("Prefs", "OpenGL").getStatus()); - openglMenuItem.addItemListener(this); - - if (globals.getUseOpenGL()) { - add(new JSeparator()); - add(new AOpenGLControl()); - } - } // APreferencesControl() ---------------------------------------------- - - - - public void itemStateChanged(ItemEvent e) - { - if(((JCheckBoxMenuItem)e.getSource()).getText().equals(CANVAS_TITLE)) - { - if(e.getStateChange() == ItemEvent.SELECTED) - { - parameterStore.get("Prefs", "CanvasTitle").setStatus(true); - ACanvas.getCanvas().getTitleBar().setVisible(true); - } - else - { - parameterStore.get("Prefs", "CanvasTitle").setStatus(false); - ACanvas.getCanvas().getTitleBar().setVisible(false); - } - ACanvas.getCanvas().validate(); - ACanvas.getCanvas().repaint(); - } - else if(((JCheckBoxMenuItem)e.getSource()).getText().equals(POINTER_POSITION)) - { - if(e.getStateChange() == ItemEvent.SELECTED) - APointerPositionWindow.getInstance().setVisible(true); - else - APointerPositionWindow.getInstance().dispose(); - } - else if(((JCheckBoxMenuItem)e.getSource()).getText().equals(LEGEND)) - { - if(e.getStateChange() == ItemEvent.SELECTED) - { - ALegendWindow legendWindow = ALegendWindow.getInstance(); - // Want to deselect legend menu item if legend window is closed - legendWindow.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - setLegMenuItem(false); - } - }); - - legendWindow.setVisible(true); - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - } - else - ALegendWindow.getInstance().dispose(); - } - else if(((JCheckBoxMenuItem)e.getSource()).getText().equals(WINDOW_TITLES)) - { - if(e.getStateChange() == ItemEvent.SELECTED) - parameterStore.get("Prefs", "WindowTitle").setStatus(true); - else - parameterStore.get("Prefs", "WindowTitle").setStatus(false); - ACanvas.getCanvas().repaintAllFromScratch(); - } - else if(((JCheckBoxMenuItem)e.getSource()).getText().equals(FISHEYE_LOGO)) - { - if(e.getStateChange() == ItemEvent.SELECTED) - parameterStore.get("Prefs", "FisheyeIndicator").setStatus(true); - else - parameterStore.get("Prefs", "FisheyeIndicator").setStatus(false); - ACanvas.getCanvas().repaintAllFromScratch(); - } - else if(((JCheckBoxMenuItem)e.getSource()).getText().equals(HIDE_SCALES)) - { - if(e.getStateChange() == ItemEvent.SELECTED) - parameterStore.get("Prefs", "HideScales").setStatus(true); - else - parameterStore.get("Prefs", "HideScales").setStatus(false); - - ACanvas.getCanvas().repaintAllFromScratch(); - } - else if(((JCheckBoxMenuItem)e.getSource()).getText().equals(ATLAS_LOGO)) - { - if(e.getStateChange() == ItemEvent.SELECTED) - parameterStore.get("Prefs", "AtlasLogo").setStatus(true); - else - parameterStore.get("Prefs", "AtlasLogo").setStatus(false); - } - else if(((JCheckBoxMenuItem)e.getSource()).getText().equals(ANTI_ALIASING)) - { - if(e.getStateChange() == ItemEvent.SELECTED) - parameterStore.get("Prefs", "AntiAlias").setStatus(true); - else - parameterStore.get("Prefs", "AntiAlias").setStatus(false); - ACanvas.getCanvas().repaintAllFromScratch(); - } - else if(((JCheckBoxMenuItem)e.getSource()).getText().equals(OPEN_GL)) - { - if(e.getStateChange() == ItemEvent.SELECTED) - parameterStore.get("Prefs", "OpenGL").setStatus(true); - else - parameterStore.get("Prefs", "OpenGL").setStatus(false); - System.out.println("No effect at present"); - } - } // itemStateChanged() ------------------------------------------------- - - - - public void actionPerformed(ActionEvent e) - { - String action = e.getActionCommand(); - - if(LAYOUT.equals(action)) - { - new ALayoutDialog(); - } - else if(SELECT_COLOR_MAP.equals(action)) - { - new AColorMapDialog(); - } - else if(COLOR_MAP_EDITOR.equals(action)) - { - AColorMapEditor.getInstance().setVisible(true); - } - else if(READ_COLOR_MAP.equals(action)) - { - new AReadColorMapChooser().showMyDialog(); - } - else if(WRITE_COLOR_MAP.equals(action)) - { - writeColorMap(); - } - else if(WRITE_CONFIG.equals(action)) - { - writeConfiguration(); - } - - } // actionPerformed() -------------------------------------------------- - - - - private static void writeColorMap() - { - String fileName = ".Atlantis-colormap.xml"; - String title = "Saving current color map"; - Frame gui = globals.getGuiFrame(); - - logger.debug("Going to write customised color map file ..."); - String data = AColorMap.getColorMapXML(); - - // color map data should be ready and valid - store it into file - try - { - AGUIUtilities.chooseFileAndWrite(gui, System.getProperty("user.home"), - fileName, data.getBytes(), title, "xml"); - logger.debug("Current color map written (or cancelled by user)."); - } - catch(AAtlantisException ex) - { - JOptionPane.showMessageDialog(gui, ex.getMessage(), - title, JOptionPane.ERROR_MESSAGE); - logger.debug(ex.getMessage(), ex); - } - - } // writeColorMap() ---------------------------------------------------- - - - - private static void writeConfiguration() - { - String FILE_SEPAR = System.getProperty("file.separator"); - String fileName = globals.getUserConfigFile(); - String title = "Saving current configuration"; - String fileNameFull = System.getProperty("user.home") + FILE_SEPAR + fileName; - String sourceFileNameFull = ""; - Frame gui = globals.getGuiFrame(); - - logger.debug("Writing customised configuration ..."); - - // get currently used configuration file and data from it - File user = new File(fileNameFull); - if(user.canRead()) - { - sourceFileNameFull = fileNameFull; - logger.debug("User has already got " + fileNameFull + - " this will be used as source."); - } - else - { - sourceFileNameFull = globals.getHomeDirectory() + - "configuration" + FILE_SEPAR + - "config.xml"; - logger.debug(sourceFileNameFull + " will be used as source."); - - } - - String data = AConfigWriter.getConfiguration(sourceFileNameFull); - if(data == null) - { - String msg = "Error when reading source configuration from file\n" + - sourceFileNameFull; - logger.error(msg); - JOptionPane.showMessageDialog(gui, msg, title, - JOptionPane.INFORMATION_MESSAGE); - return; - } - - // configuration data should be ready and valid - store it into file - try - { - logger.debug("Current customised configuration made, going to save it ..."); - AGUIUtilities.chooseFileAndWrite(gui, System.getProperty("user.home"), - fileName, data.getBytes(), title, "xml"); - logger.debug("Saving customised configuration successful (or cancelled by user)."); - } - catch(AAtlantisException ex) - { - String m = ex.getMessage(); - JOptionPane.showMessageDialog(gui, m, title, - JOptionPane.ERROR_MESSAGE); - logger.error(m); - logger.debug(m, ex); - } - - } // writeConfiguration() ----------------------------------------------- - - public static void setPosMenuItem(boolean selected) - { - posMenuItem.setSelected(selected); - } - - public static void setLegMenuItem(boolean selected) - { - legMenuItem.setSelected(selected); - } - - public static void setWindowTitleMenuItem(boolean selected) - { - windowTitleMenuItem.setSelected(selected); - parameterStore.get("Prefs", "WindowTitle").setStatus(selected); - } - - public static void setFisheyeIndicatorMenuItem(boolean selected) - { - fisheyeIndicatorMenuItem.setSelected(selected); - parameterStore.get("Prefs", "FisheyeIndicator").setStatus(selected); - } - - public static void setHideScalesMenuItem(boolean selected) - { - hideScalesMenuItem.setSelected(selected); - parameterStore.get("Prefs", "HideScales").setStatus(selected); - } - - public static void setAtlasLogoMenuItem(boolean selected) - { - atlasLogoMenuItem.setSelected(selected); - parameterStore.get("Prefs", "AtlasLogo").setStatus(selected); - } - - public static void setAliasMenuItem(boolean selected) - { - if (!AGlobals.isAtlantisHeadless()) { - aliasMenuItem.setSelected(selected); - } - parameterStore.get("Prefs", "AntiAlias").setStatus(selected); - } - - public static boolean getWindowTitleMenuItem() - { - if(windowTitleMenuItem!=null) - return windowTitleMenuItem.isSelected(); - else - return parameterStore.get("Prefs", "WindowTitle").getStatus(); - } - - public static boolean getFisheyeIndicatorMenuItem() - { - if(fisheyeIndicatorMenuItem!=null) - return fisheyeIndicatorMenuItem.isSelected(); - else - return parameterStore.get("Prefs", "FisheyeIndicator").getStatus(); - } - - public static boolean getHideScalesMenuItem() - { - if(hideScalesMenuItem!=null) - return hideScalesMenuItem.isSelected(); - else - return parameterStore.get("Prefs", "HideScales").getStatus(); - } - - - public static boolean getAtlasLogoMenuItem() - { - if(atlasLogoMenuItem!=null) - return atlasLogoMenuItem.isSelected(); - else - return parameterStore.get("Prefs", "AtlasLogo").getStatus(); - } - - public static boolean getAliasMenuItem() - { - return parameterStore.get("Prefs", "AntiAlias").getStatus(); - /*if(aliasMenuItem!=null) - return aliasMenuItem.isSelected(); - else - return false;*/ - } - -} // class APreferencesControl ============================================== diff --git a/graphics/AtlantisJava/src/atlantis/gui/AReadColorMapChooser.java b/graphics/AtlantisJava/src/atlantis/gui/AReadColorMapChooser.java deleted file mode 100755 index 303935d5c1e855ccb375a59322fae4fae4707248..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AReadColorMapChooser.java +++ /dev/null @@ -1,35 +0,0 @@ -package atlantis.gui; - -import java.io.File; - -import atlantis.canvas.ACanvas; -import atlantis.globals.AGlobals; -import atlantis.graphics.colormap.AColorMap; - -/** - * The dialog which appears when a user asks to read a new colormap - */ -public class AReadColorMapChooser extends AXMLFileChooser -{ - private static final String FILE_SEPAR = System.getProperty("file.separator"); - private static final AGlobals globals = AGlobals.instance(); - - public AReadColorMapChooser() - { - super(System.getProperty("user.dir") + FILE_SEPAR - + "configuration" + FILE_SEPAR + "colormap.xml", globals.getGuiFrame()); - } - - public boolean processSelectedFile(File file) - { - if (file.canRead()) - { - AColorMap.readColorMap(file.getPath()); - AColorMapEditor.getInstance().updateColors(); - AGUI.getGUI().repaintTable(); - ACanvas.getCanvas().repaintAllFromScratch(); - return true; - } - return false; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AReadFileChooser.java b/graphics/AtlantisJava/src/atlantis/gui/AReadFileChooser.java deleted file mode 100755 index 48ff7472657671eac3b2ec9d0cb8573897ebb3b0..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AReadFileChooser.java +++ /dev/null @@ -1,103 +0,0 @@ -package atlantis.gui; - -import java.io.File; - -import javax.swing.JFileChooser; -import javax.swing.filechooser.FileFilter; -import javax.swing.JCheckBox; -import javax.swing.JPanel; - -import java.awt.Component; -import java.awt.BorderLayout; - -import atlantis.config.ADefaultValues; - -/** - * This dialog appears when a user asks to read events from a file - * @author sboeser - */ -public class AReadFileChooser extends JFileChooser { - //Check box indicating to set the new default location - private JCheckBox defaultLoc = null; - - /** - * Constructor with a default path - * @param path the default path - */ - public AReadFileChooser(String path) { - - //Create a file chooser pointing to path - //Use users default dir if null - super(path); - - //Create a new panel with the checkbox - JPanel p = new JPanel(); - defaultLoc = new JCheckBox("default location"); - p.setLayout(new BorderLayout()); - p.add(defaultLoc, BorderLayout.SOUTH); - setAccessory(p); - - - setFileFilter(new XMLFilter()); - } - - /** - * Show the dialog waiting for user input - */ - @Override - public int showOpenDialog(Component parent) { - - //Get the return state - int state = super.showOpenDialog(parent); - - //Store the default location if user pressed ok - if (state == APPROVE_OPTION) { - //Only if checkbox is ticked - if (defaultLoc.isSelected()) { - // save last visited location - ADefaultValues.set("LastEventFilesSourceDir", - getSelectedFile().getParent() + System.getProperty("file.separator")); - } - } - - //return the result state - return state; - } - - /** - * A filter for XML files - */ - private static class XMLFilter extends FileFilter { - - /** - * Acceptance algorithm for xml files and directories - * @param file the file to test - * @return true if accepted - */ - public boolean accept(File file) { - - //accept all directories - if (file.isDirectory()) return true; - - //check the file ending - String name = file.getName().toLowerCase(); - - if (name.endsWith(".xml")) return true; - if (name.endsWith(".zip")) return true; - if (name.endsWith(".gzip")) return true; - if (name.endsWith(".gz")) return true; - - //None of the requested criteria matched - return false; - } - - /** - * Gives a description of the files that are accepted by this filter - * @return string with list of file endings - */ - public String getDescription() { - return ".xml, .zip, .gzip, .gz"; - } - } -} - diff --git a/graphics/AtlantisJava/src/atlantis/gui/AReadGeometryChooser.java b/graphics/AtlantisJava/src/atlantis/gui/AReadGeometryChooser.java deleted file mode 100755 index ae77061aeeafb0b7a38bd7a7fdde90d4ba6f04a9..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AReadGeometryChooser.java +++ /dev/null @@ -1,79 +0,0 @@ -package atlantis.gui; - -import atlantis.geometry.AEndcapTRTDetector; - -import java.awt.Frame; -import java.io.File; -import javax.swing.JOptionPane; - -import atlantis.canvas.ACanvas; -import atlantis.data.ACalorimeterData; -import atlantis.geometry.AAtlasDetector; -import atlantis.geometry.ABarrelSiliconDetector; -import atlantis.geometry.ABarrelTRTDetector; -import atlantis.geometry.ACalorimeterDetector; -import atlantis.geometry.AEndcapSiliconDetector; -import atlantis.globals.AGlobals; - - -/** - * The dialog which appears when a user asks to read in geometry XML file - */ -public class AReadGeometryChooser extends AXMLGeometryChooser { - - private static final AGlobals globals = AGlobals.instance(); - - public AReadGeometryChooser() { - super(); - } - - public void fileChosen(int state) { - Frame gui = globals.getGuiFrame(); - do { - if(state==APPROVE_OPTION) { - File file=getSelectedFile(); - - if(file!=null) - if(file.canRead()) { - processSelectedFile(file); - break; - } else { - JOptionPane.showMessageDialog(gui, - "Unable to open " + file, "IO Error", JOptionPane.ERROR_MESSAGE); - } - } else - break; - state=showOpenDialog(gui); - } while(true); - } - - public boolean processSelectedFile(File file) - { - if(file.canRead()) - { - // ACalorimterDetector keeps a list of its instances, clear this list. - ACalorimeterDetector.clear(); - ABarrelSiliconDetector.clear(); - AEndcapSiliconDetector.clear(); - ABarrelTRTDetector.clear(); - AEndcapTRTDetector.clear(); - - String muonname = file.getParent() + System.getProperty("file.separator") + - file.getName().substring(0, 1) + "Muon" + - file.getName().substring(1); - File mufile = new File(muonname); - if(mufile.canRead()) - { - AAtlasDetector.setDetector(new AAtlasDetector(file.getAbsolutePath(), muonname)); - } - else - { - AAtlasDetector.setDetector(new AAtlasDetector(file.getAbsolutePath())); - } - ACalorimeterData.remakeHitToGeometryMapping(); - ACanvas.getCanvas().repaintAllFromScratch(); - return true; - } - return false; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ASaveCanvasDialog.java b/graphics/AtlantisJava/src/atlantis/gui/ASaveCanvasDialog.java deleted file mode 100755 index 2f0d67a3982013b18bf296916d1db4911dfe9cd4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ASaveCanvasDialog.java +++ /dev/null @@ -1,477 +0,0 @@ -package atlantis.gui; - -import java.awt.Frame; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.image.RasterFormatException; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStream; - -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.filechooser.FileFilter; - -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.canvas.ACanvas; -import atlantis.utils.AAtlantisException; -import atlantis.utils.AUtilities; -import atlantis.config.ADefaultValues; -import atlantis.globals.AGlobals; -import atlantis.graphics.encoders.AImageEncoder; -import atlantis.utils.ALogger; - - -/** - * Dialog window for saving a picture of the current canvas. This dialog allows - * the user to pick the resolution and file type. - * - * @author Eric Jansen - * @author Sebastian Boeser - */ -public class ASaveCanvasDialog extends JFileChooser - implements PropertyChangeListener { - - private final ALogger logger = ALogger.getLogger(ASaveCanvasDialog.class); - private static AEventManager eventManager = AEventManager.instance(); - private static final AGlobals globals = AGlobals.instance(); - - // GUI component that contains the resolution selection panel. - private AResolutionChooser resolutionChooser; - - // Possible image widths shown to user. Heights are fixed by layout restrictions. - private final int[] IMAGE_WIDTHS = {800, 1024, 2400, 5000};//{512, 800, 1024, 2400}; - - // Default selected image width. Also the (fixed) width of the EPS images. - private final int DEFAULT_IMAGE_WIDTH = 1; - - // String holding the default file name, need to be reset after change of file type. - private String defaultFileName = null; - - // Private image encoder instance - private final AImageEncoder imageEncoder = new AImageEncoder(); - - - /** - * Constructor creating the dialog - */ - public ASaveCanvasDialog() - { - //Initialize the file chooser dialog - super(ADefaultValues.get("LastCanvasPlotSaveDir")); - setDialogTitle("Save Canvas"); - - //Add file filters - addChoosableFileFilter(new AFileFilter("eps", "Encapsulated Postscript (*.eps)")); - addChoosableFileFilter(new AFileFilter("png", "Portable Network Graphics (*.png)")); - addChoosableFileFilter(new AFileFilter("svg", "Scalable Vector Graphics (*.svg)")); - - //Set default values - setAcceptAllFileFilterUsed(false); - // In OpenJDK JRE filter is set to null by setAcceptAllFileFilterUsed, so - // have to set it to something: - setFileFilter(getChoosableFileFilters()[1]); - - //Add the resoluton chooser - resolutionChooser = new AResolutionChooser(); - setAccessory(resolutionChooser); - addPropertyChangeListener(this); - - //Set a default file name and extension - defaultFileName = makeEventFileName() + "-" + AUtilities.getDateTimeString(); - String ext = ((AFileFilter) getFileFilter()).getExtension(); - setSelectedFile(new File(defaultFileName + "." + ext)); - } - - /** - * Pops up the "Save Canvas" dialog. - */ - public void showDialog(){ - //Show dialog with GUI as parent - showSaveDialog(globals.getGuiFrame()); - } - - - /** - * @return the defualt file name - */ - public String getDefaultFileName() - { - return defaultFileName; - } - - /** - * Get the currently selected image width. - * @return selected image width - */ - public int getImageWidth() - { - return resolutionChooser.getImageWidth(); - } - - - - /** - * Gets the image height on this button. - * @return image height - */ - public int getImageHeight() - { - return resolutionChooser.getImageHeight(); - } - - - - /** - * Called when the user has selected a file and pushes the save button. - * This function will only - * approve the selection when the actual saving was successful. - */ - @Override - public void approveSelection() - { - Frame gui = globals.getGuiFrame(); - File file = new File(getSelectedFile().getAbsolutePath()); - - // If the file exists and the user does not want to overwrite it, cancel the save operation. - // The dialog is still on screen and the user can pick another file. - if (file.exists() && JOptionPane.showConfirmDialog(gui, "File exists, overwrite?", - "File exists", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) - return; - - // All exceptions are handled equally: the user is sent back to the save canvas dialog. - try { - String type = ((AFileFilter)getFileFilter()).getExtension(); - // Since EPS files can be pretty big, they're saved directly - if (type.equals("eps")){ - // Since vector images are scalable, the image size only determines the relative size of - // the data objects. To make the generated EPS independent of the canvas size, we always - // rescale the image to the default size. - int width = IMAGE_WIDTHS[DEFAULT_IMAGE_WIDTH]; - int height = ACanvas.getCanvas().getRespectiveHeight(width); - imageEncoder.saveEPS(width,height,file); - } else if (type.equals("png")) { - // Generate the canvas image in memory - byte[] data; - int width = resolutionChooser.getImageWidth(); - int height = resolutionChooser.getImageHeight(); - data = imageEncoder.getPNGData(width,height); - // And finally write the image to the selected file. - OutputStream stream = new BufferedOutputStream(new FileOutputStream(file.getAbsolutePath())); - stream.write(data); - stream.close(); - } else if (type.equals("svg")){ - // Since vector images are scalable, the image size only determines the relative size of - // the data objects. To make the generated EPS independent of the canvas size, we always - // rescale the image to the default size. - int width = IMAGE_WIDTHS[DEFAULT_IMAGE_WIDTH]; - int height = ACanvas.getCanvas().getRespectiveHeight(width); - imageEncoder.saveSVG(width,height,file); - } else{ - //Throw an exception if none of the above - throw new AAtlantisException("Unknown image type: '" + type + "'"); - } - } - catch(RasterFormatException e) - { - JOptionPane.showMessageDialog(gui, - "The chosen resolution for canvas is too high, try a lower option!", - "Error saving canvas", JOptionPane.INFORMATION_MESSAGE); - AGUI.getGUI().restoreDefaults(); - this.cancelSelection(); - } catch(Exception e) - { - // Show a dialog with the error message. - JOptionPane.showMessageDialog(AGUI.getGUI(), e.getMessage(), - "Error saving canvas", JOptionPane.ERROR_MESSAGE); - - // The selection is not approved, the user has to select another file or type. - return; - } - - // This approves the selection and ends the saving processs. - super.approveSelection(); - ADefaultValues.set("LastCanvasPlotSaveDir", file.getParent() + - System.getProperty("file.separator")); - - } - - - - /** - * Property change listener for the JFileChooser - * @param e property change event sent by JFileChooser - */ - public void propertyChange(PropertyChangeEvent e) - { - if (e.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) - { - String oldExt = ((AFileFilter)e.getOldValue()).getExtension(); - String newExt = ((AFileFilter)e.getNewValue()).getExtension(); - - if ((oldExt.equals("eps") || oldExt.equals("svg")) && !(newExt.equals("eps") || newExt.equals("svg"))) - { - for (int i=0; i<resolutionChooser.getComponentCount(); i++) - { - resolutionChooser.getComponent(i).setEnabled(true); - } - } - else if (!(oldExt.equals("eps") || oldExt.equals("svg")) && ((newExt.equals("eps")) || newExt.equals("svg"))) - { - for (int i=0; i<resolutionChooser.getComponentCount(); i++) - resolutionChooser.getComponent(i).setEnabled(false); - } - - // The behaviour of the JFileChooser is somewhat strange. Regardless of what the user has entered, - // the input text field will be emptied when the user selects another file type. It is impossible - // to retrieve the text that was in this field, so we just reset the default file name. - if (getSelectedFile() == null) - { - // Reset our default with the new extension - setSelectedFile(new File(defaultFileName + "." + newExt)); - updateUI(); - rescanCurrentDirectory(); - } - } - } - - - - /** - * Generates a file name based on the current event name and the visible projections. - * @return auto generated image file name - */ - private static String makeEventFileName() - { - String name = "Untitled"; - AEvent ev = eventManager.getCurrentEvent(); - if(ev != null) - { - name = ev.getSourceName(); - if(name.toLowerCase().endsWith(".xml")) - { - // current event comes from XML file, run and event number - // are probably already part of the current filename - name = name.substring(0, name.length() - 4); - } - else - { - // current event was probably retrieved online, add run and - // event numbers into the file name of the canvas plot - if(! ("n/a".equals(ev.getRunNumber()) && - "n/a".equals(ev.getEventNumber()))) - { - name += "_" + ev.getRunNumber() + "_" + ev.getEventNumber(); - } - } - } - - ACanvas canvas = ACanvas.getCanvas(); - String[] windows = canvas.getCurrentLayout().getWindowNames(); - StringBuilder listWindows = new StringBuilder(); - for(int i = 0; i < windows.length; i++) - { - if(canvas.isReallyOnScreen(canvas.getWindow(windows[i]))) - { - listWindows.append("-" + canvas.getWindow(windows[i]).getProjection().getName()); - } - } - name += listWindows.toString(); - - return name; - } - - - - /** - * GUI component for the resolution selection panel. - */ - class AResolutionChooser extends JPanel implements ActionListener - { - /** Currently selected button. */ - private AResolutionButton selectedButton; - - /** - * Constructor. - */ - public AResolutionChooser() - { - super(new GridLayout(IMAGE_WIDTHS.length+1, 1)); - setBorder(BorderFactory.createTitledBorder(" Resolution: ")); - - ButtonGroup group = new ButtonGroup(); - for (int i=0; i<IMAGE_WIDTHS.length; i++) - { - int width = IMAGE_WIDTHS[i]; - int height = ACanvas.getCanvas().getRespectiveHeight(IMAGE_WIDTHS[i]); - - AResolutionButton button = new AResolutionButton(width, height); - button.addActionListener(this); - if(i == DEFAULT_IMAGE_WIDTH) - { - selectedButton = button; - button.setSelected(true); - } - group.add(button); - add(button); - } - } - - /** - * Get the currently selected image width. - * @return selected image width - */ - public int getImageWidth() - { - return selectedButton.getImageWidth(); - } - - /** - * Gets the currently selected image height. - * @return selected image height - */ - public int getImageHeight() - { - return selectedButton.getImageHeight(); - } - - public void updateResolutions() - { - for (int i=0; i<getComponentCount(); i++) - { - if (getComponent(i) instanceof AResolutionButton) - { - AResolutionButton button = (AResolutionButton)getComponent(i); - int height = ACanvas.getCanvas().getRespectiveHeight(button.getImageWidth()); - button.setImageHeight(height); - } - } - } - - - - /** - * Action listener for the resolution panel. - * @param e performed action - */ - public void actionPerformed(ActionEvent e) - { - selectedButton = (AResolutionButton)e.getSource(); - } - - /** - * Radio button for the resolution chooser. - */ - public class AResolutionButton extends JRadioButton - { - /** Image width for this button. */ - int imageWidth; - /** Image height for this button. */ - int imageHeight; - - /** - * Constructor. - * @param targetWidth image width this button corresponds to - * @param targetHeight image height this button corresponds to - */ - public AResolutionButton(int imageWidth, int imageHeight) - { - super(imageWidth + "x" + imageHeight); - this.imageWidth = imageWidth; - this.imageHeight = imageHeight; - } - - /** - * Gets the image width on this button. - * @return image width - */ - public int getImageWidth() - { - return imageWidth; - } - - /** - * Gets the image height on this button. - * @return image height - */ - public int getImageHeight() - { - return imageHeight; - } - - public void setImageHeight(int imageHeight) - { - this.imageHeight = imageHeight; - setText(imageWidth + "x" + imageHeight); - } - } - } - - /** - * Simple filter class that filters files by extension. - */ - private static class AFileFilter extends FileFilter - { - /** File extension. */ - private String extension; - /** Description of the file type this filter shows. */ - private String description; - - /** - * Constructs a file filter. - * @param extension file extension that passes the filter - * @param description description of the file type this filter selects - */ - public AFileFilter(String extension, String description) - { - super(); - this.extension = extension; - this.description = description; - } - - /** - * Decides if the filter allows a file to pass or not - * @param f file under consideration - * @return decision of the filter - */ - public boolean accept(File f) - { - //Accept all directories - if (f.isDirectory()) return true; - - //Accept all files that end with given extension - if (f.getName().toLowerCase().endsWith(extension)) return true; - - //Nothing else - return false; - } - - /** - * Get the extension this filter filters on. - * @return file extension - */ - public String getExtension() - { - return extension; - } - - /** - * Get description of the filter. - * @return description - */ - public String getDescription() - { - return description; - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AStartupWindow.java b/graphics/AtlantisJava/src/atlantis/gui/AStartupWindow.java deleted file mode 100755 index 4743e6d208147af6614642aa450083a835ee2c4d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AStartupWindow.java +++ /dev/null @@ -1,86 +0,0 @@ -package atlantis.gui; - -import atlantis.globals.AGlobals; -import atlantis.graphics.AIcon; -import atlantis.utils.ALogger; -import atlantis.utils.AUtilities; -import java.awt.*; -import javax.swing.*; - - -/** - * The startup window appears when the program starts up and displays the - * progress of the operation. No need for this to be a singleton at all. - */ -public class AStartupWindow { - - //add a logger - private final ALogger logger = ALogger.getLogger(AStartupWindow.class); - - //the frame showing the startup image and progress - private final JFrame frame = (AGlobals.isAtlantisHeadless()) ? null : new JFrame(); - - //how often we will update the progress bar - private final int progressUpdateDiff; - - //GUI items that will be updated - private JLabel text = null; - private JProgressBar progress = null; - - public AStartupWindow(int numUpdates) { - - //Store how often we will update the progress bar - progressUpdateDiff=(int)100./numUpdates; - - //Don't do anything in headless mode - if (AGlobals.isAtlantisHeadless()) return; - - frame.getContentPane().setLayout(new BorderLayout()); - - String fileName = AGlobals.instance().getHomeDirectory() + "img" + - System.getProperty("file.separator") + "atlas.jpg"; - ImageIcon icon = AUtilities.getFileAsImageIcon(fileName); - - frame.getContentPane().add(new JLabel(icon), BorderLayout.CENTER); - text = new JLabel("Welcome to Atlantis", JLabel.CENTER); - JPanel p = new JPanel(); - - p.setLayout(new GridLayout(2, 1)); - p.add(text); - progress = new JProgressBar(0, 100); - progress.setStringPainted(true); - p.add(progress); - frame.getContentPane().add(p, BorderLayout.SOUTH); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - frame.setLocation(screenSize.width / 4, screenSize.height / 3); - frame.setUndecorated(true); - AIcon.setIconImage(frame); - frame.setTitle("Atlantis starting up..."); - frame.pack(); - frame.setVisible(true); - } - - /** - * Update the frame and log to the logger - * @param newText the new text for the startup window - */ - public void updateText(String newText) { - //Also send this to the logger - logger.info(newText); - - //Don't do graphics update in headless mode - if (AGlobals.isAtlantisHeadless()) return; - - //Update text and progress bar - text.setText(newText); - progress.setValue(progress.getValue()+progressUpdateDiff); - } - - /** - * When dispsoing this object, also dispose of the frame - */ - public void dispose(){ - if (frame!=null) frame.dispose(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ATabbedPaneUI.java b/graphics/AtlantisJava/src/atlantis/gui/ATabbedPaneUI.java deleted file mode 100755 index ea5cf518a7d6a1f5b438d99b7c5bacbd3cdd8006..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ATabbedPaneUI.java +++ /dev/null @@ -1,35 +0,0 @@ -package atlantis.gui; - -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; - -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.metal.MetalTabbedPaneUI; - -import atlantis.utils.AUtilities; - -/** - * Once installed on a TabbedPane this UI will allow changing the tabs only with - * the left mouse button. By default this is possible with any button. - * In Atlantis the right mouse button provides help - */ - -public class ATabbedPaneUI extends MetalTabbedPaneUI { - - public static ComponentUI createUI(JComponent c) { - return new ATabbedPaneUI(); - } - - protected MouseListener createMouseListener() { - return new myMouseHandler(); - } - - public class myMouseHandler extends MouseHandler { - public void mousePressed(MouseEvent e) { - if(!AUtilities.isRightMouseButton(e)) - super.mousePressed(e); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ATextField.java b/graphics/AtlantisJava/src/atlantis/gui/ATextField.java deleted file mode 100755 index a7aae0b222b4f13e1ad83974aed22b345bc04470..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ATextField.java +++ /dev/null @@ -1,31 +0,0 @@ -package atlantis.gui; - - -import java.awt.event.ActionListener; -import javax.swing.JTextField; - - -/** - * This textfield will not generate an event when the setText() function is called. - */ - -public class ATextField extends JTextField { - ActionListener listener; - - public ATextField() { - super(); - } - - public void addActionListener(ActionListener l) { - if(listener==null) { - super.addActionListener(l); - listener=l; - } - } - - public void setText(String t) { - if(listener!=null) super.removeActionListener(listener); - super.setText(t); - if(listener!=null) super.addActionListener(listener); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ATreeCellRenderer.java b/graphics/AtlantisJava/src/atlantis/gui/ATreeCellRenderer.java deleted file mode 100755 index 3979507b6ff0f324c31afd2302909ede1b0e631c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ATreeCellRenderer.java +++ /dev/null @@ -1,34 +0,0 @@ -package atlantis.gui; - -import java.awt.*; -import javax.swing.*; -import javax.swing.tree.*; -import atlantis.parameters.AStatusParameter; -import hep.wired.util.TristateCheckBox; - -public class ATreeCellRenderer implements TreeCellRenderer { - - public ATreeCellRenderer() { - } - - public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected, - boolean expanded, boolean leaf, int row, boolean hasFocus) { - if(value instanceof ACheckNode){ - ACheckNode cellNode = (ACheckNode)value; - cellNode.updateState(); - if (cellNode.getParameter() instanceof AStatusParameter){ - ACheckBox cellComponent = (ACheckBox)cellNode.getUserObject(); - cellComponent.setBorderPaintedFlat(true); - return cellComponent; - } else{ - TristateCheckBox cellComponent = (TristateCheckBox)cellNode.getUserObject(); - cellComponent.setState(cellNode.getState()); - cellComponent.setBorderPaintedFlat(true); - return cellComponent; - } - } - - return new JLabel("not a checkNode"); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/ATreeExpansionListener.java b/graphics/AtlantisJava/src/atlantis/gui/ATreeExpansionListener.java deleted file mode 100755 index cb7d0b791603006406fa9e34880871577435e509..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/ATreeExpansionListener.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * ATreeExpansionListener.java - * - * Created on 17 March 2005, 15:55 - */ - -package atlantis.gui; - -import javax.swing.event.TreeExpansionListener; -import javax.swing.event.TreeExpansionEvent; -import javax.swing.JTree; - -/** - * - * @author Qiang - */ -public class ATreeExpansionListener implements TreeExpansionListener { - - private JTree tree; - - private AParametersTable table; - - // the row number which the tree locates - private int treeRow; - - /** Creates a new instance of ATreeExpansionListener */ - public ATreeExpansionListener(JTree tree, AParametersTable table, int treeRow) { - this.tree = tree; - this.table = table; - this.treeRow = treeRow; - } - - public void treeExpanded(TreeExpansionEvent event) { - int newHeight = tree.getRowCount() * (int)(tree.getRowBounds(0).getHeight()); - table.setRowHeight(treeRow, newHeight); - } - - public void treeCollapsed(TreeExpansionEvent event) { - int newHeight = tree.getRowCount() * (int)(tree.getRowBounds(0).getHeight()); - table.setRowHeight(treeRow, newHeight); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AWindowControl.java b/graphics/AtlantisJava/src/atlantis/gui/AWindowControl.java deleted file mode 100755 index abac35788b1665510d6e0c12656c7747a5eba034..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AWindowControl.java +++ /dev/null @@ -1,190 +0,0 @@ -package atlantis.gui; - -import atlantis.canvas.ALayoutChangeListener; -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.canvas.ALayout; -import atlantis.graphics.layout.AFlowLayout; -import atlantis.graphics.layout.AGridLayout; -import atlantis.graphics.dnd.ADnDLabel; -import atlantis.graphics.dnd.ADragListener; -import atlantis.parameters.ACommandProcessor; -import atlantis.utils.*; -import java.util.*; -import javax.swing.BorderFactory; -import javax.swing.SwingUtilities; -import javax.swing.JPanel; -import java.awt.Color; -import java.awt.Rectangle; -import java.awt.Dimension; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.event.*; - -/** - * Allows user to select the current window and to - * copy between windows. - */ -public class AWindowControl extends JPanel - implements ALayoutChangeListener, ADragListener { - - private String selectedWindowName; - private Vector pages=new Vector(10); - - public AWindowControl getPanel() { - return this; - } - - public AWindowControl() { - super(); - setLayout(new AFlowLayout(10, 10)); - - addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - if(AUtilities.isRightMouseButton(e)) - AHelpSystem.getInstance().showPage("WindowControl"); - } - }); - - // registering as a listener to of window lock changes - ACanvas.getCanvas().addLockChangeListener(new ChangeListener() { - - public void stateChanged(ChangeEvent e) { - for(int i=0; i<pages.size(); i++) { - Hashtable page=(Hashtable)pages.elementAt(i); - Enumeration labels=page.elements(); - while(labels.hasMoreElements()) { - ADnDLabel label=(ADnDLabel)labels.nextElement(); - if(ACanvas.getCanvas().getWindow(label.getName()).isLocked()) - label.setForeground(Color.red); - else - label.setForeground(Color.black); - } - } - } - }); - - // registering as a listener to APar - ACanvas.getCanvas().addLayoutChangeListener(this); - - ACanvas.getCanvas().addWindowChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - ADnDLabel label; - - if(selectedWindowName!=null) - for(int i=0; i<pages.size(); i++) { - Hashtable page=(Hashtable)pages.elementAt(i); - - label=(ADnDLabel)page.get(selectedWindowName); - if(label!=null) - label.setBackground(new Color(207, 207, 207)); - } - - selectedWindowName=ACanvas.getCanvas().getCurrentWindow().getName(); - for(int i=0; i<pages.size(); i++) { - Hashtable page=(Hashtable)pages.elementAt(i); - - label=(ADnDLabel)page.get(selectedWindowName); - if(label!=null) - label.setBackground(Color.white); - } - } - }); - } - - // function gets called when the current layout is changed in APar - public void layoutChanged(ACanvas c) { - removeAll(); - ALayout layout = c.getCurrentLayout(); - Dimension d=layout.getSize(); - WindowMouseListener windowMouseListener=new WindowMouseListener(); - - // adding new set of pages - pages.clear(); - String[] pageNames=layout.getPageNames(); - Hashtable pageHashtable; - - for(int i=0; i<pageNames.length; i++) { - String[] wNames=layout.getPageContent(pageNames[i]); - - JPanel page=new JPanel(new AGridLayout(d, 15)); - - pageHashtable=new Hashtable(); - for(int k=0; k<wNames.length; k++) { - Rectangle constraint=layout.getWindowConstraints(wNames[k]); - ADnDLabel w=new ADnDLabel(wNames[k], wNames, true); - - w.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150))); - pageHashtable.put(wNames[k], w); - page.add(w, constraint); - w.addMouseListener(windowMouseListener); - w.addDragListener(this); - } - - pages.addElement(pageHashtable); - add(page); - setToolTipText("Current Layout - "+layout.getName()); - revalidate(); - repaint(); - } - } - - public void dragPerformed(Object from, Object to, int action) { - if((from instanceof ADnDLabel)&&(to instanceof ADnDLabel)) - ACanvas.getCanvas().copyWindowSettings(((ADnDLabel)from).getText(), ((ADnDLabel)to).getText()); - } - - private Hashtable findPage(String[] wNames) - { - for (int i = 0; i < pages.size(); i++) - { - int matches = 0; - Hashtable page = (Hashtable)pages.get(i); - - for (int j = 0; j < wNames.length; j++) - { - if (page.containsKey(wNames[j])) - matches++; - else break; - } - if (matches == wNames.length) - return page; - } - return null; - } - - class WindowMouseListener extends MouseAdapter { - - public void mousePressed(MouseEvent e) { - ADnDLabel label = (ADnDLabel) e.getSource(); - - if (AUtilities.isRightMouseButton(e)) { - if (AEventQueue.getKeyboardState() == KeyEvent.VK_A) { - - String[] pageName = label.returnPageName(); - Hashtable page = findPage(pageName); - if(page==null) - return; - - for (Enumeration labels = page.elements(); labels.hasMoreElements(); ) { - label = (ADnDLabel) labels.nextElement(); - if (label != null) - ACommandProcessor.receive("W" + label.getName()); - } - } - else { - AWindow.getPopupMenu().show(label, e.getX(), e.getY()); - ACommandProcessor.receive("W" + label.getName()); - } - } - } - - public void mouseReleased(MouseEvent e) { - ADnDLabel label=(ADnDLabel)e.getSource(); - - if(SwingUtilities.isLeftMouseButton(e)) { - ACommandProcessor.receive("W"+label.getName()); - } - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AXMLFileChooser.java b/graphics/AtlantisJava/src/atlantis/gui/AXMLFileChooser.java deleted file mode 100755 index b5c2421bfcddbc9540e338dca25f05ec4e8e2aff..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AXMLFileChooser.java +++ /dev/null @@ -1,108 +0,0 @@ -package atlantis.gui; - -import java.awt.Component; -import java.io.File; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.filechooser.FileFilter; - - - -/** - * A GUI component used choose a specific XML file - */ -public abstract class AXMLFileChooser extends JFileChooser -{ - private Component parent = null; - - public abstract boolean processSelectedFile(File file); - - - public AXMLFileChooser(String fileName, Component parent) - { - super(); - this.parent = parent; - - setFileFilter(new XMLFilter()); - if (fileName == null) - { - setCurrentDirectory(new File(System.getProperty("user.dir"))); - } - else - { - File f = new File(fileName); - if (f.isFile()) - { - setCurrentDirectory(new File(f.getAbsolutePath())); - setSelectedFile(f); - } - else - { - setCurrentDirectory(f); - } - } - - } // AXMLFileChooser() -------------------------------------------------- - - - - public void showMyDialog() - { - do - { - int state = showOpenDialog(this.parent); - if(state == APPROVE_OPTION) - { - File file = getSelectedFile(); - if(file != null) - { - if(processSelectedFile(file)) - { - break; - } - else - { - JOptionPane.showMessageDialog(parent, - "Unable to open\n" + file, "IO Error", - JOptionPane.ERROR_MESSAGE); - } - } - } - else - { - break; - } - } - while(true); - - } // showMyDialog() ----------------------------------------------------- - - - - private static class XMLFilter extends FileFilter - { - // Accept all directories and all valid files. - public boolean accept(File f) - { - if(f.isDirectory()) - { - return true; - } - - String s = f.getName(); - - if(s.toLowerCase().endsWith(".xml") || s.toLowerCase().endsWith(".zip") - || s.toLowerCase().endsWith(".gzip") || s.toLowerCase().endsWith(".gz")) - return true; - - return false; - } - - - public String getDescription() - { - return ".xml, .zip, .gzip, .gz"; - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/AXMLGeometryChooser.java b/graphics/AtlantisJava/src/atlantis/gui/AXMLGeometryChooser.java deleted file mode 100755 index c790d8aeee828ca8c8a7d0f2ac2dc8649886d227..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/AXMLGeometryChooser.java +++ /dev/null @@ -1,73 +0,0 @@ -package atlantis.gui; - -import java.awt.Frame; -import java.io.File; -import javax.swing.*; -import javax.swing.filechooser.*; - -import atlantis.globals.AGlobals; - - -/** - * A GUI component used choose a specific XML file - */ -public abstract class AXMLGeometryChooser extends JFileChooser { - - private static final AGlobals globals = AGlobals.instance(); - - public AXMLGeometryChooser(String fileName) { - super(); - String FILE_SEPAR = System.getProperty("file.separator"); - Frame gui = globals.getGuiFrame(); - setFileFilter(new XMLFilter()); - setCurrentDirectory(new File(System.getProperty("user.dir")+FILE_SEPAR+ - "geometry")); - if(fileName!=null) - setSelectedFile(new File(System.getProperty("user.dir")+FILE_SEPAR - +fileName)); - do { - int state=showOpenDialog(gui); - if(state==APPROVE_OPTION) { - File file=getSelectedFile(); - if(file!=null) - if(processSelectedFile(file)) - break; - else { - JOptionPane.showMessageDialog(gui, - "Unable to open " + file, "IO Error", JOptionPane.ERROR_MESSAGE); - } - } else - break; - } while(true); - } - - - public AXMLGeometryChooser() { - this(null); - } - - - public abstract boolean processSelectedFile(File file); - - - private static class XMLFilter extends FileFilter { - // Accept all directories and all XML files. - - public boolean accept(File f) { - if(f.isDirectory()) - return true; - - String s=f.getName(); - if(s.startsWith("AMuon")) return false; - if(s.equals("config.xml")) return false; - if(s.equals("pdg.xml")) return false; - if(s.toLowerCase().lastIndexOf(".xml")==s.length()-".xml".length()) return true; - return false; - } - - public String getDescription() { - return ".xml"; - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/gui/package.html b/graphics/AtlantisJava/src/atlantis/gui/package.html deleted file mode 100644 index 67b415276a29301847d51f4aaaf3b11bf5a743c2..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/gui/package.html +++ /dev/null @@ -1,8 +0,0 @@ -<html> -<head></head> -<body> -<p>Maintenance of GUI components (layouts, tabbed panes, etc). The -contents (not the structure) of the GUI is defined in config.xml. -</p> -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/interactions/A3DBoxGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/A3DBoxGroup.java deleted file mode 100755 index 88cb802db3d04f95034cda849b1501cf5d9ef79b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/A3DBoxGroup.java +++ /dev/null @@ -1,14 +0,0 @@ -package atlantis.interactions; - - -public class A3DBoxGroup extends AInteractionGroup { - - private A3DBoxInteraction transformInteraction; - - public A3DBoxGroup(AInteractionsManager iManager) { - super(AInteractionGroup.WINDOW_GROUP, iManager); - transformInteraction=new A3DBoxInteraction(); - this.addInteraction(transformInteraction); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/A3DBoxInteraction.java b/graphics/AtlantisJava/src/atlantis/interactions/A3DBoxInteraction.java deleted file mode 100755 index 7d264df9cc7d7d92d54e01938a56ce5a40666514..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/A3DBoxInteraction.java +++ /dev/null @@ -1,202 +0,0 @@ -package atlantis.interactions; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.event.KeyEvent; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Point2D; - -import javax.swing.JMenuItem; - -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection; -import atlantis.projection.AProjection3DBox; -import atlantis.graphics.ACursorFactory; - -/** - * The Zoom and Rotate interaction. - */ -public class A3DBoxInteraction extends AInteraction implements - ASleepMouseDragListener, AMousePressListener, AEnterExitListener -{ - private static final int ZOOM_MODE = 0; - private static final int HORIZONTAL_ZOOM_MODE = 1; - private static final int VERTICAL_ZOOM_MODE = 2; - private static final int ROTATE_MODE = 3; - - private int d = 10; - private Point2D.Double p0; - private int previousKey = KeyEvent.VK_UNDEFINED; - private int mode; - - public A3DBoxInteraction() - { - super(1, AUTOMATIC_REPAINT, SCREEN_COORDINATES, false); - - // The center of the ellipse is in (0, 0) in User Space - // dummy for now - hr[0] = new Ellipse2D.Double(-d / 2, -d / 2, d, d); - } - - public void connect(AInteractionsManager manager) - { - super.connect(manager); - } - - public int getPressButton() - { - return AInteractionsManager.LEFT; - } - - public int init(Point2D.Double p, int key) - { - keyChange(p, key); - return -1; - } - - public void pressed(Point2D.Double p, int button, int key) - {} - - public int getButton() - { - return AInteractionsManager.LEFT; - } - - public void start(Point2D.Double p, int region, int key) - {} - - private void keyChange(Point2D.Double p, int key) - { - p0 = p; - - switch (key) - { - case KeyEvent.VK_UNDEFINED: - mode = ZOOM_MODE; - break; - - case KeyEvent.VK_H: - mode = HORIZONTAL_ZOOM_MODE; - break; - - case KeyEvent.VK_V: - mode = VERTICAL_ZOOM_MODE; - break; - - case KeyEvent.VK_R: - mode = ROTATE_MODE; - break; - - case KeyEvent.VK_Z: - mode = ZOOM_MODE; - break; - } - } - - public void drag(Point2D.Double p, int region, int key) - { - if (key != previousKey) - { - keyChange(p, key); - previousKey = key; - } - - double zf; - AProjection proj = window.getProjection(); - Point2D.Double center = ((AProjection3DBox) proj).getCenter(window); - - switch (mode) - { - case ZOOM_MODE: - zf = p0.distance(center.getX(), center.getY()) - / p.distance(center.getX(), center.getY()); - ((AProjection3DBox) proj).zoom(zf); - p0 = p; - window.repaintFromScratch(); - break; - case HORIZONTAL_ZOOM_MODE: - zf = Math.abs((p0.getX() - center.getX()) - / (p.getX() - center.getX())); - ((AProjection3DBox) proj).zoomHorizontal(zf); - p0 = p; - window.repaintFromScratch(); - break; - case VERTICAL_ZOOM_MODE: - zf = Math.abs((p0.getY() - center.getY()) - / (p.getY() - center.getY())); - ((AProjection3DBox) proj).zoomVertical(zf); - p0 = p; - window.repaintFromScratch(); - break; - case ROTATE_MODE: - AParameter phiPar = parameterStore.get(proj.getName(), "Phi"); - double height = window.getCurrDisp().getHeight(); - double deltaV = p.getY() - p0.getY(); - phiPar.setD(adjustPhi(phiPar.getD() + 360. * deltaV / height)); - p0 = p; - window.repaintFromScratch(); - break; - } - } - - private double adjustPhi(double phi) - { - while (phi < 0) - phi += 360; - while (phi > 360) - phi -= 360; - return phi; - } - - public void stop() - {} - - public void cancel() - {} - - public void paint(Graphics2D g) - { - Point2D.Double p = ((AProjection3DBox) window.getProjection()).getCenter(window); - g.setColor(Color.red); - g.fillOval((int) (p.x - d / 2), (int) (p.y - d / 2), d, d); - } - - public void entered() - { -// if (region == 0) - window.setCursor(ACursorFactory.getInstance().getDefaultCursor()); - } - - public void exited() - { - // if (region == 0) - window.setCursor(ACursorFactory.getInstance().getDefaultCursor()); - } - - public int getPopupType() - { - return APopupListener.WINDOW_POPUP; - } - - /*public void showPopup(Point p, int region) - { - popupMenu.show(window, p.x, p.y); - }*/ - - public JMenuItem[] getPopupItems() { - return null; - } - - public AModifier[] getModifiers() - { - return new AModifier[] { - new AModifier(KeyEvent.VK_UNDEFINED, false, "Change the volume of the box"), - new AModifier(KeyEvent.VK_Z, false, "Change the volume of the box"), - new AModifier(KeyEvent.VK_H, false, "Change the length of the box"), - new AModifier(KeyEvent.VK_V, false, "Change the height of the box"), - new AModifier(KeyEvent.VK_R, false, "Rotate around axis of box") - }; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AClockGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/AClockGroup.java deleted file mode 100755 index 8bfd75d8ffe4883184afe6729250db8aad56bd74..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AClockGroup.java +++ /dev/null @@ -1,62 +0,0 @@ -package atlantis.interactions; - -import atlantis.canvas.ACanvas; -import atlantis.parameters.APar; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import javax.swing.JCheckBox; -import javax.swing.JPanel; - -public class AClockGroup extends AInteractionGroup { - - private AClockInteraction clockInteraction; - private JCheckBox checkbox; - // the panel that will contain the additional controls for the interactions - private JPanel additionalControls; - - public AClockGroup(AInteractionsManager iManager) { - super(AInteractionGroup.WINDOW_GROUP, iManager); - - clockInteraction=new AClockInteraction(); - addInteraction(clockInteraction); - - // create the additional controls panel - additionalControls = new JPanel(); - - checkbox=new JCheckBox("on/off", false); - checkbox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - switch(e.getStateChange()) { - case ItemEvent.SELECTED: - parameterStore.get("YX", "Clock").setStatus(true); - break; - - case ItemEvent.DESELECTED: - parameterStore.get("YX", "Clock").setStatus(false); - break; - } - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - } - }); - additionalControls.add(checkbox); - } - - public void connect() { - checkbox.setSelected(parameterStore.get("YX", "Clock").getStatus()); - } - - /** - * this interaction group has additional controls, so return true - */ - - public boolean hasAdditionalControls() { - return true; - } - /** - * returns the additional controls - */ - public JPanel getAdditionalControls() { - return additionalControls; - } - -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AClockInteraction.java b/graphics/AtlantisJava/src/atlantis/interactions/AClockInteraction.java deleted file mode 100755 index 13a44dbe9f5e267cf832a741ca8ba830dc3d1c94..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AClockInteraction.java +++ /dev/null @@ -1,103 +0,0 @@ -package atlantis.interactions; - - -import java.awt.*; -import java.awt.geom.*; - -import atlantis.graphics.*; -import atlantis.parameters.*; -import atlantis.projection.*; -import atlantis.utils.*; - - -public class AClockInteraction extends AInteraction - implements ASleepMouseDragListener { - - private ALineSegment line; - private double phi; - - public AClockInteraction() { - super(1, WINDOW_TOTAL_REPAINT, WORLD_COORDINATES, false); - // double phi = APar.get("YX","Phi").getD()*AMath.DEGREES_TO_RADIANS+Math.PI; - double phi=Math.toRadians(parameterStore.get("YX", "Phi").getD()); - - line=new ALineSegment(0, 0, 1500*Math.cos(phi), 1500*Math.sin(phi), 10); - hr[0]=line; - } - - public RectangularShape getScreenHotRegion(int region) { - if(region==0) - return new ALineSegment(window.calculateDisplay(line.p1), window.calculateDisplay(line.p2), 10); - else - return null; - } - - public int init(Point2D.Double p, int key) { - return 1; - } - - public int getButton() { - return AInteractionsManager.LEFT; - } - - public void start(Point2D.Double p, int region, int key) { - // if(parameterStore.get("YX","Clock").getStatus()) - if(region==0) - parameterStore.get("YX", "Clock").setD(0.0000001); - else if(region==1) { - AProjection2D projection=(AProjection2D)window.getProjection(); - Point2D.Double p0=projection.inverseNonLinearTransform(p); - - this.phi=Math.atan2(p0.y, p0.x); - } - } - - public void drag(Point2D.Double p, int region, int key) { - if(region==0) { - double phi=Math.atan2(p.y, p.x); - - // phi+=Math.PI; - if(phi<0) phi+=2*Math.PI; - parameterStore.get("YX", "Phi").setD(Math.toDegrees(phi)); - } else if(region==1&¶meterStore.get("YX", "Clock").getStatus()) { - double phiPrime=Math.atan2(p.y, p.x); - double phi0=Math.toRadians(parameterStore.get("YX", "Phi").getD()); - double deltaPhiPrime=phiPrime-phi0; - - if(deltaPhiPrime<-Math.PI) deltaPhiPrime+=2*Math.PI; - if(deltaPhiPrime>Math.PI) deltaPhiPrime-=2*Math.PI; - double deltaPhi=this.phi-phi0; - - if(deltaPhi<-Math.PI) deltaPhi+=2*Math.PI; - if(deltaPhi>Math.PI) deltaPhi-=2*Math.PI; - - if((deltaPhi>0.&&deltaPhiPrime-deltaPhi>0.)||(deltaPhi<0.&&deltaPhiPrime-deltaPhi<0.)) { - double a=(deltaPhi*Math.PI-deltaPhiPrime*Math.abs(deltaPhi))/(deltaPhiPrime-deltaPhi); - - parameterStore.get("YX", "Clock").setD(Math.min(Math.max(Math.PI/a, 0.000001), 7.)); - } else { - parameterStore.get("YX", "Clock").setD(0.000001); - } - } - } - - public void stop() {} - - public void cancel() {} - - public void paint(Graphics2D g) { - // double phi = parameterStore.get("YX","Phi").getD()*AMath.DEGREES_TO_RADIANS+Math.PI; - double phi=Math.toRadians(parameterStore.get("YX", "Phi").getD()); - - line.p2.setLocation(1500*Math.cos(phi), 1500*Math.sin(phi)); - ALineSegment screenLine=(ALineSegment)getScreenHotRegion(0); - - AGraphics ag=AGraphics.makeAGraphics(g); - - ag.updateDrawParameters(frameDrawParameters); - ag.drawLine(screenLine.p1.x, screenLine.p1.y, screenLine.p2.x, screenLine.p2.y); - ag.updateDrawParameters(drawParameters); - ag.drawLine(screenLine.p1.x, screenLine.p1.y, screenLine.p2.x, screenLine.p2.y); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AEnterExitListener.java b/graphics/AtlantisJava/src/atlantis/interactions/AEnterExitListener.java deleted file mode 100755 index 7bc8fdb6fb4893866fce0775b77614172e52f48d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AEnterExitListener.java +++ /dev/null @@ -1,13 +0,0 @@ -package atlantis.interactions; - - -/** - * The listener is supported by AInteractionsManager, - * it generated events when the mouse is entering or exiting a Hot Region. - */ -public interface AEnterExitListener { - - void entered(); - void exited(); -} - diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AFishEyeChangeListener.java b/graphics/AtlantisJava/src/atlantis/interactions/AFishEyeChangeListener.java deleted file mode 100644 index 5b6c091c36307da171d545d2cfc1a86829962f12..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AFishEyeChangeListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package atlantis.interactions; - -/** - * Interface for all FishEyeChangeListener classes. Each time the FishEye - * parameters are changed, all listeners are called with the new paremeters - * @author sboeser - */ -public interface AFishEyeChangeListener { - - /** - * This method gets called each time new fisheye parameters are set - * @param status the new fishEye status - * @param value the new fishEye value - */ - abstract public void fishEyeChange(boolean status, double value); - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AFishEyeGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/AFishEyeGroup.java deleted file mode 100755 index d2784b7826666ec3d63aed326130b0796947acda..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AFishEyeGroup.java +++ /dev/null @@ -1,116 +0,0 @@ -package atlantis.interactions; - -import atlantis.canvas.ACanvas; -import java.awt.event.*; -import javax.swing.JCheckBox; -import javax.swing.JFormattedTextField; -import javax.swing.JLabel; -import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.text.NumberFormat; - -public class AFishEyeGroup extends AInteractionGroup implements AFishEyeChangeListener { - - private final AFishEyeInteraction fishEyeInteraction; - private final JCheckBox checkbox; - private final JFormattedTextField valueField; - // the panel that will contain the additional controls for the interactions - private JPanel additionalControls; - -//Format, label and label string for value field - private NumberFormat valueFormat; - private JLabel valueLabel; - private static String valueString = "Value: "; - - public AFishEyeGroup(AInteractionsManager iManager) { - super(AInteractionGroup.WINDOW_GROUP, iManager); - - fishEyeInteraction=new AFishEyeInteraction(); - addInteraction(fishEyeInteraction); - - // create the additional controls panel - additionalControls = new JPanel(); - - checkbox=new JCheckBox("on/off", false); - checkbox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - switch(e.getStateChange()) { - case ItemEvent.SELECTED: - fishEyeInteraction.setStatus(true); - //fishEyeInteraction.getParameter("FishEye").setStatus(true); - break; - - case ItemEvent.DESELECTED: - fishEyeInteraction.setStatus(false); - //fishEyeInteraction.getParameter("FishEye").setStatus(false); - break; - } - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - } - }); - -//Create the label - valueLabel = new JLabel(valueString); - valueFormat = NumberFormat.getNumberInstance(); - valueFormat.setMaximumIntegerDigits(2); - valueField=new JFormattedTextField(valueFormat); - valueField.setToolTipText("Enter fish eye value between 0 and 25"); - valueField.setValue(new Double(0)); - valueField.setColumns(3); - valueField.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) - { - Number value =(Number)valueField.getValue(); - double dvalue = value.doubleValue(); - if(dvalue>0 && dvalue<25) - { - fishEyeInteraction.setValue(dvalue); - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - } - else - { - Double val = new Double(fishEyeInteraction.getValue()); - valueField.setValue(val); - } - } - }); - - JPanel nestedPanel = new JPanel(); - nestedPanel.add(valueLabel); - nestedPanel.add(valueField); - - JPanel borderPanel = new JPanel(new BorderLayout()); - borderPanel.add(checkbox, BorderLayout.WEST); - borderPanel.add(nestedPanel, BorderLayout.EAST); - - additionalControls.add(borderPanel); - - } - - public void connect() { - super.connect(); - - //Only after we are connected to a window, add ourselves as update listener - fishEyeInteraction.addFishEyeChangeListener(this); - } - - public void fishEyeChange(boolean status, double value) { - valueField.setValue(value); - checkbox.setSelected(status); - } - - /** - * FishEye has additional controls, so return true - */ - public boolean hasAdditionalControls() { - return true; - } - - /** - * return the additional controls - */ - public JPanel getAdditionalControls() { - return additionalControls; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AFishEyeInteraction.java b/graphics/AtlantisJava/src/atlantis/interactions/AFishEyeInteraction.java deleted file mode 100755 index b1abf8608b4af07a34716e55363799ec7583fc3d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AFishEyeInteraction.java +++ /dev/null @@ -1,389 +0,0 @@ -package atlantis.interactions; - -import atlantis.graphics.ACursorFactory; -import atlantis.parameters.AParameter; -import atlantis.parameters.APar; -import atlantis.projection.*; -import java.awt.Graphics2D; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.awt.event.ActionListener; -import javax.swing.JMenuItem; -import java.awt.geom.*; -import java.util.Vector; - -/** - * The FishEye transformation will expand the central part of the display, - * while keeping the outer borders. This helps in e.g. expanding the inner detector region. - **/ - -public class AFishEyeInteraction extends AInteraction - implements ASleepMouseDragListener, ActionListener, AEnterExitListener { - - //A list of listeners for fishEye changes - private Vector<AFishEyeChangeListener> fishEyeChangeListeners = new Vector<AFishEyeChangeListener>(); - - private final int d=20; - private final int region = 0; - private Point2D.Double firstP; - private JMenuItem[] popupItems; - - private final static String TOGGLE_FISHEYE="Fish Eye On/Off"; - - /** - * Create a new FishEye interaction - */ - public AFishEyeInteraction() { - super(1, WINDOW_TOTAL_REPAINT, WORLD_COORDINATES, false); - - hr[0]=new Ellipse2D.Double(0, 0, d, d); - - popupItems = new JMenuItem[] { - new JMenuItem(TOGGLE_FISHEYE), - }; - - for (int i = 0; i < popupItems.length; i++) { - popupItems[i].addActionListener(this); - } - } - - - /** - * Initialize FishEye transformation using an inital point - */ - public int init(Point2D.Double p, int key) { - - AProjection2D projection=(AProjection2D)window.getProjection(); - - firstP=new Point2D.Double(Math.abs(p.x), Math.abs(p.y)); - firstP=projection.inverseNonLinearTransform(firstP); - - return region; - } - - /** - * Returns the button this interaction uses - **/ - public int getButton() { - return AInteractionsManager.LEFT; - } - - /** - * Get projection parameters using APar - **/ - private AParameter getParameter(String name) { - AProjection projection=window.getProjection(); - - if(projection instanceof AProjectionYX) - return parameterStore.get("YX", name); - else if(projection instanceof AProjectionRZ) - return parameterStore.get("RZ", name); - else if(projection instanceof AProjection3D) - return parameterStore.get("3D", name); - else if(projection instanceof AProjectionYZ||projection instanceof AProjectionXZ) - return parameterStore.get("XZ", name); - else if(projection instanceof AProjectionFR) - return parameterStore.get("FR", name); - else if(projection instanceof AProjectionFZ) - return parameterStore.get("FZ", name); - else - throw new Error("Fish Eye should be used ONLY in YX, RZ, FZ and FR"); - } - - /** - * Get new FishEye parameter if mouse has moved to p in YX projection - **/ - private void updateYX(Point2D.Double p, int key) { - double r1=Math.sqrt(firstP.x*firstP.x+firstP.y*firstP.y); - double r2=Math.sqrt(p.x*p.x+p.y*p.y); - double rTo=getParameter("rTo").getD(); - - if(r1<rTo&&r2>rTo) return; - if(r2<rTo&&r1>rTo) return; - - double newFishEyeValue=1000*(r2-r1)/(r1*rTo-r1*r2); - - if(newFishEyeValue<0||newFishEyeValue>25) return; - - setValue(newFishEyeValue); - fireFishEyeChange(getStatus(),getValue()); - } - - /** - * Get new FishEye parameter if mouse has moved to p in RZ projection - **/ - private void updateRZ(Point2D.Double p, int key) { - double newFishEyeValue=0; - - switch(key) { - case KeyEvent.VK_UNDEFINED: - case KeyEvent.VK_F: - case KeyEvent.VK_H: - double z1=firstP.x; - double z2=Math.abs(p.x); - double zTo=getParameter("zTo").getD(); - - if(z1<zTo&&z2>zTo) return; - if(z2<zTo&&z1>zTo) return; - - newFishEyeValue=1000*(z2-z1)/(z1*zTo-z1*z2); - break; - - case KeyEvent.VK_V: - double r1=Math.abs(firstP.y); - double r2=Math.abs(p.y); - double rTo=getParameter("rTo").getD(); - - if(r1<rTo&&r2>rTo) return; - if(r2<rTo&&r1>rTo) return; - - newFishEyeValue=1000*(r2-r1)/(r1*rTo-r1*r2); - break; - } - - if(newFishEyeValue<0||newFishEyeValue>25) return; - setValue(newFishEyeValue); - fireFishEyeChange(getStatus(),getValue()); - } - - /** - * Get new FishEye parameter if mouse has moved to p in XZ projection - **/ - private void updateXZ(Point2D.Double p, int key) { - double newFishEyeValue=0; - - switch(key) { - case KeyEvent.VK_UNDEFINED: - case KeyEvent.VK_F: - case KeyEvent.VK_H: - double z1=firstP.x; - double z2=Math.abs(p.x); - double zTo=getParameter("zTo").getD(); - - if(z1<zTo&&z2>zTo) return; - if(z2<zTo&&z1>zTo) return; - - newFishEyeValue=1000*(z2-z1)/(z1*zTo-z1*z2); - break; - - case KeyEvent.VK_V: - double r1=Math.abs(firstP.y); - double r2=Math.abs(p.y); - double rTo=getParameter("yTo").getD(); - - if(r1<rTo&&r2>rTo) return; - if(r2<rTo&&r1>rTo) return; - - newFishEyeValue=1000*(r2-r1)/(r1*rTo-r1*r2); - break; - } - - if(newFishEyeValue<0||newFishEyeValue>25) return; - setValue(newFishEyeValue); - fireFishEyeChange(getStatus(),getValue()); - } - - /** - * Get new FishEye parameter if mouse has moved to p in Phi-R projection - **/ - private void updateFR(Point2D.Double p, int key) { - double r1=firstP.x; - double r2=p.x; - double rTo=getParameter("rTo").getD(); - - if(r1<rTo&&r2>rTo) return; - if(r2<rTo&&r1>rTo) return; - - double newFishEyeValue=1000*(r2-r1)/(r1*rTo-r1*r2); - - if(newFishEyeValue<0||newFishEyeValue>25) return; - - setValue(newFishEyeValue); - fireFishEyeChange(getStatus(),getValue()); - } - - /** - * Get new FishEye parameter if mouse has moved to p in Phi-Z projection - **/ - private void updateFZ(Point2D.Double p, int key) { - double z1=Math.abs(firstP.x); - double z2=Math.abs(p.x); - double zTo=getParameter("zTo").getD(); - - if(z1<zTo&&z2>zTo) return; - if(z2<zTo&&z1>zTo) return; - - double newFishEyeValue=1000*(z2-z1)/(z1*zTo-z1*z2); - - if(newFishEyeValue<0||newFishEyeValue>25) return; - - setValue(newFishEyeValue); - fireFishEyeChange(getStatus(),getValue()); - } - - /** - * Change FishEye parameter for corresponding projection - * if mouse is draged - **/ - public void drag(Point2D.Double p, int region, int key) { - if(!getParameter("FishEye").getStatus()) return; - - AProjection proj=window.getProjection(); - - if(proj instanceof AProjectionYX) - updateYX(p, key); - else if(proj instanceof AProjectionRZ||proj instanceof AProjection3D) - updateRZ(p, key); - else if(proj instanceof AProjectionXZ||proj instanceof AProjectionYZ) - updateXZ(p, key); - else if(proj instanceof AProjectionFR) - updateFR(p, key); - else if(proj instanceof AProjectionFZ) - updateFZ(p, key); - } - - // Empty interface implementations - public void stop() {} - public void start(Point2D.Double p, int region, int key) {} - public void cancel() {} - public void paint(Graphics2D g) {} - - public int getPopupType() { - return APopupListener.WINDOW_POPUP; - } - - /*public void showPopup(Point p, int region) { - popupMenu.show(window, p.x, p.y); - }*/ - - public JMenuItem[] getPopupItems() { - return popupItems; - } - - - /** - * Implementaiton of the ActionListener - * @param e - */ - public void actionPerformed(ActionEvent e) { - String action=e.getActionCommand(); - - if(action.equals(TOGGLE_FISHEYE)) { - //toggle the fisheye status - setStatus(!getStatus()); - //Update the window - window.repaintFromScratch(); - //And the GUI - fireFishEyeChange(getStatus(),getValue()); - } - } - - /** - * Public method so it can be called from the AFishEyeGroup to change the - * fish eye amount to a fixed value - * @param value the new value - */ - public void setValue(double value){ - getParameter("FishEye").setD(value); - } - - /** - * Return FishEye value (e.g to update the FishEye panel) - * @return the fishEye value - */ - public double getValue(){ - return getParameter("FishEye").getD(); - } - - /** - * Public method so it can be called externally from the AFishEyeGroup - * @param status true or false - */ - public void setStatus(boolean status) { - getParameter("FishEye").setStatus(status); - } - - /** - * @return the current fishEye status(true or false) - */ - public boolean getStatus() { - return getParameter("FishEye").getStatus(); - } - - /** - * Gets called each time we enter a window in which this interaction is active - */ - public void entered(){ - //Set mouse cursor - window.setCursor(ACursorFactory.getInstance().getFishEyeCursor()); - } - - /** - * Gets called each time we leave a window in which this interaction is active - */ - public void exited(){ - //Set mouse cursor - window.setCursor(ACursorFactory.getInstance().getDefaultCursor()); - } - - /** - * Return modifier keys for this projection - * - F for Fast (only detectors are update) - * - V for react only to Vertical mouse movement (only in RZ and XZ projection) - * - H for react only to Horizontal mouse movement (only in RZ and XZ projection, default) - **/ - public AModifier[] getModifiers(){ - if(window.getProjection() instanceof AProjectionRZ || - window.getProjection() instanceof AProjectionXZ) { - return new AModifier[] { - new AModifier(KeyEvent.VK_F, false, "Fast (data not drawn)"), - new AModifier(KeyEvent.VK_V, false, "Vertically defined FishEye"), - new AModifier(KeyEvent.VK_UNDEFINED, false, "Horizontally defined FishEye"), - new AModifier(KeyEvent.VK_H, false, "Horizontally defined FishEye") - }; - } else { - - return new AModifier[] { - new AModifier(KeyEvent.VK_F, false, "Fast (data not drawn)") - }; - } - } - - /** - * Add a new listener for FishEyeChange incidents - * @param listener to be added to list - */ - public void addFishEyeChangeListener(AFishEyeChangeListener listener) { - //Add this listener - fishEyeChangeListeners.addElement(listener); - //And bring it up to date - listener.fishEyeChange(getStatus(), getValue()); - - } - - /** - * Remove a listener from the liste - * @param listener to be removed from list - */ - public void removeFishEyeChangeListener(AFishEyeChangeListener listener) { - //Remove this listener - fishEyeChangeListeners.removeElement(listener); - } - - /** - * Call fishEyeChange method of all FishEyeChange listeners - * @param status the new fisheye status - * @param value the new fisheye value - */ - private void fireFishEyeChange(boolean status, double value) { - - // Loop over all listeners - for (AFishEyeChangeListener listener : fishEyeChangeListeners) - { - // give them the new status - listener.fishEyeChange(status,value); - } - } - -} - diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AInteraction.java b/graphics/AtlantisJava/src/atlantis/interactions/AInteraction.java deleted file mode 100755 index 446aedc3f93bf836fb861918629370266817b72b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AInteraction.java +++ /dev/null @@ -1,323 +0,0 @@ -package atlantis.interactions; - -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.geom.Point2D; -import java.awt.geom.RectangularShape; -import java.awt.Point; -import javax.swing.JPopupMenu; -import javax.swing.JMenuItem; - -import atlantis.canvas.AWindow; -import atlantis.graphics.ADrawParameters; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.gui.APopupHelper; -import atlantis.parameters.APar; -import atlantis.utils.APolygon; - -/** - * The abstract supperclass of all the Atlantis interactions. - */ -public abstract class AInteraction -{ - protected static APar parameterStore = APar.instance(); - - /** When the inteaction does'nt need repainting */ - public final static int NO_REPAINT = 0; - - /** - * When the inteaction needs an automatic repainting (acoording to its hot - * regions) - */ - public final static int AUTOMATIC_REPAINT = 1; - - /** When the inteaction needs an repaint of all windows */ - public final static int ALL_WINDOWS_REPAINT = 3; - - /** When the inteaction needs to reapint from scratch its window */ - public final static int WINDOW_TOTAL_REPAINT = 4; - - /** - * The constant used to specify that the interaction wants SCREEN - * COORDINATES - */ - public final static int SCREEN_COORDINATES = 0; - - /** The constant used to specify that the interaction wants WORLD COORDINATES */ - public final static int WORLD_COORDINATES = 1; - - protected final static ADrawParameters frameDrawParameters = new ADrawParameters(true, AColorMap.BK, 4, 1, 1, AGraphics.SYMBOL_FILLED_BOX); - - protected final static ADrawParameters drawParameters = new ADrawParameters(true, AColorMap.WH, 4, 1, 0, AGraphics.SYMBOL_FILLED_BOX); - - protected AWindow window; - protected static final int ctrlPtSize = 1; - protected RectangularShape[] hr; - protected Point2D.Double[] pt; - protected Rectangle oldAffectedRegion; - protected int hotRegionsCount; - protected int repaintMode; - protected int coordinatesType; - protected boolean isPrintable; - - /** - * Creates a new Interaction. - * - * @param hotRegionsCount The number of hot regions used be the interaction - * @param repaintMode The type of repaint wanted. Could be: NO_REPAINT, - * AUTOMATIC_REPAINT, WINDOW_REPAINT, ALL_WINDOWS_REPAINT, - * WINDOW_TOTAL_REPAINT, ALL_WINDOWS_TOTAL_REPAINT. - * @param coordinatesType Could be: SCREEN_COORDINATES, WORLD_COORDINATES. - * @param isPrintable A boolean which indicates whether or not this - * interaction should be printable. - */ - public AInteraction(int hotRegionsCount, int repaintMode, int coordinatesType, boolean isPrintable) - { - - this.hotRegionsCount = hotRegionsCount; - this.repaintMode = repaintMode; - this.coordinatesType = coordinatesType; - this.isPrintable = isPrintable; - - hr = new RectangularShape[hotRegionsCount]; - - /* - * pt = new Point2D.Double[getPointsToIncludeCount()]; for (int i = 0; i < - * pt.length; i++) pt[i] = new Point2D.Double(0, 0); - */ - } - - /** - * Called by the InteractionsManager when the interaction gets connected to - * it. - */ - public void connect(AInteractionsManager manager) - { - this.window = manager.getWindow(); - } - - /** - * Called by the InteractionsManager when the interaction gets disconnected - * from it. - */ - public void disconnect() - { - this.window = null; - } - - /** - * Called by the window on which this interaction works in order to allow - * the interaction to draw on it. - * - * @param g The graphical context on which to draw. - */ - public abstract void paint(Graphics2D g); - - /** - * This method should convert any hot region used by interaction from user - * coordinates to screen coordinates. - * - * @param region The number of the hot region which needs to be converted. - * @return The new RectangularShape object which contains the converted - * region. - */ - public RectangularShape getScreenHotRegion(int region) - { - switch (coordinatesType) - { - case AInteraction.SCREEN_COORDINATES: - return hr[region]; - - case AInteraction.WORLD_COORDINATES: - RectangularShape screenShape = (RectangularShape) hr[region].clone(); - Point2D.Double center = window.calculateDisplay(screenShape.getCenterX(), screenShape.getCenterY()); - double w = screenShape.getWidth(); - double h = screenShape.getHeight(); - - screenShape.setFrame(center.x - w / 2, center.y - w / 2, w, h); - return screenShape; - - default: - return null; - } - } - - /** - * Returns an APolygon made up of the first 4 Hot Regions. - * - * @return The APolygon. - */ - public APolygon getAPolygon() - { - APolygon p = new APolygon(); - - for (int i = 0; i < 4; i++) - p.addPoint(hr[i].getCenterX(), hr[i].getCenterY()); - - return p; - } - - /** - * Sets the x-coordinate of the center of a RectangularShape. - * - * @param shape The shape to set the center to. - * @param x The new x-coordinate of the center. - */ - protected void setCenterX(RectangularShape shape, double x) - { - double w = shape.getWidth(); - double h = shape.getHeight(); - - shape.setFrame(x - w / 2, shape.getY(), w, h); - } - - /** - * Sets the y-coordinate of the center of a RectangularShape. - * - * @param shape The shape to set the center to. - * @param y The new y-coordinate of the center. - */ - protected void setCenterY(RectangularShape shape, double y) - { - double w = shape.getWidth(); - double h = shape.getHeight(); - - shape.setFrame(shape.getX(), y - h / 2, w, h); - } - - /** - * Sets the center of a RectangularShape to (x, y). - * - * @param shape The shape to set the center to. - * @param x The new x-coordinate of the center. - * @param y The new y-coordinate of the center. - */ - protected void setCenter(RectangularShape shape, double x, double y) - { - double w = shape.getWidth(); - double h = shape.getHeight(); - - shape.setFrame(x - w / 2, y - h / 2, w, h); - } - - /** - * Returns the center of an arbitrary hot-region. - * - * @param s The RectangularShape object the center of which is required - * @return The center in double format - */ - public Point2D.Double getCenter(RectangularShape s) - { - return new Point2D.Double(s.getCenterX(), s.getCenterY()); - } - - /** - * Returns the distance between two hot-regions. The result depends on the - * coordinates type. - * - * @param region1 The first region - * @param region2 The second region - * @return The distance - */ - protected double getRadius(int region1, int region2) - { - double dx = hr[region1].getCenterX() - hr[region2].getCenterX(); - double dy = hr[region1].getCenterX() - hr[region2].getCenterY(); - - return Math.sqrt(dx * dx + dy * dy); - } - - /** - * Returns the distance between a point and a hot-regions. The result - * depends on the coordinates type. - * - * @param x The x coordinate of the point - * @param y The y coordinate of the point - * @param region The region index to be used to get the region itself - * @return The distance - */ - protected double getRadius(double x, double y, int region) - { - double dx = x - hr[region].getCenterX(); - double dy = y - hr[region].getCenterY(); - - return Math.sqrt(dx * dx + dy * dy); - } - - /** - * Returns the distance between the center (0, 0) and a hot-regions. The - * result depends on the coordinates type. - * - * @param s The hot-region - * @return The distance - */ - protected double getRadius(RectangularShape s) - { - return s.getCenterX() * s.getCenterX() + s.getCenterY() * s.getCenterY(); - } - - /** - * Retirns the angle made by the line connecting the two hot-regions and the - * horizontal axis. - * - * @param region1 The first region - * @param region2 The second region - * @return the angle in radians. - */ - protected double getAngle(int region1, int region2) - { - double dx = hr[region1].getCenterX() - hr[region2].getCenterX(); - double dy = hr[region1].getCenterY() - hr[region2].getCenterY(); - - if (dx != 0 || dy != 0) - // is this correct - return Math.atan2(dx, dy); - else - return 0.; - } - - protected void drawActivePoint(double x, double y, AGraphics g) - { - g.updateDrawParameters(frameDrawParameters); - g.drawSymbol(x, y); - g.updateDrawParameters(drawParameters); - g.drawSymbol(x, y); - } - - protected void drawActivePoint(int region, AGraphics g) - { - g.updateDrawParameters(frameDrawParameters); - g.drawSymbol(hr[region].getCenterX(), hr[region].getCenterY()); - g.updateDrawParameters(drawParameters); - g.drawSymbol(hr[region].getCenterX(), hr[region].getCenterY()); - } - - protected void drawLine(int region1, int region2, AGraphics g) - { - g.drawLine(hr[region1].getCenterX(), hr[region1].getCenterY(), hr[region2].getCenterX(), hr[region2].getCenterY()); - } - - public boolean isPrintable() - { - return isPrintable; - } - - public AModifier[] getModifiers() - { - return new AModifier[0]; - } - - public void showPopupMenu(Point p, int region) { - APopupHelper.showPopupMenu(p, window, getPopupItems()); - } - - public JPopupMenu getPopupMenu() { - return APopupHelper.getPopupMenu(getPopupItems()); - } - - public JMenuItem[] getPopupItems() { - return null; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AInteractionGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/AInteractionGroup.java deleted file mode 100755 index fece4376137fe0837d3b49cf17e88eebe0224a21..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AInteractionGroup.java +++ /dev/null @@ -1,143 +0,0 @@ -package atlantis.interactions; - -import atlantis.canvas.ACanvas; -import atlantis.parameters.APar; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import java.util.Vector; - - -/** - * The InteractionGroup groups interactions of the same kind under a single - * object. The InteractionToolBar deals with the InteractionGroups instead - * of dealing with the interactions directly. - */ -public abstract class AInteractionGroup { - protected static APar parameterStore = APar.instance(); - - /** A group type which once made current affects only the window in which it works*/ - public static final int WINDOW_GROUP=0; - - /** A group type which once made current affects all the windows of the Canvas*/ - public static final int CANVAS_GROUP=1; - - protected String name; - protected String toolTip; - protected AInteractionsManager iManager; - private int groupType; - private boolean isCurrent=false; - private Vector<AInteraction> interactions; - - /** - * Creates an InteractionGroup of a specific type - * and connected to some InteractionsManager - * @param groupType The type of the interface. Can be: WINDOW_GROUP or CANVAS_GROUP - * @param iManager The InteractionsManager to which this group will be connected. - */ - public AInteractionGroup(int groupType, AInteractionsManager iManager) { - - this.groupType=groupType; - this.iManager=iManager; - - interactions=new Vector<AInteraction>(); - } - - public void setGroupName(String name) { - this.name=name; - } - - public String getGroupName() { - return name; - } - - public void setToolTip(String toolTip) { - this.toolTip=toolTip; - } - - public String getToolTip() { - return toolTip; - } - - public JMenuItem getPopupItem() { - JMenuItem item=new JMenuItem(name); - - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - ACanvas.getCanvas().getCurrentWindow().getInteractionToolBar().setSelectedGroup(name); - } - }); - - return item; - } - - /** - * Called by the InteractionsManager when the group gets connected to it. - */ - public void connect() {} - - /** - * Called by the InteractionsManager when the group gets disconnected from it. - */ - public void disconnect() {} - - public boolean isWindowGroup() { - return(groupType==WINDOW_GROUP); - } - - public boolean isCanvasGroup() { - return(groupType==CANVAS_GROUP); - } - - /** - * Checks if any additional controls are provided by the current interaction group - * @return true if the interaction group has additional controls - */ - public boolean hasAdditionalControls() { return false; } - - /** - * Returns the additional controls for the current interaction group - * @return the panel containing the additional controls - */ - - public JPanel getAdditionalControls() { return new JPanel(); } - - /** - * Registers a new interaction which will be available with this group. - * @param i The Interaction to be registered. - */ - protected void addInteraction(AInteraction i) { - interactions.addElement(i); - if(isCurrent) - iManager.setContext(this); - } - - /** - * Removes a previously registered interaction from the group. - * @param i The Interaction to be removed. - */ - protected void removeInteraction(AInteraction i) { - interactions.remove(i); - } - - /** - * Removes all previously registered interactions from the group. - */ - protected void removeAllInteractions() { - interactions.clear(); - } - - public Vector<AInteraction> getInteractions() { - return interactions; - } - - /** - * Used to help copying of group. The group should set its internal state to be - * the same as the state of the given group. - * @param givenGroup The group to be copied. - */ - public void setGroupState(AInteractionGroup givenGroup) {} - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AInteractionsConfigReader.java b/graphics/AtlantisJava/src/atlantis/interactions/AInteractionsConfigReader.java deleted file mode 100644 index 8b4dcaeb95f3e5a7c2e5c3dc307410a5613792dd..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AInteractionsConfigReader.java +++ /dev/null @@ -1,69 +0,0 @@ -package atlantis.interactions; - -import java.util.Hashtable; -import java.util.Map.Entry; -import java.util.Set; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import atlantis.projection.AProjectionsManager; - -/** - * Handles the "Interactions" node in the XML configuration file: - * <ul> - * <li>store the InteractionControl node for each projection</li> - * <li>process the lists of available/default projections in demo mode</li> - * </ul> - * - * @author waugh - */ -public class AInteractionsConfigReader { - - /** The set of XML nodes with projection information (name : node). */ - private final static Hashtable<String,Node> projectionNodes = new Hashtable<String, Node>(); - - /** - * Read and process the Interactions information from the XML configuration file. - * - * @param node The XML Node which contains the <bold>Interactions</bold> node. - */ - public static void readInteractions(Node node) { - initProjectionNodes(node); - setAvailableProjectionsInDemoMode(); - } - - /** - * Get the configuration XML node corresponding to a given projection. - * - * @param projectionName the name of the projection - * @return the corresponding InteractionControl node - */ - public static Node getNode(String projectionName) { - return projectionNodes.get(projectionName); - } - - private static void initProjectionNodes(Node node) { - NodeList childNodes=node.getChildNodes(); - for(int i=0; i<childNodes.getLength(); i++) { - Node child=childNodes.item(i); - - if(child.getNodeType()==Node.ELEMENT_NODE) { - String name=child.getAttributes().getNamedItem("projectionName").getNodeValue(); - projectionNodes.put(name, child); - } - } - } - - private static void setAvailableProjectionsInDemoMode() { - Set<Entry<String, Node>> entries = projectionNodes.entrySet(); - for (Entry<String,Node> entry : entries) { - String name = entry.getKey(); - Node node = entry.getValue(); - boolean availableInDemoMode = node.getAttributes().getNamedItem("availableInDemoMode").getNodeValue().equals("YES"); - boolean defaultInDemoMode = node.getAttributes().getNamedItem("defaultInDemoMode").getNodeValue().equals("YES"); - if (availableInDemoMode) AProjectionsManager.makeProjectionAvailableInDemoMode(name); - if (defaultInDemoMode) AProjectionsManager.makeProjectionDefaultInDemoMode(name); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AInteractionsManager.java b/graphics/AtlantisJava/src/atlantis/interactions/AInteractionsManager.java deleted file mode 100755 index 40b0a2d484fb3688d86ef48bf95311c199a1c892..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AInteractionsManager.java +++ /dev/null @@ -1,535 +0,0 @@ -package atlantis.interactions; - -import java.awt.Rectangle; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.awt.event.WindowFocusListener; -import java.awt.event.WindowEvent; -import java.awt.geom.Point2D; -import java.awt.geom.RectangularShape; -import java.util.LinkedList; -import java.util.Vector; - -import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; -import javax.swing.JMenuItem; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.gui.AEventQueue; -import atlantis.gui.AInteractionToolBar; -import atlantis.gui.APointerPositionWindow; -import atlantis.gui.APreferencesControl; -import atlantis.projection.AProjectionTrackResidual; -import atlantis.projection.AProjectionLegoPlot; -import atlantis.projection.AProjection2D; - -/** - * The InteractionsManager connects to the corresponding window in order to - * provide basic functionality to the interactions. - */ -public class AInteractionsManager -implements MouseListener, MouseMotionListener, WindowFocusListener { - - public final static int LEFT=0; - public final static int MIDDLE=1; - public final static int RIGHT=2; - public final static int ALL=3; - - private final static int safetySize=5; - - private AWindow window; //The window that is monitored by this interaction manager - private LinkedList<AInteraction> interactions; //A list of all the interactions linked to this manager - private AInteraction dragInter; - private int dragInterHotRegion; -// private AInteraction mcInteraction; //This one is set but not used by anything -// private int mcRegion; //This one is set but not used by anything - private RectangularShape[] old_hr; - private AInteractionGroup previousInterface; - private AModifier[] mouseModifiers; - private boolean origAlias=false; - - /** - * Creates an InteractionsManager to work with a specific window. - * @param _window The window with wich the InteractionsManager should work. - */ - public AInteractionsManager(AWindow _window) { - this.window=_window; - - interactions=new LinkedList<AInteraction>(); -// mcInteraction=null; -// mcRegion=-1; - - window.addMouseListener(this); - window.addMouseMotionListener(this); - - mouseModifiers=new AModifier[] { - new AModifier(KeyEvent.VK_O, true, "Output of pointer position"), - new AModifier(KeyEvent.VK_W, true, "Window Menu pops up"), - new AModifier(KeyEvent.VK_I, true, "Interaction Manager pops up"), - new AModifier(KeyEvent.VK_UNDEFINED, true, "Interaction Menu pops up") - }; - } - - public AModifier[] getMouseModifiers() { - return mouseModifiers; - } - - // Implementation of MouseListener - - public void mousePressed(MouseEvent e) { - - if(!ACanvas.getCanvas().getCurrentWindow().equals(window)) - ACanvas.getCanvas().setCurrentWindow(window.getName()); - - if(AInteractionsManager.isIntRightMouseButton(e)) - switch(AEventQueue.getKeyboardState()) { - - case KeyEvent.VK_W: - if(!(window.getProjection() instanceof AProjectionTrackResidual)) - AWindow.getPopupMenu().show(window, e.getX(), e.getY()); - return; - - case KeyEvent.VK_I: - JPopupMenu menu=AInteractionToolBar.getInteractionMenu(window); - - menu.show(window, e.getX(), e.getY()); - return; - - case KeyEvent.VK_O: - Point2D.Double position =window.calculateUser(e.getX(),e.getY()); - //If LegoPlot need to alter phi coord using reverse of the adjustPhi function - if( window.getProjection() instanceof AProjectionLegoPlot) - position.x=-AProjectionLegoPlot.adjustPhi(window,-position.x,position.y); - //Apply inverse non-linear transforms, if in 2D projection - if ( window.getProjection() instanceof AProjection2D) - position = ((AProjection2D)window.getProjection()).inverseNonLinearTransform(position); - //Add labels - String positionX = window.getProjection().getXLabel() + parseUnits(position.x, window.getProjection().getXUnits()); - String positionY = window.getProjection().getYLabel() + parseUnits(position.y, window.getProjection().getYUnits()); - APreferencesControl.setPosMenuItem(true);//shows window if not already visible - APointerPositionWindow.getInstance().toFront();//brings to front - APointerPositionWindow.append(positionX + ", " + positionY + "\n"); - return; - } - - processMousePressed(e); - - if(dragInter!=null) { - dragInter.hr=old_hr; - ((AMouseDragListener)dragInter).cancel(); -// if(dragInter instanceof AEnterExitListener) -// ((AEnterExitListener)dragInter).exited(dragInterHotRegion); - repaintInteraction(dragInter); - dragInter=null; - return; - } - - if(AInteractionsManager.isIntRightMouseButton(e)) - if(processPopupShow(e)) - return; - - if(setupDraggingByHotRegion(e)) return; - if(initializeSleepingInteraction(e)) return; - } - - private boolean processPopupShow(MouseEvent e) { - for(int i=interactions.size()-1; i>=0; i--) { - AInteraction interaction=(AInteraction)interactions.get(i); - - for(int region=0; region<interaction.hr.length; region++) { - if(interaction.getScreenHotRegion(region).contains(e.getPoint())) { - interaction.showPopupMenu(e.getPoint(), region); - return true; - } - } - } - - for(int i=interactions.size()-1; i>=0; i--) { - AInteraction interaction=(AInteraction)interactions.get(i); - - //Turn off right click menu for pick interaction - JMenuItem[] projmenu = (interaction instanceof APickInteraction) ? null : window.getProjection().getPopupItems(); - JMenuItem[] intmenu = (interaction instanceof APickInteraction) ? null : interaction.getPopupItems(); - - JPopupMenu finalmenu = new JPopupMenu(); - - // Combine projection and interaction menus - for (int it = 0; intmenu != null && it < intmenu.length; it++) { - finalmenu.add(intmenu[it]); - } - - if (projmenu != null && projmenu.length > 0 && - intmenu != null && intmenu.length > 0) { - - finalmenu.addSeparator(); - } - - for (int it = 0; projmenu != null && it < projmenu.length; it++) { - finalmenu.add(projmenu[it]); - } - - if (finalmenu.getComponentCount() != 0) { - finalmenu.show(window, (int)e.getPoint().getX(), (int)e.getPoint().getY()); - } - } - - return false; - } - - public void mouseReleased(MouseEvent e) { - if(dragInter!=null) { - ((AMouseDragListener)dragInter).stop(); -// if(dragInter instanceof AEnterExitListener) -// ((AEnterExitListener)dragInter).exited(dragInterHotRegion); - repaintInteraction(dragInter); - dragInter=null; - } - //reset anti-alias - if(origAlias && !(dragInter instanceof ASelection)) - APreferencesControl.setAliasMenuItem(true); - } - - public void mouseClicked(MouseEvent e) {} - - /** - * This function is called each time we enter the window this interaction manager is assigned to - */ - public void mouseEntered(MouseEvent e) { - - //Loop over interaction list from the end - for(int i=interactions.size()-1; i>=0; i--) { - - //get the interaction - AInteraction interaction=(AInteraction)interactions.get(i); - - //Check if this one listens to Enter/Exit events - if (interaction instanceof AEnterExitListener){ - ((AEnterExitListener)interaction).entered(); - } - } - } - - /** - * This function is called each time we exit the window this interaction manager is assigned to - */ - public void mouseExited(MouseEvent e) { - - //Loop over interaction list from the end - for(int i=interactions.size()-1; i>=0; i--) { - - //get the interaction - AInteraction interaction=(AInteraction)interactions.get(i); - - //Check if this one listens to Enter/Exit events - if (interaction instanceof AEnterExitListener) - ((AEnterExitListener)interaction).exited(); - } - } - - private void processMousePressed(MouseEvent e) { - //update if using anti-alias so can switch off during drag - if(!(dragInter instanceof ASelection)) - origAlias = APreferencesControl.getAliasMenuItem(); - for(int i=interactions.size()-1; i>=0; i--) { - AInteraction interaction=(AInteraction)interactions.get(i); - - if(!(interaction instanceof AMousePressListener)) continue; - AMousePressListener clickListener=(AMousePressListener)interaction; - - if(clickListener.getPressButton()!=AInteractionsManager.ALL) - if(clickListener.getPressButton()!=getButton(e)) continue; - Point2D.Double p=null; - - switch(interaction.coordinatesType) { - case AInteraction.SCREEN_COORDINATES: - p=new Point2D.Double(e.getX(), e.getY()); - break; - - case AInteraction.WORLD_COORDINATES: - // p = window.calculateUser(inverseNonLinearTransform(e.getPoint())); - p=window.calculateUser(e.getPoint()); - break; - } - clickListener.pressed(p, getButton(e), AEventQueue.getKeyboardState()); - setTopZOrder(interaction); - repaintInteraction(interaction); - } - } - - // Implementation of MouseMotionListener - - public void mouseDragged(MouseEvent e) { - if(dragInter==null) return; - - //switch off anti-alias - if(origAlias && !(dragInter instanceof ASelection)) - APreferencesControl.setAliasMenuItem(false); - Point2D.Double p=new Point2D.Double(e.getX(), e.getY()); - - if(dragInter.coordinatesType==AInteraction.WORLD_COORDINATES) - // p = dragInter.manager.getWindow().calculateUser(inverseNonLinearTransform(p)); - p=window.calculateUser(p); - - ((AMouseDragListener)dragInter).drag(p, dragInterHotRegion, AEventQueue.getKeyboardState()); - repaintInteraction(dragInter); - } - - //This function is called every time the mouse is moved on the window - public void mouseMoved(MouseEvent e) { - } - - // Implementation of WindowsFocusListener - - /** - * Get called each time the canvas has obtained a focus - */ - public void windowGainedFocus(WindowEvent e) { - //Check if the mouse is over this window (or any of its children) - if (getWindow().getMousePosition(true) != null){ - //raise a mouseEntered event, so the cursor gets updated - this.mouseEntered(null); - } - } - - /** - * Get called each time the canvas has lost a focus - */ - public void windowLostFocus(WindowEvent e) {} - - //Methods belonging to this class - - /** - * Returns all the interactions associated with this InteractionsManager. - * @return The LinkedList containing the interactions. - * DO NOT CHANGE THIS LINKEDLIST, JUST READ IT. - */ - public LinkedList<AInteraction> getInteractions() { - return interactions; - } - - public AWindow getWindow() { - return window; - } - - /** - * This function disconnects the current pannel and all it's - * interactions from the InteractionsManager. - */ - public void forgetContext() { - // Disconnect all the old interactions - if(previousInterface!=null) previousInterface.disconnect(); - for(int i=0; i<interactions.size(); i++) { - AInteraction inter=(AInteraction)interactions.get(i); - - inter.disconnect(); - } - - // Clear the list and repaint the window - interactions.clear(); - window.repaint(); - } - - /** - * Sets the current interaction interface and adds its interactions to the list - * (removing first the old interface and its interactions). - * @param iFace The new interface. - */ - public void setContext(AInteractionGroup iFace) { - forgetContext(); - - if(iFace!=null) - { - // add to the list, connect and repaint the new interactions - Vector<AInteraction> iFaceInter=iFace.getInteractions(); - - for(int i=0; i<iFaceInter.size(); i++) { - AInteraction inter=(AInteraction)iFaceInter.get(i); - interactions.addLast(inter); - inter.connect(this); - repaintInteraction(inter); - } - - iFace.connect(); - } - previousInterface=iFace; - } - - private void repaintInteraction(AInteraction interaction) { - switch(interaction.repaintMode) { - case AInteraction.NO_REPAINT: - return; - - case AInteraction.ALL_WINDOWS_REPAINT: - window.repaint(); - ACanvas.getCanvas().repaintOthers(window); - return; - - case AInteraction.WINDOW_TOTAL_REPAINT: - window.repaintFromScratch(); - return; - - case AInteraction.AUTOMATIC_REPAINT: - Rectangle regionToRedraw=interaction.getScreenHotRegion(0).getBounds(); - - for(int i=1; i<interaction.hr.length; i++) - regionToRedraw.add(interaction.getScreenHotRegion(i).getBounds()); - - if((interaction.pt!=null)&&(interaction.pt.length!=0)) - for(int i=0; i<interaction.pt.length; i++) - regionToRedraw.add(getScreenPointToInclude(interaction, i)); - - regionToRedraw.x-=safetySize; - regionToRedraw.y-=safetySize; - regionToRedraw.width+=2*safetySize; - regionToRedraw.height+=2*safetySize; - - if(interaction.oldAffectedRegion==null) - window.repaint(regionToRedraw); - else - window.repaint(SwingUtilities.computeUnion(interaction.oldAffectedRegion.x, - interaction.oldAffectedRegion.y, interaction.oldAffectedRegion.width, - interaction.oldAffectedRegion.height, new Rectangle(regionToRedraw))); - - interaction.oldAffectedRegion=regionToRedraw; - return; - } - } - - /** - * This method converts the specified "point to include" from user - * coordinates to screen coordinates. - * If the point is already in screen coordinates it just returns it. - */ - private Point2D.Double getScreenPointToInclude(AInteraction interaction, int n) { - switch(interaction.coordinatesType) { - case AInteraction.SCREEN_COORDINATES: - return interaction.pt[n]; - - case AInteraction.WORLD_COORDINATES: - return window.calculateDisplay(interaction.pt[n]); - - default: - return null; - } - } - - private boolean setupDraggingByHotRegion(MouseEvent e) { - for(int i=interactions.size()-1; i>=0; i--) { - AInteraction interaction=(AInteraction)interactions.get(i); - - if(!(interaction instanceof AMouseDragListener)) continue; - AMouseDragListener dInter=(AMouseDragListener)interaction; - - if(dInter.getButton()!=getButton(e)) continue; - - for(int j=0; j<interaction.hr.length; j++) { - if(interaction.getScreenHotRegion(j).contains(e.getPoint())) { - dragInter=interaction; - dragInterHotRegion=j; - - old_hr=new RectangularShape[dragInter.hr.length]; - for(int region=0; region<dragInter.hr.length; region++) - old_hr[region]=(RectangularShape)dragInter.hr[region].clone(); - - Point2D.Double p=new Point2D.Double(e.getX(), e.getY()); - - if(interaction.coordinatesType==AInteraction.WORLD_COORDINATES) - p=window.calculateUser(p); - - // add this statement to guarantee "p0" in AZMRInteraction is initialized - // maybe need more analysis here - if(dragInter instanceof AZMRInteraction) - ((ASleepMouseDragListener)dragInter).init(p, AEventQueue.getKeyboardState()); - - setTopZOrder(dragInter); - ((AMouseDragListener)dragInter).start(p, dragInterHotRegion, AEventQueue.getKeyboardState()); - repaintInteraction(dragInter); - return true; - } - } - } - return false; - } - - private boolean initializeSleepingInteraction(MouseEvent e) { - for(int i=interactions.size()-1; i>=0; i--) { - AInteraction interaction=(AInteraction)interactions.get(i); - - if(interaction instanceof ASleepMouseDragListener) { - ASleepMouseDragListener sdListener=(ASleepMouseDragListener)interaction; - - if(sdListener.getButton()==getButton(e)) { - dragInter=interaction; - - old_hr=new RectangularShape[dragInter.hr.length]; - for(int region=0; region<dragInter.hr.length; region++) - old_hr[region]=(RectangularShape)dragInter.hr[region].clone(); - - Point2D.Double p=new Point2D.Double(e.getX(), e.getY()); - - if(interaction.coordinatesType==AInteraction.WORLD_COORDINATES) - p=window.calculateUser(p); - - dragInterHotRegion=((ASleepMouseDragListener)dragInter).init(p, AEventQueue.getKeyboardState()); - - setTopZOrder(dragInter); - ((AMouseDragListener)dragInter).start(p, dragInterHotRegion, AEventQueue.getKeyboardState()); -// if(dragInter instanceof AEnterExitListener) -// ((AEnterExitListener)dragInter).entered(dragInterHotRegion); - - repaintInteraction(dragInter); - return true; - } - } - } - - return false; - } - - private void setTopZOrder(AInteraction ineraction) { - interactions.remove(ineraction); - interactions.addLast(ineraction); - repaintInteraction((AInteraction)interactions.getLast()); - } - - private int getButton(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) - return LEFT; - else if(SwingUtilities.isMiddleMouseButton(e)) - return MIDDLE; - else if(AInteractionsManager.isIntRightMouseButton(e)) - return RIGHT; - else - return -1; - } - - private static boolean isIntRightMouseButton(MouseEvent e) - { - return SwingUtilities.isRightMouseButton(e) || - AEventQueue.getIntRightMouseButton(); - } - - private String parseUnits(double d, String units) - { - //covert units and value units shown are cm by default - double abs = Math.abs(d); - if(units.equals("(cm)")) - { - if (abs >= 100.) - return ": " + Math.rint(1000. * d / 100.) / 1000. + " m"; - else if (abs >= 1.) - return ": " + Math.rint(1000. * d / 1.) / 1000. + " cm"; - else if (abs >= 0.1) - return ": " + Math.rint(1000. * d / 0.1) / 1000. + " mm"; - else - return ": " + Math.rint(d / 0.0001) + " um"; - } - else - { - return ": " + Math.rint(1000. * d / 1.) / 1000. + units; - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ALineSegment.java b/graphics/AtlantisJava/src/atlantis/interactions/ALineSegment.java deleted file mode 100755 index 7fe3cfe1acf8737533c23c7c5567b59eaf85c3e0..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ALineSegment.java +++ /dev/null @@ -1,165 +0,0 @@ -package atlantis.interactions; - - -import atlantis.utils.AVector; -import java.awt.geom.*; - - -/** - * A implementation of the java.awt.RectangularShape which - * represents a segment of a line. - */ -public class ALineSegment extends RectangularShape implements PathIterator { - - Point2D.Double p1; - Point2D.Double p2; - double thickness; - - public ALineSegment(Point2D.Double p1, Point2D.Double p2, double thickness) { - this.p1=p1; - this.p2=p2; - this.thickness=thickness; - } - - public ALineSegment(double x1, double y1, double x2, double y2, double thickness) { - this.p1=new Point2D.Double(x1, y1); - this.p2=new Point2D.Double(x2, y2); - this.thickness=thickness; - } - - private Point2D.Double[] calculateNodes() { - AVector v1=new AVector(p1, p2).makeUnitary().scale(thickness/2).rotate(Math.PI/2); - AVector v2=new AVector(p1, p2).makeUnitary().scale(thickness/2).rotate(-Math.PI/2); - - Point2D.Double[] p=new Point2D.Double[4]; - - p[0]=new Point2D.Double(p1.x+v1.dx, p1.y+v1.dy); - p[1]=new Point2D.Double(p2.x+v1.dx, p2.y+v1.dy); - p[2]=new Point2D.Double(p2.x+v2.dx, p2.y+v2.dy); - p[3]=new Point2D.Double(p1.x+v2.dx, p1.y+v2.dy); - - return p; - } - - public Rectangle2D getBounds2D() { - Point2D.Double[] p=calculateNodes(); - - double minX, minY, maxX, maxY; - - minX=maxX=p[0].x; - minY=maxY=p[0].y; - - for(int i=1; i<p.length; i++) { - if(p[i].x<minX) minX=p[i].x; - if(p[i].x>maxX) maxX=p[i].x; - if(p[i].y<minY) minY=p[i].y; - if(p[i].y>maxY) maxY=p[i].y; - } - - return new Rectangle2D.Double(minX, minY, maxX-minX, maxY-minY); - } - - public boolean contains(double x, double y) { - boolean c=false; - Point2D.Double[] p=calculateNodes(); - - for(int i=0, j=p.length-1; i<p.length; j=i++) - if((((p[i].y<=y)&&(y<p[j].y))||((p[j].y<=y)&&(y<p[i].y))) - &&(x<(p[j].x-p[i].x)*(y-p[i].y)/(p[j].y-p[i].y)+p[i].x) - ) c=!c; - - return c; - } - - public boolean intersects(double x, double y, double w, double h) { - return false; - } - - public boolean contains(double x, double y, double w, double h) { - return false; - } - - public PathIterator getPathIterator(AffineTransform at) { - lineNumber=-1; - return this; - } - - public void setFrame(double x, double y, double w, double h) {} - - public boolean isEmpty() { - return false; - } - - public double getWidth() { - return getBounds2D().getWidth(); - } - - public double getHeight() { - return getBounds2D().getHeight(); - } - - public double getX() { - return getBounds2D().getX(); - } - - public double getY() { - return getBounds2D().getY(); - } - - // PathIterator implementation - int lineNumber; - - // Returns the coordinates and type of the current path segment in the iteration. - public int currentSegment(double[] coords) { - Point2D.Double[] p=calculateNodes(); - - if(lineNumber==-1) { - coords[0]=p[0].x; - coords[1]=p[0].y; - return PathIterator.SEG_MOVETO; - } - - if(lineNumber==4) return PathIterator.SEG_CLOSE; - - coords[0]=p[lineNumber].x; - coords[1]=p[lineNumber].y; - return PathIterator.SEG_LINETO; - } - - public int currentSegment(float[] coords) { - Point2D.Double[] p=calculateNodes(); - - if(lineNumber==-1) { - coords[0]=(float)p[0].x; - coords[1]=(float)p[0].y; - return PathIterator.SEG_MOVETO; - } - - if(lineNumber==4) return PathIterator.SEG_CLOSE; - - coords[0]=(float)p[lineNumber].x; - coords[1]=(float)p[lineNumber].y; - return PathIterator.SEG_LINETO; - } - - // Returns the winding rule for determining the interior of the path. - public int getWindingRule() { - return PathIterator.WIND_NON_ZERO; - } - - public boolean isDone() { - if(lineNumber>4) - return true; - else - return false; - } - - public void next() { - lineNumber++; - } - - public String toString() { - return "ALineSegment["+p1.x+", "+p1.y+", "+p2.x+", "+p2.y+"]"; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AModifier.java b/graphics/AtlantisJava/src/atlantis/interactions/AModifier.java deleted file mode 100644 index d1b57d65f839fdd09966c3c09e662390d7dcb671..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AModifier.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * AModifier.java - * - * Created on 16 July 2007, 12:17 by Adam Davison <adamd at hep.ucl.ac.uk> - */ - -package atlantis.interactions; - -import java.awt.event.KeyEvent; - -/** - * A structure for holding details of an interaction modifier key - * - * @author Adam Davison - */ -public class AModifier { - - public static AModifier nothing = new AModifier(KeyEvent.VK_UNDEFINED, false, "Default interaction"); - - private int m_keycode; - private char m_keychar; - - // Won't use mouse button id's from MouseEvent because i have some memory - // of this not being very platform independant, can fiddle this if we need - // middle click or something later. - private boolean m_right; - - private String m_desc; - - public AModifier(int keycode, boolean right, String desc) { - m_keycode = keycode; - m_keychar = (char)keycode; - m_right = right; - m_desc = desc; - } - - public int getKeyCode() { - return m_keycode; - } - - public char getKeyChar() { - return m_keychar; - } - - public boolean getRightClick() { - return m_right; - } - - public String toKeyString() { - String ret = ""; - if (m_keycode != KeyEvent.VK_UNDEFINED) { - ret = String.valueOf(m_keychar); - if (m_right) { - ret = ret.concat(" + "); - } - } - - if (m_right) { - ret = ret.concat("Right"); - } - - return ret; - } - - public String toDescString() { - return m_desc; - } - - // Two interactions are pretty much the same even if they have different - // descriptions, hence I won't override equals here and cause problems - // putting these things in containers or anything. - public boolean sameAs(AModifier acmp) { - if (acmp == null) { return false; } - - if (acmp.getKeyCode() != getKeyCode()) { - return false; - } - - if (acmp.getRightClick() != getRightClick()) { - return false; - } - - return true; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AMouseDragListener.java b/graphics/AtlantisJava/src/atlantis/interactions/AMouseDragListener.java deleted file mode 100755 index 155f9126f2e52dbef1fb4adf802517aaef5739b4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AMouseDragListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package atlantis.interactions; - - -import java.awt.geom.*; - - -/** - * Implemented by the interactions to get drag events - * from the InteractionsManager. - */ -public interface AMouseDragListener { - - // Should return one of the LEFT, MIDDLE or RIGHT constants from AWindow - int getButton(); - - void start(Point2D.Double p, int region, int key); - void drag(Point2D.Double p, int region, int key); - void stop(); - void cancel(); -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AMousePressListener.java b/graphics/AtlantisJava/src/atlantis/interactions/AMousePressListener.java deleted file mode 100755 index a71c7ca21871ee87c93867e3d8628408e4e5f374..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AMousePressListener.java +++ /dev/null @@ -1,16 +0,0 @@ -package atlantis.interactions; - - -import java.awt.geom.*; - - -/** - * Implemented by the interactions to get press events - * from the InteractionsManager. - */ -public interface AMousePressListener { - - int getPressButton(); - void pressed(Point2D.Double p, int button, int key); -} - diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ANZMRGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/ANZMRGroup.java deleted file mode 100644 index 713743861be9a6c210d109912cb4f7dc2f5357b6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ANZMRGroup.java +++ /dev/null @@ -1,16 +0,0 @@ -package atlantis.interactions; - -/** - * - * @author Adam Davison - */ -public class ANZMRGroup extends AInteractionGroup { - - private ANZMRInteraction transformInteraction; - - public ANZMRGroup(AInteractionsManager iManager) { - super(AInteractionGroup.WINDOW_GROUP, iManager); - transformInteraction=new ANZMRInteraction(); - this.addInteraction(transformInteraction); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ANZMRInteraction.java b/graphics/AtlantisJava/src/atlantis/interactions/ANZMRInteraction.java deleted file mode 100644 index 99ac11f99f3e8258dda8929c5ee1ada66637d83b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ANZMRInteraction.java +++ /dev/null @@ -1,80 +0,0 @@ -package atlantis.interactions; - -import atlantis.nge.ANManager; -import atlantis.nge.ANPickDrawer; -import atlantis.nge.ANPickResultPrinter; -import atlantis.nge.ANProjection; -import atlantis.nge.ANProjection3D; -import atlantis.nge.ANProjectionPhysics; -import java.awt.Graphics2D; -import java.awt.geom.Point2D.Double; - -/** - * - * @author Adam Davison, Mark Stockton - */ -public class ANZMRInteraction extends AInteraction implements ASleepMouseDragListener, AMousePressListener { - - private Double m_last = null; - - public ANZMRInteraction() { - super(0, WINDOW_TOTAL_REPAINT, SCREEN_COORDINATES, false); - } - - @Override - public void paint(Graphics2D g) { - //throw new UnsupportedOperationException("Not supported yet."); - } - - public void doRotation(double dx, double dy) { - ANProjection np = (ANManager.getManager().getFrameManager(window).getTargetProjection()); - if (np instanceof ANProjection3D) { - ((ANProjection3D) np).dPhi((float) (dx / 4.0)); - ((ANProjection3D) np).dElev((float) (dy / 4.0)); - }else if (np instanceof ANProjectionPhysics) { - ((ANProjectionPhysics) np).dPhi((float) (dx / 4.0)); - ((ANProjectionPhysics) np).dElev((float) (dy / 4.0)); - } - } - - public int getButton() { - return AInteractionsManager.LEFT; - } - - public void start(Double p, int region, int key) { - m_last = p; - } - - public void drag(Double p, int region, int key) { - double dx = (p.getX() - m_last.getX()); - double dy = (p.getY() - m_last.getY()); - - doRotation(dx,dy); - - m_last = p; - } - - public void stop() { - - } - - public void cancel() { - - } - - public int init(Double p, int key) { - return -1; - } - - public int getPressButton() { - return AInteractionsManager.ALL; - } - - public void pressed(Double p, int button, int key) { - System.out.println("ZMR PRESS: " + p.getX() + ":" + p.getY()); - ANPickDrawer pd = new ANPickDrawer(window, window.getWidth(), window.getHeight(), - (int)p.getX(), (int)p.getY(), new ANPickResultPrinter()); - pd.doPick(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AParallelogramSelection.java b/graphics/AtlantisJava/src/atlantis/interactions/AParallelogramSelection.java deleted file mode 100755 index 75e3f512cbc09dd8da1ba6fba01740214b5076cb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AParallelogramSelection.java +++ /dev/null @@ -1,119 +0,0 @@ -package atlantis.interactions; - - -import java.awt.*; -import java.awt.geom.*; - - -public class AParallelogramSelection extends ASelection { - final private static int STARTING_WIDTH=25; - - public AParallelogramSelection() { - super(6); - } - - public int init(Point2D.Double p, int key) { - isValid=false; - - setCenter(hr[0], p.x-STARTING_WIDTH, p.y); - setCenter(hr[1], p.x-STARTING_WIDTH, p.y); - setCenter(hr[2], p.x+STARTING_WIDTH, p.y); - setCenter(hr[3], p.x+STARTING_WIDTH, p.y); - setCenter(hr[4], p.x, p.y); - setCenter(hr[5], p.x, p.y); - - region=5; - return region; - } - - public void drag(Point2D.Double p, int region, int key) { - isValid=true; - - double dx, dy; - - switch(region) { - case 4: - dx=hr[0].getCenterX()-hr[4].getCenterX(); - dy=hr[0].getCenterY()-hr[4].getCenterY(); - - setCenter(hr[region], p.x, p.y); - setCenter(hr[0], p.x+dx, p.y+dy); - setCenter(hr[3], p.x-dx, p.y-dy); - break; - - case 5: - dx=hr[1].getCenterX()-hr[5].getCenterX(); - dy=hr[1].getCenterY()-hr[5].getCenterY(); - - setCenter(hr[region], p.x, p.y); - setCenter(hr[1], p.x+dx, p.y+dy); - setCenter(hr[2], p.x-dx, p.y-dy); - break; - - case 0: - case 3: - setCenter(hr[region], p.x, p.y); - - dx=hr[region].getCenterX()-hr[4].getCenterX(); - dy=hr[region].getCenterY()-hr[4].getCenterY(); - - if(region==3) { - dx=-dx; - dy=-dy; - } - - setCenter(hr[1], hr[5].getCenterX()+dx, hr[5].getCenterY()+dy); - setCenter(hr[2], hr[5].getCenterX()-dx, hr[5].getCenterY()-dy); - setCenter(hr[0], hr[4].getCenterX()+dx, hr[4].getCenterY()+dy); - setCenter(hr[3], hr[4].getCenterX()-dx, hr[4].getCenterY()-dy); - break; - - case 1: - case 2: - setCenter(hr[region], p.x, p.y); - - dx=hr[region].getCenterX()-hr[5].getCenterX(); - dy=hr[region].getCenterY()-hr[5].getCenterY(); - - if(region==2) { - dx=-dx; - dy=-dy; - } - - setCenter(hr[1], hr[5].getCenterX()+dx, hr[5].getCenterY()+dy); - setCenter(hr[2], hr[5].getCenterX()-dx, hr[5].getCenterY()-dy); - setCenter(hr[0], hr[4].getCenterX()+dx, hr[4].getCenterY()+dy); - setCenter(hr[3], hr[4].getCenterX()-dx, hr[4].getCenterY()-dy); - break; - } - } - - public void paint(Graphics2D g) { - paintStandard(g); - } - - /** - * Make the affine transform which corresponds to this - * paralleogram-shaped selection. - */ - public Point2D.Double[] getCorners() { - int first=getUpperLeftRegion(); - - // Calculate the opposite index. - int third=(first+2)%4; - - // Now use the cross-product to determine which of the - // remaining points is the one which keep the path going - // clockwise. - int second=(first+1)%4; - double dx0=hr[third].getCenterX()-hr[first].getCenterX(); - double dy0=hr[third].getCenterY()-hr[first].getCenterY(); - double dx1=hr[second].getCenterX()-hr[first].getCenterX(); - double dy1=hr[second].getCenterY()-hr[first].getCenterY(); - - if(dx0*dy1-dy0*dx1>0) second=(first+3)%4; - - return convert(first, second, third); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/APickGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/APickGroup.java deleted file mode 100755 index e45447479dd5025308c953f1fb99d6c9b13f252a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/APickGroup.java +++ /dev/null @@ -1,102 +0,0 @@ -package atlantis.interactions; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JComboBox; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JPanel; - -import atlantis.canvas.ACanvas; -import atlantis.parameters.APar; - -public class APickGroup extends AInteractionGroup -{ - private APickInteraction pickInteraction; - private JComboBox mode; - // the panel that will contain the additional controls for the interactions - private JPanel additionalControls; - - private final static String HITS = "Event Data"; - private final static String DETECTORS = "Detectors"; - - public APickGroup(AInteractionsManager iManager) - { - super(AInteractionGroup.CANVAS_GROUP, iManager); - - // create the additional controls panel - additionalControls = new JPanel(); - - pickInteraction = new APickInteraction(); - addInteraction(pickInteraction); - mode = new JComboBox(); - mode.addItem(HITS); - mode.addItem(DETECTORS); - if (parameterStore.get("Event", "PickingMode").getI() == 0) - mode.setSelectedItem(HITS); - else - mode.setSelectedItem(DETECTORS); - mode.addActionListener(new ModeListener()); - additionalControls.add(mode); - } - - /** - * pick has additional controls, so return true - */ - public boolean hasAdditionalControls() { - return true; - } - - /** - * returns the additional controls - */ - public JPanel getAdditionalControls() { - return additionalControls; - } - - public JMenuItem getPopupItem() - { - // generating the menu - JMenu menu = new JMenu(name); - ActionListener l = new PopUpListener(); - - menu.add(HITS).addActionListener(l); - menu.add(DETECTORS).addActionListener(l); - return menu; - } - - public void connect() - { - super.connect(); - if (parameterStore.get("Event", "PickingMode").getI() == 0) - mode.setSelectedItem(HITS); - else - mode.setSelectedItem(DETECTORS); - } - - class PopUpListener implements ActionListener - { - public void actionPerformed(ActionEvent e) - { - ACanvas.getCanvas().getCurrentWindow().getInteractionToolBar().setSelectedGroup(name); - mode.setSelectedItem(e.getActionCommand()); - if (e.getActionCommand().equals(HITS)) - parameterStore.get("Event", "PickingMode").setI(0); - else if (e.getActionCommand().equals(DETECTORS)) - parameterStore.get("Event", "PickingMode").setI(1); - } - } - - class ModeListener implements ActionListener - { - public void actionPerformed(ActionEvent e) - { - if (mode.getSelectedItem().equals(HITS)) - parameterStore.get("Event", "PickingMode").setI(0); - else if (mode.getSelectedItem().equals(DETECTORS)) - parameterStore.get("Event", "PickingMode").setI(1); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/APickInteraction.java b/graphics/AtlantisJava/src/atlantis/interactions/APickInteraction.java deleted file mode 100755 index a12cdce3ee14b539218af119fba8eabc66bc3f0d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/APickInteraction.java +++ /dev/null @@ -1,419 +0,0 @@ -package atlantis.interactions; - -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Robot; -import java.awt.AWTException; -import java.awt.geom.Point2D; -import java.awt.event.KeyEvent; -import javax.swing.SwingUtilities; - -import atlantis.list.AList; -import atlantis.list.AListManager; -import atlantis.nge.ANManager; -import atlantis.nge.ANProjectionPhysics; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.data.ALVL1TriggerTowerData; -import atlantis.data.AMuonHitData; -import atlantis.parameters.APar; -import atlantis.projection.AProjectionNPhysics; -import atlantis.projection.AProjectionTrackResidual; -import atlantis.projection.AProjectionsManager; -import atlantis.event.AData; -import atlantis.data.AJetData; -import atlantis.data.ACalorimeterData; -import atlantis.data.ALArData; -import atlantis.data.ASVxData; -import atlantis.data.ARVxData; -import atlantis.data.ATILEData; -import atlantis.data.ATrackData; -import atlantis.graphics.ACursorFactory; -import atlantis.graphics.APickingGraphics2D; -import atlantis.utils.AMath; - - - -public class APickInteraction extends AInteraction implements AMousePressListener, AEnterExitListener -{ - - public APickInteraction() - { - super(0, NO_REPAINT, SCREEN_COORDINATES, false); - } - - - - public int getPressButton() - { - return AInteractionsManager.ALL; - } - - - - private void showCaloPulseShapePlot(AList picked, boolean withcurve) - { - Integer i = APickingGraphics2D.getPickedHitIndex(); - if(i != null) - { - ACalorimeterData c = (ACalorimeterData) picked.getSource(); - c.plotPulseShapes(i.intValue(), withcurve); - } - } - - - - private void showTriggerPulseShapePlot(AList picked) - { - Integer i = APickingGraphics2D.getPickedHitIndex(); - if(i != null) - { - ALVL1TriggerTowerData t = (ALVL1TriggerTowerData) picked.getSource(); - t.plotPulseShapes(i.intValue()); - } - } - - - - private void ignorePickedItem(AList picked) - { - Integer i = APickingGraphics2D.getPickedHitIndex(); - if(i != null) - { - AData d = (AData) picked.getSource(); - String k = d.getStoreGateKey() != null ? ":" + d.getStoreGateKey() : ""; - String m = "\n\n" + d.getNameScreenName() + k + " ID " + - d.getIdFromIndex(i.intValue()) + " (index " + i.intValue() + - ") will be invisible and ignored " + - "(until removed from the Invisible list)"; - AOutput.alwaysAppend(m, ALogInterface.WARNING); - AListManager.getInstance().addInvisible(picked); - } - - } - - - - private void showMuonSector(AList picked) - { - if(picked.getSource() instanceof AMuonHitData) - { - int sector = ((AMuonHitData) picked.getSource()).getSector(picked.getItems()[0]); - int signRZ = ((AMuonHitData) picked.getSource()).getRZSign(picked.getItems()[0]); - if(signRZ == -1) - { - sector = (sector + 8) % 16; - } - parameterStore.get("YZ", "Phi").setD(sector * 22.5); - window.repaintFromScratch(); - } - } - - - - private void showTrackResidualPlot(AList picked) - { - AData pickedData = picked.getSource(); - if(pickedData instanceof ATrackData) - { - if(((ATrackData)pickedData).getResidualStatus()) - { - APickingGraphics2D.showTrackResiduals(window, - (int) APickingGraphics2D.getPickedH(), (int) APickingGraphics2D.getPickedV()); - } - else - { - AOutput.append("\nNo residual information available for this track\n", - ALogInterface.PICK); - } - } - } - - private void showJetView(AList picked) - { - AData pickedData = picked.getSource(); - if(pickedData instanceof AJetData){ - - // Use window "B" to show jets - String jetWindowName = "B"; - if(!ACanvas.getCanvas().isValidWindowName(jetWindowName)) - { - AOutput.append("\nWindow " + jetWindowName + " is not available in current layout" - + "\n", ALogInterface.WARNING); - } - else if(window.getName().equals(jetWindowName)){ - AOutput.append("\nPlease select jet view from a window other than window " + jetWindowName, ALogInterface.WARNING); - } - else{ - AWindow jetWindow = ACanvas.getCanvas().getWindow(jetWindowName); - - //set as NYX to get transition - AProjectionNPhysics jetProj = - (AProjectionNPhysics) AProjectionsManager.getProjection("NPhysics"); - - //setup the projection - ACanvas.getCanvas().moveToFrontWindow(jetWindowName); - jetWindow.setProjection(jetProj); - - //configure the projection - jetProj.configureFrame(ANManager.getManager().getFrameManager(jetWindow)); - ANProjectionPhysics finalProj = (ANProjectionPhysics) ANManager.getManager().getFrameManager(jetWindow).getTargetProjection(); - - AJetData jd = ((AJetData) pickedData); - int index=picked.getItems()[0]; - finalProj.lookAt(jd, index); - } - } - } - - - /** - * @param picked AList - * Check if picked data is SimVertex or RecVertex (RVx) and use the values - * as Atlantis primary vertex: Projection->eta/phi menu - */ - private void setAtlantisPrimaryVertex(AList picked) - { - Integer i = APickingGraphics2D.getPickedHitIndex(); - AData pickedData = picked.getSource(); - double[] vtx = null; - - if(i != null) - { - if(pickedData instanceof ARVxData) - { - vtx = ((ARVxData) pickedData).getVertex(i.intValue()); - } - if(pickedData instanceof ASVxData) - { - vtx = ((ASVxData) pickedData).getVertex(i.intValue()); - } - - if(vtx != null) - { - parameterStore.get("Event", "XVtx").setD(vtx[0]); - parameterStore.get("Event", "YVtx").setD(vtx[1]); - parameterStore.get("Event", "ZVtx").setD(vtx[2]); - AOutput.append("\n\nPrimary vertex set: Projection->" + - AMath.PHI + AMath.ETA + ":\n" + - " XVtx = " + String.format("%.5f",vtx[0]) + " cm\n" + - " YVtx = " + String.format("%.5f",vtx[1]) + " cm\n" + - " ZVtx = " + String.format("%.5f",vtx[2]) + " cm\n", - ALogInterface.WARNING); - } - } - - } // setAtlantisPrimaryVertex() ----------------------------------------- - - - - public void pressed(Point2D.Double p, int button, int key) - { - Point ps = null; - Point pw = null; - int pickingMode = parameterStore.get("Event", "PickingMode").getI(); - - if(button == AInteractionsManager.LEFT) - { - if(key == KeyEvent.VK_C) - { - AListManager.getInstance().clearHighlightAndMassCalculation(); - } - else - { - Rectangle bounds = window.getBounds(); - bounds.setLocation(0, 0); - window.paintWindowFromScratch(new APickingGraphics2D(bounds, - pickingMode, new Point((int) p.x, (int) p.y))); - - // this call prints pick information (calls datatype's getHitInfo()) - if(!(key == KeyEvent.VK_L)) - { - APickingGraphics2D.printPicked(); - } - AList picked = APickingGraphics2D.getPickedHit(); - - if(picked != null && pickingMode == APickingGraphics2D.PICK_HITS_AND_TRACKS) - { - - // highlight by default (not only when key==KeyEvent.VK_H) - AListManager.getInstance().highlight(picked); - - // try to always show calo pulse shapes plot by default - // if no key modifier is pressed - if(picked.getSource() instanceof ACalorimeterData && - key == KeyEvent.KEY_LOCATION_UNKNOWN) - { - showCaloPulseShapePlot(picked, true); - } - // 2009-01-19 for LAr only, see comment at - // the ALArData.plotADCCounts() method - if(picked.getSource() instanceof ACalorimeterData && - key == KeyEvent.VK_D) - { - showCaloPulseShapePlot(picked, false); - } - if(picked.getSource() instanceof ATILEData && - key == KeyEvent.VK_T) { - - Integer i = APickingGraphics2D.getPickedHitIndex(); - if (i != null) { - ATILEData c = (ATILEData) picked.getSource(); - c.plotPulseShapesWithTiming(i.intValue()); - } - } - if(picked.getSource() instanceof ALVL1TriggerTowerData && - key == KeyEvent.KEY_LOCATION_UNKNOWN) - { - showTriggerPulseShapePlot(picked); - } - - if(picked.getSource() instanceof AJetData) - { - double phi = ((AJetData) picked.getSource()).getPhi(picked.getItems()[0]); - parameterStore.get("XZ", "Phi").setD(Math.toDegrees(phi)); - } - - switch(key) - { - case KeyEvent.VK_A: - AListManager.getInstance().add(picked); - break; - case KeyEvent.VK_S: - showMuonSector(picked); - break; - case KeyEvent.VK_N: - APickingGraphics2D.navigatePicked(); - break; - case KeyEvent.VK_R: - showTrackResidualPlot(picked); - break; - case KeyEvent.VK_V: - setAtlantisPrimaryVertex(picked); - break; - case KeyEvent.VK_I: - ignorePickedItem(picked); - break; - case KeyEvent.VK_J: - if(parameterStore.get("Prefs", "OpenGL").getStatus()){ - showJetView(picked); - } - break; - case KeyEvent.VK_M: - AListManager.getInstance().massCalc(picked); - break; - case KeyEvent.VK_L: // Mass calculation for Neutral Decay scenarios - AListManager.getInstance().massCalcV0(picked); - break; - case KeyEvent.VK_P: // Calculate delta Phi for picked objects - AListManager.getInstance().deltaR(picked); - break; - - - } // switch - - } - else if(pickingMode == APickingGraphics2D.PICK_DETECTORS) - { - AListManager.getInstance().clearHighlight(); - } - } - - } // if(button == AInteractionsManager.LEFT) - - else if(button == AInteractionsManager.RIGHT) - { - Rectangle bounds = window.getBounds(); - bounds.setLocation(0, 0); - window.paintWindowFromScratch(new APickingGraphics2D(bounds, APickingGraphics2D.MOVE, - new Point((int) p.x, (int) p.y))); - } - - if(pickingMode != APickingGraphics2D.PICK_DETECTORS) - { - if(APickingGraphics2D.getPickedData() != null - || APickingGraphics2D.getPickedResidual() != null) - { - /* int numEvents = Atlantis.getEventManager().getNumberOfEvents(); - if(numEvents > 0) - { - AOutput.append("\n(" + ++numEvents + " events currently displayed)\n", ALogPane.PICK); - }*/ - - //TODO fix to avoid problems with nge - if(window==null) - return; - - pw = new Point(APickingGraphics2D.getPickedH(), APickingGraphics2D.getPickedV()); - if(pw.x != 0 && pw.y != 0) - try - { - ps = new Point(pw); - SwingUtilities.convertPointToScreen(ps, window); - new Robot().mouseMove(ps.x, ps.y); - } - catch(AWTException e) - {} - else - { - AOutput.alwaysAppend("\n\nYou must pick before you can move", ALogInterface.BAD_COMMAND); - } - } - else - { - if(!(window.getProjection() instanceof AProjectionTrackResidual)) - AOutput.alwaysAppend("\n\nNothing to pick", ALogInterface.BAD_COMMAND); - } - } - - } // pressed() ------------------------------------------------------------ - - - public void paint(Graphics2D g) - {} - - /** - * Gets called each time we enter a window in which this interaction is active - */ - public void entered() - { - //Set mouse cursor - window.setCursor(ACursorFactory.getInstance().getPickCursor()); - } - - /** - * Gets called each time we leave a window in which this interaction is active - */ - public void exited() - { - //Set mouse cursor - window.setCursor(ACursorFactory.getInstance().getDefaultCursor()); - } - - public AModifier[] getModifiers() - { - AModifier[] mods = new AModifier[] { - new AModifier(KeyEvent.VK_UNDEFINED, false, "Pick"), - new AModifier(KeyEvent.VK_UNDEFINED, true, "Move to last picked"), - new AModifier(KeyEvent.VK_A, false, "Add to the current (active) list"), - new AModifier(KeyEvent.VK_C, false, "Clear highlighted and calculation lists"), - new AModifier(KeyEvent.VK_D, false, "Plot ADC counts (digits) only"), - new AModifier(KeyEvent.VK_T, false, "Plot raw and cell time pulses (TILE only)"), - new AModifier(KeyEvent.VK_I, false, "Ignore (make invisible) picked hits/tracks"), - new AModifier(KeyEvent.VK_L, false, "Add to the V0 mass calculation list"), - new AModifier(KeyEvent.VK_M, false, "Add to the mass calculation list"), - new AModifier(KeyEvent.VK_P, false, "Calculate Delta R for 2 tracks"), - new AModifier(KeyEvent.VK_N, false, "Navigate (show data associations)"), - new AModifier(KeyEvent.VK_R, false, "Plot track residuals if available"), - new AModifier(KeyEvent.VK_S, false, "Select this muon Sector"), - new AModifier(KeyEvent.VK_V, false, "Set prim.vertex from picked rec/sim vertex"), - new AModifier(KeyEvent.VK_J, false, "Jet view (OpenGL only)") - }; - - return mods; - - } -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/APopupListener.java b/graphics/AtlantisJava/src/atlantis/interactions/APopupListener.java deleted file mode 100755 index f7b462043d6c6ac7513ad0d892a4c310339b8763..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/APopupListener.java +++ /dev/null @@ -1,16 +0,0 @@ -package atlantis.interactions; - - -import java.awt.Point; - - -/** - * The interactions implement this listener to get popup trigger events. - */ -public interface APopupListener { - int REGION_POPUP=0; - int WINDOW_POPUP=1; - - int getPopupType(); - void showPopup(Point p, int region); -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ARectangleSelection.java b/graphics/AtlantisJava/src/atlantis/interactions/ARectangleSelection.java deleted file mode 100755 index 818dd6120b24859afc674cc9d3bd241c43d12b8c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ARectangleSelection.java +++ /dev/null @@ -1,95 +0,0 @@ -package atlantis.interactions; - -import java.awt.Graphics2D; -import java.awt.geom.Point2D; - -import atlantis.graphics.ACursorFactory; -import atlantis.graphics.AGraphics; - -public class ARectangleSelection extends ASelection implements AEnterExitListener -{ - public ARectangleSelection() - { - super(4); - } - - public int init(Point2D.Double p, int key) - { - isValid = false; - - for (int i = 0; i < 4; i++) - setCenter(hr[i], p.x, p.y); - - this.region = 2; - return region; - } - - public void drag(Point2D.Double p, int region, int key) - { - isValid = true; - - // Update the active control point. - setCenter(hr[region], p.x, p.y); - - // Get the opposite control point. - int oppCtrlPt = (region + 2) % 4; - double xOpp = hr[oppCtrlPt].getCenterX(); - double yOpp = hr[oppCtrlPt].getCenterY(); - - // Now choose the next control point so that we maintain a - // clockwise order to the points. - int otherCtrlPt = ((p.x < xOpp && p.y > yOpp) || (p.x > xOpp && p.y < yOpp)) ? 1 : 3; - - otherCtrlPt = (region + otherCtrlPt) % 4; - - // Set the other two control points. - setCenter(hr[otherCtrlPt], p.x, yOpp); - otherCtrlPt = (otherCtrlPt + 2) % 4; - setCenter(hr[otherCtrlPt], xOpp, p.y); - } - - public void paint(Graphics2D g) - { - if (!isValid) - return; - - AGraphics ag = AGraphics.makeAGraphics(g); - - ag.updateDrawParameters(frameDrawParameters); - ag.drawPolygon(getAPolygon()); - ag.updateDrawParameters(drawParameters); - ag.drawPolygon(getAPolygon()); - drawActivePoint(region, ag); - } - - public Point2D.Double[] getCorners() - { - int first = getUpperLeftRegion(); - - // Calculate the adjacent partner and the opposite corner. - int second = (first + 1) % 4; - int third = (first + 2) % 4; - - return convert(first, second, third); - } - - /** - * Get called each time we enter a window in which this interaction is - * active - */ - public void entered() - { - // Set mouse cursor - window.setCursor(ACursorFactory.getInstance().getRectSelectCursor()); - } - - /** - * Get called each time we leave a window in which this interaction is active - */ - public void exited() - { - //Set mouse cursor - window.setCursor(ACursorFactory.getInstance().getDefaultCursor()); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ARectangleVPSelection.java b/graphics/AtlantisJava/src/atlantis/interactions/ARectangleVPSelection.java deleted file mode 100755 index 8d26e25ff33e56df75682fe300bc422a71ae65da..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ARectangleVPSelection.java +++ /dev/null @@ -1,524 +0,0 @@ -package atlantis.interactions; - -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.geom.Point2D; -import javax.swing.JMenuItem; -import java.util.List; -import java.util.ArrayList; - -import atlantis.event.AData; -import atlantis.event.AEventManager; -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.data.ACalorimeterData; -import atlantis.event.AEvent; -import atlantis.graphics.dnd.ADnDLabel; -import atlantis.graphics.dnd.ADragListener; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionXZ; -import atlantis.projection.AProjectionYX; -import atlantis.projection.AProjectionYZ; -import atlantis.utils.AMath; -import atlantis.utils.A3Vector; - -public class ARectangleVPSelection extends ARectangleSelection - implements ActionListener, ADragListener -{ - - public final static String RUBBERBAND_WHOLE_WINDOW = "Rubberband Whole Window"; - public final static String ZOOM_LAR = "Zoom LAr"; - public final static String ZOOM_CALORIMETERS = "Zoom Calorimeters"; - public final static String CUT_ETAPHI = "Cut ( " + AMath.ETA + AMath.PHI + " cut )"; - public final static String PRINT_CONTENTS = "Print Contents"; - public final static String SHOW_IN_3DBOX = "Show in 3DBox"; - public final static String TURN_OFF_ETAPHI_CUT = "Turn off " + CUT_ETAPHI; - - private static AEventManager eventManager = AEventManager.instance(); - - public ARectangleVPSelection() - { - super(); - - addActionButton(ZOOM_LAR, this, this); - addActionButton(ZOOM_CALORIMETERS, this, this); - addActionButton(CUT_ETAPHI, this, this); - addActionButton(RUBBERBAND_WHOLE_WINDOW, this, this); - addActionButton(PRINT_CONTENTS, this, this); - addActionButton(SHOW_IN_3DBOX, this, this); - - } - - - - @Override - public JMenuItem[] getPopupItems() - { - ArrayList al = new ArrayList(); - if (window.getUnzoomPossible()) - { - JMenuItem item = new JMenuItem("Unzoom"); - al.add(item); - item.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - window.unzoom(); - } - }); - } - if(window.getUnzoomAllPossible(ZOOM_LAR)) - { - JMenuItem item = new JMenuItem("Unzoom LAr"); - al.add(item); - item.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) { - window.unzoom(ARectangleVPSelection.ZOOM_LAR); - } - }); - } - if(window.getUnzoomAllPossible(ZOOM_CALORIMETERS)) - { - JMenuItem item = new JMenuItem("Unzoom Calorimeters"); - al.add(item); - item.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) { - window.unzoom(ZOOM_CALORIMETERS); - } - }); - } - if (window.getUnzoomFullPossible()) - { - JMenuItem item = new JMenuItem("Unzoom Full"); - al.add(item); - item.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - window.unzoomFull(); - } - }); - } - - JMenuItem rww = new JMenuItem(RUBBERBAND_WHOLE_WINDOW); - rww.addActionListener(this); - - JMenuItem toec = new JMenuItem(TURN_OFF_ETAPHI_CUT); - toec.addActionListener(this); - - al.add(rww); - al.add(toec); - - // Can't cast arrays very easily... - JMenuItem[] ret = new JMenuItem[al.size()]; - for (int i = 0; i < al.size(); i++) { - ret[i] = (JMenuItem)al.get(i); - } - - return ret; - } - - - public void actionPerformed(ActionEvent e) - { - String action = e.getActionCommand(); - - if(ZOOM_LAR.equals(action)) - { - performZoom(ZOOM_LAR); - } - else if(ZOOM_CALORIMETERS.equals(action)) - { - performZoom(ZOOM_CALORIMETERS); - } - else if(CUT_ETAPHI.equals(action)) - { - applyCutIn(window.getName()); - } - else if(RUBBERBAND_WHOLE_WINDOW.equals(action)) - { - rubberbandWholeWindow(); - } - else if(PRINT_CONTENTS.equals(action)) - { - performOperationWithCuts(PRINT_CONTENTS); - } - else if(SHOW_IN_3DBOX.equals(action)) - { - tracksTo3DBox(); - } - else if(TURN_OFF_ETAPHI_CUT.equals(action)) - { - turnOffEtaPhiCuts(); - } - - } - - - private void turnOffEtaPhiCuts() - { - parameterStore.get("CutsATLAS", "CutPhi").setStatus(false); - parameterStore.get("CutsATLAS", "CutEta").setStatus(false); - String warning = "\n\nCuts -> ATLAS -> Cut " + AMath.ETA + " deactivated" + - "\nCuts -> ATLAS -> Cut " + AMath.PHI + " deactivated\n\n"; - AOutput.append(warning, ALogInterface.WARNING); - ACanvas.getCanvas().repaintAllFromScratch(); - - } - - - - private void tracksTo3DBox() { - Point2D.Double[] corners = getCorners(); - double eta = (corners[2].x + corners[0].x) / 2.; - double phi = Math.toRadians((corners[2].y + corners[0].y) / 2.); - - A3Vector ray = A3Vector.fromEtaPhiR(eta, phi, 1.0); - - // Need to make sure we change existing 3DBoxes - parameterStore.get("3D", "xAxis").changeScope(AParameter.GLOBAL); - parameterStore.get("3D", "yAxis").changeScope(AParameter.GLOBAL); - parameterStore.get("3D", "zAxis").changeScope(AParameter.GLOBAL); - parameterStore.get("3D", "xAxis").setD(ray.x); - parameterStore.get("3D", "yAxis").setD(ray.y); - parameterStore.get("3D", "zAxis").setD(ray.z); - - // 3DBoxes can be anywhere on the screen: - ACanvas.getCanvas().repaintAllFromScratch(); - } - - - public void dragPerformed(Object from, Object to, int action) - { - if (to instanceof ADnDLabel) - { - applyCutIn(((ADnDLabel) to).getText()); - } - else if (to instanceof AWindow) - { - applyCutIn(((AWindow) to).getName()); - } - } - - - - private boolean checkEtaPhiCutValues(double eta, double phi, - double cutPhi, double cutEta) - { - if (!(parameterStore.get("CutsATLAS", "PhiMiddle").validateValue(phi) && - parameterStore.get("CutsATLAS", "EtaMiddle").validateValue(eta) && - parameterStore.get("CutsATLAS", "CutPhi").validateValue(cutPhi) && - parameterStore.get("CutsATLAS", "CutEta").validateValue(cutEta))) - { - String etaphi = AMath.ETA + AMath.PHI; - AOutput.append("\nOperation cancelled: " + etaphi + - " cut values outside allowed range\n", ALogInterface.WARNING); - return false; - - } - else - { - return true; - } - - } - - - - public void applyCutIn(String zoomWindowName) - { - Point2D.Double[] corners = getCorners(); - double eta = (corners[2].x + corners[0].x) / 2.; - double cutEta = Math.abs((corners[2].x - corners[0].x)) / 2.; - double phi = (corners[2].y + corners[0].y) / 2.; - double cutPhi = Math.abs((corners[2].y - corners[0].y)) / 2.; - double rhoVPlot = AProjectionVP.getRhoZoomVPlot(); - double zVPlot = AProjectionVP.getZZoomVPlot(); - double zVtx = parameterStore.get("Event", "ZVtx").getD(); - double zLower = Math.max(Math.min(rhoVPlot * AMath.tanLambda(eta - cutEta) + zVtx, 0.), -zVPlot); - double zUpper = Math.min(Math.max(rhoVPlot * AMath.tanLambda(eta + cutEta) + zVtx, 0.), zVPlot); - - if(! checkEtaPhiCutValues(eta, phi, cutPhi, cutEta)) - { - return; - } - - String currentWindowName = window.getName(); - - parameterStore.selectWindowParameters(zoomWindowName); - parameterStore.get("CutsATLAS", "PhiMiddle").setD(phi); - parameterStore.get("CutsATLAS", "EtaMiddle").setD(eta); - parameterStore.get("CutsATLAS", "CutPhi").setD(cutPhi); - parameterStore.get("CutsATLAS", "CutPhi").setStatus(true); - parameterStore.get("CutsATLAS", "CutEta").setD(cutEta); - parameterStore.get("CutsATLAS", "CutEta").setStatus(true); - - String warning = "\n\nCuts -> ATLAS -> Cut " + AMath.ETA + " now active" + - "\nCuts -> ATLAS -> Cut " + AMath.PHI + " now active\n\n"; - AOutput.append(warning, ALogInterface.WARNING); - - AWindow zoomWindow = ACanvas.getCanvas().getWindow(zoomWindowName); - AProjection zoomProjection = zoomWindow.getProjection(); - - if (zoomProjection instanceof AProjectionFR) - { - zoomWindow.setUserCorners(0., rhoVPlot, phi - cutPhi, phi + cutPhi); - } - else if (zoomProjection instanceof AProjectionFZ) - { - zoomWindow.setUserCorners(zLower, zUpper, phi - cutPhi, phi + cutPhi); - } - else if (zoomProjection instanceof AProjectionVP) - { - if (!zoomWindowName.equals(currentWindowName)) - zoomWindow.setUserCorners(eta - cutEta, eta + cutEta, phi - cutPhi, phi + cutPhi); - } - else if (zoomProjection instanceof AProjectionYX) - { - zoomWindow.setUserCorners(-rhoVPlot, rhoVPlot, -rhoVPlot, rhoVPlot); - } - else if (zoomProjection instanceof AProjectionXZ) - { - double rhoZoom = Math.min(rhoVPlot, 110.); - - zoomWindow.setUserCorners(zLower, zUpper, 0., rhoZoom); - parameterStore.get("XZ", "Phi").setD(AMath.nearestPhiDegrees(phi)); - } - else if (zoomProjection instanceof AProjectionYZ) - { - double rhoZoom = Math.min(rhoVPlot, 110.); - - zoomWindow.setUserCorners(zLower, zUpper, -rhoZoom, rhoZoom); - parameterStore.get("YZ", "Phi").setD(AMath.nearestPhiDegrees(phi)); - } - else if (zoomProjection instanceof AProjectionRZ) - { - zoomWindow.setUserCorners(zLower, zUpper, 0., rhoVPlot); - parameterStore.get("RZ", "Phi").setD(AMath.nearestPhiDegrees(phi)); - } - parameterStore.restoreWindowParameters(); - - // don't repaint just the current window after cut(s) are applied, - // but repaint everything (all windows) - // zoomWindow.repaintFromScratch(); - ACanvas.getCanvas().repaintAllFromScratch(); - - } - - public void performZoom(String typeOfZoom) - { - int numberOfWindows=0; - - if(ZOOM_LAR.equals(typeOfZoom)) - { - numberOfWindows = 4; - } - else if(ZOOM_CALORIMETERS.equals(typeOfZoom)) - { - numberOfWindows = 8; - } - - AWindow currentWindow = window; - String name = currentWindow.getName(); - currentWindow.saveLayout(); - boolean scaleStatus = currentWindow.getScaleStatus(); - Point2D.Double[] zoomedCorners = getCorners(); - layoutChange(typeOfZoom); - int nameIndex=-1; - for (int i = 0; i < numberOfWindows; i++) - { - String wName = Integer.toString(i + 1); - AWindow w = ACanvas.getCanvas().getWindow(wName); - //dont zoom current window as will not save corners correctly - if (w != null && !name.equals(wName)) - { - w.saveParameters(typeOfZoom); - ACanvas.getCanvas().copyWindowSettings(currentWindow.getName(), wName); - w.saveCorners(typeOfZoom); - w.setUserCorners(zoomedCorners); - w.setScaleStatus(scaleStatus); - parameterStore.selectWindowParameters(wName); - parameterStore.get("VP", "Mode").setI(AProjectionVP.MODE_ECAL_LAYER_0 + i); - parameterStore.restoreWindowParameters(); - ACanvas.getCanvas().moveToFrontWindow(w.getName()); - w.repaintFromScratch(); - } - else if(name.equals(wName)) - { - nameIndex=i; - } - } - //now do zoom of current window if needed - if(nameIndex>0) - { - currentWindow.saveParameters(typeOfZoom); - currentWindow.saveCorners(typeOfZoom); - currentWindow.setUserCorners(zoomedCorners); - currentWindow.setScaleStatus(scaleStatus); - parameterStore.selectWindowParameters(name); - parameterStore.get("VP", "Mode").setI(AProjectionVP.MODE_ECAL_LAYER_0 + nameIndex); - parameterStore.restoreWindowParameters(); - ACanvas.getCanvas().moveToFrontWindow(name); - currentWindow.repaintFromScratch(); - } - for (int i = 0; i < numberOfWindows; i++) - if (name.equals(Integer.toString(i + 1))) - invalidate(); - } - - public void layoutChange(String typeOfZoom) - { - // change layout - if(!ACanvas.getCanvas().getCurrentLayout().getName().equals("SQUARE")) - { - ACanvas.getCanvas().setCurrentLayout("SQUARE"); - } - - // print info message - AOutput.append("\nWindows changed to: \n",ALogInterface.TITLE); - AOutput.append("Window 1: ECAL sampling 0\n",ALogInterface.NORMAL); - AOutput.append("Window 2: ECAL sampling 1\n",ALogInterface.NORMAL); - AOutput.append("Window 3: ECAL sampling 2\n",ALogInterface.NORMAL); - AOutput.append("Window 4: ECAL sampling 3\n",ALogInterface.NORMAL); - - if(ZOOM_CALORIMETERS.equals(typeOfZoom)) - { - AOutput.append("Window 5: HCAL sampling 0\n",ALogInterface.NORMAL); - AOutput.append("Window 6: HCAL sampling 1\n",ALogInterface.NORMAL); - AOutput.append("Window 7: HCAL sampling 2\n",ALogInterface.NORMAL); - AOutput.append("Window 8: HCAL sampling 3\n",ALogInterface.NORMAL); - } - } - - - private void printContents() - { - // get all data within selection (eta/phi cut already applied) - AEvent event = eventManager.getCurrentEvent(); - StringBuffer output = new StringBuffer("Data inside Rubberband selection:"); - // hits and tracks first - List hitsAndTracks = event.getHitsAndTracks(window.getProjection()); - for(int i = 0; i < hitsAndTracks.size(); i++) - { - String info = ((AData) hitsAndTracks.get(i)).getVPHitInfo(); - if(! "".equals(info)) - { - output.append("\n" + info); - } - } - - // calorimeters (as they are handled differently) - List cal = event.getCalorimeters(); - for (int i = 0; i < cal.size(); i++) - { - ACalorimeterData calorimeter = (ACalorimeterData) cal.get(i); - calorimeter.makeDrawList(); - String info = calorimeter.getVPHitInfo(); - if(! "".equals(info)) - { - output.append("\n" + info); - } - } - - AOutput.alwaysAppend("\n" + output + "\n", ALogInterface.PICK); - - } - - - - /** - * Apply eta phi cuts based on the selected (rubberband region), then - * perform the desired operation with data in the selection and - * restore previous cuts settings. - */ - private void performOperationWithCuts(String operation) - { - // which corners fall into eta/phi rubberband selection - Point2D.Double[] corners = getCorners(); - double eta = (corners[2].x + corners[0].x) / 2.; - double cutEta = Math.abs((corners[2].x - corners[0].x)) / 2.; - double phi = (corners[2].y + corners[0].y) / 2.; - double cutPhi = Math.abs((corners[2].y - corners[0].y)) / 2.; - - if(! checkEtaPhiCutValues(eta, phi, cutPhi, cutEta)) - { - return; - } - - // need to temporarily apply eta/phi cut, but get the current - // eta/phi cut values first and save them - AParameter phiPar = parameterStore.get("CutsATLAS", "PhiMiddle"); - AParameter cutPhiPar = parameterStore.get("CutsATLAS", "CutPhi"); - AParameter etaPar = parameterStore.get("CutsATLAS", "EtaMiddle"); - AParameter cutEtaPar = parameterStore.get("CutsATLAS", "CutEta"); - double oldEta = etaPar.getD(); - double oldCutEta = cutEtaPar.getD(); - boolean oldCutEtaStatus = cutEtaPar.getStatus(); - double oldPhi = phiPar.getD(); - double oldCutPhi = cutPhiPar.getD(); - boolean oldCutPhiStatus = cutPhiPar.getStatus(); - - // set new (temporary) values of eta/phi cuts according to selection - phiPar.setD(phi); - etaPar.setD(eta); - cutPhiPar.setD(cutPhi); - cutPhiPar.setStatus(true); - cutEtaPar.setD(cutEta); - cutEtaPar.setStatus(true); - - if(PRINT_CONTENTS.equals(operation)) - { - printContents(); - } - - // set back the previous eta/phi cut values - phiPar.setD(oldPhi); - etaPar.setD(oldEta); - cutPhiPar.setD(oldCutPhi); - cutPhiPar.setStatus(oldCutPhiStatus); - cutEtaPar.setD(oldCutEta); - cutEtaPar.setStatus(oldCutEtaStatus); - - } // printContents() ---------------------------------------------------- - - - - public void rubberbandWholeWindow() - { - Rectangle curr = window.getCurrDisp(); - - double x = curr.getX(); - double y = curr.getY(); - double w = curr.getWidth(); - double h = curr.getHeight(); - - setCenter(hr[0], x, y); - setCenter(hr[1], x + w, y); - setCenter(hr[2], x + w, y + h); - setCenter(hr[3], x, y + h); - isValid = true; - region = 1; - stop(); - window.repaint(); - oldAffectedRegion = curr; - int safetySize = 5; - - oldAffectedRegion.x -= safetySize; - oldAffectedRegion.y -= safetySize; - oldAffectedRegion.width += 2 * safetySize; - oldAffectedRegion.height += 2 * safetySize; - - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ARectangleYXSelection.java b/graphics/AtlantisJava/src/atlantis/interactions/ARectangleYXSelection.java deleted file mode 100755 index 0a01c70592c826ec2b7719a06fec81c9736c460f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ARectangleYXSelection.java +++ /dev/null @@ -1,320 +0,0 @@ -package atlantis.interactions; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.geom.Point2D; -import java.util.ArrayList; - -import javax.swing.JMenuItem; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.graphics.dnd.ADragListener; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection; -import atlantis.projection.AProjectionYX; -import atlantis.projection.AProjectionsManager; - -/** - * Contains the function for selecting zoom endcap layers and summed endcaps - * - * @author Mark Stockton - */ -public class ARectangleYXSelection extends ARectangleSelection implements ActionListener, ADragListener -{ - public final static String ZOOM_SUMMED = "summed"; - public final static String ZOOM_LAYERS = "layers"; - - public ARectangleYXSelection() - { - super(); - addActionButton("Zoom Summed Endcaps", new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals("Zoom Summed Endcaps")) - performZoom(ZOOM_SUMMED); - } - }); - addActionButton("Zoom Endcap Layers -", new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals("Zoom Endcap Layers -")) - zoomLayersMinus(); - } - }); - addActionButton("Zoom Endcap Layers +", new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals("Zoom Endcap Layers +")) - zoomLayersPlus(); - } - }); - addActionButton("Zoom Both Endcap Layers", new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals("Zoom Both Endcap Layers")) - zoomLayersCombined(); - } - }); - } - - public void zoomLayersMinus() - { - parameterStore.get("CutsCalo", "FCAL").setI(0); - parameterStore.get("CutsCalo", "LAr").setI(0); - parameterStore.get("CutsCalo", "HEC").setI(-2); - performZoom(ZOOM_LAYERS); - } - - public void zoomLayersPlus() - { - parameterStore.get("CutsCalo", "FCAL").setI(1); - parameterStore.get("CutsCalo", "LAr").setI(1); - parameterStore.get("CutsCalo", "HEC").setI(2); - performZoom(ZOOM_LAYERS); - } - - public void zoomLayersCombined() - { - parameterStore.get("CutsCalo", "FCAL").setI(-1); - parameterStore.get("CutsCalo", "LAr").setI(-1); - parameterStore.get("CutsCalo", "HEC").setI(-1); - performZoom(ZOOM_LAYERS); - } - - public void performZoom(String typeOfZoom) - { - int numberOfWindows=0; - if(typeOfZoom.equals(ZOOM_SUMMED)) - numberOfWindows=4; - else if(typeOfZoom.equals(ZOOM_LAYERS)) - numberOfWindows=8; - - AWindow currentWindow = window; - String name = currentWindow.getName(); - currentWindow.saveLayout(); - boolean scaleStatus = currentWindow.getScaleStatus(); - Point2D.Double[] zoomedCorners = getCorners(); - //change layout and print info message - layoutChange(typeOfZoom); - int nameIndex=-1; - for (int i = numberOfWindows; i >=1; i--) - { - String wName = Integer.toString(i); - AWindow w = ACanvas.getCanvas().getWindow(wName); - //dont zoom current window as will not save corners correctly - if (w != null && !name.equals(wName)) - { - w.saveParameters(typeOfZoom); - ACanvas.getCanvas().copyWindowSettings(currentWindow.getName(), wName); - w.saveCorners(typeOfZoom); - w.setUserCorners(zoomedCorners); - w.setScaleStatus(scaleStatus); - parameterStore.selectWindowParameters(wName); - - if(typeOfZoom.equals(ZOOM_SUMMED)) - zoomSummedOptions(i-1); - else if(typeOfZoom.equals(ZOOM_LAYERS)) - parameterStore.get("YX", "Mode").setI(AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER + i -1); - - parameterStore.restoreWindowParameters(); - ACanvas.getCanvas().moveToFrontWindow(w.getName()); - w.repaintFromScratch(); - } - else if(name.equals(wName)) - { - nameIndex=i; - } - } - //now do zoom of current window if needed - if(nameIndex>0) - { - currentWindow.saveParameters(typeOfZoom); - currentWindow.saveCorners(typeOfZoom); - currentWindow.setUserCorners(zoomedCorners); - currentWindow.setScaleStatus(scaleStatus); - parameterStore.selectWindowParameters(name); - if(typeOfZoom.equals(ZOOM_SUMMED)) - zoomSummedOptions(nameIndex-1); - else if(typeOfZoom.equals(ZOOM_LAYERS)) - parameterStore.get("YX", "Mode").setI(AProjectionYX.MODE_LAR_ENDCAP_PRESAMPLER + nameIndex -1); - parameterStore.restoreWindowParameters(); - ACanvas.getCanvas().moveToFrontWindow(name); - currentWindow.repaintFromScratch(); - } - for (int i = 1; i <= numberOfWindows; i++) - if (name.equals(Integer.toString(i))) - invalidate(); - //if doing layers zoom last window shows rhoZ view - if(typeOfZoom.equals(ZOOM_LAYERS)) - zoomLastWindow(scaleStatus, name); - } - - public void layoutChange(String typeOfZoom) - { - if(typeOfZoom.equals(ZOOM_SUMMED)) - { - //change layout - if(!ACanvas.getCanvas().getCurrentLayout().getName().equals("FOUR SQUARES")) - ACanvas.getCanvas().setCurrentLayout("FOUR SQUARES"); - //print info message - AOutput.append("\nWindows changed to:\n",ALogInterface.TITLE); - AOutput.append("Window 1: LAr Endcap -\n",ALogInterface.NORMAL); - AOutput.append("Window 2: LAr Endcap +\n",ALogInterface.NORMAL); - AOutput.append("Window 3: HEC -\n",ALogInterface.NORMAL); - AOutput.append("Window 4: HEC +\n",ALogInterface.NORMAL); - } - else if(typeOfZoom.equals(ZOOM_LAYERS)) - { - //change layout - if(!ACanvas.getCanvas().getCurrentLayout().getName().equals("SQUARE")) - ACanvas.getCanvas().setCurrentLayout("SQUARE"); - //print info message - AOutput.append("\nWindows changed to:\n",ALogInterface.TITLE); - AOutput.append("Window 1: LAr Endcap Presampler\n",ALogInterface.NORMAL); - AOutput.append("Window 2: LAr Endcap 1\n",ALogInterface.NORMAL); - AOutput.append("Window 3: LAr Endcap 2\n",ALogInterface.NORMAL); - AOutput.append("Window 4: LAr Endcap 3\n",ALogInterface.NORMAL); - AOutput.append("Window 5: HEC 1\n",ALogInterface.NORMAL); - AOutput.append("Window 6: HEC 2\n",ALogInterface.NORMAL); - AOutput.append("Window 7: HEC 3\n",ALogInterface.NORMAL); - AOutput.append("Window 8: HEC 4\n",ALogInterface.NORMAL); - AOutput.append("Window 9: rhoZ view showing both endcaps\n",ALogInterface.NORMAL); - } - } - - public void zoomSummedOptions(int i) - { - parameterStore.get("CutsCalo", "LAr").changeScope(AParameter.LOCAL); - parameterStore.get("CutsCalo", "HEC").changeScope(AParameter.LOCAL); - switch (i) - { - case 0: - parameterStore.get("CutsCalo", "LAr").setI(0); - parameterStore.get("CutsCalo", "HEC").setI(-1); - break; - case 1: - parameterStore.get("CutsCalo", "LAr").setI(1); - parameterStore.get("CutsCalo", "HEC").setI(-1); - break; - case 2: - parameterStore.get("CutsCalo", "LAr").setI(-1); - parameterStore.get("CutsCalo", "HEC").setI(-2); - break; - case 3: - parameterStore.get("CutsCalo", "LAr").setI(-1); - parameterStore.get("CutsCalo", "HEC").setI(2); - break; - } - parameterStore.get("YX", "Mode").setI(AProjectionYX.MODE_LAR_ENDCAP_SUMMED + (int) Math.floor(i/2)); - } - - public void zoomLastWindow(boolean scaleStatus, String name) - { - String wName = Integer.toString(9); - AWindow w = ACanvas.getCanvas().getWindow(wName); - //want last window to be RZ view but won't change its zoom - AProjection p = AProjectionsManager.getProjection("RZ"); - w.setProjection(p); - Point2D.Double[] newCorners = new Point2D.Double[3]; - //FIXME hardcoded geometry of endcaps - //set region to be round the endcaps - newCorners[0]=new Point2D.Double(-650.0, 225); - newCorners[1]=new Point2D.Double(650.0, 225); - newCorners[2]=new Point2D.Double(650.0, -225); - - w.setUserCorners(newCorners); - w.setScaleStatus(scaleStatus); - parameterStore.selectWindowParameters(wName); - parameterStore.restoreWindowParameters(); - ACanvas.getCanvas().moveToFrontWindow(w.getName()); - w.repaintFromScratch(); - if (name.equals(wName)) - invalidate(); - } - - public void dragPerformed(Object from, Object to, int action) - {} - - public JMenuItem[] getPopupItems() { - ArrayList al = new ArrayList(); - if(window.getUnzoomPossible()) - { - JMenuItem it = new JMenuItem("Unzoom"); - it.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - window.unzoom(); - } - }); - al.add(it); - } - if(window.getUnzoomAllPossible(ZOOM_LAYERS)) - { - JMenuItem it = new JMenuItem("Unzoom layers"); - it.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - window.unzoom(ZOOM_LAYERS); - } - }); - al.add(it); - } - if(window.getUnzoomAllPossible(ZOOM_SUMMED)) - { - JMenuItem it = new JMenuItem("Unzoom summed"); - it.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - window.unzoom(ZOOM_SUMMED); - } - }); - al.add(it); - } - if (window.getUnzoomFullPossible()) - { - JMenuItem it = new JMenuItem("Unzoom Full"); - it.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - window.unzoomFull(); - } - }); - al.add(it); - } - // Can't cast arrays very easily... - JMenuItem[] ret = new JMenuItem[al.size()]; - for(int i = 0; i < al.size(); i++) - { - ret[i] = (JMenuItem) (al.get(i)); - } - return ret; - } - - public void actionPerformed(ActionEvent e) { - String action=e.getActionCommand(); - if(action.equals("Unzoom")) { - window.unzoom(); - } - if(action.equals("Unzoom layers")) { - window.unzoom(ZOOM_LAYERS); - } - if(action.equals("Unzoom summed")) { - window.unzoom(ZOOM_SUMMED); - } - if(action.equals("Unzoom Full")) { - window.unzoomFull(); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ARotatedRectangleSelection.java b/graphics/AtlantisJava/src/atlantis/interactions/ARotatedRectangleSelection.java deleted file mode 100755 index 3cf0fd33bbe0ac326531ca8c3a1d45df779a5836..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ARotatedRectangleSelection.java +++ /dev/null @@ -1,211 +0,0 @@ -package atlantis.interactions; - - -import java.awt.*; -import java.awt.geom.*; - - -public class ARotatedRectangleSelection extends ASelection { - - // The initial starting width of the first and last sides. - private final static int STARTING_WIDTH=25; - - public ARotatedRectangleSelection() { - super(6); - } - - // Initialize the control points given the starting point (x,y). - public int init(Point2D.Double p, int key) { - isValid=false; - - setCenter(hr[0], p.x-STARTING_WIDTH, p.y); - setCenter(hr[1], p.x-STARTING_WIDTH, p.y); - setCenter(hr[2], p.x+STARTING_WIDTH, p.y); - setCenter(hr[3], p.x+STARTING_WIDTH, p.y); - setCenter(hr[4], p.x, p.y); - setCenter(hr[5], p.x, p.y); - - region=5; - return region; - } - - public void drag(Point2D.Double p, int region, int key) { - isValid=true; - double dx, dy, deltax, deltay, angle, radius; - - switch(region) { - case 0: - radius=getRadius(p.x, p.y, 4); - angle=getAngle(); - - deltax=p.x-hr[4].getCenterX(); - deltay=p.y-hr[4].getCenterY(); - - dx=-Math.round(radius*Math.sin(angle)); - dy=Math.round(radius*Math.cos(angle)); - - if(deltax*dx+deltay*dy<0) { - dx=-dx; - dy=-dy; - } - - setCenter(hr[0], hr[4].getCenterX()+dx, hr[4].getCenterY()+dy); - setCenter(hr[3], hr[4].getCenterX()-dx, hr[4].getCenterY()-dy); - setCenter(hr[1], hr[5].getCenterX()+dx, hr[5].getCenterY()+dy); - setCenter(hr[2], hr[5].getCenterX()-dx, hr[5].getCenterY()-dy); - break; - - case 1: - radius=getRadius(p.x, p.y, 5); - angle=getAngle(); - - deltax=p.x-hr[5].getCenterX(); - deltay=p.y-hr[5].getCenterY(); - - dx=-Math.round(radius*Math.sin(angle)); - dy=Math.round(radius*Math.cos(angle)); - - if(deltax*dx+deltay*dy<0) { - dx=-dx; - dy=-dy; - } - - setCenter(hr[0], hr[4].getCenterX()+dx, hr[4].getCenterY()+dy); - setCenter(hr[3], hr[4].getCenterX()-dx, hr[4].getCenterY()-dy); - setCenter(hr[1], hr[5].getCenterX()+dx, hr[5].getCenterY()+dy); - setCenter(hr[2], hr[5].getCenterX()-dx, hr[5].getCenterY()-dy); - break; - - case 2: - radius=getRadius(p.x, p.y, 5); - angle=getAngle(); - - deltax=p.x-hr[5].getCenterX(); - deltay=p.y-hr[5].getCenterX(); - - dx=-Math.round(radius*Math.sin(angle)); - dy=Math.round(radius*Math.cos(angle)); - - if(deltax*dx+deltay*dy<0) { - dx=-dx; - dy=-dy; - } - - setCenter(hr[0], hr[4].getCenterX()-dx, hr[4].getCenterY()-dy); - setCenter(hr[3], hr[4].getCenterX()+dx, hr[4].getCenterY()+dy); - setCenter(hr[1], hr[5].getCenterX()-dx, hr[5].getCenterY()-dy); - setCenter(hr[2], hr[5].getCenterX()+dx, hr[5].getCenterY()+dy); - break; - - case 3: - radius=getRadius(p.x, p.y, 4); - angle=getAngle(); - - deltax=p.x-hr[4].getCenterX(); - deltay=p.y-hr[4].getCenterY(); - - dx=-Math.round(radius*Math.sin(angle)); - dy=Math.round(radius*Math.cos(angle)); - - if(deltax*dx+deltay*dy<0) { - dx=-dx; - dy=-dy; - } - - setCenter(hr[0], hr[4].getCenterX()-dx, hr[4].getCenterY()-dy); - setCenter(hr[3], hr[4].getCenterX()+dx, hr[4].getCenterY()+dy); - setCenter(hr[1], hr[5].getCenterX()-dx, hr[5].getCenterY()-dy); - setCenter(hr[2], hr[5].getCenterX()+dx, hr[5].getCenterY()+dy); - break; - - case 4: - case 5: - radius=getRadius(hr[0].getCenterX(), hr[0].getCenterY(), 4); - - // Update the active control point. - setCenter(hr[region], p.x, p.y); - angle=getAngle(); - - dx=-Math.round(radius*Math.sin(angle)); - dy=Math.round(radius*Math.cos(angle)); - - setCenter(hr[0], hr[4].getCenterX()+dx, hr[4].getCenterY()+dy); - setCenter(hr[3], hr[4].getCenterX()-dx, hr[4].getCenterY()-dy); - setCenter(hr[1], hr[5].getCenterX()+dx, hr[5].getCenterY()+dy); - setCenter(hr[2], hr[5].getCenterX()-dx, hr[5].getCenterY()-dy); - break; - } - } - - private double getAngle() { - double deltax=hr[5].getCenterX()-hr[4].getCenterX(); - double deltay=hr[5].getCenterY()-hr[4].getCenterY(); - - if(deltax!=0||deltay!=0) - return Math.atan2(deltay, deltax); - else - return 0.; - } - - public void paint(Graphics2D g) { - paintStandard(g); - } - - /** - * Make the affine transform which corresponds to this rectangular selection. - */ - public Point2D.Double[] getCorners() { - int first=getUpperLeftRegion(); - - // Calculate the index of the opposite corner. - int third=(first+2)%4; - - // Now use the cross-product to determine which of the - // remaining points is the one which keep the path going - // clockwise. - int second=(first+1)%4; - double dx0=hr[third].getCenterX()-hr[first].getCenterX(); - double dy0=hr[third].getCenterY()-hr[first].getCenterY(); - double dx1=hr[second].getCenterX()-hr[first].getCenterX(); - double dy1=hr[second].getCenterY()-hr[first].getCenterY(); - - if(dx0*dy1-dy0*dx1>0) - second=(first+3)%4; - // Get the appropriate radius. - int centerIndex=(first==0||first==3)?4:5; - double radius=getRadius(hr[first].getCenterX(), hr[first].getCenterY(), centerIndex); - double angle=getAngle(); - // Calculate the delta-x and delta-y for the points. - double dx=Math.abs(radius*Math.sin(angle)); - double dy=Math.abs(radius*Math.cos(angle)); - // Get the sign of the offsets from the control points. - double sdx; - double sdy; - - // The point closest to the origin. - centerIndex=(first==0||first==3)?4:5; - sdx=((hr[first].getCenterX()-hr[centerIndex].getCenterX())>0)?1.:-1.; - sdy=((hr[first].getCenterY()-hr[centerIndex].getCenterY())>0)?1.:-1.; - double x0=hr[centerIndex].getCenterX()+sdx*dx; - double y0=hr[centerIndex].getCenterY()+sdy*dy; - - // The next point clockwise. - centerIndex=(second==0||second==3)?4:5; - sdx=((hr[second].getCenterX()-hr[centerIndex].getCenterX())>0)?1.:-1.; - sdy=((hr[second].getCenterY()-hr[centerIndex].getCenterY())>0)?1.:-1.; - double x1=hr[centerIndex].getCenterX()+sdx*dx; - double y1=hr[centerIndex].getCenterY()+sdy*dy; - - // The next point clockwise. - centerIndex=(third==0||third==3)?4:5; - sdx=((hr[third].getCenterX()-hr[centerIndex].getCenterX())>0)?1.:-1.; - sdy=((hr[third].getCenterY()-hr[centerIndex].getCenterY())>0)?1.:-1.; - double x2=hr[centerIndex].getCenterX()+sdx*dx; - double y2=hr[centerIndex].getCenterY()+sdy*dy; - - // The control points are in the correct order, so we can just - // call the utility function of the parent. - return convert(x0, y0, x1, y1, x2, y2); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ARubberbandGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/ARubberbandGroup.java deleted file mode 100755 index fe8e54b62bde88af517ad5a65fcb96188a2d882f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ARubberbandGroup.java +++ /dev/null @@ -1,109 +0,0 @@ -package atlantis.interactions; - -import atlantis.canvas.ACanvas; -import atlantis.output.AExceptionHandler; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.JMenuItem; -import javax.swing.JMenu; -import javax.swing.JComboBox; -import javax.swing.JPanel; - -import java.lang.reflect.Constructor; -import java.util.HashMap; - -public class ARubberbandGroup extends AInteractionGroup { - - private final static String[] RUBBERBAND_NAMES= {"Rectangle", "RotatedRectangle", "Parallelogram", - "Square", "XSkew", "YSkew", "XSlice", "YSlice"}; - - private HashMap rubberbands; - private JComboBox rbComboBox; - // the panel that will contain the additional controls for the interactions - private JPanel additionalControls; - - public ARubberbandGroup(AInteractionsManager manager) { - super(AInteractionGroup.WINDOW_GROUP, manager); - - // create the additional controls panel - additionalControls = new JPanel(); - - rubberbands=new HashMap(); - rbComboBox=new JComboBox(); - - for(int i=0; i<RUBBERBAND_NAMES.length; i++) { - rbComboBox.addItem(RUBBERBAND_NAMES[i]); - try { - Constructor[] c=Class.forName("atlantis.interactions.A"+RUBBERBAND_NAMES[i]+"Selection").getDeclaredConstructors(); - - rubberbands.put(RUBBERBAND_NAMES[i], c[0].newInstance(new Object[] {})); - } catch(Exception e) { - AExceptionHandler.processException("Cannot make selection "+"A"+RUBBERBAND_NAMES[i] - +"Selection", - e); - } - } - - rbComboBox.addActionListener(new RuberbandListener()); - additionalControls.add(rbComboBox); - - changeRubberband(); - } - - /** - * rubberband has additional controls, so return true - */ - public boolean hasAdditionalControls() { - return true; - } - - /** - * returns the additional controls - */ - public JPanel getAdditionalControls() { - return additionalControls; - } - - private void changeRubberband() { - String item=(String)rbComboBox.getSelectedItem(); - - removeAllInteractions(); - addInteraction((AInteraction)rubberbands.get(item)); - iManager.setContext(this); - } - - // generating the menu - public JMenuItem getPopupItem() { - JMenu menu=new JMenu(name); - ActionListener l=new PopupListener(); - - for(int i=0; i<RUBBERBAND_NAMES.length; i++) - menu.add(RUBBERBAND_NAMES[i]).addActionListener(l); - - return menu; - } - - public void setGroupState(AInteractionGroup givenGroup) { - if(givenGroup instanceof ARubberbandGroup) { - ARubberbandGroup panel=(ARubberbandGroup)givenGroup; - - this.rbComboBox.setSelectedIndex(panel.rbComboBox.getSelectedIndex()); - } - } - - class RuberbandListener implements ActionListener { - public void actionPerformed(ActionEvent e) { - changeRubberband(); - } - } - - - class PopupListener implements ActionListener { - public void actionPerformed(ActionEvent e) { - ACanvas.getCanvas().getCurrentWindow().getInteractionToolBar().setSelectedGroup(name); - rbComboBox.setSelectedItem(e.getActionCommand()); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ARubberbandYXGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/ARubberbandYXGroup.java deleted file mode 100755 index 705da5e8e13760586ee380943ab41205f9e074b6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ARubberbandYXGroup.java +++ /dev/null @@ -1,109 +0,0 @@ -package atlantis.interactions; - -import atlantis.canvas.ACanvas; -import atlantis.output.AExceptionHandler; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.JMenuItem; -import javax.swing.JMenu; -import javax.swing.JComboBox; -import javax.swing.JPanel; - -import java.lang.reflect.Constructor; -import java.util.HashMap; - -public class ARubberbandYXGroup extends AInteractionGroup { - - private final static String[] RUBBERBAND_NAMES= {"RectangleYX", "RotatedRectangle", "Parallelogram", - "Square", "XSkew", "YSkew", "XSlice", "YSlice"}; - - private HashMap rubberbands; - private JComboBox rbComboBox; - // the panel that will contain the additional controls for the interactions - private JPanel additionalControls; - - public ARubberbandYXGroup(AInteractionsManager manager) { - super(AInteractionGroup.WINDOW_GROUP, manager); - - // create the additional controls panel - additionalControls = new JPanel(); - - rubberbands=new HashMap(); - rbComboBox=new JComboBox(); - - for(int i=0; i<RUBBERBAND_NAMES.length; i++) { - rbComboBox.addItem(RUBBERBAND_NAMES[i]); - try { - Constructor[] c=Class.forName("atlantis.interactions.A"+RUBBERBAND_NAMES[i]+"Selection").getDeclaredConstructors(); - - rubberbands.put(RUBBERBAND_NAMES[i], c[0].newInstance(new Object[] {})); - } catch(Exception e) { - AExceptionHandler.processException("Cannot make selection "+"A"+RUBBERBAND_NAMES[i] - +"Selection", - e); - } - } - - rbComboBox.addActionListener(new RuberbandListener()); - additionalControls.add(rbComboBox); - - changeRubberband(); - } - - /** - * rubberband has additional controls, so return true - */ - public boolean hasAdditionalControls() { - return true; - } - - /** - * returns the additional controls - */ - public JPanel getAdditionalControls() { - return additionalControls; - } - - private void changeRubberband() { - String item=(String)rbComboBox.getSelectedItem(); - - removeAllInteractions(); - addInteraction((AInteraction)rubberbands.get(item)); - iManager.setContext(this); - } - - // generating the menu - public JMenuItem getPopupItem() { - JMenu menu=new JMenu(name); - ActionListener l=new PopupListener(); - - for(int i=0; i<RUBBERBAND_NAMES.length; i++) - menu.add(RUBBERBAND_NAMES[i]).addActionListener(l); - - return menu; - } - - public void setGroupState(AInteractionGroup givenGroup) { - if(givenGroup instanceof ARubberbandYXGroup) { - ARubberbandYXGroup panel=(ARubberbandYXGroup)givenGroup; - - this.rbComboBox.setSelectedIndex(panel.rbComboBox.getSelectedIndex()); - } - } - - class RuberbandListener implements ActionListener { - public void actionPerformed(ActionEvent e) { - changeRubberband(); - } - } - - - class PopupListener implements ActionListener { - public void actionPerformed(ActionEvent e) { - ACanvas.getCanvas().getCurrentWindow().getInteractionToolBar().setSelectedGroup(name); - rbComboBox.setSelectedItem(e.getActionCommand()); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AScaleCopyGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/AScaleCopyGroup.java deleted file mode 100755 index 05a6d681437cc4f81ce3f5b448dab89475e1b886..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AScaleCopyGroup.java +++ /dev/null @@ -1,14 +0,0 @@ -package atlantis.interactions; - - -public class AScaleCopyGroup extends AInteractionGroup { - - AScaleCopyInteraction scaleCopyInteraction; - - public AScaleCopyGroup(AInteractionsManager iManager) { - super(AInteractionGroup.CANVAS_GROUP, iManager); - scaleCopyInteraction=new AScaleCopyInteraction(); - this.addInteraction(scaleCopyInteraction); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AScaleCopyInteraction.java b/graphics/AtlantisJava/src/atlantis/interactions/AScaleCopyInteraction.java deleted file mode 100755 index 6e4492014d799ac59faa5d2f2b710bad4642a35a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AScaleCopyInteraction.java +++ /dev/null @@ -1,24 +0,0 @@ -package atlantis.interactions; - -import java.awt.*; -import java.awt.geom.*; - -public class AScaleCopyInteraction extends AInteraction { - - public AScaleCopyInteraction() { - super(1, AUTOMATIC_REPAINT, SCREEN_COORDINATES, false); - hr[0]=new Rectangle2D.Double(0, 0, 0, 0); - } - - public void paint(Graphics2D g) {} - - public void connect(AInteractionsManager manager) { - super.connect(manager); - window.setScaleCopyStatus(true); - } - - public void disconnect() { - window.setScaleCopyStatus(false); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ASelection.java b/graphics/AtlantisJava/src/atlantis/interactions/ASelection.java deleted file mode 100755 index 1a7b181aea5cdda8591aa07058275b8995966e05..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ASelection.java +++ /dev/null @@ -1,455 +0,0 @@ -package atlantis.interactions; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; - -import java.awt.GridLayout; -import java.awt.Point; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.Dimension; -import java.awt.Polygon; -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; -import java.awt.geom.Point2D; -import java.awt.geom.Ellipse2D; - -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JMenuItem; -import javax.swing.JButton; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.graphics.ADrawnGraphics2D; -import atlantis.graphics.AGraphics; -import atlantis.graphics.ACoord; -import atlantis.graphics.dnd.ADnDButton; -import atlantis.graphics.dnd.ADnDLabel; -import atlantis.graphics.dnd.ADragListener; -import atlantis.gui.AGUI; -import atlantis.gui.ALogPane; -import atlantis.list.AListManager; -import atlantis.list.AList; -import atlantis.output.AExceptionHandler; -import atlantis.output.AOutput; -import atlantis.utils.ALogger; -import atlantis.utils.AMath; - - - -/** - * The superclass of all the selection (rubberband) interactions. - */ -public abstract class ASelection extends AInteraction - implements ASleepMouseDragListener, ActionListener -{ - - private static ALogger logger = ALogger.getLogger(ASelection.class); - - private JPanel actionsPanel; - private GridLayout actionsPanelLayout; - private int d = 10; - private boolean[][] map; - protected final static int radius = 10; - protected int region; - protected boolean isValid = false; - - - public final static String ZOOM = "Zoom"; - public final static String NEW_LIST = "New List"; - public final static String SUMMARIZE = "Summarize"; - - - - public ASelection(int hotRegionsCount) - { - super(hotRegionsCount, AUTOMATIC_REPAINT, SCREEN_COORDINATES, true); - - for(int i = 0; i < hr.length; i++) - { - hr[i] = new Ellipse2D.Double(0, 0, radius, radius); - } - - actionsPanelLayout = new GridLayout(0, 1); - actionsPanel = new JPanel(actionsPanelLayout); - - - addActionButton(ZOOM, new ADragListener() - { - public void dragPerformed(Object from, Object to, int action) - { - if(to instanceof ADnDLabel) - { - zoomIn(((ADnDLabel) to).getText()); - } - else if(to instanceof AWindow) - { - zoomIn(((AWindow) to).getName()); - } - invalidate(); - } - }, - new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - window.saveCorners(); - window.setUserCorners(getCorners()); - invalidate(); - } - }); - - - addActionButton(NEW_LIST, new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - if(e.getActionCommand().equals(NEW_LIST)) - { - Point2D.Double[] zoomedCorners = getCorners(); - Point2D.Double[] userCorners = window.getUserCorners(); - window.setUserCornersNoRepaint(zoomedCorners); - Rectangle bounds = window.getBounds(); - bounds.setLocation(0, 0); - window.paintWindowFromScratch(new ADrawnGraphics2D(bounds)); - ADrawnGraphics2D.updateLastDrawn(); - AListManager.getInstance().copyLastDrawn(); - AListManager.getInstance().showLists(); - window.setUserCornersNoRepaint(userCorners); - } - } - }); - - - addActionButton(SUMMARIZE, new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - if(e.getActionCommand().equals(SUMMARIZE)) - { - Point2D.Double[] zoomedCorners = getCorners(); - Point2D.Double[] userCorners = window.getUserCorners(); - window.setUserCornersNoRepaint(zoomedCorners); - Rectangle bounds = window.getBounds(); - bounds.setLocation(0, 0); - window.paintWindowFromScratch(new ADrawnGraphics2D(bounds)); - ADrawnGraphics2D.updateLastDrawn(); - AListManager.getInstance().summarize(); - window.setUserCornersNoRepaint(userCorners); - } - } - }); - - } // ASelection() --------------------------------------------------------- - - - - - public void invalidate() - { - isValid = false; - actionsPanel.setVisible(false); - } - - - public void addActionButton(String buttonName, ADragListener dragList, - ActionListener clickList) - { - ADnDButton b = new ADnDButton(buttonName); - b.setFocusPainted(false); - b.addActionListener(clickList); - b.addDragListener(dragList); - actionsPanelLayout.setRows(actionsPanelLayout.getRows() + 1); - actionsPanel.add(b); - actionsPanel.setSize(actionsPanel.getPreferredSize()); - } - - - public void addActionButton(String buttonName, ActionListener clickListener) - { - JButton b = new JButton(buttonName); - b.setFocusPainted(false); - b.addActionListener(clickListener); - actionsPanelLayout.setRows(actionsPanelLayout.getRows() + 1); - actionsPanel.add(b); - actionsPanel.setSize(actionsPanel.getPreferredSize()); - } - - - public JMenuItem[] getPopupItems() - { - ArrayList<JMenuItem> al = new ArrayList<JMenuItem>(); - if(window.getUnzoomPossible()) - { - JMenuItem it = new JMenuItem("Unzoom"); - it.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - window.unzoom(); - } - }); - al.add(it); - } - if(window.getUnzoomFullPossible()) - { - JMenuItem it = new JMenuItem("Unzoom Full"); - it.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - window.unzoomFull(); - } - }); - al.add(it); - } - // Can't cast arrays very easily... - JMenuItem[] ret = new JMenuItem[al.size()]; - for(int i = 0; i < al.size(); i++) - { - ret[i] = al.get(i); - } - return ret; - - } - - - public void actionPerformed(ActionEvent e) - { - String action = e.getActionCommand(); - if(action.equals("Unzoom")) - { - window.unzoom(); - } - } - - - public int getPopupType() - { - return APopupListener.WINDOW_POPUP; - } - - - public void connect(AInteractionsManager manager) - { - super.connect(manager); - window.getView().add(actionsPanel); - if(isValid) - { - actionsPanel.setVisible(true); - } - else - { - actionsPanel.setVisible(false); - } - window.validate(); - } - - - public void disconnect() - { - window.getView().remove(actionsPanel); - } - - - public int getButton() - { - return AInteractionsManager.LEFT; - } - - - public void start(Point2D.Double p, int region, int key) - { - this.region = region; - actionsPanel.setVisible(false); - } - - - public void cancel() {} - - - private boolean canLayout(int i0, int j0) - { - Dimension panelSize = actionsPanel.getSize(); - panelSize.width = (int) Math.ceil((panelSize.width + d) / (double) d); - panelSize.height = (int) Math.ceil((panelSize.height + d) / (double) d); - for(int j = 0; j < panelSize.height; j++) - { - for(int i = 0; i < panelSize.width; i++) - { - if(i0 + i > map[0].length - 1)return false; - if(j0 + j > map.length - 1)return false; - if(map[j0 + j][i0 + i] == false)return false; - } - } - return true; - - } - - - private Point calculateBestPosition() - { - AWindow w = window; - Dimension size = w.getView().getSize(); - int ny = (int) Math.ceil(size.height / (double) d); - int nx = (int) Math.ceil(size.width / (double) d); - map = new boolean[ny][nx]; - Polygon p = new Polygon(); - for(int i = 0; i < 4; i++) - { - p.addPoint((int) hr[i].getCenterX(), (int) hr[i].getCenterY()); - } - - for(int j = 0; j < map.length; j++) - { - for(int i = 0; i < map[0].length; i++) - { - if(p.intersects(i * d, j * d, d, d) || p.contains(i * d, j * d, d, d)) - { - map[j][i] = false; - } - else - { - map[j][i] = true; - } - } - } - - for(int j = 0; j < map.length; j++) - { - for(int i = 0; i < map[0].length; i++) - { - if(canLayout(i, j)) - { - map[j][i] = true; - } - else - { - map[j][i] = false; - } - } - } - - int x0 = (int) hr[region].getMaxX(); - int y0 = (int) hr[region].getMaxY(); - int i_min = 0, j_min = 0; - double dist, dist_min = 1e10; - for(int j = 0; j < map.length; j++) - { - for(int i = 0; i < map[0].length; i++) - { - if(map[j][i] == true) - { - dist = Math.hypot(x0 - i*d, y0 - j*d); - if(dist < dist_min) - { - i_min = i; - j_min = j; - dist_min = dist; - } - } - } - } - - return new Point(i_min * d + d / 2, j_min * d + d / 2); - } - - - public void stop() - { - if(isValid) - { - Point p = calculateBestPosition(); - actionsPanel.setLocation(p.x, p.y); - actionsPanel.setVisible(true); - window.revalidate(); - } - } - - - protected int getUpperLeftRegion() - { - int point = 0; - double savedValue = getRadius(hr[0]); - for(int i = 1; i < 4; i++) - { - double value = getRadius(hr[i]); - if(value < savedValue) - { - savedValue = value; - point = i; - } - } - return point; - } - - - protected Point2D.Double[] convert( - double x0, double y0, double x1, double y1, double x2, double y2) - { - if(!isValid) - { - return window.getUserCorners(); - } - if(Math.abs(getAPolygon().getArea()) == 0) - { - return window.getUserCorners(); - } - - double[][][] hv = new double[2][1][3]; - hv[0][0][0] = x0; - hv[1][0][0] = y0; - hv[0][0][1] = x1; - hv[1][0][1] = y1; - hv[0][0][2] = x2; - hv[1][0][2] = y2; - ACoord d = window.calculateUser(new ACoord(hv)); - Point2D.Double[] corners = new Point2D.Double[3]; - for(int i = 0; i < 3; i++) - { - corners[i] = new Point2D.Double(d.hv[0][0][i], d.hv[1][0][i]); - } - - return corners; - } - - - protected Point2D.Double[] convert(int region1, int region2, int region3) - { - return convert(hr[region1].getCenterX(), hr[region1].getCenterY(), - hr[region2].getCenterX(), - hr[region2].getCenterY(), hr[region3].getCenterX(), - hr[region3].getCenterY()); - } - - - public abstract Point2D.Double[] getCorners(); - - - protected void paintStandard(Graphics2D g) - { - if(isValid) - { - AGraphics ag = AGraphics.makeAGraphics(g); - ag.updateDrawParameters(frameDrawParameters); - ag.drawPolygon(getAPolygon()); - drawLine(4, 5, ag); - ag.updateDrawParameters(drawParameters); - ag.drawPolygon(getAPolygon()); - drawLine(4, 5, ag); - drawActivePoint(region, ag); - } - } - - - public void zoomIn(String zoomWindow) - { - String currentWindow = window.getName(); - ACanvas.getCanvas().copyWindowSettings(currentWindow, zoomWindow); - ACanvas.getCanvas().getWindow(zoomWindow).setUserCorners(getCorners()); - } - -} // class ASelection ======================================================= diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ASkewGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/ASkewGroup.java deleted file mode 100755 index 70057212cca9158e3647cdc34bf25d94726e62b6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ASkewGroup.java +++ /dev/null @@ -1,14 +0,0 @@ -package atlantis.interactions; - - -public class ASkewGroup extends AInteractionGroup { - - ASkewInteraction skewInteraction; - - public ASkewGroup(AInteractionsManager iManager) { - super(AInteractionGroup.WINDOW_GROUP, iManager); - skewInteraction=new ASkewInteraction(); - this.addInteraction(skewInteraction); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ASkewInteraction.java b/graphics/AtlantisJava/src/atlantis/interactions/ASkewInteraction.java deleted file mode 100755 index a338f168638e6818e3cde18ac128e80bd5bd6106..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ASkewInteraction.java +++ /dev/null @@ -1,123 +0,0 @@ -package atlantis.interactions; - -import atlantis.canvas.AWindow; -import atlantis.parameters.APar; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjection; -import atlantis.projection.AProjectionRZ; -import java.awt.*; -import java.awt.geom.*; -import java.awt.event.*; -import javax.swing.*; - -/** - * The interaction that performs a skew on the picture. - */ -public class ASkewInteraction extends AInteraction - implements ASleepMouseDragListener, ActionListener { - - private int d=20; - private Point2D.Double p0; - private JMenuItem[] popupItems; - private final static String NO_SKEW="Set No Skew"; - - public ASkewInteraction() { - super(1, WINDOW_TOTAL_REPAINT, WORLD_COORDINATES, false); - - popupItems = new JMenuItem[] { - new JMenuItem(NO_SKEW) - }; - - popupItems[0].addActionListener(this); - - // The center of the ellipse is in (0, 0) in User Space - hr[0]=new Ellipse2D.Double(-d/2, -d/2, d, d); - } - - public int init(Point2D.Double p, int key) { - p0=p; - return 0; - } - - public int getButton() { - return AInteractionsManager.LEFT; - } - - public void start(Point2D.Double p, int region, int key) {} - - public void drag(Point2D.Double p, int region, int key) { - AProjection proj=window.getProjection(); - - if(proj instanceof AProjectionFR) { - performFRSkew(-(p.y-p0.y)/p0.x, window); - } else if(proj instanceof AProjectionFZ) { - performFZSkew(-(p.y-p0.y)/p0.x, window); - } else if(proj instanceof AProjectionRZ) { - if(key==KeyEvent.VK_V) - performFZSkew(-(p.y-p0.y)/p0.x, window); - else - performRZSkew(-(p.x-p0.x)/p0.y, window); - } - } - - public static void performFRSkew(double f, AWindow window) { - Point2D.Double[] corners=window.getUserCorners(); - - for(int i=0; i<corners.length; i++) - corners[i].y+=f*corners[i].x; - - window.setUserCorners(corners); - } - - public static void performFZSkew(double f, AWindow window) { - Point2D.Double[] corners=window.getUserCorners(); - - double zVtx=parameterStore.get("Event", "ZVtx").getD(); - - for(int i=0; i<corners.length; i++) - corners[i].y+=f*(corners[i].x-zVtx); - - window.setUserCorners(corners); - } - - public static void performRZSkew(double f, AWindow window) { - Point2D.Double[] corners=window.getUserCorners(); - - for(int i=0; i<corners.length; i++) - corners[i].x+=f*corners[i].y; - - window.setUserCorners(corners); - } - - public void stop() {} - - public void cancel() {} - - public void paint(Graphics2D g) {} - - public int getPopupType() { - return APopupListener.WINDOW_POPUP; - } - - public JMenuItem[] getPopupItems() { - return popupItems; - } - - public void actionPerformed(ActionEvent e) { - - } - public AModifier[] getModifiers(){ - if(window.getProjection() instanceof AProjectionRZ) { - return new AModifier[] { - new AModifier(KeyEvent.VK_V, false, "Y Skew"), - new AModifier(KeyEvent.VK_H, false, "X Skew"), - new AModifier(KeyEvent.VK_UNDEFINED, false, "X Skew") - }; - } else { - return new AModifier[0]; - } - } - - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ASleepMouseDragListener.java b/graphics/AtlantisJava/src/atlantis/interactions/ASleepMouseDragListener.java deleted file mode 100755 index 60b145d8b1321156e9230b2a2804f1dd5bee9db8..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ASleepMouseDragListener.java +++ /dev/null @@ -1,13 +0,0 @@ -package atlantis.interactions; - - -import java.awt.geom.*; - - -/** - * This listener extends AMouseDragListener in order to make it possible to - * get drag events even without any hot region. - */ -public interface ASleepMouseDragListener extends AMouseDragListener { - int init(Point2D.Double p, int key); -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ASquareSelection.java b/graphics/AtlantisJava/src/atlantis/interactions/ASquareSelection.java deleted file mode 100755 index 0f12dae04d5737448c5fb97497940e04fbb49011..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ASquareSelection.java +++ /dev/null @@ -1,87 +0,0 @@ -package atlantis.interactions; - -import java.awt.Graphics2D; -import java.awt.geom.Point2D; - -import atlantis.graphics.AGraphics; -import atlantis.utils.AMath; - -public class ASquareSelection extends ASelection -{ - public ASquareSelection() - { - super(5); - } - - public int init(Point2D.Double p, int key) - { - isValid = false; - - for (int i = 0; i < 5; i++) - setCenter(hr[i], p.x, p.y); - - this.region = 2; - return region; - } - - public void drag(Point2D.Double p, int region, int key) - { - isValid = true; - - if (region == 4) - { - double dx = p.x - hr[4].getCenterX(); - double dy = p.y - hr[4].getCenterY(); - - for (int i = 0; i < 5; i++) - setCenter(hr[i], hr[i].getCenterX() + dx, hr[i].getCenterY() + dy); - } - else - { - double ratio = ((double) window.getSize().width) / ((double) window.getSize().height); - - double sx1 = AMath.getSign(p.x - hr[4].getCenterX()); - double sy1 = AMath.getSign(p.y - hr[4].getCenterY()); - double sx2 = sy1; - double sy2 = sx1; - double dy = getRadius(p.x, p.y, 4) / Math.sqrt(1 + ratio * ratio); - double dx = dy * ratio; - - setCenter(hr[region], hr[4].getCenterX() + dx * sx1, hr[4].getCenterY() + dy * sy1); - setCenter(hr[(region + 2) % 4], hr[4].getCenterX() - dx * sx1, hr[4].getCenterY() - dy * sy1); - - setCenter(hr[(region + 1) % 4], hr[4].getCenterX() - dx * sx2, hr[4].getCenterY() + dy * sy2); - setCenter(hr[(region + 3) % 4], hr[4].getCenterX() + dx * sx2, hr[4].getCenterY() - dy * sy2); - } - } - - public void paint(Graphics2D g) - { - if (isValid) - { - AGraphics ag = AGraphics.makeAGraphics(g); - - ag.updateDrawParameters(frameDrawParameters); - ag.drawPolygon(getAPolygon()); - drawLine(0, 2, ag); - drawLine(1, 3, ag); - ag.updateDrawParameters(drawParameters); - ag.drawPolygon(getAPolygon()); - drawLine(0, 2, ag); - drawLine(1, 3, ag); - drawActivePoint(region, ag); - } - } - - public Point2D.Double[] getCorners() - { - int first = getUpperLeftRegion(); - - // Calculate the adjacent partner and the opposite corner. - int second = (first + 1) % 4; - int third = (first + 2) % 4; - - return convert(first, second, third); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ASynchroCursorsGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/ASynchroCursorsGroup.java deleted file mode 100755 index 4a74be687a74ee353eb4c36c173e26695b816f9b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ASynchroCursorsGroup.java +++ /dev/null @@ -1,15 +0,0 @@ -package atlantis.interactions; - - -public class ASynchroCursorsGroup extends AInteractionGroup { - - private ASynchroCursorsInteraction mmSelection; - - public ASynchroCursorsGroup(AInteractionsManager iManager) { - super(AInteractionGroup.CANVAS_GROUP, iManager); - - mmSelection=new ASynchroCursorsInteraction(); - addInteraction(mmSelection); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/ASynchroCursorsInteraction.java b/graphics/AtlantisJava/src/atlantis/interactions/ASynchroCursorsInteraction.java deleted file mode 100755 index 9f7915a17dc9d8b4f2571e090e745acdd480aec6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/ASynchroCursorsInteraction.java +++ /dev/null @@ -1,483 +0,0 @@ -package atlantis.interactions; - -import java.awt.Graphics2D; -import java.awt.event.KeyEvent; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Point2D; - -import atlantis.canvas.ACanvas; -import atlantis.graphics.ACoord; -import atlantis.graphics.ACursorFactory; -import atlantis.graphics.AGraphics; -import atlantis.parameters.APar; -import atlantis.parameters.AParameterUtilities; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjectionLegoPlot; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionXZ; -import atlantis.projection.AProjectionYX; -import atlantis.projection.AProjectionYZ; -import atlantis.utils.AMath; - -public class ASynchroCursorsInteraction extends AInteraction - implements ASleepMouseDragListener, AEnterExitListener -{ - /** - * The position of the moving marker in 3D. Phi is in degrees. - * (Must be static) - */ - private static double rho, phi, z, sign_rho; - - private static final double NOT_DEFINED = 9999.0; - private static final double RHO_MAX = 3000.0; - private static final double PHI_MAX = 400.0; - private static final double Z_MAX = 3000.0; - private static final double ETA_MAX = 10.0; - - private static int key = 0; - protected int radius = 10; - - public ASynchroCursorsInteraction() - { - super(1, ALL_WINDOWS_REPAINT, WORLD_COORDINATES, true); - hr[0] = new Ellipse2D.Double(0, 0, radius, radius); - } - - public int getButton() - { - return AInteractionsManager.LEFT; - } - - /** - * Initialize the control points based on the starting point - */ - public int init(Point2D.Double p, int key) - { - this.key = key; - setCenter(hr[0], p.x, p.y); - // ACanvas.getCanvas().repaintOthers(window); - return 0; - } - - public void start(Point2D.Double p, int region, int key) - { - //call drag to update the cursor even if only a button is pressed - drag(p,region,key); - } - - /** - * Move the active control point to the point (x, y). - * - * @param pInput the input point - * @param region the region - * @param key the current key being pressed - */ - public void drag(Point2D.Double pInput, int region, int key) - { - this.key = key; - AProjection2D projection = (AProjection2D) window.getProjection(); - - Point2D.Double p = projection.inverseNonLinearTransform(pInput); - - setCenter(hr[0], p.x, p.y); - - rho = NOT_DEFINED; - z = NOT_DEFINED; - phi = NOT_DEFINED; - sign_rho = 1.; - - if (projection instanceof AProjectionYX) - { - phi = Math.toDegrees(Math.atan2(p.y, p.x)); - if (phi < 0.) - phi += 360.; - rho = AParameterUtilities.getRhoSign(p.x, p.y) * Math.sqrt(p.x * p.x + p.y * p.y); - } - else if (projection instanceof AProjectionFR) - { - phi = p.y; - rho = p.x; - } - else if (projection instanceof AProjectionFZ) - { - phi = p.y; - z = p.x; - } - else if (projection instanceof AProjectionRZ) - { - rho = Math.abs(p.y); - if (p.y < 0.) - sign_rho = -1.; - z = p.x; - } - else if (projection instanceof AProjectionYZ) - { - z = p.x; - } - else if (projection instanceof AProjectionXZ) - { - z = p.x; - } - else if (projection instanceof AProjectionVP) - { - phi = p.y; - rho = parameterStore.get("VP", "RMax").getD(); - double eta = p.x; - - z = parameterStore.get("Event", "ZVtx").getD() + 0.5 * rho * (Math.exp(eta) - 1. / Math.exp(eta)); - } - else if (projection instanceof AProjectionLegoPlot) - { - // added by Mark Stockton - // update parameters - AProjectionLegoPlot.update(); - //reverse the adjustPhi function - p.x=-(AProjectionLegoPlot.adjustPhi(window,-p.x,p.y)); - if(p.x>-1.0 && p.x<361.0 && p.y>-5.01 && p.y<5.01) - { - phi=p.x; - rho = parameterStore.get("VP", "RMax").getD(); - double eta=p.y; - if (AProjectionLegoPlot.reverse) - eta = -eta; - z = parameterStore.get("Event", "ZVtx").getD() + 0.5 * rho * (Math.exp(eta) - 1. / Math.exp(eta)); - } - } - if (key == KeyEvent.VK_P && phi != NOT_DEFINED) - { - double phiRZ = phi + 90.; - - if (phiRZ < 0.) - phiRZ += 360; - if (phiRZ > 360.) - phiRZ -= 360; - parameterStore.get("RZ", "Phi").setD(phiRZ); - parameterStore.get("RZ", "Phi").globalize(ACanvas.getCanvas().getCurrentWindow().getIndex()); - ACanvas.getCanvas().repaintAllFromScratch(); - } - else - ACanvas.getCanvas().repaintOthers(window); - } - - public void cancel() - {} - - public void stop() - {} - - public void paint(Graphics2D g) - { - // must use the window version of the parameters - parameterStore.selectWindowParameters(window.getName()); - AProjection2D projection = (AProjection2D) window.getProjection(); - AGraphics ag = AGraphics.makeAGraphics(g); - - for (int i = 0; i < 2; i++) - { - if (i == 0) - ag.updateDrawParameters(frameDrawParameters); - else - ag.updateDrawParameters(drawParameters); - - if (projection instanceof AProjectionYX) - { - if (phi != NOT_DEFINED) - { - double r = (rho == NOT_DEFINED) ? RHO_MAX : Math.abs(rho); - double cosPhi = Math.cos(Math.toRadians(phi)); - double sinPhi = Math.sin(Math.toRadians(phi)); - - Point2D.Double p = window.calculateDisplay(projection.nonLinearTransform(0, 0)); - Point2D.Double p1 = window.calculateDisplay(projection.nonLinearTransform(r * cosPhi, r * sinPhi)); - Point2D.Double p2 = window.calculateDisplay(projection.nonLinearTransform(RHO_MAX * cosPhi, RHO_MAX * sinPhi)); - Point2D.Double p3 = window.calculateDisplay(projection.nonLinearTransform(-RHO_MAX * cosPhi, -RHO_MAX * sinPhi)); - - if (key == KeyEvent.VK_P) - { - ag.drawLine(p2.x, p2.y, p3.x, p3.y); - } - else - { - ag.drawLine(p.x, p.y, p2.x, p2.y); - if (rho != NOT_DEFINED) - ag.drawSymbol(p1.x, p1.y); - } - - } - else if (rho != NOT_DEFINED) - { - int numPoints = 48; - double[][][] hv = new double[2][1][numPoints]; - - for (int j = 0; j < numPoints; j++) - { - hv[0][0][j] = rho * Math.cos(Math.PI * 2 * j / 48); - hv[1][0][j] = rho * Math.sin(Math.PI * 2 * j / 48); - } - ACoord d = window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv))); - - ag.drawPolygon(d.hv[0][0], d.hv[1][0], numPoints); - } - } - else if (projection instanceof AProjectionFR) - { - int numPoints = 5; - double[][][] hv = new double[2][1][numPoints]; - - hv[0][0][0] = Math.abs(rho); - hv[1][0][0] = phi; - hv[0][0][1] = Math.abs(rho); - hv[1][0][1] = 0.; - hv[0][0][2] = Math.abs(rho); - hv[1][0][2] = RHO_MAX; - hv[0][0][3] = 0.; - hv[1][0][3] = phi; - hv[0][0][4] = RHO_MAX; - hv[1][0][4] = phi; - ACoord d = window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv))); - - if (rho != NOT_DEFINED) - ag.drawLine(d.hv[0][0][1], d.hv[1][0][1], d.hv[0][0][2], d.hv[1][0][2]); - if (phi != NOT_DEFINED) - ag.drawLine(d.hv[0][0][3], d.hv[1][0][3], d.hv[0][0][4], d.hv[1][0][4]); - if (rho != NOT_DEFINED && phi != NOT_DEFINED) - ag.drawSymbol(d.hv[0][0][0], d.hv[1][0][0]); - } - else if (projection instanceof AProjectionFZ) - { - int numPoints = 5; - double[][][] hv = new double[2][1][numPoints]; - - hv[0][0][0] = z; - hv[1][0][0] = phi; - hv[0][0][1] = z; - hv[1][0][1] = 0.; - hv[0][0][2] = z; - hv[1][0][2] = PHI_MAX; - hv[0][0][3] = -Z_MAX; - hv[1][0][3] = phi; - hv[0][0][4] = Z_MAX; - hv[1][0][4] = phi; - ACoord d = window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv))); - - if (z != NOT_DEFINED) - ag.drawLine(d.hv[0][0][1], d.hv[1][0][1], d.hv[0][0][2], d.hv[1][0][2]); - if (phi != NOT_DEFINED) - ag.drawLine(d.hv[0][0][3], d.hv[1][0][3], d.hv[0][0][4], d.hv[1][0][4]); - if (z != NOT_DEFINED && phi != NOT_DEFINED) - ag.drawSymbol(d.hv[0][0][0], d.hv[1][0][0]); - } - else if (projection instanceof AProjectionRZ) - { - if (rho != NOT_DEFINED && phi != NOT_DEFINED && z != NOT_DEFINED && (rho != 0. || z != 0.)) - { - int numPoints = 15; - double[][][] hv = new double[2][1][numPoints]; - - double dr, dz; - if (Math.abs(rho/RHO_MAX) > Math.abs(z/Z_MAX)) { - dr = RHO_MAX / (numPoints-1); - dz = z * (RHO_MAX / ((numPoints-1)*rho)); - } else { - dz = AMath.getSign(z) * Z_MAX / (numPoints-1); - dr = rho * Math.abs(Z_MAX / ((numPoints-1)*z)); - } - - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - - if (phiMid > AMath.TWO_PI) - phiMid -= AMath.TWO_PI; - double phiDiff = Math.abs(Math.toRadians(phi) - phiMid); - - if (phiDiff > Math.PI / 2. && phiDiff < 3 * Math.PI / 2.) - dr *= -1; - - for (int j=0; j<numPoints; j++) { - hv[0][0][j] = j*dz; - hv[1][0][j] = j*dr; - } - - ACoord d = window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv))); - - ag.drawSmoothPolyline(d.hv[0][0], d.hv[1][0], numPoints); - } - else - { - int numPoints = 5; - double[][][] hv = new double[2][1][numPoints]; - - hv[0][0][0] = z; - hv[1][0][0] = rho * sign_rho; - hv[0][0][1] = z; - hv[1][0][1] = -RHO_MAX; - hv[0][0][2] = z; - hv[1][0][2] = RHO_MAX; - hv[0][0][3] = -Z_MAX; - hv[1][0][3] = rho * sign_rho; - hv[0][0][4] = Z_MAX; - hv[1][0][4] = rho * sign_rho; - ACoord d = window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv))); - - if (z != NOT_DEFINED) - ag.drawLine(d.hv[0][0][1], d.hv[1][0][1], d.hv[0][0][2], d.hv[1][0][2]); - if (rho != NOT_DEFINED) - ag.drawLine(d.hv[0][0][3], d.hv[1][0][3], d.hv[0][0][4], d.hv[1][0][4]); - if (z != NOT_DEFINED && rho != NOT_DEFINED) - ag.drawSymbol(d.hv[0][0][0], d.hv[1][0][0]); - } - } - else if (projection instanceof AProjectionYZ) - { - if (rho != NOT_DEFINED && phi != NOT_DEFINED && z != NOT_DEFINED) - { - int numPoints = 2; - double[][][] hv = new double[2][1][numPoints]; - - hv[0][0][0] = 0.; - hv[1][0][0] = 0.; - double phiRot = AProjectionXZ.getPhi(); - - hv[0][0][1] = z; - hv[1][0][1] = rho * Math.sin(phiRot); - - ACoord d = window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv))); - - ag.drawLine(d.hv[0][0][0], d.hv[1][0][0], d.hv[0][0][1], d.hv[1][0][1]); - ag.drawSymbol(d.hv[0][0][1], d.hv[1][0][1]); - } - else if (z != NOT_DEFINED) - { - int numPoints = 2; - double[][][] hv = new double[2][1][numPoints]; - - hv[0][0][0] = z; - hv[1][0][0] = -RHO_MAX; - hv[0][0][1] = z; - hv[1][0][1] = RHO_MAX; - ACoord d = window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv))); - - ag.drawLine(d.hv[0][0][0], d.hv[1][0][0], d.hv[0][0][1], d.hv[1][0][1]); - } - } - else if (projection instanceof AProjectionXZ) - { - if (rho != NOT_DEFINED && phi != NOT_DEFINED && z != NOT_DEFINED) - { - int numPoints = 2; - double[][][] hv = new double[2][1][numPoints]; - - hv[0][0][0] = 0.; - hv[1][0][0] = 0.; - double phiRot = AProjectionXZ.getPhi(); - - hv[0][0][1] = z; - hv[1][0][1] = rho * Math.cos(phiRot); - - ACoord d = window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv))); - - ag.drawLine(d.hv[0][0][0], d.hv[1][0][0], d.hv[0][0][1], d.hv[1][0][1]); - ag.drawSymbol(d.hv[0][0][1], d.hv[1][0][1]); - } - else if (z != NOT_DEFINED) - { - int numPoints = 2; - double[][][] hv = new double[2][1][numPoints]; - - hv[0][0][0] = z; - hv[1][0][0] = -RHO_MAX; - hv[0][0][1] = z; - hv[1][0][1] = RHO_MAX; - ACoord d = window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv))); - - ag.drawLine(d.hv[0][0][0], d.hv[1][0][0], d.hv[0][0][1], d.hv[1][0][1]); - } - } - else if (projection instanceof AProjectionVP) - { - int numPoints = 5; - double[][][] hv = new double[2][1][numPoints]; - double eta = 1.; - - if (z != NOT_DEFINED && rho != NOT_DEFINED) - eta = AParameterUtilities.eta(z, rho); - hv[0][0][0] = eta; - hv[1][0][0] = phi; - hv[0][0][1] = eta; - hv[1][0][1] = 0.; - hv[0][0][2] = eta; - hv[1][0][2] = PHI_MAX; - hv[0][0][3] = -ETA_MAX; - hv[1][0][3] = phi; - hv[0][0][4] = ETA_MAX; - hv[1][0][4] = phi; - ACoord d = window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv))); - - if (z != NOT_DEFINED && rho != NOT_DEFINED) - ag.drawLine(d.hv[0][0][1], d.hv[1][0][1], d.hv[0][0][2], d.hv[1][0][2]); - if (phi != NOT_DEFINED) - ag.drawLine(d.hv[0][0][3], d.hv[1][0][3], d.hv[0][0][4], d.hv[1][0][4]); - - if (z != NOT_DEFINED && phi != NOT_DEFINED && rho != NOT_DEFINED) - ag.drawSymbol(d.hv[0][0][0], d.hv[1][0][0]); - } - else if (projection instanceof AProjectionLegoPlot) - { - //added by Mark Stockton - double eta = 1.; - double[][][] hv = new double[2][1][3]; - Point2D.Double[] userCorners = window.getUserCorners(); - Point2D.Double[] displayCorners = window.getDisplayCorners(); - //update parameters - AProjectionLegoPlot.update(); - if (z != NOT_DEFINED && rho != NOT_DEFINED) - eta = AParameterUtilities.eta(z, rho); - if (AProjectionLegoPlot.reverse) - eta = -eta; - hv[0][0][0] = AProjectionLegoPlot.adjustPhi(window,phi,eta); - hv[1][0][0] = eta; - //top of plot coordinate - hv[0][0][1] = AProjectionLegoPlot.adjustPhi(window,phi,userCorners[0].y); - hv[1][0][1] = userCorners[0].y; - //bottom of plot coordinate - hv[0][0][2] = AProjectionLegoPlot.adjustPhi(window,phi,userCorners[2].y); - hv[1][0][2] = userCorners[2].y; - //convert to screen positions - ACoord d = window.calculateDisplay(projection.nonLinearTransform(new ACoord(hv))); - if (z != NOT_DEFINED && rho != NOT_DEFINED) - ag.drawLine(0, d.hv[1][0][0], displayCorners[1].x, d.hv[1][0][0]);//eta line - if (phi != NOT_DEFINED) - ag.drawLine(d.hv[0][0][1], d.hv[1][0][1],d.hv[0][0][2], d.hv[1][0][2]);//phi line - if (z != NOT_DEFINED && phi != NOT_DEFINED && rho != NOT_DEFINED) - ag.drawSymbol(d.hv[0][0][0], d.hv[1][0][0]);//square where axis cross - } - } - parameterStore.restoreWindowParameters(); - } - - /** - * Gets called each time we enter a window in which this interaction is active - */ - public void entered() - { - //Set mouse cursor - window.setCursor(ACursorFactory.getInstance().getSyncCursor()); - } - - /** - * Gets called each time we leave a window in which this interaction is active - */ - public void exited() - { - //Set mouse cursor - window.setCursor(ACursorFactory.getInstance().getSyncCursor()); - } - - public AModifier[] getModifiers() - { - return new AModifier[] { new AModifier(KeyEvent.VK_P, false, "Copy phi to RZ projection" ) }; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AVPSelectionGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/AVPSelectionGroup.java deleted file mode 100755 index c439d48ee4225aba92bad57c00b733881b4de376..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AVPSelectionGroup.java +++ /dev/null @@ -1,15 +0,0 @@ -package atlantis.interactions; - - -public class AVPSelectionGroup extends AInteractionGroup { - - private ARectangleVPSelection rectangleVPSelection; - - public AVPSelectionGroup(AInteractionsManager iManager) { - super(AInteractionGroup.WINDOW_GROUP, iManager); - - rectangleVPSelection=new ARectangleVPSelection(); - addInteraction(rectangleVPSelection); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AWindowInfoInteraction.java b/graphics/AtlantisJava/src/atlantis/interactions/AWindowInfoInteraction.java deleted file mode 100755 index 80d439b8e5fabc1e5e4f3d4c96889070e018d0da..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AWindowInfoInteraction.java +++ /dev/null @@ -1,73 +0,0 @@ -package atlantis.interactions; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.geom.Point2D; - -import atlantis.graphics.ACursorFactory; - -public class AWindowInfoInteraction extends AInteraction implements AMouseDragListener, AEnterExitListener -{ - // private int width=64; - private Point pickedPoint; - private Color c; - - public AWindowInfoInteraction() - { - super(1, AUTOMATIC_REPAINT, SCREEN_COORDINATES, true); - - this.c = Color.white; - - // hr[0] = new Rectangle2D.Double(x, y, width, width); - pickedPoint = new Point(0, 0); - } - - public int getButton() - { - return AInteractionsManager.LEFT; - } - - public void paint(Graphics2D g) - { - g.setColor(c); - g.fill(hr[0]); - - /* - * g.fillRect(hr[0].getX(), hr[0].getY(), hr[0].getWidth(), - * hr[0].getHeight()); - */ - } - - public void start(Point2D.Double p, int region, int key) - { - pickedPoint.setLocation(p.x - hr[0].getX(), p.y - hr[0].getY()); - } - - public void drag(Point2D.Double p, int region, int key) - { - hr[0].setFrame(p.x - pickedPoint.x, p.y - pickedPoint.y, hr[0].getWidth(), hr[0].getHeight()); - } - - public void stop() - {} - - public void cancel() - {} - - public void entered() - { - window.setCursor(ACursorFactory.getInstance().getDefaultCursor()); - } - - public void exited() - { - window.setCursor(ACursorFactory.getInstance().getDefaultCursor()); - } - - public int getPopupType() - { - return APopupListener.REGION_POPUP; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AXSkewSelection.java b/graphics/AtlantisJava/src/atlantis/interactions/AXSkewSelection.java deleted file mode 100755 index 1aac47fd38ed6bf53036d51691ff0826e2d4bb34..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AXSkewSelection.java +++ /dev/null @@ -1,124 +0,0 @@ -package atlantis.interactions; - - -import java.awt.*; -import java.awt.geom.*; - - -/** - * A panel which selects a parallogram-shaped region in which two - * sides are parallel to the y-axis and the other two are skewed with - * respect to the x-axis. - * - * @author Charles Loomis - **/ -public class AXSkewSelection extends ASelection { - - final private static int STARTING_WIDTH=25; - - public AXSkewSelection() { - super(6); - } - - /** - * Initialize the control points based in the starting point - */ - public int init(Point2D.Double p, int key) { - isValid=false; - - setCenter(hr[0], p.x-STARTING_WIDTH, p.y); - setCenter(hr[1], p.x-STARTING_WIDTH, p.y); - setCenter(hr[2], p.x+STARTING_WIDTH, p.y); - setCenter(hr[3], p.x+STARTING_WIDTH, p.y); - setCenter(hr[4], p.x, p.y); - setCenter(hr[5], p.x, p.y); - - region=5; - return region; - } - - /** - * Move the active control point to the point (x,y). - */ - public void drag(Point2D.Double p, int region, int key) { - isValid=true; - - double width; - - // Change what is done depending on which control point is active. - switch(region) { - case 0: - width=p.x-hr[4].getCenterX(); - setCenterX(hr[0], hr[4].getCenterX()+width); - setCenterX(hr[1], hr[5].getCenterX()+width); - setCenterX(hr[2], hr[5].getCenterX()-width); - setCenterX(hr[3], hr[4].getCenterX()-width); - break; - - case 1: - width=p.x-hr[5].getCenterX(); - setCenterX(hr[0], hr[4].getCenterX()+width); - setCenterX(hr[1], hr[5].getCenterX()+width); - setCenterX(hr[2], hr[5].getCenterX()-width); - setCenterX(hr[3], hr[4].getCenterX()-width); - break; - - case 2: - width=p.x-hr[5].getCenterX(); - setCenterX(hr[0], hr[4].getCenterX()-width); - setCenterX(hr[1], hr[5].getCenterX()-width); - setCenterX(hr[2], hr[5].getCenterX()+width); - setCenterX(hr[3], hr[4].getCenterX()+width); - break; - - case 3: - width=p.x-hr[4].getCenterX(); - setCenterX(hr[0], hr[4].getCenterX()-width); - setCenterX(hr[1], hr[5].getCenterX()-width); - setCenterX(hr[2], hr[5].getCenterX()+width); - setCenterX(hr[3], hr[4].getCenterX()+width); - break; - - case 4: - width=hr[4].getCenterX()-hr[0].getCenterX(); - setCenter(hr[region], p.x, p.y); - setCenter(hr[0], p.x-width, p.y); - setCenter(hr[3], p.x+width, p.y); - break; - - case 5: - width=hr[4].getCenterX()-hr[0].getCenterX(); - setCenter(hr[region], p.x, p.y); - setCenter(hr[1], p.x-width, p.y); - setCenter(hr[2], p.x+width, p.y); - break; - } - } - - public void paint(Graphics2D g) { - paintStandard(g); - } - - /** - * Make the affine transform which corresponds to this skewed region. - */ - public Point2D.Double[] getCorners() { - int first=getUpperLeftRegion(); - - // Calculate which is the opposite corner. - int third=(first+2)%4; - - // Now use the cross-product to determine which of the - // remaining points is the one which keep the path going clockwise. - int second=(first+1)%4; - double dx0=hr[third].getCenterX()-hr[first].getCenterX(); - double dy0=hr[third].getCenterY()-hr[first].getCenterY(); - double dx1=hr[second].getCenterX()-hr[first].getCenterX(); - double dy1=hr[second].getCenterY()-hr[first].getCenterY(); - - if(dx0*dy1-dy0*dx1>0) second=(first+3)%4; - - return convert(first, second, third); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AXSliceSelection.java b/graphics/AtlantisJava/src/atlantis/interactions/AXSliceSelection.java deleted file mode 100755 index 596f81aa6e8e35a1c5b48ae2a205599e1f01d13c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AXSliceSelection.java +++ /dev/null @@ -1,79 +0,0 @@ -package atlantis.interactions; - - -import java.awt.*; -import java.awt.geom.*; - - -/** - * A panel which selects a slice of the window in the x-direction. - * That is, it selects a rectangular region with a height equal to the - * full height of the window and with an adjustable width. - * - * @author Charles Loomis - **/ -public class AXSliceSelection extends ASelection { - - public AXSliceSelection() { - super(6); - } - - public int init(Point2D.Double p, int key) { - isValid=false; - - int ymax=window.getSize().height; - int ymid=ymax/2; - - setCenter(hr[0], p.x, 0); - setCenter(hr[1], p.x, 0); - setCenter(hr[2], p.x, ymax); - setCenter(hr[3], p.x, ymax); - setCenter(hr[4], p.x, ymid); - setCenter(hr[5], p.x, ymid); - - region=5; - return region; - } - - public void drag(Point2D.Double p, int region, int key) { - isValid=true; - - switch(region) { - case 0: - case 3: - case 4: - setCenterX(hr[0], p.x); - setCenterX(hr[3], p.x); - setCenterX(hr[4], p.x); - break; - - case 1: - case 2: - case 5: - setCenterX(hr[1], p.x); - setCenterX(hr[2], p.x); - setCenterX(hr[5], p.x); - break; - } - } - - public void paint(Graphics2D g) { - paintStandard(g); - } - - public Point2D.Double[] getCorners() { - // Sort out which are the three control points. - int first=0; - int second=1; - int third=2; - - if(hr[1].getCenterX()<hr[0].getCenterX()) { - first=1; - second=0; - third=3; - } - - return convert(first, second, third); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AYSkewSelection.java b/graphics/AtlantisJava/src/atlantis/interactions/AYSkewSelection.java deleted file mode 100755 index 9e98bde0f40330d8e66fa3ecf28e8f48506a955b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AYSkewSelection.java +++ /dev/null @@ -1,124 +0,0 @@ -package atlantis.interactions; - - -import java.awt.*; -import java.awt.geom.*; - - -/** - * A panel which selects a parallogram-shaped region in which two - * sides are parallel to the y-axis and the other two are skewed with - * respect to the x-axis. - * - * @author Charles Loomis - **/ -public class AYSkewSelection extends ASelection { - - final private static int STARTING_WIDTH=25; - - public AYSkewSelection() { - super(6); - } - - /** - * Initialize the control points based in the starting point - */ - public int init(Point2D.Double p, int key) { - isValid=false; - - setCenter(hr[0], p.x, p.y-STARTING_WIDTH); - setCenter(hr[1], p.x, p.y-STARTING_WIDTH); - setCenter(hr[2], p.x, p.y+STARTING_WIDTH); - setCenter(hr[3], p.x, p.y+STARTING_WIDTH); - setCenter(hr[4], p.x, p.y); - setCenter(hr[5], p.x, p.y); - - region=5; - return region; - } - - /** - * Move the active control point to the point (x,y). - */ - public void drag(Point2D.Double p, int region, int key) { - isValid=true; - - double width; - - // Change what is done depending on which control point is active. - switch(region) { - case 0: - width=p.y-hr[4].getCenterY(); - setCenterY(hr[0], hr[4].getCenterY()+width); - setCenterY(hr[1], hr[5].getCenterY()+width); - setCenterY(hr[2], hr[5].getCenterY()-width); - setCenterY(hr[3], hr[4].getCenterY()-width); - break; - - case 1: - width=p.y-hr[5].getCenterY(); - setCenterY(hr[0], hr[4].getCenterY()+width); - setCenterY(hr[1], hr[5].getCenterY()+width); - setCenterY(hr[2], hr[5].getCenterY()-width); - setCenterY(hr[3], hr[4].getCenterY()-width); - break; - - case 2: - width=p.y-hr[5].getCenterY(); - setCenterY(hr[0], hr[4].getCenterY()-width); - setCenterY(hr[1], hr[5].getCenterY()-width); - setCenterY(hr[2], hr[5].getCenterY()+width); - setCenterY(hr[3], hr[4].getCenterY()+width); - break; - - case 3: - width=p.y-hr[4].getCenterY(); - setCenterY(hr[0], hr[4].getCenterY()-width); - setCenterY(hr[1], hr[5].getCenterY()-width); - setCenterY(hr[2], hr[5].getCenterY()+width); - setCenterY(hr[3], hr[4].getCenterY()+width); - break; - - case 4: - width=hr[4].getCenterY()-hr[0].getCenterY(); - setCenter(hr[region], p.x, p.y); - setCenter(hr[0], p.x, p.y-width); - setCenter(hr[3], p.x, p.y+width); - break; - - case 5: - width=hr[4].getCenterY()-hr[0].getCenterY(); - setCenter(hr[region], p.x, p.y); - setCenter(hr[1], p.x, p.y-width); - setCenter(hr[2], p.x, p.y+width); - break; - } - } - - public void paint(Graphics2D g) { - paintStandard(g); - } - - /** - * Make the affine transform which corresponds to this skewed region. - */ - public Point2D.Double[] getCorners() { - int first=getUpperLeftRegion(); - - // Calculate which is the opposite corner. - int third=(first+2)%4; - - // Now use the cross-product to determine which of the - // remaining points is the one which keep the path going clockwise. - int second=(first+1)%4; - double dx0=hr[third].getCenterX()-hr[first].getCenterX(); - double dy0=hr[third].getCenterY()-hr[first].getCenterY(); - double dx1=hr[second].getCenterX()-hr[first].getCenterX(); - double dy1=hr[second].getCenterY()-hr[first].getCenterY(); - - if(dx0*dy1-dy0*dx1>0) second=(first+3)%4; - - return convert(first, second, third); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AYSliceSelection.java b/graphics/AtlantisJava/src/atlantis/interactions/AYSliceSelection.java deleted file mode 100755 index 41c0a8293cdbfdcdb89e382f0dc2e419f7b5863c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AYSliceSelection.java +++ /dev/null @@ -1,79 +0,0 @@ -package atlantis.interactions; - - -import java.awt.*; -import java.awt.geom.*; - - -/** - * A panel which selects a slice of the window in the x-direction. - * That is, it selects a rectangular region with a height equal to the - * full height of the window and with an adjustable width. - * - * @author Charles Loomis - **/ -public class AYSliceSelection extends ASelection { - - public AYSliceSelection() { - super(6); - } - - public int init(Point2D.Double p, int key) { - isValid=false; - - int xmax=window.getSize().width; - int xmid=xmax/2; - - setCenter(hr[0], 0, p.y); - setCenter(hr[1], 0, p.y); - setCenter(hr[2], xmax, p.y); - setCenter(hr[3], xmax, p.y); - setCenter(hr[4], xmid, p.y); - setCenter(hr[5], xmid, p.y); - - region=5; - return region; - } - - public void drag(Point2D.Double p, int region, int key) { - isValid=true; - - switch(region) { - case 0: - case 3: - case 4: - setCenterY(hr[0], p.y); - setCenterY(hr[3], p.y); - setCenterY(hr[4], p.y); - break; - - case 1: - case 2: - case 5: - setCenterY(hr[1], p.y); - setCenterY(hr[2], p.y); - setCenterY(hr[5], p.y); - break; - } - } - - public void paint(Graphics2D g) { - paintStandard(g); - } - - public Point2D.Double[] getCorners() { - // Sort out which are the three control points. - int first=1; - int second=2; - int third=3; - - if(hr[1].getCenterY()>hr[0].getCenterY()) { - first=0; - second=3; - third=2; - } - - return convert(first, second, third); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AZMRGroup.java b/graphics/AtlantisJava/src/atlantis/interactions/AZMRGroup.java deleted file mode 100755 index 9b6903d9fb4f2aadbbd9edef5e077d3101a1523e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AZMRGroup.java +++ /dev/null @@ -1,14 +0,0 @@ -package atlantis.interactions; - - -public class AZMRGroup extends AInteractionGroup { - - private AZMRInteraction transformInteraction; - - public AZMRGroup(AInteractionsManager iManager) { - super(AInteractionGroup.WINDOW_GROUP, iManager); - transformInteraction=new AZMRInteraction(); - this.addInteraction(transformInteraction); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/AZMRInteraction.java b/graphics/AtlantisJava/src/atlantis/interactions/AZMRInteraction.java deleted file mode 100755 index db82da56f3358ecd5530ae02dfaef4f6afc30482..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/AZMRInteraction.java +++ /dev/null @@ -1,700 +0,0 @@ -package atlantis.interactions; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; - -import javax.swing.JMenuItem; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.event.AEventManager; -import atlantis.graphics.ACursorFactory; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.projection.AProjection; -import atlantis.projection.AProjection2D; -import atlantis.projection.AProjection3D; -import atlantis.projection.AProjectionFR; -import atlantis.projection.AProjectionFZ; -import atlantis.projection.AProjectionLegoPlot; -import atlantis.projection.AProjectionRZ; -import atlantis.projection.AProjectionVP; -import atlantis.projection.AProjectionXZ; -import atlantis.projection.AProjectionYX; -import atlantis.projection.AProjectionYZ; -import atlantis.utils.AMath; -import atlantis.utils.AVector; - -/** - * The Zoom, Move and Rotate interaction. - */ -public class AZMRInteraction extends AInteraction implements - ASleepMouseDragListener, AMousePressListener, AEnterExitListener, ActionListener -{ - // when these values are reached on any of the coordinates, zooming takes - // no longer any effect - private static final double MINIMAL_ZOOM_LIMIT = 0.001; // [cm] = 10 um - private static final double MAXIMAL_ZOOM_LIMIT = 100000; // [cm] = 1000 m - - private static final int ZOOM_MODE = 0; - private static final int HORIZONTAL_ZOOM_MODE = 1; - private static final int VERTICAL_ZOOM_MODE = 2; - private static final int ROTATE_MODE = 3; - private static final int MOVE_MODE = 5; - - private int centerMarkRadius = 6; - private Point2D.Double p0; - private int previousKey = KeyEvent.VK_UNDEFINED; - private int mode; - private JMenuItem[] popupItems; - private final static String TO_CENTER_OF_DETECTOR = "To Center Of Detector"; - private final static String CENTER_PICTURE = "Center The Picture"; - private final static String ASPECT_RATIO_1 = "Aspect Ratio 1"; - private final static String UNZOOM_FULL = "Unzoom Full"; - - // if false, none of the ZMR interactions will have the red central dot - // painted - private static boolean paintCenterDot = true; - - public AZMRInteraction() - { - super(1, AUTOMATIC_REPAINT, WORLD_COORDINATES, false); - - popupItems = new JMenuItem[] { - new JMenuItem(TO_CENTER_OF_DETECTOR), - new JMenuItem(CENTER_PICTURE), - new JMenuItem(UNZOOM_FULL)}; - - for (int i = 0; i < popupItems.length; i++) { - popupItems[i].addActionListener(this); - } - - // The center of the ellipse is in (0, 0) in User Space - hr[0] = new Ellipse2D.Double(-centerMarkRadius / 2, - -centerMarkRadius / 2, centerMarkRadius, centerMarkRadius); - - //By default we are in zoom mode - mode = ZOOM_MODE; - } - - public static void setPaintCenterDot(boolean state) - { - paintCenterDot = state; - } - - public void connect(AInteractionsManager manager) - { - super.connect(manager); - Point2D.Double c = ((AProjection2D) window.getProjection()).getCenter(); - - setCenter(hr[0], c.x, c.y); - } - - public int getPressButton() - { - return AInteractionsManager.LEFT; - } - - public int init(Point2D.Double p, int key) - { - keyChange(p, key); - return -1; - } - - public void pressed(Point2D.Double p, int button, int key) - { - if (key == KeyEvent.VK_C) - setCenter(hr[0], p.x, p.y); - if (key == KeyEvent.VK_0){ - double[] primaryVertex = AEventManager.instance().getCurrentEvent().getPrimaryVertex(); - if(window.getProjection().getName().equals("YX")) setCenter(hr[0], primaryVertex[0], primaryVertex[1]); - if(window.getProjection().getName().equals("RZ")) { - double phiMid2 = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(Math.atan2(primaryVertex[1], primaryVertex[0]) - phiMid2); - int s=-1; - if (phiDiff < Math.PI / 2. || phiDiff > 3 * Math.PI / 2.) s = 1; - setCenter(hr[0], primaryVertex[2], s*Math.sqrt(primaryVertex[0]*primaryVertex[0]+primaryVertex[1]*primaryVertex[1])); - } - } - } - - public int getButton() - { - return AInteractionsManager.LEFT; - } - - public void start(Point2D.Double p, int region, int key) - {} - - private double getHd0(Point2D.Double p) - { - Point2D.Double[] c = window.getUserCorners(); - AVector v21 = new AVector(c[2].x, c[2].y, c[1].x, c[1].y); - AVector v10 = new AVector(c[1].x, c[1].y, c[0].x, c[0].y); - Point2D.Double center = getCenter(hr[0]); - - return p.distance(AMath.intersectionPoint(center, v21, p, v10)); - } - - private double getVd0(Point2D.Double p) - { - Point2D.Double[] c = window.getUserCorners(); - AVector v01 = new AVector(c[0].x, c[0].y, c[1].x, c[1].y); - AVector v12 = new AVector(c[1].x, c[1].y, c[2].x, c[2].y); - Point2D.Double center = getCenter(hr[0]); - - return p.distance(AMath.intersectionPoint(center, v01, p, v12)); - } - - private void keyChange(Point2D.Double p, int key) - { - p0 = p; - - switch (key) - { - case KeyEvent.VK_UNDEFINED: - mode = ZOOM_MODE; - break; - - case KeyEvent.VK_H: - mode = HORIZONTAL_ZOOM_MODE; - break; - - case KeyEvent.VK_V: - mode = VERTICAL_ZOOM_MODE; - break; - - case KeyEvent.VK_R: - mode = ROTATE_MODE; - break; - - case KeyEvent.VK_M: - mode = MOVE_MODE; - break; - - case KeyEvent.VK_Z: - mode = ZOOM_MODE; - break; - } - - //Update cursor mode when key changes - setCursorMode(); - } - - public void drag(Point2D.Double p, int region, int key) - { - - if (key != previousKey) - { - keyChange(p, key); - previousKey = key; - } - - double zf; - Point2D.Double center = getCenter(hr[0]); - AProjection proj = window.getProjection(); - - switch (mode) - { - case ZOOM_MODE: - zf = p0.distance(center.x, center.y) - / p.distance(center.x, center.y); - performZoom(getCenter(hr[0]), zf, window); - break; - - case HORIZONTAL_ZOOM_MODE: - zf = getHd0(p0) / getHd0(p); - performHorizontalZoom(center, zf, window); - break; - - case VERTICAL_ZOOM_MODE: - zf = getVd0(p0) / getVd0(p); - performVerticalZoom(center, zf, window); - break; - - case ROTATE_MODE: - if ((proj instanceof AProjectionFR) - || (proj instanceof AProjectionFZ) - || (proj instanceof AProjectionVP)) - performPhiRotation(p.y - p0.y, window); - else if (proj instanceof AProjectionLegoPlot) - performLegoRotation(center, p.x - p0.x, p.y - p0.y, window); - else - { - if ((proj instanceof AProjectionRZ) - || (proj instanceof AProjectionXZ) - || (proj instanceof AProjectionYZ) - || (proj instanceof AProjection3D)) - { - AParameter phiPar = parameterStore.get(proj.getName(), "Phi"); - if (proj instanceof AProjection3D) - { - Point2D.Double pDisp = window.calculateDisplay(p); - Point2D.Double p0Disp = window.calculateDisplay(p0); - double height = window.getCurrDisp().getHeight(); - double deltaV = pDisp.getY() - p0Disp.getY(); - phiPar.setD(adjustPhi(phiPar.getD() + 360. * deltaV - / height)); - } - else - phiPar.setD(adjustPhi(phiPar.getD() + (p.y - p0.y))); - p0 = p; - ACanvas.getCanvas().repaintAllFromScratch(); - } - else - { - double alpha = AMath.getAngle(p0, center) - - AMath.getAngle(p, center); - - performRotation(alpha, center, window); - if (proj instanceof AProjectionYX) - { - AParameter phiPar = parameterStore.get(proj.getName(), "Phi"); - - phiPar.setD(adjustPhi(phiPar.getD() + Math.toDegrees(alpha))); - } - } - } - break; - - case MOVE_MODE: - if ((proj instanceof AProjectionFR) - || (proj instanceof AProjectionFZ) - || (proj instanceof AProjectionVP)) - { - performMove(p.x - p0.x, 0, window); - performPhiRotation(p.y - p0.y, window); - } - else - performMove(p.x - p0.x, p.y - p0.y, window); - break; - } - } // drag() - // --------------------------------------------------------------- - - private double adjustPhi(double phi) - { - while (phi < 0) - phi += 360; - while (phi > 360) - phi -= 360; - return phi; - } - - public void stop() - {} - - public void cancel() - {} - - public void paint(Graphics2D g) - { - Point2D.Double p = window.calculateDisplay(getCenter(hr[0])); - - //don't draw red dot if not drawing the lego plot - //(i.e. when just drawing the legend) - boolean paintingJustLegoLegend = false; - if(window.getProjection().getName().equals("LegoPlot")) - { - parameterStore.selectWindowParameters(window.getName()); - if(!parameterStore.get("LegoPlot","DrawPlot").getStatus()) - paintingJustLegoLegend=true; - parameterStore.restoreWindowParameters(); - } - - if (paintCenterDot && !paintingJustLegoLegend) - { - g.setColor(Color.red); - g.fillOval((int) (p.x - centerMarkRadius / 2), - (int) (p.y - centerMarkRadius / 2), centerMarkRadius, - centerMarkRadius); - } - } - - /** - * Check the coordinates of the corners. If any of the limits was already - * reached, zooming / unzooming takes no longer any effect. - * - * @param corners Double - * @return boolean - */ - private static boolean checkCornerLimits(Point2D.Double[] corners) - { - - for (int i = 0; i < corners.length; i++) - { - //Get the difference in x and y off this corner and the next - //There is at most 3 corners - this will give us all of the combinations - double dX=Math.abs(corners[i].x-corners[(i+1)%(corners.length-1)].x); - double dY=Math.abs(corners[i].y-corners[(i+1)%(corners.length-1)].y); - //Coordinates will differ in only x OR y, get the one that does - double dMax = Math.max(dX,dY); - //Check that corner coordinate difference is within limits - if ((dMax < MINIMAL_ZOOM_LIMIT) || (dMax > MAXIMAL_ZOOM_LIMIT)) - { - AOutput.alwaysAppend("zoom / unzoom limit reached\n", - ALogInterface.NORMAL); - return false; - } - } - return true; - } // checkTheCornerLimits() - - - public static void performZoom(Point2D.Double center, double zf, - AWindow window) - { - Point2D.Double[] corners = window.getUserCorners(); - - for (int i = 0; i < corners.length; i++) - { - corners[i].x = center.x + (corners[i].x - center.x) * zf; - corners[i].y = center.y + (corners[i].y - center.y) * zf; - } - - if (!checkCornerLimits(corners)) - { - return; // zooming has already reached its limit - } - - window.setUserCorners(corners); - } - - public static void performRotation(double angle, Point2D.Double center, - AWindow window) - { - Point2D.Double[] corners = window.getUserCorners(); - - double cos = Math.cos(angle); - double sin = Math.sin(angle); - - for (int i = 0; i < corners.length; i++) - { - double dx = corners[i].x - center.x; - double dy = corners[i].y - center.y; - - corners[i].x = center.x + dx * cos - dy * sin; - corners[i].y = center.y + dx * sin + dy * cos; - } - - window.setUserCorners(corners); - } - - public static void performMinus90Rotation(AWindow window) - { - Point2D.Double[] corners = window.getUserCorners(); - - AVector v12 = new AVector(corners[1], corners[2]); - double x3 = corners[0].x + v12.dx; - double y3 = corners[0].y + v12.dy; - - corners[0].setLocation(corners[1]); - corners[1].setLocation(corners[2]); - corners[2].setLocation(x3, y3); - - window.setUserCorners(corners); - } - - public static void performPlus90Rotation(AWindow window) - { - Point2D.Double[] corners = window.getUserCorners(); - - AVector v12 = new AVector(corners[1], corners[2]); - double x3 = corners[0].x + v12.dx; - double y3 = corners[0].y + v12.dy; - - corners[2].setLocation(corners[1].x, corners[1].y); - corners[1].setLocation(corners[0].x, corners[0].y); - corners[0].setLocation(x3, y3); - - window.setUserCorners(corners); - } - - public static void performPhiRotation(double dPhi, AWindow window) - { - Point2D.Double[] corners = window.getUserCorners(); - - for (int i = 0; i < corners.length; i++) - corners[i].y -= dPhi; - - window.setUserCorners(corners); - } - - public void performLegoRotation(Point2D.Double center, double dPhi, - double dEta, AWindow window) - { - Point2D.Double[] corners = window.getUserCorners(); - - if (dPhi != 0.0 || dEta != 0.0) - { - //get original phi coord in 0-360 range - double centerX = -AProjectionLegoPlot.adjustPhi(window, -center.x, center.y); - - corners[0].x -= (dPhi); - // x offset=xz*360 so xz=change/360 - AProjectionLegoPlot.setxz(window.getIndex(), AProjectionLegoPlot - .getxz(window.getIndex()) - + (dPhi) / 360); - - if (AProjectionLegoPlot.getyz(window.getIndex()) < 1.0 - || (dEta) > 0.0) - { - corners[0].y -= (dEta); - corners[1].y -= (dEta); - // y offset=yz*50 so yz=change/50 - AProjectionLegoPlot.setyz(window.getIndex(), - AProjectionLegoPlot.getyz(window.getIndex()) - (dEta) - / 50); - } - - //now have changed xz recalcuate phi coordinte - center.x = AProjectionLegoPlot.adjustPhi(window, centerX, center.y); - setCenter(hr[0], center.x, center.y); - - window.setUserCorners(corners); - } - } - - public static void performHorizontalZoom(Point2D.Double center, double f, - AWindow window) - { - Point2D.Double[] c = window.getUserCorners(); - AVector v21 = new AVector(c[2].x, c[2].y, c[1].x, c[1].y); - Point2D.Double center1 = new Point2D.Double(center.x + v21.dx, center.y - + v21.dy); - Point2D.Double p0 = AMath - .intersectionPoint(c[0], c[1], center, center1); - - AVector v0 = new AVector(p0, c[0]).scale(f); - AVector v1 = new AVector(p0, c[1]).scale(f); - - c[0].x = p0.x + v0.dx; - c[0].y = p0.y + v0.dy; - - c[1].x = p0.x + v1.dx; - c[1].y = p0.y + v1.dy; - - v21.invert(); - p0.setLocation(p0.x + v21.dx, p0.y + v21.dy); - c[2].x = p0.x + v1.dx; - c[2].y = p0.y + v1.dy; - - if (!checkCornerLimits(c)) - { - return; // zooming has already reached its limit - } - - window.setUserCorners(c); - - } - - public static void performVerticalZoom(Point2D.Double center, double f, - AWindow window) - { - Point2D.Double[] c = window.getUserCorners(); - AVector v01 = new AVector(c[0].x, c[0].y, c[1].x, c[1].y); - Point2D.Double center1 = new Point2D.Double(center.x + v01.dx, center.y - + v01.dy); - Point2D.Double p0 = AMath - .intersectionPoint(c[1], c[2], center, center1); - - AVector v1 = new AVector(p0, c[1]).scale(f); - AVector v2 = new AVector(p0, c[2]).scale(f); - - c[1].x = p0.x + v1.dx; - c[1].y = p0.y + v1.dy; - - c[2].x = p0.x + v2.dx; - c[2].y = p0.y + v2.dy; - - v01.invert(); - p0.setLocation(p0.x + v01.dx, p0.y + v01.dy); - c[0].x = p0.x + v1.dx; - c[0].y = p0.y + v1.dy; - - if (!checkCornerLimits(c)) - { - return; // zooming has already reached its limit - } - - window.setUserCorners(c); - - } - - public static void performMove(double dx, double dy, AWindow window) - { - Point2D.Double[] corners = window.getUserCorners(); - - for (int i = 0; i < corners.length; i++) - { - corners[i].x -= dx; - corners[i].y -= dy; - } - - window.setUserCorners(corners); - } - - public static Line2D.Double getMiddleHorizontalLine(AWindow window) - { - Point2D.Double[] corners = window.getUserCorners(); - AVector v12 = new AVector(corners[1], corners[2]).scale(0.5); - - return new Line2D.Double(corners[0].x + v12.dx, corners[0].y + v12.dy, - corners[1].x + v12.dx, corners[1].y + v12.dy); - } - - public static Line2D.Double getMiddleVerticalLine(AWindow window) - { - Point2D.Double[] corners = window.getUserCorners(); - AVector v10 = new AVector(corners[1], corners[0]).scale(0.5); - - return new Line2D.Double(corners[1].x + v10.dx, corners[1].y + v10.dy, - corners[2].x + v10.dx, corners[2].y + v10.dy); - } - - public static void performFlip(Line2D.Double line, AWindow window) - { - if (line == null) - return; - - Point2D.Double[] corners = window.getUserCorners(); - double dSquare = Point2D.distanceSq(line.x1, line.y1, line.x2, line.y2); - - for (int i = 0; i < corners.length; i++) - { - double u = (1 / dSquare) - * ((corners[i].x - line.x1) * (line.x2 - line.x1) + (corners[i].y - line.y1) - * (line.y2 - line.y1)); - - double x0 = line.x1 + u * (line.x2 - line.x1); - double y0 = line.y1 + u * (line.y2 - line.y1); - - corners[i].x = 2 * x0 - corners[i].x; - corners[i].y = 2 * y0 - corners[i].y; - } - - window.setUserCorners(corners); - } - - /** - * Set cursor acording to current mode - */ - public void setCursorMode(){ - //check which mode we have - switch (mode) - { - case ZOOM_MODE: - window.setCursor(ACursorFactory.getInstance().getZoomCursor()); - break; - - case HORIZONTAL_ZOOM_MODE: - window.setCursor(ACursorFactory.getInstance().getZoomCursor()); - break; - - case VERTICAL_ZOOM_MODE: - window.setCursor(ACursorFactory.getInstance().getZoomCursor()); - break; - - case ROTATE_MODE: - window.setCursor(ACursorFactory.getInstance().getRotateCursor()); - break; - - case MOVE_MODE: - window.setCursor(ACursorFactory.getInstance().getMoveCursor()); - break; - } - } - - /** - * Gets called each time we enter a window in which this interaction is active - */ - public void entered() - { - //Set mouse cursor according to current mode - setCursorMode(); - } - - /** - * Gets called each time we leave a window in which this interaction is active - */ - public void exited() - { - //Set mouse cursor - window.setCursor(ACursorFactory.getInstance().getDefaultCursor()); - } - - public int getPopupType() - { - return APopupListener.WINDOW_POPUP; - } - - public JMenuItem[] getPopupItems() { - return popupItems; - } - - public void actionPerformed(ActionEvent e) - { - String action = e.getActionCommand(); - - if (action.equals(TO_CENTER_OF_DETECTOR)) - { - Point2D.Double c = ((AProjection2D) window.getProjection()) - .getCenter(); - - setCenter(hr[0], c.x, c.y); - window.repaint(); - } - else if (action.equals(CENTER_PICTURE)) - { - Point2D.Double[] c = window.getUserCorners(); - AVector v02 = new AVector(c[0].x, c[0].y, c[2].x, c[2].y) - .scale(0.5); - double xc = c[0].x + v02.dx; - double yc = c[0].y + v02.dy; - AVector vC0 = new AVector(xc, yc, 0, 0); - AProjection proj = window.getProjection(); - if (proj instanceof AProjectionLegoPlot) - vC0 = new AVector(xc, yc, 180 * (1 - AProjectionLegoPlot - .getxz(window.getIndex())), -5); - // 180*(1-AProjectionLegoPlot.xz), -5 is different center as center - // of plot is not at 0,0 - - for (int i = 0; i < c.length; i++) - { - c[i].x += vC0.dx; - c[i].y += vC0.dy; - } - window.setUserCorners(c); - } else if (action.equals(ASPECT_RATIO_1)) { - ((AProjection2D) window.getProjection()).setAspectRatio1(window); - } - else if (action.equals(UNZOOM_FULL)) - { - window.setUserCorners(((AProjection2D) window.getProjection()). - calculateNoZoomCorners(window.getSize())); - } - } - - public AModifier[] getModifiers() - { - return new AModifier[] { - new AModifier(KeyEvent.VK_UNDEFINED, false, "Zoom"), - new AModifier(KeyEvent.VK_Z, false, "Zoom"), - new AModifier(KeyEvent.VK_H, false, "Horizonatal Zoom"), - new AModifier(KeyEvent.VK_V, false, "Vertical Zoom"), - new AModifier(KeyEvent.VK_R, false, "Rotate"), - new AModifier(KeyEvent.VK_F, false, "Fast Zoom"), - new AModifier(KeyEvent.VK_M, false, "Move (pan)"), - new AModifier(KeyEvent.VK_C, false, "Modify Central Point") - }; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/interactions/package.html b/graphics/AtlantisJava/src/atlantis/interactions/package.html deleted file mode 100644 index 85cfaaddcc871e5bb3a7ccb5192abc402dcb0557..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/interactions/package.html +++ /dev/null @@ -1,11 +0,0 @@ -<html> -<head></head> -<body> -<p>This package contains implementation of various interactions with -the application such as the main ZMR (1Zoom Move Rotation), Fisheye, -etc. Each AWindow has an AInteractionManager which tells the current -interaction, e.g. ZMR, about what is happening with the mouse on that -window. -</p> -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/list/AColorIcon.java b/graphics/AtlantisJava/src/atlantis/list/AColorIcon.java deleted file mode 100755 index a77acc2917d3ae6e10bede13e1ef75c8e335bdcc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/list/AColorIcon.java +++ /dev/null @@ -1,69 +0,0 @@ -package atlantis.list; - - -import javax.swing.Icon; -import java.awt.*; - -import atlantis.graphics.colormap.AColorMap; - - -// icon with size and color - -class AColorIcon implements Icon { - private int w, h; - private int colorIndex; - - public AColorIcon() { - this(AColorMap.WH, 50, 15); - } - - public AColorIcon(Dimension d) { - this.w=d.width; - this.h=d.height; - } - - public AColorIcon(int colorIndex, int w, int h) { - this.colorIndex=colorIndex; - this.w=w; - this.h=h; - } - - public void paintIcon(Component c, Graphics g, int x, int y) { - g.setColor(Color.black); - g.drawRect(x, y, w-1, h-1); - if(colorIndex==AColorMap.INVISIBLE) { - g.setColor(AColorMap.getColors()[AColorMap.WH]); - g.fillRect(x+1, y+1, w-2, h-2); - g.setColor(Color.black); - g.drawLine(x, y, x+w-1, y+h-1); - g.drawLine(x, y+h-1, x+w-1, y); - } else if(colorIndex==AColorMap.NO_COLOR) { - g.setColor(AColorMap.getColors()[AColorMap.WH]); - g.fillRect(x+1, y+1, w-2, h-2); - g.setColor(Color.black); - int xc=x+w/2; - int yc=y+h/2; - g.drawLine(xc, yc-2, xc, yc+2); - g.drawLine(xc-2, yc, xc+2, yc); - } else { - g.setColor(AColorMap.getColors()[colorIndex]); - g.fillRect(x+1, y+1, w-2, h-2); - } - } - - public int getColorIndex() { - return colorIndex; - } - - public void setColorIndex(int colorIndex) { - this.colorIndex=colorIndex; - } - - public int getIconWidth() { - return w; - } - - public int getIconHeight() { - return h; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/list/AList.java b/graphics/AtlantisJava/src/atlantis/list/AList.java deleted file mode 100755 index 7377bef99e9b2843dfeee57b9c4efaf2d7c83fd6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/list/AList.java +++ /dev/null @@ -1,128 +0,0 @@ -package atlantis.list; - -import atlantis.event.AData; - -/** - * Instance of AList as seen in AListManager (Lists) - * source references instance of the datatype in the list - * <ul> - * <li>itemsIndex is a list of indices (Atlantis internal datatitems indices) - * of the particular datape which are in the list</li> - * <li>itemsID is a list of dataitems IDs of the datatype in the list</li> - * </ul> - * - * <p>index and id is identical for Track for instance, but different for - * calo cells. When masking data on cross-event basis, IDs are necessary - * (e.g. masking hot calo cells based on their IDs)</p> - * - * <p>Copyright: Copyright (c) 2002</p> - * - * @author not attributable - * @version 1.0 - */ -public class AList -{ - private AData source; - private int[] itemsIndex; - private int[] itemsID; - - - /** - * - * @param data AData - * @param singleItem int - index of the dataitem to put in the list - */ - public AList(AData data, int singleItem) - { - source = data; - itemsIndex = new int[] { singleItem }; - itemsID = new int[] { source.getIdFromIndex(singleItem) }; - - } // AList() ------------------------------------------------------------ - - - - public AList(AData data, boolean[] drawn) - { - source = data; - int num = 0; - for(int i = 0; i < drawn.length; ++i) - { - if(drawn[i]) - { - num++; - } - } - - itemsIndex = new int[num]; - itemsID = new int[num]; - num = 0; - - for(int i = 0; i < drawn.length; ++i) - { - if(drawn[i]) - { - itemsIndex[num] = i; - itemsID[num] = source.getIdFromIndex(i); - num++; - } - } - - } // AList() ------------------------------------------------------------ - - - - /** - * String representation of the AList instance. Returns the datatype name, - * resp. screen name and if there one item in the only, then the item's - * ID. If there are more items, it says the number of dataitems. - * @return String - */ - public String toString() - { - String key = source.getStoreGateKey(); - String sn = source.getNameScreenName(); - String name = key != null ? sn + ":" + key : sn; - - if(itemsIndex.length == 1) - { - return name + " " + source.getIdFromIndex(itemsIndex[0]); - } - else - { - return name + " (" + itemsIndex.length + " items)"; - } - - } // toString() --------------------------------------------------------- - - - - public AData getSource() - { - return source; - - } // getSource() -------------------------------------------------------- - - - - /** - * Returns indices of the items in the list (internal Atlantis indices - * which are *sometimes* identical with IDs) - * @return int[] - */ - public int[] getItems() - { - return itemsIndex; - - } // getItems() --------------------------------------------------------- - - - - public int[] getItemsID() - { - return itemsID; - - } // getItemsID() ------------------------------------------------------- - - -} // class AList ============================================================ diff --git a/graphics/AtlantisJava/src/atlantis/list/AListManager.java b/graphics/AtlantisJava/src/atlantis/list/AListManager.java deleted file mode 100755 index 815d922e087b1bff90080e92d0522ff7959bf821..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/list/AListManager.java +++ /dev/null @@ -1,1765 +0,0 @@ -package atlantis.list; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.Point; -import java.awt.dnd.DragSource; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.Box; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTree; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.MutableTreeNode; -import javax.swing.tree.TreeNode; -import javax.swing.tree.TreePath; - -import atlantis.canvas.ACanvas; -import atlantis.data.AHelix; -import atlantis.data.ARVxData; -import atlantis.data.ATrackData; -import atlantis.event.AData; -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACursorFactory; -import atlantis.graphics.AIcon; -import atlantis.graphics.APickingGraphics2D; -import atlantis.graphics.colormap.AColorMap; -import atlantis.gui.AGUI; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.APar; -import atlantis.utils.A4Vector; -import atlantis.utils.ALogger; -import atlantis.utils.AMath; -import atlantis.utils.AUtilities; - -public class AListManager extends JTree implements MouseListener, MouseMotionListener -{ - private static ALogger logger = ALogger.getLogger(AListManager.class); - private static AEventManager eventManager = AEventManager.instance(); - - // used to display the tree - static private JFrame dialog; // rather than JDialog - // special nodes - static private final DefaultMutableTreeNode root = new DefaultMutableTreeNode("Lists"); - static private final DefaultMutableTreeNode highlight = new DefaultMutableTreeNode("Highlight"); - static private final DefaultMutableTreeNode lastDrawn = new DefaultMutableTreeNode("Last Drawn"); - static private final DefaultMutableTreeNode others = new DefaultMutableTreeNode("Others"); - static private final DefaultMutableTreeNode invisible = new DefaultMutableTreeNode("Invisible"); - static private final DefaultMutableTreeNode mass = new DefaultMutableTreeNode("Calculation"); - // instance - static private final AListManager listManager = new AListManager(); - static private DefaultTreeModel dtm; - static private int numLists = 0; - // source and status of Drag and Drop - static private DefaultMutableTreeNode source = null; - static private boolean draging = false; - static private HashMapSet nodeColors; - - // counters for V0 mass calc - static private int V0vx=0; - static private int V0tracks=0; - static private int V0charge=0; - - // private static final Cursor DROP_VALID = DragSource.DefaultMoveDrop; - private static final Cursor DROP_VALID_COPY = DragSource.DefaultCopyDrop; - // private static final Cursor DROP_INVALID = DragSource.DefaultMoveNoDrop; - - - - private AListManager() - { - super(root, true); - dtm = (DefaultTreeModel) getModel(); - nodeColors = new HashMapSet(); - reset(); - - addMouseListener(this); - addMouseMotionListener(this); - setSelectionRow(1); - setPreferredSize(new Dimension(200, 300)); - setRootVisible(true); - setScrollsOnExpand(true); - setShowsRootHandles(false); - setCellRenderer(new ColorRenderer()); - - if (!AGlobals.isAtlantisHeadless()) { - // set up the visual representation - dialog = new JFrame("List manager"); - AIcon.setIconImage(dialog); - Box b = Box.createHorizontalBox(); - b.add(new JScrollPane(this)); - b.add(new ColorPanel()); - dialog.getContentPane().add(b); - dialog.pack(); - dialog.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); - } - - } // AListManager() ----------------------------------------------------- - - - - public static AListManager getInstance() - { - return listManager; - - } // getInstance() ------------------------------------------------------ - - - - public void showLists() - { - Component gui = AGlobals.instance().getGuiFrame(); - if (gui != null) - { - dialog.setLocation(gui.getLocation()); - } - dialog.setVisible(true); - - } // showLists() -------------------------------------------------------- - - - - private boolean isAlreadyInTheList(AList list, - DefaultMutableTreeNode destination) - { - boolean already = false; - for(int i = 0; i < destination.getChildCount(); i++) - { - DefaultMutableTreeNode child = - (DefaultMutableTreeNode) destination.getChildAt(i); - if(!child.getAllowsChildren()) - { - AList a = (AList) child.getUserObject(); - if(a.getSource() == list.getSource()) - { - int[] items = a.getItems(); - int newItem = list.getItems()[0]; - for(int j = 0; j < items.length; ++j) - { - if(items[j] == newItem) - { - already = true; - } - } - } - } - } - - return already; - - } // isAlreadyInTheList() ----------------------------------------------- - - - - public void add(AList list) - { - if(!dialog.isVisible()) - { - dialog.setVisible(true); - } - - // default destination - DefaultMutableTreeNode destination = root; - TreePath tp = getSelectionPath(); - if(tp != null) - { - destination = (DefaultMutableTreeNode) tp.getLastPathComponent(); - } - - if(destination != null && destination.getAllowsChildren()) - { - if(destination == others || destination == lastDrawn || - destination == highlight || destination == invisible || - destination == mass) - { - AOutput.alwaysAppend("Can't add to " + destination, ALogInterface.WARNING); - return; - } - - // check if it's already in the list and if so, don't add - boolean already = this.isAlreadyInTheList(list, destination); - if(already) - { - logger.info(list + " is already in this list, not added"); - } - else - { - dtm.insertNodeInto(new DefaultMutableTreeNode(list, false), - destination, destination.getChildCount()); - expandPath(new TreePath(dtm.getPathToRoot(destination))); - ACanvas.getCanvas().repaintAllFromScratch(); - } - } - - } // add() ------------------------------------------------------------- - - - - /** - * Adds the selected item to the mass list and outputs the invariant mass in the output window - * Doesn't make the list visible as really only need to see output window - * @param list - */ - public void massCalc(AList list) - { - // default destination - DefaultMutableTreeNode destination = mass; - TreePath tp = getSelectionPath(); - - if(destination != null && destination.getAllowsChildren()) - { - // check if it's already in the list and if so, don't add - boolean already = this.isAlreadyInTheList(list, destination); - if(already) - { - logger.info(list + " is already in this list, not added"); - } - else - { - dtm.insertNodeInto(new DefaultMutableTreeNode(list, false), - destination, destination.getChildCount()); - expandPath(new TreePath(dtm.getPathToRoot(destination))); - ACanvas.getCanvas().repaintAllFromScratch(); - } - } - - if (tp != null) - { - setSelectionPath(tp); - } - - // added to list, now do summarise - Summarizer summ = new Summarizer(); - AOutput.alwaysAppend(summ.getHeader(), ALogInterface.NORMAL); - - AList[] children = getChildren(mass); - - int chiLength = children.length; - - for(int i = 0; i < chiLength; i++) - { - int num = children[i].getItems().length; - A4Vector v = children[i].getSource().get4Vector(num, - children[i].getItems(),0.14); //assume pion mass - - - if(v != null && num > 0) - { - String info = summ.addAndGetInfo(v, children[i].toString()); - AOutput.alwaysAppend(info, ALogInterface.NORMAL); - } - } - - String msg = summ.getTotalInfo(); - - AOutput.alwaysAppend(msg, ALogInterface.NORMAL_BOLD); // Print default summary (ie, assuming pi mass for all) - - summ = null; - - } // massCalc() ------------------------------------------------------------- - - /** - * Adds the selected item to the mass list and outputs the invariant mass in the output window - * Doesn't make the list visible as really only need to see output window - * This is the massCalc function for V0 decays. Check for up to 2 tracks and display 4 mass scenarios - * @param list - */ - public void massCalcV0(AList list) - { - // default destination - DefaultMutableTreeNode destination = mass; - TreePath tp = getSelectionPath(); - - if(getChildren(mass).length == 0) // if list is empty, make sure counters are reinitialised - { - V0vx=0; - V0tracks=0; - V0charge=0; - } - - if(destination != null && destination.getAllowsChildren()) - { - // check if it's already in the list and if so, don't add - boolean already = this.isAlreadyInTheList(list, destination); - - // check list for tracks and vertices (to a maximum of 2 tracks and 1 vertex) - if(getChildren(mass).length < 3) - { - if(already) - { - logger.info(list + " is already in this list, not added"); - } - else if(!(list.getSource() instanceof ARVxData || list.getSource() instanceof ATrackData)) - { - logger.info("not selected a track or vertex"); - AOutput.alwaysAppend("\n\n Not selected a track or vertex\n\n",ALogInterface.PICK); - return; - } - else if((list.getSource() instanceof ARVxData && V0vx>=1) || (list.getSource() instanceof ATrackData && V0tracks>=2)) - { - logger.info("already a vertex or two tracks selected"); - AOutput.alwaysAppend("\n\n Already a vertex or two tracks selected\n",ALogInterface.PICK); - return; - } - else - { - - // check the charges of the two tracks are opposite - // - if((list.getSource() instanceof ATrackData)) - { - ATrackData track = (ATrackData) list.getSource(); - AHelix h = track.getModifiableHelix(list.getItemsID()[0]); - if((V0charge != 0) && (V0charge * AMath.getSign(h.pT()) > 0)) - { - logger.info("2nd track is same charge as 1st track"); - AOutput.alwaysAppend("\n\nPlease pick an oppositely charged track\n", ALogInterface.PICK); - return; - } - } //end check charge - - // now increment the counters - // all tests passed, now can input into list. - - if(list.getSource() instanceof ATrackData) - { - V0tracks++; - logger.info("Selected a Track"); - } - else if(list.getSource() instanceof ARVxData) - { - V0vx++; - logger.info("Selected a Vertex"); - } - - dtm.insertNodeInto(new DefaultMutableTreeNode(list, false), - destination, destination.getChildCount()); - expandPath(new TreePath(dtm.getPathToRoot(destination))); - ACanvas.getCanvas().repaintAllFromScratch(); - } - - } - else - { - logger.info("list full (max 2 tracks + 1 vertex)"); - AOutput.alwaysAppend("\n\n List full (max 2 tracks + 1 vertex)\n",ALogInterface.PICK); - return; - } - } - if (tp != null) - { - setSelectionPath(tp); - } - - - // added to list, now do summarise - Summarizer summK = new Summarizer(); // K -> pi pi - Summarizer summL = new Summarizer(); // Lambda -> pi p - Summarizer summAL = new Summarizer(); // AntiLambda -> pi pbar - Summarizer summG = new Summarizer(); // gamma -> ee - - double[] secVx = new double[3]; // initialisation of secVx x,y,z array, if no vertex selected, use primary - double[] priVx = new double[3]; // primary vertex container (used to calculate decay length) - APar parameterStore = APar.instance(); - priVx[0]=parameterStore.get("Event", "XVtx").getD(); - priVx[1]=parameterStore.get("Event", "YVtx").getD(); - priVx[2]=parameterStore.get("Event", "ZVtx").getD(); - - secVx=priVx; - - AList[] children = getChildren(mass); - - - int chiLength = children.length; - - if(chiLength == 3) - { - boolean V0title = true; - for(int i = 0; i < chiLength; i++) - { - AData source = children[i].getSource(); - //ordering of the list is important. - //if vertex selected second, then the tracks selected before use primary vertex... - //need to get secVx first, THEN calculate tracks... - if(source instanceof ARVxData) - { - ARVxData rvx = (ARVxData) source; - secVx = rvx.getVertex(children[i].getItemsID()[0]); // gets x,y,z of the picked vertex. - } - } - - for(int i = 0; i < chiLength; i++) - { - - AData source = children[i].getSource(); - - if(source instanceof ATrackData) - { - ATrackData track = (ATrackData) source; - - // get helix of picked track - AHelix h = track.getModifiableHelix(children[i].getItemsID()[0]); - - // get charge for charge check - V0charge = (int) (Math.abs(h.pT())/h.pT()); - - int num = children[i].getItems().length; - - // initialise 4 vectors - A4Vector vK = source.get4Vector(num, - children[i].getItems(),0.0); - A4Vector vL = source.get4Vector(num, - children[i].getItems(),0.0); - A4Vector vAL = source.get4Vector(num, - children[i].getItems(),0.0); - A4Vector vG = source.get4Vector(num, - children[i].getItems(),0.0); - - - // now calculate the 4 vector - if(V0vx > 0) - { - double R = parameterStore.get("Event", "Curvature").getD() * Math.abs(h.pT()); - - // +1/-1 for a clockwise/anti-clockwise helix - double S = (int) (Math.abs(h.pT())/h.pT()); - - // Coordinates of the center point for the helix - double xC = (S * h.d0() - R) * Math.cos(Math.toRadians(h.phi0()) + S * Math.PI / 2.); - double yC = (S * h.d0() - R) * Math.sin(Math.toRadians(h.phi0()) + S * Math.PI / 2.); - - // calculate new phi from centre of curvature and secondary vertex - double phiPrime = Math.atan2(yC-secVx[1], xC-secVx[0]) + S*(Math.PI / 2.0); - - double px = Math.abs(h.pT()) * Math.cos(h.phi0()); - double py = Math.abs(h.pT()) * Math.sin(h.phi0()); - double pz = Math.abs(h.pT()) * Math.sinh(h.eta()); - - // recalculate px/py at secondary vertex - double pxPrime = Math.sqrt((px*px) + (py*py))*Math.cos(phiPrime); - double pyPrime = Math.sqrt((px*px) + (py*py))*Math.sin(phiPrime); - - px = pxPrime; - py = pyPrime; - - if(chiLength == 3 && !parameterStore.get("Minerva", "hideV0massoutput").getStatus()) - { - logger.info("recalculating tracks"); - AOutput.alwaysAppend("\n\nRecalculated track values:\n", ALogInterface.PICK); - AOutput.alwaysAppend(source.getNameScreenName()+" index: " + (children[i].getItemsID()[0]) + "\n" - +"PT="+String.format("%.3f",h.pT()) +" GeV\n" - +AMath.ETA+" = "+String.format("%.3f",h.eta())+"\n" - +AMath.PHI+" = "+String.format("%.3f",Math.toDegrees(phiPrime))+AMath.DEGREES+"\n" - +"Px=" + String.format("%.3f",px) +" GeV\n" - +"Py=" + String.format("%.3f",py) +" GeV\n" - +"Pz=" + String.format("%.3f",pz) +" GeV\n" - +"Charge = " + V0charge//Math.abs(V0charge) - ,ALogInterface.PICK); - } - else if(chiLength == 3) - { - if(V0title) - { - V0title = false; - - double decayLength = Math.sqrt(Math.pow(secVx[0]-priVx[0], 2.0)+Math.pow(secVx[1]-priVx[1], 2.0)+Math.pow(secVx[2]-priVx[2], 2.0)); - - AOutput.alwaysAppend("\n Decay length for selected vertex: "+String.format("%.2f",decayLength)+" cm\n\n", ALogInterface.PICK); - - - AOutput.alwaysAppend("\n Momentum for selected tracks: \n\n", ALogInterface.PICK); - } - if(V0charge>0) - AOutput.alwaysAppend("+ve track (px,py,pz): ("+String.format("%.3f",px)+", "+String.format("%.3f",py)+", "+String.format("%.3f",pz)+")\n", ALogInterface.PICK); - else if(V0charge <0) - AOutput.alwaysAppend("-ve track (px,py,pz): ("+String.format("%.3f",px)+", "+String.format("%.3f",py)+", "+String.format("%.3f",pz)+")\n", ALogInterface.PICK); - - } - - - /* now check charges of particles again and add to corresponding 4vectors - * - * scenarios: - * - * (K) Kaon -> pi+ pi- - * (L) Lambda -> proton pi- - * (AL)AntiLambda -> antiproton pi+ - * (G) Gamma -> e+ e- - * - * - * - */ - - // negative charge - if(V0charge < 0) - { - vK.set(px, py, pz, 0.1396); - vL.set(px, py, pz, 0.1396); - vAL.set(px, py, pz, 0.938); - vG.set(px, py, pz, 0.000511); - } - // positive charge - else if(V0charge > 0) - { - vK.set(px, py, pz, 0.1396); - vL.set(px, py, pz, 0.938); - vAL.set(px, py, pz, 0.1396); - vG.set(px, py, pz, 0.000511); - } - - - - // this is to display each track summary. - // currently off as too much summary crowds the output - if(vK != null && vL != null && vAL != null && vG != null && num > 0 && chiLength == 3) - { - String info = summK.addAndGetInfo(vK, children[i].toString()); - //AOutput.alwaysAppend(info, ALogPane.NORMAL); - info = summL.addAndGetInfo(vL, children[i].toString()); - //AOutput.alwaysAppend(info, ALogPane.NORMAL); - info = summAL.addAndGetInfo(vAL, children[i].toString()); - //AOutput.alwaysAppend(info, ALogPane.NORMAL); - info = summG.addAndGetInfo(vG, children[i].toString()); - //AOutput.alwaysAppend(info, ALogPane.NORMAL); - } - } - - } - } - - if(chiLength ==3 && !parameterStore.get("Minerva", "hideV0massoutput").getStatus()) - { - // Config switch to display either mass or px,py,pz. - String msgK = summK.getTotalInfo(); - String msgL = summL.getTotalInfo(); - String msgAL = summAL.getTotalInfo(); - String msgG = summG.getTotalInfo(); - - AOutput.alwaysAppend("\n V0 Decay Scenarios", ALogInterface.NORMAL_BOLD); - - AOutput.alwaysAppend(summK.getHeader(), ALogInterface.NORMAL); - - // print out the resultant mass calculation for each scenario - AOutput.alwaysAppend("K"+AMath.RARROW+AMath.PION+AMath.SUPPLUS+AMath.PION+AMath.SUPMINUS+"\n", ALogInterface.NORMAL); - AOutput.alwaysAppend(msgK, ALogInterface.NORMAL_BOLD); // Print kaon summary - AOutput.alwaysAppend("\n"+AMath.LAMBDACAP+AMath.RARROW+"p"+AMath.PION+AMath.SUPMINUS+"\n", ALogInterface.NORMAL); - AOutput.alwaysAppend(msgL, ALogInterface.NORMAL_BOLD); // Print lambda summary - AOutput.alwaysAppend("\n"+AMath.LAMBDACAP+AMath.OVERLINE+AMath.RARROW+"p"+AMath.OVERLINE+AMath.PION+AMath.SUPPLUS+"\n", ALogInterface.NORMAL); - AOutput.alwaysAppend(msgAL, ALogInterface.NORMAL_BOLD); // Print antilambda summary - AOutput.alwaysAppend("\n"+AMath.GAMMA+AMath.RARROW+"e"+AMath.SUPPLUS+"e"+AMath.SUPMINUS+"\n", ALogInterface.NORMAL); - AOutput.alwaysAppend(msgG, ALogInterface.NORMAL_BOLD); // Print gamma summary - AOutput.alwaysAppend("\n", ALogInterface.NORMAL); - } - } - summK = null; - summL = null; - summAL = null; - summG = null; - - } // massCalcV0() ------------------------------------------------------------- - - /** - * Takes two vectors from a list (added with the pick interaction and P key modifier) - * and prints the delta R and delta Phi of the vectors - * @param list - */ - public void deltaR(AList list) - { - // default destination - DefaultMutableTreeNode destination = mass; - TreePath tp = getSelectionPath(); - - if(destination != null && destination.getAllowsChildren()) - { - // check if it's already in the list and if so, don't add - boolean already = this.isAlreadyInTheList(list, destination); - - if(already) - { - logger.info(list + " is already in this list, not added"); - } - else - { - if(getChildren(mass).length >= 2){ - logger.info(list + " is full, maximum of 2 objects for delta phi calculation " + - "\n Clearing list"); - //AOutput.alwaysAppend("\n\n List full \n Clearing List \n",ALogPane.PICK); - mass.removeAllChildren(); - } - dtm.insertNodeInto(new DefaultMutableTreeNode(list, false), - destination, destination.getChildCount()); - expandPath(new TreePath(dtm.getPathToRoot(destination))); - ACanvas.getCanvas().repaintAllFromScratch(); - } - } - - if (tp != null) - { - setSelectionPath(tp); - } - - AList[] children = getChildren(mass); - - int chiLength = children.length; - if(chiLength == 2){ - A4Vector v1 = children[0].getSource().get4Vector(children[0].getItems().length, - children[0].getItems(),0.0); - A4Vector v2 = children[1].getSource().get4Vector(children[1].getItems().length, - children[1].getItems(),0.0); - - if(v1 != null && v2 != null) - { - double deltaPhi = Math.abs(v1.getPhi() - v2.getPhi()) > Math.PI ? (2*Math.PI) - Math.abs(v1.getPhi() - v2.getPhi()) : Math.abs(v1.getPhi() - v2.getPhi()); - double deltaEta = Math.abs(v1.getEta() - v2.getEta()); - double deltaR = Math.sqrt(deltaPhi*deltaPhi + deltaEta*deltaEta); - - String info = "\n\n"+AMath.DELTA+AMath.PHI+" = "+String.format("%.1f",Math.toDegrees(deltaPhi))+AMath.DEGREES+" ("+String.format("%.3f",deltaPhi)+")" - + "\n"+AMath.DELTA+"R = "+String.format("%.3f",deltaR)+"\n"; - AOutput.alwaysAppend(info, ALogInterface.NORMAL_BOLD); - } - - } - } - - public void highlight(AList list) - { - highlight.removeAllChildren(); - dtm.insertNodeInto(new DefaultMutableTreeNode(list, false), highlight, 0); - dtm.reload(highlight); - expandPath(new TreePath(dtm.getPathToRoot(highlight))); - ACanvas.getCanvas().repaintAllFromScratch(); - - } // highlight() -------------------------------------------------------- - - - - public void addLastDrawn(AList list) - { - dtm.insertNodeInto(new DefaultMutableTreeNode(list, false), lastDrawn, 0); - dtm.reload(lastDrawn); - - } // addLastDrawn() ----------------------------------------------------- - - - - public void addInvisible(AList list) - { - if(!dialog.isVisible()) - { - dialog.setVisible(true); - } - - // check if it's already in the list and if so, don't add - boolean already = this.isAlreadyInTheList(list, invisible); - if(already) - { - logger.info(list + " is already in the Invisible list, not added"); - } - else - { - dtm.insertNodeInto(new DefaultMutableTreeNode(list, false), - invisible, invisible.getChildCount()); - expandPath(new TreePath(dtm.getPathToRoot(invisible))); - ACanvas.getCanvas().repaintAllFromScratch(); - } - - } // addInvisible() ----------------------------------------------------- - - - /** - * When adding items to the list using rubberband they are grouped by type - * and appear as "InDetTrack (5 items)". This method allows the user to expand - * these items so they can manipulate individual items. - * @param s Collection - * @return Action - */ - private Action expand(final Collection s) - { - // This is called when the user right-clicks, we first determine if this - // item can be expanded or not. - if (s.contains(root) || s.size() != 1) - { - return null; - } - - DefaultMutableTreeNode node = (DefaultMutableTreeNode) s.iterator().next(); - if (node.getUserObject() instanceof AList) - { - AList a = (AList) node.getUserObject(); - if (a.getItems().length < 1) - { - return null; - } - } - else - { - return null; - } - - // It can be expanded, so we add a menu item to the popup with the callback - // function as specified below. - return new AbstractAction("Expand items") - { - public void actionPerformed(ActionEvent e) - { - // We checked these casts before adding the callback - DefaultMutableTreeNode node = (DefaultMutableTreeNode) s.iterator().next(); - AList a = (AList) node.getUserObject(); - DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); - int index = parent.getIndex(node); - - // Now go through the list and add the items one by one to the parent. - for (int i=0; i<a.getItems().length; i++) - { - AList list = new AList(a.getSource(), a.getItems()[i]); - dtm.insertNodeInto(new DefaultMutableTreeNode(list, false), parent, index); - } - - // And remove the old list. - dtm.removeNodeFromParent(node); - } - }; - - } // expand() ----------------------------------------------------------- - - - private Action remove(final Collection s) - { - if(s.contains(root)) - { - return null; - } - - return new AbstractAction("Remove") - { - public void actionPerformed(ActionEvent e) - { - for (Iterator i = s.iterator(); i.hasNext();) - { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) i.next(); - if (node.getUserObject() instanceof AList) - { - AList a = (AList) node.getUserObject(); - a.getSource().remove(a.getItems()); - } - dtm.removeNodeFromParent(node); - ACanvas.getCanvas().repaintAllFromScratch(); - } - } - }; - - } // remove() ----------------------------------------------------------- - - - - /** - * This method is called after right-click -> summarize on the list-item in - * the list dialog - * @param s Collection - * @return Action - */ - private Action newSummarize(final Collection s) - { - if(s.contains(root) || s.size() != 1) - { - return null; - } - - return new AbstractAction("Summarize") - { - public void actionPerformed(ActionEvent e) - { - Summarizer summ = new Summarizer(); - AOutput.alwaysAppend(summ.getHeader(), ALogInterface.NORMAL); - - for(Iterator j = s.iterator(); j.hasNext();) - { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) j.next(); - AList[] children = getChildren(node); - - for(int i = 0; i < children.length; i++) - { - int num = children[i].getItems().length; - AList child = children[i]; - AData source = child.getSource(); - A4Vector v = source.get4Vector(num, child.getItems()); - - if(v != null && num > 0) - { - String info = summ.addAndGetInfo(v, children[i].toString()); - AOutput.alwaysAppend(info, ALogInterface.NORMAL); - } - } - } - - String msg = summ.getTotalInfo(); - AOutput.alwaysAppend(msg, ALogInterface.NORMAL_BOLD); - - summ = null; - - } // actionPerformed() - }; - - } // newSummarize() ----------------------------------------------------- - - - - /** - * This summarize method is called from rubberbanding menu - Summarize - * (from ASelection class) - */ - public void summarize() - { - if(lastDrawn == null) - { - return; - } - - Summarizer summ = new Summarizer(); - - AList[] children = getChildren(lastDrawn); - - AOutput.alwaysAppend(summ.getHeader(), ALogInterface.NORMAL); - - for(int i = 0; i < children.length; i++) - { - int num = children[i].getItems().length; - A4Vector v = children[i].getSource().get4Vector(num, children[i].getItems()); - - if(v != null && num > 0) - { - String msg = summ.addAndGetInfo(v, children[i].toString()); - AOutput.alwaysAppend(msg, ALogInterface.NORMAL); - } - } - - String msg = summ.getTotalInfo(); - AOutput.alwaysAppend(msg, ALogInterface.NORMAL_BOLD); - - summ = null; - - } // summarize() -------------------------------------------------------- - - - - private Action reset(final Collection s) - { - if(s.size() == 1 && s.contains(root)) - { - return new AbstractAction("Reset") - { - public void actionPerformed(ActionEvent e) - { - reset(); - ACanvas.getCanvas().repaintAllFromScratch(); - } - }; - } - else - { - return null; - } - - } // reset() ------------------------------------------------------------ - - - - public void clearHighlight() - { - highlight.removeAllChildren(); - dtm.reload(highlight); - ACanvas.getCanvas().repaintAllFromScratch(); - - } // clearHighlight() --------------------------------------------------- - - - - public void clearHighlightAndMassCalculation() - { - highlight.removeAllChildren(); - dtm.reload(highlight); - mass.removeAllChildren(); - dtm.reload(mass); - ACanvas.getCanvas().repaintAllFromScratch(); - - } // clearHighlightAndMassCalculation() --------------------------------------------------- - - - - public void clearLastDrawn() - { - lastDrawn.removeAllChildren(); - dtm.reload(lastDrawn); - - } // clearLastDrawn() --------------------------------------------------- - - - - /** - * Check if list (list of IDs id) of datatimes (toMask datatype) is present - * in the current event and if so, the items are added into the Invisible - * list, thus masked and igrored. - * - * @param toMask AData - * @param id int[] - * @param index int[] - */ - private boolean checkAndAddIntoInvisible(int[] id, int[] indexCheck, String key) - { - boolean result = false; - - // check if the datatype (key) exists in the new event - AEvent e = eventManager.getCurrentEvent(); - AData toMask = e.get(key); - - if(toMask != null) - { - // iterate over all data items in this list - for(int i = 0; i < id.length; i++) - { - // check if this ID is present in the current event - int index = toMask.getIndexFromId(id[i]); - if(index != -1) - { - // AList expects datatype and its index - AList l = new AList(toMask, index); - addInvisible(l); - AOutput.alwaysAppend(" " + l.toString() + "\n", ALogInterface.NORMAL); - result = true; - - // 2007-08-29: debugging check, remove after some time if the - // problem is not observed (then indexCheck param is not needed) - if(index != indexCheck[i]) - { - logger.warn("AListManager: problem, indices not equal!"); - } - // </debug> - } - } - } - - return result; - - } // checkAndAddIntoInvisible() ----------------------------------------- - - - - /** - * restore Invisible list, cross-event invisible - * @param backup AList[] - */ - private void restoreInvisible(AList[] backup) - { - if(backup.length > 0) - { - AOutput.alwaysAppend("\nPrevious Invisible list not empty, masked items:\n", - ALogInterface.WARNING); - - boolean somethingInvisible = false; - - for(int i = 0; i < backup.length; i++) - { - AData d = backup[i].getSource(); - String sg = d.getStoreGateKey(); - String accessKey = d.getName() + (sg != null ? sg : ""); - - if(backup[i].getItems().length > 1) - { - somethingInvisible = checkAndAddIntoInvisible(backup[i].getItemsID(), - backup[i].getItems(), accessKey); - } - else - { - int id = backup[i].getItemsID()[0]; - int index = backup[i].getItems()[0]; - somethingInvisible = checkAndAddIntoInvisible(new int[] { id }, - new int[] { index }, accessKey); - } - - } // for (overall items in the Invisible list) - - if(!somethingInvisible) - { - AOutput.alwaysAppend(" none\n", ALogInterface.NORMAL); - } - - } // if(backup.length > 0) - - } // restoreInvisible() ------------------------------------------------- - - - - public void resetAndPreserveInvisible() - { - AList[] invisibleBackup = getChildren(invisible); - reset(); - restoreInvisible(invisibleBackup); - - } // resetAndPreserveInvisible() ---------------------------------------- - - - - public void reset() - { - root.removeAllChildren(); - highlight.removeAllChildren(); - lastDrawn.removeAllChildren(); - invisible.removeAllChildren(); - mass.removeAllChildren(); - - root.add(highlight); - root.add(lastDrawn); - root.add(others); - root.add(invisible); - root.add(mass); - - numLists = 0; - root.add(new DefaultMutableTreeNode("List " + numLists++)); - - nodeColors.clear(); - nodeColors.put(highlight, new Integer(AColorMap.WH)); - nodeColors.put(invisible, new Integer(AColorMap.INVISIBLE)); - nodeColors.put(mass, new Integer(AColorMap.WH)); - dtm.reload(); - - } // reset() ------------------------------------------------------------ - - - - private Action rename(Collection s) - { - if(s.size() != 1) - { - return null; - } - - final DefaultMutableTreeNode selected = - (DefaultMutableTreeNode) (s.iterator().next()); - - if(!selected.getAllowsChildren() || selected == root || - selected == others || selected == highlight || - selected == lastDrawn || selected == invisible || - selected == mass) - { - return null; - } - - return new AbstractAction("Rename") - { - public void actionPerformed(ActionEvent h) - { - String name = JOptionPane.showInputDialog(listManager, - "Enter new name"); - selected.setUserObject(name); - } - }; - - } // rename() ----------------------------------------------------------- - - - - private Action newParent(final Collection s) - { - if(s.contains(root)) - { - return null; - } - - Set parents = new HashSet(); - - for(Iterator i = s.iterator(); i.hasNext();) - { - parents.add(((TreeNode) (i.next())).getParent()); - } - - if(parents.size() != 1) - { - return null; - } - - final DefaultMutableTreeNode oldParent = - (DefaultMutableTreeNode) (parents.iterator().next()); - - return new AbstractAction("New Parent") - { - public void actionPerformed(ActionEvent e) - { - DefaultMutableTreeNode newParent = - new DefaultMutableTreeNode("List " + numLists++); - int index = 0; - for(Iterator i = s.iterator(); i.hasNext();) - { - index = Math.min(oldParent.getIndex((TreeNode) (i.next())), - index); - } - - for(Iterator i = s.iterator(); i.hasNext();) - { - dtm.removeNodeFromParent((MutableTreeNode) (i.next())); - } - - dtm.insertNodeInto(newParent, oldParent, index); - - for(Iterator i = s.iterator(); i.hasNext();) - { - dtm.insertNodeInto((MutableTreeNode) (i.next()), newParent, 0); - } - - expandPath(new TreePath(dtm.getPathToRoot(newParent))); - } - }; - - } // newParent() -------------------------------------------------------- - - - - private Action newChild(final Collection s) - { - if(s.size() != 1) - { - return null; - } - - final DefaultMutableTreeNode selected = - (DefaultMutableTreeNode) (s.iterator().next()); - - if(!selected.getAllowsChildren()) - { - return null; - } - - return new AbstractAction("New Child") - { - public void actionPerformed(ActionEvent h) - { - dtm.insertNodeInto(new DefaultMutableTreeNode("List " + numLists++), - selected, 0); - expandPath(new TreePath(dtm.getPathToRoot(selected))); - } - }; - - } // newChild() --------------------------------------------------------- - - - - private DefaultMutableTreeNode getNode(Point m) - { - TreePath p = getPathForLocation(m.x, m.y); - if(p != null) - { - TreeNode tn = (TreeNode) p.getLastPathComponent(); - if(tn instanceof DefaultMutableTreeNode) - { - return (DefaultMutableTreeNode) tn; - } - } - return null; - - } // getNode() ---------------------------------------------------------- - - - - private static class HashMapSet extends HashMap - { - public Object put(Object key, Object value) - { - // don't allow duplicates - if(containsKey(key)) - { - this.remove(key); - } - - if(value != null) - { - return super.put(key, value); - } - - else - { - return null; - } - } - } - - - - class ColorRenderer extends DefaultTreeCellRenderer - { - AColorIcon folderIcon; - AColorIcon leafIcon; - - public ColorRenderer() - { - folderIcon = new AColorIcon(AColorMap.WH, 15, 11); - leafIcon = new AColorIcon(AColorMap.WH, 11, 11); - } - - public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) - { - - super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); - - int c = getColor((TreeNode) value); - if (c == AColorMap.NO_COLOR) - setToolTipText("No Color"); - else if (c == AColorMap.INVISIBLE) - setToolTipText("Invisible"); - else - setToolTipText(""); - - if (leaf) - { - leafIcon.setColorIndex(c); - setIcon(leafIcon); - } - else - { - folderIcon.setColorIndex(c); - setIcon(folderIcon); - } - - return this; - } - - } - - private int getColor(TreeNode node) - { - TreeNode[] parents = dtm.getPathToRoot(node); - int color = AColorMap.NO_COLOR; - for (int i = 0; i < parents.length; ++i) - { - Object o = nodeColors.get(parents[i]); - if (o != null) - color = ((Integer) o).intValue(); - } - return color; - } - - private DefaultMutableTreeNode[] getLeafs() - { - java.util.List list = new ArrayList(); - for (int i = 0; i < root.getChildCount(); ++i) - { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i); - if (node != lastDrawn) - { - if (node.getAllowsChildren()) - { - Enumeration descendents = node.breadthFirstEnumeration(); - while (descendents.hasMoreElements()) - { - DefaultMutableTreeNode descendent = (DefaultMutableTreeNode) (descendents.nextElement()); - if (!descendent.getAllowsChildren()) - list.add(descendent); - } - } - else - { - list.add(node); - } - } - } - return (DefaultMutableTreeNode[]) list.toArray(new DefaultMutableTreeNode[list.size()]); - } - - public int[][] getColorMapping(AData data) - { - DefaultMutableTreeNode[] leafs = getLeafs(); - int num = 0; - for (int i = 0; i < leafs.length; ++i) - if (((AList) (leafs[i].getUserObject())).getSource() == data) - num += ((AList) (leafs[i].getUserObject())).getItems().length; - - int[] index = new int[num]; - int[] color = new int[num]; - num = 0; - for (int i = 0; i < leafs.length; ++i) - { - if (((AList) (leafs[i].getUserObject())).getSource() == data) - { - int[] items = ((AList) (leafs[i].getUserObject())).getItems(); - int c = getColor(leafs[i]); - for (int j = 0; j < items.length; ++j) - { - index[num] = items[j]; - color[num] = c; - num++; - } - } - } - int[][] temp = new int[2][]; - temp[0] = index; - temp[1] = color; - return temp; - } - - public int getColorOfOthers() - { - return getColor(others); - } - - public boolean[] getSelection(AData data) - { - boolean[] selected = new boolean[data.getNumData()]; - - TreePath[] paths = getSelectionPaths(); - if (paths != null) - { - for (int i = 0; i < paths.length; ++i) - { - Enumeration nodes = ((DefaultMutableTreeNode) (paths[i].getLastPathComponent())).breadthFirstEnumeration(); - while (nodes.hasMoreElements()) - { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) (nodes.nextElement()); - if (!node.getAllowsChildren()) - { - AList a = (AList) (node.getUserObject()); - if (a.getSource() == data) - { - int[] items = a.getItems(); - for (int j = 0; j < items.length; ++j) - selected[items[j]] = true; - } - } - } - } - } - return selected; - } - - public AList[] getChildren(DefaultMutableTreeNode node) - { - java.util.List children = new ArrayList(); - - Object o = node.getUserObject(); - if (o instanceof AList) - { - children.add(o); - } - else - { - // process the child nodes recursively - for (int i = 0; i < node.getChildCount(); ++i) - { - AList[] grandChildren = getChildren((DefaultMutableTreeNode) node.getChildAt(i)); - for (int j = 0; j < grandChildren.length; ++j) - { - children.add(grandChildren[j]); - } - } - } - return (AList[]) (children.toArray(new AList[children.size()])); - } - - public static Collection uniqueExpansion(Collection s) - { - Collection c = new HashSet(); - for (Iterator i = s.iterator(); i.hasNext();) - { - Enumeration en = ((DefaultMutableTreeNode) (i.next())).depthFirstEnumeration(); - while (en.hasMoreElements()) - { - c.add(en.nextElement()); - } - } - return c; - } - - class ColorPanel extends JPanel - { - ColorPanel() - { - Color[] colorMap = AColorMap.getColors(); - ActionListener a = new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - int colorIndex = ((AColorIcon) (((JButton) (e.getSource())).getIcon())).getColorIndex(); - TreePath[] sel = getSelectionPaths(); - if (sel != null) - { - for (int i = 0; i < sel.length; ++i) - nodeColors.put(sel[i].getLastPathComponent(), new Integer(colorIndex)); - } - listManager.repaint(); - ACanvas.getCanvas().repaintAllFromScratch(); - } - }; - Box b = Box.createVerticalBox(); - for (int i = 0; i < colorMap.length; i++) - { - JButton l = new JButton(new AColorIcon(i, 13, 13)); - l.setMargin(new Insets(0, 0, 0, 0)); - l.setBorder(null); - b.add(l); - b.add(Box.createVerticalStrut(3)); - l.addActionListener(a); - } - b.add(Box.createVerticalStrut(6)); - JButton l = new JButton(new AColorIcon(AColorMap.NO_COLOR, 13, 13)); - l.setMargin(new Insets(0, 0, 0, 0)); - l.setBorder(null); - l.setToolTipText("No specified color"); - b.add(l); - b.add(Box.createVerticalStrut(3)); - l.addActionListener(a); - l = new JButton(new AColorIcon(AColorMap.INVISIBLE, 13, 13)); - l.setMargin(new Insets(0, 0, 0, 0)); - l.setBorder(null); - l.setToolTipText("Invisible"); - b.add(l); - l.addActionListener(a); - super.add(b); - } - } - - - - public ArrayList getLastDrawn() - { - ArrayList result = new ArrayList(); - - Enumeration myenum = lastDrawn.children(); - while(myenum.hasMoreElements()) - { - Object o = ((DefaultMutableTreeNode) (myenum.nextElement())).getUserObject(); - if(o instanceof AList) - { - if(((AList) o).getItems().length > 0) - { - result.add(o); - } - } - } - - return result; - } - - - - public void copyLastDrawn() - { - - DefaultMutableTreeNode copy = new DefaultMutableTreeNode("List " + numLists++); - Enumeration myenum = lastDrawn.children(); - while (myenum.hasMoreElements()) - { - Object o = ((DefaultMutableTreeNode) (myenum.nextElement())).getUserObject(); - if (o instanceof AList) - { - if (((AList) o).getItems().length > 0) - copy.add(new DefaultMutableTreeNode(o, false)); - } - } - dtm.insertNodeInto(copy, root, 0); - setSelectionPath(new TreePath(dtm.getPathToRoot(copy))); - // expandPath(getPathForLocation(e.getX(), e.getY())); - } - - public void mouseExited(MouseEvent e) - { - update(e); - } // DnD - - public void mouseClicked(MouseEvent e) - {} - - public void mouseEntered(MouseEvent e) - { - update(e); - } // DnD - - - public void mousePressed(MouseEvent e) - { - // source of DnD - source = getNode(e.getPoint()); - // set picked object to selection if possible - TreePath tp = getPathForLocation(e.getPoint().x, e.getPoint().y); - if (tp != null) - { - - DefaultMutableTreeNode node = (DefaultMutableTreeNode) (tp.getLastPathComponent()); - if (!node.getAllowsChildren()) - { - AList a = (AList) (node.getUserObject()); - if (a.getItems().length == 1) - APickingGraphics2D.setPicked(a.getSource(), a.getItems()[0]); - } - } - // special for right button - if (!AUtilities.isRightMouseButton(e)) - return; - // make right button act on selection just as left button does - if (tp != null) - { - if (e.isControlDown()) - { - addSelectionPath(tp); - } - else - { - setSelectionPath(tp); - } - } - // pop up menu on right click - TreePath[] sel = getSelectionPaths(); - Collection selection = new ArrayList(sel.length); - for (int i = 0; i < sel.length; ++i) - selection.add(sel[i].getLastPathComponent()); - - JPopupMenu popup = new JPopupMenu(); - Action temp; - temp = expand(selection); - if (temp != null) - popup.add(temp); - temp = remove(selection); - if (temp != null) - popup.add(temp); - temp = reset(selection); - if (temp != null) - popup.add(temp); - temp = rename(selection); - if (temp != null) - popup.add(temp); - temp = newParent(selection); - if (temp != null) - popup.add(temp); - temp = newChild(selection); - if (temp != null) - popup.add(temp); - temp = newSummarize(selection); - if (temp != null) - popup.add(temp); - // gary just remove this for now - - AListProcessor[] listProcessors = eventManager.getCurrentEvent().getData(); - - for (int i = 0; i < listProcessors.length; i++) - { - Action[] actions = listProcessors[i].getActions(selection); - for (int j = 0; j < actions.length; ++j) - { - popup.add(actions[j]); - } - } - - popup.show(e.getComponent(), e.getX(), e.getY()); - - } - - public void mouseMoved(MouseEvent e) - {} - - public void mouseDragged(MouseEvent e) - { - // start of drag - if (!draging) - { - if (source != null && isDragSource(source)) - draging = true; - } - update(e); - } - - public void mouseReleased(MouseEvent e) - { - // DnD event - if (draging && source != null) - { - DefaultMutableTreeNode destination = getNode(e.getPoint()); - if (destination != null && source != destination && destination.getAllowsChildren() && isValidDrag(source, destination)) - { - if (!e.isControlDown() && source != lastDrawn) - { - dtm.removeNodeFromParent(source); - } - if (source == lastDrawn) - { - DefaultMutableTreeNode copy = new DefaultMutableTreeNode("List " + numLists++); - Enumeration myenum = source.children(); - while (myenum.hasMoreElements()) - { - Object o = ((DefaultMutableTreeNode) (myenum.nextElement())).getUserObject(); - copy.add(new DefaultMutableTreeNode(o, false)); - } - dtm.insertNodeInto(copy, destination, 0); - } - else - dtm.insertNodeInto(source, destination, 0); - expandPath(getPathForLocation(e.getX(), e.getY())); - ACanvas.getCanvas().repaintAllFromScratch(); - } - } - draging = false; - source = null; - setCursor(ACursorFactory.getInstance().getDefaultCursor()); - } - - private boolean isDragSource(DefaultMutableTreeNode source) - { - if (source == null || source == root || source == highlight || source == others || source==mass) - return false; - else - return true; - } - - private boolean isValidDrag(DefaultMutableTreeNode source, DefaultMutableTreeNode destination) - { - if (source == null || destination == null) - return false; - if (source == root || source == highlight || source == others || source == mass) - return false; - if (destination == others) - return false; - if (destination == lastDrawn) - return false; - if (destination == highlight) - { - if (source.getAllowsChildren()) - return false; - if (((AList) (source.getUserObject())).getItems().length != 1) - return false; - if (highlight.getChildCount() != 0) - return false; - } - return true; - } - - private void update(MouseEvent e) - { - if (!draging) - return; - Point point = e.getPoint(); - DefaultMutableTreeNode current = getNode(point); - if (current != null && current.getAllowsChildren() && isValidDrag(source, current)) - { - TreePath p = getPathForLocation(point.x, point.y); - setSelectionPath(p); - if (e.isControlDown()) - { - setCursor(DROP_VALID_COPY); - } - else - { - setCursor(ACursorFactory.getInstance().getDragValidCursor()); - } - } - else - { - setCursor(ACursorFactory.getInstance().getDragInvalidCursor()); - } - } - -} - - -class Summarizer -{ - private A4Vector vector = null; - private double etSum = 0; - - - public Summarizer() - { - vector = new A4Vector(); - - } - - - public String getHeader() - { - StringBuffer sb = new StringBuffer(); - sb.append("\nSummary output:\n"); - sb.append(" "); // 18 spaces - sb.append(" PT "); - sb.append(" ET "); - sb.append(" E "); - sb.append(" M "); - sb.append(" MT "); - sb.append("\n"); - - return sb.toString(); - - } - - - public String addAndGetInfo(A4Vector item, String description) - { - vector.add(item); - etSum += item.getEt(); - StringBuffer sb = new StringBuffer(); - sb.append(description); - sb.append("\n"); - sb.append(" "); // 18 spaces - sb.append(String.format("%7.1f",item.getPt())); - sb.append(String.format("%8.1f",item.getEt())); - sb.append(String.format("%7.1f",item.getE())); - sb.append(String.format("%8.3f",item.getMass())); - sb.append(String.format("%8.1f",item.getMt())); - sb.append("\n"); - - return sb.toString(); - } - - public double getTotalEt() - { - return etSum; - } - - public double getTotalPt() - { - return vector.getPt(); - } - - public double getTotalMt() - { - double et = getTotalEt(); - double pt = getTotalPt(); - return Math.sqrt(et*et - pt*pt); - } - - public String getTotalInfo() - { - StringBuffer sb = new StringBuffer(); - sb.append(String.format("%-18s", "Total")); - sb.append(String.format("%7.1f",getTotalPt())); - sb.append(String.format("%8.1f",getTotalEt())); - sb.append(String.format("%7.1f",vector.getE())); - sb.append(String.format("%8.3f",vector.getMass())); - sb.append(String.format("%8.1f",getTotalMt())); - sb.append("\n"); - - return sb.toString(); - - } - -} - diff --git a/graphics/AtlantisJava/src/atlantis/list/AListProcessor.java b/graphics/AtlantisJava/src/atlantis/list/AListProcessor.java deleted file mode 100755 index 6c58995a4a5ba083a087a5dda7241f287a2de0bb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/list/AListProcessor.java +++ /dev/null @@ -1,10 +0,0 @@ -package atlantis.list; - - -import javax.swing.Action; -import java.util.Collection; - - -public interface AListProcessor { - Action[] getActions(Collection nodes); -} diff --git a/graphics/AtlantisJava/src/atlantis/list/package.html b/graphics/AtlantisJava/src/atlantis/list/package.html deleted file mode 100644 index ca84b937bc7735bb468aa8457f9fddcc1c7e8d7a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/list/package.html +++ /dev/null @@ -1,6 +0,0 @@ -<html> -<head></head> -<body> -<p>Implementation of lists which are used to store event datatypes.</p> -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANAnimInterpolate.java b/graphics/AtlantisJava/src/atlantis/nge/ANAnimInterpolate.java deleted file mode 100644 index 90e0284bc683fdcd7d0c2cf2280b8a6416a6702f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANAnimInterpolate.java +++ /dev/null @@ -1,47 +0,0 @@ -package atlantis.nge; - -/** - * - * @author Adam Davison - */ -public class ANAnimInterpolate extends ANAnimSegment { - - private ANAnimVar m_var; - private double m_t1; - private double m_t2; - private double m_v1; - private double m_v2; - private int m_interp; - - public ANAnimInterpolate(ANAnimVar var, double t1, double t2, - double v1, double v2, int interp) { - m_var = var; - m_t1 = t1; - m_t2 = t2; - m_v1 = v1; - m_v2 = v2; - m_interp = interp; - } - - public void evaluate(double now) { - if (now < m_t1) { return; } - switch(m_interp) { - case (ANAnimationManager.INTERP_LINEAR): - //System.out.println("now: " + now + " m_t1: " + m_t1 + " m_t2: " + m_t2); - double t = (now - m_t1) / (m_t2 - m_t1); - //System.out.println("t: " + t); - m_var.setValue((t * (m_v2 - m_v1)) + m_v1); - break; - } - } - - @Override - public double getStart() { - return m_t1; - } - - @Override - public double getEnd() { - return m_t2; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANAnimSegment.java b/graphics/AtlantisJava/src/atlantis/nge/ANAnimSegment.java deleted file mode 100644 index 6678cade19f608e823c8e2ff17d3cd65c5ab76bc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANAnimSegment.java +++ /dev/null @@ -1,13 +0,0 @@ -package atlantis.nge; - -/** - * - * @author Adam Davison - */ -public abstract class ANAnimSegment { - - public abstract double getStart(); - public abstract double getEnd(); - - public abstract void evaluate(double now); -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANAnimSetProjection.java b/graphics/AtlantisJava/src/atlantis/nge/ANAnimSetProjection.java deleted file mode 100644 index 6ca352555ac03741daf3795e631314ccc7d8a2d6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANAnimSetProjection.java +++ /dev/null @@ -1,38 +0,0 @@ -package atlantis.nge; - -/** - * - * @author Adam Davison - */ -public class ANAnimSetProjection extends ANAnimSegment { - private ANFrameManager m_fm; - private ANProjection m_p; - private double m_when; - - public ANAnimSetProjection(ANFrameManager fm, ANProjection p, double when) { - m_fm = fm; - m_p = p; - m_when = when; - } - - @Override - public void evaluate(double now) { - //System.out.println("Evaluate in SetProjection: " + now); - if (now > m_when) { - //System.out.println("CHANGE!"); - m_fm.setCurrentProjection(m_p); - } - } - - @Override - public double getStart() { - return m_when; - } - - @Override - public double getEnd() { - return m_when; - } - - -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANAnimThread.java b/graphics/AtlantisJava/src/atlantis/nge/ANAnimThread.java deleted file mode 100644 index 97185bb17cdebd54d2232e983d2b9a1e0d6c5801..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANAnimThread.java +++ /dev/null @@ -1,67 +0,0 @@ -package atlantis.nge; - -import atlantis.canvas.AWindow; -import atlantis.utils.ALogger; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author Adam Davison - */ -public class ANAnimThread implements Runnable { - - private static ALogger logger = ALogger.getLogger(ANAnimThread.class); - private ANAnimationManager m_am; - private Object m_wait = new Object(); - private AWindow m_w; - - public ANAnimThread(ANAnimationManager am, AWindow w) { - m_am = am; - m_w = w; - } - - public void reschedule() { - //System.out.println("Rescheduling"); - synchronized (m_wait) { - m_wait.notifyAll(); - } - //System.out.println("Rescheduled"); - } - - public void run() { - while (true) { - double wait = m_am.timeToWait(); - - //System.out.println("Told to wait: " + wait); - - double mintime = 1.0 / 100.0; - - if (wait == -1.0) { - // wait forever - synchronized (m_wait) { - try { - m_wait.wait(); - } catch (InterruptedException ex) { - logger.error("Interrupted in sleep", ex); - } - } - } else if (wait > mintime) { - // wait until we're supposed to do something - synchronized (m_wait) { - try { - m_wait.wait((long) (wait * 1000)); - } catch (InterruptedException ex) { - logger.error("Interrupted in sleep", ex); - } - } - } else { - // do something now - //System.out.println("Forcing Repaint!"); - m_w.invalidateQuietly(); - //m_w.getView().paintImmediately(0, 0, m_w.getWidth(), m_w.getHeight()); - m_w.repaint(); - } - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANAnimVar.java b/graphics/AtlantisJava/src/atlantis/nge/ANAnimVar.java deleted file mode 100644 index 2dd5c9c9b3820c3c96b06689abc86eefb2f2c8ae..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANAnimVar.java +++ /dev/null @@ -1,27 +0,0 @@ -package atlantis.nge; - -/** - * A variable which is animatable, pretty much a wrapper around a double... - * - * @author Adam Davison - */ -public class ANAnimVar { - - private double m_val; - - public ANAnimVar(double val) { - m_val = val; - } - - public ANAnimVar() { - m_val = 0.0; - } - - public double getValue() { - return m_val; - } - - public void setValue(double val) { - m_val = val; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANAnimationManager.java b/graphics/AtlantisJava/src/atlantis/nge/ANAnimationManager.java deleted file mode 100644 index a4d7e3fe0c88df0545067be165b30d0240725e5c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANAnimationManager.java +++ /dev/null @@ -1,92 +0,0 @@ -package atlantis.nge; - -import atlantis.canvas.AWindow; -import java.util.ArrayList; -import java.util.Iterator; - -/** - * - * @author Adam Davison - */ -public class ANAnimationManager { - - public static final int INTERP_LINEAR = 1; - private ArrayList<ANAnimSegment> m_segs; - private double m_now; - - private ANAnimThread m_at; - - public ANAnimationManager(AWindow w) { - m_segs = new ArrayList<ANAnimSegment>(); - updateNow(); - m_at = new ANAnimThread(this, w); - new Thread(m_at).start(); - } - - public void updateNow() { - m_now = ((double) System.currentTimeMillis()) / 1000.0; - } - - public void scheduleAnimationAbsolute(ANAnimVar v, double t1, double t2, double v1, double v2) { - m_segs.add(new ANAnimInterpolate(v, t1, t2, v1, v2, INTERP_LINEAR)); - m_at.reschedule(); - } - - public void scheduleAnimation(ANAnimVar v, double t1, double t2, double v1, double v2) { - updateNow(); - scheduleAnimationAbsolute(v, t1 + m_now, t2 + m_now, v1, v2); - } - - public void scheduleProjectionChange(ANFrameManager fm, ANProjection p, double t) { - updateNow(); - m_segs.add(new ANAnimSetProjection(fm, p, t + m_now)); - m_at.reschedule(); - } - - public void animate() { - updateNow(); - - //System.out.println("Animating at: " + m_now); - - Iterator<ANAnimSegment> it = m_segs.listIterator(); - while (it.hasNext()) { - ANAnimSegment seg = it.next(); - //System.out.println("Seg: " + seg + " start: " + seg.getStart() + " end: " + seg.getEnd()); - if (seg.getStart() < m_now) { - seg.evaluate(m_now); - } - if (seg.getEnd() < m_now) { - it.remove(); - } - } - } - - public double timeToWait() { - double next = -1.0; - updateNow(); - - //System.out.println("Wait testing at: " + m_now); - - Iterator<ANAnimSegment> it = m_segs.listIterator(); - while (it.hasNext()) { - ANAnimSegment seg = it.next(); - //System.out.println("Seg: " + seg + " start: " + seg.getStart() + " end: " + seg.getEnd()); - if (seg.getStart() <= next && seg.getEnd() >= next) { - //System.out.println("In segment, returning 0.0"); - return 0.0; - } else if (seg.getStart() >= next) { - double wait = seg.getStart() - m_now; - if (wait < next || next == -1.0) { - if (wait < 0.0) { - wait = 0.0; - } - next = wait; - } - } - } - - return next; - } -} - - diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANCacheToken.java b/graphics/AtlantisJava/src/atlantis/nge/ANCacheToken.java deleted file mode 100644 index 3ec2fe065ac584cbaf7e5784666efe74ab684253..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANCacheToken.java +++ /dev/null @@ -1,11 +0,0 @@ -package atlantis.nge; - -/** - * - * @author Adam Davison - */ -public class ANCacheToken<T> { - - - -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANColor.java b/graphics/AtlantisJava/src/atlantis/nge/ANColor.java deleted file mode 100644 index 87c01543c86add33f888a09d26dcb0184129d89b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANColor.java +++ /dev/null @@ -1,87 +0,0 @@ -package atlantis.nge; - -import atlantis.graphics.colormap.AColorMap; - -import java.awt.Color; - -/** - * A floating point colour class that enforces very little - * - * @author Adam Davison, Mark Stockton - */ -public class ANColor { - - public float r; - public float g; - public float b; - public float a; - - public ANColor(Color c) { - r = ((float) c.getRed()) / 255.0f; - g = ((float) c.getGreen()) / 255.0f; - b = ((float) c.getBlue()) / 255.0f; - a = ((float) c.getAlpha()) / 255.0f; - } - - public ANColor(float _r, float _g, float _b, float _a) { - r = _r; - g = _g; - b = _b; - a = _a; - } - - public ANColor(float _r, float _g, float _b) { - r = _r; - g = _g; - b = _b; - a = 1.0f; - } - - public static ANColor getBGColor() { - return getMapColor(AColorMap.BG); - } - - public static ANColor getMapColor(int index) { - Color bg = AColorMap.getColors()[index]; - - float r = ((float) bg.getRed()) / 255.0f; - float g = ((float) bg.getGreen()) / 255.0f; - float b = ((float) bg.getBlue()) / 255.0f; - - return new ANColor(r, g, b); - } - - public static ANColor getMapColor(int index, float trans) { - Color bg = AColorMap.getColors()[index]; - - float r = ((float) bg.getRed()) / 255.0f; - float g = ((float) bg.getGreen()) / 255.0f; - float b = ((float) bg.getBlue()) / 255.0f; - - return new ANColor(r, g, b, trans); - } - - public void mult(float c) { - r *= c; - g *= c; - b *= c; - if (r < 0.0f) { r = 0.0f; } - if (r > 1.0f) { r = 1.0f; } - if (g < 0.0f) { g = 0.0f; } - if (g > 1.0f) { g = 1.0f; } - if (b < 0.0f) { b = 0.0f; } - if (b > 1.0f) { b = 1.0f; } - } - - public void lighten(float c) { - r = 1.0f - ((1.0f - r)*c); - g = 1.0f - ((1.0f - g)*c); - b = 1.0f - ((1.0f - b)*c); - if (r < 0.0f) { r = 0.0f; } - if (r > 1.0f) { r = 1.0f; } - if (g < 0.0f) { g = 0.0f; } - if (g > 1.0f) { g = 1.0f; } - if (b < 0.0f) { b = 0.0f; } - if (b > 1.0f) { b = 1.0f; } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANFrameManager.java b/graphics/AtlantisJava/src/atlantis/nge/ANFrameManager.java deleted file mode 100644 index adb6cb778c01fd4c1d27cbc9fc0b38a745e4476a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANFrameManager.java +++ /dev/null @@ -1,190 +0,0 @@ -package atlantis.nge; - -import atlantis.canvas.AWindow; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.IntBuffer; -import javax.media.opengl.DebugGL; -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.glu.GLU; - -/** - * Decides which projection should be onscreen and in what state. - * Handles animation, performance and probably all sorts of other things. - * - * @author Adam Davison, Mark Stockton - */ -public class ANFrameManager { - - // Targ is what we're aiming to display but proj is what we're really - // displaying, could be the same but could also be some transition into - // targ - - private ANProjection m_targ; - private ANProjection m_proj; - - private ANAnimationManager m_am; - - public ANFrameManager(AWindow w) { - // Default, if not told anything else construct 3d projection - m_proj = null; - m_am = new ANAnimationManager(w); - - } - - public ANPickResult pick(GLAutoDrawable drawable, int w, int h, int x, int y) { - - if (m_proj == null) { return null; } - - long before = System.nanoTime(); - - GL gl = drawable.getGL(); - gl.glViewport(0, 0, w, h); - - GLU glu = new GLU(); - int maxsize = 100000; - - ByteBuffer bb = ByteBuffer.allocateDirect(4*maxsize); - bb.order(ByteOrder.nativeOrder()); - // FIXME: Reuse this object for performance - IntBuffer ib = bb.asIntBuffer(); - gl.glSelectBuffer(maxsize, ib); - gl.glRenderMode(GL.GL_SELECT); - gl.glMatrixMode(GL.GL_PROJECTION); - int[] viewport = new int[4]; - gl.glLoadIdentity(); - gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0); - y = h - y; - glu.gluPickMatrix(x - 1, y - 1, 3, 3, viewport, 0); - - ANRenderHints rh = new ANRenderHints(); - rh.setPick(true); - rh.setPickHelper(new ANPickHelper(gl)); - - //gl.glPushName(0); - m_proj.display(drawable, w, h, rh); - //gl.glPopName(); - - int hits = gl.glRenderMode(GL.GL_RENDER); - - System.out.println("HITS: " + hits); - ANSelectionList sl = new ANSelectionList(ib); - //System.out.println("FRONT: " + sl.getFrontID()); - int[] front = sl.getFrontID(); - - ANPickResult ret = null; - - if (front != null) { - int id = front[0]; - System.out.println(id); - int data = front[1]; - System.out.println(data); - ANPickHandler ph = rh.getPickHelper().getPickHandler(id); - System.out.println(ph); - if (ph != null) { - ret = ph.getHitInfo(data); - } - } - - long after = System.nanoTime(); - System.out.println("Pick took: " + (after - before) / 1000); - - System.out.println(ret); - return ret; - } - - public void display(GLAutoDrawable drawable, int w, int h) { - System.out.println("Asked to display!"); - - if (m_proj == null) { return; } - - long before = System.nanoTime(); - - GL gl = new DebugGL(drawable.getGL()); - gl.glViewport(0, 0, w, h); - - m_am.animate(); - - m_proj.display(drawable, w, h, new ANRenderHints()); - - long after = System.nanoTime(); - System.out.println("Frame took: " + (after - before) / 1000); - } - - public double timeToWait() { - return m_am.timeToWait(); - } - - public ANProjection getTargetProjection() { - return m_targ; - } - - public ANProjection getCurrentProjection() { - return m_proj; - } - - public void setCurrentProjection(ANProjection proj) { - m_proj = proj; - } - - public void scheduleTransition(ANProjection p) { - //(new Exception()).printStackTrace(); - - m_targ = p; - - if (m_proj == null || m_proj == p) { m_proj = p; return; } - - //System.out.println(m_proj); - //System.out.println(p); - - if (m_proj instanceof ANLinearProjection && - p instanceof ANLinearProjection) { - - //System.out.println("HERE!"); - - ANLinearTransition trans = new ANLinearTransition( - (ANLinearProjection) m_proj, - (ANLinearProjection) p); - - setCurrentProjection(trans); - - double length = 1.0; - - m_am.scheduleAnimation(trans.getTransformTimeVar(), 0.0, length, 0.0, 1.0); - m_am.scheduleAnimation(trans.getFadeTimeVar(), 0.0, length, 0.0, 1.0); - m_am.scheduleProjectionChange(this, p, length); - - } else { - m_proj = p; - } - } - - public void checkProjectionYX() { - //System.out.println("checkProjectionYX: m_proj: " + m_proj); - if (!(m_targ instanceof ANProjectionYX)) { - //System.out.println("RECREATING"); - scheduleTransition(new ANProjectionYX()); - } - } - - public void checkProjection3D() { - if (!(m_targ instanceof ANProjection3D)) { - scheduleTransition(new ANProjection3D()); - } - } - - public ANProjectionPhysics checkProjectionPhysics() { - if (!(m_targ instanceof ANProjectionPhysics)) { - ANProjectionPhysics pp = new ANProjectionPhysics(); - scheduleTransition(pp); - return pp; - } else { - return (ANProjectionPhysics)(m_targ); - } - } - - public ANAnimationManager getAnimationManager() { - return m_am; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANGlobalFlags.java b/graphics/AtlantisJava/src/atlantis/nge/ANGlobalFlags.java deleted file mode 100644 index 5a96788eafa1abc75e91b4e080aad18742eae1fc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANGlobalFlags.java +++ /dev/null @@ -1,17 +0,0 @@ -package atlantis.nge; - -/** - * This class contains some static final boolean flags that can be used to - * control behaviour such as debugging and sanity checking. - * - * The java compiler guarantees that code enclosed in an if(var) where var - * is a final and false boolean is entirely excluded from your class file - * - * This is better than just using logger.debug() here because we don't want - * to do the debug level testing inside the fast rendering path - * - * @author Adam Davison - */ -public class ANGlobalFlags { - -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANLinearProjection.java b/graphics/AtlantisJava/src/atlantis/nge/ANLinearProjection.java deleted file mode 100644 index c3cda8cb6275aa2f61c456344be92306981730e8..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANLinearProjection.java +++ /dev/null @@ -1,229 +0,0 @@ -package atlantis.nge; - -import atlantis.nge.object.data.ANObjectDataJet; -import atlantis.nge.object.geometry.ANObjectGeomMuon; -import atlantis.nge.object.geometry.ANObjectGeomCalo; -import atlantis.nge.object.data.ANObjectDataCell; -import atlantis.data.ACalorimeterData; -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.data.AJetData; -import atlantis.data.ALArData; -import atlantis.geometry.AAtlasDetector; -import atlantis.geometry.ABarrelCalorimeterDetector; -import atlantis.geometry.ABoxDetector; -import atlantis.geometry.ACalorimeterDetector; -import atlantis.geometry.ADetector; -import atlantis.geometry.ADetectors; -import atlantis.geometry.AEndcapCalorimeterDetector; -import atlantis.geometry.AEndcapCryostatDetector; -import atlantis.utils.AMath; - -import java.util.ArrayList; - -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; - -/** - * This class represents projections which are a linear transformation on - * 3d space. These are easy to handle for a variety of reasons - * - * @author Adam Davison, Mark Stockton - */ -public abstract class ANLinearProjection extends ANProjection { - - // DEPRECATED - public ANObjectGeomMuon m_ogm;//muon - public ANObjectGeomCalo m_ogc;//calo barrel - public ANObjectGeomCalo m_ogetp;//extended tile +z - public ANObjectGeomCalo m_ogtsp;//mbts +z - public ANObjectGeomCalo m_ogecp;//endcap +z - public ANObjectGeomCalo m_ogetm;//extended tile -z - public ANObjectGeomCalo m_ogtsm;//mbts -z - public ANObjectGeomCalo m_ogecm;//endcap -z - - public ANObjectDataJet m_jet;//jets - public ANObjectDataCell m_lar;//lar cells - - private static AEventManager eventManager = AEventManager.instance(); - - /** - * The contract of applyLinearTransform is that you can assume - * the matrix stack is in an identity state and you should always apply - * the transformation in a relative manner, ie glTransform, glRotate - * nothing like glLoadMatrix or glLoadIdentity - * - * @param drawable - */ - public abstract void applyLinearTransform(GLAutoDrawable drawable, int w, int h); - - public abstract void drawScene(GLAutoDrawable drawable, ANRenderHints hint); - - // TODO: A lot of this function should probably be broken up into more - // subclasses to allow this functionality to be selected more - // granularly - @Override - public final void display(GLAutoDrawable drawable, int w, int h, ANRenderHints hint) { - GL gl = drawable.getGL(); - gl.glMatrixMode(GL.GL_MODELVIEW); - gl.glLoadIdentity(); - - gl.glMatrixMode(GL.GL_PROJECTION); - - // This is a bit of a hack maybe... - if (!hint.getPick()) { - gl.glLoadIdentity(); - } - - gl.glEnable(gl.GL_BLEND); - gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA); - gl.glEnable(GL.GL_DEPTH_TEST); - - gl.glPolygonOffset(2.0f, 1.0f); - gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); - - applyLinearTransform(drawable, w, h); - - ANColor bg = ANColor.getBGColor(); - - gl.glClearColor(bg.r, bg.g, bg.b, 1.0f); - gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); - - drawScene(drawable, hint); - } // Some function that calls applyLinearTransform and extracts the matrix - // is needed for the transitions but that can come later... - - - // DEPRECATED - to be replaced shortly by ANObjectGenerator - public final void createGeometry(){ - ArrayList<ABoxDetector> m_boxes = new ArrayList<ABoxDetector>(); - ArrayList<ACalorimeterDetector> m_calo = new ArrayList<ACalorimeterDetector>(); - ArrayList<ACalorimeterDetector> m_extt = new ArrayList<ACalorimeterDetector>(); - ArrayList<ACalorimeterDetector> m_mbts = new ArrayList<ACalorimeterDetector>(); - ArrayList<ACalorimeterDetector> m_endc = new ArrayList<ACalorimeterDetector>(); - - ADetectors[] ds = AAtlasDetector.getDetector().getDetectors(); - for (int i = 0; i < ds.length; i++) { - ADetector[] d = ds[i].getDetectors(); - for (int j = 0; j < d.length; j++) { - if (d[j] instanceof ABoxDetector) { - ABoxDetector bd = (ABoxDetector) d[j]; - //TODO temporary code to show cut away detector - //if((bd.getPhi()>1.2 && bd.getPhi()<5.1) || !ACanvas.getCanvas().getPaintingWindow().getProjection().getName().equals("N3D")) - m_boxes.add(bd); - }else if (d[j] instanceof ABarrelCalorimeterDetector) { - ACalorimeterDetector cd = (ACalorimeterDetector) d[j]; - //extended tile only has one end in geom file and not relicated like others - if(d[j].getName().equals("Extended TILE")){ - m_extt.add(cd); - }else{ - m_calo.add(cd); - } - - } else if (d[j] instanceof AEndcapCryostatDetector) { - //adds MBTS but only has one end in geom file - AEndcapCryostatDetector ecd = (AEndcapCryostatDetector) d[j]; - m_mbts.add(ecd); - } else if (d[j] instanceof AEndcapCalorimeterDetector) { - //adds LAr endcap + HEC but only has one end in geom file - AEndcapCalorimeterDetector ecd = (AEndcapCalorimeterDetector) d[j]; - m_endc.add(ecd); - - } - - } - } - - m_ogm = new ANObjectGeomMuon(m_boxes); - m_ogc = new ANObjectGeomCalo(m_calo, 4, false); - m_ogetp = new ANObjectGeomCalo(m_extt, 4, false); - m_ogtsp = new ANObjectGeomCalo(m_mbts, 1, false); - m_ogecp = new ANObjectGeomCalo(m_endc, 1, false); - m_ogetm = new ANObjectGeomCalo(m_extt, 4, true); - m_ogtsm = new ANObjectGeomCalo(m_mbts, 1, true); - m_ogecm = new ANObjectGeomCalo(m_endc, 1, true); - - - } - - // DEPRECATED - to be replaced shortly by ANObjectGenerator - public final void createData(){ - - AEvent ev = eventManager.getCurrentEvent(); - AJetData ajd = ev.getJetData(); - ajd.makeDrawList(); - m_jet = new ANObjectDataJet(ajd); - - ALArData ald = ev.getLArData(); - ald.makeDrawList(); - m_lar = new ANObjectDataCell(ald); - - } - - // DEPRECATED - to be replaced shortly by ANObjectGenerator - public final void createGeometry(float phi, float eta, float dr){ - ArrayList<ABoxDetector> m_boxes = new ArrayList<ABoxDetector>(); - ArrayList<ACalorimeterDetector> m_calo = new ArrayList<ACalorimeterDetector>(); - ArrayList<ACalorimeterDetector> m_extt = new ArrayList<ACalorimeterDetector>(); - ArrayList<ACalorimeterDetector> m_mbts = new ArrayList<ACalorimeterDetector>(); - ArrayList<ACalorimeterDetector> m_endc = new ArrayList<ACalorimeterDetector>(); - - - ADetectors[] ds = AAtlasDetector.getDetector().getDetectors(); - for (int i = 0; i < ds.length; i++) { - ADetector[] d = ds[i].getDetectors(); - for (int j = 0; j < d.length; j++) { - if (d[j] instanceof ABoxDetector) { - ABoxDetector bd = (ABoxDetector) d[j]; - //code to show cut away detector - float etabd = (float) AMath.etaAbs(bd.getZMin(), bd.getRMin()); - if(AMath.deltaR(phi,eta,(float)bd.getPhi(),etabd)<dr) - m_boxes.add(bd); - }else if (d[j] instanceof ABarrelCalorimeterDetector) { - ACalorimeterDetector cd = (ACalorimeterDetector) d[j]; - //extended tile only has one end in geom file and not relicated like others - if(d[j].getName().equals("Extended TILE")){ - m_extt.add(cd); - }else{ - m_calo.add(cd); - } - - } else if (d[j] instanceof AEndcapCryostatDetector) { - //adds MBTS but only has one end in geom file - AEndcapCryostatDetector ecd = (AEndcapCryostatDetector) d[j]; - m_mbts.add(ecd); - } else if (d[j] instanceof AEndcapCalorimeterDetector) { - //adds LAr endcap + HEC but only has one end in geom file - AEndcapCalorimeterDetector ecd = (AEndcapCalorimeterDetector) d[j]; - m_endc.add(ecd); - - } - - } - } - - m_ogm = new ANObjectGeomMuon(m_boxes); - m_ogc = new ANObjectGeomCalo(m_calo, 4, false); - m_ogetp = new ANObjectGeomCalo(m_extt, 4, false); - m_ogtsp = new ANObjectGeomCalo(m_mbts, 1, false); - m_ogecp = new ANObjectGeomCalo(m_endc, 1, false); - m_ogetm = new ANObjectGeomCalo(m_extt, 4, true); - m_ogtsm = new ANObjectGeomCalo(m_mbts, 1, true); - m_ogecm = new ANObjectGeomCalo(m_endc, 1, true); - - - } - - public final void createData(float phi, float eta, float dr){ - - AEvent ev = eventManager.getCurrentEvent(); - AJetData ajd = ev.getJetData(); - ajd.makeDrawList(); - m_jet = new ANObjectDataJet(ajd, phi, eta, dr); - - ALArData ald = ev.getLArData(); - ald.makeDrawList(); - m_lar = new ANObjectDataCell((ACalorimeterData)ald, phi, eta, dr); - - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANLinearTransition.java b/graphics/AtlantisJava/src/atlantis/nge/ANLinearTransition.java deleted file mode 100644 index 918caf427d84710e316dafab966e56ee40f87a5b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANLinearTransition.java +++ /dev/null @@ -1,140 +0,0 @@ -package atlantis.nge; - -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; - -/** - * - * @author Adam Davison - */ -public class ANLinearTransition extends ANLinearProjection { - - private ANLinearProjection m_a; - private ANLinearProjection m_b; - private ANAnimVar m_vtttime = new ANAnimVar(); - private ANAnimVar m_fadetime = new ANAnimVar(); - - public ANLinearTransition(ANLinearProjection a, ANLinearProjection b) { - m_a = a; - m_b = b; - } - - public ANAnimVar getTransformTimeVar() { return m_vtttime; } - public ANAnimVar getFadeTimeVar() { return m_fadetime; } - - @Override - public void applyLinearTransform(GLAutoDrawable drawable, int w, int h) { - GL gl = drawable.getGL(); - - double vtttime = m_vtttime.getValue(); - - if (vtttime < 0.0) { vtttime = 0.0; } - - if (vtttime <= 0.0f) { - m_a.applyLinearTransform(drawable, w, h); - } else if (vtttime >= 1.0f) { - m_b.applyLinearTransform(drawable, w, h); - } else { - - float[] ma = new float[16]; - float[] mb = new float[16]; - - // TODO: Make this whole thing better - // Maybe this is ok. If getFloatv is problematic we may have trouble - // but generally this allows us to transform between moving projections! - gl.glMatrixMode(GL.GL_PROJECTION); - gl.glPushMatrix(); - gl.glLoadIdentity(); - m_a.applyLinearTransform(drawable, w, h); - gl.glGetFloatv(GL.GL_PROJECTION_MATRIX, ma, 0); - gl.glLoadIdentity(); - m_b.applyLinearTransform(drawable, w, h); - gl.glGetFloatv(GL.GL_PROJECTION_MATRIX, mb, 0); - gl.glPopMatrix(); - - float[] matrix = new float[16]; - - // Scaling the matrix linearly means that x/w moves in a highly - // non-linear way, especially where large scale changes in w are - // involved, try to compensate this by using a highly non-linear - // time coordinate - - // Final solution involves inverting the formula for the transformation - // to calculate what time coordinate should be applied to ensure - // linear motion of a test eye coordinate between it's clip - // coordinates under transformation by ma and mb - // Should document the maths at some point for sanity... - - // Operating on normalised time here, length 1 - double[] zerosums = new double[4]; - double[] gradsums = new double[4]; - - for (int y = 0; y < 4; y++) { - zerosums[y] = 0.0f; - gradsums[y] = 0.0f; - for (int x = 0; x < 4; x++) { - zerosums[y] += ma[(4 * x) + y]; - gradsums[y] += mb[(4 * x) + y] - ma[(4 * x) + y]; - } - } - - double w0 = ma[3] + ma[7] + ma[11] + ma[15]; - double wT = mb[3] + mb[7] + mb[11] + mb[15]; - - double[] timeest = new double[3]; - for (int i = 0; i < 3; i++) { - // Target value of coord/w - double c0w = (ma[0 + i] + ma[4 + i] + ma[8 + i] + ma[12 + i]) / w0; - double cTw = (mb[0 + i] + mb[4 + i] + mb[8 + i] + mb[12 + i]) / wT; - // Beta is the target value for this component, this could be - // a non-linear function for smoother transitions - // i.e. something with 0 first derivative at times 0 and 1 - double beta = (c0w + ((cTw - c0w) * vtttime)); - timeest[i] = (zerosums[i] - zerosums[3] * beta) / (gradsums[3] * beta - gradsums[i]); - } - - // They seem to tend to scale similarly at the moment but this - // may fall apart for some really wierd transformation matrix... - // ... just take the mean for now and look out for problems - double meantime = (timeest[0] + timeest[1] + timeest[2]) / 3.0; - - for (int i = 0; i < 16; i++) { - matrix[i] = (float) (ma[i] + ((mb[i] - ma[i]) * meantime)); - } - - gl.glMultMatrixf(matrix, 0); - } - } - - @Override - public void drawScene(GLAutoDrawable drawable, ANRenderHints hint) { - GL gl = drawable.getGL(); - - - - if (m_fadetime.getValue() > 0.0) { - m_a.drawScene(drawable, hint); - - gl.glMatrixMode(GL.GL_PROJECTION); - gl.glPushMatrix(); - gl.glLoadIdentity(); - gl.glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); - ANColor bgc = ANColor.getBGColor(); - gl.glColor4f(bgc.r, bgc.g, bgc.b, (float)(m_fadetime.getValue())); - gl.glDisable(GL.GL_DEPTH_TEST); - gl.glBegin(GL.GL_QUADS); - gl.glVertex3f(-1.0f, -1.0f, 0.0f); - gl.glVertex3f(1.0f, -1.0f, 0.0f); - gl.glVertex3f(1.0f, 1.0f, 0.0f); - gl.glVertex3f(-1.0f, 1.0f, 0.0f); - gl.glEnd(); - // FIXME: Don't always want this back on here potentially - gl.glEnable(GL.GL_DEPTH_TEST); - gl.glPopMatrix(); - gl.glClear(GL.GL_DEPTH_BUFFER_BIT); - } - - m_b.drawScene(drawable, hint); - - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANManager.java b/graphics/AtlantisJava/src/atlantis/nge/ANManager.java deleted file mode 100644 index 0b7350c29e4ef45e1eb2c44d86b5ac2cf9464c7f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANManager.java +++ /dev/null @@ -1,122 +0,0 @@ -package atlantis.nge; - -import atlantis.canvas.AWindow; -import atlantis.utils.ALogger; -import java.util.Hashtable; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLPbuffer; - -/** - * This class keeps handy resources for you... - * - * @author Adam Davison - */ -public class ANManager implements GLEventListener { - - private static ALogger logger = ALogger.getLogger(ANManager.class); - private static ANManager manager = new ANManager(); - - public static ANManager getManager() { - return manager; - } - private Hashtable<AWindow, ANFrameManager> m_fms = null; - private GLPbuffer m_buf = null; - private GLEventListener m_gll; - - public ANManager() { - m_fms = new Hashtable<AWindow, ANFrameManager>(); - } - - public ANFrameManager getFrameManager(AWindow w) { - if (w == null) { - return null; - } - ANFrameManager fm = m_fms.get(w); - if (fm == null) { - fm = new ANFrameManager(w); - m_fms.put(w, fm); - } - return fm; - } - - public static int getNextPower2(int v) { - int p = 1; - for (int i = 0; i < 16; i++) { - p *= 2; - if (p >= v) { - return p; - } - } - - logger.warn("Returning non power of 2 buffer size!"); - return v; - } - - public void requestBufferDraw(int w, int h, GLEventListener gll) { - - if (m_buf != null && m_buf.getWidth() >= w && m_buf.getHeight() >= h) { - //System.out.println("BUFFER OK"); - // Do nothing - } else { - //System.out.println("BUFFER CREATE/REPLACE"); - if (m_buf != null) { - m_buf.destroy(); - } - - GLCapabilities pbcap = new GLCapabilities(); - pbcap.setHardwareAccelerated(true); - pbcap.setSampleBuffers(true); - pbcap.setNumSamples(4); - //pbcap.setPbufferRenderToTexture(true); - //pbcap.setDoubleBuffered(false); - - //logger.info("w: " + m_w + " 2: " + getNextPower2(m_w)); - - m_buf = GLDrawableFactory.getFactory().createGLPbuffer(pbcap, null, - getNextPower2(w), getNextPower2(h), null); - - if (m_buf == null) { - logger.error("Got null when trying to create pbuffer!"); - return; - } - - m_buf.addGLEventListener(this); - - logger.info("Created pbuffer w: " + m_buf.getWidth() + " h: " + m_buf.getHeight()); - - if (m_buf.getChosenGLCapabilities() == null) { - logger.warn("Your implementation returns null for pbuffer capabilities..."); - } else { - logger.info("Pbuffer hardware accelleration: " + m_buf.getChosenGLCapabilities().getHardwareAccelerated()); - } - } - - // Set up events to go back to the projection - m_gll = gll; - - //System.out.println("CALLING DISPLAY"); - m_buf.display(); - } - - public void init(GLAutoDrawable arg0) { - m_gll.init(arg0); - } - - public void display(GLAutoDrawable arg0) { - //System.out.println("HIT DISPLAY CALLBACK"); - m_gll.display(arg0); - } - - public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) { - m_gll.reshape(arg0, arg1, arg2, arg3, arg4); - } - - public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) { - m_gll.displayChanged(arg0, arg1, arg2); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANObjectGenerator.java b/graphics/AtlantisJava/src/atlantis/nge/ANObjectGenerator.java deleted file mode 100644 index 260518afd2209c0cf901b459f159ff692d45b9a1..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANObjectGenerator.java +++ /dev/null @@ -1,151 +0,0 @@ -package atlantis.nge; - -import atlantis.event.AEventManager; -import atlantis.data.ACalorimeterData; -import atlantis.event.AEvent; -import atlantis.data.AJetData; -import atlantis.data.ATrackData; -import atlantis.geometry.ABoxDetector; -import atlantis.nge.object.ANObject; -import atlantis.nge.object.ANObjectList; -import atlantis.nge.object.data.ANObjectPointing; -import atlantis.nge.object.data.ANObjectTracks; -import atlantis.nge.object.geometry.ANObjectGeomMuon; -import atlantis.utils.ALogger; -import atlantis.utils.AMath; -import java.nio.IntBuffer; -import java.util.ArrayList; -import java.util.List; - -/** - * These things get arrays of ANObjects out of the Atlantis data store - * - * The general idea is to separate the selection of objects from the way - * they're represented in the projection. But I suspect that'll break down - * - * For now it's a static object but if we ever want to unstatic it then it's - * only accessible via getGenerator() so it should be easy to refactor - * - * A lot of the functionality should one day be pushed back into the detector - * objects themselves - * - * @author Adam Davison - */ -public class ANObjectGenerator { - - private static ALogger logger = ALogger.getLogger(ANObjectGenerator.class); - private static AEventManager eventManager = AEventManager.instance(); - - private static ANObjectGenerator thegenerator = new ANObjectGenerator(); - - private ANObjectGenerator() { - } - - public static ANObjectGenerator getGenerator() { - return thegenerator; - } - - public ANObject getGeometryMuon() { - return new ANObjectGeomMuon(ANTerribleHacks.getMuonDetectors()); - } - - // Ideally change layout of detector stuff so this can be more generic - // not like one search per type, since basically everything has eta/phi - public ANObject getGeometryMuon(float phi, float eta, float dr) { - ArrayList<ABoxDetector> boxes = ANTerribleHacks.getMuonDetectors(); - ArrayList<ABoxDetector> hits = new ArrayList<ABoxDetector>(); - - for (int i = 0; i < boxes.size(); i++) { - ABoxDetector bd = boxes.get(i); - // TODO - This formula is wrong, it's only checking one corner - float etabd = (float) AMath.etaAbs(bd.getZMin(), bd.getRMin()); - if (AMath.deltaR(phi, eta, (float) bd.getPhi(), etabd) < dr) { - hits.add(bd); - } - } - - return new ANObjectGeomMuon(hits); - } - - public ANObject getDataCaloForJet(int j, String key) { - - ANObjectList ol = new ANObjectList(); - - AEvent ev = eventManager.getCurrentEvent(); - AJetData jd = ev.getJetData(); - String assockey = jd.getFullName(); - int[][] assoc = ev.getAssociationManager().get(assockey, key); - if (assoc == null) { return ol; } - if (assoc[j] == null) { return ol; } - int[] dl = new int[assoc[j].length]; - List calolist = ev.getCalorimeters(); - ACalorimeterData calo = null; - for (int i = 0; i < calolist.size(); i++) { - ACalorimeterData tc = (ACalorimeterData)(calolist.get(i)); - if (tc.getName().equals(key)) { - calo = tc; - } - } - if (calo == null) { - logger.error("Requested unavailable calo key!"); - return ol; - } - - calo.makeDrawList(); - int[] calodl = calo.getDrawList(); - - IntBuffer ib = IntBuffer.allocate(assoc[j].length); - for (int i = 0; i < assoc[j].length; i++) { - int id = assoc[j][i]; - int index = calo.getIndexFromId(id); - boolean found = false; - for (int d = 0; d < calo.getNumDraw(); d++) { - if (calodl[d] == index) { - found = true; - } - } - if (found) { - ib.put(index); - } - } - - ol.addObject(new ANObjectPointing(calo, ib.array(), ib.position(), true)); - ol.addObject(new ANObjectPointing(calo, ib.array(), ib.position(), false)); - - return ol; - } - - public ANObject getInDetTracksForJet(int j) { - AEvent ev = eventManager.getCurrentEvent(); - AJetData jd = ev.getJetData(); - int jetid = jd.getIdFromIndex(j); - ATrackData tracks = ev.getTrackData("InDetTrack"); - int[] trackdl = tracks.getDrawList(); - String jetassockey = jd.getFullName(); - String trackassockey = tracks.getName() + tracks.getStoreGateKey(); - int[][] assoc = ev.getAssociationManager().get(trackassockey, jetassockey); - - IntBuffer ib = IntBuffer.allocate(assoc.length); - for (int i = 0; i < assoc.length; i++) { - for (int s = 0; s < assoc[i].length; s++) { - if (assoc[i][s] == jetid) { - boolean display = false; - for (int d = 0; d < trackdl.length; d++) { - if (trackdl[d] == i) { - display = true; - } - } - if (display) {ib.put(i);} - } - } - } - - return new ANObjectTracks(tracks, ib.array()); - } - - public ANObject getInDetTracks() { - AEvent ev = eventManager.getCurrentEvent(); - ATrackData td = ev.getTrackData("InDetTrack"); - return new ANObjectTracks(td); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANPickDrawer.java b/graphics/AtlantisJava/src/atlantis/nge/ANPickDrawer.java deleted file mode 100644 index 938f0a4f37077a8efbe3654c14d58e06845350dc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANPickDrawer.java +++ /dev/null @@ -1,59 +0,0 @@ -package atlantis.nge; - -import atlantis.canvas.AWindow; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLEventListener; - -/** - * - * @author Adam Davison - */ -public class ANPickDrawer implements GLEventListener { - - private AWindow m_window; - private int m_w; - private int m_h; - private int m_x; - private int m_y; - - private ANPickResult m_pr; - private boolean m_pickdone; - - private ANPickListener m_pl; - - public ANPickDrawer(AWindow window, int w, int h, int x, int y, ANPickListener pl) { - m_window = window; - m_w = w; - m_h = h; - m_x = x; - m_y = y; - m_pickdone = false; - m_pl = pl; - } - - public void doPick() { - ANManager.getManager().requestBufferDraw(m_w, m_h, this); - } - - public void init(GLAutoDrawable arg0) { - //throw new UnsupportedOperationException("Not supported yet."); - } - - public void display(GLAutoDrawable arg0) { - m_pr = ANManager.getManager().getFrameManager(m_window).pick(arg0, m_w, m_h, m_x, m_y); - m_pickdone = true; - - if (m_pl != null) { - m_pl.pickCompleted(m_pr); - } - } - - public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) { - //throw new UnsupportedOperationException("Not supported yet."); - } - - public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) { - //throw new UnsupportedOperationException("Not supported yet."); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANPickHandler.java b/graphics/AtlantisJava/src/atlantis/nge/ANPickHandler.java deleted file mode 100644 index baaeb581efe649b4cc1c128e655cbb1b33e603a7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANPickHandler.java +++ /dev/null @@ -1,11 +0,0 @@ -package atlantis.nge; - -/** - * - * @author Adam Davison - */ -public interface ANPickHandler { - - // Turn your 32 bits of data into a result somehow - public ANPickResult getHitInfo(int data); -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANPickHandlerSimple.java b/graphics/AtlantisJava/src/atlantis/nge/ANPickHandlerSimple.java deleted file mode 100644 index 7b1f713e79eb12f3a187b07eee6b090c5fabaeee..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANPickHandlerSimple.java +++ /dev/null @@ -1,19 +0,0 @@ -package atlantis.nge; - -/** - * - * @author Adam Davison - */ -public class ANPickHandlerSimple implements ANPickHandler { - - private String m_name; - - public ANPickHandlerSimple(String name) { - m_name = name; - } - - public ANPickResult getHitInfo(int data) { - return new ANPickResult(m_name); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANPickHelper.java b/graphics/AtlantisJava/src/atlantis/nge/ANPickHelper.java deleted file mode 100644 index e8912acfdf976c95a418ccd388fcb7062275d7f1..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANPickHelper.java +++ /dev/null @@ -1,51 +0,0 @@ -package atlantis.nge; - -import atlantis.nge.object.ANObject; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import javax.media.opengl.GL; - -/** - * - * @author Adam Davison - */ -public class ANPickHelper { - - private ArrayList<ANObject> m_all = new ArrayList<ANObject>(); - private GL m_gl; - - public ANPickHelper(GL gl) { - m_gl = gl; - } - - public ANPickHandler getPickHandler(int id) { - System.out.println(m_all.get(id)); - return m_all.get(id).getPickHandler(); - } - - public int getIndex(ANObject p) { - int id = m_all.indexOf(p); - - if (id == -1) { - m_all.add(p); - id = m_all.indexOf(p); - } - - return id; - } - - // Worry about it being fast much later... - public void startPick(ANObject p, int data) { - startPick(getIndex(p), data); - } - - public void startPick(int pickid, int data) { - m_gl.glPushName(pickid); - m_gl.glPushName(data); - } - - public void endPick() { - m_gl.glPopName(); - m_gl.glPopName(); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANPickListener.java b/graphics/AtlantisJava/src/atlantis/nge/ANPickListener.java deleted file mode 100644 index f7a118143fafc55735cab685523d58376ee08b95..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANPickListener.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package atlantis.nge; - -/** - * - * @author Adam - */ -public interface ANPickListener { - - public void pickCompleted(ANPickResult pr); -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANPickResult.java b/graphics/AtlantisJava/src/atlantis/nge/ANPickResult.java deleted file mode 100644 index d1d05d7efcfa4d170f6b85c88b504e1f8ca1684c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANPickResult.java +++ /dev/null @@ -1,21 +0,0 @@ -package atlantis.nge; - -/** - * This class encapsulates all the information you might want to get out of a - * pick interaction and back into Atlantis - * - * @author Adam Davison - */ -public class ANPickResult { - - private String m_result; - - public ANPickResult(String result) { - m_result = result; - } - - public String getResult() { - return m_result; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANPickResultPrinter.java b/graphics/AtlantisJava/src/atlantis/nge/ANPickResultPrinter.java deleted file mode 100644 index 1b28bd2a45e85adcff8f291f41c8157472ce6cb6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANPickResultPrinter.java +++ /dev/null @@ -1,17 +0,0 @@ -package atlantis.nge; - -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; - -/** - * - * @author Adam Davison - */ -public class ANPickResultPrinter implements ANPickListener { - - public void pickCompleted(ANPickResult pr) { - if (pr != null) { - AOutput.append("Picked: " + pr.getResult() + "\n\n", ALogInterface.PICK); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANProjection.java b/graphics/AtlantisJava/src/atlantis/nge/ANProjection.java deleted file mode 100644 index f49fb76086beab854e0747df783974b1b7e04c9e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANProjection.java +++ /dev/null @@ -1,20 +0,0 @@ -package atlantis.nge; - -import javax.media.opengl.GLAutoDrawable; - -/** - * So this class represents a projection, which in this model is the class - * that decides what objects to draw and how to draw them - * - * It is controlled by the ANFrameManager which tells it what to do. - * - * It shouldn't touch the Atlantis core at all. It gets ANObjects from an - * ANObjectGenerator which is can then render in any order it chooses into a - * renderer it can configure in any way it likes. - * - * @author Adam Davison - */ -public abstract class ANProjection { - - public abstract void display(GLAutoDrawable drawable, int w, int h, ANRenderHints hint); -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANProjection3D.java b/graphics/AtlantisJava/src/atlantis/nge/ANProjection3D.java deleted file mode 100644 index 954f0ead445747dc1e26d811f04662ef1e1961d3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANProjection3D.java +++ /dev/null @@ -1,90 +0,0 @@ -package atlantis.nge; - -import atlantis.nge.object.ANObjectTestAxes; -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; - -import atlantis.parameters.APar; - -/** - * The plain 3d projection, simple for debugging - * - * @author Adam Davison, Mark Stockton - */ -public class ANProjection3D extends ANLinearProjection { - - - private float m_phi; - private float m_elev; - private float m_distance; - private float m_tx, m_ty, m_tz; - - public ANProjection3D() { - - m_phi = -45.0f; - m_elev = 20.0f; - m_distance = 3000.0f; - m_tx = 0.0f; - m_ty = 0.0f; - m_tz = 0.0f; - - // create the object generator here - } - - @Override - public void applyLinearTransform(GLAutoDrawable drawable, int width, int height) { - GL gl = drawable.getGL(); - - float w = 1000.0f; - float h = (w * drawable.getHeight()) / drawable.getWidth(); - - gl.glFrustum(-w, w, -h, h, 1000.0f, 10000.0f); - - // Remember, these are in reverse so essentially: - // 0. GL default, start at 0,0,-1 looking at 0,0,0 - // 1. Spin around y axis to give phi - // 2. Spin around x axis to give elevation - // 3. Pull back to give distance - gl.glTranslatef(0.0f, 0.0f, -m_distance); - gl.glRotatef(m_elev, 1.0f, 0.0f, 0.0f); - gl.glRotatef(m_phi, 0.0f, 1.0f, 0.0f); - gl.glTranslatef(-m_tx, -m_ty, -m_tz); - } - - @Override - public void drawScene(GLAutoDrawable drawable, ANRenderHints hint) { - ANRenderer r = new ANRendererBasic(drawable); - if(APar.instance().get("N3D","Axis").getStatus()){ - ANObjectTestAxes ota = new ANObjectTestAxes(); - ota.render(r, hint); - } - - if (m_ogm == null) { - //m_ogm = new ANObjectGeom(); - createGeometry(); - } - - m_ogm.render(r, hint); - m_ogc.render(r, hint); - m_ogetp.render(r, hint); - m_ogecp.render(r, hint); - m_ogtsp.render(r, hint); - m_ogetm.render(r, hint); - m_ogecm.render(r, hint); - m_ogtsm.render(r, hint); - - createData(); - m_jet.render(r, hint); - - } - - public void dPhi(float phi) { - m_phi += phi; - } - - public void dElev(float elev) { - m_elev += elev; - if (m_elev < -90.0f) { m_elev = -90.0f; } - if (m_elev > 90.0f) { m_elev = 90.0f; } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANProjectionPhysics.java b/graphics/AtlantisJava/src/atlantis/nge/ANProjectionPhysics.java deleted file mode 100644 index 47e95f65d9f9c6bdaba958b3d194879104c0c970..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANProjectionPhysics.java +++ /dev/null @@ -1,181 +0,0 @@ -package atlantis.nge; - -import atlantis.event.AData; -import atlantis.data.AJetData; -import atlantis.nge.object.ANObjectTestAxes; -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; - -import atlantis.parameters.APar; -import atlantis.utils.A3Vector; -import atlantis.utils.AMath; -import javax.media.opengl.glu.GLU; - -/** - * The plain 3d projection, simple for debugging - * - * @author Adam Davison, Mark Stockton - */ -public class ANProjectionPhysics extends ANLinearProjection { - - private float m_focus_phi; - private float m_focus_eta; - private ANAnimVar m_phi; - private ANAnimVar m_elev; - private float m_distance; - private float m_tx, m_ty, m_tz; - private AData m_data; - private int m_data_index; - - public ANProjectionPhysics() { - - m_focus_phi = 0; - m_focus_eta = 0; - m_phi = new ANAnimVar(-45.0); - m_elev = new ANAnimVar(20.0); - m_distance = 2000.0f; - m_tx = 0.0f; - m_ty = 0.0f; - m_tz = 0.0f; - - - // create the object generator here - } - - @Override - public void applyLinearTransform(GLAutoDrawable drawable, int w, int h) { - GL gl = drawable.getGL(); - - //float w = 1000.0f; - //float h = (w * drawable.getHeight()) / drawable.getWidth(); - - //gl.glFrustum(-w, w, -h, h, 1000.0f, 10000.0f); - GLU glu = new GLU(); - glu.gluPerspective(7.0f, w / h, 200.0f, 10000.0f); - - /*gl.glTranslatef(0.0f, 0.0f, -2000.0f); - gl.glRotatef(m_elev, 1.0f, 0.0f, 0.0f); - gl.glRotatef(m_phi, 0.0f, 1.0f, 0.0f); - gl.glRotatef(m_focus_phi, 0.0f, 0.0f, 1.0f); - gl.glRotatef(-theta, 0.0f, 1.0f, 0.0f); - gl.glTranslatef(0.0f, 0.0f, 500.0f); - gl.glRotatef(theta, 0.0f, 1.0f, 0.0f); - gl.glRotatef(-m_focus_phi, 0.0f, 0.0f, 1.0f);*/ - // Remember, these are in reverse so essentially: - // 0. GL default, start at 0,0,-1 looking at 0,0,0 - // 1. Spin around y axis to give phi - // 2. Spin around x axis to give elevation - // 3. Pull back to give distance - gl.glTranslatef(0.0f, 0.0f, -m_distance); - gl.glRotatef((float) m_elev.getValue(), 1.0f, 0.0f, 0.0f); - gl.glRotatef((float) m_phi.getValue(), 0.0f, 1.0f, 0.0f); - gl.glTranslatef(-m_tx, -m_ty, -m_tz); - - - } - - @Override - public void drawScene(GLAutoDrawable drawable, ANRenderHints hint) { - ANRenderer r = new ANRendererBasic(drawable); - - GL gl = drawable.getGL(); - gl.glColor3f(1.0f, 0.0f, 0.0f); - gl.glPointSize(2.0f); - gl.glBegin(GL.GL_POINTS); - gl.glVertex3f(m_tx, m_ty, m_tz); - gl.glEnd(); - - if (APar.instance().get("NPhysics", "Axis").getStatus()) { - ANObjectTestAxes ota = new ANObjectTestAxes(); - ota.render(r, hint); - } - - //ANObjectGenerator.getGenerator() - // .getGeometryMuon(m_focus_phi, m_focus_eta, 1.0f).render(r, pick); - //.getGeometryMuon().render(r, pick); - - ANObjectGenerator.getGenerator().getDataCaloForJet(m_data_index, "LAr").render(r, hint); - ANObjectGenerator.getGenerator().getDataCaloForJet(m_data_index, "TILE").render(r, hint); - ANObjectGenerator.getGenerator().getDataCaloForJet(m_data_index, "HEC").render(r, hint); - //ANObjectGenerator.getGenerator().getDataCaloForJet(m_data_index, "FCAL").render(r, pick); - ANObjectGenerator.getGenerator().getInDetTracksForJet(m_data_index).render(r, hint); - - //createGeometry(m_focus_phi, m_focus_eta, 1.0f); - //m_ogm.render(r, pick); - /*m_ogc.render(r); - m_ogetp.render(r); - m_ogecp.render(r); - m_ogtsp.render(r); - m_ogetm.render(r); - m_ogecm.render(r); - m_ogtsm.render(r);*/ - - //createData(m_focus_phi, m_focus_eta, 2.0f); - //m_jet.render(r, pick); - //m_lar.render(r, pick); - - } - - public void dPhi(float phi) { - m_phi.setValue(m_phi.getValue() + phi); - } - - public void dElev(float elev) { - m_elev.setValue(m_elev.getValue() + elev); - if (m_elev.getValue() < -90.0) { - m_elev.setValue(-90.0); - } - if (m_elev.getValue() > 90.0) { - m_elev.setValue(90.0); - } - } - - public void lookAt(AJetData jd, int jet_index) { - - m_data = jd; - m_data_index = jet_index; - - A3Vector centre = ANTerribleHacks.getCellCentreLArForJet(jet_index); - m_tx = (float) centre.x; - m_ty = (float) centre.y; - m_tz = (float) centre.z; - - float phi = jd.getPhi(jet_index); - float eta = jd.getEta(jet_index); - - m_focus_phi = phi; - m_focus_eta = eta; - - // m_elev is Spin around y axis to give phi - // m_phi is Spin around x axis to give elevation - float theta = (float) (2.0f * Math.atan(Math.exp(eta))); - theta = (float) Math.toDegrees(theta); - phi = (float) Math.toDegrees(phi); - - //produce coords to try to look perpendicular to jet - //needs improving - if (eta < 0) { - eta = -1; - } else { - eta = 1; - } - float x = (float) (m_distance * Math.cos(phi) * Math.sin(theta)); - float z = (float) (m_distance * Math.cos(theta)); - - float rot = (float) Math.toDegrees(Math.atan(z / x)); - - if (theta < 90) { - m_elev.setValue(eta * -theta); - m_phi.setValue(rot); - } else { - m_elev.setValue(eta * (180. - theta)); - m_phi.setValue(rot - 45.); - } - //actually dont need to set melev - m_elev.setValue(0); - - } - - public ANAnimVar getElevVar() { return m_elev; } - public ANAnimVar getPhiVar() { return m_phi; } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANProjectionYX.java b/graphics/AtlantisJava/src/atlantis/nge/ANProjectionYX.java deleted file mode 100644 index 6ca68b65f10fcac5352239fa6a5c86e7d9f52aa6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANProjectionYX.java +++ /dev/null @@ -1,46 +0,0 @@ -package atlantis.nge; - -import atlantis.nge.object.ANObjectTestAxes; -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; - -import atlantis.parameters.APar; - -/** - * - * @author Adam Davison, Mark Stockton - */ -public class ANProjectionYX extends ANLinearProjection { - - - @Override - public void applyLinearTransform(GLAutoDrawable drawable, int w, int h) { - GL gl = drawable.getGL(); - - gl.glMatrixMode(GL.GL_PROJECTION); - float scale = ((float) drawable.getHeight()) / ((float) drawable.getWidth()); - gl.glOrtho(-1500.0f, 1500.0f, -1500.0f * scale, 1500.0f * scale, -100000.0f, 100000.0f); - } - - @Override - public void drawScene(GLAutoDrawable drawable, ANRenderHints hint) { - ANRenderer r = new ANRendererBasic(drawable); - if(APar.instance().get("NYX","Axis").getStatus()){ - ANObjectTestAxes ota = new ANObjectTestAxes(); - ota.render(r, hint); - } - - if (m_ogm == null) { - //m_ogm = new ANObjectGeomMuon(); - createGeometry(); - } - - m_ogm.render(r, hint); - - m_ogc.render(r, hint); - - createData(); - m_jet.render(r, hint); - m_lar.render(r, hint); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANRenderHints.java b/graphics/AtlantisJava/src/atlantis/nge/ANRenderHints.java deleted file mode 100644 index c370fdf3a98a88858b42afcd82b85a52a19bc2c6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANRenderHints.java +++ /dev/null @@ -1,33 +0,0 @@ -package atlantis.nge; - -/** - * - * @author Adam Davison - */ -public class ANRenderHints { - - private boolean pick; - private ANPickHelper pickHelper; - - public ANRenderHints() { - pick = false; - pickHelper = null; - } - - public ANPickHelper getPickHelper() { - return pickHelper; - } - - public void setPickHelper(ANPickHelper pickHelper) { - this.pickHelper = pickHelper; - } - - public boolean getPick() { - return pick; - } - - public void setPick(boolean pick) { - this.pick = pick; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANRenderer.java b/graphics/AtlantisJava/src/atlantis/nge/ANRenderer.java deleted file mode 100644 index 918179874077e496bb43c699271df72ffc26a87c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANRenderer.java +++ /dev/null @@ -1,22 +0,0 @@ -package atlantis.nge; - -/** - * This class provides an interface for drawing into a context of some kind - * essentially it's a drawing API, much like java.awt.Graphics but rather - * tuned towards drawing 3-d objects via OpenGL - * - * @author Adam Davison - */ -public abstract class ANRenderer { - - public abstract void begin(int type); - public abstract void end(); - - public abstract void vertex3f(float x, float y, float z); - public abstract void color3f(float r, float g, float b); - public abstract void color4f(float r, float g, float b, float a); - public abstract void lineWidth(float w); - - public abstract void drawVertices(float[] vert); - -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANRendererBasic.java b/graphics/AtlantisJava/src/atlantis/nge/ANRendererBasic.java deleted file mode 100644 index c0895accf3835409fca4a7124436b7ddce56db21..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANRendererBasic.java +++ /dev/null @@ -1,88 +0,0 @@ -package atlantis.nge; - -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.glu.GLU; - -/** - * - * @author Adam Davison - */ -public class ANRendererBasic extends ANRenderer { - - private GLAutoDrawable m_drawable; - private GL m_gl; - - public ANRendererBasic(GLAutoDrawable drawable) { - m_drawable = drawable; - m_gl = drawable.getGL(); - } - - @Override - public void begin(int type) { - m_gl.glBegin(type); - } - - @Override - public void end() { - m_gl.glEnd(); - } - - @Override - public void drawVertices(float[] vert) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void vertex3f(float x, float y, float z) { - // if (m_btesting) { - // doBoundTest(x, y, z); - // } - - m_gl.glVertex3f(x, y, z); - } - - @Override - public void color3f(float r, float g, float b) { - m_gl.glColor3f(r, g, b); - } - - @Override - public void lineWidth(float w) { - m_gl.glLineWidth(w); - } - - @Override - public void color4f(float r, float g, float b, float a) { - m_gl.glColor4f(r, g, b, a); - } - -/* private float[] m_tmat = new float[16]; - private float m_minx; - private float m_maxx; - private float m_miny; - private float m_maxy; - - private boolean m_btesting = false; - - public void beginBoundsTest() { - // This function assumes no new transformations take place - // So bear that in mind... - - m_gl.glGetFloatv(GL.GL_MODELVIEW_MATRIX, m_tmat, 0); - m_minx = Float.MAX_VALUE; - m_maxx = Float.MIN_VALUE; - m_miny = Float.MAX_VALUE; - m_maxy = Float.MIN_VALUE; - - m_btesting = true; - } - - public void stopBoundsTest() { - m_btesting = false; - } - - private void doBoundTest(float x, float y, float z) { - - }*/ -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANSelectionList.java b/graphics/AtlantisJava/src/atlantis/nge/ANSelectionList.java deleted file mode 100644 index 52e404eda2a19dc6ba5916c20840d28732fc3720..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANSelectionList.java +++ /dev/null @@ -1,81 +0,0 @@ -package atlantis.nge; - -import java.nio.IntBuffer; - -/** - * - * @author Adam Davison - */ -public class ANSelectionList { - - private long[] m_zmax; - private long[] m_zmin; - private int[][] m_names; - private int m_ent; - - public ANSelectionList(IntBuffer ib) { - int s = ib.limit(); - // Shortest possible entry is 4 ints long, could two pass to get - // memory requirements right but better to just spend a few bytes - int maxent = s/4; - m_zmax = new long[maxent]; - m_zmin = new long[maxent]; - m_names = new int[maxent][]; - - /*for (int i = 0; i < 20; i++) { - System.out.print(":" + ib.get(i)); - } - System.out.println();*/ - - m_ent = 0; - int pos = 0; - while((pos = processEntry(ib, pos, m_ent)) != -1) { - m_ent++; - } - //System.out.println("Got " + m_ent + " entries in selection list"); - } - - private int processEntry(IntBuffer ib, int pos, int ent) { - //System.out.println("Processing at " + pos + " entry " + ent); - int nn = ib.get(pos); - //System.out.println("nn: " + nn); - if (nn == 0) { - // At the end - return -1; - } - m_zmin[ent] = getUnsigned(ib.get(pos+1)); - m_zmax[ent] = getUnsigned(ib.get(pos+2)); - m_names[ent] = new int[nn]; - for (int i = 0; i < nn; i++) { - m_names[ent][i] = ib.get(pos+3+i); - //System.out.println("Name " + i + " is " + m_names[ent][i]); - } - pos += 3 + nn; - return pos; - } - - public long getUnsigned(int a) { - long b = a; - if (b < 0) { b -= 2L*(long)Integer.MIN_VALUE; } - return b; - } - - public int[] getFrontID() { - int found = -1; - long max = Long.MIN_VALUE; - for (int i = 0; i < m_ent; i++) { - System.out.println(m_zmax[i] + ":" + max); - if (m_zmax[i] > max) { - max = m_zmax[i]; - found = i; - } - } - - System.out.println(found); - if (found == -1) { - return null; - } else { - return m_names[found]; - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANTerribleHacks.java b/graphics/AtlantisJava/src/atlantis/nge/ANTerribleHacks.java deleted file mode 100644 index 1fd1b1c106abe34e2e48bc2b75994b05af164fd5..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANTerribleHacks.java +++ /dev/null @@ -1,119 +0,0 @@ -package atlantis.nge; - -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.data.AJetData; -import atlantis.data.ALArData; -import atlantis.geometry.AAtlasDetector; -import atlantis.geometry.ABarrelCalorimeterDetector; -import atlantis.geometry.ABoxDetector; -import atlantis.geometry.ACalorimeterDetector; -import atlantis.geometry.ADetector; -import atlantis.geometry.ADetectors; -import atlantis.geometry.AEndcapCalorimeterDetector; -import atlantis.geometry.AEndcapCryostatDetector; -import atlantis.utils.A3Vector; -import java.util.ArrayList; - -/** - * This class encapsulates everything that we shouldn't have to do in one place - * - * Mainly it relates to the fact that there's no way to ask the detector - * store for something like the muon geometry only at the moment - * - * One day if we really use this code then we need to add sensible access - * methods like that to the detector store - * - * This class should definitely be deleted one day - * - * @author Adam Davison - */ -public class ANTerribleHacks { - - private static ArrayList<ABoxDetector> m_boxes = null; - private static ArrayList<ACalorimeterDetector> m_calo = null; - private static ArrayList<ACalorimeterDetector> m_extt = null; - private static ArrayList<ACalorimeterDetector> m_mbts = null; - private static ArrayList<ACalorimeterDetector> m_endc = null; - - public static ArrayList<ABoxDetector> getMuonDetectors() { - if (m_boxes == null) { - fillArrays(); - } - return m_boxes; - } - - private static void fillArrays() { - m_boxes = new ArrayList<ABoxDetector>(); - m_calo = new ArrayList<ACalorimeterDetector>(); - m_extt = new ArrayList<ACalorimeterDetector>(); - m_mbts = new ArrayList<ACalorimeterDetector>(); - m_endc = new ArrayList<ACalorimeterDetector>(); - - ADetectors[] ds = AAtlasDetector.getDetector().getDetectors(); - for (int i = 0; i < ds.length; i++) { - ADetector[] d = ds[i].getDetectors(); - for (int j = 0; j < d.length; j++) { - if (d[j] instanceof ABoxDetector) { - ABoxDetector bd = (ABoxDetector) d[j]; - //TODO temporary code to show cut away detector - //if((bd.getPhi()>1.2 && bd.getPhi()<5.1) || !ACanvas.getCanvas().getPaintingWindow().getProjection().getName().equals("N3D")) - m_boxes.add(bd); - } else if (d[j] instanceof ABarrelCalorimeterDetector) { - ACalorimeterDetector cd = (ACalorimeterDetector) d[j]; - //extended tile only has one end in geom file and not relicated like others - if (d[j].getName().equals("Extended TILE")) { - m_extt.add(cd); - } else { - m_calo.add(cd); - } - - } else if (d[j] instanceof AEndcapCryostatDetector) { - //adds MBTS but only has one end in geom file - AEndcapCryostatDetector ecd = (AEndcapCryostatDetector) d[j]; - m_mbts.add(ecd); - } else if (d[j] instanceof AEndcapCalorimeterDetector) { - //adds LAr endcap + HEC but only has one end in geom file - AEndcapCalorimeterDetector ecd = (AEndcapCalorimeterDetector) d[j]; - m_endc.add(ecd); - - } - - } - } - } - - public static A3Vector getCellCentreLArForJet(int j) { - float xsum = 0.0f; - float ysum = 0.0f; - float zsum = 0.0f; - int count = 0; - AEvent ev = AEventManager.instance().getCurrentEvent(); - AJetData jd = ev.getJetData(); - String assockey = jd.getFullName(); - int[][] assoc = ev.getAssociationManager().get(assockey, "LAr"); - int[] dl = new int[assoc[j].length]; - ALArData calo = ev.getLArData(); - for (int i = 0; i < assoc[j].length; i++) { - int index = calo.getIndexFromId(assoc[j][i]); - float eta = (float) (calo.getEta(index)); - - float theta = (float) (2.0f * Math.atan(Math.exp(-eta))); - - float phi = (float) (calo.getPhi(index)); - - float rmin = (float) calo.getDetector(index).getRMin(); - float rmax = (float) calo.getDetector(index).getRMax(); - float r = 0.5f * (rmin + rmax); - - xsum += (float) (r * Math.cos(phi)); - ysum += (float) (r * Math.sin(phi)); - zsum += (float) (r / Math.tan(theta)); - count++; - } - - - - return new A3Vector(xsum / count, ysum / count, zsum / count); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/ANTestWindow.java b/graphics/AtlantisJava/src/atlantis/nge/ANTestWindow.java deleted file mode 100644 index f4340ca844e6ede6573e1a88f161c11aced3bb63..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/ANTestWindow.java +++ /dev/null @@ -1,119 +0,0 @@ -package atlantis.nge; - -import com.sun.opengl.util.Screenshot; -import java.awt.Graphics; -import java.awt.image.BufferedImage; -import java.util.Random; -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLPbuffer; -import javax.swing.JComponent; -import javax.swing.JFrame; - -/** - * The ubiquitous test window class... - * - * @author Adam Davison - */ -public class ANTestWindow implements GLEventListener { - - private Random m_r = new Random(); - - private int m_h = 400; - private int m_w = 400; - - private JFrame m_f; - private BufferedImage m_img; - - private ANFrameManager m_fm; - - private GLPbuffer m_context; - - public ANTestWindow() { - m_f = new JFrame("Happy Time!"); - m_f.setBounds(100, 100, m_w, m_h); - - TestComponent tc = new TestComponent(this); - - m_f.add(tc); - - GLCapabilities pbcap = new GLCapabilities(); - pbcap.setSampleBuffers(true); - pbcap.setNumSamples(4); - //pbcap.setPbufferRenderToTexture(true); - //pbcap.setDoubleBuffered(false); - m_context = GLDrawableFactory.getFactory().createGLPbuffer(pbcap, null, m_w, m_h, null); - m_context.addGLEventListener(this); - - m_fm = new ANFrameManager(null); - - m_f.setVisible(true); - - //(new Thread(new TimingThread(tc))).start(); - } - - public void causeRepaint(Graphics g) { - m_context.display(); - g.drawImage(m_img, 0, 0, null); - } - - public void init(GLAutoDrawable arg0) { - } - - public void display(GLAutoDrawable arg0) { - //m_fm.display(arg0); - m_img = Screenshot.readToBufferedImage(m_w, m_h); - } - - public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) { - } - - public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) { - throw new UnsupportedOperationException("Not supported yet."); - } - -} - -class TestComponent extends JComponent { - private ANTestWindow m_parent; - - public TestComponent(ANTestWindow parent) { - m_parent = parent; - } - - @Override - protected void paintComponent(Graphics g) { - m_parent.causeRepaint(g); - } - -} - -class TimingThread implements Runnable { - private JComponent m_parent; - - private long m_sum; - private int m_count; - - public TimingThread(JComponent parent) { - m_parent = parent; - } - - public void run() { - m_sum = 0; - m_count = 0; - try { - Thread.sleep(5000); - } catch (Exception e) {} - for (int i = 0; i < 100; i++) { - long before = System.nanoTime(); - m_parent.paintImmediately(0, 0, m_parent.getWidth(), m_parent.getHeight()); - long after = System.nanoTime(); - m_sum += after - before; - m_count++; - } - System.out.println("Mean time: " + m_sum/m_count + "ns"); - } -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/nge/object/ANObject.java b/graphics/AtlantisJava/src/atlantis/nge/object/ANObject.java deleted file mode 100644 index 944c3c461b9c0d8d84be558fead68cafb2d2c30f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/object/ANObject.java +++ /dev/null @@ -1,27 +0,0 @@ -package atlantis.nge.object; - -import atlantis.nge.*; - -/** - * An ANObject is the superclass of anything which knows how to draw itself - * using an ANRenderer - * - * Specifically these will tend to represent some kind of visual onscreen - * element and will contain all the information required to draw the - * representation - * - * @author Adam Davison - */ -public abstract class ANObject { - - public abstract void render(ANRenderer r, ANRenderHints hint); - - private ANPickHandler m_ph = null; - protected void setPickHandler(ANPickHandler ph) { - m_ph = ph; - } - - public ANPickHandler getPickHandler() { - return m_ph; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/object/ANObjectList.java b/graphics/AtlantisJava/src/atlantis/nge/object/ANObjectList.java deleted file mode 100644 index 7e79f7f10e5d9f3e83183d710306836b1568c4b6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/object/ANObjectList.java +++ /dev/null @@ -1,30 +0,0 @@ -package atlantis.nge.object; - -import atlantis.nge.ANRenderHints; -import atlantis.nge.ANRenderer; -import java.util.ArrayList; - -/** - * A composite object, of course these can be nested to make trees of objects - * - * @author Adam Davison - */ -public class ANObjectList extends ANObject { - - private ArrayList<ANObject> m_list; - - public ANObjectList() { - m_list = new ArrayList<ANObject>(); - } - - public void addObject(ANObject o) { - m_list.add(o); - } - - public void render(ANRenderer r, ANRenderHints hint) { - for (int i = 0; i < m_list.size(); i++) { - m_list.get(i).render(r, hint); - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/object/ANObjectTestAxes.java b/graphics/AtlantisJava/src/atlantis/nge/object/ANObjectTestAxes.java deleted file mode 100644 index c32ad4e2fec9157c21b2d241778fdcdbe049508e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/object/ANObjectTestAxes.java +++ /dev/null @@ -1,44 +0,0 @@ -package atlantis.nge.object; - -import atlantis.nge.*; -import javax.media.opengl.GL; - -/** - * A simple test object - * - * @author Adam Davison, Mark Stockton - */ -public class ANObjectTestAxes extends ANObject { - - public ANObjectTestAxes() { - - } - - @Override - public void render(ANRenderer r, ANRenderHints hint) { - - r.lineWidth(2.0f); - - // x - r.color3f(1.0f, 0.0f, 0.0f); - r.begin(GL.GL_LINES); - r.vertex3f(0.0f, 0.0f, 0.0f); - r.vertex3f(1500.0f, 0.0f, 0.0f); - r.end(); - - // y - r.color3f(0.0f, 1.0f, 0.0f); - r.begin(GL.GL_LINES); - r.vertex3f(0.0f, 0.0f, 0.0f); - r.vertex3f(0.0f, 1500.0f, 0.0f); - r.end(); - - // z - r.color3f(0.0f, 0.0f, 1.0f); - r.begin(GL.GL_LINES); - r.vertex3f(0.0f, 0.0f, 0.0f); - r.vertex3f(0.0f, 0.0f, 1500.0f); - r.end(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/object/ANObjectVL.java b/graphics/AtlantisJava/src/atlantis/nge/object/ANObjectVL.java deleted file mode 100644 index 091ac5ffb58a2a01ffe409c233e8a5d3372cd37b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/object/ANObjectVL.java +++ /dev/null @@ -1,66 +0,0 @@ -package atlantis.nge.object; - -import atlantis.nge.*; - -/** - * An object which draws from a vertex list - * - * @author Adam Davison - */ -public abstract class ANObjectVL extends ANObject { - - public abstract float[][] getVertices(); - - public abstract int[] getPrimTypes(); - - // What the hell is this? - public final int DRAW_LINE=-9; - - public ANColor getColor(int i) { - return new ANColor(1.0f, 0.0f, 0.0f, 1.0f); - } - - /** - * This function is like the software equivalent of just dumping a block - * of vertex information in GL 3.1... - * @param r - * @param hint - */ - @Override - public void render(ANRenderer r, ANRenderHints hint) { - r.lineWidth(1.5f); - - int pid = -1; - ANPickHelper ph = null; - if (hint.getPick()) { - ph = hint.getPickHelper(); - pid = ph.getIndex(this); - } - - int[] pt = getPrimTypes(); - float[][] v = getVertices(); - - if (pt == null) { - return; - } - - for (int i = 0; i < pt.length; i++) { - if (hint.getPick()) { - ph.startPick(pid, i); - } - - ANColor c = getColor(i); - r.color4f(c.r, c.g, c.b, c.a); - r.begin(pt[i]); - for (int j = 0; j < v[i].length; j+=3) { - r.vertex3f(v[i][j], v[i][j+1], v[i][j+2]); - } - r.end(); - - if (hint.getPick()) { - ph.endPick(); - } - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/object/data/ANObjectDataCell.java b/graphics/AtlantisJava/src/atlantis/nge/object/data/ANObjectDataCell.java deleted file mode 100644 index 410ea527370b5bddda735d7bd8b97c13cee137fb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/object/data/ANObjectDataCell.java +++ /dev/null @@ -1,170 +0,0 @@ -package atlantis.nge.object.data; - -import atlantis.nge.object.*; -import atlantis.nge.*; -import atlantis.data.ACalorimeterData; -import atlantis.geometry.AEndcapCalorimeterDetector; -import atlantis.utils.AMath; - -import javax.media.opengl.GL; - -/** - * Object that draws cells - * - * @author Adam Davison, Mark Stockton - */ -public class ANObjectDataCell extends ANObjectVL { - - private float[][] m_v; - private int[] m_pt; - private int[] m_color; - - public ANObjectDataCell() { - } - - public ANObjectDataCell(ACalorimeterData ald) { - - m_pt = new int[ald.getNumDraw()]; - m_v = new float[ald.getNumDraw()][]; - m_color = new int[ald.getNumDraw()]; - - for (int j = 0; j < ald.getNumDraw(); j++) { - int i = ald.getDrawIndex(j); - - m_pt[j] = GL.GL_TRIANGLE_STRIP; - m_color[j] = ald.getColor(i); - m_v[j] = getVert(ald, i); - - } - } - - public ANObjectDataCell(ACalorimeterData ald, int dl[]) { - - m_pt = new int[dl.length]; - m_v = new float[dl.length][]; - m_color = new int[dl.length]; - - for (int j = 0; j < dl.length; j++) { - int i = dl[j]; - - m_pt[j] = GL.GL_TRIANGLE_STRIP; - m_color[j] = ald.getColor(i); - m_v[j] = getVert(ald, i); - - } - } - - // This logic should be in ANObjectGenerator - public ANObjectDataCell(ACalorimeterData ald, float phi, float eta, float dr) { - - int num = 0; - for (int j = 0; j < ald.getNumDraw(); j++) { - int i = ald.getDrawIndex(j); - if (AMath.deltaR(phi, eta, (float) ald.getPhi(i), (float) ald.getEta(i)) < dr) { - num++; - } - } - - m_pt = new int[num]; - m_v = new float[num][]; - m_color = new int[num]; - num = 0; - for (int j = 0; j < ald.getNumDraw(); j++) { - int i = ald.getDrawIndex(j); - if (AMath.deltaR(phi, eta, (float) ald.getPhi(i), (float) ald.getEta(i)) > dr) { - continue; - } - m_pt[num] = GL.GL_TRIANGLE_STRIP; - m_color[num] = ald.getColor(i); - m_v[num] = getVert(ald, i); - num++; - - } - } - - private float[] getVert(ACalorimeterData ald, int index) { - - float etamin = (float) (ald.getEta(index) - ald.getdEta(index)); - float etamax = (float) (ald.getEta(index) + ald.getdEta(index)); - - float thetamin = (float) (2.0f * Math.atan(Math.exp(-etamin))); - float thetamax = (float) (2.0f * Math.atan(Math.exp(-etamax))); - - float phimin = (float) (ald.getPhi(index) - ald.getdPhi(index)); - float phimax = (float) (ald.getPhi(index) + ald.getdPhi(index)); - - float rmin = (float) ald.getDetector(index).getRMin(); - float rmax = (float) ald.getDetector(index).getRMax(); - - // TODO: Push this up to the getZ??? functions in this detector - // class. - if (ald.getDetector(index) instanceof AEndcapCalorimeterDetector) { - //correction taken from AEndcapCalorimeterDetector - String name = ald.getDetector(index).getName(); - float zmin = (float) (ald.getDetector(index).getZMin()); - //This shouldn't be 0, but just to be on the safe side. - int side = ald.getSide(index); - if (side != 0) { - side /= Math.abs(side); - } - zmin *= side; - if (name.indexOf("Inner") >= 0 || name.indexOf("Outer") >= 0 || name.indexOf("Presampler") >= 0) { - rmax = (float) (zmin / Math.sinh(etamin)); - } - rmin = (float) (zmin / Math.sinh(etamax)); - } - - float[][] v = new float[8][3]; - - fillVert(v[0], rmin, thetamin, phimin); - fillVert(v[1], rmin, thetamax, phimin); - fillVert(v[2], rmax, thetamax, phimin); - fillVert(v[3], rmax, thetamin, phimin); - fillVert(v[4], rmin, thetamin, phimax); - fillVert(v[5], rmin, thetamax, phimax); - fillVert(v[6], rmax, thetamax, phimax); - fillVert(v[7], rmax, thetamin, phimax); - - float[] vert = new float[3 * 14]; - int[] wind = {6, 5, 7, 4, 0, 5, 1, 2, 0, 3, 7, 2, 6, 5}; - for (int i = 0; i < 14; i++) { - copyVert(v[wind[i]], vert, i); - } - - return vert; - } - - private void copyVert(float[] v, float[] t, int ti) { - t[(ti * 3) + 0] = v[0]; - t[(ti * 3) + 1] = v[1]; - t[(ti * 3) + 2] = v[2]; - - } - - private void fillVert(float[] v, float r, float theta, float phi) { - - v[0] = (float) (r * Math.cos(phi)); - v[1] = (float) (r * Math.sin(phi)); - v[2] = (float) (r / Math.tan(theta)); - } - - @Override - public float[][] getVertices() { - return m_v; - } - - @Override - public int[] getPrimTypes() { - return m_pt; - } - - @Override - public ANColor getColor(int i) { - - if (m_color[i] == DRAW_LINE) { - return new ANColor(0.0f, 0.0f, 0.0f, 1.0f); - } else { - return ANColor.getMapColor(m_color[i]); - } - } -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/nge/object/data/ANObjectDataJet.java b/graphics/AtlantisJava/src/atlantis/nge/object/data/ANObjectDataJet.java deleted file mode 100644 index f97774fe95f31a9f9f213af5a90b081a8ee1235f..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/object/data/ANObjectDataJet.java +++ /dev/null @@ -1,146 +0,0 @@ -package atlantis.nge.object.data; - -import atlantis.nge.object.*; -import atlantis.nge.*; -import atlantis.data.AJetData; -import atlantis.utils.AMath; - -import javax.media.opengl.GL; - -/** - * Object that draws geometry of the muon system - * - * @author Adam Davison, Mark Stockton - */ -public class ANObjectDataJet extends ANObjectVL { - - private float[][] m_v; - private int[] m_pt; - private int[] m_color; - - public ANObjectDataJet() { - - } - -public ANObjectDataJet(AJetData ajd) { - - - m_pt = new int[2*ajd.getNumDraw()]; - m_v = new float[2*ajd.getNumDraw()][]; - m_color = new int[2*ajd.getNumDraw()]; - - for (int j = 0; j < ajd.getNumDraw(); j++) { - int i= ajd.getDrawIndex(j); - float theta = (float) (2.0f * Math.atan(Math.exp(-ajd.getEta(i)))); - - m_pt[2*j] = GL.GL_TRIANGLE_FAN; - //m_v[2*j] = getCone(ajd.getET(i), ajd.getPhi(i), theta); - m_v[2*j] = getCone(1300.0f, ajd.getPhi(i), theta); - m_color[2*j]=ajd.getColor(i); - m_pt[2*j+1] = GL.GL_LINES; - //m_v[2*i+1] = getCore(ajd.getET(i), ajd.getPhi(i), theta); - m_v[2*j+1] = getCore(1300.0f, ajd.getPhi(i), theta); - m_color[2*j+1]=DRAW_LINE; - } - } - - public ANObjectDataJet(AJetData ajd, float phi, float eta, float dr) { - - int num=0; - for (int j = 0; j < ajd.getNumDraw(); j++) { - int i= ajd.getDrawIndex(j); - if(AMath.deltaR(phi,eta,(float)ajd.getPhi(i),(float)ajd.getEta(i))<dr){ - num++; - } - } - - m_pt = new int[2*num]; - m_v = new float[2*num][]; - m_color = new int[2*num]; - num=0; - for (int j = 0; j < ajd.getNumDraw(); j++) { - int i= ajd.getDrawIndex(j); - if(AMath.deltaR(phi,eta,(float)ajd.getPhi(i),(float)ajd.getEta(i))>dr) - continue; - float theta = (float) (2.0f * Math.atan(Math.exp(-ajd.getEta(i)))); - - m_pt[2*num] = GL.GL_TRIANGLE_FAN; - //m_v[2*num] = getCone(ajd.getET(i), ajd.getPhi(i), theta); - m_v[2*num] = getCone(1300.0f, ajd.getPhi(i), theta); - m_color[2*num]=ajd.getColor(i); - m_pt[2*num+1] = GL.GL_LINES; - //m_v[2*num+1] = getCore(ajd.getET(i), ajd.getPhi(i), theta); - m_v[2*num+1] = getCore(1300.0f, ajd.getPhi(i), theta); - m_color[2*num+1]=DRAW_LINE; - num++; - } - } - - - - private float[] getCore(float len, float phi, float theta){ - - // Jets are in detector eta so primary vertex set to 0 is sensible for now - float[] core = {0.0f, 0.0f, 0.0f, - (float) (len * Math.cos(phi) * Math.sin(theta)), - (float) (len * Math.sin(phi) * Math.sin(theta)), - (float) (len * Math.cos(theta)) - }; - return core; - } - - private float[] getCone(float len, float phi, float theta){ - int segs = 8; - - float[] cone = new float[3 * (2 + segs)]; - cone[0] = 0.0f; - cone[1] = 0.0f; - cone[2] = 0.0f; - - //temporary jet radius - float jetr = 100.0f; - - for (int i = 0; i < segs; i++) { - float lphi = (float) (i * 2.0f * Math.PI / segs); - float ax = (float) (jetr * Math.cos(lphi)); - float ay = (float) (jetr * Math.sin(lphi)); - float az = len; - - float bx = (float) (ax * Math.cos(phi) * Math.cos(theta) + - az * Math.sin(theta) * Math.cos(phi) - ay * Math.sin(phi)); - float by = (float) (ax * Math.cos(theta) * Math.sin(phi) + - az * Math.sin(theta) * Math.sin(phi) + ay * Math.cos(phi)); - float bz = (float) (-ax * Math.sin(theta) + az * Math.cos(theta)); - - cone[i*3+3] = bx; - cone[i*3+4] = by; - cone[i*3+5] = bz; - } - - cone[(3*(2+segs)) - 3] = cone[3]; - cone[(3*(2+segs)) - 2] = cone[4]; - cone[(3*(2+segs)) - 1] = cone[5]; - - return cone; - } - - @Override - public float[][] getVertices() { - return m_v; - } - - @Override - public int[] getPrimTypes() { - return m_pt; - } - - @Override - public ANColor getColor(int i) { - - if(m_color[i]==DRAW_LINE) - return new ANColor(0.0f, 0.0f, 0.0f, 1.0f); - else - return ANColor.getMapColor(m_color[i], 0.5f); - - } -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/nge/object/data/ANObjectPointing.java b/graphics/AtlantisJava/src/atlantis/nge/object/data/ANObjectPointing.java deleted file mode 100644 index 2fddcee1d37211b7c5e1591a23dfb5698514f42d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/object/data/ANObjectPointing.java +++ /dev/null @@ -1,147 +0,0 @@ -package atlantis.nge.object.data; - -import atlantis.data.ACalorimeterData; -import atlantis.data.ATILEData; -import atlantis.geometry.AEndcapCalorimeterDetector; -import atlantis.nge.ANColor; -import atlantis.nge.object.ANObjectVL; -import atlantis.utils.AMath; -import javax.media.opengl.GL; - -/** - * - * @author Adam Davison - */ -public class ANObjectPointing extends ANObjectVL { - - private float[][] m_v; - private int[] m_pt; - private ANColor[] m_c; - - public ANObjectPointing(ACalorimeterData ald, int dl[], int dllen, boolean outline) { - m_pt = new int[dllen]; - m_v = new float[dllen][]; - m_c = new ANColor[dllen]; - - double[] area = new double[dl.length]; - for (int i = 0; i < dllen; i++) { - area[i] = 1.0; - } - - ald.calibrateLocalDensity(dl, area); - double[] scale = ald.getScaleFactors(dl, area); - - if (outline) { - for (int j = 0; j < dllen; j++) { - int i = dl[j]; - m_pt[j] = GL.GL_LINES; - m_c[j] = ANColor.getMapColor(ald.getColor(i)); - m_c[j].mult(0.5f); - m_v[j] = getVert(ald, i, (float)scale[j], true); - //m_v[j] = getVert(ald, i, 1.0f, true); - } - } else { - - for (int j = 0; j < dllen; j++) { - int i = dl[j]; - m_pt[j] = GL.GL_TRIANGLE_STRIP; - m_c[j] = ANColor.getMapColor(ald.getColor(i)); - m_v[j] = getVert(ald, i, (float)scale[j], false); - } - } - - } - - @Override - public float[][] getVertices() { - return m_v; - } - - @Override - public int[] getPrimTypes() { - return m_pt; - } - - @Override - public ANColor getColor(int i) { - return m_c[i]; - } - - private float[] getVert(ACalorimeterData ald, int index, float scale, boolean outline) { - - // Possibly should apply scale to theta not eta? - float etamin = (float) (ald.getEta(index) - 0.5f*scale*ald.getdEta(index)); - float etamax = (float) (ald.getEta(index) + 0.5f*scale*ald.getdEta(index)); - - float thetamin = (float) (2.0f * Math.atan(Math.exp(-etamin))); - float thetamax = (float) (2.0f * Math.atan(Math.exp(-etamax))); - - float phimin = (float) (ald.getPhi(index) - 0.5f*scale*ald.getdPhi(index)); - float phimax = (float) (ald.getPhi(index) + 0.5f*scale*ald.getdPhi(index)); - - float rmin = (float) ald.getDetector(index).getRMin(); - float rmax = (float) ald.getDetector(index).getRMax(); - float dr = 0.5f*(rmax - rmin); - rmin += (1.0f - scale)*dr; - rmax -= (1.0f - scale)*dr; - - // TODO: Push this up to the getZ??? functions in this detector - // class. - if (ald.getDetector(index) instanceof AEndcapCalorimeterDetector) { - //correction taken from AEndcapCalorimeterDetector - String name = ald.getDetector(index).getName(); - float zmin = (float) (ald.getDetector(index).getZMin()); - //This shouldn't be 0, but just to be on the safe side. - int side = ald.getSide(index); - if (side != 0) { - side /= Math.abs(side); - } - zmin *= side; - if (name.indexOf("Inner") >= 0 || name.indexOf("Outer") >= 0 || name.indexOf("Presampler") >= 0) { - rmax = (float) (zmin / Math.sinh(etamin)); - } - rmin = (float) (zmin / Math.sinh(etamax)); - } - - float[][] v = new float[8][3]; - - fillVert(v[0], rmin, thetamin, phimin); - fillVert(v[1], rmin, thetamax, phimin); - fillVert(v[2], rmax, thetamax, phimin); - fillVert(v[3], rmax, thetamin, phimin); - fillVert(v[4], rmin, thetamin, phimax); - fillVert(v[5], rmin, thetamax, phimax); - fillVert(v[6], rmax, thetamax, phimax); - fillVert(v[7], rmax, thetamin, phimax); - - int[] wind = null; - if (!outline) { - int[] inwind = {6, 5, 7, 4, 0, 5, 1, 2, 0, 3, 7, 2, 6, 5}; - wind = inwind; - } else { - int[] outwind = {0, 3, 0, 1, 0, 4, 2, 1, 2, 3, 2, 6, - 7, 4, 7, 6, 7, 3, 5, 6, 5, 4, 5, 1}; - wind = outwind; - } - float[] vert = new float[3 * wind.length]; - for (int i = 0; i < wind.length; i++) { - copyVert(v[wind[i]], vert, i); - } - - return vert; - } - - private void copyVert(float[] v, float[] t, int ti) { - t[(ti * 3) + 0] = v[0]; - t[(ti * 3) + 1] = v[1]; - t[(ti * 3) + 2] = v[2]; - - } - - private void fillVert(float[] v, float r, float theta, float phi) { - - v[0] = (float) (r * Math.cos(phi)); - v[1] = (float) (r * Math.sin(phi)); - v[2] = (float) (r / Math.tan(theta)); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/object/data/ANObjectTracks.java b/graphics/AtlantisJava/src/atlantis/nge/object/data/ANObjectTracks.java deleted file mode 100644 index f8599c1f12a6d862a10a62e1700e405bdaf8e299..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/object/data/ANObjectTracks.java +++ /dev/null @@ -1,82 +0,0 @@ -package atlantis.nge.object.data; - -import atlantis.data.ALArData; -import atlantis.data.ATrackData; -import atlantis.nge.ANColor; -import atlantis.nge.object.ANObjectVL; -import javax.media.opengl.GL; - -/** - * - * @author Adam Davison - */ -public class ANObjectTracks extends ANObjectVL { - - private float[][] m_v; - private int[] m_pt; - private int[] m_color; - - public ANObjectTracks(ATrackData td) { - float[][] x = td.getX(); - float[][] y = td.getY(); - float[][] z = td.getZ(); - - m_pt = new int[x.length]; - m_v = new float[x.length][]; - m_color = new int[x.length]; - - for (int i = 0; i < x.length; i++) { - m_pt[i] = GL.GL_LINE_STRIP; - m_v[i] = new float[x[i].length * 3]; - m_color[i] = td.getColor(i); - for (int p = 0; p < x[i].length; p++) { - m_v[i][p * 3] = x[i][p]; - m_v[i][p * 3 + 1] = y[i][p]; - m_v[i][p * 3 + 2] = z[i][p]; - } - } - } - - public ANObjectTracks(ATrackData td, int[] dl) { - float[][] x = td.getX(); - if (x == null) { - System.out.println("ARGH!!"); - m_pt = null; - m_v = null; - m_color = null; - return; - } - float[][] y = td.getY(); - float[][] z = td.getZ(); - - m_pt = new int[dl.length]; - m_v = new float[dl.length][]; - m_color = new int[dl.length]; - - for (int i = 0; i < dl.length; i++) { - m_pt[i] = GL.GL_LINE_STRIP; - int index = td.getIndexFromId(dl[i]); - m_v[i] = new float[x[index].length * 3]; - m_color[i] = td.getColor(index); - for (int p = 0; p < x[index].length; p++) { - m_v[i][p * 3] = x[index][p]; - m_v[i][p * 3 + 1] = y[index][p]; - m_v[i][p * 3 + 2] = z[index][p]; - } - } - } - - @Override - public float[][] getVertices() { - return m_v; - } - - @Override - public int[] getPrimTypes() { - return m_pt; - } - - public ANColor getColor(int i) { - return ANColor.getMapColor(m_color[i]); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/object/geometry/ANObjectBeamLine.java b/graphics/AtlantisJava/src/atlantis/nge/object/geometry/ANObjectBeamLine.java deleted file mode 100644 index ad9d7da77b47279edac2cb61b6885fd0508af8cb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/object/geometry/ANObjectBeamLine.java +++ /dev/null @@ -1,21 +0,0 @@ -package atlantis.nge.object.geometry; - -import atlantis.nge.object.ANObjectVL; - -/** - * - * @author Adam Davison - */ -public class ANObjectBeamLine extends ANObjectVL { - - @Override - public float[][] getVertices() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public int[] getPrimTypes() { - throw new UnsupportedOperationException("Not supported yet."); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/nge/object/geometry/ANObjectGeomCalo.java b/graphics/AtlantisJava/src/atlantis/nge/object/geometry/ANObjectGeomCalo.java deleted file mode 100644 index 5705182ecc6d12bb27c315ee37ee4da033f09275..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/object/geometry/ANObjectGeomCalo.java +++ /dev/null @@ -1,159 +0,0 @@ -package atlantis.nge.object.geometry; - -import atlantis.nge.object.*; -import atlantis.nge.*; -import atlantis.geometry.ACalorimeterDetector; - -import java.util.ArrayList; -import javax.media.opengl.GL; - -/** - * Object that draws geometry of the muon system - * - * @author Adam Davison, Mark Stockton - */ -public class ANObjectGeomCalo extends ANObjectVL { - - private float[][] m_v; - private int[] m_pt; - - private int[] m_color; - - public ANObjectGeomCalo(ArrayList<ACalorimeterDetector> m_calo, int nv_scale, boolean duplicate) { - - m_pt = new int[7*m_calo.size()]; - m_v = new float[7*m_calo.size()][]; - m_color = new int[7*m_calo.size()]; - - //all endcaps and extended tile only has one end in geom file and not relicated like others - for (int j = 0; j < m_calo.size(); j++) { - int i=7*j; - ACalorimeterDetector cd = m_calo.get(j); - m_pt[i]=GL.GL_TRIANGLE_STRIP; - m_pt[i+1]=GL.GL_TRIANGLE_STRIP; - m_pt[i+2]=GL.GL_TRIANGLE_STRIP; - m_pt[i+3]=GL.GL_LINE_LOOP; - m_pt[i+4]=GL.GL_LINE_LOOP; - m_pt[i+5]=GL.GL_LINE_LOOP; - m_pt[i+6]=GL.GL_LINE_LOOP; - m_color[i]=cd.getFillColor(); - m_color[i+1]=cd.getFillColor(); - m_color[i+2]=cd.getFillColor(); - m_color[i+3]=DRAW_LINE; - m_color[i+4]=DRAW_LINE; - m_color[i+5]=DRAW_LINE; - m_color[i+6]=DRAW_LINE; - - float zMin=(float) cd.getZMin(); - float zMax=(float) cd.getZMax(); - if(duplicate){ - zMin*=-1.; - zMax*=-1.; - } - m_v[i] = getEndTris(zMin, (float) cd.getRMin(), (float) cd.getRMax(), cd.getNumPhi() / nv_scale); - m_v[i+1] = getEndTris(zMax, (float) cd.getRMin(), (float) cd.getRMax(), cd.getNumPhi() / nv_scale); - m_v[i+2] = getBarrelTris(zMin, zMax, (float) cd.getRMin(), (float) cd.getRMax(), cd.getNumPhi() / nv_scale); - m_v[i+3] = getEdges(zMin, (float) cd.getRMin(), cd.getNumPhi() / nv_scale, true); - m_v[i+4] = getEdges(zMax, (float) cd.getRMin(), cd.getNumPhi() / nv_scale, true); - m_v[i+5] = getEdges(zMin, (float) cd.getRMax(), cd.getNumPhi() / nv_scale, false); - m_v[i+6] = getEdges(zMax, (float) cd.getRMax(), cd.getNumPhi() / nv_scale, false); - } - } - - - private float[] getEdges(float z, float r, int nv, boolean inner) { - float[] v = new float[3 * nv]; - - float dphi = (2 * (float) Math.PI) / nv; - float hdphi = 0.5f * dphi; - //if (inner) { hdphi = 0.0f; } - - for (int i = 0; i < nv; i++) { - int ie = i * 3; - v[ie] = r * (float) Math.cos(i * dphi + hdphi); - v[ie + 1] = r * (float) Math.sin(i * dphi + hdphi); - v[ie + 2] = (float) z; - } - - return v; - } - - private float[] getBarrelTris(float zmin, float zmax, float rmin, float rmax, int nv) { - float[] v = new float[3 * (nv * 2 + 2)]; - - float dphi = (2 * (float) Math.PI) / nv; - float hdphi = 0.5f * dphi; - - float r = (float) rmax; - - for (int i = 0; i < nv; i++) { - int ie = i * 2 * 3; - int oe = (i * 2 + 1) * 3; - v[ie] = r * (float) Math.cos(i * dphi + hdphi); - v[ie + 1] = r * (float) Math.sin(i * dphi + hdphi); - v[ie + 2] = (float) zmin; - v[oe] = r * (float) Math.cos(i * dphi + hdphi); - v[oe + 1] = r * (float) Math.sin(i * dphi + hdphi); - v[oe + 2] = (float) zmax; - } - - // Close the strip - for (int i = 0; i < 6; i++) { - v[i + v.length - 6] = v[i]; - } - - return v; - } - - private float[] getEndTris(float z, float rmin, float rmax, int nv) { - float[] v = new float[3 * (nv * 2 + 2)]; - - float dphi = (2 * (float) Math.PI) / nv; - float hdphi = 0.5f * dphi; - - for (int i = 0; i < nv; i++) { - int ie = i * 2 * 3; - int oe = (i * 2 + 1) * 3; - v[ie] = (float) rmin * (float) Math.cos(i * dphi); - v[ie + 1] = (float) rmin * (float) Math.sin(i * dphi); - v[ie + 2] = z; - v[oe] = (float) rmax * (float) Math.cos(i * dphi + hdphi); - v[oe + 1] = (float) rmax * (float) Math.sin(i * dphi + hdphi); - v[oe + 2] = z; - } - - // Close the strip - for (int i = 0; i < 6; i++) { - v[i + v.length - 6] = v[i]; - } - - return v; - } - - - - public ANObjectGeomCalo() { - - } - - @Override - public int[] getPrimTypes() - { - return m_pt; - } - - @Override - public float[][] getVertices() - { - return m_v; - } - - @Override - public ANColor getColor(int i) { - - if(m_color[i]==DRAW_LINE) - return new ANColor(0.0f, 0.0f, 0.0f, 1.0f); - else - return ANColor.getMapColor(m_color[i], 1.0f); - } -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/nge/object/geometry/ANObjectGeomMuon.java b/graphics/AtlantisJava/src/atlantis/nge/object/geometry/ANObjectGeomMuon.java deleted file mode 100644 index dd115cb360ace63e144c2f75b2f8999b2bbfe203..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/nge/object/geometry/ANObjectGeomMuon.java +++ /dev/null @@ -1,229 +0,0 @@ -package atlantis.nge.object.geometry; - -import atlantis.nge.object.*; -import atlantis.nge.*; -import atlantis.geometry.ABoxDetector; -import java.util.ArrayList; -import javax.media.opengl.GL; - -/** - * Object that draws geometry of the muon system - * - * @author Adam Davison, Mark Stockton - */ -public class ANObjectGeomMuon extends ANObjectVL { - - private float[][] m_v; - private int[] m_pt; - private int[] m_color; - - public ANObjectGeomMuon() { - setPickHandler(new ANPickHandlerSimple("Muon Spectrometer")); - } - - public ANObjectGeomMuon(ArrayList<ABoxDetector> m_boxes) { - setPickHandler(new ANPickHandlerSimple("Muon Spectrometer")); - - m_pt = new int[2*m_boxes.size()]; - m_v = new float[2*m_boxes.size()][]; - m_color = new int[2*m_boxes.size()]; - - for (int i = 0; i < m_boxes.size(); i++) { - ABoxDetector b = m_boxes.get(i); - m_pt[2*i] = GL.GL_TRIANGLE_STRIP; - m_v[2*i] = getBoxFaces((float)b.getZMin(), (float)b.getZMax(), - (float)b.getRMin(), (float)b.getRMax(), (float)b.getPhi(), - (float)b.getSize()); - m_color[2*i]=b.getFillColor(); - m_pt[2*i+1] = GL.GL_LINES; - m_v[2*i+1] = getBoxEdges((float)b.getZMin(), (float)b.getZMax(), - (float)b.getRMin(), (float)b.getRMax(), (float)b.getPhi(), - (float)b.getSize()); - m_color[2*i+1]=DRAW_LINE; - } - } - - // This code answers the question, how do you wrap a strip of 14 triangles - // to form a cube? - private float[] getBoxFaces(float zmin, float zmax, float rmin, float rmax, float phi, float w) { - float[] v = new float[3*14]; - - float sinPhi = (float)Math.sin(phi); - float cosPhi = (float)Math.cos(phi); - - float xmi = rmin*cosPhi; - float ymi = rmin*sinPhi; - float xmo = rmax*cosPhi; - float ymo = rmax*sinPhi; - float dx = -sinPhi*w/2.0f; - float dy = cosPhi*w/2.0f; - - v[0] = xmi + dx; - v[1] = ymi + dy; - v[2] = zmax; - - v[3] = xmi - dx; - v[4] = ymi - dy; - v[5] = zmax; - - v[6] = xmo + dx; - v[7] = ymo + dy; - v[8] = zmax; - - v[9] = xmo - dx; - v[10] = ymo - dy; - v[11] = zmax; - - v[12] = v[9]; - v[13] = v[10]; - v[14] = zmin; - - v[15] = v[3]; - v[16] = v[4]; - v[17] = v[5]; - - v[18] = v[3]; - v[19] = v[4]; - v[20] = zmin; - - v[21] = v[0]; - v[22] = v[1]; - v[23] = zmin; - - v[24] = v[12]; - v[25] = v[13]; - v[26] = v[14]; - - v[27] = v[6]; - v[28] = v[7]; - v[29] = zmin; - - v[30] = v[6]; - v[31] = v[7]; - v[32] = v[8]; - - v[33] = v[21]; - v[34] = v[22]; - v[35] = v[23]; - - v[36] = v[0]; - v[37] = v[1]; - v[38] = v[2]; - - v[39] = v[3]; - v[40] = v[4]; - v[41] = v[5]; - - return v; - } - - private float[] getBoxEdges(float zmin, float zmax, float rmin, float rmax, float phi, float w) { - float[] v = new float[3*12*2]; // 3d*12edges*2ends - - float sinPhi = (float)Math.sin(phi); - float cosPhi = (float)Math.cos(phi); - - float xmi = rmin*cosPhi; - float ymi = rmin*sinPhi; - float xmo = rmax*cosPhi; - float ymo = rmax*sinPhi; - float dx = -sinPhi*w/2.0f; - float dy = cosPhi*w/2.0f; - - v[0] = xmi + dx; - v[1] = ymi + dy; - v[2] = zmin; - - v[3] = xmi - dx; - v[4] = ymi - dy; - v[5] = zmin; - - v[6] = v[3]; - v[7] = v[4]; - v[8] = v[5]; - - v[9] = xmo - dx; - v[10] = ymo - dy; - v[11] = zmin; - - v[12] = v[9]; - v[13] = v[10]; - v[14] = v[11]; - - v[15] = xmo + dx; - v[16] = ymo + dy; - v[17] = zmin; - - v[18] = v[15]; - v[19] = v[16]; - v[20] = v[17]; - - v[21] = v[0]; - v[22] = v[1]; - v[23] = v[2]; - - for (int i = 24; i < 48; i++) { - if (i % 3 == 2) { - v[i] = zmax; - } else { - v[i] = v[i - 24]; - } - - } - - v[48] = v[0]; - v[49] = v[1]; - v[50] = v[2]; - - v[51] = v[0]; - v[52] = v[1]; - v[53] = zmax; - - v[54] = v[3]; - v[55] = v[4]; - v[56] = v[5]; - - v[57] = v[3]; - v[58] = v[4]; - v[59] = zmax; - - v[60] = v[9]; - v[61] = v[10]; - v[62] = v[11]; - - v[63] = v[9]; - v[64] = v[10]; - v[65] = zmax; - - v[66] = v[15]; - v[67] = v[16]; - v[68] = v[17]; - - v[69] = v[15]; - v[70] = v[16]; - v[71] = zmax; - - return v; - } - - @Override - public float[][] getVertices() { - return m_v; - } - - @Override - public int[] getPrimTypes() { - return m_pt; - } - - @Override - public ANColor getColor(int i) { - - if(m_color[i]==DRAW_LINE) - return new ANColor(0.0f, 0.0f, 0.0f, 1.0f); - else - return ANColor.getMapColor(m_color[i], 1.0f); - - } - -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/output/AExceptionHandler.java b/graphics/AtlantisJava/src/atlantis/output/AExceptionHandler.java deleted file mode 100755 index 7be2501d9e747ea20e0d2a705efbf1eaded0dec4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/output/AExceptionHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -package atlantis.output; - -import javax.swing.JOptionPane; - -import atlantis.globals.AGlobals; - -/** - * Handles an exception thrown in the AWT event-dispatch thread. If the system - * property "sun.awt.exception.handler" is defined then when an exception occurs - * in the AWT event-dispatch thread, the thread wii do the following: 1) Load - * the class named by the value of that property, using the current thread's - * context class loader, 2) Instantiate that class using its zero-argument - * constructor, 3) Find the resulting handler object's "public void handle" - * method, which should take a single argument of type "Throwable", and 4) - * Invoke the handler's "handle" method, passing it the exception as an - * argument. - * - * Note: The magic "sun.awt.exception.handler" property will be - * removed in a future release. - * - * Comment: No wonder - centrally handling all exceptions is not a good idea - * in the first place (S.B.) - */ - -public class AExceptionHandler { - private static final AGlobals globals = AGlobals.instance(); - - public void handle(Throwable exception) - { - processException("AWT Event Dispatch Thread Exception:", exception); - } - - public static void processException(String message, Throwable exception) - { - exception.printStackTrace(); - showMessageDialog(message); - } - - public static void processException(String type, String message) - { - - if (type.equals("fatal")){ - showMessageDialog(type + ": " + message + "\n"); - System.exit(1); - } - AOutput.append(type + ": " + message + "\n", ALogInterface.BAD_COMMAND); - } - - private static void showMessageDialog(String message) - { - //Do not show messages in headless mode - if(AGlobals.isAtlantisHeadless()) return; - - //Do not show messages in demo mode - if (AGlobals.instance().isDemoMode()) return; - - //Else show a message box with the exception - JOptionPane.showMessageDialog(globals.getGuiFrame(), message, "Atlantis", JOptionPane.ERROR_MESSAGE); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/output/ALogInterface.java b/graphics/AtlantisJava/src/atlantis/output/ALogInterface.java deleted file mode 100644 index 3a3f416a71f541ab4234687d3e52b1f7e0c93267..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/output/ALogInterface.java +++ /dev/null @@ -1,25 +0,0 @@ -package atlantis.output; - -/** - * Non-GUI-dependent interface for ALogPane. - * - * @author waugh - * - */ -public interface ALogInterface { - - public static final String TITLE = "TITLE"; - public static final String NORMAL = "NORMAL"; - public static final String NORMAL_BOLD = "NORMAL_BOLD"; - public static final String COMMAND = "COMMAND"; - public static final String BAD_COMMAND = "BAD_COMMAND"; - public static final String PICK = "PICK"; - public static final String WARNING = "WARNING"; - - void append(String s); - - void append(String s, String style); - - void clear(); - -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/output/AOutput.java b/graphics/AtlantisJava/src/atlantis/output/AOutput.java deleted file mode 100755 index 4f5285cb5a5578c586939ff2bd4ccd2f27ed1c89..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/output/AOutput.java +++ /dev/null @@ -1,54 +0,0 @@ -package atlantis.output; - -import atlantis.globals.AGlobals; -import atlantis.utils.ALogger; - -/** - * AOutput provides access to the specific static instance of AMainLogPane which - * is used for displaying general information within Atlantis - * @author Adam Davison - */ -public class AOutput -{ - //Handle to the main log pane - private static ALogInterface outputPane; - - /** Logger for when not outputting to the GUI (Minerva). */ - private final static ALogger logger = ALogger.getLogger(AOutput.class); - - /** Append text to output pane/logger depending on output level. */ - public static void append(String s, String style) { - if (outputPane==null) return; // in case not set yet, or no GUI - if(AGlobals.instance().getSimpleOutput()>0){ - if (style.equals(ALogInterface.BAD_COMMAND) || style.equals(ALogInterface.WARNING)) { - logger.warn(s); - }else{ - logger.info(s); - } - }else{ - outputPane.append(s, style); - } - } - - /** Append text to output pane - only for pick info (and select event/debug info). */ - public static void alwaysAppend(String s, String style) { - if (outputPane==null) return; // in case not set yet, or no GUI - outputPane.append(s, style); - } - - /** - * Provide interface to the log pane in the GUI. - * @param outputDisplay the log pane - */ - public static void setOutput(ALogInterface outputDisplay) { - AOutput.outputPane = outputDisplay; - } - - /** - * Get interface to the log pane in the GUI, if any. - * @param outputDisplay the log pane - */ - public static ALogInterface getOutput() { - return outputPane; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/package.html b/graphics/AtlantisJava/src/atlantis/package.html deleted file mode 100644 index 9d160b36ad3a4a82ea0968a85583832d39deafd1..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/package.html +++ /dev/null @@ -1,8 +0,0 @@ -<html> -<head></head> -<body> - Root package of the Atlantis application. - Contains main class Atlantis, whose purpose is to parse the command line, - initialise the application's main components and provide access to them. -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AAbstractParameter.java b/graphics/AtlantisJava/src/atlantis/parameters/AAbstractParameter.java deleted file mode 100755 index 74401090c6e014c3f7feb3d99d752026f09dcb21..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AAbstractParameter.java +++ /dev/null @@ -1,913 +0,0 @@ -package atlantis.parameters; - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JPopupMenu; -import javax.swing.LookAndFeel; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.gui.ACheckBox; -import atlantis.gui.AParametersTable; -import atlantis.output.AExceptionHandler; -import atlantis.utils.AUtilities; - -/** - * The class is used as a default implementation of the AParameter interface. - * All parameters extend this class except ALinkParameter which implements - * AParameter directly. - */ -abstract class AAbstractParameter implements AParameter -{ - // range constants - protected final static int MIN = 0; - protected final static int MAX = 1; - protected final static int SVAL = 2; - - // unitsOf constants - protected final static int NOTHING = 0; - protected final static int LENGTH = 1; - protected final static int ENERGY = 2; - protected final static int ENERGYMEV = 3; - - /** - * List of listeners/observers to be informed of changes to parameters. - * Currently this is just the GUI, which repaints its tables when a parameter - * changes. - */ - private List<AParameterChangeListener> parameterChangeListeners = new ArrayList<AParameterChangeListener>(); - - /** The internal name of the parameter. */ - protected String name; - /** The name which is displayed in the user interface. */ - protected String screenName; - /** Tool tip, i.e. text that appears when mouse hovers over control. */ - protected String toolTip; - - protected boolean hasStatus; - protected int valueType; - protected int scope; - protected int defaultScope; - protected boolean isModulus; - protected int userLevel; - protected int unitsOf; - protected String[] operators; - /** Allowed values for this parameter: - * range[MIN][i] and range[MAX][i] are the limits of the i'th range; - * range[SVAL][j] is the j'th allowed single value. */ - protected double[][] range; - - private ACheckBox nameLabel; - private JLabel label; - private boolean isInitialized = false; - - /** The number of windows in the canvas. */ - protected int wCount = 0; // initialised later in constructor - - /** Contains the values for each window. */ - protected AParameterData data; - - @Override - public void addParameterChangeListener(AParameterChangeListener listener) { - parameterChangeListeners.add(listener); - } - - public AAbstractParameter(String name, String screenName, String toolTip, - int valueType, double value, String op, String dop, - boolean haseStatus, boolean status, boolean isMod, int userLevel, - int scope, int unitsOf) - { - // initialising wCount - // for running without Canvas (e.g. calling geometry methods from GraXML), - // this may run without Canvas initialised - // check if Canvas actually exists - // dependency of AAbstractParameter on ACanvas should be revised, this - // current solution is not very elegant - ACanvas canvas = ACanvas.getCanvas(); - this.wCount = canvas == null ? 0 : canvas.getWindowsCount(); - - this.isModulus = isMod; - this.unitsOf = unitsOf; - - if (!screenName.trim().equals("")) - this.screenName = screenName; - else - this.screenName = name; - - if (isMod) - this.screenName = "|" + this.screenName + "|"; - - // removing spaces from the parameter name - StringBuffer strBuffer = new StringBuffer(name); - int i = 0; - - while (i < strBuffer.length()) - { - if (Character.isWhitespace(strBuffer.charAt(i))) - strBuffer.deleteCharAt(i); - else - i++; - } - this.name = strBuffer.toString(); - - if ((toolTip == null) || (toolTip.trim().length() == 0)) - this.toolTip = this.screenName; - else - this.toolTip = toolTip; - - this.hasStatus = haseStatus; - this.valueType = valueType; - - // set up the local window copies - this.data = new AParameterData(wCount); - - for (i = 0; i < wCount; i++) - { - this.data.setValue(i, value); - this.data.setStatus(i, status); - } - - // decompose supportedOperators - if ((op == null) || (op.trim().equals(""))) - { - this.operators = new String[1]; - operators[0] = "="; - } - else - { - String[] tempOperators = new String[10]; - - int operatorsCount = 0; - StringTokenizer st = new StringTokenizer(op, ","); - - while (st.hasMoreTokens()) - { - String oper = st.nextToken().trim(); - - if (isKnownOperator(oper)) - { - tempOperators[operatorsCount] = oper; - operatorsCount++; - } - else - throw new Error("Unknown operator: " + oper); - } - - this.operators = new String[operatorsCount]; - for (i = 0; i < operatorsCount; i++) - this.operators[i] = tempOperators[i]; - } - - if ((dop == null) || (dop.trim().equals(""))) - for (i = 0; i < wCount; i++) - this.data.setOperator(i, operators[0]); - else - for (i = 0; i < wCount; i++) - this.data.setOperator(i, dop); - - this.userLevel = userLevel; - setScope(scope); - saveDefaults(); - } - - public void saveDefaults() - { - this.data.saveDefaults(); - this.defaultScope = this.scope; - } - - public void restoreDefaults() - { - this.data.restoreDefaults(); - changeScope(this.defaultScope); - } - - /** - * This method is called to apply the change in the value of the parameter - */ - public void apply() - { - if (getScope() == LOCAL) - ACommandProcessor.receive("DO"); - else - ACanvas.getCanvas().repaintAllFromScratch(); - } - - /** - * Called by the User Interface in order to initialize the graphics of the - * parameter (if it will be displayed in the UI). - */ - public void initialize() - { - if (hasStatus) - { - nameLabel = new ACheckBox(screenName); - nameLabel.setSelected(getStatus()); - nameLabel.setBackground(new Color(204, 204, 204)); - if (getScope() == LOCAL) - setForeground(Color.black); - else - setForeground(Color.blue); - - nameLabel.setToolTipText(toolTip); - nameLabel.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - ACommandProcessor.receive(name); - apply(); - } - }); - - // after the first left click at the table in the parameter tabbed - // pane, all the followingmouse mouse event will be catched by the - // mouselisteners of those components inside the table cells, not - // the table itself, so in order for the local/global - // switch (right click to change) to always work, have to add mouse - // listeners to these components as well. - nameLabel.addMouseListener(new MouseAdapter() - { - public void mousePressed(MouseEvent e) - { - if (AUtilities.isRightMouseButton(e)) - { - JPopupMenu popupMenu = new JPopupMenu(); - if (getScope() == AParameter.LOCAL) - { - popupMenu.add(AParametersTable.SET_GLOBAL).addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - changeScope(AParameter.GLOBAL); - refresh(); - } - }); - } - else - { - popupMenu.add(AParametersTable.SET_LOCAL).addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - changeScope(AParameter.LOCAL); - refresh(); - } - }); - } - popupMenu.show(nameLabel, e.getX(), e.getY()); - } - } - }); - } - else - { - label = new JLabel(screenName); - if (getScope() == LOCAL) - setForeground(Color.black); - else - setForeground(Color.blue); - - // after the first left click at the table in the parameter tabbed - // pane, all the followingmouse mouse event will be catched by the - // mouselisteners of those components inside the table cells, not - // the table itself, so in order for the local/global - // switch (right click to change) to always work, have to add mouse - // listeners to these components as well. - label.addMouseListener(new MouseAdapter() - { - public void mousePressed(MouseEvent e) - { - if (AUtilities.isRightMouseButton(e)) - { - JPopupMenu popupMenu = new JPopupMenu(); - if (getScope() == AParameter.LOCAL) - { - popupMenu.add(AParametersTable.SET_GLOBAL).addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - changeScope(AParameter.GLOBAL); - refresh(); - } - }); - } - else - { - popupMenu.add(AParametersTable.SET_LOCAL).addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - changeScope(AParameter.LOCAL); - refresh(); - } - }); - } - popupMenu.show(label, e.getX(), e.getY()); - } - } - }); - label.setOpaque(true); - label.setToolTipText(toolTip); - LookAndFeel.installColorsAndFont(label, "CheckBox.background", "CheckBox.foreground", "CheckBox.font"); - } - - isInitialized = true; - } - - public boolean isInitialized() - { - return this.isInitialized; - } - - /** - * Copies from one window to another the value of the parameter - */ - public void copy(int from, int to) - { - data.copy(from,to); - } - - /** - * This function is called for GLOBAL parameters to apply the value in all - * windows. - */ - public void globalize(int window) - { - data.globalize(window); - } - - public void setScope(int scope) - { - this.scope = scope; - if (scope == LOCAL) - setForeground(Color.black); - else - setForeground(Color.blue); - } - - public void changeScope(int scope) - { - if (scope != this.scope) - { - this.scope = scope; - if (scope == LOCAL) - setForeground(Color.black); - else - { - setForeground(Color.blue); - data.globalize(); - ACanvas.getCanvas().repaintAllFromScratch(); - } - } - } - - public int getScope() - { - return scope; - } - - public String getName() - { - return name; - } - - public String getScreenName() - { - return screenName; - } - - public String getToolTip() - { - return toolTip; - } - - // public String getOperator() { return operator; } - public boolean isModulus() - { - return isModulus; - } - - public int getValueType() - { - return valueType; - } - - public String getOperator() - { - return data.getOperator(); - } - - protected void _setOperator(String oper) - { - // if (!validateValue(v)) - // throw new Error("Value " + v + " for parameter " + screenName + " is - // out of range "); - data.setOperator(oper); - if (scope == GLOBAL) data.globalize(); - } - - protected void _setOperator(String windowName, String oper) - { - if (scope == GLOBAL || windowName.equals("*")) { - data.setOperator(oper); - data.globalize(); - } else { - data.setOperator(ACanvas.getCanvas().getWindow(windowName).getIndex(), oper); - } - } - - protected void _setValue(String windowName, double val) - { - if (scope == GLOBAL || windowName.equals("*")) { - data.setValue(val); - data.globalize(); - } else { - data.setValue(ACanvas.getCanvas().getWindow(windowName).getIndex(), val); - } - } - - protected void _setStatus(String windowName, boolean stat) - { - if (scope == GLOBAL || windowName.equals("*")) { - data.setStatus(stat); - data.globalize(); - } else { - data.setStatus(ACanvas.getCanvas().getWindow(windowName).getIndex(), stat); - } - } - - /** - * _setD and _setI are used by subclasses when changing the values of - * parameters. - */ - protected void _setD(double v) - { - if (!validateValue(v)) - throw new Error("Value " + v + " for parameter " + screenName + " is out of range "); - data.setValue(v); - if (scope == GLOBAL) data.globalize(); - } - - protected void _setI(int v) - { - if (!validateValue(v)) - throw new Error("Value " + v + " for parameter " + screenName + " is out of range "); - data.setValue(v); - if (scope == GLOBAL) data.globalize(); - } - - public double getD() - { - if (valueType != FLOAT) - throw new Error("getD acces on not FLOAT parameter"); - return data.getValue(); - } - - public int getI() - { - if (valueType != INT) - throw new Error("getI acces on not INT parameter"); - return (int) data.getValue(); - } - - public String getValue() - { - if (valueType == FLOAT) - return Double.toString(data.getValue()); - else - return Integer.toString((int) data.getValue()); - } - - public void setStatus(boolean st) - { - if (!hasStatus) - throw new Error("Parameter has no status"); - data.setStatus(st); - if (scope == GLOBAL) data.globalize(); - - refresh(); - fireParameterChanged(); - } - - public boolean getStatus() - { - if (!hasStatus) - throw new Error("Parameter hase no status"); - - return data.getStatus(); - } - - public JComponent getNameComponent() - { - if (hasStatus) - return nameLabel; - else - return label; - } - - public JComponent getValueComponent() - { - return new JLabel("error"); - } - - protected void _refresh() - { - if (hasStatus) - if (nameLabel != null) - nameLabel.setSelected(getStatus()); - } - - /** - * Parses the PossibleValues string and returns the double[][] containing - * the range of this parameter. - */ - protected static double[][] resolvePossibleValues(String possibleValues, int type) - { - double[][] range = new double[3][100]; - int valCount = 0; - int rangeCount = 0; - StringTokenizer st = new StringTokenizer(possibleValues, ","); - String sval; - double val = 0; - - while (st.hasMoreTokens()) - { - String token = st.nextToken().trim(); - StringTokenizer st1 = new StringTokenizer(token, ":"); - - switch (st1.countTokens()) - { - case 1: - sval = st1.nextToken().trim(); - try - { - if (type == FLOAT) - val = Double.parseDouble(sval); - else if (type == INT) - val = Integer.parseInt(sval); - range[SVAL][valCount] = val; - valCount++; - } - catch (NumberFormatException nfe) - { - AExceptionHandler.processException("Corrupt Possible Value: " + sval, nfe); - } - break; - - case 2: - for (int i = 0; i < 2; i++) - { - sval = st1.nextToken().trim(); - try - { - if (type == FLOAT) - val = Double.parseDouble(sval); - else if (type == INT) - val = Integer.parseInt(sval); - } - catch (NumberFormatException nfe) - { - if (sval.equals("inf")) - val = Double.POSITIVE_INFINITY; - else if (sval.equals("-inf")) - val = Double.NEGATIVE_INFINITY; - else - AExceptionHandler.processException("Corrupt Possible Range: (" + token + ")", nfe); - } - range[i][rangeCount] = val; - } - rangeCount++; - break; - - default: - AExceptionHandler.processException("fatal", "Corrupt \"pv\" definition: \"" + possibleValues + "\""); - break; - } - } - - double[] min = new double[rangeCount]; - double[] max = new double[rangeCount]; - - for (int i = 0; i < rangeCount; i++) - if (range[MIN][i] <= range[MAX][i]) - { - min[i] = range[MIN][i]; - max[i] = range[MAX][i]; - } - else - throw new Error("Bad range definiton: (" + range[0][i] + ":" + range[1][i] + ")"); - - double[] v = new double[valCount]; - - for (int i = 0; i < valCount; i++) - v[i] = range[SVAL][i]; - - range[MIN] = min; - range[MAX] = max; - range[SVAL] = v; - return range; - } - - protected static int[] getValues(String possibleValues) - { - int[] pVal = new int[100]; - int[] range = new int[2]; - int i, valCount = 0; - String token; - StringTokenizer st, st1; - - st = new StringTokenizer(possibleValues, ","); - while (st.hasMoreTokens()) - { - token = st.nextToken().trim(); - st1 = new StringTokenizer(token, ":"); - switch (st1.countTokens()) - { - case 1: - try - { - pVal[valCount++] = Integer.parseInt(st1.nextToken().trim()); - } - catch (NumberFormatException nfe) - { - AExceptionHandler.processException("Corrupt Possible Value", nfe); - } - break; - - case 2: - for (i = 0; i < 2; i++) - try - { - range[i] = Integer.parseInt(st1.nextToken().trim()); - } - catch (NumberFormatException nfe) - { - AExceptionHandler.processException("fatal", "error in range definition"); - } - - if (range[0] <= range[1]) - for (i = range[0]; i <= range[1]; i++) - pVal[valCount++] = i; - break; - - default: - AExceptionHandler.processException("fatal", "Corrupt range definition: \"" + possibleValues + "\""); - } - } - - int[] pValFinal = new int[valCount]; - - for (i = 0; i < valCount; i++) - pValFinal[i] = pVal[i]; - - return pValFinal; - } - - public boolean processCommand(String oper, double v) - { - // first I validate the operator and the value - if (!validateOperator(oper)) - return false; - if (!validateValue(v)) - return false; - - if (valueType == FLOAT) - _setD(v); - else - _setI((int) v); - - _setOperator(oper); - - refresh(); - fireParameterChanged(); - - return true; - } - - public boolean validateValue(double v) - { - if (range[SVAL] != null) - for (int i = 0; i < range[SVAL].length; i++) - if (v == range[SVAL][i]) - return true; - - if (range[MIN] != null) - for (int i = 0; i < range[MIN].length; i++) - if ((v >= range[MIN][i]) && (v <= range[MAX][i])) - return true; - - return false; - } - - public boolean validateOperator(String oper) - { - for (int i = 0; i < operators.length; i++) - if (oper.equals(operators[i])) - return true; - - return false; - } - - public int getUserLevel() - { - return userLevel; - } - - - public String toString() - { - StringBuilder s = new StringBuilder(screenName + ": "); - - if (scope == GLOBAL) - s.append("GLOBAL"); - else if (scope == LOCAL) - s.append("LOCAL"); - - s.append("["); - - // for running without Canvas (e.g. calling geometry methods from GraXML), - // this may run without Canvas initialised - // check if Canvas actually exists - // dependency of AAbstractParameter on ACanvas should be revised, this - // current solution is not very elegant - ACanvas canvas = ACanvas.getCanvas(); - String[] wName = canvas == null ? new String[0] : canvas.getKnownWindowNames(); - - for (int i = 0; i < wName.length; i++) - { - AWindow w = ACanvas.getCanvas().getWindow(wName[i]); - - s.append(wName[i] + ": " + data.getValue(w.getIndex()) + ": "); - } - - return s.toString() + "]" + " :" + toolTip + ":"; - } - - - private final void setForeground(Color color) - { - if (getNameComponent() != null) - getNameComponent().setForeground(color); - } - - public String getDifferences(String groupName) - { - StringBuffer b = new StringBuffer(); - String[] windowNames = ACanvas.getCanvas().getKnownWindowNames(); - int[] inverse = new int[windowNames.length]; - for (int i = 0; i < windowNames.length; i++) - inverse[ACanvas.getCanvas().getWindow(windowNames[i]).getIndex()] = i; - - for (int i = 0; i < wCount; ++i) - { - if (data.getStatus() != data.getStatus(i) || !data.getOperator().equals(data.getOperator(i)) || data.getValue() != data.getValue(i)) - { - - b.append("\t\t<DIFFERENCE group=\"" + groupName + "\" name=\"" + getName() + "\" windowName=\"" + windowNames[inverse[i]] + "\""); - - if (data.getValue() != data.getValue(i)) - b.append(" va=\"" + data.getValue(i) + "\""); - if (data.getStatus() != data.getStatus(i)) - { - if (data.getStatus(i)) - b.append(" st=\"ON\""); - else - b.append(" st=\"OFF\""); - } - if (!data.getOperator().equals(data.getOperator(i))) - b.append(" op=\"" + data.getOperator(i) + "\""); - b.append("/>\n"); - } - } - return b.toString(); - } - - protected double parseUnitsDouble(String text) - { - // units shown are cm - if (unitsOf == LENGTH) - { - if (text.endsWith("MM") || text.endsWith("mm")) - return 0.1 * Double.parseDouble(text.substring(0, text.length() - 2)); - if (text.endsWith("CM") || text.endsWith("cm")) - return Double.parseDouble(text.substring(0, text.length() - 2)); - if (text.endsWith("UM") || text.endsWith("um")) - return 0.0001 * Double.parseDouble(text.substring(0, text.length() - 2)); - else if (text.endsWith("M") || text.endsWith("m")) - return 100. * Double.parseDouble(text.substring(0, text.length() - 1)); - else - return Double.parseDouble(text.substring(0, text.length())); - } - else if (unitsOf == ENERGY) - { - if (text.endsWith("GeV") || text.endsWith("gev") || text.endsWith("GEV")) - return Double.parseDouble(text.substring(0, text.length() - 3)); - else if (text.endsWith("MeV") || text.endsWith("mev") || text.endsWith("MEV")) - return .001 * Double.parseDouble(text.substring(0, text.length() - 3)); - else - return Double.parseDouble(text); - } - else if (unitsOf == ENERGYMEV) - { - if (text.endsWith("MeV") || text.endsWith("mev") || text.endsWith("MEV")) - return Double.parseDouble(text.substring(0, text.length() - 3)); - else if (text.endsWith("KeV") || text.endsWith("kev") || text.endsWith("KEV")) - return .001 * Double.parseDouble(text.substring(0, text.length() - 3)); - else if (text.endsWith(" eV") || text.endsWith(" ev") || text.endsWith(" EV")) - return .000001 * Double.parseDouble(text.substring(0, text.length() - 3)); - else - return Double.parseDouble(text); - } - else - { - return Double.parseDouble(text); - } - } - - protected String parseUnits(double d) - { - // units shown are cm - double abs = Math.abs(d); - if (unitsOf == LENGTH) - { - if (abs >= 100.) - return "" + trim(d, 100.) + " m"; - else if (abs >= 1.) - return "" + trim(d, 1.) + " cm"; - else if (abs >= 0.1) - return "" + trim(d, 0.1) + " mm"; - else - return "" + trim(d, 0.0001) + " um"; - } - else if (unitsOf == ENERGY) - { - if (abs >= 1.) - return "" + trim(d, 1.) + " GeV"; - else - return "" + trim(d, 0.001) + " MeV"; - } - else if (unitsOf == ENERGYMEV) - { - if (abs >= 1.) - return "" + trim(d, 1.) + " MeV"; - else if(abs >=0.001) - return "" + trim(d, 0.001) + " KeV"; - else - return "" + trim(d, 0.000001) + " eV"; - } - else - { - return "" + trim(d, 1.); - } - } - - private String trim(double d, double factor) - { - // only display with 3 significant digits - if (unitsOf == LENGTH && Math.abs(d) < .1) - return "" + Math.rint(d / factor); - else if (unitsOf == ENERGY && Math.abs(d) < 1.) - return "" + Math.rint(d / factor); - else if (unitsOf == ENERGYMEV && Math.abs(d) < 1.) - return "" + Math.rint(d / factor); - else - return "" + Math.rint(1000. * d / factor) / 1000.; - } - - public ACheckBox getCheckBox() - { - return this.nameLabel; - } - - /** - * Check if a given operator is one of the allowed supportedOperators. - * @param oper the operator to check - * @return true if this is a known operator - */ - protected static boolean isKnownOperator(String oper) - { - for(int i=0; i<AParameter.supportedOperators.length; i++) - if(oper.equals(AParameter.supportedOperators[i])) - return true; - - return false; - } - - /** - * Tell the listeners that a parameter has changed. - */ - protected void fireParameterChanged() { - for (AParameterChangeListener listener : parameterChangeListeners) { - listener.parameterChanged(this); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AColorParameter.java b/graphics/AtlantisJava/src/atlantis/parameters/AColorParameter.java deleted file mode 100755 index 34972e6e189101ad75145cf5cc8e2564ca6eef01..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AColorParameter.java +++ /dev/null @@ -1,92 +0,0 @@ -package atlantis.parameters; - -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import javax.swing.JComponent; - -import atlantis.gui.AColorComboBoxRenderer; -import atlantis.gui.AComboBox; - -/** - * A parameter representing a selectable colour. - */ -public class AColorParameter extends AAbstractParameter { - private AComboBox colorComboBox; - - public AColorParameter( - String name, String screenName, String toolTip, String pv, double value, - boolean haseStatus, boolean status, int userLevel, int scope) { - - super(name, screenName, toolTip, INT, value, null, null, haseStatus, status, false, userLevel, - scope, NOTHING); - - range=resolvePossibleValues(pv, INT); - if((range[SVAL]==null)&&(range[MIN]==null)) { - range[MIN]=new double[] {0}; - range[MAX]=new double[] {29}; - } - - } - - public void setD(double v) { - throw new IllegalArgumentException("is not allowed to use setD on ColorParameter"); - } - - public void setI(int v) { - if(colorComboBox!=null) - colorComboBox.setGUISelectedItem(new Integer(v)); - - _setI(v); - refresh(); - fireParameterChanged(); - } - - public void initialize() { - super.initialize(); - colorComboBox=new AComboBox(); - colorComboBox.setRenderer(new AColorComboBoxRenderer()); - colorComboBox.setToolTipText(toolTip); - - int i, j; - - for(i=0; i<range[SVAL].length; i++) { - int color=(int)range[SVAL][i]; - - if((color>=0)&&(color<=29)) - colorComboBox.addItem(new Integer(color)); - } - - for(i=0; i<range[MIN].length; i++) { - int color1=(int)range[MIN][i]; - int color2=(int)range[MAX][i]; - - if((color1>=0)&&(color1<=29)&&(color2>=0)&&(color2<=29)) - for(j=color1; j<=color2; j++) - colorComboBox.addItem(new Integer(j)); - } - - colorComboBox.setGUIItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(e.getStateChange()==ItemEvent.SELECTED) { - int color=((Integer)colorComboBox.getSelectedItem()).intValue(); - - ACommandProcessor.receive(name+"="+color); - apply(); - } - } - }); - - colorComboBox.setGUISelectedItem(new Integer(getI())); - } - - public JComponent getValueComponent() { - return colorComboBox; - } - - public void refresh() { - _refresh(); - if(colorComboBox!=null) - colorComboBox.setGUISelectedItem(new Integer(getI())); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/ACommand.java b/graphics/AtlantisJava/src/atlantis/parameters/ACommand.java deleted file mode 100755 index 1ae57ad8ffcfe7fcd3e91990694100eb3dd864c5..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/ACommand.java +++ /dev/null @@ -1,31 +0,0 @@ -package atlantis.parameters; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.JButton; - -/** - * This class is a GUI representation of a command button. - * It just generates the corresponding command when pressed. - */ -public class ACommand extends JButton { - private String command; - - ACommand(String name, String _command, String toolTip) { - super(name); - - this.command=_command; - - setToolTipText(toolTip); - addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - ACommandProcessor.receive(command); - } - }); - } - - public String getName() { - return getText(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/ACommandProcessor.java b/graphics/AtlantisJava/src/atlantis/parameters/ACommandProcessor.java deleted file mode 100755 index 9c023708c66c24986c67e125a370b67aa093b254..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/ACommandProcessor.java +++ /dev/null @@ -1,451 +0,0 @@ -package atlantis.parameters; - -import java.util.Vector; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.event.AEventManager; -import atlantis.event.AFilter; -import atlantis.data.AS3DData; -import atlantis.data.ATrackData; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.projection.AProjection; -import atlantis.utils.ALogger; - -/** - * (almost?) All actions on the GUI generate a command (which is basically a - * text string) which is passed to the command processor which performs the - * actions associated with that command. This should allow a simple - * implementation of scripting and logging - * - * NOTE: This design has been dramatically neglected in the past and should - * probably be revised (Sebastian Boeser, 06.10.09) - */ - -public class ACommandProcessor -{ - private static ALogger logger = ALogger.getLogger(ACommandProcessor.class); - private static AEventManager eventManager = AEventManager.instance(); - - private static String legoLayoutName =""; - private static String[] legoWindowNames = {"current", "W", "1", "2", "3", "4"}; - private final static String[] legoStatusParameterNames = {"DrawPlot", "MainLegend", "L1EtLegend", "L1Items", "L2Items", "EFItems"}; - private final static String[] legoIntParameterNames = {"Mode", "nphicells", "netacells"}; - private final static String[] legoCaloParameterNames = {"LAr", "TILE", "FCAL", "MBTS"}; - private static boolean[][] legoStatusParameter = new boolean[6][6]; - private static int[][] legoIntParameter = new int[6][3]; - private static boolean[][] legoCaloParameter = new boolean[2][4]; - - private static APar parameterStore = APar.instance(); - - /** - * While this is called receive, it is actually just a small wrapper to - * processes a command and at the same time log it - * @param command the command to process - */ - public synchronized static void receive(String command) - { - //In debug mode show the command - logger.debug("ACommandProcessor.receive(): " + command); - //In trace mode show also who called this - logger.trace("Calling hierarchy",new Exception()); - - //Now process the command - boolean status = process(command); - - //And log the result - logger.debug( ((status)?" success: ":" bad command:") + command); - - } - - - - private synchronized static boolean process(String c) - { - - if (processGlobal(c)) - { - return true; - } - - AProjection p = ACanvas.getCanvas().getCurrentWindow().getProjection(); - // projection dependent command could be processed here - if (p.processLocalCommand(c)) - { - return true; - } - - if (parameterStore.processParameterChangeCommand(c)) - { - return true; - } - - return false; - } - - // used for checking all command are implemented - private synchronized static boolean found(int mode, String name, String command) - { - if (mode != 0) - { - logger.warn("Command not found: " + command); - return false; - } - if (name.equals(command)) - return true; - return false; - } - - private synchronized static boolean foundWindow(int mode, String name, String command) - { - if (mode != 0) - { - String[] windowNames = ACanvas.getCanvas().getKnownWindowNames(); - - for (int i = 0; i < windowNames.length; ++i) - logger.debug(command + windowNames[i]); - return false; - } - - if (name.substring(0, name.length() - 1).equals(command)) - if (ACanvas.getCanvas().isValidWindowName(name.substring(name.length() - 1))) - if (ACanvas.getCanvas().getWindow(name.substring(name.length() - 1)) != null) - return true; - return false; - } - - private synchronized static boolean processGlobal(String c) - { - return processGlobal(c, 0); - } - - private static void getGlobalCommands() - { - processGlobal("GARY", 1); - } - - private static boolean processZoomTrack(String name, int mode) - { - ATrackData tr = null; - - // check if STr (Simulated Track) Zoom Next Track was pressed - if(found(mode, name, "ZOOMNEXTSTR")) - { - tr = eventManager.getCurrentEvent().getSTrData(); - } - // check if Track (InDetTrack) Zoom Next Track was pressed - else if(found(mode, name, "ZOOMNEXTTRACK")) - { - AEnumeratorParameter listBox = null; - listBox = (AEnumeratorParameter) parameterStore.get("InDetTrack", "InDetTrackCollections"); - String col = listBox.getCurrentText(); - if("All".equals(col)) - { - String msg = "Choose a particular Track collection, " + - "can't zoom next track when 'All' is selected.\n"; - AOutput.alwaysAppend(msg, ALogInterface.WARNING); - return false; - } - else - { - tr = eventManager.getCurrentEvent().getTrackData("InDetTrack", col); - } - } - - if(tr == null) - { - // STr or Track of requested collection doesn't exits in this event - return false; - } - - // check if the datatype where Zoom Next Track was pressed is actually - // turned on and thus visible - if(! parameterStore.get("Data", tr.getName()).getStatus()) - { - AOutput.alwaysAppend("Can't zoom next track, " + tr.getNameScreenName() + - " is turned off.\n", ALogInterface.WARNING); - return false; - } - - AParameter nextTrPar = parameterStore.get(tr.getName(), "NextTrack"); - nextTrPar.setStatus(true); - nextTrPar.setI(nextTrPar.getI() + 1); - tr.zoomAroundTracks(); - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - - AOutput.alwaysAppend(tr.getNameScreenName() + " -> Next Track cut active now.\n", - ALogInterface.WARNING); - - return true; - - } // processZoomTrack() - // --------------------------------------------------- - - private synchronized static boolean processGlobal(String name, int mode) - { - // is this a group in the parameter file ? - Vector<String> groups = parameterStore.getUIGroupNames(); - for (int i = 0; i < groups.size(); ++i) - { - String groupName = groups.elementAt(i); - if (found(mode, name, groupName + ".")) - { - ACanvas.getCanvas().getCurrentWindow().setGroup(groupName); - return true; - } - } - - if(found(mode, name, "SETORIGINALPRIMARYVERTEX")) - { - eventManager.getCurrentEvent().setPrimaryVertex(); - ACanvas.getCanvas().repaintAllFromScratch(); - } - - - if (found(mode, name, "LEGOTRIGGER")) - { - processLegoTrigger(); - return true; - } - - if (found(mode, name, "RETURNLEGOTRIGGER")) - { - if(legoLayoutName.equals("")) - { - AOutput.append("No trigger debugging to return from\n", ALogInterface.NORMAL); - return true; - } - - returnLegoTrigger(); - return true; - } - - if (found(mode, name, "PREVSECTOR")) - { - AParameter phi = parameterStore.get("YZ", "Phi"); - phi.setD(((Math.round(phi.getD()/22.5) + 15) % 16) * 22.5); - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - return true; - } - - if (found(mode, name, "NEXTSECTOR")) - { - AParameter phi = parameterStore.get("YZ", "Phi"); - phi.setD(((Math.round(phi.getD()/22.5) + 1) % 16) * 22.5); - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - return true; - } - - if (found(mode, name, "ZOOMNEXTSTR") || found(mode, name, "ZOOMNEXTTRACK")) - { - return processZoomTrack(name, mode); - } - - if (found(mode, name, "PC")) - { - getGlobalCommands(); - return true; - } - if (found(mode, name, "DO")) - { - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - return true; - } - - // turning all datatypes on/off command: - see code which was - // commented out in AtlantisJava-09-05-71 and before - - // Toggle: PT,D0,Z0,NU off:NG,NB,NS,NR,SH - if (found(mode, name, "CC")) - { - if (parameterStore.get("CutsInDet", "z0-zVtx").getStatus()) - { - parameterStore.get("CutsInDet", "z0-zVtx").setStatus(false); - parameterStore.get("CutsInDet", "d0").setStatus(false); - parameterStore.get("CutsInDet", "Pt").setStatus(false); - parameterStore.get("CutsInDet", "NumS3D").setStatus(false); - } - else - { - parameterStore.get("CutsInDet", "z0-zVtx").setStatus(true); - parameterStore.get("CutsInDet", "d0").setStatus(true); - parameterStore.get("CutsInDet", "Pt").setStatus(true); - parameterStore.get("CutsInDet", "NumS3D").setStatus(true); - } - parameterStore.get("CutsInDet", "RTrIndex").setStatus(false); - parameterStore.get("CutsInDet", "STr").setStatus(false); - parameterStore.get("CutsInDet", "Group").setStatus(false); - parameterStore.get("CutsATLAS", "Index").setStatus(false); - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - return true; - } - if (found(mode, name, "FH")) - { - //Try to get SpacePoints - AS3DData spacePoints = (AS3DData) eventManager.getCurrentEvent().get("S3D"); - //Apply Hans Drevermanns hit filter - if (spacePoints != null){ - AFilter.filter(spacePoints); - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - } - return true; - } - if (foundWindow(mode, name, "W")) - { - ACanvas.getCanvas().setCurrentWindow(name.substring(1, 2)); - return true; - } - if (foundWindow(mode, name, "C")) - { - return true; - } - if (foundWindow(mode, name, "Z")) - { - return true; - } - return false; - } // processGlobal() ------------------------------------------------------ - - private synchronized static void processLegoTrigger() - { - String currentWindowName = ACanvas.getCanvas().getCurrentWindowName(); - String currentLayoutName = ACanvas.getCanvas().getCurrentLayout().getName(); - - //save status of windows on first time button pressed - if(legoLayoutName.equals("")) - { - //output message to the user - AOutput.append("\nWindows changed to:\n",ALogInterface.TITLE); - AOutput.append("Window 1: LegoPlot with Calo View\n", ALogInterface.NORMAL); - AOutput.append("Window 2: LegoPlot with Trigger Tower View\n", ALogInterface.NORMAL); - AOutput.append("Window 3: LegoPlot with Jet Element View\n", ALogInterface.NORMAL); - AOutput.append("Window 4: LegoPlot Legend (may not be displayed if window too small)\n", ALogInterface.NORMAL); - //save current window name and layout to then parameters to restore later - legoWindowNames[0]=currentWindowName; - legoLayoutName=currentLayoutName; - for(int i=0; i<legoWindowNames.length; i++) - { - parameterStore.selectWindowParameters(legoWindowNames[i]); - if (ACanvas.getCanvas().getWindow(legoWindowNames[i]) != null) - { - //save lego status parameters - for(int j=0; j<legoStatusParameterNames.length; j++){ - legoStatusParameter[i][j]=parameterStore.get("LegoPlot", legoStatusParameterNames[j]).getStatus(); - } - //save lego int parameters - for(int j=0; j<legoIntParameterNames.length; j++){ - legoIntParameter[i][j]=parameterStore.get("LegoPlot", legoIntParameterNames[j]).getI(); - } - //save data parameters for windows 1 and 4 - if(legoWindowNames[i].equals("1")){ - for(int j=0; j<legoCaloParameterNames.length; j++){ - legoCaloParameter[0][j]=parameterStore.get("Data", legoCaloParameterNames[j]).getStatus(); - } - }else if(legoWindowNames[i].equals("4")){ - for(int j=0; j<legoCaloParameterNames.length; j++){ - legoCaloParameter[1][j]=parameterStore.get("Data", legoCaloParameterNames[j]).getStatus(); - } - } - } - parameterStore.restoreWindowParameters(); - } - } - //copy to W to make sure can switch layout to 4 squares - ACanvas.getCanvas().copyWindowSettings(currentWindowName, "W"); - if(!currentLayoutName.equals("FOUR SQUARES")) - ACanvas.getCanvas().setCurrentLayout("FOUR SQUARES"); - //for cell sizing take defaults values and then roughly scaled for different views - int nphicells = 128; - int netacells = 200; - //now copy to each window and set the display correctly - for (int i = 0; i < 4; i++) - { - String wName = Integer.toString(i + 1); - AWindow w = ACanvas.getCanvas().getWindow(wName); - parameterStore.selectWindowParameters(wName); - if (w != null) - { - ACanvas.getCanvas().copyWindowSettings("W", wName); - //first 3 windows show data items (calo, trigger towers, jet elements) - if(i<3) - { - parameterStore.get("LegoPlot", "Mode").setI(i); - parameterStore.get("LegoPlot", "DrawPlot").setStatus(true); - parameterStore.get("LegoPlot", "MainLegend").setStatus(false); - parameterStore.get("LegoPlot", "L1EtLegend").setStatus(false); - parameterStore.get("LegoPlot", "L1Items").setStatus(false); - parameterStore.get("LegoPlot", "L2Items").setStatus(false); - parameterStore.get("LegoPlot", "EFItems").setStatus(false); - parameterStore.get("LegoPlot", "nphicells").setI(nphicells/((int) Math.pow(2.0, i))); - parameterStore.get("LegoPlot", "netacells").setI(netacells/((int) Math.pow(2.0, i))); - } - else - { - //last window shows legend - parameterStore.get("LegoPlot", "DrawPlot").setStatus(false); - parameterStore.get("LegoPlot", "MainLegend").setStatus(true); - parameterStore.get("LegoPlot", "L1EtLegend").setStatus(true); - parameterStore.get("LegoPlot", "L1Items").setStatus(true); - parameterStore.get("LegoPlot", "L2Items").setStatus(true); - parameterStore.get("LegoPlot", "EFItems").setStatus(true); - } - //if first or last window it needs the data items turned on - if(i==0 || i==3) - { - for(int j=0; j<legoCaloParameterNames.length; j++){ - parameterStore.get("Data", legoCaloParameterNames[j]).setStatus(true); - } - } - } - parameterStore.restoreWindowParameters(); - ACanvas.getCanvas().moveToFrontWindow(w.getName()); - w.repaintFromScratch(); - - } - } - - private synchronized static void returnLegoTrigger() - { - //now will reset the parameters explictly set by trigger debug mode - //others may be changed as on doing trigger debug others might get changed - //when the current window is copied to W but these have been changed by the - //user so not so important to reset - - //loop backwards so can reset each window before reverting to previous layout - for(int i=legoWindowNames.length-1; i>=0; i--) - { - //reset the lego status parameters - parameterStore.selectWindowParameters(legoWindowNames[i]); - for(int j=0; j<legoStatusParameterNames.length; j++){ - parameterStore.get("LegoPlot", legoStatusParameterNames[j]).setStatus(legoStatusParameter[i][j]); - } - //reset the lego int parameters - for(int j=0; j<legoIntParameterNames.length; j++){ - parameterStore.get("LegoPlot", legoIntParameterNames[j]).setI(legoIntParameter[i][j]); - } - //reset the data ites for windows 1 and 4 - if(legoWindowNames[i].equals("1")){ - for(int j=0; j<legoCaloParameterNames.length; j++){ - parameterStore.get("Data", legoCaloParameterNames[j]).setStatus(legoCaloParameter[0][j]); - } - }else if(legoWindowNames[i].equals("4")){ - for(int j=0; j<legoCaloParameterNames.length; j++){ - parameterStore.get("Data", legoCaloParameterNames[j]).setStatus(legoCaloParameter[1][j]); - } - } - parameterStore.restoreWindowParameters(); - //finished altering window so repaint - ACanvas.getCanvas().getWindow(legoWindowNames[i]).repaintFromScratch(); - //have just finished W window so now can reset the layout - if(i==1){ - ACanvas.getCanvas().setCurrentLayout(legoLayoutName); - legoLayoutName=""; - } - } - //everything reset now make the original window where trigger debug - //was started the current window - ACanvas.getCanvas().setCurrentWindow(legoWindowNames[0]); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/ACutParameter.java b/graphics/AtlantisJava/src/atlantis/parameters/ACutParameter.java deleted file mode 100755 index 490114e3e659c74948a81454c61da549a6ee3f98..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/ACutParameter.java +++ /dev/null @@ -1,171 +0,0 @@ -package atlantis.parameters; - -import java.awt.Color; -import java.awt.event.*; -import javax.swing.*; - -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.utils.AUtilities; -import atlantis.gui.AMutableCheckBox; -import atlantis.gui.AParametersTable; -import atlantis.gui.ATextField; - -/** - * A parameter representing a cut on a variable. - */ -public class ACutParameter extends AAbstractParameter { - // name component - private AMutableCheckBox checkBox; - - // value component - private ATextField textField; - - private ActionListener statusActionListener, valueActionListener; - - public ACutParameter( - String name, String screenName, String toolTip, String pv, int valueType, double value, - String operators, String defOperator, boolean haseStatus, boolean status, boolean isMod, - int userLevel, int scope, int unitsOf) { - - super(name, screenName, toolTip, valueType, value, operators, defOperator, haseStatus, status, - isMod, userLevel, scope, unitsOf); - - range=resolvePossibleValues(pv, valueType); - } - - public void setD(double v) { - if(valueType!=FLOAT) throw new IllegalArgumentException("setD acces on not FLOAT parameter"); - - if(textField!=null) textField.setText(""+v); - _setD(v); - - refresh(); - } - - public void setI(int v) { - if(valueType!=INT) throw new IllegalArgumentException("setI acces on not INT parameter"); - - if(textField!=null) textField.setText(""+v); - _setI(v); - - refresh(); - } - - public void initialize() { - checkBox=new AMutableCheckBox(screenName); - checkBox.setToolTipText(toolTip); - if(getScope()==LOCAL) - checkBox.setForeground(Color.black); - else - checkBox.setForeground(Color.blue); - - for(int i=0; i<operators.length; i++) - checkBox.addItem(operators[i]); - - checkBox.finalizeConstruction(); - checkBox.setSelectedText(getOperator()); - - statusActionListener=new ActionListener() { - public void actionPerformed(ActionEvent e) { - ACommandProcessor.receive(name); - apply(); - } - }; - - valueActionListener=new ActionListener() { - public void actionPerformed(ActionEvent e) { - applyInput(); - } - }; - - checkBox.addStatusActionListener(statusActionListener); - checkBox.addTextActionListener(valueActionListener); - - // after the first left click at the table in the parameter tabbed pane, - // all the followingmouse mouse event will be catched by the mouselisteners of those - // components inside the table cells, not the table itself, so in order for the local/global - // switch (right click to change) to always work, have to add mouse listeners to these components - // as well. - checkBox.getCheckBox().addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - if(AUtilities.isRightMouseButton(e)) { - JPopupMenu popupMenu=new JPopupMenu(); - if(getScope()==AParameter.LOCAL) { - popupMenu.add(AParametersTable.SET_GLOBAL).addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - changeScope(AParameter.GLOBAL); - refresh(); - } - }); - } else { - popupMenu.add(AParametersTable.SET_LOCAL).addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - changeScope(AParameter.LOCAL); - refresh(); - } - }); - } - popupMenu.show(checkBox.getCheckBox(), e.getX(), e.getY()); - } - } - }); - - textField=new ATextField(); - textField.setToolTipText(toolTip); - - if(valueType==FLOAT) - textField.setText(""+getD()); - else - textField.setText(""+getI()); - - textField.addActionListener(valueActionListener); - - /* - textField.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent e) { - applyInput(); - } - }); - */ - } - - private void applyInput() { - try { - if(valueType==FLOAT) { - double v=parseUnitsDouble(textField.getText()); - - ACommandProcessor.receive(name+checkBox.getSelectedText()+v); - apply(); - } else { - int v=Integer.parseInt(textField.getText()); - - ACommandProcessor.receive(name+checkBox.getSelectedText()+v); - apply(); - } - } catch(NumberFormatException nfe) { - AOutput.append("value: "+textField.getText()+", is not correct!", ALogInterface.BAD_COMMAND); - } - } - - public JComponent getValueComponent() { - return textField; - } - - public JComponent getNameComponent() { - return checkBox; - } - - public void refresh() { - if(textField!=null) { - if(valueType==FLOAT) - textField.setText(parseUnits(getD())); - else - textField.setText(""+getI()); - } - if(checkBox!=null) checkBox.setStatus(getStatus()); - if(checkBox!=null) checkBox.setSelectedText(getOperator()); - fireParameterChanged(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AEnumeratorParameter.java b/graphics/AtlantisJava/src/atlantis/parameters/AEnumeratorParameter.java deleted file mode 100755 index 92cdc8019c756e2d385ecb6fe3a0328b8822280b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AEnumeratorParameter.java +++ /dev/null @@ -1,278 +0,0 @@ -package atlantis.parameters; - -import java.util.StringTokenizer; -import java.util.Hashtable; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import javax.swing.JComponent; - -import atlantis.output.AExceptionHandler; -import atlantis.gui.AComboBox; - - -/** - * A parameter that displays a finite list of possible values. - * Used to contain items in pTexts String[], reimplemented to contain items - * in Hash in order to be able to change the contents from event to event - * (because of the multiple collections cuts). - */ -public class AEnumeratorParameter extends AAbstractParameter -{ - private AComboBox comboBox; - private Hashtable<Integer, String> pTexts; - - - - public AEnumeratorParameter(String name, String screenName, String toolTip, - String possibleValues, double value, - boolean haseStatus, boolean status, - int userLevel, int scope) - { - super(name, screenName, toolTip, INT, value, null, null, haseStatus, - status, false, userLevel, scope, NOTHING); - - StringTokenizer st, tokenSt; - st = new StringTokenizer(possibleValues, ","); - int num = st.countTokens(); - if(num <= 0) - { - throw new Error("Empty \"pv\" attribute for ENUM: " + name); - } - pTexts = new Hashtable<Integer, String>(); - comboBox = new AComboBox(); - comboBox.setName(screenName); - - range = new double[3][]; - range[MIN] = null; - range[MAX] = null; - range[SVAL] = new double[num]; - - for(int i = 0; i < num; i++) - { - tokenSt = new StringTokenizer(st.nextToken(), "="); - if(tokenSt.countTokens() != 2) - { - throw new Error("Incomplete \"text = value\" declaration " + - "for ENUM: " + name); - } - pTexts.put(new Integer(i), tokenSt.nextToken().trim()); - - try - { - if(valueType == FLOAT) - { - range[SVAL][i] = - Double.parseDouble(tokenSt.nextToken().trim()); - } - else if(valueType == INT) - { - range[SVAL][i] = - Integer.parseInt(tokenSt.nextToken().trim()); - } - } - catch(NumberFormatException nfe) - { - String msg = "Number error for ENUM: " + name + possibleValues; - AExceptionHandler.processException(msg, nfe); - } - } - - } // AEnumeratorParameter() --------------------------------------------- - - - - public void setD(double v) - { - if(valueType != FLOAT) - { - throw new Error("setD access on not FLOAT parameter"); - } - if(comboBox != null) - { - comboBox.setGUISelectedItem(getText(v)); - } - _setD(v); - refresh(); - - } // setD() ------------------------------------------------------------- - - - - public void setI(int v) - { - if(valueType != INT) - { - throw new Error("setI access on not INT parameter"); - } - if(comboBox != null) - { - comboBox.setGUISelectedItem(getText(v)); - } - _setI(v); - refresh(); - - } // setI() ------------------------------------------------------------- - - - - public String getCurrentText() - { - return getText(getI()); - - } // getCurrentText() --------------------------------------------------- - - - - public void clear() - { - pTexts.clear(); - - } // clear() ------------------------------------------------------------ - - - - public Hashtable<Integer, String> getValuesHashtable() - { - return pTexts; - - } // getValuesHashtable() ----------------------------------------------- - - - - public int size() - { - return pTexts.size(); - - } // size() ------------------------------------------------------------- - - - - public String getText(double v) - { - for(int i = 0; i < pTexts.size(); i++) - { - if(range[SVAL][i] == v) - { - return pTexts.get(new Integer(i)); - } - } - return null; - - } // getText() ---------------------------------------------------------- - - - - public double getValue(String text) - { - for(int i = 0; i < pTexts.size(); i++) - { - if(text.equals(pTexts.get(new Integer(i)))) - { - return range[SVAL][i]; - } - } - return 0; - - } // getValue() --------------------------------------------------------- - - - - public void addItem(int key, String item) - { - pTexts.put(new Integer(key), item); - range[SVAL] = new double[pTexts.size()]; - for(int i = 0; i < pTexts.size(); i++) - { - range[SVAL][i] = i; - } - - } // addItem() ---------------------------------------------------------- - - - public void removeItem(String itemToRemove) - { - Hashtable<Integer, String> pTextsNew = new Hashtable<Integer, String>(); - for(int i = 0; i < pTexts.size(); i++) - { - String item = pTexts.get(new Integer(i)); - if(itemToRemove.equals(item)) - { - continue; - } - else - { - pTextsNew.put(new Integer(pTextsNew.size()), item); - } - } - pTexts = pTextsNew; - - range[SVAL] = new double[pTexts.size()]; - for(int i = 0; i < pTexts.size(); i++) - { - range[SVAL][i] = i; - } - - } // removeItem() ------------------------------------------------------- - - - - /** - * Initialize the contained AComboBox with the list of items stored in this AEnumeratorParameter. - * Also sets a listener to send the appropriate command when an item is selected. - */ - public void initialize() - { - super.initialize(); - // remove all existing items from, in the constructor created, comboBox - // rather than create a new instance here, because after the first - // call of this initialize() method is not possible to update items - // in the comboBox - comboBox.removeAllItems(); - comboBox.setToolTipText(toolTip); - for(int i = 0; i < pTexts.size(); i++) - { - String item = pTexts.get(new Integer(i)); - comboBox.addItem(item); - } - comboBox.setGUISelectedItem(getText(getI())); - if (!comboBox.hasGUIItemListener()) { - comboBox.setGUIItemListener(new ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - if(e.getStateChange() == ItemEvent.SELECTED) - { - int index = comboBox.getSelectedIndex(); - String command = name + "=" + range[SVAL][index]; - ACommandProcessor.receive(command); - apply(); - } - } - }); - } - refresh(); - } // initialize() ------------------------------------------------------- - - - - public JComponent getValueComponent() - { - return comboBox; - - } // getValueComponent() ------------------------------------------------ - - - - public void refresh() - { - _refresh(); - if(comboBox != null) - { - comboBox.setGUISelectedItem(getText(getI())); - } - fireParameterChanged(); - } // refresh() ---------------------------------------------------------- - - - -} // class AEnumeratorParameter ============================================= diff --git a/graphics/AtlantisJava/src/atlantis/parameters/ALinkParameter.java b/graphics/AtlantisJava/src/atlantis/parameters/ALinkParameter.java deleted file mode 100755 index c1c732e42e6737a87e04a5765374ec3a0e8db682..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/ALinkParameter.java +++ /dev/null @@ -1,151 +0,0 @@ -package atlantis.parameters; - - -import java.util.StringTokenizer; -import javax.swing.JComponent; - - -/** - * A parameter which represents a link to another parameter. - */ -public class ALinkParameter implements AParameter { - private String groupName, parameterName; - private AParameter parameter=null; - - public ALinkParameter(String linkTo) { - StringTokenizer st=new StringTokenizer(linkTo.trim(), "."); - - groupName=st.nextToken().trim(); - parameterName=st.nextToken().trim(); - } - - public void solveLink() { - parameter=APar.instance().get(groupName, parameterName); - } - - public void initialize() { - parameter.initialize(); - } - - public boolean isInitialized() { - return parameter.isInitialized(); - } - - public void copy(int from, int to) { - parameter.copy(from, to); - } - - public void globalize(int window) { - parameter.globalize(window); - } - - public boolean isModulus() { - return parameter.isModulus(); - } - - public int getValueType() { - return parameter.getValueType(); - } - - public void setScope(int scope) {} - - public void changeScope(int scope) { - parameter.changeScope(scope); - } - - public int getScope() { - return parameter.getScope(); - } - - public String getName() { - return parameter.getName(); - } - - public String getScreenName() { - return parameter.getScreenName(); - } - - public String getToolTip() { - return parameter.getToolTip(); - } - - public boolean validateOperator(String oper) { - return parameter.validateOperator(oper); - } - - public boolean validateValue(double v) { - return parameter.validateValue(v); - } - - public void setD(double v) { - parameter.setD(v); - } - - public void setI(int v) { - parameter.setI(v); - } - - public double getD() { - return parameter.getD(); - } - - public int getI() { - return parameter.getI(); - } - - public String getValue() { - return parameter.getValue(); - } - - public String getCurrentText(){ - if(parameter instanceof AEnumeratorParameter) - return ((AEnumeratorParameter) parameter).getCurrentText(); - else - return null; - } - - public void setStatus(boolean status) { - parameter.setStatus(status); - } - - public boolean getStatus() { - return parameter.getStatus(); - } - - public String toString() { - return parameter.toString(); - } - - public String getOperator() { - return parameter.getOperator(); - } - - public boolean processCommand(String oper, double value) { - return parameter.processCommand(oper, value); - } - - public JComponent getValueComponent() { - return parameter.getValueComponent(); - } - - public JComponent getNameComponent() { - return parameter.getNameComponent(); - } - - public void refresh() { - parameter.refresh(); - } - - public int getUserLevel() { - return parameter.getUserLevel(); - } - - public String getDifferences(String groupName) { - return ""; - } - - @Override - public void addParameterChangeListener(AParameterChangeListener listener) { - if (parameter!=null) parameter.addParameterChangeListener(listener); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AListIntegerParameter.java b/graphics/AtlantisJava/src/atlantis/parameters/AListIntegerParameter.java deleted file mode 100755 index 0f26c15881369f799e60ed40ca2b94ecedeb51f3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AListIntegerParameter.java +++ /dev/null @@ -1,98 +0,0 @@ -package atlantis.parameters; - -import atlantis.utils.*; -import atlantis.gui.AComboBox; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import javax.swing.JComponent; - -/** - * A parameter which shows a list of possible integer values. - */ -public class AListIntegerParameter extends AAbstractParameter { - - private static ALogger logger = ALogger.getLogger(AListIntegerParameter.class); - - private AComboBox comboBox; - int[] displayableValues; - - public AListIntegerParameter( - String name, String screenName, String toolTip, String pv, int value, - boolean haseStatus, boolean status, int userLevel, int scope) { - - super(name, screenName, toolTip, INT, value, null, null, haseStatus, status, false, userLevel, - scope, NOTHING); - - range=resolvePossibleValues(pv, INT); - displayableValues=getValues(pv); - } - - public void setD(double v) { - throw new IllegalArgumentException("is not allowed to use setD on AListIntegerParameter"); - } - - public void setI(int v) { - if(comboBox!=null) comboBox.setGUISelectedItem(""+v); - _setI(v); - refresh(); - } - - public void initialize() { - super.initialize(); - comboBox=new AComboBox(); - comboBox.setEditable(true); - comboBox.setToolTipText(toolTip); - - for(int i=0; i<displayableValues.length; i++) - if(validateValue(displayableValues[i])) - comboBox.addItem(""+displayableValues[i]); - else throw new Error("Displayable Value: "+displayableValues[i]+" cannot be validated" - +toString()); - - comboBox.setGUISelectedItem(""+getI()); - - comboBox.setGUIItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(e.getStateChange()==ItemEvent.SELECTED) - applyInput(); - } - }); - - /* - comboBox.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent e) { - applyInput(); - } - }); - */ - } - - private void applyInput() { - boolean error=false; - - try { - int val=Integer.parseInt((String)comboBox.getSelectedItem()); - - if(validateValue(val)) { - ACommandProcessor.receive(name+"="+val); - apply(); - } else - error=true; - } catch(NumberFormatException nfe) { - error=true; - } - if(error) - logger.error("value: "+comboBox.getSelectedItem()+", is not correct!"); - } - - public JComponent getValueComponent() { - return comboBox; - } - - public void refresh() { - _refresh(); - if(comboBox!=null) comboBox.setGUISelectedItem(""+getI()); - fireParameterChanged(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/ANumberParameter.java b/graphics/AtlantisJava/src/atlantis/parameters/ANumberParameter.java deleted file mode 100755 index 403285e8648c19242cac5dd603729afa441fc380..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/ANumberParameter.java +++ /dev/null @@ -1,104 +0,0 @@ -package atlantis.parameters; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.JComponent; - -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.gui.ATextField; - -public class ANumberParameter extends AAbstractParameter { - private ATextField textField; - - public ANumberParameter( - String name, String screenName, String toolTip, String pv, int valueType, double value, - boolean haseStatus, boolean status, boolean isMod, int userLevel, int scope, int unitsOf) { - - super(name, screenName, toolTip, valueType, value, null, null, haseStatus, status, isMod, - userLevel, scope, unitsOf); - range=resolvePossibleValues(pv, valueType); - } - - public void setD(double v) { - if(valueType!=FLOAT) - throw new IllegalArgumentException("setD acces on not FLOAT parameter"); - - _setD(v); - refresh(); - } - - public void setI(int v) { - if(valueType!=INT) - throw new IllegalArgumentException("setI acces on not INT parameter"); - - if(textField!=null) textField.setText(""+v); - _setI(v); - } - - public void initialize() { - super.initialize(); - - textField=new ATextField(); - textField.setEditable(true); - textField.setToolTipText(toolTip); - - if(valueType==FLOAT) - textField.setText(""+getD()); - else - textField.setText(""+getI()); - - textField.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - applyInput(); - } - }); - - /* - textField.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent e) { - applyInput(); - } - }); - */ - } - - private void applyInput() { - boolean error=false; - - try { - double val=parseUnitsDouble(textField.getText()); - - if(validateValue(val)) { - if(valueType==FLOAT) { - ACommandProcessor.receive(name+getOperator()+val); - apply(); - } else { - ACommandProcessor.receive(name+getOperator()+(int)val); - apply(); - } - } else - error=true; - } catch(NumberFormatException nfe) { - error=true; - } - if(error) - AOutput.append("value: "+textField.getText()+", is not correct!", ALogInterface.BAD_COMMAND); - } - - public JComponent getValueComponent() { - return textField; - } - - public void refresh() { - _refresh(); - if(textField!=null) { - if(valueType==FLOAT) - textField.setText(parseUnits(getD())); - else - textField.setText(""+getI()); - } - fireParameterChanged(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/APar.java b/graphics/AtlantisJava/src/atlantis/parameters/APar.java deleted file mode 100644 index 1aefa78f03b75d652d3bf1e2b04bfad5f4e5b201..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/APar.java +++ /dev/null @@ -1,657 +0,0 @@ -package atlantis.parameters; - -import java.util.ArrayList; - -import java.util.HashSet; -import java.util.Hashtable; -import java.util.List; -import java.util.Set; -import java.util.Vector; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.data.AJetData; -import atlantis.event.AEvent; -import atlantis.event.AEventManager; -import atlantis.event.ANewEventListener; -import atlantis.utils.ALogger; -import atlantis.utils.xml.AXMLUtils; - -/** - * The Atlantis parameters store. Contains a list of AParametersGroup - * groups of parameters. - * - * The class keeps a reference to a singleton instance, but this must initially be created using - * the method {@link #construct(Node)}. Attempting to access the instance before initialization will - * cause an Error to be thrown. - * - * Ideally the APar instance would be passed to the classes that need it when the application is - * initalized, but currently the instance is fetched where it is needed, in many different parts of - * the code. - */ -public final class APar implements ANewEventListener, AParameterChangeListener -{ - private static ALogger logger = ALogger.getLogger(APar.class); - - private final List<AParameterSuperGroup> superGroups = new ArrayList<AParameterSuperGroup>(); - - /** Index of the currently selected window */ - private int currentWindowIndex; - /** Index of the previously selected window. - * Used for obtaining temporary access to parameters of some window! - */ - private int previousIndex; - - /** Parameter change listeners: just the GUI for now. */ - private List<AParameterChangeListener> parameterChangeListeners = new ArrayList<AParameterChangeListener>(); - - /** The user level of the program */ - private int userLevel; - - /** The singleton instance */ - private static APar instance; - - /** - * Create and return the singleton instance. - * @param parameters - */ - public synchronized static APar construct(Node parameters) { - instance = new APar(); - instance.initialize(parameters); - return instance; - } - - /** - * Get the singleton instance. - * @return - */ - public synchronized static APar instance() { - if (instance==null) throw new Error("Attempted to access APar instance before initialization."); - return instance; - } - - /** - * For testing only: create instance without initializing. - * @return - */ - public static synchronized APar constructDummyForTesting() { - instance = new APar(); - return instance; - } - - /** - * Constructs dummy singleton instance for testing. - */ - private APar() {} - - /** - * Constructs the singleton instance by reading the config file. - */ - private void initialize(Node parameters) - { - String ul=parameters.getAttributes().getNamedItem("userLevel").getNodeValue(); - userLevel=Integer.parseInt(ul); - - NodeList superGroupNodes=parameters.getChildNodes(); - for(int s=0; s<superGroupNodes.getLength(); s++) - { - Node superGroupNode = superGroupNodes.item(s); - if (superGroupNode.getNodeType() == Node.ELEMENT_NODE) - { - // here we have a <SuperGroup> element - AParameterSuperGroup superGroup = AParameterSuperGroup.readSuperGroup(superGroupNode,userLevel); - superGroup.addParameterChangeListener(this); - - this.superGroups.add(superGroup); - } - } - // Can't resolve link parameters until all parameters configured. - for (AParameterSuperGroup superGroup : superGroups) { - superGroup.resolveLinkParameters(); - } - - previousIndex=-1; - } - - /** Used to take into account differences in local parameters. */ - public void update(Node differences) - { - if(differences==null) return; - NodeList children=differences.getChildNodes(); - int childrenCount=children.getLength(); - for(int i=0; i<childrenCount; i++) - { - Node diff=children.item(i); - if(diff.getNodeType()==Node.ELEMENT_NODE) - { - NamedNodeMap attributes=diff.getAttributes(); - String group=AXMLUtils.tryAttribut(attributes, "group"); - String name=AXMLUtils.tryAttribut(attributes, "name"); - String windowName=AXMLUtils.tryAttribut(attributes, "windowName"); - String va=AXMLUtils.tryAttribut(attributes, "va"); - String st=AXMLUtils.tryAttribut(attributes, "st"); - String op=AXMLUtils.tryAttribut(attributes, "op"); - AParameter p=get(group, name); - if(p instanceof AAbstractParameter) - { - // When setting a global variable for just one window, make it local first - if (((AAbstractParameter)p).getScope() == AAbstractParameter.GLOBAL && !windowName.equals("*")) { - System.out.println("Setting scope to local for "+p.getName()); - ((AAbstractParameter)p).setScope(AAbstractParameter.LOCAL); - } - if(va!=null&&!va.equals("")) - { - ((AAbstractParameter)p)._setValue(windowName, Double.parseDouble(va)); - } - if(st!=null&&!st.equals("")) - { - if(st.equals("ON")) - ((AAbstractParameter)p)._setStatus(windowName, true); - else if(st.equals("OFF")) - ((AAbstractParameter)p)._setStatus(windowName, false); - } - if(op!=null&&!op.equals("")) - { - ((AAbstractParameter)p)._setOperator(windowName, op); - } - ((AAbstractParameter)p).saveDefaults(); - } - } - } - } - - /** Restore default settings of all parameters. */ - public void restoreDefaults() - { - for (AParameterSuperGroup superGroup : superGroups) { - superGroup.restoreDefaults(); - } - } - - /** - * Get parameter supergroups corresponding to current user level. - * i.e. Those with a user level less than or equal to the current level. - * @return supergroups corresponding to current user level - */ - public List<AParameterSuperGroup> getUISuperGroups() { - List<AParameterSuperGroup> uiSuperGroups = new ArrayList<AParameterSuperGroup>(); - for (AParameterSuperGroup superGroup : superGroups) { - if (superGroup.getUserLevel()<=this.userLevel) uiSuperGroups.add(superGroup); - } - return uiSuperGroups; - } - - /** - * Get all the parameter groups used by the GUI, according to the user level. - * @return the parameter groups - */ - public AParametersGroup[][] getUIGroups() - { - List<AParametersGroup[]> uiSuperGroups = new ArrayList<AParametersGroup[]>(); - for (AParameterSuperGroup superGroup : superGroups) { - List<AParametersGroup> uiGroups = superGroup.getUIGroups(); - AParametersGroup[] uiGroupsArray = uiGroups.toArray(new AParametersGroup[uiGroups.size()]); - uiSuperGroups.add(uiGroupsArray); - } - AParametersGroup[][] groups = - uiSuperGroups.toArray(new AParametersGroup[uiSuperGroups.size()][]); - return groups; - } - - /** - * Get names of groups of given usage type to display in GUI. - * @param uiUsage UI usage type to select - * @return the group names - */ - public Vector<String> getUIGroupNames(int uiUsage) {return getUIGroupNames(false,uiUsage);} - - /** - * Get names of groups to display in GUI. - * @return the group names - */ - public Vector<String> getUIGroupNames() {return getUIGroupNames(true,0);} - - /** - * Get names of groups to display in GUI. - * @param selectAll true to select all regardless of UI usage - * @param uiUsage ignored if selectAll is true - * @return the group names - */ - private Vector<String> getUIGroupNames(boolean selectAll, int uiUsage) { - Vector<String> v=new Vector<String>(); - AParametersGroup[][] g=getUIGroups(); - for(int i=0;i<g.length;++i) - for(int j=0;j<g[i].length;++j) - if(selectAll || (g[i][j].getUIUsage()==uiUsage)) - v.addElement(g[i][j].getGroupName()); - return v; - } - - /** - * Find parameter group with given name. - * @param groupName name to look for - * @return the group, or null if not found - */ - public AParametersGroup getGroup(String groupName) - { - for (AParameterSuperGroup superGroup : superGroups) { - AParametersGroup group = superGroup.getGroup(groupName); - if (group!=null) return group; - } - return null; - } - - public int getUserLevel() - { - return userLevel; - } - - public AParameter get(String group, String name) - { - AParametersGroup g = getGroup(group); - if(g == null) - { - logger.debug("No group named \"" + group + "\""); - return null; - } - - AParameter p = g.getParameter(name); - if(p == null) - { - logger.debug("No parameter named \"" + group + ":" + name + "\""); - } - - return p; - } - - public AParameter getUnknown(String group, String name) - { - AParametersGroup grp = getGroup(group); - if(grp==null) - return null; - else - return grp.getParameter(name); - } - - /** - * Returns the values of an array of parameters - * (can be ANY order: C1, C2, C3 ...) - */ - public int[] getArray(String groupName, String name, int numEntries) - { - int[] array=new int[numEntries]; - - String baseName=name.substring(0, name.length()-1); - int baseNumber=Integer.parseInt(name.substring(name.length()-1, name.length())); - - for(int i=0; i<numEntries; i++) - array[i]=this.get(groupName, baseName+(baseNumber+i)).getI(); - - return array; - } - - boolean processParameterChangeCommand(String parameterChangeCommand) - { - String parameterName, sValue; - double value; - AParameter parameter=null; - String groupName = ACanvas.getCanvas().getCurrentWindow().getGroupName(); - - for(int i=0; i<AParameter.supportedOperators.length; i++) - { - int index=parameterChangeCommand.indexOf(AParameter.supportedOperators[i]); - - if(index!=-1) - { - parameterName=parameterChangeCommand.substring(0, index).trim(); - AParametersGroup pg = getGroup(groupName); - - parameter=pg.getParameter(parameterName); - - /* AEvent calls listbox initialize in order to change its values from - event to event basis - AEnumeratorParameter.initialize() -> - ACommandProcessor.receive() -> .process() -> - APar.processParameterChangeCommand() - - In case of ETMis - warning 'ETMisCollections=0.0 bad command' when - ATLAS->ETMis group wasn't the active one for a current window. - Following statement however continues if the group tab (ETMis) is - active, so it's not a bad command. - This will have to be dealt with when implementing the keyboard - commands mode of driving Atlantis, it would have to be possible to - change values, etc of group tabs which are not active. It should be - easy as local commands (like ETMisCollections) would say name of - parameter group they belong to. Proper groupName would the only problem. - */ - if(parameter==null) - { - logger.debug("APar: warning: parameter " + parameterName + - " doesn't exist " + "in active group tab " + groupName); - return true; // prevent printing warning 'bad command ...' - - // return false; - used to, hence raising 'bad command ... ' in - // ACommandProcessor.receive(). the same effect. - } - - sValue=parameterChangeCommand.substring(index+AParameter.supportedOperators[i].length(), parameterChangeCommand.length()).trim(); - - if(sValue.equals("")) break; - - try - { - value=Double.parseDouble(sValue); - } - catch(NumberFormatException e) - { - return false; - } - - return parameter.processCommand(AParameter.supportedOperators[i], value); - } - } - - AParametersGroup pg = getGroup(groupName); - - parameterName=parameterChangeCommand.trim(); - parameter=pg.getParameter(parameterName); - if(parameter!=null) - { - if(parameter.getStatus()==true) - parameter.setStatus(false); - else - parameter.setStatus(true); - return true; - } - else - return false; - } - - /** - * Copy parameters from one window to another. - * @param sourceName name of source window - * @param destName name of destination window - */ - public void copyParameters(String sourceName, String destName) - { - for (AParameterSuperGroup superGroup : superGroups) { - superGroup.copyParameters(sourceName, destName); - } - } - - public void copyCurrentGroupLocalsTo(String destinationWindow) - { - if(ACanvas.getCanvas().isValidWindowName(destinationWindow)) - { - AWindow w=ACanvas.getCanvas().getCurrentWindow(); - Vector<AParameter> params=(getGroup(w.getGroupName())).getParameters(userLevel); - - int from=w.getIndex(); - int to=ACanvas.getCanvas().getWindow(destinationWindow).getIndex(); - - for(int i=0; i<params.size(); i++) - { - AParameter p=(AParameter)params.elementAt(i); - - if(p.getScope()==AParameter.LOCAL) - p.copy(from, to); - } - } - else - throw new Error("copyCurrentGroupLocalsTo, unknown: "+destinationWindow); - } - - /** - * selectWindowParameters/restoreWindowParameters methods are used for - * obtaining temporary access to parameters of some window - */ - public void selectWindowParameters(String newWindow) - { - //ACH - this was getting thrown sometimes, and I don't know why... - //if(previousIndex!=-1) - //throw new Error("selectWindowParameters, Try to select twice !?"); - - if(ACanvas.getCanvas().isValidWindowName(newWindow)) - { - previousIndex=getCurrentWindowIndex(); - setCurrentWindowIndex(ACanvas.getCanvas().getWindow(newWindow).getIndex()); - } - else - throw new Error("selectWindowParameters, window: "+newWindow+" , doesn't exist !?"); - } - - /** - * selectWindowParameters/restoreWindowParameters methods are used for - * obtaining temporary access to parameters of some window - */ - public void restoreWindowParameters() - { - if(previousIndex!=-1) - { - setCurrentWindowIndex(previousIndex); - previousIndex=-1; - } - else - throw new Error("restoreWindowParameters: you have nothing to restore !?"); - } - - /** - * @param currentWindowIndex the currentWindowIndex to set - */ - public void setCurrentWindowIndex(int currentWindowIndex) { - this.currentWindowIndex = currentWindowIndex; - } - - /** - * @return the currentWindowIndex - */ - public int getCurrentWindowIndex() { - return currentWindowIndex; - } - - /** - * Add a listener to be informed of parameter changes. - * - * @param listener - */ - public void addParameterChangeListener(AParameterChangeListener listener) { - parameterChangeListeners.add(listener); - } - - /** - * Tell the listeners that a parameter has changed. - */ - @Override - public void parameterChanged(AParameter parameter) { - if(parameter.getName().equals("JetBTagger")){ - this.setDefaultBTaggerValue(parameter); - } - for (AParameterChangeListener listener : parameterChangeListeners) { - listener.parameterChanged(parameter); - } - } - - @Override - public void newEvent(AEvent event) { - // update collection cut listboxes for collection-aware datatypes - updateCollectionsListBoxes(event); - updateBTaggerListBox(event); - } - - /** - * Update collection cut listboxes for collection-aware datatypes. - */ - private void updateCollectionsListBoxes(AEvent event) - { - Hashtable<String,Vector<String>> collections = event.getCollections(); - String listBoxName = null; - Hashtable<Integer, String> listBoxPreviousContents = null; - Vector<String> keys = null; - String[] keysArray = null; - boolean contentsChanged = false; // contents of listbox change watchdog - Set<AEnumeratorParameter> updatedEnumeratorParameters = new HashSet<AEnumeratorParameter>(); - - // note - listBox.initialize() - // if tab containing this particular listbox was active, it didn't - // take effect to set different value by .setI() as default value - // was in this case always the first one added - .initialize() called - // automatically when tabpane is active - // if tabpane wasn't active it worked fine - for (String dataTypeName : collections.keySet()) - { - contentsChanged = false; - listBoxName = dataTypeName + "Collections"; - keys = collections.get(dataTypeName); - AEnumeratorParameter listBox = (AEnumeratorParameter) this.get(dataTypeName, listBoxName); - keysArray = keys.toArray(new String[keys.size()]); - - listBoxPreviousContents = listBox.getValuesHashtable(); - - for(int i = 0; i < listBoxPreviousContents.size(); i++) - { - String item = (String) listBoxPreviousContents.get(new Integer(i)); - if(keys.contains(item) || "All".equals(item)) - { - continue; - } - else - { - contentsChanged = true; - listBox.removeItem(item); - } - } - - for(int i = 0; i < keysArray.length; i++) - { - if(listBoxPreviousContents.containsValue(keysArray[i])) - { - continue; - } - else - { - contentsChanged = true; - listBox.addItem(listBox.size(), keysArray[i]); - } - } - - // if the previous event had completely different collections than - // the current one, 'all' item will be the only one which remained - // after removal (the first loop). then the current (new) collections - // were added in the secold loop and 'all' item was in this case the - // fist, hence the default one - not desired - // solution: if any changes were performed in these two loops - // (contentsChanged variable set to true), the listbox will - // get re-initialised anyway. by removing 'all' and subsequent - // adding it the first collection from the event will be the default - // one and 'all' would be the last item - as desired - if(contentsChanged && !dataTypeName.endsWith("Segment")) - { - listBox.removeItem("All"); - listBox.addItem(listBox.size(), "All"); - listBox.initialize(); - } - updatedEnumeratorParameters.add(listBox); - } // while - // Get the enumerator parameters so we can tell them about the new event. - List<AEnumeratorParameter> collectionParameters = new ArrayList<AEnumeratorParameter>(); - for (AParameterSuperGroup superGroup : superGroups) { - collectionParameters.addAll(superGroup.getCollectionParameters()); - } - for (AEnumeratorParameter listBox : collectionParameters) { - if (!updatedEnumeratorParameters.contains(listBox)) { - listBox.clear(); - listBox.addItem(0, "None"); - listBox.initialize(); - } - } - } // updateCollectionsCutListBoxes() ------------------------------------ - - /** - * Update btagging cut listboxes for available btaggers. - * - * @param event The current event - * - * TODO: Make this independent of context (ie. pass it the name of the listBox to update, plus the values it should use) ? - Tom - */ - private void updateBTaggerListBox(AEvent event) - { - AJetData currentjets = event.getJetData(); - if (currentjets==null) return; - List<String> taggers = currentjets.getBTaggers(); - Set<AEnumeratorParameter> updatedEnumeratorParameters = new HashSet<AEnumeratorParameter>(); - AEnumeratorParameter listBox = (AEnumeratorParameter) this.get("CutsObjects", "JetBTagger"); - - if(taggers.size() == 0) { - listBox.clear(); - listBox.addItem(0, "None"); - } - - for(int i=0; i<taggers.size(); i++) { - listBox.addItem(i, taggers.get(i)); - } - - listBox.initialize(); - updatedEnumeratorParameters.add(listBox); - - } // updateBTaggerListBox() ------------------------------------ - - /** - * Keep a list of popular 'default' values for various b-taggers - * If we don't know about the b-tagger, use a fallback default of 1.0 - * - * @param parameter The current BTagger parameter - */ - public void setDefaultBTaggerValue(AParameter parameter) { - AEventManager eventManager = AEventManager.instance(); - - //Necessary code to stop B-tagging listener when having no-jet-info xml file - AJetData Jetss = eventManager.getCurrentEvent().getJetData(); - if(Jetss == null) - return; - - // Grab the b-taggers from the current Jet Collection - List<String> taggers = eventManager.getCurrentEvent().getJetData().getBTaggers(); - if(taggers.size() == 0) - return; - - // Get the BTagName corresponding to the current selection (ordering!) - // String newTagger = taggers.get(parameter.getI()); - String newTagger = taggers.get(parameter.getI()); - - - if(newTagger.equals(new String("SV0"))){ - get("CutsObjects", "JetBTagweight").setD(5.25); - } - else if(newTagger.equals(new String("SV1"))){ - get("CutsObjects", "JetBTagweight").setD(1.00); - } - else if(newTagger.equals(new String("JetFitterCOMBNN"))){ - get("CutsObjects", "JetBTagweight").setD(2.4); - } - else if(newTagger.equals(new String("IP3D+SV1")) || newTagger.equals(new String("IP3DSV1"))){ - get("CutsObjects", "JetBTagweight").setD(1.55); - } - else if(newTagger.equals(new String("JetFitterTagNN"))){ - get("CutsObjects", "JetBTagweight").setD(1.55); - } - else if(newTagger.equals(new String("IP2D"))){ - get("CutsObjects", "JetBTagweight").setD(1.00); - } - else if(newTagger.equals(new String("IP3D"))){ - get("CutsObjects", "JetBTagweight").setD(1.00); - } - else if(newTagger.equals(new String("SV2"))){ - get("CutsObjects", "JetBTagweight").setD(1.00); - } - else if(newTagger.equals(new String("MV1"))){ - get("CutsObjects", "JetBTagweight").setD(0.601713); - } - else { - get("CutsObjects", "JetBTagweight").setD(1.00); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AParameter.java b/graphics/AtlantisJava/src/atlantis/parameters/AParameter.java deleted file mode 100755 index 31b3ce329c6cb649a673ea88354cb98c836f2f1a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AParameter.java +++ /dev/null @@ -1,107 +0,0 @@ -package atlantis.parameters; - - -import javax.swing.JComponent; - - -/** - * This interface defines all the methods a parameter should have. - */ -public interface AParameter { - // scope constants - int LOCAL=1; - int GLOBAL=2; - - // value type constants - int NO_VALUE=0; - int INT=1; - int FLOAT=2; - - /** All supported supportedOperators */ - static final String[] supportedOperators= {"!=", ">=", ">", "<=", "<", "="}; - - /** Initializes graphics for this parameter. */ - void initialize(); - - /** Checks if the parameters graphics is initialized. */ - boolean isInitialized(); - - /** Copies the value and status from one window to the other. */ - void copy(int from, int to); - - /** Copies the value and status from "window" in all the others. */ - void globalize(int window); - - /** Returns true if parameter is modulus, i.e. sign is irrelevant. */ - boolean isModulus(); - - /** Return NO_VALUE, INT or FLOAT. */ - int getValueType(); - - /** sets the scope to LOCAL or GLOBAL. */ - void setScope(int scope); - - /** Returns the scope of the parameter. */ - int getScope(); - - /** Changes scope after it has originally been set. */ - void changeScope(int scope); - - /** Returns the name of the parameter. */ - String getName(); - - /** returns the screen name of the parameter. */ - String getScreenName(); - - /** Returns the tooltip text. */ - String getToolTip(); - - /** Returns the current operator assigned to parameter. */ - String getOperator(); - - /** Sets the double value for parameter. */ - void setD(double v); - void setI(int v); - - /** Returns the value of the parameter. */ - double getD(); - /** Returns the value of the parameter. */ - int getI(); - /** Returns the value of the parameter. */ - String getValue(); - - /** Sets the parameter's status. */ - void setStatus(boolean status); - - /** Returns the current status. */ - boolean getStatus(); - - /** Returns the graphical component used to display the Name and Status of this parameter. */ - JComponent getNameComponent(); - - /** Returns the graphical component used to display the value of this parameter. */ - JComponent getValueComponent(); - - /** Make synchronisation between the value and status and graphical components. */ - void refresh(); - - /** Returns true if "oper" represents an valid operator for this parameter. */ - boolean validateOperator(String oper); - - /** Returns true if "v" represents a valid value for this parameter. */ - boolean validateValue(double v); - - String getDifferences(String groupName); - - /** Validates and updates the current operator and value. */ - boolean processCommand(String oper, double v); - - /** Returns the user level associated with the parameter. */ - int getUserLevel(); - - /** Returns a String representation of the parameter. */ - String toString(); - - /** Add a parameter change listener. */ - void addParameterChangeListener(AParameterChangeListener listener); -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AParameterChangeListener.java b/graphics/AtlantisJava/src/atlantis/parameters/AParameterChangeListener.java deleted file mode 100644 index b65e530b826dacd4ac24a1eb140de82a7afdfd68..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AParameterChangeListener.java +++ /dev/null @@ -1,11 +0,0 @@ -package atlantis.parameters; - -/** - * Used by GUI to listen for changed parameters. - * - * @author waugh - * - */ -public interface AParameterChangeListener { - void parameterChanged(AParameter parameter); -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AParameterConfigReader.java b/graphics/AtlantisJava/src/atlantis/parameters/AParameterConfigReader.java deleted file mode 100644 index 8a2a88e9eae76728ba9e57900863d5b8783ec634..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AParameterConfigReader.java +++ /dev/null @@ -1,114 +0,0 @@ -package atlantis.parameters; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; - -import atlantis.utils.xml.AXMLUtils; - -/** - * Construct AParameter objects from the XML configuration file. - * - * @author waugh - * - */ -public class AParameterConfigReader { - /** - * This function reads any type of parameters. - * @param parameter The Node containing the definition of the parameter. - * @return An AParameter object. - */ - static AParameter readParameter(Node parameter, int groupScope) - { - AParameter par=null; - - // the node name of the parameter decides its type - String type=parameter.getNodeName(); - - // read all the parameter atributes - NamedNodeMap attributes=parameter.getAttributes(); - String fn=AXMLUtils.tryAttribut(attributes, "fn"); - String sn=AXMLUtils.tryAttribut(attributes, "sn"); - String sst=AXMLUtils.tryAttribut(attributes, "st"); - String sisMod=AXMLUtils.tryAttribut(attributes, "isMod"); - String sva=AXMLUtils.tryAttribut(attributes, "va"); - String op=AXMLUtils.tryAttribut(attributes, "op"); - String dop=AXMLUtils.tryAttribut(attributes, "dop"); - String to=AXMLUtils.tryAttribut(attributes, "to"); - String pv=AXMLUtils.tryAttribut(attributes, "pv"); - String tip=AXMLUtils.tryAttribut(attributes, "tip"); - String scopeAtt=AXMLUtils.tryAttribut(attributes, "scope"); - String unitsOfAtt=AXMLUtils.tryAttribut(attributes, "u"); - - // set scope value for this parameter - int scope=groupScope; - if(scopeAtt!=null) - { - if(scopeAtt.equals("LOCAL")) - scope=AParameter.LOCAL; - else if(scopeAtt.equals("GLOBAL")) - scope=AParameter.GLOBAL; - } - - // set user level for this parameter - int ul=-1; - if(!type.equals("LINK")) - ul=Integer.parseInt(AXMLUtils.tryAttribut(attributes, "ul")); - - double va=0; - if(sva!=null) va=Double.parseDouble(sva); - - // set initial status of this parameter - boolean st=false; - if(sst!=null) - if(sst.equals("ON")) - st=true; - - boolean isMod=false; - if(sisMod!=null) - if(sisMod.equals("YES")) - isMod=true; - - int unitsOf=0; - if(unitsOfAtt!=null) - unitsOf=Integer.parseInt(unitsOfAtt); - - // create an AParameter object based on its type - if(type.equals("LINK")) - par=new ALinkParameter(to); - else if(type.equals("COLOR")) - par=new AColorParameter(fn, sn, tip, pv, va, false, st, ul, scope); - else if(type.equals("SCOLOR")) - par=new AColorParameter(fn, sn, tip, pv, va, true, st, ul, scope); - else if(type.equals("ENUM")) - par=new AEnumeratorParameter(fn, sn, tip, pv, va, false, st, ul, scope); - else if(type.equals("SENUM")) - par=new AEnumeratorParameter(fn, sn, tip, pv, va, true, st, ul, scope); - else if(type.equals("ICUT")) - par=new ACutParameter(fn, sn, tip, pv, AParameter.INT, va, op, dop, false, st, isMod, ul, scope, unitsOf); - else if(type.equals("SICUT")) - par=new ACutParameter(fn, sn, tip, pv, AParameter.INT, va, op, dop, true, st, isMod, ul, scope, unitsOf); - else if(type.equals("FCUT")) - par=new ACutParameter(fn, sn, tip, pv, AParameter.FLOAT, va, op, dop, false, st, isMod, ul, scope, unitsOf); - else if(type.equals("SFCUT")) - par=new ACutParameter(fn, sn, tip, pv, AParameter.FLOAT, va, op, dop, true, st, isMod, ul, scope, unitsOf); - else if(type.equals("FLOAT")) - par=new ANumberParameter(fn, sn, tip, pv, AParameter.FLOAT, va, false, st, isMod, ul, scope, unitsOf); - else if(type.equals("SFLOAT")) - par=new ANumberParameter(fn, sn, tip, pv, AParameter.FLOAT, va, true, st, isMod, ul, scope, unitsOf); - else if(type.equals("INT")) - par=new ANumberParameter(fn, sn, tip, pv, AParameter.INT, (int)va, false, st, isMod, ul, scope, unitsOf); - else if(type.equals("SINT")) - par=new ANumberParameter(fn, sn, tip, pv, AParameter.INT, (int)va, true, st, isMod, ul, scope, unitsOf); - else if(type.equals("LINT")) - par=new AListIntegerParameter(fn, sn, tip, pv, (int)va, false, st, ul, scope); - else if(type.equals("SLINT")) - par=new AListIntegerParameter(fn, sn, tip, pv, (int)va, true, st, ul, scope); - else if(type.equals("STATUS")) - par=new AStatusParameter(fn, sn, tip, st, ul, scope); - else if(type.equals("StatusRoot")) - par = new AStatusRootParameter(parameter, fn, sn, tip, ul, scope); - else if(type.equals("StatusGroup")) - par = new AStatusGroupParameter(parameter, fn, sn, tip, ul, scope); - return par; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AParameterData.java b/graphics/AtlantisJava/src/atlantis/parameters/AParameterData.java deleted file mode 100644 index 0abcdf85799512bef215bad5a00fe9f4a743a124..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AParameterData.java +++ /dev/null @@ -1,202 +0,0 @@ -package atlantis.parameters; - -/** - * Encapsulates the per-window data belonging to a parameter. - * - * @author waugh - * - */ -public class AParameterData { - private AParameterState[] state; - private AParameterState[] defaultState; - - protected final APar parameterStore = APar.instance(); - - /** - * Create AParameterData for given number of windows. - * @param numWindows number of windows in the canvas - */ - AParameterData(int numWindows) { - state = new AParameterState[numWindows]; - defaultState = new AParameterState[numWindows]; - initializeParameterState(state); - initializeParameterState(defaultState); - } - - /** - * Initialize arrays of AParameterState objects. - * @param state - */ - private static void initializeParameterState(AParameterState[] state) { - for (int i=0; i<state.length; ++i) { - state[i] = new AParameterState(); - } - } - - /** - * Return the state of this parameter for a given window. - * @param windowIndex index of window - * @return the state - */ - AParameterState getState(int windowIndex) { - return state[windowIndex]; - } - - /** - * Get value of parameter for current window. - * @return value - */ - public double getValue() { - int currentWindowIndex = parameterStore.getCurrentWindowIndex(); - return getValue(currentWindowIndex); - } - - /** - * Get value of parameter for given window. - * @param windowIndex index of window - * @return value - */ - public double getValue(int windowIndex) { - return state[windowIndex].value; - } - - /** - * Set value of parameter for current window. - * @param value - */ - public void setValue(double value) { - int currentWindowIndex = parameterStore.getCurrentWindowIndex(); - setValue(currentWindowIndex,value); - } - - /** - * Set value of parameter for given window. - * @param windowIndex index of window - * @param value - */ - public void setValue(int windowIndex, double value) { - this.state[windowIndex].value = value; - } - - /** - * Get status (whether parameter is enabled) for current window. - * @return true if enabled - */ - public boolean getStatus() { - int currentWindowIndex = parameterStore.getCurrentWindowIndex(); - return getStatus(currentWindowIndex); - } - - /** - * Get status (whether parameter is enabled) for given window. - * @param windowIndex index of window - * @return true if enabled - */ - public boolean getStatus(int windowIndex) { - return state[windowIndex].status; - } - - /** - * Set status (whether parameter is enabled) for current window. - * @param status true to enable - */ - public void setStatus(boolean status) { - int currentWindowIndex = parameterStore.getCurrentWindowIndex(); - setStatus(currentWindowIndex,status); - } - - /** - * Set status (whether parameter is enabled) for given window). - * @param windowIndex index of window - * @param status true to enable - */ - public void setStatus(int windowIndex, boolean status) { - this.state[windowIndex].status = status; - } - - /** - * Get operator for current window. - * @return operator - */ - public String getOperator() { - int currentWindowIndex = parameterStore.getCurrentWindowIndex(); - return getOperator(currentWindowIndex); - } - - /** - * Get operator for given window. - * @param windowIndex index of window - * @return operator - */ - public String getOperator(int windowIndex) { - return state[windowIndex].operator; - } - - /** - * Set operator for current window. - * @param operator - */ - public void setOperator(String operator) { - int currentWindowIndex = parameterStore.getCurrentWindowIndex(); - setOperator(currentWindowIndex,operator); - } - - /** - * Set operator for given window. - * @param windowIndex index of window - * @param operator - */ - public void setOperator(int windowIndex, String operator) { - this.state[windowIndex].operator = operator; - } - - /** - * Copy values from one window to another. - * @param from index of source window - * @param to index of destination window - */ - public void copy(int from, int to) { - if (to!=from) state[to] = state[from].copy(); - } - - /** - * Save current values for each window to be restored later. - */ - public void saveDefaults() { - int numWindows = state.length; - for (int iWindow = 0; iWindow<numWindows; ++iWindow) { - defaultState[iWindow] = state[iWindow].copy(); - } - } - - /** - * Restore values for each window from saved values. - */ - public void restoreDefaults() { - int numWindows = state.length; - for (int iWindow = 0; iWindow<numWindows; ++iWindow) { - state[iWindow] = defaultState[iWindow].copy(); - } - } - - /** - * This function is called for GLOBAL parameters to apply the value in all - * windows. - */ - public void globalize() - { - int currentWindowIndex = parameterStore.getCurrentWindowIndex(); - globalize(currentWindowIndex); - } - - /** - * This function is called for GLOBAL parameters to apply the value in all - * windows. - */ - public void globalize(int window) - { - int numWindows = state.length; - for (int i = 0; i < numWindows; i++) - copy(window, i); - } -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AParameterState.java b/graphics/AtlantisJava/src/atlantis/parameters/AParameterState.java deleted file mode 100644 index 0c93ee31a72b9198bd821c77945a56e6443feacf..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AParameterState.java +++ /dev/null @@ -1,38 +0,0 @@ -package atlantis.parameters; - -/** - * Encapsulate the state (value, status, operator) of a given parameter for a - * single window. - * - * @author waugh - * - */ -public class AParameterState implements Cloneable { - double value; - boolean status; - String operator = ""; - - /** - * Make a new AParameterState with default values. - */ - AParameterState() {} - - /** - * Make a new AParameterState that is a copy of another. - * Other classes should use the public copy() method. - * @param from the object to copy - */ - private AParameterState(AParameterState from) { - this.value = from.value; - this.status = from.status; - this.operator = from.operator; - } - - /** - * Make a new AParameterState that is a copy of this one. - * @return copy - */ - public AParameterState copy() { - return new AParameterState(this); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AParameterSuperGroup.java b/graphics/AtlantisJava/src/atlantis/parameters/AParameterSuperGroup.java deleted file mode 100644 index fe01d3b3d7bfdad69bf1965407e133515f1e2cda..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AParameterSuperGroup.java +++ /dev/null @@ -1,241 +0,0 @@ -package atlantis.parameters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * A supergroup of parameters, i.e. a group of groups, corresponding to one of the - * top-level tabs in the GUI, e.g. "Projections" or "Data". - * - * @author waugh - * - */ -public class AParameterSuperGroup implements AParameterChangeListener { - private String name; - private String toolTip; - private int userLevel; - - private Map<String,AParametersGroup> parameterGroups = new HashMap<String,AParametersGroup>(); - private List<AParametersGroup> uiGroups = new ArrayList<AParametersGroup>(); - /** Keep track of enumerator parameters so we can tell them about new events. */ - private final List<AEnumeratorParameter> collectionParameters = new ArrayList<AEnumeratorParameter>(); - - private List<AParameterChangeListener> parameterChangeListeners = new ArrayList<AParameterChangeListener>(); - - private AParameterSuperGroup() {} - - static AParameterSuperGroup readSuperGroup(Node node, int applicationUserLevel) { - AParameterSuperGroup superGroup = new AParameterSuperGroup(); - superGroup.name = node.getAttributes().getNamedItem("name").getNodeValue(); - superGroup.toolTip = node.getAttributes().getNamedItem("toolTip").getNodeValue(); - String sUserLevel = node.getAttributes().getNamedItem("userLevel").getNodeValue(); - superGroup.userLevel = Integer.parseInt(sUserLevel); - superGroup.readGroups(node,applicationUserLevel); - return superGroup; - } - - /** - * Populate the lists of parameter groups and UI groups. - * @param superGroupNode - */ - private void readGroups(Node superGroupNode, int applicationUserLevel) { - NodeList groups = superGroupNode.getChildNodes(); - for (int i = 0; i < groups.getLength(); i++) - { - Node group = groups.item(i); - if (group.getNodeType() == Node.ELEMENT_NODE) - { - // here we have a <Group> element and create an AParametersGroup object from it - AParametersGroup g = readGroup(group); - - String gName = g.getGroupName(); - if (parameterGroups.containsKey(gName)) - throw new Error("Duplicate definition of group " + gName); - parameterGroups.put(gName, g); - int guiUsage = g.getUIUsage(); - - if ( ( (guiUsage == AParametersGroup.TABLE) || - (guiUsage == AParametersGroup.PROJECTION) - || (guiUsage == AParametersGroup.BRAIN_TEST) - ) && (g.getUserLevel() <= userLevel)) - uiGroups.add(g); - } - } - - } - - private AParametersGroup readGroup(Node group) - { - // first we read all the attributes - NamedNodeMap attributes=group.getAttributes(); - String groupName=attributes.getNamedItem("name").getNodeValue(); - String screenName=attributes.getNamedItem("sname").getNodeValue(); - String guiUsageAttribut=attributes.getNamedItem("guiUsage").getNodeValue(); - String scopeAttribut=attributes.getNamedItem("scope").getNodeValue(); - int ul=Integer.parseInt(attributes.getNamedItem("userLevel").getNodeValue()); - String groupToolTip=attributes.getNamedItem("toolTip").getNodeValue(); - - // set guiUsage value for this group - int guiUsage; - if(guiUsageAttribut.equals("TABLE")) - guiUsage=AParametersGroup.TABLE; - else if(guiUsageAttribut.equals("PROJECTION")) - guiUsage=AParametersGroup.PROJECTION; - else if(guiUsageAttribut.equals("BRAIN_TEST")) - guiUsage=AParametersGroup.BRAIN_TEST; - else - guiUsage=AParametersGroup.NO_USE; - - // set scope value for this group - int scope; - if(scopeAttribut.equals("LOCAL")) - scope=AParameter.LOCAL; - else if(scopeAttribut.equals("GLOBAL")) - scope=AParameter.GLOBAL; - else - scope=AParameter.GLOBAL; - - // create an AParametersGroup object based on the attributes - AParametersGroup thisGroup=new AParametersGroup(groupName, screenName, guiUsage, scope, ul, groupToolTip); - - // report error if no parameters in this group - NodeList childrens=group.getChildNodes(); - if(childrens==null) throw new Error("this group contains no parameters"); - int childrensCount=childrens.getLength(); - if(childrensCount==0) throw new Error("this group contains no parameters"); - - // read all the parameters of this group recursively - for(int i=0; i<childrensCount; i++) - { - Node child=childrens.item(i); - if(child.getNodeType()==Node.ELEMENT_NODE) - { - // for each parameter, create an object (either ACommnad or AParameter) - // and add it into the to be returned AParametersGroup object - String childName=child.getNodeName(); - if(childName.equals("Command")) { - ACommand c=readCommand(child); - if(c!=null) thisGroup.add(c); - } - else { - AParameter parameter = AParameterConfigReader.readParameter(child, scope); - parameter.addParameterChangeListener(this); - thisGroup.add(parameter); - if (parameter instanceof AEnumeratorParameter && - parameter.getScreenName().endsWith("Collections")) { - collectionParameters.add((AEnumeratorParameter)parameter); - } - } - } - } - - return thisGroup; - } - - - - private ACommand readCommand(Node commandNode) - { - NamedNodeMap attributes=commandNode.getAttributes(); - - String name=attributes.getNamedItem("name").getNodeValue(); - String command=attributes.getNamedItem("command").getNodeValue(); - String toolTip=attributes.getNamedItem("toolTip").getNodeValue(); - String userLevel=attributes.getNamedItem("ul").getNodeValue(); - if(Integer.parseInt(userLevel)<=this.userLevel) - return new ACommand(name, command, toolTip); - else - return null; - } - - /** - * Get the name of the supergroup. - * @return the name - */ - public String getName() {return name;} - - /** - * Get the tool tip for this supergroup. - * @return the tool tip - */ - public String getToolTip() {return toolTip;} - - /** - * Get the user level of this supergroup. - * @return the user level - */ - public int getUserLevel() {return userLevel;} - - /** - * Get parameter group with given name. - * @param name name of group - * @return parameter group - */ - public AParametersGroup getGroup(String name) {return parameterGroups.get(name);} - - /** - * Get the parameter groups that are displayed in the UI in the current user level. - * @return list of parameter groups - */ - public List<AParametersGroup> getUIGroups() {return uiGroups;} - - /** - * Tell the listeners that a parameter has changed. - */ - @Override - public void parameterChanged(AParameter parameter) { - for (AParameterChangeListener listener : parameterChangeListeners) { - listener.parameterChanged(parameter); - } - } - - public Map<? extends String, ? extends AParametersGroup> getParameterGroups() { - return parameterGroups; - } - - public Collection<? extends AEnumeratorParameter> getCollectionParameters() { - return collectionParameters; - } - - /** - * Add a listener to be informed of parameter changes. - * - * @param listener - */ - public void addParameterChangeListener(AParameterChangeListener listener) { - this.parameterChangeListeners.add(listener); - } - - /** - * Restore all groups in supergroup to defaults. - */ - public void restoreDefaults() { - for (AParametersGroup group : parameterGroups.values()) { - group.restoreDefaults(); - } - } - - /** - * Copy parameters from one window to another. - * @param sourceName name of source window - * @param destName name of destination window - */ - public void copyParameters(String sourceName, String destName) { - for (AParametersGroup group : parameterGroups.values()) { - group.copyParameters(sourceName, destName); - } - } - - public void resolveLinkParameters() { - for (AParametersGroup group : parameterGroups.values()) { - group.resolveLinkParameters(); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AParameterUtilities.java b/graphics/AtlantisJava/src/atlantis/parameters/AParameterUtilities.java deleted file mode 100644 index 7dada86fe6932efadd81dbec812ffde54ba67baf..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AParameterUtilities.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * - */ -package atlantis.parameters; - -import atlantis.utils.AMath; - -/** - * Mathematical utility methods that act on Parameters. - * Moved from atlantis.utils.AMath to reduce dependencies of utils on other packages. - * - * @author waugh - * - */ -public class AParameterUtilities { - - private final static APar parameterStore = APar.instance(); - private final static AParameter xVertexPar = parameterStore.get("Event", "XVtx"); - private final static AParameter yVertexPar = parameterStore.get("Event", "YVtx"); - private final static AParameter zVertexPar = parameterStore.get("Event", "ZVtx"); - - /** - * Get coordinates of event vertex. - * - * @return (x,y,z) of vertex - */ - public static double[] getPrimaryVertex() - { - double[] primaryVertex = new double[3]; - primaryVertex[0] = parameterStore.get("Event", "XVtx").getD(); - primaryVertex[1] = parameterStore.get("Event", "YVtx").getD(); - primaryVertex[2] = parameterStore.get("Event", "ZVtx").getD(); - return primaryVertex; - } - - /** - * Returns phi with respect to the primary vertex. - * @param x double x coordinate - * @param y double y coordinate - * @return double phi - */ - public static double phi(double x, double y) { - double phi = Math.atan2(y-yVertexPar.getD(), x-xVertexPar.getD()); - if (phi < 0) phi += 2.*Math.PI; - return Math.toDegrees(phi); - } - - /** - * Returns eta with respect to the primary vertex. - * @param z double z coordinate - * @param rho double rho coordinate - * @return double eta - */ - public static double eta(double z, double rho) - { - return AMath.etaAbs(z - zVertexPar.getD(), rho); - } - - public static double getPhiStereo(double rho, double phi, double z) - { - AParameter stereoAnglePar = parameterStore.get("SiCluster", "Stereo"); - if(!stereoAnglePar.getStatus()) - { - return phi; - } - double stereoAngle = stereoAnglePar.getI() * 0.04; - return phi + stereoAngle * (z-parameterStore.get("Event", "ZVtx").getD()) / rho; - } - - /** - * Get the sign of the rho coordinate based on the x and y coordinates and - * the phi value set by the user. - * @param x double x coordinate - * @param y double y coordinate - * @return int sign of rho (-1 or +1) - */ - public static int getRhoSign(double x, double y) { - return getRhoSign(Math.atan2(y, x)); - } - - /** - * Get the sign of the rho coordinate based on the phi coordinate and - * the phi value set by the user. - * @param phi double phi coordinate - * @return int sign of rho (-1 or +1) - */ - private static int getRhoSign(double phi) { - int sign; - if (phi < 0.) phi += 2.*Math.PI; - - double phiMid = Math.toRadians(parameterStore.get("RZ", "Phi").getD()); - double phiDiff = Math.abs(phi-phiMid); - - if(phiDiff <= Math.PI/2.|| phiDiff > 3*Math.PI/2.) { - sign = 1; - } else { - sign = -1; - } - return sign; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AParametersGroup.java b/graphics/AtlantisJava/src/atlantis/parameters/AParametersGroup.java deleted file mode 100755 index eeadb9d318393cdcf3e28f19b8b4c7ef2cd30ad6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AParametersGroup.java +++ /dev/null @@ -1,157 +0,0 @@ -package atlantis.parameters; - -import atlantis.canvas.ACanvas; -import java.util.*; - -/** - * This class is used to store a set of parameters. Provides functions for - * fast searching of a parameter by its name. - */ -public class AParametersGroup { - public static final int NO_USE=0; - public static final int TABLE=1; - public static final int PROJECTION=2; - public static final int BRAIN_TEST=3; - - private String name; - private String screenName; - private String toolTip; - private int scope; - private int guiUsage; - private int userLevel; - - private Vector<AParameter> parametersVector = new Vector<AParameter>(); - private HashMap<String, AParameter> parametersMap = new HashMap<String, AParameter>(); - private Vector<ACommand> commandsVector = new Vector<ACommand>(); - - public AParametersGroup(String name, String screenName, int guiUsage, - int scope, int userLevel, String toolTip) { - - this.name=name; - - if(!screenName.trim().equals("")) - this.screenName=screenName; - else - this.screenName=name; - - this.guiUsage=guiUsage; - this.scope=scope; - this.userLevel=userLevel; - this.toolTip=toolTip; - } - - public void restoreDefaults() { - Enumeration<AParameter> parameters = parametersVector.elements(); - while(parameters.hasMoreElements()) { - AParameter p = parameters.nextElement(); - if(p instanceof AAbstractParameter) - ((AAbstractParameter)p).restoreDefaults(); - } - } - - - private void addToMap(AParameter p) { - if(parametersMap.containsKey(p.getName())) - throw new Error("Duplicate definition of parameter full name "+p.getName()); - - parametersMap.put(p.getName(), p); - } - - public void add(AParameter p) { - parametersVector.addElement(p); - if(!(p instanceof ALinkParameter)) - addToMap(p); - } - - public void add(ACommand c) { - for(int i=0; i<commandsVector.size(); i++) { - ACommand command = commandsVector.elementAt(i); - if(command.getName().equals(c.getName())) - throw new Error("Duplicate definition of command "+c.getName()); - } - commandsVector.addElement(c); - } - - public int getScope() { - return scope; - } - - public String getGroupName() { - return name; - } - - public String getScreenName() { - return screenName; - } - - public String getToolTip() { - return toolTip; - } - - public int getUIUsage() { - return guiUsage; - } - - public int getUserLevel() { - return userLevel; - } - - public ACommand[] getCommands() { - ACommand[] commands=new ACommand[commandsVector.size()]; - - for(int i=0; i<commands.length; i++) - commands[i]=commandsVector.elementAt(i); - - return commands; - } - - public Vector<AParameter> getParameters(int userLevel) { - Vector<AParameter> v=new Vector<AParameter>(parametersVector.size()); - - for(int i=0; i<parametersVector.size(); i++) { - AParameter p = parametersVector.elementAt(i); - if(p.getUserLevel()<=userLevel) - v.addElement(p); - } - - return v; - } - - public AParameter getParameter(String name) { - if(parametersMap.get(name)!=null) - return parametersMap.get(name); - // if under group "Data", should find the parameter in the whole tree - else if(parametersMap.get("Status")!=null){ - return ((AStatusRootParameter)parametersMap.get("Status")).getParameter(name); - } - else - return null; - } - - /** - * Copy parameters from one window to another. - * @param sourceName name of source window - * @param destName name of destination window - */ - public void copyParameters(String sourceName, String destName) { - int source=ACanvas.getCanvas().getWindow(sourceName).getIndex(); - int dest=ACanvas.getCanvas().getWindow(destName).getIndex(); - - for(int i=0; i<parametersVector.size(); i++) { - AParameter p = parametersVector.elementAt(i); - if(p.getScope()==AParameter.LOCAL) - p.copy(source, dest); - } - } - - public void resolveLinkParameters() { - for(int i=0; i<parametersVector.size(); i++) { - AParameter p = parametersVector.elementAt(i); - if(p instanceof ALinkParameter) { - ((ALinkParameter)p).solveLink(); - addToMap(p); - } - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AStatusGroupParameter.java b/graphics/AtlantisJava/src/atlantis/parameters/AStatusGroupParameter.java deleted file mode 100755 index 59bc40f1fc221ed20ff7ef584c10bfbd204372cc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AStatusGroupParameter.java +++ /dev/null @@ -1,213 +0,0 @@ -package atlantis.parameters; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import javax.swing.JComponent; -import java.util.ArrayList; -import java.awt.Color; -import hep.wired.util.TristateCheckBox; - -import atlantis.gui.ACheckNode; -import atlantis.gui.ACheckBox; - -/** - * Created on 16 March 2005, 16:15 - * - * @author Qiang Lu - */ -public class AStatusGroupParameter extends AAbstractParameter -{ - private ArrayList<AParameter> parameterNodeList; - - private ACheckNode statusGroupNode; - - /** Creates a new instance of AStatusGroupParameter */ - AStatusGroupParameter(Node statusGroup, String name, String screenName, String toolTip, int userLevel, int scope) - { - super(name, screenName, toolTip, AParameter.NO_VALUE, 0, null, null, false, false, - false, userLevel, scope, AAbstractParameter.NOTHING); - - // get child element of statusGroup - NodeList childrens = statusGroup.getChildNodes(); - // report error if no parameters - if (childrens == null) - throw new Error("StatusGroup element contains no parameters"); - int childrensCount = childrens.getLength(); - if (childrensCount == 0) - throw new Error("StatusGroup element contains no parameters"); - - // create an AParameter object for each node under statusGroup - // and add them into parameterNodeList - parameterNodeList = new ArrayList<AParameter>(); - for (int i = 0; i < childrensCount; i++) - { - Node child = childrens.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) - { - // here we have a <StatusGroup> or <Status> element - parameterNodeList.add(AParameterConfigReader.readParameter(child, scope)); - } - } - } - - public void initialize() - { - super.initialize(); - - // create the tree node using the <StatusGroup> element - TristateCheckBox groupCheckBox = new TristateCheckBox(screenName); - groupCheckBox.setBackground(new Color(204, 204, 204)); - if (getScope() == LOCAL) - groupCheckBox.setForeground(Color.black); - else - groupCheckBox.setForeground(Color.blue); - - groupCheckBox.setToolTipText(toolTip); - statusGroupNode = new ACheckNode(groupCheckBox, false, ACheckNode.MULTI_SELECTION, this); - - for (AParameter aNodeParameter : parameterNodeList) - { - aNodeParameter.initialize(); - if (aNodeParameter instanceof AStatusParameter) - { - if (aNodeParameter.getUserLevel() <= APar.instance().getUserLevel()) - { - ACheckBox statusCheckBox = ((AStatusParameter) aNodeParameter).getCheckBox(); - ACheckNode aNode = new ACheckNode(statusCheckBox, statusCheckBox.isSelected(), ACheckNode.SINGLE_SELECTION, aNodeParameter); - statusGroupNode.add(aNode); - } - } - else if (aNodeParameter instanceof AStatusGroupParameter) - { - statusGroupNode.add(((AStatusGroupParameter) aNodeParameter).getCheckNode()); - } - } - } - - public JComponent getValueComponent() - { - return null; - } - - public ACheckNode getCheckNode() - { - return statusGroupNode; - } - - ArrayList<AParameter> getParameterList() - { - return parameterNodeList; - } - - public AParameter getParameter(String name) - { - for (AParameter aNodeParameter : parameterNodeList) - { - if (aNodeParameter instanceof AStatusParameter) - { - if (aNodeParameter.getName().equals(name)) - return aNodeParameter; - } - else if (((AStatusGroupParameter) aNodeParameter).getParameter(name) != null) - { - return ((AStatusGroupParameter) aNodeParameter).getParameter(name); - } - } - return null; - } - - public AParameter getGroupParameter(String name) - { - if(getName().equals(name)) - return this; - for (AParameter aNodeParameter : parameterNodeList) - { - if (aNodeParameter instanceof AStatusGroupParameter) - { - if (((AStatusGroupParameter) aNodeParameter).getGroupParameter(name) != null) - { - return ((AStatusGroupParameter) aNodeParameter).getGroupParameter(name); - } - } - } - return null; - } - - public boolean getStatus() - { - return statusGroupNode.isSelected(); - } - - public void setStatus(boolean status) - { - for (AParameter aNodeParameter : parameterNodeList) - { - aNodeParameter.setStatus(status); - } - } - - public void refresh() - { - _refresh(); - fireParameterChanged(); - } - - public void setD(double v) - { - throw new IllegalArgumentException("StatusGroupParameter hase no value"); - } - - public void setI(int v) - { - throw new IllegalArgumentException("StatusGroupParameter hase no value"); - } - - public void saveChildrenDefaults() - { - for (AParameter aNodeParameter : parameterNodeList) - { - AAbstractParameter aNodeAbstractParameter = (AAbstractParameter) aNodeParameter; - if(aNodeAbstractParameter instanceof AStatusGroupParameter) - ((AStatusGroupParameter)aNodeAbstractParameter).saveChildrenDefaults(); - else - ((AStatusParameter)aNodeAbstractParameter).saveDefaults(); - } - } - - public void restoreDefaults() - { - super.restoreDefaults(); - for (AParameter aNodeParameter : parameterNodeList) - { - AAbstractParameter aNodeAbstractParameter = (AAbstractParameter) aNodeParameter; - aNodeAbstractParameter.restoreDefaults(); - } - } - - public void copy(int from, int to) - { - for (AParameter aNodeParameter : parameterNodeList) - { - AAbstractParameter aNodeAbstractParameter = (AAbstractParameter) aNodeParameter; - aNodeAbstractParameter.copy(from, to); - } - } - - public String getDifferences(String groupName) - { - StringBuffer ret = new StringBuffer(); - - for (AParameter aNodeParameter : parameterNodeList) - { - AAbstractParameter aNodeAbstractParameter = (AAbstractParameter) aNodeParameter; - if(aNodeAbstractParameter instanceof AStatusGroupParameter) - ret.append(((AStatusGroupParameter)aNodeAbstractParameter).getDifferences(groupName)); - else - ret.append(aNodeAbstractParameter.getDifferences(groupName)); - } - - return ret.toString(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AStatusParameter.java b/graphics/AtlantisJava/src/atlantis/parameters/AStatusParameter.java deleted file mode 100755 index ad42a168db9f20ea473b75a354750810583b4451..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AStatusParameter.java +++ /dev/null @@ -1,58 +0,0 @@ -package atlantis.parameters; - -import javax.swing.JLabel; -import javax.swing.LookAndFeel; -import javax.swing.JComponent; - -/** - * A parameter representing an on/off value. Corresponds to an ACheckBox in the GUI. - */ -public class AStatusParameter extends AAbstractParameter -{ - private JLabel valueLabel; - - public AStatusParameter(String name, String screenName, String toolTip, - boolean status, int userLevel, int scope) - { - super(name, screenName, toolTip, NO_VALUE, 0, null, null, true, - status, false, userLevel, scope, NOTHING); - } - - - public void setD(double v) - { - throw new IllegalArgumentException("StatusParameter has no value"); - } - - - public void setI(int v) - { - throw new IllegalArgumentException("StatusParameter has no value"); - } - - - public void initialize() - { - super.initialize(); - valueLabel = new JLabel(); - valueLabel.setOpaque(true); - valueLabel.setToolTipText(toolTip); - LookAndFeel.installColorsAndFont(valueLabel, "CheckBox.background", - "CheckBox.foreground", - "CheckBox.font"); - } - - - public JComponent getValueComponent() - { - return valueLabel; - } - - - public void refresh() - { - _refresh(); - fireParameterChanged(); - } - -} // class AStatusParameter ================================================= diff --git a/graphics/AtlantisJava/src/atlantis/parameters/AStatusRootParameter.java b/graphics/AtlantisJava/src/atlantis/parameters/AStatusRootParameter.java deleted file mode 100755 index fbbf4f40448e7c97f148c3d20cf39f56c2179eee..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/AStatusRootParameter.java +++ /dev/null @@ -1,435 +0,0 @@ -package atlantis.parameters; - -import hep.wired.util.TristateCheckBox; - -import java.awt.Color; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.Iterator; - -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.JTree; -import javax.swing.ToolTipManager; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreePath; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import atlantis.utils.AUtilities; -import atlantis.gui.ACheckBox; -import atlantis.gui.ACheckNode; -import atlantis.gui.AParametersTable; -import atlantis.gui.ATreeCellRenderer; - -/** - * AStatusRootParameter.java - * - * Created on 14 March 2005, 17:49 - * - * @author Qiang Lu - */ -public class AStatusRootParameter extends AAbstractParameter -{ - private ArrayList<AParameter> parameterNodeList; - - private JTree statusTree; - - private ACheckNode statusRootNode; - - /** Creates a new instance of AStatusGroupParameter */ - AStatusRootParameter(Node statusRoot, String name, String screenName, String toolTip, int userLevel, int scope) - { - super(name, screenName, toolTip, AParameter.NO_VALUE, 0, null, null, false, false, - false, userLevel, scope, AAbstractParameter.NOTHING); - // get child element of statusRoot - NodeList childrens = statusRoot.getChildNodes(); - // report error if no parameters - if (childrens == null) - throw new Error("this group contains no parameters"); - int childrensCount = childrens.getLength(); - if (childrensCount == 0) - throw new Error("this group contains no parameters"); - - // create an AParameter object for each node under statusRoot - // and add them into parameterNodeList - parameterNodeList = new ArrayList<AParameter>(); - for (int i = 0; i < childrensCount; i++) - { - Node child = childrens.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) - { - // here we have a <StatusGroup> or <Status> element - parameterNodeList.add(AParameterConfigReader.readParameter(child, scope)); - } - } - } - - public void initialize() - { - super.initialize(); - - // create the root node of the tree using the <StatusRoot> element - TristateCheckBox rootCheckBox = new TristateCheckBox(screenName); - rootCheckBox.setBackground(new Color(204, 204, 204)); - if (getScope() == LOCAL) - rootCheckBox.setForeground(Color.black); - else - rootCheckBox.setForeground(Color.blue); - - rootCheckBox.setToolTipText(toolTip); - statusRootNode = new ACheckNode(rootCheckBox, false, ACheckNode.MULTI_SELECTION, this); - for (AParameter aNodeParameter : parameterNodeList) - { - aNodeParameter.initialize(); - if (aNodeParameter instanceof AStatusParameter) - { - if (aNodeParameter.getUserLevel() <= APar.instance().getUserLevel()) - { - ACheckBox statusCheckBox = ((AStatusParameter) aNodeParameter).getCheckBox(); - ACheckNode aNode = new ACheckNode(statusCheckBox, statusCheckBox.isSelected(), ACheckNode.SINGLE_SELECTION, aNodeParameter); - statusRootNode.add(aNode); - } - } - else if (aNodeParameter instanceof AStatusGroupParameter) - { - statusRootNode.add(((AStatusGroupParameter) aNodeParameter).getCheckNode()); - } - } - - statusTree = new JTree(statusRootNode); - statusTree.setBackground(new Color(204, 204, 204)); - statusTree.setCellRenderer(new ATreeCellRenderer()); - statusTree.addMouseListener(new NodeSelectionListener(statusTree)); - ToolTipManager.sharedInstance().registerComponent(statusTree); - } - - public JComponent getValueComponent() - { - return null; - } - - public JComponent getNameComponent() - { - return statusTree; - } - - ArrayList<AParameter> getParameterList() - { - return parameterNodeList; - } - - public AParameter getParameter(String name) - { - for (AParameter aNodeParameter : parameterNodeList) - { - if (aNodeParameter instanceof AStatusParameter) - { - if (aNodeParameter.getName().equals(name)) - return aNodeParameter; - } - else if (((AStatusGroupParameter) aNodeParameter).getParameter(name) != null) - { - return ((AStatusGroupParameter) aNodeParameter).getParameter(name); - } - } - return null; - } - - public AParameter getGroupParameter(String name) - { - if(!isInitialized()) - initialize(); - - if(getName().equals(name)) - return this; - for (AParameter aNodeParameter : parameterNodeList) - { - if (aNodeParameter instanceof AStatusGroupParameter) - { - if (((AStatusGroupParameter) aNodeParameter).getGroupParameter(name) != null) - { - return ((AStatusGroupParameter) aNodeParameter).getGroupParameter(name); - } - } - } - return null; - } - - public boolean getStatus() - { - return statusRootNode.isSelected(); - } - - public void setStatus(boolean status) - { - for (AParameter aNodeParameter : parameterNodeList) - { - aNodeParameter.setStatus(status); - } - } - - public void refresh() - { - _refresh(); - fireParameterChanged(); - } - - public void setD(double v) - { - throw new IllegalArgumentException("StatusRootParameter hase no value"); - } - - public void setI(int v) - { - throw new IllegalArgumentException("StatusRootParameter hase no value"); - } - - public void saveChildrenDefaults() - { - for (AParameter aNodeParameter : parameterNodeList) - { - AAbstractParameter aNodeAbstractParameter = (AAbstractParameter) aNodeParameter; - if(aNodeAbstractParameter instanceof AStatusGroupParameter) - ((AStatusGroupParameter)aNodeAbstractParameter).saveChildrenDefaults(); - else - ((AStatusParameter)aNodeAbstractParameter).saveDefaults(); - } - } - - public void restoreDefaults() - { - for (AParameter aNodeParameter : parameterNodeList) - { - AAbstractParameter aNodeAbstractParameter = (AAbstractParameter) aNodeParameter; - aNodeAbstractParameter.restoreDefaults(); - } - if(statusTree != null) - { - for (int i = 1; i < statusTree.getRowCount(); i++) - statusTree.collapseRow(i); - } - } - - public void copy(int from, int to) - { - for (AParameter aNodeParameter : parameterNodeList) - { - AAbstractParameter aNodeAbstractParameter = (AAbstractParameter) aNodeParameter; - aNodeAbstractParameter.copy(from, to); - } - } - - public String getDifferences(String groupName) - { - StringBuffer ret = new StringBuffer(); - - for (AParameter aNodeParameter : parameterNodeList) - { - AAbstractParameter aNodeAbstractParameter = (AAbstractParameter) aNodeParameter; - if(aNodeAbstractParameter instanceof AStatusGroupParameter) - ret.append(((AStatusGroupParameter)aNodeAbstractParameter).getDifferences(groupName)); - else - ret.append(((AStatusParameter)aNodeAbstractParameter).getDifferences(groupName)); - } - - return ret.toString(); - } - - public class NodeSelectionListener extends MouseAdapter - { - private JTree tree; - - private int offsetX; - private int offsetY; - - NodeSelectionListener(JTree tree) - { - this.tree = tree; - offsetX = 0; - offsetY = 0; - } - - public void setOffset(int x, int y) - { - offsetX = x; - offsetY = y; - } - - public int getOffsetX() - { - return offsetX; - } - - public int getOffsetY() - { - return offsetY; - } - - public void mousePressed(MouseEvent e) - { - if (AUtilities.isRightMouseButton(e)) - { - AParameter clickedPar = null; - int x = e.getX(); - int y = e.getY(); - int row = tree.getRowForLocation(x, y); - TreePath path = tree.getPathForRow(row); - if (path != null) - { - Object clickedNode = path.getLastPathComponent(); - if (clickedNode instanceof ACheckNode) - { - ACheckNode node = (ACheckNode) clickedNode; - clickedPar = node.getParameter(); - } - - final AParameter effectPar = clickedPar; - if(effectPar instanceof AStatusParameter) - { - JPopupMenu popupMenu = new JPopupMenu(); - if (effectPar.getScope() == AParameter.LOCAL) - { - popupMenu.add(AParametersTable.SET_GLOBAL).addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - effectPar.changeScope(AParameter.GLOBAL); - refresh(); - } - }); - } - else - { - popupMenu.add(AParametersTable.SET_LOCAL).addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - effectPar.changeScope(AParameter.LOCAL); - refresh(); - } - }); - } - if (tree.isShowing()) - popupMenu.show(tree, e.getX(), e.getY()); - else - // when e.getSource() is the table - popupMenu.show((Component) e.getSource(), e.getX() + getOffsetX(), e.getY() + getOffsetY()); - } - else - { - popupGroupScopeMenu(effectPar, e); - } - } - } - } - - // groupPar is either AStatusRootParameter or AStatusGroupParameter - private final void changeGroupScopes(AParameter groupPar, int scope) - { - Iterator<AParameter> it; - if(groupPar instanceof AStatusRootParameter) - it = ((AStatusRootParameter) groupPar).getParameterList().iterator(); - else - it = ((AStatusGroupParameter) groupPar).getParameterList().iterator(); - while (it.hasNext()) - { - AParameter aPar = it.next(); - // aPar is either AStatusGroupParameter or AStatusParameter - if(aPar instanceof AStatusGroupParameter) - changeGroupScopes(aPar, scope); - else - aPar.changeScope(scope); - } - } - - // groupPar is either AStatusRootParameter or AStatusGroupParameter - private void popupGroupScopeMenu(AParameter groupPar, MouseEvent e) - { - final AParameter tmpPar = groupPar; - JPopupMenu popupMenu = new JPopupMenu(); - popupMenu.add(AParametersTable.SET_ALL_LOCAL).addActionListener( - new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - changeGroupScopes(tmpPar, AParameter.LOCAL); - refresh(); - } - }); - popupMenu.add(AParametersTable.SET_ALL_GLOBAL).addActionListener( - new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - changeGroupScopes(tmpPar, AParameter.GLOBAL); - refresh(); - } - }); - if (tree.isShowing()) - popupMenu.show(tree, e.getX(), e.getY()); - else - // when e.getSource() is the table - popupMenu.show((Component) e.getSource(), e.getX() + getOffsetX(), e.getY() + getOffsetY()); - } - - public void mouseClicked(MouseEvent e) - { - if (AUtilities.isRightMouseButton(e)) - { - return; - } - int x = e.getX(); - int y = e.getY(); - int row = tree.getRowForLocation(x, y); - TreePath path = tree.getPathForRow(row); - if (path != null) - { - Object clickedNode = path.getLastPathComponent(); - if (clickedNode instanceof ACheckNode) - { - ACheckNode node = (ACheckNode) clickedNode; - boolean newSelectionFlag; - if (node.getParameter() instanceof AStatusParameter) - newSelectionFlag = !node.isSelected(); - else - { - TristateCheckBox.State currentState = ((TristateCheckBox) node.getUserObject()).getState(); - if (currentState == TristateCheckBox.NOT_SELECTED) - newSelectionFlag = true; - else - newSelectionFlag = false; - } - node.getClicked(newSelectionFlag, true); - - if ((node.getSelectionMode() == ACheckNode.MULTI_SELECTION)) - { - if (node.isSelected()) - { - tree.expandPath(path); - } - else - { - if (row != 0) - tree.collapsePath(path); - } - } - ((DefaultTreeModel) tree.getModel()).nodeChanged(node); - // I need revalidate if node is root. but why? - if (row == 0) - { - tree.revalidate(); - tree.repaint(); - } - } - } - } - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/parameters/package.html b/graphics/AtlantisJava/src/atlantis/parameters/package.html deleted file mode 100644 index 8572821c5f1e9ac638b2e195abf07bc063a47498..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/parameters/package.html +++ /dev/null @@ -1,7 +0,0 @@ -<html> -<head></head> -<body> -<p>Application parameter store where APar and AParameter are the main - classes.</p> -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjection.java b/graphics/AtlantisJava/src/atlantis/projection/AProjection.java deleted file mode 100755 index 2cd72969cf86adc9ec1bd9f4b1d4cca8fddbf832..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjection.java +++ /dev/null @@ -1,32 +0,0 @@ -package atlantis.projection; - - -import java.awt.event.ActionListener; -import atlantis.canvas.AWindow; -import atlantis.event.AEventManager; -import atlantis.parameters.APar; - -import javax.swing.*; -import java.awt.*; - - -public abstract class AProjection implements ActionListener { - - protected static APar parameterStore = APar.instance(); - protected static AEventManager eventManager = AEventManager.instance(); - - public abstract String getName(); - public abstract String getScreenName(); - public abstract void paint(AWindow window, Graphics g); - - public abstract JMenuItem[] getPopupItems(); - - // next 4/5 needed for normal 2d projections, not for others e.g. Braintests - // should be changed at some point..... - public abstract String getXLabel(); - public abstract String getYLabel(); - public abstract String getXUnits(); - public abstract String getYUnits(); - public abstract void setScales(); - public abstract boolean processLocalCommand(String name); -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjection2D.java b/graphics/AtlantisJava/src/atlantis/projection/AProjection2D.java deleted file mode 100755 index d7a12dd4ead1dc0cf0c7ba93415f0ca78950c490..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjection2D.java +++ /dev/null @@ -1,348 +0,0 @@ -package atlantis.projection; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.geom.Point2D; -import java.util.List; -import java.util.ArrayList; - -import javax.swing.JMenuItem; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.data.ACalorimeterData; -import atlantis.data.ADHelix; -import atlantis.event.AData; -import atlantis.event.AEvent; -import atlantis.geometry.AAtlasDetector; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.parameters.AParameter; -import atlantis.utils.APolygon; -import atlantis.utils.AVector; - -/** - * Base class of Standard 2D projections handles the painting of a projection - * Handles non-linear transforms (linear transforms in AWindow) - */ -public abstract class AProjection2D extends AProjection -{ - private boolean debug = false; - protected ArrayList<JMenuItem> popupItems; - protected final static String ASPECT_RATIO_1 = "Aspect Ratio 1"; - - public AProjection2D() - { - popupItems = new ArrayList<JMenuItem>(); - } - - public void actionPerformed(ActionEvent e) - { - String action = e.getActionCommand(); - - if (action.equals(ASPECT_RATIO_1)) - setAspectRatio1(ACanvas.getCanvas().getCurrentWindow()); - } - - public void setAspectRatio1(AWindow window) - { - //Get the extend of the shown projection (i.e. the corners in user coordinates) - Point2D.Double[] corners = window.getUserCorners(); - AVector v01 = new AVector(corners[0], corners[1]); - AVector v12 = new AVector(corners[1], corners[2]); - //Get the actual size of this window on the screen - Rectangle wSize = window.getBounds(); - - //Calculate new corner positions - //This seems a bit longish to me... CLEANUP - S.B. - - //Calculate stretch factor f such that we keep the larger one of the two extends in user coordinates - //"modulus" just means length of vector! - double f = Math.min(wSize.width / v01.modulus(), wSize.height / v12.modulus()); - - //Rescale new width and height - double w = wSize.width / f; - double h = wSize.height / f; - - //All this just to calculate the center and the new scale - //Maybe easier to split with an if-statement rather than using "Math.min" above - AVector down = v12.getUnitary().scale(h / 2); - AVector up = v12.getUnitary().invert().scale(h / 2); - - AVector v0 = v01.getUnitary().invert().scale(w / 2).add(up); - AVector v1 = v01.getUnitary().scale(w / 2).add(up); - AVector v2 = v01.getUnitary().scale(w / 2).add(down); - - AVector v02 = new AVector(corners[0], corners[2]).scale(0.5); - Point2D.Double center = new Point2D.Double(corners[0].x + v02.dx, corners[0].y + v02.dy); - - //Set the new corner positions - corners[0].setLocation(center.x + v0.dx, center.y + v0.dy); - corners[1].setLocation(center.x + v1.dx, center.y + v1.dy); - corners[2].setLocation(center.x + v2.dx, center.y + v2.dy); - - //Apply new user coordinates - window.setUserCorners(corners); - } - - public boolean processLocalCommand(String name) - { - return false; - } - - public abstract String getName(); - - public String getScreenName() - { - return getName(); - } - - protected Color getBackgroundFillColor(Color[] colorMap) - { - return colorMap[parameterStore.get("Color", "BkgFill").getI()]; - } - - // min rho for tracks - public double getMinRho() - { - return 0.; - } - - public void paint(AWindow window, Graphics g) - { - - AEvent event = null; - List hitsAndTracks = null; - AGraphics ag = AGraphics.makeAGraphics(g); - long time = 0; - - if (debug) - { - time = System.currentTimeMillis(); - } - fillBackground(window, ag); - if (debug) - { - System.out.println("fill " + (System.currentTimeMillis() - time)); - time = System.currentTimeMillis(); - } - - // draw detector geometry - AAtlasDetector.getDetector().draw(window, ag, this); - if (debug) - { - System.out.println("det " + (System.currentTimeMillis() - time)); - time = System.currentTimeMillis(); - } - - // is true when F key is pressed during ZMR operations (detector is - // zoomed for instance, but data are not drawn during the operation) - boolean fastZooming = parameterStore.get("Projection", "SkipData").getStatus(); - if (fastZooming) - { - return; - } - - // draw the current event - event = eventManager.getCurrentEvent(); - - //If there is no current event do nothing - if (event == null) return; - - ACalorimeterData.drawCalorimeters(window, ag, this, event); - - hitsAndTracks = event.getHitsAndTracks(this); - if (debug) - { - System.out.println("calo " + (System.currentTimeMillis() - time)); - time = System.currentTimeMillis(); - } - for (int h = 0; h < hitsAndTracks.size(); h++) - { - ((AData) hitsAndTracks.get(h)).draw(window, ag, this); - if (debug) - { - long delta = (System.currentTimeMillis() - time); - if (delta > 0) - { - System.out.println(((AData) hitsAndTracks.get(h)).getName() + " " + delta); - } - time = System.currentTimeMillis(); - } - } // for - - } // paint() - - protected void fillBackground(AWindow window, AGraphics ag) - { - ag.setColor(getBackgroundFillColor(AColorMap.getColors())); - ag.fillRect(0, 0, window.getWidth(), window.getHeight()); - } - - // this is here to make drawing of tracks fast enough - public abstract ACoord getUserPoint(ADHelix dH, double s); - - public ACoord nonLinearTransform(ACoord user) - { - return user; - } - - public ACoord[] nonLinearTransform(ACoord[] user) - { - if (user != null) - for (int i = 0; i < user.length; i++) - user[i] = nonLinearTransform(user[i]); - return user; - } - - public Point2D.Double nonLinearTransform(double x, double y) - { - ACoord c = nonLinearTransform(new ACoord(x, y)); - return new Point2D.Double(c.hv[0][0][0], c.hv[1][0][0]); - } - - public Point2D.Double nonLinearTransform(Point2D.Double user) - { - return nonLinearTransform(user.x, user.y); - } - - public ACoord inverseNonLinearTransform(ACoord user) - { - return user; - } - - public Point2D.Double inverseNonLinearTransform(double x, double y) - { - ACoord c = inverseNonLinearTransform(new ACoord(x, y)); - - return new Point2D.Double(c.hv[0][0][0], c.hv[1][0][0]); - } - - public Point2D.Double inverseNonLinearTransform(Point2D.Double user) - { - return inverseNonLinearTransform(user.x, user.y); - } - - protected static ACoord nonLinearTransform2D(ACoord user, String projectionName) - { - AParameter fishEyePar = parameterStore.get(projectionName, "FishEye"); - - if (fishEyePar.getStatus()) - { - double[] z, r; - double fishEye = 0.001 * fishEyePar.getD(); - double rTo = parameterStore.get(projectionName, "rTo").getD(); - double zTo = parameterStore.get(projectionName, "zTo").getD(); - - for (int j = 0; j < user.hv[0].length; ++j) - { - z = user.hv[0][j]; - r = user.hv[1][j]; - for (int i = 0; i < z.length; ++i) - { - z[i] *= (1 + fishEye * zTo) / (1 + fishEye * Math.abs(z[i])); - r[i] *= (1 + fishEye * rTo) / (1 + fishEye * Math.abs(r[i])); - } - } - } - return user; - } - - protected static ACoord inverseNonLinearTransform2D(ACoord user, String projectionName) - { - AParameter fishEyePar = parameterStore.get(projectionName, "FishEye"); - - if (fishEyePar.getStatus()) - { - double[] z, r; - double fishEye = 0.001 * fishEyePar.getD(); - double rTo = parameterStore.get(projectionName, "rTo").getD(); - double zTo = parameterStore.get(projectionName, "zTo").getD(); - - for (int j = 0; j < user.hv[0].length; ++j) - { - z = user.hv[0][j]; - r = user.hv[1][j]; - for (int i = 0; i < z.length; ++i) - { - z[i] *= 1 / (1 + fishEye * (zTo - Math.abs(z[i]))); - r[i] *= 1 / (1 + fishEye * (rTo - Math.abs(r[i]))); - } - } - } - return user; - } - - protected static Point2D.Double[] aspectRatioLayout(double width, double height, Dimension wSize) - { - double f = Math.min(wSize.width / width, wSize.height / height); - - width = wSize.width / f; - height = wSize.height / f; - - Point2D.Double[] corners = new Point2D.Double[3]; - - corners[0] = new Point2D.Double(-width, +height); - corners[1] = new Point2D.Double(+width, +height); - corners[2] = new Point2D.Double(+width, -height); - return corners; - } - - public void setScales() - {} - - public abstract Point2D.Double[] calculateNoZoomCorners(Dimension wSize); - - public abstract Point2D.Double getCenter(); - - public Point2D.Double[] validateCorners(Point2D.Double[] corners) - { - APolygon p = new APolygon(); - - for (int i = 0; i < corners.length; i++) - p.addPoint(corners[i].x, corners[i].y); - - if (p.getArea() == 0) - return null; - else - return corners; - } - - /** - * This function is called when the ACanvas configuration was written on - * a screen with one aspect ratio but the current screen has a different - * aspect ratio. Subclasses may re-implement this to behave however they - * like. At present (when this was written) only YX does anything. - * - * -- Adam Davison - * - * @param w AWindow object containing this - * @param oldaspect Aspect ratio of screen where current window corners were chosen - * @param newaspect Aspect ratio of screen now - */ - - public void aspectRatioChange(AWindow w, double oldaspect, double newaspect) { - // Do nothing by default - } - - public JMenuItem[] getPopupItems() - { - // Can't cast arrays very easily... - JMenuItem[] ret = new JMenuItem[popupItems.size()]; - for (int i = 0; i < popupItems.size(); i++) { - ret[i] = (JMenuItem)popupItems.get(i); - } - return ret; - } - - protected void addPopupItem(String str) { - JMenuItem it = new JMenuItem(str); - popupItems.add(it); - it.addActionListener(this); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjection3D.java b/graphics/AtlantisJava/src/atlantis/projection/AProjection3D.java deleted file mode 100755 index 28bf192814cf5ba269084ff48041bc0aefb39afd..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjection3D.java +++ /dev/null @@ -1,167 +0,0 @@ -package atlantis.projection; - -import atlantis.data.ADHelix; -import atlantis.graphics.*; -import atlantis.parameters.APar; -import atlantis.utils.AMath; -import atlantis.event.*; -import java.awt.*; -import java.awt.geom.*; -import javax.swing.JMenuItem; - -public class AProjection3D extends AProjection2D { - - // axis about which the rotations take place - static private double phi; - static private double sinPhi, cosPhi; - // center of rotation in xyz frame - static private double rx, ry, rz; - // three axis abc in the xyz frame - static private double ax, ay, az; - static private double bx, by, bz; - static private double cx, cy, cz; - - static private double[][] abc=new double[3][3]; - - public AProjection3D() { - JMenuItem asp = new JMenuItem(ASPECT_RATIO_1); - asp.addActionListener(this); - popupItems.add(asp); - } - - public String getName() { - return "3D"; - } - - public String getXLabel() { - return "V"; - } - - public String getYLabel() { - return "H"; - } - - public String getXUnits() { - return "(cm)"; - } - - public String getYUnits() { - return "(cm)"; - } - - public Point2D.Double getCenter() { - return new Point2D.Double(0, 0); - } - - public Point2D.Double[] calculateNoZoomCorners(Dimension wSize) { - double radius=parameterStore.get("Projection", "TrackingRadius").getD(); - double length=parameterStore.get("Projection", "TrackingLength").getD(); - return aspectRatioLayout(length, radius, wSize); - } - - public static double getPhi() { - return parameterStore.get("3D", "Phi").getD(); - } - - public static void updateParameters() { - phi=Math.toRadians(getPhi()); - sinPhi=Math.sin(phi); - cosPhi=Math.cos(phi); - ax=parameterStore.get("3D", "xAxis").getD(); - ay=parameterStore.get("3D", "yAxis").getD(); - az=parameterStore.get("3D", "zAxis").getD(); - rx=parameterStore.get("Event", "XVtx").getD(); - ry=parameterStore.get("Event", "YVtx").getD(); - rz=parameterStore.get("Event", "ZVtx").getD(); - double dx; - double dy; - double dz; - - if(ax==0.&&ay==0) { - // d is the y-axis - dx=0.; - dy=-1.; - dz=0.; - } else { - // d is the z-axis - dx=0.; - dy=0.; - dz=1.; - } - - bx=+ay*dz-az*dy; - by=-ax*dz+az*dx; - bz=+ax*dy-ay*dx; - - cx=+ay*bz-az*by; - cy=-ax*bz+az*bx; - cz=+ax*by-ay*bx; - } - - public static double[][] getRotationMatrix() { - updateParameters(); - abc[0][0]=ax; - abc[0][1]=ay; - abc[0][2]=az; - abc[1][0]=bx; - abc[1][1]=by; - abc[1][2]=bz; - abc[2][0]=cx; - abc[2][1]=cy; - abc[2][2]=cz; - return abc; - } - - public static double[] getRotated(double[] p) { - updateParameters(); - double x=p[0]-rx; - double y=p[1]-ry; - double z=p[2]-rz; - - double u=x*ax+y*ay+z*az; - double v=x*bx+y*by+z*bz; - double w=x*cx+y*cy+z*cz; - - p[0]=u; - p[1]=v*cosPhi-w*sinPhi; - p[2]=v*sinPhi+w*cosPhi; - return p; - } - - public static double[][] getRotated(int numDraw, int[] listdl, float[] x, float[] y, float[] z) { - updateParameters(); - - double[][] uvw=new double[3][numDraw]; - - for(int i=0; i<numDraw; i++) { - int list=listdl[i]; - double xx=x[list]-rx; - double yy=y[list]-ry; - double zz=z[list]-rz; - double u=xx*ax+yy*ay+zz*az; - double v=xx*bx+yy*by+zz*bz; - double w=xx*cx+yy*cy+zz*cz; - uvw[0][i]=u; - uvw[1][i]=v*cosPhi-w*sinPhi; - uvw[2][i]=v*sinPhi+w*cosPhi; - } - return uvw; - } - - public static int[] getAxisMapping() { - return new int[] {0, 1, 2}; - } - - public ACoord getUserPoint(ADHelix dH, double s) { - return nonLinearTransform(dH.get3DPoint(s)); - } - - public ACoord nonLinearTransform(ACoord user) { - return nonLinearTransform2D(user, getName()); - } - - public ACoord inverseNonLinearTransform(ACoord user) { - return inverseNonLinearTransform2D(user, getName()); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjection3DBox.java b/graphics/AtlantisJava/src/atlantis/projection/AProjection3DBox.java deleted file mode 100755 index 62ae22b6913cd7ae2cec7df20fd5bddb31525027..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjection3DBox.java +++ /dev/null @@ -1,569 +0,0 @@ -package atlantis.projection; - -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.geom.Point2D; -import java.util.LinkedList; - -import javax.swing.JMenuItem; - -import Jama.Matrix; -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.data.A3DPointData; -import atlantis.data.ADHelix; -import atlantis.event.AEvent; -import atlantis.data.ATrackData; -import atlantis.graphics.ACoord; -import atlantis.graphics.ADrawParameters; -import atlantis.graphics.ADrawable; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; - -public class AProjection3DBox extends AProjection -{ - // angle of the rotation about the axis - static private double phi; - static private double sinPhi; - static private double cosPhi; - - static private double scale; - static private double zP; - static private double xz; - static private double yz; - - static private AVec3D centerDisplay; - static private AVec3D sizeDisplay; - - static private AVec3D sizeUser = new AVec3D(1.1, .5, .5); - - static final String RESTORE_DEFAULTS = "Default Box Volume"; - - static private LinkedList<AVec3D[]> planes = new LinkedList<AVec3D[]>(); - - static private JMenuItem[] popupItems; - - public AProjection3DBox() - { - popupItems = new JMenuItem[1]; - popupItems[0] = new JMenuItem(RESTORE_DEFAULTS); - popupItems[0].addActionListener(this); - } - - public String getName() - { - return "3DBox"; - } - - public String getScreenName() - { - return "3DBox"; - } - - public String getXLabel() - { - return "V"; - } - - public String getYLabel() - { - return "H"; - } - - public String getXUnits() - { - return "(cm)"; - } - - public String getYUnits() - { - return "(cm)"; - } - - public void setScales() - {} - - public boolean processLocalCommand(String name) - { - return false; - } - - public Point2D.Double getCenter(AWindow window) - { - updateParameters(window); - return new Point2D.Double(centerDisplay.x, centerDisplay.y); - } - - public void zoom(double factor) - { - if (factor != 0.) - { - sizeUser = sizeUser.scale(factor); - updateScale(); - } - } - - public static void setSizeUser(double size) - { - if (size != 0.) - { - sizeUser.x = size; - // updateScale(); - // ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - } - } - - public void zoomHorizontal(double factor) - { - if (factor != 0.) - { - sizeUser.x *= factor; - updateScale(); - } - } - - public void zoomVertical(double factor) - { - if (factor != 0. && !Double.isInfinite(factor)) - { - sizeUser.y *= factor; - sizeUser.z *= factor; - updateScale(); - } - } - - public static void updateScale() - { - scale = parameterStore.get("3DBox", "Scale").getD(); - ACanvas.getCanvas().getCurrentWindow().setUserCorners(0, 2. * sizeUser.x / scale, -sizeUser.y / scale, sizeUser.y / scale); - } - - public static void updateScale(AWindow window) - { - scale = parameterStore.get("3DBox", "Scale").getD(); - window.setUserCorners(0, 2. * sizeUser.x / scale, -sizeUser.y / scale, sizeUser.y / scale); - } - - public static double getPhi() - { - return parameterStore.get("3DBox", "Phi").getD(); - } - - public static void updateParameters(AWindow window) - { - phi = Math.toRadians(getPhi()); - sinPhi = Math.sin(phi); - cosPhi = Math.cos(phi); - scale = parameterStore.get("3DBox", "Scale").getD(); - zP = parameterStore.get("3DBox", "ZP").getD(); - xz = parameterStore.get("3DBox", "xz").getD(); - yz = parameterStore.get("3DBox", "yz").getD(); - - Rectangle bounds = window.getCurrDisp(); - centerDisplay = new AVec3D(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, 0.); - sizeDisplay = new AVec3D(0.5 * bounds.width * scale, 0.5 * bounds.height * scale, 0.5 * bounds.height * scale); - centerDisplay.x -= sizeDisplay.x; - updateScale(window); - } - - protected void drawBox(AGraphics ag) - { - double x = sizeDisplay.x; - double y = sizeDisplay.y; - double z = sizeDisplay.z; - - AVec3D[] firstPlane = new AVec3D[] { new AVec3D(0, y, z), new AVec3D(0, y, -z), new AVec3D(0, -y, -z), new AVec3D(0, -y, z) }; - AVec3D[] middlePlane = new AVec3D[] { new AVec3D(x, y, z), new AVec3D(x, y, -z), new AVec3D(x, -y, -z), new AVec3D(x, -y, z) }; - AVec3D[] lastPlane = new AVec3D[] { new AVec3D(2 * x, y, z), new AVec3D(2 * x, y, -z), new AVec3D(2 * x, -y, -z), new AVec3D(2 * x, -y, z) }; - - planes = new LinkedList<AVec3D[]>(); - - planes.add(firstPlane); - planes.add(middlePlane); - planes.add(lastPlane); - - for (int i = 0; i < planes.size(); i++) - { - AVec3D[] plane = (AVec3D[]) (planes.get(i)); - for (int j = 0; j < plane.length; ++j) - plane[j] = applyViewPoint(plane[j]); - } - - double[] h = new double[4]; - double[] v = new double[4]; - - // back - AVec3D[] back = new AVec3D[] { firstPlane[3], firstPlane[1], lastPlane[1], lastPlane[3] }; - for (int j = 0; j < back.length; ++j) - { - h[j] = back[j].x; - v[j] = back[j].y; - } - - ag.updateDrawParameters(new ADrawParameters(true, 0, 0, 1, 0, 0)); - ag.setColor(Color.gray); - ag.fillPolygon(h, v, 4); - ag.setColor(Color.white); - ag.drawPolygon(h, v, 4); - // base - AVec3D[] base = new AVec3D[] { firstPlane[0], firstPlane[1], lastPlane[1], lastPlane[0] }; - for (int j = 0; j < base.length; ++j) - { - h[j] = base[j].x; - v[j] = base[j].y; - } - ag.setColor(Color.black); - ag.fillPolygon(h, v, 4); - ag.setColor(Color.white); - ag.drawPolygon(h, v, 4); - - for (int i = 0; i < planes.size(); i++) - { - AVec3D[] plane = (AVec3D[]) (planes.get(i)); - for (int j = 0; j < plane.length; ++j) - { - h[j] = plane[j].x; - v[j] = plane[j].y; - } - ag.setColor(Color.black); - ag.fillPolygon(h, v, 4); - ag.setColor(Color.white); - ag.drawPolygon(h, v, 4); - } - - // top - AVec3D[] top = new AVec3D[] { firstPlane[3], firstPlane[2], lastPlane[2], lastPlane[3] }; - for (int j = 0; j < top.length; ++j) - { - h[j] = top[j].x; - v[j] = top[j].y; - } - ag.setColor(Color.white); - ag.drawPolygon(h, v, 4); - } - - protected void touchupBox(AGraphics ag) - { - ag.updateDrawParameters(new ADrawParameters(true, 0, 0, 1, 0, 0)); - ag.setColor(Color.white); - for (int i = 0; i < planes.size(); i++) - { - AVec3D[] plane = (AVec3D[]) (planes.get(i)); - ag.drawLine(plane[1].x, plane[1].y, plane[2].x, plane[2].y); - } - } - - AVec3D scale(AVec3D v) - { - return v.mult(sizeDisplay).divide(sizeUser); - } - - AVec3D rotate(AVec3D v) - { - return new AVec3D(v.x, v.y * cosPhi - v.z * sinPhi, v.y * sinPhi + v.z * cosPhi); - } - - static AVec3D applyViewPoint(AVec3D v) - { - return new AVec3D((v.x + xz * v.z) * (1 - v.z * zP) + centerDisplay.x, (v.y + yz * v.z) * (1 - v.z * zP) + centerDisplay.y, v.z); - } - - public void paint(AWindow window, Graphics g) - { - updateParameters(window); - AGraphics ag = AGraphics.makeAGraphics(g); - fillBackground(window, ag); - drawBox(ag); - AEvent event = eventManager.getCurrentEvent(); - if (event == null) - return; - - java.util.List hitsAndTracks = event.getHitsAndTracks(this); - - for (int h = 0; h < hitsAndTracks.size(); h++) - { - Object o = hitsAndTracks.get(h); - if (o instanceof ATrackData) - drawTracks((ATrackData) o, window, ag); - else if (o instanceof A3DPointData) - drawPoints((A3DPointData) o, window, ag); - } - touchupBox(ag); - } - - protected void drawPoints(A3DPointData pointData, AWindow window, AGraphics ag) - { - double[][] points = pointData.get3DPoints(); - int[] index = pointData.get3DPointsIndex(); - - double[][][] hv = new double[2][1][index.length]; - - for (int i = 0; i < points.length; ++i) - { - AVec3D point = rotate(new AVec3D(AProjection3D.getRotated(points[i]))); - - if (point.x > 0 && point.x < 2 * sizeUser.x && point.y > -sizeUser.y && point.y < sizeUser.y && point.z > -sizeUser.z && point.z < sizeUser.z) - { - point = applyViewPoint(scale(point)); - hv[0][0][i] = point.x; - hv[1][0][i] = point.y; - } - else - { - // aaargh allow this to be clipped from picture for now - hv[0][0][i] = -1000.; - hv[1][0][i] = -1000.; - } - } - - ag.draw(new ACoord(hv, index, pointData, ACoord.SYMBOLS)); - } - - protected void drawTracks(ATrackData tracks, AWindow window, AGraphics ag) - { - ADHelix[] dhelix = tracks.getHelices(); - - int numPlanes = planes.size(); - int numSegments = numPlanes + 4; - AVec3D[][] intersection = new AVec3D[dhelix.length][numPlanes]; - - double[][][] hv = new double[2][dhelix.length * numSegments][0]; - int[] index = new int[dhelix.length * numSegments]; - int[] indexTemp = tracks.getDrawList(); - for (int i = 0; i < indexTemp.length; ++i) - for (int j = 0; j < numSegments; ++j) - index[i * numSegments + j] = indexTemp[i]; - - int numPointsOnEllipse = 24; - AVec3D[] ellipse = new AVec3D[numPointsOnEllipse + 1]; - double radius = 0.005; - for (int i = 0; i < ellipse.length; i++) - { - double phi = 2. * Math.PI * i / numPointsOnEllipse; - ellipse[i] = new AVec3D(0., radius * Math.sin(phi), radius * Math.cos(phi)); - } - - for (int j = 0; j < dhelix.length; ++j) - if (dhelix[j] != null) - { - // s always 0? I don't know why that is... - double s = 0.; - AVec3D start = new AVec3D(dhelix[j].get3DPointAsArray(s)); - AVec3D end = new AVec3D(dhelix[j].get3DPointAsArray(s + 0.01)); - - boolean backwards = false; - - // calculate intersections - for (int p = 0; p < planes.size(); ++p) - { - // position of plane - double xInt = p * sizeUser.x; - double m = (xInt - start.x) / (end.x - start.x); - - // While we're in here, can check if we're pointing in the right direction - if (p == 1 && m < 0.0) { backwards = true; } - - double yInt = start.y + m * (end.y - start.y); - double zInt = start.z + m * (end.z - start.z); - intersection[j][p] = new AVec3D(xInt, yInt, zInt); - } - - // Throw out anything that isn't pointing in the right direction... - if (backwards) { continue; } - - AVec3D first = rotate(intersection[j][0]); - AVec3D middle = rotate(intersection[j][1]); - AVec3D last = rotate(intersection[j][numPlanes - 1]); - - if (first.y > -sizeUser.y && first.y < sizeUser.y && first.z > -sizeUser.z && first.z < sizeUser.z && last.y > -sizeUser.y && last.y < sizeUser.y && last.z > -sizeUser.z && last.z < sizeUser.z) - { - - double[][] cov = dhelix[j].helix.getCovariance(); - if (cov != null) - { - double[][] c = new double[2][2]; - c[0][0] = cov[0][0]; - c[0][1] = cov[0][1]; - c[1][0] = cov[1][0]; - c[1][1] = cov[1][1]; - Matrix covM = new Matrix(c); - Matrix errM = covM.inverse(); - - double b1 = errM.get(0, 0); - double b2 = errM.get(1, 1); - - double b3 = 2. * errM.get(0, 1); - if (parameterStore.get("3DBox", "ellipses").getStatus()) - { - ellipse = new AVec3D[180]; - - for (int i = 0; i < 360; i += 2) - { - double thetat = Math.toRadians(i); - double tt = Math.tan(thetat); - double xx = Math.sqrt(1. / (b1 + b2 * tt * tt + b3 * tt)); - if (i > 90 && i <= 270) - xx *= -1.; - ellipse[i / 2] = new AVec3D(0., xx, xx * tt); - } - } - // add intersections to draw list - for (int p = 0; p < planes.size(); ++p) - { - double[] h = new double[ellipse.length]; - double[] v = new double[ellipse.length]; - - for (int i = 0; i < ellipse.length; i++) - { - AVec3D point = applyViewPoint(scale(rotate(intersection[j][p].add(ellipse[i])))); - h[i] = point.x; - v[i] = point.y; - } - - hv[0][numSegments * j + p] = h; - hv[1][numSegments * j + p] = v; - } - } - first = applyViewPoint(scale(first)); - middle = applyViewPoint(scale(middle)); - last = applyViewPoint(scale(last)); - - double[][] edge = new double[planes.size()][2]; - for (int i = 0; i < planes.size(); i++) - { - AVec3D[] plane = (AVec3D[]) (planes.get(i)); - double xInt = plane[1].x; - double m = (xInt - first.x) / (last.x - first.x); - double yInt = first.y + m * (last.y - first.y); - edge[i] = new double[] { xInt, yInt }; - } - - hv[0][numSegments * j + 3] = new double[] { first.x, edge[1][0] }; - hv[1][numSegments * j + 3] = new double[] { first.y, edge[1][1] }; - hv[0][numSegments * j + 4] = new double[] { middle.x, edge[2][0] }; - hv[1][numSegments * j + 4] = new double[] { middle.y, edge[2][1] }; - - drawDashed(ag, tracks, indexTemp[j], edge[1][0], edge[1][1], middle.x, middle.y); - drawDashed(ag, tracks, indexTemp[j], edge[2][0], edge[2][1], last.x, last.y); - } - } - ag.draw(new ACoord(hv, index, tracks, ACoord.POLYLINES)); - } - - protected void drawDashed(AGraphics ag, ADrawable source, int ind, double h0, double v0, double h1, double v1) - { - double dH = h1 - h0; - double dV = v1 - v0; - double dist = Math.sqrt(dH * dH + dV * dV); - double dashSize = 4; - int num = (int) (dist / dashSize); - int[] index = new int[num / 2 + 1]; - double[][][] hv = new double[2][num / 2 + 1][2]; - - for (int i = 0; i < num; ++i) - { - if (i % 2 == 1) - { - int n = i / 2; - index[n] = ind; - hv[0][n][0] = h0 + dH * i / num; - hv[0][n][1] = h0 + dH * (i + 1) / num; - hv[1][n][0] = v0 + dV * i / num; - hv[1][n][1] = v0 + dV * (i + 1) / num; - if (i >= num - 2) - { - hv[0][n][1] = h1; - hv[1][n][1] = v1; - } - } - } - ag.draw(new ACoord(hv, index, source, ACoord.POLYLINES)); - } - -protected void fillBackground(AWindow window, AGraphics ag) - { - Color[] colorMap = AColorMap.getColors(); - ag.setColor(colorMap[getBackgroundFillColor()]); - ag.fillRect(0, 0, window.getWidth(), window.getHeight()); - } - - protected int getBackgroundFillColor() - { - return parameterStore.get("Color", "BkgFill").getI(); - } - - public JMenuItem[] getPopupItems() - { - return popupItems; - } - - public void actionPerformed(ActionEvent e) - { - String action = e.getActionCommand(); - if (action.equals(RESTORE_DEFAULTS)) - { - sizeUser.x = 2.; - sizeUser.y = .1; - sizeUser.z = .1; - updateScale(); - ACanvas.getCanvas().getCurrentWindow().repaintFromScratch(); - } - } - -} - -class AVec3D -{ - double x, y, z; - - AVec3D(double x, double y, double z) - { - this.x = x; - this.y = y; - this.z = z; - } - - AVec3D(double[] v) - { - this.x = v[0]; - this.y = v[1]; - this.z = v[2]; - } - - AVec3D cross(AVec3D d) - { - return new AVec3D(+this.y * d.z - this.z * d.y, -this.x * d.z + this.z * d.x, +this.x * d.y - this.y * d.x); - } - - AVec3D add(AVec3D d) - { - return new AVec3D(x + d.x, y + d.y, z + d.z); - } - - AVec3D mult(AVec3D d) - { - return new AVec3D(x * d.x, y * d.y, z * d.z); - } - - AVec3D divide(AVec3D d) - { - return new AVec3D(x / d.x, y / d.y, z / d.z); - } - - AVec3D scale(double s) - { - return new AVec3D(s * x, s * y, s * z); - } - - public String toString() - { - return x + " " + y + " " + z; - } - - public double mag2() { - return x*x + y*y + z*z; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionEventInfo.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionEventInfo.java deleted file mode 100644 index 1735ec2a666bc8d2c8313d49382783321309e7ba..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionEventInfo.java +++ /dev/null @@ -1,197 +0,0 @@ -package atlantis.projection; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.event.ActionEvent; -import java.awt.geom.Point2D; -import javax.swing.ImageIcon; -import javax.swing.JMenuItem; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.data.ADHelix; -import atlantis.event.AEvent; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.utils.AUtilities; - -/** Class used to display the ATLAS Experiment logo, along with - * Event Number, Run Number, and Date/Time - * - * @author Tom McLaughlan - */ -public class AProjectionEventInfo extends AProjectionInfo { - - private static long EventNumber; - private static long RunNumber; - private static String DateTime; - private static String Source; - private static Color textColor = Color.white, - backgroundColor = Color.black; - - public String getName() { - return "EventInfo"; - } - - public void paint(AWindow window, Graphics g) { - - AEvent event = eventManager.getCurrentEvent(); - - if (event != null) { - RunNumber = event.getRunNumber(); - EventNumber = event.getEventNumber(); - DateTime = event.getDateTime(); - Source = event.getSourceName(); - } - - // Begin drawing - AGraphics ag = AGraphics.makeAGraphics(g); - // Fill the background - ag.setColor(backgroundColor); - ag.fillRect(0, 0, window.getWidth(), window.getHeight()); - - String iconPath = AGlobals.instance().getHomeDirectory() + "img" + System.getProperty("file.separator"); - - ImageIcon i = AUtilities.getFileAsImageIcon(iconPath + "atlas_logo_shadow.png"); - - - // Determine height and width of current window, and width of ATLAS logo - // These are then used to determine a scaling factor which is used in the - // scale function. - // - int height = window.getSize().height; - int width = window.getSize().width; - int iwidth = i.getIconWidth(); - double factor = (double) width / (double) iwidth; - - // Call scale function to scale image to window size - ImageIcon iscale = AUtilities.scale(i.getImage(), factor, parameterStore.get("Prefs", "AntiAlias").getStatus()); - // x, y calculated to position image exactly centred - int x = (width / 2) - (iscale.getIconWidth() / 2); - int y = (height / 2) - ((3 * iscale.getIconHeight()) / 4); - - // get screen dpi for resolution independent scaling - // commented out 27/3 -- EJ - // without a screen you obviously do not have a screen resolution - int dpi = 72; //Toolkit.getDefaultToolkit().getScreenResolution(); - - // Set a scaling font size with window width - int fontSize = (int) Math.round(3.0 * width / (double) dpi); - - Font f = new Font("SansSerif", Font.PLAIN, fontSize); - - ag.drawImage(iscale.getImage(), x, y); - - ag.setColor(textColor); // Set colour for text - ag.updateColor(); // Update current colour for drawing - - String DateString = "", RunEventString = ""; - String DisclaimerString1 = "", DisclaimerString2 = ""; - if (event != null) { - DateString = "Date: " + DateTime; - RunEventString = "Run Number: " + RunNumber + ", Event Number: " + EventNumber; - DisclaimerString1 = "Snapshot of a proton collision"; - DisclaimerString2 = "directly from the ATLAS experiment"; - } else { - RunEventString = "No event data available"; - } - - FontMetrics fm = g.getFontMetrics(f); - int DateWidth = fm.stringWidth(DateString); - int RunEventWidth = fm.stringWidth(RunEventString); - int Disclaimer1Width = fm.stringWidth(DisclaimerString1); - int Disclaimer2Width = fm.stringWidth(DisclaimerString2); - - // This may need changing to be a bit more elegant - // -- currently under investigation by Tom - - // Check if font is wider than the window and scale down til it fits. - while ((RunEventWidth > width - 20) || (DateWidth > width - 20)) - { - - fontSize = fontSize - 1; - f = new Font("SansSerif", Font.PLAIN, fontSize); - fm = g.getFontMetrics(f); - RunEventWidth = fm.stringWidth(RunEventString); - DateWidth = fm.stringWidth(DateString); - Disclaimer1Width = fm.stringWidth(DisclaimerString1); - Disclaimer2Width = fm.stringWidth(DisclaimerString2); - } - - ag.setFont(f); // set font as defined above - - // For the streams at P1, we include a disclaimer - // Anything without .xml is considered a stream for now - if (Source != null && !Source.endsWith(".xml")) { - ag.drawString(DisclaimerString1, - (width / 2) - Disclaimer1Width / 2, 0.89 * height); - ag.drawString(DisclaimerString2, - (width / 2) - Disclaimer2Width / 2, 0.95 * height); - } - - if (event != null && !DateTime.equals("") && !DateTime.equals("n/a")) { - // If event contains Date/Time data, draw Run Number, Event Number and Date/Time - // and position text in centre of window - ag.drawString(RunEventString, - (width / 2) - RunEventWidth / 2, y + (1.1 * iscale.getIconHeight())); - - ag.drawString(DateString, - (width / 2) - DateWidth / 2, y + (1.3 * iscale.getIconHeight())); - } else { - // Draw text (No Date/Time, for MC events, etc) - ag.drawString(RunEventString, - (width / 2) - RunEventWidth / 2, y + (1.1 * iscale.getIconHeight())); - - } - - } - - public JMenuItem[] getPopupItems() { - return null; - } - - public String getXLabel() { - return ""; - } - - public String getXUnits() { - return ""; - } - - public String getYLabel() { - return ""; - } - - public String getYUnits() { - return ""; - } - - @Override - public void actionPerformed(ActionEvent e) { - assert false : "Did not expect AProjectionEventInfo to be used as ActionListener"; - } - - public void setScales() { - } - - public Point2D.Double getCenter() { - return new Point2D.Double(0.0, 0.0); - } - - public Point2D.Double[] calculateNoZoomCorners(Dimension wSize) { - Point2D.Double[] corners = new Point2D.Double[3]; - - corners[0] = new Point2D.Double(0., 2.); - corners[1] = new Point2D.Double(100., 2.); - corners[2] = new Point2D.Double(100., -2.); - return corners; - } - - public ACoord getUserPoint(ADHelix dH, double s) { - return ACoord.NO_DATA; - } -}//end of EventInfoProjection class diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionFR.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionFR.java deleted file mode 100755 index ddc52bdb54cf8e32b45e7e620d8fc2645240b9ac..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionFR.java +++ /dev/null @@ -1,127 +0,0 @@ -package atlantis.projection; - -import java.awt.Dimension; -import java.awt.geom.Point2D; - -import atlantis.canvas.ACanvas; -import atlantis.data.ADHelix; -import atlantis.graphics.ACoord; -import atlantis.interactions.AZMRInteraction; -import atlantis.parameters.APar; -import atlantis.parameters.AParameter; -import atlantis.utils.AMath; - -public class AProjectionFR extends AProjectionPhi -{ - public String getName() - { - return "FR"; - } - - public String getXLabel() - { - return AMath.RHO; - } - - public String getXUnits() - { - return "(cm)"; - } - - public Point2D.Double[] calculateNoZoomCorners(Dimension wSize) - { - Point2D.Double[] corners = new Point2D.Double[3]; - int phiWrap = parameterStore.get(getName(), "PhiWrap").getI(); - - double radius = parameterStore.get("Projection", "Radius").getD(); - corners[0] = new Point2D.Double(0, 360 + phiWrap); - corners[1] = new Point2D.Double(radius, 360 + phiWrap); - corners[2] = new Point2D.Double(radius, 0); - return corners; - } - - public ACoord getUserPoint(ADHelix dH, double s) - { - return nonLinearTransform(dH.getFRPoint(s)); - } - - public ACoord nonLinearTransform(ACoord user) - { - AParameter fishEyePar = parameterStore.get(getName(), "FishEye"); - - // Fisheye of projection FR should not change phi - if (fishEyePar.getStatus()) - { - double[] r; - //double[] phi; - double fishEye = 0.001 * fishEyePar.getD(); - double rTo = parameterStore.get(getName(), "rTo").getD(); - //Point2D.Double[] corners = ACanvas.getCanvas().getCurrentWindow().getUserCorners(); - //double phiMid = (corners[0].getY() + corners[2].getY()) / 2.; - - for (int j = 0; j < user.hv[0].length; ++j) - { - r = user.hv[0][j]; - //phi = user.hv[1][j]; - for (int i = 0; i < r.length; ++i) - { - double fact = (1 + fishEye * rTo) / (1 + fishEye * r[i]); - - //phi[i] = phiMid + (phi[i] - phiMid) * fact; - r[i] *= fact; - } - } - } - - // Horizontal Zoom is applied in ZMR interaction - - // don't know what this has to do here? - // CLEANUP - S.B. - /* AParameter horZoomPar = APar.get(getName(), "HorizontalZoom"); - - if (horZoomPar.getStatus()) - { - // performe initial horizontal zoom - double hzf = APar.get("FR", "HorizontalZoom").getD(); - Point2D.Double[] corners = ACanvas.getCanvas().getCurrentWindow().getUserCorners(); - double centerRho = corners[0].getX(); - double centerPhi = (corners[0].getY() + corners[2].getY()) / 2.; - Point2D.Double center = new Point2D.Double(centerRho, centerPhi); - AZMRInteraction.performHorizontalZoom(center, hzf, ACanvas.getCanvas().getPaintingWindow()); - - horZoomPar.setStatus(false); - } - */ - return user; - } - - public ACoord inverseNonLinearTransform(ACoord user) - { - AParameter fishEyePar = parameterStore.get(getName(), "FishEye"); - - if (fishEyePar.getStatus()) - { - double[] r; - //double[] phi; - double fishEye = 0.001 * fishEyePar.getD(); - double rTo = parameterStore.get(getName(), "rTo").getD(); - //Point2D.Double[] corners = ACanvas.getCanvas().getCurrentWindow().getUserCorners(); - //double phiMid = (corners[0].getY() + corners[2].getY()) / 2.; - - for (int j = 0; j < user.hv[0].length; ++j) - { - r = user.hv[0][j]; - //phi = user.hv[1][j]; - for (int i = 0; i < r.length; ++i) - { - double fact = 1 / (1 + fishEye * (rTo - r[i])); - - //phi[i] = phiMid + (phi[i] - phiMid) * fact; - r[i] *= fact; - } - } - } - - return user; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionFZ.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionFZ.java deleted file mode 100755 index 32c092064bd5bfdf68af406f15167149713a991a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionFZ.java +++ /dev/null @@ -1,76 +0,0 @@ -package atlantis.projection; - - -import atlantis.parameters.AParameter; -import atlantis.parameters.APar; -import java.awt.geom.*; -import java.awt.*; -import atlantis.graphics.ACoord; -import atlantis.data.ADHelix; - - -public class AProjectionFZ extends AProjectionPhi { - - public String getName() { - return "FZ"; - } - - public String getXLabel() { - return "Z"; - } - - public String getXUnits() { - return "(cm)"; - } - - public Point2D.Double[] calculateNoZoomCorners(Dimension wSize) { - Point2D.Double[] corners=new Point2D.Double[3]; - int phiWrap=parameterStore.get(getName(), "PhiWrap").getI(); - - double length=parameterStore.get("Projection", "Length").getD(); - - corners[0]=new Point2D.Double(-length, 360+phiWrap); - corners[1]=new Point2D.Double(length, 360+phiWrap); - corners[2]=new Point2D.Double(length, 0); - return corners; - } - - public ACoord getUserPoint(ADHelix dH, double s) { - return nonLinearTransform(dH.getFZPoint(s)); - } - - public ACoord nonLinearTransform(ACoord user) { - AParameter fishEyePar=parameterStore.get(getName(), "FishEye"); - - if(fishEyePar.getStatus()) { - double[] z; - double fishEye=0.001*fishEyePar.getD(); - double zTo=parameterStore.get(getName(), "zTo").getD(); - - for(int j=0; j<user.hv[0].length; ++j) { - z=user.hv[0][j]; - for(int i=0; i<z.length; ++i) - z[i]*=(1+fishEye*zTo)/(1+fishEye*Math.abs(z[i])); - } - } - return user; - } - - public ACoord inverseNonLinearTransform(ACoord user) { - AParameter fishEyePar=parameterStore.get(getName(), "FishEye"); - - if(fishEyePar.getStatus()) { - double[] z; - double fishEye=0.001*fishEyePar.getD(); - double zTo=parameterStore.get(getName(), "zTo").getD(); - - for(int j=0; j<user.hv[0].length; ++j) { - z=user.hv[0][j]; - for(int i=0; i<z.length; ++i) - z[i]*=1/(1+fishEye*(zTo-Math.abs(z[i]))); - } - } - return user; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionInfo.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionInfo.java deleted file mode 100644 index b7428f177514565b48e9a357c9f3b63ba9a51c4a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionInfo.java +++ /dev/null @@ -1,102 +0,0 @@ -package atlantis.projection; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.geom.Point2D; -import java.awt.image.BufferedImage; - -import javax.swing.ImageIcon; - -import atlantis.canvas.AWindow; -import atlantis.event.AEvent; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; - -/** - * Stripped down clone of the 2D Projection class - * Used simply to display event data (as text) in a window - * with the ATLAS experiment logo, for publications and presentation purposes - * - * Also contains rudimentary image scaling code used to scale the ATLAS logo depending - * on window size - * - * @author Tom McLaughlan - */ -public abstract class AProjectionInfo extends AProjection -{ - private boolean debug = false; - - protected final static String ASPECT_RATIO_1 = "Aspect Ratio 1"; - - public AProjectionInfo() - {} - - public boolean processLocalCommand(String name) - { - return false; - } - - public abstract String getName(); - - public String getScreenName() - { - return getName(); - } - - protected Color getBackgroundFillColor(Color[] colorMap) - { - return colorMap[parameterStore.get("Color", "BkgFill").getI()]; - } - - public void paint(AWindow window, Graphics g) - { - - AEvent event = null; - AGraphics ag = AGraphics.makeAGraphics(g); - long time = 0; - - if (debug) - { - time = System.currentTimeMillis(); - } - fillBackground(window, ag); - if (debug) - { - System.out.println("fill " + (System.currentTimeMillis() - time)); - time = System.currentTimeMillis(); - } - - - // draw the current event - event = eventManager.getCurrentEvent(); - - //If there is no current event do nothing - if (event == null) return; - - } // paint() - - protected void fillBackground(AWindow window, AGraphics ag) - { - ag.setColor(getBackgroundFillColor(AColorMap.getColors())); - ag.fillRect(0, 0, window.getWidth(), window.getHeight()); - } - - protected static Point2D.Double[] aspectRatioLayout(double width, double height, Dimension wSize) - { - double f = Math.min(wSize.width / width, wSize.height / height); - - width = wSize.width / f; - height = wSize.height / f; - - Point2D.Double[] corners = new Point2D.Double[3]; - - corners[0] = new Point2D.Double(-width, +height); - corners[1] = new Point2D.Double(+width, +height); - corners[2] = new Point2D.Double(+width, -height); - return corners; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionLegoPlot.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionLegoPlot.java deleted file mode 100755 index 2179a2d7f2e26d46f10f64ba8f9f3c52f381418e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionLegoPlot.java +++ /dev/null @@ -1,402 +0,0 @@ -package atlantis.projection; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.event.ActionEvent; -import java.awt.geom.Point2D; -import java.util.HashSet; -import java.util.Set; - -import atlantis.canvas.ACanvas; -import atlantis.canvas.AWindow; -import atlantis.data.ACalorimeterData; -import atlantis.data.ADHelix; -import atlantis.event.AEvent; -import atlantis.data.ALegoData; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.graphics.ALegoDraw; -import atlantis.graphics.colormap.AColorMap; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.utils.AMath; - -public class AProjectionLegoPlot extends AProjection2D -{ - public static byte nLayers = 29;//also used in ALegoData - //xz and yz are used to define the angle of the eta axis (altered in rotate interaction) - private static double[] xz; - private static double[] yz; - //Variables needed by ALegoDraw and ALegoData that are updated here from changes to the gui value - public static int defaultScale = parameterStore.get("LegoPlot", "Scale").getI();//set the axis scale (standard, log or sqrt) - public static int nPhiCells = parameterStore.get("LegoPlot", "nphicells").getI(); - public static int nEtaCells = parameterStore.get("LegoPlot", "netacells").getI(); - public static Color[] defaultColorMap = AColorMap.getColors(); - public static Color[] caloColorMap = AColorMap.getColors();//to allow colouring by energy - public static boolean reverse = false;//also used by ASynchroCursorsInteraction - public static int mode = parameterStore.get("LegoPlot", "Mode").getI(); - public static int colorEM, colorHad; - public static Set colorset = new HashSet();//not updated here - public static final int minimumofLogScale=(int) Math.round(Math.log10(0.01));// we set 10MeV to lego height 0 on log scale - protected final static String VIEW_DEFAULT = "View normal"; - protected final static String VIEW_FROM_ABOVE = "View from above"; - protected final static String VIEW_ET_ETA = "View Et v " + AMath.ETA; - protected final static String VIEW_ET_PHI = "View Et v " + AMath.PHI; - - //to select th right drawing options for AOD object towers - public final static int DRAW_MET = -21; - public final static int DRAW_MUON = -2; - public final static int DRAW_ELECTRON = -3; - public final static int DRAW_PHOTON = -4; - public final static int DRAW_CLUSTER = -5; - public final static int DRAW_COMPOSITEPARTICLE = -6; - public final static int DRAW_BJET = -7; - public final static int DRAW_TAUJET = -8; - public final static int DRAW_JET = -9; - - public AProjectionLegoPlot() { - addPopupItem(VIEW_DEFAULT); - addPopupItem(VIEW_FROM_ABOVE); - addPopupItem(VIEW_ET_ETA); - addPopupItem(VIEW_ET_PHI); - } - - @Override - public void actionPerformed(ActionEvent e) - { - String action = e.getActionCommand(); - int index=0; - AWindow currentWindow = ACanvas.getCanvas().getCurrentWindow(); - index=currentWindow.getIndex(); - Point2D.Double[] corners = currentWindow.getUserCorners(); - double dPhi=0,dEta=0,currentxz=xz[index],currentyz=yz[index]; - - if (action.equals(VIEW_DEFAULT)) - { - xz[index]=0.6; - yz[index]=0.5; - } - else if (action.equals(VIEW_FROM_ABOVE)) - { - xz[index]=0.8; - yz[index]=0.9; - } - else if (action.equals(VIEW_ET_PHI)) - { - xz[index]=0.0; - yz[index]=-50; - } - else if (action.equals(VIEW_ET_ETA)) - { - xz[index]=360.0; - yz[index]=-75; - } - dPhi=360*(xz[index]-currentxz); - dEta=50*(currentyz-yz[index]); - corners[0].x -= (dPhi); - corners[0].y -= (dEta); - corners[1].y -= (dEta); - currentWindow.setUserCorners(corners); - //reset the center of detector dot on ZMR - // TODO: Check if this really is superfluous. I can't find any situation where it - // sets the interaction group to anything other than its old value. - Ben Waugh 2011-11-09 -// currentWindow.getInteractionManager().setContext(currentWindow.getInteractionToolBar().getSelectedGroup()); - } - - @Override - public void setAspectRatio1(AWindow window) - { - AOutput.append("\nNot implemented for this projection\n", ALogInterface.WARNING); - } - - public String getName() - { - return "LegoPlot"; - } - - public String getXLabel() - { - return AMath.PHI; - } - - public String getYLabel() - { - return AMath.ETA; - } - - public String getXUnits() - { - return AMath.DEGREES; - } - - public String getYUnits() - { - return ""; - } - - public Point2D.Double getCenter() - { - /*in the lego plot the center changes if there is rotation - however the getCenter is also needed in initialization - which is before windows are indexed*/ - int index=0; - double temp=0; - //check to see if the windows are indexed - try - { - index=ACanvas.getCanvas().getCurrentWindow().getIndex(); - } - catch(Throwable t) - { - temp=0.6;//hasn't indexed windows yet - } - if(temp==0) - temp=xz[index]; - return new Point2D.Double(-360.0*temp,-5.0); - } - - public Point2D.Double[] calculateNoZoomCorners(Dimension wSize) - { - if(xz==null) - { - xz=new double[ACanvas.getCanvas().getWindowsCount()]; - for(int i=0; i<ACanvas.getCanvas().getWindowsCount(); i++) - { - xz[i]=0.6; - } - } - if(yz==null) - { - yz=new double[ACanvas.getCanvas().getWindowsCount()]; - for(int i=0; i<ACanvas.getCanvas().getWindowsCount(); i++) - { - yz[i]=0.5; - } - } - if(ACanvas.getCanvas().getCurrentWindow()!=null) - { - int currentIndex =ACanvas.getCanvas().getCurrentWindow().getIndex(); - xz[currentIndex]=0.6; - yz[currentIndex]=0.5; - } - //called before have windows so xz=0.6 and yz=0.5 - Point2D.Double[] corners = new Point2D.Double[3]; - corners[0]=new Point2D.Double(-360.0*0.6,-5-0.5*50); - corners[1]=new Point2D.Double(360.0, -5-0.5*50); - corners[2]=new Point2D.Double(360.0, 5); - //add on an offset - corners[0].x-=25.0; - corners[1].x+=25.0; - corners[2].x+=25.0; - corners[2].y+=3.0; - return corners; - } - - public ACoord getUserPoint(ADHelix dH, double s) - { - return nonLinearTransform(dH.getLEGOPoint(s)); - } - - @Override - public void paint(AWindow window, Graphics g) - { - // update parameters - update(); - // Load the event - AEvent event = eventManager.getCurrentEvent(); - if (event == null) - return; - // Create and fill histograms - double[][][] lego = new double[nPhiCells][nEtaCells][nLayers]; - ALegoData.fillHistograms(event, lego); - // Find the maximum energy - double maxEt = 0.0, AODmaxEt = 0.0, LEGOmaxEt = 0.0; - // loop over histogram data to scale towers and find maxEt - LEGOmaxEt = ALegoData.findMaxEt(lego); - maxEt=LEGOmaxEt; - // loop over AOD data - AODmaxEt = ALegoData.findAODMaxEt(event); - //check if user wants to scale to AOD objects rather than cells - //but only if the AOD max is greater than 0 - if(AODmaxEt==0) - { - if(!parameterStore.get("LegoPlot", "ScaleToAOD").isInitialized()) - parameterStore.get("LegoPlot", "ScaleToAOD").initialize(); - parameterStore.get("LegoPlot", "ScaleToAOD").getNameComponent().setEnabled(false); - } - else - { - if(!parameterStore.get("LegoPlot", "ScaleToAOD").isInitialized()) - parameterStore.get("LegoPlot", "ScaleToAOD").initialize(); - parameterStore.get("LegoPlot", "ScaleToAOD").getNameComponent().setEnabled(true); - } - if(AODmaxEt>0 && parameterStore.get("LegoPlot", "ScaleToAOD").getStatus()) - { - maxEt=AODmaxEt; - //user can no longer set the scale manually - if(!parameterStore.get("LegoPlot", "ETAxisHeight").isInitialized()) - parameterStore.get("LegoPlot", "ETAxisHeight").initialize(); - parameterStore.get("LegoPlot", "ETAxisHeight").getNameComponent().setEnabled(false); - parameterStore.get("LegoPlot", "ETAxisHeight").getValueComponent().setEnabled(false); - } - else - { - //user can now set the scale maually - if(!parameterStore.get("LegoPlot", "ETAxisHeight").isInitialized()) - parameterStore.get("LegoPlot", "ETAxisHeight").initialize(); - parameterStore.get("LegoPlot", "ETAxisHeight").getNameComponent().setEnabled(true); - parameterStore.get("LegoPlot", "ETAxisHeight").getValueComponent().setEnabled(true); - //check if user has defined a scale - if (parameterStore.get("LegoPlot", "ETAxisHeight").getD() > 0.0) - { - // use the user defined scale - maxEt = parameterStore.get("LegoPlot", "ETAxisHeight").getD(); - } - } - // Find the missing ET - double met = ALegoData.findMissingEt(window,lego,event); - // Begin drawing - AGraphics ag = AGraphics.makeAGraphics(g); - // Fill the background - ALegoDraw.fillBackground(window, ag); - // Draw the legend - boolean drawLegend=false; - if(!drawLegend && parameterStore.get("LegoPlot", "MainLegend").getStatus())drawLegend=true; - if(!drawLegend && parameterStore.get("LegoPlot", "L1EtLegend").getStatus())drawLegend=true; - if(!drawLegend && parameterStore.get("LegoPlot", "L1Items").getStatus())drawLegend=true; - if(!drawLegend && parameterStore.get("LegoPlot", "L2Items").getStatus())drawLegend=true; - if(!drawLegend && parameterStore.get("LegoPlot", "EFItems").getStatus())drawLegend=true; - if(drawLegend)ALegoDraw.drawLegend(window,ag,event,met,maxEt,AODmaxEt); - - // Scale the values for the axis type - maxEt=scaleMaxET(maxEt,AODmaxEt); - AODmaxEt=ALegoData.scaleValue(AODmaxEt); - met=ALegoData.scaleValue(met); - if(parameterStore.get("LegoPlot","DrawPlot").getStatus()) - { - // Draw the grid - //System.out.println("maxEt = "+maxEt+" and LEGOmaxEt = "+LEGOmaxEt); - ALegoDraw.drawGrid(window, ag, maxEt); - // Draw the histograms - ALegoData.drawHistograms(window, ag, event, lego, maxEt, met, AODmaxEt); - } - } // paintLego() - - /** - * MaxEt is rounded to get the axis height as well as being scaled - */ - private static double scaleMaxET(double maxEt, double AODmaxEt) - { - //for drawing if maxEt is 0 use AODmaxEt for scaling - if (maxEt == 0) - maxEt = AODmaxEt; - maxEt=ALegoData.scaleValue(maxEt); - //now round to get axis height - if (defaultScale ==1 ) - { - maxEt = Math.ceil(maxEt); - } - else if (maxEt > 10.0) - { - //set maximum to nearest 5 above maxEt - maxEt = 5 * (Math.ceil(maxEt / 5.0)); - } - else if (maxEt < 10.0) - { - maxEt = Math.ceil(maxEt); - } - return maxEt; - } - - /** Shifts the real value of phi to the screen coord to account for the slope of the eta axis. - * For reverse of operation use -adjustPhi(window,-phi,eta) - */ - public static double adjustPhi(AWindow window, double phi, double eta) - { - int index=window.getIndex(); - eta+=5;//scale to between 0 and 10 - eta/=10.0;//scale to between 0 and 1 - eta-=1;//scale to between -1 and 0 - eta*=(xz[index]*360.0);//fraction of full offset to take off - phi+=eta;//take off the fraction - return phi;//now adjusted from slant of eta axis - } - - public static double getxz(int index) - { - return xz[index]; - } - - public static double getyz(int index) - { - return yz[index]; - } - - public static void setxz(int index, double xznew) - { - xz[index]=xznew; - } - - public static void setyz(int index, double yznew) - { - yz[index]=yznew; - } - - /**check if colouring by EM/HAD - * - * @return boolean drawEMHAD - */ - public static boolean getDrawEMHAD() - { - boolean drawEMHAD=false; - if (mode == 0 && parameterStore.get("LAr", "ColorFunction").getI()==6) - { - //Calorimeter Lego - drawEMHAD=true; - } - else if (mode == 1 && parameterStore.get("LVL1TriggerTower", "ColorFunction").getI()==1) - { - //Trigger Tower Lego - drawEMHAD=true; - } - return drawEMHAD; - } - - public static void update() - { - defaultScale = parameterStore.get("LegoPlot", "Scale").getI(); - nPhiCells = parameterStore.get("LegoPlot", "nphicells").getI(); - nEtaCells = parameterStore.get("LegoPlot", "netacells").getI(); - defaultColorMap = AColorMap.getColors(); - caloColorMap = AColorMap.getColors(); - if (parameterStore.get("LAr", "ColorFunction").getI() == ACalorimeterData.COLOR_FUNC_ENERGY) - { - switch (AColorMap.getColorMap()) - { - case AColorMap.COLOR_MAP_DEFAULT1: - case AColorMap.COLOR_MAP_DEFAULT2: - case AColorMap.COLOR_MAP_M4M5: - case AColorMap.COLOR_MAP_GRAYDET: - case AColorMap.COLOR_MAP_ORIGINAL: - // Use colors. - caloColorMap = AColorMap.getColors(AColorMap.COLOR_MAP_HITCOL); - break; - case AColorMap.COLOR_MAP_GRAY: - case AColorMap.COLOR_MAP_BW: - // Use grayscale. - caloColorMap = AColorMap.getColors(AColorMap.COLOR_MAP_GRAY_HITCOL); - break; - } - } - else if (parameterStore.get("LAr", "ColorFunction").getI() == ACalorimeterData.COLOR_FUNC_TIME) - { - caloColorMap = AColorMap.getShades(nLayers+1); - } - reverse = parameterStore.get("LegoPlot", "Reverse").getStatus(); - mode = parameterStore.get("LegoPlot", "Mode").getI(); - //Use detector color but add on 12 to get different shade of same color - colorEM = parameterStore.get("Det", "ECAL" + "Fill").getI() + 12; - colorHad = parameterStore.get("Det", "HCAL" + "Fill").getI() + 12; - } -}//end of LegoProjection class diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionN3D.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionN3D.java deleted file mode 100644 index 1c57d9e8a71984baf2a58f9825f567636aeb2c0c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionN3D.java +++ /dev/null @@ -1,66 +0,0 @@ -package atlantis.projection; - -import atlantis.nge.ANFrameManager; -import java.awt.event.ActionEvent; -import javax.swing.JMenuItem; - -/** - * - * @author Adam Davison - */ -public class AProjectionN3D extends AProjectionNGE { - - @Override - public void configureFrame(ANFrameManager fm) { - fm.checkProjection3D(); - } - - @Override - public String getName() { - return "N3D"; - } - - @Override - public String getScreenName() { - return "N3D"; - } - - @Override - public JMenuItem[] getPopupItems() { - return null; - } - - @Override - public String getXLabel() { - return "X"; - } - - @Override - public String getYLabel() { - return "Y"; - } - - @Override - public String getXUnits() { - return "m"; - } - - @Override - public String getYUnits() { - return "m"; - } - - @Override - public void setScales() { - - } - - @Override - public boolean processLocalCommand(String name) { - return false; - } - - public void actionPerformed(ActionEvent e) { - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionNGE.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionNGE.java deleted file mode 100644 index 3f9294ff858f9de37b12c60c7d0d8baa4622224c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionNGE.java +++ /dev/null @@ -1,143 +0,0 @@ -package atlantis.projection; - -import atlantis.canvas.AWindow; -import atlantis.nge.ANFrameManager; -import atlantis.nge.ANManager; -import atlantis.utils.ALogger; -import com.sun.opengl.util.Screenshot; -import java.awt.Graphics; -import java.awt.image.BufferedImage; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLEventListener; - -/** - * This projection bridges between the traditional canvas and the new graphics - * engine code. Essentially it looks like an old style projection but when - * asked to paint it calls the new code and returns an image - * - * @author Adam Davison - */ -public abstract class AProjectionNGE extends AProjection implements GLEventListener { - - private static ALogger logger = ALogger.getLogger(AProjectionNGE.class); - - //private GLPbuffer m_buf = null; - private BufferedImage m_img = null; - private int m_h = 0; - private int m_w = 0; - - private AWindow m_currentWindow; - - public AProjectionNGE() { - - } - -/* @Override - public String getName() { - return "NGE"; - } - - @Override - public String getScreenName() { - return "NGE"; - }*/ - - public abstract void configureFrame(ANFrameManager fm); - - @Override - public void paint(AWindow window, Graphics g) { - - m_currentWindow = window; - - long before = System.nanoTime(); - - m_w = window.getWidth(); - m_h = window.getHeight(); - - //logger.info("Window w: " + m_w + " h: " + m_h); - - //System.out.println("TAG A"); - - configureFrame(ANManager.getManager().getFrameManager(window)); - - //System.out.println("TAG B"); - - ANManager.getManager().requestBufferDraw(m_w, m_h, this); - - //System.out.println("TAG C"); - - // TODO: Check m_img isn't null - //g.drawImage(m_img, 0, 0, m_w, m_h, null); - g.drawImage(m_img, 0, 0, m_w, m_h, 0, m_img.getHeight()-m_h, m_w, m_img.getHeight(), null); - - //System.out.println("TAG D copyback done"); - - long after = System.nanoTime(); - //System.out.println("Draw took: " + (after - before)/1000); - - //ANManager.getManager().requestReschedule(window); - } - -/* @Override - public JMenuItem[] getPopupItems() { - return null; - //throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public String getXLabel() { - return "XLABEL"; - } - - @Override - public String getYLabel() { - return "YLABEL"; - } - - @Override - public String getXUnits() { - return ""; - //throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public String getYUnits() { - return ""; - //throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setScales() { - //throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean processLocalCommand(String name) { - return false; - //throw new UnsupportedOperationException("Not supported yet."); - } - - public void actionPerformed(ActionEvent e) { - System.out.println(e.toString()); - //throw new UnsupportedOperationException("Not supported yet."); - }*/ - - public void init(GLAutoDrawable arg0) { - } - - public void display(GLAutoDrawable arg0) { - - //System.out.println("DISPLAY IN NGE"); - ANManager.getManager().getFrameManager(m_currentWindow).display(arg0, m_w, m_h); - //System.out.println("PAINT DONE"); - m_img = Screenshot.readToBufferedImage(ANManager.getNextPower2(m_w), - ANManager.getNextPower2(m_h)); - //System.out.println("COPIED BACK"); - } - - public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) { - } - - public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) { - } -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionNPhysics.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionNPhysics.java deleted file mode 100644 index e608bd9e51ccc58eec4ba163a1186c3da3770061..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionNPhysics.java +++ /dev/null @@ -1,95 +0,0 @@ -package atlantis.projection; - -import atlantis.nge.ANAnimVar; -import atlantis.nge.ANFrameManager; -import atlantis.nge.ANProjectionPhysics; -import atlantis.utils.AMath; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.JMenuItem; - -/** - * - * @author Adam Davison, Mark Stockton - */ -public class AProjectionNPhysics extends AProjectionNGE { - - private ANProjectionPhysics m_p = null; - private ANFrameManager m_fm = null; - - @Override - public void configureFrame(ANFrameManager fm) { - m_fm = fm; - m_p = fm.checkProjectionPhysics(); - } - - @Override - public String getName() { - return "NPhysics"; - } - - @Override - public String getScreenName() { - return "NPhysics"; - } - - @Override - public JMenuItem[] getPopupItems() { - - JMenuItem phi = new JMenuItem(AMath.ETA + " view"); - phi.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - phiView(); - } - }); - - JMenuItem[] i = { - phi - }; - return i; - } - - @Override - public String getXLabel() { - return "X"; - } - - @Override - public String getYLabel() { - return "Y"; - } - - @Override - public String getXUnits() { - return "m"; - } - - @Override - public String getYUnits() { - return "m"; - } - - @Override - public void setScales() { - - } - - @Override - public boolean processLocalCommand(String name) { - return false; - } - - public void actionPerformed(ActionEvent e) { - } - - public void phiView() { - - ANAnimVar pelev = m_p.getElevVar(); - ANAnimVar pphi = m_p.getPhiVar(); - - m_fm.getAnimationManager().scheduleAnimation(pelev, 0.0, 1.0, pelev.getValue(), -90.0); - m_fm.getAnimationManager().scheduleAnimation(pphi, 0.0, 1.0, pphi.getValue(), 0.0); - - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionNYX.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionNYX.java deleted file mode 100644 index fb95d8ff95aa901b663419404bf792b69528b259..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionNYX.java +++ /dev/null @@ -1,71 +0,0 @@ -package atlantis.projection; - -import atlantis.nge.ANFrameManager; -import java.awt.event.ActionEvent; -import javax.swing.JMenuItem; - -/** - * - * @author Adam Davison - */ -public class AProjectionNYX extends AProjectionNGE { - - public AProjectionNYX() { - - } - - @Override - public void configureFrame(ANFrameManager fm) { - fm.checkProjectionYX(); - } - - @Override - public String getName() { - return "NYX"; - } - - @Override - public String getScreenName() { - return "NYX"; - } - - @Override - public JMenuItem[] getPopupItems() { - return null; - } - - @Override - public String getXLabel() { - return "X"; - } - - @Override - public String getYLabel() { - return "Y"; - } - - @Override - public String getXUnits() { - return "m"; - } - - @Override - public String getYUnits() { - return "m"; - } - - @Override - public void setScales() { - - } - - @Override - public boolean processLocalCommand(String name) { - return false; - } - - public void actionPerformed(ActionEvent e) { - // - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionPhi.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionPhi.java deleted file mode 100755 index 92785454bb58927b6ce24f2b3d0df532321d1f70..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionPhi.java +++ /dev/null @@ -1,73 +0,0 @@ -package atlantis.projection; - -import atlantis.parameters.AParameter; -import atlantis.parameters.APar; -import atlantis.utils.AMath; -import atlantis.utils.AVector; -import java.awt.geom.*; - -/** - * Base class of all phi projections - */ - -public abstract class AProjectionPhi extends AProjection2D { - - public String getScreenName() - { - return AMath.PHI+ getXLabel(); - } - - public String getYLabel() { - return AMath.PHI; - } - - public String getYUnits() { - return AMath.DEGREES; - } - - public double getMinRho() { - return 2.; - } - - public Point2D.Double getCenter() { - int phiWrap=parameterStore.get(getName(), "PhiWrap").getI(); - - return new Point2D.Double(0, (360+phiWrap)/2); - } - - public Point2D.Double[] validateCorners(Point2D.Double[] corners) { - if(super.validateCorners(corners)==null) - return null; - int phiWrap=parameterStore.get(getName(), "PhiWrap").getI(); - AParameter initialFramePar=parameterStore.get(getName(), "InitialFrame"); - - if(Math.abs(getMaxPhi(corners)-getMinPhi(corners))>(360+phiWrap)) - return null; - if(getMaxPhi(corners)>(initialFramePar.getI()*360+2*360-90)) - initialFramePar.setI(initialFramePar.getI()+1); - if(getMinPhi(corners)<(initialFramePar.getI()*360+90)) - initialFramePar.setI(initialFramePar.getI()-1); - return corners; - } - - private static double getMinPhi(Point2D.Double[] corners) { - double phiMin=corners[0].y; - - for(int i=0; i<corners.length; i++) - if(corners[i].y<phiMin) phiMin=corners[i].y; - AVector v12=new AVector(corners[1], corners[2]); - - return Math.min(phiMin, corners[0].y+v12.dy); - } - - private static double getMaxPhi(Point2D.Double[] corners) { - double phiMax=corners[0].y; - - for(int i=0; i<corners.length; i++) - if(corners[i].y>phiMax) phiMax=corners[i].y; - AVector v12=new AVector(corners[1], corners[2]); - - return Math.max(phiMax, corners[0].y+v12.dy); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionRZ.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionRZ.java deleted file mode 100755 index a47d1e0f05ff71d4fbb0e53e5318f761a5aebd15..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionRZ.java +++ /dev/null @@ -1,68 +0,0 @@ -package atlantis.projection; - -import atlantis.data.ADHelix; -import atlantis.graphics.ACoord; -import atlantis.utils.AMath; -import java.awt.*; -import java.awt.geom.*; -import atlantis.event.*; -import atlantis.parameters.*; - -public class AProjectionRZ extends AProjection2D { - - public AProjectionRZ() { - addPopupItem(ASPECT_RATIO_1); - } - - public String getName() { - return "RZ"; - } - - public String getScreenName() - { - return AMath.RHO + "Z"; - } - - public String getXLabel() { - return "Z"; - } - - public String getYLabel() { - return AMath.RHO; - } - - public String getXUnits() { - return "(cm)"; - } - - public String getYUnits() { - return "(cm)"; - } - - public Point2D.Double getCenter() { - return new Point2D.Double(0, 0); - } - - public Point2D.Double[] calculateNoZoomCorners(Dimension wSize) { - double radius=parameterStore.get("Projection", "Radius").getD(); - double length=parameterStore.get("Projection", "Length").getD(); - return aspectRatioLayout(length, radius, wSize); - } - - public ACoord getUserPoint(ADHelix dH, double s) { - return nonLinearTransform(dH.getRZPoint(s)); - } - - public ACoord nonLinearTransform(ACoord user) { - return nonLinearTransform2D(user, getName()); - } - - public ACoord inverseNonLinearTransform(ACoord user) { - return inverseNonLinearTransform2D(user, getName()); - } - - public static int[] getAxisMapping() { - return new int[] {2, 1, 0}; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionTrackResidual.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionTrackResidual.java deleted file mode 100644 index fc07eddcbea4fee7b2f80c47b2d369fe65660f7b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionTrackResidual.java +++ /dev/null @@ -1,167 +0,0 @@ -package atlantis.projection; - -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.geom.Point2D; - -import atlantis.canvas.AWindow; -import atlantis.data.ADHelix; -import atlantis.data.ATrackResidualData; -import atlantis.graphics.ACoord; -import atlantis.graphics.AGraphics; -import atlantis.parameters.APar; -import atlantis.utils.AMath; - -public class AProjectionTrackResidual extends AProjection2D -{ - private ATrackResidualData residual; - private String residualType; - private double xLength; - private double yLength = 1.0; - - /** - * @param residual The residual to set. - */ - public void setResidual(ATrackResidualData residual) - { - this.residual = residual; - } - - public ATrackResidualData getResidual() - { - return residual; - } - - public void setResidualType(String type) - { - residualType = type; - } - - public String getResidualType() - { - return residualType; - } - - public String getName() - { - return "TrackResidual"; - } - - public String getXLabel() - { - return "Index"; - } - - public String getYLabel() - { - return "Res"; - } - - public String getXUnits() - { - return ""; - } - - public String getYUnits() - { - return "(mm)"; - } - - public double getXLength() - { - return xLength; - } - - public double getYLength() - { - return yLength; - } - - public Point2D.Double getCenter() - { - return new Point2D.Double(0.0, 0.0); - } - - // not useful for this projection, only put here to be compatible with - // other code - public Point2D.Double[] calculateNoZoomCorners(Dimension wSize) - { - Point2D.Double[] corners=new Point2D.Double[3]; - - corners[0]=new Point2D.Double(0., 2.); - corners[1]=new Point2D.Double(100., 2.); - corners[2]=new Point2D.Double(100., -2.); - return corners; - } - - public Point2D.Double[] calculateNoZoomCorners() - { - float[] dataArray; - if(residualType.equals(ATrackResidualData.RESIDUAL_X)) - dataArray = residual.getResLoc1(); - else - dataArray = residual.getPullLoc1(); - - xLength = dataArray.length; - if(parameterStore.get(getName(), "Scale").getI() == 0) // linear - { - yLength = (AMath.maxAbsInArray(dataArray) + 0.1) * 2; - } - else // logarithmic - { - float[] dataArrayCopy = new float[dataArray.length]; - for(int i=0; i<dataArrayCopy.length; ++i) - { - if(dataArray[i] == -99.0f) - dataArrayCopy[i] = 0.0f; - else - dataArrayCopy[i] = dataArray[i]; - } - double minValue = (double) AMath.minAbsInArray(dataArrayCopy); - double maxValue = (double) AMath.maxAbsInArray(dataArrayCopy); - double magnitude; - - // all data is either invalid or 0 - if(maxValue == 0.0 && minValue == 0.0) - { - magnitude = 1; - residual.setLogMagnitudeMin(-1.0); - } - else if (minValue == 0.0) - { - double minNonZeroValue = (double) AMath.minNonZeroAbsInArray(dataArrayCopy); - magnitude = Math.floor(Math.log10(maxValue)) - - Math.floor(Math.log10(minNonZeroValue))+ 1.0; - residual.setLogMagnitudeMin(Math.floor(Math.log10(minNonZeroValue))); - } - else - { - magnitude = Math.floor(Math.log10(maxValue)) - - Math.floor(Math.log10(minValue))+ 1.0; - residual.setLogMagnitudeMin(Math.floor(Math.log10(minValue))); - } - yLength = magnitude * 2; - } - Point2D.Double[] corners = new Point2D.Double[3]; - - corners[0] = new Point2D.Double(0., yLength/2); - corners[1] = new Point2D.Double(xLength, yLength/2); - corners[2] = new Point2D.Double(xLength, -yLength/2); - return corners; - } - - public ACoord getUserPoint(ADHelix dH, double s) - { - return ACoord.NO_DATA; - } - - public void paint(AWindow window, Graphics g) - { - AGraphics ag = AGraphics.makeAGraphics(g); - - fillBackground(window, ag); - if(residual != null) - residual.draw(window, ag, this); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionVP.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionVP.java deleted file mode 100755 index 210d848d44727230b148dfeda300d0834a01a2fc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionVP.java +++ /dev/null @@ -1,169 +0,0 @@ -package atlantis.projection; - -import atlantis.graphics.ACoord; -import atlantis.graphics.colormap.AColorMap; -import atlantis.output.ALogInterface; -import atlantis.output.AOutput; -import atlantis.parameters.AParameter; -import atlantis.parameters.APar; -import atlantis.utils.AMath; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.geom.Point2D; - -import atlantis.canvas.AWindow; -import atlantis.data.ADHelix; - -public class AProjectionVP extends AProjectionPhi { - - // this should be moved ugly - // sign is which arm of the v is being drawn at this point in time - public static int sign; - - private static double qcp=0.00035936; - - // Display modes as defined in the configuration file. - public static final int MODE_STANDARD = 0; - public static final int MODE_SPACEPOINT = 1; - public static final int MODE_TRT_DRIFT_CIRCLE = 2; - public static final int MODE_ECAL_LAYER_0 = 3; - public static final int MODE_ECAL_LAYER_1 = 4; - public static final int MODE_ECAL_LAYER_2 = 5; - public static final int MODE_ECAL_LAYER_3 = 6; - public static final int MODE_HCAL_LAYER_0 = 7; - public static final int MODE_HCAL_LAYER_1 = 8; - public static final int MODE_HCAL_LAYER_2 = 9; - public static final int MODE_HCAL_LAYER_3 = 10; - - public static final double MAX_ETA = 5.; - - private static boolean first=true; - // draw V apex at this rho or Z - private static double[] rhoMode=new double[] - { 55., 55., 108., 138., 154., 173., 193., 244., 306., 368., 368.}; - private static double[] zMode=new double[] - {277., 277., 338., 360., 374., 394., 414., 441., 482., 561., 561.}; - // zoom in another projection to this rho and Z - private static double[] rhoZoomMode=new double[] - { 56., 56., 110., 200., 200., 200., 200., 400., 400., 400., 400.}; - private static double[] zZoomMode=new double[] - {280., 280., 340., 440., 440., 440., 440., 374., 374., 374., 374.}; - - private static AParameter modePar; - private static AParameter rMaxPar; - private static AParameter zMaxPar; - private static AParameter gradientPar; - private static AParameter zVtxPar; - - public AProjectionVP() {} - - public String getName() { - return "VP"; - } - - public String getXLabel() { - return AMath.ETA; - } - - public String getXUnits() { - return ""; - } - - public void setAspectRatio1(AWindow window) - { - AOutput.append("\nNot implemented for this projection\n", ALogInterface.WARNING); - } - - public Point2D.Double[] calculateNoZoomCorners(Dimension wSize) { - Point2D.Double[] corners=new Point2D.Double[3]; - - corners[0]=new Point2D.Double(-5.0, 360); - corners[1]=new Point2D.Double(5.0, 360); - corners[2]=new Point2D.Double(5.0, 0); - return corners; - } - - protected Color getBackgroundFillColor(Color[] colorMap) { - int mode=parameterStore.get("VP", "Mode").getI(); - - switch(mode) { - case MODE_SPACEPOINT: - return colorMap[parameterStore.get("Det", "SIL"+"Fill").getI()]; - case MODE_TRT_DRIFT_CIRCLE: - return colorMap[parameterStore.get("Det", "TRT"+"Fill").getI()]; - case MODE_ECAL_LAYER_0: - case MODE_ECAL_LAYER_1: - case MODE_ECAL_LAYER_2: - case MODE_ECAL_LAYER_3: - return colorMap[parameterStore.get("Det", "ECAL"+"Fill").getI()]; - case MODE_HCAL_LAYER_0: - case MODE_HCAL_LAYER_1: - case MODE_HCAL_LAYER_2: - case MODE_HCAL_LAYER_3: - return colorMap[parameterStore.get("Det", "HCAL"+"Fill").getI()]; - default: - return colorMap[parameterStore.get("Color", "Bkg"+"Fill").getI()]; - } - } - - public ACoord getUserPoint(ADHelix dH, double s) { - return dH.getVPPoint(s, this.sign); - } - - public static double getDeltaEta(double rho, double z) { - if(first) { - modePar=parameterStore.get("VP", "Mode"); - rMaxPar=parameterStore.get("VP", "RMax"); - zMaxPar=parameterStore.get("VP", "ZMax"); - gradientPar=parameterStore.get("VP", "Gradient"); - zVtxPar=parameterStore.get("VP", "ZVtx"); - first=false; - } - double fact=qcp*gradientPar.getD(); - int mode=modePar.getI(); - double zLayer=zMode[mode]; - - if(zMaxPar.getStatus()) - zLayer=Math.min(zLayer, zMaxPar.getD()); - double rhoLayer=rhoMode[mode]; - - if(rMaxPar.getStatus()) - rhoLayer=Math.min(rhoLayer, rMaxPar.getD()); - double zVtx=zVtxPar.getD(); - double zsign=1.; - - if(z<0.) zsign=-1.; - if(Math.abs((z-zVtx)/rho)<(zLayer-zVtx)/rhoLayer) - return fact*(rhoLayer-rho); - else - return fact*rho*(zsign*zLayer-z)/(z-zVtx); - } - - public static double getRhoVPlot() { - double rhoLayer=rhoMode[parameterStore.get("VP", "Mode").getI()]; - AParameter rMaxPar=parameterStore.get("VP", "RMax"); - - if(rMaxPar.getStatus()) - rhoLayer=Math.min(rhoLayer, rMaxPar.getD()); - return rhoLayer; - } - - public static double getZVPlot() { - double zLayer=zMode[parameterStore.get("VP", "Mode").getI()]; - AParameter zMaxPar=parameterStore.get("VP", "ZMax"); - - if(zMaxPar.getStatus()) - zLayer=Math.min(zLayer, zMaxPar.getD()); - return zLayer; - } - - public static double getRhoZoomVPlot() { - return rhoZoomMode[parameterStore.get("VP", "Mode").getI()]; - } - - public static double getZZoomVPlot() { - return zZoomMode[parameterStore.get("VP", "Mode").getI()]; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionXZ.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionXZ.java deleted file mode 100755 index 24f2d9b17cc2debb9fa04f8d2d5c6ddbcc08ef06..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionXZ.java +++ /dev/null @@ -1,81 +0,0 @@ -package atlantis.projection; - -import atlantis.data.ADHelix; -import atlantis.graphics.ACoord; -import atlantis.parameters.APar; -import atlantis.utils.AMath; -import atlantis.event.*; -import java.awt.*; -import java.awt.geom.*; - -public class AProjectionXZ extends AProjection2D { - - public AProjectionXZ() { - addPopupItem(ASPECT_RATIO_1); - } - - public String getName() { - return "XZ"; - } - - public String getXLabel() { - return "Z"; - } - - public String getYLabel() { - return "X"+AMath.PRIME; - } - - public String getXUnits() { - return "(cm)"; - } - - public String getYUnits() { - return "(cm)"; - } - - public Point2D.Double getCenter() { - return new Point2D.Double(0, 0); - } - - public Point2D.Double[] calculateNoZoomCorners(Dimension wSize) { - double radius=parameterStore.get("Projection", "TrackingRadius").getD(); - double length=parameterStore.get("Projection", "TrackingLength").getD(); - return aspectRatioLayout(length, radius, wSize); - } - - public static double getPhi() { - return parameterStore.get("XZ", "Phi").getD(); - } - - public static double[][] getRotationMatrix() { - double phi=Math.toRadians(getPhi()); - double cos=Math.cos(phi); - double sin=Math.sin(phi); - double[][] r=new double[3][3]; - - r[0][0]=cos; - r[1][1]=cos; - r[2][2]=1.; - r[0][1]=sin; - r[1][0]=-sin; - return r; - } - - public static int[] getAxisMapping() { - return new int[] {2, 0, 1}; - } - - public ACoord getUserPoint(ADHelix dH, double s) { - return nonLinearTransform(dH.getXZPoint(s)); - } - - public ACoord nonLinearTransform(ACoord user) { - return nonLinearTransform2D(user, getName()); - } - - public ACoord inverseNonLinearTransform(ACoord user) { - return inverseNonLinearTransform2D(user, getName()); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionYX.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionYX.java deleted file mode 100755 index ef2a7d28db6e7d1cc70648324d25335b63c7281b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionYX.java +++ /dev/null @@ -1,307 +0,0 @@ -package atlantis.projection; - -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.geom.Point2D; - -import javax.swing.ImageIcon; - -import atlantis.canvas.AWindow; -import atlantis.data.ADHelix; -import atlantis.globals.AGlobals; -import atlantis.graphics.ACoord; -import atlantis.graphics.ADrawParameters; -import atlantis.graphics.AGraphics; -import atlantis.graphics.colormap.AColorMap; -import atlantis.interactions.AZMRInteraction; -import atlantis.parameters.AParameter; -import atlantis.utils.ALogger; -import atlantis.utils.AUtilities; - -public class AProjectionYX extends AProjection2D -{ - private static ALogger logger = ALogger.getLogger(AProjectionYX.class); - - // Different display modes, as defined in the configuration file. - public static final int MODE_STANDARD = 0; - public static final int MODE_TGC_INNER = 1; - public static final int MODE_TGC_MIDDLE_1 = 2; - public static final int MODE_TGC_MIDDLE_2 = 3; - public static final int MODE_TGC_MIDDLE_3 = 4; - public static final int MODE_MDT_INNER = 5; - public static final int MODE_MDT_EXTENSION = 6; - public static final int MODE_MDT_MIDDLE = 7; - public static final int MODE_MDT_OUTER = 8; - public static final int MODE_FCAL_EM = 9; - public static final int MODE_FCAL_HAD_1 = 10; - public static final int MODE_FCAL_HAD_2 = 11; - public static final int MODE_LAR_ENDCAP_PRESAMPLER = 12; - public static final int MODE_LAR_ENDCAP_1 = 13; - public static final int MODE_LAR_ENDCAP_2 = 14; - public static final int MODE_LAR_ENDCAP_3 = 15; - public static final int MODE_HEC_1 = 16; - public static final int MODE_HEC_2 = 17; - public static final int MODE_HEC_3 = 18; - public static final int MODE_HEC_4 = 19; - public static final int MODE_LAR_ENDCAP_SUMMED = 20; - public static final int MODE_HEC_SUMMED = 21; - public static final int MODE_MBTS = 22; - - public AProjectionYX() - { - addPopupItem(ASPECT_RATIO_1); - } - - public String getName() - { - return "YX"; - } - - public String getXLabel() - { - return "X"; - } - - public String getYLabel() - { - return "Y"; - } - - public String getXUnits() - { - return "(cm)"; - } - - public String getYUnits() - { - return "(cm)"; - } - - public Point2D.Double getCenter() - { - return new Point2D.Double(0, 0); - } - - public Point2D.Double[] calculateNoZoomCorners(Dimension wSize) - { - // should not be here - parameterStore.get(getName(), "Phi").setD(0.); - double radius = parameterStore.get("Projection", "Radius").getD(); - return aspectRatioLayout(radius, radius, wSize); - } - - public static double[][] getRotationMatrix() - { - double[][] r = new double[3][3]; - - r[0][0] = 1.; - r[1][1] = 1.; - r[2][2] = 1.; - return r; - } - - public static int[] getAxisMapping() - { - return new int[] { 0, 1, 2 }; - } - - public ACoord getUserPoint(ADHelix dH, double s) - { - return nonLinearTransform(dH.getYXPoint(s)); - } - - public ACoord nonLinearTransform(ACoord user) - { - AParameter fishEyePar = parameterStore.get(getName(), "FishEye"); - - if (fishEyePar.getStatus()) - { - double[] x, y; - double r, fact; - double fishEye = 0.001 * fishEyePar.getD(); - double rTo = parameterStore.get(getName(), "rTo").getD(); - - for (int j = 0; j < user.hv[0].length; ++j) - { - x = user.hv[0][j]; - y = user.hv[1][j]; - for (int i = 0; i < x.length; ++i) - { - r = Math.sqrt(x[i] * x[i] + y[i] * y[i]); - fact = (1 + fishEye * rTo) / (1 + fishEye * r); - x[i] *= fact; - y[i] *= fact; - } - } - } - AParameter clockPar = parameterStore.get(getName(), "Clock"); - - if (clockPar.getStatus()) - { - double clock = Math.PI / clockPar.getD(); - double phiClock = Math.toRadians(parameterStore.get(getName(), "Phi").getD()); - - for (int j = 0; j < user.hv[0].length; ++j) - { - double[] x = user.hv[0][j]; - double[] y = user.hv[1][j]; - - for (int i = 0; i < x.length; ++i) - { - double phi = Math.atan2(y[i], x[i]); - - if (phi < 0.) - phi += 2 * Math.PI; - double rho = Math.sqrt(x[i] * x[i] + y[i] * y[i]); - double dPhi = phi - phiClock; - - if (dPhi > Math.PI) - dPhi -= 2 * Math.PI; - else if (dPhi <= -Math.PI) - dPhi += 2 * Math.PI; - double fact = (clock + Math.PI) / (clock + Math.abs(dPhi)); - - phi = phiClock + fact * dPhi; - x[i] = rho * Math.cos(phi); - y[i] = rho * Math.sin(phi); - } - } - } - - return user; - } - - public ACoord inverseNonLinearTransform(ACoord user) - { - AParameter fishEyePar = parameterStore.get(getName(), "FishEye"); - - if (fishEyePar.getStatus()) - { - double[] x, y; - double r, fact; - double fishEye = 0.001 * fishEyePar.getD(); - double rTo = parameterStore.get(getName(), "rTo").getD(); - - for (int j = 0; j < user.hv[0].length; ++j) - { - x = user.hv[0][j]; - y = user.hv[1][j]; - for (int i = 0; i < x.length; ++i) - { - r = Math.sqrt(x[i] * x[i] + y[i] * y[i]); - fact = 1 / (1 + fishEye * (rTo - r)); - x[i] *= fact; - y[i] *= fact; - } - } - } - AParameter clockPar = parameterStore.get(getName(), "Clock"); - - if (clockPar.getStatus()) - { - double clock = Math.PI / clockPar.getD(); - double phiClock = Math.toRadians(parameterStore.get(getName(), "Phi").getD()); - - for (int j = 0; j < user.hv[0].length; ++j) - { - double[] x = user.hv[0][j]; - double[] y = user.hv[1][j]; - - for (int i = 0; i < x.length; ++i) - { - double phi = Math.atan2(y[i], x[i]); - - if (phi < 0.) - phi += 2 * Math.PI; - double dPhi = phi - phiClock; - - if (dPhi > Math.PI) - dPhi -= 2 * Math.PI; - else if (dPhi <= -Math.PI) - dPhi += 2 * Math.PI; - - double dPhiPrime = (clock * dPhi) / (clock + Math.PI - Math.abs(dPhi)); - - phi = phiClock + dPhiPrime; - - double rho = Math.sqrt(x[i] * x[i] + y[i] * y[i]); - - x[i] = rho * Math.cos(phi); - y[i] = rho * Math.sin(phi); - } - } - } - return user; - } - - public void paint(AWindow window, Graphics g) - { - super.paint(window, g); - - // draw RZ cutting plane - if (parameterStore.get("YX", "RZCuttingPlane").getStatus()) - { - AGraphics ag = AGraphics.makeAGraphics(g); - final ADrawParameters drawParameters = - new ADrawParameters(true, AColorMap.WH, 4, 1, 0, AGraphics.SYMBOL_FILLED_BOX); - ag.updateDrawParameters(drawParameters); - final double RHO_MAX = 3000.0; - - double phi = Math.toRadians(parameterStore.get("RZ", "Phi").getD()) - Math.PI / 2; - double cosPhi = Math.cos(phi); - double sinPhi = Math.sin(phi); - String iconPath = AGlobals.instance().getHomeDirectory() + "img" + System.getProperty("file.separator"); - - // draw the cutting plane - Point2D.Double p1 = window.calculateDisplay(nonLinearTransform(RHO_MAX * cosPhi, RHO_MAX * sinPhi)); - Point2D.Double p2 = window.calculateDisplay(nonLinearTransform(-RHO_MAX * cosPhi, -RHO_MAX * sinPhi)); - - ag.drawLine(p1.x, p1.y, p2.x, p2.y); - - // draw the arrows - Point2D.Double p3 = window.calculateDisplay(nonLinearTransform(1500 * Math.cos(phi+.07), 1500 * Math.sin(phi+.07))); - Point2D.Double p4 = window.calculateDisplay(nonLinearTransform(1500 * Math.cos(phi+3.21), 1500 * Math.sin(phi+3.21))); - - ImageIcon upArrow = AUtilities.getFileAsImageIcon(iconPath+"uparrow.png"); - ImageIcon downArrow = AUtilities.getFileAsImageIcon(iconPath+"downarrow.png"); - - Graphics2D g2d = (Graphics2D) g; - - g2d.drawImage(upArrow.getImage(),(int) p3.x,(int) p3.y,null); - g2d.drawImage(downArrow.getImage(),(int) p4.x,(int) p4.y,null); - - } - } - - /** This function ensures that when the aspect ratio of the display changes - * the aspect ratio of the contents of a YX projection remain at the same - * aspect ratio. - * - * It uses the (thankfully) static methods of AZMRInteraction to do the - * actual zooming, which can involve some non-trivial mathematics... - * -- Adam Davison - */ - @Override - public void aspectRatioChange(AWindow w, double oldaspect, double newaspect) { - logger.debug("ProjectionYX informed of aspect ratio change from " + oldaspect + " to " + newaspect); - - Point2D.Double[] corners = w.getUserCorners(); - - // Get center - Point2D.Double center = new Point2D.Double( - 0.5*(corners[0].x+corners[2].x), - 0.5*(corners[0].y+corners[2].y)); - - // If > 1, the new view is taller if < 1 it's wider - double fracchange = newaspect/oldaspect; - - if (fracchange > 1) { - // Need to vzoom "away" to restore aspect ratio - AZMRInteraction.performVerticalZoom(center, fracchange, w); - } else { - // Need to hzoom - AZMRInteraction.performHorizontalZoom(center, 1.0/fracchange, w); - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionYZ.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionYZ.java deleted file mode 100755 index 490afb72dfd8deab89a3338803696e4f1cbe267a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionYZ.java +++ /dev/null @@ -1,72 +0,0 @@ -package atlantis.projection; - - -import atlantis.graphics.ACoord; -import atlantis.utils.AMath; -import java.awt.*; -import java.awt.geom.*; -import atlantis.data.ADHelix; -import atlantis.parameters.*; - - -public class AProjectionYZ extends AProjection2D { - - public AProjectionYZ() { - addPopupItem(ASPECT_RATIO_1); - } - - public String getName() { - return "YZ"; - } - - public String getXLabel() { - return "Z"; - } - - public String getYLabel() { - return "Y"+AMath.PRIME; - } - - public String getXUnits() { - return "(cm)"; - } - - public String getYUnits() { - return "(cm)"; - } - - public Point2D.Double getCenter() { - return new Point2D.Double(0, 0); - } - - public Point2D.Double[] calculateNoZoomCorners(Dimension wSize) { - double radius=parameterStore.get("Projection", "TrackingRadius").getD(); - double length=parameterStore.get("Projection", "TrackingLength").getD(); - return aspectRatioLayout(length, radius, wSize); - } - - public static double getPhi() { - return AProjectionXZ.getPhi(); - } - - public static double[][] getRotationMatrix() { - return AProjectionXZ.getRotationMatrix(); - } - - public static int[] getAxisMapping() { - return new int[] {2, 1, 0}; - } - - public ACoord getUserPoint(ADHelix dH, double s) { - return nonLinearTransform(dH.getYZPoint(s)); - } - - public ACoord nonLinearTransform(ACoord user) { - return nonLinearTransform2D(user, getName()); - } - - public ACoord inverseNonLinearTransform(ACoord user) { - return inverseNonLinearTransform2D(user, getName()); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/AProjectionsManager.java b/graphics/AtlantisJava/src/atlantis/projection/AProjectionsManager.java deleted file mode 100755 index e9886ac1fefbbb9421de00bf744949edbe926ac3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/AProjectionsManager.java +++ /dev/null @@ -1,110 +0,0 @@ -package atlantis.projection; - -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Set; -import java.util.Vector; - -import atlantis.output.AExceptionHandler; -import atlantis.parameters.APar; -import atlantis.parameters.AParametersGroup; - -/** - * This manager keeps references to all projections. - * - * The code keeping track of the list and states of interactions associated with each - * projection in each window, and creating the corresponding pop-up menus, has been - * moved to atlantis.gui.AInteractionToolBar and atlantis.interactions.AInteractionsByProjection. - */ -public class AProjectionsManager { - - // the set of projections (name : AProjection) - private static Hashtable<String,AProjection> projections = new Hashtable<String, AProjection>(); - private static Set<String> projectionsAvailableInDemoMode = new HashSet<String>(); - private static Set<String> defaultProjectionsInDemoMode = new HashSet<String>(); - - /** - * Creates projections using information from APar. - */ - public static void initialise() { - Vector<String> projVector=APar.instance().getUIGroupNames(AParametersGroup.PROJECTION); - - for (String projName : projVector) { - createProjection(projName); - } - } - - /** - * Used to request the projection with the given name - * @param projectionName The name of the projection - * @return The AProjection corespoinding to the projection name. - */ - public static AProjection getProjection(String projectionName) { - return projections.get(projectionName); - } - - /** - * Checks whether the given name is a valid projection name. - * @param name The name to be checked - * @return True/False - */ - public static boolean isValidProjection(String name) { - return projections.containsKey(name); - } - - /** - * Returns an array containing the names of all known projections - * @return The name array - */ - public static String[] getKnownProjectionNames() { - String[] names=new String[projections.size()]; - - Enumeration<String> myenum=projections.keys(); - - for(int i=0; i<projections.size(); i++) - names[i]=myenum.nextElement(); - - return names; - } - - /** - * Check whether the projection should be used in the demo dialog - * @return false if the projection should not be used or does not exist - */ - public static boolean useProjectionInDemoMode(String name){ - return projectionsAvailableInDemoMode.contains(name); - } - - /** - * @return true if the projection should be selected by default in the demo dialog - */ - public static boolean defaultProjectionInDemoMode(String name){ - return defaultProjectionsInDemoMode.contains(name); - } - - /** - * Creates an instance of a given projection and pushes it into the - * <code>projections</code> Hashtable. The name shold be for example: YX if you - * want to create a instance of AProjectionYX.java class. - * @param name The name of the projection. - */ - private static void createProjection(String name) { - try { - - AProjection p=(AProjection)Class.forName("atlantis.projection.AProjection"+name).newInstance(); - - projections.put(name, p); - } catch(Exception e) { - AExceptionHandler.processException("Cannot create AProjection"+name, e); - } - } - - public static void makeProjectionAvailableInDemoMode(String projection) { - projectionsAvailableInDemoMode.add(projection); - } - - public static void makeProjectionDefaultInDemoMode(String name) { - defaultProjectionsInDemoMode.add(name); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/projection/package.html b/graphics/AtlantisJava/src/atlantis/projection/package.html deleted file mode 100644 index 471774c48caadc517d522ec098161f1887cc588e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/projection/package.html +++ /dev/null @@ -1,9 +0,0 @@ -<html> -<head></head> -<body> -<p>Implementation of projections (XY, Rho Z, V plot, etc). Class - AProjectionManager changes the current projection and informs the - AEvent class instance of how to draw itself, e.g. in the XY - projection.</p> -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/utils/A3Vector.java b/graphics/AtlantisJava/src/atlantis/utils/A3Vector.java deleted file mode 100755 index 649a18dd317fff92dba69393622c0f315dd47b35..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/A3Vector.java +++ /dev/null @@ -1,98 +0,0 @@ -package atlantis.utils; - - -/** - * Provides basic 3D vector operations. - */ - -public class A3Vector { - - public double x, y, z; - - /** - * Construct zero 3-vector. - */ - public A3Vector() {} - - /** - * Construct 3-vector from Cartesian coordinates. - * @param dx - * @param dy - * @param dz - */ - public A3Vector(double x, double y, double z) { - this.x=x; - this.y=y; - this.z=z; - } - - /** - * Create 3-vector from eta, phi and magnitude. - * @param eta pseudorapidity along z direction - * @param phi azimuthal angle [radians] - * @param r magnitude of vector - * @return new A3Vector - */ - public static A3Vector fromEtaPhiR(double eta, double phi, double r) { - double theta = 2.0 * Math.atan(Math.exp(-eta)); - return new A3Vector(r * Math.sin(theta) * Math.cos(phi), - r * Math.sin(theta) * Math.sin(phi), - r * Math.cos(theta)); - } - - /** - * Create 3-vector from cylindrical coordinates rho, phi, z. - * @param rho component perpendicular to z axis - * @param phi azimuthal angle [radians] - * @param z - * @return - */ - public static A3Vector fromRhoPhiZ(double rho, double phi, double z) { - double x=rho*Math.cos(phi); - double y=rho*Math.sin(phi); - return new A3Vector(x,y,z); - } - - public A3Vector getNormalized() { - double r=Math.sqrt(x*x+y*y+z*z); - return new A3Vector(x/r, y/r, z/r); - } - - public A3Vector normalize() { - double r=magnitude(); - x/=r; - y/=r; - z/=r; - return this; - } - - public double magnitude() { - return Math.sqrt(x*x+y*y+z*z); - } - - public A3Vector scale(double a) { - x*=a; - y*=a; - z*=a; - return this; - } - - public A3Vector add(A3Vector v) { - x+=v.x; - y+=v.y; - z+=v.z; - return this; - } - - public A3Vector subtract(A3Vector v) { - x-=v.x; - y-=v.y; - z-=v.z; - return this; - } - - public String toString() { - return "A3Vector[x="+x+", y="+y+", z="+z+"]"; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/A4Vector.java b/graphics/AtlantisJava/src/atlantis/utils/A4Vector.java deleted file mode 100755 index 5032250f170cb8c4515767a1ecf1e938d77fe287..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/A4Vector.java +++ /dev/null @@ -1,127 +0,0 @@ -package atlantis.utils; - -/** - * Provides basic 4D vector operations. - */ -public class A4Vector -{ - public double px, py, pz, e; - - public A4Vector() - {} - - public A4Vector(double dx, double dy, double dz, double m) - { - set(dx, dy, dz, m); - } - - public A4Vector(A3Vector v, double m) - { - set(v.x, v.y, v.z, m); - } - - public void set(double dx, double dy, double dz, double m) - { - px = dx; - py = dy; - pz = dz; - e = Math.sqrt(px * px + py * py + pz * pz + m * m); - } - - public void setPtEtaPhiM(double pT, double eta, double phi, double mass) - { - double ptAbs = Math.abs(pT); - px = ptAbs*Math.cos(phi); - py = ptAbs*Math.sin(phi); - pz = ptAbs*Math.sinh(eta); - e = Math.sqrt(px * px + py * py + pz * pz + mass * mass); - } - - public double getP() - { - return Math.sqrt(px * px + py * py + pz * pz); - } - - public double getPt() - { - return Math.sqrt(px * px + py * py); - } - - public double getE() - { - return e; - } - - /** - * getEt() returns the transverse energy. - * The formula used to calculate it is: - * Et^2 = E^2 * Pt^2 / P^2. - */ - public double getEt() - { - double pt2 = px * px + py * py; - double p2 = pt2 + pz * pz; - return Math.sqrt(e * e * pt2/p2); - } - - public double getMass() - { - return Math.sqrt(e * e - px * px - py * py - pz * pz); - } - - /** - * getMt() returns the transverse mass. - * The formula used to calculate it is: - * Mt^2 = Et^2 - Pt^2. - * - * This is from the Particle Data Group (http://pdg.lbl.gov/) - * - * Note this is different to another definition in the PDG: - * Mt^2 = E^2 - Pz^2 = m^2 + Pt^2 - * - * [J. Beringer et al. (Particle Data Group), Phys. Rev. D86, 010001 (2012). - * (Kinematics, 43.6.1 and 43.5.2)] - */ - public double getMt() - { - double pt2 = px * px + py * py; - double Et = getEt(); - return Math.sqrt(Et * Et - pt2); - } - - public double getPhi() - { - return px == 0.0 && py == 0.0 ? 0.0 : Math.atan2(py,px); - } - - public double getEta() - { - double ptot = getP(); - double cosTheta = ptot == 0.0 ? 1.0 : pz/ptot; - if (cosTheta*cosTheta < 1) return -0.5* Math.log( (1.0-cosTheta)/(1.0+cosTheta) ); - if (pz > 0) return 10e10; - else return -10e10; - } - - public void add(double dx, double dy, double dz, double m) - { - px += dx; - py += dy; - pz += dz; - e += Math.sqrt(dx * dx + dy * dy + dz * dz + m * m); - } - - public void add(A4Vector v) - { - px += v.px; - py += v.py; - pz += v.pz; - e += v.e; - } - - public String toString() - { - return "A4Vector[px=" + px + ", py=" + py + ", pz=" + pz + ", E=" + e + ", m=" + getMass() + "]"; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/AAtlantisException.java b/graphics/AtlantisJava/src/atlantis/utils/AAtlantisException.java deleted file mode 100755 index d8a4edc6d38f28ea393e7115e3733741578912c0..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/AAtlantisException.java +++ /dev/null @@ -1,41 +0,0 @@ -package atlantis.utils; - -/** - * - * @author Zdenek Maxa - */ -public class AAtlantisException extends Exception -{ - private boolean isFatal = true; - - // private static ALogger logger = ALogger.getLogger(AAtlantisException.class); - - - public AAtlantisException(String msg) - { - super(msg); - // logger.debug(msg, this); - this.isFatal = true; - - } // AAtlantisException() ----------------------------------------------- - - - - public AAtlantisException(String msg, boolean isFatal) - { - super(msg); - // logger.debug(msg, this); - this.isFatal = isFatal; - - } // AAtlantisException() ----------------------------------------------- - - - - public boolean isFatal() - { - return this.isFatal; - - } // isFatal() ---------------------------------------------------------- - - -} // class AAtlantisException =============================================== diff --git a/graphics/AtlantisJava/src/atlantis/utils/AClipPolygon.java b/graphics/AtlantisJava/src/atlantis/utils/AClipPolygon.java deleted file mode 100755 index ad73aac1bfd1427f173a85a3b9b3b12c9328567e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/AClipPolygon.java +++ /dev/null @@ -1,98 +0,0 @@ -package atlantis.utils; - -/** - * This class is used when clipping polygons. - */ -public class AClipPolygon extends APolygon { - - public AClipPolygon(double[] x, double[] y) { - super(x, y); - calc_hesse(); - } - - private double[][] normalized; - private double[] distances; - - public double[] get_normalized(int index) { - if(index>=0&&index<normalized.length&&normalized[index].length==3) - return normalized[index]; - else - return null; - } - - public double get_distance(int index) { - if(index>=0&&index<distances.length) - return distances[index]; - else - return Double.NaN; - } - - public void calc_hesse() { - int degree=nodes.size(); - - // Check if fields are already allocated - if(distances==null||distances.length!=degree) - distances=new double[nodes.size()]; // Generate array for distances - - if(normalized==null||normalized.length!=degree) - normalized=new double[nodes.size()][]; // array for normal vectors - - // Loop over all components and determine the normal vectors - for(int i=0; i<degree; i++) { - APoint r, next=null, current=null; - - if(nodes.elementAt(i) instanceof APoint) - current=(APoint)nodes.elementAt(i); - if(nodes.elementAt((i+1)%degree) instanceof APoint) - next=(APoint)nodes.elementAt((i+1)%degree); - - // If both APoints exist, calculate the normalized vector - if(next!=null&¤t!=null) { - - normalized[i]=new double[3]; - r=next.minus(current); - - // Check values and determine normalized vector. - if(r.x==0) - if(r.y>0) { - normalized[i][0]=1.0; - normalized[i][1]=0.0; - normalized[i][2]=1.0; - } else if(r.y<0) { // on the negative y-Axis - normalized[i][0]=-1.0; - normalized[i][1]=0.0; - normalized[i][2]=1.0; - } - - if(r.y==0) - if(r.x>0) { // on the positive x-Axis - normalized[i][0]=0.0; - normalized[i][1]=-1.0; - normalized[i][2]=1.0; - } else if(r.x<0) { // on the negative x-Axis - normalized[i][0]=0.0; - normalized[i][1]=1.0; - normalized[i][2]=1.0; - } - - if(r.y!=0) - if(r.x>0) { // right of the y-Axis - double x_val=r.y/r.x; - double length=Math.sqrt(x_val*x_val+1); - - normalized[i][0]=x_val/length; - normalized[i][1]=-1.0/length; - normalized[i][2]=1.0; - } else if(r.x<0) { // left of the y-Axis - double x_val=-r.y/r.x; - double length=Math.sqrt(x_val*x_val+1); - - normalized[i][0]=x_val/length; - normalized[i][1]=1.0/length; - normalized[i][2]=1.0; - } - distances[i]=-current.dot_product(normalized[i]); - } - } - } -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/ACommandHistory.java b/graphics/AtlantisJava/src/atlantis/utils/ACommandHistory.java deleted file mode 100755 index b226d78b0fac6ce0e14ef4a65b418eeea97a68dc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/ACommandHistory.java +++ /dev/null @@ -1,213 +0,0 @@ -package atlantis.utils; - -import java.util.Vector; -import javax.swing.text.JTextComponent; - - -/** - * Implementation of simple command history (up and down - * arrows) and tab completion based upon the already typed commands. - * No cross-sessions commands history so far. - * - * @author Zdenek Maxa - */ -public class ACommandHistory extends Vector -{ - // the component upon which the history operates - private JTextComponent comp = null; - // item on the size() position of the history (content of the text field) - private String tempItem = ""; - private int pointer = 0; - private int tabPointer = 0; // help pointer when doing tab completion - private String tabItem = null; - - - // ---------------------------------------------------------------------- - public ACommandHistory(JTextComponent compoment) - { - super(); - this.comp = compoment; - this.pointer = 0; - this.tabPointer = 0; - this.tempItem = ""; - this.nullTabItem(); - - } // ACommandHistory() -------------------------------------------------- - - - /** - * add the item into the history container, if it's already there it's - * removed first and then added (placed to the end) - * @param item String - */ - public void add(String item) - { - if(super.contains(item)) - { - super.remove(item); - } - super.add(item); - pointer = super.size(); - nullTabItem(); - - } // add() -------------------------------------------------------------- - - - /** - * erase the content of the tabItem string upon which the tab-completion - * searching is performed - */ - public void nullTabItem() - { - this.tabItem = null; - - } // nullTabItem() ------------------------------------------------------ - - - private String getItem() - { - if(pointer < super.size()) - { - return super.get(pointer).toString(); - } - else - { - return tempItem; - } - - } // getItem() ---------------------------------------------------------- - - - - private void desc() - { - if(pointer > 0) - { - pointer--; - } - - } // desc() ------------------------------------------------------------- - - - - private void inc() - { - if(pointer < super.size()) - { - pointer++; - } - - } // inc() -------------------------------------------------------------- - - - - /** - * compares the actual content of the text field with the history item - * on the matching position. if they differ (user changed the item in the - * text field) the item in the history (or the tempItem attribute - the - * last item, not yet added to the container) gets updated - */ - private void compareAndUpdate() - { - String currItem = comp.getText(); - if(pointer < super.size()) - { - String histItem = super.get(pointer).toString(); - if(! histItem.equals(currItem)) - { - super.remove(pointer); - super.add(pointer, currItem); - } - } - else - { - if(! tempItem.equals(currItem)) - { - tempItem = currItem; - } - } - - } // compareAndUpdate() ------------------------------------------------- - - - - /** - * up-arrow handler - it will decrease the pointer and return former - * command - */ - public void upArrow() - { - if(! super.isEmpty()) - { - compareAndUpdate(); - desc(); - comp.setText(getItem()); - } - nullTabItem(); - - } // upArrow() ---------------------------------------------------------- - - - - /** - * down-arrow handler - it will increase the pointer toward the more - * recent commands - */ - public void downArrow() - { - if(! super.isEmpty()) - { - compareAndUpdate(); - inc(); - comp.setText(getItem()); - } - nullTabItem(); - - } // downArrow() -------------------------------------------------------- - - - - /** - * tabulator handler, tab-completion - */ - public void tabulator() - { - // check tabItem - first or subsequent tab-key hit? - if(tabItem == null) - { - tabItem = comp.getText().trim(); - if("".equals(tabItem) || tabItem == null) - { - nullTabItem(); - return; - } - } - - if(! super.isEmpty()) - { - compareAndUpdate(); - - if(tabPointer >= super.size()) - { - tabPointer = 0; // rotate again from the beginning - } - - for( ; tabPointer < super.size(); tabPointer++) - { - String item = super.get(tabPointer).toString(); - if(item.startsWith(tabItem)) - { - pointer = tabPointer; - comp.setText(item); - tabPointer++; // for next iteration (next tab hit) - break; - } - } - - } // if(! super.isEmpty()) [container empty] - - } // tabulator() -------------------------------------------------------- - - - -} // class ACommandHistory ================================================== diff --git a/graphics/AtlantisJava/src/atlantis/utils/AHashMap.java b/graphics/AtlantisJava/src/atlantis/utils/AHashMap.java deleted file mode 100755 index 6e4f5f1c9d4a5b56da5359bd402ce326b9d439d9..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/AHashMap.java +++ /dev/null @@ -1,201 +0,0 @@ -package atlantis.utils; - -import java.util.HashMap; -import atlantis.Atlantis; - -/** - * Based on a standard Hashmap with an modified interface - */ - -public class AHashMap extends HashMap -{ - - private static ALogger logger = ALogger.getLogger(AHashMap.class); - - private void printWarningMessage(String msg) - { - logger.warn("AHashMap: " + msg); - } - - - public AHashMap(int num) - { - super(num); - } - - public AHashMap put(String name, int i) - { - put(name, new Integer(i)); - return this; - } - - public float[] getFloatArray(String name) - { - Object temp = get(name); - if(temp == null) - { - printWarningMessage("getFloatArray(): can't find float array named " + - name); - return null; - } - else - { - return (float[]) temp; - } - } // getFloatArray() ------------------------------------------------------- - - public float[][][] getFloatArray3D(String name) - { - Object temp = get(name); - - if(temp == null) - { - printWarningMessage("getFloatArray3D(): can't find 3D float array named " - + name); - } - return (float[][][]) temp; - } - - public String[] getStringArray(String name) - { - Object temp = get(name); - - if(temp == null) - { - printWarningMessage("getStringArray(): can't find String array named " - + name); - } - return (String[]) temp; - } - - public String[][] getStringArray2D(String name) - { - Object temp = get(name); - - if(temp == null) - { - printWarningMessage("getStringArray2D(): can't find String array named " - + name); - } - return (String[][]) temp; - } - - - public int[] getIntArray(String name) - { - Object temp = get(name); - - if(temp == null && !name.equals("sub")) - { - printWarningMessage("getIntArray(): can't find int array named " + - name); - } - return (int[]) temp; - } - - - public int[][] getIntArray2D(String name) - { - Object temp = get(name); - - if(temp == null) - { - printWarningMessage("getIntArray2D(): can't find 2D int array named " + - name); - } - return (int[][]) temp; - } - - - public int getInt(String name) - { - Object temp = get(name); - - if(temp == null) - { - printWarningMessage("getInt(): can't find int named " + name); - } - return ((Integer) temp).intValue(); - } - - public long getLong(String name) - { - Object temp = get(name); - - if(temp == null) - { - printWarningMessage("getLong(): can't find int named " + name); - return -1; - } - return ((Long) temp).longValue(); - } - - public float getFloat(String name) - { - Object temp = get(name); - - if(temp == null) - { - printWarningMessage("getFloat(): can't find int named " + name); - return -1; - } - return ((Float) temp).floatValue(); - } - - - public float[] getUnknownFloatArray(String name) - { - Object temp = get(name); - - if(temp == null) - return new float[getInt("numData")]; - return (float[]) temp; - } - - public long[] getUnknownLongArray(String name) - { - Object temp = get(name); - - if(temp == null) - return new long[getInt("numData")]; - return (long[]) temp; - } - - - public int[] getUnknownIntArray(String name) - { - Object temp = get(name); - - if(temp == null) - return new int[getInt("numData")]; - return (int[]) temp; - } - - - public float[] getUnsureFloatArray(String name) - { - Object temp = get(name); - - if(temp == null) - return null; - return (float[]) temp; - } - - public int[] getUnsureIntArray(String name) - { - Object temp = get(name); - - if(temp == null) - return null; - return (int[]) temp; - } - - public String[] getUnsureStringArray(String name) - { - Object temp = get(name); - - if(temp == null) - return null; - return (String[]) temp; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/AIdDictionary.java b/graphics/AtlantisJava/src/atlantis/utils/AIdDictionary.java deleted file mode 100644 index 9d04ec7239c5a26139a5a757acafea4a30ae89da..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/AIdDictionary.java +++ /dev/null @@ -1,152 +0,0 @@ -package atlantis.utils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * Class representing an identifier dictionary, used for decoding of compact IDs. - * - * @author Eric Jansen - */ -class AIdDictionary extends AIdField { - - private HashMap<String, Node> subregions = null; - private HashMap<String, Node> labels = null; - private HashMap<String, List<AIdRange>> ranges = new HashMap<String, List<AIdRange>>(); - - /** - * Empty constructor, used to create a placeholder dictionary that - * can be initialized later. - */ - AIdDictionary() {} - - /** - * Construct and initialize dictionary from an <IdDictionary> XML node. - * @param dict dictionary XML node - * @throws AAtlantisException - */ - AIdDictionary(Node dict) throws AAtlantisException { - initialize(dict); - } - - /** - * Initializes a dictionary from an <IdDictionary> XML node. - * @param dict dictionary XML node - * @throws AAtlantisException - */ - final void initialize(Node dict) throws AAtlantisException { - - this.dictionary = this; - - NodeList nodes = dict.getChildNodes(); - - for (int i=0; i<nodes.getLength(); i++) { - Node node = nodes.item(i); - - if (node.getNodeType() == Node.ELEMENT_NODE) { - - if ("field".equals(node.getNodeName())) { - String fieldName = node.getAttributes().getNamedItem("name").getNodeValue(); - if (labels == null) { - labels = new HashMap<String, Node>(); - } - labels.put(fieldName, node); - - } else if ("subregion".equals(node.getNodeName())) { - String subregionName = node.getAttributes().getNamedItem("name").getNodeValue(); - if (subregions == null) { - subregions = new HashMap<String, Node>(); - } - subregions.put(subregionName, node); - - } else if ("region".equals(node.getNodeName())) { - parseRegion(node, null, 0); - - } else if ("alternate_regions".equals(node.getNodeName())) { - NodeList altnodes = node.getChildNodes(); - - for (int j=0; j<altnodes.getLength(); j++) { - Node altnode = altnodes.item(j); - if (altnode.getNodeType() == Node.ELEMENT_NODE - && "region".equals(altnode.getNodeName())) { - parseRegion(altnode, null, 0); - } - } - } - } - } - - // Clean up the HashMaps, they are only needed during initialization. - ranges = null; - labels = null; - subregions = null; - } - - /** - * Returns true if the dictionary contains labels for the named field. - * @param fieldName name of the field - * @return true if labels are present - */ - boolean hasLabels(String fieldName) { - return labels.containsKey(fieldName); - } - - /** - * Returns the <field> node containing the labels for the named field. - * @param fieldName name of the field - * @return <field> XML node - * @throws AAtlantisException - */ - Node getLabels(String fieldName) throws AAtlantisException { - if (labels.containsKey(fieldName)) { - return labels.get(fieldName); - } else { - throw new AAtlantisException("Labels for field '"+fieldName+"' not found"); - } - } - - /** - * Returns the <subregion> node containing the named subregion. - * @param subRegionName name of the subregion - * @return <subregion> XML node - * @throws AAtlantisException - */ - Node getSubRegion(String subRegionName) throws AAtlantisException { - if (subregions.containsKey(subRegionName)) { - return subregions.get(subRegionName); - } else { - throw new AAtlantisException("Subregion '"+subRegionName+"' not found"); - } - } - - /** - * One AIdRange object for every unique field range is kept inside the dictionary. - * It serves to collect all possible values for the named field. Due to the tree - * structure of the identifiers multiple AIdFields with the same name might be - * created, but they will always have the same range. The first AIdField with a - * certain name will be the parent of the range, but it is only used for decoding - * of labelled fields. The field name has to be set before creating the range in the - * dictionary. - * @param field named identifier field - * @return global range corresponding to the named field - */ - AIdRange getRange(String group, int level) throws AAtlantisException { - - List<AIdRange> range; - if (ranges.containsKey(group)) { - range = ranges.get(group); - } else { - range = new ArrayList<AIdRange>(); - ranges.put(group, range); - } - - while (range.size() <= level) { - range.add(new AIdRange()); - } - - return range.get(level); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/AIdField.java b/graphics/AtlantisJava/src/atlantis/utils/AIdField.java deleted file mode 100644 index a1f9c7d8d8d7a2c268b1fdb695542b89500e4112..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/AIdField.java +++ /dev/null @@ -1,537 +0,0 @@ -package atlantis.utils; - -import java.util.HashMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * Class representing a single field in an identifier. Each field has a parent, - * a range of allowed values and child fields that may depend on the value of the - * current field. The possible values of a field will determine the number of bits - * needed to store it in the compact identifier. The AIdField tree is capable of - * encoding and decoding these compact identifiers. - * - * @author Eric Jsnsen - */ -class AIdField { - - /** - * Dictionary that this field belongs to. The dictionary is used to keep track - * of the possible values of a field, - */ - protected AIdDictionary dictionary = null; - - /** Parent field in the identifier tree. */ - private AIdField parent = null; - - /** Level of nesting this field is at. */ - private int level = 0; - - /** Field name. */ - private String name = null; - - /** All known values found for this field in the dictionary. */ - private AIdRange fieldRange = null; - - /** Map of value ranges to child AIdField objects, inverse of parent. */ - private HashMap<AIdRange, AIdField> children = new HashMap<AIdRange, AIdField>(); - - /** Map of string labels in case of an enumerated field. */ - private HashMap<Integer, String> labels = null; - - /** Reference to idHelper for retrieving dictionaries. */ - protected static ANewIdHelper idHelper = ANewIdHelper.instance(); - - /** - * Empty constructor. - */ - protected AIdField() {} - - /** - * Constructor, setting dictionary and parent field. - * @param dict dictionary the field belongs to - * @param parentField parent field - */ - protected AIdField(AIdDictionary dict, AIdField parentField) { - - dictionary = dict; - if (parentField != null) { - parent = parentField; - level = parent.getLevel()+1; - } - } - - /** - * Get the name of the field. - * @return field name - */ - String getName() { - return name; - } - - /** - * Get the nesting level of the field. - * @return nesting level - */ - int getLevel() { - return level; - } - - /** - * Obtain the value of the named field from a compact identifier. - * @param fieldName field name - * @param id compact identifier - * @return value of the given field in the identifier - * @throws AAtlantisException - */ - public int get(String fieldName, long id) throws AAtlantisException { - if (id > Integer.MAX_VALUE) { - return get(fieldName, id, 64); - } else { - return get(fieldName, id, 32); - } - } - - /** - * Obtain the string value of the named field from a compact identifier. - * @param fieldName field name - * @param id compact identifier - * @return value of the given field in the identifier - * @throws AAtlantisException - */ - public String getString(String fieldName, long id) throws AAtlantisException { - if (id > Integer.MAX_VALUE) { - return getString(fieldName, id, 64); - } else { - return getString(fieldName, id, 32); - } - } - - /** - * Internal version of get(String, long), propagating the bit offset in - * the compact identifier. - * @param fieldName field name - * @param id compact identifier - * @param offset bit offset accumulated from parent fields - * @return value of the given field in the identifier - * @throws AAtlantisException - */ - private int get(String fieldName, long id, int offset) throws AAtlantisException { - - if (fieldRange == null) { - throw new AAtlantisException("No range known for identifier field" - + " '" + name + "' while decoding '" + fieldName + "'"); - } - - // The following code is duplicated a few times in this class. This is - // necessary to extract the value but also update offset at the same time. - int bits = fieldRange.bits(); - offset -= bits; - int mask = (int)(Math.pow(2, bits)) - 1; - - int value; - try { - value = fieldRange.get((int)(id >> offset & mask)); - } catch (AAtlantisException e) { - throw new AAtlantisException("Unable to decode identifier field" - + " '" + name + "': " + e); - } - - if (fieldName.equals(name)) { - // This is me, return value - return value; - } else { - // Find the correct child to delegate this ID to - for(AIdRange range : children.keySet()) { - if (range.contains(value)) { - return children.get(range).get(fieldName, id, offset); - } - } - } - - throw new AAtlantisException("Invalid identifier '" + id + "'"); - } - - /** - * Internal version of get(String, long), propagating the bit offset in - * the compact identifier. - * @param fieldName field name - * @param id compact identifier - * @param offset bit offset accumulated from parent fields - * @return value of the given field in the identifier - * @throws AAtlantisException - */ - private String getString(String fieldName, long id, int offset) throws AAtlantisException { - - if (fieldRange == null) { - throw new AAtlantisException("No range known for identifier field" - + " '" + name + "' while decoding '" + fieldName + "'"); - } - - // The following code is duplicated a few times in this class. This is - // necessary to extract the value but also update offset at the same time. - int bits = fieldRange.bits(); - offset -= bits; - int mask = (int)(Math.pow(2, bits)) - 1; - - int value; - try { - value = fieldRange.get((int)(id >> offset & mask)); - } catch (AAtlantisException e) { - throw new AAtlantisException("Unable to decode identifier field" - + " '" + name + "': " + e); - } - - if (fieldName.equals(name)) { - // This is me, return value - return getLabel(value); - } else { - // Find the correct child to delegate this ID to - for(AIdRange range : children.keySet()) { - if (range.contains(value)) { - return children.get(range).getString(fieldName, id, offset); - } - } - } - - throw new AAtlantisException("Invalid identifier '" + id + "'"); - } - - /** - * Convert a compact identifier into a "/" delimited expanded identifier. - * @param id compact identifier - * @return expanded identifier, fields delimited by "/" - */ - public String getFullIdentifier(long id) throws AAtlantisException { - - StringBuilder s = new StringBuilder(); - if (id > Integer.MAX_VALUE) { - getFullIdentifier(id, 64, s); - } else { - getFullIdentifier(id, 32, s); - } - return s.toString(); - } - - /** - * Internal version of getFullIdentifier(long), passing the bit offset a - * StringBuilder object. The output is appended to the StringBuilder object. - * @param id compact identifier - */ - private void getFullIdentifier(long id, int offset, StringBuilder s) throws AAtlantisException { - - // The following code is duplicated a few times in this class. This is - // necessary to extract the value but also update offset at the same time. - int bits = fieldRange.bits(); - offset -= bits; - int mask = (int)(Math.pow(2, bits)) - 1; - - int value; - try { - value = fieldRange.get((int)(id >> offset & mask)); - } catch (AAtlantisException e) { - throw new AAtlantisException("Unable to decode identifier field" - + " '" + name + "': " + e.getMessage()); - } - - if (hasLabels()) { - s.append(getLabel(value));//.append("=").append(value); - } else { - s.append(value); - } - - if (children != null) { - for (AIdRange range : children.keySet()) { - if (range.contains(value)) { - AIdField child = children.get(range); - if (child != null && !child.isEmpty()) { - s.append("/"); - child.getFullIdentifier(id, offset, s); - } - return; - } - } - - throw new AAtlantisException("Invalid identifier '" + id + "', " - + "field '" + name +"' does not allow value " + value + " " - + "(partially decoded: '" + s.toString() + "')"); - } - } - - /** - * Parses a <region> element in the XML file. This method should be - * called on an AIdField instance that represents the first field in the - * region. Children will be added by recursively calling this method. - * @param region XML element to parse - * @param start Starting child element - * @return Last child parsed - * @throws AAtlantisException - */ - AIdField parseRegion(Node region, String group, int start) throws AAtlantisException { - NodeList nodes = region.getChildNodes(); - - if (start == 0) { - // In a new region, first set the group all parsed elements belong to (if any). - Node groupNode = region.getAttributes().getNamedItem("group"); - if (groupNode != null) { - group = groupNode.getNodeValue(); - } - } - - for (int i=start; i<nodes.getLength(); i++) { - Node node = nodes.item(i); - - /* Select only elements, not the text in between. */ - if (node.getNodeType() == Node.ELEMENT_NODE) { - - if ("range".equals(node.getNodeName())) { - - // The first <range> encountered is for the current AIdFied. For the - // given values of this field, the next will be a child. For example, - // when called with: - // - // <range field="subdet" value="2" /> - // <range field="part" value=1" /> - // ... - // - // This field will become "subdet". In case the value of this field - // in the identifier is "2", the next field in the chain is "part". - // More values of "part" will probably be added later, plus other - // values of "subdet" for which the next field is not "part" but - // something different. - if (name == null) { - name = node.getAttributes().getNamedItem("field").getNodeValue(); - if (dictionary.hasLabels(name)) { - parseLabels(dictionary.getLabels(name)); - } - - fieldRange = dictionary.getRange(group, level); - } - - AIdRange range = new AIdRange(this, group, node); - - // Fields are sometimes repeated without specifying any allowed values, - // in that case we allow all existing values (so we copy fieldRange). - if (range.isEmpty() && !fieldRange.isEmpty()) { - range.add(fieldRange); - } - - // If this particular range is already present, give the next - // node (i+1) to the correct child and tell it to parse it. - if (children.containsKey(range) && children.get(range) != null) { - - return children.get(range).parseRegion(region, group, i+1); - } - - // If there is another range that fully contains this range, we add the - // current node there. This is a reasonable shortcut, since we are not - // interested in fully validating IDs (i.e. raise an exception when an - // RPC identifier is presented for a muon station that should not contain - // RPCs), this is a reasonable shortcut. - for (AIdRange childRange : children.keySet()) { - if (childRange.contains(range)) { - return children.get(childRange).parseRegion(region, group, i+1); - } - } - - if (group != null && !group.equals("")) { - - // Two ranges within the same group means that they should be - // considered to lead to the same child. In that case expand - // the range using AIdRange.add(). - for (AIdRange childRange : children.keySet()) { - if (group.equals(childRange.group())) { - AIdField child = children.get(childRange); - - if (child != null) { - fieldRange.add(range); - children.remove(childRange); - childRange.add(range); - children.put(childRange, child); - return child.parseRegion(region, group, i+1); - } - } - } - } - - fieldRange.add(range); - - AIdField child = new AIdField(dictionary, this); - AIdField retfield = child.parseRegion(region, group, i+1); - if (retfield instanceof AIdDictionary) { - children.put(range, retfield); - } else { - children.put(range, child); - } - - return retfield; - - } else if ("dictionary".equals(node.getNodeName())) { - - // A dictionary is a reference to another file. The AIdDictionary class - // inherits from AIdField and can will act as the first field in the - // dictionary. Dictionaries are initialized one by one, so when a dictionary - // does not exist yet, it is created empty so that it can be initialized later. - String dictName = node.getAttributes().getNamedItem("name").getNodeValue(); - if (idHelper.hasDictionary(dictName)) { - return idHelper.getDictionary(dictName); - } else { - AIdDictionary dict = new AIdDictionary(); - idHelper.addDictionary(dictName, dict); - return dict; - } - - } else if ("reference".equals(node.getNodeName())) { - - // A reference is a link to a <subregion> element. The elements within the - // subregion are parsed as if they were present instead of the reference. - String reference = node.getAttributes().getNamedItem("subregion").getNodeValue(); - AIdField child = parseRegion(dictionary.getSubRegion(reference), group, 0); - - // After parsing the subregion, we need to continue with the current region. - AIdField retfield = child.parseRegion(region, group, i+1); - return retfield; - } - } - } - - // Reached the end of a region or subregion, - // return the last object parsed (which is us). - return this; - } - - /** - * Parse a <field> object in the XML file. - * @param field XML element to parse - * @throws AAtlantisException - */ - private void parseLabels(Node field) throws AAtlantisException { - - labels = new HashMap<Integer, String>(); - int lastValue = 0; - - NodeList nodes = field.getChildNodes(); - for (int i=0; i<nodes.getLength(); i++) { - Node node = nodes.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE) { - - if (node.getNodeName().equals("label")) { - String label = node.getAttributes().getNamedItem("name").getNodeValue(); - Integer value; - - Node valueNode = node.getAttributes().getNamedItem("value"); - if (valueNode == null) { - value = lastValue+1; - } else { - value = Integer.parseInt(valueNode.getNodeValue().replaceAll("\\+", "")); - } - - labels.put(value, label); - lastValue = value.intValue(); - } - } - } - } - - /** - * Check if this field has string labels. - * @return true if string labels are present - */ - boolean hasLabels() { - return labels != null && labels.size() > 0; - } - - /** - * Check if this field is empty/uninitialized. Fields at the end of the tree - * will remain in this state, during construction all newly initialized fields - * will be in this state. - * @return - */ - boolean isEmpty() { - return name == null; - } - - /** - * Return label corresponding to an integer value. - * @param value field value - * @return label - */ - String getLabel(Integer value) { - if (labels.containsKey(value)) { - return labels.get(value); - } else { - return "?"; - } - } - - /** - * Convert a field value as it appears in the XML file into a true integer. - * For example "+2" is converted into 2 and labelled fields are converted - * into their integer equivalents. - * @param fieldName field name (for label lookup) - * @param value "raw" field value in the XML - * @return integer value - * @throws AAtlantisException - */ - protected int valueToInt(String fieldName, String value) throws AAtlantisException { - - try { - return Integer.parseInt(value.replaceAll("\\+", "")); - } catch (NumberFormatException e) { - return labelToInt(fieldName, value); - } - } - - /** - * Convert a field label into an integer value. - * @param fieldName field name - * @param label value of the labelled field - * @return integer label - * @throws AAtlantisException - */ - protected int labelToInt(String fieldName, String label) throws AAtlantisException { - if (labels != null) { - if (labels.containsValue(label)) { - for (Integer value : labels.keySet()) { - if (label.equals(labels.get(value))) { - return value; - } - } - } - } - - throw new AAtlantisException("Field/label not found in" - +" dictionary: " + fieldName + "/" + label); - } - - /** - * Convert the field structure into a printable form, starting from this node. - * @return string representation of the identifier tree - */ - @Override - public String toString() { - return toString(""); - } - - /** - * Private version of toString(), used recursively and passing an indentation - * string to print the entire tree structure. - * @param indent identation string, appended to all lines - * @return string representation of the identifier tree - */ - private String toString(String indent) { - StringBuilder s = new StringBuilder(); - - s.append(indent).append(name).append(" ").append(fieldRange).append("\n"); - - for (AIdRange range : children.keySet()) { - s.append(indent).append(range).append("\n"); - AIdField child = children.get(range); - if (child != null) { - s.append(child.toString(indent + " ")); - } - } - - return s.toString(); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/AIdHelper.java b/graphics/AtlantisJava/src/atlantis/utils/AIdHelper.java deleted file mode 100755 index 48561f8232ea9d550c3fd78da160107bd2d4b81c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/AIdHelper.java +++ /dev/null @@ -1,599 +0,0 @@ -package atlantis.utils; - -import java.util.ArrayList; - -/** - * This class contains methods for extracting various properties from the 32 bit - * identifiers used for hits. It works very similarly to the IdHelpers in Athena, - * hence its name. - * - * @author Eric Jansen - */ -public class AIdHelper { - - private static ANewIdHelper idHelper = null; - - /** - * Returns the decoded athena identifier (id) as a string, resp. an - * array of strings: first item is the full id expanded (decoded) and - * particular subparts are separated by "/" in one sting, further - * interesting subparts of the decoded id are provided in the following - * items of the array with an explanation given. - * So far (2009-01-20), this is implemented only for LAr and Tile, for - * other subsystems only first array item is returned with the expanded - * id. - * @param id int compact identifier - * @return String decoded identifier - */ - public static String[] getFullIdentifier(long id) - { - // more than 10 items should not be necessary - ArrayList<String> r = new ArrayList<String>(10); - String s = null; - - try - { - switch (subDetector(id)) - { - case 2: - switch (indetPart(id)) - { - case 1: - // Pixel identifiers are complicated and we don't use them anyway. - throw new AAtlantisException("Pixel identifiers not implemented: " + id); - case 2: - s = "2/2/" + sctBarrelEndcap(id) + "/" + - sctLayerDisk(id) + "/" + sctPhiModule(id) + "/" + - sctEtaModule(id) + "/" + sctPhiIndex(id) + "/" + - sctEtaIndex(id); - r.add(s); - return r.toArray(new String[r.size()]); - case 3: - - int part = 3; - int barrelEndcap = trtBarrelEndcap(id); - int layerWheel = trtLayerWheel(id); - int phiModule = trtPhiModule(id); - int strawLayer = trtStrawLayer(id); - int straw = trtStraw(id); - - s = "2" + "/" + part + "/" + barrelEndcap + "/" + - layerWheel + "/" + phiModule + "/" + strawLayer + - "/" + straw; - r.add(s); - r.add("barrel-endcap: " + barrelEndcap); - r.add("layer wheel: " + layerWheel); - r.add("phi module: " + phiModule); - r.add("straw layer: " + strawLayer); - r.add("straw: " + straw); - return r.toArray(new String[r.size()]); - - default: - throw new AAtlantisException("Invalid identifier: " + id); - } - case 4: - int part = larPart(id); - int sampling = part < 3 ? 0 : larSampling(id); - int eta = larEta(id); - int phi = larPhi(id); - - if(part == 1) // LAr barrel, LAr endcap - { - int barrelEndcap = larBarrelEndcap(id); - int region = larRegion(id); - s = "4/" + part + "/" + barrelEndcap + "/" + - sampling + "/" + region + "/" + eta + "/" + phi; - r.add(s); - if(barrelEndcap == 1) - { - //r.add("barrel A"); - r.add("EMBA"); - } - else if(barrelEndcap == -1) - { - //r.add("barrel C"); - r.add("EMBC"); - } - else if(barrelEndcap == 2 || barrelEndcap == 3) - { - //r.add("endcap A"); - r.add("EMECA"); - } - else if(barrelEndcap == -2 || barrelEndcap == -3) - { - //r.add("endcap C"); - r.add("EMECC"); - } - } - else if(part == 2) // HEC - { - int posNeg = larBarrelEndcap(id); - int region = larRegion(id); - s = "4/" + part + "/" + posNeg + "/" + sampling + "/" + - region + "/" + eta + "/" + phi; - r.add(s); - if(posNeg == 2) - { - //r.add("A"); - r.add("HECA"); - } - else if(posNeg == -2) - { - //r.add("C"); - r.add("HECC"); - } - } - else if(part == 3) // FCAL - { - int posNeg = larBarrelEndcap(id); - s = "4/" + part + "/" + posNeg + "/" + sampling + "/" + - eta + "/" + phi; - r.add(s); - if(posNeg == 2) - { - //r.add("A"); - r.add("FCALA"); - } - else if(posNeg == -2) - { - //r.add("C"); - r.add("FCALC"); - } - } - else - { - throw new AAtlantisException("Invalid identifier: " + id); - } - - r.add("sampling: " + sampling); // sampling remains - - return r.toArray(new String[r.size()]); - - case 5: - // tile calorimeter (first number of full id is 5) - int section = tileSection(id); - int side = tileSide(id); - int module = tileModule(id); - int tower = tileTower(id); - sampling = tileSampling(id); - int pmt = tilePmt(id); - int adc = tileAdc(id); - - s = "5/" + section + "/" + side + "/" + module + "/" + - tower + "/" + sampling + "/" + pmt + "/" + adc; - r.add(s); - - r.add("section: " + section); - r.add("side: " + side); - r.add("module: " + module); - r.add("tower: " + tower); - r.add("sampling: " + sampling); - r.add("PMT: " + pmt); - r.add("ADC: " + adc); - - return r.toArray(new String[r.size()]); - - case 7: - String technology = technology(id); - if (technology.equals("MDT")) - { - s = "7/" + stationName(id) + "/" + stationEta(id) + - "/" + stationPhi(id) + "/" + "MDT/" + - mdtMultiLayer(id) + "/" + mdtTubeLayer(id) + "/" + - mdtTube(id); - r.add(s); - return r.toArray(new String[r.size()]); - } - else if (technology.equals("RPC")) - { - s = "7/" + stationName(id) + "/" + stationEta(id) + "/" + - stationPhi(id) + "/" + "RPC/" + rpcDoubletR(id) + "/" + - rpcDoubletZ(id) + "/" + rpcDoubletPhi(id) + "/" + - rpcGasGap(id) + "/" + rpcMeasuresPhi(id) + "/" + - rpcStrip(id); - r.add(s); - return r.toArray(new String[r.size()]); - } - else if (technology == "TGC") - { - s = "7/" + stationName(id) + "/" + stationEta(id) + - "/" + stationPhi(id) + "/" + "TGC/" + tgcGasGap(id) + - "/" + tgcIsStrip(id) + "/" + tgcChannel(id); - r.add(s); - return r.toArray(new String[r.size()]); - } - else if (technology == "CSC") - { - s = "7/" + stationName(id) + "/" + stationEta(id) + "/" + - stationPhi(id) + "/" + "CSC/" + cscChamberLayer(id) + - "/" + cscWireLayer(id) + "/" + cscMeasuresPhi(id) + - "/" + cscStrip(id); - r.add(s); - return r.toArray(new String[r.size()]); - } - else - { - throw new AAtlantisException("Invalid identifier: " + id); - } - default: - throw new AAtlantisException("Not yet implemented for identifier: " + id); - } - } - catch (AAtlantisException e) - { - s = id + " (unable to decode: " + e.getMessage() + ")"; - r.add(s); - return r.toArray(new String[r.size()]); - } - - } // getFullIdentifier() ------------------------------------------------ - - - - /** @deprecated */ - public static int subDetector(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("subdet", id); - } - - /** @deprecated */ - public static int indetPart(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("part", id); - } - - /** @deprecated */ - public static int trtBarrelEndcap(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("barrel_endcap", id); - } - - - /** @deprecated */ - public static int trtLayerWheel(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("layer_or_wheel", id); - } - - /** @deprecated */ - public static int trtPhiModule(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("phi_sector", id); - } - - /** @deprecated */ - public static int trtStrawLayer(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("straw_layer", id); - } - - /** @deprecated */ - public static int trtStraw(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("straw", id); - } - - /** @deprecated */ - public static final int sctBarrelEndcap(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("barrel_endcap", id); - } - - /** @deprecated */ - public static int sctLayerDisk(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("layer", id); - } - - /** @deprecated */ - public static int sctPhiModule(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("phi_module", id); - } - - /** @deprecated */ - public static int sctEtaModule(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("eta_module", id); - } - - /** @deprecated */ - public static int sctPhiIndex(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("side", id); // This seems odd, phi_index <-> side? - } - - /** @deprecated */ - public static int sctEtaIndex(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("strip", id); - } - - /** @deprecated */ - public static int larPart(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("part", id); - } - - /** @deprecated */ - public static int larBarrelEndcap(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("barrel-endcap", id); - } - - /** @deprecated */ - public static int larPosNeg(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("pos_neg", id); - } - - /** @deprecated */ - public static int larSampling(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("sampling", id); - } - - /** @deprecated */ - public static int larRegion(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("region", id); - } - - /** @deprecated */ - public static int larEta(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - if (larPart(id) < 3) { - return idHelper.get("eta", id); - } else { - return idHelper.get("eta-fcal", id); - } - } - - /** @deprecated */ - public static int larPhi(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - if (larPart(id) < 3) { - return idHelper.get("phi", id); - } else { - return idHelper.get("phi-fcal", id); - } - } - - /** @deprecated */ - public static int larModule(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("module", id); - } - - - /** @deprecated */ - public static boolean larIsBarrel(long id) throws AAtlantisException - { - switch(Math.abs(larBarrelEndcap(id))) - { - case 1: - return true; // yes, it's barrel - case 2: - return false; // is endcap - case 3: - return false; // is endcap - default: - throw new AAtlantisException("Not a LAr identifier: " + id); - } - } - - /** @deprecated */ - public static int tileSection(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("section", id); - } - - /** @deprecated */ - public static int tileSide(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("side", id); - } - - /** @deprecated */ - public static int tileModule(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("module", id); - } - - /** @deprecated */ - public static int tileTower(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("tower", id); - } - - /** @deprecated */ - public static int tileSampling(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("sampling", id); - } - - /** @deprecated */ - public static int tilePmt(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("pmt", id); - } - - /** @deprecated */ - public static int tileAdc(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("adc", id); - } - - - /** - * Decodes Athena 32-bit ID to following form (5 is Tile): - * 5/section/side/module/tower/sampling/pmt/adc - official identifier - * - * Identifier used by TileCal collaboration, conversion is clear from the - * code and is explained in Sasha Solodkov's email on 2006-09-18 - * - * @param id int - * @return String - */ - public static String getDecodedTileIndentifier(long id) - { - try - { - int sec = tileSection(id); - int side = tileSide(id); - int mod = tileModule(id); - int tow = tileTower(id); - int samp = tileSampling(id); - - // section/side/module into decoded form - String secSideMod = "\n[could not work out section/side]"; - mod++; - if(sec == 1 && side == 1) secSideMod = "LBA" + mod; - if(sec == 1 && side == -1) secSideMod = "LBC" + mod; - if(sec == 2 && side == 1) secSideMod = "EBA" + mod; - if(sec == 3 && side == 1) secSideMod = "EBA" + mod; - if(sec == 2 && side == -1) secSideMod = "EBC" + mod; - if(sec == 3 && side == -1) secSideMod = "EBC" + mod; - - // sampling/tower into decoded form - String sampTow = "\n[could not work out sampling/tower]"; - if(samp == 0) sampTow = "A" + (int)(tow + 1); - if(samp == 1) sampTow = "B" + (int)(tow + 1); - if(samp == 2) sampTow = "D" + (int)(tow/2); - if(samp == 3) - { - if(tow == 10) sampTow = "E1"; - if(tow == 11) sampTow = "E2"; - if(tow == 13) sampTow = "E3"; - if(tow == 15) sampTow = "E4"; - } - - return secSideMod + " " + sampTow; - } - catch (AAtlantisException e) - { - return id + " (unable to decode: " + e.getMessage() + ")"; - } - } - - - /** @deprecated */ - public static String stationName(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.getString("stationName", id); - } - - /** @deprecated */ - public static String technology(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.getString("technology", id); - } - - /** @deprecated */ - public static int stationEta(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("stationEta", id); - } - - /** @deprecated */ - public static int stationPhi(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("stationPhi", id); - } - - /** @deprecated */ - public static int mdtMultiLayer(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("multiLayer", id); - } - - /** @deprecated */ - public static int mdtTubeLayer(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("tubeLayer", id); - } - - /** @deprecated */ - public static int mdtTube(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("tube", id); - } - - /** @deprecated */ - public static int rpcDoubletR(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("doubletR", id); - } - - /** @deprecated */ - public static int rpcDoubletZ(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("doubletZ", id); - } - - /** @deprecated */ - public static int rpcDoubletPhi(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("doubletPhi", id); - } - - /** @deprecated */ - public static int rpcGasGap(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("rpcGasGap", id); - } - - /** @deprecated */ - public static int rpcMeasuresPhi(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("rpcMeasuresPhi", id); - } - - /** @deprecated */ - public static int rpcStrip(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("rpcStrip", id); - } - - /** @deprecated */ - public static int tgcGasGap(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("tgcGasGap", id); - } - - /** @deprecated */ - public static int tgcIsStrip(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("isStrip", id); - } - - /** @deprecated */ - public static int tgcChannel(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("channel", id); - } - - /** @deprecated */ - public static int cscChamberLayer(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("chamberLayer", id); - } - - /** @deprecated */ - public static int cscWireLayer(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("wireLayer", id); - } - - /** @deprecated */ - public static int cscMeasuresPhi(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("cscMeasuresPhi", id); - } - - /** @deprecated */ - public static int cscStrip(long id) throws AAtlantisException { - if (idHelper == null) idHelper = ANewIdHelper.instance(); - return idHelper.get("cscStrip", id); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/AIdRange.java b/graphics/AtlantisJava/src/atlantis/utils/AIdRange.java deleted file mode 100644 index b38d5523882f5bdb002c7011e87975d284e60b8c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/AIdRange.java +++ /dev/null @@ -1,392 +0,0 @@ -package atlantis.utils; - -import java.util.Arrays; -import org.w3c.dom.Node; - - -/** - * Class representing a range of possible values for an identifier field. - * - * @author Eric Jansen - */ -class AIdRange { - - /** Group the field belongs to, ranges of the same group should be merged. */ - private String group = null; - - /** Parent field, needed only for printing of labelled fields. */ - AIdField parent = null; - - /** A discrete range with values specified in this array. */ - private int[] values = null; - - /** A continuous range from min to max (if values == null). */ - private int minValue, maxValue; - - /** - * Empty constructor, creates an empty range. - */ - AIdRange() { - this.values = new int[0]; - } - - /** - * Continuous range constructor, contains all values >= minValue <= maxValue. - * @param minValue first value in the range - * @param maxValue last value in the range - * @throws AAtlantisException - */ - AIdRange(int minValue, int maxValue) throws AAtlantisException { - - if (minValue > maxValue) { - throw new AAtlantisException("Invalid range: " + minValue + " -> " + maxValue); - } - - this.minValue = minValue; - this.maxValue = maxValue; - } - - /** - * Discrete range constructor, contains the values given in values[]. - * @param values ordered array of values - */ - AIdRange(int[] values) { - this.values = values; - } - - /** - * XML constructor, initialize the range from a <range> element. - * @param parent id field the values belong to - * @param group group this field belongs to - * @param node <range> XML element - * @throws AAtlantisException - */ - AIdRange(AIdField parent, String group, Node node) throws AAtlantisException { - - String fieldName = node.getAttributes().getNamedItem("field").getNodeValue(); - this.parent = parent; - this.group = group; - - Node minValueAttr = node.getAttributes().getNamedItem("minvalue"); - Node maxValueAttr = node.getAttributes().getNamedItem("maxvalue"); - - if (minValueAttr != null && maxValueAttr != null) { - - minValue = parent.valueToInt(fieldName, minValueAttr.getNodeValue()); - maxValue = parent.valueToInt(fieldName, maxValueAttr.getNodeValue()); - - if (minValue > maxValue) { - throw new AAtlantisException("Invalid range: " + minValue + " -> " + maxValue); - } - - } else { - Node valueAttr = node.getAttributes().getNamedItem("value"); - Node valuesAttr = node.getAttributes().getNamedItem("values"); - - if (valueAttr != null) { - values = new int[1]; - values[0] = parent.valueToInt(fieldName, valueAttr.getNodeValue()); - } else if (valuesAttr != null) { - String[] list = valuesAttr.getNodeValue().split(" "); - values = new int[list.length]; - for (int i=0; i<list.length; i++) { - values[i] = parent.valueToInt(fieldName, list[i]); - } - } else { - values = new int[0]; - } - } - } - - /** - * Get group name for this range. - * @return group name - */ - String group() { - return group; - } - - /** - * Check if the range contains value. - * @param value value to check - * @return true if value is part of this range - */ - boolean contains(int value) { - if (values == null) { - if (value >= minValue && value <= maxValue) { - return true; - } else { - return false; - } - } else { - for (int val : values) { - if (val == value) { - return true; - } - } - return false; - } - } - - /** - * Check if the range fully contains another range. - * @param range range to check - * @return true if all values in the argument are in this range - */ - boolean contains(AIdRange range) { - if (range.values == null) { - for (int value=range.minValue; value<=range.maxValue; value++) { - if (!this.contains(value)) return false; - } - } else { - for (int value : range.values) { - if (!this.contains(value)) return false; - } - } - - return true; - } - - /** - * Check if this range equals another. - * @param obj other range - * @return true if obj is an AIdRange object and its values match - */ - @Override - public boolean equals(Object obj) { - - if (!(obj instanceof AIdRange)) { - return false; - } - - AIdRange other = (AIdRange)obj; - - if (values == null && other.values == null) { - - // Continuous range, check boundaries - if (minValue == other.minValue && maxValue == other.maxValue) { - return true; - } else { - return false; - } - - } else if (values == null) { - - // Continuous and discrete range - if (other.values.length == maxValue - minValue + 1 - && other.values[other.values.length-1] == maxValue - && other.values[0] == minValue) { - return true; - } else { - return false; - } - - } else if (other.values == null) { - - // Discrete and continuous range - if (values.length == other.maxValue - other.minValue + 1 - && values[values.length-1] == other.maxValue - && values[0] == other.minValue) { - return true; - } else { - return false; - } - - } else { - - // Discrete range, check length and individual entries - if (values.length != other.values.length) { - return false; - } else { - for (int i=0; i<values.length; i++) { - if (values[i] != other.values[i]) { - return false; - } - } - - return true; - } - } - } - - /** - * Check if the range specifies any values or not. - * @return true if the range is empty, false if not - */ - public boolean isEmpty() { - return values != null && values.length == 0; - } - - /** - * Hash code to facilitate lookups. - * @return hash - */ - @Override - public int hashCode() { - int hash = 7; - hash = 89 * hash + Arrays.hashCode(this.values); - hash = 89 * hash + this.minValue; - hash = 89 * hash + this.maxValue; - return hash; - } - - /** - * Merge the given range with the current one. - * @param other range to be added to the current range - * @return current range after new range has been added - * @throws AAtlantisException - */ - AIdRange add(AIdRange other) throws AAtlantisException { - - if (values == null && other.values == null) { - - // Both are continuous ranges, find min and max values. - minValue = Math.min(minValue, other.minValue); - maxValue = Math.max(maxValue, other.maxValue); - - } else if (values == null || other.values == null) { - - // One is continous, the other is discrete. - if (values == null) { - - if (other.values.length > 0) { - // If the discrete range is not empty, find min and max values. - minValue = Math.min(minValue, other.values[0]); - maxValue = Math.max(maxValue, other.values[other.values.length-1]); - } - - // If we add an empty range, there is nothing to be done. - - } else { - - if (values.length > 0) { - // If the discrete range is not empty, find min and max values. - minValue = Math.min(values[0], other.minValue); - maxValue = Math.max(values[values.length-1], other.maxValue); - values = null; - } else { - // if this is an empty range, copy min and max from the other. - minValue = other.minValue; - maxValue = other.maxValue; - values = null; - } - } - - } else { - - // Both ranges are discrete, count how many unique elements. - int numValues = values.length; - for (int value : other.values) { - if (!this.contains(value)) { - numValues++; - } - } - - // Merge two arrays, skipping duplicates and keeping order. - int[] newValues = new int[numValues]; - for (int i=0, j=0, k=0; i<numValues; i++) { - if (j == values.length) { - - newValues[i] = other.values[k++]; - - } else if (k == other.values.length) { - - newValues[i] = values[j++]; - - } else { - - if (this.values[j] == other.values[k]) { - newValues[i] = values[j++]; - k++; - } else if (values[j] < other.values[k]) { - newValues[i] = values[j++]; - } else { - newValues[i] = other.values[k++]; - } - } - } - - values = newValues; - } - - return this; - } - - /** - * Check the allowed values and return the number of bits needed to encode them. - * @return number of bits - */ - int bits() { - - // Cound how many values this field can have. - int numValues; - if (values != null) { - numValues = values.length; - } else { - numValues = maxValue - minValue + 1; - } - - if (numValues <= 2) { - // A field takes at least 1 bit, so return 1. - return 1; - } else { - // The number of bits required to store numValues different values. - return (int)(Math.ceil(Math.log(numValues) / Math.log(2))); - } - } - - /** - * Get the field value corresponding to the given range index. For example - * for a field that has range [ -2, 0, +2 ], get(0) will return -2. - * @param index, decoded from compact identifier - * @return field value - * @throws AAtlantisException - */ - int get(int index) throws AAtlantisException { - if (values != null) { - if (index < values.length) { - return values[index]; - } else { - throw new AAtlantisException("Invalid field index: " + index); - } - } else { - if (minValue + index <= maxValue) { - return minValue + index; - } else { - throw new AAtlantisException("Invalid field value: " + index); - } - } - } - - /** - * Convert the range into a convenient form for printing. - * @return formatted string representing range - */ - @Override - public String toString() { - StringBuilder s = new StringBuilder(); - s.append("[ "); - - if (values == null) { - if (parent != null && parent.hasLabels()) { - String minLabel = parent.getLabel(minValue); - String maxLabel = parent.getLabel(maxValue); - s.append(minLabel).append("=").append(minValue); - s.append(" -> ").append(maxLabel).append("=").append(maxValue); - } else { - s.append(minValue).append(" -> ").append(maxValue).append(" "); - } - } else { - for (int value : values) { - if (parent != null && parent.hasLabels()) { - String label = parent.getLabel(value); - s.append(label).append("=").append(value).append(" "); - } else { - s.append(value).append(" "); - } - } - } - s.append("]"); - return s.toString(); - } -} \ No newline at end of file diff --git a/graphics/AtlantisJava/src/atlantis/utils/AIntHashtable.java b/graphics/AtlantisJava/src/atlantis/utils/AIntHashtable.java deleted file mode 100755 index 04b0adbcd5f1b24adbb8c1699df10e47f7fe4ad6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/AIntHashtable.java +++ /dev/null @@ -1,79 +0,0 @@ -package atlantis.utils; - - -// does not copy input arrays for efficiency -// these arrays must not be modified ! - -public class AIntHashtable { - - int size; - int shift; - int[] key; - int[] value; - int[] next; - int[] first; - - /* - public AIntHashtable(int size) { - this.size=size; - shift=0; - count = 0; - key = new int[size]; - value = new int[size]; - next = new int[size]; - first = new int[size]; - for (int i = 0; i < size; ++i) - first[i] = -1; - } - */ - - public AIntHashtable(int[] key, int[] value) { - this.size=key.length; - this.key=key; - this.value=value; - // - int mask=0; - for(int i=0; i<size; ++i) { - mask=mask|key[i]; - if((mask&1)==1) break; - } - shift=0; - for(int i=0; i<size; ++i) { - if((mask>>i&1)==1) break; - shift++; - } - // - next=new int[size]; - first=new int[size]; - for(int i=0; i<size; ++i) - first[i]=-1; - for(int i=0; i<size; ++i) { - int index=(key[i]>>shift)%size; - if(index<0) index=-index; - this.next[i]=first[index]; - first[index]=i; - } - } - - public AIntHashtable(int[] key) { - this(key, makeIndexArray(key.length)); - } - - private static int[] makeIndexArray(int length) { - int[] temp=new int[length]; - for(int i=0; i<length; ++i) - temp[i]=i; - return temp; - } - - public int get(int key) { - if(size<=0) return -1; - int index=(key>>shift)%size; - if(index<0) index=-index; - for(int e=first[index]; e!=-1; e=next[e]) - if(this.key[e]==key) - return value[e]; - return -1; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/ALogger.java b/graphics/AtlantisJava/src/atlantis/utils/ALogger.java deleted file mode 100644 index 3079c193173929d83fb0fc2fcc2c6643dd227892..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/ALogger.java +++ /dev/null @@ -1,213 +0,0 @@ -package atlantis.utils; - -import java.io.IOException; -import java.io.File; -import java.util.Properties; - -import org.apache.log4j.Logger; -import org.apache.log4j.Level; -import org.apache.log4j.PatternLayout; -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.FileAppender; -import org.apache.log4j.ConsoleAppender; -import org.apache.log4j.Layout; - - - -/** - * The class is a common wrapper for logging facility, uses - * apache-logging library log4j (more complex and powerful than Java - * native java.util.logging (e.g. flushing is automated, allows customised - * message logs layout, different levels for different sources, etc). - * Because it is subclassing from Logger, it needs LoggerFactory mechanism - * to be in place. Reference to it is given via Properties, if more - * complex properties are to be defined, it will be put in a file (such - * properties file must be accessed generically so that it is load in - * correctly no matter whether Atlantis is run locally (and have distribution - * directories available) or from a .jar file (webstart execution). - * - * @author Zdenek Maxa - */ -public final class ALogger extends Logger -{ - // the class is a singleton, reference to itself - private static Logger root = null; - - // it's enough to instantiate a factory once and for all - private static ALoggerFactory loggerFactory = new ALoggerFactory(); - - // logging layouts definition (format characters explained at PatternLayout class) - private static final String CONSOLE_LOGGING_LAYOUT = - "%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %m%n"; - // %c - cathegory (must be specified at .getLogger(Class.class)) - private static final String FILE_LOGGING_LAYOUT = - "%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %m%n (%c thread:%t)%n"; - // contains some format characters which are slow - *only* for debugging - private static final String FILE_LOGGING_LAYOUT_FULL = - "%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %m%n (%c.%M() [line %L], thread:%t)%n"; - - - - // logging levels as defined in org.apache.log4j.Level - // this variable is used via a getter method to print out command - // line options help - private static String stringLevels = - Level.TRACE.toString() + ", " + // int value: 10000 - Level.DEBUG.toString() + ", " + // int value: 10000 - Level.INFO.toString() + ", " + // int value: 20000 - Level.WARN.toString() + ", " + // int value: 30000 - Level.ERROR.toString() + ", " + // int value: 30000 - Level.FATAL.toString(); // int value: 50000 - - // default logging level (if it wasn't specified or was incorrect) - private static Level defaultLevel = Level.INFO; - - - /** - * The constructor must be protected so that it is visible - * from ALoggerFactory. Should not be instantiated directly, but via - * .getInstance() - * @param name - */ - protected ALogger(String name) - { - super(name); - - } // ALogger() ---------------------------------------------------------- - - - - /** - * initialize(String[] options) - * Initializes the logger - * @param level severity level as read from the command line option - * @param destination destination to write logs to, as read from the command line - */ - public static void initialize(String level, String destination) - { - - // set logging level, if level contains nonsense, set default - Level currentLevel = Level.toLevel(level, defaultLevel); - - - // set properties - LogggerFactory - // log4j.loggerFactory=atlantis.utils.ALoggerFactory - // this may also be done via properties file (if necessary for - // more complex logging configuration without necessity to - // recompile). properties file is contains pairs key=value - // caution: must be accessed generically (so that it also - // works when atlantis is packed in a .jar file) - // without setting LoggerFactory - ClassCastException when getting - // Logger via ALogger.getLogger("Atlantis"); - Properties up = new Properties(); - up.setProperty("log4j.loggerFactory", - "atlantis.utils.ALoggerFactory"); - PropertyConfigurator.configure(up); - - // if instantiated this way - // logger = new ALogger(); - // -> NullPointerException when adding appender - - // all loggers created afterwards will have properties of this root logger - root = Logger.getRootLogger(); - - root.setLevel(currentLevel); - - - // logging will always be done to console (System.out - stdout) - - Layout consoleLayout = new PatternLayout(CONSOLE_LOGGING_LAYOUT); - ConsoleAppender ca = new ConsoleAppender(consoleLayout, - ConsoleAppender.SYSTEM_OUT); - ca.setImmediateFlush(true); - root.addAppender(ca); - - root.info("Logging to console (System.out) initialised"); - - // if a file was specified as logging destination, then logs - // will be duplicated to that file as well - if(destination != null) - { - // check if the file already exists - File f = new File(destination); - boolean fileExists = false; - if(f.exists()) - { - fileExists = true; - } - try - { - // some file was specified on the command line - Layout fileLayout = new PatternLayout(FILE_LOGGING_LAYOUT); - // if the file exists, it will be appended to - FileAppender fa = new FileAppender(fileLayout, destination); - fa.setImmediateFlush(true); - root.addAppender(fa); - if(fileExists) - { - String msg = "================================== " + - "Log file " + destination + " exists, " + - "opening it for appending"; - root.warn(msg); - } - root.warn("Logging to " + destination + " initialised"); - } - catch(IOException ex) - { - root.warn("Can't write log messages to: "+ destination); - } - } - - } // initialize() ------------------------------------------------------- - - - - public static ALogger getLogger(String name) - { - if(root != null) - { - return (ALogger) Logger.getLogger(name, loggerFactory); - } - else - { - // logger hasn't been initialised yet, initialise with - // default values (i.e. logging only to console with INFO level) - try - { - initialize(defaultLevel.toString(),null); - } - catch(Exception ex) - { - // this exception should never occur - ex.printStackTrace(); - } - return (ALogger) Logger.getLogger(name, loggerFactory); - } - - } // getLogger() -------------------------------------------------------- - - - - public static ALogger getLogger(Class clazz) - { - return ALogger.getLogger(clazz.getName()); - - } // getLogger() -------------------------------------------------------- - - - - public void forcedLog(String fqcn, Object msg, Throwable t) - { - super.forcedLog(fqcn, Level.ALL, msg, t); - - } // forcedLog() -------------------------------------------------------- - - - - public static String getStringLevels() - { - return stringLevels; - - } // getStringLevels() -------------------------------------------------- - -} // class ALogger ========================================================== diff --git a/graphics/AtlantisJava/src/atlantis/utils/ALoggerFactory.java b/graphics/AtlantisJava/src/atlantis/utils/ALoggerFactory.java deleted file mode 100644 index f4b5a772b9fa063361468cd4b63a47fe8edbde30..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/ALoggerFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -package atlantis.utils; - -import org.apache.log4j.Logger; -import org.apache.log4j.spi.LoggerFactory; - -/** - * LoggerFactory as used by ALogger - necessary when subclassing Logger - * @author Zdenek Maxa - */ -public class ALoggerFactory implements LoggerFactory -{ - - /** - * The constructor should be public as it will be called by - * configurators in different packages. - */ - public ALoggerFactory() { } - - - public Logger makeNewLoggerInstance(String name) - { - return new ALogger(name); - } - -} // class ALoggerFactory =================================================== diff --git a/graphics/AtlantisJava/src/atlantis/utils/AMath.java b/graphics/AtlantisJava/src/atlantis/utils/AMath.java deleted file mode 100755 index f52b826ab6537010e3ff6ad94328fe7d3cd78b32..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/AMath.java +++ /dev/null @@ -1,328 +0,0 @@ -package atlantis.utils; - -import java.awt.geom.Point2D; - - -/** - * Contains generally useful constants and mathematical functions - * and functions for formatting - */ -public class AMath -{ - final public static double TWO_PI = 2. * Math.PI; - final public static double PI_BY_8 = Math.PI / 8.; - - // Constant giving the unicode value of a small Greek eta. - final static public String ETA = "\u03B7"; - // Constant giving the unicode value of a small Greek lambda. - final static public String LAMBDA = "\u03BB"; - // Unicode capital Lambda - final static public String LAMBDACAP = "\u039B"; - // Unicode lowercase gamma - final static public String GAMMA = "\u03B3"; - // Constant giving the unicode value of a small Greek rho. - final static public String RHO = "\u03C1"; - // Constant giving the unicode value of a small Greek phi. - // final static public String PHI = "\u03C6"; // small - final static public String PHI = "\u03A6"; // capital - // Constant giving the unicode value of degrees symbol. - final static public String DEGREES = "\u00B0"; - // Constant giving the unicode value of a capital Greek delta. - final static public String DELTA = "\u0394"; - // final static public String PRIME = "\u00b4"; - final static public String PRIME = "'"; - final static public String MICRO = "\u00b5"; - final static public String TIMES = "\u00d7"; - final static public String ASYMP = "\u2248"; - final static public String PROP = "\u221D"; - final static public String RADIC = "\u221A"; - - final static public String PLUSMINUS = "\u00b1"; - final static public String NOTEQUAL = "\u2260"; - final static public String LESSEQUAL = "\u2264"; - final static public String GREATEREQUAL = "\u2265"; - final static public String PION = "\u03C0"; - final static public String SIGMA = "\u03A3"; - final static public String TAU = "\u03C4"; - final static public String XI = "\u039E"; - final static public String OMEGA = "\u03A9"; - final static public String MU = "\u03BC"; - - final static public String RARROW = "\u279D"; // right arrow - final static public String DOT = "\u00b7"; // middle dot - - - /** - * Use the unicode overline diacritical mark to place an overline over the preceeding character - * - */ - final static public String OVERLINE = "\u0305"; - // superscript plus and minus - final static public String SUPPLUS = "\u207A"; - final static public String SUPMINUS = "\u207B"; - - - /** - * Returns eta with respect to z = 0. - * @param z double z coordinate - * @param rho double eta coordinate - * @return double eta - */ - public static double etaAbs(double z, double rho) { - double zrho = z / rho; - return Math.log(zrho + Math.sqrt(zrho * zrho + 1.)); - } - - public static double tanLambda(double eta) - { - double e = Math.exp(eta); - return 0.5 * (e-1./e); - } - - public static double lambda(double eta) - { - double e = Math.exp(eta); - return Math.atan(0.5 * (e-1./e)); - } - - public static double getPFromPttL(double pT, double tL) - { - return Math.abs(pT / Math.cos(Math.atan(tL))); - } - - public static double getPtFromPtL(double p, double tL) - { - return Math.abs(p * Math.cos(Math.atan(tL))); - } - - /** - * Force phi into range [0,360) degrees. - * @param phi angle in degrees - * @return equivalent angle in range [0,360) degrees - */ - public static double nearestPhiDegrees(double phi) - { - while(phi >= 360.) - { - phi -= 360; - } - while(phi < 0.) - { - phi += 360; - } - return phi; - } - - /** - * Force phi into range [0,2 pi) radians. - * @param phi angle in radians - * @return equivalent angle in range [0,2 pi) radians - */ - public static double nearestPhiRadians(double phi) - { - while(phi >= TWO_PI) - { - phi -= TWO_PI; - } - while(phi<0.) - { - phi += TWO_PI; - } - return phi; - } - - /** - * Force phi into range [phiMid-180,phiMid+360) degrees. - * @param phi angle in degrees - * @param phiMid mid-point of required phi range - * @return equivalent angle in range [phiMid-180,phiMid+360) degrees - */ - public static double nearestPhiDegrees(double phi, double phiMid) - { - while(phi-phiMid >= 180.) - { - phi -= 360; - } - while(phi-phiMid < -180.) - { - phi += 360; - } - return phi; - } - - /** - * Force phi into range [phiMid-pi,phiMid+pi) radians. - * @param phi angle in degrees - * @param phiMid phiMid mid-point of required phi range - * @return equivalent angle in range [phiMid-pi,phiMid+pi) radians - */ - public static double nearestPhiRadians(double phi, double phiMid) - { - while(phi - phiMid >= Math.PI) - { - phi -= TWO_PI; - } - while(phi - phiMid < -Math.PI) - { - phi += TWO_PI; - } - return phi; - } - - public static double[] splitLineIntoPieces(double[] input, int numPieces) - { - if(input.length != 2) - { - return input; - } - double[] output = new double[numPieces + 1]; - for(int p = 0; p < numPieces + 1; p++) - { - output[p] = input[0] + - (input[1] - input[0]) * (double) p / (double) numPieces; - } - return output; - } - -/** - * "Stretches" the values in the input array over a longer array. - * A number numPieces[i] of equally spaced values between input[i] and input[i+1] - * are put into the output array. So the numPieces array must have the same length - * as the input array, and the length of the output array is the sum of the - * elements of numPieces. For example: - * input = {0.0, 1.0, 5.0} numPieces = {2, 4, 1} - * output = {0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0} - * The output array must already exist and have the correct number of entries, - * otherwise this method will do nothin. - * Only used by ATGCData.getYXUser(). - * @param input array to stretch - * @param output stretched array - * @param numPieces number of output elements corresponding to each input element - */ - public static void splitArrayIntoPieces(double[] input, double[] output, int[] numPieces) - { - // Previously had "output = (double[]) input.clone();" but this is not - // passed back to the calling code so no point. - if(input.length != numPieces.length) return; - - int totalNumPieces = 0; - for (int num : numPieces) totalNumPieces += num; - if(totalNumPieces != output.length) return; - - int index = 0; - for(int i = 0; i < input.length; i++) { - int nextI = (i + 1) % input.length; // "loop back" to start of input - double start = input[i]; - double end = input[nextI]; - for(int p = 0; p < numPieces[i]; p++) - { - output[index++] = start + - (end - start) * (double) p / (double) numPieces[i]; - } - } - } - - /** - * Calculate angle between two 3-vectors represented by Point2D.Double - * objects. - * @param p1 - * @param p2 - * @return angle [radians] - */ - public static double getAngle(Point2D.Double p1, Point2D.Double p2) - { - double dx = p2.x - p1.x; - double dy = p2.y - p1.y; - return Math.atan2(dy, dx); - } - - public static Point2D.Double intersectionPoint( - Point2D.Double p1, Point2D.Double p2, Point2D.Double p3, Point2D.Double p4) - { - - double u = ((p4.x-p3.x)*(p1.y-p3.y)-(p4.y-p3.y)*(p1.x-p3.x)) / - ((p4.y-p3.y)*(p2.x-p1.x)-(p4.x-p3.x)*(p2.y-p1.y)); - return new Point2D.Double(p1.x+u*(p2.x-p1.x), p1.y+u*(p2.y-p1.y)); - } - - public static Point2D.Double intersectionPoint( - Point2D.Double p1, AVector v1, Point2D.Double p3, AVector v3) - { - Point2D.Double p2 = new Point2D.Double(p1.x+v1.dx, p1.y+v1.dy); - Point2D.Double p4 = new Point2D.Double(p3.x+v3.dx, p3.y+v3.dy); - - return intersectionPoint(p1, p2, p3, p4); - } - - - public static double[] xBox(double x,double dx) - { - return new double[] {x-dx,x-dx,x+dx,x+dx}; - } - - public static double[] yBox(double y,double dy) - { - return new double[] {y-dy,y+dy,y+dy,y-dy}; - } - - /** - * Returns the sign of a double value. - * Unlike Math.signum() it never returns zero. - */ - public static double getSign(double value) { - return (value > 0) ? 1.0 : -1.0; - } - - /** - * Returns the sign of a int value. - * Unlike Math.signum() it never returns zero. - * - */ - public static int getSign(int value) { - return (value > 0) ? 1 : -1; - } - - public static float maxAbsInArray(float[] floatArray) - { - float maxAbs = Math.abs(floatArray[0]); - for(int i=1; i<floatArray.length; ++i) - { - maxAbs = Math.max(Math.abs(floatArray[i]), maxAbs); - } - return maxAbs; - } - - public static float minAbsInArray(float[] floatArray) - { - float minAbs = Math.abs(floatArray[0]); - for(int i=1; i<floatArray.length; ++i) - { - minAbs = Math.min(Math.abs(floatArray[i]), minAbs); - } - return minAbs; - } - - public static float minNonZeroAbsInArray(float[] floatArray) - { - float minAbs = Math.abs(floatArray[0]); - for(int i=1; i<floatArray.length; ++i) - { - if(minAbs == 0.0f && floatArray[i] != 0.0f) - minAbs = floatArray[i]; - else - minAbs = Math.min(Math.abs(floatArray[i]), minAbs); - } - return minAbs; - } - - public static float deltaR(float phi1, float eta1, float phi2, float eta2){ - - float deta=Math.abs(eta1-eta2); - float dphi=Math.abs(phi1-phi2); - if(dphi>Math.PI) - dphi=(float)(Math.PI*2.0f)-dphi; - float dr=(float)Math.sqrt(deta*deta+dphi*dphi); - return dr; - } - -} // class AMath ------------------------------------------------------------- diff --git a/graphics/AtlantisJava/src/atlantis/utils/ANewIdHelper.java b/graphics/AtlantisJava/src/atlantis/utils/ANewIdHelper.java deleted file mode 100644 index 5de597b66846b9fb444bfb6c421b6560e9317e6e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/ANewIdHelper.java +++ /dev/null @@ -1,157 +0,0 @@ -package atlantis.utils; - -import java.util.HashMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * Helper tool for decoding compact readout channel identifiers. - * - * @author Eric Jansen - */ -public final class ANewIdHelper { - - /** Singleton instance. */ - private static ANewIdHelper instance = null; - - /** Link to ATLAS dictionary. */ - private AIdDictionary atlas = null; - - /** Collection of named (sub-)dictionaries. */ - private HashMap<String, AIdDictionary> dictionaries = null; - - /** Logging facility. */ - public static ALogger logger = ALogger.getLogger(ANewIdHelper.class); - - /** - * Static construct method, initializes ANewIdHelper from XML dictionaries. - * @param rootNode XML root node of type IdDict. - */ - public synchronized static void construct(Node rootNode) throws AAtlantisException { - if (instance == null) instance = new ANewIdHelper(); - try { - instance.initialize(rootNode); - } catch (AAtlantisException e) { - throw new AAtlantisException("Error initializing ANewIdHelper: " + e.getMessage()); - - } - } - - /** - * Obtain instance of ANewIdHelper. - * @return ANewIdHelper instance. - */ - public synchronized static ANewIdHelper instance() { - if (instance == null) { - throw new Error("Attempted to access ANewIdHelper instance before initialization."); - } - return instance; - } - - /** - * Private constructor. - */ - private ANewIdHelper() {}; - - /** - * Non-static, private initialization method. - * @param rootNode XML root node of type IdDict. - */ - private void initialize(Node rootNode) throws AAtlantisException { - NodeList nodes = rootNode.getChildNodes(); - for (int i=0; i<nodes.getLength(); i++) { - Node node = nodes.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE) { - if ("IdDictionary".equals(node.getNodeName())) { - String name = node.getAttributes().getNamedItem("name").getNodeValue(); - try { - if (dictionaries != null && dictionaries.containsKey(name)) { - AIdDictionary dictionary = dictionaries.get(name); - dictionary.initialize(node); - } else { - if (dictionaries == null) { - dictionaries = new HashMap<String,AIdDictionary>(); - } - dictionaries.put(name, new AIdDictionary(node)); - } - } catch (AAtlantisException e) { - logger.error("Exception occurred while initializing IdHelper:" + e.getMessage()); - } - } - } - } - - if (dictionaries.containsKey("ATLAS")) { - atlas = dictionaries.get("ATLAS"); - } else { - throw new AAtlantisException("No 'ATLAS' dictionary found"); - } - } - - /** - * Check for presence of a named dictionary. - * @param dictName dictionary name. - * @return true if dictionary is present, false is not. - */ - boolean hasDictionary(String dictName) { - return dictionaries.containsKey(dictName); - } - - /** - * Return pointer to an existing named dictionary. - * @param dictName dictionary name - * @return dictionary object - */ - AIdDictionary getDictionary(String dictName) throws AAtlantisException { - if (dictionaries != null && dictionaries.containsKey(dictName)) { - return dictionaries.get(dictName); - } else { - throw new AAtlantisException("Dictionary " + dictName + " could not be found"); - } - } - - /** - * Add a named dictionary to the idHelper. - * @param dictName dictionary name - * @param dict dictionary - */ - void addDictionary(String dictName, AIdDictionary dict) { - if (dictionaries == null){ - dictionaries = new HashMap<String,AIdDictionary>(); - } - dictionaries.put(dictName, dict); - } - - /** - * Convert a compact identifier into a "/" delimited expanded identifier. - * @param id compact identifier - * @return expanded identifier, fields delimited by "/" - */ - public String getFullIdentifier(long id) throws AAtlantisException { - return atlas.getFullIdentifier(id); - } - - /** - * Extract named field from a compact identifier. - * @param field identifier field name - * @param id compact identifier - * @return value of named field - */ - public int get(String field, long id) throws AAtlantisException { - return atlas.get(field, id); - } - - /** - * Extract string value of a named field from a compact identifier. For - * example: - * get("stationName", id) = 49 - * getString("stationName", id) = "EIS" - * - * @param field identifier field name - * @param id compact identifier - * @return string value of named field - */ - public String getString(String field, long id) throws AAtlantisException { - return atlas.getString(field, id); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/APoint.java b/graphics/AtlantisJava/src/atlantis/utils/APoint.java deleted file mode 100755 index 38c9d1fd4adbcbf6251f68013aab47f5d577d2c6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/APoint.java +++ /dev/null @@ -1,72 +0,0 @@ -package atlantis.utils; - - -/** - * Used by APolygon and AClipPolygon in order to perform clipping. - */ -public class APoint { - - public double x, y; - - public APoint(APoint p) { - this.x=p.x; - this.y=p.y; - } - - public APoint(double x, double y) { - this.x=x; - this.y=y; - } - - public double dot_product(double[] normPoint) { - if(normPoint==null||normPoint.length!=3) - return 0.0; - else - return x*normPoint[0]+y*normPoint[1]; - } - - public APoint minus(APoint cgp) { - if(cgp==null) - return new APoint(this); - else - return new APoint(x-cgp.x, y-cgp.y); - } - - public APoint plus(APoint cgp) { - if(cgp==null) - return new APoint(this); - else - return new APoint(x+cgp.x, y+cgp.y); - } - - public void scalar_multiply(double d) { - x*=d; - y*=d; - } - - public boolean inside(double[] normalizedVector, double distance) { - if(normalizedVector==null||normalizedVector.length!=3) return false; - double k=dot_product(normalizedVector)+distance; - - return(k<=0); - } - - public double calculate_tls(APoint secondPoint, APoint clipNode, double[] normalized) { - APoint dv1, dv2; - - dv1=minus(clipNode); - dv2=secondPoint.minus(this); - return -(dv1.dot_product(normalized)/dv2.dot_product(normalized)); - } - - public APoint point_of_intersection(APoint second, double tls) { - if(second!=null) { - APoint v=second.minus(this); - - if(v!=null) v.scalar_multiply(tls); - return plus(v); - } else - return null; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/APolygon.java b/graphics/AtlantisJava/src/atlantis/utils/APolygon.java deleted file mode 100755 index 9a0c4e33bc3fa4487eb1be2bbd46978d1f2ee70d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/APolygon.java +++ /dev/null @@ -1,238 +0,0 @@ -package atlantis.utils; - - -import java.util.Vector; -import java.awt.geom.*; - - -/** - * Used in the process of clipping. - */ - -public class APolygon { - protected Vector nodes=new Vector(5, 10); - - public APolygon() {} - - public APolygon(double[] x, double[] y) { - for(int i=0; i<x.length; i++) - nodes.addElement(new APoint(x[i], y[i])); - - if(getSignedArea()<0) { - Vector newNodes=new Vector(5, 10); - - for(int i=nodes.size()-1; i>=0; i--) - newNodes.addElement(nodes.elementAt(i)); - nodes=newNodes; - } - } - - public void addPoint(double x, double y) { - nodes.addElement(new APoint(x, y)); - } - - public double getSignedArea() { - APoint p; - double[] x=new double[nodes.size()]; - double[] y=new double[nodes.size()]; - - for(int i=0; i<nodes.size(); i++) { - p=(APoint)nodes.elementAt(i); - x[i]=p.x; - y[i]=p.y; - } - - return getSignedArea(x, y); - } - - // this function returns the ABSOLUT VALUE of the area - public double getArea() { - return Math.abs(getSignedArea()); - } - - public static double getSignedArea(double[] x, double[] y) { - if(x.length!=y.length) - throw new Error("x.length != y.length"); - if(x.length==0) return 0; - - double s=0; - - for(int i=0; i<x.length-1; i++) - s+=x[i]*y[i+1]-x[i+1]*y[i]; - - s+=x[x.length-1]*y[0]-x[0]*y[x.length-1]; - return s/2; - } - - public static double getArea(double[] x, double[] y) { - return Math.abs(getSignedArea(x, y)); - } - - public static Point2D.Double getCenter(double[] x, double[] y, Point2D.Double p) { - if(x.length==0 || y.length==0) return null; - if(p==null) p=new Point2D.Double(0, 0); - - double s=0, v; - - for(int i=0; i<x.length-1; i++) { - v=x[i]*y[i+1]-x[i+1]*y[i]; - s+=v; - p.x+=(x[i]+x[i+1])*v; - p.y+=(y[i]+y[i+1])*v; - } - - v=x[x.length-1]*y[0]-x[0]*y[x.length-1]; - s+=v; - p.x+=(x[x.length-1]+x[0])*v; - p.y+=(y[x.length-1]+y[0])*v; - - double f=1/(6*s/2); - - p.setLocation(p.x*f, p.y*f); - return p; - } - - public static void scale(double[] x, double[] y, double factor) { - Point2D.Double center=APolygon.getCenter(x, y, null); - - for(int i=0; i<x.length; i++) { - x[i]=(x[i]-center.x)*factor+center.x; - y[i]=(y[i]-center.y)*factor+center.y; - } - } - - /* - public boolean isClockwise() { - if (getArea() < 0) - return true; - else - return false; - } - */ - - public APoint getNode(int index) { - if(index>=0&&index<nodes.size()) - return(APoint)(nodes.elementAt(index)); - else - return null; - } - - public int nrNodes() { - return nodes.size(); - } - - public boolean clip(AClipPolygon clipPolygon) { - int i=0; - int limit=clipPolygon.nrNodes(); - - APoint node=null; - double[] normalized=new double[3]; - double distance=0.0; - - for(i=0; i<limit; i++) { - normalized=clipPolygon.get_normalized(i); - node=clipPolygon.getNode(i); - distance=clipPolygon.get_distance(i); - if(normalized!=null&&node!=null&& !Double.isNaN(distance)) - s_h_clip_poly(normalized, node, distance); - } - - return(nodes.size()>0); - } - - public void s_h_clip_poly(double[] normalized, APoint node, double distance) { - int degree=nodes.size(); - APoint s=null, p=null, q=null; - boolean s_inside, p_inside; - double tls=0.0; - Vector keptNodes=new Vector(); - - if(degree>0&&nodes.elementAt(degree-1) instanceof APoint) - s=(APoint)nodes.elementAt(degree-1); - - for(int i=0; i<nodes.size(); i++) { - if(nodes.elementAt(i) instanceof APoint) { - p=(APoint)nodes.elementAt(i); - s_inside=s.inside(normalized, distance); - p_inside=p.inside(normalized, distance); - if(s_inside) - if(!p_inside) { - tls=s.calculate_tls(p, node, normalized); - q=s.point_of_intersection(p, tls); - keptNodes.addElement(q); - } else - keptNodes.addElement(p); - else if(p_inside) { - tls=s.calculate_tls(p, node, normalized); - q=s.point_of_intersection(p, tls); - keptNodes.addElement(q); - keptNodes.addElement(p); - } - } - s=p; - } - nodes=keptNodes; - } - - public double[][] getPolygon() { - int nrPoints=nodes.size(); - double[][] coord=new double[nrPoints][nrPoints]; - - if(nrPoints>0) - for(int i=0; i<nrPoints; i++) { - APoint aPoint=getNode(i); - - if(aPoint!=null) { - coord[0][i]=aPoint.x; - coord[1][i]=aPoint.y; - } - } - return coord; - } - - public double[] getX() { - int nrPoints=nodes.size(); - double[] coord=new double[nrPoints]; - - if(nrPoints>0) - for(int i=0; i<nrPoints; i++) { - APoint aPoint=getNode(i); - - if(aPoint!=null) - coord[i]=aPoint.x; - } - return coord; - } - - public double[] getY() { - int nrPoints=nodes.size(); - double[] coord=new double[nrPoints]; - - if(nrPoints>0) - for(int i=0; i<nrPoints; i++) { - APoint aPoint=getNode(i); - - if(aPoint!=null) - coord[i]=aPoint.y; - } - return coord; - } - - public String toString() { - StringBuilder s = new StringBuilder(); - int limit=nodes.size(); - - s.append("x:{ "); - for(int i=0; i<limit; i++) { - s.append(((APoint)nodes.elementAt(i)).x); - s.append(" :: "); - } - s.append(" }\ny:{ "); - for(int i=0; i<limit; i++) { - s.append(((APoint)nodes.elementAt(i)).y); - s.append(" :: "); - } - return s.toString(); - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/AUtilities.java b/graphics/AtlantisJava/src/atlantis/utils/AUtilities.java deleted file mode 100755 index 0c01e84f09947c8ef63649bb76ccc736e642d140..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/AUtilities.java +++ /dev/null @@ -1,243 +0,0 @@ -package atlantis.utils; - -import java.io.FileNotFoundException; -import java.io.FileInputStream; -import java.io.InputStream; -import java.io.File; -import java.util.Date; -import java.text.SimpleDateFormat; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.event.MouseEvent; -import java.awt.image.BufferedImage; -import javax.swing.SwingUtilities; -import javax.swing.ImageIcon; - - -/** - * - * @author Gary Taylor, Zdenek Maxa - */ -public class AUtilities -{ - public static ALogger logger = ALogger.getLogger(AUtilities.class); - - private static final String dateFormat = "yyyy-MM-dd-HH-mm-ss"; - - - private AUtilities() - { - } // AUtilities() ------------------------------------------------------- - - - /** - * Allow Ctrl+click as alternative to right-click so can use single-button - * mouse on the Mac computer - */ - public static boolean isRightMouseButton(MouseEvent e) - { - return SwingUtilities.isRightMouseButton(e) || - e.isControlDown(); - - } // isRightMouseButton() ----------------------------------------------- - - /** - * Returns string with current data and time formatted according to - * dateFomat attribute (currently: yyyy-MM-dd-HH-mm-ss) - * @return String - */ - public static String getDateTimeString() - { - String r = null; - Date d = new Date(System.currentTimeMillis()); - SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); - r = sdf.format(d); - return r; - - } // getDateTimeString() ------------------------------------------------ - - - /** - * Returns last directory and file name from fullPath which is assumed to be - * some path to a file. This method assumes it is used when a file is retrieved - * from a .jar file. - * @param fullPath - */ - private static String getLastDirectoryAndFileName(String fullPath) - { - // if running on Windows, Atlantis.fileSep is '\', but accessing a .jar - // file uses '/' as file separator - so replace all '\' occurrences - // '/' (troubles when running via webstart (from jar file (/ as file - // separator) on windows (uses \ as file separator)) - logger.debug("Trying to extract last directory and filename, input: " + fullPath); - char[] charArray = fullPath.replaceAll("\\\\", "/").toCharArray(); - int sepOccurence = 0; // file separator (e.g. '/') occurrence counter - int i; - for(i = fullPath.length() - 1; i > 0; i--) - { - // compare only to '/', even on Windows '\' was already replaced - // by '/' - if(charArray[i] == '/') - { - sepOccurence++; - } - if(sepOccurence == 2) - { - // i variable now holds second file separator occurrence from end - break; - } - } - - String relPath = null; - - if(sepOccurence == 0) - { - logger.warn("No file separator found in the file path: " + fullPath); - relPath = fullPath; - } - else if(i == 0) - { - logger.warn("The path looks like relative path already, using: " + - fullPath); - relPath = fullPath; - } - else - { - relPath = new String(charArray).substring(i + 1); - logger.debug("Last directory and filename result: " + relPath); - } - - return relPath; - - } // getLastDirectoryAndFileName() -------------------------------------- - - - - /** - * Reads either locally (full path in fileName) or from atlantis.jar. Using - * this method for reading files makes Atlantis running either with runtime - * distribution directories (e.g. img, geometry, etc) or from .jar file - * (everything including runtime directories packed in a jar file) - * transparent. Having everything in .jar files is a requirement for - * running as Java WebStart. - * This method is used for files (text, xml) as InputStream. - * @param fileName - full path - */ - public static InputStream getFileAsStream(String fileName) throws AAtlantisException - { - InputStream is = null; - - if(fileName == null || "".equals(fileName)) - { - String m = "Input parameter fileName is null or empty"; - logger.debug(m); - throw new AAtlantisException(m); - } - - try - { - logger.debug("Trying to access file: " + fileName + " ..."); - is = new FileInputStream(fileName); - logger.debug("Reading " + fileName + " successful."); - } - catch(FileNotFoundException fnfe) - { - logger.warn(fileName + " not found, trying atlantis.jar ... "); - - // need to get file name and the last directory from the full path - String relPath = getLastDirectoryAndFileName(fileName); - - ClassLoader cl = AUtilities.class.getClassLoader(); - is = cl.getResourceAsStream(relPath); - if(is == null) - { - String m = fileName + " doesn't exist, reading " + relPath + - " from atlantis.jar failed."; - logger.error(m); - throw new AAtlantisException(m); - } - logger.debug(fileName + " reading from atlantis.jar successful."); - } - - return is; - - } // getFileAsStream() -------------------------------------------------- - - - - /** - * Reads either locally (full path in fileName) or from atlantis.jar. Using - * this method for reading files makes Atlantis running either with runtime - * distribution directories (e.g. img, geometry, etc) or from .jar file - * (everything including runtime directories packed in a jar file) - * transparent. Having everything in .jar files is a requirement for - * running as Java WebStart. - * This method is used for reading images. - * @param fileName - full path - */ - public static ImageIcon getFileAsImageIcon(String fileName) - { - - ImageIcon ii = null; - - if(fileName == null || "".equals(fileName)) - { - String m = "Input parameter fileName is null or empty, can't get ImageIcon"; - logger.debug(m); - return null; - } - - File test = new File(fileName); - if(test.exists() && test.canRead()) - { - ii = new ImageIcon(fileName); - logger.debug("Reading " + fileName + " successful."); - } - else - { - logger.debug(fileName + " not found, trying atlantis.jar ... "); - - // need to get file name and the last directory from the full path - String relPath = getLastDirectoryAndFileName(fileName); - - ClassLoader cl = AUtilities.class.getClassLoader(); - try { - ii = new ImageIcon(cl.getResource(relPath)); - logger.debug(fileName + " reading from atlantis.jar successful."); - } - catch (Throwable e) { - String m = "Failed to read "+ fileName + " from " + relPath + - " in atlantis.jar"; - logger.debug(m); - } - } - - return ii; - - } // getFileAsImageIcon() ----------------------------------------------- - - // Function used to rescale an Image and return an ImageIcon - // - public static ImageIcon scale(Image src, double scale, boolean antiAlias) { - int w = (int)(scale*src.getWidth(null)); - int h = (int)(scale*src.getHeight(null)); - int type = BufferedImage.TYPE_INT_ARGB; - BufferedImage dst = new BufferedImage(w, h, type); - Graphics2D g2 = dst.createGraphics(); - if(antiAlias) // Render png High Quality when AntiAliasing selected - { - g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); - g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - } - else // else render it for speed. - { - g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); - g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED); - } - g2.drawImage(src, 0, 0, w, h, null); - g2.dispose(); - return new ImageIcon(dst); - } // ------- scale() - -} // class AUtilities ======================================================= diff --git a/graphics/AtlantisJava/src/atlantis/utils/AVector.java b/graphics/AtlantisJava/src/atlantis/utils/AVector.java deleted file mode 100755 index 2d3f7b8c9769e893ab1bba47861089e2d22553c0..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/AVector.java +++ /dev/null @@ -1,84 +0,0 @@ -package atlantis.utils; - - -import java.awt.geom.Point2D; - - -/** - * Provides basic 2D vector operations. - */ - -public class AVector { - - public double dx, dy; - - public AVector(double dx, double dy) { - set(dx, dy); - } - - public AVector(double x1, double y1, double x2, double y2) { - set(x2-x1, y2-y1); - } - - public AVector(Point2D p1, Point2D p2) { - this(p1.getX(), p1.getY(), p2.getX(), p2.getY()); - } - - public AVector set(double dx, double dy) { - this.dx=dx; - this.dy=dy; - return this; - } - - public AVector getUnitary() { - double r=Math.sqrt(dx*dx+dy*dy); - - return new AVector(dx/r, dy/r); - } - - public AVector makeUnitary() { - double r=Math.sqrt(dx*dx+dy*dy); - - dx/=r; - dy/=r; - return this; - } - - public AVector rotate(double alpha) { - double sin=Math.sin(alpha); - double cos=Math.cos(alpha); - double dx_prime=dx*cos-dy*sin; - double dy_prime=dx*sin+dy*cos; - - dx=dx_prime; - dy=dy_prime; - return this; - } - - public AVector scale(double factor) { - dx*=factor; - dy*=factor; - return this; - } - - public AVector invert() { - dx*=-1; - dy*=-1; - return this; - } - - public double modulus() { - return Math.sqrt(dx*dx+dy*dy); - } - - public AVector add(AVector v) { - dx+=v.dx; - dy+=v.dy; - return this; - } - - public String toString() { - return "AVector[dx="+dx+", dy="+dy+"]"; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/package.html b/graphics/AtlantisJava/src/atlantis/utils/package.html deleted file mode 100644 index ba4e3fa430d35a5121c429c1ceed438865a495bd..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/package.html +++ /dev/null @@ -1,6 +0,0 @@ -<html> -<head></head> -<body> -<p>Helper classes.</p> -</body> -</html> diff --git a/graphics/AtlantisJava/src/atlantis/utils/xml/AArrayParser.java b/graphics/AtlantisJava/src/atlantis/utils/xml/AArrayParser.java deleted file mode 100755 index 027bd7e0f74d8dadf1db873e01997fab0a8d311b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/xml/AArrayParser.java +++ /dev/null @@ -1,36 +0,0 @@ -package atlantis.utils.xml; - -/** - * The superclass of Integer and Float array parsers used e.g. in parseing - * arrays stored in xml files - */ - -public abstract class AArrayParser -{ - protected int count; - protected int state; - protected int sign; - protected boolean finished; - - protected static final char space = ' '; - protected static final char cariage = '\n'; - protected static final char zero = '0'; - protected static final char nine = '9'; - protected static final char minus = '-'; - protected static final char plus = '+'; - protected static final char dot = '.'; - protected static final char smallExp = 'e'; - protected static final char bigExp = 'E'; - - public abstract void parse(char[] ch, int start, int end); - - public abstract Object getArray(); - - /** - * @return Returns the count. - */ - public int getCount() - { - return count; - } -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/xml/AFloatArrayParser.java b/graphics/AtlantisJava/src/atlantis/utils/xml/AFloatArrayParser.java deleted file mode 100755 index 413eb6ccc877fcbf9a8d14dee4a67956906ab2d3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/xml/AFloatArrayParser.java +++ /dev/null @@ -1,255 +0,0 @@ -package atlantis.utils.xml; - -/** - * The parser used to generate arrays of float values. - */ - -public class AFloatArrayParser extends AArrayParser -{ - private final static int SKIPPING_BLANKS = 0; - private final static int CHECKING_MINUS = 1; - private final static int CHECKING_INF1 = 2; - private final static int CHECKING_INF2 = 3; - private final static int CHECKING_INF3 = 4; - private final static int READING_INT = 5; - private final static int CHECKING_DOT = 6; - private final static int READING_FLOAT = 7; - private final static int CHECKING_EXP = 8; - private final static int CHECKING_EXP_SIGN = 9; - private final static int READING_EXP = 10; - private final static int FINISHING = 11; - private final static int IGNORE = 12; - - private static double[] powers = new double[200 * 2]; - private float[] array; - private float number = 0; - private int floatDigits = 0; - private int exp = 0; - private int expSign = 1; - private boolean isInf = false; - - static - { - for(int i = 0; i < 2 * 200; i++) - powers[i] = Math.pow(10, i - 200); - } - - public AFloatArrayParser(int size) - { - array = new float[size]; - count = 0; - if(size == 0) - state = IGNORE; - else - state = SKIPPING_BLANKS; - sign = 1; - } - - public void parse(char[] ch, int start, int length) - { - if(state == IGNORE) - { - finished = true; - return; - } - - int end = start + length; - nextChar: for(int i = start; i < end; i++) - { - char c = ch[i]; - thisChar: while(true) - { - - switch(state) - { - - case SKIPPING_BLANKS: - if(c == space || c == cariage) - continue nextChar; - else - { - finished = false; - state++; - continue thisChar; - } - - case CHECKING_MINUS: - if(c == minus) - { - sign = -1; - state++; - continue nextChar; - } - else - { - state++; - continue thisChar; - } - - case CHECKING_INF1: - if(c == 'i' || c == 'I') - { - state++; - continue nextChar; - } - else - { - state = READING_INT; - continue thisChar; - } - - case CHECKING_INF2: - if(c == 'n' || c == 'N') - { - state++; - continue nextChar; - } - else - { - state = FINISHING; - continue thisChar; - } - - case CHECKING_INF3: - if(c == 'f' || c == 'F') - { - state = FINISHING; - isInf = true; - continue nextChar; - } - else - { - state = FINISHING; - continue thisChar; - } - - case READING_INT: - if(c >= zero && c <= nine) - { - number = number * 10 + c - zero; - continue nextChar; - } - else - { - state++; - continue thisChar; - } - - case CHECKING_DOT: - if(c == dot) - { - state++; - continue nextChar; - } - else - { - state++; - continue thisChar; - } - - case READING_FLOAT: - if(c >= zero && c <= nine) - { - number = number * 10 + c - zero; - floatDigits++; - continue nextChar; - } - else - { - state++; - continue thisChar; - } - - case CHECKING_EXP: - if(c == smallExp || c == bigExp) - { - state++; - continue nextChar; - } - else - { - state = FINISHING; - continue thisChar; - } - - case CHECKING_EXP_SIGN: - if(c == minus) - { - expSign = -1; - state++; - continue nextChar; - } - if(c == plus) - { - expSign = +1; - state++; - continue nextChar; - } - else - { - state++; - continue thisChar; - } - - case READING_EXP: - if(c >= zero && c <= nine) - { - exp = exp * 10 + c - zero; - continue nextChar; - } - else - { - state++; - continue thisChar; - } - - case FINISHING: - if(c == space || c == cariage) - { - try - { - if(isInf) - { - if(sign == 1) - array[count] = Float.POSITIVE_INFINITY; - else - array[count] = Float.NEGATIVE_INFINITY; - isInf = false; - } - else - array[count] = (float) (number * sign * powers[expSign * exp - floatDigits + 200]); - } - catch(IndexOutOfBoundsException e) - { - // the real number of data is more than the - // expected number of data - throw new IndexOutOfBoundsException("more"); - } - state = SKIPPING_BLANKS; - sign = 1; - exp = 0; - expSign = 1; - floatDigits = 0; - number = 0; - count++; - finished = true; - continue nextChar; - } - else - { - throw new NumberFormatException("" + c); - } - } - } // while true - } // for - } - - public Object getArray() - { - if(!finished) - array[count] = (float) (number * sign * powers[expSign * exp - - floatDigits + 200]); - return array; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/xml/AIntArrayParser.java b/graphics/AtlantisJava/src/atlantis/utils/xml/AIntArrayParser.java deleted file mode 100755 index 74ed17a767f36405b617f38471af72746c84739b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/xml/AIntArrayParser.java +++ /dev/null @@ -1,126 +0,0 @@ -package atlantis.utils.xml; - -/** - * The parser used to generate arrays of integer values. - */ - -public class AIntArrayParser extends AArrayParser -{ - private final static int SKIPPING_BLANKS = 0; - private final static int CHECKING_MINUS = 1; - private final static int READING_INT = 2; - private final static int FINISHING = 3; - private final static int IGNORE = 4; - - private int[] array; - private long number = 0; - - public AIntArrayParser(int size) - { - array = new int[size]; - count = 0; - if(size == 0) - state = IGNORE; - else - state = SKIPPING_BLANKS; - sign = 1; - } - - public void parse(char[] ch, int start, int length) - { - if(state == IGNORE) - { - finished = true; - return; - } - - int end = start + length; - nextChar: for(int i = start; i < end; i++) - { - char c = ch[i]; - thisChar: while(true) - { - switch(state) - { - case READING_INT: - if(c >= zero && c <= nine) - { - number = number * 10 + c - zero; - continue nextChar; - } - else - { - state++; - continue thisChar; - } - case SKIPPING_BLANKS: - if(c == space || c == cariage) - continue nextChar; - else - { - finished = false; - state++; - continue thisChar; - } - case CHECKING_MINUS: - if(c == minus) - { - sign = -1; - state++; - continue nextChar; - } - else - { - state++; - continue thisChar; - } - case FINISHING: - if(c == space || c == cariage) - { - try - { - // This is a hack to make 64-bit identifiers work without - // using long internally. It works because for most - // identifiers only the most significant 32 bits are - // actually used. Proper support for 64-bit integer - // identifiers needs to be implemented asap (#618). - // -- EJ 09/2012 - if (number > Integer.MAX_VALUE && number >> 32 != 0) { - number = number >> 32; - } - array[count] = (int)number * sign; - } - catch(IndexOutOfBoundsException e) - { - // the real number of data is more than the - // expected number of data - throw new IndexOutOfBoundsException("more"); - } - number = 0; - count++; - sign = 1; - state = SKIPPING_BLANKS; - finished = true; - continue nextChar; - } - else - { - throw new NumberFormatException("" + c); - } - } - } // while true - } // for - } - - public Object getArray() - { - if(!finished) { - if (number > Integer.MAX_VALUE) { - number = number >> 32; - } - array[count] = (int)number * sign; - } - return array; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/xml/AStringArrayParser.java b/graphics/AtlantisJava/src/atlantis/utils/xml/AStringArrayParser.java deleted file mode 100755 index 1029bbb4a6c6147c85b2c7418a0ca20657ea158a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/xml/AStringArrayParser.java +++ /dev/null @@ -1,103 +0,0 @@ -package atlantis.utils.xml; - -/** - * The parser used to generate arrays of integer values. - */ - -public class AStringArrayParser extends AArrayParser -{ - private final static int SKIPPING_BLANKS = 0; - private final static int READING_STRING = 1; - private final static int FINISHING = 2; - private final static int IGNORE = 3; - - StringBuffer buffer; - private String[] array; - - public AStringArrayParser(int size) - { - array = new String[size]; - buffer = new StringBuffer(20); - count = 0; - if(size == 0) - state = IGNORE; - else - state = SKIPPING_BLANKS; - } - - public void parse(char[] ch, int start, int length) - { - if(state == IGNORE) - { - finished = true; - return; - } - - int end = start + length; - nextChar: for(int i = start; i < end; i++) - { - char c = ch[i]; - thisChar: while(true) - { - - switch(state) - { - - case READING_STRING: - if(!(c == space || c == cariage)) - { - buffer.append(c); - continue nextChar; - } - else - { - state++; - continue thisChar; - } - - case SKIPPING_BLANKS: - if(c == space || c == cariage) - continue nextChar; - else - { - finished = false; - state++; - continue thisChar; - } - - case FINISHING: - if(c == space || c == cariage) - { - try - { - array[count++] = new String(buffer); - } - catch(IndexOutOfBoundsException e) - { - // the real number of data is more than the - // expected number of data - throw new IndexOutOfBoundsException("more"); - } - - buffer.setLength(0); - state = SKIPPING_BLANKS; - finished = true; - continue nextChar; - } - else - { - throw new NumberFormatException("" + c); - } - } - } // while true - } // for - } - - public Object getArray() - { - if(!finished && array.length > 0) - array[count] = new String(buffer); - return array; - } - -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/xml/AXMLEntityResolver.java b/graphics/AtlantisJava/src/atlantis/utils/xml/AXMLEntityResolver.java deleted file mode 100644 index 0b7a7274a483f375f985ecd9b596902abf59f18c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/xml/AXMLEntityResolver.java +++ /dev/null @@ -1,40 +0,0 @@ -package atlantis.utils.xml; - -import atlantis.utils.AAtlantisException; -import atlantis.utils.ALogger; -import atlantis.utils.AUtilities; -import java.io.IOException; -import java.io.InputStream; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -/** - * Entity resolver, used for relaying XML file includes to AUtilities. - * AUtilities.getFileAsStream() handles including files that are located in - * the webstart jar file. - * - * @author Eric Jansen - */ -public class AXMLEntityResolver implements EntityResolver { - - public static ALogger logger = ALogger.getLogger(AXMLEntityResolver.class); - - @Override - public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { - - InputStream input = null; - try { - if (systemId.startsWith("file://")) { - systemId = systemId.substring(7); - } - input = AUtilities.getFileAsStream(systemId); - } catch (AAtlantisException e) { - - logger.error("Could not resolve external entity" - +" '"+systemId+"': " + e.getMessage()); - } - - return new InputSource(input); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/xml/AXMLErrorHandler.java b/graphics/AtlantisJava/src/atlantis/utils/xml/AXMLErrorHandler.java deleted file mode 100755 index fddab8ec5dbd496f824e8a913ebb095f237f81b8..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/xml/AXMLErrorHandler.java +++ /dev/null @@ -1,127 +0,0 @@ -package atlantis.utils.xml; - -import org.xml.sax.ErrorHandler; -import org.xml.sax.SAXParseException; - -import atlantis.utils.ALogger; - -/** - * Used in the XML processing code to catch and store the possible exceptions and errors. - */ -public class AXMLErrorHandler implements ErrorHandler { - - //the logger - private final ALogger logger = ALogger.getLogger(AXMLErrorHandler.class); - /** - * Thee different error states encountered in XML parsing - */ - public enum ErrorState { - - NO_ERROR, // no error - IGNORED_DATA, // the given data will be ignored - UNKNOWN_TAG, // unknown tag - INVALID_DATA, // the given data is not valid (e.g. string instead of int) - OTHER_ERROR, // some other error - FATAL_ERROR // some fatal error - event has to be aborted - } - - //Store the current error state - private ErrorState errorState = ErrorState.NO_ERROR; - //Store the exception causing the error - private Throwable cause = null; - - /** - * @return the current error state of the parser - */ - public ErrorState getErrorState() { - return errorState; - } - - /** - * @return the cause of the last error - */ - public Throwable getErrorCause(){ - return cause; - } - - /** - * Set the error state of the parser - * @param errorState The errorState to set. - * @param cause the cause of the error - */ - public void setError(ErrorState errorState, Throwable cause) { - - //check that the user had actually given a cause for all errors - if (cause == null && (errorState != ErrorState.NO_ERROR )) - throw new IllegalArgumentException("Cause can not be NULL"); - - this.errorState = errorState; - - //force cause null for NO_ERROR - if (errorState == ErrorState.NO_ERROR) - this.cause = null; - else - this.cause = cause; - } - - /** - * Handles all errors occurding during parsing - * @param exception the SAXParseException causing the error - */ - public void error(SAXParseException exception) { - - //Only keep the first error, ignore subsequents - if ( getErrorState() != ErrorState.NO_ERROR ) return; - - //Decode error from exception message (is there no better way?! - String errorMessage = exception.getMessage(); - - //Check for undeclared elements - if ( errorMessage.startsWith("Element type") && - errorMessage.indexOf("must be declared") >= 0) { - // an undeclared element is found in event file - // errorMessage - Element type "elementName" must be declared. - setError(ErrorState.UNKNOWN_TAG,exception); - return; - - } else if (errorMessage.startsWith("The content of element type") && - errorMessage.indexOf("must match") >= 0) { - /* errorMessage - The content of element type "elementName" must - match ... - - this error will occur if any undeclared element is found. - */ - setError(ErrorState.INVALID_DATA,exception); - return; - } else { - // an untreated error (e.g. undeclared attributes, etc.) - // supposed to be corrected by modifying event.dtd or retrievers - logger.error("Parsing XML in line " + exception.getLineNumber() + ": " + errorMessage); - setError(ErrorState.OTHER_ERROR,exception); - return; - } - - } - - /** - * Handle warning exceptions - * @param exception the SAX exception - */ - public void warning(SAXParseException exception) { - //Write a warning output, otherwise ignore - logger.warn("Parsing XML at position " + exception.getLineNumber() + ", " + exception.getColumnNumber() + " :: " + exception.getMessage()); - } - - /** - * Handle fatal exceptions - * @param exception the SAX exception - */ - public void fatalError(SAXParseException exception) { - //Only fatal exceptions are handled by global exception handler - String m = "Fatal error while parsing XML, line: " + - exception.getLineNumber() + " column: " + - exception.getColumnNumber() + " reason: " + - exception.getMessage(); - logger.fatal(m); - System.exit(1); - } -} diff --git a/graphics/AtlantisJava/src/atlantis/utils/xml/AXMLUtils.java b/graphics/AtlantisJava/src/atlantis/utils/xml/AXMLUtils.java deleted file mode 100755 index c745a47669039e56d335d06e82695cfaef47c387..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/atlantis/utils/xml/AXMLUtils.java +++ /dev/null @@ -1,38 +0,0 @@ -package atlantis.utils.xml; - - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - - -/** - * Provides some basic XML utilities which are not present in the XML library. - */ -public class AXMLUtils -{ - public static Node getChild(Node node, String name) - { - NodeList childs = node.getChildNodes(); - - for (int i = 0; i < childs.getLength(); i++) - { - Node child = childs.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) - { - if (child.getNodeName().equals(name)) - return child; - } - } - return null; - } - - public static String tryAttribut(NamedNodeMap attributes, String attName) - { - Node node = attributes.getNamedItem(attName); - - return (node != null) ? node.getNodeValue() : null; - } - -} diff --git a/graphics/AtlantisJava/src/overview.html b/graphics/AtlantisJava/src/overview.html deleted file mode 100644 index ebe0e3f52e9bb547b1fdd85cabdc8663010d33aa..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/src/overview.html +++ /dev/null @@ -1,25 +0,0 @@ -<html> -<head></head> -<body> - -<p>Atlantis is an event display for the ATLAS experiment at -CERN's Large Hadron Collider.</p> - -<p>The primary goals of the program are the visual investigation and - the understanding of the physics of complete events. Secondary goals - are to help develop reconstruction and analysis algorithms, to - facilitate debugging during commisioning and to provided a tool for - creating pictures and animations for publications, presentations and - exhibitions.</p> - -<p>Atlantis is based on the ALEPH event display DALI.</p> - -<p>Atlantis is written entirely in Java. JiveXML (event converter) is - a C++ interface between Atlantis and the Athena ATLAS offline SW - framework.</p> - -<p>Atlantis event visualisation is a fast, interactive and intuitive - application allowing study of complete ATLAS events.</p> - -</body> -</html> diff --git a/graphics/AtlantisJava/test/events/emptyEvent.xml b/graphics/AtlantisJava/test/events/emptyEvent.xml deleted file mode 100644 index 575abcaba0bfe509b29b99d1966c8035afaca86b..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/events/emptyEvent.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/xsl" href="JiveXML_event.xsl"?> -<?ATLAS Release: "dummy"?> -<!DOCTYPE Event SYSTEM "event.dtd"> -<Event version="dummy" runNumber="1" eventNumber="1" lumiBlock="1" dateTime="" eventProperty=""> -</Event> diff --git a/graphics/AtlantisJava/test/events/muonCollections.xml b/graphics/AtlantisJava/test/events/muonCollections.xml deleted file mode 100644 index c9281c94d4df32fc6336a930040cb08710046b04..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/events/muonCollections.xml +++ /dev/null @@ -1,240 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/xsl" href="JiveXML_event.xsl"?> -<?ATLAS Release: "dummy"?> -<!DOCTYPE Event SYSTEM "event.dtd"> -<Event version="dummy" runNumber="1" eventNumber="1" lumiBlock="1" dateTime="" eventProperty=""> - -<!-- Test event with two muon track collections, ConvertedMBoyMuonSpectroOnlyTracks and ConvertedMBoyTracks, - each containing two tracks. Edited down from JiveXML_105200_190249.xml. --> - -<Track count="2" storeGateKey="ConvertedMBoyMuonSpectroOnlyTracks"> - -<barcode> -0 0 -</barcode> -<chi2> -11.516 97.6254 -</chi2> -<cotTheta> --0.769442 1.26983 -</cotTheta> -<covMatrix multiple="15"> -19219.9 -213.586 22.2079 -47.5008 0.526573 0.135968 0.532181 -0.384001 -0.00148101 0.00808431 --0.0402467 0.104992 0.000158801 -0.00114179 0.00470875 54908.6 11775 4453.41 -220.818 -39.2807 -1.26332 -73.45 -46.6243 0.226787 0.609096 -77.0102 42.0205 0.986568 -0.892189 6.4339 - -</covMatrix> -<d0> -0 0 -</d0> -<driftSign multiple="36"> -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 -</driftSign> -<hits multiple="36"> -2100232864 2100236992 2100241088 2100245216 2100249472 2100249504 2100253568 2100253600 2100257728 2100261824 -1730609632 1730613760 1730617856 1730621984 1730626336 1730626368 1730630432 1730630464 1730634592 1730638688 -1647284976 1647284336 1647286000 1647285364 1646731264 1646731296 1646739744 1646743840 1646747968 1646748000 -1646772976 1646772272 1646774000 1646773300 1680278368 1680282464 1680286592 1680295072 1680299168 1680303296 -1680315180 1680314384 1618215712 1618219840 1618219872 1618223968 1618228096 1618228128 2035453088 2035451984 -1802240896 1802245024 1802245056 1802249152 1802253280 1802257568 1802261664 1802261696 1802265824 1802269952 -1651803772 1651803200 1651769920 1651774016 1651778144 1651786592 1651790688 1651794816 1651823224 1651822616 -1651823644 1684836392 -</hits> -<id> -0 1 -</id> -<isOutlier multiple="36"> -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 1 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 1 1 1 0 1 1 0 0 -0 0 -</isOutlier> -<nPixHits> -0 0 -</nPixHits> -<nSCTHits> -0 0 -</nSCTHits> -<nTRTHits> -0 0 -</nTRTHits> -<numDoF> -32 19 -</numDoF> -<numHits> -42 30 -</numHits> -<numPolyline> -42 30 -</numPolyline> -<phi0> --0.799777 2.98857 -</phi0> -<polylineX multiple="36"> -362.371 364.017 365.663 367.309 381.139 382.149 382.786 383.796 385.443 387.09 -415.16 416.809 418.457 420.106 433.955 434.965 435.605 436.614 438.264 439.914 -471.844 471.844 473.398 473.398 485.111 486.12 509.514 511.168 512.822 513.83 -519.096 519.096 520.65 520.65 646.788 648.447 650.105 674.583 676.242 677.902 -682.726 682.726 -477.38 -479.179 -480.655 -482.454 -484.254 -485.73 -578.526 -578.526 --594.877 -597.01 -598.693 -600.825 -602.958 -620.809 -622.98 -624.767 -626.938 -630.896 --683.109 -683.109 -690.955 -693.412 -695.868 -731.028 -733.561 -736.094 -744.69 -744.69 --746.92 -979.54 -</polylineX> -<polylineY multiple="36"> --372.719 -374.414 -376.108 -377.802 -392.037 -393.077 -393.732 -394.773 -396.468 -398.163 --427.056 -428.753 -430.451 -432.148 -446.404 -447.443 -448.102 -449.141 -450.839 -452.538 --485.408 -485.408 -487.007 -487.007 -499.066 -500.104 -524.189 -525.892 -527.594 -528.632 --534.054 -534.054 -535.654 -535.654 -665.539 -667.248 -668.956 -694.165 -695.875 -697.584 --702.553 -702.553 85.6237 85.754 85.8609 85.9913 86.1216 86.2285 88.9471 88.9471 -89.0356 89.0428 89.0486 89.0558 89.063 89.101 89.1036 89.1058 89.1083 89.1131 -89.1739 89.1739 89.1895 89.1953 89.2011 89.329 89.3419 89.3547 89.4028 89.4028 -89.4162 92.8672 -</polylineY> -<polylineZ multiple="36"> --392.694 -394.508 -396.321 -398.134 -413.36 -414.472 -415.172 -416.284 -418.096 -419.908 --450.754 -452.563 -454.373 -456.182 -471.371 -472.478 -473.179 -474.285 -476.093 -477.901 --512.838 -512.838 -514.536 -514.536 -527.329 -528.43 -553.946 -555.748 -557.549 -558.648 --564.384 -564.384 -566.076 -566.076 -702.92 -704.714 -706.508 -732.968 -734.761 -736.554 --741.766 -741.766 624.853 627.02 628.798 630.966 633.133 634.911 734.06 734.06 -749.096 750.985 752.476 754.365 756.254 771.538 773.328 774.802 776.592 779.856 -819.572 819.572 825.126 826.836 828.545 851.948 853.557 855.167 860.549 860.549 -861.929 979.729 -</polylineZ> -<pt> -55.8412 -1.03551 -</pt> -<trackAuthor> -9 9 -</trackAuthor> -<z0> --319.781 549.784 -</z0> -</Track> - -<Track count="2" storeGateKey="ConvertedMBoyTracks"> - -<barcode> -0 0 -</barcode> -<chi2> -11.516 97.6254 -</chi2> -<cotTheta> --0.770806 1.3117 -</cotTheta> -<covMatrix multiple="15"> -82352.8 -562.768 12126.3 -112.852 1.11282 0.199247 2.26463 -40.4407 -0.00427538 0.146613 --0.0227186 0.948083 0.00233271 -0.00250997 0.00411825 1.41767e+07 175813 5.07167e+07 -38589 17704.2 -133.741 5445.87 -130132 -66.2113 351.292 -4460.38 20560 25.2706 -57.2321 21.1558 - -</covMatrix> -<d0> -0.493352 11.5304 -</d0> -<driftSign multiple="36"> -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 -</driftSign> -<hits multiple="36"> -2100232864 2100236992 2100241088 2100245216 2100249472 2100249504 2100253568 2100253600 2100257728 2100261824 -1730609632 1730613760 1730617856 1730621984 1730626336 1730626368 1730630432 1730630464 1730634592 1730638688 -1647284976 1647284336 1647286000 1647285364 1646731264 1646731296 1646739744 1646743840 1646747968 1646748000 -1646772976 1646772272 1646774000 1646773300 1680278368 1680282464 1680286592 1680295072 1680299168 1680303296 -1680315180 1680314384 1618215712 1618219840 1618219872 1618223968 1618228096 1618228128 2035453088 2035451984 -1802240896 1802245024 1802245056 1802249152 1802253280 1802257568 1802261664 1802261696 1802265824 1802269952 -1651803772 1651803200 1651769920 1651774016 1651778144 1651786592 1651790688 1651794816 1651823224 1651822616 -1651823644 1684836392 -</hits> -<id> -0 1 -</id> -<isOutlier multiple="36"> -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 1 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 1 1 1 0 1 1 0 0 -0 0 -</isOutlier> -<nPixHits> -0 0 -</nPixHits> -<nSCTHits> -0 0 -</nSCTHits> -<nTRTHits> -0 0 -</nTRTHits> -<numDoF> -32 19 -</numDoF> -<numHits> -42 30 -</numHits> -<numPolyline> -42 30 -</numPolyline> -<phi0> --0.790721 2.76041 -</phi0> -<polylineX multiple="36"> -362.371 364.017 365.663 367.309 381.139 382.149 382.786 383.796 385.443 387.09 -415.16 416.809 418.457 420.106 433.955 434.965 435.605 436.614 438.264 439.914 -471.844 471.844 473.398 473.398 485.111 486.12 509.514 511.168 512.822 513.83 -519.096 519.096 520.65 520.65 646.788 648.447 650.105 674.583 676.242 677.902 -682.726 682.726 -477.38 -479.179 -480.655 -482.454 -484.254 -485.73 -578.526 -578.526 --594.877 -597.01 -598.693 -600.825 -602.958 -620.809 -622.98 -624.767 -626.938 -630.896 --683.109 -683.109 -690.955 -693.412 -695.868 -731.028 -733.561 -736.094 -744.69 -744.69 --746.92 -979.54 -</polylineX> -<polylineY multiple="36"> --372.719 -374.414 -376.108 -377.802 -392.037 -393.077 -393.732 -394.773 -396.468 -398.163 --427.056 -428.753 -430.451 -432.148 -446.404 -447.443 -448.102 -449.141 -450.839 -452.538 --485.408 -485.408 -487.007 -487.007 -499.066 -500.104 -524.189 -525.892 -527.594 -528.632 --534.054 -534.054 -535.654 -535.654 -665.539 -667.248 -668.956 -694.165 -695.875 -697.584 --702.553 -702.553 85.6237 85.754 85.8609 85.9913 86.1216 86.2285 88.9471 88.9471 -89.0356 89.0428 89.0486 89.0558 89.063 89.101 89.1036 89.1058 89.1083 89.1131 -89.1739 89.1739 89.1895 89.1953 89.2011 89.329 89.3419 89.3547 89.4028 89.4028 -89.4162 92.8672 -</polylineY> -<polylineZ multiple="36"> --392.694 -394.508 -396.321 -398.134 -413.36 -414.472 -415.172 -416.284 -418.096 -419.908 --450.754 -452.563 -454.373 -456.182 -471.371 -472.478 -473.179 -474.285 -476.093 -477.901 --512.838 -512.838 -514.536 -514.536 -527.329 -528.43 -553.946 -555.748 -557.549 -558.648 --564.384 -564.384 -566.076 -566.076 -702.92 -704.714 -706.508 -732.968 -734.761 -736.554 --741.766 -741.766 624.853 627.02 628.798 630.966 633.133 634.911 734.06 734.06 -749.096 750.985 752.476 754.365 756.254 771.538 773.328 774.802 776.592 779.856 -819.572 819.572 825.126 826.836 828.545 851.948 853.557 855.167 860.549 860.549 -861.929 979.729 -</polylineZ> -<pt> -58.6356 -3.08337 -</pt> -<trackAuthor> -9 9 -</trackAuthor> -<z0> -7.67828 -4.26881 -</z0> -</Track> -</Event> - diff --git a/graphics/AtlantisJava/test/events/muonCollections2.xml b/graphics/AtlantisJava/test/events/muonCollections2.xml deleted file mode 100644 index 36c046de320dc209bebd3467675719cf8758ae93..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/events/muonCollections2.xml +++ /dev/null @@ -1,291 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/xsl" href="JiveXML_event.xsl"?> -<?ATLAS Release: "dummy"?> -<!DOCTYPE Event SYSTEM "event.dtd"> - -<Event version="dummy" runNumber="2" eventNumber="2" lumiBlock="2" dateTime="" eventProperty=""> - -<!-- Test event with two muon track collections, ConvertedMBoyTracks and - ConvertedMuIdCBTracks, each containing 2 tracks. - Edited down from JiveXML_105200_190249.xml. ---> - -<Track count="2" storeGateKey="ConvertedMBoyTracks"> -<barcode> -0 0 -</barcode> -<chi2> -11.516 97.6254 -</chi2> -<cotTheta> --0.770806 1.3117 -</cotTheta> -<covMatrix multiple="15"> -82352.8 -562.768 12126.3 -112.852 1.11282 0.199247 2.26463 -40.4407 -0.00427538 0.146613 --0.0227186 0.948083 0.00233271 -0.00250997 0.00411825 1.41767e+07 175813 5.07167e+07 -38589 17704.2 -133.741 5445.87 -130132 -66.2113 351.292 -4460.38 20560 25.2706 -57.2321 21.1558 - -</covMatrix> -<d0> -0.493352 11.5304 -</d0> -<driftSign multiple="36"> -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 -</driftSign> -<hits multiple="36"> -2100232864 2100236992 2100241088 2100245216 2100249472 2100249504 2100253568 2100253600 2100257728 2100261824 -1730609632 1730613760 1730617856 1730621984 1730626336 1730626368 1730630432 1730630464 1730634592 1730638688 -1647284976 1647284336 1647286000 1647285364 1646731264 1646731296 1646739744 1646743840 1646747968 1646748000 -1646772976 1646772272 1646774000 1646773300 1680278368 1680282464 1680286592 1680295072 1680299168 1680303296 -1680315180 1680314384 1618215712 1618219840 1618219872 1618223968 1618228096 1618228128 2035453088 2035451984 -1802240896 1802245024 1802245056 1802249152 1802253280 1802257568 1802261664 1802261696 1802265824 1802269952 -1651803772 1651803200 1651769920 1651774016 1651778144 1651786592 1651790688 1651794816 1651823224 1651822616 -1651823644 1684836392 -</hits> -<id> -0 1 -</id> -<isOutlier multiple="36"> -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 1 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 1 1 1 0 1 1 0 0 -0 0 -</isOutlier> -<nPixHits> -0 0 -</nPixHits> -<nSCTHits> -0 0 -</nSCTHits> -<nTRTHits> -0 0 -</nTRTHits> -<numDoF> -32 19 -</numDoF> -<numHits> -42 30 -</numHits> -<numPolyline> -42 30 -</numPolyline> -<phi0> --0.790721 2.76041 -</phi0> -<polylineX multiple="36"> -362.371 364.017 365.663 367.309 381.139 382.149 382.786 383.796 385.443 387.09 -415.16 416.809 418.457 420.106 433.955 434.965 435.605 436.614 438.264 439.914 -471.844 471.844 473.398 473.398 485.111 486.12 509.514 511.168 512.822 513.83 -519.096 519.096 520.65 520.65 646.788 648.447 650.105 674.583 676.242 677.902 -682.726 682.726 -477.38 -479.179 -480.655 -482.454 -484.254 -485.73 -578.526 -578.526 --594.877 -597.01 -598.693 -600.825 -602.958 -620.809 -622.98 -624.767 -626.938 -630.896 --683.109 -683.109 -690.955 -693.412 -695.868 -731.028 -733.561 -736.094 -744.69 -744.69 --746.92 -979.54 -</polylineX> -<polylineY multiple="36"> --372.719 -374.414 -376.108 -377.802 -392.037 -393.077 -393.732 -394.773 -396.468 -398.163 --427.056 -428.753 -430.451 -432.148 -446.404 -447.443 -448.102 -449.141 -450.839 -452.538 --485.408 -485.408 -487.007 -487.007 -499.066 -500.104 -524.189 -525.892 -527.594 -528.632 --534.054 -534.054 -535.654 -535.654 -665.539 -667.248 -668.956 -694.165 -695.875 -697.584 --702.553 -702.553 85.6237 85.754 85.8609 85.9913 86.1216 86.2285 88.9471 88.9471 -89.0356 89.0428 89.0486 89.0558 89.063 89.101 89.1036 89.1058 89.1083 89.1131 -89.1739 89.1739 89.1895 89.1953 89.2011 89.329 89.3419 89.3547 89.4028 89.4028 -89.4162 92.8672 -</polylineY> -<polylineZ multiple="36"> --392.694 -394.508 -396.321 -398.134 -413.36 -414.472 -415.172 -416.284 -418.096 -419.908 --450.754 -452.563 -454.373 -456.182 -471.371 -472.478 -473.179 -474.285 -476.093 -477.901 --512.838 -512.838 -514.536 -514.536 -527.329 -528.43 -553.946 -555.748 -557.549 -558.648 --564.384 -564.384 -566.076 -566.076 -702.92 -704.714 -706.508 -732.968 -734.761 -736.554 --741.766 -741.766 624.853 627.02 628.798 630.966 633.133 634.911 734.06 734.06 -749.096 750.985 752.476 754.365 756.254 771.538 773.328 774.802 776.592 779.856 -819.572 819.572 825.126 826.836 828.545 851.948 853.557 855.167 860.549 860.549 -861.929 979.729 -</polylineZ> -<pt> -58.6356 -3.08337 -</pt> -<trackAuthor> -9 9 -</trackAuthor> -<z0> -7.67828 -4.26881 -</z0> -</Track> - - -<Track count="2" storeGateKey="ConvertedMuIdCBTracks"> - -<barcode> -0 0 -</barcode> -<chi2> -42.814 49.7505 -</chi2> -<cotTheta> --0.771556 1.27815 -</cotTheta> -<covMatrix multiple="15"> -0.00826928 0.00161205 0.524101 -0.000787796 -0.000158775 9.16577e-05 -9.49e-05 -0.0391607 1.23985e-05 0.00336271 --0.00155346 -0.000959667 0.000188491 8.20954e-05 0.00144041 0.169634 -0.0124204 0.789371 -0.0337235 0.00136704 -0.00730118 0.0015583 -0.128944 -0.000194753 0.02396 -0.0501037 0.0144917 0.0149698 -0.00297823 0.352475 - -</covMatrix> -<d0> -0.089879 -0.11419 -</d0> -<driftSign multiple="75.5"> -0 0 0 0 0 0 0 0 0 0 -0 1 1 -1 1 -1 -1 -1 -1 -1 --1 1 -1 -1 1 1 -1 1 -1 -1 --1 -1 1 1 -1 1 -1 1 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 -1 -1 -1 -1 --1 -1 -1 1 1 1 -1 -1 -1 1 --1 1 -1 -1 -1 -1 -1 1 1 1 --1 -1 -1 1 -1 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 -</driftSign> -<hits multiple="75.5"> -2725184265 2888627033 3047989021 168699032 168697991 171025537 171024522 173350018 173348972 175676530 -175675510 331359616 331360672 331361728 331362752 331364832 331384384 331386400 331388416 331390464 -331392480 331395520 331396544 331398560 331399584 331401600 331405664 331416928 331419008 331422144 -331424224 331427360 331428384 331430464 331432576 331433600 331435680 331436736 2100232864 2100236992 -2100241088 2100245216 2100249472 2100249504 2100253568 2100253600 2100257728 2100261824 1730609632 1730613760 -1730617856 1730621984 1730626336 1730630432 1730630464 1730634592 1730638688 1647286000 1647285364 1646731264 -1646731296 1646739744 1646743840 1646747968 1646748000 1646773300 1646774000 1680278368 1680282464 1680286592 -1680295072 1680299168 1680303296 1680314384 1680315180 2706406253 2855456339 3002378023 168253015 168251976 -170483061 170482036 172713122 172712111 174909133 174908084 383784512 383786592 383788640 383789664 -383790720 383791680 383792736 383793760 383812192 383814272 383816288 383818368 383820416 383821440 -383822496 383823520 383825536 383827616 383846048 383848128 383850144 383851168 383853216 383855296 -383857312 383859392 383877824 383882944 383885024 1618215712 1618219840 1618219872 1618223968 1618228096 -1618228128 2035453096 2035451984 1802240896 1802245024 1802245056 1802249152 1802253280 1802257568 1802261664 -1802261696 1802265824 1802269952 1651803772 1651803200 1651769920 1651774016 1651778144 1651786592 1651790688 -1651794816 1651823224 1651823644 1684800672 1684804768 1684808896 1684817248 1684821312 1684825440 1684838064 -1684837408 -</hits> -<id> -0 1 -</id> -<isOutlier multiple="75.5"> -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 1 1 1 1 1 -1 0 0 0 0 0 0 0 0 0 -0 0 1 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 -</isOutlier> -<nPixHits> -3 3 -</nPixHits> -<nSCTHits> -8 8 -</nSCTHits> -<nTRTHits> -27 29 -</nTRTHits> -<numDoF> -73 67 -</numDoF> -<numHits> -75 76 -</numHits> -<numPolyline> -75 76 -</numPolyline> -<phi0> --0.792403 2.83724 -</phi0> -<polylineX multiple="75.5"> -3.76812 6.33631 8.61433 21.2214 21.2854 26.2311 26.295 31.4707 31.5345 36.4392 -36.5029 44.1987 44.685 45.1907 45.675 46.6756 49.9041 50.7914 51.6869 52.5953 -53.5071 54.8868 55.3573 56.2911 56.7603 57.7053 59.6133 61.3182 62.2339 63.6216 -64.5559 65.9688 66.4364 67.3895 68.3545 68.8261 69.7947 70.2729 361.985 363.632 -365.28 366.928 380.774 381.786 382.423 383.434 385.083 386.732 414.834 416.484 -418.135 419.786 433.65 435.302 436.313 437.964 439.616 471.581 472.359 484.864 -485.874 509.294 510.949 512.605 513.614 519.664 519.664 646.717 648.378 650.038 -674.541 676.203 677.864 682.699 682.699 -4.69928 -8.49491 -11.7275 -28.6103 -28.6966 --35.5786 -35.6658 -43.2266 -43.3145 -49.3888 -49.4759 -62.7019 -63.94 -65.41 -66.0181 --66.6494 -67.4119 -68.0438 -68.6522 -70.5337 -71.7754 -73.1723 -74.4154 -75.8909 -76.4981 --77.1352 -77.7425 -79.1421 -80.3877 -82.3188 -83.5658 -84.9682 -85.5738 -87.0543 -88.3031 --89.7074 -90.9573 -92.824 -96.0854 -97.3375 -477.031 -478.837 -480.315 -482.129 -483.948 --485.428 -578.457 -578.457 -594.879 -597.008 -598.688 -600.823 -602.96 -620.821 -622.986 --624.768 -626.94 -630.918 -683.109 -683.109 -691.068 -693.535 -696.015 -731.403 -733.952 --736.508 -744.69 -745.805 -927.496 -930.236 -932.976 -967.838 -969.536 -972.29 -979.54 --980.655 -</polylineX> -<polylineY multiple="75.5"> --3.69527 -6.30342 -8.61847 -21.4575 -21.5229 -26.5724 -26.6377 -31.9298 -31.995 -37.0174 --37.0826 -44.9778 -45.4772 -45.9968 -46.4943 -47.5225 -50.8422 -51.7552 -52.6767 -53.6118 --54.5506 -55.9717 -56.4564 -57.4187 -57.9022 -58.8765 -60.8442 -62.6033 -63.5486 -64.9814 --65.9465 -67.4063 -67.8896 -68.8748 -69.8726 -70.3604 -71.3623 -71.8571 -373.106 -374.798 --376.49 -378.183 -392.402 -393.442 -394.096 -395.135 -396.828 -398.522 -427.384 -429.079 --430.774 -432.47 -446.71 -448.406 -449.444 -451.141 -452.837 -485.67 -486.469 -499.314 --500.351 -524.41 -526.11 -527.811 -528.848 -535.063 -535.063 -665.602 -667.309 -669.015 --694.196 -695.903 -697.61 -702.579 -702.579 1.57025 2.70537 3.64723 8.20767 8.22939 -9.91078 9.93148 11.6655 11.6851 12.9935 13.0117 15.5953 15.8191 16.081 16.1881 -16.2985 16.4308 16.5395 16.6435 16.9605 17.1658 17.3931 17.5922 17.8246 17.9191 -18.0174 18.1104 18.3221 18.5071 18.7879 18.9655 19.1617 19.2453 19.4468 19.6134 -19.7969 19.9571 20.1911 20.5846 20.7305 72.212 72.4473 72.6375 72.8677 73.0952 -73.2777 81.2266 81.2266 82.1853 82.3048 82.3986 82.5175 82.6355 83.5933 83.7065 -83.7992 83.9127 84.1196 86.7554 86.7554 87.1596 87.2851 87.4124 89.2493 89.3834 -89.5192 89.9559 90.0156 100.839 101.018 101.197 103.504 103.618 103.802 104.29 -104.366 -</polylineY> -<polylineZ multiple="75.5"> -3.50153 0.677387 -1.82855 -15.7119 -15.7825 -21.2359 -21.3064 -27.0176 -27.088 -32.5043 --32.5746 -41.0812 -41.619 -42.1784 -42.7141 -43.821 -47.3938 -48.3761 -49.3675 -50.3733 --51.383 -52.9113 -53.4324 -54.4669 -54.9867 -56.034 -58.1486 -60.0387 -61.0541 -62.5931 --63.6294 -65.1968 -65.7157 -66.7733 -67.8442 -68.3677 -69.4429 -69.9738 -392.695 -394.508 --396.321 -398.134 -413.359 -414.471 -415.172 -416.284 -418.095 -419.907 -450.752 -452.562 --454.371 -456.181 -471.369 -473.178 -474.284 -476.092 -477.9 -512.837 -513.686 -527.328 --528.429 -553.945 -555.747 -557.549 -558.648 -565.23 -565.23 -702.927 -704.721 -706.516 --732.978 -734.772 -736.565 -741.784 -741.784 13.9188 18.9826 23.283 45.5935 45.7069 -54.7381 54.8523 64.7366 64.8514 72.7677 72.881 90.0479 91.6506 93.5526 94.3391 -95.1555 96.1413 96.9581 97.7443 100.175 101.778 103.581 105.185 107.087 107.87 -108.691 109.474 111.277 112.881 115.367 116.972 118.776 119.555 121.458 123.063 -124.868 126.473 128.87 133.055 134.661 625.142 627.308 629.076 631.238 633.399 -635.154 734.06 734.06 749.091 750.989 752.48 754.369 756.247 771.525 773.326 -774.801 776.589 779.835 819.417 819.417 824.967 826.666 828.354 851.354 852.938 -854.512 859.492 860.163 951.515 952.693 953.866 968.469 969.167 970.296 973.262 -973.717 -</polylineZ> -<pt> -59.5287 -3.02081 -</pt> -<trackAuthor> -1 1 -</trackAuthor> -<z0> -7.57297 7.58689 -</z0> -</Track> - -</Event> diff --git a/graphics/AtlantisJava/test/events/rvxEvent.xml b/graphics/AtlantisJava/test/events/rvxEvent.xml deleted file mode 100644 index 21c7b7ca07e5a960a0d514b4ca836ffe747a5e3a..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/events/rvxEvent.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/xsl" href="JiveXML_event.xsl"?> -<?ATLAS Release: "dummy"?> -<!DOCTYPE Event SYSTEM "event.dtd"> -<Event version="dummy" runNumber="1" eventNumber="1" lumiBlock="1" dateTime="" eventProperty=""> - -<RVx count="4" storeGateKey=""> - -<chi2> -13.3549 13.3549 0.979663 0.979663 -</chi2> -<covMatrix multiple="6"> -3145 1516.27 739.31 230.495 111.531 34.7901 3145 1516.27 739.31 230.495 -111.531 34.7901 0.0057955 0.00580698 0.0161258 0.00385126 0.0066793 0.172986 0.0057955 0.00580698 -0.0161258 0.00385126 0.0066793 0.172986 -</covMatrix> -<numTracks> -2 2 29 0 -</numTracks> -<primVxCand> -2 2 1 0 -</primVxCand> -<sgkey> -TrackParticleCandidate TrackParticleCandidate TrackParticleCandidate TrackParticleCandidate -</sgkey> -<tracks multiple="8.25"> -41 33 41 33 0 1 2 3 4 5 -6 7 8 9 10 11 12 13 14 15 -16 17 18 19 20 21 22 23 24 25 -26 27 28 -</tracks> -<x> -35.1249 35.1249 -0.0114638 -0.0114638 -</x> -<y> -18.3795 18.3795 0.0945006 0.0945006 -</y> -<z> -7.44812 7.44812 5.03257 5.03257 -</z> -</RVx> - - -</Event> diff --git a/graphics/AtlantisJava/test/events/rvxInconsistentEvent.xml b/graphics/AtlantisJava/test/events/rvxInconsistentEvent.xml deleted file mode 100644 index 3c745253f7cef70d7250f664801ccc25ed554beb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/events/rvxInconsistentEvent.xml +++ /dev/null @@ -1,258 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/xsl" href="JiveXML_event.xsl"?> -<?ATLAS Release: "dummy"?> -<!DOCTYPE Event SYSTEM "event.dtd"> -<Event version="dummy" runNumber="1" eventNumber="1" lumiBlock="1" dateTime="" eventProperty=""> - -<RVx count="4" storeGateKey=""> - -<chi2> -13.3549 13.3549 0.979663 0.979663 -</chi2> -<covMatrix multiple="6"> -3145 1516.27 739.31 230.495 111.531 34.7901 3145 1516.27 739.31 230.495 -111.531 34.7901 0.0057955 0.00580698 0.0161258 0.00385126 0.0066793 0.172986 0.0057955 0.00580698 -0.0161258 0.00385126 0.0066793 0.172986 -</covMatrix> -<numTracks> -2 2 29 0 -</numTracks> -<primVxCand> -2 2 1 0 -</primVxCand> -<sgkey> -TrackParticleCandidate TrackParticleCandidate TrackParticleCandidate TrackParticleCandidate -</sgkey> -<tracks multiple="544.5"> --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 41 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 33 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 41 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 33 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 0 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 2 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 3 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 4 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 5 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 6 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 7 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -8 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 9 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 10 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 11 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 12 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 13 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 14 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 15 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 16 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 17 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -18 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 19 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 20 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 21 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 22 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 23 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 24 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 25 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 26 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 27 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -28 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -1 -1 --1 -1 -1 -1 -1 -1 -1 -1 -</tracks> -<x> -35.1249 35.1249 -0.0114638 -0.0114638 -</x> -<y> -18.3795 18.3795 0.0945006 0.0945006 -</y> -<z> -7.44812 7.44812 5.03257 5.03257 -</z> -</RVx> - - -</Event> diff --git a/graphics/AtlantisJava/test/src/atlantis/AtlantisHeadlessTestCase.java b/graphics/AtlantisJava/test/src/atlantis/AtlantisHeadlessTestCase.java deleted file mode 100644 index 25f0a50137d3b0ad4fd220b57dded3ee7e34090d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/AtlantisHeadlessTestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -package atlantis; - - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -import testutils.TeeOutputStream; -import testutils.TestUtils; - -public class AtlantisHeadlessTestCase { - ByteArrayOutputStream stdOutCopy = new ByteArrayOutputStream(); - protected String eventFileName = null; // Event file to give on the command line - - /** Start Atlantis in headless mode. - */ - protected void startHeadlessMode() { - // Redirect standard output to ByteArrayOutputStream as well as normal System.out - TeeOutputStream teeOut = new TeeOutputStream(System.out,stdOutCopy); - System.setOut(new PrintStream(teeOut)); - - String atlantisHomeDir = Atlantis.getHomeDirectory(); - String testEventsDir = atlantisHomeDir+"/test/events"; - TestUtils.setPropertyIfNotSet("atlantis.test.events",testEventsDir); - - System.setProperty("java.awt.headless", "true"); - String[] args = {"--debug","DEBUG"}; - if (eventFileName!=null) { - String[] newArgs = new String[args.length+1]; - for (int i=0; i<args.length; ++i) { - newArgs[i] = args[i]; - } - String eventsDirectory = System.getProperty("atlantis.test.events"); - newArgs[args.length] = eventsDirectory+"/"+eventFileName; - args = newArgs; - } - Atlantis.main(args); - } -} diff --git a/graphics/AtlantisJava/test/src/atlantis/HeadlessTest.java b/graphics/AtlantisJava/test/src/atlantis/HeadlessTest.java deleted file mode 100644 index 759ea917c954392ab86df6b1b622cb6fcef64b1e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/HeadlessTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package atlantis; - -import org.fest.swing.timing.Condition; -import org.junit.Test; -import static org.fest.swing.timing.Pause.pause; -import static org.fest.swing.timing.Timeout.timeout; - -public class HeadlessTest extends AtlantisHeadlessTestCase { - - @Test - /** Start Atlantis in headless mode and make sure it doesn't crash part-way through. - * Atlantis.initAtlantis catches all Exceptions so we check for "Atlantis Ready" in - * the output console. - */ - public void testHeadlessMode() { - startHeadlessMode(); - pause(new Condition("output to contain \"Atlantis Ready\"") { - public boolean test() {return stdOutCopy.toString().contains("Atlantis Ready");} - },timeout(10000)); - } -} diff --git a/graphics/AtlantisJava/test/src/atlantis/InconsistentEventTest.java b/graphics/AtlantisJava/test/src/atlantis/InconsistentEventTest.java deleted file mode 100644 index 5dbfffcd532b105fdd8b830fc6eb4e068b87cc43..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/InconsistentEventTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package atlantis; - -import static org.fest.swing.timing.Pause.pause; -import static org.fest.swing.timing.Timeout.timeout; -import static org.junit.Assert.*; - -import org.fest.swing.timing.Condition; -import org.junit.Before; -import org.junit.Test; - -/** - * Test for bug#556, where a JiveXML file from Atlas release 17 causes an error - * on startup when the file is given on the command line, though not when it is - * opened after Atlantis has started. - * - * @author waugh - * - */ -public class InconsistentEventTest extends AtlantisHeadlessTestCase { - @Before - public void setUp() { - eventFileName = "rel17vtxEvent.xml"; - System.setProperty("java.awt.headless", "true"); - startHeadlessMode(); - } - - @Test - public void loadEvent() { - pause(new Condition("output to contain \"Atlantis Ready\"") { - public boolean test() {return stdOutCopy.toString().contains("Atlantis Ready");} - },timeout(10000)); - String output = stdOutCopy.toString(); - assertTrue("Could not find or parse event ",output.contains("Parsing event")); - assertFalse("Error reading event",output.contains("Can not read events")); - } -} diff --git a/graphics/AtlantisJava/test/src/atlantis/NoTracksElementTest.java b/graphics/AtlantisJava/test/src/atlantis/NoTracksElementTest.java deleted file mode 100644 index e761ec038c140857108c301a80e6fbe51672e9ac..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/NoTracksElementTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package atlantis; - -import static org.fest.swing.timing.Pause.pause; -import static org.fest.swing.timing.Timeout.timeout; -import static org.junit.Assert.*; - -import org.fest.swing.timing.Condition; -import org.junit.Before; -import org.junit.Test; - -/** - * Test for bug#552, where a JiveXML file contains a "numTracks" element but - * not a corresponding "tracks" element in the "RVx" section, as in some - * of the events from the Hypatia masterclass. - * - * @author waugh - * - */ -public class NoTracksElementTest extends AtlantisHeadlessTestCase { - @Before - public void setUp() { - eventFileName = "masterclassMuonEvents.zip"; - System.setProperty("java.awt.headless", "true"); - startHeadlessMode(); - } - - @Test - public void loadEvent() { - pause(new Condition("output to contain \"Atlantis Ready\"") { - public boolean test() {return stdOutCopy.toString().contains("Atlantis Ready");} - },timeout(10000)); - String output = stdOutCopy.toString(); - assertTrue("Could not find or parse event ",output.contains("Parsing event")); - assertFalse("Error when constructing RVx",output.contains("Error when constructing RVx")); - } -} diff --git a/graphics/AtlantisJava/test/src/atlantis/canvas/AScaleBorderTest.java b/graphics/AtlantisJava/test/src/atlantis/canvas/AScaleBorderTest.java deleted file mode 100644 index 9ec8b4504a83a45724361c84b4b46d3a7b3c2ef7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/canvas/AScaleBorderTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package atlantis.canvas; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class AScaleBorderTest { - - @Test - public void testGetNumDecimalPlaces() { - assertEquals("Wrong number of decimal places",0,AScaleBorder.getNumDecimalPlaces(1.0)); - assertEquals("Wrong number of decimal places",0,AScaleBorder.getNumDecimalPlaces(10.0)); - assertEquals("Wrong number of decimal places",1,AScaleBorder.getNumDecimalPlaces(0.5)); - assertEquals("Wrong number of decimal places",2,AScaleBorder.getNumDecimalPlaces(0.02)); - assertEquals("Wrong number of decimal places",0,AScaleBorder.getNumDecimalPlaces(-2.0)); - assertEquals("Wrong number of decimal places",1,AScaleBorder.getNumDecimalPlaces(-0.5)); - } - -} diff --git a/graphics/AtlantisJava/test/src/atlantis/canvas/AScaleTest.java b/graphics/AtlantisJava/test/src/atlantis/canvas/AScaleTest.java deleted file mode 100644 index 75b0e7c588279bb6712c25a659610a9f2b67d6ad..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/canvas/AScaleTest.java +++ /dev/null @@ -1,104 +0,0 @@ -package atlantis.canvas; - -import static org.junit.Assert.*; - -import java.awt.geom.GeneralPath; -import java.awt.geom.PathIterator; - -import org.junit.Assert; -import org.junit.Test; - -public class AScaleTest { - - private static final double TOLERANCE = 0.00001; - - @Test - public void testCalculateScale() { - AScale scale = AScale.calculateScale(0, 10, 100, 3, 7, 0, 0, null); - for (double label : scale.labelValues) { - System.out.println("label = "+label); - } - for (double pos : scale.labelPositions) { - System.out.println("position: "+pos); - } - System.out.println("Primary tick marks = " + scale.primaryTicks); - GeneralPath primaryTicks = scale.primaryTicks; - PathIterator iterPTicks = primaryTicks.getPathIterator(null); - double[] coords = new double[2]; - int i = 0; - while (!iterPTicks.isDone()) { - int type = iterPTicks.currentSegment(coords); - System.out.format("point %d has type %d%n",i,type); - System.out.print("Coords: "); - for (int j=0; j<2; ++j) { - System.out.format(" %f", coords[j]); - } - System.out.println(); - i++; - iterPTicks.next(); - } - } - - @Test - public void testRoundNumbers() { - assertEquals("Wrong rounding", 5.0, AScale.getRoundNumber(9.0), TOLERANCE); - assertEquals("Wrong rounding", -5.0, AScale.getRoundNumber(-9.0), TOLERANCE); - assertEquals("Wrong rounding", 1.0, AScale.getRoundNumber(1.01), TOLERANCE); - assertEquals("Wrong rounding", 500.0, AScale.getRoundNumber(999.0), TOLERANCE); - } - - @Test - public void testGetScaleIntervals() { - double[] intervals, expectedValues; - intervals = AScale.getScaleIntervals(-11.0,11.0); - expectedValues = new double[] {10.0, 5.0, 1.0}; - assertArrayEquals("Wrong intervals", expectedValues, intervals, TOLERANCE); - intervals = AScale.getScaleIntervals(-110.0,110.0); - expectedValues = new double[] {100.0, 50.0, 10.0}; - assertArrayEquals("Wrong intervals", expectedValues, intervals, TOLERANCE); - intervals = AScale.getScaleIntervals(-51.0,51.0); - expectedValues = new double[] {50.0, 10.0, 5.0}; - assertArrayEquals("Wrong intervals", expectedValues, intervals, TOLERANCE); - intervals = AScale.getScaleIntervals(-50.0,50.0); - expectedValues = new double[] {50.0, 10.0, 5.0}; - assertArrayEquals("Wrong intervals", expectedValues, intervals, TOLERANCE); - intervals = AScale.getScaleIntervals(-49.0,49.0); - expectedValues = new double[] {40.0, 20.0, 5.0}; - assertArrayEquals("Wrong intervals", expectedValues, intervals, TOLERANCE); - intervals = AScale.getScaleIntervals(1.0,49.0); - expectedValues = new double[] {20.0, 10.0, 2.0}; - assertArrayEquals("Wrong intervals", expectedValues, intervals, TOLERANCE); - intervals = AScale.getScaleIntervals(1.0,101.0); - expectedValues = new double[] {50.0, 10.0, 5.0}; - assertArrayEquals("Wrong intervals", expectedValues, intervals, TOLERANCE); - intervals = AScale.getScaleIntervals(-101.0,-1.0); - expectedValues = new double[] {50.0, 10.0, 5.0}; - assertArrayEquals("Wrong intervals", expectedValues, intervals, TOLERANCE); - intervals = AScale.getScaleIntervals(-9.5,9.5); - expectedValues = new double[] {5.0, 1.0, 0.5}; - assertArrayEquals("Wrong intervals", expectedValues, intervals, TOLERANCE); - intervals = AScale.getScaleIntervals(19.0,61.0); - expectedValues = new double[] {20.0, 10.0, 2.0}; - assertArrayEquals("Wrong intervals", expectedValues, intervals, TOLERANCE); - intervals = AScale.getScaleIntervals(0.0,0.0); - assertNull("Intervals should be null for invalid input",intervals); - } - - @Test - public void testGetScaleValues() { - double[] values; - double[] expectedValues; - values = AScale.getScaleValues(0.0, 1.0, 1.0); - expectedValues = new double[] {0.0, 1.0}; - assertArrayEquals("Wrong scale values", expectedValues, values, TOLERANCE); - values = AScale.getScaleValues(-0.1, 1.1, 1.0); - expectedValues = new double[] {0.0, 1.0}; - assertArrayEquals("Wrong scale values", expectedValues, values, TOLERANCE); - } - - @Test - public void testInterpolate() { - float result = AScale.interpolate(0.5, 10.0, 0.0, 1.0); - assertEquals("Wrong interpolated value",5.0,result,TOLERANCE); - } -} diff --git a/graphics/AtlantisJava/test/src/atlantis/canvas/AWindowTest.java b/graphics/AtlantisJava/test/src/atlantis/canvas/AWindowTest.java deleted file mode 100644 index 076249c99931fdd80539d0457cb14f3e9fa9b391..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/canvas/AWindowTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package atlantis.canvas; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class AWindowTest { - - @Test - public void test() { - AWindow window = new AWindow("dummyName","dummyProjection","dummyGroup",1); - } - -} diff --git a/graphics/AtlantisJava/test/src/atlantis/data/AHelixTest.java b/graphics/AtlantisJava/test/src/atlantis/data/AHelixTest.java deleted file mode 100644 index b55aecf4db0d00ccbff97794223383c66c76aaff..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/data/AHelixTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package atlantis.data; - -import atlantis.parameters.APar; -import atlantis.utils.AMath; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.*; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; - -/** - * - * @author ejansen - */ - -@RunWith(Parameterized.class) -public class AHelixTest { - - private static final double TOLERANCE = 0.001; - private static final double CURVATURE = 100/0.6; - - private float d0, z0, phi0, cotanTheta, pt; - private AHelix helix; - - public AHelixTest(float d0, float z0, float phi0, float cotanTheta, float pt) { - this.d0 = d0; - this.z0 = z0; - this.phi0 = phi0; - this.cotanTheta = cotanTheta; - this.pt = pt; - } - - @Parameters - public static Collection helices() { - Collection data = new ArrayList<Object[]>(); - - for (int charge=-1; charge<=1; charge+=2) { - for (float d0=-1.f; d0<=1.f; d0+=1.f) { - for (float phi0=-(float)Math.PI; phi0<Math.PI; phi0+=Math.PI/4) { - float pt = 20.f; - - data.add(new Object[] {d0, 0.0f, phi0, 0.5f, charge*pt}); - } - } - } - - return data; - } - - @Before - public void setUp() { - APar.constructDummyForTesting(); - helix = new AHelix(d0, z0, (float)Math.toDegrees(phi0), cotanTheta, pt); - } - - @Test - public void testBackwardsCompatibility() { - AOldHelix oldHelix = new AOldHelix(d0, z0, (float)Math.toDegrees(phi0), cotanTheta, pt); - - assertArrayEquals(oldHelix.getPar(), helix.getPar(), TOLERANCE); - assertEquals(oldHelix.eta, helix.eta(), TOLERANCE); - assertEquals(oldHelix.startPhi, helix.getAlphaMin(), TOLERANCE); - assertEquals(oldHelix.rhoVertex, helix.getRhoVtx(), TOLERANCE); - } - - @Test - public void testD0() { - // The alpha=0 point should be at distance d0 - double rho = helix.getRho(0); - assertEquals(Math.abs(d0), rho, TOLERANCE); - } - - @Test - public void testCenterCoordinates() { - // Check the center of the circle against a separate calculation - double charge = Math.signum(pt); - double rC = CURVATURE * Math.abs(pt); - double xC = (rC - charge * d0) * Math.cos(phi0 - charge * Math.PI / 2); - double yC = (rC - charge * d0) * Math.sin(phi0 - charge * Math.PI / 2); - assertEquals(xC, helix.getXc(), TOLERANCE); - assertEquals(yC, helix.getYc(), TOLERANCE); - } - - @Test - public void testEndPoint() { - // End the helix at 1m from the beam pipe and check that the last point is at 1m - double alphaMax = helix.getAlphaCylinder(100., 250.); - assertEquals(100., helix.getRho(alphaMax), TOLERANCE); - } -} diff --git a/graphics/AtlantisJava/test/src/atlantis/data/AOldHelixTest.java b/graphics/AtlantisJava/test/src/atlantis/data/AOldHelixTest.java deleted file mode 100644 index 39b5077be3386e218b4a85bf7950cbb73280a550..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/data/AOldHelixTest.java +++ /dev/null @@ -1,92 +0,0 @@ -package atlantis.data; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; - -import atlantis.parameters.APar; - -import static java.lang.Math.PI; - -public class AOldHelixTest { - /** Arbitrary tolerance for floating-point comparisons */ - private static final double TOLERANCE = 0.00001; - - @Before - public void setUp() throws Exception { - APar.constructDummyForTesting(); - } - - @Test - public void helixFromNominalVertex() { - // Input: rhoVtx,phiVtx,zVtx,pt,phi,eta,charge - // Start at (0,0,0), pt=2, eta=0 so perp to z axis - // phi = 0 (arbitrary), positive charge (+1) - // Expect all params 0 except ptInverse = 0.5 - AOldHelix helix = new AOldHelix(0,0,0,2,0,0,1); - assertHelixParametersEqual("Wrong helix parameters.",0,0,0,0,0.5,helix.getPar()); - // charge = -1 so ptInverse changes sign - helix = new AOldHelix(0,0,0,2,0,0,-1); - assertHelixParametersEqual("Wrong helix parameters.",0,0,0,0,-0.5,helix.getPar()); - } - - @Test - public void helixStartingAtPCA() { - /* Input: rhoVtx,phiVtx,zVtx,pt,phi,eta,charge - * Circular track (pz=0) starting at point closest to beam, at non-zero z. - * Perpendicular to line from beam to starting vertex: phi = phiVtx + PI/2 - * Start in upwards direction, from point to the right of the beam axis, */ - AOldHelix helix = new AOldHelix(0.1f,0,0.25f,1,(float)(PI/2),0,1); - double[] actualParameters = helix.getPar(); - /* Closest approach is where we started so phi at PCA is same as phi at start. - * Note that d0 is negative. */ - assertHelixParametersEqual("",-0.1,0.25,PI/2,0,1,actualParameters); - /* Same starting position and direction, but negative particle. - * No change to d0, which is still negative. */ - helix = new AOldHelix(0.1f,0,0.25f,1,(float)(PI/2),0,-1); - actualParameters = helix.getPar(); - assertHelixParametersEqual("",-0.1,0.25,PI/2,0,-1,actualParameters); - /* - * Positive and negative particles, now starting in same direction (upwards) - * but from a starting position to the left of the beam. - * This time d0 is positive. - */ - helix = new AOldHelix(0.1f,(float)PI,0.25f,1,(float)(PI/2),0,1); - actualParameters = helix.getPar(); - assertHelixParametersEqual("",0.1,0.25,PI/2,0,1,actualParameters); - helix = new AOldHelix(0.1f,(float)PI,0.25f,1,(float)(PI/2),0,-1); - actualParameters = helix.getPar(); - assertHelixParametersEqual("",0.1,0.25,PI/2,0,-1,actualParameters); - } - - protected void assertHelixParametersEqual(String message, double d0, double z0, - double phi0, double tL, double ptInverse, double[] actualParameters) { - assertD0Equals(message,d0,actualParameters); - assertZ0Equals(message,z0,actualParameters); - assertPhi0Equals(message,phi0,actualParameters); - assertTLEquals(message,tL,actualParameters); - assertPtInverseEquals(message,ptInverse,actualParameters); - } - - protected void assertD0Equals(String message, double expected, double[] actualParameters) { - assertEquals(message+" Wrong d0.",expected,actualParameters[0],TOLERANCE); - } - - protected void assertZ0Equals(String message, double expected, double[] actualParameters) { - assertEquals(message+" Wrong z0.",expected,actualParameters[1],TOLERANCE); - } - - protected void assertPhi0Equals(String message, double expected, double[] actualParameters) { - assertEquals(message+" Wrong phi0.",expected,actualParameters[2],TOLERANCE); - } - - protected void assertTLEquals(String message, double expected, double[] actualParameters) { - assertEquals(message+" Wrong tL.",expected,actualParameters[3],TOLERANCE); - } - - protected void assertPtInverseEquals(String message, double expected, double[] actualParameters) { - assertEquals(message+" Wrong ptInverse.",expected,actualParameters[4],TOLERANCE); - } - -} diff --git a/graphics/AtlantisJava/test/src/atlantis/event/AEventInfoTest.java b/graphics/AtlantisJava/test/src/atlantis/event/AEventInfoTest.java deleted file mode 100644 index 8c541eecb5e7e68dd7e86f96c181583193d78bd7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/event/AEventInfoTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package atlantis.event; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class AEventInfoTest { - private static final long eventNumber=12345; - private static final long runNumber=123; - - @Test - public void testAEventInfoCreation() { - AEventInfo e = new AEventInfo(eventNumber,runNumber,"TIME","SOURCE","LUMIBLOCK","EVENTPROPERTIES"); - assertAEventInfo(e,eventNumber,runNumber,"TIME","SOURCE","LUMIBLOCK","EVENTPROPERTIES"); - } - - /** - * Create AEventInfo object with null or other special values for parameters. - */ - @Test - public void testAEventInfoCreationChecks() { - AEventInfo e1 = new AEventInfo(eventNumber,runNumber,null,null,null,null); - assertAEventInfo(e1,eventNumber,runNumber,"n/a","n/a","default","default"); - AEventInfo e2 = new AEventInfo(eventNumber,runNumber,null,null,"blah-1","blah-1"); - assertAEventInfo(e2,eventNumber,runNumber,"n/a","n/a","default","default"); - } - - @Test - public void testAEventCopyConstructor() { - AEventInfo e0 = new AEventInfo(eventNumber,runNumber,"TIME","SOURCE","LUMIBLOCK","EVENTPROPERTIES"); - AEventInfo e = new AEventInfo(e0); - assertAEventInfo(e,eventNumber,runNumber,"TIME","SOURCE","LUMIBLOCK","EVENTPROPERTIES"); - } - - @Test - public void testHashCode() { - // Check different run/event numbers give different hash codes - AEventInfo e1 = new AEventInfo(eventNumber,runNumber,"TIME","SOURCE","LUMIBLOCK","EVENTPROPERTIES"); - AEventInfo e2 = new AEventInfo(eventNumber+1,runNumber,"TIME","SOURCE","LUMIBLOCK","EVENTPROPERTIES"); - AEventInfo e3 = new AEventInfo(eventNumber,runNumber+1,"TIME","SOURCE","LUMIBLOCK","EVENTPROPERTIES"); - int h1 = e1.hashCode(); - int h2 = e2.hashCode(); - int h3 = e3.hashCode(); - assertTrue("hash codes should be different for e1,e2",h2!=h1); - assertTrue("hash codes should be different for e1,e3",h1!=h3); - assertTrue("hash codes should be different for e2,e3",h2!=h3); - } - - @Test - public void testEqualsAEventInfo() { - AEventInfo e1a = new AEventInfo(eventNumber,runNumber,"TIME","SOURCE","LUMIBLOCK","EVENTPROPERTIES"); - AEventInfo e1b = new AEventInfo(eventNumber,runNumber,"TIME","SOURCE","LUMIBLOCK","EVENTPROPERTIES"); - AEventInfo e2 = new AEventInfo(eventNumber+1,runNumber,"TIME","SOURCE","LUMIBLOCK","EVENTPROPERTIES"); - assertTrue("equals should return true for e1a,e1b",e1a.equals(e1b)); - assertFalse("equals should return false for e1a,e2",e1a.equals(e2)); - } - - /** Check values in AEventInfo object */ - private void assertAEventInfo(AEventInfo eventInfo, long event, long run, String time, String source, String lumiBlock, String eventProperties) { - assertEquals("event number not set correctly",event,eventInfo.getEventNumber()); - assertEquals("run number not set correctly",run,eventInfo.getRunNumber()); - assertEquals("time not set correctly",time,eventInfo.getDateTime()); - assertEquals("source not set correctly",source,eventInfo.getSourceName()); - assertEquals("source not set correctly",lumiBlock,eventInfo.getLumiBlock()); - assertEquals("event properties not set correctly",eventProperties,eventInfo.getEventProperties()); - } - -} diff --git a/graphics/AtlantisJava/test/src/atlantis/graphics/ACoordTest.java b/graphics/AtlantisJava/test/src/atlantis/graphics/ACoordTest.java deleted file mode 100644 index 24f5de94ef373256ef2719c055c2a0f677bd85b3..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/graphics/ACoordTest.java +++ /dev/null @@ -1,73 +0,0 @@ -package atlantis.graphics; - -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import atlantis.parameters.APar; -import static org.junit.Assert.*; - -public class ACoordTest { - private static final double TOLERANCE = 0.001; - - @BeforeClass - public static void setUpOnce() throws Exception { - APar.constructDummyForTesting(); - } - - @Test - public void constructACoordWithOnePoint() { - ACoord coord = new ACoord(0.0, 0.0, 0); - Point2D.Double point = new Point2D.Double(0.0,0.0); - assertContainsPoints(coord,point); - } - - @Test - public void constructACoordWithOneArrayOfPoints() { - double[] h = {0.0, 1.0, -1.0, 2.5}; - double[] v = {0.0, 0.0, 1.0, -2.5}; - ACoord coord = new ACoord(h,v); - Point2D.Double[] expectedPoints = createPointsArray(h,v); - assertContainsPoints(coord,expectedPoints); - } - - /** - * Currently just checks first set of points, i.e. x = hv[0][0][i], y = [1][0][i] - * @param coord - * @param points - */ - protected static void assertContainsPoints(ACoord coord, Point2D.Double... points) { - double[] x = coord.hv[0][0]; - double[] y = coord.hv[1][0]; - int xLen = x.length; - int yLen = y.length; - assertTrue(String.format( - "Numbers of x and y coordinates are not equal: %d, %d",xLen,yLen), - xLen==yLen); - assertTrue(String.format( - "Wrong number of points: expected %d, found %d",points.length,xLen), - points.length==xLen); - int i=0; - for (Point2D.Double point : points) { - Point2D.Double hvPoint = new Point2D.Double(x[i],y[i]); - double distance = hvPoint.distance(point); - if (distance>TOLERANCE) { - fail(String.format("Didn't find expected points. First difference is point %d: expected (%f,%f), found (%f,%f)", - i,point.x,point.y,hvPoint.x,hvPoint.y)); - } - i++; - } - } - - private Point2D.Double[] createPointsArray(double[] x, double[] y) { - Point2D.Double[] points = new Point2D.Double[x.length]; - for (int i=0; i<x.length; i++) { - points[i] = new Point2D.Double(x[i], y[i]); - } - return points; - } -} diff --git a/graphics/AtlantisJava/test/src/atlantis/list/AListManagerTest.java b/graphics/AtlantisJava/test/src/atlantis/list/AListManagerTest.java deleted file mode 100644 index 3b2e70bd5bff73a5d14fc4b20177eab5a6343fcc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/list/AListManagerTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package atlantis.list; - -import static org.junit.Assert.*; - -import org.junit.Test; - -import atlantis.utils.A4Vector; - -public class AListManagerTest { - private static final double TOLERANCE = 0.00001; - - @Test - public void testTotalEt() { - Summarizer summ = new Summarizer(); - A4Vector pos = new A4Vector(3.0,0,0,4.0); - String posDescription = "A positive 4vector"; - A4Vector neg = new A4Vector(-3.0,0,0,4.0); - String negDescription = "A negative 4vector"; - summ.addAndGetInfo(pos, posDescription); - summ.addAndGetInfo(neg, negDescription); - double totalEt = summ.getTotalEt(); - assertEquals(totalEt,10.0,TOLERANCE); - } - - @Test - public void testTotalPt() { - Summarizer summ = new Summarizer(); - A4Vector pos = new A4Vector(3.0,0,0,4.0); - String posDescription = "A positive 4vector"; - A4Vector neg = new A4Vector(-3.0,0,0,4.0); - String negDescription = "A negative 4vector"; - summ.addAndGetInfo(pos, posDescription); - summ.addAndGetInfo(neg, negDescription); - double totalPt = summ.getTotalPt(); - assertEquals(totalPt,0.0,TOLERANCE); - } - - @Test - public void testTotalMt() { - Summarizer summ = new Summarizer(); - A4Vector pos = new A4Vector(3.0,0,0,4.0); - String posDescription = "A positive 4vector"; - A4Vector neg = new A4Vector(-3.0,0,0,4.0); - String negDescription = "A negative 4vector"; - summ.addAndGetInfo(pos, posDescription); - summ.addAndGetInfo(neg, negDescription); - double totalMt = summ.getTotalMt(); - assertEquals(totalMt,10.0,TOLERANCE); - } - -} diff --git a/graphics/AtlantisJava/test/src/atlantis/parameters/AAbstractParameterTest.java b/graphics/AtlantisJava/test/src/atlantis/parameters/AAbstractParameterTest.java deleted file mode 100644 index c2df08a2a5549eb7745e91038f7022db0a4991cc..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/parameters/AAbstractParameterTest.java +++ /dev/null @@ -1,120 +0,0 @@ -package atlantis.parameters; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; - -import testutils.AtlantisInit; - -import atlantis.canvas.ACanvas; - -/** - * Tests for AAbstractParameter. - * @author waugh - * - */ -public class AAbstractParameterTest { - /** Arbitrary tolerance for floating-point comparisons */ - private static final double TOLERANCE = 0.00001; - - private AAbstractParameter parameter; - - @Before - public void setUp() throws Exception { - AtlantisInit.init(); - APar.constructDummyForTesting(); - ACanvas.constructDummyForTesting(); - parameter = new AAbstractParameter("name", "screen name", null, 0, 0, null, null, false, false, false, 0, 0, 0) { - {wCount = 1; data = new AParameterData(wCount);} - public void setD(double v) {} - public void setI(int v) {} - public void refresh() {} - }; - } - - @Test - public void testAAbstractParameter() { - assertNotNull(parameter); - } - - @Test - public void testSaveAndRestoreDefaults() { - // Access member variables directly since set and other methods rely on - // information about existing windows. Rely on uninitialized - // APar.currentIndex being zero. - - // Set value, status etc. - parameter.valueType = AAbstractParameter.FLOAT; - parameter.data.setValue(1.0); - parameter.data.setStatus(false); - parameter.data.setOperator(""); - parameter.range = AAbstractParameter.resolvePossibleValues("0:10", AAbstractParameter.FLOAT); - parameter._setD(1.0); - parameter.hasStatus = true; - parameter.setStatus(true); - parameter._setOperator("A"); // no restriction on value of operator? - parameter.setScope(AAbstractParameter.LOCAL); - // Save current settings as defaults then change them - parameter.saveDefaults(); - parameter._setD(2.0); - parameter.setStatus(false); - parameter._setOperator("B"); - parameter.setScope(AAbstractParameter.GLOBAL); - // Make sure the current settings have changed - double value = parameter.getD(); - boolean status = parameter.getStatus(); - String operator = parameter.getOperator(); - int scope = parameter.getScope(); - assertEquals("parameter value not changed from default",2.0,value,TOLERANCE); - assertEquals("parameter status not changed from default",false,status); - assertEquals("parameter operator not changed from default","B",operator); - assertEquals("parameter scope not changed from default",AAbstractParameter.GLOBAL,scope); - // Then restore defaults and verify the original settings are back - parameter.restoreDefaults(); - double restoredValue = parameter.getD(); - boolean restoredStatus = parameter.getStatus(); - String restoredOperator = parameter.getOperator(); - int restoredScope = parameter.getScope(); - assertEquals("parameter value not set to default",1.0,restoredValue,TOLERANCE); - assertEquals("parameter status not set to default",true,restoredStatus); - assertEquals("parameter operator not set to default","A",restoredOperator); - assertEquals("parameter scope not set to default",AAbstractParameter.LOCAL,restoredScope); - } - - @Test - public void testPossibleValuesFloat() { - parameter.valueType = AAbstractParameter.FLOAT; - String possibleValues = "1.0:2.0,3.0:4.5"; - parameter.range = AAbstractParameter.resolvePossibleValues(possibleValues, AAbstractParameter.FLOAT); - assertValidValue(parameter,possibleValues,1.2); - assertValidValue(parameter,possibleValues,4.4); - assertInvalidValue(parameter,possibleValues,0.9); - assertInvalidValue(parameter,possibleValues,2.1); - assertInvalidValue(parameter,possibleValues,9.9); - assertInvalidValue(parameter,possibleValues,-1.2); - } - - @Test - public void testPossibleValuesInt() { - parameter.valueType = AAbstractParameter.INT; - String possibleValues = "1,2,4"; - parameter.range = AAbstractParameter.resolvePossibleValues(possibleValues, AAbstractParameter.FLOAT); - assertValidValue(parameter,possibleValues,1); - assertValidValue(parameter,possibleValues,2); - assertValidValue(parameter,possibleValues,4); - assertInvalidValue(parameter,possibleValues,3); - assertInvalidValue(parameter,possibleValues,-1); - } - - private static void assertValidValue(AAbstractParameter parameter, String possibleValues, double value) { - boolean validated = parameter.validateValue(value); - assertTrue(String.format("Value %f incorrectly fails validation with possible values %s",value,possibleValues),validated); - } - - private static void assertInvalidValue(AAbstractParameter parameter, String possibleValues, double value) { - boolean validated = parameter.validateValue(value); - assertFalse(String.format("Value %f incorrectly passes validation with possible values %s",value,possibleValues),validated); - } - -} diff --git a/graphics/AtlantisJava/test/src/atlantis/parameters/AParameterDataTest.java b/graphics/AtlantisJava/test/src/atlantis/parameters/AParameterDataTest.java deleted file mode 100644 index afab7d5293af259ec665421c4f7f4f5e3c3994eb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/parameters/AParameterDataTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package atlantis.parameters; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * We don't test the methods that call APar to find out the current window, - * which is not defined in unit tests. - * - * @author waugh - * - */ -public class AParameterDataTest { - private static final int numWindows = 3; - private static final double TOLERANCE = 0.001; - - private AParameterData paramData; - - @Before - public void setUp() { - APar.constructDummyForTesting(); - paramData = new AParameterData(numWindows); - } - - @Test - /** - * Check default values for all windows. - */ - public void constructDefault() { - for (int iWindow=0; iWindow<numWindows; ++iWindow) { - AParameterState state = paramData.getState(iWindow); - assertValuesEqual("Default state is wrong.",0.0,false,"",state); - } - } - - @Test - /** - * Copy values from window 1 to window 2. - */ - public void copyValues() { - paramData.setValue(1, 1.0); - paramData.setStatus(1, true); - paramData.setOperator(1, "+"); - paramData.copy(1, 2); - AParameterState state = paramData.getState(2); - assertValuesEqual("Copied state is wrong.",1.0,true,"+",state); - } - - @Test - public void saveAndRestoreValues() { - paramData.setValue(1, 1.0); - paramData.setStatus(1, true); - paramData.setOperator(1, "+"); - paramData.saveDefaults(); - paramData.setValue(1, 2.0); - paramData.setStatus(1, false); - paramData.setOperator(1, "-"); - AParameterState state = paramData.getState(1); - assertValuesEqual("Set state is wrong.",2.0,false,"-",state); - paramData.restoreDefaults(); - state = paramData.getState(1); - assertValuesEqual("Restored state is wrong.",1.0,true,"+",state); - } - - @Test - public void testGlobalize() { - paramData.setValue(1, 1.0); - paramData.setStatus(1, true); - paramData.setOperator(1, "+"); - paramData.globalize(1); - for (int iWindow=0; iWindow<numWindows; ++iWindow) { - AParameterState state = paramData.getState(iWindow); - assertValuesEqual("State wrong after globalization.",1.0,true,"+",state); - } - } - - private static void assertValuesEqual(String message, double value, boolean status, String operator, AParameterState actual) { - assertEquals(message+" Wrong value.",value,actual.value,TOLERANCE); - assertEquals(message+" Wrong status.",status,actual.status); - assertEquals(message+" Wrong operator.",operator,actual.operator); - } -} diff --git a/graphics/AtlantisJava/test/src/atlantis/utils/A3VectorTest.java b/graphics/AtlantisJava/test/src/atlantis/utils/A3VectorTest.java deleted file mode 100644 index 0b88546b31d61ad6cd035517ede778867ae2f963..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/utils/A3VectorTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package atlantis.utils; - -import static org.junit.Assert.*; - -import org.junit.Test; - -/** - * Tests for A3Vector class. Initial rather clumsy implementation just to get started. - * @author waugh - * - */ -public class A3VectorTest { - /** Arbitrary tolerance for floating-point comparisons */ - private static final double TOLERANCE = 0.00001; - - @Test - public void testA3Vector() { - A3Vector v = new A3Vector(); - assertA3VectorEquals("three-vector",0.0,0.0,0.0,v,TOLERANCE); - } - - @Test - public void testA3VectorDoubleDoubleDouble() { - A3Vector v = new A3Vector(1.0,-2.5,3.3); - assertA3VectorEquals("three-vector",1.0,-2.5,3.3,v,TOLERANCE); - } - - @Test - public void testFromEtaPhiR() { - A3Vector v = A3Vector.fromEtaPhiR(0.0, Math.PI, 2.0); - assertA3VectorEquals("three-vector",-2.0,0.0,0.0,v,TOLERANCE); - } - - @Test - public void testFromRhoPhiZ() { - A3Vector v = A3Vector.fromRhoPhiZ(1.0, Math.PI, 1.0); - assertA3VectorEquals("three-vector",-1.0,0.0,1.0,v,TOLERANCE); - } - - @Test - public void testGetNormalized() { - A3Vector v0 = new A3Vector(1.0,1.0,1.0); - double a = 1 / Math.sqrt(3); - A3Vector v = v0.getNormalized(); - assertA3VectorEquals("three-vector",a,a,a,v,TOLERANCE); - } - - @Test - public void testNormalize() { - A3Vector v = new A3Vector(1.0,1.0,1.0); - v.normalize(); - double a = 1 / Math.sqrt(3); - assertA3VectorEquals("three-vector",a,a,a,v,TOLERANCE); - } - - @Test - public void testMagnitude() { - A3Vector v = new A3Vector(1.0,1.0,1.0); - double r = v.magnitude(); - double rExpected = Math.sqrt(3); - assertEquals("magnitude calculation",rExpected,r,TOLERANCE); - } - - @Test - public void testScale() { - A3Vector v = new A3Vector(1.0,1.0,1.0); - v.scale(0.5); - assertA3VectorEquals("three-vector",0.5,0.5,0.5,v,TOLERANCE); - } - - @Test - public void testAdd() { - A3Vector v = new A3Vector(1.0,2.0,3.0); - A3Vector v0 = new A3Vector(0.0,1.0,-0.5); - v.add(v0); - assertA3VectorEquals("three-vector",1.0,3.0,2.5,v,TOLERANCE); - } - - @Test - public void testSubtract() { - A3Vector v = new A3Vector(1.0,2.0,3.0); - A3Vector v0 = new A3Vector(0.0,1.0,-0.5); - v.subtract(v0); - assertA3VectorEquals("three-vector",1.0,1.0,3.5,v,TOLERANCE); - } - - /** - * Check given A3Vector has expected components - */ - private static void assertA3VectorEquals(String message, double x, double y, double z, - A3Vector v, double delta) { - if (Math.abs(v.x-x)>delta || Math.abs(v.y-y)>delta || - Math.abs(v.z-z)>delta) { - String vExpected = String.format("<%f,%f,%f>", x,y,z); - String vActual = String.format("<%f,%f,%f>", v.x,v.y,v.z); - String summary = message+" "+ - "expected:"+vExpected+" but was:"+vActual; - fail(summary); - } - } -} diff --git a/graphics/AtlantisJava/test/src/atlantis/utils/A4VectorTest.java b/graphics/AtlantisJava/test/src/atlantis/utils/A4VectorTest.java deleted file mode 100644 index 03fb94f20012f9fbb90643847f552b44980a181e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/utils/A4VectorTest.java +++ /dev/null @@ -1,128 +0,0 @@ -package atlantis.utils; - - -import static org.junit.Assert.*; - -import org.junit.Test; - -/** - * Tests for A4Vector class. - */ -public class A4VectorTest { - /** Arbitrary tolerance for floating-point comparisons */ - private static final double TOLERANCE = 0.00001; - - @Test - public void testA4Vector() { - A4Vector v = new A4Vector(); - assertA4VectorEquals("construct zero 4-vector",0.0,0.0,0.0,0.0,v,TOLERANCE); - } - - @Test - public void testA4VectorDoubleDoubleDoubleDouble() { - // fourth argument is mass, not energy - // use 3-4-5 numbers for simple arithmetic - A4Vector v = new A4Vector(2.0,2.0,-1.0,4.0); - assertA4VectorEquals("construct 4-vector",2.0,2.0,-1.0,5.0,v,TOLERANCE); - } - - @Test - public void testA4VectorA3VectorDouble() { - A3Vector v3 = new A3Vector(2.0,2.0,-1.0); - A4Vector v = new A4Vector(v3,4.0); - assertA4VectorEquals("construct 4-vector",2.0,2.0,-1.0,5.0,v,TOLERANCE); - } - - @Test - public void testSet() { - A4Vector v = new A4Vector(); - v.set(2.0,2.0,-1.0,4.0); - assertA4VectorEquals("set 4-vector",2.0,2.0,-1.0,5.0,v,TOLERANCE); - } - - @Test - public void testSetPtEtaPhiM() { - A4Vector v1 = new A4Vector(); - v1.setPtEtaPhiM(1.0, 0.0, 0.0, 0.0); - assertA4VectorEquals("set 4-vector",1.0,0.0,0.0,1.0,v1,TOLERANCE); - // test with negative pT - A4Vector v2 = new A4Vector(); - v2.setPtEtaPhiM(-1.0, 0.0, 0.0, 0.0); - assertA4VectorEquals("set 4-vector",1.0,0.0,0.0,1.0,v2,TOLERANCE); - } - - @Test - public void testGetP() { - A4Vector v = new A4Vector(2.0,2.0,-1.0,4.0); - double p = v.getP(); - assertEquals(3.0,p,TOLERANCE); - } - - @Test - public void testGetPt() { - A4Vector v = new A4Vector(0.3,0.4,-1.0,4.0); - double pt = v.getPt(); - assertEquals(0.5,pt,TOLERANCE); - } - - @Test - public void testGetE() { - A4Vector v = new A4Vector(2.0,2.0,-1.0,4.0); - double e = v.getE(); - assertEquals(5.0,e,TOLERANCE); - } - - @Test - public void testgetEt() { - A4Vector v = new A4Vector(1.0,1.0,2.0,3.0); - double et = v.getEt(); - double x = Math.sqrt(5.0); - assertEquals(x,et,TOLERANCE); - } - - @Test - public void testGetMass() { - A4Vector v = new A4Vector(2.0,2.0,-1.0,4.0); - double m = v.getMass(); - assertEquals(4.0,m,TOLERANCE); - } - - @Test - public void testGetMt() { - A4Vector v = new A4Vector(1.0,1.0,2.0,3.0); - double mt = v.getMt(); - double x = Math.sqrt(3.0); - assertEquals(x,mt,TOLERANCE); - } - - @Test - public void testAddDoubleDoubleDoubleDouble() { - A4Vector v = new A4Vector(2.0,2.0,-1.0,4.0); - v.add(2.2,2.2,-1.1,4.4); - assertA4VectorEquals("add 4-vectors",4.2,4.2,-2.1,10.5,v,TOLERANCE); - } - - @Test - public void testAddA4Vector() { - A4Vector v = new A4Vector(2.0,2.0,-1.0,4.0); - A4Vector v2 = new A4Vector(2.2,2.2,-1.1,4.4); - v.add(v2); - assertA4VectorEquals("add 4-vectors",4.2,4.2,-2.1,10.5,v,TOLERANCE); - } - - /** - * Check given A4Vector has expected components - */ - private static void assertA4VectorEquals(String message, double px, double py, double pz, double e, - A4Vector v, double delta) { - if (Math.abs(v.px-px)>delta || Math.abs(v.py-py)>delta || - Math.abs(v.pz-pz)>delta || Math.abs(v.e-e)>delta) { - String vExpected = String.format("<%f,%f,%f,%f>", px,py,pz,e); - String vActual = String.format("<%f,%f,%f,%f>", v.px,v.py,v.pz,v.e); - String summary = message+" "+ - "expected:"+vExpected+" but was:"+vActual; - fail(summary); - } - } - -} diff --git a/graphics/AtlantisJava/test/src/atlantis/utils/AIdRangeTest.java b/graphics/AtlantisJava/test/src/atlantis/utils/AIdRangeTest.java deleted file mode 100644 index cae60427953a6e7adbe00ca1a892a05251a32eca..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/utils/AIdRangeTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package atlantis.utils; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -/** - * Test for the IdHelper range class used to represent - * possible values of an identifier field. - * - * @author Eric Jansen - */ -public class AIdRangeTest { - - public AIdRangeTest() {} - - @Test - public void testEmptyRange() throws Exception { - AIdRange a = new AIdRange(); - AIdRange b = new AIdRange(new int[] {1, 2}); - - a.add(b); - assertEquals(a, b); - - b.add(a); - assertEquals(a, b); - } - - @Test - public void testContainsRange() throws Exception { - AIdRange a = new AIdRange(1, 3); - AIdRange b = new AIdRange(new int[] {1, 2, 4}); - AIdRange c = new AIdRange(1, 2); - - assert(a.contains(c)); - assert(b.contains(c)); - assert(!a.contains(b)); - assert(!b.contains(a)); - } - - @Test - public void testContainsValue() throws Exception { - AIdRange a = new AIdRange(-5, 5); - AIdRange b = new AIdRange(new int[] {-1, 3, 9}); - - assert(!a.contains(-6)); - assert(a.contains(-5)); - assert(a.contains(2)); - assert(a.contains(5)); - assert(!a.contains(6)); - - assert(b.contains(-1)); - assert(!b.contains(2)); - assert(b.contains(3)); - assert(b.contains(9)); - } - - @Test - public void testAddRange() throws Exception { - AIdRange a = new AIdRange(new int[] {-1, 0, 1, 2, 5, 6}); - AIdRange b = new AIdRange(new int[] {-1, 1, 2, 6}); - AIdRange c = new AIdRange(new int[] {0, 1, 2, 5}); - - b.add(c); - assert(a.equals(b)); - - AIdRange d = new AIdRange(-5, 5); - AIdRange e = new AIdRange(new int[] {-5, -4}); - AIdRange f = new AIdRange(-3, 5); - - e.add(f); - assert(d.equals(e)); - - AIdRange g = new AIdRange(0, 2); - AIdRange h = new AIdRange(new int[] {0, 1}); - AIdRange i = new AIdRange(new int[] {1, 2}); - - h.add(i); - assert(g.equals(h)); // comparing [ 0 -> 2 ] to [ 0 1 2 ] - } - - @Test - public void testToString() throws Exception { - AIdRange a = new AIdRange(-2, 15); - AIdRange b = new AIdRange(new int[] {2, 3, 5}); - AIdRange c = new AIdRange(); - assertEquals("[ -2 -> 15 ]", a.toString()); - assertEquals("[ 2 3 5 ]", b.toString()); - assertEquals("[ ]", c.toString()); - } -} diff --git a/graphics/AtlantisJava/test/src/atlantis/utils/AMathTest.java b/graphics/AtlantisJava/test/src/atlantis/utils/AMathTest.java deleted file mode 100644 index 8bb888866ac95b98c92122faadfeaafbe8d95fdb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/utils/AMathTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * - */ -package atlantis.utils; - -import static org.junit.Assert.*; -import org.junit.Test; - -import static java.lang.Math.PI; - -/** - * @author waugh - * - */ -public class AMathTest { - /** Arbitrary tolerance for floating-point comparisons */ - private static final double TOLERANCE = 0.00001; - - /** - * Test method for {@link atlantis.utils.AMath#nearestPhiDegrees(double)}. - */ - @Test - public void testNearestPhiDegreesDouble() { - assertEquals("Wrong value for phi",0.,AMath.nearestPhiDegrees(0.),TOLERANCE); - assertEquals("Wrong value for phi",0.,AMath.nearestPhiDegrees(360.),TOLERANCE); - assertEquals("Wrong value for phi",180.,AMath.nearestPhiDegrees(180.),TOLERANCE); - assertEquals("Wrong value for phi",1.,AMath.nearestPhiDegrees(1.),TOLERANCE); - assertEquals("Wrong value for phi",359.,AMath.nearestPhiDegrees(-1.),TOLERANCE); - } - - /** - * Test method for {@link atlantis.utils.AMath#nearestPhiRadians(double)}. - */ - @Test - public void testNearestPhiRadiansDouble() { - assertEquals("Wrong value for phi",0.,AMath.nearestPhiRadians(0.),TOLERANCE); - assertEquals("Wrong value for phi",0.,AMath.nearestPhiRadians(2*PI),TOLERANCE); - assertEquals("Wrong value for phi",PI,AMath.nearestPhiRadians(PI),TOLERANCE); - assertEquals("Wrong value for phi",0.1,AMath.nearestPhiRadians(0.1),TOLERANCE); - assertEquals("Wrong value for phi",2*PI-0.1,AMath.nearestPhiRadians(-0.1),TOLERANCE); - } - - /** - * Test method for {@link atlantis.utils.AMath#nearestPhiDegrees(double, double)}. - */ - @Test - public void testNearestPhiDegreesDoubleDouble() { - double phiMid = 360; // range [180,540) - assertEquals("Wrong value for phi",180.,AMath.nearestPhiDegrees(180.0,phiMid),TOLERANCE); - assertEquals("Wrong value for phi",180.,AMath.nearestPhiDegrees(540.0,phiMid),TOLERANCE); - assertEquals("Wrong value for phi",360.,AMath.nearestPhiDegrees(360.0,phiMid),TOLERANCE); - assertEquals("Wrong value for phi",361.,AMath.nearestPhiDegrees(1.0,phiMid),TOLERANCE); - assertEquals("Wrong value for phi",539.,AMath.nearestPhiDegrees(179.0,phiMid),TOLERANCE); - } - - /** - * Test method for {@link atlantis.utils.AMath#nearestPhiRadians(double, double)}. - */ - @Test - public void testNearestPhiRadiansDoubleDouble() { - double phiMid = 2*PI; // range [180,540) - assertEquals("Wrong value for phi",PI,AMath.nearestPhiRadians(PI,phiMid),TOLERANCE); - assertEquals("Wrong value for phi",PI,AMath.nearestPhiRadians(PI,phiMid),TOLERANCE); - assertEquals("Wrong value for phi",2*PI,AMath.nearestPhiRadians(2*PI,phiMid),TOLERANCE); - assertEquals("Wrong value for phi",2*PI+0.1,AMath.nearestPhiRadians(0.1,phiMid),TOLERANCE); - assertEquals("Wrong value for phi",3*PI-0.1,AMath.nearestPhiRadians(PI-0.1,phiMid),TOLERANCE); - } - -} diff --git a/graphics/AtlantisJava/test/src/atlantis/utils/ANewIdHelperTest.java b/graphics/AtlantisJava/test/src/atlantis/utils/ANewIdHelperTest.java deleted file mode 100644 index bad4515a8e3ea379c5ab544684da422c2492ccf7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/atlantis/utils/ANewIdHelperTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package atlantis.utils; - -import atlantis.globals.AGlobals; -import atlantis.utils.xml.AXMLErrorHandler; -import java.io.InputStream; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import org.junit.BeforeClass; -import org.junit.Test; -import org.w3c.dom.Document; -import testutils.AtlantisInit; - -/** - * Tests for the ANewIdHelper class. Tests are performed by fully - * decoding compact identifiers of several subsystems. - * - * @author Eric Jansen - */ -public class ANewIdHelperTest { - - public ANewIdHelperTest() {} - - @BeforeClass - public static void setUpClass() throws Exception { - AtlantisInit.init(); - String geometryBase = AGlobals.instance().getHomeDirectory() + "geometry/"; - InputStream isIdDict = AUtilities.getFileAsStream(geometryBase + "ATLAS_IDS.xml"); - - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setValidating(true); - DocumentBuilder parser = factory.newDocumentBuilder(); - parser.setErrorHandler(new AXMLErrorHandler()); - - Document xmlDictDoc = parser.parse(isIdDict, geometryBase); - ANewIdHelper.construct(xmlDictDoc.getDocumentElement()); - - System.out.println("The loaded identifier structure is:\n" - + ANewIdHelper.instance().getDictionary("ATLAS")); - } - - @Test - public void testPixel() throws Exception { - ANewIdHelper idHelper = ANewIdHelper.instance(); - assertEquals("InnerDetector/Pixel/negative_endcap/0/15/0/86/76", idHelper.getFullIdentifier(8661285809946624l)); - } - - @Test - public void testSCT() throws Exception { - ANewIdHelper idHelper = ANewIdHelper.instance(); - assertEquals("InnerDetector/SCT/negative_endcap/1/23/2/0/683", idHelper.getFullIdentifier(137085611)); - assertEquals("InnerDetector/SCT/positive_endcap/8/50/0/1/609", idHelper.getFullIdentifier(219756129)); - } - - @Test - public void testTRT() throws Exception { - ANewIdHelper idHelper = ANewIdHelper.instance(); - assertEquals("InnerDetector/TRT/negative_endcap/2/2/6/7", idHelper.getFullIdentifier(270604512)); - assertEquals("InnerDetector/TRT/negative_endcap/11/1/7/9", idHelper.getFullIdentifier(280010016)); - assertEquals("InnerDetector/TRT/negative_barrel/9/0/18/7", idHelper.getFullIdentifier(311445728)); - assertEquals("InnerDetector/TRT/positive_barrel/5/2/22/10", idHelper.getFullIdentifier(340875584)); - assertEquals("InnerDetector/TRT/positive_endcap/7/10/1/13", idHelper.getFullIdentifier(376767904)); - assertEquals("InnerDetector/TRT/positive_endcap/31/13/7/18", idHelper.getFullIdentifier(402038336)); - } - - @Test - public void testLAr() throws Exception { - ANewIdHelper idHelper = ANewIdHelper.instance(); - assertEquals("LArCalorimeter/LArEM/negative-endcap-outer-wheel/2/1/37/72", idHelper.getFullIdentifier(3225785215439863808l)); - assertEquals("LArCalorimeter/LArEM/positive-barrel/1/0/167/15", idHelper.getFullIdentifier(765546014)); - assertEquals("LArCalorimeter/LArEM/negative-barrel/2/0/4/113", idHelper.getFullIdentifier(759171298)); - } - - @Test - public void testTILE() throws Exception { - ANewIdHelper idHelper = ANewIdHelper.instance(); - assertEquals("TileCalorimeter/Barrel/positive/28/0/1/0/0", idHelper.getFullIdentifier(1149698064)); - assertEquals("TileCalorimeter/Extended-barrel/negative/0/14/0/0/0", idHelper.getFullIdentifier(1207963136)); - } - - @Test - public void testHEC() throws Exception { - ANewIdHelper idHelper = ANewIdHelper.instance(); - assertEquals("LArCalorimeter/LArHEC/negative-endcap-outer-wheel/1/0/5/22", idHelper.getFullIdentifier(815095808)); - assertEquals("LArCalorimeter/LArHEC/negative-endcap-outer-wheel/2/0/6/22", idHelper.getFullIdentifier(823746560)); - assertEquals("LArCalorimeter/LArHEC/positive-endcap-outer-wheel/2/1/2/20", idHelper.getFullIdentifier(860438528)); - assertEquals("LArCalorimeter/LArHEC/positive-endcap-outer-wheel/3/0/8/0", idHelper.getFullIdentifier(866123776)); - assertEquals("LArCalorimeter/LArHEC/positive-endcap-outer-wheel/3/1/3/29", idHelper.getFullIdentifier(869126144)); - } - - @Test - public void testFCAL() throws Exception { - ANewIdHelper idHelper = ANewIdHelper.instance(); - assertEquals("LArCalorimeter/LArFCAL/negative-endcap-outer-wheel/1/4/13", idHelper.getFullIdentifier(873046016)); - assertEquals("LArCalorimeter/LArFCAL/negative-endcap-outer-wheel/1/45/0", idHelper.getFullIdentifier(878313472)); - assertEquals("LArCalorimeter/LArFCAL/positive-endcap-outer-wheel/1/3/0", idHelper.getFullIdentifier(906362880)); - assertEquals("LArCalorimeter/LArFCAL/positive-endcap-outer-wheel/2/23/14", idHelper.getFullIdentifier(917487616)); - assertEquals("LArCalorimeter/LArFCAL/positive-endcap-outer-wheel/3/15/15", idHelper.getFullIdentifier(924835840)); - } - - @Test - public void testMDT() throws Exception { - ANewIdHelper idHelper = ANewIdHelper.instance(); - assertEquals("MuonSpectrometer/BIL/-6/1/MDT/1/3/1", idHelper.getFullIdentifier(6922067811640541184l)); - assertEquals("MuonSpectrometer/BIL/-6/2/MDT/2/2/34", idHelper.getFullIdentifier(1611748384)); - assertEquals("MuonSpectrometer/BIL/1/5/MDT/1/2/3", idHelper.getFullIdentifier(1615597632)); - assertEquals("MuonSpectrometer/BOL/1/5/MDT/1/2/7", idHelper.getFullIdentifier(1682706624)); - assertEquals("MuonSpectrometer/EOL/2/3/MDT/2/1/6", idHelper.getFullIdentifier(1884438688)); - assertEquals("MuonSpectrometer/EIS/-1/6/MDT/2/3/36", idHelper.getFullIdentifier(2050843744)); - } - - @Test - public void testRPC() throws Exception { - ANewIdHelper idHelper = ANewIdHelper.instance(); - assertEquals("MuonSpectrometer/BML/-6/6/RPC/1/2/2/2/0/4", idHelper.getFullIdentifier(1645583372)); - } - - @Test - public void testCSC() throws Exception { - ANewIdHelper idHelper = ANewIdHelper.instance(); - assertEquals("MuonSpectrometer/CSS/-1/1/CSC/2/4/0/6", idHelper.getFullIdentifier(2064056960)); - } - - @Test - public void testTGC() throws Exception { - ANewIdHelper idHelper = ANewIdHelper.instance(); - assertEquals("MuonSpectrometer/T4E/1/10/TGC/2/1/15", idHelper.getFullIdentifier(2035436656)); - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/AAssert.java b/graphics/AtlantisJava/test/src/guitest/AAssert.java deleted file mode 100644 index 0010a9594878a0770ef25b8f095132acbe20e9a6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/AAssert.java +++ /dev/null @@ -1,28 +0,0 @@ -package guitest; - -import static org.junit.Assert.*; - -import java.util.Arrays; - -/** - * Useful assertion methods for tests. - * @author waugh - * - */ -public class AAssert { - public static void assertArrayEqualsIgnoreOrder(String message, - Object[] expecteds, Object[] actuals) { - int lengthExp = expecteds.length; - int lengthAct = actuals.length; - if (lengthAct!=lengthExp) fail(message+ - ": array lengths differed, "+ - String.format("expected.length=%d,actual.length=%d",lengthExp,lengthAct)); - Object[] copyExpecteds = new Object[lengthExp]; - System.arraycopy(expecteds,0,copyExpecteds,0,lengthExp); - Object[] copyActuals = new Object[lengthAct]; - System.arraycopy(actuals,0,copyActuals,0,lengthAct); - Arrays.sort(copyExpecteds); - Arrays.sort(copyActuals); - assertArrayEquals(message,copyExpecteds,copyActuals); - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/AtlantisGUIFixture.java b/graphics/AtlantisJava/test/src/guitest/AtlantisGUIFixture.java deleted file mode 100644 index 5d49d4fae4e9e43d47d1d0a80999eb71c1661305..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/AtlantisGUIFixture.java +++ /dev/null @@ -1,141 +0,0 @@ -package guitest; - -import java.awt.Dialog; -import java.io.File; - -import org.fest.swing.core.BasicComponentFinder; -import org.fest.swing.core.ComponentFinder; -import org.fest.swing.core.ComponentFoundCondition; -import org.fest.swing.core.Robot; -import org.fest.swing.core.matcher.DialogMatcher; -import org.fest.swing.core.matcher.FrameMatcher; -import org.fest.swing.core.matcher.JButtonMatcher; -import org.fest.swing.data.TableCell; -import org.fest.swing.data.TableCellByColumnId; -import org.fest.swing.exception.ComponentLookupException; -import org.fest.swing.fixture.DialogFixture; -import org.fest.swing.fixture.FrameFixture; -import org.fest.swing.fixture.JButtonFixture; -import org.fest.swing.fixture.JFileChooserFixture; -import org.fest.swing.fixture.JTabbedPaneFixture; -import org.fest.swing.fixture.JTableCellFixture; -import org.fest.swing.fixture.JTableFixture; -import org.fest.swing.fixture.JToolBarFixture; -import org.fest.swing.timing.Pause; - -import static org.junit.Assert.*; - -import atlantis.gui.AGUI; - -/** - * Fixture for testing the Atlantis GUI (class AGUI). - * @author waugh - * - */ -public class AtlantisGUIFixture extends FrameFixture { - private Robot robot; - private ComponentFinder finder; - private FrameFixture guiFixture; - - /** - * Construct and return AtlantisGUIFixture using specified robot. - * @param robot the robot to use - * @return fixture for the Atlantis GUI - */ - public static AtlantisGUIFixture getFixture(Robot robot) { - ComponentFinder finder = BasicComponentFinder.finderWithCurrentAwtHierarchy(); - FrameMatcher matcherGuiTitle = FrameMatcher.withTitle("Atlantis GUI"); - ComponentFoundCondition guiFound = new ComponentFoundCondition("Atlantis GUI found", - finder, matcherGuiTitle); - Pause.pause(guiFound,30000); - AGUI gui = (AGUI) guiFound.found(); - return new AtlantisGUIFixture(robot,gui); - } - - /** - * Construct AtlantisGUIFixture. - * @param robot - */ - public AtlantisGUIFixture(Robot robot, AGUI gui) { - super(robot,gui); - this.robot = robot; - this.finder = BasicComponentFinder.finderWithCurrentAwtHierarchy(); - this.guiFixture = new FrameFixture(robot,gui); - } - - /** Find AParametersTable for given supergroup and group */ - protected JTableFixture findParametersTable(String superGroup, String group) { - JTabbedPaneFixture tabs = guiFixture.tabbedPane("parameterGroups"); - tabs.selectTab(superGroup); - JTabbedPaneFixture subTabs = guiFixture.tabbedPane(superGroup); - subTabs.selectTab(group); - JTableFixture parametersTable = guiFixture.table(group); - return parametersTable; - } - - /** - * Find table cell containing given parameter. - * @param superGroup - * @param group - * @param parameter - * @return - */ - protected JTableCellFixture findParameterCell(String superGroup, String group, String parameter) { - JTableFixture table = findParametersTable(superGroup,group); - TableCell cellName = table.cell(parameter); - int row = cellName.row; // Row containing cell with specified name - JTableCellFixture cellValue = table.cell(TableCellByColumnId.row(row).columnId("Value")); - return cellValue; - } - - /** Find button in GUI with given text */ - protected JButtonFixture findGuiButton(String text) { - JButtonMatcher matcher = JButtonMatcher.withText(text); - return guiFixture.button(matcher); - } - - /** - * Open file using GUI - * @param file event file - */ - protected void openEventFile(File file) { - guiFixture.menuItemWithPath("File", "Read Event Locally").click(); - // Sometimes we have more than one "Open" dialog, but should be only one showing - Dialog dialogOpen = finder.find(DialogMatcher.withTitle("Open").andShowing()); - DialogFixture fixtureDialogOpen = new DialogFixture(robot,dialogOpen); - JFileChooserFixture fileChooser = fixtureDialogOpen.fileChooser(); - fileChooser.selectFile(file); - fileChooser.approve(); - } - - /** - * Open file using GUI and fail if there is a problem - * @param file event file - */ - protected void openEventFileAndCheck(File file) { - openEventFile(file); - try { - Dialog dialogInvalid = finder.find(DialogMatcher.withTitle("Invalid source")); - fail("Failed to open event: found invalid source dialog"); - } - catch (ComponentLookupException e) { - // OK: no warning dialog! - } - } - - /** - * Get a fixture for the event source tool bar. - * @return - */ - public JToolBarFixture findEventSourceToolBar() { - return new JToolBarFixture(robot,"Atlantis event source toolbar"); - } - - /** - * Get a fixture for the interactions tool bar. - * @return - */ - public JToolBarFixture findInteractionToolBar() { - return new JToolBarFixture(robot,"Atlantis interaction toolbar"); - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/AtlantisGuiTestCase.java b/graphics/AtlantisJava/test/src/guitest/AtlantisGuiTestCase.java deleted file mode 100644 index 6c69d170207a95d152c6437a18f8ef084d398d69..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/AtlantisGuiTestCase.java +++ /dev/null @@ -1,100 +0,0 @@ -package guitest; - -import java.awt.Frame; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -import org.fest.swing.core.BasicComponentFinder; -import org.fest.swing.core.BasicRobot; -import org.fest.swing.core.ComponentFinder; -import org.fest.swing.core.Robot; -import org.fest.swing.core.matcher.FrameMatcher; -import org.fest.swing.edt.FailOnThreadViolationRepaintManager; -import org.fest.swing.fixture.FrameFixture; -import org.fest.swing.security.NoExitSecurityManagerInstaller; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; - -import testutils.AtlantisInit; -import testutils.TeeOutputStream; -import testutils.TestUtils; - -import atlantis.Atlantis; -import atlantis.globals.AGlobals; - -public class AtlantisGuiTestCase { - protected Robot robot; - protected ComponentFinder finder; - protected FrameFixture canvasFixture; - protected AtlantisGUIFixture guiFixture; - ByteArrayOutputStream stdOutCopy = new ByteArrayOutputStream(); - private static NoExitSecurityManagerInstaller noExitSecurityManagerInstaller; - - /** Time [ms] to pause at end of test for easier viewing */ - protected long pauseLength = 0; - - /** - * Install NoExitSecurityManager because JUnit gets upset if the forked JVM exits - */ - @BeforeClass - public static void setUpOnce() { - noExitSecurityManagerInstaller = NoExitSecurityManagerInstaller.installNoExitSecurityManager(); - } - - @AfterClass - public static void tearDownOnce() { - noExitSecurityManagerInstaller.uninstall(); - } - - @Before - public void setUp() { - startAtlantis(); - } - - protected void startAtlantis() { - AtlantisInit.init(); - String atlantisHomeDir=AGlobals.instance().getHomeDirectory(); - String testEventsDir = atlantisHomeDir+"/test/events"; - TestUtils.setPropertyIfNotSet("atlantis.test.events",testEventsDir); - - // Omit this for now since Atlantis main does not do set-up on EDT - // FailOnThreadViolationRepaintManager.install(); - - finder = BasicComponentFinder.finderWithCurrentAwtHierarchy(); - robot = BasicRobot.robotWithCurrentAwtHierarchy(); - - // Redirect standard output to ByteArrayOutputStream as well as normal System.out - TeeOutputStream teeOut = new TeeOutputStream(System.out,stdOutCopy); - System.setOut(new PrintStream(teeOut)); - - // Launch Atlantis application - String[] args = {"--debug","DEBUG"}; - Atlantis.main(args); - // Don't use ACrashReporter to handle uncaught exceptions - Thread.setDefaultUncaughtExceptionHandler(null); - - // Get fixtures for the GUI and Canvas - guiFixture = AtlantisGUIFixture.getFixture(robot); - FrameMatcher matcherCanvasTitle = FrameMatcher.withTitle("Atlantis Canvas"); - // Cannot cast to ACanvas because the ACanvas is actually a JPanel that creates its own - // parent JFrame. - Frame canvas = finder.find(matcherCanvasTitle); - canvasFixture = new FrameFixture(robot,canvas); - } - - @After - public void tearDown() { - pause(pauseLength); - } - - /** Pause for a second so can see end result on screen */ - protected static void pause(long duration) { - try { - Thread.sleep(duration); - } catch (InterruptedException e) { - // allow to return if interrupted - } - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/EnumeratorParameterTest.java b/graphics/AtlantisJava/test/src/guitest/EnumeratorParameterTest.java deleted file mode 100644 index 5b9c2fb1c6492c19c0b9b4eb0cf0c78a5cda6bf9..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/EnumeratorParameterTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package guitest; - -import org.junit.Test; -import org.fest.swing.fixture.JComboBoxFixture; -import org.fest.swing.fixture.JTableCellFixture; - -public class EnumeratorParameterTest extends AtlantisGuiTestCase { - - @Test - public void test() { - JTableCellFixture cell = guiFixture.findParameterCell("MuonDet","Track","Track Collections"); - cell.click(); - JComboBoxFixture comboBox = guiFixture.comboBox("Track Collections"); - String[] contents = comboBox.contents(); - comboBox.selectItem("All"); - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/EventSourceToolBarTest.java b/graphics/AtlantisJava/test/src/guitest/EventSourceToolBarTest.java deleted file mode 100644 index 15bb2f5481a34ea14371480734443c19615cfbef..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/EventSourceToolBarTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package guitest; - -import org.fest.swing.fixture.JToolBarFixture; -import org.junit.Test; - -public class EventSourceToolBarTest extends AtlantisGuiTestCase { - @Test - public void testEventSourceToolBar() { - JToolBarFixture toolBarFixture = guiFixture.findEventSourceToolBar(); - toolBarFixture.radioButton("Sequential mode").click(); - toolBarFixture.radioButton("Loop mode").click(); - toolBarFixture.radioButton("Random mode").click(); - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/InteractionToolBarTest.java b/graphics/AtlantisJava/test/src/guitest/InteractionToolBarTest.java deleted file mode 100644 index ffe8a982a4094894171bcb65961b28c2efad4b19..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/InteractionToolBarTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package guitest; - -import java.awt.event.KeyEvent; - -import org.fest.swing.fixture.JComboBoxFixture; -import org.fest.swing.fixture.JTextComponentFixture; -import org.fest.swing.fixture.JToolBarFixture; -import org.junit.Test; - -import static guitest.AAssert.*; - -public class InteractionToolBarTest extends AtlantisGuiTestCase { - @Test - public void testInteractionToolBar() { - JToolBarFixture toolBarFixture = guiFixture.findInteractionToolBar(); - - toolBarFixture.toggleButton("ZMR").click(); - - toolBarFixture.toggleButton("RubberBand").click(); - JComboBoxFixture rubberBandComboBox = toolBarFixture.comboBox(); - String[] listRubberBand = rubberBandComboBox.contents(); - String[] expectedRubberBand = {"RectangleYX","RotatedRectangle","Parallelogram", - "Square","XSkew","YSkew","XSlice","YSlice"}; - assertArrayEqualsIgnoreOrder("Didn't find expected rubberband list",expectedRubberBand,listRubberBand); - - toolBarFixture.toggleButton("Pick").click(); - JComboBoxFixture pickComboBox = toolBarFixture.comboBox(); - String[] listPick = pickComboBox.contents(); - String[] expectedPick = {"Event Data","Detectors"}; - assertArrayEqualsIgnoreOrder("Didn't find expected pick list",expectedPick,listPick); - - toolBarFixture.toggleButton("SyncCursors").click(); - - toolBarFixture.toggleButton("FishEye").click(); - JTextComponentFixture textBox = toolBarFixture.textBox(); - textBox.setText(""); // deleteText() does not work - textBox.enterText("5.0"); // this does not press "enter", so... - textBox.pressAndReleaseKeys(KeyEvent.VK_ENTER); // we do it here - toolBarFixture.checkBox().click(); // turn off fish-eye - toolBarFixture.checkBox().click(); // turn it on again - - toolBarFixture.toggleButton("Clock").click(); - toolBarFixture.checkBox().click(); // turn on clock transformation - toolBarFixture.checkBox().click(); // turn it on again - - toolBarFixture.toggleButton("Scale").click(); - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/LoadEventFailureTest.java b/graphics/AtlantisJava/test/src/guitest/LoadEventFailureTest.java deleted file mode 100644 index 48e2cabb35b83f12fac39e7d088de0998b3fbaa4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/LoadEventFailureTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package guitest; - -import java.awt.Dialog; -import java.io.File; -import org.junit.Test; -import static org.junit.Assert.*; -import org.fest.swing.core.matcher.DialogMatcher; -import org.fest.swing.exception.ComponentLookupException; - -public class LoadEventFailureTest extends AtlantisGuiTestCase { - @Test - public void loadEvent() { - guiFixture.openEventFile(new File("/nosuchfile")); - try { - Dialog dialogInvalid = finder.find(DialogMatcher.withTitle("Invalid source")); - // OK, correctly failed to open file - } - catch (ComponentLookupException e) { - fail("Did not find invalid source dialog when opening non-existent event file"); - } - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/LoadEventTest.java b/graphics/AtlantisJava/test/src/guitest/LoadEventTest.java deleted file mode 100644 index 7bfcaef27e665d8746fc24eefa61d72f396ca41c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/LoadEventTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package guitest; - -import static org.junit.Assert.*; - -import java.awt.Dialog; -import java.io.File; - -import org.fest.swing.core.matcher.DialogMatcher; -import org.fest.swing.exception.ComponentLookupException; -import org.junit.Test; - -public class LoadEventTest extends AtlantisGuiTestCase { - @Test - public void loadEvent() { - String eventsDirectory = System.getProperty("atlantis.test.events"); - guiFixture.openEventFile(new File(eventsDirectory,"muonCollections.xml")); - try { - Dialog dialogInvalid = finder.find(DialogMatcher.withTitle("Invalid source")); - fail("Failed to open event: found invalid source dialog"); - } - catch (ComponentLookupException e) { - // OK - } - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/LoadEventWithInvalidRecVertexDataTest.java b/graphics/AtlantisJava/test/src/guitest/LoadEventWithInvalidRecVertexDataTest.java deleted file mode 100644 index 7cb70d7e2c553744b9612312f1aa28e12e98d0b7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/LoadEventWithInvalidRecVertexDataTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package guitest; - -import static org.junit.Assert.*; - -import java.awt.Dialog; -import java.io.File; - -import org.fest.swing.core.matcher.DialogMatcher; -import org.fest.swing.exception.ComponentLookupException; -import org.junit.Test; - -public class LoadEventWithInvalidRecVertexDataTest extends AtlantisGuiTestCase { - @Test - public void loadEvent() { - String output = stdOutCopy.toString(); - assertTrue("Output does not contain \"Atlantis Ready\"",output.contains("Atlantis Ready")); - String eventsDirectory = System.getProperty("atlantis.test.events"); - guiFixture.openEventFile(new File(eventsDirectory,"rvxInconsistentEvent.xml")); - try { - Dialog dialogInvalid = finder.find(DialogMatcher.withTitle("Invalid source")); - fail("Failed to open event: found invalid source dialog"); - } - catch (ComponentLookupException e) { - // OK - } - output = stdOutCopy.toString(); - assertTrue("Failed to detect inconsistent track numbers",output.contains("RVx: numbers of tracks are inconsistent.")); - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/LoadEventWithValidRecVertexDataTest.java b/graphics/AtlantisJava/test/src/guitest/LoadEventWithValidRecVertexDataTest.java deleted file mode 100644 index 846af19bf93d9b8e27b4d6d8de92d65672c4dbf4..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/LoadEventWithValidRecVertexDataTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package guitest; - -import static org.junit.Assert.*; - -import java.awt.Dialog; -import java.io.File; - -import org.fest.swing.core.matcher.DialogMatcher; -import org.fest.swing.exception.ComponentLookupException; -import org.junit.Test; - -public class LoadEventWithValidRecVertexDataTest extends AtlantisGuiTestCase { - @Test - public void loadEvent() { - String output = stdOutCopy.toString(); - assertTrue("Output does not contain \"Atlantis Ready\"",output.contains("Atlantis Ready")); - String eventsDirectory = System.getProperty("atlantis.test.events"); - guiFixture.openEventFile(new File(eventsDirectory,"rvxEvent.xml")); - try { - Dialog dialogInvalid = finder.find(DialogMatcher.withTitle("Invalid source")); - fail("Failed to open event: found invalid source dialog"); - } - catch (ComponentLookupException e) { - // OK - } - output = stdOutCopy.toString(); - assertFalse("Inconsistent data incorrectly detected",output.contains("RVx: numbers of tracks are inconsistent.")); - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/LoadEventsManyTimesTest.java b/graphics/AtlantisJava/test/src/guitest/LoadEventsManyTimesTest.java deleted file mode 100644 index d395260b2f4a45fd5c673352a71bfb5b066e09bb..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/LoadEventsManyTimesTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package guitest; - -import java.io.File; -import org.junit.Test; -import org.fest.swing.fixture.JButtonFixture; -import org.fest.swing.fixture.JToolBarFixture; - -public class LoadEventsManyTimesTest extends AtlantisGuiTestCase { - - private static final int numEvents = 9; - private static final int numRepeats = 3; - - @Test(timeout=45000) - public void readEvents() { - String eventsDirectory = System.getProperty("atlantis.test.events"); - guiFixture.openEventFileAndCheck(new File(eventsDirectory,"masterclassMuonEvents.zip")); - JToolBarFixture toolBarFixture = guiFixture.findEventSourceToolBar(); - JButtonFixture nextButton = toolBarFixture.button("nextButton"); - JButtonFixture previousButton = toolBarFixture.button("previousButton"); - for (int i=0; i<numRepeats; i++) { - for (int iEvent=0; iEvent<(numEvents-1); iEvent++) { - System.out.println("Click number "+iEvent); - nextButton.click(); - } - for (int iEvent=0; iEvent<(numEvents-1); iEvent++) { - System.out.println("Click number "+iEvent); - previousButton.click(); - } - } - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/MuonTrackCollectionsEmptyTest.java b/graphics/AtlantisJava/test/src/guitest/MuonTrackCollectionsEmptyTest.java deleted file mode 100644 index dddeb873b61f792b27b43724d6af9dd8a207643c..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/MuonTrackCollectionsEmptyTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package guitest; - -import java.io.File; -import org.junit.Test; -import org.fest.swing.fixture.JComboBoxFixture; -import org.fest.swing.fixture.JTableCellFixture; -import static guitest.AAssert.*; - -/** - * Check list of muon track collections for Trac bug #507 - * Should be empty in empty event! - * @author waugh - * - */ -public class MuonTrackCollectionsEmptyTest extends AtlantisGuiTestCase { - @Test - public void loadEvents() { - String eventsDirectory = System.getProperty("atlantis.test.events"); - guiFixture.openEventFileAndCheck(new File(eventsDirectory,"muonCollections.xml")); - checkMuonTrackCollections("ConvertedMBoyTracks", - "ConvertedMBoyMuonSpectroOnlyTracks", - "All"); - guiFixture.openEventFileAndCheck(new File(eventsDirectory,"emptyEvent.xml")); - checkMuonTrackCollections("None"); - } - - private void checkMuonTrackCollections(String... expected) { - String[] contents = getMuonTrackCollections(); - assertArrayEqualsIgnoreOrder("Didn't find expected collections",expected,contents); - } - - private String[] getMuonTrackCollections() { - JTableCellFixture cell = guiFixture.findParameterCell("MuonDet","Track","Track Collections"); - cell.click(); - JComboBoxFixture comboBox = guiFixture.comboBox("Track Collections"); - String[] contents = comboBox.contents(); - return contents; - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/MuonTrackCollectionsTest.java b/graphics/AtlantisJava/test/src/guitest/MuonTrackCollectionsTest.java deleted file mode 100644 index 8ee5814913a44daa52b195255c26bff78204dc7d..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/MuonTrackCollectionsTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package guitest; - -import java.io.File; -import org.junit.Test; -import org.fest.swing.fixture.JComboBoxFixture; -import org.fest.swing.fixture.JTableCellFixture; -import static guitest.AAssert.*; - -/** - * Check list of muon track collections for Trac bug #507 - * @author waugh - * - */ -public class MuonTrackCollectionsTest extends AtlantisGuiTestCase { - @Test - public void loadEvents() { - String eventsDirectory = System.getProperty("atlantis.test.events"); - guiFixture.openEventFileAndCheck(new File(eventsDirectory,"muonCollections.xml")); - checkMuonTrackCollections("ConvertedMBoyTracks", - "ConvertedMBoyMuonSpectroOnlyTracks", - "All"); - guiFixture.openEventFileAndCheck(new File(eventsDirectory,"muonCollections2.xml")); - checkMuonTrackCollections("ConvertedMBoyTracks", - "ConvertedMuIdCBTracks", - "All"); - } - - private void checkMuonTrackCollections(String... expected) { - String[] contents = getMuonTrackCollections(); - assertArrayEqualsIgnoreOrder("Didn't find expected collections",expected,contents); - } - - private String[] getMuonTrackCollections() { - JTableCellFixture cell = guiFixture.findParameterCell("MuonDet","Track","Track Collections"); - cell.click(); - JComboBoxFixture comboBox = guiFixture.comboBox("Track Collections"); - String[] contents = comboBox.contents(); - return contents; - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/OverlayTest.java b/graphics/AtlantisJava/test/src/guitest/OverlayTest.java deleted file mode 100644 index d35ca958746d7f01c2f12a0de9f6536e87c449e6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/OverlayTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package guitest; - -import org.junit.Test; -import org.fest.swing.data.TableCellByColumnId; -import org.fest.swing.fixture.JTableCellFixture; -import org.fest.swing.fixture.JTableFixture; - -public class OverlayTest extends AtlantisGuiTestCase { - - @Test - public void testOverlay() { - JTableFixture table = guiFixture.findParametersTable("Appearance","Logo"); - int row = 0; - JTableCellFixture check = table.cell(TableCellByColumnId.row(row).columnId("Name")); - //check the box to show logo - check.click(); - //change the x position - JTableCellFixture logox = guiFixture.findParameterCell("Appearance","Logo", "Logo X"); - logox.enterValue("0.5\n"); - //resize - JTableCellFixture size = guiFixture.findParameterCell("Appearance","Logo", "Logo Size"); - size.enterValue("0.7\n"); - size.click(); - //now uncheck the box - check.click(); - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/ProjectionsTest.java b/graphics/AtlantisJava/test/src/guitest/ProjectionsTest.java deleted file mode 100644 index 3b32476ab894e4c3a28e83e0235ebce3e8ca397e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/ProjectionsTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package guitest; - -import org.fest.swing.fixture.JPanelFixture; -import org.junit.Test; - -import static atlantis.utils.AMath.*; // for Greek letters - -public class ProjectionsTest extends AtlantisGuiTestCase { - @Test - public void testWindowControls() { - JPanelFixture windowControls = guiFixture.panel("windowControl"); - windowControls.label("W").click(); - guiFixture.findParametersTable("Projection","YX").click(); - guiFixture.findParametersTable("Projection",PHI+ETA).click(); - guiFixture.findParametersTable("Projection",RHO+"Z").click(); - guiFixture.findParametersTable("Projection",PHI+RHO).click(); - guiFixture.findParametersTable("Projection",PHI+"Z").click(); - guiFixture.findParametersTable("Projection","X'Z").click(); - guiFixture.findParametersTable("Projection","Y'Z").click(); - guiFixture.findParametersTable("Projection","3DBox").click(); - guiFixture.findParametersTable("Projection","LegoPlot").click(); - guiFixture.findParametersTable("Projection","Event Info").click(); - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/ReadNextAndPreviousEventTest.java b/graphics/AtlantisJava/test/src/guitest/ReadNextAndPreviousEventTest.java deleted file mode 100644 index 4849224a4a4953c661f2b31032a1db38f1c2b527..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/ReadNextAndPreviousEventTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package guitest; - -import java.awt.Dialog; - -import org.fest.swing.core.matcher.DialogMatcher; -import org.fest.swing.core.matcher.JButtonMatcher; -import org.fest.swing.fixture.DialogFixture; -import org.fest.swing.fixture.JButtonFixture; -import org.fest.swing.fixture.JToolBarFixture; -import org.junit.Test; - -public class ReadNextAndPreviousEventTest extends AtlantisGuiTestCase { - - @Test - public void readNextThenPreviousEvent() { - JToolBarFixture toolBarFixture = guiFixture.findEventSourceToolBar(); - JButtonFixture nextButton = toolBarFixture.button("nextButton"); - JButtonFixture previousButton = toolBarFixture.button("previousButton"); - nextButton.click(); - previousButton.click(); - guiFixture.menuItemWithPath("File", "Exit").click(); - DialogMatcher matcherConfirmExit = DialogMatcher.withTitle("Exit Atlantis"); - Dialog dialogConfirmExit = finder.find(matcherConfirmExit); - DialogFixture fixtureDialogConfirmExit = new DialogFixture(robot,dialogConfirmExit); - // fixtureDialogConfirmExit.button(JButtonMatcher.withText("Yes")).click(); - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/StartAndExitTest.java b/graphics/AtlantisJava/test/src/guitest/StartAndExitTest.java deleted file mode 100644 index ec93dce67c4369a1a415fe3c2f54716baffc2b83..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/StartAndExitTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package guitest; - -import java.awt.Dialog; -import org.junit.Test; -import org.fest.swing.core.matcher.DialogMatcher; -import org.fest.swing.core.matcher.JButtonMatcher; -import org.fest.swing.fixture.DialogFixture; - -public class StartAndExitTest extends AtlantisGuiTestCase { - - @Test - public void atlantisStarts() { - guiFixture.menuItemWithPath("File", "Exit").click(); - DialogMatcher matcherConfirmExit = DialogMatcher.withTitle("Exit Atlantis"); - Dialog dialogConfirmExit = finder.find(matcherConfirmExit); - DialogFixture fixtureDialogConfirmExit = new DialogFixture(robot,dialogConfirmExit); - fixtureDialogConfirmExit.button(JButtonMatcher.withText("Yes")).click(); - } -} diff --git a/graphics/AtlantisJava/test/src/guitest/TabsTest.java b/graphics/AtlantisJava/test/src/guitest/TabsTest.java deleted file mode 100644 index 11ba9148e3b546a544edee70f38e6cc72725c3f7..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/guitest/TabsTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package guitest; - -import org.junit.Test; -import org.fest.swing.fixture.JTableFixture; - -public class TabsTest extends AtlantisGuiTestCase { - - @Test - public void testTabs() { - JTableFixture table = guiFixture.findParametersTable("MuonDet","Segment"); - // Click on cell: does nothing but checks we have found required cell - table.cell(table.cell("Segment Collections")).click(); - guiFixture.findParametersTable("Projection","YX"); - guiFixture.findParametersTable("Data","Data"); - guiFixture.findParametersTable("Cuts","Calo"); - guiFixture.findParametersTable("InDet","SpacePoint"); - guiFixture.findParametersTable("Calo","HEC"); - guiFixture.findParametersTable("MuonDet","MDT"); - guiFixture.findParametersTable("Objects","Muon"); - guiFixture.findParametersTable("Detector","Geo"); - guiFixture.findParametersTable("Appearance","Logo"); - } -} diff --git a/graphics/AtlantisJava/test/src/testutils/AtlantisInit.java b/graphics/AtlantisJava/test/src/testutils/AtlantisInit.java deleted file mode 100644 index d1732aec9f84e5a421d933295881e8f4346209c6..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/testutils/AtlantisInit.java +++ /dev/null @@ -1,20 +0,0 @@ -package testutils; - -import atlantis.Atlantis; -import atlantis.globals.AGlobals; - -/** - * Do Atlantis initialization for tests: things that would be set up by main() in the - * full application, and require access to protected Atlantis members. - * - * @author waugh - * - */ -public class AtlantisInit extends Atlantis { - - public static void init() { - String homeDirectory = Atlantis.getHomeDirectory(); - AGlobals.instance().setHomeDirectory(homeDirectory); - } - -} diff --git a/graphics/AtlantisJava/test/src/testutils/TeeOutputStream.java b/graphics/AtlantisJava/test/src/testutils/TeeOutputStream.java deleted file mode 100644 index e490cc19821d8c932e41d3825b94444677efb76e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/testutils/TeeOutputStream.java +++ /dev/null @@ -1,34 +0,0 @@ -package testutils; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; - -/** - * Wraps any number of OutputStreams and directs input to all of them. - * @author waugh - * - */ -public class TeeOutputStream extends OutputStream { - private List<OutputStream> streams; - - /** - * Create a TeeOutputStream that writes to the given OutputStreams. - * @param outputStreams the OutputStreams to be wrapped - */ - public TeeOutputStream(OutputStream... outputStreams) { - streams = new ArrayList<OutputStream>(); - for (OutputStream stream : outputStreams) { - streams.add(stream); - } - } - - @Override - public void write(int b) throws IOException { - for (OutputStream stream : streams) { - stream.write(b); - } - } - -} diff --git a/graphics/AtlantisJava/test/src/testutils/TestUtils.java b/graphics/AtlantisJava/test/src/testutils/TestUtils.java deleted file mode 100644 index d9b580329146e7be599335b06292d2c086e12c4e..0000000000000000000000000000000000000000 --- a/graphics/AtlantisJava/test/src/testutils/TestUtils.java +++ /dev/null @@ -1,17 +0,0 @@ -package testutils; - -public class TestUtils { - - /** - * Set system property if it doesn't already have a value. - * Useful in providing sensible defaults for properties set in build file when - * using Ant. - * @param key - * @param value - */ - public static void setPropertyIfNotSet(String key, String value) { - String old = System.getProperty(key); - if (old==null) System.setProperty(key,value); - } - -}