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