]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONv1.cxx
Optimization of code (Christian)
[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 "AliMUONFactoryV2.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     fStepManagerVersionDE(kFALSE),
52     fAngleEffect(kTRUE),
53     fStepMaxInActiveGas(0.6),
54     fStepSum(0x0),
55     fDestepSum(0x0),
56     fTrackMomentum(), 
57     fTrackPosition(),
58     fElossRatio(0x0),
59     fAngleEffect10(0x0),
60     fAngleEffectNorma(0x0)
61 {
62 // Default constructor
63
64
65 //___________________________________________
66 AliMUONv1::AliMUONv1(const char *name, const char *title)
67   : AliMUON(name,title), 
68     fStepManagerVersionOld(kFALSE),
69     fStepManagerVersionDE(kFALSE),
70     fAngleEffect(kTRUE),
71     fStepMaxInActiveGas(0.6),
72     fStepSum(0x0),
73     fDestepSum(0x0),
74     fTrackMomentum(), 
75     fTrackPosition(),
76     fElossRatio(0x0),
77     fAngleEffect10(0x0),
78     fAngleEffectNorma(0x0)
79 {
80 // Standard onstructor
81
82     // By default include all stations
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    AliDebug(1,"Start Init for version 1 - CPC chamber type");
170    Int_t i;
171
172  
173    //
174    // Initialize geometry
175    //
176    fGeometryBuilder->InitGeometry();
177    AliDebug(1,"Finished Init for version 1 - CPC chamber type");   
178
179    fFactory = new AliMUONFactoryV2("New MUON Factory");
180    AliInfo("New Segmentation");
181
182
183    fFactory->Build(this, "default");
184
185    //
186    // Initialize segmentation
187    //
188
189    for (i=0; i<AliMUONConstants::NCh(); i++) 
190      ( (AliMUONChamber*) (*fChambers)[i])->Init(2);// new segmentation
191    
192  
193    // trigger circuit
194    // cp 
195    for (i=0; i<AliMUONConstants::NTriggerCircuit(); i++) 
196      ( (AliMUONTriggerCircuit*) (*fTriggerCircuits)[i])->Init(i);
197    
198
199
200
201
202 }
203
204 //__________________________________________________________________
205 Int_t  AliMUONv1::GetChamberId(Int_t volId) const
206 {
207 // Check if the volume with specified  volId is a sensitive volume (gas) 
208 // of some chamber and returns the chamber number;
209 // if not sensitive volume - return 0.
210 // ---
211
212 /*
213   for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
214     if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
215 */
216   for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
217     if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(volId) ) return i;
218
219   return 0;
220 }
221
222 //_______________________________________________________________________________
223 TString  AliMUONv1::CurrentVolumePath() const
224 {
225 // Returns current volume path
226 // (Could be removed when this function is available via gMC)
227 // ---       
228
229   TString path = "";
230   TString name;
231   Int_t copyNo;
232   Int_t imother = 0;
233   do {
234     name = gMC->CurrentVolOffName(imother);
235     gMC->CurrentVolOffID(imother++, copyNo);
236     TString add = "/";
237     add += name;
238     add += ".";
239     add += copyNo;
240     path.Insert(0,add); 
241   }
242   while ( name != TString("ALIC") );
243   
244   return path;  
245 }
246
247 //_______________________________________________________________________________
248 void AliMUONv1::StepManager()
249 {
250   // Stepmanager for the chambers
251   // TBR
252
253  if (fStepManagerVersionDE) {
254     StepManager2();
255     return;
256   }
257
258
259   // Only charged tracks
260   if( !(gMC->TrackCharge()) ) return; 
261   // Only charged tracks
262   
263   // Only gas gap inside chamber
264   // Tag chambers and record hits when track enters 
265   static Int_t   idvol=-1;
266   Int_t   iChamber=0;
267   Int_t   id=0;
268   Int_t   copy;
269   const  Float_t kBig = 1.e10;
270
271
272   //
273   // Only gas gap inside chamber
274   // Tag chambers and record hits when track enters 
275   id=gMC->CurrentVolID(copy);
276   iChamber = GetChamberId(id);
277   idvol = iChamber -1;
278
279   if (idvol == -1) return;
280
281   // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
282   if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )     
283     AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
284   
285    if( gMC->IsTrackEntering() ) {
286      Float_t theta = fTrackMomentum.Theta();
287      if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
288   }
289
290    //  AliDebug(1,
291    //    Form("Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber,
292    //    ( (AliMUONChamber*)(*fChambers)[idvol])->Z()));
293    // Particule id and mass, 
294   Int_t     ipart = gMC->TrackPid();
295   Float_t   mass  = gMC->TrackMass();
296
297   fDestepSum[idvol]+=gMC->Edep();
298   // Get current particle id (ipart), track position (pos)  and momentum (mom)
299   if ( fStepSum[idvol]==0.0 )  gMC->TrackMomentum(fTrackMomentum);
300   fStepSum[idvol]+=gMC->TrackStep();
301   
302   //  if(AliDebugLevel()) {
303   //  AliDebug(1,
304   //         Form("iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
305   //              iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg, 
306   //              mass, fStepSum[idvol], gMC->Edep()));
307   //  AliDebug(1,
308   //         Form("Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(), 
309   //              fTrackMomentum.Z()));
310   //  gMC->TrackPosition(fTrackPosition);
311   //  AliDebug(1,
312   //         Form("Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),
313   //      fTrackPosition.Z())) ;
314   //   }
315
316   // Track left chamber or StepSum larger than fStepMaxInActiveGas
317   if ( gMC->IsTrackExiting() || 
318        gMC->IsTrackStop() || 
319        gMC->IsTrackDisappeared()||
320        (fStepSum[idvol]>fStepMaxInActiveGas) ) {
321     
322     if   ( gMC->IsTrackExiting() || 
323            gMC->IsTrackStop() || 
324            gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
325
326     gMC->TrackPosition(fTrackPosition);
327     Float_t theta = fTrackMomentum.Theta();
328     Float_t phi   = fTrackMomentum.Phi();
329     
330     TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
331                                fStepSum[idvol]/2.*sin(theta)*sin(phi),
332                                fStepSum[idvol]/2.*cos(theta),0.0       );
333     //     AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),
334     //                     fTrackPosition.Y(),fTrackPosition.Z())) ;
335     //     AliDebug(1,Form("Exit: Track backToWire %f %f %f",backToWire.X(),
336     //                     backToWire.Y(),backToWire.Z()) ;
337     fTrackPosition-=backToWire;
338     
339     //-------------- Angle effect 
340     // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
341     
342     Float_t betaxGamma    = fTrackMomentum.P()/mass;//  pc/mc2
343     Float_t sigmaEffect10degrees;
344     Float_t sigmaEffectThetadegrees;
345     Float_t eLossParticleELossMip;
346     Float_t yAngleEffect=0.;
347     Float_t thetawires      =  TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
348
349
350     if (fAngleEffect){
351     if ( (betaxGamma >3.2)   &&  (thetawires*kRaddeg<=15.) ) {
352       betaxGamma=TMath::Log(betaxGamma);
353       eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
354       // 10 degrees is a reference for a model (arbitrary)
355       sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
356       // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
357       sigmaEffectThetadegrees =  sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg);  // For 5mm gap  
358       if ( (iChamber==1)  ||  (iChamber==2) )  
359         sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
360       yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
361     }
362     }
363     
364     // Detection elements ids
365     AliMUONGeometryModule* geometry
366       = Chamber(iChamber-1).GetGeometry();
367
368     AliMUONGeometryDetElement* detElement
369       = geometry->FindBySensitiveVolume(CurrentVolumePath());
370
371     Int_t detElemId = 0;
372     if (detElement) detElemId = detElement->GetUniqueID(); 
373  
374     if (!detElemId) {
375       cerr << "Chamber id: "
376            << setw(3) << iChamber << "  "
377            << "Current SV: " 
378            <<  CurrentVolumePath() 
379            << "  detElemId: "
380            << setw(5) << detElemId 
381            << endl;
382       Double_t x, y, z;
383       gMC->TrackPosition(x, y, z);         
384       cerr << "   global position: "
385            << x << ", " << y << ", " << z
386            << endl;
387       AliWarning("DetElemId not identified.");
388     }  
389     
390     // One hit per chamber
391     GetMUONData()->AddHit(fIshunt, 
392                           gAlice->GetMCApp()->GetCurrentTrackNumber(), 
393                           iChamber, ipart,
394                           fTrackPosition.X(), 
395                           fTrackPosition.Y()+yAngleEffect, 
396                           fTrackPosition.Z(), 
397                           gMC->TrackTime(),
398                           fTrackMomentum.P(),
399                           theta, 
400                           phi, 
401                           fStepSum[idvol], 
402                           fDestepSum[idvol],                        
403                           fTrackPosition.X(),
404                           fTrackPosition.Y(),
405                           fTrackPosition.Z());
406
407 //     if (AliDebugLevel()){
408 //       AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber));
409 //       AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]));
410 //       AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z())) ;
411 //     }
412     fStepSum[idvol]  =0; // Reset for the next event
413     fDestepSum[idvol]=0; // Reset for the next event
414   }
415 }
416
417 //_______________________________________________________________________________
418 void AliMUONv1::StepManager2()
419 {
420   // Stepmanager for the chambers
421
422   // Only charged tracks
423   if( !(gMC->TrackCharge()) ) return; 
424   // Only charged tracks
425   
426   // Only gas gap inside chamber
427   // Tag chambers and record hits when track enters 
428   static Int_t   idvol=-1;
429   Int_t   iChamber=0;
430   Int_t   id=0;
431   Int_t   copy;
432   const  Float_t kBig = 1.e10;
433
434
435   //
436   // Only gas gap inside chamber
437   // Tag chambers and record hits when track enters 
438   id=gMC->CurrentVolID(copy);
439   iChamber = GetChamberId(id);
440   idvol = iChamber -1;
441
442   if (idvol == -1) return;
443   
444   // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
445   if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )     
446     AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
447   
448    if( gMC->IsTrackEntering() ) {
449      Float_t theta = fTrackMomentum.Theta();
450      if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
451   }
452
453    //   AliDebug(1,
454    //       Form("Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber,
455    //            ( (AliMUONChamber*)(*fChambers)[idvol])->Z())) ;
456   // Particule id and mass, 
457   Int_t     ipart = gMC->TrackPid();
458   Float_t   mass  = gMC->TrackMass();
459
460   fDestepSum[idvol]+=gMC->Edep();
461   // Get current particle id (ipart), track position (pos)  and momentum (mom)
462   if ( fStepSum[idvol]==0.0 )  gMC->TrackMomentum(fTrackMomentum);
463   fStepSum[idvol]+=gMC->TrackStep();
464   
465   //  if (AliDebugLevel()) {
466   //   AliDebug(1,Form("Step, iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
467   //                 iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg,
468   //         mass, fStepSum[idvol], gMC->Edep()));
469   // AliDebug(1,Form("Step:Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(), 
470   //         fTrackMomentum.Z()));
471   // gMC->TrackPosition(fTrackPosition);
472   // AliDebug(1,Form("Step: Track Position %f %f %f",fTrackPosition.X(),
473   //         fTrackPosition.Y(),fTrackPosition.Z())) ;
474   //}
475
476   // Track left chamber or StepSum larger than fStepMaxInActiveGas
477   if ( gMC->IsTrackExiting() || 
478        gMC->IsTrackStop() || 
479        gMC->IsTrackDisappeared()||
480        (fStepSum[idvol]>fStepMaxInActiveGas) ) {
481     
482     if   ( gMC->IsTrackExiting() || 
483            gMC->IsTrackStop() || 
484            gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
485
486     gMC->TrackPosition(fTrackPosition);
487     Float_t theta = fTrackMomentum.Theta();
488     Float_t phi   = fTrackMomentum.Phi();
489     
490     TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
491                                fStepSum[idvol]/2.*sin(theta)*sin(phi),
492                                fStepSum[idvol]/2.*cos(theta),0.0       );
493     //    AliDebug(1,
494     //       Form("Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()));
495     // AliDebug(1,
496     //       Form("Exit: Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z())) ;
497     fTrackPosition-=backToWire;
498     
499     //-------------- Angle effect 
500     // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
501     
502     Float_t betaxGamma    = fTrackMomentum.P()/mass;//  pc/mc2
503     Float_t sigmaEffect10degrees;
504     Float_t sigmaEffectThetadegrees;
505     Float_t eLossParticleELossMip;
506     Float_t yAngleEffect=0.;
507     Float_t thetawires      =  TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
508
509
510     if (fAngleEffect){
511     if ( (betaxGamma >3.2)   &&  (thetawires*kRaddeg<=15.) ) {
512       betaxGamma=TMath::Log(betaxGamma);
513       eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
514       // 10 degrees is a reference for a model (arbitrary)
515       sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
516       // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
517       sigmaEffectThetadegrees =  sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg);  // For 5mm gap  
518       if ( (iChamber==1)  ||  (iChamber==2) )  
519         sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
520       yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
521     }
522     }
523     
524     // Detection elements ids
525     AliMUONGeometryModule* geometry
526       = Chamber(iChamber-1).GetGeometry();
527
528     AliMUONGeometryDetElement* detElement
529       = geometry->FindBySensitiveVolume(CurrentVolumePath());
530
531     Int_t detElemId = 0;
532     if (detElement) detElemId = detElement->GetUniqueID(); 
533  
534     if (!detElemId) {
535       cerr << "Chamber id: "
536            << setw(3) << iChamber << "  "
537            << "Current SV: " 
538            <<  CurrentVolumePath() 
539            << "  detElemId: "
540            << setw(5) << detElemId 
541            << endl;
542       Double_t x, y, z;
543       gMC->TrackPosition(x, y, z);         
544       cerr << "   global position: "
545            << x << ", " << y << ", " << z
546            << endl;
547       AliError("DetElemId not identified.");
548     }  
549     
550     // One hit per chamber
551     GetMUONData()->AddHit2(fIshunt, 
552                           gAlice->GetMCApp()->GetCurrentTrackNumber(), 
553                           detElemId, ipart,
554                           fTrackPosition.X(), 
555                           fTrackPosition.Y()+yAngleEffect, 
556                           fTrackPosition.Z(), 
557                           gMC->TrackTime(),
558                           fTrackMomentum.P(),
559                           theta, 
560                           phi, 
561                           fStepSum[idvol], 
562                           fDestepSum[idvol],                        
563                           fTrackPosition.X(),
564                           fTrackPosition.Y(),
565                           fTrackPosition.Z());
566
567     //       AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber));
568     //       AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]));
569     //       AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
570
571     fStepSum[idvol]  =0; // Reset for the next event
572     fDestepSum[idvol]=0; // Reset for the next event
573   }
574 }