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