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

HPS-SVN June 2015

Subject:

r3209 - /java/trunk/users/src/main/java/org/hps/users/luca/FeeCalibHistCreator.java

From:

[log in to unmask]

Reply-To:

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

Date:

Tue, 30 Jun 2015 14:27:25 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (185 lines)

Author: [log in to unmask]
Date: Tue Jun 30 07:27:14 2015
New Revision: 3209

Log:
committing driver

Modified:
    java/trunk/users/src/main/java/org/hps/users/luca/FeeCalibHistCreator.java

Modified: java/trunk/users/src/main/java/org/hps/users/luca/FeeCalibHistCreator.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/luca/FeeCalibHistCreator.java	(original)
+++ java/trunk/users/src/main/java/org/hps/users/luca/FeeCalibHistCreator.java	Tue Jun 30 07:27:14 2015
@@ -5,16 +5,26 @@
  */
 package org.hps.users.luca;
 import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
+import java.io.FileWriter;
+import java.io.IOException;
 
 import java.util.ArrayList;
 import java.util.List;
+import org.hps.conditions.database.DatabaseConditionsManager;
+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.recon.ecal.triggerbank.AbstractIntData;
+import org.hps.recon.ecal.triggerbank.TIData;
 import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.Cluster;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
+import org.lcsim.geometry.Detector;
 import org.lcsim.geometry.Subdetector;
 import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
@@ -24,10 +34,13 @@
  */
 public class FeeCalibHistCreator extends Driver {
     
-double energyThreshold=0;
-    protected String clusterCollectionName = "EcalClustersGTP";
+    double energyThreshold=0.5;
+    protected String clusterCollectionName = "GTPEcalClusters";
+    //create the writer to write the gains on txt
+    private FileWriter writer;
+    String outputFileName = "gains.txt";
     
-    
+    //things you need to get the gains
     private EcalConditions ecalConditions = null;
     final private String ecalName = "Ecal";
     private Subdetector ecal;
@@ -36,35 +49,50 @@
     
     //Declaration of histograms array
     AIDA aida = AIDA.defaultInstance();
-    ArrayList<IHistogram1D> GTPHists = new ArrayList<IHistogram1D>(442);
-    ArrayList<IHistogram1D> GTPSeedHists = new ArrayList<IHistogram1D>(442);
+    ArrayList<IHistogram2D> GTPHists = new ArrayList<IHistogram2D>(442);
+   
     
     
     public void setEnergyThreshold (double threshold){
     this.energyThreshold=threshold;
        }
   
+  public void setOutputFileName(String outputFileName){
+  this.outputFileName = outputFileName+".txt";
+  }
   
-  
-  
+  @Override
+    public void detectorChanged(Detector detector) {
+        // Get the Subdetector.
+        ecal = detector.getSubdetector(ecalName);
+        
+      /*  // ECAL combined conditions object.
+        ecalConditions = ConditionsManager.defaultInstance()
+                .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();*/
+                       
+        ecalConditions = DatabaseConditionsManager.getInstance().getEcalConditions();
+         channels = ecalConditions.getChannelCollection();
+    }  
 
    @Override   
 public void startOfData(){
    //initialize histograms  
       for(int t=0; t<442; t++){
       String cristallo=String.valueOf(t+1);  
-      String GTPhistName="GTP Cluster Energy(Run)" + cristallo;
-      String GTPSeedHistName="GTP Seed Energy(Run)"+ cristallo;
-      
-      
-      IHistogram1D GTPseedhisto=aida.histogram1D(GTPSeedHistName, 200, 0.0,2.5);
-      IHistogram1D GTPclushisto=aida.histogram1D(GTPhistName, 200, 0.0,2.5);
-     
+      String GTPhistName="GTPCluster-Seeds Energy " + cristallo;
+      IHistogram2D GTPclushisto=aida.histogram2D(GTPhistName, 150, 0.0,1.5,150,0.0,1.5);
       GTPHists.add(GTPclushisto);
-      GTPSeedHists.add(GTPseedhisto);
-   
       }
-    
+   //initialize writer
+      try{
+         //initialize the writers
+         writer=new FileWriter(outputFileName);
+         //Clear the files
+         writer.write("");
+      }
+      catch(IOException e ){
+      System.err.println("Error initializing output file for gains.");
+      }
     
 }
 
@@ -72,10 +100,36 @@
 
     @Override
     public void endOfData(){
- 
+    
+        for(int t=0;t<442;t++){
+      int id =t+1;
+      try{  writer.append(id + " " + gain[t] + "\n");}
+      catch(IOException e){
+      System.err.println("Error closing output file.");}
+      }
+      //close the file writer.  
+      try{
+      writer.close();
+      }
+      catch(IOException e){
+      System.err.println("Error closing utput file.");
+      }
 } 
     @Override
     public void process (EventHeader event){
+        
+          if (event.hasCollection(GenericObject.class, "TriggerBank")) {
+            List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank");
+            for (GenericObject data : triggerList)
+                if (AbstractIntData.getTag(data) == TIData.BANK_TAG) {
+                    TIData triggerData = new TIData(data);
+                    if (!triggerData.isSingle1Trigger())//only process singles0 triggers...
+
+                        return;
+                }
+        } else //if (debug)
+            System.out.println(this.getClass().getSimpleName() + ":  No trigger bank found...running over all trigger types");
+  
         
         //here it writes the GTP clusters info
         if(event.hasCollection(Cluster.class,"EcalClustersGTP"))
@@ -85,15 +139,19 @@
            
            
            idBack=getDBID(cluster);
-           
+           EcalChannel channel = channels.findGeometric(cluster.getCalorimeterHits().get(0).getCellID());
+           EcalChannelConstants channelConstants = ecalConditions.getChannelConstants(channel);
+           gain[idBack-1]=channelConstants.getGain().getGain();
            
            //riempio gli istogrammi
            if(cluster.getEnergy()>energyThreshold){
-           GTPHists.get(idBack -1).fill(cluster.getEnergy());
-           GTPSeedHists.get(idBack-1).fill(cluster.getCalorimeterHits().get(0).getCorrectedEnergy());
+           GTPHists.get(idBack -1).fill(cluster.getEnergy(),cluster.getCalorimeterHits().get(0).getCorrectedEnergy());
+          
+           //System.out.println("Clu = " + cluster.getEnergy() + " Seed = " + cluster.getCalorimeterHits().get(0).getCorrectedEnergy() + "\n");
            }         
          }
         }
+       
        
     }
     

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