From 3cc40e059e928482865230a21a6862ad556a92eb Mon Sep 17 00:00:00 2001 From: Pierre Chatagnon Date: Wed, 10 Jan 2018 16:19:56 +0100 Subject: [PATCH] modif --- .../jlab/rec/cnd/banks/RecoBankWriter.java | 12 +- .../service/cnd/CNDCalibrationEngine.java | 144 ++++++++++++------ .../java/org/jlab/service/cnd/CNDEngine.java | 20 ++- 3 files changed, 123 insertions(+), 53 deletions(-) diff --git a/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/banks/RecoBankWriter.java b/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/banks/RecoBankWriter.java index 76a9b8c8e8..99750f084c 100755 --- a/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/banks/RecoBankWriter.java +++ b/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/banks/RecoBankWriter.java @@ -49,5 +49,15 @@ public static DataBank fillCndHitBanks(DataEvent event, ArrayList hitlis } + public void appendCNDBanks(DataEvent event,ArrayList hitlist) { + if(hitlist.size()!=0){ + DataBank bank = this.fillCndHitBanks((DataEvent) event, hitlist); + //bank.show(); + event.appendBanks(bank); + //event.show(); + } + } + +} + -} \ No newline at end of file diff --git a/reconstruction/cnd/src/main/java/org/jlab/service/cnd/CNDCalibrationEngine.java b/reconstruction/cnd/src/main/java/org/jlab/service/cnd/CNDCalibrationEngine.java index e132e42321..1199dc5cda 100644 --- a/reconstruction/cnd/src/main/java/org/jlab/service/cnd/CNDCalibrationEngine.java +++ b/reconstruction/cnd/src/main/java/org/jlab/service/cnd/CNDCalibrationEngine.java @@ -26,10 +26,11 @@ public class CNDCalibrationEngine extends ReconstructionEngine { public CNDCalibrationEngine() { super("CND", "chatagnon", "1.0"); + } int Run = -1; - + RecoBankWriter rbc; //test static int enb =0; static int ecnd=0; @@ -41,38 +42,42 @@ public CNDCalibrationEngine() { @Override public boolean processDataEvent(DataEvent event) { + //event.show(); + //System.out.println("in data process "); ArrayList halfhits = new ArrayList(); ArrayList hits = new ArrayList(); - + //test - if(event.hasBank("CVTRec::Tracks")){ - hcvt++; - } +// if(event.hasBank("CVTRec::Tracks")){ +// hcvt++; +// } halfhits = HitReader.getCndHalfHits(event); //1) exit if halfhit list is empty - if(halfhits.size()==0 ) + if(halfhits.size()==0 ){ + // System.out.println("fin de process (0) : "); + // event.show(); return true; - + } // update calibration constants based on run number if changed setRunConditionsParameters(event); - + //2) find the CND hits from these half-hits CndHitFinder hitFinder = new CndHitFinder(); hits = hitFinder.findHits(halfhits,0); CvtGetHTrack cvttry = new CvtGetHTrack(); cvttry.getCvtHTrack(event); // get the list of helix associated with the event - - int flag=0; + + //int flag=0; for (CndHit hit : hits){ // findlength for charged particles double length =hitFinder.findLength(hit, cvttry.getHelices(),0); if (length!=0){ hit.set_tLength(length); // the path length is non zero only when there is a match with cvt track - if(flag==0){match++;} - flag=1; + //if(flag==0){match++;} + //flag=1; } - + } // GetVertex getVertex = new GetVertex(); @@ -82,28 +87,54 @@ public boolean processDataEvent(DataEvent event) { // } // + // if(hits.size()!=0){ + // + // DataBank outbank = RecoBankWriter.fillCndHitBanks(event, hits); + //// System.out.println("event before process : "); + //// event.show(); + // event.appendBanks(outbank); + // //System.out.println("event after process : "); + // //event.show(); + // ecnd++; + // if(event.hasBank("CVTRec::Tracks")){ + // posmatch++; + // //event.getBank("MC::Particle").show(); + // //outbank.show(); + // } + // + // } + //// System.out.println("fin de process : "); + //// event.show(); + // return true; + // } if(hits.size()!=0){ - DataBank outbank = RecoBankWriter.fillCndHitBanks(event, hits); - event.appendBank(outbank); - ecnd++; - if(event.hasBank("CVTRec::Tracks")){ - posmatch++; - //event.getBank("MC::Particle").show(); - //outbank.show(); - } - - } - return true; + // DataBank outbank = RecoBankWriter.fillCndHitBanks(event, hits); + // event.appendBanks(outbank); + // event.show(); + // System.out.println("in process event "); + rbc.appendCNDBanks(event,hits); + // ecnd++; + // if(event.hasBank("CVTRec::Tracks")){ + // posmatch++; + //event.getBank("MC::Particle").show(); + //outbank.show(); + // } + // event.show(); + + } return true; + } @Override public boolean init() { // TODO Auto-generated method stub - + rbc = new RecoBankWriter(); + System.out.println("in init "); return true; } + public void setRunConditionsParameters(DataEvent event) { if(event.hasBank("RUN::config")==false) { System.err.println("RUN CONDITIONS NOT READ!"); @@ -125,7 +156,7 @@ public void setRunConditionsParameters(DataEvent event) { public static void main (String arg[]) throws IOException { CNDCalibrationEngine en = new CNDCalibrationEngine(); - + en.init(); //String input = "/Users/ziegler/Workdir/Files/GEMC/ForwardTracks/pi-.r100.evio"; //String input = "/projet/nucleon/silvia/test.hipo"; @@ -136,39 +167,51 @@ public static void main (String arg[]) throws IOException { //String input = "/projet/nucleon/silvia/test.rec.hipo"; //String input = "/projet/nucleon/pierre/test_out3.hipo"; //String input = "/projet/nucleon/silvia/test.hipo"; - String input = "/projet/nucleon/pierre/CND_run2052_2053/ctof_cnd_2052_2053.hipo"; + String input = "/projet/nucleon/pierre/RecCND/clas_002227.evio.18.hipo"; + //String input = "/projet/nucleon/pierre/RecCND/test.hipo"; //String input = "/projet/nucleon/silvia/CLARA/out_clasdispr_small.00849.hipo"; HipoDataSource reader = new HipoDataSource(); reader.open(input); - String outputFile="/projet/nucleon/pierre/CND_run2052_2053/test.hipo"; + String outputFile="/projet/nucleon/pierre/RecCND/test1.hipo"; HipoDataSync writer = new HipoDataSync(); writer.open(outputFile); - + while(reader.hasEvent()) { enb++; DataEvent event = (DataEvent) reader.getNextEvent(); - - System.out.println("event nb "+enb); - event.show(); - + //event.show(); + //System.out.println("event nb "+enb); + + // System.out.println("event avant process "); + // event.show(); + //event.getBank("MC::Particle").show(); //if(event.hasBank("CVTRec::Tracks")){event.getBank("CVTRec::Tracks").show();}; en.processDataEvent(event); - if(event.hasBank("CND::hits")){ - event.show(); - event.getBank("CND::hits").show(); - event.getBank("CND::adc").show(); - event.getBank("CND::tdc").show(); - } + + // System.out.println("event après process "); + // event.show(); + + //System.out.println("avant write "); writer.writeEvent(event); - - - if(enb==20) break; - + //System.out.println("après write "); + +// if(event.hasBank("CND::hits")){ +// //event.show(); +// System.out.println("event nb "+enb); +// event.getBank("CND::hits").show(); +// event.getBank("CND::adc").show(); +// event.getBank("CND::tdc").show(); +// } + + + + if(enb==30) break; + } writer.close(); - + //some statitics on cvt/cnd matching System.out.println("enb "+enb); System.out.println("ecnd "+ecnd); @@ -177,7 +220,20 @@ public static void main (String arg[]) throws IOException { System.out.println("match "+match); System.out.println("%match cnd "+100.*match/posmatch); System.out.println("Done"); + + + HipoDataSource sortie = new HipoDataSource(); + sortie.open(outputFile); + + System.out.println("Fichier de sortie : "); + while(sortie.hasEvent()) { + + DataEvent event = (DataEvent) sortie.getNextEvent(); + //event.show(); + + } } } + diff --git a/reconstruction/cnd/src/main/java/org/jlab/service/cnd/CNDEngine.java b/reconstruction/cnd/src/main/java/org/jlab/service/cnd/CNDEngine.java index 7d46042614..9ed9773668 100755 --- a/reconstruction/cnd/src/main/java/org/jlab/service/cnd/CNDEngine.java +++ b/reconstruction/cnd/src/main/java/org/jlab/service/cnd/CNDEngine.java @@ -30,7 +30,7 @@ public CNDEngine() { } int Run = -1; - + RecoBankWriter rbc; //test static int enb =0; static int ecnd=0; @@ -83,13 +83,17 @@ public boolean processDataEvent(DataEvent event) { if(hits.size()!=0){ - DataBank outbank = RecoBankWriter.fillCndHitBanks(event, hits); - event.appendBank(outbank); - ecnd++; - if(event.hasBank("CVTRec::Tracks")){ - posmatch++; - } + // DataBank outbank = RecoBankWriter.fillCndHitBanks(event, hits); + // event.appendBanks(outbank); + // event.show(); + System.out.println("in process event "); + rbc.appendCNDBanks(event,hits); + // ecnd++; + // if(event.hasBank("CVTRec::Tracks")){ + // posmatch++; + //event.getBank("MC::Particle").show(); //outbank.show(); + // } } return true; } @@ -169,4 +173,4 @@ public static void main (String arg[]) throws IOException { System.out.println("Done"); } -} \ No newline at end of file +}