LCOV - code coverage report
Current view: top level - HLT/BASE - AliHLTDAQ.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 170 0.6 %
Date: 2016-06-14 17:26:59 Functions: 1 32 3.1 %

          Line data    Source code
       1             : // $Id$
       2             : 
       3             : //**************************************************************************
       4             : //* This file is property of and copyright by the ALICE HLT Project        * 
       5             : //* ALICE Experiment at CERN, All rights reserved.                         *
       6             : //*                                                                        *
       7             : //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
       8             : //*                  for The ALICE HLT Project.                            *
       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             : /// @file   AliHLTDAQ.cxx
      20             : /// @author Matthias Richter
      21             : /// @date   24.10.2008
      22             : /// @brief  Virtual Interface to the AliDAQ class.
      23             : ///
      24             : 
      25             : #include "AliHLTDAQ.h"
      26             : #include "AliHLTLogging.h"
      27             : #include "AliHLTDataTypes.h"
      28             : #include "AliHLTMisc.h"
      29             : #include "TClass.h"
      30             : #include "TSystem.h"
      31             : 
      32             : /** ROOT macro for the implementation of ROOT specific class methods */
      33         126 : ClassImp(AliHLTDAQ)
      34             : 
      35             : AliHLTDAQ::AliHLTDAQ()
      36           0 : {
      37             :   // see header file for class documentation
      38             :   // or
      39             :   // refer to README to build package
      40             :   // or
      41             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      42           0 : }
      43             : 
      44             : AliHLTDAQ* AliHLTDAQ::fgpInstance=NULL;
      45             : const char* AliHLTDAQ::fgkImplName="AliHLTDAQInterfaceImplementation";
      46             : const char* AliHLTDAQ::fgkImplLibrary="libHLTrec.so";
      47             : const char* AliHLTDAQ::fgkOriginMapping[] = {
      48             :   kAliHLTDataOriginITSSPD,  
      49             :   kAliHLTDataOriginITSSDD,
      50             :   kAliHLTDataOriginITSSSD,
      51             :   kAliHLTDataOriginTPC,
      52             :   kAliHLTDataOriginTRD,
      53             :   kAliHLTDataOriginTOF,
      54             :   kAliHLTDataOriginHMPID,
      55             :   kAliHLTDataOriginPHOS,
      56             :   kAliHLTDataOriginCPV,
      57             :   kAliHLTDataOriginPMD,
      58             :   kAliHLTDataOriginMUON,
      59             :   "", // MUONTRG
      60             :   kAliHLTDataOriginFMD,
      61             :   kAliHLTDataOriginT0,
      62             :   kAliHLTDataOriginVZERO,
      63             :   kAliHLTDataOriginZDC,
      64             :   kAliHLTDataOriginACORDE,
      65             :   kAliHLTDataOriginTRG,
      66             :   kAliHLTDataOriginEMCAL,
      67             :   kAliHLTDataOriginAD,
      68             :   NULL
      69             : };
      70             : 
      71             : AliHLTDAQ::~AliHLTDAQ()
      72           0 : {
      73             :   // see header file for class documentation
      74           0 : }
      75             : 
      76             : Int_t       AliHLTDAQ::NumberOfDetectors()
      77             : {
      78             :   // see header file for class documentation
      79           0 :   if (!fgpInstance) GetInstance();
      80           0 :   if (fgpInstance) return fgpInstance->VirtNumberOfDetectors();
      81           0 :   return -1;
      82           0 : }
      83             : 
      84             : Int_t       AliHLTDAQ::HLTId()
      85             : {
      86             :   // get the HLT ID
      87             :   // returns AliDAQ::kHLTId
      88           0 :   if (!fgpInstance) GetInstance();
      89           0 :   if (fgpInstance) return fgpInstance->VirtHLTId();
      90           0 :   return -1;
      91           0 : }
      92             : 
      93             : Int_t       AliHLTDAQ::DetectorID(const char *detectorName)
      94             : {
      95             :   // get the detector ID from the detector name
      96             :   // forwards to AliDAQ::DetectorName
      97           0 :   if (!fgpInstance) GetInstance();
      98           0 :   if (fgpInstance) return fgpInstance->VirtDetectorID(detectorName);
      99           0 :   return -1;
     100           0 : }
     101             : 
     102             : const char *AliHLTDAQ::DetectorName(Int_t detectorID)
     103             : {
     104             :   // get the detector name from the detector ID
     105             :   // forwards to AliDAQ::DetectorName
     106           0 :   if (!fgpInstance) GetInstance();
     107           0 :   if (fgpInstance) return fgpInstance->VirtDetectorName(detectorID);
     108           0 :   return NULL;
     109           0 : }
     110             : 
     111             : Int_t       AliHLTDAQ::DetectorIDFromHLTOrigin(const char dataorigin[kAliHLTComponentDataTypefOriginSize])
     112             : {
     113             :   // get the detector id from HLT origin
     114           0 :   for (int i=0; fgkOriginMapping[i]!=NULL; i++) {
     115           0 :     if (strncmp(fgkOriginMapping[i], dataorigin, kAliHLTComponentDataTypefOriginSize)==0) {
     116           0 :       return i;
     117             :     }
     118             :   }
     119             : 
     120           0 :   return -1;
     121           0 : }
     122             : 
     123             : const char *AliHLTDAQ::DetectorName(const char dataorigin[kAliHLTComponentDataTypefOriginSize])
     124             : {
     125             :   // get the detector name from HLT origin
     126           0 :   Int_t detectorID=DetectorIDFromHLTOrigin(dataorigin);
     127           0 :   if (detectorID<0) return NULL;
     128             : 
     129           0 :   return DetectorName(detectorID);
     130           0 : }
     131             : 
     132             : Int_t       AliHLTDAQ::DdlIDOffset(const char *detectorName)
     133             : {
     134             :   // get ID of the first DDL of a detector
     135             :   // forwards to AliDAQ::DdlIDOffset
     136           0 :   if (!fgpInstance) GetInstance();
     137           0 :   if (fgpInstance) return fgpInstance->VirtDdlIDOffset(detectorName);
     138           0 :   return -1;
     139           0 : }
     140             : 
     141             : Int_t       AliHLTDAQ::DdlIDOffset(Int_t detectorID)
     142             : {
     143             :   // get ID of the first DDL of a detector
     144             :   // forwards to AliDAQ::DdlIDOffset
     145           0 :   if (!fgpInstance) GetInstance();
     146           0 :   if (fgpInstance) return fgpInstance->VirtDdlIDOffset(detectorID);
     147           0 :   return -1;
     148           0 : }
     149             : 
     150             : const char *AliHLTDAQ::DetectorNameFromDdlID(Int_t ddlID, Int_t &ddlIndex)
     151             : {
     152             :   // get detector name from global DDL ID and index of DDL within the detector
     153             :   // forwards to AliDAQ::DetectorNameFromDdlID
     154           0 :   if (!fgpInstance) GetInstance();
     155           0 :   if (fgpInstance) return fgpInstance->VirtDetectorNameFromDdlID(ddlID, ddlIndex);
     156           0 :   return NULL;
     157           0 : }
     158             : 
     159             : Int_t       AliHLTDAQ::DetectorIDFromDdlID(Int_t ddlID, Int_t &ddlIndex)
     160             : {
     161             :   // get detector ID from global DDL ID and index of DDL within the detector
     162             :   // forwards to AliDAQ::DetectorNameFromDdlID
     163           0 :   if (!fgpInstance) GetInstance();
     164           0 :   if (fgpInstance) return fgpInstance->VirtDetectorIDFromDdlID(ddlID, ddlIndex);
     165           0 :   return -1;
     166           0 : }
     167             : 
     168             : Int_t       AliHLTDAQ::DdlID(const char *detectorName, Int_t ddlIndex)
     169             : {
     170             :   // get global DDL ID from detector name and index of DDL within the detector
     171             :   // forwards to AliDAQ::DdlID
     172           0 :   if (!fgpInstance) GetInstance();
     173           0 :   if (fgpInstance) return fgpInstance->VirtDdlID(detectorName, ddlIndex);
     174           0 :   return -1;
     175           0 : }
     176             : 
     177             : Int_t       AliHLTDAQ::DdlID(Int_t detectorID, Int_t ddlIndex)
     178             : {
     179             :   // get global DDL ID from detector ID and index of DDL within the detector
     180             :   // forwards to AliDAQ::DdlID
     181           0 :   if (!fgpInstance) GetInstance();
     182           0 :   if (fgpInstance) return fgpInstance->VirtDdlID(detectorID, ddlIndex);
     183           0 :   return -1;
     184           0 : }
     185             : 
     186             : const char *AliHLTDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex)
     187             : {
     188             :   // see header file for class documentation
     189           0 :   if (!fgpInstance) GetInstance();
     190           0 :   if (fgpInstance) return fgpInstance->VirtDdlFileName(detectorName, ddlIndex);
     191           0 :   return NULL;
     192           0 : }
     193             : 
     194             : const char *AliHLTDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex)
     195             : {
     196             :   // see header file for class documentation
     197           0 :   if (!fgpInstance) GetInstance();
     198           0 :   if (fgpInstance) return fgpInstance->VirtDdlFileName(detectorID, ddlIndex);
     199           0 :   return NULL;
     200           0 : }
     201             : 
     202             : Int_t       AliHLTDAQ::NumberOfDdls(const char *detectorName)
     203             : {
     204             :   // see header file for class documentation
     205           0 :   if (!fgpInstance) GetInstance();
     206           0 :   if (fgpInstance) return fgpInstance->VirtNumberOfDdls(detectorName);
     207           0 :   return -1;
     208           0 : }
     209             : 
     210             : Int_t       AliHLTDAQ::NumberOfDdls(Int_t detectorID)
     211             : {
     212             :   // see header file for class documentation
     213           0 :   if (!fgpInstance) GetInstance();
     214           0 :   if (fgpInstance) return fgpInstance->VirtNumberOfDdls(detectorID);
     215           0 :   return -1;
     216           0 : }
     217             : 
     218             : const char *AliHLTDAQ::ListOfTriggeredDetectors(UInt_t detectorPattern)
     219             : {
     220             :   // see header file for class documentation
     221           0 :   if (!fgpInstance) GetInstance();
     222           0 :   if (fgpInstance) return fgpInstance->VirtListOfTriggeredDetectors(detectorPattern);
     223           0 :   return NULL;
     224           0 : }
     225             : 
     226             : UInt_t      AliHLTDAQ::DetectorPattern(const char *detectorList)
     227             : {
     228             :   // see header file for class documentation
     229           0 :   if (!fgpInstance) GetInstance();
     230           0 :   if (fgpInstance) return fgpInstance->VirtDetectorPattern(detectorList);
     231           0 :   return 0;
     232           0 : }
     233             : 
     234             : const char *AliHLTDAQ::OfflineModuleName(const char *detectorName)
     235             : {
     236             :   // see header file for class documentation
     237           0 :   if (!fgpInstance) GetInstance();
     238           0 :   if (fgpInstance) return fgpInstance->VirtOfflineModuleName(detectorName);
     239           0 :   return NULL;
     240           0 : }
     241             : const char *AliHLTDAQ::OfflineModuleName(Int_t detectorID)
     242             : {
     243             :   // see header file for class documentation
     244           0 :   if (!fgpInstance) GetInstance();
     245           0 :   if (fgpInstance) return fgpInstance->VirtOfflineModuleName(detectorID);
     246           0 :   return NULL;
     247           0 : }
     248             : 
     249             : const char *AliHLTDAQ::OnlineName(const char *detectorName)
     250             : {
     251             :   // see header file for class documentation
     252           0 :   if (!fgpInstance) GetInstance();
     253           0 :   if (fgpInstance) return fgpInstance->VirtOnlineName(detectorName);
     254           0 :   return NULL;
     255           0 : }
     256             : const char *AliHLTDAQ::OnlineName(Int_t detectorID)
     257             : {
     258             :   // see header file for class documentation
     259           0 :   if (!fgpInstance) GetInstance();
     260           0 :   if (fgpInstance) return fgpInstance->VirtOnlineName(detectorID);
     261           0 :   return NULL;
     262           0 : }
     263             : 
     264             : string AliHLTDAQ::HLTOrigin(const char *detectorName)
     265             : {
     266             :   // get HLT origin from detector name
     267           0 :   return HLTOrigin(DetectorID(detectorName));
     268             : }
     269             : 
     270             : string AliHLTDAQ::HLTOrigin(Int_t detectorID)
     271             : {
     272             :   // get HLT origin from detector ID
     273           0 :   string origin;
     274           0 :   if (detectorID>=0 && (unsigned)detectorID<sizeof(fgkOriginMapping)/sizeof(const char*)) {
     275           0 :     origin.append(fgkOriginMapping[detectorID], kAliHLTComponentDataTypefOriginSize);
     276             :   }
     277             :   return origin;
     278           0 : }
     279             : 
     280             : string AliHLTDAQ::HLTSpecificationFromDdlID(Int_t ddlID)
     281             : {
     282             :   // get the HLT data specification from equipment id
     283           0 :   string result = "";
     284           0 :   Int_t ddlIndex=0;
     285           0 :   Int_t detectorID = DetectorIDFromDdlID(ddlID, ddlIndex);
     286           0 :   if (detectorID < 0)
     287           0 :     return result;
     288           0 :   Int_t TPCID = DetectorID("TPC");
     289             :   const int strtmplength=11;
     290           0 :   char strtmp[strtmplength];
     291           0 :   memset(strtmp, 0, strtmplength);
     292           0 :   if (detectorID == TPCID) {
     293             :     int partition;
     294             :     int slice;
     295           0 :     if (ddlID < 840) {
     296           0 :       partition = ddlID % 2;
     297           0 :       slice = (ddlID - 768) / 2;
     298           0 :     } else {
     299           0 :       partition = (ddlID % 4) + 2;
     300           0 :       slice = (ddlID - 840) / 4;
     301             :     }
     302           0 :     snprintf(strtmp, strtmplength, "0x%02x%02x%02x%02x", slice, slice, partition, partition);
     303           0 :     result = strtmp;
     304           0 :   }
     305           0 :   else if (detectorID == DetectorID("TOF")) {
     306           0 :     AliHLTLogging log;
     307           0 :     log.Logging(kHLTLogWarning, "AliHLTDAQ::HLTSpecificationFromDdlID", "HLT Analysis", "Mapping of data specification not implemented for TOF");
     308           0 :   }
     309             :   else { // default
     310           0 :     snprintf(strtmp, strtmplength, "0x%08x", 0x1 << ddlIndex);
     311           0 :     result = strtmp;
     312             :   }
     313             :   return result;
     314           0 : }
     315             : 
     316             : Int_t AliHLTDAQ::DdlIDFromHLTBlockData(const char dataorigin[kAliHLTComponentDataTypefOriginSize], UInt_t specification)
     317             : {
     318             :   // get the DDL ID (global equipment ID) from HLT origin and data specification
     319           0 :   Int_t detectorID=DetectorIDFromHLTOrigin(dataorigin);
     320           0 :   if (detectorID<0) return -1;
     321           0 :   Int_t ddlID=DdlIDOffset(detectorID);
     322           0 :   if (ddlID<0) return -1;
     323             : 
     324           0 :   if (detectorID == DetectorID("TPC")) {
     325           0 :     int minPartition= specification     &0xff;
     326           0 :     int maxPartition=(specification>>8) &0xff;
     327           0 :     int minSlice    =(specification>>16)&0xff;
     328           0 :     int maxSlice    =(specification>>24)&0xff;
     329           0 :     if (minPartition<0 || minPartition>5 ||
     330           0 :         maxPartition<0 || maxPartition>5 ||
     331           0 :         minSlice<0 || minSlice>35 ||
     332           0 :         maxSlice<0 || maxSlice>35) {
     333           0 :       AliHLTLogging log;
     334           0 :       log.Logging(kHLTLogError, "AliHLTDAQ::DdlID", "HLT Analysis", "invalid data specification 0x%08x", specification);
     335             :       return -1;
     336           0 :     }
     337           0 :     else if (minPartition!=maxPartition || 
     338           0 :              minSlice!=maxSlice) {
     339           0 :       AliHLTLogging log;
     340           0 :       log.Logging(kHLTLogError, "AliHLTDAQ::DdlID", "HLT Analysis", "ambiguous data specification 0x%08x", specification);
     341             :       return -1;
     342           0 :     }
     343           0 :     if (minPartition<2) ddlID+=2*minSlice+minPartition;        // inner sector
     344           0 :     else                ddlID+=4*minSlice+(minPartition-2)+72; // outer sector
     345           0 :   }
     346           0 :   else if (detectorID == DetectorID("TOF")) {
     347           0 :     AliHLTLogging log;
     348           0 :     log.Logging(kHLTLogWarning, "AliHLTDAQ::DdlID", "HLT Analysis", "Mapping of data specification not implemented for TOF");
     349             :     return -1;
     350           0 :   }
     351             :   else { // default
     352           0 :     for (int i=0; i<32; i++) {
     353           0 :       if ((specification&(0x1<<i))==0) continue; // if bit not set
     354           0 :       if ((specification&(0xffffffff^(0x1<<i)))!=0) { // check if other bits set
     355           0 :         AliHLTLogging log;
     356           0 :         log.Logging(kHLTLogError, "AliHLTDAQ::DdlID", "HLT Analysis", "ambiguous data specification 0x%08x", specification);
     357             :         return -1;
     358           0 :       }
     359           0 :       ddlID+=i;
     360           0 :       break;
     361             :     }
     362             :   }
     363             : 
     364           0 :   return ddlID;
     365           0 : }
     366             : 
     367             : AliHLTDAQ* AliHLTDAQ::GetInstance()
     368             : {
     369             :   // see header file for class documentation
     370           0 :   if (!fgpInstance) {
     371           0 :     fgpInstance=AliHLTMisc::LoadInstance((AliHLTDAQ*)NULL, fgkImplName, fgkImplLibrary);
     372           0 :     if (!fgpInstance) {
     373           0 :       AliHLTLogging log;
     374           0 :       log.Logging(kHLTLogError, "AliHLTDAQ::Instance", "HLT Analysis", "failed to load AliHLTDAQ implementation");
     375           0 :     }
     376             :   }
     377           0 :   return fgpInstance;
     378           0 : }

Generated by: LCOV version 1.11