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