LCOV - code coverage report
Current view: top level - HLT/TRD - AliHLTTRDHistoMergerComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 83 14.5 %
Date: 2016-06-14 17:26:59 Functions: 7 15 46.7 %

          Line data    Source code
       1             : // $Id$
       2             : //**************************************************************************
       3             : //* This file is property of and copyright by the ALICE HLT Project        * 
       4             : //* ALICE Experiment at CERN, All rights reserved.                         *
       5             : //*                                                                        *
       6             : //* Primary Authors:                                                       *
       7             : //*                  for The ALICE HLT Project.                            *
       8             : //*                                                                        *
       9             : //* Permission to use, copy, modify and distribute this software and its   *
      10             : //* documentation strictly for non-commercial purposes is hereby granted   *
      11             : //* without fee, provided that the above copyright notice appears in all   *
      12             : //* copies and that both the copyright notice and this permission notice   *
      13             : //* appear in the supporting documentation. The authors make no claims     *
      14             : //* about the suitability of this software for any purpose. It is          *
      15             : //* provided "as is" without express or implied warranty.                  *
      16             : //**************************************************************************
      17             : 
      18             : /** @file   AliHLTTRDHistoMergerComponent.cxx
      19             :     @author Theodor Rascanu
      20             :     @brief  Component for adding histos of partition wise working histo components
      21             : */
      22             : 
      23             : #include "TFile.h"
      24             : #include "TString.h"
      25             : #include "TObjString.h"
      26             : #include "TObjArray.h"
      27             : #include "TH1F.h"
      28             : 
      29             : #include "AliHLTTRDHistoMergerComponent.h"
      30             : #include "AliHLTTRDDefinitions.h"
      31             : #include "AliHLTTRDUtils.h"
      32             : 
      33             : #define stringCompare(a,b) !(strcmp(a,b))
      34             : 
      35             : //#include "AliHLTTRD.h"
      36             : //#include <stdlib.h>
      37             : //#include <cerrno>
      38             : 
      39             : using namespace std;
      40             : 
      41             : /** ROOT macro for the implementation of ROOT specific class methods */
      42           6 : ClassImp(AliHLTTRDHistoMergerComponent)
      43             : 
      44             : AliHLTTRDHistoMergerComponent::AliHLTTRDHistoMergerComponent()
      45           3 : : AliHLTProcessor(),
      46           3 :   fOutputSize(500000)
      47          15 : {
      48             :   // see header file for class documentation
      49             :   // or
      50             :   // refer to README to build package
      51             :   // or
      52             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      53             : 
      54          60 :   for(int i=0; i<9; i++)
      55          27 :     fHistoArr[i]=NULL;
      56             : 
      57         114 :   for(int i=0; i<18; i++)
      58          54 :     fIncSM[i]=kFALSE;
      59             : 
      60           6 : }
      61             : 
      62             : AliHLTTRDHistoMergerComponent::~AliHLTTRDHistoMergerComponent()
      63          12 : {
      64             :   // see header file for class documentation
      65          12 : }
      66             : 
      67             : // Public functions to implement AliHLTComponent's interface.
      68             : // These functions are required for the registration process
      69             : 
      70             : const char* AliHLTTRDHistoMergerComponent::GetComponentID()
      71             : {
      72             :   // see header file for class documentation
      73             :   
      74         114 :   return "TRDHistoMerger";
      75             : }
      76             : 
      77             : void AliHLTTRDHistoMergerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
      78             : {
      79             :   // see header file for class documentation
      80           0 :   list.clear();
      81           0 :   list.push_back(kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD);
      82           0 : }
      83             : 
      84             : AliHLTComponentDataType AliHLTTRDHistoMergerComponent::GetOutputDataType()
      85             : {
      86             :   // see header file for class documentation
      87           0 :   return kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD;
      88             : 
      89             : }
      90             : 
      91             : void AliHLTTRDHistoMergerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
      92             : {
      93             :   // see header file for class documentation
      94           0 :   constBase = fOutputSize;
      95           0 :   inputMultiplier = 0;
      96           0 : }
      97             : 
      98             : AliHLTComponent* AliHLTTRDHistoMergerComponent::Spawn()
      99             : {
     100             :   // see header file for class documentation
     101           0 :   return new AliHLTTRDHistoMergerComponent;
     102           0 : }
     103             : 
     104             : int AliHLTTRDHistoMergerComponent::DoInit(int argc, const char** argv)
     105             : {
     106             : 
     107             :   int iResult=0;
     108             :   
     109           0 :   TString configuration="";
     110           0 :   TString argument="";
     111           0 :   for (int i=0; i<argc && iResult>=0; i++) {
     112           0 :     argument=argv[i];
     113           0 :     if (!configuration.IsNull()) configuration+=" ";
     114           0 :     configuration+=argument;
     115             :   }
     116             : 
     117           0 :   if (!configuration.IsNull()) {
     118           0 :     iResult=Configure(configuration.Data());
     119           0 :   }
     120             : 
     121           0 :   for(int i=0; i<9; i++)
     122           0 :     fHistoArr[i]=NULL;
     123             : 
     124           0 :   for(int i=0; i<18; i++)
     125           0 :     fIncSM[i]=kFALSE;
     126             :  
     127             :   return 0;
     128           0 : }
     129             :   
     130             : int AliHLTTRDHistoMergerComponent::DoDeinit()
     131             : {
     132             :   // see header file for class documentation
     133             : 
     134           0 :   return 0;
     135             : }
     136             : 
     137             : int AliHLTTRDHistoMergerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
     138             :                                             AliHLTComponentTriggerData& /*trigData*/)
     139             : {
     140           0 :   if(!IsDataEvent())return 0;
     141             : 
     142             :   int histNr = 0;
     143             :   int lastSM = -1;
     144             : 
     145           0 :   for(const TObject* iter = GetFirstInputObject(kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD);
     146           0 :         iter != NULL; iter = GetNextInputObject() ) {
     147             : 
     148           0 :     if(!dynamic_cast<const TH1*>(iter))
     149             :       continue;
     150             : 
     151           0 :     AliHLTUInt32_t spec = GetSpecification(iter);
     152           0 :     int SM = AliHLTTRDUtils::GetSM(spec);
     153             : 
     154           0 :     if(SM!=lastSM){
     155           0 :       if(fIncSM[SM]){
     156           0 :         for(int i = 0; fHistoArr[i]; i++){
     157           0 :           PushBack((TObject*)fHistoArr[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, 0);
     158           0 :           delete fHistoArr[i];
     159           0 :           fHistoArr[i] = NULL;
     160             :         }
     161           0 :         for(int i=0; i<18; i++)
     162           0 :           fIncSM[i]=kFALSE;
     163           0 :       }
     164             :       lastSM = SM;
     165             :       histNr = 0;
     166           0 :       fIncSM[SM]=kTRUE;
     167           0 :     }
     168             : 
     169           0 :     if(histNr>9){
     170           0 :       HLTError("Got more histogramms than expected.");
     171           0 :       return 0;
     172             :     }
     173             : 
     174           0 :     if(!fHistoArr[histNr]) fHistoArr[histNr] = (TH1*)iter->Clone();
     175           0 :     else if(stringCompare(fHistoArr[histNr]->GetName(),iter->GetName()))
     176           0 :       fHistoArr[histNr]->Add((TH1*)iter);
     177             : 
     178           0 :     histNr++;
     179           0 :   }
     180             : 
     181           0 :   return 0;
     182           0 : }
     183             : 
     184             : int AliHLTTRDHistoMergerComponent::Configure(const char* arguments){
     185             :   int iResult=0;
     186           0 :   if (!arguments) return iResult;
     187             :   
     188           0 :   TString allArgs=arguments;
     189           0 :   TString argument;
     190             :   int bMissingParam=0;
     191             : 
     192           0 :   TObjArray* pTokens=allArgs.Tokenize(" ");
     193           0 :   if (pTokens) {
     194           0 :     for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
     195           0 :       argument=((TObjString*)pTokens->At(i))->GetString();
     196           0 :       if (argument.IsNull()) continue;
     197             :       
     198           0 :       if (argument.CompareTo("output_size")==0) {
     199           0 :         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
     200           0 :         HLTInfo("Setting output size to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
     201           0 :         fOutputSize=((TObjString*)pTokens->At(i))->GetString().Atoi();
     202           0 :         continue;
     203             :       } 
     204             :       else {
     205           0 :         HLTError("unknown argument: %s", argument.Data());
     206             :         iResult=-EINVAL;
     207           0 :         break;
     208             :       }
     209             :     }
     210           0 :     delete pTokens;
     211             :   }
     212           0 :   if (bMissingParam) {
     213           0 :     HLTError("missing parameter for argument %s", argument.Data());
     214             :     iResult=-EINVAL;
     215           0 :   }
     216             :   return iResult;
     217           0 : }

Generated by: LCOV version 1.11