5 added + 4 modified, total 9 files
java/trunk/users/src/main/java/org/hps/users/luca
--- java/trunk/users/src/main/java/org/hps/users/luca/FEETrigger.java 2014-10-08 01:17:32 UTC (rev 1154)
+++ java/trunk/users/src/main/java/org/hps/users/luca/FEETrigger.java 2014-10-08 09:33:11 UTC (rev 1155)
@@ -88,12 +88,12 @@
// Determine in which region the cluster is located
// and increment the counter for that region. Zones
// are defined as:
- // Zone 1 is -13 < ix < -4 and 14 < ix < 21
+ // Zone 1 is -13 < ix < -4 and 14 < ix < 21 MISTAKE!!! it's all reversed!! remember!!!
// Zone 2 is -20 < ix < -14 and ix > 20
- // Zone 3 is -23 <= ix < -19
- if(-23 <= ix && ix < -19) { zone3Count++; }
- if((-20 < ix && ix < -14) || (ix > 20)) { zone2Count++; }
- if((-13 < ix && ix < -4) || (14 < ix && ix < 21)) { zone1Count++; }
+ // Zone 3 is -23 <= ix < -18
+ if( ix > 18 || ix < -22) { zone3Count++; }
+ if(ix < 19 && ix > 12 ) { zone2Count++; }
+ if((ix > 4 && ix < 13) || (ix > -23 && ix < -14)) { zone1Count++; }
}
}
}
java/trunk/users/src/main/java/org/hps/users/luca
--- java/trunk/users/src/main/java/org/hps/users/luca/FEETrigger2.java (rev 0)
+++ java/trunk/users/src/main/java/org/hps/users/luca/FEETrigger2.java 2014-10-08 09:33:11 UTC (rev 1155)
@@ -0,0 +1,174 @@
+package org.hps.users.luca;
+
+import java.util.List;
+
+import org.hps.readout.ecal.TriggerDriver;
+import org.hps.recon.ecal.HPSEcalCluster;
+
+import org.lcsim.event.EventHeader;
+
+/**
+ * Class <code>FEETrigger</code> represents a single-cluster trigger
+ * that triggers off of clusters which exceed a certain energy threshold.
+ * The trigger considers three regions, each which require a different
+ * number of clusters to occur in said region before the trigger occurs.
+ *
+ * @author Luca Colaneri
+ */
+public class FEETrigger2 extends TriggerDriver {
+ // Store the LCIO cluster collection name.
+ private String clusterCollectionName = "EcalClusters";
+
+ // Store the cluster total energy trigger threshold.
+ private double energyThreshold = 1.5;
+
+ // Track the number of over-threshold clusters in each region.
+ private int zone1Count = 0;
+ private int zone2Count = 0;
+ private int zone3Count = 0;
+ private int zone4Count = 0;
+
+ // The number of cluster over threshold that must occur in a region
+ // before a trigger occurs.
+ private int zone1Prescaling = 1000;
+ private int zone2Prescaling = 70;
+ private int zone4Prescaling = 200;
+ /**
+ * Sets the energy threshold required for a cluster to be counted.
+ *
+ * @param energyThreshold - The energy threshold in GeV.
+ */
+ public void setEnergyThreshold(int energyThreshold) {
+ this.energyThreshold = energyThreshold;
+ }
+
+ /**
+ * Sets the number of events over threshold which must occur in the
+ * first region in order for a trigger to occur.
+ *
+ * @param zone1Prescaling - The number of over-threshold clusters needed
+ * for a trigger.
+ */
+ public void setZone1Prescaling(int zone1Prescaling) {
+ this.zone1Prescaling = zone1Prescaling;
+ }
+
+ /**
+ * Sets the number of events over threshold which must occur in the
+ * second region in order for a trigger to occur.
+ *
+ * @param zone2Prescaling - The number of over-threshold clusters needed
+ * for a trigger.
+ */
+ public void setZone2Prescaling(int zone2Prescaling) {
+ this.zone2Prescaling = zone2Prescaling;
+ }
+
+ /**
+ * Checks if any clusters exist over the set energy threshold and,
+ * if they do, increments the appropriate over-threshold count
+ * variable for the zone in which the cluster resides.
+ *
+ * @param event - The event from which clusters should be extracted.
+ */
+ @Override
+ public void process(EventHeader event) {
+ if(event.hasCollection(HPSEcalCluster.class, clusterCollectionName)) {
+ // Get the list of clusters from the event.
+ List<HPSEcalCluster> clusterList = event.get(HPSEcalCluster.class, clusterCollectionName);
+
+ // Loop over the clusters and check for any that pass the threshold.
+ for(HPSEcalCluster cluster : clusterList) {
+ // Check if the current cluster exceeds the energy
+ // threshold. If it does not, continue to the next
+ // cluster in the list.
+ if(cluster.getEnergy() > energyThreshold) {
+ // Get the x-index of the seed hit.
+ int ix = cluster.getSeedHit().getIdentifierFieldValue("ix");
+
+ // Determine in which region the cluster is located
+ // and increment the counter for that region. Zones
+ // are defined as:
+ // Zone 1 is -13 < ix < -4 and 14 < ix < 21
+ // Zone 2 is -20 < ix < -14 and ix > 20
+ // Zone 3 is -23 <= ix < -19
+ if(-23 <= ix && ix < -19) { zone3Count++; }
+ if((-20 < ix && ix < -14)) { zone2Count++; }
+ if((-13 < ix && ix < -4) || (14 < ix && ix < 21)) { zone1Count++; }
+ if(ix>20){zone4Count++;}
+ }
+ }
+ }
+
+ // Run the superclass event processing.
+ super.process(event);
+ }
+
+ /**
+ * Checks whether or not a trigger occurred.
+ *
+ * @param event - The event on which to base the trigger decision.
+ * @return Returns <code>true</code> if a trigger occurred and <code>
+ * false</code> if a trigger did not.
+ */
+ @Override
+ protected boolean triggerDecision(EventHeader event) {
+ // Check if the event has clusters. An event with no clusters
+ // should never result in a trigger.
+ if(event.hasCollection(HPSEcalCluster.class, clusterCollectionName)) {
+ // Check if any of the zone counts are high enough to trigger.
+ return triggerTest();
+ }
+
+ // Events without clusters can not trigger.
+ else { return false; }
+ }
+
+ /**
+ * Checks if any of the regional counts are sufficiently high to
+ * register a trigger.
+ *
+ * @return Returns <code>true</code> if a region has enough clusters
+ * to trigger and <code>false</code> otherwise.
+ */
+ private boolean triggerTest() {
+ // Track whether a trigger occurred.
+ boolean trigger = false;
+
+ // If any clusters occur in zone 3, reset the count and note
+ // that a trigger occurred.
+ if(zone3Count > 0) {
+ zone3Count = 0;
+ if(zone2Count==zone2Prescaling){zone2Count=0;}
+ if(zone1Count==zone1Prescaling){zone1Count=0;}
+ trigger = true;
+ }
+
+ // If zone 2 has sufficient clusters (100 by default) to
+ // trigger, reset its count and note that a trigger occurred.
+ else if(zone2Count == zone2Prescaling) {
+ zone2Count = 0;
+ if(zone3Count>0){zone3Count=0;}
+ if(zone1Count==zone1Prescaling){zone1Count=0;}
+ trigger = true;
+ }
+
+ // If zone 3 has sufficient clusters (1000 by default) to
+ // trigger, reset its count and note that a trigger occurred.
+ else if(zone1Count == zone1Prescaling) {
+ zone1Count = 0;
+ if(zone3Count>0){zone3Count=0;}
+ if(zone2Count==zone2Prescaling){zone2Count=0;}
+ trigger = true;
+ }
+ else if(zone4Count == zone4Prescaling) {
+ zone4Count = 0;
+ if(zone3Count>0){zone3Count=0;}
+ if(zone2Count==zone2Prescaling){zone2Count=0;}
+ if(zone1Count==zone1Prescaling){zone1Count=0;}
+ trigger = true;
+ }
+ // Return whether or not a trigger occurred.
+ return trigger;
+ }
+}
\ No newline at end of file
java/trunk/users/src/main/java/org/hps/users/luca
--- java/trunk/users/src/main/java/org/hps/users/luca/FeeTriggerAna.java (rev 0)
+++ java/trunk/users/src/main/java/org/hps/users/luca/FeeTriggerAna.java 2014-10-08 09:33:11 UTC (rev 1155)
@@ -0,0 +1,420 @@
+/*
+ * 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.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;
+
+
+/**
+ *
+ * @author Luca Colaneri
+ */
+public class FeeTriggerAna extends Driver {
+ int posx, posy;
+ int radius=2;
+ int Clustercount=0;
+ int clusterWindow=50;
+ int TotalCluster=0;
+ double timeDifference;
+ double energyThreshold=0;
+ private LinkedList<ArrayList<HPSEcalCluster>> clusterBuffer;
+ protected String clusterCollectionName = "EcalClusters";
+
+ //AIDA aida = AIDA.defaultInstance();
+// IHistogram1D clusterEne=aida.histogram1D("Clusters energy with Luca's trigger",300, 0, 3);
+// ArrayList<IHistogram1D> SeedHistograms = new ArrayList<IHistogram1D>(442);
+ // ArrayList<IHistogram1D> ClustHistograms = new ArrayList<IHistogram1D>(442);
+ // ArrayList<IHistogram1D> HitHistograms = new ArrayList<IHistogram1D>(442);
+ private FileWriter writer;
+ // private FileWriter writer2;
+ String outputFileName = "LucaTriggerFEE.txt";
+ // String outputFileName2 = "LucaTriggerHits.txt";
+
+
+
+
+ public void setRadius (int radius){
+ this.radius=radius;
+ }
+
+ public void setEnergyThreshold (double threshold){
+ this.energyThreshold=threshold;
+ }
+
+ public void setClusterCollectionName(String clusterCollectionName) {
+ this.clusterCollectionName = clusterCollectionName;
+ }
+
+ public void setOutputFileName(String outputFileName){
+this.outputFileName = outputFileName;
+}
+/// public void setOutputFileName2(String outputFileName2){
+//this.outputFileName2 = outputFileName2;
+ //}
+ public void settimeDifference(double time){
+ this.timeDifference=time;
+
+ }
+ /*
+ *
+ *
+ *
+ */
+
+ @Override
+public void startOfData(){
+
+ //initialize the clusterbuffer
+ clusterBuffer= new LinkedList<ArrayList<HPSEcalCluster>>();
+ //populate the clusterbuffer with (2*clusterWindow + 1)
+ // empty events, representing the fact that the first few events will not have any events in the past portion of the buffer
+ int bufferSize=(2*clusterWindow)+1;
+ for(int i = 0;i<bufferSize; i++){
+ clusterBuffer.add(new ArrayList<HPSEcalCluster>(0));
+ }
+
+
+
+
+ try{
+ //initialize the writers
+ writer=new FileWriter(outputFileName);
+ // writer2=new FileWriter(outputFileName2);
+ //Clear the files
+ writer.write("");
+ // writer2.write("");
+
+ //initialize histograms
+ /* for(int t=0; t<442; t++){
+ String cristallo=String.valueOf(t);
+ String seedhistogram="SeedHit_" + String.valueOf(t);
+ String Clushistogram="Clusters_" + String.valueOf(t);
+ String HitHistogram="Hits_" + String.valueOf(t);
+
+ IHistogram1D seedhisto=aida.histogram1D(seedhistogram, 150, 0.0,3.0);
+ IHistogram1D clushisto=aida.histogram1D(Clushistogram, 150, 0.0,3.0);
+ IHistogram1D hitshisto=aida.histogram1D(HitHistogram,150,0.0,3.0);
+ SeedHistograms.add(seedhisto);
+ ClustHistograms.add(clushisto);
+ HitHistograms.add(hitshisto);
+ }*/
+
+}
+catch(IOException e ){
+System.err.println("Error initializing output file for event display.");
+}
+}
+
+@Override
+public void endOfData(){
+System.out.println("Ho contato" + TotalCluster + " clusters di cui " + Clustercount + "isolati\n");
+
+ 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){
+
+
+
+
+
+ //get the clusters from the event
+ if(TriggerDriver.triggerBit()){ //if they have triggered!
+
+ if(event.hasCollection(HPSEcalCluster.class, "EcalClusters")) {
+
+ List<HPSEcalCluster> clusterList =event.get(HPSEcalCluster.class,clusterCollectionName );
+
+ //put the clusters in the arraylist
+
+ ArrayList<HPSEcalCluster> clusterSet = new ArrayList<HPSEcalCluster>();
+ for(HPSEcalCluster cluster : clusterList){
+ // clusterEne.fill(cluster.getEnergy());
+ TotalCluster++;
+ // clusterSet.add(cluster);
+ int id;
+ id=getCrystal(cluster);
+ try{
+ writer.append(id + " " + cluster.getEnergy()+ " " + cluster.getSize() + " " + cluster.getSeedHit().getRawEnergy() + " " + cluster.getSeedHit().getIdentifierFieldValue("ix")+" " +cluster.getSeedHit().getIdentifierFieldValue("iy"));
+ /*for(CalorimeterHit hit : cluster.getCalorimeterHits())
+ {writer.append(hit.getRawEnergy()+ " ");
+ }*/
+ writer.append("\n");
+
+ }
+ catch(IOException e ){System.err.println("Error writing to output for event display");}
+
+ }
+ //remove the last event from cluster buffer and add the new one
+ //clusterBuffer.removeLast();
+ // clusterBuffer.addFirst(clusterSet);
+ //Run the sorting algorithm;
+ // ClusterAnalyzer();
+
+ }
+
+
+
+ }// questa parentesi va scommentata se si scommenta l'if del trigger
+
+}
+
+
+ /**
+ * For each crystal, looks for clusters that hit that clystar, if it is an isolated cluster, it's put in goodclusterqueue
+ */
+ public void ClusterAnalyzer(){
+ //get the cluster list at the current time in the buffer
+ArrayList<HPSEcalCluster> currentClusters = clusterBuffer.get(clusterWindow+1);
+
+
+ ///cerca i cluster nella posizione che ci interessa poi chiama la funzione che decide se sono "isolati"
+ //System.out.println("Sta partendo il for sulla Queue \n");
+ for(int y=-5;y<6;y++){
+ for(int x=-23;x<24;x++){
+ posx=x;
+ posy=y;
+
+ //ciclo for nel set di currentCluster, ovvero il set nel mezzo del buffer
+ for(HPSEcalCluster cluster : currentClusters){
+ if((cluster.getSeedHit().getIdentifierFieldValue("ix")== posx) && (cluster.getSeedHit().getIdentifierFieldValue("iy")==posy )&& (cluster.getEnergy() > energyThreshold)){
+
+ if(ClusterChecker(cluster)){
+ int id;
+ Clustercount++;
+ id=getCrystal(cluster);
+ try{
+ writer.append(id + " " + cluster.getEnergy()+ " " + cluster.getSize() + " " + cluster.getSeedHit().getRawEnergy() + " " + cluster.getSeedHit().getIdentifierFieldValue("ix")+" " +cluster.getSeedHit().getIdentifierFieldValue("iy"));
+ /*for(CalorimeterHit hit : cluster.getCalorimeterHits())
+ {writer.append(hit.getRawEnergy()+ " ");
+ }*/
+ writer.append("\n");
+ // SeedHistograms.get(id-1).fill(cluster.getSeedHit().getRawEnergy());
+ // ClustHistograms.get(id-1).fill(cluster.getEnergy());
+ }
+
+ catch(IOException e ){System.err.println("Error writing to output for event display");}
+
+ }
+ }
+
+
+ }
+
+
+
+ }
+ }
+
+
+
+
+
+ }
+ /**
+ * Check if the cluster is isolaterd checking if there are clusters near it in time and in space in the buffer
+ * @param cluster
+ * @return
+ */
+
+public boolean ClusterChecker (HPSEcalCluster cluster){
+//System.out.println("Sono nel clustercheck! \n");
+
+boolean check=true;
+
+ //ciclo sulle liste del buffer
+loops:
+ for(ArrayList<HPSEcalCluster> currentList : clusterBuffer){
+ //ciclo sui cluster della lista corrente
+ for(HPSEcalCluster currentcluster : currentList){
+ if(currentcluster!= cluster){
+ //if there is a cluster in the buffer that is in the considered radius in a time window lower than expected, the loop is brocken and the analyzed cluster is not good
+ if(!((currentcluster.getSeedHit().getIdentifierFieldValue("ix") < posx-radius || currentcluster.getSeedHit().getIdentifierFieldValue("ix")> posx+radius)&& (currentcluster.getSeedHit().getIdentifierFieldValue("iy")< posy-radius || currentcluster.getSeedHit().getIdentifierFieldValue("iy")> posy+radius))&& Math.abs(cluster.getSeedHit().getTime()-currentcluster.getSeedHit().getTime())<timeDifference){
+ check=false;
+ break loops;
+ }
+ }
+
+
+
+ }
+
+
+ }
+
+
+
+return check;
+
+}
+
+
+
+ public int getCrystal (HPSEcalCluster cluster){
+ int x,y,id=0;
+ x= (-1)*cluster.getSeedHit().getIdentifierFieldValue("ix");
+ y= cluster.getSeedHit().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= (-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;
+
+ }
+
+ } //chiusura driver
+
+
+
java/trunk/users/src/main/java/org/hps/users/luca
--- java/trunk/users/src/main/java/org/hps/users/luca/RawDataReader.java (rev 0)
+++ java/trunk/users/src/main/java/org/hps/users/luca/RawDataReader.java 2014-10-08 09:33:11 UTC (rev 1155)
@@ -0,0 +1,111 @@
+/*
+ * 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 java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.hps.recon.ecal.HPSRawCalorimeterHit;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawCalorimeterHit;
+import org.lcsim.util.Driver;
+import org.lcsim.lcio.LCIOConstants;
+import java.io.PrintWriter;
+
+/**
+ *
+ * @author Luca
+ */
+public class RawDataReader extends Driver{
+
+ private FileWriter writer;
+ private FileWriter writer2;
+ String outputFileName = "raw1.txt";
+ String outputFileName2 = "raw2.txt";
+ String rawCollectionName;
+ String ecalReadoutName = "EcalHits";
+ String ecalCollectionName = "EcalCorrectedHits";
+ double scale = 1.0;
+// double pedestal = 0.0;
+ double period = 4.0;
+ double dt = 0.0;
+ public void setScale(double scale) {
+ this.scale = scale;
+ }
+
+ public void setEcalCollectionName(String ecalCollectionName) {
+ this.ecalCollectionName = ecalCollectionName;
+ }
+
+ public void setRawCollectionName(String rawCollectionName) {
+ this.rawCollectionName = rawCollectionName;
+ }
+
+ public void setOutputFileName(String outputFileName){
+ this.outputFileName = outputFileName;
+}
+ @Override
+ public void startOfData() {
+ if (ecalCollectionName == null) {
+ throw new RuntimeException("The parameter ecalCollectionName was not set!");
+ }
+
+ 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.");
+ }
+
+
+
+ }
+
+ @Override
+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(HPSRawCalorimeterHit.class, rawCollectionName)) {
+ // Get the list of ECal hits.
+ List<HPSRawCalorimeterHit> hits = event.get(HPSRawCalorimeterHit.class, rawCollectionName);
+ for(HPSRawCalorimeterHit hit : hits){
+ try{
+ writer.append(hit.getCellID()+" "+hit.getAmplitude());
+ }
+ 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");}
+ }
+}
java/trunk/users/src/main/java/org/hps/users/luca
--- java/trunk/users/src/main/java/org/hps/users/luca/ReconDataPos.java 2014-10-08 01:17:32 UTC (rev 1154)
+++ java/trunk/users/src/main/java/org/hps/users/luca/ReconDataPos.java 2014-10-08 09:33:11 UTC (rev 1155)
@@ -15,9 +15,8 @@
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;
@@ -30,6 +29,7 @@
import java.io.FileWriter;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.MCParticle;
+import org.lcsim.event.ReconstructedParticle;
/**
*
@@ -154,9 +154,34 @@
public void process (EventHeader event){
-
+ //see if it has the reconstructed collectiom
+ if(event.hasCollection(ReconstructedParticle.class, "FinalStateParticles")){
+ List<ReconstructedParticle> particles = event.get(ReconstructedParticle.class, "FinalStateParticles");
+
+ for(ReconstructedParticle particle: particles){
+
+ if(particle.getCharge()>0){
+
+ System.out.println(particle.getEnergy()*particle.getEnergy()-particle.getMomentum().magnitudeSquared()+"\n");
+
+ double mass=Math.sqrt(particle.getEnergy()*particle.getEnergy() - particle.getMomentum().magnitudeSquared());
+ List<Cluster> clusters = particle.getClusters();
+
+ for(Cluster cluster : clusters){
+
+ int id=getCrystal(cluster);
+ try{
+ writer.append(id + " " + cluster.getEnergy() + " " + cluster.getSize() + " " + HPSEcalCluster.getSeedHit(cluster).getCorrectedEnergy() + " " + HPSEcalCluster.getSeedHit(cluster).getIdentifierFieldValue("ix")+" " +HPSEcalCluster.getSeedHit(cluster).getIdentifierFieldValue("iy")+ "\n");
+ }
+
+ catch(IOException e ){System.err.println("Error writing to output for event display");}
+
-
+ }
+
+ }
+ }
+ }
//get the clusters from the event
if(event.hasCollection(Cluster.class, "EcalClusters")) {
List<Cluster> clusterList =event.get(Cluster.class,clusterCollectionName );
java/trunk/users/src/main/java/org/hps/users/luca
--- java/trunk/users/src/main/java/org/hps/users/luca/TriggerAna.java 2014-10-08 01:17:32 UTC (rev 1154)
+++ java/trunk/users/src/main/java/org/hps/users/luca/TriggerAna.java 2014-10-08 09:33:11 UTC (rev 1155)
@@ -42,18 +42,18 @@
int clusterWindow=50;
int TotalCluster=0;
double timeDifference;
- double energyThreshold=1.5;
+ double energyThreshold=0;
private LinkedList<ArrayList<HPSEcalCluster>> clusterBuffer;
protected String clusterCollectionName = "EcalClusters";
- AIDA aida = AIDA.defaultInstance();
-IHistogram1D clusterEne=aida.histogram1D("Clusters energy with Kyle's trigger",300, 0, 3);
+ //AIDA aida = AIDA.defaultInstance();
+//IHistogram1D clusterEne=aida.histogram1D("Clusters energy with Kyle's trigger",300, 0, 3);
private FileWriter writer;
- private FileWriter writer2;
+ // private FileWriter writer2;
private FileWriter writer3;
private FileWriter writer4;
String outputFileName = "KyleTriggerFEE.txt";
- String outputFileName2 = "KyleTriggerHits.txt";
+ // String outputFileName2 = "KyleTriggerHits.txt";
String outputFileName3 = "NoTriggerFEE.txt";
@@ -74,8 +74,8 @@
public void setOutputFileName(String outputFileName){
this.outputFileName = outputFileName;
}
- public void setOutputFileName2(String outputFileName2){
-this.outputFileName2 = outputFileName2;
+ public void setOutputFileName3(String outputFileName3){
+this.outputFileName3 = outputFileName3;
}
public void settimeDifference(double time){
this.timeDifference=time;
@@ -105,12 +105,12 @@
try{
//initialize the writers
writer=new FileWriter(outputFileName);
- writer2=new FileWriter(outputFileName2);
+ //writer2=new FileWriter(outputFileName2);
writer3=new FileWriter(outputFileName3);
//Clear the files
writer.write("");
- writer2.write("");
+ // writer2.write("");
writer3.write("");
@@ -123,12 +123,12 @@
@Override
public void endOfData(){
-System.out.println("Ho contato" + TotalCluster + " clusters di cui " + Clustercount + "isolati\n");
+//System.out.println("Ho contato" + TotalCluster + " clusters di cui " + Clustercount + "isolati\n");
try{
//close the file writer.
writer.close();
- writer2.close();
+ // writer2.close();
writer3.close();
}
@@ -163,58 +163,11 @@
//put the clusters in the arraylist
- ArrayList<HPSEcalCluster> clusterSet = new ArrayList<HPSEcalCluster>();
+
for(HPSEcalCluster cluster : clusterList){
- clusterEne.fill(cluster.getEnergy());
+ // clusterEne.fill(cluster.getEnergy());
TotalCluster++;
- clusterSet.add(cluster);
- }
- //remove the last event from cluster buffer and add the new one
- clusterBuffer.removeLast();
- clusterBuffer.addFirst(clusterSet);
- //Run the sorting algorithm;
- ClusterAnalyzer();
- }
-
- //get the hits from the event
- if(event.hasCollection(CalorimeterHit.class,"EcalCorrectedHits")){
- List<CalorimeterHit> hits =event.get(CalorimeterHit.class,"EcalCorrectedHits");
-
- for(CalorimeterHit hit : hits){
- int id=getCrystal(hit)-1;
-
- try{ writer2.append(id + " " + hit.getRawEnergy()+ "\n");}
- catch(IOException e ){System.err.println("Error writing to output for event display");}
- }
-
- }
-
- }
-
-}
-
-
- /**
- * For each crystal, looks for clusters that hit that clystar, if it is an isolated cluster, it's put in goodclusterqueue
- */
- public void ClusterAnalyzer(){
- //get the cluster list at the current time in the buffer
-ArrayList<HPSEcalCluster> currentClusters = clusterBuffer.get(clusterWindow+1);
-
-
- ///cerca i cluster nella posizione che ci interessa poi chiama la funzione che decide se sono "isolati"
- //System.out.println("Sta partendo il for sulla Queue \n");
- for(int y=-5;y<6;y++){
- for(int x=-23;x<24;x++){
- posx=x;
- posy=y;
-
- //ciclo for nel set di currentCluster, ovvero il set nel mezzo del buffer
- for(HPSEcalCluster cluster : currentClusters){
- if((cluster.getSeedHit().getIdentifierFieldValue("ix")== posx) && (cluster.getSeedHit().getIdentifierFieldValue("iy")==posy )&& (cluster.getEnergy() > energyThreshold)){
-
- if(ClusterChecker(cluster)){
- int id;
+ int id;
Clustercount++;
id=getCrystal(cluster);
try{
@@ -227,60 +180,15 @@
}
catch(IOException e ){System.err.println("Error writing to output for event display");}
-
- }
- }
+ }
+
+ }
+
}
-
-
-
- }
- }
-
-
-
-
-
- }
- /**
- * Check if the cluster is isolaterd checking if there are clusters near it in time and in space in the buffer
- * @param cluster
- * @return
- */
-
-public boolean ClusterChecker (HPSEcalCluster cluster){
-//System.out.println("Sono nel clustercheck! \n");
-
-boolean check=true;
-
- //ciclo sulle liste del buffer
-loops:
- for(ArrayList<HPSEcalCluster> currentList : clusterBuffer){
- //ciclo sui cluster della lista corrente
- for(HPSEcalCluster currentcluster : currentList){
- if(currentcluster!= cluster){
- //if there is a cluster in the buffer that is in the considered radius in a time window lower than expected, the loop is brocken and the analyzed cluster is not good
- if(!((currentcluster.getSeedHit().getIdentifierFieldValue("ix") < posx-radius || currentcluster.getSeedHit().getIdentifierFieldValue("ix")> posx+radius)&& (currentcluster.getSeedHit().getIdentifierFieldValue("iy")< posy-radius || currentcluster.getSeedHit().getIdentifierFieldValue("iy")> posy+radius))&& Math.abs(cluster.getSeedHit().getTime()-currentcluster.getSeedHit().getTime())<timeDifference){
- check=false;
- break loops;
- }
- }
-
-
-
- }
-
- }
-
-
-
-return check;
-
}
-
public int getCrystal (HPSEcalCluster cluster){
java/trunk/users/src/main/java/org/hps/users/luca
--- java/trunk/users/src/main/java/org/hps/users/luca/TriggerAnaFEE.java (rev 0)
+++ java/trunk/users/src/main/java/org/hps/users/luca/TriggerAnaFEE.java 2014-10-08 09:33:11 UTC (rev 1155)
@@ -0,0 +1,316 @@
+/*
+ * 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.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;
+
+
+/**
+ *
+ * @author Luca Colaneri
+ */
+public class TriggerAnaFEE extends Driver {
+ int posx, posy;
+ int radius=2;
+ int Clustercount=0;
+ int clusterWindow=50;
+ int TotalCluster=0;
+ double timeDifference;
+ double energyThreshold=0;
+ private LinkedList<ArrayList<HPSEcalCluster>> clusterBuffer;
+ protected String clusterCollectionName = "EcalClusters";
+
+ //AIDA aida = AIDA.defaultInstance();
+//IHistogram1D clusterEne=aida.histogram1D("Clusters energy with Kyle's trigger",300, 0, 3);
+ private FileWriter writer;
+ // private FileWriter writer2;
+
+ String outputFileName = "KyleTriggerFEE.txt";
+ // String outputFileName2 = "KyleTriggerHits.txt";
+
+
+
+
+
+ public void setRadius (int radius){
+ this.radius=radius;
+ }
+
+ public void setEnergyThreshold (double threshold){
+ this.energyThreshold=threshold;
+ }
+
+ public void setClusterCollectionName(String clusterCollectionName) {
+ this.clusterCollectionName = clusterCollectionName;
+ }
+
+ public void setOutputFileName(String outputFileName){
+this.outputFileName = outputFileName;
+}
+
+ public void settimeDifference(double time){
+ this.timeDifference=time;
+
+ }
+ /*
+ *
+ *
+ *
+ */
+
+ @Override
+public void startOfData(){
+
+ //initialize the clusterbuffer
+ clusterBuffer= new LinkedList<ArrayList<HPSEcalCluster>>();
+ //populate the clusterbuffer with (2*clusterWindow + 1)
+ // empty events, representing the fact that the first few events will not have any events in the past portion of the buffer
+ int bufferSize=(2*clusterWindow)+1;
+ for(int i = 0;i<bufferSize; i++){
+ clusterBuffer.add(new ArrayList<HPSEcalCluster>(0));
+ }
+
+
+
+
+ try{
+ //initialize the writers
+ writer=new FileWriter(outputFileName);
+ //writer2=new FileWriter(outputFileName2);
+
+
+ //Clear the files
+ writer.write("");
+
+
+
+
+
+}
+catch(IOException e ){
+System.err.println("Error initializing output file for event display.");
+}
+}
+
+@Override
+public void endOfData(){
+//System.out.println("Ho contato" + TotalCluster + " clusters di cui " + Clustercount + "isolati\n");
+
+ 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){
+
+
+
+
+ //get the clusters from the event IF they are triggered
+ if(TriggerDriver.triggerBit()){
+ if(event.hasCollection(HPSEcalCluster.class, "EcalClusters")) {
+ List<HPSEcalCluster> clusterList =event.get(HPSEcalCluster.class,clusterCollectionName );
+
+
+
+
+ for(HPSEcalCluster cluster : clusterList){
+ // clusterEne.fill(cluster.getEnergy());
+ TotalCluster++;
+ int id;
+ Clustercount++;
+ id=getCrystal(cluster);
+ try{
+ writer.append(id + " " + cluster.getEnergy()+ " " + cluster.getSize() + " " + cluster.getSeedHit().getRawEnergy() + " " + cluster.getSeedHit().getIdentifierFieldValue("ix")+" " +cluster.getSeedHit().getIdentifierFieldValue("iy"));
+ /*for(CalorimeterHit hit : cluster.getCalorimeterHits())
+ {writer.append(hit.getRawEnergy()+ " ");
+ }*/
+ writer.append("\n");
+
+ }
+
+ catch(IOException e ){System.err.println("Error writing to output for event display");}
+ }
+
+ }
+
+
+
+ }
+
+}
+
+
+
+
+
+
+
+
+ public int getCrystal (HPSEcalCluster cluster){
+ int x,y,id=0;
+ x= (-1)*cluster.getSeedHit().getIdentifierFieldValue("ix");
+ y= cluster.getSeedHit().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= (-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;
+
+ }
+
+ } //chiusura driver
+
+
+
java/trunk/users/src/main/java/org/hps/users/luca
--- java/trunk/users/src/main/java/org/hps/users/luca/TriggerTest.java (rev 0)
+++ java/trunk/users/src/main/java/org/hps/users/luca/TriggerTest.java 2014-10-08 09:33:11 UTC (rev 1155)
@@ -0,0 +1,42 @@
+// import the required classes
+package org.hps.users.luca;
+
+//import hep.aida.ITupleColumn.String;
+import hep.aida.IHistogram1D;
+import org.lcsim.util.aida.AIDA;
+import java.util.List;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
+import org.lcsim.util.Driver;
+
+
+// the class has to be derived from the driver class
+public class TriggerTest extends Driver {
+
+ AIDA aida = AIDA.defaultInstance();
+ IHistogram1D elettroni=aida.histogram1D("elettroni", 150, 0.0,3.0);
+ IHistogram1D positroni=aida.histogram1D("positroni", 150, 0.0,3.0);
+
+ // overwrite the process method
+ @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.");
+
+ for (MCParticle particle : mcParticles)
+ {
+ if(particle.getPDGID()==11)
+ {elettroni.fill(particle.getEnergy());
+ }
+ if(particle.getPDGID()==-11)
+ {positroni.fill(particle.getEnergy());
+ }
+ //System.out.println(particle.getPDGID());
+ }
+
+
+ }
+
+}
\ No newline at end of file
java/trunk/users/src/main/java/org/hps/users/luca
--- java/trunk/users/src/main/java/org/hps/users/luca/mycluster3.java 2014-10-08 01:17:32 UTC (rev 1154)
+++ java/trunk/users/src/main/java/org/hps/users/luca/mycluster3.java 2014-10-08 09:33:11 UTC (rev 1155)
@@ -42,19 +42,19 @@
int clusterWindow=50;
int TotalCluster=0;
double timeDifference;
- double energyThreshold=1.5;
+ double energyThreshold=0;
private LinkedList<ArrayList<HPSEcalCluster>> clusterBuffer;
protected String clusterCollectionName = "EcalClusters";
- AIDA aida = AIDA.defaultInstance();
- IHistogram1D clusterEne=aida.histogram1D("Clusters energy with Luca's trigger",300, 0, 3);
+ //AIDA aida = AIDA.defaultInstance();
+// IHistogram1D clusterEne=aida.histogram1D("Clusters energy with Luca's trigger",300, 0, 3);
// ArrayList<IHistogram1D> SeedHistograms = new ArrayList<IHistogram1D>(442);
// ArrayList<IHistogram1D> ClustHistograms = new ArrayList<IHistogram1D>(442);
// ArrayList<IHistogram1D> HitHistograms = new ArrayList<IHistogram1D>(442);
private FileWriter writer;
- private FileWriter writer2;
+ // private FileWriter writer2;
String outputFileName = "LucaTriggerFEE.txt";
- String outputFileName2 = "LucaTriggerHits.txt";
+ // String outputFileName2 = "LucaTriggerHits.txt";
@@ -74,9 +74,9 @@
public void setOutputFileName(String outputFileName){
this.outputFileName = outputFileName;
}
- public void setOutputFileName2(String outputFileName2){
-this.outputFileName2 = outputFileName2;
- }
+/// public void setOutputFileName2(String outputFileName2){
+//this.outputFileName2 = outputFileName2;
+ //}
public void settimeDifference(double time){
this.timeDifference=time;
@@ -105,10 +105,10 @@
try{
//initialize the writers
writer=new FileWriter(outputFileName);
- writer2=new FileWriter(outputFileName2);
+ // writer2=new FileWriter(outputFileName2);
//Clear the files
writer.write("");
- writer2.write("");
+ // writer2.write("");
//initialize histograms
/* for(int t=0; t<442; t++){
@@ -138,7 +138,7 @@
try{
//close the file writer.
writer.close();
- writer2.close();
+ //writer2.close();
}
catch(IOException e){
System.err.println("Error closing utput file for event display.");
@@ -153,39 +153,35 @@
//get the clusters from the event
- if(TriggerDriver.triggerBit()){ //if they have triggered!
+ // if(TriggerDriver.triggerBit()){ //if they have triggered!
+
if(event.hasCollection(HPSEcalCluster.class, "EcalClusters")) {
+
List<HPSEcalCluster> clusterList =event.get(HPSEcalCluster.class,clusterCollectionName );
//put the clusters in the arraylist
ArrayList<HPSEcalCluster> clusterSet = new ArrayList<HPSEcalCluster>();
for(HPSEcalCluster cluster : clusterList){
- clusterEne.fill(cluster.getEnergy());
+ // clusterEne.fill(cluster.getEnergy());
TotalCluster++;
clusterSet.add(cluster);
+
+
+
}
//remove the last event from cluster buffer and add the new one
clusterBuffer.removeLast();
clusterBuffer.addFirst(clusterSet);
//Run the sorting algorithm;
ClusterAnalyzer();
- }
- //get the hits from the event
- if(event.hasCollection(CalorimeterHit.class,"EcalCorrectedHits")){
- List<CalorimeterHit> hits =event.get(CalorimeterHit.class,"EcalCorrectedHits");
-
- for(CalorimeterHit hit : hits){
- int id=getCrystal(hit)-1;
- // HitHistograms.get(id).fill(hit.getRawEnergy());
- try{ writer2.append(id + " " + hit.getRawEnergy()+ "\n");}
- catch(IOException e ){System.err.println("Error writing to output for event display");}
- }//end of for cycle
}
- }
+
+ // }// questa parentesi va scommentata se si scommenta l'if del trigger
+//
}
SVNspam 0.1