]>
Commit | Line | Data |
---|---|---|
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 | #include "AliMUONSimpleClusterServer.h" | |
19 | ||
20 | #include "AliCodeTimer.h" | |
21 | #include "AliLog.h" | |
22 | #include "AliMUONCluster.h" | |
23 | #include "AliMUONConstants.h" | |
24 | #include "AliMUONGeometryTransformer.h" | |
25 | #include "AliMUONPad.h" | |
26 | #include "AliMUONTriggerTrackToTrackerClusters.h" | |
27 | #include "AliMUONVCluster.h" | |
28 | #include "AliMUONVClusterFinder.h" | |
29 | #include "AliMUONVClusterStore.h" | |
30 | #include "AliMUONVDigitStore.h" | |
31 | #include "AliMUONRecoParam.h" | |
32 | #include "AliMpArea.h" | |
33 | #include "AliMpDEIterator.h" | |
34 | #include "AliMpDEManager.h" | |
35 | #include "AliMpExMap.h" | |
36 | #include "AliMpPad.h" | |
37 | #include "AliMpSegmentation.h" | |
38 | #include "AliMpVSegmentation.h" | |
39 | #include <Riostream.h> | |
40 | #include <TClonesArray.h> | |
41 | #include <TString.h> | |
42 | #include <float.h> | |
43 | ||
44 | /// \class AliMUONSimpleClusterServer | |
45 | /// | |
46 | /// Implementation of AliMUONVClusterServer interface | |
47 | /// | |
48 | /// | |
49 | /// \author Laurent Aphecetche, Subatech | |
50 | ||
51 | /// \cond CLASSIMP | |
52 | ClassImp(AliMUONSimpleClusterServer) | |
53 | /// \endcond | |
54 | ||
55 | namespace | |
56 | { | |
57 | TString AsString(const AliMpArea& area) | |
58 | { | |
59 | return Form("(X,Y)=(%7.3f,%7.3f) (DX,DY)=(%7.3f,%7.3f)", | |
60 | area.Position().X(), | |
61 | area.Position().Y(), | |
62 | area.Dimensions().Y(), | |
63 | area.Dimensions().Y()); | |
64 | } | |
65 | } | |
66 | ||
67 | //_____________________________________________________________________________ | |
68 | AliMUONSimpleClusterServer::AliMUONSimpleClusterServer(AliMUONVClusterFinder* clusterFinder, | |
69 | const AliMUONGeometryTransformer& transformer) | |
70 | : AliMUONVClusterServer(), | |
71 | fClusterFinder(clusterFinder), | |
72 | fTransformer(transformer), | |
73 | fPads(), | |
74 | fTriggerTrackStore(0x0), | |
75 | fBypass(0x0) | |
76 | { | |
77 | /// Ctor | |
78 | /// Note that we take ownership of the clusterFinder | |
79 | ||
80 | fPads[0] = new AliMpExMap; | |
81 | fPads[1] = new AliMpExMap; | |
82 | ||
83 | } | |
84 | ||
85 | //_____________________________________________________________________________ | |
86 | AliMUONSimpleClusterServer::~AliMUONSimpleClusterServer() | |
87 | { | |
88 | /// Dtor | |
89 | delete fClusterFinder; | |
90 | delete fPads[0]; | |
91 | delete fPads[1]; | |
92 | delete fBypass; | |
93 | } | |
94 | ||
95 | //_____________________________________________________________________________ | |
96 | Int_t | |
97 | AliMUONSimpleClusterServer::Clusterize(Int_t chamberId, | |
98 | AliMUONVClusterStore& clusterStore, | |
99 | const AliMpArea& area, | |
100 | const AliMUONRecoParam* recoParam) | |
101 | { | |
102 | /// Area is in absolute coordinate. If not valid, means clusterize all | |
103 | /// the chamber. | |
104 | /// | |
105 | /// We first find out the list of DE that have a non-zero overlap with area, | |
106 | /// and then use the clusterfinder to find clusters in those areas (and DE). | |
107 | ||
108 | AliCodeTimerAuto(Form("Chamber %d",chamberId)); | |
109 | ||
110 | if ( fTriggerTrackStore && chamberId >= 6 ) | |
111 | { | |
112 | return fBypass->GenerateClusters(chamberId,clusterStore); | |
113 | } | |
114 | ||
115 | if (!recoParam) { | |
116 | AliError("Reconstruction parameters are missing: unable to clusterize"); | |
117 | return 0; | |
118 | } | |
119 | ||
120 | AliMpDEIterator it; | |
121 | ||
122 | it.First(chamberId); | |
123 | ||
124 | Int_t nofAddedClusters(0); | |
125 | Int_t fNCluster = clusterStore.GetSize(); | |
126 | ||
127 | AliDebug(1,Form("chamberId = %2d NofClusters before = %d searchArea=%s", | |
128 | chamberId,fNCluster,AsString(area).Data())); | |
129 | ||
130 | while ( !it.IsDone() ) | |
131 | { | |
132 | Int_t detElemId = it.CurrentDEId(); | |
133 | ||
134 | TClonesArray* pads[2] = | |
135 | { | |
136 | static_cast<TClonesArray*>(fPads[0]->GetValue(detElemId)), | |
137 | static_cast<TClonesArray*>(fPads[1]->GetValue(detElemId)) | |
138 | }; | |
139 | ||
140 | if ( ( pads[0] && pads[0]->GetLast()>=0 ) || | |
141 | ( pads[1] && pads[1]->GetLast()>=0 ) ) | |
142 | { | |
143 | AliMpArea deArea; // area in DE-local-coordinates | |
144 | Bool_t ok(kTRUE); | |
145 | ||
146 | if ( area.IsValid() ) | |
147 | { | |
148 | ok = Overlap(detElemId,area,deArea); | |
149 | } | |
150 | ||
151 | if ( ok ) | |
152 | { | |
153 | if ( fClusterFinder->NeedSegmentation() ) | |
154 | { | |
155 | const AliMpVSegmentation* seg[2] = | |
156 | { AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath0), | |
157 | AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath1) | |
158 | }; | |
159 | fClusterFinder->Prepare(detElemId,pads,deArea,seg); | |
160 | } | |
161 | else | |
162 | { | |
163 | fClusterFinder->Prepare(detElemId,pads,deArea); | |
164 | } | |
165 | ||
166 | AliDebug(1,Form("Clusterizing DE %04d with %3d pads (cath0) and %3d pads (cath1)", | |
167 | detElemId, | |
168 | (pads[0] ? pads[0]->GetLast()+1 : 0), | |
169 | (pads[1] ? pads[1]->GetLast()+1 : 0))); | |
170 | ||
171 | AliMUONCluster* cluster; | |
172 | ||
173 | while ( ( cluster = fClusterFinder->NextCluster() ) ) | |
174 | { | |
175 | // add new cluster to the store with information to build its ID | |
176 | // increment the number of clusters into the store | |
177 | AliMUONVCluster* rawCluster = clusterStore.Add(chamberId, detElemId, fNCluster++); | |
178 | ||
179 | ++nofAddedClusters; | |
180 | ||
181 | // fill array of Id of digits attached to this cluster | |
182 | Int_t nPad = cluster->Multiplicity(); | |
183 | if (nPad < 1) AliWarning("no pad attached to the cluster"); | |
184 | ||
185 | for (Int_t iPad=0; iPad<nPad; iPad++) | |
186 | { | |
187 | AliMUONPad *pad = cluster->Pad(iPad); | |
188 | ||
189 | // skip virtual pads | |
190 | if (!pad->IsReal()) continue; | |
191 | ||
192 | rawCluster->AddDigitId(pad->GetUniqueID()); | |
193 | } | |
194 | ||
195 | // fill charge and other cluster informations | |
196 | rawCluster->SetCharge(cluster->Charge()); | |
197 | rawCluster->SetChi2(cluster->Chi2()); | |
198 | ||
199 | Double_t xg, yg, zg; | |
200 | fTransformer.Local2Global(detElemId, | |
201 | cluster->Position().X(), cluster->Position().Y(), | |
202 | 0, xg, yg, zg); | |
203 | rawCluster->SetXYZ(xg, yg, zg); | |
204 | rawCluster->SetErrXY(recoParam->GetDefaultNonBendingReso(chamberId),recoParam->GetDefaultBendingReso(chamberId)); | |
205 | ||
206 | AliDebug(1,Form("Adding RawCluster detElemId %4d mult %2d charge %e (xl,yl,zl)=(%e,%e,%e) (xg,yg,zg)=(%e,%e,%e)", | |
207 | detElemId,rawCluster->GetNDigits(),rawCluster->GetCharge(), | |
208 | cluster->Position().X(),cluster->Position().Y(),0.0, | |
209 | xg,yg,zg)); | |
210 | } | |
211 | } | |
212 | } | |
213 | it.Next(); | |
214 | } | |
215 | ||
216 | AliDebug(1,Form("chamberId = %2d NofClusters after = %d",chamberId,fNCluster)); | |
217 | ||
218 | return nofAddedClusters; | |
219 | } | |
220 | ||
221 | ||
222 | //_____________________________________________________________________________ | |
223 | void | |
224 | AliMUONSimpleClusterServer::Global2Local(Int_t detElemId, const AliMpArea& globalArea, | |
225 | AliMpArea& localArea) const | |
226 | { | |
227 | /// Convert a global area in local area for a given DE | |
228 | ||
229 | Double_t xl,yl,zl; | |
230 | ||
231 | Double_t zg = AliMUONConstants::DefaultChamberZ(AliMpDEManager::GetChamberId(detElemId)); | |
232 | ||
233 | fTransformer.Global2Local(detElemId, | |
234 | globalArea.Position().X(),globalArea.Position().Y(),zg, | |
235 | xl,yl,zl); | |
236 | ||
237 | localArea = AliMpArea(TVector2(xl,yl), globalArea.Dimensions()); | |
238 | } | |
239 | ||
240 | //_____________________________________________________________________________ | |
241 | Bool_t | |
242 | AliMUONSimpleClusterServer::Overlap(Int_t detElemId, | |
243 | const AliMpArea& area, | |
244 | AliMpArea& deArea) const | |
245 | { | |
246 | /// Check whether (global) area overlaps with the given DE. | |
247 | /// If it is, set deArea to the overlap region and convert it | |
248 | /// in the local coordinate system of that DE. | |
249 | ||
250 | Bool_t overlap(kFALSE); | |
251 | ||
252 | AliMpArea* globalDEArea = fTransformer.GetDEArea(detElemId); | |
253 | ||
254 | if (!globalDEArea) return kFALSE; | |
255 | ||
256 | AliMpArea overlapArea; | |
257 | ||
258 | if ( area.Overlap(*globalDEArea) ) | |
259 | { | |
260 | overlapArea = area.Intersect(*globalDEArea); | |
261 | Global2Local(detElemId,overlapArea,deArea); | |
262 | overlap = kTRUE; | |
263 | } | |
264 | else | |
265 | { | |
266 | deArea = AliMpArea(); | |
267 | } | |
268 | ||
269 | AliDebug(1,Form("DE %04d area %s globalDEArea %s overlapArea %s deArea %s overlap=%d", | |
270 | detElemId, | |
271 | AsString(area).Data(), | |
272 | AsString(*globalDEArea).Data(), | |
273 | AsString(overlapArea).Data(), | |
274 | AsString(deArea).Data(), | |
275 | overlap)); | |
276 | ||
277 | return overlap; | |
278 | } | |
279 | ||
280 | //_____________________________________________________________________________ | |
281 | TClonesArray* | |
282 | AliMUONSimpleClusterServer::PadArray(Int_t detElemId, Int_t cathode) const | |
283 | { | |
284 | /// Return array for given cathode of given DE | |
285 | ||
286 | return static_cast<TClonesArray*>(fPads[cathode]->GetValue(detElemId)); | |
287 | } | |
288 | ||
289 | //_____________________________________________________________________________ | |
290 | Bool_t | |
291 | AliMUONSimpleClusterServer::UseTriggerTrackStore(AliMUONVTriggerTrackStore* trackStore) | |
292 | { | |
293 | /// Tells us to use trigger track store, and thus to bypass St45 clusters | |
294 | fTriggerTrackStore = trackStore; // not owner | |
295 | delete fBypass; | |
296 | fBypass = new AliMUONTriggerTrackToTrackerClusters(fTransformer,fTriggerTrackStore); | |
297 | return kTRUE; | |
298 | } | |
299 | ||
300 | //_____________________________________________________________________________ | |
301 | void | |
302 | AliMUONSimpleClusterServer::UseDigits(TIter& next) | |
303 | { | |
304 | /// Convert digitStore into two arrays of AliMUONPads | |
305 | ||
306 | fPads[0]->Clear(); | |
307 | fPads[1]->Clear(); | |
308 | ||
309 | AliMUONVDigit* d; | |
310 | while ( ( d = static_cast<AliMUONVDigit*>(next()) ) ) | |
311 | { | |
312 | if ( ! d->Charge() > 0 ) continue; // skip void digits. | |
313 | Int_t ix = d->PadX(); | |
314 | Int_t iy = d->PadY(); | |
315 | Int_t cathode = d->Cathode(); | |
316 | Int_t detElemId = d->DetElemId(); | |
317 | const AliMpVSegmentation* seg = AliMpSegmentation::Instance()-> | |
318 | GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode)); | |
319 | AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy)); | |
320 | ||
321 | TClonesArray* padArray = PadArray(detElemId,cathode); | |
322 | if (!padArray) | |
323 | { | |
324 | padArray = new TClonesArray("AliMUONPad",100); | |
325 | fPads[cathode]->Add(detElemId,padArray); | |
326 | } | |
327 | ||
328 | AliMUONPad mpad(detElemId,cathode, | |
329 | ix,iy,pad.Position().X(),pad.Position().Y(), | |
330 | pad.Dimensions().X(),pad.Dimensions().Y(), | |
331 | d->Charge()); | |
332 | if ( d->IsSaturated() ) mpad.SetSaturated(kTRUE); | |
333 | mpad.SetUniqueID(d->GetUniqueID()); | |
334 | new ((*padArray)[padArray->GetLast()+1]) AliMUONPad(mpad); | |
335 | } | |
336 | } | |
337 | ||
338 | //_____________________________________________________________________________ | |
339 | void | |
340 | AliMUONSimpleClusterServer::Print(Option_t*) const | |
341 | { | |
342 | /// Printout for debug only | |
343 | ||
344 | AliMpDEIterator it; | |
345 | ||
346 | it.First(); | |
347 | ||
348 | while ( !it.IsDone() ) | |
349 | { | |
350 | Int_t detElemId = it.CurrentDEId(); | |
351 | ||
352 | // printout the number of pads / de, and number of used pads / de | |
353 | ||
354 | if ( ( PadArray(detElemId,0) && PadArray(detElemId,0)->GetLast() >= 0 ) || | |
355 | ( PadArray(detElemId,1) && PadArray(detElemId,1)->GetLast() >= 0 ) ) | |
356 | { | |
357 | cout << Form("---- DE %04d",detElemId) << endl; | |
358 | ||
359 | for ( Int_t cathode = 0; cathode < 2; ++cathode ) | |
360 | { | |
361 | cout << Form(" -- Cathode %1d",cathode) << endl; | |
362 | ||
363 | TClonesArray* padArray = PadArray(detElemId,cathode); | |
364 | ||
365 | if (!padArray) | |
366 | { | |
367 | cout << "no pad array" << endl; | |
368 | } | |
369 | else if ( padArray->GetLast() < 0 ) | |
370 | { | |
371 | cout << "no pads" << endl; | |
372 | } | |
373 | else | |
374 | { | |
375 | TIter next(padArray); | |
376 | AliMUONPad* pad; | |
377 | while ( ( pad = static_cast<AliMUONPad*>(next()) ) ) | |
378 | { | |
379 | pad->Print("full"); | |
380 | } | |
381 | } | |
382 | } | |
383 | } | |
384 | it.Next(); | |
385 | } | |
386 | } | |
387 | ||
388 |