Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

Collision Class Reference

Inheritance diagram for Collision:

Inheritance graph
[legend]
Collaboration diagram for Collision:

Collaboration graph
[legend]
List of all members.

Detailed Description

A collision describes a set of colliding beams & their energies.

Author:
Jon Butterworth
Version:
Date
2006-07-11 15:14:02 +0100 (Tue, 11 Jul 2006)
Revision
1241

Definition at line 18 of file Collision.java.


Public Member Functions

 Collision (int id) throws JetWebException
 Collision ()
Collision addParticle (Particle p, Integer pNumber) throws JetWebException
void addParticle (Particle p) throws JetWebException
Collection< ParticlegetParticles ()
Integer getNumberOfParticles ()
void setId (int id)
Particle getParticle1 ()
Particle getParticle2 ()
boolean equals (Object obj)
int hashCode ()
int getId ()
boolean retrieve () throws JetWebException
boolean store () throws JetWebException
double getCMEnergy ()
String toString ()

Static Public Member Functions

Vector< CollisiongetAll ()

Private Member Functions

void calcCME ()

Private Attributes

double ecms = -1.0
HashMap< Integer, Particleparticles
int collisionId = 0
Particle particle1
Particle particle2

Constructor & Destructor Documentation

Collision int  id  )  throws JetWebException
 

Create a collision from a unique collision ID.

Definition at line 31 of file Collision.java.

References Collision.collisionId, and Collision.retrieve().

00031                                                     {
00032 
00033     collisionId = id;
00034     retrieve();
00035 
00036     }

Collision  ) 
 

Create an empty collision.

Definition at line 40 of file Collision.java.

00040                        {
00041     }


Member Function Documentation

void addParticle Particle  p  )  throws JetWebException
 

Definition at line 54 of file Collision.java.

References Collision.particles.

00055                            {
00056 
00057     if(particles.size()>=2){
00058         throw new JetWebException("Too many particles for this collision",
00059                       p.getName());
00060     }
00061 
00062     Integer pNumber = null;
00063     Integer ii=1;
00064     while(pNumber==null){
00065         if (particles.get(ii)==null){
00066         pNumber = ii;
00067         } 
00068         ++ii;
00069     }
00070 
00071     if(pNumber >2){
00072         throw new JetWebException("Too many particles for this collision",
00073                       p.getName());
00074     }
00075 
00076     particles.put(pNumber, p);
00077     }

Collision addParticle Particle  p,
Integer  pNumber
throws JetWebException
 

Definition at line 43 of file Collision.java.

References Collision.particles.

Referenced by JetWebLogReader.fillCollision().

00044                           {
00045     if(pNumber >2){
00046         throw new JetWebException("Too many particles for this collision",
00047                       p.getName());
00048     }
00049     particles.put(pNumber, p);
00050 
00051     return this;
00052     }

void calcCME  )  [private]
 

Definition at line 168 of file Collision.java.

References Collision.ecms, Collision.getParticle1(), and Collision.getParticle2().

Referenced by Collision.getCMEnergy().

00168                           {
00169     ecms = 2.*Math.sqrt( getParticle1().getEnergy()*
00170                  getParticle2().getEnergy() );
00171     }

boolean equals Object  obj  ) 
 

Override the Object equals method. Use the processId.

Definition at line 98 of file Collision.java.

References Collision.collisionId, Particle.equals(), Collision.getId(), Collision.getParticle1(), and Collision.getParticle2().

Referenced by MCProcessType.matches().

00098                                      {
00099 
00100     if (obj==null) { return false; }
00101 
00102     if ( !this.getClass().equals(obj.getClass())  ) { return false; }
00103 
00104     Collision c = (Collision)obj;
00105     if (collisionId>0 && c.getId() > 0){
00106         return (collisionId==c.getId());
00107     } else {
00108         return (getParticle1().equals(c.getParticle1()) && 
00109             getParticle2().equals(c.getParticle2()) );
00110     }
00111     }

Vector<Collision> getAll  )  [static]
 

Returns a list of all valid Collisions in the database.

Definition at line 158 of file Collision.java.

00158                                             {
00159     try {
00160         Vector<Collision> colls = DBManager.getAllCollisions();
00161         return colls;
00162     } catch (JetWebException j) {
00163         System.out.println(j);
00164         return null;
00165     }
00166     }

double getCMEnergy  ) 
 

Gets beam centre-of-mass energy

Returns:
ecms

Definition at line 147 of file Collision.java.

References Collision.calcCME(), and Collision.ecms.

Referenced by HTMLJobWriter.getDescription().

00147                                { 
00148     if (ecms<0) {
00149         calcCME();
00150     }
00151     return ecms;
00152     }

int getId  ) 
 

Get the unique ID of the object

Implements Storeable.

Definition at line 115 of file Collision.java.

References Collision.collisionId.

Referenced by HTMLProcessWriter.addNewProcess(), MCProcessType.compareTo(), HTMLProcessWriter.display(), Collision.equals(), JetWebLogReader.fillCollision(), MCProcessType.getCollisionId(), RealPlot.getMCProcessType(), DBManager.selectId(), and HTMLPaperWriter.writePlotEntry().

00115                        { 
00116     if (collisionId==0) {
00117         // See if this collision is one we understand.
00118         try {
00119 
00120         System.out.println("Looking up Collison Id in DB");
00121 
00122         DBManager.selectId(this);
00123 
00124         System.out.println("collision id = "+collisionId);
00125 
00126         } catch (Exception e){
00127         collisionId=-1;
00128         }
00129     }
00130     if (collisionId==0) collisionId=-1;
00131     return collisionId; 
00132     }

Integer getNumberOfParticles  ) 
 

Definition at line 84 of file Collision.java.

References Collision.particles.

Referenced by JetWebLogReader.fillCollision().

00084                                          {
00085     return(particles.size());
00086     }

Particle getParticle1  ) 
 

Definition at line 90 of file Collision.java.

References Collision.particles.

Referenced by Collision.calcCME(), Collision.equals(), MCProcessType.getBeams(), HTMLJobWriter.getDescription(), MCProcessType.hasPhoton(), MCProcessType.hasProton(), and Collision.toString().

00090 { return particles.get(1); }

Particle getParticle2  ) 
 

Definition at line 92 of file Collision.java.

References Collision.particles.

Referenced by Collision.calcCME(), Collision.equals(), MCProcessType.getBeams(), HTMLJobWriter.getDescription(), MCProcessType.hasPhoton(), MCProcessType.hasProton(), and Collision.toString().

00092 { return particles.get(2); }

Collection<Particle> getParticles  ) 
 

Definition at line 80 of file Collision.java.

References Collision.particles.

00080                                               {
00081     return particles.values();
00082     }

int hashCode  ) 
 

Definition at line 113 of file Collision.java.

00113 { return collisionId; }

boolean retrieve  )  throws JetWebException
 

Populate the object in memory from the database. Return true if the information retrieved is up to date.

Implements Storeable.

Definition at line 134 of file Collision.java.

Referenced by Collision.Collision().

00134                                                      {
00135     return DBManager.selectFromDB(this);
00136     }

void setId int  id  ) 
 

Definition at line 88 of file Collision.java.

References Collision.collisionId.

00088 {collisionId = id; }

boolean store  )  throws JetWebException
 

Write the object in memory to the database. If the ID does not exist in the DB the object is inserted as a new entry. If the ID exists, that entry is updated.

Returns:
true if the object was inserted, false otherwise.

Implements Storeable.

Definition at line 138 of file Collision.java.

00138                                                   {
00139     return DBManager.addToDB(this);
00140     }

String toString  ) 
 

Definition at line 173 of file Collision.java.

References Collision.getParticle1(), Collision.getParticle2(), and Particle.toString().

Referenced by HTMLProcessWriter.addNewProcess(), HTMLProcessWriter.display(), MCProcessType.toString(), and HTMLPaperWriter.writePlotEntry().

00173                             {
00174 
00175     StringBuffer str = new StringBuffer();
00176     str.append(getParticle1().getEnergy());
00177     str.append(getParticle1().getName());
00178     str.append("_");
00179     str.append(getParticle2().getEnergy());
00180     str.append(getParticle2().getName());
00181     return str.toString();
00182     }


Member Data Documentation

int collisionId = 0 [private]
 

Definition at line 24 of file Collision.java.

Referenced by Collision.Collision(), Collision.equals(), Collision.getId(), and Collision.setId().

double ecms = -1.0 [private]
 

Definition at line 20 of file Collision.java.

Referenced by Collision.calcCME(), and Collision.getCMEnergy().

Particle particle1 [private]
 

Definition at line 25 of file Collision.java.

Particle particle2 [private]
 

Definition at line 26 of file Collision.java.

HashMap<Integer, Particle> particles [private]
 

Initial value:

 
    new HashMap<Integer Particle>()

Definition at line 22 of file Collision.java.

Referenced by Collision.addParticle(), Collision.getNumberOfParticles(), Collision.getParticle1(), Collision.getParticle2(), and Collision.getParticles().


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

Generated Wed Jan 17 09:14:27 GMT 2007