LCOV - code coverage report
Current view: top level - HLT/TPCLib - AliHLTTPCCFComparisonComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 24 113 21.2 %
Date: 2016-06-14 17:26:59 Functions: 7 18 38.9 %

          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: Kalliopi Kanaki <Kalliopi.Kanaki@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   AliHLTTPCCFComparisonComponent.cxx
      20             : /// @author Kalliopi Kanaki
      21             : /// @date   
      22             : /// @brief  A comparison component for FCF and SCF properties
      23             : ///
      24             : 
      25             : #include "AliHLTTPCCFComparisonComponent.h"
      26             : #include "AliHLTTPCGeometry.h"
      27             : #include "AliHLTTPCClusterDataFormat.h"
      28             : #include "AliHLTTPCMemHandler.h"
      29             : #include "AliHLTTPCDefinitions.h"
      30             : #include "AliHLTGlobalBarrelTrack.h"
      31             : #include "AliHLTExternalTrackParam.h"
      32             : #include "AliHLTDataTypes.h"
      33             : 
      34             : #include <TFile.h>
      35             : #include <TString.h>
      36             : #include "TNtuple.h"
      37             : #include "TH1F.h"
      38             : #include "TObjString.h"
      39             : #include "TObjArray.h"
      40             : 
      41             : /** ROOT macro for the implementation of ROOT specific class methods */
      42           6 : ClassImp(AliHLTTPCCFComparisonComponent)
      43             : 
      44           3 : AliHLTTPCCFComparisonComponent::AliHLTTPCCFComparisonComponent()
      45             :     :
      46           3 :     fEvtMod(20)
      47           3 :   , fBufferSize(5000)
      48           3 :   , fMultiplicity(NULL)
      49           3 :   , fClusters(NULL)
      50           3 :   , fTracks(NULL)
      51          15 : {
      52             :   // see header file for class documentation
      53             :   // or
      54             :   // refer to README to build package
      55             :   // or
      56             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      57         222 :   for(int i=0; i<36; i++){
      58        1512 :      for(int j=0; j<6; j++){
      59         648 :          fSCFClustersArray[i][j] = NULL;
      60         648 :          fSCFNSpacePoints[i][j]  = 0;     
      61         648 :          fFCFClustersArray[i][j] = NULL;
      62         648 :          fFCFNSpacePoints[i][j]  = 0;     
      63             :      }  
      64             :   }
      65           6 : }
      66             : 
      67             : const char* AliHLTTPCCFComparisonComponent::fgkOCDBEntry="HLT/ConfigTPC/TPCCFComparison";
      68             : 
      69          18 : AliHLTTPCCFComparisonComponent::~AliHLTTPCCFComparisonComponent(){
      70             : // see header file for class documentation
      71         222 :   for(int i=0; i<36; i++){
      72        1512 :      for(int j=0; j<6; j++){
      73         648 :          delete[] fSCFClustersArray[i][j];
      74         648 :          fSCFClustersArray[i][j] = NULL;         
      75         648 :          delete[] fSCFClustersArray[i][j];
      76         648 :          fSCFClustersArray[i][j] = NULL;         
      77             :      }  
      78             :   }
      79           9 : }
      80             : 
      81             : // Public functions to implement AliHLTComponent's interface.
      82             : // These functions are required for the registration process
      83             : 
      84             : const char* AliHLTTPCCFComparisonComponent::GetComponentID(){
      85             : // see header file for class documentation
      86             :   
      87         450 :   return "TPCCFComparison";
      88             : }
      89             : 
      90             : void AliHLTTPCCFComparisonComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){
      91             : // see header file for class documentation
      92             :   
      93           0 :   list.clear();
      94           0 :   list.push_back(AliHLTTPCDefinitions::fgkClustersDataType|kAliHLTDataOriginTPC);
      95           0 :   list.push_back(AliHLTTPCDefinitions::fgkAlterClustersDataType|kAliHLTDataOriginTPC);
      96           0 :   list.push_back(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);  
      97           0 : }
      98             : 
      99             : AliHLTComponentDataType AliHLTTPCCFComparisonComponent::GetOutputDataType(){
     100             : // see header file for class documentation
     101           0 :   return kAliHLTMultipleDataType;
     102             : }
     103             : 
     104             : int AliHLTTPCCFComparisonComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
     105             : // see header file for class documentation
     106           0 :   tgtList.clear();
     107           0 :   tgtList.push_back(kAliHLTDataTypeTNtuple|kAliHLTDataOriginTPC);
     108           0 :   tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
     109           0 :   return tgtList.size();
     110             : }
     111             : 
     112             : void AliHLTTPCCFComparisonComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){
     113             : // see header file for class documentation
     114             :   
     115           0 :   constBase = 5000;
     116           0 :   inputMultiplier = 1;// XXX TODO: Find more realistic value
     117           0 : }
     118             : 
     119             : AliHLTComponent* AliHLTTPCCFComparisonComponent::Spawn(){
     120             : // see header file for class documentation
     121           0 :   return new AliHLTTPCCFComparisonComponent;
     122           0 : }
     123             : 
     124             : int AliHLTTPCCFComparisonComponent::DoInit( int argc, const char** argv ){
     125             : // see header file for class documentation
     126             :  
     127           0 :   fClusters = new TNtuple("fClusters", "fClusters", "charge:qmax:residualY:residualZ"); 
     128           0 :   fTracks   = new TNtuple("fTracks",  "fTracks",  "pt:eta:psi:nclusters"); 
     129             :  
     130           0 :   fClusters->SetCircular(fBufferSize);
     131           0 :   fTracks->SetCircular(fBufferSize);
     132             :  
     133           0 :   fMultiplicity = new TH1F("fMultiplicity","Track multiplicity per event", 1000, 0, 1000);
     134             :   
     135             :   
     136             :   // first configure the default
     137             :   int iResult=0;
     138           0 :   if (iResult>=0) iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
     139             : 
     140             :   // configure from the command line parameters if specified
     141           0 :   if (iResult>=0 && argc>0)  iResult=ConfigureFromArgumentString(argc, argv);
     142             :   
     143           0 :   return iResult;
     144           0 : }
     145             :   
     146             : int AliHLTTPCCFComparisonComponent::DoDeinit(){
     147             : // see header file for class documentation
     148             :   
     149           0 :   delete fClusters;
     150           0 :   delete fTracks;
     151           0 :   delete fMultiplicity;
     152             :   
     153           0 :   return 0;
     154             : }
     155             : 
     156             : int AliHLTTPCCFComparisonComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/){
     157             : // see header file for class documentation
     158             : 
     159             :   // configure from the specified antry or the default one
     160             :   const char* entry=cdbEntry;
     161           0 :   if (!entry || entry[0]==0) {
     162           0 :      entry=fgkOCDBEntry;
     163           0 :   }
     164           0 :   return ConfigureFromCDBTObjString(entry);
     165             : }
     166             : 
     167             : 
     168             : int AliHLTTPCCFComparisonComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){
     169             : // see header file for class documentation
     170             : 
     171           0 :   if(GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) return 0;  
     172             : 
     173             :   const AliHLTComponentBlockData *iter = NULL;
     174             :   
     175           0 :   for(int i=0; i<36; i++){
     176           0 :      for(int j=0; j<6; j++){
     177           0 :          fSCFClustersArray[i][j] = NULL;
     178           0 :          fSCFNSpacePoints[i][j]  = 0;     
     179           0 :          fFCFClustersArray[i][j] = NULL;
     180           0 :          fFCFNSpacePoints[i][j]  = 0;     
     181             :      }  
     182             :   }
     183             :  
     184             :  
     185             :   //----------------- loop over SCF output blocks ---------------------//
     186             :   
     187             :   //Int_t totalSpacePoints = 0;
     188             :   
     189           0 :   for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
     190             :             
     191           0 :       if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType) continue;
     192             : 
     193           0 :       AliHLTUInt8_t minSlice     = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
     194           0 :       AliHLTUInt8_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
     195             :       //HLTDebug("Input Data - TPC cluster - slice/partition: %d/%d.", minSlice, minPartition);
     196             : 
     197           0 :       const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*)iter->fPtr;
     198           0 :       Int_t nSpacepoint = (Int_t)clusterData->fSpacePointCnt;    
     199             :       //totalSpacePoints += nSpacepoint;
     200             :       HLTDebug("TPCCFComparison component found %d SCF spacepoints in slice %d partition %d", nSpacepoint, minSlice, minPartition);
     201             :       
     202           0 :       AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
     203             :       
     204           0 :       if(fSCFClustersArray[minSlice][minPartition] != NULL){
     205           0 :          delete(fSCFClustersArray[minSlice][minPartition]); 
     206           0 :          fSCFClustersArray[minSlice][minPartition] = NULL;
     207           0 :       }      
     208             : 
     209           0 :       fSCFClustersArray[minSlice][minPartition] = clusters;
     210           0 :       fSCFNSpacePoints[minSlice][minPartition]  = nSpacepoint;
     211             :       
     212           0 :       HLTInfo("SCF cluster loop charge %d, slice %d partition %d\n", (UInt_t)clusters->fCharge, minSlice, minPartition);   
     213             :       
     214             :       // Here are all the cluster data you can use:
     215             :               
     216             :       //Float_t fX;        // X coordinate in local coordinates
     217             :       //Float_t fY;        // Y coordinate in local coordinates
     218             :       //Float_t fZ;        // Z coordinate in local coordinates
     219             :       //UInt_t fID;        // contains slice patch and number
     220             :       //UChar_t fPadRow;  // Pad row number
     221             :       //Float_t fSigmaY2; // error (former width) of the clusters
     222             :       //Float_t fSigmaZ2; // error (former width) of the clusters
     223             :       //UInt_t fCharge;   // total charge of cluster
     224             :       //UInt_t fQMax;     // QMax of cluster
     225             :   
     226             :       
     227           0 :       if(nSpacepoint==0) fSCFClustersArray[minSlice][minPartition] = NULL;
     228             : 
     229           0 :   } // end of loop over cluster data blocks
     230             :   
     231             :   //HLTDebug("TPCCFComparison found %d spacepoints",totalSpacePoints);
     232             :   
     233             :   
     234             :   //----------------- loop over FCF output blocks ---------------------//
     235             :   
     236             :   
     237           0 :   for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkAlterClustersDataType); iter != NULL; iter = GetNextInputBlock()){
     238             :             
     239           0 :       if(iter->fDataType!=AliHLTTPCDefinitions::fgkAlterClustersDataType) continue;
     240             : 
     241           0 :       AliHLTUInt8_t minSlice     = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
     242           0 :       AliHLTUInt8_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
     243             :       //HLTDebug("Input Data - TPC cluster - slice/partition: %d/%d.", minSlice, minPartition);
     244             : 
     245           0 :       const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*)iter->fPtr;
     246           0 :       Int_t nSpacepoint = (Int_t)clusterData->fSpacePointCnt;    
     247             :       //totalSpacePoints += nSpacepoint;
     248             :       HLTDebug("TPCCFComparison component found %d FCF spacepoints in slice %d partition %d", nSpacepoint, minSlice, minPartition);
     249             :       
     250           0 :       AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
     251             :       
     252           0 :       if(fFCFClustersArray[minSlice][minPartition] != NULL){
     253           0 :          delete(fFCFClustersArray[minSlice][minPartition]); 
     254           0 :          fFCFClustersArray[minSlice][minPartition] = NULL;
     255           0 :       }      
     256             : 
     257           0 :       fFCFClustersArray[minSlice][minPartition] = clusters;
     258           0 :       fFCFNSpacePoints[minSlice][minPartition]  = nSpacepoint;
     259             :            
     260           0 :       HLTInfo("FCF cluster loop charge %d, slice %d partition %d\n", (UInt_t)clusters->fCharge, minSlice, minPartition);  
     261             :       
     262           0 :       if(nSpacepoint==0) fFCFClustersArray[minSlice][minPartition] = NULL;
     263             : 
     264           0 :   } // end of loop over cluster data blocks
     265             :   
     266             :   
     267             :   
     268             :   //----------------- loop over merged tracks -------------------//
     269             : 
     270             : //   Int_t totalTracks = 0;
     271             : //   
     272             : //   for(iter = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){    
     273             : //       if(iter->fDataType != (kAliHLTDataTypeTrack|kAliHLTDataOriginTPC)) continue; 
     274             : //       ReadTracks(iter,totalTracks);
     275             : //   }
     276             : //   
     277             : //   HLTDebug("TrackHisto found %d tracks", totalTracks);  
     278             : // 
     279             : //   fMultiplicity->Fill(totalTracks);
     280             : // 
     281             : //   PushHisto();
     282             :   
     283             :   return 0;
     284           0 : } // end of DoEvent
     285             :  
     286             : // void AliHLTTPCCFComparisonComponent::ReadTracks(const AliHLTComponentBlockData* iter,Int_t &tt){
     287             : // // see header file for class documentation
     288             : // 
     289             : //   //AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
     290             : //   
     291             : //   Int_t usedSpacePoints = 0;
     292             : //   
     293             : //   vector<AliHLTGlobalBarrelTrack> tracksVector;
     294             : //   AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(iter->fPtr), iter->fSize, tracksVector);
     295             : //   
     296             : //   tt = tracksVector.size();
     297             : //   
     298             : //   for(vector<AliHLTGlobalBarrelTrack>::iterator element=tracksVector.begin();  element!=tracksVector.end(); element++){
     299             : //        
     300             : //   
     301             : // 
     302             : //            
     303             : //        UInt_t nHits = element->GetNumberOfPoints();
     304             : //        fTracks->Fill( 1./element->OneOverPt(), element->GetSnp(), element->GetTgl(), nHits );  
     305             : //        //fdNdEta->Fill(element->GetSnp());
     306             : //  
     307             : //        Double_t totCharge = 0;
     308             : //        const UInt_t *hitnum = element->GetPoints();
     309             : //        for(UInt_t i=0; i<element->GetNumberOfPoints(); i++){
     310             : //            
     311             : //                 UInt_t idTrack   = hitnum[i];
     312             : //            Int_t sliceTrack = AliHLTTPCSpacePointData::GetSlice(idTrack);
     313             : //            Int_t patchTrack = AliHLTTPCSpacePointData::GetPatch(idTrack);
     314             : //            UInt_t pos            = AliHLTTPCSpacePointData::GetNumber(idTrack);
     315             : //         
     316             : //         //printf("KKKK pos :%d\n", pos);
     317             : //         cout << "KKKK pos  " << pos << endl;
     318             : // 
     319             : //            if( !fClustersArray[sliceTrack][patchTrack] ) continue;          
     320             : //                 
     321             : //                 if(sliceTrack<0 || sliceTrack>36 || patchTrack<0 || patchTrack>5 ){
     322             : //                    HLTError("Corrupted TPC cluster Id: slice %d, patch %d, cluster %d", sliceTrack, patchTrack, idTrack);
     323             : //                    continue;
     324             : //                 }
     325             : // 
     326             : //            if(fNSpacePoints[sliceTrack][patchTrack]<=pos ){
     327             : //                    HLTError("Space point array out of boundaries!");
     328             : //                    continue;
     329             : //            }
     330             : //                 
     331             : //                 totCharge += (fClustersArray[sliceTrack][patchTrack])[pos].fCharge; 
     332             : //                 
     333             : //                 //Float_t xyz[3]; xyz[0] = xyz[1] = xyz[2] = 0.;
     334             : //         
     335             : //            //xyz[0] = (fClustersArray[sliceTrack][patchTrack])[pos].fX;
     336             : //            //xyz[1] = (fClustersArray[sliceTrack][patchTrack])[pos].fY;
     337             : //            //xyz[2] = (fClustersArray[sliceTrack][patchTrack])[pos].fZ;
     338             : //         
     339             : //            //AliHLTTPCGeometry::Local2Global(xyz,slice); 
     340             : //                 
     341             : //                 //Double_t p[2]   = { xyz[1], xyz[2] };
     342             : //            //Double_t cov[3] = { (fClustersArray[sliceTrack][patchTrack])[pos].fSigmaY2, 0., (fClustersArray[sliceTrack][patchTrack])[pos].fSigmaZ2};  
     343             : //                 //Double_t *res = element->GetResiduals(p,cov,kFALSE); 
     344             : //                 
     345             : //                 //HLTInfo("resy: %f, resz: %f", res[0], res[1]);
     346             : //                 
     347             : //                 //if(!res)  res[0] = res[1] = -1000.;
     348             : //                 //else      fClusters->Fill( (fClustersArray[sliceTrack][patchTrack])[pos].fCharge, (fClustersArray[sliceTrack][patchTrack])[pos].fQMax, res[0], res[1]);
     349             : //                
     350             : //                 fClusters->Fill( (fClustersArray[sliceTrack][patchTrack])[pos].fCharge, (fClustersArray[sliceTrack][patchTrack])[pos].fQMax, -1000., -1000.);
     351             : //             
     352             : //                 usedSpacePoints++;      
     353             : //        }     
     354             : // 
     355             : //   }
     356             : // }
     357             : 
     358             : // void AliHLTTPCCFComparisonComponent::PushHisto(){
     359             : // // see header file for class documentation
     360             : //     
     361             : //     PushBack( (TObject*)fTracks,       kAliHLTDataTypeTNtuple  |kAliHLTDataOriginTPC, 0x0);   
     362             : //     PushBack( (TObject*)fClusters,     kAliHLTDataTypeTNtuple  |kAliHLTDataOriginTPC, 0x0);
     363             : //     PushBack( (TObject*)fMultiplicity, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, 0x0);
     364             : // }
     365             : 
     366             : int AliHLTTPCCFComparisonComponent::ScanConfigurationArgument(int argc, const char** argv){
     367             : // see header file for class documentation
     368             :  
     369           0 :   if (argc<=0) return 0;
     370             :   int i=0;
     371           0 :   TString argument=argv[i];
     372             : 
     373             :   // -event-modulo
     374           0 :   if (argument.CompareTo("-event-modulo")==0) {
     375           0 :     if (++i>=argc) return -EPROTO;
     376           0 :     argument=argv[i];
     377           0 :     fEvtMod=argument.Atoi();
     378           0 :     return 2;
     379             :   }    
     380             : 
     381             :   // -buffer-size
     382           0 :   if (argument.CompareTo("-buffer-size")==0) {
     383           0 :     if (++i>=argc) return -EPROTO;
     384           0 :     argument=argv[i];
     385           0 :     fBufferSize=argument.Atoi();
     386           0 :     return 2;
     387             :   }    
     388             :    
     389           0 :   return -EINVAL;
     390           0 : }
     391             : 
     392             : void AliHLTTPCCFComparisonComponent::GetOCDBObjectDescription( TMap* const targetMap){
     393             : // Get a list of OCDB object description needed for the particular component
     394           0 :   if (!targetMap) return;
     395           0 :   targetMap->Add(new TObjString("HLT/ConfigTPC/TPCCFComparison"), new TObjString("component arguments for setting the size of the filled ntuples and the event modulo for the mean multiplicity distribution"));
     396           0 : }

Generated by: LCOV version 1.11