lcsim/src/org/lcsim/digisim
diff -u -r1.4 -r1.5
--- TempCalHit.java 25 May 2005 17:50:31 -0000 1.4
+++ TempCalHit.java 27 Jun 2005 21:49:09 -0000 1.5
@@ -8,12 +8,21 @@
* hit information between modifiers.
*
* @author Guilherme Lima
- * @version $Id: TempCalHit.java,v 1.4 2005/05/25 17:50:31 lima Exp $
+ * @version $Id: TempCalHit.java,v 1.5 2005/06/27 21:49:09 lima Exp $
*/
class TempCalHit {
private TempCalHit() { };
+ /** copy constructor */
+ public TempCalHit( TempCalHit oldhit ) {
+ this._rawID = oldhit._rawID;
+ this._simHits = new Vector<HitContrib>();
+ for( HitContrib contr : oldhit._simHits ) {
+ this.addContribution( contr.id(), contr.energy(), contr.time() );
+ }
+ }
+
/** same-cell constructor */
public TempCalHit(long simid, double energy, double time) {
_simHits = new Vector<HitContrib>();
@@ -43,17 +52,22 @@
return totEnergy;
}
- /** Changes global energy -- use it with care, as it then
- * becomes different than the sum of contribution energies.
+ public void scaleEnergy(double factor) {
+ for( HitContrib contr : _simHits ) {
+ contr.scale(factor);
+ }
+ _energy *= factor;
+ }
+
+ /** changes global energy. Actually, this changes the energy of
+ * each contribution by the same factor, so that final energy
+ * gets updated to the value provided.
+ * @param energy Final value of total energy
*/
public void setEnergy(double energy) {
- // This should be avoid if possible, because it is better to
- // set the energy of each contribution separately
- if(!_warned) {
-// System.out.println("***** TempCalHit.setEnergy() called. Please avoid it.");
- _warned=true;
- }
- _energy = energy;
+ // set the energy of each contribution separately
+ double factor = energy/_energy;
+ this.scaleEnergy( factor );
}
/** Changes global time stamp -- use it with care, as it then
@@ -92,7 +106,8 @@
}
// choose earliestTime or largestContribTime?!
primaryTime = earliestTime;
- return primaryTime;
+ _time = primaryTime;
+ return _time;
}
/** Adds contribution from a simulated hit */
@@ -170,6 +185,7 @@
private double _time;
/** Cell IDs contributing to this TempCalHit object */
private Vector<HitContrib> _simHits;
+
/** Internal notification flag */
private static boolean _warned = false;
private static boolean _warned1 = false;