BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//____________________________________________________________________
// 
// This commit module is meant to be used if you want to commit a
// calibration to the database. This should be THE VERY LAST MODULE
// inserted in the module pipeline. 
//
// The finish method is the only one used. The parameter element
// manager will commit from the start time of the initial run and the
// end time of the final run (they can be the same run) 

//____________________________________________________________________
//
// $Id: BrDbCommitModule.cxx,v 1.3 2001/10/08 11:29:49 cholm Exp $
// $Author: cholm $
// $Date: 2001/10/08 11:29:49 $
// $Copyright: (C) 2001 BRAHMS Collaboration <brahmlib@rhic.bnl.gov>
//
#ifndef BRAT_BrDbCommitModule
#include "BrDbCommitModule.h"
#endif
#ifndef ROOT_TDirectory
#include "TDirectory.h"
#endif
#ifndef WIN32
#include <iostream>
#else
#include <iostream.h>
#endif
#ifndef BRAT_BrCalibrationManager
#include "BrCalibrationManager.h"
#endif
#ifndef BRAT_BrRunInfoManager
#include "BrRunInfoManager.h"
#endif
#ifndef BRAT_BrRunInfo
#include "BrRunInfo.h"
#endif

//____________________________________________________________________
ClassImp(BrDbCommitModule);

//____________________________________________________________________
 BrDbCommitModule::BrDbCommitModule()
{
  // Default constructor. DO NOT USE
  SetState(kSetup);
}

//____________________________________________________________________
 BrDbCommitModule::BrDbCommitModule(const Char_t* name, const Char_t* title)
  : BrModule(name, title)
{
  // Named Constructor
  SetState(kSetup);
  
  SetInitialRun();
  SetFinalRun();
}

//____________________________________________________________________
 void BrDbCommitModule::Finish()
{
  // ------------------------------------  
  // commit calibration to database
  // ------------------------------------  

  // Job-level finalisation
  SetState(kFinish);

  
  BrRunInfoManager* runMan = BrRunInfoManager::Instance();
  if (!runMan) {
    Fatal("Finish", "Run DB manager has not been found");
    return;
  }
  
  BrCalibrationManager* parMan = 
    BrCalibrationManager::Instance();
  
  if (!parMan) {
    Fatal("Finish", "Calibration parameter manager has not been found");
    return;
  }
  
  // check initial run for revision startime 
  runMan->Update(fInitialRun);
  const BrRunInfo* irun = runMan->GetCurrentRun();
  if (irun->GetRunNo() == -1) {
    Fatal("Finish", "Initial run is not updated by run manager");
    return;
  }
  
  Int_t startTime = irun->GetUnixStartTime();
  if (DebugLevel() > 2)
    cout << " Start time of run " << irun->GetRunNo() 
	 << ": " << startTime << endl;


  // check final run for revision endtime 
  Int_t endTime = irun->GetUnixEndTime();

  for (Int_t i = fFinalRun; i > fInitialRun; i--) {
    runMan->Update(i);
    const BrRunInfo* frun = runMan->GetCurrentRun();
    if (frun->GetRunNo() == -1) 
      continue;

    endTime = irun->GetUnixEndTime();
    if (DebugLevel() > 2)
      cout << " End time of run " << frun->GetRunNo() 
	   << ": " << endTime << endl;
    break;
  }
  
  // commit stuff
  parMan->Commit(startTime, endTime);
}

//____________________________________________________________________
 void BrDbCommitModule::Print(Option_t* option) const
{
  // Print module information
  // See BrModule::Print for options.
  // In addition this module defines the Option:
  // <fill in here>

  TString opt(option);
  opt.ToLower(); 
  
  BrModule::Print(option); 
  if (opt.Contains("d")) 
   cout << endl 
         << "  Original author: Djamel Ouerdane" << endl
         << "  Last Modifications: " << endl 
         << "    $Author: cholm $" << endl  
         << "    $Date: 2001/10/08 11:29:49 $"   << endl 
         << "    $Revision: 1.3 $ " << endl  
         << endl 
         << "-------------------------------------------------" << endl;
}

//____________________________________________________________________
//
// $Log: BrDbCommitModule.cxx,v $
// Revision 1.3  2001/10/08 11:29:49  cholm
// Changed to use new DB access classes
//
// Revision 1.2  2001/07/19 10:53:02  ouerdane
// Added return statement after Fatal statement in Finish method
//
// Revision 1.1  2001/07/18 16:19:30  ouerdane
// Added 2 classes in this directory (modules/util)
//  BrDbUpdateModule
//  BrDbCommitModule
//
// The 1st one updates the calibration parameter manager and the run info manager
// The 2nd commit new calibration to the database, given a start run and an end
// run (they can be the same).
//
// See email on the brahms-soft/dev-list for more details on how to use them.
//
// Updated Makefile.am, LinkDef.h, Include.h for the classes to compile
//

This page automatically generated by script docBrat by Christian Holm

Copyright ; 2002 BRAHMS Collaboration <brahmlib@rcf.rhic.bnl.gov>
Last Update on by

Validate HTML
Validate CSS