Commit in LCDetectors on MAIN
Makefile+165-451.12 -> 1.13
JM: Add new commands to LCDetectors for GDML output, DAWN output, VRML output, OpenGL vis, ROOT vis, and overlap check.

LCDetectors
Makefile 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- Makefile	26 Sep 2006 17:34:58 -0000	1.12
+++ Makefile	5 Oct 2006 00:11:06 -0000	1.13
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.12 2006/09/26 17:34:58 jeremy Exp $
+# $Id: Makefile,v 1.13 2006/10/05 00:11:06 jeremy Exp $
 
 #
 # Makefile using GeomConverter and shell tools to
@@ -14,17 +14,28 @@
 # at www.lcsim.org/detectors
 #
 
-# SLAC NFS location of GeomConverter.
+# How to run GeomConverter?
 ifndef GEOMCONVERTER
-	GEOMCONVERTER=/nfs/slac/g/lcd/mc/prj/sw/dist/GeomConverter/pro/bin/GeomConverter
+	GEOMCONVERTER=GeomConverter
 endif
 
-# SLAC NFS location of LCSim website.
+# How to run SLIC?
+ifndef SLICBIN
+	SLICBIN=slic
+endif
+
+# How to run Python?
+ifndef PYTHON
+	PYTHON=python
+endif
+
+# Location of the LCSim website.
+# Default is SLAC NFS.
 ifndef PRJ_WWW
 	PRJ_WWW=/nfs/slac/g/lcd/mc/prj/www/lcsim/
 endif
 
-# List of all detectors.
+# The list of all detectors.
 DETECTORS=$(shell cat detectors/taglist.txt)
 
 # By default, print help if no target is given.
@@ -32,47 +43,64 @@
 
 # Detailed list of available make targets.
 help:
-	@echo "----LCDetectors Makefile Targets----" ; \
+	@echo "======== LCDetectors Makefile Targets ========" ; \
 	echo ; \
-	echo "ALL DETECTORS"; \
+	echo "Define the working detector in the environment." ;\
 	echo ; \
-	echo "build_all      - rebuild all detectors"; \
-	echo "update_all     - update detectors to WWW"; \
-	echo "lcdd_all       - make LCDD files for all detectors"; \
-	echo "heprep_all     - make HepRep files for all detectors"; \
-	echo "zip_all        - make zip files for all detectors"; \
+	echo "  export DETECTOR=detname"; \
 	echo ; \
-	echo "SINGLE DETECTOR"; \
+	echo "Or use a variable passed to make." ; \
 	echo ; \
-	echo "Define a detector using" ;\
-	echo "  export DETECTOR=detname"; \
-	echo "or" ; \
 	echo "  make DETECTOR=detname" ;\
 	echo ; \
+	echo "SINGLE DETECTOR COMMANDS"; \
+	echo ; \
 	echo "build          - rebuild single detector"; \
-	echo "update         - update single detector to WWW"; \
-	echo "lcdd           - make LCDD file for single detector"; \
-	echo "heprep         - make HepRep file for single detector"; \
+	echo "cleanup        - make fresh copy of detector"; \
 	echo "cvs_commit     - commit changes to single detector"; \
+	echo "dawn           - generate prim file for DAWN for single detector"; \
+	echo "gdml           - make GDML file for single detector"; \
+	echo "heprep         - make HepRep file for single detector"; \
+	echo "lcdd           - make LCDD file for single detector"; \
+	echo "new            - create a new detector"; \
+	echo "olap           - check a single detector for overlaps"; \
 	echo "mkdir          - make directory for new detector"; \
-	echo "template       - copy template files to new detector dir"; \
 	echo "properties     - create detector.properties file for single detector"; \
+	echo "root           - load the GDML file into the ROOT OpenGL viewer"; \
+	echo "template       - copy template files to new detector dir"; \
+	echo "tree           - output drawTree command to file"; \
+	echo "update         - update single detector to WWW"; \
+	echo "vrml           - make VRML2 file for single detector"; \
 	echo "zip            - create zip file for single detector"; \
-	echo "new            - create a new detector"; \
 	echo ; \
-	echo "MISCELLANEOUS"; \
+	echo "COMMANDS ON ALL DETECTORS"; \
+	echo ; \
+	echo "build_all      - rebuild all detectors"; \
+	echo "cleanup_all    - make fresh copies of all detectors"; \
+	echo "gdml_all       - make gdml files for all detectors"; \
+	echo "lcdd_all       - make LCDD files for all detectors"; \
+	echo "heprep_all     - make HepRep files for all detectors"; \
+	echo "olap_all       - check all detectors for overlaps"; \
+	echo "tree_all       - detector tree for all detectors"; \
+	echo "update_all     - update detectors to WWW"; \
+	echo "vrml_all       - make vrml files for all detectors"; \
+	echo "zip_all        - make zip files for all detectors"; \
+	echo ; \
+	echo "MISCELLANEOUS COMMANDS"; \
+	echo ; \
+	echo "cvs_update     - update all from LCDetectors CVS"; \
 	echo "taglist        - create detectors/taglist.txt"; \
 	echo "taglist_commit - commit detectors/taglist.txt to CVS"; \
-	echo "cvs_update     - update from LCDetectors CVS"; \
+	echo "taglist_update - update taglist.txt to WWW"; \
 	echo ; \
 	echo "Questions or bugs to <[log in to unmask]>";
 
-# Rebuild all detectors.  CAREFUL WITH THIS TARGET.
+# Rebuild all detectors.  PLEASE BE CAREFUL WITH THIS TARGET.
 build_all: lcdd_all heprep_all zip_all update_all
 
-# Remake the taglist at ./detector/taglist.txt
+# Remake the taglist at detector/taglist.txt
 taglist:
-	@ echo "Creating detector taglist ..." ; \
+	@echo "Creating detector taglist ..." ; \
 	> taglist.txt; \
 	for d in `find detectors -type d -mindepth 1 -maxdepth 1`; do \
 	dd=$$(basename $$d); \
@@ -82,9 +110,12 @@
 	done ; \
 	sort taglist.txt > taglist.txt.tmp ; \
 	mv taglist.txt.tmp ./detectors/taglist.txt; \
-	cp taglist.txt /nfs/slac/g/lcd/mc/prj/www/lcsim/detectors; \
 	cat ./detectors/taglist.txt;
 
+# Update taglist to WWW.
+taglist_update: taglist
+	@cp ./detectors/taglist.txt $(PRJ_WWW)/detectors;
+
 # Commit the taglist to the CVS.
 taglist_commit:
 	@cd detectors && cvs commit -m "Update taglist." taglist.txt
@@ -103,16 +134,41 @@
 	@for detector in $(DETECTORS); do \
 	$(MAKE) lcdd DETECTOR=$$detector; done
 
+# Create a GDML file for each detector.
+gdml_all:
+	@for detector in $(DETECTORS); do \
+	$(MAKE) gdml DETECTOR=$$detector; done
+
+# Create a VRML file for each detector.
+vrml_all:
+	@for detector in $(DETECTORS); do \
+	$(MAKE) vrml DETECTOR=$$detector; done
+
+# Check all detectors for overlaps.
+olap_all:
+	@for detector in $(DETECTORS); do \
+	$(MAKE) olap DETECTOR=$$detector; done
+
 # Create the HepRep file for each detector.
 heprep_all:
 	@for detector in $(DETECTORS); do \
 	$(MAKE) heprep DETECTOR=$$detector; done
 
+# Detector tree for all.
+tree_all:
+	@for detector in $(DETECTORS); do \
+	$(MAKE) tree DETECTOR=$$detector; done
+
 # Create the zip file for each detector.
 zip_all:
 	@for detector in $(DETECTORS); do \
 	$(MAKE) zip DETECTOR=$$detector; done
 
+# Cleanup all detectors.
+cleanup_all:
+	@for detector in $(DETECTORS); do \
+	$(MAKE) cleanup DETECTOR=$$detector; done
+
 # Following are targets that are only defined if the
 # DETECTOR variable is defined.  This means the user
 # is currently working on this detector.  These targets
@@ -133,31 +189,68 @@
 # Build a single detector.
 build: lcdd zip
 
-# Update detector to the website if necessary.
 update:
-	@if [[ detectors/$(DETECTOR).zip -nt $(PRJ_WWW)/detectors/$(DETECTOR).zip ]]; then \
-		chk_local=$$(md5sum detectors/$(DETECTOR).zip | awk '{print $$1}') ; \
-		chk_www=$$(md5sum $(PRJ_WWW)/detectors/$(DETECTOR).zip | awk '{print $$1}') ; \
-		if [[ $$chk_local != $$chk_www ]]; then \
-			echo "Detector $(DETECTOR) needs update ..."; \
-			echo "Copying detectors/$(DETECTOR).zip to $(PRJ_WWW)/detectors ..."; \
-            rm $(PRJ_WWW)/detectors/$(DETECTOR).zip; \
-			cp detectors/$(DETECTOR).zip $(PRJ_WWW)/detectors; \
-			chmod 775 $(PRJ_WWW)/detectors/$(DETECTOR).zip; \
-			chgrp lcddata $(PRJ_WWW)/detectors/$(DETECTOR).zip; \
-		else \
-			echo "$(PRJ_WWW)/detectors/$(DETECTOR).zip is already up-to-date."; \
-		fi \
+	chk_local=$$(md5sum detectors/$(DETECTOR).zip | awk '{print $$1}') ; \
+	chk_www=$$(md5sum $(PRJ_WWW)/detectors/$(DETECTOR).zip | awk '{print $$1}') ; \
+	if [[ $$chk_local != $$chk_www ]]; then \
+		echo "Detector $(DETECTOR) needs update ..."; \
+		echo "Copying detectors/$(DETECTOR).zip to $(PRJ_WWW)/detectors ..."; \
+		rm $(PRJ_WWW)/detectors/$(DETECTOR).zip; \
+		cp detectors/$(DETECTOR).zip $(PRJ_WWW)/detectors; \
+		chmod 775 $(PRJ_WWW)/detectors/$(DETECTOR).zip; \
+		chgrp lcddata $(PRJ_WWW)/detectors/$(DETECTOR).zip; \
 	else \
-		echo "Detector $(DETECTOR) is already up-to-date."; \
-	fi
+		echo "$(PRJ_WWW)/detectors/$(DETECTOR).zip is already up-to-date."; \
+	fi \
 
 # Create the LCDD file for a single detector.
 lcdd:
-	@echo "Creating LCDD file for $(DETECTOR)..." ; \
+	@echo "Creating LCDD file for $(DETECTOR) ..." ; \
 	$(GEOMCONVERTER) -o lcdd ./detectors/$(DETECTOR)/compact.xml ./detectors/$(DETECTOR)/$(DETECTOR).lcdd;
 
-# Create the HepRep file for a single detector.
+# Use SLIC to dump a pure GDML file for a single detector.
+gdml:
+	@echo "Creating GDML file for $(DETECTOR) ..." ; \
+	$(SLICBIN) -g ./detectors/$(DETECTOR)/$(DETECTOR).lcdd -G ./detectors/$(DETECTOR)/$(DETECTOR).gdml;
+
+# Load the LCDD file into SLIC.
+slic:
+	@echo "Loading $(DETECTOR) into slic ..."; \
+	$(SLICBIN) -g ./detectors/$(DETECTOR)/$(DETECTOR).lcdd -m ./g4macros/opengl.mac -n;
+
+# Generate the prim file for DAWN.
+dawn:
+	@echo "Creating prim file for $(DETECTOR) ..."; \
+	$(SLICBIN) -g ./detectors/$(DETECTOR)/$(DETECTOR).lcdd -m ./g4macros/dawn.mac; \
+	mv g4_00.prim ./detectors/$(DETECTOR)/$(DETECTOR).prim;
+
+# Generate a VRML file.
+vrml:
+	@echo "Creating VRML file for $(DETECTOR) .."; \
+	$(SLICBIN) -g ./detectors/$(DETECTOR)/$(DETECTOR).lcdd -m ./g4macros/vrml.mac; \
+	mv g4_00.wrl ./detectors/$(DETECTOR)/$(DETECTOR).wrl;
+
+# Check a detector for overlaps.
+olap:
+	@echo "Checking $(DETECTOR) for overlaps ..."; \
+	$(SLICBIN) -g ./detectors/$(DETECTOR)/$(DETECTOR).lcdd -m ./g4macros/olap.mac &> ./detectors/$(DETECTOR)/$(DETECTOR)_olap_check.txt;
+
+# Output the text geometry tree.
+tree:
+	@echo "Outputting geometry tree for $(DETECTOR) ..."; \
+	$(SLICBIN) -g ./detectors/$(DETECTOR)/$(DETECTOR).lcdd -m ./g4macros/tree.mac &> ./detectors/$(DETECTOR)/$(DETECTOR)_geom_tree.txt;
+
+# Only define this target if ROOT is defined in the user environment.
+ifdef ROOTSYS
+
+# Load the GDML file into the Python/GDML/ROOT viewer.
+root:
+	@echo "Loading $(DETECTOR) into ROOT ..."; \
+	$(PYTHON) -i $(ROOTSYS)/gdml/GDMLROOT.py file://$(PWD)/detectors/$(DETECTOR)/$(DETECTOR).gdml;
+
+endif
+
+# Use GeomConverter to create the HepRep file for a single detector.
 heprep:
 	@echo "Creating HepRep file for $(DETECTOR)..." ; \
 	$(GEOMCONVERTER) -o heprep ./detectors/$(DETECTOR)/compact.xml ./detectors/$(DETECTOR)/detector.heprep;
@@ -192,4 +285,31 @@
 # Create a new detector.
 new: mkdir template properties
 
+# Cleanup a detector directory by deleting and then recheckout from CVS.
+cleanup:
+	@echo "Cleaning up $(DETECTOR) ... "; \
+	rm -rf ./detectors/$(DETECTOR); \
+	cvs update -d detectors/$(DETECTOR);
+
+# Update detector to the website if necessary.
+# update:
+# 	@if [[ "$(PWD)/detectors/$(DETECTOR).zip" -nt "$(PRJ_WWW)/detectors/$(DETECTOR).zip" ]]; then \
+# 		chk_local=$$(md5sum detectors/$(DETECTOR).zip | awk '{print $$1}') ; \
+# 		chk_www=$$(md5sum $(PRJ_WWW)/detectors/$(DETECTOR).zip | awk '{print $$1}') ; \
+# 		if [[ $$chk_local != $$chk_www ]]; then \
+# 			echo "Detector $(DETECTOR) needs update ..."; \
+# 			echo "Copying detectors/$(DETECTOR).zip to $(PRJ_WWW)/detectors ..."; \
+#             rm $(PRJ_WWW)/detectors/$(DETECTOR).zip; \
+# 			cp detectors/$(DETECTOR).zip $(PRJ_WWW)/detectors; \
+# 			chmod 775 $(PRJ_WWW)/detectors/$(DETECTOR).zip; \
+# 			chgrp lcddata $(PRJ_WWW)/detectors/$(DETECTOR).zip; \
+# 		else \
+# 			echo "$(PRJ_WWW)/detectors/$(DETECTOR).zip is already up-to-date."; \
+# 		fi \
+# 	else \
+# 		echo "Detector $(DETECTOR) is already up-to-date."; \
+# 	fi
+
 endif
+
+
CVSspam 0.2.8