BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//____________________________________________________________________
// 
// BrDbUpdateModule: a module to update the runinfo and
// calibration parameters information 
//
// This module _must_ be placed _before_ all other analysis modules in  
// the module pipeline. 
//
// Note that this module assumes that you use file sets when looping
// over sequences of a run or multiple runs.  
// 
// Therefor, your configuration script should look like 
// 
//   // Register all needed runs.  Needed runs are passed on the
//   // commandline as 
//   //
//   //   bratmain <script> -r <run1> -r <run2> ... 
//   //
//   // The runs are processed in the order given
//   Int_t nRuns = runOption->GetNValues(); 
//   Int_t i     = 0;
//   for (i = 0; i < nRuns; i++) 
//     BrRunInfoManager::Instance()->Register(runOption->GetValue(i));
//
//   // Make the input module, and set the modus operandi according to
//   // the number of runs we're processing. 
//   BrIOModule* inputModule = 
//     new BrEventIO("inputModule", "Reader of data files");
//   mainModule->AddModule(inputModule);
//   inputModule->SetIOMode((nRuns > 1 ?
//                           BrIOModule::kRunFile : 
//                           BrIOModule::kJobFile) |BrIOReadFile);
//
//   // Add a file set for each run we're processing 
//   for (i = 0; i < ; i++) 
//     inputModule->AddFileSet(includeOption->GetValue(), 
//                             Form("run%06dseq....root", 
//                                  runOption->GetValue(i))); 
//    
//   // Add the Database update module 
//   BrDbUpdateModule* dbUpdateModule = 
//     new BrDbUpdateModule("dbUpdateModule", "Update from DB");
//   mainModule->AddModule(dbUpdateModule);
// 

//____________________________________________________________________
//
// $Id: BrDbUpdateModule.cxx,v 1.9 2002/03/21 15:06:17 ouerdane Exp $
// $Author: ouerdane $
// $Date: 2002/03/21 15:06:17 $
// $Copyright: (C) 2001 BRAHMS Collaboration <brahmlib@rhic.bnl.gov>
//

#ifndef BRAT_BrDbUpdateModule
#include "BrDbUpdateModule.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
#ifndef BRAT_BrEvent
#include "BrEvent.h"
#endif
#ifndef BRAT_BrMainModule
#include "BrMainModule.h"
#endif
// These are here only temporarily 
#ifndef BRAT_BrTileCalibration
#include "BrTileCalibration.h"
#endif
#ifndef BRAT_BrSiCalibration
#include "BrSiCalibration.h"
#endif
#ifndef BRAT_BrMultCentCalibration
#include "BrMultCentCalibration.h"
#endif

//____________________________________________________________________
ClassImp(BrDbUpdateModule);

//____________________________________________________________________
 BrDbUpdateModule::BrDbUpdateModule()
{
  // Default constructor. 
  SetState(kSetup);
  fHasBegun = kFALSE;
}

//____________________________________________________________________
 BrDbUpdateModule::BrDbUpdateModule(const Char_t* name, const Char_t* title)
  : BrModule(name, title)
{
  // Named Constructor
  SetState(kSetup);
  fHasBegun = kFALSE;
}

//____________________________________________________________________
 void BrDbUpdateModule::Init()
{
  // Instantiate, initialize and update only once the run info manager
  SetState(kInit);

  BrRunInfoManager* runInfoManager = 
    BrRunInfoManager::Instance();

  // Make sure that we have initialised the run manager 
  runInfoManager->Init();
  
  // Do we really need this one here? 
  runInfoManager->Update();
  // DO: I used to think so, now, I'm not sure anymore...
  // I guess it was to make sure that at least a run was registered 
  // before the 1st Begin call

  // Check that we did get the run information
  if (runInfoManager->GetCurrentRun()->GetRunNo() == -1) {
    Abort("Update", "RunInfo has run number == -1");
    return;
  }
}

//____________________________________________________________________
 void BrDbUpdateModule::Begin()
{
  // update the calibration manager for the 1st begin
  SetState(kBegin);

  // Check the manager. 
  BrRunInfoManager* runInfoManager = BrRunInfoManager::Instance();
  if (!runInfoManager) {
    Abort("Begin", "run information manager not instantiated");
    return;
  }
  
  // Get the next run. First time we get here, we already have updated
  // in Init, so we do that conditionally on the state parameter,
  // fHasBegun.  
  if (fHasBegun)
    runInfoManager->Update(); 
  const BrRunInfo* runInfo = runInfoManager->GetCurrentRun(); 
  
  // Check that we did get the run information
  if (runInfo->GetRunNo() == -1) {
    Failure("Update", "RunInfo has run number == -1");
    return;
  }
  
  // Perhaps we need to print something? 
  if (Verbose() > 3)
    runInfo->Print();

  // Get the times 
  Int_t startTime = runInfo->GetUnixStartTime();
  Int_t endTime = runInfo->GetUnixEndTime();

  
  // Check the manager. 
  BrCalibrationManager* calibManager = BrCalibrationManager::Instance(); 
  if (!calibManager) {
    Abort("Begin", "Calibration manager not instantiated");
    return;
  }

  // Update the calibrations 
  Info(5, "Begin","DbUpdate");
  
  // calling init here because this is the last module to be initialized
  // (hence justify the use of fHasBegun)
  if (!fHasBegun) {
    fHasBegun = kTRUE;
    calibManager->SetDebugLevel(DebugLevel());  
    calibManager->Init();

    // Print the list of parameters. 
    if (Verbose() > 3)
      calibManager->Print("SL");
  }
  
  // Update the calibrations 
  calibManager->Update(startTime, endTime);

  // Temporary hack:  We update the BrMultTmpCalibrations here too. 
#ifdef BR_MULT_CAL_TMP
  Warning("Begin", "updating BrMultTmpCalibrations"); 
  BrTileTmpCalibration::Instance()->ReadASCIIFile(runInfo->GetRunNo());
  BrSiTmpCalibration::Instance()->ReadASCIIFile(runInfo->GetRunNo());
  BrMultCentTmpCalibration::Instance()->SetRunNumber(runInfo->GetRunNo());
#endif
  
}

//____________________________________________________________________
 void BrDbUpdateModule::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: ouerdane $" << endl  
         << "    $Date: 2002/03/21 15:06:17 $"   << endl 
         << "    $Revision: 1.9 $ " << endl  
         << endl 
         << "-------------------------------------------------" << endl;
}

//____________________________________________________________________
//
// $Log: BrDbUpdateModule.cxx,v $
// Revision 1.9  2002/03/21 15:06:17  ouerdane
// added a small comment (reply to a question in Init method)
//
// Revision 1.8  2002/03/11 17:10:34  cholm
// Added update of TMA and SMA calibrations.  NOTE: This is temporary, until
// BrMultCalibration is in sync with BrMultTmpCalibration, and we can commit
// the calibrations to the database.  Also, the module _only_ updates in
// Begin, and _not_ in Event as previously.  This  is because that mode is
// redundant after the introduction of FileSets.  Also, I took out the fNoDb
// member as it really doesn't make sense.   If one does not want to use the
// database, simply do not add the module to the pipeline.  That's it.  Please
// note, that the check of wether the event actually belongs to the current
// run has been removed.  This shouldn't cause any trouble if the module is
// used correctly (like demonstrated in the class documentation and in The
// Guide).
//
// Revision 1.7  2001/12/17 16:24:38  ejkim
// choice of DB
//
// Revision 1.6  2001/10/25 16:08:27  videbaek
// Added a new calss BrAppendContainer to deal with modules that use both
// inNode and outNode as requeired input.
//
// Revision 1.5  2001/10/08 11:29:54  cholm
// Changed to use new DB access classes
//
// Revision 1.4  2001/10/03 10:11:55  ouerdane
// Replaced Failure by Abort
//
// Revision 1.3  2001/09/12 15:06:04  cholm
// Added typechecking to the Event method.  That is very VERY important
// in this case.
//
// Revision 1.2  2001/08/10 13:49:12  ouerdane
// Added 2 methods in BrRunInfoManager:
//   Int_t* GetRunNumbers   -> returns the array of registered runs
//   Int_t  GetNumberOfRuns -> returns the number of runs registered
//
// Added a check in BrDbUpdateModule::Event:
//   if the user has not registered initially the run number
//   returned by the event header, then the job will abort.
//   It forces the user to know exactly which runs he wants
//   to analyze at registration time (brRunInfoManager::Register(runNo))
//
// Removed in the same class a reference to BrMainModule in Begin since
// BrDbUpdateModule might be used in another context (if possible).
//
// Revision 1.1  2001/07/18 16:19:33  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