LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  October 2014

HPS-SVN October 2014

Subject:

r1363 - in /java/trunk/users/src/main/java/org/hps/users/luca: RawDataReader.java TruthReader.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Fri, 31 Oct 2014 11:35:58 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (288 lines)

Author: luca
Date: Fri Oct 31 04:35:56 2014
New Revision: 1363

Log: (empty)

Added:
    java/trunk/users/src/main/java/org/hps/users/luca/TruthReader.java
Modified:
    java/trunk/users/src/main/java/org/hps/users/luca/RawDataReader.java

Modified: java/trunk/users/src/main/java/org/hps/users/luca/RawDataReader.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/luca/RawDataReader.java	(original)
+++ java/trunk/users/src/main/java/org/hps/users/luca/RawDataReader.java	Fri Oct 31 04:35:56 2014
@@ -17,6 +17,8 @@
 import org.lcsim.util.Driver;
 import org.lcsim.lcio.LCIOConstants;
 import java.io.PrintWriter;
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.event.CalorimeterHit;
 
 /**
  *
@@ -28,7 +30,7 @@
     private FileWriter writer2;
     String outputFileName = "raw1.txt";
     String outputFileName2 = "raw2.txt";
-    String rawCollectionName;
+    String rawCollectionName="EcalReadoutHits";
     String ecalReadoutName = "EcalHits";
     String ecalCollectionName = "EcalCorrectedHits";
     double scale = 1.0;
@@ -88,24 +90,170 @@
     
     @Override
     public void process(EventHeader event) {
-        if (event.hasCollection(HPSRawCalorimeterHit.class, rawCollectionName)) {
-            // Get the list of ECal hits.
-            List<HPSRawCalorimeterHit> hits = event.get(HPSRawCalorimeterHit.class, rawCollectionName);
-            for(HPSRawCalorimeterHit hit : hits){
+        
+        if (event.hasCollection(RawCalorimeterHit.class, rawCollectionName)) {
+            // Get the list of ECal hits
+            
+            List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, rawCollectionName);
+            IDDecoder dec = event.getMetaData(hits).getIDDecoder();
+            for(RawCalorimeterHit hit : hits){ 
+                dec.setID(hit.getCellID());
+                int ix = dec.getValue("ix");
+                int iy = dec.getValue("iy");
+                int id=getCrystal(ix,iy);
                 try{
-                 writer.append(hit.getCellID()+" "+hit.getAmplitude());
+                 writer.append(id+" "+hit.getAmplitude() + " \n");
                 }
                 catch(IOException e){
     System.err.println("Error closing utput file for event display.");
 }
-            try{writer2.append(hit.getAnalogHit().getIdentifierFieldValue("ix") + " " + hit.getAnalogHit().getIdentifierFieldValue("iy") + " " + hit.getAnalogHit().getRawEnergy()+" \n");    
-               } 
-            
-            catch(IOException e){
-    System.err.println("Error closing utput file for event display.");
-}
+         
             }
         }
         else{System.out.println("NUOOO \n");}
-    }
-}
+        
+        if(event.hasCollection(CalorimeterHit.class, "EcalHits")){
+        List<CalorimeterHit> hits = event.get(CalorimeterHit.class, "EcalHits");
+        for(CalorimeterHit hit : hits){
+        int id=getCrystal(hit);
+        try{
+            writer2.append(id + " " + hit.getRawEnergy() + "\n");
+        }
+        catch(IOException e){System.err.println("Non riesco a scrivere raw2.");}    
+        }
+        }
+        else{System.out.println("NUOOO hits \n");}
+    }
+    
+    
+    public int getCrystal (CalorimeterHit hit){
+ int x,y,id=0;
+ x= (-1)*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;
+ 
+ }
+    
+    public int getCrystal (int ix, int iy){
+ 
+ int x,y,id=0;
+ x= (-1)*ix;
+ y= 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/TruthReader.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/luca/TruthReader.java	(added)
+++ java/trunk/users/src/main/java/org/hps/users/luca/TruthReader.java	Fri Oct 31 04:35:56 2014
@@ -0,0 +1,64 @@
+/*
+ * 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.util.*;
+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.SimCalorimeterHit; 
+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 java.io.FileWriter;
+import org.lcsim.event.CalorimeterHit;
+/**
+ * This driver is supposed to read the truth information out of a SLIC output about the energy deposition in a given crystal
+ * @author Luca
+ */
+public class TruthReader extends Driver {
+ AIDA aida = AIDA.defaultInstance();
+ IHistogram1D Ene=aida.histogram1D("Clusters energy with Luca's trigger",300, 0, 1);
+ private FileWriter writer;
+ @Override
+    public void startOfData() {
+    try{
+    //initialize the writers
+    writer=new FileWriter("verita.txt");
+    writer.write("");
+    }   
+    catch(IOException e ){ System.err.println("Error initializing output file for event display.");}
+    
+    }
+ @Override  
+ public void process (EventHeader event){
+     if(event.hasCollection(SimCalorimeterHit.class, "EcalHits")){
+     List<SimCalorimeterHit> hits=event.get(SimCalorimeterHit.class, "EcalHits");
+        for(SimCalorimeterHit hit : hits){
+            try{writer.append(hit.getCorrectedEnergy() + " " + hit.getRawEnergy() + " " + hit.getContributedEnergy(0) + "\n");}
+            catch(IOException e ){System.out.println("non riesco a scrivere perché sei stupido");}
+     
+        }  
+     
+     }
+         
+ }
+    
+}

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use