bc25ec3937a6a479ddc7c05acf4635de18ef7928
[u/mrichter/AliRoot.git] / RICH / AliRICHv1.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 /*
17   $Log$
18   Revision 1.3  2000/06/13 13:06:38  jbarbosa
19   Fixed compiling error for HP (multiple declaration)
20
21   Revision 1.2  2000/06/12 15:36:16  jbarbosa
22   Cleaned up version.
23
24   Revision 1.1  2000/06/09 15:00:31  jbarbosa
25   New full version. All parameters configurable.
26
27   Revision 1.9  2000/05/31 08:19:38  jbarbosa
28   Fixed bug in StepManager
29
30   Revision 1.8  2000/05/26 17:30:08  jbarbosa
31   Cerenkov angle now stored within cerenkov data structure.
32
33   Revision 1.7  2000/05/18 10:31:36  jbarbosa
34   Fixed positioning of spacers inside freon.
35   Fixed positioning of proximity gap
36   inside methane.
37   Fixed cut on neutral particles in the StepManager.
38
39   Revision 1.6  2000/04/28 11:51:58  morsch
40    Dimensions of arrays hits and Ckov_data corrected.
41
42   Revision 1.5  2000/04/19 13:28:46  morsch
43   Major changes in geometry (parametrised), materials (updated) and
44   step manager (diagnostics) (JB, AM)
45
46 */
47
48
49
50 //////////////////////////////////////////////////////////
51 //  Manager and hits classes for set: RICH full version //
52 //////////////////////////////////////////////////////////
53
54 #include <TTUBE.h>
55 #include <TNode.h> 
56 #include <TRandom.h> 
57 #include <TParticle.h> 
58
59 #include "AliRICHv1.h"
60 #include "AliRICHHit.h"
61 #include "AliRun.h"
62 #include "AliMC.h"
63 #include "iostream.h"
64 #include "AliCallf77.h"
65 #include "AliConst.h" 
66 #include "AliPDG.h" 
67 #include "TGeant3.h"
68
69 ClassImp(AliRICHv1)
70     
71 //___________________________________________
72 AliRICHv1::AliRICHv1() : AliRICHv0()
73 {
74
75 // Default constructor fo AliRICHvv1 (full version)
76
77     //fChambers = 0;
78 }
79
80 //___________________________________________
81 AliRICHv1::AliRICHv1(const char *name, const char *title)
82     : AliRICHv0(name,title)
83 {
84
85 // Full version of RICH with hits and diagnostics
86
87     fCkovNumber=0;
88     fFreonProd=0;
89   
90     fChambers = new TObjArray(kNCH);
91     for (Int_t i=0; i<kNCH; i++) {
92     
93         (*fChambers)[i] = new AliRICHChamber();  
94         
95     }
96 }
97
98 void AliRICHv1::Init()
99 {
100
101   printf("*********************************** RICH_INIT ***********************************\n");
102   printf("*                                                                               *\n");
103   printf("*                    AliRICHv1 Configurable version started                     *\n");
104   printf("*                                                                               *\n");
105
106   
107   AliRICHSegmentation*  segmentation;
108   AliRICHGeometry*  geometry;
109   AliRICHResponse*  response;
110
111
112     // 
113     // Initialize Tracking Chambers
114     //
115     for (Int_t i=1; i<kNCH; i++) {
116         //printf ("i:%d",i);
117         ( (AliRICHChamber*) (*fChambers)[i])->Init();  
118     }  
119     
120     //
121     // Set the chamber (sensitive region) GEANT identifier
122     
123     ((AliRICHChamber*)(*fChambers)[0])->SetGid(1);  
124     ((AliRICHChamber*)(*fChambers)[1])->SetGid(2);  
125     ((AliRICHChamber*)(*fChambers)[2])->SetGid(3);  
126     ((AliRICHChamber*)(*fChambers)[3])->SetGid(4);  
127     ((AliRICHChamber*)(*fChambers)[4])->SetGid(5);  
128     ((AliRICHChamber*)(*fChambers)[5])->SetGid(6);  
129     ((AliRICHChamber*)(*fChambers)[6])->SetGid(7); 
130
131     Float_t pos1[3]={0,471.8999,165.2599};
132     Chamber(0).SetChamberTransform(pos1[0],pos1[1],pos1[2],new TRotMatrix("rot993","rot993",90,0,70.69,90,19.30999,-90));
133
134     Float_t pos2[3]={171,470,0};
135     Chamber(1).SetChamberTransform(pos2[0],pos2[1],pos2[2],new TRotMatrix("rot994","rot994",90,-20,90,70,0,0));
136
137     Float_t pos3[3]={0,500,0};
138     Chamber(2).SetChamberTransform(pos3[0],pos3[1],pos3[2],new TRotMatrix("rot995","rot995",90,0,90,90,0,0));
139     
140     Float_t pos4[3]={-171,470,0};
141     Chamber(3).SetChamberTransform(pos4[0],pos4[1],pos4[2], new TRotMatrix("rot996","rot996",90,20,90,110,0,0));  
142
143     Float_t pos5[3]={161.3999,443.3999,-165.3};
144     Chamber(4).SetChamberTransform(pos5[0],pos5[1],pos5[2],new TRotMatrix("rot997","rot997",90,340,108.1999,70,18.2,70));
145
146     Float_t pos6[3]={0., 471.9, -165.3,};
147     Chamber(5).SetChamberTransform(pos6[0],pos6[1],pos6[2],new TRotMatrix("rot998","rot998",90,0,109.3099,90,19.30999,90));
148
149     Float_t pos7[3]={-161.399,443.3999,-165.3};
150     Chamber(6).SetChamberTransform(pos7[0],pos7[1],pos7[2],new TRotMatrix("rot999","rot999",90,20,108.1999,110,18.2,110));
151     
152     segmentation=Chamber(0).GetSegmentationModel(0);
153     geometry=Chamber(0).GetGeometryModel();
154     response=Chamber(0).GetResponseModel();
155     
156      
157     printf("*                            Pads            : %3dx%3d                          *\n",segmentation->Npx(),segmentation->Npy());
158     printf("*                            Pad size        : %5.2f x%5.2f mm2                 *\n",segmentation->Dpx(),segmentation->Dpy()); 
159     printf("*                            Gap Thickness   : %5.1f mm                         *\n",geometry->GetGapThickness());
160     printf("*                            Radiator Width  : %5.1f mm                         *\n",geometry->GetQuartzWidth());
161     printf("*                            Radiator Length : %5.1f mm                         *\n",geometry->GetQuartzLength());
162     printf("*                            Freon Thickness : %5.1f mm                         *\n",geometry->GetFreonThickness());
163     printf("*                            Charge Slope    : %5.1f ADC                        *\n",response->ChargeSlope());
164     printf("*                            Feedback Prob.  : %5.2f %%                          *\n",response->AlphaFeedback());
165     printf("*                                                                               *\n");
166     printf("*                                   Success!                                    *\n");
167     printf("*                                                                               *\n");
168     printf("*********************************************************************************\n");
169
170 }
171
172 //___________________________________________
173 void AliRICHv1::StepManager()
174 {
175
176 // Full Step Manager
177
178     Int_t          copy, id;
179     static Int_t   idvol;
180     static Int_t   vol[2];
181     Int_t          ipart;
182     static Float_t hits[18];
183     static Float_t ckovData[19];
184     TLorentzVector position;
185     TLorentzVector momentum;
186     Float_t        pos[3];
187     Float_t        mom[4];
188     Float_t        localPos[3];
189     Float_t        localMom[4];
190     Float_t        localTheta,localPhi;
191     Float_t        theta,phi;
192     Float_t        destep, step;
193     Float_t        ranf[2];
194     Int_t          nPads;
195     Float_t        coscerenkov;
196     static Float_t eloss, xhit, yhit, tlength;
197     const  Float_t kBig=1.e10;
198        
199     TClonesArray &lhits = *fHits;
200     TGeant3 *geant3 = (TGeant3*) gMC;
201     TParticle *current = (TParticle*)(*gAlice->Particles())[gAlice->CurrentTrack()];
202
203  //if (current->Energy()>1)
204    //{
205         
206     // Only gas gap inside chamber
207     // Tag chambers and record hits when track enters 
208     
209     idvol=-1;
210     id=gMC->CurrentVolID(copy);
211     Float_t cherenkovLoss=0;
212     //gAlice->KeepTrack(gAlice->CurrentTrack());
213     
214     gMC->TrackPosition(position);
215     pos[0]=position(0);
216     pos[1]=position(1);
217     pos[2]=position(2);
218     ckovData[1] = pos[0];                 // X-position for hit
219     ckovData[2] = pos[1];                 // Y-position for hit
220     ckovData[3] = pos[2];                 // Z-position for hit
221     //ckovData[11] = gAlice->CurrentTrack();
222
223     //AliRICH *RICH = (AliRICH *) gAlice->GetDetector("RICH"); 
224     
225     /********************Store production parameters for Cerenkov photons************************/ 
226 //is it a Cerenkov photon? 
227     if (gMC->TrackPid() == 50000050) {          
228
229       //if (gMC->VolId("GAP ")==gMC->CurrentVolID(copy))
230         //{                    
231           Float_t ckovEnergy = current->Energy();
232           //energy interval for tracking
233           if  (ckovEnergy > 5.6e-09 && ckovEnergy < 7.8e-09 )       
234             //if (ckovEnergy > 0)
235             {
236               if (gMC->IsTrackEntering()){                                     //is track entering?
237                 if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy))
238                   {                                                          //is it in freo?
239                     if (geant3->Gctrak()->nstep<1){                          //is it the first step?
240                       Int_t mother = current->GetFirstMother(); 
241                       
242                       //printf("Second Mother:%d\n",current->GetSecondMother());
243                       
244                       ckovData[10] = mother;
245                       ckovData[11] = gAlice->CurrentTrack();
246                       ckovData[12] = 1;             //Media where photon was produced 1->Freon, 2->Quarz
247                       fCkovNumber++;
248                       fFreonProd=1;
249                       //printf("Index: %d\n",fCkovNumber);
250                     }    //first step question
251                   }        //freo question
252                 
253                 if (geant3->Gctrak()->nstep<1){                                  //is it first step?
254                   if (gMC->VolId("QUAR")==gMC->CurrentVolID(copy))             //is it in quarz?
255                     {
256                       ckovData[12] = 2;
257                     }    //quarz question
258                 }        //first step question
259                 
260                 //printf("Before %d\n",fFreonProd);
261               }   //track entering question
262               
263               if (ckovData[12] == 1)                                        //was it produced in Freon?
264                 //if (fFreonProd == 1)
265                 {
266                   if (gMC->IsTrackEntering()){                                     //is track entering?
267                     //printf("Got in");
268                     if (gMC->VolId("META")==gMC->CurrentVolID(copy))                //is it in gap?      
269                       {
270                         //printf("Got in\n");
271                         gMC->TrackMomentum(momentum);
272                         mom[0]=momentum(0);
273                         mom[1]=momentum(1);
274                         mom[2]=momentum(2);
275                         mom[3]=momentum(3);
276                         // Z-position for hit
277                         
278                         
279                         /**************** Photons lost in second grid have to be calculated by hand************/ 
280                         
281                         Float_t cophi = TMath::Cos(TMath::ATan2(mom[0], mom[1]));
282                         Float_t t = (1. - .025 / cophi) * (1. - .05 /  cophi);
283                         gMC->Rndm(ranf, 1);
284                         //printf("grid calculation:%f\n",t);
285                         if (ranf[0] > t) {
286                           //geant3->StopTrack();
287                           ckovData[13] = 5;
288                           AddCerenkov(gAlice->CurrentTrack(),vol,ckovData);
289                           //printf("Lost one in grid\n");
290                         }
291                         /**********************************************************************************/
292                       }    //gap
293                     
294                     if (gMC->VolId("CSI ")==gMC->CurrentVolID(copy))             //is it in csi?      
295                       {
296                         gMC->TrackMomentum(momentum);
297                         mom[0]=momentum(0);
298                         mom[1]=momentum(1);
299                         mom[2]=momentum(2);
300                         mom[3]=momentum(3);
301                         
302                         /********* Photons lost by Fresnel reflection have to be calculated by hand********/ 
303                         /***********************Cerenkov phtons (always polarised)*************************/
304                         
305                         Float_t cophi = TMath::Cos(TMath::ATan2(mom[0], mom[1]));
306                         Float_t t = Fresnel(ckovEnergy*1e9,cophi,1);
307                         gMC->Rndm(ranf, 1);
308                         if (ranf[0] < t) {
309                           //geant3->StopTrack();
310                           ckovData[13] = 6;
311                           AddCerenkov(gAlice->CurrentTrack(),vol,ckovData);
312                           //printf("Lost by Fresnel\n");
313                         }
314                         /**********************************************************************************/
315                       }
316                   } //track entering?
317                   
318                   
319                   /********************Evaluation of losses************************/
320                   /******************still in the old fashion**********************/
321                   
322                   Int_t i1 = geant3->Gctrak()->nmec;            //number of physics mechanisms acting on the particle
323                   for (Int_t i = 0; i < i1; ++i) {
324                     //        Reflection loss 
325                     if (geant3->Gctrak()->lmec[i] == 106) {        //was it reflected
326                       ckovData[13]=10;
327                       if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy)) 
328                         ckovData[13]=1;
329                       if (gMC->CurrentVolID(copy) == gMC->VolId("QUAR")) 
330                         ckovData[13]=2;
331                       //geant3->StopTrack();
332                       AddCerenkov(gAlice->CurrentTrack(),vol,ckovData);
333                     } //reflection question
334                     
335                     
336                     //        Absorption loss 
337                     else if (geant3->Gctrak()->lmec[i] == 101) {              //was it absorbed?
338                       ckovData[13]=20;
339                       if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy)) 
340                         ckovData[13]=11;
341                       if (gMC->CurrentVolID(copy) == gMC->VolId("QUAR")) 
342                         ckovData[13]=12;
343                       if (gMC->CurrentVolID(copy) == gMC->VolId("META")) 
344                         ckovData[13]=13;
345                       if (gMC->CurrentVolID(copy) == gMC->VolId("GAP ")) 
346                         ckovData[13]=13;
347                       
348                       if (gMC->CurrentVolID(copy) == gMC->VolId("SRIC")) 
349                         ckovData[13]=15;
350                       
351                       //        CsI inefficiency 
352                       if (gMC->CurrentVolID(copy) == gMC->VolId("CSI ")) {
353                         ckovData[13]=16;
354                       }
355                       //geant3->StopTrack();
356                       AddCerenkov(gAlice->CurrentTrack(),vol,ckovData);
357                       //printf("Added cerenkov %d\n",fCkovNumber);
358                     } //absorption question 
359                     
360                     
361                     //        Photon goes out of tracking scope 
362                     else if (geant3->Gctrak()->lmec[i] == 30) {                 //is it below energy treshold?
363                       ckovData[13]=21;
364                       //geant3->StopTrack();
365                       AddCerenkov(gAlice->CurrentTrack(),vol,ckovData);
366                     }   // energy treshold question         
367                   }  //number of mechanisms cycle
368                   /**********************End of evaluation************************/
369                 } //freon production question
370             } //energy interval question
371         //}//inside the proximity gap question
372     } //cerenkov photon question
373       
374     /**************************************End of Production Parameters Storing*********************/ 
375     
376     
377     /*******************************Treat photons that hit the CsI (Ckovs and Feedbacks)************/ 
378     
379     if (gMC->TrackPid() == 50000050 || gMC->TrackPid() == 50000051) {
380       //printf("Cerenkov\n");
381         if (gMC->VolId("CSI ")==gMC->CurrentVolID(copy))
382         {
383             
384           if (gMC->Edep() > 0.){
385                 gMC->TrackPosition(position);
386                 gMC->TrackMomentum(momentum);
387                 pos[0]=position(0);
388                 pos[1]=position(1);
389                 pos[2]=position(2);
390                 mom[0]=momentum(0);
391                 mom[1]=momentum(1);
392                 mom[2]=momentum(2);
393                 mom[3]=momentum(3);
394                 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
395                 Double_t rt = TMath::Sqrt(tc);
396                 theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
397                 phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
398                 gMC->Gmtod(pos,localPos,1);                                                                    
399                 gMC->Gmtod(mom,localMom,2);
400                 
401                 gMC->CurrentVolOffID(2,copy);
402                 vol[0]=copy;
403                 idvol=vol[0]-1;
404
405                 //Int_t sector=((AliRICHChamber*) (*fChambers)[idvol])
406                         //->Sector(localPos[0], localPos[2]);
407                 //printf("Sector:%d\n",sector);
408
409                 /*if (gMC->TrackPid() == 50000051){
410                   fFeedbacks++;
411                   printf("Feedbacks:%d\n",fFeedbacks);
412                 }*/     
413                 
414                 ((AliRICHChamber*) (*fChambers)[idvol])
415                     ->SigGenInit(localPos[0], localPos[2], localPos[1]);
416                 if(idvol<kNCH) {        
417                     ckovData[0] = gMC->TrackPid();        // particle type
418                     ckovData[1] = pos[0];                 // X-position for hit
419                     ckovData[2] = pos[1];                 // Y-position for hit
420                     ckovData[3] = pos[2];                 // Z-position for hit
421                     ckovData[4] = theta;                      // theta angle of incidence
422                     ckovData[5] = phi;                      // phi angle of incidence 
423                     ckovData[8] = (Float_t) fNPadHits;      // first padhit
424                     ckovData[9] = -1;                       // last pad hit
425                     ckovData[13] = 4;                       // photon was detected
426                     ckovData[14] = mom[0];
427                     ckovData[15] = mom[1];
428                     ckovData[16] = mom[2];
429                     
430                     destep = gMC->Edep();
431                     gMC->SetMaxStep(kBig);
432                     cherenkovLoss  += destep;
433                     ckovData[7]=cherenkovLoss;
434                     
435                     nPads = MakePadHits(localPos[0],localPos[2],cherenkovLoss,idvol,kCerenkov);
436                     if (fNPadHits > (Int_t)ckovData[8]) {
437                         ckovData[8]= ckovData[8]+1;
438                         ckovData[9]= (Float_t) fNPadHits;
439                     }
440
441                     ckovData[17] = nPads;
442                     //printf("nPads:%d",nPads);
443                     
444                     //TClonesArray *Hits = RICH->Hits();
445                     AliRICHHit *mipHit =  (AliRICHHit*) (fHits->UncheckedAt(0));
446                     if (mipHit)
447                       {
448                         mom[0] = current->Px();
449                         mom[1] = current->Py();
450                         mom[2] = current->Pz();
451                         Float_t mipPx = mipHit->fMomX;
452                         Float_t mipPy = mipHit->fMomY;
453                         Float_t mipPz = mipHit->fMomZ;
454                         
455                         Float_t r = mom[0]*mom[0] + mom[1]*mom[1] + mom[2]*mom[2];
456                         Float_t rt = TMath::Sqrt(r);
457                         Float_t mipR = mipPx*mipPx + mipPy*mipPy + mipPz*mipPz; 
458                         Float_t mipRt = TMath::Sqrt(mipR);
459                         if ((rt*mipRt) > 0)
460                           {
461                             coscerenkov = (mom[0]*mipPx + mom[1]*mipPy + mom[2]*mipPz)/(rt*mipRt);
462                           }
463                         else
464                           {
465                             coscerenkov = 0;
466                           }
467                         Float_t cherenkov = TMath::ACos(coscerenkov);
468                         ckovData[18]=cherenkov;
469                       }
470                     //if (sector != -1)
471                     //{
472                     AddHit(gAlice->CurrentTrack(),vol,ckovData);
473                     AddCerenkov(gAlice->CurrentTrack(),vol,ckovData);
474                     //}
475                 }
476             }
477         }
478     }
479     
480     /***********************************************End of photon hits*********************************************/
481     
482
483     /**********************************************Charged particles treatment*************************************/
484
485     else if (gMC->TrackCharge())
486     //else if (1 == 1)
487       {
488 //If MIP
489         /*if (gMC->IsTrackEntering())
490           {                
491             hits[13]=20;//is track entering?
492           }*/
493         if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy))
494           {
495             fFreonProd=1;
496           }
497
498         if (gMC->VolId("GAP ")== gMC->CurrentVolID(copy)) {
499 // Get current particle id (ipart), track position (pos)  and momentum (mom)
500             
501             gMC->CurrentVolOffID(3,copy);
502             vol[0]=copy;
503             idvol=vol[0]-1;
504
505             //Int_t sector=((AliRICHChamber*) (*fChambers)[idvol])
506                         //->Sector(localPos[0], localPos[2]);
507             //printf("Sector:%d\n",sector);
508             
509             gMC->TrackPosition(position);
510             gMC->TrackMomentum(momentum);
511             pos[0]=position(0);
512             pos[1]=position(1);
513             pos[2]=position(2);
514             mom[0]=momentum(0);
515             mom[1]=momentum(1);
516             mom[2]=momentum(2);
517             mom[3]=momentum(3);
518             gMC->Gmtod(pos,localPos,1);                                                                    
519             gMC->Gmtod(mom,localMom,2);
520             
521             ipart  = gMC->TrackPid();
522             //
523             // momentum loss and steplength in last step
524             destep = gMC->Edep();
525             step   = gMC->TrackStep();
526   
527             //
528             // record hits when track enters ...
529             if( gMC->IsTrackEntering()) {
530 //              gMC->SetMaxStep(fMaxStepGas);
531                 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
532                 Double_t rt = TMath::Sqrt(tc);
533                 theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
534                 phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
535                 
536
537                 Double_t localTc = localMom[0]*localMom[0]+localMom[2]*localMom[2];
538                 Double_t localRt = TMath::Sqrt(localTc);
539                 localTheta   = Float_t(TMath::ATan2(localRt,Double_t(localMom[1])))*kRaddeg;                       
540                 localPhi     = Float_t(TMath::ATan2(Double_t(localMom[2]),Double_t(localMom[0])))*kRaddeg;    
541                 
542                 hits[0] = Float_t(ipart);         // particle type
543                 hits[1] = localPos[0];                 // X-position for hit
544                 hits[2] = localPos[1];                 // Y-position for hit
545                 hits[3] = localPos[2];                 // Z-position for hit
546                 hits[4] = localTheta;                  // theta angle of incidence
547                 hits[5] = localPhi;                    // phi angle of incidence 
548                 hits[8] = (Float_t) fNPadHits;    // first padhit
549                 hits[9] = -1;                     // last pad hit
550                 hits[13] = fFreonProd;           // did id hit the freon?
551                 hits[14] = mom[0];
552                 hits[15] = mom[1];
553                 hits[16] = mom[2];
554
555                 tlength = 0;
556                 eloss   = 0;
557                 fFreonProd = 0;
558         
559                 Chamber(idvol).LocaltoGlobal(localPos,hits+1);
560            
561                 
562                 //To make chamber coordinates x-y had to pass localPos[0], localPos[2]
563                 xhit    = localPos[0];
564                 yhit    = localPos[2];
565                 // Only if not trigger chamber
566                 if(idvol<kNCH) {
567                     //
568                     //  Initialize hit position (cursor) in the segmentation model 
569                     ((AliRICHChamber*) (*fChambers)[idvol])
570                         ->SigGenInit(localPos[0], localPos[2], localPos[1]);
571                 }
572             }
573             
574             // 
575             // Calculate the charge induced on a pad (disintegration) in case 
576             //
577             // Mip left chamber ...
578             if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
579                 gMC->SetMaxStep(kBig);
580                 eloss   += destep;
581                 tlength += step;
582                 
583                                 
584                 // Only if not trigger chamber
585                 if(idvol<kNCH) {
586                   if (eloss > 0) 
587                     {
588                       if(gMC->TrackPid() == kNeutron)
589                         printf("\n\n\n\n\n Neutron Making Pad Hit!!! \n\n\n\n");
590                       nPads = MakePadHits(xhit,yhit,eloss,idvol,kMip);
591                       hits[17] = nPads;
592                       //printf("nPads:%d",nPads);
593                     }
594                 }
595                 
596                 hits[6]=tlength;
597                 hits[7]=eloss;
598                 if (fNPadHits > (Int_t)hits[8]) {
599                     hits[8]= hits[8]+1;
600                     hits[9]= (Float_t) fNPadHits;
601                 }
602                 
603                 //if(sector !=-1)
604                 new(lhits[fNhits++]) AliRICHHit(fIshunt,gAlice->CurrentTrack(),vol,hits);
605                 eloss = 0; 
606                 //
607                 // Check additional signal generation conditions 
608                 // defined by the segmentation
609                 // model (boundary crossing conditions) 
610             } else if 
611                 (((AliRICHChamber*) (*fChambers)[idvol])
612                  ->SigGenCond(localPos[0], localPos[2], localPos[1]))
613             {
614                 ((AliRICHChamber*) (*fChambers)[idvol])
615                     ->SigGenInit(localPos[0], localPos[2], localPos[1]);
616                 if (eloss > 0) 
617                   {
618                     if(gMC->TrackPid() == kNeutron)
619                       printf("\n\n\n\n\n Neutron Making Pad Hit!!! \n\n\n\n");
620                     nPads = MakePadHits(xhit,yhit,eloss,idvol,kMip);
621                     hits[17] = nPads;
622                     //printf("Npads:%d",NPads);
623                   }
624                 xhit     = localPos[0];
625                 yhit     = localPos[2]; 
626                 eloss    = destep;
627                 tlength += step ;
628                 //
629                 // nothing special  happened, add up energy loss
630             } else {        
631                 eloss   += destep;
632                 tlength += step ;
633             }
634         }
635       }
636     /*************************************************End of MIP treatment**************************************/
637    //}
638 }