LCOV - code coverage report
Current view: top level - RAW/MDC - AliRawRootdDB.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 36 2.8 %
Date: 2016-06-14 17:26:59 Functions: 1 5 20.0 %

          Line data    Source code
       1             : // @(#) $Id$
       2             : // Author: Fons Rademakers  26/11/99
       3             : 
       4             : /**************************************************************************
       5             :  * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
       6             :  *                                                                        *
       7             :  * Author: The ALICE Off-line Project.                                    *
       8             :  * Contributors are mentioned in the code where appropriate.              *
       9             :  *                                                                        *
      10             :  * Permission to use, copy, modify and distribute this software and its   *
      11             :  * documentation strictly for non-commercial purposes is hereby granted   *
      12             :  * without fee, provided that the above copyright notice appears in all   *
      13             :  * copies and that both the copyright notice and this permission notice   *
      14             :  * appear in the supporting documentation. The authors make no claims     *
      15             :  * about the suitability of this software for any purpose. It is          *
      16             :  * provided "as is" without express or implied warranty.                  *
      17             :  **************************************************************************/
      18             : 
      19             : //////////////////////////////////////////////////////////////////////////
      20             : //                                                                      //
      21             : // AliRawRootdDB                                                        //
      22             : //                                                                      //
      23             : //////////////////////////////////////////////////////////////////////////
      24             : 
      25             : #include <TSystem.h>
      26             : 
      27             : #include "AliRawRootdDB.h"
      28             : 
      29             : 
      30           2 : ClassImp(AliRawRootdDB)
      31             : 
      32             : 
      33             : //______________________________________________________________________________
      34             : AliRawRootdDB::AliRawRootdDB(AliRawEventV2 *event,
      35             :                              AliESDEvent *esd,
      36             :                              Int_t compress,
      37             :                              const char* fileName,Int_t basketsize, Long64_t autoflush)
      38           0 :   : AliRawDB(event, esd, compress, fileName, basketsize, autoflush)
      39           0 : {
      40             :    // Create a new raw DB that will be accessed via rootd daemon.
      41             : 
      42             : #if ROOT_VERSION_CODE < ROOT_VERSION(5,99,0)
      43           0 :    if (fRawDB) fRawDB->UseCache(50, 0x200000);  //0x100000 = 1MB)
      44             : #endif
      45           0 : }
      46             : 
      47             : //______________________________________________________________________________
      48             : const char *AliRawRootdDB::GetFileName() const
      49             : {
      50             :    // Return filename based on hostname and date and time. This will make
      51             :    // each file unique. Also the directory will be made unique for each
      52             :    // day by adding the date to the fs. Assumes there is always enough
      53             :    // space on the device.
      54             : 
      55           0 :    static TString fname;
      56             : 
      57           0 :    TString fs = fFS1;
      58           0 :    TDatime dt;
      59             : 
      60             : #if 0
      61             :    // make a new subdirectory for each day
      62             :    fs += "/adc-";
      63             :    fs += dt.GetDate();
      64             : 
      65             :    Long_t id, size, flags, time;
      66             :    if (gSystem->GetPathInfo(fs, &id, &size, &flags, &time) == 1) {
      67             :       // directory does not exist, create it
      68             :       if (gSystem->mkdir(fs, kTRUE) == -1) {
      69             :          Error("GetFileName", "cannot create dir %s, using %s", fs.Data(),
      70             :                fFS1.Data());
      71             :          fs = fFS1;
      72             :       }
      73             :    }
      74             :    // FIXME: should check if fs is a directory
      75             : #endif
      76             : 
      77           0 :    TString hostname = gSystem->HostName();
      78             :    Int_t pos;
      79           0 :    if ((pos = hostname.Index(".")) != kNPOS)
      80           0 :       hostname.Remove(pos);
      81             : 
      82           0 :    fname = fs + "/" + hostname + "_";
      83           0 :    fname += dt.GetDate();
      84           0 :    fname += "_";
      85           0 :    fname += dt.GetTime();
      86           0 :    fname += ".root";
      87             : 
      88           0 :    return fname;
      89           0 : }
      90             : 
      91             : //______________________________________________________________________________
      92             : Long64_t AliRawRootdDB::Close()
      93             : {
      94             :    // Close raw rootd DB.
      95             : 
      96           0 :    if (!fRawDB) return 0;
      97             : 
      98           0 :    if (!fRawDB->IsOpen()) return 0;
      99             : 
     100           0 :    fRawDB->cd();
     101             : 
     102             :    // Write the tree.
     103             :    Bool_t error = kFALSE;
     104           0 :    if (fTree)
     105           0 :      if (fTree->Write() == 0)
     106           0 :        error = kTRUE;
     107           0 :    if (fESDTree)
     108           0 :      if (fESDTree->Write() == 0)
     109           0 :        error = kTRUE;
     110             : 
     111             :    // Close DB, this also deletes the fTree
     112           0 :    fRawDB->Close();
     113             : 
     114           0 :    fTree = NULL;
     115             : 
     116           0 :    Long64_t filesize = fRawDB->GetEND();
     117             : 
     118             : #if 0
     119             :    // can use services of TFTP
     120             :    if (fDeleteFiles)
     121             :       gSystem->Exec(Form("rfrm %s", fRawDB->GetName()));
     122             : #endif
     123             : 
     124           0 :    delete fRawDB;
     125           0 :    fRawDB = 0;
     126           0 :    if(!error)
     127           0 :      return filesize;
     128             :    else
     129           0 :      return -1;
     130           0 : }

Generated by: LCOV version 1.11