lcsim/src/org/lcsim/util/step
diff -N StepConditions.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ StepConditions.java 13 Jul 2006 23:33:39 -0000 1.1
@@ -0,0 +1,223 @@
+package org.lcsim.util.step;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import org.lcsim.event.*;
+import java.io.*;
+import java.util.*;
+import java.lang.Math;
+import org.lcsim.util.step.TrackStepper; // C.M. Stepper
+import org.lcsim.recon.cluster.util.Samplexmlclass;
+import org.lcsim.util.step.DeDx;
+import org.lcsim.util.aida.AIDA;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.subdetector.CylindricalBarrelCalorimeter;
+import org.lcsim.geometry.segmentation.SegmentationBase;
+import org.lcsim.geometry.util.IDEncoder;
+import org.lcsim.geometry.util.IDDescriptor;
+import org.lcsim.geometry.layer.LayerSlice;
+import org.lcsim.recon.cluster.util.CalHitMapMgr;
+import org.lcsim.material.*;
+import org.lcsim.geometry.field.FieldOverlay;
+import org.lcsim.recon.muon.CoilSubLayer;
+import org.lcsim.geometry.subdetector.MultiLayerTracker;
+import org.lcsim.geometry.layer.*;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.util.aida.*;
+import org.lcsim.geometry.layer.*;
+import org.lcsim.geometry.Layered;
+//import org.lcsim.material.Material;
+
+/**
+ To get the Step Conditions for the Stepper, and to reconstuct the track in the Calorimeters, ECAL, HCAL, and MUDET,
+ and in the medium in between
+ @author Judith Odili
+ @version 1- 07/13/06 - 18:05
+ Called by @see org.lcsim.util.step.TrackStepper
+ */
+public class StepConditions
+{
+ public Detector det;
+ public CylindricalBarrelCalorimeter calsub;
+ public String subdetName, materialName, sublayerMat, name;
+ public int layerN;
+ public double rNow, rToGo, layerthickness,materialthickness, layerDEdx=0., matterDEdx = 0., mass, charge, distance;
+ public Map<String, Double> materials;
+ public DeDx dedx;
+ public double []rpVect = new double[8] ;
+ public double []pp = new double[3];
+ //?how to declare material
+ public Material material;
+ public MaterialManager manager;
+ public FieldOverlay Field = new FieldOverlay();
+ public double[] b = new double[3];
+ private Vector<CoilSubLayer> coilSlices;
+ private static AIDA aida = AIDA.defaultInstance();
+ public TrackStepper stpr = new TrackStepper();
+ public double rmin, rLayer0Mid, rmax, nLayers, zmax;
+
+ /**
+ Constructor for the Subdetectors
+
+ @param rpvect Array containing the postion, momentum , mass and charge of the particle reconstructed.
+ @param det The Detector
+ @param subdetName The subdetector name, EMBarrel, HCALBarrel, MuonBarrel
+ @param layerN The layer number in the subdetector.
+ */
+ public StepConditions(double r, double []rpvect, Detector det, String subdetName, int layerN )
+ {
+ this.rpVect = rpvect;
+ this.subdetName = subdetName;
+ this.layerN = layerN;
+ this.det = det;
+ name = subdetName;
+ this.rNow = stpr.partR(rpVect);
+ layerthickness = r - rNow;
+
+
+ calsub = (CylindricalBarrelCalorimeter)det.getSubdetectors().get(subdetName);
+
+ materials = new HashMap<String, Double>();
+ Layering layers = ((Layered) calsub).getLayering();
+ for ( LayerSlice ls : layers.getLayerStack().getLayer(layerN).getSlices() )
+ {
+ sublayerMat = ls.getMaterial().getName();
+ if (materials.containsKey(sublayerMat))
+ {
+ materialthickness = materials.get(sublayerMat);
+ materialthickness += ls.getThickness();
+ materials.put(sublayerMat, materialthickness);
+ }
+ else
+ materials.put(ls.getMaterial().getName(), ls.getThickness());
+
+ }
+
+ String compoundMaterial = name+"_Material";
+ layerDEdx=0.;
+ //layerthickness = 0.;
+ int i=0;
+ for( String mat : materials.keySet() )
+ {
+ if(dedx==null) dedx = DeDx.instance();
+ double tthk = materials.get(mat).doubleValue();
+ double a1 = (dedx.getDeDx(mat)/10);
+ double e1 = tthk * a1; // energy loss this material
+
+ //layerthickness += tthk;
+ layerDEdx += e1; // sum energy loss per material
+ }
+ //System.out.println("JUDITH ..... LAYERTHICKNESS " +totalthickness );
+ //nLayers = calsub.getLayering().getLayerCount();
+ //rmin = calsub.getInnerRadius();
+ // rmax = calsub.getOuterRadius();
+ //zmax = calsub.getZMax();
+ //rLayer0Mid = calsub.getLayering().getDistanceToLayerSensorMid(0);
+ //double dr = (rmax - rmin)/nLayers;
+ // layerthickness =(layerN!=(nLayers-1))?dr:(dr+dr-(rLayer0Mid-rmin));
+
+ }
+ /**
+ Constructor for the Materials between the subdetectors.
+
+ @param rpvect Array containing the postion, momentum , mass and charge of the particle reconstructed.
+ @param det The Detector
+ @param materialName The name of the material e.g Air, Aluminum
+ @param rToGo The radius to reach.
+ */
+ public StepConditions(double []rpvect, Detector det, String materialName, double rToGo)
+ {
+ this.materialName = materialName;
+ this.det = det;
+ this.rToGo = rToGo;
+ name = materialName;
+ this.rpVect = rpvect;
+ this.rNow = stpr.partR(rpVect);
+ int i = 0; int j=3;//px = rpvect[3]
+ for (i=0; i<3; i++)
+ {
+ pp[i]= rpvect[i+j];
+
+ }
+ mass = rpVect[6];
+ charge = rpVect[7];
+ this.distance = rToGo - rNow;
+ try
+ {
+ manager = MaterialManager.instance();
+ material = manager.findMaterial(materialName);
+ matterDEdx = MaterialCalculator.computeBetheBloch(material, pp, mass, charge, distance);
+ //System.out.println("....... mass " + mass + " charge " + charge + " D " + distance);
+ //System.out.print("MATTER DEDX....." + matterDEdx + "MATERIAL .... " + materialName);
+ //System.out.println("Momentum ... ." + stpr.partPabs(rpVect));
+ }
+ catch (MaterialNotFoundException e)
+ {
+ System.out.println("Error: "+e);
+
+ }
+ }
+
+ /**
+
+ @return The thickness of the layer in the Subdetector
+
+ */
+ public double getLayerThickness()
+ {
+
+ return layerthickness;
+
+ }
+ /**
+
+ @return The thickness of the material in the Subdetector
+
+ */
+ public double getMaterialThickness()
+ {
+ materialthickness = distance;
+ return materialthickness;
+
+ }
+ /**
+
+ @return The material in the Subdetector
+
+ */
+ public String getMaterial()
+ {
+ return sublayerMat;
+
+ }
+ /**
+
+ @return The DEDX of the material in the Subdetector
+
+ */
+ public double getMatterDeDx()
+ {
+ return (matterDEdx/(distance * 10.))/1000.;
+ }
+ /**
+
+ @return The DEDX of the layer in the Subdetector
+
+ */
+ public double getlayerDeDx()
+ {
+ return layerDEdx;
+ }
+ /**
+
+ @return The magntic field at the position.
+
+ */
+ public double[] getField()
+ {
+ double[] b = det.getFieldMap().getField(rpVect);
+
+ return b;
+
+ }
+}
\ No newline at end of file