LCOV - code coverage report
Current view: top level - TRD/TRDbase - AliTRDtrackingSector.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 56 72 77.8 %
Date: 2016-06-14 17:26:59 Functions: 8 10 80.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             : * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             : *                                                                        *
       4             : * Author: The ALICE Off-line Project.                                    *
       5             : * Contributors are mentioned in the code where appropriate.              *
       6             : *                                                                        *
       7             : * Permission to use, copy, modify and distribute this software and its   *
       8             : * documentation strictly for non-commercial purposes is hereby granted   *
       9             : * without fee, provided that the above copyright notice appears in all   *
      10             : * copies and that both the copyright notice and this permission notice   *
      11             : * appear in the supporting documentation. The authors make no claims     *
      12             : * about the suitability of this software for any purpose. It is          *
      13             : * provided "as is" without express or implied warranty.                  *
      14             : **************************************************************************/
      15             : 
      16             : /* $Id: AliTRDtrackingSector.cxx 23810 2008-02-08 09:00:27Z hristov $ */
      17             : 
      18             : ///////////////////////////////////////////////////////////////////////////////
      19             : //                                                                           //
      20             : //  Tracking data container for one sector                                   //
      21             : //                                                                           //
      22             : //  Authors:                                                                 //
      23             : //    Alex Bercuci <A.Bercuci@gsi.de>                                        //
      24             : //    Markus Fasel <M.Fasel@gsi.de>                                          //
      25             : //                                                                           //
      26             : ///////////////////////////////////////////////////////////////////////////////
      27             : 
      28             : #include "AliTRDReconstructor.h"
      29             : #include "AliTRDtrackingSector.h"
      30             : #include "AliTRDtrackingChamber.h"
      31             : 
      32             : 
      33          48 : ClassImp(AliTRDtrackingSector)
      34             : 
      35             : //_____________________________________________________________________________
      36             : AliTRDtrackingSector::AliTRDtrackingSector()
      37          36 :   :fSector(-1)
      38          36 :   ,fN(0)
      39          36 :   ,fGeom(NULL)
      40         144 : {
      41             :   // Default constructor
      42             :   
      43          36 :   memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));
      44          36 :   memset(fStack,   0, AliTRDgeometry::kNlayer*sizeof(AliTRDtrackingChamber*));
      45          36 :   memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));
      46          36 :   memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));
      47          72 : }
      48             : 
      49             : //_____________________________________________________________________________
      50             : AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry *geo, Int_t gs)
      51          36 :   :fSector(gs)
      52          36 :   ,fN(0)
      53          36 :   ,fGeom(geo)
      54         144 : {
      55             :   //
      56             :   // AliTRDtrackingSector Constructor
      57             :   //
      58             : 
      59          36 :   memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));
      60          36 :   memset(fStack,   0, AliTRDgeometry::kNlayer*sizeof(AliTRDtrackingChamber*));
      61          36 :   memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));
      62          36 :   memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));
      63          72 : }
      64             : 
      65             :     
      66             : //_____________________________________________________________________________
      67             : void AliTRDtrackingSector::Init(const AliTRDReconstructor *rec)
      68             : {               
      69             : //      Steer building of tracking chambers and build tracking sector.
      70             : //      Propagate radial position information (calibration/alignment aware) from chambers to sector level
      71             : //
      72             :   
      73             :   AliTRDchamberTimeBin *tb = NULL;
      74          84 :   AliTRDtrackingChamber **tc = &fChamber[0];
      75        1173 :   for(Int_t ic = 0; (ic<AliTRDgeometry::kNdets) && (*tc); ic++, tc++){
      76       22336 :     for(Int_t itb=0; itb<AliTRDseedV1::kNtb; itb++){
      77       10819 :       if(!(tb = (*tc)->GetTB(itb))) continue;
      78       10819 :       tb->SetReconstructor(rec);
      79       10819 :     }
      80         349 :     (*tc)->Build(fGeom, rec->IsHLT());
      81             :   }
      82             :     
      83             :   Int_t nl;
      84         588 :   for(int il=0; il<AliTRDgeometry::kNlayer; il++){
      85         252 :     fX0[il] = 0.; nl = 0;
      86        3024 :     for(int is=0; is<AliTRDgeometry::kNstack; is++){
      87        1260 :       Int_t idx = is*AliTRDgeometry::kNlayer + il;
      88        2171 :       if(fIndex[idx]<0) continue;
      89         349 :       fX0[il] += GetChamber(fIndex[idx])->GetX(); 
      90         349 :       nl++; 
      91         349 :     }
      92         252 :     if(!nl){
      93             :       //printf("Could not estimate radial position  of plane %d in sector %d.\n", ip, fSector);
      94             :       continue;
      95             :     }
      96         230 :     fX0[il] /= Float_t(nl);
      97         230 :   }
      98          42 : }
      99             : 
     100             : 
     101             : 
     102             : //_____________________________________________________________________________
     103             : void AliTRDtrackingSector::Clear(const Option_t *opt)
     104             : {
     105             : // Reset counters and steer chamber clear
     106             : 
     107         288 :   AliTRDtrackingChamber **tc = &fChamber[0];
     108         986 :   for(Int_t ich=0; ich<fN; ich++, tc++){ 
     109         349 :     (*tc)->Clear(opt);
     110        1047 :     delete (*tc); (*tc) = NULL;   // I would avoid
     111             :   }     
     112         144 :   memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));
     113         144 :   fN = 0;
     114         144 : }
     115             : 
     116             : //_____________________________________________________________________________
     117             : AliTRDtrackingChamber* AliTRDtrackingSector::GetChamber(Int_t stack, Int_t layer, Bool_t build)
     118             : {
     119             : // Return chamber at position (stack, plane) in current 
     120             : // sector or build a new one if it is not already created
     121             :   
     122       18738 :   Int_t ch = stack*AliTRDgeometry::kNlayer + layer;
     123       37105 :   if(fIndex[ch] >= 0) return fChamber[Int_t(fIndex[ch])];
     124         393 :   else if(!build) return NULL;
     125             :   
     126             :   // CHAMBER HAS TO BE BUILD
     127       10304 :   Int_t rch = ch;do rch--; while(rch>=0 && fIndex[rch]<0);
     128         698 :   fIndex[ch] = rch >=0 ? fIndex[rch]+1 : 0; 
     129         349 :   fN++;
     130             :   
     131         349 :   memmove(&fChamber[Int_t(fIndex[ch])+1], &fChamber[Int_t(fIndex[ch])], (AliTRDgeometry::kNdets-fIndex[ch]-1)*sizeof(void*));
     132       11334 :   for(Int_t ic = ch+1; ic<AliTRDgeometry::kNdets; ic++) fIndex[ic] += fIndex[ic] >= 0 ? 1 : 0;
     133             :   
     134         698 :   AliTRDtrackingChamber *chmb = fChamber[Int_t(fIndex[ch])] = new AliTRDtrackingChamber();
     135         349 :   chmb->SetDetector(AliTRDgeometry::GetDetector(layer, stack, fSector));
     136             :   return chmb;
     137       18738 : }
     138             : 
     139             : //_____________________________________________________________________________
     140             : AliTRDtrackingChamber** AliTRDtrackingSector::GetStack(Int_t stack)
     141             : {
     142             : // Return chamber at position (stack, plane) in current 
     143             : // sector or build a new one if it is not already created
     144             :   
     145           0 :   if(stack<0 || stack>=AliTRDgeometry::kNstack) return NULL;
     146             :   
     147             :   Int_t ich, n = 0;
     148           0 :   for(int il=0; il<AliTRDgeometry::kNlayer; il++){
     149           0 :     ich = stack*AliTRDgeometry::kNlayer + il;
     150           0 :     if(fIndex[ich] < 0) fStack[il] = NULL; 
     151             :     else{
     152           0 :       fStack[il] = fChamber[Int_t(fIndex[ich])];
     153           0 :       n++;
     154             :     }
     155             :   }
     156             :   
     157           0 :   return n ? &fStack[0] : NULL;
     158           0 : }
     159             : 
     160             : //_____________________________________________________________________________
     161             : void AliTRDtrackingSector::Print(Option_t *opt) const
     162             : {
     163             : // Dump info about this tracking sector and the tracking chamber within
     164             : // 
     165             : 
     166           0 :   printf("\n\tSector[%2d]\n", fSector);
     167           0 :   for(int il=0; il<AliTRDgeometry::kNlayer; il++){
     168           0 :     for(int is =0; is<AliTRDgeometry::kNstack; is++){
     169           0 :       Int_t ch = is*AliTRDgeometry::kNlayer + il;
     170           0 :       if(opt) fChamber[Int_t(fIndex[ch])]->Print(opt);
     171           0 :       else printf("%2d[%2d] ", fIndex[ch], fIndex[ch]>=0 ? fChamber[Int_t(fIndex[ch])]->GetNClusters() : 0);
     172             :     }
     173           0 :     if(!opt) printf("\n");
     174             :   }
     175             : 
     176           0 : }

Generated by: LCOV version 1.11