From 9cfaf3ff44b028d083f5d2bd16101af3ad86c8c0 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Sun, 27 Jan 2019 17:52:45 -0500 Subject: [PATCH 001/104] FTTrk first commit --- etc/bankdefs/hipo/FT.json | 17 ++ .../org/jlab/rec/ft/trk/FTTRKCluster.java | 14 ++ .../jlab/rec/ft/trk/FTTRKConstantsLoader.java | 129 ++++++++++ .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 147 +++++++++++ .../java/org/jlab/rec/ft/trk/FTTRKHit.java | 228 ++++++++++++++++++ .../jlab/rec/ft/trk/FTTRKReconstruction.java | 125 ++++++++++ 6 files changed, 660 insertions(+) create mode 100644 reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java create mode 100644 reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java create mode 100644 reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java create mode 100644 reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java create mode 100644 reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java diff --git a/etc/bankdefs/hipo/FT.json b/etc/bankdefs/hipo/FT.json index 7468b3a7f8..fd21a4f707 100644 --- a/etc/bankdefs/hipo/FT.json +++ b/etc/bankdefs/hipo/FT.json @@ -68,6 +68,23 @@ {"name":"energy", "id":10, "type":"float", "info":"Cluster total energy" } ] }, + { + "bank": "FTTRK::hits", + "group": 21321, + "info": "Reconstructed Hits in FT hodoscope", + "items": [ + {"name":"sector", "id":2, "type":"int8", "info":"sector number"}, + {"name":"layer", "id":3, "type":"int8", "info":"layer number"}, + {"name":"component", "id":4, "type":"int16", "info":"component number"}, + {"name":"x", "id":5, "type":"float", "info":"Hit X position (cm)" }, + {"name":"y", "id":6, "type":"float", "info":"Hit Y position (cm)" }, + {"name":"z", "id":7, "type":"float", "info":"Hit Z position (cm)" }, + {"name":"energy", "id":8, "type":"float", "info":"Hit Energy" }, + {"name":"time", "id":9, "type":"float", "info":"Hit Time" }, + {"name":"hitID", "id":10, "type":"int16", "info":"Hit Pointer to ADC bank"}, + {"name":"clusterID", "id":11, "type":"int16", "info":"Hit Pointer to Cluster Bank"} + ] + }, { "bank": "FT::particles", "group": 20924, diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java new file mode 100644 index 0000000000..25b1b1cfa3 --- /dev/null +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java @@ -0,0 +1,14 @@ +/* + * 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.ft.trk; + +/** + * + * @author devita + */ +public class FTTRKCluster { + +} diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java new file mode 100644 index 0000000000..a141034478 --- /dev/null +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java @@ -0,0 +1,129 @@ +/* + * 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.ft.trk; + +/** + * + * @author devita + */ +public class FTTRKConstantsLoader { + + FTTRKConstantsLoader() { + } + + // geometry constants + public static final int Nlayers = 4; + public static int Nstrips=768 ;// Number of strips + public static int Halfstrips ; // In the middle of the FMT, 320 strips are split in two. + public static int Sidestrips=312 ; + public static double[] Zlayer = {175, 176, 177, 178}; //Give z-coordinate of the layer + public static double[] Alpha = {0,90,0,90}; //Give the rotation angle to apply + public static double Pitch=0.05; //strip width + public static double Beamhole=7;//Radius of the hole in the center for the beam. +// public static double Interstrip ; //inter strip + public static double YCentral; + public static double Rmax; + public static double[][] stripsXloc; //Give the local end-points x-coordinates of the strip segment + public static double[][] stripsYloc; //Give the local end-points y-coordinates of the strip segment + public static double[] stripsXlocref; //Give the local ref-points x-coordinates of the strip segment + public static double[] stripsYlocref; //Give the local ref-points y-coordinates of the strip segment + public static double[][][] stripsX; //Give the end-points x-coordinates of the strip segment rotated in the correct frame for the layer + public static double[][][] stripsY; //Give the end-points y-coordinates of the strip segment + public static double[] stripslength; //Give the strip length + + public static synchronized void Load() { + + Sidestrips = (Nstrips -2*Halfstrips)/2; + YCentral = (double)Halfstrips*Pitch/2.; + Rmax = Pitch*(Halfstrips + 2*Sidestrips)/2.; + stripsXloc = new double[Nstrips][2]; + stripsYloc = new double[Nstrips][2]; + stripsXlocref = new double[Nstrips]; + stripsYlocref = new double[Nstrips]; + stripsX = new double[Nlayers][Nstrips][2]; + stripsY = new double[Nlayers][Nstrips][2]; + stripslength = new double[Nstrips]; + + + for(int i=0;i=0 && i<320) + region =1; + if(i>=320 && i<512) + region =2; + if(i>=512 && i<832) + region =3; + if(i>=832 && i<1024) + region =4; + + return region; + } + + +} diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java new file mode 100644 index 0000000000..4c30e21334 --- /dev/null +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java @@ -0,0 +1,147 @@ +/* + * 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.ft.trk; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.swing.JFrame; +import org.jlab.clas.physics.GenericKinematicFitter; +import org.jlab.clas.physics.PhysicsEvent; +import org.jlab.clas.reco.ReconstructionEngine; +import org.jlab.groot.data.H1F; +import org.jlab.groot.graphics.EmbeddedCanvas; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.io.evio.EvioDataBank; +import org.jlab.io.evio.EvioDataEvent; +import org.jlab.io.evio.EvioSource; + +/** + * + * @author devita + */ +public class FTTRKEngine extends ReconstructionEngine { + + public FTTRKEngine() { + super("FTTRK", "devita", "1.0"); + } + + FTTRKReconstruction reco; + + @Override + public boolean init() { + reco = new FTTRKReconstruction(); + reco.debugMode=0; + + String[] tables = new String[]{ + "/calibration/ft/fthodo/charge_to_energy", + "/calibration/ft/fthodo/time_offsets", + "/calibration/ft/fthodo/status", + "/geometry/ft/fthodo" + }; + requireConstants(Arrays.asList(tables)); + this.getConstantsManager().setVariation("default"); + + return true; + } + + @Override + public boolean processDataEvent(DataEvent event) { + List allHits = new ArrayList(); + List selectedHits = new ArrayList(); + List clusters = new ArrayList(); + + // update calibration constants based on run number if changed + int run = setRunConditionsParameters(event); + + if(run>=0) { + // get hits fron banks + allHits = reco.initFTTRK(event,this.getConstantsManager(), run); +// // select good hits and order them by energy +// selectedHits = reco.selectHits(allHits); +// // create clusters +// clusters = reco.findClusters(selectedHits); + // write output banks + reco.writeBanks(event, selectedHits, clusters); + } + return true; + } + + public int setRunConditionsParameters(DataEvent event) { + int run = -1; + if(event.hasBank("RUN::config")==false) { + System.out.println("RUN CONDITIONS NOT READ!"); + } + + if(event instanceof EvioDataEvent) { + EvioDataBank bank = (EvioDataBank) event.getBank("RUN::config"); + run = bank.getInt("Run")[0]; + } + else { + DataBank bank = event.getBank("RUN::config"); + run = bank.getInt("run")[0]; + } + return run; + } + + + public static void main (String arg[]) { + FTTRKEngine cal = new FTTRKEngine(); + cal.init(); +// String input = "/Users/devita/data/out_clasdispr.00.e11.000.emn0.75tmn.09.xs65.61nb.dis.1.V5.hipo"; +// HipoDataSource reader = new HipoDataSource(); + String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/out_header.ev"; + EvioSource reader = new EvioSource(); + reader.open(input); + + // initialize histos + H1F h1 = new H1F("Cluster Energy",100, 0.,5.); + h1.setOptStat(Integer.parseInt("1111")); h1.setTitleX("Cluster Energy (GeV)"); + H1F h2 = new H1F("Energy Resolution",100, -1, 1); + h2.setOptStat(Integer.parseInt("1111")); h2.setTitleX("Energy Resolution(GeV)"); + H1F h3 = new H1F("Theta Resolution",100, -2, 2); + h3.setOptStat(Integer.parseInt("1111")); h3.setTitleX("Theta Resolution(deg)"); + H1F h4 = new H1F("Phi Resolution",100, -10, 10); + h4.setOptStat(Integer.parseInt("1111")); h4.setTitleX("Phi Resolution(deg)"); + H1F h5 = new H1F("Time Resolution",100, -10, 10); + h5.setOptStat(Integer.parseInt("1111")); h5.setTitleX("Time Resolution(ns)"); + + while(reader.hasEvent()){ + DataEvent event = (DataEvent) reader.getNextEvent(); + cal.processDataEvent(event); + + GenericKinematicFitter fitter = new GenericKinematicFitter(11); + PhysicsEvent gen = fitter.getGeneratedEvent((EvioDataEvent)event); +// DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); +// PhysicsEvent gen = detectorEvent.getGeneratedEvent(); + if(event.hasBank("FTHODORec::clusters")) { + DataBank bank = event.getBank("FTHODORec::clusters"); + int nrows = bank.rows(); + for(int i=0; i{ + // class implements Comparable interface to allow for sorting a collection of hits by wire number values + + + // constructors + + /** + * @param sector + * @param layer + * @param strip + * @param Edep (for gemc output without digitization) + */ + public FTTRKHit(int sector, int layer, int strip, double Edep) { + this._Sector = sector; + this._Layer = layer; + this._Strip = strip; + this._Edep = Edep; + + double x0 = FTTRKConstantsLoader.stripsX[layer-1][strip-1][0]; + double x1 = FTTRKConstantsLoader.stripsX[layer-1][strip-1][1]; + double y0 = FTTRKConstantsLoader.stripsY[layer-1][strip-1][0]; + double y1 = FTTRKConstantsLoader.stripsY[layer-1][strip-1][1]; + double Z = FTTRKConstantsLoader.Zlayer[layer-1]; // z + Line3D seg = new Line3D(); + seg.setOrigin(new Point3D(x0,y0,Z)); + seg.setEnd(new Point3D(x1,y1,Z)); + set_StripSegment(seg); + } + + + private int _Sector; // sector[1...24] + private int _Layer; // layer [1,...6] + private int _Strip; // strip [1...256] + + private double _Edep; // Reconstructed time, for now it is the gemc time + private Line3D _StripSegment; // The geometry segment representing the strip position + private int _Id; // Hit Id + private double _Time; // Reconstructed time, for now it is the gemc time + private int _DGTZIndex; // Pointer to cluster + private int _ClusterIndex; // Pointer to cluster + + + /** + * + * @return the sector (1...24) + */ + public int get_Sector() { + return _Sector; + } + + /** + * Sets the sector + * @param _Sector + */ + public void set_Sector(int _Sector) { + this._Sector = _Sector; + } + + + /** + * + * @return the layer (1...8) + */ + public int get_Layer() { + return _Layer; + } + + /** + * Sets the layer + * @param _Layer + */ + public void set_Layer(int _Layer) { + this._Layer = _Layer; + } + + /** + * + * @return the wire number (1...256) + */ + public int get_Strip() { + return _Strip; + } + + /** + * Sets the wire number + * @param _Wire + */ + public void set_Strip(int _Strip) { + this._Strip = _Strip; + } + + /** + * + * @return the Edep in MeV + */ + public double get_Edep() { + return _Edep; + } + + /** + * Sets the Edep + * @param _Edep + */ + public void set_Edep(double _Edep) { + this._Edep = _Edep; + } + + + public double get_Time() { + return _Time; + } + + public void set_Time(double _Time) { + this._Time = _Time; + } + + + /** + * + * @return the ID + */ + public int get_Id() { + return _Id; + } + + /** + * Sets the hit ID. The ID corresponds to the hit index in the EvIO column. + * @param _Id + */ + public void set_Id(int _Id) { + this._Id = _Id; + } + + + /** + * + * @return region (1...4) + */ + public int get_Region() { + return (int) (this._Layer+1)/2; + } + /** + * + * @return superlayer 1 or 2 in region (1...4) + */ + public int get_RegionSlayer() { + return (this._Layer+1)%2+1; + } + + public Line3D get_StripSegment() { + return _StripSegment; + } + + public void set_StripSegment(Line3D _StripSegment) { + this._StripSegment = _StripSegment; + } + + public int get_DGTZIndex() { + return _DGTZIndex; + } + + public void set_DGTZIndex(int _DGTZIndex) { + this._DGTZIndex = _DGTZIndex; + } + + public int get_ClusterIndex() { + return _ClusterIndex; + } + + public void set_ClusterIndex(int _ClusterIndex) { + this._ClusterIndex = _ClusterIndex; + } + + /** + * + * @param arg0 the other hit + * @return an int used to sort a collection of hits by wire number. Sorting by wire is used in clustering. + */ + @Override + public int compareTo(FTTRKHit arg0) { + if(this._Strip>arg0._Strip) { + return 1; + } else { + return 0; + } + } + + /** + * + * @return print statement with hit information + */ + public String printInfo() { + String s = " Hit: ID "+this.get_Id()+" Sector "+this.get_Sector()+" Layer "+this.get_Layer()+" Strip "+this.get_Strip()+" Edep "+this.get_Edep(); + return s; + } + +// /** +// * +// * @param otherHit +// * @return a boolean comparing 2 hits based on basic descriptors; +// * returns true if the hits are the same +// */ +// public boolean isSameAs(FittedHit otherHit) { +// FittedHit thisHit = (FittedHit) this; +// boolean cmp = false; +// if(thisHit.get_Edep() == otherHit.get_Edep() +// && thisHit.get_Sector() == otherHit.get_Sector() +// && thisHit.get_Layer() == otherHit.get_Layer() +// && thisHit.get_Strip() == otherHit.get_Strip() ) +// cmp = true; +// return cmp; +// } + +} diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java new file mode 100644 index 0000000000..d7152a6471 --- /dev/null +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -0,0 +1,125 @@ +/* + * 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.ft.trk; + +import java.util.ArrayList; +import java.util.List; +import org.jlab.detector.calib.utils.ConstantsManager; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.io.evio.EvioDataEvent; +import org.jlab.io.hipo.HipoDataEvent; +import org.jlab.rec.ft.hodo.FTHODOCluster; +import org.jlab.rec.ft.hodo.FTHODOHit; +import org.jlab.utils.groups.IndexedTable; + +/** + * + * @author devita + */ +public class FTTRKReconstruction { + + public int debugMode = 0; + + public FTTRKReconstruction() { + } + public List initFTTRK(DataEvent event, ConstantsManager manager, int run) { + + IndexedTable charge2Energy = manager.getConstants(run, "/calibration/ft/fthodo/charge_to_energy"); + IndexedTable timeOffsets = manager.getConstants(run, "/calibration/ft/fthodo/time_offsets"); + IndexedTable geometry = manager.getConstants(run, "/geometry/ft/fthodo"); + + if(debugMode>=1) System.out.println("\nAnalyzing new event"); + List allhits = null; + + allhits = this.readRawHits(event,charge2Energy,timeOffsets,geometry); + + if(debugMode>=1) { + System.out.println("Found " + allhits.size() + " hits"); + for(int i = 0; i < allhits.size(); i++) { + System.out.print(i + "\t"); + System.out.println(allhits.get(i).printInfo()); + } + } + return allhits; + } + + + + + public List readRawHits(DataEvent event, IndexedTable charge2Energy, IndexedTable timeOffsets, IndexedTable geometry) { + // getting raw data bank + if(debugMode>=1) System.out.println("Getting raw hits from FTTRK:adc bank"); + + List hits = new ArrayList(); + if(event.hasBank("FTTRK::adc")==true) { + DataBank bankDGTZ = event.getBank("FTTRK::adc"); + int nrows = bankDGTZ.rows(); + for(int row = 0; row < nrows; row++){ + int isector = bankDGTZ.getInt("sector",row); + int ilayer = bankDGTZ.getInt("layer",row); + int icomponent = bankDGTZ.getInt("component",row); + int iorder = bankDGTZ.getInt("order",row); + int adc = bankDGTZ.getInt("ADC",row); + float time = bankDGTZ.getFloat("time",row); + if(adc!=-1 && time!=-1){ + FTTRKHit hit = new FTTRKHit(isector,ilayer,icomponent, (double) adc); + hits.add(hit); + } + } + } + return hits; + } + + + public void writeBanks(DataEvent event, List hits, List clusters){ + + // hits banks + if(hits.size()!=0) { + DataBank bankHits = event.createBank("FTTRK::hits", hits.size()); + if(bankHits==null){ + System.out.println("ERROR CREATING BANK : FTTRK::hits"); + return; + } + for(int i = 0; i < hits.size(); i++){ + bankHits.setByte("sector",i,(byte) hits.get(i).get_Sector()); + bankHits.setByte("layer",i,(byte) hits.get(i).get_Layer()); + bankHits.setShort("component",i,(short) hits.get(i).get_Strip()); +// bankHits.setFloat("x",i,(float) (hits.get(i).get_Dx()/10.0)); +// bankHits.setFloat("y",i,(float) (hits.get(i).get_Dy()/10.0)); +// bankHits.setFloat("z",i,(float) (hits.get(i).get_Dz()/10.0)); + bankHits.setFloat("energy",i,(float) hits.get(i).get_Edep()); + bankHits.setFloat("time",i,(float) hits.get(i).get_Time()); + bankHits.setShort("hitID",i,(short) hits.get(i).get_DGTZIndex()); + bankHits.setShort("clusterID",i,(short) hits.get(i).get_ClusterIndex()); + } + event.appendBanks(bankHits); + } +// // cluster bank +// if(clusters.size()!=0){ +// DataBank bankCluster = event.createBank("FTHODO::clusters", clusters.size()); +// if(bankCluster==null){ +// System.out.println("ERROR CREATING BANK : FTHODO::clusters"); +// return; +// } +// for(int i = 0; i < clusters.size(); i++){ +// bankCluster.setShort("id", i,(short) clusters.get(i).getID()); +// bankCluster.setShort("size", i,(short) clusters.get(i).getSize()); +// bankCluster.setFloat("x",i,(float) (clusters.get(i).getX()/10.0)); +// bankCluster.setFloat("y",i,(float) (clusters.get(i).getY()/10.0)); +// bankCluster.setFloat("z",i,(float) (clusters.get(i).getZ()/10.0)); +// bankCluster.setFloat("widthX",i,(float) (clusters.get(i).getWidthX()/10.0)); +// bankCluster.setFloat("widthY",i,(float) (clusters.get(i).getWidthY()/10.0)); +// bankCluster.setFloat("radius",i,(float) (clusters.get(i).getRadius()/10.0)); +// bankCluster.setFloat("time",i,(float) clusters.get(i).getTime()); +// bankCluster.setFloat("energy",i,(float) clusters.get(i).getEnergy()); +// } +// event.appendBanks(bankCluster); +// } + } + + +} From 53a6913225f924a88b3d2765f002b18bccb0eb95 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Fri, 1 Mar 2019 10:10:48 +0100 Subject: [PATCH 002/104] FTTRK completed skeleton --- etc/bankdefs/hipo/FT.json | 32 +- .../org/jlab/rec/ft/trk/FTTRKCluster.java | 302 +++++++++++++++++- .../jlab/rec/ft/trk/FTTRKConstantsLoader.java | 3 +- .../java/org/jlab/rec/ft/trk/FTTRKCross.java | 279 ++++++++++++++++ .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 9 +- .../java/org/jlab/rec/ft/trk/FTTRKHit.java | 19 +- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 210 ++++++++++-- 7 files changed, 815 insertions(+), 39 deletions(-) create mode 100644 reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java diff --git a/etc/bankdefs/hipo/FT.json b/etc/bankdefs/hipo/FT.json index fd21a4f707..e3b8605202 100644 --- a/etc/bankdefs/hipo/FT.json +++ b/etc/bankdefs/hipo/FT.json @@ -85,7 +85,37 @@ {"name":"clusterID", "id":11, "type":"int16", "info":"Hit Pointer to Cluster Bank"} ] }, - { + { + "bank": "FTTRK::clusters", + "group": 21322, + "info": "Reconstructed clusters in FT tracker", + "items": [ + {"name":"size", "id":1, "type":"int16", "info":"Cluster size"}, + {"name":"id", "id":2, "type":"int16", "info":"Cluster ID"}, + {"name":"sector", "id":3, "type":"int8", "info":"Cluster sector"}, + {"name":"layer", "id":4, "type":"int8", "info":"Cluster layer"}, + {"name":"energy", "id":5, "type":"float", "info":"Cluster total energy"}, + {"name":"maxEnergy", "id":6, "type":"float", "info":"Seed energy "}, + {"name":"seed", "id":7, "type":"int16", "info":"Seed strip"}, + {"name":"centroid", "id":8, "type":"float", "info":"Centroid strip number"} + ] + }, + { + "bank": "FTTRK::crosses", + "group": 21323, + "info": "Reconstructed crosses in FT tracker", + "items": [ + {"name":"id", "id":1, "type":"int16", "info":"Cross ID"}, + {"name":"sector", "id":2, "type":"int8", "info":"Cross sector"}, + {"name":"detector", "id":3, "type":"int8", "info":"Cross detector"}, + {"name":"x", "id":4, "type":"float", "info":"Cross X position (cm)"}, + {"name":"y", "id":5, "type":"float", "info":"Cross Y position (cm)"}, + {"name":"z", "id":6, "type":"float", "info":"Cross Z position (cm)"}, + {"name":"Cluster1ID", "id":10, "type":"int16", "info":"ID of the bottom layer cluster in the Cross"}, + {"name":"Cluster2ID", "id":11, "type":"int16", "info":"ID of the top layer cluster in the Cross"} + ] + }, + { "bank": "FT::particles", "group": 20924, "info": "Reconstructed Particles in FT", diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java index 25b1b1cfa3..8a98fcb9ab 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java @@ -5,10 +5,310 @@ */ package org.jlab.rec.ft.trk; +import java.util.ArrayList; +import org.jlab.geom.prim.Line3D; + /** * * @author devita */ -public class FTTRKCluster { + public class FTTRKCluster extends ArrayList implements Comparable{ + + private static final long serialVersionUID = 9153980362683755204L; + + + private int _Sector; + private int _Layer; + private int _Id; + private Line3D _StripSegment ; + + /** + * + * @param sector the sector + * @param layer the layer + * @param cid the cluster ID, an incremental integer corresponding to the cluster formed in the series of clusters + */ + public FTTRKCluster(int sector, int layer, int cid) { + this._Sector = sector; + this._Layer = layer; + this._Id = cid; + + + } + /** + * + * @param hit the first hit in the list of hits composing the cluster + * @param cid the id of the cluster + * @return an array list of hits characterized by its sector, layer and id number. + */ + public FTTRKCluster newCluster(FTTRKHit hit, int cid) { + return new FTTRKCluster(hit.get_Sector(), hit.get_Layer(), cid); + } + + /** + * + * @return the sector of the cluster (1...24) + */ + public int get_Sector() { + return _Sector; + } + + /** + * + * @param _Sector sector of the cluster (1...24) + */ + public void set_Sector(int _Sector) { + this._Sector = _Sector; + } + + /** + * + * @return the layer of the cluster (1...8) + */ + public int get_Layer() { + return _Layer; + } + + /** + * + * @param _Superlayer the layer of the cluster (1...6) + */ + public void set_Layer(int _Layer) { + this._Layer = _Layer; + } + + /** + * + * @return the id of the cluster + */ + public int get_Id() { + return _Id; + } + + /** + * + * @param _Id the id of the cluster + */ + public void set_Id(int _Id) { + this._Id = _Id; + } + + /** + * + * @return region (1...4) + */ + public int get_Region() { + return (int) (this._Layer+1)/2; + } + + /** + * + * @return superlayer 1 or 2 in region (1...4) + */ + public int get_RegionSlayer() { + return (this._Layer+1)%2+1; + } + /** + * + * @return cluster info. about location and number of hits contained in it + */ + public String printInfo() { + String s = "FTTRK cluster: ID "+this.get_Id()+" Seed "+this.get_SeedStrip()+" Layer "+this.get_Layer()+" Size "+this.size(); + return s; + } + + + + private double _TotalEnergy; + private double _Centroid; + private double _CentroidError; + + public double get_Centroid() { + return _Centroid; + } + public void set_Centroid(double _Centroid) { + this._Centroid = _Centroid; + } + public double get_CentroidError() { + return _CentroidError; + } + public void set_CentroidError(double _CentroidError) { + this._CentroidError = _CentroidError; + } + public double get_TotalEnergy() { + return _TotalEnergy; + } + public void set_TotalEnergy(double _TotalEnergy) { + this._TotalEnergy = _TotalEnergy; + } + /** + * sets energy-weighted parameters; these are the strip centroid (energy-weighted) value, the energy-weighted phi for Z detectors and the energy-weighted z for C detectors + */ + public void calc_CentroidParams() { + // instantiation of variables + double stripNumCent = 0; // cluster Lorentz-angle-corrected energy-weighted strip = centroid + + double xCentEndPoint1 = 0; // cluster energy-weighted Centroid x coordinate of the first end-point + double yCentEndPoint1 = 0; // cluster energy-weighted Centroid y coordinate of the first end-point + double zCentEndPoint1 = 0; // cluster energy-weighted Centroid z coordinate of the first end-point + double xCentEndPoint2 = 0; // cluster energy-weighted Centroid x coordinate of the second end-point + double yCentEndPoint2 = 0; // cluster energy-weighted Centroid y coordinate of the second end-point + double zCentEndPoint2 = 0; // cluster energy-weighted Centroid z coordinate of the second end-point + + double totEn = 0.; // cluster total energy + double weightedStrp = 0; // energy-weighted strip + + double weightedStripEndPoint1X = 0; // Energy-weighted x of the strip first end point + double weightedStripEndPoint1Y = 0; // Energy-weighted y of the strip first end point + double weightedStripEndPoint1Z = 0; // Energy-weighted z of the strip first end point + double weightedStripEndPoint2X = 0; // Energy-weighted x of the strip second end point + double weightedStripEndPoint2Y = 0; // Energy-weighted y of the strip second end point + double weightedStripEndPoint2Z = 0; // Energy-weighted z of the strip second end point + + int nbhits = this.size(); + + if(nbhits != 0) { + int min = 1000000; + int max = -1; + int seed = -1; + double Emax = -1; + // looping over the number of hits in the cluster + for(int i=0;i=max) + max = strpNb; + // getting the seed strip which is defined as the strip with the largest deposited energy + if(strpEn>=Emax) { + Emax = strpEn; + seed = strpNb; + } + + } + if(totEn==0) { + System.err.println(" Cluster energy is null .... exit"); + return; + } + + this.set_MinStrip(min); + this.set_MaxStrip(max); + this.set_SeedStrip(seed); + this.set_SeedEnergy(Emax); + // calculates the centroid values and associated positions + stripNumCent = weightedStrp/totEn; //System.out.println(" --> centroid "+stripNumCent); + xCentEndPoint1 = weightedStripEndPoint1X/totEn; + yCentEndPoint1 = weightedStripEndPoint1Y/totEn; + zCentEndPoint1 = weightedStripEndPoint1Z/totEn; + xCentEndPoint2 = weightedStripEndPoint2X/totEn; + yCentEndPoint2 = weightedStripEndPoint2Y/totEn; + zCentEndPoint2 = weightedStripEndPoint2Z/totEn; + + } + + _TotalEnergy = totEn; + _Centroid = stripNumCent; + _CentroidError = Math.sqrt(this.size())*FTTRKConstantsLoader.Pitch/Math.sqrt(12); + _StripSegment = new Line3D(); + _StripSegment.setOrigin(xCentEndPoint1, yCentEndPoint1, zCentEndPoint1); + _StripSegment.setEnd(xCentEndPoint2, yCentEndPoint2, zCentEndPoint2); + } + + + private int _MinStrip; + private int _MaxStrip; + private int _SeedStrip; + private double _SeedEnergy; + + + public int get_MinStrip() { + return _MinStrip; + } + public void set_MinStrip(int _MinStrip) { + this._MinStrip = _MinStrip; + } + public int get_MaxStrip() { + return _MaxStrip; + } + public void set_MaxStrip(int _MaxStrip) { + this._MaxStrip = _MaxStrip; + } + + + public int get_SeedStrip() { + return _SeedStrip; + } + public void set_SeedStrip(int _SeedStrip) { + this._SeedStrip = _SeedStrip; + } + public double get_SeedEnergy() { + return _SeedEnergy; + } + public void set_SeedEnergy(double _SeedEnergy) { + this._SeedEnergy = _SeedEnergy; + } + public Line3D get_StripSegment() { + return _StripSegment; + } + public void set_StripSegment(Line3D _StripSegment) { + this._StripSegment = _StripSegment; + } + + + + /** + * + * @param Z z-coordinate of a point in the local coordinate system of a module + * @return the average resolution for a group of strips in a cluster + * + */ + + + private int _AssociatedCrossID; + private int _AssociatedTrackID; + + public int get_AssociatedCrossID() { + return _AssociatedCrossID; + } + + public void set_AssociatedCrossID(int _AssociatedCrossID) { + this._AssociatedCrossID = _AssociatedCrossID; + } + + public int get_AssociatedTrackID() { + return _AssociatedTrackID; + } + + public void set_AssociatedTrackID(int _AssociatedTrackID) { + this._AssociatedTrackID = _AssociatedTrackID; + } + + @Override + public int compareTo(FTTRKCluster arg) { + + return this.get_Layer() < arg.get_Layer() ? -1 : this.get_Layer() == arg.get_Layer() ? 0 : 1; + + } } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java index a141034478..640494bde1 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java @@ -34,7 +34,7 @@ public class FTTRKConstantsLoader { public static double[][][] stripsY; //Give the end-points y-coordinates of the strip segment public static double[] stripslength; //Give the strip length - public static synchronized void Load() { + public static synchronized void Load() { Sidestrips = (Nstrips -2*Halfstrips)/2; YCentral = (double)Halfstrips*Pitch/2.; @@ -104,6 +104,7 @@ public static synchronized void Load() { } System.out.println("***** FMT constants loaded!"); } + private static int getLocalRegion(int i) { // To represent the geometry we divide the barrel micromega disk into 3 regions according to the strip numbering system. // Here i = strip_number -1; diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java new file mode 100644 index 0000000000..76bc4dd555 --- /dev/null +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java @@ -0,0 +1,279 @@ +/* + * 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.ft.trk; + +import java.util.ArrayList; +import org.jlab.geom.prim.Line3D; +import org.jlab.geom.prim.Point3D; +import org.jlab.geom.prim.Vector3D; + +/** + * The crosses are objects used to find tracks and are characterized by a 3-D point and a direction unit vector. + * @author ziegler + * @author devita + * + */ +public class FTTRKCross extends ArrayList implements Comparable { + + /** + * serial id + */ + private static final long serialVersionUID = 5317526429163382618L; + + /** + * + * @param sector the sector (1) + * @param region the region (1...3) + * @param rid the cross ID (if there are only 3 crosses in the event, the ID corresponds to the region index + */ + public FTTRKCross(int sector, int region, int rid) { + this._Sector = sector; + this._Region = region; + this._Id = rid; + } + + private int _Sector; // sector[1...6] + private int _Region; // region [1,...3] + private int _Id; // cross Id + + // point parameters: + private Point3D _Point; + private Point3D _PointErr; + + private Vector3D _Dir; + private Vector3D _DirErr; + + /** + * + * @return the sector of the cross + */ + public int get_Sector() { + return _Sector; + } + + /** + * Sets the sector + * @param _Sector the sector of the cross + */ + public void set_Sector(int _Sector) { + this._Sector = _Sector; + } + + /** + * + * @return the region of the cross + */ + public int get_Region() { + return _Region; + } + + /** + * Sets the region + * @param _Region the region of the cross + */ + public void set_Region(int _Region) { + this._Region = _Region; + } + + /** + * + * @return the id of the cross + */ + public int get_Id() { + return _Id; + } + + /** + * Sets the cross ID + * @param _Id the id of the cross + */ + public void set_Id(int _Id) { + this._Id = _Id; + } + + + + + /** + * + * @return a 3-D point characterizing the position of the cross in the tilted coordinate system. + */ + public Point3D get_Point() { + return _Point; + } + + /** + * Sets the cross 3-D point + * @param _Point a 3-D point characterizing the position of the cross in the tilted coordinate system. + */ + public void set_Point(Point3D _Point) { + this._Point = _Point; + } + + /** + * + * @return a 3-dimensional error on the 3-D point characterizing the position of the cross in the tilted coordinate system. + */ + public Point3D get_PointErr() { + return _PointErr; + } + + /** + * Sets a 3-dimensional error on the 3-D point + * @param _PointErr a 3-dimensional error on the 3-D point characterizing the position of the cross in the tilted coordinate system. + */ + public void set_PointErr(Point3D _PointErr) { + this._PointErr = _PointErr; + } + + /** + * + * @return the cross unit direction vector + */ + public Vector3D get_Dir() { + return _Dir; + } + + /** + * Sets the cross unit direction vector + * @param _Dir the cross unit direction vector + */ + public void set_Dir(Vector3D _Dir) { + this._Dir = _Dir; + } + + /** + * + * @return the cross unit direction vector + */ + public Vector3D get_DirErr() { + return _DirErr; + } + + /** + * Sets the cross unit direction vector + * @param _DirErr the cross unit direction vector + */ + public void set_DirErr(Vector3D _DirErr) { + this._DirErr = _DirErr; + } + + /** + * + * @return serialVersionUID + */ + public static long getSerialversionuid() { + return serialVersionUID; + } + + + /** + * Sorts crosses by azimuth angle values + */ + @Override + public int compareTo(FTTRKCross arg) { + + if(this.get_Point().toVector3D().phi() allHits = new ArrayList(); List selectedHits = new ArrayList(); List clusters = new ArrayList(); + List crosses = new ArrayList(); // update calibration constants based on run number if changed int run = setRunConditionsParameters(event); @@ -63,10 +64,12 @@ public boolean processDataEvent(DataEvent event) { allHits = reco.initFTTRK(event,this.getConstantsManager(), run); // // select good hits and order them by energy // selectedHits = reco.selectHits(allHits); -// // create clusters -// clusters = reco.findClusters(selectedHits); + // create clusters + clusters = reco.findClusters(allHits); + // create crosses + crosses = reco.findCrosses(clusters); // write output banks - reco.writeBanks(event, selectedHits, clusters); + reco.writeBanks(event, allHits, clusters, crosses); } return true; } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java index ec936d87b8..7d3cd014f9 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java @@ -47,11 +47,12 @@ public FTTRKHit(int sector, int layer, int strip, double Edep) { private int _Strip; // strip [1...256] private double _Edep; // Reconstructed time, for now it is the gemc time - private Line3D _StripSegment; // The geometry segment representing the strip position - private int _Id; // Hit Id - private double _Time; // Reconstructed time, for now it is the gemc time - private int _DGTZIndex; // Pointer to cluster - private int _ClusterIndex; // Pointer to cluster + private Line3D _StripSegment; // The geometry segment representing the strip position + private int _Id; // Hit Id + private double _Time; // Reconstructed time, for now it is the gemc time + private int _DGTZIndex; // Pointer to raw hit + private int _ClusterIndex; // Pointer to cluster + private int _CrossIndex; // Pointer to cross /** @@ -185,6 +186,14 @@ public void set_ClusterIndex(int _ClusterIndex) { this._ClusterIndex = _ClusterIndex; } + public int get_CrossIndex() { + return _CrossIndex; + } + + public void set_CrossIndex(int _CrossIndex) { + this._CrossIndex = _CrossIndex; + } + /** * * @param arg0 the other hit diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index d7152a6471..c7bd5a4d0a 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -10,10 +10,6 @@ import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; -import org.jlab.io.evio.EvioDataEvent; -import org.jlab.io.hipo.HipoDataEvent; -import org.jlab.rec.ft.hodo.FTHODOCluster; -import org.jlab.rec.ft.hodo.FTHODOHit; import org.jlab.utils.groups.IndexedTable; /** @@ -48,9 +44,151 @@ public List initFTTRK(DataEvent event, ConstantsManager manager, int r } + public ArrayList findClusters(List hits) + { + // cluster finding algorithm + // the loop is done over sectors + int nlayer = FTTRKConstantsLoader.Nlayers; + int nstrip = FTTRKConstantsLoader.Nstrips; + boolean[][] checked; + FTTRKHit[][] HitArray; + ArrayList clusters = new ArrayList(); + + // a boolean array to avoid double counting at the numbering discontinuities + checked = new boolean[nstrip][nlayer] ; + for(int l=0; l0 && w clusterHits = new ArrayList(); + + // adding all hits in this and all the subsequent + // strip until there's a strip with no hit + // Strip 1 and 513 needs a particular loop + if (si==0){ + int sj=832; + while(HitArray[sj][l] != null && sj readRawHits(DataEvent event, IndexedTable charge2Energy, IndexedTable timeOffsets, IndexedTable geometry) { + public ArrayList findCrosses(List clusters) { + + // first separate the segments according to layers + ArrayList allinnerlayrclus = new ArrayList(); + ArrayList allouterlayrclus = new ArrayList(); + + // Sorting by layer first: + for (FTTRKCluster theclus : clusters){ + if(theclus.get_Layer()%2==0) { + allouterlayrclus.add(theclus); + } + if(theclus.get_Layer()%2==1) { + allinnerlayrclus.add(theclus); + } + } + + ArrayList crosses = new ArrayList(); + + int rid =0; + for(FTTRKCluster inlayerclus : allinnerlayrclus){ + for(FTTRKCluster outlayerclus : allouterlayrclus){ + if(outlayerclus.get_Layer()-inlayerclus.get_Layer()!=1) + continue; + if(outlayerclus.get_Sector()!=inlayerclus.get_Sector()) + continue; + if( (inlayerclus.get_MinStrip()+outlayerclus.get_MinStrip() > 1) + && (inlayerclus.get_MaxStrip()+outlayerclus.get_MaxStrip() < FTTRKConstantsLoader.Nstrips*2) ) { // put correct numbers to make sure the intersection is valid + + // define new cross + FTTRKCross this_cross = new FTTRKCross(inlayerclus.get_Sector(), inlayerclus.get_Region(),rid++); + this_cross.set_Cluster1(inlayerclus); + this_cross.set_Cluster2(outlayerclus); + + this_cross.set_CrossParams(); + //make arraylist + crosses.add(this_cross); + + } + } + } + return crosses; + } + + public List readRawHits(DataEvent event, IndexedTable charge2Energy, IndexedTable timeOffsets, IndexedTable geometry) { // getting raw data bank if(debugMode>=1) System.out.println("Getting raw hits from FTTRK:adc bank"); @@ -75,7 +213,7 @@ public List readRawHits(DataEvent event, IndexedTable charge2Energy, I } - public void writeBanks(DataEvent event, List hits, List clusters){ + public void writeBanks(DataEvent event, List hits, List clusters, List crosses){ // hits banks if(hits.size()!=0) { @@ -98,28 +236,44 @@ public void writeBanks(DataEvent event, List hits, List } event.appendBanks(bankHits); } -// // cluster bank -// if(clusters.size()!=0){ -// DataBank bankCluster = event.createBank("FTHODO::clusters", clusters.size()); -// if(bankCluster==null){ -// System.out.println("ERROR CREATING BANK : FTHODO::clusters"); -// return; -// } -// for(int i = 0; i < clusters.size(); i++){ -// bankCluster.setShort("id", i,(short) clusters.get(i).getID()); -// bankCluster.setShort("size", i,(short) clusters.get(i).getSize()); -// bankCluster.setFloat("x",i,(float) (clusters.get(i).getX()/10.0)); -// bankCluster.setFloat("y",i,(float) (clusters.get(i).getY()/10.0)); -// bankCluster.setFloat("z",i,(float) (clusters.get(i).getZ()/10.0)); -// bankCluster.setFloat("widthX",i,(float) (clusters.get(i).getWidthX()/10.0)); -// bankCluster.setFloat("widthY",i,(float) (clusters.get(i).getWidthY()/10.0)); -// bankCluster.setFloat("radius",i,(float) (clusters.get(i).getRadius()/10.0)); -// bankCluster.setFloat("time",i,(float) clusters.get(i).getTime()); -// bankCluster.setFloat("energy",i,(float) clusters.get(i).getEnergy()); -// } -// event.appendBanks(bankCluster); -// } + // cluster bank + if(clusters.size()!=0){ + DataBank bankCluster = event.createBank("FTTRK::clusters", clusters.size()); + if(bankCluster==null){ + System.out.println("ERROR CREATING BANK : FTTRK::clusters"); + return; + } + for(int i = 0; i < clusters.size(); i++){ + bankCluster.setShort("size", i,(short) clusters.get(i).size()); + bankCluster.setShort("id", i,(short) clusters.get(i).get_Id()); + bankCluster.setByte("sector", i,(byte) clusters.get(i).get_Sector()); + bankCluster.setByte("layer", i,(byte) clusters.get(i).get_Layer()); + bankCluster.setFloat("energy", i,(float) clusters.get(i).get_TotalEnergy()); + bankCluster.setFloat("maxEnergy", i,(float) clusters.get(i).get_SeedEnergy()); + bankCluster.setShort("seed", i,(short) clusters.get(i).get_SeedStrip()); + bankCluster.setFloat("centroid", i,(float) clusters.get(i).get_Centroid()); + } + event.appendBanks(bankCluster); + } + // cross bank + if(crosses.size()!=0){ + DataBank bankCross = event.createBank("FTTRK::crosses", crosses.size()); + if(bankCross==null){ + System.out.println("ERROR CREATING BANK : FTTRK::crosses"); + return; + } + for (int j = 0; j < crosses.size(); j++) { + bankCross.setShort("id", j, (short) crosses.get(j).get_Id()); + bankCross.setByte("sector", j, (byte) crosses.get(j).get_Sector()); + bankCross.setByte("detector", j, (byte) crosses.get(j).get_Region()); + bankCross.setFloat("x", j, (float) crosses.get(j).get_Point().x()); + bankCross.setFloat("y", j, (float) crosses.get(j).get_Point().y()); + bankCross.setFloat("z", j, (float) crosses.get(j).get_Point().z()); + bankCross.setShort("Cluster1ID", j, (short) crosses.get(j).get_Cluster1().get_Id()); + bankCross.setShort("Cluster2ID", j, (short) crosses.get(j).get_Cluster2().get_Id()); + } + } } - + } From fd8bb00bb63fb67694a61b12d4baba3b0af00eea Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Fri, 1 Mar 2019 12:25:52 +0100 Subject: [PATCH 003/104] added FTTRK service to yaml file and notsouseful, fixed clustering and cross finding --- .../org/jlab/clas/reco/EngineProcessor.java | 3 +- etc/services/data.yaml | 2 + etc/services/dst.yaml | 2 + etc/services/mc.yaml | 2 + etc/services/reconstruction.yaml | 2 + .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 93 +++++++++---------- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 51 +++++----- 7 files changed, 80 insertions(+), 75 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java index da32442e91..3bf5d39cb6 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java @@ -70,7 +70,7 @@ public void initAll(){ String[] names = new String[]{ "MAGFIELDS", - "FTCAL", "FTHODO", "FTEB", + "FTCAL", "FTHODO", "FTTRK", "FTEB", "DCHB","FTOFHB","EC", "CVT","CTOF","CND", "HTCC","LTCC","RICHEB","EBHB", @@ -81,6 +81,7 @@ public void initAll(){ "org.jlab.clas.swimtools.MagFieldsEngine", "org.jlab.rec.ft.cal.FTCALEngine", "org.jlab.rec.ft.hodo.FTHODOEngine", + "org.jlab.rec.ft.trk.FTTRKEngine", "org.jlab.rec.ft.FTEBEngine", "org.jlab.service.dc.DCHBEngine", "org.jlab.service.ftof.FTOFHBEngine", diff --git a/etc/services/data.yaml b/etc/services/data.yaml index c26b6f88be..4531903a08 100644 --- a/etc/services/data.yaml +++ b/etc/services/data.yaml @@ -12,6 +12,8 @@ services: name: FTCAL - class: org.jlab.rec.ft.hodo.FTHODOEngine name: FTHODO + - class: org.jlab.rec.ft.trk.FTTRKEngine + name: FTTRK - class: org.jlab.rec.ft.FTEBEngine name: FTEB - class: org.jlab.service.dc.DCHBEngine diff --git a/etc/services/dst.yaml b/etc/services/dst.yaml index f6481999b5..caa9c0ef70 100644 --- a/etc/services/dst.yaml +++ b/etc/services/dst.yaml @@ -12,6 +12,8 @@ services: name: FTCAL - class: org.jlab.rec.ft.hodo.FTHODOEngine name: FTHODO + - class: org.jlab.rec.ft.trk.FTTRKEngine + name: FTTRK - class: org.jlab.rec.ft.FTEBEngine name: FTEB - class: org.jlab.service.dc.DCHBEngine diff --git a/etc/services/mc.yaml b/etc/services/mc.yaml index 5f1bce3f30..c0604b4efe 100644 --- a/etc/services/mc.yaml +++ b/etc/services/mc.yaml @@ -12,6 +12,8 @@ services: name: FTCAL - class: org.jlab.rec.ft.hodo.FTHODOEngine name: FTHODO + - class: org.jlab.rec.ft.trk.FTTRKEngine + name: FTTRK - class: org.jlab.rec.ft.FTEBEngine name: FTEB - class: org.jlab.service.dc.DCHBEngine diff --git a/etc/services/reconstruction.yaml b/etc/services/reconstruction.yaml index 5f1bce3f30..c0604b4efe 100644 --- a/etc/services/reconstruction.yaml +++ b/etc/services/reconstruction.yaml @@ -12,6 +12,8 @@ services: name: FTCAL - class: org.jlab.rec.ft.hodo.FTHODOEngine name: FTHODO + - class: org.jlab.rec.ft.trk.FTTRKEngine + name: FTTRK - class: org.jlab.rec.ft.FTEBEngine name: FTEB - class: org.jlab.service.dc.DCHBEngine diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java index 4e8838847a..acb2112f9c 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java @@ -9,16 +9,17 @@ import java.util.Arrays; import java.util.List; import javax.swing.JFrame; +import org.jlab.clas.detector.DetectorData; +import org.jlab.clas.detector.DetectorEvent; import org.jlab.clas.physics.GenericKinematicFitter; import org.jlab.clas.physics.PhysicsEvent; import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.groot.data.H1F; +import org.jlab.groot.data.H2F; import org.jlab.groot.graphics.EmbeddedCanvas; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; -import org.jlab.io.evio.EvioDataBank; -import org.jlab.io.evio.EvioDataEvent; -import org.jlab.io.evio.EvioSource; +import org.jlab.io.hipo.HipoDataSource; /** * @@ -34,19 +35,22 @@ public FTTRKEngine() { @Override public boolean init() { + + FTTRKConstantsLoader.Load(); + reco = new FTTRKReconstruction(); reco.debugMode=0; - String[] tables = new String[]{ - "/calibration/ft/fthodo/charge_to_energy", - "/calibration/ft/fthodo/time_offsets", - "/calibration/ft/fthodo/status", - "/geometry/ft/fthodo" - }; - requireConstants(Arrays.asList(tables)); - this.getConstantsManager().setVariation("default"); + String[] tables = new String[]{ + "/calibration/ft/fthodo/charge_to_energy", + "/calibration/ft/fthodo/time_offsets", + "/calibration/ft/fthodo/status", + "/geometry/ft/fthodo" + }; + requireConstants(Arrays.asList(tables)); + this.getConstantsManager().setVariation("default"); - return true; + return true; } @Override @@ -80,68 +84,57 @@ public int setRunConditionsParameters(DataEvent event) { System.out.println("RUN CONDITIONS NOT READ!"); } - if(event instanceof EvioDataEvent) { - EvioDataBank bank = (EvioDataBank) event.getBank("RUN::config"); - run = bank.getInt("Run")[0]; - } - else { - DataBank bank = event.getBank("RUN::config"); + DataBank bank = event.getBank("RUN::config"); run = bank.getInt("run")[0]; - } + return run; } public static void main (String arg[]) { - FTTRKEngine cal = new FTTRKEngine(); - cal.init(); -// String input = "/Users/devita/data/out_clasdispr.00.e11.000.emn0.75tmn.09.xs65.61nb.dis.1.V5.hipo"; -// HipoDataSource reader = new HipoDataSource(); - String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/out_header.ev"; - EvioSource reader = new EvioSource(); + FTTRKEngine trk = new FTTRKEngine(); + trk.init(); + String input = "/Users/devita/work/clas12/simulations/clas12Tags/4.3.1/out.hipo"; + HipoDataSource reader = new HipoDataSource(); reader.open(input); // initialize histos - H1F h1 = new H1F("Cluster Energy",100, 0.,5.); - h1.setOptStat(Integer.parseInt("1111")); h1.setTitleX("Cluster Energy (GeV)"); - H1F h2 = new H1F("Energy Resolution",100, -1, 1); - h2.setOptStat(Integer.parseInt("1111")); h2.setTitleX("Energy Resolution(GeV)"); - H1F h3 = new H1F("Theta Resolution",100, -2, 2); - h3.setOptStat(Integer.parseInt("1111")); h3.setTitleX("Theta Resolution(deg)"); - H1F h4 = new H1F("Phi Resolution",100, -10, 10); - h4.setOptStat(Integer.parseInt("1111")); h4.setTitleX("Phi Resolution(deg)"); - H1F h5 = new H1F("Time Resolution",100, -10, 10); - h5.setOptStat(Integer.parseInt("1111")); h5.setTitleX("Time Resolution(ns)"); + H2F h1 = new H2F("h1", "Layer vs. Component",100, 0.,1000,5, 0.,5.); + h1.setTitleX("Component"); + h1.setTitleX("Layer"); + H1F h2 = new H1F("Energy",100, 0, 100); + h2.setOptStat(Integer.parseInt("1111")); h2.setTitleX("Energy"); h2.setTitleY("Counts"); + H1F h3 = new H1F("Time",100, -2, 2); + h3.setOptStat(Integer.parseInt("1111")); h3.setTitleX("Time"); h3.setTitleY("Counts"); while(reader.hasEvent()){ DataEvent event = (DataEvent) reader.getNextEvent(); - cal.processDataEvent(event); + trk.processDataEvent(event); - GenericKinematicFitter fitter = new GenericKinematicFitter(11); - PhysicsEvent gen = fitter.getGeneratedEvent((EvioDataEvent)event); -// DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); -// PhysicsEvent gen = detectorEvent.getGeneratedEvent(); - if(event.hasBank("FTHODORec::clusters")) { - DataBank bank = event.getBank("FTHODORec::clusters"); + DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); + PhysicsEvent gen = detectorEvent.getGeneratedEvent(); + if(event.hasBank("FTTRK::hits")) { + DataBank bank = event.getBank("FTTRK::hits"); int nrows = bank.rows(); for(int i=0; i findClusters(List hits) int w = hit.get_Strip(); int l = hit.get_Layer(); - if(w>0 && w0 && w<=nstrip) { HitArray[w-1][l-1] = hit; + if(debugMode>=1) System.out.println(w + " " + l + " " + HitArray[w-1][l-1].printInfo()); } } @@ -86,13 +87,13 @@ public ArrayList findClusters(List hits) // for each layer and sector, a loop over the strips // is done to define clusters in that module's layer // clusters are delimited by strips with no hits - for(int l=0; l clusterHits = new ArrayList(); @@ -100,45 +101,45 @@ public ArrayList findClusters(List hits) // adding all hits in this and all the subsequent // strip until there's a strip with no hit // Strip 1 and 513 needs a particular loop - if (si==0){ - int sj=832; - while(HitArray[sj][l] != null && sj findCrosses(List clusters) { continue; if(outlayerclus.get_Sector()!=inlayerclus.get_Sector()) continue; + if(debugMode>=1) System.out.println(inlayerclus.printInfo() + " " + outlayerclus.printInfo()); if( (inlayerclus.get_MinStrip()+outlayerclus.get_MinStrip() > 1) && (inlayerclus.get_MaxStrip()+outlayerclus.get_MaxStrip() < FTTRKConstantsLoader.Nstrips*2) ) { // put correct numbers to make sure the intersection is valid @@ -181,7 +183,7 @@ public ArrayList findCrosses(List clusters) { this_cross.set_CrossParams(); //make arraylist crosses.add(this_cross); - + if(debugMode>=1) System.out.println(this_cross.printInfo() + " " + crosses.size()); } } } @@ -203,7 +205,7 @@ public List readRawHits(DataEvent event, IndexedTable charge2Energy, I int iorder = bankDGTZ.getInt("order",row); int adc = bankDGTZ.getInt("ADC",row); float time = bankDGTZ.getFloat("time",row); - if(adc!=-1 && time!=-1){ + if(adc>0 && time!=-1 && icomponent!=-1){ FTTRKHit hit = new FTTRKHit(isector,ilayer,icomponent, (double) adc); hits.add(hit); } @@ -272,6 +274,7 @@ public void writeBanks(DataEvent event, List hits, List bankCross.setShort("Cluster1ID", j, (short) crosses.get(j).get_Cluster1().get_Id()); bankCross.setShort("Cluster2ID", j, (short) crosses.get(j).get_Cluster2().get_Id()); } + event.appendBanks(bankCross); } } From 7d63d3596bcf0f9fca71fa237e99da263712a92d Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Thu, 14 Mar 2019 18:16:10 -0400 Subject: [PATCH 004/104] FTTrk: updated geometry and clustering --- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 20 +- .../java/org/jlab/rec/ft/cal/FTCALEngine.java | 2 +- .../org/jlab/rec/ft/trk/FTTRKCluster.java | 35 ++-- .../jlab/rec/ft/trk/FTTRKConstantsLoader.java | 183 ++++++++++++++--- .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 179 +++++++++++++++-- .../java/org/jlab/rec/ft/trk/FTTRKHit.java | 45 ++++- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 186 ++++++++++++++---- 7 files changed, 537 insertions(+), 113 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index 22bef7d298..8dc87fa4c8 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -130,8 +130,8 @@ public static void main(String arg[]){ en.init(); // String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/elec_nofield_header.evio"; // EvioSource reader = new EvioSource(); - String input = "/Users/devita/NetBeansProjects/clas12-offline-software/validation/advanced-tests/electrongammaFT.hipo"; - //"/Users/devita/Work/clas12/simulations/tests/clas12Tags/4a.2.2/electron.hipo"; +// String input = "/Users/devita/NetBeansProjects/clas12-offline-software/validation/advanced-tests/electrongammaFT.hipo"; + String input = "/Users/devita/Work/clas12/simulations/clas12Tags/4.3.1/out.hipo"; // String input = "/Users/devita/out_gemc_10.hipo"; HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -197,18 +197,18 @@ public static void main(String arg[]){ DataBank bank = event.getBank("FT::particles"); int nrows = bank.rows(); for (int i = 0; i < nrows; i++) { - if(bank.getByte("charge", i)==0) { + if(bank.getByte("charge", i)==-1) { h1.fill(bank.getFloat("energy", i)); - h2.fill(bank.getFloat("energy", i) - gen.getGeneratedParticle(1).vector().p()); + h2.fill(bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); Vector3D part = new Vector3D(bank.getFloat("cx", i), bank.getFloat("cy", i), bank.getFloat("cz", i)); - h3.fill(Math.toDegrees(part.theta() - gen.getGeneratedParticle(1).theta())); - h4.fill(Math.toDegrees(part.phi() - gen.getGeneratedParticle(1).phi())); + h3.fill(Math.toDegrees(part.theta() - gen.getGeneratedParticle(0).theta())); + h4.fill(Math.toDegrees(part.phi() - gen.getGeneratedParticle(0).phi())); h5.fill(bank.getFloat("time", i) - 124.25); - h6.fill(bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("energy", i) - gen.getGeneratedParticle(1).vector().p()); + h6.fill(bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); h7.fill(bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS); - h8.fill(gen.getGeneratedParticle(1).vector().p(), bank.getFloat("energy", i) - gen.getGeneratedParticle(1).vector().p()); - h9.fill(Math.toDegrees(gen.getGeneratedParticle(1).theta()), bank.getFloat("energy", i) - gen.getGeneratedParticle(1).vector().p()); - h10.fill(Math.toDegrees(gen.getGeneratedParticle(1).phi()), bank.getFloat("energy", i) - gen.getGeneratedParticle(1).vector().p()); + h8.fill(gen.getGeneratedParticle(0).vector().p(), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h9.fill(Math.toDegrees(gen.getGeneratedParticle(0).theta()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h10.fill(Math.toDegrees(gen.getGeneratedParticle(0).phi()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); } } } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java index 7020fc2bec..e5107ebd5c 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java @@ -93,7 +93,7 @@ public int setRunConditionsParameters(DataEvent event) { public static void main (String arg[]) { FTCALEngine cal = new FTCALEngine(); cal.init(); - String input = "/Users/devita/Work/clas12/simulations/tests/clas12Tags/4a.2.2/out.hipo"; + String input = "/Users/devita/Work/clas12/simulations/clas12Tags/4.3.1/out.hipo"; HipoDataSource reader = new HipoDataSource(); // String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/out_header.ev"; // EvioSource reader = new EvioSource(); diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java index 8a98fcb9ab..194c7e598f 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java @@ -11,6 +11,7 @@ /** * * @author devita + * @author filippi */ public class FTTRKCluster extends ArrayList implements Comparable{ @@ -63,7 +64,7 @@ public void set_Sector(int _Sector) { /** * - * @return the layer of the cluster (1...8) + * @return the layer of the cluster (1...4) */ public int get_Layer() { return _Layer; @@ -71,7 +72,7 @@ public int get_Layer() { /** * - * @param _Superlayer the layer of the cluster (1...6) + * @param set the layer of the cluster (1...4) */ public void set_Layer(int _Layer) { this._Layer = _Layer; @@ -93,21 +94,23 @@ public void set_Id(int _Id) { this._Id = _Id; } + /** * - * @return region (1...4) + * @return region (1...4) // this is not useful */ - public int get_Region() { - return (int) (this._Layer+1)/2; - } - - /** - * - * @return superlayer 1 or 2 in region (1...4) - */ - public int get_RegionSlayer() { - return (this._Layer+1)%2+1; - } + public int get_Region() { + return (int) (this._Layer+1)/2; + } +// +// /** +// * +// * @return superlayer 1 or 2 in region (1...4) +// */ +// public int get_RegionSlayer() { +// return (this._Layer+1)%2+1; +// } +// /** * @@ -188,7 +191,9 @@ public void calc_CentroidParams() { double z2 = thehit.get_StripSegment().end().z(); totEn += strpEn; - weightedStrp+= strpEn*(double)FTTRKConstantsLoader.stripsYloc[strpNb-1][0]; + int layer = thehit.get_Layer(); + int Slayer = thehit.get_SuperLayer(layer); + weightedStrp+= strpEn*(double)FTTRKConstantsLoader.stripsYloc[Slayer][strpNb-1][0]; weightedStripEndPoint1X+= strpEn*x1; weightedStripEndPoint1Y+= strpEn*y1; weightedStripEndPoint1Z+= strpEn*z1; diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java index 640494bde1..bfdd01bc59 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java @@ -8,6 +8,7 @@ /** * * @author devita + * @author filippi */ public class FTTRKConstantsLoader { @@ -15,41 +16,71 @@ public class FTTRKConstantsLoader { } // geometry constants - public static final int Nlayers = 4; + public static final int Nlayers = 4; // 2 double layers, ordered as FTT1B+FTT1T, FTT3B+FTT3T + public static int NSupLayers = Nlayers/2; // bottom+top makes a a SuperLayer public static int Nstrips=768 ;// Number of strips - public static int Halfstrips ; // In the middle of the FMT, 320 strips are split in two. - public static int Sidestrips=312 ; - public static double[] Zlayer = {175, 176, 177, 178}; //Give z-coordinate of the layer - public static double[] Alpha = {0,90,0,90}; //Give the rotation angle to apply - public static double Pitch=0.05; //strip width - public static double Beamhole=7;//Radius of the hole in the center for the beam. + public static int SideHalfstrips; + public static int Longstrips=128; + public static double[] Zlayer = {175., 176., 177., 178.}; //Give z-coordinate of the layer + public static double[] Alpha = {0.,-0.5*Math.PI}; //Give the rotation angle to apply + public static double Pitch=0.056; //strip width + public static double Beamhole=14.086/2.;//Radius of the hole in the center for the beam (mm) // public static double Interstrip ; //inter strip public static double YCentral; public static double Rmax; - public static double[][] stripsXloc; //Give the local end-points x-coordinates of the strip segment - public static double[][] stripsYloc; //Give the local end-points y-coordinates of the strip segment + public static double[][][] stripsXloc; //Give the local end-points x-coordinates of the strip segment, per layer + public static double[][][] stripsYloc; //Give the local end-points y-coordinates of the strip segment, per layer public static double[] stripsXlocref; //Give the local ref-points x-coordinates of the strip segment public static double[] stripsYlocref; //Give the local ref-points y-coordinates of the strip segment public static double[][][] stripsX; //Give the end-points x-coordinates of the strip segment rotated in the correct frame for the layer public static double[][][] stripsY; //Give the end-points y-coordinates of the strip segment public static double[] stripslength; //Give the strip length - + public static int[] UStrips, IStrips; + + public static synchronized void Load() { - Sidestrips = (Nstrips -2*Halfstrips)/2; - YCentral = (double)Halfstrips*Pitch/2.; - Rmax = Pitch*(Halfstrips + 2*Sidestrips)/2.; - stripsXloc = new double[Nstrips][2]; - stripsYloc = new double[Nstrips][2]; + SideHalfstrips = (Nstrips -2*Longstrips)/2; + YCentral = (double)SideHalfstrips*Pitch/2.; + Rmax = Pitch*(SideHalfstrips + 2*Longstrips)/2.; + // 2d arrays: [0] origin, [1] segment endpoint + stripsXloc = new double[NSupLayers][Nstrips][2]; + stripsYloc = new double[NSupLayers][Nstrips][2]; stripsXlocref = new double[Nstrips]; - stripsYlocref = new double[Nstrips]; + stripsYlocref = new double[Nstrips]; stripsX = new double[Nlayers][Nstrips][2]; stripsY = new double[Nlayers][Nstrips][2]; stripslength = new double[Nstrips]; + UStrips = new int[2*Longstrips+SideHalfstrips]; + IStrips = new int[SideHalfstrips]; + + // fill the arrays with strip numbers ordered according to the module region. Start from 0. + for(int i=0; i0 && i<=256){ + regionY = -1; + }else if(i>384 && i<=512){ + regionY = -2; + }else if(i>256 && i<=384){ + regionY = 2; + }else if(i>512 && i<=768){ + regionY = 1; + } + return regionY; + } + + private static int getLocalRegionX(int strip){ + // the strips are read by the db table in the format 1-768 + // divide the geometry in horizontal direction in 6 contiguity regions + int regionX = 0; + int i = strip+1; + if(i>512 && i<=640){ + regionX = 1; + }else if(i>384 && i<=512){ + regionX = 2; + }else if(i>0 && i<=128){ + regionX = 3; + }else if(i>128 && i<=256){ + regionX = 4; + }else if(i>256 && i<=384){ + regionX = 5; + }else if(i>640 && i<=768){ + regionX = 6; + } + return regionX; + } + + } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java index acb2112f9c..63fd980669 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java @@ -16,14 +16,18 @@ import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.groot.data.H1F; import org.jlab.groot.data.H2F; +import org.jlab.groot.data.DataLine; import org.jlab.groot.graphics.EmbeddedCanvas; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.io.hipo.HipoDataSource; +import org.jlab.geom.prim.Line3D; +import org.jlab.geom.prim.Point3D; /** * * @author devita + * @author filippi */ public class FTTRKEngine extends ReconstructionEngine { @@ -77,6 +81,30 @@ public boolean processDataEvent(DataEvent event) { } return true; } + + public ArrayList processDataEventAndGetClusters(DataEvent event) { + List allHits = new ArrayList(); + List selectedHits = new ArrayList(); + ArrayList clusters = new ArrayList(); + List crosses = new ArrayList(); + + // update calibration constants based on run number if changed + int run = setRunConditionsParameters(event); + + if(run>=0) { + // get hits fron banks + allHits = reco.initFTTRK(event,this.getConstantsManager(), run); +// // select good hits and order them by energy +// selectedHits = reco.selectHits(allHits); + // create clusters + clusters = reco.findClusters(allHits); + // create crosses + crosses = reco.findCrosses(clusters); + // write output banks + reco.writeBanks(event, allHits, clusters, crosses); + } + return clusters; + } public int setRunConditionsParameters(DataEvent event) { int run = -1; @@ -92,24 +120,46 @@ public int setRunConditionsParameters(DataEvent event) { public static void main (String arg[]) { - FTTRKEngine trk = new FTTRKEngine(); - trk.init(); - String input = "/Users/devita/work/clas12/simulations/clas12Tags/4.3.1/out.hipo"; - HipoDataSource reader = new HipoDataSource(); - reader.open(input); + FTTRKEngine trk = new FTTRKEngine(); + trk.init(); + String input = "/Users/devita/Work/clas12/simulations/clas12Tags/4.3.1/out.hipo"; + HipoDataSource reader = new HipoDataSource(); + reader.open(input); - // initialize histos - H2F h1 = new H2F("h1", "Layer vs. Component",100, 0.,1000,5, 0.,5.); + // initialize histos + H2F h1 = new H2F("h1", "Layer vs. Component", 768, 0., 769., 4, 0.5, 4.5); h1.setTitleX("Component"); - h1.setTitleX("Layer"); + h1.setTitleY("Layer"); H1F h2 = new H1F("Energy",100, 0, 100); h2.setOptStat(Integer.parseInt("1111")); h2.setTitleX("Energy"); h2.setTitleY("Counts"); H1F h3 = new H1F("Time",100, -2, 2); h3.setOptStat(Integer.parseInt("1111")); h3.setTitleX("Time"); h3.setTitleY("Counts"); - while(reader.hasEvent()){ + H2F hHitL1 = new H2F("hHitL1","cross y vs x detector 1", 100, -13., 13., 100, -13., 13.); + H2F hHitL2 = new H2F("hHitL2","cross y vs x detector 2", 100, -13., 13., 100, -13., 13.); + H2F hHitMatch = new H2F("hHitL2","cross y vs x match", 100, -13., 13., 100, -13., 13.); +// H2F hHitL3 = new H2F("hHitL3","hit y vs x layer 3", 100, -13., 13., 100, -13., 13.); +// H2F hHitL4 = new H2F("hHitL4","hit y vs x layer 4", 100, -13., 13., 100, -13., 13.); + hHitL1.setTitleX("x cross detector 1"); hHitL1.setTitleY("y cross detector 1"); + hHitL2.setTitleX("x cross detector 2"); hHitL1.setTitleY("y cross detector 2"); + hHitMatch.setTitleX("x cross detector match"); hHitMatch.setTitleY("y cross detector match"); + DataLine segment[] = new DataLine[FTTRKConstantsLoader.Nstrips]; + + JFrame frameClusters = new JFrame("FT strips in clusters"); + frameClusters.setSize(800,800); + EmbeddedCanvas canvasCl = new EmbeddedCanvas(); + +// hHitL3.setTitleX("x hit layer3"); hHitL1.setTitleY("y hit layer 3"); +// hHitL4.setTitleX("x hit layer4"); hHitL1.setTitleY("y hit layer 4"); + + int nc1 = 0, nc2 = 0, ncmatch = 0, nStripsInClusters = 0; +// while(reader.hasEvent()){ +// int nev1 = 1; int nev2 = nev1+1; for(int nev=nev1; nev clusters = new ArrayList(); + clusters = trk.processDataEventAndGetClusters(event); DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); PhysicsEvent gen = detectorEvent.getGeneratedEvent(); @@ -122,12 +172,103 @@ public static void main (String arg[]) { float energy = bank.getFloat("energy",i); float time = bank.getFloat("time",i); + System.out.println("layer " + layer + " strip " + comp); h1.fill(comp,layer); h2.fill(energy); h3.fill(time); } + } + + // iterate along the cluster list for every event + if(clusters.size()!=0){ + // get one cluster and iterate over all the strips contained in it + for(int i = 0; i < clusters.size(); i++){ + // get a single cluster and count its strip, extract the information on extremal points of the segment + FTTRKCluster singleCluster = clusters.get(i); + int nst = singleCluster.size(); + for(int j=0; j1){ + for(int i=0; ii; j--){ + if(det[i]!=det[j]){ + double distance = Math.sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])); + if(distance < minDistance){ + minDistance = distance; + iBest = i; jBest = j; + } + } + } + } + System.out.println("minimum distance " + minDistance); + double distTolerance = 0.1; + if(minDistance < distTolerance) { + hHitMatch.fill((x[iBest]+x[jBest])/2., (y[iBest]+y[jBest])/2.); + ncmatch++; + } + } + } } + System.out.println("number of found crosses: module 1: " + nc1 + " module 2: " + nc2 + " matching crosses " + ncmatch); + + JFrame frame = new JFrame("FT Reconstruction"); frame.setSize(800,800); EmbeddedCanvas canvas = new EmbeddedCanvas(); @@ -137,7 +278,23 @@ public static void main (String arg[]) { canvas.cd(2); canvas.draw(h3); frame.add(canvas); frame.setLocationRelativeTo(null); - frame.setVisible(true); + frame.setVisible(true); + + JFrame frame2 = new JFrame("FT crosses coordinates per module"); + frame2.setSize(800,800); + EmbeddedCanvas canvas2 = new EmbeddedCanvas(); + canvas2.divide(2,2); + canvas2.cd(0); canvas2.draw(hHitL1); + canvas2.cd(1); canvas2.draw(hHitL2); + canvas2.cd(2); canvas2.draw(hHitMatch); +// for(int i=0; i{ // class implements Comparable interface to allow for sorting a collection of hits by wire number values @@ -26,7 +27,7 @@ public class FTTRKHit implements Comparable{ */ public FTTRKHit(int sector, int layer, int strip, double Edep) { this._Sector = sector; - this._Layer = layer; + this._Layer = layer; this._Strip = strip; this._Edep = Edep; @@ -35,16 +36,30 @@ public FTTRKHit(int sector, int layer, int strip, double Edep) { double y0 = FTTRKConstantsLoader.stripsY[layer-1][strip-1][0]; double y1 = FTTRKConstantsLoader.stripsY[layer-1][strip-1][1]; double Z = FTTRKConstantsLoader.Zlayer[layer-1]; // z + Line3D seg = new Line3D(); seg.setOrigin(new Point3D(x0,y0,Z)); seg.setEnd(new Point3D(x1,y1,Z)); set_StripSegment(seg); +// System.out.println("++++++++++++ strip origin, layer " + layer + " strip " + strip + " x " + x0 + " y0 " + y0 + " z0 " + Z); +// System.out.println("++++++++++++ strip end, layer " + layer + " strip " + strip + " x1 " + x1 + " y1 " + y1); + + /// for debugging purposes + int Slayer = this.get_SuperLayer(layer); + double x0loc = FTTRKConstantsLoader.stripsXloc[Slayer][strip-1][0]; + double x1loc = FTTRKConstantsLoader.stripsXloc[Slayer][strip-1][1]; + double y0loc = FTTRKConstantsLoader.stripsYloc[Slayer][strip-1][0]; + double y1loc = FTTRKConstantsLoader.stripsYloc[Slayer][strip-1][1]; +// System.out.println("~~~~~~~~~~~ strip origin local frame " + " x " + x0loc + " y " + y0loc + " layer " + layer + " Slayer " + Slayer); +// System.out.println("~~~~~~~~~~~ strip endpoint local frame " + " x " + x1loc + " y " + y1loc + " layer " + layer + " Slayer " + Slayer); +// System.out.println(""); +// } - private int _Sector; // sector[1...24] - private int _Layer; // layer [1,...6] - private int _Strip; // strip [1...256] + private int _Sector; // sector[1] + private int _Layer; // layer [1,..4] + private int _Strip; // strip [1...768] private double _Edep; // Reconstructed time, for now it is the gemc time private Line3D _StripSegment; // The geometry segment representing the strip position @@ -57,7 +72,7 @@ public FTTRKHit(int sector, int layer, int strip, double Edep) { /** * - * @return the sector (1...24) + * @return the sector (1) */ public int get_Sector() { return _Sector; @@ -74,7 +89,7 @@ public void set_Sector(int _Sector) { /** * - * @return the layer (1...8) + * @return the layer (1-4) */ public int get_Layer() { return _Layer; @@ -88,9 +103,17 @@ public void set_Layer(int _Layer) { this._Layer = _Layer; } + /** + * + * @return the superlayer: 0 (for bottom modules, 1,3), 1 (for top modules, 2, 4) + */ + public int get_SuperLayer(int _Layer){ + return (_Layer+1)%2; + } + /** * - * @return the wire number (1...256) + * @return the wire number (1...768) */ public int get_Strip() { return _Strip; @@ -146,22 +169,24 @@ public void set_Id(int _Id) { this._Id = _Id; } - /** * - * @return region (1...4) + * @return region (1-2) */ + public int get_Region() { return (int) (this._Layer+1)/2; } + /** * * @return superlayer 1 or 2 in region (1...4) */ + /* public int get_RegionSlayer() { return (this._Layer+1)%2+1; } - + */ public Line3D get_StripSegment() { return _StripSegment; } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index bf55e22979..5e9fbabf50 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -15,6 +15,7 @@ /** * * @author devita + * @author filippi */ public class FTTRKReconstruction { @@ -49,26 +50,35 @@ public ArrayList findClusters(List hits) // cluster finding algorithm // the loop is done over sectors - int nlayer = FTTRKConstantsLoader.Nlayers; - int nstrip = FTTRKConstantsLoader.Nstrips; + int Nlayers = FTTRKConstantsLoader.Nlayers; + int Nstrips = FTTRKConstantsLoader.Nstrips; + /* + int logStripsBottom[] = FTTRKConstantsLoader.longStripsDown; + int longStripsUp[] = FTTRKConstantsLoader.longStripsUp; + int shortStripsLeft[] = FTTRKConstantsLoader.shortStripsLeft; + int shortStripsRight[] = FTTRKConstantsLoader.shortStripsRight; + */ boolean[][] checked; FTTRKHit[][] HitArray; ArrayList clusters = new ArrayList(); + // + + // a boolean array to avoid double counting at the numbering discontinuities - checked = new boolean[nstrip][nlayer] ; - for(int l=0; l findClusters(List hits) int w = hit.get_Strip(); int l = hit.get_Layer(); - if(w>0 && w<=nstrip) { + if(w>0 && w<=Nstrips) { HitArray[w-1][l-1] = hit; if(debugMode>=1) System.out.println(w + " " + l + " " + HitArray[w-1][l-1].printInfo()); } } int cid = 1; // cluster id, will increment with each new good cluster + int cidLim = 1; // for each layer and sector, a loop over the strips // is done to define clusters in that module's layer - // clusters are delimited by strips with no hits - for(int il=0; il clusterHits = new ArrayList(); + + // adding all hits in this and all the subsequent + // strip until there's a strip with no hit + int issnext = iss+1; + int isnext = is+1; + // check if the next strip is hit (but only if it's not the last one on the layer) + while(HitArray[issnext][il] != null && issnext=1) System.out.println(issnext); + issnext++; + isnext++; +// if(issnext == ) +// if(issnext!=Nstrips){issnext++;}else{System.out.println("dove vai ? " + is + " " + iss); break;} + } + // define new cluster + if(isUstripAtLimit){ + FTTRKCluster clusterAtLimit = new FTTRKCluster(1, il+1, cidLim++); + }else{ + // add hits to the cluster + FTTRKCluster this_cluster = new FTTRKCluster(1, il+1, cid++); + this_cluster.addAll(clusterHits); + this_cluster.calc_CentroidParams(); + //make arraylist + clusters.add(this_cluster); + if(debugMode>=1) System.out.println((iss-1) + " cluster identifier in FTTRKReco, UStrip section " + cid + " layer " + il); + } + } + } + + /* + // loop on Istrips (half strips on one side of the hole: 385-640) + for(int is=0; is < nIStrips; is++){ + int iss = FTTRKConstantsLoader.IStrips[is]; + if(HitArray[iss][il] != null && !checked[is][il]){ + // how many strips in the cluster + int nst = 1; + // if there is a strip start to store it as a cluster seed + ArrayList clusterHits = new ArrayList(); + + // adding all hits in this and all the subsequent + // strip until there's a strip with no hit + int issnext = iss+1; + int isnext = is+1; + // check if the next strip is hit (but only if it's not the last one on the layer) + while(HitArray[issnext][il] != null && isnext findClusters(List hits) // adding all hits in this and all the subsequent // strip until there's a strip with no hit // Strip 1 and 513 needs a particular loop + // strips in bottom layer and in top layer have different numberings according to regions, beware of contiguity + // between different regions + + nstripRight + if(il==1 || il==3){ + // all strips + while(HitArray[is][il] != null && is findClusters(List hits) sj++; } } - +*/ //For all strips - while(HitArray[is][il] != null && is findCrosses(List clusters) { From aa092238d2dc09f774c740eb2a6e88b446c11c5c Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Mon, 25 Mar 2019 18:05:57 -0400 Subject: [PATCH 005/104] FTTRK: fixes to geometry and clustering --- .../jlab/rec/ft/trk/FTTRKConstantsLoader.java | 110 ++++--- .../java/org/jlab/rec/ft/trk/FTTRKCross.java | 4 +- .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 109 ++++--- .../java/org/jlab/rec/ft/trk/FTTRKHit.java | 28 +- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 268 ++++++------------ 5 files changed, 217 insertions(+), 302 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java index bfdd01bc59..19d87f28fe 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java @@ -22,11 +22,12 @@ public class FTTRKConstantsLoader { public static int SideHalfstrips; public static int Longstrips=128; public static double[] Zlayer = {175., 176., 177., 178.}; //Give z-coordinate of the layer - public static double[] Alpha = {0.,-0.5*Math.PI}; //Give the rotation angle to apply +// public static double[] Alpha = {0.,0.5*Math.PI}; //Give the rotation angle to apply + public static double[] Alpha = {-0.5*Math.PI, 0.}; //Give the rotation angle to apply public static double Pitch=0.056; //strip width public static double Beamhole=14.086/2.;//Radius of the hole in the center for the beam (mm) // public static double Interstrip ; //inter strip - public static double YCentral; + public static double InnerHole; public static double Rmax; public static double[][][] stripsXloc; //Give the local end-points x-coordinates of the strip segment, per layer public static double[][][] stripsYloc; //Give the local end-points y-coordinates of the strip segment, per layer @@ -35,14 +36,14 @@ public class FTTRKConstantsLoader { public static double[][][] stripsX; //Give the end-points x-coordinates of the strip segment rotated in the correct frame for the layer public static double[][][] stripsY; //Give the end-points y-coordinates of the strip segment public static double[] stripslength; //Give the strip length - public static int[] UStrips, IStrips; + /// public static int[] UStrips, IStrips; public static synchronized void Load() { - SideHalfstrips = (Nstrips -2*Longstrips)/2; - YCentral = (double)SideHalfstrips*Pitch/2.; - Rmax = Pitch*(SideHalfstrips + 2*Longstrips)/2.; + SideHalfstrips = (Nstrips -2*Longstrips)/4; // 128 + InnerHole = (double)SideHalfstrips*Pitch; // 7.168 cm, exceeds Beamhole by 0.125 cm - reference as minimum radius + Rmax = Pitch*(SideHalfstrips + Longstrips); // 21.504 // 2d arrays: [0] origin, [1] segment endpoint stripsXloc = new double[NSupLayers][Nstrips][2]; stripsYloc = new double[NSupLayers][Nstrips][2]; @@ -51,30 +52,34 @@ public static synchronized void Load() { stripsX = new double[Nlayers][Nstrips][2]; stripsY = new double[Nlayers][Nstrips][2]; stripslength = new double[Nstrips]; + + int debug = FTTRKReconstruction.debugMode; - UStrips = new int[2*Longstrips+SideHalfstrips]; - IStrips = new int[SideHalfstrips]; - // fill the arrays with strip numbers ordered according to the module region. Start from 0. + /* for(int i=0; i=1) System.out.println(Constants.getLocalRegion(i)+" strip-1 = "+i+" x' "+stripsXloc[i][1]+" y' "+stripsYloc[i][1]+" length "+stripslength[i]+" Beamhole "+Beamhole); } } System.out.println("***** FTTRK constants loaded"); } - - /* - private static int getLocalRegion(int i) { - // To represent the geometry we divide the barrel micromega disk into 3 regions according to the strip numbering system. - // Here i = strip_number -1; - // Region 1 is the region in the negative x part of inner region: the strips range is from 1 to 320 ( 0 <= i < 320) - // Region 2 is the region in the negative y part of outer region: the strips range is from 321 to 512 ( 320 <= i < 512) - // Region 3 is the region in the positive x part of inner region: the strips range is from 513 to 832 ( 512 <= i < 832) - // Region 4 is the region in the positive y part of outer region: the strips range is from 833 to 1024 ( 832 <= i < 1024) - - int region = 0; - if(i>=0 && i<320) - region =1; - if(i>=320 && i<512) - region =2; - if(i>=512 && i<832) - region =3; - if(i>=832 && i<1024) - region =4; - - return region; - } - */ - private static int getLocalRegionY(int strip){ // the strips are read by the db table in the format 1-768 // divide the geometry in vertical direction in 4 contiguity regions int regionY = 0; int i = strip+1; - if(i>0 && i<=256){ + int stripBlock = Nstrips/6; + if(i>0 && i<=stripBlock*2){ regionY = -1; - }else if(i>384 && i<=512){ + }else if(i>stripBlock*3 && i<=stripBlock*4){ regionY = -2; - }else if(i>256 && i<=384){ + }else if(i>stripBlock*2 && i<=stripBlock*3){ regionY = 2; - }else if(i>512 && i<=768){ + }else if(i>stripBlock*4 && i<=Nstrips){ regionY = 1; } return regionY; @@ -229,17 +222,18 @@ private static int getLocalRegionX(int strip){ // divide the geometry in horizontal direction in 6 contiguity regions int regionX = 0; int i = strip+1; - if(i>512 && i<=640){ + int stripBlock = Nstrips/6; + if(i>stripBlock*4 && i<=stripBlock*5){ // 513-640 regionX = 1; - }else if(i>384 && i<=512){ + }else if(i>stripBlock*3 && i<=stripBlock*4){ // 385-512 regionX = 2; - }else if(i>0 && i<=128){ + }else if(i>0 && i<=stripBlock){ // 1-128 regionX = 3; - }else if(i>128 && i<=256){ + }else if(i>stripBlock && i<=stripBlock*2){ // 129-256 regionX = 4; - }else if(i>256 && i<=384){ + }else if(i>stripBlock*2 && i<=stripBlock*3){ // 257-384 regionX = 5; - }else if(i>640 && i<=768){ + }else if(i>stripBlock*5 && i<=Nstrips){ // 641-768 regionX = 6; } return regionX; diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java index 76bc4dd555..6593196bf7 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java @@ -26,8 +26,8 @@ public class FTTRKCross extends ArrayList implements Comparable clusters = new ArrayList(); clusters = trk.processDataEventAndGetClusters(event); + int nStripsInClusters = 0; DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); PhysicsEvent gen = detectorEvent.getGeneratedEvent(); @@ -172,57 +185,50 @@ public static void main (String arg[]) { float energy = bank.getFloat("energy",i); float time = bank.getFloat("time",i); - System.out.println("layer " + layer + " strip " + comp); + if(debug>=1) System.out.println("layer " + layer + " strip " + comp); h1.fill(comp,layer); h2.fill(energy); h3.fill(time); } } + // iterate along the cluster list for every event + if(debug>=1) System.out.println("clusters size --- " + clusters.size()); + // DataLine segment[] = new DataLine[clusters.size()]; if(clusters.size()!=0){ // get one cluster and iterate over all the strips contained in it + canvasCl.cd(1); canvasCl.draw(hHitL1); + for(int l=0; l<4; l++){ + canvasClSingleLay.cd(l); + if(l==2 || l==3){canvasClSingleLay.draw(hHitL2);}else{canvasClSingleLay.draw(hHitL1);} + } for(int i = 0; i < clusters.size(); i++){ // get a single cluster and count its strip, extract the information on extremal points of the segment FTTRKCluster singleCluster = clusters.get(i); int nst = singleCluster.size(); + if(debug>=1) System.out.println("nst - " + nst); for(int j=0; j=1) System.out.println("total number of clusters " + clusters.size() + " - number of cluster " + i + " cluster size " + singleCluster.size() + " strip# " + j + " clusterId " + singleCluster.get_Id() + - " layer " + singleCluster.get_Layer() + " seed strip number " + singleCluster.get_SeedStrip() + " segment -------------- " + seg.origin().x() + " " + seg.origin().y()); + " layer " + singleCluster.get_Layer() + " seed strip number " + singleCluster.get_SeedStrip() + + " segment -------------- " + seg.origin().x() + " " + seg.origin().y() + " " + seg.end().x() + " " + seg.end().y()); segment[nStripsInClusters] = new DataLine(seg.origin().x(), seg.origin().y(), seg.end().x(), seg.end().y()); - canvasCl.draw(hHitL1); + int lay = singleCluster.get_Layer(); + segment[nStripsInClusters].setLineColor(lay); + // canvasCl.cd(1); canvasCl.draw(hHitL1); + if(debug>=1) System.out.println("nStripsInCluster " + nStripsInClusters); canvasCl.draw(segment[nStripsInClusters]); + canvasClSingleLay.cd(lay-1); canvasClSingleLay.draw(segment[nStripsInClusters]); + nStripsInClusters++; } } } -/* - System.out.println("is there the cluster bank? " + event.hasBank("FTTRK::clusters")); - if(event.hasBank("FTTRK::clusters")){ - DataBank cluBank = event.getBank("FTTRK::clusters"); - int nrows = cluBank.rows(); - Line3D seg; - for(int i=0; i=1) System.out.println("is there the crosses bank? " + event.hasBank("FTTRK::crosses")); if(event.hasBank("FTTRK::crosses")){ DataBank crossBank = event.getBank("FTTRK::crosses"); int nrows = crossBank.rows(); @@ -236,7 +242,7 @@ public static void main (String arg[]) { det[i] = crossBank.getByte("detector",i); x[i] = crossBank.getFloat("x", i); y[i] = crossBank.getFloat("y", i); - System.out.println("detector " + det[i] + " x " + x[i] + " y " + y[i]); + if(debug>=2) System.out.println("number of crosses " + nrows + " detector " + det[i] + " x " + x[i] + " y " + y[i]); if(det[i]==1) {hHitL1.fill(x[i], y[i]); nc1++;} if(det[i]==2) {hHitL2.fill(x[i], y[i]); nc2++;} @@ -244,7 +250,7 @@ public static void main (String arg[]) { /// loop on all crosses on detector 1 and 2 and find the oone with better matching double minDistance = 1000; int iBest = -1, jBest = -1; - System.out.println("number of rows " + nrows); + if(debug>=1) System.out.println("number of rows " + nrows); if(nrows>1){ for(int i=0; ii; j--){ @@ -257,8 +263,9 @@ public static void main (String arg[]) { } } } - System.out.println("minimum distance " + minDistance); + if(debug>=1) System.out.println("minimum distance " + minDistance); double distTolerance = 0.1; + distTolerance = 1000; if(minDistance < distTolerance) { hHitMatch.fill((x[iBest]+x[jBest])/2., (y[iBest]+y[jBest])/2.); ncmatch++; @@ -266,8 +273,9 @@ public static void main (String arg[]) { } } } - System.out.println("number of found crosses: module 1: " + nc1 + " module 2: " + nc2 + " matching crosses " + ncmatch); + + if(debug>=1) System.out.println("number of found crosses: module 1: " + nc1 + " module 2: " + nc2 + " matching crosses " + ncmatch); JFrame frame = new JFrame("FT Reconstruction"); frame.setSize(800,800); @@ -287,8 +295,6 @@ public static void main (String arg[]) { canvas2.cd(0); canvas2.draw(hHitL1); canvas2.cd(1); canvas2.draw(hHitL2); canvas2.cd(2); canvas2.draw(hHitMatch); -// for(int i=0; i{ * @param Edep (for gemc output without digitization) */ public FTTRKHit(int sector, int layer, int strip, double Edep) { + int debug = FTTRKReconstruction.debugMode; this._Sector = sector; this._Layer = layer; this._Strip = strip; @@ -41,19 +42,21 @@ public FTTRKHit(int sector, int layer, int strip, double Edep) { seg.setOrigin(new Point3D(x0,y0,Z)); seg.setEnd(new Point3D(x1,y1,Z)); set_StripSegment(seg); -// System.out.println("++++++++++++ strip origin, layer " + layer + " strip " + strip + " x " + x0 + " y0 " + y0 + " z0 " + Z); -// System.out.println("++++++++++++ strip end, layer " + layer + " strip " + strip + " x1 " + x1 + " y1 " + y1); - + if(debug>=1){ + System.out.println("++++++++++++ strip origin, layer " + layer + " strip " + strip + " x " + x0 + " y0 " + y0 + " z0 " + Z); + System.out.println("++++++++++++ strip end, layer " + layer + " strip " + strip + " x1 " + x1 + " y1 " + y1); + } /// for debugging purposes int Slayer = this.get_SuperLayer(layer); double x0loc = FTTRKConstantsLoader.stripsXloc[Slayer][strip-1][0]; double x1loc = FTTRKConstantsLoader.stripsXloc[Slayer][strip-1][1]; double y0loc = FTTRKConstantsLoader.stripsYloc[Slayer][strip-1][0]; double y1loc = FTTRKConstantsLoader.stripsYloc[Slayer][strip-1][1]; -// System.out.println("~~~~~~~~~~~ strip origin local frame " + " x " + x0loc + " y " + y0loc + " layer " + layer + " Slayer " + Slayer); -// System.out.println("~~~~~~~~~~~ strip endpoint local frame " + " x " + x1loc + " y " + y1loc + " layer " + layer + " Slayer " + Slayer); -// System.out.println(""); -// + if(debug>=1){ + System.out.println("~~~~~~~~~~~ strip origin local frame " + " x " + x0loc + " y " + y0loc + " layer " + layer + " Slayer " + Slayer); + System.out.println("~~~~~~~~~~~ strip endpoint local frame " + " x " + x1loc + " y " + y1loc + " layer " + layer + " Slayer " + Slayer); + System.out.println(""); + } } @@ -107,7 +110,7 @@ public void set_Layer(int _Layer) { * * @return the superlayer: 0 (for bottom modules, 1,3), 1 (for top modules, 2, 4) */ - public int get_SuperLayer(int _Layer){ + public int get_SuperLayer(int _Layer){ return (_Layer+1)%2; } @@ -178,15 +181,6 @@ public int get_Region() { return (int) (this._Layer+1)/2; } - /** - * - * @return superlayer 1 or 2 in region (1...4) - */ - /* - public int get_RegionSlayer() { - return (this._Layer+1)%2+1; - } - */ public Line3D get_StripSegment() { return _StripSegment; } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index 5e9fbabf50..2930196e2c 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -19,7 +19,7 @@ */ public class FTTRKReconstruction { - public int debugMode = 0; + public static int debugMode = 0; public FTTRKReconstruction() { } @@ -47,23 +47,17 @@ public List initFTTRK(DataEvent event, ConstantsManager manager, int r public ArrayList findClusters(List hits) { + int debugMode=FTTRKReconstruction.debugMode; // cluster finding algorithm // the loop is done over sectors int Nlayers = FTTRKConstantsLoader.Nlayers; int Nstrips = FTTRKConstantsLoader.Nstrips; - /* - int logStripsBottom[] = FTTRKConstantsLoader.longStripsDown; - int longStripsUp[] = FTTRKConstantsLoader.longStripsUp; - int shortStripsLeft[] = FTTRKConstantsLoader.shortStripsLeft; - int shortStripsRight[] = FTTRKConstantsLoader.shortStripsRight; - */ - boolean[][] checked; + boolean[][] checked; FTTRKHit[][] HitArray; ArrayList clusters = new ArrayList(); - - // - + FTTRKHit[] clusterHitAtBorder = new FTTRKHit[3]; + int[] limitingStrip = {127, 383, 639}; // strip numbering from 0 to 767 // a boolean array to avoid double counting at the numbering discontinuities checked = new boolean[Nstrips][Nlayers] ; @@ -76,196 +70,108 @@ public ArrayList findClusters(List hits) // a Hit Array is used to identify clusters HitArray = new FTTRKHit[Nstrips][Nlayers] ; - // initializing non-zero Hit Array entries // fill with valid hits for(FTTRKHit hit : hits) { - if(hit.get_Strip()==-1) continue; - int w = hit.get_Strip(); int l = hit.get_Layer(); - if(w>0 && w<=Nstrips) { + if(w>0 && w<=Nstrips){ HitArray[w-1][l-1] = hit; if(debugMode>=1) System.out.println(w + " " + l + " " + HitArray[w-1][l-1].printInfo()); } } - int cid = 1; // cluster id, will increment with each new good cluster - int cidLim = 1; + int cid = 0; // cluster id, will increment with each new good cluster - // for each layer and sector, a loop over the strips - // is done to define clusters in that module's layer + // for each layer and sector, loop over the strips: + // once one is selected for the first time, loop over the remainder // clusters are delimited by strips with no hits - // divide the layer geometry in two parts: U part with contiguous numbering, I part is the insert on the other side coresponding to the hole section - int nUStrips = 2*FTTRKConstantsLoader.Longstrips + FTTRKConstantsLoader.SideHalfstrips; - int nIStrips = FTTRKConstantsLoader.SideHalfstrips; - - for(int il=0; il clusterHits = new ArrayList(); - - // adding all hits in this and all the subsequent - // strip until there's a strip with no hit - int issnext = iss+1; - int isnext = is+1; - // check if the next strip is hit (but only if it's not the last one on the layer) - while(HitArray[issnext][il] != null && issnext=1) System.out.println(issnext); - issnext++; - isnext++; -// if(issnext == ) -// if(issnext!=Nstrips){issnext++;}else{System.out.println("dove vai ? " + is + " " + iss); break;} - } - // define new cluster - if(isUstripAtLimit){ - FTTRKCluster clusterAtLimit = new FTTRKCluster(1, il+1, cidLim++); - }else{ - // add hits to the cluster - FTTRKCluster this_cluster = new FTTRKCluster(1, il+1, cid++); - this_cluster.addAll(clusterHits); - this_cluster.calc_CentroidParams(); - //make arraylist - clusters.add(this_cluster); - if(debugMode>=1) System.out.println((iss-1) + " cluster identifier in FTTRKReco, UStrip section " + cid + " layer " + il); - } - } - } - - /* - // loop on Istrips (half strips on one side of the hole: 385-640) - for(int is=0; is < nIStrips; is++){ - int iss = FTTRKConstantsLoader.IStrips[is]; - if(HitArray[iss][il] != null && !checked[is][il]){ - // how many strips in the cluster - int nst = 1; - // if there is a strip start to store it as a cluster seed - ArrayList clusterHits = new ArrayList(); - - // adding all hits in this and all the subsequent - // strip until there's a strip with no hit - int issnext = iss+1; - int isnext = is+1; - // check if the next strip is hit (but only if it's not the last one on the layer) - while(HitArray[issnext][il] != null && isnext clusterHits = new ArrayList(); - - // adding all hits in this and all the subsequent - // strip until there's a strip with no hit - // Strip 1 and 513 needs a particular loop - // strips in bottom layer and in top layer have different numberings according to regions, beware of contiguity - // between different regions - - nstripRight - if(il==1 || il==3){ - // all strips - while(HitArray[is][il] != null && is clusterHits = new ArrayList(); + int nst=0; + if(HitArray[is][il] != null && !checked[is][il]){ + // select one fired strip + checked[is][il]=true; + // if it's fired it is the seed of the cluster (which may be formed by one stip only + clusterHits.add(new FTTRKHit(HitArray[is][il].get_Sector(),HitArray[is][il].get_Layer(), + HitArray[is][il].get_Strip(),HitArray[is][il].get_Edep())); + if(debugMode>=1) System.out.println("hitArray " + HitArray[is][il].printInfo()); + // now check if there are tother strips to be added to the cluster + int isnext = is; + // is it a limiting strip? + if(is==limitingStrip[0]){ // strip 127: next one can be 384 or 128 + if(HitArray[limitingStrip[0]+1][il] != null){ + isnext++; + }else if(HitArray[limitingStrip[1]+1][il] != null){ + isnext = limitingStrip[1]+1; } - } - - if (is==512){ - int sj=320; - while(HitArray[sj][il] != null && sj<512) { - checked[sj][il]=true; - clusterHits.add(new FTTRKHit(HitArray[sj][il].get_Sector(),HitArray[sj][il].get_Layer(),HitArray[sj][il].get_Strip(),HitArray[sj][il].get_Edep())); - sj++; + while(HitArray[isnext][il] != null && isnext=1) System.out.println("cluster number " + cid + " size " + clusterHits.size() + " layer " + this_cluster.get_Layer() + + " " + this_cluster.get_MaxStrip() + "-" + this_cluster.get_MinStrip() + " " + this_cluster.get_Centroid()) ; - - // if no hits, check for next wire coordinate -// is++; - - + } // check on seed + } // end loop on strips } // end loop on layers return clusters; - } public ArrayList findCrosses(List clusters) { + int debugMode=FTTRKReconstruction.debugMode; // first separate the segments according to layers ArrayList allinnerlayrclus = new ArrayList(); ArrayList allouterlayrclus = new ArrayList(); @@ -300,8 +206,12 @@ public ArrayList findCrosses(List clusters) { this_cross.set_CrossParams(); //make arraylist - crosses.add(this_cross); - if(debugMode>=1) System.out.println(this_cross.printInfo() + " " + crosses.size()); + // check if the cross center is in a physical position + double radXCenter = Math.sqrt(this_cross.get_Point().x()*this_cross.get_Point().x() + + this_cross.get_Point().y()*this_cross.get_Point().y()); + if(debugMode>=1) System.out.println("cross radius =============" + radXCenter); + if(radXCenter > FTTRKConstantsLoader.InnerHole && radXCenter < FTTRKConstantsLoader.Rmax) crosses.add(this_cross); + if(debugMode>=1) System.out.println("cross info :" + this_cross.printInfo() + " " + crosses.size()); } } } @@ -357,6 +267,7 @@ public void writeBanks(DataEvent event, List hits, List event.appendBanks(bankHits); } // cluster bank + if(debugMode>=1) System.out.println("cluster bank size " + clusters.size()); if(clusters.size()!=0){ DataBank bankCluster = event.createBank("FTTRK::clusters", clusters.size()); if(bankCluster==null){ @@ -376,6 +287,7 @@ public void writeBanks(DataEvent event, List hits, List event.appendBanks(bankCluster); } // cross bank + if(debugMode>=1) System.out.println("crosses bank size " + crosses.size()); if(crosses.size()!=0){ DataBank bankCross = event.createBank("FTTRK::crosses", crosses.size()); if(bankCross==null){ From 7e815a0aae03a1b9305bec655cd09aa3b96cd738 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Wed, 27 Mar 2019 08:34:30 -0400 Subject: [PATCH 006/104] FTTRK: fix order of boolean expression in while loops --- .../java/org/jlab/rec/ft/trk/FTTRKReconstruction.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index 2930196e2c..5c6a9191f0 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -110,7 +110,7 @@ public ArrayList findClusters(List hits) }else if(HitArray[limitingStrip[1]+1][il] != null){ isnext = limitingStrip[1]+1; } - while(HitArray[isnext][il] != null && isnext findClusters(List hits) } }else if(is==limitingStrip[1]){ isnext = limitingStrip[2]+1; - while(HitArray[isnext][il] != null && isnext findClusters(List hits) } }else if(is==limitingStrip[2]){ // strip 383||639: next strip is 640 isnext = limitingStrip[2]+1; - while(HitArray[isnext][il] != null && isnext findClusters(List hits) } }else{ // the first strip is not at the border of any zone, check is other strips can be added to the cluster - while(HitArray[isnext][il] != null && isnext Date: Sun, 10 Jan 2021 15:02:57 +0100 Subject: [PATCH 007/104] fttrk tracking updates --- .../org/jlab/clas/reco/EngineProcessor.java | 90 ++- .../org/jlab/clas/reco/io/EvioHipoEvent4.java | 4 +- etc/bankdefs/hipo/FT.json | 27 +- etc/bankdefs/hipo4/ft.json | 59 +- etc/bankdefs/util/bankSplit.py | 16 +- etc/services/data.yaml | 4 +- etc/services/data_endplates.yaml | 2 + etc/services/dst.yaml | 2 +- etc/services/mc.yaml | 6 +- etc/services/reconstruction.yaml | 7 +- .../java/org/jlab/rec/ft/FTConstants.java | 14 +- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 662 +++++++++++++++++- .../java/org/jlab/rec/ft/FTEventBuilder.java | 221 +++++- .../main/java/org/jlab/rec/ft/FTParticle.java | 23 +- .../java/org/jlab/rec/ft/cal/FTCALEngine.java | 9 +- .../org/jlab/rec/ft/trk/FTTRKCluster.java | 146 +++- .../jlab/rec/ft/trk/FTTRKConstantsLoader.java | 141 +--- .../java/org/jlab/rec/ft/trk/FTTRKCross.java | 177 +++-- .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 260 +++++-- .../java/org/jlab/rec/ft/trk/FTTRKHit.java | 141 ++-- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 477 ++++++++++--- 21 files changed, 2014 insertions(+), 474 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java index 035539258c..7e7a7beb03 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java @@ -1,7 +1,13 @@ +/* + * 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.clas.reco; import java.io.FileNotFoundException; import java.io.IOException; +import java.lang.ClassCastException; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -12,19 +18,19 @@ import org.jlab.io.hipo.HipoDataSync; import org.jlab.utils.benchmark.ProgressPrintout; import org.jlab.utils.options.OptionParser; +import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.clara.engine.EngineData; import org.jlab.clara.engine.EngineDataType; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; import java.io.InputStream; import java.io.FileInputStream; -import org.jlab.utils.JsonUtils; import org.json.JSONObject; /** * - * @author gavalian, kenjo, baltzell + * @author gavalian, kenjo */ public class EngineProcessor { @@ -68,6 +74,10 @@ public void initDefault(){ for(int i = 0; i < names.length; i++){ this.addEngine(names[i], services[i]); } + /* + for(String service : services){ + this.addEngine(service); + }*/ } public void initAll(){ @@ -107,8 +117,11 @@ public void initAll(){ for(int i = 0; i < names.length; i++){ this.addEngine(names[i], services[i]); } + /* + for(String service : services){ + this.addEngine(service); + }*/ } - public void initCaloDebug(){ String[] names = new String[]{ @@ -123,23 +136,26 @@ public void initCaloDebug(){ for(int i = 0; i < names.length; i++){ this.addEngine(names[i], services[i]); } + /* + for(String service : services){ + this.addEngine(service); + }*/ } - /** * Adding engine to the map the order of the services matters, since they will * be executed in order added. * @param name name for the service * @param clazz class name including the package name - * @param jsonConf string in json format with engine configuration + * @param jsonConfig string in json format with engine configuration */ public void addEngine(String name, String clazz, String jsonConf) { - Class c; + Class c = null; try { c = Class.forName(clazz); if( ReconstructionEngine.class.isAssignableFrom(c)==true){ ReconstructionEngine engine = (ReconstructionEngine) c.newInstance(); engine.init(); - if(!jsonConf.equals("null")) { + if(jsonConf!="null") { EngineData input = new EngineData(); input.setData(EngineDataType.JSON.mimeType(), jsonConf); engine.configure(input); @@ -148,11 +164,14 @@ public void addEngine(String name, String clazz, String jsonConf) { } else { System.out.println(">>>> ERROR: class is not a reconstruction engine : " + clazz); } - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { + } catch (ClassNotFoundException ex) { + Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); } } - /** * Adding engine to the map the order of the services matters, since they will * be executed in order added. @@ -160,7 +179,7 @@ public void addEngine(String name, String clazz, String jsonConf) { * @param clazz class name including the package name */ public void addEngine(String name, String clazz) { - Class c; + Class c = null; try { c = Class.forName(clazz); if( ReconstructionEngine.class.isAssignableFrom(c)==true){ @@ -170,17 +189,20 @@ public void addEngine(String name, String clazz) { } else { System.out.println(">>>> ERROR: class is not a reconstruction engine : " + clazz); } - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { + } catch (ClassNotFoundException ex) { + Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); } } - /** * Add reconstruction engine to the chain * @param clazz Engine class. */ public void addEngine( String clazz) { - Class c; + Class c = null; try { c = Class.forName(clazz); if( ReconstructionEngine.class.isAssignableFrom(c)==true){ @@ -190,11 +212,14 @@ public void addEngine( String clazz) { } else { System.out.println(">>>> ERROR: class is not a reconstruction engine : " + clazz); } - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { + } catch (ClassNotFoundException ex) { + Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); } } - /** * Initialize all the engines in the chain. */ @@ -207,7 +232,6 @@ public void init(){ } System.out.println("\n\n"); } - /** * process a single event through the chain. * @param event @@ -215,11 +239,8 @@ public void init(){ public void processEvent(DataEvent event){ for(Map.Entry engine : this.processorEngines.entrySet()){ try { - if (!engine.getValue().wroteConfig) { - engine.getValue().wroteConfig = true; - JsonUtils.extend(event, ReconstructionEngine.CONFIG_BANK_NAME, "json", - engine.getValue().generateConfig()); - } + //System.out.println("processing engine : " + engine.getKey()); + //System.out.println("processing event"); engine.getValue().processDataEvent(event); } catch (Exception e){ @@ -233,12 +254,10 @@ public void processEvent(DataEvent event){ public void processFile(String file, String output){ this.processFile(file, output, -1); } - /** * process entire file through engine chain. * @param file file name to process. * @param output - * @param nevents */ public void processFile(String file, String output, int nevents){ if(file.endsWith(".hipo")==true){ @@ -265,7 +284,6 @@ public void processFile(String file, String output, int nevents){ writer.close(); } } - /** * display services registered with the processor. */ @@ -296,29 +314,37 @@ public static void main(String[] args){ String inputFile = parser.getOption("-i").stringValue(); String outputFile = parser.getOption("-o").stringValue(); + /*for(int i =1; i < args.length; i++){ + services.add(args[i]); + }*/ + EngineProcessor proc = new EngineProcessor(); int config = parser.getOption("-c").intValue(); int nevents = parser.getOption("-n").intValue(); String yamlFileName = parser.getOption("-y").stringValue(); - - if(!yamlFileName.equals("0")) { + if(yamlFileName!="0") { try { InputStream input = new FileInputStream(yamlFileName); Yaml yaml = new Yaml(); Map yamlConf = (Map) yaml.load(input); JSONObject jsonObject=new JSONObject(yamlConf); + System.out.println(jsonObject.getJSONObject("configuration").getJSONObject("services")); for(Object obj: jsonObject.getJSONArray("services")) { if(obj instanceof JSONObject) { JSONObject service = (JSONObject) obj; String name = service.getString("name"); String engineClass = service.getString("class"); - JSONObject configs = JsonUtils.filterClaraYaml(jsonObject,name); - if(configs.length()>0) { - proc.addEngine(name, engineClass, configs.toString()); + System.out.println(name); + System.out.println(engineClass); + JSONObject configs = jsonObject.getJSONObject("configuration").getJSONObject("services"); + if(configs.has(name)) { + proc.addEngine(name, engineClass, configs.getJSONObject(name).toString()); } else { proc.addEngine(name, engineClass); } } +// System.out.println(yamlConf.get("configuration").get("services")); +// String jsonConf = gson.toJson(yamlConf["configuration"]["services"][service["name"]]); } } catch (FileNotFoundException ex) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); @@ -327,8 +353,7 @@ public static void main(String[] args){ } catch (ClassCastException | YAMLException ex) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); } - } - else if (config>0){ + } else if (config>0){ if(config>2){ proc.initCaloDebug(); } else if(config==2){ @@ -336,8 +361,7 @@ else if (config>0){ } else { proc.initDefault(); } - } - else { + } else { for(String engine : services){ System.out.println("Adding reconstruction engine " + engine); proc.addEngine(engine); diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/EvioHipoEvent4.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/EvioHipoEvent4.java index 423772384f..1b01f3460c 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/EvioHipoEvent4.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/EvioHipoEvent4.java @@ -371,7 +371,9 @@ public void fillHipoEventFTTRK(Event hipoEvent, EvioDataEvent evioEvent){ hipoADC.putByte("order", i,(byte) 0); hipoADC.putInt("ADC", i, evioBank.getInt("ADC", i)); double tdc = 0; - hipoADC.putFloat("time", i, (float) (tdc/25.0)); +// hipoADC.putFloat("time", i, (float) (tdc/25.0)); + double time = (float) evioBank.getFloat("time",i); + hipoADC.putFloat("time", i, (float) evioBank.getFloat("time",i)); } hipoEvent.write(hipoADC); } diff --git a/etc/bankdefs/hipo/FT.json b/etc/bankdefs/hipo/FT.json index e3b8605202..e1d79ebcab 100644 --- a/etc/bankdefs/hipo/FT.json +++ b/etc/bankdefs/hipo/FT.json @@ -68,24 +68,24 @@ {"name":"energy", "id":10, "type":"float", "info":"Cluster total energy" } ] }, - { + { "bank": "FTTRK::hits", "group": 21321, "info": "Reconstructed Hits in FT hodoscope", "items": [ {"name":"sector", "id":2, "type":"int8", "info":"sector number"}, - {"name":"layer", "id":3, "type":"int8", "info":"layer number"}, + {"name":"layer", "id":3, "type":"int8", "info":"layer number"}, {"name":"component", "id":4, "type":"int16", "info":"component number"}, {"name":"x", "id":5, "type":"float", "info":"Hit X position (cm)" }, {"name":"y", "id":6, "type":"float", "info":"Hit Y position (cm)" }, {"name":"z", "id":7, "type":"float", "info":"Hit Z position (cm)" }, {"name":"energy", "id":8, "type":"float", "info":"Hit Energy" }, {"name":"time", "id":9, "type":"float", "info":"Hit Time" }, - {"name":"hitID", "id":10, "type":"int16", "info":"Hit Pointer to ADC bank"}, + {"name":"hitID", "id":10, "type":"int16", "info":"Hit Pointer to ADC bank"}, {"name":"clusterID", "id":11, "type":"int16", "info":"Hit Pointer to Cluster Bank"} ] - }, - { + }, + { "bank": "FTTRK::clusters", "group": 21322, "info": "Reconstructed clusters in FT tracker", @@ -105,17 +105,18 @@ "group": 21323, "info": "Reconstructed crosses in FT tracker", "items": [ - {"name":"id", "id":1, "type":"int16", "info":"Cross ID"}, - {"name":"sector", "id":2, "type":"int8", "info":"Cross sector"}, - {"name":"detector", "id":3, "type":"int8", "info":"Cross detector"}, - {"name":"x", "id":4, "type":"float", "info":"Cross X position (cm)"}, - {"name":"y", "id":5, "type":"float", "info":"Cross Y position (cm)"}, - {"name":"z", "id":6, "type":"float", "info":"Cross Z position (cm)"}, + {"name":"size", "id":1, "type":"int16", "info":"Size of cross bank"}, + {"name":"id", "id":2, "type":"int16", "info":"Cross ID"}, + {"name":"sector", "id":3, "type":"int8", "info":"Cross sector"}, + {"name":"detector", "id":4, "type":"int8", "info":"Cross detector"}, + {"name":"x", "id":5, "type":"float", "info":"Cross X position (cm)"}, + {"name":"y", "id":6, "type":"float", "info":"Cross Y position (cm)"}, + {"name":"z", "id":7, "type":"float", "info":"Cross Z position (cm)"}, {"name":"Cluster1ID", "id":10, "type":"int16", "info":"ID of the bottom layer cluster in the Cross"}, {"name":"Cluster2ID", "id":11, "type":"int16", "info":"ID of the top layer cluster in the Cross"} ] - }, - { + }, + { "bank": "FT::particles", "group": 20924, "info": "Reconstructed Particles in FT", diff --git a/etc/bankdefs/hipo4/ft.json b/etc/bankdefs/hipo4/ft.json index efd62c6f8d..c5e4d73ee9 100644 --- a/etc/bankdefs/hipo4/ft.json +++ b/etc/bankdefs/hipo4/ft.json @@ -1,5 +1,5 @@ -[ - { +[ + { "name": "FTCAL::hits", "group": 21000, "item" : 21, @@ -15,7 +15,7 @@ {"name":"hitID", "type":"S", "info":"Hit Pointer to ADC bank"}, {"name":"clusterID", "type":"S", "info":"Hit Pointer to Cluster Bank"} ] - }, + }, { "name": "FTCAL::clusters", "group": 21000, @@ -90,5 +90,58 @@ {"name":"trkID", "type":"S", "info":"pointer to cross banks"} ] + }, + { + "name": "FTTRK::hits", + "group": 21300, + "item": 21, + "info": "Reconstructed Hits in FT tracker", + "entries": [ + {"name":"sector", "type":"B", "info":"sector number"}, + {"name":"layer", "type":"B", "info":"layer number"}, + {"name":"component", "type":"S", "info":"component number"}, + {"name":"x", "type":"F", "info":"Hit X position (cm)" }, + {"name":"y", "type":"F", "info":"Hit Y position (cm)" }, + {"name":"z", "type":"F", "info":"Hit Z position (cm)" }, + {"name":"energy", "type":"F", "info":"Hit Energy" }, + {"name":"time", "type":"F", "info":"Hit Time" }, + {"name":"hitID", "type":"S", "info":"Hit Pointer to ADC bank"}, + {"name":"clusterID", "type":"S", "info":"Hit Pointer to Cluster Bank"} + ] + }, + { + "name": "FTTRK::clusters", + "group": 21300, + "item": 22, + "info": "Reconstructed clusters in FT tracker", + "entries": [ + {"name":"size", "type":"S", "info":"Cluster size"}, + {"name":"id", "type":"S", "info":"Cluster ID"}, + {"name":"sector", "type":"B", "info":"Cluster sector"}, + {"name":"layer", "type":"B", "info":"Cluster layer"}, + {"name":"energy", "type":"F", "info":"Cluster total energy"}, + {"name":"maxEnergy", "type":"F", "info":"Seed energy"}, + {"name":"seed", "type":"S", "info":"Seed strip"}, + {"name":"centroid", "type":"F", "info":"Centroid strip number"} + ] + }, + { + "name": "FTTRK::crosses", + "group": 21300, + "item": 23, + "info": "Reconstructed crosses in FT tracker", + "entries": [ + {"name":"size", "type":"S", "info":"Size of cross bank"}, + {"name":"id", "type":"S", "info":"Cross ID"}, + {"name":"sector", "type":"B", "info":"Cross sector"}, + {"name":"detector", "type":"B", "info":"Cross detector"}, + {"name":"x", "type":"F", "info":"Cross X position (cm)"}, + {"name":"y", "type":"F", "info":"Cross Y position (cm)"}, + {"name":"z", "type":"F", "info":"Cross Z position (cm)"}, + {"name":"Cluster1ID", "type":"S", "info":"ID of the bottom layer cluster in the Cross"}, + {"name":"Cluster2ID", "type":"S", "info":"ID of the top layer cluster in the Cross"} + ] } + + ] diff --git a/etc/bankdefs/util/bankSplit.py b/etc/bankdefs/util/bankSplit.py index 1dd48ebbfa..67ff536787 100644 --- a/etc/bankdefs/util/bankSplit.py +++ b/etc/bankdefs/util/bankSplit.py @@ -49,20 +49,12 @@ def createdirandlinks(dirname, banklist): print("Single json files saved in " + workdirectory + singledirectory) # create dst, calibration and monitoring directories -dst = ["BAND::laser","RUN::config","RAW::epics","RAW::scaler","REC::Event","REC::Particle","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::ForwardTagger","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RICH::tdc","RICH::ringCher","RICH::hadCher","RTPC::tracks","RUN::scaler","HEL::flip","HEL::online","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True"] - -calibration = ["BAND::adc","BAND::tdc","BAND::hits","BAND::rawhits","BAND::laser","CND::adc","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::flip","HEL::online","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadCher","RICH::hadrons","RICH::photons","RICH::ringCher","RTPC::hits","RTPC::tracks","RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] - -monitoring = ["BAND::adc","BAND::tdc","BAND::rawhits","BAND::laser","BAND::hits","BMT::adc","BMTRec::Clusters","BMTRec::Crosses","BMTRec::Hits","BMTRec::LayerEffs","BST::adc","BSTRec::Clusters","BSTRec::Crosses","BSTRec::Hits","BSTRec::LayerEffs","CND::adc","CND::clusters","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","CVTRec::Trajectory","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::hits","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::adc","HEL::flip","HEL::online","HitBasedTrkg::HBTracks","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","RAW::vtp","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RECHB::Calorimeter","RECHB::Cherenkov","RECHB::Event","RECHB::ForwardTagger","RECHB::Particle","RECHB::Scintillator","RECHB::Track","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadCher","RICH::hadrons","RICH::photons","RICH::ringCher","RTPC::hits","RTPC::tracks","RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] - +dst = ["BAND::laser","RUN::config","RAW::epics","RAW::scaler","REC::Event","REC::Particle","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::ForwardTagger","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RICH::tdc","RICH::ringCher","RICH::hadCher","RUN::scaler","HEL::flip","HEL::online","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True"] +calibration = ["BAND::adc","BAND::tdc","BAND::hits","BAND::rawhits","BAND::laser","CND::adc","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTTRK::adc","FTTRK::clusters","FTTRK::hits","FTTRK::crosses","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::flip","HEL::online","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadCher","RICH::hadrons","RICH::photons","RICH::ringCher","RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] +monitoring = ["BAND::adc","BAND::tdc","BAND::rawhits","BAND::laser","BAND::hits","BMT::adc","BMTRec::Clusters","BMTRec::Crosses","BMTRec::Hits","BMTRec::LayerEffs","BST::adc","BSTRec::Clusters","BSTRec::Crosses","BSTRec::Hits","BSTRec::LayerEffs","CND::adc","CND::clusters","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","CVTRec::Trajectory","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::hits","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTTRK::adc","FTTRK::clusters","FTTRK::hits","FTTRK::crosses","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::adc","HEL::flip","HEL::online","HitBasedTrkg::HBTracks","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","RAW::vtp","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RECHB::Calorimeter","RECHB::Cherenkov","RECHB::Event","RECHB::ForwardTagger","RECHB::Particle","RECHB::Scintillator","RECHB::Track","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadCher","RICH::hadrons","RICH::photons","RICH::ringCher","RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] ebrerun=list(dst) -ebrerun.extend(["FTOF::hits","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory","TimeBasedTrkg::TBCovMat","HitBasedTrkg::HBTracks","FTOF::hbhits","ECAL::clusters","CTOF::hits","CND::clusters","HTCC::rec","LTCC::clusters","ECAL::moments","CVTRec::Tracks","CVTRec::Trajectory","FT::particles","FTCAL::clusters","FTHODO::clusters","RUN:rf"]) - -dsthb=list(dst) -dsthb.extend(["RECHB::Event","RECHB::Particle","RECHB::Calorimeter","RECHB::Cherenkov","RECHB::CovMat","RECHB::ForwardTagger","RECHB::Scintillator","RECHB::ScintExtras","RECHB::Track"]) - +ebrerun.extend(["FTOF::hits","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory","TimeBasedTrkg::TBCovMat","HitBasedTrkg::HBTracks","FTOF::hbhits","ECAL::clusters","CTOF::hits","CND::clusters","HTCC::rec","LTCC::clusters","ECAL::moments","CVTRec::Tracks","CVTRec::Trajectory","FT::particles","FTCAL::clusters","FTHODO::clusters","FTTRK::clusters","RUN:rf"]) createdirandlinks("dst/", dst) -createdirandlinks("dsthb/", dsthb) createdirandlinks("calibration/", calibration) createdirandlinks("monitoring/", monitoring) #createdirandlinks("ebrerun/", ebrerun) diff --git a/etc/services/data.yaml b/etc/services/data.yaml index 6b285fe73c..58af73de84 100644 --- a/etc/services/data.yaml +++ b/etc/services/data.yaml @@ -12,7 +12,7 @@ services: name: FTCAL - class: org.jlab.rec.ft.hodo.FTHODOEngine name: FTHODO - - class: org.jlab.rec.ft.trk.FTTRKEngine + - class: org.jlab.ft.trk.FTTRKEngine name: FTTRK - class: org.jlab.rec.ft.FTEBEngine name: FTEB @@ -79,6 +79,6 @@ configuration: variation: rga_fall2018 EBTB: variation: rga_fall2018 - + mime-types: - binary/data-hipo diff --git a/etc/services/data_endplates.yaml b/etc/services/data_endplates.yaml index ff984b381f..7ad7df2d46 100644 --- a/etc/services/data_endplates.yaml +++ b/etc/services/data_endplates.yaml @@ -12,6 +12,8 @@ services: name: FTCAL - class: org.jlab.rec.ft.hodo.FTHODOEngine name: FTHODO + - class: org.jlab.ft.trk.FTTRKEngine + name: FTTRK - class: org.jlab.rec.ft.FTEBEngine name: FTEB - class: org.jlab.service.dc.DCHBEngine diff --git a/etc/services/dst.yaml b/etc/services/dst.yaml index 90c5543854..1842c82daf 100644 --- a/etc/services/dst.yaml +++ b/etc/services/dst.yaml @@ -12,7 +12,7 @@ services: name: FTCAL - class: org.jlab.rec.ft.hodo.FTHODOEngine name: FTHODO - - class: org.jlab.rec.ft.trk.FTTRKEngine + - class: org.jlab.ft.trk.FTTRKEngine name: FTTRK - class: org.jlab.rec.ft.FTEBEngine name: FTEB diff --git a/etc/services/mc.yaml b/etc/services/mc.yaml index 9227211e10..22a47598a8 100644 --- a/etc/services/mc.yaml +++ b/etc/services/mc.yaml @@ -12,9 +12,9 @@ services: name: FTCAL - class: org.jlab.rec.ft.hodo.FTHODOEngine name: FTHODO - - class: org.jlab.rec.ft.trk.FTTRKEngine + - class: org.jlab.ft.trk.FTTRKEngine name: FTTRK - - class: org.jlab.rec.ft.FTEBEngine + - class: org.jlab.rec.ft.FTEBEngine name: FTEB - class: org.jlab.service.dc.DCHBEngine name: DCHB @@ -53,8 +53,6 @@ configuration: MAGFIELDS: magfieldSolenoidMap: Symm_solenoid_r601_phi1_z1201_13June2018.dat magfieldTorusMap: Symm_torus_r2501_phi16_z251_24Apr2018.dat - RTPC: - rtpcSimulation: "true" mime-types: - binary/data-hipo diff --git a/etc/services/reconstruction.yaml b/etc/services/reconstruction.yaml index 725399b9c2..692abb1912 100644 --- a/etc/services/reconstruction.yaml +++ b/etc/services/reconstruction.yaml @@ -12,7 +12,7 @@ services: name: FTCAL - class: org.jlab.rec.ft.hodo.FTHODOEngine name: FTHODO - - class: org.jlab.rec.ft.trk.FTTRKEngine + - class: org.jlab.ft.trk.FTTRKEngine name: FTTRK - class: org.jlab.rec.ft.FTEBEngine name: FTEB @@ -73,6 +73,9 @@ configuration: # EBTB: # variation: default # timestamp: 08/22/2018 - + RTPC: + rtpcSimulation: "false" + rtpcCosmic: "true" + rtpcBeamlineFit: "false" mime-types: - binary/data-hipo diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java index fc51b84123..4caab1a4fa 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java @@ -11,12 +11,18 @@ */ public class FTConstants { - public static final int HODO_MIN_CLUSTER_SIZE = 2; // minimum size of hodo clusters for match to calorimeter + public static final int HODO_MIN_CLUSTER_SIZE = 2; // minimum size of hodo clusters for match to calorimeter public static final double CAL_HODO_DISTANCE_MATCHING = 3.0; // matching distance in cm - public static final double CAL_HODO_TIME_MATCHING = 8; // matching time in ns + public static final double CAL_HODO_TIME_MATCHING = 8; // matching time in ns - public static final double CAL_TRK_DISTANCE_MATCHING = 1.5; // matching distance in cm - public static final double CAL_TRK_TIME_MATCHING = 30; // matching time in ns TOBECORRECTED + public static final double CAL_TRK_DISTANCE_MATCHING = 1.5; // matching distance in cm + public static final double CAL_TRK_TIME_MATCHING = 30; // matching time in ns TOBECORRECTED + public static final double TRK_MIN_CROSS_NUMBER = 2; // minimum number of crosses to find a line in the tracker + public static final double TRK0_TRK1_DISTANCE_MATCHING = 0.01; // matching distance between FTTRK points in cms + public static final double TOLERANCE_ON_CROSSES_TWO_DETECTORS = 1.; // 1. cm radius tolerance, tune it up + public static final double FTTRKAdcThreshold = 5.; // check minimum threshold for FTTTRK ADCs (18) + public static final double TRK_MIN_CLUS_ENERGY = 0.; // minimum cluster energy to accept a signal cluster (15) + public static final int TRK_MIN_CLUS_SIZE = 0; // minimum cluster size to form crosses (0: no limit on cluster size) } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index 7b6c51974f..a72eac79c6 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -12,9 +12,13 @@ import org.jlab.clas.physics.GenericKinematicFitter; import org.jlab.clas.physics.PhysicsEvent; import org.jlab.clas.reco.ReconstructionEngine; +import org.jlab.geom.prim.Line3D; +import org.jlab.geom.prim.Point3D; import org.jlab.geom.prim.Vector3D; import org.jlab.groot.data.H1F; import org.jlab.groot.data.H2F; +import org.jlab.groot.math.F1D; +import org.jlab.groot.fitter.DataFitter; import org.jlab.groot.graphics.EmbeddedCanvas; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; @@ -24,10 +28,11 @@ import org.jlab.rec.ft.cal.FTCALConstantsLoader; import org.jlab.rec.ft.cal.FTCALEngine; import org.jlab.rec.ft.hodo.FTHODOEngine; +import org.jlab.rec.ft.trk.FTTRKEngine; +import org.jlab.rec.ft.trk.FTTRKConstantsLoader; public class FTEBEngine extends ReconstructionEngine { - FTEventBuilder reco; int Run = -1; double Solenoid; @@ -61,8 +66,9 @@ public boolean processDataEvent(DataEvent event) { reco.init(this.getSolenoid()); FTresponses = reco.addResponses(event, this.getConstantsManager(), run); FTparticles = reco.initFTparticles(FTresponses); + reco.matchToTRK(FTresponses, FTparticles); reco.matchToHODO(FTresponses, FTparticles); - reco.correctDirection(FTparticles, this.getConstantsManager(), run); + reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo reco.writeBanks(event, FTparticles); } return true; @@ -120,17 +126,26 @@ public double getSolenoid() { public void setSolenoid(double Solenoid) { this.Solenoid = Solenoid; } + + public int getDebugMode() { + return this.reco.debugMode; + } public static void main(String arg[]){ + FTCALEngine cal = new FTCALEngine(); cal.init(); FTHODOEngine hodo = new FTHODOEngine(); hodo.init(); + FTTRKEngine trk = new FTTRKEngine(); + trk.init(); FTEBEngine en = new FTEBEngine(); en.init(); + int debugMode = en.getDebugMode(); // String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/elec_nofield_header.evio"; // EvioSource reader = new EvioSource(); - String input = "/Users/devita/Work/clas12/simulations/clas12Tags/4.4.0/out.hipo"; + //String input = "/Users/devita/Work/clas12/simulations/clas12Tags/4.4.0/out.hipo"; + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_-30.60.120.30_fullAcceptance.hipo"; HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -141,12 +156,13 @@ public static void main(String arg[]){ H1F h2 = new H1F("Energy Resolution", 100, -1, 1); h2.setOptStat(Integer.parseInt("1111")); h2.setTitleX("Energy Resolution(GeV)"); - H2F h3 = new H2F("Theta Resolution", 100, 0, 5, 100, -2, 2); - h3.setTitleX("Energy (GeV)"); - h3.setTitleY("Theta Resolution(deg)"); - H2F h4 = new H2F("Phi Resolution", 100, 0, 5, 100, -10, 10); - h4.setTitleX("Energy (GeV)"); - h4.setTitleY("Phi Resolution(deg)"); + H1F h3 = new H1F("Theta Resolution", 100, -1, 1); + h3.setOptStat(Integer.parseInt("1111")); + h3.setTitleX("Theta Resolution(deg)"); + H1F h4 = new H1F("Phi Resolution", 100, -10, 10); + h4.setOptStat(Integer.parseInt("1111")); + h4.setTitleX("Phi Resolution(deg)"); + H1F h5 = new H1F("Time Resolution", 100, -2, 2); h5.setOptStat(Integer.parseInt("1111")); h5.setTitleX("Time Resolution(ns)"); @@ -165,11 +181,175 @@ public static void main(String arg[]){ H2F h10 = new H2F("Cluster Energy", 100, -180., 180., 100, -0.5, 0.5); h10.setTitleX("#phi"); h10.setTitleY("Energy Resolution(GeV)"); + + // residual plots (of TRK wrt tracking on ECAL - black histograms) + H2F h100 = new H2F("Cross on trk layer1", 100, -15., 15., 100, -15., 15.); + h100.setTitleX("x (mm) trk1"); + h100.setTitleY("y (mm) trk1"); + H2F h101 = new H2F("Cross on trk layer2", 100, -15., 15., 100, -15., 15.); + h101.setTitleX("x (mm) trk2"); + h101.setTitleY("y (mm) trk2"); + H1F h102 = new H1F("trk1 x residual", 63, -.5, .5); + h102.setOptStat(0); + h102.setTitleX("trk1 x residual (mm)"); + h102.setFillColor(1); + H1F h103 = new H1F("trk2 x residual", 63, -.5, .5); + h103.setOptStat(0); + h103.setFillColor(51); + h103.setTitleX("trk2 x residual (mm)"); + H1F h104 = new H1F("trk1 y residual", 63, -.5, .5); + h104.setOptStat(Integer.parseInt("0")); + h104.setFillColor(1); + h104.setTitleX("trk1 y residual (mm)"); + H1F h105 = new H1F("trk2 y residual;", 63, -.5, .5); + h105.setOptStat(0); + h105.setTitleX("trk2 y residual (mm)"); + h105.setFillColor(51); + H1F h106 = new H1F("trk1 theta residual (rad)", 100, -0.005, 0.005); + h106.setOptStat(0); + h106.setTitleX("trk1 theta residual (rad)"); + h106.setFillColor(1); + H1F h107 = new H1F("trk2 theta residual (rad)", 100, -0.005, 0.005); + h107.setOptStat(Integer.parseInt("0")); + h107.setTitleX("trk2 theta residual (rad)"); + h107.setFillColor(51); + H1F h108 = new H1F("trk1 phi residual (rad)", 100, -.05, .05); + h108.setOptStat(0); + h108.setTitleX("trk1 phi residual"); + h108.setFillColor(1); + H1F h109 = new H1F("trk2 phi residual (rad)", 100, -.05, .05); + h109.setOptStat(0); + h109.setTitleX("trk2 phi residual (rad)"); + h109.setFillColor(51); + +// H1F h202 = new H1F("trk1-trk2 x residual", 100, -.2, .2); + H1F h202 = new H1F("trk1 x", 25, 9., 9.4); + H1F h1202 = new H1F("trk1 x MC", 25, 9., 9.4); + h202.setOptStat(0); + h202.setTitleX("trk1 x position (mm)"); +// h202.setTitleY("counts/half strip width (28 um)"); // 14 bins + h202.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins + h202.setLineColor(3); + h202.setFillColor(3); + h1202.setLineColor(9); + h1202.setFillColor(49); + // H1F h203 = new H1F("trk1-trk2 y residual", 100, -.2, .2); + H1F h203 = new H1F("trk2 x", 25, 9., 9.4); + H1F h1203 = new H1F("trk2 MC", 25, 9., 9.4); + h203.setOptStat(0); + h203.setTitleX("trk2 x position (mm)"); + h203.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins + h203.setLineColor(3); + h203.setFillColor(3); + h1203.setLineColor(9); + h1203.setFillColor(49); + H1F h204 = new H1F("trk1 y", 25, 1.4, 1.8); + H1F h1204 = new H1F("trk1 y MC", 25, 1.4, 1.8); + h204.setOptStat(0); + h204.setTitleX("trk1 y position (mm)"); + h204.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins + h204.setLineColor(3); + h204.setFillColor(3); + h1204.setLineColor(9); + h1204.setFillColor(49); + // H1F h203 = new H1F("trk1-trk2 y residual", 100, -.2, .2); + H1F h205 = new H1F("trk2 y", 25, 1.4, 1.8); + H1F h1205 = new H1F("trk2 y MC", 25, 1.4, 1.8); + h205.setOptStat(0); + h205.setTitleX("trk2 y position (mm)"); + h205.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins + h205.setLineColor(3); + h205.setFillColor(3); + h1205.setLineColor(9); + h1205.setFillColor(49); + + // resolution plots (of TRK wrt MC truth - red histograms) + H2F h1100 = new H2F("Cross on trk layer1 MC truth", 100, -15., 15., 100, -15., 15.); + h1100.setTitleX("x (mm) trk1"); + h1100.setTitleY("y (mm) trk1"); + H2F h1101 = new H2F("Cross on trk layer2 MC truth", 100, -15., 15., 100, -15., 15.); + h1101.setTitleX("x (mm) trk2"); + h1101.setTitleY("y (mm) trk2"); + int binres = 35; + double reslim = 5.*FTTRKConstantsLoader.Pitch; + H1F h1102 = new H1F("trk1 x resolution", binres, -reslim, reslim); + h1102.setOptStat(0); + h1102.setTitleX("trk1 x resolutionl (mm)"); + h1102.setLineColor(2); + h1102.setFillColor(2); + H1F h1103 = new H1F("trk2 x resolution", binres, -reslim, reslim); + h1103.setOptStat(0); + h1103.setTitleX("trk2 x resolution (mm)"); + h1103.setLineColor(2); + h1103.setFillColor(32); + H1F h1104 = new H1F("trk1 y resolution", binres, -reslim, reslim); + h1104.setOptStat(0); + h1104.setTitleX("trk1 y resolution (mm)"); + h1104.setLineColor(2); + h1104.setFillColor(2); + H1F h1105 = new H1F("trk2 y resolution", binres, -reslim, reslim); + h1105.setOptStat(0); + h1105.setTitleX("trk2 y resolution (mm)"); + h1105.setLineColor(2); + h1105.setFillColor(32); + H1F h1106 = new H1F("trk1 theta resolution", 50, -0.001, 0.001); + h1106.setOptStat(0); + h1106.setTitleX("trk1 theta resolution (rad)"); + h1106.setLineColor(2); + h1106.setFillColor(27); + H1F h1107 = new H1F("trk2 theta resolution", 50, -0.001, 0.001); + h1107.setOptStat(0); + h1107.setTitleX("trk2 theta resolution (rad)"); + h1107.setLineColor(2); + h1107.setFillColor(37); + H1F h1108 = new H1F("trk1 phi resolution", 50, -0.02, 0.02); + h1108.setOptStat(0); + h1108.setTitleX("trk1 phi resolution (rad)"); + h1108.setLineColor(2); + h1108.setFillColor(2); + H1F h1109 = new H1F("trk2 phi resolution", 50, -0.02, 0.02); + h1109.setOptStat(0); + h1109.setTitleX("trk2 phi resolution (rad)"); + h1109.setLineColor(2); + h1109.setFillColor(32); + + H1F h1112 = new H1F("trk1 Delta x", 50, -0.05, 0.05); + h1112.setOptStat(0); + h1112.setTitleX("trk1 Delta x"); + h1112.setLineColor(6); + h1112.setFillColor(6); + H1F h1113 = new H1F("trk2 Delta x", 50, -0.05, 0.05); + h1113.setOptStat(0); + h1113.setTitleX("trk2 Delta x"); + h1113.setLineColor(6); + h1113.setFillColor(36); + H1F h1114 = new H1F("trk1 Delta y", 50, -0.1, 0.1); + h1114.setOptStat(0); + h1114.setTitleX("trk1 Delta y"); + h1114.setLineColor(6); + h1114.setFillColor(6); + H1F h1115 = new H1F("trk2 Delta y", 50, -0.1, 0.1); + h1115.setOptStat(0); + h1115.setTitleX("trk2 Delta y"); + h1115.setLineColor(6); + h1115.setFillColor(36); + + // Montecarlo radiography + H2F h2000 = new H2F("Montecarlo radiography at first FTTRK det", 100, -15., 15., 100, -15, 15.); + h2000.setTitleX("x (mm)"); + h2000.setTitleY("y (mm)"); + H2F h2001 = new H2F("Montecarlo radiography at second FTTRK det", 100, -15., 15., 100, -15, 15.); + h2001.setTitleX("x (mm)"); + h2001.setTitleY("y (mm)"); - while (reader.hasEvent()) { + int nev = -1; + int nevWithCrosses = 0; + while (reader.hasEvent()) { // run over all events +// int nev1 = 0; int nev2 = 5; for(nev=nev1; nev0) { + // track candidate through calorimeter h1.fill(bank.getFloat("energy", i)); h2.fill(bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); Vector3D part = new Vector3D(bank.getFloat("cx", i), bank.getFloat("cy", i), bank.getFloat("cz", i)); @@ -207,12 +395,140 @@ public static void main(String arg[]){ h8.fill(gen.getGeneratedParticle(0).vector().p(), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); h9.fill(Math.toDegrees(gen.getGeneratedParticle(0).theta()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); h10.fill(Math.toDegrees(gen.getGeneratedParticle(0).phi()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + + // check match with trk bank (entry trkID) + int trkID = bank.getShort("trkID", i); + if(trkID >= 0){ + // loop on crosses bank + DataBank banktrk = event.getBank("FTTRK::crosses"); + int ncrosses = banktrk.rows(); + for(int nc = 0; nc < ncrosses; nc++){ + int det = banktrk.getInt("detector", nc); + if(det>=0){ + float xt = banktrk.getFloat("x", nc); + float yt = banktrk.getFloat("y", nc); + float zt = banktrk.getFloat("z", nc); + Vector3D hitOnTrk = new Vector3D(xt, yt, zt); + if(det==0){ + h100.fill(xt, yt); + if(debugMode>0){ + System.out.println("coodinates on calorimeter " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); + System.out.println("director cosines hit on calorimeter " + part.x() + " " + part.y() + " " + part.z()); + System.out.println("director cosines hit of fttrk " + xt + " " + yt + " " + zt); + } + h102.fill(bank.getFloat("cx", i) *zt - xt); + h104.fill(bank.getFloat("cy", i) *zt - yt); + h106.fill((part.theta() - hitOnTrk.theta())); + h108.fill((part.phi() - hitOnTrk.phi())); + }else if(det==1){ + h101.fill(xt, yt); + h103.fill(bank.getFloat("cx", i) *zt - xt); + h105.fill(bank.getFloat("cy", i) *zt - yt); + h107.fill((part.theta() - hitOnTrk.theta())); + h109.fill((part.phi() - hitOnTrk.phi())); + } + } + } + if(ncrosses==2){ + float x0 = banktrk.getFloat("x", 0); + float y0 = banktrk.getFloat("y", 0); + float x1 = banktrk.getFloat("x", 1); + float y1 = banktrk.getFloat("y", 1); + + Point3D c0 = new Point3D(x0, y0, banktrk.getFloat("z",0)); + Point3D c1 = new Point3D(x1, y1, banktrk.getFloat("z",1)); + Line3D lineBwCrosses = new Line3D(c1, c0); + if(debugMode>0){ + System.out.println("x coordinates on 2 layers " + x0 + " " + x1); + System.out.println("director cosines straight line bw crosses, cx " + lineBwCrosses.originDir().x() + " cy " + + lineBwCrosses.originDir().y() + " cz " + lineBwCrosses.originDir().z()); + } + } + } } } } + + if(event.hasBank("FTTRK::crosses")){ + nevWithCrosses++; + DataBank banktrk = event.getBank("FTTRK::crosses"); + int nrows = banktrk.rows(); + // how many particles have been generated? + int ipart = gen.countGenerated(); + + for(int ip=0; ip0){ + System.out.println("MC: x0 = " + x0 + " y0 " + y0 + " z0 " + z0); + System.out.println("MC cosines: cx = " + cx + " cy " + cy + " cz " + cz); + System.out.println("trk: xt = " + xt + " yt " + yt + " zt " + zt); + } + double t = (zt - z0)/cz; + Vector3D hitOnTrk = new Vector3D(xt, yt, zt); + Vector3D hitMCOnTrk = new Vector3D(x0+cx*t, y0+cy*t, zt); + + // Montecarlo hit location on first detector middle plane + if(det==0) h2000.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); + if(det==1) h2001.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); + + if(det==0){ + h1100.fill(hitOnTrk.x(), hitOnTrk.y()); + h1102.fill(hitMCOnTrk.x() - hitOnTrk.x()); + h1104.fill(hitMCOnTrk.y() - hitOnTrk.y()); + + h1106.fill((hitMCOnTrk.theta() - hitOnTrk.theta())); + h1108.fill((hitMCOnTrk.phi() - hitOnTrk.phi())); + + h1112.fill((hitMCOnTrk.x() - hitOnTrk.x())/hitMCOnTrk.x()); + h1114.fill((hitMCOnTrk.y() - hitOnTrk.y())/hitMCOnTrk.y()); + + h202.fill(hitOnTrk.x()); + h1202.fill(hitMCOnTrk.x()); + h204.fill(hitOnTrk.y()); + h1204.fill(hitMCOnTrk.y()); + + }else if(det==1){ + h1101.fill(hitOnTrk.x(), hitOnTrk.y()); + h1103.fill(hitMCOnTrk.x() - hitOnTrk.x()); + h1105.fill(hitMCOnTrk.y() - hitOnTrk.y()); + h1107.fill((hitMCOnTrk.theta() - hitOnTrk.theta())); + h1109.fill((hitMCOnTrk.phi() - hitOnTrk.phi())); + + h1113.fill((hitMCOnTrk.x() - hitOnTrk.x())/hitMCOnTrk.x()); + h1115.fill((hitMCOnTrk.y() - hitOnTrk.y())/hitMCOnTrk.y()); + + h203.fill(hitOnTrk.x()); + h1203.fill(hitMCOnTrk.x()); + h205.fill(hitOnTrk.y()); + h1205.fill(hitMCOnTrk.y()); + } + if(debugMode>0){ + System.out.println("MC hit coordinates " + hitMCOnTrk.x() + " " + hitMCOnTrk.y() + " " + hitMCOnTrk.z()); + System.out.println("MC theta " + hitMCOnTrk.theta() + " hit on trk " + hitOnTrk.theta()); + System.out.println("MC phi " + hitMCOnTrk.phi() + " hit on trk " + hitOnTrk.phi()); + System.out.println("trk hit coordinates " + hitOnTrk.x() + " " + hitOnTrk.y() + " " + hitOnTrk.z()); + } + } + } + } } } + + if(debugMode>0) System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + nevWithCrosses); + JFrame frame = new JFrame("FT Reconstruction"); frame.setSize(1200, 800); EmbeddedCanvas canvas = new EmbeddedCanvas(); @@ -246,5 +562,329 @@ public static void main(String arg[]){ frame.setLocationRelativeTo(null); frame.setVisible(true); + JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); + frametrk.setSize(1600, 800); + EmbeddedCanvas canvastrk = new EmbeddedCanvas(); + canvastrk.divide(5, 2); + canvastrk.cd(0); + canvastrk.draw(h100); + canvastrk.cd(1); + canvastrk.draw(h102); + F1D f02 = new F1D("f02","[amp]*gaus(x,[mean],[sigma])", -0.5, 0.5); + f02.setParameter(0, 10.0); + f02.setParameter(1, 0.0); + f02.setParameter(2, 1.0); + f02.setLineColor(6); + f02.setLineWidth(3); + DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma + f02.setParameter(0, f02.parameter(0).value()); + f02.setParameter(1, f02.parameter(1).value()); + f02.setParameter(2, f02.parameter(2).value()); + DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma + f02.setOptStat(1111); + canvastrk.draw(f02,"same"); + canvastrk.cd(2); + canvastrk.draw(h104); + F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -0.5, 0.5); + f04.setParameter(0, 10.0); + f04.setParameter(1, 0.0); + f04.setParameter(2, 1.0); + f04.setLineColor(6); + f04.setLineWidth(3); + DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma + f04.setParameter(0, f04.parameter(0).value()); + f04.setParameter(1, f04.parameter(1).value()); + f04.setParameter(2, f04.parameter(2).value()); + DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma + f04.setOptStat(1111); + canvastrk.draw(f04,"same"); + canvastrk.cd(3); + canvastrk.draw(h106); + F1D f06 = new F1D("f06","[amp]*gaus(x,[mean],[sigma])", -0.002, 0.002); + f06.setParameter(0, 10.0); + f06.setParameter(1, h106.getMean()); + f06.setParameter(2, h106.getRMS()); + f06.setLineColor(6); + f06.setLineWidth(3); + DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma + f06.setParameter(0, f06.parameter(0).value()); + f06.setParameter(1, f06.parameter(1).value()); + f06.setParameter(2, f06.parameter(2).value()); + DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma + f06.setOptStat(1111); + canvastrk.draw(f06,"same"); + canvastrk.cd(4); + canvastrk.draw(h108); + F1D f08 = new F1D("f08","[amp]*gaus(x,[mean],[sigma])", -0.01, 0.01); + f08.setParameter(0, h108.getMax()); + f08.setParameter(1, h108.getMean()); + f08.setParameter(2, h108.getRMS()); + f08.setLineColor(6); + f08.setLineWidth(3); + DataFitter.fit(f08, h108, "Q"); //No options uses error for sigma + f08.setOptStat(1111); + canvastrk.draw(f08,"same"); + + canvastrk.cd(5); + canvastrk.draw(h101); + canvastrk.cd(6); + canvastrk.draw(h103); + F1D f03 = new F1D("f03","[amp]*gaus(x,[mean],[sigma])", -0.5, 0.5); + f03.setParameter(0, 10.0); + f03.setParameter(1, 0.0); + f03.setParameter(2, 1.0); + f03.setLineColor(6); + f03.setLineWidth(3); + DataFitter.fit(f03, h103, "Q"); //No options uses error for sigma + f03.setParameter(0, f03.parameter(0).value()); + f03.setParameter(1, f03.parameter(1).value()); + f03.setParameter(2, f03.parameter(2).value()); + DataFitter.fit(f03, h103, "Q"); //No options uses error for sigma + f03.setOptStat(1111); + canvastrk.draw(f03,"same"); + + canvastrk.cd(7); + canvastrk.draw(h105); + F1D f05 = new F1D("f05","[amp]*gaus(x,[mean],[sigma])", -0.5, 0.5); + f05.setParameter(0, 10.0); + f05.setParameter(1, 0.0); + f05.setParameter(2, 1.0); + f05.setLineColor(6); + f05.setLineWidth(3); + DataFitter.fit(f05, h105, "Q"); //No options uses error for sigma + f05.setParameter(0, f05.parameter(0).value()); + f05.setParameter(1, f05.parameter(1).value()); + f05.setParameter(2, f05.parameter(2).value()); + DataFitter.fit(f05, h105, "Q"); //No options uses error for sigma + f05.setOptStat(1111); + canvastrk.draw(f05,"same"); + + canvastrk.cd(8); + canvastrk.draw(h107); + F1D f07 = new F1D("f07","[amp]*gaus(x,[mean],[sigma])", -0.002, 0.002); + f07.setParameter(0, h107.getMax()); + f07.setParameter(1, h107.getMean()); + f07.setParameter(2, h107.getRMS()); + f07.setLineColor(6); + f07.setLineWidth(3); + DataFitter.fit(f07, h107, "Q"); //No options uses error for sigma + f07.setOptStat(1111); + canvastrk.draw(f07,"same"); + + canvastrk.cd(9); + canvastrk.draw(h109); + F1D f09 = new F1D("f09","[amp]*gaus(x,[mean],[sigma])", -0.01, 0.01); + f09.setParameter(0, h109.getMax()); + f09.setParameter(1, h109.getMean()); + f09.setParameter(2, h109.getRMS()); + f09.setLineColor(6); + f09.setLineWidth(3); + DataFitter.fit(f09, h109, "Q"); //No options uses error for sigma + f09.setParameter(0, f09.parameter(0).value()); + f09.setParameter(1, f09.parameter(1).value()); + f09.setParameter(2, f09.parameter(2).value()); + DataFitter.fit(f09, h109, "Q"); //No options uses error for sigma + f09.setOptStat(1111); + canvastrk.draw(f09,"same"); + frametrk.add(canvastrk); + frametrk.setLocationRelativeTo(null); + frametrk.setVisible(true); + + JFrame frametrkres = new JFrame("FTTRK Resolutions wrt MC generated events"); + frametrkres.setSize(1800, 800); + EmbeddedCanvas canvastrkres = new EmbeddedCanvas(); + canvastrkres.divide(7, 2); + int ii = 0; + canvastrkres.cd(ii); + canvastrkres.draw(h1100); + canvastrkres.cd(++ii); + canvastrkres.draw(h1102); + F1D f1 = new F1D("f1","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); + f1.setParameter(0, h1102.getMax()); + f1.setParameter(1, h1102.getMean()); + f1.setParameter(2, h1102.getRMS()); + f1.setLineColor(4); + f1.setLineWidth(3); + DataFitter.fit(f1, h1102, "Q"); //No options uses error for sigma + f1.setParameter(0, f1.parameter(0).value()); + f1.setParameter(1, f1.parameter(1).value()); + f1.setParameter(2, f1.parameter(2).value()); + DataFitter.fit(f1, h1102, "Q"); //No options uses error for sigma + f1.setOptStat(1111); + canvastrkres.draw(f1,"same"); + if(debugMode>0) System.out.println(" mean = " + f1.parameter(1).value() + + " sigma = " + f1.parameter(2).value()); + canvastrkres.cd(++ii); + canvastrkres.draw(h1104); + F1D f2 = new F1D("f2","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); + f2.setParameter(0, f1.parameter(0).value()); + f2.setParameter(1, f1.parameter(1).value()); + f2.setParameter(2, f1.parameter(2).value()); + f2.setLineColor(24); + f2.setLineWidth(3); + DataFitter.fit(f2, h1104, "Q"); //No options uses error for sigma + f2.setOptStat(1111); + canvastrkres.draw(f2,"same"); + if(debugMode>0) System.out.println(" mean = " + f2.parameter(1).value() + + " sigma = " + f2.parameter(2).error()); + canvastrkres.cd(++ii); + canvastrkres.draw(h1106); + F1D f6 = new F1D("f6","[amp]*gaus(x,[mean],[sigma])", -0.001, 0.001); + f6.setParameter(0, f1.parameter(0).value()); + f6.setParameter(1, h1106.getMean()); + f6.setParameter(2, h1106.getRMS()); + f6.setLineColor(24); + f6.setLineWidth(3); + DataFitter.fit(f6, h1106, "Q"); //No options uses error for sigma + f6.setOptStat(1111); + canvastrkres.draw(f6,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1108); + F1D f8 = new F1D("f8","[amp]*gaus(x,[mean],[sigma])", -0.005, 0.005); + f8.setParameter(0, h1108.getMax()); + f8.setParameter(1, h1108.getMean()); + f8.setParameter(2, h1108.getRMS()/2); + f8.setLineColor(24); + f8.setLineWidth(3); + DataFitter.fit(f8, h1108, "Q"); //No options uses error for sigma + f8.setOptStat(1111); + canvastrkres.draw(f8,"same"); + canvastrkres.cd(++ii); + canvastrkres.draw(h1112); + F1D f12 = new F1D("f12","[amp]*gaus(x,[mean],[sigma])", -0.05, 0.05); + f12.setParameter(0, f1.parameter(0).value()); + f12.setParameter(1, h1112.getMean()); + f12.setParameter(2, h1112.getRMS()); + f12.setLineColor(24); + f12.setLineWidth(3); + DataFitter.fit(f12, h1112, "Q"); //No options uses error for sigma + f12.setOptStat(1111); + canvastrkres.draw(f12,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1114); + F1D f14 = new F1D("f14","[amp]*gaus(x,[mean],[sigma])", -0.1, 0.1); + f14.setParameter(0, f1.parameter(0).value()); + f14.setParameter(1, h1114.getMean()); + f14.setParameter(2, h1114.getRMS()); + f14.setLineColor(24); + f14.setLineWidth(3); + DataFitter.fit(f14, h1114, "Q"); //No options uses error for sigma + f14.setOptStat(1111); + canvastrkres.draw(f14,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1101); + canvastrkres.cd(++ii); + canvastrkres.draw(h1103); + F1D f3 = new F1D("f3","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); + f3.setParameter(0, f1.parameter(0).value()); + f3.setParameter(1, f1.parameter(1).value()); + f3.setParameter(2, f1.parameter(2).value()); + f3.setLineColor(34); + f3.setLineWidth(3); + DataFitter.fit(f3, h1103, "Q"); //No options uses error for sigma + f3.setOptStat(1111); + canvastrkres.draw(f3,"same"); + if(debugMode>0) System.out.println(" mean = " + f3.parameter(1).value() + + " sigma = " + f3.parameter(2).error()); + canvastrkres.cd(++ii); + canvastrkres.draw(h1105); + F1D f4 = new F1D("f4","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); + f4.setParameter(0, f1.parameter(0).value()); + f4.setParameter(1, f1.parameter(1).value()); + f4.setParameter(2, f1.parameter(2).value()); + f4.setLineColor(44); + f4.setLineWidth(3); + DataFitter.fit(f4, h1105, "Q"); //No options uses error for sigma + f4.setOptStat(1111); + canvastrkres.draw(f4,"same"); + if(debugMode>0) System.out.println(" mean = " + f4.parameter(1).value() + + " sigma = " + f4.parameter(2).error()); + canvastrkres.cd(++ii); + canvastrkres.draw(h1107); + F1D f17 = new F1D("f17","[amp]*gaus(x,[mean],[sigma])", -0.001, 0.001); + f17.setParameter(0, h1107.getMax()); + f17.setParameter(1, h1107.getMean()); + f17.setParameter(2, h1107.getRMS()); + f17.setLineColor(24); + f17.setLineWidth(3); + DataFitter.fit(f17, h1107, "Q"); //No options uses error for sigma + f17.setOptStat(1111); + canvastrkres.draw(f17,"same"); + canvastrkres.cd(++ii); + canvastrkres.draw(h1109); + F1D f19 = new F1D("f19","[amp]*gaus(x,[mean],[sigma])", -0.002, 0.002); + f19.setParameter(0, h1109.getMax()); + f19.setParameter(1, h1109.getMean()); + f19.setParameter(2, h1109.getRMS()); + f19.setLineColor(24); + f19.setLineWidth(3); + DataFitter.fit(f19, h1109, "Q"); //No options uses error for sigma + f19.setOptStat(1111); + canvastrkres.draw(f19,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1113); + F1D f13 = new F1D("f13","[amp]*gaus(x,[mean],[sigma])", -0.05, 0.05); + f13.setParameter(0, f1.parameter(0).value()); + f13.setParameter(1, h1113.getMean()); + f13.setParameter(2, h1113.getRMS()); + f13.setLineColor(24); + f13.setLineWidth(3); + DataFitter.fit(f13, h1113, "Q"); //No options uses error for sigma + f13.setOptStat(1111); + canvastrkres.draw(f13,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1115); + F1D f15 = new F1D("f15","[amp]*gaus(x,[mean],[sigma])", -0.1, 0.1); + f15.setParameter(0, f1.parameter(0).value()); + f15.setParameter(1, h1115.getMean()); + f15.setParameter(2, h1115.getRMS()); + f15.setLineColor(24); + f15.setLineWidth(3); + DataFitter.fit(f15, h1115, "Q"); //No options uses error for sigma + f15.setOptStat(1111); + canvastrkres.draw(f15,"same"); + + frametrkres.add(canvastrkres); + frametrkres.setLocationRelativeTo(null); + frametrkres.setVisible(true); + + JFrame frametrkrel = new JFrame("FTTRK Resolutions layer1 vs layer2"); + frametrkrel.setSize(800, 800); + EmbeddedCanvas canvastrkrel = new EmbeddedCanvas(); + canvastrkrel.divide(2, 2); + canvastrkrel.cd(0); + canvastrkrel.draw(h202); + canvastrkrel.draw(h1202,"same"); + canvastrkrel.cd(1); + canvastrkrel.draw(h203); + canvastrkrel.draw(h1203,"same"); + canvastrkrel.cd(2); + canvastrkrel.draw(h204); + canvastrkrel.draw(h1204,"same"); + canvastrkrel.cd(3); + canvastrkrel.draw(h205); + canvastrkrel.draw(h1205,"same"); + + frametrkrel.add(canvastrkrel); + frametrkrel.setLocationRelativeTo(null); + frametrkrel.setVisible(true); + + JFrame frameMCradio = new JFrame("Montecarlo radiography of vertex"); + frameMCradio.setSize(1000,500); + EmbeddedCanvas canvasMCradio = new EmbeddedCanvas(); + canvasMCradio.divide(2,1); + canvasMCradio.cd(0); + canvasMCradio.draw(h2000); + canvasMCradio.cd(1); + canvasMCradio.draw(h2001); + frameMCradio.add(canvasMCradio); + frameMCradio.setLocationRelativeTo(null); + frameMCradio.setVisible(true); } + } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index cd048b7393..35889662e0 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -11,10 +11,13 @@ import org.jlab.io.evio.EvioDataEvent; import org.jlab.rec.ft.cal.FTCALConstantsLoader; import org.jlab.utils.groups.IndexedTable; +import org.jlab.geom.prim.Line3D; +import org.jlab.geom.prim.Vector3D; +import org.jlab.geom.prim.Point3D; public class FTEventBuilder { - public int debugMode = 0; + public int debugMode = -1; private double solenoidField; @@ -41,6 +44,10 @@ public void setField(double field) { this.solenoidField = field; } + public void setDebugMode(int debug){ + this.debugMode = debug; + } + public void init(double field) { if (debugMode >= 1) { System.out.println("New event"); @@ -69,7 +76,26 @@ public List addResponses(DataEvent event, ConstantsManager manager, resp.setPosition(bank.getDouble("clusX", i), bank.getDouble("clusY", i), FTCALConstantsLoader.CRYS_ZPOS + cluster.getDoubleValue("depth_z", 1, 1, 0)); responses.add(resp); } + } + + if (event.hasBank("FTTRK::crosses") == true) { + DataBank bank = event.getBank("FTTRK::crosses"); + int nrows = bank.rows(); + for (int i = 0; i < nrows; i++) { + FTResponse resp = new FTResponse("FTTRK"); + resp.setAssociation(-1); + resp.setSize(bank.getInt("size", i)); +// resp.setSize(nrows); + resp.setId(bank.getInt("id", i)); + resp.setEnergy(-9999.); + resp.setTime(9999.); + resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); + if(debugMode>=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); + responses.add(resp); + } + } + if (event.hasBank("FTHODORec::clusters") == true) { EvioDataBank bank = (EvioDataBank) event.getBank("FTHODORec::clusters"); int nrows = bank.rows(); @@ -112,23 +138,109 @@ public List addResponses(DataEvent event, ConstantsManager manager, responses.add(resp); } } + if (event.hasBank("FTTRK::crosses") == true) { + DataBank bank = event.getBank("FTTRK::crosses"); + DataBank bankClust = event.getBank("FTTRK::clusters"); + DataBank bankHits = event.getBank("FTTRK::hits"); + int nrows = bank.rows(); + for (int i = 0; i < nrows; i++) { + FTResponse resp = new FTResponse("FTTRK"); + resp.setAssociation(-1); + resp.setSize(bank.getInt("size", i)); + resp.setId(bank.getInt("id", i)); +// resp.setEnergy(-9999.); +// resp.setTime(9999.); + // time and energy correspond to the energies of the clusters associated to the cross + int det = bank.getInt("detector", i); + int idCl1 = bank.getInt("Cluster1ID", i); + int idCl2 = bank.getInt("Cluster2ID", i); + double meanEnergy = -9999; + double meanTime = -9999; + double enCl1 = 0., enCl2 = 0., timeCross1 = 0., timeCross2 = 0.; + int layer = -1; + if(det==0){ + // find clusters on layers 1 and 2 + for(int j=0; j=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); + responses.add(resp); + } + } + } if (debugMode >= 1) { this.showResponses(responses); } return responses; } - + public void correctDirection(List particles, ConstantsManager manager, int run) { IndexedTable thetaCorr = manager.getConstants(run, "/calibration/ft/ftcal/thetacorr"); IndexedTable phiCorr = manager.getConstants(run, "/calibration/ft/ftcal/phicorr"); for (int i = 0; i < particles.size(); i++) { FTParticle particle = particles.get(i); - particle.setDirection(thetaCorr, phiCorr); + if(particle.getCalorimeterIndex()>-1) particle.setDirection(thetaCorr, phiCorr); } } - + public List initFTparticles(List responses) { List particles = new ArrayList(); // this.FTparticles.clear(); @@ -148,6 +260,22 @@ public List initFTparticles(List responses) { particles.add(track); responses.get(i).setAssociation(particles.size()-1); } + + if (responses.get(i).getType() == "FTTRK") { + FTParticle track = new FTParticle(i); + track.setCharge(-999); // provisional, one should take care of the nofield case + track.setField(this.solenoidField); + track.setEnergy(responses.get(i).getEnergy()); + track.setPosition(responses.get(i).getPosition()); + track.setDirection(); + double trkTime = responses.get(i).getTime() - responses.get(i).getPosition().mag()/PhysicsConstants.speedOfLight(); + if(trkTime>=0){track.setTime(trkTime);}else{track.setTime(0.);}; + track.setCalorimeterIndex(-1); + track.setHodoscopeIndex(-1); + track.setTrackerIndex(responses.get(i).getId()); + particles.add(track); + responses.get(i).setAssociation(particles.size()-responses.size()); + } } if (debugMode >= 1) { for (int i = 0; i < particles.size(); i++) { @@ -166,7 +294,7 @@ public void matchToHODO(List responses, List particles) int iHodo = track.getDetectorHit(responses, "FTHODO", FTConstants.CAL_HODO_DISTANCE_MATCHING, FTConstants.CAL_HODO_TIME_MATCHING); if (iHodo > 0) { if (debugMode >= 1) { - System.out.println("found signal " + iHodo); + System.out.println("found signal in the hodoscope " + iHodo); } track.setCharge(-1); track.setHodoscopeIndex(responses.get(iHodo).getId()); @@ -178,6 +306,88 @@ public void matchToHODO(List responses, List particles) } } + public void matchToTRK(List responses, List particles) { + for (int i = 0; i < particles.size(); i++) { + FTParticle track = particles.get(i); + if (debugMode >= 1) { + System.out.println("Searching for matching signal in the tracker:"); + } + int iTrk = track.getDetectorHit(responses, "FTTRK", FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); + if (iTrk > 0) { + if (debugMode >= 1) { + System.out.println("found signal in FTTRK" + iTrk); + } + track.setCharge(-999); // provisional, for no field tracking + track.setTrackerIndex(responses.get(iTrk).getId()); + responses.get(iTrk).setAssociation(i); + } + if (debugMode >= 1) track.show(); + } + } + + public void matchTRKHits(List responses, List particles) { + for (int i = 0; i < particles.size(); i++) { + FTParticle track = particles.get(i); + if (debugMode >= 1) { + System.out.println("Searching for matching signal in the tracker:"); + } + // consider FTParticles only through FTTRK detector + if(track.getCalorimeterIndex()<0){ + int iTrk = track.getDetectorHit(responses, "FTTRK", FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); + if (iTrk > 0) { + if (debugMode >= 1) { + System.out.println("found signal in FTTRK" + iTrk); + } + track.setCharge(-999); // provisional, for no field tracking + track.setTrackerIndex(responses.get(iTrk).getId()); + responses.get(iTrk).setAssociation(i); + } + if (debugMode >= 1) track.show(); + } + } + } + + /* + // alternative method, keep it provisionally + public void matchTRKCrosses(List responses){ + // check whether the responses on opposite FTTRK detectors can belong to the same track + Point3D origin = new Point3D(0.,0.,0.); + if(this.solenoidField == 0){ + for(int i=0; ii; j--){ + FTResponse resp2 = responses.get(j); + if(resp2.getType() == "FTTRK" && resp2.getSector()==1){ + Line3D line2 = new Line3D(origin, resp2.getPosition().toPoint3D()); + // check the distance of the lines at the z coordinate of the second hit + double x2 = resp2.getPosition().toPoint3D().x(); + double y2 = resp2.getPosition().toPoint3D().y(); + double z2 = resp2.getPosition().toPoint3D().z(); + double t = line1.direction().z()/z2; + double x1 = line1.direction().x() * t; + double y1 = line1.direction().y() * t; + Line3D diff = new Line3D(x1, y1, z2, x2, y2, z2); + double distance = diff.length(); + // if distance is small than a given tolerance, validate both the responses + double FTTRK_DISTANCE_TOLERANCE = 0.1; // cm + if(distance < FTTRK_DISTANCE_TOLERANCE){ + responses.get(i).setAssociation(2); + responses.get(j).setAssociation(2); + } + } + } + } + + } + } + } + */ + public void showResponses(List responses) { System.out.println("\nFound " + responses.size() + " clusters in FT detector"); for (int i = 0; i < responses.size(); i++) { @@ -230,7 +440,6 @@ public void writeBanks(DataEvent event, List particles) { banktrack.setShort("hodoID", i, (short) particles.get(i).getHodoscopeIndex()); banktrack.setShort("trkID", i, (short) particles.get(i).getTrackerIndex()); if (debugMode >= 1) { - particles.get(i).show(); particles.get(i).show(); System.out.println(particles.get(i).getDirection().x() + " " + particles.get(i).getDirection().y() + " " + particles.get(i).getDirection().z()); } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index cda4624fa1..c1218a256a 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -18,7 +18,7 @@ public class FTParticle { private Vector3D _Direction = new Vector3D(); // direction private int _Cluster; // track pointer to cluster information in FTCALRec::cluster bank private int _Signal; // track pointer to signal information in FTHODORec::cluster bank - private int _Cross; // track pointer to cross information in FTTRKRec::cluster bank + private int _Cross; // track pointer to cross information in FTTRKRec::cross bank private double _field; // constructor @@ -157,20 +157,37 @@ public int getDetectorHit(List hitList, String detectorType, double double hitdistance = dist.length(); double timedistance = Math.abs(this.getTime()-(response.getTime()-response.getPosition().mag()/PhysicsConstants.speedOfLight())); // System.out.println(" LOOP = " + loop + " distance = " + hitdistance); - if(timedistance0){ + if(hitdistance>distanceThreshold) inTolerance=false; + } + if(this.getTrackerIndex()>0){ + if(hitdistance>FTConstants.TRK0_TRK1_DISTANCE_MATCHING) inTolerance = false; + } + if(inTolerance && hitdistance-1) { - if(hitList.get(bestIndex).getSize()0 && this.getTrackerIndex()<0){dtype = "FTCAL ";}else{dtype = "FTTRK ";} + System.out.println( "FT Particle info " + + " hit in " + dtype + " Charge = "+ this.getCharge() + " E = " + this.getEnergy() + " X = " + this.getPosition().x() + diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java index bab57366cd..04e6f1b59e 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java @@ -12,6 +12,7 @@ import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.geom.prim.Vector3D; import org.jlab.groot.data.H1F; +import org.jlab.groot.data.H2F; import org.jlab.groot.graphics.EmbeddedCanvas; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; @@ -95,7 +96,9 @@ public int setRunConditionsParameters(DataEvent event) { public static void main (String arg[]) { FTCALEngine cal = new FTCALEngine(); cal.init(); - String input = "/Users/devita/Work/clas12/simulations/clas12Tags/4.4.0/out.hipo"; + // String input = "/Users/devita/Work/clas12/simulations/clas12Tags/4.4.0/out.hipo"; +// String input = "/home/filippi/clas/ForwardTracker/DATA/out_realGeo_noMagField.data"; + String input = "/home/filippi/clas/gemc/electronGun/gemc.hipo"; HipoDataSource reader = new HipoDataSource(); // String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/out_header.ev"; // EvioSource reader = new EvioSource(); @@ -112,6 +115,8 @@ public static void main (String arg[]) { h4.setOptStat(Integer.parseInt("1111")); h4.setTitleX("Phi Resolution(deg)"); H1F h5 = new H1F("Time Resolution",100, -10, 10); h5.setOptStat(Integer.parseInt("1111")); h5.setTitleX("Time Resolution(ns)"); + H2F h6 = new H2F("cluster xy", 100, -15., 15., 100, -15., 15.); + h6.setTitleX("cluster x"); h6.setTitleY("cluster y"); while(reader.hasEvent()){ DataEvent event = (DataEvent) reader.getNextEvent(); @@ -147,6 +152,7 @@ public static void main (String arg[]) { // System.out.println(cluster.x() + " " + cluster.y() + " " + cluster.z() + " "); h4.fill(Math.toDegrees(cluster.phi()-gen.getGeneratedParticle(0).phi())); h5.fill(bank.getFloat("time",i)-124.25); + h6.fill(cluster.x(), cluster.y()); } } @@ -160,6 +166,7 @@ public static void main (String arg[]) { canvas.cd(1); canvas.draw(h2); canvas.cd(2); canvas.draw(h3); canvas.cd(3); canvas.draw(h4); + canvas.cd(4); canvas.draw(h6); canvas.cd(5); canvas.draw(h5); frame.add(canvas); frame.setLocationRelativeTo(null); diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java index 194c7e598f..7b1aa864f9 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import org.jlab.geom.prim.Line3D; +import org.jlab.geom.prim.Vector3D; /** * @@ -17,10 +18,9 @@ public class FTTRKCluster extends ArrayList implements Comparable implements ComparablemaxStripsForTM){ + // max energy strip + for(int i=0; i< nbhits; i++){ + FTTRKHit oneHit = this.get(i); + double stripEn = oneHit.get_Edep(); + if(stripEn> maxEn1){ + maxEn1 = stripEn; + maxI = i; + } + } + // 2nd to max energy strip + for(int i=0; i < nbhits; i++){ + FTTRKHit oneHit = this.get(i); + double stripEn = oneHit.get_Edep(); + if(i!=maxI && stripEn> maxEn2){ + maxEn2 = stripEn; + maxI2nd = i; + } + } + } + + // looping over the number of hits in the cluster for(int i=0;i0.5) {continue;} // get strip informations int strpNb = thehit.get_Strip(); double x1 = thehit.get_StripSegment().origin().x(); @@ -191,9 +220,13 @@ public void calc_CentroidParams() { double z2 = thehit.get_StripSegment().end().z(); totEn += strpEn; + totEnSq += strpEn*strpEn; int layer = thehit.get_Layer(); - int Slayer = thehit.get_SuperLayer(layer); - weightedStrp+= strpEn*(double)FTTRKConstantsLoader.stripsYloc[Slayer][strpNb-1][0]; + int Slayer = thehit.get_HalfLayer(layer); + double y = (double)FTTRKConstantsLoader.stripsYloc[Slayer][strpNb-1][0]; +// double y = (double)FTTRKConstantsLoader.stripsY[Slayer][strpNb-1][0]; + + weightedStrp+= strpEn*y; weightedStripEndPoint1X+= strpEn*x1; weightedStripEndPoint1Y+= strpEn*y1; weightedStripEndPoint1Z+= strpEn*z1; @@ -209,9 +242,9 @@ public void calc_CentroidParams() { // getting the seed strip which is defined as the strip with the largest deposited energy if(strpEn>=Emax) { Emax = strpEn; - seed = strpNb; + seed = strpNb; // seed: hit with largest energy release } - + Slay = 2*Slayer; } if(totEn==0) { System.err.println(" Cluster energy is null .... exit"); @@ -222,23 +255,59 @@ public void calc_CentroidParams() { this.set_MaxStrip(max); this.set_SeedStrip(seed); this.set_SeedEnergy(Emax); - // calculates the centroid values and associated positions - stripNumCent = weightedStrp/totEn; //System.out.println(" --> centroid "+stripNumCent); + // calculates the centroid values and associated positions (in local RF) + stripYCent = weightedStrp/totEn; // + //System.out.println(" --> centroid "+stripNumCent); + // extreme points of the strip in global RF xCentEndPoint1 = weightedStripEndPoint1X/totEn; yCentEndPoint1 = weightedStripEndPoint1Y/totEn; zCentEndPoint1 = weightedStripEndPoint1Z/totEn; xCentEndPoint2 = weightedStripEndPoint2X/totEn; yCentEndPoint2 = weightedStripEndPoint2Y/totEn; zCentEndPoint2 = weightedStripEndPoint2Z/totEn; - - } - + + } + + // use the discrete coordinate of the seed strip x-y (for debug purposes only) + /* + int seed = this.get_SeedStrip(); + if(this.get_Layer()==1 || this.get_Layer()==3){ + xCentEndPoint1 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][0]; + xCentEndPoint2 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][1]; + yCentEndPoint1 = (double)FTTRKConstantsLoader.stripsYloc[this.get_Region()-1][seed-1][0]; + yCentEndPoint2 = (double)FTTRKConstantsLoader.stripsYloc[this.get_Region()-1][seed-1][1]; + }else{ + xCentEndPoint1 = -(double)FTTRKConstantsLoader.stripsYloc[this.get_Region()-1][seed-1][0]; + xCentEndPoint2 = -(double)FTTRKConstantsLoader.stripsYloc[this.get_Region()-1][seed-1][1]; + yCentEndPoint1 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][0]; + yCentEndPoint2 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][1]; + } + */ + + // use the weighted coordinate in both x and y directions (for debugging purposes only) + /* + int seed = this.get_SeedStrip(); + if(seed>0){ + if(this.get_Layer()==1 || this.get_Layer()==3){ + xCentEndPoint1 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][0]; + xCentEndPoint2 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][1]; + }else if(this.get_Layer()==2 || this.get_Layer()==4){ + yCentEndPoint1 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][0]; + yCentEndPoint2 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][1]; + } + } + */ + _TotalEnergy = totEn; - _Centroid = stripNumCent; - _CentroidError = Math.sqrt(this.size())*FTTRKConstantsLoader.Pitch/Math.sqrt(12); + double xmeanCent = (xCentEndPoint1+xCentEndPoint2)/2.; + stripNumCent = this.get(0).get_StripNumberFromLocalY(xmeanCent, stripYCent, this.get(0).get_Layer()); + //centroid: centroid strip number in the measurement direction (local y of each layer) + _Centroid = stripNumCent; + _CentroidError = FTTRKConstantsLoader.Pitch/Math.sqrt(12)*Math.sqrt(totEnSq); _StripSegment = new Line3D(); _StripSegment.setOrigin(xCentEndPoint1, yCentEndPoint1, zCentEndPoint1); _StripSegment.setEnd(xCentEndPoint2, yCentEndPoint2, zCentEndPoint2); + } @@ -300,6 +369,12 @@ public int get_AssociatedCrossID() { public void set_AssociatedCrossID(int _AssociatedCrossID) { this._AssociatedCrossID = _AssociatedCrossID; + // set the _AssociatedCrossID index to all hits belonging to the cluster + for(int i=0; i=1) System.out.println(Constants.getLocalRegion(i)+" strip-1 = "+i+" x' "+stripsXloc[i][1]+" y' "+stripsYloc[i][1]+" length "+stripslength[i]+" Beamhole "+Beamhole); } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java index 6593196bf7..4e401f156c 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java @@ -9,6 +9,7 @@ import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Point3D; import org.jlab.geom.prim.Vector3D; +import org.jlab.rec.ft.FTConstants; /** * The crosses are objects used to find tracks and are characterized by a 3-D point and a direction unit vector. @@ -16,17 +17,31 @@ * @author devita * */ -public class FTTRKCross extends ArrayList implements Comparable { - +//public class FTTRKCross extends ArrayList implements Comparable { +public class FTTRKCross implements Comparable { /** * serial id */ - private static final long serialVersionUID = 5317526429163382618L; + private static final long serialVersionUID = 5317526429163382619L; - /** + private int _Sector; // sector[1] + private int _Region; // region [1,2] + private int _Id; // cross Id [0,1] + + // point parameters: + private Point3D _Point; + private Point3D _PointErr; + + private Vector3D _Dir; + private Vector3D _DirErr; + + private FTTRKCluster _clus1; + private FTTRKCluster _clus2; + + /** * * @param sector the sector (1) - * @param region the region (1...4) + * @param region the region (1-2) * @param rid the cross ID (if there are only 2 crosses in the event, the ID corresponds to the region index) */ public FTTRKCross(int sector, int region, int rid) { @@ -35,17 +50,6 @@ public FTTRKCross(int sector, int region, int rid) { this._Id = rid; } - private int _Sector; // sector[1...6] - private int _Region; // region [1,...3] - private int _Id; // cross Id - - // point parameters: - private Point3D _Point; - private Point3D _PointErr; - - private Vector3D _Dir; - private Vector3D _DirErr; - /** * * @return the sector of the cross @@ -58,8 +62,8 @@ public int get_Sector() { * Sets the sector * @param _Sector the sector of the cross */ - public void set_Sector(int _Sector) { - this._Sector = _Sector; + public void set_Sector(int sector) { + this._Sector = sector; } /** @@ -67,15 +71,17 @@ public void set_Sector(int _Sector) { * @return the region of the cross */ public int get_Region() { - return _Region; + // return the number of supermodule (top or bottom) +// if(_Region==0 || _Region==1){return 0;}else{return 1;} + return _Region; } /** * Sets the region * @param _Region the region of the cross */ - public void set_Region(int _Region) { - this._Region = _Region; + public void set_Region(int region) { + this._Region = region; } /** @@ -90,8 +96,8 @@ public int get_Id() { * Sets the cross ID * @param _Id the id of the cross */ - public void set_Id(int _Id) { - this._Id = _Id; + public void set_Id(int id) { + this._Id = id; } @@ -109,8 +115,8 @@ public Point3D get_Point() { * Sets the cross 3-D point * @param _Point a 3-D point characterizing the position of the cross in the tilted coordinate system. */ - public void set_Point(Point3D _Point) { - this._Point = _Point; + public void set_Point(Point3D point) { + this._Point = point; } /** @@ -125,8 +131,8 @@ public Point3D get_PointErr() { * Sets a 3-dimensional error on the 3-D point * @param _PointErr a 3-dimensional error on the 3-D point characterizing the position of the cross in the tilted coordinate system. */ - public void set_PointErr(Point3D _PointErr) { - this._PointErr = _PointErr; + public void set_PointErr(Point3D pointErr) { + this._PointErr = pointErr; } /** @@ -141,8 +147,8 @@ public Vector3D get_Dir() { * Sets the cross unit direction vector * @param _Dir the cross unit direction vector */ - public void set_Dir(Vector3D _Dir) { - this._Dir = _Dir; + public void set_Dir(Vector3D dir) { + this._Dir = dir; } /** @@ -157,8 +163,8 @@ public Vector3D get_DirErr() { * Sets the cross unit direction vector * @param _DirErr the cross unit direction vector */ - public void set_DirErr(Vector3D _DirErr) { - this._DirErr = _DirErr; + public void set_DirErr(Vector3D dirErr) { + this._DirErr = dirErr; } /** @@ -182,21 +188,18 @@ public int compareTo(FTTRKCross arg) { return -1; } } - - private FTTRKCluster _clus1; - private FTTRKCluster _clus2; /** - * Set the first cluster (corresponding to the first superlayer in a region) - * @param seg1 the Cluster (in the first superlayer) which is used to make a cross + * Set the first cluster (corresponding to the first layer in a region) + * @param seg1 the Cluster (in the first layer) which is used to make a cross */ public void set_Cluster1(FTTRKCluster seg1) { this._clus1 = seg1; } /** - * Set the second Cluster (corresponding to the second superlayer in a region) - * @param seg2 the Cluster (in the second superlayer) which is used to make a cross + * Set the second Cluster (corresponding to the second layer in a region) + * @param seg2 the Cluster (in the second layer) which is used to make a cross */ public void set_Cluster2(FTTRKCluster seg2) { this._clus2 = seg2; @@ -204,7 +207,7 @@ public void set_Cluster2(FTTRKCluster seg2) { /** * - * @return he Cluster (in the first superlayer) which is used to make a cross + * @return he Cluster (in the first layer) which is used to make a cross */ public FTTRKCluster get_Cluster1() { return _clus1; @@ -212,7 +215,7 @@ public FTTRKCluster get_Cluster1() { /** * - * @return the Cluster (in the second superlayer) which is used to make a cross + * @return the Cluster (in the second layer) which is used to make a cross */ public FTTRKCluster get_Cluster2() { return _clus2; @@ -238,30 +241,94 @@ public void set_CrossParams() { double y1_outer = outlayerclus.get_StripSegment().end().y(); double z0_inner = inlayerclus.get_StripSegment().origin().z(); double z0_outer = outlayerclus.get_StripSegment().origin().z(); - Line3D l_in = new Line3D(x0_inner, y0_inner, z0_inner, x1_inner, y1_inner, z0_inner); Line3D l_out = new Line3D(x0_outer, y0_outer, z0_outer, x1_outer, y1_outer, z0_outer); - this.set_Point(l_in.distance(l_out).midpoint()); - + Point3D mid = l_in.distance(l_out).midpoint(); + double d = l_in.distance(mid).length(); + int region = inlayerclus.get_Region(); // 1-2 + double distanceBwLayers = FTTRKConstantsLoader.Zlayer[2*region-1] - FTTRKConstantsLoader.Zlayer[2*region-2]; + // check if the point belongs to the crossed segments +// double tolerance = FTTRKConstantsLoader.Pitch/Math.sqrt(2.); + // set as tolerance the maximum uncertainty of the two centroids + double maxTolerance = 0; + double tol1 = inlayerclus.get_CentroidError(); + double tol2 = outlayerclus.get_CentroidError(); + double err1 = Math.abs(tol1*Math.cos(FTTRKConstantsLoader.Alpha[inlayerclus.get_Layer()-1])); + double err2 = Math.abs(tol2*Math.cos(FTTRKConstantsLoader.Alpha[outlayerclus.get_Layer()-1])); + if(err1>=err2){ + maxTolerance = err1; + }else{ + maxTolerance = err2; + } + boolean isPointInSegment1 = false; + // first one, inner + if(x0_inner<=x1_inner){ + if(mid.x()>=x0_inner-tol1 && mid.x()<=x1_inner+tol1){ + if(y0_inner<=y1_inner){ + if(mid.y()>=y0_inner-tol1 && mid.y()<=y1_inner+tol1) isPointInSegment1 = true; + }else{ + if(mid.y()>=y1_inner-tol1 && mid.y()<=y0_inner+tol1) isPointInSegment1 = true; + } + } + }else{ + if(mid.x()<=x0_inner+tol1 && mid.x()>=x1_inner-tol1){ + if(y0_inner<=y1_inner){ + if(mid.y()>=y0_inner-tol1 && mid.y()<=y1_inner+tol1) isPointInSegment1 = true; + }else{ + if(mid.y()>=y1_inner-tol1 && mid.y()<=y0_inner+tol1) isPointInSegment1 = true; + } + } + } + // second one, outer + boolean isPointInSegment2 = false; + if(x0_outer<=x1_outer){ + if(mid.x()>=x0_outer-tol2 && mid.x()<=x1_outer+tol2){ + if(y0_outer<=y1_outer){ + if(mid.y()>=y0_outer-tol2 && mid.y()<=y1_outer+tol2) isPointInSegment2 = true; + }else{ + if(mid.y()>=y1_outer-tol2 && mid.y()<=y0_outer+tol2) isPointInSegment2 = true; + } + } + }else{ + if(mid.x()<=x0_outer+tol2 && mid.x()>=x1_outer-tol2){ + if(y0_outer<=y1_outer){ + if(mid.y()>=y0_outer-tol2 && mid.y()<=y1_outer+tol2) isPointInSegment2 = true; + }else{ + if(mid.y()>=y1_outer-tol2 && mid.y()<=y0_outer+tol2) isPointInSegment2 = true; + } + } + } + boolean isPointInSegments = isPointInSegment1&&isPointInSegment2; + + boolean isCluster1EnergyAboveTHR = (inlayerclus.get_TotalEnergy() > FTConstants.TRK_MIN_CLUS_ENERGY); + boolean isCluster2EnergyAboveTHR = (outlayerclus.get_TotalEnergy() > FTConstants.TRK_MIN_CLUS_ENERGY); + if(d allHits = new ArrayList(); - List selectedHits = new ArrayList(); - List clusters = new ArrayList(); - List crosses = new ArrayList(); + ArrayList clusters = new ArrayList(); + ArrayList crosses = new ArrayList(); // update calibration constants based on run number if changed int run = setRunConditionsParameters(event); if(run>=0) { // get hits fron banks - allHits = reco.initFTTRK(event,this.getConstantsManager(), run); -// // select good hits and order them by energy -// selectedHits = reco.selectHits(allHits); + allHits = reco.initFTTRK(event,this.getConstantsManager(), run); // create clusters clusters = reco.findClusters(allHits); // create crosses @@ -84,24 +83,25 @@ public boolean processDataEvent(DataEvent event) { public ArrayList processDataEventAndGetClusters(DataEvent event) { List allHits = new ArrayList(); - List selectedHits = new ArrayList(); - ArrayList clusters = new ArrayList(); - List crosses = new ArrayList(); + ArrayList clusters = new ArrayList(); // era ArrayList + ArrayList crosses = new ArrayList(); // update calibration constants based on run number if changed int run = setRunConditionsParameters(event); if(run>=0) { - // get hits fron banks + // get hits from banks allHits = reco.initFTTRK(event,this.getConstantsManager(), run); -// // select good hits and order them by energy -// selectedHits = reco.selectHits(allHits); + if(allHits.size()>0){ // create clusters - clusters = reco.findClusters(allHits); - // create crosses - crosses = reco.findCrosses(clusters); - // write output banks - reco.writeBanks(event, allHits, clusters, crosses); + clusters = reco.findClusters(allHits); + // create crosses + crosses = reco.findCrosses(clusters); + // update hit banks with associated clusters/crosses information + reco.updateAllHitsWithAssociatedIDs(allHits, clusters); + // write output banks + reco.writeBanks(event, allHits, clusters, crosses); + } } return clusters; } @@ -124,10 +124,24 @@ public static void main (String arg[]) { FTTRKEngine trk = new FTTRKEngine(); trk.init(); // String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/out.hipo"; -// String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/out_allTracks.hipo"; - String input = "/Users/devita/Work/clas12/simulations/clas12Tags/4.3.1/out.hipo"; +// String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/out_allTracks.hipo"; +// String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/out_largeCoverage.hipo"; +// String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/out_noMagField_oldGeo.hipo"; +// String input = "/home/filippi/clas/ForwardTracker/DATA/out_electrons2.5GeV_3degTheta_10degPhi.hipo"; +//// String input = "/home/filippi/clas/gemc/electronGun/gemc.hipo"; +// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_new.hipo"; +// String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/out_realGeo_noMagField.data"; +// String input = "/home/filippi/clas/ForwardTracker/DATA/out_realGeo_noMagField.data"; +// String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/clas_004013.evio.111.hipo"; // String input = "/home/filippi/clas/ForwardTracker/out_allTracks.hipo"; // String input = "/home/filippi/clas/ForwardTracker/out.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_0.90.0.90.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_0.90.0.90_spread1mdeg.hipo"; + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_-30.60.120.30_circle.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_0.90.0.90_fullAcceptance.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_-30.60.120.30_fullAcceptance.hipo"; + System.out.println("input file " + input); HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -137,9 +151,41 @@ public static void main (String arg[]) { h1.setTitleY("Layer"); H1F h2 = new H1F("Energy",100, 0, 100); h2.setOptStat(Integer.parseInt("1111")); h2.setTitleX("Energy"); h2.setTitleY("Counts"); - H1F h3 = new H1F("Time",100, -2, 2); + H1F h3 = new H1F("Time",100, 0., 1.e-3); h3.setOptStat(Integer.parseInt("1111")); h3.setTitleX("Time"); h3.setTitleY("Counts"); - + H1F h1clEn = new H1F("Cluster energy", 100, 0., 100.); + h1clEn.setOptStat(Integer.parseInt("1111")); h1clEn.setTitleX("centroid energy of clusters"); + H1F hOccupancy1 = new H1F("hOccupancy1", 768, 0., 769.); hOccupancy1.setTitleX("Component layer 1"); + hOccupancy1.setLineColor(1); hOccupancy1.setFillColor(1); + H1F hOccupancy2 = new H1F("hOccupancy2", 768, 0., 769.); hOccupancy2.setTitleX("Component layer 2"); + hOccupancy2.setLineColor(1); hOccupancy2.setFillColor(2); + H1F hOccupancy3 = new H1F("hOccupancy3", 768, 0., 769.); hOccupancy3.setTitleX("Component layer 3"); + hOccupancy3.setLineColor(1); hOccupancy3.setFillColor(3); + H1F hOccupancy4 = new H1F("hOccupancy4", 768, 0., 769.); hOccupancy4.setTitleX("Component layer 4"); + hOccupancy4.setLineColor(1); hOccupancy4.setFillColor(4); + + H1F hStripDiff1 = new H1F("hStripDiff1", 10, -5.5, 4.5); hStripDiff1.setTitleX("Strip difference layer 1"); + hStripDiff1.setOptStat(Integer.parseInt("1111")); hStripDiff1.setLineColor(1); hStripDiff1.setFillColor(1); + H1F hStripDiff2 = new H1F("hStripDiff2", 10, -5.5, 4.5); hStripDiff2.setTitleX("Strip difference layer 2"); + hStripDiff2.setOptStat(Integer.parseInt("1111")); hStripDiff2.setLineColor(1); hStripDiff2.setFillColor(2); + H1F hStripDiff3 = new H1F("hStripDiff3", 10, -5.5, 4.5); hStripDiff3.setTitleX("Strip difference layer 3"); + hStripDiff3.setOptStat(Integer.parseInt("1111")); hStripDiff3.setLineColor(1); hStripDiff3.setFillColor(3); + H1F hStripDiff4 = new H1F("hStripDiff4", 10, -5.5, 4.5); hStripDiff4.setTitleX("Strip difference layer 4"); + hStripDiff4.setOptStat(Integer.parseInt("1111")); hStripDiff4.setLineColor(1); hStripDiff4.setFillColor(4); + H1F hNumberOfStrips = new H1F("hNumberOfStrips", 10, -0.5, 9.5); hNumberOfStrips.setTitleX("number of strips per cluster"); + hNumberOfStrips.setOptStat(Integer.parseInt("1111")); hNumberOfStrips.setLineColor(1); hNumberOfStrips.setFillColor(5); + H1F hNumberOfStripsInCrosses = new H1F("hNumberOfStripsInCrosses", 10, -0.5, 9.5); hNumberOfStripsInCrosses.setTitleX("number of strips per cluster in crosses"); + hNumberOfStripsInCrosses.setOptStat(Integer.parseInt("1111")); hNumberOfStripsInCrosses.setLineColor(1); hNumberOfStripsInCrosses.setFillColor(6); + + H1F hStripLay1 = new H1F("hStripLay1", 10, -0.5, 9.5); hStripLay1.setTitleX("Number of strips in clusters, layer 1"); + hStripLay1.setOptStat(Integer.parseInt("1111")); hStripLay1.setLineColor(1); hStripLay1.setFillColor(1); + H1F hStripLay2 = new H1F("hStripLay2", 10, -0.5, 9.5); hStripLay2.setTitleX("Number of strips in clusters, layer 2"); + hStripLay2.setOptStat(Integer.parseInt("1111")); hStripLay2.setLineColor(1); hStripLay2.setFillColor(2); + H1F hStripLay3 = new H1F("hStripLay3", 10, -0.5, 9.5); hStripLay3.setTitleX("Number of strips in clusters, layer 3"); + hStripLay3.setOptStat(Integer.parseInt("1111")); hStripLay3.setLineColor(1); hStripLay3.setFillColor(3); + H1F hStripLay4 = new H1F("hStripLay4", 10, -0.5, 9.5); hStripLay4.setTitleX("Number of strips in clusters, layer 4"); + hStripLay4.setOptStat(Integer.parseInt("1111")); hStripLay4.setLineColor(1); hStripLay4.setFillColor(4); + float lim = 15; H2F hHitL1 = new H2F("hHitL1","cross y vs x detector 1", 100, -lim, lim, 100, -lim, lim); H2F hHitL2 = new H2F("hHitL2","cross y vs x detector 2", 100, -lim, lim, 100, -lim, lim); @@ -159,23 +205,23 @@ public static void main (String arg[]) { EmbeddedCanvas canvasClSingleLay = new EmbeddedCanvas(); canvasClSingleLay.divide(2,2); -// hHitL3.setTitleX("x hit layer3"); hHitL1.setTitleY("y hit layer 3"); -// hHitL4.setTitleX("x hit layer4"); hHitL1.setTitleY("y hit layer 4"); - - int nc1 = 0, nc2 = 0, ncmatch = 0; + int nc1 = 0, nc2 = 0, ncmatch = 0; + int nev=-1; while(reader.hasEvent()){ -// int nev1 = 0; int nev2 = nev1+1; for(int nev=nev1; nev=1) System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~ processing event ~~~~~~~~~~~ " + ++nev); +// if(nev!=6146) continue; // select one event only for debugging purposes ArrayList clusters = new ArrayList(); + clusters = trk.processDataEventAndGetClusters(event); int nStripsInClusters = 0; DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); PhysicsEvent gen = detectorEvent.getGeneratedEvent(); + double maxcomp1=-100, maxcomp2=-100, maxcomp3=-100, maxcomp4=-100; + int imax1 = -1, imax2 = -1, imax3 = -1, imax4 = -1; if(event.hasBank("FTTRK::hits")) { DataBank bank = event.getBank("FTTRK::hits"); int nrows = bank.rows(); @@ -189,13 +235,43 @@ public static void main (String arg[]) { h1.fill(comp,layer); h2.fill(energy); h3.fill(time); + if(layer==1){ + if(debug>=1) System.out.println("component layer 1 " + comp + " event number " + nev + " n rows " + nrows); + hOccupancy1.fill(comp); + if(energy>maxcomp1){ + maxcomp1 = energy; + imax1 = i; + } + }else if(layer==2){ + hOccupancy2.fill(comp); + if(energy>maxcomp2){ + maxcomp2 = energy; + imax2 = i; + } + }else if(layer==3){ + hOccupancy3.fill(comp); + if(energy>maxcomp3){ + maxcomp3 = energy; + imax3 = i; + } + }else if(layer==4){ + hOccupancy4.fill(comp); + if(energy>maxcomp4){ + maxcomp4 = energy; + imax4 = i; + } + } } + // strip number correposponding to the max energy release + maxcomp1 = bank.getShort("component", imax1); + maxcomp2 = bank.getShort("component", imax2); + maxcomp3 = bank.getShort("component", imax3); + maxcomp4 = bank.getShort("component", imax4); } // iterate along the cluster list for every event if(debug>=1) System.out.println("clusters size --- " + clusters.size()); - // DataLine segment[] = new DataLine[clusters.size()]; if(clusters.size()!=0){ // get one cluster and iterate over all the strips contained in it canvasCl.cd(1); canvasCl.draw(hHitL1); @@ -206,20 +282,40 @@ public static void main (String arg[]) { for(int i = 0; i < clusters.size(); i++){ // get a single cluster and count its strip, extract the information on extremal points of the segment FTTRKCluster singleCluster = clusters.get(i); + if(singleCluster.get_AssociatedCrossID() >-1) hNumberOfStripsInCrosses.fill(singleCluster.size()); + if(singleCluster.get_Layer()==1){ + hStripDiff1.fill(maxcomp1 - singleCluster.get_Centroid()); + hStripLay1.fill(singleCluster.size()); + }else if(singleCluster.get_Layer()==2){ + hStripDiff2.fill(maxcomp2 - singleCluster.get_Centroid()); + hStripLay2.fill(singleCluster.size()); + }else if(singleCluster.get_Layer()==3){ + hStripDiff3.fill(maxcomp3 - singleCluster.get_Centroid()); + hStripLay3.fill(singleCluster.size()); + }else if(singleCluster.get_Layer()==4){ + hStripDiff4.fill(maxcomp4 - singleCluster.get_Centroid()); + hStripLay4.fill(singleCluster.size()); + } int nst = singleCluster.size(); if(debug>=1) System.out.println("nst - " + nst); for(int j=0; j=1) System.out.println("total number of clusters " + clusters.size() + " - number of cluster " + i + " cluster size " + - singleCluster.size() + " strip# " + j + " clusterId " + singleCluster.get_Id() + - " layer " + singleCluster.get_Layer() + " seed strip number " + singleCluster.get_SeedStrip() + - " segment -------------- " + seg.origin().x() + " " + seg.origin().y() + " " + seg.end().x() + " " + seg.end().y()); + singleCluster.size() + " strip# " + j + " clusterId " + singleCluster.get_CId() + + " layer " + singleCluster.get_Layer() + " strip number " + singleCluster.get(j).get_Strip() + + " segment " + seg.origin().x() + " " + seg.origin().y() + " " + seg.end().x() + " " + seg.end().y() + + " total mean energy of the cluster " + singleCluster.get_TotalEnergy()); segment[nStripsInClusters] = new DataLine(seg.origin().x(), seg.origin().y(), seg.end().x(), seg.end().y()); int lay = singleCluster.get_Layer(); + // lay = singleCluster.get(j).get_Layer(); segment[nStripsInClusters].setLineColor(lay); // canvasCl.cd(1); canvasCl.draw(hHitL1); if(debug>=1) System.out.println("nStripsInCluster " + nStripsInClusters); canvasCl.draw(segment[nStripsInClusters]); + h1clEn.fill(singleCluster.get_TotalEnergy()); + hNumberOfStrips.fill(singleCluster.size()); + if(debug>=1) System.out.println("%%%%% drawn segment " + singleCluster.get(j).get_Strip() + " cluster " + singleCluster.get_CId() + " layer " + singleCluster.get_Layer()); canvasClSingleLay.cd(lay-1); canvasClSingleLay.draw(segment[nStripsInClusters]); nStripsInClusters++; @@ -234,42 +330,69 @@ public static void main (String arg[]) { int nrows = crossBank.rows(); float x[]; float y[]; + float z[]; byte det[]; x = new float[nrows]; y = new float[nrows]; + z = new float[nrows]; det = new byte[nrows]; for(int i=0; i=2) System.out.println("number of crosses " + nrows + " detector " + det[i] + " x " + x[i] + " y " + y[i]); + z[i] = crossBank.getFloat("z", i); + if(debug>=1) System.out.println("number of crosses " + nrows + " detector " + det[i] + " x " + x[i] + " y " + y[i]); - if(det[i]==1) {hHitL1.fill(x[i], y[i]); nc1++;} - if(det[i]==2) {hHitL2.fill(x[i], y[i]); nc2++;} + if(det[i]==0) {hHitL1.fill(x[i], y[i]); nc1++;} + if(det[i]==1) {hHitL2.fill(x[i], y[i]); nc2++;} } - /// loop on all crosses on detector 1 and 2 and find the oone with better matching + /// loop on all crosses on detector 1 and 2 and find the one with better matching double minDistance = 1000; + double minDiffPhi = 1000.; int iBest = -1, jBest = -1; if(debug>=1) System.out.println("number of rows " + nrows); if(nrows>1){ + double diffPhi = 1000; for(int i=0; ii; j--){ if(det[i]!=det[j]){ double distance = Math.sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])); - if(distance < minDistance){ - minDistance = distance; +// if(distance < minDistance){ +// minDistance = distance; +// iBest = i; jBest = j; +// check det1 and det2 correspondence by comparing phi angles +// the radius is larger for the second detector (as it is more distant) + double phiCross1 = Math.atan2(y[i],x[i]); + double phiCross2 = Math.atan2(y[j],x[j]); + diffPhi = Math.abs(phiCross1-phiCross2); + if(Math.abs(phiCross1-phiCross2)=1) System.out.println("minimum distance " + minDistance); - double distTolerance = 0.1; - distTolerance = 1000; - if(minDistance < distTolerance) { - hHitMatch.fill((x[iBest]+x[jBest])/2., (y[iBest]+y[jBest])/2.); - ncmatch++; - } + // adjust tolerances if needed + double diffRadTolerance = 0.5; + double diffPhiTolerance = 1.; + double thetaTolerance = 0.05; +// if(minDistance < distTolerance) { + if(iBest>-1 && jBest>-1){ + double r1 = Math.sqrt(x[iBest]*x[iBest]+y[iBest]*y[iBest]); + double r2 = Math.sqrt(x[jBest]*x[jBest]+y[jBest]*y[jBest]); + double diffRadii = r1-r2; + double diffTheta = Math.atan2(r1,z[iBest])- Math.atan2(r2,z[jBest]); + // if(minDiffPhi < diffPhiTolerance && diffRadii<0 && Math.abs(diffRadii)=1) System.out.println("phi differences on two detectors " + diffPhi + " number of cross " + ncmatch + + " diffTheta " + diffTheta + " diffRadii " + diffRadii + " " + det[iBest] + " " + det[jBest]); + hHitMatch.fill((x[iBest]+x[jBest])/2., (y[iBest]+y[jBest])/2.); + ncmatch++; + } + } } } } @@ -280,14 +403,41 @@ public static void main (String arg[]) { JFrame frame = new JFrame("FT Reconstruction"); frame.setSize(800,800); EmbeddedCanvas canvas = new EmbeddedCanvas(); - canvas.divide(1,3); + canvas.divide(2,2); canvas.cd(0); canvas.draw(h1); canvas.cd(1); canvas.draw(h2); canvas.cd(2); canvas.draw(h3); + canvas.cd(3); canvas.draw(h1clEn); frame.add(canvas); frame.setLocationRelativeTo(null); frame.setVisible(true); + JFrame frameDiff = new JFrame("Strip Difference"); + frameDiff.setSize(800,800); + EmbeddedCanvas canvasDiff = new EmbeddedCanvas(); + canvasDiff.divide(2,3); + canvasDiff.cd(0); canvasDiff.draw(hStripDiff1); + canvasDiff.cd(1); canvasDiff.draw(hStripDiff2); + canvasDiff.cd(2); canvasDiff.draw(hStripDiff3); + canvasDiff.cd(3); canvasDiff.draw(hStripDiff4); + canvasDiff.cd(4); canvasDiff.draw(hNumberOfStrips); + canvasDiff.cd(5); canvasDiff.draw(hNumberOfStripsInCrosses); + frameDiff.add(canvasDiff); + frameDiff.setLocationRelativeTo(null); + frameDiff.setVisible(true); + + JFrame frameStrip = new JFrame("Strips in clusters"); + frameStrip.setSize(800,800); + EmbeddedCanvas canvasStrip = new EmbeddedCanvas(); + canvasStrip.divide(2,2); + canvasStrip.cd(0); canvasStrip.draw(hStripLay1); + canvasStrip.cd(1); canvasStrip.draw(hStripLay2); + canvasStrip.cd(2); canvasStrip.draw(hStripLay3); + canvasStrip.cd(3); canvasStrip.draw(hStripLay4); + frameStrip.add(canvasStrip); + frameStrip.setLocationRelativeTo(null); + frameStrip.setVisible(true); + JFrame frame2 = new JFrame("FT crosses coordinates per module"); frame2.setSize(800,800); EmbeddedCanvas canvas2 = new EmbeddedCanvas(); @@ -307,6 +457,18 @@ public static void main (String arg[]) { frameClustersSingleLay.setLocationRelativeTo(null); frameClustersSingleLay.setVisible(true); + JFrame frame3 = new JFrame("FT Occupancy single layers"); + frame3.setSize(1200,800); + EmbeddedCanvas canvas3 = new EmbeddedCanvas(); + canvas3.divide(2,2); + int ic=-1; + canvas3.cd(++ic); canvas3.draw(hOccupancy1); + canvas3.cd(++ic); canvas3.draw(hOccupancy2); + canvas3.cd(++ic); canvas3.draw(hOccupancy3); + canvas3.cd(++ic); canvas3.draw(hOccupancy4); + frame3.add(canvas3); + frame3.setLocationRelativeTo(null); + frame3.setVisible(true); } } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java index 637547d653..b67f38ba10 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java @@ -7,6 +7,7 @@ import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Point3D; +import org.jlab.rec.ft.trk.FTTRKConstantsLoader; /** * @@ -16,7 +17,18 @@ public class FTTRKHit implements Comparable{ // class implements Comparable interface to allow for sorting a collection of hits by wire number values - + private int _Sector; // sector[1] + private int _Layer; // layer [1,..4] + private int _Strip; // strip [1...768] + + private double _Edep; // Reconstructed time, for now it is the gemc time + private Line3D _StripSegment; // The geometry segment representing the strip position + private int _Id; // Hit Id + private double _Time; // Reconstructed time, for now it is the gemc time + private int _DGTZIndex; // Pointer to raw hit + private int _ClusterIndex; // Pointer to cluster + private int _CrossIndex; // Pointer to cross + // constructors /** @@ -25,12 +37,17 @@ public class FTTRKHit implements Comparable{ * @param strip * @param Edep (for gemc output without digitization) */ - public FTTRKHit(int sector, int layer, int strip, double Edep) { - int debug = FTTRKReconstruction.debugMode; + public FTTRKHit(int sector, int layer, int strip, double Edep, int id) { + int debug = FTTRKReconstruction.debugMode; // gets the debug flag from FTTRKReconstruction this._Sector = sector; this._Layer = layer; this._Strip = strip; this._Edep = Edep; + this._Id = id; + // update associations after crosses are found + this._DGTZIndex = -1; + this._ClusterIndex = -1; + this._CrossIndex = -1; double x0 = FTTRKConstantsLoader.stripsX[layer-1][strip-1][0]; double x1 = FTTRKConstantsLoader.stripsX[layer-1][strip-1][1]; @@ -47,7 +64,7 @@ public FTTRKHit(int sector, int layer, int strip, double Edep) { System.out.println("++++++++++++ strip end, layer " + layer + " strip " + strip + " x1 " + x1 + " y1 " + y1); } /// for debugging purposes - int Slayer = this.get_SuperLayer(layer); + int Slayer = this.get_HalfLayer(layer); // half layer: top(1) or bottom(0) double x0loc = FTTRKConstantsLoader.stripsXloc[Slayer][strip-1][0]; double x1loc = FTTRKConstantsLoader.stripsXloc[Slayer][strip-1][1]; double y0loc = FTTRKConstantsLoader.stripsYloc[Slayer][strip-1][0]; @@ -58,21 +75,7 @@ public FTTRKHit(int sector, int layer, int strip, double Edep) { System.out.println(""); } } - - - private int _Sector; // sector[1] - private int _Layer; // layer [1,..4] - private int _Strip; // strip [1...768] - - private double _Edep; // Reconstructed time, for now it is the gemc time - private Line3D _StripSegment; // The geometry segment representing the strip position - private int _Id; // Hit Id - private double _Time; // Reconstructed time, for now it is the gemc time - private int _DGTZIndex; // Pointer to raw hit - private int _ClusterIndex; // Pointer to cluster - private int _CrossIndex; // Pointer to cross - - + /** * * @return the sector (1) @@ -106,11 +109,11 @@ public void set_Layer(int _Layer) { this._Layer = _Layer; } - /** + /** * - * @return the superlayer: 0 (for bottom modules, 1,3), 1 (for top modules, 2, 4) + * @return the superlayer: 0 for bottom modules 1+3, 1 for top modules 2+4 */ - public int get_SuperLayer(int _Layer){ + public int get_HalfLayer(int _Layer){ return (_Layer+1)%2; } @@ -174,7 +177,7 @@ public void set_Id(int _Id) { /** * - * @return region (1-2) + * @return region (1-2) */ public int get_Region() { @@ -194,7 +197,8 @@ public int get_DGTZIndex() { } public void set_DGTZIndex(int _DGTZIndex) { - this._DGTZIndex = _DGTZIndex; +// this._DGTZIndex = _DGTZIndex; + this._DGTZIndex = _Id; } public int get_ClusterIndex() { @@ -213,7 +217,75 @@ public void set_CrossIndex(int _CrossIndex) { this._CrossIndex = _CrossIndex; } - /** + public int get_StripNumberFromLocalY(double xGlobal, double yLocal, int layer){ + + // input: xGlobal, yLocal --> must retrieve xLocal to determine strip number + double alpha = FTTRKConstantsLoader.Alpha[layer-1]; + + double y = yLocal; + double yg = (y+xGlobal*Math.sin(alpha))/Math.cos(alpha); + double x = xGlobal*Math.cos(alpha)+yg*Math.sin(alpha); + + double r=Math.sqrt(x*x+y*y); + if(r<=FTTRKConstantsLoader.Rmax && r>=FTTRKConstantsLoader.InnerHole && Math.abs(y)<=FTTRKConstantsLoader.Pitch*FTTRKConstantsLoader.Nstrips*2/6) { + int strip = (int) Math.floor(y/FTTRKConstantsLoader.Pitch) + 1 + FTTRKConstantsLoader.Nstrips*2/6; + if(strip>FTTRKConstantsLoader.Nstrips*3/6) { // strip in the top sector + strip += FTTRKConstantsLoader.Nstrips*2/6; + }else if(strip>FTTRKConstantsLoader.Nstrips/6 && x>0){ + strip += FTTRKConstantsLoader.Nstrips*2/6; + } + return strip; + }else{ + return -1; + } + } + + public int get_StripNumberFromGlobal(double xGlobal, double yGlobal, int layer){ + + double alpha = FTTRKConstantsLoader.Alpha[layer-1]; + double x = xGlobal*Math.cos(alpha)+yGlobal*Math.sin(alpha); + double y = yGlobal*Math.cos(alpha)-xGlobal*Math.sin(alpha); + + double r=Math.sqrt(x*x+y*y); + if(r<=FTTRKConstantsLoader.Rmax && r>=FTTRKConstantsLoader.InnerHole && Math.abs(y)<=FTTRKConstantsLoader.Pitch*FTTRKConstantsLoader.Nstrips*2/6) { + int strip = (int) Math.floor(y/FTTRKConstantsLoader.Pitch) + 1 + FTTRKConstantsLoader.Nstrips*2/6; + if(strip>FTTRKConstantsLoader.Nstrips*3/6) { // strip in the top sector + strip += FTTRKConstantsLoader.Nstrips*2/6; + }else if(strip>FTTRKConstantsLoader.Nstrips/6 && x>0){ + strip += FTTRKConstantsLoader.Nstrips*2/6; + } + return strip; + }else{ + return -1; + } + } + + + public int compareLayerTo(FTTRKHit arg0) { + if(this._Layer > arg0._Layer) { + return 1; + } else { + return 0; + } + } + + /** + * + * @param otherHit + * @return a boolean comparing 2 hits based on basic descriptors; + * returns true if the hits are the same + */ + public boolean isSameAs(FTTRKHit otherHit){ + boolean cmp = false; + if(this._Edep == otherHit._Edep && + this._Sector == otherHit._Sector && + this._Layer == otherHit._Layer && + this._Strip == otherHit._Strip ) + cmp = true; + return cmp; + } + + /** * * @param arg0 the other hit * @return an int used to sort a collection of hits by wire number. Sorting by wire is used in clustering. @@ -226,7 +298,7 @@ public int compareTo(FTTRKHit arg0) { return 0; } } - + /** * * @return print statement with hit information @@ -235,22 +307,5 @@ public String printInfo() { String s = " Hit: ID "+this.get_Id()+" Sector "+this.get_Sector()+" Layer "+this.get_Layer()+" Strip "+this.get_Strip()+" Edep "+this.get_Edep(); return s; } - -// /** -// * -// * @param otherHit -// * @return a boolean comparing 2 hits based on basic descriptors; -// * returns true if the hits are the same -// */ -// public boolean isSameAs(FittedHit otherHit) { -// FittedHit thisHit = (FittedHit) this; -// boolean cmp = false; -// if(thisHit.get_Edep() == otherHit.get_Edep() -// && thisHit.get_Sector() == otherHit.get_Sector() -// && thisHit.get_Layer() == otherHit.get_Layer() -// && thisHit.get_Strip() == otherHit.get_Strip() ) -// cmp = true; -// return cmp; -// } } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index 5c6a9191f0..b9bf1917dc 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -7,9 +7,14 @@ import java.util.ArrayList; import java.util.List; +import java.util.Collections; import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; +import org.jlab.io.evio.EvioDataBank; +import org.jlab.io.evio.EvioDataEvent; +import org.jlab.io.hipo.HipoDataEvent; +import org.jlab.rec.ft.FTConstants; import org.jlab.utils.groups.IndexedTable; /** @@ -19,7 +24,7 @@ */ public class FTTRKReconstruction { - public static int debugMode = 0; + public static int debugMode = 0; // 1 for verbose, set it here (better be set in the steering Engine) public FTTRKReconstruction() { } @@ -56,8 +61,6 @@ public ArrayList findClusters(List hits) boolean[][] checked; FTTRKHit[][] HitArray; ArrayList clusters = new ArrayList(); - FTTRKHit[] clusterHitAtBorder = new FTTRKHit[3]; - int[] limitingStrip = {127, 383, 639}; // strip numbering from 0 to 767 // a boolean array to avoid double counting at the numbering discontinuities checked = new boolean[Nstrips][Nlayers] ; @@ -83,89 +86,208 @@ public ArrayList findClusters(List hits) } } - int cid = 0; // cluster id, will increment with each new good cluster + int cid = -1; // cluster id, will increment with each new good cluster // for each layer and sector, loop over the strips: // once one is selected for the first time, loop over the remainder // clusters are delimited by strips with no hits + int[] indR = new int[512]; + int[] indL = new int[512]; + // strip index: from 0 to 512 (full right hand side, left hand side fired only in the interval 384-639) + // strip number: from 1 to 768 + for(int i=0; i<512; i++){ + if(i<128){ + indR[i] = indL[i] = i; + }else if(i >= 128 && i < 384){ + indR[i] = i; + indL[i] = i+256; + }else if(i >= 384){ + indR[i] = indL[i] = i+256; + } + } + + // loop on layers +// for(int il=0; il<2; il++){ for(int il=0; il clusterHits = new ArrayList(); - int nst=0; - if(HitArray[is][il] != null && !checked[is][il]){ - // select one fired strip - checked[is][il]=true; - // if it's fired it is the seed of the cluster (which may be formed by one stip only - clusterHits.add(new FTTRKHit(HitArray[is][il].get_Sector(),HitArray[is][il].get_Layer(), - HitArray[is][il].get_Strip(),HitArray[is][il].get_Edep())); - if(debugMode>=1) System.out.println("hitArray " + HitArray[is][il].printInfo()); - // now check if there are tother strips to be added to the cluster - int isnext = is; - // is it a limiting strip? - if(is==limitingStrip[0]){ // strip 127: next one can be 384 or 128 - if(HitArray[limitingStrip[0]+1][il] != null){ - isnext++; - }else if(HitArray[limitingStrip[1]+1][il] != null){ - isnext = limitingStrip[1]+1; - } - while(isnext clusterHits = new ArrayList(); + checked[ris][il] = true; + // if fired this is the first strip of the cluster + clusterHits.add(new FTTRKHit(HitArray[ris][il].get_Sector(), HitArray[ris][il].get_Layer(), HitArray[ris][il].get_Strip(), + HitArray[ris][il].get_Edep(), HitArray[ris][il].get_Id())); +// System.out.println(" clusterHits iteration " + is + " strip " + ris + " " + HitArray[ris][il].get_Strip()); + // look for a consecutive strip in the stack and stick it to the cluster + int isnext = is+1; + while(isnext < 512 && HitArray[indR[isnext]][il] != null && !checked[indR[isnext]][il]){ + int nris = indR[isnext]; + checked[nris][il] = true; + clusterHits.add(new FTTRKHit(HitArray[nris][il].get_Sector(), HitArray[nris][il].get_Layer(), HitArray[nris][il].get_Strip(), + HitArray[nris][il].get_Edep(), HitArray[nris][il].get_Id())); +// System.out.println(" clusterHits iteration " + isnext + " strip " + nris + " " + HitArray[nris][il].get_Strip()); + nst++; + isnext++; } - FTTRKCluster this_cluster = new FTTRKCluster(1, il+1, cid++); - this_cluster.addAll(clusterHits); + is = isnext-1; + FTTRKCluster this_cluster = new FTTRKCluster(1, il+1, ++cid); + // modify clusterIndex for all the hits belonging to the cluster + ArrayList cloneHitsWNewID = new ArrayList(); + for(FTTRKHit clHit: clusterHits){ + clHit.set_DGTZIndex(clHit.get_Id()); + clHit.set_ClusterIndex(cid); + cloneHitsWNewID.add(clHit); + } + this_cluster.addAll(cloneHitsWNewID); this_cluster.calc_CentroidParams(); clusters.add(this_cluster); - if(debugMode>=1) System.out.println("cluster number " + cid + " size " + clusterHits.size() + " layer " + this_cluster.get_Layer() + - " " + this_cluster.get_MaxStrip() + "-" + this_cluster.get_MinStrip() + " " + this_cluster.get_Centroid()) ; - } // check on seed - } // end loop on strips - } // end loop on layers + if(debugMode>=1){ + System.out.println("xxxxxxxxxxxxxxx cluster properties " + this_cluster.get_CId() + " cluster size " + this_cluster.size()); + for(int k=0; k clusterHits = new ArrayList(); + checked[lis][il] = true; + // if fired this is the first strip of the cluster + clusterHits.add(new FTTRKHit(HitArray[lis][il].get_Sector(), HitArray[lis][il].get_Layer(), HitArray[lis][il].get_Strip(), + HitArray[lis][il].get_Edep(), HitArray[lis][il].get_Id())); + // look for a consecutive strip in the stack and stick it to the cluster + int isnext = is+1; + while(isnext < 640 && HitArray[indL[isnext]][il] != null && !checked[indL[isnext]][il]){ + int nlis = indL[isnext]; + checked[nlis][il] = true; + clusterHits.add(new FTTRKHit(HitArray[nlis][il].get_Sector(), HitArray[nlis][il].get_Layer(), HitArray[nlis][il].get_Strip(), + HitArray[nlis][il].get_Edep(), HitArray[nlis][il].get_Id())); + nst++; + isnext++; + } + is = isnext-1; + FTTRKCluster this_cluster = new FTTRKCluster(1, il+1, ++cid); +// this_cluster.addAll(clusterHits); + ArrayList cloneHitsWNewID = new ArrayList(); + for(FTTRKHit clHit: clusterHits){ + clHit.set_DGTZIndex(clHit.get_Id()); + clHit.set_ClusterIndex(cid); + cloneHitsWNewID.add(clHit); + } + this_cluster.addAll(cloneHitsWNewID); + this_cluster.calc_CentroidParams(); + clusters.add(this_cluster); + } + is++; + } + // check if in any cluster there is a limiting strip. If two consecutive limiting strips are found, merge the clusters and + // delete the second one + int clusterId11 = -1; + int clusterId12 = -1; + int clusterId21 = -1; + int clusterId22 = -1; + for(FTTRKCluster clust : clusters){ + if(clust.get_Layer() == il+1){ + int nbhits = clust.size(); + for(int i=0; i < nbhits; i++){ + FTTRKHit hit = clust.get(i); + int nstrip = hit.get_Strip(); +// System.out.println("strip " + nstrip + " clusterId " + clust.get_CId() + " layer " + clust.get_Layer()); + if(nstrip==128 || nstrip==385 || nstrip==640 || nstrip==641){ + if(nstrip==128) clusterId11 = clust.get_CId(); //cut 127-384 + if(nstrip==385) clusterId12 = clust.get_CId(); + if(nstrip==640) clusterId21 = clust.get_CId(); // cut 640-641 + if(nstrip==641) clusterId22 = clust.get_CId(); + } + } + } + } + // join clusters if there are consecutive limiting hits + if(clusterId11>=0 && clusterId12>=0 && clusterId11 != clusterId12){ + ArrayList twoClusterHits = new ArrayList(); + FTTRKCluster firstCluster = clusters.get(clusterId11); + FTTRKCluster secondCluster = clusters.get(clusterId12); + for(int i=0; i< firstCluster.size(); i++){ + FTTRKHit hit = firstCluster.get(i); + twoClusterHits.add(hit); + } + for(int i=0; i< secondCluster.size(); i++){ + FTTRKHit hit = secondCluster.get(i); + twoClusterHits.add(hit); + } + //FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, clusters.size()+1); + FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, clusters.size()-2); + // update cluster and hit ID + ArrayList cloneHitsWNewID = new ArrayList(); + for(FTTRKHit clHit: twoClusterHits){ + clHit.set_DGTZIndex(clHit.get_Id()); + clHit.set_ClusterIndex(clusters.size()-2); // was +1 + cloneHitsWNewID.add(clHit); + } + joinedClusters.addAll(cloneHitsWNewID); +// joinedClusters.addAll(twoClusterHits); + joinedClusters.calc_CentroidParams(); + clusters.add(joinedClusters); + } + if(clusterId21>=0 && clusterId22>=0 && clusterId21 != clusterId22){ + ArrayList twoClusterHits = new ArrayList(); + FTTRKCluster firstCluster = clusters.get(clusterId21); + FTTRKCluster secondCluster = clusters.get(clusterId22); + for(int i=0; i< firstCluster.size(); i++){ + FTTRKHit hit = firstCluster.get(i); + twoClusterHits.add(hit); + } + for(int i=0; i< secondCluster.size(); i++){ + FTTRKHit hit = secondCluster.get(i); + twoClusterHits.add(hit); + } + FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, clusters.size()-2); +// joinedClusters.addAll(twoClusterHits); + // update cluster and hit ID + ArrayList cloneHitsWNewID = new ArrayList(); + for(FTTRKHit clHit: twoClusterHits){ + clHit.set_DGTZIndex(clHit.get_Id()); + clHit.set_ClusterIndex(clusters.size()-2); + cloneHitsWNewID.add(clHit); + } + joinedClusters.addAll(cloneHitsWNewID); + joinedClusters.calc_CentroidParams(); + clusters.add(joinedClusters); + } + // remove second clusters from the final list + if(clusterId11>=0 && clusterId12>=0) { + if(clusterId11=0 && clusterId22>=0){ + if(clusterId21 findCrosses(List clusters) { ArrayList crosses = new ArrayList(); - int rid =0; + int rid =-1; for(FTTRKCluster inlayerclus : allinnerlayrclus){ + if(inlayerclus.size() findCrosses(List clusters) { && (inlayerclus.get_MaxStrip()+outlayerclus.get_MaxStrip() < FTTRKConstantsLoader.Nstrips*2) ) { // put correct numbers to make sure the intersection is valid // define new cross - FTTRKCross this_cross = new FTTRKCross(inlayerclus.get_Sector(), inlayerclus.get_Region(),rid++); + FTTRKCross this_cross = new FTTRKCross(inlayerclus.get_Sector(), inlayerclus.get_Region(),++rid); this_cross.set_Cluster1(inlayerclus); this_cross.set_Cluster2(outlayerclus); @@ -212,10 +336,61 @@ public ArrayList findCrosses(List clusters) { if(debugMode>=1) System.out.println("cross radius =============" + radXCenter); if(radXCenter > FTTRKConstantsLoader.InnerHole && radXCenter < FTTRKConstantsLoader.Rmax) crosses.add(this_cross); if(debugMode>=1) System.out.println("cross info :" + this_cross.printInfo() + " " + crosses.size()); + + } + } + } + /* + // validate crosses in two detectors: their distance must be within a reasonable tolerance + ArrayList validatedCrosses = new ArrayList(); + for(int ic=0; icic; jc--){ + FTTRKCross cross1 = crosses.get(ic); + FTTRKCross cross2 = crosses.get(jc); + if(cross1.get_Id()!=cross2.get_Id() && cross1.get_Region()!=cross2.get_Region()){ + double rad1 = Math.sqrt(cross1.get_Point().x()*cross1.get_Point().x() + + cross1.get_Point().y()*cross1.get_Point().y()); + double rad2 = Math.sqrt(cross2.get_Point().x()*cross2.get_Point().x() + + cross2.get_Point().y()*cross2.get_Point().y()); + double diffPhi = Math.abs(Math.atan2(cross1.get_Point().y(),cross1.get_Point().x()) - + Math.atan2(cross2.get_Point().y(),cross2.get_Point().x())); + double diffTheta = Math.abs(Math.atan2(rad1,cross1.get_Point().z())- Math.atan2(rad2,cross2.get_Point().z())); + double phiTolerance = 0.01; + double thetaTolerance = 0.01; + if(Math.abs(rad2-rad1)< FTConstants.TOLERANCE_ON_CROSSES_TWO_DETECTORS && diffPhi validatedCrosses = new ArrayList(); + double maxEn1 =-100.; + double maxEn2 =-100.; + int idMax1=-1, idMax2=-1; + for(int ic=0; icmaxEn1){ + maxEn1 = crossEnergy; + idMax1 = ic; + } + }else if(aCross.get_Region()==2){ + if(crossEnergy>maxEn2){ + maxEn2 = crossEnergy; + idMax2 = ic; } } } - return crosses; + if(idMax1>=0) validatedCrosses.add(crosses.get(idMax1)); + if(idMax2>=0) validatedCrosses.add(crosses.get(idMax2)); + + return validatedCrosses; + //return crosses; } public List readRawHits(DataEvent event, IndexedTable charge2Energy, IndexedTable timeOffsets, IndexedTable geometry) { @@ -226,24 +401,58 @@ public List readRawHits(DataEvent event, IndexedTable charge2Energy, I if(event.hasBank("FTTRK::adc")==true) { DataBank bankDGTZ = event.getBank("FTTRK::adc"); int nrows = bankDGTZ.rows(); + int hitId = -1; for(int row = 0; row < nrows; row++){ int isector = bankDGTZ.getInt("sector",row); int ilayer = bankDGTZ.getInt("layer",row); int icomponent = bankDGTZ.getInt("component",row); int iorder = bankDGTZ.getInt("order",row); int adc = bankDGTZ.getInt("ADC",row); - float time = bankDGTZ.getFloat("time",row); - if(adc>0 && time!=-1 && icomponent!=-1){ - FTTRKHit hit = new FTTRKHit(isector,ilayer,icomponent, (double) adc); + float time = bankDGTZ.getLong("timestamp",row); // entry not avalable in mc banks yet + // set threshold on FTTRK ADCs (in FTConstants.java + if(adc>FTConstants.FTTRKAdcThreshold && time!=-1 && icomponent!=-1){ +// System.out.println("~~~~~~~~~~ adc dell'hit accettato " + adc + " component " + icomponent + " layer " + ilayer); + FTTRKHit hit = new FTTRKHit(isector,ilayer,icomponent, (double) adc, ++hitId); hits.add(hit); } } } - return hits; + // order hits list by component + List hitsOrderedByLay = new ArrayList(); + + // order by layers + int Nlayers = FTTRKConstantsLoader.Nlayers; + int Nstrips = FTTRKConstantsLoader.Nstrips; + for(int nlayer=1; nlayer<=Nlayers; nlayer++){ + for(FTTRKHit h:hits){ + if(h.get_Layer()==nlayer) hitsOrderedByLay.add(h); + } + } + + // order by strip + List hitsOrderedByStrip = new ArrayList(); + for(int nlayer=1; nlayer<=Nlayers; nlayer++){ + for(int nstrip=1; nstrip<=Nstrips; nstrip++){ + for(FTTRKHit h: hitsOrderedByLay){ + if(nlayer == h.get_Layer() && nstrip == h.get_Strip()) hitsOrderedByStrip.add(h); + } + } + } + + return hitsOrderedByStrip; } - public void writeBanks(DataEvent event, List hits, List clusters, List crosses){ + if(event instanceof EvioDataEvent) { + writeEvioBanks(event, hits, clusters, crosses); + } + else if(event instanceof HipoDataEvent) { + writeHipoBanks(event, hits, clusters, crosses); + } + } + + + public void writeHipoBanks(DataEvent event, List hits, List clusters, List crosses){ // hits banks if(hits.size()!=0) { @@ -276,7 +485,7 @@ public void writeBanks(DataEvent event, List hits, List } for(int i = 0; i < clusters.size(); i++){ bankCluster.setShort("size", i,(short) clusters.get(i).size()); - bankCluster.setShort("id", i,(short) clusters.get(i).get_Id()); + bankCluster.setShort("id", i,(short) clusters.get(i).get_CId()); bankCluster.setByte("sector", i,(byte) clusters.get(i).get_Sector()); bankCluster.setByte("layer", i,(byte) clusters.get(i).get_Layer()); bankCluster.setFloat("energy", i,(float) clusters.get(i).get_TotalEnergy()); @@ -295,18 +504,110 @@ public void writeBanks(DataEvent event, List hits, List return; } for (int j = 0; j < crosses.size(); j++) { + bankCross.setShort("size", j, (short) crosses.size()); bankCross.setShort("id", j, (short) crosses.get(j).get_Id()); bankCross.setByte("sector", j, (byte) crosses.get(j).get_Sector()); - bankCross.setByte("detector", j, (byte) crosses.get(j).get_Region()); + bankCross.setByte("detector", j, (byte) (crosses.get(j).get_Region()-1)); // detector: 0 or 1, region 1 or 2 bankCross.setFloat("x", j, (float) crosses.get(j).get_Point().x()); bankCross.setFloat("y", j, (float) crosses.get(j).get_Point().y()); bankCross.setFloat("z", j, (float) crosses.get(j).get_Point().z()); - bankCross.setShort("Cluster1ID", j, (short) crosses.get(j).get_Cluster1().get_Id()); - bankCross.setShort("Cluster2ID", j, (short) crosses.get(j).get_Cluster2().get_Id()); + bankCross.setShort("Cluster1ID", j, (short) crosses.get(j).get_Cluster1().get_CId()); + bankCross.setShort("Cluster2ID", j, (short) crosses.get(j).get_Cluster2().get_CId()); } event.appendBanks(bankCross); } } + + public void writeEvioBanks(DataEvent event, List hits, List clusters, List crosses){ + + EvioDataBank bankHits = null; + EvioDataBank bankCluster = null; + EvioDataBank bankCross = null; + + // hits banks + if(hits.size()!=0) { + bankHits = (EvioDataBank) event.getDictionary().createBank("FTTRK::hits", hits.size()); + if(bankHits==null){ + System.out.println("ERROR CREATING BANK : FTTRK::hits"); + return; + } + + for(int i = 0; i < hits.size(); i++){ + bankHits.setByte("sector",i,(byte) hits.get(i).get_Sector()); + bankHits.setByte("layer",i,(byte) hits.get(i).get_Layer()); + bankHits.setShort("component",i,(short) hits.get(i).get_Strip()); +// bankHits.setFloat("x",i,(float) (hits.get(i).get_Dx()/10.0)); +// bankHits.setFloat("y",i,(float) (hits.get(i).get_Dy()/10.0)); +// bankHits.setFloat("z",i,(float) (hits.get(i).get_Dz()/10.0)); + bankHits.setFloat("energy",i,(float) hits.get(i).get_Edep()); + bankHits.setFloat("time",i,(float) hits.get(i).get_Time()); + bankHits.setShort("hitID",i,(short) hits.get(i).get_DGTZIndex()); + bankHits.setShort("clusterID",i,(short) hits.get(i).get_ClusterIndex()); + } + event.appendBanks(bankHits); + } + // cluster bank + if(debugMode>=1) System.out.println("cluster bank size " + clusters.size()); + if(clusters.size()!=0){ + bankCluster = (EvioDataBank) event.getDictionary().createBank("FTTRK::clusters", clusters.size()); + if(bankCluster==null){ + System.out.println("ERROR CREATING BANK : FTTRK::clusters"); + return; + } + for(int i = 0; i < clusters.size(); i++){ + bankCluster.setShort("size", i,(short) clusters.get(i).size()); + bankCluster.setShort("id", i,(short) clusters.get(i).get_CId()); + bankCluster.setByte("sector", i,(byte) clusters.get(i).get_Sector()); + bankCluster.setByte("layer", i,(byte) clusters.get(i).get_Layer()); + bankCluster.setFloat("energy", i,(float) clusters.get(i).get_TotalEnergy()); + bankCluster.setFloat("maxEnergy", i,(float) clusters.get(i).get_SeedEnergy()); + bankCluster.setShort("seed", i,(short) clusters.get(i).get_SeedStrip()); + bankCluster.setFloat("centroid", i,(float) clusters.get(i).get_Centroid()); + } + event.appendBanks(bankCluster); + } + // cross bank + if(debugMode>=1) System.out.println("crosses bank size " + crosses.size()); + if(crosses.size()!=0){ + bankCross = (EvioDataBank) event.getDictionary().createBank("FTTRK::crosses", crosses.size()); + if(bankCross==null){ + System.out.println("ERROR CREATING BANK : FTTRK::crosses"); + return; + } + for (int j = 0; j < crosses.size(); j++) { +// bankCross.setShort("size", j, (short) crosses.get(j).size()); + bankCross.setShort("size", j, (short) crosses.size()); + bankCross.setShort("id", j, (short) crosses.get(j).get_Id()); + bankCross.setByte("sector", j, (byte) crosses.get(j).get_Sector()); + bankCross.setByte("detector", j, (byte) (crosses.get(j).get_Region()-1)); // detector: 0 or 1, region 1 or 2 + bankCross.setFloat("x", j, (float) crosses.get(j).get_Point().x()); + bankCross.setFloat("y", j, (float) crosses.get(j).get_Point().y()); + bankCross.setFloat("z", j, (float) crosses.get(j).get_Point().z()); + bankCross.setShort("Cluster1ID", j, (short) crosses.get(j).get_Cluster1().get_CId()); + bankCross.setShort("Cluster2ID", j, (short) crosses.get(j).get_Cluster2().get_CId()); + } + event.appendBanks(bankCross); + } + } + + + public void updateAllHitsWithAssociatedIDs(List hits, List clusters){ + // update clusterIndex and crossIndex for hits belonging to a cross + for(FTTRKCluster aCluster: clusters){ + int i=-1; + for(FTTRKHit ahitInCluster: aCluster){ + for(FTTRKHit aHit: hits){ + if(aHit.get_Id()==ahitInCluster.get_Id()){ + aHit.set_DGTZIndex(ahitInCluster.get_DGTZIndex()); + aHit.set_ClusterIndex(ahitInCluster.get_ClusterIndex()); + aHit.set_CrossIndex(ahitInCluster.get_CrossIndex()); + } + } + } + } + } + + } From fa0283c0248d3782c56feac9e6438109420e51c0 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Mon, 11 Jan 2021 15:54:53 +0100 Subject: [PATCH 008/104] minor fix --- .../ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java index 7b1aa864f9..74a7b9a9b2 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java @@ -90,11 +90,11 @@ public int get_CId() { * @param _Id the id of the cluster */ public void set_CId(int _Id) { - this._CId = _CId; + this._CId = _Id; // update hits collection with the proper cluster index for(int i=0; i Date: Tue, 12 Jan 2021 15:58:08 +0100 Subject: [PATCH 009/104] minor fix --- etc/services/reconstruction.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/services/reconstruction.yaml b/etc/services/reconstruction.yaml index 692abb1912..f99941fa84 100644 --- a/etc/services/reconstruction.yaml +++ b/etc/services/reconstruction.yaml @@ -12,7 +12,7 @@ services: name: FTCAL - class: org.jlab.rec.ft.hodo.FTHODOEngine name: FTHODO - - class: org.jlab.ft.trk.FTTRKEngine + - class: org.jlab.rec.ft.trk.FTTRKEngine name: FTTRK - class: org.jlab.rec.ft.FTEBEngine name: FTEB From fd9456ced2b66a444e7876bb482f41b7799831f6 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Wed, 13 Jan 2021 13:33:07 +0100 Subject: [PATCH 010/104] FTTRKCluster: added missing parenthesis --- .../ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java index 2175effdf5..407dc3244a 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java @@ -391,5 +391,5 @@ public void set_AssociatedTrackID(int _AssociatedTrackID) { public int compareTo(FTTRKCluster arg) { return this.get_Layer() < arg.get_Layer() ? -1 : this.get_Layer() == arg.get_Layer() ? 0 : 1; - + } } From c9b472ad5fb2243e68aea1803504652d45addf6d Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Wed, 13 Jan 2021 18:53:14 +0100 Subject: [PATCH 011/104] restore original version after merge --- etc/bankdefs/hipo/FT.json | 47 ------------------- .../org/jlab/rec/ft/trk/FTTRKCluster.java | 4 +- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 2 - 3 files changed, 2 insertions(+), 51 deletions(-) diff --git a/etc/bankdefs/hipo/FT.json b/etc/bankdefs/hipo/FT.json index fe78feb41c..e1d79ebcab 100644 --- a/etc/bankdefs/hipo/FT.json +++ b/etc/bankdefs/hipo/FT.json @@ -117,53 +117,6 @@ ] }, { - "bank": "FTTRK::hits", - "group": 21321, - "info": "Reconstructed Hits in FT hodoscope", - "items": [ - {"name":"sector", "id":2, "type":"int8", "info":"sector number"}, - {"name":"layer", "id":3, "type":"int8", "info":"layer number"}, - {"name":"component", "id":4, "type":"int16", "info":"component number"}, - {"name":"x", "id":5, "type":"float", "info":"Hit X position (cm)" }, - {"name":"y", "id":6, "type":"float", "info":"Hit Y position (cm)" }, - {"name":"z", "id":7, "type":"float", "info":"Hit Z position (cm)" }, - {"name":"energy", "id":8, "type":"float", "info":"Hit Energy" }, - {"name":"time", "id":9, "type":"float", "info":"Hit Time" }, - {"name":"hitID", "id":10, "type":"int16", "info":"Hit Pointer to ADC bank"}, - {"name":"clusterID", "id":11, "type":"int16", "info":"Hit Pointer to Cluster Bank"} - ] - }, - { - "bank": "FTTRK::clusters", - "group": 21322, - "info": "Reconstructed clusters in FT tracker", - "items": [ - {"name":"size", "id":1, "type":"int16", "info":"Cluster size"}, - {"name":"id", "id":2, "type":"int16", "info":"Cluster ID"}, - {"name":"sector", "id":3, "type":"int8", "info":"Cluster sector"}, - {"name":"layer", "id":4, "type":"int8", "info":"Cluster layer"}, - {"name":"energy", "id":5, "type":"float", "info":"Cluster total energy"}, - {"name":"maxEnergy", "id":6, "type":"float", "info":"Seed energy "}, - {"name":"seed", "id":7, "type":"int16", "info":"Seed strip"}, - {"name":"centroid", "id":8, "type":"float", "info":"Centroid strip number"} - ] - }, - { - "bank": "FTTRK::crosses", - "group": 21323, - "info": "Reconstructed crosses in FT tracker", - "items": [ - {"name":"id", "id":1, "type":"int16", "info":"Cross ID"}, - {"name":"sector", "id":2, "type":"int8", "info":"Cross sector"}, - {"name":"detector", "id":3, "type":"int8", "info":"Cross detector"}, - {"name":"x", "id":4, "type":"float", "info":"Cross X position (cm)"}, - {"name":"y", "id":5, "type":"float", "info":"Cross Y position (cm)"}, - {"name":"z", "id":6, "type":"float", "info":"Cross Z position (cm)"}, - {"name":"Cluster1ID", "id":10, "type":"int16", "info":"ID of the bottom layer cluster in the Cross"}, - {"name":"Cluster2ID", "id":11, "type":"int16", "info":"ID of the top layer cluster in the Cross"} - ] - }, - { "bank": "FT::particles", "group": 20924, "info": "Reconstructed Particles in FT", diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java index 407dc3244a..e5fc22954f 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java @@ -158,7 +158,7 @@ public void calc_CentroidParams() { double zCentEndPoint2 = 0; // cluster energy-weighted Centroid z coordinate of the second end-point double totEn = 0.; // cluster total energy - double totEnSq = 0.; // sum of energies squared + double totEnSq = 0.; // sum of energies squared double weightedStrp = 0; // energy-weighted strip double weightedStripEndPoint1X = 0; // Energy-weighted x of the strip first end point @@ -170,7 +170,7 @@ public void calc_CentroidParams() { int nbhits = this.size(); - if(nbhits != 0) { + if(nbhits != 0) { int min = 1000000; int max = -1; int seed = -1; diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index bc1bc2a8d9..b9bf1917dc 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -61,8 +61,6 @@ public ArrayList findClusters(List hits) boolean[][] checked; FTTRKHit[][] HitArray; ArrayList clusters = new ArrayList(); - FTTRKHit[] clusterHitAtBorder = new FTTRKHit[3]; - int[] limitingStrip = {127, 383, 639}; // strip numbering from 0 to 767 // a boolean array to avoid double counting at the numbering discontinuities checked = new boolean[Nstrips][Nlayers] ; From c941245064b93cc3282c8736fded4bd8992b684b Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 14 Jan 2021 11:03:21 +0100 Subject: [PATCH 012/104] include FTTRKEngine --- .../org/jlab/clas/reco/EngineProcessor.java | 92 +++++++------------ 1 file changed, 34 insertions(+), 58 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java index 7e7a7beb03..691118a26f 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java @@ -1,13 +1,7 @@ -/* - * 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.clas.reco; import java.io.FileNotFoundException; import java.io.IOException; -import java.lang.ClassCastException; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -18,19 +12,19 @@ import org.jlab.io.hipo.HipoDataSync; import org.jlab.utils.benchmark.ProgressPrintout; import org.jlab.utils.options.OptionParser; -import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.clara.engine.EngineData; import org.jlab.clara.engine.EngineDataType; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; import java.io.InputStream; import java.io.FileInputStream; +import org.jlab.utils.JsonUtils; import org.json.JSONObject; /** * - * @author gavalian, kenjo + * @author gavalian, kenjo, baltzell */ public class EngineProcessor { @@ -74,10 +68,6 @@ public void initDefault(){ for(int i = 0; i < names.length; i++){ this.addEngine(names[i], services[i]); } - /* - for(String service : services){ - this.addEngine(service); - }*/ } public void initAll(){ @@ -94,7 +84,7 @@ public void initAll(){ "org.jlab.clas.swimtools.MagFieldsEngine", "org.jlab.rec.ft.cal.FTCALEngine", "org.jlab.rec.ft.hodo.FTHODOEngine", - "org.jlab.rec.ft.trk.FTTRKEngine", + "org.jlab.rec.ft.fttrk.FTTRKEngine", "org.jlab.rec.ft.FTEBEngine", "org.jlab.service.dc.DCHBEngine", "org.jlab.service.ftof.FTOFHBEngine", @@ -117,11 +107,8 @@ public void initAll(){ for(int i = 0; i < names.length; i++){ this.addEngine(names[i], services[i]); } - /* - for(String service : services){ - this.addEngine(service); - }*/ } + public void initCaloDebug(){ String[] names = new String[]{ @@ -136,26 +123,23 @@ public void initCaloDebug(){ for(int i = 0; i < names.length; i++){ this.addEngine(names[i], services[i]); } - /* - for(String service : services){ - this.addEngine(service); - }*/ } + /** * Adding engine to the map the order of the services matters, since they will * be executed in order added. * @param name name for the service * @param clazz class name including the package name - * @param jsonConfig string in json format with engine configuration + * @param jsonConf string in json format with engine configuration */ public void addEngine(String name, String clazz, String jsonConf) { - Class c = null; + Class c; try { c = Class.forName(clazz); if( ReconstructionEngine.class.isAssignableFrom(c)==true){ ReconstructionEngine engine = (ReconstructionEngine) c.newInstance(); engine.init(); - if(jsonConf!="null") { + if(!jsonConf.equals("null")) { EngineData input = new EngineData(); input.setData(EngineDataType.JSON.mimeType(), jsonConf); engine.configure(input); @@ -164,14 +148,11 @@ public void addEngine(String name, String clazz, String jsonConf) { } else { System.out.println(">>>> ERROR: class is not a reconstruction engine : " + clazz); } - } catch (ClassNotFoundException ex) { - Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); } } + /** * Adding engine to the map the order of the services matters, since they will * be executed in order added. @@ -179,7 +160,7 @@ public void addEngine(String name, String clazz, String jsonConf) { * @param clazz class name including the package name */ public void addEngine(String name, String clazz) { - Class c = null; + Class c; try { c = Class.forName(clazz); if( ReconstructionEngine.class.isAssignableFrom(c)==true){ @@ -189,20 +170,17 @@ public void addEngine(String name, String clazz) { } else { System.out.println(">>>> ERROR: class is not a reconstruction engine : " + clazz); } - } catch (ClassNotFoundException ex) { - Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); } } + /** * Add reconstruction engine to the chain * @param clazz Engine class. */ public void addEngine( String clazz) { - Class c = null; + Class c; try { c = Class.forName(clazz); if( ReconstructionEngine.class.isAssignableFrom(c)==true){ @@ -212,14 +190,11 @@ public void addEngine( String clazz) { } else { System.out.println(">>>> ERROR: class is not a reconstruction engine : " + clazz); } - } catch (ClassNotFoundException ex) { - Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); } } + /** * Initialize all the engines in the chain. */ @@ -232,6 +207,7 @@ public void init(){ } System.out.println("\n\n"); } + /** * process a single event through the chain. * @param event @@ -239,8 +215,11 @@ public void init(){ public void processEvent(DataEvent event){ for(Map.Entry engine : this.processorEngines.entrySet()){ try { - //System.out.println("processing engine : " + engine.getKey()); - //System.out.println("processing event"); + if (!engine.getValue().wroteConfig) { + engine.getValue().wroteConfig = true; + JsonUtils.extend(event, ReconstructionEngine.CONFIG_BANK_NAME, "json", + engine.getValue().generateConfig()); + } engine.getValue().processDataEvent(event); } catch (Exception e){ @@ -254,10 +233,12 @@ public void processEvent(DataEvent event){ public void processFile(String file, String output){ this.processFile(file, output, -1); } + /** * process entire file through engine chain. * @param file file name to process. * @param output + * @param nevents */ public void processFile(String file, String output, int nevents){ if(file.endsWith(".hipo")==true){ @@ -284,6 +265,7 @@ public void processFile(String file, String output, int nevents){ writer.close(); } } + /** * display services registered with the processor. */ @@ -314,37 +296,29 @@ public static void main(String[] args){ String inputFile = parser.getOption("-i").stringValue(); String outputFile = parser.getOption("-o").stringValue(); - /*for(int i =1; i < args.length; i++){ - services.add(args[i]); - }*/ - EngineProcessor proc = new EngineProcessor(); int config = parser.getOption("-c").intValue(); int nevents = parser.getOption("-n").intValue(); String yamlFileName = parser.getOption("-y").stringValue(); - if(yamlFileName!="0") { + + if(!yamlFileName.equals("0")) { try { InputStream input = new FileInputStream(yamlFileName); Yaml yaml = new Yaml(); Map yamlConf = (Map) yaml.load(input); JSONObject jsonObject=new JSONObject(yamlConf); - System.out.println(jsonObject.getJSONObject("configuration").getJSONObject("services")); for(Object obj: jsonObject.getJSONArray("services")) { if(obj instanceof JSONObject) { JSONObject service = (JSONObject) obj; String name = service.getString("name"); String engineClass = service.getString("class"); - System.out.println(name); - System.out.println(engineClass); - JSONObject configs = jsonObject.getJSONObject("configuration").getJSONObject("services"); - if(configs.has(name)) { - proc.addEngine(name, engineClass, configs.getJSONObject(name).toString()); + JSONObject configs = JsonUtils.filterClaraYaml(jsonObject,name); + if(configs.length()>0) { + proc.addEngine(name, engineClass, configs.toString()); } else { proc.addEngine(name, engineClass); } } -// System.out.println(yamlConf.get("configuration").get("services")); -// String jsonConf = gson.toJson(yamlConf["configuration"]["services"][service["name"]]); } } catch (FileNotFoundException ex) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); @@ -353,7 +327,8 @@ public static void main(String[] args){ } catch (ClassCastException | YAMLException ex) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); } - } else if (config>0){ + } + else if (config>0){ if(config>2){ proc.initCaloDebug(); } else if(config==2){ @@ -361,7 +336,8 @@ public static void main(String[] args){ } else { proc.initDefault(); } - } else { + } + else { for(String engine : services){ System.out.println("Adding reconstruction engine " + engine); proc.addEngine(engine); From 19615b1b943b119b1b7c1af5a6b8456ea2cc543a Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 14 Jan 2021 11:24:38 +0100 Subject: [PATCH 013/104] align after merge --- etc/bankdefs/util/bankSplit.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/etc/bankdefs/util/bankSplit.py b/etc/bankdefs/util/bankSplit.py index 67ff536787..c05d047c9c 100644 --- a/etc/bankdefs/util/bankSplit.py +++ b/etc/bankdefs/util/bankSplit.py @@ -49,12 +49,20 @@ def createdirandlinks(dirname, banklist): print("Single json files saved in " + workdirectory + singledirectory) # create dst, calibration and monitoring directories -dst = ["BAND::laser","RUN::config","RAW::epics","RAW::scaler","REC::Event","REC::Particle","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::ForwardTagger","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RICH::tdc","RICH::ringCher","RICH::hadCher","RUN::scaler","HEL::flip","HEL::online","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True"] -calibration = ["BAND::adc","BAND::tdc","BAND::hits","BAND::rawhits","BAND::laser","CND::adc","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTTRK::adc","FTTRK::clusters","FTTRK::hits","FTTRK::crosses","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::flip","HEL::online","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadCher","RICH::hadrons","RICH::photons","RICH::ringCher","RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] -monitoring = ["BAND::adc","BAND::tdc","BAND::rawhits","BAND::laser","BAND::hits","BMT::adc","BMTRec::Clusters","BMTRec::Crosses","BMTRec::Hits","BMTRec::LayerEffs","BST::adc","BSTRec::Clusters","BSTRec::Crosses","BSTRec::Hits","BSTRec::LayerEffs","CND::adc","CND::clusters","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","CVTRec::Trajectory","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::hits","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTTRK::adc","FTTRK::clusters","FTTRK::hits","FTTRK::crosses","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::adc","HEL::flip","HEL::online","HitBasedTrkg::HBTracks","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","RAW::vtp","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RECHB::Calorimeter","RECHB::Cherenkov","RECHB::Event","RECHB::ForwardTagger","RECHB::Particle","RECHB::Scintillator","RECHB::Track","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadCher","RICH::hadrons","RICH::photons","RICH::ringCher","RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] +dst = ["BAND::laser","RUN::config","RAW::epics","RAW::scaler","REC::Event","REC::Particle","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::ForwardTagger","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RICH::tdc","RICH::ringCher","RICH::hadCher","RTPC::tracks", "RUN::scaler","HEL::flip","HEL::online","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True"] + +calibration = ["BAND::adc","BAND::tdc","BAND::hits","BAND::rawhits","BAND::laser","CND::adc","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTTRK::adc","FTTRK::clusters","FTTRK::hits","FTTRK::crosses","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::flip","HEL::online","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadCher","RICH::hadrons","RICH::photons","RICH::ringCher", "RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] + +monitoring = ["BAND::adc","BAND::tdc","BAND::rawhits","BAND::laser","BAND::hits","BMT::adc","BMTRec::Clusters","BMTRec::Crosses","BMTRec::Hits","BMTRec::LayerEffs","BST::adc","BSTRec::Clusters","BSTRec::Crosses","BSTRec::Hits","BSTRec::LayerEffs","CND::adc","CND::clusters","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","CVTRec::Trajectory","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::hits","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTTRK::adc","FTTRK::clusters","FTTRK::hits","FTTRK::crosses","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::adc","HEL::flip","HEL::online","HitBasedTrkg::HBTracks","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","RAW::vtp","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RECHB::Calorimeter","RECHB::Cherenkov","RECHB::Event","RECHB::ForwardTagger","RECHB::Particle","RECHB::Scintillator","RECHB::Track","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadCher","RICH::hadrons","RICH::photons","RICH::ringCher","RTPC::hits","RTPC::tracks","RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] + ebrerun=list(dst) ebrerun.extend(["FTOF::hits","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory","TimeBasedTrkg::TBCovMat","HitBasedTrkg::HBTracks","FTOF::hbhits","ECAL::clusters","CTOF::hits","CND::clusters","HTCC::rec","LTCC::clusters","ECAL::moments","CVTRec::Tracks","CVTRec::Trajectory","FT::particles","FTCAL::clusters","FTHODO::clusters","FTTRK::clusters","RUN:rf"]) + +dsthb=list(dst) +dsthb.extend(["RECHB::Event","RECHB::Particle","RECHB::Calorimeter","RECHB::Cherenkov","RECHB::CovMat","RECHB::ForwardTagger","RECHB::Scintillator","RECHB::ScintExtras","RECHB::Track"]) + createdirandlinks("dst/", dst) +createdirandlinks("dsthb/", dsthb) createdirandlinks("calibration/", calibration) createdirandlinks("monitoring/", monitoring) #createdirandlinks("ebrerun/", ebrerun) From f26acd53151041ed282d5904fc85bec77b28a4f9 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 14 Jan 2021 11:36:02 +0100 Subject: [PATCH 014/104] align after merge --- etc/services/mc.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etc/services/mc.yaml b/etc/services/mc.yaml index fd2f25b925..e9c597b17d 100644 --- a/etc/services/mc.yaml +++ b/etc/services/mc.yaml @@ -53,6 +53,8 @@ configuration: MAGFIELDS: magfieldSolenoidMap: Symm_solenoid_r601_phi1_z1201_13June2018.dat magfieldTorusMap: Symm_torus_r2501_phi16_z251_24Apr2018.dat - + RTPC: + rtpcSimulation: "true" + mime-types: - binary/data-hipo From 116b57dbc3c97700ef69a7fefac8710ee928177e Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 14 Jan 2021 11:38:06 +0100 Subject: [PATCH 015/104] align after merge --- etc/services/reconstruction.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/etc/services/reconstruction.yaml b/etc/services/reconstruction.yaml index f99941fa84..725399b9c2 100644 --- a/etc/services/reconstruction.yaml +++ b/etc/services/reconstruction.yaml @@ -73,9 +73,6 @@ configuration: # EBTB: # variation: default # timestamp: 08/22/2018 - RTPC: - rtpcSimulation: "false" - rtpcCosmic: "true" - rtpcBeamlineFit: "false" + mime-types: - binary/data-hipo From efe79d9e8c52b8b06914d88f42f1ebe8725cf27e Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 17 Jan 2021 14:37:21 +0100 Subject: [PATCH 016/104] fix formatting --- etc/bankdefs/util/bankSplit.py | 2 +- .../ft/src/main/java/org/jlab/rec/ft/FTConstants.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/etc/bankdefs/util/bankSplit.py b/etc/bankdefs/util/bankSplit.py index c05d047c9c..8b965b7398 100644 --- a/etc/bankdefs/util/bankSplit.py +++ b/etc/bankdefs/util/bankSplit.py @@ -49,7 +49,7 @@ def createdirandlinks(dirname, banklist): print("Single json files saved in " + workdirectory + singledirectory) # create dst, calibration and monitoring directories -dst = ["BAND::laser","RUN::config","RAW::epics","RAW::scaler","REC::Event","REC::Particle","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::ForwardTagger","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RICH::tdc","RICH::ringCher","RICH::hadCher","RTPC::tracks", "RUN::scaler","HEL::flip","HEL::online","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True"] +dst = ["BAND::laser","RUN::config","RAW::epics","RAW::scaler","REC::Event","REC::Particle","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::ForwardTagger","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RICH::tdc","RICH::ringCher","RICH::hadCher","RTPC::tracks","RUN::scaler","HEL::flip","HEL::online","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True"] calibration = ["BAND::adc","BAND::tdc","BAND::hits","BAND::rawhits","BAND::laser","CND::adc","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTTRK::adc","FTTRK::clusters","FTTRK::hits","FTTRK::crosses","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::flip","HEL::online","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::ScintExtras","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadCher","RICH::hadrons","RICH::photons","RICH::ringCher", "RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java index 4caab1a4fa..97e241540d 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java @@ -11,13 +11,13 @@ */ public class FTConstants { - public static final int HODO_MIN_CLUSTER_SIZE = 2; // minimum size of hodo clusters for match to calorimeter + public static final int HODO_MIN_CLUSTER_SIZE = 2; // minimum size of hodo clusters for match to calorimeter public static final double CAL_HODO_DISTANCE_MATCHING = 3.0; // matching distance in cm - public static final double CAL_HODO_TIME_MATCHING = 8; // matching time in ns + public static final double CAL_HODO_TIME_MATCHING = 8; // matching time in ns - public static final double CAL_TRK_DISTANCE_MATCHING = 1.5; // matching distance in cm - public static final double CAL_TRK_TIME_MATCHING = 30; // matching time in ns TOBECORRECTED + public static final double CAL_TRK_DISTANCE_MATCHING = 1.5; // matching distance in cm + public static final double CAL_TRK_TIME_MATCHING = 30; // matching time in ns TOBECORRECTED public static final double TRK_MIN_CROSS_NUMBER = 2; // minimum number of crosses to find a line in the tracker public static final double TRK0_TRK1_DISTANCE_MATCHING = 0.01; // matching distance between FTTRK points in cms From d33e383d4ae38d99f8bccbb9a41f1072196369fb Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Mon, 18 Jan 2021 10:34:46 +0100 Subject: [PATCH 017/104] change FTTRK bank content, ClusterID(1,2) removed, replaced by energy and time --- etc/bankdefs/hipo/FT.json | 16 ++++++++-------- etc/bankdefs/hipo4/ft.json | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/etc/bankdefs/hipo/FT.json b/etc/bankdefs/hipo/FT.json index e1d79ebcab..7dae4e1ba2 100644 --- a/etc/bankdefs/hipo/FT.json +++ b/etc/bankdefs/hipo/FT.json @@ -68,23 +68,23 @@ {"name":"energy", "id":10, "type":"float", "info":"Cluster total energy" } ] }, - { + { "bank": "FTTRK::hits", "group": 21321, "info": "Reconstructed Hits in FT hodoscope", "items": [ {"name":"sector", "id":2, "type":"int8", "info":"sector number"}, - {"name":"layer", "id":3, "type":"int8", "info":"layer number"}, + {"name":"layer", "id":3, "type":"int8", "info":"layer number"}, {"name":"component", "id":4, "type":"int16", "info":"component number"}, {"name":"x", "id":5, "type":"float", "info":"Hit X position (cm)" }, {"name":"y", "id":6, "type":"float", "info":"Hit Y position (cm)" }, {"name":"z", "id":7, "type":"float", "info":"Hit Z position (cm)" }, {"name":"energy", "id":8, "type":"float", "info":"Hit Energy" }, {"name":"time", "id":9, "type":"float", "info":"Hit Time" }, - {"name":"hitID", "id":10, "type":"int16", "info":"Hit Pointer to ADC bank"}, + {"name":"hitID", "id":10, "type":"int16", "info":"Hit Pointer to ADC bank"}, {"name":"clusterID", "id":11, "type":"int16", "info":"Hit Pointer to Cluster Bank"} ] - }, + }, { "bank": "FTTRK::clusters", "group": 21322, @@ -100,7 +100,7 @@ {"name":"centroid", "id":8, "type":"float", "info":"Centroid strip number"} ] }, - { + { "bank": "FTTRK::crosses", "group": 21323, "info": "Reconstructed crosses in FT tracker", @@ -112,10 +112,10 @@ {"name":"x", "id":5, "type":"float", "info":"Cross X position (cm)"}, {"name":"y", "id":6, "type":"float", "info":"Cross Y position (cm)"}, {"name":"z", "id":7, "type":"float", "info":"Cross Z position (cm)"}, - {"name":"Cluster1ID", "id":10, "type":"int16", "info":"ID of the bottom layer cluster in the Cross"}, - {"name":"Cluster2ID", "id":11, "type":"int16", "info":"ID of the top layer cluster in the Cross"} + {"name":"energy", "id":8, "type":"float", "info":"Energy associated to the Cross"}, + {"name":"time", "id":9, "type":"float", "info":"Time associated to the Cross"} ] - }, + }, { "bank": "FT::particles", "group": 20924, diff --git a/etc/bankdefs/hipo4/ft.json b/etc/bankdefs/hipo4/ft.json index c5e4d73ee9..d6e5dee76a 100644 --- a/etc/bankdefs/hipo4/ft.json +++ b/etc/bankdefs/hipo4/ft.json @@ -138,8 +138,8 @@ {"name":"x", "type":"F", "info":"Cross X position (cm)"}, {"name":"y", "type":"F", "info":"Cross Y position (cm)"}, {"name":"z", "type":"F", "info":"Cross Z position (cm)"}, - {"name":"Cluster1ID", "type":"S", "info":"ID of the bottom layer cluster in the Cross"}, - {"name":"Cluster2ID", "type":"S", "info":"ID of the top layer cluster in the Cross"} + {"name":"energy", "type":"F", "info":"Energy assigned to the Cross"}, + {"name":"time", "type":"F", "info":"Time assigned to the Cross"} ] } From 0ad97f27fa46e3bbc3dfa380a918f9fedc27338f Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Mon, 18 Jan 2021 10:36:09 +0100 Subject: [PATCH 018/104] added _Energy and _Time as private, evaluate_EnergyAndTime method (moved from FTEventBuilder --- .../java/org/jlab/rec/ft/trk/FTTRKCross.java | 58 ++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java index 4e401f156c..4d869bd6ad 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java @@ -38,6 +38,9 @@ public class FTTRKCross implements Comparable { private FTTRKCluster _clus1; private FTTRKCluster _clus2; + private float _Energy; + private float _Time; + /** * * @param sector the sector (1) @@ -175,7 +178,22 @@ public static long getSerialversionuid() { return serialVersionUID; } - + public void set_Energy(float energy){ + this._Energy = energy; + } + + public void set_Time(float time){ + this._Time = time; + } + + public float get_Energy(){ + return this._Energy; + } + + public float get_Time(){ + return this._Time; + } + /** * Sorts crosses by azimuth angle values */ @@ -321,9 +339,45 @@ public void set_CrossParams() { this.set_Point(error); this.set_PointErr(error); } + + this.evaluate_EnergyAndTime(); } - + public void evaluate_EnergyAndTime(){ + FTTRKCluster cl1 = this._clus1; + FTTRKCluster cl2 = this._clus2; + int idCl1 = cl1.get_CId(); + int idCl2 = cl2.get_CId(); + double meanEnergy = -9999.; + double meanTime = -9999.; + double timeCross1 = 0., timeCross2 = 0.; + int det; + int layer = cl1.get_Layer(); + if(layer==1 || layer==2){ + det = 0; + }else if(layer==3 || layer ==4){ + det = 1; + } + meanEnergy = Math.sqrt(cl1.get_TotalEnergy() * cl2.get_TotalEnergy()); + this.set_Energy((float)meanEnergy); + +// to determine the time associated with the cross, the times of each hit forming each cluster must be retrieved + // loop on strips of each cluster + int nHits1 = cl1.size(); + for(int i=0; i Date: Mon, 18 Jan 2021 10:37:59 +0100 Subject: [PATCH 019/104] change FTTRK::crosses bank readout (new float variables energy and time) --- .../java/org/jlab/rec/ft/trk/FTTRKReconstruction.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index b9bf1917dc..ea3d494987 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -511,8 +511,10 @@ public void writeHipoBanks(DataEvent event, List hits, List hits, List Date: Mon, 18 Jan 2021 10:39:06 +0100 Subject: [PATCH 020/104] move energy and time assigment to crosses to FTTRKCrosses::evaluate_EnergyAndTime --- .../java/org/jlab/rec/ft/FTEventBuilder.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index 35889662e0..b9cbfce42a 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -87,8 +87,8 @@ public List addResponses(DataEvent event, ConstantsManager manager, resp.setSize(bank.getInt("size", i)); // resp.setSize(nrows); resp.setId(bank.getInt("id", i)); - resp.setEnergy(-9999.); - resp.setTime(9999.); + resp.setEnergy(bank.getFloat("energy", i)); + resp.setTime(bank.getFloat("time", i)); resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); if(debugMode>=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); responses.add(resp); @@ -140,8 +140,8 @@ public List addResponses(DataEvent event, ConstantsManager manager, } if (event.hasBank("FTTRK::crosses") == true) { DataBank bank = event.getBank("FTTRK::crosses"); - DataBank bankClust = event.getBank("FTTRK::clusters"); - DataBank bankHits = event.getBank("FTTRK::hits"); + //DataBank bankClust = event.getBank("FTTRK::clusters"); + //DataBank bankHits = event.getBank("FTTRK::hits"); int nrows = bank.rows(); for (int i = 0; i < nrows; i++) { FTResponse resp = new FTResponse("FTTRK"); @@ -150,6 +150,8 @@ public List addResponses(DataEvent event, ConstantsManager manager, resp.setId(bank.getInt("id", i)); // resp.setEnergy(-9999.); // resp.setTime(9999.); + +/* // time and energy correspond to the energies of the clusters associated to the cross int det = bank.getInt("detector", i); int idCl1 = bank.getInt("Cluster1ID", i); @@ -216,8 +218,10 @@ public List addResponses(DataEvent event, ConstantsManager manager, if(nHits2 != 0){timeCross2 /= nHits2;}else{timeCross2 = 9999.;}; meanTime = (timeCross1+timeCross2)/2.; } - resp.setEnergy(meanEnergy); - resp.setTime(meanTime); +*/ + + resp.setEnergy(bank.getFloat("energy", i)); + resp.setTime(bank.getFloat("time", i)); resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); if(debugMode>=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); responses.add(resp); From 4c6f64a463eb70b8384e2978d71c8e0a563790bf Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Mon, 25 Jan 2021 14:49:12 +0100 Subject: [PATCH 021/104] add-ons for plots with magnetic files on; cleanup --- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 60 +++++++++++++------ 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index a72eac79c6..c260b93db7 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -66,10 +66,12 @@ public boolean processDataEvent(DataEvent event) { reco.init(this.getSolenoid()); FTresponses = reco.addResponses(event, this.getConstantsManager(), run); FTparticles = reco.initFTparticles(FTresponses); - reco.matchToTRK(FTresponses, FTparticles); - reco.matchToHODO(FTresponses, FTparticles); - reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo - reco.writeBanks(event, FTparticles); + if(FTparticles.size()>0){ + reco.matchToTRK(FTresponses, FTparticles); + reco.matchToHODO(FTresponses, FTparticles); + reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo + reco.writeBanks(event, FTparticles); + } } return true; } @@ -143,9 +145,7 @@ public static void main(String arg[]){ en.init(); int debugMode = en.getDebugMode(); // String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/elec_nofield_header.evio"; -// EvioSource reader = new EvioSource(); - //String input = "/Users/devita/Work/clas12/simulations/clas12Tags/4.4.0/out.hipo"; - String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_-30.60.120.30_fullAcceptance.hipo"; + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -222,18 +222,15 @@ public static void main(String arg[]){ h109.setTitleX("trk2 phi residual (rad)"); h109.setFillColor(51); -// H1F h202 = new H1F("trk1-trk2 x residual", 100, -.2, .2); H1F h202 = new H1F("trk1 x", 25, 9., 9.4); H1F h1202 = new H1F("trk1 x MC", 25, 9., 9.4); h202.setOptStat(0); h202.setTitleX("trk1 x position (mm)"); -// h202.setTitleY("counts/half strip width (28 um)"); // 14 bins h202.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins h202.setLineColor(3); h202.setFillColor(3); h1202.setLineColor(9); h1202.setFillColor(49); - // H1F h203 = new H1F("trk1-trk2 y residual", 100, -.2, .2); H1F h203 = new H1F("trk2 x", 25, 9., 9.4); H1F h1203 = new H1F("trk2 MC", 25, 9., 9.4); h203.setOptStat(0); @@ -252,7 +249,6 @@ public static void main(String arg[]){ h204.setFillColor(3); h1204.setLineColor(9); h1204.setFillColor(49); - // H1F h203 = new H1F("trk1-trk2 y residual", 100, -.2, .2); H1F h205 = new H1F("trk2 y", 25, 1.4, 1.8); H1F h1205 = new H1F("trk2 y MC", 25, 1.4, 1.8); h205.setOptStat(0); @@ -362,13 +358,8 @@ public static void main(String arg[]){ h1.fill(bank.getDouble("Energy", i)); h2.fill(bank.getDouble("Energy", i) - gen.getParticle("[11]").vector().p()); Vector3D part = new Vector3D(bank.getDouble("Cx", i), bank.getDouble("Cy", i), bank.getDouble("Cz", i)); - /* - h3.fill(gen.getParticle("[11]").vector().p(),Math.toDegrees(part.theta() - gen.getParticle("[11]").theta())); - h4.fill(gen.getParticle("[11]").vector().p(),Math.toDegrees(part.phi() - gen.getParticle("[11]").phi())); - */ h3.fill(Math.toDegrees(part.theta() - gen.getParticle("[11]").theta())); h4.fill(Math.toDegrees(part.phi() - gen.getParticle("[11]").phi())); - h5.fill(bank.getDouble("Time", i)); h6.fill(bank.getDouble("Energy", i), bank.getDouble("Energy", i) - gen.getParticle("[11]").vector().p()); } @@ -459,12 +450,16 @@ public static void main(String arg[]){ for(int ip=0; ip0) System.out.println("MC before swimming in mag field x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + + " z = " + hitMCOnTrk.z()); + // if the magnetic field is on, the coordinates must be swum along a helix + double B = en.getSolenoid(); + if(B!=0.){ + double phi0 = Math.atan2(cy,cx); + double R = Pperp/0.3/B/q*1.e2; // R in cm + double dAlpha = (zt-z0)*(B*q*0.3)/Pz*1.e-2; // deltaZ in meters + double dAlphaDiv = dAlpha/2./Math.PI; // check multiple turns + int nturns = (int)dAlphaDiv; + if(dAlpha>0){ + dAlpha -= nturns*2.*Math.PI; + }else{ + dAlpha += nturns*2.*Math.PI; + } + double xc = -R*Math.sin(phi0); + double yc = R*Math.cos(phi0); + if(R*dAlpha>0){ + hitMCOnTrk.setX(xc + R*(Math.sin(phi0 + dAlpha))); + hitMCOnTrk.setY(yc - R*(Math.cos(phi0 + dAlpha))); + }else{ + System.out.println("check particle/curvature signs"); + } + } + if(debugMode>0) System.out.println("MC after swimming in mag field x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + + " z = " + hitMCOnTrk.z()); + // Montecarlo hit location on first detector middle plane if(det==0) h2000.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); if(det==1) h2001.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); From 31172e146ab0f7d488633a04b4ba65515868810f Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Mon, 25 Jan 2021 14:56:47 +0100 Subject: [PATCH 022/104] initiate FTParticle with leading FTCal hit only; cleanup --- .../java/org/jlab/rec/ft/FTEventBuilder.java | 132 ------------------ 1 file changed, 132 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index b9cbfce42a..104142afd8 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -85,7 +85,6 @@ public List addResponses(DataEvent event, ConstantsManager manager, FTResponse resp = new FTResponse("FTTRK"); resp.setAssociation(-1); resp.setSize(bank.getInt("size", i)); -// resp.setSize(nrows); resp.setId(bank.getInt("id", i)); resp.setEnergy(bank.getFloat("energy", i)); resp.setTime(bank.getFloat("time", i)); @@ -140,86 +139,12 @@ public List addResponses(DataEvent event, ConstantsManager manager, } if (event.hasBank("FTTRK::crosses") == true) { DataBank bank = event.getBank("FTTRK::crosses"); - //DataBank bankClust = event.getBank("FTTRK::clusters"); - //DataBank bankHits = event.getBank("FTTRK::hits"); int nrows = bank.rows(); for (int i = 0; i < nrows; i++) { FTResponse resp = new FTResponse("FTTRK"); resp.setAssociation(-1); resp.setSize(bank.getInt("size", i)); resp.setId(bank.getInt("id", i)); -// resp.setEnergy(-9999.); -// resp.setTime(9999.); - -/* - // time and energy correspond to the energies of the clusters associated to the cross - int det = bank.getInt("detector", i); - int idCl1 = bank.getInt("Cluster1ID", i); - int idCl2 = bank.getInt("Cluster2ID", i); - double meanEnergy = -9999; - double meanTime = -9999; - double enCl1 = 0., enCl2 = 0., timeCross1 = 0., timeCross2 = 0.; - int layer = -1; - if(det==0){ - // find clusters on layers 1 and 2 - for(int j=0; j initFTparticles(List responses) { particles.add(track); responses.get(i).setAssociation(particles.size()-1); } - - if (responses.get(i).getType() == "FTTRK") { - FTParticle track = new FTParticle(i); - track.setCharge(-999); // provisional, one should take care of the nofield case - track.setField(this.solenoidField); - track.setEnergy(responses.get(i).getEnergy()); - track.setPosition(responses.get(i).getPosition()); - track.setDirection(); - double trkTime = responses.get(i).getTime() - responses.get(i).getPosition().mag()/PhysicsConstants.speedOfLight(); - if(trkTime>=0){track.setTime(trkTime);}else{track.setTime(0.);}; - track.setCalorimeterIndex(-1); - track.setHodoscopeIndex(-1); - track.setTrackerIndex(responses.get(i).getId()); - particles.add(track); - responses.get(i).setAssociation(particles.size()-responses.size()); - } } if (debugMode >= 1) { for (int i = 0; i < particles.size(); i++) { @@ -350,47 +259,6 @@ public void matchTRKHits(List responses, List particles) } } } - - /* - // alternative method, keep it provisionally - public void matchTRKCrosses(List responses){ - // check whether the responses on opposite FTTRK detectors can belong to the same track - Point3D origin = new Point3D(0.,0.,0.); - if(this.solenoidField == 0){ - for(int i=0; ii; j--){ - FTResponse resp2 = responses.get(j); - if(resp2.getType() == "FTTRK" && resp2.getSector()==1){ - Line3D line2 = new Line3D(origin, resp2.getPosition().toPoint3D()); - // check the distance of the lines at the z coordinate of the second hit - double x2 = resp2.getPosition().toPoint3D().x(); - double y2 = resp2.getPosition().toPoint3D().y(); - double z2 = resp2.getPosition().toPoint3D().z(); - double t = line1.direction().z()/z2; - double x1 = line1.direction().x() * t; - double y1 = line1.direction().y() * t; - Line3D diff = new Line3D(x1, y1, z2, x2, y2, z2); - double distance = diff.length(); - // if distance is small than a given tolerance, validate both the responses - double FTTRK_DISTANCE_TOLERANCE = 0.1; // cm - if(distance < FTTRK_DISTANCE_TOLERANCE){ - responses.get(i).setAssociation(2); - responses.get(j).setAssociation(2); - } - } - } - } - - } - } - } - */ public void showResponses(List responses) { System.out.println("\nFound " + responses.size() + " clusters in FT detector"); From 2d8f0082c752e24df3b88248bbba6c6af3645ff0 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Mon, 25 Jan 2021 15:02:53 +0100 Subject: [PATCH 023/104] force matching with initiating FTCal hit; cleanup --- .../ft/src/main/java/org/jlab/rec/ft/FTParticle.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index c1218a256a..24e038f863 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -159,14 +159,12 @@ public int getDetectorHit(List hitList, String detectorType, double // System.out.println(" LOOP = " + loop + " distance = " + hitdistance); // if(timedistance0){ if(hitdistance>distanceThreshold) inTolerance=false; } - if(this.getTrackerIndex()>0){ - if(hitdistance>FTConstants.TRK0_TRK1_DISTANCE_MATCHING) inTolerance = false; - } if(inTolerance && hitdistance Date: Mon, 25 Jan 2021 15:09:14 +0100 Subject: [PATCH 024/104] cleanup --- .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java index 1805820f3c..77fc8150fe 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java @@ -123,24 +123,8 @@ public static void main (String arg[]) { int debug = FTTRKReconstruction.debugMode; FTTRKEngine trk = new FTTRKEngine(); trk.init(); -// String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/out.hipo"; -// String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/out_allTracks.hipo"; -// String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/out_largeCoverage.hipo"; -// String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/out_noMagField_oldGeo.hipo"; -// String input = "/home/filippi/clas/ForwardTracker/DATA/out_electrons2.5GeV_3degTheta_10degPhi.hipo"; -//// String input = "/home/filippi/clas/gemc/electronGun/gemc.hipo"; -// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_new.hipo"; -// String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/out_realGeo_noMagField.data"; -// String input = "/home/filippi/clas/ForwardTracker/DATA/out_realGeo_noMagField.data"; -// String input = "/disk2/Clas/ForwardTrackerReconstruction/DATA/clas_004013.evio.111.hipo"; -// String input = "/home/filippi/clas/ForwardTracker/out_allTracks.hipo"; -// String input = "/home/filippi/clas/ForwardTracker/out.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_0.90.0.90.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_0.90.0.90_spread1mdeg.hipo"; - String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_-30.60.120.30_circle.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_0.90.0.90_fullAcceptance.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-coatjava6.5.8/gemc_singleEle_nofields_big_-30.60.120.30_fullAcceptance.hipo"; + // insert input filename here + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; System.out.println("input file " + input); HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -190,8 +174,6 @@ public static void main (String arg[]) { H2F hHitL1 = new H2F("hHitL1","cross y vs x detector 1", 100, -lim, lim, 100, -lim, lim); H2F hHitL2 = new H2F("hHitL2","cross y vs x detector 2", 100, -lim, lim, 100, -lim, lim); H2F hHitMatch = new H2F("hHitL2","cross y vs x match", 100, -lim, lim, 100, -lim, lim); -// H2F hHitL3 = new H2F("hHitL3","hit y vs x layer 3", 100, -13., 13., 100, -13., 13.); -// H2F hHitL4 = new H2F("hHitL4","hit y vs x layer 4", 100, -13., 13., 100, -13., 13.); hHitL1.setTitleX("x cross detector 1"); hHitL1.setTitleY("y cross detector 1"); hHitL2.setTitleX("x cross detector 2"); hHitL2.setTitleY("y cross detector 2"); hHitMatch.setTitleX("x cross detector match"); hHitMatch.setTitleY("y cross detector match"); @@ -308,9 +290,7 @@ public static void main (String arg[]) { " total mean energy of the cluster " + singleCluster.get_TotalEnergy()); segment[nStripsInClusters] = new DataLine(seg.origin().x(), seg.origin().y(), seg.end().x(), seg.end().y()); int lay = singleCluster.get_Layer(); - // lay = singleCluster.get(j).get_Layer(); segment[nStripsInClusters].setLineColor(lay); - // canvasCl.cd(1); canvasCl.draw(hHitL1); if(debug>=1) System.out.println("nStripsInCluster " + nStripsInClusters); canvasCl.draw(segment[nStripsInClusters]); h1clEn.fill(singleCluster.get_TotalEnergy()); @@ -377,7 +357,6 @@ public static void main (String arg[]) { double diffRadTolerance = 0.5; double diffPhiTolerance = 1.; double thetaTolerance = 0.05; -// if(minDistance < distTolerance) { if(iBest>-1 && jBest>-1){ double r1 = Math.sqrt(x[iBest]*x[iBest]+y[iBest]*y[iBest]); double r2 = Math.sqrt(x[jBest]*x[jBest]+y[jBest]*y[jBest]); From 0906cb1a6157ec1e4ec1ee9f9340e634d0fff114 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Wed, 27 Jan 2021 10:52:58 +0100 Subject: [PATCH 025/104] fix in Show() method --- .../ft/src/main/java/org/jlab/rec/ft/FTParticle.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index 24e038f863..a2ae8531a6 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -180,12 +180,8 @@ public int getDetectorHit(List hitList, String detectorType, double return bestIndex; } - public void show() { - String dtype = "xxx"; - if(this.getCalorimeterIndex()>0 && this.getTrackerIndex()<0){dtype = "FTCAL ";}else{dtype = "FTTRK ";} - + public void show() { System.out.println( "FT Particle info " + - " hit in " + dtype + " Charge = "+ this.getCharge() + " E = " + this.getEnergy() + " X = " + this.getPosition().x() + From 97e813d77d6bdb284cdad63851c029251455ceca Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Wed, 27 Jan 2021 10:54:37 +0100 Subject: [PATCH 026/104] fix in correctDirection method --- .../ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index 104142afd8..8ca54c01e2 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -166,7 +166,8 @@ public void correctDirection(List particles, ConstantsManager manage IndexedTable phiCorr = manager.getConstants(run, "/calibration/ft/ftcal/phicorr"); for (int i = 0; i < particles.size(); i++) { FTParticle particle = particles.get(i); - if(particle.getCalorimeterIndex()>-1) particle.setDirection(thetaCorr, phiCorr); +// if(particle.getCalorimeterIndex()>-1) particle.setDirection(thetaCorr, phiCorr); + particle.setDirection(thetaCorr, phiCorr); } } From 8c4750c1012f8406e0c04113365f9750295d4781 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Wed, 27 Jan 2021 15:51:00 +0100 Subject: [PATCH 027/104] restore check on time for FTHODO-FTTRK/FTCAL matching validation --- .../main/java/org/jlab/rec/ft/FTParticle.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index a2ae8531a6..8a0ca4f08f 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -145,7 +145,7 @@ public void setTrackerIndex(int _Cross) { this._Cross = _Cross; } - public int getDetectorHit(List hitList, String detectorType, double distanceThreshold, double timeThresholds){ + public int getDetectorHit(List hitList, String detectorType, double distanceThreshold, double timeThreshold){ Line3D cross = this.getLastCross(); double minimumDistance = 500.0; @@ -156,19 +156,10 @@ public int getDetectorHit(List hitList, String detectorType, double Line3D dist = cross.distance(response.getPosition().toPoint3D()); double hitdistance = dist.length(); double timedistance = Math.abs(this.getTime()-(response.getTime()-response.getPosition().mag()/PhysicsConstants.speedOfLight())); - // System.out.println(" LOOP = " + loop + " distance = " + hitdistance); - // if(timedistance0){ - if(hitdistance>distanceThreshold) inTolerance=false; - } - if(inTolerance && hitdistance-1) { From fe718750e32353328bd225cbf0354e05c8e5795f Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 29 Aug 2021 10:50:36 +0200 Subject: [PATCH 028/104] update constants, improved tuning --- .../java/org/jlab/rec/ft/FTConstants.java | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java index 97e241540d..b5c9c89911 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java @@ -14,15 +14,30 @@ public class FTConstants { public static final int HODO_MIN_CLUSTER_SIZE = 2; // minimum size of hodo clusters for match to calorimeter public static final double CAL_HODO_DISTANCE_MATCHING = 3.0; // matching distance in cm - public static final double CAL_HODO_TIME_MATCHING = 8; // matching time in ns + public static final double CAL_HODO_TIME_MATCHING = 8; // matching time in ns (it was 8) - public static final double CAL_TRK_DISTANCE_MATCHING = 1.5; // matching distance in cm - public static final double CAL_TRK_TIME_MATCHING = 30; // matching time in ns TOBECORRECTED +// public static final double CAL_TRK_DISTANCE_MATCHING = 1.5; // matching distance in cm +// public static final double CAL_TRK_TIME_MATCHING = 30; // matching time in ns TOBECORRECTED + public static final double CAL_TRK_DISTANCE_MATCHING = 3.; // matching distance in cm (it was 3) + public static final double CAL_TRK_TIME_MATCHING = 100; // matching time in ns TOBECORRECTED (it was 300) + + public static final double TRK_MIN_CROSS_NUMBER = 2; // minimum number of crosses to find a line in the tracker - public static final double TRK0_TRK1_DISTANCE_MATCHING = 0.01; // matching distance between FTTRK points in cms - public static final double TOLERANCE_ON_CROSSES_TWO_DETECTORS = 1.; // 1. cm radius tolerance, tune it up - public static final double FTTRKAdcThreshold = 5.; // check minimum threshold for FTTTRK ADCs (18) - public static final double TRK_MIN_CLUS_ENERGY = 0.; // minimum cluster energy to accept a signal cluster (15) - public static final int TRK_MIN_CLUS_SIZE = 0; // minimum cluster size to form crosses (0: no limit on cluster size) +// public static final double TRK0_TRK1_DISTANCE_MATCHING = 0.25; // matching distance between FTTRK points in cms +// public static final double TOLERANCE_ON_CROSSES_TWO_DETECTORS = 0.; // 1. cm radius tolerance, tune it up +// public static final double TRK0_TRK1_RADTOL = 2.5; // max tolerance for TRK0/TRK1 distance (3D) +/// public static final double TRK0_TRK1_RADTOL = 0.5; // max tolerance for TRK0/TRK1 radial distance (2D) +/// public static final double TRK0_TRK1_PHITOL = 0.07; // max tolerance for TRK0/TRK1 phi angular deviation +/// public static final double TRK0_TRK1_THETATOL = 0.07; // max tolerance for TRK0/TRK1 theta angulare deviation + public static final double TRK0_TRK1_RADTOL = 10.; // max tolerance for TRK0/TRK1 radial distance (2D) + public static final double TRK0_TRK1_PHITOL = 1.; // max tolerance for TRK0/TRK1 phi angular deviation + public static final double TRK0_TRK1_THETATOL = 1.; // max tolerance for TRK0/TRK1 theta angulare deviation + + public static final double FTTRKMinAdcThreshold = 18.; // check min threshold for FTTTRK ADCs (18) + public static final double FTTRKMaxAdcThreshold = 1000.; // check max threshold for FTTTRK ADCs (18) + public static final double TRK_MIN_CLUS_ENERGY = 20.; // minimum cluster energy to accept a signal cluster (20) + public static final int TRK_MIN_CLUS_SIZE = 1; // minimum cluster size to form crosses (0: no limit on cluster size) // 2 is very strict + + } From 97eca8312640ccfd5ffe021e705ba549ef6a3140 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 29 Aug 2021 10:51:21 +0200 Subject: [PATCH 029/104] added histos for diagnostics --- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 373 ++++++++++++++---- 1 file changed, 290 insertions(+), 83 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index c260b93db7..c18930da4b 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -17,9 +17,13 @@ import org.jlab.geom.prim.Vector3D; import org.jlab.groot.data.H1F; import org.jlab.groot.data.H2F; +import org.jlab.groot.data.DataLine; import org.jlab.groot.math.F1D; import org.jlab.groot.fitter.DataFitter; import org.jlab.groot.graphics.EmbeddedCanvas; +import org.jlab.groot.base.DatasetAttributes; +import org.jlab.groot.base.GStyle; +import org.jlab.groot.base.TColorPalette; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.io.evio.EvioDataBank; @@ -30,6 +34,7 @@ import org.jlab.rec.ft.hodo.FTHODOEngine; import org.jlab.rec.ft.trk.FTTRKEngine; import org.jlab.rec.ft.trk.FTTRKConstantsLoader; +import org.jlab.rec.ft.trk.FTTRKReconstruction; public class FTEBEngine extends ReconstructionEngine { @@ -69,7 +74,7 @@ public boolean processDataEvent(DataEvent event) { if(FTparticles.size()>0){ reco.matchToTRK(FTresponses, FTparticles); reco.matchToHODO(FTresponses, FTparticles); - reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo +// reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo reco.writeBanks(event, FTparticles); } } @@ -132,6 +137,30 @@ public void setSolenoid(double Solenoid) { public int getDebugMode() { return this.reco.debugMode; } + + public static H1F h500 = new H1F("Time Difference FTCAL-response", 100, 0., 200.); + public static H1F h501 = new H1F("Cross Energy TRK0", 100, 0., 2000.); + public static H1F h502 = new H1F("Cross Energy TRK1", 100, 0., 2000.); + public static H1F h503 = new H1F("Cross time TRK0", 100, 0.0, 500.); + public static H1F h504 = new H1F("Cross time TRK1", 100, 0.0, 500.); + public static H2F h505 = new H2F("Cross energy vs time TRK0", 100, 0.0, 500., 100, 0., 2000.); + public static H2F h506 = new H2F("Cross energy vs time TRK1", 100, 0.0, 500., 100, 0., 2000.); + public static H2F h507 = new H2F("Cross energy vs time TRK0+1", 100, 0.0, 500., 100, 0., 2000.); + public static H2F h510 = new H2F("Clusters total energies TRK0", 100, 0., 2000., 100, 0., 2000.); + public static H2F h511 = new H2F("Clusters total energies TRK1", 100, 0., 2000., 100, 0., 2000.); + public static H1F h512 = new H1F("Clusters total energies TRK0", 100, 0., 2000.); + public static H1F h513 = new H1F("Clusters total energies TRK1", 100, 0., 2000.); + public static H1F h520 = new H1F("Time of strips in cluster1 TRK0", 100, 0., 500.); + public static H1F h521 = new H1F("Time of strips in cluster2 TRK0", 100, 0., 500.); + public static H1F h522 = new H1F("time of strips in cluster1 TRK1", 100, 0., 500.); + public static H1F h523 = new H1F("Time of strips in cluster2 TRK1", 100, 0., 500.); + + + public static H1F h600 = new H1F("TRK response position", 100, 5.93, 6.03); + public static H2F h601 = new H2F("TRK tof vs time", 100, 0., 500., 100, 5.93, 6.03); + public static H1F h602 = new H1F("cross0 time", 100, 0.0001, 500.); + public static H1F h603 = new H1F("cross1 time", 100, 0.0001, 500.); + public static void main(String arg[]){ @@ -145,22 +174,28 @@ public static void main(String arg[]){ en.init(); int debugMode = en.getDebugMode(); // String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/elec_nofield_header.evio"; - String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30_fullAcceptance.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_withFields_big_-30.60.120.30.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_dis.hipo"; + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; HipoDataSource reader = new HipoDataSource(); reader.open(input); // initialize histos H1F h1 = new H1F("Cluster Energy", 100, 0., 8.); - h1.setOptStat(Integer.parseInt("1111")); + h1.setOptStat(Integer.parseInt("11111")); h1.setTitleX("Cluster Energy (GeV)"); H1F h2 = new H1F("Energy Resolution", 100, -1, 1); - h2.setOptStat(Integer.parseInt("1111")); + h2.setOptStat(Integer.parseInt("11111")); h2.setTitleX("Energy Resolution(GeV)"); H1F h3 = new H1F("Theta Resolution", 100, -1, 1); - h3.setOptStat(Integer.parseInt("1111")); + h3.setOptStat(Integer.parseInt("11111")); h3.setTitleX("Theta Resolution(deg)"); H1F h4 = new H1F("Phi Resolution", 100, -10, 10); - h4.setOptStat(Integer.parseInt("1111")); + h4.setOptStat(Integer.parseInt("11111")); h4.setTitleX("Phi Resolution(deg)"); H1F h5 = new H1F("Time Resolution", 100, -2, 2); @@ -169,9 +204,9 @@ public static void main(String arg[]){ H2F h6 = new H2F("Cluster Energy", 24, -180., 180., 24, -180., 180.); h6.setTitleX("x (cm)"); h6.setTitleY("y (cm)"); - H2F h7 = new H2F("N. Clusters", 24, -180., 180., 24, -180., 180.); - h7.setTitleX("x (cm)"); - h7.setTitleY("y (cm)"); + H2F h7 = new H2F("N. Clusters", 24, -18., 18., 24, -18., 18.); + h7.setTitleX("x (mm)"); + h7.setTitleY("y (mm)"); H2F h8 = new H2F("Cluster Energy", 100, 0., 9., 100, -0.5, 0.5); h8.setTitleX("E (GeV)"); h8.setTitleY("Energy Resolution(GeV)"); @@ -183,47 +218,59 @@ public static void main(String arg[]){ h10.setTitleY("Energy Resolution(GeV)"); // residual plots (of TRK wrt tracking on ECAL - black histograms) - H2F h100 = new H2F("Cross on trk layer1", 100, -15., 15., 100, -15., 15.); + H2F h100 = new H2F("Cross on trk layer1", 100, -18., 18., 100, -18., 18.); + h100.setTitleX("x (mm) trk1"); + h100.setTitleY("y (mm) trk1"); + H2F h101 = new H2F("Cross on trk layer2", 100, -18., 18., 100, -18., 18.); + h101.setTitleX("x (mm) trk2"); + h101.setTitleY("y (mm) trk2"); + H2F h700 = new H2F("Strips on trk layer1", 100, -18., 18., 100, -18., 18.); h100.setTitleX("x (mm) trk1"); h100.setTitleY("y (mm) trk1"); - H2F h101 = new H2F("Cross on trk layer2", 100, -15., 15., 100, -15., 15.); + H2F h701 = new H2F("Strips on trk layer2", 100, -18., 18., 100, -18., 18.); h101.setTitleX("x (mm) trk2"); h101.setTitleY("y (mm) trk2"); - H1F h102 = new H1F("trk1 x residual", 63, -.5, .5); - h102.setOptStat(0); + + double limTC = 4.; // for MC 0.05 is ok + H1F h102 = new H1F("trk1 x residual", 63, -limTC, limTC); + h102.setOptStat(10); h102.setTitleX("trk1 x residual (mm)"); h102.setFillColor(1); - H1F h103 = new H1F("trk2 x residual", 63, -.5, .5); - h103.setOptStat(0); + H1F h103 = new H1F("trk2 x residual", 63, -limTC, limTC); + h103.setOptStat(10); h103.setFillColor(51); h103.setTitleX("trk2 x residual (mm)"); - H1F h104 = new H1F("trk1 y residual", 63, -.5, .5); + H1F h104 = new H1F("trk1 y residual", 63, -limTC, limTC); h104.setOptStat(Integer.parseInt("0")); h104.setFillColor(1); h104.setTitleX("trk1 y residual (mm)"); - H1F h105 = new H1F("trk2 y residual;", 63, -.5, .5); - h105.setOptStat(0); + H1F h105 = new H1F("trk2 y residual;", 63, -limTC, limTC); + h105.setOptStat(10); h105.setTitleX("trk2 y residual (mm)"); h105.setFillColor(51); - H1F h106 = new H1F("trk1 theta residual (rad)", 100, -0.005, 0.005); - h106.setOptStat(0); + double limTCTheta = 0.05; + double limTCPhi = 1.; + H1F h106 = new H1F("trk1 theta residual (rad)", 100, -limTCTheta, limTCTheta); + h106.setOptStat(10); h106.setTitleX("trk1 theta residual (rad)"); h106.setFillColor(1); - H1F h107 = new H1F("trk2 theta residual (rad)", 100, -0.005, 0.005); + H1F h107 = new H1F("trk2 theta residual (rad)", 100, -limTCTheta, limTCTheta); h107.setOptStat(Integer.parseInt("0")); h107.setTitleX("trk2 theta residual (rad)"); h107.setFillColor(51); - H1F h108 = new H1F("trk1 phi residual (rad)", 100, -.05, .05); + H1F h108 = new H1F("trk1 phi residual (rad)", 100, -limTCPhi, limTCPhi); h108.setOptStat(0); h108.setTitleX("trk1 phi residual"); h108.setFillColor(1); - H1F h109 = new H1F("trk2 phi residual (rad)", 100, -.05, .05); - h109.setOptStat(0); + H1F h109 = new H1F("trk2 phi residual (rad)", 100, -limTCPhi, limTCPhi); + h109.setOptStat(10); h109.setTitleX("trk2 phi residual (rad)"); h109.setFillColor(51); - H1F h202 = new H1F("trk1 x", 25, 9., 9.4); - H1F h1202 = new H1F("trk1 x MC", 25, 9., 9.4); +// H1F h202 = new H1F("trk1 x", 25, 9., 9.4); +// H1F h1202 = new H1F("trk1 x MC", 25, 9., 9.4); + H1F h202 = new H1F("trk1 x", 25, 8.2, 9.0); + H1F h1202 = new H1F("trk1 x MC", 25, 8.2, 9.0); h202.setOptStat(0); h202.setTitleX("trk1 x position (mm)"); h202.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins @@ -231,8 +278,10 @@ public static void main(String arg[]){ h202.setFillColor(3); h1202.setLineColor(9); h1202.setFillColor(49); - H1F h203 = new H1F("trk2 x", 25, 9., 9.4); - H1F h1203 = new H1F("trk2 MC", 25, 9., 9.4); +// H1F h203 = new H1F("trk2 x", 25, 9., 9.4); +// H1F h1203 = new H1F("trk2 MC", 25, 9., 9.4); + H1F h203 = new H1F("trk2 x", 25, 8.2, 9.0); + H1F h1203 = new H1F("trk2 MC", 25, 8.2, 9.0); h203.setOptStat(0); h203.setTitleX("trk2 x position (mm)"); h203.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins @@ -240,8 +289,10 @@ public static void main(String arg[]){ h203.setFillColor(3); h1203.setLineColor(9); h1203.setFillColor(49); - H1F h204 = new H1F("trk1 y", 25, 1.4, 1.8); - H1F h1204 = new H1F("trk1 y MC", 25, 1.4, 1.8); +// H1F h204 = new H1F("trk1 y", 25, 1.4, 1.8); +// H1F h1204 = new H1F("trk1 y MC", 25, 1.4, 1.8); + H1F h204 = new H1F("trk1 y", 25, 2.4, 4.0); + H1F h1204 = new H1F("trk1 y MC", 25, 2.4, 4.0); h204.setOptStat(0); h204.setTitleX("trk1 y position (mm)"); h204.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins @@ -249,8 +300,10 @@ public static void main(String arg[]){ h204.setFillColor(3); h1204.setLineColor(9); h1204.setFillColor(49); - H1F h205 = new H1F("trk2 y", 25, 1.4, 1.8); - H1F h1205 = new H1F("trk2 y MC", 25, 1.4, 1.8); +// H1F h205 = new H1F("trk2 y", 25, 1.4, 1.8); +// H1F h1205 = new H1F("trk2 y MC", 25, 1.4, 1.8); + H1F h205 = new H1F("trk2 y", 25, 2.4, 4.0); + H1F h1205 = new H1F("trk2 y MC", 25, 2.4, 4.0); h205.setOptStat(0); h205.setTitleX("trk2 y position (mm)"); h205.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins @@ -260,10 +313,10 @@ public static void main(String arg[]){ h1205.setFillColor(49); // resolution plots (of TRK wrt MC truth - red histograms) - H2F h1100 = new H2F("Cross on trk layer1 MC truth", 100, -15., 15., 100, -15., 15.); + H2F h1100 = new H2F("Cross on trk layer1 MC truth", 100, -18., 18., 100, -18., 18.); h1100.setTitleX("x (mm) trk1"); h1100.setTitleY("y (mm) trk1"); - H2F h1101 = new H2F("Cross on trk layer2 MC truth", 100, -15., 15., 100, -15., 15.); + H2F h1101 = new H2F("Cross on trk layer2 MC truth", 100, -18., 18., 100, -18., 18.); h1101.setTitleX("x (mm) trk2"); h1101.setTitleY("y (mm) trk2"); int binres = 35; @@ -337,16 +390,24 @@ public static void main(String arg[]){ H2F h2001 = new H2F("Montecarlo radiography at second FTTRK det", 100, -15., 15., 100, -15, 15.); h2001.setTitleX("x (mm)"); h2001.setTitleY("y (mm)"); - - int nev = -1; + + JFrame frameCALTRK = new JFrame("radiography FTCAL hits and FTTRK Crosses"); + frameCALTRK.setSize(1500,500); + EmbeddedCanvas canvasCALTRK = new EmbeddedCanvas(); + canvasCALTRK.divide(3,1); + + int nev = 0; int nevWithCrosses = 0; while (reader.hasEvent()) { // run over all events -// int nev1 = 0; int nev2 = 5; for(nev=nev1; nev0) { // track candidate through calorimeter h1.fill(bank.getFloat("energy", i)); - h2.fill(bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); Vector3D part = new Vector3D(bank.getFloat("cx", i), bank.getFloat("cy", i), bank.getFloat("cz", i)); - h3.fill(gen.getGeneratedParticle(0).vector().p(),Math.toDegrees(part.theta() - gen.getGeneratedParticle(0).theta())); - h4.fill(gen.getGeneratedParticle(0).vector().p(),Math.toDegrees(part.phi() - gen.getGeneratedParticle(0).phi())); - h5.fill(bank.getFloat("time", i) - 124.25); - h6.fill(bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); - h7.fill(bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS); - h8.fill(gen.getGeneratedParticle(0).vector().p(), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); - h9.fill(Math.toDegrees(gen.getGeneratedParticle(0).theta()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); - h10.fill(Math.toDegrees(gen.getGeneratedParticle(0).phi()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); - + h5.fill(bank.getFloat("time", i) - 124.25); // simulation + h7.fill((bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS)/10., (bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS)/10.); + if(gen.countGenerated() != 0){ + h2.fill(bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h3.fill(gen.getGeneratedParticle(0).vector().p(),Math.toDegrees(part.theta() - gen.getGeneratedParticle(0).theta())); + h4.fill(gen.getGeneratedParticle(0).vector().p(),Math.toDegrees(part.phi() - gen.getGeneratedParticle(0).phi())); + h6.fill(bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h8.fill(gen.getGeneratedParticle(0).vector().p(), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h9.fill(Math.toDegrees(gen.getGeneratedParticle(0).theta()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h10.fill(Math.toDegrees(gen.getGeneratedParticle(0).phi()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + } + // check match with trk bank (entry trkID) int trkID = bank.getShort("trkID", i); - if(trkID >= 0){ + if(trkID > 0){ // accept all fired strips if trkID >-1, only hits connected with a track if >0 // loop on crosses bank DataBank banktrk = event.getBank("FTTRK::crosses"); int ncrosses = banktrk.rows(); @@ -400,10 +465,43 @@ public static void main(String arg[]){ float yt = banktrk.getFloat("y", nc); float zt = banktrk.getFloat("z", nc); Vector3D hitOnTrk = new Vector3D(xt, yt, zt); + // extract information on the crossed strips + + float icl1 = banktrk.getFloat("energy", nc); // Cluster1ID provisional to be changed + float icl2 = banktrk.getFloat("time", nc); // cluster2ID provisional to be changes + DataBank bankcl = event.getBank("FTTRK::clusters"); + DataLine segment1 = new DataLine(); + DataLine segment2 = new DataLine(); + if(bankcl.rows()>0){ + segment1.setOrigin(0.,0.); segment1.setEnd(0.,0.); + segment2.setOrigin(0.,0.); segment2.setEnd(0.,0.); + int seed1 = bankcl.getInt("seed", (int)icl1); + int seed2 = bankcl.getInt("seed", (int)icl2); + int lay1 = bankcl.getInt("layer", (int)icl1); + int lay2 = bankcl.getInt("layer", (int)icl2); + System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ seed1, seed2 " + seed1 + " " + seed2 + " layer1 layer2 " + lay1 + " " + lay2); + System.out.println("~~~~~~~~~~ hit strip 1: " + seed1 + " layer " + lay1 + " sector " + + FTTRKReconstruction.findSector(seed1)); + System.out.println("~~~~~~~~~~ hit strip 2: " + seed2 + " layer " + lay2 + " sector " + + FTTRKReconstruction.findSector(seed2)); + + if(seed1!=0 && seed2!=0){ + Line3D seg1 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay1, seed1); + Line3D seg2 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay2, seed2); + segment1.setOrigin(seg1.origin().x(), seg1.origin().y()); + segment2.setOrigin(seg2.origin().x(), seg2.origin().y()); + segment1.setEnd(seg1.end().x(), seg1.end().y()); + segment2.setEnd(seg2.end().x(), seg2.end().y()); + + } + } + if(det==0){ h100.fill(xt, yt); - if(debugMode>0){ - System.out.println("coodinates on calorimeter " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); + if(debugMode>0){ +// System.out.println("coordinates on calorimeter " + bank.getDouble("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); + System.out.println("coordinates of track on fttrk " + bank.getFloat("cx", i)*zt + " " + + bank.getFloat("cy", i)*zt + " " + bank.getFloat("cz", i)*zt); System.out.println("director cosines hit on calorimeter " + part.x() + " " + part.y() + " " + part.z()); System.out.println("director cosines hit of fttrk " + xt + " " + yt + " " + zt); } @@ -411,13 +509,27 @@ public static void main(String arg[]){ h104.fill(bank.getFloat("cy", i) *zt - yt); h106.fill((part.theta() - hitOnTrk.theta())); h108.fill((part.phi() - hitOnTrk.phi())); + + canvasCALTRK.cd(0); + segment1.setLineColor(1); + segment2.setLineColor(2); + canvasCALTRK.draw(segment1); + canvasCALTRK.draw(segment2); + }else if(det==1){ h101.fill(xt, yt); h103.fill(bank.getFloat("cx", i) *zt - xt); h105.fill(bank.getFloat("cy", i) *zt - yt); h107.fill((part.theta() - hitOnTrk.theta())); h109.fill((part.phi() - hitOnTrk.phi())); + + canvasCALTRK.cd(1); + segment1.setLineColor(3); + segment2.setLineColor(4); + canvasCALTRK.draw(segment1); + canvasCALTRK.draw(segment2); } + } } if(ncrosses==2){ @@ -450,7 +562,9 @@ public static void main(String arg[]){ for(int ip=0; ip0) System.out.println("------- generated particle n " + ip + " type: " + gen.getGeneratedParticle(ip).pid() + " mass " + mass); + double P = gen.getGeneratedParticle(ip).p(); double cx = gen.getGeneratedParticle(ip).px()/P; double cy = gen.getGeneratedParticle(ip).py()/P; double cz = gen.getGeneratedParticle(ip).pz()/P; @@ -473,31 +587,60 @@ public static void main(String arg[]){ } double t = (zt - z0)/cz; Vector3D hitOnTrk = new Vector3D(xt, yt, zt); - Vector3D hitMCOnTrk = new Vector3D(x0+cx*t, y0+cy*t, zt); + Vector3D hitMCOnTrk = new Vector3D(x0+cx*t, y0+cy*t, zt); // straight line - if(debugMode>0) System.out.println("MC before swimming in mag field x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + + if(debugMode>0) System.out.println("MC on the straight line x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + " z = " + hitMCOnTrk.z()); // if the magnetic field is on, the coordinates must be swum along a helix double B = en.getSolenoid(); if(B!=0.){ +// Pperp /= P; +// Pz /= P; +// B *= 2.; // perche'? da cosa deriva questo 2? + // find the crossing point of the helix and a xy plane at given z, where the magneti field stops + double zStop = 100.0; // provisional fix it to 1 meter double phi0 = Math.atan2(cy,cx); double R = Pperp/0.3/B/q*1.e2; // R in cm - double dAlpha = (zt-z0)*(B*q*0.3)/Pz*1.e-2; // deltaZ in meters - double dAlphaDiv = dAlpha/2./Math.PI; // check multiple turns - int nturns = (int)dAlphaDiv; + //double dAlpha = (zt-z0)*(B*q*0.3)/Pz*1.e-2; // deltaZ in meters + double dAlpha = (zStop-z0)*(B*q*0.3)/Pz*1.e-2; // deltaZ in meters + int nturns = (int) Math.floor(dAlpha/2./Math.PI); // number of full turns if(dAlpha>0){ dAlpha -= nturns*2.*Math.PI; }else{ dAlpha += nturns*2.*Math.PI; } - double xc = -R*Math.sin(phi0); + + double xc = R*Math.sin(phi0); double yc = R*Math.cos(phi0); + Vector3D hitOnPlane = new Vector3D(); + Vector3D tangentAtZstop = new Vector3D(); if(R*dAlpha>0){ - hitMCOnTrk.setX(xc + R*(Math.sin(phi0 + dAlpha))); - hitMCOnTrk.setY(yc - R*(Math.cos(phi0 + dAlpha))); + hitOnPlane.setX(-xc + R*(Math.sin(phi0 + dAlpha))); + hitOnPlane.setY( yc - R*(Math.cos(phi0 + dAlpha))); + hitOnPlane.setZ(zStop); + double gamma = Math.atan2(hitOnPlane.y(),hitOnPlane.x()); + double vx1 = Pperp/P*Math.sin(gamma); + double vy1 = Pperp/P*Math.cos(gamma); + double vz1 = Math.sqrt(1. - vx1*vx1 + vy1*vy1); + double t1 = (zt - hitOnPlane.z())/vz1; + hitMCOnTrk.setXYZ(hitOnPlane.x()+vx1*t1, hitOnPlane.y()+vy1*t1, zt); }else{ System.out.println("check particle/curvature signs"); } + // find the direction of the tanget vector at the + + + + + /* + // alternative method + double w = B*0.3/q/mass; + t = (zt-z0)*1e-2*mass/Pz; + hitMCOnTrk.setX(x0 + Pperp/mass/w*1.e2 * Math.sin(w*t+phi0) - xc); + hitMCOnTrk.setY(y0 - Pperp/mass/w*1.e2 * Math.cos(w*t+phi0) + yc); + */ + + } if(debugMode>0) System.out.println("MC after swimming in mag field x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + " z = " + hitMCOnTrk.z()); @@ -549,7 +692,7 @@ public static void main(String arg[]){ } } - if(debugMode>0) System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + nevWithCrosses); + if(debugMode>=0) System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + nevWithCrosses); JFrame frame = new JFrame("FT Reconstruction"); frame.setSize(1200, 800); @@ -562,9 +705,22 @@ public static void main(String arg[]){ canvas.cd(2); canvas.draw(h3); canvas.cd(3); - canvas.draw(h4); +// canvas.draw(h4); + h501.setFillColor(3); // green + h502.setFillColor(5); // yellow + h503.setFillColor(8); // dark green + h504.setFillColor(7); // orange + h600.setFillColor(9); // blue violet + h602.setFillColor(3); // green trk0 + h603.setFillColor(5); // yellow trk1 + + canvas.draw(h501); + canvas.draw(h502,"same"); canvas.cd(4); - canvas.draw(h5); + canvas.draw(h503,""); + canvas.draw(h504,"same"); + + for (int i = 0; i < h6.getDataBufferSize(); i++) { float meanE = h6.getDataBufferBin(i); float nE = h7.getDataBufferBin(i); @@ -573,17 +729,23 @@ public static void main(String arg[]){ } } canvas.cd(5); - canvas.draw(h6); +// canvas.draw(h7); + canvas.draw(h507); canvas.cd(6); - canvas.draw(h8); +// canvas.draw(h8); + canvas.draw(h600); canvas.cd(7); - canvas.draw(h9); +// canvas.draw(h9); + canvas.draw(h601); canvas.cd(8); - canvas.draw(h10); +// canvas.draw(h10); + canvas.draw(h602); + canvas.draw(h603,"same"); frame.add(canvas); frame.setLocationRelativeTo(null); frame.setVisible(true); + double narrowFactor = 4.5; JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); frametrk.setSize(1600, 800); EmbeddedCanvas canvastrk = new EmbeddedCanvas(); @@ -592,7 +754,7 @@ public static void main(String arg[]){ canvastrk.draw(h100); canvastrk.cd(1); canvastrk.draw(h102); - F1D f02 = new F1D("f02","[amp]*gaus(x,[mean],[sigma])", -0.5, 0.5); + F1D f02 = new F1D("f02","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); f02.setParameter(0, 10.0); f02.setParameter(1, 0.0); f02.setParameter(2, 1.0); @@ -603,11 +765,11 @@ public static void main(String arg[]){ f02.setParameter(1, f02.parameter(1).value()); f02.setParameter(2, f02.parameter(2).value()); DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma - f02.setOptStat(1111); + f02.setOptStat(11111); canvastrk.draw(f02,"same"); canvastrk.cd(2); canvastrk.draw(h104); - F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -0.5, 0.5); + F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/(narrowFactor+0.2)); f04.setParameter(0, 10.0); f04.setParameter(1, 0.0); f04.setParameter(2, 1.0); @@ -618,11 +780,11 @@ public static void main(String arg[]){ f04.setParameter(1, f04.parameter(1).value()); f04.setParameter(2, f04.parameter(2).value()); DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma - f04.setOptStat(1111); + f04.setOptStat(11111); canvastrk.draw(f04,"same"); canvastrk.cd(3); canvastrk.draw(h106); - F1D f06 = new F1D("f06","[amp]*gaus(x,[mean],[sigma])", -0.002, 0.002); + F1D f06 = new F1D("f06","[amp]*gaus(x,[mean],[sigma])", -limTCTheta/narrowFactor, limTCTheta/narrowFactor); f06.setParameter(0, 10.0); f06.setParameter(1, h106.getMean()); f06.setParameter(2, h106.getRMS()); @@ -633,25 +795,26 @@ public static void main(String arg[]){ f06.setParameter(1, f06.parameter(1).value()); f06.setParameter(2, f06.parameter(2).value()); DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma - f06.setOptStat(1111); + f06.setOptStat(11111); canvastrk.draw(f06,"same"); canvastrk.cd(4); canvastrk.draw(h108); - F1D f08 = new F1D("f08","[amp]*gaus(x,[mean],[sigma])", -0.01, 0.01); + F1D f08 = new F1D("f08","[amp]*gaus(x,[mean],[sigma])", -limTCPhi/narrowFactor, limTCPhi/narrowFactor); f08.setParameter(0, h108.getMax()); f08.setParameter(1, h108.getMean()); f08.setParameter(2, h108.getRMS()); f08.setLineColor(6); f08.setLineWidth(3); DataFitter.fit(f08, h108, "Q"); //No options uses error for sigma - f08.setOptStat(1111); + f08.setOptStat(11111); canvastrk.draw(f08,"same"); canvastrk.cd(5); canvastrk.draw(h101); + canvastrk.cd(6); canvastrk.draw(h103); - F1D f03 = new F1D("f03","[amp]*gaus(x,[mean],[sigma])", -0.5, 0.5); + F1D f03 = new F1D("f03","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); f03.setParameter(0, 10.0); f03.setParameter(1, 0.0); f03.setParameter(2, 1.0); @@ -665,9 +828,10 @@ public static void main(String arg[]){ f03.setOptStat(1111); canvastrk.draw(f03,"same"); + canvastrk.cd(7); canvastrk.draw(h105); - F1D f05 = new F1D("f05","[amp]*gaus(x,[mean],[sigma])", -0.5, 0.5); + F1D f05 = new F1D("f05","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); f05.setParameter(0, 10.0); f05.setParameter(1, 0.0); f05.setParameter(2, 1.0); @@ -683,7 +847,7 @@ public static void main(String arg[]){ canvastrk.cd(8); canvastrk.draw(h107); - F1D f07 = new F1D("f07","[amp]*gaus(x,[mean],[sigma])", -0.002, 0.002); + F1D f07 = new F1D("f07","[amp]*gaus(x,[mean],[sigma])", -limTCTheta/narrowFactor, limTCTheta/narrowFactor); f07.setParameter(0, h107.getMax()); f07.setParameter(1, h107.getMean()); f07.setParameter(2, h107.getRMS()); @@ -695,7 +859,7 @@ public static void main(String arg[]){ canvastrk.cd(9); canvastrk.draw(h109); - F1D f09 = new F1D("f09","[amp]*gaus(x,[mean],[sigma])", -0.01, 0.01); + F1D f09 = new F1D("f09","[amp]*gaus(x,[mean],[sigma])", -limTCPhi/narrowFactor, limTCPhi/narrowFactor); f09.setParameter(0, h109.getMax()); f09.setParameter(1, h109.getMean()); f09.setParameter(2, h109.getRMS()); @@ -907,6 +1071,49 @@ public static void main(String arg[]){ frameMCradio.add(canvasMCradio); frameMCradio.setLocationRelativeTo(null); frameMCradio.setVisible(true); + + canvasCALTRK.cd(0); canvasCALTRK.draw(h100, "same"); canvasCALTRK.draw(h7, "same"); + canvasCALTRK.cd(1); canvasCALTRK.draw(h101, "same"); canvasCALTRK.draw(h7, "same"); + canvasCALTRK.cd(2); canvasCALTRK.draw(h7, "same"); + frameCALTRK.add(canvasCALTRK); + frameCALTRK.setLocationRelativeTo(null); + frameCALTRK.setVisible(true); + + JFrame frameStripET = new JFrame("strip energy and time studies"); + frameStripET.setSize(1500, 1000); + EmbeddedCanvas canvasStripET = new EmbeddedCanvas(); + canvasStripET.divide(4,2); + canvasStripET.cd(0); + canvasStripET.draw(h510); + canvasStripET.cd(1); + canvasStripET.draw(h511); + canvasStripET.cd(2); + h512.setFillColor(53); h513.setFillColor(58); + h512.setOptStat(Integer.parseInt("11")); + h513.setOptStat(Integer.parseInt("11")); + canvasStripET.draw(h512); + canvasStripET.cd(3); + canvasStripET.draw(h513); + + h520.setFillColor(54); h521.setFillColor(59); h522.setFillColor(52); h523.setFillColor(57); + h520.setOptStat(Integer.parseInt("11")); + h521.setOptStat(Integer.parseInt("11")); + h522.setOptStat(Integer.parseInt("11")); + h523.setOptStat(Integer.parseInt("11")); + canvasStripET.cd(4); + canvasStripET.draw(h520); + canvasStripET.cd(5); + canvasStripET.draw(h521); + canvasStripET.cd(6); + canvasStripET.draw(h522); + canvasStripET.cd(7); + canvasStripET.draw(h523); + frameStripET.add(canvasStripET); + frameStripET.setLocationRelativeTo(null); + frameStripET.setVisible(true); + + + } } From b6b35c99840988e678bcfb48077160ed8b5c6a8d Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 29 Aug 2021 10:52:08 +0200 Subject: [PATCH 030/104] updates for FTTRK timing and energy studies --- .../java/org/jlab/rec/ft/FTEventBuilder.java | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index 8ca54c01e2..418feaf9ba 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -14,6 +14,7 @@ import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Vector3D; import org.jlab.geom.prim.Point3D; +import org.jlab.rec.ft.trk.FTTRKReconstruction; public class FTEventBuilder { @@ -147,6 +148,10 @@ public List addResponses(DataEvent event, ConstantsManager manager, resp.setId(bank.getInt("id", i)); resp.setEnergy(bank.getFloat("energy", i)); resp.setTime(bank.getFloat("time", i)); + ////////////////////////////// provisional + resp.setCrEnergy(FTTRKReconstruction.crEnergy[i]); + resp.setCrTime(FTTRKReconstruction.crTime[i]); + ////////////////////////////// resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); if(debugMode>=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); responses.add(resp); @@ -238,7 +243,40 @@ public void matchToTRK(List responses, List particles) { if (debugMode >= 1) track.show(); } } - + + + public void matchToFTCal(List responses, List particles) { + for (int i = 0; i < particles.size(); i++) { + FTParticle track = particles.get(i); + + int iHodo = track.getDetectorHit(responses, "FTHODO", FTConstants.CAL_HODO_DISTANCE_MATCHING, FTConstants.CAL_HODO_TIME_MATCHING); + if (iHodo > 0) { + if (debugMode >= 1) { + System.out.println("found signal in the hodoscope " + iHodo); + } + track.setCharge(-1); + track.setHodoscopeIndex(responses.get(iHodo).getId()); + responses.get(iHodo).setAssociation(i); + } + + int iTrk = track.getDetectorHit(responses, "FTTRK", FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); + if (iTrk > 0) { + if (debugMode >= 1) { + System.out.println("found signal in FTTRK" + iTrk); + } + track.setCharge(-999); // provisional, for no field tracking + track.setTrackerIndex(responses.get(iTrk).getId()); + responses.get(iTrk).setAssociation(i); + } + + if (debugMode >= 1) track.show(); + + } + } + + +/* + // version to match FTTRK hits ony, to be dropped public void matchTRKHits(List responses, List particles) { for (int i = 0; i < particles.size(); i++) { FTParticle track = particles.get(i); @@ -260,6 +298,7 @@ public void matchTRKHits(List responses, List particles) } } } +*/ public void showResponses(List responses) { System.out.println("\nFound " + responses.size() + " clusters in FT detector"); From b483311296b624cca250c7913b540b551b05bec3 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 29 Aug 2021 10:52:29 +0200 Subject: [PATCH 031/104] updates for FTTRK timing and energy studies --- .../main/java/org/jlab/rec/ft/FTParticle.java | 36 +++++++++++++++---- .../main/java/org/jlab/rec/ft/FTResponse.java | 17 +++++++++ 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index 8a0ca4f08f..1074990732 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -5,7 +5,7 @@ import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Vector3D; import org.jlab.utils.groups.IndexedTable; - +import org.jlab.rec.ft.FTEBEngine; public class FTParticle { @@ -155,11 +155,35 @@ public int getDetectorHit(List hitList, String detectorType, double if(response.getAssociation()<0 && response.getType() == detectorType){ Line3D dist = cross.distance(response.getPosition().toPoint3D()); double hitdistance = dist.length(); - double timedistance = Math.abs(this.getTime()-(response.getTime()-response.getPosition().mag()/PhysicsConstants.speedOfLight())); - if(timedistance-1) { diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java index de895f340a..24059b2c92 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java @@ -17,6 +17,8 @@ public class FTResponse extends DetectorResponse { private int _size; // cluster multiplicity private int _id; // response ID + private float _crTime; // provisional: detector time (for crosses only: the location in the bank is overwritten) + private float _crEnergy; // provisional: detector energy (for crosses only same reason) public FTResponse() { @@ -50,6 +52,21 @@ public void setId(int id) { this._id = id; } + /////////////////////////// provisional (info must be present in banks) + public void setCrTime(float crTime){ + this._crTime = crTime; + } + public float getCrTime(){ + return _crTime; + } + public void setCrEnergy(float crEnergy){ + this._crEnergy = crEnergy; + } + public float getCrEnergy(){ + return _crEnergy; + } + ////////////////////////// + public void show() { System.out.println("ID = "+ this.getId() + " Type = " + this.getType() From ba1b66a88778a29877f9414355a6954177be8788 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 29 Aug 2021 10:52:51 +0200 Subject: [PATCH 032/104] added histos for diagnostics --- .../java/org/jlab/rec/ft/cal/FTCALEngine.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java index 04e6f1b59e..beab6173c1 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java @@ -98,7 +98,8 @@ public static void main (String arg[]) { cal.init(); // String input = "/Users/devita/Work/clas12/simulations/clas12Tags/4.4.0/out.hipo"; // String input = "/home/filippi/clas/ForwardTracker/DATA/out_realGeo_noMagField.data"; - String input = "/home/filippi/clas/gemc/electronGun/gemc.hipo"; +// String input = "/home/filippi/clas/gemc/electronGun/gemc.hipo"; + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; HipoDataSource reader = new HipoDataSource(); // String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/out_header.ev"; // EvioSource reader = new EvioSource(); @@ -113,12 +114,14 @@ public static void main (String arg[]) { h3.setOptStat(Integer.parseInt("1111")); h3.setTitleX("Theta Resolution(deg)"); H1F h4 = new H1F("Phi Resolution",100, -10, 10); h4.setOptStat(Integer.parseInt("1111")); h4.setTitleX("Phi Resolution(deg)"); - H1F h5 = new H1F("Time Resolution",100, -10, 10); +// H1F h5 = new H1F("Time Resolution",100, -10, 10); + H1F h5 = new H1F("Time Resolution",100, -100, 300); h5.setOptStat(Integer.parseInt("1111")); h5.setTitleX("Time Resolution(ns)"); H2F h6 = new H2F("cluster xy", 100, -15., 15., 100, -15., 15.); h6.setTitleX("cluster x"); h6.setTitleY("cluster y"); while(reader.hasEvent()){ +// for(int nev=0; nev<2; nev++){ DataEvent event = (DataEvent) reader.getNextEvent(); cal.processDataEvent(event); @@ -145,14 +148,17 @@ public static void main (String arg[]) { int nrows = bank.rows(); for(int i=0; i Date: Sun, 29 Aug 2021 10:53:50 +0200 Subject: [PATCH 033/104] single crystal selection --- .../jlab/rec/ft/cal/FTCALReconstruction.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java index 341a8e1bf7..e272c7c82c 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java @@ -268,7 +268,38 @@ public List readRawHitsHipo(DataEvent event, IndexedTable charge2Energ float time = bankDGTZ.getFloat("time",row); if(adc!=-1 && time!=-1){ FTCALHit hit = new FTCALHit(row,icomponent, adc, time, charge2Energy, timeOffsets, timeWalk, cluster); - hits.add(hit); +// if(icomponent>=90 && icomponent<=98) hits.add(hit); // select only crystals in a given region +// if(icomponent>= 90 && icomponent<=107) +// if(icomponent == 92) +// if(icomponent == 105) +// if(icomponent == 400) +// if(icomponent == 412) +// select one vertical stip of crystals left of the hole +// if(icomponent == 472 || icomponent == 450 || icomponent == 428 || icomponent == 406 || icomponent == 384 || +// icomponent == 362 || icomponent == 340) +// select one vertical strip of crystals right of the hole +// if(icomponent == 473 || icomponent == 451 || icomponent == 429 || icomponent == 407 || icomponent == 385 || +// icomponent == 363 || icomponent == 341) +// if(icomponent == 454 || icomponent == 432 || icomponent == 410 || icomponent == 388 || icomponent == 366 || +// icomponent == 344 || icomponent == 322 || icomponent == 300) +// if(icomponent == 402 || icomponent == 401 || icomponent == 400 || icomponent == 380 || icomponent == 379 || +// icomponent == 378 || icomponent == 358 || icomponent == 357 || icomponent == 356) +// if(icomponent == 381 || icomponent == 380 || icomponent == 379 || icomponent == 359 || icomponent == 358 || +// icomponent == 357 || icomponent == 337 || icomponent == 336 || icomponent == 335) +// if(icomponent == 340 || icomponent == 339 || icomponent == 316 || icomponent == 293 || icomponent == 270 || +// icomponent == 248) +// if(icomponent == 341 || icomponent == 342 || icomponent == 321 || icomponent == 300 || icomponent == 279 || +// icomponent == 257) +// if(icomponent == 226 || icomponent == 204 || icomponent == 183 || icomponent == 162 || icomponent == 141 || +// icomponent == 142) +// if(icomponent == 235 || icomponent == 213 || icomponent == 190 || icomponent == 167 || icomponent == 144 || +// icomponent == 143) +// if(icomponent == 241 || icomponent == 218 || icomponent == 195 || icomponent == 172 || icomponent == 149 || +// icomponent == 126 || icomponent == 103 || icomponent == 80 || icomponent == 57 || icomponent == 34 || +// icomponent == 11) +// if(icomponent >=341 && icomponent<=350) + // if(icomponent==347) + hits.add(hit); } } } From 3134d2f85a4a2946503ee165000f890944808120 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 29 Aug 2021 10:54:47 +0200 Subject: [PATCH 034/104] change of cluster centroid algorithm: arithmetic mean (not weighted on strip energy --- .../ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java index e5fc22954f..473c340805 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java @@ -158,6 +158,7 @@ public void calc_CentroidParams() { double zCentEndPoint2 = 0; // cluster energy-weighted Centroid z coordinate of the second end-point double totEn = 0.; // cluster total energy + double totEnergy = 0.; double totEnSq = 0.; // sum of energies squared double weightedStrp = 0; // energy-weighted strip @@ -210,6 +211,8 @@ public void calc_CentroidParams() { FTTRKHit thehit = this.get(i); // gets the energy value of the strip double strpEn = thehit.get_Edep(); + totEnergy += strpEn; + strpEn = 1.; // fix to 1 if no energy weighted mean is required - seems to have better efficiency // if truncated mean on the maximun energy if(i==maxI || i==maxI2nd && Math.random()>0.5) {continue;} // get strip informations @@ -235,7 +238,6 @@ public void calc_CentroidParams() { weightedStripEndPoint2X+= strpEn*x2; weightedStripEndPoint2Y+= strpEn*y2; weightedStripEndPoint2Z+= strpEn*z2; - //System.out.println(" making a cluster with strip "+strpNb+" ref var "+Constants.FVT_stripsYloc[strpNb-1][0]); // getting the max and min strip number in the cluster if(strpNb<=min) min = strpNb; @@ -300,7 +302,7 @@ public void calc_CentroidParams() { } */ - _TotalEnergy = totEn; + _TotalEnergy = totEnergy; double xmeanCent = (xCentEndPoint1+xCentEndPoint2)/2.; stripNumCent = this.get(0).get_StripNumberFromLocalY(xmeanCent, stripYCent, this.get(0).get_Layer()); //centroid: centroid strip number in the measurement direction (local y of each layer) From 20cb4e8397286b309c7d37a0c907848bb5f53003 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 29 Aug 2021 10:55:45 +0200 Subject: [PATCH 035/104] update to retrieve geo constants from db --- .../jlab/rec/ft/trk/FTTRKConstantsLoader.java | 133 +++++++++++++++++- 1 file changed, 129 insertions(+), 4 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java index 5a4ecdda10..5153a2a451 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java @@ -4,6 +4,8 @@ * and open the template in the editor. */ package org.jlab.rec.ft.trk; +import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.geom.prim.Line3D; /** * @@ -14,10 +16,26 @@ public class FTTRKConstantsLoader { FTTRKConstantsLoader() { } +// read all relevant constants from DB + + public static final int Nlayers = 4; // 2 double layers, ordered as FTT1B+FTT1T, FTT3T+FTT3B, 0-4 + public static int NSupLayers = Nlayers/2; // bottom+top makes a a SuperLayer + + public static int Nstrips; // Number of strips + public static int Longstrips; + public static int SideHalfstrips; + public static double[] Zlayer; // from MC mean position of gas layers (average z position of MC hits) + // identical layers (test): 0, 90, 0, 90 deg useful for debugging purposes + // public static double[] Alpha = {0., 0.5*Math.PI, 0., 0.5*Math.PI}; + // real geometry condition (gemc): -30, 60, 120, +30 deg + public static double[] Alpha; + + public static double Pitch; //strip width + public static double Beamhole; //Radius of the hole in the center for the beam (mm) + + /* // geometry constants - public static final int Nlayers = 4; // 2 double layers, ordered as FTT1B+FTT1T, FTT3T+FTT3B, 0-4 - public static int NSupLayers = Nlayers/2; // bottom+top makes a a SuperLayer public static int Nstrips=768 ; // Number of strips public static int SideHalfstrips; public static int Longstrips=128; @@ -30,6 +48,8 @@ public class FTTRKConstantsLoader { public static double Pitch=0.056; //strip width public static double Beamhole=14.086/2.; //Radius of the hole in the center for the beam (mm) + */ + public static double InnerHole; public static double Rmax; public static double[][][] stripsXloc; //Give the local end-points x-coordinates of the strip segment, per layer @@ -39,10 +59,71 @@ public class FTTRKConstantsLoader { public static double[][][] stripsX; //Give the end-points x-coordinates of the strip segment rotated in the correct frame for the layer public static double[][][] stripsY; //Give the end-points y-coordinates of the strip segment public static double[] stripslength; //Give the strip length + + public static boolean CSTLOADED = false; + static DatabaseConstantProvider dbprovider = null; - public static synchronized void Load() { + public static synchronized void Load(int run, String var) { + // get constants from database table + System.out.println(" LOADING CONSTANTS "); +// if(CSTLOADED == true) return null; + dbprovider = new DatabaseConstantProvider(run, var); // reset using the new variation + +// // load table reads entire table and makes an array of variables for each column in the table. + dbprovider.loadTable("/geometry/ft/fttrk"); + dbprovider.disconnect(); + dbprovider.show(); + + Nstrips = dbprovider.getInteger("/geometry/ft/fttrk/nstrips", 0) ; // Number of strips + Longstrips = dbprovider.getInteger("/geometry/ft/fttrk/nlongstrips", 0); + Pitch = dbprovider.getDouble("/geometry/ft/fttrk/pitch", 0); + Beamhole = dbprovider.getDouble("/geometry/ft/fttrk/innerradius", 0); // radius of the central hole for beam (mm) + + + double innerRadiusActive = dbprovider.getDouble("/geometry/ft/fttrk/innerradiusactive", 0); + Zlayer = new double[Nlayers]; + Alpha = new double[Nlayers]; + for(int lay=0; lay1) Alpha[lay] += Math.PI; + ////// if(lay==0 || lay==1) Alpha[lay] += (Math.PI-Math.PI/3.); + //if(lay==3) Alpha[lay] += Math.PI; + //if(lay!=1) Alpha[lay] += Math.PI; + /* + if(lay==0){ + Alpha[lay] = 0.; + }else if(lay==1){ + Alpha[lay] = Math.PI/2.; + }else if(lay==2){ + Alpha[lay] = Math.PI/2.; + }else if(lay==3){ + Alpha[lay] = 0.; + } + */ + + } + + /* + Alpha[0] = (150)*Math.PI/180.; + Alpha[1] = (60.)*Math.PI/180.; + Alpha[2] = (-60.)*Math.PI/180.; + Alpha[3] = (-150.)*Math.PI/180.; + */ + + CSTLOADED = true; + System.out.println("SUCCESFULLY LOADED FTTRK GEOMETRY CONSTANTS"); + + + + SideHalfstrips = (Nstrips -2*Longstrips)/4; // 128 InnerHole = (double)(SideHalfstrips)*Pitch; // 7.168 cm, exceeds Beamhole by 0.125 cm - reference as minimum radius Rmax = Pitch*(SideHalfstrips + Longstrips); // 14.336 @@ -118,6 +199,44 @@ public static synchronized void Load() { stripsY[j+2][i][1] = (stripsXloc[j][i][1]*Math.sin(Alpha[j+2]) + stripsYloc[j][i][1]*Math.cos(Alpha[j+2])); //if(debug>=1) System.out.println(Constants.getLocalRegion(i)+" strip-1 = "+i+" x' "+stripsXloc[i][1]+" y' "+stripsYloc[i][1]+" length "+stripslength[i]+" Beamhole "+Beamhole); + /* + // inversione x con y + double xyinv = stripsX[j][i][0]; + stripsX[j][i][0] = stripsY[j][i][0]; + stripsY[j][i][0] = xyinv; + xyinv = stripsX[j][i][1]; + stripsX[j][i][1] = stripsY[j][i][1]; + stripsY[j][i][1] = xyinv; + xyinv = stripsX[j+2][i][0]; + stripsX[j+2][i][0] = stripsY[j+2][i][0]; + stripsY[j+2][i][0] = xyinv; + xyinv = stripsX[j+2][i][1]; + stripsX[j+2][i][1] = stripsY[j+2][i][1]; + stripsY[j+2][i][1] = xyinv; + */ + + // alignment: global translation: x-y coordinates layer 0,1 + double tX1 = 0.; double tY1 = 0.; + double tX2 = 0.; double tY2 = 0.; + /* + tX1 = -0.006; tY1 = 0.051; // first tenative alignment + tX2 = 0.046; tY2 = 0.008; +// tX1 = 1.5; + */ + + stripsX[j][i][0] += tX1; // cm + stripsX[j][i][1] += tX1; + stripsY[j][i][0] += tY1; + stripsY[j][i][1] += tY1; + + stripsX[j+2][i][0] += tX2; // cm + stripsX[j+2][i][1] += tX2; + stripsY[j+2][i][0] += tY2; + stripsY[j+2][i][1] += tY2; + + + + } } System.out.println("***** FTTRK constants loaded"); @@ -163,5 +282,11 @@ private static int getLocalRegionX(int strip){ return regionX; } - + public static Line3D getStripSegmentLab(int layer, int seed){ + Line3D stripSegment = new Line3D(stripsX[layer-1][seed-1][0], stripsY[layer-1][seed-1][0], Zlayer[layer-1], + stripsX[layer-1][seed-1][1], stripsY[layer-1][seed-1][1], Zlayer[layer-1]); + stripSegment.show(); + + return stripSegment; + } } From 909acb9b3e8e2fb9f26f6be78e3554fe2a035f46 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 29 Aug 2021 10:56:12 +0200 Subject: [PATCH 036/104] added histos for diagnostics --- .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 157 ++++++++++++++++-- 1 file changed, 139 insertions(+), 18 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java index 77fc8150fe..5bdce509ef 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java @@ -41,20 +41,34 @@ public FTTRKEngine() { @Override public boolean init() { + + String[] tables = new String[]{ + "/calibration/ft/fthodo/charge_to_energy", + "/calibration/ft/fthodo/time_offsets", + "/calibration/ft/fthodo/status", + "/geometry/ft/fthodo", + "/geometry/ft/fttrk" + }; + requireConstants(Arrays.asList(tables)); + this.getConstantsManager().setVariation("default"); - FTTRKConstantsLoader.Load(); - - reco = new FTTRKReconstruction(); -// reco.debugMode=0; + // use 11 provisionally as run number to download the basic FTTK geometry constants + FTTRKConstantsLoader.Load(11, this.getConstantsManager().getVariation()); + reco = new FTTRKReconstruction(); + reco.debugMode=0; +/* String[] tables = new String[]{ "/calibration/ft/fthodo/charge_to_energy", "/calibration/ft/fthodo/time_offsets", "/calibration/ft/fthodo/status", - "/geometry/ft/fthodo" + "/geometry/ft/fthodo", + "/geometry/ft/fttrk" }; requireConstants(Arrays.asList(tables)); this.getConstantsManager().setVariation("default"); +*/ + return true; } @@ -124,7 +138,11 @@ public static void main (String arg[]) { FTTRKEngine trk = new FTTRKEngine(); trk.init(); // insert input filename here - String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; +// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_dis.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; +// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_fullAcceptance_singleTrack.hipo"; System.out.println("input file " + input); HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -133,11 +151,23 @@ public static void main (String arg[]) { H2F h1 = new H2F("h1", "Layer vs. Component", 768, 0., 769., 4, 0.5, 4.5); h1.setTitleX("Component"); h1.setTitleY("Layer"); - H1F h2 = new H1F("Energy",100, 0, 100); + H1F h2 = new H1F("Energy",100, 0, 1000.); h2.setOptStat(Integer.parseInt("1111")); h2.setTitleX("Energy"); h2.setTitleY("Counts"); - H1F h3 = new H1F("Time",100, 0., 1.e-3); + H1F h3 = new H1F("Time",100, 0., 500.); // was 1e-3 h3.setOptStat(Integer.parseInt("1111")); h3.setTitleX("Time"); h3.setTitleY("Counts"); - H1F h1clEn = new H1F("Cluster energy", 100, 0., 100.); + H2F h333 = new H2F("energy vs time",100, 0., 410., 100, 0., 410.); + h333.setTitleX("strip Time"); h333.setTitleY("strip Energy"); + H2F h444 = new H2F("strip vs time",100, 0., 500., 768, 0., 769.); + h444.setTitleX("strip Time"); h444.setTitleY("strip number"); + H2F h445 = new H2F("strip lay 1 vs time",100, 0., 500., 768, 0., 769.); + h445.setTitleX("strip Time"); h445.setTitleY("strip number"); + H2F h446 = new H2F("strip lay 2 vs time",100, 0., 500., 768, 0., 769.); + h446.setTitleX("strip Time"); h446.setTitleY("strip number"); + H2F h447 = new H2F("strip lay 3 vs time",100, 0., 500., 768, 0., 769.); + h447.setTitleX("strip Time"); h447.setTitleY("strip number"); + H2F h448 = new H2F("strip lay 4 vs time",100, 0., 500., 768, 0., 769.); + h448.setTitleX("strip Time"); h448.setTitleY("strip number"); + H1F h1clEn = new H1F("Cluster energy", 100, 0., 1000.); h1clEn.setOptStat(Integer.parseInt("1111")); h1clEn.setTitleX("centroid energy of clusters"); H1F hOccupancy1 = new H1F("hOccupancy1", 768, 0., 769.); hOccupancy1.setTitleX("Component layer 1"); hOccupancy1.setLineColor(1); hOccupancy1.setFillColor(1); @@ -188,12 +218,12 @@ public static void main (String arg[]) { canvasClSingleLay.divide(2,2); int nc1 = 0, nc2 = 0, ncmatch = 0; - int nev=-1; - while(reader.hasEvent()){ -// int nev1 = 0; int nev2 = nev1+6150; for(nev=nev1; nev=1) System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~ processing event ~~~~~~~~~~~ " + ++nev); -// if(nev!=6146) continue; // select one event only for debugging purposes + int nev=0; +// while(reader.hasEvent()){ + int nev1 = 0; int nev2 = 10000; for(nev=nev1; nev=1) System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~ processing event ~~~~~~~~~~~ " + nev); +// if(nev != 8) continue; // select one event only for debugging purposes ArrayList clusters = new ArrayList(); @@ -217,6 +247,19 @@ public static void main (String arg[]) { h1.fill(comp,layer); h2.fill(energy); h3.fill(time); + h333.fill(time, energy); + + h444.fill(time, comp); + if(layer==1){ + h445.fill(time, comp); + }else if(layer==2){ + h446.fill(time, comp); + }else if(layer==3){ + h447.fill(time, comp); + }else if(layer==4){ + h448.fill(time, comp); + } + if(layer==1){ if(debug>=1) System.out.println("component layer 1 " + comp + " event number " + nev + " n rows " + nrows); hOccupancy1.fill(comp); @@ -380,17 +423,31 @@ public static void main (String arg[]) { if(debug>=1) System.out.println("number of found crosses: module 1: " + nc1 + " module 2: " + nc2 + " matching crosses " + ncmatch); JFrame frame = new JFrame("FT Reconstruction"); - frame.setSize(800,800); + frame.setSize(1200,800); EmbeddedCanvas canvas = new EmbeddedCanvas(); - canvas.divide(2,2); + canvas.divide(2,3); canvas.cd(0); canvas.draw(h1); canvas.cd(1); canvas.draw(h2); canvas.cd(2); canvas.draw(h3); - canvas.cd(3); canvas.draw(h1clEn); + canvas.cd(3); canvas.draw(h333); + canvas.cd(4); canvas.draw(h1clEn); + canvas.cd(5); canvas.draw(h444); frame.add(canvas); frame.setLocationRelativeTo(null); frame.setVisible(true); + JFrame framest = new JFrame("FT strip vs time in layers"); + framest.setSize(800,800); + EmbeddedCanvas canvast = new EmbeddedCanvas(); + canvast.divide(2,2); + canvast.cd(0); canvast.draw(h445); + canvast.cd(1); canvast.draw(h446); + canvast.cd(2); canvast.draw(h447); + canvast.cd(3); canvast.draw(h448); + framest.add(canvast); + framest.setLocationRelativeTo(null); + framest.setVisible(true); + JFrame frameDiff = new JFrame("Strip Difference"); frameDiff.setSize(800,800); EmbeddedCanvas canvasDiff = new EmbeddedCanvas(); @@ -441,10 +498,74 @@ public static void main (String arg[]) { EmbeddedCanvas canvas3 = new EmbeddedCanvas(); canvas3.divide(2,2); int ic=-1; + double upl = 100.; + DataLine l1 = new DataLine(64., 0., 64., upl); + DataLine l2 = new DataLine(129., 0., 129., upl); + DataLine l3 = new DataLine(162., 0., 162., upl); + DataLine l4 = new DataLine(193., 0., 193., upl); + DataLine l5 = new DataLine(224., 0., 224., upl); // + DataLine l6 = new DataLine(256., 0., 256., upl); + DataLine l7 = new DataLine(288., 0., 288., upl); // + DataLine l8 = new DataLine(321., 0., 321., upl); + DataLine l9 = new DataLine(353., 0., 353., upl); + DataLine l10 = new DataLine(385., 0., 385., upl); + DataLine l11 = new DataLine(417., 0., 417., upl); + DataLine l12 = new DataLine(449., 0., 449., upl); + DataLine l13 = new DataLine(480., 0., 480., upl); // + DataLine l14 = new DataLine(513., 0., 513., upl); + DataLine l15 = new DataLine(544., 0., 544., upl); // + DataLine l16 = new DataLine(578., 0., 578., upl); + DataLine l17 = new DataLine(611., 0., 611., upl); + DataLine l18 = new DataLine(641., 0., 641., upl); + DataLine l19 = new DataLine(705., 0., 705., upl); + DataLine l20 = new DataLine(768., 0., 768., upl); + l1.setLineColor(6); l2.setLineColor(6); l3.setLineColor(6); + l4.setLineColor(6); l5.setLineColor(6); l6.setLineColor(6); + l7.setLineColor(6); l8.setLineColor(6); l9.setLineColor(6); l10.setLineColor(6); + l11.setLineColor(6); l12.setLineColor(6); l13.setLineColor(6); l14.setLineColor(4); l15.setLineColor(6); + l16.setLineColor(6); l17.setLineColor(6); l18.setLineColor(6); l19.setLineColor(6); l20.setLineColor(6); + l1.setLineStyle(3); l2.setLineStyle(3); l3.setLineStyle(3); l4.setLineStyle(3); l5.setLineStyle(3); + canvas3.cd(++ic); canvas3.draw(hOccupancy1); + canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); + canvas3.draw(l4); //canvas3.draw(l5); + canvas3.draw(l6); //canvas3.draw(l7); + canvas3.draw(l8); canvas3.draw(l9); + canvas3.draw(l10); canvas3.draw(l11); + canvas3.draw(l12); //canvas3.draw(l13); + canvas3.draw(l14); //canvas3.draw(l15); + canvas3.draw(l16); canvas3.draw(l17); + canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); canvas3.cd(++ic); canvas3.draw(hOccupancy2); + canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); + canvas3.draw(l4); //canvas3.draw(l5); + canvas3.draw(l6); //canvas3.draw(l7); + canvas3.draw(l8); canvas3.draw(l9); + canvas3.draw(l10); canvas3.draw(l11); + canvas3.draw(l12); //canvas3.draw(l13); + canvas3.draw(l14); //canvas3.draw(l15); + canvas3.draw(l16); canvas3.draw(l17); + canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); canvas3.cd(++ic); canvas3.draw(hOccupancy3); + canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); + canvas3.draw(l4); //canvas3.draw(l5); + canvas3.draw(l6); //canvas3.draw(l7); + canvas3.draw(l8); canvas3.draw(l9); + canvas3.draw(l10); canvas3.draw(l11); + canvas3.draw(l12); //canvas3.draw(l13); + canvas3.draw(l14); //canvas3.draw(l15); + canvas3.draw(l16); //canvas3.draw(l17); + canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); canvas3.cd(++ic); canvas3.draw(hOccupancy4); + canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); + canvas3.draw(l4); //canvas3.draw(l5); + canvas3.draw(l6); //canvas3.draw(l7); + canvas3.draw(l8); canvas3.draw(l9); + canvas3.draw(l10); canvas3.draw(l11); + canvas3.draw(l12); //canvas3.draw(l13); + canvas3.draw(l14); //canvas3.draw(l15); + canvas3.draw(l16); //canvas3.draw(l17); + canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); frame3.add(canvas3); frame3.setLocationRelativeTo(null); frame3.setVisible(true); From 93e86f05276cac31ecd303dfb20a08d3ec48b787 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 29 Aug 2021 10:56:46 +0200 Subject: [PATCH 037/104] added edep and time infor for FTRRK as private memebers in the class --- .../ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java index 73454a3d86..4d0f068537 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java @@ -37,13 +37,14 @@ public class FTTRKHit implements Comparable{ * @param strip * @param Edep (for gemc output without digitization) */ - public FTTRKHit(int sector, int layer, int strip, double Edep, int id) { + public FTTRKHit(int sector, int layer, int strip, double Edep, double time, int id) { int debug = FTTRKReconstruction.debugMode; // gets the debug flag from FTTRKReconstruction this._Sector = sector; this._Layer = layer; this._Strip = strip; this._Edep = Edep; this._Id = id; + this._Time = time; // update associations after crosses are found this._DGTZIndex = -1; this._ClusterIndex = -1; From 36f71ee2be2202dc6a07b472ed15925abe368dfc Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 29 Aug 2021 10:58:12 +0200 Subject: [PATCH 038/104] add auxiliarmy methods for strip groups renumbering/adjustment/swaps (offlinee adjust of transition table --- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 1034 ++++++++++++++++- 1 file changed, 1018 insertions(+), 16 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index ea3d494987..95535820cd 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -16,28 +16,40 @@ import org.jlab.io.hipo.HipoDataEvent; import org.jlab.rec.ft.FTConstants; import org.jlab.utils.groups.IndexedTable; +import org.jlab.geom.prim.Point3D; +import org.jlab.rec.ft.FTEBEngine; /** * * @author devita * @author filippi */ + + public class FTTRKReconstruction { public static int debugMode = 0; // 1 for verbose, set it here (better be set in the steering Engine) - + ////////////////////// provisional + public static float[] crEnergy; + public static float[] crTime; + ////////////////////////////////// + public FTTRKReconstruction() { } public List initFTTRK(DataEvent event, ConstantsManager manager, int run) { + /* tables are not needed for FTTRK reco at this point IndexedTable charge2Energy = manager.getConstants(run, "/calibration/ft/fthodo/charge_to_energy"); IndexedTable timeOffsets = manager.getConstants(run, "/calibration/ft/fthodo/time_offsets"); IndexedTable geometry = manager.getConstants(run, "/geometry/ft/fthodo"); + IndexedTable trkGeo = manager.getConstants(run, "/geometry/ft/fttrk"); + */ if(debugMode>=1) System.out.println("\nAnalyzing new event"); List allhits = null; - allhits = this.readRawHits(event,charge2Energy,timeOffsets,geometry); +// allhits = this.readRawHits(event,charge2Energy,timeOffsets,geometry,trkGeo); + allhits = this.readRawHits(event, run); if(debugMode>=1) { System.out.println("Found " + allhits.size() + " hits"); @@ -120,7 +132,7 @@ public ArrayList findClusters(List hits) checked[ris][il] = true; // if fired this is the first strip of the cluster clusterHits.add(new FTTRKHit(HitArray[ris][il].get_Sector(), HitArray[ris][il].get_Layer(), HitArray[ris][il].get_Strip(), - HitArray[ris][il].get_Edep(), HitArray[ris][il].get_Id())); + HitArray[ris][il].get_Edep(), HitArray[ris][il].get_Time(), HitArray[ris][il].get_Id())); // System.out.println(" clusterHits iteration " + is + " strip " + ris + " " + HitArray[ris][il].get_Strip()); // look for a consecutive strip in the stack and stick it to the cluster int isnext = is+1; @@ -128,7 +140,7 @@ public ArrayList findClusters(List hits) int nris = indR[isnext]; checked[nris][il] = true; clusterHits.add(new FTTRKHit(HitArray[nris][il].get_Sector(), HitArray[nris][il].get_Layer(), HitArray[nris][il].get_Strip(), - HitArray[nris][il].get_Edep(), HitArray[nris][il].get_Id())); + HitArray[nris][il].get_Edep(), HitArray[ris][il].get_Time(), HitArray[nris][il].get_Id())); // System.out.println(" clusterHits iteration " + isnext + " strip " + nris + " " + HitArray[nris][il].get_Strip()); nst++; isnext++; @@ -165,14 +177,14 @@ public ArrayList findClusters(List hits) checked[lis][il] = true; // if fired this is the first strip of the cluster clusterHits.add(new FTTRKHit(HitArray[lis][il].get_Sector(), HitArray[lis][il].get_Layer(), HitArray[lis][il].get_Strip(), - HitArray[lis][il].get_Edep(), HitArray[lis][il].get_Id())); + HitArray[lis][il].get_Edep(), HitArray[lis][il].get_Time(), HitArray[lis][il].get_Id())); // look for a consecutive strip in the stack and stick it to the cluster int isnext = is+1; while(isnext < 640 && HitArray[indL[isnext]][il] != null && !checked[indL[isnext]][il]){ int nlis = indL[isnext]; checked[nlis][il] = true; clusterHits.add(new FTTRKHit(HitArray[nlis][il].get_Sector(), HitArray[nlis][il].get_Layer(), HitArray[nlis][il].get_Strip(), - HitArray[nlis][il].get_Edep(), HitArray[nlis][il].get_Id())); + HitArray[nlis][il].get_Edep(), HitArray[lis][il].get_Time(), HitArray[nlis][il].get_Id())); nst++; isnext++; } @@ -389,11 +401,28 @@ public ArrayList findCrosses(List clusters) { if(idMax1>=0) validatedCrosses.add(crosses.get(idMax1)); if(idMax2>=0) validatedCrosses.add(crosses.get(idMax2)); + // make a geometric match of the two crosses + if(validatedCrosses.size()== FTTRKConstantsLoader.NSupLayers){ + double diffRadTolerance = FTConstants.TRK0_TRK1_RADTOL; + double diffPhiTolerance = FTConstants.TRK0_TRK1_PHITOL; + double diffThetaTolerance = FTConstants.TRK0_TRK1_THETATOL; + Point3D cross0 = validatedCrosses.get(0).get_Point(); + Point3D cross1 = validatedCrosses.get(1).get_Point(); + double r02d = Math.sqrt(cross0.x()*cross0.x() + cross0.y()*cross0.y()); + double r12d = Math.sqrt(cross1.x()*cross1.x() + cross1.y()*cross1.y()); + double r0 = Math.sqrt(r02d*r02d + cross0.z()*cross0.z()); + double r1 = Math.sqrt(r12d*r12d + cross1.z()*cross1.z()); + double diffRadii = r02d-r12d; + double diffTheta = Math.acos(cross0.z()/r0) - Math.acos(cross1.z()/r1); + double diffPhi = Math.atan2(cross0.y(), cross0.x()) - Math.atan2(cross1.y(), cross1.x()); + if(!(Math.abs(diffPhi) < diffPhiTolerance && Math.abs(diffRadii)< diffRadTolerance && Math.abs(diffTheta) < diffThetaTolerance)) validatedCrosses.clear(); + } + return validatedCrosses; //return crosses; } - public List readRawHits(DataEvent event, IndexedTable charge2Energy, IndexedTable timeOffsets, IndexedTable geometry) { + public List readRawHits(DataEvent event, int run) { // getting raw data bank if(debugMode>=1) System.out.println("Getting raw hits from FTTRK:adc bank"); @@ -408,12 +437,185 @@ public List readRawHits(DataEvent event, IndexedTable charge2Energy, I int icomponent = bankDGTZ.getInt("component",row); int iorder = bankDGTZ.getInt("order",row); int adc = bankDGTZ.getInt("ADC",row); - float time = bankDGTZ.getLong("timestamp",row); // entry not avalable in mc banks yet +// float time = bankDGTZ.getLong("timestamp",row); // entry not avalable in mc banks yet + float time = bankDGTZ.getFloat("time", row); // set threshold on FTTRK ADCs (in FTConstants.java - if(adc>FTConstants.FTTRKAdcThreshold && time!=-1 && icomponent!=-1){ + +/////////////////////////////////////////////////////// insert here operations modifying strip number +/////////////////////////////////////////////////////// IN RECO: STRIP NUMBERS: 0-767, layer numbers: 0-3 +/////////////////////////////////////////////////////// IN FEE: STRIP NUMBERS: 1-768, layer numbers: 1-4 + + // swap layer numbers + /* + if(ilayer==1){ + ilayer = 3; + }else if(ilayer==2){ + ilayer = 4; + }else if(ilayer==3){ + ilayer = 1; + }else if(ilayer==4){ + ilayer = 2; + } + */ + // swap left/right short strips sectors for layer 2 and 4 (it means a reflection wrt y axis) + + /* + if(ilayer==4 || ilayer==2){ + if(icomponent>=129 && icomponent<=384){ + icomponent += 256; + }else if(icomponent>=385 && icomponent<=640){ + icomponent -= 256; + } + } + */ + + /* + if(ilayer==2 || ilayer==3) icomponent = flipStripVertical(ilayer, icomponent); + if(ilayer==4) icomponent = flipStripHorizontal(ilayer, icomponent); + */ + + // read just layer sectors only for real data (no montecarlo) + //icomponent = adjustStripNumberingTest11(run, ilayer, icomponent); + //icomponent = renumberStrip(ilayer, icomponent); + icomponent = renumberFEE2RECRotatedAndAdjust(run, ilayer, icomponent); + + +/* +// layer 3: swap 6-7 e inversione + if(ilayer==3){ + int isec1 = findSector(icomponent); + if(isec1 == 6){ + icomponent = swapSectors(icomponent, 7); + }else if(isec1 == 7){ + icomponent = swapSectors(icomponent, 6); + } + int newSector = findSector(icomponent); + if(newSector == 6 || newSector==7) icomponent = reverseStripsInSector(icomponent); + } + +// swap central sectors (6->9, 7->10, 8->11) for layers 1,4 - large sectors (16) numbering + if(ilayer==1 || ilayer == 4 || ilayer==3 || ilayer==2){ + int isec1 = findSector(icomponent); + if(isec1==6){ + icomponent = swapSectors(icomponent, 10); + }else if(isec1==7){ + icomponent = swapSectors(icomponent, 11); + }else if(isec1==8){ + icomponent = swapSectors(icomponent, 12); + }else if(isec1==9){ + icomponent = swapSectors(icomponent, 13); + }else if(isec1==10){ + icomponent = swapSectors(icomponent, 6); + }else if(isec1==11){ + icomponent = swapSectors(icomponent, 7); + }else if(isec1==12){ + icomponent = swapSectors(icomponent, 8); + }else if(isec1==13){ + icomponent = swapSectors(icomponent, 9); + } + +// }else if(isec1==2){ +// icomponent = swapSectors(icomponent, 14); +// }else if(isec1==3){ +// icomponent = swapSectors(icomponent, 15); +// }else if(isec1==4){ +// icomponent = swapSectors(icomponent, 16); +// }else if(isec1==5){ +// icomponent = swapSectors(icomponent, 17); +// }else if(isec1==14){ +// icomponent = swapSectors(icomponent, 2); +// }else if(isec1==15){ +// icomponent = swapSectors(icomponent, 3); +// }else if(isec1==16){ +// icomponent = swapSectors(icomponent, 4); +// }else if(isec1==17){ +// icomponent = swapSectors(icomponent, 5); +// } + } + +*/ + + +///////////////////////////////////////////////////////////////////////////////////////////////// + + if(adc>FTConstants.FTTRKMinAdcThreshold && adc0 && icomponent<=64) hits.add(hit); + }else if(ilayer == 3){ + if(icomponent>705&& icomponent<=768) hits.add(hit); + }else{ + hits.add(hit); + } +*/ + +// if(icomponent>64 && icomponent<=128) hits.add(hit); +// if(icomponent>128 && icomponent<=160) hits.add(hit); +// if(icomponent>160 && icomponent<=192) hits.add(hit); +// if(icomponent>192 && icomponent<=256) hits.add(hit); +// if(icomponent>256 && icomponent<=320) hits.add(hit); +// if(icomponent>320 && icomponent<=352) hits.add(hit); +// if(icomponent>352 && icomponent<=384) hits.add(hit); +// if(icomponent>384 && icomponent<=416) hits.add(hit); +// if(icomponent>416 && icomponent<=448) hits.add(hit); +// if(icomponent>448 && icomponent<=512) hits.add(hit); +// if(icomponent>513 && icomponent<=577) hits.add(hit); +// if(icomponent>577 && icomponent<=610) hits.add(hit); +// if(icomponent>610 && icomponent<=640) hits.add(hit); +// if(icomponent>640 && icomponent<=705) hits.add(hit); +// if(icomponent>705 && icomponent<=768) hits.add(hit); +// if(icomponent>512) + + +/* + if(ilayer==1){ + if(isInSector(0, icomponent)) hits.add(hit); + }else if(ilayer==2){ + if(isInSector(7, icomponent)) hits.add(hit); + }else if(ilayer==3){ + if(isInSector(19, icomponent)) hits.add(hit); + }else if(ilayer==4){ + if(isInSector(3, icomponent)) hits.add(hit); +} +*/ +/* + if(isStripInConnector(3, ilayer, icomponent)) { + hits.add(hit); + } +*/ + +// select strips belonging to a crate (1-2-3) +/// if(isStripInCrate(1, ilayer, icomponent)) hits.add(hit); +// select strips belonging to a given physical connector in a layer +// int iconn = findPhysicalConnector(icomponent); +// if(ilayer==2 && iconn==6) hits.add(hit); // bad connector +// if(ilayer==4 && iconn==12) hits.add(hit); // bad connector + + + /* + if(ilayer==1 && icomponent>=1 && icomponent<=64) hits.add(hit); + if(ilayer==2 && icomponent>=193 && icomponent<=258) hits.add(hit); + if(ilayer==3 && icomponent>=705 && icomponent<=768) hits.add(hit); + if(ilayer==4 && icomponent>=119 && icomponent<=384) hits.add(hit); + */ + + boolean isHitAccepted = true; +// if(ilayer == 2 || ilayer ==3) isHitAccepted = false; +// if((ilayer==2) && icomponent<=641) isHitAccepted = false; +// if((ilayer==4) && icomponent>=1 && icomponent>64) isHitAccepted = false; + +// selection on strip time + if(time < 50 || time > 350) isHitAccepted = false; + + if(isHitAccepted) hits.add(hit); +//////////////////////////////////////////////////////////////////////////////////////// } } } @@ -503,7 +705,14 @@ public void writeHipoBanks(DataEvent event, List hits, List1200.) continue; + // these are probaly outoftimers, no needo to cut + //if(crosses.get(j).get_Time()<150. || crosses.get(j).get_Time()>250.) continue; + /////////////////////////////////////////////////////////////////////////////////////// bankCross.setShort("size", j, (short) crosses.size()); bankCross.setShort("id", j, (short) crosses.get(j).get_Id()); bankCross.setByte("sector", j, (byte) crosses.get(j).get_Sector()); @@ -511,10 +720,45 @@ public void writeHipoBanks(DataEvent event, List hits, List hits, List hits, List0){ // provisional + if(ilayer==1){ + //icomponent = overturnModule(ilayer, icomponent); + icomponent = flipStripVertical(ilayer, icomponent); + int isec1 = findSector(icomponent); + + // test 9 + /* + if(isec1==2){ // era 2-5, 5-13, 13-12, 12-2 (test8_2) + icomponent = swapSectors(icomponent, 12); + }else if(isec1==3){ + icomponent = swapSectors(icomponent, 2); + }else if(isec1==5){ + icomponent = swapSectors(icomponent, 13); + }else if(isec1==12){ + icomponent = swapSectors(icomponent, 3); + }else if(isec1==13){ + icomponent = swapSectors(icomponent, 5); + */ + // test10 + if(isec1==2){ + icomponent = swapSectors(icomponent, 12); + }else if(isec1==12){ + icomponent = swapSectors(icomponent, 2); + }else if(isec1==5){ + icomponent = swapSectors(icomponent, 13); + }else if(isec1==13){ + icomponent = swapSectors(icomponent, 5); + + //}else if(isec1==12){ + // icomponent = swapSectors(icomponent, 10); + //}else if(isec1==10){ + // icomponent = swapSectors(icomponent, 12); + + /* + if(isec1==12){ + icomponent = swapSectors(icomponent, 10); + }else if(isec1==10){ + icomponent = swapSectors(icomponent, 12); + }else if(isec1==5){ + icomponent = swapSectors(icomponent, 2); + }else if(isec1==2){ + icomponent = swapSectors(icomponent, 5); + }else if(isec1==13){ + icomponent = swapSectors(icomponent, 11); + }else if(isec1==11){ + icomponent = swapSectors(icomponent, 13); + */ + + /* + if(isec1==13){ + icomponent = swapSectors(icomponent, 12); + }else if(isec1==12){ + icomponent = swapSectors(icomponent, 10); + }else if(isec1==10){ + icomponent = swapSectors(icomponent, 13); + }else if(isec1==5){ + icomponent = swapSectors(icomponent, 2); + }else if(isec1==2){ + icomponent = swapSectors(icomponent, 5); + */ + + }else if(isec1==14){ + icomponent = swapSectors(icomponent, 17); + }else if(isec1==15){ + icomponent = swapSectors(icomponent, 16); + }else if(isec1==16){ + icomponent = swapSectors(icomponent, 15); + }else if(isec1==17){ + icomponent = swapSectors(icomponent, 14); + } + // reverse sectors + int newsec = findSector(icomponent); + if(newsec==16 || newsec==17 || newsec==2) icomponent = reverseStripsInSector(icomponent); + +// test 12 +// if(newsec==13){ +// icomponent = swapSectors(icomponent, 10); +// }else if(newsec==10){ +// icomponent = swapSectors(icomponent, 13); +// } + + + /* + newsec = findSector(icomponent); + if(newsec==3){ + icomponent = swapSectors(icomponent, 12); + }else if(newsec==12){ + icomponent = swapSectors(icomponent, 3); + } + if(newsec==2 || newsec==4) icomponent = reverseStripsInSector(icomponent); + */ + + }else if(ilayer==2){ + icomponent = flipStripVertical(ilayer, icomponent); + int isec1 = findSector(icomponent); + + if(isec1==2){ + icomponent = swapSectors(icomponent, 12); + }else if(isec1==12){ + icomponent = swapSectors(icomponent, 2); + }else if(isec1==5){ + icomponent = swapSectors(icomponent, 13); + }else if(isec1==13){ + icomponent = swapSectors(icomponent, 5); + + }else if(isec1==14){ + icomponent = swapSectors(icomponent, 17); + }else if(isec1==15){ + icomponent = swapSectors(icomponent, 16); + }else if(isec1==16){ + icomponent = swapSectors(icomponent, 15); + }else if(isec1==17){ + icomponent = swapSectors(icomponent, 14); + } + // reverse sectors + int newsec = findSector(icomponent); + if(newsec==16 || newsec==17) icomponent = reverseStripsInSector(icomponent); + + }else if(ilayer==3){ + icomponent = flipStripVertical(ilayer, icomponent); + int isec1 = findSector(icomponent); + if(isec1==2){ + icomponent = swapSectors(icomponent, 4); + }else if(isec1==3){ + icomponent = swapSectors(icomponent, 5); + }else if(isec1==4){ + icomponent = swapSectors(icomponent, 2); + }else if(isec1==5){ + icomponent = swapSectors(icomponent, 3); + + }else if(isec1==14){ + icomponent = swapSectors(icomponent, 17); + }else if(isec1==15){ + icomponent = swapSectors(icomponent, 16); + }else if(isec1==16){ + icomponent = swapSectors(icomponent, 15); + }else if(isec1==17){ + icomponent = swapSectors(icomponent, 14); + } + // reverse sectors + int newsec = findSector(icomponent); + if(newsec==16 || newsec==17) icomponent = reverseStripsInSector(icomponent); + }else if(ilayer==4){ + icomponent = flipStripHorizontal(ilayer, icomponent); + int isec1 = findSector(icomponent); + if(isec1==2){ + icomponent = swapSectors(icomponent, 5); + }else if(isec1==5){ + icomponent = swapSectors(icomponent, 2); + }else if(isec1==3){ + icomponent = swapSectors(icomponent, 4); + }else if(isec1==4){ + icomponent = swapSectors(icomponent, 3); + }else if(isec1==14){ + icomponent = swapSectors(icomponent, 17); + }else if(isec1==15){ + icomponent = swapSectors(icomponent, 16); + }else if(isec1==16){ + icomponent = swapSectors(icomponent, 15); + }else if(isec1==17){ + icomponent = swapSectors(icomponent, 14); + } + int newsec = findSector(icomponent); + if(newsec==16 || newsec==17 || newsec==2 || newsec==3) icomponent = reverseStripsInSector(icomponent); + + } + } + return icomponent; } + + + public int flipStripVertical(int ilayer, int icomponent){ + // flip the layer vertically with respect to y axis (left/right flip) + // strips numbered 1-768 + /* + if(ilayer==1 || ilayer==3){ // vertical strips + if(icomponent>=129 && icomponent<=384){ + icomponent = 512-icomponent; + }else if(icomponent>384 && icomponent<=640){ + icomponent = 1025 - icomponent; + }else{ + icomponent = 769 - icomponent; + } + }else if(ilayer==2 || ilayer==4){ + if(icomponent>=129 && icomponent<=384){ + icomponent = 513 - icomponent; + }else if(icomponent>384 && icomponent<=640){ + icomponent = 1025 - icomponent; + }else{ + //icomponent = 769 - icomponent; + } + } + */ + + // strips numbers 1-768 + if(ilayer==2 || ilayer==3){ // RECO vertical strips + if(icomponent>=129 && icomponent<=384){ + icomponent += 256; + }else if(icomponent>=385 && icomponent<=640){ + icomponent -= 256; + } + }else if(ilayer==1 || ilayer==4){ // RECO horizontal strips + if(icomponent>=129 && icomponent<=384){ + icomponent = 513 - icomponent; + }else if(icomponent>=385 && icomponent<=640){ + icomponent = 1025 - icomponent; + }else{ // for horizontal strips flip also long strips + icomponent = 769 - icomponent; + } + } + + + return icomponent; + } + + public int flipStripHorizontal(int ilayer, int icomponent){ + // flip the layer horizontally with respect to the x axis (top/bottom flip) + // strips 1-128 + /* + if(ilayer==1 || ilayer==3){ + if(icomponent>=129 && icomponent<=384){ + icomponent += 256; + }else if(icomponent>=385 && icomponent<=640){ + icomponent -= 256; + }else{ + icomponent = 769 - icomponent; + } + }else if(ilayer==2 || ilayer ==4){ + if(icomponent>=129 && icomponent<=384){ + icomponent = 513 - icomponent; + }else if(icomponent>=385 && icomponent<=640){ + icomponent = 1025 - icomponent; + }else{ + // icomponent = 769 - icomponent; + } + } + */ + if(ilayer==1 || ilayer==4){ // RECO vertical strips + if(icomponent>=129 && icomponent<=384){ + icomponent += 256; + }else if(icomponent>=385 && icomponent<=640){ + icomponent -= 256; + } + }else if(ilayer==2 || ilayer==3){ // RECO horizontal strips + if(icomponent>=129 && icomponent<=384){ + icomponent = 513 - icomponent; + }else if(icomponent>=385 && icomponent<=640){ + icomponent = 1025 - icomponent; + }else{ + icomponent = 769 - icomponent; + } + } + + return icomponent; + } + + public int overturnModule(int ilayer, int icomponent){ + // rotate of 180 degrees: this incluse a flip with respect to the x axis followed by a flip with respect to y + int icompNew = flipStripHorizontal(ilayer, icomponent); + icompNew = flipStripVertical(ilayer, icompNew); + return icompNew; + } + +public int reverseStripsInSector(int icomponent){ + // flip the layer horizontally with respect to the x axis (top/bottom flip) + int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + int nsector = findSector(icomponent); + int offset = sectorLimit[nsector+1] - icomponent; + icomponent = sectorLimit[nsector] + offset; + + return icomponent; + } + +public int swapSectors(int icomponent, int nsector2){ + // get the new strip number of the icomponent strip in nsector1 once the sector is swapped to nsector2 + int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + int nsector1 = findSector(icomponent); + int offset = -sectorLimit[nsector1] + icomponent; + int newicomp = sectorLimit[nsector2] + offset; + + return newicomp; +} + +public static int findSector(int icomponent){ + // returns the sector number, corresponding to the component of the lower extreme of the interval + // sectors are numbered 0-20 + int[] sectorLimits = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + int nsector = -1; + for(int i=0; i<20; i++){ + if(icomponent>sectorLimits[i] && icomponent<=sectorLimits[i+1]){ + nsector = i; + break; + } + } + return nsector; +} + +public static int findIn16Sectors(int icomponent){ + // returns the sector number, corresponding to the component of the lower extreme of the interval + // sectors are numbered 0-16 + int[] sectorLimits = {0, 64, 128, 160, 192, 224, 256, 320, 352, 384, 416, 448, 512, 576, 608, 640, 704, 768}; + int nsector = -1; + for(int i=0; i<16; i++){ + if(icomponent>sectorLimits[i] && icomponent<=sectorLimits[i+1]){ + nsector = i; + break; + } + } + return nsector; +} + + +public boolean isInSector(int iSector, int icomponent){ + // returns ture is the strip icomponent is in the iSector sector + int[] sectorLimits = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + if(icomponent>sectorLimits[iSector] && icomponent<=sectorLimits[iSector+1]){ + return true; + }else{ + return false; + } +} + +public int adjustStripNumbering(int run, int ilayer, int icomponent){ + // adjustment of strip numbering valid for fall18 data + if(run>0){ // provisional + if(ilayer==1){ + ; + }else if(ilayer==2){ + //icomponent = flipStripVertical(ilayer, icomponent); + + }else if(ilayer==3){ + //icomponent = flipStripVertical(ilayer, icomponent); + + }else if(ilayer==4){ + ; + } + } + return icomponent; +} + + +public boolean isStripInSlot(int slot, int icomponent){ + // exits true if the strip is located in the group corresponding to one of the 12 fee slots (64 strips each) + // strips numeration in slots start from 1 to 768 + int[] slotLimits = {1, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768}; + // 12 slots, from 0 to 11, ordered according to the sequence: 0,1,2,3, 6,7,8,9, 4,5,10,11 + icomponent++; + boolean isInSlot = false; + switch(slot){ + case 0: + if(icomponent>=slotLimits[0] && icomponent<=slotLimits[1]) isInSlot = true; + break; + case 1: + if(icomponent>slotLimits[1] && icomponent<=slotLimits[2]) isInSlot = true; + break; + case 2: + if(icomponent>slotLimits[2] && icomponent<=slotLimits[3]) isInSlot = true; + break; + case 3: + if(icomponent>slotLimits[3] && icomponent<=slotLimits[4]) isInSlot = true; + break; + case 6: + if(icomponent>slotLimits[4] && icomponent<=slotLimits[5]) isInSlot = true; + break; + case 7: + if(icomponent>slotLimits[5] && icomponent<=slotLimits[6]) isInSlot = true; + break; + case 8: + if(icomponent>slotLimits[6] && icomponent<=slotLimits[7]) isInSlot = true; + break; + case 9: + if(icomponent>slotLimits[7] && icomponent<=slotLimits[8]) isInSlot = true; + break; + case 4: + if(icomponent>slotLimits[8] && icomponent<=slotLimits[9]) isInSlot = true; + break; + case 5: + if(icomponent>slotLimits[9] && icomponent<=slotLimits[10]) isInSlot = true; + break; + case 10: + if(icomponent>slotLimits[10] && icomponent<=slotLimits[11]) isInSlot = true; + break; + case 11: + if(icomponent>slotLimits[11] && icomponent<=slotLimits[12]) isInSlot = true; + break; + default: + break; + } + return isInSlot; +} + + +public boolean isStripInConnector(int iFEUConn, int ilayer, int icomponent) +{ + boolean isStripConnected = false; + // there are 12 connectors per layer, layers are numbered 1-4, FEUConnectors 0 to 11 + switch(iFEUConn){ + case 0: + if(ilayer==1){if(isStripInSlot(4, icomponent)) isStripConnected = true;} + else if(ilayer==2){if(isStripInSlot(6, icomponent)) isStripConnected = true;} + else if(ilayer==3){if(isStripInSlot(1, icomponent)) isStripConnected = true;} + else if(ilayer==4){if(isStripInSlot(2, icomponent)) isStripConnected = true;} + break; + case 1: + if(ilayer==1){if(isStripInSlot(7, icomponent)) isStripConnected = true;} + else if(ilayer==2){if(isStripInSlot(2, icomponent)) isStripConnected = true;} + else if(ilayer==3){if(isStripInSlot(1, icomponent)) isStripConnected = true;} + else if(ilayer==4){if(isStripInSlot(2, icomponent)) isStripConnected = true;} + break; + case 2: + if(ilayer==1){if(isStripInSlot(7, icomponent)) isStripConnected = true;} + else if(ilayer==2){if(isStripInSlot(7, icomponent)) isStripConnected = true;} + else if(ilayer==3){if(isStripInSlot(0, icomponent)) isStripConnected = true;} + else if(ilayer==4){if(isStripInSlot(1, icomponent)) isStripConnected = true;} + break; + case 3: + if(ilayer==1){if(isStripInSlot(0, icomponent)) isStripConnected = true;} + else if(ilayer==2){if(isStripInSlot(3, icomponent)) isStripConnected = true;} + else if(ilayer==3){if(isStripInSlot(5, icomponent)) isStripConnected = true;} + else if(ilayer==4){if(isStripInSlot(6, icomponent)) isStripConnected = true;} + break; + case 4: + if(ilayer==1){if(isStripInSlot(0, icomponent)) isStripConnected = true;} + else if(ilayer==2){if(isStripInSlot(6, icomponent)) isStripConnected = true;} + else if(ilayer==3){if(isStripInSlot(5, icomponent)) isStripConnected = true;} + else if(ilayer==4){if(isStripInSlot(6, icomponent)) isStripConnected = true;} + break; + case 5: + if(ilayer==1){if(isStripInSlot(4, icomponent)) isStripConnected = true;} + else if(ilayer==2){if(isStripInSlot(5, icomponent)) isStripConnected = true;} + else if(ilayer==3){if(isStripInSlot(3, icomponent)) isStripConnected = true;} + else if(ilayer==4){if(isStripInSlot(7, icomponent)) isStripConnected = true;} + break; + case 6: + if(ilayer==1){if(isStripInSlot(1, icomponent)) isStripConnected = true;} + else if(ilayer==2){if(isStripInSlot(0, icomponent)) isStripConnected = true;} + else if(ilayer==3){if(isStripInSlot(3, icomponent)) isStripConnected = true;} + else if(ilayer==4){if(isStripInSlot(5, icomponent)) isStripConnected = true;} + break; + case 7: + if(ilayer==1){if(isStripInSlot(3, icomponent)) isStripConnected = true;} + else if(ilayer==2){if(isStripInSlot(4, icomponent)) isStripConnected = true;} + else if(ilayer==3){if(isStripInSlot(1, icomponent)) isStripConnected = true;} + else if(ilayer==4){if(isStripInSlot(3, icomponent)) isStripConnected = true;} + break; + case 8: + if(ilayer==1){if(isStripInSlot(4, icomponent)) isStripConnected = true;} + else if(ilayer==2){if(isStripInSlot(7, icomponent)) isStripConnected = true;} + else if(ilayer==3){if(isStripInSlot(2, icomponent)) isStripConnected = true;} + else if(ilayer==4){if(isStripInSlot(5, icomponent)) isStripConnected = true;} + break; + case 9: + if(ilayer==1){if(isStripInSlot(0, icomponent)) isStripConnected = true;} + else if(ilayer==2){if(isStripInSlot(4, icomponent)) isStripConnected = true;} + else if(ilayer==3){if(isStripInSlot(1, icomponent)) isStripConnected = true;} + else if(ilayer==4){if(isStripInSlot(7, icomponent)) isStripConnected = true;} + break; + case 10: + if(ilayer==1){if(isStripInSlot(6, icomponent)) isStripConnected = true;} + else if(ilayer==2){if(isStripInSlot(2, icomponent)) isStripConnected = true;} + else if(ilayer==3){if(isStripInSlot(5, icomponent)) isStripConnected = true;} + else if(ilayer==4){if(isStripInSlot(4, icomponent)) isStripConnected = true;} + break; + case 11: + if(ilayer==1){if(isStripInSlot(3, icomponent)) isStripConnected = true;} + else if(ilayer==2){if(isStripInSlot(2, icomponent)) isStripConnected = true;} + else if(ilayer==3){if(isStripInSlot(1, icomponent)) isStripConnected = true;} + else if(ilayer==4){if(isStripInSlot(6, icomponent)) isStripConnected = true;} + break; + default: + break; + } + return isStripConnected; +} + +public boolean isStripInCrate(int nCrate, int ilayer, int icomponent){ + boolean isInCrate = false; + // check if the strip belongs to a given connector - connectors are numbered 1-12 + // icomponent is numberered 0-767 + int iConnector = findPhysicalConnector(icomponent); + // check if the connector belongs to the chosen crate + if(nCrate==1){ + if(ilayer==1){ + if(iConnector==1 || iConnector==2 || iConnector==3 || iConnector==4) isInCrate = true; + }else if(ilayer==2){ + if(iConnector==5 || iConnector==6 || iConnector==7 || iConnector==8) isInCrate = true; + }else if(ilayer==3){ + if(iConnector==5 || iConnector==6 || iConnector==7 || iConnector==8) isInCrate = true; + }else if(ilayer==4){ + if(iConnector==1 || iConnector==2 || iConnector==3 || iConnector==4) isInCrate = true; + } + }else if(nCrate==2){ + if(ilayer==1){ + if(iConnector==5 || iConnector==6 || iConnector==7 || iConnector==8) isInCrate = true; + }else if(ilayer==2){ + if(iConnector==1 || iConnector==2 || iConnector==3 || iConnector==4) isInCrate = true; + }else if(ilayer==3){ + if(iConnector==9 || iConnector==10 || iConnector==11 || iConnector==12) isInCrate = true; + }else if(ilayer==4){ + if(iConnector==9 || iConnector==10 || iConnector==11 || iConnector==12) isInCrate = true; + } + }else if(nCrate==3){ + if(ilayer==1){ + if(iConnector==9 || iConnector==10 || iConnector==11 || iConnector==12) isInCrate = true; + }else if(ilayer==2){ + if(iConnector==9 || iConnector==10 || iConnector==11 || iConnector==12) isInCrate = true; + }else if(ilayer==3){ + if(iConnector==1 || iConnector==2 || iConnector==3 || iConnector==4) isInCrate = true; + }else if(ilayer==4){ + if(iConnector==5 || iConnector==6 || iConnector==7 || iConnector==8) isInCrate = true; + } + }else{ + System.out.println("wrong crate number selected in FTTRKReconstruction"); + } + return isInCrate; +} + +public int findPhysicalConnector(int icomponent){ + // returns the number of the physical connector one strip belongs to + // physical connectors are numbered 1-12 + int iConnector = -1; + if(icomponent>=0 && icomponent <64){ + iConnector = 1; + }else if(icomponent>=64 && icomponent <128){ + iConnector = 2; + }else if(icomponent>=128 && icomponent <192){ + iConnector = 3; + }else if(icomponent>=192 && icomponent <256){ + iConnector = 4; + }else if(icomponent>=384 && icomponent <448){ + iConnector = 5; + }else if(icomponent>=448 && icomponent <512){ + iConnector = 6; + }else if(icomponent>=512 && icomponent <576){ + iConnector = 7; + }else if(icomponent>=576 && icomponent <640){ + iConnector = 8; + }else if(icomponent>=256 && icomponent <320){ + iConnector = 9; + }else if(icomponent>=320 && icomponent <384){ + iConnector = 10; + }else if(icomponent>=640 && icomponent <704){ + iConnector = 11; + }else if(icomponent>=704 && icomponent <768){ + iConnector = 12; + } + return iConnector; +} + +public int renumberStrip(int ilayer, int icomponent){ + // renumber strips from FEE number (to RECO numbering + // strips numbering 1-768 + int newStripNumber = -1; + if(ilayer==1){ + if((icomponent>=1 && icomponent <=128) || (icomponent>=641 && icomponent<=768)){ + newStripNumber = icomponent; + }else if(icomponent>128 && icomponent<=256){ + newStripNumber = icomponent+256; + }else if(icomponent>=257 && icomponent<=512){ + newStripNumber = icomponent-128; + }else if(icomponent>=513 && icomponent<=640){ + newStripNumber = icomponent; + } + }else if(ilayer==2 || ilayer==4 || ilayer==3){ + if(icomponent>=257 && icomponent <=512){ + newStripNumber = icomponent+128; + }else if(icomponent>=513 && icomponent <=640){ + newStripNumber = icomponent-256; + }else{ + newStripNumber = icomponent; + } + } + return (newStripNumber); +} + +public int renumberFEE2RECAndAdjust(int run, int ilayer, int icomponent){ +// apply the renumbering schema - method 2 + if(run>0){ + //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); + icomponent = renumberStrip(ilayer, icomponent); + if(ilayer==1 || ilayer==2 || ilayer==4) icomponent = flipStripVertical(ilayer, icomponent); + if(ilayer==3){ + int isec1 = findSector(icomponent); + if(isec1==11){ + icomponent = swapSectors(icomponent, 10); + }else if(isec1==10){ + icomponent = swapSectors(icomponent, 11); + } + // reverse sectors 10-11 + flip horizontal + int newsec = findSector(icomponent); + if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); + icomponent = flipStripHorizontal(ilayer, icomponent); + } + + } + return icomponent; +} + +public int renumberFEE2RECRotatedAndAdjust(int run, int ilayer, int icomponent){ +// apply the renumbering schema - method 2 + if(run>0){ + //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); + icomponent = renumberStrip(ilayer, icomponent); + + //if(ilayer==2) icomponent = flipStripVertical(ilayer, icomponent); + if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); + if(ilayer==3){ + int isec1 = findSector(icomponent); + if(isec1==11){ + icomponent = swapSectors(icomponent, 10); + }else if(isec1==10){ + icomponent = swapSectors(icomponent, 11); + } + // reverse sectors 10-11 + flip horizontal + int newsec = findSector(icomponent); + if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); + icomponent = flipStripHorizontal(ilayer, icomponent); + } + if(ilayer==1){ + int isec1 = findSector(icomponent); + /* + if(isec1==4){ + icomponent = swapSectors(icomponent, 2); + }else if(isec1==5){ + icomponent = swapSectors(icomponent, 3); + }else if(isec1==3){ + icomponent = swapSectors(icomponent, 4); + }else if(isec1==9){ + icomponent = swapSectors(icomponent, 17); + }else if(isec1==17){ + icomponent = swapSectors(icomponent, 9); + } + + int newsec = findSector(icomponent); + if(newsec == 2) icomponent = reverseStripsInSector(icomponent); +*/ + /* + if(isec1==10){ + icomponent = swapSectors(icomponent, 2); + }else if(isec1==3){ + icomponent = swapSectors(icomponent, 10); + } + int newsec = findSector(icomponent); + if(newsec == 2) icomponent = reverseStripsInSector(icomponent); + */ + /* + if(isec1==9){ + icomponent = swapSectors(icomponent, 3); + }else if(isec1==8){ + icomponent = swapSectors(icomponent, 4); + }else if(isec1==6){ + icomponent = swapSectors(icomponent, 5); + }else if(isec1==7){ + icomponent = swapSectors(icomponent, 6); + }else if(isec1==5){ + icomponent = swapSectors(icomponent, 7); + }else if(isec1==3){ + icomponent = swapSectors(icomponent, 8); + }else if(isec1==4){ + icomponent = swapSectors(icomponent, 9); + } + int newsec = findSector(icomponent); + if(newsec == 3 || newsec==7 || newsec==4) icomponent = reverseStripsInSector(icomponent); + */ + /* + if(isec1==18){ + icomponent = swapSectors(icomponent, 17); + }else if(isec1==17){ + icomponent = swapSectors(icomponent, 18); + } + */ + // prova Livio l2 + /* + if(isec1==3){ + icomponent = swapSectors(icomponent, 5); + }else if(isec1==4){ + icomponent = swapSectors(icomponent, 6); + }else if(isec1==5){ + icomponent = swapSectors(icomponent, 7); + }else if(isec1==6){ + icomponent = swapSectors(icomponent, 11); + }else if(isec1==7){ + icomponent = swapSectors(icomponent, 10); + }else if(isec1==8){ + icomponent = swapSectors(icomponent, 3); + }else if(isec1==9){ + icomponent = swapSectors(icomponent, 4); + }else if(isec1==10){ + icomponent = swapSectors(icomponent, 9); + }else if(isec1==11){ + icomponent = swapSectors(icomponent, 8); + } + int newsec = findSector(icomponent); + if( newsec==2 || newsec==9) icomponent = reverseStripsInSector(icomponent); + */ + /* + if(isec1==5){ + icomponent = swapSectors(icomponent, 9); + }else if(isec1==4){ + icomponent = swapSectors(icomponent, 8); + }else if(isec1==3){ + icomponent = swapSectors(icomponent, 7); + }else if(isec1==2){ + icomponent = swapSectors(icomponent, 6); + }else if(isec1==7){ + icomponent = reverseStripsInSector(icomponent); + icomponent = swapSectors(icomponent, 4); + }else if(isec1==8){ + icomponent = reverseStripsInSector(icomponent); + icomponent = swapSectors(icomponent, 3); + }else if(isec1==9){ + icomponent = reverseStripsInSector(icomponent); + icomponent = swapSectors(icomponent, 2); + } + */ + /* + if(isec1==5){ + icomponent = reverseStripsInSector(icomponent); + icomponent = swapSectors(icomponent, 7); + }else if(isec1==4){ + icomponent = swapSectors(icomponent, 8); + }else if(isec1==10){ + icomponent = swapSectors(icomponent, 9); + }else if(isec1==3){ + icomponent = swapSectors(icomponent, 10); + }else if(isec1==7){ + icomponent = reverseStripsInSector(icomponent); + icomponent = swapSectors(icomponent, 5); + }else if(isec1==8){ + icomponent = reverseStripsInSector(icomponent); + icomponent = swapSectors(icomponent, 4); + }else if(isec1==9){ + icomponent = reverseStripsInSector(icomponent); + icomponent = swapSectors(icomponent, 3); + }else if(isec1==5){ + icomponent = reverseStripsInSector(icomponent); + icomponent = swapSectors(icomponent, 7); + } + */ + + } + } + + return icomponent; +} + + + +} + + + + From f2ff6601d20aee4f1698c971cd08304fc5f6db33 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 29 Aug 2021 11:06:09 +0200 Subject: [PATCH 039/104] update for FTTRK energy/time studies --- etc/bankdefs/hipo/FT.json | 4 +++- etc/bankdefs/hipo4/ft.json | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/etc/bankdefs/hipo/FT.json b/etc/bankdefs/hipo/FT.json index 7dae4e1ba2..a176a75971 100644 --- a/etc/bankdefs/hipo/FT.json +++ b/etc/bankdefs/hipo/FT.json @@ -113,7 +113,9 @@ {"name":"y", "id":6, "type":"float", "info":"Cross Y position (cm)"}, {"name":"z", "id":7, "type":"float", "info":"Cross Z position (cm)"}, {"name":"energy", "id":8, "type":"float", "info":"Energy associated to the Cross"}, - {"name":"time", "id":9, "type":"float", "info":"Time associated to the Cross"} + {"name":"time", "id":9, "type":"float", "info":"Time associated to the Cross"}, + {"name":"Cluster1ID", "id":10, "type":"int16", "info":"ID of the bottom layer cluster in the Cross"}, + {"name":"Cluster2ID", "id":11, "type":"int16", "info":"ID of the top layer cluster in the Cross"} ] }, { diff --git a/etc/bankdefs/hipo4/ft.json b/etc/bankdefs/hipo4/ft.json index d6e5dee76a..f8a968fdd9 100644 --- a/etc/bankdefs/hipo4/ft.json +++ b/etc/bankdefs/hipo4/ft.json @@ -139,7 +139,9 @@ {"name":"y", "type":"F", "info":"Cross Y position (cm)"}, {"name":"z", "type":"F", "info":"Cross Z position (cm)"}, {"name":"energy", "type":"F", "info":"Energy assigned to the Cross"}, - {"name":"time", "type":"F", "info":"Time assigned to the Cross"} + {"name":"time", "type":"F", "info":"Time assigned to the Cross"}, + {"name":"Cluster1ID", "type":"S", "info":"ID of the bottom layer cluster in the Cross"}, + {"name":"Cluster2ID", "type":"S", "info":"ID of the top layer cluster in the Cross"} ] } From 018e7bba5b4f30068a8761dc3addef12d0699f6a Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 14:29:14 +0100 Subject: [PATCH 040/104] update --- .../java/org/jlab/rec/ft/FTConstants.java | 4 +- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 106 +++++- .../java/org/jlab/rec/ft/FTEventBuilder.java | 5 + .../main/java/org/jlab/rec/ft/FTParticle.java | 11 +- .../jlab/rec/ft/cal/FTCALReconstruction.java | 38 +- .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 20 +- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 332 +++++++++++++++++- 7 files changed, 482 insertions(+), 34 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java index b5c9c89911..fa81ee3745 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java @@ -23,7 +23,7 @@ public class FTConstants { - public static final double TRK_MIN_CROSS_NUMBER = 2; // minimum number of crosses to find a line in the tracker + public static final double TRK_MIN_CROSS_NUMBER = 1; // minimum number of crosses to find a line in the tracker // public static final double TRK0_TRK1_DISTANCE_MATCHING = 0.25; // matching distance between FTTRK points in cms // public static final double TOLERANCE_ON_CROSSES_TWO_DETECTORS = 0.; // 1. cm radius tolerance, tune it up // public static final double TRK0_TRK1_RADTOL = 2.5; // max tolerance for TRK0/TRK1 distance (3D) @@ -37,7 +37,7 @@ public class FTConstants { public static final double FTTRKMinAdcThreshold = 18.; // check min threshold for FTTTRK ADCs (18) public static final double FTTRKMaxAdcThreshold = 1000.; // check max threshold for FTTTRK ADCs (18) public static final double TRK_MIN_CLUS_ENERGY = 20.; // minimum cluster energy to accept a signal cluster (20) - public static final int TRK_MIN_CLUS_SIZE = 1; // minimum cluster size to form crosses (0: no limit on cluster size) // 2 is very strict + public static final int TRK_MIN_CLUS_SIZE = 0; // minimum cluster size to form crosses (0: no limit on cluster size) // 2 is very strict } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index c18930da4b..ee4becb217 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -179,7 +179,8 @@ public static void main(String arg[]){ /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_withFields_big_-30.60.120.30.hipo"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance.hipo"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_dis.hipo"; - String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; +////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418.0.hipo"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -390,19 +391,40 @@ public static void main(String arg[]){ H2F h2001 = new H2F("Montecarlo radiography at second FTTRK det", 100, -15., 15., 100, -15, 15.); h2001.setTitleX("x (mm)"); h2001.setTitleY("y (mm)"); - + JFrame frameCALTRK = new JFrame("radiography FTCAL hits and FTTRK Crosses"); frameCALTRK.setSize(1500,500); EmbeddedCanvas canvasCALTRK = new EmbeddedCanvas(); canvasCALTRK.divide(3,1); + H1F h71 = new H1F("hOccupancyMatchedSeed1", 768, 0., 769.); h71.setTitleX("Component layer 1"); + h71.setLineColor(1); h71.setFillColor(51); + H1F h72 = new H1F("hOccupancyMatchedSeed2", 768, 0., 769.); h72.setTitleX("Component layer 2"); + h72.setLineColor(1); h72.setFillColor(52); + H1F h73 = new H1F("hOccupancyMatchedSeed3", 768, 0., 769.); h73.setTitleX("Component layer 3"); + h73.setLineColor(1); h73.setFillColor(53); + H1F h74 = new H1F("hOccupancyMatchedSeed4", 768, 0., 769.); h74.setTitleX("Component layer 4"); + h74.setLineColor(1); h74.setFillColor(54); + + H1F h81 = new H1F("hOccupancyMatched1", 768, 0., 769.); h81.setTitleX("Component layer 1"); + h81.setLineColor(1); h81.setFillColor(31); + H1F h82 = new H1F("hOccupancyMatched2", 768, 0., 769.); h82.setTitleX("Component layer 2"); + h82.setLineColor(1); h82.setFillColor(32); + H1F h83 = new H1F("hOccupancyMatched3", 768, 0., 769.); h83.setTitleX("Component layer 3"); + h83.setLineColor(1); h83.setFillColor(33); + H1F h84 = new H1F("hOccupancyMatched4", 768, 0., 769.); h84.setTitleX("Component layer 4"); + h84.setLineColor(1); h84.setFillColor(34); + + + int nev = 0; int nevWithCrosses = 0; while (reader.hasEvent()) { // run over all events // int nev1 = 0; int nev2 = 10000; for(nev=nev1; nev=0){ float xt = banktrk.getFloat("x", nc); float yt = banktrk.getFloat("y", nc); @@ -493,7 +518,47 @@ public static void main(String arg[]){ segment1.setEnd(seg1.end().x(), seg1.end().y()); segment2.setEnd(seg2.end().x(), seg2.end().y()); - } + // extract the mumber of strips forming the cross and store them in an occupancy plot for matched signals + // which strips are forming the id cross? + + if(lay1==1){ + h71.fill(seed1); + }else if(lay1==2){ + h72.fill(seed1); + }else if(lay1==3){ + h73.fill(seed1); +; }else if(lay1==4){ + h74.fill(seed1); + } + if(lay2==1){ + h71.fill(seed2); + }else if(lay2==2){ + h72.fill(seed2); + }else if(lay2==3){ + h73.fill(seed2); +; }else if(lay2==4){ + h74.fill(seed2); + } + + DataBank bankhit = event.getBank("FTTRK::hits"); + if(bankhit.rows()>0){ + for(int k=0; k addResponses(DataEvent event, ConstantsManager manager, resp.setCrTime(FTTRKReconstruction.crTime[i]); ////////////////////////////// resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); + //debugMode = 2; if(debugMode>=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); responses.add(resp); } @@ -239,6 +240,10 @@ public void matchToTRK(List responses, List particles) { track.setCharge(-999); // provisional, for no field tracking track.setTrackerIndex(responses.get(iTrk).getId()); responses.get(iTrk).setAssociation(i); + responses.get(iTrk).setMatchPosition(track.getPosition().x(), track.getPosition().y(), track.getPosition().z()); + System.out.println("matched cross coordinates " + responses.get(iTrk).getPosition().x() + " " + responses.get(iTrk).getPosition().y()); + }else{ + // wrong cross coordinates need to be deleted } if (debugMode >= 1) track.show(); } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index 1074990732..fe71e63c95 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -179,6 +179,8 @@ public int getDetectorHit(List hitList, String detectorType, double minimumDistance = hitdistance; bestIndex = loop; System.out.println("best hit distance and time " + minimumDistance + " " + timedistance); + System.out.println("cross center coordinates x, y " + response.getPosition().toPoint3D().x() + " , " + + response.getPosition().toPoint3D().y()); }else if(detectorType=="FTHODO" && timedistance hitList, String detectorType, double // if bestHit is on hodo require at least two hits overall on HODO if(detectorType=="HODO"){if(hitList.get(bestIndex).getSize()= FTConstants.TRK_MIN_CROSS_NUMBER){ + ; + }else{ + bestIndex=-1; + } + } } return bestIndex; } + public void show() { System.out.println( "FT Particle info " + " Charge = "+ this.getCharge() + diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java index e272c7c82c..a5cb78945f 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java @@ -269,8 +269,42 @@ public List readRawHitsHipo(DataEvent event, IndexedTable charge2Energ if(adc!=-1 && time!=-1){ FTCALHit hit = new FTCALHit(row,icomponent, adc, time, charge2Energy, timeOffsets, timeWalk, cluster); // if(icomponent>=90 && icomponent<=98) hits.add(hit); // select only crystals in a given region -// if(icomponent>= 90 && icomponent<=107) -// if(icomponent == 92) +// if(icomponent>= 69 && icomponent<=84) +// vertical strip of crystals, right side +/* + if(icomponent == 61 || icomponent == 83 || icomponent == 105 || icomponent == 127 || + icomponent == 149 || icomponent == 193 || icomponent == 215 || icomponent == 237 || + icomponent == 259 || icomponent == 281 || icomponent == 303 || icomponent == 325 || + icomponent == 347 || icomponent == 369 || icomponent == 391 || icomponent == 413 || icomponent == 435) +*/ +// vertical strip of crystals, left side +/* + if(icomponent == 27 || icomponent == 49 || icomponent == 71 || icomponent == 93 || + icomponent == 115 || icomponent == 137 || icomponent == 159 || icomponent == 181 || + icomponent == 203 || icomponent == 225 || icomponent == 247 || icomponent == 269 || + icomponent == 291 || icomponent == 313 || icomponent == 335 || icomponent == 357 || + icomponent == 379 || icomponent == 401 || icomponent == 423 || icomponent == 445 ) +*/ +// vertical strip of crystals, left side central +/* + if(icomponent == 10 || icomponent == 32 || icomponent == 54 || icomponent == 76 || + icomponent == 98 || icomponent == 120 || icomponent == 142 || icomponent == 340 || + icomponent == 362 || icomponent == 384 || icomponent == 406 || icomponent == 428 || + icomponent == 450 || icomponent == 472 ) + */ +// vertical strip of crystals, right side central +/* + if(icomponent == 11 || icomponent == 33 || icomponent == 55 || icomponent == 77 || + icomponent == 99 || icomponent == 121 || icomponent == 143 || icomponent == 341 || + icomponent == 363 || icomponent == 385 || icomponent == 407 || icomponent == 429 || + icomponent == 451 || icomponent == 473 ) +*/ +// top half +// if(icomponent >= 242) +// bottom half + // if(icomponent <= 241) + +// if(icomponent == 92) // if(icomponent == 105) // if(icomponent == 400) // if(icomponent == 412) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java index 5bdce509ef..dfd94d2c78 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java @@ -141,7 +141,8 @@ public static void main (String arg[]) { // String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_dis.hipo"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; - String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; +////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418.0.hipo"; // String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_fullAcceptance_singleTrack.hipo"; System.out.println("input file " + input); HipoDataSource reader = new HipoDataSource(); @@ -170,13 +171,13 @@ public static void main (String arg[]) { H1F h1clEn = new H1F("Cluster energy", 100, 0., 1000.); h1clEn.setOptStat(Integer.parseInt("1111")); h1clEn.setTitleX("centroid energy of clusters"); H1F hOccupancy1 = new H1F("hOccupancy1", 768, 0., 769.); hOccupancy1.setTitleX("Component layer 1"); - hOccupancy1.setLineColor(1); hOccupancy1.setFillColor(1); + hOccupancy1.setLineColor(1); hOccupancy1.setFillColor(1); hOccupancy1.setOptStat(11); H1F hOccupancy2 = new H1F("hOccupancy2", 768, 0., 769.); hOccupancy2.setTitleX("Component layer 2"); - hOccupancy2.setLineColor(1); hOccupancy2.setFillColor(2); + hOccupancy2.setLineColor(1); hOccupancy2.setFillColor(2); hOccupancy2.setOptStat(11); H1F hOccupancy3 = new H1F("hOccupancy3", 768, 0., 769.); hOccupancy3.setTitleX("Component layer 3"); - hOccupancy3.setLineColor(1); hOccupancy3.setFillColor(3); + hOccupancy3.setLineColor(1); hOccupancy3.setFillColor(3); hOccupancy3.setOptStat(11); H1F hOccupancy4 = new H1F("hOccupancy4", 768, 0., 769.); hOccupancy4.setTitleX("Component layer 4"); - hOccupancy4.setLineColor(1); hOccupancy4.setFillColor(4); + hOccupancy4.setLineColor(1); hOccupancy4.setFillColor(4); hOccupancy4.setOptStat(11); H1F hStripDiff1 = new H1F("hStripDiff1", 10, -5.5, 4.5); hStripDiff1.setTitleX("Strip difference layer 1"); hStripDiff1.setOptStat(Integer.parseInt("1111")); hStripDiff1.setLineColor(1); hStripDiff1.setFillColor(1); @@ -219,8 +220,8 @@ public static void main (String arg[]) { int nc1 = 0, nc2 = 0, ncmatch = 0; int nev=0; -// while(reader.hasEvent()){ - int nev1 = 0; int nev2 = 10000; for(nev=nev1; nev=1) System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~ processing event ~~~~~~~~~~~ " + nev); // if(nev != 8) continue; // select one event only for debugging purposes @@ -294,7 +295,7 @@ public static void main (String arg[]) { maxcomp4 = bank.getShort("component", imax4); } - + /* // iterate along the cluster list for every event if(debug>=1) System.out.println("clusters size --- " + clusters.size()); if(clusters.size()!=0){ @@ -416,7 +417,8 @@ public static void main (String arg[]) { } } } - } + } +*/ } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index 95535820cd..023c5d0636 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -431,6 +431,7 @@ public List readRawHits(DataEvent event, int run) { DataBank bankDGTZ = event.getBank("FTTRK::adc"); int nrows = bankDGTZ.rows(); int hitId = -1; + int nsec1 = -1, nsec2 = -1; for(int row = 0; row < nrows; row++){ int isector = bankDGTZ.getInt("sector",row); int ilayer = bankDGTZ.getInt("layer",row); @@ -476,10 +477,10 @@ public List readRawHits(DataEvent event, int run) { // read just layer sectors only for real data (no montecarlo) //icomponent = adjustStripNumberingTest11(run, ilayer, icomponent); - //icomponent = renumberStrip(ilayer, icomponent); - icomponent = renumberFEE2RECRotatedAndAdjust(run, ilayer, icomponent); - - +// icomponent = renumberStrip(ilayer, icomponent); +// icomponent = renumberFEE2RECRotatedAndAdjustVanilla(run, ilayer, icomponent); + icomponent = renumberFEE2RECRotatedAndAdjustHazel(run, ilayer, icomponent); + /* // layer 3: swap 6-7 e inversione if(ilayer==3){ @@ -591,8 +592,17 @@ public List readRawHits(DataEvent event, int run) { } */ + boolean isHitAccepted = true; + // select strips belonging to a crate (1-2-3) -/// if(isStripInCrate(1, ilayer, icomponent)) hits.add(hit); +// if(isStripInCrate(1, ilayer, icomponent)) hits.add(hit); + + if(isStripInCrate(1, ilayer, icomponent)){ + isHitAccepted = true; + }else{ + isHitAccepted = false; + } + // select strips belonging to a given physical connector in a layer // int iconn = findPhysicalConnector(icomponent); // if(ilayer==2 && iconn==6) hits.add(hit); // bad connector @@ -606,13 +616,31 @@ public List readRawHits(DataEvent event, int run) { if(ilayer==4 && icomponent>=119 && icomponent<=384) hits.add(hit); */ - boolean isHitAccepted = true; // if(ilayer == 2 || ilayer ==3) isHitAccepted = false; // if((ilayer==2) && icomponent<=641) isHitAccepted = false; -// if((ilayer==4) && icomponent>=1 && icomponent>64) isHitAccepted = false; +// if((ilayer==4) && icomponent>=1 && icomponent>64) isHitAccepted = false; + +// strip sector selection in layer 1-2 +/* + if(ilayer==1){ + nsec1 = findIn12Sectors(icomponent); + if(nsec1!=10 && nsec1!=11) isHitAccepted = false; + } + if(ilayer==2){ + nsec2 = findIn12Sectors(icomponent); + if(nsec2 ==6){ + System.out.println("layer 2 sector 6 " + icomponent); +// if(icomponent-64*6 > 32.){icomponent = -1;}else{icomponent = 200;} + }else{ + icomponent = -1; + } + } +// if(nsec1 !=5) isHitAccepted = false; +*/ // selection on strip time if(time < 50 || time > 350) isHitAccepted = false; + if(icomponent<0) isHitAccepted = false; if(isHitAccepted) hits.add(hit); //////////////////////////////////////////////////////////////////////////////////////// @@ -1132,9 +1160,20 @@ public int reverseStripsInSector(int icomponent){ int offset = sectorLimit[nsector+1] - icomponent; icomponent = sectorLimit[nsector] + offset; - return icomponent; + return icomponent; } - + +public int reverseStripsIn12Sectors(int icomponent){ + // flip the layer horizontally with respect to the x axis (top/bottom flip) + int[] sectorLimit = {0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768}; + int nsector = findIn12Sectors(icomponent); + int offset = sectorLimit[nsector+1] - icomponent; + icomponent = sectorLimit[nsector] + offset; + + return icomponent; +} + + public int swapSectors(int icomponent, int nsector2){ // get the new strip number of the icomponent strip in nsector1 once the sector is swapped to nsector2 int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; @@ -1145,6 +1184,31 @@ public int swapSectors(int icomponent, int nsector2){ return newicomp; } +public int swap12Sectors(int icomponent, int nsector2){ + // get the new strip number of the icomponent strip in nsector1 once the sector is swapped to nsector2 + //int[] sectorLimits = {0, 64, 128, 192, 256, 320, 384, 498, 512, 576, 640, 704, 768}; + int[] sectorNumber = {0, 1, 2, 3, 8, 9, 4, 5, 6, 7, 10, 11 }; + int[] sectorLimits = {0, 64, 128, 192, 256, 448, 512, 576, 640, 320, 384, 704, 768}; + int[] sectorLimitsSequential = {0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768}; + int[] sectorNumberSequential = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + int nsector1 = findIn12Sectors(icomponent); + int secidx1 = -1; + int secidx2 = -1; + /* + for(int i=0; i<11; i++){ + if(sectorNumberSequential[i] == nsector1) secidx1 = i; + if(sectorNumberSequential[i] == nsector2) secidx2 = i; + } + */ + int offset = -sectorLimitsSequential[nsector1] + icomponent; + int newicomp = sectorLimitsSequential[nsector2] + offset; + + return newicomp; +} + + + + public static int findSector(int icomponent){ // returns the sector number, corresponding to the component of the lower extreme of the interval // sectors are numbered 0-20 @@ -1159,6 +1223,24 @@ public static int findSector(int icomponent){ return nsector; } +public static int findIn12Sectors(int icomponent){ + // returns the sector number, corresponding to the component of the lower extreme of the interval + // sectors are numbered 0-11 + //int[] sectorLimits = {0, 64, 128, 192, 256, 320, 384, 498, 512, 576, 640, 704, 768}; + int[] sectorLimits = {0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768}; + int[] sectorNumber = {0, 1, 2, 3, 8, 9, 4, 5, 6, 7, 10, 11 }; + int nsector = -1; + for(int i=0; i<12; i++){ + if(icomponent>sectorLimits[i] && icomponent<=sectorLimits[i+1]){ +// nsector = sectorNumber[i]; + nsector = i; + break; + } + } + return nsector; +} + + public static int findIn16Sectors(int icomponent){ // returns the sector number, corresponding to the component of the lower extreme of the interval // sectors are numbered 0-16 @@ -1341,7 +1423,7 @@ public boolean isStripInCrate(int nCrate, int ilayer, int icomponent){ boolean isInCrate = false; // check if the strip belongs to a given connector - connectors are numbered 1-12 // icomponent is numberered 0-767 - int iConnector = findPhysicalConnector(icomponent); + int iConnector = findOrderedConnector(icomponent); // check if the connector belongs to the chosen crate if(nCrate==1){ if(ilayer==1){ @@ -1379,6 +1461,38 @@ public boolean isStripInCrate(int nCrate, int ilayer, int icomponent){ return isInCrate; } +public int findOrderedConnector(int icomponent){ + // returns the number of the physical connector one strip belongs to + // physical connectors are numbered 1-12 + int iConnector = -1; + if(icomponent>=0 && icomponent <64){ + iConnector = 1; + }else if(icomponent>=64 && icomponent <128){ + iConnector = 2; + }else if(icomponent>=128 && icomponent <192){ + iConnector = 3; + }else if(icomponent>=192 && icomponent <256){ + iConnector = 4; + }else if(icomponent>=384 && icomponent <448){ + iConnector = 7; + }else if(icomponent>=448 && icomponent <512){ + iConnector = 8; + }else if(icomponent>=512 && icomponent <576){ + iConnector = 9; + }else if(icomponent>=576 && icomponent <640){ + iConnector = 10; + }else if(icomponent>=256 && icomponent <320){ + iConnector = 5; + }else if(icomponent>=320 && icomponent <384){ + iConnector = 6; + }else if(icomponent>=640 && icomponent <704){ + iConnector = 11; + }else if(icomponent>=704 && icomponent <768){ + iConnector = 12; + } + return iConnector; +} + public int findPhysicalConnector(int icomponent){ // returns the number of the physical connector one strip belongs to // physical connectors are numbered 1-12 @@ -1409,7 +1523,8 @@ public int findPhysicalConnector(int icomponent){ iConnector = 12; } return iConnector; -} +} + public int renumberStrip(int ilayer, int icomponent){ // renumber strips from FEE number (to RECO numbering @@ -1466,8 +1581,11 @@ public int renumberFEE2RECRotatedAndAdjust(int run, int ilayer, int icomponent){ //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); icomponent = renumberStrip(ilayer, icomponent); - //if(ilayer==2) icomponent = flipStripVertical(ilayer, icomponent); +// if(ilayer==2) icomponent = flipStripHorizontal(ilayer, icomponent); +// if(ilayer==1) icomponent = overturnModule(ilayer, icomponent); if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); +// if(ilayer==2) icomponent = overturnModule(ilayer, icomponent); + if(ilayer==3){ int isec1 = findSector(icomponent); if(isec1==11){ @@ -1480,13 +1598,97 @@ public int renumberFEE2RECRotatedAndAdjust(int run, int ilayer, int icomponent){ if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); icomponent = flipStripHorizontal(ilayer, icomponent); } + + + if(ilayer==2){ + int isec1 = findIn12Sectors(icomponent); +// if(isec1 == 1 || isec1==6 || isec1 == 10){ +// icomponent = -1; +// } + } + + +/* + if(isec1 == 6) icomponent = -1; + if(isec1 == 0){ + icomponent = swap12Sectors(icomponent, 11); + }else if(isec1 == 1){ + icomponent = swap12Sectors(icomponent, 10); + }else if(isec1 == 11){ + icomponent = swap12Sectors(icomponent, 0); + }else if(isec1 == 10){ + icomponent = swap12Sectors(icomponent, 1); + } + int newsec = findIn12Sectors(icomponent); + if( newsec==0 || newsec==1 || newsec ==10 || newsec==11) icomponent = reverseStripsIn12Sectors(icomponent); + if(newsec==1 || newsec==10) icomponent = -1; +*/ + //} + + if(ilayer==1){ - int isec1 = findSector(icomponent); + + int isec1 = findIn12Sectors(icomponent); + /* + if(isec1==2){ + icomponent = swap12Sectors(icomponent, 9); +// icomponent = -1; + }else if(isec1==9){ + icomponent = swap12Sectors(icomponent, 2); + }else if(isec1==3){ + icomponent = swap12Sectors(icomponent, 6); + //icomponent = -1; + }else if(isec1==6){ + icomponent = swap12Sectors(icomponent, 3); + } + int newsec = findIn12Sectors(icomponent); + if(newsec == 2 || newsec == 9) icomponent = reverseStripsIn12Sectors(icomponent); + if(newsec==3){ + icomponent = swap12Sectors(icomponent, 2); +// icomponent = -1; + }else if(newsec==2){ + icomponent = swap12Sectors(icomponent, 3); + }else if(newsec==9){ + icomponent = swap12Sectors(icomponent, 6); + } + */ + + // good + + if(isec1==3){ +// icomponent = reverseStripsInSector(icomponent); +// icomponent = swap12Sectors(icomponent, 2); +// icomponent = -1; + }else if(isec1==6){ + icomponent = swap12Sectors(icomponent, 10); + }else if(isec1==8){ + icomponent = swap12Sectors(icomponent, 11); +// icomponent = -1; + }else if(isec1==4){ +// icomponent = -1; +// icomponent = swap12Sectors(icomponent, 6); + }else if(isec1==2){ +// icomponent = reverseStripsIn12Sectors(icomponent); + //icomponent = swap12Sectors(icomponent, 3); + } + + /* + int isec2 = findIn12Sectors(icomponent); + if(isec2==3){ + icomponent = swap12Sectors(icomponent, 6); + icomponent = reverseStripsIn12Sectors(icomponent); + } + */ + +// int newsec1 = findIn12Sectors(icomponent); +// if(newsec1!=2) icomponent = -1; + + /* if(isec1==4){ icomponent = swapSectors(icomponent, 2); }else if(isec1==5){ - icomponent = swapSectors(icomponent, 3); + icomponent = swapSectors(icomponent, 3); }else if(isec1==3){ icomponent = swapSectors(icomponent, 4); }else if(isec1==9){ @@ -1497,7 +1699,7 @@ public int renumberFEE2RECRotatedAndAdjust(int run, int ilayer, int icomponent){ int newsec = findSector(icomponent); if(newsec == 2) icomponent = reverseStripsInSector(icomponent); -*/ + */ /* if(isec1==10){ icomponent = swapSectors(icomponent, 2); @@ -1609,8 +1811,106 @@ public int renumberFEE2RECRotatedAndAdjust(int run, int ilayer, int icomponent){ } +public int renumberFEE2RECRotatedAndAdjustVanilla(int run, int ilayer, int icomponent){ +// apply the renumbering schema - method 2 + if(run>0){ + //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); + icomponent = renumberStrip(ilayer, icomponent); + + /* + if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); + if(ilayer==3){ + int isec1 = findSector(icomponent); + if(isec1==11){ + icomponent = swapSectors(icomponent, 10); + }else if(isec1==10){ + icomponent = swapSectors(icomponent, 11); + } + // reverse sectors 10-11 + flip horizontal + int newsec = findSector(icomponent); + if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); + icomponent = flipStripHorizontal(ilayer, icomponent); + } + */ + } + + return icomponent; +} -} + +public int renumberFEE2RECRotatedAndAdjustHazel(int run, int ilayer, int icomponent){ +// apply the renumbering schema - method 2 + if(run>0){ + //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); + icomponent = renumberStrip(ilayer, icomponent); + + if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); + if(ilayer==3){ + // consider 16 sectors division + int isec1 = findSector(icomponent); + if(isec1==11){ + icomponent = swapSectors(icomponent, 10); + }else if(isec1==10){ + icomponent = swapSectors(icomponent, 11); + } + // reverse sectors 10-11 + flip horizontal + int newsec = findSector(icomponent); + if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); + icomponent = flipStripHorizontal(ilayer, icomponent); + } + + if(ilayer==2){ + int isec1 = findIn12Sectors(icomponent); +// if(isec1 == 1 || isec1==6 || isec1 == 10) icomponent = -1; +// if(isec1 != 10){icomponent = -1;} + } + + + if(ilayer==1){ + int isec1 = findIn12Sectors(icomponent); + + // good + /* + if(isec1==3){ +// icomponent = reverseStripsInSector(icomponent); +// icomponent = swap12Sectors(icomponent, 2); +// icomponent = -1; + }else if(isec1==6){ + icomponent = swap12Sectors(icomponent, 10); + }else if(isec1==8){ + icomponent = swap12Sectors(icomponent, 11); +// icomponent = -1; + }else if(isec1==4){ +// icomponent = -1; +// icomponent = swap12Sectors(icomponent, 6); + }else if(isec1==2){ +// icomponent = reverseStripsIn12Sectors(icomponent); + //icomponent = swap12Sectors(icomponent, 3); + } + */ + +// if(isec1 != 10 && isec1 != 11) icomponent = -1; + + //if(isec1 != 4) icomponent = -1; + if(isec1 == 4){ +// icomponent = swap12Sectors(icomponent, 10); +// icomponent = -1; + } + + + } + if(ilayer==3){ + int isec1 = findIn12Sectors(icomponent); + //if(isec1 != 8) icomponent = -1; + } + + } + + return icomponent; +} + +} + From 19562597be671907966cb64bd477d8ad9b8b6bb9 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 15:16:13 +0100 Subject: [PATCH 041/104] add FT::particles bank locations for TRK0 and TRK1 detectors --- etc/bankdefs/hipo4/ft.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/etc/bankdefs/hipo4/ft.json b/etc/bankdefs/hipo4/ft.json index f8a968fdd9..4a5b1977f5 100644 --- a/etc/bankdefs/hipo4/ft.json +++ b/etc/bankdefs/hipo4/ft.json @@ -87,7 +87,8 @@ {"name":"time", "type":"F", "info":"track Time" }, {"name":"calID", "type":"S", "info":"pointer to cluster bank"}, {"name":"hodoID", "type":"S", "info":"pointer to signal bank"}, - {"name":"trkID", "type":"S", "info":"pointer to cross banks"} + {"name":"trk0ID", "type":"S", "info":"pointer to first cross bank"}, + {"name":"trk1ID", "type":"S", "info":"pointer to second cross bank"} ] }, @@ -119,7 +120,7 @@ {"name":"id", "type":"S", "info":"Cluster ID"}, {"name":"sector", "type":"B", "info":"Cluster sector"}, {"name":"layer", "type":"B", "info":"Cluster layer"}, - {"name":"energy", "type":"F", "info":"Cluster total energy"}, + {"name":"energy", "type":"F", "info":"Hit Energy" }, {"name":"maxEnergy", "type":"F", "info":"Seed energy"}, {"name":"seed", "type":"S", "info":"Seed strip"}, {"name":"centroid", "type":"F", "info":"Centroid strip number"} @@ -138,8 +139,8 @@ {"name":"x", "type":"F", "info":"Cross X position (cm)"}, {"name":"y", "type":"F", "info":"Cross Y position (cm)"}, {"name":"z", "type":"F", "info":"Cross Z position (cm)"}, - {"name":"energy", "type":"F", "info":"Energy assigned to the Cross"}, - {"name":"time", "type":"F", "info":"Time assigned to the Cross"}, + {"name":"energy", "type":"F", "info":"Cross Energy" }, + {"name":"time", "type":"F", "info":"Cross Time" }, {"name":"Cluster1ID", "type":"S", "info":"ID of the bottom layer cluster in the Cross"}, {"name":"Cluster2ID", "type":"S", "info":"ID of the top layer cluster in the Cross"} ] From 1507877219ae67832740e631dc3828d6992d4fd5 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 15:16:50 +0100 Subject: [PATCH 042/104] update --- build-coatjava.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-coatjava.sh b/build-coatjava.sh index 47a5f39d03..1f4ec02ef3 100755 --- a/build-coatjava.sh +++ b/build-coatjava.sh @@ -30,7 +30,8 @@ do done wget='wget' -mvn='mvn' +#mvn='mvn' +mvn='/usr/local/apache-maven-3.6.3/bin/mvn' if [ "$quiet" == "yes" ] then wget='wget --progress=dot:mega' From 33af445f035490a79f7449efd218034dafe08cad Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 15:25:16 +0100 Subject: [PATCH 043/104] tuning of TRK constants for reco --- .../java/org/jlab/rec/ft/FTConstants.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java index fa81ee3745..8cfe5d580e 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java @@ -16,28 +16,29 @@ public class FTConstants { public static final double CAL_HODO_DISTANCE_MATCHING = 3.0; // matching distance in cm public static final double CAL_HODO_TIME_MATCHING = 8; // matching time in ns (it was 8) -// public static final double CAL_TRK_DISTANCE_MATCHING = 1.5; // matching distance in cm -// public static final double CAL_TRK_TIME_MATCHING = 30; // matching time in ns TOBECORRECTED - public static final double CAL_TRK_DISTANCE_MATCHING = 3.; // matching distance in cm (it was 3) - public static final double CAL_TRK_TIME_MATCHING = 100; // matching time in ns TOBECORRECTED (it was 300) - + public static final double CAL_TRK_DISTANCE_MATCHING = 3.; // matching distance in cm (it was 1.5) + public static final double CAL_TRK_TIME_MATCHING = 200; // matching time in ns TOBECORRECTED (it was 30 - 300 - 100 - 150) + public static final double TRK_STRIP_MIN_TIME = 50; // minimum time value associated to one strip + public static final double TRK_STRIP_MAX_TIME = 350; // minimum time value associated to one strip public static final double TRK_MIN_CROSS_NUMBER = 1; // minimum number of crosses to find a line in the tracker // public static final double TRK0_TRK1_DISTANCE_MATCHING = 0.25; // matching distance between FTTRK points in cms // public static final double TOLERANCE_ON_CROSSES_TWO_DETECTORS = 0.; // 1. cm radius tolerance, tune it up -// public static final double TRK0_TRK1_RADTOL = 2.5; // max tolerance for TRK0/TRK1 distance (3D) + public static final double TRK0_TRK1_RADTOL = 1.; // max tolerance for TRK0/TRK1 distance (3D) /// public static final double TRK0_TRK1_RADTOL = 0.5; // max tolerance for TRK0/TRK1 radial distance (2D) /// public static final double TRK0_TRK1_PHITOL = 0.07; // max tolerance for TRK0/TRK1 phi angular deviation /// public static final double TRK0_TRK1_THETATOL = 0.07; // max tolerance for TRK0/TRK1 theta angulare deviation - public static final double TRK0_TRK1_RADTOL = 10.; // max tolerance for TRK0/TRK1 radial distance (2D) - public static final double TRK0_TRK1_PHITOL = 1.; // max tolerance for TRK0/TRK1 phi angular deviation - public static final double TRK0_TRK1_THETATOL = 1.; // max tolerance for TRK0/TRK1 theta angulare deviation +// public static final double TRK0_TRK1_RADTOL = 10.; // max tolerance for TRK0/TRK1 radial distance (2D) +// public static final double TRK0_TRK1_PHITOL = 1.; // max tolerance for TRK0/TRK1 phi angular deviation +// public static final double TRK0_TRK1_THETATOL = 1.; // max tolerance for TRK0/TRK1 theta angulare deviation + public static final double TRK0_TRK1_PHITOL = 0.7; // max tolerance for TRK0/TRK1 phi angular deviation + public static final double TRK0_TRK1_THETATOL = 0.7; public static final double FTTRKMinAdcThreshold = 18.; // check min threshold for FTTTRK ADCs (18) - public static final double FTTRKMaxAdcThreshold = 1000.; // check max threshold for FTTTRK ADCs (18) + public static final double FTTRKMaxAdcThreshold = 2000.; // check max threshold for FTTTRK ADCs (18) was 1000 170122 + public static final int TRK_MAX_StripsForTruncatedMean = 20; // threshold for maxnumber of strips included in the truncated mean algo. public static final double TRK_MIN_CLUS_ENERGY = 20.; // minimum cluster energy to accept a signal cluster (20) public static final int TRK_MIN_CLUS_SIZE = 0; // minimum cluster size to form crosses (0: no limit on cluster size) // 2 is very strict - - + public static final int TRK_MAXNUMBEROFHITS = 100; // maximum number of accepted hits in the tracker banks } From cf9b4533bd03d4d2dc7d3824a9ec3cd58c74cb04 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 15:27:37 +0100 Subject: [PATCH 044/104] add new trkDet private member for detector number --- .../ft/src/main/java/org/jlab/rec/ft/FTResponse.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java index 24059b2c92..adfa85f6ba 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java @@ -16,6 +16,7 @@ public class FTResponse extends DetectorResponse { private String _type; // FTCAL, FTHODO, FTTRK private int _size; // cluster multiplicity private int _id; // response ID + private int _trkDet; private float _crTime; // provisional: detector time (for crosses only: the location in the bank is overwritten) private float _crEnergy; // provisional: detector energy (for crosses only same reason) @@ -51,6 +52,15 @@ public int getId() { public void setId(int id) { this._id = id; } + + public int getTrkDet() { + return _trkDet; + } + + public void setTrkDet(int ndet) { + this._trkDet = ndet; + } + /////////////////////////// provisional (info must be present in banks) public void setCrTime(float crTime){ From e3f89db87c7cc63702aab21a66f5bb42e1ed3b53 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 15:30:44 +0100 Subject: [PATCH 045/104] add two private member for crosses in both TRK detectors, remove single cross reference and update methods --- .../main/java/org/jlab/rec/ft/FTParticle.java | 73 ++++++++++++++++--- 1 file changed, 62 insertions(+), 11 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index fe71e63c95..c2c967fe11 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -18,7 +18,9 @@ public class FTParticle { private Vector3D _Direction = new Vector3D(); // direction private int _Cluster; // track pointer to cluster information in FTCALRec::cluster bank private int _Signal; // track pointer to signal information in FTHODORec::cluster bank - private int _Cross; // track pointer to cross information in FTTRKRec::cross bank +// private int _Cross; // track pointer to cross information in FTTRKRec::cross bank + private int _Cross0; // track pointer to cross information in FTTRKRec::cross bank (TRK0) + private int _Cross1; // track pointer to cross information in FTTRKRec::cross bank (TRK1) private double _field; // constructor @@ -135,18 +137,27 @@ public void setHodoscopeIndex(int _Signal) { this._Signal = _Signal; } - +/* public int getTrackerIndex() { return _Cross; } +*/ + + public int getTrackerIndex(int ndet) { + if(ndet==0){return _Cross0;}else{return _Cross1;} + } - +/* public void setTrackerIndex(int _Cross) { this._Cross = _Cross; } +*/ + public void setTrackerIndex(int _Cross, int ndet) { + if(ndet==0){this._Cross0 = _Cross;}else{this._Cross1 = _Cross;} + } + public int getDetectorHit(List hitList, String detectorType, double distanceThreshold, double timeThreshold){ - Line3D cross = this.getLastCross(); double minimumDistance = 500.0; int bestIndex = -1; @@ -159,9 +170,10 @@ public int getDetectorHit(List hitList, String detectorType, double // FTEBEngine.h600.fill(timedistance); // FTEBEngine.h601.fill(response.getTime()); +/* if(detectorType=="FTTRK") { double t=response.getTime(); - System.out.println(this.getTime() + " to be compard to " + response.getPosition().mag()/PhysicsConstants.speedOfLight()); + System.out.println(this.getTime() + " to be compared to " + response.getPosition().mag()/PhysicsConstants.speedOfLight()); FTEBEngine.h600.fill(response.getPosition().mag()/PhysicsConstants.speedOfLight()); FTEBEngine.h601.fill(response.getCrTime(), response.getPosition().mag()/PhysicsConstants.speedOfLight()); if(response.getId()==0){ @@ -171,7 +183,8 @@ public int getDetectorHit(List hitList, String detectorType, double FTEBEngine.h603.fill(response.getCrTime()); } } - +*/ + // if(detectorType=="FTHODO") FTEBEngine.h502.fill(timedistance); // if((timedistanceTRK || timedistance<2.*timeThreshold) && hitdistance hitList, String detectorType, double if(detectorType=="HODO"){if(hitList.get(bestIndex).getSize()= FTConstants.TRK_MIN_CROSS_NUMBER){ - ; - }else{ - bestIndex=-1; - } + if(hitList.get(bestIndex).getSize() >= FTConstants.TRK_MIN_CROSS_NUMBER){;}else{bestIndex=-1;} } } return bestIndex; } + public int[] getTRKBestHits(List hitList, int it, double distanceThreshold, double timeThreshold){ + Line3D cross = this.getLastCross(); + double minimumDistance = 500.0; + int[] bestIndex = {-1, -1}; + for(int loop = 0; loop < hitList.size(); loop++){ + int bestidx = -1; + FTResponse response = hitList.get(loop); + if(response.getAssociation()<0 && response.getType() == "FTTRK"){ + Line3D dist = cross.distance(response.getPosition().toPoint3D()); + double hitdistance = dist.length(); + double timedistance = Math.abs(this.getTime() - (response.getTime()-response.getPosition().mag()/PhysicsConstants.speedOfLight())); + + double t=response.getTime(); + int det = response.getTrkDet(); + if(it==0){ + // fill energy and time histograms only once per set or hits on FTTRK + FTEBEngine.h600.fill(response.getPosition().mag()/PhysicsConstants.speedOfLight()); + FTEBEngine.h601.fill(response.getCrTime(), response.getPosition().mag()/PhysicsConstants.speedOfLight()); + if(det==0){ // non e' Id ma trkDet + FTEBEngine.h602.fill(response.getCrTime()); + }else if(det==1){ + FTEBEngine.h603.fill(response.getCrTime()); + } + } + +// if(timedistance-1){ + if(hitList.get(bestidx).getSize() < FTConstants.TRK_MIN_CROSS_NUMBER) bestidx=-1; + bestIndex[det] = bestidx; + } + } + } + return bestIndex; + } + + public void show() { System.out.println( "FT Particle info " + " Charge = "+ this.getCharge() + From 9e037f66467428bfe4f5efe94fb0a25e4024a918 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 15:34:29 +0100 Subject: [PATCH 046/104] adapts methods to two crosses information, banks writeup, new method matchToTRKTwoDetectors for matching FTParticle to response from both TRK detectors --- .../java/org/jlab/rec/ft/FTEventBuilder.java | 64 +++++++++++++++++-- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index 5f81281eee..4fbff9d801 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -14,6 +14,7 @@ import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Vector3D; import org.jlab.geom.prim.Point3D; +import org.jlab.rec.ft.trk.FTTRKConstantsLoader; import org.jlab.rec.ft.trk.FTTRKReconstruction; public class FTEventBuilder { @@ -153,6 +154,17 @@ public List addResponses(DataEvent event, ConstantsManager manager, resp.setCrTime(FTTRKReconstruction.crTime[i]); ////////////////////////////// resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); + /// detector id (it is not the cross id) + double zCoord = bank.getFloat("z", i); + + if(zCoord >= FTTRKConstantsLoader.Zlayer[0] && zCoord <= FTTRKConstantsLoader.Zlayer[1]){ + resp.setTrkDet(0); + }else{ + resp.setTrkDet(1); + } + + + //debugMode = 2; if(debugMode>=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); responses.add(resp); @@ -192,7 +204,9 @@ public List initFTparticles(List responses) { track.setTime(responses.get(i).getTime() - responses.get(i).getPosition().mag() / PhysicsConstants.speedOfLight()); track.setCalorimeterIndex(responses.get(i).getId()); track.setHodoscopeIndex(-1); - track.setTrackerIndex(-1); + //track.setTrackerIndex(-1); + track.setTrackerIndex(-1, 0); + track.setTrackerIndex(-1, 1); particles.add(track); responses.get(i).setAssociation(particles.size()-1); } @@ -238,8 +252,10 @@ public void matchToTRK(List responses, List particles) { System.out.println("found signal in FTTRK" + iTrk); } track.setCharge(-999); // provisional, for no field tracking - track.setTrackerIndex(responses.get(iTrk).getId()); + track.setTrackerIndex(responses.get(iTrk).getId(), responses.get(iTrk).getTrkDet()); // here trkID is set to the index of the matched track responses.get(iTrk).setAssociation(i); + // if the cross is matched to the track set the cross id as negative + if(responses.get(iTrk).getAssociation()==0) responses.get(iTrk).setId(-responses.get(iTrk).getId()); responses.get(iTrk).setMatchPosition(track.getPosition().x(), track.getPosition().y(), track.getPosition().z()); System.out.println("matched cross coordinates " + responses.get(iTrk).getPosition().x() + " " + responses.get(iTrk).getPosition().y()); }else{ @@ -249,6 +265,39 @@ public void matchToTRK(List responses, List particles) { } } + public void matchToTRKTwoDetectors(List responses, List particles) { + for (int i = 0; i < particles.size(); i++) { + FTParticle track = particles.get(i); + if (debugMode >= 1) { + System.out.println("Searching for matching signal in the tracker:"); + } + //int[] iTrk = track.getTRKBestHits(responses, FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); + int[] iTrk = {-1, -1}; + iTrk = track.getTRKBestHits(responses, i, FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); + for(int j=0; j<2; j++){ // loop on two detectors + if (iTrk[j] > 0) { + if (debugMode >= 1) { + System.out.println("found signal in FTTRK" + iTrk[j]); + } + + track.setCharge(-999); // provisional, for no field tracking + track.setTrackerIndex(responses.get(iTrk[j]).getId(), j); // here trkIS is set to the index of the matched track +//// track.setTrackerIndex(iTrk[j], j); +// responses.get(iTrk[j]).setId(iTrk[j]); + responses.get(iTrk[j]).setHitIndex(iTrk[j]); + responses.get(iTrk[j]).setAssociation(i); + //responses.get(iTrk[j]).getCross and change the index of the cross + responses.get(iTrk[j]).setMatchPosition(track.getPosition().x(), track.getPosition().y(), track.getPosition().z()); + System.out.println("matched cross coordinates " + responses.get(iTrk[j]).getPosition().x() + " " + + responses.get(iTrk[j]).getPosition().y()); + }else{ + // wrong cross coordinates need to be deleted + } + } + if (debugMode >= 1) track.show(); + } + } + public void matchToFTCal(List responses, List particles) { for (int i = 0; i < particles.size(); i++) { @@ -270,7 +319,7 @@ public void matchToFTCal(List responses, List particles) System.out.println("found signal in FTTRK" + iTrk); } track.setCharge(-999); // provisional, for no field tracking - track.setTrackerIndex(responses.get(iTrk).getId()); + track.setTrackerIndex(responses.get(iTrk).getId(), responses.get(iTrk).getTrkDet()); responses.get(iTrk).setAssociation(i); } @@ -332,7 +381,9 @@ public void writeBanks(DataEvent event, List particles) { banktrack.setDouble("Time", i, particles.get(i).getTime()); banktrack.setInt("CalID", i, particles.get(i).getCalorimeterIndex()); banktrack.setInt("HodoID", i, particles.get(i).getHodoscopeIndex()); - banktrack.setInt("TrkID", i, particles.get(i).getTrackerIndex()); + banktrack.setInt("Trk0ID", i, particles.get(i).getTrackerIndex(0)); +// banktrack.setInt("trkID", i, particles.get(i).getTrackerIndex(0)); + banktrack.setInt("Trk1ID", i, particles.get(i).getTrackerIndex(1)); if (debugMode >= 1) { particles.get(i).show(); } @@ -355,7 +406,10 @@ public void writeBanks(DataEvent event, List particles) { banktrack.setFloat("time", i, (float) particles.get(i).getTime()); banktrack.setShort("calID", i, (short) particles.get(i).getCalorimeterIndex()); banktrack.setShort("hodoID", i, (short) particles.get(i).getHodoscopeIndex()); - banktrack.setShort("trkID", i, (short) particles.get(i).getTrackerIndex()); +// banktrack.setShort("trkID", i, (short) particles.get(i).getTrackerIndex()); + banktrack.setShort("trk0ID", i, (short) particles.get(i).getTrackerIndex(0)); + banktrack.setShort("trk1ID", i, (short) particles.get(i).getTrackerIndex(1)); + if (debugMode >= 1) { particles.get(i).show(); System.out.println(particles.get(i).getDirection().x() + " " + particles.get(i).getDirection().y() + " " + particles.get(i).getDirection().z()); From f0402c43420fece9800097eb7d5750dd5db503e6 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 15:37:13 +0100 Subject: [PATCH 047/104] new histograms and output for diagnostics --- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 495 +++++++++++++++--- 1 file changed, 426 insertions(+), 69 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index ee4becb217..49cef76a52 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -18,12 +18,14 @@ import org.jlab.groot.data.H1F; import org.jlab.groot.data.H2F; import org.jlab.groot.data.DataLine; +import org.jlab.groot.ui.LatexText; import org.jlab.groot.math.F1D; import org.jlab.groot.fitter.DataFitter; import org.jlab.groot.graphics.EmbeddedCanvas; import org.jlab.groot.base.DatasetAttributes; import org.jlab.groot.base.GStyle; import org.jlab.groot.base.TColorPalette; +import org.jlab.groot.data.GraphErrors; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.io.evio.EvioDataBank; @@ -72,7 +74,8 @@ public boolean processDataEvent(DataEvent event) { FTresponses = reco.addResponses(event, this.getConstantsManager(), run); FTparticles = reco.initFTparticles(FTresponses); if(FTparticles.size()>0){ - reco.matchToTRK(FTresponses, FTparticles); +//// reco.matchToTRK(FTresponses, FTparticles); + reco.matchToTRKTwoDetectors(FTresponses, FTparticles); reco.matchToHODO(FTresponses, FTparticles); // reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo reco.writeBanks(event, FTparticles); @@ -161,6 +164,11 @@ public int getDebugMode() { public static H1F h602 = new H1F("cross0 time", 100, 0.0001, 500.); public static H1F h603 = new H1F("cross1 time", 100, 0.0001, 500.); + public static H2F hSecDet0 = new H2F("lay 2 vs lay1 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); + public static H2F hSecDet1 = new H2F("lay 4 vs lay3 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); + public static H2F hSeedDet0 = new H2F("lay 2 vs lay1 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); + public static H2F hSeedDet1 = new H2F("lay 4 vs lay3 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); + public static void main(String arg[]){ @@ -176,12 +184,22 @@ public static void main(String arg[]){ // String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/elec_nofield_header.evio"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30_fullAcceptance.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_withFields_big_-30.60.120.30.hipo"; +/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_singleEle_withFields_big_-30.60.120.30_newbanks.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_test_1000.hipo"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance.hipo"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_dis.hipo"; ////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; - String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418.0.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; +////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418.0.hipo"; // dontuse + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; +/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/ft_005038_01231_newbanks.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/data_merge.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_154824_det0.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_153947_det1.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_160427_det1.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/twoHits_10239.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_10730.hipo"; +// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; +/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance_newbanks.hipo"; HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -418,13 +436,22 @@ public static void main(String arg[]){ int nev = 0; - int nevWithCrosses = 0; + int nevWithCrosses = 0, ncrosses2 = 0; while (reader.hasEvent()) { // run over all events // int nev1 = 0; int nev2 = 10000; for(nev=nev1; nev=1) System.out.println("////////////// event read " + bankEvt + " - sequential number " + nev); + //if(nev > 10239) System.exit(0); if(nev != 10239) continue; cal.processDataEvent(event); hodo.processDataEvent(event); trk.processDataEventAndGetClusters(event); @@ -452,7 +479,7 @@ public static void main(String arg[]){ } else { DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); PhysicsEvent gen = detectorEvent.getGeneratedEvent(); - nev++; +// nev++; if (event.hasBank("FT::particles")) { DataBank bank = event.getBank("FT::particles"); int nrows = bank.rows(); @@ -475,16 +502,44 @@ public static void main(String arg[]){ } // check match with trk bank (entry trkID) - int trkID = bank.getShort("trkID", i); - if(trkID > 0){ // accept all fired strips if trkID >-1, only hits connected with a track if >0 +// int trkID = bank.getShort("trkID", i); + int trk0ID = bank.getShort("trk0ID", i); // it should correspond to the number of the cross in the banks + int trk1ID = bank.getShort("trk1ID", i); + if(trk0ID >= 0 || trk1ID >= 0){ // at least one cross is present on one TRK det + // loop on crosses bank DataBank banktrk = event.getBank("FTTRK::crosses"); int ncrosses = banktrk.rows(); + // how many matched crosses are associated to a given track? + int matchedCrosses = 0; + for(int nc=0; nc=0){ float xt = banktrk.getFloat("x", nc); float yt = banktrk.getFloat("y", nc); @@ -492,25 +547,54 @@ public static void main(String arg[]){ Vector3D hitOnTrk = new Vector3D(xt, yt, zt); // extract information on the crossed strips - float icl1 = banktrk.getFloat("energy", nc); // Cluster1ID provisional to be changed - float icl2 = banktrk.getFloat("time", nc); // cluster2ID provisional to be changes +// float icl1 = banktrk.getFloat("energy", nc); // Cluster1ID provisional to be changed +// float icl2 = banktrk.getFloat("time", nc); // cluster2ID provisional to be changes + float icl1 = banktrk.getShort("Cluster1ID", nc); + float icl2 = banktrk.getShort("Cluster2ID", nc); DataBank bankcl = event.getBank("FTTRK::clusters"); + // which is the correct location in the cluster bank for the cluster with the given id? + int icl1ok = -1; + int icl2ok = -1; + for(int k=0; k0){ - segment1.setOrigin(0.,0.); segment1.setEnd(0.,0.); - segment2.setOrigin(0.,0.); segment2.setEnd(0.,0.); - int seed1 = bankcl.getInt("seed", (int)icl1); - int seed2 = bankcl.getInt("seed", (int)icl2); - int lay1 = bankcl.getInt("layer", (int)icl1); - int lay2 = bankcl.getInt("layer", (int)icl2); - System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ seed1, seed2 " + seed1 + " " + seed2 + " layer1 layer2 " + lay1 + " " + lay2); - System.out.println("~~~~~~~~~~ hit strip 1: " + seed1 + " layer " + lay1 + " sector " + + segment1.setOrigin(0.,0.); segment1.setEnd(0.,0.); + segment2.setOrigin(0.,0.); segment2.setEnd(0.,0.); + seed1 = bankcl.getInt("seed", (int)icl1ok); + seed2 = bankcl.getInt("seed", (int)icl2ok); + int cent1 = (int)bankcl.getFloat("centroid", icl1ok); + int cent2 = (int)bankcl.getFloat("centroid", icl2ok); + // if the cluster is formed by > 3 strips take the centroid + int clustsize1 = bankcl.getShort("size", icl1ok); + int clustsize2 = bankcl.getShort("size", icl2ok); + if(clustsize1>=3){ + int sector = FTTRKReconstruction.findSector(seed1); + if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed1 = cent1; + } + if(clustsize2>=3){ + int sector = FTTRKReconstruction.findSector(seed2); + if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed2 = cent2; + } + // if seed and centroid dont coincide, take the geometric centroid as seed + //if(cent1 != seed1) seed1 = cent1; + //if(cent2 != seed2) seed2 = cent2; + int lay1 = bankcl.getInt("layer", (int)icl1ok); + int lay2 = bankcl.getInt("layer", (int)icl2ok); + System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ seed1, seed2 " + seed1 + " " + seed2 + " layer1 layer2 " + lay1 + " " + lay2); + System.out.println("~~~~~~~~~~ hit strip 1: " + seed1 + " layer " + lay1 + " sector " + FTTRKReconstruction.findSector(seed1)); - System.out.println("~~~~~~~~~~ hit strip 2: " + seed2 + " layer " + lay2 + " sector " + + System.out.println("~~~~~~~~~~ hit strip 2: " + seed2 + " layer " + lay2 + " sector " + FTTRKReconstruction.findSector(seed2)); - if(seed1!=0 && seed2!=0){ + if(seed1!=0 && seed2!=0){ + System.out.println("seed2" + seed2); Line3D seg1 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay1, seed1); Line3D seg2 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay2, seed2); segment1.setOrigin(seg1.origin().x(), seg1.origin().y()); @@ -521,47 +605,48 @@ public static void main(String arg[]){ // extract the mumber of strips forming the cross and store them in an occupancy plot for matched signals // which strips are forming the id cross? - if(lay1==1){ - h71.fill(seed1); - }else if(lay1==2){ - h72.fill(seed1); - }else if(lay1==3){ - h73.fill(seed1); -; }else if(lay1==4){ - h74.fill(seed1); - } - if(lay2==1){ - h71.fill(seed2); - }else if(lay2==2){ - h72.fill(seed2); - }else if(lay2==3){ - h73.fill(seed2); -; }else if(lay2==4){ - h74.fill(seed2); - } + if(lay1==1){ + h71.fill(seed1); + }else if(lay1==2){ + h72.fill(seed1); + }else if(lay1==3){ + h73.fill(seed1); +; }else if(lay1==4){ + h74.fill(seed1); + } - DataBank bankhit = event.getBank("FTTRK::hits"); - if(bankhit.rows()>0){ - for(int k=0; k0){ + for(int k=0; k0){ // System.out.println("coordinates on calorimeter " + bank.getDouble("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); @@ -574,20 +659,68 @@ public static void main(String arg[]){ h104.fill(bank.getFloat("cy", i) *zt - yt); h106.fill((part.theta() - hitOnTrk.theta())); h108.fill((part.phi() - hitOnTrk.phi())); - + int sec1 = FTTRKReconstruction.findSector(seed1); + int sec2 = FTTRKReconstruction.findSector(seed2); + hSecDet0.fill(sec1, sec2); + hSeedDet0.fill(seed1, seed2); + /* + if(sec1 == 1 && sec2 == 10){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1-10 bad seeds d0, event " + nev); + }else if(sec1 == 10 && sec2 == 10){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 10-10 bad seeds d0, event " + nev); + }else if(sec1 == 10 && sec2 == 11){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 10-11 bad seeds d0, event " + nev); + }else if(sec1 == 16 && sec2 == 8){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 16-8 bad seeds d0, event " + nev); + }else if(sec1 == 16 && sec2 == 8){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 16-8 bad seeds d0, event " + nev); + }else if(sec1 == 1 && sec2 == 11){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1-11 bad seeds d0, event " + nev); + }else if(sec1 == 11 && sec2 == 15){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 11-15 bad seeds d0, event " + nev); + }else if(sec1 == 12 && sec2 == 16){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 12-16 bad seeds d0, event " + nev); + }else if(sec1 == 13 && sec2 == 11){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 13-11 bad seeds d0, event " + nev); + } + */ + /* + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + + " bad seeds d0, event " + nev); + */ canvasCALTRK.cd(0); segment1.setLineColor(1); segment2.setLineColor(2); canvasCALTRK.draw(segment1); canvasCALTRK.draw(segment2); - }else if(det==1){ + }else if(det==1 && trk1ID==crossID){ h101.fill(xt, yt); h103.fill(bank.getFloat("cx", i) *zt - xt); h105.fill(bank.getFloat("cy", i) *zt - yt); h107.fill((part.theta() - hitOnTrk.theta())); h109.fill((part.phi() - hitOnTrk.phi())); - + int sec1 = FTTRKReconstruction.findSector(seed1); + int sec2 = FTTRKReconstruction.findSector(seed2); + hSecDet1.fill(sec1, sec2); + hSeedDet1.fill(seed1, seed2); + /* + if(sec1 == 0 && sec2 == 8){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 0-8 bad seeds d1, event " + nev); + }else if(sec1 == 12 && sec2 == 10){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 12-10 bad seeds d1, event " + nev); + }else if(sec1 == 3 && sec2 == 18){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3-18 bad seeds d1, event " + nev); + }else if(sec1 == 12 && sec2 == 9){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 12-9 bad seeds d1, event " + nev); + }else if(sec1 == 2 && sec2 == 18){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 2-18 bad seeds d1, event " + nev); + } + */ + /* + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + + " bad seeds d1, event " + nev); + */ canvasCALTRK.cd(1); segment1.setLineColor(3); segment2.setLineColor(4); @@ -810,7 +943,7 @@ public static void main(String arg[]){ frame.setLocationRelativeTo(null); frame.setVisible(true); - double narrowFactor = 4.5; + double narrowFactor = 6.5; // was 4.5 JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); frametrk.setSize(1600, 800); EmbeddedCanvas canvastrk = new EmbeddedCanvas(); @@ -1125,6 +1258,7 @@ public static void main(String arg[]){ frametrkrel.setLocationRelativeTo(null); frametrkrel.setVisible(true); + /* JFrame frameMCradio = new JFrame("Montecarlo radiography of vertex"); frameMCradio.setSize(1000,500); EmbeddedCanvas canvasMCradio = new EmbeddedCanvas(); @@ -1136,7 +1270,230 @@ public static void main(String arg[]){ frameMCradio.add(canvasMCradio); frameMCradio.setLocationRelativeTo(null); frameMCradio.setVisible(true); - + */ + + JFrame frameSecradio = new JFrame("20 sectors occupancy"); + frameSecradio.setSize(1000,500); + EmbeddedCanvas canvasSecradio = new EmbeddedCanvas(); + canvasSecradio.divide(2,1); + canvasSecradio.cd(0); + canvasSecradio.draw(hSecDet0); + // excluded cells + double excx0h1[] = {0., 1., 2., 3., 4., 5., 10., 11., 12., 13.}; + double excy0h1[] = {10., 11., 12., 13., 14., 15., 16., 17.}; + GraphErrors excludedDet0half1 = new GraphErrors(); + for(int i=0; i Date: Thu, 10 Feb 2022 15:40:06 +0100 Subject: [PATCH 048/104] slim FTEBEngine for single event debugging --- .../jlab/rec/ft/FTEBEngineSingleEvent.java | 1488 +++++++++++++++++ 1 file changed, 1488 insertions(+) create mode 100755 reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java new file mode 100755 index 0000000000..359abb5999 --- /dev/null +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java @@ -0,0 +1,1488 @@ +package org.jlab.rec.ft; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JFrame; +import org.jlab.clas.detector.DetectorData; +import org.jlab.clas.detector.DetectorEvent; + +import org.jlab.clas.physics.GenericKinematicFitter; +import org.jlab.clas.physics.PhysicsEvent; +import org.jlab.clas.reco.ReconstructionEngine; +import org.jlab.geom.prim.Line3D; +import org.jlab.geom.prim.Point3D; +import org.jlab.geom.prim.Vector3D; +import org.jlab.groot.data.H1F; +import org.jlab.groot.data.H2F; +import org.jlab.groot.data.DataLine; +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.math.F1D; +import org.jlab.groot.fitter.DataFitter; +import org.jlab.groot.graphics.EmbeddedCanvas; +import org.jlab.groot.base.DatasetAttributes; +import org.jlab.groot.base.GStyle; +import org.jlab.groot.base.TColorPalette; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.io.evio.EvioDataBank; +import org.jlab.io.evio.EvioDataEvent; +import org.jlab.io.hipo.HipoDataSource; +import org.jlab.rec.ft.cal.FTCALConstantsLoader; +import org.jlab.rec.ft.cal.FTCALEngine; +import org.jlab.rec.ft.hodo.FTHODOEngine; +import org.jlab.rec.ft.trk.FTTRKEngine; +import org.jlab.rec.ft.trk.FTTRKConstantsLoader; +import org.jlab.rec.ft.trk.FTTRKReconstruction; + +public class FTEBEngineSingleEvent extends ReconstructionEngine { + + FTEventBuilder reco; + int Run = -1; + double Solenoid; + + public FTEBEngineSingleEvent() { + super("FTEB", "devita", "3.0"); + } + + @Override + public boolean init() { + reco = new FTEventBuilder(); + reco.debugMode = 0; + String[] tables = new String[]{ + "/calibration/ft/ftcal/cluster", + "/calibration/ft/ftcal/thetacorr", + "/calibration/ft/ftcal/phicorr" + }; + requireConstants(Arrays.asList(tables)); + this.getConstantsManager().setVariation("default"); + + return true; + } + + @Override + public boolean processDataEvent(DataEvent event) { + List FTparticles = new ArrayList(); + List FTresponses = new ArrayList(); + + int run = this.setRunConditionsParameters(event); + if (run>=0) { + reco.init(this.getSolenoid()); + FTresponses = reco.addResponses(event, this.getConstantsManager(), run); + FTparticles = reco.initFTparticles(FTresponses); + if(FTparticles.size()>0){ +//// reco.matchToTRK(FTresponses, FTparticles); + reco.matchToTRKTwoDetectors(FTresponses, FTparticles); + reco.matchToHODO(FTresponses, FTparticles); +// reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo + reco.writeBanks(event, FTparticles); + } + } + return true; + } + + public int setRunConditionsParameters(DataEvent event) { + int run = -1; + if (event.hasBank("RUN::config") == false) { + System.err.println("RUN CONDITIONS NOT READ!"); + } + else { + double fieldScale = 0; + + boolean isMC = false; + boolean isCosmics = false; + + if (event instanceof EvioDataEvent) { + EvioDataBank bank = (EvioDataBank) event.getBank("RUN::config"); + if (bank.getByte("Type",0) == 0) { + isMC = true; + } + if (bank.getByte("Mode",0)== 1) { + isCosmics = true; + } + run = bank.getInt("Run",0); + fieldScale = bank.getFloat("Solenoid")[0]; + } else { + DataBank bank = event.getBank("RUN::config"); + if (bank.getByte("type",0) == 0) { + isMC = true; + } + if (bank.getByte("mode",0)== 1) { + isCosmics = true; + } + run = bank.getInt("run",0); + fieldScale = bank.getFloat("solenoid",0); + } + this.setSolenoid(fieldScale); + } + return run; + } + + public int getRun() { + return Run; + } + + public void setRun(int run) { + Run = run; + } + + public double getSolenoid() { + return Solenoid; + } + + public void setSolenoid(double Solenoid) { + this.Solenoid = Solenoid; + } + + public int getDebugMode() { + return this.reco.debugMode; + } + + public static H1F h500 = new H1F("Time Difference FTCAL-response", 100, 0., 200.); + public static H1F h501 = new H1F("Cross Energy TRK0", 100, 0., 2000.); + public static H1F h502 = new H1F("Cross Energy TRK1", 100, 0., 2000.); + public static H1F h503 = new H1F("Cross time TRK0", 100, 0.0, 500.); + public static H1F h504 = new H1F("Cross time TRK1", 100, 0.0, 500.); + public static H2F h505 = new H2F("Cross energy vs time TRK0", 100, 0.0, 500., 100, 0., 2000.); + public static H2F h506 = new H2F("Cross energy vs time TRK1", 100, 0.0, 500., 100, 0., 2000.); + public static H2F h507 = new H2F("Cross energy vs time TRK0+1", 100, 0.0, 500., 100, 0., 2000.); + public static H2F h510 = new H2F("Clusters total energies TRK0", 100, 0., 2000., 100, 0., 2000.); + public static H2F h511 = new H2F("Clusters total energies TRK1", 100, 0., 2000., 100, 0., 2000.); + public static H1F h512 = new H1F("Clusters total energies TRK0", 100, 0., 2000.); + public static H1F h513 = new H1F("Clusters total energies TRK1", 100, 0., 2000.); + public static H1F h520 = new H1F("Time of strips in cluster1 TRK0", 100, 0., 500.); + public static H1F h521 = new H1F("Time of strips in cluster2 TRK0", 100, 0., 500.); + public static H1F h522 = new H1F("time of strips in cluster1 TRK1", 100, 0., 500.); + public static H1F h523 = new H1F("Time of strips in cluster2 TRK1", 100, 0., 500.); + + + public static H1F h600 = new H1F("TRK response position", 100, 5.93, 6.03); + public static H2F h601 = new H2F("TRK tof vs time", 100, 0., 500., 100, 5.93, 6.03); + public static H1F h602 = new H1F("cross0 time", 100, 0.0001, 500.); + public static H1F h603 = new H1F("cross1 time", 100, 0.0001, 500.); + + public static H2F hSecDet0 = new H2F("lay 2 vs lay1 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); + public static H2F hSecDet1 = new H2F("lay 4 vs lay3 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); + + + public static void main(String arg[]){ + + FTCALEngine cal = new FTCALEngine(); + cal.init(); + FTHODOEngine hodo = new FTHODOEngine(); + hodo.init(); + FTTRKEngine trk = new FTTRKEngine(); + trk.init(); + FTEBEngine en = new FTEBEngine(); + en.init(); + int debugMode = en.getDebugMode(); +// String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/elec_nofield_header.evio"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30_fullAcceptance.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_withFields_big_-30.60.120.30.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_dis.hipo"; +////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; +////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418.0.hipo"; // dontuse +////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_154824_det0.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_153947_det1.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_160427_det1.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/twoHits_10298.hipo"; + String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_92897.hipo"; +/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; + HipoDataSource reader = new HipoDataSource(); + reader.open(input); + + // initialize histos + H1F h1 = new H1F("Cluster Energy", 100, 0., 8.); + h1.setOptStat(Integer.parseInt("11111")); + h1.setTitleX("Cluster Energy (GeV)"); + H1F h2 = new H1F("Energy Resolution", 100, -1, 1); + h2.setOptStat(Integer.parseInt("11111")); + h2.setTitleX("Energy Resolution(GeV)"); + H1F h3 = new H1F("Theta Resolution", 100, -1, 1); + h3.setOptStat(Integer.parseInt("11111")); + h3.setTitleX("Theta Resolution(deg)"); + H1F h4 = new H1F("Phi Resolution", 100, -10, 10); + h4.setOptStat(Integer.parseInt("11111")); + h4.setTitleX("Phi Resolution(deg)"); + + H1F h5 = new H1F("Time Resolution", 100, -2, 2); + h5.setOptStat(Integer.parseInt("1111")); + h5.setTitleX("Time Resolution(ns)"); + H2F h6 = new H2F("Cluster Energy", 24, -180., 180., 24, -180., 180.); + h6.setTitleX("x (cm)"); + h6.setTitleY("y (cm)"); + H2F h7 = new H2F("N. Clusters", 24, -18., 18., 24, -18., 18.); + h7.setTitleX("x (mm)"); + h7.setTitleY("y (mm)"); + H2F h8 = new H2F("Cluster Energy", 100, 0., 9., 100, -0.5, 0.5); + h8.setTitleX("E (GeV)"); + h8.setTitleY("Energy Resolution(GeV)"); + H2F h9 = new H2F("Cluster Energy", 100, 2., 5., 100, -0.5, 0.5); + h9.setTitleX("#theta"); + h9.setTitleY("Energy Resolution(GeV)"); + H2F h10 = new H2F("Cluster Energy", 100, -180., 180., 100, -0.5, 0.5); + h10.setTitleX("#phi"); + h10.setTitleY("Energy Resolution(GeV)"); + + // residual plots (of TRK wrt tracking on ECAL - black histograms) + H2F h100 = new H2F("Cross on trk layer1", 100, -18., 18., 100, -18., 18.); + h100.setTitleX("x (mm) trk1"); + h100.setTitleY("y (mm) trk1"); + H2F h101 = new H2F("Cross on trk layer2", 100, -18., 18., 100, -18., 18.); + h101.setTitleX("x (mm) trk2"); + h101.setTitleY("y (mm) trk2"); + H2F h700 = new H2F("Strips on trk layer1", 100, -18., 18., 100, -18., 18.); + h100.setTitleX("x (mm) trk1"); + h100.setTitleY("y (mm) trk1"); + H2F h701 = new H2F("Strips on trk layer2", 100, -18., 18., 100, -18., 18.); + h101.setTitleX("x (mm) trk2"); + h101.setTitleY("y (mm) trk2"); + + double limTC = 4.; // for MC 0.05 is ok + H1F h102 = new H1F("trk1 x residual", 63, -limTC, limTC); + h102.setOptStat(10); + h102.setTitleX("trk1 x residual (mm)"); + h102.setFillColor(1); + H1F h103 = new H1F("trk2 x residual", 63, -limTC, limTC); + h103.setOptStat(10); + h103.setFillColor(51); + h103.setTitleX("trk2 x residual (mm)"); + H1F h104 = new H1F("trk1 y residual", 63, -limTC, limTC); + h104.setOptStat(Integer.parseInt("0")); + h104.setFillColor(1); + h104.setTitleX("trk1 y residual (mm)"); + H1F h105 = new H1F("trk2 y residual;", 63, -limTC, limTC); + h105.setOptStat(10); + h105.setTitleX("trk2 y residual (mm)"); + h105.setFillColor(51); + double limTCTheta = 0.05; + double limTCPhi = 1.; + H1F h106 = new H1F("trk1 theta residual (rad)", 100, -limTCTheta, limTCTheta); + h106.setOptStat(10); + h106.setTitleX("trk1 theta residual (rad)"); + h106.setFillColor(1); + H1F h107 = new H1F("trk2 theta residual (rad)", 100, -limTCTheta, limTCTheta); + h107.setOptStat(Integer.parseInt("0")); + h107.setTitleX("trk2 theta residual (rad)"); + h107.setFillColor(51); + H1F h108 = new H1F("trk1 phi residual (rad)", 100, -limTCPhi, limTCPhi); + h108.setOptStat(0); + h108.setTitleX("trk1 phi residual"); + h108.setFillColor(1); + H1F h109 = new H1F("trk2 phi residual (rad)", 100, -limTCPhi, limTCPhi); + h109.setOptStat(10); + h109.setTitleX("trk2 phi residual (rad)"); + h109.setFillColor(51); + +// H1F h202 = new H1F("trk1 x", 25, 9., 9.4); +// H1F h1202 = new H1F("trk1 x MC", 25, 9., 9.4); + H1F h202 = new H1F("trk1 x", 25, 8.2, 9.0); + H1F h1202 = new H1F("trk1 x MC", 25, 8.2, 9.0); + h202.setOptStat(0); + h202.setTitleX("trk1 x position (mm)"); + h202.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins + h202.setLineColor(3); + h202.setFillColor(3); + h1202.setLineColor(9); + h1202.setFillColor(49); +// H1F h203 = new H1F("trk2 x", 25, 9., 9.4); +// H1F h1203 = new H1F("trk2 MC", 25, 9., 9.4); + H1F h203 = new H1F("trk2 x", 25, 8.2, 9.0); + H1F h1203 = new H1F("trk2 MC", 25, 8.2, 9.0); + h203.setOptStat(0); + h203.setTitleX("trk2 x position (mm)"); + h203.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins + h203.setLineColor(3); + h203.setFillColor(3); + h1203.setLineColor(9); + h1203.setFillColor(49); +// H1F h204 = new H1F("trk1 y", 25, 1.4, 1.8); +// H1F h1204 = new H1F("trk1 y MC", 25, 1.4, 1.8); + H1F h204 = new H1F("trk1 y", 25, 2.4, 4.0); + H1F h1204 = new H1F("trk1 y MC", 25, 2.4, 4.0); + h204.setOptStat(0); + h204.setTitleX("trk1 y position (mm)"); + h204.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins + h204.setLineColor(3); + h204.setFillColor(3); + h1204.setLineColor(9); + h1204.setFillColor(49); +// H1F h205 = new H1F("trk2 y", 25, 1.4, 1.8); +// H1F h1205 = new H1F("trk2 y MC", 25, 1.4, 1.8); + H1F h205 = new H1F("trk2 y", 25, 2.4, 4.0); + H1F h1205 = new H1F("trk2 y MC", 25, 2.4, 4.0); + h205.setOptStat(0); + h205.setTitleX("trk2 y position (mm)"); + h205.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins + h205.setLineColor(3); + h205.setFillColor(3); + h1205.setLineColor(9); + h1205.setFillColor(49); + + // resolution plots (of TRK wrt MC truth - red histograms) + H2F h1100 = new H2F("Cross on trk layer1 MC truth", 100, -18., 18., 100, -18., 18.); + h1100.setTitleX("x (mm) trk1"); + h1100.setTitleY("y (mm) trk1"); + H2F h1101 = new H2F("Cross on trk layer2 MC truth", 100, -18., 18., 100, -18., 18.); + h1101.setTitleX("x (mm) trk2"); + h1101.setTitleY("y (mm) trk2"); + int binres = 35; + double reslim = 5.*FTTRKConstantsLoader.Pitch; + H1F h1102 = new H1F("trk1 x resolution", binres, -reslim, reslim); + h1102.setOptStat(0); + h1102.setTitleX("trk1 x resolutionl (mm)"); + h1102.setLineColor(2); + h1102.setFillColor(2); + H1F h1103 = new H1F("trk2 x resolution", binres, -reslim, reslim); + h1103.setOptStat(0); + h1103.setTitleX("trk2 x resolution (mm)"); + h1103.setLineColor(2); + h1103.setFillColor(32); + H1F h1104 = new H1F("trk1 y resolution", binres, -reslim, reslim); + h1104.setOptStat(0); + h1104.setTitleX("trk1 y resolution (mm)"); + h1104.setLineColor(2); + h1104.setFillColor(2); + H1F h1105 = new H1F("trk2 y resolution", binres, -reslim, reslim); + h1105.setOptStat(0); + h1105.setTitleX("trk2 y resolution (mm)"); + h1105.setLineColor(2); + h1105.setFillColor(32); + H1F h1106 = new H1F("trk1 theta resolution", 50, -0.001, 0.001); + h1106.setOptStat(0); + h1106.setTitleX("trk1 theta resolution (rad)"); + h1106.setLineColor(2); + h1106.setFillColor(27); + H1F h1107 = new H1F("trk2 theta resolution", 50, -0.001, 0.001); + h1107.setOptStat(0); + h1107.setTitleX("trk2 theta resolution (rad)"); + h1107.setLineColor(2); + h1107.setFillColor(37); + H1F h1108 = new H1F("trk1 phi resolution", 50, -0.02, 0.02); + h1108.setOptStat(0); + h1108.setTitleX("trk1 phi resolution (rad)"); + h1108.setLineColor(2); + h1108.setFillColor(2); + H1F h1109 = new H1F("trk2 phi resolution", 50, -0.02, 0.02); + h1109.setOptStat(0); + h1109.setTitleX("trk2 phi resolution (rad)"); + h1109.setLineColor(2); + h1109.setFillColor(32); + + H1F h1112 = new H1F("trk1 Delta x", 50, -0.05, 0.05); + h1112.setOptStat(0); + h1112.setTitleX("trk1 Delta x"); + h1112.setLineColor(6); + h1112.setFillColor(6); + H1F h1113 = new H1F("trk2 Delta x", 50, -0.05, 0.05); + h1113.setOptStat(0); + h1113.setTitleX("trk2 Delta x"); + h1113.setLineColor(6); + h1113.setFillColor(36); + H1F h1114 = new H1F("trk1 Delta y", 50, -0.1, 0.1); + h1114.setOptStat(0); + h1114.setTitleX("trk1 Delta y"); + h1114.setLineColor(6); + h1114.setFillColor(6); + H1F h1115 = new H1F("trk2 Delta y", 50, -0.1, 0.1); + h1115.setOptStat(0); + h1115.setTitleX("trk2 Delta y"); + h1115.setLineColor(6); + h1115.setFillColor(36); + + // Montecarlo radiography + H2F h2000 = new H2F("Montecarlo radiography at first FTTRK det", 100, -15., 15., 100, -15, 15.); + h2000.setTitleX("x (mm)"); + h2000.setTitleY("y (mm)"); + H2F h2001 = new H2F("Montecarlo radiography at second FTTRK det", 100, -15., 15., 100, -15, 15.); + h2001.setTitleX("x (mm)"); + h2001.setTitleY("y (mm)"); + + JFrame frameCALTRK = new JFrame("radiography FTCAL hits and FTTRK Crosses"); + frameCALTRK.setSize(1500,500); + EmbeddedCanvas canvasCALTRK = new EmbeddedCanvas(); + canvasCALTRK.divide(3,1); + + H1F h71 = new H1F("hOccupancyMatchedSeed1", 768, 0., 769.); h71.setTitleX("Component layer 1"); + h71.setLineColor(1); h71.setFillColor(51); + H1F h72 = new H1F("hOccupancyMatchedSeed2", 768, 0., 769.); h72.setTitleX("Component layer 2"); + h72.setLineColor(1); h72.setFillColor(52); + H1F h73 = new H1F("hOccupancyMatchedSeed3", 768, 0., 769.); h73.setTitleX("Component layer 3"); + h73.setLineColor(1); h73.setFillColor(53); + H1F h74 = new H1F("hOccupancyMatchedSeed4", 768, 0., 769.); h74.setTitleX("Component layer 4"); + h74.setLineColor(1); h74.setFillColor(54); + + H1F h81 = new H1F("hOccupancyMatched1", 768, 0., 769.); h81.setTitleX("Component layer 1"); + h81.setLineColor(1); h81.setFillColor(31); + H1F h82 = new H1F("hOccupancyMatched2", 768, 0., 769.); h82.setTitleX("Component layer 2"); + h82.setLineColor(1); h82.setFillColor(32); + H1F h83 = new H1F("hOccupancyMatched3", 768, 0., 769.); h83.setTitleX("Component layer 3"); + h83.setLineColor(1); h83.setFillColor(33); + H1F h84 = new H1F("hOccupancyMatched4", 768, 0., 769.); h84.setTitleX("Component layer 4"); + h84.setLineColor(1); h84.setFillColor(34); + + + + int nev = 0; + int nevWithCrosses = 0, ncrosses2 = 0; + while (reader.hasEvent()) { // run over all events +// int nev1 = 0; int nev2 = 10000; for(nev=nev1; nev=1) System.out.println("////////////// event read " + bankEvt + " - sequential number " + nev); + //if(nev > 10239) System.exit(0); if(nev != 10239) continue; + cal.processDataEvent(event); + hodo.processDataEvent(event); + trk.processDataEventAndGetClusters(event); + en.processDataEvent(event); + if(!event.hasBank("FTCAL::hits")) continue; //////////////////////////////////////////// + + if (event instanceof EvioDataEvent) { + GenericKinematicFitter fitter = new GenericKinematicFitter(11); + PhysicsEvent gen = fitter.getGeneratedEvent((EvioDataEvent) event); + if (event.hasBank("FTRec::tracks")) { + DataBank bank = event.getBank("FTRec::tracks"); + int nrows = bank.rows(); + for (int i = 0; i < nrows; i++) { + h1.fill(bank.getDouble("Energy", i)); + Vector3D part = new Vector3D(bank.getDouble("Cx", i), bank.getDouble("Cy", i), bank.getDouble("Cz", i)); + h5.fill(bank.getDouble("Time", i)); + if(gen.countGenerated() != 0){ + h2.fill(bank.getDouble("Energy", i) - gen.getParticle("[11]").vector().p()); + h3.fill(Math.toDegrees(part.theta() - gen.getParticle("[11]").theta())); + h4.fill(Math.toDegrees(part.phi() - gen.getParticle("[11]").phi())); + h6.fill(bank.getDouble("Energy", i), bank.getDouble("Energy", i) - gen.getParticle("[11]").vector().p()); + } + } + } + } else { + DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); + PhysicsEvent gen = detectorEvent.getGeneratedEvent(); +// nev++; + if (event.hasBank("FT::particles")) { + DataBank bank = event.getBank("FT::particles"); + int nrows = bank.rows(); + for (int i = 0; i < nrows; i++) { + int calId = bank.getShort("calID",i); + if(bank.getByte("charge", i)==-1 && bank.getShort("calID",i)>0) { + // track candidate through calorimeter + h1.fill(bank.getFloat("energy", i)); + Vector3D part = new Vector3D(bank.getFloat("cx", i), bank.getFloat("cy", i), bank.getFloat("cz", i)); + h5.fill(bank.getFloat("time", i) - 124.25); // simulation + h7.fill((bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS)/10., (bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS)/10.); + if(gen.countGenerated() != 0){ + h2.fill(bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h3.fill(gen.getGeneratedParticle(0).vector().p(),Math.toDegrees(part.theta() - gen.getGeneratedParticle(0).theta())); + h4.fill(gen.getGeneratedParticle(0).vector().p(),Math.toDegrees(part.phi() - gen.getGeneratedParticle(0).phi())); + h6.fill(bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h8.fill(gen.getGeneratedParticle(0).vector().p(), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h9.fill(Math.toDegrees(gen.getGeneratedParticle(0).theta()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h10.fill(Math.toDegrees(gen.getGeneratedParticle(0).phi()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + } + + // check match with trk bank (entry trkID) +// int trkID = bank.getShort("trkID", i); + int trk0ID = bank.getShort("trk0ID", i); // it should correspond to the number of the cross in the banks + int trk1ID = bank.getShort("trk1ID", i); + if(trk0ID >= 0 || trk1ID >= 0){ // at least one cross is present on one TRK det + + // loop on crosses bank + DataBank banktrk = event.getBank("FTTRK::crosses"); + int ncrosses = banktrk.rows(); + // how many matched crosses are associated to a given track? + int matchedCrosses = 0; + for(int nc=0; nc=0){ + float xt = banktrk.getFloat("x", nc); + float yt = banktrk.getFloat("y", nc); + float zt = banktrk.getFloat("z", nc); + Vector3D hitOnTrk = new Vector3D(xt, yt, zt); + // extract information on the crossed strips + +// float icl1 = banktrk.getFloat("energy", nc); // Cluster1ID provisional to be changed +// float icl2 = banktrk.getFloat("time", nc); // cluster2ID provisional to be changes + float icl1 = banktrk.getShort("Cluster1ID", nc); + float icl2 = banktrk.getShort("Cluster2ID", nc); + DataBank bankcl = event.getBank("FTTRK::clusters"); + // which is the correct location in the cluster bank for the cluster with the given id? + int icl1ok = -1; + int icl2ok = -1; + for(int k=0; k0){ + segment1.setOrigin(0.,0.); segment1.setEnd(0.,0.); + segment2.setOrigin(0.,0.); segment2.setEnd(0.,0.); + seed1 = bankcl.getInt("seed", icl1ok); + seed2 = bankcl.getInt("seed", icl2ok); + int cent1 = (int)bankcl.getFloat("centroid", icl1ok); + int cent2 = (int)bankcl.getFloat("centroid", icl2ok); + // the cluster is formed by > 3 strips take the centroid + int clustsize1 = bankcl.getShort("size", icl1ok); + int clustsize2 = bankcl.getShort("size", icl2ok); + if(clustsize1>=3){ + int sector = FTTRKReconstruction.findSector(seed1); + if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed1 = cent1; + } + if(clustsize2>=3){ + int sector = FTTRKReconstruction.findSector(seed2); + if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed2 = cent2; + } + + // if seed and centroid dont coincide, take the centroid as seed + //if(cent1 != seed1) seed1 = cent1; + //if(cent2 != seed2) seed2 = cent2; + int lay1 = bankcl.getInt("layer", icl1ok); + int lay2 = bankcl.getInt("layer", icl2ok); + System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ seed1, seed2 " + seed1 + " " + seed2 + " layer1 layer2 " + lay1 + " " + lay2); + System.out.println("~~~~~~~~~~ hit strip 1: " + seed1 + " layer " + lay1 + " sector " + + FTTRKReconstruction.findSector(seed1)); + System.out.println("~~~~~~~~~~ hit strip 2: " + seed2 + " layer " + lay2 + " sector " + + FTTRKReconstruction.findSector(seed2)); + + if(seed1!=0 && seed2!=0){ + Line3D seg1 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay1, seed1); + Line3D seg2 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay2, seed2); + segment1.setOrigin(seg1.origin().x(), seg1.origin().y()); + segment2.setOrigin(seg2.origin().x(), seg2.origin().y()); + segment1.setEnd(seg1.end().x(), seg1.end().y()); + segment2.setEnd(seg2.end().x(), seg2.end().y()); + + // extract the mumber of strips forming the cross and store them in an occupancy plot for matched signals + // which strips are forming the id cross? + + if(lay1==1){ + h71.fill(seed1); + }else if(lay1==2){ + h72.fill(seed1); + }else if(lay1==3){ + h73.fill(seed1); +; }else if(lay1==4){ + h74.fill(seed1); + } + + if(lay2==1){ + h71.fill(seed2); + }else if(lay2==2){ + h72.fill(seed2); + }else if(lay2==3){ + h73.fill(seed2); +; }else if(lay2==4){ + h74.fill(seed2); + } + + DataBank bankhit = event.getBank("FTTRK::hits"); + if(bankhit.rows()>0){ + for(int k=0; k0){ +// System.out.println("coordinates on calorimeter " + bank.getDouble("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); + System.out.println("coordinates of track on fttrk " + bank.getFloat("cx", i)*zt + " " + + bank.getFloat("cy", i)*zt + " " + bank.getFloat("cz", i)*zt); + System.out.println("director cosines hit on calorimeter " + part.x() + " " + part.y() + " " + part.z()); + System.out.println("director cosines hit of fttrk " + xt + " " + yt + " " + zt); + } + h102.fill(bank.getFloat("cx", i) *zt - xt); + h104.fill(bank.getFloat("cy", i) *zt - yt); + h106.fill((part.theta() - hitOnTrk.theta())); + h108.fill((part.phi() - hitOnTrk.phi())); + hSecDet0.fill(FTTRKReconstruction.findSector(seed1), FTTRKReconstruction.findSector(seed2)); + + canvasCALTRK.cd(0); + segment1.setLineColor(1); + segment2.setLineColor(2); + canvasCALTRK.draw(segment1); + canvasCALTRK.draw(segment2); + + }else if(det==1 && trk1ID==crossID){ + h101.fill(xt, yt); + h103.fill(bank.getFloat("cx", i) *zt - xt); + h105.fill(bank.getFloat("cy", i) *zt - yt); + h107.fill((part.theta() - hitOnTrk.theta())); + h109.fill((part.phi() - hitOnTrk.phi())); + hSecDet1.fill(FTTRKReconstruction.findSector(seed1), FTTRKReconstruction.findSector(seed2)); + + canvasCALTRK.cd(1); + segment1.setLineColor(3); + segment2.setLineColor(4); + canvasCALTRK.draw(segment1); + canvasCALTRK.draw(segment2); + } + + } + } + + if(ncrosses==2){ + float x0 = banktrk.getFloat("x", 0); + float y0 = banktrk.getFloat("y", 0); + float x1 = banktrk.getFloat("x", 1); + float y1 = banktrk.getFloat("y", 1); + + Point3D c0 = new Point3D(x0, y0, banktrk.getFloat("z",0)); + Point3D c1 = new Point3D(x1, y1, banktrk.getFloat("z",1)); + Line3D lineBwCrosses = new Line3D(c1, c0); + if(debugMode>0){ + System.out.println("x coordinates on 2 layers " + x0 + " " + x1); + System.out.println("director cosines straight line bw crosses, cx " + lineBwCrosses.originDir().x() + " cy " + + lineBwCrosses.originDir().y() + " cz " + lineBwCrosses.originDir().z()); + } + } + } + } + } + } + + + if(event.hasBank("FTTRK::crosses")){ + nevWithCrosses++; + DataBank banktrk = event.getBank("FTTRK::crosses"); + int nrows = banktrk.rows(); + // how many particles have been generated? + int ipart = gen.countGenerated(); + + for(int ip=0; ip0) System.out.println("------- generated particle n " + ip + " type: " + gen.getGeneratedParticle(ip).pid() + " mass " + mass); + double P = gen.getGeneratedParticle(ip).p(); + double cx = gen.getGeneratedParticle(ip).px()/P; + double cy = gen.getGeneratedParticle(ip).py()/P; + double cz = gen.getGeneratedParticle(ip).pz()/P; + double Pz = P*cz; + double Pperp = P*Math.sqrt(cx*cx+cy*cy); + double x0 = gen.getGeneratedParticle(ip).vx(); + double y0 = gen.getGeneratedParticle(ip).vy(); + double z0 = gen.getGeneratedParticle(ip).vz(); + double q = Math.abs(gen.getGeneratedParticle(ip).charge()); // negative particles bend upwards + for (int i = 0; i < nrows; i++) { + int det = banktrk.getInt("detector", i); + double xt = banktrk.getFloat("x", i); + double yt = banktrk.getFloat("y", i); + double zt = banktrk.getFloat("z", i); + + if(debugMode>0){ + System.out.println("MC: x0 = " + x0 + " y0 " + y0 + " z0 " + z0); + System.out.println("MC cosines: cx = " + cx + " cy " + cy + " cz " + cz); + System.out.println("trk: xt = " + xt + " yt " + yt + " zt " + zt); + } + double t = (zt - z0)/cz; + Vector3D hitOnTrk = new Vector3D(xt, yt, zt); + Vector3D hitMCOnTrk = new Vector3D(x0+cx*t, y0+cy*t, zt); // straight line + + if(debugMode>0) System.out.println("MC on the straight line x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + + " z = " + hitMCOnTrk.z()); + // if the magnetic field is on, the coordinates must be swum along a helix + double B = en.getSolenoid(); + if(B!=0.){ +// Pperp /= P; +// Pz /= P; +// B *= 2.; // perche'? da cosa deriva questo 2? + // find the crossing point of the helix and a xy plane at given z, where the magneti field stops + double zStop = 100.0; // provisional fix it to 1 meter + double phi0 = Math.atan2(cy,cx); + double R = Pperp/0.3/B/q*1.e2; // R in cm + //double dAlpha = (zt-z0)*(B*q*0.3)/Pz*1.e-2; // deltaZ in meters + double dAlpha = (zStop-z0)*(B*q*0.3)/Pz*1.e-2; // deltaZ in meters + int nturns = (int) Math.floor(dAlpha/2./Math.PI); // number of full turns + if(dAlpha>0){ + dAlpha -= nturns*2.*Math.PI; + }else{ + dAlpha += nturns*2.*Math.PI; + } + + double xc = R*Math.sin(phi0); + double yc = R*Math.cos(phi0); + Vector3D hitOnPlane = new Vector3D(); + Vector3D tangentAtZstop = new Vector3D(); + if(R*dAlpha>0){ + hitOnPlane.setX(-xc + R*(Math.sin(phi0 + dAlpha))); + hitOnPlane.setY( yc - R*(Math.cos(phi0 + dAlpha))); + hitOnPlane.setZ(zStop); + double gamma = Math.atan2(hitOnPlane.y(),hitOnPlane.x()); + double vx1 = Pperp/P*Math.sin(gamma); + double vy1 = Pperp/P*Math.cos(gamma); + double vz1 = Math.sqrt(1. - vx1*vx1 + vy1*vy1); + double t1 = (zt - hitOnPlane.z())/vz1; + hitMCOnTrk.setXYZ(hitOnPlane.x()+vx1*t1, hitOnPlane.y()+vy1*t1, zt); + }else{ + System.out.println("check particle/curvature signs"); + } + // find the direction of the tanget vector at the + + + + + /* + // alternative method + double w = B*0.3/q/mass; + t = (zt-z0)*1e-2*mass/Pz; + hitMCOnTrk.setX(x0 + Pperp/mass/w*1.e2 * Math.sin(w*t+phi0) - xc); + hitMCOnTrk.setY(y0 - Pperp/mass/w*1.e2 * Math.cos(w*t+phi0) + yc); + */ + + + } + if(debugMode>0) System.out.println("MC after swimming in mag field x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + + " z = " + hitMCOnTrk.z()); + + // Montecarlo hit location on first detector middle plane + if(det==0) h2000.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); + if(det==1) h2001.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); + + if(det==0){ + h1100.fill(hitOnTrk.x(), hitOnTrk.y()); + h1102.fill(hitMCOnTrk.x() - hitOnTrk.x()); + h1104.fill(hitMCOnTrk.y() - hitOnTrk.y()); + + h1106.fill((hitMCOnTrk.theta() - hitOnTrk.theta())); + h1108.fill((hitMCOnTrk.phi() - hitOnTrk.phi())); + + h1112.fill((hitMCOnTrk.x() - hitOnTrk.x())/hitMCOnTrk.x()); + h1114.fill((hitMCOnTrk.y() - hitOnTrk.y())/hitMCOnTrk.y()); + + h202.fill(hitOnTrk.x()); + h1202.fill(hitMCOnTrk.x()); + h204.fill(hitOnTrk.y()); + h1204.fill(hitMCOnTrk.y()); + + }else if(det==1){ + h1101.fill(hitOnTrk.x(), hitOnTrk.y()); + h1103.fill(hitMCOnTrk.x() - hitOnTrk.x()); + h1105.fill(hitMCOnTrk.y() - hitOnTrk.y()); + h1107.fill((hitMCOnTrk.theta() - hitOnTrk.theta())); + h1109.fill((hitMCOnTrk.phi() - hitOnTrk.phi())); + + h1113.fill((hitMCOnTrk.x() - hitOnTrk.x())/hitMCOnTrk.x()); + h1115.fill((hitMCOnTrk.y() - hitOnTrk.y())/hitMCOnTrk.y()); + + h203.fill(hitOnTrk.x()); + h1203.fill(hitMCOnTrk.x()); + h205.fill(hitOnTrk.y()); + h1205.fill(hitMCOnTrk.y()); + } + if(debugMode>0){ + System.out.println("MC hit coordinates " + hitMCOnTrk.x() + " " + hitMCOnTrk.y() + " " + hitMCOnTrk.z()); + System.out.println("MC theta " + hitMCOnTrk.theta() + " hit on trk " + hitOnTrk.theta()); + System.out.println("MC phi " + hitMCOnTrk.phi() + " hit on trk " + hitOnTrk.phi()); + System.out.println("trk hit coordinates " + hitOnTrk.x() + " " + hitOnTrk.y() + " " + hitOnTrk.z()); + } + } + } + } + } + } + + if(debugMode>=0) System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + nevWithCrosses); + + JFrame frame = new JFrame("FT Reconstruction"); + frame.setSize(1200, 800); + EmbeddedCanvas canvas = new EmbeddedCanvas(); + canvas.divide(3, 3); + canvas.cd(0); + canvas.draw(h1); + canvas.cd(1); + canvas.draw(h2); + canvas.cd(2); + canvas.draw(h3); + canvas.cd(3); +// canvas.draw(h4); + h501.setFillColor(3); // green + h502.setFillColor(5); // yellow + h503.setFillColor(8); // dark green + h504.setFillColor(7); // orange + h600.setFillColor(9); // blue violet + h602.setFillColor(3); // green trk0 + h603.setFillColor(5); // yellow trk1 + + canvas.draw(h501); + canvas.draw(h502,"same"); + canvas.cd(4); + canvas.draw(h503,""); + canvas.draw(h504,"same"); + + + for (int i = 0; i < h6.getDataBufferSize(); i++) { + float meanE = h6.getDataBufferBin(i); + float nE = h7.getDataBufferBin(i); + if (nE > 0) { + h6.setDataBufferBin(i, meanE / nE); + } + } + canvas.cd(5); +// canvas.draw(h7); + canvas.draw(h507); + canvas.cd(6); +// canvas.draw(h8); + canvas.draw(h600); + canvas.cd(7); +// canvas.draw(h9); + canvas.draw(h601); + canvas.cd(8); +// canvas.draw(h10); + canvas.draw(h602); + canvas.draw(h603,"same"); + frame.add(canvas); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + + double narrowFactor = 4.5; + JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); + frametrk.setSize(1600, 800); + EmbeddedCanvas canvastrk = new EmbeddedCanvas(); + canvastrk.divide(5, 2); + canvastrk.cd(0); + canvastrk.draw(h100); + canvastrk.cd(1); + canvastrk.draw(h102); + F1D f02 = new F1D("f02","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); + f02.setParameter(0, 10.0); + f02.setParameter(1, 0.0); + f02.setParameter(2, 1.0); + f02.setLineColor(6); + f02.setLineWidth(3); + DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma + f02.setParameter(0, f02.parameter(0).value()); + f02.setParameter(1, f02.parameter(1).value()); + f02.setParameter(2, f02.parameter(2).value()); + DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma + f02.setOptStat(11111); + canvastrk.draw(f02,"same"); + canvastrk.cd(2); + canvastrk.draw(h104); + F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/(narrowFactor+0.2)); + f04.setParameter(0, 10.0); + f04.setParameter(1, 0.0); + f04.setParameter(2, 1.0); + f04.setLineColor(6); + f04.setLineWidth(3); + DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma + f04.setParameter(0, f04.parameter(0).value()); + f04.setParameter(1, f04.parameter(1).value()); + f04.setParameter(2, f04.parameter(2).value()); + DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma + f04.setOptStat(11111); + canvastrk.draw(f04,"same"); + canvastrk.cd(3); + canvastrk.draw(h106); + F1D f06 = new F1D("f06","[amp]*gaus(x,[mean],[sigma])", -limTCTheta/narrowFactor, limTCTheta/narrowFactor); + f06.setParameter(0, 10.0); + f06.setParameter(1, h106.getMean()); + f06.setParameter(2, h106.getRMS()); + f06.setLineColor(6); + f06.setLineWidth(3); + DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma + f06.setParameter(0, f06.parameter(0).value()); + f06.setParameter(1, f06.parameter(1).value()); + f06.setParameter(2, f06.parameter(2).value()); + DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma + f06.setOptStat(11111); + canvastrk.draw(f06,"same"); + canvastrk.cd(4); + canvastrk.draw(h108); + F1D f08 = new F1D("f08","[amp]*gaus(x,[mean],[sigma])", -limTCPhi/narrowFactor, limTCPhi/narrowFactor); + f08.setParameter(0, h108.getMax()); + f08.setParameter(1, h108.getMean()); + f08.setParameter(2, h108.getRMS()); + f08.setLineColor(6); + f08.setLineWidth(3); + DataFitter.fit(f08, h108, "Q"); //No options uses error for sigma + f08.setOptStat(11111); + canvastrk.draw(f08,"same"); + + canvastrk.cd(5); + canvastrk.draw(h101); + + canvastrk.cd(6); + canvastrk.draw(h103); + F1D f03 = new F1D("f03","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); + f03.setParameter(0, 10.0); + f03.setParameter(1, 0.0); + f03.setParameter(2, 1.0); + f03.setLineColor(6); + f03.setLineWidth(3); + DataFitter.fit(f03, h103, "Q"); //No options uses error for sigma + f03.setParameter(0, f03.parameter(0).value()); + f03.setParameter(1, f03.parameter(1).value()); + f03.setParameter(2, f03.parameter(2).value()); + DataFitter.fit(f03, h103, "Q"); //No options uses error for sigma + f03.setOptStat(1111); + canvastrk.draw(f03,"same"); + + + canvastrk.cd(7); + canvastrk.draw(h105); + F1D f05 = new F1D("f05","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); + f05.setParameter(0, 10.0); + f05.setParameter(1, 0.0); + f05.setParameter(2, 1.0); + f05.setLineColor(6); + f05.setLineWidth(3); + DataFitter.fit(f05, h105, "Q"); //No options uses error for sigma + f05.setParameter(0, f05.parameter(0).value()); + f05.setParameter(1, f05.parameter(1).value()); + f05.setParameter(2, f05.parameter(2).value()); + DataFitter.fit(f05, h105, "Q"); //No options uses error for sigma + f05.setOptStat(1111); + canvastrk.draw(f05,"same"); + + canvastrk.cd(8); + canvastrk.draw(h107); + F1D f07 = new F1D("f07","[amp]*gaus(x,[mean],[sigma])", -limTCTheta/narrowFactor, limTCTheta/narrowFactor); + f07.setParameter(0, h107.getMax()); + f07.setParameter(1, h107.getMean()); + f07.setParameter(2, h107.getRMS()); + f07.setLineColor(6); + f07.setLineWidth(3); + DataFitter.fit(f07, h107, "Q"); //No options uses error for sigma + f07.setOptStat(1111); + canvastrk.draw(f07,"same"); + + canvastrk.cd(9); + canvastrk.draw(h109); + F1D f09 = new F1D("f09","[amp]*gaus(x,[mean],[sigma])", -limTCPhi/narrowFactor, limTCPhi/narrowFactor); + f09.setParameter(0, h109.getMax()); + f09.setParameter(1, h109.getMean()); + f09.setParameter(2, h109.getRMS()); + f09.setLineColor(6); + f09.setLineWidth(3); + DataFitter.fit(f09, h109, "Q"); //No options uses error for sigma + f09.setParameter(0, f09.parameter(0).value()); + f09.setParameter(1, f09.parameter(1).value()); + f09.setParameter(2, f09.parameter(2).value()); + DataFitter.fit(f09, h109, "Q"); //No options uses error for sigma + f09.setOptStat(1111); + canvastrk.draw(f09,"same"); + frametrk.add(canvastrk); + frametrk.setLocationRelativeTo(null); + frametrk.setVisible(true); + + JFrame frametrkres = new JFrame("FTTRK Resolutions wrt MC generated events"); + frametrkres.setSize(1800, 800); + EmbeddedCanvas canvastrkres = new EmbeddedCanvas(); + canvastrkres.divide(7, 2); + int ii = 0; + canvastrkres.cd(ii); + canvastrkres.draw(h1100); + canvastrkres.cd(++ii); + canvastrkres.draw(h1102); + F1D f1 = new F1D("f1","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); + f1.setParameter(0, h1102.getMax()); + f1.setParameter(1, h1102.getMean()); + f1.setParameter(2, h1102.getRMS()); + f1.setLineColor(4); + f1.setLineWidth(3); + DataFitter.fit(f1, h1102, "Q"); //No options uses error for sigma + f1.setParameter(0, f1.parameter(0).value()); + f1.setParameter(1, f1.parameter(1).value()); + f1.setParameter(2, f1.parameter(2).value()); + DataFitter.fit(f1, h1102, "Q"); //No options uses error for sigma + f1.setOptStat(1111); + canvastrkres.draw(f1,"same"); + if(debugMode>0) System.out.println(" mean = " + f1.parameter(1).value() + + " sigma = " + f1.parameter(2).value()); + canvastrkres.cd(++ii); + canvastrkres.draw(h1104); + F1D f2 = new F1D("f2","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); + f2.setParameter(0, f1.parameter(0).value()); + f2.setParameter(1, f1.parameter(1).value()); + f2.setParameter(2, f1.parameter(2).value()); + f2.setLineColor(24); + f2.setLineWidth(3); + DataFitter.fit(f2, h1104, "Q"); //No options uses error for sigma + f2.setOptStat(1111); + canvastrkres.draw(f2,"same"); + if(debugMode>0) System.out.println(" mean = " + f2.parameter(1).value() + + " sigma = " + f2.parameter(2).error()); + canvastrkres.cd(++ii); + canvastrkres.draw(h1106); + F1D f6 = new F1D("f6","[amp]*gaus(x,[mean],[sigma])", -0.001, 0.001); + f6.setParameter(0, f1.parameter(0).value()); + f6.setParameter(1, h1106.getMean()); + f6.setParameter(2, h1106.getRMS()); + f6.setLineColor(24); + f6.setLineWidth(3); + DataFitter.fit(f6, h1106, "Q"); //No options uses error for sigma + f6.setOptStat(1111); + canvastrkres.draw(f6,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1108); + F1D f8 = new F1D("f8","[amp]*gaus(x,[mean],[sigma])", -0.005, 0.005); + f8.setParameter(0, h1108.getMax()); + f8.setParameter(1, h1108.getMean()); + f8.setParameter(2, h1108.getRMS()/2); + f8.setLineColor(24); + f8.setLineWidth(3); + DataFitter.fit(f8, h1108, "Q"); //No options uses error for sigma + f8.setOptStat(1111); + canvastrkres.draw(f8,"same"); + canvastrkres.cd(++ii); + canvastrkres.draw(h1112); + F1D f12 = new F1D("f12","[amp]*gaus(x,[mean],[sigma])", -0.05, 0.05); + f12.setParameter(0, f1.parameter(0).value()); + f12.setParameter(1, h1112.getMean()); + f12.setParameter(2, h1112.getRMS()); + f12.setLineColor(24); + f12.setLineWidth(3); + DataFitter.fit(f12, h1112, "Q"); //No options uses error for sigma + f12.setOptStat(1111); + canvastrkres.draw(f12,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1114); + F1D f14 = new F1D("f14","[amp]*gaus(x,[mean],[sigma])", -0.1, 0.1); + f14.setParameter(0, f1.parameter(0).value()); + f14.setParameter(1, h1114.getMean()); + f14.setParameter(2, h1114.getRMS()); + f14.setLineColor(24); + f14.setLineWidth(3); + DataFitter.fit(f14, h1114, "Q"); //No options uses error for sigma + f14.setOptStat(1111); + canvastrkres.draw(f14,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1101); + canvastrkres.cd(++ii); + canvastrkres.draw(h1103); + F1D f3 = new F1D("f3","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); + f3.setParameter(0, f1.parameter(0).value()); + f3.setParameter(1, f1.parameter(1).value()); + f3.setParameter(2, f1.parameter(2).value()); + f3.setLineColor(34); + f3.setLineWidth(3); + DataFitter.fit(f3, h1103, "Q"); //No options uses error for sigma + f3.setOptStat(1111); + canvastrkres.draw(f3,"same"); + if(debugMode>0) System.out.println(" mean = " + f3.parameter(1).value() + + " sigma = " + f3.parameter(2).error()); + canvastrkres.cd(++ii); + canvastrkres.draw(h1105); + F1D f4 = new F1D("f4","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); + f4.setParameter(0, f1.parameter(0).value()); + f4.setParameter(1, f1.parameter(1).value()); + f4.setParameter(2, f1.parameter(2).value()); + f4.setLineColor(44); + f4.setLineWidth(3); + DataFitter.fit(f4, h1105, "Q"); //No options uses error for sigma + f4.setOptStat(1111); + canvastrkres.draw(f4,"same"); + if(debugMode>0) System.out.println(" mean = " + f4.parameter(1).value() + + " sigma = " + f4.parameter(2).error()); + canvastrkres.cd(++ii); + canvastrkres.draw(h1107); + F1D f17 = new F1D("f17","[amp]*gaus(x,[mean],[sigma])", -0.001, 0.001); + f17.setParameter(0, h1107.getMax()); + f17.setParameter(1, h1107.getMean()); + f17.setParameter(2, h1107.getRMS()); + f17.setLineColor(24); + f17.setLineWidth(3); + DataFitter.fit(f17, h1107, "Q"); //No options uses error for sigma + f17.setOptStat(1111); + canvastrkres.draw(f17,"same"); + canvastrkres.cd(++ii); + canvastrkres.draw(h1109); + F1D f19 = new F1D("f19","[amp]*gaus(x,[mean],[sigma])", -0.002, 0.002); + f19.setParameter(0, h1109.getMax()); + f19.setParameter(1, h1109.getMean()); + f19.setParameter(2, h1109.getRMS()); + f19.setLineColor(24); + f19.setLineWidth(3); + DataFitter.fit(f19, h1109, "Q"); //No options uses error for sigma + f19.setOptStat(1111); + canvastrkres.draw(f19,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1113); + F1D f13 = new F1D("f13","[amp]*gaus(x,[mean],[sigma])", -0.05, 0.05); + f13.setParameter(0, f1.parameter(0).value()); + f13.setParameter(1, h1113.getMean()); + f13.setParameter(2, h1113.getRMS()); + f13.setLineColor(24); + f13.setLineWidth(3); + DataFitter.fit(f13, h1113, "Q"); //No options uses error for sigma + f13.setOptStat(1111); + canvastrkres.draw(f13,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1115); + F1D f15 = new F1D("f15","[amp]*gaus(x,[mean],[sigma])", -0.1, 0.1); + f15.setParameter(0, f1.parameter(0).value()); + f15.setParameter(1, h1115.getMean()); + f15.setParameter(2, h1115.getRMS()); + f15.setLineColor(24); + f15.setLineWidth(3); + DataFitter.fit(f15, h1115, "Q"); //No options uses error for sigma + f15.setOptStat(1111); + canvastrkres.draw(f15,"same"); + + frametrkres.add(canvastrkres); + frametrkres.setLocationRelativeTo(null); + frametrkres.setVisible(true); + + JFrame frametrkrel = new JFrame("FTTRK Resolutions layer1 vs layer2"); + frametrkrel.setSize(800, 800); + EmbeddedCanvas canvastrkrel = new EmbeddedCanvas(); + canvastrkrel.divide(2, 2); + canvastrkrel.cd(0); + canvastrkrel.draw(h202); + canvastrkrel.draw(h1202,"same"); + canvastrkrel.cd(1); + canvastrkrel.draw(h203); + canvastrkrel.draw(h1203,"same"); + canvastrkrel.cd(2); + canvastrkrel.draw(h204); + canvastrkrel.draw(h1204,"same"); + canvastrkrel.cd(3); + canvastrkrel.draw(h205); + canvastrkrel.draw(h1205,"same"); + + frametrkrel.add(canvastrkrel); + frametrkrel.setLocationRelativeTo(null); + frametrkrel.setVisible(true); + + /* + JFrame frameMCradio = new JFrame("Montecarlo radiography of vertex"); + frameMCradio.setSize(1000,500); + EmbeddedCanvas canvasMCradio = new EmbeddedCanvas(); + canvasMCradio.divide(2,1); + canvasMCradio.cd(0); + canvasMCradio.draw(h2000); + canvasMCradio.cd(1); + canvasMCradio.draw(h2001); + frameMCradio.add(canvasMCradio); + frameMCradio.setLocationRelativeTo(null); + frameMCradio.setVisible(true); + */ + + + JFrame frameSecradio = new JFrame("20 sectors occupancy"); + frameSecradio.setSize(1000,500); + EmbeddedCanvas canvasSecradio = new EmbeddedCanvas(); + canvasSecradio.divide(2,1); + canvasSecradio.cd(0); + canvasSecradio.draw(hSecDet0); + // excluded cells + double excx0h1[] = {0., 1., 2., 3., 4., 5., 10., 11., 12., 13.}; + double excy0h1[] = {10., 11., 12., 13., 14., 15., 16., 17.}; + GraphErrors excludedDet0half1 = new GraphErrors(); + for(int i=0; i Date: Thu, 10 Feb 2022 15:45:00 +0100 Subject: [PATCH 049/104] fix clustering wtih bordering strips; update corrections to fix Fall18 transition table + ancillary methods --- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 652 ++++++++++++++---- 1 file changed, 526 insertions(+), 126 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index 023c5d0636..72e37ed2ee 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -119,8 +119,8 @@ public ArrayList findClusters(List hits) } } + boolean needsReordering = false; // loop on layers -// for(int il=0; il<2; il++){ for(int il=0; il findClusters(List hits) for(FTTRKCluster clust : clusters){ if(clust.get_Layer() == il+1){ int nbhits = clust.size(); + int control = clust.get_CId(); for(int i=0; i < nbhits; i++){ FTTRKHit hit = clust.get(i); int nstrip = hit.get_Strip(); // System.out.println("strip " + nstrip + " clusterId " + clust.get_CId() + " layer " + clust.get_Layer()); if(nstrip==128 || nstrip==385 || nstrip==640 || nstrip==641){ + needsReordering = true; if(nstrip==128) clusterId11 = clust.get_CId(); //cut 127-384 if(nstrip==385) clusterId12 = clust.get_CId(); if(nstrip==640) clusterId21 = clust.get_CId(); // cut 640-641 @@ -225,8 +227,10 @@ public ArrayList findClusters(List hits) } } } - // join clusters if there are consecutive limiting hits + int clustersize = clusters.size(); + // join clusters if there are consecutive limiting hits if(clusterId11>=0 && clusterId12>=0 && clusterId11 != clusterId12){ + int newIndex = Math.min(clusterId11, clusterId12); ArrayList twoClusterHits = new ArrayList(); FTTRKCluster firstCluster = clusters.get(clusterId11); FTTRKCluster secondCluster = clusters.get(clusterId12); @@ -239,13 +243,16 @@ public ArrayList findClusters(List hits) twoClusterHits.add(hit); } //FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, clusters.size()+1); - FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, clusters.size()-2); + // new list for joined clusters +// FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, clusters.size()-2); + FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, ++clustersize); // update cluster and hit ID ArrayList cloneHitsWNewID = new ArrayList(); for(FTTRKHit clHit: twoClusterHits){ - clHit.set_DGTZIndex(clHit.get_Id()); - clHit.set_ClusterIndex(clusters.size()-2); // was +1 - cloneHitsWNewID.add(clHit); + clHit.set_DGTZIndex(clHit.get_Id()); + //clHit.set_ClusterIndex(clusters.size()-2); // was +1 +// clHit.set_ClusterIndex(newIndex); //gets the index of the first of the joined clusters (both will be removed) + cloneHitsWNewID.add(clHit); } joinedClusters.addAll(cloneHitsWNewID); // joinedClusters.addAll(twoClusterHits); @@ -253,6 +260,7 @@ public ArrayList findClusters(List hits) clusters.add(joinedClusters); } if(clusterId21>=0 && clusterId22>=0 && clusterId21 != clusterId22){ + int newIndex = Math.min(clusterId21, clusterId22); ArrayList twoClusterHits = new ArrayList(); FTTRKCluster firstCluster = clusters.get(clusterId21); FTTRKCluster secondCluster = clusters.get(clusterId22); @@ -264,20 +272,22 @@ public ArrayList findClusters(List hits) FTTRKHit hit = secondCluster.get(i); twoClusterHits.add(hit); } - FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, clusters.size()-2); +// FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, clusters.size()-2); + FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, ++clustersize); // joinedClusters.addAll(twoClusterHits); // update cluster and hit ID ArrayList cloneHitsWNewID = new ArrayList(); for(FTTRKHit clHit: twoClusterHits){ - clHit.set_DGTZIndex(clHit.get_Id()); - clHit.set_ClusterIndex(clusters.size()-2); - cloneHitsWNewID.add(clHit); + clHit.set_DGTZIndex(clHit.get_Id()); + //clHit.set_ClusterIndex(clusters.size()-2); + clHit.set_ClusterIndex(newIndex); + cloneHitsWNewID.add(clHit); } joinedClusters.addAll(cloneHitsWNewID); joinedClusters.calc_CentroidParams(); clusters.add(joinedClusters); } - // remove second clusters from the final list + // remove joined clusters from the final list if(clusterId11>=0 && clusterId12>=0) { if(clusterId11 findClusters(List hits) } } // end loop on layers + + // before returning cluster list re-calculate centroid and its error, if the cluster list was modified + if(needsReordering){ + int newClusterID = -1; + for(FTTRKCluster aCluster : clusters){ + aCluster.calc_CentroidParams(); + aCluster.set_CId(++newClusterID); // ClusterID relabelling to match the ordinal cluster number + } + } + return clusters; } @@ -324,21 +344,21 @@ public ArrayList findCrosses(List clusters) { int rid =-1; for(FTTRKCluster inlayerclus : allinnerlayrclus){ - if(inlayerclus.size()=1) System.out.println(inlayerclus.printInfo() + " " + outlayerclus.printInfo()); - if( (inlayerclus.get_MinStrip()+outlayerclus.get_MinStrip() > 1) + if( (inlayerclus.get_MinStrip()+outlayerclus.get_MinStrip() > 0) && (inlayerclus.get_MaxStrip()+outlayerclus.get_MaxStrip() < FTTRKConstantsLoader.Nstrips*2) ) { // put correct numbers to make sure the intersection is valid // define new cross FTTRKCross this_cross = new FTTRKCross(inlayerclus.get_Sector(), inlayerclus.get_Region(),++rid); this_cross.set_Cluster1(inlayerclus); this_cross.set_Cluster2(outlayerclus); + int dummy = this_cross.get_Cluster1().get_CId(); + int dummy2 = this_cross.get_Cluster2().get_CId(); this_cross.set_CrossParams(); //make arraylist @@ -430,6 +450,7 @@ public List readRawHits(DataEvent event, int run) { if(event.hasBank("FTTRK::adc")==true) { DataBank bankDGTZ = event.getBank("FTTRK::adc"); int nrows = bankDGTZ.rows(); + if(nrows>FTConstants.TRK_MAXNUMBEROFHITS) return hits; // if too many hits skip the event int hitId = -1; int nsec1 = -1, nsec2 = -1; for(int row = 0; row < nrows; row++){ @@ -477,10 +498,12 @@ public List readRawHits(DataEvent event, int run) { // read just layer sectors only for real data (no montecarlo) //icomponent = adjustStripNumberingTest11(run, ilayer, icomponent); -// icomponent = renumberStrip(ilayer, icomponent); -// icomponent = renumberFEE2RECRotatedAndAdjustVanilla(run, ilayer, icomponent); - icomponent = renumberFEE2RECRotatedAndAdjustHazel(run, ilayer, icomponent); - + //icomponent = renumberStrip(ilayer, icomponent); + //icomponent = renumberFEE2RECRotatedAndAdjustVanilla(run, ilayer, icomponent); + //icomponent = renumberFEE2RECRotatedAndAdjustHazel(run, ilayer, icomponent); + if(run != 10) icomponent = renumberFEE2RECRotatedAndAdjustWalnut(run, ilayer, icomponent); + + /* // layer 3: swap 6-7 e inversione if(ilayer==3){ @@ -592,17 +615,8 @@ public List readRawHits(DataEvent event, int run) { } */ - boolean isHitAccepted = true; - // select strips belonging to a crate (1-2-3) -// if(isStripInCrate(1, ilayer, icomponent)) hits.add(hit); - - if(isStripInCrate(1, ilayer, icomponent)){ - isHitAccepted = true; - }else{ - isHitAccepted = false; - } - +/// if(isStripInCrate(1, ilayer, icomponent)) hits.add(hit); // select strips belonging to a given physical connector in a layer // int iconn = findPhysicalConnector(icomponent); // if(ilayer==2 && iconn==6) hits.add(hit); // bad connector @@ -616,6 +630,7 @@ public List readRawHits(DataEvent event, int run) { if(ilayer==4 && icomponent>=119 && icomponent<=384) hits.add(hit); */ + boolean isHitAccepted = true; // if(ilayer == 2 || ilayer ==3) isHitAccepted = false; // if((ilayer==2) && icomponent<=641) isHitAccepted = false; // if((ilayer==4) && icomponent>=1 && icomponent>64) isHitAccepted = false; @@ -639,7 +654,7 @@ public List readRawHits(DataEvent event, int run) { */ // selection on strip time - if(time < 50 || time > 350) isHitAccepted = false; + if(time < FTConstants.TRK_STRIP_MIN_TIME || time > FTConstants.TRK_STRIP_MAX_TIME) isHitAccepted = false; if(icomponent<0) isHitAccepted = false; if(isHitAccepted) hits.add(hit); @@ -716,6 +731,7 @@ public void writeHipoBanks(DataEvent event, List hits, List hits, List1200.) continue; - // these are probaly outoftimers, no needo to cut - //if(crosses.get(j).get_Time()<150. || crosses.get(j).get_Time()>250.) continue; + //if(crosses.get(j).get_Energy()>1200.) continue; + // these are probaly outoftimers, no needo to cut + //if(crosses.get(j).get_Time()<150. || crosses.get(j).get_Time()>250.) continue; /////////////////////////////////////////////////////////////////////////////////////// bankCross.setShort("size", j, (short) crosses.size()); - bankCross.setShort("id", j, (short) crosses.get(j).get_Id()); +// bankCross.setShort("id", j, (short) crosses.get(j).get_Id()); + bankCross.setShort("id", j, (short) crosses.get(j).get_trkId()); bankCross.setByte("sector", j, (byte) crosses.get(j).get_Sector()); bankCross.setByte("detector", j, (byte) (crosses.get(j).get_Region()-1)); // detector: 0 or 1, region 1 or 2 bankCross.setFloat("x", j, (float) crosses.get(j).get_Point().x()); bankCross.setFloat("y", j, (float) crosses.get(j).get_Point().y()); bankCross.setFloat("z", j, (float) crosses.get(j).get_Point().z()); - System.out.println("energy and time to be stored in banks " + crosses.get(j).get_Energy() + " " + crosses.get(j).get_Time()); - FTEBEngine.h507.fill(crosses.get(j).get_Time(), crosses.get(j).get_Energy()); - if(crosses.get(j).get_Id()==0){ - FTEBEngine.h503.fill(crosses.get(j).get_Time()); - FTEBEngine.h501.fill(crosses.get(j).get_Energy()); - FTEBEngine.h505.fill(crosses.get(j).get_Time(), crosses.get(j).get_Energy()); - FTTRKCluster cl1 = crosses.get(j).get_Cluster1(); - FTTRKCluster cl2 = crosses.get(j).get_Cluster2(); - FTEBEngine.h510.fill(cl1.get_TotalEnergy(), cl2.get_TotalEnergy()); - FTEBEngine.h512.fill(cl1.get_TotalEnergy()); - FTEBEngine.h512.fill(cl2.get_TotalEnergy()); - for(int k=0; k20) System.out.println("wrong sector number, check code"); int offset = sectorLimit[nsector+1] - icomponent; - icomponent = sectorLimit[nsector] + offset; + icomponent = sectorLimit[nsector]+1 + offset; return icomponent; } +public int reverseStripInFirstHalf(int icomponent){ + // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is + // excluded in the sector, [i+1]is inluded + int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + int nsector = findSector(icomponent); + if(nsector>20) System.out.println("wrong sector number, check code"); + int halfStrip = (sectorLimit[nsector+1]-sectorLimit[nsector])/2 + sectorLimit[nsector]; + if(icomponent <= halfStrip){ + int offset = halfStrip - icomponent; + icomponent = sectorLimit[nsector]+1 + offset; + } + return icomponent; + } + + +public int reverseStripInSecondHalf(int icomponent){ + // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is + // excluded in the sector, [i+1]is included + int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + int nsector = findSector(icomponent); + if(nsector>20) System.out.println("wrong sector number, check code"); + int halfStrip = (sectorLimit[nsector+1]-sectorLimit[nsector])/2 + sectorLimit[nsector]; + if(icomponent > halfStrip){ + int offset = sectorLimit[nsector+1] - icomponent; + icomponent = halfStrip + offset; + } + return icomponent; + } + +public int swapHalves(int icomponent){ + // swap half the module to the opposite half, rigid translation + // the strips are numbered 1-768, the [i] component of sectorLimit vector is + // excluded in the sector, [i+1]is included + int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + int nsector = findSector(icomponent); + if(nsector>20) System.out.println("wrong sector number, check code"); + int halfWid = (sectorLimit[nsector+1]-sectorLimit[nsector])/2; + int halfStrip = halfWid + sectorLimit[nsector]; + if(icomponent >= halfStrip+1){ + icomponent -= halfWid; + }else{ + icomponent += (halfWid-1); + } + return icomponent; + } + +public int switchStripOff(){return -1;} + public int reverseStripsIn12Sectors(int icomponent){ - // flip the layer horizontally with respect to the x axis (top/bottom flip) int[] sectorLimit = {0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768}; int nsector = findIn12Sectors(icomponent); int offset = sectorLimit[nsector+1] - icomponent; @@ -1176,6 +1238,8 @@ public int reverseStripsIn12Sectors(int icomponent){ public int swapSectors(int icomponent, int nsector2){ // get the new strip number of the icomponent strip in nsector1 once the sector is swapped to nsector2 + // icomponent strips are numbered 1-768 so the vector sectorLimits contains the number of the starting + // strip of a sector: [i] is excluded from sector i, [i+1] is included int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector1 = findSector(icomponent); int offset = -sectorLimit[nsector1] + icomponent; @@ -1211,15 +1275,18 @@ public int swap12Sectors(int icomponent, int nsector2){ public static int findSector(int icomponent){ // returns the sector number, corresponding to the component of the lower extreme of the interval - // sectors are numbered 0-20 + // sectors are numbered 0-20; icomponent strips are numbered 1-768 so the vector sectorLimits contains + // the number of the starting strip of a sector: [i] is excluded from sector i, [i+1] is included int[] sectorLimits = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector = -1; for(int i=0; i<20; i++){ if(icomponent>sectorLimits[i] && icomponent<=sectorLimits[i+1]){ +// if(icomponent>=sectorLimits[i] && icomponent20) System.out.println("wrong sector number, check code"); return nsector; } @@ -1423,7 +1490,7 @@ public boolean isStripInCrate(int nCrate, int ilayer, int icomponent){ boolean isInCrate = false; // check if the strip belongs to a given connector - connectors are numbered 1-12 // icomponent is numberered 0-767 - int iConnector = findOrderedConnector(icomponent); + int iConnector = findPhysicalConnector(icomponent); // check if the connector belongs to the chosen crate if(nCrate==1){ if(ilayer==1){ @@ -1461,38 +1528,6 @@ public boolean isStripInCrate(int nCrate, int ilayer, int icomponent){ return isInCrate; } -public int findOrderedConnector(int icomponent){ - // returns the number of the physical connector one strip belongs to - // physical connectors are numbered 1-12 - int iConnector = -1; - if(icomponent>=0 && icomponent <64){ - iConnector = 1; - }else if(icomponent>=64 && icomponent <128){ - iConnector = 2; - }else if(icomponent>=128 && icomponent <192){ - iConnector = 3; - }else if(icomponent>=192 && icomponent <256){ - iConnector = 4; - }else if(icomponent>=384 && icomponent <448){ - iConnector = 7; - }else if(icomponent>=448 && icomponent <512){ - iConnector = 8; - }else if(icomponent>=512 && icomponent <576){ - iConnector = 9; - }else if(icomponent>=576 && icomponent <640){ - iConnector = 10; - }else if(icomponent>=256 && icomponent <320){ - iConnector = 5; - }else if(icomponent>=320 && icomponent <384){ - iConnector = 6; - }else if(icomponent>=640 && icomponent <704){ - iConnector = 11; - }else if(icomponent>=704 && icomponent <768){ - iConnector = 12; - } - return iConnector; -} - public int findPhysicalConnector(int icomponent){ // returns the number of the physical connector one strip belongs to // physical connectors are numbered 1-12 @@ -1523,8 +1558,7 @@ public int findPhysicalConnector(int icomponent){ iConnector = 12; } return iConnector; -} - +} public int renumberStrip(int ilayer, int icomponent){ // renumber strips from FEE number (to RECO numbering @@ -1533,7 +1567,7 @@ public int renumberStrip(int ilayer, int icomponent){ if(ilayer==1){ if((icomponent>=1 && icomponent <=128) || (icomponent>=641 && icomponent<=768)){ newStripNumber = icomponent; - }else if(icomponent>128 && icomponent<=256){ + }else if(icomponent>=129 && icomponent<=256){ newStripNumber = icomponent+256; }else if(icomponent>=257 && icomponent<=512){ newStripNumber = icomponent-128; @@ -1846,7 +1880,6 @@ public int renumberFEE2RECRotatedAndAdjustHazel(int run, int ilayer, int icompon if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); if(ilayer==3){ - // consider 16 sectors division int isec1 = findSector(icomponent); if(isec1==11){ icomponent = swapSectors(icomponent, 10); @@ -1889,19 +1922,15 @@ public int renumberFEE2RECRotatedAndAdjustHazel(int run, int ilayer, int icompon } */ -// if(isec1 != 10 && isec1 != 11) icomponent = -1; - - //if(isec1 != 4) icomponent = -1; - if(isec1 == 4){ -// icomponent = swap12Sectors(icomponent, 10); -// icomponent = -1; - } - - + //if(isec1 != 10 && isec1 != 11) icomponent = -1; +/// if(isec1 != 4) icomponent = -1; } + if(ilayer==3){ +// int isec1 = findIn12Sectors(icomponent); int isec1 = findIn12Sectors(icomponent); - //if(isec1 != 8) icomponent = -1; +// if(isec1 == 1 || isec1==6 || isec1 == 10) icomponent = -1; +/// if(isec1 != 8) icomponent = -1; } } @@ -1909,9 +1938,380 @@ public int renumberFEE2RECRotatedAndAdjustHazel(int run, int ilayer, int icompon return icomponent; } +public int renumberFEE2RECRotatedAndAdjustWalnut2(int run, int ilayer, int icomponent){ +// apply the renumbering schema - method 2 + if(run>0){ + //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); + icomponent = renumberStrip(ilayer, icomponent); + + if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); + if(ilayer==3){ + int isec1 = findSector(icomponent); + if(isec1==11){ + icomponent = swapSectors(icomponent, 10); + }else if(isec1==10){ + icomponent = swapSectors(icomponent, 11); + } + // reverse sectors 10-11 + flip horizontal + int newsec = findSector(icomponent); + if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); + icomponent = flipStripHorizontal(ilayer, icomponent); + } + + if(ilayer==1){ + int isec1 = findSector(icomponent); + if(isec1==18){ + if(icomponent > 672) icomponent = 1377-icomponent; + }else if(isec1==7){ + icomponent = swapSectors(icomponent, 6); + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==6){ + icomponent = swapSectors(icomponent, 7); + } + } + + if(ilayer==2){ + int isec1 = findSector(icomponent); + if(isec1==10){ + icomponent = swapSectors(icomponent, 11); + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==11){ + icomponent = swapSectors(icomponent, 10); + icomponent = reverseStripsInSector(icomponent); + } + } + + + if(ilayer==4){ + int isec1 = findSector(icomponent); + if(isec1==18){ + if(icomponent>= 673){ + icomponent -= 32; + }else{ + icomponent += 31; + } + } + } + + + if(ilayer==3){ + int isec1 = findSector(icomponent); + if(isec1==15){ + icomponent = swapSectors(icomponent, 13); + }else if(isec1==13){ + icomponent = swapSectors(icomponent, 15); + } + } + } + + return icomponent; +} + +public int maskFaultySectors(int ilay, int isec){ + int isMasked = 1; + // bad sectors, need masking + if( +// (ilay==2 && (isec==12 || isec==13) ) || +// (ilay==3 && (isec==7 ) ) || + isec<0 ) + isMasked = 0; + return isMasked; +} + + +public int renumberFEE2RECRotatedAndAdjustWalnut4(int run, int ilayer, int icomponent){ +// apply the renumbering schema - method 2 + if(run>0){ + //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); + icomponent = renumberStrip(ilayer, icomponent); + + if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); + if(ilayer==3){ + int isec1 = findSector(icomponent); + if(isec1==11){ + icomponent = swapSectors(icomponent, 10); + }else if(isec1==10){ + icomponent = swapSectors(icomponent, 11); + } + // reverse sectors 10-11 + flip horizontal + int newsec = findSector(icomponent); + if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); + icomponent = flipStripHorizontal(ilayer, icomponent); + } + + int isec1 = -1; + if(ilayer==1){ + isec1 = findSector(icomponent); + if(isec1==18){ + if(icomponent > 672){ + icomponent = 1377-icomponent; + }else{ + icomponent = 1312-icomponent; + } + }else if(isec1==7){ + icomponent = swapSectors(icomponent, 6); + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==6){ + icomponent = swapSectors(icomponent, 7); + }else if(isec1==13){ + icomponent = reverseStripsInSector(icomponent); + }else if(isec1 == 1){ + if(icomponent >= 128){ + icomponent = 224 - icomponent; + } + } + } + + if(ilayer==2){ + isec1 = findSector(icomponent); + if(isec1==10){ + icomponent = swapSectors(icomponent, 11); + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==11){ + icomponent = swapSectors(icomponent, 10); + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==1){ + icomponent = reverseStripsInSector(icomponent); + } + } + + + if(ilayer==4){ + isec1 = findSector(icomponent); + if(isec1==18){ + //icomponent = reverseStripsInSector(icomponent); + if(icomponent>= 673){ + icomponent -= 32; + }else{ + icomponent += 31; + } + }else if(isec1 == 5){ + icomponent = reverseStripsInSector(icomponent); + }else if(isec1 == 13){ + //icomponent = reverseStripsInSector(icomponent); + }else if(isec1 == 1){ + if(icomponent >= 128){ + icomponent = 224 - icomponent; + } + } + } + + + if(ilayer==3){ + isec1 = findSector(icomponent); + if(isec1==15){ + //icomponent = swapSectors(icomponent, 13); + // icomponent = swapSectors(icomponent, 15); + }else if(isec1==14){ + icomponent = swapSectors(icomponent, 15); + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==8){ + icomponent = reverseStripsInSector(icomponent); + } + } + isec1 = findSector(icomponent); // rehash + //icomponent = flipStripHorizontal(ilayer, icomponent); + + if(maskFaultySectors(ilayer, isec1) == 0) icomponent = -1; + } + return icomponent; } + +public int renumberFEE2RECRotatedAndAdjustWalnut(int run, int ilayer, int icomponent){ +// apply the renumbering schema - method 2 + if(run>0){ + //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); + icomponent = renumberStrip(ilayer, icomponent); + + if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); + + int isec1 = -1; + if(ilayer==1){ + isec1 = findSector(icomponent); + if(isec1==18){ + icomponent = reverseStripInFirstHalf(icomponent); + //icomponent = reverseStripInSecondHalf(icomponent); + }else if(isec1==7){ + icomponent = swapSectors(icomponent, 6); + icomponent = reverseStripsInSector(icomponent); //ok + }else if(isec1==6){ + //icomponent = swapSectors(icomponent, 8); + icomponent = swapSectors(icomponent, 7); + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==8){ + //icomponent = swapSectors(icomponent, 7); + }else if(isec1==13){ + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==14){ + icomponent = reverseStripsInSector(icomponent); + }else if(isec1 == 1){ + ///if(icomponent >= 96){ + /// icomponent = 224 - icomponent; + ///}//else{ + // icomponent = 160 - icomponent; + //} + icomponent = reverseStripInSecondHalf(icomponent); + } + //if(isec1==18){ + // icomponent = swapSectors(icomponent, 19); + //icomponent = reverseStripsInSector(icomponent); + //if(icomponent>672){ + // icomponent -= 32; + //}else{ + // icomponent += 32; + //} + //}else if(isec1==19){ + // icomponent = swapSectors(icomponent, 18); + //} + } + + if(ilayer==2){ + isec1 = findSector(icomponent); + if(isec1==10){ + //icomponent = swapSectors(icomponent, 11); + //icomponent = reverseStripsInSector(icomponent); + }else if(isec1==11){ + //icomponent = swapSectors(icomponent, 10); + //icomponent = reverseStripsInSector(icomponent); + }else if(isec1==1){ + icomponent = reverseStripsInSector(icomponent); + //if(icomponent<=96) icomponent += 32; + //icomponent = reverseStripInSecondHalf(icomponent); + if(icomponent>96) icomponent -= 8; + }else if(isec1==3){ + icomponent = reverseStripsInSector(icomponent); + //if(icomponent<=96) icomponent += 32; + //icomponent = reverseStripInSecondHalf(icomponent); + }else if(isec1==18){ + //icomponent = switchStripOff(); + //if(icomponent > 672) icomponent = swapSectors(icomponent, 19); + ///if(icomponent>= 673){ + /// icomponent -= 32; + ///}else{ + /// icomponent += 31; + ///} + //if(icomponent > 672){ + // icomponent = 1377-icomponent; + //}else{ + // icomponent = 1312-icomponent; + //} + // icomponent = reverseStripsInSector(icomponent); + }else if(isec1==19){ + //icomponent = switchStripOff(); + //if(icomponent <= 736) icomponent -= 32; + }else if(isec1==0){ + //icomponent = swapSectors(icomponent, 1); + //if(icomponent > 48 && icomponent <= 64) icomponent += 16; + //if(icomponent > 32) icomponent = -1; + //icomponent = reverseStripInSecondHalf(icomponent); + } + } + + + if(ilayer==3){ + isec1 = findSector(icomponent); + if(isec1==11){ + icomponent = swapSectors(icomponent, 10); + }else if(isec1==10){ + icomponent = swapSectors(icomponent, 11); + } + // reverse sectors 10-11 + flip horizontal + int newsec = findSector(icomponent); + if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); + icomponent = flipStripHorizontal(ilayer, icomponent); + + isec1 = findSector(icomponent); +// if(isec1 == 1 || isec1==6 || isec1 == 10) icomponent = -1; +/// if(isec1 != 8) icomponent = -1; + if(isec1==15){ + //icomponent = swapSectors(icomponent, 13); + // icomponent = swapSectors(icomponent, 15); + icomponent = swapSectors(icomponent, 14); + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==14){ + icomponent = swapSectors(icomponent, 15); + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==7){ + //icomponent = swapSectors(icomponent, 8); + //icomponent = reverseStripsInSector(icomponent); + }else if(isec1==8){ + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==0){ //swap half of sector 0 + //if(icomponent>=33){ + // icomponent -= 32; + //}else{ + // icomponent += 31; + //}else if(isec1==18){ + // if(icomponent < 673) icomponent = swapSectors(icomponent, 17); + //}else if(isec1==17){ + // icomponent = swapSectors(icomponent, 18); + }else if(isec1==2){ + // icomponent = swapSectors(icomponent, 3); + //}else if(isec1==3){ + // icomponent = swapSectors(icomponent, 2); + }else if(isec1==10){ + //icomponent = swapSectors(icomponent, 9); + }else if(isec1==11){ + //icomponent = switchStripOff(); + //icomponent = swapSectors(icomponent, 9); + } + /* + isec1 = findSector(icomponent); // rehash + if(isec1==13){ + icomponent = swapSectors(icomponent, 15); + } + */ + } + + if(ilayer==4){ + isec1 = findSector(icomponent); + if(isec1==18){ + ////icomponent = reverseStripsInSector(icomponent); + //if(icomponent>= 673){ // qui sembra che faccia swap tra prima e seconda meta' + // icomponent -= 32; + //}else{ + // icomponent += 31; + //} + icomponent = swapHalves(icomponent); + icomponent = reverseStripInSecondHalf(icomponent); + }else if(isec1 == 15){ + //component = swapSectors(icomponent, 14); + //icomponent = reverseStripsInSector(icomponent); + }else if(isec1 == 5){ + icomponent = reverseStripsInSector(icomponent); + }else if(isec1 == 13){ + //icomponent = reverseStripsInSector(icomponent); + }else if(isec1 == 1){ + icomponent = reverseStripInSecondHalf(icomponent); + }else if(isec1 == 6){ + icomponent = reverseStripsInSector(icomponent); + } + } + + isec1 = findSector(icomponent); // rehash + //icomponent = flipStripHorizontal(ilayer, icomponent); + + //if(maskFaultySectors(ilayer, isec1) == 0) icomponent = -1; + /* + // select bad crosses rejecting all other strips + int newsec = findSector(icomponent); + if(ilayer==1){ + if(newsec != 3) icomponent = -1; + }else if(ilayer==2){ + if(newsec != 14); icomponent = -1; + }else{ + icomponent = -1; + } + */ + } + + return icomponent; +} + + +} From 3f573404fda247877902c631782583fd3249f756 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 15:50:44 +0100 Subject: [PATCH 050/104] fixes in centroid evaluation for clusters with limiting strips --- .../org/jlab/rec/ft/trk/FTTRKCluster.java | 208 +++++++++++------- 1 file changed, 133 insertions(+), 75 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java index 473c340805..ff902a6d2c 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Vector3D; +import org.jlab.rec.ft.FTConstants; /** * @@ -18,11 +19,14 @@ public class FTTRKCluster extends ArrayList implements ComparablemaxStripsForTM){ // max energy strip for(int i=0; i< nbhits; i++){ @@ -204,74 +201,135 @@ public void calc_CentroidParams() { } } } - + // are all the strips int he cluster consecutive? if they are limiting pick as seed the strip with larger energy release + /* + boolean isCutInside = false; + for(int i=0; i< nbhits-1; i++){ + FTTRKHit oneHit = this.get(i); + FTTRKHit theNext = this.get(i+1); + if(oneHit.get_Strip() != theNext.get_Strip()) isCutInside = true; + double stripEn = oneHit.get_Edep(); + if(stripEn> maxEn1){ + maxEn1 = stripEn; + maxI = i; + } + if(i==nbhits-1){ + stripEn = theNext.get_Edep(); + if(stripEn> maxEn1){ + maxEn1 = stripEn; + maxI = i+1; + } + } + } // looping over the number of hits in the cluster - for(int i=0;i0.5) {continue;} - // get strip informations - int strpNb = thehit.get_Strip(); - double x1 = thehit.get_StripSegment().origin().x(); - double y1 = thehit.get_StripSegment().origin().y(); - double z1 = thehit.get_StripSegment().origin().z(); - double x2 = thehit.get_StripSegment().end().x(); - double y2 = thehit.get_StripSegment().end().y(); - double z2 = thehit.get_StripSegment().end().z(); - - totEn += strpEn; - totEnSq += strpEn*strpEn; - int layer = thehit.get_Layer(); - int Slayer = thehit.get_HalfLayer(layer); - double y = (double)FTTRKConstantsLoader.stripsYloc[Slayer][strpNb-1][0]; -// double y = (double)FTTRKConstantsLoader.stripsY[Slayer][strpNb-1][0]; - - weightedStrp+= strpEn*y; - weightedStripEndPoint1X+= strpEn*x1; - weightedStripEndPoint1Y+= strpEn*y1; - weightedStripEndPoint1Z+= strpEn*z1; - weightedStripEndPoint2X+= strpEn*x2; - weightedStripEndPoint2Y+= strpEn*y2; - weightedStripEndPoint2Z+= strpEn*z2; - // getting the max and min strip number in the cluster - if(strpNb<=min) - min = strpNb; - if(strpNb>=max) - max = strpNb; - // getting the seed strip which is defined as the strip with the largest deposited energy - if(strpEn>=Emax) { - Emax = strpEn; - seed = strpNb; // seed: hit with largest energy release - } - Slay = 2*Slayer; - } - if(totEn==0) { + isCutInside = false; + if(isCutInside){ + // if there is a limiting strip choose as centroid (seed) the strip with max energy release + int maxStripNumber = -1; + int minStripNumber = 1000; + for(int i=0;i= maxStripNumber) maxStripNumber = numStrip; + if(numStrip <= minStripNumber) minStripNumber = numStrip; + } + FTTRKHit centHit = this.get(maxI); + int layer = centHit.get_Layer(); + int Slayer = centHit.get_HalfLayer(layer); + int strpNb = seed = centHit.get_Strip(); + Slay = 2*Slayer; + double y = (double)FTTRKConstantsLoader.stripsYloc[Slayer][strpNb-1][0]; + + if(totEn==0) { System.err.println(" Cluster energy is null .... exit"); return; - } + } - this.set_MinStrip(min); - this.set_MaxStrip(max); - this.set_SeedStrip(seed); - this.set_SeedEnergy(Emax); - // calculates the centroid values and associated positions (in local RF) - stripYCent = weightedStrp/totEn; // - //System.out.println(" --> centroid "+stripNumCent); - // extreme points of the strip in global RF - xCentEndPoint1 = weightedStripEndPoint1X/totEn; - yCentEndPoint1 = weightedStripEndPoint1Y/totEn; - zCentEndPoint1 = weightedStripEndPoint1Z/totEn; - xCentEndPoint2 = weightedStripEndPoint2X/totEn; - yCentEndPoint2 = weightedStripEndPoint2Y/totEn; - zCentEndPoint2 = weightedStripEndPoint2Z/totEn; - + this.set_MinStrip(minStripNumber); + this.set_MaxStrip(maxStripNumber); + this.set_SeedStrip(seed); + this.set_SeedEnergy(maxEn1); + // calculates the centroid values and associated positions (in local RF) + stripYCent = seed; + //System.out.println(" --> centroid "+stripNumCent); + // extreme points of the strip in global RF + xCentEndPoint2 = centHit.get_StripSegment().end().x(); + yCentEndPoint2 = centHit.get_StripSegment().end().y(); + zCentEndPoint2 = centHit.get_StripSegment().end().z(); + xCentEndPoint1 = centHit.get_StripSegment().origin().x(); + yCentEndPoint1 = centHit.get_StripSegment().origin().y(); + zCentEndPoint1 = centHit.get_StripSegment().origin().z(); + + }else{ + */ + for(int i=0;i0.5) {continue;} + // get strip informations + int strpNb = thehit.get_Strip(); + double x1 = thehit.get_StripSegment().origin().x(); + double y1 = thehit.get_StripSegment().origin().y(); + double z1 = thehit.get_StripSegment().origin().z(); + double x2 = thehit.get_StripSegment().end().x(); + double y2 = thehit.get_StripSegment().end().y(); + double z2 = thehit.get_StripSegment().end().z(); + + totEn += strpEn; + totEnSq += strpEn*strpEn; + int layer = thehit.get_Layer(); + int Slayer = thehit.get_HalfLayer(layer); + double y = (double)FTTRKConstantsLoader.stripsYloc[Slayer][strpNb-1][0]; +// double y = (double)FTTRKConstantsLoader.stripsY[Slayer][strpNb-1][0]; + + weightedStrp+= strpEn*y; + weightedStripEndPoint1X+= strpEn*x1; + weightedStripEndPoint1Y+= strpEn*y1; + weightedStripEndPoint1Z+= strpEn*z1; + weightedStripEndPoint2X+= strpEn*x2; + weightedStripEndPoint2Y+= strpEn*y2; + weightedStripEndPoint2Z+= strpEn*z2; + // getting the max and min strip number in the cluster + if(strpNb<=min) min = strpNb; + if(strpNb>=max) max = strpNb; + // getting the seed strip which is defined as the strip with the largest deposited energy + if(strpEn>=Emax) { + Emax = strpEn; + seed = strpNb; // seed: hit with largest energy release + } + Slay = 2*Slayer; + } + if(totEn==0) { + System.err.println(" Cluster energy is null .... exit"); + return; + } + + this.set_MinStrip(min); + this.set_MaxStrip(max); + this.set_SeedStrip(seed); + this.set_SeedEnergy(Emax); + // calculates the centroid values and associated positions (in local RF) + stripYCent = weightedStrp/totEn; // + //System.out.println(" --> centroid "+stripNumCent); + // extreme points of the strip in global RF + xCentEndPoint1 = weightedStripEndPoint1X/totEn; + yCentEndPoint1 = weightedStripEndPoint1Y/totEn; + zCentEndPoint1 = weightedStripEndPoint1Z/totEn; + xCentEndPoint2 = weightedStripEndPoint2X/totEn; + yCentEndPoint2 = weightedStripEndPoint2Y/totEn; + zCentEndPoint2 = weightedStripEndPoint2Z/totEn; + //} } - // use the discrete coordinate of the seed strip x-y (for debug purposes only) /* int seed = this.get_SeedStrip(); From 7b90db5b66488e34551ee1490abcc14c107acbd8 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 16:01:31 +0100 Subject: [PATCH 051/104] inlcude new private variable as track matching reference --- .../java/org/jlab/rec/ft/trk/FTTRKCross.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java index 4d869bd6ad..a81cf62b89 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java @@ -27,7 +27,8 @@ public class FTTRKCross implements Comparable { private int _Sector; // sector[1] private int _Region; // region [1,2] private int _Id; // cross Id [0,1] - + private int _trkId; // cross index for tracking + // point parameters: private Point3D _Point; private Point3D _PointErr; @@ -41,6 +42,8 @@ public class FTTRKCross implements Comparable { private float _Energy; private float _Time; + + /** * * @param sector the sector (1) @@ -50,7 +53,8 @@ public class FTTRKCross implements Comparable { public FTTRKCross(int sector, int region, int rid) { this._Sector = sector; this._Region = region; - this._Id = rid; + this._Id = rid; // sequential number + this._trkId = rid; } /** @@ -103,8 +107,15 @@ public void set_Id(int id) { this._Id = id; } - - + public int get_trkId() { + return _trkId; + } + + public void set_trkId(int trkid) { + this._trkId = trkid; + } + + /** * @@ -239,6 +250,11 @@ public FTTRKCluster get_Cluster2() { return _clus2; } + public int getDetector() { + return (_Region-1); + } + + /** * Sets the cross parameters: the position and direction unit vector */ @@ -333,7 +349,7 @@ public void set_CrossParams() { } Point3D error = new Point3D(err1, err2, thickness); this.set_PointErr(error); - this.set_AssociatedElementsIDs(); + this.set_AssociatedElementsIDs(); // associates cross number to the clusters }else{ Point3D error = new Point3D(-999., -999., -999); this.set_Point(error); @@ -341,6 +357,7 @@ public void set_CrossParams() { } this.evaluate_EnergyAndTime(); + } public void evaluate_EnergyAndTime(){ From ddcbe4cc39471d5ef2fef84d08b30fdb30e4fa1d Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 16:05:40 +0100 Subject: [PATCH 052/104] update input list --- .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java index dfd94d2c78..6beded4d26 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java @@ -142,8 +142,18 @@ public static void main (String arg[]) { /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_dis.hipo"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; ////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; - String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418.0.hipo"; +/////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418.0.hipo"; +// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; // String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_fullAcceptance_singleTrack.hipo"; +// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_154824_det0.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_153947_det1.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_160427_det1.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_42486.hipo"; // multihit evt + String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_10323.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_92897.hipo"; +/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_test_1000.hipo"; +/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance_newbanks.hipo"; System.out.println("input file " + input); HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -245,6 +255,7 @@ public static void main (String arg[]) { float time = bank.getFloat("time",i); if(debug>=1) System.out.println("layer " + layer + " strip " + comp); + System.out.println("%%%%%%%%% layer " + layer + " strip " + comp + " sector " + FTTRKReconstruction.findSector(comp)); h1.fill(comp,layer); h2.fill(energy); h3.fill(time); @@ -295,7 +306,7 @@ public static void main (String arg[]) { maxcomp4 = bank.getShort("component", imax4); } - /* + // iterate along the cluster list for every event if(debug>=1) System.out.println("clusters size --- " + clusters.size()); if(clusters.size()!=0){ @@ -417,8 +428,7 @@ public static void main (String arg[]) { } } } - } -*/ + } } From 371d1c8d56488ad1c2ec4a7ba6a7bb9711c5f276 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 16:32:38 +0100 Subject: [PATCH 053/104] tune constants for TRK tracking --- .../src/main/java/org/jlab/rec/ft/FTConstants.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java index 8cfe5d580e..bb6719caa4 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java @@ -25,15 +25,9 @@ public class FTConstants { public static final double TRK_MIN_CROSS_NUMBER = 1; // minimum number of crosses to find a line in the tracker // public static final double TRK0_TRK1_DISTANCE_MATCHING = 0.25; // matching distance between FTTRK points in cms // public static final double TOLERANCE_ON_CROSSES_TWO_DETECTORS = 0.; // 1. cm radius tolerance, tune it up - public static final double TRK0_TRK1_RADTOL = 1.; // max tolerance for TRK0/TRK1 distance (3D) -/// public static final double TRK0_TRK1_RADTOL = 0.5; // max tolerance for TRK0/TRK1 radial distance (2D) -/// public static final double TRK0_TRK1_PHITOL = 0.07; // max tolerance for TRK0/TRK1 phi angular deviation -/// public static final double TRK0_TRK1_THETATOL = 0.07; // max tolerance for TRK0/TRK1 theta angulare deviation -// public static final double TRK0_TRK1_RADTOL = 10.; // max tolerance for TRK0/TRK1 radial distance (2D) -// public static final double TRK0_TRK1_PHITOL = 1.; // max tolerance for TRK0/TRK1 phi angular deviation -// public static final double TRK0_TRK1_THETATOL = 1.; // max tolerance for TRK0/TRK1 theta angulare deviation - public static final double TRK0_TRK1_PHITOL = 0.7; // max tolerance for TRK0/TRK1 phi angular deviation - public static final double TRK0_TRK1_THETATOL = 0.7; + public static final double TRK0_TRK1_RADTOL = 0.1; // max tolerance for TRK0/TRK1 distance (3D) (was 1.-0.5) + public static final double TRK0_TRK1_PHITOL = 0.07; // max tolerance for TRK0/TRK1 phi angular deviation (was 1.-0.7) + public static final double TRK0_TRK1_THETATOL = 0.07; // max tolerance for TRK0/TRK1 theta angulare deviation (was 1.-0.7= public static final double FTTRKMinAdcThreshold = 18.; // check min threshold for FTTTRK ADCs (18) public static final double FTTRKMaxAdcThreshold = 2000.; // check max threshold for FTTTRK ADCs (18) was 1000 170122 From cc73d61f50fa167f85c044eed8496c8dea3b265b Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 16:36:38 +0100 Subject: [PATCH 054/104] fix for multitrack matching, new histograms for diagnostics, trk crosses quality selection --- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 256 ++++++++++++++++-- 1 file changed, 232 insertions(+), 24 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index 49cef76a52..aed28485af 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -75,7 +75,8 @@ public boolean processDataEvent(DataEvent event) { FTparticles = reco.initFTparticles(FTresponses); if(FTparticles.size()>0){ //// reco.matchToTRK(FTresponses, FTparticles); - reco.matchToTRKTwoDetectors(FTresponses, FTparticles); +//// reco.matchToTRKTwoDetectors(FTresponses, FTparticles); + reco.matchToTRKTwoDetectorsMultiHits(FTresponses, FTparticles); reco.matchToHODO(FTresponses, FTparticles); // reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo reco.writeBanks(event, FTparticles); @@ -158,7 +159,6 @@ public int getDebugMode() { public static H1F h522 = new H1F("time of strips in cluster1 TRK1", 100, 0., 500.); public static H1F h523 = new H1F("Time of strips in cluster2 TRK1", 100, 0., 500.); - public static H1F h600 = new H1F("TRK response position", 100, 5.93, 6.03); public static H2F h601 = new H2F("TRK tof vs time", 100, 0., 500., 100, 5.93, 6.03); public static H1F h602 = new H1F("cross0 time", 100, 0.0001, 500.); @@ -169,7 +169,9 @@ public int getDebugMode() { public static H2F hSeedDet0 = new H2F("lay 2 vs lay1 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); public static H2F hSeedDet1 = new H2F("lay 4 vs lay3 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); - + public static Point3D ORIGIN = new Point3D(0., 0., 0.); + + public static void main(String arg[]){ FTCALEngine cal = new FTCALEngine(); @@ -285,7 +287,41 @@ public static void main(String arg[]){ h109.setOptStat(10); h109.setTitleX("trk2 phi residual (rad)"); h109.setFillColor(51); - + + H1F resTrkXdet0 = new H1F("trk1 x residual wrt line thru trk0", 63, -0.5, 0.5); + resTrkXdet0.setOptStat(10); + resTrkXdet0.setTitleX("trk1 x residual (mm) wrt line thru trk0"); + resTrkXdet0.setFillColor(9); + H1F resTrkYdet0 = new H1F("trk1 y residual wrt line thru trk0", 63, -0.5, 0.5); + resTrkYdet0.setOptStat(10); + resTrkYdet0.setFillColor(9); + resTrkYdet0.setTitleX("trk1 y residual (mm) wrt line thru trk0"); + H1F resTrkXdet1 = new H1F("trk0 x residual wrt line thru trk1", 63, -0.5, 0.5); + resTrkXdet1.setOptStat(10); + resTrkXdet1.setFillColor(49); + resTrkXdet1.setTitleX("trk0 y residual (mm) wrt line thru trk1"); + H1F resTrkYdet1 = new H1F("trk0 y residual wrt line thru trk1", 63, -0.5, 0.5); + resTrkYdet1.setOptStat(10); + resTrkYdet1.setTitleX("trk0 y residual (mm) wrt line thru trk1"); + resTrkYdet1.setFillColor(49); + + H1F resTrkThetadet0 = new H1F("trk1 theta residual (rad) wrt line thru trk0", 100, -0.005, 0.005); + resTrkThetadet0.setOptStat(10); + resTrkThetadet0.setTitleX("trk1 theta residual (rad) wrt line thru trk0"); + resTrkThetadet0.setFillColor(9); + H1F resTrkThetadet1 = new H1F("trk0 theta residual (rad) wrt line thru trk1", 100, -0.005, 0.005); + resTrkThetadet1.setOptStat(10); + resTrkThetadet1.setTitleX("trk0 theta residual (rad) wrt line thru trk1"); + resTrkThetadet1.setFillColor(49); + H1F resTrkPhidet0 = new H1F("trk1 phi residual (rad) wrt line thru trk0", 100, -0.1, 0.1); + resTrkPhidet0.setOptStat(10); + resTrkPhidet0.setTitleX("trk1 phi residual wrt line thru trk0"); + resTrkPhidet0.setFillColor(9); + H1F resTrkPhidet1 = new H1F("trk0 phi residual (rad) wrt line thru trk1", 100, -0.1, 0.1); + resTrkPhidet1.setOptStat(10); + resTrkPhidet1.setTitleX("trk0 phi residual (rad) wrt line thru trk1"); + resTrkPhidet1.setFillColor(49); + // H1F h202 = new H1F("trk1 x", 25, 9., 9.4); // H1F h1202 = new H1F("trk1 x MC", 25, 9., 9.4); H1F h202 = new H1F("trk1 x", 25, 8.2, 9.0); @@ -432,11 +468,13 @@ public static void main(String arg[]){ h83.setLineColor(1); h83.setFillColor(33); H1F h84 = new H1F("hOccupancyMatched4", 768, 0., 769.); h84.setTitleX("Component layer 4"); h84.setLineColor(1); h84.setFillColor(34); - - + + double diffRadTolerance = FTConstants.TRK0_TRK1_RADTOL; + double diffPhiTolerance = FTConstants.TRK0_TRK1_PHITOL; + double diffThetaTolerance = FTConstants.TRK0_TRK1_THETATOL; int nev = 0; - int nevWithCrosses = 0, ncrosses2 = 0; + int nevWithCrosses = 0, ncrosses2 = 0, nOfFTParticles = 0; while (reader.hasEvent()) { // run over all events // int nev1 = 0; int nev2 = 10000; for(nev=nev1; nev0) nOfFTParticles++; for (int i = 0; i < nrows; i++) { int calId = bank.getShort("calID",i); if(bank.getByte("charge", i)==-1 && bank.getShort("calID",i)>0) { @@ -521,8 +560,8 @@ public static void main(String arg[]){ // if(matchedCrosses != 1){ - if(matchedCrosses != 2){ -// if(matchedCrosses == 0){ // accept all crosses +// if(matchedCrosses != 2){ + if(matchedCrosses == 0){ // accept all crosses continue; }else{ ncrosses2++; @@ -621,7 +660,7 @@ public static void main(String arg[]){ h72.fill(seed2); }else if(lay2==3){ h73.fill(seed2); -; }else if(lay2==4){ + }else if(lay2==4){ h74.fill(seed2); } @@ -684,10 +723,10 @@ public static void main(String arg[]){ System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 13-11 bad seeds d0, event " + nev); } */ - /* + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + " bad seeds d0, event " + nev); - */ + canvasCALTRK.cd(0); segment1.setLineColor(1); segment2.setLineColor(2); @@ -717,19 +756,63 @@ public static void main(String arg[]){ System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 2-18 bad seeds d1, event " + nev); } */ - /* + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + " bad seeds d1, event " + nev); - */ + canvasCALTRK.cd(1); segment1.setLineColor(3); segment2.setLineColor(4); canvasCALTRK.draw(segment1); canvasCALTRK.draw(segment2); } + + // extract residuals of TRK1 wrt TRK0 and viceversa + // loop on crosses in det0, find track connecting with origin, evaluate residuals of TRK1 hits wrt to this track + + double cx = hitOnTrk.x() - ORIGIN.x(); + double cy = hitOnTrk.y() - ORIGIN.y(); + double cz = hitOnTrk.z() - ORIGIN.z(); + for(int ncj = 0; ncj < ncrosses; ncj++) { + int det1 = banktrk.getInt("detector", ncj); + if(det1 >=0 && nc != ncj && det != det1){ + double x1 = banktrk.getFloat("x", ncj); + double y1 = banktrk.getFloat("y", ncj); + double z1 = banktrk.getFloat("z", ncj); + int secondCrossID = banktrk.getInt("id", ncj); + Vector3D cross = new Vector3D(x1, y1, z1); + // check if within tolerance (previously done in findCross) + double r0 = Math.sqrt(hitOnTrk.x()*hitOnTrk.x() + hitOnTrk.y()*hitOnTrk.y() + hitOnTrk.z()*hitOnTrk.z()); + double r1 = Math.sqrt(cross.x()*cross.x() + cross.y()*cross.y() + cross.z()*cross.z()); + double r02d = Math.sqrt(hitOnTrk.x()*hitOnTrk.x() + hitOnTrk.y()*hitOnTrk.y()); + double r12d = Math.sqrt(cross.x()*cross.x() + cross.y()*cross.y()); + double diffRadii = r02d-r12d; + double diffTheta = Math.acos(hitOnTrk.z()/r0) - Math.acos(cross.z()/r1); + double diffPhi = Math.atan2(hitOnTrk.y(), hitOnTrk.x()) - Math.atan2(cross.y(), cross.x()); + if(Math.abs(diffPhi) < diffPhiTolerance && Math.abs(diffRadii)< diffRadTolerance && + Math.abs(diffTheta) < diffThetaTolerance){ + double t = cross.z()/hitOnTrk.z(); + Vector3D pointOnTrackAtZ = new Vector3D(cx*t + ORIGIN.x(), cy*t + ORIGIN.y(), z1); + //if(det1 == 1){ + if(det1 == 1 && trk1ID == secondCrossID){ + resTrkXdet0.fill(pointOnTrackAtZ.x() - cross.x()); + resTrkYdet0.fill(pointOnTrackAtZ.y() - cross.y()); + resTrkThetadet0.fill(pointOnTrackAtZ.theta() - cross.theta()); + resTrkPhidet0.fill(pointOnTrackAtZ.phi() - cross.phi()); + //}else if(det1 == 0){ + }else if(det1 == 0 && trk0ID == secondCrossID){ + resTrkXdet1.fill(pointOnTrackAtZ.x() - cross.x()); + resTrkYdet1.fill(pointOnTrackAtZ.y() - cross.y()); + resTrkThetadet1.fill(pointOnTrackAtZ.theta() - cross.theta()); + resTrkPhidet1.fill(pointOnTrackAtZ.phi() - cross.phi()); + } + } + } + } } - } + } + if(ncrosses==2){ float x0 = banktrk.getFloat("x", 0); float y0 = banktrk.getFloat("y", 0); @@ -743,21 +826,21 @@ public static void main(String arg[]){ System.out.println("x coordinates on 2 layers " + x0 + " " + x1); System.out.println("director cosines straight line bw crosses, cx " + lineBwCrosses.originDir().x() + " cy " + lineBwCrosses.originDir().y() + " cz " + lineBwCrosses.originDir().z()); - } + } } } } } } - if(event.hasBank("FTTRK::crosses")){ nevWithCrosses++; DataBank banktrk = event.getBank("FTTRK::crosses"); int nrows = banktrk.rows(); - // how many particles have been generated? - int ipart = gen.countGenerated(); + // comparison with MC data + // how many particles have been generated? + int ipart = gen.countGenerated(); for(int ip=0; ip=0) System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + nevWithCrosses); + if(debugMode>=0) + System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + + nevWithCrosses + " @@@@ number of reconstructed FTParticles " + nOfFTParticles); JFrame frame = new JFrame("FT Reconstruction"); frame.setSize(1200, 800); @@ -943,7 +1060,7 @@ public static void main(String arg[]){ frame.setLocationRelativeTo(null); frame.setVisible(true); - double narrowFactor = 6.5; // was 4.5 + double narrowFactor = 7.; // was 4.5 JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); frametrk.setSize(1600, 800); EmbeddedCanvas canvastrk = new EmbeddedCanvas(); @@ -967,7 +1084,7 @@ public static void main(String arg[]){ canvastrk.draw(f02,"same"); canvastrk.cd(2); canvastrk.draw(h104); - F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/(narrowFactor+0.2)); + F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/(narrowFactor)); f04.setParameter(0, 10.0); f04.setParameter(1, 0.0); f04.setParameter(2, 1.0); @@ -1569,6 +1686,97 @@ public static void main(String arg[]){ frameOccMatch.setLocationRelativeTo(null); frameOccMatch.setVisible(true); + + JFrame frametrkonlyres = new JFrame("FTTRK residuals with respect to the second detector"); + frametrkonlyres.setSize(1600, 800); + EmbeddedCanvas canvastrkonlyres = new EmbeddedCanvas(); + canvastrkonlyres.divide(4, 2); + int nc=-1; + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkXdet0); + double lowLim = resTrkXdet0.getMean() - resTrkXdet0.getRMS()/1.5; + double upLim = resTrkXdet0.getMean() + resTrkXdet0.getRMS()/1.5; + F1D f10x = new F1D("f10x","[amp]*gaus(x,[mean],[sigma])", lowLim, upLim); + f10x.setParameter(0, resTrkXdet0.getMax()); + f10x.setParameter(1, resTrkXdet0.getMean()); + f10x.setParameter(2, resTrkXdet0.getRMS()); + f10x.setLineColor(6); + f10x.setLineWidth(3); + DataFitter.fit(f10x, resTrkXdet0, " "); //No options uses error for sigma + f10x.setParameter(0, f10x.parameter(0).value()); + f10x.setParameter(1, f10x.parameter(1).value()); + f10x.setParameter(2, f10x.parameter(2).value()); + DataFitter.fit(f10x, resTrkXdet0, " "); //No options uses error for sigma + f10x.setOptStat(11111); + canvastrkonlyres.draw(f10x,"same"); + + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkYdet0); + lowLim = resTrkYdet0.getMean() - resTrkYdet0.getRMS()/1.5; + upLim = resTrkYdet0.getMean() + resTrkYdet0.getRMS()/1.5; + F1D f10y = new F1D("f10y","[amp]*gaus(x,[mean],[sigma])", lowLim, upLim); + f10y.setParameter(0, resTrkYdet0.getMax()); + f10y.setParameter(1, resTrkYdet0.getMean()); + f10y.setParameter(2, resTrkYdet0.getRMS()); + f10y.setLineColor(6); + f10y.setLineWidth(3); + DataFitter.fit(f10y, resTrkYdet0, "Q"); //No options uses error for sigma + f10y.setParameter(0, f10y.parameter(0).value()); + f10y.setParameter(1, f10y.parameter(1).value()); + f10y.setParameter(2, f10y.parameter(2).value()); + DataFitter.fit(f10y, resTrkYdet0, "Q"); //No options uses error for sigma + f10y.setOptStat(11111); + canvastrkonlyres.draw(f10y,"same"); + + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkThetadet0); + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkPhidet0); + + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkXdet1); + lowLim = resTrkXdet1.getMean() - resTrkXdet1.getRMS()/1.5; + upLim = resTrkXdet1.getMean() + resTrkXdet1.getRMS()/1.5; + F1D f11x = new F1D("f11x","[amp]*gaus(x,[mean],[sigma])", lowLim, upLim); + f11x.setParameter(0, resTrkXdet1.getMax()); + f11x.setParameter(1, resTrkXdet1.getMean()); + f11x.setParameter(2, resTrkXdet1.getRMS()); + f11x.setLineColor(6); + f11x.setLineWidth(3); + DataFitter.fit(f11x, resTrkXdet1, "Q"); //No options uses error for sigma + f11x.setParameter(0, f11x.parameter(0).value()); + f11x.setParameter(1, f11x.parameter(1).value()); + f11x.setParameter(2, f11x.parameter(2).value()); + DataFitter.fit(f11x, resTrkXdet1, "Q"); //No options uses error for sigma + f11x.setOptStat(11111); + canvastrkonlyres.draw(f11x,"same"); + + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkYdet1); + lowLim = resTrkYdet1.getMean() - resTrkYdet1.getRMS()/1.5; + upLim = resTrkYdet1.getMean() + resTrkYdet1.getRMS()/1.5; + F1D f11y = new F1D("f11y","[amp]*gaus(x,[mean],[sigma])", lowLim, upLim); + f11y.setParameter(0, resTrkYdet1.getMax()); + f11y.setParameter(1, resTrkYdet1.getMean()); + f11y.setParameter(2, resTrkYdet1.getRMS()); + f11y.setLineColor(6); + f11y.setLineWidth(3); + DataFitter.fit(f11y, resTrkYdet1, "Q"); //No options uses error for sigma + f11y.setParameter(0, f11y.parameter(0).value()); + f11y.setParameter(1, f11y.parameter(1).value()); + f11y.setParameter(2, f11y.parameter(2).value()); + DataFitter.fit(f11y, resTrkYdet1, "Q"); //No options uses error for sigma + f11y.setOptStat(11111); + canvastrkonlyres.draw(f11y,"same"); + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkThetadet1); + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkPhidet1); + frametrkonlyres.add(canvastrkonlyres); + frametrkonlyres.setLocationRelativeTo(null); + frametrkonlyres.setVisible(true); + } + } From 4fe2dc1c5acdef3001f1945f43e810bcbbab6394 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 16:38:14 +0100 Subject: [PATCH 055/104] fix for multitrack matching, new histograms for diagnostics --- .../jlab/rec/ft/FTEBEngineSingleEvent.java | 553 ++++++++++++++---- 1 file changed, 433 insertions(+), 120 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java index 359abb5999..dda6c0b380 100755 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java @@ -18,13 +18,14 @@ import org.jlab.groot.data.H1F; import org.jlab.groot.data.H2F; import org.jlab.groot.data.DataLine; -import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.ui.LatexText; import org.jlab.groot.math.F1D; import org.jlab.groot.fitter.DataFitter; import org.jlab.groot.graphics.EmbeddedCanvas; import org.jlab.groot.base.DatasetAttributes; import org.jlab.groot.base.GStyle; import org.jlab.groot.base.TColorPalette; +import org.jlab.groot.data.GraphErrors; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.io.evio.EvioDataBank; @@ -74,7 +75,8 @@ public boolean processDataEvent(DataEvent event) { FTparticles = reco.initFTparticles(FTresponses); if(FTparticles.size()>0){ //// reco.matchToTRK(FTresponses, FTparticles); - reco.matchToTRKTwoDetectors(FTresponses, FTparticles); +//// reco.matchToTRKTwoDetectors(FTresponses, FTparticles); + reco.matchToTRKTwoDetectorsMultiHits(FTresponses, FTparticles); reco.matchToHODO(FTresponses, FTparticles); // reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo reco.writeBanks(event, FTparticles); @@ -157,7 +159,6 @@ public int getDebugMode() { public static H1F h522 = new H1F("time of strips in cluster1 TRK1", 100, 0., 500.); public static H1F h523 = new H1F("Time of strips in cluster2 TRK1", 100, 0., 500.); - public static H1F h600 = new H1F("TRK response position", 100, 5.93, 6.03); public static H2F h601 = new H2F("TRK tof vs time", 100, 0., 500., 100, 5.93, 6.03); public static H1F h602 = new H1F("cross0 time", 100, 0.0001, 500.); @@ -165,8 +166,12 @@ public int getDebugMode() { public static H2F hSecDet0 = new H2F("lay 2 vs lay1 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); public static H2F hSecDet1 = new H2F("lay 4 vs lay3 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); + public static H2F hSeedDet0 = new H2F("lay 2 vs lay1 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); + public static H2F hSeedDet1 = new H2F("lay 4 vs lay3 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); + + public static Point3D ORIGIN = new Point3D(0., 0., 0.); + - public static void main(String arg[]){ FTCALEngine cal = new FTCALEngine(); @@ -181,18 +186,22 @@ public static void main(String arg[]){ // String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/elec_nofield_header.evio"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30_fullAcceptance.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_withFields_big_-30.60.120.30.hipo"; +/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_singleEle_withFields_big_-30.60.120.30_newbanks.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_test_1000.hipo"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance.hipo"; /// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_dis.hipo"; ////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; ////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418.0.hipo"; // dontuse ////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; +/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/ft_005038_01231_newbanks.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/data_merge.hipo"; // String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_154824_det0.hipo"; // String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_153947_det1.hipo"; // String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_160427_det1.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/twoHits_10298.hipo"; - String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_92897.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/twoHits_10239.hipo"; + String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_94976.hipo"; +// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; +/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance_newbanks.hipo"; HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -278,7 +287,41 @@ public static void main(String arg[]){ h109.setOptStat(10); h109.setTitleX("trk2 phi residual (rad)"); h109.setFillColor(51); - + + H1F resTrkXdet0 = new H1F("trk1 x residual wrt line thru trk0", 63, -0.5, 0.5); + resTrkXdet0.setOptStat(10); + resTrkXdet0.setTitleX("trk1 x residual (mm) wrt line thru trk0"); + resTrkXdet0.setFillColor(9); + H1F resTrkYdet0 = new H1F("trk1 y residual wrt line thru trk0", 63, -0.5, 0.5); + resTrkYdet0.setOptStat(10); + resTrkYdet0.setFillColor(9); + resTrkYdet0.setTitleX("trk1 y residual (mm) wrt line thru trk0"); + H1F resTrkXdet1 = new H1F("trk0 x residual wrt line thru trk1", 63, -1., 1.); + resTrkXdet1.setOptStat(10); + resTrkXdet1.setFillColor(49); + resTrkXdet1.setTitleX("trk0 y residual (mm) wrt line thru trk1"); + H1F resTrkYdet1 = new H1F("trk0 y residual wrt line thru trk1", 63, -1., 1.); + resTrkYdet1.setOptStat(10); + resTrkYdet1.setTitleX("trk0 y residual (mm) wrt line thru trk1"); + resTrkYdet1.setFillColor(49); + + H1F resTrkThetadet0 = new H1F("trk1 theta residual (rad) wrt line thru trk0", 100, -0.01, 0.01); + resTrkThetadet0.setOptStat(10); + resTrkThetadet0.setTitleX("trk1 theta residual (rad) wrt line thru trk0"); + resTrkThetadet0.setFillColor(9); + H1F resTrkThetadet1 = new H1F("trk0 theta residual (rad) wrt line thru trk1", 100, -0.01, 0.01); + resTrkThetadet1.setOptStat(10); + resTrkThetadet1.setTitleX("trk0 theta residual (rad) wrt line thru trk1"); + resTrkThetadet1.setFillColor(49); + H1F resTrkPhidet0 = new H1F("trk1 phi residual (rad) wrt line thru trk0", 100, -0.2, 0.2); + resTrkPhidet0.setOptStat(10); + resTrkPhidet0.setTitleX("trk1 phi residual wrt line thru trk0"); + resTrkPhidet0.setFillColor(9); + H1F resTrkPhidet1 = new H1F("trk0 phi residual (rad) wrt line thru trk1", 100, -0.2, 0.2); + resTrkPhidet1.setOptStat(10); + resTrkPhidet1.setTitleX("trk0 phi residual (rad) wrt line thru trk1"); + resTrkPhidet1.setFillColor(49); + // H1F h202 = new H1F("trk1 x", 25, 9., 9.4); // H1F h1202 = new H1F("trk1 x MC", 25, 9., 9.4); H1F h202 = new H1F("trk1 x", 25, 8.2, 9.0); @@ -425,11 +468,9 @@ public static void main(String arg[]){ h83.setLineColor(1); h83.setFillColor(33); H1F h84 = new H1F("hOccupancyMatched4", 768, 0., 769.); h84.setTitleX("Component layer 4"); h84.setLineColor(1); h84.setFillColor(34); - - - + int nev = 0; - int nevWithCrosses = 0, ncrosses2 = 0; + int nevWithCrosses = 0, ncrosses2 = 0, nOfFTParticles = 0; while (reader.hasEvent()) { // run over all events // int nev1 = 0; int nev2 = 10000; for(nev=nev1; nev0) nOfFTParticles++; for (int i = 0; i < nrows; i++) { int calId = bank.getShort("calID",i); if(bank.getByte("charge", i)==-1 && bank.getShort("calID",i)>0) { @@ -513,18 +555,15 @@ public static void main(String arg[]){ } - if(matchedCrosses == 0){ +// if(matchedCrosses != 1){ // if(matchedCrosses != 2){ + if(matchedCrosses == 0){ // accept all crosses continue; }else{ ncrosses2++; if(ncrosses< 100) System.out.println("++++++++++++++++++++++++++ Sequential number " + nev); } - -// if(matchedCrosses != 1) continue; -// if(matchedCrosses == 0) continue; - for(int nc = 0; nc < ncrosses; nc++){ int crossID = banktrk.getInt("id", nc); if(crossID != trk0ID && crossID != trk1ID) continue; @@ -556,7 +595,6 @@ public static void main(String arg[]){ if((int)icl1 == cid) icl1ok = k; if((int)icl2 == cid) icl2ok = k; } - DataLine segment1 = new DataLine(); DataLine segment2 = new DataLine(); int seed1 = -1; @@ -564,11 +602,11 @@ public static void main(String arg[]){ if(bankcl.rows()>0){ segment1.setOrigin(0.,0.); segment1.setEnd(0.,0.); segment2.setOrigin(0.,0.); segment2.setEnd(0.,0.); - seed1 = bankcl.getInt("seed", icl1ok); - seed2 = bankcl.getInt("seed", icl2ok); + seed1 = bankcl.getInt("seed", (int)icl1ok); + seed2 = bankcl.getInt("seed", (int)icl2ok); int cent1 = (int)bankcl.getFloat("centroid", icl1ok); int cent2 = (int)bankcl.getFloat("centroid", icl2ok); - // the cluster is formed by > 3 strips take the centroid + // if the cluster is formed by > 3 strips take the centroid int clustsize1 = bankcl.getShort("size", icl1ok); int clustsize2 = bankcl.getShort("size", icl2ok); if(clustsize1>=3){ @@ -579,12 +617,11 @@ public static void main(String arg[]){ int sector = FTTRKReconstruction.findSector(seed2); if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed2 = cent2; } - - // if seed and centroid dont coincide, take the centroid as seed + // if seed and centroid dont coincide, take the geometric centroid as seed //if(cent1 != seed1) seed1 = cent1; //if(cent2 != seed2) seed2 = cent2; - int lay1 = bankcl.getInt("layer", icl1ok); - int lay2 = bankcl.getInt("layer", icl2ok); + int lay1 = bankcl.getInt("layer", (int)icl1ok); + int lay2 = bankcl.getInt("layer", (int)icl2ok); System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ seed1, seed2 " + seed1 + " " + seed2 + " layer1 layer2 " + lay1 + " " + lay2); System.out.println("~~~~~~~~~~ hit strip 1: " + seed1 + " layer " + lay1 + " sector " + FTTRKReconstruction.findSector(seed1)); @@ -592,6 +629,7 @@ public static void main(String arg[]){ FTTRKReconstruction.findSector(seed2)); if(seed1!=0 && seed2!=0){ + System.out.println("seed2" + seed2); Line3D seg1 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay1, seed1); Line3D seg2 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay2, seed2); segment1.setOrigin(seg1.origin().x(), seg1.origin().y()); @@ -618,13 +656,13 @@ public static void main(String arg[]){ h72.fill(seed2); }else if(lay2==3){ h73.fill(seed2); -; }else if(lay2==4){ + }else if(lay2==4){ h74.fill(seed2); } DataBank bankhit = event.getBank("FTTRK::hits"); if(bankhit.rows()>0){ - for(int k=0; k>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1-10 bad seeds d0, event " + nev); + }else if(sec1 == 10 && sec2 == 10){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 10-10 bad seeds d0, event " + nev); + }else if(sec1 == 10 && sec2 == 11){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 10-11 bad seeds d0, event " + nev); + }else if(sec1 == 16 && sec2 == 8){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 16-8 bad seeds d0, event " + nev); + }else if(sec1 == 16 && sec2 == 8){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 16-8 bad seeds d0, event " + nev); + }else if(sec1 == 1 && sec2 == 11){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1-11 bad seeds d0, event " + nev); + }else if(sec1 == 11 && sec2 == 15){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 11-15 bad seeds d0, event " + nev); + }else if(sec1 == 12 && sec2 == 16){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 12-16 bad seeds d0, event " + nev); + }else if(sec1 == 13 && sec2 == 11){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 13-11 bad seeds d0, event " + nev); + } + */ + /* + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + + " bad seeds d0, event " + nev); + */ canvasCALTRK.cd(0); segment1.setLineColor(1); segment2.setLineColor(2); canvasCALTRK.draw(segment1); canvasCALTRK.draw(segment2); + canvasCALTRK.cd(2); + canvasCALTRK.draw(segment1); + canvasCALTRK.draw(segment2); }else if(det==1 && trk1ID==crossID){ h101.fill(xt, yt); @@ -670,46 +738,128 @@ public static void main(String arg[]){ h105.fill(bank.getFloat("cy", i) *zt - yt); h107.fill((part.theta() - hitOnTrk.theta())); h109.fill((part.phi() - hitOnTrk.phi())); - hSecDet1.fill(FTTRKReconstruction.findSector(seed1), FTTRKReconstruction.findSector(seed2)); - + int sec1 = FTTRKReconstruction.findSector(seed1); + int sec2 = FTTRKReconstruction.findSector(seed2); + hSecDet1.fill(sec1, sec2); + hSeedDet1.fill(seed1, seed2); + /* + if(sec1 == 0 && sec2 == 8){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 0-8 bad seeds d1, event " + nev); + }else if(sec1 == 12 && sec2 == 10){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 12-10 bad seeds d1, event " + nev); + }else if(sec1 == 3 && sec2 == 18){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3-18 bad seeds d1, event " + nev); + }else if(sec1 == 12 && sec2 == 9){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 12-9 bad seeds d1, event " + nev); + }else if(sec1 == 2 && sec2 == 18){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 2-18 bad seeds d1, event " + nev); + } + */ + /* + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + + " bad seeds d1, event " + nev); + */ canvasCALTRK.cd(1); segment1.setLineColor(3); segment2.setLineColor(4); canvasCALTRK.draw(segment1); - canvasCALTRK.draw(segment2); + canvasCALTRK.draw(segment2); + canvasCALTRK.cd(2); + canvasCALTRK.draw(segment1); + canvasCALTRK.draw(segment2); } - + + // extract residuals of TRK1 wrt TRK0 and viceversa + // loop on crosses in det0, find track connecting with origin, evaluate residuals of TRK1 hits wrt to this track + /* + double x0 = banktrk.getFloat("x", i); + double y0 = banktrk.getFloat("y", i); + double z0 = banktrk.getFloat("z", i); + for(int j = 0; j < nrows; j++) { + int det1 = banktrk.getInt("detector", j); + if(det1 >=0 && i != j && det != det1){ + double x1 = banktrk.getFloat("x", j); + double y1 = banktrk.getFloat("y", j); + double z1 = banktrk.getFloat("z", j); + //int cross1ID = banktrk.getInt("id", j); + Vector3D pointOnTrack = new Vector3D(x0*z1/z0, y0*z1/z0, z1); + Vector3D cross = new Vector3D(x1, y1, z1); + //if(det == 0 && trk0ID == crossID){ + if(det == 0){ + resTrkXdet0.fill(pointOnTrack.x() - cross.x()); + resTrkYdet0.fill(pointOnTrack.y() - cross.y()); + resTrkThetadet0.fill(pointOnTrack.theta() - cross.theta()); + resTrkPhidet0.fill(pointOnTrack.phi() - cross.phi()); + //}else if(det == 1 && trk1ID == crossID){ + }else if(det == 1){ + resTrkXdet1.fill(pointOnTrack.x() - cross.x()); + resTrkYdet1.fill(pointOnTrack.y() - cross.y()); + resTrkThetadet1.fill(pointOnTrack.theta() - cross.theta()); + resTrkPhidet1.fill(pointOnTrack.phi() - cross.phi()); + } + } + } + */ + + double cx = hitOnTrk.x() - ORIGIN.x(); + double cy = hitOnTrk.y() - ORIGIN.y(); + double cz = hitOnTrk.z() - ORIGIN.z(); + for(int ncj = 0; ncj < ncrosses; ncj++) { + int det1 = banktrk.getInt("detector", ncj); + if(det1 >=0 && nc != ncj && det != det1){ + double x1 = banktrk.getFloat("x", ncj); + double y1 = banktrk.getFloat("y", ncj); + double z1 = banktrk.getFloat("z", ncj); + int secondCrossID = banktrk.getInt("id", ncj); + Vector3D cross = new Vector3D(x1, y1, z1); + double t = cross.z()/hitOnTrk.z(); + Vector3D pointOnTrackAtZ = new Vector3D(cx*t + ORIGIN.x(), cy*t + ORIGIN.y(), z1); + //if(det == 0 && trk0ID == crossID){ + if(det1 == 1 && trk1ID == secondCrossID){ + resTrkXdet0.fill(pointOnTrackAtZ.x() - cross.x()); + resTrkYdet0.fill(pointOnTrackAtZ.y() - cross.y()); + resTrkThetadet0.fill(pointOnTrackAtZ.theta() - cross.theta()); + resTrkPhidet0.fill(pointOnTrackAtZ.phi() - cross.phi()); + //}else if(det == 1 && trk1ID == crossID){ + }else if(det1 == 0 && trk0ID == secondCrossID){ + resTrkXdet1.fill(pointOnTrackAtZ.x() - cross.x()); + resTrkYdet1.fill(pointOnTrackAtZ.y() - cross.y()); + resTrkThetadet1.fill(pointOnTrackAtZ.theta() - cross.theta()); + resTrkPhidet1.fill(pointOnTrackAtZ.phi() - cross.phi()); + } + } + } } } - + if(ncrosses==2){ - float x0 = banktrk.getFloat("x", 0); - float y0 = banktrk.getFloat("y", 0); - float x1 = banktrk.getFloat("x", 1); - float y1 = banktrk.getFloat("y", 1); + float x0 = banktrk.getFloat("x", 0); + float y0 = banktrk.getFloat("y", 0); + float x1 = banktrk.getFloat("x", 1); + float y1 = banktrk.getFloat("y", 1); - Point3D c0 = new Point3D(x0, y0, banktrk.getFloat("z",0)); - Point3D c1 = new Point3D(x1, y1, banktrk.getFloat("z",1)); - Line3D lineBwCrosses = new Line3D(c1, c0); - if(debugMode>0){ + Point3D c0 = new Point3D(x0, y0, banktrk.getFloat("z",0)); + Point3D c1 = new Point3D(x1, y1, banktrk.getFloat("z",1)); + Line3D lineBwCrosses = new Line3D(c1, c0); + if(debugMode>0){ System.out.println("x coordinates on 2 layers " + x0 + " " + x1); System.out.println("director cosines straight line bw crosses, cx " + lineBwCrosses.originDir().x() + " cy " + lineBwCrosses.originDir().y() + " cz " + lineBwCrosses.originDir().z()); - } + } } } } } } - if(event.hasBank("FTTRK::crosses")){ nevWithCrosses++; DataBank banktrk = event.getBank("FTTRK::crosses"); int nrows = banktrk.rows(); - // how many particles have been generated? - int ipart = gen.countGenerated(); + // comparison with MC data + // how many particles have been generated? + int ipart = gen.countGenerated(); for(int ip=0; ip=0) System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + nevWithCrosses); + if(debugMode>=0) + System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + + nevWithCrosses + " @@@@ number of reconstructed FTParticles " + nOfFTParticles); JFrame frame = new JFrame("FT Reconstruction"); frame.setSize(1200, 800); @@ -895,7 +1079,7 @@ public static void main(String arg[]){ frame.setLocationRelativeTo(null); frame.setVisible(true); - double narrowFactor = 4.5; + double narrowFactor = 7.; // was 4.5 JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); frametrk.setSize(1600, 800); EmbeddedCanvas canvastrk = new EmbeddedCanvas(); @@ -919,7 +1103,7 @@ public static void main(String arg[]){ canvastrk.draw(f02,"same"); canvastrk.cd(2); canvastrk.draw(h104); - F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/(narrowFactor+0.2)); + F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/(narrowFactor)); f04.setParameter(0, 10.0); f04.setParameter(1, 0.0); f04.setParameter(2, 1.0); @@ -1224,7 +1408,6 @@ public static void main(String arg[]){ frameMCradio.setVisible(true); */ - JFrame frameSecradio = new JFrame("20 sectors occupancy"); frameSecradio.setSize(1000,500); EmbeddedCanvas canvasSecradio = new EmbeddedCanvas(); @@ -1305,109 +1488,148 @@ public static void main(String arg[]){ excludedDet1half2.setMarkerSize(4); excludedDet1half2.setMarkerColor(55); excludedDet1half3.setMarkerSize(4); excludedDet1half3.setMarkerColor(55); excludedDet1half4.setMarkerSize(4); excludedDet1half4.setMarkerColor(55); - + canvasSecradio.draw(excludedDet0half1,"same"); + canvasSecradio.draw(excludedDet0half2,"same"); + canvasSecradio.draw(excludedDet0half3,"same"); + canvasSecradio.draw(excludedDet0half4,"same"); + canvasSecradio.cd(1); + canvasSecradio.draw(hSecDet1); + canvasSecradio.draw(excludedDet1half1,"same"); + canvasSecradio.draw(excludedDet1half2,"same"); + canvasSecradio.draw(excludedDet1half3,"same"); + canvasSecradio.draw(excludedDet1half4,"same"); + frameSecradio.add(canvasSecradio); + frameSecradio.setLocationRelativeTo(null); + frameSecradio.setVisible(true); - /* - JFrame frameSecradio = new JFrame("20 sectors occupancy"); - frameSecradio.setSize(1000,500); - EmbeddedCanvas canvasSecradio = new EmbeddedCanvas(); - canvasSecradio.divide(2,1); - canvasSecradio.cd(0); - canvasSecradio.draw(hSecDet0); - // excluded cells - double excx0h1[] = {0., 1., 2., 3., 4., 5., 10., 11., 12., 13.}; - double excy0h1[] = {10., 11., 12., 13., 14., 15., 16., 17.}; - GraphErrors excludedDet0half1 = new GraphErrors(); + JFrame frameSeedradio = new JFrame("Cluster seeds occupancy"); + double limSec[] = + {64., 128., 160., 192., 224., 256., 288., 320., 352., 384., 416., 448., 480., 512., 544., 576., 608., 640., 704., 768.}; + double limLab[] = + {50., 110., 150., 180., 205., 230., 260., 290., 320., 350., 370., 400., 425., 450., 480., 510., 530., 560., 605., 660.}; + double limLab2[] = + {50., 110., 150., 180., 205., 230., 260., 290., 320., 350., 390., 420., 450., 480., 510., 540., 570., 600., 650., 710.}; + int limLen = limSec.length; + DataLine[] limitX = new DataLine[limLen]; + DataLine[] limitY = new DataLine[limLen]; + LatexText[] labSecX = new LatexText[limLen]; + LatexText[] labSecY = new LatexText[limLen]; + + double[] limSecCenter = new double[limLen]; + for(int l=0; l Date: Thu, 10 Feb 2022 16:39:47 +0100 Subject: [PATCH 056/104] pass full list of crosses instead of two best ones --- .../main/java/org/jlab/rec/ft/FTParticle.java | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index c2c967fe11..4ef321348d 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -1,5 +1,8 @@ package org.jlab.rec.ft; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.jlab.clas.pdg.PhysicsConstants; import org.jlab.geom.prim.Line3D; @@ -254,6 +257,114 @@ public int[] getTRKBestHits(List hitList, int it, double distanceTh return bestIndex; } + public int [][] getTRKOrderedListOfHits(List hitList, int it, double distanceThreshold, double timeThreshold){ + Line3D cross = this.getLastCross(); + double minimumDistance = 500.0; + // how many FTTRK events? + int hitsTRK = 0; + for(int l=0; l hitDistancesDet0 = new ArrayList(hitsTRK); + ArrayList hitOrderDet0 = new ArrayList(hitsTRK); + ArrayList hitDistancesDet1 = new ArrayList(hitsTRK); + ArrayList hitOrderDet1 = new ArrayList(hitsTRK); + int lTRK = -1; + //init + for(int l=0; l-1){ + if(hitList.get(bestidx).getSize() < FTConstants.TRK_MIN_CROSS_NUMBER){ + bestidx=-1; + if(det==0){ + hitDistancesDet0.set(lTRK, -1.); + hitOrderDet0.set(lTRK, -1); + } + if(det==1){ + hitDistancesDet1.set(lTRK, -1.); + hitOrderDet1.set(lTRK, -1); + } + } + } + } + } + // sort the two arrays as a function of the distance + //int hitLen = hitDistancesDet0.size(); + ArrayList iniHitDis0 = new ArrayList(); + ArrayList iniHitDis1 = new ArrayList(); + for(int l=0; l0) orderedIndices0[l] = hitOrderDet0.get(k); + if(hitDistancesDet1.get(l) == iniHitDis1.get(k) && hitDistancesDet1.get(l)>0) orderedIndices1[l] = hitOrderDet1.get(k); + } + } + // compose the double arrays of indices ordered by distance + for(int l=0; l < hitsTRK; l++){ + bestIndices[l][0] = orderedIndices0[l]; + bestIndices[l][1] = orderedIndices1[l]; + } + }else{ + bestIndices = new int[1][2]; + bestIndices[0][0] = bestIndices[0][1] = -1; + } + return bestIndices; + } + public void show() { System.out.println( "FT Particle info " + From 75fa63b6ddc6f70dc49ea48f47c42169f84d2d91 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 16:41:28 +0100 Subject: [PATCH 057/104] add matchToTRKTwoDetectorsMultiHits method for tracking through multihits --- .../java/org/jlab/rec/ft/FTEventBuilder.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index 4fbff9d801..a366b8b620 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -265,7 +265,7 @@ public void matchToTRK(List responses, List particles) { } } - public void matchToTRKTwoDetectors(List responses, List particles) { + public void matchToTRKTwoDetectors(List responses, List particles) { for (int i = 0; i < particles.size(); i++) { FTParticle track = particles.get(i); if (debugMode >= 1) { @@ -298,6 +298,37 @@ public void matchToTRKTwoDetectors(List responses, List } } + public void matchToTRKTwoDetectorsMultiHits(List responses, List particles) { + for (int i = 0; i < particles.size(); i++) { + FTParticle track = particles.get(i); + if (debugMode >= 1) { + System.out.println("Searching for matching signal in the tracker:"); + } + int[][] iTrk; + iTrk = track.getTRKOrderedListOfHits(responses, i, FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); + int nHitsOnTRK = iTrk.length; + for(int j=0; j<2; j++){ // j: loop on two detectors + for(int k=0; k 0) { + if (debugMode >= 1) { + System.out.println("found signal in FTTRK" + iTrk[k][j]); + } + track.setCharge(-999); // provisional, for no field tracking + track.setTrackerIndex(responses.get(iTrk[k][j]).getId(), j); + responses.get(iTrk[k][j]).setHitIndex(iTrk[k][j]); + responses.get(iTrk[k][j]).setAssociation(i); + responses.get(iTrk[k][j]).setMatchPosition(track.getPosition().x(), track.getPosition().y(), track.getPosition().z()); + System.out.println("matched cross coordinates " + responses.get(iTrk[k][j]).getPosition().x() + " " + + responses.get(iTrk[k][j]).getPosition().y()); + }else{ + // wrong cross coordinates need to be deleted + } + } + } + if (debugMode >= 1) track.show(); + } + } + public void matchToFTCal(List responses, List particles) { for (int i = 0; i < particles.size(); i++) { From efb3b2ca16833065eaba7f099df27178954acf49 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 16:45:28 +0100 Subject: [PATCH 058/104] minor update --- .../ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java index 6beded4d26..f507f57e6d 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java @@ -145,12 +145,12 @@ public static void main (String arg[]) { /////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418.0.hipo"; // String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; // String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_fullAcceptance_singleTrack.hipo"; -// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; // String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_154824_det0.hipo"; // String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_153947_det1.hipo"; // String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_160427_det1.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_42486.hipo"; // multihit evt - String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_10323.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_126798.hipo"; // multihit evt +/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_68733.hipo"; // String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_92897.hipo"; /// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_test_1000.hipo"; /// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance_newbanks.hipo"; From 9b1e0ded27f304cd4bbddcaaedc44248343697f7 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Thu, 10 Feb 2022 16:47:06 +0100 Subject: [PATCH 059/104] remove two best crosses validation, pass the full list --- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 42 +++++-------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index 72e37ed2ee..383e758a09 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -372,31 +372,6 @@ public ArrayList findCrosses(List clusters) { } } } - /* - // validate crosses in two detectors: their distance must be within a reasonable tolerance - ArrayList validatedCrosses = new ArrayList(); - for(int ic=0; icic; jc--){ - FTTRKCross cross1 = crosses.get(ic); - FTTRKCross cross2 = crosses.get(jc); - if(cross1.get_Id()!=cross2.get_Id() && cross1.get_Region()!=cross2.get_Region()){ - double rad1 = Math.sqrt(cross1.get_Point().x()*cross1.get_Point().x() + - cross1.get_Point().y()*cross1.get_Point().y()); - double rad2 = Math.sqrt(cross2.get_Point().x()*cross2.get_Point().x() + - cross2.get_Point().y()*cross2.get_Point().y()); - double diffPhi = Math.abs(Math.atan2(cross1.get_Point().y(),cross1.get_Point().x()) - - Math.atan2(cross2.get_Point().y(),cross2.get_Point().x())); - double diffTheta = Math.abs(Math.atan2(rad1,cross1.get_Point().z())- Math.atan2(rad2,cross2.get_Point().z())); - double phiTolerance = 0.01; - double thetaTolerance = 0.01; - if(Math.abs(rad2-rad1)< FTConstants.TOLERANCE_ON_CROSSES_TWO_DETECTORS && diffPhi validatedCrosses = new ArrayList(); @@ -421,11 +396,12 @@ public ArrayList findCrosses(List clusters) { if(idMax1>=0) validatedCrosses.add(crosses.get(idMax1)); if(idMax2>=0) validatedCrosses.add(crosses.get(idMax2)); - // make a geometric match of the two crosses - if(validatedCrosses.size()== FTTRKConstantsLoader.NSupLayers){ - double diffRadTolerance = FTConstants.TRK0_TRK1_RADTOL; - double diffPhiTolerance = FTConstants.TRK0_TRK1_PHITOL; - double diffThetaTolerance = FTConstants.TRK0_TRK1_THETATOL; + double diffRadTolerance = FTConstants.TRK0_TRK1_RADTOL; + double diffPhiTolerance = FTConstants.TRK0_TRK1_PHITOL; + double diffThetaTolerance = FTConstants.TRK0_TRK1_THETATOL; + +// make a geometric match of the two crosses + if(validatedCrosses.size()== FTTRKConstantsLoader.NSupLayers){ Point3D cross0 = validatedCrosses.get(0).get_Point(); Point3D cross1 = validatedCrosses.get(1).get_Point(); double r02d = Math.sqrt(cross0.x()*cross0.x() + cross0.y()*cross0.y()); @@ -438,8 +414,8 @@ public ArrayList findCrosses(List clusters) { if(!(Math.abs(diffPhi) < diffPhiTolerance && Math.abs(diffRadii)< diffRadTolerance && Math.abs(diffTheta) < diffThetaTolerance)) validatedCrosses.clear(); } - return validatedCrosses; - //return crosses; + //return validatedCrosses; + return crosses; } public List readRawHits(DataEvent event, int run) { @@ -2205,6 +2181,8 @@ public int renumberFEE2RECRotatedAndAdjustWalnut(int run, int ilayer, int icompo //if(icomponent > 48 && icomponent <= 64) icomponent += 16; //if(icomponent > 32) icomponent = -1; //icomponent = reverseStripInSecondHalf(icomponent); + }else if(isec1==12){ // strip 476 only is fired + //icomponent += 16; } } From 1c1ced3e1241ae3dbadb6b692b77dc2d5a4fce6b Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Fri, 11 Feb 2022 10:29:39 +0100 Subject: [PATCH 060/104] cleanup --- .../org/jlab/rec/ft/trk/FTTRKCluster.java | 501 +++++++----------- .../jlab/rec/ft/trk/FTTRKConstantsLoader.java | 305 ++++------- .../java/org/jlab/rec/ft/trk/FTTRKCross.java | 8 +- .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 107 ++-- 4 files changed, 351 insertions(+), 570 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java index ff902a6d2c..80924ff908 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java @@ -25,7 +25,6 @@ public class FTTRKCluster extends ArrayList implements Comparable implements ComparablemaxStripsForTM){ - // max energy strip - for(int i=0; i< nbhits; i++){ - FTTRKHit oneHit = this.get(i); - double stripEn = oneHit.get_Edep(); - if(stripEn> maxEn1){ - maxEn1 = stripEn; - maxI = i; - } - } - // 2nd to max energy strip - for(int i=0; i < nbhits; i++){ - FTTRKHit oneHit = this.get(i); - double stripEn = oneHit.get_Edep(); - if(i!=maxI && stripEn> maxEn2){ - maxEn2 = stripEn; - maxI2nd = i; - } - } + double totEn = 0.; // cluster total energy + double totEnergy = 0.; + double totEnSq = 0.; // sum of energies squared + double weightedStrp = 0; // energy-weighted strip + + double weightedStripEndPoint1X = 0; // Energy-weighted x of the strip first end point + double weightedStripEndPoint1Y = 0; // Energy-weighted y of the strip first end point + double weightedStripEndPoint1Z = 0; // Energy-weighted z of the strip first end point + double weightedStripEndPoint2X = 0; // Energy-weighted x of the strip second end point + double weightedStripEndPoint2Y = 0; // Energy-weighted y of the strip second end point + double weightedStripEndPoint2Z = 0; // Energy-weighted z of the strip second end point + + int nbhits = this.size(); + + if(nbhits != 0) { + int min = 1000000; + int max = -1; + int seed = -1; + double Emax = -1; + int Slay = -1; + // find the number of two two strips with the highest energy deposited (to be zeroed in case of a truncated mean which excludes the two highest signals) + // sort the FTTRKHIT list to find the maximum + double maxEn1 = -1; + double maxEn2 = -1; + int maxI = -1; + int maxI2nd = -1; + int maxStripsForTM = FTConstants.TRK_MAX_StripsForTruncatedMean; // truncated mean: minimum energy HARDCODED + if(nbhits>maxStripsForTM){ + // max energy strip + for(int i=0; i< nbhits; i++){ + FTTRKHit oneHit = this.get(i); + double stripEn = oneHit.get_Edep(); + if(stripEn> maxEn1){ + maxEn1 = stripEn; + maxI = i; } - // are all the strips int he cluster consecutive? if they are limiting pick as seed the strip with larger energy release - /* - boolean isCutInside = false; - for(int i=0; i< nbhits-1; i++){ - FTTRKHit oneHit = this.get(i); - FTTRKHit theNext = this.get(i+1); - if(oneHit.get_Strip() != theNext.get_Strip()) isCutInside = true; - double stripEn = oneHit.get_Edep(); - if(stripEn> maxEn1){ - maxEn1 = stripEn; - maxI = i; - } - if(i==nbhits-1){ - stripEn = theNext.get_Edep(); - if(stripEn> maxEn1){ - maxEn1 = stripEn; - maxI = i+1; - } - } + } + // 2nd to max energy strip + for(int i=0; i < nbhits; i++){ + FTTRKHit oneHit = this.get(i); + double stripEn = oneHit.get_Edep(); + if(i!=maxI && stripEn> maxEn2){ + maxEn2 = stripEn; + maxI2nd = i; } - - // looping over the number of hits in the cluster - isCutInside = false; - if(isCutInside){ - // if there is a limiting strip choose as centroid (seed) the strip with max energy release - int maxStripNumber = -1; - int minStripNumber = 1000; - for(int i=0;i= maxStripNumber) maxStripNumber = numStrip; - if(numStrip <= minStripNumber) minStripNumber = numStrip; - } - FTTRKHit centHit = this.get(maxI); - int layer = centHit.get_Layer(); - int Slayer = centHit.get_HalfLayer(layer); - int strpNb = seed = centHit.get_Strip(); - Slay = 2*Slayer; - double y = (double)FTTRKConstantsLoader.stripsYloc[Slayer][strpNb-1][0]; - - if(totEn==0) { - System.err.println(" Cluster energy is null .... exit"); - return; - } + } + } - this.set_MinStrip(minStripNumber); - this.set_MaxStrip(maxStripNumber); - this.set_SeedStrip(seed); - this.set_SeedEnergy(maxEn1); - // calculates the centroid values and associated positions (in local RF) - stripYCent = seed; - //System.out.println(" --> centroid "+stripNumCent); - // extreme points of the strip in global RF - xCentEndPoint2 = centHit.get_StripSegment().end().x(); - yCentEndPoint2 = centHit.get_StripSegment().end().y(); - zCentEndPoint2 = centHit.get_StripSegment().end().z(); - xCentEndPoint1 = centHit.get_StripSegment().origin().x(); - yCentEndPoint1 = centHit.get_StripSegment().origin().y(); - zCentEndPoint1 = centHit.get_StripSegment().origin().z(); - - }else{ - */ - for(int i=0;i0.5) {continue;} - // get strip informations - int strpNb = thehit.get_Strip(); - double x1 = thehit.get_StripSegment().origin().x(); - double y1 = thehit.get_StripSegment().origin().y(); - double z1 = thehit.get_StripSegment().origin().z(); - double x2 = thehit.get_StripSegment().end().x(); - double y2 = thehit.get_StripSegment().end().y(); - double z2 = thehit.get_StripSegment().end().z(); - - totEn += strpEn; - totEnSq += strpEn*strpEn; - int layer = thehit.get_Layer(); - int Slayer = thehit.get_HalfLayer(layer); - double y = (double)FTTRKConstantsLoader.stripsYloc[Slayer][strpNb-1][0]; -// double y = (double)FTTRKConstantsLoader.stripsY[Slayer][strpNb-1][0]; + for(int i=0;i0.5) {continue;} + // get strip informations + int strpNb = thehit.get_Strip(); + double x1 = thehit.get_StripSegment().origin().x(); + double y1 = thehit.get_StripSegment().origin().y(); + double z1 = thehit.get_StripSegment().origin().z(); + double x2 = thehit.get_StripSegment().end().x(); + double y2 = thehit.get_StripSegment().end().y(); + double z2 = thehit.get_StripSegment().end().z(); - weightedStrp+= strpEn*y; - weightedStripEndPoint1X+= strpEn*x1; - weightedStripEndPoint1Y+= strpEn*y1; - weightedStripEndPoint1Z+= strpEn*z1; - weightedStripEndPoint2X+= strpEn*x2; - weightedStripEndPoint2Y+= strpEn*y2; - weightedStripEndPoint2Z+= strpEn*z2; - // getting the max and min strip number in the cluster - if(strpNb<=min) min = strpNb; - if(strpNb>=max) max = strpNb; - // getting the seed strip which is defined as the strip with the largest deposited energy - if(strpEn>=Emax) { - Emax = strpEn; - seed = strpNb; // seed: hit with largest energy release - } - Slay = 2*Slayer; - } - if(totEn==0) { - System.err.println(" Cluster energy is null .... exit"); - return; - } - - this.set_MinStrip(min); - this.set_MaxStrip(max); - this.set_SeedStrip(seed); - this.set_SeedEnergy(Emax); - // calculates the centroid values and associated positions (in local RF) - stripYCent = weightedStrp/totEn; // - //System.out.println(" --> centroid "+stripNumCent); - // extreme points of the strip in global RF - xCentEndPoint1 = weightedStripEndPoint1X/totEn; - yCentEndPoint1 = weightedStripEndPoint1Y/totEn; - zCentEndPoint1 = weightedStripEndPoint1Z/totEn; - xCentEndPoint2 = weightedStripEndPoint2X/totEn; - yCentEndPoint2 = weightedStripEndPoint2Y/totEn; - zCentEndPoint2 = weightedStripEndPoint2Z/totEn; - //} - } - // use the discrete coordinate of the seed strip x-y (for debug purposes only) - /* - int seed = this.get_SeedStrip(); - if(this.get_Layer()==1 || this.get_Layer()==3){ - xCentEndPoint1 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][0]; - xCentEndPoint2 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][1]; - yCentEndPoint1 = (double)FTTRKConstantsLoader.stripsYloc[this.get_Region()-1][seed-1][0]; - yCentEndPoint2 = (double)FTTRKConstantsLoader.stripsYloc[this.get_Region()-1][seed-1][1]; - }else{ - xCentEndPoint1 = -(double)FTTRKConstantsLoader.stripsYloc[this.get_Region()-1][seed-1][0]; - xCentEndPoint2 = -(double)FTTRKConstantsLoader.stripsYloc[this.get_Region()-1][seed-1][1]; - yCentEndPoint1 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][0]; - yCentEndPoint2 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][1]; - } - */ - - // use the weighted coordinate in both x and y directions (for debugging purposes only) - /* - int seed = this.get_SeedStrip(); - if(seed>0){ - if(this.get_Layer()==1 || this.get_Layer()==3){ - xCentEndPoint1 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][0]; - xCentEndPoint2 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][1]; - }else if(this.get_Layer()==2 || this.get_Layer()==4){ - yCentEndPoint1 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][0]; - yCentEndPoint2 = (double)FTTRKConstantsLoader.stripsXloc[this.get_Region()-1][seed-1][1]; + totEn += strpEn; + totEnSq += strpEn*strpEn; + int layer = thehit.get_Layer(); + int Slayer = thehit.get_HalfLayer(layer); + double y = (double)FTTRKConstantsLoader.stripsYloc[Slayer][strpNb-1][0]; + weightedStrp+= strpEn*y; + weightedStripEndPoint1X+= strpEn*x1; + weightedStripEndPoint1Y+= strpEn*y1; + weightedStripEndPoint1Z+= strpEn*z1; + weightedStripEndPoint2X+= strpEn*x2; + weightedStripEndPoint2Y+= strpEn*y2; + weightedStripEndPoint2Z+= strpEn*z2; + // getting the max and min strip number in the cluster + if(strpNb<=min) min = strpNb; + if(strpNb>=max) max = strpNb; + // getting the seed strip which is defined as the strip with the largest deposited energy + if(strpEn>=Emax) { + Emax = strpEn; + seed = strpNb; // seed: hit with largest energy release } + Slay = 2*Slayer; } - */ - - _TotalEnergy = totEnergy; - double xmeanCent = (xCentEndPoint1+xCentEndPoint2)/2.; - stripNumCent = this.get(0).get_StripNumberFromLocalY(xmeanCent, stripYCent, this.get(0).get_Layer()); - //centroid: centroid strip number in the measurement direction (local y of each layer) - _Centroid = stripNumCent; - _CentroidError = FTTRKConstantsLoader.Pitch/Math.sqrt(12)*Math.sqrt(totEnSq); - _StripSegment = new Line3D(); - _StripSegment.setOrigin(xCentEndPoint1, yCentEndPoint1, zCentEndPoint1); - _StripSegment.setEnd(xCentEndPoint2, yCentEndPoint2, zCentEndPoint2); - - } + if(totEn==0) { + System.err.println(" Cluster energy is null .... exit"); + return; + } + this.set_MinStrip(min); + this.set_MaxStrip(max); + this.set_SeedStrip(seed); + this.set_SeedEnergy(Emax); + // calculates the centroid values and associated positions (in local RF) + stripYCent = weightedStrp/totEn; + // extreme points of the strip in global RF + xCentEndPoint1 = weightedStripEndPoint1X/totEn; + yCentEndPoint1 = weightedStripEndPoint1Y/totEn; + zCentEndPoint1 = weightedStripEndPoint1Z/totEn; + xCentEndPoint2 = weightedStripEndPoint2X/totEn; + yCentEndPoint2 = weightedStripEndPoint2Y/totEn; + zCentEndPoint2 = weightedStripEndPoint2Z/totEn; + } + + _TotalEnergy = totEnergy; + double xmeanCent = (xCentEndPoint1+xCentEndPoint2)/2.; + stripNumCent = this.get(0).get_StripNumberFromLocalY(xmeanCent, stripYCent, this.get(0).get_Layer()); + //centroid: centroid strip number in the measurement direction (local y of each layer) + _Centroid = stripNumCent; + _CentroidError = FTTRKConstantsLoader.Pitch/Math.sqrt(12)*Math.sqrt(totEnSq); + _StripSegment = new Line3D(); + _StripSegment.setOrigin(xCentEndPoint1, yCentEndPoint1, zCentEndPoint1); + _StripSegment.setEnd(xCentEndPoint2, yCentEndPoint2, zCentEndPoint2); + } - private int _MinStrip; - private int _MaxStrip; - private int _SeedStrip; - private double _SeedEnergy; - - - public int get_MinStrip() { - return _MinStrip; - } - public void set_MinStrip(int _MinStrip) { - this._MinStrip = _MinStrip; - } - public int get_MaxStrip() { - return _MaxStrip; - } - public void set_MaxStrip(int _MaxStrip) { - this._MaxStrip = _MaxStrip; - } - - - public int get_SeedStrip() { - return _SeedStrip; - } - public void set_SeedStrip(int _SeedStrip) { - this._SeedStrip = _SeedStrip; - } - public double get_SeedEnergy() { - return _SeedEnergy; - } - public void set_SeedEnergy(double _SeedEnergy) { - this._SeedEnergy = _SeedEnergy; - } - public Line3D get_StripSegment() { - return _StripSegment; - } - public void set_StripSegment(Line3D _StripSegment) { - this._StripSegment = _StripSegment; - } - - - - /** - * - * @param Z z-coordinate of a point in the local coordinate system of a module - * @return the average resolution for a group of strips in a cluster - * - */ - + private int _MinStrip; + private int _MaxStrip; + private int _SeedStrip; + private double _SeedEnergy; - private int _AssociatedCrossID; - private int _AssociatedTrackID; - public int get_AssociatedCrossID() { - return _AssociatedCrossID; - } + public int get_MinStrip() { + return _MinStrip; + } + public void set_MinStrip(int _MinStrip) { + this._MinStrip = _MinStrip; + } + public int get_MaxStrip() { + return _MaxStrip; + } + public void set_MaxStrip(int _MaxStrip) { + this._MaxStrip = _MaxStrip; + } - public void set_AssociatedCrossID(int _AssociatedCrossID) { - this._AssociatedCrossID = _AssociatedCrossID; - // set the _AssociatedCrossID index to all hits belonging to the cluster - for(int i=0; i1) Alpha[lay] += Math.PI; - ////// if(lay==0 || lay==1) Alpha[lay] += (Math.PI-Math.PI/3.); - //if(lay==3) Alpha[lay] += Math.PI; - //if(lay!=1) Alpha[lay] += Math.PI; - /* - if(lay==0){ - Alpha[lay] = 0.; - }else if(lay==1){ - Alpha[lay] = Math.PI/2.; - }else if(lay==2){ - Alpha[lay] = Math.PI/2.; - }else if(lay==3){ - Alpha[lay] = 0.; - } - */ - } - /* - Alpha[0] = (150)*Math.PI/180.; - Alpha[1] = (60.)*Math.PI/180.; - Alpha[2] = (-60.)*Math.PI/180.; - Alpha[3] = (-150.)*Math.PI/180.; - */ - CSTLOADED = true; System.out.println("SUCCESFULLY LOADED FTTRK GEOMETRY CONSTANTS"); - - - - SideHalfstrips = (Nstrips -2*Longstrips)/4; // 128 - InnerHole = (double)(SideHalfstrips)*Pitch; // 7.168 cm, exceeds Beamhole by 0.125 cm - reference as minimum radius - Rmax = Pitch*(SideHalfstrips + Longstrips); // 14.336 - // 2d arrays: [0] origin, [1] segment endpoint - stripsXloc = new double[NSupLayers][Nstrips][2]; - stripsYloc = new double[NSupLayers][Nstrips][2]; - stripsXlocref = new double[Nstrips]; - stripsYlocref = new double[Nstrips]; - stripsX = new double[Nlayers][Nstrips][2]; - stripsY = new double[Nlayers][Nstrips][2]; - stripslength = new double[Nstrips]; - - int debug = FTTRKReconstruction.debugMode; - double half = 0.5; - - // just the first two layers are enough, the second two are identical - for(int j=0; j=1) System.out.println(Constants.getLocalRegion(i)+" strip-1 = "+i+" x' "+stripsXloc[i][1]+" y' "+stripsYloc[i][1]+" length "+stripslength[i]+" Beamhole "+Beamhole); - /* - // inversione x con y - double xyinv = stripsX[j][i][0]; - stripsX[j][i][0] = stripsY[j][i][0]; - stripsY[j][i][0] = xyinv; - xyinv = stripsX[j][i][1]; - stripsX[j][i][1] = stripsY[j][i][1]; - stripsY[j][i][1] = xyinv; - xyinv = stripsX[j+2][i][0]; - stripsX[j+2][i][0] = stripsY[j+2][i][0]; - stripsY[j+2][i][0] = xyinv; - xyinv = stripsX[j+2][i][1]; - stripsX[j+2][i][1] = stripsY[j+2][i][1]; - stripsY[j+2][i][1] = xyinv; - */ - - // alignment: global translation: x-y coordinates layer 0,1 - double tX1 = 0.; double tY1 = 0.; - double tX2 = 0.; double tY2 = 0.; - /* - tX1 = -0.006; tY1 = 0.051; // first tenative alignment - tX2 = 0.046; tY2 = 0.008; -// tX1 = 1.5; - */ + SideHalfstrips = (Nstrips -2*Longstrips)/4; // 128 + InnerHole = (double)(SideHalfstrips)*Pitch; // 7.168 cm, exceeds Beamhole by 0.125 cm - reference as minimum radius + Rmax = Pitch*(SideHalfstrips + Longstrips); // 14.336 + // 2d arrays: [0] origin, [1] segment endpoint + stripsXloc = new double[NSupLayers][Nstrips][2]; + stripsYloc = new double[NSupLayers][Nstrips][2]; + stripsXlocref = new double[Nstrips]; + stripsYlocref = new double[Nstrips]; + stripsX = new double[Nlayers][Nstrips][2]; + stripsY = new double[Nlayers][Nstrips][2]; + stripslength = new double[Nstrips]; - stripsX[j][i][0] += tX1; // cm - stripsX[j][i][1] += tX1; - stripsY[j][i][0] += tY1; - stripsY[j][i][1] += tY1; - - stripsX[j+2][i][0] += tX2; // cm - stripsX[j+2][i][1] += tX2; - stripsY[j+2][i][0] += tY2; - stripsY[j+2][i][1] += tY2; - - - - + int debug = FTTRKReconstruction.debugMode; + double half = 0.5; + + // just the first two layers are enough, the second two are identical + for(int j=0; j0 && i<=stripBlock*2){ - regionY = -1; - }else if(i>stripBlock*3 && i<=stripBlock*4){ - regionY = -2; - }else if(i>stripBlock*2 && i<=stripBlock*3){ - regionY = 2; - }else if(i>stripBlock*4 && i<=Nstrips){ - regionY = 1; - } - return regionY; + int regionY = 0; + int i = strip+1; + int stripBlock = Nstrips/6; + if(i>0 && i<=stripBlock*2){ + regionY = -1; + }else if(i>stripBlock*3 && i<=stripBlock*4){ + regionY = -2; + }else if(i>stripBlock*2 && i<=stripBlock*3){ + regionY = 2; + }else if(i>stripBlock*4 && i<=Nstrips){ + regionY = 1; + } + return regionY; } private static int getLocalRegionX(int strip){ // the strips are read by the db table in the format 1-768 // divide the geometry in horizontal direction in 6 contiguity regions - int regionX = 0; - int i = strip+1; - int stripBlock = Nstrips/6; - if(i>stripBlock*4 && i<=stripBlock*5){ // 513-640 - regionX = 1; - }else if(i>stripBlock*3 && i<=stripBlock*4){ // 385-512 - regionX = 2; - }else if(i>0 && i<=stripBlock){ // 1-128 - regionX = 3; - }else if(i>stripBlock && i<=stripBlock*2){ // 129-256 - regionX = 4; - }else if(i>stripBlock*2 && i<=stripBlock*3){ // 257-384 - regionX = 5; - }else if(i>stripBlock*5 && i<=Nstrips){ // 641-768 - regionX = 6; - } - return regionX; + int regionX = 0; + int i = strip+1; + int stripBlock = Nstrips/6; + if(i>stripBlock*4 && i<=stripBlock*5){ // 513-640 + regionX = 1; + }else if(i>stripBlock*3 && i<=stripBlock*4){ // 385-512 + regionX = 2; + }else if(i>0 && i<=stripBlock){ // 1-128 + regionX = 3; + }else if(i>stripBlock && i<=stripBlock*2){ // 129-256 + regionX = 4; + }else if(i>stripBlock*2 && i<=stripBlock*3){ // 257-384 + regionX = 5; + }else if(i>stripBlock*5 && i<=Nstrips){ // 641-768 + regionX = 6; + } + return regionX; } public static Line3D getStripSegmentLab(int layer, int seed){ diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java index a81cf62b89..cc798c819c 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java @@ -79,7 +79,6 @@ public void set_Sector(int sector) { */ public int get_Region() { // return the number of supermodule (top or bottom) -// if(_Region==0 || _Region==1){return 0;}else{return 1;} return _Region; } @@ -275,8 +274,7 @@ public void set_CrossParams() { double y1_outer = outlayerclus.get_StripSegment().end().y(); double z0_inner = inlayerclus.get_StripSegment().origin().z(); double z0_outer = outlayerclus.get_StripSegment().origin().z(); - - + Line3D l_in = new Line3D(x0_inner, y0_inner, z0_inner, x1_inner, y1_inner, z0_inner); Line3D l_out = new Line3D(x0_outer, y0_outer, z0_outer, x1_outer, y1_outer, z0_outer); @@ -285,7 +283,6 @@ public void set_CrossParams() { int region = inlayerclus.get_Region(); // 1-2 double distanceBwLayers = FTTRKConstantsLoader.Zlayer[2*region-1] - FTTRKConstantsLoader.Zlayer[2*region-2]; // check if the point belongs to the crossed segments -// double tolerance = FTTRKConstantsLoader.Pitch/Math.sqrt(2.); // set as tolerance the maximum uncertainty of the two centroids double maxTolerance = 0; double tol1 = inlayerclus.get_CentroidError(); @@ -378,7 +375,7 @@ public void evaluate_EnergyAndTime(){ meanEnergy = Math.sqrt(cl1.get_TotalEnergy() * cl2.get_TotalEnergy()); this.set_Energy((float)meanEnergy); -// to determine the time associated with the cross, the times of each hit forming each cluster must be retrieved + // to determine the time associated with the cross, the times of each hit forming each cluster must be retrieved // loop on strips of each cluster int nHits1 = cl1.size(); for(int i=0; i processDataEventAndGetClusters(DataEvent event) { // get hits from banks allHits = reco.initFTTRK(event,this.getConstantsManager(), run); if(allHits.size()>0){ - // create clusters + // create clusters clusters = reco.findClusters(allHits); // create crosses crosses = reco.findCrosses(clusters); @@ -138,22 +125,8 @@ public static void main (String arg[]) { FTTRKEngine trk = new FTTRKEngine(); trk.init(); // insert input filename here -// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_dis.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; -////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; -/////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418.0.hipo"; // String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; -// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_fullAcceptance_singleTrack.hipo"; - String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_154824_det0.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_153947_det1.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_160427_det1.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_126798.hipo"; // multihit evt -/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_68733.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_92897.hipo"; -/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_test_1000.hipo"; -/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance_newbanks.hipo"; + String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_126798.hipo"; // multihit evt System.out.println("input file " + input); HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -237,7 +210,6 @@ public static void main (String arg[]) { // if(nev != 8) continue; // select one event only for debugging purposes ArrayList clusters = new ArrayList(); - clusters = trk.processDataEventAndGetClusters(event); int nStripsInClusters = 0; @@ -254,8 +226,10 @@ public static void main (String arg[]) { float energy = bank.getFloat("energy",i); float time = bank.getFloat("time",i); - if(debug>=1) System.out.println("layer " + layer + " strip " + comp); - System.out.println("%%%%%%%%% layer " + layer + " strip " + comp + " sector " + FTTRKReconstruction.findSector(comp)); + if(debug>=1) { + System.out.println("layer " + layer + " strip " + comp); + System.out.println("%%%%%%%%% layer " + layer + " strip " + comp + " sector " + FTTRKReconstruction.findSector(comp)); + } h1.fill(comp,layer); h2.fill(energy); h3.fill(time); @@ -312,7 +286,7 @@ public static void main (String arg[]) { if(clusters.size()!=0){ // get one cluster and iterate over all the strips contained in it canvasCl.cd(1); canvasCl.draw(hHitL1); - for(int l=0; l<4; l++){ + for(int l=0; l=1) System.out.println("number of rows " + nrows); - if(nrows>1){ + if(nrows>=1){ double diffPhi = 1000; for(int i=0; ii; j--){ if(det[i]!=det[j]){ double distance = Math.sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])); -// if(distance < minDistance){ -// minDistance = distance; -// iBest = i; jBest = j; -// check det1 and det2 correspondence by comparing phi angles -// the radius is larger for the second detector (as it is more distant) + // check det1 and det2 correspondence by comparing phi angles + // the radius is larger for the second detector (as it is more distant) double phiCross1 = Math.atan2(y[i],x[i]); double phiCross2 = Math.atan2(y[j],x[j]); diffPhi = Math.abs(phiCross1-phiCross2); @@ -408,7 +379,7 @@ public static void main (String arg[]) { } } if(debug>=1) System.out.println("minimum distance " + minDistance); - // adjust tolerances if needed + // adjust tolerances if needed (some reference values are hardcoded in FTConstants.java double diffRadTolerance = 0.5; double diffPhiTolerance = 1.; double thetaTolerance = 0.05; @@ -417,21 +388,19 @@ public static void main (String arg[]) { double r2 = Math.sqrt(x[jBest]*x[jBest]+y[jBest]*y[jBest]); double diffRadii = r1-r2; double diffTheta = Math.atan2(r1,z[iBest])- Math.atan2(r2,z[jBest]); - // if(minDiffPhi < diffPhiTolerance && diffRadii<0 && Math.abs(diffRadii)=1) System.out.println("phi differences on two detectors " + diffPhi + " number of cross " + ncmatch + - " diffTheta " + diffTheta + " diffRadii " + diffRadii + " " + det[iBest] + " " + det[jBest]); - hHitMatch.fill((x[iBest]+x[jBest])/2., (y[iBest]+y[jBest])/2.); - ncmatch++; + if(minDiffPhi < diffPhiTolerance && + Math.abs(diffRadii)=1) System.out.println("phi differences on two detectors " + diffPhi + " number of cross " + ncmatch + + " diffTheta " + diffTheta + " diffRadii " + diffRadii + " " + det[iBest] + " " + det[jBest]); + hHitMatch.fill((x[iBest]+x[jBest])/2., (y[iBest]+y[jBest])/2.); + ncmatch++; } } } - } + } } - + // output if(debug>=1) System.out.println("number of found crosses: module 1: " + nc1 + " module 2: " + nc2 + " matching crosses " + ncmatch); JFrame frame = new JFrame("FT Reconstruction"); @@ -540,43 +509,43 @@ public static void main (String arg[]) { canvas3.cd(++ic); canvas3.draw(hOccupancy1); canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); - canvas3.draw(l4); //canvas3.draw(l5); - canvas3.draw(l6); //canvas3.draw(l7); + canvas3.draw(l4); + canvas3.draw(l6); canvas3.draw(l8); canvas3.draw(l9); canvas3.draw(l10); canvas3.draw(l11); - canvas3.draw(l12); //canvas3.draw(l13); - canvas3.draw(l14); //canvas3.draw(l15); + canvas3.draw(l12); + canvas3.draw(l14); canvas3.draw(l16); canvas3.draw(l17); canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); canvas3.cd(++ic); canvas3.draw(hOccupancy2); canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); - canvas3.draw(l4); //canvas3.draw(l5); - canvas3.draw(l6); //canvas3.draw(l7); + canvas3.draw(l4); + canvas3.draw(l6); canvas3.draw(l8); canvas3.draw(l9); canvas3.draw(l10); canvas3.draw(l11); - canvas3.draw(l12); //canvas3.draw(l13); - canvas3.draw(l14); //canvas3.draw(l15); + canvas3.draw(l12); + canvas3.draw(l14); canvas3.draw(l16); canvas3.draw(l17); canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); canvas3.cd(++ic); canvas3.draw(hOccupancy3); canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); - canvas3.draw(l4); //canvas3.draw(l5); - canvas3.draw(l6); //canvas3.draw(l7); + canvas3.draw(l4); + canvas3.draw(l6); canvas3.draw(l8); canvas3.draw(l9); canvas3.draw(l10); canvas3.draw(l11); - canvas3.draw(l12); //canvas3.draw(l13); - canvas3.draw(l14); //canvas3.draw(l15); - canvas3.draw(l16); //canvas3.draw(l17); + canvas3.draw(l12); + canvas3.draw(l14); + canvas3.draw(l16); canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); canvas3.cd(++ic); canvas3.draw(hOccupancy4); canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); - canvas3.draw(l4); //canvas3.draw(l5); - canvas3.draw(l6); //canvas3.draw(l7); + canvas3.draw(l4); + canvas3.draw(l6); canvas3.draw(l8); canvas3.draw(l9); canvas3.draw(l10); canvas3.draw(l11); - canvas3.draw(l12); //canvas3.draw(l13); - canvas3.draw(l14); //canvas3.draw(l15); - canvas3.draw(l16); //canvas3.draw(l17); + canvas3.draw(l12); + canvas3.draw(l14); + canvas3.draw(l16); canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); frame3.add(canvas3); frame3.setLocationRelativeTo(null); From 40528bcf0654caaf7ceabc931e815f305505036e Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Fri, 11 Feb 2022 10:29:59 +0100 Subject: [PATCH 061/104] cleanup --- .../ft/src/main/java/org/jlab/rec/ft/FTConstants.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java index bb6719caa4..9fd6e04157 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java @@ -8,6 +8,7 @@ /** * * @author devita + * @author filippi */ public class FTConstants { @@ -23,8 +24,6 @@ public class FTConstants { public static final double TRK_STRIP_MAX_TIME = 350; // minimum time value associated to one strip public static final double TRK_MIN_CROSS_NUMBER = 1; // minimum number of crosses to find a line in the tracker -// public static final double TRK0_TRK1_DISTANCE_MATCHING = 0.25; // matching distance between FTTRK points in cms -// public static final double TOLERANCE_ON_CROSSES_TWO_DETECTORS = 0.; // 1. cm radius tolerance, tune it up public static final double TRK0_TRK1_RADTOL = 0.1; // max tolerance for TRK0/TRK1 distance (3D) (was 1.-0.5) public static final double TRK0_TRK1_PHITOL = 0.07; // max tolerance for TRK0/TRK1 phi angular deviation (was 1.-0.7) public static final double TRK0_TRK1_THETATOL = 0.07; // max tolerance for TRK0/TRK1 theta angulare deviation (was 1.-0.7= From 9aeec2b1abbec38aeacab39f72198915329e0f26 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Fri, 11 Feb 2022 11:24:06 +0100 Subject: [PATCH 062/104] cleanup --- .../main/java/org/jlab/rec/ft/FTParticle.java | 61 +++++-------------- .../main/java/org/jlab/rec/ft/FTResponse.java | 2 +- 2 files changed, 17 insertions(+), 46 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index 4ef321348d..b0e26d2408 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -9,10 +9,11 @@ import org.jlab.geom.prim.Vector3D; import org.jlab.utils.groups.IndexedTable; import org.jlab.rec.ft.FTEBEngine; +import org.jlab.rec.ft.FTEventBuilder; +import org.jlab.rec.ft.trk.FTTRKConstantsLoader; public class FTParticle { - private int _ID; // track ID private int _Charge; // 0/1 for photon/electron private double _Time; // time of the particle at the vertex @@ -21,7 +22,6 @@ public class FTParticle { private Vector3D _Direction = new Vector3D(); // direction private int _Cluster; // track pointer to cluster information in FTCALRec::cluster bank private int _Signal; // track pointer to signal information in FTHODORec::cluster bank -// private int _Cross; // track pointer to cross information in FTTRKRec::cross bank private int _Cross0; // track pointer to cross information in FTTRKRec::cross bank (TRK0) private int _Cross1; // track pointer to cross information in FTTRKRec::cross bank (TRK1) private double _field; @@ -139,22 +139,11 @@ public int getHodoscopeIndex() { public void setHodoscopeIndex(int _Signal) { this._Signal = _Signal; } - -/* - public int getTrackerIndex() { - return _Cross; - } -*/ public int getTrackerIndex(int ndet) { if(ndet==0){return _Cross0;}else{return _Cross1;} } - -/* - public void setTrackerIndex(int _Cross) { - this._Cross = _Cross; - } -*/ + public void setTrackerIndex(int _Cross, int ndet) { if(ndet==0){this._Cross0 = _Cross;}else{this._Cross1 = _Cross;} } @@ -170,36 +159,18 @@ public int getDetectorHit(List hitList, String detectorType, double Line3D dist = cross.distance(response.getPosition().toPoint3D()); double hitdistance = dist.length(); double timedistance = Math.abs(this.getTime() - (response.getTime()-response.getPosition().mag()/PhysicsConstants.speedOfLight())); -// FTEBEngine.h600.fill(timedistance); -// FTEBEngine.h601.fill(response.getTime()); - -/* - if(detectorType=="FTTRK") { - double t=response.getTime(); - System.out.println(this.getTime() + " to be compared to " + response.getPosition().mag()/PhysicsConstants.speedOfLight()); - FTEBEngine.h600.fill(response.getPosition().mag()/PhysicsConstants.speedOfLight()); - FTEBEngine.h601.fill(response.getCrTime(), response.getPosition().mag()/PhysicsConstants.speedOfLight()); - if(response.getId()==0){ - FTEBEngine.h602.fill(response.getCrTime()); - } - if(response.getId()==1){ - FTEBEngine.h603.fill(response.getCrTime()); - } - } -*/ - -// if(detectorType=="FTHODO") FTEBEngine.h502.fill(timedistance); -// if((timedistanceTRK || timedistance<2.*timeThreshold) && hitdistance=1){ + System.out.println("best hit distance and time " + minimumDistance + " " + timedistance); + System.out.println("cross center coordinates x, y " + response.getPosition().toPoint3D().x() + " , " + response.getPosition().toPoint3D().y()); + } }else if(detectorType=="FTHODO" && timedistance hitList, int it, double distanceTh } } -// if(timedistance hitList, int it, double distanceTh return bestIndex; } + public int [][] getTRKOrderedListOfHits(List hitList, int it, double distanceThreshold, double timeThreshold){ Line3D cross = this.getLastCross(); - double minimumDistance = 500.0; + //double minimumDistance = 500.0; // how many FTTRK events? + int ndetectors = FTTRKConstantsLoader.NSupLayers; int hitsTRK = 0; for(int l=0; l hitDistancesDet0 = new ArrayList(hitsTRK); ArrayList hitOrderDet0 = new ArrayList(hitsTRK); ArrayList hitDistancesDet1 = new ArrayList(hitsTRK); @@ -300,7 +272,7 @@ public int[] getTRKBestHits(List hitList, int it, double distanceTh // fill energy and time histograms only once per set or hits on FTTRK FTEBEngine.h600.fill(response.getPosition().mag()/PhysicsConstants.speedOfLight()); FTEBEngine.h601.fill(response.getCrTime(), response.getPosition().mag()/PhysicsConstants.speedOfLight()); - if(det==0){ // non e' Id ma trkDet + if(det==0){ FTEBEngine.h602.fill(response.getCrTime()); }else if(det==1){ FTEBEngine.h603.fill(response.getCrTime()); @@ -335,7 +307,6 @@ public int[] getTRKBestHits(List hitList, int it, double distanceTh } } // sort the two arrays as a function of the distance - //int hitLen = hitDistancesDet0.size(); ArrayList iniHitDis0 = new ArrayList(); ArrayList iniHitDis1 = new ArrayList(); for(int l=0; l Date: Fri, 11 Feb 2022 12:55:57 +0100 Subject: [PATCH 063/104] major cleanup --- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 1614 ++--------------- 1 file changed, 141 insertions(+), 1473 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index 383e758a09..322dfb804a 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import java.util.List; -import java.util.Collections; +//import java.util.Collections; import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; @@ -15,7 +15,7 @@ import org.jlab.io.evio.EvioDataEvent; import org.jlab.io.hipo.HipoDataEvent; import org.jlab.rec.ft.FTConstants; -import org.jlab.utils.groups.IndexedTable; +//import org.jlab.utils.groups.IndexedTable; import org.jlab.geom.prim.Point3D; import org.jlab.rec.ft.FTEBEngine; @@ -28,11 +28,13 @@ public class FTTRKReconstruction { - public static int debugMode = 0; // 1 for verbose, set it here (better be set in the steering Engine) - ////////////////////// provisional + public static int debugMode = 0; // 1 for verbose, set it here (better be set in the steering Engine) PROVISIONAL public static float[] crEnergy; public static float[] crTime; - ////////////////////////////////// + public static int[] sectorLimits = + {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + + public FTTRKReconstruction() { } @@ -48,7 +50,7 @@ public List initFTTRK(DataEvent event, ConstantsManager manager, int r if(debugMode>=1) System.out.println("\nAnalyzing new event"); List allhits = null; -// allhits = this.readRawHits(event,charge2Energy,timeOffsets,geometry,trkGeo); +// allhits = this.readRawHits(event,charge2Energy,timeOffsets,geometry,trkGeo); allhits = this.readRawHits(event, run); if(debugMode>=1) { @@ -123,7 +125,7 @@ public ArrayList findClusters(List hits) // loop on layers for(int il=0; il findClusters(List hits) // if fired this is the first strip of the cluster clusterHits.add(new FTTRKHit(HitArray[ris][il].get_Sector(), HitArray[ris][il].get_Layer(), HitArray[ris][il].get_Strip(), HitArray[ris][il].get_Edep(), HitArray[ris][il].get_Time(), HitArray[ris][il].get_Id())); -// System.out.println(" clusterHits iteration " + is + " strip " + ris + " " + HitArray[ris][il].get_Strip()); // look for a consecutive strip in the stack and stick it to the cluster int isnext = is+1; while(isnext < 512 && HitArray[indR[isnext]][il] != null && !checked[indR[isnext]][il]){ @@ -141,7 +142,6 @@ public ArrayList findClusters(List hits) checked[nris][il] = true; clusterHits.add(new FTTRKHit(HitArray[nris][il].get_Sector(), HitArray[nris][il].get_Layer(), HitArray[nris][il].get_Strip(), HitArray[nris][il].get_Edep(), HitArray[ris][il].get_Time(), HitArray[nris][il].get_Id())); -// System.out.println(" clusterHits iteration " + isnext + " strip " + nris + " " + HitArray[nris][il].get_Strip()); nst++; isnext++; } @@ -167,9 +167,9 @@ public ArrayList findClusters(List hits) } is++; } - // second loop on LHS strips (only lateral strips) - is = 128; //384 - while(is < 384){ //639 + // second loop on LHS strips (only lateral strips) + is = 128; + while(is < 384){ int nst = 0; int lis = indL[is]; if(HitArray[lis][il] != null && !checked[lis][il]){ @@ -190,7 +190,6 @@ public ArrayList findClusters(List hits) } is = isnext-1; FTTRKCluster this_cluster = new FTTRKCluster(1, il+1, ++cid); -// this_cluster.addAll(clusterHits); ArrayList cloneHitsWNewID = new ArrayList(); for(FTTRKHit clHit: clusterHits){ clHit.set_DGTZIndex(clHit.get_Id()); @@ -203,8 +202,8 @@ public ArrayList findClusters(List hits) } is++; } - // check if in any cluster there is a limiting strip. If two consecutive limiting strips are found, merge the clusters and - // delete the second one + // check if in any cluster there is a limiting strip. If two consecutive limiting strips are found, merge the clusters and + // delete the second one int clusterId11 = -1; int clusterId12 = -1; int clusterId21 = -1; @@ -216,7 +215,6 @@ public ArrayList findClusters(List hits) for(int i=0; i < nbhits; i++){ FTTRKHit hit = clust.get(i); int nstrip = hit.get_Strip(); -// System.out.println("strip " + nstrip + " clusterId " + clust.get_CId() + " layer " + clust.get_Layer()); if(nstrip==128 || nstrip==385 || nstrip==640 || nstrip==641){ needsReordering = true; if(nstrip==128) clusterId11 = clust.get_CId(); //cut 127-384 @@ -242,20 +240,14 @@ public ArrayList findClusters(List hits) FTTRKHit hit = secondCluster.get(i); twoClusterHits.add(hit); } - //FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, clusters.size()+1); - // new list for joined clusters -// FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, clusters.size()-2); FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, ++clustersize); // update cluster and hit ID ArrayList cloneHitsWNewID = new ArrayList(); for(FTTRKHit clHit: twoClusterHits){ clHit.set_DGTZIndex(clHit.get_Id()); - //clHit.set_ClusterIndex(clusters.size()-2); // was +1 -// clHit.set_ClusterIndex(newIndex); //gets the index of the first of the joined clusters (both will be removed) cloneHitsWNewID.add(clHit); } joinedClusters.addAll(cloneHitsWNewID); -// joinedClusters.addAll(twoClusterHits); joinedClusters.calc_CentroidParams(); clusters.add(joinedClusters); } @@ -272,14 +264,10 @@ public ArrayList findClusters(List hits) FTTRKHit hit = secondCluster.get(i); twoClusterHits.add(hit); } -// FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, clusters.size()-2); FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, ++clustersize); -// joinedClusters.addAll(twoClusterHits); - // update cluster and hit ID ArrayList cloneHitsWNewID = new ArrayList(); for(FTTRKHit clHit: twoClusterHits){ clHit.set_DGTZIndex(clHit.get_Id()); - //clHit.set_ClusterIndex(clusters.size()-2); clHit.set_ClusterIndex(newIndex); cloneHitsWNewID.add(clHit); } @@ -287,7 +275,7 @@ public ArrayList findClusters(List hits) joinedClusters.calc_CentroidParams(); clusters.add(joinedClusters); } - // remove joined clusters from the final list + // remove joined clusters from the final list if(clusterId11>=0 && clusterId12>=0) { if(clusterId11 findClusters(List hits) } // end loop on layers - // before returning cluster list re-calculate centroid and its error, if the cluster list was modified + // before returning cluster list update centroid and its error, if the cluster list was modified if(needsReordering){ int newClusterID = -1; for(FTTRKCluster aCluster : clusters){ @@ -351,8 +339,7 @@ public ArrayList findCrosses(List clusters) { if(outlayerclus.get_Sector()!=inlayerclus.get_Sector()) continue; if(debugMode>=1) System.out.println(inlayerclus.printInfo() + " " + outlayerclus.printInfo()); if( (inlayerclus.get_MinStrip()+outlayerclus.get_MinStrip() > 0) - && (inlayerclus.get_MaxStrip()+outlayerclus.get_MaxStrip() < FTTRKConstantsLoader.Nstrips*2) ) { // put correct numbers to make sure the intersection is valid - + && (inlayerclus.get_MaxStrip()+outlayerclus.get_MaxStrip() < FTTRKConstantsLoader.Nstrips*2) ) { // define new cross FTTRKCross this_cross = new FTTRKCross(inlayerclus.get_Sector(), inlayerclus.get_Region(),++rid); this_cross.set_Cluster1(inlayerclus); @@ -361,8 +348,7 @@ public ArrayList findCrosses(List clusters) { int dummy2 = this_cross.get_Cluster2().get_CId(); this_cross.set_CrossParams(); - //make arraylist - // check if the cross center is in a physical position + //make arraylist and check whether the cross center is in a physical position double radXCenter = Math.sqrt(this_cross.get_Point().x()*this_cross.get_Point().x() + this_cross.get_Point().y()*this_cross.get_Point().y()); if(debugMode>=1) System.out.println("cross radius =============" + radXCenter); @@ -373,7 +359,9 @@ public ArrayList findCrosses(List clusters) { } } - // validate crosses: for every detector choose the cross with larger deposited energy: only two crosses are saved + // best validated crosses: for every detector choose the cross with larger deposited energy: only two crosses are saved with the largest energy + // not used if all crosses are used for multihit matching + /* ArrayList validatedCrosses = new ArrayList(); double maxEn1 =-100.; double maxEn2 =-100.; @@ -400,7 +388,7 @@ public ArrayList findCrosses(List clusters) { double diffPhiTolerance = FTConstants.TRK0_TRK1_PHITOL; double diffThetaTolerance = FTConstants.TRK0_TRK1_THETATOL; -// make a geometric match of the two crosses +// make a geometric match of the two validate crosses if(validatedCrosses.size()== FTTRKConstantsLoader.NSupLayers){ Point3D cross0 = validatedCrosses.get(0).get_Point(); Point3D cross1 = validatedCrosses.get(1).get_Point(); @@ -413,8 +401,9 @@ public ArrayList findCrosses(List clusters) { double diffPhi = Math.atan2(cross0.y(), cross0.x()) - Math.atan2(cross1.y(), cross1.x()); if(!(Math.abs(diffPhi) < diffPhiTolerance && Math.abs(diffRadii)< diffRadTolerance && Math.abs(diffTheta) < diffThetaTolerance)) validatedCrosses.clear(); } + */ - //return validatedCrosses; + //return validatedCrosses; // return this if just the best two crosses per event are required return crosses; } @@ -435,206 +424,35 @@ public List readRawHits(DataEvent event, int run) { int icomponent = bankDGTZ.getInt("component",row); int iorder = bankDGTZ.getInt("order",row); int adc = bankDGTZ.getInt("ADC",row); -// float time = bankDGTZ.getLong("timestamp",row); // entry not avalable in mc banks yet float time = bankDGTZ.getFloat("time", row); - // set threshold on FTTRK ADCs (in FTConstants.java + /////////////////////////////////////////////////////// insert here operations modifying strip number /////////////////////////////////////////////////////// IN RECO: STRIP NUMBERS: 0-767, layer numbers: 0-3 /////////////////////////////////////////////////////// IN FEE: STRIP NUMBERS: 1-768, layer numbers: 1-4 - - // swap layer numbers - /* - if(ilayer==1){ - ilayer = 3; - }else if(ilayer==2){ - ilayer = 4; - }else if(ilayer==3){ - ilayer = 1; - }else if(ilayer==4){ - ilayer = 2; - } - */ - // swap left/right short strips sectors for layer 2 and 4 (it means a reflection wrt y axis) - - /* - if(ilayer==4 || ilayer==2){ - if(icomponent>=129 && icomponent<=384){ - icomponent += 256; - }else if(icomponent>=385 && icomponent<=640){ - icomponent -= 256; - } - } - */ - - /* - if(ilayer==2 || ilayer==3) icomponent = flipStripVertical(ilayer, icomponent); - if(ilayer==4) icomponent = flipStripHorizontal(ilayer, icomponent); - */ - + // read just layer sectors only for real data (no montecarlo) - //icomponent = adjustStripNumberingTest11(run, ilayer, icomponent); - //icomponent = renumberStrip(ilayer, icomponent); - //icomponent = renumberFEE2RECRotatedAndAdjustVanilla(run, ilayer, icomponent); - //icomponent = renumberFEE2RECRotatedAndAdjustHazel(run, ilayer, icomponent); - if(run != 10) icomponent = renumberFEE2RECRotatedAndAdjustWalnut(run, ilayer, icomponent); - - -/* -// layer 3: swap 6-7 e inversione - if(ilayer==3){ - int isec1 = findSector(icomponent); - if(isec1 == 6){ - icomponent = swapSectors(icomponent, 7); - }else if(isec1 == 7){ - icomponent = swapSectors(icomponent, 6); - } - int newSector = findSector(icomponent); - if(newSector == 6 || newSector==7) icomponent = reverseStripsInSector(icomponent); - } - -// swap central sectors (6->9, 7->10, 8->11) for layers 1,4 - large sectors (16) numbering - if(ilayer==1 || ilayer == 4 || ilayer==3 || ilayer==2){ - int isec1 = findSector(icomponent); - if(isec1==6){ - icomponent = swapSectors(icomponent, 10); - }else if(isec1==7){ - icomponent = swapSectors(icomponent, 11); - }else if(isec1==8){ - icomponent = swapSectors(icomponent, 12); - }else if(isec1==9){ - icomponent = swapSectors(icomponent, 13); - }else if(isec1==10){ - icomponent = swapSectors(icomponent, 6); - }else if(isec1==11){ - icomponent = swapSectors(icomponent, 7); - }else if(isec1==12){ - icomponent = swapSectors(icomponent, 8); - }else if(isec1==13){ - icomponent = swapSectors(icomponent, 9); - } - -// }else if(isec1==2){ -// icomponent = swapSectors(icomponent, 14); -// }else if(isec1==3){ -// icomponent = swapSectors(icomponent, 15); -// }else if(isec1==4){ -// icomponent = swapSectors(icomponent, 16); -// }else if(isec1==5){ -// icomponent = swapSectors(icomponent, 17); -// }else if(isec1==14){ -// icomponent = swapSectors(icomponent, 2); -// }else if(isec1==15){ -// icomponent = swapSectors(icomponent, 3); -// }else if(isec1==16){ -// icomponent = swapSectors(icomponent, 4); -// }else if(isec1==17){ -// icomponent = swapSectors(icomponent, 5); -// } - } - -*/ - - -///////////////////////////////////////////////////////////////////////////////////////////////// + // PROVISIONAL: include correct run range for fall18 RGA runs & same FTTRK FEEE configuration + if(run != 10) icomponent = renumberFEE2RECRotatedAndAdjust_Fall18RGA(run, ilayer, icomponent); if(adc>FTConstants.FTTRKMinAdcThreshold && adc0 && icomponent<=64) hits.add(hit); - }else if(ilayer == 3){ - if(icomponent>705&& icomponent<=768) hits.add(hit); - }else{ - hits.add(hit); - } -*/ - -// if(icomponent>64 && icomponent<=128) hits.add(hit); -// if(icomponent>128 && icomponent<=160) hits.add(hit); -// if(icomponent>160 && icomponent<=192) hits.add(hit); -// if(icomponent>192 && icomponent<=256) hits.add(hit); -// if(icomponent>256 && icomponent<=320) hits.add(hit); -// if(icomponent>320 && icomponent<=352) hits.add(hit); -// if(icomponent>352 && icomponent<=384) hits.add(hit); -// if(icomponent>384 && icomponent<=416) hits.add(hit); -// if(icomponent>416 && icomponent<=448) hits.add(hit); -// if(icomponent>448 && icomponent<=512) hits.add(hit); -// if(icomponent>513 && icomponent<=577) hits.add(hit); -// if(icomponent>577 && icomponent<=610) hits.add(hit); -// if(icomponent>610 && icomponent<=640) hits.add(hit); -// if(icomponent>640 && icomponent<=705) hits.add(hit); -// if(icomponent>705 && icomponent<=768) hits.add(hit); -// if(icomponent>512) - - -/* - if(ilayer==1){ - if(isInSector(0, icomponent)) hits.add(hit); - }else if(ilayer==2){ - if(isInSector(7, icomponent)) hits.add(hit); - }else if(ilayer==3){ - if(isInSector(19, icomponent)) hits.add(hit); - }else if(ilayer==4){ - if(isInSector(3, icomponent)) hits.add(hit); -} -*/ -/* - if(isStripInConnector(3, ilayer, icomponent)) { - hits.add(hit); - } -*/ - -// select strips belonging to a crate (1-2-3) -/// if(isStripInCrate(1, ilayer, icomponent)) hits.add(hit); -// select strips belonging to a given physical connector in a layer -// int iconn = findPhysicalConnector(icomponent); -// if(ilayer==2 && iconn==6) hits.add(hit); // bad connector -// if(ilayer==4 && iconn==12) hits.add(hit); // bad connector - +//////////////////////////////////////////////////////// insert here possible operations selecting strips or groups of strips - /* - if(ilayer==1 && icomponent>=1 && icomponent<=64) hits.add(hit); - if(ilayer==2 && icomponent>=193 && icomponent<=258) hits.add(hit); - if(ilayer==3 && icomponent>=705 && icomponent<=768) hits.add(hit); - if(ilayer==4 && icomponent>=119 && icomponent<=384) hits.add(hit); - */ + // select only one sector at a time, for instance + // if(icomponent>64 && icomponent<=128) hits.add(hit); - boolean isHitAccepted = true; -// if(ilayer == 2 || ilayer ==3) isHitAccepted = false; -// if((ilayer==2) && icomponent<=641) isHitAccepted = false; -// if((ilayer==4) && icomponent>=1 && icomponent>64) isHitAccepted = false; - -// strip sector selection in layer 1-2 -/* - if(ilayer==1){ - nsec1 = findIn12Sectors(icomponent); - if(nsec1!=10 && nsec1!=11) isHitAccepted = false; - } - if(ilayer==2){ - nsec2 = findIn12Sectors(icomponent); - if(nsec2 ==6){ - System.out.println("layer 2 sector 6 " + icomponent); -// if(icomponent-64*6 > 32.){icomponent = -1;}else{icomponent = 200;} - }else{ - icomponent = -1; - } - } -// if(nsec1 !=5) isHitAccepted = false; -*/ + boolean isHitAccepted = true; + // exclude here some layers or sectors, for instance + // if((ilayer==4) && icomponent>=1 && icomponent>64) isHitAccepted = false; + + // selection on strip time + if(time < FTConstants.TRK_STRIP_MIN_TIME || time > FTConstants.TRK_STRIP_MAX_TIME) isHitAccepted = false; + // icomponent = -1: strip is off + if(icomponent<0) isHitAccepted = false; -// selection on strip time - if(time < FTConstants.TRK_STRIP_MIN_TIME || time > FTConstants.TRK_STRIP_MAX_TIME) isHitAccepted = false; - if(icomponent<0) isHitAccepted = false; - - if(isHitAccepted) hits.add(hit); -//////////////////////////////////////////////////////////////////////////////////////// + if(isHitAccepted) hits.add(hit); } } } @@ -701,13 +519,12 @@ public void writeHipoBanks(DataEvent event, List hits, List hits, List1200.) continue; - // these are probaly outoftimers, no needo to cut - //if(crosses.get(j).get_Time()<150. || crosses.get(j).get_Time()>250.) continue; - /////////////////////////////////////////////////////////////////////////////////////// + for (int j = 0; j < crosses.size(); j++){ bankCross.setShort("size", j, (short) crosses.size()); -// bankCross.setShort("id", j, (short) crosses.get(j).get_Id()); bankCross.setShort("id", j, (short) crosses.get(j).get_trkId()); bankCross.setByte("sector", j, (byte) crosses.get(j).get_Sector()); bankCross.setByte("detector", j, (byte) (crosses.get(j).get_Region()-1)); // detector: 0 or 1, region 1 or 2 bankCross.setFloat("x", j, (float) crosses.get(j).get_Point().x()); bankCross.setFloat("y", j, (float) crosses.get(j).get_Point().y()); bankCross.setFloat("z", j, (float) crosses.get(j).get_Point().z()); - // System.out.println("energy and time to be stored in banks " + crosses.get(j).get_Energy() + " " + crosses.get(j).get_Time()); + if(debugMode>=1) System.out.println("energy and time to be stored in banks " + crosses.get(j).get_Energy() + " " + crosses.get(j).get_Time()); + // control histograms should be provisional and filled only if existing FTEBEngine.h507.fill(crosses.get(j).get_Time(), crosses.get(j).get_Energy()); if(crosses.get(j).get_Id()==0){ FTEBEngine.h503.fill(crosses.get(j).get_Time()); @@ -793,7 +605,7 @@ public void writeEvioBanks(DataEvent event, List hits, List hits, List hits, List hits, List0){ // provisional - if(ilayer==1){ - //icomponent = overturnModule(ilayer, icomponent); - icomponent = flipStripVertical(ilayer, icomponent); - int isec1 = findSector(icomponent); - - // test 9 - /* - if(isec1==2){ // era 2-5, 5-13, 13-12, 12-2 (test8_2) - icomponent = swapSectors(icomponent, 12); - }else if(isec1==3){ - icomponent = swapSectors(icomponent, 2); - }else if(isec1==5){ - icomponent = swapSectors(icomponent, 13); - }else if(isec1==12){ - icomponent = swapSectors(icomponent, 3); - }else if(isec1==13){ - icomponent = swapSectors(icomponent, 5); - */ - // test10 - if(isec1==2){ - icomponent = swapSectors(icomponent, 12); - }else if(isec1==12){ - icomponent = swapSectors(icomponent, 2); - }else if(isec1==5){ - icomponent = swapSectors(icomponent, 13); - }else if(isec1==13){ - icomponent = swapSectors(icomponent, 5); - - //}else if(isec1==12){ - // icomponent = swapSectors(icomponent, 10); - //}else if(isec1==10){ - // icomponent = swapSectors(icomponent, 12); - - /* - if(isec1==12){ - icomponent = swapSectors(icomponent, 10); - }else if(isec1==10){ - icomponent = swapSectors(icomponent, 12); - }else if(isec1==5){ - icomponent = swapSectors(icomponent, 2); - }else if(isec1==2){ - icomponent = swapSectors(icomponent, 5); - }else if(isec1==13){ - icomponent = swapSectors(icomponent, 11); - }else if(isec1==11){ - icomponent = swapSectors(icomponent, 13); - */ - - /* - if(isec1==13){ - icomponent = swapSectors(icomponent, 12); - }else if(isec1==12){ - icomponent = swapSectors(icomponent, 10); - }else if(isec1==10){ - icomponent = swapSectors(icomponent, 13); - }else if(isec1==5){ - icomponent = swapSectors(icomponent, 2); - }else if(isec1==2){ - icomponent = swapSectors(icomponent, 5); - */ - - }else if(isec1==14){ - icomponent = swapSectors(icomponent, 17); - }else if(isec1==15){ - icomponent = swapSectors(icomponent, 16); - }else if(isec1==16){ - icomponent = swapSectors(icomponent, 15); - }else if(isec1==17){ - icomponent = swapSectors(icomponent, 14); - } - // reverse sectors - int newsec = findSector(icomponent); - if(newsec==16 || newsec==17 || newsec==2) icomponent = reverseStripsInSector(icomponent); - -// test 12 -// if(newsec==13){ -// icomponent = swapSectors(icomponent, 10); -// }else if(newsec==10){ -// icomponent = swapSectors(icomponent, 13); -// } - - - /* - newsec = findSector(icomponent); - if(newsec==3){ - icomponent = swapSectors(icomponent, 12); - }else if(newsec==12){ - icomponent = swapSectors(icomponent, 3); - } - if(newsec==2 || newsec==4) icomponent = reverseStripsInSector(icomponent); - */ - - }else if(ilayer==2){ - icomponent = flipStripVertical(ilayer, icomponent); - int isec1 = findSector(icomponent); - - if(isec1==2){ - icomponent = swapSectors(icomponent, 12); - }else if(isec1==12){ - icomponent = swapSectors(icomponent, 2); - }else if(isec1==5){ - icomponent = swapSectors(icomponent, 13); - }else if(isec1==13){ - icomponent = swapSectors(icomponent, 5); - - }else if(isec1==14){ - icomponent = swapSectors(icomponent, 17); - }else if(isec1==15){ - icomponent = swapSectors(icomponent, 16); - }else if(isec1==16){ - icomponent = swapSectors(icomponent, 15); - }else if(isec1==17){ - icomponent = swapSectors(icomponent, 14); - } - // reverse sectors - int newsec = findSector(icomponent); - if(newsec==16 || newsec==17) icomponent = reverseStripsInSector(icomponent); - - }else if(ilayer==3){ - icomponent = flipStripVertical(ilayer, icomponent); - int isec1 = findSector(icomponent); - if(isec1==2){ - icomponent = swapSectors(icomponent, 4); - }else if(isec1==3){ - icomponent = swapSectors(icomponent, 5); - }else if(isec1==4){ - icomponent = swapSectors(icomponent, 2); - }else if(isec1==5){ - icomponent = swapSectors(icomponent, 3); - - }else if(isec1==14){ - icomponent = swapSectors(icomponent, 17); - }else if(isec1==15){ - icomponent = swapSectors(icomponent, 16); - }else if(isec1==16){ - icomponent = swapSectors(icomponent, 15); - }else if(isec1==17){ - icomponent = swapSectors(icomponent, 14); - } - // reverse sectors - int newsec = findSector(icomponent); - if(newsec==16 || newsec==17) icomponent = reverseStripsInSector(icomponent); - }else if(ilayer==4){ - icomponent = flipStripHorizontal(ilayer, icomponent); - int isec1 = findSector(icomponent); - if(isec1==2){ - icomponent = swapSectors(icomponent, 5); - }else if(isec1==5){ - icomponent = swapSectors(icomponent, 2); - }else if(isec1==3){ - icomponent = swapSectors(icomponent, 4); - }else if(isec1==4){ - icomponent = swapSectors(icomponent, 3); - }else if(isec1==14){ - icomponent = swapSectors(icomponent, 17); - }else if(isec1==15){ - icomponent = swapSectors(icomponent, 16); - }else if(isec1==16){ - icomponent = swapSectors(icomponent, 15); - }else if(isec1==17){ - icomponent = swapSectors(icomponent, 14); - } - int newsec = findSector(icomponent); - if(newsec==16 || newsec==17 || newsec==2 || newsec==3) icomponent = reverseStripsInSector(icomponent); - - } - } - return icomponent; -} - public int flipStripVertical(int ilayer, int icomponent){ // flip the layer vertically with respect to y axis (left/right flip) // strips numbered 1-768 - /* - if(ilayer==1 || ilayer==3){ // vertical strips - if(icomponent>=129 && icomponent<=384){ - icomponent = 512-icomponent; - }else if(icomponent>384 && icomponent<=640){ - icomponent = 1025 - icomponent; - }else{ - icomponent = 769 - icomponent; - } - }else if(ilayer==2 || ilayer==4){ - if(icomponent>=129 && icomponent<=384){ - icomponent = 513 - icomponent; - }else if(icomponent>384 && icomponent<=640){ - icomponent = 1025 - icomponent; - }else{ - //icomponent = 769 - icomponent; - } - } - */ - - // strips numbers 1-768 if(ilayer==2 || ilayer==3){ // RECO vertical strips if(icomponent>=129 && icomponent<=384){ icomponent += 256; @@ -1089,33 +704,12 @@ public int flipStripVertical(int ilayer, int icomponent){ icomponent = 769 - icomponent; } } - - return icomponent; } public int flipStripHorizontal(int ilayer, int icomponent){ // flip the layer horizontally with respect to the x axis (top/bottom flip) // strips 1-128 - /* - if(ilayer==1 || ilayer==3){ - if(icomponent>=129 && icomponent<=384){ - icomponent += 256; - }else if(icomponent>=385 && icomponent<=640){ - icomponent -= 256; - }else{ - icomponent = 769 - icomponent; - } - }else if(ilayer==2 || ilayer ==4){ - if(icomponent>=129 && icomponent<=384){ - icomponent = 513 - icomponent; - }else if(icomponent>=385 && icomponent<=640){ - icomponent = 1025 - icomponent; - }else{ - // icomponent = 769 - icomponent; - } - } - */ if(ilayer==1 || ilayer==4){ // RECO vertical strips if(icomponent>=129 && icomponent<=384){ icomponent += 256; @@ -1135,35 +729,37 @@ public int flipStripHorizontal(int ilayer, int icomponent){ return icomponent; } - public int overturnModule(int ilayer, int icomponent){ +public int overturnModule(int ilayer, int icomponent){ // rotate of 180 degrees: this incluse a flip with respect to the x axis followed by a flip with respect to y int icompNew = flipStripHorizontal(ilayer, icomponent); icompNew = flipStripVertical(ilayer, icompNew); return icompNew; } - + public int reverseStripsInSector(int icomponent){ // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is - // excluded in the sector, [i+1]is inluded - int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + // excluded in the sector, [i+1]is included + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + //int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector = findSector(icomponent); if(nsector>20) System.out.println("wrong sector number, check code"); - int offset = sectorLimit[nsector+1] - icomponent; - icomponent = sectorLimit[nsector]+1 + offset; + int offset = sectorLimits[nsector+1] - icomponent; + icomponent = sectorLimits[nsector]+1 + offset; return icomponent; } public int reverseStripInFirstHalf(int icomponent){ // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is - // excluded in the sector, [i+1]is inluded - int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + // excluded in the sector, [i+1]is included + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + //int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector = findSector(icomponent); if(nsector>20) System.out.println("wrong sector number, check code"); - int halfStrip = (sectorLimit[nsector+1]-sectorLimit[nsector])/2 + sectorLimit[nsector]; + int halfStrip = (sectorLimits[nsector+1]-sectorLimits[nsector])/2 + sectorLimits[nsector]; if(icomponent <= halfStrip){ int offset = halfStrip - icomponent; - icomponent = sectorLimit[nsector]+1 + offset; + icomponent = sectorLimits[nsector]+1 + offset; } return icomponent; } @@ -1172,12 +768,13 @@ public int reverseStripInFirstHalf(int icomponent){ public int reverseStripInSecondHalf(int icomponent){ // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is // excluded in the sector, [i+1]is included - int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + //int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector = findSector(icomponent); - if(nsector>20) System.out.println("wrong sector number, check code"); - int halfStrip = (sectorLimit[nsector+1]-sectorLimit[nsector])/2 + sectorLimit[nsector]; + if(nsector>20) System.err.println("wrong FTTRK strip sector number, check code"); + int halfStrip = (sectorLimits[nsector+1]-sectorLimits[nsector])/2 + sectorLimits[nsector]; if(icomponent > halfStrip){ - int offset = sectorLimit[nsector+1] - icomponent; + int offset = sectorLimits[nsector+1] - icomponent; icomponent = halfStrip + offset; } return icomponent; @@ -1187,11 +784,12 @@ public int swapHalves(int icomponent){ // swap half the module to the opposite half, rigid translation // the strips are numbered 1-768, the [i] component of sectorLimit vector is // excluded in the sector, [i+1]is included - int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + //int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector = findSector(icomponent); - if(nsector>20) System.out.println("wrong sector number, check code"); - int halfWid = (sectorLimit[nsector+1]-sectorLimit[nsector])/2; - int halfStrip = halfWid + sectorLimit[nsector]; + if(nsector>20) System.err.println("wrong FTTRK strip sector number, check code"); + int halfWid = (sectorLimits[nsector+1]-sectorLimits[nsector])/2; + int halfStrip = halfWid + sectorLimits[nsector]; if(icomponent >= halfStrip+1){ icomponent -= halfWid; }else{ @@ -1202,106 +800,42 @@ public int swapHalves(int icomponent){ public int switchStripOff(){return -1;} -public int reverseStripsIn12Sectors(int icomponent){ - int[] sectorLimit = {0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768}; - int nsector = findIn12Sectors(icomponent); - int offset = sectorLimit[nsector+1] - icomponent; - icomponent = sectorLimit[nsector] + offset; - - return icomponent; -} - public int swapSectors(int icomponent, int nsector2){ // get the new strip number of the icomponent strip in nsector1 once the sector is swapped to nsector2 // icomponent strips are numbered 1-768 so the vector sectorLimits contains the number of the starting // strip of a sector: [i] is excluded from sector i, [i+1] is included - int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + //int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector1 = findSector(icomponent); - int offset = -sectorLimit[nsector1] + icomponent; - int newicomp = sectorLimit[nsector2] + offset; - - return newicomp; -} - -public int swap12Sectors(int icomponent, int nsector2){ - // get the new strip number of the icomponent strip in nsector1 once the sector is swapped to nsector2 - //int[] sectorLimits = {0, 64, 128, 192, 256, 320, 384, 498, 512, 576, 640, 704, 768}; - int[] sectorNumber = {0, 1, 2, 3, 8, 9, 4, 5, 6, 7, 10, 11 }; - int[] sectorLimits = {0, 64, 128, 192, 256, 448, 512, 576, 640, 320, 384, 704, 768}; - int[] sectorLimitsSequential = {0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768}; - int[] sectorNumberSequential = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - int nsector1 = findIn12Sectors(icomponent); - int secidx1 = -1; - int secidx2 = -1; - /* - for(int i=0; i<11; i++){ - if(sectorNumberSequential[i] == nsector1) secidx1 = i; - if(sectorNumberSequential[i] == nsector2) secidx2 = i; - } - */ - int offset = -sectorLimitsSequential[nsector1] + icomponent; - int newicomp = sectorLimitsSequential[nsector2] + offset; + int offset = -sectorLimits[nsector1] + icomponent; + int newicomp = sectorLimits[nsector2] + offset; return newicomp; } - - public static int findSector(int icomponent){ // returns the sector number, corresponding to the component of the lower extreme of the interval // sectors are numbered 0-20; icomponent strips are numbered 1-768 so the vector sectorLimits contains // the number of the starting strip of a sector: [i] is excluded from sector i, [i+1] is included - int[] sectorLimits = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + //int[] sectorLimits = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector = -1; for(int i=0; i<20; i++){ if(icomponent>sectorLimits[i] && icomponent<=sectorLimits[i+1]){ -// if(icomponent>=sectorLimits[i] && icomponent20) System.out.println("wrong sector number, check code"); - return nsector; -} - -public static int findIn12Sectors(int icomponent){ - // returns the sector number, corresponding to the component of the lower extreme of the interval - // sectors are numbered 0-11 - //int[] sectorLimits = {0, 64, 128, 192, 256, 320, 384, 498, 512, 576, 640, 704, 768}; - int[] sectorLimits = {0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768}; - int[] sectorNumber = {0, 1, 2, 3, 8, 9, 4, 5, 6, 7, 10, 11 }; - int nsector = -1; - for(int i=0; i<12; i++){ - if(icomponent>sectorLimits[i] && icomponent<=sectorLimits[i+1]){ -// nsector = sectorNumber[i]; - nsector = i; - break; - } - } - return nsector; -} - - -public static int findIn16Sectors(int icomponent){ - // returns the sector number, corresponding to the component of the lower extreme of the interval - // sectors are numbered 0-16 - int[] sectorLimits = {0, 64, 128, 160, 192, 224, 256, 320, 352, 384, 416, 448, 512, 576, 608, 640, 704, 768}; - int nsector = -1; - for(int i=0; i<16; i++){ - if(icomponent>sectorLimits[i] && icomponent<=sectorLimits[i+1]){ nsector = i; break; } } + if(nsector>20) System.err.println("wrong FTTRK strip sector number, check code"); return nsector; } - public boolean isInSector(int iSector, int icomponent){ // returns ture is the strip icomponent is in the iSector sector - int[] sectorLimits = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + //int[] sectorLimits = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; if(icomponent>sectorLimits[iSector] && icomponent<=sectorLimits[iSector+1]){ return true; }else{ @@ -1309,295 +843,77 @@ public boolean isInSector(int iSector, int icomponent){ } } -public int adjustStripNumbering(int run, int ilayer, int icomponent){ - // adjustment of strip numbering valid for fall18 data - if(run>0){ // provisional - if(ilayer==1){ - ; - }else if(ilayer==2){ - //icomponent = flipStripVertical(ilayer, icomponent); - - }else if(ilayer==3){ - //icomponent = flipStripVertical(ilayer, icomponent); - - }else if(ilayer==4){ - ; - } - } - return icomponent; -} - - -public boolean isStripInSlot(int slot, int icomponent){ - // exits true if the strip is located in the group corresponding to one of the 12 fee slots (64 strips each) - // strips numeration in slots start from 1 to 768 - int[] slotLimits = {1, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768}; - // 12 slots, from 0 to 11, ordered according to the sequence: 0,1,2,3, 6,7,8,9, 4,5,10,11 - icomponent++; - boolean isInSlot = false; - switch(slot){ - case 0: - if(icomponent>=slotLimits[0] && icomponent<=slotLimits[1]) isInSlot = true; - break; - case 1: - if(icomponent>slotLimits[1] && icomponent<=slotLimits[2]) isInSlot = true; - break; - case 2: - if(icomponent>slotLimits[2] && icomponent<=slotLimits[3]) isInSlot = true; - break; - case 3: - if(icomponent>slotLimits[3] && icomponent<=slotLimits[4]) isInSlot = true; - break; - case 6: - if(icomponent>slotLimits[4] && icomponent<=slotLimits[5]) isInSlot = true; - break; - case 7: - if(icomponent>slotLimits[5] && icomponent<=slotLimits[6]) isInSlot = true; - break; - case 8: - if(icomponent>slotLimits[6] && icomponent<=slotLimits[7]) isInSlot = true; - break; - case 9: - if(icomponent>slotLimits[7] && icomponent<=slotLimits[8]) isInSlot = true; - break; - case 4: - if(icomponent>slotLimits[8] && icomponent<=slotLimits[9]) isInSlot = true; - break; - case 5: - if(icomponent>slotLimits[9] && icomponent<=slotLimits[10]) isInSlot = true; - break; - case 10: - if(icomponent>slotLimits[10] && icomponent<=slotLimits[11]) isInSlot = true; - break; - case 11: - if(icomponent>slotLimits[11] && icomponent<=slotLimits[12]) isInSlot = true; - break; - default: - break; - } - return isInSlot; -} - - -public boolean isStripInConnector(int iFEUConn, int ilayer, int icomponent) -{ - boolean isStripConnected = false; - // there are 12 connectors per layer, layers are numbered 1-4, FEUConnectors 0 to 11 - switch(iFEUConn){ - case 0: - if(ilayer==1){if(isStripInSlot(4, icomponent)) isStripConnected = true;} - else if(ilayer==2){if(isStripInSlot(6, icomponent)) isStripConnected = true;} - else if(ilayer==3){if(isStripInSlot(1, icomponent)) isStripConnected = true;} - else if(ilayer==4){if(isStripInSlot(2, icomponent)) isStripConnected = true;} - break; - case 1: - if(ilayer==1){if(isStripInSlot(7, icomponent)) isStripConnected = true;} - else if(ilayer==2){if(isStripInSlot(2, icomponent)) isStripConnected = true;} - else if(ilayer==3){if(isStripInSlot(1, icomponent)) isStripConnected = true;} - else if(ilayer==4){if(isStripInSlot(2, icomponent)) isStripConnected = true;} - break; - case 2: - if(ilayer==1){if(isStripInSlot(7, icomponent)) isStripConnected = true;} - else if(ilayer==2){if(isStripInSlot(7, icomponent)) isStripConnected = true;} - else if(ilayer==3){if(isStripInSlot(0, icomponent)) isStripConnected = true;} - else if(ilayer==4){if(isStripInSlot(1, icomponent)) isStripConnected = true;} - break; - case 3: - if(ilayer==1){if(isStripInSlot(0, icomponent)) isStripConnected = true;} - else if(ilayer==2){if(isStripInSlot(3, icomponent)) isStripConnected = true;} - else if(ilayer==3){if(isStripInSlot(5, icomponent)) isStripConnected = true;} - else if(ilayer==4){if(isStripInSlot(6, icomponent)) isStripConnected = true;} - break; - case 4: - if(ilayer==1){if(isStripInSlot(0, icomponent)) isStripConnected = true;} - else if(ilayer==2){if(isStripInSlot(6, icomponent)) isStripConnected = true;} - else if(ilayer==3){if(isStripInSlot(5, icomponent)) isStripConnected = true;} - else if(ilayer==4){if(isStripInSlot(6, icomponent)) isStripConnected = true;} - break; - case 5: - if(ilayer==1){if(isStripInSlot(4, icomponent)) isStripConnected = true;} - else if(ilayer==2){if(isStripInSlot(5, icomponent)) isStripConnected = true;} - else if(ilayer==3){if(isStripInSlot(3, icomponent)) isStripConnected = true;} - else if(ilayer==4){if(isStripInSlot(7, icomponent)) isStripConnected = true;} - break; - case 6: - if(ilayer==1){if(isStripInSlot(1, icomponent)) isStripConnected = true;} - else if(ilayer==2){if(isStripInSlot(0, icomponent)) isStripConnected = true;} - else if(ilayer==3){if(isStripInSlot(3, icomponent)) isStripConnected = true;} - else if(ilayer==4){if(isStripInSlot(5, icomponent)) isStripConnected = true;} - break; - case 7: - if(ilayer==1){if(isStripInSlot(3, icomponent)) isStripConnected = true;} - else if(ilayer==2){if(isStripInSlot(4, icomponent)) isStripConnected = true;} - else if(ilayer==3){if(isStripInSlot(1, icomponent)) isStripConnected = true;} - else if(ilayer==4){if(isStripInSlot(3, icomponent)) isStripConnected = true;} - break; - case 8: - if(ilayer==1){if(isStripInSlot(4, icomponent)) isStripConnected = true;} - else if(ilayer==2){if(isStripInSlot(7, icomponent)) isStripConnected = true;} - else if(ilayer==3){if(isStripInSlot(2, icomponent)) isStripConnected = true;} - else if(ilayer==4){if(isStripInSlot(5, icomponent)) isStripConnected = true;} - break; - case 9: - if(ilayer==1){if(isStripInSlot(0, icomponent)) isStripConnected = true;} - else if(ilayer==2){if(isStripInSlot(4, icomponent)) isStripConnected = true;} - else if(ilayer==3){if(isStripInSlot(1, icomponent)) isStripConnected = true;} - else if(ilayer==4){if(isStripInSlot(7, icomponent)) isStripConnected = true;} - break; - case 10: - if(ilayer==1){if(isStripInSlot(6, icomponent)) isStripConnected = true;} - else if(ilayer==2){if(isStripInSlot(2, icomponent)) isStripConnected = true;} - else if(ilayer==3){if(isStripInSlot(5, icomponent)) isStripConnected = true;} - else if(ilayer==4){if(isStripInSlot(4, icomponent)) isStripConnected = true;} - break; - case 11: - if(ilayer==1){if(isStripInSlot(3, icomponent)) isStripConnected = true;} - else if(ilayer==2){if(isStripInSlot(2, icomponent)) isStripConnected = true;} - else if(ilayer==3){if(isStripInSlot(1, icomponent)) isStripConnected = true;} - else if(ilayer==4){if(isStripInSlot(6, icomponent)) isStripConnected = true;} - break; - default: - break; - } - return isStripConnected; -} - -public boolean isStripInCrate(int nCrate, int ilayer, int icomponent){ - boolean isInCrate = false; - // check if the strip belongs to a given connector - connectors are numbered 1-12 - // icomponent is numberered 0-767 - int iConnector = findPhysicalConnector(icomponent); - // check if the connector belongs to the chosen crate - if(nCrate==1){ - if(ilayer==1){ - if(iConnector==1 || iConnector==2 || iConnector==3 || iConnector==4) isInCrate = true; - }else if(ilayer==2){ - if(iConnector==5 || iConnector==6 || iConnector==7 || iConnector==8) isInCrate = true; - }else if(ilayer==3){ - if(iConnector==5 || iConnector==6 || iConnector==7 || iConnector==8) isInCrate = true; - }else if(ilayer==4){ - if(iConnector==1 || iConnector==2 || iConnector==3 || iConnector==4) isInCrate = true; - } - }else if(nCrate==2){ - if(ilayer==1){ - if(iConnector==5 || iConnector==6 || iConnector==7 || iConnector==8) isInCrate = true; - }else if(ilayer==2){ - if(iConnector==1 || iConnector==2 || iConnector==3 || iConnector==4) isInCrate = true; - }else if(ilayer==3){ - if(iConnector==9 || iConnector==10 || iConnector==11 || iConnector==12) isInCrate = true; - }else if(ilayer==4){ - if(iConnector==9 || iConnector==10 || iConnector==11 || iConnector==12) isInCrate = true; - } - }else if(nCrate==3){ - if(ilayer==1){ - if(iConnector==9 || iConnector==10 || iConnector==11 || iConnector==12) isInCrate = true; - }else if(ilayer==2){ - if(iConnector==9 || iConnector==10 || iConnector==11 || iConnector==12) isInCrate = true; - }else if(ilayer==3){ - if(iConnector==1 || iConnector==2 || iConnector==3 || iConnector==4) isInCrate = true; - }else if(ilayer==4){ - if(iConnector==5 || iConnector==6 || iConnector==7 || iConnector==8) isInCrate = true; - } - }else{ - System.out.println("wrong crate number selected in FTTRKReconstruction"); - } - return isInCrate; -} - -public int findPhysicalConnector(int icomponent){ - // returns the number of the physical connector one strip belongs to - // physical connectors are numbered 1-12 - int iConnector = -1; - if(icomponent>=0 && icomponent <64){ - iConnector = 1; - }else if(icomponent>=64 && icomponent <128){ - iConnector = 2; - }else if(icomponent>=128 && icomponent <192){ - iConnector = 3; - }else if(icomponent>=192 && icomponent <256){ - iConnector = 4; - }else if(icomponent>=384 && icomponent <448){ - iConnector = 5; - }else if(icomponent>=448 && icomponent <512){ - iConnector = 6; - }else if(icomponent>=512 && icomponent <576){ - iConnector = 7; - }else if(icomponent>=576 && icomponent <640){ - iConnector = 8; - }else if(icomponent>=256 && icomponent <320){ - iConnector = 9; - }else if(icomponent>=320 && icomponent <384){ - iConnector = 10; - }else if(icomponent>=640 && icomponent <704){ - iConnector = 11; - }else if(icomponent>=704 && icomponent <768){ - iConnector = 12; - } - return iConnector; -} public int renumberStrip(int ilayer, int icomponent){ // renumber strips from FEE number (to RECO numbering // strips numbering 1-768 int newStripNumber = -1; if(ilayer==1){ - if((icomponent>=1 && icomponent <=128) || (icomponent>=641 && icomponent<=768)){ - newStripNumber = icomponent; - }else if(icomponent>=129 && icomponent<=256){ - newStripNumber = icomponent+256; - }else if(icomponent>=257 && icomponent<=512){ - newStripNumber = icomponent-128; - }else if(icomponent>=513 && icomponent<=640){ - newStripNumber = icomponent; - } + if((icomponent>=1 && icomponent <=128) || (icomponent>=641 && icomponent<=768)){ + newStripNumber = icomponent; + }else if(icomponent>=129 && icomponent<=256){ + newStripNumber = icomponent+256; + }else if(icomponent>=257 && icomponent<=512){ + newStripNumber = icomponent-128; + }else if(icomponent>=513 && icomponent<=640){ + newStripNumber = icomponent; + } }else if(ilayer==2 || ilayer==4 || ilayer==3){ - if(icomponent>=257 && icomponent <=512){ - newStripNumber = icomponent+128; - }else if(icomponent>=513 && icomponent <=640){ - newStripNumber = icomponent-256; - }else{ - newStripNumber = icomponent; - } + if(icomponent>=257 && icomponent <=512){ + newStripNumber = icomponent+128; + }else if(icomponent>=513 && icomponent <=640){ + newStripNumber = icomponent-256; + }else{ + newStripNumber = icomponent; + } } return (newStripNumber); } -public int renumberFEE2RECAndAdjust(int run, int ilayer, int icomponent){ -// apply the renumbering schema - method 2 - if(run>0){ - //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); - icomponent = renumberStrip(ilayer, icomponent); - if(ilayer==1 || ilayer==2 || ilayer==4) icomponent = flipStripVertical(ilayer, icomponent); - if(ilayer==3){ - int isec1 = findSector(icomponent); - if(isec1==11){ - icomponent = swapSectors(icomponent, 10); - }else if(isec1==10){ - icomponent = swapSectors(icomponent, 11); - } - // reverse sectors 10-11 + flip horizontal - int newsec = findSector(icomponent); - if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); - icomponent = flipStripHorizontal(ilayer, icomponent); - } - - } +public int renumberFEE2RECRotatedAndAdjustVanilla(int run, int ilayer, int icomponent){ +// apply strip renumbering only + if(run>10) icomponent = renumberStrip(ilayer, icomponent); return icomponent; } -public int renumberFEE2RECRotatedAndAdjust(int run, int ilayer, int icomponent){ + +public int renumberFEE2RECRotatedAndAdjust_Fall18RGA(int run, int ilayer, int icomponent){ // apply the renumbering schema - method 2 - if(run>0){ - //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); + if(run>0){ icomponent = renumberStrip(ilayer, icomponent); - -// if(ilayer==2) icomponent = flipStripHorizontal(ilayer, icomponent); -// if(ilayer==1) icomponent = overturnModule(ilayer, icomponent); + // overturn layer 1+4 if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); -// if(ilayer==2) icomponent = overturnModule(ilayer, icomponent); - - if(ilayer==3){ - int isec1 = findSector(icomponent); + + int isec1 = -1; + if(ilayer==1){ + isec1 = findSector(icomponent); + if(isec1 == 1){ + icomponent = reverseStripInSecondHalf(icomponent); + }else if(isec1==6){ + icomponent = swapSectors(icomponent, 7); + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==7){ + icomponent = swapSectors(icomponent, 6); + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==13){ + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==14){ + icomponent = reverseStripsInSector(icomponent); + }else if(isec1==18){ + icomponent = reverseStripInFirstHalf(icomponent); + } + + }else if(ilayer==2){ + isec1 = findSector(icomponent); + if(isec1==1){ + icomponent = reverseStripsInSector(icomponent); + if(icomponent>96) icomponent -= 8; + }else if(isec1==3){ + icomponent = reverseStripsInSector(icomponent); + } + + }else if(ilayer==3){ + isec1 = findSector(icomponent); if(isec1==11){ icomponent = swapSectors(icomponent, 10); }else if(isec1==10){ @@ -1607,682 +923,34 @@ public int renumberFEE2RECRotatedAndAdjust(int run, int ilayer, int icomponent){ int newsec = findSector(icomponent); if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); icomponent = flipStripHorizontal(ilayer, icomponent); - } - - - if(ilayer==2){ - int isec1 = findIn12Sectors(icomponent); -// if(isec1 == 1 || isec1==6 || isec1 == 10){ -// icomponent = -1; -// } - } - - -/* - if(isec1 == 6) icomponent = -1; - if(isec1 == 0){ - icomponent = swap12Sectors(icomponent, 11); - }else if(isec1 == 1){ - icomponent = swap12Sectors(icomponent, 10); - }else if(isec1 == 11){ - icomponent = swap12Sectors(icomponent, 0); - }else if(isec1 == 10){ - icomponent = swap12Sectors(icomponent, 1); - } - int newsec = findIn12Sectors(icomponent); - if( newsec==0 || newsec==1 || newsec ==10 || newsec==11) icomponent = reverseStripsIn12Sectors(icomponent); - if(newsec==1 || newsec==10) icomponent = -1; -*/ - //} - - - if(ilayer==1){ - - int isec1 = findIn12Sectors(icomponent); - /* - if(isec1==2){ - icomponent = swap12Sectors(icomponent, 9); -// icomponent = -1; - }else if(isec1==9){ - icomponent = swap12Sectors(icomponent, 2); - }else if(isec1==3){ - icomponent = swap12Sectors(icomponent, 6); - //icomponent = -1; - }else if(isec1==6){ - icomponent = swap12Sectors(icomponent, 3); - } - int newsec = findIn12Sectors(icomponent); - if(newsec == 2 || newsec == 9) icomponent = reverseStripsIn12Sectors(icomponent); - if(newsec==3){ - icomponent = swap12Sectors(icomponent, 2); -// icomponent = -1; - }else if(newsec==2){ - icomponent = swap12Sectors(icomponent, 3); - }else if(newsec==9){ - icomponent = swap12Sectors(icomponent, 6); - } - */ - - // good - - if(isec1==3){ -// icomponent = reverseStripsInSector(icomponent); -// icomponent = swap12Sectors(icomponent, 2); -// icomponent = -1; - }else if(isec1==6){ - icomponent = swap12Sectors(icomponent, 10); - }else if(isec1==8){ - icomponent = swap12Sectors(icomponent, 11); -// icomponent = -1; - }else if(isec1==4){ -// icomponent = -1; -// icomponent = swap12Sectors(icomponent, 6); - }else if(isec1==2){ -// icomponent = reverseStripsIn12Sectors(icomponent); - //icomponent = swap12Sectors(icomponent, 3); - } - - /* - int isec2 = findIn12Sectors(icomponent); - if(isec2==3){ - icomponent = swap12Sectors(icomponent, 6); - icomponent = reverseStripsIn12Sectors(icomponent); - } - */ - -// int newsec1 = findIn12Sectors(icomponent); -// if(newsec1!=2) icomponent = -1; - - - /* - if(isec1==4){ - icomponent = swapSectors(icomponent, 2); - }else if(isec1==5){ - icomponent = swapSectors(icomponent, 3); - }else if(isec1==3){ - icomponent = swapSectors(icomponent, 4); - }else if(isec1==9){ - icomponent = swapSectors(icomponent, 17); - }else if(isec1==17){ - icomponent = swapSectors(icomponent, 9); - } - - int newsec = findSector(icomponent); - if(newsec == 2) icomponent = reverseStripsInSector(icomponent); - */ - /* - if(isec1==10){ - icomponent = swapSectors(icomponent, 2); - }else if(isec1==3){ - icomponent = swapSectors(icomponent, 10); - } - int newsec = findSector(icomponent); - if(newsec == 2) icomponent = reverseStripsInSector(icomponent); - */ - /* - if(isec1==9){ - icomponent = swapSectors(icomponent, 3); - }else if(isec1==8){ - icomponent = swapSectors(icomponent, 4); - }else if(isec1==6){ - icomponent = swapSectors(icomponent, 5); - }else if(isec1==7){ - icomponent = swapSectors(icomponent, 6); - }else if(isec1==5){ - icomponent = swapSectors(icomponent, 7); - }else if(isec1==3){ - icomponent = swapSectors(icomponent, 8); - }else if(isec1==4){ - icomponent = swapSectors(icomponent, 9); - } - int newsec = findSector(icomponent); - if(newsec == 3 || newsec==7 || newsec==4) icomponent = reverseStripsInSector(icomponent); - */ - /* - if(isec1==18){ - icomponent = swapSectors(icomponent, 17); - }else if(isec1==17){ - icomponent = swapSectors(icomponent, 18); - } - */ - // prova Livio l2 - /* - if(isec1==3){ - icomponent = swapSectors(icomponent, 5); - }else if(isec1==4){ - icomponent = swapSectors(icomponent, 6); - }else if(isec1==5){ - icomponent = swapSectors(icomponent, 7); - }else if(isec1==6){ - icomponent = swapSectors(icomponent, 11); - }else if(isec1==7){ - icomponent = swapSectors(icomponent, 10); - }else if(isec1==8){ - icomponent = swapSectors(icomponent, 3); - }else if(isec1==9){ - icomponent = swapSectors(icomponent, 4); - }else if(isec1==10){ - icomponent = swapSectors(icomponent, 9); - }else if(isec1==11){ - icomponent = swapSectors(icomponent, 8); - } - int newsec = findSector(icomponent); - if( newsec==2 || newsec==9) icomponent = reverseStripsInSector(icomponent); - */ - /* - if(isec1==5){ - icomponent = swapSectors(icomponent, 9); - }else if(isec1==4){ - icomponent = swapSectors(icomponent, 8); - }else if(isec1==3){ - icomponent = swapSectors(icomponent, 7); - }else if(isec1==2){ - icomponent = swapSectors(icomponent, 6); - }else if(isec1==7){ - icomponent = reverseStripsInSector(icomponent); - icomponent = swapSectors(icomponent, 4); - }else if(isec1==8){ - icomponent = reverseStripsInSector(icomponent); - icomponent = swapSectors(icomponent, 3); - }else if(isec1==9){ - icomponent = reverseStripsInSector(icomponent); - icomponent = swapSectors(icomponent, 2); - } - */ - /* - if(isec1==5){ - icomponent = reverseStripsInSector(icomponent); - icomponent = swapSectors(icomponent, 7); - }else if(isec1==4){ - icomponent = swapSectors(icomponent, 8); - }else if(isec1==10){ - icomponent = swapSectors(icomponent, 9); - }else if(isec1==3){ - icomponent = swapSectors(icomponent, 10); - }else if(isec1==7){ - icomponent = reverseStripsInSector(icomponent); - icomponent = swapSectors(icomponent, 5); - }else if(isec1==8){ - icomponent = reverseStripsInSector(icomponent); - icomponent = swapSectors(icomponent, 4); - }else if(isec1==9){ - icomponent = reverseStripsInSector(icomponent); - icomponent = swapSectors(icomponent, 3); - }else if(isec1==5){ - icomponent = reverseStripsInSector(icomponent); - icomponent = swapSectors(icomponent, 7); - } - */ - - } - } - - return icomponent; -} - - -public int renumberFEE2RECRotatedAndAdjustVanilla(int run, int ilayer, int icomponent){ -// apply the renumbering schema - method 2 - if(run>0){ - //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); - icomponent = renumberStrip(ilayer, icomponent); - - /* - if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); - if(ilayer==3){ - int isec1 = findSector(icomponent); - if(isec1==11){ - icomponent = swapSectors(icomponent, 10); - }else if(isec1==10){ - icomponent = swapSectors(icomponent, 11); - } - // reverse sectors 10-11 + flip horizontal - int newsec = findSector(icomponent); - if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); - icomponent = flipStripHorizontal(ilayer, icomponent); - } - */ - } - - return icomponent; -} - - -public int renumberFEE2RECRotatedAndAdjustHazel(int run, int ilayer, int icomponent){ -// apply the renumbering schema - method 2 - if(run>0){ - //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); - icomponent = renumberStrip(ilayer, icomponent); - - if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); - if(ilayer==3){ - int isec1 = findSector(icomponent); - if(isec1==11){ - icomponent = swapSectors(icomponent, 10); - }else if(isec1==10){ - icomponent = swapSectors(icomponent, 11); - } - // reverse sectors 10-11 + flip horizontal - int newsec = findSector(icomponent); - if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); - icomponent = flipStripHorizontal(ilayer, icomponent); - } - - if(ilayer==2){ - int isec1 = findIn12Sectors(icomponent); -// if(isec1 == 1 || isec1==6 || isec1 == 10) icomponent = -1; -// if(isec1 != 10){icomponent = -1;} - } - - - if(ilayer==1){ - int isec1 = findIn12Sectors(icomponent); - - // good - /* - if(isec1==3){ -// icomponent = reverseStripsInSector(icomponent); -// icomponent = swap12Sectors(icomponent, 2); -// icomponent = -1; - }else if(isec1==6){ - icomponent = swap12Sectors(icomponent, 10); - }else if(isec1==8){ - icomponent = swap12Sectors(icomponent, 11); -// icomponent = -1; - }else if(isec1==4){ -// icomponent = -1; -// icomponent = swap12Sectors(icomponent, 6); - }else if(isec1==2){ -// icomponent = reverseStripsIn12Sectors(icomponent); - //icomponent = swap12Sectors(icomponent, 3); - } - */ - //if(isec1 != 10 && isec1 != 11) icomponent = -1; -/// if(isec1 != 4) icomponent = -1; - } - - if(ilayer==3){ -// int isec1 = findIn12Sectors(icomponent); - int isec1 = findIn12Sectors(icomponent); -// if(isec1 == 1 || isec1==6 || isec1 == 10) icomponent = -1; -/// if(isec1 != 8) icomponent = -1; - } - - } - - return icomponent; -} - -public int renumberFEE2RECRotatedAndAdjustWalnut2(int run, int ilayer, int icomponent){ -// apply the renumbering schema - method 2 - if(run>0){ - //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); - icomponent = renumberStrip(ilayer, icomponent); - - if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); - if(ilayer==3){ - int isec1 = findSector(icomponent); - if(isec1==11){ - icomponent = swapSectors(icomponent, 10); - }else if(isec1==10){ - icomponent = swapSectors(icomponent, 11); - } - // reverse sectors 10-11 + flip horizontal - int newsec = findSector(icomponent); - if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); - icomponent = flipStripHorizontal(ilayer, icomponent); - } - - if(ilayer==1){ - int isec1 = findSector(icomponent); - if(isec1==18){ - if(icomponent > 672) icomponent = 1377-icomponent; - }else if(isec1==7){ - icomponent = swapSectors(icomponent, 6); - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==6){ - icomponent = swapSectors(icomponent, 7); - } - } - - if(ilayer==2){ - int isec1 = findSector(icomponent); - if(isec1==10){ - icomponent = swapSectors(icomponent, 11); - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==11){ - icomponent = swapSectors(icomponent, 10); - icomponent = reverseStripsInSector(icomponent); - } - } - - - if(ilayer==4){ - int isec1 = findSector(icomponent); - if(isec1==18){ - if(icomponent>= 673){ - icomponent -= 32; - }else{ - icomponent += 31; - } - } - } - - - if(ilayer==3){ - int isec1 = findSector(icomponent); - if(isec1==15){ - icomponent = swapSectors(icomponent, 13); - }else if(isec1==13){ - icomponent = swapSectors(icomponent, 15); - } - } - } - - return icomponent; -} - -public int maskFaultySectors(int ilay, int isec){ - int isMasked = 1; - // bad sectors, need masking - if( -// (ilay==2 && (isec==12 || isec==13) ) || -// (ilay==3 && (isec==7 ) ) || - isec<0 ) - isMasked = 0; - return isMasked; -} - - -public int renumberFEE2RECRotatedAndAdjustWalnut4(int run, int ilayer, int icomponent){ -// apply the renumbering schema - method 2 - if(run>0){ - //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); - icomponent = renumberStrip(ilayer, icomponent); - - if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); - if(ilayer==3){ - int isec1 = findSector(icomponent); - if(isec1==11){ - icomponent = swapSectors(icomponent, 10); - }else if(isec1==10){ - icomponent = swapSectors(icomponent, 11); - } - // reverse sectors 10-11 + flip horizontal - int newsec = findSector(icomponent); - if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); - icomponent = flipStripHorizontal(ilayer, icomponent); - } - - int isec1 = -1; - if(ilayer==1){ isec1 = findSector(icomponent); - if(isec1==18){ - if(icomponent > 672){ - icomponent = 1377-icomponent; - }else{ - icomponent = 1312-icomponent; - } - }else if(isec1==7){ - icomponent = swapSectors(icomponent, 6); - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==6){ - icomponent = swapSectors(icomponent, 7); - }else if(isec1==13){ - icomponent = reverseStripsInSector(icomponent); - }else if(isec1 == 1){ - if(icomponent >= 128){ - icomponent = 224 - icomponent; - } - } - } - - if(ilayer==2){ - isec1 = findSector(icomponent); - if(isec1==10){ - icomponent = swapSectors(icomponent, 11); - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==11){ - icomponent = swapSectors(icomponent, 10); - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==1){ - icomponent = reverseStripsInSector(icomponent); - } - } - - - if(ilayer==4){ - isec1 = findSector(icomponent); - if(isec1==18){ - //icomponent = reverseStripsInSector(icomponent); - if(icomponent>= 673){ - icomponent -= 32; - }else{ - icomponent += 31; - } - }else if(isec1 == 5){ - icomponent = reverseStripsInSector(icomponent); - }else if(isec1 == 13){ - //icomponent = reverseStripsInSector(icomponent); - }else if(isec1 == 1){ - if(icomponent >= 128){ - icomponent = 224 - icomponent; - } - } - } - - if(ilayer==3){ - isec1 = findSector(icomponent); - if(isec1==15){ - //icomponent = swapSectors(icomponent, 13); - // icomponent = swapSectors(icomponent, 15); + if(isec1==8){ + icomponent = reverseStripsInSector(icomponent); }else if(isec1==14){ icomponent = swapSectors(icomponent, 15); icomponent = reverseStripsInSector(icomponent); - }else if(isec1==8){ - icomponent = reverseStripsInSector(icomponent); - } - } - isec1 = findSector(icomponent); // rehash - //icomponent = flipStripHorizontal(ilayer, icomponent); - - if(maskFaultySectors(ilayer, isec1) == 0) icomponent = -1; - } - return icomponent; -} - - -public int renumberFEE2RECRotatedAndAdjustWalnut(int run, int ilayer, int icomponent){ -// apply the renumbering schema - method 2 - if(run>0){ - //System.out.println("icomponent in bank " + icomponent + " ilayer " + ilayer); - icomponent = renumberStrip(ilayer, icomponent); - - if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); - - int isec1 = -1; - if(ilayer==1){ - isec1 = findSector(icomponent); - if(isec1==18){ - icomponent = reverseStripInFirstHalf(icomponent); - //icomponent = reverseStripInSecondHalf(icomponent); - }else if(isec1==7){ - icomponent = swapSectors(icomponent, 6); - icomponent = reverseStripsInSector(icomponent); //ok - }else if(isec1==6){ - //icomponent = swapSectors(icomponent, 8); - icomponent = swapSectors(icomponent, 7); - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==8){ - //icomponent = swapSectors(icomponent, 7); - }else if(isec1==13){ - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==14){ - icomponent = reverseStripsInSector(icomponent); - }else if(isec1 == 1){ - ///if(icomponent >= 96){ - /// icomponent = 224 - icomponent; - ///}//else{ - // icomponent = 160 - icomponent; - //} - icomponent = reverseStripInSecondHalf(icomponent); - } - //if(isec1==18){ - // icomponent = swapSectors(icomponent, 19); - //icomponent = reverseStripsInSector(icomponent); - //if(icomponent>672){ - // icomponent -= 32; - //}else{ - // icomponent += 32; - //} - //}else if(isec1==19){ - // icomponent = swapSectors(icomponent, 18); - //} - } - - if(ilayer==2){ - isec1 = findSector(icomponent); - if(isec1==10){ - //icomponent = swapSectors(icomponent, 11); - //icomponent = reverseStripsInSector(icomponent); - }else if(isec1==11){ - //icomponent = swapSectors(icomponent, 10); - //icomponent = reverseStripsInSector(icomponent); - }else if(isec1==1){ - icomponent = reverseStripsInSector(icomponent); - //if(icomponent<=96) icomponent += 32; - //icomponent = reverseStripInSecondHalf(icomponent); - if(icomponent>96) icomponent -= 8; - }else if(isec1==3){ - icomponent = reverseStripsInSector(icomponent); - //if(icomponent<=96) icomponent += 32; - //icomponent = reverseStripInSecondHalf(icomponent); - }else if(isec1==18){ - //icomponent = switchStripOff(); - //if(icomponent > 672) icomponent = swapSectors(icomponent, 19); - ///if(icomponent>= 673){ - /// icomponent -= 32; - ///}else{ - /// icomponent += 31; - ///} - //if(icomponent > 672){ - // icomponent = 1377-icomponent; - //}else{ - // icomponent = 1312-icomponent; - //} - // icomponent = reverseStripsInSector(icomponent); - }else if(isec1==19){ - //icomponent = switchStripOff(); - //if(icomponent <= 736) icomponent -= 32; - }else if(isec1==0){ - //icomponent = swapSectors(icomponent, 1); - //if(icomponent > 48 && icomponent <= 64) icomponent += 16; - //if(icomponent > 32) icomponent = -1; - //icomponent = reverseStripInSecondHalf(icomponent); - }else if(isec1==12){ // strip 476 only is fired - //icomponent += 16; - } - } - - - if(ilayer==3){ - isec1 = findSector(icomponent); - if(isec1==11){ - icomponent = swapSectors(icomponent, 10); - }else if(isec1==10){ - icomponent = swapSectors(icomponent, 11); - } - // reverse sectors 10-11 + flip horizontal - int newsec = findSector(icomponent); - if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); - icomponent = flipStripHorizontal(ilayer, icomponent); - - isec1 = findSector(icomponent); -// if(isec1 == 1 || isec1==6 || isec1 == 10) icomponent = -1; -/// if(isec1 != 8) icomponent = -1; - if(isec1==15){ - //icomponent = swapSectors(icomponent, 13); - // icomponent = swapSectors(icomponent, 15); + }else if(isec1==15){ icomponent = swapSectors(icomponent, 14); icomponent = reverseStripsInSector(icomponent); - }else if(isec1==14){ - icomponent = swapSectors(icomponent, 15); - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==7){ - //icomponent = swapSectors(icomponent, 8); - //icomponent = reverseStripsInSector(icomponent); - }else if(isec1==8){ - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==0){ //swap half of sector 0 - //if(icomponent>=33){ - // icomponent -= 32; - //}else{ - // icomponent += 31; - //}else if(isec1==18){ - // if(icomponent < 673) icomponent = swapSectors(icomponent, 17); - //}else if(isec1==17){ - // icomponent = swapSectors(icomponent, 18); - }else if(isec1==2){ - // icomponent = swapSectors(icomponent, 3); - //}else if(isec1==3){ - // icomponent = swapSectors(icomponent, 2); - }else if(isec1==10){ - //icomponent = swapSectors(icomponent, 9); - }else if(isec1==11){ - //icomponent = switchStripOff(); - //icomponent = swapSectors(icomponent, 9); } - /* - isec1 = findSector(icomponent); // rehash - if(isec1==13){ - icomponent = swapSectors(icomponent, 15); - } - */ - } - if(ilayer==4){ + }else if(ilayer==4){ isec1 = findSector(icomponent); - if(isec1==18){ - ////icomponent = reverseStripsInSector(icomponent); - //if(icomponent>= 673){ // qui sembra che faccia swap tra prima e seconda meta' - // icomponent -= 32; - //}else{ - // icomponent += 31; - //} - icomponent = swapHalves(icomponent); + if(isec1 == 1){ icomponent = reverseStripInSecondHalf(icomponent); - }else if(isec1 == 15){ - //component = swapSectors(icomponent, 14); - //icomponent = reverseStripsInSector(icomponent); }else if(isec1 == 5){ icomponent = reverseStripsInSector(icomponent); - }else if(isec1 == 13){ - //icomponent = reverseStripsInSector(icomponent); - }else if(isec1 == 1){ - icomponent = reverseStripInSecondHalf(icomponent); }else if(isec1 == 6){ icomponent = reverseStripsInSector(icomponent); + }else if(isec1==18){ + icomponent = swapHalves(icomponent); + icomponent = reverseStripInSecondHalf(icomponent); } } - isec1 = findSector(icomponent); // rehash - //icomponent = flipStripHorizontal(ilayer, icomponent); - - //if(maskFaultySectors(ilayer, isec1) == 0) icomponent = -1; - /* - // select bad crosses rejecting all other strips - int newsec = findSector(icomponent); - if(ilayer==1){ - if(newsec != 3) icomponent = -1; - }else if(ilayer==2){ - if(newsec != 14); icomponent = -1; - }else{ - icomponent = -1; - } - */ } return icomponent; From 9d35f07c160e8909b5624c1584b4432450c4974f Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Fri, 11 Feb 2022 13:02:22 +0100 Subject: [PATCH 064/104] cleanup --- .../jlab/rec/ft/cal/FTCALReconstruction.java | 98 ++++++------------- 1 file changed, 32 insertions(+), 66 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java index a5cb78945f..1184a99dea 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java @@ -268,72 +268,38 @@ public List readRawHitsHipo(DataEvent event, IndexedTable charge2Energ float time = bankDGTZ.getFloat("time",row); if(adc!=-1 && time!=-1){ FTCALHit hit = new FTCALHit(row,icomponent, adc, time, charge2Energy, timeOffsets, timeWalk, cluster); -// if(icomponent>=90 && icomponent<=98) hits.add(hit); // select only crystals in a given region -// if(icomponent>= 69 && icomponent<=84) -// vertical strip of crystals, right side -/* - if(icomponent == 61 || icomponent == 83 || icomponent == 105 || icomponent == 127 || - icomponent == 149 || icomponent == 193 || icomponent == 215 || icomponent == 237 || - icomponent == 259 || icomponent == 281 || icomponent == 303 || icomponent == 325 || - icomponent == 347 || icomponent == 369 || icomponent == 391 || icomponent == 413 || icomponent == 435) -*/ -// vertical strip of crystals, left side -/* - if(icomponent == 27 || icomponent == 49 || icomponent == 71 || icomponent == 93 || - icomponent == 115 || icomponent == 137 || icomponent == 159 || icomponent == 181 || - icomponent == 203 || icomponent == 225 || icomponent == 247 || icomponent == 269 || - icomponent == 291 || icomponent == 313 || icomponent == 335 || icomponent == 357 || - icomponent == 379 || icomponent == 401 || icomponent == 423 || icomponent == 445 ) -*/ -// vertical strip of crystals, left side central -/* - if(icomponent == 10 || icomponent == 32 || icomponent == 54 || icomponent == 76 || - icomponent == 98 || icomponent == 120 || icomponent == 142 || icomponent == 340 || - icomponent == 362 || icomponent == 384 || icomponent == 406 || icomponent == 428 || - icomponent == 450 || icomponent == 472 ) - */ -// vertical strip of crystals, right side central -/* - if(icomponent == 11 || icomponent == 33 || icomponent == 55 || icomponent == 77 || - icomponent == 99 || icomponent == 121 || icomponent == 143 || icomponent == 341 || - icomponent == 363 || icomponent == 385 || icomponent == 407 || icomponent == 429 || - icomponent == 451 || icomponent == 473 ) -*/ -// top half -// if(icomponent >= 242) -// bottom half - // if(icomponent <= 241) - -// if(icomponent == 92) -// if(icomponent == 105) -// if(icomponent == 400) -// if(icomponent == 412) -// select one vertical stip of crystals left of the hole -// if(icomponent == 472 || icomponent == 450 || icomponent == 428 || icomponent == 406 || icomponent == 384 || -// icomponent == 362 || icomponent == 340) -// select one vertical strip of crystals right of the hole -// if(icomponent == 473 || icomponent == 451 || icomponent == 429 || icomponent == 407 || icomponent == 385 || -// icomponent == 363 || icomponent == 341) -// if(icomponent == 454 || icomponent == 432 || icomponent == 410 || icomponent == 388 || icomponent == 366 || -// icomponent == 344 || icomponent == 322 || icomponent == 300) -// if(icomponent == 402 || icomponent == 401 || icomponent == 400 || icomponent == 380 || icomponent == 379 || -// icomponent == 378 || icomponent == 358 || icomponent == 357 || icomponent == 356) -// if(icomponent == 381 || icomponent == 380 || icomponent == 379 || icomponent == 359 || icomponent == 358 || -// icomponent == 357 || icomponent == 337 || icomponent == 336 || icomponent == 335) -// if(icomponent == 340 || icomponent == 339 || icomponent == 316 || icomponent == 293 || icomponent == 270 || -// icomponent == 248) -// if(icomponent == 341 || icomponent == 342 || icomponent == 321 || icomponent == 300 || icomponent == 279 || -// icomponent == 257) -// if(icomponent == 226 || icomponent == 204 || icomponent == 183 || icomponent == 162 || icomponent == 141 || -// icomponent == 142) -// if(icomponent == 235 || icomponent == 213 || icomponent == 190 || icomponent == 167 || icomponent == 144 || -// icomponent == 143) -// if(icomponent == 241 || icomponent == 218 || icomponent == 195 || icomponent == 172 || icomponent == 149 || -// icomponent == 126 || icomponent == 103 || icomponent == 80 || icomponent == 57 || icomponent == 34 || -// icomponent == 11) -// if(icomponent >=341 && icomponent<=350) - // if(icomponent==347) - hits.add(hit); + + //////////////////////////////////////////////////////////////////////////////////////////////////// + // select here single/groups of crystals for debugging purposes + // examples: + /// if(icomponent>=90 && icomponent<=98) hits.add(hit); // select only crystals in a given region + // vertical strip of crystals, right side + /// if(icomponent == 61 || icomponent == 83 || icomponent == 105 || icomponent == 127 || + /// icomponent == 149 || icomponent == 193 || icomponent == 215 || icomponent == 237 || + /// icomponent == 259 || icomponent == 281 || icomponent == 303 || icomponent == 325 || + /// icomponent == 347 || icomponent == 369 || icomponent == 391 || icomponent == 413 || icomponent == 435) + // vertical strip of crystals, left side + ///if(icomponent == 27 || icomponent == 49 || icomponent == 71 || icomponent == 93 || + /// icomponent == 115 || icomponent == 137 || icomponent == 159 || icomponent == 181 || + /// icomponent == 203 || icomponent == 225 || icomponent == 247 || icomponent == 269 || + /// icomponent == 291 || icomponent == 313 || icomponent == 335 || icomponent == 357 || + /// icomponent == 379 || icomponent == 401 || icomponent == 423 || icomponent == 445 ) + // vertical strip of crystals, left side central + ///if(icomponent == 10 || icomponent == 32 || icomponent == 54 || icomponent == 76 || + /// icomponent == 98 || icomponent == 120 || icomponent == 142 || icomponent == 340 || + /// icomponent == 362 || icomponent == 384 || icomponent == 406 || icomponent == 428 || + /// icomponent == 450 || icomponent == 472 ) + // vertical strip of crystals, right side central + ///if(icomponent == 11 || icomponent == 33 || icomponent == 55 || icomponent == 77 || + /// icomponent == 99 || icomponent == 121 || icomponent == 143 || icomponent == 341 || + /// icomponent == 363 || icomponent == 385 || icomponent == 407 || icomponent == 429 || + /// icomponent == 451 || icomponent == 473 ) + // top half + /// if(icomponent >= 242) + // bottom half + /// if(icomponent <= 241) + + hits.add(hit); } } } From 10fcda8b4940cb14f355a81d09cfd22c7f6974cf Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Fri, 11 Feb 2022 15:07:55 +0100 Subject: [PATCH 065/104] cleanup --- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 472 ++++++------------ .../java/org/jlab/rec/ft/FTEventBuilder.java | 89 +--- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 50 +- 3 files changed, 198 insertions(+), 413 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index aed28485af..d89ce9b66a 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -43,6 +43,39 @@ public class FTEBEngine extends ReconstructionEngine { FTEventBuilder reco; int Run = -1; double Solenoid; + + public static boolean timeEnergyDiagnosticHistograms = false; + + public static H1F h500 = new H1F("Time Difference FTCAL-response", 100, 0., 200.); + public static H1F h501 = new H1F("Cross Energy TRK0", 100, 0., 2000.); + public static H1F h502 = new H1F("Cross Energy TRK1", 100, 0., 2000.); + public static H1F h503 = new H1F("Cross time TRK0", 100, 0.0, 500.); + public static H1F h504 = new H1F("Cross time TRK1", 100, 0.0, 500.); + public static H2F h505 = new H2F("Cross energy vs time TRK0", 100, 0.0, 500., 100, 0., 2000.); + public static H2F h506 = new H2F("Cross energy vs time TRK1", 100, 0.0, 500., 100, 0., 2000.); + public static H2F h507 = new H2F("Cross energy vs time TRK0+1", 100, 0.0, 500., 100, 0., 2000.); + public static H2F h510 = new H2F("Clusters total energies TRK0", 100, 0., 2000., 100, 0., 2000.); + public static H2F h511 = new H2F("Clusters total energies TRK1", 100, 0., 2000., 100, 0., 2000.); + public static H1F h512 = new H1F("Clusters total energies TRK0", 100, 0., 2000.); + public static H1F h513 = new H1F("Clusters total energies TRK1", 100, 0., 2000.); + public static H1F h520 = new H1F("Time of strips in cluster1 TRK0", 100, 0., 500.); + public static H1F h521 = new H1F("Time of strips in cluster2 TRK0", 100, 0., 500.); + public static H1F h522 = new H1F("time of strips in cluster1 TRK1", 100, 0., 500.); + public static H1F h523 = new H1F("Time of strips in cluster2 TRK1", 100, 0., 500.); + + public static H1F h600 = new H1F("TRK response position", 100, 5.93, 6.03); + public static H2F h601 = new H2F("TRK tof vs time", 100, 0., 500., 100, 5.93, 6.03); + public static H1F h602 = new H1F("cross0 time", 100, 0.0001, 500.); + public static H1F h603 = new H1F("cross1 time", 100, 0.0001, 500.); + + public static H2F hSecDet0 = new H2F("lay 2 vs lay1 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); + public static H2F hSecDet1 = new H2F("lay 4 vs lay3 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); + public static H2F hSeedDet0 = new H2F("lay 2 vs lay1 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); + public static H2F hSeedDet1 = new H2F("lay 4 vs lay3 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); + + public static Point3D ORIGIN = new Point3D(0., 0., 0.); + + public FTEBEngine() { super("FTEB", "devita", "3.0"); @@ -142,35 +175,6 @@ public int getDebugMode() { return this.reco.debugMode; } - public static H1F h500 = new H1F("Time Difference FTCAL-response", 100, 0., 200.); - public static H1F h501 = new H1F("Cross Energy TRK0", 100, 0., 2000.); - public static H1F h502 = new H1F("Cross Energy TRK1", 100, 0., 2000.); - public static H1F h503 = new H1F("Cross time TRK0", 100, 0.0, 500.); - public static H1F h504 = new H1F("Cross time TRK1", 100, 0.0, 500.); - public static H2F h505 = new H2F("Cross energy vs time TRK0", 100, 0.0, 500., 100, 0., 2000.); - public static H2F h506 = new H2F("Cross energy vs time TRK1", 100, 0.0, 500., 100, 0., 2000.); - public static H2F h507 = new H2F("Cross energy vs time TRK0+1", 100, 0.0, 500., 100, 0., 2000.); - public static H2F h510 = new H2F("Clusters total energies TRK0", 100, 0., 2000., 100, 0., 2000.); - public static H2F h511 = new H2F("Clusters total energies TRK1", 100, 0., 2000., 100, 0., 2000.); - public static H1F h512 = new H1F("Clusters total energies TRK0", 100, 0., 2000.); - public static H1F h513 = new H1F("Clusters total energies TRK1", 100, 0., 2000.); - public static H1F h520 = new H1F("Time of strips in cluster1 TRK0", 100, 0., 500.); - public static H1F h521 = new H1F("Time of strips in cluster2 TRK0", 100, 0., 500.); - public static H1F h522 = new H1F("time of strips in cluster1 TRK1", 100, 0., 500.); - public static H1F h523 = new H1F("Time of strips in cluster2 TRK1", 100, 0., 500.); - - public static H1F h600 = new H1F("TRK response position", 100, 5.93, 6.03); - public static H2F h601 = new H2F("TRK tof vs time", 100, 0., 500., 100, 5.93, 6.03); - public static H1F h602 = new H1F("cross0 time", 100, 0.0001, 500.); - public static H1F h603 = new H1F("cross1 time", 100, 0.0001, 500.); - - public static H2F hSecDet0 = new H2F("lay 2 vs lay1 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); - public static H2F hSecDet1 = new H2F("lay 4 vs lay3 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); - public static H2F hSeedDet0 = new H2F("lay 2 vs lay1 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); - public static H2F hSeedDet1 = new H2F("lay 4 vs lay3 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); - - public static Point3D ORIGIN = new Point3D(0., 0., 0.); - public static void main(String arg[]){ @@ -183,25 +187,7 @@ public static void main(String arg[]){ FTEBEngine en = new FTEBEngine(); en.init(); int debugMode = en.getDebugMode(); -// String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/elec_nofield_header.evio"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30_fullAcceptance.hipo"; -/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_singleEle_withFields_big_-30.60.120.30_newbanks.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_test_1000.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_dis.hipo"; -////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; -////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418.0.hipo"; // dontuse String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; -/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/ft_005038_01231_newbanks.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/data_merge.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_154824_det0.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_153947_det1.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_160427_det1.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/twoHits_10239.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_10730.hipo"; -// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; -/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance_newbanks.hipo"; HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -237,7 +223,7 @@ public static void main(String arg[]){ H2F h10 = new H2F("Cluster Energy", 100, -180., 180., 100, -0.5, 0.5); h10.setTitleX("#phi"); h10.setTitleY("Energy Resolution(GeV)"); - + // residual plots (of TRK wrt tracking on ECAL - black histograms) H2F h100 = new H2F("Cross on trk layer1", 100, -18., 18., 100, -18., 18.); h100.setTitleX("x (mm) trk1"); @@ -321,9 +307,7 @@ public static void main(String arg[]){ resTrkPhidet1.setOptStat(10); resTrkPhidet1.setTitleX("trk0 phi residual (rad) wrt line thru trk1"); resTrkPhidet1.setFillColor(49); - -// H1F h202 = new H1F("trk1 x", 25, 9., 9.4); -// H1F h1202 = new H1F("trk1 x MC", 25, 9., 9.4); + H1F h202 = new H1F("trk1 x", 25, 8.2, 9.0); H1F h1202 = new H1F("trk1 x MC", 25, 8.2, 9.0); h202.setOptStat(0); @@ -333,8 +317,6 @@ public static void main(String arg[]){ h202.setFillColor(3); h1202.setLineColor(9); h1202.setFillColor(49); -// H1F h203 = new H1F("trk2 x", 25, 9., 9.4); -// H1F h1203 = new H1F("trk2 MC", 25, 9., 9.4); H1F h203 = new H1F("trk2 x", 25, 8.2, 9.0); H1F h1203 = new H1F("trk2 MC", 25, 8.2, 9.0); h203.setOptStat(0); @@ -344,8 +326,6 @@ public static void main(String arg[]){ h203.setFillColor(3); h1203.setLineColor(9); h1203.setFillColor(49); -// H1F h204 = new H1F("trk1 y", 25, 1.4, 1.8); -// H1F h1204 = new H1F("trk1 y MC", 25, 1.4, 1.8); H1F h204 = new H1F("trk1 y", 25, 2.4, 4.0); H1F h1204 = new H1F("trk1 y MC", 25, 2.4, 4.0); h204.setOptStat(0); @@ -355,8 +335,6 @@ public static void main(String arg[]){ h204.setFillColor(3); h1204.setLineColor(9); h1204.setFillColor(49); -// H1F h205 = new H1F("trk2 y", 25, 1.4, 1.8); -// H1F h1205 = new H1F("trk2 y MC", 25, 1.4, 1.8); H1F h205 = new H1F("trk2 y", 25, 2.4, 4.0); H1F h1205 = new H1F("trk2 y MC", 25, 2.4, 4.0); h205.setOptStat(0); @@ -487,15 +465,14 @@ public static void main(String arg[]){ }else{ continue; } - // bankEvt is used to extract the event with groovy - if(debugMode>=1) System.out.println("////////////// event read " + bankEvt + " - sequential number " + nev); - //if(nev > 10239) System.exit(0); if(nev != 10239) continue; + // bankEvt is the number used to extract the event with groovy + if(debugMode>0) System.out.println("////////////// event read " + bankEvt + " - sequential number " + nev); + //if(nev > 10239) System.exit(0); if(nev != 10239) continue; // stop at a given evt number cal.processDataEvent(event); hodo.processDataEvent(event); trk.processDataEventAndGetClusters(event); en.processDataEvent(event); - if(!event.hasBank("FTCAL::hits")) continue; //////////////////////////////////////////// - + if(!event.hasBank("FTCAL::hits")) continue; if (event instanceof EvioDataEvent) { GenericKinematicFitter fitter = new GenericKinematicFitter(11); PhysicsEvent gen = fitter.getGeneratedEvent((EvioDataEvent) event); @@ -517,7 +494,6 @@ public static void main(String arg[]){ } else { DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); PhysicsEvent gen = detectorEvent.getGeneratedEvent(); -// nev++; if (event.hasBank("FT::particles")) { DataBank bank = event.getBank("FT::particles"); int nrows = bank.rows(); @@ -545,7 +521,6 @@ public static void main(String arg[]){ int trk0ID = bank.getShort("trk0ID", i); // it should correspond to the number of the cross in the banks int trk1ID = bank.getShort("trk1ID", i); if(trk0ID >= 0 || trk1ID >= 0){ // at least one cross is present on one TRK det - // loop on crosses bank DataBank banktrk = event.getBank("FTTRK::crosses"); int ncrosses = banktrk.rows(); @@ -558,26 +533,21 @@ public static void main(String arg[]){ if(trk1ID == crossID && det==1) matchedCrosses++; } - -// if(matchedCrosses != 1){ -// if(matchedCrosses != 2){ - if(matchedCrosses == 0){ // accept all crosses +// if(matchedCrosses != 1){ +// if(matchedCrosses != 2){ + if(matchedCrosses < FTConstants.TRK_MIN_CROSS_NUMBER){ // at least TRK_MIN_CROSS_NUMBER per event continue; }else{ ncrosses2++; - if(ncrosses< 100) System.out.println("++++++++++++++++++++++++++ Sequential number " + nev); + if(ncrosses<100 && debugMode>0) System.out.println("++++++++++++++++++++++++++ Sequential number " + nev); } for(int nc = 0; nc < ncrosses; nc++){ int crossID = banktrk.getInt("id", nc); if(crossID != trk0ID && crossID != trk1ID) continue; int det = banktrk.getInt("detector", nc); -// if(det != 0) continue; - //int crossID = banktrk.getInt("id", nc); - System.out.println("trk0ID " + trk0ID + " trk1ID " + trk1ID + + if(debugMode>0) System.out.println("trk0ID " + trk0ID + " trk1ID " + trk1ID + " crossID " + crossID); -// if(ncrosses<2) continue; -// if(crossID != trk0ID || crossID != trk1ID) continue; // keep only 2nd detector if(det>=0){ float xt = banktrk.getFloat("x", nc); @@ -585,9 +555,6 @@ public static void main(String arg[]){ float zt = banktrk.getFloat("z", nc); Vector3D hitOnTrk = new Vector3D(xt, yt, zt); // extract information on the crossed strips - -// float icl1 = banktrk.getFloat("energy", nc); // Cluster1ID provisional to be changed -// float icl2 = banktrk.getFloat("time", nc); // cluster2ID provisional to be changes float icl1 = banktrk.getShort("Cluster1ID", nc); float icl2 = banktrk.getShort("Cluster2ID", nc); DataBank bankcl = event.getBank("FTTRK::clusters"); @@ -610,7 +577,7 @@ public static void main(String arg[]){ seed2 = bankcl.getInt("seed", (int)icl2ok); int cent1 = (int)bankcl.getFloat("centroid", icl1ok); int cent2 = (int)bankcl.getFloat("centroid", icl2ok); - // if the cluster is formed by > 3 strips take the centroid + // if the cluster is formed by >= 3 strips take the centroid int clustsize1 = bankcl.getShort("size", icl1ok); int clustsize2 = bankcl.getShort("size", icl2ok); if(clustsize1>=3){ @@ -621,19 +588,17 @@ public static void main(String arg[]){ int sector = FTTRKReconstruction.findSector(seed2); if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed2 = cent2; } - // if seed and centroid dont coincide, take the geometric centroid as seed - //if(cent1 != seed1) seed1 = cent1; - //if(cent2 != seed2) seed2 = cent2; int lay1 = bankcl.getInt("layer", (int)icl1ok); int lay2 = bankcl.getInt("layer", (int)icl2ok); - System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ seed1, seed2 " + seed1 + " " + seed2 + " layer1 layer2 " + lay1 + " " + lay2); - System.out.println("~~~~~~~~~~ hit strip 1: " + seed1 + " layer " + lay1 + " sector " + + if(debugMode>0){ + System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ seed1, seed2 " + + seed1 + " " + seed2 + " layer1 layer2 " + lay1 + " " + lay2); + System.out.println("~~~~~~~~~~ hit strip 1: " + seed1 + " layer " + lay1 + " sector " + FTTRKReconstruction.findSector(seed1)); - System.out.println("~~~~~~~~~~ hit strip 2: " + seed2 + " layer " + lay2 + " sector " + + System.out.println("~~~~~~~~~~ hit strip 2: " + seed2 + " layer " + lay2 + " sector " + FTTRKReconstruction.findSector(seed2)); - + } if(seed1!=0 && seed2!=0){ - System.out.println("seed2" + seed2); Line3D seg1 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay1, seed1); Line3D seg2 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay2, seed2); segment1.setOrigin(seg1.origin().x(), seg1.origin().y()); @@ -641,29 +606,18 @@ public static void main(String arg[]){ segment1.setEnd(seg1.end().x(), seg1.end().y()); segment2.setEnd(seg2.end().x(), seg2.end().y()); - // extract the mumber of strips forming the cross and store them in an occupancy plot for matched signals - // which strips are forming the id cross? - - if(lay1==1){ - h71.fill(seed1); - }else if(lay1==2){ - h72.fill(seed1); - }else if(lay1==3){ - h73.fill(seed1); -; }else if(lay1==4){ - h74.fill(seed1); - } - - if(lay2==1){ - h71.fill(seed2); - }else if(lay2==2){ - h72.fill(seed2); - }else if(lay2==3){ - h73.fill(seed2); - }else if(lay2==4){ - h74.fill(seed2); - } + // extract the mumber of strips forming the cross and store them in an occupancy plot for matched signals + // which strips are forming the id cross? + if(lay1==1){h71.fill(seed1);} + else if(lay1==2){h72.fill(seed1);} + else if(lay1==3){h73.fill(seed1);} + else if(lay1==4){h74.fill(seed1);} + if(lay2==1){h71.fill(seed2);} + else if(lay2==2){h72.fill(seed2);} + else if(lay2==3){h73.fill(seed2);} + else if(lay2==4){h74.fill(seed2);} + DataBank bankhit = event.getBank("FTTRK::hits"); if(bankhit.rows()>0){ for(int k=0; k0){ -// System.out.println("coordinates on calorimeter " + bank.getDouble("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); System.out.println("coordinates of track on fttrk " + bank.getFloat("cx", i)*zt + " " + bank.getFloat("cy", i)*zt + " " + bank.getFloat("cz", i)*zt); System.out.println("director cosines hit on calorimeter " + part.x() + " " + part.y() + " " + part.z()); @@ -702,31 +650,10 @@ public static void main(String arg[]){ int sec2 = FTTRKReconstruction.findSector(seed2); hSecDet0.fill(sec1, sec2); hSeedDet0.fill(seed1, seed2); - /* - if(sec1 == 1 && sec2 == 10){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1-10 bad seeds d0, event " + nev); - }else if(sec1 == 10 && sec2 == 10){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 10-10 bad seeds d0, event " + nev); - }else if(sec1 == 10 && sec2 == 11){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 10-11 bad seeds d0, event " + nev); - }else if(sec1 == 16 && sec2 == 8){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 16-8 bad seeds d0, event " + nev); - }else if(sec1 == 16 && sec2 == 8){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 16-8 bad seeds d0, event " + nev); - }else if(sec1 == 1 && sec2 == 11){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1-11 bad seeds d0, event " + nev); - }else if(sec1 == 11 && sec2 == 15){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 11-15 bad seeds d0, event " + nev); - }else if(sec1 == 12 && sec2 == 16){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 12-16 bad seeds d0, event " + nev); - }else if(sec1 == 13 && sec2 == 11){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 13-11 bad seeds d0, event " + nev); - } - */ - - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + + if(debugMode>0){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + " bad seeds d0, event " + nev); - + } canvasCALTRK.cd(0); segment1.setLineColor(1); segment2.setLineColor(2); @@ -743,23 +670,10 @@ public static void main(String arg[]){ int sec2 = FTTRKReconstruction.findSector(seed2); hSecDet1.fill(sec1, sec2); hSeedDet1.fill(seed1, seed2); - /* - if(sec1 == 0 && sec2 == 8){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 0-8 bad seeds d1, event " + nev); - }else if(sec1 == 12 && sec2 == 10){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 12-10 bad seeds d1, event " + nev); - }else if(sec1 == 3 && sec2 == 18){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3-18 bad seeds d1, event " + nev); - }else if(sec1 == 12 && sec2 == 9){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 12-9 bad seeds d1, event " + nev); - }else if(sec1 == 2 && sec2 == 18){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 2-18 bad seeds d1, event " + nev); - } - */ - - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + + if(debugMode>0){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + " bad seeds d1, event " + nev); - + } canvasCALTRK.cd(1); segment1.setLineColor(3); segment2.setLineColor(4); @@ -768,12 +682,10 @@ public static void main(String arg[]){ } // extract residuals of TRK1 wrt TRK0 and viceversa - // loop on crosses in det0, find track connecting with origin, evaluate residuals of TRK1 hits wrt to this track - + // loop on crosses in det0, find track connecting with origin, evaluate residuals of TRK1 hits wrt to this track double cx = hitOnTrk.x() - ORIGIN.x(); double cy = hitOnTrk.y() - ORIGIN.y(); double cz = hitOnTrk.z() - ORIGIN.z(); - for(int ncj = 0; ncj < ncrosses; ncj++) { int det1 = banktrk.getInt("detector", ncj); if(det1 >=0 && nc != ncj && det != det1){ @@ -794,13 +706,11 @@ public static void main(String arg[]){ Math.abs(diffTheta) < diffThetaTolerance){ double t = cross.z()/hitOnTrk.z(); Vector3D pointOnTrackAtZ = new Vector3D(cx*t + ORIGIN.x(), cy*t + ORIGIN.y(), z1); - //if(det1 == 1){ if(det1 == 1 && trk1ID == secondCrossID){ resTrkXdet0.fill(pointOnTrackAtZ.x() - cross.x()); resTrkYdet0.fill(pointOnTrackAtZ.y() - cross.y()); resTrkThetadet0.fill(pointOnTrackAtZ.theta() - cross.theta()); resTrkPhidet0.fill(pointOnTrackAtZ.phi() - cross.phi()); - //}else if(det1 == 0){ }else if(det1 == 0 && trk0ID == secondCrossID){ resTrkXdet1.fill(pointOnTrackAtZ.x() - cross.x()); resTrkYdet1.fill(pointOnTrackAtZ.y() - cross.y()); @@ -875,14 +785,10 @@ public static void main(String arg[]){ // if the magnetic field is on, the coordinates must be swum along a helix double B = en.getSolenoid(); if(B!=0.){ -// Pperp /= P; -// Pz /= P; -// B *= 2.; // perche'? da cosa deriva questo 2? // find the crossing point of the helix and a xy plane at given z, where the magneti field stops - double zStop = 100.0; // provisional fix it to 1 meter + double zStop = 100.0; // PROVISIONAL fixed to 1 meter double phi0 = Math.atan2(cy,cx); double R = Pperp/0.3/B/q*1.e2; // R in cm - //double dAlpha = (zt-z0)*(B*q*0.3)/Pz*1.e-2; // deltaZ in meters double dAlpha = (zStop-z0)*(B*q*0.3)/Pz*1.e-2; // deltaZ in meters int nturns = (int) Math.floor(dAlpha/2./Math.PI); // number of full turns if(dAlpha>0){ @@ -907,21 +813,7 @@ public static void main(String arg[]){ hitMCOnTrk.setXYZ(hitOnPlane.x()+vx1*t1, hitOnPlane.y()+vy1*t1, zt); }else{ System.out.println("check particle/curvature signs"); - } - // find the direction of the tanget vector at the - - - - - /* - // alternative method - double w = B*0.3/q/mass; - t = (zt-z0)*1e-2*mass/Pz; - hitMCOnTrk.setX(x0 + Pperp/mass/w*1.e2 * Math.sin(w*t+phi0) - xc); - hitMCOnTrk.setY(y0 - Pperp/mass/w*1.e2 * Math.cos(w*t+phi0) + yc); - */ - - + } } if(debugMode>0) System.out.println("MC after swimming in mag field x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + " z = " + hitMCOnTrk.z()); @@ -929,23 +821,18 @@ public static void main(String arg[]){ // Montecarlo hit location on first detector middle plane if(det==0) h2000.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); if(det==1) h2001.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); - if(det==0){ h1100.fill(hitOnTrk.x(), hitOnTrk.y()); h1102.fill(hitMCOnTrk.x() - hitOnTrk.x()); h1104.fill(hitMCOnTrk.y() - hitOnTrk.y()); - h1106.fill((hitMCOnTrk.theta() - hitOnTrk.theta())); h1108.fill((hitMCOnTrk.phi() - hitOnTrk.phi())); - h1112.fill((hitMCOnTrk.x() - hitOnTrk.x())/hitMCOnTrk.x()); h1114.fill((hitMCOnTrk.y() - hitOnTrk.y())/hitMCOnTrk.y()); - h202.fill(hitOnTrk.x()); h1202.fill(hitMCOnTrk.x()); h204.fill(hitOnTrk.y()); h1204.fill(hitMCOnTrk.y()); - }else if(det==1){ h1101.fill(hitOnTrk.x(), hitOnTrk.y()); h1103.fill(hitMCOnTrk.x() - hitOnTrk.x()); @@ -969,38 +856,6 @@ public static void main(String arg[]){ } } } // end MC comparison - - /* - // extract residuals of TRK1 wrt TRK0 and viceversa - // loop on crosses in det0, find track connecting with origin, evaluate residuals of TRK1 hits wrt to this track - for(int i = 0; i < nrows; i++) { - int det0 = banktrk.getInt("detector", i); - double x0 = banktrk.getFloat("x", i); - double y0 = banktrk.getFloat("y", i); - double z0 = banktrk.getFloat("z", i); - Vector3D hitOnTrk = new Vector3D(x0, y0, z0); - for(int j = 0; j < nrows; j++) { - int det1 = banktrk.getInt("detector", j); - if(i != j && det0 != det1){ - double x1 = banktrk.getFloat("x", j); - double y1 = banktrk.getFloat("y", j); - double z1 = banktrk.getFloat("z", j); - Vector3D cross = new Vector3D(x1, y1*x1/x0, z1*x1/x0); - if(det0 == 0){ - resTrkXdet0.fill(hitOnTrk.x() - cross.x()); - resTrkYdet0.fill (hitOnTrk.y() - cross.y()); - resTrkThetadet0.fill(hitOnTrk.theta() - cross.theta()); - resTrkPhidet0.fill(hitOnTrk.phi() - cross.phi()); - }else if(det0 == 1){ - resTrkXdet1.fill(hitOnTrk.x() - cross.x()); - resTrkYdet1.fill (hitOnTrk.y() - cross.y()); - resTrkThetadet1.fill(hitOnTrk.theta() - cross.theta()); - resTrkPhidet1.fill(hitOnTrk.phi() - cross.phi()); - } - } - } - } - */ } // end loop on crosses } } @@ -1009,56 +864,52 @@ public static void main(String arg[]){ System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + nevWithCrosses + " @@@@ number of reconstructed FTParticles " + nOfFTParticles); - JFrame frame = new JFrame("FT Reconstruction"); - frame.setSize(1200, 800); - EmbeddedCanvas canvas = new EmbeddedCanvas(); - canvas.divide(3, 3); - canvas.cd(0); - canvas.draw(h1); - canvas.cd(1); - canvas.draw(h2); - canvas.cd(2); - canvas.draw(h3); - canvas.cd(3); -// canvas.draw(h4); - h501.setFillColor(3); // green - h502.setFillColor(5); // yellow - h503.setFillColor(8); // dark green - h504.setFillColor(7); // orange - h600.setFillColor(9); // blue violet - h602.setFillColor(3); // green trk0 - h603.setFillColor(5); // yellow trk1 + if(timeEnergyDiagnosticHistograms){ + JFrame frame = new JFrame("FT Reconstruction"); + frame.setSize(1200, 800); + EmbeddedCanvas canvas = new EmbeddedCanvas(); + canvas.divide(3, 3); + canvas.cd(0); + canvas.draw(h1); + canvas.cd(1); + canvas.draw(h2); + canvas.cd(2); + canvas.draw(h3); + canvas.cd(3); + h501.setFillColor(3); // green + h502.setFillColor(5); // yellow + h503.setFillColor(8); // dark green + h504.setFillColor(7); // orange + h600.setFillColor(9); // blue violet + h602.setFillColor(3); // green trk0 + h603.setFillColor(5); // yellow trk1 - canvas.draw(h501); - canvas.draw(h502,"same"); - canvas.cd(4); - canvas.draw(h503,""); - canvas.draw(h504,"same"); - + canvas.draw(h501); + canvas.draw(h502,"same"); + canvas.cd(4); + canvas.draw(h503,""); + canvas.draw(h504,"same"); - for (int i = 0; i < h6.getDataBufferSize(); i++) { - float meanE = h6.getDataBufferBin(i); - float nE = h7.getDataBufferBin(i); - if (nE > 0) { - h6.setDataBufferBin(i, meanE / nE); + for (int i = 0; i < h6.getDataBufferSize(); i++) { + float meanE = h6.getDataBufferBin(i); + float nE = h7.getDataBufferBin(i); + if (nE > 0) { + h6.setDataBufferBin(i, meanE / nE); + } } + canvas.cd(5); + canvas.draw(h507); + canvas.cd(6); + canvas.draw(h600); + canvas.cd(7); + canvas.draw(h601); + canvas.cd(8); + canvas.draw(h602); + canvas.draw(h603,"same"); + frame.add(canvas); + frame.setLocationRelativeTo(null); + frame.setVisible(true); } - canvas.cd(5); -// canvas.draw(h7); - canvas.draw(h507); - canvas.cd(6); -// canvas.draw(h8); - canvas.draw(h600); - canvas.cd(7); -// canvas.draw(h9); - canvas.draw(h601); - canvas.cd(8); -// canvas.draw(h10); - canvas.draw(h602); - canvas.draw(h603,"same"); - frame.add(canvas); - frame.setLocationRelativeTo(null); - frame.setVisible(true); double narrowFactor = 7.; // was 4.5 JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); @@ -1375,20 +1226,6 @@ public static void main(String arg[]){ frametrkrel.setLocationRelativeTo(null); frametrkrel.setVisible(true); - /* - JFrame frameMCradio = new JFrame("Montecarlo radiography of vertex"); - frameMCradio.setSize(1000,500); - EmbeddedCanvas canvasMCradio = new EmbeddedCanvas(); - canvasMCradio.divide(2,1); - canvasMCradio.cd(0); - canvasMCradio.draw(h2000); - canvasMCradio.cd(1); - canvasMCradio.draw(h2001); - frameMCradio.add(canvasMCradio); - frameMCradio.setLocationRelativeTo(null); - frameMCradio.setVisible(true); - */ - JFrame frameSecradio = new JFrame("20 sectors occupancy"); frameSecradio.setSize(1000,500); EmbeddedCanvas canvasSecradio = new EmbeddedCanvas(); @@ -1509,7 +1346,6 @@ public static void main(String arg[]){ GraphErrors excludedDet01 = new GraphErrors(); for(int i=0; i getFTparticles() { -// return FTparticles; -// } -// -// public List getFTresponses() { -// return FTresponses; -// } -// -// public void setFTresponses(List FTresponses) { -// this.FTresponses = FTresponses; -// } public double getField() { return solenoidField; } @@ -149,12 +137,10 @@ public List addResponses(DataEvent event, ConstantsManager manager, resp.setId(bank.getInt("id", i)); resp.setEnergy(bank.getFloat("energy", i)); resp.setTime(bank.getFloat("time", i)); - ////////////////////////////// provisional resp.setCrEnergy(FTTRKReconstruction.crEnergy[i]); resp.setCrTime(FTTRKReconstruction.crTime[i]); - ////////////////////////////// resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); - /// detector id (it is not the cross id) + /// detector id (different from cross id!) double zCoord = bank.getFloat("z", i); if(zCoord >= FTTRKConstantsLoader.Zlayer[0] && zCoord <= FTTRKConstantsLoader.Zlayer[1]){ @@ -163,9 +149,6 @@ public List addResponses(DataEvent event, ConstantsManager manager, resp.setTrkDet(1); } - - - //debugMode = 2; if(debugMode>=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); responses.add(resp); } @@ -195,7 +178,7 @@ public List initFTparticles(List responses) { for (int i = 0; i < responses.size(); i++) { if (responses.get(i).getType() == "FTCAL") { FTParticle track = new FTParticle(i); - // start assuming the cluster to be associated to a photon + // start assuming the cluster to be associated to a photon PROVISIONAL to be updated with correct charge (if possible) track.setCharge(0); track.setField(this.solenoidField); track.setEnergy(responses.get(i).getEnergy()); @@ -204,7 +187,6 @@ public List initFTparticles(List responses) { track.setTime(responses.get(i).getTime() - responses.get(i).getPosition().mag() / PhysicsConstants.speedOfLight()); track.setCalorimeterIndex(responses.get(i).getId()); track.setHodoscopeIndex(-1); - //track.setTrackerIndex(-1); track.setTrackerIndex(-1, 0); track.setTrackerIndex(-1, 1); particles.add(track); @@ -240,7 +222,9 @@ public void matchToHODO(List responses, List particles) } } - public void matchToTRK(List responses, List particles) { + /* + // obsolete version, including just one hit from the tracker + public void matchToTRK(List responses, List particles) { for (int i = 0; i < particles.size(); i++) { FTParticle track = particles.get(i); if (debugMode >= 1) { @@ -251,52 +235,48 @@ public void matchToTRK(List responses, List particles) { if (debugMode >= 1) { System.out.println("found signal in FTTRK" + iTrk); } - track.setCharge(-999); // provisional, for no field tracking + track.setCharge(-999); // provisional, assuming no field tracking track.setTrackerIndex(responses.get(iTrk).getId(), responses.get(iTrk).getTrkDet()); // here trkID is set to the index of the matched track responses.get(iTrk).setAssociation(i); // if the cross is matched to the track set the cross id as negative if(responses.get(iTrk).getAssociation()==0) responses.get(iTrk).setId(-responses.get(iTrk).getId()); responses.get(iTrk).setMatchPosition(track.getPosition().x(), track.getPosition().y(), track.getPosition().z()); System.out.println("matched cross coordinates " + responses.get(iTrk).getPosition().x() + " " + responses.get(iTrk).getPosition().y()); - }else{ - // wrong cross coordinates need to be deleted } if (debugMode >= 1) track.show(); } } - + */ + + // 2nd version including both detectors + /* public void matchToTRKTwoDetectors(List responses, List particles) { for (int i = 0; i < particles.size(); i++) { FTParticle track = particles.get(i); if (debugMode >= 1) { System.out.println("Searching for matching signal in the tracker:"); } - //int[] iTrk = track.getTRKBestHits(responses, FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); int[] iTrk = {-1, -1}; iTrk = track.getTRKBestHits(responses, i, FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); - for(int j=0; j<2; j++){ // loop on two detectors + for(int j=0; j 0) { if (debugMode >= 1) { System.out.println("found signal in FTTRK" + iTrk[j]); } track.setCharge(-999); // provisional, for no field tracking - track.setTrackerIndex(responses.get(iTrk[j]).getId(), j); // here trkIS is set to the index of the matched track -//// track.setTrackerIndex(iTrk[j], j); -// responses.get(iTrk[j]).setId(iTrk[j]); + track.setTrackerIndex(responses.get(iTrk[j]).getId(), j); // here trkID is set to the index of the matched track responses.get(iTrk[j]).setHitIndex(iTrk[j]); responses.get(iTrk[j]).setAssociation(i); - //responses.get(iTrk[j]).getCross and change the index of the cross responses.get(iTrk[j]).setMatchPosition(track.getPosition().x(), track.getPosition().y(), track.getPosition().z()); - System.out.println("matched cross coordinates " + responses.get(iTrk[j]).getPosition().x() + " " + + if(debugMode>=1) System.out.println("matched cross coordinates " + responses.get(iTrk[j]).getPosition().x() + " " + responses.get(iTrk[j]).getPosition().y()); - }else{ - // wrong cross coordinates need to be deleted } } if (debugMode >= 1) track.show(); } } + */ public void matchToTRKTwoDetectorsMultiHits(List responses, List particles) { for (int i = 0; i < particles.size(); i++) { @@ -307,21 +287,19 @@ public void matchToTRKTwoDetectorsMultiHits(List responses, List 0) { - if (debugMode >= 1) { - System.out.println("found signal in FTTRK" + iTrk[k][j]); - } + if (debugMode >= 1) System.out.println("found signal in FTTRK" + iTrk[k][j]); track.setCharge(-999); // provisional, for no field tracking track.setTrackerIndex(responses.get(iTrk[k][j]).getId(), j); responses.get(iTrk[k][j]).setHitIndex(iTrk[k][j]); responses.get(iTrk[k][j]).setAssociation(i); responses.get(iTrk[k][j]).setMatchPosition(track.getPosition().x(), track.getPosition().y(), track.getPosition().z()); - System.out.println("matched cross coordinates " + responses.get(iTrk[k][j]).getPosition().x() + " " + + if(debugMode>=1) System.out.println("matched cross coordinates " + responses.get(iTrk[k][j]).getPosition().x() + " " + responses.get(iTrk[k][j]).getPosition().y()); }else{ - // wrong cross coordinates need to be deleted + // wrong cross coordinates need to be deleted - consider if any action shuould be taken here TOBEDONE } } } @@ -353,38 +331,11 @@ public void matchToFTCal(List responses, List particles) track.setTrackerIndex(responses.get(iTrk).getId(), responses.get(iTrk).getTrkDet()); responses.get(iTrk).setAssociation(i); } - if (debugMode >= 1) track.show(); } } - -/* - // version to match FTTRK hits ony, to be dropped - public void matchTRKHits(List responses, List particles) { - for (int i = 0; i < particles.size(); i++) { - FTParticle track = particles.get(i); - if (debugMode >= 1) { - System.out.println("Searching for matching signal in the tracker:"); - } - // consider FTParticles only through FTTRK detector - if(track.getCalorimeterIndex()<0){ - int iTrk = track.getDetectorHit(responses, "FTTRK", FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); - if (iTrk > 0) { - if (debugMode >= 1) { - System.out.println("found signal in FTTRK" + iTrk); - } - track.setCharge(-999); // provisional, for no field tracking - track.setTrackerIndex(responses.get(iTrk).getId()); - responses.get(iTrk).setAssociation(i); - } - if (debugMode >= 1) track.show(); - } - } - } -*/ - public void showResponses(List responses) { System.out.println("\nFound " + responses.size() + " clusters in FT detector"); for (int i = 0; i < responses.size(); i++) { @@ -413,7 +364,6 @@ public void writeBanks(DataEvent event, List particles) { banktrack.setInt("CalID", i, particles.get(i).getCalorimeterIndex()); banktrack.setInt("HodoID", i, particles.get(i).getHodoscopeIndex()); banktrack.setInt("Trk0ID", i, particles.get(i).getTrackerIndex(0)); -// banktrack.setInt("trkID", i, particles.get(i).getTrackerIndex(0)); banktrack.setInt("Trk1ID", i, particles.get(i).getTrackerIndex(1)); if (debugMode >= 1) { particles.get(i).show(); @@ -437,7 +387,6 @@ public void writeBanks(DataEvent event, List particles) { banktrack.setFloat("time", i, (float) particles.get(i).getTime()); banktrack.setShort("calID", i, (short) particles.get(i).getCalorimeterIndex()); banktrack.setShort("hodoID", i, (short) particles.get(i).getHodoscopeIndex()); -// banktrack.setShort("trkID", i, (short) particles.get(i).getTrackerIndex()); banktrack.setShort("trk0ID", i, (short) particles.get(i).getTrackerIndex(0)); banktrack.setShort("trk1ID", i, (short) particles.get(i).getTrackerIndex(1)); diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index 322dfb804a..3adf62523c 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -554,30 +554,32 @@ public void writeHipoBanks(DataEvent event, List hits, List=1) System.out.println("energy and time to be stored in banks " + crosses.get(j).get_Energy() + " " + crosses.get(j).get_Time()); // control histograms should be provisional and filled only if existing - FTEBEngine.h507.fill(crosses.get(j).get_Time(), crosses.get(j).get_Energy()); - if(crosses.get(j).get_Id()==0){ - FTEBEngine.h503.fill(crosses.get(j).get_Time()); - FTEBEngine.h501.fill(crosses.get(j).get_Energy()); - FTEBEngine.h505.fill(crosses.get(j).get_Time(), crosses.get(j).get_Energy()); - FTTRKCluster cl1 = crosses.get(j).get_Cluster1(); - FTTRKCluster cl2 = crosses.get(j).get_Cluster2(); - FTEBEngine.h510.fill(cl1.get_TotalEnergy(), cl2.get_TotalEnergy()); - FTEBEngine.h512.fill(cl1.get_TotalEnergy()); - FTEBEngine.h512.fill(cl2.get_TotalEnergy()); - for(int k=0; k Date: Fri, 11 Feb 2022 15:27:13 +0100 Subject: [PATCH 066/104] cleanup --- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 7 +-- .../java/org/jlab/rec/ft/FTEventBuilder.java | 56 ------------------- .../jlab/rec/ft/trk/FTTRKConstantsLoader.java | 3 +- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 7 --- 4 files changed, 2 insertions(+), 71 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index d89ce9b66a..a8b168bf35 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -22,9 +22,6 @@ import org.jlab.groot.math.F1D; import org.jlab.groot.fitter.DataFitter; import org.jlab.groot.graphics.EmbeddedCanvas; -import org.jlab.groot.base.DatasetAttributes; -import org.jlab.groot.base.GStyle; -import org.jlab.groot.base.TColorPalette; import org.jlab.groot.data.GraphErrors; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; @@ -107,8 +104,6 @@ public boolean processDataEvent(DataEvent event) { FTresponses = reco.addResponses(event, this.getConstantsManager(), run); FTparticles = reco.initFTparticles(FTresponses); if(FTparticles.size()>0){ -//// reco.matchToTRK(FTresponses, FTparticles); -//// reco.matchToTRKTwoDetectors(FTresponses, FTparticles); reco.matchToTRKTwoDetectorsMultiHits(FTresponses, FTparticles); reco.matchToHODO(FTresponses, FTparticles); // reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo @@ -812,7 +807,7 @@ public static void main(String arg[]){ double t1 = (zt - hitOnPlane.z())/vz1; hitMCOnTrk.setXYZ(hitOnPlane.x()+vx1*t1, hitOnPlane.y()+vy1*t1, zt); }else{ - System.out.println("check particle/curvature signs"); + if(debugMode>0) System.out.println("check particle/curvature signs"); } } if(debugMode>0) System.out.println("MC after swimming in mag field x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index de0e36e042..eaef9e28bc 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -221,62 +221,6 @@ public void matchToHODO(List responses, List particles) } } } - - /* - // obsolete version, including just one hit from the tracker - public void matchToTRK(List responses, List particles) { - for (int i = 0; i < particles.size(); i++) { - FTParticle track = particles.get(i); - if (debugMode >= 1) { - System.out.println("Searching for matching signal in the tracker:"); - } - int iTrk = track.getDetectorHit(responses, "FTTRK", FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); - if (iTrk > 0) { - if (debugMode >= 1) { - System.out.println("found signal in FTTRK" + iTrk); - } - track.setCharge(-999); // provisional, assuming no field tracking - track.setTrackerIndex(responses.get(iTrk).getId(), responses.get(iTrk).getTrkDet()); // here trkID is set to the index of the matched track - responses.get(iTrk).setAssociation(i); - // if the cross is matched to the track set the cross id as negative - if(responses.get(iTrk).getAssociation()==0) responses.get(iTrk).setId(-responses.get(iTrk).getId()); - responses.get(iTrk).setMatchPosition(track.getPosition().x(), track.getPosition().y(), track.getPosition().z()); - System.out.println("matched cross coordinates " + responses.get(iTrk).getPosition().x() + " " + responses.get(iTrk).getPosition().y()); - } - if (debugMode >= 1) track.show(); - } - } - */ - - // 2nd version including both detectors - /* - public void matchToTRKTwoDetectors(List responses, List particles) { - for (int i = 0; i < particles.size(); i++) { - FTParticle track = particles.get(i); - if (debugMode >= 1) { - System.out.println("Searching for matching signal in the tracker:"); - } - int[] iTrk = {-1, -1}; - iTrk = track.getTRKBestHits(responses, i, FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); - for(int j=0; j 0) { - if (debugMode >= 1) { - System.out.println("found signal in FTTRK" + iTrk[j]); - } - - track.setCharge(-999); // provisional, for no field tracking - track.setTrackerIndex(responses.get(iTrk[j]).getId(), j); // here trkID is set to the index of the matched track - responses.get(iTrk[j]).setHitIndex(iTrk[j]); - responses.get(iTrk[j]).setAssociation(i); - responses.get(iTrk[j]).setMatchPosition(track.getPosition().x(), track.getPosition().y(), track.getPosition().z()); - if(debugMode>=1) System.out.println("matched cross coordinates " + responses.get(iTrk[j]).getPosition().x() + " " + - responses.get(iTrk[j]).getPosition().y()); - } - } - if (debugMode >= 1) track.show(); - } - } - */ public void matchToTRKTwoDetectorsMultiHits(List responses, List particles) { for (int i = 0; i < particles.size(); i++) { diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java index 257a2e16b5..21e52d4082 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKConstantsLoader.java @@ -206,8 +206,7 @@ private static int getLocalRegionX(int strip){ public static Line3D getStripSegmentLab(int layer, int seed){ Line3D stripSegment = new Line3D(stripsX[layer-1][seed-1][0], stripsY[layer-1][seed-1][0], Zlayer[layer-1], stripsX[layer-1][seed-1][1], stripsY[layer-1][seed-1][1], Zlayer[layer-1]); - stripSegment.show(); - + //stripSegment.show(); return stripSegment; } } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index 3adf62523c..77184f1901 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -742,7 +742,6 @@ public int reverseStripsInSector(int icomponent){ // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is // excluded in the sector, [i+1]is included // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - //int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector = findSector(icomponent); if(nsector>20) System.out.println("wrong sector number, check code"); int offset = sectorLimits[nsector+1] - icomponent; @@ -755,7 +754,6 @@ public int reverseStripInFirstHalf(int icomponent){ // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is // excluded in the sector, [i+1]is included // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - //int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector = findSector(icomponent); if(nsector>20) System.out.println("wrong sector number, check code"); int halfStrip = (sectorLimits[nsector+1]-sectorLimits[nsector])/2 + sectorLimits[nsector]; @@ -771,7 +769,6 @@ public int reverseStripInSecondHalf(int icomponent){ // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is // excluded in the sector, [i+1]is included // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - //int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector = findSector(icomponent); if(nsector>20) System.err.println("wrong FTTRK strip sector number, check code"); int halfStrip = (sectorLimits[nsector+1]-sectorLimits[nsector])/2 + sectorLimits[nsector]; @@ -787,7 +784,6 @@ public int swapHalves(int icomponent){ // the strips are numbered 1-768, the [i] component of sectorLimit vector is // excluded in the sector, [i+1]is included // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - //int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector = findSector(icomponent); if(nsector>20) System.err.println("wrong FTTRK strip sector number, check code"); int halfWid = (sectorLimits[nsector+1]-sectorLimits[nsector])/2; @@ -808,7 +804,6 @@ public int swapSectors(int icomponent, int nsector2){ // icomponent strips are numbered 1-768 so the vector sectorLimits contains the number of the starting // strip of a sector: [i] is excluded from sector i, [i+1] is included // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - //int[] sectorLimit = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector1 = findSector(icomponent); int offset = -sectorLimits[nsector1] + icomponent; int newicomp = sectorLimits[nsector2] + offset; @@ -822,7 +817,6 @@ public static int findSector(int icomponent){ // sectors are numbered 0-20; icomponent strips are numbered 1-768 so the vector sectorLimits contains // the number of the starting strip of a sector: [i] is excluded from sector i, [i+1] is included // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - //int[] sectorLimits = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; int nsector = -1; for(int i=0; i<20; i++){ if(icomponent>sectorLimits[i] && icomponent<=sectorLimits[i+1]){ @@ -837,7 +831,6 @@ public static int findSector(int icomponent){ public boolean isInSector(int iSector, int icomponent){ // returns ture is the strip icomponent is in the iSector sector // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - //int[] sectorLimits = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; if(icomponent>sectorLimits[iSector] && icomponent<=sectorLimits[iSector+1]){ return true; }else{ From 432b115fc95c4387ab8326d61b0c4fabe4bb1527 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Fri, 11 Feb 2022 16:02:08 +0100 Subject: [PATCH 067/104] cleanup --- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 5 +- .../jlab/rec/ft/FTEBEngineSingleEvent.java | 834 +++++++----------- 2 files changed, 336 insertions(+), 503 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index a8b168bf35..4eeaf33b96 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -461,7 +461,8 @@ public static void main(String arg[]){ continue; } // bankEvt is the number used to extract the event with groovy - if(debugMode>0) System.out.println("////////////// event read " + bankEvt + " - sequential number " + nev); + // always print to keep track of running + if(debugMode>-1) System.out.println("////////////// event read " + bankEvt + " - sequential number " + nev); //if(nev > 10239) System.exit(0); if(nev != 10239) continue; // stop at a given evt number cal.processDataEvent(event); hodo.processDataEvent(event); @@ -855,7 +856,7 @@ public static void main(String arg[]){ } } - if(debugMode>=0) + if(debugMode>=-1) // print always System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + nevWithCrosses + " @@@@ number of reconstructed FTParticles " + nOfFTParticles); diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java index dda6c0b380..efe120f329 100755 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java @@ -22,9 +22,6 @@ import org.jlab.groot.math.F1D; import org.jlab.groot.fitter.DataFitter; import org.jlab.groot.graphics.EmbeddedCanvas; -import org.jlab.groot.base.DatasetAttributes; -import org.jlab.groot.base.GStyle; -import org.jlab.groot.base.TColorPalette; import org.jlab.groot.data.GraphErrors; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; @@ -43,6 +40,8 @@ public class FTEBEngineSingleEvent extends ReconstructionEngine { FTEventBuilder reco; int Run = -1; double Solenoid; + static boolean timeEnergyDiagnosticHistograms = false; + static boolean residualsHistograms = false; public FTEBEngineSingleEvent() { super("FTEB", "devita", "3.0"); @@ -74,8 +73,6 @@ public boolean processDataEvent(DataEvent event) { FTresponses = reco.addResponses(event, this.getConstantsManager(), run); FTparticles = reco.initFTparticles(FTresponses); if(FTparticles.size()>0){ -//// reco.matchToTRK(FTresponses, FTparticles); -//// reco.matchToTRKTwoDetectors(FTresponses, FTparticles); reco.matchToTRKTwoDetectorsMultiHits(FTresponses, FTparticles); reco.matchToHODO(FTresponses, FTparticles); // reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo @@ -142,6 +139,8 @@ public int getDebugMode() { return this.reco.debugMode; } + static boolean plotDiagnosticHistograms = timeEnergyDiagnosticHistograms || residualsHistograms; + public static H1F h500 = new H1F("Time Difference FTCAL-response", 100, 0., 200.); public static H1F h501 = new H1F("Cross Energy TRK0", 100, 0., 2000.); public static H1F h502 = new H1F("Cross Energy TRK1", 100, 0., 2000.); @@ -183,25 +182,9 @@ public static void main(String arg[]){ FTEBEngine en = new FTEBEngine(); en.init(); int debugMode = en.getDebugMode(); -// String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/elec_nofield_header.evio"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_nofields_big_-30.60.120.30_fullAcceptance.hipo"; -/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_singleEle_withFields_big_-30.60.120.30_newbanks.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_test_1000.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance.hipo"; -/// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_dis.hipo"; -////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; -////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418.0.hipo"; // dontuse ////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; -/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/ft_005038_01231_newbanks.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/data_merge.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_154824_det0.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_153947_det1.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_160427_det1.hipo"; -// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/twoHits_10239.hipo"; String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_94976.hipo"; -// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/gemc_test.hipo"; -/// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/gemc_singleEle_withFields_big_-30.60.120.30_fullAcceptance_newbanks.hipo"; + HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -321,9 +304,7 @@ public static void main(String arg[]){ resTrkPhidet1.setOptStat(10); resTrkPhidet1.setTitleX("trk0 phi residual (rad) wrt line thru trk1"); resTrkPhidet1.setFillColor(49); - -// H1F h202 = new H1F("trk1 x", 25, 9., 9.4); -// H1F h1202 = new H1F("trk1 x MC", 25, 9., 9.4); + H1F h202 = new H1F("trk1 x", 25, 8.2, 9.0); H1F h1202 = new H1F("trk1 x MC", 25, 8.2, 9.0); h202.setOptStat(0); @@ -333,8 +314,6 @@ public static void main(String arg[]){ h202.setFillColor(3); h1202.setLineColor(9); h1202.setFillColor(49); -// H1F h203 = new H1F("trk2 x", 25, 9., 9.4); -// H1F h1203 = new H1F("trk2 MC", 25, 9., 9.4); H1F h203 = new H1F("trk2 x", 25, 8.2, 9.0); H1F h1203 = new H1F("trk2 MC", 25, 8.2, 9.0); h203.setOptStat(0); @@ -344,8 +323,6 @@ public static void main(String arg[]){ h203.setFillColor(3); h1203.setLineColor(9); h1203.setFillColor(49); -// H1F h204 = new H1F("trk1 y", 25, 1.4, 1.8); -// H1F h1204 = new H1F("trk1 y MC", 25, 1.4, 1.8); H1F h204 = new H1F("trk1 y", 25, 2.4, 4.0); H1F h1204 = new H1F("trk1 y MC", 25, 2.4, 4.0); h204.setOptStat(0); @@ -355,8 +332,6 @@ public static void main(String arg[]){ h204.setFillColor(3); h1204.setLineColor(9); h1204.setFillColor(49); -// H1F h205 = new H1F("trk2 y", 25, 1.4, 1.8); -// H1F h1205 = new H1F("trk2 y MC", 25, 1.4, 1.8); H1F h205 = new H1F("trk2 y", 25, 2.4, 4.0); H1F h1205 = new H1F("trk2 y MC", 25, 2.4, 4.0); h205.setOptStat(0); @@ -490,7 +465,7 @@ public static void main(String arg[]){ hodo.processDataEvent(event); trk.processDataEventAndGetClusters(event); en.processDataEvent(event); - if(!event.hasBank("FTCAL::hits")) continue; //////////////////////////////////////////// + if(!event.hasBank("FTCAL::hits")) continue; if (event instanceof EvioDataEvent) { GenericKinematicFitter fitter = new GenericKinematicFitter(11); @@ -513,7 +488,6 @@ public static void main(String arg[]){ } else { DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); PhysicsEvent gen = detectorEvent.getGeneratedEvent(); -// nev++; if (event.hasBank("FT::particles")) { DataBank bank = event.getBank("FT::particles"); int nrows = bank.rows(); @@ -537,7 +511,6 @@ public static void main(String arg[]){ } // check match with trk bank (entry trkID) -// int trkID = bank.getShort("trkID", i); int trk0ID = bank.getShort("trk0ID", i); // it should correspond to the number of the cross in the banks int trk1ID = bank.getShort("trk1ID", i); if(trk0ID >= 0 || trk1ID >= 0){ // at least one cross is present on one TRK det @@ -553,37 +526,28 @@ public static void main(String arg[]){ if(trk0ID == crossID && det==0) matchedCrosses++; if(trk1ID == crossID && det==1) matchedCrosses++; } - - + // if(matchedCrosses != 1){ // if(matchedCrosses != 2){ - if(matchedCrosses == 0){ // accept all crosses + if(matchedCrosses < FTConstants.TRK_MIN_CROSS_NUMBER){ // accept at least one cross continue; }else{ ncrosses2++; - if(ncrosses< 100) System.out.println("++++++++++++++++++++++++++ Sequential number " + nev); + if(ncrosses< 100 && debugMode>0) System.out.println("++++++++++++++++++++++++++ Sequential number " + nev); } for(int nc = 0; nc < ncrosses; nc++){ int crossID = banktrk.getInt("id", nc); if(crossID != trk0ID && crossID != trk1ID) continue; int det = banktrk.getInt("detector", nc); -// if(det != 0) continue; - //int crossID = banktrk.getInt("id", nc); - System.out.println("trk0ID " + trk0ID + " trk1ID " + trk1ID + + if(debugMode>0) System.out.println("trk0ID " + trk0ID + " trk1ID " + trk1ID + " crossID " + crossID); -// if(ncrosses<2) continue; -// if(crossID != trk0ID || crossID != trk1ID) continue; // keep only 2nd detector - if(det>=0){ float xt = banktrk.getFloat("x", nc); float yt = banktrk.getFloat("y", nc); float zt = banktrk.getFloat("z", nc); Vector3D hitOnTrk = new Vector3D(xt, yt, zt); // extract information on the crossed strips - -// float icl1 = banktrk.getFloat("energy", nc); // Cluster1ID provisional to be changed -// float icl2 = banktrk.getFloat("time", nc); // cluster2ID provisional to be changes float icl1 = banktrk.getShort("Cluster1ID", nc); float icl2 = banktrk.getShort("Cluster2ID", nc); DataBank bankcl = event.getBank("FTTRK::clusters"); @@ -606,7 +570,7 @@ public static void main(String arg[]){ seed2 = bankcl.getInt("seed", (int)icl2ok); int cent1 = (int)bankcl.getFloat("centroid", icl1ok); int cent2 = (int)bankcl.getFloat("centroid", icl2ok); - // if the cluster is formed by > 3 strips take the centroid + // if the cluster is formed by >= 3 strips take the centroid int clustsize1 = bankcl.getShort("size", icl1ok); int clustsize2 = bankcl.getShort("size", icl2ok); if(clustsize1>=3){ @@ -617,19 +581,16 @@ public static void main(String arg[]){ int sector = FTTRKReconstruction.findSector(seed2); if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed2 = cent2; } - // if seed and centroid dont coincide, take the geometric centroid as seed - //if(cent1 != seed1) seed1 = cent1; - //if(cent2 != seed2) seed2 = cent2; int lay1 = bankcl.getInt("layer", (int)icl1ok); int lay2 = bankcl.getInt("layer", (int)icl2ok); - System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ seed1, seed2 " + seed1 + " " + seed2 + " layer1 layer2 " + lay1 + " " + lay2); - System.out.println("~~~~~~~~~~ hit strip 1: " + seed1 + " layer " + lay1 + " sector " + + if(debugMode>-1){ + System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ seed1, seed2 " + seed1 + " " + seed2 + " layer1 layer2 " + lay1 + " " + lay2); + System.out.println("~~~~~~~~~~ hit strip 1: " + seed1 + " layer " + lay1 + " sector " + FTTRKReconstruction.findSector(seed1)); - System.out.println("~~~~~~~~~~ hit strip 2: " + seed2 + " layer " + lay2 + " sector " + + System.out.println("~~~~~~~~~~ hit strip 2: " + seed2 + " layer " + lay2 + " sector " + FTTRKReconstruction.findSector(seed2)); - + } if(seed1!=0 && seed2!=0){ - System.out.println("seed2" + seed2); Line3D seg1 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay1, seed1); Line3D seg2 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay2, seed2); segment1.setOrigin(seg1.origin().x(), seg1.origin().y()); @@ -637,9 +598,8 @@ public static void main(String arg[]){ segment1.setEnd(seg1.end().x(), seg1.end().y()); segment2.setEnd(seg2.end().x(), seg2.end().y()); - // extract the mumber of strips forming the cross and store them in an occupancy plot for matched signals - // which strips are forming the id cross? - + // extract the mumber of strips forming the cross and store them in an occupancy plot for matched signals + // which strips are forming the id cross? if(lay1==1){ h71.fill(seed1); }else if(lay1==2){ @@ -698,31 +658,10 @@ public static void main(String arg[]){ int sec2 = FTTRKReconstruction.findSector(seed2); hSecDet0.fill(sec1, sec2); hSeedDet0.fill(seed1, seed2); - /* - if(sec1 == 1 && sec2 == 10){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1-10 bad seeds d0, event " + nev); - }else if(sec1 == 10 && sec2 == 10){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 10-10 bad seeds d0, event " + nev); - }else if(sec1 == 10 && sec2 == 11){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 10-11 bad seeds d0, event " + nev); - }else if(sec1 == 16 && sec2 == 8){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 16-8 bad seeds d0, event " + nev); - }else if(sec1 == 16 && sec2 == 8){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 16-8 bad seeds d0, event " + nev); - }else if(sec1 == 1 && sec2 == 11){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1-11 bad seeds d0, event " + nev); - }else if(sec1 == 11 && sec2 == 15){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 11-15 bad seeds d0, event " + nev); - }else if(sec1 == 12 && sec2 == 16){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 12-16 bad seeds d0, event " + nev); - }else if(sec1 == 13 && sec2 == 11){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 13-11 bad seeds d0, event " + nev); - } - */ - /* - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + + if(debugMode>0){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + " bad seeds d0, event " + nev); - */ + } canvasCALTRK.cd(0); segment1.setLineColor(1); segment2.setLineColor(2); @@ -742,23 +681,10 @@ public static void main(String arg[]){ int sec2 = FTTRKReconstruction.findSector(seed2); hSecDet1.fill(sec1, sec2); hSeedDet1.fill(seed1, seed2); - /* - if(sec1 == 0 && sec2 == 8){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 0-8 bad seeds d1, event " + nev); - }else if(sec1 == 12 && sec2 == 10){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 12-10 bad seeds d1, event " + nev); - }else if(sec1 == 3 && sec2 == 18){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3-18 bad seeds d1, event " + nev); - }else if(sec1 == 12 && sec2 == 9){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 12-9 bad seeds d1, event " + nev); - }else if(sec1 == 2 && sec2 == 18){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 2-18 bad seeds d1, event " + nev); - } - */ - /* - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + + if(debugMode>0){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + " bad seeds d1, event " + nev); - */ + } canvasCALTRK.cd(1); segment1.setLineColor(3); segment2.setLineColor(4); @@ -768,39 +694,7 @@ public static void main(String arg[]){ canvasCALTRK.draw(segment1); canvasCALTRK.draw(segment2); } - - // extract residuals of TRK1 wrt TRK0 and viceversa - // loop on crosses in det0, find track connecting with origin, evaluate residuals of TRK1 hits wrt to this track - /* - double x0 = banktrk.getFloat("x", i); - double y0 = banktrk.getFloat("y", i); - double z0 = banktrk.getFloat("z", i); - for(int j = 0; j < nrows; j++) { - int det1 = banktrk.getInt("detector", j); - if(det1 >=0 && i != j && det != det1){ - double x1 = banktrk.getFloat("x", j); - double y1 = banktrk.getFloat("y", j); - double z1 = banktrk.getFloat("z", j); - //int cross1ID = banktrk.getInt("id", j); - Vector3D pointOnTrack = new Vector3D(x0*z1/z0, y0*z1/z0, z1); - Vector3D cross = new Vector3D(x1, y1, z1); - //if(det == 0 && trk0ID == crossID){ - if(det == 0){ - resTrkXdet0.fill(pointOnTrack.x() - cross.x()); - resTrkYdet0.fill(pointOnTrack.y() - cross.y()); - resTrkThetadet0.fill(pointOnTrack.theta() - cross.theta()); - resTrkPhidet0.fill(pointOnTrack.phi() - cross.phi()); - //}else if(det == 1 && trk1ID == crossID){ - }else if(det == 1){ - resTrkXdet1.fill(pointOnTrack.x() - cross.x()); - resTrkYdet1.fill(pointOnTrack.y() - cross.y()); - resTrkThetadet1.fill(pointOnTrack.theta() - cross.theta()); - resTrkPhidet1.fill(pointOnTrack.phi() - cross.phi()); - } - } - } - */ - + double cx = hitOnTrk.x() - ORIGIN.x(); double cy = hitOnTrk.y() - ORIGIN.y(); double cz = hitOnTrk.z() - ORIGIN.z(); @@ -814,13 +708,11 @@ public static void main(String arg[]){ Vector3D cross = new Vector3D(x1, y1, z1); double t = cross.z()/hitOnTrk.z(); Vector3D pointOnTrackAtZ = new Vector3D(cx*t + ORIGIN.x(), cy*t + ORIGIN.y(), z1); - //if(det == 0 && trk0ID == crossID){ if(det1 == 1 && trk1ID == secondCrossID){ resTrkXdet0.fill(pointOnTrackAtZ.x() - cross.x()); resTrkYdet0.fill(pointOnTrackAtZ.y() - cross.y()); resTrkThetadet0.fill(pointOnTrackAtZ.theta() - cross.theta()); resTrkPhidet0.fill(pointOnTrackAtZ.phi() - cross.phi()); - //}else if(det == 1 && trk1ID == crossID){ }else if(det1 == 0 && trk0ID == secondCrossID){ resTrkXdet1.fill(pointOnTrackAtZ.x() - cross.x()); resTrkYdet1.fill(pointOnTrackAtZ.y() - cross.y()); @@ -894,14 +786,10 @@ public static void main(String arg[]){ // if the magnetic field is on, the coordinates must be swum along a helix double B = en.getSolenoid(); if(B!=0.){ -// Pperp /= P; -// Pz /= P; -// B *= 2.; // perche'? da cosa deriva questo 2? // find the crossing point of the helix and a xy plane at given z, where the magneti field stops double zStop = 100.0; // provisional fix it to 1 meter double phi0 = Math.atan2(cy,cx); double R = Pperp/0.3/B/q*1.e2; // R in cm - //double dAlpha = (zt-z0)*(B*q*0.3)/Pz*1.e-2; // deltaZ in meters double dAlpha = (zStop-z0)*(B*q*0.3)/Pz*1.e-2; // deltaZ in meters int nturns = (int) Math.floor(dAlpha/2./Math.PI); // number of full turns if(dAlpha>0){ @@ -925,22 +813,8 @@ public static void main(String arg[]){ double t1 = (zt - hitOnPlane.z())/vz1; hitMCOnTrk.setXYZ(hitOnPlane.x()+vx1*t1, hitOnPlane.y()+vy1*t1, zt); }else{ - System.out.println("check particle/curvature signs"); - } - // find the direction of the tanget vector at the - - - - - /* - // alternative method - double w = B*0.3/q/mass; - t = (zt-z0)*1e-2*mass/Pz; - hitMCOnTrk.setX(x0 + Pperp/mass/w*1.e2 * Math.sin(w*t+phi0) - xc); - hitMCOnTrk.setY(y0 - Pperp/mass/w*1.e2 * Math.cos(w*t+phi0) + yc); - */ - - + if(debugMode>0) System.out.println("check particle/curvature signs"); + } } if(debugMode>0) System.out.println("MC after swimming in mag field x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + " z = " + hitMCOnTrk.z()); @@ -988,38 +862,6 @@ public static void main(String arg[]){ } } } // end MC comparison - - /* - // extract residuals of TRK1 wrt TRK0 and viceversa - // loop on crosses in det0, find track connecting with origin, evaluate residuals of TRK1 hits wrt to this track - for(int i = 0; i < nrows; i++) { - int det0 = banktrk.getInt("detector", i); - double x0 = banktrk.getFloat("x", i); - double y0 = banktrk.getFloat("y", i); - double z0 = banktrk.getFloat("z", i); - Vector3D hitOnTrk = new Vector3D(x0, y0, z0); - for(int j = 0; j < nrows; j++) { - int det1 = banktrk.getInt("detector", j); - if(i != j && det0 != det1){ - double x1 = banktrk.getFloat("x", j); - double y1 = banktrk.getFloat("y", j); - double z1 = banktrk.getFloat("z", j); - Vector3D cross = new Vector3D(x1, y1*x1/x0, z1*x1/x0); - if(det0 == 0){ - resTrkXdet0.fill(hitOnTrk.x() - cross.x()); - resTrkYdet0.fill (hitOnTrk.y() - cross.y()); - resTrkThetadet0.fill(hitOnTrk.theta() - cross.theta()); - resTrkPhidet0.fill(hitOnTrk.phi() - cross.phi()); - }else if(det0 == 1){ - resTrkXdet1.fill(hitOnTrk.x() - cross.x()); - resTrkYdet1.fill (hitOnTrk.y() - cross.y()); - resTrkThetadet1.fill(hitOnTrk.theta() - cross.theta()); - resTrkPhidet1.fill(hitOnTrk.phi() - cross.phi()); - } - } - } - } - */ } // end loop on crosses } } @@ -1028,187 +870,189 @@ public static void main(String arg[]){ System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + nevWithCrosses + " @@@@ number of reconstructed FTParticles " + nOfFTParticles); - JFrame frame = new JFrame("FT Reconstruction"); - frame.setSize(1200, 800); - EmbeddedCanvas canvas = new EmbeddedCanvas(); - canvas.divide(3, 3); - canvas.cd(0); - canvas.draw(h1); - canvas.cd(1); - canvas.draw(h2); - canvas.cd(2); - canvas.draw(h3); - canvas.cd(3); -// canvas.draw(h4); - h501.setFillColor(3); // green - h502.setFillColor(5); // yellow - h503.setFillColor(8); // dark green - h504.setFillColor(7); // orange - h600.setFillColor(9); // blue violet - h602.setFillColor(3); // green trk0 - h603.setFillColor(5); // yellow trk1 - - canvas.draw(h501); - canvas.draw(h502,"same"); - canvas.cd(4); - canvas.draw(h503,""); - canvas.draw(h504,"same"); + if(plotDiagnosticHistograms){ + JFrame frame = new JFrame("FT Reconstruction"); + frame.setSize(1200, 800); + EmbeddedCanvas canvas = new EmbeddedCanvas(); + canvas.divide(3, 3); + canvas.cd(0); + canvas.draw(h1); + canvas.cd(1); + canvas.draw(h2); + canvas.cd(2); + canvas.draw(h3); + canvas.cd(3); + // canvas.draw(h4); + h501.setFillColor(3); // green + h502.setFillColor(5); // yellow + h503.setFillColor(8); // dark green + h504.setFillColor(7); // orange + h600.setFillColor(9); // blue violet + h602.setFillColor(3); // green trk0 + h603.setFillColor(5); // yellow trk1 - - for (int i = 0; i < h6.getDataBufferSize(); i++) { - float meanE = h6.getDataBufferBin(i); - float nE = h7.getDataBufferBin(i); - if (nE > 0) { - h6.setDataBufferBin(i, meanE / nE); + canvas.draw(h501); + canvas.draw(h502,"same"); + canvas.cd(4); + canvas.draw(h503,""); + canvas.draw(h504,"same"); + + + for (int i = 0; i < h6.getDataBufferSize(); i++) { + float meanE = h6.getDataBufferBin(i); + float nE = h7.getDataBufferBin(i); + if (nE > 0) { + h6.setDataBufferBin(i, meanE / nE); + } } - } - canvas.cd(5); -// canvas.draw(h7); - canvas.draw(h507); - canvas.cd(6); -// canvas.draw(h8); - canvas.draw(h600); - canvas.cd(7); -// canvas.draw(h9); - canvas.draw(h601); - canvas.cd(8); -// canvas.draw(h10); - canvas.draw(h602); - canvas.draw(h603,"same"); - frame.add(canvas); - frame.setLocationRelativeTo(null); - frame.setVisible(true); + canvas.cd(5); + // canvas.draw(h7); + canvas.draw(h507); + canvas.cd(6); + // canvas.draw(h8); + canvas.draw(h600); + canvas.cd(7); + // canvas.draw(h9); + canvas.draw(h601); + canvas.cd(8); + // canvas.draw(h10); + canvas.draw(h602); + canvas.draw(h603,"same"); + frame.add(canvas); + frame.setLocationRelativeTo(null); + frame.setVisible(true); - double narrowFactor = 7.; // was 4.5 - JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); - frametrk.setSize(1600, 800); - EmbeddedCanvas canvastrk = new EmbeddedCanvas(); - canvastrk.divide(5, 2); - canvastrk.cd(0); - canvastrk.draw(h100); - canvastrk.cd(1); - canvastrk.draw(h102); - F1D f02 = new F1D("f02","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); - f02.setParameter(0, 10.0); - f02.setParameter(1, 0.0); - f02.setParameter(2, 1.0); - f02.setLineColor(6); - f02.setLineWidth(3); - DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma - f02.setParameter(0, f02.parameter(0).value()); - f02.setParameter(1, f02.parameter(1).value()); - f02.setParameter(2, f02.parameter(2).value()); - DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma - f02.setOptStat(11111); - canvastrk.draw(f02,"same"); - canvastrk.cd(2); - canvastrk.draw(h104); - F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/(narrowFactor)); - f04.setParameter(0, 10.0); - f04.setParameter(1, 0.0); - f04.setParameter(2, 1.0); - f04.setLineColor(6); - f04.setLineWidth(3); - DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma - f04.setParameter(0, f04.parameter(0).value()); - f04.setParameter(1, f04.parameter(1).value()); - f04.setParameter(2, f04.parameter(2).value()); - DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma - f04.setOptStat(11111); - canvastrk.draw(f04,"same"); - canvastrk.cd(3); - canvastrk.draw(h106); - F1D f06 = new F1D("f06","[amp]*gaus(x,[mean],[sigma])", -limTCTheta/narrowFactor, limTCTheta/narrowFactor); - f06.setParameter(0, 10.0); - f06.setParameter(1, h106.getMean()); - f06.setParameter(2, h106.getRMS()); - f06.setLineColor(6); - f06.setLineWidth(3); - DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma - f06.setParameter(0, f06.parameter(0).value()); - f06.setParameter(1, f06.parameter(1).value()); - f06.setParameter(2, f06.parameter(2).value()); - DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma - f06.setOptStat(11111); - canvastrk.draw(f06,"same"); - canvastrk.cd(4); - canvastrk.draw(h108); - F1D f08 = new F1D("f08","[amp]*gaus(x,[mean],[sigma])", -limTCPhi/narrowFactor, limTCPhi/narrowFactor); - f08.setParameter(0, h108.getMax()); - f08.setParameter(1, h108.getMean()); - f08.setParameter(2, h108.getRMS()); - f08.setLineColor(6); - f08.setLineWidth(3); - DataFitter.fit(f08, h108, "Q"); //No options uses error for sigma - f08.setOptStat(11111); - canvastrk.draw(f08,"same"); - - canvastrk.cd(5); - canvastrk.draw(h101); - - canvastrk.cd(6); - canvastrk.draw(h103); - F1D f03 = new F1D("f03","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); - f03.setParameter(0, 10.0); - f03.setParameter(1, 0.0); - f03.setParameter(2, 1.0); - f03.setLineColor(6); - f03.setLineWidth(3); - DataFitter.fit(f03, h103, "Q"); //No options uses error for sigma - f03.setParameter(0, f03.parameter(0).value()); - f03.setParameter(1, f03.parameter(1).value()); - f03.setParameter(2, f03.parameter(2).value()); - DataFitter.fit(f03, h103, "Q"); //No options uses error for sigma - f03.setOptStat(1111); - canvastrk.draw(f03,"same"); - - - canvastrk.cd(7); - canvastrk.draw(h105); - F1D f05 = new F1D("f05","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); - f05.setParameter(0, 10.0); - f05.setParameter(1, 0.0); - f05.setParameter(2, 1.0); - f05.setLineColor(6); - f05.setLineWidth(3); - DataFitter.fit(f05, h105, "Q"); //No options uses error for sigma - f05.setParameter(0, f05.parameter(0).value()); - f05.setParameter(1, f05.parameter(1).value()); - f05.setParameter(2, f05.parameter(2).value()); - DataFitter.fit(f05, h105, "Q"); //No options uses error for sigma - f05.setOptStat(1111); - canvastrk.draw(f05,"same"); - - canvastrk.cd(8); - canvastrk.draw(h107); - F1D f07 = new F1D("f07","[amp]*gaus(x,[mean],[sigma])", -limTCTheta/narrowFactor, limTCTheta/narrowFactor); - f07.setParameter(0, h107.getMax()); - f07.setParameter(1, h107.getMean()); - f07.setParameter(2, h107.getRMS()); - f07.setLineColor(6); - f07.setLineWidth(3); - DataFitter.fit(f07, h107, "Q"); //No options uses error for sigma - f07.setOptStat(1111); - canvastrk.draw(f07,"same"); - - canvastrk.cd(9); - canvastrk.draw(h109); - F1D f09 = new F1D("f09","[amp]*gaus(x,[mean],[sigma])", -limTCPhi/narrowFactor, limTCPhi/narrowFactor); - f09.setParameter(0, h109.getMax()); - f09.setParameter(1, h109.getMean()); - f09.setParameter(2, h109.getRMS()); - f09.setLineColor(6); - f09.setLineWidth(3); - DataFitter.fit(f09, h109, "Q"); //No options uses error for sigma - f09.setParameter(0, f09.parameter(0).value()); - f09.setParameter(1, f09.parameter(1).value()); - f09.setParameter(2, f09.parameter(2).value()); - DataFitter.fit(f09, h109, "Q"); //No options uses error for sigma - f09.setOptStat(1111); - canvastrk.draw(f09,"same"); - frametrk.add(canvastrk); - frametrk.setLocationRelativeTo(null); - frametrk.setVisible(true); + double narrowFactor = 7.; // was 4.5 + JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); + frametrk.setSize(1600, 800); + EmbeddedCanvas canvastrk = new EmbeddedCanvas(); + canvastrk.divide(5, 2); + canvastrk.cd(0); + canvastrk.draw(h100); + canvastrk.cd(1); + canvastrk.draw(h102); + F1D f02 = new F1D("f02","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); + f02.setParameter(0, 10.0); + f02.setParameter(1, 0.0); + f02.setParameter(2, 1.0); + f02.setLineColor(6); + f02.setLineWidth(3); + DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma + f02.setParameter(0, f02.parameter(0).value()); + f02.setParameter(1, f02.parameter(1).value()); + f02.setParameter(2, f02.parameter(2).value()); + DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma + f02.setOptStat(11111); + canvastrk.draw(f02,"same"); + canvastrk.cd(2); + canvastrk.draw(h104); + F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/(narrowFactor)); + f04.setParameter(0, 10.0); + f04.setParameter(1, 0.0); + f04.setParameter(2, 1.0); + f04.setLineColor(6); + f04.setLineWidth(3); + DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma + f04.setParameter(0, f04.parameter(0).value()); + f04.setParameter(1, f04.parameter(1).value()); + f04.setParameter(2, f04.parameter(2).value()); + DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma + f04.setOptStat(11111); + canvastrk.draw(f04,"same"); + canvastrk.cd(3); + canvastrk.draw(h106); + F1D f06 = new F1D("f06","[amp]*gaus(x,[mean],[sigma])", -limTCTheta/narrowFactor, limTCTheta/narrowFactor); + f06.setParameter(0, 10.0); + f06.setParameter(1, h106.getMean()); + f06.setParameter(2, h106.getRMS()); + f06.setLineColor(6); + f06.setLineWidth(3); + DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma + f06.setParameter(0, f06.parameter(0).value()); + f06.setParameter(1, f06.parameter(1).value()); + f06.setParameter(2, f06.parameter(2).value()); + DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma + f06.setOptStat(11111); + canvastrk.draw(f06,"same"); + canvastrk.cd(4); + canvastrk.draw(h108); + F1D f08 = new F1D("f08","[amp]*gaus(x,[mean],[sigma])", -limTCPhi/narrowFactor, limTCPhi/narrowFactor); + f08.setParameter(0, h108.getMax()); + f08.setParameter(1, h108.getMean()); + f08.setParameter(2, h108.getRMS()); + f08.setLineColor(6); + f08.setLineWidth(3); + DataFitter.fit(f08, h108, "Q"); //No options uses error for sigma + f08.setOptStat(11111); + canvastrk.draw(f08,"same"); + + canvastrk.cd(5); + canvastrk.draw(h101); + + canvastrk.cd(6); + canvastrk.draw(h103); + F1D f03 = new F1D("f03","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); + f03.setParameter(0, 10.0); + f03.setParameter(1, 0.0); + f03.setParameter(2, 1.0); + f03.setLineColor(6); + f03.setLineWidth(3); + DataFitter.fit(f03, h103, "Q"); //No options uses error for sigma + f03.setParameter(0, f03.parameter(0).value()); + f03.setParameter(1, f03.parameter(1).value()); + f03.setParameter(2, f03.parameter(2).value()); + DataFitter.fit(f03, h103, "Q"); //No options uses error for sigma + f03.setOptStat(1111); + canvastrk.draw(f03,"same"); + + + canvastrk.cd(7); + canvastrk.draw(h105); + F1D f05 = new F1D("f05","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); + f05.setParameter(0, 10.0); + f05.setParameter(1, 0.0); + f05.setParameter(2, 1.0); + f05.setLineColor(6); + f05.setLineWidth(3); + DataFitter.fit(f05, h105, "Q"); //No options uses error for sigma + f05.setParameter(0, f05.parameter(0).value()); + f05.setParameter(1, f05.parameter(1).value()); + f05.setParameter(2, f05.parameter(2).value()); + DataFitter.fit(f05, h105, "Q"); //No options uses error for sigma + f05.setOptStat(1111); + canvastrk.draw(f05,"same"); + + canvastrk.cd(8); + canvastrk.draw(h107); + F1D f07 = new F1D("f07","[amp]*gaus(x,[mean],[sigma])", -limTCTheta/narrowFactor, limTCTheta/narrowFactor); + f07.setParameter(0, h107.getMax()); + f07.setParameter(1, h107.getMean()); + f07.setParameter(2, h107.getRMS()); + f07.setLineColor(6); + f07.setLineWidth(3); + DataFitter.fit(f07, h107, "Q"); //No options uses error for sigma + f07.setOptStat(1111); + canvastrk.draw(f07,"same"); + + canvastrk.cd(9); + canvastrk.draw(h109); + F1D f09 = new F1D("f09","[amp]*gaus(x,[mean],[sigma])", -limTCPhi/narrowFactor, limTCPhi/narrowFactor); + f09.setParameter(0, h109.getMax()); + f09.setParameter(1, h109.getMean()); + f09.setParameter(2, h109.getRMS()); + f09.setLineColor(6); + f09.setLineWidth(3); + DataFitter.fit(f09, h109, "Q"); //No options uses error for sigma + f09.setParameter(0, f09.parameter(0).value()); + f09.setParameter(1, f09.parameter(1).value()); + f09.setParameter(2, f09.parameter(2).value()); + DataFitter.fit(f09, h109, "Q"); //No options uses error for sigma + f09.setOptStat(1111); + canvastrk.draw(f09,"same"); + frametrk.add(canvastrk); + frametrk.setLocationRelativeTo(null); + frametrk.setVisible(true); + } JFrame frametrkres = new JFrame("FTTRK Resolutions wrt MC generated events"); frametrkres.setSize(1800, 800); @@ -1394,20 +1238,6 @@ public static void main(String arg[]){ frametrkrel.setLocationRelativeTo(null); frametrkrel.setVisible(true); - /* - JFrame frameMCradio = new JFrame("Montecarlo radiography of vertex"); - frameMCradio.setSize(1000,500); - EmbeddedCanvas canvasMCradio = new EmbeddedCanvas(); - canvasMCradio.divide(2,1); - canvasMCradio.cd(0); - canvasMCradio.draw(h2000); - canvasMCradio.cd(1); - canvasMCradio.draw(h2001); - frameMCradio.add(canvasMCradio); - frameMCradio.setLocationRelativeTo(null); - frameMCradio.setVisible(true); - */ - JFrame frameSecradio = new JFrame("20 sectors occupancy"); frameSecradio.setSize(1000,500); EmbeddedCanvas canvasSecradio = new EmbeddedCanvas(); @@ -1637,41 +1467,43 @@ public static void main(String arg[]){ frameCALTRK.setLocationRelativeTo(null); frameCALTRK.setVisible(true); - JFrame frameStripET = new JFrame("strip energy and time studies"); - frameStripET.setSize(1500, 1000); - EmbeddedCanvas canvasStripET = new EmbeddedCanvas(); - canvasStripET.divide(4,2); - canvasStripET.cd(0); - canvasStripET.draw(h510); - canvasStripET.cd(1); - canvasStripET.draw(h511); - canvasStripET.cd(2); - h512.setFillColor(53); h513.setFillColor(58); - h512.setOptStat(Integer.parseInt("11")); - h513.setOptStat(Integer.parseInt("11")); - canvasStripET.draw(h512); - canvasStripET.cd(3); - canvasStripET.draw(h513); - - h520.setFillColor(54); h521.setFillColor(59); h522.setFillColor(52); h523.setFillColor(57); - h520.setOptStat(Integer.parseInt("11")); - h521.setOptStat(Integer.parseInt("11")); - h522.setOptStat(Integer.parseInt("11")); - h523.setOptStat(Integer.parseInt("11")); - canvasStripET.cd(4); - canvasStripET.draw(h520); - canvasStripET.cd(5); - canvasStripET.draw(h521); - canvasStripET.cd(6); - canvasStripET.draw(h522); - canvasStripET.cd(7); - canvasStripET.draw(h523); - frameStripET.add(canvasStripET); - frameStripET.setLocationRelativeTo(null); - frameStripET.setVisible(true); + if(plotDiagnosticHistograms){ + JFrame frameStripET = new JFrame("strip energy and time studies"); + frameStripET.setSize(1500, 1000); + EmbeddedCanvas canvasStripET = new EmbeddedCanvas(); + canvasStripET.divide(4,2); + canvasStripET.cd(0); + canvasStripET.draw(h510); + canvasStripET.cd(1); + canvasStripET.draw(h511); + canvasStripET.cd(2); + h512.setFillColor(53); h513.setFillColor(58); + h512.setOptStat(Integer.parseInt("11")); + h513.setOptStat(Integer.parseInt("11")); + canvasStripET.draw(h512); + canvasStripET.cd(3); + canvasStripET.draw(h513); + + h520.setFillColor(54); h521.setFillColor(59); h522.setFillColor(52); h523.setFillColor(57); + h520.setOptStat(Integer.parseInt("11")); + h521.setOptStat(Integer.parseInt("11")); + h522.setOptStat(Integer.parseInt("11")); + h523.setOptStat(Integer.parseInt("11")); + canvasStripET.cd(4); + canvasStripET.draw(h520); + canvasStripET.cd(5); + canvasStripET.draw(h521); + canvasStripET.cd(6); + canvasStripET.draw(h522); + canvasStripET.cd(7); + canvasStripET.draw(h523); + frameStripET.add(canvasStripET); + frameStripET.setLocationRelativeTo(null); + frameStripET.setVisible(true); + } - JFrame frameOccMatchSeed = new JFrame("strip occupancy clutsre seed for matched crosses"); + JFrame frameOccMatchSeed = new JFrame("strip occupancy cluster seed for matched crosses"); frameOccMatchSeed.setSize(1200,800); h71.setOptStat(11); h72.setOptStat(11); h73.setOptStat(11); h74.setOptStat(11); EmbeddedCanvas canvasOccMatchSeed = new EmbeddedCanvas(); @@ -1705,96 +1537,96 @@ public static void main(String arg[]){ frameOccMatch.setLocationRelativeTo(null); frameOccMatch.setVisible(true); - /* - JFrame frametrkonlyres = new JFrame("FTTRK residuals with respect to the second detector"); - frametrkonlyres.setSize(1600, 800); - EmbeddedCanvas canvastrkonlyres = new EmbeddedCanvas(); - canvastrkonlyres.divide(4, 2); - int nc=-1; - canvastrkonlyres.cd(++nc); - canvastrkonlyres.draw(resTrkXdet0); - double lowLim = resTrkXdet0.getMean() - resTrkXdet0.getRMS()/1.5; - double upLim = resTrkXdet0.getMean() + resTrkXdet0.getRMS()/1.5; - F1D f10x = new F1D("f10x","[amp]*gaus(x,[mean],[sigma])", lowLim, upLim); - f10x.setParameter(0, resTrkXdet0.getMax()); - f10x.setParameter(1, resTrkXdet0.getMean()); - f10x.setParameter(2, resTrkXdet0.getRMS()); - f10x.setLineColor(6); - f10x.setLineWidth(3); - DataFitter.fit(f10x, resTrkXdet0, " "); //No options uses error for sigma - f10x.setParameter(0, f10x.parameter(0).value()); - f10x.setParameter(1, f10x.parameter(1).value()); - f10x.setParameter(2, f10x.parameter(2).value()); - DataFitter.fit(f10x, resTrkXdet0, " "); //No options uses error for sigma - f10x.setOptStat(11111); - canvastrkonlyres.draw(f10x,"same"); - - canvastrkonlyres.cd(++nc); - canvastrkonlyres.draw(resTrkYdet0); - lowLim = resTrkYdet0.getMean() - resTrkYdet0.getRMS()/1.5; - upLim = resTrkYdet0.getMean() + resTrkYdet0.getRMS()/1.5; - F1D f10y = new F1D("f10y","[amp]*gaus(x,[mean],[sigma])", lowLim, upLim); - f10y.setParameter(0, resTrkYdet0.getMax()); - f10y.setParameter(1, resTrkYdet0.getMean()); - f10y.setParameter(2, resTrkYdet0.getRMS()); - f10y.setLineColor(6); - f10y.setLineWidth(3); - DataFitter.fit(f10y, resTrkYdet0, "Q"); //No options uses error for sigma - f10y.setParameter(0, f10y.parameter(0).value()); - f10y.setParameter(1, f10y.parameter(1).value()); - f10y.setParameter(2, f10y.parameter(2).value()); - DataFitter.fit(f10y, resTrkYdet0, "Q"); //No options uses error for sigma - f10y.setOptStat(11111); - canvastrkonlyres.draw(f10y,"same"); - - canvastrkonlyres.cd(++nc); - canvastrkonlyres.draw(resTrkThetadet0); - canvastrkonlyres.cd(++nc); - canvastrkonlyres.draw(resTrkPhidet0); - - canvastrkonlyres.cd(++nc); - canvastrkonlyres.draw(resTrkXdet1); - lowLim = resTrkXdet1.getMean() - resTrkXdet1.getRMS()/1.5; - upLim = resTrkXdet1.getMean() + resTrkXdet1.getRMS()/1.5; - F1D f11x = new F1D("f11x","[amp]*gaus(x,[mean],[sigma])", lowLim, upLim); - f11x.setParameter(0, resTrkXdet1.getMax()); - f11x.setParameter(1, resTrkXdet1.getMean()); - f11x.setParameter(2, resTrkXdet1.getRMS()); - f11x.setLineColor(6); - f11x.setLineWidth(3); - DataFitter.fit(f11x, resTrkXdet1, "Q"); //No options uses error for sigma - f11x.setParameter(0, f11x.parameter(0).value()); - f11x.setParameter(1, f11x.parameter(1).value()); - f11x.setParameter(2, f11x.parameter(2).value()); - DataFitter.fit(f11x, resTrkXdet1, "Q"); //No options uses error for sigma - f11x.setOptStat(11111); - canvastrkonlyres.draw(f11x,"same"); - - canvastrkonlyres.cd(++nc); - canvastrkonlyres.draw(resTrkYdet1); - lowLim = resTrkYdet1.getMean() - resTrkYdet1.getRMS()/1.5; - upLim = resTrkYdet1.getMean() + resTrkYdet1.getRMS()/1.5; - F1D f11y = new F1D("f11y","[amp]*gaus(x,[mean],[sigma])", lowLim, upLim); - f11y.setParameter(0, resTrkYdet1.getMax()); - f11y.setParameter(1, resTrkYdet1.getMean()); - f11y.setParameter(2, resTrkYdet1.getRMS()); - f11y.setLineColor(6); - f11y.setLineWidth(3); - DataFitter.fit(f11y, resTrkYdet1, "Q"); //No options uses error for sigma - f11y.setParameter(0, f11y.parameter(0).value()); - f11y.setParameter(1, f11y.parameter(1).value()); - f11y.setParameter(2, f11y.parameter(2).value()); - DataFitter.fit(f11y, resTrkYdet1, "Q"); //No options uses error for sigma - f11y.setOptStat(11111); - canvastrkonlyres.draw(f11y,"same"); - canvastrkonlyres.cd(++nc); - canvastrkonlyres.draw(resTrkThetadet1); - canvastrkonlyres.cd(++nc); - canvastrkonlyres.draw(resTrkPhidet1); - frametrkonlyres.add(canvastrkonlyres); - frametrkonlyres.setLocationRelativeTo(null); - frametrkonlyres.setVisible(true); - */ + if(plotDiagnosticHistograms){ + JFrame frametrkonlyres = new JFrame("FTTRK residuals with respect to the second detector"); + frametrkonlyres.setSize(1600, 800); + EmbeddedCanvas canvastrkonlyres = new EmbeddedCanvas(); + canvastrkonlyres.divide(4, 2); + int nc=-1; + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkXdet0); + double lowLim = resTrkXdet0.getMean() - resTrkXdet0.getRMS()/1.5; + double upLim = resTrkXdet0.getMean() + resTrkXdet0.getRMS()/1.5; + F1D f10x = new F1D("f10x","[amp]*gaus(x,[mean],[sigma])", lowLim, upLim); + f10x.setParameter(0, resTrkXdet0.getMax()); + f10x.setParameter(1, resTrkXdet0.getMean()); + f10x.setParameter(2, resTrkXdet0.getRMS()); + f10x.setLineColor(6); + f10x.setLineWidth(3); + DataFitter.fit(f10x, resTrkXdet0, " "); //No options uses error for sigma + f10x.setParameter(0, f10x.parameter(0).value()); + f10x.setParameter(1, f10x.parameter(1).value()); + f10x.setParameter(2, f10x.parameter(2).value()); + DataFitter.fit(f10x, resTrkXdet0, " "); //No options uses error for sigma + f10x.setOptStat(11111); + canvastrkonlyres.draw(f10x,"same"); + + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkYdet0); + lowLim = resTrkYdet0.getMean() - resTrkYdet0.getRMS()/1.5; + upLim = resTrkYdet0.getMean() + resTrkYdet0.getRMS()/1.5; + F1D f10y = new F1D("f10y","[amp]*gaus(x,[mean],[sigma])", lowLim, upLim); + f10y.setParameter(0, resTrkYdet0.getMax()); + f10y.setParameter(1, resTrkYdet0.getMean()); + f10y.setParameter(2, resTrkYdet0.getRMS()); + f10y.setLineColor(6); + f10y.setLineWidth(3); + DataFitter.fit(f10y, resTrkYdet0, "Q"); //No options uses error for sigma + f10y.setParameter(0, f10y.parameter(0).value()); + f10y.setParameter(1, f10y.parameter(1).value()); + f10y.setParameter(2, f10y.parameter(2).value()); + DataFitter.fit(f10y, resTrkYdet0, "Q"); //No options uses error for sigma + f10y.setOptStat(11111); + canvastrkonlyres.draw(f10y,"same"); + + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkThetadet0); + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkPhidet0); + + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkXdet1); + lowLim = resTrkXdet1.getMean() - resTrkXdet1.getRMS()/1.5; + upLim = resTrkXdet1.getMean() + resTrkXdet1.getRMS()/1.5; + F1D f11x = new F1D("f11x","[amp]*gaus(x,[mean],[sigma])", lowLim, upLim); + f11x.setParameter(0, resTrkXdet1.getMax()); + f11x.setParameter(1, resTrkXdet1.getMean()); + f11x.setParameter(2, resTrkXdet1.getRMS()); + f11x.setLineColor(6); + f11x.setLineWidth(3); + DataFitter.fit(f11x, resTrkXdet1, "Q"); //No options uses error for sigma + f11x.setParameter(0, f11x.parameter(0).value()); + f11x.setParameter(1, f11x.parameter(1).value()); + f11x.setParameter(2, f11x.parameter(2).value()); + DataFitter.fit(f11x, resTrkXdet1, "Q"); //No options uses error for sigma + f11x.setOptStat(11111); + canvastrkonlyres.draw(f11x,"same"); + + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkYdet1); + lowLim = resTrkYdet1.getMean() - resTrkYdet1.getRMS()/1.5; + upLim = resTrkYdet1.getMean() + resTrkYdet1.getRMS()/1.5; + F1D f11y = new F1D("f11y","[amp]*gaus(x,[mean],[sigma])", lowLim, upLim); + f11y.setParameter(0, resTrkYdet1.getMax()); + f11y.setParameter(1, resTrkYdet1.getMean()); + f11y.setParameter(2, resTrkYdet1.getRMS()); + f11y.setLineColor(6); + f11y.setLineWidth(3); + DataFitter.fit(f11y, resTrkYdet1, "Q"); //No options uses error for sigma + f11y.setParameter(0, f11y.parameter(0).value()); + f11y.setParameter(1, f11y.parameter(1).value()); + f11y.setParameter(2, f11y.parameter(2).value()); + DataFitter.fit(f11y, resTrkYdet1, "Q"); //No options uses error for sigma + f11y.setOptStat(11111); + canvastrkonlyres.draw(f11y,"same"); + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkThetadet1); + canvastrkonlyres.cd(++nc); + canvastrkonlyres.draw(resTrkPhidet1); + frametrkonlyres.add(canvastrkonlyres); + frametrkonlyres.setLocationRelativeTo(null); + frametrkonlyres.setVisible(true); + } } From 676a23905d3c1dcd272a92feddac88f79c33d0d1 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Fri, 18 Feb 2022 14:52:11 +0100 Subject: [PATCH 068/104] narrow radial tolerance --- .../ft/src/main/java/org/jlab/rec/ft/FTConstants.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java index 9fd6e04157..7c285e8d83 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java @@ -24,9 +24,9 @@ public class FTConstants { public static final double TRK_STRIP_MAX_TIME = 350; // minimum time value associated to one strip public static final double TRK_MIN_CROSS_NUMBER = 1; // minimum number of crosses to find a line in the tracker - public static final double TRK0_TRK1_RADTOL = 0.1; // max tolerance for TRK0/TRK1 distance (3D) (was 1.-0.5) + public static final double TRK0_TRK1_RADTOL = 0.05; // max tolerance for TRK0/TRK1 distance (3D) (was 1.-0.5) public static final double TRK0_TRK1_PHITOL = 0.07; // max tolerance for TRK0/TRK1 phi angular deviation (was 1.-0.7) - public static final double TRK0_TRK1_THETATOL = 0.07; // max tolerance for TRK0/TRK1 theta angulare deviation (was 1.-0.7= + public static final double TRK0_TRK1_THETATOL = 0.07; // max tolerance for TRK0/TRK1 theta angulare deviation (was 1.-0.7) public static final double FTTRKMinAdcThreshold = 18.; // check min threshold for FTTTRK ADCs (18) public static final double FTTRKMaxAdcThreshold = 2000.; // check max threshold for FTTTRK ADCs (18) was 1000 170122 From 8e62e9c396600ee2da1b6c5f0e203f4576a6a3b4 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Fri, 18 Feb 2022 14:53:04 +0100 Subject: [PATCH 069/104] fix nominal center of target position --- .../java/org/jlab/rec/ft/FTEBEngineSingleEvent.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java index efe120f329..7da94edf7d 100755 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java @@ -168,7 +168,7 @@ public int getDebugMode() { public static H2F hSeedDet0 = new H2F("lay 2 vs lay1 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); public static H2F hSeedDet1 = new H2F("lay 4 vs lay3 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); - public static Point3D ORIGIN = new Point3D(0., 0., 0.); + public static Point3D centerOfTarget = new Point3D(0., 0., -3.); public static void main(String arg[]){ @@ -695,9 +695,9 @@ public static void main(String arg[]){ canvasCALTRK.draw(segment2); } - double cx = hitOnTrk.x() - ORIGIN.x(); - double cy = hitOnTrk.y() - ORIGIN.y(); - double cz = hitOnTrk.z() - ORIGIN.z(); + double cx = hitOnTrk.x() - centerOfTarget.x(); + double cy = hitOnTrk.y() - centerOfTarget.y(); + double cz = hitOnTrk.z() - centerOfTarget.z(); for(int ncj = 0; ncj < ncrosses; ncj++) { int det1 = banktrk.getInt("detector", ncj); if(det1 >=0 && nc != ncj && det != det1){ @@ -706,8 +706,8 @@ public static void main(String arg[]){ double z1 = banktrk.getFloat("z", ncj); int secondCrossID = banktrk.getInt("id", ncj); Vector3D cross = new Vector3D(x1, y1, z1); - double t = cross.z()/hitOnTrk.z(); - Vector3D pointOnTrackAtZ = new Vector3D(cx*t + ORIGIN.x(), cy*t + ORIGIN.y(), z1); + double t = (cross.z()-centerOfTarget.z())/hitOnTrk.z(); + Vector3D pointOnTrackAtZ = new Vector3D(cx*t + centerOfTarget.x(), cy*t + centerOfTarget.y(), z1); if(det1 == 1 && trk1ID == secondCrossID){ resTrkXdet0.fill(pointOnTrackAtZ.x() - cross.x()); resTrkYdet0.fill(pointOnTrackAtZ.y() - cross.y()); From e97cc9bc0f585d420c01d65662b9b73521437aa1 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Fri, 18 Feb 2022 14:53:52 +0100 Subject: [PATCH 070/104] fix nominal center of target position, add histograms for TRK resolution studies --- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 83 ++++++++++++++----- 1 file changed, 60 insertions(+), 23 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index 4eeaf33b96..2d32423b46 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -70,7 +70,7 @@ public class FTEBEngine extends ReconstructionEngine { public static H2F hSeedDet0 = new H2F("lay 2 vs lay1 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); public static H2F hSeedDet1 = new H2F("lay 4 vs lay3 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); - public static Point3D ORIGIN = new Point3D(0., 0., 0.); + public static Point3D centerOfTarget = new Point3D(0., 0., -3.); @@ -303,6 +303,19 @@ public static void main(String arg[]){ resTrkPhidet1.setTitleX("trk0 phi residual (rad) wrt line thru trk1"); resTrkPhidet1.setFillColor(49); + H2F resTrkXVsXdet0 = new H2F("trk1 x residual wrt line thru trk0 vs X", 50, -15., 15., 63, -0.5, 0.5); + resTrkXVsXdet0.setTitleX("trk1 x (mm)"); + resTrkXVsXdet0.setTitleY("trk1 x residual (mm) wrt line thru trk0"); + H2F resTrkYVsYdet0 = new H2F("trk1 y residual wrt line thru trk0 vs Y", 50, -15., 15., 63, -0.5, 0.5); + resTrkYVsYdet0.setTitleX("trk1 y (mm)"); + resTrkYVsYdet0.setTitleY("trk1 y residual (mm) wrt line thru trk0"); + H2F resTrkXVsXdet1 = new H2F("trk0 x residual wrt line thru trk1 vs X", 50, -15., 15., 63, -0.5, 0.5); + resTrkXVsXdet1.setTitleX("trk0 x (mm)"); + resTrkXVsXdet1.setTitleY("trk0 x residual (mm) wrt line thru trk1"); + H2F resTrkYVsYdet1 = new H2F("trk0 y residual wrt line thru trk1 vs Y", 50, -15., 15., 63, -0.5, 0.5); + resTrkYVsYdet1.setTitleX("trk0 y (mm)"); + resTrkYVsYdet1.setTitleY("trk0 y residual (mm) wrt line thru trk1"); + H1F h202 = new H1F("trk1 x", 25, 8.2, 9.0); H1F h1202 = new H1F("trk1 x MC", 25, 8.2, 9.0); h202.setOptStat(0); @@ -604,15 +617,17 @@ public static void main(String arg[]){ // extract the mumber of strips forming the cross and store them in an occupancy plot for matched signals // which strips are forming the id cross? - if(lay1==1){h71.fill(seed1);} - else if(lay1==2){h72.fill(seed1);} - else if(lay1==3){h73.fill(seed1);} - else if(lay1==4){h74.fill(seed1);} + if(lay1==1){h71.fill(seed1); + }else if(lay1==2){h72.fill(seed1); + }else if(lay1==3){h73.fill(seed1); + }else if(lay1==4){h74.fill(seed1); + } - if(lay2==1){h71.fill(seed2);} - else if(lay2==2){h72.fill(seed2);} - else if(lay2==3){h73.fill(seed2);} - else if(lay2==4){h74.fill(seed2);} + if(lay2==1){h71.fill(seed2); + }else if(lay2==2){h72.fill(seed2); + }else if(lay2==3){h73.fill(seed2); + }else if(lay2==4){h74.fill(seed2); + } DataBank bankhit = event.getBank("FTTRK::hits"); if(bankhit.rows()>0){ @@ -621,10 +636,11 @@ public static void main(String arg[]){ if(clusterNum != icl1 && clusterNum != icl2) continue; int stripInCluster = bankhit.getInt("component", k); int clusterLay = bankhit.getInt("layer", k); - if(clusterLay==1){h81.fill(stripInCluster);} - else if(clusterLay==2){h82.fill(stripInCluster);} - else if(clusterLay==3){h83.fill(stripInCluster);} - else if(clusterLay==4){h84.fill(stripInCluster);} + if(clusterLay==1){h81.fill(stripInCluster); + }else if(clusterLay==2){h82.fill(stripInCluster); + }else if(clusterLay==3){h83.fill(stripInCluster); + }else if(clusterLay==4){h84.fill(stripInCluster); + } } } } @@ -679,9 +695,9 @@ public static void main(String arg[]){ // extract residuals of TRK1 wrt TRK0 and viceversa // loop on crosses in det0, find track connecting with origin, evaluate residuals of TRK1 hits wrt to this track - double cx = hitOnTrk.x() - ORIGIN.x(); - double cy = hitOnTrk.y() - ORIGIN.y(); - double cz = hitOnTrk.z() - ORIGIN.z(); + double cx = hitOnTrk.x() - centerOfTarget.x(); + double cy = hitOnTrk.y() - centerOfTarget.y(); + double cz = hitOnTrk.z() - centerOfTarget.z(); for(int ncj = 0; ncj < ncrosses; ncj++) { int det1 = banktrk.getInt("detector", ncj); if(det1 >=0 && nc != ncj && det != det1){ @@ -700,18 +716,22 @@ public static void main(String arg[]){ double diffPhi = Math.atan2(hitOnTrk.y(), hitOnTrk.x()) - Math.atan2(cross.y(), cross.x()); if(Math.abs(diffPhi) < diffPhiTolerance && Math.abs(diffRadii)< diffRadTolerance && Math.abs(diffTheta) < diffThetaTolerance){ - double t = cross.z()/hitOnTrk.z(); - Vector3D pointOnTrackAtZ = new Vector3D(cx*t + ORIGIN.x(), cy*t + ORIGIN.y(), z1); + double t = (cross.z()-centerOfTarget.z())/hitOnTrk.z(); + Vector3D pointOnTrackAtZ = new Vector3D(cx*t + centerOfTarget.x(), cy*t + centerOfTarget.y(), z1); if(det1 == 1 && trk1ID == secondCrossID){ resTrkXdet0.fill(pointOnTrackAtZ.x() - cross.x()); resTrkYdet0.fill(pointOnTrackAtZ.y() - cross.y()); resTrkThetadet0.fill(pointOnTrackAtZ.theta() - cross.theta()); resTrkPhidet0.fill(pointOnTrackAtZ.phi() - cross.phi()); + resTrkXVsXdet0.fill(cross.x(), pointOnTrackAtZ.x() - cross.x()); + resTrkYVsYdet0.fill(cross.y(), pointOnTrackAtZ.y() - cross.y()); }else if(det1 == 0 && trk0ID == secondCrossID){ resTrkXdet1.fill(pointOnTrackAtZ.x() - cross.x()); resTrkYdet1.fill(pointOnTrackAtZ.y() - cross.y()); resTrkThetadet1.fill(pointOnTrackAtZ.theta() - cross.theta()); resTrkPhidet1.fill(pointOnTrackAtZ.phi() - cross.phi()); + resTrkXVsXdet1.fill(cross.x(), pointOnTrackAtZ.x() - cross.x()); + resTrkYVsYdet1.fill(cross.y(), pointOnTrackAtZ.y() - cross.y()); } } } @@ -907,7 +927,7 @@ public static void main(String arg[]){ frame.setVisible(true); } - double narrowFactor = 7.; // was 4.5 + double narrowFactor = 7.5; // was 4.5 JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); frametrk.setSize(1600, 800); EmbeddedCanvas canvastrk = new EmbeddedCanvas(); @@ -932,9 +952,9 @@ public static void main(String arg[]){ canvastrk.cd(2); canvastrk.draw(h104); F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/(narrowFactor)); - f04.setParameter(0, 10.0); - f04.setParameter(1, 0.0); - f04.setParameter(2, 1.0); + f04.setParameter(0, h104.getMax()); + f04.setParameter(1, h104.getMean()); + f04.setParameter(2, h104.getRMS()/2.); f04.setLineColor(6); f04.setLineWidth(3); DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma @@ -1607,6 +1627,23 @@ public static void main(String arg[]){ canvastrkonlyres.draw(resTrkPhidet1); frametrkonlyres.add(canvastrkonlyres); frametrkonlyres.setLocationRelativeTo(null); - frametrkonlyres.setVisible(true); + frametrkonlyres.setVisible(true); + + JFrame frametrkonlyresVsCoord = new JFrame("FTTRK residuals wrt 2nd detector vs 2nd det coordinate"); + frametrkonlyresVsCoord.setSize(1000, 800); + EmbeddedCanvas canvastrkonlyresVsCoord = new EmbeddedCanvas(); + canvastrkonlyresVsCoord.divide(2, 2); + nc=-1; + canvastrkonlyresVsCoord.cd(++nc); + canvastrkonlyresVsCoord.draw(resTrkXVsXdet0); + canvastrkonlyresVsCoord.cd(++nc); + canvastrkonlyresVsCoord.draw(resTrkYVsYdet0); + canvastrkonlyresVsCoord.cd(++nc); + canvastrkonlyresVsCoord.draw(resTrkXVsXdet1); + canvastrkonlyresVsCoord.cd(++nc); + canvastrkonlyresVsCoord.draw(resTrkYVsYdet1); + frametrkonlyresVsCoord.add(canvastrkonlyresVsCoord); + frametrkonlyresVsCoord.setLocationRelativeTo(null); + frametrkonlyresVsCoord.setVisible(true); } } From ee304305e71d8e62764082bbc1e3bcfef39d358a Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Tue, 22 Feb 2022 11:51:18 +0100 Subject: [PATCH 071/104] revert to previous version --- build-coatjava.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build-coatjava.sh b/build-coatjava.sh index 1f4ec02ef3..47a5f39d03 100755 --- a/build-coatjava.sh +++ b/build-coatjava.sh @@ -30,8 +30,7 @@ do done wget='wget' -#mvn='mvn' -mvn='/usr/local/apache-maven-3.6.3/bin/mvn' +mvn='mvn' if [ "$quiet" == "yes" ] then wget='wget --progress=dot:mega' From 27be229c28fad160ec44d57425f8633fd718dbe2 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Tue, 22 Feb 2022 12:02:59 +0100 Subject: [PATCH 072/104] fix FTTRK banks description --- etc/bankdefs/hipo4/ft.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/bankdefs/hipo4/ft.json b/etc/bankdefs/hipo4/ft.json index 4a5b1977f5..d7e87d1954 100644 --- a/etc/bankdefs/hipo4/ft.json +++ b/etc/bankdefs/hipo4/ft.json @@ -120,7 +120,7 @@ {"name":"id", "type":"S", "info":"Cluster ID"}, {"name":"sector", "type":"B", "info":"Cluster sector"}, {"name":"layer", "type":"B", "info":"Cluster layer"}, - {"name":"energy", "type":"F", "info":"Hit Energy" }, + {"name":"energy", "type":"F", "info":"Cluster total energy" }, {"name":"maxEnergy", "type":"F", "info":"Seed energy"}, {"name":"seed", "type":"S", "info":"Seed strip"}, {"name":"centroid", "type":"F", "info":"Centroid strip number"} @@ -141,8 +141,8 @@ {"name":"z", "type":"F", "info":"Cross Z position (cm)"}, {"name":"energy", "type":"F", "info":"Cross Energy" }, {"name":"time", "type":"F", "info":"Cross Time" }, - {"name":"Cluster1ID", "type":"S", "info":"ID of the bottom layer cluster in the Cross"}, - {"name":"Cluster2ID", "type":"S", "info":"ID of the top layer cluster in the Cross"} + {"name":"Cluster1ID", "type":"S", "info":"ID of the upstream layer cluster in the Cross"}, + {"name":"Cluster2ID", "type":"S", "info":"ID of the downstream layer cluster in the Cross"} ] } From f345e8d9aa62b55661c33f174188f66c432f0edd Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Tue, 22 Feb 2022 12:24:37 +0100 Subject: [PATCH 073/104] remove file from repository --- .../jlab/rec/ft/FTEBEngineSingleEvent.java | 1633 ----------------- 1 file changed, 1633 deletions(-) delete mode 100755 reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java deleted file mode 100755 index 7da94edf7d..0000000000 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngineSingleEvent.java +++ /dev/null @@ -1,1633 +0,0 @@ -package org.jlab.rec.ft; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.swing.JFrame; -import org.jlab.clas.detector.DetectorData; -import org.jlab.clas.detector.DetectorEvent; - -import org.jlab.clas.physics.GenericKinematicFitter; -import org.jlab.clas.physics.PhysicsEvent; -import org.jlab.clas.reco.ReconstructionEngine; -import org.jlab.geom.prim.Line3D; -import org.jlab.geom.prim.Point3D; -import org.jlab.geom.prim.Vector3D; -import org.jlab.groot.data.H1F; -import org.jlab.groot.data.H2F; -import org.jlab.groot.data.DataLine; -import org.jlab.groot.ui.LatexText; -import org.jlab.groot.math.F1D; -import org.jlab.groot.fitter.DataFitter; -import org.jlab.groot.graphics.EmbeddedCanvas; -import org.jlab.groot.data.GraphErrors; -import org.jlab.io.base.DataBank; -import org.jlab.io.base.DataEvent; -import org.jlab.io.evio.EvioDataBank; -import org.jlab.io.evio.EvioDataEvent; -import org.jlab.io.hipo.HipoDataSource; -import org.jlab.rec.ft.cal.FTCALConstantsLoader; -import org.jlab.rec.ft.cal.FTCALEngine; -import org.jlab.rec.ft.hodo.FTHODOEngine; -import org.jlab.rec.ft.trk.FTTRKEngine; -import org.jlab.rec.ft.trk.FTTRKConstantsLoader; -import org.jlab.rec.ft.trk.FTTRKReconstruction; - -public class FTEBEngineSingleEvent extends ReconstructionEngine { - - FTEventBuilder reco; - int Run = -1; - double Solenoid; - static boolean timeEnergyDiagnosticHistograms = false; - static boolean residualsHistograms = false; - - public FTEBEngineSingleEvent() { - super("FTEB", "devita", "3.0"); - } - - @Override - public boolean init() { - reco = new FTEventBuilder(); - reco.debugMode = 0; - String[] tables = new String[]{ - "/calibration/ft/ftcal/cluster", - "/calibration/ft/ftcal/thetacorr", - "/calibration/ft/ftcal/phicorr" - }; - requireConstants(Arrays.asList(tables)); - this.getConstantsManager().setVariation("default"); - - return true; - } - - @Override - public boolean processDataEvent(DataEvent event) { - List FTparticles = new ArrayList(); - List FTresponses = new ArrayList(); - - int run = this.setRunConditionsParameters(event); - if (run>=0) { - reco.init(this.getSolenoid()); - FTresponses = reco.addResponses(event, this.getConstantsManager(), run); - FTparticles = reco.initFTparticles(FTresponses); - if(FTparticles.size()>0){ - reco.matchToTRKTwoDetectorsMultiHits(FTresponses, FTparticles); - reco.matchToHODO(FTresponses, FTparticles); -// reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo - reco.writeBanks(event, FTparticles); - } - } - return true; - } - - public int setRunConditionsParameters(DataEvent event) { - int run = -1; - if (event.hasBank("RUN::config") == false) { - System.err.println("RUN CONDITIONS NOT READ!"); - } - else { - double fieldScale = 0; - - boolean isMC = false; - boolean isCosmics = false; - - if (event instanceof EvioDataEvent) { - EvioDataBank bank = (EvioDataBank) event.getBank("RUN::config"); - if (bank.getByte("Type",0) == 0) { - isMC = true; - } - if (bank.getByte("Mode",0)== 1) { - isCosmics = true; - } - run = bank.getInt("Run",0); - fieldScale = bank.getFloat("Solenoid")[0]; - } else { - DataBank bank = event.getBank("RUN::config"); - if (bank.getByte("type",0) == 0) { - isMC = true; - } - if (bank.getByte("mode",0)== 1) { - isCosmics = true; - } - run = bank.getInt("run",0); - fieldScale = bank.getFloat("solenoid",0); - } - this.setSolenoid(fieldScale); - } - return run; - } - - public int getRun() { - return Run; - } - - public void setRun(int run) { - Run = run; - } - - public double getSolenoid() { - return Solenoid; - } - - public void setSolenoid(double Solenoid) { - this.Solenoid = Solenoid; - } - - public int getDebugMode() { - return this.reco.debugMode; - } - - static boolean plotDiagnosticHistograms = timeEnergyDiagnosticHistograms || residualsHistograms; - - public static H1F h500 = new H1F("Time Difference FTCAL-response", 100, 0., 200.); - public static H1F h501 = new H1F("Cross Energy TRK0", 100, 0., 2000.); - public static H1F h502 = new H1F("Cross Energy TRK1", 100, 0., 2000.); - public static H1F h503 = new H1F("Cross time TRK0", 100, 0.0, 500.); - public static H1F h504 = new H1F("Cross time TRK1", 100, 0.0, 500.); - public static H2F h505 = new H2F("Cross energy vs time TRK0", 100, 0.0, 500., 100, 0., 2000.); - public static H2F h506 = new H2F("Cross energy vs time TRK1", 100, 0.0, 500., 100, 0., 2000.); - public static H2F h507 = new H2F("Cross energy vs time TRK0+1", 100, 0.0, 500., 100, 0., 2000.); - public static H2F h510 = new H2F("Clusters total energies TRK0", 100, 0., 2000., 100, 0., 2000.); - public static H2F h511 = new H2F("Clusters total energies TRK1", 100, 0., 2000., 100, 0., 2000.); - public static H1F h512 = new H1F("Clusters total energies TRK0", 100, 0., 2000.); - public static H1F h513 = new H1F("Clusters total energies TRK1", 100, 0., 2000.); - public static H1F h520 = new H1F("Time of strips in cluster1 TRK0", 100, 0., 500.); - public static H1F h521 = new H1F("Time of strips in cluster2 TRK0", 100, 0., 500.); - public static H1F h522 = new H1F("time of strips in cluster1 TRK1", 100, 0., 500.); - public static H1F h523 = new H1F("Time of strips in cluster2 TRK1", 100, 0., 500.); - - public static H1F h600 = new H1F("TRK response position", 100, 5.93, 6.03); - public static H2F h601 = new H2F("TRK tof vs time", 100, 0., 500., 100, 5.93, 6.03); - public static H1F h602 = new H1F("cross0 time", 100, 0.0001, 500.); - public static H1F h603 = new H1F("cross1 time", 100, 0.0001, 500.); - - public static H2F hSecDet0 = new H2F("lay 2 vs lay1 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); - public static H2F hSecDet1 = new H2F("lay 4 vs lay3 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); - public static H2F hSeedDet0 = new H2F("lay 2 vs lay1 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); - public static H2F hSeedDet1 = new H2F("lay 4 vs lay3 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); - - public static Point3D centerOfTarget = new Point3D(0., 0., -3.); - - - public static void main(String arg[]){ - - FTCALEngine cal = new FTCALEngine(); - cal.init(); - FTHODOEngine hodo = new FTHODOEngine(); - hodo.init(); - FTTRKEngine trk = new FTTRKEngine(); - trk.init(); - FTEBEngine en = new FTEBEngine(); - en.init(); - int debugMode = en.getDebugMode(); -////// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; - String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_94976.hipo"; - - HipoDataSource reader = new HipoDataSource(); - reader.open(input); - - // initialize histos - H1F h1 = new H1F("Cluster Energy", 100, 0., 8.); - h1.setOptStat(Integer.parseInt("11111")); - h1.setTitleX("Cluster Energy (GeV)"); - H1F h2 = new H1F("Energy Resolution", 100, -1, 1); - h2.setOptStat(Integer.parseInt("11111")); - h2.setTitleX("Energy Resolution(GeV)"); - H1F h3 = new H1F("Theta Resolution", 100, -1, 1); - h3.setOptStat(Integer.parseInt("11111")); - h3.setTitleX("Theta Resolution(deg)"); - H1F h4 = new H1F("Phi Resolution", 100, -10, 10); - h4.setOptStat(Integer.parseInt("11111")); - h4.setTitleX("Phi Resolution(deg)"); - - H1F h5 = new H1F("Time Resolution", 100, -2, 2); - h5.setOptStat(Integer.parseInt("1111")); - h5.setTitleX("Time Resolution(ns)"); - H2F h6 = new H2F("Cluster Energy", 24, -180., 180., 24, -180., 180.); - h6.setTitleX("x (cm)"); - h6.setTitleY("y (cm)"); - H2F h7 = new H2F("N. Clusters", 24, -18., 18., 24, -18., 18.); - h7.setTitleX("x (mm)"); - h7.setTitleY("y (mm)"); - H2F h8 = new H2F("Cluster Energy", 100, 0., 9., 100, -0.5, 0.5); - h8.setTitleX("E (GeV)"); - h8.setTitleY("Energy Resolution(GeV)"); - H2F h9 = new H2F("Cluster Energy", 100, 2., 5., 100, -0.5, 0.5); - h9.setTitleX("#theta"); - h9.setTitleY("Energy Resolution(GeV)"); - H2F h10 = new H2F("Cluster Energy", 100, -180., 180., 100, -0.5, 0.5); - h10.setTitleX("#phi"); - h10.setTitleY("Energy Resolution(GeV)"); - - // residual plots (of TRK wrt tracking on ECAL - black histograms) - H2F h100 = new H2F("Cross on trk layer1", 100, -18., 18., 100, -18., 18.); - h100.setTitleX("x (mm) trk1"); - h100.setTitleY("y (mm) trk1"); - H2F h101 = new H2F("Cross on trk layer2", 100, -18., 18., 100, -18., 18.); - h101.setTitleX("x (mm) trk2"); - h101.setTitleY("y (mm) trk2"); - H2F h700 = new H2F("Strips on trk layer1", 100, -18., 18., 100, -18., 18.); - h100.setTitleX("x (mm) trk1"); - h100.setTitleY("y (mm) trk1"); - H2F h701 = new H2F("Strips on trk layer2", 100, -18., 18., 100, -18., 18.); - h101.setTitleX("x (mm) trk2"); - h101.setTitleY("y (mm) trk2"); - - double limTC = 4.; // for MC 0.05 is ok - H1F h102 = new H1F("trk1 x residual", 63, -limTC, limTC); - h102.setOptStat(10); - h102.setTitleX("trk1 x residual (mm)"); - h102.setFillColor(1); - H1F h103 = new H1F("trk2 x residual", 63, -limTC, limTC); - h103.setOptStat(10); - h103.setFillColor(51); - h103.setTitleX("trk2 x residual (mm)"); - H1F h104 = new H1F("trk1 y residual", 63, -limTC, limTC); - h104.setOptStat(Integer.parseInt("0")); - h104.setFillColor(1); - h104.setTitleX("trk1 y residual (mm)"); - H1F h105 = new H1F("trk2 y residual;", 63, -limTC, limTC); - h105.setOptStat(10); - h105.setTitleX("trk2 y residual (mm)"); - h105.setFillColor(51); - double limTCTheta = 0.05; - double limTCPhi = 1.; - H1F h106 = new H1F("trk1 theta residual (rad)", 100, -limTCTheta, limTCTheta); - h106.setOptStat(10); - h106.setTitleX("trk1 theta residual (rad)"); - h106.setFillColor(1); - H1F h107 = new H1F("trk2 theta residual (rad)", 100, -limTCTheta, limTCTheta); - h107.setOptStat(Integer.parseInt("0")); - h107.setTitleX("trk2 theta residual (rad)"); - h107.setFillColor(51); - H1F h108 = new H1F("trk1 phi residual (rad)", 100, -limTCPhi, limTCPhi); - h108.setOptStat(0); - h108.setTitleX("trk1 phi residual"); - h108.setFillColor(1); - H1F h109 = new H1F("trk2 phi residual (rad)", 100, -limTCPhi, limTCPhi); - h109.setOptStat(10); - h109.setTitleX("trk2 phi residual (rad)"); - h109.setFillColor(51); - - H1F resTrkXdet0 = new H1F("trk1 x residual wrt line thru trk0", 63, -0.5, 0.5); - resTrkXdet0.setOptStat(10); - resTrkXdet0.setTitleX("trk1 x residual (mm) wrt line thru trk0"); - resTrkXdet0.setFillColor(9); - H1F resTrkYdet0 = new H1F("trk1 y residual wrt line thru trk0", 63, -0.5, 0.5); - resTrkYdet0.setOptStat(10); - resTrkYdet0.setFillColor(9); - resTrkYdet0.setTitleX("trk1 y residual (mm) wrt line thru trk0"); - H1F resTrkXdet1 = new H1F("trk0 x residual wrt line thru trk1", 63, -1., 1.); - resTrkXdet1.setOptStat(10); - resTrkXdet1.setFillColor(49); - resTrkXdet1.setTitleX("trk0 y residual (mm) wrt line thru trk1"); - H1F resTrkYdet1 = new H1F("trk0 y residual wrt line thru trk1", 63, -1., 1.); - resTrkYdet1.setOptStat(10); - resTrkYdet1.setTitleX("trk0 y residual (mm) wrt line thru trk1"); - resTrkYdet1.setFillColor(49); - - H1F resTrkThetadet0 = new H1F("trk1 theta residual (rad) wrt line thru trk0", 100, -0.01, 0.01); - resTrkThetadet0.setOptStat(10); - resTrkThetadet0.setTitleX("trk1 theta residual (rad) wrt line thru trk0"); - resTrkThetadet0.setFillColor(9); - H1F resTrkThetadet1 = new H1F("trk0 theta residual (rad) wrt line thru trk1", 100, -0.01, 0.01); - resTrkThetadet1.setOptStat(10); - resTrkThetadet1.setTitleX("trk0 theta residual (rad) wrt line thru trk1"); - resTrkThetadet1.setFillColor(49); - H1F resTrkPhidet0 = new H1F("trk1 phi residual (rad) wrt line thru trk0", 100, -0.2, 0.2); - resTrkPhidet0.setOptStat(10); - resTrkPhidet0.setTitleX("trk1 phi residual wrt line thru trk0"); - resTrkPhidet0.setFillColor(9); - H1F resTrkPhidet1 = new H1F("trk0 phi residual (rad) wrt line thru trk1", 100, -0.2, 0.2); - resTrkPhidet1.setOptStat(10); - resTrkPhidet1.setTitleX("trk0 phi residual (rad) wrt line thru trk1"); - resTrkPhidet1.setFillColor(49); - - H1F h202 = new H1F("trk1 x", 25, 8.2, 9.0); - H1F h1202 = new H1F("trk1 x MC", 25, 8.2, 9.0); - h202.setOptStat(0); - h202.setTitleX("trk1 x position (mm)"); - h202.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins - h202.setLineColor(3); - h202.setFillColor(3); - h1202.setLineColor(9); - h1202.setFillColor(49); - H1F h203 = new H1F("trk2 x", 25, 8.2, 9.0); - H1F h1203 = new H1F("trk2 MC", 25, 8.2, 9.0); - h203.setOptStat(0); - h203.setTitleX("trk2 x position (mm)"); - h203.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins - h203.setLineColor(3); - h203.setFillColor(3); - h1203.setLineColor(9); - h1203.setFillColor(49); - H1F h204 = new H1F("trk1 y", 25, 2.4, 4.0); - H1F h1204 = new H1F("trk1 y MC", 25, 2.4, 4.0); - h204.setOptStat(0); - h204.setTitleX("trk1 y position (mm)"); - h204.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins - h204.setLineColor(3); - h204.setFillColor(3); - h1204.setLineColor(9); - h1204.setFillColor(49); - H1F h205 = new H1F("trk2 y", 25, 2.4, 4.0); - H1F h1205 = new H1F("trk2 y MC", 25, 2.4, 4.0); - h205.setOptStat(0); - h205.setTitleX("trk2 y position (mm)"); - h205.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins - h205.setLineColor(3); - h205.setFillColor(3); - h1205.setLineColor(9); - h1205.setFillColor(49); - - // resolution plots (of TRK wrt MC truth - red histograms) - H2F h1100 = new H2F("Cross on trk layer1 MC truth", 100, -18., 18., 100, -18., 18.); - h1100.setTitleX("x (mm) trk1"); - h1100.setTitleY("y (mm) trk1"); - H2F h1101 = new H2F("Cross on trk layer2 MC truth", 100, -18., 18., 100, -18., 18.); - h1101.setTitleX("x (mm) trk2"); - h1101.setTitleY("y (mm) trk2"); - int binres = 35; - double reslim = 5.*FTTRKConstantsLoader.Pitch; - H1F h1102 = new H1F("trk1 x resolution", binres, -reslim, reslim); - h1102.setOptStat(0); - h1102.setTitleX("trk1 x resolutionl (mm)"); - h1102.setLineColor(2); - h1102.setFillColor(2); - H1F h1103 = new H1F("trk2 x resolution", binres, -reslim, reslim); - h1103.setOptStat(0); - h1103.setTitleX("trk2 x resolution (mm)"); - h1103.setLineColor(2); - h1103.setFillColor(32); - H1F h1104 = new H1F("trk1 y resolution", binres, -reslim, reslim); - h1104.setOptStat(0); - h1104.setTitleX("trk1 y resolution (mm)"); - h1104.setLineColor(2); - h1104.setFillColor(2); - H1F h1105 = new H1F("trk2 y resolution", binres, -reslim, reslim); - h1105.setOptStat(0); - h1105.setTitleX("trk2 y resolution (mm)"); - h1105.setLineColor(2); - h1105.setFillColor(32); - H1F h1106 = new H1F("trk1 theta resolution", 50, -0.001, 0.001); - h1106.setOptStat(0); - h1106.setTitleX("trk1 theta resolution (rad)"); - h1106.setLineColor(2); - h1106.setFillColor(27); - H1F h1107 = new H1F("trk2 theta resolution", 50, -0.001, 0.001); - h1107.setOptStat(0); - h1107.setTitleX("trk2 theta resolution (rad)"); - h1107.setLineColor(2); - h1107.setFillColor(37); - H1F h1108 = new H1F("trk1 phi resolution", 50, -0.02, 0.02); - h1108.setOptStat(0); - h1108.setTitleX("trk1 phi resolution (rad)"); - h1108.setLineColor(2); - h1108.setFillColor(2); - H1F h1109 = new H1F("trk2 phi resolution", 50, -0.02, 0.02); - h1109.setOptStat(0); - h1109.setTitleX("trk2 phi resolution (rad)"); - h1109.setLineColor(2); - h1109.setFillColor(32); - - H1F h1112 = new H1F("trk1 Delta x", 50, -0.05, 0.05); - h1112.setOptStat(0); - h1112.setTitleX("trk1 Delta x"); - h1112.setLineColor(6); - h1112.setFillColor(6); - H1F h1113 = new H1F("trk2 Delta x", 50, -0.05, 0.05); - h1113.setOptStat(0); - h1113.setTitleX("trk2 Delta x"); - h1113.setLineColor(6); - h1113.setFillColor(36); - H1F h1114 = new H1F("trk1 Delta y", 50, -0.1, 0.1); - h1114.setOptStat(0); - h1114.setTitleX("trk1 Delta y"); - h1114.setLineColor(6); - h1114.setFillColor(6); - H1F h1115 = new H1F("trk2 Delta y", 50, -0.1, 0.1); - h1115.setOptStat(0); - h1115.setTitleX("trk2 Delta y"); - h1115.setLineColor(6); - h1115.setFillColor(36); - - // Montecarlo radiography - H2F h2000 = new H2F("Montecarlo radiography at first FTTRK det", 100, -15., 15., 100, -15, 15.); - h2000.setTitleX("x (mm)"); - h2000.setTitleY("y (mm)"); - H2F h2001 = new H2F("Montecarlo radiography at second FTTRK det", 100, -15., 15., 100, -15, 15.); - h2001.setTitleX("x (mm)"); - h2001.setTitleY("y (mm)"); - - JFrame frameCALTRK = new JFrame("radiography FTCAL hits and FTTRK Crosses"); - frameCALTRK.setSize(1500,500); - EmbeddedCanvas canvasCALTRK = new EmbeddedCanvas(); - canvasCALTRK.divide(3,1); - - H1F h71 = new H1F("hOccupancyMatchedSeed1", 768, 0., 769.); h71.setTitleX("Component layer 1"); - h71.setLineColor(1); h71.setFillColor(51); - H1F h72 = new H1F("hOccupancyMatchedSeed2", 768, 0., 769.); h72.setTitleX("Component layer 2"); - h72.setLineColor(1); h72.setFillColor(52); - H1F h73 = new H1F("hOccupancyMatchedSeed3", 768, 0., 769.); h73.setTitleX("Component layer 3"); - h73.setLineColor(1); h73.setFillColor(53); - H1F h74 = new H1F("hOccupancyMatchedSeed4", 768, 0., 769.); h74.setTitleX("Component layer 4"); - h74.setLineColor(1); h74.setFillColor(54); - - H1F h81 = new H1F("hOccupancyMatched1", 768, 0., 769.); h81.setTitleX("Component layer 1"); - h81.setLineColor(1); h81.setFillColor(31); - H1F h82 = new H1F("hOccupancyMatched2", 768, 0., 769.); h82.setTitleX("Component layer 2"); - h82.setLineColor(1); h82.setFillColor(32); - H1F h83 = new H1F("hOccupancyMatched3", 768, 0., 769.); h83.setTitleX("Component layer 3"); - h83.setLineColor(1); h83.setFillColor(33); - H1F h84 = new H1F("hOccupancyMatched4", 768, 0., 769.); h84.setTitleX("Component layer 4"); - h84.setLineColor(1); h84.setFillColor(34); - - int nev = 0; - int nevWithCrosses = 0, ncrosses2 = 0, nOfFTParticles = 0; - while (reader.hasEvent()) { // run over all events -// int nev1 = 0; int nev2 = 10000; for(nev=nev1; nev=1) System.out.println("////////////// event read " + bankEvt + " - sequential number " + nev); - //if(nev > 10239) System.exit(0); if(nev != 10239) continue; - cal.processDataEvent(event); - hodo.processDataEvent(event); - trk.processDataEventAndGetClusters(event); - en.processDataEvent(event); - if(!event.hasBank("FTCAL::hits")) continue; - - if (event instanceof EvioDataEvent) { - GenericKinematicFitter fitter = new GenericKinematicFitter(11); - PhysicsEvent gen = fitter.getGeneratedEvent((EvioDataEvent) event); - if (event.hasBank("FTRec::tracks")) { - DataBank bank = event.getBank("FTRec::tracks"); - int nrows = bank.rows(); - for (int i = 0; i < nrows; i++) { - h1.fill(bank.getDouble("Energy", i)); - Vector3D part = new Vector3D(bank.getDouble("Cx", i), bank.getDouble("Cy", i), bank.getDouble("Cz", i)); - h5.fill(bank.getDouble("Time", i)); - if(gen.countGenerated() != 0){ - h2.fill(bank.getDouble("Energy", i) - gen.getParticle("[11]").vector().p()); - h3.fill(Math.toDegrees(part.theta() - gen.getParticle("[11]").theta())); - h4.fill(Math.toDegrees(part.phi() - gen.getParticle("[11]").phi())); - h6.fill(bank.getDouble("Energy", i), bank.getDouble("Energy", i) - gen.getParticle("[11]").vector().p()); - } - } - } - } else { - DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); - PhysicsEvent gen = detectorEvent.getGeneratedEvent(); - if (event.hasBank("FT::particles")) { - DataBank bank = event.getBank("FT::particles"); - int nrows = bank.rows(); - if(nrows>0) nOfFTParticles++; - for (int i = 0; i < nrows; i++) { - int calId = bank.getShort("calID",i); - if(bank.getByte("charge", i)==-1 && bank.getShort("calID",i)>0) { - // track candidate through calorimeter - h1.fill(bank.getFloat("energy", i)); - Vector3D part = new Vector3D(bank.getFloat("cx", i), bank.getFloat("cy", i), bank.getFloat("cz", i)); - h5.fill(bank.getFloat("time", i) - 124.25); // simulation - h7.fill((bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS)/10., (bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS)/10.); - if(gen.countGenerated() != 0){ - h2.fill(bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); - h3.fill(gen.getGeneratedParticle(0).vector().p(),Math.toDegrees(part.theta() - gen.getGeneratedParticle(0).theta())); - h4.fill(gen.getGeneratedParticle(0).vector().p(),Math.toDegrees(part.phi() - gen.getGeneratedParticle(0).phi())); - h6.fill(bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); - h8.fill(gen.getGeneratedParticle(0).vector().p(), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); - h9.fill(Math.toDegrees(gen.getGeneratedParticle(0).theta()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); - h10.fill(Math.toDegrees(gen.getGeneratedParticle(0).phi()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); - } - - // check match with trk bank (entry trkID) - int trk0ID = bank.getShort("trk0ID", i); // it should correspond to the number of the cross in the banks - int trk1ID = bank.getShort("trk1ID", i); - if(trk0ID >= 0 || trk1ID >= 0){ // at least one cross is present on one TRK det - - // loop on crosses bank - DataBank banktrk = event.getBank("FTTRK::crosses"); - int ncrosses = banktrk.rows(); - // how many matched crosses are associated to a given track? - int matchedCrosses = 0; - for(int nc=0; nc0) System.out.println("++++++++++++++++++++++++++ Sequential number " + nev); - } - - for(int nc = 0; nc < ncrosses; nc++){ - int crossID = banktrk.getInt("id", nc); - if(crossID != trk0ID && crossID != trk1ID) continue; - int det = banktrk.getInt("detector", nc); - if(debugMode>0) System.out.println("trk0ID " + trk0ID + " trk1ID " + trk1ID + - " crossID " + crossID); - if(det>=0){ - float xt = banktrk.getFloat("x", nc); - float yt = banktrk.getFloat("y", nc); - float zt = banktrk.getFloat("z", nc); - Vector3D hitOnTrk = new Vector3D(xt, yt, zt); - // extract information on the crossed strips - float icl1 = banktrk.getShort("Cluster1ID", nc); - float icl2 = banktrk.getShort("Cluster2ID", nc); - DataBank bankcl = event.getBank("FTTRK::clusters"); - // which is the correct location in the cluster bank for the cluster with the given id? - int icl1ok = -1; - int icl2ok = -1; - for(int k=0; k0){ - segment1.setOrigin(0.,0.); segment1.setEnd(0.,0.); - segment2.setOrigin(0.,0.); segment2.setEnd(0.,0.); - seed1 = bankcl.getInt("seed", (int)icl1ok); - seed2 = bankcl.getInt("seed", (int)icl2ok); - int cent1 = (int)bankcl.getFloat("centroid", icl1ok); - int cent2 = (int)bankcl.getFloat("centroid", icl2ok); - // if the cluster is formed by >= 3 strips take the centroid - int clustsize1 = bankcl.getShort("size", icl1ok); - int clustsize2 = bankcl.getShort("size", icl2ok); - if(clustsize1>=3){ - int sector = FTTRKReconstruction.findSector(seed1); - if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed1 = cent1; - } - if(clustsize2>=3){ - int sector = FTTRKReconstruction.findSector(seed2); - if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed2 = cent2; - } - int lay1 = bankcl.getInt("layer", (int)icl1ok); - int lay2 = bankcl.getInt("layer", (int)icl2ok); - if(debugMode>-1){ - System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ seed1, seed2 " + seed1 + " " + seed2 + " layer1 layer2 " + lay1 + " " + lay2); - System.out.println("~~~~~~~~~~ hit strip 1: " + seed1 + " layer " + lay1 + " sector " + - FTTRKReconstruction.findSector(seed1)); - System.out.println("~~~~~~~~~~ hit strip 2: " + seed2 + " layer " + lay2 + " sector " + - FTTRKReconstruction.findSector(seed2)); - } - if(seed1!=0 && seed2!=0){ - Line3D seg1 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay1, seed1); - Line3D seg2 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay2, seed2); - segment1.setOrigin(seg1.origin().x(), seg1.origin().y()); - segment2.setOrigin(seg2.origin().x(), seg2.origin().y()); - segment1.setEnd(seg1.end().x(), seg1.end().y()); - segment2.setEnd(seg2.end().x(), seg2.end().y()); - - // extract the mumber of strips forming the cross and store them in an occupancy plot for matched signals - // which strips are forming the id cross? - if(lay1==1){ - h71.fill(seed1); - }else if(lay1==2){ - h72.fill(seed1); - }else if(lay1==3){ - h73.fill(seed1); -; }else if(lay1==4){ - h74.fill(seed1); - } - - if(lay2==1){ - h71.fill(seed2); - }else if(lay2==2){ - h72.fill(seed2); - }else if(lay2==3){ - h73.fill(seed2); - }else if(lay2==4){ - h74.fill(seed2); - } - - DataBank bankhit = event.getBank("FTTRK::hits"); - if(bankhit.rows()>0){ - for(int k=0; k0){ -// System.out.println("coordinates on calorimeter " + bank.getDouble("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); - System.out.println("coordinates of track on fttrk " + bank.getFloat("cx", i)*zt + " " + - bank.getFloat("cy", i)*zt + " " + bank.getFloat("cz", i)*zt); - System.out.println("director cosines hit on calorimeter " + part.x() + " " + part.y() + " " + part.z()); - System.out.println("director cosines hit of fttrk " + xt + " " + yt + " " + zt); - } - h102.fill(bank.getFloat("cx", i) *zt - xt); - h104.fill(bank.getFloat("cy", i) *zt - yt); - h106.fill((part.theta() - hitOnTrk.theta())); - h108.fill((part.phi() - hitOnTrk.phi())); - int sec1 = FTTRKReconstruction.findSector(seed1); - int sec2 = FTTRKReconstruction.findSector(seed2); - hSecDet0.fill(sec1, sec2); - hSeedDet0.fill(seed1, seed2); - if(debugMode>0){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + - " bad seeds d0, event " + nev); - } - canvasCALTRK.cd(0); - segment1.setLineColor(1); - segment2.setLineColor(2); - canvasCALTRK.draw(segment1); - canvasCALTRK.draw(segment2); - canvasCALTRK.cd(2); - canvasCALTRK.draw(segment1); - canvasCALTRK.draw(segment2); - - }else if(det==1 && trk1ID==crossID){ - h101.fill(xt, yt); - h103.fill(bank.getFloat("cx", i) *zt - xt); - h105.fill(bank.getFloat("cy", i) *zt - yt); - h107.fill((part.theta() - hitOnTrk.theta())); - h109.fill((part.phi() - hitOnTrk.phi())); - int sec1 = FTTRKReconstruction.findSector(seed1); - int sec2 = FTTRKReconstruction.findSector(seed2); - hSecDet1.fill(sec1, sec2); - hSeedDet1.fill(seed1, seed2); - if(debugMode>0){ - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + - " bad seeds d1, event " + nev); - } - canvasCALTRK.cd(1); - segment1.setLineColor(3); - segment2.setLineColor(4); - canvasCALTRK.draw(segment1); - canvasCALTRK.draw(segment2); - canvasCALTRK.cd(2); - canvasCALTRK.draw(segment1); - canvasCALTRK.draw(segment2); - } - - double cx = hitOnTrk.x() - centerOfTarget.x(); - double cy = hitOnTrk.y() - centerOfTarget.y(); - double cz = hitOnTrk.z() - centerOfTarget.z(); - for(int ncj = 0; ncj < ncrosses; ncj++) { - int det1 = banktrk.getInt("detector", ncj); - if(det1 >=0 && nc != ncj && det != det1){ - double x1 = banktrk.getFloat("x", ncj); - double y1 = banktrk.getFloat("y", ncj); - double z1 = banktrk.getFloat("z", ncj); - int secondCrossID = banktrk.getInt("id", ncj); - Vector3D cross = new Vector3D(x1, y1, z1); - double t = (cross.z()-centerOfTarget.z())/hitOnTrk.z(); - Vector3D pointOnTrackAtZ = new Vector3D(cx*t + centerOfTarget.x(), cy*t + centerOfTarget.y(), z1); - if(det1 == 1 && trk1ID == secondCrossID){ - resTrkXdet0.fill(pointOnTrackAtZ.x() - cross.x()); - resTrkYdet0.fill(pointOnTrackAtZ.y() - cross.y()); - resTrkThetadet0.fill(pointOnTrackAtZ.theta() - cross.theta()); - resTrkPhidet0.fill(pointOnTrackAtZ.phi() - cross.phi()); - }else if(det1 == 0 && trk0ID == secondCrossID){ - resTrkXdet1.fill(pointOnTrackAtZ.x() - cross.x()); - resTrkYdet1.fill(pointOnTrackAtZ.y() - cross.y()); - resTrkThetadet1.fill(pointOnTrackAtZ.theta() - cross.theta()); - resTrkPhidet1.fill(pointOnTrackAtZ.phi() - cross.phi()); - } - } - } - } - } - - if(ncrosses==2){ - float x0 = banktrk.getFloat("x", 0); - float y0 = banktrk.getFloat("y", 0); - float x1 = banktrk.getFloat("x", 1); - float y1 = banktrk.getFloat("y", 1); - - Point3D c0 = new Point3D(x0, y0, banktrk.getFloat("z",0)); - Point3D c1 = new Point3D(x1, y1, banktrk.getFloat("z",1)); - Line3D lineBwCrosses = new Line3D(c1, c0); - if(debugMode>0){ - System.out.println("x coordinates on 2 layers " + x0 + " " + x1); - System.out.println("director cosines straight line bw crosses, cx " + lineBwCrosses.originDir().x() + " cy " + - lineBwCrosses.originDir().y() + " cz " + lineBwCrosses.originDir().z()); - } - } - } - } - } - } - - if(event.hasBank("FTTRK::crosses")){ - nevWithCrosses++; - DataBank banktrk = event.getBank("FTTRK::crosses"); - int nrows = banktrk.rows(); - - // comparison with MC data - // how many particles have been generated? - int ipart = gen.countGenerated(); - for(int ip=0; ip0) System.out.println("------- generated particle n " + ip + " type: " + gen.getGeneratedParticle(ip).pid() + " mass " + mass); - double P = gen.getGeneratedParticle(ip).p(); - double cx = gen.getGeneratedParticle(ip).px()/P; - double cy = gen.getGeneratedParticle(ip).py()/P; - double cz = gen.getGeneratedParticle(ip).pz()/P; - double Pz = P*cz; - double Pperp = P*Math.sqrt(cx*cx+cy*cy); - double x0 = gen.getGeneratedParticle(ip).vx(); - double y0 = gen.getGeneratedParticle(ip).vy(); - double z0 = gen.getGeneratedParticle(ip).vz(); - double q = Math.abs(gen.getGeneratedParticle(ip).charge()); // negative particles bend upwards - for (int i = 0; i < nrows; i++) { - int det = banktrk.getInt("detector", i); - double xt = banktrk.getFloat("x", i); - double yt = banktrk.getFloat("y", i); - double zt = banktrk.getFloat("z", i); - - if(debugMode>0){ - System.out.println("MC: x0 = " + x0 + " y0 " + y0 + " z0 " + z0); - System.out.println("MC cosines: cx = " + cx + " cy " + cy + " cz " + cz); - System.out.println("trk: xt = " + xt + " yt " + yt + " zt " + zt); - } - double t = (zt - z0)/cz; - Vector3D hitOnTrk = new Vector3D(xt, yt, zt); - Vector3D hitMCOnTrk = new Vector3D(x0+cx*t, y0+cy*t, zt); // straight line - - if(debugMode>0) System.out.println("MC on the straight line x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + - " z = " + hitMCOnTrk.z()); - // if the magnetic field is on, the coordinates must be swum along a helix - double B = en.getSolenoid(); - if(B!=0.){ - // find the crossing point of the helix and a xy plane at given z, where the magneti field stops - double zStop = 100.0; // provisional fix it to 1 meter - double phi0 = Math.atan2(cy,cx); - double R = Pperp/0.3/B/q*1.e2; // R in cm - double dAlpha = (zStop-z0)*(B*q*0.3)/Pz*1.e-2; // deltaZ in meters - int nturns = (int) Math.floor(dAlpha/2./Math.PI); // number of full turns - if(dAlpha>0){ - dAlpha -= nturns*2.*Math.PI; - }else{ - dAlpha += nturns*2.*Math.PI; - } - - double xc = R*Math.sin(phi0); - double yc = R*Math.cos(phi0); - Vector3D hitOnPlane = new Vector3D(); - Vector3D tangentAtZstop = new Vector3D(); - if(R*dAlpha>0){ - hitOnPlane.setX(-xc + R*(Math.sin(phi0 + dAlpha))); - hitOnPlane.setY( yc - R*(Math.cos(phi0 + dAlpha))); - hitOnPlane.setZ(zStop); - double gamma = Math.atan2(hitOnPlane.y(),hitOnPlane.x()); - double vx1 = Pperp/P*Math.sin(gamma); - double vy1 = Pperp/P*Math.cos(gamma); - double vz1 = Math.sqrt(1. - vx1*vx1 + vy1*vy1); - double t1 = (zt - hitOnPlane.z())/vz1; - hitMCOnTrk.setXYZ(hitOnPlane.x()+vx1*t1, hitOnPlane.y()+vy1*t1, zt); - }else{ - if(debugMode>0) System.out.println("check particle/curvature signs"); - } - } - if(debugMode>0) System.out.println("MC after swimming in mag field x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + - " z = " + hitMCOnTrk.z()); - - // Montecarlo hit location on first detector middle plane - if(det==0) h2000.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); - if(det==1) h2001.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); - - if(det==0){ - h1100.fill(hitOnTrk.x(), hitOnTrk.y()); - h1102.fill(hitMCOnTrk.x() - hitOnTrk.x()); - h1104.fill(hitMCOnTrk.y() - hitOnTrk.y()); - - h1106.fill((hitMCOnTrk.theta() - hitOnTrk.theta())); - h1108.fill((hitMCOnTrk.phi() - hitOnTrk.phi())); - - h1112.fill((hitMCOnTrk.x() - hitOnTrk.x())/hitMCOnTrk.x()); - h1114.fill((hitMCOnTrk.y() - hitOnTrk.y())/hitMCOnTrk.y()); - - h202.fill(hitOnTrk.x()); - h1202.fill(hitMCOnTrk.x()); - h204.fill(hitOnTrk.y()); - h1204.fill(hitMCOnTrk.y()); - - }else if(det==1){ - h1101.fill(hitOnTrk.x(), hitOnTrk.y()); - h1103.fill(hitMCOnTrk.x() - hitOnTrk.x()); - h1105.fill(hitMCOnTrk.y() - hitOnTrk.y()); - h1107.fill((hitMCOnTrk.theta() - hitOnTrk.theta())); - h1109.fill((hitMCOnTrk.phi() - hitOnTrk.phi())); - - h1113.fill((hitMCOnTrk.x() - hitOnTrk.x())/hitMCOnTrk.x()); - h1115.fill((hitMCOnTrk.y() - hitOnTrk.y())/hitMCOnTrk.y()); - - h203.fill(hitOnTrk.x()); - h1203.fill(hitMCOnTrk.x()); - h205.fill(hitOnTrk.y()); - h1205.fill(hitMCOnTrk.y()); - } - if(debugMode>0){ - System.out.println("MC hit coordinates " + hitMCOnTrk.x() + " " + hitMCOnTrk.y() + " " + hitMCOnTrk.z()); - System.out.println("MC theta " + hitMCOnTrk.theta() + " hit on trk " + hitOnTrk.theta()); - System.out.println("MC phi " + hitMCOnTrk.phi() + " hit on trk " + hitOnTrk.phi()); - System.out.println("trk hit coordinates " + hitOnTrk.x() + " " + hitOnTrk.y() + " " + hitOnTrk.z()); - } - } - } // end MC comparison - } // end loop on crosses - } - } - - if(debugMode>=0) - System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " - + nevWithCrosses + " @@@@ number of reconstructed FTParticles " + nOfFTParticles); - - if(plotDiagnosticHistograms){ - JFrame frame = new JFrame("FT Reconstruction"); - frame.setSize(1200, 800); - EmbeddedCanvas canvas = new EmbeddedCanvas(); - canvas.divide(3, 3); - canvas.cd(0); - canvas.draw(h1); - canvas.cd(1); - canvas.draw(h2); - canvas.cd(2); - canvas.draw(h3); - canvas.cd(3); - // canvas.draw(h4); - h501.setFillColor(3); // green - h502.setFillColor(5); // yellow - h503.setFillColor(8); // dark green - h504.setFillColor(7); // orange - h600.setFillColor(9); // blue violet - h602.setFillColor(3); // green trk0 - h603.setFillColor(5); // yellow trk1 - - canvas.draw(h501); - canvas.draw(h502,"same"); - canvas.cd(4); - canvas.draw(h503,""); - canvas.draw(h504,"same"); - - - for (int i = 0; i < h6.getDataBufferSize(); i++) { - float meanE = h6.getDataBufferBin(i); - float nE = h7.getDataBufferBin(i); - if (nE > 0) { - h6.setDataBufferBin(i, meanE / nE); - } - } - canvas.cd(5); - // canvas.draw(h7); - canvas.draw(h507); - canvas.cd(6); - // canvas.draw(h8); - canvas.draw(h600); - canvas.cd(7); - // canvas.draw(h9); - canvas.draw(h601); - canvas.cd(8); - // canvas.draw(h10); - canvas.draw(h602); - canvas.draw(h603,"same"); - frame.add(canvas); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - - double narrowFactor = 7.; // was 4.5 - JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); - frametrk.setSize(1600, 800); - EmbeddedCanvas canvastrk = new EmbeddedCanvas(); - canvastrk.divide(5, 2); - canvastrk.cd(0); - canvastrk.draw(h100); - canvastrk.cd(1); - canvastrk.draw(h102); - F1D f02 = new F1D("f02","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); - f02.setParameter(0, 10.0); - f02.setParameter(1, 0.0); - f02.setParameter(2, 1.0); - f02.setLineColor(6); - f02.setLineWidth(3); - DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma - f02.setParameter(0, f02.parameter(0).value()); - f02.setParameter(1, f02.parameter(1).value()); - f02.setParameter(2, f02.parameter(2).value()); - DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma - f02.setOptStat(11111); - canvastrk.draw(f02,"same"); - canvastrk.cd(2); - canvastrk.draw(h104); - F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/(narrowFactor)); - f04.setParameter(0, 10.0); - f04.setParameter(1, 0.0); - f04.setParameter(2, 1.0); - f04.setLineColor(6); - f04.setLineWidth(3); - DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma - f04.setParameter(0, f04.parameter(0).value()); - f04.setParameter(1, f04.parameter(1).value()); - f04.setParameter(2, f04.parameter(2).value()); - DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma - f04.setOptStat(11111); - canvastrk.draw(f04,"same"); - canvastrk.cd(3); - canvastrk.draw(h106); - F1D f06 = new F1D("f06","[amp]*gaus(x,[mean],[sigma])", -limTCTheta/narrowFactor, limTCTheta/narrowFactor); - f06.setParameter(0, 10.0); - f06.setParameter(1, h106.getMean()); - f06.setParameter(2, h106.getRMS()); - f06.setLineColor(6); - f06.setLineWidth(3); - DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma - f06.setParameter(0, f06.parameter(0).value()); - f06.setParameter(1, f06.parameter(1).value()); - f06.setParameter(2, f06.parameter(2).value()); - DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma - f06.setOptStat(11111); - canvastrk.draw(f06,"same"); - canvastrk.cd(4); - canvastrk.draw(h108); - F1D f08 = new F1D("f08","[amp]*gaus(x,[mean],[sigma])", -limTCPhi/narrowFactor, limTCPhi/narrowFactor); - f08.setParameter(0, h108.getMax()); - f08.setParameter(1, h108.getMean()); - f08.setParameter(2, h108.getRMS()); - f08.setLineColor(6); - f08.setLineWidth(3); - DataFitter.fit(f08, h108, "Q"); //No options uses error for sigma - f08.setOptStat(11111); - canvastrk.draw(f08,"same"); - - canvastrk.cd(5); - canvastrk.draw(h101); - - canvastrk.cd(6); - canvastrk.draw(h103); - F1D f03 = new F1D("f03","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); - f03.setParameter(0, 10.0); - f03.setParameter(1, 0.0); - f03.setParameter(2, 1.0); - f03.setLineColor(6); - f03.setLineWidth(3); - DataFitter.fit(f03, h103, "Q"); //No options uses error for sigma - f03.setParameter(0, f03.parameter(0).value()); - f03.setParameter(1, f03.parameter(1).value()); - f03.setParameter(2, f03.parameter(2).value()); - DataFitter.fit(f03, h103, "Q"); //No options uses error for sigma - f03.setOptStat(1111); - canvastrk.draw(f03,"same"); - - - canvastrk.cd(7); - canvastrk.draw(h105); - F1D f05 = new F1D("f05","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); - f05.setParameter(0, 10.0); - f05.setParameter(1, 0.0); - f05.setParameter(2, 1.0); - f05.setLineColor(6); - f05.setLineWidth(3); - DataFitter.fit(f05, h105, "Q"); //No options uses error for sigma - f05.setParameter(0, f05.parameter(0).value()); - f05.setParameter(1, f05.parameter(1).value()); - f05.setParameter(2, f05.parameter(2).value()); - DataFitter.fit(f05, h105, "Q"); //No options uses error for sigma - f05.setOptStat(1111); - canvastrk.draw(f05,"same"); - - canvastrk.cd(8); - canvastrk.draw(h107); - F1D f07 = new F1D("f07","[amp]*gaus(x,[mean],[sigma])", -limTCTheta/narrowFactor, limTCTheta/narrowFactor); - f07.setParameter(0, h107.getMax()); - f07.setParameter(1, h107.getMean()); - f07.setParameter(2, h107.getRMS()); - f07.setLineColor(6); - f07.setLineWidth(3); - DataFitter.fit(f07, h107, "Q"); //No options uses error for sigma - f07.setOptStat(1111); - canvastrk.draw(f07,"same"); - - canvastrk.cd(9); - canvastrk.draw(h109); - F1D f09 = new F1D("f09","[amp]*gaus(x,[mean],[sigma])", -limTCPhi/narrowFactor, limTCPhi/narrowFactor); - f09.setParameter(0, h109.getMax()); - f09.setParameter(1, h109.getMean()); - f09.setParameter(2, h109.getRMS()); - f09.setLineColor(6); - f09.setLineWidth(3); - DataFitter.fit(f09, h109, "Q"); //No options uses error for sigma - f09.setParameter(0, f09.parameter(0).value()); - f09.setParameter(1, f09.parameter(1).value()); - f09.setParameter(2, f09.parameter(2).value()); - DataFitter.fit(f09, h109, "Q"); //No options uses error for sigma - f09.setOptStat(1111); - canvastrk.draw(f09,"same"); - frametrk.add(canvastrk); - frametrk.setLocationRelativeTo(null); - frametrk.setVisible(true); - } - - JFrame frametrkres = new JFrame("FTTRK Resolutions wrt MC generated events"); - frametrkres.setSize(1800, 800); - EmbeddedCanvas canvastrkres = new EmbeddedCanvas(); - canvastrkres.divide(7, 2); - int ii = 0; - canvastrkres.cd(ii); - canvastrkres.draw(h1100); - canvastrkres.cd(++ii); - canvastrkres.draw(h1102); - F1D f1 = new F1D("f1","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); - f1.setParameter(0, h1102.getMax()); - f1.setParameter(1, h1102.getMean()); - f1.setParameter(2, h1102.getRMS()); - f1.setLineColor(4); - f1.setLineWidth(3); - DataFitter.fit(f1, h1102, "Q"); //No options uses error for sigma - f1.setParameter(0, f1.parameter(0).value()); - f1.setParameter(1, f1.parameter(1).value()); - f1.setParameter(2, f1.parameter(2).value()); - DataFitter.fit(f1, h1102, "Q"); //No options uses error for sigma - f1.setOptStat(1111); - canvastrkres.draw(f1,"same"); - if(debugMode>0) System.out.println(" mean = " + f1.parameter(1).value() - + " sigma = " + f1.parameter(2).value()); - canvastrkres.cd(++ii); - canvastrkres.draw(h1104); - F1D f2 = new F1D("f2","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); - f2.setParameter(0, f1.parameter(0).value()); - f2.setParameter(1, f1.parameter(1).value()); - f2.setParameter(2, f1.parameter(2).value()); - f2.setLineColor(24); - f2.setLineWidth(3); - DataFitter.fit(f2, h1104, "Q"); //No options uses error for sigma - f2.setOptStat(1111); - canvastrkres.draw(f2,"same"); - if(debugMode>0) System.out.println(" mean = " + f2.parameter(1).value() - + " sigma = " + f2.parameter(2).error()); - canvastrkres.cd(++ii); - canvastrkres.draw(h1106); - F1D f6 = new F1D("f6","[amp]*gaus(x,[mean],[sigma])", -0.001, 0.001); - f6.setParameter(0, f1.parameter(0).value()); - f6.setParameter(1, h1106.getMean()); - f6.setParameter(2, h1106.getRMS()); - f6.setLineColor(24); - f6.setLineWidth(3); - DataFitter.fit(f6, h1106, "Q"); //No options uses error for sigma - f6.setOptStat(1111); - canvastrkres.draw(f6,"same"); - - canvastrkres.cd(++ii); - canvastrkres.draw(h1108); - F1D f8 = new F1D("f8","[amp]*gaus(x,[mean],[sigma])", -0.005, 0.005); - f8.setParameter(0, h1108.getMax()); - f8.setParameter(1, h1108.getMean()); - f8.setParameter(2, h1108.getRMS()/2); - f8.setLineColor(24); - f8.setLineWidth(3); - DataFitter.fit(f8, h1108, "Q"); //No options uses error for sigma - f8.setOptStat(1111); - canvastrkres.draw(f8,"same"); - canvastrkres.cd(++ii); - canvastrkres.draw(h1112); - F1D f12 = new F1D("f12","[amp]*gaus(x,[mean],[sigma])", -0.05, 0.05); - f12.setParameter(0, f1.parameter(0).value()); - f12.setParameter(1, h1112.getMean()); - f12.setParameter(2, h1112.getRMS()); - f12.setLineColor(24); - f12.setLineWidth(3); - DataFitter.fit(f12, h1112, "Q"); //No options uses error for sigma - f12.setOptStat(1111); - canvastrkres.draw(f12,"same"); - - canvastrkres.cd(++ii); - canvastrkres.draw(h1114); - F1D f14 = new F1D("f14","[amp]*gaus(x,[mean],[sigma])", -0.1, 0.1); - f14.setParameter(0, f1.parameter(0).value()); - f14.setParameter(1, h1114.getMean()); - f14.setParameter(2, h1114.getRMS()); - f14.setLineColor(24); - f14.setLineWidth(3); - DataFitter.fit(f14, h1114, "Q"); //No options uses error for sigma - f14.setOptStat(1111); - canvastrkres.draw(f14,"same"); - - canvastrkres.cd(++ii); - canvastrkres.draw(h1101); - canvastrkres.cd(++ii); - canvastrkres.draw(h1103); - F1D f3 = new F1D("f3","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); - f3.setParameter(0, f1.parameter(0).value()); - f3.setParameter(1, f1.parameter(1).value()); - f3.setParameter(2, f1.parameter(2).value()); - f3.setLineColor(34); - f3.setLineWidth(3); - DataFitter.fit(f3, h1103, "Q"); //No options uses error for sigma - f3.setOptStat(1111); - canvastrkres.draw(f3,"same"); - if(debugMode>0) System.out.println(" mean = " + f3.parameter(1).value() - + " sigma = " + f3.parameter(2).error()); - canvastrkres.cd(++ii); - canvastrkres.draw(h1105); - F1D f4 = new F1D("f4","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); - f4.setParameter(0, f1.parameter(0).value()); - f4.setParameter(1, f1.parameter(1).value()); - f4.setParameter(2, f1.parameter(2).value()); - f4.setLineColor(44); - f4.setLineWidth(3); - DataFitter.fit(f4, h1105, "Q"); //No options uses error for sigma - f4.setOptStat(1111); - canvastrkres.draw(f4,"same"); - if(debugMode>0) System.out.println(" mean = " + f4.parameter(1).value() - + " sigma = " + f4.parameter(2).error()); - canvastrkres.cd(++ii); - canvastrkres.draw(h1107); - F1D f17 = new F1D("f17","[amp]*gaus(x,[mean],[sigma])", -0.001, 0.001); - f17.setParameter(0, h1107.getMax()); - f17.setParameter(1, h1107.getMean()); - f17.setParameter(2, h1107.getRMS()); - f17.setLineColor(24); - f17.setLineWidth(3); - DataFitter.fit(f17, h1107, "Q"); //No options uses error for sigma - f17.setOptStat(1111); - canvastrkres.draw(f17,"same"); - canvastrkres.cd(++ii); - canvastrkres.draw(h1109); - F1D f19 = new F1D("f19","[amp]*gaus(x,[mean],[sigma])", -0.002, 0.002); - f19.setParameter(0, h1109.getMax()); - f19.setParameter(1, h1109.getMean()); - f19.setParameter(2, h1109.getRMS()); - f19.setLineColor(24); - f19.setLineWidth(3); - DataFitter.fit(f19, h1109, "Q"); //No options uses error for sigma - f19.setOptStat(1111); - canvastrkres.draw(f19,"same"); - - canvastrkres.cd(++ii); - canvastrkres.draw(h1113); - F1D f13 = new F1D("f13","[amp]*gaus(x,[mean],[sigma])", -0.05, 0.05); - f13.setParameter(0, f1.parameter(0).value()); - f13.setParameter(1, h1113.getMean()); - f13.setParameter(2, h1113.getRMS()); - f13.setLineColor(24); - f13.setLineWidth(3); - DataFitter.fit(f13, h1113, "Q"); //No options uses error for sigma - f13.setOptStat(1111); - canvastrkres.draw(f13,"same"); - - canvastrkres.cd(++ii); - canvastrkres.draw(h1115); - F1D f15 = new F1D("f15","[amp]*gaus(x,[mean],[sigma])", -0.1, 0.1); - f15.setParameter(0, f1.parameter(0).value()); - f15.setParameter(1, h1115.getMean()); - f15.setParameter(2, h1115.getRMS()); - f15.setLineColor(24); - f15.setLineWidth(3); - DataFitter.fit(f15, h1115, "Q"); //No options uses error for sigma - f15.setOptStat(1111); - canvastrkres.draw(f15,"same"); - - frametrkres.add(canvastrkres); - frametrkres.setLocationRelativeTo(null); - frametrkres.setVisible(true); - - JFrame frametrkrel = new JFrame("FTTRK Resolutions layer1 vs layer2"); - frametrkrel.setSize(800, 800); - EmbeddedCanvas canvastrkrel = new EmbeddedCanvas(); - canvastrkrel.divide(2, 2); - canvastrkrel.cd(0); - canvastrkrel.draw(h202); - canvastrkrel.draw(h1202,"same"); - canvastrkrel.cd(1); - canvastrkrel.draw(h203); - canvastrkrel.draw(h1203,"same"); - canvastrkrel.cd(2); - canvastrkrel.draw(h204); - canvastrkrel.draw(h1204,"same"); - canvastrkrel.cd(3); - canvastrkrel.draw(h205); - canvastrkrel.draw(h1205,"same"); - - frametrkrel.add(canvastrkrel); - frametrkrel.setLocationRelativeTo(null); - frametrkrel.setVisible(true); - - JFrame frameSecradio = new JFrame("20 sectors occupancy"); - frameSecradio.setSize(1000,500); - EmbeddedCanvas canvasSecradio = new EmbeddedCanvas(); - canvasSecradio.divide(2,1); - canvasSecradio.cd(0); - canvasSecradio.draw(hSecDet0); - // excluded cells - double excx0h1[] = {0., 1., 2., 3., 4., 5., 10., 11., 12., 13.}; - double excy0h1[] = {10., 11., 12., 13., 14., 15., 16., 17.}; - GraphErrors excludedDet0half1 = new GraphErrors(); - for(int i=0; i Date: Sat, 26 Feb 2022 14:35:51 +0100 Subject: [PATCH 074/104] add modules and detector layers for FTTRK --- .../main/java/org/jlab/detector/base/DetectorLayer.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorLayer.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorLayer.java index 1f2241a221..1641018fe6 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorLayer.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorLayer.java @@ -32,5 +32,14 @@ public class DetectorLayer { public static final byte TARGET_CENTER=1; public static final byte TARGET_DOWNSTREAM=2; public static final byte TARGET_UPSTREAM=3; + + public static final byte FTTRK_MODULE1=1; + public static final byte FTTRK_MODULE2=2; + public static final byte FTTRK_LAYER1=1; + public static final byte FTTRK_LAYER2=2; + public static final byte FTTRK_LAYER3=3; + public static final byte FTTRK_LAYER4=4; + + } From 83597981e4ee1996dbdd68206b254d03aea8a23a Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sat, 26 Feb 2022 14:43:39 +0100 Subject: [PATCH 075/104] tuning of parameters, rename TRK0->TRK1, TRK1->TRK2 --- .../ft/src/main/java/org/jlab/rec/ft/FTConstants.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java index 7c285e8d83..b787e26c98 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java @@ -24,13 +24,14 @@ public class FTConstants { public static final double TRK_STRIP_MAX_TIME = 350; // minimum time value associated to one strip public static final double TRK_MIN_CROSS_NUMBER = 1; // minimum number of crosses to find a line in the tracker - public static final double TRK0_TRK1_RADTOL = 0.05; // max tolerance for TRK0/TRK1 distance (3D) (was 1.-0.5) - public static final double TRK0_TRK1_PHITOL = 0.07; // max tolerance for TRK0/TRK1 phi angular deviation (was 1.-0.7) - public static final double TRK0_TRK1_THETATOL = 0.07; // max tolerance for TRK0/TRK1 theta angulare deviation (was 1.-0.7) + public static final double TRK1_TRK2_RADTOL = 0.05; // max tolerance for TRK0/TRK1 distance (3D) (was 1.-0.5) + public static final double TRK1_TRK2_PHITOL = 0.07; // max tolerance for TRK0/TRK1 phi angular deviation (was 1.-0.7) + public static final double TRK1_TRK2_THETATOL = 0.07; // max tolerance for TRK0/TRK1 theta angulare deviation (was 1.-0.7) public static final double FTTRKMinAdcThreshold = 18.; // check min threshold for FTTTRK ADCs (18) public static final double FTTRKMaxAdcThreshold = 2000.; // check max threshold for FTTTRK ADCs (18) was 1000 170122 public static final int TRK_MAX_StripsForTruncatedMean = 20; // threshold for maxnumber of strips included in the truncated mean algo. + public static final int TRK_MIN_ClusterSizeForCentroid = 3; // minimum size of the cluster to provide a reliable location by its centroid public static final double TRK_MIN_CLUS_ENERGY = 20.; // minimum cluster energy to accept a signal cluster (20) public static final int TRK_MIN_CLUS_SIZE = 0; // minimum cluster size to form crosses (0: no limit on cluster size) // 2 is very strict public static final int TRK_MAXNUMBEROFHITS = 100; // maximum number of accepted hits in the tracker banks From 16effeec4999be56c61b938572b4d8cfb7c82fb6 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sat, 26 Feb 2022 14:51:16 +0100 Subject: [PATCH 076/104] use static constants for limiting strips; cleanup --- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 236 ++++++------------ 1 file changed, 79 insertions(+), 157 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index 77184f1901..970247c3a5 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import java.util.List; -//import java.util.Collections; +import org.jlab.detector.base.DetectorLayer; import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; @@ -15,9 +15,7 @@ import org.jlab.io.evio.EvioDataEvent; import org.jlab.io.hipo.HipoDataEvent; import org.jlab.rec.ft.FTConstants; -//import org.jlab.utils.groups.IndexedTable; -import org.jlab.geom.prim.Point3D; -import org.jlab.rec.ft.FTEBEngine; + /** * @@ -29,11 +27,17 @@ public class FTTRKReconstruction { public static int debugMode = 0; // 1 for verbose, set it here (better be set in the steering Engine) PROVISIONAL - public static float[] crEnergy; - public static float[] crTime; public static int[] sectorLimits = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; - + public static int NStripsSectors = 20; + public static int stripsInLongSector = 64; + public static int stripsInShortSector = 32; + public static int sideShortStrips = 2*FTTRKConstantsLoader.SideHalfstrips; // 256 + public static int sequentialStrips = FTTRKConstantsLoader.Longstrips + FTTRKConstantsLoader.SideHalfstrips + sideShortStrips; // 512 + public static int stripDiscontinuity1 = FTTRKConstantsLoader.Longstrips; // 128 CHECK DISCONTINUITIES +- 1 strip + public static int stripDiscontinuity2 = FTTRKConstantsLoader.Longstrips + sideShortStrips + 1; // 385 + public static int stripDiscontinuity3 = sequentialStrips + FTTRKConstantsLoader.SideHalfstrips; // 640 + public static int stripDiscontinuity4 = stripDiscontinuity3+1; public FTTRKReconstruction() { @@ -105,19 +109,18 @@ public ArrayList findClusters(List hits) // for each layer and sector, loop over the strips: // once one is selected for the first time, loop over the remainder // clusters are delimited by strips with no hits - - int[] indR = new int[512]; - int[] indL = new int[512]; + int[] indR = new int[sequentialStrips]; + int[] indL = new int[sequentialStrips]; // strip index: from 0 to 512 (full right hand side, left hand side fired only in the interval 384-639) // strip number: from 1 to 768 - for(int i=0; i<512; i++){ - if(i<128){ + for(int i=0; i= 128 && i < 384){ + }else if(i >= FTTRKConstantsLoader.Longstrips && i < (FTTRKConstantsLoader.Longstrips + sideShortStrips)){ //384 indR[i] = i; - indL[i] = i+256; - }else if(i >= 384){ - indR[i] = indL[i] = i+256; + indL[i] = i + sideShortStrips; //256 + }else if(i >= (FTTRKConstantsLoader.Longstrips + sideShortStrips)){ // 384 + indR[i] = indL[i] = i + sideShortStrips; // 256 } } @@ -126,7 +129,7 @@ public ArrayList findClusters(List hits) for(int il=0; il findClusters(List hits) HitArray[ris][il].get_Edep(), HitArray[ris][il].get_Time(), HitArray[ris][il].get_Id())); // look for a consecutive strip in the stack and stick it to the cluster int isnext = is+1; - while(isnext < 512 && HitArray[indR[isnext]][il] != null && !checked[indR[isnext]][il]){ + while(isnext < sequentialStrips && HitArray[indR[isnext]][il] != null && !checked[indR[isnext]][il]){ int nris = indR[isnext]; checked[nris][il] = true; clusterHits.add(new FTTRKHit(HitArray[nris][il].get_Sector(), HitArray[nris][il].get_Layer(), HitArray[nris][il].get_Strip(), @@ -168,8 +171,8 @@ public ArrayList findClusters(List hits) is++; } // second loop on LHS strips (only lateral strips) - is = 128; - while(is < 384){ + is = FTTRKConstantsLoader.Longstrips; + while(is < (FTTRKConstantsLoader.Longstrips + sideShortStrips)){ //384 int nst = 0; int lis = indL[is]; if(HitArray[lis][il] != null && !checked[lis][il]){ @@ -180,7 +183,8 @@ public ArrayList findClusters(List hits) HitArray[lis][il].get_Edep(), HitArray[lis][il].get_Time(), HitArray[lis][il].get_Id())); // look for a consecutive strip in the stack and stick it to the cluster int isnext = is+1; - while(isnext < 640 && HitArray[indL[isnext]][il] != null && !checked[indL[isnext]][il]){ + while(isnext < (sequentialStrips + FTTRKConstantsLoader.SideHalfstrips) && // 640 + HitArray[indL[isnext]][il] != null && !checked[indL[isnext]][il]){ int nlis = indL[isnext]; checked[nlis][il] = true; clusterHits.add(new FTTRKHit(HitArray[nlis][il].get_Sector(), HitArray[nlis][il].get_Layer(), HitArray[nlis][il].get_Strip(), @@ -215,12 +219,13 @@ public ArrayList findClusters(List hits) for(int i=0; i < nbhits; i++){ FTTRKHit hit = clust.get(i); int nstrip = hit.get_Strip(); - if(nstrip==128 || nstrip==385 || nstrip==640 || nstrip==641){ + // 641 + if(nstrip==stripDiscontinuity1 || nstrip==stripDiscontinuity2 || nstrip==stripDiscontinuity3 || nstrip==stripDiscontinuity4){ needsReordering = true; - if(nstrip==128) clusterId11 = clust.get_CId(); //cut 127-384 - if(nstrip==385) clusterId12 = clust.get_CId(); - if(nstrip==640) clusterId21 = clust.get_CId(); // cut 640-641 - if(nstrip==641) clusterId22 = clust.get_CId(); + if(nstrip==stripDiscontinuity1) clusterId11 = clust.get_CId(); //cut 127-384 + if(nstrip==stripDiscontinuity2) clusterId12 = clust.get_CId(); + if(nstrip==stripDiscontinuity3) clusterId21 = clust.get_CId(); // cut 640-641 + if(nstrip==stripDiscontinuity4) clusterId22 = clust.get_CId(); } } } @@ -359,51 +364,6 @@ public ArrayList findCrosses(List clusters) { } } - // best validated crosses: for every detector choose the cross with larger deposited energy: only two crosses are saved with the largest energy - // not used if all crosses are used for multihit matching - /* - ArrayList validatedCrosses = new ArrayList(); - double maxEn1 =-100.; - double maxEn2 =-100.; - int idMax1=-1, idMax2=-1; - for(int ic=0; icmaxEn1){ - maxEn1 = crossEnergy; - idMax1 = ic; - } - }else if(aCross.get_Region()==2){ - if(crossEnergy>maxEn2){ - maxEn2 = crossEnergy; - idMax2 = ic; - } - } - } - if(idMax1>=0) validatedCrosses.add(crosses.get(idMax1)); - if(idMax2>=0) validatedCrosses.add(crosses.get(idMax2)); - - double diffRadTolerance = FTConstants.TRK0_TRK1_RADTOL; - double diffPhiTolerance = FTConstants.TRK0_TRK1_PHITOL; - double diffThetaTolerance = FTConstants.TRK0_TRK1_THETATOL; - -// make a geometric match of the two validate crosses - if(validatedCrosses.size()== FTTRKConstantsLoader.NSupLayers){ - Point3D cross0 = validatedCrosses.get(0).get_Point(); - Point3D cross1 = validatedCrosses.get(1).get_Point(); - double r02d = Math.sqrt(cross0.x()*cross0.x() + cross0.y()*cross0.y()); - double r12d = Math.sqrt(cross1.x()*cross1.x() + cross1.y()*cross1.y()); - double r0 = Math.sqrt(r02d*r02d + cross0.z()*cross0.z()); - double r1 = Math.sqrt(r12d*r12d + cross1.z()*cross1.z()); - double diffRadii = r02d-r12d; - double diffTheta = Math.acos(cross0.z()/r0) - Math.acos(cross1.z()/r1); - double diffPhi = Math.atan2(cross0.y(), cross0.x()) - Math.atan2(cross1.y(), cross1.x()); - if(!(Math.abs(diffPhi) < diffPhiTolerance && Math.abs(diffRadii)< diffRadTolerance && Math.abs(diffTheta) < diffThetaTolerance)) validatedCrosses.clear(); - } - */ - - //return validatedCrosses; // return this if just the best two crosses per event are required return crosses; } @@ -542,8 +502,6 @@ public void writeHipoBanks(DataEvent event, List hits, List hits, List=1) System.out.println("energy and time to be stored in banks " + crosses.get(j).get_Energy() + " " + crosses.get(j).get_Time()); - // control histograms should be provisional and filled only if existing - if(FTEBEngine.timeEnergyDiagnosticHistograms){ - FTEBEngine.h507.fill(crosses.get(j).get_Time(), crosses.get(j).get_Energy()); - if(crosses.get(j).get_Id()==0){ - FTEBEngine.h503.fill(crosses.get(j).get_Time()); - FTEBEngine.h501.fill(crosses.get(j).get_Energy()); - FTEBEngine.h505.fill(crosses.get(j).get_Time(), crosses.get(j).get_Energy()); - FTTRKCluster cl1 = crosses.get(j).get_Cluster1(); - FTTRKCluster cl2 = crosses.get(j).get_Cluster2(); - FTEBEngine.h510.fill(cl1.get_TotalEnergy(), cl2.get_TotalEnergy()); - FTEBEngine.h512.fill(cl1.get_TotalEnergy()); - FTEBEngine.h512.fill(cl2.get_TotalEnergy()); - for(int k=0; k=1) System.out.println("energy and time to be stored in banks " + crosses.get(j).get_Energy() + " " + crosses.get(j).get_Time()); bankCross.setFloat("energy", j, (float) crosses.get(j).get_Energy()); bankCross.setFloat("time", j, (float) crosses.get(j).get_Time()); - int dummy = crosses.get(j).get_Cluster1().get_CId(); - int dummy2 = crosses.get(j).get_Cluster2().get_CId(); bankCross.setShort("Cluster1ID", j, (short) crosses.get(j).get_Cluster1().get_CId()); bankCross.setShort("Cluster2ID", j, (short) crosses.get(j).get_Cluster2().get_CId()); } @@ -674,7 +599,6 @@ public void writeEvioBanks(DataEvent event, List hits, List hits, List clusters){ // update clusterIndex and crossIndex for hits belonging to a cross for(FTTRKCluster aCluster: clusters){ - int i=-1; for(FTTRKHit ahitInCluster: aCluster){ for(FTTRKHit aHit: hits){ if(aHit.get_Id()==ahitInCluster.get_Id()){ @@ -691,19 +615,19 @@ public void updateAllHitsWithAssociatedIDs(List hits, List=129 && icomponent<=384){ - icomponent += 256; - }else if(icomponent>=385 && icomponent<=640){ - icomponent -= 256; + if(ilayer==DetectorLayer.FTTRK_LAYER2 || ilayer==DetectorLayer.FTTRK_LAYER3){ // RECO vertical strips + if(icomponent>=(stripDiscontinuity1+1) && icomponent<=(stripDiscontinuity2-1)){ // [129,384] + icomponent += sideShortStrips; // 256 + }else if(icomponent>=stripDiscontinuity2 && icomponent<=stripDiscontinuity3){ // [385,640] + icomponent -= sideShortStrips; // 256 } - }else if(ilayer==1 || ilayer==4){ // RECO horizontal strips - if(icomponent>=129 && icomponent<=384){ - icomponent = 513 - icomponent; - }else if(icomponent>=385 && icomponent<=640){ - icomponent = 1025 - icomponent; + }else if(ilayer==DetectorLayer.FTTRK_LAYER1 || ilayer==DetectorLayer.FTTRK_LAYER4){ // RECO horizontal strips + if(icomponent>=129 && icomponent<=384){ // [129,384] + icomponent = 513 - icomponent; // 513 + }else if(icomponent>=stripDiscontinuity2 && icomponent<=stripDiscontinuity3){ // [385,640] + icomponent = 2*sequentialStrips+1 - icomponent; // 1025 }else{ // for horizontal strips flip also long strips - icomponent = 769 - icomponent; + icomponent = FTTRKConstantsLoader.Nstrips+1 - icomponent; // 769 } } return icomponent; @@ -712,19 +636,19 @@ public int flipStripVertical(int ilayer, int icomponent){ public int flipStripHorizontal(int ilayer, int icomponent){ // flip the layer horizontally with respect to the x axis (top/bottom flip) // strips 1-128 - if(ilayer==1 || ilayer==4){ // RECO vertical strips - if(icomponent>=129 && icomponent<=384){ - icomponent += 256; - }else if(icomponent>=385 && icomponent<=640){ - icomponent -= 256; + if(ilayer==DetectorLayer.FTTRK_LAYER1 || ilayer==DetectorLayer.FTTRK_LAYER4){ // RECO vertical strips + if(icomponent>=(stripDiscontinuity1+1) && icomponent<=(stripDiscontinuity2-1)){ // [129, 384] + icomponent += sideShortStrips; // 256 + }else if(icomponent>=stripDiscontinuity2 && icomponent<=stripDiscontinuity3){ // [385,640] + icomponent -= sideShortStrips; // 256 } - }else if(ilayer==2 || ilayer==3){ // RECO horizontal strips - if(icomponent>=129 && icomponent<=384){ - icomponent = 513 - icomponent; - }else if(icomponent>=385 && icomponent<=640){ - icomponent = 1025 - icomponent; + }else if(ilayer==DetectorLayer.FTTRK_LAYER2 || ilayer==DetectorLayer.FTTRK_LAYER3){ // RECO horizontal strips + if(icomponent>=(stripDiscontinuity1+1) && icomponent<=(stripDiscontinuity2-1)){ // [129,384] + icomponent = sequentialStrips+1 - icomponent; // 513 + }else if(icomponent>=stripDiscontinuity2 && icomponent<=stripDiscontinuity3){ // [385,640] + icomponent = 2*sequentialStrips+1 - icomponent; // 1025 }else{ - icomponent = 769 - icomponent; + icomponent = FTTRKConstantsLoader.Nstrips+1 - icomponent; // 769 } } @@ -743,7 +667,7 @@ public int reverseStripsInSector(int icomponent){ // excluded in the sector, [i+1]is included // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips int nsector = findSector(icomponent); - if(nsector>20) System.out.println("wrong sector number, check code"); + if(nsector>NStripsSectors) System.out.println("wrong sector number, check code"); int offset = sectorLimits[nsector+1] - icomponent; icomponent = sectorLimits[nsector]+1 + offset; @@ -755,7 +679,7 @@ public int reverseStripInFirstHalf(int icomponent){ // excluded in the sector, [i+1]is included // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips int nsector = findSector(icomponent); - if(nsector>20) System.out.println("wrong sector number, check code"); + if(nsector>NStripsSectors) System.out.println("wrong sector number, check code"); int halfStrip = (sectorLimits[nsector+1]-sectorLimits[nsector])/2 + sectorLimits[nsector]; if(icomponent <= halfStrip){ int offset = halfStrip - icomponent; @@ -770,7 +694,7 @@ public int reverseStripInSecondHalf(int icomponent){ // excluded in the sector, [i+1]is included // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips int nsector = findSector(icomponent); - if(nsector>20) System.err.println("wrong FTTRK strip sector number, check code"); + if(nsector>NStripsSectors) System.err.println("wrong FTTRK strip sector number, check code"); int halfStrip = (sectorLimits[nsector+1]-sectorLimits[nsector])/2 + sectorLimits[nsector]; if(icomponent > halfStrip){ int offset = sectorLimits[nsector+1] - icomponent; @@ -785,7 +709,7 @@ public int swapHalves(int icomponent){ // excluded in the sector, [i+1]is included // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips int nsector = findSector(icomponent); - if(nsector>20) System.err.println("wrong FTTRK strip sector number, check code"); + if(nsector>NStripsSectors) System.err.println("wrong FTTRK strip sector number, check code"); int halfWid = (sectorLimits[nsector+1]-sectorLimits[nsector])/2; int halfStrip = halfWid + sectorLimits[nsector]; if(icomponent >= halfStrip+1){ @@ -818,13 +742,13 @@ public static int findSector(int icomponent){ // the number of the starting strip of a sector: [i] is excluded from sector i, [i+1] is included // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips int nsector = -1; - for(int i=0; i<20; i++){ + for(int i=0; isectorLimits[i] && icomponent<=sectorLimits[i+1]){ nsector = i; break; } } - if(nsector>20) System.err.println("wrong FTTRK strip sector number, check code"); + if(nsector>NStripsSectors) System.err.println("wrong FTTRK strip sector number, check code"); return nsector; } @@ -843,21 +767,21 @@ public int renumberStrip(int ilayer, int icomponent){ // renumber strips from FEE number (to RECO numbering // strips numbering 1-768 int newStripNumber = -1; - if(ilayer==1){ - if((icomponent>=1 && icomponent <=128) || (icomponent>=641 && icomponent<=768)){ + if(ilayer==DetectorLayer.FTTRK_LAYER1){ + if((icomponent>=1 && icomponent <=stripDiscontinuity1) || (icomponent>=641 && icomponent<=768)){ //[1,128], [641,768] newStripNumber = icomponent; - }else if(icomponent>=129 && icomponent<=256){ - newStripNumber = icomponent+256; - }else if(icomponent>=257 && icomponent<=512){ - newStripNumber = icomponent-128; - }else if(icomponent>=513 && icomponent<=640){ + }else if(icomponent>=(stripDiscontinuity1+1) && icomponent<=sideShortStrips){ // [129, 256] + newStripNumber = icomponent+sideShortStrips; // 256 + }else if(icomponent>=(sideShortStrips+1) && icomponent<=sequentialStrips){ // [257, 512] + newStripNumber = icomponent-FTTRKConstantsLoader.Longstrips; // 128 + }else if(icomponent>=(sequentialStrips+1) && icomponent<=stripDiscontinuity3){ // [513, 640] newStripNumber = icomponent; } - }else if(ilayer==2 || ilayer==4 || ilayer==3){ - if(icomponent>=257 && icomponent <=512){ - newStripNumber = icomponent+128; - }else if(icomponent>=513 && icomponent <=640){ - newStripNumber = icomponent-256; + }else if(ilayer==DetectorLayer.FTTRK_LAYER2 || ilayer==DetectorLayer.FTTRK_LAYER4 || ilayer==DetectorLayer.FTTRK_LAYER3){ + if(icomponent>=(sideShortStrips+1) && icomponent <=sequentialStrips){ // [257, 512] + newStripNumber = icomponent+FTTRKConstantsLoader.Longstrips; // 128 + }else if(icomponent>=(sequentialStrips+1) && icomponent <=stripDiscontinuity3){ // [513, 640] + newStripNumber = icomponent-sideShortStrips; // 256 }else{ newStripNumber = icomponent; } @@ -865,7 +789,7 @@ public int renumberStrip(int ilayer, int icomponent){ return (newStripNumber); } -public int renumberFEE2RECRotatedAndAdjustVanilla(int run, int ilayer, int icomponent){ +public int renumberFEE2REC(int run, int ilayer, int icomponent){ // apply strip renumbering only if(run>10) icomponent = renumberStrip(ilayer, icomponent); return icomponent; @@ -877,10 +801,10 @@ public int renumberFEE2RECRotatedAndAdjust_Fall18RGA(int run, int ilayer, int ic if(run>0){ icomponent = renumberStrip(ilayer, icomponent); // overturn layer 1+4 - if(ilayer==1 || ilayer==4) icomponent = overturnModule(ilayer, icomponent); + if(ilayer==DetectorLayer.FTTRK_LAYER1 || ilayer==DetectorLayer.FTTRK_LAYER4) icomponent = overturnModule(ilayer, icomponent); int isec1 = -1; - if(ilayer==1){ + if(ilayer==DetectorLayer.FTTRK_LAYER1){ isec1 = findSector(icomponent); if(isec1 == 1){ icomponent = reverseStripInSecondHalf(icomponent); @@ -898,16 +822,16 @@ public int renumberFEE2RECRotatedAndAdjust_Fall18RGA(int run, int ilayer, int ic icomponent = reverseStripInFirstHalf(icomponent); } - }else if(ilayer==2){ + }else if(ilayer==DetectorLayer.FTTRK_LAYER2){ isec1 = findSector(icomponent); if(isec1==1){ icomponent = reverseStripsInSector(icomponent); - if(icomponent>96) icomponent -= 8; + if(icomponent>(stripsInLongSector+stripsInShortSector)/2) icomponent -= 8; // 96 }else if(isec1==3){ icomponent = reverseStripsInSector(icomponent); } - }else if(ilayer==3){ + }else if(ilayer==DetectorLayer.FTTRK_LAYER3){ isec1 = findSector(icomponent); if(isec1==11){ icomponent = swapSectors(icomponent, 10); @@ -931,7 +855,7 @@ public int renumberFEE2RECRotatedAndAdjust_Fall18RGA(int run, int ilayer, int ic icomponent = reverseStripsInSector(icomponent); } - }else if(ilayer==4){ + }else if(ilayer==DetectorLayer.FTTRK_LAYER4){ isec1 = findSector(icomponent); if(isec1 == 1){ icomponent = reverseStripInSecondHalf(icomponent); @@ -944,8 +868,6 @@ public int renumberFEE2RECRotatedAndAdjust_Fall18RGA(int run, int ilayer, int ic icomponent = reverseStripInSecondHalf(icomponent); } } - - isec1 = findSector(icomponent); // rehash } return icomponent; From cb05306313fc4b99a9ffae3cd00a8f67cf1739f7 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sat, 26 Feb 2022 14:53:11 +0100 Subject: [PATCH 077/104] cleanup --- .../java/org/jlab/rec/ft/trk/FTTRKHit.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java index 4d0f068537..28cd3e98a1 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java @@ -7,7 +7,6 @@ import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Point3D; -import org.jlab.rec.ft.trk.FTTRKConstantsLoader; /** * @@ -228,12 +227,12 @@ public int get_StripNumberFromLocalY(double xGlobal, double yLocal, int layer){ double x = xGlobal*Math.cos(alpha)+yg*Math.sin(alpha); double r=Math.sqrt(x*x+y*y); - if(r<=FTTRKConstantsLoader.Rmax && r>=FTTRKConstantsLoader.InnerHole && Math.abs(y)<=FTTRKConstantsLoader.Pitch*FTTRKConstantsLoader.Nstrips*2/6) { - int strip = (int) Math.floor(y/FTTRKConstantsLoader.Pitch) + 1 + FTTRKConstantsLoader.Nstrips*2/6; - if(strip>FTTRKConstantsLoader.Nstrips*3/6) { // strip in the top sector - strip += FTTRKConstantsLoader.Nstrips*2/6; + if(r<=FTTRKConstantsLoader.Rmax && r>=FTTRKConstantsLoader.InnerHole && Math.abs(y)<=FTTRKConstantsLoader.Pitch*FTTRKConstantsLoader.Nstrips/3) { + int strip = (int) Math.floor(y/FTTRKConstantsLoader.Pitch) + 1 + FTTRKConstantsLoader.Nstrips/3; + if(strip>FTTRKConstantsLoader.Nstrips/2) { // strip in the top sector + strip += FTTRKConstantsLoader.Nstrips/3; }else if(strip>FTTRKConstantsLoader.Nstrips/6 && x>0){ - strip += FTTRKConstantsLoader.Nstrips*2/6; + strip += FTTRKConstantsLoader.Nstrips/3; } return strip; }else{ @@ -248,12 +247,12 @@ public int get_StripNumberFromGlobal(double xGlobal, double yGlobal, int layer){ double y = yGlobal*Math.cos(alpha)-xGlobal*Math.sin(alpha); double r=Math.sqrt(x*x+y*y); - if(r<=FTTRKConstantsLoader.Rmax && r>=FTTRKConstantsLoader.InnerHole && Math.abs(y)<=FTTRKConstantsLoader.Pitch*FTTRKConstantsLoader.Nstrips*2/6) { - int strip = (int) Math.floor(y/FTTRKConstantsLoader.Pitch) + 1 + FTTRKConstantsLoader.Nstrips*2/6; - if(strip>FTTRKConstantsLoader.Nstrips*3/6) { // strip in the top sector - strip += FTTRKConstantsLoader.Nstrips*2/6; + if(r<=FTTRKConstantsLoader.Rmax && r>=FTTRKConstantsLoader.InnerHole && Math.abs(y)<=FTTRKConstantsLoader.Pitch*FTTRKConstantsLoader.Nstrips/3) { + int strip = (int) Math.floor(y/FTTRKConstantsLoader.Pitch) + 1 + FTTRKConstantsLoader.Nstrips/3; + if(strip>FTTRKConstantsLoader.Nstrips/2) { // strip in the top sector + strip += FTTRKConstantsLoader.Nstrips/3; }else if(strip>FTTRKConstantsLoader.Nstrips/6 && x>0){ - strip += FTTRKConstantsLoader.Nstrips*2/6; + strip += FTTRKConstantsLoader.Nstrips/3; } return strip; }else{ From 0c127fcedcae3f2bff9632bd79c60b46b4254dd3 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sat, 26 Feb 2022 14:56:18 +0100 Subject: [PATCH 078/104] usage of DetectorLayer types --- .../java/org/jlab/rec/ft/trk/FTTRKCross.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java index cc798c819c..55810c121a 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCross.java @@ -5,7 +5,7 @@ */ package org.jlab.rec.ft.trk; -import java.util.ArrayList; +import org.jlab.detector.base.DetectorLayer; import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Point3D; import org.jlab.geom.prim.Vector3D; @@ -336,13 +336,14 @@ public void set_CrossParams() { boolean isCluster1EnergyAboveTHR = (inlayerclus.get_TotalEnergy() > FTConstants.TRK_MIN_CLUS_ENERGY); boolean isCluster2EnergyAboveTHR = (outlayerclus.get_TotalEnergy() > FTConstants.TRK_MIN_CLUS_ENERGY); + int regionDet1 = DetectorLayer.FTTRK_MODULE1; // region of detector1: 1 if(d Date: Sat, 26 Feb 2022 15:00:06 +0100 Subject: [PATCH 079/104] cleanup --- .../ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java index 80924ff908..cc6864353e 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKCluster.java @@ -7,7 +7,6 @@ import java.util.ArrayList; import org.jlab.geom.prim.Line3D; -import org.jlab.geom.prim.Vector3D; import org.jlab.rec.ft.FTConstants; /** @@ -94,7 +93,6 @@ public int get_CId() { */ public void set_CId(int _Id) { this._CId = _Id; - // update hits collection with the proper cluster index for(int i=0; i Date: Sat, 26 Feb 2022 15:03:48 +0100 Subject: [PATCH 080/104] remove crTime and crResponse for cross time and energy response from private list --- .../main/java/org/jlab/rec/ft/FTResponse.java | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java index d181285fb2..578f0432be 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java @@ -6,6 +6,7 @@ package org.jlab.rec.ft; import org.jlab.clas.detector.DetectorResponse; +import org.jlab.detector.base.DetectorLayer; /** * @@ -17,9 +18,7 @@ public class FTResponse extends DetectorResponse { private int _size; // cluster multiplicity private int _id; // response ID private int _trkDet; // number of TRK detector (0,1) - - private float _crTime; // provisional: detector time (for crosses only: the location in the bank is overwritten) - private float _crEnergy; // provisional: detector energy (for crosses only same reason) + //private DetectorLayer _trkLayer; // number of TRK detector+1 public FTResponse() { @@ -53,6 +52,7 @@ public void setId(int id) { this._id = id; } + public int getTrkDet() { return _trkDet; } @@ -61,22 +61,24 @@ public void setTrkDet(int ndet) { this._trkDet = ndet; } - - /////////////////////////// provisional (info must be present in banks) - public void setCrTime(float crTime){ - this._crTime = crTime; - } - public float getCrTime(){ - return _crTime; - } - public void setCrEnergy(float crEnergy){ - this._crEnergy = crEnergy; + + /* + public DetectorLayer getTrkDet() { + if(this._id == 0){ + this._trkDet = DetectorLayer.FTTRK_MODULE1; + }else if(this._id == 1){ + this._trkDet = DetectorLayer.FTTRK_MODULE1; + } + return _trkDet; } - public float getCrEnergy(){ - return _crEnergy; + + + public void setTrkDet(int ndet) { + this._trkDet = ndet; } - ////////////////////////// - + */ + + public void show() { System.out.println("ID = "+ this.getId() + " Type = " + this.getType() From 5c7b28abbbd3decce20cf68156265451f3c942a3 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sat, 26 Feb 2022 15:13:59 +0100 Subject: [PATCH 081/104] usage of DetectorLayer types --- .../java/org/jlab/rec/ft/FTEventBuilder.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index eaef9e28bc..1430d195d5 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; import org.jlab.clas.pdg.PhysicsConstants; +import org.jlab.detector.base.DetectorLayer; import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; @@ -11,11 +12,7 @@ import org.jlab.io.evio.EvioDataEvent; import org.jlab.rec.ft.cal.FTCALConstantsLoader; import org.jlab.utils.groups.IndexedTable; -import org.jlab.geom.prim.Line3D; -import org.jlab.geom.prim.Vector3D; -import org.jlab.geom.prim.Point3D; import org.jlab.rec.ft.trk.FTTRKConstantsLoader; -import org.jlab.rec.ft.trk.FTTRKReconstruction; public class FTEventBuilder { @@ -51,7 +48,7 @@ public List addResponses(DataEvent event, ConstantsManager manager, List responses = new ArrayList(); IndexedTable cluster = manager.getConstants(run, "/calibration/ft/ftcal/cluster"); - + if (event instanceof EvioDataEvent) { if (event.hasBank("FTCALRec::clusters") == true) { EvioDataBank bank = (EvioDataBank) event.getBank("FTCALRec::clusters"); @@ -128,6 +125,8 @@ public List addResponses(DataEvent event, ConstantsManager manager, } } if (event.hasBank("FTTRK::crosses") == true) { + int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; // tracker id=0 + int TRK2 = DetectorLayer.FTTRK_MODULE2 - 1; // tracker id=1 DataBank bank = event.getBank("FTTRK::crosses"); int nrows = bank.rows(); for (int i = 0; i < nrows; i++) { @@ -137,16 +136,13 @@ public List addResponses(DataEvent event, ConstantsManager manager, resp.setId(bank.getInt("id", i)); resp.setEnergy(bank.getFloat("energy", i)); resp.setTime(bank.getFloat("time", i)); - resp.setCrEnergy(FTTRKReconstruction.crEnergy[i]); - resp.setCrTime(FTTRKReconstruction.crTime[i]); resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); - /// detector id (different from cross id!) double zCoord = bank.getFloat("z", i); - if(zCoord >= FTTRKConstantsLoader.Zlayer[0] && zCoord <= FTTRKConstantsLoader.Zlayer[1]){ - resp.setTrkDet(0); + if(zCoord >= FTTRKConstantsLoader.Zlayer[TRK1] && zCoord <= FTTRKConstantsLoader.Zlayer[TRK2]){ + resp.setTrkDet(TRK1); }else{ - resp.setTrkDet(1); + resp.setTrkDet(TRK2); } if(debugMode>=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); @@ -291,12 +287,15 @@ public void writeBanks(DataEvent event, List particles) { if (debugMode >= 1) { System.out.println("Preparing to output track bank with " + particles.size() + " FTparticles"); } + int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; + int TRK2 = DetectorLayer.FTTRK_MODULE2 - 1; if (particles.size() != 0) { if (event instanceof EvioDataEvent) { EvioDataBank banktrack = (EvioDataBank) event.getDictionary().createBank("FTRec::tracks", particles.size()); if (debugMode >= 1) { System.out.println("Creating output track bank with " + particles.size() + " FTparticles"); } + for (int i = 0; i < particles.size(); i++) { banktrack.setInt("ID", i, particles.get(i).get_ID()); banktrack.setInt("Charge", i, particles.get(i).getCharge()); @@ -307,8 +306,8 @@ public void writeBanks(DataEvent event, List particles) { banktrack.setDouble("Time", i, particles.get(i).getTime()); banktrack.setInt("CalID", i, particles.get(i).getCalorimeterIndex()); banktrack.setInt("HodoID", i, particles.get(i).getHodoscopeIndex()); - banktrack.setInt("Trk0ID", i, particles.get(i).getTrackerIndex(0)); - banktrack.setInt("Trk1ID", i, particles.get(i).getTrackerIndex(1)); + banktrack.setInt("Trk0ID", i, particles.get(i).getTrackerIndex(TRK1)); + banktrack.setInt("Trk1ID", i, particles.get(i).getTrackerIndex(TRK2)); if (debugMode >= 1) { particles.get(i).show(); } @@ -331,8 +330,8 @@ public void writeBanks(DataEvent event, List particles) { banktrack.setFloat("time", i, (float) particles.get(i).getTime()); banktrack.setShort("calID", i, (short) particles.get(i).getCalorimeterIndex()); banktrack.setShort("hodoID", i, (short) particles.get(i).getHodoscopeIndex()); - banktrack.setShort("trk0ID", i, (short) particles.get(i).getTrackerIndex(0)); - banktrack.setShort("trk1ID", i, (short) particles.get(i).getTrackerIndex(1)); + banktrack.setShort("trk0ID", i, (short) particles.get(i).getTrackerIndex(TRK1)); + banktrack.setShort("trk1ID", i, (short) particles.get(i).getTrackerIndex(TRK2)); if (debugMode >= 1) { particles.get(i).show(); From 46d88e39c9770a65b818c1f9ff2c8c892e4d0bc5 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sat, 26 Feb 2022 15:15:16 +0100 Subject: [PATCH 082/104] remove filling of diagnostic histograms, moved to test class --- .../main/java/org/jlab/rec/ft/FTParticle.java | 51 ++++++------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index b0e26d2408..a779af1e91 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -1,15 +1,13 @@ package org.jlab.rec.ft; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import org.jlab.clas.pdg.PhysicsConstants; +import org.jlab.detector.base.DetectorLayer; import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Vector3D; import org.jlab.utils.groups.IndexedTable; -import org.jlab.rec.ft.FTEBEngine; -import org.jlab.rec.ft.FTEventBuilder; import org.jlab.rec.ft.trk.FTTRKConstantsLoader; public class FTParticle { @@ -201,17 +199,7 @@ public int[] getTRKBestHits(List hitList, int it, double distanceTh double t=response.getTime(); int det = response.getTrkDet(); - if(it==0){ - // fill energy and time histograms only once per set or hits on FTTRK - FTEBEngine.h600.fill(response.getPosition().mag()/PhysicsConstants.speedOfLight()); - FTEBEngine.h601.fill(response.getCrTime(), response.getPosition().mag()/PhysicsConstants.speedOfLight()); - if(det==0){ // non e' Id ma trkDet - FTEBEngine.h602.fill(response.getCrTime()); - }else if(det==1){ - FTEBEngine.h603.fill(response.getCrTime()); - } - } - + if(timedistance hitList, int it, double distanceTh public int [][] getTRKOrderedListOfHits(List hitList, int it, double distanceThreshold, double timeThreshold){ + + int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; // tracker id=0 + int TRK2 = DetectorLayer.FTTRK_MODULE2 -1; // tracker id=1 + Line3D cross = this.getLastCross(); - //double minimumDistance = 500.0; - // how many FTTRK events? int ndetectors = FTTRKConstantsLoader.NSupLayers; int hitsTRK = 0; for(int l=0; l hitList, int it, double distanceTh int lTRK = -1; //init for(int l=0; l hitList, int it, double distanceTh double t=response.getTime(); int det = response.getTrkDet(); - if(it==0){ - // fill energy and time histograms only once per set or hits on FTTRK - FTEBEngine.h600.fill(response.getPosition().mag()/PhysicsConstants.speedOfLight()); - FTEBEngine.h601.fill(response.getCrTime(), response.getPosition().mag()/PhysicsConstants.speedOfLight()); - if(det==0){ - FTEBEngine.h602.fill(response.getCrTime()); - }else if(det==1){ - FTEBEngine.h603.fill(response.getCrTime()); - } - } - + if(timedistance hitList, int it, double distanceTh if(bestidx>-1){ if(hitList.get(bestidx).getSize() < FTConstants.TRK_MIN_CROSS_NUMBER){ bestidx=-1; - if(det==0){ + if(det==TRK1){ hitDistancesDet0.set(lTRK, -1.); hitOrderDet0.set(lTRK, -1); - } - if(det==1){ + }else if(det==TRK2){ hitDistancesDet1.set(lTRK, -1.); hitOrderDet1.set(lTRK, -1); } @@ -326,12 +305,12 @@ public int[] getTRKBestHits(List hitList, int it, double distanceTh } // compose the double arrays of indices ordered by distance for(int l=0; l < hitsTRK; l++){ - bestIndices[l][0] = orderedIndices0[l]; - bestIndices[l][1] = orderedIndices1[l]; + bestIndices[l][TRK1] = orderedIndices0[l]; + bestIndices[l][TRK2] = orderedIndices1[l]; } }else{ bestIndices = new int[1][2]; - bestIndices[0][0] = bestIndices[0][1] = -1; + bestIndices[0][TRK1] = bestIndices[0][TRK2] = -1; } return bestIndices; } From b825500c0e9824c284b59adf3802a6859705ec32 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sat, 26 Feb 2022 15:16:08 +0100 Subject: [PATCH 083/104] move diagnostic histogram filling to test class, keep it simpler --- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 679 +----------------- 1 file changed, 21 insertions(+), 658 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index 2d32423b46..78bb105429 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -1,6 +1,5 @@ package org.jlab.rec.ft; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -12,17 +11,16 @@ import org.jlab.clas.physics.GenericKinematicFitter; import org.jlab.clas.physics.PhysicsEvent; import org.jlab.clas.reco.ReconstructionEngine; +import org.jlab.detector.base.DetectorLayer; import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Point3D; import org.jlab.geom.prim.Vector3D; import org.jlab.groot.data.H1F; import org.jlab.groot.data.H2F; import org.jlab.groot.data.DataLine; -import org.jlab.groot.ui.LatexText; import org.jlab.groot.math.F1D; import org.jlab.groot.fitter.DataFitter; import org.jlab.groot.graphics.EmbeddedCanvas; -import org.jlab.groot.data.GraphErrors; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.io.evio.EvioDataBank; @@ -41,39 +39,6 @@ public class FTEBEngine extends ReconstructionEngine { int Run = -1; double Solenoid; - public static boolean timeEnergyDiagnosticHistograms = false; - - public static H1F h500 = new H1F("Time Difference FTCAL-response", 100, 0., 200.); - public static H1F h501 = new H1F("Cross Energy TRK0", 100, 0., 2000.); - public static H1F h502 = new H1F("Cross Energy TRK1", 100, 0., 2000.); - public static H1F h503 = new H1F("Cross time TRK0", 100, 0.0, 500.); - public static H1F h504 = new H1F("Cross time TRK1", 100, 0.0, 500.); - public static H2F h505 = new H2F("Cross energy vs time TRK0", 100, 0.0, 500., 100, 0., 2000.); - public static H2F h506 = new H2F("Cross energy vs time TRK1", 100, 0.0, 500., 100, 0., 2000.); - public static H2F h507 = new H2F("Cross energy vs time TRK0+1", 100, 0.0, 500., 100, 0., 2000.); - public static H2F h510 = new H2F("Clusters total energies TRK0", 100, 0., 2000., 100, 0., 2000.); - public static H2F h511 = new H2F("Clusters total energies TRK1", 100, 0., 2000., 100, 0., 2000.); - public static H1F h512 = new H1F("Clusters total energies TRK0", 100, 0., 2000.); - public static H1F h513 = new H1F("Clusters total energies TRK1", 100, 0., 2000.); - public static H1F h520 = new H1F("Time of strips in cluster1 TRK0", 100, 0., 500.); - public static H1F h521 = new H1F("Time of strips in cluster2 TRK0", 100, 0., 500.); - public static H1F h522 = new H1F("time of strips in cluster1 TRK1", 100, 0., 500.); - public static H1F h523 = new H1F("Time of strips in cluster2 TRK1", 100, 0., 500.); - - public static H1F h600 = new H1F("TRK response position", 100, 5.93, 6.03); - public static H2F h601 = new H2F("TRK tof vs time", 100, 0., 500., 100, 5.93, 6.03); - public static H1F h602 = new H1F("cross0 time", 100, 0.0001, 500.); - public static H1F h603 = new H1F("cross1 time", 100, 0.0001, 500.); - - public static H2F hSecDet0 = new H2F("lay 2 vs lay1 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); - public static H2F hSecDet1 = new H2F("lay 4 vs lay3 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); - public static H2F hSeedDet0 = new H2F("lay 2 vs lay1 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); - public static H2F hSeedDet1 = new H2F("lay 4 vs lay3 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); - - public static Point3D centerOfTarget = new Point3D(0., 0., -3.); - - - public FTEBEngine() { super("FTEB", "devita", "3.0"); } @@ -268,53 +233,6 @@ public static void main(String arg[]){ h109.setOptStat(10); h109.setTitleX("trk2 phi residual (rad)"); h109.setFillColor(51); - - H1F resTrkXdet0 = new H1F("trk1 x residual wrt line thru trk0", 63, -0.5, 0.5); - resTrkXdet0.setOptStat(10); - resTrkXdet0.setTitleX("trk1 x residual (mm) wrt line thru trk0"); - resTrkXdet0.setFillColor(9); - H1F resTrkYdet0 = new H1F("trk1 y residual wrt line thru trk0", 63, -0.5, 0.5); - resTrkYdet0.setOptStat(10); - resTrkYdet0.setFillColor(9); - resTrkYdet0.setTitleX("trk1 y residual (mm) wrt line thru trk0"); - H1F resTrkXdet1 = new H1F("trk0 x residual wrt line thru trk1", 63, -0.5, 0.5); - resTrkXdet1.setOptStat(10); - resTrkXdet1.setFillColor(49); - resTrkXdet1.setTitleX("trk0 y residual (mm) wrt line thru trk1"); - H1F resTrkYdet1 = new H1F("trk0 y residual wrt line thru trk1", 63, -0.5, 0.5); - resTrkYdet1.setOptStat(10); - resTrkYdet1.setTitleX("trk0 y residual (mm) wrt line thru trk1"); - resTrkYdet1.setFillColor(49); - - H1F resTrkThetadet0 = new H1F("trk1 theta residual (rad) wrt line thru trk0", 100, -0.005, 0.005); - resTrkThetadet0.setOptStat(10); - resTrkThetadet0.setTitleX("trk1 theta residual (rad) wrt line thru trk0"); - resTrkThetadet0.setFillColor(9); - H1F resTrkThetadet1 = new H1F("trk0 theta residual (rad) wrt line thru trk1", 100, -0.005, 0.005); - resTrkThetadet1.setOptStat(10); - resTrkThetadet1.setTitleX("trk0 theta residual (rad) wrt line thru trk1"); - resTrkThetadet1.setFillColor(49); - H1F resTrkPhidet0 = new H1F("trk1 phi residual (rad) wrt line thru trk0", 100, -0.1, 0.1); - resTrkPhidet0.setOptStat(10); - resTrkPhidet0.setTitleX("trk1 phi residual wrt line thru trk0"); - resTrkPhidet0.setFillColor(9); - H1F resTrkPhidet1 = new H1F("trk0 phi residual (rad) wrt line thru trk1", 100, -0.1, 0.1); - resTrkPhidet1.setOptStat(10); - resTrkPhidet1.setTitleX("trk0 phi residual (rad) wrt line thru trk1"); - resTrkPhidet1.setFillColor(49); - - H2F resTrkXVsXdet0 = new H2F("trk1 x residual wrt line thru trk0 vs X", 50, -15., 15., 63, -0.5, 0.5); - resTrkXVsXdet0.setTitleX("trk1 x (mm)"); - resTrkXVsXdet0.setTitleY("trk1 x residual (mm) wrt line thru trk0"); - H2F resTrkYVsYdet0 = new H2F("trk1 y residual wrt line thru trk0 vs Y", 50, -15., 15., 63, -0.5, 0.5); - resTrkYVsYdet0.setTitleX("trk1 y (mm)"); - resTrkYVsYdet0.setTitleY("trk1 y residual (mm) wrt line thru trk0"); - H2F resTrkXVsXdet1 = new H2F("trk0 x residual wrt line thru trk1 vs X", 50, -15., 15., 63, -0.5, 0.5); - resTrkXVsXdet1.setTitleX("trk0 x (mm)"); - resTrkXVsXdet1.setTitleY("trk0 x residual (mm) wrt line thru trk1"); - H2F resTrkYVsYdet1 = new H2F("trk0 y residual wrt line thru trk1 vs Y", 50, -15., 15., 63, -0.5, 0.5); - resTrkYVsYdet1.setTitleX("trk0 y (mm)"); - resTrkYVsYdet1.setTitleY("trk0 y residual (mm) wrt line thru trk1"); H1F h202 = new H1F("trk1 x", 25, 8.2, 9.0); H1F h1202 = new H1F("trk1 x MC", 25, 8.2, 9.0); @@ -437,30 +355,14 @@ public static void main(String arg[]){ EmbeddedCanvas canvasCALTRK = new EmbeddedCanvas(); canvasCALTRK.divide(3,1); - H1F h71 = new H1F("hOccupancyMatchedSeed1", 768, 0., 769.); h71.setTitleX("Component layer 1"); - h71.setLineColor(1); h71.setFillColor(51); - H1F h72 = new H1F("hOccupancyMatchedSeed2", 768, 0., 769.); h72.setTitleX("Component layer 2"); - h72.setLineColor(1); h72.setFillColor(52); - H1F h73 = new H1F("hOccupancyMatchedSeed3", 768, 0., 769.); h73.setTitleX("Component layer 3"); - h73.setLineColor(1); h73.setFillColor(53); - H1F h74 = new H1F("hOccupancyMatchedSeed4", 768, 0., 769.); h74.setTitleX("Component layer 4"); - h74.setLineColor(1); h74.setFillColor(54); - - H1F h81 = new H1F("hOccupancyMatched1", 768, 0., 769.); h81.setTitleX("Component layer 1"); - h81.setLineColor(1); h81.setFillColor(31); - H1F h82 = new H1F("hOccupancyMatched2", 768, 0., 769.); h82.setTitleX("Component layer 2"); - h82.setLineColor(1); h82.setFillColor(32); - H1F h83 = new H1F("hOccupancyMatched3", 768, 0., 769.); h83.setTitleX("Component layer 3"); - h83.setLineColor(1); h83.setFillColor(33); - H1F h84 = new H1F("hOccupancyMatched4", 768, 0., 769.); h84.setTitleX("Component layer 4"); - h84.setLineColor(1); h84.setFillColor(34); - - double diffRadTolerance = FTConstants.TRK0_TRK1_RADTOL; - double diffPhiTolerance = FTConstants.TRK0_TRK1_PHITOL; - double diffThetaTolerance = FTConstants.TRK0_TRK1_THETATOL; + double diffRadTolerance = FTConstants.TRK1_TRK2_RADTOL; + double diffPhiTolerance = FTConstants.TRK1_TRK2_PHITOL; + double diffThetaTolerance = FTConstants.TRK1_TRK2_THETATOL; int nev = 0; int nevWithCrosses = 0, ncrosses2 = 0, nOfFTParticles = 0; + int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; + int TRK2 = DetectorLayer.FTTRK_MODULE2 - 1; while (reader.hasEvent()) { // run over all events // int nev1 = 0; int nev2 = 10000; for(nev=nev1; nev= 3 strips take the centroid int clustsize1 = bankcl.getShort("size", icl1ok); int clustsize2 = bankcl.getShort("size", icl2ok); - if(clustsize1>=3){ + if(clustsize1>=FTConstants.TRK_MIN_ClusterSizeForCentroid){ int sector = FTTRKReconstruction.findSector(seed1); if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed1 = cent1; } - if(clustsize2>=3){ + if(clustsize2>=FTConstants.TRK_MIN_ClusterSizeForCentroid){ int sector = FTTRKReconstruction.findSector(seed2); if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed2 = cent2; } @@ -613,40 +515,12 @@ public static void main(String arg[]){ segment1.setOrigin(seg1.origin().x(), seg1.origin().y()); segment2.setOrigin(seg2.origin().x(), seg2.origin().y()); segment1.setEnd(seg1.end().x(), seg1.end().y()); - segment2.setEnd(seg2.end().x(), seg2.end().y()); - - // extract the mumber of strips forming the cross and store them in an occupancy plot for matched signals - // which strips are forming the id cross? - if(lay1==1){h71.fill(seed1); - }else if(lay1==2){h72.fill(seed1); - }else if(lay1==3){h73.fill(seed1); - }else if(lay1==4){h74.fill(seed1); - } - - if(lay2==1){h71.fill(seed2); - }else if(lay2==2){h72.fill(seed2); - }else if(lay2==3){h73.fill(seed2); - }else if(lay2==4){h74.fill(seed2); - } - - DataBank bankhit = event.getBank("FTTRK::hits"); - if(bankhit.rows()>0){ - for(int k=0; k0){ System.out.println("coordinates of track on fttrk " + bank.getFloat("cx", i)*zt + " " + @@ -660,8 +534,6 @@ public static void main(String arg[]){ h108.fill((part.phi() - hitOnTrk.phi())); int sec1 = FTTRKReconstruction.findSector(seed1); int sec2 = FTTRKReconstruction.findSector(seed2); - hSecDet0.fill(sec1, sec2); - hSeedDet0.fill(seed1, seed2); if(debugMode>0){ System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + " bad seeds d0, event " + nev); @@ -672,7 +544,7 @@ public static void main(String arg[]){ canvasCALTRK.draw(segment1); canvasCALTRK.draw(segment2); - }else if(det==1 && trk1ID==crossID){ + }else if(det==TRK2 && trk1ID==crossID){ h101.fill(xt, yt); h103.fill(bank.getFloat("cx", i) *zt - xt); h105.fill(bank.getFloat("cy", i) *zt - yt); @@ -680,8 +552,6 @@ public static void main(String arg[]){ h109.fill((part.phi() - hitOnTrk.phi())); int sec1 = FTTRKReconstruction.findSector(seed1); int sec2 = FTTRKReconstruction.findSector(seed2); - hSecDet1.fill(sec1, sec2); - hSeedDet1.fill(seed1, seed2); if(debugMode>0){ System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + " bad seeds d1, event " + nev); @@ -692,50 +562,7 @@ public static void main(String arg[]){ canvasCALTRK.draw(segment1); canvasCALTRK.draw(segment2); } - - // extract residuals of TRK1 wrt TRK0 and viceversa - // loop on crosses in det0, find track connecting with origin, evaluate residuals of TRK1 hits wrt to this track - double cx = hitOnTrk.x() - centerOfTarget.x(); - double cy = hitOnTrk.y() - centerOfTarget.y(); - double cz = hitOnTrk.z() - centerOfTarget.z(); - for(int ncj = 0; ncj < ncrosses; ncj++) { - int det1 = banktrk.getInt("detector", ncj); - if(det1 >=0 && nc != ncj && det != det1){ - double x1 = banktrk.getFloat("x", ncj); - double y1 = banktrk.getFloat("y", ncj); - double z1 = banktrk.getFloat("z", ncj); - int secondCrossID = banktrk.getInt("id", ncj); - Vector3D cross = new Vector3D(x1, y1, z1); - // check if within tolerance (previously done in findCross) - double r0 = Math.sqrt(hitOnTrk.x()*hitOnTrk.x() + hitOnTrk.y()*hitOnTrk.y() + hitOnTrk.z()*hitOnTrk.z()); - double r1 = Math.sqrt(cross.x()*cross.x() + cross.y()*cross.y() + cross.z()*cross.z()); - double r02d = Math.sqrt(hitOnTrk.x()*hitOnTrk.x() + hitOnTrk.y()*hitOnTrk.y()); - double r12d = Math.sqrt(cross.x()*cross.x() + cross.y()*cross.y()); - double diffRadii = r02d-r12d; - double diffTheta = Math.acos(hitOnTrk.z()/r0) - Math.acos(cross.z()/r1); - double diffPhi = Math.atan2(hitOnTrk.y(), hitOnTrk.x()) - Math.atan2(cross.y(), cross.x()); - if(Math.abs(diffPhi) < diffPhiTolerance && Math.abs(diffRadii)< diffRadTolerance && - Math.abs(diffTheta) < diffThetaTolerance){ - double t = (cross.z()-centerOfTarget.z())/hitOnTrk.z(); - Vector3D pointOnTrackAtZ = new Vector3D(cx*t + centerOfTarget.x(), cy*t + centerOfTarget.y(), z1); - if(det1 == 1 && trk1ID == secondCrossID){ - resTrkXdet0.fill(pointOnTrackAtZ.x() - cross.x()); - resTrkYdet0.fill(pointOnTrackAtZ.y() - cross.y()); - resTrkThetadet0.fill(pointOnTrackAtZ.theta() - cross.theta()); - resTrkPhidet0.fill(pointOnTrackAtZ.phi() - cross.phi()); - resTrkXVsXdet0.fill(cross.x(), pointOnTrackAtZ.x() - cross.x()); - resTrkYVsYdet0.fill(cross.y(), pointOnTrackAtZ.y() - cross.y()); - }else if(det1 == 0 && trk0ID == secondCrossID){ - resTrkXdet1.fill(pointOnTrackAtZ.x() - cross.x()); - resTrkYdet1.fill(pointOnTrackAtZ.y() - cross.y()); - resTrkThetadet1.fill(pointOnTrackAtZ.theta() - cross.theta()); - resTrkPhidet1.fill(pointOnTrackAtZ.phi() - cross.phi()); - resTrkXVsXdet1.fill(cross.x(), pointOnTrackAtZ.x() - cross.x()); - resTrkYVsYdet1.fill(cross.y(), pointOnTrackAtZ.y() - cross.y()); - } - } - } - } + } } @@ -835,9 +662,9 @@ public static void main(String arg[]){ " z = " + hitMCOnTrk.z()); // Montecarlo hit location on first detector middle plane - if(det==0) h2000.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); - if(det==1) h2001.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); - if(det==0){ + if(det==TRK1) h2000.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); + if(det==TRK2) h2001.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); + if(det==TRK1){ h1100.fill(hitOnTrk.x(), hitOnTrk.y()); h1102.fill(hitMCOnTrk.x() - hitOnTrk.x()); h1104.fill(hitMCOnTrk.y() - hitOnTrk.y()); @@ -849,7 +676,7 @@ public static void main(String arg[]){ h1202.fill(hitMCOnTrk.x()); h204.fill(hitOnTrk.y()); h1204.fill(hitMCOnTrk.y()); - }else if(det==1){ + }else if(det==TRK2){ h1101.fill(hitOnTrk.x(), hitOnTrk.y()); h1103.fill(hitMCOnTrk.x() - hitOnTrk.x()); h1105.fill(hitMCOnTrk.y() - hitOnTrk.y()); @@ -879,54 +706,7 @@ public static void main(String arg[]){ if(debugMode>=-1) // print always System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + nevWithCrosses + " @@@@ number of reconstructed FTParticles " + nOfFTParticles); - - if(timeEnergyDiagnosticHistograms){ - JFrame frame = new JFrame("FT Reconstruction"); - frame.setSize(1200, 800); - EmbeddedCanvas canvas = new EmbeddedCanvas(); - canvas.divide(3, 3); - canvas.cd(0); - canvas.draw(h1); - canvas.cd(1); - canvas.draw(h2); - canvas.cd(2); - canvas.draw(h3); - canvas.cd(3); - h501.setFillColor(3); // green - h502.setFillColor(5); // yellow - h503.setFillColor(8); // dark green - h504.setFillColor(7); // orange - h600.setFillColor(9); // blue violet - h602.setFillColor(3); // green trk0 - h603.setFillColor(5); // yellow trk1 - - canvas.draw(h501); - canvas.draw(h502,"same"); - canvas.cd(4); - canvas.draw(h503,""); - canvas.draw(h504,"same"); - - for (int i = 0; i < h6.getDataBufferSize(); i++) { - float meanE = h6.getDataBufferBin(i); - float nE = h7.getDataBufferBin(i); - if (nE > 0) { - h6.setDataBufferBin(i, meanE / nE); - } - } - canvas.cd(5); - canvas.draw(h507); - canvas.cd(6); - canvas.draw(h600); - canvas.cd(7); - canvas.draw(h601); - canvas.cd(8); - canvas.draw(h602); - canvas.draw(h603,"same"); - frame.add(canvas); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - } - + double narrowFactor = 7.5; // was 4.5 JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); frametrk.setSize(1600, 800); @@ -1221,429 +1001,12 @@ public static void main(String arg[]){ frametrkres.setLocationRelativeTo(null); frametrkres.setVisible(true); - JFrame frametrkrel = new JFrame("FTTRK Resolutions layer1 vs layer2"); - frametrkrel.setSize(800, 800); - EmbeddedCanvas canvastrkrel = new EmbeddedCanvas(); - canvastrkrel.divide(2, 2); - canvastrkrel.cd(0); - canvastrkrel.draw(h202); - canvastrkrel.draw(h1202,"same"); - canvastrkrel.cd(1); - canvastrkrel.draw(h203); - canvastrkrel.draw(h1203,"same"); - canvastrkrel.cd(2); - canvastrkrel.draw(h204); - canvastrkrel.draw(h1204,"same"); - canvastrkrel.cd(3); - canvastrkrel.draw(h205); - canvastrkrel.draw(h1205,"same"); - - frametrkrel.add(canvastrkrel); - frametrkrel.setLocationRelativeTo(null); - frametrkrel.setVisible(true); - - JFrame frameSecradio = new JFrame("20 sectors occupancy"); - frameSecradio.setSize(1000,500); - EmbeddedCanvas canvasSecradio = new EmbeddedCanvas(); - canvasSecradio.divide(2,1); - canvasSecradio.cd(0); - canvasSecradio.draw(hSecDet0); - // excluded cells - double excx0h1[] = {0., 1., 2., 3., 4., 5., 10., 11., 12., 13.}; - double excy0h1[] = {10., 11., 12., 13., 14., 15., 16., 17.}; - GraphErrors excludedDet0half1 = new GraphErrors(); - for(int i=0; i Date: Sat, 26 Feb 2022 15:16:21 +0100 Subject: [PATCH 084/104] move diagnostic histogram filling to test class, keep it simpler --- .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 305 ++++-------------- 1 file changed, 70 insertions(+), 235 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java index 26c461e40d..fbe8d8bc33 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java @@ -11,9 +11,9 @@ import javax.swing.JFrame; import org.jlab.clas.detector.DetectorData; import org.jlab.clas.detector.DetectorEvent; -import org.jlab.clas.physics.GenericKinematicFitter; import org.jlab.clas.physics.PhysicsEvent; import org.jlab.clas.reco.ReconstructionEngine; +import org.jlab.detector.base.DetectorLayer; import org.jlab.groot.data.H1F; import org.jlab.groot.data.H2F; import org.jlab.groot.data.DataLine; @@ -22,8 +22,6 @@ import org.jlab.io.base.DataEvent; import org.jlab.io.hipo.HipoDataSource; import org.jlab.geom.prim.Line3D; -import org.jlab.geom.prim.Point3D; -import org.jlab.utils.system.ClasUtilsFile; import org.jlab.rec.ft.FTConstants; /** @@ -55,8 +53,21 @@ public boolean init() { // use 11 provisionally as run number to download the basic FTTK geometry constants FTTRKConstantsLoader.Load(11, this.getConstantsManager().getVariation()); reco = new FTTRKReconstruction(); - reco.debugMode=0; + reco.debugMode=0; + +/* + String[] tables = new String[]{ + "/calibration/ft/fthodo/charge_to_energy", + "/calibration/ft/fthodo/time_offsets", + "/calibration/ft/fthodo/status", + "/geometry/ft/fthodo", + "/geometry/ft/fttrk" + }; + requireConstants(Arrays.asList(tables)); + this.getConstantsManager().setVariation("default"); +*/ + return true; } @@ -125,8 +136,7 @@ public static void main (String arg[]) { FTTRKEngine trk = new FTTRKEngine(); trk.init(); // insert input filename here -// String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; - String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_126798.hipo"; // multihit evt + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; System.out.println("input file " + input); HipoDataSource reader = new HipoDataSource(); reader.open(input); @@ -143,46 +153,17 @@ public static void main (String arg[]) { h333.setTitleX("strip Time"); h333.setTitleY("strip Energy"); H2F h444 = new H2F("strip vs time",100, 0., 500., 768, 0., 769.); h444.setTitleX("strip Time"); h444.setTitleY("strip number"); - H2F h445 = new H2F("strip lay 1 vs time",100, 0., 500., 768, 0., 769.); - h445.setTitleX("strip Time"); h445.setTitleY("strip number"); - H2F h446 = new H2F("strip lay 2 vs time",100, 0., 500., 768, 0., 769.); - h446.setTitleX("strip Time"); h446.setTitleY("strip number"); - H2F h447 = new H2F("strip lay 3 vs time",100, 0., 500., 768, 0., 769.); - h447.setTitleX("strip Time"); h447.setTitleY("strip number"); - H2F h448 = new H2F("strip lay 4 vs time",100, 0., 500., 768, 0., 769.); - h448.setTitleX("strip Time"); h448.setTitleY("strip number"); + H1F h1clEn = new H1F("Cluster energy", 100, 0., 1000.); h1clEn.setOptStat(Integer.parseInt("1111")); h1clEn.setTitleX("centroid energy of clusters"); H1F hOccupancy1 = new H1F("hOccupancy1", 768, 0., 769.); hOccupancy1.setTitleX("Component layer 1"); - hOccupancy1.setLineColor(1); hOccupancy1.setFillColor(1); hOccupancy1.setOptStat(11); + hOccupancy1.setLineColor(1); hOccupancy1.setFillColor(1); H1F hOccupancy2 = new H1F("hOccupancy2", 768, 0., 769.); hOccupancy2.setTitleX("Component layer 2"); - hOccupancy2.setLineColor(1); hOccupancy2.setFillColor(2); hOccupancy2.setOptStat(11); + hOccupancy2.setLineColor(1); hOccupancy2.setFillColor(2); H1F hOccupancy3 = new H1F("hOccupancy3", 768, 0., 769.); hOccupancy3.setTitleX("Component layer 3"); - hOccupancy3.setLineColor(1); hOccupancy3.setFillColor(3); hOccupancy3.setOptStat(11); + hOccupancy3.setLineColor(1); hOccupancy3.setFillColor(3); H1F hOccupancy4 = new H1F("hOccupancy4", 768, 0., 769.); hOccupancy4.setTitleX("Component layer 4"); - hOccupancy4.setLineColor(1); hOccupancy4.setFillColor(4); hOccupancy4.setOptStat(11); - - H1F hStripDiff1 = new H1F("hStripDiff1", 10, -5.5, 4.5); hStripDiff1.setTitleX("Strip difference layer 1"); - hStripDiff1.setOptStat(Integer.parseInt("1111")); hStripDiff1.setLineColor(1); hStripDiff1.setFillColor(1); - H1F hStripDiff2 = new H1F("hStripDiff2", 10, -5.5, 4.5); hStripDiff2.setTitleX("Strip difference layer 2"); - hStripDiff2.setOptStat(Integer.parseInt("1111")); hStripDiff2.setLineColor(1); hStripDiff2.setFillColor(2); - H1F hStripDiff3 = new H1F("hStripDiff3", 10, -5.5, 4.5); hStripDiff3.setTitleX("Strip difference layer 3"); - hStripDiff3.setOptStat(Integer.parseInt("1111")); hStripDiff3.setLineColor(1); hStripDiff3.setFillColor(3); - H1F hStripDiff4 = new H1F("hStripDiff4", 10, -5.5, 4.5); hStripDiff4.setTitleX("Strip difference layer 4"); - hStripDiff4.setOptStat(Integer.parseInt("1111")); hStripDiff4.setLineColor(1); hStripDiff4.setFillColor(4); - H1F hNumberOfStrips = new H1F("hNumberOfStrips", 10, -0.5, 9.5); hNumberOfStrips.setTitleX("number of strips per cluster"); - hNumberOfStrips.setOptStat(Integer.parseInt("1111")); hNumberOfStrips.setLineColor(1); hNumberOfStrips.setFillColor(5); - H1F hNumberOfStripsInCrosses = new H1F("hNumberOfStripsInCrosses", 10, -0.5, 9.5); hNumberOfStripsInCrosses.setTitleX("number of strips per cluster in crosses"); - hNumberOfStripsInCrosses.setOptStat(Integer.parseInt("1111")); hNumberOfStripsInCrosses.setLineColor(1); hNumberOfStripsInCrosses.setFillColor(6); - - H1F hStripLay1 = new H1F("hStripLay1", 10, -0.5, 9.5); hStripLay1.setTitleX("Number of strips in clusters, layer 1"); - hStripLay1.setOptStat(Integer.parseInt("1111")); hStripLay1.setLineColor(1); hStripLay1.setFillColor(1); - H1F hStripLay2 = new H1F("hStripLay2", 10, -0.5, 9.5); hStripLay2.setTitleX("Number of strips in clusters, layer 2"); - hStripLay2.setOptStat(Integer.parseInt("1111")); hStripLay2.setLineColor(1); hStripLay2.setFillColor(2); - H1F hStripLay3 = new H1F("hStripLay3", 10, -0.5, 9.5); hStripLay3.setTitleX("Number of strips in clusters, layer 3"); - hStripLay3.setOptStat(Integer.parseInt("1111")); hStripLay3.setLineColor(1); hStripLay3.setFillColor(3); - H1F hStripLay4 = new H1F("hStripLay4", 10, -0.5, 9.5); hStripLay4.setTitleX("Number of strips in clusters, layer 4"); - hStripLay4.setOptStat(Integer.parseInt("1111")); hStripLay4.setLineColor(1); hStripLay4.setFillColor(4); + hOccupancy4.setLineColor(1); hOccupancy4.setFillColor(4); float lim = 15; H2F hHitL1 = new H2F("hHitL1","cross y vs x detector 1", 100, -lim, lim, 100, -lim, lim); @@ -203,13 +184,13 @@ public static void main (String arg[]) { int nc1 = 0, nc2 = 0, ncmatch = 0; int nev=0; - while(reader.hasEvent()){ -// int nev1 = 0; int nev2 = 40000; for(nev=nev1; nev=1) System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~ processing event ~~~~~~~~~~~ " + nev); -// if(nev != 8) continue; // select one event only for debugging purposes ArrayList clusters = new ArrayList(); + clusters = trk.processDataEventAndGetClusters(event); int nStripsInClusters = 0; @@ -225,52 +206,42 @@ public static void main (String arg[]) { int comp = bank.getShort("component",i); float energy = bank.getFloat("energy",i); float time = bank.getFloat("time",i); - - if(debug>=1) { - System.out.println("layer " + layer + " strip " + comp); - System.out.println("%%%%%%%%% layer " + layer + " strip " + comp + " sector " + FTTRKReconstruction.findSector(comp)); - } h1.fill(comp,layer); h2.fill(energy); h3.fill(time); h333.fill(time, energy); - h444.fill(time, comp); - if(layer==1){ - h445.fill(time, comp); - }else if(layer==2){ - h446.fill(time, comp); - }else if(layer==3){ - h447.fill(time, comp); - }else if(layer==4){ - h448.fill(time, comp); - } - if(layer==1){ - if(debug>=1) System.out.println("component layer 1 " + comp + " event number " + nev + " n rows " + nrows); - hOccupancy1.fill(comp); - if(energy>maxcomp1){ - maxcomp1 = energy; - imax1 = i; - } - }else if(layer==2){ - hOccupancy2.fill(comp); - if(energy>maxcomp2){ - maxcomp2 = energy; - imax2 = i; - } - }else if(layer==3){ - hOccupancy3.fill(comp); - if(energy>maxcomp3){ - maxcomp3 = energy; - imax3 = i; - } - }else if(layer==4){ - hOccupancy4.fill(comp); - if(energy>maxcomp4){ - maxcomp4 = energy; - imax4 = i; - } + switch(layer){ + case DetectorLayer.FTTRK_LAYER1: + hOccupancy1.fill(comp); + if(energy>maxcomp1){ + maxcomp1 = energy; + imax1 = i; + } + break; + case DetectorLayer.FTTRK_LAYER2: + hOccupancy2.fill(comp); + if(energy>maxcomp2){ + maxcomp2 = energy; + imax2 = i; + } + break; + case DetectorLayer.FTTRK_LAYER3: + hOccupancy3.fill(comp); + if(energy>maxcomp3){ + maxcomp3 = energy; + imax3 = i; + } + break; + case DetectorLayer.FTTRK_LAYER4: + hOccupancy4.fill(comp); + if(energy>maxcomp4){ + maxcomp4 = energy; + imax4 = i; + } + break; + default: } } // strip number correposponding to the max energy release @@ -288,52 +259,27 @@ public static void main (String arg[]) { canvasCl.cd(1); canvasCl.draw(hHitL1); for(int l=0; l-1) hNumberOfStripsInCrosses.fill(singleCluster.size()); - if(singleCluster.get_Layer()==1){ - hStripDiff1.fill(maxcomp1 - singleCluster.get_Centroid()); - hStripLay1.fill(singleCluster.size()); - }else if(singleCluster.get_Layer()==2){ - hStripDiff2.fill(maxcomp2 - singleCluster.get_Centroid()); - hStripLay2.fill(singleCluster.size()); - }else if(singleCluster.get_Layer()==3){ - hStripDiff3.fill(maxcomp3 - singleCluster.get_Centroid()); - hStripLay3.fill(singleCluster.size()); - }else if(singleCluster.get_Layer()==4){ - hStripDiff4.fill(maxcomp4 - singleCluster.get_Centroid()); - hStripLay4.fill(singleCluster.size()); - } int nst = singleCluster.size(); - if(debug>=1) System.out.println("nst - " + nst); for(int j=0; j=1) System.out.println("total number of clusters " + clusters.size() + " - number of cluster " + i + " cluster size " + - singleCluster.size() + " strip# " + j + " clusterId " + singleCluster.get_CId() + - " layer " + singleCluster.get_Layer() + " strip number " + singleCluster.get(j).get_Strip() + - " segment " + seg.origin().x() + " " + seg.origin().y() + " " + seg.end().x() + " " + seg.end().y() + - " total mean energy of the cluster " + singleCluster.get_TotalEnergy()); segment[nStripsInClusters] = new DataLine(seg.origin().x(), seg.origin().y(), seg.end().x(), seg.end().y()); int lay = singleCluster.get_Layer(); segment[nStripsInClusters].setLineColor(lay); if(debug>=1) System.out.println("nStripsInCluster " + nStripsInClusters); canvasCl.draw(segment[nStripsInClusters]); h1clEn.fill(singleCluster.get_TotalEnergy()); - hNumberOfStrips.fill(singleCluster.size()); - if(debug>=1) System.out.println("%%%%% drawn segment " + singleCluster.get(j).get_Strip() + " cluster " + singleCluster.get_CId() + " layer " + singleCluster.get_Layer()); - canvasClSingleLay.cd(lay-1); canvasClSingleLay.draw(segment[nStripsInClusters]); - nStripsInClusters++; } } } - - if(debug>=1) System.out.println("is there the crosses bank? " + event.hasBank("FTTRK::crosses")); if(event.hasBank("FTTRK::crosses")){ DataBank crossBank = event.getBank("FTTRK::crosses"); int nrows = crossBank.rows(); @@ -352,22 +298,19 @@ public static void main (String arg[]) { z[i] = crossBank.getFloat("z", i); if(debug>=1) System.out.println("number of crosses " + nrows + " detector " + det[i] + " x " + x[i] + " y " + y[i]); - if(det[i]==0) {hHitL1.fill(x[i], y[i]); nc1++;} - if(det[i]==1) {hHitL2.fill(x[i], y[i]); nc2++;} + if(det[i]==(DetectorLayer.FTTRK_MODULE1 - 1)) {hHitL1.fill(x[i], y[i]); nc1++;} + if(det[i]==(DetectorLayer.FTTRK_MODULE2 - 1)) {hHitL2.fill(x[i], y[i]); nc2++;} } /// loop on all crosses on detector 1 and 2 and find the one with better matching double minDistance = 1000; double minDiffPhi = 1000.; int iBest = -1, jBest = -1; - if(debug>=1) System.out.println("number of rows " + nrows); - if(nrows>=1){ + if(nrows>1){ double diffPhi = 1000; for(int i=0; ii; j--){ if(det[i]!=det[j]){ double distance = Math.sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])); - // check det1 and det2 correspondence by comparing phi angles - // the radius is larger for the second detector (as it is more distant) double phiCross1 = Math.atan2(y[i],x[i]); double phiCross2 = Math.atan2(y[j],x[j]); diffPhi = Math.abs(phiCross1-phiCross2); @@ -378,31 +321,25 @@ public static void main (String arg[]) { } } } - if(debug>=1) System.out.println("minimum distance " + minDistance); - // adjust tolerances if needed (some reference values are hardcoded in FTConstants.java + // adjust tolerances if needed double diffRadTolerance = 0.5; double diffPhiTolerance = 1.; double thetaTolerance = 0.05; if(iBest>-1 && jBest>-1){ - double r1 = Math.sqrt(x[iBest]*x[iBest]+y[iBest]*y[iBest]); - double r2 = Math.sqrt(x[jBest]*x[jBest]+y[jBest]*y[jBest]); - double diffRadii = r1-r2; - double diffTheta = Math.atan2(r1,z[iBest])- Math.atan2(r2,z[jBest]); - if(minDiffPhi < diffPhiTolerance && - Math.abs(diffRadii)=1) System.out.println("phi differences on two detectors " + diffPhi + " number of cross " + ncmatch + - " diffTheta " + diffTheta + " diffRadii " + diffRadii + " " + det[iBest] + " " + det[jBest]); - hHitMatch.fill((x[iBest]+x[jBest])/2., (y[iBest]+y[jBest])/2.); - ncmatch++; + double r1 = Math.sqrt(x[iBest]*x[iBest]+y[iBest]*y[iBest]); + double r2 = Math.sqrt(x[jBest]*x[jBest]+y[jBest]*y[jBest]); + double diffRadii = r1-r2; + double diffTheta = Math.atan2(r1,z[iBest])- Math.atan2(r2,z[jBest]); + if(minDiffPhi < diffPhiTolerance && + Math.abs(diffRadii)=1) System.out.println("number of found crosses: module 1: " + nc1 + " module 2: " + nc2 + " matching crosses " + ncmatch); - + JFrame frame = new JFrame("FT Reconstruction"); frame.setSize(1200,800); EmbeddedCanvas canvas = new EmbeddedCanvas(); @@ -417,44 +354,6 @@ public static void main (String arg[]) { frame.setLocationRelativeTo(null); frame.setVisible(true); - JFrame framest = new JFrame("FT strip vs time in layers"); - framest.setSize(800,800); - EmbeddedCanvas canvast = new EmbeddedCanvas(); - canvast.divide(2,2); - canvast.cd(0); canvast.draw(h445); - canvast.cd(1); canvast.draw(h446); - canvast.cd(2); canvast.draw(h447); - canvast.cd(3); canvast.draw(h448); - framest.add(canvast); - framest.setLocationRelativeTo(null); - framest.setVisible(true); - - JFrame frameDiff = new JFrame("Strip Difference"); - frameDiff.setSize(800,800); - EmbeddedCanvas canvasDiff = new EmbeddedCanvas(); - canvasDiff.divide(2,3); - canvasDiff.cd(0); canvasDiff.draw(hStripDiff1); - canvasDiff.cd(1); canvasDiff.draw(hStripDiff2); - canvasDiff.cd(2); canvasDiff.draw(hStripDiff3); - canvasDiff.cd(3); canvasDiff.draw(hStripDiff4); - canvasDiff.cd(4); canvasDiff.draw(hNumberOfStrips); - canvasDiff.cd(5); canvasDiff.draw(hNumberOfStripsInCrosses); - frameDiff.add(canvasDiff); - frameDiff.setLocationRelativeTo(null); - frameDiff.setVisible(true); - - JFrame frameStrip = new JFrame("Strips in clusters"); - frameStrip.setSize(800,800); - EmbeddedCanvas canvasStrip = new EmbeddedCanvas(); - canvasStrip.divide(2,2); - canvasStrip.cd(0); canvasStrip.draw(hStripLay1); - canvasStrip.cd(1); canvasStrip.draw(hStripLay2); - canvasStrip.cd(2); canvasStrip.draw(hStripLay3); - canvasStrip.cd(3); canvasStrip.draw(hStripLay4); - frameStrip.add(canvasStrip); - frameStrip.setLocationRelativeTo(null); - frameStrip.setVisible(true); - JFrame frame2 = new JFrame("FT crosses coordinates per module"); frame2.setSize(800,800); EmbeddedCanvas canvas2 = new EmbeddedCanvas(); @@ -479,74 +378,10 @@ public static void main (String arg[]) { EmbeddedCanvas canvas3 = new EmbeddedCanvas(); canvas3.divide(2,2); int ic=-1; - double upl = 100.; - DataLine l1 = new DataLine(64., 0., 64., upl); - DataLine l2 = new DataLine(129., 0., 129., upl); - DataLine l3 = new DataLine(162., 0., 162., upl); - DataLine l4 = new DataLine(193., 0., 193., upl); - DataLine l5 = new DataLine(224., 0., 224., upl); // - DataLine l6 = new DataLine(256., 0., 256., upl); - DataLine l7 = new DataLine(288., 0., 288., upl); // - DataLine l8 = new DataLine(321., 0., 321., upl); - DataLine l9 = new DataLine(353., 0., 353., upl); - DataLine l10 = new DataLine(385., 0., 385., upl); - DataLine l11 = new DataLine(417., 0., 417., upl); - DataLine l12 = new DataLine(449., 0., 449., upl); - DataLine l13 = new DataLine(480., 0., 480., upl); // - DataLine l14 = new DataLine(513., 0., 513., upl); - DataLine l15 = new DataLine(544., 0., 544., upl); // - DataLine l16 = new DataLine(578., 0., 578., upl); - DataLine l17 = new DataLine(611., 0., 611., upl); - DataLine l18 = new DataLine(641., 0., 641., upl); - DataLine l19 = new DataLine(705., 0., 705., upl); - DataLine l20 = new DataLine(768., 0., 768., upl); - l1.setLineColor(6); l2.setLineColor(6); l3.setLineColor(6); - l4.setLineColor(6); l5.setLineColor(6); l6.setLineColor(6); - l7.setLineColor(6); l8.setLineColor(6); l9.setLineColor(6); l10.setLineColor(6); - l11.setLineColor(6); l12.setLineColor(6); l13.setLineColor(6); l14.setLineColor(4); l15.setLineColor(6); - l16.setLineColor(6); l17.setLineColor(6); l18.setLineColor(6); l19.setLineColor(6); l20.setLineColor(6); - l1.setLineStyle(3); l2.setLineStyle(3); l3.setLineStyle(3); l4.setLineStyle(3); l5.setLineStyle(3); - canvas3.cd(++ic); canvas3.draw(hOccupancy1); - canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); - canvas3.draw(l4); - canvas3.draw(l6); - canvas3.draw(l8); canvas3.draw(l9); - canvas3.draw(l10); canvas3.draw(l11); - canvas3.draw(l12); - canvas3.draw(l14); - canvas3.draw(l16); canvas3.draw(l17); - canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); canvas3.cd(++ic); canvas3.draw(hOccupancy2); - canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); - canvas3.draw(l4); - canvas3.draw(l6); - canvas3.draw(l8); canvas3.draw(l9); - canvas3.draw(l10); canvas3.draw(l11); - canvas3.draw(l12); - canvas3.draw(l14); - canvas3.draw(l16); canvas3.draw(l17); - canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); canvas3.cd(++ic); canvas3.draw(hOccupancy3); - canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); - canvas3.draw(l4); - canvas3.draw(l6); - canvas3.draw(l8); canvas3.draw(l9); - canvas3.draw(l10); canvas3.draw(l11); - canvas3.draw(l12); - canvas3.draw(l14); - canvas3.draw(l16); - canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); canvas3.cd(++ic); canvas3.draw(hOccupancy4); - canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); - canvas3.draw(l4); - canvas3.draw(l6); - canvas3.draw(l8); canvas3.draw(l9); - canvas3.draw(l10); canvas3.draw(l11); - canvas3.draw(l12); - canvas3.draw(l14); - canvas3.draw(l16); - canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); frame3.add(canvas3); frame3.setLocationRelativeTo(null); frame3.setVisible(true); From ecad72f410ca68142f476ac41a36c9a5d7ca4651 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sat, 26 Feb 2022 15:18:58 +0100 Subject: [PATCH 085/104] test classes for FTEB reconstruction, outputs for diagnostics --- .../org/jlab/service/ft/FTEBEngineTest.java | 1679 +++++++++++++++++ 1 file changed, 1679 insertions(+) create mode 100644 reconstruction/ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java diff --git a/reconstruction/ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java b/reconstruction/ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java new file mode 100644 index 0000000000..22684b715c --- /dev/null +++ b/reconstruction/ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java @@ -0,0 +1,1679 @@ +package org.jlab.service.ft; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JFrame; +import org.jlab.clas.detector.DetectorData; +import org.jlab.clas.detector.DetectorEvent; + +import org.jlab.clas.physics.GenericKinematicFitter; +import org.jlab.clas.physics.PhysicsEvent; +import org.jlab.clas.reco.ReconstructionEngine; +import org.jlab.detector.base.DetectorLayer; +import org.jlab.geom.prim.Line3D; +import org.jlab.geom.prim.Point3D; +import org.jlab.geom.prim.Vector3D; +import org.jlab.groot.data.H1F; +import org.jlab.groot.data.H2F; +import org.jlab.groot.data.DataLine; +import org.jlab.groot.ui.LatexText; +import org.jlab.groot.math.F1D; +import org.jlab.groot.fitter.DataFitter; +import org.jlab.groot.graphics.EmbeddedCanvas; +import org.jlab.groot.data.GraphErrors; +import org.jlab.clas.pdg.PhysicsConstants; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.io.evio.EvioDataBank; +import org.jlab.io.evio.EvioDataEvent; +import org.jlab.io.hipo.HipoDataSource; +import org.jlab.rec.ft.cal.FTCALConstantsLoader; +import org.jlab.rec.ft.cal.FTCALEngine; +import org.jlab.rec.ft.hodo.FTHODOEngine; +import org.jlab.rec.ft.trk.FTTRKEngine; +import org.jlab.rec.ft.trk.FTTRKConstantsLoader; +import org.jlab.rec.ft.trk.FTTRKReconstruction; +import org.jlab.rec.ft.FTEventBuilder; +import org.jlab.rec.ft.FTParticle; +import org.jlab.rec.ft.FTResponse; +import org.jlab.rec.ft.FTEBEngine; +import org.jlab.rec.ft.FTConstants; + +public class FTEBEngineTest extends ReconstructionEngine { + + FTEventBuilder reco; + int Run = -1; + double Solenoid; + + public static boolean timeEnergyDiagnosticHistograms = true; + + public static H1F h500 = new H1F("Time Difference FTCAL-response", 100, 0., 200.); + public static H1F h501 = new H1F("Cross Energy TRK0", 100, 0., 2000.); + public static H1F h502 = new H1F("Cross Energy TRK1", 100, 0., 2000.); + public static H1F h503 = new H1F("Cross time TRK0", 100, 0.0, 500.); + public static H1F h504 = new H1F("Cross time TRK1", 100, 0.0, 500.); + public static H2F h505 = new H2F("Cross energy vs time TRK0", 100, 0.0, 500., 100, 0., 2000.); + public static H2F h506 = new H2F("Cross energy vs time TRK1", 100, 0.0, 500., 100, 0., 2000.); + public static H2F h507 = new H2F("Cross energy vs time TRK0+1", 100, 0.0, 500., 100, 0., 2000.); + public static H2F h510 = new H2F("Clusters total energies TRK0", 100, 0., 2000., 100, 0., 2000.); + public static H2F h511 = new H2F("Clusters total energies TRK1", 100, 0., 2000., 100, 0., 2000.); + public static H1F h512 = new H1F("Clusters total energies TRK0", 100, 0., 2000.); + public static H1F h513 = new H1F("Clusters total energies TRK1", 100, 0., 2000.); + // there is no time information yet in banks for clusters + //public static H1F h520 = new H1F("Time of strips in cluster1 TRK0", 100, 0., 500.); + //public static H1F h521 = new H1F("Time of strips in cluster2 TRK0", 100, 0., 500.); + //public static H1F h522 = new H1F("time of strips in cluster1 TRK1", 100, 0., 500.); + //public static H1F h523 = new H1F("Time of strips in cluster2 TRK1", 100, 0., 500.); + + public static H1F h600 = new H1F("TRK response position", 100, 5.93, 6.03); + public static H2F h601 = new H2F("TRK tof vs time", 100, 0., 500., 100, 5.93, 6.03); + + public static H2F hSecDet0 = new H2F("lay 2 vs lay1 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); + public static H2F hSecDet1 = new H2F("lay 4 vs lay3 sectors fo form a cross", 20, -0.5, 19.5, 20, -0.5, 19.5); + public static H2F hSeedDet0 = new H2F("lay 2 vs lay1 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); + public static H2F hSeedDet1 = new H2F("lay 4 vs lay3 cluster seeds fo form a cross", 768/4, -0.5, 767.5, 768/4, -0.5, 767.5); + + public static Point3D centerOfTarget = new Point3D(0., 0., -3.); + + + + public FTEBEngineTest() { + super("FTEB", "devita", "3.0"); + } + + @Override + public boolean init() { + reco = new FTEventBuilder(); + reco.debugMode = 0; + String[] tables = new String[]{ + "/calibration/ft/ftcal/cluster", + "/calibration/ft/ftcal/thetacorr", + "/calibration/ft/ftcal/phicorr" + }; + requireConstants(Arrays.asList(tables)); + this.getConstantsManager().setVariation("default"); + + return true; + } + + @Override + public boolean processDataEvent(DataEvent event) { + List FTparticles = new ArrayList(); + List FTresponses = new ArrayList(); + + int run = this.setRunConditionsParameters(event); + if (run>=0) { + reco.init(this.getSolenoid()); + FTresponses = reco.addResponses(event, this.getConstantsManager(), run); + FTparticles = reco.initFTparticles(FTresponses); + if(FTparticles.size()>0){ + reco.matchToTRKTwoDetectorsMultiHits(FTresponses, FTparticles); + reco.matchToHODO(FTresponses, FTparticles); +// reco.correctDirection(FTparticles, this.getConstantsManager(), run); // correction to be applied only to FTcal and FThodo + reco.writeBanks(event, FTparticles); + } + } + return true; + } + + public int setRunConditionsParameters(DataEvent event) { + int run = -1; + if (event.hasBank("RUN::config") == false) { + System.err.println("RUN CONDITIONS NOT READ!"); + } + else { + double fieldScale = 0; + + boolean isMC = false; + boolean isCosmics = false; + + if (event instanceof EvioDataEvent) { + EvioDataBank bank = (EvioDataBank) event.getBank("RUN::config"); + if (bank.getByte("Type",0) == 0) { + isMC = true; + } + if (bank.getByte("Mode",0)== 1) { + isCosmics = true; + } + run = bank.getInt("Run",0); + fieldScale = bank.getFloat("Solenoid")[0]; + } else { + DataBank bank = event.getBank("RUN::config"); + if (bank.getByte("type",0) == 0) { + isMC = true; + } + if (bank.getByte("mode",0)== 1) { + isCosmics = true; + } + run = bank.getInt("run",0); + fieldScale = bank.getFloat("solenoid",0); + } + this.setSolenoid(fieldScale); + } + return run; + } + + public int getRun() { + return Run; + } + + public void setRun(int run) { + Run = run; + } + + public double getSolenoid() { + return Solenoid; + } + + public void setSolenoid(double Solenoid) { + this.Solenoid = Solenoid; + } + + public int getDebugMode() { + return this.reco.debugMode; + } + + + public static void main(String arg[]){ + + FTCALEngine cal = new FTCALEngine(); + cal.init(); + FTHODOEngine hodo = new FTHODOEngine(); + hodo.init(); + FTTRKEngine trk = new FTTRKEngine(); + trk.init(); + FTEBEngine en = new FTEBEngine(); + en.init(); + int debugMode = en.getDebugMode(); + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; + HipoDataSource reader = new HipoDataSource(); + reader.open(input); + + // initialize histos + H1F h1 = new H1F("Cluster Energy", 100, 0., 8.); + h1.setOptStat(Integer.parseInt("11111")); + h1.setTitleX("Cluster Energy (GeV)"); + H1F h2 = new H1F("Energy Resolution", 100, -1, 1); + h2.setOptStat(Integer.parseInt("11111")); + h2.setTitleX("Energy Resolution(GeV)"); + H1F h3 = new H1F("Theta Resolution", 100, -1, 1); + h3.setOptStat(Integer.parseInt("11111")); + h3.setTitleX("Theta Resolution(deg)"); + H1F h4 = new H1F("Phi Resolution", 100, -10, 10); + h4.setOptStat(Integer.parseInt("11111")); + h4.setTitleX("Phi Resolution(deg)"); + + H1F h5 = new H1F("Time Resolution", 100, -2, 2); + h5.setOptStat(Integer.parseInt("1111")); + h5.setTitleX("Time Resolution(ns)"); + H2F h6 = new H2F("Cluster Energy", 24, -180., 180., 24, -180., 180.); + h6.setTitleX("x (cm)"); + h6.setTitleY("y (cm)"); + H2F h7 = new H2F("N. Clusters", 24, -18., 18., 24, -18., 18.); + h7.setTitleX("x (mm)"); + h7.setTitleY("y (mm)"); + H2F h8 = new H2F("Cluster Energy", 100, 0., 9., 100, -0.5, 0.5); + h8.setTitleX("E (GeV)"); + h8.setTitleY("Energy Resolution(GeV)"); + H2F h9 = new H2F("Cluster Energy", 100, 2., 5., 100, -0.5, 0.5); + h9.setTitleX("#theta"); + h9.setTitleY("Energy Resolution(GeV)"); + H2F h10 = new H2F("Cluster Energy", 100, -180., 180., 100, -0.5, 0.5); + h10.setTitleX("#phi"); + h10.setTitleY("Energy Resolution(GeV)"); + + // residual plots (of TRK wrt tracking on ECAL - black histograms) + H2F h100 = new H2F("Cross on trk layer1", 100, -18., 18., 100, -18., 18.); + h100.setTitleX("x (mm) trk1"); + h100.setTitleY("y (mm) trk1"); + H2F h101 = new H2F("Cross on trk layer2", 100, -18., 18., 100, -18., 18.); + h101.setTitleX("x (mm) trk2"); + h101.setTitleY("y (mm) trk2"); + H2F h700 = new H2F("Strips on trk layer1", 100, -18., 18., 100, -18., 18.); + h100.setTitleX("x (mm) trk1"); + h100.setTitleY("y (mm) trk1"); + H2F h701 = new H2F("Strips on trk layer2", 100, -18., 18., 100, -18., 18.); + h101.setTitleX("x (mm) trk2"); + h101.setTitleY("y (mm) trk2"); + + double limTC = 4.; // for MC 0.05 is ok + H1F h102 = new H1F("trk1 x residual", 63, -limTC, limTC); + h102.setOptStat(10); + h102.setTitleX("trk1 x residual (mm)"); + h102.setFillColor(1); + H1F h103 = new H1F("trk2 x residual", 63, -limTC, limTC); + h103.setOptStat(10); + h103.setFillColor(51); + h103.setTitleX("trk2 x residual (mm)"); + H1F h104 = new H1F("trk1 y residual", 63, -limTC, limTC); + h104.setOptStat(Integer.parseInt("0")); + h104.setFillColor(1); + h104.setTitleX("trk1 y residual (mm)"); + H1F h105 = new H1F("trk2 y residual;", 63, -limTC, limTC); + h105.setOptStat(10); + h105.setTitleX("trk2 y residual (mm)"); + h105.setFillColor(51); + double limTCTheta = 0.05; + double limTCPhi = 1.; + H1F h106 = new H1F("trk1 theta residual (rad)", 100, -limTCTheta, limTCTheta); + h106.setOptStat(10); + h106.setTitleX("trk1 theta residual (rad)"); + h106.setFillColor(1); + H1F h107 = new H1F("trk2 theta residual (rad)", 100, -limTCTheta, limTCTheta); + h107.setOptStat(Integer.parseInt("0")); + h107.setTitleX("trk2 theta residual (rad)"); + h107.setFillColor(51); + H1F h108 = new H1F("trk1 phi residual (rad)", 100, -limTCPhi, limTCPhi); + h108.setOptStat(0); + h108.setTitleX("trk1 phi residual"); + h108.setFillColor(1); + H1F h109 = new H1F("trk2 phi residual (rad)", 100, -limTCPhi, limTCPhi); + h109.setOptStat(10); + h109.setTitleX("trk2 phi residual (rad)"); + h109.setFillColor(51); + + H1F resTrkXdet0 = new H1F("trk2 x residual wrt line thru trk1", 63, -0.5, 0.5); + resTrkXdet0.setOptStat(10); + resTrkXdet0.setTitleX("trk2 x residual (mm) wrt line thru trk1"); + resTrkXdet0.setFillColor(9); + H1F resTrkYdet0 = new H1F("trk2 y residual wrt line thru trk1", 63, -0.5, 0.5); + resTrkYdet0.setOptStat(10); + resTrkYdet0.setFillColor(9); + resTrkYdet0.setTitleX("trk22 y residual (mm) wrt line thru trk1"); + H1F resTrkXdet1 = new H1F("trk1 x residual wrt line thru trk2", 63, -0.5, 0.5); + resTrkXdet1.setOptStat(10); + resTrkXdet1.setFillColor(49); + resTrkXdet1.setTitleX("trk1 y residual (mm) wrt line thru trk2"); + H1F resTrkYdet1 = new H1F("trk1 y residual wrt line thru trk2", 63, -0.5, 0.5); + resTrkYdet1.setOptStat(10); + resTrkYdet1.setTitleX("trk1 y residual (mm) wrt line thru trk2"); + resTrkYdet1.setFillColor(49); + + H1F resTrkThetadet0 = new H1F("trk2 theta residual (rad) wrt line thru trk1", 100, -0.005, 0.005); + resTrkThetadet0.setOptStat(10); + resTrkThetadet0.setTitleX("trk2 theta residual (rad) wrt line thru trk1"); + resTrkThetadet0.setFillColor(9); + H1F resTrkThetadet1 = new H1F("trk1 theta residual (rad) wrt line thru trk2", 100, -0.005, 0.005); + resTrkThetadet1.setOptStat(10); + resTrkThetadet1.setTitleX("trk1 theta residual (rad) wrt line thru trk2"); + resTrkThetadet1.setFillColor(49); + H1F resTrkPhidet0 = new H1F("trk2 phi residual (rad) wrt line thru trk1", 100, -0.1, 0.1); + resTrkPhidet0.setOptStat(10); + resTrkPhidet0.setTitleX("trk2 phi residual wrt line thru trk1"); + resTrkPhidet0.setFillColor(9); + H1F resTrkPhidet1 = new H1F("trk1 phi residual (rad) wrt line thru trk2", 100, -0.1, 0.1); + resTrkPhidet1.setOptStat(10); + resTrkPhidet1.setTitleX("trk1 phi residual (rad) wrt line thru trk2"); + resTrkPhidet1.setFillColor(49); + + H2F resTrkXVsXdet0 = new H2F("trk2 x residual wrt line thru trk1 vs X", 50, -15., 15., 63, -0.5, 0.5); + resTrkXVsXdet0.setTitleX("trk2 x (mm)"); + resTrkXVsXdet0.setTitleY("trk2 x residual (mm) wrt line thru trk1"); + H2F resTrkYVsYdet0 = new H2F("trk2 y residual wrt line thru trk1 vs Y", 50, -15., 15., 63, -0.5, 0.5); + resTrkYVsYdet0.setTitleX("trk2 y (mm)"); + resTrkYVsYdet0.setTitleY("trk2 y residual (mm) wrt line thru trk1"); + H2F resTrkXVsXdet1 = new H2F("trk1 x residual wrt line thru trk2 vs X", 50, -15., 15., 63, -0.5, 0.5); + resTrkXVsXdet1.setTitleX("trk1 x (mm)"); + resTrkXVsXdet1.setTitleY("trk1 x residual (mm) wrt line thru trk2"); + H2F resTrkYVsYdet1 = new H2F("trk1 y residual wrt line thru trk2 vs Y", 50, -15., 15., 63, -0.5, 0.5); + resTrkYVsYdet1.setTitleX("trk1 y (mm)"); + resTrkYVsYdet1.setTitleY("trk1 y residual (mm) wrt line thru trk2"); + + H1F h202 = new H1F("trk1 x", 25, 8.2, 9.0); + H1F h1202 = new H1F("trk1 x MC", 25, 8.2, 9.0); + h202.setOptStat(0); + h202.setTitleX("trk1 x position (mm)"); + h202.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins + h202.setLineColor(3); + h202.setFillColor(3); + h1202.setLineColor(9); + h1202.setFillColor(49); + H1F h203 = new H1F("trk2 x", 25, 8.2, 9.0); + H1F h1203 = new H1F("trk2 MC", 25, 8.2, 9.0); + h203.setOptStat(0); + h203.setTitleX("trk2 x position (mm)"); + h203.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins + h203.setLineColor(3); + h203.setFillColor(3); + h1203.setLineColor(9); + h1203.setFillColor(49); + H1F h204 = new H1F("trk1 y", 25, 2.4, 4.0); + H1F h1204 = new H1F("trk1 y MC", 25, 2.4, 4.0); + h204.setOptStat(0); + h204.setTitleX("trk1 y position (mm)"); + h204.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins + h204.setLineColor(3); + h204.setFillColor(3); + h1204.setLineColor(9); + h1204.setFillColor(49); + H1F h205 = new H1F("trk2 y", 25, 2.4, 4.0); + H1F h1205 = new H1F("trk2 y MC", 25, 2.4, 4.0); + h205.setOptStat(0); + h205.setTitleX("trk2 y position (mm)"); + h205.setTitleY("counts/strip width/sqrt(12) (16 um)"); // 25 bins + h205.setLineColor(3); + h205.setFillColor(3); + h1205.setLineColor(9); + h1205.setFillColor(49); + + // resolution plots (of TRK wrt MC truth - red histograms) + H2F h1100 = new H2F("Cross on trk layer1 MC truth", 100, -18., 18., 100, -18., 18.); + h1100.setTitleX("x (mm) trk1"); + h1100.setTitleY("y (mm) trk1"); + H2F h1101 = new H2F("Cross on trk layer2 MC truth", 100, -18., 18., 100, -18., 18.); + h1101.setTitleX("x (mm) trk2"); + h1101.setTitleY("y (mm) trk2"); + int binres = 35; + double reslim = 5.*FTTRKConstantsLoader.Pitch; + H1F h1102 = new H1F("trk1 x resolution", binres, -reslim, reslim); + h1102.setOptStat(0); + h1102.setTitleX("trk1 x resolutionl (mm)"); + h1102.setLineColor(2); + h1102.setFillColor(2); + H1F h1103 = new H1F("trk2 x resolution", binres, -reslim, reslim); + h1103.setOptStat(0); + h1103.setTitleX("trk2 x resolution (mm)"); + h1103.setLineColor(2); + h1103.setFillColor(32); + H1F h1104 = new H1F("trk1 y resolution", binres, -reslim, reslim); + h1104.setOptStat(0); + h1104.setTitleX("trk1 y resolution (mm)"); + h1104.setLineColor(2); + h1104.setFillColor(2); + H1F h1105 = new H1F("trk2 y resolution", binres, -reslim, reslim); + h1105.setOptStat(0); + h1105.setTitleX("trk2 y resolution (mm)"); + h1105.setLineColor(2); + h1105.setFillColor(32); + H1F h1106 = new H1F("trk1 theta resolution", 50, -0.001, 0.001); + h1106.setOptStat(0); + h1106.setTitleX("trk1 theta resolution (rad)"); + h1106.setLineColor(2); + h1106.setFillColor(27); + H1F h1107 = new H1F("trk2 theta resolution", 50, -0.001, 0.001); + h1107.setOptStat(0); + h1107.setTitleX("trk2 theta resolution (rad)"); + h1107.setLineColor(2); + h1107.setFillColor(37); + H1F h1108 = new H1F("trk1 phi resolution", 50, -0.02, 0.02); + h1108.setOptStat(0); + h1108.setTitleX("trk1 phi resolution (rad)"); + h1108.setLineColor(2); + h1108.setFillColor(2); + H1F h1109 = new H1F("trk2 phi resolution", 50, -0.02, 0.02); + h1109.setOptStat(0); + h1109.setTitleX("trk2 phi resolution (rad)"); + h1109.setLineColor(2); + h1109.setFillColor(32); + + H1F h1112 = new H1F("trk1 Delta x", 50, -0.05, 0.05); + h1112.setOptStat(0); + h1112.setTitleX("trk1 Delta x"); + h1112.setLineColor(6); + h1112.setFillColor(6); + H1F h1113 = new H1F("trk2 Delta x", 50, -0.05, 0.05); + h1113.setOptStat(0); + h1113.setTitleX("trk2 Delta x"); + h1113.setLineColor(6); + h1113.setFillColor(36); + H1F h1114 = new H1F("trk1 Delta y", 50, -0.1, 0.1); + h1114.setOptStat(0); + h1114.setTitleX("trk1 Delta y"); + h1114.setLineColor(6); + h1114.setFillColor(6); + H1F h1115 = new H1F("trk2 Delta y", 50, -0.1, 0.1); + h1115.setOptStat(0); + h1115.setTitleX("trk2 Delta y"); + h1115.setLineColor(6); + h1115.setFillColor(36); + + // Montecarlo radiography + H2F h2000 = new H2F("Montecarlo radiography at first FTTRK det", 100, -15., 15., 100, -15, 15.); + h2000.setTitleX("x (mm)"); + h2000.setTitleY("y (mm)"); + H2F h2001 = new H2F("Montecarlo radiography at second FTTRK det", 100, -15., 15., 100, -15, 15.); + h2001.setTitleX("x (mm)"); + h2001.setTitleY("y (mm)"); + + JFrame frameCALTRK = new JFrame("radiography FTCAL hits and FTTRK Crosses"); + frameCALTRK.setSize(1500,500); + EmbeddedCanvas canvasCALTRK = new EmbeddedCanvas(); + canvasCALTRK.divide(3,1); + + H1F h71 = new H1F("hOccupancyMatchedSeed1", 768, 0., 769.); h71.setTitleX("Component layer 1"); + h71.setLineColor(1); h71.setFillColor(51); + H1F h72 = new H1F("hOccupancyMatchedSeed2", 768, 0., 769.); h72.setTitleX("Component layer 2"); + h72.setLineColor(1); h72.setFillColor(52); + H1F h73 = new H1F("hOccupancyMatchedSeed3", 768, 0., 769.); h73.setTitleX("Component layer 3"); + h73.setLineColor(1); h73.setFillColor(53); + H1F h74 = new H1F("hOccupancyMatchedSeed4", 768, 0., 769.); h74.setTitleX("Component layer 4"); + h74.setLineColor(1); h74.setFillColor(54); + + H1F h81 = new H1F("hOccupancyMatched1", 768, 0., 769.); h81.setTitleX("Component layer 1"); + h81.setLineColor(1); h81.setFillColor(31); + H1F h82 = new H1F("hOccupancyMatched2", 768, 0., 769.); h82.setTitleX("Component layer 2"); + h82.setLineColor(1); h82.setFillColor(32); + H1F h83 = new H1F("hOccupancyMatched3", 768, 0., 769.); h83.setTitleX("Component layer 3"); + h83.setLineColor(1); h83.setFillColor(33); + H1F h84 = new H1F("hOccupancyMatched4", 768, 0., 769.); h84.setTitleX("Component layer 4"); + h84.setLineColor(1); h84.setFillColor(34); + + double diffRadTolerance = FTConstants.TRK1_TRK2_RADTOL; + double diffPhiTolerance = FTConstants.TRK1_TRK2_PHITOL; + double diffThetaTolerance = FTConstants.TRK1_TRK2_THETATOL; + + int nev = 0; + int nevWithCrosses = 0, ncrosses2 = 0, nOfFTParticles = 0; + int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; + int TRK2 = DetectorLayer.FTTRK_MODULE2 - 1; + while (reader.hasEvent()) { // run over all events +// int nev1 = 0; int nev2 = 10000; for(nev=nev1; nev-1) System.out.println("////////////// event read " + bankEvt + " - sequential number " + nev); + //if(nev > 10239) System.exit(0); if(nev != 10239) continue; // stop at a given evt number + cal.processDataEvent(event); + hodo.processDataEvent(event); + trk.processDataEventAndGetClusters(event); + en.processDataEvent(event); + if(!event.hasBank("FTCAL::hits")) continue; + if (event instanceof EvioDataEvent) { + GenericKinematicFitter fitter = new GenericKinematicFitter(11); + PhysicsEvent gen = fitter.getGeneratedEvent((EvioDataEvent) event); + if (event.hasBank("FTRec::tracks")) { + DataBank bank = event.getBank("FTRec::tracks"); + int nrows = bank.rows(); + for (int i = 0; i < nrows; i++) { + h1.fill(bank.getDouble("Energy", i)); + Vector3D part = new Vector3D(bank.getDouble("Cx", i), bank.getDouble("Cy", i), bank.getDouble("Cz", i)); + h5.fill(bank.getDouble("Time", i)); + if(gen.countGenerated() != 0){ + h2.fill(bank.getDouble("Energy", i) - gen.getParticle("[11]").vector().p()); + h3.fill(Math.toDegrees(part.theta() - gen.getParticle("[11]").theta())); + h4.fill(Math.toDegrees(part.phi() - gen.getParticle("[11]").phi())); + h6.fill(bank.getDouble("Energy", i), bank.getDouble("Energy", i) - gen.getParticle("[11]").vector().p()); + } + } + } + } else { + DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); + PhysicsEvent gen = detectorEvent.getGeneratedEvent(); + if (event.hasBank("FT::particles")) { + DataBank bank = event.getBank("FT::particles"); + int nrows = bank.rows(); + if(nrows>0) nOfFTParticles++; + for (int i = 0; i < nrows; i++) { + int calId = bank.getShort("calID",i); + if(bank.getByte("charge", i)==-1 && bank.getShort("calID",i)>0) { + // track candidate through calorimeter + h1.fill(bank.getFloat("energy", i)); + Vector3D part = new Vector3D(bank.getFloat("cx", i), bank.getFloat("cy", i), bank.getFloat("cz", i)); + h5.fill(bank.getFloat("time", i) - 124.25); // simulation + h7.fill((bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS)/10., (bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS)/10.); + if(gen.countGenerated() != 0){ + h2.fill(bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h3.fill(gen.getGeneratedParticle(0).vector().p(),Math.toDegrees(part.theta() - gen.getGeneratedParticle(0).theta())); + h4.fill(gen.getGeneratedParticle(0).vector().p(),Math.toDegrees(part.phi() - gen.getGeneratedParticle(0).phi())); + h6.fill(bank.getFloat("cx", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("cy", i) * FTCALConstantsLoader.CRYS_ZPOS, bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h8.fill(gen.getGeneratedParticle(0).vector().p(), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h9.fill(Math.toDegrees(gen.getGeneratedParticle(0).theta()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + h10.fill(Math.toDegrees(gen.getGeneratedParticle(0).phi()), bank.getFloat("energy", i) - gen.getGeneratedParticle(0).vector().p()); + } + + // check match with trk bank (entry trkID) +// int trkID = bank.getShort("trkID", i); + int trk1ID = bank.getShort("trk0ID", i); // it should correspond to the number of the cross in the banks + int trk2ID = bank.getShort("trk1ID", i); + if(trk1ID >= 0 || trk2ID >= 0){ // at least one cross is present on one TRK det + // loop on crosses bank + DataBank banktrk = event.getBank("FTTRK::crosses"); + int ncrosses = banktrk.rows(); + // how many matched crosses are associated to a given track? + int matchedCrosses = 0; + for(int nc=0; nc=1) System.out.println("time from TRK" + timeFromTRK + " to be compared to time from TRK" + + ptOnTRK.mag()/PhysicsConstants.speedOfLight()); + int icl1 = banktrk.getShort("Cluster1ID", nc); + int icl2 = banktrk.getShort("Cluster2ID", nc); + DataBank bankcl = event.getBank("FTTRK::clusters"); + int sizeCl1 = bankcl.getShort("size", icl1); + int sizeCl2 = bankcl.getShort("size", icl2); + float totEnergyCl1 = bankcl.getFloat("energy", icl1); + float totEnergyCl2 = bankcl.getFloat("energy", icl2); + if(crossID==TRK1){ + h503.fill(timeFromTRK); + h501.fill(energyFromTRK); + h505.fill(timeFromTRK, energyFromTRK); + h510.fill(totEnergyCl1, totEnergyCl2); + h512.fill(totEnergyCl1); + h512.fill(totEnergyCl2); + }else if(crossID==TRK2){ + h504.fill(timeFromTRK); + h502.fill(energyFromTRK); + h506.fill(timeFromTRK, energyFromTRK); + h511.fill(totEnergyCl1, totEnergyCl2); + h513.fill(totEnergyCl1); + h513.fill(totEnergyCl2); + } + } + } + +// if(matchedCrosses != 1){ +// if(matchedCrosses != 2){ + if(matchedCrosses < FTConstants.TRK_MIN_CROSS_NUMBER){ // at least TRK_MIN_CROSS_NUMBER per event + continue; + }else{ + ncrosses2++; + if(ncrosses<100 && debugMode>0) System.out.println("++++++++++++++++++++++++++ Sequential number " + nev); + } + + for(int nc = 0; nc < ncrosses; nc++){ + int crossID = banktrk.getInt("id", nc); + if(crossID != trk1ID && crossID != trk2ID) continue; + int det = banktrk.getInt("detector", nc); + if(debugMode>0) System.out.println("trk1ID " + trk1ID + " trk2ID " + trk2ID + + " crossID " + crossID); + + if(det>=0){ + float xt = banktrk.getFloat("x", nc); + float yt = banktrk.getFloat("y", nc); + float zt = banktrk.getFloat("z", nc); + Vector3D hitOnTrk = new Vector3D(xt, yt, zt); + // extract information on the crossed strips + float icl1 = banktrk.getShort("Cluster1ID", nc); + float icl2 = banktrk.getShort("Cluster2ID", nc); + DataBank bankcl = event.getBank("FTTRK::clusters"); + // which is the correct location in the cluster bank for the cluster with the given id? + int icl1ok = -1; + int icl2ok = -1; + for(int k=0; k0){ + segment1.setOrigin(0.,0.); segment1.setEnd(0.,0.); + segment2.setOrigin(0.,0.); segment2.setEnd(0.,0.); + seed1 = bankcl.getInt("seed", (int)icl1ok); + seed2 = bankcl.getInt("seed", (int)icl2ok); + int cent1 = (int)bankcl.getFloat("centroid", icl1ok); + int cent2 = (int)bankcl.getFloat("centroid", icl2ok); + // if the cluster is formed by >= 3 strips take the centroid + int clustsize1 = bankcl.getShort("size", icl1ok); + int clustsize2 = bankcl.getShort("size", icl2ok); + if(clustsize1>=FTConstants.TRK_MIN_ClusterSizeForCentroid){ + int sector = FTTRKReconstruction.findSector(seed1); + if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed1 = cent1; + } + if(clustsize2>=FTConstants.TRK_MIN_ClusterSizeForCentroid){ + int sector = FTTRKReconstruction.findSector(seed2); + if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed2 = cent2; + } + int lay1 = bankcl.getInt("layer", (int)icl1ok); + int lay2 = bankcl.getInt("layer", (int)icl2ok); + if(debugMode>0){ + System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ seed1, seed2 " + + seed1 + " " + seed2 + " layer1 layer2 " + lay1 + " " + lay2); + System.out.println("~~~~~~~~~~ hit strip 1: " + seed1 + " layer " + lay1 + " sector " + + FTTRKReconstruction.findSector(seed1)); + System.out.println("~~~~~~~~~~ hit strip 2: " + seed2 + " layer " + lay2 + " sector " + + FTTRKReconstruction.findSector(seed2)); + } + if(seed1!=0 && seed2!=0){ + Line3D seg1 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay1, seed1); + Line3D seg2 = (Line3D) FTTRKConstantsLoader.getStripSegmentLab(lay2, seed2); + segment1.setOrigin(seg1.origin().x(), seg1.origin().y()); + segment2.setOrigin(seg2.origin().x(), seg2.origin().y()); + segment1.setEnd(seg1.end().x(), seg1.end().y()); + segment2.setEnd(seg2.end().x(), seg2.end().y()); + + // extract the mumber of strips forming the cross and store them in an occupancy plot for matched signals + // which strips are forming the id cross? + if(lay1==DetectorLayer.FTTRK_LAYER1){h71.fill(seed1); + }else if(lay1==DetectorLayer.FTTRK_LAYER2){h72.fill(seed1); + }else if(lay1==DetectorLayer.FTTRK_LAYER3){h73.fill(seed1); + }else if(lay1==DetectorLayer.FTTRK_LAYER4){h74.fill(seed1); + } + + if(lay2==DetectorLayer.FTTRK_LAYER1){h71.fill(seed2); + }else if(lay2==DetectorLayer.FTTRK_LAYER2){h72.fill(seed2); + }else if(lay2==DetectorLayer.FTTRK_LAYER3){h73.fill(seed2); + }else if(lay2==DetectorLayer.FTTRK_LAYER4){h74.fill(seed2); + } + + DataBank bankhit = event.getBank("FTTRK::hits"); + if(bankhit.rows()>0){ + for(int k=0; k0){ + System.out.println("coordinates of track on fttrk " + bank.getFloat("cx", i)*zt + " " + + bank.getFloat("cy", i)*zt + " " + bank.getFloat("cz", i)*zt); + System.out.println("director cosines hit on calorimeter " + part.x() + " " + part.y() + " " + part.z()); + System.out.println("director cosines hit of fttrk " + xt + " " + yt + " " + zt); + } + h102.fill(bank.getFloat("cx", i) *zt - xt); + h104.fill(bank.getFloat("cy", i) *zt - yt); + h106.fill((part.theta() - hitOnTrk.theta())); + h108.fill((part.phi() - hitOnTrk.phi())); + int sec1 = FTTRKReconstruction.findSector(seed1); + int sec2 = FTTRKReconstruction.findSector(seed2); + hSecDet0.fill(sec1, sec2); + hSeedDet0.fill(seed1, seed2); + if(debugMode>0){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + + " bad seeds d0, event " + nev); + } + canvasCALTRK.cd(0); + segment1.setLineColor(1); + segment2.setLineColor(2); + canvasCALTRK.draw(segment1); + canvasCALTRK.draw(segment2); + + }else if(det==TRK2 && trk2ID==crossID){ + h101.fill(xt, yt); + h103.fill(bank.getFloat("cx", i) *zt - xt); + h105.fill(bank.getFloat("cy", i) *zt - yt); + h107.fill((part.theta() - hitOnTrk.theta())); + h109.fill((part.phi() - hitOnTrk.phi())); + int sec1 = FTTRKReconstruction.findSector(seed1); + int sec2 = FTTRKReconstruction.findSector(seed2); + hSecDet1.fill(sec1, sec2); + hSeedDet1.fill(seed1, seed2); + if(debugMode>0){ + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + sec1 + "-" + sec2 + + " bad seeds d1, event " + nev); + } + canvasCALTRK.cd(1); + segment1.setLineColor(3); + segment2.setLineColor(4); + canvasCALTRK.draw(segment1); + canvasCALTRK.draw(segment2); + } + + // extract residuals of TRK1 wrt TRK0 and viceversa + // loop on crosses in det0, find track connecting with origin, evaluate residuals of TRK1 hits wrt to this track + double cx = hitOnTrk.x() - centerOfTarget.x(); + double cy = hitOnTrk.y() - centerOfTarget.y(); + double cz = hitOnTrk.z() - centerOfTarget.z(); + for(int ncj = 0; ncj < ncrosses; ncj++) { + int det1 = banktrk.getInt("detector", ncj); + if(det1 >=0 && nc != ncj && det != det1){ + double x1 = banktrk.getFloat("x", ncj); + double y1 = banktrk.getFloat("y", ncj); + double z1 = banktrk.getFloat("z", ncj); + int secondCrossID = banktrk.getInt("id", ncj); + Vector3D cross = new Vector3D(x1, y1, z1); + // check if within tolerance (previously done in findCross) + double r0 = Math.sqrt(hitOnTrk.x()*hitOnTrk.x() + hitOnTrk.y()*hitOnTrk.y() + hitOnTrk.z()*hitOnTrk.z()); + double r1 = Math.sqrt(cross.x()*cross.x() + cross.y()*cross.y() + cross.z()*cross.z()); + double r02d = Math.sqrt(hitOnTrk.x()*hitOnTrk.x() + hitOnTrk.y()*hitOnTrk.y()); + double r12d = Math.sqrt(cross.x()*cross.x() + cross.y()*cross.y()); + double diffRadii = r02d-r12d; + double diffTheta = Math.acos(hitOnTrk.z()/r0) - Math.acos(cross.z()/r1); + double diffPhi = Math.atan2(hitOnTrk.y(), hitOnTrk.x()) - Math.atan2(cross.y(), cross.x()); + if(Math.abs(diffPhi) < diffPhiTolerance && Math.abs(diffRadii)< diffRadTolerance && + Math.abs(diffTheta) < diffThetaTolerance){ + double t = (cross.z()-centerOfTarget.z())/hitOnTrk.z(); + Vector3D pointOnTrackAtZ = new Vector3D(cx*t + centerOfTarget.x(), cy*t + centerOfTarget.y(), z1); + if(det1 == TRK2 && trk2ID == secondCrossID){ + resTrkXdet0.fill(pointOnTrackAtZ.x() - cross.x()); + resTrkYdet0.fill(pointOnTrackAtZ.y() - cross.y()); + resTrkThetadet0.fill(pointOnTrackAtZ.theta() - cross.theta()); + resTrkPhidet0.fill(pointOnTrackAtZ.phi() - cross.phi()); + resTrkXVsXdet0.fill(cross.x(), pointOnTrackAtZ.x() - cross.x()); + resTrkYVsYdet0.fill(cross.y(), pointOnTrackAtZ.y() - cross.y()); + }else if(det1 == TRK1 && trk1ID == secondCrossID){ + resTrkXdet1.fill(pointOnTrackAtZ.x() - cross.x()); + resTrkYdet1.fill(pointOnTrackAtZ.y() - cross.y()); + resTrkThetadet1.fill(pointOnTrackAtZ.theta() - cross.theta()); + resTrkPhidet1.fill(pointOnTrackAtZ.phi() - cross.phi()); + resTrkXVsXdet1.fill(cross.x(), pointOnTrackAtZ.x() - cross.x()); + resTrkYVsYdet1.fill(cross.y(), pointOnTrackAtZ.y() - cross.y()); + } + } + } + } + } + } + + if(ncrosses==2){ + float x0 = banktrk.getFloat("x", 0); + float y0 = banktrk.getFloat("y", 0); + float x1 = banktrk.getFloat("x", 1); + float y1 = banktrk.getFloat("y", 1); + + Point3D c0 = new Point3D(x0, y0, banktrk.getFloat("z",0)); + Point3D c1 = new Point3D(x1, y1, banktrk.getFloat("z",1)); + Line3D lineBwCrosses = new Line3D(c1, c0); + if(debugMode>0){ + System.out.println("x coordinates on 2 layers " + x0 + " " + x1); + System.out.println("director cosines straight line bw crosses, cx " + lineBwCrosses.originDir().x() + " cy " + + lineBwCrosses.originDir().y() + " cz " + lineBwCrosses.originDir().z()); + } + } + } + } + } + } + + if(event.hasBank("FTTRK::crosses")){ + nevWithCrosses++; + DataBank banktrk = event.getBank("FTTRK::crosses"); + int nrows = banktrk.rows(); + + // comparison with MC data + // how many particles have been generated? + int ipart = gen.countGenerated(); + for(int ip=0; ip0) System.out.println("------- generated particle n " + ip + " type: " + gen.getGeneratedParticle(ip).pid() + " mass " + mass); + double P = gen.getGeneratedParticle(ip).p(); + double cx = gen.getGeneratedParticle(ip).px()/P; + double cy = gen.getGeneratedParticle(ip).py()/P; + double cz = gen.getGeneratedParticle(ip).pz()/P; + double Pz = P*cz; + double Pperp = P*Math.sqrt(cx*cx+cy*cy); + double x0 = gen.getGeneratedParticle(ip).vx(); + double y0 = gen.getGeneratedParticle(ip).vy(); + double z0 = gen.getGeneratedParticle(ip).vz(); + double q = Math.abs(gen.getGeneratedParticle(ip).charge()); // negative particles bend upwards + for (int i = 0; i < nrows; i++) { + int det = banktrk.getInt("detector", i); + double xt = banktrk.getFloat("x", i); + double yt = banktrk.getFloat("y", i); + double zt = banktrk.getFloat("z", i); + + if(debugMode>0){ + System.out.println("MC: x0 = " + x0 + " y0 " + y0 + " z0 " + z0); + System.out.println("MC cosines: cx = " + cx + " cy " + cy + " cz " + cz); + System.out.println("trk: xt = " + xt + " yt " + yt + " zt " + zt); + } + double t = (zt - z0)/cz; + Vector3D hitOnTrk = new Vector3D(xt, yt, zt); + Vector3D hitMCOnTrk = new Vector3D(x0+cx*t, y0+cy*t, zt); // straight line + + if(debugMode>0) System.out.println("MC on the straight line x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + + " z = " + hitMCOnTrk.z()); + // if the magnetic field is on, the coordinates must be swum along a helix + double B = en.getSolenoid(); + if(B!=0.){ + // find the crossing point of the helix and a xy plane at given z, where the magneti field stops + double zStop = 100.0; // PROVISIONAL fixed to 1 meter + double phi0 = Math.atan2(cy,cx); + double R = Pperp/0.3/B/q*1.e2; // R in cm + double dAlpha = (zStop-z0)*(B*q*0.3)/Pz*1.e-2; // deltaZ in meters + int nturns = (int) Math.floor(dAlpha/2./Math.PI); // number of full turns + if(dAlpha>0){ + dAlpha -= nturns*2.*Math.PI; + }else{ + dAlpha += nturns*2.*Math.PI; + } + + double xc = R*Math.sin(phi0); + double yc = R*Math.cos(phi0); + Vector3D hitOnPlane = new Vector3D(); + Vector3D tangentAtZstop = new Vector3D(); + if(R*dAlpha>0){ + hitOnPlane.setX(-xc + R*(Math.sin(phi0 + dAlpha))); + hitOnPlane.setY( yc - R*(Math.cos(phi0 + dAlpha))); + hitOnPlane.setZ(zStop); + double gamma = Math.atan2(hitOnPlane.y(),hitOnPlane.x()); + double vx1 = Pperp/P*Math.sin(gamma); + double vy1 = Pperp/P*Math.cos(gamma); + double vz1 = Math.sqrt(1. - vx1*vx1 + vy1*vy1); + double t1 = (zt - hitOnPlane.z())/vz1; + hitMCOnTrk.setXYZ(hitOnPlane.x()+vx1*t1, hitOnPlane.y()+vy1*t1, zt); + }else{ + if(debugMode>0) System.out.println("check particle/curvature signs"); + } + } + if(debugMode>0) System.out.println("MC after swimming in mag field x = " + hitMCOnTrk.x() + " y = " + hitMCOnTrk.y() + + " z = " + hitMCOnTrk.z()); + + if(det==TRK1){ + h2000.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); // Montecarlo hit location on first detector middle plane + h1100.fill(hitOnTrk.x(), hitOnTrk.y()); + h1102.fill(hitMCOnTrk.x() - hitOnTrk.x()); + h1104.fill(hitMCOnTrk.y() - hitOnTrk.y()); + h1106.fill((hitMCOnTrk.theta() - hitOnTrk.theta())); + h1108.fill((hitMCOnTrk.phi() - hitOnTrk.phi())); + h1112.fill((hitMCOnTrk.x() - hitOnTrk.x())/hitMCOnTrk.x()); + h1114.fill((hitMCOnTrk.y() - hitOnTrk.y())/hitMCOnTrk.y()); + h202.fill(hitOnTrk.x()); + h1202.fill(hitMCOnTrk.x()); + h204.fill(hitOnTrk.y()); + h1204.fill(hitMCOnTrk.y()); + }else if(det==TRK2){ + h2001.fill(hitMCOnTrk.x(), hitMCOnTrk.y()); + h1101.fill(hitOnTrk.x(), hitOnTrk.y()); + h1103.fill(hitMCOnTrk.x() - hitOnTrk.x()); + h1105.fill(hitMCOnTrk.y() - hitOnTrk.y()); + h1107.fill((hitMCOnTrk.theta() - hitOnTrk.theta())); + h1109.fill((hitMCOnTrk.phi() - hitOnTrk.phi())); + h1113.fill((hitMCOnTrk.x() - hitOnTrk.x())/hitMCOnTrk.x()); + h1115.fill((hitMCOnTrk.y() - hitOnTrk.y())/hitMCOnTrk.y()); + h203.fill(hitOnTrk.x()); + h1203.fill(hitMCOnTrk.x()); + h205.fill(hitOnTrk.y()); + h1205.fill(hitMCOnTrk.y()); + } + if(debugMode>0){ + System.out.println("MC hit coordinates " + hitMCOnTrk.x() + " " + hitMCOnTrk.y() + " " + hitMCOnTrk.z()); + System.out.println("MC theta " + hitMCOnTrk.theta() + " hit on trk " + hitOnTrk.theta()); + System.out.println("MC phi " + hitMCOnTrk.phi() + " hit on trk " + hitOnTrk.phi()); + System.out.println("trk hit coordinates " + hitOnTrk.x() + " " + hitOnTrk.y() + " " + hitOnTrk.z()); + } + } + } // end MC comparison + } // end loop on crosses + } + } + + if(debugMode>=-1) // print always + System.out.println("@@@@@@@@@@@@@ total number of events read " + nev + " @@@@@ total number of events with rec cross in FTTRK " + + nevWithCrosses + " @@@@ number of reconstructed FTParticles " + nOfFTParticles); + + if(timeEnergyDiagnosticHistograms){ + JFrame frame = new JFrame("FT Reconstruction"); + frame.setSize(1200, 800); + EmbeddedCanvas canvas = new EmbeddedCanvas(); + canvas.divide(3, 3); + canvas.cd(0); + canvas.draw(h1); + canvas.cd(1); + canvas.draw(h2); + canvas.cd(2); + canvas.draw(h3); + canvas.cd(3); + h501.setFillColor(3); // green + h502.setFillColor(5); // yellow + h503.setFillColor(8); // dark green + h504.setFillColor(7); // orange + h600.setFillColor(9); // blue violet + + + canvas.draw(h501); + canvas.draw(h502,"same"); + canvas.cd(4); + canvas.draw(h503,""); + canvas.draw(h504,"same"); + + for (int i = 0; i < h6.getDataBufferSize(); i++) { + float meanE = h6.getDataBufferBin(i); + float nE = h7.getDataBufferBin(i); + if (nE > 0) { + h6.setDataBufferBin(i, meanE / nE); + } + } + canvas.cd(5); + canvas.draw(h507); + canvas.cd(6); + canvas.draw(h600); + canvas.cd(7); + canvas.draw(h601); + canvas.cd(8); + frame.add(canvas); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + double narrowFactor = 7.5; // was 4.5 + JFrame frametrk = new JFrame("FTTRK Reconstruction with respect to FTCAL tracking"); + frametrk.setSize(1600, 800); + EmbeddedCanvas canvastrk = new EmbeddedCanvas(); + canvastrk.divide(5, 2); + canvastrk.cd(0); + canvastrk.draw(h100); + canvastrk.cd(1); + canvastrk.draw(h102); + F1D f02 = new F1D("f02","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); + f02.setParameter(0, 10.0); + f02.setParameter(1, 0.0); + f02.setParameter(2, 1.0); + f02.setLineColor(6); + f02.setLineWidth(3); + DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma + f02.setParameter(0, f02.parameter(0).value()); + f02.setParameter(1, f02.parameter(1).value()); + f02.setParameter(2, f02.parameter(2).value()); + DataFitter.fit(f02, h102, "Q"); //No options uses error for sigma + f02.setOptStat(11111); + canvastrk.draw(f02,"same"); + canvastrk.cd(2); + canvastrk.draw(h104); + F1D f04 = new F1D("f04","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/(narrowFactor)); + f04.setParameter(0, h104.getMax()); + f04.setParameter(1, h104.getMean()); + f04.setParameter(2, h104.getRMS()/2.); + f04.setLineColor(6); + f04.setLineWidth(3); + DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma + f04.setParameter(0, f04.parameter(0).value()); + f04.setParameter(1, f04.parameter(1).value()); + f04.setParameter(2, f04.parameter(2).value()); + DataFitter.fit(f04, h104, "Q"); //No options uses error for sigma + f04.setOptStat(11111); + canvastrk.draw(f04,"same"); + canvastrk.cd(3); + canvastrk.draw(h106); + F1D f06 = new F1D("f06","[amp]*gaus(x,[mean],[sigma])", -limTCTheta/narrowFactor, limTCTheta/narrowFactor); + f06.setParameter(0, 10.0); + f06.setParameter(1, h106.getMean()); + f06.setParameter(2, h106.getRMS()); + f06.setLineColor(6); + f06.setLineWidth(3); + DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma + f06.setParameter(0, f06.parameter(0).value()); + f06.setParameter(1, f06.parameter(1).value()); + f06.setParameter(2, f06.parameter(2).value()); + DataFitter.fit(f06, h106, "Q"); //No options uses error for sigma + f06.setOptStat(11111); + canvastrk.draw(f06,"same"); + canvastrk.cd(4); + canvastrk.draw(h108); + F1D f08 = new F1D("f08","[amp]*gaus(x,[mean],[sigma])", -limTCPhi/narrowFactor, limTCPhi/narrowFactor); + f08.setParameter(0, h108.getMax()); + f08.setParameter(1, h108.getMean()); + f08.setParameter(2, h108.getRMS()); + f08.setLineColor(6); + f08.setLineWidth(3); + DataFitter.fit(f08, h108, "Q"); //No options uses error for sigma + f08.setOptStat(11111); + canvastrk.draw(f08,"same"); + + canvastrk.cd(5); + canvastrk.draw(h101); + + canvastrk.cd(6); + canvastrk.draw(h103); + F1D f03 = new F1D("f03","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); + f03.setParameter(0, 10.0); + f03.setParameter(1, 0.0); + f03.setParameter(2, 1.0); + f03.setLineColor(6); + f03.setLineWidth(3); + DataFitter.fit(f03, h103, "Q"); //No options uses error for sigma + f03.setParameter(0, f03.parameter(0).value()); + f03.setParameter(1, f03.parameter(1).value()); + f03.setParameter(2, f03.parameter(2).value()); + DataFitter.fit(f03, h103, "Q"); //No options uses error for sigma + f03.setOptStat(1111); + canvastrk.draw(f03,"same"); + + + canvastrk.cd(7); + canvastrk.draw(h105); + F1D f05 = new F1D("f05","[amp]*gaus(x,[mean],[sigma])", -limTC/narrowFactor, limTC/narrowFactor); + f05.setParameter(0, 10.0); + f05.setParameter(1, 0.0); + f05.setParameter(2, 1.0); + f05.setLineColor(6); + f05.setLineWidth(3); + DataFitter.fit(f05, h105, "Q"); //No options uses error for sigma + f05.setParameter(0, f05.parameter(0).value()); + f05.setParameter(1, f05.parameter(1).value()); + f05.setParameter(2, f05.parameter(2).value()); + DataFitter.fit(f05, h105, "Q"); //No options uses error for sigma + f05.setOptStat(1111); + canvastrk.draw(f05,"same"); + + canvastrk.cd(8); + canvastrk.draw(h107); + F1D f07 = new F1D("f07","[amp]*gaus(x,[mean],[sigma])", -limTCTheta/narrowFactor, limTCTheta/narrowFactor); + f07.setParameter(0, h107.getMax()); + f07.setParameter(1, h107.getMean()); + f07.setParameter(2, h107.getRMS()); + f07.setLineColor(6); + f07.setLineWidth(3); + DataFitter.fit(f07, h107, "Q"); //No options uses error for sigma + f07.setOptStat(1111); + canvastrk.draw(f07,"same"); + + canvastrk.cd(9); + canvastrk.draw(h109); + F1D f09 = new F1D("f09","[amp]*gaus(x,[mean],[sigma])", -limTCPhi/narrowFactor, limTCPhi/narrowFactor); + f09.setParameter(0, h109.getMax()); + f09.setParameter(1, h109.getMean()); + f09.setParameter(2, h109.getRMS()); + f09.setLineColor(6); + f09.setLineWidth(3); + DataFitter.fit(f09, h109, "Q"); //No options uses error for sigma + f09.setParameter(0, f09.parameter(0).value()); + f09.setParameter(1, f09.parameter(1).value()); + f09.setParameter(2, f09.parameter(2).value()); + DataFitter.fit(f09, h109, "Q"); //No options uses error for sigma + f09.setOptStat(1111); + canvastrk.draw(f09,"same"); + frametrk.add(canvastrk); + frametrk.setLocationRelativeTo(null); + frametrk.setVisible(true); + + JFrame frametrkres = new JFrame("FTTRK Resolutions wrt MC generated events"); + frametrkres.setSize(1800, 800); + EmbeddedCanvas canvastrkres = new EmbeddedCanvas(); + canvastrkres.divide(7, 2); + int ii = 0; + canvastrkres.cd(ii); + canvastrkres.draw(h1100); + canvastrkres.cd(++ii); + canvastrkres.draw(h1102); + F1D f1 = new F1D("f1","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); + f1.setParameter(0, h1102.getMax()); + f1.setParameter(1, h1102.getMean()); + f1.setParameter(2, h1102.getRMS()); + f1.setLineColor(4); + f1.setLineWidth(3); + DataFitter.fit(f1, h1102, "Q"); //No options uses error for sigma + f1.setParameter(0, f1.parameter(0).value()); + f1.setParameter(1, f1.parameter(1).value()); + f1.setParameter(2, f1.parameter(2).value()); + DataFitter.fit(f1, h1102, "Q"); //No options uses error for sigma + f1.setOptStat(1111); + canvastrkres.draw(f1,"same"); + if(debugMode>0) System.out.println(" mean = " + f1.parameter(1).value() + + " sigma = " + f1.parameter(2).value()); + canvastrkres.cd(++ii); + canvastrkres.draw(h1104); + F1D f2 = new F1D("f2","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); + f2.setParameter(0, f1.parameter(0).value()); + f2.setParameter(1, f1.parameter(1).value()); + f2.setParameter(2, f1.parameter(2).value()); + f2.setLineColor(24); + f2.setLineWidth(3); + DataFitter.fit(f2, h1104, "Q"); //No options uses error for sigma + f2.setOptStat(1111); + canvastrkres.draw(f2,"same"); + if(debugMode>0) System.out.println(" mean = " + f2.parameter(1).value() + + " sigma = " + f2.parameter(2).error()); + canvastrkres.cd(++ii); + canvastrkres.draw(h1106); + F1D f6 = new F1D("f6","[amp]*gaus(x,[mean],[sigma])", -0.001, 0.001); + f6.setParameter(0, f1.parameter(0).value()); + f6.setParameter(1, h1106.getMean()); + f6.setParameter(2, h1106.getRMS()); + f6.setLineColor(24); + f6.setLineWidth(3); + DataFitter.fit(f6, h1106, "Q"); //No options uses error for sigma + f6.setOptStat(1111); + canvastrkres.draw(f6,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1108); + F1D f8 = new F1D("f8","[amp]*gaus(x,[mean],[sigma])", -0.005, 0.005); + f8.setParameter(0, h1108.getMax()); + f8.setParameter(1, h1108.getMean()); + f8.setParameter(2, h1108.getRMS()/2); + f8.setLineColor(24); + f8.setLineWidth(3); + DataFitter.fit(f8, h1108, "Q"); //No options uses error for sigma + f8.setOptStat(1111); + canvastrkres.draw(f8,"same"); + canvastrkres.cd(++ii); + canvastrkres.draw(h1112); + F1D f12 = new F1D("f12","[amp]*gaus(x,[mean],[sigma])", -0.05, 0.05); + f12.setParameter(0, f1.parameter(0).value()); + f12.setParameter(1, h1112.getMean()); + f12.setParameter(2, h1112.getRMS()); + f12.setLineColor(24); + f12.setLineWidth(3); + DataFitter.fit(f12, h1112, "Q"); //No options uses error for sigma + f12.setOptStat(1111); + canvastrkres.draw(f12,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1114); + F1D f14 = new F1D("f14","[amp]*gaus(x,[mean],[sigma])", -0.1, 0.1); + f14.setParameter(0, f1.parameter(0).value()); + f14.setParameter(1, h1114.getMean()); + f14.setParameter(2, h1114.getRMS()); + f14.setLineColor(24); + f14.setLineWidth(3); + DataFitter.fit(f14, h1114, "Q"); //No options uses error for sigma + f14.setOptStat(1111); + canvastrkres.draw(f14,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1101); + canvastrkres.cd(++ii); + canvastrkres.draw(h1103); + F1D f3 = new F1D("f3","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); + f3.setParameter(0, f1.parameter(0).value()); + f3.setParameter(1, f1.parameter(1).value()); + f3.setParameter(2, f1.parameter(2).value()); + f3.setLineColor(34); + f3.setLineWidth(3); + DataFitter.fit(f3, h1103, "Q"); //No options uses error for sigma + f3.setOptStat(1111); + canvastrkres.draw(f3,"same"); + if(debugMode>0) System.out.println(" mean = " + f3.parameter(1).value() + + " sigma = " + f3.parameter(2).error()); + canvastrkres.cd(++ii); + canvastrkres.draw(h1105); + F1D f4 = new F1D("f4","[amp]*gaus(x,[mean],[sigma])", -0.25, 0.25); + f4.setParameter(0, f1.parameter(0).value()); + f4.setParameter(1, f1.parameter(1).value()); + f4.setParameter(2, f1.parameter(2).value()); + f4.setLineColor(44); + f4.setLineWidth(3); + DataFitter.fit(f4, h1105, "Q"); //No options uses error for sigma + f4.setOptStat(1111); + canvastrkres.draw(f4,"same"); + if(debugMode>0) System.out.println(" mean = " + f4.parameter(1).value() + + " sigma = " + f4.parameter(2).error()); + canvastrkres.cd(++ii); + canvastrkres.draw(h1107); + F1D f17 = new F1D("f17","[amp]*gaus(x,[mean],[sigma])", -0.001, 0.001); + f17.setParameter(0, h1107.getMax()); + f17.setParameter(1, h1107.getMean()); + f17.setParameter(2, h1107.getRMS()); + f17.setLineColor(24); + f17.setLineWidth(3); + DataFitter.fit(f17, h1107, "Q"); //No options uses error for sigma + f17.setOptStat(1111); + canvastrkres.draw(f17,"same"); + canvastrkres.cd(++ii); + canvastrkres.draw(h1109); + F1D f19 = new F1D("f19","[amp]*gaus(x,[mean],[sigma])", -0.002, 0.002); + f19.setParameter(0, h1109.getMax()); + f19.setParameter(1, h1109.getMean()); + f19.setParameter(2, h1109.getRMS()); + f19.setLineColor(24); + f19.setLineWidth(3); + DataFitter.fit(f19, h1109, "Q"); //No options uses error for sigma + f19.setOptStat(1111); + canvastrkres.draw(f19,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1113); + F1D f13 = new F1D("f13","[amp]*gaus(x,[mean],[sigma])", -0.05, 0.05); + f13.setParameter(0, f1.parameter(0).value()); + f13.setParameter(1, h1113.getMean()); + f13.setParameter(2, h1113.getRMS()); + f13.setLineColor(24); + f13.setLineWidth(3); + DataFitter.fit(f13, h1113, "Q"); //No options uses error for sigma + f13.setOptStat(1111); + canvastrkres.draw(f13,"same"); + + canvastrkres.cd(++ii); + canvastrkres.draw(h1115); + F1D f15 = new F1D("f15","[amp]*gaus(x,[mean],[sigma])", -0.1, 0.1); + f15.setParameter(0, f1.parameter(0).value()); + f15.setParameter(1, h1115.getMean()); + f15.setParameter(2, h1115.getRMS()); + f15.setLineColor(24); + f15.setLineWidth(3); + DataFitter.fit(f15, h1115, "Q"); //No options uses error for sigma + f15.setOptStat(1111); + canvastrkres.draw(f15,"same"); + + frametrkres.add(canvastrkres); + frametrkres.setLocationRelativeTo(null); + frametrkres.setVisible(true); + + JFrame frametrkrel = new JFrame("FTTRK Resolutions layer1 vs layer2"); + frametrkrel.setSize(800, 800); + EmbeddedCanvas canvastrkrel = new EmbeddedCanvas(); + canvastrkrel.divide(2, 2); + canvastrkrel.cd(0); + canvastrkrel.draw(h202); + canvastrkrel.draw(h1202,"same"); + canvastrkrel.cd(1); + canvastrkrel.draw(h203); + canvastrkrel.draw(h1203,"same"); + canvastrkrel.cd(2); + canvastrkrel.draw(h204); + canvastrkrel.draw(h1204,"same"); + canvastrkrel.cd(3); + canvastrkrel.draw(h205); + canvastrkrel.draw(h1205,"same"); + + frametrkrel.add(canvastrkrel); + frametrkrel.setLocationRelativeTo(null); + frametrkrel.setVisible(true); + + JFrame frameSecradio = new JFrame("20 sectors occupancy"); + frameSecradio.setSize(1000,500); + EmbeddedCanvas canvasSecradio = new EmbeddedCanvas(); + canvasSecradio.divide(2,1); + canvasSecradio.cd(0); + canvasSecradio.draw(hSecDet0); + // excluded cells + double excx0h1[] = {0., 1., 2., 3., 4., 5., 10., 11., 12., 13.}; + double excy0h1[] = {10., 11., 12., 13., 14., 15., 16., 17.}; + GraphErrors excludedDet0half1 = new GraphErrors(); + for(int i=0; i Date: Sat, 26 Feb 2022 15:19:19 +0100 Subject: [PATCH 086/104] test classes for FTTRK reconstruction, outputs for diagnostics --- .../org/jlab/service/ft/FTTRKEngineTest.java | 565 ++++++++++++++++++ 1 file changed, 565 insertions(+) create mode 100644 reconstruction/ft/src/test/java/org/jlab/service/ft/FTTRKEngineTest.java diff --git a/reconstruction/ft/src/test/java/org/jlab/service/ft/FTTRKEngineTest.java b/reconstruction/ft/src/test/java/org/jlab/service/ft/FTTRKEngineTest.java new file mode 100644 index 0000000000..53179288ec --- /dev/null +++ b/reconstruction/ft/src/test/java/org/jlab/service/ft/FTTRKEngineTest.java @@ -0,0 +1,565 @@ +/* + * 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.service.ft; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.swing.JFrame; +import org.jlab.clas.detector.DetectorData; +import org.jlab.clas.detector.DetectorEvent; +import org.jlab.clas.physics.PhysicsEvent; +import org.jlab.clas.reco.ReconstructionEngine; +import org.jlab.detector.base.DetectorLayer; +import org.jlab.groot.data.H1F; +import org.jlab.groot.data.H2F; +import org.jlab.groot.data.DataLine; +import org.jlab.groot.graphics.EmbeddedCanvas; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.io.hipo.HipoDataSource; +import org.jlab.geom.prim.Line3D; +import org.jlab.rec.ft.FTConstants; +import org.jlab.rec.ft.trk.FTTRKEngine; +import org.jlab.rec.ft.trk.FTTRKConstantsLoader; +import org.jlab.rec.ft.trk.FTTRKReconstruction; +import org.jlab.rec.ft.trk.FTTRKCross; +import org.jlab.rec.ft.trk.FTTRKCluster; +import org.jlab.rec.ft.trk.FTTRKHit; + + +/** + * + * @author devita + * @author filippi + */ +public class FTTRKEngineTest extends ReconstructionEngine { + + public FTTRKEngineTest() { + super("FTTRK", "devita", "1.0"); + } + + FTTRKReconstruction reco; + + @Override + public boolean init() { + + String[] tables = new String[]{ + "/calibration/ft/fthodo/charge_to_energy", + "/calibration/ft/fthodo/time_offsets", + "/calibration/ft/fthodo/status", + "/geometry/ft/fthodo", + "/geometry/ft/fttrk" + }; + requireConstants(Arrays.asList(tables)); + this.getConstantsManager().setVariation("default"); + + // use 11 provisionally as run number to download the basic FTTK geometry constants + FTTRKConstantsLoader.Load(11, this.getConstantsManager().getVariation()); + reco = new FTTRKReconstruction(); + reco.debugMode=0; + + return true; + } + + @Override + public boolean processDataEvent(DataEvent event) { + List allHits = new ArrayList(); + ArrayList clusters = new ArrayList(); + ArrayList crosses = new ArrayList(); + + // update calibration constants based on run number if changed + int run = setRunConditionsParameters(event); + + if(run>=0) { + // get hits fron banks + allHits = reco.initFTTRK(event,this.getConstantsManager(), run); + // create clusters + clusters = reco.findClusters(allHits); + // create crosses + crosses = reco.findCrosses(clusters); + // write output banks + reco.writeBanks(event, allHits, clusters, crosses); + } + return true; + } + + public ArrayList processDataEventAndGetClusters(DataEvent event) { + List allHits = new ArrayList(); + ArrayList clusters = new ArrayList(); // era ArrayList + ArrayList crosses = new ArrayList(); + + // update calibration constants based on run number if changed + int run = setRunConditionsParameters(event); + + if(run>=0) { + // get hits from banks + allHits = reco.initFTTRK(event,this.getConstantsManager(), run); + if(allHits.size()>0){ + // create clusters + clusters = reco.findClusters(allHits); + // create crosses + crosses = reco.findCrosses(clusters); + // update hit banks with associated clusters/crosses information + reco.updateAllHitsWithAssociatedIDs(allHits, clusters); + // write output banks + reco.writeBanks(event, allHits, clusters, crosses); + } + } + return clusters; + } + + public int setRunConditionsParameters(DataEvent event) { + int run = -1; + if(event.hasBank("RUN::config")==false) { + System.out.println("RUN CONDITIONS NOT READ!"); + } + + DataBank bank = event.getBank("RUN::config"); + run = bank.getInt("run")[0]; + + return run; + } + + + public static void main (String arg[]) { + int debug = FTTRKReconstruction.debugMode; + FTTRKEngine trk = new FTTRKEngine(); + trk.init(); + // insert input filename here + String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/filter_005418_newbanks.hipo"; +// String input = "/home/filippi/clas12/coatjava-devel/clas12-offline-software_v7.0.0/oneHit_126798.hipo"; // multihit evt + System.out.println("input file " + input); + HipoDataSource reader = new HipoDataSource(); + reader.open(input); + + // initialize histos + H2F h1 = new H2F("h1", "Layer vs. Component", 768, 0., 769., 4, 0.5, 4.5); + h1.setTitleX("Component"); + h1.setTitleY("Layer"); + H1F h2 = new H1F("Energy",100, 0, 1000.); + h2.setOptStat(Integer.parseInt("1111")); h2.setTitleX("Energy"); h2.setTitleY("Counts"); + H1F h3 = new H1F("Time",100, 0., 500.); // was 1e-3 + h3.setOptStat(Integer.parseInt("1111")); h3.setTitleX("Time"); h3.setTitleY("Counts"); + H2F h333 = new H2F("energy vs time",100, 0., 410., 100, 0., 410.); + h333.setTitleX("strip Time"); h333.setTitleY("strip Energy"); + H2F h444 = new H2F("strip vs time",100, 0., 500., 768, 0., 769.); + h444.setTitleX("strip Time"); h444.setTitleY("strip number"); + H2F h445 = new H2F("strip lay 1 vs time",100, 0., 500., 768, 0., 769.); + h445.setTitleX("strip Time"); h445.setTitleY("strip number"); + H2F h446 = new H2F("strip lay 2 vs time",100, 0., 500., 768, 0., 769.); + h446.setTitleX("strip Time"); h446.setTitleY("strip number"); + H2F h447 = new H2F("strip lay 3 vs time",100, 0., 500., 768, 0., 769.); + h447.setTitleX("strip Time"); h447.setTitleY("strip number"); + H2F h448 = new H2F("strip lay 4 vs time",100, 0., 500., 768, 0., 769.); + h448.setTitleX("strip Time"); h448.setTitleY("strip number"); + H1F h1clEn = new H1F("Cluster energy", 100, 0., 1000.); + h1clEn.setOptStat(Integer.parseInt("1111")); h1clEn.setTitleX("centroid energy of clusters"); + H1F hOccupancy1 = new H1F("hOccupancy1", 768, 0., 769.); hOccupancy1.setTitleX("Component layer 1"); + hOccupancy1.setLineColor(1); hOccupancy1.setFillColor(1); hOccupancy1.setOptStat(11); + H1F hOccupancy2 = new H1F("hOccupancy2", 768, 0., 769.); hOccupancy2.setTitleX("Component layer 2"); + hOccupancy2.setLineColor(1); hOccupancy2.setFillColor(2); hOccupancy2.setOptStat(11); + H1F hOccupancy3 = new H1F("hOccupancy3", 768, 0., 769.); hOccupancy3.setTitleX("Component layer 3"); + hOccupancy3.setLineColor(1); hOccupancy3.setFillColor(3); hOccupancy3.setOptStat(11); + H1F hOccupancy4 = new H1F("hOccupancy4", 768, 0., 769.); hOccupancy4.setTitleX("Component layer 4"); + hOccupancy4.setLineColor(1); hOccupancy4.setFillColor(4); hOccupancy4.setOptStat(11); + + H1F hStripDiff1 = new H1F("hStripDiff1", 10, -5.5, 4.5); hStripDiff1.setTitleX("Strip difference layer 1"); + hStripDiff1.setOptStat(Integer.parseInt("1111")); hStripDiff1.setLineColor(1); hStripDiff1.setFillColor(1); + H1F hStripDiff2 = new H1F("hStripDiff2", 10, -5.5, 4.5); hStripDiff2.setTitleX("Strip difference layer 2"); + hStripDiff2.setOptStat(Integer.parseInt("1111")); hStripDiff2.setLineColor(1); hStripDiff2.setFillColor(2); + H1F hStripDiff3 = new H1F("hStripDiff3", 10, -5.5, 4.5); hStripDiff3.setTitleX("Strip difference layer 3"); + hStripDiff3.setOptStat(Integer.parseInt("1111")); hStripDiff3.setLineColor(1); hStripDiff3.setFillColor(3); + H1F hStripDiff4 = new H1F("hStripDiff4", 10, -5.5, 4.5); hStripDiff4.setTitleX("Strip difference layer 4"); + hStripDiff4.setOptStat(Integer.parseInt("1111")); hStripDiff4.setLineColor(1); hStripDiff4.setFillColor(4); + H1F hNumberOfStrips = new H1F("hNumberOfStrips", 10, -0.5, 9.5); hNumberOfStrips.setTitleX("number of strips per cluster"); + hNumberOfStrips.setOptStat(Integer.parseInt("1111")); hNumberOfStrips.setLineColor(1); hNumberOfStrips.setFillColor(5); + H1F hNumberOfStripsInCrosses = new H1F("hNumberOfStripsInCrosses", 10, -0.5, 9.5); hNumberOfStripsInCrosses.setTitleX("number of strips per cluster in crosses"); + hNumberOfStripsInCrosses.setOptStat(Integer.parseInt("1111")); hNumberOfStripsInCrosses.setLineColor(1); hNumberOfStripsInCrosses.setFillColor(6); + + H1F hStripLay1 = new H1F("hStripLay1", 10, -0.5, 9.5); hStripLay1.setTitleX("Number of strips in clusters, layer 1"); + hStripLay1.setOptStat(Integer.parseInt("1111")); hStripLay1.setLineColor(1); hStripLay1.setFillColor(1); + H1F hStripLay2 = new H1F("hStripLay2", 10, -0.5, 9.5); hStripLay2.setTitleX("Number of strips in clusters, layer 2"); + hStripLay2.setOptStat(Integer.parseInt("1111")); hStripLay2.setLineColor(1); hStripLay2.setFillColor(2); + H1F hStripLay3 = new H1F("hStripLay3", 10, -0.5, 9.5); hStripLay3.setTitleX("Number of strips in clusters, layer 3"); + hStripLay3.setOptStat(Integer.parseInt("1111")); hStripLay3.setLineColor(1); hStripLay3.setFillColor(3); + H1F hStripLay4 = new H1F("hStripLay4", 10, -0.5, 9.5); hStripLay4.setTitleX("Number of strips in clusters, layer 4"); + hStripLay4.setOptStat(Integer.parseInt("1111")); hStripLay4.setLineColor(1); hStripLay4.setFillColor(4); + + float lim = 15; + H2F hHitL1 = new H2F("hHitL1","cross y vs x detector 1", 100, -lim, lim, 100, -lim, lim); + H2F hHitL2 = new H2F("hHitL2","cross y vs x detector 2", 100, -lim, lim, 100, -lim, lim); + H2F hHitMatch = new H2F("hHitL2","cross y vs x match", 100, -lim, lim, 100, -lim, lim); + hHitL1.setTitleX("x cross detector 1"); hHitL1.setTitleY("y cross detector 1"); + hHitL2.setTitleX("x cross detector 2"); hHitL2.setTitleY("y cross detector 2"); + hHitMatch.setTitleX("x cross detector match"); hHitMatch.setTitleY("y cross detector match"); + DataLine segment[] = new DataLine[FTTRKConstantsLoader.Nstrips*4]; + + JFrame frameClusters = new JFrame("FT strips in clusters"); + frameClusters.setSize(800,800); + EmbeddedCanvas canvasCl = new EmbeddedCanvas(); + JFrame frameClustersSingleLay = new JFrame("FT strips in clusters single layers"); + frameClustersSingleLay.setSize(800,800); + EmbeddedCanvas canvasClSingleLay = new EmbeddedCanvas(); + canvasClSingleLay.divide(2,2); + + int nc1 = 0, nc2 = 0, ncmatch = 0; + int nev=0; + int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; + int TRK2 = DetectorLayer.FTTRK_MODULE1 - 2; + while(reader.hasEvent()){ +// int nev1 = 0; int nev2 = 10000; for(nev=nev1; nev=1) System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~ processing event ~~~~~~~~~~~ " + nev); +// if(nev != 8) continue; // select one event only for debugging purposes + + ArrayList clusters = new ArrayList(); + clusters = trk.processDataEventAndGetClusters(event); + int nStripsInClusters = 0; + + DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); + PhysicsEvent gen = detectorEvent.getGeneratedEvent(); + double maxcomp1=-100, maxcomp2=-100, maxcomp3=-100, maxcomp4=-100; + int imax1 = -1, imax2 = -1, imax3 = -1, imax4 = -1; + if(event.hasBank("FTTRK::hits")) { + DataBank bank = event.getBank("FTTRK::hits"); + int nrows = bank.rows(); + for(int i=0; i=1) { + System.out.println("layer " + layer + " strip " + comp); + System.out.println("%%%%%%%%% layer " + layer + " strip " + comp + " sector " + FTTRKReconstruction.findSector(comp)); + } + h1.fill(comp,layer); + h2.fill(energy); + h3.fill(time); + h333.fill(time, energy); + + h444.fill(time, comp); + if(layer==DetectorLayer.FTTRK_LAYER1){ + h445.fill(time, comp); + }else if(layer==DetectorLayer.FTTRK_LAYER2){ + h446.fill(time, comp); + }else if(layer==DetectorLayer.FTTRK_LAYER3){ + h447.fill(time, comp); + }else if(layer==DetectorLayer.FTTRK_LAYER4){ + h448.fill(time, comp); + } + + if(layer==DetectorLayer.FTTRK_LAYER1){ + if(debug>=1) System.out.println("component layer 1 " + comp + " event number " + nev + " n rows " + nrows); + hOccupancy1.fill(comp); + if(energy>maxcomp1){ + maxcomp1 = energy; + imax1 = i; + } + }else if(layer==DetectorLayer.FTTRK_LAYER2){ + hOccupancy2.fill(comp); + if(energy>maxcomp2){ + maxcomp2 = energy; + imax2 = i; + } + }else if(layer==DetectorLayer.FTTRK_LAYER3){ + hOccupancy3.fill(comp); + if(energy>maxcomp3){ + maxcomp3 = energy; + imax3 = i; + } + }else if(layer==DetectorLayer.FTTRK_LAYER4){ + hOccupancy4.fill(comp); + if(energy>maxcomp4){ + maxcomp4 = energy; + imax4 = i; + } + } + } + // strip number correposponding to the max energy release + maxcomp1 = bank.getShort("component", imax1); + maxcomp2 = bank.getShort("component", imax2); + maxcomp3 = bank.getShort("component", imax3); + maxcomp4 = bank.getShort("component", imax4); + } + + + // iterate along the cluster list for every event + if(debug>=1) System.out.println("clusters size --- " + clusters.size()); + if(clusters.size()!=0){ + // get one cluster and iterate over all the strips contained in it + canvasCl.cd(1); canvasCl.draw(hHitL1); + for(int l=0; l-1) hNumberOfStripsInCrosses.fill(singleCluster.size()); + if(singleCluster.get_Layer()==DetectorLayer.FTTRK_LAYER1){ + hStripDiff1.fill(maxcomp1 - singleCluster.get_Centroid()); + hStripLay1.fill(singleCluster.size()); + }else if(singleCluster.get_Layer()==DetectorLayer.FTTRK_LAYER2){ + hStripDiff2.fill(maxcomp2 - singleCluster.get_Centroid()); + hStripLay2.fill(singleCluster.size()); + }else if(singleCluster.get_Layer()==DetectorLayer.FTTRK_LAYER3){ + hStripDiff3.fill(maxcomp3 - singleCluster.get_Centroid()); + hStripLay3.fill(singleCluster.size()); + }else if(singleCluster.get_Layer()==DetectorLayer.FTTRK_LAYER4){ + hStripDiff4.fill(maxcomp4 - singleCluster.get_Centroid()); + hStripLay4.fill(singleCluster.size()); + } + int nst = singleCluster.size(); + if(debug>=1) System.out.println("nst - " + nst); + for(int j=0; j=1) System.out.println("total number of clusters " + clusters.size() + " - number of cluster " + i + " cluster size " + + singleCluster.size() + " strip# " + j + " clusterId " + singleCluster.get_CId() + + " layer " + singleCluster.get_Layer() + " strip number " + singleCluster.get(j).get_Strip() + + " segment " + seg.origin().x() + " " + seg.origin().y() + " " + seg.end().x() + " " + seg.end().y() + + " total mean energy of the cluster " + singleCluster.get_TotalEnergy()); + segment[nStripsInClusters] = new DataLine(seg.origin().x(), seg.origin().y(), seg.end().x(), seg.end().y()); + int lay = singleCluster.get_Layer(); + segment[nStripsInClusters].setLineColor(lay); + if(debug>=1) System.out.println("nStripsInCluster " + nStripsInClusters); + canvasCl.draw(segment[nStripsInClusters]); + h1clEn.fill(singleCluster.get_TotalEnergy()); + hNumberOfStrips.fill(singleCluster.size()); + if(debug>=1) System.out.println("%%%%% drawn segment " + singleCluster.get(j).get_Strip() + " cluster " + singleCluster.get_CId() + " layer " + singleCluster.get_Layer()); + canvasClSingleLay.cd(lay-1); canvasClSingleLay.draw(segment[nStripsInClusters]); + + nStripsInClusters++; + } + } + } + + + if(debug>=1) System.out.println("is there the crosses bank? " + event.hasBank("FTTRK::crosses")); + if(event.hasBank("FTTRK::crosses")){ + DataBank crossBank = event.getBank("FTTRK::crosses"); + int nrows = crossBank.rows(); + float x[]; + float y[]; + float z[]; + byte det[]; + x = new float[nrows]; + y = new float[nrows]; + z = new float[nrows]; + det = new byte[nrows]; + for(int i=0; i=1) System.out.println("number of crosses " + nrows + " detector " + det[i] + " x " + x[i] + " y " + y[i]); + + if(det[i]==TRK1) {hHitL1.fill(x[i], y[i]); nc1++;} + if(det[i]==TRK2) {hHitL2.fill(x[i], y[i]); nc2++;} + } + // loop on all crosses on detector 1 and 2 and find the one with better matching + double minDistance = 1000; + double minDiffPhi = 1000.; + int iBest = -1, jBest = -1; + if(debug>=1) System.out.println("number of rows " + nrows); + if(nrows>=1){ + double diffPhi = 1000; + for(int i=0; ii; j--){ + if(det[i]!=det[j]){ + double distance = Math.sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])); + // check det1 and det2 correspondence by comparing phi angles + // the radius is larger for the second detector (as it is more distant) + double phiCross1 = Math.atan2(y[i],x[i]); + double phiCross2 = Math.atan2(y[j],x[j]); + diffPhi = Math.abs(phiCross1-phiCross2); + if(Math.abs(phiCross1-phiCross2)=1) System.out.println("minimum distance " + minDistance); + // adjust tolerances if needed (some reference values are hardcoded in FTConstants.java + double diffRadTolerance = 0.5; + double diffPhiTolerance = 1.; + double thetaTolerance = 0.05; + if(iBest>-1 && jBest>-1){ + double r1 = Math.sqrt(x[iBest]*x[iBest]+y[iBest]*y[iBest]); + double r2 = Math.sqrt(x[jBest]*x[jBest]+y[jBest]*y[jBest]); + double diffRadii = r1-r2; + double diffTheta = Math.atan2(r1,z[iBest])- Math.atan2(r2,z[jBest]); + if(minDiffPhi < diffPhiTolerance && + Math.abs(diffRadii)=1) System.out.println("phi differences on two detectors " + diffPhi + " number of cross " + ncmatch + + " diffTheta " + diffTheta + " diffRadii " + diffRadii + " " + det[iBest] + " " + det[jBest]); + hHitMatch.fill((x[iBest]+x[jBest])/2., (y[iBest]+y[jBest])/2.); + ncmatch++; + } + } + } + } + } + + // output + if(debug>=1) System.out.println("number of found crosses: module 1: " + nc1 + " module 2: " + nc2 + " matching crosses " + ncmatch); + + JFrame frame = new JFrame("FT Reconstruction"); + frame.setSize(1200,800); + EmbeddedCanvas canvas = new EmbeddedCanvas(); + canvas.divide(2,3); + canvas.cd(0); canvas.draw(h1); + canvas.cd(1); canvas.draw(h2); + canvas.cd(2); canvas.draw(h3); + canvas.cd(3); canvas.draw(h333); + canvas.cd(4); canvas.draw(h1clEn); + canvas.cd(5); canvas.draw(h444); + frame.add(canvas); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + + JFrame framest = new JFrame("FT strip vs time in layers"); + framest.setSize(800,800); + EmbeddedCanvas canvast = new EmbeddedCanvas(); + canvast.divide(2,2); + canvast.cd(0); canvast.draw(h445); + canvast.cd(1); canvast.draw(h446); + canvast.cd(2); canvast.draw(h447); + canvast.cd(3); canvast.draw(h448); + framest.add(canvast); + framest.setLocationRelativeTo(null); + framest.setVisible(true); + + JFrame frameDiff = new JFrame("Strip Difference"); + frameDiff.setSize(800,800); + EmbeddedCanvas canvasDiff = new EmbeddedCanvas(); + canvasDiff.divide(2,3); + canvasDiff.cd(0); canvasDiff.draw(hStripDiff1); + canvasDiff.cd(1); canvasDiff.draw(hStripDiff2); + canvasDiff.cd(2); canvasDiff.draw(hStripDiff3); + canvasDiff.cd(3); canvasDiff.draw(hStripDiff4); + canvasDiff.cd(4); canvasDiff.draw(hNumberOfStrips); + canvasDiff.cd(5); canvasDiff.draw(hNumberOfStripsInCrosses); + frameDiff.add(canvasDiff); + frameDiff.setLocationRelativeTo(null); + frameDiff.setVisible(true); + + JFrame frameStrip = new JFrame("Strips in clusters"); + frameStrip.setSize(800,800); + EmbeddedCanvas canvasStrip = new EmbeddedCanvas(); + canvasStrip.divide(2,2); + canvasStrip.cd(0); canvasStrip.draw(hStripLay1); + canvasStrip.cd(1); canvasStrip.draw(hStripLay2); + canvasStrip.cd(2); canvasStrip.draw(hStripLay3); + canvasStrip.cd(3); canvasStrip.draw(hStripLay4); + frameStrip.add(canvasStrip); + frameStrip.setLocationRelativeTo(null); + frameStrip.setVisible(true); + + JFrame frame2 = new JFrame("FT crosses coordinates per module"); + frame2.setSize(800,800); + EmbeddedCanvas canvas2 = new EmbeddedCanvas(); + canvas2.divide(2,2); + canvas2.cd(0); canvas2.draw(hHitL1); + canvas2.cd(1); canvas2.draw(hHitL2); + canvas2.cd(2); canvas2.draw(hHitMatch); + frame2.add(canvas2); + frame2.setLocationRelativeTo(null); + frame2.setVisible(true); + + frameClusters.add(canvasCl); + frameClusters.setLocationRelativeTo(null); + frameClusters.setVisible(true); + + frameClustersSingleLay.add(canvasClSingleLay); + frameClustersSingleLay.setLocationRelativeTo(null); + frameClustersSingleLay.setVisible(true); + + JFrame frame3 = new JFrame("FT Occupancy single layers"); + frame3.setSize(1200,800); + EmbeddedCanvas canvas3 = new EmbeddedCanvas(); + canvas3.divide(2,2); + int ic=-1; + double upl = 100.; + DataLine l1 = new DataLine(64., 0., 64., upl); + DataLine l2 = new DataLine(129., 0., 129., upl); + DataLine l3 = new DataLine(162., 0., 162., upl); + DataLine l4 = new DataLine(193., 0., 193., upl); + DataLine l5 = new DataLine(224., 0., 224., upl); // + DataLine l6 = new DataLine(256., 0., 256., upl); + DataLine l7 = new DataLine(288., 0., 288., upl); // + DataLine l8 = new DataLine(321., 0., 321., upl); + DataLine l9 = new DataLine(353., 0., 353., upl); + DataLine l10 = new DataLine(385., 0., 385., upl); + DataLine l11 = new DataLine(417., 0., 417., upl); + DataLine l12 = new DataLine(449., 0., 449., upl); + DataLine l13 = new DataLine(480., 0., 480., upl); // + DataLine l14 = new DataLine(513., 0., 513., upl); + DataLine l15 = new DataLine(544., 0., 544., upl); // + DataLine l16 = new DataLine(578., 0., 578., upl); + DataLine l17 = new DataLine(611., 0., 611., upl); + DataLine l18 = new DataLine(641., 0., 641., upl); + DataLine l19 = new DataLine(705., 0., 705., upl); + DataLine l20 = new DataLine(768., 0., 768., upl); + l1.setLineColor(6); l2.setLineColor(6); l3.setLineColor(6); + l4.setLineColor(6); l5.setLineColor(6); l6.setLineColor(6); + l7.setLineColor(6); l8.setLineColor(6); l9.setLineColor(6); l10.setLineColor(6); + l11.setLineColor(6); l12.setLineColor(6); l13.setLineColor(6); l14.setLineColor(4); l15.setLineColor(6); + l16.setLineColor(6); l17.setLineColor(6); l18.setLineColor(6); l19.setLineColor(6); l20.setLineColor(6); + l1.setLineStyle(3); l2.setLineStyle(3); l3.setLineStyle(3); l4.setLineStyle(3); l5.setLineStyle(3); + + canvas3.cd(++ic); canvas3.draw(hOccupancy1); + canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); + canvas3.draw(l4); + canvas3.draw(l6); + canvas3.draw(l8); canvas3.draw(l9); + canvas3.draw(l10); canvas3.draw(l11); + canvas3.draw(l12); + canvas3.draw(l14); + canvas3.draw(l16); canvas3.draw(l17); + canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); + canvas3.cd(++ic); canvas3.draw(hOccupancy2); + canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); + canvas3.draw(l4); + canvas3.draw(l6); + canvas3.draw(l8); canvas3.draw(l9); + canvas3.draw(l10); canvas3.draw(l11); + canvas3.draw(l12); + canvas3.draw(l14); + canvas3.draw(l16); canvas3.draw(l17); + canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); + canvas3.cd(++ic); canvas3.draw(hOccupancy3); + canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); + canvas3.draw(l4); + canvas3.draw(l6); + canvas3.draw(l8); canvas3.draw(l9); + canvas3.draw(l10); canvas3.draw(l11); + canvas3.draw(l12); + canvas3.draw(l14); + canvas3.draw(l16); + canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); + canvas3.cd(++ic); canvas3.draw(hOccupancy4); + canvas3.draw(l1); canvas3.draw(l2); canvas3.draw(l3); + canvas3.draw(l4); + canvas3.draw(l6); + canvas3.draw(l8); canvas3.draw(l9); + canvas3.draw(l10); canvas3.draw(l11); + canvas3.draw(l12); + canvas3.draw(l14); + canvas3.draw(l16); + canvas3.draw(l18); canvas3.draw(l19); canvas3.draw(l20); + frame3.add(canvas3); + frame3.setLocationRelativeTo(null); + frame3.setVisible(true); + + } +} + + + From a931bf399f1be9773ef22cc2c0f052e25be5cb27 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sat, 26 Feb 2022 16:47:33 +0100 Subject: [PATCH 087/104] add new methods for DetectorType definition --- .../org/jlab/detector/base/DetectorType.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java index d773505bbd..385c56ad67 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java @@ -47,6 +47,28 @@ public enum DetectorType { detectorId = id; detectorName = name; } + + DetectorType(String name){ + detectorName = name; + int i = -1; + for(DetectorType det: DetectorType.values()){ + i++; + if(det.getName().equalsIgnoreCase(name)) break; + } + detectorId = i; + } + + DetectorType(int id){ + detectorId = id; + String name = "UNDEFINED"; + for(DetectorType det: DetectorType.values()){ + name = det.getName(); + if(det.getName().equalsIgnoreCase(name)) break; + } + detectorName = name; + } + + /** * Returns the name of the detector. * @return the name of the detector From ed031a663314447b4901296d84e168f86263a6d7 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sat, 26 Feb 2022 16:48:44 +0100 Subject: [PATCH 088/104] use DetectorType as private instead of String, add new definition methods --- .../main/java/org/jlab/rec/ft/FTResponse.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java index 578f0432be..dc2769dedd 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java @@ -7,6 +7,7 @@ import org.jlab.clas.detector.DetectorResponse; import org.jlab.detector.base.DetectorLayer; +import org.jlab.detector.base.DetectorType; /** * @@ -14,7 +15,8 @@ */ public class FTResponse extends DetectorResponse { - private String _type; // FTCAL, FTHODO, FTTRK + //private String _type; // FTCAL, FTHODO, FTTRK + private DetectorType _type; private int _size; // cluster multiplicity private int _id; // response ID private int _trkDet; // number of TRK detector (0,1) @@ -24,6 +26,7 @@ public class FTResponse extends DetectorResponse { public FTResponse() { } + /* public FTResponse(String type) { this._type = type; } @@ -35,6 +38,23 @@ public String getType() { public void setType(String type) { this._type = type; } + */ + + public FTResponse(DetectorType type) { + this._type = type; + } + + public DetectorType getType() { + return _type; + } + + public void setType(String type) { + this._type.getType(type); + } + + public void setType(DetectorType type) { + this._type = type; + } public int getSize() { return _size; From b3212a0110d24b2f88d43d35512123df01d84031 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sat, 26 Feb 2022 16:49:36 +0100 Subject: [PATCH 089/104] use DetectorType types instead of Strings to identify detectors --- .../main/java/org/jlab/rec/ft/FTParticle.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index a779af1e91..c82480c6ec 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -5,6 +5,7 @@ import java.util.List; import org.jlab.clas.pdg.PhysicsConstants; import org.jlab.detector.base.DetectorLayer; +import org.jlab.detector.base.DetectorType; import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Vector3D; import org.jlab.utils.groups.IndexedTable; @@ -147,7 +148,7 @@ public void setTrackerIndex(int _Cross, int ndet) { } - public int getDetectorHit(List hitList, String detectorType, double distanceThreshold, double timeThreshold){ + public int getDetectorHit(List hitList, DetectorType detectorType, double distanceThreshold, double timeThreshold){ Line3D cross = this.getLastCross(); double minimumDistance = 500.0; int bestIndex = -1; @@ -158,7 +159,7 @@ public int getDetectorHit(List hitList, String detectorType, double double hitdistance = dist.length(); double timedistance = Math.abs(this.getTime() - (response.getTime()-response.getPosition().mag()/PhysicsConstants.speedOfLight())); if(hitdistance=1){ @@ -166,7 +167,7 @@ public int getDetectorHit(List hitList, String detectorType, double System.out.println("cross center coordinates x, y " + response.getPosition().toPoint3D().x() + " , " + response.getPosition().toPoint3D().y()); } - }else if(detectorType=="FTHODO" && timedistance hitList, String detectorType, double } if(bestIndex>-1) { // if bestHit is on hodo require at least two hits overall on HODO - if(detectorType=="HODO"){if(hitList.get(bestIndex).getSize()= FTConstants.TRK_MIN_CROSS_NUMBER){;}else{bestIndex=-1;} } } @@ -192,7 +193,7 @@ public int[] getTRKBestHits(List hitList, int it, double distanceTh for(int loop = 0; loop < hitList.size(); loop++){ int bestidx = -1; FTResponse response = hitList.get(loop); - if(response.getAssociation()<0 && response.getType() == "FTTRK"){ + if(response.getAssociation()<0 && response.getType().getName() == "FTTRK"){ Line3D dist = cross.distance(response.getPosition().toPoint3D()); double hitdistance = dist.length(); double timedistance = Math.abs(this.getTime() - (response.getTime()-response.getPosition().mag()/PhysicsConstants.speedOfLight())); @@ -225,7 +226,7 @@ public int[] getTRKBestHits(List hitList, int it, double distanceTh int ndetectors = FTTRKConstantsLoader.NSupLayers; int hitsTRK = 0; for(int l=0; l hitList, int it, double distanceTh for(int loop = 0; loop < hitList.size(); loop++){ int bestidx = -1; FTResponse response = hitList.get(loop); - if(response.getAssociation()<0 && response.getType() == "FTTRK"){ + if(response.getAssociation()<0 && response.getType().getName() == "FTTRK"){ lTRK++; hitDistancesDet0.add(lTRK, -1.); hitDistancesDet1.add(lTRK, -1.); From d46d3f8c8efe3f7831610766d3450f7b789a4679 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sat, 26 Feb 2022 16:49:45 +0100 Subject: [PATCH 090/104] use DetectorType types instead of Strings to identify detectors --- .../java/org/jlab/rec/ft/FTEventBuilder.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index 1430d195d5..a7fcdbfa22 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -13,6 +13,7 @@ import org.jlab.rec.ft.cal.FTCALConstantsLoader; import org.jlab.utils.groups.IndexedTable; import org.jlab.rec.ft.trk.FTTRKConstantsLoader; +import org.jlab.detector.base.DetectorType; public class FTEventBuilder { @@ -54,7 +55,7 @@ public List addResponses(DataEvent event, ConstantsManager manager, EvioDataBank bank = (EvioDataBank) event.getBank("FTCALRec::clusters"); int nrows = bank.rows(); for (int i = 0; i < nrows; i++) { - FTResponse resp = new FTResponse("FTCAL"); + FTResponse resp = new FTResponse(DetectorType.FTCAL); resp.setAssociation(-1); resp.setSize(bank.getInt("clusSize", i)); resp.setId(bank.getInt("clusID", i)); @@ -69,7 +70,7 @@ public List addResponses(DataEvent event, ConstantsManager manager, DataBank bank = event.getBank("FTTRK::crosses"); int nrows = bank.rows(); for (int i = 0; i < nrows; i++) { - FTResponse resp = new FTResponse("FTTRK"); + FTResponse resp = new FTResponse(DetectorType.FTTRK); resp.setAssociation(-1); resp.setSize(bank.getInt("size", i)); resp.setId(bank.getInt("id", i)); @@ -86,7 +87,7 @@ public List addResponses(DataEvent event, ConstantsManager manager, EvioDataBank bank = (EvioDataBank) event.getBank("FTHODORec::clusters"); int nrows = bank.rows(); for (int i = 0; i < nrows; i++) { - FTResponse resp = new FTResponse("FTHODO"); + FTResponse resp = new FTResponse(DetectorType.FTHODO); resp.setSize(bank.getInt("clusterSize", i)); resp.setId(bank.getInt("clusterID", i)); resp.setEnergy(bank.getDouble("clusterEnergy", i)); @@ -100,7 +101,7 @@ public List addResponses(DataEvent event, ConstantsManager manager, DataBank bank = event.getBank("FTCAL::clusters"); int nrows = bank.rows(); for (int i = 0; i < nrows; i++) { - FTResponse resp = new FTResponse("FTCAL"); + FTResponse resp = new FTResponse(DetectorType.FTCAL); resp.setAssociation(-1); resp.setSize(bank.getInt("size", i)); resp.setId(bank.getInt("id", i)); @@ -114,7 +115,7 @@ public List addResponses(DataEvent event, ConstantsManager manager, DataBank bank = event.getBank("FTHODO::clusters"); int nrows = bank.rows(); for (int i = 0; i < nrows; i++) { - FTResponse resp = new FTResponse("FTHODO"); + FTResponse resp = new FTResponse(DetectorType.FTHODO); resp.setAssociation(-1); resp.setSize(bank.getInt("size", i)); resp.setId(bank.getInt("id", i)); @@ -130,7 +131,7 @@ public List addResponses(DataEvent event, ConstantsManager manager, DataBank bank = event.getBank("FTTRK::crosses"); int nrows = bank.rows(); for (int i = 0; i < nrows; i++) { - FTResponse resp = new FTResponse("FTTRK"); + FTResponse resp = new FTResponse(DetectorType.FTTRK); resp.setAssociation(-1); resp.setSize(bank.getInt("size", i)); resp.setId(bank.getInt("id", i)); @@ -172,7 +173,7 @@ public List initFTparticles(List responses) { List particles = new ArrayList(); // this.FTparticles.clear(); for (int i = 0; i < responses.size(); i++) { - if (responses.get(i).getType() == "FTCAL") { + if (responses.get(i).getType().getName() == "FTCAL") { FTParticle track = new FTParticle(i); // start assuming the cluster to be associated to a photon PROVISIONAL to be updated with correct charge (if possible) track.setCharge(0); @@ -203,7 +204,7 @@ public void matchToHODO(List responses, List particles) if (debugMode >= 1) { System.out.println("Searching for matching signal in the hodoscope:"); } - int iHodo = track.getDetectorHit(responses, "FTHODO", FTConstants.CAL_HODO_DISTANCE_MATCHING, FTConstants.CAL_HODO_TIME_MATCHING); + int iHodo = track.getDetectorHit(responses, DetectorType.FTHODO, FTConstants.CAL_HODO_DISTANCE_MATCHING, FTConstants.CAL_HODO_TIME_MATCHING); if (iHodo > 0) { if (debugMode >= 1) { System.out.println("found signal in the hodoscope " + iHodo); @@ -252,7 +253,7 @@ public void matchToFTCal(List responses, List particles) for (int i = 0; i < particles.size(); i++) { FTParticle track = particles.get(i); - int iHodo = track.getDetectorHit(responses, "FTHODO", FTConstants.CAL_HODO_DISTANCE_MATCHING, FTConstants.CAL_HODO_TIME_MATCHING); + int iHodo = track.getDetectorHit(responses, DetectorType.FTHODO, FTConstants.CAL_HODO_DISTANCE_MATCHING, FTConstants.CAL_HODO_TIME_MATCHING); if (iHodo > 0) { if (debugMode >= 1) { System.out.println("found signal in the hodoscope " + iHodo); @@ -262,7 +263,7 @@ public void matchToFTCal(List responses, List particles) responses.get(iHodo).setAssociation(i); } - int iTrk = track.getDetectorHit(responses, "FTTRK", FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); + int iTrk = track.getDetectorHit(responses, DetectorType.FTTRK, FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); if (iTrk > 0) { if (debugMode >= 1) { System.out.println("found signal in FTTRK" + iTrk); From a39130ebd90c36eb414cb8448f6c78bb973d4ee9 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 27 Feb 2022 10:20:26 +0100 Subject: [PATCH 091/104] cleanup --- .../src/main/java/org/jlab/detector/base/DetectorLayer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorLayer.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorLayer.java index 1641018fe6..5001ac37ea 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorLayer.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorLayer.java @@ -40,6 +40,5 @@ public class DetectorLayer { public static final byte FTTRK_LAYER3=3; public static final byte FTTRK_LAYER4=4; - } From e806f80d5f165141a1be58039b6e94089bf0a1ea Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 27 Feb 2022 10:21:25 +0100 Subject: [PATCH 092/104] use of DetectorLayer byte to identify the response, add a new setter --- .../main/java/org/jlab/rec/ft/FTResponse.java | 46 ++++--------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java index dc2769dedd..aa6fa06d17 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java @@ -14,31 +14,15 @@ * @author devita */ public class FTResponse extends DetectorResponse { - - //private String _type; // FTCAL, FTHODO, FTTRK - private DetectorType _type; + + private DetectorType _type; // FTCAL, FTHODO, FTTRK private int _size; // cluster multiplicity - private int _id; // response ID + private int _id; // response ID (ordinal number of hit) private int _trkDet; // number of TRK detector (0,1) - //private DetectorLayer _trkLayer; // number of TRK detector+1 - - public FTResponse() { - } - /* - public FTResponse(String type) { - this._type = type; - } - - public String getType() { - return _type; - } - - public void setType(String type) { - this._type = type; + public FTResponse() { } - */ public FTResponse(DetectorType type) { this._type = type; @@ -72,32 +56,22 @@ public void setId(int id) { this._id = id; } - public int getTrkDet() { return _trkDet; } - - public void setTrkDet(int ndet) { - this._trkDet = ndet; - } - - /* - public DetectorLayer getTrkDet() { - if(this._id == 0){ - this._trkDet = DetectorLayer.FTTRK_MODULE1; - }else if(this._id == 1){ - this._trkDet = DetectorLayer.FTTRK_MODULE1; + public void setTrkDet(byte layer) { + // if the name of the module is passed it is a byte variable + if(layer == DetectorLayer.FTTRK_MODULE1){ + this._trkDet = 0; + }else if(layer == DetectorLayer.FTTRK_MODULE2){ + this._trkDet = 1; } - return _trkDet; } - public void setTrkDet(int ndet) { this._trkDet = ndet; } - */ - public void show() { System.out.println("ID = "+ this.getId() From 92e3390ec270ec2df7c1da4bad0064782449a80a Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 27 Feb 2022 10:22:11 +0100 Subject: [PATCH 093/104] use of DetectorLayer byte to set the detector response --- .../src/main/java/org/jlab/rec/ft/FTEventBuilder.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index a7fcdbfa22..4fc2609d51 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -126,8 +126,10 @@ public List addResponses(DataEvent event, ConstantsManager manager, } } if (event.hasBank("FTTRK::crosses") == true) { - int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; // tracker id=0 - int TRK2 = DetectorLayer.FTTRK_MODULE2 - 1; // tracker id=1 + int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; // module1, tracker id=0 (int index for loops) + int TRK2 = DetectorLayer.FTTRK_MODULE2 - 1; // module2, tracker id=1 + byte bytTRK1 = DetectorLayer.FTTRK_MODULE1; // module1, trkid=0 + byte bytTRK2 = DetectorLayer.FTTRK_MODULE2; // module2, trkid=1 DataBank bank = event.getBank("FTTRK::crosses"); int nrows = bank.rows(); for (int i = 0; i < nrows; i++) { @@ -141,9 +143,9 @@ public List addResponses(DataEvent event, ConstantsManager manager, double zCoord = bank.getFloat("z", i); if(zCoord >= FTTRKConstantsLoader.Zlayer[TRK1] && zCoord <= FTTRKConstantsLoader.Zlayer[TRK2]){ - resp.setTrkDet(TRK1); + resp.setTrkDet(bytTRK1); }else{ - resp.setTrkDet(TRK2); + resp.setTrkDet(bytTRK2); } if(debugMode>=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); From 6de3bb16392bd2e3b03446dfe7a2ceaf42fa1f3c Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 27 Feb 2022 12:15:46 +0100 Subject: [PATCH 094/104] move constants definitions to init method --- .../jlab/rec/ft/trk/FTTRKReconstruction.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index 970247c3a5..0491766c0f 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -32,13 +32,12 @@ public class FTTRKReconstruction { public static int NStripsSectors = 20; public static int stripsInLongSector = 64; public static int stripsInShortSector = 32; - public static int sideShortStrips = 2*FTTRKConstantsLoader.SideHalfstrips; // 256 - public static int sequentialStrips = FTTRKConstantsLoader.Longstrips + FTTRKConstantsLoader.SideHalfstrips + sideShortStrips; // 512 - public static int stripDiscontinuity1 = FTTRKConstantsLoader.Longstrips; // 128 CHECK DISCONTINUITIES +- 1 strip - public static int stripDiscontinuity2 = FTTRKConstantsLoader.Longstrips + sideShortStrips + 1; // 385 - public static int stripDiscontinuity3 = sequentialStrips + FTTRKConstantsLoader.SideHalfstrips; // 640 - public static int stripDiscontinuity4 = stripDiscontinuity3+1; - + public static int sideShortStrips; // 256 + public static int sequentialStrips; // 512 + public static int stripDiscontinuity1; // 128 CHECK DISCONTINUITIES +- 1 strip + public static int stripDiscontinuity2; // 385 + public static int stripDiscontinuity3; // 640 + public static int stripDiscontinuity4; // 641 public FTTRKReconstruction() { } @@ -51,6 +50,13 @@ public List initFTTRK(DataEvent event, ConstantsManager manager, int r IndexedTable trkGeo = manager.getConstants(run, "/geometry/ft/fttrk"); */ + sideShortStrips = 2*FTTRKConstantsLoader.SideHalfstrips; // 256 + sequentialStrips = FTTRKConstantsLoader.Longstrips + FTTRKConstantsLoader.SideHalfstrips + sideShortStrips; // 512 + stripDiscontinuity1 = FTTRKConstantsLoader.Longstrips; // 128 CHECK DISCONTINUITIES +- 1 strip + stripDiscontinuity2 = FTTRKConstantsLoader.Longstrips + sideShortStrips + 1; // 385 + stripDiscontinuity3 = sequentialStrips + FTTRKConstantsLoader.SideHalfstrips; // 640 + stripDiscontinuity4 = stripDiscontinuity3+1; + if(debugMode>=1) System.out.println("\nAnalyzing new event"); List allhits = null; From 1e54917fbfdc9f2de27f20b92500a65e28e0e322 Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Sun, 27 Feb 2022 15:47:33 +0100 Subject: [PATCH 095/104] cleanup diagnostic histograms --- .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 25 +++---------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java index fbe8d8bc33..4b228aa0e9 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKEngine.java @@ -177,15 +177,11 @@ public static void main (String arg[]) { JFrame frameClusters = new JFrame("FT strips in clusters"); frameClusters.setSize(800,800); EmbeddedCanvas canvasCl = new EmbeddedCanvas(); - JFrame frameClustersSingleLay = new JFrame("FT strips in clusters single layers"); - frameClustersSingleLay.setSize(800,800); - EmbeddedCanvas canvasClSingleLay = new EmbeddedCanvas(); - canvasClSingleLay.divide(2,2); int nc1 = 0, nc2 = 0, ncmatch = 0; int nev=0; -// while(reader.hasEvent()){ - int nev1 = 0; int nev2 = 20000; for(nev=nev1; nev=1) System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~ processing event ~~~~~~~~~~~ " + nev); @@ -244,24 +240,13 @@ public static void main (String arg[]) { default: } } - // strip number correposponding to the max energy release - maxcomp1 = bank.getShort("component", imax1); - maxcomp2 = bank.getShort("component", imax2); - maxcomp3 = bank.getShort("component", imax3); - maxcomp4 = bank.getShort("component", imax4); } - + canvasCl.draw(hHitL1); // dummy histogram // iterate along the cluster list for every event if(debug>=1) System.out.println("clusters size --- " + clusters.size()); if(clusters.size()!=0){ // get one cluster and iterate over all the strips contained in it - canvasCl.cd(1); canvasCl.draw(hHitL1); - for(int l=0; l Date: Sun, 27 Feb 2022 16:10:24 +0100 Subject: [PATCH 096/104] fix output histograms --- .../test/java/org/jlab/service/ft/FTTRKEngineTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/reconstruction/ft/src/test/java/org/jlab/service/ft/FTTRKEngineTest.java b/reconstruction/ft/src/test/java/org/jlab/service/ft/FTTRKEngineTest.java index 53179288ec..0023082b20 100644 --- a/reconstruction/ft/src/test/java/org/jlab/service/ft/FTTRKEngineTest.java +++ b/reconstruction/ft/src/test/java/org/jlab/service/ft/FTTRKEngineTest.java @@ -209,9 +209,9 @@ public static void main (String arg[]) { int nc1 = 0, nc2 = 0, ncmatch = 0; int nev=0; int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; - int TRK2 = DetectorLayer.FTTRK_MODULE1 - 2; + int TRK2 = DetectorLayer.FTTRK_MODULE2 - 1; while(reader.hasEvent()){ -// int nev1 = 0; int nev2 = 10000; for(nev=nev1; nev=1) System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~ processing event ~~~~~~~~~~~ " + nev); // if(nev != 8) continue; // select one event only for debugging purposes @@ -292,11 +292,13 @@ public static void main (String arg[]) { if(debug>=1) System.out.println("clusters size --- " + clusters.size()); if(clusters.size()!=0){ // get one cluster and iterate over all the strips contained in it - canvasCl.cd(1); canvasCl.draw(hHitL1); + // draw dummy histograms to be superimposed with strips + canvasCl.cd(1); canvasCl.draw(hHitMatch); for(int l=0; l Date: Wed, 27 Apr 2022 12:12:54 +0200 Subject: [PATCH 097/104] remove redundant class constructor --- .../org/jlab/detector/base/DetectorType.java | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java index 385c56ad67..f2ce38ae5b 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java @@ -48,27 +48,6 @@ public enum DetectorType { detectorName = name; } - DetectorType(String name){ - detectorName = name; - int i = -1; - for(DetectorType det: DetectorType.values()){ - i++; - if(det.getName().equalsIgnoreCase(name)) break; - } - detectorId = i; - } - - DetectorType(int id){ - detectorId = id; - String name = "UNDEFINED"; - for(DetectorType det: DetectorType.values()){ - name = det.getName(); - if(det.getName().equalsIgnoreCase(name)) break; - } - detectorName = name; - } - - /** * Returns the name of the detector. * @return the name of the detector From 229c3e930b1a3a5cde4c7c8acecd8a6bdc5a352e Mon Sep 17 00:00:00 2001 From: Alessandra Filippi Date: Wed, 27 Apr 2022 12:15:43 +0200 Subject: [PATCH 098/104] remove redundant getter (String instead of DetectorType) --- .../ft/src/main/java/org/jlab/rec/ft/FTResponse.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java index aa6fa06d17..cdc0d22de0 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTResponse.java @@ -31,10 +31,6 @@ public FTResponse(DetectorType type) { public DetectorType getType() { return _type; } - - public void setType(String type) { - this._type.getType(type); - } public void setType(DetectorType type) { this._type = type; From 62aca160888912542c8c99505b62f055c2d3c497 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Tue, 17 May 2022 11:11:50 +0200 Subject: [PATCH 099/104] FT: fix unit test to account for recent merge --- .../ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reconstruction/ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java b/reconstruction/ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java index 22684b715c..ac71e999d9 100644 --- a/reconstruction/ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java +++ b/reconstruction/ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java @@ -107,7 +107,7 @@ public boolean processDataEvent(DataEvent event) { if (run>=0) { reco.init(this.getSolenoid()); FTresponses = reco.addResponses(event, this.getConstantsManager(), run); - FTparticles = reco.initFTparticles(FTresponses); + FTparticles = reco.initFTparticles(FTresponses, this.getConstantsManager(), run); if(FTparticles.size()>0){ reco.matchToTRKTwoDetectorsMultiHits(FTresponses, FTparticles); reco.matchToHODO(FTresponses, FTparticles); From ef09c7bdaeda7a87de56dd74e191cdc98fbc3e4c Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Mon, 6 Jun 2022 16:29:05 +0200 Subject: [PATCH 100/104] FTCal code cleanip --- .../org/jlab/rec/ft/cal/FTCALCluster.java | 5 - .../jlab/rec/ft/cal/FTCALConstantsLoader.java | 213 +----------------- .../java/org/jlab/rec/ft/cal/FTCALEngine.java | 1 - .../java/org/jlab/rec/ft/cal/FTCALHit.java | 14 +- .../jlab/rec/ft/cal/FTCALReconstruction.java | 80 +------ 5 files changed, 17 insertions(+), 296 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALCluster.java index c2df400793..b7e09cbd53 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALCluster.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALCluster.java @@ -48,11 +48,6 @@ public double getFullEnergy(IndexedTable energyTable) { // return energy corrected for leakage and threshold effects double clusterEnergy = this.getEnergy(); int seedID = this.get(0).get_COMPONENT(); -// double energyCorr = FTCALConstantsLoader.energy_corr[0] -// + FTCALConstantsLoader.energy_corr[1]*clusterEnergy -// + FTCALConstantsLoader.energy_corr[2]*clusterEnergy*clusterEnergy -// + FTCALConstantsLoader.energy_corr[3]*clusterEnergy*clusterEnergy*clusterEnergy -// + FTCALConstantsLoader.energy_corr[4]*clusterEnergy*clusterEnergy*clusterEnergy*clusterEnergy; double energyCorr = (energyTable.getDoubleValue("c0",1,1,seedID) + energyTable.getDoubleValue("c1",1,1,seedID)*clusterEnergy + energyTable.getDoubleValue("c2",1,1,seedID)*clusterEnergy*clusterEnergy diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALConstantsLoader.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALConstantsLoader.java index fa27ad10c5..3fc33b23bf 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALConstantsLoader.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALConstantsLoader.java @@ -1,228 +1,21 @@ package org.jlab.rec.ft.cal; -import org.jlab.detector.calib.utils.DatabaseConstantProvider; - public class FTCALConstantsLoader { public FTCALConstantsLoader() { } - public static int debugMode = 0; - public static boolean CSTLOADED = false; - - /* - // BANK TAG and NUMS statics : - // Reco tag - public static final int HITTAG = 911; - public static final int CLUSTERTAG = 912; - - // Gemc tag&nums - public static final int TAG = 901; - public static final int EDEP_NUM = 7; - public static final int E_NUM = 6; - public static final int TIME_NUM = 23; - public static final int PID_NUM = 1; - public static final int X_NUM = 8; - public static final int Y_NUM = 9; - public static final int Z_NUM = 10; - - public static final int TAG = 902; - public static final int IDX_NUM = 1; - public static final int IDY_NUM = 2; - public static final int ADC_NUM = 3; - public static final int TDC_NUM = 4; - - */ -// // HIT CONVERSION CONSTANTS -// public static double[][][] mips_charge = new double[1][1][484]; -// public static double[][][] mips_energy = new double[1][1][484]; -// public static double[][][] fadc_to_charge = new double[1][1][484]; -// public static double[][][] time_offset = new double[1][1][484]; -// public static int[][][] status = new int[1][1][484]; + public static int DEBUGMODE = 0; // RECONSTRUCTION CONSTANTS public static final double TIMECONVFAC = 100./4.; // conversion factor from TDC channel to time (ns^-1) public static final double VEFF = 150.; // speed of light in the scintillator mm/ns -// // CLUSTER RECONSTRUCTION PARAMETERS -// public static double seed_min_energy; // minimum cluster reconstructed energy -// public static double cluster_min_energy; // minimum number of crystals in a cluster -// public static int cluster_min_size; // minimum number of crystals in a cluster -// public static double time_window; // time window of hits forming a cluster -// public static double w0; // time window of hits forming a cluster -// public static double depth_z; // time window of hits forming a cluster -// -// // CONSTANTS USED IN CORRECTIONS -// public static double[] energy_corr = new double[5] ; -// public static double[] theta_corr = new double[4] ; -// public static double[] phi_corr = new double[6] ; -// public static double[][][] c0 = new double[1][1][484]; -// public static double[][][] c1 = new double[1][1][484]; -// public static double[][][] c2 = new double[1][1][484]; -// public static double[][][] c3 = new double[1][1][484]; -// public static double[][][] c4 = new double[1][1][484]; - -// public static int MAX_CLUS_RAD =3 ; // maximum radius of the cluster in # of crystals -// public static double EN_THRES = 0.01; // energy threshold in GeV - // GEOMETRY PARAMETERS + // energy threshold in GeV + // GEOMETRY PARAMETERS public static double CRYS_DELTA = 11.5; public static double CRYS_WIDTH = 15.3; // crystal width in mm public static double CRYS_LENGTH = 200.; // crystal length in mm public static double CRYS_ZPOS = 1898.; // position of the crystal front face - -// static DatabaseConstantProvider dbprovider = null; -// -// public static synchronized void Load(int runno, String var) { -// -// System.out.println(" LOADING CONSTANTS "); -//// if (CSTLOADED == true) -//// return null; -// dbprovider = new DatabaseConstantProvider(runno, var); // reset using the new variation -// -// -// // load table reads entire table and makes an array of variables for each column in the table. -// dbprovider.loadTable("/calibration/ft/ftcal/charge_to_energy"); -// dbprovider.loadTable("/calibration/ft/ftcal/time_offsets"); -// dbprovider.loadTable("/calibration/ft/ftcal/status"); -// dbprovider.loadTable("/calibration/ft/ftcal/cluster"); -// dbprovider.loadTable("/calibration/ft/ftcal/phicorr"); -// dbprovider.loadTable("/calibration/ft/ftcal/thetacorr"); -// dbprovider.loadTable("/calibration/ft/ftcal/energycorr"); -// //disconnect from database. Important to do this after loading tables. -// dbprovider.disconnect(); -// -// dbprovider.show(); -// -// // Getting the Timing Constants -// // 1) Charge to Energy Conversion: MIPS_CHARGE, MIPS_ENERGY, FADC_TO_CHARGE -// for(int i =0; i< dbprovider.length("/calibration/ft/ftcal/charge_to_energy/mips_charge"); i++) { -// -// int iSec = dbprovider.getInteger("/calibration/ft/ftcal/charge_to_energy/sector", i); -// int iLay = dbprovider.getInteger("/calibration/ft/ftcal/charge_to_energy/layer", i); -// int iCom = dbprovider.getInteger("/calibration/ft/ftcal/charge_to_energy/component", i); -// double imips_charge = dbprovider.getDouble("/calibration/ft/ftcal/charge_to_energy/mips_charge", i); -// double imips_energy = dbprovider.getDouble("/calibration/ft/ftcal/charge_to_energy/mips_energy", i); -// double ifadc2charge = dbprovider.getDouble("/calibration/ft/ftcal/charge_to_energy/fadc_to_charge", i); -// -// mips_charge[iSec-1][iLay-1][iCom-1] = imips_charge; -// mips_energy[iSec-1][iLay-1][iCom-1] = imips_energy; -// fadc_to_charge[iSec-1][iLay-1][iCom-1] = ifadc2charge; -// if(debugMode>=1) System.out.println("energy_to_charge table: " + iCom + " " + imips_charge + " " + imips_energy + " " + ifadc2charge); -// } -// // 2) Offsets : TIME_OFFSET -// for(int i =0; i< dbprovider.length("/calibration/ft/ftcal/time_offsets/time_offset"); i++) { -// -// int iSec = dbprovider.getInteger("/calibration/ft/ftcal/time_offsets/sector", i); -// int iLay = dbprovider.getInteger("/calibration/ft/ftcal/time_offsets/layer", i); -// int iCom = dbprovider.getInteger("/calibration/ft/ftcal/time_offsets/component", i); -// double ioffset = dbprovider.getDouble("/calibration/ft/ftcal/time_offsets/time_offset", i); -// -// time_offset[iSec-1][iLay-1][iCom-1] = ioffset; -// if(debugMode>=1) System.out.println("time_offset: " + iCom + " " + ioffset ); -// } -// // 3) Status : STATUS -// for(int i =0; i< dbprovider.length("/calibration/ft/ftcal/status/status"); i++) { -// -// int iSec = dbprovider.getInteger("/calibration/ft/ftcal/status/sector", i); -// int iLay = dbprovider.getInteger("/calibration/ft/ftcal/status/layer", i); -// int iCom = dbprovider.getInteger("/calibration/ft/ftcal/status/component", i); -// int istatus = dbprovider.getInteger("/calibration/ft/ftcal/status/status", i); -// -// status[iSec-1][iLay-1][iCom-1] = istatus; -// if(debugMode>=1) System.out.println("status: " + iCom + " " + istatus ); -// } -// // 4) Cluster Reconstruction Parameters : CLUSTER -// for(int i =0; i< dbprovider.length("/calibration/ft/ftcal/cluster/seed_min_energy"); i++) { -// -// int iSec = dbprovider.getInteger("/calibration/ft/ftcal/cluster/sector", i); -// int iLay = dbprovider.getInteger("/calibration/ft/ftcal/cluster/layer", i); -// int iCom = dbprovider.getInteger("/calibration/ft/ftcal/cluster/component", i); -// double iseed = dbprovider.getDouble("/calibration/ft/ftcal/cluster/seed_min_energy", i); -// double icluster = dbprovider.getDouble("/calibration/ft/ftcal/cluster/cluster_min_energy", i); -// int isize = dbprovider.getInteger("/calibration/ft/ftcal/cluster/cluster_min_size", i); -// double itime = dbprovider.getDouble("/calibration/ft/ftcal/cluster/time_window", i); -// double iw0 = dbprovider.getDouble("/calibration/ft/ftcal/cluster/w0", i); -// double idepth = dbprovider.getDouble("/calibration/ft/ftcal/cluster/depth_z", i); -// -// seed_min_energy = iseed/1000.; -// cluster_min_energy = icluster/1000.; -// cluster_min_size = isize; -// time_window = itime; -// w0 = iw0; -// depth_z = idepth; -// if(debugMode>=1) System.out.println("cluster table: " + time_window + " " + cluster_min_energy + " " + cluster_min_size + " " + depth_z); -// } -// // 5) OLD Energy Corrections : ECORR -// energy_corr[0] = 0.0587502; -// energy_corr[1] = 0.0881192; -// energy_corr[2] = -0.0120113; -// energy_corr[3] = 0.00131961; -// energy_corr[4] = -0.0000550674; -// -// // 6) Theta Corrections : THETACORR -// for(int i =0; i< dbprovider.length("/calibration/ft/ftcal/thetacorr/thetacorr0"); i++) { -// -// int iSec = dbprovider.getInteger("/calibration/ft/ftcal/thetacorr/sector", i); -// int iLay = dbprovider.getInteger("/calibration/ft/ftcal/thetacorr/layer", i); -// int iCom = dbprovider.getInteger("/calibration/ft/ftcal/thetacorr/component", i); -// double thetacorr0 = dbprovider.getDouble("/calibration/ft/ftcal/thetacorr/thetacorr0", i); -// double thetacorr1 = dbprovider.getDouble("/calibration/ft/ftcal/thetacorr/thetacorr1", i); -// double thetacorr2 = dbprovider.getDouble("/calibration/ft/ftcal/thetacorr/thetacorr2", i); -// double thetacorr3 = dbprovider.getDouble("/calibration/ft/ftcal/thetacorr/thetacorr3", i); -// -// theta_corr[0] = thetacorr0; -// theta_corr[1] = thetacorr1; -// theta_corr[2] = thetacorr2; -// theta_corr[3] = thetacorr3; -// if(debugMode>=1) System.out.println("theta correction: " + thetacorr0 + " " + thetacorr1 + " " + thetacorr2 + " " + thetacorr3 ); -// } -// // 7) Phi Corrections : PHICORR -// for(int i =0; i< dbprovider.length("/calibration/ft/ftcal/phicorr/phicorr0"); i++) { -// -// int iSec = dbprovider.getInteger("/calibration/ft/ftcal/phicorr/sector", i); -// int iLay = dbprovider.getInteger("/calibration/ft/ftcal/phicorr/layer", i); -// int iCom = dbprovider.getInteger("/calibration/ft/ftcal/phicorr/component", i); -// double phicorr0 = dbprovider.getDouble("/calibration/ft/ftcal/phicorr/phicorr0", i); -// double phicorr1 = dbprovider.getDouble("/calibration/ft/ftcal/phicorr/phicorr1", i); -// double phicorr2 = dbprovider.getDouble("/calibration/ft/ftcal/phicorr/phicorr2", i); -// double phicorr3 = dbprovider.getDouble("/calibration/ft/ftcal/phicorr/phicorr3", i); -// double phicorr4 = dbprovider.getDouble("/calibration/ft/ftcal/phicorr/phicorr4", i); -// double phicorr5 = dbprovider.getDouble("/calibration/ft/ftcal/phicorr/phicorr5", i); -// -// phi_corr[0] = phicorr0; -// phi_corr[1] = phicorr1; -// phi_corr[2] = phicorr2; -// phi_corr[3] = phicorr3; -// phi_corr[4] = phicorr4; -// phi_corr[5] = phicorr5; -// if(debugMode>=1) System.out.println("theta correction: " + phicorr0 + " " + phicorr1 + " " + phicorr2 + " " + phicorr3 + " " + phicorr4 + " " + phicorr5); -// } -// // 5) NEW Energy Corrections : ENERGYCORR -// for(int i =0; i< dbprovider.length("/calibration/ft/ftcal/energycorr/c0"); i++) { -// -// int iSec = dbprovider.getInteger("/calibration/ft/ftcal/energycorr/sector", i); -// int iLay = dbprovider.getInteger("/calibration/ft/ftcal/energycorr/layer", i); -// int iCom = dbprovider.getInteger("/calibration/ft/ftcal/energycorr/component", i); -// double ecorr0 = dbprovider.getDouble("/calibration/ft/ftcal/energycorr/c0", i); -// double ecorr1 = dbprovider.getDouble("/calibration/ft/ftcal/energycorr/c1", i); -// double ecorr2 = dbprovider.getDouble("/calibration/ft/ftcal/energycorr/c2", i); -// double ecorr3 = dbprovider.getDouble("/calibration/ft/ftcal/energycorr/c3", i); -// double ecorr4 = dbprovider.getDouble("/calibration/ft/ftcal/energycorr/c4", i); -// -// c0[iSec-1][iLay-1][iCom-1] = ecorr0; -// c1[iSec-1][iLay-1][iCom-1] = ecorr1; -// c2[iSec-1][iLay-1][iCom-1] = ecorr2; -// c3[iSec-1][iLay-1][iCom-1] = ecorr3; -// c4[iSec-1][iLay-1][iCom-1] = ecorr4; -// -// if(debugMode>=1) System.out.println("energy correction: " + ecorr0 + " " + ecorr1 + " " + ecorr2 + " " + ecorr3 + " " + ecorr4); -// } -// -// -// CSTLOADED = true; -// System.out.println("SUCCESSFULLY LOADED FTCAL CALIBRATION CONSTANTS...."); -//// return dbprovider; -// -// } } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java index 33b8e93cf2..cf41a2ef5b 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java @@ -1,6 +1,5 @@ package org.jlab.rec.ft.cal; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALHit.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALHit.java index 27354dd32f..507bdf089c 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALHit.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALHit.java @@ -141,7 +141,7 @@ public double get_Edep() { } - public void set_Edep(double edep) { + public final void set_Edep(double edep) { this._Edep = edep; } @@ -152,7 +152,7 @@ public double get_Time() { } - public void set_Time(double Time) { + public final void set_Time(double Time) { this._Time = Time; } @@ -162,7 +162,7 @@ public double get_Dx() { } - public void set_Dx(double Dx) { + public final void set_Dx(double Dx) { this._Dx = Dx; } @@ -172,7 +172,7 @@ public double get_Dy() { } - public void set_Dy(double Dy) { + public final void set_Dy(double Dy) { this._Dy = Dy; } @@ -182,7 +182,7 @@ public double get_Dz() { } - public void set_Dz(double Dz) { + public final void set_Dz(double Dz) { this._Dz = Dz; } @@ -192,7 +192,7 @@ public int get_DGTZIndex() { } - public void set_DGTZIndex(int _DGTZIndex) { + public final void set_DGTZIndex(int _DGTZIndex) { this._DGTZIndex = _DGTZIndex; } @@ -202,7 +202,7 @@ public int get_ClusID() { } - public void set_ClusID(int _ClusIndex) { + public final void set_ClusID(int _ClusIndex) { this._ClusIndex = _ClusIndex; } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java index 7eea60fa5d..e9e044a9b2 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java @@ -118,21 +118,11 @@ public void selectClusters(List clusters, ConstantsManager manager public void writeBanks(DataEvent event, List hits, List clusters, ConstantsManager manager, int run){ - + IndexedTable energyTable = manager.getConstants(run, "/calibration/ft/ftcal/energycorr"); - - if(event instanceof EvioDataEvent) { - writeEvioBanks(event, hits, clusters, energyTable); - } - else if(event instanceof HipoDataEvent) { - writeHipoBanks(event, hits, clusters, energyTable); - } - } - - private void writeHipoBanks(DataEvent event, List hits, List clusters, IndexedTable energyTable){ // hits banks - if(hits.size()!=0) { + if(!hits.isEmpty()) { DataBank bankHits = event.createBank("FTCAL::hits", hits.size()); if(bankHits==null){ System.out.println("ERROR CREATING BANK : FTCAL::hits"); @@ -147,7 +137,7 @@ private void writeHipoBanks(DataEvent event, List hits, List0 && clusters.get(hits.get(i).get_ClusID()-1).getStatus()) { + if(!clusters.isEmpty() && clusters.get(hits.get(i).get_ClusID()-1).getStatus()) { bankHits.setShort("clusterID",i,(short) hits.get(i).get_ClusID()); } else { @@ -158,12 +148,12 @@ private void writeHipoBanks(DataEvent event, List hits, List selectedClusters = new ArrayList(); for(int i =0; i< clusters.size(); i++) { if(clusters.get(i).getStatus()) selectedClusters.add(clusters.get(i)); } - if(selectedClusters.size()>0) { + if(!selectedClusters.isEmpty()) { DataBank bankCluster = event.createBank("FTCAL::clusters", selectedClusters.size()); if(bankCluster==null){ System.out.println("ERROR CREATING BANK : FTCAL::clusters"); @@ -188,71 +178,16 @@ private void writeHipoBanks(DataEvent event, List hits, List hits, List clusters, IndexedTable energyTable) { - - EvioDataBank bankhits = null; - EvioDataBank bankclust = null; - - // hits banks - if(hits.size()!=0) { - bankhits = (EvioDataBank) event.getDictionary().createBank("FTCALRec::hits",hits.size()); - for(int i=0; i=1) clusters.get(i).show(); - bankclust.setInt("clusID", i,clusters.get(i).getID()); - bankclust.setInt("clusSize", i,clusters.get(i).getSize()); - bankclust.setDouble("clusX",i,clusters.get(i).getX()/10.0); - bankclust.setDouble("clusY",i,clusters.get(i).getY()/10.0); - bankclust.setDouble("clusXX",i,clusters.get(i).getX2()/100.0); - bankclust.setDouble("clusYY",i,clusters.get(i).getY2()/100.0); - bankclust.setDouble("clusSigmaX",i,clusters.get(i).getWidthX()/10.0); - bankclust.setDouble("clusSigmaY",i,clusters.get(i).getWidthY()/10.0); - bankclust.setDouble("clusRadius",i,clusters.get(i).getRadius()/10.0); - bankclust.setDouble("clusTime",i,clusters.get(i).getTime()); - bankclust.setDouble("clusEnergy",i,clusters.get(i).getFullEnergy(energyTable)); - bankclust.setDouble("clusRecEnergy",i,clusters.get(i).getEnergy()); - bankclust.setDouble("clusMaxEnergy",i,clusters.get(i).getSeedEnergy()); - bankclust.setDouble("clusTheta",i,clusters.get(i).getTheta()); - bankclust.setDouble("clusPhi",i,clusters.get(i).getPhi()); - } - - // If there are no clusters, punt here but save the reconstructed hits - if(bankclust!=null) { - event.appendBanks(bankhits,bankclust); - } - else if (bankhits!=null) { - event.appendBank(bankhits); - } - } - } public List readRawHits(DataEvent event, IndexedTable charge2Energy, IndexedTable timeOffsets, IndexedTable timeWalk, IndexedTable cluster) { // getting raw data bank if(debugMode>=1) System.out.println("Getting raw hits from FTCAL:dgtz bank"); - List hits = new ArrayList(); + List hits = new ArrayList<>(); if(event.hasBank("FTCAL::dgtz")==true) { EvioDataBank bankDGTZ = (EvioDataBank) event.getBank("FTCAL::dgtz"); int nrows = bankDGTZ.rows(); for(int row = 0; row < nrows; row++){ - int isector = bankDGTZ.getInt("sector",row); - int ilayer = bankDGTZ.getInt("layer",row); int icomponent = bankDGTZ.getInt("component",row); int adc = bankDGTZ.getInt("ADC",row); int tdc = bankDGTZ.getInt("TDC",row); @@ -269,7 +204,7 @@ public List readRawHitsHipo(DataEvent event, IndexedTable charge2Energ // getting raw data bank if(debugMode>=1) System.out.println("Getting raw hits from FTCAL:adc bank"); - List hits = new ArrayList(); + List hits = new ArrayList<>(); if(event.hasBank("FTCAL::adc")==true) { DataBank bankDGTZ = event.getBank("FTCAL::adc"); int nrows = bankDGTZ.rows(); @@ -277,7 +212,6 @@ public List readRawHitsHipo(DataEvent event, IndexedTable charge2Energ int isector = bankDGTZ.getByte("sector",row); int ilayer = bankDGTZ.getByte("layer",row); int icomponent = bankDGTZ.getShort("component",row); - int iorder = bankDGTZ.getByte("order",row); int adc = bankDGTZ.getInt("ADC",row); float time = bankDGTZ.getFloat("time",row); if(adc!=-1 && time!=-1 && status.getIntValue("status", isector, ilayer, icomponent)==0){ From f0a55238d5dad0861866e79eba98d68f94fce038 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Mon, 6 Jun 2022 16:32:42 +0200 Subject: [PATCH 101/104] FTHodo code cleanup --- .../jlab/rec/ft/cal/FTCALReconstruction.java | 1 - .../org/jlab/rec/ft/hodo/FTHODOCluster.java | 10 +- .../rec/ft/hodo/FTHODOConstantsLoader.java | 124 +----------------- .../org/jlab/rec/ft/hodo/FTHODOEngine.java | 14 +- .../rec/ft/hodo/FTHODOReconstruction.java | 70 +--------- 5 files changed, 19 insertions(+), 200 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java index e9e044a9b2..a1e2a9c6ae 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALReconstruction.java @@ -113,7 +113,6 @@ public void selectClusters(List clusters, ConstantsManager manager clusters.get(i).setStatus(clusterTable); if(debugMode>=1) System.out.println("Setting status for cluster " + i + " " + clusters.get(i).toString()); } - return; } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOCluster.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOCluster.java index 7da3480c24..3d91e9eb45 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOCluster.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOCluster.java @@ -152,8 +152,8 @@ public double getLayerMultiplicity(int ilayer) { } public boolean isgoodCluster() { - if(this.getSize() > FTHODOConstantsLoader.cluster_min_size && - this.getEnergy()> FTHODOConstantsLoader.cluster_min_energy && + if(this.getSize() > FTHODOConstantsLoader.CLUSTER_MIN_SIZE && + this.getEnergy()> FTHODOConstantsLoader.CLUSTER_MIN_ENERGY && this.getLayerMultiplicity(1)>0 && this.getLayerMultiplicity(2)>0) { return true; } @@ -171,9 +171,9 @@ public boolean containsHit(FTHODOHit hit) { // System.out.println("DT: " + tDiff + "(" + FTHODOConstantsLoader.time_window // + ")\t DX: " + xDiff + "(" + FTHODOConstantsLoader.hit_distance // + ")\t DY: " + yDiff + "(" + FTHODOConstantsLoader.hit_distance + ")"); - if(tDiff <= FTHODOConstantsLoader.time_window && - xDiff <= FTHODOConstantsLoader.hit_distance && - yDiff <= FTHODOConstantsLoader.hit_distance) addFlag = true; + if(tDiff <= FTHODOConstantsLoader.TIME_WINDOW && + xDiff <= FTHODOConstantsLoader.HIT_DISTANCE && + yDiff <= FTHODOConstantsLoader.HIT_DISTANCE) addFlag = true; } return addFlag; } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOConstantsLoader.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOConstantsLoader.java index f76f4f23ed..c8765ae2d1 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOConstantsLoader.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOConstantsLoader.java @@ -1,49 +1,12 @@ package org.jlab.rec.ft.hodo; -import org.jlab.detector.calib.utils.DatabaseConstantProvider; - public class FTHODOConstantsLoader { FTHODOConstantsLoader() { } - public static int debugMode = 0; - public static boolean CSTLOADED = false; - - - /* - // BANK TAG and NUMS statics : - // Reco tag - public static final int RECOTAG = 811; - // Gemc tag&nums - public static final int TAG = 801; - public static final int EDEP_NUM = 7; - public static final int E_NUM = 6; - public static final int TIME_NUM = 23; - public static final int PID_NUM = 1; - public static final int X_NUM = 8; - public static final int Y_NUM = 9; - public static final int Z_NUM = 10; - - public static final int TAG = 802; - public static final int TILEID_NUM = 1; - public static final int LAYERID_NUM = 2; - public static final int ADC_NUM = 3; - public static final int TDC_NUM = 4; - - */ - -// // HIT CONVERSION CONSTANTS -// public static double[][][] mips_charge = new double[8][2][20]; -// public static double[][][] mips_energy = new double[8][2][20]; -// public static double[][][] time_offset = new double[8][2][20]; -// public static int[][][] status = new int[8][2][20]; -// -// //GEOMETRY -// public static double[][][] px = new double[8][2][20]; -// public static double[][][] py = new double[8][2][20]; -// public static double[][][] pz = new double[8][2][20]; + public static int DEBUGMODE = 0; // RECONSTRUCTION CONSTANTS public static double TIMECONVFAC = 100./4.; // conversion factor from TDC channel to time (ns^-1) @@ -51,86 +14,9 @@ public class FTHODOConstantsLoader { public static double FADC_TO_CHARGE = 4*0.4884/50.; // CLUSTER RECONSTRUCTION PARAMETERS - public static double cluster_min_energy = 1.; // minimum number of crystals in a cluster in MeV - public static int cluster_min_size = 2; // minimum number of crystals in a cluster - public static double time_window = 8; // time window of hits forming a cluster - public static double hit_distance = 3; // max distance of hits forming a cluster in cm + public static double CLUSTER_MIN_ENERGY = 1.; // minimum number of crystals in a cluster in MeV + public static int CLUSTER_MIN_SIZE = 2; // minimum number of crystals in a cluster + public static double TIME_WINDOW = 8; // time window of hits forming a cluster + public static double HIT_DISTANCE = 3; // max distance of hits forming a cluster in cm -// static DatabaseConstantProvider dbprovider = null; -// -// public static synchronized void Load(int runno, String var) { -// -// System.out.println(" LOADING CONSTANTS "); -//// if (CSTLOADED == true) -//// return null; -// dbprovider = new DatabaseConstantProvider(runno, var); // reset using the new variation -// -// // load table reads entire table and makes an array of variables for each column in the table. -// dbprovider.loadTable("/calibration/ft/fthodo/charge_to_energy"); -// dbprovider.loadTable("/calibration/ft/fthodo/time_offsets"); -// dbprovider.loadTable("/calibration/ft/fthodo/status"); -// dbprovider.loadTable("/geometry/ft/fthodo"); -// //disconnect from database. Important to do this after loading tables. -// dbprovider.disconnect(); -// -// dbprovider.show(); -// -// // Getting the Timing Constants -// // 1) Charge to Energy Conversion: MIPS_CHARGE, MIPS_ENERGY, FADC_TO_CHARGE -// for(int i =0; i< dbprovider.length("/calibration/ft/fthodo/charge_to_energy/mips_charge"); i++) { -// -// int iSec = dbprovider.getInteger("/calibration/ft/fthodo/charge_to_energy/sector", i); -// int iLay = dbprovider.getInteger("/calibration/ft/fthodo/charge_to_energy/layer", i); -// int iCom = dbprovider.getInteger("/calibration/ft/fthodo/charge_to_energy/component", i); -// double imips_charge = dbprovider.getDouble("/calibration/ft/fthodo/charge_to_energy/mips_charge", i); -// double imips_energy = dbprovider.getDouble("/calibration/ft/fthodo/charge_to_energy/mips_energy", i); -// -// mips_charge[iSec-1][iLay-1][iCom-1] = imips_charge; -// mips_energy[iSec-1][iLay-1][iCom-1] = imips_energy; -// if(debugMode>=1) System.out.println("energy_to_charge table: " + iCom + " " + imips_charge + " " + imips_energy ); -// } -// // 2) Offsets : TIME_OFFSET -// for(int i =0; i< dbprovider.length("/calibration/ft/fthodo/time_offsets/time_offset"); i++) { -// -// int iSec = dbprovider.getInteger("/calibration/ft/fthodo/time_offsets/sector", i); -// int iLay = dbprovider.getInteger("/calibration/ft/fthodo/time_offsets/layer", i); -// int iCom = dbprovider.getInteger("/calibration/ft/fthodo/time_offsets/component", i); -// double ioffset = dbprovider.getDouble("/calibration/ft/fthodo/time_offsets/time_offset", i); -// -// time_offset[iSec-1][iLay-1][iCom-1] = ioffset; -// if(debugMode>=1) System.out.println("time_offsets: " + iCom + " " + ioffset ); -// } -// // 3) Status : STATUS -// for(int i =0; i< dbprovider.length("/calibration/ft/fthodo/status/status"); i++) { -// -// int iSec = dbprovider.getInteger("/calibration/ft/fthodo/status/sector", i); -// int iLay = dbprovider.getInteger("/calibration/ft/fthodo/status/layer", i); -// int iCom = dbprovider.getInteger("/calibration/ft/fthodo/status/component", i); -// int istatus = dbprovider.getInteger("/calibration/ft/fthodo/status/status", i); -// -// status[iSec-1][iLay-1][iCom-1] = istatus; -// if(debugMode>=1) System.out.println("status: " + iCom + " " + istatus ); -// } -// // 4) Geometry -// for(int i =0; i< dbprovider.length("/geometry/ft/fthodo/x"); i++) { -// -// int iSec = dbprovider.getInteger("/geometry/ft/fthodo/sector", i); -// int iLay = dbprovider.getInteger("/geometry/ft/fthodo/layer", i); -// int iCom = dbprovider.getInteger("/geometry/ft/fthodo/component", i); -// double x = dbprovider.getDouble("/geometry/ft/fthodo/x", i); -// double y = dbprovider.getDouble("/geometry/ft/fthodo/y", i); -// double z = dbprovider.getDouble("/geometry/ft/fthodo/z", i); -// -// px[iSec-1][iLay-1][iCom-1] = x; -// py[iSec-1][iLay-1][iCom-1] = y; -// pz[iSec-1][iLay-1][iCom-1] = z; -// if(debugMode>=1) System.out.println("geometry: " + iCom + " " + x + " " + y + " " + z); -// } -// CSTLOADED = true; -// System.out.println("SUCCESSFULLY LOADED FTHODO CALIBRATION CONSTANTS...."); -//// return dbprovider; -// -// } - - } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOEngine.java index b8c57bf4f5..26166c562e 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOEngine.java @@ -1,13 +1,11 @@ package org.jlab.rec.ft.hodo; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import javax.swing.JFrame; import org.jlab.clas.detector.DetectorData; import org.jlab.clas.detector.DetectorEvent; -import org.jlab.clas.physics.GenericKinematicFitter; import org.jlab.clas.physics.PhysicsEvent; import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.groot.data.H1F; @@ -16,7 +14,6 @@ import org.jlab.io.base.DataEvent; import org.jlab.io.evio.EvioDataBank; import org.jlab.io.evio.EvioDataEvent; -import org.jlab.io.evio.EvioSource; import org.jlab.io.hipo.HipoDataSource; @@ -49,20 +46,17 @@ public boolean init() { @Override public boolean processDataEvent(DataEvent event) { - List allHits = new ArrayList(); - List selectedHits = new ArrayList(); - List clusters = new ArrayList(); - + // update calibration constants based on run number if changed int run = setRunConditionsParameters(event); if(run>=0) { // get hits fron banks - allHits = reco.initFTHODO(event,this.getConstantsManager(), run); + List allHits = reco.initFTHODO(event,this.getConstantsManager(), run); // select good hits and order them by energy - selectedHits = reco.selectHits(allHits); + List selectedHits = reco.selectHits(allHits); // create clusters - clusters = reco.findClusters(selectedHits); + List clusters = reco.findClusters(selectedHits); // write output banks reco.writeBanks(event, selectedHits, clusters); } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOReconstruction.java index 736b033fb2..cc7f3541aa 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/hodo/FTHODOReconstruction.java @@ -50,7 +50,7 @@ public List initFTHODO(DataEvent event, ConstantsManager manager, int public List selectHits(List allhits) { if(debugMode>=1) System.out.println("\nSelecting hits"); - ArrayList hits = new ArrayList(); + ArrayList hits = new ArrayList<>(); for(int i = 0; i < allhits.size(); i++) { @@ -99,18 +99,8 @@ public List findClusters(List hits) { } public void writeBanks(DataEvent event, List hits, List clusters){ - if(event instanceof EvioDataEvent) { - writeEvioBanks(event, hits, clusters); - } - else if(event instanceof HipoDataEvent) { - writeHipoBanks(event, hits, clusters); - } - } - - private void writeHipoBanks(DataEvent event, List hits, List clusters){ - // hits banks - if(hits.size()!=0) { + if(!hits.isEmpty()) { DataBank bankHits = event.createBank("FTHODO::hits", hits.size()); if(bankHits==null){ System.out.println("ERROR CREATING BANK : FTHODO::hits"); @@ -131,7 +121,7 @@ private void writeHipoBanks(DataEvent event, List hits, List hits, List hits, List clusters) { - - EvioDataBank bankhits = null; - EvioDataBank bankclust = null; - - // hits banks - if(hits.size()!=0) { - bankhits = (EvioDataBank) event.getDictionary().createBank("FTHODORec::hits",hits.size()); - for(int i=0; i=1) clusters.get(i).showCluster(); - bankclust.setInt("clusterID", i,clusters.get(i).getID()); - bankclust.setInt("clusterSize", i,clusters.get(i).size()); - bankclust.setDouble("clusterX",i,clusters.get(i).getX()/10.0); - bankclust.setDouble("clusterY",i,clusters.get(i).getY()/10.0); - bankclust.setDouble("clusterDX",i,clusters.get(i).getWidthX()/10.0); - bankclust.setDouble("clusterDY",i,clusters.get(i).getWidthY()/10.0); - bankclust.setDouble("clusterTime",i,clusters.get(i).getTime()); - bankclust.setDouble("clusterEnergy",i,clusters.get(i).getEnergy()); - bankclust.setDouble("clusterTheta",i,clusters.get(i).getTheta()); - bankclust.setDouble("clusterPhi",i,clusters.get(i).getPhi()); - } - } - - // If there are no clusters, punt here but save the reconstructed hits - if(bankclust!=null) { - event.appendBanks(bankhits,bankclust); - } - else if (bankhits!=null) { - event.appendBank(bankhits); - } - - } public List readRawHits(DataEvent event, IndexedTable charge2Energy, IndexedTable timeOffsets, IndexedTable geometry) { // getting raw data bank if(debugMode>=1) System.out.println("Getting raw hits from FTHODO:dgtz bank"); - List hits = new ArrayList(); + List hits = new ArrayList<>(); if(event.hasBank("FTHODO::dgtz")==true) { EvioDataBank bankDGTZ = (EvioDataBank) event.getBank("FTHODO::dgtz"); int nrows = bankDGTZ.rows(); @@ -229,7 +170,7 @@ public List readRawHitsHipo(DataEvent event, IndexedTable charge2Ener // getting raw data bank if(debugMode>=1) System.out.println("Getting raw hits from FTHODO:adc bank"); - List hits = new ArrayList(); + List hits = new ArrayList<>(); if(event.hasBank("FTHODO::adc")==true) { DataBank bankDGTZ = event.getBank("FTHODO::adc"); int nrows = bankDGTZ.rows(); @@ -237,7 +178,6 @@ public List readRawHitsHipo(DataEvent event, IndexedTable charge2Ener int isector = bankDGTZ.getByte("sector",row); int ilayer = bankDGTZ.getByte("layer",row); int icomponent = bankDGTZ.getShort("component",row); - int iorder = bankDGTZ.getByte("order",row); int adc = bankDGTZ.getInt("ADC",row); float time = bankDGTZ.getFloat("time",row); if(adc!=-1 && time!=-1 && status.getIntValue("status", isector, ilayer, icomponent)==0){ From 8b14647fc46dd274e025e72ea6e72382036a1681 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Mon, 6 Jun 2022 17:14:28 +0200 Subject: [PATCH 102/104] More cleanups --- .../java/org/jlab/rec/ft/FTConstants.java | 23 +- .../main/java/org/jlab/rec/ft/FTEBEngine.java | 21 +- .../java/org/jlab/rec/ft/FTEventBuilder.java | 283 ++--- .../main/java/org/jlab/rec/ft/FTParticle.java | 52 +- .../main/java/org/jlab/rec/ft/FTResponse.java | 30 +- .../org/jlab/rec/ft/trk/FTTRKCluster.java | 2 +- .../jlab/rec/ft/trk/FTTRKConstantsLoader.java | 8 +- .../java/org/jlab/rec/ft/trk/FTTRKEngine.java | 27 +- .../java/org/jlab/rec/ft/trk/FTTRKHit.java | 5 - .../jlab/rec/ft/trk/FTTRKReconstruction.java | 1097 ++++++++--------- .../org/jlab/service/ft/FTEBEngineTest.java | 4 +- 11 files changed, 680 insertions(+), 872 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java index b787e26c98..390a7a380d 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java @@ -1,8 +1,3 @@ -/* - * 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.ft; /** @@ -14,7 +9,7 @@ public class FTConstants { public static final int HODO_MIN_CLUSTER_SIZE = 2; // minimum size of hodo clusters for match to calorimeter - public static final double CAL_HODO_DISTANCE_MATCHING = 3.0; // matching distance in cm + public static final double CAL_HODO_DISTANCE_MATCHING = 3.0; // matching distance in cm public static final double CAL_HODO_TIME_MATCHING = 8; // matching time in ns (it was 8) public static final double CAL_TRK_DISTANCE_MATCHING = 3.; // matching distance in cm (it was 1.5) @@ -23,16 +18,16 @@ public class FTConstants { public static final double TRK_STRIP_MIN_TIME = 50; // minimum time value associated to one strip public static final double TRK_STRIP_MAX_TIME = 350; // minimum time value associated to one strip - public static final double TRK_MIN_CROSS_NUMBER = 1; // minimum number of crosses to find a line in the tracker - public static final double TRK1_TRK2_RADTOL = 0.05; // max tolerance for TRK0/TRK1 distance (3D) (was 1.-0.5) + public static final double TRK_MIN_CROSS_NUMBER = 1; // minimum number of crosses to find a line in the tracker + public static final double TRK1_TRK2_RADTOL = 0.05; // max tolerance for TRK0/TRK1 distance (3D) (was 1.-0.5) public static final double TRK1_TRK2_PHITOL = 0.07; // max tolerance for TRK0/TRK1 phi angular deviation (was 1.-0.7) public static final double TRK1_TRK2_THETATOL = 0.07; // max tolerance for TRK0/TRK1 theta angulare deviation (was 1.-0.7) - public static final double FTTRKMinAdcThreshold = 18.; // check min threshold for FTTTRK ADCs (18) - public static final double FTTRKMaxAdcThreshold = 2000.; // check max threshold for FTTTRK ADCs (18) was 1000 170122 - public static final int TRK_MAX_StripsForTruncatedMean = 20; // threshold for maxnumber of strips included in the truncated mean algo. - public static final int TRK_MIN_ClusterSizeForCentroid = 3; // minimum size of the cluster to provide a reliable location by its centroid - public static final double TRK_MIN_CLUS_ENERGY = 20.; // minimum cluster energy to accept a signal cluster (20) - public static final int TRK_MIN_CLUS_SIZE = 0; // minimum cluster size to form crosses (0: no limit on cluster size) // 2 is very strict + public static final double TRK_ADC_MINIMUM = 18.; // check min threshold for FTTTRK ADCs (18) + public static final double TRK_ADC_MAXIMUM = 2000.; // check max threshold for FTTTRK ADCs (18) was 1000 170122 + public static final int TRK_MAX_STRIPS_FOR_TRUNCATED_MEAN = 20; // threshold for maxnumber of strips included in the truncated mean algo. + public static final int TRK_MIN_CLUSTER_SIZE_CENTROID = 3; // minimum size of the cluster to provide a reliable location by its centroid + public static final double TRK_MIN_CLUS_ENERGY = 20.; // minimum cluster energy to accept a signal cluster (20) + public static final int TRK_MIN_CLUS_SIZE = 0; // minimum cluster size to form crosses (0: no limit on cluster size) // 2 is very strict public static final int TRK_MAXNUMBEROFHITS = 100; // maximum number of accepted hits in the tracker banks } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index a6760a6739..57bc2bca0d 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -35,7 +35,7 @@ public class FTEBEngine extends ReconstructionEngine { - FTEventBuilder reco; + FTEventBuilder reco = new FTEventBuilder(); int Run = -1; double Solenoid; @@ -45,7 +45,6 @@ public FTEBEngine() { @Override public boolean init() { - reco = new FTEventBuilder(); reco.debugMode = 0; String[] tables = new String[]{ "/calibration/ft/ftcal/cluster", @@ -63,16 +62,14 @@ public boolean init() { @Override public boolean processDataEvent(DataEvent event) { - List FTparticles = new ArrayList(); - List FTresponses = new ArrayList(); - + int run = this.setRunConditionsParameters(event); if (run>=0) { reco.init(this.getSolenoid()); - FTresponses = reco.addResponses(event, this.getConstantsManager(), run); + List FTresponses = reco.addResponses(event, this.getConstantsManager(), run); - FTparticles = reco.initFTparticles(FTresponses, this.getConstantsManager(), run); - if(FTparticles.size()>0){ + List FTparticles = reco.initFTparticles(FTresponses, this.getConstantsManager(), run); + if(!FTparticles.isEmpty()){ reco.matchToTRKTwoDetectorsMultiHits(FTresponses, FTparticles); reco.matchToHODO(FTresponses, FTparticles); reco.correctDirection(FTparticles, this.getConstantsManager(), run); @@ -359,10 +356,6 @@ public static void main(String arg[]){ EmbeddedCanvas canvasCALTRK = new EmbeddedCanvas(); canvasCALTRK.divide(3,1); - double diffRadTolerance = FTConstants.TRK1_TRK2_RADTOL; - double diffPhiTolerance = FTConstants.TRK1_TRK2_PHITOL; - double diffThetaTolerance = FTConstants.TRK1_TRK2_THETATOL; - int nev = 0; int nevWithCrosses = 0, ncrosses2 = 0, nOfFTParticles = 0; int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; @@ -495,11 +488,11 @@ public static void main(String arg[]){ // if the cluster is formed by >= 3 strips take the centroid int clustsize1 = bankcl.getShort("size", icl1ok); int clustsize2 = bankcl.getShort("size", icl2ok); - if(clustsize1>=FTConstants.TRK_MIN_ClusterSizeForCentroid){ + if(clustsize1>=FTConstants.TRK_MIN_CLUSTER_SIZE_CENTROID){ int sector = FTTRKReconstruction.findSector(seed1); if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed1 = cent1; } - if(clustsize2>=FTConstants.TRK_MIN_ClusterSizeForCentroid){ + if(clustsize2>=FTConstants.TRK_MIN_CLUSTER_SIZE_CENTROID){ int sector = FTTRKReconstruction.findSector(seed2); if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed2 = cent2; } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index 15a91e03cb..01cd16a649 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -2,16 +2,10 @@ import java.util.ArrayList; import java.util.List; -import org.jlab.clas.pdg.PhysicsConstants; import org.jlab.detector.base.DetectorLayer; import org.jlab.detector.calib.utils.ConstantsManager; -import org.jlab.geom.prim.Vector3D; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; - -import org.jlab.io.evio.EvioDataBank; -import org.jlab.io.evio.EvioDataEvent; -import org.jlab.rec.ft.cal.FTCALConstantsLoader; import org.jlab.utils.groups.IndexedTable; import org.jlab.rec.ft.trk.FTTRKConstantsLoader; import org.jlab.detector.base.DetectorType; @@ -42,119 +36,66 @@ public void init(double field) { System.out.println("New event"); } this.solenoidField = field; -// this.FTparticles.clear(); -// this.FTresponses.clear(); } public List addResponses(DataEvent event, ConstantsManager manager, int run) { - List responses = new ArrayList(); - - IndexedTable cluster = manager.getConstants(run, "/calibration/ft/ftcal/cluster"); - - if (event instanceof EvioDataEvent) { - if (event.hasBank("FTCALRec::clusters") == true) { - EvioDataBank bank = (EvioDataBank) event.getBank("FTCALRec::clusters"); - int nrows = bank.rows(); - for (int i = 0; i < nrows; i++) { - FTResponse resp = new FTResponse(DetectorType.FTCAL); - resp.setAssociation(-1); - resp.setSize(bank.getInt("clusSize", i)); - resp.setId(bank.getInt("clusID", i)); - resp.setEnergy(bank.getDouble("clusEnergy", i)); - resp.setTime(bank.getDouble("clusTime", i)); - resp.setPosition(bank.getDouble("clusX", i), bank.getDouble("clusY", i), FTCALConstantsLoader.CRYS_ZPOS + cluster.getDoubleValue("depth_z", 1, 1, 0)); - responses.add(resp); - } - } - - if (event.hasBank("FTTRK::crosses") == true) { - DataBank bank = event.getBank("FTTRK::crosses"); - int nrows = bank.rows(); - for (int i = 0; i < nrows; i++) { - FTResponse resp = new FTResponse(DetectorType.FTTRK); - resp.setAssociation(-1); - resp.setSize(bank.getInt("size", i)); - resp.setId(bank.getInt("id", i)); - resp.setEnergy(bank.getFloat("energy", i)); - resp.setTime(bank.getFloat("time", i)); - resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); - if(debugMode>=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); - responses.add(resp); - } - - } - - if (event.hasBank("FTHODORec::clusters") == true) { - EvioDataBank bank = (EvioDataBank) event.getBank("FTHODORec::clusters"); - int nrows = bank.rows(); - for (int i = 0; i < nrows; i++) { - FTResponse resp = new FTResponse(DetectorType.FTHODO); - resp.setSize(bank.getInt("clusterSize", i)); - resp.setId(bank.getInt("clusterID", i)); - resp.setEnergy(bank.getDouble("clusterEnergy", i)); - resp.setTime(bank.getDouble("clusterTime", i)); - resp.setPosition(bank.getDouble("clusterX", i), bank.getDouble("clusterY", i), bank.getDouble("clusterZ", i)); - responses.add(resp); - } - } - } else { - if (event.hasBank("FTCAL::clusters") == true) { - DataBank bank = event.getBank("FTCAL::clusters"); - int nrows = bank.rows(); - for (int i = 0; i < nrows; i++) { - FTResponse resp = new FTResponse(DetectorType.FTCAL); - resp.setAssociation(-1); - resp.setSize(bank.getInt("size", i)); - resp.setId(bank.getInt("id", i)); - resp.setEnergy(bank.getFloat("energy", i)); - resp.setTime(bank.getFloat("time", i)); - resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); - responses.add(resp); - } + List responses = new ArrayList<>(); + + if (event.hasBank("FTCAL::clusters") == true) { + DataBank bank = event.getBank("FTCAL::clusters"); + int nrows = bank.rows(); + for (int i = 0; i < nrows; i++) { + FTResponse resp = new FTResponse(DetectorType.FTCAL); + resp.setAssociation(-1); + resp.setSize(bank.getInt("size", i)); + resp.setId(bank.getInt("id", i)); + resp.setEnergy(bank.getFloat("energy", i)); + resp.setTime(bank.getFloat("time", i)); + resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); + responses.add(resp); } - if (event.hasBank("FTHODO::clusters") == true) { - DataBank bank = event.getBank("FTHODO::clusters"); - int nrows = bank.rows(); - for (int i = 0; i < nrows; i++) { - FTResponse resp = new FTResponse(DetectorType.FTHODO); - resp.setAssociation(-1); - resp.setSize(bank.getInt("size", i)); - resp.setId(bank.getInt("id", i)); - resp.setEnergy(bank.getFloat("energy", i)); - resp.setTime(bank.getFloat("time", i)); - resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); - responses.add(resp); - } + } + if (event.hasBank("FTHODO::clusters") == true) { + DataBank bank = event.getBank("FTHODO::clusters"); + int nrows = bank.rows(); + for (int i = 0; i < nrows; i++) { + FTResponse resp = new FTResponse(DetectorType.FTHODO); + resp.setAssociation(-1); + resp.setSize(bank.getInt("size", i)); + resp.setId(bank.getInt("id", i)); + resp.setEnergy(bank.getFloat("energy", i)); + resp.setTime(bank.getFloat("time", i)); + resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); + responses.add(resp); } - if (event.hasBank("FTTRK::crosses") == true) { - int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; // module1, tracker id=0 (int index for loops) - int TRK2 = DetectorLayer.FTTRK_MODULE2 - 1; // module2, tracker id=1 - byte bytTRK1 = DetectorLayer.FTTRK_MODULE1; // module1, trkid=0 - byte bytTRK2 = DetectorLayer.FTTRK_MODULE2; // module2, trkid=1 - DataBank bank = event.getBank("FTTRK::crosses"); - int nrows = bank.rows(); - for (int i = 0; i < nrows; i++) { - FTResponse resp = new FTResponse(DetectorType.FTTRK); - resp.setAssociation(-1); - resp.setSize(bank.getInt("size", i)); - resp.setId(bank.getInt("id", i)); - resp.setEnergy(bank.getFloat("energy", i)); - resp.setTime(bank.getFloat("time", i)); - resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); - double zCoord = bank.getFloat("z", i); - - if(zCoord >= FTTRKConstantsLoader.Zlayer[TRK1] && zCoord <= FTTRKConstantsLoader.Zlayer[TRK2]){ - resp.setTrkDet(bytTRK1); - }else{ - resp.setTrkDet(bytTRK2); - } - - if(debugMode>=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); - responses.add(resp); - } + } + if (event.hasBank("FTTRK::crosses") == true) { + int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; // module1, tracker id=0 (int index for loops) + int TRK2 = DetectorLayer.FTTRK_MODULE2 - 1; // module2, tracker id=1 + DataBank bank = event.getBank("FTTRK::crosses"); + int nrows = bank.rows(); + for (int i = 0; i < nrows; i++) { + FTResponse resp = new FTResponse(DetectorType.FTTRK); + resp.setAssociation(-1); + resp.setSize(bank.getInt("size", i)); + resp.setId(bank.getInt("id", i)); + resp.setEnergy(bank.getFloat("energy", i)); + resp.setTime(bank.getFloat("time", i)); + resp.setPosition(bank.getFloat("x", i), bank.getFloat("y", i), bank.getFloat("z", i)); + double zCoord = bank.getFloat("z", i); + + if(zCoord >= FTTRKConstantsLoader.Zlayer[TRK1] && zCoord <= FTTRKConstantsLoader.Zlayer[TRK2]){ + resp.setModule(DetectorLayer.FTTRK_MODULE1); + }else{ + resp.setModule(DetectorLayer.FTTRK_MODULE2); + } + + if(debugMode>=1) System.out.println(" --------- id, cross x, y, z " + bank.getInt("id", i) + " " + bank.getFloat("x", i) + " " + bank.getFloat("y", i) + " " + bank.getFloat("z", i)); + responses.add(resp); } - } + + if (debugMode >= 1) { this.showResponses(responses); } @@ -167,16 +108,14 @@ public void correctDirection(List particles, ConstantsManager manage IndexedTable phiCorr = manager.getConstants(run, "/calibration/ft/ftcal/phicorr"); for (int i = 0; i < particles.size(); i++) { FTParticle particle = particles.get(i); -// if(particle.getCalorimeterIndex()>-1) particle.setDirection(thetaCorr, phiCorr); - particle.setDirection(thetaCorr, phiCorr); + particle.setDirection(thetaCorr, phiCorr); } } public List initFTparticles(List responses, ConstantsManager manager, int run) { IndexedTable target = manager.getConstants(run, "/geometry/target"); - List particles = new ArrayList(); -// this.FTparticles.clear(); + List particles = new ArrayList<>(); for (int i = 0; i < responses.size(); i++) { if (responses.get(i).getType()==DetectorType.FTCAL) { // start assuming the cluster to be associated to a photon @@ -243,35 +182,6 @@ public void matchToTRKTwoDetectorsMultiHits(List responses, List responses, List particles) { - for (int i = 0; i < particles.size(); i++) { - FTParticle track = particles.get(i); - - int iHodo = track.getDetectorHit(responses, DetectorType.FTHODO, FTConstants.CAL_HODO_DISTANCE_MATCHING, FTConstants.CAL_HODO_TIME_MATCHING); - if (iHodo > 0) { - if (debugMode >= 1) { - System.out.println("found signal in the hodoscope " + iHodo); - } - track.setCharge(-1); - track.setHodoscopeIndex(responses.get(iHodo).getId()); - responses.get(iHodo).setAssociation(i); - } - - int iTrk = track.getDetectorHit(responses, DetectorType.FTTRK, FTConstants.CAL_TRK_DISTANCE_MATCHING, FTConstants.CAL_TRK_TIME_MATCHING); - if (iTrk > 0) { - if (debugMode >= 1) { - System.out.println("found signal in FTTRK" + iTrk); - } - track.setCharge(-999); // provisional, for no field tracking - track.setTrackerIndex(responses.get(iTrk).getId(), responses.get(iTrk).getTrkDet()); - responses.get(iTrk).setAssociation(i); - } - if (debugMode >= 1) track.show(); - - } - } - public void showResponses(List responses) { System.out.println("\nFound " + responses.size() + " clusters in FT detector"); for (int i = 0; i < responses.size(); i++) { @@ -283,64 +193,37 @@ public void writeBanks(DataEvent event, List particles) { if (debugMode >= 1) { System.out.println("Preparing to output track bank with " + particles.size() + " FTparticles"); } - int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; - int TRK2 = DetectorLayer.FTTRK_MODULE2 - 1; - if (particles.size() != 0) { - if (event instanceof EvioDataEvent) { - EvioDataBank banktrack = (EvioDataBank) event.getDictionary().createBank("FTRec::tracks", particles.size()); - if (debugMode >= 1) { - System.out.println("Creating output track bank with " + particles.size() + " FTparticles"); - } - - for (int i = 0; i < particles.size(); i++) { - banktrack.setInt("ID", i, particles.get(i).get_ID()); - banktrack.setInt("Charge", i, particles.get(i).getCharge()); - banktrack.setDouble("Energy", i, particles.get(i).getEnergy()); - banktrack.setDouble("Cx", i, particles.get(i).getDirection().x()); - banktrack.setDouble("Cy", i, particles.get(i).getDirection().y()); - banktrack.setDouble("Cz", i, particles.get(i).getDirection().z()); - banktrack.setDouble("Time", i, particles.get(i).getTime()); - banktrack.setInt("CalID", i, particles.get(i).getCalorimeterIndex()); - banktrack.setInt("HodoID", i, particles.get(i).getHodoscopeIndex()); - banktrack.setInt("Trk0ID", i, particles.get(i).getTrackerIndex(TRK1)); - banktrack.setInt("Trk1ID", i, particles.get(i).getTrackerIndex(TRK2)); - if (debugMode >= 1) { - particles.get(i).show(); - } - } - if (banktrack != null) { - event.appendBanks(banktrack); - } - } else { - DataBank banktrack = event.createBank("FT::particles", particles.size()); + if (!particles.isEmpty()) { + + DataBank banktrack = event.createBank("FT::particles", particles.size()); + if (debugMode >= 1) { + System.out.println("Creating output track bank with " + particles.size() + " FTparticles"); + } + for (int i = 0; i < particles.size(); i++) { + banktrack.setShort("id", i, (short) particles.get(i).get_ID()); + banktrack.setByte("charge", i, (byte) particles.get(i).getCharge()); + banktrack.setFloat("energy", i, (float) particles.get(i).getEnergy()); + banktrack.setFloat("cx", i, (float) particles.get(i).getDirection().x()); + banktrack.setFloat("cy", i, (float) particles.get(i).getDirection().y()); + banktrack.setFloat("cz", i, (float) particles.get(i).getDirection().z()); + banktrack.setFloat("vx", i, (float) particles.get(i).getVertex().x()); + banktrack.setFloat("vy", i, (float) particles.get(i).getVertex().y()); + banktrack.setFloat("vz", i, (float) particles.get(i).getVertex().z()); + banktrack.setFloat("time", i, (float) particles.get(i).getTime()); + banktrack.setShort("calID", i, (short) particles.get(i).getCalorimeterIndex()); + banktrack.setShort("hodoID", i, (short) particles.get(i).getHodoscopeIndex()); + banktrack.setShort("trk0ID", i, (short) particles.get(i).getTrackerIndex(DetectorLayer.FTTRK_MODULE1-1)); + banktrack.setShort("trk1ID", i, (short) particles.get(i).getTrackerIndex(DetectorLayer.FTTRK_MODULE2-1)); + if (debugMode >= 1) { - System.out.println("Creating output track bank with " + particles.size() + " FTparticles"); - } - for (int i = 0; i < particles.size(); i++) { - banktrack.setShort("id", i, (short) particles.get(i).get_ID()); - banktrack.setByte("charge", i, (byte) particles.get(i).getCharge()); - banktrack.setFloat("energy", i, (float) particles.get(i).getEnergy()); - banktrack.setFloat("cx", i, (float) particles.get(i).getDirection().x()); - banktrack.setFloat("cy", i, (float) particles.get(i).getDirection().y()); - banktrack.setFloat("cz", i, (float) particles.get(i).getDirection().z()); - banktrack.setFloat("vx", i, (float) particles.get(i).getVertex().x()); - banktrack.setFloat("vy", i, (float) particles.get(i).getVertex().y()); - banktrack.setFloat("vz", i, (float) particles.get(i).getVertex().z()); - banktrack.setFloat("time", i, (float) particles.get(i).getTime()); - banktrack.setShort("calID", i, (short) particles.get(i).getCalorimeterIndex()); - banktrack.setShort("hodoID", i, (short) particles.get(i).getHodoscopeIndex()); - banktrack.setShort("trk0ID", i, (short) particles.get(i).getTrackerIndex(TRK1)); - banktrack.setShort("trk1ID", i, (short) particles.get(i).getTrackerIndex(TRK2)); - - if (debugMode >= 1) { - particles.get(i).show(); - System.out.println(particles.get(i).getDirection().x() + " " + particles.get(i).getDirection().y() + " " + particles.get(i).getDirection().z()); - } - } - if (banktrack != null) { - event.appendBanks(banktrack); + particles.get(i).show(); + System.out.println(particles.get(i).getDirection().x() + " " + particles.get(i).getDirection().y() + " " + particles.get(i).getDirection().z()); } } + if (banktrack != null) { + event.appendBanks(banktrack); + } + } } diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index d7f15b53bf..4832348335 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -191,34 +191,34 @@ public int getDetectorHit(List hitList, DetectorType detectorType, Line3D dist = cross.distance(response.getPosition().toPoint3D()); double hitdistance = dist.length(); double timedistance = Math.abs(this.getTime() - (response.getTime()-response.getPosition().mag()/PhysicsConstants.speedOfLight())); - if(hitdistance=1){ - System.out.println("best hit distance and time " + minimumDistance + " " + timedistance); - System.out.println("cross center coordinates x, y " + response.getPosition().toPoint3D().x() + " , " + - response.getPosition().toPoint3D().y()); - } - }else if(detectorType.getName()=="FTHODO" && timedistance=1 && detectorType==DetectorType.FTTRK ){ + System.out.println("best hit distance and time " + minimumDistance + " " + timedistance); + System.out.println("cross center coordinates x, y " + response.getPosition().toPoint3D().x() + " , " + + response.getPosition().toPoint3D().y()); + } } } } if(bestIndex>-1) { // if bestHit is on hodo require at least two hits overall on HODO - if(detectorType.getName()=="HODO"){if(hitList.get(bestIndex).getSize()= FTConstants.TRK_MIN_CROSS_NUMBER){;}else{bestIndex=-1;} + if(detectorType==DetectorType.FTTRK){ + if(hitList.get(bestIndex).getSize() < FTConstants.TRK_MIN_CROSS_NUMBER) { + bestIndex=-1; + } } } return bestIndex; } - + // not used public int[] getTRKBestHits(List hitList, int it, double distanceThreshold, double timeThreshold){ Line3D cross = this.getLastCross(); double minimumDistance = 500.0; @@ -232,7 +232,7 @@ public int[] getTRKBestHits(List hitList, int it, double distanceTh double timedistance = Math.abs(this.getTime() - (response.getTime()-response.getPosition().mag()/PhysicsConstants.speedOfLight())); double t=response.getTime(); - int det = response.getTrkDet(); + int det = response.getModule(); if(timedistance hitList, int it, double distanceTh public int [][] getTRKOrderedListOfHits(List hitList, int it, double distanceThreshold, double timeThreshold){ int TRK1 = DetectorLayer.FTTRK_MODULE1 - 1; // tracker id=0 - int TRK2 = DetectorLayer.FTTRK_MODULE2 -1; // tracker id=1 + int TRK2 = DetectorLayer.FTTRK_MODULE2 - 1; // tracker id=1 Line3D cross = this.getLastCross(); int ndetectors = FTTRKConstantsLoader.NSupLayers; int hitsTRK = 0; for(int l=0; l hitDistancesDet0 = new ArrayList(hitsTRK); - ArrayList hitOrderDet0 = new ArrayList(hitsTRK); - ArrayList hitDistancesDet1 = new ArrayList(hitsTRK); - ArrayList hitOrderDet1 = new ArrayList(hitsTRK); + ArrayList hitDistancesDet0 = new ArrayList<>(hitsTRK); + ArrayList hitOrderDet0 = new ArrayList<>(hitsTRK); + ArrayList hitDistancesDet1 = new ArrayList<>(hitsTRK); + ArrayList hitOrderDet1 = new ArrayList<>(hitsTRK); int lTRK = -1; //init for(int l=0; l hitList, int it, double distanceTh for(int loop = 0; loop < hitList.size(); loop++){ int bestidx = -1; FTResponse response = hitList.get(loop); - if(response.getAssociation()<0 && response.getType().getName() == "FTTRK"){ + if(response.getAssociation()<0 && response.getType()==DetectorType.FTTRK){ lTRK++; hitDistancesDet0.add(lTRK, -1.); hitDistancesDet1.add(lTRK, -1.); @@ -291,7 +291,7 @@ public int[] getTRKBestHits(List hitList, int it, double distanceTh double timedistance = Math.abs(this.getTime() - (response.getTime()-response.getPosition().mag()/PhysicsConstants.speedOfLight())); double t=response.getTime(); - int det = response.getTrkDet(); + int det = response.getModule(); if(timedistance allHits = new ArrayList(); - ArrayList clusters = new ArrayList(); - ArrayList crosses = new ArrayList(); - // update calibration constants based on run number if changed int run = setRunConditionsParameters(event); if(run>=0) { // get hits fron banks - allHits = reco.initFTTRK(event,this.getConstantsManager(), run); + List allHits = reco.initFTTRK(event,this.getConstantsManager(), run); // create clusters - clusters = reco.findClusters(allHits); + List clusters = reco.findClusters(allHits); // create crosses - crosses = reco.findCrosses(clusters); + List crosses = reco.findCrosses(clusters); + // update hit banks with associated clusters/crosses information + reco.updateAllHitsWithAssociatedIDs(allHits, clusters); // write output banks reco.writeBanks(event, allHits, clusters, crosses); } @@ -179,10 +180,8 @@ public static void main (String arg[]) { // int nev1 = 0; int nev2 = 20000; for(nev=nev1; nev=1) System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~ processing event ~~~~~~~~~~~ " + nev); - - ArrayList clusters = new ArrayList(); - - clusters = trk.processDataEventAndGetClusters(event); + + ArrayList clusters = trk.processDataEventAndGetClusters(event); int nStripsInClusters = 0; DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); @@ -240,7 +239,7 @@ public static void main (String arg[]) { canvasCl.draw(hHitL1); // dummy histogram // iterate along the cluster list for every event if(debug>=1) System.out.println("clusters size --- " + clusters.size()); - if(clusters.size()!=0){ + if(!clusters.isEmpty()){ // get one cluster and iterate over all the strips contained in it for(int i = 0; i < clusters.size(); i++){ // get a single cluster and count its strip, extract the information on extremal points of the segment diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java index 28cd3e98a1..fe90044bb7 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKHit.java @@ -1,8 +1,3 @@ -/* - * 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.ft.trk; import org.jlab.geom.prim.Line3D; diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java index ae7a8668b7..c83603cb42 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/trk/FTTRKReconstruction.java @@ -1,8 +1,3 @@ -/* - * 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.ft.trk; import java.util.ArrayList; @@ -11,24 +6,18 @@ import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; -import org.jlab.io.evio.EvioDataBank; -import org.jlab.io.evio.EvioDataEvent; -import org.jlab.io.hipo.HipoDataEvent; import org.jlab.rec.ft.FTConstants; - /** * * @author devita * @author filippi */ - - public class FTTRKReconstruction { public static int debugMode = 0; // 1 for verbose, set it here (better be set in the steering Engine) PROVISIONAL - public static int[] sectorLimits = - {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; + public static int[] sectorLimits + = {0, 64, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 704, 768}; public static int NStripsSectors = 20; public static int stripsInLongSector = 64; public static int stripsInShortSector = 32; @@ -38,9 +27,10 @@ public class FTTRKReconstruction { public static int stripDiscontinuity2; // 385 public static int stripDiscontinuity3; // 640 public static int stripDiscontinuity4; // 641 - + public FTTRKReconstruction() { } + public List initFTTRK(DataEvent event, ConstantsManager manager, int run) { /* tables are not needed for FTTRK reco at this point @@ -48,24 +38,25 @@ public List initFTTRK(DataEvent event, ConstantsManager manager, int r IndexedTable timeOffsets = manager.getConstants(run, "/calibration/ft/fthodo/time_offsets"); IndexedTable geometry = manager.getConstants(run, "/geometry/ft/fthodo"); IndexedTable trkGeo = manager.getConstants(run, "/geometry/ft/fttrk"); - */ - - sideShortStrips = 2*FTTRKConstantsLoader.SideHalfstrips; // 256 + */ + sideShortStrips = 2 * FTTRKConstantsLoader.SideHalfstrips; // 256 sequentialStrips = FTTRKConstantsLoader.Longstrips + FTTRKConstantsLoader.SideHalfstrips + sideShortStrips; // 512 stripDiscontinuity1 = FTTRKConstantsLoader.Longstrips; // 128 CHECK DISCONTINUITIES +- 1 strip stripDiscontinuity2 = FTTRKConstantsLoader.Longstrips + sideShortStrips + 1; // 385 stripDiscontinuity3 = sequentialStrips + FTTRKConstantsLoader.SideHalfstrips; // 640 - stripDiscontinuity4 = stripDiscontinuity3+1; - - if(debugMode>=1) System.out.println("\nAnalyzing new event"); + stripDiscontinuity4 = stripDiscontinuity3 + 1; + + if (debugMode >= 1) { + System.out.println("\nAnalyzing new event"); + } List allhits = null; - + // allhits = this.readRawHits(event,charge2Energy,timeOffsets,geometry,trkGeo); allhits = this.readRawHits(event, run); - - if(debugMode>=1) { + + if (debugMode >= 1) { System.out.println("Found " + allhits.size() + " hits"); - for(int i = 0; i < allhits.size(); i++) { + for (int i = 0; i < allhits.size(); i++) { System.out.print(i + "\t"); System.out.println(allhits.get(i).printInfo()); } @@ -73,40 +64,42 @@ public List initFTTRK(DataEvent event, ConstantsManager manager, int r return allhits; } + public ArrayList findClusters(List hits) { + int debugMode = FTTRKReconstruction.debugMode; + // cluster finding algorithm + // the loop is done over sectors - public ArrayList findClusters(List hits) - { - int debugMode=FTTRKReconstruction.debugMode; - // cluster finding algorithm - // the loop is done over sectors - - int Nlayers = FTTRKConstantsLoader.Nlayers; - int Nstrips = FTTRKConstantsLoader.Nstrips; - boolean[][] checked; - FTTRKHit[][] HitArray; + int Nlayers = FTTRKConstantsLoader.Nlayers; + int Nstrips = FTTRKConstantsLoader.Nstrips; + boolean[][] checked; + FTTRKHit[][] HitArray; ArrayList clusters = new ArrayList(); - + // a boolean array to avoid double counting at the numbering discontinuities - checked = new boolean[Nstrips][Nlayers] ; - for(int l=0; l0 && w<=Nstrips){ - HitArray[w-1][l-1] = hit; - if(debugMode>=1) System.out.println(w + " " + l + " " + HitArray[w-1][l-1].printInfo()); + if (w > 0 && w <= Nstrips) { + HitArray[w - 1][l - 1] = hit; + if (debugMode >= 1) { + System.out.println(w + " " + l + " " + HitArray[w - 1][l - 1].printInfo()); + } } } @@ -115,50 +108,50 @@ public ArrayList findClusters(List hits) // for each layer and sector, loop over the strips: // once one is selected for the first time, loop over the remainder // clusters are delimited by strips with no hits - int[] indR = new int[sequentialStrips]; + int[] indR = new int[sequentialStrips]; int[] indL = new int[sequentialStrips]; // strip index: from 0 to 512 (full right hand side, left hand side fired only in the interval 384-639) // strip number: from 1 to 768 - for(int i=0; i= FTTRKConstantsLoader.Longstrips && i < (FTTRKConstantsLoader.Longstrips + sideShortStrips)){ //384 + } else if (i >= FTTRKConstantsLoader.Longstrips && i < (FTTRKConstantsLoader.Longstrips + sideShortStrips)) { //384 indR[i] = i; indL[i] = i + sideShortStrips; //256 - }else if(i >= (FTTRKConstantsLoader.Longstrips + sideShortStrips)){ // 384 + } else if (i >= (FTTRKConstantsLoader.Longstrips + sideShortStrips)) { // 384 indR[i] = indL[i] = i + sideShortStrips; // 256 } } - + boolean needsReordering = false; // loop on layers - for(int il=0; il clusterHits = new ArrayList(); checked[ris][il] = true; // if fired this is the first strip of the cluster - clusterHits.add(new FTTRKHit(HitArray[ris][il].get_Sector(), HitArray[ris][il].get_Layer(), HitArray[ris][il].get_Strip(), + clusterHits.add(new FTTRKHit(HitArray[ris][il].get_Sector(), HitArray[ris][il].get_Layer(), HitArray[ris][il].get_Strip(), HitArray[ris][il].get_Edep(), HitArray[ris][il].get_Time(), HitArray[ris][il].get_Id())); // look for a consecutive strip in the stack and stick it to the cluster - int isnext = is+1; - while(isnext < sequentialStrips && HitArray[indR[isnext]][il] != null && !checked[indR[isnext]][il]){ + int isnext = is + 1; + while (isnext < sequentialStrips && HitArray[indR[isnext]][il] != null && !checked[indR[isnext]][il]) { int nris = indR[isnext]; checked[nris][il] = true; - clusterHits.add(new FTTRKHit(HitArray[nris][il].get_Sector(), HitArray[nris][il].get_Layer(), HitArray[nris][il].get_Strip(), - HitArray[nris][il].get_Edep(), HitArray[ris][il].get_Time(), HitArray[nris][il].get_Id())); + clusterHits.add(new FTTRKHit(HitArray[nris][il].get_Sector(), HitArray[nris][il].get_Layer(), HitArray[nris][il].get_Strip(), + HitArray[nris][il].get_Edep(), HitArray[ris][il].get_Time(), HitArray[nris][il].get_Id())); nst++; isnext++; } - is = isnext-1; - FTTRKCluster this_cluster = new FTTRKCluster(1, il+1, ++cid); + is = isnext - 1; + FTTRKCluster this_cluster = new FTTRKCluster(1, il + 1, ++cid); // modify clusterIndex for all the hits belonging to the cluster - ArrayList cloneHitsWNewID = new ArrayList(); - for(FTTRKHit clHit: clusterHits){ + ArrayList cloneHitsWNewID = new ArrayList<>(); + for (FTTRKHit clHit : clusterHits) { clHit.set_DGTZIndex(clHit.get_Id()); clHit.set_ClusterIndex(cid); cloneHitsWNewID.add(clHit); @@ -166,10 +159,10 @@ public ArrayList findClusters(List hits) this_cluster.addAll(cloneHitsWNewID); this_cluster.calc_CentroidParams(); clusters.add(this_cluster); - - if(debugMode>=1){ + + if (debugMode >= 1) { System.out.println("xxxxxxxxxxxxxxx cluster properties " + this_cluster.get_CId() + " cluster size " + this_cluster.size()); - for(int k=0; k findClusters(List hits) is++; } // second loop on LHS strips (only lateral strips) - is = FTTRKConstantsLoader.Longstrips; - while(is < (FTTRKConstantsLoader.Longstrips + sideShortStrips)){ //384 + is = FTTRKConstantsLoader.Longstrips; + while (is < (FTTRKConstantsLoader.Longstrips + sideShortStrips)) { //384 int nst = 0; int lis = indL[is]; - if(HitArray[lis][il] != null && !checked[lis][il]){ - ArrayList clusterHits = new ArrayList(); + if (HitArray[lis][il] != null && !checked[lis][il]) { + ArrayList clusterHits = new ArrayList<>(); checked[lis][il] = true; // if fired this is the first strip of the cluster - clusterHits.add(new FTTRKHit(HitArray[lis][il].get_Sector(), HitArray[lis][il].get_Layer(), HitArray[lis][il].get_Strip(), + clusterHits.add(new FTTRKHit(HitArray[lis][il].get_Sector(), HitArray[lis][il].get_Layer(), HitArray[lis][il].get_Strip(), HitArray[lis][il].get_Edep(), HitArray[lis][il].get_Time(), HitArray[lis][il].get_Id())); // look for a consecutive strip in the stack and stick it to the cluster - int isnext = is+1; - while(isnext < (sequentialStrips + FTTRKConstantsLoader.SideHalfstrips) && // 640 - HitArray[indL[isnext]][il] != null && !checked[indL[isnext]][il]){ + int isnext = is + 1; + while (isnext < (sequentialStrips + FTTRKConstantsLoader.SideHalfstrips) + && // 640 + HitArray[indL[isnext]][il] != null && !checked[indL[isnext]][il]) { int nlis = indL[isnext]; checked[nlis][il] = true; - clusterHits.add(new FTTRKHit(HitArray[nlis][il].get_Sector(), HitArray[nlis][il].get_Layer(), HitArray[nlis][il].get_Strip(), - HitArray[nlis][il].get_Edep(), HitArray[lis][il].get_Time(), HitArray[nlis][il].get_Id())); + clusterHits.add(new FTTRKHit(HitArray[nlis][il].get_Sector(), HitArray[nlis][il].get_Layer(), HitArray[nlis][il].get_Strip(), + HitArray[nlis][il].get_Edep(), HitArray[lis][il].get_Time(), HitArray[nlis][il].get_Id())); nst++; isnext++; } - is = isnext-1; - FTTRKCluster this_cluster = new FTTRKCluster(1, il+1, ++cid); - ArrayList cloneHitsWNewID = new ArrayList(); - for(FTTRKHit clHit: clusterHits){ + is = isnext - 1; + FTTRKCluster this_cluster = new FTTRKCluster(1, il + 1, ++cid); + ArrayList cloneHitsWNewID = new ArrayList<>(); + for (FTTRKHit clHit : clusterHits) { clHit.set_DGTZIndex(clHit.get_Id()); clHit.set_ClusterIndex(cid); cloneHitsWNewID.add(clHit); } - this_cluster.addAll(cloneHitsWNewID); + this_cluster.addAll(cloneHitsWNewID); this_cluster.calc_CentroidParams(); clusters.add(this_cluster); } @@ -214,145 +208,161 @@ public ArrayList findClusters(List hits) } // check if in any cluster there is a limiting strip. If two consecutive limiting strips are found, merge the clusters and // delete the second one - int clusterId11 = -1; - int clusterId12 = -1; - int clusterId21 = -1; + int clusterId11 = -1; + int clusterId12 = -1; + int clusterId21 = -1; int clusterId22 = -1; - for(FTTRKCluster clust : clusters){ - if(clust.get_Layer() == il+1){ + for (FTTRKCluster clust : clusters) { + if (clust.get_Layer() == il + 1) { int nbhits = clust.size(); int control = clust.get_CId(); - for(int i=0; i < nbhits; i++){ + for (int i = 0; i < nbhits; i++) { FTTRKHit hit = clust.get(i); int nstrip = hit.get_Strip(); - // 641 - if(nstrip==stripDiscontinuity1 || nstrip==stripDiscontinuity2 || nstrip==stripDiscontinuity3 || nstrip==stripDiscontinuity4){ + // 641 + if (nstrip == stripDiscontinuity1 || nstrip == stripDiscontinuity2 || nstrip == stripDiscontinuity3 || nstrip == stripDiscontinuity4) { needsReordering = true; - if(nstrip==stripDiscontinuity1) clusterId11 = clust.get_CId(); //cut 127-384 - if(nstrip==stripDiscontinuity2) clusterId12 = clust.get_CId(); - if(nstrip==stripDiscontinuity3) clusterId21 = clust.get_CId(); // cut 640-641 - if(nstrip==stripDiscontinuity4) clusterId22 = clust.get_CId(); - } + if (nstrip == stripDiscontinuity1) { + clusterId11 = clust.get_CId(); //cut 127-384 + } + if (nstrip == stripDiscontinuity2) { + clusterId12 = clust.get_CId(); + } + if (nstrip == stripDiscontinuity3) { + clusterId21 = clust.get_CId(); // cut 640-641 + } + if (nstrip == stripDiscontinuity4) { + clusterId22 = clust.get_CId(); + } + } } } } int clustersize = clusters.size(); // join clusters if there are consecutive limiting hits - if(clusterId11>=0 && clusterId12>=0 && clusterId11 != clusterId12){ - int newIndex = Math.min(clusterId11, clusterId12); - ArrayList twoClusterHits = new ArrayList(); + if (clusterId11 >= 0 && clusterId12 >= 0 && clusterId11 != clusterId12) { + ArrayList twoClusterHits = new ArrayList<>(); FTTRKCluster firstCluster = clusters.get(clusterId11); FTTRKCluster secondCluster = clusters.get(clusterId12); - for(int i=0; i< firstCluster.size(); i++){ + for (int i = 0; i < firstCluster.size(); i++) { FTTRKHit hit = firstCluster.get(i); twoClusterHits.add(hit); } - for(int i=0; i< secondCluster.size(); i++){ + for (int i = 0; i < secondCluster.size(); i++) { FTTRKHit hit = secondCluster.get(i); twoClusterHits.add(hit); } - FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, ++clustersize); + FTTRKCluster joinedClusters = new FTTRKCluster(1, il + 1, ++clustersize); // update cluster and hit ID - ArrayList cloneHitsWNewID = new ArrayList(); - for(FTTRKHit clHit: twoClusterHits){ + ArrayList cloneHitsWNewID = new ArrayList<>(); + for (FTTRKHit clHit : twoClusterHits) { clHit.set_DGTZIndex(clHit.get_Id()); cloneHitsWNewID.add(clHit); - } + } joinedClusters.addAll(cloneHitsWNewID); joinedClusters.calc_CentroidParams(); clusters.add(joinedClusters); - } - if(clusterId21>=0 && clusterId22>=0 && clusterId21 != clusterId22){ + } + if (clusterId21 >= 0 && clusterId22 >= 0 && clusterId21 != clusterId22) { int newIndex = Math.min(clusterId21, clusterId22); - ArrayList twoClusterHits = new ArrayList(); + ArrayList twoClusterHits = new ArrayList<>(); FTTRKCluster firstCluster = clusters.get(clusterId21); FTTRKCluster secondCluster = clusters.get(clusterId22); - for(int i=0; i< firstCluster.size(); i++){ + for (int i = 0; i < firstCluster.size(); i++) { FTTRKHit hit = firstCluster.get(i); twoClusterHits.add(hit); } - for(int i=0; i< secondCluster.size(); i++){ + for (int i = 0; i < secondCluster.size(); i++) { FTTRKHit hit = secondCluster.get(i); twoClusterHits.add(hit); } - FTTRKCluster joinedClusters = new FTTRKCluster(1, il+1, ++clustersize); - ArrayList cloneHitsWNewID = new ArrayList(); - for(FTTRKHit clHit: twoClusterHits){ + FTTRKCluster joinedClusters = new FTTRKCluster(1, il + 1, ++clustersize); + ArrayList cloneHitsWNewID = new ArrayList<>(); + for (FTTRKHit clHit : twoClusterHits) { clHit.set_DGTZIndex(clHit.get_Id()); clHit.set_ClusterIndex(newIndex); cloneHitsWNewID.add(clHit); - } + } joinedClusters.addAll(cloneHitsWNewID); joinedClusters.calc_CentroidParams(); clusters.add(joinedClusters); } // remove joined clusters from the final list - if(clusterId11>=0 && clusterId12>=0) { - if(clusterId11= 0 && clusterId12 >= 0) { + if (clusterId11 < clusterId12) { clusters.remove(clusterId12); clusters.remove(clusterId11); - }else{ + } else { clusters.remove(clusterId11); clusters.remove(clusterId12); } - cid--; + cid--; } - if(clusterId21>=0 && clusterId22>=0){ - if(clusterId21= 0 && clusterId22 >= 0) { + if (clusterId21 < clusterId22) { clusters.remove(clusterId22); clusters.remove(clusterId21); - }else{ + } else { clusters.remove(clusterId21); clusters.remove(clusterId22); } cid--; } } // end loop on layers - - + // before returning cluster list update centroid and its error, if the cluster list was modified - if(needsReordering){ + if (needsReordering) { int newClusterID = -1; - for(FTTRKCluster aCluster : clusters){ + for (FTTRKCluster aCluster : clusters) { aCluster.calc_CentroidParams(); aCluster.set_CId(++newClusterID); // ClusterID relabelling to match the ordinal cluster number } } - + return clusters; } - + public ArrayList findCrosses(List clusters) { - int debugMode=FTTRKReconstruction.debugMode; + int debugMode = FTTRKReconstruction.debugMode; // first separate the segments according to layers - ArrayList allinnerlayrclus = new ArrayList(); - ArrayList allouterlayrclus = new ArrayList(); + ArrayList allinnerlayrclus = new ArrayList<>(); + ArrayList allouterlayrclus = new ArrayList<>(); // Sorting by layer first: - for (FTTRKCluster theclus : clusters){ - if(theclus.get_Layer()%2==0) { - allouterlayrclus.add(theclus); - } - if(theclus.get_Layer()%2==1) { - allinnerlayrclus.add(theclus); - } - } - - ArrayList crosses = new ArrayList(); - - int rid =-1; - for(FTTRKCluster inlayerclus : allinnerlayrclus){ - if(inlayerclus.size()=1) System.out.println(inlayerclus.printInfo() + " " + outlayerclus.printInfo()); - if( (inlayerclus.get_MinStrip()+outlayerclus.get_MinStrip() > 0) - && (inlayerclus.get_MaxStrip()+outlayerclus.get_MaxStrip() < FTTRKConstantsLoader.Nstrips*2) ) { + for (FTTRKCluster theclus : clusters) { + if (theclus.get_Layer() % 2 == 0) { + allouterlayrclus.add(theclus); + } + if (theclus.get_Layer() % 2 == 1) { + allinnerlayrclus.add(theclus); + } + } + + ArrayList crosses = new ArrayList<>(); + + int rid = -1; + for (FTTRKCluster inlayerclus : allinnerlayrclus) { + if (inlayerclus.size() < FTConstants.TRK_MIN_CLUS_SIZE) { + continue; + } + for (FTTRKCluster outlayerclus : allouterlayrclus) { + if (outlayerclus.size() < FTConstants.TRK_MIN_CLUS_SIZE) { + continue; + } + if (outlayerclus.get_Layer() - inlayerclus.get_Layer() != 1) { + continue; + } + if (outlayerclus.get_Sector() != inlayerclus.get_Sector()) { + continue; + } + if (debugMode >= 1) { + System.out.println(inlayerclus.printInfo() + " " + outlayerclus.printInfo()); + } + if ((inlayerclus.get_MinStrip() + outlayerclus.get_MinStrip() > 0) + && (inlayerclus.get_MaxStrip() + outlayerclus.get_MaxStrip() < FTTRKConstantsLoader.Nstrips * 2)) { // define new cross - FTTRKCross this_cross = new FTTRKCross(inlayerclus.get_Sector(), inlayerclus.get_Region(),++rid); + FTTRKCross this_cross = new FTTRKCross(inlayerclus.get_Sector(), inlayerclus.get_Region(), ++rid); this_cross.set_Cluster1(inlayerclus); this_cross.set_Cluster2(outlayerclus); int dummy = this_cross.get_Cluster1().get_CId(); @@ -360,162 +370,175 @@ public ArrayList findCrosses(List clusters) { this_cross.set_CrossParams(); //make arraylist and check whether the cross center is in a physical position - double radXCenter = Math.sqrt(this_cross.get_Point().x()*this_cross.get_Point().x() + - this_cross.get_Point().y()*this_cross.get_Point().y()); - if(debugMode>=1) System.out.println("cross radius =============" + radXCenter); - if(radXCenter > FTTRKConstantsLoader.InnerHole && radXCenter < FTTRKConstantsLoader.Rmax) crosses.add(this_cross); - if(debugMode>=1) System.out.println("cross info :" + this_cross.printInfo() + " " + crosses.size()); - + double radXCenter = Math.sqrt(this_cross.get_Point().x() * this_cross.get_Point().x() + + this_cross.get_Point().y() * this_cross.get_Point().y()); + if (debugMode >= 1) { + System.out.println("cross radius =============" + radXCenter); + } + if (radXCenter > FTTRKConstantsLoader.InnerHole && radXCenter < FTTRKConstantsLoader.Rmax) { + crosses.add(this_cross); + } + if (debugMode >= 1) { + System.out.println("cross info :" + this_cross.printInfo() + " " + crosses.size()); + } + } } } - + return crosses; } - public List readRawHits(DataEvent event, int run) { + public List readRawHits(DataEvent event, int run) { // getting raw data bank - if(debugMode>=1) System.out.println("Getting raw hits from FTTRK:adc bank"); + if (debugMode >= 1) { + System.out.println("Getting raw hits from FTTRK:adc bank"); + } - List hits = new ArrayList(); - if(event.hasBank("FTTRK::adc")==true) { + List hits = new ArrayList<>(); + if (event.hasBank("FTTRK::adc") == true) { DataBank bankDGTZ = event.getBank("FTTRK::adc"); int nrows = bankDGTZ.rows(); - if(nrows>FTConstants.TRK_MAXNUMBEROFHITS) return hits; // if too many hits skip the event + if (nrows > FTConstants.TRK_MAXNUMBEROFHITS) { + return hits; // if too many hits skip the event + } int hitId = -1; - for(int row = 0; row < nrows; row++){ - int isector = bankDGTZ.getInt("sector",row); - int ilayer = bankDGTZ.getInt("layer",row); - int icomponent = bankDGTZ.getInt("component",row); - int iorder = bankDGTZ.getInt("order",row); - int adc = bankDGTZ.getInt("ADC",row); - float time = bankDGTZ.getFloat("time", row); - - + for (int row = 0; row < nrows; row++) { + int isector = bankDGTZ.getInt("sector", row); + int ilayer = bankDGTZ.getInt("layer", row); + int icomponent = bankDGTZ.getInt("component", row); + int adc = bankDGTZ.getInt("ADC", row); + float time = bankDGTZ.getFloat("time", row); + /////////////////////////////////////////////////////// insert here operations modifying strip number /////////////////////////////////////////////////////// IN RECO: STRIP NUMBERS: 0-767, layer numbers: 0-3 /////////////////////////////////////////////////////// IN FEE: STRIP NUMBERS: 1-768, layer numbers: 1-4 - // read just layer sectors only for real data (no montecarlo) - // PROVISIONAL: include correct run range for fall18 RGA runs & same FTTRK FEEE configuration - if(run >100) icomponent = renumberFEE2RECRotatedAndAdjust_Fall18RGA(run, ilayer, icomponent); + // PROVISIONAL: include correct run range for fall18 RGA runs & same FTTRK FEE configuration + if (FTTRKConstantsLoader.ADJUSTTT) { + icomponent = renumberFEE2RECRotatedAndAdjust_Fall18RGA(run, ilayer, icomponent); + } - if(adc>FTConstants.FTTRKMinAdcThreshold && adc FTConstants.TRK_ADC_MINIMUM && adc < FTConstants.TRK_ADC_MAXIMUM && time != -1 && icomponent != -1) { + FTTRKHit hit = new FTTRKHit(isector, ilayer, icomponent, (double) adc, (double) time, ++hitId); //////////////////////////////////////////////////////// insert here possible operations selecting strips or groups of strips - // select only one sector at a time, for instance // if(icomponent>64 && icomponent<=128) hits.add(hit); - boolean isHitAccepted = true; // exclude here some layers or sectors, for instance // if((ilayer==4) && icomponent>=1 && icomponent>64) isHitAccepted = false; - + // selection on strip time - if(time < FTConstants.TRK_STRIP_MIN_TIME || time > FTConstants.TRK_STRIP_MAX_TIME) isHitAccepted = false; + if (time < FTConstants.TRK_STRIP_MIN_TIME || time > FTConstants.TRK_STRIP_MAX_TIME) { + isHitAccepted = false; + } // icomponent = -1: strip is off - if(icomponent<0) isHitAccepted = false; - - if(isHitAccepted) hits.add(hit); - } + if (icomponent < 0) { + isHitAccepted = false; + } + + if (isHitAccepted) { + hits.add(hit); + } + } } } // order hits list by component - List hitsOrderedByLay = new ArrayList(); + List hitsOrderedByLay = new ArrayList<>(); // order by layers int Nlayers = FTTRKConstantsLoader.Nlayers; int Nstrips = FTTRKConstantsLoader.Nstrips; - for(int nlayer=1; nlayer<=Nlayers; nlayer++){ - for(FTTRKHit h:hits){ - if(h.get_Layer()==nlayer) hitsOrderedByLay.add(h); + for (int nlayer = 1; nlayer <= Nlayers; nlayer++) { + for (FTTRKHit h : hits) { + if (h.get_Layer() == nlayer) { + hitsOrderedByLay.add(h); + } } } // order by strip - List hitsOrderedByStrip = new ArrayList(); - for(int nlayer=1; nlayer<=Nlayers; nlayer++){ - for(int nstrip=1; nstrip<=Nstrips; nstrip++){ - for(FTTRKHit h: hitsOrderedByLay){ - if(nlayer == h.get_Layer() && nstrip == h.get_Strip()) hitsOrderedByStrip.add(h); + List hitsOrderedByStrip = new ArrayList<>(); + for (int nlayer = 1; nlayer <= Nlayers; nlayer++) { + for (int nstrip = 1; nstrip <= Nstrips; nstrip++) { + for (FTTRKHit h : hitsOrderedByLay) { + if (nlayer == h.get_Layer() && nstrip == h.get_Strip()) { + hitsOrderedByStrip.add(h); + } } - } + } } - + return hitsOrderedByStrip; - } - - public void writeBanks(DataEvent event, List hits, List clusters, List crosses){ - if(event instanceof EvioDataEvent) { - writeEvioBanks(event, hits, clusters, crosses); - } - else if(event instanceof HipoDataEvent) { - writeHipoBanks(event, hits, clusters, crosses); - } } - - - public void writeHipoBanks(DataEvent event, List hits, List clusters, List crosses){ - + + public void writeBanks(DataEvent event, List hits, List clusters, List crosses) { + // hits banks - if(hits.size()!=0) { - DataBank bankHits = event.createBank("FTTRK::hits", hits.size()); - if(bankHits==null){ + if (!hits.isEmpty()) { + DataBank bankHits = event.createBank("FTTRK::hits", hits.size()); + if (bankHits == null) { System.out.println("ERROR CREATING BANK : FTTRK::hits"); return; } - for(int i = 0; i < hits.size(); i++){ - bankHits.setByte("sector",i,(byte) hits.get(i).get_Sector()); - bankHits.setByte("layer",i,(byte) hits.get(i).get_Layer()); - bankHits.setShort("component",i,(short) hits.get(i).get_Strip()); + for (int i = 0; i < hits.size(); i++) { + bankHits.setByte("sector", i, (byte) hits.get(i).get_Sector()); + bankHits.setByte("layer", i, (byte) hits.get(i).get_Layer()); + bankHits.setShort("component", i, (short) hits.get(i).get_Strip()); // bankHits.setFloat("x",i,(float) (hits.get(i).get_Dx()/10.0)); // bankHits.setFloat("y",i,(float) (hits.get(i).get_Dy()/10.0)); // bankHits.setFloat("z",i,(float) (hits.get(i).get_Dz()/10.0)); - bankHits.setFloat("energy",i,(float) hits.get(i).get_Edep()); - bankHits.setFloat("time",i,(float) hits.get(i).get_Time()); - bankHits.setShort("hitID",i,(short) hits.get(i).get_DGTZIndex()); - bankHits.setShort("clusterID",i,(short) hits.get(i).get_ClusterIndex()); + bankHits.setFloat("energy", i, (float) hits.get(i).get_Edep()); + bankHits.setFloat("time", i, (float) hits.get(i).get_Time()); + bankHits.setShort("hitID", i, (short) hits.get(i).get_DGTZIndex()); + bankHits.setShort("clusterID", i, (short) hits.get(i).get_ClusterIndex()); } event.appendBanks(bankHits); } // cluster bank - if(debugMode>=1) System.out.println("cluster bank size " + clusters.size()); - if(clusters.size()!=0){ - DataBank bankCluster = event.createBank("FTTRK::clusters", clusters.size()); - if(bankCluster==null){ + if (debugMode >= 1) { + System.out.println("cluster bank size " + clusters.size()); + } + if (!clusters.isEmpty()) { + DataBank bankCluster = event.createBank("FTTRK::clusters", clusters.size()); + if (bankCluster == null) { System.err.println("ERROR CREATING BANK : FTTRK::clusters"); return; } - for(int i = 0; i < clusters.size(); i++){ - bankCluster.setShort("size", i,(short) clusters.get(i).size()); - bankCluster.setShort("id", i,(short) clusters.get(i).get_CId()); - bankCluster.setByte("sector", i,(byte) clusters.get(i).get_Sector()); - bankCluster.setByte("layer", i,(byte) clusters.get(i).get_Layer()); - bankCluster.setFloat("energy", i,(float) clusters.get(i).get_TotalEnergy()); - bankCluster.setFloat("maxEnergy", i,(float) clusters.get(i).get_SeedEnergy()); - bankCluster.setShort("seed", i,(short) clusters.get(i).get_SeedStrip()); - bankCluster.setFloat("centroid", i,(float) clusters.get(i).get_Centroid()); + for (int i = 0; i < clusters.size(); i++) { + bankCluster.setShort("size", i, (short) clusters.get(i).size()); + bankCluster.setShort("id", i, (short) clusters.get(i).get_CId()); + bankCluster.setByte("sector", i, (byte) clusters.get(i).get_Sector()); + bankCluster.setByte("layer", i, (byte) clusters.get(i).get_Layer()); + bankCluster.setFloat("energy", i, (float) clusters.get(i).get_TotalEnergy()); + bankCluster.setFloat("maxEnergy", i, (float) clusters.get(i).get_SeedEnergy()); + bankCluster.setShort("seed", i, (short) clusters.get(i).get_SeedStrip()); + bankCluster.setFloat("centroid", i, (float) clusters.get(i).get_Centroid()); } event.appendBanks(bankCluster); } // cross bank - if(debugMode>=1) System.out.println("crosses bank size " + crosses.size()); - if(crosses.size()!=0){ + if (debugMode >= 1) { + System.out.println("crosses bank size " + crosses.size()); + } + if (!crosses.isEmpty()) { DataBank bankCross = event.createBank("FTTRK::crosses", crosses.size()); - if(bankCross==null){ + if (bankCross == null) { System.err.println("ERROR CREATING BANK : FTTRK::crosses"); return; - } - for (int j = 0; j < crosses.size(); j++){ - bankCross.setShort("size", j, (short) crosses.size()); - bankCross.setShort("id", j, (short) crosses.get(j).get_trkId()); - bankCross.setByte("sector", j, (byte) crosses.get(j).get_Sector()); - bankCross.setByte("detector", j, (byte) (crosses.get(j).get_Region()-1)); // detector: 0 or 1, region 1 or 2 - bankCross.setFloat("x", j, (float) crosses.get(j).get_Point().x()); - bankCross.setFloat("y", j, (float) crosses.get(j).get_Point().y()); - bankCross.setFloat("z", j, (float) crosses.get(j).get_Point().z()); - if(debugMode>=1) System.out.println("energy and time to be stored in banks " + crosses.get(j).get_Energy() + " " + crosses.get(j).get_Time()); + } + for (int j = 0; j < crosses.size(); j++) { + bankCross.setShort("size", j, (short) crosses.size()); + bankCross.setShort("id", j, (short) crosses.get(j).get_trkId()); + bankCross.setByte("sector", j, (byte) crosses.get(j).get_Sector()); + bankCross.setByte("detector", j, (byte) (crosses.get(j).get_Region() - 1)); // detector: 0 or 1, region 1 or 2 + bankCross.setFloat("x", j, (float) crosses.get(j).get_Point().x()); + bankCross.setFloat("y", j, (float) crosses.get(j).get_Point().y()); + bankCross.setFloat("z", j, (float) crosses.get(j).get_Point().z()); + if (debugMode >= 1) { + System.out.println("energy and time to be stored in banks " + crosses.get(j).get_Energy() + " " + crosses.get(j).get_Time()); + } bankCross.setFloat("energy", j, (float) crosses.get(j).get_Energy()); bankCross.setFloat("time", j, (float) crosses.get(j).get_Time()); bankCross.setShort("Cluster1ID", j, (short) crosses.get(j).get_Cluster1().get_CId()); @@ -524,362 +547,296 @@ public void writeHipoBanks(DataEvent event, List hits, List hits, List clusters, List crosses){ - - EvioDataBank bankHits = null; - EvioDataBank bankCluster = null; - EvioDataBank bankCross = null; - - // hits banks - if(hits.size()!=0) { - bankHits = (EvioDataBank) event.getDictionary().createBank("FTTRK::hits", hits.size()); - if(bankHits==null){ - System.err.println("ERROR CREATING BANK : FTTRK::hits"); - return; - } - - for(int i = 0; i < hits.size(); i++){ - bankHits.setByte("sector",i,(byte) hits.get(i).get_Sector()); - bankHits.setByte("layer",i,(byte) hits.get(i).get_Layer()); - bankHits.setShort("component",i,(short) hits.get(i).get_Strip()); -// bankHits.setFloat("x",i,(float) (hits.get(i).get_Dx()/10.0)); -// bankHits.setFloat("y",i,(float) (hits.get(i).get_Dy()/10.0)); -// bankHits.setFloat("z",i,(float) (hits.get(i).get_Dz()/10.0)); - bankHits.setFloat("energy",i,(float) hits.get(i).get_Edep()); - bankHits.setFloat("time",i,(float) hits.get(i).get_Time()); - bankHits.setShort("hitID",i,(short) hits.get(i).get_DGTZIndex()); - bankHits.setShort("clusterID",i,(short) hits.get(i).get_ClusterIndex()); + + public void updateAllHitsWithAssociatedIDs(List hits, List clusters) { + // update clusterIndex and crossIndex for hits belonging to a cross + for (FTTRKCluster aCluster : clusters) { + for (FTTRKHit ahitInCluster : aCluster) { + for (FTTRKHit aHit : hits) { + if (aHit.get_Id() == ahitInCluster.get_Id()) { + aHit.set_DGTZIndex(ahitInCluster.get_DGTZIndex()); + aHit.set_ClusterIndex(ahitInCluster.get_ClusterIndex()); + aHit.set_CrossIndex(ahitInCluster.get_CrossIndex()); + } + } } - event.appendBanks(bankHits); } - // cluster bank - if(debugMode>=1) System.out.println("cluster bank size " + clusters.size()); - if(clusters.size()!=0){ - bankCluster = (EvioDataBank) event.getDictionary().createBank("FTTRK::clusters", clusters.size()); - if(bankCluster==null){ - System.err.println("ERROR CREATING BANK : FTTRK::clusters"); - return; + } + + public int flipStripVertical(int ilayer, int icomponent) { + // flip the layer vertically with respect to y axis (left/right flip) + // strips numbered 1-768 + if (ilayer == DetectorLayer.FTTRK_LAYER2 || ilayer == DetectorLayer.FTTRK_LAYER3) { // RECO vertical strips + if (icomponent >= (stripDiscontinuity1 + 1) && icomponent <= (stripDiscontinuity2 - 1)) { // [129,384] + icomponent += sideShortStrips; // 256 + } else if (icomponent >= stripDiscontinuity2 && icomponent <= stripDiscontinuity3) { // [385,640] + icomponent -= sideShortStrips; // 256 } - for(int i = 0; i < clusters.size(); i++){ - bankCluster.setShort("size", i,(short) clusters.get(i).size()); - bankCluster.setShort("id", i,(short) clusters.get(i).get_CId()); - bankCluster.setByte("sector", i,(byte) clusters.get(i).get_Sector()); - bankCluster.setByte("layer", i,(byte) clusters.get(i).get_Layer()); - bankCluster.setFloat("energy", i,(float) clusters.get(i).get_TotalEnergy()); - bankCluster.setFloat("maxEnergy", i,(float) clusters.get(i).get_SeedEnergy()); - bankCluster.setShort("seed", i,(short) clusters.get(i).get_SeedStrip()); - bankCluster.setFloat("centroid", i,(float) clusters.get(i).get_Centroid()); + } else if (ilayer == DetectorLayer.FTTRK_LAYER1 || ilayer == DetectorLayer.FTTRK_LAYER4) { // RECO horizontal strips + if (icomponent >= 129 && icomponent <= 384) { // [129,384] + icomponent = 513 - icomponent; // 513 + } else if (icomponent >= stripDiscontinuity2 && icomponent <= stripDiscontinuity3) { // [385,640] + icomponent = 2 * sequentialStrips + 1 - icomponent; // 1025 + } else { // for horizontal strips flip also long strips + icomponent = FTTRKConstantsLoader.Nstrips + 1 - icomponent; // 769 } - event.appendBanks(bankCluster); } - // cross bank - if(debugMode>=1) System.out.println("crosses bank size " + crosses.size()); - if(crosses.size()!=0){ - bankCross = (EvioDataBank) event.getDictionary().createBank("FTTRK::crosses", crosses.size()); - if(bankCross==null){ - System.err.println("ERROR CREATING BANK : FTTRK::crosses"); - return; - } - for (int j = 0; j < crosses.size(); j++) { - bankCross.setShort("size", j, (short) crosses.size()); - bankCross.setShort("id", j, (short) crosses.get(j).get_Id()); - bankCross.setByte("sector", j, (byte) crosses.get(j).get_Sector()); - bankCross.setByte("detector", j, (byte) (crosses.get(j).get_Region()-1)); // detector: 0 or 1, region 1 or 2 - bankCross.setFloat("x", j, (float) crosses.get(j).get_Point().x()); - bankCross.setFloat("y", j, (float) crosses.get(j).get_Point().y()); - bankCross.setFloat("z", j, (float) crosses.get(j).get_Point().z()); - bankCross.setFloat("energy", j, (float) crosses.get(j).get_Energy()); - bankCross.setFloat("time", j, (float) crosses.get(j).get_Time()); - bankCross.setShort("Cluster1ID", j, (short) crosses.get(j).get_Cluster1().get_CId()); - bankCross.setShort("Cluster2ID", j, (short) crosses.get(j).get_Cluster2().get_CId()); + return icomponent; + } + + public int flipStripHorizontal(int ilayer, int icomponent) { + // flip the layer horizontally with respect to the x axis (top/bottom flip) + // strips 1-128 + if (ilayer == DetectorLayer.FTTRK_LAYER1 || ilayer == DetectorLayer.FTTRK_LAYER4) { // RECO vertical strips + if (icomponent >= (stripDiscontinuity1 + 1) && icomponent <= (stripDiscontinuity2 - 1)) { // [129, 384] + icomponent += sideShortStrips; // 256 + } else if (icomponent >= stripDiscontinuity2 && icomponent <= stripDiscontinuity3) { // [385,640] + icomponent -= sideShortStrips; // 256 + } + } else if (ilayer == DetectorLayer.FTTRK_LAYER2 || ilayer == DetectorLayer.FTTRK_LAYER3) { // RECO horizontal strips + if (icomponent >= (stripDiscontinuity1 + 1) && icomponent <= (stripDiscontinuity2 - 1)) { // [129,384] + icomponent = sequentialStrips + 1 - icomponent; // 513 + } else if (icomponent >= stripDiscontinuity2 && icomponent <= stripDiscontinuity3) { // [385,640] + icomponent = 2 * sequentialStrips + 1 - icomponent; // 1025 + } else { + icomponent = FTTRKConstantsLoader.Nstrips + 1 - icomponent; // 769 } - event.appendBanks(bankCross); } - } - - public void updateAllHitsWithAssociatedIDs(List hits, List clusters){ - // update clusterIndex and crossIndex for hits belonging to a cross - for(FTTRKCluster aCluster: clusters){ - for(FTTRKHit ahitInCluster: aCluster){ - for(FTTRKHit aHit: hits){ - if(aHit.get_Id()==ahitInCluster.get_Id()){ - aHit.set_DGTZIndex(ahitInCluster.get_DGTZIndex()); - aHit.set_ClusterIndex(ahitInCluster.get_ClusterIndex()); - aHit.set_CrossIndex(ahitInCluster.get_CrossIndex()); - } - } + return icomponent; + } + + public int overturnModule(int ilayer, int icomponent) { + // rotate of 180 degrees: this incluse a flip with respect to the x axis followed by a flip with respect to y + int icompNew = flipStripHorizontal(ilayer, icomponent); + icompNew = flipStripVertical(ilayer, icompNew); + return icompNew; + } + + public int reverseStripsInSector(int icomponent) { + // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is + // excluded in the sector, [i+1]is included + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + int nsector = findSector(icomponent); + if (nsector > NStripsSectors) { + System.out.println("wrong sector number, check code"); } + int offset = sectorLimits[nsector + 1] - icomponent; + icomponent = sectorLimits[nsector] + 1 + offset; + + return icomponent; } - } - - - public int flipStripVertical(int ilayer, int icomponent){ - // flip the layer vertically with respect to y axis (left/right flip) - // strips numbered 1-768 - if(ilayer==DetectorLayer.FTTRK_LAYER2 || ilayer==DetectorLayer.FTTRK_LAYER3){ // RECO vertical strips - if(icomponent>=(stripDiscontinuity1+1) && icomponent<=(stripDiscontinuity2-1)){ // [129,384] - icomponent += sideShortStrips; // 256 - }else if(icomponent>=stripDiscontinuity2 && icomponent<=stripDiscontinuity3){ // [385,640] - icomponent -= sideShortStrips; // 256 - } - }else if(ilayer==DetectorLayer.FTTRK_LAYER1 || ilayer==DetectorLayer.FTTRK_LAYER4){ // RECO horizontal strips - if(icomponent>=129 && icomponent<=384){ // [129,384] - icomponent = 513 - icomponent; // 513 - }else if(icomponent>=stripDiscontinuity2 && icomponent<=stripDiscontinuity3){ // [385,640] - icomponent = 2*sequentialStrips+1 - icomponent; // 1025 - }else{ // for horizontal strips flip also long strips - icomponent = FTTRKConstantsLoader.Nstrips+1 - icomponent; // 769 + + public int reverseStripInFirstHalf(int icomponent) { + // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is + // excluded in the sector, [i+1]is included + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + int nsector = findSector(icomponent); + if (nsector > NStripsSectors) { + System.out.println("wrong sector number, check code"); } + int halfStrip = (sectorLimits[nsector + 1] - sectorLimits[nsector]) / 2 + sectorLimits[nsector]; + if (icomponent <= halfStrip) { + int offset = halfStrip - icomponent; + icomponent = sectorLimits[nsector] + 1 + offset; + } + return icomponent; } - return icomponent; - } - - public int flipStripHorizontal(int ilayer, int icomponent){ - // flip the layer horizontally with respect to the x axis (top/bottom flip) - // strips 1-128 - if(ilayer==DetectorLayer.FTTRK_LAYER1 || ilayer==DetectorLayer.FTTRK_LAYER4){ // RECO vertical strips - if(icomponent>=(stripDiscontinuity1+1) && icomponent<=(stripDiscontinuity2-1)){ // [129, 384] - icomponent += sideShortStrips; // 256 - }else if(icomponent>=stripDiscontinuity2 && icomponent<=stripDiscontinuity3){ // [385,640] - icomponent -= sideShortStrips; // 256 - } - }else if(ilayer==DetectorLayer.FTTRK_LAYER2 || ilayer==DetectorLayer.FTTRK_LAYER3){ // RECO horizontal strips - if(icomponent>=(stripDiscontinuity1+1) && icomponent<=(stripDiscontinuity2-1)){ // [129,384] - icomponent = sequentialStrips+1 - icomponent; // 513 - }else if(icomponent>=stripDiscontinuity2 && icomponent<=stripDiscontinuity3){ // [385,640] - icomponent = 2*sequentialStrips+1 - icomponent; // 1025 - }else{ - icomponent = FTTRKConstantsLoader.Nstrips+1 - icomponent; // 769 + + public int reverseStripInSecondHalf(int icomponent) { + // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is + // excluded in the sector, [i+1]is included + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + int nsector = findSector(icomponent); + if (nsector > NStripsSectors) { + System.err.println("wrong FTTRK strip sector number, check code"); } + int halfStrip = (sectorLimits[nsector + 1] - sectorLimits[nsector]) / 2 + sectorLimits[nsector]; + if (icomponent > halfStrip) { + int offset = sectorLimits[nsector + 1] - icomponent; + icomponent = halfStrip + offset; + } + return icomponent; } - - return icomponent; - } - -public int overturnModule(int ilayer, int icomponent){ - // rotate of 180 degrees: this incluse a flip with respect to the x axis followed by a flip with respect to y - int icompNew = flipStripHorizontal(ilayer, icomponent); - icompNew = flipStripVertical(ilayer, icompNew); - return icompNew; - } - -public int reverseStripsInSector(int icomponent){ - // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is - // excluded in the sector, [i+1]is included - // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - int nsector = findSector(icomponent); - if(nsector>NStripsSectors) System.out.println("wrong sector number, check code"); - int offset = sectorLimits[nsector+1] - icomponent; - icomponent = sectorLimits[nsector]+1 + offset; - - return icomponent; - } - -public int reverseStripInFirstHalf(int icomponent){ - // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is - // excluded in the sector, [i+1]is included - // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - int nsector = findSector(icomponent); - if(nsector>NStripsSectors) System.out.println("wrong sector number, check code"); - int halfStrip = (sectorLimits[nsector+1]-sectorLimits[nsector])/2 + sectorLimits[nsector]; - if(icomponent <= halfStrip){ - int offset = halfStrip - icomponent; - icomponent = sectorLimits[nsector]+1 + offset; + + public int swapHalves(int icomponent) { + // swap half the module to the opposite half, rigid translation + // the strips are numbered 1-768, the [i] component of sectorLimit vector is + // excluded in the sector, [i+1]is included + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + int nsector = findSector(icomponent); + if (nsector > NStripsSectors) { + System.err.println("wrong FTTRK strip sector number, check code"); + } + int halfWid = (sectorLimits[nsector + 1] - sectorLimits[nsector]) / 2; + int halfStrip = halfWid + sectorLimits[nsector]; + if (icomponent >= halfStrip + 1) { + icomponent -= halfWid; + } else { + icomponent += (halfWid - 1); + } + return icomponent; } - return icomponent; - } - - -public int reverseStripInSecondHalf(int icomponent){ - // reverse the number of strips inside a sector (strips are numbered 1-768, the [i] component of sectorLimit vector is - // excluded in the sector, [i+1]is included - // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - int nsector = findSector(icomponent); - if(nsector>NStripsSectors) System.err.println("wrong FTTRK strip sector number, check code"); - int halfStrip = (sectorLimits[nsector+1]-sectorLimits[nsector])/2 + sectorLimits[nsector]; - if(icomponent > halfStrip){ - int offset = sectorLimits[nsector+1] - icomponent; - icomponent = halfStrip + offset; - } - return icomponent; - } - -public int swapHalves(int icomponent){ - // swap half the module to the opposite half, rigid translation - // the strips are numbered 1-768, the [i] component of sectorLimit vector is - // excluded in the sector, [i+1]is included - // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - int nsector = findSector(icomponent); - if(nsector>NStripsSectors) System.err.println("wrong FTTRK strip sector number, check code"); - int halfWid = (sectorLimits[nsector+1]-sectorLimits[nsector])/2; - int halfStrip = halfWid + sectorLimits[nsector]; - if(icomponent >= halfStrip+1){ - icomponent -= halfWid; - }else{ - icomponent += (halfWid-1); + + public int switchStripOff() { + return -1; } - return icomponent; - } - -public int switchStripOff(){return -1;} - - -public int swapSectors(int icomponent, int nsector2){ - // get the new strip number of the icomponent strip in nsector1 once the sector is swapped to nsector2 - // icomponent strips are numbered 1-768 so the vector sectorLimits contains the number of the starting - // strip of a sector: [i] is excluded from sector i, [i+1] is included - // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - int nsector1 = findSector(icomponent); - int offset = -sectorLimits[nsector1] + icomponent; - int newicomp = sectorLimits[nsector2] + offset; - - return newicomp; -} + public int swapSectors(int icomponent, int nsector2) { + // get the new strip number of the icomponent strip in nsector1 once the sector is swapped to nsector2 + // icomponent strips are numbered 1-768 so the vector sectorLimits contains the number of the starting + // strip of a sector: [i] is excluded from sector i, [i+1] is included + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + int nsector1 = findSector(icomponent); + int offset = -sectorLimits[nsector1] + icomponent; + int newicomp = sectorLimits[nsector2] + offset; -public static int findSector(int icomponent){ - // returns the sector number, corresponding to the component of the lower extreme of the interval - // sectors are numbered 0-20; icomponent strips are numbered 1-768 so the vector sectorLimits contains - // the number of the starting strip of a sector: [i] is excluded from sector i, [i+1] is included - // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - int nsector = -1; - for(int i=0; isectorLimits[i] && icomponent<=sectorLimits[i+1]){ - nsector = i; - break; - } + return newicomp; } - if(nsector>NStripsSectors) System.err.println("wrong FTTRK strip sector number, check code"); - return nsector; -} -public boolean isInSector(int iSector, int icomponent){ - // returns ture is the strip icomponent is in the iSector sector - // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips - if(icomponent>sectorLimits[iSector] && icomponent<=sectorLimits[iSector+1]){ - return true; - }else{ - return false; + public static int findSector(int icomponent) { + // returns the sector number, corresponding to the component of the lower extreme of the interval + // sectors are numbered 0-20; icomponent strips are numbered 1-768 so the vector sectorLimits contains + // the number of the starting strip of a sector: [i] is excluded from sector i, [i+1] is included + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + int nsector = -1; + for (int i = 0; i < NStripsSectors; i++) { + if (icomponent > sectorLimits[i] && icomponent <= sectorLimits[i + 1]) { + nsector = i; + break; + } + } + if (nsector > NStripsSectors) { + System.err.println("wrong FTTRK strip sector number, check code"); + } + return nsector; } -} - - -public int renumberStrip(int ilayer, int icomponent){ - // renumber strips from FEE number (to RECO numbering - // strips numbering 1-768 - int newStripNumber = -1; - if(ilayer==DetectorLayer.FTTRK_LAYER1){ - if((icomponent>=1 && icomponent <=stripDiscontinuity1) || (icomponent>=641 && icomponent<=768)){ //[1,128], [641,768] - newStripNumber = icomponent; - }else if(icomponent>=(stripDiscontinuity1+1) && icomponent<=sideShortStrips){ // [129, 256] - newStripNumber = icomponent+sideShortStrips; // 256 - }else if(icomponent>=(sideShortStrips+1) && icomponent<=sequentialStrips){ // [257, 512] - newStripNumber = icomponent-FTTRKConstantsLoader.Longstrips; // 128 - }else if(icomponent>=(sequentialStrips+1) && icomponent<=stripDiscontinuity3){ // [513, 640] - newStripNumber = icomponent; - } - }else if(ilayer==DetectorLayer.FTTRK_LAYER2 || ilayer==DetectorLayer.FTTRK_LAYER4 || ilayer==DetectorLayer.FTTRK_LAYER3){ - if(icomponent>=(sideShortStrips+1) && icomponent <=sequentialStrips){ // [257, 512] - newStripNumber = icomponent+FTTRKConstantsLoader.Longstrips; // 128 - }else if(icomponent>=(sequentialStrips+1) && icomponent <=stripDiscontinuity3){ // [513, 640] - newStripNumber = icomponent-sideShortStrips; // 256 - }else{ - newStripNumber = icomponent; + + public boolean isInSector(int iSector, int icomponent) { + // returns ture is the strip icomponent is in the iSector sector + // 20 sectors of 32 strips each, except long strips sectors (0, 1, 18, 19) which have 64 strips + if (icomponent > sectorLimits[iSector] && icomponent <= sectorLimits[iSector + 1]) { + return true; + } else { + return false; } } - return (newStripNumber); -} -public int renumberFEE2REC(int run, int ilayer, int icomponent){ -// apply strip renumbering only - if(run>10) icomponent = renumberStrip(ilayer, icomponent); - return icomponent; -} + public int renumberStrip(int ilayer, int icomponent) { + // renumber strips from FEE number (to RECO numbering + // strips numbering 1-768 + int newStripNumber = -1; + if (ilayer == DetectorLayer.FTTRK_LAYER1) { + if ((icomponent >= 1 && icomponent <= stripDiscontinuity1) || (icomponent >= 641 && icomponent <= 768)) { //[1,128], [641,768] + newStripNumber = icomponent; + } else if (icomponent >= (stripDiscontinuity1 + 1) && icomponent <= sideShortStrips) { // [129, 256] + newStripNumber = icomponent + sideShortStrips; // 256 + } else if (icomponent >= (sideShortStrips + 1) && icomponent <= sequentialStrips) { // [257, 512] + newStripNumber = icomponent - FTTRKConstantsLoader.Longstrips; // 128 + } else if (icomponent >= (sequentialStrips + 1) && icomponent <= stripDiscontinuity3) { // [513, 640] + newStripNumber = icomponent; + } + } else if (ilayer == DetectorLayer.FTTRK_LAYER2 || ilayer == DetectorLayer.FTTRK_LAYER4 || ilayer == DetectorLayer.FTTRK_LAYER3) { + if (icomponent >= (sideShortStrips + 1) && icomponent <= sequentialStrips) { // [257, 512] + newStripNumber = icomponent + FTTRKConstantsLoader.Longstrips; // 128 + } else if (icomponent >= (sequentialStrips + 1) && icomponent <= stripDiscontinuity3) { // [513, 640] + newStripNumber = icomponent - sideShortStrips; // 256 + } else { + newStripNumber = icomponent; + } + } + return (newStripNumber); + } + public int renumberFEE2REC(int run, int ilayer, int icomponent) { +// apply strip renumbering only + if (run > 10) { + icomponent = renumberStrip(ilayer, icomponent); + } + return icomponent; + } -public int renumberFEE2RECRotatedAndAdjust_Fall18RGA(int run, int ilayer, int icomponent){ + public int renumberFEE2RECRotatedAndAdjust_Fall18RGA(int run, int ilayer, int icomponent) { // apply the renumbering schema - method 2 - if(run>0){ - icomponent = renumberStrip(ilayer, icomponent); - // overturn layer 1+4 - if(ilayer==DetectorLayer.FTTRK_LAYER1 || ilayer==DetectorLayer.FTTRK_LAYER4) icomponent = overturnModule(ilayer, icomponent); - - int isec1 = -1; - if(ilayer==DetectorLayer.FTTRK_LAYER1){ - isec1 = findSector(icomponent); - if(isec1 == 1){ - icomponent = reverseStripInSecondHalf(icomponent); - }else if(isec1==6){ - icomponent = swapSectors(icomponent, 7); - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==7){ - icomponent = swapSectors(icomponent, 6); - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==13){ - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==14){ - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==18){ - icomponent = reverseStripInFirstHalf(icomponent); - } - - }else if(ilayer==DetectorLayer.FTTRK_LAYER2){ - isec1 = findSector(icomponent); - if(isec1==1){ - icomponent = reverseStripsInSector(icomponent); - if(icomponent>(stripsInLongSector+stripsInShortSector)/2) icomponent -= 8; // 96 - }else if(isec1==3){ - icomponent = reverseStripsInSector(icomponent); - } - - }else if(ilayer==DetectorLayer.FTTRK_LAYER3){ - isec1 = findSector(icomponent); - if(isec1==11){ - icomponent = swapSectors(icomponent, 10); - }else if(isec1==10){ - icomponent = swapSectors(icomponent, 11); - } - // reverse sectors 10-11 + flip horizontal - int newsec = findSector(icomponent); - if(newsec==11 || newsec==10) icomponent = reverseStripsInSector(icomponent); - icomponent = flipStripHorizontal(ilayer, icomponent); - - isec1 = findSector(icomponent); - - if(isec1==8){ - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==14){ - icomponent = swapSectors(icomponent, 15); - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==15){ - icomponent = swapSectors(icomponent, 14); - icomponent = reverseStripsInSector(icomponent); - } - - }else if(ilayer==DetectorLayer.FTTRK_LAYER4){ - isec1 = findSector(icomponent); - if(isec1 == 1){ - icomponent = reverseStripInSecondHalf(icomponent); - }else if(isec1 == 5){ - icomponent = reverseStripsInSector(icomponent); - }else if(isec1 == 6){ - icomponent = reverseStripsInSector(icomponent); - }else if(isec1==18){ - icomponent = swapHalves(icomponent); - icomponent = reverseStripInSecondHalf(icomponent); + if (run > 0) { + icomponent = renumberStrip(ilayer, icomponent); + // overturn layer 1+4 + if (ilayer == DetectorLayer.FTTRK_LAYER1 || ilayer == DetectorLayer.FTTRK_LAYER4) { + icomponent = overturnModule(ilayer, icomponent); } - } - } - return icomponent; -} + int isec1 = -1; + if (ilayer == DetectorLayer.FTTRK_LAYER1) { + isec1 = findSector(icomponent); + if (isec1 == 1) { + icomponent = reverseStripInSecondHalf(icomponent); + } else if (isec1 == 6) { + icomponent = swapSectors(icomponent, 7); + icomponent = reverseStripsInSector(icomponent); + } else if (isec1 == 7) { + icomponent = swapSectors(icomponent, 6); + icomponent = reverseStripsInSector(icomponent); + } else if (isec1 == 13) { + icomponent = reverseStripsInSector(icomponent); + } else if (isec1 == 14) { + icomponent = reverseStripsInSector(icomponent); + } else if (isec1 == 18) { + icomponent = reverseStripInFirstHalf(icomponent); + } + } else if (ilayer == DetectorLayer.FTTRK_LAYER2) { + isec1 = findSector(icomponent); + if (isec1 == 1) { + icomponent = reverseStripsInSector(icomponent); + if (icomponent > (stripsInLongSector + stripsInShortSector) / 2) { + icomponent -= 8; // 96 + } + } else if (isec1 == 3) { + icomponent = reverseStripsInSector(icomponent); + } -} + } else if (ilayer == DetectorLayer.FTTRK_LAYER3) { + isec1 = findSector(icomponent); + if (isec1 == 11) { + icomponent = swapSectors(icomponent, 10); + } else if (isec1 == 10) { + icomponent = swapSectors(icomponent, 11); + } + // reverse sectors 10-11 + flip horizontal + int newsec = findSector(icomponent); + if (newsec == 11 || newsec == 10) { + icomponent = reverseStripsInSector(icomponent); + } + icomponent = flipStripHorizontal(ilayer, icomponent); + + isec1 = findSector(icomponent); + + if (isec1 == 8) { + icomponent = reverseStripsInSector(icomponent); + } else if (isec1 == 14) { + icomponent = swapSectors(icomponent, 15); + icomponent = reverseStripsInSector(icomponent); + } else if (isec1 == 15) { + icomponent = swapSectors(icomponent, 14); + icomponent = reverseStripsInSector(icomponent); + } + } else if (ilayer == DetectorLayer.FTTRK_LAYER4) { + isec1 = findSector(icomponent); + if (isec1 == 1) { + icomponent = reverseStripInSecondHalf(icomponent); + } else if (isec1 == 5) { + icomponent = reverseStripsInSector(icomponent); + } else if (isec1 == 6) { + icomponent = reverseStripsInSector(icomponent); + } else if (isec1 == 18) { + icomponent = swapHalves(icomponent); + icomponent = reverseStripInSecondHalf(icomponent); + } + } + } + return icomponent; + } +} diff --git a/reconstruction/ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java b/reconstruction/ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java index ac71e999d9..4156f882b5 100644 --- a/reconstruction/ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java +++ b/reconstruction/ft/src/test/java/org/jlab/service/ft/FTEBEngineTest.java @@ -630,11 +630,11 @@ public static void main(String arg[]){ // if the cluster is formed by >= 3 strips take the centroid int clustsize1 = bankcl.getShort("size", icl1ok); int clustsize2 = bankcl.getShort("size", icl2ok); - if(clustsize1>=FTConstants.TRK_MIN_ClusterSizeForCentroid){ + if(clustsize1>=FTConstants.TRK_MIN_CLUSTER_SIZE_CENTROID){ int sector = FTTRKReconstruction.findSector(seed1); if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed1 = cent1; } - if(clustsize2>=FTConstants.TRK_MIN_ClusterSizeForCentroid){ + if(clustsize2>=FTConstants.TRK_MIN_CLUSTER_SIZE_CENTROID){ int sector = FTTRKReconstruction.findSector(seed2); if(!(sector == 0 || sector == 1 || sector == 18 || sector == 19)) seed2 = cent2; } From ba2fa03538ef27fb9fba0c4c28c4e9196277338d Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Thu, 9 Jun 2022 19:22:32 -0400 Subject: [PATCH 103/104] adding the fttrk service to data-aicv.yaml --- etc/services/data-aicv.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etc/services/data-aicv.yaml b/etc/services/data-aicv.yaml index 8fa3eee2bd..a9ebc0da9f 100644 --- a/etc/services/data-aicv.yaml +++ b/etc/services/data-aicv.yaml @@ -12,6 +12,8 @@ services: name: FTCAL - class: org.jlab.rec.ft.hodo.FTHODOEngine name: FTHODO + - class: org.jlab.rec.ft.trk.FTTRKEngine + name: FTTRK - class: org.jlab.rec.ft.FTEBEngine name: FTEB # DC clustering: nominal algoritm, filled the cluster bank for ai and conventional tracking From d281b37588bfd38351eb28ca48034c4ddd6acad2 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Fri, 10 Jun 2022 12:18:39 -0400 Subject: [PATCH 104/104] removed provisial setting of FT particle charge based on the tracker --- .../ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index 01cd16a649..e9db393b35 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -166,7 +166,7 @@ public void matchToTRKTwoDetectorsMultiHits(List responses, List 0) { if (debugMode >= 1) System.out.println("found signal in FTTRK" + iTrk[k][j]); - track.setCharge(-999); // provisional, for no field tracking +// track.setCharge(-999); // provisional, for no field tracking track.setTrackerIndex(responses.get(iTrk[k][j]).getId(), j); responses.get(iTrk[k][j]).setHitIndex(iTrk[k][j]); responses.get(iTrk[k][j]).setAssociation(i);