4c039060 |
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 | **************************************************************************/ |
4c039060 |
15 | /* |
16 | $Log$ |
e4fa3d7e |
17 | Revision 1.34 2000/10/18 11:42:06 morsch |
18 | - AliMUONRawCluster contains z-position. |
19 | - Some clean-up of useless print statements during initialisations. |
20 | |
3e1872ed |
21 | Revision 1.33 2000/10/09 14:01:57 morsch |
22 | Unused variables removed. |
23 | |
0234695f |
24 | Revision 1.32 2000/10/06 09:08:10 morsch |
25 | Built geometry includes slat geometry for event display. |
26 | |
7ab910ae |
27 | Revision 1.31 2000/10/02 21:28:08 fca |
28 | Removal of useless dependecies via forward declarations |
29 | |
94de3818 |
30 | Revision 1.30 2000/10/02 16:58:29 egangler |
31 | Cleaning of the code : |
32 | -> coding conventions |
33 | -> void Streamers |
34 | -> some useless includes removed or replaced by "class" statement |
35 | |
ecfa008b |
36 | Revision 1.29 2000/07/28 13:49:38 morsch |
37 | SetAcceptance defines inner and outer chamber radii according to angular acceptance. |
38 | Can be used for simple acceptance studies. |
39 | |
5c1f55c5 |
40 | Revision 1.28 2000/07/22 16:43:15 morsch |
41 | Same comment as before, but now done correctly I hope (sorry it's Saturday evening) |
42 | |
45085cb9 |
43 | Revision 1.27 2000/07/22 16:36:50 morsch |
44 | Change order of indices in creation (new) of xhit and yhit |
45 | |
6b18d06a |
46 | Revision 1.26 2000/07/03 11:54:57 morsch |
47 | AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER |
48 | The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC. |
49 | |
a30a000f |
50 | Revision 1.25 2000/06/29 12:34:09 morsch |
51 | AliMUONSegmentation class has been made independent of AliMUONChamber. This makes |
52 | it usable with any other geometry class. The link to the object to which it belongs is |
53 | established via an index. This assumes that there exists a global geometry manager |
54 | from which the pointer to the parent object can be obtained (in our case gAlice). |
55 | |
d81db581 |
56 | Revision 1.24 2000/06/28 15:16:35 morsch |
57 | (1) Client code adapted to new method signatures in AliMUONSegmentation (see comments there) |
58 | to allow development of slat-muon chamber simulation and reconstruction code in the MUON |
59 | framework. The changes should have no side effects (mostly dummy arguments). |
60 | (2) Hit disintegration uses 3-dim hit coordinates to allow simulation |
61 | of chambers with overlapping modules (MakePadHits, Disintegration). |
62 | |
802a864d |
63 | Revision 1.23 2000/06/28 12:19:17 morsch |
64 | More consequent seperation of global input data services (AliMUONClusterInput singleton) and the |
65 | cluster and hit reconstruction algorithms in AliMUONClusterFinderVS. |
66 | AliMUONClusterFinderVS becomes the base class for clustering and hit reconstruction. |
67 | It requires two cathode planes. Small modifications in the code will make it usable for |
68 | one cathode plane and, hence, more general (for test beam data). |
69 | AliMUONClusterFinder is now obsolete. |
70 | |
30aaba74 |
71 | Revision 1.22 2000/06/28 08:06:10 morsch |
72 | Avoid global variables in AliMUONClusterFinderVS by seperating the input data for the fit from the |
73 | algorithmic part of the class. Input data resides inside the AliMUONClusterInput singleton. |
74 | It also naturally takes care of the TMinuit instance. |
75 | |
9825400f |
76 | Revision 1.21 2000/06/27 08:54:41 morsch |
77 | Problems with on constant array sizes (in hitMap, nmuon, xhit, yhit) corrected. |
78 | |
d09fafb0 |
79 | Revision 1.20 2000/06/26 14:02:38 morsch |
80 | Add class AliMUONConstants with MUON specific constants using static memeber data and access methods. |
81 | |
f665c1ea |
82 | Revision 1.19 2000/06/22 13:40:51 morsch |
83 | scope problem on HP, "i" declared once |
84 | pow changed to TMath::Power (PH, AM) |
85 | |
9ae15266 |
86 | Revision 1.18 2000/06/15 07:58:48 morsch |
87 | Code from MUON-dev joined |
88 | |
a9e2aefa |
89 | Revision 1.14.4.17 2000/06/14 14:36:46 morsch |
90 | - add TriggerCircuit (PC) |
91 | - add GlobalTrigger and LocalTrigger and specific methods (PC) |
92 | |
93 | Revision 1.14.4.16 2000/06/09 21:20:28 morsch |
94 | Most coding rule violations corrected |
95 | |
96 | Revision 1.14.4.15 2000/05/02 09:54:32 morsch |
97 | RULE RN17 violations corrected |
98 | |
99 | Revision 1.14.4.12 2000/04/26 12:25:02 morsch |
100 | Code revised by P. Crochet: |
101 | - Z position of TriggerChamber changed according to A.Tournaire Priv.Comm. |
102 | - ToF included in the method MakePadHits |
103 | - inner radius of flange between beam shielding and trigger corrected |
104 | - Trigger global volume updated (according to the new geometry) |
105 | |
106 | Revision 1.14.4.11 2000/04/19 19:42:08 morsch |
107 | Some changes of variable names curing viols and methods concerning |
108 | correlated clusters removed. |
109 | |
110 | Revision 1.14.4.10 2000/03/22 16:44:07 gosset |
111 | Memory leak suppressed in function Digitise: |
112 | p_adr->Delete() instead of Clear (I.Chevrot and A.Baldisseri) |
113 | |
114 | Revision 1.14.4.9 2000/03/20 18:15:25 morsch |
115 | Positions of trigger chambers corrected (P.C.) |
dbe37a89 |
116 | |
a9e2aefa |
117 | Revision 1.14.4.8 2000/02/21 15:38:01 morsch |
118 | Call to AddHitList introduced to make this version compatible with head. |
dffd31ef |
119 | |
a9e2aefa |
120 | Revision 1.14.4.7 2000/02/20 07:45:53 morsch |
121 | Bugs in Trigger part of BuildGeomemetry corrected (P.C) |
1cedd08a |
122 | |
a9e2aefa |
123 | Revision 1.14.4.6 2000/02/17 14:28:54 morsch |
124 | Trigger included into initialization and digitization |
6a935c13 |
125 | |
a9e2aefa |
126 | Revision 1.14.4.5 2000/02/15 10:02:58 morsch |
127 | Log messages of previous revisions added |
5d84196c |
128 | |
a9e2aefa |
129 | Revision 1.14.4.2 2000/02/04 10:57:34 gosset |
130 | Z position of the chambers: |
131 | it was the Z position of the stations; |
132 | it is now really the Z position of the chambers. |
133 | !!!! WARNING: THE CALLS TO "AliMUONChamber::SetZPOS" |
134 | !!!! AND "AliMUONChamber::ZPosition" |
135 | !!!! HAVE TO BE CHANGED TO "AliMUONChamber::"SetZ" |
136 | !!!! AND "AliMUONChamber::Z" |
50f986db |
137 | |
a9e2aefa |
138 | Revision 1.14.4.3 2000/02/04 16:19:04 gosset |
139 | Correction for mis-spelling of NCH |
0b34885d |
140 | |
a9e2aefa |
141 | Revision 1.14.4.4 2000/02/15 09:43:38 morsch |
142 | Log message added |
2b86633d |
143 | |
4c039060 |
144 | */ |
145 | |
a9e2aefa |
146 | |
147 | /////////////////////////////////////////////// |
fe4da5cc |
148 | // Manager and hits classes for set:MUON // |
149 | //////////////////////////////////////////////// |
150 | |
151 | #include <TTUBE.h> |
a897a37a |
152 | #include <TBRIK.h> |
153 | #include <TRotMatrix.h> |
94de3818 |
154 | #include <TGeometry.h> |
fe4da5cc |
155 | #include <TNode.h> |
a897a37a |
156 | #include <TTree.h> |
fe4da5cc |
157 | #include <TRandom.h> |
158 | #include <TObject.h> |
159 | #include <TVector.h> |
160 | #include <TObjArray.h> |
a897a37a |
161 | #include <TMinuit.h> |
162 | #include <TParticle.h> |
163 | #include <TROOT.h> |
164 | #include <TFile.h> |
165 | #include <TNtuple.h> |
166 | #include <TCanvas.h> |
167 | #include <TPad.h> |
168 | #include <TDirectory.h> |
169 | #include <TObjectTable.h> |
170 | #include <AliPDG.h> |
a9e2aefa |
171 | #include <TTUBE.h> |
fe4da5cc |
172 | |
173 | #include "AliMUON.h" |
a9e2aefa |
174 | #include "AliMUONHit.h" |
175 | #include "AliMUONPadHit.h" |
176 | #include "AliMUONDigit.h" |
177 | #include "AliMUONTransientDigit.h" |
178 | #include "AliMUONRawCluster.h" |
179 | #include "AliMUONLocalTrigger.h" |
180 | #include "AliMUONGlobalTrigger.h" |
ecfa008b |
181 | #include "AliMUONTriggerCircuit.h" |
a30a000f |
182 | #include "AliHitMap.h" |
a9e2aefa |
183 | #include "AliMUONHitMapA1.h" |
184 | #include "AliMUONChamberTrigger.h" |
f665c1ea |
185 | #include "AliMUONConstants.h" |
30aaba74 |
186 | #include "AliMUONClusterFinderVS.h" |
a9e2aefa |
187 | #include "AliMUONTriggerDecision.h" |
fe4da5cc |
188 | #include "AliRun.h" |
189 | #include "AliMC.h" |
9825400f |
190 | #include "AliMUONClusterInput.h" |
fe4da5cc |
191 | #include "iostream.h" |
192 | #include "AliCallf77.h" |
a9e2aefa |
193 | #include "AliConst.h" |
194 | |
195 | // Defaults parameters for Z positions of chambers |
196 | // taken from values for "stations" in AliMUON::AliMUON |
197 | // const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.}; |
198 | // and from array "dstation" in AliMUONv1::CreateGeometry |
199 | // Float_t dstation[5]={20., 20., 20, 20., 20.}; |
200 | // for tracking chambers, |
201 | // according to (Z1 = zch - dstation) and (Z2 = zch + dstation) |
202 | // for the first and second chambers in the station, respectively, |
203 | // and from "DTPLANES" in AliMUONv1::CreateGeometry |
204 | // const Float_t DTPLANES = 15.; |
205 | // for trigger chambers, |
206 | // according to (Z1 = zch) and (Z2 = zch + DTPLANES) |
207 | // for the first and second chambers in the station, respectively |
fe4da5cc |
208 | |
fe4da5cc |
209 | ClassImp(AliMUON) |
fe4da5cc |
210 | //___________________________________________ |
211 | AliMUON::AliMUON() |
212 | { |
a9e2aefa |
213 | fIshunt = 0; |
214 | fHits = 0; |
215 | fPadHits = 0; |
216 | fNPadHits = 0; |
217 | fDchambers = 0; |
218 | fTriggerCircuits = 0; // cp new design of AliMUONTriggerDecision |
219 | fNdch = 0; |
220 | fRawClusters = 0; |
221 | fNrawch = 0; |
222 | fGlobalTrigger = 0; |
223 | fNLocalTrigger = 0; |
224 | fLocalTrigger = 0; |
225 | fNLocalTrigger = 0; |
5c1f55c5 |
226 | fAccMin = 0.; |
227 | fAccMax = 0.; |
228 | fAccCut = kFALSE; |
fe4da5cc |
229 | } |
230 | |
231 | //___________________________________________ |
232 | AliMUON::AliMUON(const char *name, const char *title) |
233 | : AliDetector(name,title) |
234 | { |
235 | //Begin_Html |
236 | /* |
a897a37a |
237 | <img src="gif/alimuon.gif"> |
fe4da5cc |
238 | */ |
239 | //End_Html |
f665c1ea |
240 | |
a9e2aefa |
241 | fHits = new TClonesArray("AliMUONHit",1000); |
1cedd08a |
242 | gAlice->AddHitList(fHits); |
a9e2aefa |
243 | fPadHits = new TClonesArray("AliMUONPadHit",10000); |
244 | fNPadHits = 0; |
fe4da5cc |
245 | fIshunt = 0; |
246 | |
f665c1ea |
247 | fNdch = new Int_t[AliMUONConstants::NCh()]; |
fe4da5cc |
248 | |
f665c1ea |
249 | fDchambers = new TObjArray(AliMUONConstants::NCh()); |
fe4da5cc |
250 | |
251 | Int_t i; |
252 | |
f665c1ea |
253 | for (i=0; i<AliMUONConstants::NCh() ;i++) { |
a9e2aefa |
254 | (*fDchambers)[i] = new TClonesArray("AliMUONDigit",10000); |
fe4da5cc |
255 | fNdch[i]=0; |
256 | } |
257 | |
f665c1ea |
258 | fNrawch = new Int_t[AliMUONConstants::NTrackingCh()]; |
a897a37a |
259 | |
f665c1ea |
260 | fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh()); |
a897a37a |
261 | |
f665c1ea |
262 | for (i=0; i<AliMUONConstants::NTrackingCh();i++) { |
a897a37a |
263 | (*fRawClusters)[i] = new TClonesArray("AliMUONRawCluster",10000); |
264 | fNrawch[i]=0; |
265 | } |
266 | |
a9e2aefa |
267 | fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1); |
268 | fNGlobalTrigger = 0; |
269 | fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234); |
270 | fNLocalTrigger = 0; |
fe4da5cc |
271 | |
fe4da5cc |
272 | SetMarkerColor(kRed); |
a9e2aefa |
273 | // |
274 | // |
275 | // |
276 | // |
f665c1ea |
277 | |
a9e2aefa |
278 | Int_t ch; |
279 | |
f665c1ea |
280 | fChambers = new TObjArray(AliMUONConstants::NCh()); |
a9e2aefa |
281 | |
282 | // Loop over stations |
f665c1ea |
283 | for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) { |
a9e2aefa |
284 | // Loop over 2 chambers in the station |
285 | for (Int_t stCH = 0; stCH < 2; stCH++) { |
286 | // |
287 | // |
288 | // Default Parameters for Muon Tracking Stations |
289 | |
290 | |
291 | ch = 2 * st + stCH; |
292 | // |
f665c1ea |
293 | if (ch < AliMUONConstants::NTrackingCh()) { |
d81db581 |
294 | (*fChambers)[ch] = new AliMUONChamber(ch); |
a9e2aefa |
295 | } else { |
d81db581 |
296 | (*fChambers)[ch] = new AliMUONChamberTrigger(ch); |
a9e2aefa |
297 | } |
298 | |
299 | AliMUONChamber* chamber = (AliMUONChamber*) (*fChambers)[ch]; |
300 | |
301 | chamber->SetGid(0); |
302 | // Default values for Z of chambers |
f665c1ea |
303 | chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch)); |
a9e2aefa |
304 | // |
f665c1ea |
305 | chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch)); |
5c1f55c5 |
306 | // Set chamber inner and outer radius to default |
f665c1ea |
307 | chamber->SetRInner(AliMUONConstants::Dmin(st)/2); |
308 | chamber->SetROuter(AliMUONConstants::Dmax(st)/2); |
a9e2aefa |
309 | // |
310 | } // Chamber stCH (0, 1) in |
311 | } // Station st (0...) |
312 | fMaxStepGas=0.01; |
313 | fMaxStepAlu=0.1; |
314 | fMaxDestepGas=-1; |
315 | fMaxDestepAlu=-1; |
316 | // |
317 | fMaxIterPad = 0; |
318 | fCurIterPad = 0; |
5c1f55c5 |
319 | // |
320 | fAccMin = 0.; |
321 | fAccMax = 0.; |
322 | fAccCut = kFALSE; |
a9e2aefa |
323 | |
324 | // cp new design of AliMUONTriggerDecision |
f665c1ea |
325 | fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit()); |
326 | for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) { |
a9e2aefa |
327 | (*fTriggerCircuits)[circ] = new AliMUONTriggerCircuit(); |
328 | } |
329 | // cp new design of AliMUONTriggerDecision |
330 | |
fe4da5cc |
331 | } |
332 | |
333 | //___________________________________________ |
a9e2aefa |
334 | AliMUON::AliMUON(const AliMUON& rMUON) |
335 | { |
336 | // Dummy copy constructor |
337 | ; |
338 | |
339 | } |
340 | |
fe4da5cc |
341 | AliMUON::~AliMUON() |
342 | { |
a897a37a |
343 | printf("Calling AliMUON destructor !!!\n"); |
344 | |
f665c1ea |
345 | Int_t i; |
346 | fIshunt = 0; |
347 | delete fHits; |
348 | delete fPadHits; |
349 | |
350 | delete fGlobalTrigger; |
351 | fNGlobalTrigger = 0; |
352 | |
353 | delete fLocalTrigger; |
354 | fNLocalTrigger = 0; |
a897a37a |
355 | |
f665c1ea |
356 | for (i=0;i<AliMUONConstants::NCh();i++) { |
357 | delete (*fDchambers)[i]; |
358 | fNdch[i]=0; |
359 | } |
360 | delete fDchambers; |
361 | |
362 | for (i=0;i<AliMUONConstants::NTrackingCh();i++) { |
363 | delete (*fRawClusters)[i]; |
364 | fNrawch[i]=0; |
365 | } |
366 | delete fRawClusters; |
367 | |
368 | for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) { |
369 | delete (*fTriggerCircuits)[circ]; |
370 | } |
371 | delete fTriggerCircuits; |
fe4da5cc |
372 | } |
373 | |
374 | //___________________________________________ |
375 | void AliMUON::AddHit(Int_t track, Int_t *vol, Float_t *hits) |
376 | { |
377 | TClonesArray &lhits = *fHits; |
a9e2aefa |
378 | new(lhits[fNhits++]) AliMUONHit(fIshunt,track,vol,hits); |
fe4da5cc |
379 | } |
380 | //___________________________________________ |
a9e2aefa |
381 | void AliMUON::AddPadHit(Int_t *clhits) |
fe4da5cc |
382 | { |
a9e2aefa |
383 | TClonesArray &lclusters = *fPadHits; |
384 | new(lclusters[fNPadHits++]) AliMUONPadHit(clhits); |
fe4da5cc |
385 | } |
386 | //_____________________________________________________________________________ |
387 | void AliMUON::AddDigits(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits) |
388 | { |
389 | // |
390 | // Add a MUON digit to the list |
391 | // |
392 | |
393 | TClonesArray &ldigits = *((TClonesArray*)(*fDchambers)[id]); |
a9e2aefa |
394 | new(ldigits[fNdch[id]++]) AliMUONDigit(tracks,charges,digits); |
fe4da5cc |
395 | } |
396 | |
a897a37a |
397 | //_____________________________________________________________________________ |
398 | void AliMUON::AddRawCluster(Int_t id, const AliMUONRawCluster& c) |
399 | { |
400 | // |
401 | // Add a MUON digit to the list |
402 | // |
403 | |
404 | TClonesArray &lrawcl = *((TClonesArray*)(*fRawClusters)[id]); |
405 | new(lrawcl[fNrawch[id]++]) AliMUONRawCluster(c); |
406 | } |
a897a37a |
407 | |
a9e2aefa |
408 | //___________________________________________ |
409 | void AliMUON::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus, |
410 | Int_t *singleUndef, |
411 | Int_t *pairUnlike, Int_t *pairLike) |
412 | { |
413 | // add a MUON Global Trigger to the list (only one GlobalTrigger per event !) |
414 | TClonesArray &globalTrigger = *fGlobalTrigger; |
415 | new(globalTrigger[fNGlobalTrigger++]) |
416 | AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, |
417 | pairLike); |
418 | } |
419 | //___________________________________________ |
420 | void AliMUON::AddLocalTrigger(Int_t *localtr) |
421 | { |
422 | // add a MUON Local Trigger to the list |
423 | TClonesArray &localTrigger = *fLocalTrigger; |
424 | new(localTrigger[fNLocalTrigger++]) AliMUONLocalTrigger(localtr); |
a897a37a |
425 | } |
426 | |
fe4da5cc |
427 | //___________________________________________ |
428 | void AliMUON::BuildGeometry() |
429 | { |
a9e2aefa |
430 | TNode *node, *nodeF, *top, *nodeS; |
431 | const int kColorMUON = kBlue; |
7ab910ae |
432 | const int kColorMUON2 = kYellow; |
433 | const int kColorMUON3 = kBlue; |
a897a37a |
434 | // |
a9e2aefa |
435 | top=gAlice->GetGeometry()->GetNode("alice"); |
a897a37a |
436 | // MUON |
437 | // |
438 | // z-Positions of Chambers |
a9e2aefa |
439 | const Float_t kCz[7]={511., 686., 971., 1245., 1445., 1600, 1700.}; |
440 | // inner diameter (Xlenght for trigger chamber -> active area) |
441 | const Float_t kDmin[7]={ 35., 47., 67., 86., 100., 544., 544.}; |
442 | // outer diameter (Ylenght for trigger chamber -> active area) |
443 | const Float_t kDmax[7]={183., 245., 346., 520., 520., 612., 612.}; |
a897a37a |
444 | |
445 | TRotMatrix* rot000 = new TRotMatrix("Rot000"," ", 90, 0, 90, 90, 0, 0); |
446 | TRotMatrix* rot090 = new TRotMatrix("Rot090"," ", 90, 90, 90,180, 0, 0); |
447 | TRotMatrix* rot180 = new TRotMatrix("Rot180"," ", 90,180, 90,270, 0, 0); |
448 | TRotMatrix* rot270 = new TRotMatrix("Rot270"," ", 90,270, 90, 0, 0, 0); |
449 | |
a9e2aefa |
450 | Float_t rmin, rmax, dx, dy, dz, dr, xpos, ypos, zpos; |
451 | Float_t dzc1=4.; // tracking chambers |
452 | Float_t dzc2=15.; // trigger chambers |
453 | Float_t hole=102.; // x-y hole around beam pipe for trig. chambers |
454 | Float_t zscale; // scaling parameter trigger chambers |
455 | Float_t halfx, halfy; |
7ab910ae |
456 | char nameChamber[9], nameSense[9], nameFrame[9], nameNode[9]; |
a9e2aefa |
457 | char nameSense1[9], nameSense2[9]; |
458 | for (Int_t i=0; i<7; i++) { |
a897a37a |
459 | for (Int_t j=0; j<2; j++) { |
460 | Int_t id=2*i+j+1; |
a9e2aefa |
461 | if (i<5) { // tracking chambers |
462 | if (j==0) { |
463 | zpos=kCz[i]-dzc1; |
464 | } else { |
465 | zpos=kCz[i]+dzc1; |
466 | } |
a897a37a |
467 | } else { |
a9e2aefa |
468 | if (j==0) { |
469 | zpos=kCz[i]; |
470 | } else { |
471 | zpos=kCz[i]+dzc2; |
472 | } |
a897a37a |
473 | } |
a9e2aefa |
474 | sprintf(nameChamber,"C_MUON%d",id); |
475 | sprintf(nameSense,"S_MUON%d",id); |
476 | sprintf(nameSense1,"S1_MUON%d",id); |
477 | sprintf(nameSense2,"S2_MUON%d",id); |
478 | sprintf(nameFrame,"F_MUON%d",id); |
e4fa3d7e |
479 | if (i<2) { // tracking chambers |
a9e2aefa |
480 | rmin = kDmin[i]/2.-3; |
481 | rmax = kDmax[i]/2.+3; |
482 | new TTUBE(nameChamber,"Mother","void",rmin,rmax,0.25,1.); |
483 | rmin = kDmin[i]/2.; |
484 | rmax = kDmax[i]/2.; |
485 | new TTUBE(nameSense,"Sens. region","void",rmin,rmax,0.25, 1.); |
486 | dx=(rmax-rmin)/2; |
487 | dy=3.; |
488 | dz=0.25; |
489 | TBRIK* frMUON = new TBRIK(nameFrame,"Frame","void",dx,dy,dz); |
490 | top->cd(); |
491 | sprintf(nameNode,"MUON%d",100+id); |
492 | node = new TNode(nameNode,"ChamberNode",nameChamber,0,0,zpos,""); |
493 | node->SetLineColor(kColorMUON); |
494 | fNodes->Add(node); |
495 | node->cd(); |
496 | sprintf(nameNode,"MUON%d",200+id); |
497 | node = new TNode(nameNode,"Sens. Region Node",nameSense,0,0,0,""); |
498 | node->SetLineColor(kColorMUON); |
499 | node->cd(); |
500 | dr=dx+rmin; |
501 | sprintf(nameNode,"MUON%d",300+id); |
502 | nodeF = new TNode(nameNode,"Frame0",frMUON,dr, 0, 0,rot000,""); |
503 | nodeF->SetLineColor(kColorMUON); |
504 | node->cd(); |
505 | sprintf(nameNode,"MUON%d",400+id); |
506 | nodeF = new TNode(nameNode,"Frame1",frMUON,0 ,dr,0,rot090,""); |
507 | nodeF->SetLineColor(kColorMUON); |
508 | node->cd(); |
509 | sprintf(nameNode,"MUON%d",500+id); |
510 | nodeF = new TNode(nameNode,"Frame2",frMUON,-dr,0,0,rot180,""); |
511 | nodeF->SetLineColor(kColorMUON); |
512 | node ->cd(); |
513 | sprintf(nameNode,"MUON%d",600+id); |
514 | nodeF = new TNode(nameNode,"Frame3",frMUON,0,-dr,0,rot270,""); |
515 | nodeF->SetLineColor(kColorMUON); |
e4fa3d7e |
516 | } else if (i >= 2 || i <= 4) { |
517 | Int_t nslats; |
518 | Int_t npcb[7]={0, 0, 0, 0, 0, 0, 0}; |
519 | if (i==2) { |
520 | nslats = 4; |
521 | npcb[0] = 3; npcb[1] = 4; npcb[2] = 3; npcb[3] = 2; |
522 | } else if (i==3) { |
523 | nslats = 6; |
524 | npcb[0] = 4; npcb[1] = 5; npcb[2] = 5; npcb[3] = 4; |
525 | npcb[4] = 3; npcb[5] = 2; |
526 | } else { |
527 | nslats = 7; |
528 | npcb[0] = 7; npcb[1] = 7; npcb[2] = 6; npcb[3] = 6; |
529 | npcb[4] = 5; npcb[5] = 4; npcb[6] = 2; |
530 | } |
531 | |
7ab910ae |
532 | char nameSlat[9]; |
533 | |
534 | Float_t xpos=4.; |
535 | Float_t ypos1=-0.75+20.; |
536 | Float_t ypos2= 0.75-20.; |
e4fa3d7e |
537 | if (i!=2) { |
538 | ypos1=ypos2=0.; |
539 | } |
7ab910ae |
540 | |
541 | new TBRIK(nameChamber,"Mother","void",340,340,5.); |
542 | top->cd(); |
543 | sprintf(nameNode,"MUON%d",100+id); |
544 | node = new TNode(nameNode,"Chambernode",nameChamber,0,0,zpos,""); |
545 | node->SetLineColor(kBlack); |
546 | fNodes->Add(node); |
547 | TNode* nodeSlat; |
548 | Int_t color; |
549 | |
e4fa3d7e |
550 | for (Int_t j=0; j<nslats; j++) |
7ab910ae |
551 | { |
7ab910ae |
552 | sprintf(nameSlat,"SLAT%d",100*id+j); |
553 | new TBRIK(nameSlat,"Slat Module","void",20.*npcb[j],20.,0.25); |
554 | node->cd(); |
555 | xpos=20.*npcb[j]+4; |
556 | if (j==0) xpos+=30; |
557 | |
558 | color = TMath::Even(j) ? kColorMUON2 : kColorMUON3; |
559 | |
560 | sprintf(nameNode,"SLAT%d",100*id+j); |
561 | nodeSlat = |
562 | new TNode(nameNode,"Slat Module",nameSlat,xpos,ypos1,0,""); |
563 | nodeSlat->SetLineColor(color); |
564 | |
565 | node->cd(); |
566 | sprintf(nameNode,"SLAT%d",100*id+j+7); |
567 | nodeSlat = |
568 | new TNode(nameNode,"Slat Module",nameSlat,-xpos,ypos1,0,""); |
569 | nodeSlat->SetLineColor(color); |
570 | |
e4fa3d7e |
571 | if (i==2 || (i!=2 && j!=0)) { |
572 | |
573 | if (i==2) { |
574 | color = TMath::Even(j) ? kColorMUON3 : kColorMUON2; |
575 | } else { |
576 | color = TMath::Even(j) ? kColorMUON2 : kColorMUON3; |
577 | } |
578 | |
579 | |
580 | sprintf(nameNode,"SLAT%d",100*id+j+14); |
581 | nodeSlat = |
582 | new TNode(nameNode,"Slat Module",nameSlat,xpos,ypos2,0,""); |
583 | nodeSlat->SetLineColor(color); |
584 | |
585 | node->cd(); |
586 | sprintf(nameNode,"SLAT%d",100*id+j+21); |
587 | nodeSlat = |
588 | new TNode(nameNode,"Slat Module",nameSlat,-xpos,ypos2,0,""); |
589 | nodeSlat->SetLineColor(color); |
590 | } |
591 | |
7ab910ae |
592 | ypos1+=38.5; |
593 | ypos2-=38.5; |
594 | } |
595 | |
a9e2aefa |
596 | } else { |
597 | zscale=zpos/kCz[5]; |
598 | Float_t xsize=kDmin[i]*zscale; |
599 | Float_t ysize=kDmax[i]*zscale; |
600 | Float_t holeScaled=hole*zscale; |
601 | |
602 | halfx=xsize/2.+3.; |
603 | halfy=ysize/2.+3.; |
604 | new TBRIK(nameChamber,"Mother","void",halfx,halfy,0.25); |
605 | top->cd(); |
606 | sprintf(nameNode,"MUON%d",100+id); |
607 | node = new TNode(nameNode,"Chambernode",nameChamber,0,0,zpos,""); |
608 | node->SetLineColor(kColorMUON2); |
609 | fNodes->Add(node); |
610 | |
611 | // up/down of beam pipe |
612 | halfx=xsize/2.; |
613 | halfy=(ysize/2.-holeScaled/2.)/2.; |
614 | new TBRIK(nameSense,"Sens. region","void",halfx,halfy,0.25); |
615 | |
616 | node->cd(); |
617 | ypos=holeScaled/2.+((ysize/2.-holeScaled/2.)/2.); |
618 | sprintf(nameNode,"MUON%d",200+id); |
619 | nodeS = new TNode(nameNode,"Sens. Region Node",nameSense,0,ypos,0,""); |
620 | nodeS->SetLineColor(kColorMUON2); |
621 | |
622 | node->cd(); |
623 | ypos=-1.*ypos; |
624 | sprintf(nameNode,"MUON%d",300+id); |
625 | nodeS = new TNode(nameNode,"Sens. Region Node",nameSense,0,ypos,0,""); |
626 | nodeS->SetLineColor(kColorMUON2); |
627 | |
628 | // left/right of beam pipe |
629 | halfx=(xsize/2.-holeScaled/2.)/2.; |
630 | halfy=holeScaled/2.; |
631 | new TBRIK(nameSense1,"Sens. region","void",halfx,halfy,0.25); |
632 | |
633 | node->cd(); |
634 | xpos=holeScaled/2.+((xsize/2.-holeScaled/2.)/2.); |
635 | sprintf(nameNode,"MUON%d",400+id); |
636 | nodeS = new TNode(nameNode,"Sens. Region Node",nameSense1,xpos,0,0,""); |
637 | nodeS->SetLineColor(kColorMUON2); |
638 | |
639 | node->cd(); |
640 | xpos=-1.*xpos; |
641 | sprintf(nameNode,"MUON%d",500+id); |
642 | nodeS = new TNode(nameNode,"Sens. Region Node",nameSense1,xpos,0,0,""); |
643 | nodeS->SetLineColor(kColorMUON2); |
644 | |
645 | // missing corners |
646 | halfx=17.*zscale/2.; |
647 | halfy=halfx; |
648 | new TBRIK(nameSense2,"Sens. region","void",halfx,halfy,0.25); |
649 | |
650 | node->cd(); |
651 | xpos=holeScaled/2.-halfx; |
652 | ypos=xpos; |
653 | sprintf(nameNode,"MUON%d",600+id); |
654 | nodeS = new TNode(nameNode,"Sens. Region Node",nameSense2,xpos,ypos,0,""); |
655 | nodeS->SetLineColor(kColorMUON2); |
656 | |
657 | node->cd(); |
658 | ypos=-1.*xpos; |
659 | sprintf(nameNode,"MUON%d",700+id); |
660 | nodeS = new TNode(nameNode,"Sens. Region Node",nameSense2,xpos,ypos,0,""); |
661 | nodeS->SetLineColor(kColorMUON2); |
662 | |
663 | node->cd(); |
664 | xpos=-1.*xpos; |
665 | sprintf(nameNode,"MUON%d",800+id); |
666 | nodeS = new TNode(nameNode,"Sens. Region Node",nameSense2,xpos,ypos,0,""); |
667 | nodeS->SetLineColor(kColorMUON2); |
668 | |
669 | node->cd(); |
670 | ypos=-1.*xpos; |
671 | sprintf(nameNode,"MUON%d",900+id); |
672 | nodeS = new TNode(nameNode,"Sens. Region Node",nameSense2,xpos,ypos,0,""); |
673 | nodeS->SetLineColor(kColorMUON2); |
674 | } |
a897a37a |
675 | } |
676 | } |
fe4da5cc |
677 | } |
678 | |
a897a37a |
679 | |
fe4da5cc |
680 | //___________________________________________ |
681 | Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t ) |
682 | { |
683 | return 9999; |
684 | } |
685 | |
686 | //___________________________________________ |
687 | void AliMUON::MakeBranch(Option_t* option) |
688 | { |
f665c1ea |
689 | // Create Tree branches for the MUON. |
690 | const Int_t kBufferSize = 4000; |
691 | char branchname[30]; |
692 | sprintf(branchname,"%sCluster",GetName()); |
693 | |
694 | AliDetector::MakeBranch(option); |
695 | |
696 | if (fPadHits && gAlice->TreeH()) { |
697 | gAlice->TreeH()->Branch(branchname,&fPadHits, kBufferSize); |
698 | printf("Making Branch %s for clusters\n",branchname); |
699 | } |
700 | |
fe4da5cc |
701 | // one branch for digits per chamber |
f665c1ea |
702 | Int_t i; |
703 | |
704 | for (i=0; i<AliMUONConstants::NCh() ;i++) { |
705 | sprintf(branchname,"%sDigits%d",GetName(),i+1); |
706 | |
707 | if (fDchambers && gAlice->TreeD()) { |
708 | gAlice->TreeD()->Branch(branchname,&((*fDchambers)[i]), kBufferSize); |
709 | printf("Making Branch %s for digits in chamber %d\n",branchname,i+1); |
710 | } |
711 | } |
712 | |
713 | printf("Make Branch - TreeR address %p\n",gAlice->TreeR()); |
714 | |
a897a37a |
715 | // one branch for raw clusters per chamber |
f665c1ea |
716 | for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) { |
717 | sprintf(branchname,"%sRawClusters%d",GetName(),i+1); |
718 | |
719 | if (fRawClusters && gAlice->TreeR()) { |
720 | gAlice->TreeR()->Branch(branchname,&((*fRawClusters)[i]), kBufferSize); |
721 | printf("Making Branch %s for raw clusters in chamber %d\n",branchname,i+1); |
722 | } |
723 | } |
724 | |
a9e2aefa |
725 | // one branch for global trigger |
f665c1ea |
726 | sprintf(branchname,"%sGlobalTrigger",GetName()); |
727 | if (fGlobalTrigger && gAlice->TreeR()) { |
728 | gAlice->TreeR()->Branch(branchname,&fGlobalTrigger,kBufferSize); |
729 | printf("Making Branch %s for Global Trigger\n",branchname); |
730 | } |
a9e2aefa |
731 | // one branch for local trigger |
f665c1ea |
732 | sprintf(branchname,"%sLocalTrigger",GetName()); |
733 | if (fLocalTrigger && gAlice->TreeR()) { |
734 | gAlice->TreeR()->Branch(branchname,&fLocalTrigger,kBufferSize); |
735 | printf("Making Branch %s for Local Trigger\n",branchname); |
736 | } |
737 | |
fe4da5cc |
738 | } |
739 | |
740 | //___________________________________________ |
741 | void AliMUON::SetTreeAddress() |
742 | { |
743 | // Set branch address for the Hits and Digits Tree. |
a897a37a |
744 | char branchname[30]; |
fe4da5cc |
745 | AliDetector::SetTreeAddress(); |
746 | |
747 | TBranch *branch; |
748 | TTree *treeH = gAlice->TreeH(); |
749 | TTree *treeD = gAlice->TreeD(); |
a897a37a |
750 | TTree *treeR = gAlice->TreeR(); |
fe4da5cc |
751 | |
752 | if (treeH) { |
a9e2aefa |
753 | if (fPadHits) { |
fe4da5cc |
754 | branch = treeH->GetBranch("MUONCluster"); |
a9e2aefa |
755 | if (branch) branch->SetAddress(&fPadHits); |
fe4da5cc |
756 | } |
757 | } |
758 | |
759 | if (treeD) { |
f665c1ea |
760 | for (int i=0; i<AliMUONConstants::NCh(); i++) { |
fe4da5cc |
761 | sprintf(branchname,"%sDigits%d",GetName(),i+1); |
762 | if (fDchambers) { |
763 | branch = treeD->GetBranch(branchname); |
764 | if (branch) branch->SetAddress(&((*fDchambers)[i])); |
765 | } |
766 | } |
767 | } |
a897a37a |
768 | |
769 | // printf("SetTreeAddress --- treeR address %p \n",treeR); |
770 | |
771 | if (treeR) { |
f665c1ea |
772 | for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) { |
a897a37a |
773 | sprintf(branchname,"%sRawClusters%d",GetName(),i+1); |
774 | if (fRawClusters) { |
775 | branch = treeR->GetBranch(branchname); |
776 | if (branch) branch->SetAddress(&((*fRawClusters)[i])); |
777 | } |
778 | } |
a897a37a |
779 | |
a9e2aefa |
780 | if (fLocalTrigger) { |
781 | branch = treeR->GetBranch("MUONLocalTrigger"); |
782 | if (branch) branch->SetAddress(&fLocalTrigger); |
783 | } |
784 | if (fGlobalTrigger) { |
785 | branch = treeR->GetBranch("MUONGlobalTrigger"); |
786 | if (branch) branch->SetAddress(&fGlobalTrigger); |
787 | } |
788 | } |
fe4da5cc |
789 | } |
790 | //___________________________________________ |
791 | void AliMUON::ResetHits() |
792 | { |
793 | // Reset number of clusters and the cluster array for this detector |
794 | AliDetector::ResetHits(); |
a9e2aefa |
795 | fNPadHits = 0; |
796 | if (fPadHits) fPadHits->Clear(); |
fe4da5cc |
797 | } |
798 | |
799 | //____________________________________________ |
800 | void AliMUON::ResetDigits() |
801 | { |
802 | // |
803 | // Reset number of digits and the digits array for this detector |
804 | // |
f665c1ea |
805 | for ( int i=0;i<AliMUONConstants::NCh();i++ ) { |
a897a37a |
806 | if ((*fDchambers)[i]) ((TClonesArray*)(*fDchambers)[i])->Clear(); |
fe4da5cc |
807 | if (fNdch) fNdch[i]=0; |
808 | } |
809 | } |
810 | //____________________________________________ |
a897a37a |
811 | void AliMUON::ResetRawClusters() |
812 | { |
813 | // |
814 | // Reset number of raw clusters and the raw clust array for this detector |
815 | // |
f665c1ea |
816 | for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) { |
a897a37a |
817 | if ((*fRawClusters)[i]) ((TClonesArray*)(*fRawClusters)[i])->Clear(); |
818 | if (fNrawch) fNrawch[i]=0; |
819 | } |
820 | } |
a9e2aefa |
821 | |
a897a37a |
822 | //____________________________________________ |
a9e2aefa |
823 | void AliMUON::ResetTrigger() |
a897a37a |
824 | { |
a9e2aefa |
825 | // Reset Local and Global Trigger |
826 | fNGlobalTrigger = 0; |
827 | if (fGlobalTrigger) fGlobalTrigger->Clear(); |
828 | fNLocalTrigger = 0; |
829 | if (fLocalTrigger) fLocalTrigger->Clear(); |
830 | } |
831 | |
832 | //____________________________________________ |
833 | void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2) |
834 | { |
835 | Int_t i=2*(id-1); |
836 | ((AliMUONChamber*) (*fChambers)[i]) ->SetPadSize(isec,p1,p2); |
837 | ((AliMUONChamber*) (*fChambers)[i+1])->SetPadSize(isec,p1,p2); |
a897a37a |
838 | } |
839 | |
fe4da5cc |
840 | //___________________________________________ |
a9e2aefa |
841 | void AliMUON::SetChambersZ(const Float_t *Z) |
842 | { |
843 | // Set Z values for all chambers (tracking and trigger) |
844 | // from the array pointed to by "Z" |
f665c1ea |
845 | for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++) |
846 | ((AliMUONChamber*) ((*fChambers)[ch]))->SetZ(Z[ch]); |
847 | return; |
a9e2aefa |
848 | } |
fe4da5cc |
849 | |
a9e2aefa |
850 | //___________________________________________ |
851 | void AliMUON::SetChambersZToDefault() |
fe4da5cc |
852 | { |
a9e2aefa |
853 | // Set Z values for all chambers (tracking and trigger) |
854 | // to default values |
f665c1ea |
855 | SetChambersZ(AliMUONConstants::DefaultChamberZ()); |
a9e2aefa |
856 | return; |
fe4da5cc |
857 | } |
858 | |
859 | //___________________________________________ |
a897a37a |
860 | void AliMUON::SetChargeSlope(Int_t id, Float_t p1) |
fe4da5cc |
861 | { |
862 | Int_t i=2*(id-1); |
a9e2aefa |
863 | ((AliMUONChamber*) (*fChambers)[i])->SetChargeSlope(p1); |
864 | ((AliMUONChamber*) (*fChambers)[i+1])->SetChargeSlope(p1); |
fe4da5cc |
865 | } |
866 | |
867 | //___________________________________________ |
a897a37a |
868 | void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2) |
fe4da5cc |
869 | { |
870 | Int_t i=2*(id-1); |
a9e2aefa |
871 | ((AliMUONChamber*) (*fChambers)[i])->SetChargeSpread(p1,p2); |
872 | ((AliMUONChamber*) (*fChambers)[i+1])->SetChargeSpread(p1,p2); |
fe4da5cc |
873 | } |
874 | |
875 | //___________________________________________ |
a897a37a |
876 | void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1) |
fe4da5cc |
877 | { |
878 | Int_t i=2*(id-1); |
a9e2aefa |
879 | ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1); |
880 | ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1); |
fe4da5cc |
881 | } |
882 | |
883 | //___________________________________________ |
d09fafb0 |
884 | void AliMUON::SetMaxAdc(Int_t id, Int_t p1) |
fe4da5cc |
885 | { |
886 | Int_t i=2*(id-1); |
a9e2aefa |
887 | ((AliMUONChamber*) (*fChambers)[i])->SetMaxAdc(p1); |
888 | ((AliMUONChamber*) (*fChambers)[i+1])->SetMaxAdc(p1); |
fe4da5cc |
889 | } |
890 | |
891 | //___________________________________________ |
a897a37a |
892 | void AliMUON::SetMaxStepGas(Float_t p1) |
fe4da5cc |
893 | { |
894 | fMaxStepGas=p1; |
895 | } |
896 | |
897 | //___________________________________________ |
a897a37a |
898 | void AliMUON::SetMaxStepAlu(Float_t p1) |
fe4da5cc |
899 | { |
900 | fMaxStepAlu=p1; |
901 | } |
902 | |
903 | //___________________________________________ |
a897a37a |
904 | void AliMUON::SetMaxDestepGas(Float_t p1) |
fe4da5cc |
905 | { |
906 | fMaxDestepGas=p1; |
907 | } |
908 | |
909 | //___________________________________________ |
a897a37a |
910 | void AliMUON::SetMaxDestepAlu(Float_t p1) |
fe4da5cc |
911 | { |
912 | fMaxDestepAlu=p1; |
913 | } |
914 | //___________________________________________ |
5c1f55c5 |
915 | void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax) |
fe4da5cc |
916 | { |
917 | fAccCut=acc; |
5c1f55c5 |
918 | fAccMin=angmin*TMath::Pi()/180; |
919 | fAccMax=angmax*TMath::Pi()/180; |
920 | Int_t ch; |
921 | if (acc) { |
922 | for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) { |
923 | // Loop over 2 chambers in the station |
924 | for (Int_t stCH = 0; stCH < 2; stCH++) { |
925 | ch = 2 * st + stCH; |
926 | // Set chamber inner and outer radius according to acceptance cuts |
927 | Chamber(ch).SetRInner(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMin)); |
928 | Chamber(ch).SetROuter(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMax)); |
929 | } // chamber loop |
930 | } // station loop |
931 | } |
fe4da5cc |
932 | } |
933 | //___________________________________________ |
a30a000f |
934 | void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation) |
fe4da5cc |
935 | { |
a9e2aefa |
936 | ((AliMUONChamber*) (*fChambers)[id])->SetSegmentationModel(isec, segmentation); |
fe4da5cc |
937 | |
938 | } |
939 | //___________________________________________ |
a9e2aefa |
940 | void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response) |
fe4da5cc |
941 | { |
a9e2aefa |
942 | ((AliMUONChamber*) (*fChambers)[id])->SetResponseModel(response); |
fe4da5cc |
943 | } |
944 | |
30aaba74 |
945 | void AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst) |
a897a37a |
946 | { |
a9e2aefa |
947 | ((AliMUONChamber*) (*fChambers)[id])->SetReconstructionModel(reconst); |
a897a37a |
948 | } |
949 | |
fe4da5cc |
950 | void AliMUON::SetNsec(Int_t id, Int_t nsec) |
951 | { |
a9e2aefa |
952 | ((AliMUONChamber*) (*fChambers)[id])->SetNsec(nsec); |
fe4da5cc |
953 | } |
954 | |
955 | |
956 | //___________________________________________ |
957 | |
a897a37a |
958 | |
a9e2aefa |
959 | |
802a864d |
960 | void AliMUON::MakePadHits(Float_t xhit,Float_t yhit, Float_t zhit, |
a9e2aefa |
961 | Float_t eloss, Float_t tof, Int_t idvol) |
fe4da5cc |
962 | { |
963 | // |
a897a37a |
964 | // Calls the charge disintegration method of the current chamber and adds |
965 | // the simulated cluster to the root treee |
fe4da5cc |
966 | // |
a897a37a |
967 | Int_t clhits[7]; |
968 | Float_t newclust[6][500]; |
969 | Int_t nnew; |
970 | |
971 | |
fe4da5cc |
972 | // |
a897a37a |
973 | // Integrated pulse height on chamber |
974 | |
975 | |
976 | clhits[0]=fNhits+1; |
fe4da5cc |
977 | // |
a897a37a |
978 | // |
7ab910ae |
979 | // if (idvol == 6) printf("\n ->Disintegration %f %f %f", xhit, yhit, eloss ); |
980 | |
981 | |
a9e2aefa |
982 | ((AliMUONChamber*) (*fChambers)[idvol]) |
802a864d |
983 | ->DisIntegration(eloss, tof, xhit, yhit, zhit, nnew, newclust); |
a897a37a |
984 | Int_t ic=0; |
7ab910ae |
985 | // if (idvol == 6) printf("\n nnew %d \n", nnew); |
a897a37a |
986 | // |
987 | // Add new clusters |
988 | for (Int_t i=0; i<nnew; i++) { |
989 | if (Int_t(newclust[3][i]) > 0) { |
990 | ic++; |
991 | // Cathode plane |
992 | clhits[1] = Int_t(newclust[5][i]); |
993 | // Cluster Charge |
994 | clhits[2] = Int_t(newclust[0][i]); |
995 | // Pad: ix |
996 | clhits[3] = Int_t(newclust[1][i]); |
997 | // Pad: iy |
998 | clhits[4] = Int_t(newclust[2][i]); |
999 | // Pad: charge |
1000 | clhits[5] = Int_t(newclust[3][i]); |
1001 | // Pad: chamber sector |
1002 | clhits[6] = Int_t(newclust[4][i]); |
1003 | |
a9e2aefa |
1004 | AddPadHit(clhits); |
a897a37a |
1005 | } |
1006 | } |
a897a37a |
1007 | } |
1008 | |
a9e2aefa |
1009 | //---------------------------------------------------------------------- |
1010 | |
1011 | void AliMUON::Digitise(Int_t nev,Int_t bgrEvent,Option_t *option,Option_t *opt,Text_t *filename) |
a897a37a |
1012 | { |
1013 | // keep galice.root for signal and name differently the file for |
1014 | // background when add! otherwise the track info for signal will be lost ! |
1015 | |
a6f39961 |
1016 | static Bool_t first=kTRUE; |
a9e2aefa |
1017 | static TFile *file; |
1018 | char *addBackground = strstr(option,"Add"); |
a897a37a |
1019 | |
f665c1ea |
1020 | |
a30a000f |
1021 | AliMUONChamber* iChamber; |
1022 | AliSegmentation* segmentation; |
a897a37a |
1023 | |
1024 | |
1025 | Int_t trk[50]; |
1026 | Int_t chtrk[50]; |
1027 | TObjArray *list=new TObjArray; |
a9e2aefa |
1028 | static TClonesArray *pAddress=0; |
1029 | if(!pAddress) pAddress=new TClonesArray("TVector",1000); |
a897a37a |
1030 | Int_t digits[5]; |
1031 | |
a9e2aefa |
1032 | AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON"); |
a30a000f |
1033 | AliHitMap** hitMap= new AliHitMap* [AliMUONConstants::NCh()]; |
f665c1ea |
1034 | for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {hitMap[i]=0;} |
a9e2aefa |
1035 | if (addBackground ) { |
a897a37a |
1036 | if(first) { |
1037 | fFileName=filename; |
1038 | cout<<"filename"<<fFileName<<endl; |
a9e2aefa |
1039 | file=new TFile(fFileName); |
a897a37a |
1040 | cout<<"I have opened "<<fFileName<<" file "<<endl; |
a9e2aefa |
1041 | fHits2 = new TClonesArray("AliMUONHit",1000 ); |
1042 | fPadHits2 = new TClonesArray("AliMUONPadHit",10000); |
a897a37a |
1043 | } |
a6f39961 |
1044 | first=kFALSE; |
a9e2aefa |
1045 | file->cd(); |
1046 | //file->ls(); |
a897a37a |
1047 | // Get Hits Tree header from file |
1048 | if(fHits2) fHits2->Clear(); |
a9e2aefa |
1049 | if(fPadHits2) fPadHits2->Clear(); |
1050 | if(fTrH1) delete fTrH1; |
1051 | fTrH1=0; |
a897a37a |
1052 | |
1053 | char treeName[20]; |
a9e2aefa |
1054 | sprintf(treeName,"TreeH%d",bgrEvent); |
1055 | fTrH1 = (TTree*)gDirectory->Get(treeName); |
1056 | //printf("fTrH1 %p of treename %s for event %d \n",fTrH1,treeName,bgrEvent); |
a897a37a |
1057 | |
a9e2aefa |
1058 | if (!fTrH1) { |
1059 | printf("ERROR: cannot find Hits Tree for event:%d\n",bgrEvent); |
a897a37a |
1060 | } |
1061 | // Set branch addresses |
1062 | TBranch *branch; |
1063 | char branchname[20]; |
1064 | sprintf(branchname,"%s",GetName()); |
a9e2aefa |
1065 | if (fTrH1 && fHits2) { |
1066 | branch = fTrH1->GetBranch(branchname); |
a897a37a |
1067 | if (branch) branch->SetAddress(&fHits2); |
1068 | } |
a9e2aefa |
1069 | if (fTrH1 && fPadHits2) { |
1070 | branch = fTrH1->GetBranch("MUONCluster"); |
1071 | if (branch) branch->SetAddress(&fPadHits2); |
a897a37a |
1072 | } |
1073 | // test |
a9e2aefa |
1074 | //Int_t ntracks1 =(Int_t)fTrH1->GetEntries(); |
a897a37a |
1075 | //printf("background - ntracks1 - %d\n",ntracks1); |
1076 | } |
1077 | // |
1078 | // loop over cathodes |
1079 | // |
a30a000f |
1080 | AliHitMap* hm; |
a897a37a |
1081 | Int_t countadr=0; |
1082 | for (int icat=0; icat<2; icat++) { |
a897a37a |
1083 | Int_t counter=0; |
d09fafb0 |
1084 | Int_t * nmuon = new Int_t [AliMUONConstants::NCh()]; |
f665c1ea |
1085 | for (Int_t i =0; i<AliMUONConstants::NCh(); i++) { |
a9e2aefa |
1086 | iChamber=(AliMUONChamber*) (*fChambers)[i]; |
a897a37a |
1087 | if (iChamber->Nsec()==1 && icat==1) { |
fe4da5cc |
1088 | continue; |
a897a37a |
1089 | } else { |
a9e2aefa |
1090 | segmentation=iChamber->SegmentationModel(icat+1); |
fe4da5cc |
1091 | } |
a9e2aefa |
1092 | hitMap[i] = new AliMUONHitMapA1(segmentation, list); |
f665c1ea |
1093 | nmuon[i]=0; |
a897a37a |
1094 | } |
1095 | //printf("Start loop over tracks \n"); |
1096 | // |
1097 | // Loop over tracks |
1098 | // |
1099 | |
a9e2aefa |
1100 | TTree *treeH = gAlice->TreeH(); |
1101 | Int_t ntracks =(Int_t) treeH->GetEntries(); |
d09fafb0 |
1102 | Int_t jj; |
6b18d06a |
1103 | |
1104 | Float_t ** xhit = new Float_t * [AliMUONConstants::NCh()]; |
1105 | for (jj=0; jj<AliMUONConstants::NCh(); jj++) xhit[jj] = new Float_t[2]; |
45085cb9 |
1106 | Float_t ** yhit = new Float_t * [AliMUONConstants::NCh()]; |
6b18d06a |
1107 | for (jj=0; jj<AliMUONConstants::NCh(); jj++) yhit[jj] = new Float_t[2]; |
1108 | |
a897a37a |
1109 | for (Int_t track=0; track<ntracks; track++) { |
1110 | gAlice->ResetHits(); |
a9e2aefa |
1111 | treeH->GetEvent(track); |
a897a37a |
1112 | // |
1113 | // Loop over hits |
a9e2aefa |
1114 | for(AliMUONHit* mHit=(AliMUONHit*)pMUON->FirstHit(-1); |
a897a37a |
1115 | mHit; |
a9e2aefa |
1116 | mHit=(AliMUONHit*)pMUON->NextHit()) |
a897a37a |
1117 | { |
1118 | Int_t nch = mHit->fChamber-1; // chamber number |
f665c1ea |
1119 | if (nch > AliMUONConstants::NCh()-1) continue; |
7ab910ae |
1120 | // if (nch > 9) continue; |
a9e2aefa |
1121 | iChamber = &(pMUON->Chamber(nch)); |
a897a37a |
1122 | // new 17.07.99 |
a9e2aefa |
1123 | if (addBackground) { |
1124 | |
1125 | if (mHit->fParticle == kMuonPlus |
1126 | || mHit->fParticle == kMuonMinus) { |
94de3818 |
1127 | xhit[nch][nmuon[nch]]=mHit->X(); |
1128 | yhit[nch][nmuon[nch]]=mHit->Y(); |
a9e2aefa |
1129 | nmuon[nch]++; |
1130 | if (nmuon[nch] >2) printf("nmuon %d\n",nmuon[nch]); |
1131 | } |
fe4da5cc |
1132 | } |
a9e2aefa |
1133 | |
a897a37a |
1134 | |
1135 | |
1136 | |
1137 | // |
1138 | // Loop over pad hits |
a9e2aefa |
1139 | for (AliMUONPadHit* mPad= |
1140 | (AliMUONPadHit*)pMUON->FirstPad(mHit,fPadHits); |
a897a37a |
1141 | mPad; |
a9e2aefa |
1142 | mPad=(AliMUONPadHit*)pMUON->NextPad(fPadHits)) |
a897a37a |
1143 | { |
1144 | Int_t cathode = mPad->fCathode; // cathode number |
1145 | Int_t ipx = mPad->fPadX; // pad number on X |
1146 | Int_t ipy = mPad->fPadY; // pad number on Y |
a9e2aefa |
1147 | Int_t iqpad = Int_t(mPad->fQpad);// charge per pad |
7ab910ae |
1148 | // printf("\n Pad: %d %d %d %d", ipx, ipy, cathode,nch); |
a897a37a |
1149 | // |
1150 | // |
1151 | |
1152 | if (cathode != (icat+1)) continue; |
1153 | // fill the info array |
7ab910ae |
1154 | // Float_t thex, they, thez; |
a9e2aefa |
1155 | segmentation=iChamber->SegmentationModel(cathode); |
7ab910ae |
1156 | // segmentation->GetPadC(ipx,ipy,thex,they,thez); |
a9e2aefa |
1157 | // Float_t rpad=TMath::Sqrt(thex*thex+they*they); |
1158 | // if (rpad < rmin || iqpad ==0 || rpad > rmax) continue; |
a897a37a |
1159 | |
a9e2aefa |
1160 | new((*pAddress)[countadr++]) TVector(2); |
1161 | TVector &trinfo=*((TVector*) (*pAddress)[countadr-1]); |
a897a37a |
1162 | trinfo(0)=(Float_t)track; |
1163 | trinfo(1)=(Float_t)iqpad; |
1164 | |
1165 | digits[0]=ipx; |
1166 | digits[1]=ipy; |
1167 | digits[2]=iqpad; |
1168 | digits[3]=iqpad; |
a9e2aefa |
1169 | if (mHit->fParticle == kMuonPlus || |
1170 | mHit->fParticle == kMuonMinus) { |
1171 | digits[4]=mPad->fHitNumber; |
a897a37a |
1172 | } else digits[4]=-1; |
1173 | |
a9e2aefa |
1174 | AliMUONTransientDigit* pdigit; |
a897a37a |
1175 | // build the list of fired pads and update the info |
a9e2aefa |
1176 | if (!hitMap[nch]->TestHit(ipx, ipy)) { |
a897a37a |
1177 | |
1178 | list->AddAtAndExpand( |
a9e2aefa |
1179 | new AliMUONTransientDigit(nch,digits),counter); |
a897a37a |
1180 | |
a9e2aefa |
1181 | hitMap[nch]->SetHit(ipx, ipy, counter); |
a897a37a |
1182 | counter++; |
a9e2aefa |
1183 | pdigit=(AliMUONTransientDigit*)list->At(list->GetLast()); |
a897a37a |
1184 | // list of tracks |
1185 | TObjArray *trlist=(TObjArray*)pdigit->TrackList(); |
1186 | trlist->Add(&trinfo); |
1187 | } else { |
a9e2aefa |
1188 | pdigit=(AliMUONTransientDigit*) hitMap[nch]->GetHit(ipx, ipy); |
a897a37a |
1189 | // update charge |
1190 | (*pdigit).fSignal+=iqpad; |
1191 | (*pdigit).fPhysics+=iqpad; |
1192 | // update list of tracks |
1193 | TObjArray* trlist=(TObjArray*)pdigit->TrackList(); |
a9e2aefa |
1194 | Int_t lastEntry=trlist->GetLast(); |
1195 | TVector *pTrack=(TVector*)trlist->At(lastEntry); |
1196 | TVector &ptrk=*pTrack; |
7ab910ae |
1197 | Int_t lastTrack = Int_t(ptrk(0)); |
1198 | Int_t lastCharge = Int_t(ptrk(1)); |
a9e2aefa |
1199 | if (lastTrack==track) { |
1200 | lastCharge+=iqpad; |
1201 | trlist->RemoveAt(lastEntry); |
1202 | trinfo(0)=lastTrack; |
1203 | trinfo(1)=lastCharge; |
1204 | trlist->AddAt(&trinfo,lastEntry); |
a897a37a |
1205 | } else { |
1206 | trlist->Add(&trinfo); |
1207 | } |
1208 | // check the track list |
1209 | Int_t nptracks=trlist->GetEntriesFast(); |
1210 | if (nptracks > 2) { |
1211 | for (Int_t tr=0;tr<nptracks;tr++) { |
a9e2aefa |
1212 | TVector *ppTrack=(TVector*)trlist->At(tr); |
1213 | TVector &pptrk=*ppTrack; |
7ab910ae |
1214 | trk[tr] = Int_t(pptrk(0)); |
1215 | chtrk[tr] = Int_t(pptrk(1)); |
a897a37a |
1216 | } |
1217 | } // end if nptracks |
1218 | } // end if pdigit |
1219 | } //end loop over clusters |
1220 | } // hit loop |
1221 | } // track loop |
a897a37a |
1222 | |
1223 | // open the file with background |
1224 | |
a9e2aefa |
1225 | if (addBackground) { |
1226 | ntracks =(Int_t)fTrH1->GetEntries(); |
a897a37a |
1227 | // |
1228 | // Loop over tracks |
1229 | // |
1230 | for (Int_t track=0; track<ntracks; track++) { |
1231 | |
1232 | if (fHits2) fHits2->Clear(); |
a9e2aefa |
1233 | if (fPadHits2) fPadHits2->Clear(); |
a897a37a |
1234 | |
a9e2aefa |
1235 | fTrH1->GetEvent(track); |
a897a37a |
1236 | // |
1237 | // Loop over hits |
a9e2aefa |
1238 | AliMUONHit* mHit; |
a897a37a |
1239 | for(int i=0;i<fHits2->GetEntriesFast();++i) |
a9e2aefa |
1240 | { |
1241 | mHit=(AliMUONHit*) (*fHits2)[i]; |
a897a37a |
1242 | Int_t nch = mHit->fChamber-1; // chamber number |
1243 | if (nch >9) continue; |
a9e2aefa |
1244 | iChamber = &(pMUON->Chamber(nch)); |
0234695f |
1245 | // Int_t rmin = (Int_t)iChamber->RInner(); |
1246 | // Int_t rmax = (Int_t)iChamber->ROuter(); |
94de3818 |
1247 | Float_t xbgr=mHit->X(); |
1248 | Float_t ybgr=mHit->Y(); |
a6f39961 |
1249 | Bool_t cond=kFALSE; |
a897a37a |
1250 | |
1251 | for (Int_t imuon =0; imuon < nmuon[nch]; imuon++) { |
1252 | Float_t dist= (xbgr-xhit[nch][imuon])*(xbgr-xhit[nch][imuon]) |
1253 | +(ybgr-yhit[nch][imuon])*(ybgr-yhit[nch][imuon]); |
a6f39961 |
1254 | if (dist<100) cond=kTRUE; |
a897a37a |
1255 | } |
1256 | if (!cond) continue; |
1257 | |
1258 | // |
1259 | // Loop over pad hits |
a9e2aefa |
1260 | for (AliMUONPadHit* mPad= |
1261 | (AliMUONPadHit*)pMUON->FirstPad(mHit,fPadHits2); |
a897a37a |
1262 | mPad; |
a9e2aefa |
1263 | mPad=(AliMUONPadHit*)pMUON->NextPad(fPadHits2)) |
a897a37a |
1264 | { |
a9e2aefa |
1265 | // mPad = (AliMUONPadHit*) (*fPadHits2)[j]; |
a897a37a |
1266 | Int_t cathode = mPad->fCathode; // cathode number |
1267 | Int_t ipx = mPad->fPadX; // pad number on X |
1268 | Int_t ipy = mPad->fPadY; // pad number on Y |
a9e2aefa |
1269 | Int_t iqpad = Int_t(mPad->fQpad);// charge per pad |
a897a37a |
1270 | |
1271 | if (cathode != (icat+1)) continue; |
7ab910ae |
1272 | printf("\n Pad: %d %d %d", ipx, ipy, cathode); |
1273 | |
1274 | // Float_t thex, they, thez; |
1275 | // segmentation=iChamber->SegmentationModel(cathode); |
1276 | // segmentation->GetPadC(ipx,ipy,thex,they,thez); |
1277 | // Float_t rpad=TMath::Sqrt(thex*thex+they*they); |
1278 | // if (rpad < rmin || iqpad ==0 || rpad > rmax) continue; |
a9e2aefa |
1279 | new((*pAddress)[countadr++]) TVector(2); |
1280 | TVector &trinfo=*((TVector*) (*pAddress)[countadr-1]); |
1281 | trinfo(0)=-1; // tag background |
1282 | trinfo(1)=-1; |
1283 | |
a897a37a |
1284 | digits[0]=ipx; |
1285 | digits[1]=ipy; |
1286 | digits[2]=iqpad; |
1287 | digits[3]=0; |
1288 | digits[4]=-1; |
a897a37a |
1289 | |
a9e2aefa |
1290 | AliMUONTransientDigit* pdigit; |
1291 | // build the list of fired pads and update the info |
1292 | if (!hitMap[nch]->TestHit(ipx, ipy)) { |
1293 | list->AddAtAndExpand(new AliMUONTransientDigit(nch,digits),counter); |
1294 | |
1295 | hitMap[nch]->SetHit(ipx, ipy, counter); |
a897a37a |
1296 | counter++; |
1297 | |
a9e2aefa |
1298 | pdigit=(AliMUONTransientDigit*)list->At(list->GetLast()); |
a897a37a |
1299 | // list of tracks |
a9e2aefa |
1300 | TObjArray *trlist=(TObjArray*)pdigit-> |
1301 | TrackList(); |
1302 | trlist->Add(&trinfo); |
a897a37a |
1303 | } else { |
a9e2aefa |
1304 | pdigit=(AliMUONTransientDigit*) hitMap[nch]->GetHit(ipx, ipy); |
a897a37a |
1305 | // update charge |
1306 | (*pdigit).fSignal+=iqpad; |
a9e2aefa |
1307 | |
a897a37a |
1308 | // update list of tracks |
a9e2aefa |
1309 | TObjArray* trlist=(TObjArray*)pdigit-> |
1310 | TrackList(); |
1311 | Int_t lastEntry=trlist->GetLast(); |
1312 | TVector *pTrack=(TVector*)trlist-> |
1313 | At(lastEntry); |
1314 | TVector &ptrk=*pTrack; |
1315 | Int_t lastTrack=Int_t(ptrk(0)); |
1316 | if (lastTrack==-1) { |
1317 | continue; |
1318 | } else { |
1319 | trlist->Add(&trinfo); |
1320 | } |
a897a37a |
1321 | // check the track list |
a9e2aefa |
1322 | Int_t nptracks=trlist->GetEntriesFast(); |
1323 | if (nptracks > 0) { |
1324 | for (Int_t tr=0;tr<nptracks;tr++) { |
1325 | TVector *ppTrack=(TVector*)trlist->At(tr); |
1326 | TVector &pptrk=*ppTrack; |
1327 | trk[tr]=Int_t(pptrk(0)); |
1328 | chtrk[tr]=Int_t(pptrk(1)); |
1329 | } |
1330 | } // end if nptracks |
a897a37a |
1331 | } // end if pdigit |
1332 | } //end loop over clusters |
1333 | } // hit loop |
1334 | } // track loop |
1335 | //Int_t nentr2=list->GetEntriesFast(); |
1336 | //printf(" \n counter2, nentr2 %d %d \n",counter,nentr2); |
1337 | TTree *fAli=gAlice->TreeK(); |
a9e2aefa |
1338 | TFile *file=NULL; |
a897a37a |
1339 | |
1340 | if (fAli) file =fAli->GetCurrentFile(); |
1341 | file->cd(); |
d09fafb0 |
1342 | } // if addBackground |
1343 | delete [] xhit; |
1344 | delete [] yhit; |
1345 | |
a897a37a |
1346 | Int_t tracks[10]; |
1347 | Int_t charges[10]; |
a897a37a |
1348 | Int_t nentries=list->GetEntriesFast(); |
a897a37a |
1349 | |
1350 | for (Int_t nent=0;nent<nentries;nent++) { |
a9e2aefa |
1351 | AliMUONTransientDigit *address=(AliMUONTransientDigit*)list->At(nent); |
a897a37a |
1352 | if (address==0) continue; |
1353 | Int_t ich=address->fChamber; |
1354 | Int_t q=address->fSignal; |
a9e2aefa |
1355 | iChamber=(AliMUONChamber*) (*fChambers)[ich]; |
1356 | // |
1357 | // Digit Response (noise, threshold, saturation, ...) |
1358 | // if (address->fPhysics !=0 ) address->fPhysics+=(Int_t)Noise; |
1359 | AliMUONResponse * response=iChamber->ResponseModel(); |
1360 | q=response->DigitResponse(q); |
1361 | |
1362 | if (!q) continue; |
1363 | |
a897a37a |
1364 | digits[0]=address->fPadX; |
1365 | digits[1]=address->fPadY; |
1366 | digits[2]=q; |
1367 | digits[3]=address->fPhysics; |
1368 | digits[4]=address->fHit; |
a897a37a |
1369 | |
1370 | TObjArray* trlist=(TObjArray*)address->TrackList(); |
1371 | Int_t nptracks=trlist->GetEntriesFast(); |
1372 | //printf("nptracks, trlist %d %p\n",nptracks,trlist); |
1373 | |
a9e2aefa |
1374 | // this was changed to accomodate the real number of tracks |
1375 | if (nptracks > 10) { |
1376 | cout<<"Attention - nptracks > 10 "<<nptracks<<endl; |
1377 | nptracks=10; |
1378 | } |
1379 | if (nptracks > 2) { |
1380 | printf("Attention - nptracks > 2 %d \n",nptracks); |
1381 | printf("cat,ich,ix,iy,q %d %d %d %d %d \n",icat,ich,digits[0],digits[1],q); |
1382 | } |
1383 | for (Int_t tr=0;tr<nptracks;tr++) { |
1384 | TVector *ppP=(TVector*)trlist->At(tr); |
1385 | if(!ppP ) printf("ppP - %p\n",ppP); |
1386 | TVector &pp =*ppP; |
1387 | tracks[tr]=Int_t(pp(0)); |
1388 | charges[tr]=Int_t(pp(1)); |
a897a37a |
1389 | //printf("tracks, charges - %d %d\n",tracks[tr],charges[tr]); |
a9e2aefa |
1390 | } //end loop over list of tracks for one pad |
a897a37a |
1391 | // Sort list of tracks according to charge |
a9e2aefa |
1392 | if (nptracks > 1) { |
1393 | SortTracks(tracks,charges,nptracks); |
1394 | } |
1395 | if (nptracks < 10 ) { |
1396 | for (Int_t i=nptracks; i<10; i++) { |
1397 | tracks[i]=0; |
1398 | charges[i]=0; |
a897a37a |
1399 | } |
a9e2aefa |
1400 | } |
1401 | |
a897a37a |
1402 | // fill digits |
a9e2aefa |
1403 | pMUON->AddDigits(ich,tracks,charges,digits); |
1404 | // delete trlist; |
a897a37a |
1405 | } |
1406 | //cout<<"I'm out of the loops for digitisation"<<endl; |
a9e2aefa |
1407 | // gAlice->GetEvent(nev); |
a897a37a |
1408 | gAlice->TreeD()->Fill(); |
a9e2aefa |
1409 | pMUON->ResetDigits(); |
a897a37a |
1410 | list->Delete(); |
d09fafb0 |
1411 | |
a9e2aefa |
1412 | |
f665c1ea |
1413 | for(Int_t ii=0;ii<AliMUONConstants::NCh();++ii) { |
a9e2aefa |
1414 | if (hitMap[ii]) { |
1415 | hm=hitMap[ii]; |
a897a37a |
1416 | delete hm; |
a9e2aefa |
1417 | hitMap[ii]=0; |
fe4da5cc |
1418 | } |
a897a37a |
1419 | } |
d09fafb0 |
1420 | delete [] nmuon; |
a897a37a |
1421 | } //end loop over cathodes |
d09fafb0 |
1422 | delete [] hitMap; |
a9e2aefa |
1423 | char hname[30]; |
1424 | sprintf(hname,"TreeD%d",nev); |
1425 | gAlice->TreeD()->Write(hname); |
1426 | // reset tree |
1427 | gAlice->TreeD()->Reset(); |
1428 | delete list; |
1429 | |
1430 | pAddress->Delete(); |
1431 | // gObjectTable->Print(); |
a897a37a |
1432 | } |
1433 | |
1434 | void AliMUON::SortTracks(Int_t *tracks,Int_t *charges,Int_t ntr) |
1435 | { |
1436 | // |
1437 | // Sort the list of tracks contributing to a given digit |
1438 | // Only the 3 most significant tracks are acctually sorted |
1439 | // |
1440 | |
1441 | // |
1442 | // Loop over signals, only 3 times |
1443 | // |
1444 | |
1445 | Int_t qmax; |
1446 | Int_t jmax; |
1447 | Int_t idx[3] = {-2,-2,-2}; |
1448 | Int_t jch[3] = {-2,-2,-2}; |
1449 | Int_t jtr[3] = {-2,-2,-2}; |
1450 | Int_t i,j,imax; |
1451 | |
1452 | if (ntr<3) imax=ntr; |
1453 | else imax=3; |
1454 | for(i=0;i<imax;i++){ |
1455 | qmax=0; |
1456 | jmax=0; |
1457 | |
1458 | for(j=0;j<ntr;j++){ |
1459 | |
1460 | if((i == 1 && j == idx[i-1]) |
1461 | ||(i == 2 && (j == idx[i-1] || j == idx[i-2]))) continue; |
1462 | |
1463 | if(charges[j] > qmax) { |
1464 | qmax = charges[j]; |
1465 | jmax=j; |
1466 | } |
1467 | } |
1468 | |
1469 | if(qmax > 0) { |
1470 | idx[i]=jmax; |
1471 | jch[i]=charges[jmax]; |
1472 | jtr[i]=tracks[jmax]; |
1473 | } |
1474 | |
1475 | } |
1476 | |
1477 | for(i=0;i<3;i++){ |
1478 | if (jtr[i] == -2) { |
1479 | charges[i]=0; |
1480 | tracks[i]=0; |
1481 | } else { |
1482 | charges[i]=jch[i]; |
1483 | tracks[i]=jtr[i]; |
1484 | } |
1485 | } |
1486 | |
fe4da5cc |
1487 | } |
1488 | |
a9e2aefa |
1489 | //___________________________________________ |
1490 | void AliMUON::Trigger(Int_t nev){ |
1491 | // call the Trigger Algorithm and fill TreeR |
1492 | |
1493 | Int_t singlePlus[3] = {0,0,0}; |
1494 | Int_t singleMinus[3] = {0,0,0}; |
1495 | Int_t singleUndef[3] = {0,0,0}; |
1496 | Int_t pairUnlike[3] = {0,0,0}; |
1497 | Int_t pairLike[3] = {0,0,0}; |
1498 | |
1499 | ResetTrigger(); |
a9e2aefa |
1500 | AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1); |
1501 | decision->Trigger(); |
1502 | decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef, |
1503 | pairUnlike, pairLike); |
1504 | // add a local trigger in the list |
1505 | AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike); |
9ae15266 |
1506 | Int_t i; |
a9e2aefa |
1507 | |
f665c1ea |
1508 | for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) { |
9ae15266 |
1509 | if(decision->GetITrigger(icirc)==1) { |
1510 | Int_t localtr[7]={0,0,0,0,0,0,0}; |
1511 | Int_t loLpt[2]={0,0}; Int_t loHpt[2]={0,0}; Int_t loApt[2]={0,0}; |
1512 | decision->GetLutOutput(icirc, loLpt, loHpt, loApt); |
1513 | localtr[0] = icirc; |
1514 | localtr[1] = decision->GetStripX11(icirc); |
1515 | localtr[2] = decision->GetDev(icirc); |
1516 | localtr[3] = decision->GetStripY11(icirc); |
1517 | for (i=0; i<2; i++) { // convert the Lut output in 1 digit |
1518 | localtr[4] = localtr[4]+Int_t(loLpt[i]*TMath::Power(2,i)); |
1519 | localtr[5] = localtr[5]+Int_t(loHpt[i]*TMath::Power(2,i)); |
1520 | localtr[6] = localtr[6]+Int_t(loApt[i]*TMath::Power(2,i)); |
1521 | } |
1522 | AddLocalTrigger(localtr); // add a local trigger in the list |
a897a37a |
1523 | } |
a9e2aefa |
1524 | } |
1525 | delete decision; |
a897a37a |
1526 | |
a9e2aefa |
1527 | gAlice->TreeR()->Fill(); |
1528 | ResetTrigger(); |
a897a37a |
1529 | char hname[30]; |
1530 | sprintf(hname,"TreeR%d",nev); |
1531 | gAlice->TreeR()->Write(hname); |
1532 | gAlice->TreeR()->Reset(); |
a9e2aefa |
1533 | printf("\n End of trigger for event %d", nev); |
a897a37a |
1534 | } |
a897a37a |
1535 | |
a897a37a |
1536 | |
a9e2aefa |
1537 | //____________________________________________ |
1538 | void AliMUON::FindClusters(Int_t nev,Int_t lastEntry) |
1539 | { |
1540 | TClonesArray *dig1, *dig2; |
1541 | Int_t ndig, k; |
1542 | dig1 = new TClonesArray("AliMUONDigit",1000); |
1543 | dig2 = new TClonesArray("AliMUONDigit",1000); |
1544 | AliMUONDigit *digit; |
a897a37a |
1545 | // |
a9e2aefa |
1546 | // Loop on chambers and on cathode planes |
a897a37a |
1547 | // |
a897a37a |
1548 | |
a9e2aefa |
1549 | for (Int_t ich=0;ich<10;ich++) { |
1550 | AliMUONChamber* iChamber=(AliMUONChamber*) (*fChambers)[ich]; |
30aaba74 |
1551 | AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel(); |
a9e2aefa |
1552 | gAlice->ResetDigits(); |
1553 | gAlice->TreeD()->GetEvent(lastEntry); |
1554 | TClonesArray *muonDigits = this->DigitsAddress(ich); |
1555 | ndig=muonDigits->GetEntriesFast(); |
1556 | printf("\n 1 Found %d digits in %p %d", ndig, muonDigits,ich); |
1557 | TClonesArray &lhits1 = *dig1; |
1558 | Int_t n=0; |
1559 | for (k=0; k<ndig; k++) { |
1560 | digit=(AliMUONDigit*) muonDigits->UncheckedAt(k); |
1561 | if (rec->TestTrack(digit->fTracks[0])) |
1562 | new(lhits1[n++]) AliMUONDigit(*digit); |
1563 | } |
1564 | gAlice->ResetDigits(); |
1565 | gAlice->TreeD()->GetEvent(lastEntry+1); |
1566 | muonDigits = this->DigitsAddress(ich); |
1567 | ndig=muonDigits->GetEntriesFast(); |
1568 | printf("\n 2 Found %d digits in %p %d", ndig, muonDigits, ich); |
1569 | TClonesArray &lhits2 = *dig2; |
1570 | n=0; |
1571 | |
1572 | for (k=0; k<ndig; k++) { |
1573 | digit= (AliMUONDigit*) muonDigits->UncheckedAt(k); |
1574 | if (rec->TestTrack(digit->fTracks[0])) |
1575 | new(lhits2[n++]) AliMUONDigit(*digit); |
a897a37a |
1576 | } |
a897a37a |
1577 | |
9825400f |
1578 | if (rec) { |
1579 | AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2); |
a9e2aefa |
1580 | rec->FindRawClusters(); |
1581 | } |
1582 | dig1->Delete(); |
1583 | dig2->Delete(); |
1584 | } // for ich |
1585 | gAlice->TreeR()->Fill(); |
1586 | ResetRawClusters(); |
1587 | char hname[30]; |
1588 | sprintf(hname,"TreeR%d",nev); |
1589 | gAlice->TreeR()->Write(hname); |
1590 | gAlice->TreeR()->Reset(); |
1591 | printf("\n End of cluster finding for event %d", nev); |
1592 | |
1593 | delete dig1; |
1594 | delete dig2; |
1595 | //gObjectTable->Print(); |
a897a37a |
1596 | } |
a9e2aefa |
1597 | |
a897a37a |
1598 | |
fe4da5cc |
1599 | void AliMUON::Streamer(TBuffer &R__b) |
1600 | { |
1601 | // Stream an object of class AliMUON. |
a30a000f |
1602 | AliMUONChamber *iChamber; |
a9e2aefa |
1603 | AliMUONTriggerCircuit *iTriggerCircuit; |
a30a000f |
1604 | AliSegmentation *segmentation; |
1605 | AliMUONResponse *response; |
1606 | TClonesArray *digitsaddress; |
1607 | TClonesArray *rawcladdress; |
9ae15266 |
1608 | Int_t i; |
9ae15266 |
1609 | if (R__b.IsReading()) { |
1610 | Version_t R__v = R__b.ReadVersion(); if (R__v) { } |
1611 | AliDetector::Streamer(R__b); |
1612 | R__b >> fNPadHits; |
1613 | R__b >> fPadHits; // diff |
1614 | R__b >> fNLocalTrigger; |
1615 | R__b >> fLocalTrigger; |
1616 | R__b >> fNGlobalTrigger; |
1617 | R__b >> fGlobalTrigger; |
1618 | R__b >> fDchambers; |
1619 | R__b >> fRawClusters; |
1620 | R__b.ReadArray(fNdch); |
1621 | R__b.ReadArray(fNrawch); |
1622 | R__b >> fAccCut; |
1623 | R__b >> fAccMin; |
1624 | R__b >> fAccMax; |
1625 | R__b >> fChambers; |
1626 | R__b >> fTriggerCircuits; |
f665c1ea |
1627 | for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) { |
9ae15266 |
1628 | iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i]; |
1629 | iTriggerCircuit->Streamer(R__b); |
fe4da5cc |
1630 | } |
9ae15266 |
1631 | // Stream chamber related information |
f665c1ea |
1632 | for (i =0; i<AliMUONConstants::NCh(); i++) { |
9ae15266 |
1633 | iChamber=(AliMUONChamber*) (*fChambers)[i]; |
1634 | iChamber->Streamer(R__b); |
1635 | if (iChamber->Nsec()==1) { |
1636 | segmentation=iChamber->SegmentationModel(1); |
1637 | if (segmentation) |
1638 | segmentation->Streamer(R__b); |
1639 | } else { |
1640 | segmentation=iChamber->SegmentationModel(1); |
1641 | if (segmentation) |
1642 | segmentation->Streamer(R__b); |
1643 | if (segmentation) |
1644 | segmentation=iChamber->SegmentationModel(2); |
1645 | segmentation->Streamer(R__b); |
1646 | } |
1647 | response=iChamber->ResponseModel(); |
1648 | if (response) |
1649 | response->Streamer(R__b); |
1650 | digitsaddress=(TClonesArray*) (*fDchambers)[i]; |
1651 | digitsaddress->Streamer(R__b); |
f665c1ea |
1652 | if (i < AliMUONConstants::NTrackingCh()) { |
9ae15266 |
1653 | rawcladdress=(TClonesArray*) (*fRawClusters)[i]; |
1654 | rawcladdress->Streamer(R__b); |
1655 | } |
a9e2aefa |
1656 | } |
9ae15266 |
1657 | |
1658 | } else { |
1659 | R__b.WriteVersion(AliMUON::IsA()); |
1660 | AliDetector::Streamer(R__b); |
1661 | R__b << fNPadHits; |
1662 | R__b << fPadHits; // diff |
1663 | R__b << fNLocalTrigger; |
1664 | R__b << fLocalTrigger; |
1665 | R__b << fNGlobalTrigger; |
1666 | R__b << fGlobalTrigger; |
1667 | R__b << fDchambers; |
1668 | R__b << fRawClusters; |
f665c1ea |
1669 | R__b.WriteArray(fNdch, AliMUONConstants::NCh()); |
1670 | R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh()); |
9ae15266 |
1671 | |
1672 | R__b << fAccCut; |
1673 | R__b << fAccMin; |
1674 | R__b << fAccMax; |
1675 | |
1676 | R__b << fChambers; |
1677 | R__b << fTriggerCircuits; |
f665c1ea |
1678 | for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) { |
9ae15266 |
1679 | iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i]; |
1680 | iTriggerCircuit->Streamer(R__b); |
fe4da5cc |
1681 | } |
f665c1ea |
1682 | for (i =0; i<AliMUONConstants::NCh(); i++) { |
9ae15266 |
1683 | iChamber=(AliMUONChamber*) (*fChambers)[i]; |
1684 | iChamber->Streamer(R__b); |
1685 | if (iChamber->Nsec()==1) { |
1686 | segmentation=iChamber->SegmentationModel(1); |
1687 | if (segmentation) |
1688 | segmentation->Streamer(R__b); |
1689 | } else { |
1690 | segmentation=iChamber->SegmentationModel(1); |
1691 | if (segmentation) |
1692 | segmentation->Streamer(R__b); |
1693 | segmentation=iChamber->SegmentationModel(2); |
1694 | if (segmentation) |
1695 | segmentation->Streamer(R__b); |
1696 | } |
1697 | response=iChamber->ResponseModel(); |
1698 | if (response) |
1699 | response->Streamer(R__b); |
1700 | digitsaddress=(TClonesArray*) (*fDchambers)[i]; |
1701 | digitsaddress->Streamer(R__b); |
f665c1ea |
1702 | if (i < AliMUONConstants::NTrackingCh()) { |
9ae15266 |
1703 | rawcladdress=(TClonesArray*) (*fRawClusters)[i]; |
1704 | rawcladdress->Streamer(R__b); |
1705 | } |
a9e2aefa |
1706 | } |
fe4da5cc |
1707 | } |
fe4da5cc |
1708 | } |
a9e2aefa |
1709 | AliMUONPadHit* AliMUON::FirstPad(AliMUONHit* hit, TClonesArray *clusters) |
fe4da5cc |
1710 | { |
1711 | // |
1712 | // Initialise the pad iterator |
1713 | // Return the address of the first padhit for hit |
a897a37a |
1714 | TClonesArray *theClusters = clusters; |
fe4da5cc |
1715 | Int_t nclust = theClusters->GetEntriesFast(); |
1716 | if (nclust && hit->fPHlast > 0) { |
a9e2aefa |
1717 | AliMUON::fMaxIterPad=hit->fPHlast; |
1718 | AliMUON::fCurIterPad=hit->fPHfirst; |
1719 | return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1); |
fe4da5cc |
1720 | } else { |
1721 | return 0; |
1722 | } |
1723 | } |
1724 | |
a9e2aefa |
1725 | AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters) |
fe4da5cc |
1726 | { |
a9e2aefa |
1727 | AliMUON::fCurIterPad++; |
1728 | if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) { |
1729 | return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1); |
fe4da5cc |
1730 | } else { |
1731 | return 0; |
1732 | } |
1733 | } |
1734 | |
a897a37a |
1735 | |
1736 | AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster) |
1737 | { |
a9e2aefa |
1738 | TClonesArray *muonRawCluster = RawClustAddress(ichamber); |
a897a37a |
1739 | ResetRawClusters(); |
a9e2aefa |
1740 | TTree *treeR = gAlice->TreeR(); |
1741 | Int_t nent=(Int_t)treeR->GetEntries(); |
1742 | treeR->GetEvent(nent-2+icathod-1); |
1743 | //treeR->GetEvent(icathod); |
1744 | //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast(); |
a897a37a |
1745 | |
a9e2aefa |
1746 | AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster); |
a897a37a |
1747 | //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw); |
1748 | |
1749 | return mRaw; |
1750 | } |
1751 | |
a9e2aefa |
1752 | AliMUON& AliMUON::operator = (const AliMUON& rhs) |
a897a37a |
1753 | { |
a9e2aefa |
1754 | // copy operator |
1755 | // dummy version |
1756 | return *this; |
a897a37a |
1757 | } |
1758 | |
1759 | |
1760 | |
a897a37a |
1761 | |
1762 | |
fe4da5cc |
1763 | |
fe4da5cc |
1764 | |
fe4da5cc |
1765 | |
fe4da5cc |
1766 | |
1767 | |
1768 | |
1769 | |
1770 | |
1771 | |
1772 | |
1773 | |
1774 | |
1775 | |
1776 | |