Print

Print


Commit in java/trunk/users/src/main/java/org/hps/users/luca on MAIN
CalibTest2.java+21-16585 -> 586
ElectronAnalysis.java-80585 removed
LCIOReadScript.java+100added 586
LCIOReaderScript.java-117585 removed
LCIOReaderScript2.java-76585 removed
mycluster.java+143added 586
+264-289
2 added + 3 removed + 1 modified, total 6 files


java/trunk/users/src/main/java/org/hps/users/luca
CalibTest2.java 585 -> 586
--- java/trunk/users/src/main/java/org/hps/users/luca/CalibTest2.java	2014-05-15 15:51:59 UTC (rev 585)
+++ java/trunk/users/src/main/java/org/hps/users/luca/CalibTest2.java	2014-05-15 16:11:46 UTC (rev 586)
@@ -48,13 +48,15 @@
 private FileWriter writer;
 String outputFileName = "elettrons.txt";
 private AIDA aida = AIDA.defaultInstance();
-    IHistogram1D thetaPlot = aida.histogram1D("theta", 1000, 0.0, 0.3);
-    IHistogram2D pulses = aida.histogram2D("pulses",1000,-3.0,3.0,1000,-3.0,3.0);
-
+    IHistogram1D thetaPlot = aida.histogram1D("theta", 100, 0.0, 0.3);
+    IHistogram2D pulses = aida.histogram2D("pulses",100,-3.0,3.0,100,-3.0,3.0);
+    IHistogram1D eneMCPlot = aida.histogram1D("energia elettroni coulomb", 100, 0.0, 3);
+    IHistogram1D enetuttiPlot = aida.histogram1D("energia tutti", 100, 0.0, 0.3);
+     IHistogram1D eneTuttiEmenoPlot = aida.histogram1D("energia tutti elettroni", 100, 0.0, 0.3);
 public void setOutputFileName(String outputFileName){
 this.outputFileName = outputFileName;
 }
-    
+ @Override   
 public void startOfData(){
 try{
     //initialize the writer
@@ -66,7 +68,7 @@
 System.err.println("Error initializing output file for event display.");
 }
 }
-    
+ @Override   
 public void endOfData(){
 try{
 //close the file writer.
@@ -87,14 +89,17 @@
   @Override
   protected void process(EventHeader event) {
     // Get the list of mc particles from the event
-    List<MCParticle> mcParticles = event.getMCParticles();
-    // Print out the number of mc particles
-    //System.out.println("Event " + event.getEventNumber() + " contains " + mcParticles.size() + " mc particles.");
+    
+     if(event.hasCollection(MCParticle.class,"MCParticle"))
+     {
+         List<MCParticle> mcParticles = event.get(MCParticle.class,"MCParticle");
+         
  // try{
     for (MCParticle particle : mcParticles)
-    {
-       if(particle.getPDGID()==11)
-       {   if(particle.getEnergy()> 2.1)
+    { enetuttiPlot.fill(particle.getEnergy());
+       if(particle.getPDGID()>0)
+       {    eneTuttiEmenoPlot.fill(particle.getEnergy());
+             if(particle.getEnergy()> 2.1)
            { 
            PTOT=Math.sqrt(particle.getPX()*particle.getPX() + particle.getPY()*particle.getPY()+particle.getPZ()*particle.getPZ() );
            theta=Math.acos(particle.getPZ()/PTOT);
@@ -102,19 +107,19 @@
            //writer.append(theta+" "+particle.getPX()+" "+particle.getPY()+"\n");
            thetaPlot.fill(theta);
            pulses.fill(particle.getPX(),particle.getPY());
-           
+           eneMCPlot.fill(particle.getEnergy());
            }
       // }
      
      //System.out.println(particle.getPDGID());
-     } //end of for cycle
-  }//end of try
- 
+     } 
+  }
+     }
   
  /* catch(IOException e ){
   System.err.println("Error writing tooutput for event display");
   }*/
-//System.out.println("ho contato" + counter + "elettroni. \n");
+  //System.out.println("ho contato" + counter + "elettroni. \n");
     
    
    

java/trunk/users/src/main/java/org/hps/users/luca
ElectronAnalysis.java removed after 585
--- java/trunk/users/src/main/java/org/hps/users/luca/ElectronAnalysis.java	2014-05-15 15:51:59 UTC (rev 585)
+++ java/trunk/users/src/main/java/org/hps/users/luca/ElectronAnalysis.java	2014-05-15 16:11:46 UTC (rev 586)
@@ -1,80 +0,0 @@
-/*
- * 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.util.List;
-
-import org.hps.recon.ecal.HPSEcalCluster;
-import org.lcsim.event.CalorimeterHit;
-import org.lcsim.event.EventHeader;
-import org.lcsim.util.Driver;
-import org.lcsim.util.aida.AIDA;
-
-/**
- * leggo le informazioni sugli e- coulombiani. speriamo bene
- * @author Luca
- */
-public class ElectronAnalysis extends Driver {
-    //dichiaro la classe per i grafici e quelle per la ricostruzione qui invece che nello steering
-    private AIDA aida = AIDA.defaultInstance();
-    IHistogram1D enePlot = aida.histogram1D("energia", 1000, 0, 3);
-    IHistogram1D enePlotcorre = aida.histogram1D("energiacorretta", 1000, 0, 3);
-    
-	// FADCEcalReadoutDriver readoutDriver= new FADCEcalReadoutDriver();
-	// EcalRawConverterDriver converterDriver = new EcalRawConverterDriver();
-	// EcalClusterer ecalClusterer = new EcalClusterer();
-    // da qui vanno definiti gli istogrammi
-    
-    
-    //start of data
-    @Override
-    public void startOfData() {
-    	// ecalClusterer.setEcalName("Ecal");
-    	// ecalClusterer.setEcalCollectionName("EcalCorrectedHits");
-        super.startOfData();
-    }
-    
-    
-    
-    //inizio processo eventi
-    @Override
-    public void process(EventHeader event) {
-    	// Make sure that the event contains a hit collection.
-    	if(event.hasCollection(CalorimeterHit.class, "EcalHits")) {
-    		// Get the hit collection.
-	    	List<CalorimeterHit> hits = event.get(CalorimeterHit.class, "EcalHits");
-	    	
-	    	// Generate histograms from the hits which exceed 2 GeV.
-	    	for(CalorimeterHit hit : hits){
-	    		if(hit.getRawEnergy() > 2){
-	    			enePlot.fill(hit.getRawEnergy());
-	    			enePlotcorre.fill(hit.getCorrectedEnergy());
-	    		 }
-	    	}
-    	}
-    	
-    	// Make sure that the event contains a cluster collection.
-    	if(event.hasCollection(HPSEcalCluster.class, "EcalClusters")) {
-    		// Indicate that there are clusters.
-    		System.out.println("Event contains clusters.");
-    		
-    		// Get the cluster collection.
-	    	List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, "EcalClusters");
-	    	
-	    	// Print the seed hits for the clusters.
-	    	for(HPSEcalCluster cluster : clusters){
-	    		System.out.printf("\t%d%n", cluster.getSeedHit().getCellID());
-	    	}
-	    	System.out.println("\n");
-    	}
-    	
-    	// Otherwise, indicate that there are no clusters.
-    	else { System.out.println("Event does not contain clusters.\n"); }
-    }
-}

java/trunk/users/src/main/java/org/hps/users/luca
LCIOReadScript.java added at 586
--- java/trunk/users/src/main/java/org/hps/users/luca/LCIOReadScript.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/hps/users/luca/LCIOReadScript.java	2014-05-15 16:11:46 UTC (rev 586)
@@ -0,0 +1,100 @@
+package org.hps.users.luca;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
+import org.lcsim.lcio.LCIOReader;
+import org.lcsim.lcio.LCIOWriter;
+
+public class LCIOReadScript {
+	public static void main(String[] args) {
+		// Make sure there arguments are valid.
+		if(args.length != 2) {
+			System.err.println("Error: Arguments must be [Input_File] [Output_File]");
+			System.exit(1);
+		}
+		
+		// Set the input/output files.
+		File inputFile = new File(args[0]);
+		File outputFile = new File(args[1]);
+		
+		// Make sure that the input file exists.
+		if(!inputFile.canRead()) {
+			System.err.println("Error: Input file can not be found.");
+			System.exit(1);
+		}
+		
+		// Create an LCIO reader to read it in.
+		LCIOReader reader = null;
+		try { reader = new LCIOReader(inputFile); }
+		catch(IOException e) {
+			e.printStackTrace();
+			System.exit(1);
+		}
+		
+		// Create an LCIO writer to output the new file.
+		LCIOWriter writer = null;
+		try { writer = new LCIOWriter(outputFile); }
+		catch(IOException e) {
+			e.printStackTrace();
+			System.exit(1);
+		}
+		
+		// Keep looping through events until there are no more.
+		while(true) {
+			// Try to get an event.
+			EventHeader event = null;
+			try { event = reader.read(); }
+			catch(IOException e) { }
+			
+			// If the event is still null, there either was no event
+			// or an error occurred.
+			if(event == null) { break; }
+			
+			// Get the event number to print a status update.
+			int num = event.getEventNumber();
+			if(num % 10000 == 0) { System.out.println("Parsing event " + num + "."); }
+			
+			// See if the MCParticle collection exists.
+			if(event.hasCollection(MCParticle.class, "MCParticle")) {
+				// Get the MCParticle collection from the event.
+				ArrayList<MCParticle> particleList = (ArrayList<MCParticle>) event.get(MCParticle.class, "MCParticle");
+				
+				// Remove the MCParticle collection from the event.
+				event.remove("MCParticle");
+				
+				// Make a new list for good particles which pass some test.
+				ArrayList<MCParticle> goodParticles = new ArrayList<MCParticle>();
+				
+				// Sort through the list of MCParticle objects in the
+				// full list and add good ones to the good list.
+				for(MCParticle p : particleList) {
+					if(p.getEnergy() >= 2.1) { goodParticles.add(p); }
+				}
+				
+				// Write the good particles back to the event.
+				event.put("MCParticle", goodParticles);
+			}
+			
+			// Write the event back out to the new file.
+			try { writer.write(event); }
+			catch(IOException e) {
+				e.printStackTrace();
+				System.exit(1);
+			}
+		}
+		
+		// Close the reader and writer.
+		try {
+			reader.close();
+			writer.close();
+		}
+		catch(IOException e) {
+			e.printStackTrace();
+			System.exit(1);
+		}
+	}
+}

java/trunk/users/src/main/java/org/hps/users/luca
LCIOReaderScript.java removed after 585
--- java/trunk/users/src/main/java/org/hps/users/luca/LCIOReaderScript.java	2014-05-15 15:51:59 UTC (rev 585)
+++ java/trunk/users/src/main/java/org/hps/users/luca/LCIOReaderScript.java	2014-05-15 16:11:46 UTC (rev 586)
@@ -1,117 +0,0 @@
-package org.hps.users.luca;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.MCParticle;
-import org.lcsim.lcio.LCIOReader;
-import org.lcsim.lcio.LCIOWriter;
-import org.lcsim.util.Driver;
-
-public class LCIOReaderScript extends Driver {
-    String InputName;
-    String OutputName;
-    public void setOutputName(String outputName){
-    this.OutputName=outputName;}
-    public void setInputName(String inputName){
-    this.InputName= inputName;}
-	public static void prova (String inputfile, String outputfile) {
-            
-            /*
-		// Make sure there arguments are valid.
-		if(args.length != 2) {
-			System.err.println("Error: Arguments must be [Input_File] [Output_File]");
-			System.exit(1);
-		}
-		*/
-		// Set the input/output files.
-		File inputFile = new File(inputfile);
-		File outputFile = new File(outputfile);
-		
-		// Make sure that the input file exists.
-		if(!inputFile.canRead()) {
-			System.err.println("Error: Input file can not be found.");
-			System.exit(1);
-		}
-		
-		// Create an LCIO reader to read it in.
-		LCIOReader reader = null;
-		try { reader = new LCIOReader(inputFile); }
-		catch(IOException e) {
-			e.printStackTrace();
-			System.exit(1);
-		}
-		
-		// Create an LCIO writer to output the new file.
-		LCIOWriter writer = null;
-		try { writer = new LCIOWriter(outputFile); }
-		catch(IOException e) {
-			e.printStackTrace();
-			System.exit(1);
-		}
-		
-		// Keep looping through events until there are no more.
-		while(true) {
-			// Try to get an event.
-			EventHeader event = null;
-			try { event = reader.read(); }
-			catch(IOException e) { }
-			
-			// If the event is still null, there either was no event
-			// or an error occurred.
-			if(event == null) { break; }
-			
-			// Get the event number to print a status update.
-			int num = event.getEventNumber();
-			if(num % 10000 == 0) { System.out.println("Parsing event " + num + "."); }
-			
-			// See if the MCParticle collection exists.
-			if(event.hasCollection(MCParticle.class, "MCParticle")) {
-				// Get the MCParticle collection from the event.
-				ArrayList<MCParticle> particleList = (ArrayList<MCParticle>) event.get(MCParticle.class, "MCParticle");
-				
-				// Remove the MCParticle collection from the event.
-				event.remove("MCParticle");
-				
-				// Make a new list for good particles which pass some test.
-				ArrayList<MCParticle> goodParticles = new ArrayList<MCParticle>();
-				
-				// Sort through the list of MCParticle objects in the
-				// full list and add good ones to the good list.
-				for(MCParticle p : particleList) {
-					if(p.getEnergy() >= 2.1) { goodParticles.add(p); }
-				}
-				
-				// Write the good particles back to the event.
-				event.put("MCParticle", goodParticles);
-			}
-		//	System.out.println("sto scrivendo l'event nel nuovo file \n");
-			// Write the event back out to the new file.
-			try { writer.write(event); }
-			catch(IOException e) {
-				e.printStackTrace();
-				System.exit(1);
-			}
-                       // System.out.println("Sono alla ine del while");
-                        if(event.getEventNumber()==999999){break;}
-		}
-		
-		// Close the reader and writer.
-		try {
-			reader.close();
-			writer.close();
-		}
-		catch(IOException e) {
-			e.printStackTrace();
-			System.exit(1);
-		}
-	}
-        
-   @Override
-   public void process (EventHeader event){
-   prova(InputName,OutputName);
-   }
-        
-}

java/trunk/users/src/main/java/org/hps/users/luca
LCIOReaderScript2.java removed after 585
--- java/trunk/users/src/main/java/org/hps/users/luca/LCIOReaderScript2.java	2014-05-15 15:51:59 UTC (rev 585)
+++ java/trunk/users/src/main/java/org/hps/users/luca/LCIOReaderScript2.java	2014-05-15 16:11:46 UTC (rev 586)
@@ -1,76 +0,0 @@
-package org.hps.users.luca;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.MCParticle;
-import org.lcsim.lcio.LCIOReader;
-import org.lcsim.lcio.LCIOWriter;
-import org.lcsim.util.Driver;
-
-public class LCIOReaderScript2 extends Driver {
-    
-    String OutputName;
-    public void setOutputName(String outputName){
-    this.OutputName=outputName;}
-    
-  /* @Override
-   public void endOfData(){
-   System.out.println("fine dei dati");
-   }
-     */   
-    @Override
-       public void process(EventHeader event) {
-            File outputFile = new File(OutputName);
-           
-           //Create an LCIO writer to output the new file
-           LCIOWriter writer = null;
-           try { writer = new LCIOWriter(outputFile);}
-           catch(IOException e)
-           {
-           System.exit(1);}
-            //get the event number to print a status update.
-           int num =event.getEventNumber();
-           if(num % 10000 == 0){System.out.println("Parsing event" + num + ".");}
-           
-           //see if the particle collection exist
-           if(event.hasCollection(MCParticle.class,"MCParticle")){
-              
-               
-               //get the MCparticle collection from the event
-               
-               ArrayList<MCParticle> particleList = (ArrayList<MCParticle>) event.get(MCParticle.class,"MCParticle");
-               
-               //Remove the MCParticle collection from event.
-               event.remove("MCParticle");
-               
-               //make a nre list for good particles which pass some test
-               ArrayList<MCParticle> goodParticles =new ArrayList<>();
-               
-               //sort trhough the list of MCParticle objects in the full list and add good ones to the good list
-              for(MCParticle p : particleList){
-                  if(p.getEnergy()>=2.1){goodParticles.add(p);}
-              }
-              
-              //Write the good particles back to the event.
-              event.put("MCParticle", goodParticles);
-              
-              //Write the event back out to the new file
-              
-               try{writer.write(event);}
-               catch(IOException e){System.exit(1);}
-              //close the writer
-        
-               
-               try{writer.close();}
-        catch(IOException e ){System.exit(1);}            
-           }
-           
-           
-       }
-       
-       
-        
-}

java/trunk/users/src/main/java/org/hps/users/luca
mycluster.java added at 586
--- java/trunk/users/src/main/java/org/hps/users/luca/mycluster.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/hps/users/luca/mycluster.java	2014-05-15 16:11:46 UTC (rev 586)
@@ -0,0 +1,143 @@
+/*
+ * 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 hep.aida.IHistogram2D;
+import java.io.IOException;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import org.hps.readout.ecal.ClockSingleton;
+import org.hps.readout.ecal.TriggerDriver;
+
+import org.hps.recon.ecal.ECalUtils;
+import org.hps.recon.ecal.HPSEcalCluster;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.aida.AIDA;
+import org.lcsim.util.Driver;
+import hep.aida.*;
+import hep.aida.IHistogram3D;
+import java.io.FileWriter;
+import org.lcsim.event.CalorimeterHit;
+
+/**
+ *
+ * @author Luca
+ */
+public class mycluster extends Driver {
+  
+    private FileWriter writer;
+    String outputFileName = "HitEnePos.txt";
+    
+    
+    int counter=0;
+  AIDA aida = AIDA.defaultInstance();
+  IHistogram1D enePlot = aida.histogram1D("energia cluster", 100, 0.0,3.0);
+  IHistogram2D positionPlot = aida.histogram2D("Posizione cluster", 60,-350,350,10,-100,100);
+  IHistogram1D dimPlot = aida.histogram1D("dimensione cluster", 12, 0.0,12);
+  IHistogram1D dimPlot2 = aida.histogram1D("dimensione cluster con taglio", 12, 0.0,12);
+  IHistogram1D eneSeedHitPlot = aida.histogram1D("energia seedHit", 100, 0.0,3.0);
+   IHistogram1D eneHitPlot = aida.histogram1D("energia dHit", 100, 0.2,3.0);
+  IHistogram3D enePosPlot = aida.histogram3D("energia cluster vs posizione",350,-350,350,100,-100,100, 100, 0.0,3.0);
+   double[] position;
+ 
+   public void setOutputFileName(String outputFileName){
+this.outputFileName = outputFileName;
+}
+  @Override   
+public void startOfData(){
+try{
+    //initialize the writer
+    writer=new FileWriter(outputFileName);
+    //Clear the file
+    writer.write("");
+}
+catch(IOException e ){
+System.err.println("Error initializing output file for event display.");
+}
+}
+  
+@Override
+public void endOfData(){
+try{
+//close the file writer.
+    writer.close();
+    }
+catch(IOException e){
+    System.err.println("Error closing utput file for event display.");
+}
+} 
+   
+ @Override  
+ public void process (EventHeader event){
+   
+     
+     
+     if(event.hasCollection(CalorimeterHit.class,"EcalCorrectedHits"))
+     {
+         List<CalorimeterHit> hits = event.get(CalorimeterHit.class,"EcalCorrectedHits");
+         for(CalorimeterHit hit : hits){
+            if(hit.getRawEnergy()>0.6 &&hit.getRawEnergy()<2.3){
+             eneHitPlot.fill(hit.getRawEnergy());
+            
+            }
+         }
+     
+     }
+     
+     if(event.hasCollection(HPSEcalCluster.class, "EcalClusters")) {
+            List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, "EcalClusters");
+          
+            if(clusters.size() > 0) {
+                counter++;
+                for(HPSEcalCluster cluster : clusters){
+                
+                    
+                    positionPlot.fill(cluster.getPosition()[0], cluster.getPosition()[1]);
+                    enePlot.fill(cluster.getEnergy());
+                    dimPlot.fill(cluster.getSize());
+                    eneSeedHitPlot.fill(cluster.getSeedHit().getRawEnergy());
+                    position=cluster.getPosition();
+                  
+                    if(cluster.getSeedHit().getRawEnergy()>1)
+                    {dimPlot2.fill(cluster.getSize());}
+                    /* try{
+                    //writer.append(position[0] + " " + position[1] + " " +cluster.getSeedHit().getRawEnergy()+ "\n");
+                    }
+                    
+                    catch(IOException e ){System.err.println("Error writing to output for event display.");}*/
+
+
+                }
+                
+               
+            }
+           }
+        
+ 
+ }
+
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ } //chiusura driver  
+    
+    
+    
SVNspam 0.1