Author: luca Date: Wed Jan 7 03:58:50 2015 New Revision: 1893 Log: (empty) Added: java/trunk/users/src/main/java/org/hps/users/luca/CalibClusterAnalizerSim.java java/trunk/users/src/main/java/org/hps/users/luca/CalibClusterAnalyzerEngRun.java Removed: java/trunk/users/src/main/java/org/hps/users/luca/EcalClustererCosmics.java Modified: java/trunk/users/src/main/java/org/hps/users/luca/CalibClusterAnalizer.java java/trunk/users/src/main/java/org/hps/users/luca/mycluster3.java Modified: java/trunk/users/src/main/java/org/hps/users/luca/CalibClusterAnalizer.java ============================================================================= --- java/trunk/users/src/main/java/org/hps/users/luca/CalibClusterAnalizer.java (original) +++ java/trunk/users/src/main/java/org/hps/users/luca/CalibClusterAnalizer.java Wed Jan 7 03:58:50 2015 @@ -32,6 +32,7 @@ if(event.hasCollection(Cluster.class,"EcalClusters")) {List<Cluster> clusters= event.get(Cluster.class,"EcalClusters"); for(Cluster cluster : clusters){ + eneTuttiPlot.fill(cluster.getEnergy()); SeedHitPlot.fill(cluster.getCalorimeterHits().get(0).getCorrectedEnergy()); } Added: java/trunk/users/src/main/java/org/hps/users/luca/CalibClusterAnalizerSim.java ============================================================================= --- java/trunk/users/src/main/java/org/hps/users/luca/CalibClusterAnalizerSim.java (added) +++ java/trunk/users/src/main/java/org/hps/users/luca/CalibClusterAnalizerSim.java Wed Jan 7 03:58:50 2015 @@ -0,0 +1,226 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package org.hps.users.luca; +import hep.aida.IHistogram1D; +import java.io.FileWriter; +import java.io.IOException; +import java.util.List; + +import org.lcsim.event.CalorimeterHit; + +import org.lcsim.event.Cluster; +import org.lcsim.event.EventHeader; +import org.lcsim.util.Driver; +import org.lcsim.util.aida.AIDA; +/** + * Driver <code>CalibClusterAnalizerSim<\code> reads the cluster collections + * created by the GTPEcalClusterer in the simulated readout and selecet clusters + * with energy above 1.4 GeV form which plots the Seed Hit energy distribution + * that will be somewhere else fitted for calibration. + * @author Luca + */ + + + + + +public class CalibClusterAnalizerSim extends Driver { + double energyThreshold=0; + AIDA aida = AIDA.defaultInstance(); + IHistogram1D eneTuttiPlot = aida.histogram1D("All Clusters Energy", 300, 0.0,3.0); + IHistogram1D SeedHitPlot = aida.histogram1D("SeedHit Energy", 300, 0.0,3.0); + protected String clusterCollectionName = "EcalClusters"; + private FileWriter writer; +// private FileWriter writer2; + String outputFileName = "CalibClusterAnalizerSim.txt"; + // String outputFileName2 = "LucaTriggerHits.txt"; + public void setEnergyThreshold (double threshold){ + this.energyThreshold=threshold; + } + + public void setOutputFileName(String outputFileName){ + this.outputFileName = outputFileName; + } + @Override +public void startOfData(){ + try{ + //initialize the writers + writer=new FileWriter(outputFileName); + // writer2=new FileWriter(outputFileName2); + //Clear the files + writer.write(""); + // writer2.write(""); + } + catch(IOException e ){ + System.err.println("Error initializing output file for event display."); + } +} + + + +public void endOfData(){ + + try{ +//close the file writer. + writer.close(); + //writer2.close(); + } +catch(IOException e){ + System.err.println("Error closing utput file for event display."); +} +} + @Override + public void process (EventHeader event){ + + if(event.hasCollection(Cluster.class,"EcalClusters")) + {List<Cluster> clusters= event.get(Cluster.class,"EcalClusters"); + for(Cluster cluster : clusters){ + int id; + + id=getCrystal(cluster); + try{ + writer.append(id + " " + cluster.getEnergy()+ " " + cluster.getSize() + " " + cluster.getCalorimeterHits().get(0).getRawEnergy() + " " + cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix")+" " +cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy")+ "\n"); + } + catch(IOException e ){System.err.println("Error writing to output for event display");} + + } + + + } + + } + + + public int getCrystal (Cluster cluster){ + int x,y,id=0; + x= cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix"); + y= cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy"); + + if(y==5){ + if(x<0) + {id=x+24;} + else id= x+23; + } + + else if(y==4) + {if(x<0){ + id=x+70;} + else id=x+69;} + + else if(y==3) + {if(x<0){ + id=x+116;} + else id=x+115;} + + else if(y==2) + {if(x<0){ + id=x+162;} + else id=x+161;} + + else if(y==1) + {x=-x; + if(x>0){ + id=-x+208;} + else if(x==-1){id=208;} + else if(x<-1) id=-x+198;} + + else if(y==-1) + {x=-x; + if(x>0){ + id=-x+245;} + else if(x==-1 )id=245; + else if(x<-1){id=-x+235;}} + + + else if(y==-2) + {if(x<0){ + id=x+282;} + else id=x+281;} + + else if(y==-3) + {if(x<0){ + id=x+328;} + else id=x+327;} + + else if(y==-4) + {if(x<0){ + id=x+374;} + else id=x+373;} + + else if(y==-5) + {if(x<0){ + id=x+420;} + else id=x+419;} + + return id; + + } + public int getCrystal (CalorimeterHit hit){ + int x,y,id=0; + x= hit.getIdentifierFieldValue("ix"); + y= hit.getIdentifierFieldValue("iy"); + + if(y==5){ + if(x<0) + {id=x+24;} + else id= x+23; + } + + else if(y==4) + {if(x<0){ + id=x+70;} + else id=x+69;} + + else if(y==3) + {if(x<0){ + id=x+116;} + else id=x+115;} + + else if(y==2) + {if(x<0){ + id=x+162;} + else id=x+161;} + + else if(y==1) + {x=-x; + if(x>0){ + id=-x+208;} + else if(x==-1){id=208;} + else if(x<-1) id=-x+198;} + + else if(y==-1) + {x=-x; + if(x>0){ + id=-x+245;} + else if(x==-1 )id=245; + else if(x<-1){id=-x+235;}} + + + else if(y==-2) + {if(x<0){ + id=x+282;} + else id=x+281;} + + else if(y==-3) + {if(x<0){ + id=x+328;} + else id=x+327;} + + else if(y==-4) + {if(x<0){ + id=x+374;} + else id=x+373;} + + else if(y==-5) + {if(x<0){ + id=x+420;} + else id=x+419;} + + return id; + + } +} Added: java/trunk/users/src/main/java/org/hps/users/luca/CalibClusterAnalyzerEngRun.java ============================================================================= --- java/trunk/users/src/main/java/org/hps/users/luca/CalibClusterAnalyzerEngRun.java (added) +++ java/trunk/users/src/main/java/org/hps/users/luca/CalibClusterAnalyzerEngRun.java Wed Jan 7 03:58:50 2015 @@ -0,0 +1,215 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package org.hps.users.luca; + + +import org.lcsim.util.Driver; +import hep.aida.IHistogram1D; +import java.io.FileWriter; +import java.io.IOException; +import java.util.List; +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.Cluster; +import org.lcsim.event.EventHeader; +import org.lcsim.util.aida.AIDA; + +/** + * + * @author Luca + */ +public class CalibClusterAnalyzerEngRun extends Driver { + double energyThreshold=0; + protected String clusterCollectionName = "EcalClusters"; + private FileWriter writer; +// private FileWriter writer2; + String outputFileName = "CalibClusterAnalizerEngRun.txt"; + // String outputFileName2 = "LucaTriggerHits.txt"; + public void setEnergyThreshold (double threshold){ + this.energyThreshold=threshold; + } + + public void setOutputFileName(String outputFileName){ + this.outputFileName = outputFileName; + } + @Override +public void startOfData(){ + try{ + //initialize the writers + writer=new FileWriter(outputFileName); + // writer2=new FileWriter(outputFileName2); + //Clear the files + writer.write(""); + // writer2.write(""); + } + catch(IOException e ){ + System.err.println("Error initializing output file for event display."); + } +} + + + +public void endOfData(){ + + try{ +//close the file writer. + writer.close(); + //writer2.close(); + } +catch(IOException e){ + System.err.println("Error closing utput file for event display."); +} +} + @Override + public void process (EventHeader event){ + + if(event.hasCollection(Cluster.class,"EcalClusters")) + {List<Cluster> clusters= event.get(Cluster.class,"EcalClusters"); + for(Cluster cluster : clusters){ + int id; + id=getCrystal(cluster); + try{ + writer.append(id + " " + cluster.getEnergy()+ " " + cluster.getSize() + " " + cluster.getCalorimeterHits().get(0).getRawEnergy() + " " + cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix")+" " +cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy")+ cluster.getCalorimeterHits().get(0).getCellID() + "\n"); + } + catch(IOException e ){System.err.println("Error writing to output for event display");} + + } + + + } + + } + + + public int getCrystal (Cluster cluster){ + int x,y,id=0; + x= cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix"); + y= cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy"); + + if(y==5){ + if(x<0) + {id=x+24;} + else id= x+23; + } + + else if(y==4) + {if(x<0){ + id=x+70;} + else id=x+69;} + + else if(y==3) + {if(x<0){ + id=x+116;} + else id=x+115;} + + else if(y==2) + {if(x<0){ + id=x+162;} + else id=x+161;} + + else if(y==1) + {x=-x; + if(x>0){ + id=-x+208;} + else if(x==-1){id=208;} + else if(x<-1) id=-x+198;} + + else if(y==-1) + {x=-x; + if(x>0){ + id=-x+245;} + else if(x==-1 )id=245; + else if(x<-1){id=-x+235;}} + + + else if(y==-2) + {if(x<0){ + id=x+282;} + else id=x+281;} + + else if(y==-3) + {if(x<0){ + id=x+328;} + else id=x+327;} + + else if(y==-4) + {if(x<0){ + id=x+374;} + else id=x+373;} + + else if(y==-5) + {if(x<0){ + id=x+420;} + else id=x+419;} + + return id; + + } + public int getCrystal (CalorimeterHit hit){ + int x,y,id=0; + x= hit.getIdentifierFieldValue("ix"); + y= hit.getIdentifierFieldValue("iy"); + + if(y==5){ + if(x<0) + {id=x+24;} + else id= x+23; + } + + else if(y==4) + {if(x<0){ + id=x+70;} + else id=x+69;} + + else if(y==3) + {if(x<0){ + id=x+116;} + else id=x+115;} + + else if(y==2) + {if(x<0){ + id=x+162;} + else id=x+161;} + + else if(y==1) + {x=-x; + if(x>0){ + id=-x+208;} + else if(x==-1){id=208;} + else if(x<-1) id=-x+198;} + + else if(y==-1) + {x=-x; + if(x>0){ + id=-x+245;} + else if(x==-1 )id=245; + else if(x<-1){id=-x+235;}} + + + else if(y==-2) + {if(x<0){ + id=x+282;} + else id=x+281;} + + else if(y==-3) + {if(x<0){ + id=x+328;} + else id=x+327;} + + else if(y==-4) + {if(x<0){ + id=x+374;} + else id=x+373;} + + else if(y==-5) + {if(x<0){ + id=x+420;} + else id=x+419;} + + return id; + + } +} Modified: java/trunk/users/src/main/java/org/hps/users/luca/mycluster3.java ============================================================================= --- java/trunk/users/src/main/java/org/hps/users/luca/mycluster3.java (original) +++ java/trunk/users/src/main/java/org/hps/users/luca/mycluster3.java Wed Jan 7 03:58:50 2015 @@ -5,6 +5,7 @@ */ package org.hps.users.luca; + import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList;