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");
}
}
}
+
}
|