]>
Commit | Line | Data |
---|---|---|
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 | 55 | ClassImp(AliMpSt345Reader) |
13985652 | 56 | /// \endcond |
f0eac1a3 | 57 | |
dee1d5f1 | 58 | //_____________________________________________________________________________ |
21027e5a | 59 | AliMpSt345Reader::AliMpSt345Reader(AliMpSlatMotifMap* motifMap) |
d5c9a22c | 60 | : |
61 | TObject(), | |
183279c1 | 62 | fMotifMap(motifMap) |
dee1d5f1 | 63 | { |
71a2d3aa | 64 | /// |
65 | /// Default ctor. | |
66 | /// | |
dee1d5f1 | 67 | } |
68 | ||
69 | //_____________________________________________________________________________ | |
70 | AliMpSt345Reader::~AliMpSt345Reader() | |
71 | { | |
71a2d3aa | 72 | /// |
73 | /// Dtor. | |
74 | /// | |
dee1d5f1 | 75 | } |
76 | ||
77 | //_____________________________________________________________________________ | |
78 | AliMpPCB* | |
21027e5a | 79 | AliMpSt345Reader::ReadPCB(const AliMpDataStreams& dataStreams, |
80 | const char* pcbType) | |
dee1d5f1 | 81 | { |
d5c9a22c | 82 | /// |
83 | /// Create a new AliMpPCB object, by reading it from file. | |
84 | /// The returned object must be deleted by the client | |
dee1d5f1 | 85 | |
228fd720 | 86 | istream& in |
21027e5a | 87 | = dataStreams. |
ab167304 | 88 | CreateDataStream(AliMpFiles::SlatPCBFilePath( |
228fd720 | 89 | AliMp::kStation345, pcbType)); |
dee1d5f1 | 90 | |
21027e5a | 91 | AliMpMotifReader reader(AliMp::kStation345, AliMq::kNotSt12, AliMp::kNonBendingPlane); |
dee1d5f1 | 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 | char line[80]; | |
98 | ||
84aac932 | 99 | const TString kSizeKeyword("SIZES"); |
100 | const TString kMotifKeyword("MOTIF"); | |
dee1d5f1 | 101 | |
102 | AliMpPCB* pcb = 0; | |
103 | ||
104 | while ( in.getline(line,80) ) | |
105 | { | |
106 | if ( line[0] == '#' ) continue; | |
107 | ||
108 | TString sline(line); | |
109 | ||
84aac932 | 110 | if ( sline(0,kSizeKeyword.Length()) == kSizeKeyword ) |
dee1d5f1 | 111 | { |
84aac932 | 112 | std::istringstream sin(sline(kSizeKeyword.Length(), |
113 | sline.Length()-kSizeKeyword.Length()).Data()); | |
d5c9a22c | 114 | double padSizeX = 0.0; |
115 | double padSizeY = 0.0; | |
116 | double pcbSizeX = 0.0; | |
117 | double pcbSizeY = 0.0; | |
dee1d5f1 | 118 | sin >> padSizeX >> padSizeY >> pcbSizeX >> pcbSizeY; |
c918393d | 119 | if (pcb) |
120 | { | |
121 | AliError("pcb not null as expected"); | |
122 | } | |
657b96e3 | 123 | pcb = new AliMpPCB(fMotifMap,pcbType,padSizeX,padSizeY,pcbSizeX,pcbSizeY); |
dee1d5f1 | 124 | } |
125 | ||
84aac932 | 126 | if ( sline(0,kMotifKeyword.Length()) == kMotifKeyword ) |
dee1d5f1 | 127 | { |
84aac932 | 128 | std::istringstream sin(sline(kMotifKeyword.Length(), |
129 | sline.Length()-kMotifKeyword.Length()).Data()); | |
dee1d5f1 | 130 | TString sMotifType; |
131 | int ix; | |
132 | int iy; | |
133 | sin >> sMotifType >> ix >> iy; | |
134 | ||
657b96e3 | 135 | AliMpMotifType* motifType = fMotifMap->FindMotifType(sMotifType); |
d5c9a22c | 136 | if (!motifType) |
137 | { | |
138 | AliDebug(1,Form("Reading motifType %s from file",sMotifType.Data())); | |
21027e5a | 139 | motifType = reader.BuildMotifType(dataStreams, sMotifType.Data()); |
657b96e3 | 140 | fMotifMap->AddMotifType(motifType); |
d5c9a22c | 141 | } |
142 | else | |
143 | { | |
144 | AliDebug(1,Form("Got motifType %s from motifMap",sMotifType.Data())); | |
145 | } | |
dee1d5f1 | 146 | |
76e1274b | 147 | if (pcb) pcb->Add(motifType,ix,iy); |
dee1d5f1 | 148 | } |
149 | } | |
150 | ||
228fd720 | 151 | delete ∈ |
dee1d5f1 | 152 | |
dee1d5f1 | 153 | return pcb; |
154 | } | |
155 | ||
156 | //_____________________________________________________________________________ | |
157 | AliMpSlat* | |
21027e5a | 158 | AliMpSt345Reader::ReadSlat(const AliMpDataStreams& dataStreams, |
159 | const char* slatType, AliMp::PlaneType planeType) | |
dee1d5f1 | 160 | { |
d5c9a22c | 161 | /// |
162 | /// Create a new AliMpSlat object, by reading it from file. | |
163 | /// The returned object must be deleted by the client. | |
dee1d5f1 | 164 | |
228fd720 | 165 | istream& in |
21027e5a | 166 | = dataStreams. |
ab167304 | 167 | CreateDataStream(AliMpFiles::SlatFilePath( |
228fd720 | 168 | AliMp::kStation345, slatType, planeType)); |
169 | ||
dee1d5f1 | 170 | char line[80]; |
171 | ||
84aac932 | 172 | const TString kpcbKeyword("PCB"); |
dee1d5f1 | 173 | |
aad465b5 | 174 | AliMpSlat* slat = new AliMpSlat(slatType, planeType); |
dee1d5f1 | 175 | |
176 | while ( in.getline(line,80) ) | |
177 | { | |
178 | if ( line[0] == '#' ) continue; | |
179 | ||
180 | TString sline(AliMpHelper::Normalize(line)); | |
181 | ||
84aac932 | 182 | if ( sline(0,kpcbKeyword.Length()) == kpcbKeyword ) |
dee1d5f1 | 183 | { |
84aac932 | 184 | TString tmp(sline(kpcbKeyword.Length()+1,sline.Length()-kpcbKeyword.Length())); |
dee1d5f1 | 185 | Ssiz_t blankPos = tmp.First(' '); |
186 | if ( blankPos < 0 ) | |
187 | { | |
188 | AliErrorClass("Syntax error in PCB file, should get a list of " | |
189 | "manu ids after the pcbname"); | |
190 | delete slat; | |
191 | return 0; | |
192 | } | |
193 | ||
194 | TString pcbName(tmp(0,blankPos)); | |
195 | TString manus(tmp(blankPos+1,tmp.Length()-blankPos)); | |
196 | ||
21027e5a | 197 | AliMpPCB* pcbType = ReadPCB(dataStreams,pcbName.Data()); |
dee1d5f1 | 198 | if (!pcbType) |
199 | { | |
200 | AliErrorClass(Form("Cannot read pcbType=%s",pcbName.Data())); | |
201 | delete slat; | |
202 | return 0; | |
203 | } | |
204 | ||
205 | TArrayI manuList; | |
206 | AliMpHelper::DecodeName(manus,';',manuList); | |
c6e05ab2 | 207 | if ( manuList.GetSize() != Int_t(pcbType->GetSize()) ) |
dee1d5f1 | 208 | { |
209 | AliErrorClass(Form("Wrong number of manu ids for this PCB (" | |
210 | "%s) : %d out of %d",pcbName.Data(), | |
211 | manuList.GetSize(),pcbType->GetSize())); | |
d5c9a22c | 212 | delete pcbType; |
dee1d5f1 | 213 | delete slat; |
214 | return 0; | |
215 | } | |
f0eac1a3 | 216 | |
217 | for ( Int_t i = 0; i < manuList.GetSize(); ++i ) | |
218 | { | |
219 | manuList[i] |= AliMpConstants::ManuMask(planeType); | |
220 | } | |
d5c9a22c | 221 | slat->Add(*pcbType,manuList); |
222 | delete pcbType; | |
dee1d5f1 | 223 | } |
224 | } | |
225 | ||
228fd720 | 226 | delete ∈ |
dee1d5f1 | 227 | |
228 | return slat; | |
228fd720 | 229 | } |
230 | ||
dee1d5f1 | 231 |