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

PDF.java

Go to the documentation of this file.
00001 package cedar.jetweb.model;
00002 
00003 import java.util.HashMap;
00004 import java.util.Vector;
00005 import java.util.Arrays;
00006 import java.util.Map;
00007 
00018 public class PDF{
00019 
00020     private String name_;
00021     private Integer member_;
00022     private boolean proton_    = false;
00023     private boolean photon_    = false;
00024     private boolean pion_      = false;
00025     private boolean dirtyType_ = true;
00026 
00027     private static HashMap<Integer, String> numberToName_;
00028     private static HashMap<String, Integer> nameToNumber_;
00029     
00030     private static boolean initialise_ = true;
00031 
00032     private static Vector<PDF> knownPDFs_;
00033 
00039     public PDF(Integer member){
00040 
00041     if(initialise_) init();
00042     member_ = member;
00043     setMember(member);
00044     return;
00045     }
00046 
00052     public PDF(String name){
00053     
00054     if(initialise_) init();
00055     name_ = name;
00056     setName(name);
00057     return;
00058     }
00059 
00060     public static Vector<PDF> getKnownPDFs(){
00061     if(initialise_) init();
00062     return knownPDFs_;
00063     }
00064 
00070     public PDF setName(String name){
00071     name_ = name;
00072     dirtyType_ = true;
00073     member_ = nameToNumber_.get(name);
00074     return this;
00075     }
00076 
00082     public PDF setMember(Integer member){
00083     member_ = member;
00084     dirtyType_ = true;
00085     name_ = numberToName_.get(member);
00086     return this;
00087     }
00088 
00093     public Integer getMember(){
00094     return member_;
00095     }
00096 
00101     public String getName(){
00102     return name_;
00103     }
00104 
00111     public boolean isProton(){
00112     if(dirtyType_){
00113         deduceType();
00114     }
00115 
00116     return proton_;
00117     }
00118 
00125     public boolean isPhoton(){
00126     if(dirtyType_){
00127         deduceType();
00128     }
00129     return photon_;
00130     }
00131 
00138     public boolean isPion(){
00139     if(dirtyType_){
00140         deduceType();
00141     }
00142     return pion_;
00143     }
00144 
00149     public PDF setIsPhoton(){
00150     //System.out.println("setting pdf to be photon");
00151     dirtyType_ = false;
00152     proton_ = false;
00153     photon_ = true;
00154     pion_   = false;
00155 
00156     return this;
00157     }
00158 
00163     public PDF setIsProton(){
00164     //System.out.println("setting pdf to be a proton");
00165     dirtyType_ = false;
00166     proton_ = true;
00167     photon_ = false;
00168     pion_ = false;
00169     return this;
00170     }
00171 
00176     public PDF setIsPion(){
00177     dirtyType_ = false;
00178     proton_ = false;
00179     photon_ = false;
00180     pion_   = true;
00181     return this;
00182     }
00183 
00188     public String toString(){
00189     return(getMember().toString());
00190     }
00191 
00197     public boolean equals(Object pdf){
00198     if(pdf==null) return false;
00199     if(!this.getClass().equals(pdf.getClass()))return false;
00200     return getMember().equals(((PDF)pdf).getMember());
00201     }
00202 
00203     private void deduceType(){
00204 
00205     String sMember = member_.toString();
00206     int len = sMember.length();
00207     char initial = sMember.charAt(0);
00208 
00209     //System.out.println("sMember = "+sMember);
00210     //System.out.println("len = "+len);
00211     //System.out.println("initial = "+initial);
00212     //boolean test = initial=='3';
00213     //System.out.println("initial=='3' = "+test);
00214 
00215     if(len==5){
00216         setIsProton();
00217     }else if(len==3 &&
00218          initial=='3'){
00219         setIsPhoton();
00220     }else if(len==3){
00221         setIsPion();
00222     }else{
00223         //do something 
00224     }
00225     return;
00226     }
00227 
00228     private static void init(){
00229 
00230     initialise_ = false;
00231 
00232     nameToNumber_ = new HashMap<String, Integer>();
00233     numberToName_ = new HashMap<Integer, String>();
00234     knownPDFs_ = new Vector<PDF>();
00235 
00236     nameToNumber_.put("GRV-G HO DIS NLO", 352);
00237     nameToNumber_.put("SaS-G 1D (ver.2) LO", 395);
00238     nameToNumber_.put("SaS-G 2D (ver.2) LO", 397);
00239     nameToNumber_.put("WHIT-G 2 LO", 382);
00240 
00241     nameToNumber_.put("CTEQ6m", 10050);
00242     nameToNumber_.put("MRST2004nnlo", 20470);
00243     nameToNumber_.put("ZEUS2005", 60300);
00244 
00245     for(Map.Entry entry: nameToNumber_.entrySet()){
00246 
00247         Integer val = (Integer) entry.getValue();
00248 
00249         numberToName_.put
00250         (val, (String)entry.getKey());
00251 
00252         knownPDFs_.add(new PDF(val));
00253     }
00254 
00255     }
00256 
00257 }

Generated Wed Jan 17 09:14:27 GMT 2007