LCOV - code coverage report
Current view: top level - STEER/CDB - AliDCSGenDB.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 97 1.0 %
Date: 2016-06-14 17:26:59 Functions: 1 19 5.3 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : 
      17             : ///////////////////////////////////////////////////////////////////////////////
      18             : //                                                                           //
      19             : //  Class to generate DCS data base entries                                  //
      20             : //  Author: Haavard Helstrup                                                 //
      21             : //                                                                           //
      22             : ///////////////////////////////////////////////////////////////////////////////
      23             : 
      24             : 
      25             : 
      26             : 
      27             : 
      28             : // TTimeStamp startTime(2006,10,18,0,0,0,0,kFALSE)
      29             : // TTimeStamp endTime(2006,10,19,0,0,0,0,kFALSE)
      30             : // Int_t run=2546
      31             : // AliDCSGenDB db
      32             : // db->SetDefaultStorage("local:///afs/cern.ch/alice/tpctest/AliRoot/HEAD");
      33             : // db->SetSpecificStorage("local:///afs/cern.ch/alice/tpctest/Calib/");
      34             : // db->Init(run,"TPC/Config/Pressure","TPC/*/*")
      35             : // db->MakeCalib("PressureSensor.txt","DCSMap.root",startTime,endTime,firstRun,lastRun,"TPC/Calib/Pressure")
      36             : 
      37             : 
      38             : #include "AliDCSGenDB.h"
      39             : #include "AliLog.h"
      40             : #include "ARVersion.h"
      41             : 
      42             : const Int_t kBeamPeriod=2;
      43             : 
      44         128 : ClassImp(AliDCSGenDB)
      45             : 
      46             : //______________________________________________________________________________________________
      47             : 
      48           0 : AliDCSGenDB::AliDCSGenDB():
      49           0 :   fFirstRun(0),
      50           0 :   fLastRun(0),
      51           0 :   fSpecificStorage(0),
      52           0 :   fDefaultStorage(0),
      53           0 :   fSensor(0),
      54           0 :   fStorLoc(0),
      55           0 :   fMetaData(0),
      56           0 :   fConfTree(0)
      57             :   //
      58             :   //  standard constructor
      59             :   //
      60           0 : {}
      61             : 
      62             : //______________________________________________________________________________________________
      63             : 
      64           0 : AliDCSGenDB::AliDCSGenDB(const char* defaultStorage, const char* specificStorage):
      65           0 :   fFirstRun(0),
      66           0 :   fLastRun(0),
      67           0 :   fSpecificStorage(specificStorage),
      68           0 :   fDefaultStorage(defaultStorage),
      69           0 :   fSensor(0),
      70           0 :   fStorLoc(0),
      71           0 :   fMetaData(0),
      72           0 :   fConfTree(0)
      73             :   //
      74             :   //  special constructor
      75             :   //
      76           0 : {}
      77             : 
      78             : //______________________________________________________________________________________________
      79             : 
      80             : AliDCSGenDB::AliDCSGenDB(const AliDCSGenDB& org):
      81           0 :   TObject(org),
      82           0 :   fFirstRun(org.fFirstRun),
      83           0 :   fLastRun(org.fLastRun),
      84           0 :   fSpecificStorage(org.fSpecificStorage),
      85           0 :   fDefaultStorage(org.fDefaultStorage),
      86           0 :   fSensor(0),
      87           0 :   fStorLoc(0),
      88           0 :   fMetaData(0),
      89           0 :   fConfTree(0)
      90           0 : {
      91             :   //
      92             :   //  Copy constructor
      93             :   //
      94             : 
      95           0 :   AliError("copy constructor not implemented");
      96             : 
      97           0 : }
      98             : 
      99             : //______________________________________________________________________________________________
     100           0 : AliDCSGenDB::~AliDCSGenDB(){
     101             :   //
     102             :   // destructor
     103             :   //
     104           0 :   delete fSensor;
     105           0 :   delete fMetaData;
     106           0 :   delete fConfTree;
     107           0 : }
     108             : 
     109             : //______________________________________________________________________________________________
     110             : AliDCSGenDB& AliDCSGenDB::operator= (const AliDCSGenDB& /*org*/ )
     111             : {
     112             :   //
     113             :   // assignment operator
     114             :   //
     115           0 :   AliError("assignment operator not implemented");
     116           0 :   return *this;
     117             : 
     118             : }
     119             : 
     120             : //______________________________________________________________________________________________
     121             : 
     122             : void AliDCSGenDB::MakeCalib(const char *list, const char *mapDCS,
     123             :     const TTimeStamp& startTime,
     124             :     const TTimeStamp& endTime,
     125             :     Int_t firstRun, Int_t lastRun, const char *calibDir )
     126             : {
     127             : 
     128             :   // Generate calibration entry from DCS map
     129             :   // Configuration read from ASCII file specified by list
     130             : 
     131           0 :   TClonesArray *arr = ReadList(list);
     132           0 :   fSensor = new AliDCSSensorArray(arr);
     133           0 :   fSensor->SetStartTime(startTime);
     134           0 :   fSensor->SetEndTime(endTime);
     135           0 :   TMap* map = SetGraphFile(mapDCS);
     136           0 :   if (map) {
     137           0 :     fSensor->MakeSplineFit(map);
     138           0 :   }
     139           0 :   delete map;
     140             :   map=0;
     141             :   mapDCS=0;
     142             : 
     143           0 :   SetFirstRun(firstRun);
     144           0 :   SetLastRun(lastRun);
     145             : 
     146           0 :   StoreObject(calibDir, fSensor, fMetaData);
     147           0 : }
     148             : 
     149             : //______________________________________________________________________________________________
     150             : void AliDCSGenDB::MakeConfig(const char *file, Int_t firstRun, Int_t lastRun, const char *confDir )
     151             : {
     152             :   //
     153             :   // Store Configuration file to OCDB
     154             :   //
     155             : 
     156           0 :   TTree *tree = ReadListTree(file);
     157           0 :   SetConfTree(tree);
     158           0 :   SetFirstRun(firstRun);
     159           0 :   SetLastRun(lastRun);
     160             : 
     161           0 :   StoreObject(confDir, fConfTree, fMetaData);
     162           0 : }
     163             : 
     164             : 
     165             : 
     166             : 
     167             : //______________________________________________________________________________________________
     168             : AliCDBMetaData* AliDCSGenDB::CreateMetaObject(const char* objectClassName)
     169             : {
     170           0 :   AliCDBMetaData *md1= new AliCDBMetaData();
     171           0 :   md1->SetObjectClassName(objectClassName);
     172           0 :   md1->SetResponsible("Haavard Helstrup");
     173           0 :   md1->SetBeamPeriod(kBeamPeriod);
     174           0 :   md1->SetAliRootVersion(ALIROOT_VERSION);
     175             : 
     176           0 :   return md1;
     177           0 : }
     178             : 
     179             : //______________________________________________________________________________________________
     180             : void AliDCSGenDB::StoreObject(const char* cdbPath, TObject* object, AliCDBMetaData* metaData)
     181             : {
     182             : 
     183           0 :   AliCDBId id1(cdbPath, fFirstRun, fLastRun);
     184           0 :   if (fStorLoc) fStorLoc->Put(object, id1, metaData);
     185           0 : }
     186             : 
     187             : //______________________________________________________________________________________________
     188             : void AliDCSGenDB::Init(Int_t run, const char *configDir, 
     189             :     const char *specificDir,
     190             :     const char *sensorClass)
     191             : {
     192             : 
     193           0 :   fMetaData = CreateMetaObject(sensorClass);
     194           0 :   AliCDBManager *man = AliCDBManager::Instance();
     195           0 :   man->SetDefaultStorage(fDefaultStorage);
     196           0 :   man->SetRun(run);
     197           0 :   man->SetSpecificStorage(specificDir,fSpecificStorage);
     198           0 :   AliCDBEntry *config = man->Get(configDir);
     199           0 :   if (config) fConfTree = (TTree*)config->GetObject();
     200           0 :   fStorLoc = man->GetStorage(fSpecificStorage);
     201           0 :   if (!fStorLoc)    return;
     202             : 
     203           0 :   /*Bool_t cdbCache = */AliCDBManager::Instance()->GetCacheFlag(); // save cache status
     204           0 :   AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
     205             : 
     206             : 
     207           0 : }
     208             : 
     209             : //______________________________________________________________________________________________
     210             : 
     211             : 
     212             : //_____________________________________________________________________________
     213             : TMap* AliDCSGenDB::SetGraphFile(const char *fname)
     214             : {
     215             :   //
     216             :   // Read DCS maps from file given by fname
     217             :   //
     218           0 :   TFile file(fname);
     219           0 :   TMap * map = (TMap*)file.Get("DCSMap");
     220             :   return map;
     221           0 : }
     222             : 
     223             : //______________________________________________________________________________________________
     224             : 
     225             : TClonesArray * AliDCSGenDB::ReadList(const char *fname, const char *title) {
     226             :   //
     227             :   // read values from ascii file
     228             :   //
     229           0 :   TTree* tree = new TTree(title,title);
     230           0 :   tree->ReadFile(fname,"");
     231           0 :   TClonesArray *arr = AliDCSSensor::ReadTree(tree);
     232           0 :   delete tree;
     233           0 :   return arr;
     234           0 : }
     235             : 
     236             : //______________________________________________________________________________________________
     237             : 
     238             : TTree * AliDCSGenDB::ReadListTree(const char *fname, const char *title) {
     239             :   //
     240             :   // read values from ascii file
     241             :   //
     242           0 :   TTree* tree = new TTree(title,title);
     243           0 :   tree->ReadFile(fname,"");
     244           0 :   TClonesArray *arr = AliDCSSensor::ReadTree(tree);
     245           0 :   arr->Delete();
     246           0 :   delete arr;
     247           0 :   return tree;
     248           0 : }
     249             : 
     250             : 
     251             : 

Generated by: LCOV version 1.11