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

Generated by: LCOV version 1.11