From a8dc3b47ecbdafa51ce67d2e04c484cd30819282 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Tue, 14 Jul 2026 13:54:02 -0400 Subject: [PATCH 01/10] remove debug and timing stuff --- .../org/jlab/rec/rich/RICHCalibration.java | 118 +----- .../java/org/jlab/rec/rich/RICHCluster.java | 10 +- .../java/org/jlab/rec/rich/RICHEBEngine.java | 31 +- .../main/java/org/jlab/rec/rich/RICHEdge.java | 15 +- .../java/org/jlab/rec/rich/RICHEvent.java | 9 - .../org/jlab/rec/rich/RICHEventBuilder.java | 354 ++---------------- .../main/java/org/jlab/rec/rich/RICHHit.java | 12 - .../jlab/rec/rich/RICHPMTReconstruction.java | 319 ++++------------ .../org/jlab/rec/rich/RICHParameters.java | 32 -- .../java/org/jlab/rec/rich/RICHParticle.java | 173 +-------- .../java/org/jlab/rec/rich/RICHRayTrace.java | 270 +------------ .../java/org/jlab/rec/rich/RICHRecoType.java | 24 +- .../java/org/jlab/rec/rich/RICHSolution.java | 36 +- .../main/java/org/jlab/rec/rich/RICHTime.java | 88 ----- .../main/java/org/jlab/rec/rich/RICHio.java | 125 +------ 15 files changed, 159 insertions(+), 1457 deletions(-) delete mode 100644 reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTime.java diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHCalibration.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHCalibration.java index 00ae47b625..74513dd66a 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHCalibration.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHCalibration.java @@ -15,16 +15,8 @@ */ public class RICHCalibration{ - private final static int NSEC = RICHGeoConstants.NSEC; - private final static int NLAY = RICHGeoConstants.NLAY; - private final static int NPMT = RICHGeoConstants.NPMT; - private final static int NPIX = RICHGeoConstants.NPIX; - private final static int NCOMPO = RICHGeoConstants.NCOMPO; - private final static int NWALK = RICHGeoConstants.NWALK; - - private final static int NAERMAX = RICHGeoConstants.NAERMAX; - - private static IndexedTable richTable; + private RICHParameters richpar; + private IndexedTable richTable; private ArrayList timewalkTables = new ArrayList<>(); private ArrayList timeoffTables = new ArrayList<>(); private ArrayList anglerefTables = new ArrayList<>(); @@ -32,22 +24,17 @@ public class RICHCalibration{ private ArrayList pixstatusTables = new ArrayList<>(); private ArrayList aerstatusTables = new ArrayList<>(); private ArrayList mirstatusTables = new ArrayList<>(); - - private RICHParameters richpar; - - private double aero_chele_dir[][][] = new double[4][NAERMAX][225]; - private double aero_chele_lat[][][] = new double[4][NAERMAX][225]; - private double aero_chele_spe[][][] = new double[4][NAERMAX][225]; - private double aero_schele_dir[][][] = new double[4][NAERMAX][225]; - private double aero_schele_lat[][][] = new double[4][NAERMAX][225]; - private double aero_schele_spe[][][] = new double[4][NAERMAX][225]; + private double aero_chele_dir[][][] = new double[4][RICHGeoConstants.NAERMAX][225]; + private double aero_chele_lat[][][] = new double[4][RICHGeoConstants.NAERMAX][225]; + private double aero_chele_spe[][][] = new double[4][RICHGeoConstants.NAERMAX][225]; + private double aero_schele_dir[][][] = new double[4][RICHGeoConstants.NAERMAX][225]; + private double aero_schele_lat[][][] = new double[4][RICHGeoConstants.NAERMAX][225]; + private double aero_schele_spe[][][] = new double[4][RICHGeoConstants.NAERMAX][225]; public RICHCalibration() {} public void load_CCDB(ConstantsManager manager, int run, int ncalls, RICHGeoFactory richgeo, RICHParameters richpar){ - int debugMode = 0; - this.richpar = richpar; this.richTable = richgeo.get_richTable(); @@ -72,75 +59,18 @@ public void load_CCDB(ConstantsManager manager, int run, int ncalls, RICHGeoFact manager.getConstants(run, stat_pmts), manager.getConstants(run, stat_mirr) ); - /*if(irich==1){ - // first RICH module - init_CalConstantsCCDB( manager.getConstants(run, "/calibration/rich/module1/time_walk"), - manager.getConstants(run, "/calibration/rich/module1/time_offset"), - manager.getConstants(run, "/calibration/rich/module1/cherenkov_angle"), - manager.getConstants(run, "/calibration/rich/module1/status_aerogel"), - manager.getConstants(run, "/calibration/rich/module1/mapmt_pixel"), - manager.getConstants(run, "/calibration/rich/module1/status_mapmt"), - manager.getConstants(run, "/calibration/rich/module1/status_mirror"), irich ); - }else{ - // second RICH module - init_CalConstantsCCDB( manager.getConstants(run, "/calibration/rich/module2/time_walk"), - manager.getConstants(run, "/calibration/rich/module2/time_offset"), - manager.getConstants(run, "/calibration/rich/module2/cherenkov_angle"), - manager.getConstants(run, "/calibration/rich/module2/status_aerogel"), - manager.getConstants(run, "/calibration/rich/module2/mapmt_pixel"), - manager.getConstants(run, "/calibration/rich/module2/status_mapmt"), - manager.getConstants(run, "/calibration/rich/module2/status_mirror"), irich ); - }*/ - - if((debugMode>=1 || richpar.DEBUG_CAL_COST>=1) && ncalls=1 || richpar.DEBUG_CAL_COST>=1) && ncalls=1 || richpar.DEBUG_CAL_COST>=1) && ncalls=1 || richpar.DEBUG_CAL_COST>=1) && ncalls=1 || richpar.DEBUG_CAL_COST>=1) && ncalls=1 || richpar.DEBUG_CAL_COST>=1) && ncalls=382)System.out.format("CCDB RICH TOFF ipmt %4d %8.3f (ch1) %8.3f (ch2) %8.3f (ch63) %8.3f (ch64) \n", ipmt, -get_PixelTimeOff(isec, ipmt, 1), -get_PixelTimeOff(isec, ipmt, 2), -get_PixelTimeOff(isec, ipmt, 63), -get_PixelTimeOff(isec, ipmt, 64)); @@ -312,7 +231,7 @@ public void dump_TimeConstants(int irich) { if(ipmt==391)System.out.format(" \n"); } - for(int ipmt=1; ipmt<=NPMT; ipmt++){ + for(int ipmt=1; ipmt<=RICHGeoConstants.NPMT; ipmt++){ if(ipmt<=10 || ipmt>=382)System.out.format("CCDB RICH TWALK ipmt %4d D0 = %8.3f T0 = %8.3f m1 = %8.4f m2 = %8.4f\n", ipmt, timewalkTables.get(irich-1).getDoubleValue("D0", isec, ipmt, 0), timewalkTables.get(irich-1).getDoubleValue("m1", isec, ipmt, 0), timewalkTables.get(irich-1).getDoubleValue("m2", isec, ipmt, 0), timewalkTables.get(irich-1).getDoubleValue("T0", isec, ipmt, 0)); @@ -330,7 +249,7 @@ public void dump_PixelConstants(int irich) { int isec = find_RICHSector(irich); if(isec==0) return; - for(int ipmt=1; ipmt<=NPMT; ipmt++){ + for(int ipmt=1; ipmt<=RICHGeoConstants.NPMT; ipmt++){ if(ipmt<=2 || ipmt>=390)System.out.format("CCDB PIXEL GAIN ipmt %4d %8.2f (ch1) %8.2f (ch2) %8.2f (ch63) %8.2f (ch64) \n", ipmt, get_PixelGain(isec, ipmt, 1), get_PixelGain(isec, ipmt, 2), get_PixelGain(isec, ipmt, 63), get_PixelGain(isec, ipmt, 64)); @@ -359,10 +278,9 @@ public void dump_PixelConstants(int irich) { } System.out.format(" \n"); - int p_dead = 0; - for(int ipmt=1; ipmt<=NPMT; ipmt++){ - for(int ianode=1; ianode<=NPIX; ianode++){ + for(int ipmt=1; ipmt<=RICHGeoConstants.NPMT; ipmt++){ + for(int ianode=1; ianode<=RICHGeoConstants.NPIX; ianode++){ if(get_PixelStatus(isec, ipmt, ianode)==2){ System.out.format("CCDB PIXEL DEAD Sec %4d PMT %4d Anode %6d Status %6d \n",isec, ipmt, ianode, get_PixelStatus(isec, ipmt, ianode)); p_dead++; @@ -372,8 +290,8 @@ public void dump_PixelConstants(int irich) { int p_hot = 0; System.out.format(" \n"); - for(int ipmt=1; ipmt<=NPMT; ipmt++){ - for(int ianode=1; ianode<=NPIX; ianode++){ + for(int ipmt=1; ipmt<=RICHGeoConstants.NPMT; ipmt++){ + for(int ianode=1; ianode<=RICHGeoConstants.NPIX; ianode++){ if(get_PixelStatus(isec, ipmt, ianode)==5){ System.out.format("CCDB PIXEL HOT Sec %4d PMT %4d Anode %6d Status %6d \n",isec, ipmt, ianode, get_PixelStatus(isec, ipmt, ianode)); p_hot++; @@ -475,7 +393,6 @@ public void dump_MirrorConstants(int irich) { public double get_SChElectron(int isec, int ila, int ico, int iqua, int irefle, int icharge) { - if(ico<0 || ico>=RICHGeoConstants.NAERCO[ila]) return 0.0; int irich = find_RICHModule(isec); if(irich==0) return 0.0; @@ -574,7 +491,6 @@ public int get_AeroStatus(int isec, int ila, int ico, int iqua) { int irow = ico*225+iqua+1; return aerstatusTables.get(irich-1).getIntValue("status", isec, 201+ila, irow); - } @@ -588,7 +504,6 @@ public int get_MirrorStatus(int isec, int ila, int ico) { if(lla==-1 || cco==-1) return 0; return mirstatusTables.get(irich-1).getIntValue("status", isec, lla, cco); - } @@ -705,11 +620,8 @@ public int find_RICHModule(int isec){ public int find_RICHSector(int irich){ - int debugMode = 0; - for (int isec=1; isec<=RICHGeoConstants.NSEC; isec++){ if(richTable.hasEntry(isec,0,0)){ - if(debugMode>=1)System.out.format(" trovo %4d <--> %4d \n",irich, richTable.getIntValue("module", isec, 0, 0)); if(richTable.getIntValue("module", isec, 0, 0) == irich) return isec; } } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHCluster.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHCluster.java index be4f6d588c..0758f33283 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHCluster.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHCluster.java @@ -3,11 +3,10 @@ import java.util.ArrayList; import org.jlab.geom.prim.Point3D; -public class RICHCluster extends ArrayList { - - /** - * A cluster in the RICH consists of an array of anodes in one PMT - */ +/** + * A cluster in the RICH consists of an array of anodes in one PMT + */ +public final class RICHCluster extends ArrayList { private int clusid; // cluster ID private int signal; // pointer to the derived RICH signal @@ -44,7 +43,6 @@ public double get_charge() { // ---------------- public int get_iMax() { // return anode with maximum charge - int imax = 0; double maxcharge = 0; for(int i=0; i=1)System.out.format("I am in RICHEBEngine init \n"); - String[] richTables = new String[]{ "/geometry/rich/setup", "/geometry/rich/geo_parameter", @@ -65,34 +61,21 @@ public boolean init() { @Override public void detectorChanged(int runNumber) { richgeo = new RICHGeoFactory(1, this.getConstantsManager(), runNumber, engineDebug); - richtime.init_ProcessTime(); } @Override public boolean processDataEventUser(DataEvent event) { - int debugMode = 0; - // create instances of all event-dependent classes in processDataEventUser to avoid interferences between different threads when running in clara RICHEvent richevent = new RICHEvent(); RICHio richio = new RICHio(); RICHCalibration richcal = new RICHCalibration(); RICHParameters richpar = new RICHParameters(); - RICHPMTReconstruction rpmt = new RICHPMTReconstruction(richevent, richgeo, richio); RICHEventBuilder reb = new RICHEventBuilder(event, richevent, richgeo, richio); RICHRayTrace richtrace = new RICHRayTrace(richgeo, richpar); - richtime.save_ProcessTime(0, richevent); - - if(debugMode>=1){ - System.out.println("---------------------------------"); - System.out.println("RICH Engine call: "+Ncalls+" New Event Process "+richevent.get_EventID()); - System.out.println("---------------------------------"); - } - // Initialize the CCDB information - if(debugMode>=1)System.out.println("----- Load CCDB data \n"); int run = richevent.get_RunID(); if(run>0){ richpar.load_CCDB(this.getConstantsManager(), run, Ncalls, engineDebug); @@ -103,28 +86,18 @@ public boolean processDataEventUser(DataEvent event) { } Ncalls++; - richtime.save_ProcessTime(1, richevent); - - // Process RICH signals to get hits and clusters if(richpar.PROCESS_RAWDATA==1){ - if(debugMode>=1)System.out.println("----- Process raw data \n"); richio.clear_LowBanks(event); rpmt.process_RawData(event, richpar, richcal); - richtime.save_ProcessTime(2, richevent); } // Process RICH-DC event reconstruction if(richpar.PROCESS_DATA==1){ - if(debugMode>=1)System.out.println("----- Process data \n"); richio.clear_HighBanks(event); - if( !reb.process_Data(event, richpar, richcal, richtrace, richtime)) return false; - richtime.save_ProcessTime(8, richevent); + if( !reb.process_Data(event, richpar, richcal, richtrace)) return false; } - if(richpar.DEBUG_PROC_TIME>=1) richtime.dump_ProcessTime(); - return true; - } } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEdge.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEdge.java index 8c426546db..f2b56fe8de 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEdge.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEdge.java @@ -8,9 +8,6 @@ public RICHEdge(int i, int isector, int ilayer, int icomponent, int iorder, int this.sector = isector; this.tile = ilayer; this.channel = icomponent; - this.anode = 0; - this.idx = 0; - this.idy = 0; this.polarity = iorder; this.tdc = itdc; } @@ -19,9 +16,6 @@ public RICHEdge(int i, int isector, int ilayer, int icomponent, int iorder, int private int sector; // Sector private int tile; // Front-End TILE ID private int channel; // MAROC channel - private int anode; // MA-PMT anode - private int idx; // MA-PMT idx - private int idy; // MA-PMT idy private int polarity; // Edge polarity private int tdc; // Edge TDC private int hit; // Hit belonging to @@ -42,12 +36,7 @@ public RICHEdge(int i, int isector, int ilayer, int icomponent, int iorder, int public void set_hit(int hit) { this.hit = hit; } public boolean pass_EdgeSelection() { - // a selection cut to pass the edge - if(this.get_tdc() > 0) { - return true; - } else { - return false; - } + return this.get_tdc() > 0; } /* @@ -61,7 +50,6 @@ public int compareTo(RICHEdge oedge) { }*/ public int compareTo(RICHEdge oedge) { - //System.out.println(" --> comp "+this.get_channel()+" "+this.get_tdc()+" "+oedge.get_channel()+" "+oedge.get_tdc()); if(this.get_tdc() == oedge.get_tdc())return 0; if(this.get_tdc() > oedge.get_tdc()){ return 1; @@ -70,7 +58,6 @@ public int compareTo(RICHEdge oedge) { } } - public void showEdge() { System.out.println( + this.get_id() + "\t" diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEvent.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEvent.java index 4444c1a6f3..0035099602 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEvent.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEvent.java @@ -18,7 +18,6 @@ public class RICHEvent { private int runID; private int eventID; private float eventTime; - private long CPUTime; private int phase; private ArrayList clusters = new ArrayList<>(); @@ -44,7 +43,6 @@ public void clear(){ public void set_RunID(int ID) { runID = ID; } public void set_EventID(int ID) { eventID = ID; } public void set_EventTime(float time) { eventTime = time; } - public void set_CPUTime(long CPUTime) { this.CPUTime = CPUTime; } public int getFTOFphase() {return phase;} public void add_Hit(RICHHit hit){ hits.add(hit); } public void add_Cluster(RICHCluster cluster){ clusters.add(cluster); } @@ -63,7 +61,6 @@ public void clear(){ public int get_RunID() {return runID;} public int get_EventID() {return eventID;} public float get_EventTime() {return eventTime;} - public long get_CPUTime() {return CPUTime;} public void setFTOFphase(int phase) { this.phase = phase; } public RICHCluster get_Cluster(int i){ return clusters.get(i); } public RICHHit get_Hit(int i){ return hits.get(i); } @@ -120,13 +117,9 @@ public void select_Signals() { public int count_Signals() { - - int debugMode = 0; - int nsig = 0; for( RICHHit hit: hits) if(hit.get_signal()>0)nsig++; for( RICHCluster clu: clusters) if(clu.get_signal()>0) nsig++; - return nsig; } @@ -390,8 +383,6 @@ public void get_HypoPID(RICHParticle hadron, int recotype, RICHParameters richpa double ma_lat[] = {0.0, 0.0, 0.0, 0.0}; double ma_spe[] = {0.0, 0.0, 0.0, 0.0}; - double ch_had = 0.0; - for (int hypo=0; hypo pindex_map = new HashMap<>(); - private static double RAD=180/Math.PI; public RICHEventBuilder(DataEvent event, RICHEvent richeve, RICHGeoFactory richgeo, RICHio richio) { - this.richevent = richeve; this.richio = richio; this.richgeo = richgeo; - this.clasevent = new DetectorEvent(); - + clasevent = new DetectorEvent(); clasevent.clear(); richevent.clear(); - set_EventInfo(event); } - - public boolean process_Data(DataEvent event, RICHParameters richpar, RICHCalibration richcal, RICHRayTrace richtrace, RICHTime richtime) { + public boolean process_Data(DataEvent event, RICHParameters richpar, RICHCalibration richcal, RICHRayTrace richtrace) { - int debugMode = 0; - - /* - * look for RICH - DC matches - */ - if(debugMode>=1)System.out.format("process_DCData \n"); + // look for RICH - DC matches if(!process_DCData(event, richpar)) return false; - richtime.save_ProcessTime(3, richevent); - + richio.write_RECBank(event, richevent, richpar); - /* - * create RICH particles - */ - if(debugMode>=1)System.out.format("process_RICHData\n"); + // create RICH particles if(!process_RICHData(event, richtrace, richpar, richcal)) return false; - richtime.save_ProcessTime(4, richevent); - /* - * analytic solution (direct light only) - */ - if(debugMode>=1)System.out.format("analyze_Cherenkovs\n"); + // analytic solution (direct light only) if(!analyze_Cherenkovs(richtrace, richpar)) return false; - richtime.save_ProcessTime(5, richevent); - /* - * ray-traced solution (all photons) - */ - if(debugMode>=1)System.out.format("reco_Cherenkovs\n"); + // ray-traced solution (all photons) if(!reco_Cherenkovs(richtrace, richpar, richcal)) return false; - richtime.save_ProcessTime(6, richevent); - - if(debugMode>=1)richevent.showEvent(); richio.write_CherenkovBanks(event, richevent, richpar); - richtime.save_ProcessTime(7, richevent); return true; - } public boolean process_DCData(DataEvent event, RICHParameters richpar) { - int debugMode = 0; - - /* - Load tracks from time based tracking - */ - if(debugMode>=1){ - System.out.println("---------------------------------"); - System.out.println("RICH EB: Load Tracks"); - System.out.println("---------------------------------"); - } - - if(!read_ForwardTracks(event)){ - if(debugMode>=1)System.out.print(" no useful track in RICH sectors --> disregard RICH reco \n"); - return false; - } + // Load tracks from time based tracking + if(!read_ForwardTracks(event)) return false; - /* - Load the cluster information - */ + // Load the cluster information if(richpar.USE_SIGNAL_BANK==1){ richevent.add_ResClus( RingCherenkovResponse.readHipoEvent(event, "RICH::Signal",DetectorType.RICH,1) ); }else{ richevent.add_ResClus( RingCherenkovResponse.readHipoEvent(event, "RICH::Cluster",DetectorType.RICH,1) ); } - if(debugMode>=1){ - if(richevent.get_nResClu()>0){ - System.out.format(" ----------------------------------------- \n"); - if(richpar.USE_SIGNAL_BANK==1){ - System.out.format(" RICH EB: clus reloaded from RICH::Signal \n"); - }else{ - System.out.format(" RICH EB: clus reloaded from RICH::Cluster \n"); - } - System.out.format(" ----------------------------------------- \n"); - for (DetectorResponse rclu: richevent.get_ResClus()){ - System.out.format("RICHEB Load Clu : --> id %4d pmt %5d ene %8.1f time %8.2f pos %s \n", - rclu.getHitIndex(),rclu.getDescriptor().getComponent(),rclu.getEnergy(),rclu.getTime(),rclu.getPosition().toStringBrief(1)); - } - } - } - - /* - Perform the DC tracks to RICH clusters matching - */ - if(debugMode>=1){ - System.out.println("---------------------------------"); - System.out.println("RICH EB: Perform Track-RICH Matching"); - System.out.println("---------------------------------"); - } + // Perform the DC tracks to RICH clusters matching process_HitMatching(richpar); - if(clasevent.getParticles().size()>0)richevent.add_Matches(getRichResponseList()); + if(!clasevent.getParticles().isEmpty())richevent.add_Matches(getRichResponseList()); return true; - } public boolean process_RICHData(DataEvent event, RICHRayTrace richtrace, RICHParameters richpar, RICHCalibration richcal) { - - int debugMode = 0; - - if(debugMode>=1){ - System.out.println("---------------------------------"); - System.out.format(" Reco hadrons and photons with npart %d nmatches %d \n", clasevent.getParticles().size(), get_nMatch()); - System.out.println("---------------------------------"); - } - - /* - Load the hit information - */ if(richpar.USE_SIGNAL_BANK==1){ richevent.add_ResHits( RingCherenkovResponse.readHipoEvent(event, "RICH::Signal",DetectorType.RICH,0) ); }else{ richevent.add_ResHits( RingCherenkovResponse.readHipoEvent(event, "RICH::Hit",DetectorType.RICH,0) ); } - - if(richevent.get_nResHit()>0){ - if(debugMode>=1){ - System.out.format(" --------------------------------------- \n"); - if(richpar.USE_SIGNAL_BANK==1){ - System.out.format(" RICH EB: hits reloaded from RICH::Signal\n"); - }else{ - System.out.format(" RICH EB: hits reloaded from RICH::Hit\n"); - } - System.out.format(" --------------------------------------- \n"); - for (DetectorResponse rhit: richevent.get_ResHits()){ - System.out.format(" --> id %4d sec %3d pmt %5d ene %8.1f time %8.2f pos %8.1f %8.1f %8.1f \n", - rhit.getHitIndex(),rhit.getDescriptor().getSector(),rhit.getDescriptor().getComponent(), - rhit.getEnergy(),rhit.getTime(),rhit.getPosition().x(),rhit.getPosition().y(),rhit.getPosition().z()); - } - } - } - - if(clasevent.getParticles().size()>0){ + if(!clasevent.getParticles().isEmpty()){ if(find_Hadrons(richtrace, richcal, richpar)){ if(richevent.get_nResHit()>0){ - if(!find_Photons(richevent.get_ResHits(), richpar, richcal)){ - if(debugMode>=1)System.out.println("Found no RICH photon \n"); - } - }else{ - if(debugMode>=1)System.out.println("Found no RICH hits \n"); + find_Photons(richevent.get_ResHits(), richpar, richcal); } - }else{ - if(debugMode>=1)System.out.println("Found no RICH hadron \n"); } - }else{ - if(debugMode>=1)System.out.println("Found no CLAS particle in sector 4 \n"); } - return true; - } public boolean read_ForwardTracks(DataEvent event) { - int debugMode = 0; - if(event.hasBank("REC::Track") && event.hasBank("REC::Particle") && event.hasBank("REC::Traj")){ DataBank tbank = event.getBank("REC::Track"); DataBank pbank = event.getBank("REC::Particle"); DataBank rbank = event.getBank("REC::Traj"); - if(debugMode>=1) System.out.format("Look for tracks after EB: REC:tk %3d REC:part %3d REC:Traj %3d \n",tbank.rows(),pbank.rows(),rbank.rows()); for(int i = 0 ; i < tbank.rows(); i++){ @@ -232,14 +123,7 @@ public boolean read_ForwardTracks(DataEvent event) { tr.setVertex(vertex.x(), vertex.y(), vertex.z()); tr.setSector(isec); - if(debugMode>=1){ - System.out.format(" from REC::Track %3d det %4d --> tk %4d sec %4d theta %8.2f --> part %4d pid %d \n", - i,idet,itk,tr.getSector(), pvec.theta()*RAD,ipr,CLASpid); - } - - /* - * disregard central detector tracks - */ + // disregard central detector tracks if(idet!=6)continue; if(!richgeo.has_RICH(isec)) continue; @@ -257,11 +141,8 @@ public boolean read_ForwardTracks(DataEvent event) { int jdet = (int) rbank.getByte("detector",j); int jlay = (int) rbank.getByte("layer",j); if (jpr==ipr && jtk==itk){ - if(debugMode>=1) System.out.format("traj %3d part %3d tk %3d det %3d lay %3d ",j,jpr,jtk,jdet,jlay); - /* - * trajectory plane 42 till 5b.6.2 - 40 since 5c.7.0 - layer 36 since 6b.1.0 - */ + // trajectory plane 42 till 5b.6.2 - 40 since 5c.7.0 - layer 36 since 6b.1.0 if( (jdet==DetectorType.DC.getDetectorId() && jlay==36) || jdet==DetectorType.RICH.getDetectorId()){ double jx = (double) rbank.getFloat("x",j); double jy = (double) rbank.getFloat("y",j); @@ -277,32 +158,24 @@ public boolean read_ForwardTracks(DataEvent event) { if(jdet==DetectorType.DC.getDetectorId() && jlay==36){ traj_cross[0] = new Line3D(jx, jy, jz, vdir.x(), vdir.y(), vdir.z()); traj_path[0] = path; - if(debugMode>=1) System.out.format(" --> DC3 "); ntraj_cross++; } if(jdet==DetectorType.RICH.getDetectorId() && jlay==1){ traj_cross[1] = new Line3D(jx, jy, jz, vdir.x(), vdir.y(), vdir.z()); traj_path[1] = path; - if(debugMode>=1) System.out.format(" --> PMT "); ntraj_cross++; } if(jdet==DetectorType.RICH.getDetectorId() && jlay>=2 && jlay<=4){ aero_cross[naero_cross] = new Line3D(jx, jy, jz, vdir.x(), vdir.y(), vdir.z()); aero_path[naero_cross] = path; aero_lay[naero_cross] = jlay; - if(debugMode>=1) System.out.format(" --> AER "); naero_cross++; } - if(debugMode>=1) System.out.format(" --> %7.2f %7.2f %7.2f | %7.2f %7.2f %7.2f -> %s | path %7.2f ", - jx,jy,jz,jcx,jcy,jcz,vdir.toStringBrief(2),path); } - - if(debugMode>=1) System.out.format(" [%3d % 3d]\n",ntraj_cross,naero_cross); } } //overwrite DC3 with first AERO if present - if(debugMode>=1) System.out.format(" AERO: %4d cross found \n",naero_cross); if(naero_cross>0){ double minpath = 999.; for (int ia=0; ia=1) System.out.format(" take aero %3d %3d path %7.2f \n",ia,aero_lay[ia],traj_path[0]); } } } int detid = DetectorType.RICH.getDetectorId(); - if(debugMode>=1) System.out.format(" TRAJ: %4d crosses found \n",ntraj_cross); for (int k=0; k0){ tr.addCross(traj_cross[k].origin().x(), traj_cross[k].origin().y(), traj_cross[k].origin().z(), traj_cross[k].end().x(), traj_cross[k].end().y(), traj_cross[k].end().z() ); tr.getTrajectory().add(new DetectorTrack.TrajectoryPoint(detid, k, traj_cross[k], (float) traj_path[k], (float) 0., (float) 0.)); tr.setPath(traj_path[k]); - if(debugMode>=1) System.out.format(" TRAJ: store cross %4d: %3d %3d with path %7.2f \n",k,DetectorType.RICH.getDetectorId(),k,traj_path[k]); } } - if(tr.getCrossCount()==0){if(debugMode>=1)System.out.format("Traj not found \n"); continue;} - tr.setStatus(ipr); - if(debugMode>=1) { - System.out.format(" Track cross N %4d first %s %s %7.2f last %s %s %7.2f path %7.2f status %3d \n \n", tr.getCrossCount(), - tr.getFirstCross().origin().toStringBrief(2), tr.getFirstCross().end().toStringBrief(2), - tr.getPathLength(DetectorType.RICH, 0), - tr.getLastCross().origin().toStringBrief(2), tr.getLastCross().end().toStringBrief(2), - tr.getPathLength(DetectorType.RICH, 1), tr.getPath(),tr.getStatus() ); - } DetectorParticle particle = new DetectorParticle(tr); particle.setPid(CLASpid); @@ -356,15 +217,7 @@ public boolean read_ForwardTracks(DataEvent event) { String trackBank = "TimeBasedTrkg::TBTracks"; String tracjBank = "TimeBasedTrkg::Trajectory"; String covBank = "TimeBasedTrkg::TBCovMat"; - if(debugMode>=1) System.out.format("Look for tracks before EB: %s %s %s \n",trackBank,tracjBank,covBank); - List tracks = DetectorData.readDetectorTracks(event, trackBank, tracjBank, covBank); - if(debugMode>=1){ - for(int i = 0 ; i < tracks.size(); i++){ - Line3D test = tracks.get(i).getLastCross(); - System.out.format(" %d sec %d %s\n", i,tracks.get(i).getSector(),test.origin().toString()); - } - } for(int i = 0 ; i < tracks.size(); i++){ DetectorTrack tr = tracks.get(i); @@ -377,53 +230,20 @@ public boolean read_ForwardTracks(DataEvent event) { } }else{ - - if(debugMode>=1)System.out.format("No track banks: Go back\n"); return false; } } - if(debugMode>=1){ - System.out.format(" \n CLAS-Event PARTICLE found %3d \n",clasevent.getParticles().size()); - for(int n = 0; n < clasevent.getParticles().size(); n++){ - DetectorParticle p = clasevent.getParticle(n); - DetectorTrack tr = p.getTrack(); - show_Particle(p); - show_Track(tr); - } - System.out.format(" \n"); - } - return !clasevent.getParticles().isEmpty(); } public void process_HitMatching(RICHParameters richpar){ - int debugMode = 0; - - if(debugMode>=1){ - int nc=richevent.get_nResClu(); - for(int n = 0; n < nc; n++){ - DetectorResponse dt = richevent.get_ResClu(n); - if(debugMode>=1) System.out.format("Response n %4d %4d %s time %8.2f ene %8.2f pos %8.1f %8.1f %8.1f \n",n, - dt.getSector(), dt.getDescriptor().getType().getName(), - dt.getTime(),dt.getEnergy(),dt.getPosition().x(),dt.getPosition().y(),dt.getPosition().z()); - } - } - int np = clasevent.getParticles().size(); for(int n = 0; n < np; n++){ DetectorParticle p = this.clasevent.getParticle(n); - if(debugMode>=1){ - Line3D trajectory = p.getLastCross(); - Point3D ori = trajectory.origin(); - Point3D end = trajectory.end(); - System.out.format("Particle n %4d itr %3d path %8.1f ori %s end %s\n", - n,p.getTrackIndex(),p.getPathLength(),ori.toStringBrief(2),end.toStringBrief(2)); - } - // Matching tracks to RICH: from LastCross minimum distance in any direction Double rich_match_cut = richpar.RICH_DCMATCH_CUT; int index = p.getDetectorHit(richevent.get_ResClus(), DetectorType.RICH, -1, rich_match_cut); @@ -433,7 +253,6 @@ public void process_HitMatching(RICHParameters richpar){ DetectorResponse res = richevent.get_ResClu(index); Point3D ocross = p.getLastCross().origin(); double dz = res.getPosition().z() - ocross.z(); - if(debugMode>=1) System.out.format(" --> match found %4d par %s clu %s dz %7.2f \n", index, ocross.toStringBrief(2), res.getPosition().toStringBrief(2), dz); // while storing the match, calculates the matched position as middle point between track and hit // and path (track last cross plus distance to hit) assuming the hit is downstream of last cross @@ -442,7 +261,6 @@ public void process_HitMatching(RICHParameters richpar){ // go backward instead of forward from LastCross double extra = p.getPathLength(res.getPosition()); res.setPath( res.getPath()-2*extra); - if(debugMode>=1) System.out.format(" --> Negative Delta z %7.2f --> correct path by %7.2 \n", dz, -2*extra); } // Status brings the pindex of the original track to fix the hipo cross-indexes @@ -450,37 +268,24 @@ public void process_HitMatching(RICHParameters richpar){ } } - if(debugMode>=1) System.out.format(" \n"); } - public void set_EventInfo(DataEvent event) { + private void set_EventInfo(DataEvent event) { - int debugMode = 0; - - long tt = System.nanoTime(); - richevent.set_CPUTime(tt); if(event.hasBank("REC::Event")==true){ DataBank bankeve = event.getBank("REC::Event"); - float evttime = bankeve.getFloat("startTime",0); richevent.set_EventTime(evttime); - - if(debugMode>=1)System.out.format(" Create RICH Event id %8d time %8.2f \n", richevent.get_EventID(), richevent.get_EventTime()); } if(event.hasBank("RUN::config")==true){ DataBank bankrun = event.getBank("RUN::config"); richevent.set_RunID(bankrun.getInt("run",0)); richevent.set_EventID(bankrun.getInt("event",0)); - - //int phase = (int) ((bankrun.getLong("timestamp",0)%6 +1)%6) /2; int phase = (int) (bankrun.getLong("timestamp",0)%2); richevent.setFTOFphase(phase); - - if(debugMode>=1)System.out.println(" Create RICH Event id "+richevent.get_EventID()+" stamp "+bankrun.getLong("timestamp",0)+" phase "+phase); } - if(debugMode>=1)System.out.println(" Create RICH Event id "+richevent.get_EventID()+" reftime"+richevent.get_CPUTime()+" "+tt); - + } @@ -488,7 +293,6 @@ public int get_NClasParticle() { return clasevent.getParticles().size(); } - public int get_nMatch() { return richevent.get_nMatch(); } @@ -496,14 +300,6 @@ public int get_nMatch() { public boolean find_Hadrons(RICHRayTrace richtrace, RICHCalibration richcal, RICHParameters richpar) { - int debugMode = 0; - - if(debugMode>=1){ - System.out.println("---------------------------------"); - System.out.println("Find RICH hadrons from CLAS "+get_NClasParticle()+" particles"); - System.out.println("---------------------------------"); - } - int hindex = 0; for(DetectorParticle p : clasevent.getParticles()){ @@ -511,12 +307,6 @@ public boolean find_Hadrons(RICHRayTrace richtrace, RICHCalibration richcal, RIC int CLASpid = check_CLASpid( p.getPid() ); double CLASbeta = p.getBeta(); - if(debugMode>=1) { - System.out.format(" --> track %4d %4d %4d sec %4d ori %s P %8.2f the %8.2f time @IP %8.2f path %7.2f\n", - p.getTrackIndex(),p.getTrackStatus(),CLASpid, p.getTrackSector(), - p.getLastCross().origin().toStringBrief(2),p.vector().mag(),theta*RAD,richevent.get_EventTime(),p.getPathLength()); - } - DetectorResponse r = null; DetectorResponse exr = null; int nr = 0; @@ -530,88 +320,48 @@ public boolean find_Hadrons(RICHRayTrace richtrace, RICHCalibration richcal, RIC RICHtime = richevent.get_EventTime() + r.getPath()/CLASbeta/(PhysicsConstants.speedOfLight()); RICHiclu = r.getHitIndex(); double TRACKtime = richevent.get_EventTime() + p.getPathLength()/CLASbeta/(PhysicsConstants.speedOfLight()); - - if(debugMode>=1)System.out.format(" --> cluster %4d hit %s path %7.2f --> rich %8.2f vs track %8.2f time\n \n",RICHiclu, - r.getPosition().toStringBrief(2), r.getPath(), r.getTime(), TRACKtime); - - nr++; } } if( (nr==1) || (nr==0 && richpar.DO_MIRROR_HADS==1) ){ - if(debugMode>=1)System.out.format("EXTRAPOLATED with nresp %d \n",nr); exr = extrapolate_RICHResponse(p, r, richtrace); if(exr!=null) nexr++; } // define the response treatment in special cases - if(nexr==0){if(debugMode>=1)System.out.format("No RICH intersection for particle with nresp %d and theta %8.2f \n",nr,theta*RAD); continue;} - if(nr==1)Match_chi2 = 2*exr.getMatchedDistance()/richpar.RICH_HITMATCH_RMS; - - if(debugMode>=1)System.out.format(" --> intersec %4d hit %s path %7.2f --> time %8.2f chi2 %7.2f \n \n",RICHiclu, - exr.getPosition().toStringBrief(2), exr.getPath(), exr.getTime(), Match_chi2); + if(nexr==0) continue; + if(nr==1) Match_chi2 = 2*exr.getMatchedDistance()/richpar.RICH_HITMATCH_RMS; RICHParticle richhadron = new RICHParticle(hindex, p, exr, richpar); richhadron.set_StartTime(richevent.get_EventTime()); richhadron.traced.set_time(exr.getTime()); richhadron.traced.set_machi2(Match_chi2); - //richhadron.set_HitTime(exr.getTime()); - /*if(!richhadron.set_points(p.getLastCross().origin(), p.getLastCross().end(), exr.getPosition(), exr.getStatus(), richtrace) ){ - if(debugMode>=1)System.out.println(" ERROR: no MAPMT interesection found for hadron \n"); - continue; - }*/ - if(!richhadron.find_AerogelPoints(richtrace, richcal) ) { - if(debugMode>=1)System.out.println(" ERROR: no aerogel interesection found for hadron \n"); continue; } richhadron.traced.set_path((float) richhadron.get_HitPos().distance(richhadron.aero_middle)); - if(debugMode>=1)System.out.format(" Timing id %3d beta %8.4f | time eve %8.2f emi %8.2f hit %8.2f at light speed %8.2f (cm/ns) \n", - CLASpid,CLASbeta,richevent.get_EventTime(),richhadron.get_StartTime(), exr.getTime(), PhysicsConstants.speedOfLight()); if(!richhadron.set_rotated_points() ) { System.out.println(" ERROR: no rotation found \n"); continue; } - if(debugMode>=1){ - System.out.format(" ------------------- \n"); - System.out.format(" Hadron %4d id %4d from part %4d and clu %4d CLAS eve %7d pid %5d \n ", hindex, richhadron.get_id(), - p.getTrackStatus(), RICHiclu, richevent.get_EventID(), CLASpid); - System.out.format(" ------------------- \n"); - - richhadron.show(); - Point3D crosspos = p.getLastCross().origin(); - Point3D crossdir = richhadron.lab_emission; - System.out.format(" track cross 1 xyz %s dir %s \n",crosspos.toStringBrief(3), crossdir.toStringBrief(3)); - } - richevent.add_Hadron(richhadron); hindex++; } - if(debugMode==1 && hindex>1)System.out.format(" MOREHADs \n"); - if(richevent.get_nHad()>0)return true; - return false; - + return richevent.get_nHad()>0; } public boolean find_Photons(List RichHits, RICHParameters richpar, RICHCalibration richcal){ - int debugMode = 0; if(RichHits==null) return false; int id = 0; for(RICHParticle richhadron : richevent.get_Hadrons()){ - if(debugMode>=1){ - System.out.format("---------------------------------\n"); - System.out.format("Find photons from hadron %3d and %6d hits \n",richhadron.get_id(), RichHits.size()); - System.out.format("---------------------------------\n"); - } - for(int hypo=0; hypo RichHits, RICHParameters ric Point3D dummy= new Point3D(0., 0., 0.); RICHParticle photon = new RICHParticle(id, richhadron, RichHits.get(k), dummy, richpar); - if(debugMode>=1){ - System.out.format(" ------------------- \n"); - System.out.format(" Photon id %4d from hit %4d hadron %3d and hypo %s\n", - photon.get_id(), richhadron.get_id(), RichHits.get(k).getHitIndex(), RICHConstants.HYPO_STRING[hypo]); - System.out.format(" ------------------- \n"); - } - photon.set_rotated_points(richhadron); photon.set_PixelProp(richcal); photon.set_type(hypo); @@ -642,34 +385,25 @@ public boolean find_Photons(List RichHits, RICHParameters ric } } - if(richevent.get_nPho()>0)return true; - return false; + return richevent.get_nPho()>0; } public boolean analyze_Cherenkovs(RICHRayTrace richtrace, RICHParameters richpar) { - int debugMode = 0; - if(richpar.DO_ANALYTIC==1){ int hypo = 1; richevent.analyze_Photons(hypo, richtrace); - //richevent.select_Photons(hypo, 0, richpar); for(RICHParticle richhadron : richevent.get_Hadrons()){ if (richhadron.get_Status()==1){ //richevent.get_ChMean(richhadron, hypo, 0); richevent.get_pid(richhadron, 0, richpar); - }else{ - if(debugMode>=1)System.out.format(" Hadron pointing to mirror, skip analytic analysis \n"); } } - } - return true; - } @@ -685,8 +419,6 @@ public boolean is_WantedHypo(RICHParameters richpar, int hypo) { public boolean reco_Cherenkovs(RICHRayTrace richtrace, RICHParameters richpar, RICHCalibration richcal) { - int debugMode = 0; - int recotype = RICHRecoType.TRACED.id(); for(RICHParticle richhadron : richevent.get_Hadrons()){ @@ -696,12 +428,6 @@ public boolean reco_Cherenkovs(RICHRayTrace richtrace, RICHParameters richpar, R if(!is_WantedHypo(richpar, hypo)) continue; - if(debugMode==1){ - System.out.format(" ------------\n"); - System.out.format(" RECO Hadron %3d with Hypothesis %s \n", richhadron.get_id(), RICHConstants.HYPO_LUND[hypo]); - System.out.format(" ------------\n"); - } - richevent.throw_Photons(richhadron, Ntrials, hypo, richtrace, richpar, richcal); if(richpar.TRACE_PHOTONS==1){ @@ -733,16 +459,12 @@ public boolean reco_Cherenkovs(RICHRayTrace richtrace, RICHParameters richpar, R public DetectorResponse extrapolate_RICHResponse(DetectorParticle p, DetectorResponse r, RICHRayTrace richtrace){ - int debugMode = 0; - int imir=0; Point3D extra = richtrace.find_IntersectionMAPMT( p.getTrackSector(), p.getLastCross() ); if(extra!=null){ - if(debugMode>0)System.out.format(" Extrapolation to MAPMT %s \n", extra.toStringBrief(2)); }else{ imir=1; extra = richtrace.find_IntersectionSpheMirror( p.getTrackSector(), p.getLastCross() ); - if(extra!=null && debugMode>0)System.out.format(" Extrapolation to SPHER %s \n", extra.toStringBrief(2)); } if(extra==null) return null; @@ -767,7 +489,6 @@ public DetectorResponse extrapolate_RICHResponse(DetectorParticle p, DetectorRes exr.setTime (r.getTime()); exr.setStatus(1); exr.getDescriptor().setSectorLayerComponent( r.getDescriptor().getSector(), r.getDescriptor().getLayer(), r.getDescriptor().getComponent()); - if(debugMode>0)System.out.format(" Take response %s path %7.2f time %7.2f\n", rpos.toStringBrief(2), exr.getPath(), exr.getTime()); }else{ @@ -777,18 +498,7 @@ public DetectorResponse extrapolate_RICHResponse(DetectorParticle p, DetectorRes exr.setStatus(0); double CLASbeta = p.getBeta(); exr.setTime( richevent.get_EventTime() + exr.getPath()/CLASbeta/(PhysicsConstants.speedOfLight()) ); - if(debugMode>0)System.out.format(" Take extra %s path %7.2f time %7.2f\n", extra.toStringBrief(2), exr.getPath(), exr.getTime()); - - } - - - if(debugMode>=1){ - Vector3D pos = new Vector3D(0.,0.,0.); - if(r!=null) pos = r.getPosition(); - System.out.format("exr: status %4d imir %4d ex %s r %s exr %s L %7.2f (%7.2f + %7.2f) T %7.2f \n", - exr.getStatus(),imir,extra.toStringBrief(2), pos.toStringBrief(2), - exr.getPosition().toStringBrief(2),exr.getPath(),p.getPathLength(),extrapath,exr.getTime()); } return exr; @@ -813,23 +523,17 @@ public int check_CLASpid(int pid) { public double Pi_Likelihood(double angolo) { - double mean = 0.307; double sigma= 0.004; - System.out.println("Angolo: " + angolo); double Norm = Math.log(1+1/ sigma*(Math.sqrt(2* Math.PI))); double Argomento = 1+Math.exp((-0.5)*Math.pow((angolo - mean)/sigma, 2) )/ sigma*(Math.sqrt(2* Math.PI)); - System.out.println(Argomento); double LikeLihood= Math.log(Argomento)/Norm; - //System.out.println(LikeLihood); return LikeLihood; - } public Point3D Outer_Intersection(Point3D first, Point3D second, Vector3D direction ) { - int debugMode = 0; Point3D Emissione = new Point3D(0,0,0); // Define a Vector3D as: Second point of intersection Minus first point of intersection Vector3D V_inter = second.vectorFrom(first); @@ -846,14 +550,6 @@ public Point3D Outer_Intersection(Point3D first, Point3D second, Vector3D direct Emissione.setY( first.y() ); Emissione.setZ( first.z() ); } - if(debugMode>=1){ - System.out.println("First "+first); - System.out.println("Second "+second); - System.out.println("Direction"+direction); - System.out.println("V_inter "+V_inter); - System.out.println(" prod "+V_inter.asUnit().dot(direction.asUnit())); - System.out.println("Emission "+Emissione); - } return Emissione; } @@ -876,12 +572,6 @@ public HashMap getPindexMap() { } - public void CosmicEvent(List Hits, List Clusters) { - int debugMode = 0; - if(debugMode>=1) System.out.println("RICH Event Builder: Event Process "); - } - - public void show_Particle(DetectorParticle pr) { System.out.format(" Particle pid %4d mass %9.4f beta %8.5f vert %8.2f %8.2f %8.2f mom %8.3f %8.3f %8.3f \n", pr.getPid(),pr.getMass(),pr.getBeta(), diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHHit.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHHit.java index 4b764ad0b1..4665e46073 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHHit.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHHit.java @@ -36,9 +36,6 @@ public RICHHit(){} public RICHHit(int hid, int phase, RICHEdge lead, RICHEdge trail, RICHGeoFactory richgeo, RICHCalibration richcal) { - - int debugMode = 0; - // Edge channel runs [1:192], Hit channel runs [0:191] this.id = hid; this.sector = lead.get_sector(); @@ -62,12 +59,6 @@ public RICHHit(int hid, int phase, RICHEdge lead, RICHEdge trail, RICHGeoFactory this.cluster = 0; this.xtalk = 0; - if(debugMode>=2)System.out.format("Correzione time til %3d ch %6d pmt %3d anode %4d dur %5d raw %7.2f toff %7.2f twalk %7.3f --> time %7.2f \n", - this.tile, this.channel, this.pmt,this.anode,this.duration, this.rawtime, toff_corr, twalk_corr, this.time); - - if(debugMode>=2)System.out.format(" Hittime %4d %4d %8d %7.2f %7d %7.2f %7.2f %7.2f \n", hid, pmt, this.duration, this.rawtime, - phase*4, toff_corr, -twalk_corr, this.time); - //this.glx = richgeo.get_PixelMap().get_Globalidx(pmt, anode); //this.gly = richgeo.get_PixelMap().get_Globalidy(pmt, anode); this.idx = richgeo.get_PixelMap().Anode2idx(anode); @@ -77,11 +68,8 @@ public RICHHit(int hid, int phase, RICHEdge lead, RICHEdge trail, RICHGeoFactory this.y = CesPos.y(); this.z = CesPos.z(); - if(debugMode>=1)System.out.format(" Hit pmt %4d anode %3d --> %8.2f %8.2f %8.2f \n", pmt, anode, this.x, this.y, this.z); - } - public int get_id() { return id; } public void set_id(int id) { this.id = id; } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHPMTReconstruction.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHPMTReconstruction.java index ce8f8621c1..2b40e62501 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHPMTReconstruction.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHPMTReconstruction.java @@ -3,171 +3,99 @@ import java.util.ArrayList; import java.util.Collections; import org.jlab.io.base.DataEvent; -import org.jlab.io.evio.EvioDataEvent; import org.jlab.io.hipo.HipoDataEvent; import org.jlab.detector.banks.RawDataBank; import org.jlab.detector.geom.RICH.RICHGeoFactory; public class RICHPMTReconstruction { - + private RICHEvent richevent; private RICHGeoFactory richgeo; private RICHio richio; - - // ---------------- + public RICHPMTReconstruction(RICHEvent richeve, RICHGeoFactory richgeo, RICHio richio) { - // ---------------- - this.richevent = richeve; this.richgeo = richgeo; this.richio = richio; - } - - // ---------------- + public void process_RawData(DataEvent event, RICHParameters richpar, RICHCalibration richcal) { - // ---------------- - - int debugMode = 0; - if(debugMode>=1){ - System.out.println("---------------------------------"); - System.out.println("PMT Event: Process raw data "); - System.out.println("---------------------------------"); - } - - ArrayList allEdges = new ArrayList(); - ArrayList Leads = new ArrayList(); - ArrayList Trails = new ArrayList(); - - ArrayList Hits = new ArrayList(); - ArrayList AllClusters = new ArrayList(); - ArrayList Clusters = new ArrayList(); - + // get edges fron banks - allEdges = read_RawBank(event); - + ArrayList allEdges = read_RawBank(event); + // select good edges and order them - Leads = selectLeadEdges(allEdges); - Trails = selectTrailEdges(allEdges); - + ArrayList Leads = selectLeadEdges(allEdges); + ArrayList Trails = selectTrailEdges(allEdges); + // build hits - Hits = reco_PMTHits(Leads, Trails, richcal); - AllClusters = findClusters(Hits); - Clusters = selectGoodClusters(AllClusters); - + ArrayList Hits = reco_PMTHits(Leads, Trails, richcal); + ArrayList AllClusters = findClusters(Hits); + ArrayList Clusters = selectGoodClusters(AllClusters); + find_XTalk(Hits, AllClusters, richpar); - + richevent.add_Hits(Hits); richevent.add_Clusters(Clusters); richevent.select_Signals(); - + richio.write_PMTBanks(event, richevent); - } - - // ---------------- + public ArrayList read_RawBank(DataEvent event) { - // ---------------- - - int debugMode = 0; - ArrayList allEdges = null; - - if(event instanceof EvioDataEvent) { - if(debugMode>=2)System.out.print("EVIO event found\t"); - //allEdges = this.read_RawEdgesEVIO(event); - } - if(event instanceof HipoDataEvent) { - if(debugMode>=2)System.out.print("HIPO event found\t"); allEdges = this.read_RawEdgesHIPO(event); } - - if(debugMode>=2) { - System.out.println("Found " + allEdges.size() + " edges"); - for(int i = 0; i < allEdges.size(); i++) { - System.out.print(i + "\t"); - allEdges.get(i).showEdge(); - } - } return allEdges; } - // ---------------- public ArrayList selectLeadEdges(ArrayList allEdges) { - // ---------------- - - int debugMode = 0; - ArrayList Leads = new ArrayList(); + + ArrayList Leads = new ArrayList<>(); for(int i = 0; i < allEdges.size(); i++) { RICHEdge edge = allEdges.get(i); - if(edge.pass_EdgeSelection()) { - if(edge.get_polarity()==RICHConstants.LEADING_EDGE_POLARITY)Leads.add(edge); - } - } - - if(debugMode>=2)System.out.println("Sorting leads "+Leads.size()); + if(edge.pass_EdgeSelection()) { + if(edge.get_polarity()==RICHConstants.LEADING_EDGE_POLARITY)Leads.add(edge); + } + } + Collections.sort(Leads); // redefine IDs accroding to the sorting for(int il=0; il=2) { - if(debugMode>=1)System.out.println("List of selected Leading edges"); - for(int i = 0; i < Leads.size(); i++) - { - System.out.print(i + "\t"); - Leads.get(i).showEdge(); - } - } + return Leads; } - - - // ---------------- + + public ArrayList selectTrailEdges(ArrayList allEdges) { - // ---------------- - - int debugMode = 0; - ArrayList Trails = new ArrayList(); - for(int i = 0; i < allEdges.size(); i++) + ArrayList Trails = new ArrayList<>(); + + for(int i = 0; i < allEdges.size(); i++) { RICHEdge edge = allEdges.get(i); - if(edge.pass_EdgeSelection()) { - if(edge.get_polarity()==RICHConstants.TRAILING_EDGE_POLARITY)Trails.add(edge); - } - } - - - if(debugMode>=2)System.out.println("Sorting trail "+Trails.size()); + if(edge.pass_EdgeSelection()) { + if(edge.get_polarity()==RICHConstants.TRAILING_EDGE_POLARITY)Trails.add(edge); + } + } + + Collections.sort(Trails); // redefine IDs accroding to the sorting for(int it=0; it=2) { - if(debugMode>=1)System.out.println("List of selected Trailing edges"); - for(int i = 0; i < Trails.size(); i++) - { - System.out.print(i + "\t"); - Trails.get(i).showEdge(); - } - } + return Trails; } - - - // ---------------- + + public ArrayList read_RawEdgesHIPO(DataEvent event) { - // ---------------- // getting raw data bank - - int debugMode = 0; - if(debugMode>=2) System.out.println("Getting raw edges from RICH:tdc bank"); - - ArrayList edges = new ArrayList(); + + ArrayList edges = new ArrayList<>(); if(event.hasBank("RICH::tdc")==true) { RawDataBank bankDGTZ = new RawDataBank("RICH::tdc"); bankDGTZ.read(event); @@ -179,138 +107,92 @@ public ArrayList read_RawEdgesHIPO(DataEvent event) { int iorder = bankDGTZ.trueOrder(row); int itdc = bankDGTZ.getInt("TDC",row); if(ilayer<0)ilayer=ilayer+256; - if(debugMode>=2)System.out.print(" --> Edge "+row+" sec "+isector+" lay "+ilayer+" comp "+icomponent+" order "+iorder+" tdc "+itdc+"\n"); if(itdc!=-1){ RICHEdge edge = new RICHEdge(bankDGTZ.trueIndex(row), isector, ilayer, icomponent, iorder, itdc); - edges.add(edge); - } + edges.add(edge); + } } } return edges; } - - // ---------------- + public ArrayList reco_PMTHits(ArrayList Leads, ArrayListTrails, RICHCalibration richcal) { - // ---------------- - - int debugMode = 0; + int nhit=0; ArrayList hits = new ArrayList(); - - if(debugMode>=1)System.out.println("Entering hit reconstruction"); + for(int iled=0; iled0)continue; - //if(debugMode>=1) System.out.println("Working on lead "+iled+" ch "+lead.get_channel()+" tdc "+lead.get_tdc()); - if(debugMode>=1) System.out.format("Working on lead %4d sec %3d tile %4d ch %4d tdc %6d \n",iled,lead.get_sector(), - lead.get_tile(), lead.get_channel(),lead.get_tdc()); - + + if(lead.get_hit()>0)continue; + for(int itra=0; itra0)continue; - if(trail.get_sector() == lead.get_sector() && - trail.get_tile()*192+trail.get_channel() == lead.get_tile()*192+lead.get_channel()){ - //if(debugMode>=1) System.out.println("Candidate trail found "+itra+" ch "+trail.get_channel()+" tdc " +trail.get_tdc()); - if(debugMode>=1) System.out.format(" --> Candidate trail %4d sec %3d tile %4d ch %4d tdc %6d \n",itra,trail.get_sector(), - trail.get_tile(),trail.get_channel(),trail.get_tdc()); + if(trail.get_sector() == lead.get_sector() && + trail.get_tile()*192+trail.get_channel() == lead.get_tile()*192+lead.get_channel()){ if(trail.get_tdc() > lead.get_tdc()){ - if(debugMode>=1) System.out.println(" --> Candidate hit found from lead "+iled+" trail "+itra); - - nhit++; - lead.set_hit(nhit); - trail.set_hit(nhit); - RICHHit hit = new RICHHit(nhit, richevent.getFTOFphase(), lead, trail, richgeo, richcal); - hits.add(hit); - break; - + nhit++; + lead.set_hit(nhit); + trail.set_hit(nhit); + RICHHit hit = new RICHHit(nhit, richevent.getFTOFphase(), lead, trail, richgeo, richcal); + hits.add(hit); + break; } } } } - - if(debugMode>=2)System.out.println("Sorting hits "+hits.size()); + Collections.sort(hits); // redefine the IDs following the sorting for(int ih=0; ih=1) { - System.out.println("-------------------------"); - System.out.println("List of selected Hits"); - System.out.println("-------------------------"); - for(int i = 0; i < hits.size(); i++) - { - hits.get(i).showHit(); - } - } + return hits; } - - - // ---------------- + + public ArrayList findClusters(ArrayList hits) { - // ---------------- - - int debugMode = 0; + ArrayList allclusters = new ArrayList(); - if(debugMode>=2) { - System.out.println("--------------------\n"); - System.out.println("Building allclusters\n"); - System.out.println("--------------------\n"); - } - + for(int ihit=0; ihit=2)System.out.println(" Check hit "+hit.get_id()+" "+hit.get_pmt()+" "+hit.get_anode()+" "+hit.get_Time()); - + if(hit.get_cluster()==0) { // this hit is not yet associated with a cluster + for(int jclus=0; jclus=2) System.out.println("Attaching hit " + ihit + " to cluster " + cluster.get_id() + " label " + hit.get_cluster()); } } } - + if(hit.get_cluster()==0) { // new cluster found RICHCluster cluster = new RICHCluster(allclusters.size()+1); hit.set_cluster(cluster.get_id()); cluster.add(hit); allclusters.add(cluster); - if(debugMode>=2) System.out.println("Creating new cluster with id " + cluster.get_id()); } } - - if(debugMode>=2){ - System.out.println("List of all Clusters"); - for(int i=0; i selectGoodClusters(ArrayList allclusters) { - // ---------------- - - int debugMode = 0; + ArrayList clusters = new ArrayList(); - if(debugMode>=2) System.out.println("\nSelecting good clusters"); - + int nclu = 0; for(int i=0; i selectGoodClusters(ArrayList allclust if(clusters.get(j).get(0).get_pmt() == goodclu.get(0).get_pmt()){ clusters.get(j).merge(goodclu); merge = 1; - if(debugMode>=1)System.out.format(" merge clu %d %d xyz %7.2f %7.2f %7.2f to %d %d \n",i,goodclu.get_id(),goodclu.get_x(), goodclu.get_y(), goodclu.get_z(), j,clusters.get(j).get_id()); } } if(merge==0){ @@ -328,7 +209,7 @@ public ArrayList selectGoodClusters(ArrayList allclust goodclu.set_id(nclu); clusters.add(goodclu); } - }else{ + }else{ // cancel hit to cluster link RICHCluster badclu = allclusters.get(i); for(int j = 0; j< badclu.size(); j++) { @@ -336,76 +217,42 @@ public ArrayList selectGoodClusters(ArrayList allclust } } } - - if(debugMode>=1){ - System.out.format("-------------------------\n"); - System.out.format("List of selected Clusters %4d \n",clusters.size()); - System.out.format("-------------------------\n"); - for(int i=0; i=1){ - System.out.println("List of sorted Clusters"); - for(int i=0; i hits, ArrayList allclusters, RICHParameters richpar) { - // ---------------- - - int debugMode = 0; - if(debugMode==1){ - System.out.println("----------------"); - System.out.println("Search for Xtalk"); - System.out.println("----------------"); - System.out.format(" %7.3f \n",richpar.GOODHIT_FRAC); - } - for(int ih=0; ih=1 || DEBUG_RECO_FLAG>=1) && ncalls=1 || DEBUG_RECO_PAR>=1) && ncalls0)System.out.format("RICHFactory: Load calibration parameters from TxT\n"); init_ParameterTxT(); - } - } - public void init_FlagCCDB(IndexedTable flagConstants, boolean engineDebug) { - int debugMode = 0; - PROCESS_RAWDATA = flagConstants.getIntValue("reco_raw", 0, 0, 0); PROCESS_DATA = flagConstants.getIntValue("reco_data", 0, 0, 0); USE_SIGNAL_BANK = flagConstants.getIntValue("use_sig_bank", 0, 0, 0); @@ -154,20 +126,16 @@ public void init_FlagCCDB(IndexedTable flagConstants, boolean engineDebug) { RING_ONLY_USED = flagConstants.getIntValue("ring_only_used", 0, 0, 0); if(!engineDebug){ - if(debugMode>=1)System.out.format("RICH RECO debugging set to OFF \n"); DEBUG_RECO_FLAG = 0; DEBUG_RECO_PAR = 0; DEBUG_CAL_COST = 0; DEBUG_PROC_TIME = 0; } - } public void init_ParameterCCDB(IndexedTable paraConstants) { - int debugMode = 0; - OFFSET_TIME = paraConstants.getDoubleValue("global_time_off", 0, 0, 0); GOODHIT_FRAC = paraConstants.getDoubleValue("xtalk_frac", 0, 0, 0); diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java index 4e6aa6c517..2e94ea7f10 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java @@ -11,12 +11,11 @@ import org.jlab.detector.geom.RICH.RICHIntersection; import org.jlab.detector.geom.RICH.RICHGeoConstants; +/* +* A particle in the RICH consists of an array of ray lines plus particle information +*/ public class RICHParticle { - /* - * A particle in the RICH consists of an array of ray lines plus particle information - */ - private int id = -999; private int parent_index = -999; private int type = 0; @@ -86,7 +85,6 @@ public RICHParticle(int id, DetectorParticle p, DetectorResponse exr, RICHParame /* * RICHParticle from a CLAS charged particle for RICH reconstruction */ - int debugMode = 0; this.id = id; // ATT: vedere se si puo' evitare tenendolo fuori @@ -110,7 +108,6 @@ public RICHParticle(int id, DetectorParticle p, DetectorResponse exr, RICHParame int detid = DetectorType.RICH.getDetectorId();; this.path = p.getTrackTrajectory().get(detid,0).getPathLength(); if(richpar.FORCE_DC_MATCH==1){ - if(debugMode>=1)System.out.println(" FORCE DC-RICH match \n"); this.direct_ray = new Line3D(p.getFirstCross().origin(), exr.getPosition().toPoint3D()); } this.lab_phi = direct_ray.toVector().phi(); @@ -263,9 +260,6 @@ public double chgain() { public double chbackgr() { - int debugMode = 0; - - if(debugMode>=1)System.out.format("Pixel back %7.2f %7.2f (1e-9)\n",pixel_backr*1e9,richpar.PIXEL_NOMINAL_DARKRATE*1e9); if(richpar.USE_CALIBRATED_PIXELS==1 && pixel_backr>0) return pixel_backr; return richpar.PIXEL_NOMINAL_DARKRATE; @@ -327,9 +321,9 @@ private void dump_ChAngle() { public int get_type() {return type;} - public boolean is_throw() {if(get_type()>10)return true; return false;} + public boolean is_throw() {return get_type()>10;} - public boolean is_real() {if(get_type()<10)return true; return false;} + public boolean is_real() {return get_type()<10;} public int get_recofound() {return recofound;} @@ -415,43 +409,29 @@ public double nominal_ChAngle(int pid){ // calculate the cherenkov angle from the aerogel // nominal refractive index for the four accepted // particle hypothesis - - int debugMode = 0; - int ok = 0; for (int ip=0; ip0) arg = 1.0/beta/refi_emission; - if(debugMode>=1) System.out.format(" Nominal Ch Angle %8.4f beta %8.4f n %7.3f arg %8.4f\n",get_mass(pid),beta,refi_emission, Math.acos(arg)*MRAD); - if(arg>0.0 && arg<1.0) return Math.acos(arg); return 0.0; } public double nominal_nChAngle(int pid){ - - int debugMode = 0; - int ok = 0; for (int ip=0; ip=1) System.out.format(" Expected N photo PID %5d Ne %7.2f r %7.2f --> n %7.3f \n",pid,nele,ratio,nele*ratio); - return nele*ratio; } public double calibrated_sChAngle(int irefle){ - return schele_emission[irefle]; } @@ -460,21 +440,13 @@ public double calibrated_ChAngle(int pid, int irefle){ // recalculate the expected Cherenkov angle // for the given particle hypothesis starting // from the electron measured values - - int debugMode = 0; - int ok = 0; for (int ip=0; ipRICHConstants.N_PATH) return 0.0; - double beta = get_beta(pid); double cose = Math.cos(chele_emission[irefle]); - double arg = 0.0; if(beta>0) arg = 1.0/beta*cose; - if(debugMode>=1) System.out.format(" Calibrated Ch Angle %7.2f %8.4f beta %8.4f n %7.3f arg %8.4f [%4d %4d]\n", - chele_emission[irefle]*MRAD,get_mass(pid),beta,refi_emission, Math.acos(arg)*MRAD, ilay_emission, ico_emission); - if(arg>0.0 && arg<1.0) return Math.acos(arg); return 0.0; } @@ -484,19 +456,12 @@ public double calibrated_nChAngle(int pid, int irefle){ // recalculate the expected Cherenkov photon yield // for the given particle hypothesis starting // from the electron measured values - - int debugMode = 0; - int ok = 0; for (int ip=0; ipRICHConstants.N_PATH) return 0.0; - if(changle(11,0)==0)return 0.0; double ratio = Math.pow(Math.sin(changle(pid,0)),2)/Math.pow(Math.sin(changle(11,0)),2); double nele = nchele_emission[irefle]; - - if(debugMode>=1) System.out.format(" Expected N photo PID %5d Ne %7.2f r %7.2f --> n %7.3f \n",pid,nele,ratio,nele*ratio); - return nele*ratio; } @@ -537,22 +502,14 @@ public void set_RICHpid(int hpid){ } public void set_PixelProp(RICHCalibration richcal){ - - int debugMode = 0; - int isec = hit.get_sector(); int ipmt = hit.get_pmt(); int ich = hit.get_anode(); - pixel_gain = richcal.get_PixelGain(isec, ipmt, ich); pixel_eff = richcal.get_PixelEff(isec, ipmt, ich); pixel_mtime = richcal.get_PixelMeanTime(isec, ipmt, ich); pixel_stime = richcal.get_PixelRMSTime(isec, ipmt, ich); pixel_backr = richcal.get_PixelDarkRate(isec, ipmt, ich)*1e-9; - - if(debugMode>=1) System.out.format("Photon pixel %4d %4d %4d --> %7.2f %7.2f %7.2f %7.2f %7.3f (e-9) \n",hit.get_id(), ipmt-1, ich-1, - pixel_gain, pixel_eff, pixel_mtime, pixel_stime, pixel_backr*1e9); - } @@ -562,40 +519,20 @@ public boolean find_AerogelPoints(RICHRayTrace richtrace, RICHCalibration richca * Take the first (in z) with track pointing inside as Entrance * Take the last (in z) with track pointing outside as Exit */ - - int debugMode = 0; - boolean found_exit = false; - boolean found_entrance = false; - RICHIntersection compo = null; - - if(debugMode>=1){ - if(debugMode>=3) System.out.println(" \n RICHParticle::set_aerogel_points \n"); - System.out.format(" from ray %s \n",direct_ray.origin().toStringBrief(2)); - if(debugMode>=3) System.out.println(" Look for intersection with layer 201 \n"); - } RICHIntersection entrance = richtrace.get_Layer(sector, "AEROGEL_2CM_B1").find_Entrance(direct_ray, -1); - if(debugMode>=1 && entrance!=null) System.out.format(" B1 entrance %4d %6d %s \n",entrance.get_layer(),entrance.get_component(), entrance.get_pos().toStringBrief(2)); RICHIntersection exit = richtrace.get_Layer(sector, "AEROGEL_2CM_B1").find_Exit(direct_ray, -1); - if(debugMode>=1 && exit!=null) System.out.format(" B1 exit %4d %6d %s \n",exit.get_layer(),exit.get_component(), exit.get_pos().toStringBrief(2)); if(entrance==null || exit==null){ - if(debugMode>=3) System.out.println(" Look for intersection with layer 202 \n"); entrance = richtrace.get_Layer(sector, "AEROGEL_2CM_B2").find_Entrance(direct_ray, -1); - if(debugMode>=1 && entrance!=null) System.out.format(" B2 entrance %4d %6d %s \n",entrance.get_layer(),entrance.get_component(), entrance.get_pos().toStringBrief(2)); exit = richtrace.get_Layer(sector, "AEROGEL_2CM_B2").find_Exit(direct_ray, -1); - if(debugMode>=1 && exit!=null) System.out.format(" B2 exit %4d %6d %s \n",exit.get_layer(),exit.get_component(), exit.get_pos().toStringBrief(2)); } if(entrance==null || exit==null){ - if(debugMode>=3) System.out.println(" Look for intersection with layer 203/204 \n"); entrance = richtrace.get_Layer(sector, "AEROGEL_3CM_L2").find_Entrance(direct_ray, -1); - if(debugMode>=1 && entrance!=null) System.out.format(" B3 entrance %4d %6d %s \n",entrance.get_layer(),entrance.get_component(), entrance.get_pos().toStringBrief(2)); exit = richtrace.get_Layer(sector, "AEROGEL_3CM_L1").find_Exit(direct_ray, -1); - if(debugMode>=1 && exit!=null) System.out.format(" B3 exit %4d %6d %s \n",exit.get_layer(),exit.get_component(), exit.get_pos().toStringBrief(2)); } if(entrance==null || exit==null){ - if(debugMode>=1)System.out.format(" No intersection with aerogel plane found \n"); return false; } @@ -618,11 +555,6 @@ public boolean find_AerogelPoints(RICHRayTrace richtrace, RICHCalibration richca int Nqua = richpar.QUADRANT_NUMBER; iqua_emission = richtrace.get_Layer(sector, ilay_emission).get_Quadrant(Nqua, ico_emission, exit.get_pos()); - if(debugMode>=1){ - System.out.format(" AERO lay %3d ico %3d qua %3d \n",ilay_emission,ico_emission,iqua_emission); - if(entrance.get_layer()!=ilay_emission || entrance.get_component()!=ico_emission) - System.out.format(" AERO CROSS ilay %4d %4d ico %4d %4d \n",entrance.get_layer(),ilay_emission,entrance.get_component(),ico_emission); - } // perform photon reconstruction, to be saved in RICH::Ring /*if(richcal.get_AeroStatus(sector, ilay_emission, ico_emission)>0){ if(debugMode>=1)System.out.format(" AERO bad status: disregard \n"); @@ -634,8 +566,6 @@ public boolean find_AerogelPoints(RICHRayTrace richtrace, RICHCalibration richca chele_emission[iref] = richcal.get_ChElectron(sector, ilay_emission, ico_emission, iqua_emission, iref, charge); schele_emission[iref] = richcal.get_SChElectron(sector, ilay_emission, ico_emission, iqua_emission, iref, charge); nchele_emission[iref] = richcal.get_NElectron(sector, ilay_emission, ico_emission, iqua_emission, iref, charge); - if(debugMode>=1 && iref==0)System.out.format(" AERO [%4d %4d] iref %4d --> %8.3f %7.2f \n", - ilay_emission, ico_emission, iref, chele_emission[iref]*MRAD,nchele_emission[iref]); } } @@ -649,16 +579,6 @@ public boolean find_AerogelPoints(RICHRayTrace richtrace, RICHCalibration richca if(aero_middle.z()-direct_ray.origin().z()<0) dist*=-1; start_time += (path + dist)/get_beta(CLASpid)/(PhysicsConstants.speedOfLight()); - if(debugMode>=3){ - System.out.println(" AERO entrance %s "+aero_entrance.toStringBrief(2)); - System.out.println(" AERO middle %s "+aero_middle.toStringBrief(2)); - System.out.println(" AERO exit %s "+aero_exit.toStringBrief(2)); - System.out.println(" AERO normal %s "+aero_normal.toStringBrief(2)); - System.out.println(" AERO layer "+ilay_emission); - System.out.println(" AERO compo "+ico_emission); - System.out.println(" AERO refi "+refi_emission); - } - return true; } @@ -682,11 +602,8 @@ public void set_rotated_points(RICHParticle hadron){ public boolean set_rotated_points() { - int debugMode = 0; if(lab_emission==null)return false; - if(debugMode>=2) System.out.println(" \n RICHParticle::set_rotated_points \n"); - // define an arbitrary reference point, here taken to be the photon emission point reference = lab_emission; @@ -702,12 +619,6 @@ public boolean set_rotated_points() { this.ref_phi = ref_impact.toVector3D().phi(); this.ref_theta = ref_impact.toVector3D().theta(); - if(debugMode>=2){ - System.out.format(" --> Track projection (P_PCP) %s ",ref_proj.toStringBrief(2)); - System.out.format(" --> Track impact (P_P) %s ",ref_impact.toStringBrief(2)); - System.out.format(" --> Track angles %8.2f %8.2f \n", this.ref_theta*57.3, this.ref_phi*57.3); - } - return true; } @@ -721,17 +632,13 @@ public double calc_EtaC (RICHParticle hadron, double theta) { double Cos_EtaC = Math.sin(Theta_P)* Math.sin(theta)*Math.cos(this.ref_phi-Phi_P)+Math.cos(Theta_P)*Math.cos(theta); return Math.acos(Cos_EtaC); - } - public double time_probability(double testtime, int recotype) { /* * calculate probability for a given time hypothesis */ - int debugMode = 0; - RICHSolution reco = new RICHSolution(); if(recotype==0) reco = analytic; if(recotype==1) reco = traced; @@ -747,14 +654,7 @@ public double time_probability(double testtime, int recotype) { funt = Math.exp((-0.5)*Math.pow((testtime - meant)/sigmat, 2) )/ (sigmat*Math.sqrt(2* Math.PI)); } - double prob = funt*dfunt; - double back = richpar.PIXEL_NOMINAL_DARKRATE*richpar.NSIGMA_TIME*richpar.PIXEL_NOMINAL_STIME; - - if(debugMode>=1)if(prob>back)System.out.format( - "TIM prob meant %8.3f time %8.3f --> %g %g \n", - meant,testtime,funt*dfunt,Math.log(prob)); - return prob; - + return funt*dfunt; } @@ -767,7 +667,6 @@ public double pid_probability(RICHParticle hadron, int hypo_pid, int recotype) { * the photon yiled decreases and pions outnumber koans. */ - int debugMode = 0; RICHSolution reco = new RICHSolution(); if(recotype==0) reco = analytic; if(recotype==1) reco = traced; @@ -811,13 +710,7 @@ public double pid_probability(RICHParticle hadron, int hypo_pid, int recotype) { } double back = richpar.PIXEL_NOMINAL_DARKRATE*richpar.NSIGMA_TIME*richpar.PIXEL_NOMINAL_STIME; - double prob = 1 + pixel_eff *func*dfunc*funt*dfunt + back; - - if(debugMode>=1)System.out.format( - "PID prob %4d mean %7.2f etaC %7.2f sigma %7.2f meant %7.2f (%7.2f + %7.2f) time %7.2f sigmat %7.2f eff %7.2f --> %10.4g %10.4g %8.4f e-3\n",hypo_pid, - mean*MRAD,reco.get_EtaC()*MRAD,sigma*MRAD,recot+meant,recot,meant,hit.get_Time(),sigmat,pixel_eff,func*dfunc,funt*dfunt,Math.log(prob)*1e3); - return prob; - + return 1 + pixel_eff *func*dfunc*funt*dfunt + back; } @@ -830,7 +723,6 @@ public double pid_LHCb(RICHParticle hadron, int hypo_pid, int recotype, int inor * the photon yiled decreases and pions outnumber koans. */ - int debugMode = 0; RICHSolution reco = new RICHSolution(); if(recotype==0) reco = analytic; if(recotype==1) reco = traced; @@ -877,13 +769,7 @@ public double pid_LHCb(RICHParticle hadron, int hypo_pid, int recotype, int inor } double back = richpar.PIXEL_NOMINAL_DARKRATE*richpar.NSIGMA_TIME*richpar.PIXEL_NOMINAL_STIME; - double prob = 1 + pixel_eff *func*dfunc*funt*dfunt + back; - - if(debugMode>=1)System.out.format( - "PID prob %4d mean %7.2f etaC %7.2f sigma %7.2f meant %7.2f (%7.2f + %7.2f) time %7.2f sigmat %7.2f eff %7.2f --> %10.4g %10.4g %8.4f\n",hypo_pid, - mean*MRAD,reco.get_EtaC()*MRAD,sigma*MRAD,recot+meant,recot,meant,hit.get_Time(),sigmat,pixel_eff,func*dfunc,funt*dfunt,prob); - return prob; - + return 1 + pixel_eff *func*dfunc*funt*dfunt + back; } @@ -895,7 +781,6 @@ public double calc_HypoYield(RICHParticle hadron, int hypo_pid, int recotype, do * background; iref = 1 forces a right hypothesis */ - int debugMode = 0; RICHSolution reco = new RICHSolution(); if(recotype==0) reco = analytic; if(recotype==1) reco = traced; @@ -955,18 +840,6 @@ public double calc_HypoYield(RICHParticle hadron, int hypo_pid, int recotype, do if(richpar.USE_PIXEL_BACKGR==1) prob += backgr; - if(debugMode>=1 && iref==0){ - System.out.format("\n HYPO %4d %4d %3d: A %6.2f (%6.2f, %5.2f) ", - hit.get_id(),hypo_pid,irefle,reco.get_EtaC()*MRAD,mean*MRAD,sigma*MRAD); - //System.out.format(" T %6.2f (%6.2f, %5.2f) E %5.2f B %8.4g", - // hit.get_Time(),recot+meant,sigmat,pixel_eff,backgr); - //System.out.format("--> %5.1f %10.4g %10.4g %10.4g --> %8.4g \n", - // Npho,ftheta*dtheta,dphi,ftime*dtime,prob); - System.out.format(" T %6.2f (%6.2f, %5.2f) ", - hit.get_Time(),recot+meant,sigmat); - System.out.format("--> %5.1f %10.4g %10.4g %10.4g %10.4g %10.4g %10.4g --> %8.4g \n\n", - Npho,ftheta,dtheta,dphi,ftime,dtime,backgr,prob); - } return prob; } @@ -978,7 +851,6 @@ public double calc_HypoC2(RICHParticle hadron, int hypo_pid, int recotype) { * based on angle and time of RICH resolution; */ - int debugMode = 0; RICHSolution reco = new RICHSolution(); if(recotype==0) reco = analytic; if(recotype==1) reco = traced; @@ -1002,35 +874,8 @@ public double calc_HypoC2(RICHParticle hadron, int hypo_pid, int recotype) { double ftime = Math.pow((hit.get_Time() - recot - meant)/sigmat, 2); - double prob = ftheta + ftime; - //if(prob>12)prob=12.; - - if(debugMode>=1){ - System.out.format("HYPO %4d %4d %3d: A %6.2f (%6.2f, %5.2f) ", - hit.get_id(),hypo_pid,irefle,reco.get_EtaC()*MRAD,mean*MRAD,sigma*MRAD); - System.out.format(" T %6.2f (%6.2f, %5.2f) ", - hit.get_Time(),recot+meant,sigmat); - System.out.format("--> %10.4g %10.4g --> %10.4g \n", - ftheta,ftime,prob); - } - return prob; - - } - - - /* - public double set_likelihood(double etaC) { - - double pi = probability(211, etaC) - double k = probability(211, etaC) - double pr = probability(211, etaC) - - pi_like = Math.log(pi/(pi+k+pr)); - k_like = Math.log(k/(pi+k+pr)); - pr_like = Math.log(pr/(pi+k+pr)); - + return ftheta + ftime; } - */ public void show() { diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHRayTrace.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHRayTrace.java index bf764a2cf8..6006461dc1 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHRayTrace.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHRayTrace.java @@ -28,82 +28,52 @@ public class RICHRayTrace{ private RICHGeoFactory richgeo; private RICHParameters richpar; - private static final double RAD = RICHConstants.RAD; - private static final double MRAD = RICHConstants.MRAD; - - - public RICHRayTrace() { - } - + public RICHRayTrace() {} public RICHRayTrace(RICHGeoFactory richgeo, RICHParameters richpar){ - this.richgeo = richgeo; this.richpar = richpar; - } - public RICHLayer get_Layer(int isec, String slay){ - return richgeo.get_Layer(isec, slay); - } - public RICHLayer get_Layer(int isec, int ilay){ - return richgeo.get_Layer(isec, ilay); - } - public RICHComponent get_Component(int isec, int ilay, int ico){ - return richgeo.get_Layer(isec, ilay).get(ico); - } - public Vector3D Reflection(Vector3D vector1, Vector3D normal) { - int debugMode = 0; Vector3D vin = vector1.asUnit(); Vector3D vnorm = normal.asUnit(); double cosI = vin.dot(vnorm); - if(debugMode>=1)System.out.format("Vector in %s vnorm %s cosI %7.3f \n ",vin.toStringBrief(3),vnorm.toStringBrief(3),cosI); if (cosI > 0) { - if(debugMode>=1)System.out.format("Mirror normal parallel to impinging ray %7.3f \n",cosI); vnorm.scale(-1.0); } double refle = 2*(vin.dot(vnorm)); Vector3D vout = vin.sub(vnorm.multiply(refle)); - if(debugMode>=1){ - System.out.format("Mirror normal %s\n",normal.toStringBrief(3)); - System.out.format("Reflected versor %s\n", vout.asUnit().toStringBrief(3)); - } - return vout.asUnit(); } public Vector3D Transmission2(Vector3D vector1, Vector3D normal, double n_1, double n_2) { - int debugMode = 0; double rn = n_1 / n_2; Vector3D vin = vector1.asUnit(); Vector3D vnorm = normal.asUnit(); double cosI = vin.dot(vnorm); - if(debugMode>=1)System.out.format("Vector in %s vnorm %s cosI %7.3f \n ",vin.toStringBrief(3),vnorm.toStringBrief(3),cosI); if (cosI < 0) { - if(debugMode>=1)System.out.format("Mirror normal parallel to impinging ray %7.3f \n",cosI); vnorm.scale(-1.0); } - if(debugMode>=1)System.out.format("Vector in %s vnorm %s cosI %7.3f \n ",vin.toStringBrief(3),vnorm.toStringBrief(3),cosI); Vector3D vrot = (vnorm.cross(vin)).asUnit(); @@ -114,77 +84,47 @@ public Vector3D Transmission2(Vector3D vector1, Vector3D normal, double n_1, dou Vector3D vout = q.rotate(vnorm); - if(debugMode>=1){ - System.out.format(" vin %s \n", vin.toStringBrief(3)); - System.out.format(" vnorm %s \n", vnorm.toStringBrief(3)); - System.out.format(" angles %7.3f %7.3f \n",angi*57.3, ango*57.3); - System.out.format(" vout %s \n", vout.toStringBrief(3)); - } - return vout; - } public RICHRay OpticalRotation(RICHRay rayin, RICHIntersection intersection) { - int debugMode = 0; Point3D vori = rayin.origin(); Vector3D inVersor = rayin.direction().asUnit(); Vector3D newVersor = new Vector3D(0.0, 0.0, 0.0); RICHRay rayout = null; int type = 0; - if(debugMode>=1)System.out.format("Ray for %3d %3d %3d \n",intersection.get_sector(), intersection.get_layer(), intersection.get_component()); RICHLayer layer = richgeo.get_Layer(intersection.get_sector(), intersection.get_layer()); if(layer.is_optical()==true){ - if(debugMode>=1)System.out.format("Ray rotation at Optical compo %3d %3d xyz %s \n", intersection.get_layer(), intersection.get_component(), vori.toStringBrief(2)); Vector3D vnorm = intersection.get_normal(); if(vnorm != null ){ if(layer.is_mirror()==true){ - newVersor = Reflection(inVersor, vnorm); type=10000+intersection.get_layer()*100+intersection.get_component()+1; - if(debugMode>=1)System.out.format(" Reflection at mirror surface norm %s \n", vnorm.toStringBrief(3)); - }else{ - newVersor = Transmission2(inVersor, vnorm, intersection.get_nin(), intersection.get_nout()); type=20000+intersection.get_layer()*100+intersection.get_component()+1; - if(debugMode>=1){ - System.out.format(" Refraction at surface boundary norm %s \n", vnorm.toStringBrief(3)); - System.out.format(" norm in %s %7.4f \n",vnorm.toStringBrief(3), vnorm.costheta()); - System.out.format(" vers in %s %7.4f \n",inVersor.toStringBrief(3), inVersor.costheta()); - System.out.format(" vers ou %s %7.4f \n",newVersor.toStringBrief(3), newVersor.costheta()); - } } } - - if(debugMode>=1)System.out.format(" Versor in %s --> out %s \n",inVersor.toStringBrief(3), newVersor.toStringBrief(3)); } rayout = new RICHRay(vori, newVersor.multiply(200)); rayout.set_type(type); return rayout; - } public ArrayList RayTrace(RICHParticle photon, Vector3D vlab) { - - int debugMode = 0; - RICHLayer layer = get_Layer(photon.get_sector(), photon.ilay_emission); - if(debugMode>=1)System.out.format("Raytrace gets refractive index from CCDB database %8.5f \n",layer.get(photon.ico_emission).get_index()); return RayTrace(photon, vlab, layer.get(photon.ico_emission).get_index()); - } public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double naero) { // return the hit position on the PMT plane of a photon emitted at emission with direction vlab - int debugMode = 0; ArrayList raytracks = new ArrayList(); int orilay = photon.ilay_emission; @@ -194,12 +134,6 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na Vector3D vdir = vlab; RICHRay lastray = new RICHRay(emi, vdir.multiply(200)); - if(debugMode>=1) { - System.out.format(" --------------------------- \n"); - System.out.format("Raytrace photon ori %s olay %3d oco %3d dir %s \n",emi.toStringBrief(2),orilay,orico,vdir.toStringBrief(3)); - System.out.format(" --------------------------- \n"); - } - RICHLayer layer = get_Layer(isec, orilay); if(layer==null)return null; @@ -211,11 +145,6 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na } if(first_intersection==null)return null; - if(debugMode>=1){ - System.out.format(" first inter : "); - first_intersection.showIntersection(); - } - Point3D new_pos = first_intersection.get_pos(); RICHRay oriray = new RICHRay(emi, new_pos); @@ -233,13 +162,6 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na lastray.set_refind(geocost.RICH_AIR_INDEX); RICHIntersection last_intersection = first_intersection; - if(debugMode>=1){ - System.out.format(" add first ray : "); - oriray.showRay(); - System.out.format(" get rotated ray : "); - lastray.showRay(); - } - int jj = 1; int front_nrefl = 0; boolean detected = false; @@ -249,7 +171,6 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na Point3D last_ori = lastray.origin(); Point3D new_hit = null; RICHIntersection new_intersection = null; - if(debugMode>=1)System.out.format(" ray-tracking step %d \n",jj); if(last_intersection.get_layer()<4){ @@ -260,14 +181,8 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na if(test_intersection==null)test_intersection = get_Layer(isec, "MIRROR_LEFT_L2").find_Entrance(lastray.asLine3D(), -1); if(test_intersection==null)test_intersection = get_Layer(isec, "MIRROR_RIGHT_R2").find_Entrance(lastray.asLine3D(), -1); if(test_intersection!=null){ - if(debugMode>=1){ - System.out.format(" test planar (z %7.2f, step %7.2f) : ",last_ori.z(), test_intersection.get_pos().distance(last_ori)); - test_intersection.showIntersection(); - } //if(test_intersection.get_pos().distance(last_ori)>RICHConstants.PHOTON_DISTMIN_TRACING)new_intersection = test_intersection; new_intersection = test_intersection; - }else{ - if(debugMode>=1)System.out.format(" no lateral mirror intersection \n"); } // shperical mirrors @@ -275,17 +190,10 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na test_intersection = get_Layer(isec, "MIRROR_SPHERE").find_EntranceCurved(lastray.asLine3D(), -1); if(test_intersection!=null){ - if(debugMode>=1){ - System.out.format(" test sphere (z %7.2f, step %7.2f) : ",last_ori.z(), test_intersection.get_pos().distance(last_ori)); - test_intersection.showIntersection(); - } //if(test_intersection.get_pos().distance(last_ori)>RICHConstants.PHOTON_DISTMIN_TRACING){ if(new_intersection==null || (new_intersection!=null && test_intersection.get_pos().z()=1)System.out.format(" no sphere intersection \n"); } RICHIntersection pmt_inter = get_Layer(isec, "MAPMT").find_Entrance(lastray.asLine3D(), -1); @@ -293,41 +201,26 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na Point3D test_hit = pmt_inter.get_pos(); //if(test_hit.distance(last_ori)>RICHConstants.PHOTON_DISTMIN_TRACING){ new_hit=test_hit; - if(debugMode>=1)System.out.format(" test PMT : Hit %s \n",new_hit.toStringBrief(2)); - //}else{ - //if(debugMode>=1)System.out.format(" too far PMT plane intersection \n"); - //} - }else{ - if(debugMode>=1)System.out.format(" no PMT plane intersection \n"); } }else{ test_intersection = get_Layer(isec, "MIRROR_FRONT_B1").find_Entrance(lastray.asLine3D(), -1); if(test_intersection==null)test_intersection = get_Layer(isec, "MIRROR_FRONT_B2").find_Entrance(lastray.asLine3D(), -1); if(test_intersection!=null){ - if(debugMode>=1){ - System.out.format(" test front (z %7.2f, step %7.2f) : ",last_ori.z(), test_intersection.get_pos().distance(last_ori)); - test_intersection.showIntersection(); - } //if(test_intersection.get_pos().distance(last_ori)>RICHConstants.PHOTON_DISTMIN_TRACING)new_intersection = test_intersection; new_intersection = test_intersection; front_nrefl++; - }else{ - if(debugMode>=1)System.out.format(" no front mirror intersection \n"); } } - } if(new_hit!=null){ if(new_intersection==null || new_hit.distance(last_ori) <= new_intersection.get_pos().distance(last_ori)) { detected=true; - if(debugMode>=1) System.out.format(" found PMT hit %s dist %6.2f \n", new_hit.toStringBrief(2), new_hit.distance(last_ori)); } } if(front_nrefl>richpar.RAY_NFRONT_REFLE){ lost = true; new_hit=new_intersection.get_pos(); - if(debugMode>=1)System.out.format(" double front reflection: stop at front %s \n",new_hit.toStringBrief(2)); } if(new_hit==null && new_intersection==null){ lost = true; @@ -337,31 +230,19 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na if(plane.intersection(lastray.asLine3D(), point)==1){ double vers = lastray.direction().costheta(); double Delta_z = point.z()-lastray.origin().z(); - if(debugMode>=1) System.out.format(" forced stop at PMT plane: Delta_z %7.3f vers %7.3f \n",Delta_z, vers); if(Delta_z*vers>0){ new_hit=point; - if(debugMode>=1) System.out.format(" take PMT plane hit %s \n", new_hit.toStringBrief(2)); - }else{ - if(debugMode>=1) System.out.format(" no Delta_z on PMT plane: take last ray end %s \n", new_hit.toStringBrief(2)); } - }else{ - if(debugMode>=1) System.out.format(" no hit on PMT plane: take last ray end %s \n", new_hit.toStringBrief(2)); } } if(lost || detected){ - if(debugMode>=1 && lost) System.out.format("LOST! stop ray-tracing \n"); - if(debugMode>=1 && detected) System.out.format("DETECTED! stop ray-tracing \n"); RICHRay newray = new RICHRay(last_ori, new_hit); newray.set_type(lastray.get_type()); newray.set_refind((float) geocost.RICH_AIR_INDEX); if(detected)newray.set_detected(); raytracks.add(newray); - if(debugMode>=1){ - System.out.format(" --> Add last ray (%7.4f) : ", geocost.RICH_AIR_INDEX); - newray.showRay(); - } }else{ @@ -375,28 +256,17 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na lastray = OpticalRotation(rayin, new_intersection); lastray.set_refind(new_intersection.get_nout()); - if(debugMode>=1){ - System.out.format(" --> Add new ray (%7.4f) : ",new_intersection.get_nin()); - newray.showRay(); - System.out.format(" --> Get rotated ray (%7.4f) : ",new_intersection.get_nout()); - lastray.showRay(); - } - } jj++; } - if(debugMode>=1) System.out.format(" --------------------------- \n"); - //if(detected==true)return raytracks; return raytracks; - //return null; } public void find_EtaC_raytrace_migrad(RICHParticle hadron, RICHParticle photon) { - int debugMode = 0; double n_a = geocost.RICH_AIR_INDEX; double Phi_ini = photon.trial_pho.lab_phi; @@ -406,11 +276,6 @@ public void find_EtaC_raytrace_migrad(RICHParticle hadron, RICHParticle photon) double Theta_P = hadron.lab_theta; double Phi_P = hadron.lab_phi; double start_EtaC=Math.sin(Theta_P)* Math.sin(Theta_ini)*Math.cos(Phi_ini-Phi_P)+Math.cos(Theta_P)*Math.cos(Theta_ini); - if(debugMode>=0){ - System.out.format(" Tracing starting values \n"); - System.out.format(" Hadron phi %8.2f theta %8.2f \n ", Phi_P*RAD, Theta_P*RAD); - System.out.format(" Photon initial phi %8.2f theta %8.2f EtaC %10.4f \n ", Phi_ini*RAD, Theta_ini*RAD, start_EtaC*MRAD); - } // Minimizing function FCNBase myFunction = new FCNBase() { @@ -427,23 +292,15 @@ public double valueOf(double[] par) { Function = pmt_hit.distance(photon.get_HitPos()); } - if(debugMode>=0)System.out.format(" ==> %8.2f %8.2f | %s vs %s --> %10.4f \n", - theta*RAD, phi*RAD, pmt_hit.toStringBrief(2), - photon.get_HitPos().toStringBrief(2), Function); return Function; } }; - if(debugMode>=0)System.out.format(" Start minimization %8.2f %8.2f | %8.2f %8.2f \n",Theta_P*RAD, Phi_P*RAD, Theta_ini*RAD, Phi_ini*RAD); MnUserParameters myParameters = new MnUserParameters(); myParameters.add("Theta",Theta_ini, 0.01); myParameters.add("Phi",Phi_ini, 0.01); MnMigrad migrad = new MnMigrad(myFunction, myParameters); FunctionMinimum min = migrad.minimize(); - if(debugMode>=0){ - System.out.format(" --> Minimum value %g found using %d calls: result is %8.2f %8.2f\n", - min.fval(), min.nfcn(), min.userParameters().value(0)*RAD, min.userParameters().value(1)*RAD); - } double Theta_Min = min.userParameters().value(0); double Phi_Min = min.userParameters().value(1); @@ -463,39 +320,22 @@ public double valueOf(double[] par) { Vector3D vmin = new Vector3D( Math.sin(Theta_Min)*Math.cos(Phi_Min), Math.sin(Theta_Min)*Math.sin(Phi_Min), Math.cos(Theta_Min)); ArrayList raysmin = RayTrace(photon, vmin); if(raysmin!=null)photon.traced.set_raytracks(raysmin); - - if(debugMode>=1){ - photon.traced.show_raytrack(); - System.out.format("#### ETAC ref %8.4f min %8.4f path %8.2f time %8.2f \n", photon.EtaC_ref*MRAD, - photon.traced.get_EtaC()*MRAD, photon.traced.get_raypath(), photon.traced.get_raytime()); - } - - }else{ - if(debugMode>=0) System.out.format("Missing starting values from trial photon\n"); } - } public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, int hypo) { - int debugMode = 0; - if(hypo<0 || hypo>=RICHConstants.N_HYPO ) return; double n_a = geocost.RICH_AIR_INDEX; int hypo_pid = RICHConstants.HYPO_LUND[hypo]; if(photon.trial_pho==null){ - if(debugMode>=1) System.out.format(" Missing starting values from trial photon\n"); return; } double Theta_P = hadron.lab_theta; double Phi_P = hadron.lab_phi; - if(debugMode>=1) { - System.out.format(" Hadron phi %8.2f theta %8.2f \n", Phi_P*RAD, Theta_P*RAD); - System.out.format(" Measured hit %s \n",photon.get_HitPos().toStringBrief(2)); - } // taking starting point (from most closed throws) double phi_min = photon.trial_pho.lab_phi; @@ -515,15 +355,8 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i if(Math.abs(Cos_EtaC)<1.)EtaCmin = Math.acos(Cos_EtaC); int ntrials = 0; - if(debugMode>=1)System.out.format("check %7.2f [%7.2f %7.2f %7.2f --> %7.2f] : %4d [%4d] \n ",dist, - photon.nominal_sChAngle(), RICHConstants.GAP_NOMINAL_SIZE, richpar.RAYTRACE_RESO_FRAC, - photon.nominal_sChAngle()*RICHConstants.GAP_NOMINAL_SIZE*richpar.RAYTRACE_RESO_FRAC,ntrials,richpar.RAYTRACE_MAX_NSTEPS); while (dist > photon.nominal_sChAngle()*RICHConstants.GAP_NOMINAL_SIZE*richpar.RAYTRACE_RESO_FRAC && ntrials=1){ - System.out.format(" Attempt %d with the %7.1f (%7.2f) phi %7.2f EtaC %7.2f\n",ntrials, the_min*MRAD, the_min*RAD, phi_min*RAD, EtaCmin*MRAD); - System.out.format(" --> (nrfl %2d) pos %s dist %7.4f (x %7.4f y %7.4f) \n", nrefle_min, pmt_min.toStringBrief(2), dist, vec_dist.x(), vec_dist.y()); - } double dthe = 0.0; double dphi = 0.0; @@ -535,7 +368,6 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i ArrayList rays_dthe = RayTrace(photon, vpho_dthe, naero); if(rays_dthe!=null && rays_dthe.get(rays_dthe.size()-1).is_detected()){ int nrefle_dthe = get_Nrefle(rays_dthe); - if(debugMode>=1) System.out.format(" test %2d the %7.1f nrfl %2d vs %2d ",nthe, theta_dthe*MRAD, nrefle_dthe, nrefle_min); if(nrefle_dthe==nrefle_min){ Point3D pmt_dthe = rays_dthe.get(rays_dthe.size()-1).end(); Vector3D vers_dthe = pmt_dthe.vectorFrom(pmt_min); @@ -543,14 +375,8 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i dthe_min = pmt_dthe.distance(pmt_min)*nthe; // theta step for minimization dthe = (vec_dist.x()*vers_dthe.x() + vec_dist.y()*vers_dthe.y()) / (vers_dthe.x()*vers_dthe.x() + vers_dthe.y()*vers_dthe.y()) * photon.nominal_sChAngle(); - if(debugMode>=1) { - System.out.format(" --> dthe pos %s delta %7.1f (%8.2f %8.2f) %7.2f \n", - pmt_dthe.toStringBrief(2), dthe*MRAD, vers_dthe.x(), vers_dthe.y(),dthe_min); - dump_raytrack("TTTT",rays_dthe); - } break; }else{ - if(debugMode>=1) System.out.format(" failed \n"); } } } @@ -563,7 +389,6 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i ArrayList rays_dphi = RayTrace(photon, vpho_dphi, naero); if(rays_dphi!=null && rays_dphi.get(rays_dphi.size()-1).is_detected()){ int nrefle_dphi = get_Nrefle(rays_dphi); - if(debugMode>=1) System.out.format(" test %2d phi %7.2f nrfl %2d vs %2d ",nphi, phi_dphi*RAD, nrefle_dphi, nrefle_min); if(nrefle_dphi==nrefle_min){ Point3D pmt_dphi = rays_dphi.get(rays_dphi.size()-1).end(); Vector3D vers_dphi = (pmt_dphi.vectorFrom(pmt_min)); @@ -571,14 +396,8 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i dphi_min = pmt_dphi.distance(pmt_min)*nphi; // phi step for minimization dphi = (vec_dist.x()*vers_dphi.x() + vec_dist.y()*vers_dphi.y()) / (vers_dphi.x()*vers_dphi.x() + vers_dphi.y()*vers_dphi.y()) * photon.nominal_sChAngle(); - if(debugMode>=1) { - System.out.format(" --> dphi pos %s delta %7.2f (%8.2f %8.2f) %7.2f \n", - pmt_dphi.toStringBrief(2), dphi*RAD, vers_dphi.x(), vers_dphi.y(),dphi_min); - dump_raytrack("TTTT",rays_dphi); - } break; }else{ - if(debugMode>=1) System.out.format(" failed \n"); } } } @@ -588,7 +407,6 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i for (int nn=1; nn<=4; nn++){ double the_new = the_min + dthe/nn; double phi_new = phi_min + dphi/nn; - if(debugMode>=1) System.out.format(" do step nn %3d the %7.1f phi %7.2f (from %7.1f %7.2f) \n",nn,the_new*MRAD,phi_new*RAD,the_min*MRAD,phi_min*RAD); Vector3D vpho_min = new Vector3D( Math.sin(the_new)*Math.cos(phi_new), Math.sin(the_new)*Math.sin(phi_new), Math.cos(the_new)); double naero = 1/(hadron.get_beta(hypo_pid)*(Math.sin(Theta_P)* Math.sin(the_new)*Math.cos(phi_new-Phi_P)+Math.cos(Theta_P)*Math.cos(the_new))); @@ -596,7 +414,6 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i rays_min = RayTrace(photon, vpho_min, naero); if(rays_min!=null && rays_min.get(rays_min.size()-1).is_detected()){ int nrefle_new = get_Nrefle(rays_min); - if(debugMode>=1) System.out.format(" test %2d the %7.1f phi %7.2f nrfl %2d vs %2d ",nn, the_new*MRAD, phi_new*RAD, nrefle_new, nrefle_min); if(nrefle_new==nrefle_min){ the_min = the_new; phi_min = phi_new; @@ -607,24 +424,14 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i EtaCmin = 0.0; if(Math.abs(Cos_EtaC)<1.)EtaCmin = Math.acos(Cos_EtaC); found = 1; - if(debugMode>=1) { - System.out.format(" found new point %s dist %7.2f\n",pmt_min.toStringBrief(2), dist); - dump_raytrack("TTTT",rays_min); - } break; - }else{ - if(debugMode>=1) System.out.format(" failed \n"); } - }else{ - if(debugMode>=1) System.out.format(" no PMT hit \n"); } } if(found==0){ - if(debugMode>=1) System.out.format(" No Raytrace solution; give up \n"); return; } }else{ - if(debugMode>=1) System.out.format(" No Raytrace solution; give up \n"); return; } @@ -632,15 +439,8 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i } if(dist < photon.nominal_sChAngle()*RICHConstants.GAP_NOMINAL_SIZE){ - - if(debugMode>=1){ - System.out.format(" --> Matched value found using %d calls: result is %8.2f %8.2f matched hit %s dist %7.3f \n", - ntrials, the_min*MRAD, phi_min*RAD, pmt_min.toStringBrief(2), dist); - } - int CLASpid = photon.get_CLASpid(); double n_tile = 1/(hadron.get_beta(hypo_pid)*(Math.sin(Theta_P)* Math.sin(the_min)*Math.cos(phi_min-Phi_P)+Math.cos(Theta_P)*Math.cos(the_min))); - photon.traced.set_theta((float) the_min); photon.traced.set_phi((float) phi_min); photon.traced.set_dthe_res((float) dthe_min); @@ -650,14 +450,6 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i photon.traced.set_aeron((float) n_tile); photon.traced.set_EtaC((float) EtaCmin); photon.traced.set_raytracks(rays_min); - - if(debugMode>=1){ - photon.traced.show_raytrack(); - System.out.format("#### ETAC %s TRA min %8.4f ttime %8.2f dthe (%7.2f, %7.2f) dphi (%7.2f, %7.2f) \n", - RICHConstants.HYPO_LUND[hypo], photon.traced.get_EtaC()*MRAD, photon.traced.get_time(), - photon.traced.get_dthe_res(), photon.traced.get_dthe_bin(), - photon.traced.get_dphi_res(), photon.traced.get_dphi_bin()); - } } } @@ -665,15 +457,10 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i public double find_dthe_steps(RICHParticle photon) { - int debugMode = 0; - double pho_phi = photon.traced.get_phi(); Point3D pho_hit = photon.traced.get_hit(); int pho_nrefle = photon.traced.get_Nrefle(); - if(debugMode>=1)System.out.format("Find_dthe %7.2f %7.2f %s ", - photon.traced.get_theta()*MRAD,photon.nominal_sChAngle()*MRAD,pho_hit.toStringBrief(2)); - double dthe_res = RICHConstants.TRACE_NOMINAL_DTHE; for (int nthe=1; nthe<=4; nthe++){ double theta_dthe = photon.traced.get_theta() + photon.nominal_sChAngle()/nthe; @@ -681,16 +468,10 @@ public double find_dthe_steps(RICHParticle photon) { ArrayList rays_dthe = RayTrace(photon, vpho_dthe); if(rays_dthe!=null){ int nrefle_dthe = get_Nrefle(rays_dthe); - if(debugMode>=1) System.out.format(" --> test %2d the %7.1f nrfl %2d vs %2d ",nthe, - theta_dthe*MRAD, nrefle_dthe, pho_nrefle); - if(nrefle_dthe==pho_nrefle){ Point3D pmt_dthe = rays_dthe.get(rays_dthe.size()-1).end(); dthe_res = pmt_dthe.distance(pho_hit)*nthe; - if(debugMode>=1)System.out.format(" --> %s %7.2f \n", pmt_dthe.toStringBrief(2),dthe_res); break; - }else{ - if(debugMode>=1) System.out.format(" \n"); } } } @@ -702,15 +483,10 @@ public double find_dthe_steps(RICHParticle photon) { public double find_dphi_steps(RICHParticle photon) { - int debugMode = 0; - double pho_the = photon.traced.get_theta(); Point3D pho_hit = photon.traced.get_hit(); int pho_nrefle = photon.traced.get_Nrefle(); - if(debugMode>=1)System.out.format("Find_dphi %7.2f %7.2f %s ", - photon.traced.get_phi()*MRAD,photon.nominal_sChAngle()*MRAD,pho_hit.toStringBrief(2)); - double dphi_res = RICHConstants.TRACE_NOMINAL_DPHI; for (int nphi=1; nphi<=4; nphi++){ double phi_dphi = photon.traced.get_phi() + photon.nominal_sChAngle()/nphi; @@ -718,16 +494,10 @@ public double find_dphi_steps(RICHParticle photon) { ArrayList rays_dphi = RayTrace(photon, vpho_dphi); if(rays_dphi!=null){ int nrefle_dphi = get_Nrefle(rays_dphi); - if(debugMode>=1) System.out.format(" --> test %2d phi %7.1f nrfl %2d vs %2d ",nphi, - phi_dphi*MRAD, nrefle_dphi, pho_nrefle); - if(nrefle_dphi==pho_nrefle){ Point3D pmt_dphi = rays_dphi.get(rays_dphi.size()-1).end(); dphi_res = pmt_dphi.distance(pho_hit)*nphi; - if(debugMode>=1)System.out.format(" --> %s %7.2f \n", pmt_dphi.toStringBrief(2),dphi_res); break; - }else{ - if(debugMode>=1) System.out.format(" \n"); } } } @@ -739,7 +509,6 @@ public double find_dphi_steps(RICHParticle photon) { public void find_EtaC_analytic_migrad (RICHParticle hadron, RICHParticle photon) { - int debugMode = 0; double n_a = geocost.RICH_AIR_INDEX; // The following definition should be read by the geometry @@ -751,7 +520,6 @@ public void find_EtaC_analytic_migrad (RICHParticle hadron, RICHParticle photon) Vector3D vec_b = photon.ref_impact.vectorFrom(hadron.ref_proj); double radius = vec_b.mag(); - if(debugMode>=1)System.out.println(" T_g "+T_g+" T_r "+T_r+" L "+L+" R "+radius); if(radius >=-1 ) { // Starting values @@ -759,11 +527,6 @@ public void find_EtaC_analytic_migrad (RICHParticle hadron, RICHParticle photon) double Theta_ini = photon.ref_theta; double Theta_P = hadron.ref_theta; double Phi_P = hadron.ref_phi; - if(debugMode>=1){ - System.out.format(" Minimization starting values \n"); - System.out.format(" Hadron phi %8.2f initial Theta %8.2f \n ", Phi_P*RAD, Theta_P*RAD); - System.out.format(" Photon radius %8.2f phi %8.2f Theta %8.2f EtaC %10.4f \n ", radius, Phi*RAD, Theta_ini*RAD, photon.EtaC_ref*MRAD); - } // Minimizing function int CLASpid = photon.get_CLASpid(); @@ -779,19 +542,14 @@ public double valueOf(double[] par) { double Fun = (T_r -L) * Math.tan(Theta)+T_g* (n_tile * Math.sin(Theta))/Denominator; double Function = Math.pow(radius - Fun, 2); - if(debugMode>=1)System.out.format(" ==> %8.2f %8.2f | %8.2f %8.2f | %9.3f %10.4f \n",Theta_P*RAD, Phi_P*RAD, Theta*RAD, Phi*RAD, nn_tile, Function); return Function; } }; - if(debugMode>=1)System.out.format(" Start minimization %8.2f %8.2f | %8.2f %8.2f \n",Theta_P*RAD, Phi_P*RAD, Theta_ini*RAD, Phi*RAD); MnUserParameters myParameters = new MnUserParameters(); myParameters.add("Theta",Theta_ini, 0.01); MnMigrad migrad = new MnMigrad(myFunction, myParameters); FunctionMinimum min = migrad.minimize(); - if(debugMode>=1){ - System.out.format(" --> Minimum value %g found using %d calls: result is %8.2f \n", min.fval(), min.nfcn(), min.userParameters().value(0)*RAD); - } double Theta_Min = min.userParameters().value(0); photon.analytic.set_theta((float) Theta_Min); photon.analytic.set_phi((float) Phi); @@ -811,27 +569,21 @@ public double valueOf(double[] par) { photon.analytic.set_aeron((float) n_tile); photon.analytic.set_EtaC((float) Math.acos(Cos_EtaC) ); - if(debugMode>=1){ - System.out.format("#### ETAC ALY ref %8.4f min %8.4f path %8.2f time %8.2f \n", photon.EtaC_ref*MRAD, photon.analytic.get_EtaC()*MRAD, photon.analytic.get_path(), photon.analytic.get_time()); - } - } } - + + public Point3D find_IntersectionSpheMirror(int isec, Line3D ray){ - return richgeo.find_IntersectionSpheMirror(isec, ray); - } - + + public Point3D find_IntersectionMAPMT(int isec, Line3D ray){ - return richgeo.find_IntersectionMAPMT(isec, ray); } - - + + public int get_Nrefle(ArrayList rays) { - int nrfl=0; for (RICHRay ray : rays) { int refe = (int) ray.get_type()/10000; @@ -842,7 +594,6 @@ public int get_Nrefle(ArrayList rays) { public void dump_raytrack(String head, ArrayList raytracks) { - int ii=0; for(RICHRay ray: raytracks){ if(head!=null){ @@ -856,15 +607,11 @@ public void dump_raytrack(String head, ArrayList raytracks) { public int get_RefleLayers(ArrayList raytracks) { - - int debugMode = 0; - int relay = 0 ; if(raytracks.size()<=2) return relay; for(int i=2; i %3d %7.2f %5d \n",raytracks.get(i).get_type(),i,off,ilay); if (ilay==11){ relay += off*2; }else{ @@ -872,11 +619,9 @@ public int get_RefleLayers(ArrayList raytracks) { } } return relay; - } public int get_RefleCompos(ArrayList raytracks) { - int recompo = 0 ; if(raytracks.size()<=2) return recompo; for(int i=2; i raytracks) { recompo += off*icompo; } return recompo; - } } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHRecoType.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHRecoType.java index 40c6a80e81..d7f6c8ccd6 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHRecoType.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHRecoType.java @@ -1,16 +1,16 @@ package org.jlab.rec.rich; /* - * @author mcontalb - */ +* @author mcontalb +*/ enum RICHRecoType{ - ANALYTIC (0, "analytic"), TRACED(1, "traced"), UNDEFINED (3, "undefined"); - - private String stringtype; - private int id; - - private RICHRecoType(int id, String stringtype){ this.id=id; this.stringtype = stringtype;} - - public String type() {return stringtype;} - public int id() {return id;} - } + ANALYTIC (0, "analytic"), TRACED(1, "traced"), UNDEFINED (3, "undefined"); + + private String stringtype; + private int id; + + private RICHRecoType(int id, String stringtype){ this.id=id; this.stringtype = stringtype;} + + public String type() {return stringtype;} + public int id() {return id;} +} diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHSolution.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHSolution.java index 630779a008..55e28f22b3 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHSolution.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHSolution.java @@ -10,8 +10,6 @@ public class RICHSolution { - private int debugMode = 0; - public RICHSolution(){} public RICHSolution(int type) { @@ -128,7 +126,6 @@ public double get_raypath() { double rpath = 0.0; for (RICHRay ray : raytracks) { rpath = rpath + ray.direction().mag(); - if(debugMode>=2)System.out.format(" photon ray path %s --> %8.2f %8.2f \n",ray.direction().toStringBrief(3), ray.direction().mag(),rpath); } return (double) rpath; } @@ -139,7 +136,6 @@ public double get_raytime() { for (RICHRay ray : raytracks) { double dtime = ray.direction().mag()/PhysicsConstants.speedOfLight()*ray.get_refind(); time = time + (double) dtime; - if(debugMode>=3)System.out.format(" photon ray path %8.2f n %8.2f --> %8.2f %8.2f \n", ray.direction().mag(),ray.get_refind(),dtime,time); } return time; } @@ -148,14 +144,11 @@ public double get_raytime() { public int get_RefleLayers() { // return a coded flag with the layer sequence alongt the photon path - int debugMode = 0; - int relay = 0 ; if(raytracks.size()<=2) return relay; for(int i=2; i %3d %7.2f %5d \n",raytracks.get(i).get_type(),i,off,ilay); if (ilay==11){ relay += off*2; }else{ @@ -221,11 +214,9 @@ public boolean is_Hit(int lay, int compo) { public boolean exist(){ // return true if a raytrace solution was found if(raytracks.size()<=1) { - if(debugMode>0)System.out.format("No raytrace solution \n"); return false; } if(!get_lastray().is_detected()){ - if(debugMode>0)System.out.format("No raytrace detected \n"); return false; } return true; @@ -237,8 +228,6 @@ public boolean exist(){ public void set_status(int isec, int lai, int ico, int iqua, RICHCalibration richcal) { // record if there is a bad-status mirror on the photon path - int debugMode = 0; - if(!exist()) return; if(richcal.get_AeroStatus(isec, lai, ico, iqua)>0){status=1; return;} if(raytracks.size()>2){ @@ -252,7 +241,6 @@ public void set_status(int isec, int lai, int ico, int iqua, RICHCalibration ric icompo = 0; } int check = richcal.get_MirrorStatus(isec, ilay, icompo+1); - if(debugMode>0)System.out.format("check ray %3d %6d %3d %3d --> %3d \n",i,raytracks.get(i).get_type(),ilay,icompo, check); if(check>0){status=1; return;} } } @@ -285,15 +273,11 @@ public int get_RefleType() { public int get_Nrefle() { - int debugMode = 0; - - if(debugMode==1)System.out.format("RICHSolution::get_Nrefle \n"); int nrfl=0; int ira=0; for (RICHRay ray : raytracks) { int refe = (int) ray.get_type()/10000; if(refe == 1) nrfl++; - if(debugMode==1)System.out.format(" ray %3d type %6d refe %3d nrfl %4d \n",ira, ray.get_type(), refe, nrfl); ira++; } return nrfl; @@ -399,13 +383,10 @@ public int get_BestH(int charge) { public double assign_LHCbPID(double lh[]) { - int debugMode = 0; - set_ElProb(lh[0]); set_PiProb(lh[1]); set_KProb(lh[2]); set_PrProb(lh[3]); - if(debugMode==1)System.out.format(" assign (LHCB) %10.4g [%10.4g %10.4g %10.4g] --> ",lh[0],lh[1],lh[2],lh[3]); int ibest=-1; double lhtest=0.0; @@ -453,21 +434,16 @@ public double assign_LHCbPID(double lh[]) { } } - if(debugMode==1)System.out.format(" --> %5d (%10.4g) %5d (%10.4g) %8.4f %8.4f \n",bestH,bestprob,secH,secprob,R_QP,Re_QP); - return R_QP; } public double assign_HypoPID(double lh[]) { - int debugMode = 0; - set_ElProb(lh[0]); set_PiProb(lh[1]); set_KProb(lh[2]); set_PrProb(lh[3]); - if(debugMode==1)System.out.format(" assign (PASS2) %10.4g [%10.4g %10.4g %10.4g] --> ",lh[0],lh[1],lh[2],lh[3]); int ibest=-1; double lhtest=999.0; @@ -515,21 +491,16 @@ public double assign_HypoPID(double lh[]) { } } - if(debugMode==1)System.out.format(" --> %5d (%10.4g) %5d (%10.4g) %8.4f %8.4f \n",bestH,bestprob,secH,secprob,R_QP,Re_QP); - return R_QP; } public double assign_PID(double lh[]) { - int debugMode = 0; - set_ElProb(lh[0]); set_PiProb(lh[1]); set_KProb(lh[2]); set_PrProb(lh[3]); - if(debugMode==1)System.out.format(" assign (PASS1) %10.4g [%10.4g %10.4g %10.4g] --> ",lh[0],lh[1],lh[2],lh[3]); double likeh[] = {lh[1], lh[2], lh[3]}; Arrays.sort(likeh); @@ -557,7 +528,6 @@ public double assign_PID(double lh[]) { //} } } - if(debugMode==1)System.out.format(" --> %5d (%10.4g) %5d (%10.4g) %8.4f %8.4f \n",bestH,bestprob,secH,secprob,R_QP,Re_QP); return R_QP; } @@ -603,10 +573,8 @@ public double assign_PID(double lh[]) { public void set_raytracks(ArrayList rays){ - int debugMode = 0; - //ATT: Vedere se puo' succedere - if(rays==null){if(debugMode>=1)System.out.format("No RAYTRACE solution\n"); return;} + if(rays==null) return; for (RICHRay ray: rays){ this.raytracks.add(ray); } @@ -678,12 +646,10 @@ public void set_raytracks(ArrayList rays){ public double get_EqPixelNumber(){ - int debugMode = 0; double dthe_delta = dthe_res*dthe_bin; double dphi_delta = dphi_res*dphi_bin; double solid = dthe_delta/RICHConstants.PIXEL_NOMINAL_SIZE*dphi_delta/RICHConstants.PIXEL_NOMINAL_SIZE; - if(debugMode>=1)System.out.format(" Eq Pixel %7.2f %7.2f (%7.2f) --> %8.4f \n",dthe_delta,dphi_delta,RICHConstants.PIXEL_NOMINAL_SIZE,solid); return solid; } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTime.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTime.java deleted file mode 100644 index 9da4c50b26..0000000000 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTime.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.jlab.rec.rich; - -/** - * @author mcontalb - */ -public class RICHTime{ - - private final static int NTIME = 10; - private long RICH_START_TIME = (long) 0; - private double richprocess_time[] = new double[NTIME]; - private int richprocess_ntimes[] = new int[NTIME]; - // as default, do not print anything - - public RICHTime() { - } - - - public void init_ProcessTime(){ - - int debugMode = 0; - - for(int i=0; i-1 && iphase0){ - int found=-1; - for(int j=i-1; j>-1; j--){ - if(richprocess_ntimes[j]>0){found=j; break;} - } - //if(found>-1){ - // time = (richprocess_time[i]/richprocess_ntimes[i]-richprocess_time[found]/richprocess_ntimes[found]); - //}else{ - time = richprocess_time[i]/richprocess_ntimes[i]; - //} - tot += time; - System.out.format(" PHASE %3d: %s %12.4f average over %6d time %10.4f ms \n", i, str[i], richprocess_time[i], richprocess_ntimes[i], time); - } - } - double zero = 0.0 ; - System.out.format(" TOTAL : %s %12.4f average over %6d time %10.4f ms \n", seve, zero, richprocess_ntimes[0], tot); - - /*for(int i=NTIME-1; i>-1; i--){ - double time = 0.0; - if(richprocess_ntimes[i]>0){ - time = richprocess_time[i]/richprocess_ntimes[i]; - System.out.format(" PHASE %3d: TOTAL average over %6d time %10.4f ms \n", NTIME, richprocess_ntimes[i], time); - break; - } - }*/ - } - -} diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java index ab65def3ac..bb5cb4250c 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java @@ -15,136 +15,93 @@ public RICHio() {} public void clear_LowBanks(DataEvent event) { - int debugMode = 0; - // remove previous version of low-level banks from the event if(event.hasBank("RICH::hits")){ event.removeBank("RICH::hits"); - if(debugMode==1)System.out.format("Remove RICH::hits from event \n"); } if(event.hasBank("RICH::clusters")){ event.removeBank("RICH::clusters"); - if(debugMode==1)System.out.format("Remove RICH::clusters from event \n"); } if(event.hasBank("RICH::Hit")){ event.removeBank("RICH::Hit"); - if(debugMode==1)System.out.format("Remove RICH::Hit from event \n"); } if(event.hasBank("RICH::Cluster")){ event.removeBank("RICH::Cluster"); - if(debugMode==1)System.out.format("Remove RICH::Cluster from event \n"); } if(event.hasBank("RICH::Signal")){ event.removeBank("RICH::Signal"); - if(debugMode==1)System.out.format("Remove RICH::Signal from event \n"); } } public void clear_HighBanks(DataEvent event) { - int debugMode = 0; - // remove previous version of high-level banks from the event if(event.hasBank("RICH::response")){ event.removeBank("RICH::response"); - if(debugMode==1)System.out.format("Remove RICH::response from event \n"); } if(event.hasBank("RICH::hadrons")){ event.removeBank("RICH::hadrons"); - if(debugMode==1)System.out.format("Remove RICH::hadrons from event \n"); } if(event.hasBank("RICH::photons")){ event.removeBank("RICH::photons"); - if(debugMode==1)System.out.format("Remove RICH::photons from event \n"); } if(event.hasBank("RICH::ringCher")){ event.removeBank("RICH::ringCher"); - if(debugMode==1)System.out.format("Remove RICH::ringCher from event \n"); } if(event.hasBank("RICH::hadCher")){ event.removeBank("RICH::hadCher"); - if(debugMode==1)System.out.format("Remove RICH::hadCher from event \n"); } if(event.hasBank("RICH::Response")){ event.removeBank("RICH::Response"); - if(debugMode==1)System.out.format("Remove RICH::Response from event \n"); } if(event.hasBank("RICH::Hadron")){ event.removeBank("RICH::Hadron"); - if(debugMode==1)System.out.format("Remove RICH::Hadron from event \n"); } if(event.hasBank("RICH::Photon")){ event.removeBank("RICH::Photon"); - if(debugMode==1)System.out.format("Remove RICH::Photon from event \n"); } if(event.hasBank("RICH::Ring")){ event.removeBank("RICH::Ring"); - if(debugMode==1)System.out.format("Remove RICH::Ring from event \n"); } if(event.hasBank("RICH::Particle")){ event.removeBank("RICH::Particle"); - if(debugMode==1)System.out.format("Remove RICH::Particle from event \n"); } } public void write_PMTBanks(DataEvent event, RICHEvent richevent) { - - if(richevent.get_nHit()>0)write_HitBank(event, richevent); - if(richevent.get_nClu()>0)write_ClusterBank(event, richevent); - //ATT: pass2 //if(richevent.get_nHit()>0 || richevent.get_nClu()>0) // write_SignalBank(event, richevent); - } public void write_RECBank(DataEvent event, RICHEvent richevent, RICHParameters richpar) { - - int debugMode = 0; - - int NMAT = richevent.get_nMatch(); - if(debugMode>=1)System.out.format("Creating Bank for %5d Matches \n", NMAT); - - if(NMAT>0){ - + if(richevent.get_nMatch() > 0){ String richBank = "RICH::Response"; DataBank bankRich = get_ResponseBank(richevent.get_Matches(), event, richBank, richpar); if(bankRich!=null)event.appendBanks(bankRich); - } - } public void write_CherenkovBanks(DataEvent event, RICHEvent richevent, RICHParameters richpar) { - - //ATT: Pass2 if(richevent.get_nHad()>0)write_HadronBank(event, richevent); - if(richevent.get_nPho()>0)write_PhotonBank(event, richevent, richpar); - if(richevent.get_nPho()>0)write_RingBank(event, richevent, richpar); - if(richevent.get_nHad()>0)write_ParticleBank(event, richevent, richpar); - } private void write_HitBank(DataEvent event, RICHEvent richevent) { - int debugMode = 0; - int NHIT = richevent.get_nHit(); - if(debugMode>=1)System.out.format("Creating Bank for %5d Hits \n", NHIT); if(NHIT>0) { - if(debugMode>=2)System.out.println(" --> Creating the RICH::Hit Bank "); DataBank bankHits = event.createBank("RICH::Hit", NHIT); if(bankHits==null){ System.out.println("ERROR CREATING BANK : RICH::Hit"); @@ -169,8 +126,6 @@ private void write_HitBank(DataEvent event, RICHEvent richevent) { bankHits.setShort("xtalk", i, (short) hit.get_xtalk()); bankHits.setShort("status", i, (short) hit.get_status()); bankHits.setShort("duration",i, (short) hit.get_duration()); - if(debugMode>=1)System.out.format(" hit %3d id %3d [%3d %4d %4d] %3d %3d %5d \n", i, hit.get_id(), - hit.get_sector(), hit.get_pmt(),hit.get_anode(),hit.get_status(),hit.get_cluster(),hit.get_xtalk()); } event.appendBanks(bankHits); } @@ -179,13 +134,9 @@ private void write_HitBank(DataEvent event, RICHEvent richevent) { private void write_ClusterBank(DataEvent event, RICHEvent richevent) { - int debugMode = 0; - int NCLU = richevent.get_nClu(); - if(debugMode>=1)System.out.format("Creating Bank for %5d Clusters \n", NCLU); if(NCLU>0) { - if(debugMode>=2)System.out.println(" --> Creating the RICH::Cluster Bank "); DataBank bankCluster = event.createBank("RICH::Cluster", NCLU); if(bankCluster==null){ System.out.println("ERROR CREATING BANK : RICH::Cluster"); @@ -219,17 +170,13 @@ private void write_ClusterBank(DataEvent event, RICHEvent richevent) { private void write_SignalBank(DataEvent event, RICHEvent richevent) { - int debugMode = 0; - int NHIT = richevent.get_nHit(); int NCLU = richevent.get_nClu(); - if(debugMode>=1)System.out.format("Creating Bank for Signals (%4d HITs and %4d CLUs) \n", NHIT,NCLU); if(NHIT>0 || NCLU>0) { int nsig = richevent.count_Signals(); - if(debugMode>=1)System.out.format(" --> Creating the RICH::Signal Bank for NHIT,NCLU (%5d,%5d) --> %5d \n",NHIT,NCLU,nsig); DataBank bankSignal = event.createBank("RICH::Signal", nsig); if(bankSignal==null){ System.out.println("ERROR CREATING BANK : RICH::Signal"); @@ -241,7 +188,6 @@ private void write_SignalBank(DataEvent event, RICHEvent richevent) { for(int i=0; i < NHIT; i++){ RICHHit hit = richevent.get_Hit(i); - if(debugMode>=1)System.out.format(" hit %3d %5d (%3d %3d %5d) %7.2f",i,hit.get_id(),hit.get_status(),hit.get_cluster(),hit.get_xtalk(),hit.get_Time()); if(ientry0){ @@ -259,18 +205,14 @@ private void write_SignalBank(DataEvent event, RICHEvent richevent) { bankSignal.setFloat("rawtime", ientry, (float) hit.get_rawtime()); bankSignal.setFloat("charge" , ientry, (float) hit.get_duration()); - if(debugMode>=1)System.out.format(" --> sig %4d %5d %7.2f \n",ientry, hit.get_id(), (float) hit.get_duration()); ientry++; - }else{ - if(debugMode>=1)System.out.format(" \n"); } - + } for(int j=0; j < NCLU; j++){ RICHCluster clu = richevent.get_Cluster(j); - if(debugMode>=1)System.out.format(" clu %3d %5d %7.2f ",j,clu.get_id(),clu.get_time()); if(ientry0){ @@ -289,10 +231,7 @@ private void write_SignalBank(DataEvent event, RICHEvent richevent) { bankSignal.setFloat("rawtime", ientry, (float) clu.get_rawtime()); bankSignal.setFloat("charge", ientry, (float) clu.get_charge()); - if(debugMode>=1)System.out.format(" --> clu %4d %5d %7.2f \n",ientry,clu.get_size(),clu.get_charge()); ientry++; - }else{ - if(debugMode>=1)System.out.format("\n"); } } @@ -303,13 +242,9 @@ private void write_SignalBank(DataEvent event, RICHEvent richevent) { public void write_HadronBank(DataEvent event, RICHEvent richevent) { - int debugMode = 0; - int NHAD = richevent.get_nHad(); - if(debugMode>=1)System.out.format("Creating Bank for %5d Hadrons \n", NHAD); if(NHAD>0) { - if(debugMode>=1)System.out.println(" --> Creating the RICH::Hadron Bank "); DataBank bankHads = event.createBank("RICH::Hadron", NHAD); if(bankHads==null){ System.out.println("ERROR CREATING BANK : RICH::Hadron"); @@ -344,8 +279,6 @@ public void write_HadronBank(DataEvent event, RICHEvent richevent) { bankHads.setFloat("etaC_lat", i, (float) had.changle(11,1)); bankHads.setFloat("etaC_sphe", i, (float) had.changle(11,2)); bankHads.setFloat("etaC_rms", i, (float) had.schangle(0)); - if(debugMode>0)System.out.format(" part %4d %4d %4d %5d %5d %7.2f %7.2f \n", - had.get_id(),had.get_HitIndex(),had.get_ParentIndex(),had.ilay_emission,had.ico_emission,had.traced.get_time(),had.traced.get_machi2()); } event.appendBanks(bankHads); @@ -356,13 +289,9 @@ public void write_HadronBank(DataEvent event, RICHEvent richevent) { public void write_ParticleBank(DataEvent event, RICHEvent richevent, RICHParameters richpar) { - int debugMode = 0; - int NHAD = richevent.get_nHad(); - if(debugMode>=1)System.out.format("Creating Bank for %5d RICH Particles \n", NHAD); if(NHAD>0) { - if(debugMode>=1)System.out.println(" --> Creating the RICH::Particle Bank "); DataBank bankPart = event.createBank("RICH::Particle", NHAD); if(bankPart==null){ System.out.println("ERROR CREATING BANK : RICH::Particle"); @@ -372,11 +301,6 @@ public void write_ParticleBank(DataEvent event, RICHEvent richevent, RICHParamet for(int i = 0; i < NHAD; i++){ RICHParticle had = richevent.get_Hadron(i); - double dT_max = richpar.PIXEL_NOMINAL_STIME*3; - - if(debugMode>0)System.out.format(" part %4d %4d %4d %5d %5d %5d %5d \n", - had.get_id(),had.get_HitIndex(),had.get_ParentIndex(),had.ilay_emission,had.ico_emission,had.ico_entrance,had.traced.get_BestH()); - if(had.get_id()>255)continue; if(had.get_HitIndex()>255)continue; if(had.get_ParentIndex()>255)continue; @@ -384,10 +308,6 @@ public void write_ParticleBank(DataEvent event, RICHEvent richevent, RICHParamet if(had.ico_emission>255)continue; if(had.ico_entrance>255)continue; - if(debugMode>0)System.out.format(" RICHio %7.2f %7.2f %5d %7.2f %9.4f %9.4f %7.2f %7.2f %7.2f\n",had.min_changle(0)*MRAD,had.max_changle(0)*MRAD, - had.traced.get_BestH(),had.traced.get_RQP(),had.traced.get_ElProb(),had.traced.get_PiProb(),had.traced.get_BestCH(), - had.traced.get_BestC2(),had.traced.get_BestRL() ); - bankPart.setByte("id", i ,(byte) had.get_id()); bankPart.setShort("hindex", i, (short) had.get_HitIndex()); bankPart.setByte("pindex", i, (byte) had.get_ParentIndex()); @@ -420,10 +340,7 @@ public void write_ParticleBank(DataEvent event, RICHEvent richevent, RICHParamet public void write_RingBank(DataEvent event, RICHEvent richevent, RICHParameters richpar) { - int debugMode = 0; - int NPHO = richevent.get_nPho(); - if(debugMode>=1)System.out.format("Creating Ring Bank from %5d Photons\n", NPHO); if(NPHO!=0) { @@ -439,7 +356,6 @@ public void write_RingBank(DataEvent event, RICHEvent richevent, RICHParameters if(pho.traced.get_OK()>=110) Nring++; } - if(debugMode>=1)System.out.format(" --> Creating the RICH::Ring Bank for Npho %5d Nring %5d \n",NPHO,Nring); DataBank bankRing = event.createBank("RICH::Ring", Nring); if(bankRing==null){ System.out.println("ERROR CREATING BANK : RICH::Ring"); @@ -469,7 +385,6 @@ public void write_RingBank(DataEvent event, RICHEvent richevent, RICHParameters int hypo_pid = pho.traced.get_hypo(had.charge()); if(!pho.is_real())continue; - if(debugMode>=1)System.out.format(" phot %3d (%3d %3d) pmt %4d [%6d] ok %6d ",i,pho.get_ParentIndex(),had.get_ParentIndex(),pmt,pho.traced.get_RefleLayers(),pho.traced.get_OK()); // skip no real Cherenkov solution boolean reject=false; @@ -524,17 +439,9 @@ public void write_RingBank(DataEvent event, RICHEvent richevent, RICHParameters bankRefe.setFloat("etac_ref", ientry, (float) had.changle(hypo_pid,irefle)); bankRefe.setFloat("etac_rms", ientry, (float) had.schangle(irefle));*/ - if(debugMode>=1)System.out.format(" --> ring %3d %5d %7.2f %7.2f (%3d) %7.2f %7.2f \n", - ientry,hypo_pid,t_time,t_etaC*MRAD,use,htime-t_time,prob); ientry++; - }else{ - if(debugMode>=1)System.out.format(" \n"); } - - }else{ - if(debugMode>=1)System.out.format(" \n"); } - } event.appendBanks(bankRing); //event.appendBanks(bankRefe); @@ -544,10 +451,7 @@ public void write_RingBank(DataEvent event, RICHEvent richevent, RICHParameters public void write_PhotonBank(DataEvent event, RICHEvent richevent, RICHParameters richpar) { - int debugMode = 0; - int NPHO = richevent.get_nPho(); - if(debugMode>=1)System.out.format("Creating Bank for %5d Photons \n", NPHO); if(NPHO!=0) { @@ -557,7 +461,6 @@ public void write_PhotonBank(DataEvent event, RICHEvent richevent, RICHParameter if((pho.is_real() && richpar.SAVE_PHOTONS==1) || (!pho.is_real() && richpar.SAVE_THROWS==1))Nrow++; } - if(debugMode>=1)System.out.format(" --> Creating the RICH::Photon Bank for Npho %4d Nrow %4d \n",NPHO,Nrow); DataBank bankPhos = event.createBank("RICH::Photon", Nrow); if(bankPhos==null){ System.out.println("ERROR CREATING BANK : RICH::Photon"); @@ -571,7 +474,6 @@ public void write_PhotonBank(DataEvent event, RICHEvent richevent, RICHParameter RICHParticle pho = richevent.get_Photon(i); RICHParticle had = richevent.get_Hadron( pho.get_ParentIndex() ); int hypo_pid = pho.traced.get_hypo(had.charge()); - if(debugMode>=1)System.out.format(" phot %3d (%3d %3d) %3d %5d ",i,pho.get_ParentIndex(),had.get_ParentIndex(),pho.get_type(),hypo_pid); int use = pho.traced.get_OK(); if(use>=1000)use=-1*(use-1000); @@ -600,7 +502,6 @@ public void write_PhotonBank(DataEvent event, RICHEvent richevent, RICHParameter bankPhos.setFloat("etac_rms", ientry,(float) had.schangle(irefle)); bankPhos.setFloat("etac_ref", ientry,(float) had.changle(hypo_pid,irefle)); - if(debugMode>=1)System.out.format(" %4d --> %4d %4d ", pho.get_id(),ientry,pho.get_HitIndex()); if(pho.traced.exist()){ bankPhos.setFloat("traced_the", ientry,(float) pho.traced.get_theta()); @@ -627,20 +528,10 @@ public void write_PhotonBank(DataEvent event, RICHEvent richevent, RICHParameter if(Math.abs(hypo_pid)==2212) prob = pho.traced.get_PrProb(); bankPhos.setFloat("prob", ientry, (float) prob); - if(debugMode>=1)System.out.format(" --> %4d %7.2f [%7.2f] %7.2f [%7.2f] --> (%5d) %7.2f %6d \n", - irefle,pho.traced.get_EtaC()*MRAD,had.changle(hypo_pid,irefle)*MRAD, - htime,pho.get_StartTime()+pho.traced.get_time(),pho.traced.get_OK(),prob,hypo_pid); - }else{ - if(debugMode>=1)System.out.format(" --> no traced \n"); } - + ientry++; - - }else{ - if(debugMode>=1)System.out.format(" \n"); } - }else{ - if(debugMode>=1)System.out.format(" \n"); } } @@ -651,8 +542,6 @@ public void write_PhotonBank(DataEvent event, RICHEvent richevent, RICHParameter public DataBank get_ResponseBank(List responses, DataEvent event, String bank_name, RICHParameters richpar){ - int debugMode = 0; - if(debugMode>=1)System.out.format("Saving match in RICH::Response bank Nmatches %5d \n",responses.size()); DataBank bank = event.createBank(bank_name, responses.size()); for(int row = 0; row < responses.size(); row++){ DetectorResponse r = (DetectorResponse) responses.get(row); @@ -675,16 +564,8 @@ public DataBank get_ResponseBank(List responses, DataEvent eve Math.pow(r.getMatchedPosition().y()-r.getPosition().y(),2)+ Math.pow(r.getMatchedPosition().z()-r.getPosition().z(),2))/richpar.RICH_HITMATCH_RMS); bank.setFloat("chi2", row, (float) chi2); - - if(debugMode>=1)System.out.format("RICH::Response id %3d hit %6.1f %6.1f %6.1f tk %6.1f %6.1f %6.1f chi2 %8.3f \n", - r.getHitIndex(), - r.getPosition().x(),r.getPosition().y(),r.getPosition().z(), - r.getPosition().x()+(r.getMatchedPosition().x()-r.getPosition().x())*2, - r.getPosition().y()+(r.getMatchedPosition().y()-r.getPosition().y())*2, - r.getPosition().z()+(r.getMatchedPosition().z()-r.getPosition().z())*2,chi2); } return bank; } - } From 0e460057467002480b3ec56df1515b3e439182dc Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Tue, 14 Jul 2026 16:06:20 -0400 Subject: [PATCH 02/10] move debug stuff --- .../java/org/jlab/rec/rich/RICHEBEngine.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java index 39592c7b72..3781356d49 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java @@ -1,6 +1,5 @@ package org.jlab.rec.rich; -import java.util.Arrays; import java.util.Optional; import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.io.base.DataEvent; @@ -10,7 +9,6 @@ public class RICHEBEngine extends ReconstructionEngine { private int Ncalls = 0; private RICHGeoFactory richgeo; - private boolean engineDebug = false; public RICHEBEngine() { super("RICHEB", "mcontalb", "3.0"); @@ -44,23 +42,17 @@ public boolean init() { "/calibration/rich/module2/status_mapmt" }; - requireConstants(Arrays.asList(richTables)); + requireConstants(richTables); - // initialize constants manager default variation, will be then modified based on yaml settings - // Get the constants for the correct variation - String engineVariation = Optional.ofNullable(this.getEngineConfigString("variation")).orElse("default"); - this.getConstantsManager().setVariation(engineVariation); - - if(this.getEngineConfigString("debug")!=null) - this.engineDebug = Boolean.parseBoolean(this.getEngineConfigString("debug")); + String v = Optional.ofNullable(this.getEngineConfigString("variation")).orElse("default"); + this.getConstantsManager().setVariation(v); return true; - } @Override public void detectorChanged(int runNumber) { - richgeo = new RICHGeoFactory(1, this.getConstantsManager(), runNumber, engineDebug); + richgeo = new RICHGeoFactory(1, this.getConstantsManager(), runNumber, false); } @Override @@ -78,10 +70,10 @@ public boolean processDataEventUser(DataEvent event) { // Initialize the CCDB information int run = richevent.get_RunID(); if(run>0){ - richpar.load_CCDB(this.getConstantsManager(), run, Ncalls, engineDebug); + richpar.load_CCDB(this.getConstantsManager(), run, Ncalls, false); richcal.load_CCDB(this.getConstantsManager(), run, Ncalls, richgeo, richpar); }else{ - richpar.load_CCDB(this.getConstantsManager(), 11, Ncalls, engineDebug); + richpar.load_CCDB(this.getConstantsManager(), 11, Ncalls, false); richcal.load_CCDB(this.getConstantsManager(), 11, Ncalls, richgeo, richpar); } Ncalls++; From 10f859c1a0cdbf2714dba1b9c0195b5106aefed1 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Tue, 14 Jul 2026 16:06:27 -0400 Subject: [PATCH 03/10] call rich from eb --- reconstruction/eb/pom.xml | 5 ++ .../java/org/jlab/service/eb/EBEngine.java | 81 ++++++++++--------- 2 files changed, 50 insertions(+), 36 deletions(-) diff --git a/reconstruction/eb/pom.xml b/reconstruction/eb/pom.xml index 8b386b2740..7e701365f9 100644 --- a/reconstruction/eb/pom.xml +++ b/reconstruction/eb/pom.xml @@ -90,6 +90,11 @@ clas12detector-ltcc 14.1.2-SNAPSHOT + + org.jlab.clas12.detector + clas12detector-rich + 14.1.2-SNAPSHOT + junit junit diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java index 89b6bf0145..f732f624bc 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java @@ -13,6 +13,7 @@ import org.jlab.rec.eb.EBCCDBEnum; import org.jlab.rec.eb.EBScalers; import org.jlab.rec.eb.EBRadioFrequency; +import org.jlab.rec.rich.RICHEBEngine; /** * @@ -26,6 +27,8 @@ public class EBEngine extends ReconstructionEngine { boolean usePOCA = false; + RICHEBEngine rich; + // output banks: String eventBank = null; String eventBankFT = null; @@ -58,10 +61,48 @@ public EBEngine(String name){ initBankNames(); } - public void initBankNames() { - //Initialize bank names + @Override + public boolean init() { + + this.registerOutputBank(eventBank); + this.registerOutputBank(particleBank); + this.registerOutputBank(eventBankFT); + this.registerOutputBank(particleBankFT); + this.registerOutputBank(calorimeterBank); + this.registerOutputBank(caloextrasBank); + this.registerOutputBank(scintillatorBank); + this.registerOutputBank(scintextrasBank); + this.registerOutputBank(cherenkovBank); + this.registerOutputBank(trackBank); + this.registerOutputBank(utrackBank); + this.registerOutputBank(ftrackBank); + this.registerOutputBank(crossBank); + this.registerOutputBank(ftBank); + this.registerOutputBank(trajectoryBank); + this.registerOutputBank(covMatrixBank); + + if (this.getEngineConfigString("outputBankPrefix")!=null) { + this.setOutputBankPrefix(this.getEngineConfigString("outputBankPrefix")); + } + + requireConstants(EBCCDBConstants.getAllTableNames()); + + this.getConstantsManager().setVariation("default"); + + if (this.getEngineConfigString("rich") != null) { + rich = new RICHEBEngine(); + rich.init(); + } + return true; } + @Override + public void detectorChanged(int run) { + if (rich != null) rich.detectorChanged(run); + } + + public void initBankNames() {} + public void setUsePOCA(boolean val) { this.usePOCA=val; } @@ -250,6 +291,8 @@ public boolean processDataEventUser(DataEvent de,EBScalers ebs) { } + if (rich != null) rich.processDataEventUser(de); + return true; } @@ -345,38 +388,4 @@ public void setCvtTrajType(String name) { this.cvtTrajType = name; } - @Override - public boolean init() { - - this.registerOutputBank(eventBank); - this.registerOutputBank(particleBank); - this.registerOutputBank(eventBankFT); - this.registerOutputBank(particleBankFT); - this.registerOutputBank(calorimeterBank); - this.registerOutputBank(caloextrasBank); - this.registerOutputBank(scintillatorBank); - this.registerOutputBank(scintextrasBank); - this.registerOutputBank(cherenkovBank); - this.registerOutputBank(trackBank); - this.registerOutputBank(utrackBank); - this.registerOutputBank(ftrackBank); - this.registerOutputBank(crossBank); - this.registerOutputBank(ftBank); - this.registerOutputBank(trajectoryBank); - this.registerOutputBank(covMatrixBank); - - if (this.getEngineConfigString("outputBankPrefix")!=null) { - this.setOutputBankPrefix(this.getEngineConfigString("outputBankPrefix")); - } - - requireConstants(EBCCDBConstants.getAllTableNames()); - - this.getConstantsManager().setVariation("default"); - - return true; - } - - @Override - public void detectorChanged(int runNumber) {} - } From 1c98a45a7351e900ae260b2a986b980d072f8cdb Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Tue, 14 Jul 2026 16:16:04 -0400 Subject: [PATCH 04/10] use registerOutputBank by rich --- .../java/org/jlab/rec/rich/RICHEBEngine.java | 32 +++++++--- .../main/java/org/jlab/rec/rich/RICHio.java | 62 ------------------- 2 files changed, 23 insertions(+), 71 deletions(-) diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java index 3781356d49..cfbcc6dc6d 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java @@ -17,7 +17,7 @@ public RICHEBEngine() { @Override public boolean init() { - String[] richTables = new String[]{ + requireConstants( "/geometry/rich/setup", "/geometry/rich/geo_parameter", "/geometry/rich/module1/aerogel", @@ -40,12 +40,28 @@ public boolean init() { "/calibration/rich/module2/status_mirror", "/calibration/rich/module2/status_aerogel", "/calibration/rich/module2/status_mapmt" - }; - - requireConstants(richTables); + ); + + registerOutputBank( + "RICH::hits", + "RICH::clusters", + "RICH::Hit", + "RICH::Cluster", + "RICH::Signal", + "RICH::response", + "RICH::hadrons", + "RICH::photons", + "RICH::ringCher", + "RICH::hadCher", + "RICH::Response", + "RICH::Hadron", + "RICH::Photon", + "RICH::Ring", + "RICH::Particle" + ); String v = Optional.ofNullable(this.getEngineConfigString("variation")).orElse("default"); - this.getConstantsManager().setVariation(v); + getConstantsManager().setVariation(v); return true; } @@ -80,16 +96,14 @@ public boolean processDataEventUser(DataEvent event) { // Process RICH signals to get hits and clusters if(richpar.PROCESS_RAWDATA==1){ - richio.clear_LowBanks(event); rpmt.process_RawData(event, richpar, richcal); } // Process RICH-DC event reconstruction if(richpar.PROCESS_DATA==1){ - richio.clear_HighBanks(event); - if( !reb.process_Data(event, richpar, richcal, richtrace)) return false; + reb.process_Data(event, richpar, richcal, richtrace); } - + return true; } } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java index bb5cb4250c..2a01fe79e6 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java @@ -4,73 +4,11 @@ import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.clas.detector.DetectorResponse; -import org.jlab.detector.geom.RICH.RICHGeoConstants; public class RICHio { - private static double MRAD = RICHGeoConstants.MRAD; - private static double RAD = RICHGeoConstants.RAD; - public RICHio() {} - public void clear_LowBanks(DataEvent event) { - - // remove previous version of low-level banks from the event - if(event.hasBank("RICH::hits")){ - event.removeBank("RICH::hits"); - } - if(event.hasBank("RICH::clusters")){ - event.removeBank("RICH::clusters"); - } - if(event.hasBank("RICH::Hit")){ - event.removeBank("RICH::Hit"); - } - if(event.hasBank("RICH::Cluster")){ - event.removeBank("RICH::Cluster"); - } - if(event.hasBank("RICH::Signal")){ - event.removeBank("RICH::Signal"); - } - } - - - public void clear_HighBanks(DataEvent event) { - - // remove previous version of high-level banks from the event - if(event.hasBank("RICH::response")){ - event.removeBank("RICH::response"); - } - if(event.hasBank("RICH::hadrons")){ - event.removeBank("RICH::hadrons"); - } - if(event.hasBank("RICH::photons")){ - event.removeBank("RICH::photons"); - } - if(event.hasBank("RICH::ringCher")){ - event.removeBank("RICH::ringCher"); - } - if(event.hasBank("RICH::hadCher")){ - event.removeBank("RICH::hadCher"); - } - - if(event.hasBank("RICH::Response")){ - event.removeBank("RICH::Response"); - } - if(event.hasBank("RICH::Hadron")){ - event.removeBank("RICH::Hadron"); - } - if(event.hasBank("RICH::Photon")){ - event.removeBank("RICH::Photon"); - } - if(event.hasBank("RICH::Ring")){ - event.removeBank("RICH::Ring"); - } - if(event.hasBank("RICH::Particle")){ - event.removeBank("RICH::Particle"); - } - } - - public void write_PMTBanks(DataEvent event, RICHEvent richevent) { if(richevent.get_nHit()>0)write_HitBank(event, richevent); if(richevent.get_nClu()>0)write_ClusterBank(event, richevent); From 5c0cb3cfd9e58e416f4b98652039db797db3de2c Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Tue, 14 Jul 2026 16:29:29 -0400 Subject: [PATCH 05/10] change comfig string --- .../eb/src/main/java/org/jlab/service/eb/EBEngine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java index f732f624bc..5ea8d2b974 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java @@ -89,7 +89,7 @@ public boolean init() { this.getConstantsManager().setVariation("default"); - if (this.getEngineConfigString("rich") != null) { + if (this.getEngineConfigString("eb-rich") != null) { rich = new RICHEBEngine(); rich.init(); } From 3648c2ff2ea5ff74e6f6434f60f4144d8ba09378 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Tue, 14 Jul 2026 18:14:50 -0400 Subject: [PATCH 06/10] resolve ide warnings --- .../java/org/jlab/service/eb/EBEngine.java | 7 +- .../java/org/jlab/rec/rich/RICHEBEngine.java | 8 +- .../org/jlab/rec/rich/RICHEventBuilder.java | 4 +- .../java/org/jlab/rec/rich/RICHRayTrace.java | 82 +++++++------------ 4 files changed, 42 insertions(+), 59 deletions(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java index 5ea8d2b974..bfd112fb02 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java @@ -290,9 +290,12 @@ public boolean processDataEventUser(DataEvent de,EBScalers ebs) { } } - - if (rich != null) rich.processDataEventUser(de); + if (rich != null) { + rich.dropBanks(de); + rich.processDataEventUser(de); + } + return true; } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java index cfbcc6dc6d..6dac9798d5 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java @@ -9,7 +9,7 @@ public class RICHEBEngine extends ReconstructionEngine { private int Ncalls = 0; private RICHGeoFactory richgeo; - + public RICHEBEngine() { super("RICHEB", "mcontalb", "3.0"); } @@ -60,12 +60,12 @@ public boolean init() { "RICH::Particle" ); - String v = Optional.ofNullable(this.getEngineConfigString("variation")).orElse("default"); + String v = Optional.ofNullable(getEngineConfigString("variation")).orElse("default"); getConstantsManager().setVariation(v); - + return true; } - + @Override public void detectorChanged(int runNumber) { richgeo = new RICHGeoFactory(1, this.getConstantsManager(), runNumber, false); diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEventBuilder.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEventBuilder.java index f1b44e96a1..4ebd5bd2fb 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEventBuilder.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEventBuilder.java @@ -43,7 +43,7 @@ public boolean process_Data(DataEvent event, RICHParameters richpar, RICHCalibra // look for RICH - DC matches if(!process_DCData(event, richpar)) return false; - richio.write_RECBank(event, richevent, richpar); + if(richio!=null) richio.write_RECBank(event, richevent, richpar); // create RICH particles if(!process_RICHData(event, richtrace, richpar, richcal)) return false; @@ -54,7 +54,7 @@ public boolean process_Data(DataEvent event, RICHParameters richpar, RICHCalibra // ray-traced solution (all photons) if(!reco_Cherenkovs(richtrace, richpar, richcal)) return false; - richio.write_CherenkovBanks(event, richevent, richpar); + if(richio!=null) richio.write_CherenkovBanks(event, richevent, richpar); return true; } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHRayTrace.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHRayTrace.java index 6006461dc1..24e0a9f61b 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHRayTrace.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHRayTrace.java @@ -23,8 +23,6 @@ */ public class RICHRayTrace{ - private final static RICHGeoConstants geocost = new RICHGeoConstants(); - private RICHGeoFactory richgeo; private RICHParameters richpar; @@ -92,7 +90,6 @@ public RICHRay OpticalRotation(RICHRay rayin, RICHIntersection intersection) { Point3D vori = rayin.origin(); Vector3D inVersor = rayin.direction().asUnit(); Vector3D newVersor = new Vector3D(0.0, 0.0, 0.0); - RICHRay rayout = null; int type = 0; RICHLayer layer = richgeo.get_Layer(intersection.get_sector(), intersection.get_layer()); @@ -111,7 +108,7 @@ public RICHRay OpticalRotation(RICHRay rayin, RICHIntersection intersection) { } } - rayout = new RICHRay(vori, newVersor.multiply(200)); + RICHRay rayout = new RICHRay(vori, newVersor.multiply(200)); rayout.set_type(type); return rayout; } @@ -125,7 +122,7 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab) { public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double naero) { // return the hit position on the PMT plane of a photon emitted at emission with direction vlab - ArrayList raytracks = new ArrayList(); + ArrayList raytracks = new ArrayList<>(); int orilay = photon.ilay_emission; int orico = photon.ico_emission; @@ -137,7 +134,7 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na RICHLayer layer = get_Layer(isec, orilay); if(layer==null)return null; - RICHIntersection first_intersection = null; + RICHIntersection first_intersection; if(richpar.DO_CURVED_AERO==1){ first_intersection = layer.find_ExitCurved(lastray.asLine3D(), orico); }else{ @@ -159,7 +156,7 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na RICHRay rayin = new RICHRay(new_pos, oriray.direction().multiply(200)); lastray = OpticalRotation(rayin, first_intersection); - lastray.set_refind(geocost.RICH_AIR_INDEX); + lastray.set_refind(RICHGeoConstants.RICH_AIR_INDEX); RICHIntersection last_intersection = first_intersection; int jj = 1; @@ -191,7 +188,7 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na if(test_intersection!=null){ //if(test_intersection.get_pos().distance(last_ori)>RICHConstants.PHOTON_DISTMIN_TRACING){ - if(new_intersection==null || (new_intersection!=null && test_intersection.get_pos().z() RayTrace(RICHParticle photon, Vector3D vlab, double na RICHRay newray = new RICHRay(last_ori, new_hit); newray.set_type(lastray.get_type()); - newray.set_refind((float) geocost.RICH_AIR_INDEX); + newray.set_refind((float) RICHGeoConstants.RICH_AIR_INDEX); if(detected)newray.set_detected(); raytracks.add(newray); @@ -267,33 +264,26 @@ public ArrayList RayTrace(RICHParticle photon, Vector3D vlab, double na public void find_EtaC_raytrace_migrad(RICHParticle hadron, RICHParticle photon) { - double n_a = geocost.RICH_AIR_INDEX; - double Phi_ini = photon.trial_pho.lab_phi; double Theta_ini = photon.trial_pho.lab_theta; if(Phi_ini!=0 && Theta_ini!=0) { double Theta_P = hadron.lab_theta; double Phi_P = hadron.lab_phi; - double start_EtaC=Math.sin(Theta_P)* Math.sin(Theta_ini)*Math.cos(Phi_ini-Phi_P)+Math.cos(Theta_P)*Math.cos(Theta_ini); // Minimizing function - FCNBase myFunction = new FCNBase() { - public double valueOf(double[] par) { - - double theta = par[0]; - double phi = par[1]; - Vector3D vpho = new Vector3D( Math.sin(theta)*Math.cos(phi), Math.sin(theta)*Math.sin(phi), Math.cos(theta)); - ArrayList rays = RayTrace(photon, vpho); - double Function = 999; + FCNBase myFunction = (double[] par) -> { + double theta = par[0]; + double phi = par[1]; + Vector3D vpho = new Vector3D( Math.sin(theta)*Math.cos(phi), Math.sin(theta)*Math.sin(phi), Math.cos(theta)); + ArrayList rays = RayTrace(photon, vpho); + double Function = 999; + if(rays!=null){ Point3D pmt_hit = new Point3D(0.0, 0.0, 0.0); - if(rays!=null){ - pmt_hit = rays.get(rays.size()-1).end(); - Function = pmt_hit.distance(photon.get_HitPos()); - } - - return Function; + pmt_hit = rays.get(rays.size()-1).end(); + Function = pmt_hit.distance(photon.get_HitPos()); } + return Function; }; MnUserParameters myParameters = new MnUserParameters(); @@ -306,10 +296,6 @@ public double valueOf(double[] par) { int CLASpid = photon.get_CLASpid(); double n_tile = 1/(hadron.get_beta(CLASpid)*(Math.sin(Theta_P)* Math.sin(Theta_Min)*Math.cos(Phi_Min-Phi_P)+Math.cos(Theta_P)*Math.cos(Theta_Min))); - double arg = Math.pow(n_a, 2)-Math.pow(n_tile, 2)*Math.pow(Math.sin(Theta_Min), 2); - double Denominator = 1e-4; - if(arg>0) Denominator = Math.sqrt(arg); - double Cos_EtaC=Math.sin(Theta_P)* Math.sin(Theta_Min)*Math.cos(Phi_Min-Phi_P)+Math.cos(Theta_P)*Math.cos(Theta_Min); photon.traced.set_theta((float) Theta_Min); @@ -327,7 +313,6 @@ public double valueOf(double[] par) { public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, int hypo) { if(hypo<0 || hypo>=RICHConstants.N_HYPO ) return; - double n_a = geocost.RICH_AIR_INDEX; int hypo_pid = RICHConstants.HYPO_LUND[hypo]; if(photon.trial_pho==null){ @@ -344,8 +329,7 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i double dthe_min = 0; Point3D pmt_min = photon.trial_pho.get_HitPos(); int nrefle_min = photon.trial_pho.traced.get_nrefle(); - ArrayList rays_min = new ArrayList(); - rays_min = photon.trial_pho.traced.get_raytracks(); + ArrayList rays_min = photon.trial_pho.traced.get_raytracks(); Vector3D vec_dist = photon.get_HitPos().vectorFrom(pmt_min); // ATT: this takes the projection on the z plane. Equivalent but unnecessary. @@ -439,7 +423,6 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHParticle photon, i } if(dist < photon.nominal_sChAngle()*RICHConstants.GAP_NOMINAL_SIZE){ - int CLASpid = photon.get_CLASpid(); double n_tile = 1/(hadron.get_beta(hypo_pid)*(Math.sin(Theta_P)* Math.sin(the_min)*Math.cos(phi_min-Phi_P)+Math.cos(Theta_P)*Math.cos(the_min))); photon.traced.set_theta((float) the_min); photon.traced.set_phi((float) phi_min); @@ -509,12 +492,12 @@ public double find_dphi_steps(RICHParticle photon) { public void find_EtaC_analytic_migrad (RICHParticle hadron, RICHParticle photon) { - double n_a = geocost.RICH_AIR_INDEX; + double n_a = RICHGeoConstants.RICH_AIR_INDEX; // The following definition should be read by the geometry // ATT: mismatch con la definizione di emission a 3/4 dell'aerogel // ATT: L deve essere calcolato con il coseno - double T_r = geocost.AERO_REF_THICKNESS*geocost.CM; + double T_r = RICHGeoConstants.AERO_REF_THICKNESS*RICHGeoConstants.CM; double L = T_r/2.; // middle point is Thickness double T_g = hadron.ref_impact.z()-hadron.ref_emission.z()-L; @@ -530,20 +513,17 @@ public void find_EtaC_analytic_migrad (RICHParticle hadron, RICHParticle photon) // Minimizing function int CLASpid = photon.get_CLASpid(); - FCNBase myFunction = new FCNBase() { - public double valueOf(double[] par) { - double Theta = par[0]; - double nn_tile = 1/(hadron.get_beta(CLASpid)*(Math.sin(Theta_P)* Math.sin(Theta)*Math.cos(Phi-Phi_P)+Math.cos(Theta_P)*Math.cos(Theta))); - double n_tile = nn_tile; - //double n_tile = 1.05; - double arg = Math.pow(n_a, 2)-Math.pow(n_tile, 2)*Math.pow(Math.sin(Theta), 2); - double Denominator = 1e-4; - if(arg>0) Denominator = Math.sqrt(arg); - - double Fun = (T_r -L) * Math.tan(Theta)+T_g* (n_tile * Math.sin(Theta))/Denominator; - double Function = Math.pow(radius - Fun, 2); - return Function; - } + FCNBase myFunction = (double[] par) -> { + double Theta = par[0]; + double nn_tile = 1/(hadron.get_beta(CLASpid)*(Math.sin(Theta_P)* Math.sin(Theta)*Math.cos(Phi-Phi_P)+Math.cos(Theta_P)*Math.cos(Theta))); + double n_tile = nn_tile; + //double n_tile = 1.05; + double arg = Math.pow(n_a, 2)-Math.pow(n_tile, 2)*Math.pow(Math.sin(Theta), 2); + double Denominator = 1e-4; + if(arg>0) Denominator = Math.sqrt(arg); + + double Fun = (T_r -L) * Math.tan(Theta)+T_g* (n_tile * Math.sin(Theta))/Denominator; + return Math.pow(radius - Fun, 2); }; MnUserParameters myParameters = new MnUserParameters(); @@ -627,7 +607,7 @@ public int get_RefleCompos(ArrayList raytracks) { for(int i=2; i Date: Wed, 15 Jul 2026 18:57:34 -0400 Subject: [PATCH 07/10] cleanup --- .../jlab/clas/detector/RingCherenkovResponse.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/RingCherenkovResponse.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/RingCherenkovResponse.java index 0c856fc375..080f09eae1 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/RingCherenkovResponse.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/RingCherenkovResponse.java @@ -1,7 +1,6 @@ package org.jlab.clas.detector; import java.util.ArrayList; -import java.util.List; import org.jlab.detector.base.DetectorType; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; @@ -16,10 +15,6 @@ public class RingCherenkovResponse extends DetectorResponse { private int cluster = 0; private int xtalk = 0; - //public RingCherenkovResponse(){ - // super(); - //} - public RingCherenkovResponse(int sector, int layer, int component){ this.getDescriptor().setSectorLayerComponent(sector, layer, component); } @@ -34,13 +29,11 @@ public RingCherenkovResponse(RingCherenkovResponse r){ public void set_cluster(int cluster){ this.cluster = cluster;} public void set_xtalk(int xtalk){ this.xtalk = xtalk;} - // ---------------- public static ArrayList readHipoEvent(DataEvent event, String bankName, DetectorType type, int signal_type){ - // ---------------- int debugMode = 0; - ArrayList responseList = new ArrayList(); + ArrayList responseList = new ArrayList<>(); if(debugMode==1){ if(signal_type==0)System.out.format(" reading bank %s for single hits \n", bankName); @@ -72,8 +65,7 @@ public static ArrayList readHipoEvent(DataEvent event, z = bank.getFloat("z", row); if(debugMode>=1)System.out.format(" ---> read cluster %4d %4d %8.2f %8.2f ",row,id,energy,time); } - - if(bankName.equals("RICH::Hit")){ + else if(bankName.equals("RICH::Hit")){ id = bank.getShort("id", row); int cluster = bank.getShort("cluster", row); int xtalk = bank.getShort("xtalk", row); @@ -88,7 +80,7 @@ public static ArrayList readHipoEvent(DataEvent event, if(debugMode>=1)System.out.format(" ---> read hit %4d %4d (%3d %3d %5d --> %3d) %8.2f %8.2f ", row,id,status,cluster,xtalk,good,energy,time); } - if(bankName.equals("RICH::Signal")){ + else if(bankName.equals("RICH::Signal")){ id = bank.getShort("id", row); int hindex = bank.getShort("hindex", row); int size = bank.getShort("size", row); From 1eb5cd5126f39f379f1a629ff1571ba42322d5d3 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Wed, 15 Jul 2026 18:58:33 -0400 Subject: [PATCH 08/10] cleanup --- .../eb/src/main/java/org/jlab/service/eb/EBEngine.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java index bfd112fb02..36fe26b8f7 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java @@ -97,9 +97,7 @@ public boolean init() { } @Override - public void detectorChanged(int run) { - if (rich != null) rich.detectorChanged(run); - } + public void detectorChanged(int run) {} public void initBankNames() {} @@ -291,10 +289,7 @@ public boolean processDataEventUser(DataEvent de,EBScalers ebs) { } - if (rich != null) { - rich.dropBanks(de); - rich.processDataEventUser(de); - } + if (rich != null) rich.processDataEvent(de); return true; } From 417d9aebe2190c402362d14a210f23285098907e Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Wed, 15 Jul 2026 18:59:13 -0400 Subject: [PATCH 09/10] rich-eb prep --- .../org/jlab/clas/detector/DetectorData.java | 34 +++++++++++++++++++ .../jlab/clas/detector/DetectorParticle.java | 3 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java index d0228a11c2..367d9efc45 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java @@ -164,6 +164,40 @@ public static DetectorEvent readDetectorEvent(DataEvent event, String particle_b return detectorEvent; } + public static void readRichParticles(List particles, DataEvent event, String richbank) { + if (event.hasBank(richbank)) { + DataBank rich = event.getBank(richbank); + int nrows = rich.rows(); + for (int row = 0; row particles, DataEvent event) { + final int np = particles.size(); + int nrows = 0; + for (int i=0; i 0) nrows++; + DataBank bank = event.createBank("REC::Hypotheses", nrows); + for (int i=0; i 0) { + int row = j + i*4; + bank.setByte("pindex", row, (byte)i); + bank.setInt("pid", row, 11); + bank.setFloat("logl", row, (float)particles.get(i).particleScores[j]); + } + } + } + return bank; + } + /** * creates a bank with particles information. * diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java index 34c1d5d599..3c5da45a75 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java @@ -34,7 +34,8 @@ public class DetectorParticle implements Comparable { private int particleScore = 0; // scores are assigned detector hits private double particleScoreChi2 = 0.0; // chi2 for particle score private double startTime = -1.0; // per-particle start-time - + public double[] particleScores = new double[4]; + public double getStartTime() { return this.startTime; } public void setStartTime(double time) {this.startTime=time; } From 162ea9428d82e3a5817d378d73da2db223918ac2 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Wed, 15 Jul 2026 19:49:06 -0400 Subject: [PATCH 10/10] add missing bank --- etc/bankdefs/hipo4/event.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/etc/bankdefs/hipo4/event.json b/etc/bankdefs/hipo4/event.json index e0e9d57fbf..78a9886583 100644 --- a/etc/bankdefs/hipo4/event.json +++ b/etc/bankdefs/hipo4/event.json @@ -644,5 +644,16 @@ {"name":"py", "type":"F", "info":"y component of the momentum (GeV)"}, {"name":"pz", "type":"F", "info":"z component of the momentum (GeV)"} ] + }, + { + "name": "REC::Hypotheses", + "group": 300, + "item": 50, + "info": "Particle identification bank", + "entries": [ + {"name":"pindex","type":"S", "info":"row index in REC::Particle"}, + {"name":"pid", "type":"I", "info":"particle id hypothesis in LUND conventions"}, + {"name":"logl", "type":"F", "info":"log(Likelihood) for this hypothesis"} + ] } ]