]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONv1.cxx
7bed63f12b6e1f6c245f8e48b4b930232efbd357
[u/mrichter/AliRoot.git] / MUON / AliMUONv1.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *      SigmaEffect_thetadegrees                                                                  *
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 purpeateose. It is      *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 /////////////////////////////////////////////////////////
19 //  Manager and hits classes for set:MUON version 1    //
20 /////////////////////////////////////////////////////////
21
22 #include <TRandom.h>
23 #include <TF1.h>
24 #include <TClonesArray.h>
25 #include <TRandom.h> 
26 #include <TVirtualMC.h>
27 #include <TGeoMatrix.h>
28
29 #include "AliMUONv1.h"
30 #include "AliConst.h" 
31 #include "AliMUONChamber.h"
32 #include "AliMUONConstants.h"
33 #include "AliMUONFactory.h"
34 #include "AliMUONHit.h"
35 #include "AliMUONTriggerCircuit.h"
36 #include "AliMUONGeometryBuilder.h"     
37 #include "AliMUONGeometryModule.h"      
38 #include "AliMUONGeometrySVMap.h"       
39 #include "AliMUONGeometryDetElement.h"  
40 #include "AliMagF.h"
41 #include "AliRun.h"
42 #include "AliMC.h"
43 #include "AliLog.h"
44
45 ClassImp(AliMUONv1)
46  
47 //___________________________________________
48 AliMUONv1::AliMUONv1() 
49   : AliMUON(),
50     fStepManagerVersionOld(kFALSE),
51     fAngleEffect(kTRUE),
52     fStepMaxInActiveGas(0.6),
53     fStepSum(0x0),
54     fDestepSum(0x0),
55     fTrackMomentum(), 
56     fTrackPosition(),
57     fElossRatio(0x0),
58     fAngleEffect10(0x0),
59     fAngleEffectNorma(0x0)
60 {
61 // Default constructor
62
63
64 //___________________________________________
65 AliMUONv1::AliMUONv1(const char *name, const char *title)
66   : AliMUON(name,title), 
67     fStepManagerVersionOld(kFALSE),
68     fAngleEffect(kTRUE),
69     fStepMaxInActiveGas(0.6),
70     fStepSum(0x0),
71     fDestepSum(0x0),
72     fTrackMomentum(), 
73     fTrackPosition(),
74     fElossRatio(0x0),
75     fAngleEffect10(0x0),
76     fAngleEffectNorma(0x0)
77 {
78 // Standard onstructor
79
80     // By default include all stations
81     AliMUONFactory factory;
82     factory.Build(this, title);
83
84     fStepSum   = new Float_t [AliMUONConstants::NCh()];
85     fDestepSum = new Float_t [AliMUONConstants::NCh()];
86     for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
87       fStepSum[i] =0.0;
88       fDestepSum[i]=0.0;
89     }
90     // Ratio of particle mean eloss with respect MIP's Khalil Boudjemline, sep 2003, PhD.Thesis and Particle Data Book
91     fElossRatio = new TF1("ElossRatio","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",0.5,5.); 
92     fElossRatio->SetParameter(0,1.02138);
93     fElossRatio->SetParameter(1,-9.54149e-02);
94     fElossRatio->SetParameter(2,+7.83433e-02); 
95     fElossRatio->SetParameter(3,-9.98208e-03);
96     fElossRatio->SetParameter(4,+3.83279e-04);
97
98     // Angle effect in tracking chambers at theta =10 degres as a function of ElossRatio (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis) (in micrometers)
99     fAngleEffect10 = new TF1("AngleEffect10","[0]+[1]*x+[2]*x*x",0.5,3.0);
100     fAngleEffect10->SetParameter(0, 1.90691e+02);
101     fAngleEffect10->SetParameter(1,-6.62258e+01);
102     fAngleEffect10->SetParameter(2,+1.28247e+01);
103     // Angle effect: Normalisation form theta=10 degres to theta between 0 and 10 (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis)  
104     // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
105     fAngleEffectNorma = new TF1("AngleEffectNorma","[0]+[1]*x+[2]*x*x+[3]*x*x*x",0.0,10.0);
106     fAngleEffectNorma->SetParameter(0,4.148);
107     fAngleEffectNorma->SetParameter(1,-6.809e-01);
108     fAngleEffectNorma->SetParameter(2,5.151e-02);
109     fAngleEffectNorma->SetParameter(3,-1.490e-03);
110 }
111
112 //_____________________________________________________________________________
113 AliMUONv1::AliMUONv1(const AliMUONv1& right) 
114   : AliMUON(right) 
115 {  
116   // copy constructor (not implemented)
117
118   AliFatal("Copy constructor not provided.");
119 }
120
121 //___________________________________________
122 AliMUONv1::~AliMUONv1()
123 {
124 // Destructor
125
126   delete [] fStepSum;
127   delete [] fDestepSum;
128   delete fElossRatio;
129   delete fAngleEffect10;
130   delete fAngleEffectNorma;  
131 }
132
133 //_____________________________________________________________________________
134 AliMUONv1& AliMUONv1::operator=(const AliMUONv1& right)
135 {
136   // assignement operator (not implemented)
137
138   // check assignement to self
139   if (this == &right) return *this;
140
141   AliFatal("Assignement operator not provided.");
142     
143   return *this;  
144 }    
145
146 //__________________________________________________
147 void AliMUONv1::CreateGeometry()
148 {
149 //
150 // Construct geometry using geometry builder
151 //
152
153   fGeometryBuilder->CreateGeometry();
154 }
155
156 //________________________________________________________________
157 void AliMUONv1::CreateMaterials()
158 {
159 //
160 // Construct materials using geometry builder
161 //
162
163   fGeometryBuilder->CreateMaterials();
164 }
165
166 //___________________________________________
167 void AliMUONv1::Init()
168 {
169    // 
170    // Initialize Tracking Chambers
171    //
172    AliDebug(1,"Start Init for version 1 - CPC chamber type");
173    Int_t i;
174    for (i=0; i<AliMUONConstants::NCh(); i++) {
175        ( (AliMUONChamber*) (*fChambers)[i])->Init();
176    }
177    
178    //
179    // Initialize geometry
180    //
181    fGeometryBuilder->InitGeometry();
182    AliDebug(1,"Finished Init for version 1 - CPC chamber type");
183
184    //cp 
185    AliDebug(1,"Start Init for Trigger Circuits");
186    for (i=0; i<AliMUONConstants::NTriggerCircuit(); i++) {
187      ( (AliMUONTriggerCircuit*) (*fTriggerCircuits)[i])->Init(i);
188    }
189    AliDebug(1,"Finished Init for Trigger Circuits");
190    //cp
191
192    //
193    // Debug info
194    //
195      // Print transformations and SV map
196      for (i=0; i<AliMUONConstants::NCh(); i++) {
197  
198        AliDebug(2,Form("Chamber: %d \n" , i+1 ));
199        AliDebug(2,"===================\n"); 
200      
201        // To do - move PrintLocalTransforms to geometryModule
202        //Chamber(i).GetGeometry()
203        //          ->GetDetElementStore()->PrintLocalTransforms();
204  
205        if (GetDebug() >1) Chamber(i).GetGeometry()->GetSVMap()->Print("");
206      }
207      AliDebug(2,"\n"); 
208 }
209
210 //__________________________________________________________________
211 Int_t  AliMUONv1::GetChamberId(Int_t volId) const
212 {
213 // Check if the volume with specified  volId is a sensitive volume (gas) 
214 // of some chamber and returns the chamber number;
215 // if not sensitive volume - return 0.
216 // ---
217
218 /*
219   for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
220     if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
221 */
222   for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
223     if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(volId) ) return i;
224
225   return 0;
226 }
227
228 //_______________________________________________________________________________
229 TString  AliMUONv1::CurrentVolumePath() const
230 {
231 // Returns current volume path
232 // (Could be removed when this function is available via gMC)
233 // ---       
234
235   TString path = "";
236   TString name;
237   Int_t copyNo;
238   Int_t imother = 0;
239   do {
240     name = gMC->CurrentVolOffName(imother);
241     gMC->CurrentVolOffID(imother++, copyNo);
242     TString add = "/";
243     add += name;
244     add += ".";
245     add += copyNo;
246     path.Insert(0,add); 
247   }
248   while ( name != TString("ALIC") );
249   
250   return path;  
251 }
252
253 //_______________________________________________________________________________
254 void AliMUONv1::StepManager()
255 {
256   // Stepmanager for the chambers
257
258  if (fStepManagerVersionOld) {
259     StepManagerOld();
260     return;
261   }
262
263   // Only charged tracks
264   if( !(gMC->TrackCharge()) && !(gMC->TrackPid()==0) ) return; 
265   // Only charged tracks
266   
267   // Only gas gap inside chamber
268   // Tag chambers and record hits when track enters 
269   static Int_t   idvol=-1;
270   Int_t   iChamber=0;
271   Int_t   id=0;
272   Int_t   copy;
273   const  Float_t kBig = 1.e10;
274
275
276   //
277   // Only gas gap inside chamber
278   // Tag chambers and record hits when track enters 
279   id=gMC->CurrentVolID(copy);
280   iChamber = GetChamberId(id);
281   idvol = iChamber -1;
282
283   if (idvol == -1) return;
284   
285   if (GetDebug() > 1) {
286     // Fill the global position of detection elements
287     // Only for verification 
288     AliMUONGeometrySVMap* svMap
289       =  Chamber(iChamber-1).GetGeometry()->GetSVMap();
290     Double_t x, y, z;
291     gMC->TrackPosition(x, y, z);           
292     svMap->AddPosition(CurrentVolumePath(), TGeoTranslation(x, y, z));
293   }   
294   
295   if (gMC->TrackPid()==0) return;
296
297   // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
298   if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )     
299     AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
300   
301    if( gMC->IsTrackEntering() ) {
302      Float_t theta = fTrackMomentum.Theta();
303      if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
304   }
305
306 //  if (GetDebug()) {
307 //     Float_t z = ( (AliMUONChamber*)(*fChambers)[idvol])->Z() ;
308 //      Info("StepManager Step","Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber, z);
309 //   }  
310   // Particule id and mass, 
311   Int_t     ipart = gMC->TrackPid();
312   Float_t   mass  = gMC->TrackMass();
313
314   fDestepSum[idvol]+=gMC->Edep();
315   // Get current particle id (ipart), track position (pos)  and momentum (mom)
316   if ( fStepSum[idvol]==0.0 )  gMC->TrackMomentum(fTrackMomentum);
317   fStepSum[idvol]+=gMC->TrackStep();
318   
319 //   if (GetDebug()) {
320 //     Info("StepManager Step","iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
321 //       iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg, mass, fStepSum[idvol], gMC->Edep());//     Info("StepManager Step","Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(), fTrackMomentum.Z()) ;
322 //     gMC->TrackPosition(fTrackPosition);
323 //     Info("StepManager Step","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
324 //   }
325
326   // Track left chamber or StepSum larger than fStepMaxInActiveGas
327   if ( gMC->IsTrackExiting() || 
328        gMC->IsTrackStop() || 
329        gMC->IsTrackDisappeared()||
330        (fStepSum[idvol]>fStepMaxInActiveGas) ) {
331     
332     if   ( gMC->IsTrackExiting() || 
333            gMC->IsTrackStop() || 
334            gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
335
336     gMC->TrackPosition(fTrackPosition);
337     Float_t theta = fTrackMomentum.Theta();
338     Float_t phi   = fTrackMomentum.Phi();
339     
340     TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
341                                fStepSum[idvol]/2.*sin(theta)*sin(phi),
342                                fStepSum[idvol]/2.*cos(theta),0.0       );
343     //     if (GetDebug()) 
344     //       Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
345     //     if (GetDebug()) 
346     //        Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ;
347     fTrackPosition-=backToWire;
348     
349     //-------------- Angle effect 
350     // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
351     
352     Float_t betaxGamma    = fTrackMomentum.P()/mass;//  pc/mc2
353     Float_t sigmaEffect10degrees;
354     Float_t sigmaEffectThetadegrees;
355     Float_t eLossParticleELossMip;
356     Float_t yAngleEffect=0.;
357     Float_t thetawires      =  TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
358
359
360     if (fAngleEffect){
361     if ( (betaxGamma >3.2)   &&  (thetawires*kRaddeg<=15.) ) {
362       betaxGamma=TMath::Log(betaxGamma);
363       eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
364       // 10 degrees is a reference for a model (arbitrary)
365       sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
366       // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
367       sigmaEffectThetadegrees =  sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg);  // For 5mm gap  
368       if ( (iChamber==1)  ||  (iChamber==2) )  
369         sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
370       yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
371     }
372     }
373     
374     // Detection elements ids
375     AliMUONGeometryModule* geometry
376       = Chamber(iChamber-1).GetGeometry();
377
378     AliMUONGeometryDetElement* detElement
379       = geometry->FindBySensitiveVolume(CurrentVolumePath());
380
381     Int_t detElemId = 0;
382     if (detElement) detElemId = detElement->GetUniqueID(); 
383  
384     if (!detElemId) {
385       cerr << "Chamber id: "
386            << setw(3) << iChamber << "  "
387            << "Current SV: " 
388            <<  CurrentVolumePath() 
389            << "  detElemId: "
390            << setw(5) << detElemId 
391            << endl;
392       Double_t x, y, z;
393       gMC->TrackPosition(x, y, z);         
394       cerr << "   global position: "
395            << x << ", " << y << ", " << z
396            << endl;
397       AliWarning("DetElemId not identified.");
398     }  
399     
400     // One hit per chamber
401     GetMUONData()->AddHit(fIshunt, 
402                           gAlice->GetMCApp()->GetCurrentTrackNumber(), 
403                           iChamber, ipart,
404                           fTrackPosition.X(), 
405                           fTrackPosition.Y()+yAngleEffect, 
406                           fTrackPosition.Z(), 
407                           gMC->TrackTime(),
408                           fTrackMomentum.P(),
409                           theta, 
410                           phi, 
411                           fStepSum[idvol], 
412                           fDestepSum[idvol],                        
413                           fTrackPosition.X(),
414                           fTrackPosition.Y(),
415                           fTrackPosition.Z());
416
417 //     if (GetDebug()){
418 //       Info("StepManager Exit","Particle exiting from chamber %d",iChamber);
419 //       Info("StepManager Exit","StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]);
420 //       Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
421 //     }
422     fStepSum[idvol]  =0; // Reset for the next event
423     fDestepSum[idvol]=0; // Reset for the next event
424   }
425 }
426
427 //__________________________________________
428 void AliMUONv1::StepManagerOld()
429 {
430   // Old Stepmanager for the chambers
431   Int_t          copy, id;
432   static Int_t   idvol =-1;
433   static Int_t   vol[2];
434   Int_t          ipart;
435   TLorentzVector pos;
436   TLorentzVector mom;
437   Float_t        theta,phi;
438   Float_t        destep, step;
439   
440   static Float_t sstep;
441   static Float_t eloss, eloss2, xhit, yhit, zhit, tof, tlength;
442   const  Float_t kBig = 1.e10;
443   static Float_t hits[15];
444
445   TClonesArray &lhits = *fHits;
446
447   //
448   //
449   // Only charged tracks
450   if( !(gMC->TrackCharge()) ) return; 
451   //
452   // Only gas gap inside chamber
453   // Tag chambers and record hits when track enters 
454   id=gMC->CurrentVolID(copy);
455   vol[0] = GetChamberId(id);
456   idvol = vol[0] -1;
457
458   if (idvol == -1) return;
459
460   //
461   // Get current particle id (ipart), track position (pos)  and momentum (mom) 
462   gMC->TrackPosition(pos);
463   gMC->TrackMomentum(mom);
464
465   ipart  = gMC->TrackPid();
466
467   //
468   // momentum loss and steplength in last step
469   destep = gMC->Edep();
470   step   = gMC->TrackStep();
471   // cout<<"------------"<<step<<endl;
472   //
473   // record hits when track enters ...
474   if( gMC->IsTrackEntering()) {
475
476       gMC->SetMaxStep(fMaxStepGas);
477       Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
478       Double_t rt = TMath::Sqrt(tc);
479       Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
480       Double_t tx = mom[0]/pmom;
481       Double_t ty = mom[1]/pmom;
482       Double_t tz = mom[2]/pmom;
483       Double_t s  = ((AliMUONChamber*)(*fChambers)[idvol])
484           ->ResponseModel()
485           ->Pitch()/tz;
486       theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
487       phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
488       hits[0] = Float_t(ipart);         // Geant3 particle type
489       hits[1] = pos[0]+s*tx;            // X-position for hit
490       hits[2] = pos[1]+s*ty;            // Y-position for hit
491       hits[3] = pos[2]+s*tz;            // Z-position for hit
492       hits[4] = theta;                  // theta angle of incidence
493       hits[5] = phi;                    // phi angle of incidence 
494       hits[8] = 0;//PadHits does not exist anymore  (Float_t) fNPadHits;    // first padhit
495       hits[9] = -1;                     // last pad hit
496       hits[10] = mom[3];                // hit momentum P
497       hits[11] = mom[0];                // Px
498       hits[12] = mom[1];                // Py
499       hits[13] = mom[2];                // Pz
500       tof=gMC->TrackTime();
501       hits[14] = tof;                   // Time of flight
502       tlength  = 0;
503       eloss    = 0;
504       eloss2   = 0;
505       sstep=0;
506       xhit     = pos[0];
507       yhit     = pos[1];      
508       zhit     = pos[2];      
509       Chamber(idvol).ChargeCorrelationInit();
510       // Only if not trigger chamber
511
512 //       printf("---------------------------\n");
513 //       printf(">>>> Y =  %f \n",hits[2]);
514 //       printf("---------------------------\n");
515     
516       
517
518      //  if(idvol < AliMUONConstants::NTrackingCh()) {
519 //        //
520 //        //  Initialize hit position (cursor) in the segmentation model 
521 //        ((AliMUONChamber*) (*fChambers)[idvol])
522 //            ->SigGenInit(pos[0], pos[1], pos[2]);
523 //       } else {
524 //        //geant3->Gpcxyz();
525 //        //printf("In the Trigger Chamber #%d\n",idvol-9);
526 //       }
527   }
528   eloss2+=destep;
529   sstep+=step;
530
531   // cout<<sstep<<endl;
532
533   // 
534   // Calculate the charge induced on a pad (disintegration) in case 
535   //
536   // Mip left chamber ...
537   if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
538       gMC->SetMaxStep(kBig);
539       eloss   += destep;
540       tlength += step;
541       
542       Float_t x0,y0,z0;
543       Float_t localPos[3];
544       Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
545       gMC->Gmtod(globalPos,localPos,1); 
546
547       if(idvol < AliMUONConstants::NTrackingCh()) {
548 // tracking chambers
549           x0 = 0.5*(xhit+pos[0]);
550           y0 = 0.5*(yhit+pos[1]);
551           z0 = 0.5*(zhit+pos[2]);
552       } else {
553 // trigger chambers
554           x0 = xhit;
555           y0 = yhit;
556           z0 = 0.;
557       }
558       
559
560       //      if (eloss >0)  MakePadHits(x0,y0,z0,eloss,tof,idvol);
561       
562           
563       hits[6] = tlength;   // track length
564       hits[7] = eloss2;    // de/dx energy loss
565
566
567       //      if (fNPadHits > (Int_t)hits[8]) {
568       //          hits[8] = hits[8]+1;
569       //          hits[9] = 0: // PadHits does not exist anymore (Float_t) fNPadHits;
570       //}
571 //
572 //    new hit 
573       
574       new(lhits[fNhits++]) 
575           AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);
576       eloss = 0; 
577       //
578       // Check additional signal generation conditions 
579       // defined by the segmentation
580       // model (boundary crossing conditions)
581       // only for tracking chambers
582   } else if 
583       ((idvol < AliMUONConstants::NTrackingCh()) &&
584        ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
585   {
586       ((AliMUONChamber*) (*fChambers)[idvol])
587           ->SigGenInit(pos[0], pos[1], pos[2]);
588       
589       Float_t localPos[3];
590       Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
591       gMC->Gmtod(globalPos,localPos,1); 
592
593       eloss    += destep;
594
595       // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
596       //        MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
597       xhit     = pos[0];
598       yhit     = pos[1]; 
599       zhit     = pos[2];
600       eloss = 0;
601       tlength += step ;
602       //
603       // nothing special  happened, add up energy loss
604   } else {        
605       eloss   += destep;
606       tlength += step ;
607   }
608 }
609
610 //______________________________________________________________________________
611 void   AliMUONv1::FinishRun()
612 {
613 // Print debug info 
614 // ---
615
616   if (GetDebug() <= 1) return;
617
618   // Print the global positions of detection elements
619   for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
620
621     AliDebug(2,Form("Chamber: %d\n" , i+1 ));
622     AliDebug(2,"===================\n"); 
623      
624     AliMUONGeometrySVMap* svMap
625       = Chamber(i).GetGeometry()->GetSVMap();
626       
627     svMap->SortPositions();
628     svMap->PrintPositions();
629     svMap->ClearPositions();
630   }
631   AliDebug(2,"\n"); 
632 }