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