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  March 2015

HPS-SVN March 2015

Subject:

r2590 - /java/trunk/users/src/main/java/org/hps/users/luca/ratetest.java

From:

[log in to unmask]

Reply-To:

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

Date:

Fri, 27 Mar 2015 11:02:28 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (411 lines)

Author: [log in to unmask]
Date: Fri Mar 27 04:02:23 2015
New Revision: 2590

Log: (empty)

Added:
    java/trunk/users/src/main/java/org/hps/users/luca/ratetest.java

Added: java/trunk/users/src/main/java/org/hps/users/luca/ratetest.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/luca/ratetest.java	(added)
+++ java/trunk/users/src/main/java/org/hps/users/luca/ratetest.java	Fri Mar 27 04:02:23 2015
@@ -0,0 +1,396 @@
+/*
+ * 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 hep.aida.IHistogram2D;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Scanner;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.hps.conditions.database.TableConstants;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalChannelConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.hps.readout.ecal.FADCEcalReadoutDriver;
+import org.hps.readout.ecal.RingBuffer;
+import org.hps.recon.ecal.cluster.ClusterUtilities;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.Subdetector;
+import org.lcsim.geometry.subdetector.HPSEcal3;
+import org.lcsim.util.aida.AIDA;
+/**
+ *
+ * @author Luca
+ */
+public class ratetest extends Driver {
+    
+    private FileWriter writer;
+    String outputFileName = "ratetest.txt";
+    
+    private EcalConditions ecalConditions = null;
+    final private String ecalName = "Ecal";
+    private Subdetector ecal;
+    private EcalChannelCollection channels= null;
+    AIDA aida = AIDA.defaultInstance();
+    ArrayList<IHistogram1D> Top = new ArrayList<IHistogram1D>(6);
+    ArrayList<IHistogram1D> Bot = new ArrayList<IHistogram1D>(6);
+    ArrayList<IHistogram1D> TopNoCut = new ArrayList<IHistogram1D>(6);
+    ArrayList<IHistogram1D> BotNoCut = new ArrayList<IHistogram1D>(6);
+    ArrayList<IHistogram2D> TopCry=new ArrayList<IHistogram2D>(6);
+    ArrayList<IHistogram2D> BotCry=new ArrayList<IHistogram2D>(6);
+    ArrayList<IHistogram2D> CryTop=new ArrayList<IHistogram2D>(5);
+    ArrayList<IHistogram2D> CryBot=new ArrayList<IHistogram2D>(5);
+    ArrayList<IHistogram1D> TopCryEne = new ArrayList<IHistogram1D>(5);
+    ArrayList<IHistogram1D> BotCryEne = new ArrayList<IHistogram1D>(5);
+    
+    IHistogram1D clusTot=aida.histogram1D("ALL", 200,0,2.5 );
+    
+    IHistogram1D CryId=aida.histogram1D("cry Id",446,1,447);
+    double[] timei=new double[6];
+    double timef=0;
+    double counterTop=0;
+    double counterBot=0;
+    double counterEcut=0;
+    
+    double nevents=0;
+    
+double[] time=new double[6];
+double E0=1.92;
+double[] Ymax={45.91,52.95,60.00,67.01,74.04,81.18};
+double[] Ymin={38.83,45.81,52.95,60.00,67.01,74.04};
+double[] Xmax={-23.59,-23.1,-22.61,-22.11,-21.62,-21.13};
+double[] Xmin={-30.1,-30.59,-31.08,-31.58,-32.07,-32.57};
+
+int[] countertop=new int[6];
+int[] counterbot=new int[6];
+int[]crycountertop=new int[5];
+int[]crycounterbot=new int[5];
+
+double[] vertpos=new double[5];
+
+//e cuts 3430
+/*
+double[] ecuttopmin={1.4,1.5,1.55,1.6,1.65,1.65};
+double[] ecuttopmax={1.8,1.85,1.9,1.95,2,2};
+
+double[] ecutbotmin= {1.45,1.5,1.5,1.6,1.6,1.6};
+double[] ecutbotmax={1.75,1.85,1.9,2,2,2};
+
+
+double[] cryecuttopmin={1.38,1.38,1.52,1.6,1.6};
+double[] cryecuttopmax={1.8,1.8,1.8,2,2};
+
+double[] cryecutbotmax={2,2,1.9,1.9,2};
+double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55};
+*/
+//e cuts 3434
+/*
+double[] ecuttopmin={1.25,1.45,1.5,1.5,1.65,1.63};
+double[] ecuttopmax={1.55,1.8,1.9,1.95,2,2};
+
+double[] ecutbotmin= {1.27,1.32,1.37,1.52,1.6,1.6};
+double[] ecutbotmax={1.7,1.8,1.77,1.9,2,2};
+
+
+double[] cryecuttopmin={1.38,1.38,1.52,1.6,1.6};
+double[] cryecuttopmax={1.8,1.8,1.8,2,2};
+
+double[] cryecutbotmax={2,2,1.9,1.9,2};
+double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55}; 
+*/
+//e cuts 3435 
+
+double[] ecuttopmin={1.3,1.35,1.45,1.50,1.60,1.60};
+double[] ecuttopmax={1.6,1.80,1.90,1.95,2.00,2.00};
+
+double[] ecutbotmin= {1.27,1.3,1.3,1.5,1.6,1.6};
+double[] ecutbotmax={1.7,1.8,1.8,2,2,2};
+
+
+double[] cryecuttopmin={1.38,1.38,1.52,1.6,1.6};
+double[] cryecuttopmax={1.8,1.8,1.8,2,2};
+
+double[] cryecutbotmax={2,2,1.9,1.9,2};
+double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55};
+
+
+double vertical;
+
+
+
+public void setOutputFileName(String outputFileName){
+this.outputFileName = outputFileName;
+}
+
+@Override
+public void startOfData(){
+ //inizializzo il file di uscita
+   try{
+    //initialize the writers
+    writer=new FileWriter(outputFileName);
+    writer.write("");
+   }
+    catch(IOException e ){
+    System.err.println("Error initializing output file for event display.");
+    } 
+    
+    
+//inizializzo istogrammi
+     for(int t=0;t<5;t++){
+     String bin=String.valueOf(t+1);  
+     String crytopname="FEE in Crystal " + bin;
+     String topcryenename="CLu ene in crystal " + bin;
+     
+     String bin2=String.valueOf(-(t+1));
+     String crybotname="FEE in Crystal " + bin2;
+     String botcryenename="CLu ene in crystal " + bin2;
+     IHistogram2D crytophist=aida.histogram2D(crytopname,46,-24,25,10,-5,5 );
+     IHistogram2D crybothist=aida.histogram2D(crybotname,46,-24,25,10,-5,5 );
+     IHistogram1D Topcryenehist=aida.histogram1D(topcryenename, 250, 0.0,2.5);
+     IHistogram1D botcryenehist=aida.histogram1D(botcryenename,250,0.0,2.5);
+     TopCryEne.add(Topcryenehist);
+     BotCryEne.add(botcryenehist);
+     CryTop.add(crytophist);
+     CryBot.add(crybothist);
+     crycountertop[t]=0;
+     crycounterbot[t]=0;
+     }
+    
+    
+      for(int t=0; t<6; t++){
+      String bin=String.valueOf(t+1);  
+      String top="(TOP) FEE in Bin in " + bin;
+      String bot="(BOT) FEE in Bin in "+ bin;
+      String tope="(TOP) Cluster Energy in Bin " + bin;
+      String bote="(BOT) Cluster Energy in Bin "+ bin;
+      String topcryname="(TOP) Crystals in Bin " + bin;
+      String botcryname="(BOT) Crystals in Bin " + bin;
+      
+      
+      
+      IHistogram1D Toppe=aida.histogram1D(top, 250, 0.0,2.5);
+      IHistogram1D Botte=aida.histogram1D(bot, 250, 0.0,2.5);
+      IHistogram1D TopNoCute=aida.histogram1D(tope, 250, 0.0,2.5);
+      IHistogram1D BotNoCute=aida.histogram1D(bote, 250, 0.0,2.5);
+      IHistogram2D topcryhist=aida.histogram2D(topcryname,46,-24,25,11,-5,6 );
+      IHistogram2D botcryhist=aida.histogram2D(botcryname,46,-24,25,11,-5,6 );
+      
+ 
+      Top.add(Toppe);
+      Bot.add(Botte);
+      TopNoCut.add(TopNoCute);
+      BotNoCut.add(BotNoCute);
+      TopCry.add(topcryhist);
+      BotCry.add(botcryhist);
+      }
+    
+    
+    
+for (int i =0;i<6;i++){
+    time[i]=0;
+    timei[i]=0;
+    
+    countertop[i]=0;
+    counterbot[i]=0;
+    
+}
+
+
+}
+
+
+@Override
+public void endOfData(){
+double timme=(timef-timei[0])/1000000000;
+
+//for(int i=0;i<6;i++){System.out.println(i + " " + time[i] + "\n");}
+
+try{
+writer.append("Total event in file " + nevents + " Total time = "+ timme  +"\n");
+writer.append("TOP \n");
+for(int i=0;i<6;i++){
+ int bin=i+1;   
+ time[i]=timef-timei[i];   
+writer.append("Bin " + bin + " Total event  " + countertop[i] + " Rate = " + (countertop[i]/time[i])*1000000000 + "\n" );
+}
+
+
+for(int i=0;i<6;i++){
+ int bin=i+1;   
+ time[i]=timef-timei[i];   
+writer.append("Bin " + bin +" Total event BOT " + counterbot[i] + " Rate = " + (counterbot[i]/time[i])*1000000000 + "\n" );
+}
+
+writer.append("\n \n \n");
+for(int t=0;t<5;t++){
+writer.append("events in row  " + t + " = " + crycountertop[t]+ " Rate = " + (crycountertop[t]/timme) + "\n" );
+int menot=-t;
+writer.append("events in row  " + menot + " = " + crycounterbot[t]+ " Rate = " + (crycounterbot[t]/timme) + "\n" );
+}
+writer.append("\n verticale = " + vertical +"\n");
+
+}
+
+
+catch(IOException e)
+    {
+    System.err.println("Non ho scritto sul file");
+    }
+
+System.out.println("vertical =  " + vertical + "\n");
+/*vertical=vertical-6.5;
+for(int i=0;i<7;i++)
+{double theta=Math.atan2( (vertical+i*13),1397);
+System.out.println("theta = " + theta + "\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){
+        
+     timef=event.getTimeStamp();
+     
+     nevents++;
+     
+     for(int i=0;i<6;i++){
+    if(countertop[i]==0){timei[i]=timef;}}
+        
+    if(event.hasCollection(Cluster.class,"EcalClusters")){
+        
+        
+        List<Cluster> clusters= event.get(Cluster.class,"EcalClusters");
+        
+         for(Cluster cluster : clusters){
+         
+             
+          int ID=getDBID(cluster);   
+         clusTot.fill(cluster.getEnergy());
+         double posY=cluster.getPosition()[1];
+         double posX=cluster.getPosition()[0];
+         double cryx=cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix");
+         double cryy=cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy");
+         
+         //if(cryy==1){verpos[0]=posY;}
+         //da qui righe e colonne
+        if(cryx==-5||cryx==-6){
+            
+            for(int i=0;i<5;i++){
+                //top
+                if(cryy==i+1){
+                 if(cluster.getEnergy()>cryecuttopmin[i]&&cluster.getEnergy()<cryecuttopmax[i]){
+                     CryTop.get(i).fill(cryx, cryy);
+                     TopCryEne.get(i).fill(cluster.getEnergy());
+                     crycountertop[i]++;
+                    }
+                }
+           
+               //bottom
+                if(cryy==-(i+1)){
+                    if(cluster.getEnergy()>cryecutbotmin[i] && cluster.getEnergy()<cryecutbotmax[i]){
+                    CryBot.get(i).fill(cryx, cryy);
+                    BotCryEne.get(i).fill(cluster.getEnergy());
+                    crycounterbot[i]++;
+                    }
+                }
+            }
+        } 
+        
+        
+        ///da qui bin angolari 
+         
+         for(int i=0;i<6;i++){
+             //top
+             if(posY>Ymin[i]&&posY<=Ymax[i]){
+                if(posX<=Xmax[i] &&posX>=Xmin[i]){      
+                    TopNoCut.get(i).fill(cluster.getEnergy());
+                    if(cluster.getEnergy()>ecuttopmin[i]&&cluster.getEnergy()<ecuttopmax[i]){
+                        Top.get(i).fill(cluster.getEnergy());
+                        countertop[i]++;
+                        CryId.fill(ID);
+                        TopCry.get(i).fill(cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix"), cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy"));
+                    }//tagli energia
+                } //if su X
+             }//if pos y   
+            //controllo down                 
+            if(posY< -Ymin[i]&& posY> -Ymax[i]){
+                if(posX<Xmax[i] &&posX>Xmin[i]){
+                    BotNoCut.get(i).fill(cluster.getEnergy());
+                    if(cluster.getEnergy()>ecutbotmin[i]&&cluster.getEnergy()<ecutbotmax[i]){
+                        Bot.get(i).fill(cluster.getEnergy());
+                        counterbot[i]++;
+                        BotCry.get(i).fill(cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix"), cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy"));
+                        CryId.fill(ID);
+                    }//e cut bot  
+                } //xpos    
+         }// ypos bot
+        }//for sui bin
+       
+    }//end of for over clusters
+    }   //and of if has colelction  
+    }//end pf process
+    
+    
+    
+    
+    public int getDBID ( Cluster cluster ){
+    int xx=  cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix");
+    int yy=cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy");
+    int XOFFSET=23;
+    int YOFFSET=5;
+    int ix = xx<0 ? xx+XOFFSET : xx+XOFFSET-1;
+    int iy = yy<0 ? yy+YOFFSET : yy+YOFFSET-1;
+    int dbid = ix + 2*XOFFSET*(YOFFSET*2-iy-1) + 1;
+    if      (yy ==  1 && xx>-10){ dbid-=9;}
+    else if (yy == -1 && xx<-10) {dbid-=9;}
+    else if (yy < 0){dbid-=18;}
+   return dbid;
+}
+  
+public int getDBID ( CalorimeterHit hit ){
+    int xx=  hit.getIdentifierFieldValue("ix");
+    int yy=  hit.getIdentifierFieldValue("iy");
+    int XOFFSET=23;
+    int YOFFSET=5;
+    int ix = xx<0 ? xx+XOFFSET : xx+XOFFSET-1;
+    int iy = yy<0 ? yy+YOFFSET : yy+YOFFSET-1;
+    int dbid = ix + 2*XOFFSET*(YOFFSET*2-iy-1) + 1;
+    if      (yy ==  1 && xx>-10){ dbid-=9;}
+    else if (yy == -1 && xx<-10) {dbid-=9;}
+    else if (yy < 0){dbid-=18;}
+   return dbid;
+}  
+    
+}

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