]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUON.cxx
Optimising initialisation of data members
[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$
549eb4c2 17Revision 1.57 2002/10/14 14:57:29 hristov
18Merging the VirtualMC branch to the main development branch (HEAD)
19
b9d0a01d 20Revision 1.56.6.2 2002/07/24 10:07:20 alibrary
21Updating VirtualMC
22
23Revision 1.56.6.1 2002/06/10 15:10:14 hristov
24Merged with v3-08-02
25
26Revision 1.56 2001/11/22 11:26:28 jchudoba
27Proper deletion of arrays, deletion of unused variables (thanks to Rene Brun)
28
62468ef9 29Revision 1.55 2001/09/07 08:38:30 hristov
30Pointers initialised to 0 in the default constructors
31
edf34242 32Revision 1.54 2001/08/30 09:52:12 hristov
33The operator[] is replaced by At() or AddAt() in case of TObjArray.
34
2682e810 35Revision 1.53 2001/07/20 10:03:13 morsch
36Changes needed to work with Root 3.01 (substitute lhs [] operator). (Jiri Chudoba)
37
cd4df77b 38Revision 1.52 2001/06/14 13:49:22 hristov
39Write a TreeD in SDigits2Digits method (needed to be compatible with alirun script)
40
d963c261 41Revision 1.51 2001/05/31 10:19:52 morsch
42Fix for new AliRun::RunReco().
43
e365e1ee 44Revision 1.50 2001/05/16 14:57:17 alibrary
45New files for folders and Stack
46
9e1a0ddb 47Revision 1.49 2001/03/12 17:45:48 hristov
48Changes needed on Sun with CC 5.0
49
5cf7bbad 50Revision 1.48 2001/03/06 00:01:36 morsch
51Add Digits2Reco() and FindClusters()
52Adapt call of cluster finder to new STEER.
53
fe311ef1 54Revision 1.47 2001/03/05 08:38:36 morsch
55Digitization related methods moved to AliMUONMerger.
56
1cae9436 57Revision 1.46 2001/01/26 21:34:59 morsch
58Use access functions for AliMUONHit, AliMUONDigit and AliMUONPadHit data members.
59
1bd28025 60Revision 1.45 2001/01/26 20:00:49 hristov
61Major upgrade of AliRoot code
62
2ab0c725 63Revision 1.44 2001/01/25 17:39:09 morsch
64Pass size of fNdch and fNrawch to CINT.
65
1bd26093 66Revision 1.43 2001/01/23 18:58:19 hristov
67Initialisation of some pointers
68
3f5cf0b3 69Revision 1.42 2001/01/17 20:53:40 hristov
70Destructors corrected to avoid memory leaks
71
c2c0190f 72Revision 1.41 2000/12/21 22:12:40 morsch
73Clean-up of coding rule violations,
74
de05461e 75Revision 1.40 2000/11/29 20:32:26 gosset
76Digitize:
771. correction for array index out of bounds
782. one printout commented
79
48030acd 80Revision 1.39 2000/11/12 17:17:03 pcrochet
81BuildGeometry of AliMUON for trigger chambers delegated to AliMUONSegmentationTriggerX (same strategy as for tracking chambers)
82
5fd73042 83Revision 1.38 2000/11/06 09:20:43 morsch
84AliMUON delegates part of BuildGeometry() to AliMUONSegmentation using the
85Draw() method. This avoids code and parameter replication.
86
aaf4addd 87Revision 1.37 2000/10/26 09:53:37 pcrochet
88put back trigger chambers in the display (there was a problem in buildgeometry)
89
43b96d92 90Revision 1.36 2000/10/25 19:51:18 morsch
91Correct x-position of chambers.
92
6bc66d8f 93Revision 1.35 2000/10/24 19:46:21 morsch
94BuildGeometry updated for slats in station 3-4.
95
e4fa3d7e 96Revision 1.34 2000/10/18 11:42:06 morsch
97- AliMUONRawCluster contains z-position.
98- Some clean-up of useless print statements during initialisations.
99
3e1872ed 100Revision 1.33 2000/10/09 14:01:57 morsch
101Unused variables removed.
102
0234695f 103Revision 1.32 2000/10/06 09:08:10 morsch
104Built geometry includes slat geometry for event display.
105
7ab910ae 106Revision 1.31 2000/10/02 21:28:08 fca
107Removal of useless dependecies via forward declarations
108
94de3818 109Revision 1.30 2000/10/02 16:58:29 egangler
110Cleaning of the code :
111-> coding conventions
112-> void Streamers
113-> some useless includes removed or replaced by "class" statement
114
ecfa008b 115Revision 1.29 2000/07/28 13:49:38 morsch
116SetAcceptance defines inner and outer chamber radii according to angular acceptance.
117Can be used for simple acceptance studies.
118
5c1f55c5 119Revision 1.28 2000/07/22 16:43:15 morsch
120Same comment as before, but now done correctly I hope (sorry it's Saturday evening)
121
45085cb9 122Revision 1.27 2000/07/22 16:36:50 morsch
123Change order of indices in creation (new) of xhit and yhit
124
6b18d06a 125Revision 1.26 2000/07/03 11:54:57 morsch
126AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
127The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
128
a30a000f 129Revision 1.25 2000/06/29 12:34:09 morsch
130AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
131it usable with any other geometry class. The link to the object to which it belongs is
132established via an index. This assumes that there exists a global geometry manager
133from which the pointer to the parent object can be obtained (in our case gAlice).
134
d81db581 135Revision 1.24 2000/06/28 15:16:35 morsch
136(1) Client code adapted to new method signatures in AliMUONSegmentation (see comments there)
137to allow development of slat-muon chamber simulation and reconstruction code in the MUON
138framework. The changes should have no side effects (mostly dummy arguments).
139(2) Hit disintegration uses 3-dim hit coordinates to allow simulation
140of chambers with overlapping modules (MakePadHits, Disintegration).
141
802a864d 142Revision 1.23 2000/06/28 12:19:17 morsch
143More consequent seperation of global input data services (AliMUONClusterInput singleton) and the
fe311ef1 144cluster and hit reconstruction algorithms in AliMUONClusterFindRawinderVS.
802a864d 145AliMUONClusterFinderVS becomes the base class for clustering and hit reconstruction.
146It requires two cathode planes. Small modifications in the code will make it usable for
147one cathode plane and, hence, more general (for test beam data).
148AliMUONClusterFinder is now obsolete.
149
30aaba74 150Revision 1.22 2000/06/28 08:06:10 morsch
151Avoid global variables in AliMUONClusterFinderVS by seperating the input data for the fit from the
152algorithmic part of the class. Input data resides inside the AliMUONClusterInput singleton.
153It also naturally takes care of the TMinuit instance.
154
9825400f 155Revision 1.21 2000/06/27 08:54:41 morsch
156Problems with on constant array sizes (in hitMap, nmuon, xhit, yhit) corrected.
157
d09fafb0 158Revision 1.20 2000/06/26 14:02:38 morsch
159Add class AliMUONConstants with MUON specific constants using static memeber data and access methods.
160
f665c1ea 161Revision 1.19 2000/06/22 13:40:51 morsch
162scope problem on HP, "i" declared once
163pow changed to TMath::Power (PH, AM)
164
9ae15266 165Revision 1.18 2000/06/15 07:58:48 morsch
166Code from MUON-dev joined
167
a9e2aefa 168Revision 1.14.4.17 2000/06/14 14:36:46 morsch
169- add TriggerCircuit (PC)
170- add GlobalTrigger and LocalTrigger and specific methods (PC)
171
172Revision 1.14.4.16 2000/06/09 21:20:28 morsch
173Most coding rule violations corrected
174
175Revision 1.14.4.15 2000/05/02 09:54:32 morsch
176RULE RN17 violations corrected
177
178Revision 1.14.4.12 2000/04/26 12:25:02 morsch
179Code revised by P. Crochet:
180- Z position of TriggerChamber changed according to A.Tournaire Priv.Comm.
181- ToF included in the method MakePadHits
182- inner radius of flange between beam shielding and trigger corrected
183- Trigger global volume updated (according to the new geometry)
184
185Revision 1.14.4.11 2000/04/19 19:42:08 morsch
186Some changes of variable names curing viols and methods concerning
187correlated clusters removed.
188
189Revision 1.14.4.10 2000/03/22 16:44:07 gosset
190Memory leak suppressed in function Digitise:
191p_adr->Delete() instead of Clear (I.Chevrot and A.Baldisseri)
192
193Revision 1.14.4.9 2000/03/20 18:15:25 morsch
194Positions of trigger chambers corrected (P.C.)
dbe37a89 195
a9e2aefa 196Revision 1.14.4.8 2000/02/21 15:38:01 morsch
197Call to AddHitList introduced to make this version compatible with head.
dffd31ef 198
a9e2aefa 199Revision 1.14.4.7 2000/02/20 07:45:53 morsch
200Bugs in Trigger part of BuildGeomemetry corrected (P.C)
1cedd08a 201
a9e2aefa 202Revision 1.14.4.6 2000/02/17 14:28:54 morsch
203Trigger included into initialization and digitization
6a935c13 204
a9e2aefa 205Revision 1.14.4.5 2000/02/15 10:02:58 morsch
206Log messages of previous revisions added
5d84196c 207
a9e2aefa 208Revision 1.14.4.2 2000/02/04 10:57:34 gosset
209Z position of the chambers:
210it was the Z position of the stations;
211it is now really the Z position of the chambers.
212 !!!! WARNING: THE CALLS TO "AliMUONChamber::SetZPOS"
213 !!!! AND "AliMUONChamber::ZPosition"
214 !!!! HAVE TO BE CHANGED TO "AliMUONChamber::"SetZ"
215 !!!! AND "AliMUONChamber::Z"
50f986db 216
a9e2aefa 217Revision 1.14.4.3 2000/02/04 16:19:04 gosset
218Correction for mis-spelling of NCH
0b34885d 219
a9e2aefa 220Revision 1.14.4.4 2000/02/15 09:43:38 morsch
221Log message added
2b86633d 222
4c039060 223*/
224
a9e2aefa 225
226///////////////////////////////////////////////
fe4da5cc 227// Manager and hits classes for set:MUON //
228////////////////////////////////////////////////
229
230#include <TTUBE.h>
a897a37a 231#include <TBRIK.h>
232#include <TRotMatrix.h>
94de3818 233#include <TGeometry.h>
fe4da5cc 234#include <TNode.h>
a897a37a 235#include <TTree.h>
fe4da5cc 236#include <TRandom.h>
237#include <TObject.h>
238#include <TVector.h>
239#include <TObjArray.h>
a897a37a 240#include <TMinuit.h>
241#include <TParticle.h>
242#include <TROOT.h>
243#include <TFile.h>
244#include <TNtuple.h>
245#include <TCanvas.h>
246#include <TPad.h>
247#include <TDirectory.h>
248#include <TObjectTable.h>
249#include <AliPDG.h>
a9e2aefa 250#include <TTUBE.h>
fe4da5cc 251
252#include "AliMUON.h"
a9e2aefa 253#include "AliMUONHit.h"
254#include "AliMUONPadHit.h"
255#include "AliMUONDigit.h"
256#include "AliMUONTransientDigit.h"
257#include "AliMUONRawCluster.h"
258#include "AliMUONLocalTrigger.h"
259#include "AliMUONGlobalTrigger.h"
ecfa008b 260#include "AliMUONTriggerCircuit.h"
a30a000f 261#include "AliHitMap.h"
a9e2aefa 262#include "AliMUONHitMapA1.h"
263#include "AliMUONChamberTrigger.h"
f665c1ea 264#include "AliMUONConstants.h"
30aaba74 265#include "AliMUONClusterFinderVS.h"
a9e2aefa 266#include "AliMUONTriggerDecision.h"
fe4da5cc 267#include "AliRun.h"
e365e1ee 268#include "AliHeader.h"
fe4da5cc 269#include "AliMC.h"
9825400f 270#include "AliMUONClusterInput.h"
1cae9436 271#include "AliMUONMerger.h"
549eb4c2 272#include "Riostream.h"
a9e2aefa 273#include "AliConst.h"
274
275// Defaults parameters for Z positions of chambers
276// taken from values for "stations" in AliMUON::AliMUON
277// const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
278// and from array "dstation" in AliMUONv1::CreateGeometry
279// Float_t dstation[5]={20., 20., 20, 20., 20.};
280// for tracking chambers,
281// according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
282// for the first and second chambers in the station, respectively,
283// and from "DTPLANES" in AliMUONv1::CreateGeometry
284// const Float_t DTPLANES = 15.;
285// for trigger chambers,
286// according to (Z1 = zch) and (Z2 = zch + DTPLANES)
287// for the first and second chambers in the station, respectively
fe4da5cc 288
fe4da5cc 289ClassImp(AliMUON)
fe4da5cc 290//___________________________________________
291AliMUON::AliMUON()
292{
de05461e 293// Default Constructor
294//
1bd28025 295 fNCh = 0;
296 fNTrackingCh = 0;
1bd26093 297 fIshunt = 0;
1bd26093 298 fPadHits = 0;
299 fNPadHits = 0;
1bd28025 300 fChambers = 0;
1bd26093 301 fDchambers = 0;
1bd28025 302 fTriggerCircuits = 0;
1bd26093 303 fNdch = 0;
304 fRawClusters = 0;
305 fNrawch = 0;
306 fGlobalTrigger = 0;
307 fNLocalTrigger = 0;
308 fLocalTrigger = 0;
309 fNLocalTrigger = 0;
310 fAccMin = 0.;
311 fAccMax = 0.;
312 fAccCut = kFALSE;
1cae9436 313 fMerger = 0;
edf34242 314 fFileName = 0;
fe4da5cc 315}
316
317//___________________________________________
318AliMUON::AliMUON(const char *name, const char *title)
319 : AliDetector(name,title)
320{
321//Begin_Html
322/*
a897a37a 323<img src="gif/alimuon.gif">
fe4da5cc 324*/
325//End_Html
f665c1ea 326
a9e2aefa 327 fHits = new TClonesArray("AliMUONHit",1000);
1cedd08a 328 gAlice->AddHitList(fHits);
a9e2aefa 329 fPadHits = new TClonesArray("AliMUONPadHit",10000);
330 fNPadHits = 0;
fe4da5cc 331 fIshunt = 0;
332
1bd28025 333 fNCh = AliMUONConstants::NCh();
1bd26093 334 fNTrackingCh = AliMUONConstants::NTrackingCh();
1bd28025 335 fNdch = new Int_t[fNCh];
fe4da5cc 336
f665c1ea 337 fDchambers = new TObjArray(AliMUONConstants::NCh());
fe4da5cc 338
339 Int_t i;
340
f665c1ea 341 for (i=0; i<AliMUONConstants::NCh() ;i++) {
cd4df77b 342 fDchambers->AddAt(new TClonesArray("AliMUONDigit",10000),i);
fe4da5cc 343 fNdch[i]=0;
344 }
345
1bd28025 346 fNrawch = new Int_t[fNTrackingCh];
a897a37a 347
f665c1ea 348 fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
a897a37a 349
f665c1ea 350 for (i=0; i<AliMUONConstants::NTrackingCh();i++) {
cd4df77b 351 fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i);
a897a37a 352 fNrawch[i]=0;
353 }
354
a9e2aefa 355 fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1);
356 fNGlobalTrigger = 0;
357 fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234);
358 fNLocalTrigger = 0;
fe4da5cc 359
fe4da5cc 360 SetMarkerColor(kRed);
a9e2aefa 361//
362//
363//
364//
f665c1ea 365
a9e2aefa 366 Int_t ch;
367
f665c1ea 368 fChambers = new TObjArray(AliMUONConstants::NCh());
a9e2aefa 369
370 // Loop over stations
f665c1ea 371 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
a9e2aefa 372 // Loop over 2 chambers in the station
373 for (Int_t stCH = 0; stCH < 2; stCH++) {
374//
375//
376// Default Parameters for Muon Tracking Stations
377
378
379 ch = 2 * st + stCH;
380//
f665c1ea 381 if (ch < AliMUONConstants::NTrackingCh()) {
cd4df77b 382 fChambers->AddAt(new AliMUONChamber(ch),ch);
a9e2aefa 383 } else {
cd4df77b 384 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
a9e2aefa 385 }
386
2682e810 387 //PH AliMUONChamber* chamber = (AliMUONChamber*) (*fChambers)[ch];
388 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
a9e2aefa 389
390 chamber->SetGid(0);
391 // Default values for Z of chambers
f665c1ea 392 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
a9e2aefa 393//
f665c1ea 394 chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
5c1f55c5 395// Set chamber inner and outer radius to default
f665c1ea 396 chamber->SetRInner(AliMUONConstants::Dmin(st)/2);
397 chamber->SetROuter(AliMUONConstants::Dmax(st)/2);
a9e2aefa 398//
399 } // Chamber stCH (0, 1) in
400 } // Station st (0...)
cd4df77b 401// fChambers->SetLast(AliMUONConstants::NCh());
a9e2aefa 402 fMaxStepGas=0.01;
403 fMaxStepAlu=0.1;
404 fMaxDestepGas=-1;
405 fMaxDestepAlu=-1;
406//
407 fMaxIterPad = 0;
408 fCurIterPad = 0;
5c1f55c5 409//
410 fAccMin = 0.;
411 fAccMax = 0.;
412 fAccCut = kFALSE;
a9e2aefa 413
414 // cp new design of AliMUONTriggerDecision
f665c1ea 415 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
416 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
cd4df77b 417 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
a9e2aefa 418
1cae9436 419 }
420 fMerger = 0;
fe4da5cc 421}
422
423//___________________________________________
a9e2aefa 424AliMUON::AliMUON(const AliMUON& rMUON)
425{
426// Dummy copy constructor
427 ;
428
429}
430
fe4da5cc 431AliMUON::~AliMUON()
432{
de05461e 433// Destructor
9e1a0ddb 434 if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
a897a37a 435
f665c1ea 436 fIshunt = 0;
c2c0190f 437
438 // Delete TObjArrays
439
440 if (fChambers){
441 fChambers->Delete();
442 delete fChambers;
443 }
444
445 if (fTriggerCircuits){
446 fTriggerCircuits->Delete();
447 delete fTriggerCircuits;
448 }
449
450 if (fDchambers){
451 fDchambers->Delete();
452 delete fDchambers;
453 }
454
455 if (fRawClusters){
456 fRawClusters->Delete();
457 delete fRawClusters;
458 }
62468ef9 459
460 if (fNrawch) delete [] fNrawch;
c2c0190f 461
462 // Delete TClonesArrays
463
464 if (fPadHits){
465 fPadHits->Delete();
466 delete fPadHits;
467 }
468
469 if (fGlobalTrigger){
470 fGlobalTrigger->Delete();
471 delete fGlobalTrigger;
472 }
f665c1ea 473 fNGlobalTrigger = 0;
474
c2c0190f 475 if (fLocalTrigger){
476 fLocalTrigger->Delete();
477 delete fLocalTrigger;
478 }
f665c1ea 479 fNLocalTrigger = 0;
a897a37a 480
c2c0190f 481 if (fHits) {
482 fHits->Delete();
483 delete fHits;
484 }
485
1cae9436 486 if (fMerger) delete fMerger;
62468ef9 487 if (fNdch) delete [] fNdch;
488
fe4da5cc 489}
490
491//___________________________________________
492void AliMUON::AddHit(Int_t track, Int_t *vol, Float_t *hits)
493{
494 TClonesArray &lhits = *fHits;
a9e2aefa 495 new(lhits[fNhits++]) AliMUONHit(fIshunt,track,vol,hits);
fe4da5cc 496}
497//___________________________________________
a9e2aefa 498void AliMUON::AddPadHit(Int_t *clhits)
fe4da5cc 499{
a9e2aefa 500 TClonesArray &lclusters = *fPadHits;
501 new(lclusters[fNPadHits++]) AliMUONPadHit(clhits);
fe4da5cc 502}
503//_____________________________________________________________________________
504void AliMUON::AddDigits(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
505{
506 //
507 // Add a MUON digit to the list
508 //
509
2682e810 510 //PH TClonesArray &ldigits = *((TClonesArray*)(*fDchambers)[id]);
511 TClonesArray &ldigits = *((TClonesArray*)fDchambers->At(id));
a9e2aefa 512 new(ldigits[fNdch[id]++]) AliMUONDigit(tracks,charges,digits);
fe4da5cc 513}
514
a897a37a 515//_____________________________________________________________________________
516void AliMUON::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
517{
518 //
519 // Add a MUON digit to the list
520 //
521
2682e810 522 //PH TClonesArray &lrawcl = *((TClonesArray*)(*fRawClusters)[id]);
523 TClonesArray &lrawcl = *((TClonesArray*)fRawClusters->At(id));
a897a37a 524 new(lrawcl[fNrawch[id]++]) AliMUONRawCluster(c);
525}
a897a37a 526
a9e2aefa 527//___________________________________________
528void AliMUON::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
529 Int_t *singleUndef,
530 Int_t *pairUnlike, Int_t *pairLike)
531{
532// add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
533 TClonesArray &globalTrigger = *fGlobalTrigger;
534 new(globalTrigger[fNGlobalTrigger++])
535 AliMUONGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike,
536 pairLike);
537}
538//___________________________________________
539void AliMUON::AddLocalTrigger(Int_t *localtr)
540{
541// add a MUON Local Trigger to the list
542 TClonesArray &localTrigger = *fLocalTrigger;
543 new(localTrigger[fNLocalTrigger++]) AliMUONLocalTrigger(localtr);
a897a37a 544}
545
fe4da5cc 546//___________________________________________
547void AliMUON::BuildGeometry()
548{
de05461e 549// Geometry for event display
5fd73042 550 for (Int_t i=0; i<7; i++) {
551 for (Int_t j=0; j<2; j++) {
552 Int_t id=2*i+j+1;
553 this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
a897a37a 554 }
5fd73042 555 }
fe4da5cc 556}
557
558//___________________________________________
559Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t )
560{
561 return 9999;
562}
563
564//___________________________________________
9e1a0ddb 565void AliMUON::MakeBranch(Option_t* option, const char *file)
fe4da5cc 566{
2ab0c725 567 //
f665c1ea 568 // Create Tree branches for the MUON.
2ab0c725 569 //
f665c1ea 570 const Int_t kBufferSize = 4000;
571 char branchname[30];
572 sprintf(branchname,"%sCluster",GetName());
573
2ab0c725 574 AliDetector::MakeBranch(option,file);
f665c1ea 575
5cf7bbad 576 const char *cD = strstr(option,"D");
577 const char *cR = strstr(option,"R");
578 const char *cH = strstr(option,"H");
2ab0c725 579
580 if (fPadHits && gAlice->TreeH() && cH) {
9e1a0ddb 581 MakeBranchInTree(gAlice->TreeH(),
582 branchname, &fPadHits, kBufferSize, file);
f665c1ea 583 }
584
2ab0c725 585 if (cD) {
586 //
587 // one branch for digits per chamber
588 //
589 Int_t i;
f665c1ea 590
2ab0c725 591 for (i=0; i<AliMUONConstants::NCh() ;i++) {
592 sprintf(branchname,"%sDigits%d",GetName(),i+1);
593 if (fDchambers && gAlice->TreeD()) {
9e1a0ddb 594 MakeBranchInTree(gAlice->TreeD(),
595 branchname, &((*fDchambers)[i]), kBufferSize, file);
2ab0c725 596 printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
597 }
598 }
f665c1ea 599 }
600
2ab0c725 601 if (cR) {
602 //
603 // one branch for raw clusters per chamber
604 //
605 printf("Make Branch - TreeR address %p\n",gAlice->TreeR());
606
607 Int_t i;
608
609 for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
610 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
611 if (fRawClusters && gAlice->TreeR()) {
9e1a0ddb 612 MakeBranchInTree(gAlice->TreeR(),
613 branchname, &((*fRawClusters)[i]), kBufferSize, file);
2ab0c725 614 printf("Making Branch %s for raw clusters in chamber %d\n",branchname,i+1);
615 }
616 }
617 //
618 // one branch for global trigger
619 //
620 sprintf(branchname,"%sGlobalTrigger",GetName());
621 if (fGlobalTrigger && gAlice->TreeR()) {
9e1a0ddb 622 MakeBranchInTree(gAlice->TreeR(),
623 branchname, &fGlobalTrigger, kBufferSize, file);
2ab0c725 624 printf("Making Branch %s for Global Trigger\n",branchname);
625 }
626 //
627 // one branch for local trigger
628 //
629 sprintf(branchname,"%sLocalTrigger",GetName());
630 if (fLocalTrigger && gAlice->TreeR()) {
9e1a0ddb 631 MakeBranchInTree(gAlice->TreeR(),
632 branchname, &fLocalTrigger, kBufferSize, file);
2ab0c725 633 printf("Making Branch %s for Local Trigger\n",branchname);
634 }
635 }
fe4da5cc 636}
637
638//___________________________________________
639void AliMUON::SetTreeAddress()
640{
641 // Set branch address for the Hits and Digits Tree.
a897a37a 642 char branchname[30];
fe4da5cc 643 AliDetector::SetTreeAddress();
644
645 TBranch *branch;
646 TTree *treeH = gAlice->TreeH();
647 TTree *treeD = gAlice->TreeD();
a897a37a 648 TTree *treeR = gAlice->TreeR();
fe4da5cc 649
650 if (treeH) {
a9e2aefa 651 if (fPadHits) {
fe4da5cc 652 branch = treeH->GetBranch("MUONCluster");
a9e2aefa 653 if (branch) branch->SetAddress(&fPadHits);
fe4da5cc 654 }
655 }
656
657 if (treeD) {
f665c1ea 658 for (int i=0; i<AliMUONConstants::NCh(); i++) {
fe4da5cc 659 sprintf(branchname,"%sDigits%d",GetName(),i+1);
660 if (fDchambers) {
661 branch = treeD->GetBranch(branchname);
662 if (branch) branch->SetAddress(&((*fDchambers)[i]));
663 }
664 }
665 }
a897a37a 666
667 // printf("SetTreeAddress --- treeR address %p \n",treeR);
668
669 if (treeR) {
f665c1ea 670 for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
a897a37a 671 sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
672 if (fRawClusters) {
673 branch = treeR->GetBranch(branchname);
674 if (branch) branch->SetAddress(&((*fRawClusters)[i]));
675 }
676 }
a897a37a 677
a9e2aefa 678 if (fLocalTrigger) {
679 branch = treeR->GetBranch("MUONLocalTrigger");
680 if (branch) branch->SetAddress(&fLocalTrigger);
681 }
682 if (fGlobalTrigger) {
683 branch = treeR->GetBranch("MUONGlobalTrigger");
684 if (branch) branch->SetAddress(&fGlobalTrigger);
685 }
686 }
fe4da5cc 687}
688//___________________________________________
689void AliMUON::ResetHits()
690{
691 // Reset number of clusters and the cluster array for this detector
692 AliDetector::ResetHits();
a9e2aefa 693 fNPadHits = 0;
694 if (fPadHits) fPadHits->Clear();
fe4da5cc 695}
696
697//____________________________________________
698void AliMUON::ResetDigits()
699{
700 //
701 // Reset number of digits and the digits array for this detector
702 //
f665c1ea 703 for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
2682e810 704 //PH if ((*fDchambers)[i]) ((TClonesArray*)(*fDchambers)[i])->Clear();
705 if ((*fDchambers)[i]) ((TClonesArray*)fDchambers->At(i))->Clear();
fe4da5cc 706 if (fNdch) fNdch[i]=0;
707 }
708}
a897a37a 709//____________________________________________
710void AliMUON::ResetRawClusters()
711{
712 //
713 // Reset number of raw clusters and the raw clust array for this detector
714 //
f665c1ea 715 for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
2682e810 716 //PH if ((*fRawClusters)[i]) ((TClonesArray*)(*fRawClusters)[i])->Clear();
717 if ((*fRawClusters)[i]) ((TClonesArray*)fRawClusters->At(i))->Clear();
a897a37a 718 if (fNrawch) fNrawch[i]=0;
719 }
720}
a9e2aefa 721
a897a37a 722//____________________________________________
a9e2aefa 723void AliMUON::ResetTrigger()
a897a37a 724{
a9e2aefa 725 // Reset Local and Global Trigger
726 fNGlobalTrigger = 0;
727 if (fGlobalTrigger) fGlobalTrigger->Clear();
728 fNLocalTrigger = 0;
729 if (fLocalTrigger) fLocalTrigger->Clear();
730}
731
732//____________________________________________
733void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
734{
de05461e 735// Set the pad size for chamber id and cathode isec
a9e2aefa 736 Int_t i=2*(id-1);
2682e810 737 //PH ((AliMUONChamber*) (*fChambers)[i]) ->SetPadSize(isec,p1,p2);
738 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetPadSize(isec,p1,p2);
739 ((AliMUONChamber*) fChambers->At(i)) ->SetPadSize(isec,p1,p2);
740 ((AliMUONChamber*) fChambers->At(i+1))->SetPadSize(isec,p1,p2);
a897a37a 741}
742
fe4da5cc 743//___________________________________________
a9e2aefa 744void AliMUON::SetChambersZ(const Float_t *Z)
745{
746 // Set Z values for all chambers (tracking and trigger)
747 // from the array pointed to by "Z"
f665c1ea 748 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
2682e810 749 //PH ((AliMUONChamber*) ((*fChambers)[ch]))->SetZ(Z[ch]);
750 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
f665c1ea 751 return;
a9e2aefa 752}
fe4da5cc 753
a9e2aefa 754//___________________________________________
755void AliMUON::SetChambersZToDefault()
fe4da5cc 756{
a9e2aefa 757 // Set Z values for all chambers (tracking and trigger)
758 // to default values
f665c1ea 759 SetChambersZ(AliMUONConstants::DefaultChamberZ());
a9e2aefa 760 return;
fe4da5cc 761}
762
763//___________________________________________
a897a37a 764void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
fe4da5cc 765{
de05461e 766// Set the inverse charge slope for chamber id
fe4da5cc 767 Int_t i=2*(id-1);
2682e810 768 //PH ((AliMUONChamber*) (*fChambers)[i])->SetChargeSlope(p1);
769 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetChargeSlope(p1);
770 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
771 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
fe4da5cc 772}
773
774//___________________________________________
a897a37a 775void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
fe4da5cc 776{
de05461e 777// Set sigma of charge spread for chamber id
fe4da5cc 778 Int_t i=2*(id-1);
2682e810 779 //PH ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
780 //PH ((AliMUONChamber*) fChambers->Ati+1])->SetChargeSpread(p1,p2);
781 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
782 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
fe4da5cc 783}
784
785//___________________________________________
a897a37a 786void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
fe4da5cc 787{
de05461e 788// Set integration limits for charge spread
fe4da5cc 789 Int_t i=2*(id-1);
2682e810 790 //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
791 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
792 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
793 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
fe4da5cc 794}
795
796//___________________________________________
d09fafb0 797void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
fe4da5cc 798{
de05461e 799// Set maximum number for ADCcounts (saturation)
fe4da5cc 800 Int_t i=2*(id-1);
2682e810 801 //PH ((AliMUONChamber*) (*fChambers)[i])->SetMaxAdc(p1);
802 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetMaxAdc(p1);
803 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
804 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
fe4da5cc 805}
806
807//___________________________________________
a897a37a 808void AliMUON::SetMaxStepGas(Float_t p1)
fe4da5cc 809{
de05461e 810// Set stepsize in gas
fe4da5cc 811 fMaxStepGas=p1;
812}
813
814//___________________________________________
a897a37a 815void AliMUON::SetMaxStepAlu(Float_t p1)
fe4da5cc 816{
de05461e 817// Set step size in Alu
fe4da5cc 818 fMaxStepAlu=p1;
819}
820
821//___________________________________________
a897a37a 822void AliMUON::SetMaxDestepGas(Float_t p1)
fe4da5cc 823{
de05461e 824// Set maximum step size in Gas
fe4da5cc 825 fMaxDestepGas=p1;
826}
827
828//___________________________________________
a897a37a 829void AliMUON::SetMaxDestepAlu(Float_t p1)
fe4da5cc 830{
de05461e 831// Set maximum step size in Alu
fe4da5cc 832 fMaxDestepAlu=p1;
833}
834//___________________________________________
5c1f55c5 835void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
fe4da5cc 836{
de05461e 837// Set acceptance cuts
fe4da5cc 838 fAccCut=acc;
5c1f55c5 839 fAccMin=angmin*TMath::Pi()/180;
840 fAccMax=angmax*TMath::Pi()/180;
841 Int_t ch;
842 if (acc) {
843 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
844 // Loop over 2 chambers in the station
845 for (Int_t stCH = 0; stCH < 2; stCH++) {
846 ch = 2 * st + stCH;
847// Set chamber inner and outer radius according to acceptance cuts
848 Chamber(ch).SetRInner(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMin));
849 Chamber(ch).SetROuter(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMax));
850 } // chamber loop
851 } // station loop
852 }
fe4da5cc 853}
854//___________________________________________
a30a000f 855void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
fe4da5cc 856{
de05461e 857// Set the segmentation for chamber id cathode isec
2682e810 858 //PH ((AliMUONChamber*) (*fChambers)[id])->SetSegmentationModel(isec, segmentation);
859 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
fe4da5cc 860
861}
862//___________________________________________
a9e2aefa 863void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
fe4da5cc 864{
de05461e 865// Set the response for chamber id
2682e810 866 //PH ((AliMUONChamber*) (*fChambers)[id])->SetResponseModel(response);
867 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
fe4da5cc 868}
869
30aaba74 870void AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
a897a37a 871{
de05461e 872// Set ClusterFinder for chamber id
2682e810 873 //PH ((AliMUONChamber*) (*fChambers)[id])->SetReconstructionModel(reconst);
874 ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
a897a37a 875}
876
fe4da5cc 877void AliMUON::SetNsec(Int_t id, Int_t nsec)
878{
de05461e 879// Set number of segmented cathods for chamber id
2682e810 880 //PH ((AliMUONChamber*) (*fChambers)[id])->SetNsec(nsec);
881 ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
fe4da5cc 882}
883
fe4da5cc 884//___________________________________________
2ab0c725 885void AliMUON::SDigits2Digits()
886{
d963c261 887
888// write TreeD here
889
890 if (!fMerger) {
891 if (gAlice->GetDebug()>0) {
892 cerr<<"AliMUON::SDigits2Digits: create default AliMUONMerger "<<endl;
893 cerr<<" no merging, just digitization of 1 event will be done"<<endl;
894 }
895 fMerger = new AliMUONMerger();
2ab0c725 896 }
d963c261 897 fMerger->Init();
898 fMerger->Digitise();
899 char hname[30];
900 sprintf(hname,"TreeD%d",gAlice->GetHeader()->GetEvent());
901 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
902 gAlice->TreeD()->Reset();
2ab0c725 903}
a9e2aefa 904
2ab0c725 905//___________________________________________
802a864d 906void AliMUON::MakePadHits(Float_t xhit,Float_t yhit, Float_t zhit,
a9e2aefa 907 Float_t eloss, Float_t tof, Int_t idvol)
fe4da5cc 908{
909//
a897a37a 910// Calls the charge disintegration method of the current chamber and adds
911// the simulated cluster to the root treee
fe4da5cc 912//
a897a37a 913 Int_t clhits[7];
914 Float_t newclust[6][500];
915 Int_t nnew;
916
917
fe4da5cc 918//
a897a37a 919// Integrated pulse height on chamber
920
921
922 clhits[0]=fNhits+1;
fe4da5cc 923//
a897a37a 924//
7ab910ae 925// if (idvol == 6) printf("\n ->Disintegration %f %f %f", xhit, yhit, eloss );
926
927
2682e810 928 //PH ((AliMUONChamber*) (*fChambers)[idvol])
929 ((AliMUONChamber*) fChambers->At(idvol))
802a864d 930 ->DisIntegration(eloss, tof, xhit, yhit, zhit, nnew, newclust);
a897a37a 931 Int_t ic=0;
7ab910ae 932// if (idvol == 6) printf("\n nnew %d \n", nnew);
a897a37a 933//
934// Add new clusters
935 for (Int_t i=0; i<nnew; i++) {
936 if (Int_t(newclust[3][i]) > 0) {
937 ic++;
938// Cathode plane
939 clhits[1] = Int_t(newclust[5][i]);
940// Cluster Charge
941 clhits[2] = Int_t(newclust[0][i]);
942// Pad: ix
943 clhits[3] = Int_t(newclust[1][i]);
944// Pad: iy
945 clhits[4] = Int_t(newclust[2][i]);
946// Pad: charge
947 clhits[5] = Int_t(newclust[3][i]);
948// Pad: chamber sector
949 clhits[6] = Int_t(newclust[4][i]);
950
a9e2aefa 951 AddPadHit(clhits);
a897a37a 952 }
953 }
a897a37a 954}
955
a9e2aefa 956//___________________________________________
957void AliMUON::Trigger(Int_t nev){
958// call the Trigger Algorithm and fill TreeR
959
960 Int_t singlePlus[3] = {0,0,0};
961 Int_t singleMinus[3] = {0,0,0};
962 Int_t singleUndef[3] = {0,0,0};
963 Int_t pairUnlike[3] = {0,0,0};
964 Int_t pairLike[3] = {0,0,0};
965
966 ResetTrigger();
a9e2aefa 967 AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
968 decision->Trigger();
969 decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef,
970 pairUnlike, pairLike);
971// add a local trigger in the list
972 AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
9ae15266 973 Int_t i;
a9e2aefa 974
f665c1ea 975 for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) {
9ae15266 976 if(decision->GetITrigger(icirc)==1) {
977 Int_t localtr[7]={0,0,0,0,0,0,0};
978 Int_t loLpt[2]={0,0}; Int_t loHpt[2]={0,0}; Int_t loApt[2]={0,0};
979 decision->GetLutOutput(icirc, loLpt, loHpt, loApt);
980 localtr[0] = icirc;
981 localtr[1] = decision->GetStripX11(icirc);
982 localtr[2] = decision->GetDev(icirc);
983 localtr[3] = decision->GetStripY11(icirc);
984 for (i=0; i<2; i++) { // convert the Lut output in 1 digit
985 localtr[4] = localtr[4]+Int_t(loLpt[i]*TMath::Power(2,i));
986 localtr[5] = localtr[5]+Int_t(loHpt[i]*TMath::Power(2,i));
987 localtr[6] = localtr[6]+Int_t(loApt[i]*TMath::Power(2,i));
988 }
989 AddLocalTrigger(localtr); // add a local trigger in the list
a897a37a 990 }
a9e2aefa 991 }
992 delete decision;
a897a37a 993
a9e2aefa 994 gAlice->TreeR()->Fill();
995 ResetTrigger();
a897a37a 996 char hname[30];
997 sprintf(hname,"TreeR%d",nev);
2ab0c725 998 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
a897a37a 999 gAlice->TreeR()->Reset();
a9e2aefa 1000 printf("\n End of trigger for event %d", nev);
a897a37a 1001}
a897a37a 1002
a897a37a 1003
a9e2aefa 1004//____________________________________________
fe311ef1 1005void AliMUON::Digits2Reco()
1006{
1007 FindClusters();
e365e1ee 1008 Int_t nev = gAlice->GetHeader()->GetEvent();
1009 gAlice->TreeR()->Fill();
1010 char hname[30];
1011 sprintf(hname,"TreeR%d", nev);
1012 gAlice->TreeR()->Write(hname);
1013 gAlice->TreeR()->Reset();
1014 ResetRawClusters();
1015 printf("\n End of cluster finding for event %d", nev);
fe311ef1 1016}
1017
1018void AliMUON::FindClusters()
a9e2aefa 1019{
de05461e 1020//
1021// Perform cluster finding
1022//
a9e2aefa 1023 TClonesArray *dig1, *dig2;
1024 Int_t ndig, k;
1025 dig1 = new TClonesArray("AliMUONDigit",1000);
1026 dig2 = new TClonesArray("AliMUONDigit",1000);
1027 AliMUONDigit *digit;
a897a37a 1028//
a9e2aefa 1029// Loop on chambers and on cathode planes
a897a37a 1030//
fe311ef1 1031 ResetRawClusters();
1bd28025 1032 for (Int_t ich = 0; ich < 10; ich++) {
2682e810 1033 //PH AliMUONChamber* iChamber = (AliMUONChamber*) (*fChambers)[ich];
1034 AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
fe311ef1 1035 AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
1036
a9e2aefa 1037 gAlice->ResetDigits();
fe311ef1 1038 gAlice->TreeD()->GetEvent(0);
1bd28025 1039 TClonesArray *muonDigits = this->DigitsAddress(ich);
a9e2aefa 1040 ndig=muonDigits->GetEntriesFast();
1041 printf("\n 1 Found %d digits in %p %d", ndig, muonDigits,ich);
1042 TClonesArray &lhits1 = *dig1;
1bd28025 1043 Int_t n = 0;
1044 for (k = 0; k < ndig; k++) {
1045 digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
1046 if (rec->TestTrack(digit->Track(0)))
a9e2aefa 1047 new(lhits1[n++]) AliMUONDigit(*digit);
1048 }
1049 gAlice->ResetDigits();
fe311ef1 1050 gAlice->TreeD()->GetEvent(1);
a9e2aefa 1051 muonDigits = this->DigitsAddress(ich);
1052 ndig=muonDigits->GetEntriesFast();
1053 printf("\n 2 Found %d digits in %p %d", ndig, muonDigits, ich);
1054 TClonesArray &lhits2 = *dig2;
1055 n=0;
1056
1057 for (k=0; k<ndig; k++) {
1058 digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
1bd28025 1059 if (rec->TestTrack(digit->Track(0)))
a9e2aefa 1060 new(lhits2[n++]) AliMUONDigit(*digit);
a897a37a 1061 }
a897a37a 1062
9825400f 1063 if (rec) {
1064 AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
a9e2aefa 1065 rec->FindRawClusters();
1066 }
1067 dig1->Delete();
1068 dig2->Delete();
1069 } // for ich
a9e2aefa 1070 delete dig1;
1071 delete dig2;
a897a37a 1072}
a9e2aefa 1073
2ab0c725 1074#ifdef never
fe4da5cc 1075void AliMUON::Streamer(TBuffer &R__b)
1076{
1077 // Stream an object of class AliMUON.
a30a000f 1078 AliMUONChamber *iChamber;
a9e2aefa 1079 AliMUONTriggerCircuit *iTriggerCircuit;
a30a000f 1080 AliSegmentation *segmentation;
1081 AliMUONResponse *response;
1082 TClonesArray *digitsaddress;
1083 TClonesArray *rawcladdress;
9ae15266 1084 Int_t i;
9ae15266 1085 if (R__b.IsReading()) {
1086 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1087 AliDetector::Streamer(R__b);
1088 R__b >> fNPadHits;
1089 R__b >> fPadHits; // diff
1090 R__b >> fNLocalTrigger;
1091 R__b >> fLocalTrigger;
1092 R__b >> fNGlobalTrigger;
1093 R__b >> fGlobalTrigger;
1094 R__b >> fDchambers;
1095 R__b >> fRawClusters;
1096 R__b.ReadArray(fNdch);
1097 R__b.ReadArray(fNrawch);
1098 R__b >> fAccCut;
1099 R__b >> fAccMin;
1100 R__b >> fAccMax;
1101 R__b >> fChambers;
1102 R__b >> fTriggerCircuits;
f665c1ea 1103 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
9ae15266 1104 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
1105 iTriggerCircuit->Streamer(R__b);
fe4da5cc 1106 }
9ae15266 1107// Stream chamber related information
f665c1ea 1108 for (i =0; i<AliMUONConstants::NCh(); i++) {
9ae15266 1109 iChamber=(AliMUONChamber*) (*fChambers)[i];
1110 iChamber->Streamer(R__b);
1111 if (iChamber->Nsec()==1) {
1112 segmentation=iChamber->SegmentationModel(1);
1113 if (segmentation)
1114 segmentation->Streamer(R__b);
1115 } else {
1116 segmentation=iChamber->SegmentationModel(1);
1117 if (segmentation)
1118 segmentation->Streamer(R__b);
1119 if (segmentation)
1120 segmentation=iChamber->SegmentationModel(2);
1121 segmentation->Streamer(R__b);
1122 }
1123 response=iChamber->ResponseModel();
1124 if (response)
1125 response->Streamer(R__b);
1126 digitsaddress=(TClonesArray*) (*fDchambers)[i];
1127 digitsaddress->Streamer(R__b);
f665c1ea 1128 if (i < AliMUONConstants::NTrackingCh()) {
9ae15266 1129 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
1130 rawcladdress->Streamer(R__b);
1131 }
a9e2aefa 1132 }
9ae15266 1133
1134 } else {
1135 R__b.WriteVersion(AliMUON::IsA());
1136 AliDetector::Streamer(R__b);
1137 R__b << fNPadHits;
1138 R__b << fPadHits; // diff
1139 R__b << fNLocalTrigger;
1140 R__b << fLocalTrigger;
1141 R__b << fNGlobalTrigger;
1142 R__b << fGlobalTrigger;
1143 R__b << fDchambers;
1144 R__b << fRawClusters;
f665c1ea 1145 R__b.WriteArray(fNdch, AliMUONConstants::NCh());
1146 R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh());
9ae15266 1147
1148 R__b << fAccCut;
1149 R__b << fAccMin;
1150 R__b << fAccMax;
1151
1152 R__b << fChambers;
1153 R__b << fTriggerCircuits;
f665c1ea 1154 for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
9ae15266 1155 iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
1156 iTriggerCircuit->Streamer(R__b);
fe4da5cc 1157 }
f665c1ea 1158 for (i =0; i<AliMUONConstants::NCh(); i++) {
9ae15266 1159 iChamber=(AliMUONChamber*) (*fChambers)[i];
1160 iChamber->Streamer(R__b);
1161 if (iChamber->Nsec()==1) {
1162 segmentation=iChamber->SegmentationModel(1);
1163 if (segmentation)
1164 segmentation->Streamer(R__b);
1165 } else {
1166 segmentation=iChamber->SegmentationModel(1);
1167 if (segmentation)
1168 segmentation->Streamer(R__b);
1169 segmentation=iChamber->SegmentationModel(2);
1170 if (segmentation)
1171 segmentation->Streamer(R__b);
1172 }
1173 response=iChamber->ResponseModel();
1174 if (response)
1175 response->Streamer(R__b);
1176 digitsaddress=(TClonesArray*) (*fDchambers)[i];
1177 digitsaddress->Streamer(R__b);
f665c1ea 1178 if (i < AliMUONConstants::NTrackingCh()) {
9ae15266 1179 rawcladdress=(TClonesArray*) (*fRawClusters)[i];
1180 rawcladdress->Streamer(R__b);
1181 }
a9e2aefa 1182 }
fe4da5cc 1183 }
fe4da5cc 1184}
2ab0c725 1185#endif
1186
a9e2aefa 1187AliMUONPadHit* AliMUON::FirstPad(AliMUONHit* hit, TClonesArray *clusters)
fe4da5cc 1188{
1189//
1190 // Initialise the pad iterator
1191 // Return the address of the first padhit for hit
a897a37a 1192 TClonesArray *theClusters = clusters;
fe4da5cc 1193 Int_t nclust = theClusters->GetEntriesFast();
1bd28025 1194 if (nclust && hit->PHlast() > 0) {
1195 AliMUON::fMaxIterPad=hit->PHlast();
1196 AliMUON::fCurIterPad=hit->PHfirst();
a9e2aefa 1197 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
fe4da5cc 1198 } else {
1199 return 0;
1200 }
1201}
1202
a9e2aefa 1203AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters)
fe4da5cc 1204{
de05461e 1205// Get next pad (in iterator)
1206//
a9e2aefa 1207 AliMUON::fCurIterPad++;
1208 if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) {
1209 return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
fe4da5cc 1210 } else {
1211 return 0;
1212 }
1213}
1214
a897a37a 1215
1216AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
1217{
de05461e 1218//
1219// Return rawcluster (icluster) for chamber ichamber and cathode icathod
1220// Obsolete ??
a9e2aefa 1221 TClonesArray *muonRawCluster = RawClustAddress(ichamber);
a897a37a 1222 ResetRawClusters();
a9e2aefa 1223 TTree *treeR = gAlice->TreeR();
1224 Int_t nent=(Int_t)treeR->GetEntries();
1225 treeR->GetEvent(nent-2+icathod-1);
1226 //treeR->GetEvent(icathod);
1227 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
a897a37a 1228
a9e2aefa 1229 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
a897a37a 1230 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
1231
1232 return mRaw;
1233}
1cae9436 1234
1235void AliMUON::SetMerger(AliMUONMerger* merger)
1236{
1237// Set pointer to merger
1238 fMerger = merger;
1239}
1240
1241AliMUONMerger* AliMUON::Merger()
1242{
1243// Return pointer to merger
1244 return fMerger;
1245}
1246
1247
a897a37a 1248
a9e2aefa 1249AliMUON& AliMUON::operator = (const AliMUON& rhs)
a897a37a 1250{
a9e2aefa 1251// copy operator
1252// dummy version
1253 return *this;
a897a37a 1254}
1255
cd4df77b 1256////////////////////////////////////////////////////////////////////////
1257void AliMUON::MakeBranchInTreeD(TTree *treeD, const char *file)
1258{
1259 //
1260 // Create TreeD branches for the MUON.
1261 //
a897a37a 1262
cd4df77b 1263 const Int_t kBufferSize = 4000;
1264 char branchname[30];
1265
1266 //
1267 // one branch for digits per chamber
1268 //
1269 for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
1270 sprintf(branchname,"%sDigits%d",GetName(),i+1);
1271 if (fDchambers && treeD) {
1272 MakeBranchInTree(treeD,
1273 branchname, &((*fDchambers)[i]), kBufferSize, file);
62468ef9 1274// printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
cd4df77b 1275 }
1276 }
1277}
a897a37a 1278
cd4df77b 1279//___________________________________________
fe4da5cc 1280