Author: [log in to unmask] Date: Mon Jan 5 15:20:14 2015 New Revision: 1872 Log: Remove old EcalConditions class. Removed: java/trunk/conditions/src/main/java/org/hps/conditions/deprecated/EcalConditions.java Modified: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalWindowPlots.java java/trunk/users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java Modified: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalWindowPlots.java ============================================================================= --- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalWindowPlots.java (original) +++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalWindowPlots.java Mon Jan 5 15:20:14 2015 @@ -11,7 +11,11 @@ import javax.swing.JComboBox; import javax.swing.JLabel; -import org.hps.conditions.deprecated.EcalConditions; +import org.hps.conditions.database.DatabaseConditionsManager; +import org.hps.conditions.ecal.EcalChannel; +import org.hps.conditions.ecal.EcalConditions; +import org.hps.conditions.ecal.EcalConditionsUtil; +import org.lcsim.detector.identifier.IIdentifierHelper; import org.lcsim.event.EventHeader; import org.lcsim.event.RawTrackerHit; import org.lcsim.geometry.Detector; @@ -38,6 +42,9 @@ private boolean testSlot = false; private boolean testChannel = false; private int plotCrate, plotSlot, plotChannel; + private EcalConditions conditions; + private EcalConditionsUtil util; + private IIdentifierHelper helper; public EcalWindowPlots() { int count = 0; @@ -76,6 +83,11 @@ if (inputCollection == null) { throw new RuntimeException("The inputCollection parameter was not set."); } + + DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); + this.conditions = manager.getCachedConditions(EcalConditions.class, "ecal_conditions").getCachedData(); + this.util = new EcalConditionsUtil(conditions); + this.helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper(); setupPlots(); } @@ -127,13 +139,15 @@ @Override public void process(EventHeader event) { - if (event.hasCollection(RawTrackerHit.class, inputCollection)) { + if (event.hasCollection(RawTrackerHit.class, inputCollection)) { List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollection); for (RawTrackerHit hit : hits) { - Long daqId = EcalConditions.physicalToDaqID(hit.getCellID()); - int crate = EcalConditions.getCrate(daqId); - int slot = EcalConditions.getSlot(daqId); - int channel = EcalConditions.getChannel(daqId); + + EcalChannel ecalChannel = util.findChannel(helper, hit.getCellID()); + int crate = ecalChannel.getCrate(); + int slot = ecalChannel.getSlot(); + int channelNumber = ecalChannel.getChannel(); + //System.out.println("got hit: crate " + crate + ", slot " + slot + ", channel " + channel); if (hit.getADCValues().length != window) { throw new RuntimeException("Hit has unexpected window length " + hit.getADCValues().length + ", not " + window); @@ -144,7 +158,7 @@ if (testSlot && slot != plotSlot) { continue; } - if (testChannel && channel != plotChannel) { + if (testChannel && channelNumber != plotChannel) { continue; } windowPlot.reset(); Modified: java/trunk/users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java ============================================================================= --- java/trunk/users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java (original) +++ java/trunk/users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java Mon Jan 5 15:20:14 2015 @@ -1,131 +1,125 @@ package org.hps.users.celentan; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.PrintWriter; import java.util.List; -import org.hps.conditions.deprecated.EcalConditions; +import org.hps.conditions.database.DatabaseConditionsManager; +import org.hps.conditions.ecal.EcalChannel; +import org.hps.conditions.ecal.EcalChannel.GeometryId; +import org.hps.conditions.ecal.EcalConditions; import org.hps.recon.ecal.ECalUtils; -import org.lcsim.event.CalorimeterHit; +import org.lcsim.detector.identifier.IIdentifierHelper; import org.lcsim.event.EventHeader; -import org.lcsim.event.GenericObject; -import org.lcsim.event.RawCalorimeterHit; import org.lcsim.event.RawTrackerHit; import org.lcsim.geometry.Detector; -import org.lcsim.lcio.LCIOConstants; import org.lcsim.util.Driver; -import java.io.PrintWriter; -import java.io.FileNotFoundException; -import java.io.IOException; +public class RawPedestalComputator extends Driver { -public class RawPedestalComputator extends Driver{ - - String inputCollectionRaw = "EcalReadoutHits"; - int row,column; - - int[] windowRaw=new int[47*11];//in case we have the raw waveform, this is the window lenght (in samples) - boolean[] isFirstRaw=new boolean[47*11]; - - double[] pedestal=new double[47*11]; - double[] noise=new double[47*11]; - double[] result; - - int pedSamples=50; - int nEvents=0; - @Override - public void detectorChanged(Detector detector) { - System.out.println("Pedestal computator: detector changed"); - for (int ii=0;ii<11*47;ii++){ - isFirstRaw[ii]=true; - pedestal[ii]=0; - noise[ii]=0; - } - } - + String inputCollectionRaw = "EcalReadoutHits"; + int row, column; - @Override - public void process(EventHeader event) { - int ii=0; - if (event.hasCollection(RawTrackerHit.class, inputCollectionRaw)){ - List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollectionRaw); - for (RawTrackerHit hit : hits) { - row=hit.getIdentifierFieldValue("iy"); - column=hit.getIdentifierFieldValue("ix"); - ii = ECalUtils.getHistoIDFromRowColumn(row,column); - if ((row!=0)&&(column!=0)){ - if (!ECalUtils.isInHole(row,column)){ - if (isFirstRaw[ii]){ //at the very first hit we read for this channel, we need to read the window length and save it - isFirstRaw[ii]=false; - windowRaw[ii]=hit.getADCValues().length; - } - result=ECalUtils.computeAmplitude(hit.getADCValues(),windowRaw[ii],pedSamples); - pedestal[ii]+=result[1]; - noise[ii]+=result[2]; - } - } - } - } - nEvents++; - } - - @Override - public void endOfData() { - try{ - PrintWriter writerTop = new PrintWriter("default01.ped","UTF-8"); - PrintWriter writerBottom = new PrintWriter("default02.ped","UTF-8"); - - for (int ii=0;ii<11*47;ii++){ - int row,column; - row=ECalUtils.getRowFromHistoID(ii); - column=ECalUtils.getColumnFromHistoID(ii); - if (ECalUtils.isInHole(row,column)) continue; - if ((row==0)||(column==0)) continue; - pedestal[ii]/=nEvents; - noise[ii]/=nEvents; + int[] windowRaw = new int[47 * 11];// in case we have the raw waveform, this is the window lenght (in samples) + boolean[] isFirstRaw = new boolean[47 * 11]; - long daqID=EcalConditions.physicalToDaqID(EcalConditions.makePhysicalID(column,row)); - - int crate=EcalConditions.getCrate(daqID); - int slot=EcalConditions.getSlot(daqID); - int channel=EcalConditions.getChannel(daqID); + double[] pedestal = new double[47 * 11]; + double[] noise = new double[47 * 11]; + double[] result; - System.out.println(column+" "+row+" "+crate+" "+slot+" "+channel+" "+pedestal[ii]+" "+noise[ii]); - - - - if (crate==37){ - writerTop.print(slot+" "+channel+" "+(int)(Math.round(pedestal[ii]))+" "+(int)(Math.round(noise[ii]))+"\r\n"); - } - else if (crate==39){ - writerBottom.print(slot+" "+channel+" "+(int)(Math.round(pedestal[ii]))+" "+(int)(Math.round(noise[ii]))+"\r\n"); - } - - } + int pedSamples = 50; + int nEvents = 0; - writerTop.close(); - writerBottom.close(); - } - catch(FileNotFoundException fnfe) - { + private EcalConditions conditions; + private IIdentifierHelper helper; + private int systemId; - System.out.println(fnfe.getMessage()); + @Override + public void detectorChanged(Detector detector) { - } + DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); + this.conditions = manager.getCachedConditions(EcalConditions.class, "ecal_conditions").getCachedData(); + this.helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper(); + this.systemId = detector.getSubdetector("Ecal").getSystemID(); - catch(IOException ioe) - { + System.out.println("Pedestal computator: detector changed"); + for (int ii = 0; ii < 11 * 47; ii++) { + isFirstRaw[ii] = true; + pedestal[ii] = 0; + noise[ii] = 0; + } + } - System.out.println(ioe.getMessage()); + @Override + public void process(EventHeader event) { + int ii = 0; + if (event.hasCollection(RawTrackerHit.class, inputCollectionRaw)) { + List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollectionRaw); + for (RawTrackerHit hit : hits) { + row = hit.getIdentifierFieldValue("iy"); + column = hit.getIdentifierFieldValue("ix"); + ii = ECalUtils.getHistoIDFromRowColumn(row, column); + if ((row != 0) && (column != 0)) { + if (!ECalUtils.isInHole(row, column)) { + if (isFirstRaw[ii]) { // at the very first hit we read for this channel, we need to read the window length and save it + isFirstRaw[ii] = false; + windowRaw[ii] = hit.getADCValues().length; + } + result = ECalUtils.computeAmplitude(hit.getADCValues(), windowRaw[ii], pedSamples); + pedestal[ii] += result[1]; + noise[ii] += result[2]; + } + } + } + } + nEvents++; + } - } - } + @Override + public void endOfData() { + try { + PrintWriter writerTop = new PrintWriter("default01.ped", "UTF-8"); + PrintWriter writerBottom = new PrintWriter("default02.ped", "UTF-8"); + + for (int ii = 0; ii < 11 * 47; ii++) { + int row, column; + row = ECalUtils.getRowFromHistoID(ii); + column = ECalUtils.getColumnFromHistoID(ii); + if (ECalUtils.isInHole(row, column)) + continue; + if ((row == 0) || (column == 0)) + continue; + pedestal[ii] /= nEvents; + noise[ii] /= nEvents; + + EcalChannel ecalChannel = conditions.getChannelCollection().findChannel(new GeometryId(helper, new int[] {systemId, column, row})); + int crate = ecalChannel.getCrate(); + int slot = ecalChannel.getSlot(); + int channel = ecalChannel.getChannel(); + + System.out.println(column + " " + row + " " + crate + " " + slot + " " + channel + " " + pedestal[ii] + " " + noise[ii]); + + if (crate == 37) { + writerTop.print(slot + " " + channel + " " + (int) (Math.round(pedestal[ii])) + " " + (int) (Math.round(noise[ii])) + "\r\n"); + } else if (crate == 39) { + writerBottom.print(slot + " " + channel + " " + (int) (Math.round(pedestal[ii])) + " " + (int) (Math.round(noise[ii])) + "\r\n"); + } + + } + + writerTop.close(); + writerBottom.close(); + } catch (FileNotFoundException fnfe) { + + System.out.println(fnfe.getMessage()); + + } + + catch (IOException ioe) { + + System.out.println(ioe.getMessage()); + + } + } } - - - - - - - - - -