LCOV - code coverage report
Current view: top level - HLT/ITS - AliHLTITSAgent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 24 137 17.5 %
Date: 2016-06-14 17:26:59 Functions: 7 20 35.0 %

          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   AliHLTITSAgent.cxx
      20             : //  @author Matthias Richter
      21             : //  @date   25.08.2008
      22             : //  @brief  Agent of the libAliHLTITS library
      23             : //  @note
      24             : 
      25             : #include <cassert>
      26             : #include "AliHLTITSAgent.h"
      27             : #include "AliHLTOUT.h"
      28             : #include "AliHLTDAQ.h"
      29             : #include "AliDAQ.h"
      30             : 
      31             : // header files of library components
      32             : #include "AliHLTITSCompressRawDataSDDComponent.h"
      33             : #include "AliHLTITSSSDQARecPointsComponent.h"
      34             : #include "AliHLTITSQAComponent.h"
      35             : #include "AliHLTITSClusterFinderComponent.h"
      36             : #include "AliHLTITSClusterHistoComponent.h"
      37             : #include "AliHLTITSTrackerComponent.h"
      38             : #include "AliHLTITSSAPTrackerComponent.h"
      39             : #include "AliHLTITSVertexerSPDComponent.h"
      40             : #include "AliHLTITSDigitPublisherComponent.h"
      41             : 
      42             : // header file of the module preprocessor
      43             : // none at the moment
      44             : 
      45             : /** global instance for agent registration */
      46           6 : AliHLTITSAgent gAliHLTITSAgent;
      47             : 
      48             : /** ROOT macro for the implementation of ROOT specific class methods */
      49           6 : ClassImp(AliHLTITSAgent)
      50             : 
      51             : AliHLTITSAgent::AliHLTITSAgent()
      52             :   :
      53           3 :   AliHLTModuleAgent("ITS"),
      54           3 :   fRawDataHandler(NULL)
      55          15 : {
      56             :   // see header file for class documentation
      57             :   // or
      58             :   // refer to README to build package
      59             :   // or
      60             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      61           6 : }
      62             : 
      63           0 : AliHLTITSAgent::~AliHLTITSAgent()
      64           6 : {
      65             :   // see header file for class documentation
      66           9 : }
      67             : 
      68             : UInt_t AliHLTITSAgent::GetDetectorMask() const
      69             : {
      70           0 :   return AliDAQ::kITS;
      71             : }
      72             : 
      73             : int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
      74             :                                          AliRawReader* rawReader,
      75             :                                          AliRunLoader* runloader) const
      76             : {
      77             :   // see header file for class documentation
      78             :   int iResult=0;
      79           0 :   if (!handler) return -EINVAL;
      80             : 
      81             :   ///////////////////////////////////////////////////////////////////////////////////////////////////
      82             :   ///////////////////////////////////////////////////////////////////////////////////////////////////
      83             :   //
      84             :   // ITS tracking is currently only working on raw data
      85             :   // to run on digits, a digit publisher needs to be implemented
      86             : 
      87           0 :   TString trackerInput="";
      88           0 :   TString trackerSAPInput="";
      89           0 :   TString vertexerSPDInput="";
      90           0 :   if (rawReader || !runloader) {
      91             :     // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
      92             :     // Alireconstruction: indicated by runloader==NULL, run always on raw data
      93             : 
      94             :     ///////////////////////////////////////////////////////////////////////////////////////////////////
      95             :     //
      96             :     // define the ITS cluster finder configurations
      97             :     //
      98             : 
      99           0 :     TString spdCF;
     100           0 :     TString ssdCF;
     101           0 :     TString sddCF;
     102             :     
     103           0 :     iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSPD"), spdCF);
     104           0 :     handler->CreateConfiguration("ITS-SPD-CF","BlockFilter",spdCF.Data(),"");
     105             : 
     106           0 :     iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSDD"), sddCF);
     107           0 :     handler->CreateConfiguration("ITS-SDD-CF","BlockFilter",sddCF.Data(),"");
     108             : 
     109           0 :     iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSSD"), ssdCF);
     110           0 :     handler->CreateConfiguration("ITS-SSD-CF","BlockFilter",ssdCF.Data(),"");
     111             : 
     112             : 
     113             :     ///////////////////////////////////////////////////////////////////////////////////////////////////
     114             :     //
     115             :     // define the SPD vertexer Z input
     116             :     //
     117           0 :     vertexerSPDInput="ITS-SPD-CF";
     118             : 
     119             :     ///////////////////////////////////////////////////////////////////////////////////////////////////
     120             :     //
     121             :     // define the ITS tracker input
     122             :     //
     123           0 :     trackerInput="ITS-SPD-CF ITS-SDD-CF ITS-SSD-CF";
     124           0 :     trackerSAPInput="ITS-SPD-CF ITS-SDD-CF ITS-SSD-CF";
     125           0 :   }
     126           0 :   else if (runloader && !rawReader) {
     127             :     // indicates AliSimulation with no RawReader available -> run on digits
     128             : 
     129             :     ///////////////////////////////////////////////////////////////////////////////////////////////////
     130             :     //
     131             :     // define the Digit Publisher and ITS cluster finder configuration
     132             :     //
     133           0 :     handler->CreateConfiguration("DigitPublisher","AliLoaderPublisher",NULL,"-loader ITSLoader -datatype 'ALITREED' 'ITS '");
     134           0 :     handler->CreateConfiguration("DigitClusterFinder","ITSClusterFinderDigits","DigitPublisher","");
     135             :     
     136             :     ///////////////////////////////////////////////////////////////////////////////////////////////////
     137             :     //
     138             :     // define the SPD vertexer Z input.
     139             :     //
     140             :     // Can not run on Digit ClusterFinder. Wrong inputtype. And wrong input data.
     141             :     // If this is fixed in the VertexerSPD it needs to implement the data type
     142             :     // handling for the ITS digits and ignore the input from the SDD and SSD
     143             :     //vertexerSPDInput="DigitClusterFinder";
     144             :     
     145             :     ///////////////////////////////////////////////////////////////////////////////////////////////////
     146             :     //
     147             :     // define the ITS tracker input
     148             :     //
     149             :     // Currently there is a seg fault in the TTree access from the DigitClusterFinder
     150             :     // needs first to be investigated
     151           0 :     trackerInput="DigitClusterFinder";
     152           0 :     trackerSAPInput="DigitClusterFinder";
     153           0 :     vertexerSPDInput="DigitClusterFinder";
     154             :   }
     155             : 
     156             :   ///////////////////////////////////////////////////////////////////////////////////////////////////
     157             :   //
     158             :   // define the SPD vertexer Z configuration
     159             :   //
     160           0 :   if (!vertexerSPDInput.IsNull()) {
     161           0 :     handler->CreateConfiguration("ITS-SPD-vertexer","ITSVertexerSPD", vertexerSPDInput, "");
     162             :   }
     163             : 
     164             :   ///////////////////////////////////////////////////////////////////////////////////////////////////
     165             :   //
     166             :   // define the ITS tracker configuration
     167             :   //
     168           0 :   if (!trackerInput.IsNull()) {
     169           0 :     if (handler->FindConfiguration("TPC-globalmerger")) {
     170             :       // add the TPC tracking if available
     171           0 :       trackerInput+=" TPC-globalmerger";
     172             :     }
     173           0 :     if (handler->FindConfiguration("TPC-mcTrackMarker")) {
     174             :       // add the TPC tracking if available
     175           0 :       trackerInput+=" TPC-mcTrackMarker";
     176             :     }
     177           0 :     handler->CreateConfiguration("ITS-tracker","ITSTracker",trackerInput.Data(),"");
     178             :   }
     179             :   
     180           0 :   if( !trackerSAPInput.IsNull() ) trackerSAPInput+=" ";
     181           0 :   trackerSAPInput+="ITS-SPD-vertexer";
     182             : 
     183           0 :   handler->CreateConfiguration("ITS-SAPtracker","ITSSAPTracker",trackerSAPInput.Data(),"");
     184             : 
     185             :   return iResult;
     186           0 : }
     187             : 
     188             : const char* AliHLTITSAgent::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             :     // the chain is just defined and can be used as input for subsequent
     198             :     // components
     199             :     //return "ITS-tracker";
     200             :   }
     201             : 
     202           0 :   return "";
     203             : }
     204             : 
     205             : const char* AliHLTITSAgent::GetRequiredComponentLibraries() const
     206             : {
     207             :   // see header file for class documentation
     208           0 :   return "libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so";
     209             : }
     210             : 
     211             : int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
     212             : {
     213             :   // see header file for class documentation
     214           6 :   assert(pHandler);
     215           3 :   if (!pHandler) return -EINVAL;
     216           6 :   pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent);
     217           6 :   pHandler->AddComponent(new AliHLTITSSSDQARecPointsComponent);
     218           6 :   pHandler->AddComponent(new AliHLTITSQAComponent);
     219           6 :   pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSPD));
     220           6 :   pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSDD));
     221           6 :   pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSSD));
     222           6 :   pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderDigits));
     223           6 :   pHandler->AddComponent(new AliHLTITSClusterHistoComponent);
     224           6 :   pHandler->AddComponent(new AliHLTITSTrackerComponent);
     225           6 :   pHandler->AddComponent(new AliHLTITSSAPTrackerComponent);
     226           6 :   pHandler->AddComponent(new AliHLTITSVertexerSPDComponent);
     227           6 :   pHandler->AddComponent(new AliHLTITSDigitPublisherComponent);
     228             : 
     229           3 :   return 0;
     230           3 : }
     231             : 
     232             : AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor()
     233             : {
     234             :   // see header file for class documentation
     235           0 :   return NULL;
     236             : }
     237             : 
     238             : int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt,
     239             :                                              AliHLTUInt32_t spec,
     240             :                                              AliHLTOUTHandlerDesc& desc) const
     241             : {
     242             :   // see header file for class documentation
     243             : 
     244             :   // Handlers for ITS raw data. Even though there are 3 detectors
     245             :   // everything is handled in one module library and one HLTOUT handler.
     246             :   // This assumes that the data blocks are sent with data type
     247             :   // {DDL_RAW :ISDD} and the bit set in the specification corresponding.
     248             :   // to detector DDL id.
     249             :   // An HLTOUT handler is implemented to extract the equipment id from
     250             :   // the specification.
     251             :   // Note: Future versions of the framework will provide a default handler
     252             :   // class with that functionality.
     253           0 :   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
     254           0 :       desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
     255           0 :       HLTInfo("module %s handles data block type %s specification %d (0x%x)", 
     256             :               GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
     257           0 :       return 1;
     258             :   }
     259           0 :   return 0;
     260           0 : }
     261             : 
     262             : AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt,
     263             :                                                    AliHLTUInt32_t /*spec*/)
     264             : {
     265             :   // see header file for class documentation
     266           0 :   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
     267             :     // use the default handler
     268           0 :     if (!fRawDataHandler) {
     269           0 :       fRawDataHandler=new AliHLTOUTSDDRawDataHandler;
     270           0 :     }
     271           0 :     return fRawDataHandler;
     272             :   }
     273           0 :   return NULL;
     274           0 : }
     275             : 
     276             : int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
     277             : {
     278             :   // see header file for class documentation
     279           0 :   if (pInstance==NULL) return -EINVAL;
     280             : 
     281           0 :   if (pInstance==fRawDataHandler) {
     282           0 :     delete fRawDataHandler;
     283           0 :     fRawDataHandler=NULL;
     284           0 :     return 0;
     285             :   }
     286             : 
     287           0 :   delete pInstance;
     288           0 :   return 0;
     289           0 : }
     290             : 
     291             : int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData)
     292             : {
     293             :   // see header file for class documentation
     294           0 :   if (!pData) return -EINVAL;
     295             :   static int errorCount=0;
     296             :   const int maxErrorCount=10;
     297           0 :   AliHLTComponentDataType dt=kAliHLTVoidDataType;
     298           0 :   AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
     299           0 :   int iResult=pData->GetDataBlockDescription(dt, spec);
     300           0 :   if (iResult>=0) {
     301           0 :     if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
     302             :       int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD");
     303             :       int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD");
     304             :       int ddlNo=0;
     305           0 :       for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) {
     306           0 :         if (spec&(0x1<<ddlNo)) break;
     307             :       }
     308           0 :       if (ddlNo>=32 || ddlNo>=numberOfDDLs) {
     309           0 :         HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
     310             :         iResult=-ENODEV;
     311           0 :       } else if (spec^(0x1<<ddlNo)) {
     312             :         iResult=-EEXIST;
     313           0 :         HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
     314             :       } else {
     315           0 :         iResult=ddlOffset+ddlNo;
     316             :       }
     317           0 :     } else {
     318           0 :       if (errorCount++<10) {
     319           0 :         HLTError("wrong data type: expecting %s, got %s; %s",
     320             :                  AliHLTComponent::DataType2Text(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD).c_str(),
     321             :                  AliHLTComponent::DataType2Text(dt).c_str(),
     322             :                    errorCount==maxErrorCount?"suppressing further error messages":"");
     323             :       }
     324             :       iResult=-EFAULT;
     325             :     }
     326             :   }
     327             :   return iResult;
     328           0 : }
     329             : 
     330             : int AliHLTITSAgent::CreateCFConfigurations(AliHLTConfigurationHandler* pHandler, int detectorId, TString& output) const
     331             : {
     332             :   // see header file for class documentation
     333           0 :   if (!pHandler) return -EINVAL;
     334             : 
     335             :   ///////////////////////////////////////////////////////////////////////////////////////////////////
     336             :   //
     337             :   // define the ITS cluster finder components
     338             :   //
     339             :     
     340             :   //The spec starts from 0x1 in SPD, SDD and SSD. So 0x1 is ddl 0 for SPD, 0x10 is ddl 1, and so on
     341             :   //in SDD 0x1 is ddl 256, 0x10 is ddl 257, and so on. This means that the spec has to be set to 0x1 
     342             :   //before the loops over the clusterfinder
     343             : 
     344           0 :   TString idString=AliHLTDAQ::DetectorName(detectorId);
     345           0 :   if (idString.CompareTo("ITSSPD") &&
     346           0 :       idString.CompareTo("ITSSDD") &&
     347           0 :       idString.CompareTo("ITSSSD")) {
     348           0 :     HLTError("invalid detector id %d does not describe any ITS detector", detectorId);
     349           0 :     return -ENOENT;
     350             :   }
     351             : 
     352           0 :   int minddl=AliHLTDAQ::DdlIDOffset(detectorId);
     353           0 :   int maxddl=minddl+AliHLTDAQ::NumberOfDdls(detectorId)-1;
     354             :   int spec=0x1;
     355             :   int ddlno=0;
     356             : 
     357             :   // this is a simple switch for experimenting with different configurations
     358             :   // it's supposed to be false for normal compilation
     359             :   bool bOneCFperDDL=false;
     360           0 :   TString origin=idString; origin.ReplaceAll("ITS", "I");
     361           0 :   TString cfBase=idString; cfBase+="_CF";
     362           0 :   TString componentId=idString; componentId.ReplaceAll("ITS", "ITSClusterFinder");
     363           0 :   TString cfinput, cf;
     364           0 :   for(ddlno=minddl;ddlno<=maxddl;ddlno++){  
     365           0 :     TString arg, publisher;
     366             :  
     367             :     // the HLT origin defines are 4 chars: ISPD, ISSD, ISDD respectively
     368           0 :     arg.Form("-minid %d -datatype 'DDL_RAW ' '%s' -dataspec 0x%08x",ddlno, origin.Data(), spec);
     369           0 :     if (CheckFilter(kHLTLogDebug)) arg+=" -verbose";
     370           0 :     publisher.Form("ITS-DP_%d", ddlno);
     371           0 :     pHandler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
     372             : 
     373           0 :     if (cfinput.Length()>0) cfinput+=" ";
     374           0 :     cfinput+=publisher;
     375             : 
     376           0 :     if (bOneCFperDDL) {
     377           0 :     cf.Form("%s_%d",cfBase.Data(), ddlno);
     378           0 :     pHandler->CreateConfiguration(cf.Data(), componentId.Data(), publisher.Data(), "");
     379             : 
     380           0 :     if (output.Length()>0) output+=" ";
     381           0 :     output+=cf;
     382             :     }
     383             : 
     384           0 :     spec=spec<<1;
     385           0 :   }
     386             : 
     387           0 :   if (!bOneCFperDDL) {
     388           0 :     cf.Form("%s",cfBase.Data());
     389           0 :     pHandler->CreateConfiguration(cf.Data(), componentId.Data(), cfinput.Data(), "");
     390             : 
     391           0 :     if (output.Length()>0) output+=" ";
     392           0 :     output+=cf;
     393             :   }
     394             :   
     395             :   return 0;
     396           0 : }

Generated by: LCOV version 1.11