lcsim/src/org/lcsim/contrib/Cassell/recon/Cheat
diff -u -r1.2 -r1.3
--- CheatReconDriver.java 30 Aug 2007 18:14:12 -0000 1.2
+++ CheatReconDriver.java 13 Sep 2007 14:41:29 -0000 1.3
@@ -23,9 +23,11 @@
import org.lcsim.recon.tracking.cheat.CheatTrackDriver;
import org.lcsim.recon.particle.CheatParticleDriver;
import org.lcsim.event.util.CreateFinalStateMCParticleList;
-import org.lcsim.digisim.DigiSimDriver;
-import org.lcsim.digisim.SimCalorimeterHitsDriver;
+import org.lcsim.digisim.DigiPackageDriver;
import org.lcsim.recon.cluster.util.CalHitMapDriver;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.detector.solids.Tube;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
@@ -38,159 +40,191 @@
*/
public class CheatReconDriver extends Driver
{
- String FSname = "GenFinalStateParticles";
- String Tname = "RefinedCheatTracks";
- String Cname = "RefinedCheatClusters";
- String outRname = "CheatReconReconstructedParticles";
- String outFSname = "CheatReconFinalStateParticles";
- String outTname = "CheatReconTracks";
- String outCname = "CheatReconClusters";
- String[] diginames = {"EcalBarrDigiHits", "EcalEndcapDigiHits",
- "HcalBarrDigiHits", "HcalEndcapDigiHits"};
- double mintfromin = 4;
- double mintfromout = 3;
- double mintlength = 100.;
- double ptcut = .1;
- double emR = 1270.;
- double emZ = 1680.;
- double tccut = 400.;
- double minneutlen = 200.;
- Map<MCParticle,Track> tmap;
- CheatParticleDriver cpd;
- /** Creates a new instance of CheatSimReconParticleDriver */
- public CheatReconDriver()
- {
-//
-// Make a list of MCParticles to be considered
-//
- CreateFinalStateMCParticleList cfs = new CreateFinalStateMCParticleList("Gen");
- cfs.setCollectionName(FSname);
- add(cfs);
+ String inFSname = "GenFinalStateParticles";
+ String inTname = "RefinedCheatTracks";
+ String inCname = "RefinedCheatClusters";
+ String outRname;
+ String outFSname;
+ String outTname;
+ String outCname;
+ String[] diginames = {"EcalBarrDigiHits", "EcalEndcapDigiHits","HcalBarrDigiHits", "HcalEndcapDigiHits"};
+//
+// Default parameters for defining "trackable" track
+//
+ double mintfromin = 4;
+ double mintfromout = 3;
+ double mintlength = 100.;
+ double ptcut = .1;
+// Ask Jeremy how to do this
+ double emR = 1270.;
+ double emZ = 1680.;
+// Just keep it distance cut
+ double jki = 100.;
+// Too close cut
+ double tccut = 400.;
+// Minimum length of neutral parent to consider for replacement
+ double minneutlen = 400.;
+ Map<MCParticle,Track> tmap;
+ TraceOrigin to;
+ /** Creates a new instance of CheatSimReconParticleDriver */
+ public CheatReconDriver()
+ {
+ outRname = "ReconPerfectReconParticles";
+ outFSname = "ReconFSParticles";
+ outTname = "ReconTracks";
+ outCname = "ReconClusters";
+//
+// Make an initial list of MCParticles to be considered
+//
+ CreateFinalStateMCParticleList cfs = new CreateFinalStateMCParticleList("Gen");
+ cfs.setCollectionName(inFSname);
+ add(cfs);
//
-// Make TrackerHit Clusters
+// Make cheating TrackerHit Clusters
//
- add(new CheatTrackDriver());
+ add(new CheatTrackDriver(inTname));
//
// Make CalorimeterHit Cheat Clusters
//
- add(new CalHitMapDriver());
- DigiSimDriver digi = new DigiSimDriver();
- add(digi);
- add(new SimCalorimeterHitsDriver());
- // output of DigiSim is hit collections - EcalBarrDigiHits, EcalEndcapDigiHits, HcalBarrDigiHits, HcalEndcapDigiHits
- add(new CheatClusterDriver(diginames, Cname));
- cpd = new CheatParticleDriver("dummy");
- }
- public void process(EventHeader event)
- {
- super.process(event);
- List<MCParticle> initfs = event.get(MCParticle.class,FSname);
- List<Track> inittracks = event.get(Track.class,Tname);
- List<Cluster> initclusters = event.get(Cluster.class,Cname);
- List<MCParticle> add = new ArrayList<MCParticle>();
- List<MCParticle> remove = new ArrayList<MCParticle>();
- List<MCParticle> tempfs = new ArrayList<MCParticle>();
- List<MCParticle> untracked = new ArrayList<MCParticle>();
- List<MCParticle> reconfs = new ArrayList<MCParticle>();
- List<Track> fstracks = new ArrayList<Track>();
- List<Cluster> fsclusters = new ArrayList<Cluster>();
- List<Cluster> nonfsclusters = new ArrayList<Cluster>();
- List<Cluster> untrackedchargedclusters = new ArrayList<Cluster>();
- tmap = new HashMap<MCParticle,Track>();
+ add(new DigiPackageDriver());
+ // output of DigiSim is hit collections - EcalBarrDigiHits, EcalEndcapDigiHits, HcalBarrDigiHits, HcalEndcapDigiHits
+ add(new CheatClusterDriver(diginames, inCname));
+ }
+ public void setCheatTrackOutputName(String s)
+ {outTname = s;}
+ public void setCheatClusterOutputName(String s)
+ {outCname = s;}
+ public void setCheatFSParticleOutputName(String s)
+ {outFSname = s;}
+ public void setCheatReconstructedParticleOutputName(String s)
+ {outRname = s;}
+ public void setJustKeepItCut(double x)
+ {jki = x;}
+ public void setTooCloseCut(double x)
+ {tccut = x;}
+ public void setMinNeutralLengthCut(double x)
+ {minneutlen = x;}
+ public void process(EventHeader event)
+ {
+ super.process(event);
+ List<MCParticle> initfs = event.get(MCParticle.class,inFSname);
+ List<Track> inittracks = event.get(Track.class,inTname);
+ List<Cluster> initclusters = event.get(Cluster.class,inCname);
+ List<MCParticle> add = new ArrayList<MCParticle>();
+ List<MCParticle> remove = new ArrayList<MCParticle>();
+ List<MCParticle> tempfs = new ArrayList<MCParticle>();
+ List<MCParticle> untracked = new ArrayList<MCParticle>();
+ List<MCParticle> reconfs = new ArrayList<MCParticle>();
+ List<Track> fstracks = new ArrayList<Track>();
+ List<Cluster> fsclusters = new ArrayList<Cluster>();
+ List<Cluster> nonfsclusters = new ArrayList<Cluster>();
+ List<Cluster> untrackedchargedclusters = new ArrayList<Cluster>();
+ tmap = new HashMap<MCParticle,Track>();
//
// Make a map of trackable tracks
//
- for(Track t:inittracks)
- {
- MCParticle p = ((BaseTrackMC) t).getMCParticle();
- if(isTrackable(p,t))tmap.put(p,t);
- }
+ for(Track t:inittracks)
+ {
+ MCParticle p = ((BaseTrackMC) t).getMCParticle();
+ if(isTrackable(p,t))tmap.put(p,t);
+ }
//
// Start with the generator final state particles
//
- for(MCParticle p:initfs)
- {
+ for(MCParticle p:initfs)
+ {
//
// If the particle has already been removed skip it
//
- if(remove.contains(p))continue;
- Hep3Vector vtx = p.getOrigin();
- Hep3Vector ep = p.getEndPoint();
+ if(remove.contains(p))continue;
+//
+// For the majority of generator fs particles, they originate near the ip
+// and end near or beyond the Ecal. Just keep them
+//
+ Hep3Vector vtx = p.getOrigin();
+ Hep3Vector ep = p.getEndPoint();
+ if(vtx.magnitude() < jki)
+ {
+ if( (Math.sqrt(ep.x()*ep.x()+ep.y()*ep.y())>emR-jki)||(Math.abs(ep.z())>emZ-jki) )
+ {
+ continue;
+ }
+ }
//
// Check if we really want the parent
//
- MCParticle tp = getTrackableParent(p);
+ MCParticle tp = getTrackableParent(p);
//
// No trackable parentage. Only keep parent if really close to Cal
//
- if(tp == null)
- {
+ if(tp == null)
+ {
//
// If particle is trackable, we aren't going to remove it for parentage
//
- if(!tmap.containsKey(p))
+ if(!tmap.containsKey(p))
+ {
+ if(tooClose(vtx))
{
- if(tooClose(vtx))
- {
//
// Vertex is close to Ecal. Consider replacing with a neutral parent
//
- MCParticle par = getLongestNeutralParent(p);
- if(par != null)
+ MCParticle par = getLongestNeutralParent(p);
+ if(par != null)
+ {
+ if(!hasTrackableDaughters(par))
{
- if(!hasTrackableDaughters(par))
+ add.add(par);
+ List<MCParticle> dl = new ArrayList<MCParticle>();
+ for(MCParticle d:par.getDaughters())
+ {
+ dl.add(d);
+ }
+ while(dl.size() > 0)
{
- add.add(par);
- List<MCParticle> dl = new ArrayList<MCParticle>();
- for(MCParticle d:par.getDaughters())
+ remove.add(dl.get(0));
+ for(MCParticle d:dl.get(0).getDaughters())
{
dl.add(d);
}
- while(dl.size() > 0)
- {
- remove.add(dl.get(0));
- for(MCParticle d:dl.get(0).getDaughters())
- {
- dl.add(d);
- }
- dl.remove(0);
- }
- continue;
+ dl.remove(0);
}
+ continue;
}
}
}
}
+ }
//
// Have trackable parentage. Only keep parent if no trackable offspring
// of trackable parent.
//
- else
+ else
+ {
+ if(!hasTrackableDaughters(tp))
{
- if(!hasTrackableDaughters(tp))
- {
//
// No trackable offspring, so keep trackable parent and remove all
// offspring.
//
- add.add(tp);
- List<MCParticle> dl = new ArrayList<MCParticle>();
- for(MCParticle d:tp.getDaughters())
+ add.add(tp);
+ List<MCParticle> dl = new ArrayList<MCParticle>();
+ for(MCParticle d:tp.getDaughters())
+ {
+ dl.add(d);
+ }
+ while(dl.size() > 0)
+ {
+ remove.add(dl.get(0));
+ for(MCParticle d:dl.get(0).getDaughters())
{
dl.add(d);
}
- while(dl.size() > 0)
- {
- remove.add(dl.get(0));
- for(MCParticle d:dl.get(0).getDaughters())
- {
- dl.add(d);
- }
- dl.remove(0);
- }
- continue;
+ dl.remove(0);
}
+ continue;
}
+ }
//
// Done checking for parentage replacement. Now check for offspring replacement
//
@@ -198,6 +232,71 @@
// Start with a special case for photon conversions. Only replace the photon
// if both electrons are trackable
//
+ if(p.getPDGID() == 22)
+ {
+ if(hasTrackableDaughters(p))
+ {
+ boolean hasep = false;
+ boolean hasem = false;
+ for(MCParticle d:p.getDaughters())
+ {
+ if(d.getSimulatorStatus().isBackscatter())continue;
+ if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
+ if(tmap.containsKey(d))
+ {
+ if(d.getPDGID() == 11)hasem = true;
+ if(d.getPDGID() == -11)hasep = true;
+ }
+ }
+ if(hasem&&hasep)
+ {
+ remove.add(p);
+ for(MCParticle d:p.getDaughters())
+ {
+ if(d.getSimulatorStatus().isBackscatter())continue;
+ if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
+ add.add(d);
+ }
+ }
+ }
+ continue;
+ }
+//
+// And on to the general case
+//
+ if(hasTrackableDaughters(p))
+ {
+ remove.add(p);
+ for(MCParticle d:p.getDaughters())
+ {
+ if(d.getSimulatorStatus().isBackscatter())continue;
+ if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
+ add.add(d);
+ }
+ }
+ else
+ {
+ if(tooClose(ep))continue;
+ if(tmap.containsKey(p))continue;
+ remove.add(p);
+ for(MCParticle d:p.getDaughters())
+ {
+ if(d.getSimulatorStatus().isBackscatter())continue;
+ if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
+ add.add(d);
+ }
+ }
+ }
+//
+// Done with pass over original FS particles. Now need to check added particles
+// for further offspring replacement
+//
+ List<MCParticle> newadd = new ArrayList<MCParticle>(add);
+ while(newadd.size() > 0)
+ {
+ List<MCParticle> add2 = new ArrayList<MCParticle>();
+ for(MCParticle p:newadd)
+ {
if(p.getPDGID() == 22)
{
if(hasTrackableDaughters(p))
@@ -216,250 +315,232 @@
}
if(hasem&&hasep)
{
- remove.add(p);
for(MCParticle d:p.getDaughters())
{
if(d.getSimulatorStatus().isBackscatter())continue;
if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
- add.add(d);
+ add2.add(d);
}
+ continue;
}
}
+ tempfs.add(p);
continue;
}
-//
-// And on to the general case
-//
if(hasTrackableDaughters(p))
{
- remove.add(p);
for(MCParticle d:p.getDaughters())
{
if(d.getSimulatorStatus().isBackscatter())continue;
if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
- add.add(d);
+ add2.add(d);
}
}
else
{
- if(tooClose(ep))continue;
- if(tmap.containsKey(p))continue;
- remove.add(p);
- for(MCParticle d:p.getDaughters())
+ if(tooClose(p.getEndPoint()))
{
- if(d.getSimulatorStatus().isBackscatter())continue;
- if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
- add.add(d);
+ tempfs.add(p);
+ continue;
}
- }
- }
-//
-// Done with pass over original FS particles. Now need to check added particles
-// for further offspring replacement
-//
- List<MCParticle> newadd = new ArrayList<MCParticle>(add);
- while(newadd.size() > 0)
- {
- List<MCParticle> add2 = new ArrayList<MCParticle>();
- for(MCParticle p:newadd)
- {
- if(hasTrackableDaughters(p))
+ if(tmap.containsKey(p))
{
- for(MCParticle d:p.getDaughters())
- {
- if(d.getSimulatorStatus().isBackscatter())continue;
- if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
- add2.add(d);
- }
+ tempfs.add(p);
+ continue;
}
- else
+ for(MCParticle d:p.getDaughters())
{
- if(tooClose(p.getEndPoint()))
- {
- tempfs.add(p);
- continue;
- }
- if(tmap.containsKey(p))
- {
- tempfs.add(p);
- continue;
- }
- for(MCParticle d:p.getDaughters())
- {
- if(d.getSimulatorStatus().isBackscatter())continue;
- if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
- add2.add(d);
- }
+ if(d.getSimulatorStatus().isBackscatter())continue;
+ if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
+ add2.add(d);
}
}
- newadd = new ArrayList<MCParticle>(add2);
}
+ newadd = new ArrayList<MCParticle>(add2);
+ }
//
// Now have remove and add lists for a temp fs particle list. Make it.
//
- for(MCParticle p:initfs)
- {
- if(!remove.contains(p))tempfs.add(p);
- }
+ for(MCParticle p:initfs)
+ {
+ if(!remove.contains(p))tempfs.add(p);
+ }
+ to = new TraceOrigin(tempfs);
//
// Now make the recon lists. (Removes untrackable tracks, and invisible particles
//
- Map<MCParticle,Cluster> fsclmap = new HashMap<MCParticle,Cluster>();
- for(Track t:inittracks)
+ Map<MCParticle,Cluster> fsclmap = new HashMap<MCParticle,Cluster>();
+ for(Track t:inittracks)
+ {
+ MCParticle p = ((BaseTrackMC) t).getMCParticle();
+ if(tmap.containsKey(p))
{
- MCParticle p = ((BaseTrackMC) t).getMCParticle();
- if(tmap.containsKey(p))
+ if(tempfs.contains(p))
{
- if(tempfs.contains(p))
- {
- reconfs.add(p);
- fstracks.add(t);
- }
+ reconfs.add(p);
+ fstracks.add(t);
}
}
- for(Cluster c:initclusters)
+ }
+ for(Cluster c:initclusters)
+ {
+ CheatCluster cc = (CheatCluster) c;
+ MCParticle trmc = to.traceit(cc.getMCParticle());
+ if(trmc == null)
+ {
+ nonfsclusters.add(c);
+ }
+ else
{
- CheatCluster cc = (CheatCluster) c;
- MCParticle trmc = cpd.traceit(cc.getMCParticle(),tempfs);
- if(trmc == null)
+ if(fsclmap.containsKey(trmc))
{
- nonfsclusters.add(c);
+ CheatCluster bc = (CheatCluster) fsclmap.get(trmc);
+ bc.addCluster(c);
}
else
{
- if(fsclmap.containsKey(trmc))
- {
- CheatCluster bc = (CheatCluster) fsclmap.get(trmc);
- bc.addCluster(c);
- }
- else
- {
- CheatCluster bc = new CheatCluster(trmc);
- bc.addCluster(c);
- fsclmap.put(trmc, bc);
- if(!reconfs.contains(trmc))reconfs.add(trmc);
- }
+ CheatCluster bc = new CheatCluster(trmc);
+ bc.addCluster(c);
+ fsclmap.put(trmc, bc);
+ if(!reconfs.contains(trmc))reconfs.add(trmc);
}
}
- List<MCParticle> rm = new ArrayList<MCParticle>();
- for(MCParticle p:reconfs)
+ }
+ List<MCParticle> rm = new ArrayList<MCParticle>();
+ for(MCParticle p:reconfs)
+ {
+ if(p.getCharge() != 0)
{
- if(p.getCharge() != 0)
+ if(!tmap.containsKey(p))
{
- if(!tmap.containsKey(p))
- {
- rm.add(p);
- untrackedchargedclusters.add(fsclmap.get(p));
- fsclmap.remove(p);
- }
+ rm.add(p);
+ untrackedchargedclusters.add(fsclmap.get(p));
+ fsclmap.remove(p);
}
}
- for(MCParticle p:rm)
+ }
+ for(MCParticle p:rm)
+ {
+ reconfs.remove(p);
+ }
+ event.put(outFSname,reconfs,MCParticle.class,0);
+ int flag = 1<<LCIOConstants.TRBIT_HITS;
+ event.put(outTname,fstracks,BaseTrackMC.class,flag);
+ flag = 1<<LCIOConstants.CLBIT_HITS;
+ event.put(outCname,new ArrayList(fsclmap.values()),CheatCluster.class,flag);
+ event.put("NonFSReconClusters",nonfsclusters,CheatCluster.class,flag);
+ event.put("UntrackedChargedClusters",untrackedchargedclusters,CheatCluster.class,flag);
+ List<ReconstructedParticle> rrl = new ArrayList<ReconstructedParticle>();
+ for(MCParticle p:reconfs)
+ {
+ MCReconstructedParticle rp = new MCReconstructedParticle(p);
+ if(tmap.containsKey(p))rp.addTrack(tmap.get(p));
+ if(fsclmap.containsKey(p))rp.addCluster(fsclmap.get(p));
+ rrl.add(rp);
+ }
+ event.put(outRname,rrl);
+ }
+ private boolean isTrackable(MCParticle p,Track t)
+ {
+ boolean tr = false;
+//
+// Always return false for neutrals
+//
+ if(p.getCharge() == 0)return tr;
+//
+// Apply a pt cut
+//
+ Hep3Vector m = p.getMomentum();
+ if(Math.sqrt(m.x()*m.x()+m.y()*m.y()) < ptcut)return tr;
+//
+// Apply a minimum length cut
+//
+ Hep3Vector vtx = p.getOrigin();
+ Hep3Vector ep = p.getEndPoint();
+ double d = Math.sqrt( (ep.x()-vtx.x())*(ep.x()-vtx.x()) +
+ (ep.y()-vtx.y())*(ep.y()-vtx.y()) +
+ (ep.z()-vtx.z())*(ep.z()-vtx.z()) );
+ if(d > mintlength)
+ {
+//
+// Apply a minimum #hits cut, which can depend on whether or not
+// the particle makes it to the Ecal.
+//
+ if( (Math.sqrt(ep.x()*ep.x()+ep.y()*ep.y())>emR)||(Math.abs(ep.z())>emZ) )
{
- reconfs.remove(p);
+ if(t.getTrackerHits().size() >= mintfromout)tr=true;
}
- event.put("ReconFSParticles",reconfs,MCParticle.class,0);
- int flag = 1<<LCIOConstants.TRBIT_HITS;
- event.put("ReconTracks",fstracks,BaseTrackMC.class,flag);
- flag = 1<<LCIOConstants.CLBIT_HITS;
- event.put("ReconClusters",new ArrayList(fsclmap.values()),CheatCluster.class,flag);
- event.put("NonFSReconClusters",nonfsclusters,CheatCluster.class,flag);
- event.put("UntrackedChargedClusters",untrackedchargedclusters,CheatCluster.class,flag);
- List<ReconstructedParticle> rrl = new ArrayList<ReconstructedParticle>();
- for(MCParticle p:reconfs)
+ else
{
- MCReconstructedParticle rp = new MCReconstructedParticle(p);
- if(tmap.containsKey(p))rp.addTrack(tmap.get(p));
- if(fsclmap.containsKey(p))rp.addCluster(fsclmap.get(p));
- rrl.add(rp);
+ if(t.getTrackerHits().size() >= mintfromin)tr=true;
}
- event.put("ReconPerfectReconParticles",rrl);
}
- private boolean isTrackable(MCParticle p,Track t)
+ return tr;
+ }
+ private MCParticle getTrackableParent(MCParticle p)
+ {
+ MCParticle ret = null;
+ boolean htp = false;
+ MCParticle par = p;
+ while(!htp&&(par.getParents().size() == 1))
{
- boolean tr = false;
- Hep3Vector m = p.getMomentum();
- if(Math.sqrt(m.x()*m.x()+m.y()*m.y()) < ptcut)return tr;
- Hep3Vector vtx = p.getOrigin();
- Hep3Vector ep = p.getEndPoint();
- double d = Math.sqrt( (ep.x()-vtx.x())*(ep.x()-vtx.x()) +
- (ep.y()-vtx.y())*(ep.y()-vtx.y()) +
- (ep.z()-vtx.z())*(ep.z()-vtx.z()) );
- if(d > mintlength)
- {
- if( (Math.sqrt(ep.x()*ep.x()+ep.y()*ep.y())>emR)||(Math.abs(ep.z())>emZ) )
- {
- if(t.getTrackerHits().size() >= mintfromout)tr=true;
- }
- else
- {
- if(t.getTrackerHits().size() >= mintfromin)tr=true;
- }
- }
- return tr;
+ par = par.getParents().get(0);
+ if(tmap.containsKey(par))htp = true;
}
- private MCParticle getTrackableParent(MCParticle p)
+ if(htp)ret = par;
+ return ret;
+ }
+ private boolean hasTrackableDaughters(MCParticle p)
+ {
+ boolean htd = false;
+ List<MCParticle> check = new ArrayList<MCParticle>();
+ for(MCParticle d:p.getDaughters())
{
- MCParticle ret = null;
- boolean htp = false;
- MCParticle par = p;
- while(!htp&&(par.getParents().size() == 1))
- {
- par = par.getParents().get(0);
- if(tmap.containsKey(par))htp = true;
- }
- if(htp)ret = par;
- return ret;
+ if(d.getSimulatorStatus().isBackscatter())continue;
+ if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
+ check.add(d);
}
- private boolean hasTrackableDaughters(MCParticle p)
+ while(!htd && (check.size() > 0))
{
- boolean htd = false;
- List<MCParticle> check = new ArrayList<MCParticle>();
- for(MCParticle d:p.getDaughters())
+ if(tmap.containsKey(check.get(0)))htd = true;
+ else
{
- if(d.getSimulatorStatus().isBackscatter())continue;
- if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
- check.add(d);
- }
- while(!htd && (check.size() > 0))
- {
- if(tmap.containsKey(check.get(0)))htd = true;
- else
- {
- List<MCParticle> dl = check.get(0).getDaughters();
- check.remove(0);
- for(MCParticle d:dl)
- {
- if(d.getSimulatorStatus().isBackscatter())continue;
- if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
- check.add(d);
- }
+ List<MCParticle> dl = check.get(0).getDaughters();
+ check.remove(0);
+ for(MCParticle d:dl)
+ {
+ if(d.getSimulatorStatus().isBackscatter())continue;
+ if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
+ check.add(d);
}
}
- return htd;
}
- private boolean tooClose(Hep3Vector v)
+ return htd;
+ }
+ private boolean tooClose(Hep3Vector v)
+ {
+ boolean tc = false;
+ double vr = Math.sqrt(v.x()*v.x() + v.y()*v.y());
+ if( (vr > emR-tccut)||(Math.abs(v.z()) > emZ-tccut) )
{
- boolean tc = false;
- double vr = Math.sqrt(v.x()*v.x() + v.y()*v.y());
- if( (vr > emR-tccut)||(Math.abs(v.z()) > emZ-tccut) )
- {
- tc = true;
- }
- return tc;
+ tc = true;
}
- private MCParticle getLongestNeutralParent(MCParticle p)
+ return tc;
+ }
+ private MCParticle getLongestNeutralParent(MCParticle p)
+ {
+ MCParticle ret = null;
+ double length = minneutlen;
+ MCParticle par = p;
+ while(par.getParents().size() == 1)
{
- MCParticle ret = null;
- double length = minneutlen;
- MCParticle par = p;
- while(par.getParents().size() == 1)
+ par = par.getParents().get(0);
+ if(par.getCharge() != 0)
{
- par = par.getParents().get(0);
- if(par.getCharge() != 0)
+ Hep3Vector v = par.getOrigin();
+ Hep3Vector e = par.getEndPoint();
+ if(tooClose(e))
{
- Hep3Vector v = par.getOrigin();
- Hep3Vector e = par.getEndPoint();
double l = Math.sqrt( (e.x()-v.x())*(e.x()-v.x()) +
(e.y()-v.y())*(e.y()-v.y()) +
(e.z()-v.z())*(e.z()-v.z()) );
@@ -470,7 +551,36 @@
}
}
}
- return ret;
}
-
+ return ret;
+ }
+ protected void detectorChanged(Detector detector)
+ {
+ super.detectorChanged(detector);
+
+ Map<String,Subdetector> subdets = detector.getSubdetectors();
+ for (Subdetector subdet : subdets.values())
+ {
+ if (subdet.isCalorimeter())
+ {
+ if (subdet.getName().equals("EMBarrel"))
+ {
+ Tube tube = (Tube)subdet.getDetectorElement().getGeometry().getLogicalVolume().getSolid();
+ emR = tube.getInnerRadius();
+ double outerRadius = tube.getOuterRadius();
+ double zHalfLength = tube.getZHalfLength();
+ }
+ if (subdet.getName().equals("EMEndcap"))
+ {
+ Tube tube = (Tube)subdet.getDetectorElement().getChildren().get(0).getGeometry().getLogicalVolume().getSolid();
+ double zHalfLength = tube.getZHalfLength();
+ Hep3Vector v = subdet.getDetectorElement().getChildren().get(0).getGeometry().getPosition();
+ emZ = Math.abs(v.z()) - zHalfLength;
+ }
+ }
+ }
+ System.out.println("Detector change: innerZ = "+emZ+" innerR = "+emR);
+
+ }
+
}