7 added files
lcsim/src/org/lcsim/recon/cheater
diff -N PPRDriverRealTracking.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PPRDriverRealTracking.java 26 Oct 2010 20:14:22 -0000 1.1
@@ -0,0 +1,43 @@
+/*
+ * PPRDriver.java
+ *
+ * Created on September 4, 2007, 7:47 AM
+ *
+ * To change this template, choose Tools | Options and locate the template under
+ * the Source Creation and Management node. Right-click the template and choose
+ * Open. You can then make changes to the template in the Source Editor.
+ */
+
+package org.lcsim.recon.cheater;
+import org.lcsim.util.Driver;
+import org.lcsim.recon.cluster.util.ClusterEnergyCalculator;
+
+/**
+ *
+ * @author cassell
+ */
+public class PPRDriverRealTracking extends Driver
+{
+ PPRParticleDriverRealTracking d;
+ /** Creates a new instance of PPRDriver */
+ public PPRDriverRealTracking(String in,String out,String xtrat)
+ {
+ d = new PPRParticleDriverRealTracking(in, out, xtrat);
+ add(d);
+ }
+ public PPRDriverRealTracking(String in,String out,String xtrat,int mc)
+ {
+ d = new PPRParticleDriverRealTracking(in, out, xtrat);
+ d.setMinCalorimeterHits(mc);
+ add(d);
+ }
+ public void setPhotonClusterEnergyCalculator(ClusterEnergyCalculator cec)
+ {
+ d.setPhotonClusterEnergyCalculator(cec);
+ }
+ public void setNeutralHadronClusterEnergyCalculator(ClusterEnergyCalculator cec)
+ {
+ d.setNeutralHadronClusterEnergyCalculator(cec);
+ }
+
+}
lcsim/src/org/lcsim/recon/cheater
diff -N PPRParticleDriverRealTracking.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PPRParticleDriverRealTracking.java 26 Oct 2010 20:14:22 -0000 1.1
@@ -0,0 +1,134 @@
+/*
+ * PPRParticleDriver.java
+ *
+ * Created on March 2, 2007, 6:11 AM
+ *
+ * To change this template, choose Tools | Options and locate the template under
+ * the Source Creation and Management node. Right-click the template and choose
+ * Open. You can then make changes to the template in the Source Editor.
+ */
+package org.lcsim.recon.cheater;
+
+import org.lcsim.event.MCParticle;
+import org.lcsim.util.Driver;
+import java.util.ArrayList;
+import java.util.List;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.Track;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.recon.cluster.util.BasicCluster;
+import org.lcsim.recon.cluster.util.ClusterEnergyCalculator;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.base.MCReconstructedParticle;
+import org.lcsim.event.base.BaseReconstructedParticle;
+import org.lcsim.util.lcio.LCIOConstants;
+
+/**
+ *
+ * @author cassell
+ */
+public class PPRParticleDriverRealTracking extends Driver
+{
+
+ String inlist;
+ String outlist;
+ String outlistMC;
+ String xtralist;
+ int minChits = 5;
+ PPRReconParticleConstructorRealTracking crpc;
+ ClusterEnergyCalculator calc;
+ ClusterEnergyCalculator scalc;
+ /** Creates a new instance of PPRParticleDriver */
+ public PPRParticleDriverRealTracking(String in,String out,String xtra)
+ {
+ inlist = in;
+ outlist = out;
+ outlistMC = null;
+ xtralist = xtra;
+ }
+ /** Creates a new instance of PPRParticleDriver */
+ public PPRParticleDriverRealTracking(String in,String out,String xtra, String outMC)
+ {
+ inlist = in;
+ outlist = out;
+ outlistMC = outMC;
+ xtralist = xtra;
+ }
+ public void setMinCalorimeterHits(int n)
+ {
+ minChits = n;
+ }
+ public void setPhotonClusterEnergyCalculator(ClusterEnergyCalculator cec)
+ {
+ scalc = cec;
+ }
+ public void setNeutralHadronClusterEnergyCalculator(ClusterEnergyCalculator cec)
+ {
+ calc = cec;
+ }
+ protected void process(EventHeader event)
+ {
+// System.out.println("Making PPR list from "+inlist);
+ List<MCReconstructedParticle> rl = event.get(MCReconstructedParticle.class,inlist);
+ List<ReconstructedParticle>outrl = new ArrayList<ReconstructedParticle>();
+ List<ReconstructedParticle>outrls = new ArrayList<ReconstructedParticle>();
+ List<MCParticle>outrlMC = new ArrayList<MCParticle>();
+ List<Track> xtl = event.get(Track.class,xtralist);
+ crpc = new PPRReconParticleConstructorRealTracking();
+ crpc.setMinCalorimeterHits(minChits);
+ if(calc != null)crpc.setNeutralHadronClusterEnergyCalculator(calc);
+ if(scalc != null)crpc.setPhotonClusterEnergyCalculator(scalc);
+ List<Cluster> pprclusters = new ArrayList<Cluster>();
+ for(MCReconstructedParticle p:rl)
+ {
+ ReconstructedParticle rp = crpc.makeReconParticle(p);
+ if(rp.getEnergy() > 0.)
+ {
+ BaseReconstructedParticle rps = new BaseReconstructedParticle(rp.getMass(),rp.asFourVector());
+ rps.setCharge(rp.getCharge());
+ rps.setGoodnessOfPid(rp.getGoodnessOfPID());
+ rps.setParticleIdUsed(rp.getParticleIDUsed());
+ rps.setReferencePoint(rp.getReferencePoint());
+ rps.setStartVertex(rp.getStartVertex());
+ rps.setType(rp.getType());
+ for(Track track:rp.getTracks())
+ {
+ rps.addTrack(track);
+ }
+ BasicCluster pprc = new BasicCluster();
+ for(Cluster cl:rp.getClusters())
+ {
+ for(CalorimeterHit h:cl.getCalorimeterHits())
+ {
+ pprc.addHit(h);
+ }
+ }
+ if(pprc.getCalorimeterHits().size() > 0)
+ {
+ rps.addCluster(pprc);
+ pprclusters.add(pprc);
+ }
+ rp.addParticle(p);
+ outrl.add(rp);
+ outrls.add(rps);
+ outrlMC.add(p.getMCParticle());
+ }
+ }
+ for(Track t:xtl)
+ {
+ ReconstructedParticle p = crpc.makeReconParticleFromTrack(t);
+ outrl.add(p);
+ outrls.add(p);
+ }
+ event.put(outlist,outrl,ReconstructedParticle.class,0);
+ event.put("S"+outlist,outrls,ReconstructedParticle.class,0);
+ int flag = 1<<LCIOConstants.CLBIT_HITS;
+ event.put("PPRClusters",pprclusters,Cluster.class,flag);
+ if (outlistMC != null)
+ {
+ event.put(outlistMC,outrlMC,MCParticle.class,0);
+ }
+ }
+
+}
lcsim/src/org/lcsim/recon/cheater
diff -N PPRReconParticleConstructorRealTracking.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PPRReconParticleConstructorRealTracking.java 26 Oct 2010 20:14:22 -0000 1.1
@@ -0,0 +1,187 @@
+package org.lcsim.recon.cheater;
+
+/*
+ * PPRReconParticleConstructor.java
+ */
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
+import java.util.List;
+
+import org.lcsim.event.Cluster;
+import org.lcsim.event.ParticleID;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.Track;
+import org.lcsim.event.base.BaseReconstructedParticle;
+import org.lcsim.event.util.CheatParticleID;
+import org.lcsim.recon.cluster.nn.NearestNeighborClusterer;
+import org.lcsim.recon.cluster.util.BasicCluster;
+import org.lcsim.recon.cluster.util.Clusterer;
+import org.lcsim.recon.cluster.util.DetailedNeutralHadronClusterEnergyCalculator;
+import org.lcsim.recon.cluster.util.PhotonClusterEnergyCalculator;
+import org.lcsim.recon.cluster.util.ClusterEnergyCalculator;
+import org.lcsim.event.base.MCReconstructedParticle;
+
+/**
+ *
+ * @author cassell
+ */
+public class PPRReconParticleConstructorRealTracking
+{
+ Clusterer clusterer;
+ ClusterEnergyCalculator scalc;
+ ClusterEnergyCalculator calc;
+ int minTrkhits = 3;
+ int minCalhits = 3;
+ double pimass = .1395679;
+ ParticleID pippid;
+ ParticleID pimpid;
+ double mumass = .10566;
+ ParticleID muppid;
+ ParticleID mumpid;
+ double emass = .00051;
+ ParticleID eppid;
+ ParticleID empid;
+ double k0lmass = .497671;
+ ParticleID k0lpid;
+ double photonmass = 0.;
+ ParticleID photonpid;
+ double[] cov = {0.,0.,0.,0.,0.,0.};
+ /** Creates a new instance of PPRReconParticleConstructor */
+ public PPRReconParticleConstructorRealTracking()
+ {
+ scalc = null;
+ calc = null;
+ clusterer = new NearestNeighborClusterer(4,4,2,0,0.);
+ pippid = new CheatParticleID(211);
+ pimpid = new CheatParticleID(-211);
+ mumpid = new CheatParticleID(13);
+ muppid = new CheatParticleID(-13);
+ empid = new CheatParticleID(11);
+ eppid = new CheatParticleID(-11);
+ photonpid = new CheatParticleID(22);
+ k0lpid = new CheatParticleID(130);
+ }
+ public void setMinCalorimeterHits(int n)
+ {
+ minCalhits = n;
+ }
+ public void setPhotonClusterEnergyCalculator(ClusterEnergyCalculator cec)
+ {
+ scalc = cec;
+ }
+ public void setNeutralHadronClusterEnergyCalculator(ClusterEnergyCalculator cec)
+ {
+ calc = cec;
+ }
+ public ReconstructedParticle makeReconParticle(
+ MCReconstructedParticle p)
+ {
+ if(scalc == null)scalc = new PhotonClusterEnergyCalculator();
+ if(calc == null)calc = new DetailedNeutralHadronClusterEnergyCalculator();
+ double E = 0.;
+ double px = 0.;
+ double py = 0.;
+ double pz = 0.;
+ Hep3Vector mom;
+ mom = new BasicHep3Vector(px,py,pz);
+ Hep3Vector ref = new BasicHep3Vector(px,py,pz);
+ if(p.getTracks().size() == 1)
+ {
+ Track t = p.getTracks().get(0);
+ mom = new BasicHep3Vector(t.getMomentum());
+ double mass = pimass;
+ ParticleID pid = pippid;
+ if(p.getCharge() < 0.)pid = pimpid;
+ int pdg = Math.abs(p.getMCParticle().getPDGID());
+ if(pdg == 11)
+ {
+ mass = emass;
+ pid = empid;
+ if(p.getCharge() > 0.)pid = eppid;
+ }
+ else if(pdg == 13)
+ {
+ mass = mumass;
+ pid = mumpid;
+ if(p.getCharge() > 0.)pid = muppid;
+ }
+ E = Math.sqrt(mom.magnitude()*mom.magnitude() + mass*mass);
+ BaseReconstructedParticle rp = new BaseReconstructedParticle(E,mom);
+ rp.setMass(mass);
+ rp.setCharge(p.getCharge());
+ rp.setReferencePoint(ref);
+ rp.setParticleIdUsed(pid);
+ rp.addParticleID(pid);
+ rp.addTrack(t);
+ for(Cluster c:p.getClusters())
+ {
+ rp.addCluster(c);
+ }
+ return rp;
+ }
+ double mass = 0.;
+ ParticleID pid = photonpid;
+ BasicCluster cc = new BasicCluster();
+ if(p.getClusters().size() > 0)
+ {
+ for(Cluster c:p.getClusters())cc.addCluster(c);
+ if(cc.getCalorimeterHits().size() >= minCalhits)
+ {
+ if((p.getMCParticle().getPDGID() == 22)||(Math.abs(p.getMCParticle().getPDGID()) == 11))
+ {
+ E = scalc.getEnergy(cc);
+ }
+ else
+ {
+ E = calc.getEnergy(cc);
+ if(E < .5)E = .5;
+ mass = k0lmass;
+ pid = k0lpid;
+ }
+ }
+ }
+ if(E > 0.)
+ {
+ List<Cluster> clist = clusterer.createClusters(cc.getCalorimeterHits());
+ double[] pos = {0.,0.,0.};
+ int maxhits = 0;
+ for(Cluster ccc:clist)
+ {
+ if(ccc.getCalorimeterHits().size() > maxhits)
+ {
+ pos = ccc.getPosition();
+ maxhits = ccc.getCalorimeterHits().size();
+ }
+ }
+ double norm = Math.sqrt(E*E - mass*mass)/
+ Math.sqrt(pos[0]*pos[0] + pos[1]*pos[1] + pos[2]*pos[2]);
+ mom = new BasicHep3Vector(pos[0]*norm, pos[1]*norm, pos[2]*norm);
+ }
+ BaseReconstructedParticle nrp = new BaseReconstructedParticle(E,mom);
+ nrp.setMass(mass);
+ nrp.setParticleIdUsed(pid);
+ nrp.addParticleID(pid);
+ for(Cluster c:p.getClusters())nrp.addCluster(c);
+ return nrp;
+ }
+
+ public ReconstructedParticle makeReconParticleFromTrack(
+ Track t)
+ {
+ Hep3Vector mom = new BasicHep3Vector(t.getMomentum());
+ Hep3Vector ref = new BasicHep3Vector(0.,0.,0.);
+ double mass = pimass;
+ double E = Math.sqrt(mom.magnitude()*mom.magnitude() + mass*mass);
+ BaseReconstructedParticle rp = new BaseReconstructedParticle(E,mom);
+ ParticleID pid = pippid;
+ if(t.getCharge() < 0.)pid = pimpid;
+ rp.setCharge(t.getCharge());
+ rp.setReferencePoint(ref);
+ rp.setParticleIdUsed(pid);
+ rp.addParticleID(pid);
+ rp.addTrack(t);
+ return rp;
+ }
+}
lcsim/src/org/lcsim/recon/cheater
diff -N PPRReconDriverRealTracking.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PPRReconDriverRealTracking.java 26 Oct 2010 20:14:22 -0000 1.1
@@ -0,0 +1,45 @@
+package org.lcsim.recon.cheater;
+import org.lcsim.util.Driver;
+import org.lcsim.recon.cluster.util.*;
+import org.lcsim.recon.util.CalInfoDriver;
+
+/**
+ *
+ * @author cassell
+ */
+public class PPRReconDriverRealTracking extends Driver
+{
+ String CheatReconRname = "ReconPerfectReconParticles";
+ String PPRPflowRname = "PPRReconParticles";
+ String CheatReconFSname = "ReconFSParticles";
+ String ExtraTracks = "ExtraTracks";
+ public PPRReconDriverRealTracking()
+ {
+//
+// Make calorimeter information available
+//
+ add(new CalInfoDriver());
+ // Run tracking.
+ add(new org.lcsim.recon.tracking.seedtracker.ReconTracking.SiD02ReconTrackingDriver());
+//
+// Do the cheating reconstruction (includes Digisim)
+//
+ CheatReconDriverRealTracking crd = new CheatReconDriverRealTracking();
+ crd.setCheatReconstructedParticleOutputName(CheatReconRname);
+ crd.setCheatFSParticleOutputName(CheatReconFSname);
+ add(crd);
+
+
+
+//
+// Make the perfect pattern recognition pflow reconstructed particles from the
+// Cheat Recon particles
+//
+ PPRDriverRealTracking pprd = new PPRDriverRealTracking(CheatReconRname,PPRPflowRname,ExtraTracks);
+ ClusterEnergyCalculator pcec = new QPhotonClusterEnergyCalculator();
+ pprd.setPhotonClusterEnergyCalculator(pcec);
+ ClusterEnergyCalculator nhcec = new QNeutralHadronClusterEnergyCalculator();
+ pprd.setNeutralHadronClusterEnergyCalculator(nhcec);
+ add(pprd);
+ }
+}
lcsim/src/org/lcsim/recon/cheater
diff -N CheatReconDriverRealTracking.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CheatReconDriverRealTracking.java 26 Oct 2010 20:14:22 -0000 1.1
@@ -0,0 +1,380 @@
+/*
+ * CheatReconDriver.java
+ *
+ * Created on April 27, 2007, 6:12 AM
+ *
+ * Driver to do a cheat reconstruction. Output is lists of FSparticles, clusters,
+ * tracks, and reconstructed particles
+ */
+
+package org.lcsim.recon.cheater;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.Track;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.base.MCReconstructedParticle;
+import org.lcsim.recon.cluster.cheat.CheatClusterDriver;
+import org.lcsim.recon.cluster.cheat.CheatCluster;
+import org.lcsim.recon.cluster.util.TraceOrigin;
+import org.lcsim.event.util.CreateFinalStateMCParticleList;
+import org.lcsim.digisim.DigiPackageDriver;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import org.lcsim.util.lcio.LCIOConstants;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.BasicHep3Vector;
+import org.lcsim.event.LCRelation;
+import org.lcsim.digisim.MyLCRelation;
+import org.lcsim.recon.util.CalorimeterInformation;
+import org.lcsim.geometry.Calorimeter.CalorimeterType;
+import org.lcsim.recon.tracking.cheat.*;
+/**
+ *
+ * @author cassell
+ */
+public class CheatReconDriverRealTracking extends Driver
+{
+ String inFSname = "GenFinalStateParticles";
+ String inTname = "Tracks";
+ String tempPname = "TempCheatParticles";
+ String inCname = "RefinedCheatClusters";
+ String outRname;
+ String outVRname;
+ String outGenRname;
+ String outGenVRname;
+ String outFSname;
+ String outTrFSname;
+ String outCname;
+ String[] diginames;
+ double trackMaxPCut = 250.;
+//
+// Default parameters for defining "trackable" track
+//
+ double emR = 1270.;
+ double emZ = 1680.;
+// Too close cut
+ double tccut = 200.;
+ Map<MCParticle,Track> tmap;
+ TraceOrigin to;
+ boolean init;
+ TrackMCParticleDriver tmcd;
+ /** Creates a new instance of CheatSimReconParticleDriver */
+ public CheatReconDriverRealTracking()
+ {
+ outRname = "ReconPerfectReconParticles";
+ outVRname = "ReconPerfectVisReconParticles";
+ outGenRname = "GenPerfectReconParticles";
+ outGenVRname = "GenPerfectVisReconParticles";
+ outFSname = "ReconFSParticles";
+ outTrFSname = "TrackedReconFSParticles";
+ outCname = "ReconClusters";
+//
+// Make an initial list of MCParticles to be considered
+//
+ CreateFinalStateMCParticleList cfs = new CreateFinalStateMCParticleList("Gen");
+ cfs.setCollectionName(inFSname);
+ add(cfs);
+//
+// Make CalorimeterHit Cheat Clusters
+//
+ add(new DigiPackageDriver());
+ init = false;
+ diginames = new String[4];
+ // output of DigiSim is hit collections - EcalBarrDigiHits, EcalEndcapDigiHits, HcalBarrDigiHits, HcalEndcapDigiHits
+ add(new CheatClusterDriver(diginames, inCname));
+ tmcd = new TrackMCParticleDriver();
+ add(tmcd);
+ }
+ public void setCheatClusterOutputName(String s)
+ {outCname = s;}
+ public void setCheatFSParticleOutputName(String s)
+ {outFSname = s;}
+ public void setCheatTrackedFSParticleOutputName(String s)
+ {outTrFSname = s;}
+ public void setCheatReconstructedParticleOutputName(String s)
+ {outRname = s;}
+ public void setCheatVisReconstructedParticleOutputName(String s)
+ {outVRname = s;}
+ public void setGenReconstructedParticleOutputName(String s)
+ {outGenRname = s;}
+ public void setGenVisReconstructedParticleOutputName(String s)
+ {outGenVRname = s;}
+ public void setTooCloseCut(double x)
+ {tccut = x;}
+ public void setTrackMaxPCut(double x){trackMaxPCut = x;}
+ public void process(EventHeader event)
+ {
+ if(!init)
+ {
+ init = true;
+ CalorimeterInformation ci = CalorimeterInformation.instance();
+ diginames[0] = ci.getDigiCollectionName(CalorimeterType.EM_BARREL);
+ diginames[1] = ci.getDigiCollectionName(CalorimeterType.EM_ENDCAP);
+ diginames[2] = ci.getDigiCollectionName(CalorimeterType.HAD_BARREL);
+ diginames[3] = ci.getDigiCollectionName(CalorimeterType.HAD_ENDCAP);
+ emR = ci.getRMin(CalorimeterType.EM_BARREL);
+ emZ = ci.getZMin(CalorimeterType.EM_ENDCAP);
+ }
+ super.process(event);
+ List<MCParticle> initfs = event.get(MCParticle.class,inFSname);
+ List<Track> intracks = event.get(Track.class,inTname);
+ List<Track> inittracks = new ArrayList<Track>(intracks);
+ // Remove extreme p tracks
+ for(Track t:intracks)
+ {
+ if(new BasicHep3Vector(t.getMomentum()).magnitude() > trackMaxPCut)inittracks.remove(t);
+ }
+ List<Cluster> initclusters = event.get(Cluster.class,inCname);
+ List<MCParticle> reconfs = new ArrayList<MCParticle>();
+ List<MCParticle> trreconfs = new ArrayList<MCParticle>();
+ List<Track> tracks = new ArrayList<Track>();
+ List<Cluster> fsclusters = new ArrayList<Cluster>();
+ List<Cluster> nonfsclusters = new ArrayList<Cluster>();
+ List<ReconstructedParticle> perfect = new ArrayList<ReconstructedParticle>();
+ List<ReconstructedParticle> visperfect = new ArrayList<ReconstructedParticle>();
+ List<ReconstructedParticle> genperfect = new ArrayList<ReconstructedParticle>();
+ List<ReconstructedParticle> genvisperfect = new ArrayList<ReconstructedParticle>();
+ tmap = new HashMap<MCParticle,Track>();
+//
+// Make a map of trackable tracks, and add LCRelations to event:
+// "ReconTracksToMCP" -> from=Track, to = MCParticle
+// "TracksToParent" -> from=Track, to=Track, linking tracks to parent tracks. Most to Tracks are null
+//
+ List<LCRelation> lcrelationList = new ArrayList<LCRelation>();
+ List<Track> xtrat = new ArrayList<Track>();
+ for(Track t:inittracks)
+ {
+ MCParticle p = tmcd.getMCParticle(t);
+ if(tmap.containsKey(p))
+ {
+ Track t2 = tmap.get(p);
+ double frac = tmcd.getFraction(t);
+ double frac2 = tmcd.getFraction(t2);
+ if(frac*t.getTrackerHits().size() <= frac2*t2.getTrackerHits().size())
+ {
+ xtrat.add(t);
+ }
+ else
+ {
+ xtrat.add(t2);
+ tmap.remove(p);
+ tmap.put(p,t);
+ tracks.remove(t2);
+ tracks.add(t);
+ }
+ }
+ else
+ {
+ tmap.put(p,t);
+ tracks.add(t);
+ trreconfs.add(p);
+ }
+ }
+ for(MCParticle p:tmap.keySet())
+ {
+ Track t = tmap.get(p);
+ lcrelationList.add(new MyLCRelation(t,p));
+ }
+ event.put("ReconTracksToMCP", lcrelationList, LCRelation.class, 0);
+//
+// Start with the generator final state particles
+//
+ TraceOrigin tot = new TraceOrigin(new ArrayList<MCParticle>(tmap.keySet()));
+ for(MCParticle p:initfs)
+ {
+ if(tmap.containsKey(p))
+ {
+ reconfs.add(p);
+ continue;
+ }
+ if(tot.traceit(p) != null)continue;
+//
+// For the majority of generator fs particles, they originate near the ip
+// and end near or beyond the Ecal. Just keep them, unless they trace back
+// to a track.
+//
+ Hep3Vector vtx = p.getOrigin();
+ Hep3Vector ep = p.getEndPoint();
+ if(vtx.magnitude() < tccut)
+ {
+ if( (Math.sqrt(ep.x()*ep.x()+ep.y()*ep.y())>emR-tccut)||(Math.abs(ep.z())>emZ-tccut) )
+ {
+ reconfs.add(p);
+ continue;
+ }
+ }
+//
+// Check if we really want the parent: Only if the vtx is close to Ecal
+//
+ if( (Math.sqrt(vtx.x()*vtx.x()+vtx.y()*vtx.y())>emR-tccut)||(Math.abs(vtx.z())>emZ-tccut) )
+ {
+ MCParticle par = p.getParents().get(0);
+ Hep3Vector pvtx = par.getOrigin();
+ while( (Math.sqrt(pvtx.x()*pvtx.x()+pvtx.y()*pvtx.y())>emR-tccut)||(Math.abs(pvtx.z())>emZ-tccut) )
+ {
+ par = par.getParents().get(0);
+ pvtx = par.getOrigin();
+ }
+// System.out.println("Parent replacement: vtx close to Ecal");
+ if(!reconfs.contains(par))
+ {
+ reconfs.add(par);
+// System.out.println("Adding to FS list "+par.getType().getName()+": E = "+par.getEnergy());
+ }
+// System.out.println("Subtracting from FS list "+p.getType().getName()+": E = "+p.getEnergy());
+ continue;
+ }
+//
+// Done checking for parentage replacement. Now check for offspring replacement
+//
+//
+// If the endpoint is close to or beyond the Ecal, keep it
+//
+ if( (Math.sqrt(ep.x()*ep.x()+ep.y()*ep.y())>emR-tccut)||(Math.abs(ep.z())>emZ-tccut) )
+ {
+ reconfs.add(p);
+ continue;
+ }
+//
+// Now do the offspring replacement. Only keep trackable particles and
+// particles which reach the Ecal.
+//
+ List<MCParticle> repl = new ArrayList<MCParticle>(p.getDaughters());
+ while(repl.size() > 0)
+ {
+ MCParticle d = repl.get(0);
+ repl.remove(d);
+ if(d.getSimulatorStatus().isBackscatter())continue;
+ if(d.getSimulatorStatus().vertexIsNotEndpointOfParent())continue;
+ if(tmap.containsKey(d))
+ {
+ reconfs.add(d);
+ continue;
+ }
+ Hep3Vector dep = d.getEndPoint();
+ if( (Math.sqrt(dep.x()*dep.x()+dep.y()*dep.y())>emR)||(Math.abs(dep.z())>emZ) )
+ {
+ reconfs.add(d);
+ }
+ else
+ {
+ repl.addAll(d.getDaughters());
+ }
+ }
+ }
+ for(MCParticle p:new ArrayList<MCParticle>(tmap.keySet()))
+ {
+ if(!reconfs.contains(p))reconfs.add(p);
+ }
+// System.out.println("Done with replacement lists:");
+// System.out.println("E GenFS = "+Einit+": Added E = "+Eadd+": Subtracted E = "+Esub);
+//
+// Now make the recon lists.
+//
+//
+// Now the clusters. Trace the cheated clusters back to the reconfs
+// list. Also trace to genfs list.
+//
+ to = new TraceOrigin(reconfs);
+ Map<MCParticle,Cluster> fsclmap = new HashMap<MCParticle,Cluster>();
+ TraceOrigin gento = new TraceOrigin(initfs);
+ Map<MCParticle,Cluster> genfsclmap = new HashMap<MCParticle,Cluster>();
+ for(Cluster c:initclusters)
+ {
+ CheatCluster cc = (CheatCluster) c;
+ MCParticle trmc = to.traceit(cc.getMCParticle());
+ if(trmc == null)
+ {
+ nonfsclusters.add(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);
+ }
+ }
+ trmc = gento.traceit(cc.getMCParticle());
+ if(trmc != null)
+ {
+ if(genfsclmap.containsKey(trmc))
+ {
+ CheatCluster bc = (CheatCluster) genfsclmap.get(trmc);
+ bc.addCluster(c);
+ }
+ else
+ {
+ CheatCluster bc = new CheatCluster(trmc);
+ bc.addCluster(c);
+ genfsclmap.put(trmc, bc);
+ }
+ }
+ }
+//
+// Have the map, make the list of clusters
+//
+ fsclusters.addAll(fsclmap.values());
+//
+// Output the lists to event
+//
+ event.put(outFSname,reconfs,MCParticle.class,0);
+ event.getMetaData(reconfs).setSubset(true);
+ event.put(outTrFSname,trreconfs,MCParticle.class,0);
+ event.getMetaData(trreconfs).setSubset(true);
+ int flag = 1<<LCIOConstants.CLBIT_HITS;
+ event.put(outCname,fsclusters,CheatCluster.class,flag);
+ event.put("NonFSReconClusters",nonfsclusters,CheatCluster.class,flag);
+ event.put("ExtraTracks",xtrat);
+ for(MCParticle p:reconfs)
+ {
+//
+// Eliminate the neutrinos
+//
+ int pid = Math.abs(p.getPDGID());
+ if( (pid == 12)||(pid == 14)||(pid == 16) )continue;
+ MCReconstructedParticle rp = new MCReconstructedParticle(p);
+ if(tmap.containsKey(p))rp.addTrack(tmap.get(p));
+ if(fsclmap.containsKey(p))rp.addCluster(fsclmap.get(p));
+ perfect.add(rp);
+ if(tmap.containsKey(p)||fsclmap.containsKey(p))visperfect.add(rp);
+ }
+ event.put(outRname,perfect);
+ event.put(outVRname,visperfect);
+ for(MCParticle p:initfs)
+ {
+//
+// Eliminate the neutrinos
+//
+ int pid = Math.abs(p.getPDGID());
+ if( (pid == 12)||(pid == 14)||(pid == 16) )continue;
+ MCReconstructedParticle rp = new MCReconstructedParticle(p);
+ if(tmap.containsKey(p))rp.addTrack(tmap.get(p));
+ List<MCParticle> dlist = new ArrayList<MCParticle>(p.getDaughters());
+ while(dlist.size() > 0)
+ {
+ MCParticle d = dlist.get(0);
+ dlist.remove(d);
+ if(tmap.containsKey(d))rp.addTrack(tmap.get(d));
+ dlist.addAll(d.getDaughters());
+ }
+ if(genfsclmap.containsKey(p))rp.addCluster(genfsclmap.get(p));
+ genperfect.add(rp);
+ if(tmap.containsKey(p)||genfsclmap.containsKey(p))genvisperfect.add(rp);
+ }
+ event.put(outGenRname,genperfect);
+ event.put(outGenVRname,genvisperfect);
+ }
+
+}
lcsim/src/org/lcsim/recon/tracking/cheat
diff -N TrackMCParticleMatcher.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TrackMCParticleMatcher.java 26 Oct 2010 20:14:22 -0000 1.1
@@ -0,0 +1,60 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.lcsim.recon.tracking.cheat;
+import org.lcsim.recon.pfa.identifier.*;
+import org.lcsim.event.LCRelation;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.Track;
+import org.lcsim.event.TrackerHit;
+import java.util.*;
+
+/**
+ *
+ * @author cassell
+ */
+public class TrackMCParticleMatcher
+{
+ List<LCRelation> lcrl;
+ double frac;
+ public TrackMCParticleMatcher(List<LCRelation> rl)
+ {
+ lcrl = rl;
+ }
+ public MCParticle getMCParticle(Track t)
+ {
+ Map<MCParticle,Integer> counter = new HashMap<MCParticle,Integer>();
+ for(TrackerHit h:t.getTrackerHits())
+ {
+ for(LCRelation r:lcrl)
+ {
+ if((TrackerHit)(r.getFrom()) == h)
+ {
+ MCParticle p = (MCParticle)(r.getTo());
+ if(counter.containsKey(p))
+ {
+ int ic = counter.get(p) + 1;
+ counter.remove(p);
+ counter.put(p,ic);
+ }
+ else counter.put(p,1);
+ }
+ }
+ }
+ MCParticle maxmc = null;
+ int maxcnt = 0;
+ for(MCParticle p:counter.keySet())
+ {
+ if(counter.get(p) > maxcnt)
+ {
+ maxcnt = counter.get(p);
+ maxmc = p;
+ }
+ }
+ frac = ((double) maxcnt)/t.getTrackerHits().size();
+ return maxmc;
+ }
+ public double getFraction(){return frac;}
+}
lcsim/src/org/lcsim/recon/tracking/cheat
diff -N TrackMCParticleDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TrackMCParticleDriver.java 26 Oct 2010 20:14:22 -0000 1.1
@@ -0,0 +1,48 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.lcsim.recon.tracking.cheat;
+import org.lcsim.recon.pfa.identifier.*;
+import org.lcsim.event.LCRelation;
+import org.lcsim.util.Driver;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.Track;
+import org.lcsim.event.MCParticle;
+import java.util.*;
+
+/**
+ *
+ * @author cassell
+ */
+public class TrackMCParticleDriver extends Driver
+{
+ Map<Track,MCParticle> tmcmap;
+ Map<Track,Double> fmap;
+ public TrackMCParticleDriver()
+ {
+
+ }
+ protected void process(EventHeader event)
+ {
+ List<Track> tl = event.get(Track.class,"Tracks");
+ List<LCRelation> rl = event.get(LCRelation.class,"HelicalTrackMCRelations");
+ TrackMCParticleMatcher m = new TrackMCParticleMatcher(rl);
+ tmcmap = new HashMap<Track,MCParticle>();
+ fmap = new HashMap<Track,Double>();
+ for(Track t:tl)
+ {
+ tmcmap.put(t, m.getMCParticle(t));
+ fmap.put(t,m.getFraction());
+ }
+ }
+ public MCParticle getMCParticle(Track t)
+ {
+ return tmcmap.get(t);
+ }
+ public double getFraction(Track t)
+ {
+ return fmap.get(t);
+ }
+}
CVSspam 0.2.8