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