lcsim/src/org/lcsim/contrib/uiowa/structural
diff -u -r1.2 -r1.3
--- EventEnergySum.java 23 Dec 2005 17:24:06 -0000 1.2
+++ EventEnergySum.java 6 Jan 2006 23:00:58 -0000 1.3
@@ -132,6 +132,8 @@
{
m_event = event;
+ String eventDebugInfo = new String();
+
// Read in the clusters:
List<Cluster> inputClusterList = event.get(Cluster.class, m_inputClusterListName);
// Read in the track association map:
@@ -185,7 +187,24 @@
double energySumRawChargedOld = 0.0; // Raw charged energy (old)
double energySumRawChargedRon = 0.0; // Raw charged energy (old)
int countFoundTracks = 0;
+
Set<TrackExtrapolationInfo> helixSet = helixMap.keySet();
+ List<TrackExtrapolationInfo> helixMatchedToUsedClusterList = new Vector<TrackExtrapolationInfo> ();
+ for (TrackExtrapolationInfo helix : helixSet) {
+ CalorimeterHit anchor = helix.getHit();
+ for (Cluster currentCluster : inputClusterList) {
+ List<CalorimeterHit> hitsInCluster = currentCluster.getCalorimeterHits();
+ if (hitsInCluster.contains(anchor)) {
+ helixMatchedToUsedClusterList.add(helix);
+ break;
+ }
+ }
+ if ( !(helixMatchedToUsedClusterList.contains(helix)) ) {
+ MCParticle missingPart = helix.getMCParticle();
+ System.out.println("WARNING when using map '"+m_nameOfHelixToClusterMap+"' for list '"+m_inputClusterListName+"': Missing MC particle: "+missingPart.getType().getName());
+ }
+ }
+
for (Cluster currentCluster : inputClusterList) {
// Is there an associated track?
List<TrackExtrapolationInfo> associatedTracks = new Vector<TrackExtrapolationInfo>();
@@ -195,7 +214,7 @@
if (associatedTrackList != null) { associatedTracks.addAll(associatedTrackList); }
*/
- for (TrackExtrapolationInfo helix : helixSet) {
+ for (TrackExtrapolationInfo helix : helixMatchedToUsedClusterList) {
CalorimeterHit anchor = helix.getHit();
List<CalorimeterHit> hitsInCluster = currentCluster.getCalorimeterHits();
if (hitsInCluster.contains(anchor)) {
@@ -246,18 +265,21 @@
infoDump += ") ";
}
infoDump += "). Crude energy="+sumCrudeEnergyOfThisCluster+"; track energy="+sumEnergyOfThisCluster;
+ eventDebugInfo += infoDump + "\n";
+ /*
System.out.println(infoDump);
+ */
String truthDump = new String("DEBUG: "+this.getClass().getName()+": Here are all contributing particles: ");
List<MCParticle> contributingParticles = assoc.associateClusterToMCParticles(currentCluster);
int hitCountChargedButNoTrack = 0;
int hitCountChargedWithTrack = 0;
int hitCountNeutral = 0;
-
+
for (MCParticle truthPart : contributingParticles) {
if (Math.abs(truthPart.getCharge())>0.5) {
// charged
boolean matchedTrack = false;
- for (TrackExtrapolationInfo helix : helixSet) {
+ for (TrackExtrapolationInfo helix : helixMatchedToUsedClusterList) {
if (helix.getMCParticle() == truthPart && helix.getHit() != null) {
matchedTrack = true;
break;
@@ -301,7 +323,10 @@
truthDump += ") ";
}
truthDump += " *** Hits: "+hitCountNeutral+" neutral, "+hitCountChargedButNoTrack+" charged(bad), "+hitCountChargedWithTrack+" charged(safe)";
+ eventDebugInfo += truthDump + "\n";
+ /*
System.out.println(truthDump);
+ */
}
} else {
// No track
@@ -311,7 +336,10 @@
energySumOldECAL += energyOldECAL;
energySumOldHCAL += energyOldHCAL;
energySumRon += this.getClusterEnergy(currentCluster);
+ /*
System.out.println("DEBUG: "+this.getClass().getName()+": Neutral cluster with "+currentCluster.getCalorimeterHits().size()+" hits contributes "+this.getClusterEnergy(currentCluster)+" (ron) or "+energyOldECAL+" (old ECAL) + "+energyOldHCAL+" (old HCAL)");
+ */
+ eventDebugInfo += "DEBUG: "+this.getClass().getName()+": Neutral cluster with "+currentCluster.getCalorimeterHits().size()+" hits contributes "+this.getClusterEnergy(currentCluster)+" (ron) or "+energyOldECAL+" (old ECAL) + "+energyOldHCAL+" (old HCAL)\n";
String truthDump = new String("DEBUG: "+this.getClass().getName()+": Here are all contributing particles: ");
List<MCParticle> contributingParticles = assoc.associateClusterToMCParticles(currentCluster);
int hitCountChargedButNoTrack = 0;
@@ -327,7 +355,7 @@
if (Math.abs(truthPart.getCharge())>0.5) {
// charged
boolean matchedTrack = false;
- for (TrackExtrapolationInfo helix : helixSet) {
+ for (TrackExtrapolationInfo helix : helixMatchedToUsedClusterList) {
if (helix.getMCParticle() == truthPart && helix.getHit() != null) {
matchedTrack = true;
break;
@@ -371,7 +399,10 @@
truthDump += ")";
}
truthDump += " *** Hits: "+hitCountNeutral+" neutral, "+hitCountChargedButNoTrack+" charged(safe), "+hitCountChargedWithTrack+" charged(bad)";
+ eventDebugInfo += truthDump + "\n";
+ /*
System.out.println(truthDump);
+ */
}
}
@@ -391,10 +422,15 @@
// done
double fracChargedHitsBad = ( (double)(totalChargedHitsBad) / (double)(totalChargedHitsSafe+totalChargedHitsBad));
double fracNeutralHitsBad = ( (double)(totalNeutralHitsBad) / (double)(totalNeutralHitsSafe+totalNeutralHitsBad));
+ eventDebugInfo += "In this event, charged hits: "+totalChargedHitsSafe+" safe and "+totalChargedHitsBad+" bad.\n";
+ eventDebugInfo += "In this event, neutral hits: "+totalNeutralHitsSafe+" safe and "+totalNeutralHitsBad+" bad.\n";
+ /*
System.out.println("In this event, charged hits: "+totalChargedHitsSafe+" safe and "+totalChargedHitsBad+" bad.");
System.out.println("In this event, neutral hits: "+totalNeutralHitsSafe+" safe and "+totalNeutralHitsBad+" bad.");
+ */
m_hFractionChargedHitsBad.fill(fracChargedHitsBad);
m_hFractionNeutralHitsBad.fill(fracNeutralHitsBad);
+ /*
System.out.println("In this event, ECAL energy for charged particles with tracks: "
+energyECAL_ChargedParticleWithTrack_ClusterWithTrack+" (particle with track -> cluster with track) "
+energyECAL_ChargedParticleWithTrack_ClusterWithNoTrack+" (particle with track -> cluster with no track) ");
@@ -413,6 +449,7 @@
System.out.println("In this event, HCAL hits for neutral particles: "
+hitsHCAL_NeutralParticle_ClusterWithTrack+" (particle -> cluster with track) "
+hitsHCAL_NeutralParticle_ClusterWithNoTrack+" (particle -> cluster with no track) ");
+ */
double badECAL_track_to_notrack = energyECAL_ChargedParticleWithTrack_ClusterWithNoTrack;
double goodECAL_track_to_track = energyECAL_ChargedParticleWithTrack_ClusterWithTrack;
double badECAL_notrack_to_track = energyECAL_ChargedParticleWithNoTrack_ClusterWithTrack + energyECAL_NeutralParticle_ClusterWithTrack;
@@ -421,13 +458,15 @@
int goodHCAL_track_to_track = hitsHCAL_ChargedParticleWithTrack_ClusterWithTrack;
int badHCAL_notrack_to_track = hitsHCAL_ChargedParticleWithNoTrack_ClusterWithTrack + hitsHCAL_NeutralParticle_ClusterWithTrack;
int goodHCAL_notrack_to_notrack = hitsHCAL_ChargedParticleWithNoTrack_ClusterWithNoTrack + hitsHCAL_NeutralParticle_ClusterWithNoTrack;
+ /*
System.out.println("ECAL energy bad: "
+badECAL_track_to_notrack+"/"+(badECAL_track_to_notrack+goodECAL_notrack_to_notrack)+" (seen as notrack) "
+badECAL_notrack_to_track+"/"+(badECAL_notrack_to_track+goodECAL_track_to_track)+" (seen as track)");
System.out.println("HCAL hits bad: "
+badHCAL_track_to_notrack+"/"+(badHCAL_track_to_notrack+goodHCAL_notrack_to_notrack)+" (seen as notrack) "
+badHCAL_notrack_to_track+"/"+(badHCAL_notrack_to_track+goodHCAL_track_to_track)+" (seen as track)");
-
+ */
+
m_hECAL_charged_track_to_track .fill(energyECAL_ChargedParticleWithTrack_ClusterWithTrack);
m_hECAL_charged_track_to_notrack .fill(energyECAL_ChargedParticleWithTrack_ClusterWithNoTrack);
@@ -475,14 +514,21 @@
m_hHCAL_charged_notrack_fractionbad.fill(fraction_HCAL_chargednotrack_bad);
m_hHCAL_neutral_fractionbad .fill(fraction_HCAL_neutral_bad);
+ if (fraction_HCAL_chargedtrack_bad > 0.8) {
+ System.out.println("DEBUG: fraction HCAL chargedtrack bad = "+hitsHCAL_ChargedParticleWithTrack_ClusterWithNoTrack+" / "+(hitsHCAL_ChargedParticleWithTrack_ClusterWithNoTrack+hitsHCAL_ChargedParticleWithTrack_ClusterWithTrack)+" = "+fraction_HCAL_chargedtrack_bad);
+ System.out.println(eventDebugInfo);
+ }
+
// Crosschecks
if ( Math.abs((badECAL_track_to_notrack+goodECAL_track_to_track+badECAL_notrack_to_track+goodECAL_notrack_to_notrack)-(energyECAL_ChargedParticleWithTrack_ClusterWithTrack+energyECAL_ChargedParticleWithTrack_ClusterWithNoTrack+energyECAL_ChargedParticleWithNoTrack_ClusterWithTrack+energyECAL_ChargedParticleWithNoTrack_ClusterWithNoTrack+energyECAL_NeutralParticle_ClusterWithTrack+energyECAL_NeutralParticle_ClusterWithNoTrack)) > 0.0001 ) { throw new AssertionError("bookkeeping"); }
if ( ((badHCAL_track_to_notrack+goodHCAL_track_to_track+badHCAL_notrack_to_track+goodHCAL_notrack_to_notrack)-(hitsHCAL_ChargedParticleWithTrack_ClusterWithTrack+hitsHCAL_ChargedParticleWithNoTrack_ClusterWithTrack+hitsHCAL_ChargedParticleWithTrack_ClusterWithNoTrack+hitsHCAL_ChargedParticleWithNoTrack_ClusterWithNoTrack+hitsHCAL_NeutralParticle_ClusterWithTrack+hitsHCAL_NeutralParticle_ClusterWithNoTrack)) != 0 ) { throw new AssertionError("bookkeeping"); }
double oldTotal = energySumCharged+energySumOldECAL+energySumOldHCAL+truthNeutrinoEnergySum;
double newTotal = energySumCharged+energySumRon+truthNeutrinoEnergySum;
+ /*
System.out.println("Charged energy in event = "+energySumCharged+" from "+countFoundTracks+" tracks, "+countChargedClusters+" charged clusters.");
System.out.println("Neutral energy sum in event: old("+(energySumOldECAL+energySumOldHCAL)+"), new("+energySumRon+") and neutrinos="+truthNeutrinoEnergySum+" => total = old("+oldTotal+"), new("+newTotal+") from "+countNeutralClusters+" neutral clusters.");
+ */
double sampFracHCAL = (91.0 - energySumOldECAL - truthNeutrinoEnergySum - energySumCharged) / energySumOldHCAL;
//System.out.println("Sampling fraction in HCAL = "+sampFracHCAL);
m_hSampFrac.fill(sampFracHCAL);