Commit in hps-java/src/main/java/org/lcsim/hps/users/phansson on MAIN
mergeSimpleAIDA.java+26-101.1 -> 1.2
ecalPlots.java+50-1141.4 -> 1.5
ECalHitMapPlots.java+34-161.3 -> 1.4
SimpleHPSConditions.java+31.2 -> 1.3
+113-140
4 modified files
Small analysis updates.

hps-java/src/main/java/org/lcsim/hps/users/phansson
mergeSimpleAIDA.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- mergeSimpleAIDA.java	23 Jul 2012 21:14:52 -0000	1.1
+++ mergeSimpleAIDA.java	24 Jul 2012 23:28:10 -0000	1.2
@@ -32,6 +32,7 @@
          option.addOption("r", true, "Regular expression to match files");
          option.addOption("d", true, "File directory");
          option.addOption("o", true, "Merged file name");
+         option.addOption("t", false, "Print files to be merged only");
          return option;
     }
     
@@ -66,6 +67,10 @@
         if(cmd.hasOption("o")) {
             outfile = cmd.getOptionValue("o");
         }
+        boolean testOnly = false;
+        if(cmd.hasOption("t")) {
+            testOnly = true;
+        }
         
         File[] files = listFilesMatching(path,regexp);
         
@@ -74,11 +79,16 @@
             System.exit(1);
         }
         
-        System.out.println("Found " + files.toString() + " matching files");
-        
-        
-        mergeFiles(files,path+"/"+outfile);
+        System.out.println("Found " + files.length + " matching files");
         
+        if(testOnly) {
+            
+            for(File f : files) {
+                System.out.println(f.getName());
+            }
+        } else {
+            mergeFiles(files,path+"/"+outfile);
+        }
         
         
         
@@ -109,26 +119,32 @@
                 Logger.getLogger(mergeSimpleAIDA.class.getName()).log(Level.SEVERE, null, ex);
             }
             for( String str : tree.listObjectNames()) {
-                if(!str.contains("Cluster energy x")) continue;
-                IHistogram1D h = (IHistogram1D)tree.find(str);
+                //if(!str.contains("Cluster energy x")) continue;
+                IManagedObject obj = tree.find(str);
+                if(!IHistogram1D.class.isInstance(obj)) continue;
+                IHistogram1D h = (IHistogram1D)obj;
                 if(h==null) {
                     System.out.println("Error " + str + " had problems to be cast to 1D?");
                     continue;
                 }
-                String name = h.title() + " merged";
-                IHistogram1D hc = null;
+                String name = h.title();// + " merged";
+                IHistogram1D hc = null;// = aida.histogram1D(name);
                 try {
                     hc = (IHistogram1D) aida.tree().find(name);
                 } catch (IllegalArgumentException ex) {
                     System.out.println(" creating " + name);
                 }
-                //IHistogram1D hc = aida.histogram1D(name);
                 if(hc==null) {        
+                   
                     hc = hf.createCopy(name, h);
                 } else {
                     hc = hf.add(hc.title(), hc, h);
                 }
+                if(name.contains("x=1 y=1")) {
+                    System.out.println("Now " + hc.entries() + " entries (<m>="+hc.mean()+" RMS="+h.rms()+")");
+                }
             }
+                
             ++count;
             
             
@@ -160,7 +176,7 @@
             @Override
             public boolean accept(File file,String name) {
                 boolean match = p.matcher(name).matches();
-                System.out.println("accepting file " + name + ": " + match);
+                //System.out.println("accepting file " + name + ": " + match);
                 return match;
             }
 

hps-java/src/main/java/org/lcsim/hps/users/phansson
ecalPlots.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- ecalPlots.java	19 Jul 2012 19:35:03 -0000	1.4
+++ ecalPlots.java	24 Jul 2012 23:28:10 -0000	1.5
@@ -85,7 +85,21 @@
             savePlots = true;
         }
         
-            
+ 
+               
+        if(type==999) {
+        
+            ITree tree=null;
+            try {
+                tree = af.createTreeFactory().create("test.aida");
+            } catch (IllegalArgumentException ex) {
+                Logger.getLogger(ecalPlots.class.getName()).log(Level.SEVERE, null, ex);
+            } catch (IOException ex) {
+                Logger.getLogger(ecalPlots.class.getName()).log(Level.SEVERE, null, ex);
+            }
+            printObjectsInTree(tree);
+            return;
+        }
         
         if(type==0) {
             
@@ -217,119 +231,7 @@
         
         
           
-         if(type==3) {
-            
-            try {
-                String path = "";//plots/20120710_ecal_dataMC/../../";
-                
-                String file_mc = "trigratefile_egs5_500mb_90na_01.aida";//trigratefile_egs5_160rl.aida";
-                String file_data = "trigratefile_run1351.aida";
-                String file_bkg = "trigratefile_run1358.aida";
-                
-                ITree tree_data = af.createTreeFactory().create(path+ file_data);
-                ITree tree_mc = af.createTreeFactory().create(path+ file_mc);
-                ITree tree_bkg = af.createTreeFactory().create(path+ file_bkg);
-                
-                
-                
-                String name = "dataMC_clusterE_tophalf_norm";
-
-                
-                
-                SimpleHPSConditions cond = new SimpleHPSConditions();
-                
-                int idx = file_data.indexOf("run");
-                int run_data = Integer.parseInt(file_data.substring(idx+3,idx+7));
-                idx = file_bkg.indexOf("run");
-                int run_bkg = Integer.parseInt(file_bkg.substring(idx+3,idx+7));
-
-                //normalize to integrated current of data
-                double int_current_mc = 90.0; //nC i.e. 1s of beam at 90nA
-                double k_Q = cond.getIntCurrent(run_data)/int_current_mc;
-                System.out.printf("Run %d: intCurrent %.1fnC intCurrent(MC) %.1fnC \n",run_data,cond.getIntCurrent(run_data),int_current_mc);
-                System.out.printf("=> k_current %.1f\n",k_Q );
-                
-                double k_rec_data = cond.getRecRate(run_data)/cond.getRate(run_data);
-                System.out.printf("Run %d: rate %.1fHz rec rate %.1fHz\n",run_data,cond.getRate(run_data),cond.getRecRate(run_data));
-                System.out.printf("=> k_rec_data %.2f\n",k_rec_data );
-                
-                double k_rec_bkg = cond.getRecRate(run_bkg)/cond.getRate(run_bkg);
-                System.out.printf("Run %d: rate %.1fHz rec rate %.1fHz\n",run_data,cond.getRate(run_bkg),cond.getRecRate(run_bkg));
-                System.out.printf("=> k_rate_bkg %.2f\n",k_rec_bkg );
-                
-                double k_norm_bkg = cond.getIntCurrent(run_data)/cond.getIntCurrent(run_bkg);
-                System.out.printf("Run %d: intCurrent %.1fnC \n",run_bkg,cond.getIntCurrent(run_bkg));
-                System.out.printf("=> k_norm_bkg %.1f\n",k_norm_bkg );
-                
-                //Overlay a few histograms
-                List<String> histNames = new ArrayList<String>();
-                for(int ix=-23;ix<=23;++ix) {
-                    for(int iy=-5;iy<=5;++iy) {
-                        
-                        if(ix<=0) continue;
-                        if(iy<=0) continue;
-                        
-                        histNames.add("Cluster energy x="+ix+" y="+iy);
-                        
-                    }    
-                }
-                //System.out.println("Histogram names: "+histNames.toString());
-                
-                int iadded=0;
-                IHistogram1D h_obs=null;
-                IHistogram1D h_bkg=null;
-                IHistogram1D h_mc=null;
-                 
-                
-                boolean dataToMCNorm = false;
-                for(String hname : histNames) {
-                    IHistogram1D h_obs_tmp = (IHistogram1D)tree_data.find(hname);
-                    IHistogram1D h_bkg_tmp = (IHistogram1D)tree_bkg.find(hname);
-                    IHistogram1D h_mc_tmp = (IHistogram1D)tree_mc.find(hname);
-                    if(iadded==0) {
-                        h_obs = ecalhtplots.hf.createCopy(h_obs_tmp.title()+ " sum", h_obs_tmp);
-                        h_bkg = ecalhtplots.hf.createCopy(h_bkg_tmp.title()+ " sum", h_bkg_tmp);
-                        h_mc = ecalhtplots.hf.createCopy(h_mc_tmp.title()+ " sum", h_mc_tmp);
-                    } else {
-                    
-                        h_obs.add(h_obs_tmp);
-                        h_bkg.add(h_bkg_tmp);
-                        h_mc.add(h_mc_tmp);
-                    }
-                    ++iadded;
-                    
-                }
-                
-                System.out.println("Added " + iadded + " histograms");
-                
-                //scale data by dead time efficiency
-                h_bkg.scale(1/k_rec_bkg);
-                h_obs.scale(1/k_rec_data);
-                
-                //subtract normalized background from data
-                h_bkg.scale(k_norm_bkg);
-                IHistogram1D h_data = ecalhtplots.hf.subtract(h_obs.title() + " bkgsubtr", h_obs, h_bkg);
-
-                if(dataToMCNorm) { //normalize by setting histogram integrals equal
-                    h_mc.scale(h_data.sumBinHeights()/h_mc.sumBinHeights());
-                } else { //absolute normalization to beam current
-                    h_mc.scale(k_Q);
-                }
-                //System.out.println("mc " + h_mc.entries() + "(" + h_mc.allEntries() + ")" + " obs " + h_obs.entries()+ "(" + h_obs.allEntries() + ")" + " bkg " + h_bkg.entries()+ "(" + h_bkg.allEntries() + ")" + " obs " + h_data.entries()+ "(" + h_data.allEntries() + ")");
-                //System.out.println("mc " + h_mc.sumBinHeights() + " obs " + h_obs.sumBinHeights() + " bkg " + h_bkg.sumBinHeights() + " obs " + h_data.sumBinHeights());
-                System.out.printf("Run %d: obs %.1f bkg %.1f\t=>\tdata %.1f MC %.1f\t->\tdata/MC=%.2f\n",run_data,h_obs.sumBinHeights(),h_bkg.sumBinHeights(),h_data.sumBinHeights(),h_mc.sumBinHeights(),h_data.sumBinHeights()/h_mc.sumBinHeights());
-
-                ecalhtplots.plotBasic1D(h_data,h_mc,name+"_"+h_obs.title(), "","","data","MC",savePlots);
-
-                
-                
-                
-
-            } catch(IOException e) {
-                throw new RuntimeException(e);
-            }
-         }
-         
+        
          
         
         /*
@@ -391,4 +293,38 @@
         
         
     }
+
+    public static double getBunchesFromFileName(String filename) {
+        //trigratefile_egs5_merged_500mb_90na_0x016.aida
+        String[] parts = filename.split("_");
+        for(String part : parts) {
+            int idx = part.indexOf("mb");
+            if(idx!=-1) {
+                return Double.valueOf(part.substring(0, idx));
+            }
+            idx = part.indexOf("bb");
+            if(idx!=-1) {
+                return 1000.0*Double.valueOf(part.substring(0, idx));
+            }
+            
+        }
+        return -1.0;
+        
+    }
+
+    public static double getCurrentFromFileName(String filename) {
+        //trigratefile_egs5_merged_500mb_90na_0x016.aida
+        String[] parts = filename.split("_");
+        for(String part : parts) {
+            int idx = part.indexOf("na");
+            if(idx==-1) {
+                continue;
+            }
+            return Double.valueOf(part.substring(0, idx));
+        }
+        return -1.0;
+        
+    }
+
+    
 }

hps-java/src/main/java/org/lcsim/hps/users/phansson
ECalHitMapPlots.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- ECalHitMapPlots.java	19 Jul 2012 19:35:03 -0000	1.3
+++ ECalHitMapPlots.java	24 Jul 2012 23:28:10 -0000	1.4
@@ -104,26 +104,44 @@
      
      
     public void plotBasic1D(IHistogram1D h, IHistogram1D h2, String title, String xTitle, String yTitle, String leg1,String leg2,boolean writeToFile) {
+        //IPlotter plotter_hm1 = af.createPlotterFactory().create();
+        //IPlotter plotter_hm2 = af.createPlotterFactory().create();
         IPlotter plotter_hm = af.createPlotterFactory().create();
-        if(!"".equals(title)) plotter_hm.setTitle(title);
+        //if(!"".equals(title)) {
+        //    plotter_hm.setTitle(title);
+        //    h.setTitle(title);
+        //}
+        
         //if(fillColor=="") fillColor="yellow";
         //plotter_hm.createRegion(10.0,20.0, 460.0,100.0);
         //plotter_hm.createRegion(d, d1, d2, d3)
-        plotter_hm.createRegions(1,3);//.plot(hm);
-        //plotter_hm.region(0).style().dataStyle().fillStyle().setOpacity(0);
-        //plotter_hm.region(1).style().dataStyle().fillStyle().setOpacity(0);
-        plotter_hm.region(2).style().dataStyle().fillStyle().setVisible(false);
-        plotter_hm.region(2).style().statisticsBoxStyle().setVisible(false);
-        //plotter_hm.style().dataStyle().fillStyle().setColor(fillColor);
-        plotter_hm.region(1).style().dataStyle().lineStyle().setColor("green");
-        
-        IPlotterStyle dataStyle = plotter_hm.region(0).style();
-        dataStyle.dataStyle().lineStyle().setColor("green");
-        plotter_hm.region(0).plot(h,dataStyle);
-        dataStyle.dataStyle().lineStyle().setColor("blue");
-        plotter_hm.region(1).plot(h2,dataStyle);
-        plotter_hm.region(2).plot(h);
-        plotter_hm.region(2).plot(h2,"mode=overlay");
+        plotter_hm.createRegions(1,1);//.plot(hm);
+        //plotter_hm1.createRegions(1,1);
+        //plotter_hm2.createRegions(1,1);
+        plotter_hm.region(0).style().dataStyle().fillStyle().setVisible(false);
+        plotter_hm.region(0).style().statisticsBoxStyle().setVisible(false);
+        //plotter_hm.region(0).style().dataStyle().lineStyle().setColor("green");
+        plotter_hm.style().xAxisStyle().setLabel(xTitle);
+        plotter_hm.style().yAxisStyle().setLabel(yTitle);
+//        plotter_hm1.region(1).style().dataStyle().fillStyle().setVisible(false);
+//        plotter_hm1.region(1).style().statisticsBoxStyle().setVisible(false);
+//        plotter_hm1.region(1).style().dataStyle().lineStyle().setColor("green");
+//        plotter_hm1.style().xAxisStyle().setLabel(xTitle);
+//        plotter_hm1.style().yAxisStyle().setLabel(yTitle);
+//        plotter_hm2.region(1).style().dataStyle().fillStyle().setVisible(false);
+//        plotter_hm2.region(1).style().statisticsBoxStyle().setVisible(false);
+//        plotter_hm2.region(1).style().dataStyle().lineStyle().setColor("green");
+//        plotter_hm2.style().xAxisStyle().setLabel(xTitle);
+//        plotter_hm2.style().yAxisStyle().setLabel(yTitle);
+//        
+        //IPlotterStyle dataStyle = plotter_hm.region(0).style();
+        //dataStyle.dataStyle().lineStyle().setColor("green");
+        plotter_hm.region(0).plot(h);
+        //IPlotterStyle dataStyle2 = plotter_hm.region(0).style().;
+        //dataStyle2.dataStyle().lineStyle().setColor("blue");
+        //plotter_hm.region(1).plot(h2,dataStyle);
+        //plotter_hm.region(2).plot(h);
+        plotter_hm.region(0).plot(h2,"mode=overlay");
         
         //System.out.println("av Params: " + plotter_hm.style().dataStyle().fillStyle().availableParameters().toString());
         //for(String str : plotter_hm.style().dataStyle().fillStyle().availableParameters()) {

hps-java/src/main/java/org/lcsim/hps/users/phansson
SimpleHPSConditions.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- SimpleHPSConditions.java	19 Jul 2012 19:35:03 -0000	1.2
+++ SimpleHPSConditions.java	24 Jul 2012 23:28:10 -0000	1.3
@@ -118,6 +118,9 @@
     public double getRecRate(int run) {
         return this.getCond(run)._rate_rec;
     }
+    public double getThickness(int run) {
+        return this.getCond(run)._thickness;
+    }
     
     public String toString() {
          //String str = String.format("%10s\t%8d\t%8d\t%8.2f+-%.2f",getRun(),getStartTime(),getStopTime(),getIntCurrent(),getIntCurrentError());
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1