LCOV - code coverage report
Current view: top level - HLT/ITS - AliHLTITSClusterFinderComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 56 371 15.1 %
Date: 2016-06-14 17:26:59 Functions: 7 19 36.8 %

          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: Gaute Ovrebekk <st05886@alf.uib.no>                   *
       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   AliHLTITSClusterFinderComponent.cxx
      19             : /// @author Gaute Ovrebekk <st05886@alf.uib.no>
      20             : /// @date   
      21             : /// @brief  Component to run offline clusterfinders
      22             : ///
      23             : 
      24             : #include "AliHLTITSClusterFinderComponent.h" 
      25             : 
      26             : #include "AliCDBEntry.h"
      27             : #include "AliCDBManager.h"
      28             : #include "AliITSgeomTGeo.h"
      29             : #include "AliITSRecPoint.h"
      30             : #include "AliHLTITSSpacePointData.h"
      31             : #include "AliHLTITSClusterDataFormat.h"
      32             : #include <AliHLTDAQ.h>
      33             : #include "AliGeomManager.h"
      34             : #include "AliITSRecoParam.h"
      35             : #include "AliITSReconstructor.h"
      36             : #include "AliHLTITSClusterFinderSPD.h"
      37             : #include "AliHLTITSClusterFinderSSD.h"
      38             : #include "TMap.h"
      39             : #include "AliITSRecPointContainer.h"
      40             : #include "AliRunLoader.h"
      41             : #include "AliLoader.h"
      42             : 
      43             : #include <cstdlib>
      44             : #include <cerrno>
      45             : #include "TFile.h"
      46             : #include "TString.h"
      47             : #include "TObjString.h"
      48             : #include <sys/time.h>
      49             : 
      50             : using namespace std;
      51             : 
      52             : /** ROOT macro for the implementation of ROOT specific class methods */
      53           6 : ClassImp(AliHLTITSClusterFinderComponent);
      54             : 
      55          12 : AliHLTITSClusterFinderComponent::AliHLTITSClusterFinderComponent(int mode)
      56             :   :
      57          12 :   fModeSwitch(mode),
      58          12 :   fInputDataType(kAliHLTVoidDataType),
      59          12 :   fOutputDataType(kAliHLTVoidDataType),
      60          12 :   fUseOfflineFinder(0),
      61          12 :   fNModules(0),
      62          12 :   fId(0),
      63          12 :   fNddl(0),
      64          12 :   fRawReader(NULL),
      65          12 :   fDettype(NULL),
      66          12 :   fgeom(NULL),
      67          12 :   fgeomInit(NULL),
      68          12 :   fSPD(NULL),
      69          12 :   fSSD(NULL),
      70          12 :   tD(NULL),
      71          12 :   tR(NULL),
      72          12 :   fSPDNModules(0),
      73          12 :   fSDDNModules(0),
      74          12 :   fSSDNModules(0),
      75          12 :   fFirstModule(0),
      76          12 :   fLastModule(0),
      77          12 :   fnClusters(0),
      78          12 :   fclusters(),
      79          24 :   fBenchmark(GetComponentID()),
      80          12 :   fOutputSizeOffset(0),
      81          12 :   fInputMultiplierDigits(20),
      82          12 :   fpLoader(NULL)
      83          60 : { 
      84             :   // see header file for class documentation
      85             :   // or
      86             :   // refer to README to build package
      87             :   // or
      88             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      89             : 
      90          12 :   switch(fModeSwitch){
      91             :   case kClusterFinderSPD:
      92           3 :     fInputDataType  = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSPD;
      93           3 :     fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD;
      94           3 :     break;
      95             :   case kClusterFinderSDD:        
      96           3 :     fInputDataType  = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD;
      97           3 :     fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD;
      98           3 :     break;
      99             :   case kClusterFinderSSD:
     100           3 :     fInputDataType  = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSSD;
     101           3 :     fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD;
     102           3 :     break;
     103             :   case kClusterFinderDigits:
     104           3 :     fInputDataType  = kAliHLTDataTypeAliTreeD|kAliHLTDataOriginITS;
     105           3 :     fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITS;
     106           3 :     break;
     107             :   default:
     108           0 :     HLTFatal("unknown cluster finder");
     109             :   }
     110          24 : }
     111             : 
     112             : AliHLTITSClusterFinderComponent::~AliHLTITSClusterFinderComponent() 
     113          72 : {
     114             :   // see header file for class documentation
     115          12 :   delete fRawReader;
     116          12 :   delete fDettype;
     117          12 :   delete fgeomInit;  
     118          12 :   delete fSPD;
     119          12 :   delete fSSD;
     120          36 : }
     121             : 
     122             : // Public functions to implement AliHLTComponent's interface.
     123             : // These functions are required for the registration process
     124             : 
     125             : const char* AliHLTITSClusterFinderComponent::GetComponentID()
     126             : {
     127             :   // see header file for class documentation
     128         252 :   switch(fModeSwitch){
     129             :   case kClusterFinderSPD:
     130          36 :     return "ITSClusterFinderSPD";
     131             :     break;
     132             :   case kClusterFinderSDD:        
     133          33 :     return "ITSClusterFinderSDD";
     134             :     break;
     135             :   case kClusterFinderSSD:
     136          30 :     return "ITSClusterFinderSSD";
     137             :     break;
     138             :   case kClusterFinderDigits:
     139          27 :     return "ITSClusterFinderDigits";
     140             :     break;
     141             :   }
     142           0 :   return "";
     143         126 : }
     144             : 
     145             : void AliHLTITSClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) 
     146             : {
     147             :   // see header file for class documentation
     148           0 :   list.clear(); 
     149           0 :   list.push_back( fInputDataType );
     150           0 : }
     151             : 
     152             : AliHLTComponentDataType AliHLTITSClusterFinderComponent::GetOutputDataType() 
     153             : {
     154             :   // see header file for class documentation
     155           0 :   return fOutputDataType;
     156             : }
     157             : 
     158             : void AliHLTITSClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
     159             :   // see header file for class documentation
     160           0 :   constBase = fOutputSizeOffset;
     161           0 :   switch(fModeSwitch){
     162             :   case kClusterFinderDigits:
     163           0 :     inputMultiplier = fInputMultiplierDigits;
     164           0 :     break;
     165             :   case kClusterFinderSPD:
     166             :   case kClusterFinderSDD:        
     167             :   case kClusterFinderSSD:
     168             :   default:
     169           0 :     inputMultiplier = 20;
     170           0 :   }
     171           0 : }
     172             : 
     173             : AliHLTComponent* AliHLTITSClusterFinderComponent::Spawn() {
     174             :   // see header file for class documentation
     175           0 :   return new AliHLTITSClusterFinderComponent(fModeSwitch);
     176           0 : }
     177             :         
     178             : Int_t AliHLTITSClusterFinderComponent::DoInit( int argc, const char** argv ) {
     179             :   // see header file for class documentation
     180           0 :   fBenchmark.Reset();
     181           0 :   fBenchmark.SetTimer(0,"total");
     182           0 :   fBenchmark.SetTimer(1,"reco");
     183             : 
     184           0 :   if(fModeSwitch==kClusterFinderSPD) {
     185             :     HLTDebug("using ClusterFinder for SPD");
     186             :     //fNModules=AliITSgeomTGeo::GetNDetectors(1)*AliITSgeomTGeo::GetNLadders(1) + AliITSgeomTGeo::GetNDetectors(2)*AliITSgeomTGeo::GetNLadders(2);
     187           0 :     fId=AliHLTDAQ::DdlIDOffset("ITSSPD");
     188           0 :     fNddl=AliHLTDAQ::NumberOfDdls("ITSSPD");
     189           0 :   }
     190           0 :   else if(fModeSwitch==kClusterFinderSDD) {
     191             :     HLTDebug("using ClusterFinder for SDD");
     192             :     //fNModules=AliITSgeomTGeo::GetNDetectors(3)*AliITSgeomTGeo::GetNLadders(3) + AliITSgeomTGeo::GetNDetectors(4)*AliITSgeomTGeo::GetNLadders(4);
     193           0 :     fId=AliHLTDAQ::DdlIDOffset("ITSSDD");
     194           0 :     fNddl=AliHLTDAQ::NumberOfDdls("ITSSDD");
     195           0 :   }
     196           0 :   else if(fModeSwitch==kClusterFinderSSD) {
     197             :     HLTDebug("using ClusterFinder for SSD");
     198             :     //fNModules=AliITSgeomTGeo::GetNDetectors(5)*AliITSgeomTGeo::GetNLadders(5) + AliITSgeomTGeo::GetNDetectors(6)*AliITSgeomTGeo::GetNLadders(6);
     199           0 :     fId=AliHLTDAQ::DdlIDOffset("ITSSSD");
     200           0 :     fNddl=AliHLTDAQ::NumberOfDdls("ITSSSD");
     201           0 :   }
     202           0 :   else if(fModeSwitch==kClusterFinderDigits) {
     203           0 :     tR = new TTree();
     204           0 :   }
     205             :   else{
     206           0 :      HLTFatal("No mode set for clusterfindercomponent");
     207             :   }
     208             : 
     209             :   //Removed the warning for loading default RecoParam in HLT
     210           0 :   AliITSRecoParam *par = AliITSRecoParam::GetLowFluxParam();
     211           0 :   AliITSReconstructor *rec = new AliITSReconstructor();
     212           0 :   rec->SetRecoParam(par);
     213             :   
     214           0 :   AliCDBManager* man = AliCDBManager::Instance();
     215           0 :   if (!man->IsDefaultStorageSet()){
     216           0 :     HLTError("Default CDB storage has not been set !");
     217           0 :     return -ENOENT;
     218             :   }
     219             : 
     220           0 :   if(AliGeomManager::GetGeometry()==NULL){
     221           0 :     AliGeomManager::LoadGeometry();
     222           0 :   }
     223             : 
     224           0 :   fgeomInit = new AliITSInitGeometry();
     225             :   //fgeomInit = new AliITSInitGeometry(kvPPRasymmFMD,2);
     226             :   //fgeomInit->InitAliITSgeom(fgeom);
     227           0 :   fgeom = fgeomInit->CreateAliITSgeom();
     228             :  
     229           0 :   fNModules = fgeom->GetIndexMax();
     230           0 :   Int_t modperlay[6];
     231           0 :   for(Int_t i=0;i<6;i++)modperlay[i]=AliITSgeomTGeo::GetNDetectors(1+i)*AliITSgeomTGeo::GetNLadders(1+i);
     232           0 :   fSPDNModules=modperlay[0]+modperlay[1];
     233           0 :   fSDDNModules=modperlay[2]+modperlay[3];
     234           0 :   fSSDNModules=modperlay[4]+modperlay[5];
     235             :   
     236           0 :   if(fModeSwitch==kClusterFinderSPD) {
     237           0 :     fFirstModule=0;
     238           0 :     fLastModule=fSPDNModules;
     239           0 :   }
     240           0 :   else if(fModeSwitch==kClusterFinderSDD) {
     241           0 :      fFirstModule=fSPDNModules;
     242           0 :      fLastModule=fFirstModule + fSDDNModules;
     243           0 :   }
     244           0 :   else if(fModeSwitch==kClusterFinderSSD) {
     245           0 :     fFirstModule=fSPDNModules + fSDDNModules;
     246           0 :     fLastModule=fFirstModule + fSSDNModules;
     247           0 :   }
     248             :  
     249             :   //set dettype
     250           0 :   fDettype = new AliITSDetTypeRec();
     251           0 :   fDettype->SetITSgeom(fgeom); 
     252           0 :   fDettype->SetDefaults();
     253           0 :   fDettype->SetDefaultClusterFindersV2(kTRUE,kTRUE); 
     254             : 
     255           0 :   if ( fRawReader )
     256           0 :     return -EINPROGRESS;
     257             : 
     258           0 :   fRawReader = new AliRawReaderMemory();
     259           0 :   fSPD = new AliHLTITSClusterFinderSPD( fDettype );
     260           0 :   fSSD = new AliHLTITSClusterFinderSSD( fDettype, fRawReader );
     261             : 
     262           0 :   TString arguments = "";
     263           0 :   for ( int i = 0; i < argc; i++ ) {
     264           0 :     if ( !arguments.IsNull() ) arguments += " ";
     265           0 :     arguments += argv[i];
     266             :   }
     267             : 
     268           0 :   tD = NULL;
     269             :   //tR = NULL;
     270             : 
     271           0 :   return Configure( arguments.Data() );
     272           0 : }
     273             : 
     274             : Int_t AliHLTITSClusterFinderComponent::DoDeinit() {
     275             :   // see header file for class documentation
     276             : 
     277           0 :   if ( fRawReader )
     278           0 :     delete fRawReader;
     279           0 :   fRawReader = NULL;
     280             : 
     281           0 :   if ( fDettype )
     282           0 :     delete fDettype;
     283           0 :   fDettype = NULL;
     284             : 
     285           0 :   if ( fgeomInit )
     286           0 :     delete fgeomInit;
     287           0 :   fgeomInit = NULL;
     288             :   
     289           0 :   delete fSPD;
     290           0 :   fSPD = 0;
     291             : 
     292           0 :   delete fSSD;
     293           0 :   fSSD = 0;
     294             : 
     295           0 :   fUseOfflineFinder = 0;
     296             : 
     297           0 :   if (fpLoader) {
     298           0 :     fpLoader->UnloadDigits();
     299           0 :   }
     300           0 :   fpLoader=NULL;
     301             : 
     302           0 :   return 0;
     303             : }
     304             : 
     305             : int AliHLTITSClusterFinderComponent::DoEvent
     306             : (
     307             :  const AliHLTComponentEventData& evtData,
     308             :  const AliHLTComponentBlockData* /*blocks*/,
     309             :  AliHLTComponentTriggerData& /*trigData*/,
     310             :  AliHLTUInt8_t* outputPtr,
     311             :  AliHLTUInt32_t& size,
     312             :   vector<AliHLTComponentBlockData>& outputBlocks )
     313             : {
     314             :  // see header file for class documentation
     315             :   
     316           0 :   AliHLTUInt32_t maxBufferSize = size;
     317           0 :   size = 0; // output size
     318             : 
     319           0 :   if (!IsDataEvent()) return 0;
     320             :   
     321           0 :   if ( evtData.fBlockCnt<=0 )
     322             :     {
     323             :       HLTDebug("no blocks in event" );
     324           0 :       return 0;
     325             :     }
     326             : 
     327             :   AliHLTUInt32_t totalInputSize=0;
     328           0 :   fBenchmark.StartNewEvent();
     329           0 :   fBenchmark.Start(0);
     330           0 :   for( const AliHLTComponentBlockData *i= GetFirstInputBlock(fInputDataType); i!=NULL; i=GetNextInputBlock() ){
     331           0 :     totalInputSize+=i->fSize;
     332           0 :     fBenchmark.AddInput(i->fSize);
     333             :   }
     334             : 
     335             :   Int_t ret = 0;
     336             : 
     337           0 :   if(fModeSwitch==kClusterFinderDigits) {
     338             : 
     339           0 :     for ( const TObject *iter = GetFirstInputObject(fInputDataType); iter != NULL; iter = GetNextInputObject() ) {  
     340           0 :       tD = dynamic_cast<TTree*>(const_cast<TObject*>( iter ) );
     341           0 :       if(!tD){
     342           0 :         HLTFatal("No Digit Tree found");
     343           0 :         return -1;
     344             :       }
     345             :       // 2010-04-17 very crude workaround: TTree objects are difficult to send
     346             :       // The actual case: Running ITS and TPC reconstruction fails at the second event
     347             :       // to read the ITS digits from the TreeD
     348             :       //
     349             :       // Reason: reading fails in TBranch::GetBasket, there a new basket is opened from
     350             :       // a TFile object. The function TBranch::GetFile returns the file object from
     351             :       // an internal fDirectory (TDirectory) object. This file is at the second event
     352             :       // set to the TPC.Digits.root. The internal mismatch creates a seg fault
     353             :       //
     354             :       // Investigation: TBranch::Streamer uses a crude assignment after creating the
     355             :       // TBranch object
     356             :       //    fDirectory = gDirectory;
     357             :       // gDirectory is obviously not set correctly. Setting the directory to a TFile
     358             :       // object for the ITS digits helps to fix the internal mess. Tried also to set
     359             :       // the Directory for the TreeD to NULL (This has only effect if ones sets it 
     360             :       // to something not NULL first, and then to NULL). But then no content, i.e.
     361             :       // ITS clusters could be retrieved.
     362             :       //
     363             :       // Conclusion: TTree objects are hardly to be sent via TMessage, there are direct
     364             :       // links to the file required anyhow.
     365             :       //
     366             :       // 2011-01-28 hotfix reloaded: accessing the files like that fails if there are
     367             :       // multiple digit files because of a large number of events. New ugly fix is to
     368             :       // use the global runloader instance to get hold on the digits tree.
     369           0 :       fnClusters = 0;
     370           0 :       AliRunLoader* pRunLoader=AliRunLoader::Instance();
     371           0 :       if (!pRunLoader) {
     372           0 :         HLTError("failed to get global runloader instance");
     373           0 :         return -ENOSYS;
     374             :       }
     375             :       // get the specific loader for the module
     376           0 :       if (!fpLoader) {
     377             :         const char* loaderType="ITSLoader";
     378           0 :         fpLoader=pRunLoader->GetLoader(loaderType);
     379           0 :         if (!fpLoader) {
     380           0 :           HLTError("can not get loader \"%s\" from runloader", loaderType);
     381           0 :           return -ENOSYS;
     382             :         }
     383             :         // prepare the loader
     384           0 :         fpLoader->LoadDigits("read");
     385           0 :       }
     386           0 :       pRunLoader->GetEvent(GetEventCount());
     387             : 
     388           0 :       tD=fpLoader->TreeD();
     389           0 :       tR->Reset();
     390           0 :       tR->SetDirectory(0);
     391           0 :       fDettype->SetTreeAddressD(tD);
     392           0 :       fDettype->MakeBranch(tR,"R");
     393           0 :       fDettype->SetTreeAddressR(tR);
     394             :       Option_t *opt="All";
     395           0 :       fBenchmark.Start(1);
     396           0 :       fDettype->DigitsToRecPoints(tD,tR,0,opt,1);
     397           0 :       fBenchmark.Stop(1);
     398           0 :       TClonesArray * fRecPoints = NULL;
     399           0 :       tR->SetBranchAddress("ITSRecPoints",&fRecPoints);
     400           0 :       for(Int_t treeEntry=0;treeEntry<tR->GetEntries();treeEntry++){
     401           0 :         tR->GetEntry(treeEntry);
     402           0 :         fnClusters += fRecPoints->GetEntries();
     403             :       }
     404             : 
     405           0 :       UInt_t bufferSize = fnClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData);
     406           0 :       if( size + bufferSize > maxBufferSize ){
     407             :         //HLTWarning( "Output buffer size exceed (buffer size %d, required size %d)", maxBufferSize, size+bufferSize);
     408           0 :         if (totalInputSize>0) {
     409           0 :           fInputMultiplierDigits=(float)(size+bufferSize)/totalInputSize;
     410           0 :           fInputMultiplierDigits+=1.;
     411           0 :         } else {
     412           0 :           fOutputSizeOffset=totalInputSize;
     413           0 :           fInputMultiplierDigits=1.;
     414             :         }
     415             :         ret = -ENOSPC;      
     416           0 :         break;          
     417             :       }
     418           0 :       if( fnClusters>0 ){
     419           0 :         fBenchmark.Start(1);
     420           0 :         RecPointToSpacePoint(outputPtr,size);
     421           0 :         fBenchmark.Stop(1);
     422           0 :         AliHLTComponentBlockData bd;
     423           0 :         FillBlockData( bd );
     424           0 :         bd.fOffset = size;
     425           0 :         bd.fSize = bufferSize;
     426           0 :         bd.fSpecification = 0x00000000;
     427           0 :         bd.fDataType = GetOutputDataType();
     428           0 :         outputBlocks.push_back( bd );
     429           0 :         size += bufferSize;
     430           0 :         fBenchmark.AddOutput(bd.fSize);
     431           0 :       }
     432           0 :     }
     433             :   }
     434             :   else{
     435             : 
     436           0 :     AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
     437             : 
     438             :     // -- Loop over blocks
     439           0 :     for( const AliHLTComponentBlockData* iter = GetFirstInputBlock(fInputDataType); iter != NULL; iter = GetNextInputBlock() ) {
     440             : 
     441           0 :       if(fUseOfflineFinder){
     442           0 :         if(fModeSwitch==kClusterFinderSPD){rpc->ResetSPD();}
     443           0 :         if(fModeSwitch==kClusterFinderSSD){rpc->ResetSSD();}
     444             :       }
     445           0 :       if(fModeSwitch==kClusterFinderSDD){rpc->ResetSDD();}
     446             :       
     447             :       // -- Debug output of datatype --
     448             :       HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
     449             :                evtData.fEventID, evtData.fEventID, 
     450             :                DataType2Text(iter->fDataType).c_str(), 
     451             :                DataType2Text(fInputDataType).c_str());
     452             :       
     453             :       // -- Check for the correct data type
     454           0 :       if ( iter->fDataType != (fInputDataType) )  
     455             :         continue;
     456             :       
     457             :       // -- Get equipment ID out of specification
     458           0 :       AliHLTUInt32_t spec = iter->fSpecification;
     459             :       
     460           0 :       Int_t id = fId;
     461           0 :       for ( Int_t ii = 0; ii < fNddl ; ii++ ) {   //number of ddl's
     462           0 :         if ( spec & 0x00000001 ) {
     463           0 :           id += ii;
     464           0 :           break;
     465             :         }
     466           0 :         spec = spec >> 1 ;
     467             :       }
     468             :       
     469             :       // -- Set equipment ID to the raw reader
     470             :       
     471           0 :       if(!fRawReader){
     472           0 :         HLTWarning("The fRawReader pointer is NULL");
     473           0 :         continue;
     474             :       }
     475             : 
     476           0 :       if(!fRawReader->AddBuffer((UChar_t*) iter->fPtr, iter->fSize, id)){
     477           0 :         HLTWarning("Could not add buffer");
     478             :       }
     479             : 
     480           0 :       fBenchmark.Start(1);
     481             : 
     482           0 :       fnClusters = 0;
     483             : 
     484           0 :       if(fModeSwitch==kClusterFinderSPD && !fUseOfflineFinder){ fSPD->RawdataToClusters( fRawReader, fclusters ); }
     485           0 :       else if(fModeSwitch==kClusterFinderSSD && !fUseOfflineFinder){ fSSD->RawdataToClusters( fclusters ); }
     486             :       else{
     487           0 :         if(fModeSwitch==kClusterFinderSPD && fUseOfflineFinder) {fDettype->DigitsToRecPoints(fRawReader,"SPD");}
     488           0 :         if(fModeSwitch==kClusterFinderSSD && fUseOfflineFinder) {fDettype->DigitsToRecPoints(fRawReader,"SSD");}
     489           0 :         if(fModeSwitch==kClusterFinderSDD) {fDettype->DigitsToRecPoints(fRawReader,"SDD");}
     490             :         TClonesArray* clusters = NULL;
     491           0 :         for(int i=fFirstModule;i<fLastModule;i++){
     492           0 :           clusters = rpc->UncheckedGetClusters(i);
     493           0 :           if(clusters != NULL){
     494           0 :             fnClusters += clusters->GetEntriesFast();
     495           0 :           }
     496             :         }     
     497             :       }
     498             :       
     499             :       /* Do not work
     500             :          if(fModeSwitch==kClusterfinderSPD){
     501             :          fnClusters = rpc->GetNClustersInLayerFast(1) + rpc->GetNClustersInLayerFast(2);
     502             :          }
     503             :          if(fModeSwitch==kClusterfinderSDD){
     504             :          fnClusters = rpc->GetNClustersInLayerFast(3) + rpc->GetNClustersInLayerFast(4);
     505             :          }
     506             :          if(fModeSwitch==kClusterfinderSSD){
     507             :          fnClusters = rpc->GetNClustersInLayerFast(5) + rpc->GetNClustersInLayerFast(6);
     508             :          }
     509             :       */
     510             : 
     511           0 :       fBenchmark.Stop(1);
     512             :       
     513           0 :       fRawReader->ClearBuffers();    
     514             :       
     515           0 :       UInt_t nClusters=fclusters.size();
     516           0 :       if(nClusters>0){fnClusters = nClusters;}
     517             : 
     518           0 :       UInt_t bufferSize = fnClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData);
     519           0 :       if( size + bufferSize > maxBufferSize ){
     520           0 :         HLTWarning( "Output buffer size exceed (buffer size %d, current size %d)", maxBufferSize, size+bufferSize);
     521             :         ret = -ENOSPC;      
     522           0 :         break;          
     523             :       }
     524           0 :       if( fnClusters>0 ){
     525             : 
     526           0 :         RecPointToSpacePoint(outputPtr,size);
     527             : 
     528           0 :         AliHLTComponentBlockData bd;
     529           0 :         FillBlockData( bd );
     530           0 :         bd.fOffset = size;
     531           0 :         bd.fSize = bufferSize;
     532           0 :         bd.fSpecification = iter->fSpecification;
     533           0 :         bd.fDataType = GetOutputDataType();
     534           0 :         outputBlocks.push_back( bd );
     535           0 :         size += bufferSize;
     536           0 :         fBenchmark.AddOutput(bd.fSize);
     537           0 :         if(nClusters>0){fclusters.clear();}  
     538           0 :       }
     539             :       
     540           0 :     } // input blocks
     541             :   }
     542             : 
     543           0 :   fBenchmark.Stop(0);
     544           0 :   HLTInfo(fBenchmark.GetStatistics());
     545           0 :   return ret;
     546           0 : }
     547             : 
     548             : int AliHLTITSClusterFinderComponent::Configure(const char* arguments)
     549             : {
     550             :   
     551             :   int iResult=0;
     552             :   
     553           0 :   if (!arguments) return iResult;
     554             :   
     555           0 :   TString allArgs=arguments;
     556           0 :   TString argument;
     557             :   
     558           0 :   TObjArray* pTokens=allArgs.Tokenize(" ");
     559             :   
     560           0 :   if (pTokens) {
     561           0 :     for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
     562           0 :       argument=((TObjString*)pTokens->At(i))->GetString();
     563           0 :       if (argument.IsNull()) continue;      
     564           0 :       if (argument.CompareTo("-use-offline-finder")==0) {
     565           0 :         fUseOfflineFinder = 1;
     566           0 :         HLTInfo("Off-line ClusterFinder will be used");
     567             :         continue;
     568             :       }
     569             :       /*
     570             :       else if (argument.CompareTo("")==0) {
     571             :         HLTInfo("");
     572             :         continue;
     573             :       }
     574             :       */
     575             :       else {
     576           0 :         HLTError("unknown argument %s", argument.Data());
     577             :         iResult=-EINVAL;
     578           0 :         break;
     579             :       }
     580             :     }
     581           0 :     delete pTokens;
     582             :   }
     583             :   
     584             :   return iResult;
     585           0 : }
     586             : 
     587             : int AliHLTITSClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* chainId)
     588             : {
     589             :   // see header file for class documentation
     590             :   int iResult=0;
     591             :   
     592             :   const char* path="";
     593             : 
     594           0 :   switch(fModeSwitch){
     595             :   case kClusterFinderSPD:
     596             :     path = "HLT/ConfigITS/ITSClusterFinderSPD";
     597           0 :     break;
     598             :   case kClusterFinderSDD:        
     599             :     path = "HLT/ConfigITS/ITSClusterFinderSDD";
     600           0 :     break;
     601             :   case kClusterFinderSSD:
     602             :     path = "HLT/ConfigITS/ITSClusterFinderSSD";
     603           0 :     break;
     604             :   case kClusterFinderDigits:
     605             :     path = "";
     606           0 :     break;
     607             :   default:
     608           0 :     HLTFatal("unknown cluster finder");
     609             :   }
     610             : 
     611             :   const char* defaultNotify="";
     612           0 :   if (cdbEntry) {
     613             :     path=cdbEntry;
     614             :     defaultNotify=" (default)";
     615           0 :   }
     616           0 :   if (path) {
     617           0 :     HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
     618           0 :     AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);
     619           0 :     if (pEntry) {
     620           0 :       TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
     621           0 :       if (pString) {
     622           0 :         HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
     623           0 :         iResult=Configure(pString->GetString().Data());
     624           0 :       } else {
     625           0 :         HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
     626             :       }
     627           0 :     } else {
     628           0 :       HLTError("can not fetch object \"%s\" from CDB", path);
     629             :     }
     630           0 :   }
     631             :   
     632           0 :   return iResult;
     633           0 : }
     634             : void AliHLTITSClusterFinderComponent::GetOCDBObjectDescription( TMap* const targetMap)
     635             : {
     636             :   // Get a list of OCDB object description.
     637           0 :   if (!targetMap) return;
     638             :   //SPD
     639           0 :   targetMap->Add(new TObjString("ITS/Calib/SPDNoisy"),new TObjString("Calibration object for SPD" ));
     640           0 :   targetMap->Add(new TObjString("ITS/Calib/SPDDead"),new TObjString("Calibration object for SPD" ));
     641           0 :   targetMap->Add(new TObjString("TRIGGER/SPD/PITConditions"),new TObjString("Calibration object for SPD" ));
     642             :   //SDD
     643           0 :   targetMap->Add(new TObjString("ITS/Calib/CalibSDD"),new TObjString("Calibration object for SDD" ));
     644           0 :   targetMap->Add(new TObjString("ITS/Calib/RespSDD"),new TObjString("Calibration object for SDD" ));
     645           0 :   targetMap->Add(new TObjString("ITS/Calib/DriftSpeedSDD"),new TObjString("Calibration object for SDD" ));
     646           0 :   targetMap->Add(new TObjString("ITS/Calib/DDLMapSDD"),new TObjString("Calibration object for SDD" ));
     647           0 :   targetMap->Add(new TObjString("ITS/Calib/MapsTimeSDD"),new TObjString("Calibration object for SDD" ));
     648             :   //SSD
     649           0 :   targetMap->Add(new TObjString("ITS/Calib/NoiseSSD"),new TObjString("Calibration object for SSD" ));
     650           0 :   targetMap->Add(new TObjString("ITS/Calib/GainSSD"),new TObjString("Calibration object for SSD" ));
     651           0 :   targetMap->Add(new TObjString("ITS/Calib/BadChannelsSSD"),new TObjString("Calibration object for SSD" ));
     652             :   //General reconstruction
     653           0 :   targetMap->Add(new TObjString("GRP/CTP/Scalers"),new TObjString("General reconstruction object" ));
     654           0 : }
     655             : 
     656             : 
     657             : void AliHLTITSClusterFinderComponent::RecPointToSpacePoint(AliHLTUInt8_t* outputPtr,AliHLTUInt32_t& size){
     658           0 :   AliHLTITSClusterData *outputClusters = reinterpret_cast<AliHLTITSClusterData*>(outputPtr + size);
     659           0 :   outputClusters->fSpacePointCnt=fnClusters;    
     660           0 :   int clustIdx=0;
     661           0 :   if(fModeSwitch==kClusterFinderDigits) {
     662           0 :     TClonesArray * fRecPoints = NULL;
     663           0 :     tR->SetBranchAddress("ITSRecPoints",&fRecPoints);
     664           0 :     for(Int_t treeEntry=0;treeEntry<tR->GetEntries();treeEntry++){
     665           0 :       tR->GetEntry(treeEntry);
     666           0 :       fnClusters += fRecPoints->GetEntries();
     667           0 :       for(Int_t tCloneEntry=0;tCloneEntry<fRecPoints->GetEntries();tCloneEntry++){
     668           0 :         AliITSRecPoint *recpoint=(AliITSRecPoint*)fRecPoints->At(tCloneEntry);
     669           0 :         RecpointToOutput(outputClusters,recpoint,clustIdx);
     670             :       }
     671             :     } 
     672           0 :   }
     673           0 :   else if(fclusters.size()>0){
     674           0 :     for(UInt_t i=0;i<fclusters.size();i++){
     675           0 :       AliITSRecPoint *recpoint = (AliITSRecPoint*) &(fclusters[i]);
     676           0 :       RecpointToOutput(outputClusters,recpoint,clustIdx);
     677             :     }
     678           0 :   }
     679             :   else{
     680           0 :     AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
     681             :     TClonesArray* clusters = NULL;
     682           0 :     for(Int_t i=fFirstModule;i<fLastModule;i++){
     683           0 :       clusters = rpc->UncheckedGetClusters(i);
     684           0 :       for(Int_t j=0;j<clusters->GetEntriesFast();j++){
     685           0 :         AliITSRecPoint *recpoint = (AliITSRecPoint*) clusters->At(j);
     686           0 :         RecpointToOutput(outputClusters,recpoint,clustIdx);
     687             :       }
     688             :     } 
     689             :   }
     690           0 : }
     691             : 
     692             : void AliHLTITSClusterFinderComponent::RecpointToOutput(AliHLTITSClusterData *outputClusters, AliITSRecPoint *recpoint, int &clustIdx){
     693           0 :   outputClusters->fSpacePoints[clustIdx].fY=recpoint->GetY();
     694           0 :   outputClusters->fSpacePoints[clustIdx].fZ=recpoint->GetZ();
     695           0 :   outputClusters->fSpacePoints[clustIdx].fSigmaY2=recpoint->GetSigmaY2();
     696           0 :   outputClusters->fSpacePoints[clustIdx].fSigmaZ2=recpoint->GetSigmaZ2();
     697           0 :   outputClusters->fSpacePoints[clustIdx].fSigmaYZ=recpoint->GetSigmaYZ();
     698           0 :   outputClusters->fSpacePoints[clustIdx].fQ=recpoint->GetQ();
     699           0 :   outputClusters->fSpacePoints[clustIdx].fNy=recpoint->GetNy();
     700           0 :   outputClusters->fSpacePoints[clustIdx].fNz=recpoint->GetNz();
     701           0 :   outputClusters->fSpacePoints[clustIdx].fLayer=recpoint->GetLayer();
     702           0 :   outputClusters->fSpacePoints[clustIdx].fIndex=recpoint->GetDetectorIndex() | recpoint->GetPindex() | recpoint->GetNindex();
     703           0 :   outputClusters->fSpacePoints[clustIdx].fTracks[0]=recpoint->GetLabel(0);
     704           0 :   outputClusters->fSpacePoints[clustIdx].fTracks[1]=recpoint->GetLabel(1);
     705           0 :   outputClusters->fSpacePoints[clustIdx].fTracks[2]=recpoint->GetLabel(2);      
     706           0 :   clustIdx++;
     707           0 : }

Generated by: LCOV version 1.11