java/branches/ecal-recon_HPSJAVA-93/src/main/java/org/hps/recon/ecal
--- java/branches/ecal-recon_HPSJAVA-93/src/main/java/org/hps/recon/ecal/EcalTriggerFilterDriver.java 2014-05-26 12:23:44 UTC (rev 636)
+++ java/branches/ecal-recon_HPSJAVA-93/src/main/java/org/hps/recon/ecal/EcalTriggerFilterDriver.java 2014-05-26 12:47:55 UTC (rev 637)
@@ -7,6 +7,8 @@
import org.hps.conditions.ConditionsDriver;
import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalChannel.DaqId;
import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
import org.hps.conditions.ecal.EcalChannel.GeometryId;
import org.hps.conditions.ecal.EcalChannelConstants;
@@ -113,13 +115,19 @@
}
}
+ /**
+ * This method takes input hits and makes new hits with different ix
+ * @param CalorimeterHit hit
+ * @return new HPSCalorimeterHit
+ */
private CalorimeterHit filterHit(CalorimeterHit hit) {
int ix = hit.getIdentifierFieldValue("ix");
int iy = hit.getIdentifierFieldValue("iy");
int crate = getCrate(hit.getCellID());
int slot = getSlot(hit.getCellID());
- int delay = iy>0?topDelay:bottomDelay;
+ int delay = iy>0?topDelay:bottomDelay;
+
// no triggers from crate 1, slot 3
if (crate == 1 && slot == 3) {
return null;
@@ -129,9 +137,10 @@
if (ix > 0 && iy > 0) {
ix = 24 - ix;
}
- // long newID = EcalConditions.makePhysicalID(ix, iy);
- long newID = hit.getCellID(); //TODO
+ // Creating the new channel from cell id, ix and iy, then reading its ID
+ long newID = getID(hit.getCellID(),ix,iy);
+
//make new hit; set position to null so it gets recalculated
return new HPSCalorimeterHit(hit.getRawEnergy(), hit.getTime()+delay*4, newID, hit.getType());
}
@@ -160,6 +169,28 @@
// Find the ECAL channel and return the crate number.
return util.getSlot(helper, cellID);
}
+
+ /**
+ * Return the identity of a channel based on x and y coordinates of the crystal/channel, cellID is needed to create the IIdentifier
+ * @param cellID (long), ix position (int), iy position (int)
+ * @return ID of the channel/crystal (long)
+ */
+ private long getID(long cellID, int ix, int iy){
+ // Make an ID object from raw hit ID.
+ IIdentifier id = new Identifier(cellID);
+
+ // Get physical field values.
+ int system = helper.getValue(id, "system");
+
+ // Create an ID to search for in channel collection.
+ GeometryId geometryId = new GeometryId(helper, new int[] { system, ix, iy });
+
+ EcalChannel channel = channels.findChannel(geometryId);
+
+ long newID = channel.getChannelId();
+
+ return newID;
+ }
}