lcsim/src/org/lcsim/recon/cluster/util
diff -u -r1.1 -r1.2
--- Samplexmlclass.java 22 Jun 2006 21:45:35 -0000 1.1
+++ Samplexmlclass.java 9 Aug 2006 22:46:40 -0000 1.2
@@ -31,20 +31,24 @@
System.out.println(xmlfile);
}
+ public int systemID = 999, layerRepeat;
+ public String readoutname = "", phibins, thetabins, type, readoutID;
+ public boolean found = false;
/**
- Get the Integer value of the subdetector Id.
+
@param detname The name of the subdetector.
- @return The integer value of the subdetector id.
+
@throws ParserConfigurationException
@throws SAXParseException
@throws IOException
*/
- public int getSubdetId(String detname)
+
+ public void SystemInfo(String detname)
{
- int s = 999;
- boolean found= false;
+
+
try
- {
+ {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(xmlfile);
@@ -63,7 +67,7 @@
NodeList DetectorsChildren = childElement.getChildNodes();
for(int j=0; j<=DetectorsChildren.getLength(); j++)
- {
+ {
Node Detectorschild = DetectorsChildren.item(j);
if (Detectorschild instanceof Element)
{
@@ -74,10 +78,25 @@
String name = DetectorsChildElement.getAttribute("name");
if (detname.equalsIgnoreCase(name))
{
- String id = DetectorsChildElement.getAttribute("id");
found = true;
- s = Integer.valueOf(id).intValue();
- //System.out.println("subdetid == "+ s);
+ String id = DetectorsChildElement.getAttribute("id");
+ readoutname = DetectorsChildElement.getAttribute("readout");
+ systemID = Integer.valueOf(id).intValue();
+ NodeList DetectorsChildElementsChildren = DetectorsChildElement.getChildNodes();
+ for (int k=0; k<DetectorsChildElementsChildren.getLength(); k++ )
+ {
+ Node DetectorsChildElementsChild = DetectorsChildElementsChildren.item(k);
+ if (DetectorsChildElementsChild instanceof Element)
+ {
+ Element DetectorsChildElementsChildElement = (Element)DetectorsChildElementsChild;
+ if (DetectorsChildElementsChildElement.getTagName().equals("layer"))
+ {
+ layerRepeat = Integer.valueOf(DetectorsChildElementsChildElement.getAttribute("repeat")).intValue();
+ System.out.println("Detectorname = "+ detname+ " Systemid == "+ systemID + " Readout name = " + readoutname + " layer repeat == " + layerRepeat );
+ }
+ }
+ }
+
}
@@ -86,76 +105,14 @@
}
}
}
- }
- }
- }
- catch (ParserConfigurationException err)
- {
- System.out.println(" " + err.getMessage ());
-
- }
- catch (SAXParseException err)
- {
-
- System.out.println(" " + err.getMessage ());
-
- }
- catch (IOException err) {
- System.out.println(" " + err.getMessage ());
-
- }
-
- catch (Throwable t) {
- t.printStackTrace ();
- }
-
- if (found==true)
- return s;
- else
- {
- System.out.println("Invalid Detector Name:" + detname +" ID will be set to 999 ");
- return 999;
- }
-
-
-
- }
-
- /**
- Get the String value from the readouts of the Barrel Hits.(e.g MuonBarrHits, HCalBarrHits, EcalBarrHits)
- @param detname The name of the subdetector.
- @return The String value of the Segmentation id.
- @throws ParserConfigurationException
- @throws SAXParseException
- @throws IOException
- */
-
- public String getReadoutId(String detname)
- {
- String s= "Invalid ";
- boolean found = false;
- try
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(xmlfile);
- Element root = doc.getDocumentElement();
- NodeList children = root.getChildNodes();
- //int j = 0;
- //Get number of children of the entire xml file without spaces
- for(int i=0; i<=children.getLength(); i++)
- {
- Node child = children.item(i);
- if (child instanceof Element)
- {
- Element childElement = (Element)child;
- if (childElement.getTagName().equals("readouts"))
+ //-------------------------------------------------------------------------
+ if (childElement.getTagName().equals("readouts"))
{
//System.out.println("Readouts Found");
NodeList ReadoutsChildren = childElement.getChildNodes();
for(int j=0; j<=ReadoutsChildren.getLength(); j++)
- {
+ {
Node Readoutschild = ReadoutsChildren.item(j);
if (Readoutschild instanceof Element)
{
@@ -163,10 +120,7 @@
if (ReadoutsChildElement.getTagName().equals("readout"))
{
String name= ReadoutsChildElement.getAttribute("name");
- //System.out.println("NAME == " + name);
- String namestart= name.substring(0,1);
- // System.out.println("NAMESTART == " + namestart);
- if (detname.startsWith(namestart) && name.endsWith("BarrHits") )
+ if (name.equals(readoutname))
{
//System.out.println("Barr Hits");
NodeList DetectorsChildren = ReadoutsChildElement.getChildNodes();
@@ -183,11 +137,17 @@
{
//System.out.println("ID found");
Node N = ((Node)idcontent.item(0));
- s = N.getNodeValue();
+ readoutID = N.getNodeValue();
found=true;
}
-
+
+ if (DetectorsChildElement.getTagName().equals("segmentation"))
+ {
+ phibins = DetectorsChildElement.getAttribute("phiBins");
+ thetabins = DetectorsChildElement.getAttribute("thetaBins");
+ type = DetectorsChildElement.getAttribute("type");
+ }
}
}
@@ -201,12 +161,9 @@
}//end of readouts children
}
-
- }
-
- }//end of total children
-
-
+ //-----------------------------------------------------------------
+ }
+ }
}
catch (ParserConfigurationException err)
{
@@ -228,9 +185,37 @@
t.printStackTrace ();
}
- if (found == false)
- System.out.println("Invalid Detector name.... "+ detname+ "....Id will be set to Invalid");
- return s;
- }
+ if (found!=true)
+ System.out.println("Invalid Detector Name:" + detname );
+
+
+ }
+
+ public int getSystemID()
+ {
+ return systemID;
+ }
+ public int getLayerRepeat()
+ {
+ return layerRepeat;
+ }
+
+ public int getPhiBins()
+ {
+ return Integer.valueOf(phibins).intValue();
+ }
+
+ public int getThetaBins()
+ {
+ return Integer.valueOf(thetabins).intValue();
+ }
+ public String getType()
+ {
+ return type;
+ }
+ public String getReadoutID()
+ {
+ return readoutID;
+ }
}
\ No newline at end of file