LCOV - code coverage report
Current view: top level - MUON/MUONmapping - AliMpSt345Reader.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 73 84 86.9 %
Date: 2016-06-14 17:26:59 Functions: 7 8 87.5 %

          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 purpeateose. It is      *
      13             : * provided "as is" without express or implied warranty.                  *
      14             : **************************************************************************/
      15             : 
      16             : // $Id$
      17             : // $MpId: AliMpSt345Reader.cxx,v 1.11 2006/05/24 13:58:50 ivana Exp $
      18             : 
      19             : #include "AliMpSt345Reader.h"
      20             : 
      21             : #include "AliLog.h"
      22             : #include "AliMpSlatMotifMap.h"
      23             : #include "AliMpMotifReader.h"
      24             : #include "AliMpFiles.h"
      25             : #include "AliMpDataStreams.h"
      26             : #include "AliMpMotifType.h"
      27             : #include "AliMpPCB.h"
      28             : #include "AliMpSlat.h"
      29             : #include "AliMpMotifPosition.h"
      30             : #include "AliMpMotif.h"
      31             : #include "AliMpHelper.h"
      32             : #include "AliMpConstants.h"
      33             : 
      34             : #include "Riostream.h"
      35             : #include "TClass.h"
      36             : #include "TObjString.h"
      37             : #include "TString.h"
      38             : 
      39             : #include <sstream>
      40             : 
      41             :  
      42             : //-----------------------------------------------------------------------------
      43             : /// \class AliMpSt345Reader
      44             : //
      45             : /// Read slat and pcb ASCII files.
      46             : /// 
      47             : /// Basically this class provides two methods :
      48             : /// - AliMpSlat* ReadSlat()
      49             : /// - AliMpPCB ReadPCB()
      50             : ///
      51             : /// \author Laurent Aphecetche
      52             : //-----------------------------------------------------------------------------
      53             : 
      54             : /// \cond CLASSIMP
      55          18 : ClassImp(AliMpSt345Reader)
      56             : /// \endcond
      57             : 
      58             : //_____________________________________________________________________________
      59             : AliMpSt345Reader::AliMpSt345Reader(AliMpSlatMotifMap* motifMap)
      60             : : 
      61         114 : TObject(),
      62         114 : fMotifMap(motifMap)
      63         570 : {
      64             :   ///
      65             :   /// Default ctor.
      66             :   ///
      67         228 : } 
      68             : 
      69             : //_____________________________________________________________________________
      70             : AliMpSt345Reader::~AliMpSt345Reader()
      71         228 : {
      72             :   ///
      73             :   /// Dtor.
      74             :   ///
      75         342 : }
      76             : 
      77             : //_____________________________________________________________________________
      78             : AliMpPCB*
      79             : AliMpSt345Reader::ReadPCB(const AliMpDataStreams& dataStreams,
      80             :                           const char* pcbType)
      81             : { 
      82             :   ///
      83             :   /// Create a new AliMpPCB object, by reading it from file.
      84             :   /// The returned object must be deleted by the client
      85             :   
      86             :   istream& in 
      87         960 :     = dataStreams.
      88         960 :         CreateDataStream(AliMpFiles::SlatPCBFilePath(
      89             :                              AliMp::kStation345, pcbType));
      90             :  
      91         480 :   AliMpMotifReader reader(AliMp::kStation345, AliMq::kNotSt12, AliMp::kNonBendingPlane); 
      92             :   // note that the nonbending
      93             :   // parameter is of no use for station345, as far as reading motif is 
      94             :   // concerned, as all motifs are supposed to be in the same directory
      95             :   // (as they are shared by bending/non-bending planes).
      96             :      
      97         480 :   char line[80];
      98             :   
      99         480 :   const TString kSizeKeyword("SIZES");
     100         480 :   const TString kMotifKeyword("MOTIF");
     101             :   
     102             :   AliMpPCB* pcb = 0;
     103             :   
     104       37668 :   while ( in.getline(line,80) )
     105             :   {
     106        9186 :     if ( line[0] == '#' ) continue;
     107             :     
     108        8190 :     TString sline(line);
     109             :     
     110       32760 :     if ( sline(0,kSizeKeyword.Length()) == kSizeKeyword )
     111             :     {
     112        2880 :       std::istringstream sin(sline(kSizeKeyword.Length(),
     113        1440 :                                    sline.Length()-kSizeKeyword.Length()).Data());
     114         480 :       double padSizeX = 0.0;
     115         480 :       double padSizeY = 0.0;
     116         480 :       double pcbSizeX = 0.0;
     117         480 :       double pcbSizeY = 0.0;
     118        1920 :       sin >> padSizeX >> padSizeY >> pcbSizeX >> pcbSizeY;
     119         480 :       if (pcb)
     120             :       {
     121           0 :         AliError("pcb not null as expected");
     122             :       }
     123         960 :       pcb = new AliMpPCB(fMotifMap,pcbType,padSizeX,padSizeY,pcbSizeX,pcbSizeY);
     124         480 :     }
     125             :     
     126       32760 :     if ( sline(0,kMotifKeyword.Length()) == kMotifKeyword )
     127             :     {
     128       24678 :       std::istringstream sin(sline(kMotifKeyword.Length(),
     129       12339 :                                    sline.Length()-kMotifKeyword.Length()).Data());
     130        4113 :       TString sMotifType;
     131        4113 :       int ix;
     132        4113 :       int iy;
     133       12339 :       sin >> sMotifType >> ix >> iy;
     134             :       
     135        4113 :       AliMpMotifType* motifType = fMotifMap->FindMotifType(sMotifType);
     136        8226 :       if (!motifType)
     137             :       {
     138        1560 :         AliDebug(1,Form("Reading motifType %s from file",sMotifType.Data()));
     139        1248 :         motifType = reader.BuildMotifType(dataStreams, sMotifType.Data());
     140         312 :         fMotifMap->AddMotifType(motifType);
     141             :       }
     142             :       else
     143             :       {
     144       23118 :         AliDebug(1,Form("Got motifType %s from motifMap",sMotifType.Data()));
     145             :       }
     146             :       
     147        8226 :       if (pcb) pcb->Add(motifType,ix,iy);
     148        4113 :     }
     149        8190 :   }
     150             :   
     151         960 :   delete &in;
     152             :   
     153             :   return pcb;
     154         480 : }
     155             : 
     156             : //_____________________________________________________________________________
     157             : AliMpSlat*
     158             : AliMpSt345Reader::ReadSlat(const AliMpDataStreams& dataStreams,
     159             :                            const char* slatType, AliMp::PlaneType planeType)
     160             : {
     161             :   ///
     162             :   /// Create a new AliMpSlat object, by reading it from file.
     163             :   /// The returned object must be deleted by the client.
     164             :   
     165             :   istream& in 
     166         228 :     = dataStreams.
     167         228 :         CreateDataStream(AliMpFiles::SlatFilePath(
     168             :                              AliMp::kStation345, slatType, planeType));
     169             : 
     170         114 :   char line[80];
     171             :   
     172         114 :   const TString kpcbKeyword("PCB");
     173             :   
     174         228 :   AliMpSlat* slat = new AliMpSlat(slatType, planeType);
     175             :   
     176        2418 :   while ( in.getline(line,80) )
     177             :   {
     178         654 :     if ( line[0] == '#' ) continue;
     179             :     
     180         567 :     TString sline(AliMpHelper::Normalize(line));
     181             :     
     182        2268 :     if ( sline(0,kpcbKeyword.Length()) == kpcbKeyword )
     183             :     {
     184        2400 :       TString tmp(sline(kpcbKeyword.Length()+1,sline.Length()-kpcbKeyword.Length()));
     185         480 :       Ssiz_t blankPos = tmp.First(' ');
     186         480 :       if ( blankPos < 0 )
     187             :             {
     188           0 :         AliErrorClass("Syntax error in PCB file, should get a list of "
     189             :                       "manu ids after the pcbname");
     190           0 :         delete slat;
     191           0 :         return 0;
     192             :             }
     193             :       
     194         960 :       TString pcbName(tmp(0,blankPos));
     195        1440 :       TString manus(tmp(blankPos+1,tmp.Length()-blankPos));
     196             :       
     197         960 :       AliMpPCB* pcbType = ReadPCB(dataStreams,pcbName.Data());
     198         480 :       if (!pcbType)
     199             :             {
     200           0 :         AliErrorClass(Form("Cannot read pcbType=%s",pcbName.Data()));
     201           0 :               delete slat;
     202           0 :               return 0;
     203             :             }      
     204             : 
     205         480 :       TArrayI manuList;
     206         960 :       AliMpHelper::DecodeName(manus,';',manuList);
     207         960 :       if ( manuList.GetSize() != Int_t(pcbType->GetSize()) )
     208             :             {
     209           0 :         AliErrorClass(Form("Wrong number of manu ids for this PCB ("
     210             :                            "%s) : %d out of %d",pcbName.Data(),
     211             :                            manuList.GetSize(),pcbType->GetSize()));
     212           0 :         delete pcbType;
     213           0 :               delete slat;
     214           0 :               return 0;
     215             :       }
     216             : 
     217        9186 :       for ( Int_t i = 0; i < manuList.GetSize(); ++i )
     218             :       {
     219       12339 :         manuList[i] |= AliMpConstants::ManuMask(planeType);
     220             :       }
     221         480 :       slat->Add(*pcbType,manuList);
     222         960 :       delete pcbType;
     223        1920 :     }
     224        1134 :   }
     225             :   
     226         228 :   delete &in;
     227             :   
     228         114 :   return slat;
     229         114 : }  
     230             :                               
     231             : 

Generated by: LCOV version 1.11