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