LCOV - code coverage report
Current view: top level - HLT/EMCAL - AliHLTEMCALAgent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 26 123 21.1 %
Date: 2016-06-14 17:26:59 Functions: 7 24 29.2 %

          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: Federico Ronchetti                                    *
       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   AliHLTEMCALAgent.cxx
      19             :  @author Federico Ronchetti
      20             :  @date   
      21             :  @brief  Agent of the libAliHLTEMCAL library
      22             :  */
      23             : 
      24             : #include "AliHLTEMCALAgent.h"
      25             : #include "AliHLTConfiguration.h"
      26             : #include "AliHLTEMCALDefinitions.h"
      27             : #include "AliHLTOUT.h"
      28             : #include "AliHLTOUTHandlerChain.h"
      29             : #include "AliHLTErrorGuard.h"
      30             : #include "AliRunLoader.h"
      31             : #include "AliDAQ.h"
      32             : #include "AliCDBManager.h"
      33             : #include "AliCDBEntry.h"
      34             : 
      35             : 
      36             : // #include "AliHLTEMCALConstant.h"
      37             : #include "AliHLTEMCALConstants.h"
      38             : #include "AliHLTEMCALMapper.h"
      39             : 
      40             : /** global instance for agent registration */
      41           6 : AliHLTEMCALAgent gAliHLTEMCALAgent;
      42             : 
      43             : // component headers
      44             : //#include "AliHLTEMCALCalibrationComponent.h"
      45             : #include "AliHLTCaloClusterAnalyser.h"
      46             : #include "AliHLTEMCALClusterizerComponent.h"
      47             : #include "AliHLTEMCALDigitMakerComponent.h"
      48             : //#include "AliHLTEMCALESDEntriesMakerComponent.h"
      49             : //#include "AliHLTEMCALHistogramProducerComponent.h"
      50             : //#include "AliHLTEMCALModuleCalibrationProcessorComponent.h"
      51             : //#include "AliHLTEMCALMonitorTriggerComponent.h"
      52             : #include "AliHLTEMCALRawAnalyzerComponent.h"
      53             : #include "AliHLTEMCALRawAnalyzerStandardComponent.h"
      54             : #include "AliHLTEMCALRawAnalyzerPeakFinderComponent.h"
      55             : #include "AliHLTEMCALRawAnalyzerComponentTRU.h"
      56             : #include "AliHLTEMCALRawAnalyzerComponentSTU.h"
      57             : #include "AliHLTEMCALTriggerDataMakerComponent.h"
      58             : //#include "AliHLTEMCALRcuCalibrationProcessorComponent.h"
      59             : //#include "AliHLTEMCALRcuDAComponent.h"
      60             : #include "AliHLTEMCALRawAnalyzerCrudeComponent.h"
      61             : #include "AliHLTEMCALRawAnalyzerLMSComponent.h"
      62             : #include "AliHLTEMCALRawAnalyzerFastFitComponent.h"
      63             : #include "AliHLTEMCALRawAnalyzerNNComponent.h"
      64             : #include "AliHLTEMCALClusterizerComponentNbyN.h"
      65             : #include "AliHLTEMCALTriggerMakerComponent.h"
      66             : #include "AliHLTEMCALTriggerQAComponent.h"
      67             : 
      68             : /** ROOT macro for the implementation of ROOT specific class methods */
      69           6 : ClassImp(AliHLTEMCALAgent)
      70             : 
      71           3 : AliHLTEMCALAgent::AliHLTEMCALAgent() : AliHLTModuleAgent("EMCAL")
      72           3 :   , fRawDataHandler(NULL)
      73           3 :   , fMappers()
      74          15 : {
      75             :     // see header file for class documentation
      76             :     // or
      77             :     // refer to README to build package
      78             :     // or
      79             :     // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      80           6 : }
      81             : 
      82           0 : AliHLTEMCALAgent::~AliHLTEMCALAgent()
      83          12 : {
      84             :     // see header file for class documentation
      85           6 : }
      86             : 
      87             : UInt_t AliHLTEMCALAgent::GetDetectorMask() const
      88             : {
      89           0 :   return AliDAQ::kEMCAL;
      90             : }
      91             : 
      92             : int AliHLTEMCALAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
      93             :                                            AliRawReader* /*rawReader*/,
      94             :                                            AliRunLoader* /*runloader*/) const
      95             : {
      96             :     // see header file for class documentation
      97           0 :     if (handler) 
      98             :     {
      99             :         //      const char* cdbEntry="EMCAL/Calib/Parameters";
     100             :         //AliCDBManager* pMan=AliCDBManager::Instance();
     101             :         //AliEMCALParam* pEMCALParam=NULL;
     102             :         
     103             :         //       if (pMan) 
     104             :         //      {
     105             :         //        AliCDBEntry *pEntry = pMan->Get(cdbEntry);
     106             :         //        if (pEntry && 
     107             :         //            pEntry->GetObject() &&
     108             :         //            (pEMCALParam=dynamic_cast<AliEMCALParam*>(pEntry->GetObject()))) 
     109             :         //          {
     110             :         //          } else 
     111             :         //          {
     112             :         //            HLTWarning("can not load AliEMCALParam from CDB entry %s", cdbEntry);
     113             :         //          }
     114             :         //      }
     115             :         
     116             :         Int_t ddlOffset = 4608; 
     117             :         
     118           0 :         TString mergerInput;
     119           0 :         TString sinkClusterInput;
     120           0 :         TString emInput;
     121           0 :         TString tmInput;   // Input for trigger maker
     122           0 :         TString tdInput;   // Input for trigger data maker
     123           0 :         TString arg;
     124             :         
     125           0 :         TString clInput, rps;
     126             : 
     127           0 :         for (int module = 0; module <= AliDAQ::NumberOfDdls("EMCAL"); module++)
     128             :         {
     129           0 :            TString publisher, ra, ta, dm;
     130             :            // raw data publisher components
     131           0 :            publisher.Form("EMCAL-RP_%02d", module);
     132           0 :            arg.Form("-verbose -minid %d -datatype 'DDL_RAW ' 'EMCA'  -dataspec %d ", ddlOffset + module, module);
     133             :                 
     134           0 :            if(rps.Length()) rps += " ";
     135           0 :            rps += publisher;
     136           0 :            handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
     137           0 :         }
     138             :                 
     139             :        // Raw analyzer
     140           0 :        arg = "";
     141           0 :        handler->CreateConfiguration("EMCAL-RA", "EmcalRawCrude", rps.Data(), arg.Data());
     142             :                 
     143             :        // Raw analyzer for TRU data
     144           0 :        arg = "";
     145           0 :        handler->CreateConfiguration("EMCAL-TRU", "EmcalTruAnalyzer", rps.Data(), arg.Data());
     146           0 :        if(tdInput.Length() > 0) tdInput += " ";
     147           0 :        tdInput += "EMCAL-TRU";
     148             : 
     149             :        // STU raw analyser
     150           0 :        handler->CreateConfiguration("EMCAL-STU", "EmcalStuAnalyzer", rps.Data(), "");
     151           0 :        tdInput += " EMCAL-STU";
     152             : 
     153             :        // digit maker components
     154           0 :        arg="";
     155           0 :        arg.Form("-sethighgainfactor 0.0153 -setlowgainfactor 0.2448 -setdigitthresholds 0.005 0.002");
     156           0 :        handler->CreateConfiguration("EMCAL-DM", "EmcalDigitMaker", "EMCAL-RA", arg.Data());
     157           0 :        if(tmInput.Length() > 0) tmInput += " ";
     158           0 :        tmInput+ "EMCAL-DM";
     159             :             
     160           0 :        arg = "";
     161           0 :        arg.Form("-digitthreshold 0.005 -recpointthreshold 0.1 -modulemode");
     162           0 :        handler->CreateConfiguration("EMCAL-CF", "EmcalClusterizer", clInput.Data(), arg.Data());
     163             :             
     164             :        //ca.Form("EMCAL-CA_%02d", module);
     165             :        //arg = " ";
     166             :        //handler->CreateConfiguration(ca.Data(), "CaloClusterAnalyser", cl.Data(), arg.Data());
     167             :             
     168             : 
     169             :         // Tigger data merger
     170           0 :        handler->CreateConfiguration("EMCAL-TRG", "EmcalTriggerDataMaker", tdInput.Data(), "");
     171           0 :        tmInput += " EMCAL-TRG";
     172             : 
     173           0 :        handler->CreateConfiguration("EMCAL-TM", "EmcalTriggerMaker", tmInput.Data(), "");
     174             :         
     175           0 :        TString em;
     176             :         
     177             :         // tracker finder components
     178             :         
     179             :         // later
     180             :         //      em.Form("EMCAL-EM");
     181             :         //arg = " ";
     182             :         //handler->CreateConfiguration(em.Data(), "EmcalEsdEntriesMaker", emInput.Data(), " ");
     183             :         
     184           0 :     }
     185           0 :     return 0;
     186           0 : }
     187             : 
     188             : const char* AliHLTEMCALAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
     189             :                                                       AliRunLoader* runloader) const
     190             : {
     191             :     // see header file for class documentation
     192             :     if (runloader) {
     193             :         // reconstruction chains for AliRoot simulation
     194             :         // Note: run loader is only available while running embedded into
     195             :         // AliRoot simulation
     196             :         
     197             :         // if (runloader->GetLoader("EMCALLoader") != NULL)
     198             :         //     return "EMCAL-EM";
     199             :     }
     200           0 :     return NULL;
     201             : }
     202             : 
     203             : const char* AliHLTEMCALAgent::GetRequiredComponentLibraries() const
     204             : {
     205             :     // see header file for class documentation
     206           0 :     return NULL;
     207             : }
     208             : 
     209             : int AliHLTEMCALAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
     210             : {
     211             :     // see header file for class documentation
     212           6 :     if (!pHandler) return -EINVAL;
     213             :     
     214           6 :     pHandler->AddComponent(new AliHLTEMCALRawAnalyzerStandardComponent);
     215           6 :     pHandler->AddComponent(new AliHLTEMCALRawAnalyzerCrudeComponent);
     216           6 :     pHandler->AddComponent(new AliHLTEMCALRawAnalyzerLMSComponent);
     217           6 :     pHandler->AddComponent(new AliHLTEMCALRawAnalyzerPeakFinderComponent);
     218           6 :     pHandler->AddComponent(new AliHLTEMCALRawAnalyzerFastFitComponent);
     219           6 :     pHandler->AddComponent(new AliHLTEMCALRawAnalyzerNNComponent);
     220           6 :     pHandler->AddComponent(new AliHLTEMCALRawAnalyzerComponentTRU);
     221           6 :     pHandler->AddComponent(new AliHLTEMCALRawAnalyzerComponentSTU);
     222           6 :     pHandler->AddComponent(new AliHLTEMCALTriggerDataMakerComponent);
     223           6 :     pHandler->AddComponent(new AliHLTEMCALDigitMakerComponent);
     224           6 :     pHandler->AddComponent(new AliHLTEMCALClusterizerComponent);
     225           6 :     pHandler->AddComponent(new AliHLTEMCALClusterizerComponentNbyN);
     226             :     //pHandler->AddComponent(new AliHLTCaloClusterAnalyserComponent);                         
     227             :     //pHandler->AddComponent(new AliHLTEMCALESDEntriesMakerComponent);
     228           6 :     pHandler->AddComponent(new AliHLTEMCALTriggerMakerComponent);
     229           6 :     pHandler->AddComponent(new AliHLTEMCALTriggerQAComponent);
     230           3 :     return 0;
     231           3 : }
     232             : 
     233             : 
     234             : int AliHLTEMCALAgent::GetHandlerDescription(AliHLTComponentDataType dt,
     235             :                                             AliHLTUInt32_t spec,
     236             :                                             AliHLTOUTHandlerDesc& desc) const
     237             : {
     238             :     // see header file for class documentation
     239             : 
     240             :     // raw data blocks to be fed into offline reconstruction
     241           0 :     if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginEMCAL)) 
     242             :     {
     243           0 :         AliHLTEMCALMapper* pMapper=GetMapper(spec);
     244             :     
     245           0 :         if(pMapper && pMapper->GetDDLFromSpec(spec) >= 0)
     246             :         {
     247           0 :             desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
     248           0 :             return 1;
     249             :         } 
     250           0 :         else if (pMapper==NULL)
     251             :         {
     252           0 :             ALIHLTERRORGUARD(5, "failed to create EMCAL mapper");
     253           0 :             return 0;
     254             :         }
     255             :         else 
     256             :         {
     257           0 :             HLTWarning("Handler can not process data inconsistent with a single EMCAL DDL from specification % d", spec);
     258           0 :             return 0;
     259             :         }
     260             :     }
     261           0 :     return 0;
     262           0 : }
     263             : 
     264             : AliHLTOUTHandler* AliHLTEMCALAgent::GetOutputHandler(AliHLTComponentDataType dt,
     265             :                                                      AliHLTUInt32_t /*spec*/)
     266             : {
     267             :     // see header file for class documentation
     268             :     
     269             :     // raw data blocks to be fed into offline reconstruction
     270           0 :     if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginEMCAL)) 
     271             :     {
     272           0 :         if (!fRawDataHandler) 
     273             :         {
     274           0 :             fRawDataHandler = new AliHLTEMCALAgent::AliHLTEMCALRawDataHandler(this);
     275           0 :         }
     276           0 :         return fRawDataHandler;
     277             :     }
     278             :     
     279           0 :     return NULL;
     280           0 : }
     281             : 
     282             : int AliHLTEMCALAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
     283             : {
     284             :     // see header file for class documentation
     285           0 :     if (pInstance==NULL) return -EINVAL;
     286             :     
     287           0 :     if (pInstance==fRawDataHandler) {
     288           0 :         delete fRawDataHandler;
     289           0 :         fRawDataHandler=NULL;
     290           0 :     }
     291           0 :     return 0;
     292           0 : }
     293             : 
     294           0 : AliHLTEMCALAgent::AliHLTEMCALRawDataHandler::AliHLTEMCALRawDataHandler(AliHLTEMCALAgent* pAgent)
     295           0 :   : fpAgent(pAgent)
     296           0 : {
     297             :     // see header file for class documentation
     298           0 : }
     299             : 
     300             : AliHLTEMCALAgent::AliHLTEMCALRawDataHandler::~AliHLTEMCALRawDataHandler()
     301           0 : {
     302             :     // see header file for class documentation
     303           0 : }
     304             : 
     305             : int AliHLTEMCALAgent::AliHLTEMCALRawDataHandler::ProcessData(AliHLTOUT* pData)
     306             : {
     307             :     // see header file for class documentation
     308           0 :     if (!pData) return -EINVAL;
     309             :     
     310           0 :     AliHLTComponentDataType dt = kAliHLTVoidDataType;
     311           0 :     AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
     312             :     
     313           0 :     AliHLTEMCALMapper* pMapper=fpAgent?fpAgent->GetMapper(spec):NULL;
     314           0 :     if (!pMapper) {
     315           0 :       ALIHLTERRORGUARD(5, "%s", fpAgent?"can not retrieve EMCAL mapper from agent":"agent not available to retrieve EMCAL mapper");
     316           0 :       return -ENODEV;
     317             :     }
     318             :     
     319           0 :     int iResult = pData->GetDataBlockDescription(dt, spec);
     320           0 :     if (iResult>=0) 
     321             :     {
     322             :         int ddl = -1;
     323           0 :         if((ddl = pMapper->GetDDLFromSpec(spec)) >=0)
     324             :         {
     325             :             iResult = ddl;
     326           0 :         }
     327           0 :     } 
     328             :     else 
     329             :     {
     330           0 :         HLTError("Handler can not process data inconsistent with a single EMCAL DDL from specification % d", spec);
     331             :         iResult=-EBADMSG;
     332             :     }
     333             :     return iResult;
     334           0 : }
     335             : 
     336             : AliHLTEMCALMapper* AliHLTEMCALAgent::GetMapper(AliHLTUInt32_t spec) const
     337             : {
     338             :   // get the mapper instance for a specification
     339           0 :   std::map<AliHLTUInt32_t, AliHLTEMCALMapper*>::const_iterator element=fMappers.find(spec);
     340           0 :   if (element!=fMappers.end()) return element->second;
     341             : 
     342           0 :   AliHLTEMCALMapper* mapper=new AliHLTEMCALMapper(spec);
     343           0 :   if (!mapper) return NULL;
     344           0 :   mapper->InitDDLSpecificationMapping();
     345           0 :   const_cast<AliHLTEMCALAgent*>(this)->fMappers[spec]=mapper;
     346           0 :   return mapper;
     347           0 : }

Generated by: LCOV version 1.11