LCOV - code coverage report
Current view: top level - STEER/CDB - AliPreprocessor.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 102 1.0 %
Date: 2016-06-14 17:26:59 Functions: 1 30 3.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             :    $Log$
      18             :    Revision 1.17  2007/08/28 16:03:30  acolla
      19             :    Restored to v1.14:
      20             : 
      21             : 
      22             :    Function Bool_t GetHLTStatus() added to preprocessor interface. It will return
      23             :    the status of HLT read from the run logbook.
      24             : 
      25             :    Revision 1.16  2007/08/22 09:20:50  hristov
      26             :    Updated QA classes (Yves)
      27             : 
      28             :    Revision 1.14  2007/05/30 06:35:21  jgrosseo
      29             :    Adding functionality to the Shuttle/TestShuttle:
      30             :    o) Function to retrieve list of sources from a given system (GetFileSources with id=0)
      31             :    o) Function to retrieve list of IDs for a given source      (GetFileIDs)
      32             :    These functions are needed for dealing with the tag files that are saved for the GRP preprocessor
      33             :    Example code has been added to the TestProcessor in TestShuttle
      34             : 
      35             :    Revision 1.13  2007/04/12 08:26:33  jgrosseo
      36             :    updated commment
      37             : 
      38             :    Revision 1.12  2007/04/05 08:05:55  acolla
      39             :    Conversion from online to offline detector name in StoreReferenceFile
      40             : 
      41             :    Revision 1.11  2007/04/04 10:29:18  jgrosseo
      42             :    1) Storing of files to the Grid is now done _after_ your preprocessors succeeded. This is transparent, which means that you can still use the same functions (Store, StoreReferenceData) to store files to the Grid. However, the Shuttle first stores them locally and transfers them after the preprocessor finished. The return code of these two functions has changed from UInt_t to Bool_t which gives you the success of the storing.
      43             :    In case of an error with the Grid, the Shuttle will retry the storing later, the preprocessor does not need to be run again.
      44             : 
      45             :    2) The meaning of the return code of the preprocessor has changed. 0 is now success and any other value means failure. This value is stored in the log and you can use it to keep details about the error condition.
      46             : 
      47             :    3) New function StoreReferenceFile to _directly_ store a file (without opening it) to the reference storage.
      48             : 
      49             :    4) The memory usage of the preprocessor is monitored. If it exceeds 2 GB it is terminated.
      50             : 
      51             :    5) New function AliPreprocessor::ProcessDCS(). If you do not need to have DCS data in all cases, you can skip the processing by implemting this function and returning kFALSE under certain conditions. E.g. if there is a certain run type.
      52             :    If you always need DCS data (like before), you do not need to implement it.
      53             : 
      54             :    6) The run type has been added to the monitoring page
      55             : 
      56             :    Revision 1.9  2007/02/28 10:42:58  acolla
      57             :    Run type field added in SHUTTLE framework. Run type is read from "run type" logbook and retrieved by
      58             :    AliPreprocessor::GetRunType() function.
      59             : 
      60             :    Revision 1.7  2006/11/06 14:24:21  jgrosseo
      61             :    reading of run parameters from the logbook
      62             :    online offline naming conversion
      63             : 
      64             :    Revision 1.6  2006/10/02 12:57:48  jgrosseo
      65             :    Small interface change of function StoreReferenceData in Shuttle
      66             : 
      67             :    Revision 1.5  2006/09/04 17:42:34  hristov
      68             :    Changes required by Effective C++
      69             : 
      70             :    Revision 1.4  2006/08/08 14:20:49  jgrosseo
      71             :    Update to shuttle classes (Alberto)
      72             : 
      73             :    - Possibility to set the full object's path in the Preprocessor's and
      74             :    Shuttle's  Store functions
      75             :    - Possibility to extend the object's run validity in the same classes
      76             :    ("startValidity" and "validityInfinite" parameters)
      77             :    - Implementation of the StoreReferenceData function to store reference
      78             :    data in a dedicated CDB storage.
      79             : 
      80             :    Revision 1.3  2006/07/11 12:42:43  jgrosseo
      81             :    adding parameters for extended validity range of data produced by preprocessor
      82             : 
      83             :    Revision 1.2  2006/06/06 16:36:49  jgrosseo
      84             :    minor changes in AliShuttleInterface and AliPreprocessor
      85             : 
      86             :    Revision 1.1  2006/06/02 14:14:36  hristov
      87             : Separate library for CDB (Jan)
      88             : 
      89             :   Revision 1.2  2006/03/07 07:52:34  hristov
      90             : New version (B.Yordanov)
      91             : 
      92             :   Revision 1.3  2005/11/17 17:47:34  byordano
      93             :   TList changed to TObjArray
      94             : 
      95             :   Revision 1.2  2005/11/17 14:43:22  byordano
      96             :   import to local CVS
      97             : 
      98             :   Revision 1.1.1.1  2005/10/28 07:33:58  hristov
      99             :   Initial import as subdirectory in AliRoot
     100             : 
     101             :   Revision 1.1.1.1  2005/09/12 22:11:40  byordano
     102             :   SHUTTLE package
     103             : 
     104             :   Revision 1.2  2005/08/29 21:15:47  byordano
     105             :   some docs added
     106             : 
     107             :   */
     108             : 
     109             :   // Description:
     110             :   // This class is the CDBPreProcessor interface,
     111             :   // supposed to be implemented by any detector
     112             :   // interested in immediate processing of data 
     113             :   // which is retrieved from DCS.
     114             :   // For every particular run set of aliases and
     115             :   // their corespoding value sets are returned.
     116             :   // Usage schema:
     117             :   //    1) virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime) 
     118             :   //    This method is called at the begining of data retrieval.
     119             :   //    run: run number
     120             :   //    startTime: when the run started
     121             :   //    endTime: when the run finished  
     122             :   //
     123             :   //    2) virtual void Process()
     124             :   //
     125             :   //    This method is called and passed a list of retrieved values from DCS
     126             :   //
     127             :   //
     128             : 
     129             : 
     130             : #include "AliPreprocessor.h"
     131             : 
     132             : #include <TString.h>
     133             : #include <TMap.h>
     134             : #include <TObjString.h>
     135             : 
     136             : #include "AliLog.h"
     137             : #include "AliCDBMetaData.h"
     138             : #include "AliCDBStorage.h"
     139             : #include "AliCDBId.h"
     140             : #include "AliCDBPath.h"
     141             : #include "AliCDBEntry.h"
     142             : #include "AliShuttleInterface.h"
     143             : 
     144         128 : ClassImp(AliPreprocessor)
     145             : 
     146             : //______________________________________________________________________________________________
     147             : AliPreprocessor::AliPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
     148           0 :   TNamed(detector, ""),
     149           0 :   fRun(-1),
     150           0 :   fStartTime(0),
     151           0 :   fEndTime(0),
     152           0 :   fShuttle(shuttle),
     153           0 :   fRunTypes()
     154           0 : {
     155           0 :   SetTitle(Form("AliPreprocessor for %s subdetector.", detector));
     156             : 
     157           0 :   if (!fShuttle)
     158             :   {
     159           0 :     AliFatal("Initialized without Shuttle instance.");
     160             :     return;
     161             :   }
     162             : 
     163           0 :   fShuttle->RegisterPreprocessor(this);
     164             : 
     165           0 :   fRunTypes.SetOwner(kTRUE);
     166           0 : }
     167             : 
     168             : //______________________________________________________________________________________________
     169             : AliPreprocessor::~AliPreprocessor()
     170           0 : {
     171           0 : }
     172             : 
     173             : //______________________________________________________________________________________________
     174             : void AliPreprocessor::Initialize(Int_t run, UInt_t startTime,   UInt_t endTime)
     175             : {
     176             :   // Sets the information of the run which is currently processed
     177             :   // can be overriden for special behaviour, make sure that you call base class
     178             :   // function
     179             : 
     180           0 :   fRun = run;
     181           0 :   fStartTime = startTime;
     182           0 :   fEndTime = endTime;
     183           0 : }
     184             : 
     185             : //______________________________________________________________________________________________
     186             : Bool_t AliPreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
     187             :     AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
     188             : {
     189             :   // Stores a CDB object in the storage for offline reconstruction. Objects that are not needed for
     190             :   // offline reconstruction, but should be stored anyway (e.g. for debugging) should NOT be stored
     191             :   // using this function. Use StoreReferenceData instead!
     192             :   //
     193             :   // This function should be called at the end of the preprocessor cycle
     194             :   //
     195             :   // The parameters are
     196             :   //   1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
     197             :   //         by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
     198             :   //   3) the object to be stored
     199             :   //   4) the metaData to be associated with the object
     200             :   //   5) the validity start run number w.r.t. the current run,
     201             :   //      if the data is valid only for this run leave the default 0
     202             :   //   6) specifies if the calibration data is valid for infinity (this means until updated),
     203             :   //      typical for calibration runs, the default is kFALSE
     204             :   //
     205             :   // The call is delegated to AliShuttleInterface
     206             : 
     207           0 :   const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
     208           0 :   if(!offlineDetName) return 0;
     209             : 
     210           0 :   return fShuttle->Store(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
     211           0 :       metaData, validityStart, validityInfinite);
     212           0 : }
     213             : 
     214             : //______________________________________________________________________________________________
     215             : Bool_t AliPreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
     216             :     AliCDBMetaData* metaData)
     217             : {
     218             :   // Stores a CDB object in the storage for reference data. This objects will not be available during
     219             :   // offline reconstrunction. Use this function for reference data only!
     220             :   //
     221             :   // This function should be called at the end of the preprocessor cycle
     222             :   //
     223             :   // The parameters are
     224             :   //   1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
     225             :   //         by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
     226             :   //   3) the object to be stored
     227             :   //   4) the metaData to be associated with the object
     228             :   //
     229             :   // The call is delegated to AliShuttleInterface
     230             : 
     231           0 :   const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
     232           0 :   if(!offlineDetName) return 0;
     233             : 
     234           0 :   return fShuttle->StoreReferenceData(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
     235             :       metaData);
     236           0 : }
     237             : 
     238             : //______________________________________________________________________________________________
     239             : Bool_t AliPreprocessor::StoreReferenceFile(const char* localFile, const char* gridFileName)
     240             : {
     241             :   //
     242             :   // Stores a file directly (without opening it) in the reference storage in the Grid
     243             :   //
     244             :   // The file is stored under the following location: 
     245             :   // <base folder of reference storage>/<DET>/<RUN#>_<gridFileName>
     246             :   // where <gridFileName> is the second parameter given to the function
     247             :   //
     248             :   // The call is delegated to AliShuttleInterface
     249             : 
     250           0 :   const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
     251           0 :   if(!offlineDetName) return 0;
     252           0 :   return fShuttle->StoreReferenceFile(GetName(), localFile, gridFileName);
     253           0 : }
     254             : 
     255             : //______________________________________________________________________________________________
     256             : Bool_t AliPreprocessor::StoreRunMetadataFile(const char* localFile, const char* gridFileName)
     257             : {
     258             :   //
     259             :   // Stores Run metadata file to the Grid, in the run folder
     260             :   //
     261             :   // Only GRP can call this function.
     262             : 
     263           0 :   TString detName(GetName());
     264           0 :   if (detName != "GRP") 
     265             :   {
     266           0 :     Log("StoreRunMetadataFile - Only GRP can call this function.");
     267           0 :     return kFALSE;
     268             :   }
     269           0 :   return fShuttle->StoreRunMetadataFile(localFile, gridFileName);
     270           0 : }
     271             : 
     272             : //______________________________________________________________________________________________
     273             : const char* AliPreprocessor::GetFile(Int_t system, const char* id, const char* source)
     274             : {
     275             :   // This function retrieves a file from the given system (kDAQ, kDCS, kHLT) with the given file id
     276             :   // and from the given source in the system.
     277             :   // The function returnes the path to the local file.
     278             :   //
     279             :   // The call is delegated to AliShuttleInterface
     280             : 
     281           0 :   return fShuttle->GetFile(system, GetName(), id, source);
     282             : }
     283             : 
     284             : //______________________________________________________________________________________________
     285             : TList* AliPreprocessor::GetFileSources(Int_t system, const char* id)
     286             : {
     287             :   // Returns a list of sources in a given system that saved a file with the given id
     288             :   // if id is not given all sources are returned
     289             :   //
     290             :   // The call is delegated to AliShuttleInterface
     291             : 
     292           0 :   return fShuttle->GetFileSources(system, GetName(), id);
     293             : }
     294             : 
     295             : //______________________________________________________________________________________________
     296             : TList* AliPreprocessor::GetFileIDs(Int_t system, const char* source)
     297             : {
     298             :   // Returns a list of ids in a given system that saved a file with the given source
     299             :   //
     300             :   // The call is delegated to AliShuttleInterface
     301             : 
     302           0 :   return fShuttle->GetFileIDs(system, GetName(), source);
     303             : }
     304             : 
     305             : //______________________________________________________________________________________________
     306             : void AliPreprocessor::Log(const char* message, UInt_t level)
     307             : {
     308             :   // Adds a log message to the Shuttle log of this preprocessor
     309             :   //
     310             :   // The call is delegated to AliShuttleInterface
     311             : 
     312           0 :   fShuttle->Log(GetName(), message, level);
     313           0 : }
     314             : 
     315             : //______________________________________________________________________________________________
     316             : const char* AliPreprocessor::GetRunParameter(const char* param)
     317             : {
     318             :   // Return run parameter read from run logbook
     319             :   //
     320             :   // The call is delegated to AliShuttleInterface
     321             : 
     322           0 :   return fShuttle->GetRunParameter(param);
     323             : }
     324             : 
     325             : //______________________________________________________________________________________________
     326             : AliCDBEntry* AliPreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3)
     327             : {
     328             :   // Return object from OCDB valid for current run
     329             :   //
     330             :   // The call is delegated to AliShuttleInterface
     331             : 
     332           0 :   const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
     333           0 :   if (!offlineDetName) return 0;
     334             : 
     335           0 :   return dynamic_cast<AliCDBEntry*>
     336           0 :     (fShuttle->GetFromOCDB(GetName(), AliCDBPath(offlineDetName, pathLevel2, pathLevel3)));
     337           0 : }
     338             : 
     339             : //______________________________________________________________________________________________
     340             : AliCDBEntry* AliPreprocessor::GetGeometryFromOCDB()
     341             : {
     342             :   // Return geometry from OCDB (GRP/Geometry/Data) valid for current run
     343             :   //
     344             :   // The call is delegated to AliShuttleInterface
     345             : 
     346           0 :   return dynamic_cast<AliCDBEntry*>
     347           0 :     (fShuttle->GetFromOCDB(GetName(), AliCDBPath("GRP", "Geometry", "Data")));
     348           0 : }
     349             : 
     350             : //______________________________________________________________________________________________
     351             : const char* AliPreprocessor::GetRunType()
     352             : {
     353             :   // Return run type string read from "run type" logbook
     354             :   //
     355             :   // The call is delegated to AliShuttleInterface
     356             : 
     357           0 :   return fShuttle->GetRunType();
     358             : }
     359             : 
     360             : //______________________________________________________________________________________________
     361             : Bool_t AliPreprocessor::GetHLTStatus()
     362             : {
     363             :   // Return HLT status (ON or OFF)
     364             :   // Converts the HLT status from the status string read in the run logbook (not just a bool)
     365             :   // The call is delegated to AliShuttleInterface
     366             : 
     367           0 :   return fShuttle->GetHLTStatus();
     368             : 
     369             : }
     370             : 
     371             : //______________________________________________________________________________________________
     372             : const char* AliPreprocessor::GetTriggerConfiguration()
     373             : {
     374             :   // Returns the trigger configuration which is read from a table in the DAQ logbook
     375             :   // The call is delegated to AliShuttleInterface
     376             :   // Only GRP can call this function.
     377             : 
     378           0 :   TString detName(GetName());
     379           0 :   if (detName != "GRP") 
     380             :   {
     381           0 :     Log("GetTriggerConfiguration - Only GRP can call this function.");
     382           0 :     return 0;
     383             :   }
     384             : 
     385           0 :   return fShuttle->GetTriggerConfiguration();
     386           0 : }
     387             : //______________________________________________________________________________________________
     388             : const char* AliPreprocessor::GetCTPTimeParams()
     389             : {
     390             :   // Returns the CTP timing parameters read from a table in the DAQ logbook
     391             :   // The call is delegated to AliShuttleInterface
     392             :   // Only GRP can call this function.
     393             : 
     394           0 :   TString detName(GetName());
     395           0 :   if (detName != "GRP") 
     396             :   {
     397           0 :     Log("GetCTPTimeParams - Only GRP can call this function.");
     398           0 :     return 0;
     399             :   }
     400             : 
     401           0 :   return fShuttle->GetCTPTimeParams();
     402           0 : }
     403             : //______________________________________________________________________________________________
     404             : const char* AliPreprocessor::GetTriggerDetectorMask()
     405             : {
     406             :   // Returns the trigger detector mask which is read from a table in the DAQ logbook
     407             :   // The call is delegated to AliShuttleInterface
     408             :   // Only TRI can call this function.
     409             : 
     410           0 :   TString detName(GetName());
     411           0 :   if (detName != "TRI") 
     412             :   {
     413           0 :     Log("GetTriggerDetectorMask - Only TRI can call this function.");
     414           0 :     return 0;
     415             :   }
     416             : 
     417           0 :   return fShuttle->GetTriggerDetectorMask();
     418           0 : }
     419             : 
     420             : //______________________________________________________________________________________________
     421             : void AliPreprocessor::AddRunType(const char* runType)
     422             : {
     423             :   // adds the given run type to the list of run types that are processed
     424             :   // this function should be called in the constructor of the derived preprocessor
     425             : 
     426           0 :   if (!runType)
     427             :     return;
     428             : 
     429           0 :   fRunTypes.Add(new TObjString(runType));
     430           0 : }
     431             : 
     432             : //______________________________________________________________________________________________
     433             : Bool_t AliPreprocessor::AliPreprocessor::ProcessRunType()
     434             : {
     435             :   // searches for the current run type in the list of run types that are processed by this
     436             :   // preprocessor. The list is populated by AddRunType
     437             : 
     438           0 :   const char* runType = GetRunType();
     439             : 
     440           0 :   Log(Form("Checking if run type %s is in the list of run types to be processed by this preprocessor...", runType));
     441             : 
     442           0 :   if (fRunTypes.GetEntries() == 0)
     443           0 :     Log("WARNING! There are no run types defined. This preprocessor will never run.");
     444             : 
     445           0 :   if (fRunTypes.FindObject(runType))
     446             :   {
     447           0 :     Log("Run type found. Processing this run.");
     448           0 :     return kTRUE;
     449             :   }
     450             : 
     451           0 :   Log("Run type not found. Skipping this run.");
     452           0 :   return kFALSE;
     453           0 : }
     454             : //______________________________________________________________________________________________
     455             : UInt_t AliPreprocessor::GetStartTimeDCSQuery()
     456             : {
     457             :   // Return Start Time for the DCS query
     458             :   //
     459             :   // The call is delegated to AliShuttleInterface
     460             : 
     461           0 :   return fShuttle->GetStartTimeDCSQuery();
     462             : }
     463             : //______________________________________________________________________________________________
     464             : UInt_t AliPreprocessor::GetEndTimeDCSQuery()
     465             : {
     466             :   // Return End Time for the DCS query
     467             :   //
     468             :   // The call is delegated to AliShuttleInterface
     469             : 
     470           0 :   return fShuttle->GetEndTimeDCSQuery();
     471             : }
     472             : 
     473             : //______________________________________________________________________________________________
     474             : const char* AliPreprocessor::GetForeignFile(const char* detector, Int_t system, const char* id, const char* source)
     475             : {
     476             :   // This function retrieves a file produced from the given detector (different from the 
     477             :   // current one) from the given system (kDAQ, kDCS, kHLT) 
     478             :   // with the given file id
     479             :   // and from the given source in the system.
     480             :   // The function returnes the path to the local file.
     481             :   //
     482             :   // The call is delegated to AliShuttleInterface
     483             :   // The function can be called only from the GRP preprocessor
     484             : 
     485           0 :   TString detName(GetName());
     486           0 :   if (detName != "GRP") 
     487             :   {
     488           0 :     Log("GetForeignFile - Only GRP can call this function.");
     489           0 :     return 0;
     490             :   }
     491           0 :   return fShuttle->GetFile(system, detector, id, source);
     492           0 : }
     493             : 
     494             : //______________________________________________________________________________________________
     495             : TList* AliPreprocessor::GetForeignFileSources(const char* detector, Int_t system, const char* id)
     496             : {
     497             :   // Returns the list of sources in a given system that produced the file 
     498             :   // with the given id for the foreign detector specified
     499             :   //
     500             :   // The call is delegated to AliShuttleInterface
     501             :   // The function can be called only from the GRP preprocessor
     502             : 
     503           0 :   TString detName(GetName());
     504           0 :   if (detName != "GRP") 
     505             :   {
     506           0 :     Log("GetForeignFileSources - Only GRP can call this function.");
     507           0 :     return 0;
     508             :   }
     509           0 :   return fShuttle->GetFileSources(system, detector, id);
     510           0 : }
     511             : 
     512             : //______________________________________________________________________________________________
     513             : void AliPreprocessor::SendToML(const char* value)
     514             : {
     515             :   //
     516             :   // Sending to ML the information coming from the current detector
     517             :   //
     518             : 
     519           0 :   return fShuttle->SendMLFromDet(value);
     520             : }
     521             : //______________________________________________________________________________________________
     522             : TString* AliPreprocessor::GetLTUConfig(const char* det)
     523             : {
     524             :   // LTU config from logbook_detector table from DAQ logbook for detector det
     525             :   //
     526             :   // The call is delegated to AliShuttleInterface
     527             : 
     528           0 :   return fShuttle->GetLTUConfig(det);
     529             : }

Generated by: LCOV version 1.11