]>
Commit | Line | Data |
---|---|---|
74f8c8e3 | 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$ */ | |
17 | //=========================================================== | |
18 | // Segmentation classes for MUON Detection Elements | |
19 | // Gines MARTINEZ, SUBATECH July 04 | |
20 | // This class interfaces with the mapping and segmentation | |
21 | // files MUON. | |
22 | // This files are placed by default in | |
23 | // $ALICE_ROOT/MUON/mapping/data/Stationxxx/yyy_plane/ | |
24 | // There are in tracking 23 types of detection elements | |
25 | // 8 SectorSt1, 8 SectorSt2, 2 122000SR1, 2 122000NR1, 4 112200SR2, 4 112200NR2 | |
26 | // 4 122200S, 4 122200N, 8 222000N,8 220000N, 8 330000N, 4 122300N, 8 112230NR3 | |
27 | // 8 112230N, 8 222330N, 8 223300N, 16 333000N, 4 122330N, 8 112233NR3, 8 112233N | |
28 | // 8 222333N, 8 223330N, 8 333300N | |
29 | // Detailed information in Alice Technical Note xxxxxxxx (2004) | |
30 | //=========================================================== | |
31 | ||
8fe7187d | 32 | #include <stdlib.h> |
74f8c8e3 | 33 | #include <Riostream.h> |
9d936539 | 34 | #include <stdlib.h> |
74f8c8e3 | 35 | |
36 | #include "TClonesArray.h" | |
37 | #include "TMap.h" | |
6b74910d | 38 | #include "TMath.h" |
74f8c8e3 | 39 | |
40 | #include "AliMUONSegmentationDetectionElement.h" | |
41 | #include "AliMUONSegmentManuIndex.h" | |
42 | #include "AliMUONSegmentPosition.h" | |
43 | #include "AliMUONSegmentIndex.h" | |
44 | ||
74f8c8e3 | 45 | //___________________________________________ |
46 | ClassImp(AliMUONSegmentationDetectionElement) | |
47 | ||
48 | //static data member | |
49 | const TString AliMUONSegmentationDetectionElement::fgkDefaultTop =getenv("ALICE_ROOT") ; | |
50 | const TString AliMUONSegmentationDetectionElement::fgkStationDir = "/MUON/mapping/data/station"; | |
51 | const TString AliMUONSegmentationDetectionElement::fgkBendingDir= "/bending_plane"; | |
52 | const TString AliMUONSegmentationDetectionElement::fgkNonBendingDir= "/non-bending_plane"; | |
53 | const TString AliMUONSegmentationDetectionElement::fgkFileExt = ".map"; | |
54 | const TString AliMUONSegmentationDetectionElement::fgkBendingExt = ".Bending"; | |
55 | const TString AliMUONSegmentationDetectionElement::fgkNonBendingExt = ".NonBending"; | |
56 | ||
57 | //___________________________________________ | |
58 | ||
59 | AliMUONSegmentationDetectionElement::AliMUONSegmentationDetectionElement() : TObject() | |
60 | { | |
212bb69d | 61 | //Default constructor |
6b74910d | 62 | fWireD = 0.25; // wire pitch in cm |
63 | fWireX0 = 0.; // X0 position of the 1st wire | |
74f8c8e3 | 64 | fMapManuIndexIndex= 0x0; |
65 | fMapIndexManuIndex= 0x0; | |
66 | fMapIndexPosition= 0x0; | |
212bb69d | 67 | fMapPositionIndex=0X0; |
74f8c8e3 | 68 | } |
69 | ||
70 | ||
71 | // AliMUONSegmentationDetectionElement::AliMUONSegmentationDetectionElement(const char* ElementType) | |
72 | // { | |
73 | ||
74 | // fMapManuIndexIndex= 0x0; | |
75 | // fMapIndexManuIndex= 0x0; | |
76 | // fMapIndexPosition= 0x0; | |
74f8c8e3 | 77 | // } |
78 | ||
79 | //________________________________________________ | |
80 | AliMUONSegmentationDetectionElement::AliMUONSegmentationDetectionElement(const AliMUONSegmentationDetectionElement& rhs): TObject(rhs) | |
81 | { | |
82 | // Protected copy constructor | |
83 | ||
84 | Fatal("AliMUONSegmentationDetectionElementModule", "Not implemented."); | |
85 | } | |
86 | //_________________________________________________ | |
87 | AliMUONSegmentationDetectionElement::~AliMUONSegmentationDetectionElement(){ | |
212bb69d | 88 | //Class destructor |
74f8c8e3 | 89 | fListOfIndexes->Delete(); |
90 | fListOfManuIndexes->Delete(); | |
91 | fListOfPositions->Delete(); | |
92 | fMapManuIndexIndex->Clear(); | |
93 | fMapIndexManuIndex->Clear(); | |
94 | fMapIndexPosition->Clear(); | |
212bb69d | 95 | fMapPositionIndex->Clear(); |
96 | } | |
97 | ||
6b74910d | 98 | //__________________________________________________ |
99 | AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::FindIndexFromPosition(Float_t x, Float_t y, Int_t cathode) | |
100 | { | |
101 | // Finding x_wire corresponding to x | |
102 | Float_t x_wire = GetAnod(x); | |
103 | ||
104 | //Finding pad corresponding to the position (x_wire, y) in a zone of size 3cm x 10cm or 10cm x 3cm depending on cathode plane | |
105 | // | |
106 | Int_t ix_max = (cathode==0) ? TMath::Nint(5./AliMUONSegmentPosition::GetUnit()) : TMath::Nint(1.5/AliMUONSegmentPosition::GetUnit()); | |
107 | Int_t iy_max = (cathode==0) ? TMath::Nint(1.5/AliMUONSegmentPosition::GetUnit()) : TMath::Nint(5./AliMUONSegmentPosition::GetUnit()); | |
108 | ||
109 | AliMUONSegmentIndex * segmentindex =0x0; | |
110 | AliMUONSegmentIndex * foundsegmentindex =0x0; | |
111 | AliMUONSegmentPosition * segmentposition=0x0; | |
112 | Int_t ix, iy; | |
113 | Float_t xt,yt; | |
114 | Float_t distance = 99999999.; | |
115 | //printf("%d %d \n",ix_max, iy_max); | |
116 | ||
117 | for(ix=-ix_max; ix<ix_max; ix++) { | |
118 | xt = x_wire + ((Float_t)ix)*AliMUONSegmentPosition::GetUnit(); | |
119 | for(iy=-iy_max; iy<iy_max; iy++) { | |
120 | yt = y + ((Float_t)iy)*AliMUONSegmentPosition::GetUnit(); | |
121 | segmentindex = GetIndexFromPosition( xt, yt, cathode); | |
122 | if ( segmentindex ) { | |
66657aef | 123 | // segmentindex->Print(); |
6b74910d | 124 | segmentposition = GetPosition(segmentindex->GetName()); |
125 | if ( segmentposition->Distance(x_wire, y) < distance ) { | |
126 | //printf("adfafa xt %f yt %f distance %f \n", xt, yt, segmentposition->Distance(xt,yt) ); | |
127 | distance = segmentposition->Distance(x_wire,y); | |
128 | foundsegmentindex = segmentindex; | |
129 | } | |
130 | } | |
131 | } | |
132 | } | |
133 | if (!foundsegmentindex) { | |
134 | Warning("FindIndexFromPosition","Not found Index for position x=%5.2f y=%5.2f \n",x,y); | |
135 | } | |
136 | return foundsegmentindex; | |
137 | } | |
138 | ||
139 | //____________________________________________________- | |
140 | Float_t AliMUONSegmentationDetectionElement::GetAnod(Float_t xhit) const | |
141 | { | |
142 | // Returns for a hit position xhit the position of the nearest anode wire | |
143 | Float_t wire= ( (xhit- fWireX0)>0 ) ? | |
144 | Int_t( (xhit- fWireX0)/fWireD )+0.5 : | |
145 | Int_t( (xhit- fWireX0)/fWireD )-0.5; | |
146 | return fWireD*wire+fWireX0; | |
147 | } | |
212bb69d | 148 | //_________________________________________________ |
149 | AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndex(Int_t manu, Int_t channel) const | |
150 | { | |
151 | // Getting AliMUONSegmentIndex from ManuIndex | |
152 | return GetIndex( AliMUONSegmentManuIndex::Name(manu, channel).Data() ) ; | |
74f8c8e3 | 153 | } |
154 | //_________________________________________________ | |
212bb69d | 155 | AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndex( const char * SegmentManuIndexName) const |
74f8c8e3 | 156 | { |
212bb69d | 157 | // Getting AliMUONSegmentIndex from name of AliMUONSegmentManuIndex |
74f8c8e3 | 158 | if (fMapManuIndexIndex) return (AliMUONSegmentIndex*) fMapManuIndexIndex->GetValue(SegmentManuIndexName); |
159 | else { | |
160 | Warning("GetIndex","SegmentManuIndex %s out of DetectionElement Mapping %s", | |
161 | SegmentManuIndexName,fDetectionElementType.Data()); | |
162 | return 0x0; | |
163 | } | |
164 | } | |
74f8c8e3 | 165 | //_________________________________________________ |
212bb69d | 166 | AliMUONSegmentManuIndex * AliMUONSegmentationDetectionElement::GetManuIndex(Int_t padx, Int_t pady, Int_t cathode ) const |
167 | { | |
168 | // Getting ManuIndex from Index | |
169 | return GetManuIndex( AliMUONSegmentIndex::Name(padx, pady, cathode).Data() ); | |
170 | } | |
171 | //_________________________________________________ | |
172 | AliMUONSegmentManuIndex * AliMUONSegmentationDetectionElement::GetManuIndex( const char * SegmentIndexName) const | |
74f8c8e3 | 173 | { |
212bb69d | 174 | // Getting ManuIndex from manuname |
74f8c8e3 | 175 | if (fMapIndexManuIndex) return (AliMUONSegmentManuIndex*) fMapIndexManuIndex->GetValue(SegmentIndexName); |
176 | else { | |
177 | Warning("GetManuIndex","SegmentIndex %s out of Detection Element mapping %s", | |
178 | SegmentIndexName,fDetectionElementType.Data()); | |
179 | return 0x0; | |
180 | } | |
181 | } | |
6b74910d | 182 | //__________________________________________________ |
183 | void AliMUONSegmentationDetectionElement::GetPadC(Int_t ix, Int_t iy, Int_t cathode, Float_t &x, Float_t &y ) | |
184 | { | |
185 | x = GetPosition(ix,iy,cathode)->GetXlocal(); | |
186 | y = GetPosition(ix,iy,cathode)->GetYlocal(); | |
187 | } | |
188 | //__________________________________________________ | |
189 | void AliMUONSegmentationDetectionElement::GetPadI(Float_t x, Float_t y, Int_t cathode, Int_t &padx, Int_t &pady) | |
190 | { | |
191 | ||
192 | AliMUONSegmentIndex * segmentindex = FindIndexFromPosition(x,y,cathode); | |
193 | ||
194 | if (segmentindex) { | |
195 | padx = segmentindex->GetPadX(); | |
66657aef | 196 | pady = segmentindex->GetPadY(); |
6b74910d | 197 | } |
198 | else { | |
199 | Warning("GetPadI","Not found Index for position x=%5.2f y=%5.2f \n",x,y); | |
200 | } | |
201 | } | |
74f8c8e3 | 202 | //_________________________________________________ |
212bb69d | 203 | AliMUONSegmentPosition * AliMUONSegmentationDetectionElement::GetPosition(Int_t padx, Int_t pady, Int_t cathode ) const |
204 | { | |
205 | //Getting position from index | |
206 | return GetPosition( AliMUONSegmentIndex::Name(padx, pady, cathode).Data() ); | |
207 | } | |
208 | //_________________________________________________ | |
209 | AliMUONSegmentPosition * AliMUONSegmentationDetectionElement::GetPosition( const char * SegmentIndexName) const | |
74f8c8e3 | 210 | { |
212bb69d | 211 | // Getting position from indexname |
74f8c8e3 | 212 | if (fMapIndexPosition) return (AliMUONSegmentPosition*) fMapIndexPosition->GetValue(SegmentIndexName); |
213 | else { | |
214 | Warning("GetPosition","SegmentIndex %s out of DetectionElement mapping %s", | |
215 | SegmentIndexName, fDetectionElementType.Data()); | |
216 | return 0x0; | |
217 | } | |
218 | } | |
212bb69d | 219 | //_________________________________________________ |
220 | AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndexFromPosition(Float_t x, Float_t y, Int_t cathode) const | |
221 | { | |
222 | // Getting Index from position if position is a center pad position | |
6b74910d | 223 | return GetIndexFromPosition( AliMUONSegmentPosition::Name(x, y, cathode).Data() ); |
212bb69d | 224 | } |
225 | //_________________________________________________ | |
226 | AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndexFromPosition( const char * PositionName) const | |
227 | { | |
228 | // Getting index form positionname | |
229 | if (fMapPositionIndex) return (AliMUONSegmentIndex*) fMapPositionIndex->GetValue(PositionName); | |
230 | else { | |
231 | Warning("GetIndexFromPosition","SegmentPosition %s out of DetectionElement Mapping %s", | |
232 | PositionName,fDetectionElementType.Data()); | |
233 | return 0x0; | |
234 | } | |
235 | } | |
74f8c8e3 | 236 | |
237 | //_________________________________________________ | |
212bb69d | 238 | AliMUONSegmentManuIndex * AliMUONSegmentationDetectionElement::FindManuIndex( const char* ManuIndexName)const |
74f8c8e3 | 239 | { |
212bb69d | 240 | // Getting AliMUONSegmentManuIndex objecto from manu index |
74f8c8e3 | 241 | if (fMapManuIndexIndex) return (AliMUONSegmentManuIndex*) fMapManuIndexIndex->FindObject(ManuIndexName); |
242 | else { | |
243 | Warning("FindManuIndex","SegmentManuIndex %s out of DetectionElement mapping %s", | |
244 | ManuIndexName,fDetectionElementType.Data()); | |
245 | return 0x0; | |
246 | } | |
247 | } | |
248 | ||
249 | //_________________________________________________ | |
212bb69d | 250 | AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::FindIndex(const char* IndexName) const |
74f8c8e3 | 251 | { |
212bb69d | 252 | // Getting |
253 | if (fMapIndexPosition) return (AliMUONSegmentIndex *) fMapIndexPosition->FindObject(IndexName); | |
74f8c8e3 | 254 | else { |
255 | Warning("FindIndex","SegmentIndex %s out of DetectionElement mapping %s", | |
256 | IndexName,fDetectionElementType.Data()); | |
257 | return 0x0; | |
258 | } | |
259 | } | |
212bb69d | 260 | //_________________________________________________ |
74f8c8e3 | 261 | void AliMUONSegmentationDetectionElement::Init(const char * DetectionElementType) |
262 | { | |
212bb69d | 263 | TString elementType(DetectionElementType); |
264 | fSegmentationMappingFileBending = fgkDefaultTop+fgkStationDir+"345" | |
265 | +fgkBendingDir+"/"+elementType+fgkBendingExt+fgkFileExt; | |
212bb69d | 266 | fSegmentationMappingFileNonBending = fgkDefaultTop+fgkStationDir+"345" |
267 | +fgkNonBendingDir+"/"+elementType+fgkNonBendingExt+fgkFileExt; | |
74f8c8e3 | 268 | |
269 | if (fMapManuIndexIndex==0x0) { | |
212bb69d | 270 | fListOfIndexes = new TObjArray(15000); |
271 | fListOfManuIndexes =new TObjArray(15000); | |
272 | fListOfPositions =new TObjArray(15000); | |
74f8c8e3 | 273 | fMapManuIndexIndex= new TMap(); |
274 | fMapIndexManuIndex = new TMap(); | |
275 | fMapIndexPosition = new TMap(); | |
212bb69d | 276 | fMapPositionIndex = new TMap(); |
74f8c8e3 | 277 | } |
278 | else { | |
279 | fListOfIndexes->Delete(); | |
280 | fListOfManuIndexes->Delete(); | |
281 | fListOfPositions->Delete(); | |
282 | fMapManuIndexIndex->Clear(); | |
283 | fMapIndexManuIndex->Clear(); | |
284 | fMapIndexPosition->Clear(); | |
212bb69d | 285 | fMapPositionIndex->Clear(); |
74f8c8e3 | 286 | } |
74f8c8e3 | 287 | Int_t icathode; |
288 | //Bendingplane | |
289 | icathode=0; | |
6b74910d | 290 | Info("ReadingSegmentationMappingFile","%s", fSegmentationMappingFileBending.Data()); |
212bb69d | 291 | ReadingSegmentationMappingFile(fSegmentationMappingFileBending ,icathode); |
74f8c8e3 | 292 | //NonBendingplane |
293 | icathode=1; | |
6b74910d | 294 | Info("Init","Reading mapping file is %s\n", fSegmentationMappingFileNonBending.Data()); |
212bb69d | 295 | ReadingSegmentationMappingFile(fSegmentationMappingFileNonBending,icathode); |
74f8c8e3 | 296 | |
297 | } | |
298 | //_______________________________________________________________ | |
299 | void AliMUONSegmentationDetectionElement::ReadingSegmentationMappingFile(TString infile, Int_t cathode) | |
300 | { | |
301 | ifstream in( infile, ios::in); | |
302 | if (!in) { | |
6b74910d | 303 | Error("ReadingSegmentationMappingFile", "File not found."); |
74f8c8e3 | 304 | } |
305 | else { | |
306 | Int_t id, ix, iy, idmanu, idchannel; | |
307 | Float_t x, y; | |
6b74910d | 308 | do { |
74f8c8e3 | 309 | in >> id >> ix >> iy >> x >> y >> idmanu >> idchannel; |
6b74910d | 310 | // printf("id=%d ix=%d iy=%d x=%f y=%f idmanu=%d and idchannel=%d\n",id, ix, iy, x, y,idmanu, idchannel); |
74f8c8e3 | 311 | |
312 | fListOfIndexes->AddAt( new AliMUONSegmentIndex(id,ix,iy,cathode), id); | |
313 | fListOfManuIndexes->AddAt( new AliMUONSegmentManuIndex(id,idmanu,0,idchannel), id);; | |
314 | fListOfPositions->AddAt( new AliMUONSegmentPosition(id, x, y,cathode), id);; | |
315 | ||
6b74910d | 316 | //( (AliMUONSegmentIndex* )fListOfIndexes->At(id))->Print(); |
317 | //( (AliMUONSegmentManuIndex*)fListOfManuIndexes->At(id))->Print(); | |
318 | //( (AliMUONSegmentPosition*)fListOfPositions->At(id))->Print(); | |
74f8c8e3 | 319 | |
320 | fMapManuIndexIndex->Add( fListOfManuIndexes->At(id), fListOfIndexes->At(id)); | |
321 | fMapIndexManuIndex->Add( fListOfIndexes->At(id), fListOfManuIndexes->At(id)); | |
322 | fMapIndexPosition->Add( fListOfIndexes->At(id), fListOfPositions->At(id)); | |
6b74910d | 323 | fMapPositionIndex->Add( fListOfPositions->At(id), fListOfIndexes->At(id) ); |
324 | } | |
325 | while ( !in.eof()); | |
74f8c8e3 | 326 | } |
327 | in.close(); | |
328 | } |