lcsim/src/org/lcsim/recon/cluster/density
diff -u -r1.1 -r1.2
--- LoadMyCalorimeterHit.java 12 Aug 2005 19:59:49 -0000 1.1
+++ LoadMyCalorimeterHit.java 27 Sep 2005 20:46:19 -0000 1.2
@@ -4,127 +4,83 @@
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
-
import org.lcsim.util.aida.AIDA;
import org.lcsim.util.Driver;
import org.lcsim.event.EventHeader;
import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.event.CalorimeterHit;
import org.lcsim.geometry.segmentation.SegmentationBase;
import org.lcsim.geometry.compact.Readout;
+import org.lcsim.geometry.Subdetector;
public class LoadMyCalorimeterHit {
public static LoadMyCalorimeterHit getInstance(){
- if(_me==null){
+ if(_me==null) {
_me = new LoadMyCalorimeterHit();
}
return _me;
}
- public void process(EventHeader event){
- System.out.println("Running LoadMyCalorimeterHit.process");
- this.reset();
- _segmMap = event.getDetector().getReadouts();
+ private LoadMyCalorimeterHit() {
+ if(_me==null) _me=this;
+ _collMap = new HashMap<String,Map<Long,CalorimeterHit>>();
+ _densityMap = new HashMap<Long,Double>();
+ _subdet2collMap = new HashMap<Subdetector,Map<Long,CalorimeterHit>>();
_runPar = RunControlParameters.getInstance();
- _event = event;
}
- private LoadMyCalorimeterHit(){
- if(_me==null) _me=this;
- _collMap = new HashMap<String,Map<Long,MyCalorimeterHit>>();
- _myEMhits = new HashMap<Long,MyCalorimeterHit>();
- _myHDhits = new HashMap<Long,MyCalorimeterHit>();
+ public void process(EventHeader event){
+ if( event != _event ) {
+ this.reset();
+ _segmMap = event.getDetector().getReadouts();
+ _event = event;
+ }
}
public void reset(){
- System.out.println("reset: EM="+_myEMhits.size()+", HD="+_myHDhits.size());
- _myEMhits.clear();
- _myHDhits.clear();
- System.out.println("reset: EM="+_myEMhits.size()+", HD="+_myHDhits.size());
- // Loop over all existing hit collections
- for( String key : _collMap.keySet() ) {
- // clear hit maps for each subdetector collection
- Map<Long,MyCalorimeterHit> subDetHitMap = _collMap.get(key);
- System.out.println("reset: key="+key+", size="+subDetHitMap.size());
- subDetHitMap.clear();
- System.out.println("reset: key="+key+", size="+subDetHitMap.size());
- }
- System.out.println("reset: #colls="+_collMap.size());
- _collMap.clear();
- System.out.println("reset: #colls="+_collMap.size());
+ // clear hit maps for each subdetector collection
+ for( Map<Long,CalorimeterHit> aHitMap : _collMap.values() ) {
+ aHitMap.clear();
+ }
+ _collMap.clear();
+ _subdet2collMap.clear();
+ _densityMap.clear();
+ _segmMap = null;
}
-// public Map<Long,MyCalorimeterHit> getEMHitMap(EventHeader event){
-// if(_myEMhits.size()==0){
-// List<SimCalorimeterHit> ecol = new ArrayList<SimCalorimeterHit>();
-// ecol.addAll( event.getSimCalorimeterHits("EcalBarrHits") );
-// ecol.addAll( event.getSimCalorimeterHits("EcalEndcapHits") );
-// System.out.println("getEMHitMap: sizes="
-// +event.getSimCalorimeterHits("EcalBarrHits").size()
-// +" "+event.getSimCalorimeterHits("EcalEndcapHits").size()
-// +", total="+ecol.size());
-// // System.out.println(ecol);
-// String calType = "EM";
-// fillHitMap(ecol,_myEMhits,calType);
-// }
-// return _myEMhits;
-// }
-
-// public Map<Long,MyCalorimeterHit> getHDHitMap(EventHeader event){
-// if(_myHDhits.size()==0){
-// List<SimCalorimeterHit> hcol = new ArrayList<SimCalorimeterHit>();
-// hcol.addAll( event.getSimCalorimeterHits("HcalBarrHits") );
-// hcol.addAll( event.getSimCalorimeterHits("HcalEndcapHits") );
-// System.out.println("getHDHitMap: sizes="
-// +event.getSimCalorimeterHits("HcalBarrHits").size()
-// +" "+event.getSimCalorimeterHits("HcalEndcapHits").size()
-// +", total="+hcol.size());
-
-// String calType = "HD";
-// fillHitMap(hcol,_myHDhits,calType);
-// }
-// return _myHDhits;
-// }
/**
- * Returns a CellID decoder
+ * Returns a hit map, with all hits contained in a given collection.
* @param colName name of collection with data to be returned
*/
- public final Map<Long,MyCalorimeterHit> getCollHitMap(final String colName) {
- Map<Long,MyCalorimeterHit> retColl = _collMap.get( colName );
+ public final Map<Long,CalorimeterHit> getCollHitMap(final String colName) {
+ Map<Long,CalorimeterHit> retColl = _collMap.get( colName );
if(retColl==null) {
- // if it does not exist, create it now
- retColl = new HashMap<Long,MyCalorimeterHit>();
- _collMap.put(colName, retColl);
+ // if it does not exist, create it now
+ retColl = new HashMap<Long,CalorimeterHit>();
+ _collMap.put(colName, retColl);
}
- assert retColl!=null : "retColl is empty for colName="+colName;
- String calType = "??";
- if( colName.contains("Ecal") ) calType = "EM";
- if( colName.contains("Hcal") ) calType = "HD";
- assert !calType.contains("??") : "Unknown calorimeter type.";
-
- System.out.println("getCollHitMap: name=<"+colName
- +">, size="+retColl.size()
- +", calType="+calType);
- if( retColl.size()==0 ) fillHitMap( colName, retColl, calType );
- System.out.println("getCollHitMap: name=<"+colName
- +">, size="+retColl.size());
+ assert retColl!=null :
+ "getCollHitMap: Could not create a new hitmap collection";
+
+ if( retColl.size()==0 ) fillHitMap( colName, retColl );
return retColl;
}
/**
- * Returns a hit map, with all hits contained in a given collection.
+ * Returns a CellID decoder
* @param colName name of collection with data to be returned
*/
public final SegmentationBase getSegmentation(final String colName) {
return (SegmentationBase)_segmMap.get(colName).getSegmentation();
}
+
public void fillHitMap(final String colName,
- Map<Long,MyCalorimeterHit> hitmap,
- String calType)
+ Map<Long,CalorimeterHit> hitmap )
{
- if(calType=="EM"){
+ if( colName.contains("Ecal") ) {
_weight = _runPar.getEMweight();
_mip = _runPar.getEMmip();
_thresh = _runPar.getEMthresh();
@@ -132,7 +88,7 @@
_nZ = _runPar.getZNeighEM();
_nPhi = _runPar.getPhiNeighEM();
}
- else {
+ else if( colName.contains("Hcal") ) {
_weight = _runPar.getHDweight();
_mip = _runPar.getHDmip();
_thresh = _runPar.getHDthresh();
@@ -140,131 +96,83 @@
_nZ = _runPar.getZNeighHD();
_nPhi = _runPar.getPhiNeighHD();
}
- /*
- _nLyr = _runPar.getLyrNeigh1();
- _nZ = _runPar.getZNeigh1();
- _nPhi = _runPar.getPhiNeigh1();
- */
+ else {
+ assert false : "loadMyCalHit.fillHitMap(): colName="+colName;
+ }
+ // Get hits, if they exist
+ List<SimCalorimeterHit> tmpHits = null;
try {
- List<SimCalorimeterHit> tmpHits= _event.getSimCalorimeterHits(colName);
- for( SimCalorimeterHit ihit : tmpHits ){
- double ene = _weight*(ihit.getRawEnergy());
- if(ene>_thresh*_mip){
- long cellid = ihit.getCellID();
- Long key = new Long(cellid);
- MyCalorimeterHit khit = new MyCalorimeterHit(ihit);
- hitmap.put(key,khit);
- }
- }
-
- for( MyCalorimeterHit khit : hitmap.values() ) {
- SimCalorimeterHit ihit = khit.getHit();
- long cellid = ihit.getCellID();
- // System.out.println("cell index (lyr,theta,phi)"+" "+MyTools.getCalLayer(cellid)+
- // " "+MyTools.getThetaBin(cellid)+" "+MyTools.getPhiBin(cellid));
-
- // int neigh[] = _cPar.getNeighbors(cellid,_nLyr,_nZ,_nPhi);
-
- SegmentationBase segm = (SegmentationBase)_segmMap.get(colName).getSegmentation();
- segm.setID(cellid);
-
- long neigh[] = segm.getNeighbourIDs(_nLyr,_nZ,_nPhi);
- System.out.println(" Density: id="+MyTools.printID(cellid)
- +", #neighbors="+neigh.length);
- double nNeigh = 0.0;
- for(int j=0;j<neigh.length;j++){
- long jid = neigh[j];
- // System.out.println("neigh index"+" "+MyTools.getCalLayer(jid)+" "+
- // MyTools.getThetaBin(jid)+" "+MyTools.getPhiBin(jid));
- Long jkey = new Long(jid);
- MyCalorimeterHit lhit = (MyCalorimeterHit) hitmap.get(jkey);
- if(lhit==null) continue;
- // System.out.println("not null");
-// jhit = lhit.getHit();
- nNeigh++;
- }
- khit.setDensity(0,nNeigh);
- khit.setDensity(1,0.0);
- AIDA.defaultInstance().cloud1D("density").fill(nNeigh);
- }
+ tmpHits = _event.getSimCalorimeterHits(colName);
}
catch(Exception e) {
- System.out.println(" Evt "+_event.getEventNumber()
- +": No data in collection "+colName);
- // This happens quite frequently, no data from this component
+ // This happens quite frequently, no data from this component
+ System.out.println(" Evt "+_event.getEventNumber()
+ +": No data in collection "+colName);
+ }
+ if(tmpHits==null) return;
+
+ // Fill a hit map from this collection
+ // fill also a subdetector -> hit collection map
+ Subdetector det = null;
+ for( SimCalorimeterHit ihit : tmpHits ) {
+ // Make sure all hits come from same subdetector
+ if(det==null) det=ihit.getSubdetector();
+ else assert det == ihit.getSubdetector()
+ : "LoadCalorimeterHit: multiple subdets in a collection";
+
+ double ene = _weight*(ihit.getRawEnergy());
+ if(ene>_thresh*_mip){
+ long cellid = ihit.getCellID();
+ Long key = new Long(cellid);
+ CalorimeterHit khit = new MyCalorimeterHit(ihit);
+ hitmap.put(key,khit);
+ }
+// else {
+// System.out.println("LoadMyCalhit: rejected hit="+ihit+", id="+MyTools.printID(ihit.getCellID()));
+// }
+ }
+ if(det!=null) _subdet2collMap.put( det, hitmap );
+
+ // assign densities to every hit
+ for( CalorimeterHit khit : hitmap.values() ) {
+ long cellid = khit.getCellID();
+
+ SegmentationBase segm = (SegmentationBase)_segmMap.get(colName).getSegmentation();
+ segm.setID(cellid);
+
+ long neigh[] = segm.getNeighbourIDs(_nLyr,_nZ,_nPhi);
+ double nNeigh = 1.0; // count hit itself + neighbors (never zero)
+ for(int j=0; j<neigh.length; ++j) {
+ long jid = neigh[j];
+ CalorimeterHit lhit = hitmap.get(jid);
+ if(lhit!=null) nNeigh++;
+ }
+
+ _densityMap.put(cellid,nNeigh);
+ ((MyCalorimeterHit)khit).setDensity(0, nNeigh);
+ AIDA.defaultInstance().cloud1D("density").fill(nNeigh);
}
}
- public void fillHitMap(final List<SimCalorimeterHit> col,
- Map<Long,MyCalorimeterHit> hitmap,
- String calType)
- {
- if(calType=="EM"){
- _weight = _runPar.getEMweight();
- _mip = _runPar.getEMmip();
- _thresh = _runPar.getEMthresh();
- _nLyr = _runPar.getLyrNeighEM();
- _nZ = _runPar.getZNeighEM();
- _nPhi = _runPar.getPhiNeighEM();
- }
- else {
- _weight = _runPar.getHDweight();
- _mip = _runPar.getHDmip();
- _thresh = _runPar.getHDthresh();
- _nLyr = _runPar.getLyrNeighHD();
- _nZ = _runPar.getZNeighHD();
- _nPhi = _runPar.getPhiNeighHD();
- }
- /*
- _nLyr = _runPar.getLyrNeigh1();
- _nZ = _runPar.getZNeigh1();
- _nPhi = _runPar.getPhiNeigh1();
- */
-
- // System.out.println(col.getNumberOfElements());
-// for(int i=0;i<col.size();i++){
-// ihit = (SimCalorimeterHit) col.getElementAt(i);
- for( SimCalorimeterHit ihit : col ){
- double ene = _weight*(ihit.getRawEnergy());
- if(ene>_thresh*_mip){
- long cellid = ihit.getCellID();
- Long key = new Long(cellid);
- MyCalorimeterHit khit = new MyCalorimeterHit(ihit);
- hitmap.put(key,khit);
- }
- }
- for( MyCalorimeterHit khit : hitmap.values() ) {
- SimCalorimeterHit ihit = khit.getHit();
- long cellid = ihit.getCellID();
- // System.out.println("cell index (lyr,theta,phi)"+" "+MyTools.getCalLayer(cellid)+
- // " "+MyTools.getThetaBin(cellid)+" "+MyTools.getPhiBin(cellid));
-
- // int neigh[] = _cPar.getNeighbors(cellid,_nLyr,_nZ,_nPhi);
-
- SegmentationBase segm = (SegmentationBase)_segmMap.get("EcalBarrHits").getSegmentation();
- segm.setID(cellid);
-
- long neigh[] = segm.getNeighbourIDs(_nLyr,_nZ,_nPhi);
- double nNeigh = 0.0;
- for(int j=0;j<neigh.length;j++){
- long jid = neigh[j];
- // System.out.println("neigh index"+" "+MyTools.getCalLayer(jid)+" "+
- // MyTools.getThetaBin(jid)+" "+MyTools.getPhiBin(jid));
- Long jkey = new Long(jid);
- MyCalorimeterHit lhit = (MyCalorimeterHit) hitmap.get(jkey);
- if(lhit==null) continue;
- // System.out.println("not null");
-// jhit = lhit.getHit();
- nNeigh++;
- }
- khit.setDensity(0,nNeigh);
- khit.setDensity(1,0.0);
- AIDA.defaultInstance().cloud1D("density").fill(nNeigh);
- }
+ double getDensity(final CalorimeterHit hit) {
+ if(hit==null) return 0.0;
+ try {
+ return _densityMap.get( hit.getCellID() );
+ }
+ catch(NullPointerException e) {
+ // Hits below threshold end up here, should return density=0
+ return 0.0;
+ }
+ }
+
+ double getDensity(long cellid) {
+ if(cellid==0) return 0.0;
+ return _densityMap.get( cellid );
}
+ //*** FIELDS ***
private static LoadMyCalorimeterHit _me = null;
/** Current event */
@@ -276,8 +184,8 @@
private int _nLyr;
private int _nZ;
private int _nPhi;
- private Map<String,Map<Long,MyCalorimeterHit>> _collMap;
- private Map<Long,MyCalorimeterHit> _myEMhits;
- private Map<Long,MyCalorimeterHit> _myHDhits;
+ private Map<String,Map<Long,CalorimeterHit>> _collMap;
private Map<String,Readout> _segmMap;
+ private Map<Subdetector,Map<Long,CalorimeterHit>> _subdet2collMap;
+ private Map<Long,Double> _densityMap;
}
lcsim/src/org/lcsim/recon/cluster/density
diff -u -r1.1 -r1.2
--- DirectedTree.java 12 Aug 2005 19:59:49 -0000 1.1
+++ DirectedTree.java 27 Sep 2005 20:46:19 -0000 1.2
@@ -2,19 +2,20 @@
import java.io.IOException;
import java.util.*;
+import hep.aida.*;
+import hep.physics.vec.Hep3Vector;
-import hep.aida.ITree;
-import hep.aida.ITupleFactory;
-import hep.aida.ITuple;
+import org.lcsim.util.aida.AIDA;
import org.lcsim.util.Driver;
import org.lcsim.event.EventHeader;
import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.MCParticle;
import org.lcsim.geometry.compact.Readout;
import org.lcsim.geometry.segmentation.SegmentationBase;
import org.lcsim.digisim.CellSelector;
-import org.lcsim.recon.cluster.util.HitsCluster;
-import hep.physics.vec.Hep3Vector;
+import org.lcsim.recon.cluster.util.BasicCluster;
+import org.lcsim.recon.cluster.util.SortClustersBySize;
public class DirectedTree extends Driver {
@@ -30,66 +31,36 @@
_tree.cd("..");
}
- public void process(EventHeader event){
+ public void process(EventHeader event) {
+ System.out.println("*************** New Event **********");
+ AIDA aida = AIDA.defaultInstance();
_evtnum = event.getEventNumber();
- System.out.println("Starting DirectedTree for event no."+" "+_evtnum);
+ System.out.println("Starting DirectedTree for event no. "+_evtnum);
_tree.cd("DirectedTree");
_roMap = event.getDetector().getReadouts();
- LoadMyCalorimeterHit loader = LoadMyCalorimeterHit.getInstance();
-
-// emhitmap = loader.getEMHitMap(event);
-// hdhitmap = loader.getHDHitMap(event);
String embName = "EcalBarrHits";
String emeName = "EcalEndcapHits";
String hdbName = "HcalBarrHits";
String hdeName = "HcalEndcapHits";
- embhitmap = loader.getCollHitMap(embName);
- emehitmap = loader.getCollHitMap(emeName);
- hdbhitmap = loader.getCollHitMap(hdbName);
- hdehitmap = loader.getCollHitMap(hdeName);
+ embhitmap = _loader.getCollHitMap(embName);
+ emehitmap = _loader.getCollHitMap(emeName);
+ hdbhitmap = _loader.getCollHitMap(hdbName);
+ hdehitmap = _loader.getCollHitMap(hdeName);
+
System.out.println("DTree: #hits: EMB="+embhitmap.size()
-+", EMEC="+emehitmap.size()+", HB="+hdbhitmap.size()+", HEC="+hdehitmap.size());
+ +", EMEC="+emehitmap.size()
+ +", HB="+hdbhitmap.size()
+ +", HEC="+hdehitmap.size());
if(_runPar.ClusterSeparately()){
_calType = "EM";
-// Vector<MyCalorimeterHit> emhit = new Vector<MyCalorimeterHit>();
-// emhit.addAll(embhitmap.values());
-// emhit.addAll(emehitmap.values());
-// emhitmap = new HashMap<Long,MyCalorimeterHit>();
-// emhitmap.putAll(embhitmap);
-// emhitmap.putAll(emehitmap);
-
- SegmentationBase segm = (SegmentationBase)_roMap.get(embName).getSegmentation();
- Vector<Vector<MyCalorimeterHit>> embTrees = makeTree(embhitmap, segm);
- ClusterBuilder embclus = new ClusterBuilder();
- List<Cluster> embClusters= embclus.makeClusters(embTrees,_runPar);
-
- List<MCCluster> mcEMB= MCReconstruction.getInstance().getmcClusters(embName);
-
-// List<HitsCluster> embClusters1 = event.get(HitsCluster.class, embName+"Clusters");
-
- fillDirectedTreeNtuple(embClusters,mcEMB);
-
+ processCollection(event,embName);
_calType = "HD";
-// Vector<MyCalorimeterHit> hdhit = new Vector<MyCalorimeterHit>();
-// hdhit.addAll(hdbhitmap.values());
-// hdhit.addAll(hdehitmap.values());
-// hdhitmap = new HashMap<Long,MyCalorimeterHit>();
-// hdhitmap.putAll(hdbhitmap);
-// hdhitmap.putAll(hdehitmap);
-
- segm = (SegmentationBase)_roMap.get(hdbName).getSegmentation();
- Vector<Vector<MyCalorimeterHit>> hdbTrees = makeTree(hdbhitmap, segm);
- ClusterBuilder hdbclus = new ClusterBuilder();
- List<Cluster> hdbClusters= hdbclus.makeClusters(hdbTrees,_runPar);
- List<MCCluster> mcHDB = MCReconstruction.getInstance().getmcClusters(hdbName);
-
-// List<HitsCluster> hdbClusters1 = event.get(HitsCluster.class, hdbName+"Clusters");
- fillDirectedTreeNtuple(hdbClusters,mcHDB);
+ processCollection(event,hdbName);
}
else {
assert false : "Sorry, single-pass clustering unavailable for now.";
@@ -112,122 +83,120 @@
}
_tree.cd("..");
-
}
- public Vector<Vector<MyCalorimeterHit>>
- makeTree(Map<Long,MyCalorimeterHit> cahitmap, SegmentationBase segm) {
+ public Vector<Vector<CalorimeterHit>>
+ makeTree(Map<Long,CalorimeterHit> cahitmap, SegmentationBase segm) {
+ System.out.println("makeTree called: cahitmap size="+cahitmap.size());
_ParentMap = new HashMap<Long,Long>();
- Vector<MyCalorimeterHit> RootVec = new Vector<MyCalorimeterHit>();
+ Vector<CalorimeterHit> RootVec = new Vector<CalorimeterHit>();
- for( MyCalorimeterHit myhit1 : cahitmap.values() ) {
-// for(int i=0;i<cahit.size();i++){
-// MyCalorimeterHit myhit1 = (MyCalorimeterHit) cahit.get(i);
- SimCalorimeterHit ihit = myhit1.getHit();
+ for( CalorimeterHit ihit : cahitmap.values() ) {
long cellid = ihit.getCellID();
- double idens = myhit1.getDensity(0);
- // if(_evtnum==81 && cellid== 1672347904) System.out.println("density="+idens);
+ double idens = _loader.getDensity( cellid );
+// if(_evtnum==81 && cellid== 1672347904) System.out.println("density="+idens);
segm.setID(cellid);
- System.out.println("makeTree ihit: cellID="+MyTools.printID(cellid)
- +", layer "+segm.getLayer()
- +", dens="+idens);
+// System.out.println("makeTree ihit: cellID="+MyTools.printID(cellid)
+// +", layer "+segm.getLayer()
+// +", dens="+idens);
double maxdensDiff = -999999.;
long maxdensID = -999999;
Vector<Long> nVec = new Vector<Long>();
- if(idens!=0.){
- double[] ipos = ihit.getPosition();
- if(_calType=="EM"){
- int nLyrOrig = _runPar.getLyrNeighEM();
- int nZOrig = _runPar.getZNeighEM();
- int nPhiOrig = _runPar.getPhiNeighEM();
- int dRegion = emDensityRegion(idens,nLyrOrig,nZOrig,nPhiOrig);
- int[] lyrCon = _runPar.getLyrContracEM();
- int[] zCon = _runPar.getZContracEM();
- int[] phiCon = _runPar.getPhiContracEM();
- System.out.println("Original Window"+" "+nLyrOrig+" "+nZOrig+" "+nPhiOrig);
- if(dRegion==1){
- _nLyr = nLyrOrig - lyrCon[0];
- _nZ = nZOrig - zCon[0];
- _nPhi = nPhiOrig - phiCon[0];
- }
- if(dRegion==2){
- _nLyr = nLyrOrig - lyrCon[1];
- _nZ = nZOrig - zCon[1];
- _nPhi = nPhiOrig - phiCon[1];
- }
- if(dRegion==3){
- _nLyr = nLyrOrig - lyrCon[2];
- _nZ = nZOrig - zCon[2];
- _nPhi = nPhiOrig - phiCon[2];
- }
- }
- if(_calType=="HD"){
- int nLyrOrig = _runPar.getLyrNeighHD();
- int nZOrig = _runPar.getZNeighHD();
- int nPhiOrig = _runPar.getPhiNeighHD();
- int dRegion = hdDensityRegion(idens,nLyrOrig,nZOrig,nPhiOrig);
- int[] lyrCon = _runPar.getLyrContracHD();
- int[] zCon = _runPar.getZContracHD();
- int[] phiCon = _runPar.getPhiContracHD();
- System.out.println("Original Window"+" "+nLyrOrig+" "+nZOrig+" "+nPhiOrig);
- if(dRegion==0){
- _nLyr = nLyrOrig;
- _nZ = nZOrig;
- _nPhi = nPhiOrig;
- }
- if(dRegion==1){
- _nLyr = nLyrOrig - lyrCon[0];
- _nZ = nZOrig - zCon[0];
- _nPhi = nPhiOrig - phiCon[0];
- }
- if(dRegion==2){
- _nLyr = nLyrOrig - lyrCon[1];
- _nZ = nZOrig - zCon[1];
- _nPhi = nPhiOrig - phiCon[1];
- }
- if(dRegion==3){
- _nLyr = nLyrOrig - lyrCon[2];
- _nZ = nZOrig - zCon[2];
- _nPhi = nPhiOrig - phiCon[2];
- }
- }
+ if(idens==0.0) {
+ RootVec.add(ihit);
+// System.out.println("Zero density root");
+ }
+ else{
+ double[] ipos = ihit.getPosition();
+ if(_calType=="EM"){
+ int nLyrOrig = _runPar.getLyrNeighEM();
+ int nZOrig = _runPar.getZNeighEM();
+ int nPhiOrig = _runPar.getPhiNeighEM();
+ int dRegion = emDensityRegion(idens,nLyrOrig,nZOrig,nPhiOrig);
+ int[] lyrCon = _runPar.getLyrContracEM();
+ int[] zCon = _runPar.getZContracEM();
+ int[] phiCon = _runPar.getPhiContracEM();
+// System.out.println("Original Window"+" "+nLyrOrig+" "+nZOrig+" "+nPhiOrig);
+ if(dRegion==1){
+ _nLyr = nLyrOrig - lyrCon[0];
+ _nZ = nZOrig - zCon[0];
+ _nPhi = nPhiOrig - phiCon[0];
+ }
+ if(dRegion==2){
+ _nLyr = nLyrOrig - lyrCon[1];
+ _nZ = nZOrig - zCon[1];
+ _nPhi = nPhiOrig - phiCon[1];
+ }
+ if(dRegion==3){
+ _nLyr = nLyrOrig - lyrCon[2];
+ _nZ = nZOrig - zCon[2];
+ _nPhi = nPhiOrig - phiCon[2];
+ }
+ }
+ if(_calType=="HD"){
+ int nLyrOrig = _runPar.getLyrNeighHD();
+ int nZOrig = _runPar.getZNeighHD();
+ int nPhiOrig = _runPar.getPhiNeighHD();
+ int dRegion = hdDensityRegion(idens,nLyrOrig,nZOrig,nPhiOrig);
+ int[] lyrCon = _runPar.getLyrContracHD();
+ int[] zCon = _runPar.getZContracHD();
+ int[] phiCon = _runPar.getPhiContracHD();
+// System.out.println("Original Window"+" "+nLyrOrig+" "+nZOrig+" "+nPhiOrig);
+ if(dRegion==0){
+ _nLyr = nLyrOrig;
+ _nZ = nZOrig;
+ _nPhi = nPhiOrig;
+ }
+ if(dRegion==1){
+ _nLyr = nLyrOrig - lyrCon[0];
+ _nZ = nZOrig - zCon[0];
+ _nPhi = nPhiOrig - phiCon[0];
+ }
+ if(dRegion==2){
+ _nLyr = nLyrOrig - lyrCon[1];
+ _nZ = nZOrig - zCon[1];
+ _nPhi = nPhiOrig - phiCon[1];
+ }
+ if(dRegion==3){
+ _nLyr = nLyrOrig - lyrCon[2];
+ _nZ = nZOrig - zCon[2];
+ _nPhi = nPhiOrig - phiCon[2];
+ }
+ }
// int neigh[] = segm.getNeighbors(cellid,_nLyr,_nZ,_nPhi);
-// if(_calType=="HD")
- System.out.println("window in directed tree "+_nLyr+" "+_nZ+" "+_nPhi);
- segm.setID(cellid);
- System.out.println("Processing ihit: cellID="+MyTools.printID(cellid));
+// if(_calType=="HD")
+// System.out.println("window in directed tree "+_nLyr+" "+_nZ+" "+_nPhi);
+ segm.setID(cellid);
+// System.out.println("Processing ihit: cellID="+MyTools.printID(cellid));
long neigh[] = segm.getNeighbourIDs(_nLyr, _nZ, _nPhi);
// if(_evtnum==81 && cellid== 1672347904) System.out.println("neighborhood="+" "+_nLyr+" "+_nZ+" "+_nPhi);
for(int j=0; j<neigh.length; j++){
long jid = neigh[j];
- Long jkey = new Long(jid);
- MyCalorimeterHit myhit2 = cahitmap.get(jkey);
- if(myhit2==null) continue;
- SimCalorimeterHit jhit = myhit2.getHit();
- double jdens = myhit2.getDensity(0);
+ CalorimeterHit jhit = cahitmap.get(jid);
+ if(jhit==null) continue;
+ double jdens = _loader.getDensity(jhit);
double[] jpos = jhit.getPosition();
_distType = _runPar.getDistanceType();
CalculateDistance calcD = new CalculateDistance();
double distance = calcD.CalculateDistance(_distType,ipos,jpos);
double densDiff = (jdens-idens)/distance;
- if(distance==0) densDiff=0;
+//??? if(distance==0) densDiff=0;
+
+ if(densDiff==0.0) nVec.add(jid);
+// System.out.println(" jhit: layer="+(jid&0x7f)
+// +", cellID="+MyTools.printID(jid)
+// +", idens="+idens
+// +", jdens="+jdens
+// +", dist="+distance
+// +", densDiff="+densDiff);
- if(densDiff==0.0) nVec.add(jkey);
- System.out.println(" jhit: layer="+(jid&0x7f)
- +", cellID="+MyTools.printID(jid)
- +", idens="+idens
- +", jdens="+jdens
- +", dist="+distance
- +", densDiff="+densDiff);
-// if(_evtnum==81 && cellid==1672347904) System.out.println(cellid+" "+jid+" "+jkey+" "+myhit2+" "+
-// idens+" "+jdens+" "+densDiff);
if(densDiff>maxdensDiff){
maxdensDiff = densDiff;
maxdensID = jid;
@@ -235,51 +204,48 @@
calcD = null;
}
-// if(_evtnum==81 && cellid== 1672347904) System.out.println("densDiff="+maxdensDiff);
-
- if(maxdensDiff<0.0){
- RootVec.add(myhit1);
- System.out.println("Bonafide root");
- }
+// if(maxdensDiff<0.0){
+// RootVec.add(myhit1);
+// System.out.println("Bonafide root");
+// }
if(maxdensDiff>0.0){
Long key1 = new Long(cellid);
Long key2 = new Long(maxdensID);
- System.out.println("pt1: parentmap.put: "+MyTools.printID(key1.longValue())+" "+MyTools.printID(key2.longValue()));
_ParentMap.put(key1,key2);
- System.out.println(" maxdensDiff>0: "
- +" id="+MyTools.printID(maxdensID)
- +", parent of "+MyTools.printID(cellid));
+// System.out.println(" maxdensDiff>0: "
+// +" id="+MyTools.printID(maxdensID)
+// +", parent of "+MyTools.printID(cellid));
}
if(maxdensDiff==0.0){
Vector<Long> removeItems = new Vector<Long>();
- Long key = new Long(cellid);
+// Long key = new Long(cellid);
for(Long jkey : nVec) {
Vector<Long> temporary = new Vector<Long>();
Long parent = _ParentMap.get(jkey);
-// if(_evtnum==81 && cellid== 1672347904) System.out.println(parent);
+
while(parent!=null){
temporary.add(parent);
Long lkey = parent;
parent = _ParentMap.get(lkey);
}
- if(temporary.contains(key)){
+ if(temporary.contains(cellid)){
removeItems.add(jkey);
}
}
nVec.removeAll(removeItems);
if(nVec.size()==0){
- RootVec.add(myhit1);
+ RootVec.add(ihit);
}
else{
double dmin = 9999.;
- Long parentKey = new Long(0);
+ long parentKey = 0;
for(Long jkey : nVec) {
// if(_evtnum==81 && cellid== 1672347904) System.out.println(jkey);
- MyCalorimeterHit myhit2 = cahitmap.get(jkey);
- SimCalorimeterHit jhit = myhit2.getHit();
+ CalorimeterHit jhit = cahitmap.get(jkey);
+// SimCalorimeterHit jhit = myhit2.getHit();
double[] jpos = jhit.getPosition();
CalculateDistance calcD = new CalculateDistance();
double distance = calcD.CalculateDistance(_distType,ipos,jpos);
@@ -290,78 +256,73 @@
parentKey = jkey;
}
}
- _ParentMap.put(key,parentKey);
- System.out.println("Cell is matched to identical density neighbor");
+ _ParentMap.put(cellid,parentKey);
+// System.out.println("Cell is matched to identical density neighbor");
}
- }
+ }
}
- else{
- RootVec.add(myhit1);
- System.out.println("Zero density root");
- }
}
- Vector<MyCalorimeterHit> startingPoints = new Vector<MyCalorimeterHit>();
- for( MyCalorimeterHit myhit1 : cahitmap.values() ) {
-// for(int i=0;i<cahit.size();i++){
-// MyCalorimeterHit myhit1 = (MyCalorimeterHit) cahit.get(i);
- SimCalorimeterHit ihit = myhit1.getHit();
+ Vector<CalorimeterHit> startingPoints = new Vector<CalorimeterHit>();
+ for( CalorimeterHit ihit : cahitmap.values() ) {
long cellid = ihit.getCellID();
- Long value = new Long(cellid);
- boolean isParent = _ParentMap.containsValue(value);
- boolean isRoot = RootVec.contains(myhit1);
+ boolean isParent = _ParentMap.containsValue(cellid);
+ boolean isRoot = RootVec.contains(ihit);
if(!isParent && !isRoot){
- startingPoints.add(myhit1);
+ startingPoints.add(ihit);
}
}
+ System.out.println("# starting points = "+startingPoints.size());
- Vector<Vector<MyCalorimeterHit>> branches
- = new Vector<Vector<MyCalorimeterHit>>();
+ Vector<Vector<CalorimeterHit>> branches = new Vector<Vector<CalorimeterHit>>();
for(int i=0;i<startingPoints.size();i++) {
- branches.add( new Vector<MyCalorimeterHit>() );
+ branches.add( new Vector<CalorimeterHit>() );
}
for(int i=0;i<startingPoints.size();i++){
- MyCalorimeterHit myhit1 = startingPoints.get(i);
- branches.get(i).add(myhit1);
- SimCalorimeterHit ihit = myhit1.getHit();
+ CalorimeterHit ihit = startingPoints.get(i);
+ branches.get(i).add(ihit);
long cellid = ihit.getCellID();
- Long key = new Long(cellid);
- while(_ParentMap.containsKey(key)){
- Long jkey = _ParentMap.get(key);
- MyCalorimeterHit myhit2 = cahitmap.get(jkey);
- branches.get(i).add(myhit2);
-// if(_evtnum==81) System.out.println("filling branches"+" "+i+" "+myhit1+" "+key+" "+jkey+" "+myhit2);
- key = jkey;
+ Long key = new Long(cellid);
+ while(_ParentMap.containsKey(cellid)){
+ Long jkey = _ParentMap.get(cellid);
+ CalorimeterHit jhit = cahitmap.get(jkey);
+ branches.get(i).add(jhit);
+ cellid = jkey.longValue();
}
}
int vsiz = RootVec.size();
- // System.out.println("no. of roots"+" "+vsiz);
- Vector<Vector<MyCalorimeterHit>> caTrees = new Vector<Vector<MyCalorimeterHit>>();
+ System.out.println("no. of roots = "+vsiz);
+ Vector<Vector<CalorimeterHit>> caTrees = new Vector<Vector<CalorimeterHit>>();
for(int i=0;i<vsiz;i++){
- caTrees.add( new Vector<MyCalorimeterHit>() );
+ caTrees.add( new Vector<CalorimeterHit>() );
}
for(int i=0;i<vsiz;i++){
- MyCalorimeterHit myhit1 = RootVec.get(i);
- long tmpID = myhit1.getHit().getCellID();
- System.out.println("ROOT id="+MyTools.printID(tmpID));
- caTrees.get(i).add(myhit1);
+ CalorimeterHit ihit = RootVec.get(i);
+ long tmpID = ihit.getCellID();
+ caTrees.get(i).add(ihit);
for(int j=0;j<startingPoints.size();j++) {
- MyCalorimeterHit parentHit = branches.get(j).lastElement();
+ CalorimeterHit parentHit = branches.get(j).lastElement();
// if(_evtnum==81) System.out.println(myhit1+" "+parentHit+" "+startingPoints.size()+" "+j);
- if(parentHit.equals(myhit1)) {
- for( MyCalorimeterHit myhit2 : branches.get(j) ) {
- if(!caTrees.get(i).contains(myhit2)){
- caTrees.get(i).add(myhit2);
- long tmppID = myhit2.getHit().getCellID();
- System.out.println("Branches id="+MyTools.printID(tmppID));
+ if(parentHit.equals(ihit)) {
+ for( CalorimeterHit jhit : branches.get(j) ) {
+ if(!caTrees.get(i).contains(jhit)){
+ caTrees.get(i).add(jhit);
+ long tmppID = jhit.getCellID();
+// System.out.println("Branches id="+MyTools.printID(tmppID));
}
}
}
}
+ System.out.println("ROOT id="+MyTools.printID(tmpID)
+ +", #hits="+caTrees.get(i).size());
}
+// for( Vector<MyCalorimeterHit> rootHits : caTrees ) {
+// System.out.println("ROOT: #hits="+rootHits.size());
+// }
+
return caTrees;
}
@@ -412,9 +373,8 @@
}
public void fillDirectedTreeNtuple(List<Cluster> recon,
- List<MCCluster> mctruth)
+ List<BasicCluster> mctruth)
{
- System.out.println("fillDirectedTreeNtuple() called, "+recon+" "+mctruth);
if(_calType=="EM"){
emClusFolder = _tupleEM.getTuple(1);
emCellFolder = _tupleEM.getTuple(2);
@@ -430,21 +390,20 @@
}
int tag = 0;
- Map<MyCalorimeterHit,Integer> recTagMap
- = new HashMap<MyCalorimeterHit,Integer>();
+ Map<CalorimeterHit,Integer> recTagMap
+ = new HashMap<CalorimeterHit,Integer>();
for(Cluster clust : recon ) {
- Vector<MyCalorimeterHit> cellVec = clust._hitColl;
+ Vector<CalorimeterHit> cellVec = clust._hitColl;
// System.out.println(tag+" "+cellVec.size());
if(cellVec.size()==0.) System.out.println("Damn 3");
// for(int i=0;i<cellVec.size();i++){
// MyCalorimeterHit myhit = (MyCalorimeterHit) cellVec.get(i);
- for(MyCalorimeterHit myhit : cellVec) {
- SimCalorimeterHit ihit = myhit.getHit();
+ for(CalorimeterHit ihit : cellVec) {
Integer tagObject = new Integer(tag);
- System.out.println("putting <"+myhit+"->"+tagObject+">");
- recTagMap.put(myhit,tagObject);
+// System.out.println("putting <"+myhit+"->"+tagObject+">");
+ recTagMap.put(ihit,tagObject);
double[] pos = ihit.getPosition();
- double cdens = myhit.getDensity(0);
+ double cdens = _loader.getDensity(ihit);
if(_calType=="EM"){
emCellFolder.fill(0,(float) ihit.getRawEnergy());
emCellFolder.fill(1,(float)pos[0]);
@@ -469,143 +428,190 @@
emClusFolder.fill(1,(float) clust._xpos);
emClusFolder.fill(2,(float) clust._ypos);
emClusFolder.fill(3,(float) clust._zpos);
- emClusFolder.fill(4,(int) clust._size);
+ emClusFolder.fill(4, clust._size);
emClusFolder.addRow();
- System.out.println("EM Clus"+" "+tag+" "+clust._xpos+" "+clust._ypos+" "+clust._zpos+" "+clust._size);
+// System.out.println("EM Clus "+tag+" "+clust._xpos+" "+clust._ypos+" "+clust._zpos+" "+ clust._size );
}
if(_calType=="HD"){
hdClusFolder.fill(0,(float) clust._ene);
hdClusFolder.fill(1,(float) clust._xpos);
hdClusFolder.fill(2,(float) clust._ypos);
hdClusFolder.fill(3,(float) clust._zpos);
- hdClusFolder.fill(4,(int) clust._size);
+ hdClusFolder.fill(4, clust._size );
hdClusFolder.addRow();
}
tag++;
}
tag = 0;
- for( MCCluster clust : mctruth ) {
- Vector<MyCalorimeterHit> cellVec = clust._hitColl;
- for(MyCalorimeterHit myhit : cellVec) {
- Integer tagObject = recTagMap.get(myhit);
- System.out.println("getting: "+myhit+" -> "+tagObject);
- int rtag = -1;
- if(tagObject!=null) rtag = tagObject.intValue();
- SimCalorimeterHit ihit = myhit.getHit();
- double[] pos = ihit.getPosition();
- double cdens = myhit.getDensity(0);
- long jid = ihit.getCellID();
- int ily = MyTools.getLayer(jid);
- int iz = MyTools.getThetaBin(jid);
- int iphi = MyTools.getPhiBin(jid);
- if(_calType=="EM") {
- emmcCellFolder.fill(0,(float) ihit.getRawEnergy());
- emmcCellFolder.fill(1,(float)pos[0]);
- emmcCellFolder.fill(2,(float)pos[1]);
- emmcCellFolder.fill(3,(float)pos[2]);
- emmcCellFolder.fill(4,(float) cdens);
- emmcCellFolder.fill(5,tag);
- emmcCellFolder.fill(6,rtag);
- emmcCellFolder.fill(7,ily);
- emmcCellFolder.fill(8,iz);
- emmcCellFolder.fill(9,iphi);
- emmcCellFolder.addRow();
- // if(tag==17){
- System.out.println("EM Clus cells tag="+tag
- +", id="+MyTools.printID(jid)
- +", pos="+pos[0]+" "+pos[1]+" "+pos[2]
- +", dens="+cdens);
- }
- if(_calType=="HD"){
- hdmcCellFolder.fill(0,(float) ihit.getRawEnergy());
- hdmcCellFolder.fill(1,(float)pos[0]);
- hdmcCellFolder.fill(2,(float)pos[1]);
- hdmcCellFolder.fill(3,(float)pos[2]);
- hdmcCellFolder.fill(4,(float) cdens);
- hdmcCellFolder.fill(5,tag);
- hdmcCellFolder.fill(6,rtag);
- hdmcCellFolder.fill(7,ily);
- hdmcCellFolder.fill(8,iz);
- hdmcCellFolder.fill(9,iphi);
- hdmcCellFolder.addRow();
- if(tag==7){
- System.out.println("HD Clus cells: id="+MyTools.printID(jid)
- +", pos="+pos[0]+" "+pos[1]+" "+pos[2]
- +", dens="+cdens);
- }
- }
- }
- MCParticle mcpart = clust._mcpart;
- float charge = (float)mcpart.getCharge();
- System.out.println("charge="+charge);
- int particleID = mcpart.getType().getPDGID();
- float mcE = (float)mcpart.getEnergy();
- Hep3Vector mcMom = mcpart.getMomentum();
- if(_calType=="EM"){
- emmcClusFolder.fill(0,(float) clust._ene);
- emmcClusFolder.fill(1,(float) clust._xpos);
- emmcClusFolder.fill(2,(float) clust._ypos);
- emmcClusFolder.fill(3,(float) clust._zpos);
- emmcClusFolder.fill(4,(int) clust._size);
- emmcClusFolder.fill(5,particleID);
- emmcClusFolder.fill(6,charge);
- emmcClusFolder.fill(7,mcE);
- emmcClusFolder.fill(8,(float)mcMom.x());
- emmcClusFolder.fill(9,(float)mcMom.y());
- emmcClusFolder.fill(10,(float)mcMom.z());
- emmcClusFolder.addRow();
- }
- if(_calType=="HD"){
- hdmcClusFolder.fill(0,(float) clust._ene);
- hdmcClusFolder.fill(1,(float) clust._xpos);
- hdmcClusFolder.fill(2,(float) clust._ypos);
- hdmcClusFolder.fill(3,(float) clust._zpos);
- hdmcClusFolder.fill(4,(int) clust._size);
- hdmcClusFolder.fill(5,particleID);
- hdmcClusFolder.fill(6,(int) charge);
- hdmcClusFolder.fill(7,mcE);
- hdmcClusFolder.fill(8,(float)mcMom.x());
- hdmcClusFolder.fill(9,(float)mcMom.y());
- hdmcClusFolder.fill(10,(float)mcMom.z());
- hdmcClusFolder.addRow();
- }
- tag++;
+ for( BasicCluster clust : mctruth ) {
+ for( CalorimeterHit ihit : clust.getCalorimeterHits() ) {
+ Integer tagObject = recTagMap.get(ihit);
+// System.out.println("getting: "+ihit+" -> "+tagObject);
+ int rtag = -1;
+ if(tagObject!=null) rtag = tagObject.intValue();
+ double[] pos = ihit.getPosition();
+ double cdens = _loader.getDensity(ihit);
+ if(cdens==0) continue; // skip hits below energy cut
+ long jid = ihit.getCellID();
+ int ily = MyTools.getLayer(jid);
+ int iz = MyTools.getThetaBin(jid);
+ int iphi = MyTools.getPhiBin(jid);
+ if(_calType=="EM") {
+ emmcCellFolder.fill(0,(float) ihit.getRawEnergy());
+ emmcCellFolder.fill(1,(float)pos[0]);
+ emmcCellFolder.fill(2,(float)pos[1]);
+ emmcCellFolder.fill(3,(float)pos[2]);
+ emmcCellFolder.fill(4,(float) cdens);
+ emmcCellFolder.fill(5,tag);
+ emmcCellFolder.fill(6,rtag);
+ emmcCellFolder.fill(7,ily);
+ emmcCellFolder.fill(8,iz);
+ emmcCellFolder.fill(9,iphi);
+ emmcCellFolder.addRow();
+// System.out.println("EM Clus cells tag="+tag+", rtag="+rtag
+// +", id="+MyTools.printID(jid)
+// // +", pos="+pos[0]+" "+pos[1]+" "+pos[2]
+// +", dens="+cdens);
+ }
+ if(_calType=="HD") {
+ hdmcCellFolder.fill(0,(float) ihit.getRawEnergy());
+ hdmcCellFolder.fill(1,(float)pos[0]);
+ hdmcCellFolder.fill(2,(float)pos[1]);
+ hdmcCellFolder.fill(3,(float)pos[2]);
+ hdmcCellFolder.fill(4,(float) cdens);
+ hdmcCellFolder.fill(5,tag);
+ hdmcCellFolder.fill(6,rtag);
+ hdmcCellFolder.fill(7,ily);
+ hdmcCellFolder.fill(8,iz);
+ hdmcCellFolder.fill(9,iphi);
+ hdmcCellFolder.addRow();
+// if(tag==7){
+// System.out.println("HD Clus cells: id="+MyTools.printID(jid)
+// +", pos="+pos[0]+" "+pos[1]+" "+pos[2]
+// +", dens="+cdens);
+// }
+ }
+ }
+ MCParticle mcpart = getMCParticleInCluster(clust);
+
+ float charge = (float)mcpart.getCharge();
+ System.out.println("charge="+charge);
+ int particleID = mcpart.getType().getPDGID();
+ float mcE = (float)mcpart.getEnergy();
+ Hep3Vector mcMom = mcpart.getMomentum();
+ double[] pos = clust.getPosition();
+ if(_calType=="EM"){
+ emmcClusFolder.fill(0,(float) clust.getEnergy());
+ emmcClusFolder.fill(1, (float)pos[0] );
+ emmcClusFolder.fill(2, (float)pos[1] );
+ emmcClusFolder.fill(3, (float)pos[2] );
+ emmcClusFolder.fill(4, clust.getSize() );
+ emmcClusFolder.fill(5, particleID);
+ emmcClusFolder.fill(6, charge);
+ emmcClusFolder.fill(7, mcE);
+ emmcClusFolder.fill(8, (float)mcMom.x());
+ emmcClusFolder.fill(9,(float)mcMom.y());
+ emmcClusFolder.fill(10,(float)mcMom.z());
+ emmcClusFolder.addRow();
+ }
+ if(_calType=="HD") {
+ hdmcClusFolder.fill(0, (float)clust.getEnergy() );
+ hdmcClusFolder.fill(1, (float)pos[0] );
+ hdmcClusFolder.fill(2, (float)pos[1] );
+ hdmcClusFolder.fill(3, (float)pos[2] );
+ hdmcClusFolder.fill(4, clust.getSize() );
+ hdmcClusFolder.fill(5, particleID);
+ hdmcClusFolder.fill(6, (int) charge);
+ hdmcClusFolder.fill(7, mcE);
+ hdmcClusFolder.fill(8, (float)mcMom.x());
+ hdmcClusFolder.fill(9, (float)mcMom.y());
+ hdmcClusFolder.fill(10, (float)mcMom.z());
+ hdmcClusFolder.addRow();
+ }
+ tag++;
}
if(_calType=="EM"){
- _tupleEM.fill(0,recon.size());
- _tupleEM.fill(3,_evtnum);
- _tupleEM.addRow();
- _tupleMCem.fill(0,mctruth.size());
- _tupleMCem.fill(3,_evtnum);
- _tupleMCem.addRow();
- _tupleEvt.fill(0,_evtnum);
- _tupleEvt.addRow();
+ _tupleEM.fill(0,recon.size());
+ _tupleEM.fill(3,_evtnum);
+ _tupleEM.addRow();
+ _tupleMCem.fill(0,mctruth.size());
+ _tupleMCem.fill(3,_evtnum);
+ _tupleMCem.addRow();
+ _tupleEvt.fill(0,_evtnum);
+ _tupleEvt.addRow();
}
if(_calType=="HD"){
- _tupleHD.fill(0,recon.size());
- _tupleHD.fill(3,_evtnum);
- _tupleHD.addRow();
- _tupleMChd.fill(0,mctruth.size());
- _tupleMChd.fill(3,_evtnum);
- _tupleMChd.addRow();
+ _tupleHD.fill(0,recon.size());
+ _tupleHD.fill(3,_evtnum);
+ _tupleHD.addRow();
+ _tupleMChd.fill(0,mctruth.size());
+ _tupleMChd.fill(3,_evtnum);
+ _tupleMChd.addRow();
}
recTagMap.clear();
+ }
+
+ private void processCollection(EventHeader event, String colName) {
+ System.out.println("*** Entering procColl: colName="+colName);
+ Map<Long,CalorimeterHit> hitmap = _loader.getCollHitMap(colName);
+
+ SegmentationBase segm
+ = (SegmentationBase)_roMap.get(colName).getSegmentation();
+ Vector<Vector<CalorimeterHit>> trees = makeTree(hitmap, segm);
+
+ List<Cluster> recoClusColl = clusBuilder.makeClusters( trees, _runPar);
+
+ int nclusCheat=0;
+ List<BasicCluster> mcClusColl = event.get(BasicCluster.class, colName+"Clusters");
+ System.out.println("*** procColl: colName="+colName
+ +", # of MCclusters: "+mcClusColl.size());
+
+ Collections.sort( mcClusColl, new SortClustersBySize() );
+
+ // Analyze MC clusters
+ int mchits=0;
+ for( BasicCluster iclus : mcClusColl ) {
+ double pos[] = iclus.getPosition();
+ List<CalorimeterHit> iHits = iclus.getCalorimeterHits();
+ mchits += iHits.size(); // includes hits below threshold
+ }
+ nclusCheat = mcClusColl.size();
+
+ System.out.println(" Comparing cheat clusters: "
+ +", cheater="+nclusCheat);
+ System.out.println(" Comparing total #hits: "
+ +" in event: "+hitmap.size()
+ +", in MCClusters="+mchits );
+
+ int nhits = hitmap.size();
+ AIDA aida = AIDA.defaultInstance();
+ aida.cloud1D(colName+"-Nhits").fill( nhits );
+ aida.cloud1D(colName+"-NmcHits").fill(mchits);
+ aida.cloud1D(colName+"-diffHitsColl-mc").fill(nhits-mchits);
+ aida.cloud1D(colName+"-numCheatClusters").fill(nclusCheat);
+
+ fillDirectedTreeNtuple( recoClusColl, mcClusColl );
}
-// public SegmentationBase getSegmentation(long cellid) {
-// // warning: this is very detector specific!!!
-// int segmID = cellid & 0x0;
-// }
+ private MCParticle getMCParticleInCluster(BasicCluster clust) {
+ for( CalorimeterHit hit : clust.getCalorimeterHits() ) {
+ SimCalorimeterHit simhit = (SimCalorimeterHit)hit;
+ if( simhit!=null && simhit.getMCParticleCount()==1 ) {
+ return simhit.getMCParticle(0);
+ }
+ }
+ return null;
+ }
private static Map<String,Readout> _roMap;
private static RunControlParameters _runPar;
+ private LoadMyCalorimeterHit _loader = LoadMyCalorimeterHit.getInstance();
private Map<Long,Long> _ParentMap;
- private Map<Long,MyCalorimeterHit> emhitmap,hdhitmap,cahitmap;
- private Map<Long,MyCalorimeterHit> embhitmap,emehitmap,hdbhitmap,hdehitmap;
+ private Map<Long,CalorimeterHit> embhitmap,emehitmap,hdbhitmap,hdehitmap;
private String _distType,_calType;
private int _nLyr;
private int _nZ;
@@ -622,4 +628,5 @@
private ITuple hdClusFolder,hdCellFolder;
private ITuple emmcClusFolder,emmcCellFolder;
private ITuple hdmcClusFolder,hdmcCellFolder;
+ private ClusterBuilder clusBuilder = new ClusterBuilder();
}