]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUON.cxx
Corrections to obey the coding conventions
[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 /* $Id$ */
17
18
19 ///////////////////////////////////////////////
20 //  Manager and hits classes for set:MUON     //
21 ////////////////////////////////////////////////
22
23 #include "Riostream.h"
24
25 #include <AliPDG.h>
26 #include <TBRIK.h>
27 #include <TCanvas.h>
28 #include <TDirectory.h>
29 #include <TFile.h>
30 #include <TGeometry.h>
31 #include <TMinuit.h>
32 #include <TNode.h> 
33 #include <TNtuple.h>
34 #include <TObjArray.h>
35 #include <TObject.h>
36 #include <TObjectTable.h>
37 #include <TPad.h>
38 #include <TParticle.h>
39 #include <TROOT.h>
40 #include <TRandom.h> 
41 #include <TRotMatrix.h>
42 #include <TTUBE.h>
43 #include <TTUBE.h>
44 #include <TTree.h> 
45 #include <TVector.h>
46 #include <TVirtualMC.h>
47
48 #include "AliConst.h" 
49 #include "AliHeader.h"
50 #include "AliHitMap.h"
51 #include "AliLoader.h"
52 #include "AliMUONLoader.h"
53 #include "AliMUON.h"
54 #include "AliMUONChamberTrigger.h"
55 #include "AliMUONClusterFinderVS.h"
56 #include "AliMUONClusterInput.h"
57 #include "AliMUONConstants.h"
58 #include "AliMUONDigit.h"
59 #include "AliMUONGlobalTrigger.h"
60 #include "AliMUONHit.h"
61 #include "AliMUONHitMapA1.h"
62 #include "AliMUONLocalTrigger.h"
63 #include "AliMUONMerger.h"      
64 #include "AliMUONPadHit.h"
65 #include "AliMUONRawCluster.h"
66 #include "AliMUONTransientDigit.h"
67 #include "AliMUONTriggerCircuit.h"
68 #include "AliMUONTriggerDecision.h"
69 #include "AliRun.h"     
70 #include "AliMUONDigitizerv1.h"
71
72
73 // Defaults parameters for Z positions of chambers
74 // taken from values for "stations" in AliMUON::AliMUON
75 //     const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
76 // and from array "dstation" in AliMUONv1::CreateGeometry
77 //          Float_t dstation[5]={20., 20., 20, 20., 20.};
78 //     for tracking chambers,
79 //          according to (Z1 = zch - dstation) and  (Z2 = zch + dstation)
80 //          for the first and second chambers in the station, respectively,
81 // and from "DTPLANES" in AliMUONv1::CreateGeometry
82 //           const Float_t DTPLANES = 15.;
83 //     for trigger chambers,
84 //          according to (Z1 = zch) and  (Z2 = zch + DTPLANES)
85 //          for the first and second chambers in the station, respectively
86
87 ClassImp(AliMUON)
88 //__________________________________________________________________
89 AliMUON::AliMUON()
90 {
91 // Default Constructor
92 //
93     fNCh             = 0;
94     fNTrackingCh     = 0;
95     fIshunt          = 0;
96     fChambers        = 0;
97     fTriggerCircuits = 0;
98     fAccMin          = 0.;
99     fAccMax          = 0.;   
100     fAccCut          = kFALSE;
101     fMerger          = 0;
102     fFileName        = 0;
103     fMUONData        = 0;
104     fSplitLevel      = 0;
105 }
106 //__________________________________________________________________
107 AliMUON::AliMUON(const char *name, const char *title)
108   : AliDetector(name,title)
109 {
110 //Begin_Html
111 /*
112 <img src="gif/alimuon.gif">
113 */
114 //End_Html
115   fMUONData  = 0x0;
116   fSplitLevel= 0;
117   fIshunt     =  0;
118
119   fNCh             = AliMUONConstants::NCh(); 
120   fNTrackingCh     = AliMUONConstants::NTrackingCh();
121
122   SetMarkerColor(kRed);//
123 //
124 // Creating List of Chambers
125     Int_t ch;
126     fChambers = new TObjArray(AliMUONConstants::NCh());
127     // Loop over stations
128     for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
129       // Loop over 2 chambers in the station
130       for (Int_t stCH = 0; stCH < 2; stCH++) {
131         //
132         //    
133         //    Default Parameters for Muon Tracking Stations
134         ch = 2 * st + stCH;
135         if (ch < AliMUONConstants::NTrackingCh()) {
136           fChambers->AddAt(new AliMUONChamber(ch),ch);
137         } else {
138           fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
139         }
140         AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
141         chamber->SetGid(0);
142         // Default values for Z of chambers
143         chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
144         //
145         chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
146         //          Set chamber inner and outer radius to default
147         chamber->SetRInner(AliMUONConstants::Dmin(st)/2);
148         chamber->SetROuter(AliMUONConstants::Dmax(st)/2);
149         //
150       } // Chamber stCH (0, 1) in 
151     }     // Station st (0...)
152     
153     // Negatives values are ignored by geant3 CONS200 in the calculation of the tracking parameters
154     fMaxStepGas=0.1; 
155     fMaxStepAlu=0.1;  
156     fMaxDestepGas=-1;
157     fMaxDestepAlu=-1;
158     
159     fMaxIterPad   = 0;
160     fCurIterPad   = 0;
161     
162     fAccMin          = 0.;
163     fAccMax          = 0.;   
164     fAccCut          = kFALSE;
165     
166     // cp new design of AliMUONTriggerDecision
167     fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
168     for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
169       fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);          
170     }
171     fMerger = 0;
172 }
173 //____________________________________________________________________
174 AliMUON::AliMUON(const AliMUON& rMUON):AliDetector(rMUON)
175 {
176 // Dummy copy constructor
177     ;
178     
179 }
180 //____________________________________________________________________
181 AliMUON::~AliMUON()
182 {
183 // Destructor
184   if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
185   fIshunt  = 0;
186   if (fMerger) delete fMerger;
187 }
188 //____________________________________________________________________
189 void AliMUON::BuildGeometry()
190 {
191 // Geometry for event display
192   for (Int_t i=0; i<7; i++) {
193     for (Int_t j=0; j<2; j++) {
194       Int_t id=2*i+j+1;
195       this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
196     }
197   }
198 }
199 //___________________________________________________________________
200 Int_t AliMUON::DistancetoPrimitive(Int_t , Int_t )
201 {
202   return 9999;
203 }
204 //__________________________________________________________________
205 void  AliMUON::SetTreeAddress()
206 {
207   GetMUONData()->SetLoader(fLoader); 
208   GetMUONData()->SetTreeAddress("H,D,RC");
209   fHits = GetMUONData()->Hits(); // Added by Ivana to use the methods FisrtHit, NextHit of AliDetector
210 }
211
212 //____________________________________________________________________
213 void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
214 {
215 // Set the pad size for chamber id and cathode isec
216     Int_t i=2*(id-1);
217     ((AliMUONChamber*) fChambers->At(i))  ->SetPadSize(isec,p1,p2);
218     ((AliMUONChamber*) fChambers->At(i+1))->SetPadSize(isec,p1,p2);
219 }
220
221 //___________________________________________
222 void AliMUON::SetChambersZ(const Float_t *Z)
223 {
224   // Set Z values for all chambers (tracking and trigger)
225   // from the array pointed to by "Z"
226     for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
227         ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
228     return;
229 }
230 //_________________________________________________________________
231 void AliMUON::SetChambersZToDefault()
232 {
233   // Set Z values for all chambers (tracking and trigger)
234   // to default values
235   SetChambersZ(AliMUONConstants::DefaultChamberZ());
236   return;
237 }
238 //_________________________________________________________________
239 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
240 {
241 // Set the inverse charge slope for chamber id
242     Int_t i=2*(id-1);    //PH    ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
243     //PH    ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
244     ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
245     ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
246 }
247 //__________________________________________________________________
248 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
249 {
250 // Set sigma of charge spread for chamber id
251     Int_t i=2*(id-1);
252     ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
253     ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
254 }
255 //___________________________________________________________________
256 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
257 {
258 // Set integration limits for charge spread
259     Int_t i=2*(id-1);
260     ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
261     ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
262 }
263
264 //__________________________________________________________________
265 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
266 {
267 // Set maximum number for ADCcounts (saturation)
268     Int_t i=2*(id-1);
269     ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
270     ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
271 }
272 //__________________________________________________________________
273 void AliMUON::SetMaxStepGas(Float_t p1)
274 {
275 // Set stepsize in gas
276   fMaxStepGas=p1;
277 }
278 //__________________________________________________________________
279 void AliMUON::SetMaxStepAlu(Float_t p1)
280 {
281 // Set step size in Alu
282     fMaxStepAlu=p1;
283 }
284 //__________________________________________________________________
285 void AliMUON::SetMaxDestepGas(Float_t p1)
286 {
287 // Set maximum step size in Gas
288     fMaxDestepGas=p1;
289 }
290 //__________________________________________________________________
291 void AliMUON::SetMaxDestepAlu(Float_t p1)
292 {
293 // Set maximum step size in Alu
294   fMaxDestepAlu=p1;
295 }
296 //___________________________________________________________________
297 void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
298 {
299 // Set acceptance cuts 
300   fAccCut=acc;
301   fAccMin=angmin*TMath::Pi()/180;
302   fAccMax=angmax*TMath::Pi()/180;
303   Int_t ch;
304   if (acc) {
305     for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
306       // Loop over 2 chambers in the station
307       for (Int_t stCH = 0; stCH < 2; stCH++) {
308         ch = 2 * st + stCH;
309         //         Set chamber inner and outer radius according to acceptance cuts
310         Chamber(ch).SetRInner(TMath::Abs(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMin)));
311         Chamber(ch).SetROuter(TMath::Abs(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMax)));
312       } // chamber loop
313     } // station loop
314   }
315 }
316 //____________________________________________________________________
317 void   AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
318 {
319 // Set the segmentation for chamber id cathode isec
320     ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
321
322 }
323 //____________________________________________________________________
324 void   AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
325 {
326 // Set the response for chamber id
327     ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
328 }
329 //____________________________________________________________________
330 void   AliMUON::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
331 {
332 // Set ClusterFinder for chamber id
333     ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
334 }
335 //____________________________________________________________________
336 void   AliMUON::SetNsec(Int_t id, Int_t nsec)
337 {
338 // Set number of segmented cathods for chamber id
339     ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
340 }
341 //____________________________________________________________________
342 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
343 {
344   return new AliMUONDigitizerv1(manager);
345 }
346 //_____________________________________________________________________
347 void AliMUON::SDigits2Digits()
348 {
349
350 // write TreeD here 
351
352     if (!fMerger) {
353       if (gAlice->GetDebug()>0) {
354         cerr<<"AliMUON::SDigits2Digits: create default AliMUONMerger "<<endl;
355         cerr<<" no merging, just digitization of 1 event will be done"<<endl;
356       }
357       fMerger = new AliMUONMerger();
358     }
359     fMerger->Init();
360     fMerger->Digitise();
361     char hname[30];
362     //    sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
363     fLoader->TreeD()->Write(hname,TObject::kOverwrite);
364     fLoader->TreeD()->Reset();
365 }
366
367 //_______________________________________________________________________
368 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
369
370 //builds standard getter (AliLoader type)
371 //if detector wants to use castomized getter, it must overload this method
372
373  if (GetDebug())
374    Info("MakeLoader",
375         "Creating standard getter for detector %s. Top folder is %s.",
376          GetName(),topfoldername);
377      
378  fLoader   = new AliLoader(GetName(),topfoldername);
379  fMUONData = new AliMUONData(fLoader,GetName(),GetName()); 
380  fMUONData->SetSplitLevel(fSplitLevel);
381  return fLoader;
382 }
383
384 //_______________________________________________________________________
385 void AliMUON::Trigger(Int_t nev){
386 // call the Trigger Algorithm and fill TreeR
387
388   Int_t singlePlus[3]  = {0,0,0}; 
389   Int_t singleMinus[3] = {0,0,0}; 
390   Int_t singleUndef[3] = {0,0,0};
391   Int_t pairUnlike[3]  = {0,0,0}; 
392   Int_t pairLike[3]    = {0,0,0};
393   
394   ResetTrigger();
395   AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
396   decision->Trigger();   
397   decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef,
398                              pairUnlike, pairLike);
399   
400   // add a local trigger in the list 
401   GetMUONData()->AddGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
402   Int_t i;
403   
404   for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) { 
405     if(decision->GetITrigger(icirc)==1) {
406       Int_t localtr[7]={0,0,0,0,0,0,0};      
407       Int_t loLpt[2]={0,0}; Int_t loHpt[2]={0,0}; Int_t loApt[2]={0,0};
408       decision->GetLutOutput(icirc, loLpt, loHpt, loApt);
409       localtr[0] = icirc;
410       localtr[1] = decision->GetStripX11(icirc);
411       localtr[2] = decision->GetDev(icirc);
412       localtr[3] = decision->GetStripY11(icirc);
413       for (i=0; i<2; i++) {    // convert the Lut output in 1 digit 
414         localtr[4] = localtr[4]+Int_t(loLpt[i]*TMath::Power(2,i));
415         localtr[5] = localtr[5]+Int_t(loHpt[i]*TMath::Power(2,i));
416         localtr[6] = localtr[6]+Int_t(loApt[i]*TMath::Power(2,i));
417       }
418       GetMUONData()->AddLocalTrigger(localtr);  // add a local trigger in the list
419     }
420   }
421   
422   delete decision;
423
424   //  fLoader->TreeR()->Fill();
425   GetMUONData()->Fill("GLT"); //Filling Global and Local Trigger GLT
426   //  char hname[30];
427   //  sprintf(hname,"TreeR%d",nev);
428   //  fLoader->TreeR()->Write(hname,TObject::kOverwrite);
429     //  fLoader->TreeR()->Reset();
430   fLoader->WriteRecPoints("OVERWRITE");
431   
432   printf("\n End of trigger for event %d", nev);
433 }
434
435 //____________________________________________________________________
436 void AliMUON::Digits2Reco()
437 {
438   FindClusters();
439   Int_t nev = gAlice->GetHeader()->GetEvent();
440   GetMUONData()->Fill("RC"); //Filling Reconstructed Cluster
441   fLoader->WriteRecPoints("OVERWRITE");
442   GetMUONData()->ResetRawClusters();        
443   Info("Digits2Reco","End of cluster finding for event %d", nev);
444 }
445 //____________________________________________________________________
446 void AliMUON::FindClusters()
447 {
448 //
449 //  Perform cluster finding
450 //
451     TClonesArray *dig1, *dig2;
452     Int_t ndig, k;
453     dig1 = new TClonesArray("AliMUONDigit",1000);
454     dig2 = new TClonesArray("AliMUONDigit",1000);
455     AliMUONDigit *digit;
456 // Loop on chambers and on cathode planes
457 //
458     ResetRawClusters();        
459     TClonesArray * muonDigits;
460
461     for (Int_t ich = 0; ich < 10; ich++) {
462       //PH      AliMUONChamber* iChamber = (AliMUONChamber*) (*fChambers)[ich];
463         AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
464         AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
465     
466         ResetDigits();
467         GetMUONData()->GetCathode(0);
468         //TClonesArray *
469         muonDigits = GetMUONData()->Digits(ich); 
470         ndig=muonDigits->GetEntriesFast();
471         printf("\n 1 Found %d digits in %p chamber %d", ndig, muonDigits,ich);
472         TClonesArray &lhits1 = *dig1;
473         Int_t n = 0;
474         for (k = 0; k < ndig; k++) {
475             digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
476             if (rec->TestTrack(digit->Track(0)))
477                 new(lhits1[n++]) AliMUONDigit(*digit);
478         }
479         GetMUONData()->ResetDigits();
480         GetMUONData()->GetCathode(1);
481         muonDigits =  GetMUONData()->Digits(ich);  
482         ndig=muonDigits->GetEntriesFast();
483         printf("\n 2 Found %d digits in %p %d", ndig, muonDigits, ich);
484         TClonesArray &lhits2 = *dig2;
485         n=0;
486         
487         for (k=0; k<ndig; k++) {
488             digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
489             if (rec->TestTrack(digit->Track(0)))
490             new(lhits2[n++]) AliMUONDigit(*digit);
491         }
492
493         if (rec) {       
494             AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
495             rec->FindRawClusters();
496         }
497         dig1->Delete();
498         dig2->Delete();
499     } // for ich
500     delete dig1;
501     delete dig2;
502 }
503 //______________________________________________________________________
504 #ifdef never
505 void AliMUON::Streamer(TBuffer &R__b)_
506 {
507    // Stream an object of class AliMUON.
508       AliMUONChamber        *iChamber;
509       AliMUONTriggerCircuit *iTriggerCircuit;
510       AliSegmentation       *segmentation;
511       AliMUONResponse       *response;
512       TClonesArray          *digitsaddress;
513       TClonesArray          *rawcladdress;
514       Int_t i;
515       if (R__b.IsReading()) {
516           Version_t R__v = R__b.ReadVersion(); if (R__v) { }
517           AliDetector::Streamer(R__b);
518           R__b >> fNPadHits;
519           R__b >> fPadHits; // diff
520           R__b >> fNLocalTrigger;       
521           R__b >> fLocalTrigger;       
522           R__b >> fNGlobalTrigger;       
523           R__b >> fGlobalTrigger;   
524           R__b >> fDchambers;
525           R__b >> fRawClusters;
526           R__b.ReadArray(fNdch);
527           R__b.ReadArray(fNrawch);
528           R__b >> fAccCut;
529           R__b >> fAccMin;
530           R__b >> fAccMax; 
531           R__b >> fChambers;
532           R__b >> fTriggerCircuits;
533           for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
534               iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
535               iTriggerCircuit->Streamer(R__b);
536           }
537 // Stream chamber related information
538           for (i =0; i<AliMUONConstants::NCh(); i++) {
539               iChamber=(AliMUONChamber*) (*fChambers)[i];
540               iChamber->Streamer(R__b);
541               if (iChamber->Nsec()==1) {
542                   segmentation=iChamber->SegmentationModel(1);
543                   if (segmentation)
544                       segmentation->Streamer(R__b);
545               } else {
546                   segmentation=iChamber->SegmentationModel(1);
547                   if (segmentation)
548                       segmentation->Streamer(R__b);
549                   if (segmentation)
550                       segmentation=iChamber->SegmentationModel(2);
551                   segmentation->Streamer(R__b);
552               }
553               response=iChamber->ResponseModel();
554               if (response)
555                   response->Streamer(R__b);       
556               digitsaddress=(TClonesArray*) (*fDchambers)[i];
557               digitsaddress->Streamer(R__b);
558               if (i < AliMUONConstants::NTrackingCh()) {
559                   rawcladdress=(TClonesArray*) (*fRawClusters)[i];
560                   rawcladdress->Streamer(R__b);
561               }
562           }
563           
564       } else {
565           R__b.WriteVersion(AliMUON::IsA());
566           AliDetector::Streamer(R__b);
567           R__b << fNPadHits;
568           R__b << fPadHits; // diff
569           R__b << fNLocalTrigger;       
570           R__b << fLocalTrigger;       
571           R__b << fNGlobalTrigger;       
572           R__b << fGlobalTrigger; 
573           R__b << fDchambers;
574           R__b << fRawClusters;
575           R__b.WriteArray(fNdch, AliMUONConstants::NCh());
576           R__b.WriteArray(fNrawch, AliMUONConstants::NTrackingCh());
577           
578           R__b << fAccCut;
579           R__b << fAccMin;
580           R__b << fAccMax; 
581           
582           R__b << fChambers;
583           R__b << fTriggerCircuits;
584           for (i =0; i<AliMUONConstants::NTriggerCircuit(); i++) {
585               iTriggerCircuit=(AliMUONTriggerCircuit*) (*fTriggerCircuits)[i];
586               iTriggerCircuit->Streamer(R__b);
587           }
588           for (i =0; i<AliMUONConstants::NCh(); i++) {
589               iChamber=(AliMUONChamber*) (*fChambers)[i];
590               iChamber->Streamer(R__b);
591               if (iChamber->Nsec()==1) {
592                   segmentation=iChamber->SegmentationModel(1);
593                   if (segmentation)
594                       segmentation->Streamer(R__b);
595               } else {
596                   segmentation=iChamber->SegmentationModel(1);
597                   if (segmentation)
598                       segmentation->Streamer(R__b);
599                   segmentation=iChamber->SegmentationModel(2);
600                   if (segmentation)
601                       segmentation->Streamer(R__b);
602               }
603               response=iChamber->ResponseModel();
604               if (response)
605                   response->Streamer(R__b);
606               digitsaddress=(TClonesArray*) (*fDchambers)[i];
607               digitsaddress->Streamer(R__b);
608               if (i < AliMUONConstants::NTrackingCh()) {
609                   rawcladdress=(TClonesArray*) (*fRawClusters)[i];
610                   rawcladdress->Streamer(R__b);
611               }
612           }
613       }
614 }
615 #endif
616 //_______________________________________________________________________
617 AliMUONPadHit* AliMUON::FirstPad(AliMUONHit*  hit, TClonesArray *clusters) 
618 {
619 // to be removed
620     // Initialise the pad iterator
621     // Return the address of the first padhit for hit
622     TClonesArray *theClusters = clusters;
623     Int_t nclust = theClusters->GetEntriesFast();
624     if (nclust && hit->PHlast() > 0) {
625         AliMUON::fMaxIterPad=hit->PHlast();
626         AliMUON::fCurIterPad=hit->PHfirst();
627         return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
628     } else {
629         return 0;
630     }
631 }
632 //_______________________________________________________________________
633 AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters) 
634 {
635   // To be removed
636 // Get next pad (in iterator) 
637 //
638     AliMUON::fCurIterPad++;
639     if (AliMUON::fCurIterPad <= AliMUON::fMaxIterPad) {
640         return (AliMUONPadHit*) clusters->UncheckedAt(AliMUON::fCurIterPad-1);
641     } else {
642         return 0;
643     }
644 }
645 //_______________________________________________________________________
646
647 AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
648 {
649 //
650 //  Return rawcluster (icluster) for chamber ichamber and cathode icathod
651 //  Obsolete ??
652     TClonesArray *muonRawCluster  = GetMUONData()->RawClusters(ichamber);
653     ResetRawClusters();
654     TTree *treeR = fLoader->TreeR();
655     Int_t nent=(Int_t)treeR->GetEntries();
656     treeR->GetEvent(nent-2+icathod-1);
657     //treeR->GetEvent(icathod);
658     //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
659
660     AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
661     //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
662     
663     return  mRaw;
664 }
665 //________________________________________________________________________
666 void   AliMUON::SetMerger(AliMUONMerger* merger)
667 {
668 // Set pointer to merger 
669     fMerger = merger;
670 }
671 //________________________________________________________________________
672 AliMUONMerger*  AliMUON::Merger()
673 {
674 // Return pointer to merger
675     return fMerger;
676 }
677 //________________________________________________________________________
678 AliMUON& AliMUON::operator = (const AliMUON& /*rhs*/)
679 {
680 // copy operator
681 // dummy version
682     return *this;
683 }
684