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

LogFile Class Reference

Inheritance diagram for LogFile:

Inheritance graph
[legend]
Collaboration diagram for LogFile:

Collaboration graph
[legend]
List of all members.

Detailed Description

Representation of a log file from a single Monte Carlo batch job.

Author:
Jon Butterworth
Version:
Date
2006-12-14 19:12:11 +0000 (Thu, 14 Dec 2006)
Revision
1337

Definition at line 35 of file LogFile.java.


Public Member Functions

 LogFile (RunSeries lp)
 LogFile (int id)
 LogFile (String name) throws JetWebException
boolean retrieve () throws JetWebException
boolean store () throws JetWebException
JetWebFile getFile ()
void setFile (JetWebFile f)
int getId ()
int getStatus ()
RunSeries getRunSeries () throws JetWebException
Generator getGenerator () throws JetWebException
void setRunSeriesId (int inew)
void setRunSeries (RunSeries newrs)
void setId (int i)
void setStatus (int i) throws JetWebException
LogFile setStatusAsSubmitted ()
void setGenerator (Generator gen) throws JetWebException
LogFile setCrossSection (Double cs)
Double getCrossSection ()
void setLumi (double l)
double getLumi ()
void doChecks () throws JetWebException
String getStem ()
String getXmlFileName () throws JetWebException
void setXmlFile (String path)
boolean hasAidaFile ()
boolean isArchived ()
boolean isValid ()
void setValid (boolean b)
String toString ()
void checkStatus () throws JetWebException

Static Public Attributes

final int RESERVED = 5
final int UNDEFINED = -1
final int SUBMITTED = 0
final int RUN = 1
final int COMPLETED = 2
final int ERROR = 3

Private Member Functions

boolean checkStatus (int i)
void addLogFile () throws JetWebException
synchronized boolean toDB () throws JetWebException
void makePlots () throws JetWebException
void addPlots () throws JetWebException
void dumpStream (InputStream in) throws IOException

Private Attributes

JetWebFile logfile
String xmlFile = ""
int logId = -1
RunSeries runSeries
double lumi = 0.0
Double crossSection_ = -1.0
boolean weighted = false
boolean valid = false
Vector< PredictedPlotmcPlots
int status
int rsId = -1

Static Private Attributes

String SCHEME_PDFLIB = "PDFLIB"

Constructor & Destructor Documentation

LogFile RunSeries  lp  ) 
 

Do nothing constructor. This constructor does not populate any of the fields of the LogFile except for the associated RunSeries, which is the input argument.

Definition at line 79 of file LogFile.java.

References RunSeries.getId(), LogFile.rsId, and LogFile.runSeries.

00079                                 {
00080     runSeries = lp;
00081     rsId = runSeries.getId();
00082 
00083     }

LogFile int  id  ) 
 

Do nothing constructor.

Definition at line 89 of file LogFile.java.

References LogFile.logId.

00089                           {
00090     logId = id;
00091     }

LogFile String  name  )  throws JetWebException
 

Create a new LogFile. Looks in the DB logfile table to see if a file with this name exists. If it does, obtains the status & validity.

Parameters:
name String containing the absolute name+path of the logfile on the server.

Definition at line 100 of file LogFile.java.

References LogFile.retrieve(), LogFile.rsId, LogFile.status, and LogFile.valid.

00100                                                         { 
00101 
00102     try {
00103         // Initialise File.
00104 
00105         this.logfile = new JetWebFile(name);
00106                 
00107         status = LogFile.UNDEFINED;
00108         
00109         // Fill the runSeriesId, the status and logId.
00110         retrieve();
00111         
00112         if (rsId>=0 && status>0) {
00113         // This is a finished logfile which has already been
00114         // added to the DB.
00115         valid = true;
00116         status = LogFile.COMPLETED;
00117         System.out.println("LogFile: Name already used. "+name);
00118         return;
00119         }
00120 
00121     } catch (NullPointerException e){
00122         System.out.println("Caused by "+e.getCause());
00123         System.out.println(e.getMessage());
00124         System.out.println("WARNING: LogFile not properly initialised; JetWebConfig probably not initialised");
00125     }
00126     }


Member Function Documentation

void addLogFile  )  throws JetWebException [private]
 

Definition at line 386 of file LogFile.java.

References RunSeries.getId(), LogFile.lumi, LogFile.rsId, LogFile.runSeries, RunSeries.setId(), RunSeries.setLumi(), and LogFile.valid.

Referenced by LogFile.store().

00387                           {
00388        
00389     try{
00390 
00391         if(runSeries.getId()<0){
00392         rsId = DBManager.matchRunSeriesId(runSeries);
00393         runSeries.setId(rsId);
00394         }
00395 
00396         if(runSeries.getId()>0){
00397         //DBManager.addLumi(lumi, runSeries.getId());
00398         DBManager.addLumi(this);
00399         rsId = runSeries.getId();
00400         }else{
00401         runSeries.setLumi(lumi);
00402         DBManager.addRunSeries(runSeries);
00403         rsId = runSeries.getId();
00404         
00405         }
00406 
00407         DBJobManager.addLogfile(this);
00408     }catch(JetWebException err){
00409         System.out.println
00410         ("Logfile: This file not added - failed updating runSeries");
00411         valid = false;
00412         throw err;
00413     }
00414     return;
00415     }

void addPlots  )  throws JetWebException [private]
 

Definition at line 718 of file LogFile.java.

References PredictedPlot.add(), DataPlot.getNumber(), and PredictedPlot.hasData().

Referenced by LogFile.toDB().

00718                                                    {
00719 
00720     // Add the plots for this logfile to those already associated with 
00721     // this row of runSeries.
00722         
00723     for (PredictedPlot mcPlot : mcPlots){
00724         
00725         // Get the plots associated with this runSeries table.
00726         // Create a DataPlot object from this record and the DataPlot.
00727         PredictedPlot plot2 = null;
00728         plot2 = new PredictedPlot(mcPlot.getCompPlot(),runSeries);
00729         System.out.println(mcPlot.getNumber()+","+plot2.getNumber());
00730         if (plot2.hasData()){
00731         mcPlot.add(plot2);
00732         }
00733     }
00734     }

void checkStatus  )  throws JetWebException
 

Works out the status of this LogFile and sets it.

Definition at line 842 of file LogFile.java.

References LogFile.isValid(), LogFile.setStatus(), LogFile.status, and LogFile.UNDEFINED.

Referenced by LogFile.setStatus().

00842                                                      {
00843     if (isValid() && status!=ERROR){
00844         //setStatus(RUN);
00845         status=RUN;
00846         DBJobManager.checkStatus(this);
00847     } else {
00848         setStatus(UNDEFINED);
00849     }
00850     }

boolean checkStatus int  i  )  [private]
 

Definition at line 336 of file LogFile.java.

References LogFile.COMPLETED, LogFile.RESERVED, LogFile.RUN, LogFile.SUBMITTED, and LogFile.UNDEFINED.

Referenced by JobUtils.getLogFiles(), and JobUtils.getNewData().

00336                                       {
00337     boolean ok = false;
00338     if (i==RESERVED  || 
00339         i==UNDEFINED || 
00340         i==SUBMITTED || 
00341         i==RUN       || 
00342         i==COMPLETED || 
00343         i==ERROR        ){
00344         ok = true;
00345     }
00346     return ok;
00347     }

void doChecks  )  throws JetWebException
 

Make consistency checks on parameters.

Definition at line 482 of file LogFile.java.

References LogFile.getGenerator(), RunSeries.getGenerator(), MCProcessType.getId(), RunSeries.getMCProcessType(), LogFile.getRunSeries(), RunSeries.removeIrrelevantParameters(), LogFile.runSeries, and LogFile.valid.

00482                                                   {
00483     valid=true;
00484 
00485     RunSeries runSeries = getRunSeries();
00486     Generator gen = runSeries.getGenerator();
00487 
00488     // Check we have RunSeries and Generator. 
00489     if ( (runSeries==null) || (getGenerator()==null) ) { 
00490         System.out.println("LogFile: Null runseries or generator");
00491         valid=false;
00492         return;
00493     }
00494     
00495     // Check the consistency etc of the process name.
00496     //runSeries.checkMCProcessType();
00497 
00498     MCProcessType proc = runSeries.getMCProcessType();
00499 
00500     // Check the MCProcessType is one we know about.
00501 
00502 
00503     // Check we have RunSeries and Generator. 
00504     if ( (proc==null) ) { 
00505         System.out.println("LogFile: Null MCProcessType");
00506         valid=false;
00507         return;
00508     }
00509 
00510 
00511     if (proc.getId()<=0) {
00512         System.out.println("LogFile: Unknown ProcessType");
00513         valid=false;
00514         return;
00515     }
00516 
00517 
00518     // Remove any irrelevant parameters.
00519     runSeries.removeIrrelevantParameters();
00520 
00521     // Perform any generator specific consistency checks.
00522     valid = gen.checkParameters();
00523     return;
00524     }

void dumpStream InputStream  in  )  throws IOException [private]
 

Check the known lumi for this logfile against the lumi actually in the file on disk. If they are different, reset to the value from the file. (this is an error repair method). AND NEEDS TO BE REIMPLEMENTED FOR XML

public void updateLumi() throws JetWebException {

Look for control cards in the log file. double newLumi = 0.0;

String name = getFile().getPath(); String line; BufferedReader log; Deal with zipped or unzipped files. try { if (name.indexOf(".gz")>0){ log = new BufferedReader( new InputStreamReader( new GZIPInputStream( new FileInputStream(name)))); } else { System.out.println("Logfile error: unzipped logfile."); return; }

while((line=log.readLine())!=null){

System.out.println(line); int index = line.indexOf(LUMISTR); if ( index >=0 ){ try { newLumi = Double.parseDouble(line.substring(index+LUMISTR.length()).trim()); } catch (Exception e){ System.out.println("LogFile: Failed to parse lumi string"); } }

} } catch (IOException e1) { System.out.println("LogFile: Problem reading log file "+e1); System.out.println("Logfile should be "+name); System.out.println("Ought to delete this - no logfiles exist!"); valid = false; }

if (newLumi!=lumi){ lumi=newLumi; try { DBJobManager.addLogfile(this); } catch (Exception e){ throw new JetWebException(e); } } }

Definition at line 795 of file LogFile.java.

00795                                                                {
00796     BufferedReader br = new BufferedReader(new InputStreamReader(in));
00797     String line;
00798     while ((line = br.readLine()) != null) {
00799     }
00800     }

Double getCrossSection  ) 
 

Get the cross section generated by this logfile

Definition at line 368 of file LogFile.java.

00368                                    {
00369     return crossSection_;
00370     }

JetWebFile getFile  ) 
 

Get the file.

Returns:
the log file of this Monte Carlo run.

Definition at line 209 of file LogFile.java.

Referenced by JobUtils.moveLogs(), and DBJobManager.removeLogFile().

00209 { return logfile; }

Generator getGenerator  )  throws JetWebException
 

See also:
cedar.jetweb.model.RunSeries.getGenerator

Definition at line 264 of file LogFile.java.

References RunSeries.getGenerator(), and LogFile.getRunSeries().

Referenced by LogFile.doChecks(), JobUtils.doJobRequest(), LogFile.makePlots(), and LogFile.toString().

00264                                                            { 
00265     try {
00266         return getRunSeries().getGenerator();
00267     } catch (JetWebException jwe){
00268         return null;
00269     }
00270     }

int getId  ) 
 

Get the unique ID of the LogFile.

Returns:
-1 if undefined.

Implements Storeable.

Definition at line 223 of file LogFile.java.

00223 { return logId;}

double getLumi  ) 
 

Get the integrated luminosity for this logfile.

Definition at line 380 of file LogFile.java.

Referenced by LogFile.toString().

00380 { return lumi;}

RunSeries getRunSeries  )  throws JetWebException
 

Get the associated RunSeries.

Returns:
runSeries contains all the parameters associated with this run.

Definition at line 247 of file LogFile.java.

References RunSeries.getId(), RunSeries.Maker(), LogFile.rsId, and LogFile.runSeries.

Referenced by LogFile.doChecks(), FileUploader.doModelUpload(), LogFile.getGenerator(), JobUtils.getNewData(), LogFile.setGenerator(), LogFile.toDB(), and LogFile.toString().

00247                                                            { 
00248 
00249     if (rsId<0 && runSeries !=null) {
00250 
00251         rsId = runSeries.getId();
00252     } else if ( (runSeries==null && rsId>0) || 
00253          (runSeries!=null) && (runSeries.getId()!=rsId) &&
00254          rsId >= 0)  { 
00255 
00256         //runSeries = new RunSeries(rsId);
00257         runSeries = RunSeries.Maker(rsId);
00258     }
00259     return runSeries; 
00260     }

int getStatus  ) 
 

Get the status for the LogFile.

Returns:
  • UNDEFINED
  • SUBMITTED
  • RUN
  • COMPLETED
See also:
UNDEFINED

SUBMITTED

RUN

COMPLETED

Definition at line 238 of file LogFile.java.

Referenced by JobUtils.getLogFiles(), and JobUtils.getNewData().

00238                            { 
00239     return status;
00240     }

String getStem  ) 
 

Get the LogFile stem.

Returns:
the path for this logfile (relative to app. root) without the trailing oXXXX.gz

Definition at line 532 of file LogFile.java.

References LogFile.logfile.

Referenced by LogFile.hasAidaFile(), LogFile.isArchived(), LogFile.makePlots(), and JobUtils.moveLogs().

00532                            {
00533 
00534     return logfile.directory() + logfile.toString();
00535     }

String getXmlFileName  )  throws JetWebException
 

Get the LogFile xml file.

Returns:
xml filename, including path rel to app. root.

Definition at line 541 of file LogFile.java.

References LogFile.logfile, LogFile.setXmlFile(), and LogFile.xmlFile.

Referenced by JobUtils.getLogFiles(), and JobUtils.getNewData().

00541                                                           {
00542 
00543     String path;
00544 
00545     if (!xmlFile.equals("")){
00546         if(xmlFile.endsWith(JetWebFile.XML)||
00547            xmlFile.endsWith(JetWebFile.XML + ".gz")){
00548         path = xmlFile;
00549         }else{
00550         path = xmlFile + JetWebFile.XML;
00551         }
00552     } else {
00553         path = logfile + logfile.XML;
00554     }
00555     //either .xml or .xml.gz SHOULD exist
00556     //JetWebFile test = new JetWebFile(xmlFile);
00557     JetWebFile test = new JetWebFile(path);
00558 
00559     if(!test.isXML() || !test.exists()){
00560         throw new JetWebException
00561         ("Logfile Error: Attempt to open XML file which does not exist"
00562          ,test + " in directory " + test.directory());
00563     }
00564 
00565     test.Zip();
00566 
00567         setXmlFile(path);
00568 
00569     return  test.fullPath();
00570     }

boolean hasAidaFile  ) 
 

Tests whether aida file exists.

Returns:
boolean exists.

Definition at line 580 of file LogFile.java.

References LogFile.getStem().

Referenced by JobUtils.getLogFiles(), and JobUtils.getNewData().

00580                                 {
00581     boolean exists = false;
00582     String path = getStem();
00583     //.aida SHOULD exist
00584     JetWebFile test = new JetWebFile(path, JetWebFile.AIDA);
00585     if (!test.exists()){
00586         System.out.println
00587         ("Logfile: AIDA File does not exist :"+test.fullPath());
00588     } else {
00589         System.out.println
00590         ("LogFile: Found matching AIDA file");
00591         exists = true;
00592     }
00593     return  exists;
00594     }

boolean isArchived  ) 
 

Tests whether this logfile has already been archived

Returns:
true if the file corresponding to this logfile is archived

Definition at line 601 of file LogFile.java.

References LogFile.getStem().

Referenced by JobUtils.getLogFiles().

00601                                {
00602     boolean archived = false;
00603     String path = getStem();
00604 
00605     JetWebFile test = new JetWebFile(path, JetWebFile.AIDA);
00606 
00607     if(test.exists()){
00608         if(test.isArchived()){
00609         archived = true;
00610         }
00611     }
00612     return archived;
00613     }

boolean isValid  ) 
 

Check whether this is a valid LogFile.

Returns:
true if the batch job terminated properly and its parameters could be read.

Definition at line 623 of file LogFile.java.

Referenced by LogFile.checkStatus(), and LogFile.toString().

00623 {return valid;}

void makePlots  )  throws JetWebException [private]
 

Definition at line 629 of file LogFile.java.

References PredictedPlot.add(), JetWebPlotReader.fillPlot(), PredictedPlot.fixZeroErrors(), DataPlot.getCutCollection(), LogFile.getGenerator(), MCProcessType.getId(), RunSeries.getMCProcessType(), PredictedPlot.getProcIdWanted(), LogFile.getStem(), DataPlot.getYLabel(), CutCollection.isWithin(), LogFile.logfile, LogFile.lumi, LogFile.mcPlots, LogFile.runSeries, JetWebPlotReader.setDirectory(), LogFile.valid, and DataPlot.zero().

Referenced by LogFile.store().

00629                                                     {
00630 
00631     if (!valid) {
00632         System.out.println("Warning: attempt to make paper for invalid log "+logfile.getPath());
00633         return;
00634     }
00635 
00636     // mcPlots will be a Vector containing all plots which
00637     // are predicted by this LogFile.
00638     mcPlots = new Vector<PredictedPlot>();
00639 
00640     // first make a plot reader.
00641     String xfname = getStem()+".aida";
00642 
00643     try {
00644         if ( (new JetWebFile(xfname)).exists() ){
00645         System.out.println("LogFile: found file "+xfname);
00646         JetWebPlotReader reader = 
00647             JetWebPlotReaderFactory.getNewPlotReader(xfname);
00648 
00649         for (Paper paper : PaperBank.getPapers()){
00650 
00651             reader.setDirectory(paper.getDirName());
00652 
00653             for (DataPlot dplot : paper.getPlots()){
00654 
00655             RealPlot rplot = (RealPlot)dplot;
00656 
00657             PredictedPlot plot = new PredictedPlot(rplot,runSeries);
00658 
00659             //Only fill and write the plot if this 
00660             //logfile generated the correct process in the 
00661             //correct region of phase space
00662 
00663             if (runSeries.getMCProcessType().getId()==
00664                 plot.getProcIdWanted() && 
00665                 plot.getCutCollection().isWithin
00666                 (getGenerator().getCutCollection())){
00667             
00668                 // Read the xml file for the plot.
00669                 try {
00670                 reader.fillPlot(plot);
00671                 
00672                 // Now, various fixes to plots to account for bugs
00673                 // and features in HZTOOL.
00674                 if (weighted) {
00675                     // No more weighted runs.
00676                     plot.zero();
00677                 } else {
00678                     // Set errors on zero points to upper limits.
00679                     if (plot.getYLabel().indexOf("pb")>0){
00680                     plot.fixZeroErrors(lumi/1000.);
00681                     } else { 
00682                     plot.fixZeroErrors(lumi);
00683                     }
00684                 }
00685                 // Remove points with known bug (run list
00686                 // lookup table).
00687                 //JobUtils.removeBadPoints(plot,this);
00688                 
00689                 // Add this plot to the MC plots Vector.
00690                 mcPlots.add(plot);
00691 
00692                 } catch (JetWebException e) {
00693                 // not found this histogram. try the next.
00694                 System.out.println("Not found");
00695                 }
00696                         
00697             }
00698             }
00699         }
00700         
00701         }
00702     } catch (JetWebException je) {
00703         System.out.println("LogFile: no data for "+xfname);
00704         System.out.println(je);
00705         je.printStackTrace(System.out);
00706     }
00707 
00708     if (mcPlots.size()==0) {
00709         System.out.println("LogFile: no valid plots found");
00710         valid=false;
00711     }
00712     }

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 128 of file LogFile.java.

References LogFile.logId.

Referenced by JobUtils.doJobRequest(), DBJobManager.getLogFiles(), and LogFile.LogFile().

00128                                                      {
00129     if (logId>=0) {
00130         DBJobManager.selectFromDB(this);
00131     } else {
00132         DBJobManager.selectFromDBbyName(this);
00133     }
00134     return true;
00135     }

LogFile setCrossSection Double  cs  ) 
 

Set the cross section generated in this logfile

Parameters:
cs is the new cross section value

Definition at line 359 of file LogFile.java.

References LogFile.crossSection_.

00359                                              {
00360     crossSection_ = cs;
00361     return this;
00362     }

void setFile JetWebFile  f  ) 
 

Set the actual file associated with this LogFile.

Parameters:
set the log file of this Monte Carlo run.

Definition at line 216 of file LogFile.java.

References LogFile.logfile.

Referenced by JobUtils.doJobRequest().

00216 { logfile = f; }

void setGenerator Generator  gen  )  throws JetWebException
 

See also:
cedar.jetweb.model.RunSeries.getGenerator

Definition at line 350 of file LogFile.java.

References RunSeries.getGeneratorList(), and LogFile.getRunSeries().

00350                                                                    { 
00351     getRunSeries().getGeneratorList().clear();
00352     getRunSeries().getGeneratorList().add(gen);}

void setId int  i  ) 
 

Set the unique ID of the LogFile.

Parameters:
id 

Definition at line 301 of file LogFile.java.

References LogFile.logId.

00301 { logId = i;}

void setLumi double  l  ) 
 

Set the integrated luminosity for this logfile.

Parameters:
l is the new luminosity value to be set.

Definition at line 376 of file LogFile.java.

References LogFile.lumi.

00376 { lumi = l;}

void setRunSeries RunSeries  newrs  ) 
 

Set the associated RunSeries

Parameters:
runSeries contains all the parameters associated with this run.

Definition at line 291 of file LogFile.java.

References RunSeries.getId(), LogFile.rsId, and LogFile.runSeries.

00291                                              { 
00292     runSeries = newrs;
00293     rsId = runSeries.getId();
00294     }

void setRunSeriesId int  inew  ) 
 

Set the associated RunSeries id.

Parameters:
runSeriesId unique id of runseries which contains all the parameters associated with this run.

Definition at line 278 of file LogFile.java.

References LogFile.rsId, LogFile.runSeries, and RunSeries.setId().

Referenced by LogFile.toDB().

00278                                         { 
00279     rsId = inew;
00280     if (runSeries!=null){
00281         runSeries.setId(inew);
00282     }
00283     }

void setStatus int  i  )  throws JetWebException
 

Set Job Status: must be one of

See also:
UNDEFINED

SUBMITTED

RUN

COMPLETED

Exceptions:
JetWebException 

Definition at line 317 of file LogFile.java.

References LogFile.checkStatus(), and LogFile.status.

Referenced by LogFile.checkStatus(), JobUtils.doJobRequest(), LogFile.setStatusAsSubmitted(), and LogFile.toDB().

00317                                                         {
00318 
00319     if (checkStatus(i)){
00320         status = i; 
00321         DBJobManager.updateStatus(this);
00322     } else {
00323         throw new JetWebException("Attempt to set invalid Status on logfile:"+i,"");
00324     }
00325     }

LogFile setStatusAsSubmitted  ) 
 

Definition at line 327 of file LogFile.java.

References LogFile.setStatus(), and LogFile.SUBMITTED.

00327                                          {
00328     try{
00329         setStatus(SUBMITTED);
00330     }catch(JetWebException err){
00331         System.out.println(err.getMessage());
00332     }
00333     return this;
00334     }

void setValid boolean  b  ) 
 

Definition at line 624 of file LogFile.java.

References LogFile.valid.

00624 { valid = b;}

void setXmlFile String  path  ) 
 

Definition at line 571 of file LogFile.java.

References LogFile.logfile, and LogFile.xmlFile.

Referenced by LogFile.getXmlFileName().

00571                                        {
00572     xmlFile= path;
00573     logfile = new JetWebFile(path);
00574     }

boolean store  )  throws JetWebException
 

Save the LogFile in the Database.

Find the row in the runSeries table which matches them (and create one if none does). If no row exists in the logfile table, create one pointing to this row in the runSeries table. If a row exists, set the status bit to "completed". Make the plots for this logfile from the xml. Get the points from the predicted_point table which go with the runSeries row, and add the points from this logfile to them. (Create the predicted_point if they don't already exist.

Exceptions:
JetWebException 

Implements Storeable.

Definition at line 151 of file LogFile.java.

References LogFile.addLogFile(), LogFile.makePlots(), LogFile.status, and LogFile.toDB().

Referenced by JobUtils.doJobRequest().

00151                                                   {
00152 
00153     // First check this logfile isn't already stored.
00154     //checkStatus();
00155     DBJobManager.checkStatus(this);
00156     
00157     if (status==COMPLETED) {
00158         System.out.println
00159         ("LogFile: attempt to add a LogFile for which an entry exists."
00160          );
00161         System.out.println("DB not changed, LogFile rejected.");
00162         return false;
00163 
00164     } else if (status==RUN) {
00165 
00166         //System.out.println("LogFile: Making plots");
00167 
00168 
00169         //add the log file if it isn't already in the DB.
00170 
00171         addLogFile();
00172         
00173         // Make MC papers associated with this logfile by building
00174         // & reading XML.
00175 
00176         makePlots();
00177         
00178         if (!valid) {
00179         System.out.println("LogFile: Invalid plots. Nothing added to DB.");
00180         return false;
00181         }
00182         
00183         
00184         // Write the logfile, the parameters (or a link to them) and the
00185         // updated predicted_point to the DB.       
00186         return toDB();
00187 
00188     }else if(status==SUBMITTED){
00189         addLogFile();
00190         return true;
00191         //  }else if(status==RESERVED){
00192 
00193     }else{
00194 
00195         System.out.println("LogFile: attempt to add a LogFile with undefined/error status");
00196         System.out.println("DB not changed, LogFile rejected.");
00197 
00198         System.out.println("Logfile: status = " + status);
00199         return false;
00200 
00201     }
00202     }   

synchronized boolean toDB  )  throws JetWebException [private]
 

Add this logfile to the LogFile table in the database. return true if ok, false if there was an error.

This is a private method because it adds the predicted points from this logfile to those already in the DB, and therefore should only be called for LogFiles with the appropriate state, to avoid the same points being added several times.

Definition at line 426 of file LogFile.java.

References LogFile.addPlots(), LogFile.COMPLETED, RunSeries.getId(), LogFile.getRunSeries(), LogFile.lumi, LogFile.runSeries, RunSeries.setLumi(), LogFile.setRunSeriesId(), LogFile.setStatus(), LogFile.status, and LogFile.valid.

Referenced by LogFile.store().

00426                                                                {
00427 
00428     if (status!=LogFile.RUN) {return false;}
00429 
00430     setRunSeriesId(DBManager.matchRunSeriesId(getRunSeries()));
00431 
00432     int update=0;
00433 
00434     if (runSeries.getId()>0){
00435         // Add the plots from this logfile to those already in the DB.
00436         addPlots();
00437         // Add the lumi and update the timestamp.
00438         //DBManager.addLumi(lumi,runSeries.getId());
00439 
00440         //no need to add the lumi here because it was already done 
00441         //by the addLogFile method
00442 
00443         //DBManager.addLumi(this);
00444     } else {
00445 
00446         //No existing db record so add a row to the runSeries table.
00447         try {
00448 
00449         runSeries.setLumi(lumi);
00450         DBManager.addRunSeries(runSeries);
00451         } catch (JetWebException e){
00452         System.out.println("LogFile: This file not added.");
00453         valid = false;
00454         throw e;
00455         }
00456         update = 1;
00457     }
00458     
00459     // Now insert the points into the predicted_point table.
00460     //Enumeration<PredictedPlot> plots = mcPlots.elements();
00461     for (PredictedPlot plot : mcPlots){
00462         //while (plots.hasMoreElements()){
00463         //PredictedPlot plot = (PredictedPlot)plots.nextElement();
00464         //plot.setRunSeriesId(runSeries.getId());
00465         plot.setRunSeries(runSeries);
00466         // Only update plots which have data for this logfile.
00467         if (plot.hasData()){
00468         plot.toDB(update);
00469         }
00470     }
00471     
00472     // Finally add or update a row to the logfile table.
00473     setStatus(COMPLETED);
00474     DBJobManager.addLogfile(this); 
00475     return true;
00476     }

String toString  ) 
 

Definition at line 802 of file LogFile.java.

References LogFile.getGenerator(), LogFile.getLumi(), LogFile.getRunSeries(), LogFile.isValid(), LogFile.logfile, and LogFile.status.

Referenced by JobUtils.getNewData().

00802                              {
00803 
00804     try {
00805         StringBuffer b = new StringBuffer("Logfile: "+logfile.getPath()+"\n");
00806         b.append("Generator:");b.append(getGenerator());b.append("\n");
00807         b.append("Luminosity:");b.append(getLumi());b.append("\n");
00808         
00809         b.append("Process:");
00810         b.append(getRunSeries().getMCProcessType().getMCProcessName());
00811         b.append("\n");
00812 
00813         if (isValid()){
00814         b.append("Logfile is valid, ");
00815         } else {
00816         b.append("Logfile is invalid, ");
00817         }
00818         String statusString = "UNDEFINED";
00819         if (status==RUN) { 
00820         statusString="RUN";
00821         } else if (status==COMPLETED){
00822         statusString="COMPLETED";       
00823         } else if (status==SUBMITTED){
00824         statusString="SUBMITTED";       
00825         }
00826         b.append("Status is "+statusString);
00827 
00828         
00829         return b.toString();
00830 
00831     } catch (Exception e){
00832         return e.getMessage();
00833 
00834     }
00835 
00836     
00837     }


Member Data Documentation

final int COMPLETED = 2 [static]
 

LogFile job already in db, data already used

Definition at line 46 of file LogFile.java.

Referenced by LogFile.checkStatus(), and LogFile.toDB().

Double crossSection_ = -1.0 [private]
 

Definition at line 63 of file LogFile.java.

Referenced by LogFile.setCrossSection().

final int ERROR = 3 [static]
 

An error occurred during processing. Data in a semi-saved state.

Definition at line 48 of file LogFile.java.

JetWebFile logfile [private]
 

Definition at line 51 of file LogFile.java.

Referenced by LogFile.getStem(), LogFile.getXmlFileName(), LogFile.makePlots(), LogFile.setFile(), LogFile.setXmlFile(), and LogFile.toString().

int logId = -1 [private]
 

Definition at line 56 of file LogFile.java.

Referenced by LogFile.LogFile(), LogFile.retrieve(), and LogFile.setId().

double lumi = 0.0 [private]
 

Definition at line 62 of file LogFile.java.

Referenced by LogFile.addLogFile(), LogFile.makePlots(), LogFile.setLumi(), and LogFile.toDB().

Vector<PredictedPlot> mcPlots [private]
 

Definition at line 67 of file LogFile.java.

Referenced by LogFile.makePlots().

final int RESERVED = 5 [static]
 

LogFile name reserved but not submitted yet

Definition at line 38 of file LogFile.java.

Referenced by LogFile.checkStatus().

int rsId = -1 [private]
 

Definition at line 70 of file LogFile.java.

Referenced by LogFile.addLogFile(), LogFile.getRunSeries(), LogFile.LogFile(), LogFile.setRunSeries(), and LogFile.setRunSeriesId().

final int RUN = 1 [static]
 

LogFile job just completed, data to be added to runSeries.

Definition at line 44 of file LogFile.java.

Referenced by LogFile.checkStatus(), JobUtils.getLogFiles(), and JobUtils.getNewData().

RunSeries runSeries [private]
 

Definition at line 59 of file LogFile.java.

Referenced by LogFile.addLogFile(), LogFile.doChecks(), LogFile.getRunSeries(), LogFile.LogFile(), LogFile.makePlots(), LogFile.setRunSeries(), LogFile.setRunSeriesId(), and LogFile.toDB().

String SCHEME_PDFLIB = "PDFLIB" [static, private]
 

Definition at line 72 of file LogFile.java.

int status [private]
 

Definition at line 69 of file LogFile.java.

Referenced by LogFile.checkStatus(), LogFile.LogFile(), LogFile.setStatus(), LogFile.store(), LogFile.toDB(), and LogFile.toString().

final int SUBMITTED = 0 [static]
 

LogFile job was submitted but not complete yet.

Definition at line 42 of file LogFile.java.

Referenced by LogFile.checkStatus(), and LogFile.setStatusAsSubmitted().

final int UNDEFINED = -1 [static]
 

LogFile job in undefined state.

Definition at line 40 of file LogFile.java.

Referenced by LogFile.checkStatus().

boolean valid = false [private]
 

Definition at line 66 of file LogFile.java.

Referenced by LogFile.addLogFile(), LogFile.doChecks(), LogFile.LogFile(), LogFile.makePlots(), LogFile.setValid(), and LogFile.toDB().

boolean weighted = false [private]
 

Definition at line 64 of file LogFile.java.

String xmlFile = "" [private]
 

Definition at line 53 of file LogFile.java.

Referenced by LogFile.getXmlFileName(), and LogFile.setXmlFile().


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

Generated Wed Jan 17 09:14:27 GMT 2007