Reaction Class Reference

A process with initial and final states defined in terms of Particles. More...

Inheritance diagram for Reaction:

Inheritance graph
[legend]

Collaboration diagram for Reaction:

Collaboration graph
[legend]

List of all members.


Public Member Functions

 Reaction ()
 No-arg constructor.
Set< ParticlegetInitialState ()
 Get initial state.
Reaction setInitialState (Set< Particle > initialState)
 Set initial state.
Reaction addToInitialState (Particle particle)
 Add a particle (with multiplicity) into the initial state.
Reaction removeFromInitialState (Particle particle)
 Remove a particle (with multiplicity) from the initial state: this will only remove the corresponding multiplicity from the state, without going negative.
Reaction purgeFromInitialState (Particle particle)
 Remove all particles of this type from the initial state.
Set< ParticlegetFinalState ()
 Get final state.
Reaction setFinalState (Set< Particle > finalState)
 Set final state.
Reaction addToFinalState (Particle particle)
 Add a particle (with multiplicity) into the final state.
Reaction removeFromFinalState (Particle particle)
 Remove a particle (with multiplicity) from the final state: this will only remove the corresponding multiplicity from the state, without going negative.
Reaction purgeFromFinalState (Particle particle)
 Remove all particles of this type from the final state.
boolean equals (Object other)
 Compare reactions for equality.
String initialStateToString ()
 String representation of the initial state.
String finalStateToString ()
 String representation of the final state.
String toString ()
 String representation of this Reaction.

Package Functions

.hibernate.annotations.CollectionOfElements.hibernate.annotations. CollectionId (columns=@Column(name="InitialStateId"), type=@org.hibernate.annotations.Type(type="long"), generator="sequence") private Set< Particle > _initialState
 A collection of particles and multiplicities in the initial state.
.hibernate.annotations.CollectionOfElements.hibernate.annotations. CollectionId (columns=@Column(name="FinalStateId"), type=@org.hibernate.annotations.Type(type="long"), generator="sequence") private Set< Particle > _finalState
 A collection of particles and multiplicities in the final state.
Logger log ()
 Neat method to allow every class to get hold of a custom-named Logger.

Detailed Description

A process with initial and final states defined in terms of Particles.

Author:
Andy Buckley
Version:
Date
2007-10-26 18:14:44 +0100 (Fri, 26 Oct 2007)
Revision
1110

Definition at line 19 of file Reaction.java.


Constructor & Destructor Documentation

Reaction (  ) 

No-arg constructor.

Definition at line 46 of file Reaction.java.

00046 {}


Member Function Documentation

.hibernate.annotations.CollectionOfElements.hibernate.annotations. CollectionId ( columns  = @Column(name="InitialStateId"),
type  = @org.hibernate.annotations.Type(type="long"),
generator  = "sequence" 
) [package]

A collection of particles and multiplicities in the initial state.

.hibernate.annotations.CollectionOfElements.hibernate.annotations. CollectionId ( columns  = @Column(name="FinalStateId"),
type  = @org.hibernate.annotations.Type(type="long"),
generator  = "sequence" 
) [package]

A collection of particles and multiplicities in the final state.

Set<Particle> getInitialState (  ) 

Get initial state.

Definition at line 52 of file Reaction.java.

Referenced by Reaction.equals().

00052                                            {
00053         return _initialState;
00054     }

Reaction setInitialState ( Set< Particle initialState  ) 

Set initial state.

Definition at line 56 of file Reaction.java.

00056                                                                 {
00057         _initialState = initialState;
00058         return this;
00059     }

Reaction addToInitialState ( Particle  particle  ) 

Add a particle (with multiplicity) into the initial state.

If a particle of the same type already exists, the multiplicities will be combined.

Definition at line 64 of file Reaction.java.

References Particle.getMultiplicity().

00064                                                          {
00065         boolean foundType = false;
00066         for (Particle p : _initialState) {
00067             if (Particle.sameType(p, particle)) {
00068                 foundType = true;
00069                 p.setMultiplicity(p.getMultiplicity() + particle.getMultiplicity());
00070                 break;
00071             }
00072         }
00073         if (!foundType) _initialState.add(particle);
00074         return this;
00075     }

Reaction removeFromInitialState ( Particle  particle  ) 

Remove a particle (with multiplicity) from the initial state: this will only remove the corresponding multiplicity from the state, without going negative.

If you want to remove all the particles of a given type from the state, use purgeFromInitialState().

Definition at line 82 of file Reaction.java.

References Particle.getMultiplicity().

00082                                                               {
00083         for (Particle p : _initialState) {
00084             if (Particle.sameType(p, particle)) {
00085                 int newMult = p.getMultiplicity() - particle.getMultiplicity();
00086                 if (newMult <= 0) {
00087                     _initialState.remove(p);
00088                 } else {
00089                     p.setMultiplicity(newMult);
00090                 }
00091                 break;
00092             }
00093         }
00094         return this;
00095     }

Reaction purgeFromInitialState ( Particle  particle  ) 

Remove all particles of this type from the initial state.

Definition at line 97 of file Reaction.java.

00097                                                              {
00098         for (Particle p : _initialState) {
00099             if (Particle.sameType(p, particle)) {
00100                 _initialState.remove(p);
00101             }
00102         }
00103         return this;
00104     }

Set<Particle> getFinalState (  ) 

Get final state.

Definition at line 108 of file Reaction.java.

Referenced by Reaction.equals().

00108                                          {
00109         return _finalState;
00110     }

Reaction setFinalState ( Set< Particle finalState  ) 

Set final state.

Definition at line 112 of file Reaction.java.

00112                                                             {
00113         _finalState = finalState;
00114         return this;
00115     }

Reaction addToFinalState ( Particle  particle  ) 

Add a particle (with multiplicity) into the final state.

If a particle of the same type already exists, the multiplicities will be combined.

Definition at line 120 of file Reaction.java.

References Particle.getMultiplicity().

00120                                                        {
00121         boolean foundType = false;
00122         for (Particle p : _finalState) {
00123             if (Particle.sameType(p, particle)) {
00124                 foundType = true;
00125                 p.setMultiplicity(p.getMultiplicity() + particle.getMultiplicity());
00126                 break;
00127             }
00128         }
00129         if (!foundType) _finalState.add(particle);
00130         return this;
00131     }

Reaction removeFromFinalState ( Particle  particle  ) 

Remove a particle (with multiplicity) from the final state: this will only remove the corresponding multiplicity from the state, without going negative.

If you want to remove all the particles of a given type from the state, use purgeFromFinalState().

Definition at line 138 of file Reaction.java.

References Particle.getMultiplicity().

00138                                                             {
00139         for (Particle p : _finalState) {
00140             if (Particle.sameType(p, particle)) {
00141                 int newMult = p.getMultiplicity() - particle.getMultiplicity();
00142                 if (newMult <= 0) {
00143                     _finalState.remove(p);
00144                 } else {
00145                     p.setMultiplicity(newMult);
00146                 }
00147                 break;
00148             }
00149         }
00150         return this;
00151     }

Reaction purgeFromFinalState ( Particle  particle  ) 

Remove all particles of this type from the final state.

Definition at line 153 of file Reaction.java.

00153                                                            {
00154         for (Particle p : _finalState) {
00155             if (Particle.sameType(p, particle)) {
00156                 _finalState.remove(p);
00157             }
00158         }
00159         return this;
00160     }

boolean equals ( Object  other  ) 

Compare reactions for equality.

Todo:
Also check YAxis and ReactionGroup relations?

Definition at line 167 of file Reaction.java.

References Reaction.getFinalState(), and Reaction.getInitialState().

00167                                         {
00168         log().debug("Comparing reactions...");
00169         if (this == other) return true;
00170         if (! (other instanceof Reaction)) return false;
00171         final Reaction test = (Reaction) other;
00172 
00173         if (! this.getInitialState().equals( test.getInitialState() )) return false;
00174         if (test.getInitialState() != null && this.getInitialState() != null) {
00175             Set<Particle> is1 = this.getInitialState();
00176             Set<Particle> is2 = test.getInitialState();
00177             if (is1.size() != is2.size()) return false;
00178             for (Particle p : is1) {
00179                 if (! is2.contains(p)) return false;
00180             }
00181         }
00182 
00183         if (! this.getFinalState().equals( test.getFinalState() )) return false;
00184         if (test.getFinalState() != null && this.getFinalState() != null) {
00185             Set<Particle> fs1 = this.getFinalState();
00186             Set<Particle> fs2 = test.getFinalState();
00187             if (fs1.size() != fs2.size()) return false;
00188             for (Particle p : fs1) {
00189                 if (! fs2.contains(p)) return false;
00190             }
00191         }
00192 
00194 
00195         // If not proven guilty...
00196         return true;
00197     }

String initialStateToString (  ) 

String representation of the initial state.

Definition at line 206 of file Reaction.java.

00206                                          {
00207         StringBuffer s = new StringBuffer();
00208         for (Particle ispart : getInitialState()) {
00209             s.append(" " + ispart.toString());
00210         }
00211         return s.toString().trim();
00212     }

String finalStateToString (  ) 

String representation of the final state.

Definition at line 216 of file Reaction.java.

00216                                        {
00217         StringBuffer s = new StringBuffer();
00218         for (Particle fspart : getFinalState()) {
00219             s.append(" " + fspart.toString());
00220         }
00221         return s.toString().trim();
00222     }

String toString (  ) 

String representation of this Reaction.

Reimplemented from Storeable.

Definition at line 226 of file Reaction.java.

00226                              {
00227         StringBuffer s = new StringBuffer();
00228         s.append(initialStateToString());
00229         s.append(" -> ");
00230         s.append(finalStateToString());
00231         return s.toString().trim();
00232     }

Logger log (  )  [package, inherited]


The documentation for this class was generated from the following file:


Generated on Tue Apr 21 15:54:49 2009 for HepData object model by  doxygen 1.5.5