diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/svt/test/CCDBConstantsLoader.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/svt/test/CCDBConstantsLoader.java deleted file mode 100644 index f753dddfad..0000000000 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/svt/test/CCDBConstantsLoader.java +++ /dev/null @@ -1,194 +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 org.jlab.rec.cvt.svt.test; - -import org.jlab.detector.calib.utils.DatabaseConstantProvider; - -/** - * - * @author ziegler - */ -public class CCDBConstantsLoader { - - public CCDBConstantsLoader() { - // TODO Auto-generated constructor stub - } - - static boolean CSTLOADED = false; - - // static FTOFGeant4Factory geometry ; - private static DatabaseConstantProvider DB; - static DatabaseConstantProvider dbprovider = new DatabaseConstantProvider( - 10, "default"); - - public static final synchronized void Load(int runNb) { - // SVT GEOMETRY PARAMETERS - // fundamentals - int NREGIONS; // number of regions - int[] NSECTORS; // number of sectors in a region - int NFIDUCIALS; // number of survey fiducials on a sector module - int NMODULES; // number of modules in a sector - int NSENSORS; // number of sensors in a module - int NSTRIPS; // number of strips in a layer - int NPADS; // number of pads on High Voltage Rail - double STRIPOFFSETWID; // offset of first intermediate sensor strip from edge of active zone - double READOUTPITCH; // distance between start of strips along front of hybrid sensor - double STEREOANGLE; // total angle swept by sensor strips - int[] STATUS; // whether a region is used in Reconstruction - // - // position and orientation of layers - double PHI0; - double SECTOR0; - double[] REFRADIUS; // outer side of U (inner) module - double LAYERPOSFAC; // location of strip layer within sensor volume - double[] Z0ACTIVE; // Cu edge of hybrid sensor's active volume - // fiducials - double[] SUPPORTRADIUS; // from MechEng drawings, to inner side of wide copper part - double FIDCUX; - double FIDPKX; - double FIDORIGINZ; - double FIDCUZ; - double FIDPKZ0; - double FIDPKZ1; - // - // dimensions of sensors - double ACTIVESENWID; - double PHYSSENWID; - double DEADZNWID; - // - double SILICONTHK; - // - double PHYSSENLEN; - double ACTIVESENLEN; - double DEADZNLEN; - double MICROGAPLEN; // spacing between sensors - // - // dimensions of passive materials - int NMATERIALS; - double PASSIVETHK; - // - // calculated on load() - - double[][] LAYERRADIUS; // radius to strip planes - double LAYERGAPTHK; // distance between pairs of layers within a sector - double MODULELEN; // || DZ | AZ | DZ |MG| DZ | AZ | DZ |MG| DZ | AZ || DZ || - double STRIPLENMAX; // || AZ | DZ |MG| DZ | AZ | DZ |MG| DZ | AZ || - double MODULEWID; // || DZ | AZ | DZ || - double SECTORLEN; - double[][][] SECTORSHIFTDATA; - //double - - // Load the tables - dbprovider = new DatabaseConstantProvider(runNb, "default"); // reset - // using - // the - // new - // run - // load the geometry tables - dbprovider.loadTable("/geometry/cvt/svt/svt"); - dbprovider.loadTable("/geometry/cvt/svt/region"); - dbprovider.loadTable("/geometry/cvt/svt/support"); - dbprovider.loadTable("/geometry/cvt/svt/fiducial"); - dbprovider.loadTable("/geometry/cvt/svt/material/box"); - dbprovider.loadTable("/geometry/cvt/svt/material/tube"); - dbprovider.loadTable("/geometry/cvt/svt/alignment"); - - // read constants from svt table - NREGIONS = dbprovider.getInteger("/geometry/cvt/svt/svt/nRegions", 0 ); - NMODULES = dbprovider.getInteger("/geometry/cvt/svt/svt/nModules", 0 ); - NSENSORS = dbprovider.getInteger("/geometry/cvt/svt/svt/nSensors", 0 ); - NSTRIPS = dbprovider.getInteger("/geometry/cvt/svt/svt/nStrips", 0 ); - NFIDUCIALS = dbprovider.getInteger("/geometry/cvt/svt/svt/nFiducials", 0 ); - NPADS = dbprovider.getInteger("/geometry/cvt/svt/svt/nPads", 0 ); - - READOUTPITCH = dbprovider.getDouble("/geometry/cvt/svt/svt/readoutPitch", 0 ); - STEREOANGLE = Math.toRadians(dbprovider.getDouble("/geometry/cvt/svt/svt/stereoAngle", 0 )); - PHI0 = Math.toRadians(dbprovider.getDouble("/geometry/cvt/svt/svt/phiStart", 0 )); - SECTOR0 = Math.toRadians(dbprovider.getDouble("/geometry/cvt/svt/svt/zRotationStart", 0 )); - LAYERPOSFAC = dbprovider.getDouble("/geometry/cvt/svt/svt/modulePosFac", 0 ); - - SILICONTHK = dbprovider.getDouble("/geometry/cvt/svt/svt/siliconThk", 0 ); - PHYSSENLEN = dbprovider.getDouble("/geometry/cvt/svt/svt/physSenLen", 0 ); - PHYSSENWID = dbprovider.getDouble("/geometry/cvt/svt/svt/physSenWid", 0 ); - ACTIVESENLEN = dbprovider.getDouble("/geometry/cvt/svt/svt/activeSenLen", 0 ); - ACTIVESENWID = dbprovider.getDouble("/geometry/cvt/svt/svt/activeSenWid", 0 ); - DEADZNLEN = dbprovider.getDouble("/geometry/cvt/svt/svt/deadZnLen", 0 ); - DEADZNWID = dbprovider.getDouble("/geometry/cvt/svt/svt/deadZnWid", 0 ); - MICROGAPLEN = dbprovider.getDouble("/geometry/cvt/svt/svt/microGapLen", 0 ); - - FIDCUX = dbprovider.getDouble("/geometry/cvt/svt/fiducial/CuX", 0 ); - FIDPKX = dbprovider.getDouble("/geometry/cvt/svt/fiducial/PkX", 0 ); - FIDORIGINZ = dbprovider.getDouble("/geometry/cvt/svt/fiducial/OriginZ", 0 ); - FIDCUZ = dbprovider.getDouble("/geometry/cvt/svt/fiducial/CuZ", 0 ); - FIDPKZ0 = dbprovider.getDouble("/geometry/cvt/svt/fiducial/PkZ0", 0 ); - FIDPKZ1 = dbprovider.getDouble("/geometry/cvt/svt/fiducial/PkZ1", 0 ); - - // calculate derived constants - int NLAYERS = NMODULES*NREGIONS; - MODULELEN = NSENSORS*(ACTIVESENLEN + 2*DEADZNLEN) + (NSENSORS - 1)*MICROGAPLEN; - STRIPLENMAX = MODULELEN - 2*DEADZNLEN; - MODULEWID = ACTIVESENWID + 2*DEADZNWID; - STRIPOFFSETWID = dbprovider.getDouble("/geometry/cvt/svt/svt/stripStart", 0 ); - LAYERGAPTHK = dbprovider.getDouble("/geometry/cvt/svt/svt/layerGapThk", 0 ); - - // read constants from region and support table - NSECTORS = new int[NREGIONS]; - STATUS = new int[NREGIONS]; - Z0ACTIVE = new double[NREGIONS]; - REFRADIUS = new double[NREGIONS]; // used to derive LAYERRADIUS - SUPPORTRADIUS = new double[NREGIONS]; // used to build volumes - LAYERRADIUS = new double[NREGIONS][NMODULES]; // used to build strips - - for( int regionIdx = 0; regionIdx < NREGIONS; regionIdx++ ) { - NSECTORS[regionIdx] = dbprovider.getInteger("/geometry/cvt/svt/region/nSectors", regionIdx ); - STATUS[regionIdx] = dbprovider.getInteger("/geometry/cvt/svt/region/status", regionIdx ); - Z0ACTIVE[regionIdx] = dbprovider.getDouble("/geometry/cvt/svt/region/zStart", regionIdx ); // Cu edge of hybrid sensor's active volume - REFRADIUS[regionIdx] = dbprovider.getDouble("/geometry/cvt/svt/region/UlayerOuterRadius", regionIdx); // radius to outer side of U (inner) module - SUPPORTRADIUS[regionIdx] = dbprovider.getDouble("/geometry/cvt/svt/region/CuSupportInnerRadius", regionIdx); // radius to inner side of heatSinkRidge - - for( int m = 0; m < NMODULES; m++ ) - { - switch( m ) - { - case 0: // U = lower / inner - LAYERRADIUS[regionIdx][m] = REFRADIUS[regionIdx] - LAYERPOSFAC*SILICONTHK; - break; - case 1: // V = upper / outer - LAYERRADIUS[regionIdx][m] = REFRADIUS[regionIdx] + LAYERGAPTHK + LAYERPOSFAC*SILICONTHK; - break; - } - //System.out.println("LAYERRADIUS "+ LAYERRADIUS[region][m]); - } - } - - SECTORSHIFTDATA = new double[NSECTORS[2]][3][7]; - int alignIdx=0; - for( int regionIdx = 0; regionIdx < NREGIONS; regionIdx++ ) { - for(int sectorIdx = 0; sectorIdx Constants.MODULELENGTH + Constants.interTol * 2) { - return new double[]{Double.NaN, 0, Double.NaN, Double.NaN, Double.NaN, Double.NaN}; - } - // once there is a trk, the cross should be well calculated - //if the local cross is not in the fiducial volume it is not physical - if ((trkDir != null && (LC_x < 0 || LC_x > Constants.ACTIVESENWIDTH + Constants.TOLTOMODULEEDGE)) - || (trkDir != null && (LC_z < -Constants.interTol || LC_z > Constants.MODULELENGTH + Constants.interTol))) { - return new double[]{Double.NaN, 0, Double.NaN, Double.NaN, Double.NaN, Double.NaN}; - } - - //if(vals[5]Constants.Z0[upperlayer-1]+Constants.MODULELENGTH+Constants.interTol) { - // return new double[] {Double.NaN,0,Double.NaN,Double.NaN, Double.NaN, Double.NaN}; - //} - double[] values = new double[6]; - if (frame.equals("lab")) { - values = vals; - } - if (frame.equals("local")) { - values = new double[]{LC_x, 0, LC_z, LCErr_x, 0, LCErr_z}; - } - - return values; - - } - - private double getCorrectedStrip(int sector, int upperlayer, double s2, - Vector3D trkDir, double ZalongModule) { - double s2corr = s2; - // second iteration: there is a track direction - if (trkDir != null) { - double stripCorr = getStripIndexShift(sector, upperlayer, trkDir, s2, ZalongModule); - if (s2 > 1) { - s2corr = s2 + stripCorr; - } - if (s2 == 1) { - if (stripCorr >= 0) { - s2corr = s2 + stripCorr; - } - if (stripCorr < 0) { - s2corr = s2; - } - } - } - return s2corr; - } - - public double calcNearestStrip(double X, double Y, double Z, int layer, int sect) { - - Point3D LocPoint = this.transformToFrame(sect, layer, X, Y, Z, "local", ""); - - double x = LocPoint.x(); - double z = LocPoint.z(); - - double alpha = Constants.STEREOANGLE / (double) (Constants.NSTRIP - 1); - - double b = Constants.ACTIVESENWIDTH; - double P = Constants.PITCH; - - double s = -1; - - if (layer % 2 == 1) {//layers 1,3,5 == bottom ==i ==>(1) : regular configuration - //m1,b1 - s = (int) Math.floor((-x + b + alpha * z + 0.5 * P - Constants.STRIPTSTART) / (alpha * z + P)); - - double delta = 99999; - double sdelta = delta; - double newStrip = s; - for (int i = -1; i < 2; i++) { - double sp = s + (double) i; - double x_calc = -Math.tan((sp - 1) * alpha) * z + b - sp * P + 0.5 * P - Constants.STRIPTSTART; - - if (Math.abs(x - x_calc) < delta) { - sdelta = x - x_calc; - delta = Math.abs(sdelta); - newStrip = sp; - } - } - - s = newStrip; - for (int i = -10; i <= 10; i++) { - double sp = s + (double) i * 0.1; - double x_calc = -Math.tan((sp - 1) * alpha) * z + b - sp * P + 0.5 * P - Constants.STRIPTSTART; - - if (Math.abs(x - x_calc) < delta) { - sdelta = x - x_calc; - delta = Math.abs(sdelta); - newStrip = sp; - } - } - s = newStrip; - - // charge sharing digitization routine in GEMC - /*if(sdelta>(P+z*Math.tan(alpha))/4.) - s= newStrip-0.5; - if(sdelta<-(P+z*Math.tan(alpha))/4.) - s= newStrip+0.5; - //s=(-x+b+alpha*z)/(alpha*z+P); */ - //System.out.println(" nearest strip "+s+" at ("+X+", "+Y+", "+Z+"); delta = "+delta); - } - if (layer % 2 == 0) { - //layers 2,4,6 == top ==j ==>(2) : regular configuration - //m2,b2 - s = (int) Math.floor((x + alpha * z + 0.5 * P - Constants.STRIPTSTART) / (alpha * z + P)); - - double delta = 99999; - double sdelta = delta; - double newStrip = s; - for (int i = -1; i < 2; i++) { - double sp = s + (double) i; - double x_calc = Math.tan((sp - 1) * alpha) * z + sp * P - 0.5 * P + Constants.STRIPTSTART; - - if (Math.abs(x - x_calc) < delta) { - sdelta = x - x_calc; - delta = Math.abs(sdelta); - newStrip = sp; - } - } - - s = newStrip; - for (int i = -10; i <= 10; i++) { - double sp = s + (double) i * 0.1; - double x_calc = Math.tan((sp - 1) * alpha) * z + sp * P - 0.5 * P + Constants.STRIPTSTART; - - if (Math.abs(x - x_calc) < delta) { - sdelta = x - x_calc; - delta = Math.abs(sdelta); - newStrip = sp; - } - } - s = newStrip; - // charge sharing digitization routine in GEMC - /*if(sdelta>(P+z*Math.tan(alpha))/4.) - s= newStrip+0.5; - if(sdelta<-(P+z*Math.tan(alpha))/4.) - s= newStrip-0.5; - //s=(x+alpha*z)/(alpha*z+P); */ - //System.out.println(" nearest strip "+s+" at ("+X+", "+Y+", "+Z+"); delta = "+delta); - } - if (s <= 1) { - s = 1; - } - if (s >= 256) { - s = 256; - } - - //System.out.println(" layer "+layer+" sector "+sect+" strip "+s); - return s; - } - //**** - - public double getSingleStripResolution(int lay, int strip, double Z) { // as a function of local z - double Strip = (double) strip; - double StripUp = Strip + 1; - if (strip == Constants.NSTRIP) { - StripUp = (double) Constants.NSTRIP; //edge strip - } - double StripDown = Strip - 1; - if (strip == 1) { - StripDown = 1; //edge strip - } - - double pitchToNextStrp = Math.abs(getXAtZ(lay, (double) StripUp, Z) - getXAtZ(lay, (double) Strip, Z)); // this is P- in the formula below - double pitchToPrevStrp = Math.abs(getXAtZ(lay, (double) StripDown, Z) - getXAtZ(lay, (double) Strip, Z)); // this is P+ in the formula below - - // For a given strip (for which we estimate the resolution), P+ is the pitch to the strip above (at z position) and P- to that below in the local coordinate system of the module. - // The current design of the BST is simulated in gemc such that each strip provides hit-no-hit information, and the single strip resolution is - // therefore given by the variance, - // sigma^2 = (2/[P+ + P-]) {integral_{- P-/2}^{P+/2) x^2 dx -[integral_{- P-/2}^{P+/2) x dx]^2} - //this gives, sigma^2 = [1/(P+ + P-)]*[ (P+^3 + P-^3)/12 - (P+^2 - P-^2)^2/[32(P+ + P-)] ] - double Pp2 = pitchToNextStrp * pitchToNextStrp; - double Pp3 = pitchToNextStrp * Pp2; - double Pm2 = pitchToPrevStrp * pitchToPrevStrp; - double Pm3 = pitchToPrevStrp * Pm2; - double Psum = pitchToNextStrp + pitchToPrevStrp; - double invPsum = 1. / Psum; - double firstTerm = (Pp3 + Pm3) / 12.; - double secondTerm = ((Pp2 - Pm2) * (Pp2 - Pm2) * invPsum) / 32.; - double strip_sigma_sq = (firstTerm - secondTerm) * invPsum; - - double strip_sigma = Math.sqrt(strip_sigma_sq); - - return strip_sigma; - } - //**** - - public double getDOCAToStrip(int sector, int layer, double centroidstrip, Point3D point0) { - - // local angle of line graded from 0 to 3 deg. - double ialpha = (centroidstrip - 1) * Constants.STEREOANGLE / (double) (Constants.NSTRIP - 1); - //the active area starts at the first strip - double interc = (centroidstrip - 0.5) * Constants.PITCH + Constants.STRIPTSTART; - - // Equation for strip line is x = mz + b [i.e. z is the direction of the length of the module] - // ------------------------------------- - double m1 = -Math.tan(ialpha); - double m2 = Math.tan(ialpha); - double b1 = Constants.ACTIVESENWIDTH - interc; - double b2 = interc; - - Vector3D vecAlongStrip = new Vector3D(); - Point3D pointOnStrip = new Point3D(); - Point3D LocPoint = this.transformToFrame(sector, layer, point0.x(), point0.y(), point0.z(), "local", ""); - - if (layer % 2 == 0) { //layers 2,4,6 == top ==j ==>(2) : regular configuration - vecAlongStrip = new Vector3D(m2, 0, 1).asUnit(); - pointOnStrip = new Point3D(b2, 0, 0); - } - if (layer % 2 == 1) { //layers 1,3,5 == bottom ==i ==>(1) : regular configuration - vecAlongStrip = new Vector3D(m1, 0, 1).asUnit(); - pointOnStrip = new Point3D(b1, 0, 0); - } - - Vector3D r = LocPoint.vectorTo(pointOnStrip); // - Vector3D d = r.cross(vecAlongStrip); - - Line3D l = new Line3D(pointOnStrip, pointOnStrip.toVector3D().add(vecAlongStrip.multiply(10))); - //fix for hemisphere - return d.y()*Math.signum(this.findBSTPlaneNormal(sector, layer).y()); - - } - //**** - // in the local coordinate system - - public double getXAtZ(int layer, double centroidstrip, double Z) { - double X = 0; - // local angle of line graded from 0 to 3 deg. - double ialpha = (centroidstrip - 1) * Constants.STEREOANGLE / (double) (Constants.NSTRIP - 1); - //the active area starts at the first strip - double interc = (centroidstrip - 0.5) * Constants.PITCH + Constants.STRIPTSTART; - - // Equation for strip line is x = mz + b [i.e. z is the direction of the length of the module] - // ------------------------------------- - double m1 = -Math.tan(ialpha); - double m2 = Math.tan(ialpha); - double b1 = Constants.ACTIVESENWIDTH - interc; - double b2 = interc; - - if (layer % 2 == 0) { //layers 2,4,6 == top ==j ==>(2) : regular configuration - - X = m2 * Z + b2; - } - if (layer % 2 == 1) { //layers 1,3,5 == bottom ==i ==>(1) : regular configuration - - X = m1 * Z + b1; - } - - return X; - } - - //*** - public double getStripIndexShift(int sector, int layer, Vector3D trkDir, double s2, double z) { - - double tx = trkDir.x(); - double ty = trkDir.y(); - Vector3D trkDir_t = new Vector3D(tx / Math.sqrt(tx * tx + ty * ty), ty / Math.sqrt(tx * tx + ty * ty), 0); - Vector3D n = findBSTPlaneNormal(sector, layer); - - if (org.jlab.rec.cvt.Constants.isCosmicsData() && Math.acos(n.dot(trkDir_t)) > Math.PI / 2) // flip the direction of the track for y<0 for cosmics - { - trkDir_t = new Vector3D(-trkDir_t.x(), -trkDir_t.y(), 0); - } - - double TrkToPlnNormRelatAngl = Math.acos(n.dot(trkDir_t)); - double sign = Math.signum(n.cross(trkDir_t).z()); - // int shift = (int)((Constants.LAYRGAP*n.cross(trkDir_t).z())/Constants.PITCH); - // - //correction to the pitch to take into account the grading of the angle -- get the upper or lower strip depending on the trkdir - double pitchcorr = Constants.PITCH; - - if (s2 > 2 && s2 < 255) { - double pitchToNextStrp = Math.abs(getXAtZ(layer, (double) s2 + 1, z) - getXAtZ(layer, (double) s2, z)); - double pitchToPrevStrp = Math.abs(getXAtZ(layer, (double) s2 - 1, z) - getXAtZ(layer, (double) s2, z)); - pitchcorr = (pitchToNextStrp + pitchToPrevStrp) / 2.; - } - if (s2 <= 2) { - pitchcorr = Math.abs(getXAtZ(layer, (double) s2 + 1, z) - getXAtZ(layer, (double) s2, z)); - } - if (s2 == 256) { - pitchcorr = Math.abs(getXAtZ(layer, (double) s2 - 1, z) - getXAtZ(layer, (double) s2, z)); - } - - double layerGap = Constants.MODULERADIUS[1][0] - Constants.MODULERADIUS[0][0]; - - double shift = sign * layerGap * Math.tan(TrkToPlnNormRelatAngl) / pitchcorr; - - return -shift; - } - //*** - - public double planeNormDotTrkDir(int sector, int layer, Point3D trkDir, double s2, double z) { - double tx = trkDir.x(); - double ty = trkDir.y(); - Vector3D trkDir_t = new Vector3D(tx / Math.sqrt(tx * tx + ty * ty), ty / Math.sqrt(tx * tx + ty * ty), 0); - Vector3D n = findBSTPlaneNormal(sector, layer); - - return Math.abs(n.dot(trkDir_t)); - } - - //*** - public Point3D intersectionOfHelixWithPlane(int layer, int sector, Helix helix) { - - int nstep = 1; - double stepSize = 0.001; - - double Theta = Math.atan2((Constants.ACTIVESENWIDTH / 2), Constants.MODULERADIUS[layer - 1][sector - 1]); - double RMin = Constants.MODULERADIUS[layer - 1][sector - 1]; - double RMax = RMin / Math.cos(Theta); - double R = RMin; - - Point3D InterPoint = helix.getPointAtRadius(R); - - double minDelta = RMax - RMin; - - while (R < RMax) { - - Point3D I = helix.getPointAtRadius(R); - Vector3D Inorm = I.toVector3D().asUnit(); - - double Rinter = RMin / findBSTPlaneNormal(sector, layer).dot(Inorm); - double y_rho = Math.sqrt(I.x() * I.x() + I.y() * I.y()); - if (Math.abs(Rinter - y_rho) < minDelta) { - InterPoint = I; - minDelta = Math.abs(Rinter - y_rho); - } - R += nstep * stepSize; - nstep++; - - } - return InterPoint; - - } - - public Point3D recalcCrossFromTrajectoryIntersWithModulePlanes(int s, double s1, double s2, - int l1, int l2, double trajX1, double trajY1, double trajZ1, - double trajX2, double trajY2, double trajZ2) { - Point3D LocPoint1 = this.transformToFrame(s, l1, trajX1, trajY1, trajZ1, "local", ""); - Point3D LocPoint2 = this.transformToFrame(s, l2, trajX2, trajY2, trajZ2, "local", ""); - double m = (LocPoint1.x() - LocPoint2.x()) / (LocPoint1.z() - LocPoint2.z()); - double b = LocPoint1.x() - m * LocPoint1.z(); - - double ialpha1 = (s1 - 1) * org.jlab.rec.cvt.svt.Constants.STEREOANGLE / (double) (org.jlab.rec.cvt.svt.Constants.NSTRIP - 1); - //the active area starts at the first strip - double interc1 = (s1 - 0.5) * org.jlab.rec.cvt.svt.Constants.PITCH + org.jlab.rec.cvt.svt.Constants.STRIPTSTART; - double ialpha2 = (s2 - 1) * org.jlab.rec.cvt.svt.Constants.STEREOANGLE / (double) (org.jlab.rec.cvt.svt.Constants.NSTRIP - 1); - //the active area starts at the first strip - double interc2 = (s2 - 0.5) * org.jlab.rec.cvt.svt.Constants.PITCH + org.jlab.rec.cvt.svt.Constants.STRIPTSTART; - - // Equation for strip line is x = mz + b [i.e. z is the direction of the length of the module] - // ------------------------------------- - double m1 = -Math.tan(ialpha1); - double m2 = Math.tan(ialpha2); - double b1 = org.jlab.rec.cvt.svt.Constants.ACTIVESENWIDTH - interc1; - double b2 = interc2; - - double z1 = (b - b1) / (m1 - m); - double x1 = m1 * z1 + b1; - double z2 = (b - b2) / (m2 - m); - double x2 = m2 * z2 + b2; - - Point3D Point1 = this.transformToFrame(s, l1, x1, 0, z1, "lab", ""); - Point3D Point2 = this.transformToFrame(s, l2, x2, 0, z2, "lab", ""); - // unit vec along dir of track - Vector3D t = new Vector3D(Point2.x() - Point1.x(), Point2.y() - Point1.y(), Point2.z() - Point1.z()).asUnit(); - //normal to plane of module - Vector3D n = this.findBSTPlaneNormal(s, l1); - //path length tranversed inbetween modules - double l = (org.jlab.rec.cvt.svt.Constants.MODULERADIUS[l2 - 1][0] - org.jlab.rec.cvt.svt.Constants.MODULERADIUS[l1 - 1][0]) / (n.dot(t)); - //Point inbetween the modules - - Point3D Point = new Point3D(Point1.x() + t.x() * ((double) l / 2), Point1.y() + t.y() * ((double) l / 2), Point1.z() + t.z() * ((double) l / 2)); - - return Point; - } - - public double[][] getStripEndPoints(int strip, int slyr) { //1 top, 0 bottom - - double[][] X = new double[2][2]; - - double z1 = 0; - double x1 = 0; - double z2 = 0; - double x2 = 0; - - // Equation for strip line is x = mz + b [i.e. z is the direction of the length of the module] - // ------------------------------------- - if (slyr == 0) { - double s1 = strip; - double ialpha1 = (s1 - 1) * Constants.STEREOANGLE / (double) (Constants.NSTRIP - 1); - //the active area starts at the first strip - double interc1 = (s1 - 0.5) * Constants.PITCH + Constants.STRIPTSTART; - double m1 = -Math.tan(ialpha1); - double b1 = Constants.ACTIVESENWIDTH - interc1; - - z1 = 0; - x1 = m1 * z1 + b1; - z2 = Constants.MODULELENGTH; - x2 = m1 * z2 + b1; - - if (x2 < 0) { - x2 = 0; - z2 = -b1 / m1; - } - } - - if (slyr == 1) { - double s2 = strip; - double ialpha2 = (s2 - 1) * Constants.STEREOANGLE / (double) (Constants.NSTRIP - 1); - //the active area starts at the first strip - double interc2 = (s2 - 0.5) * Constants.PITCH + Constants.STRIPTSTART; - double m2 = Math.tan(ialpha2); - double b2 = interc2; - - z1 = 0; - x1 = m2 * z1 + b2; - z2 = Constants.MODULELENGTH; - x2 = m2 * z2 + b2; - - if (x2 > Constants.ACTIVESENWIDTH) { - x2 = Constants.ACTIVESENWIDTH; - z2 = (x2 - b2) / m2; - } - } - X[0][0] = x1; - X[0][1] = z1; - X[1][0] = x2; - X[1][1] = z2; - - return X; - - } - - public static void main(String arg[]) throws FileNotFoundException { - - Constants.Load(); - - int s1 = 1; - int s2 = 1; - - GeometryOld geo = new GeometryOld(); - - System.out.println(" old geom strip inter " + geo.getLocCoord(s1, s2)[0] + "," + geo.getLocCoord(s1, s2)[1]); - //end points for the first strip in local system - double[][] X = geo.getStripEndPoints(s1, 0); // bottom layer - double[][] Y = geo.getStripEndPoints(s2, 1); //top layer - System.out.println(" ep1 loc x " + X[0][0] + ", y" + X[0][1] + ", x " + X[1][0] + ", y " + X[1][1] + " ep2 loc x " + Y[0][0] + ", y" + Y[0][1] + ", x " + Y[1][0] + ", y " + Y[1][1]); - //transform to sector 1 layer 1 in lab frame - Point3D EP1u = geo.transformToFrame(1, 1, X[0][0], 0, X[0][1], "lab", ""); - Point3D EP2u = geo.transformToFrame(1, 1, X[1][0], 0, X[1][1], "lab", ""); - //transform to sector 1 layer 2 in lab frame - Point3D EP1v = geo.transformToFrame(1, 2, Y[0][0], 0, Y[0][1], "lab", ""); - Point3D EP2v = geo.transformToFrame(1, 2, Y[1][0], 0, Y[1][1], "lab", ""); - System.out.println(EP1u.toString()); - System.out.println(EP2u.toString()); - System.out.println(EP1v.toString()); - System.out.println(EP2v.toString()); - - //System.out.println(geo.calcNearestStrip(25.66, -66.55, 1.37,2, 10) ); - //System.out.println(geo.transformToFrame(8, 1, 66.3, 7.8, 38.6, "local", "").z()-Constants.ACTIVESENLEN*2-2*0.835-Constants.ACTIVESENLEN/2); - /* - Line3D stripLine1 = svt.createStrip(s1-1); - Line3D stripLine2 = svt.createStrip(s2-1); - stripLine2.rotateZ(Math.toRadians(180)); - Transformation3D transform = new Transformation3D(); - transform.translateXYZ( -svt.DEADZNWID + svt.MODULEWID/2 , 0, -svt.DEADZNLEN + svt.MODULELEN/2 ); // align - - transform.apply( stripLine1 ); - transform.apply( stripLine2 ); - */ - /* - double[] LC = geo.getLocCoord(136,39); - double LC_x = LC[0]; - double LC_z = LC[1]; - - Point3D crPoint = geo.transformToFrame( 10, 2-1, LC_x, 0, LC_z, "lab", "middle"); - - - double m1 = (stripLine1.origin().x() - stripLine1.end().x() )/(stripLine1.origin().z() - stripLine1.end().z() ); - double m2 = (stripLine2.origin().x() - stripLine2.end().x() )/(stripLine2.origin().z() - stripLine2.end().z() ); - double b1 = stripLine1.origin().x() - stripLine1.origin().z()*m1; - double b2 = stripLine2.origin().x() - stripLine2.origin().z()*m2; - double z = (b2-b1)/(m1-m2); - double x = m1*z +b1; - System.out.println(" x "+x +" z "+z+" my geo "+crPoint.toString()); - - System.out.println(geo.getPlaneModuleOrigin(1, 1).toString() ); - */ - /* - int l = 1; - int s = 6; - double s10 = geo.calcNearestStrip(0., Constants.MODULERADIUS[l-1][s-1], 0, l, s); - double s20 = geo.calcNearestStrip(0., Constants.MODULERADIUS[l][s-1], 0, l+1, s); - - double s1 = geo.calcNearestStrip(0.5, Constants.MODULERADIUS[l-1][s-1], 0, l, s); - double s2 = geo.calcNearestStrip(0.5, Constants.MODULERADIUS[l][s-1], 0, l+1, s); - - - System.out.println("D "+geo.getLocCoord(s10, s20)[0]+","+geo.getLocCoord(s10, s20)[1]+" ; "+geo.getLocCoord(s1, s2)[0]+","+geo.getLocCoord(s1, s2)[1]); - */ - //SVTConstants.VERBOSE = true; - DatabaseConstantProvider cp = new DatabaseConstantProvider(190,"default"); - cp = SVTConstants.connect( cp ); - // create the factory - //SVTStripFactory svtShiftedStripFactory = new SVTStripFactory( cp, true ); - SVTStripFactory svtIdealStripFactory = new SVTStripFactory( cp, false ); - // load alignment shifts and print them out; - //SVTConstants.loadAlignmentShifts( cp ); - - // set parameters. - int myStrip = 1; // pick a strip, layer, sector - int myLayer = 1; - int mySector = 1; - //int myModule = 1; // corresponding module and region. - //int myRegion = 2; - - System.out.format("\nmyStrip = %1d, mySector = %1d, myLayer = %1d\n\n",myStrip,mySector,myLayer); - - // set indices. the method wants the index not the acutal number which differ by 1. - int myStripIndex = myStrip-1; - int myLayerIndex = myLayer-1; - int mySectorIndex = mySector-1; - - // shifted strip in lab coordinates - Line3d myCLASstriplineShifted = svtIdealStripFactory.getIdealStrip(myLayerIndex, mySectorIndex, myStripIndex); - System.out.println( "myLabIdeal = "+myCLASstriplineShifted.toString()); - - // ideal strip in lab coordinates - Line3d myCLASstriplineIdeal = svtIdealStripFactory.getIdealStrip(myLayerIndex+1, mySectorIndex, myStripIndex); - System.out.println( "myLabIdeal = "+myCLASstriplineIdeal.toString()); - } - -}