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