예제 #1
0
Int_t  califa_test()
{
  // Create a Runtime Database singleton.
  FairRuntimeDb* db = FairRuntimeDb::instance();

   // Create in memory the relevant container
  R3BCaloCalPar* par = (R3BCaloCalPar*)(db->getContainer("CaloCalPar"));  

  // Set the SQL IO as first input
  FairParAsciiFileIo* inp = new FairParAsciiFileIo();

  TString filename ="ducals.par";
  inp->open(filename.Data(),"in");

  db->setFirstInput(inp);

// Generate a unique RunID
  FairRunIdGenerator runID;
  UInt_t runId =  runID.generateId();
  db->initContainers(runId);


  // Get the container after initialisation
  // from the RuntimeDB
  R3BCaloCalPar* par = (R3BCaloCalPar*)(db->getContainer("CaloCalPar"));

  // Dump the Parameters
  cout << endl;
  cout << "-I- Reading Parameter data from Ascii File: \n" << filename.Data() << endl;
  cout << endl;

  par->Print();
  cout << endl;

  // Convert in ROOT format 
  par->setChanged();
  Bool_t kParameterMerged = kTRUE;
  FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
  parOut->open("califa_cal_par.root");
  db->setOutput(parOut);
  db->saveOutput();
  db->print();
  // ------------------------------------------------------------------------

  if (db) delete db;
  return 0;
}
예제 #2
0
Int_t  run_insert()
{

    //gDebug = 5;

    // Generate a unique RunID
    FairRunIdGenerator runID;
    UInt_t runId =  runID.generateId();

    // Create the Runtime Database ( parameter manager class )
    FairRuntimeDb* db = FairRuntimeDb::instance();

    // Set the SQL based IO as second input
    FairParTSQLIo* input_db = new FairParTSQLIo();
    input_db->SetVerbosity(1);

    // Set Global SeqNo ( Replication Global Index Base )
    //inp2->SetGlobalSeqNoIn();

    // Shutdown Mode ( True, False )
    input_db->SetShutdown(kTRUE);


    // Open first input
    input_db->open();
    db->setFirstInput(input_db);

    // Set the output=input
    db->setOutput(input_db);


    // Write a Run
    R3BDBRunInfo rInfo;
    rInfo.SetRunId(11334465);
    ValTimeStamp now;
    rInfo.SetRunTime(now);

    if (!rInfo.Commit()) cout << "-E- Error Writing Run Info " << endl;

    R3BDBRunInfo rInfo2;
    rInfo2.SetRunId(11334469);
    ValTimeStamp shifted(now.GetSec()+1,0);
    rInfo2.SetRunTime(shifted);

    if (!rInfo2.Commit()) cout << "-E- Error Writing Run Info2 " << endl;


    // Read it back in
    // make a extended query to get ConfigFileText
    ValTimeStamp tsStart(1970, 1, 1, 0, 0, 0);
    ValTimeStamp   tsEnd(2038, 1,18,19,14, 7);

    FairDbExtSqlContent extContextConfig(FairDbExtSqlContent::kStarts,tsStart,tsEnd,
                                         Detector::kLand,   // any
                                         DataType::kData); // any


    string seqSelectConfig = Form("SEQNO=%d",rInfo.GetRunId());

    FairDbReader<R3BDBRunInfo>
    rsConfig("R3BDBRUNINFO",extContextConfig,FairDb::kAnyVersion,
             seqSelectConfig.c_str());

    Int_t nConfig = rsConfig.GetNumRows();
    cout << "nConfig: = " << nConfig << endl;
    const R3BDBRunInfo* rpInfo = rsConfig.GetRow(0);

    if (rpInfo) cout << " run # " << rpInfo->GetRunId() << " has time: " << rpInfo->GetRunTime().AsString("s") << endl;

    // FairRuntimeDB deletion
    if (db) delete db;
    return 0;
}
예제 #3
0
/********************************************************************************
 *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
 *                                                                              *
 *              This software is distributed under the terms of the             * 
 *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
 *                  copied verbatim in the file "LICENSE"                       *
 ********************************************************************************/
Int_t  sql_params_write_bin()
{
  // ----  Load libraries   -------------------------------------------------
  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
  basiclibs();
  gSystem->Load("libGenVector");
  gSystem->Load("libGeoBase");
  gSystem->Load("libFairDB");
  gSystem->Load("libParBase");
  gSystem->Load("libBase");
  gSystem->Load("libMCStack");
  gSystem->Load("libTutorial5");

  // Generate a unique RunID
  FairRunIdGenerator runID;
  UInt_t runId =  runID.generateId();

  FairRuntimeDb* db = FairRuntimeDb::instance();
  cout << "-I- FairRuntimeDb created ----> " << db << endl;

  // Create in memory the relevant container
  FairDbTutParBin* p1 = (FairDbTutParBin*)(db->getContainer("TUTParBin"));

  // Set the Ascii IO as first input
  FairParAsciiFileIo* inp1 = new FairParAsciiFileIo();

  //TString work = getenv("VMCWORKDIR");
  TString filename = "ascii-example_bin.par";
  inp1->open(filename.Data(),"in");
  db->setFirstInput(inp1);

  // Set the SQL based IO as second input
  FairParTSQLIo* inp2 = new FairParTSQLIo();
  inp2->open();
  db->setSecondInput(inp2);


  // <INIT> containers from Ascii input
  // with assigned  RunId
  db->initContainers(runId);

  // Additionnally  prime some dummy values to the data members that are not
  // initialized using the ascii input file .
 
  p1->FillDummy();

  cout << endl;
  cout << "\n  -I- FAIRDB: RuntimeDB::init from Ascii File done using RunID# " <<  runId << endl;
  cout << endl;

  // <WRITE> back containers to the user-defined
  // Database using the Sql based IO of the
  // second input.

  db->setOutput(inp2);
  db->writeContainers();

  cout << endl;
  cout << "-I-  FAIRDB: RuntimeDB Parameters successfully written to DB with RunID# " << runId << endl;
  cout << endl;

  if (db) delete db;
  return 0;
}