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