]>
Commit | Line | Data |
---|---|---|
197883c2 | 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$ | |
13985652 | 17 | // $MpId: AliMpMotifReader.cxx,v 1.10 2006/05/24 13:58:41 ivana Exp $ |
197883c2 | 18 | // Category: sector |
19 | // | |
20 | // Class AliMpMotifReader | |
21 | // ------------------- | |
22 | // Class that takes care of reading the sector data. | |
23 | // Included in AliRoot: 2003/05/02 | |
24 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay | |
25 | ||
197883c2 | 26 | #include "AliMpFiles.h" |
27 | #include "AliMpMotifReader.h" | |
28 | #include "AliMpMotifMap.h" | |
29 | #include "AliMpMotif.h" | |
30 | #include "AliMpMotifSpecial.h" | |
31 | #include "AliMpMotifType.h" | |
32 | #include "AliMpConnection.h" | |
33 | #include "AliMpIntPair.h" | |
34 | #include "AliMpDirection.h" | |
35 | ||
2c605e66 | 36 | #include "AliLog.h" |
37 | ||
38 | #include <TSystem.h> | |
39 | #include <TMath.h> | |
40 | #include <Riostream.h> | |
41 | #include <Rstrstream.h> | |
42 | ||
43 | #if !defined(__HP_aCC) && !defined(__alpha) | |
44 | #include <sstream> | |
45 | #endif | |
46 | ||
13985652 | 47 | /// \cond CLASSIMP |
197883c2 | 48 | ClassImp(AliMpMotifReader) |
13985652 | 49 | /// \endcond |
197883c2 | 50 | |
197883c2 | 51 | //_____________________________________________________________________________ |
52 | AliMpMotifReader::AliMpMotifReader(AliMpStationType station, | |
53 | AliMpPlaneType plane) | |
54 | : TObject(), | |
55 | fStationType(station), | |
2c605e66 | 56 | fPlaneType(plane) |
197883c2 | 57 | { |
58 | /// Standard constructor | |
59 | } | |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | AliMpMotifReader::AliMpMotifReader() | |
63 | : TObject(), | |
64 | fStationType(kStation1), | |
2c605e66 | 65 | fPlaneType(kBendingPlane) |
197883c2 | 66 | { |
67 | /// Default constructor | |
68 | } | |
69 | ||
197883c2 | 70 | //_____________________________________________________________________________ |
71 | AliMpMotifReader::~AliMpMotifReader() | |
72 | { | |
73 | /// Destructor | |
74 | } | |
75 | ||
197883c2 | 76 | // |
77 | // public methods | |
78 | // | |
79 | ||
80 | //_____________________________________________________________________________ | |
81 | AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId) | |
82 | { | |
83 | /// Read the files describing a motif in the "$MINSTALL/data" directory | |
84 | /// and fill the AliMpMotifType structure with. | |
85 | /// The files mentioned are are named padPos<maskName>.dat | |
86 | /// and connect<maskName>.dat | |
87 | ||
88 | AliMpMotifType* motifType = new AliMpMotifType(motifTypeId); | |
89 | ||
d1c53ece | 90 | TString padPosFileName(AliMpFiles::PadPosFilePath(fStationType, |
91 | fPlaneType, motifTypeId)); | |
197883c2 | 92 | ifstream padPos(padPosFileName); |
da3a1bb2 | 93 | AliDebugStream(2) << "Opening file " << padPosFileName << endl; |
197883c2 | 94 | |
95 | PadMapType positions; | |
96 | ||
97 | char line[256]; | |
98 | do { | |
99 | padPos.getline(line,255); | |
100 | if (!padPos) break; | |
101 | ||
102 | #if defined (__HP_aCC) || (__alpha) | |
103 | strstream strline; | |
104 | strline << line; | |
105 | #else | |
106 | istringstream strline(line); | |
107 | #endif | |
108 | string key; | |
109 | ||
110 | strline>>key; | |
111 | if ((key=="#") || (key=="") ) continue; | |
112 | ||
113 | int i,j; | |
114 | strline>>i>>j; | |
115 | #ifdef WITH_STL | |
116 | positions[key].first=i; | |
117 | positions[key].second=j; | |
118 | #endif | |
119 | #ifdef WITH_ROOT | |
5006ec94 | 120 | positions.Add( AliMpExMap::GetIndex(key), |
121 | AliMpExMap::GetIndex(AliMpIntPair(i,j)) ); | |
197883c2 | 122 | #endif |
123 | } while (!padPos.eof()); | |
124 | ||
125 | padPos.close(); | |
126 | ||
127 | TString bergToGCFileName | |
d1c53ece | 128 | = AliMpFiles::BergToGCFilePath(fStationType); |
da3a1bb2 | 129 | AliDebugStream(2) << "Opening file " << bergToGCFileName << endl; |
197883c2 | 130 | |
131 | ifstream bergToGCFile(bergToGCFileName); | |
f29ba3e1 | 132 | const Int_t knbergpins = |
197883c2 | 133 | (fStationType == kStation1 || fStationType == kStation2 ) ? 80 : 100; |
134 | // Station1 & 2 Bergstak connectors have 80 pins, while for stations | |
135 | // 3, 4 and 5 they have 100 pins. | |
136 | Int_t gassiChannel[100]; | |
137 | while(1) { | |
138 | Int_t bergNum; | |
139 | TString gcStr; | |
140 | bergToGCFile>>bergNum>>gcStr; | |
141 | if (!bergToGCFile.good()) break; | |
142 | if (gcStr=="GND") continue; | |
f29ba3e1 | 143 | if (bergNum>knbergpins) { |
197883c2 | 144 | Fatal("BuildMotifType","Berg number > 80 ..."); |
145 | continue; | |
146 | } | |
147 | gassiChannel[bergNum-1]= atoi(gcStr); | |
148 | } | |
149 | bergToGCFile.close(); | |
150 | ||
d1c53ece | 151 | TString motifTypeFileName(AliMpFiles::MotifFilePath(fStationType, |
152 | fPlaneType, motifTypeId)); | |
197883c2 | 153 | ifstream motif(motifTypeFileName); |
da3a1bb2 | 154 | AliDebugStream(2) << "Opening file " << motifTypeFileName << endl; |
197883c2 | 155 | |
156 | Int_t nofPadsX=0; | |
157 | Int_t nofPadsY=0; | |
158 | ||
159 | do { | |
160 | ||
161 | Int_t ix,iy,numBerg,numKapton,padNum,gassiNum; | |
162 | ||
163 | TString lineStr,token; | |
164 | lineStr.ReadLine(motif); | |
165 | if (!motif.good()) break; | |
166 | #if defined (__HP_aCC) || (__alpha) | |
167 | strstream tokenList; | |
168 | tokenList << lineStr.Data(); | |
169 | #else | |
170 | istringstream tokenList(lineStr.Data()); | |
171 | #endif | |
172 | ||
173 | token.ReadToken(tokenList); | |
174 | if (!tokenList.good()) continue; // column is missing... | |
175 | if ( (token.Length()>0) && (token[0]=='#') ) continue; // this is a comment line | |
176 | ||
177 | numBerg = atoi(token.Data()); | |
178 | if (numBerg==0) { | |
179 | AliWarning(Form("Berg number %s invalid",token.Data())); | |
180 | continue; | |
181 | } | |
182 | ||
183 | token.ReadToken(tokenList); | |
184 | if (!tokenList.good()) continue; // column is missing... | |
185 | numKapton = atoi(token.Data()); | |
186 | if (numKapton==0) continue; | |
187 | ||
188 | ||
189 | token.ReadToken(tokenList); | |
190 | if (!tokenList.good()) continue; // column is missing... | |
191 | if (token=="GND") continue; | |
192 | string padName = token.Data(); | |
193 | padNum = motifType->PadNum(token); | |
194 | ||
195 | token.ReadToken(tokenList); | |
196 | if (token.IsNull() ) continue; // column is missing... | |
197 | // if (token[0]!='E') { | |
198 | // cerr<<"Problem : gassinumber isn't begining with E:"<<token<<endl; | |
199 | // continue; | |
200 | // } else { | |
201 | // gassiNum = atoi(token.Data() +1 )-1; | |
202 | // } | |
f29ba3e1 | 203 | if ( (numBerg<1) || (numBerg>knbergpins) ) { |
204 | AliWarning(Form("Berg number %d outside range (1..%d)",numBerg,knbergpins)); | |
197883c2 | 205 | continue; |
206 | } | |
207 | ||
208 | gassiNum = gassiChannel[numBerg-1]; | |
209 | ||
210 | #ifdef WITH_STL | |
211 | PadMapTypeIterator iter = positions.find(padName); | |
212 | if (iter==positions.end()) { | |
2c605e66 | 213 | AliWarningStream() |
214 | << "Problem: Pad number " << padNum | |
215 | << " found in the file " << motifTypeFileName | |
216 | << " but not in the file " << padPosFileName << endl; | |
197883c2 | 217 | continue; |
218 | } | |
219 | ||
220 | ix= iter->second.first; | |
221 | iy= iter->second.second; | |
222 | #endif | |
223 | ||
224 | #ifdef WITH_ROOT | |
5006ec94 | 225 | Long_t value = positions.GetValue(AliMpExMap::GetIndex(padName)); |
197883c2 | 226 | if (!value) { |
2c605e66 | 227 | AliWarningStream() |
228 | << "Problem: Pad number " << padNum | |
229 | << " found in the file " << motifTypeFileName | |
230 | << " but not in the file " << padPosFileName << endl; | |
197883c2 | 231 | continue; |
232 | } | |
233 | ||
5006ec94 | 234 | ix = AliMpExMap::GetPair(value).GetFirst(); |
235 | iy = AliMpExMap::GetPair(value).GetSecond(); | |
197883c2 | 236 | #endif |
237 | ||
238 | motifType->AddConnection(AliMpIntPair(ix,iy), | |
239 | new AliMpConnection(padNum,numBerg,numKapton,gassiNum)); | |
240 | ||
241 | if (ix>=nofPadsX) nofPadsX=ix+1; | |
242 | if (iy>=nofPadsY) nofPadsY=iy+1; | |
243 | ||
244 | } while (!motif.eof()); | |
245 | ||
246 | ||
247 | motifType->SetNofPads(nofPadsX, nofPadsY); | |
248 | ||
249 | motif.close(); | |
250 | ||
251 | return motifType; | |
252 | } | |
253 | ||
254 | ||
255 | //_____________________________________________________________________________ | |
256 | AliMpMotifSpecial* | |
257 | AliMpMotifReader::BuildMotifSpecial(const TString& motifID, | |
d1c53ece | 258 | AliMpMotifType* motifType, |
259 | Double_t scale) | |
197883c2 | 260 | { |
261 | /// Build a special motif by reading the file motifSpecial<motifId>.dat | |
262 | /// in the data directory | |
263 | ||
264 | // Open the input file | |
d1c53ece | 265 | TString motifSpecialFileName(AliMpFiles::MotifSpecialFilePath(fStationType, |
266 | fPlaneType, motifID)); | |
197883c2 | 267 | ifstream in(motifSpecialFileName); |
268 | if (!in) { | |
2c605e66 | 269 | AliErrorStream() |
270 | << "File " << motifSpecialFileName.Data() << " not found." << endl; | |
197883c2 | 271 | return 0; |
272 | } | |
273 | ||
274 | AliMpMotifSpecial* res = new AliMpMotifSpecial(motifID,motifType); | |
275 | Int_t i,j; | |
276 | Double_t x,y; | |
277 | in >> i; | |
278 | while (!in.eof()){ | |
279 | in >>j >>x >> y; | |
d1c53ece | 280 | res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x*scale/2.,y*scale/2.)); |
197883c2 | 281 | in >> i; |
282 | } | |
d7885370 | 283 | res->CalculateDimensions(); |
197883c2 | 284 | |
285 | in.close(); | |
286 | return res; | |
287 | } | |
288 |