LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  November 2015

HPS-SVN November 2015

Subject:

r3984 - /java/trunk/tracking/src/main/java/org/hps/svt/alignment/MillepedeCompactDump.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Wed, 25 Nov 2015 00:54:40 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (181 lines)

Author: [log in to unmask]
Date: Tue Nov 24 16:54:37 2015
New Revision: 3984

Log:
dump MP constants from XML

Added:
    java/trunk/tracking/src/main/java/org/hps/svt/alignment/MillepedeCompactDump.java

Added: java/trunk/tracking/src/main/java/org/hps/svt/alignment/MillepedeCompactDump.java
 =============================================================================
--- java/trunk/tracking/src/main/java/org/hps/svt/alignment/MillepedeCompactDump.java	(added)
+++ java/trunk/tracking/src/main/java/org/hps/svt/alignment/MillepedeCompactDump.java	Tue Nov 24 16:54:37 2015
@@ -0,0 +1,165 @@
+package org.hps.svt.alignment;
+
+/**
+ * Class building a new compact.xml detector based on MillepedeII input corrections
+ * @author phansson
+ * created on 1/15/2014
+ */
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.List;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+
+
+public class MillepedeCompactDump {
+
+	private static String detectorName = "Tracker";
+
+
+
+    private static Options createCmdLineOpts() {
+		Options options = new Options();
+		options.addOption(new Option("c",true,"The path to the compact xml file."));
+		options.addOption(new Option("o",true,"The name of the output text file."));
+		return options;
+	}
+	
+	private static void printHelpAndExit(Options options) {
+		HelpFormatter help = new HelpFormatter();
+		help.printHelp(" ", options);
+		System.exit(1);
+	}
+	
+		
+	public static void main(String[] args) {
+
+		// Setup command line input
+		Options options = createCmdLineOpts();
+		if (args.length == 0) {
+			printHelpAndExit(options);
+		}
+
+		CommandLineParser parser = new DefaultParser();
+		CommandLine cl = null;
+		try {
+			cl = parser.parse(options, args);
+		} catch (ParseException e) {
+			throw new RuntimeException("Problem parsing command line options.",e);
+		}
+		
+		String compactFilename = null;  
+		if(cl.hasOption("c")) {
+			compactFilename = cl.getOptionValue("c");
+		} else {
+			printHelpAndExit(options);
+		}
+		
+		String outputFilename = "millepede_dump.txt";// + compactFilename.replace(".xml", ".txt");
+		if(cl.hasOption("o")) {
+			outputFilename = cl.getOptionValue("o");
+		}
+		
+        PrintWriter outputPrintWriter = null;
+		try {
+             outputPrintWriter
+               = new PrintWriter(new BufferedWriter(new FileWriter(outputFilename)));
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+		 
+		
+		
+		
+		File compactFile = new File(compactFilename);
+		
+		// read XML
+		SAXBuilder builder = new SAXBuilder();
+		Document compact_document = null;
+		try {
+			compact_document = (Document) builder.build(compactFile);
+		} catch (JDOMException | IOException e1) {
+			throw new RuntimeException("problem with JDOM ", e1);
+		}
+		
+		
+
+		Element rootNode = compact_document.getRootElement();
+		
+		// find the constants needed to calculate the final millepede parameters
+		List<Element> definitions = rootNode.getChildren("define");
+		for(Element definition : definitions) {
+		    List<Element> constants = definition.getChildren("constant");
+		    
+		}
+        
+		
+		
+		// find the millepede constants
+		List<Element> mpConstants = null;
+		List<Element> detectors = rootNode.getChildren("detectors");
+		for(Element detectorsNode : detectors) {
+		    List<Element> detectorNode = detectorsNode.getChildren("detector");
+		    if(detectorNode!=null) {
+		        System.out.println(detectorNode.size() + " detectors");
+		        for(Element detector : detectorNode) {
+		            if(detector.getAttribute("name")!=null) {
+		                if(detector.getAttributeValue("name").compareTo(detectorName)==0 ) {
+		                    System.out.println("Found " + detectorName);
+		                    
+		                    Element element_constants = detector.getChild("millepede_constants");
+		                    if(element_constants==null) {
+		                        throw new RuntimeException("no alignment constants in this compact file.");
+		                    }
+		                    mpConstants = element_constants.getChildren("millepede_constant");
+
+		                           
+		                }
+		            } else {
+		                throw new RuntimeException("this detector node element is not formatted correctly");
+		            }
+		        }
+		    } else {
+		        throw new RuntimeException("this detector node element is not formatted correctly");
+		    }
+		}
+        System.out.println("Found " + mpConstants.size() + " constants" );
+        for(Element element : mpConstants) {
+            String name = element.getAttributeValue("name");
+            String value = element.getAttributeValue("value");
+            String s = name + "," + value;
+            System.out.println(s);
+            outputPrintWriter.println(s);
+        }
+        
+
+		outputPrintWriter.close();
+		
+		
+		
+		
+	}
+
+
+
+	
+
+	
+	
+	
+
+}

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use