LCOV - code coverage report
Current view: top level - HLT/QA - AliHLTQADataMakerRec.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 34 111 30.6 %
Date: 2016-06-14 17:26:59 Functions: 5 12 41.7 %

          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   AliHLTQADataMakerRec.cxx
      20             : /// @author Matthias Richter
      21             : /// @date   2010-03-10
      22             : /// @brief  Steering class for the HLT offline QA
      23             : ///
      24             : #include "AliHLTQADataMakerRec.h"
      25             : #include "AliHLTMisc.h"
      26             : #include "AliHLTModuleAgent.h"
      27             : #include "AliRecoParam.h"
      28             : #include <iostream>
      29             : #include "TString.h"
      30             : #include "TObjString.h"
      31             : #include "TObjArray.h"
      32             : #include "TDirectory.h"
      33             : 
      34             : using namespace std;
      35             : 
      36             : /** ROOT macro for the implementation of ROOT specific class methods */
      37           6 : ClassImp(AliHLTQADataMakerRec)
      38             : 
      39             : AliHLTQADataMakerRec::AliHLTQADataMakerRec()
      40           2 :   : AliHLTQADataMakerBase()
      41           2 :   , fPlugins()
      42           2 :   , fFlags(0)
      43          10 : {
      44             :   // see header file for class documentation
      45             :   // or
      46             :   // refer to README to build package
      47             :   // or
      48             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      49             : 
      50           2 :   LoadAgents();
      51           4 : }
      52             : 
      53             : AliHLTQADataMakerRec::~AliHLTQADataMakerRec()
      54           0 : {
      55             :   // see header file for class documentation
      56           0 : }
      57             : 
      58             : int AliHLTQADataMakerRec::LoadAgents()
      59             : {
      60             :   // iterate over available agents and query class names of plugins
      61           4 :   TString plugins;
      62          46 :   for (AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); 
      63          22 :        pAgent!=NULL;
      64          20 :        pAgent=AliHLTModuleAgent::GetNextAgent()) {
      65          20 :     const char* modulePlugins=pAgent->GetQAPlugins();
      66          58 :     if (!modulePlugins || !modulePlugins[0]) continue;
      67           4 :     if (!plugins.IsNull() && !plugins.EndsWith(" ")) plugins+=" ";
      68           2 :     plugins+=modulePlugins;
      69           2 :   }
      70          10 :   if (!plugins.IsNull()) return LoadPlugins(plugins);
      71           0 :   return 0;
      72           2 : }
      73             : 
      74             : int AliHLTQADataMakerRec::LoadPlugins(const char* plugins)
      75             : {
      76             :   // load plugins from list of blank separated class names
      77             :   int iResult=0;
      78           4 :   TString strPlugins=plugins;
      79           6 :   TObjArray* tokens=strPlugins.Tokenize(" ");
      80           2 :   if (tokens) {
      81           2 :     TIter next(tokens);
      82             :     TObject* obj=NULL;
      83          10 :     while ((obj=next())) {
      84           6 :       TObjString* objstring=dynamic_cast<TObjString*>(obj);
      85           2 :       if (!objstring) continue;
      86           4 :       AliHLTQADataMakerBase* plugin=AliHLTMisc::LoadInstance((AliHLTQADataMakerBase*)0,
      87           4 :                                                              objstring->GetString().Data());
      88           2 :       if (!plugin) continue;
      89          10 :       AliInfo(Form("using HLT QA plugin %s", plugin->IsA()->GetName()));
      90           2 :       fPlugins.Add(plugin);
      91           2 :     }
      92           4 :     delete tokens;
      93           2 :   }
      94             :   return iResult;
      95           2 : }
      96             : 
      97             : void AliHLTQADataMakerRec::StartOfDetectorCycle()
      98             : {
      99             :   // see header file for class documentation
     100             :   
     101             :   // this function is called multiple times by the framework, actually for every QA task
     102             :   // however, here we don't have any argument for the task
     103             :   // this class is initialized right before StartOfDetectorCycle is called, and depending
     104             :   // on the availibility of thr histogram arrays one can tell where we are ;-)
     105             :   unsigned init=0;
     106           0 :   if (fDigitsQAList!=NULL && (fFlags&kDigitsListInit)==0) {
     107             :     init|=kDigitsListInit; // indicate that plugins should be initialized for that task
     108           0 :     fFlags|=kDigitsListInit; // indicate that it was initialized
     109           0 :   }
     110           0 :   if (fESDsQAList!=NULL && (fFlags&kESDsListInit)==0) {
     111           0 :     init|=kESDsListInit; // indicate that plugins should be initialized for that task
     112           0 :     fFlags|=kESDsListInit; // indicate that it was initialized
     113           0 :   }
     114           0 :   if (fRawsQAList!=NULL && (fFlags&kRawsListInit)==0) {
     115           0 :     init|=kRawsListInit; // indicate that plugins should be initialized for that task
     116           0 :     fFlags|=kRawsListInit; // indicate that it was initialized
     117           0 :   }
     118           0 :   if (fRecPointsQAList!=NULL && (fFlags&kRecPointsListInit)==0) {
     119           0 :     init|=kRecPointsListInit; // indicate that plugins should be initialized for that task
     120           0 :     fFlags|=kRecPointsListInit; // indicate that it was initialized
     121           0 :   }
     122             : 
     123           0 :   TIter next(&fPlugins);
     124             :   TObject* obj=NULL;
     125           0 :   while ((obj=next())) {
     126           0 :     AliHLTQADataMakerBase* plugin=dynamic_cast<AliHLTQADataMakerBase*>(obj);
     127           0 :     if (!plugin) continue;
     128             :     // transfer the properties set in AliQAManager::GetQADataMaker to the plugin
     129           0 :     plugin->SetName(GetName());
     130           0 :     plugin->SetUniqueID(GetUniqueID());
     131           0 :     if (init&kDigitsListInit) plugin->Init(AliQAv1::GetTaskIndex("Digits"), 0);
     132           0 :     if (init&kESDsListInit) plugin->Init(AliQAv1::GetTaskIndex("ESDs"), 0);
     133           0 :     if (init&kRawsListInit) plugin->Init(AliQAv1::GetTaskIndex("Raws"), 0);
     134           0 :     if (init&kRecPointsListInit) plugin->Init(AliQAv1::GetTaskIndex("RecPoints"), 0);
     135           0 :     plugin->StartOfDetectorCycle();
     136           0 :   }
     137           0 : }
     138             : 
     139             : void AliHLTQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray** list)
     140             : {
     141             :   // see header file for class documentation
     142           0 :   TIter next(&fPlugins);
     143             :   TObject* obj=NULL;
     144           0 :   Bool_t dirStatusBackup = gDirectory->AddDirectoryStatus();
     145           0 :   gDirectory->AddDirectory(kFALSE);
     146           0 :   while ((obj=next())) {
     147           0 :     AliHLTQADataMakerBase* plugin=dynamic_cast<AliHLTQADataMakerBase*>(obj);
     148           0 :     if (!plugin) continue;
     149           0 :     plugin->SetEventSpecie(GetEventSpecie());
     150             : 
     151             :     TObjArray** pluginList=NULL;
     152           0 :     if (task==AliQAv1::kESDS) {
     153           0 :       pluginList=plugin->GetESDsQAList();
     154           0 :     } else if (task==AliQAv1::kRECPOINTS) {
     155           0 :       pluginList=plugin->GetRecPointsQAList();
     156           0 :     } else if (task==AliQAv1::kDIGITS) {
     157           0 :       pluginList=plugin->GetDigitsQAList();
     158           0 :     } else if (task==AliQAv1::kRAWS) {
     159           0 :       pluginList=plugin->GetRawsQAList();
     160           0 :     }
     161             : 
     162           0 :     if (pluginList) {
     163           0 :       plugin->EndOfDetectorCycle(task, pluginList);
     164           0 :       for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
     165           0 :         if (!pluginList[specie]) continue;
     166           0 :         TIter nextentry(pluginList[specie]);
     167             :         TObject* entry=NULL;
     168           0 :         while ((entry=nextentry())) {
     169           0 :           AliInfo(Form("cloning histogram %s for specie %d", entry->GetName(), specie));
     170           0 :           list[specie]->Add(entry->Clone());
     171             :         }
     172           0 :       }
     173           0 :     }
     174           0 :   }
     175           0 :   gDirectory->AddDirectory(dirStatusBackup);
     176           0 : }
     177             : 
     178             : void AliHLTQADataMakerRec::MakeRaws(AliRawReader * rawReader)
     179             : {
     180             :   // see header file for class documentation
     181           0 :   if (!rawReader) return;
     182             : 
     183           0 :   TIter next(&fPlugins);
     184             :   TObject* obj=NULL;
     185           0 :   while ((obj=next())) {
     186           0 :     AliHLTQADataMakerBase* plugin=dynamic_cast<AliHLTQADataMakerBase*>(obj);
     187           0 :     if (!plugin) continue;
     188           0 :     plugin->SetEventSpecie(GetEventSpecie());
     189           0 :     plugin->MakeRaws(rawReader);
     190           0 :   }
     191           0 : }
     192             : 
     193             : void AliHLTQADataMakerRec::MakeESDs(AliESDEvent * esd, AliESDEvent* hltesd)
     194             : {
     195             :   // HLT QA on ESDs
     196           0 :   TIter next(&fPlugins);
     197             :   TObject* obj=NULL;
     198           0 :   while ((obj=next())) {
     199           0 :     AliHLTQADataMakerBase* plugin=dynamic_cast<AliHLTQADataMakerBase*>(obj);
     200           0 :     if (!plugin) continue;
     201           0 :     plugin->SetEventSpecie(GetEventSpecie());
     202           0 :     plugin->MakeESDs(esd, hltesd);
     203           0 :   }
     204           0 : }

Generated by: LCOV version 1.11