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