]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHv1.cxx
9defac147220239aa46121cc4e8d919da630d3ef
[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 #include "AliRICHv1.h"
18 #include "AliRICHParam.h"
19 #include "AliRICHChamber.h"
20 #include <TParticle.h> 
21 #include <TRandom.h> 
22 #include <TVirtualMC.h>
23 #include <TPDGCode.h>
24
25 #include <AliConst.h>
26 #include <AliPDG.h>
27 #include <AliRun.h>
28 #include <AliMC.h>
29
30 ClassImp(AliRICHv1)    
31 //__________________________________________________________________________________________________
32 void AliRICHv1::StepManager()
33 {
34 //Full Step Manager
35
36   Int_t          copy;
37   static Int_t   iCurrentChamber;
38         
39 //Treat photons    
40   static TLorentzVector cerX4;
41   if((gMC->TrackPid()==kCerenkov||gMC->TrackPid()==kFeedback)&&gMC->CurrentVolID(copy)==gMC->VolId("CSI ")){//photon in CSI
42     if(gMC->Edep()>0.){//CF+CSI+DE
43       if(IsLostByFresnel()){ gMC->StopTrack(); return;}        
44       gMC->TrackPosition(cerX4); gMC->CurrentVolOffID(2,iCurrentChamber);
45         
46       AddHit(iCurrentChamber,gAlice->GetMCApp()->GetCurrentTrackNumber(),cerX4.Vect(),cerX4.Vect());//HIT for PHOTON in conditions CF+CSI+DE
47       GenerateFeedbacks(iCurrentChamber);
48     }//CF+CSI+DE
49   }//CF in CSI
50   
51 //Treat charged particles  
52   static Float_t eloss;
53   static TLorentzVector mipInX4,mipOutX4;
54   if(gMC->TrackCharge() && gMC->CurrentVolID(copy)==gMC->VolId("GAP ")){//MIP in GAP
55     gMC->CurrentVolOffID(3,iCurrentChamber);
56     if(gMC->IsTrackEntering()||gMC->IsNewTrack()) {//MIP in GAP entering or newly created
57       eloss=0;                                                           
58       gMC->TrackPosition(mipInX4);
59     }else if(gMC->IsTrackExiting()||gMC->IsTrackStop()||gMC->IsTrackDisappeared()){//MIP in GAP exiting or disappeared
60       eloss+=gMC->Edep();//take into account last step dEdX
61       gMC->TrackPosition(mipOutX4);  
62       AddHit(iCurrentChamber,gAlice->GetMCApp()->GetCurrentTrackNumber(),mipInX4.Vect(),mipOutX4.Vect(),eloss);//HIT for MIP: MIP in GAP Exiting
63       GenerateFeedbacks(iCurrentChamber,eloss);//MIP+GAP+Exit
64     }else//MIP in GAP going inside
65       eloss   += gMC->Edep();
66   }//MIP in GAP
67 }//StepManager()
68 //__________________________________________________________________________________________________
69 Bool_t AliRICHv1::IsLostByFresnel()
70 {
71   TLorentzVector p4;
72   Double_t mom[3],localMom[3];
73   gMC->TrackMomentum(p4); mom[0]=p4(0);   mom[1]=p4(1);   mom[2]=p4(2);   mom[3]=p4(3);
74   gMC->Gmtod(mom,localMom,2);
75   Double_t localTc    = localMom[0]*localMom[0]+localMom[2]*localMom[2];
76   Double_t localTheta = TMath::ATan2(TMath::Sqrt(localTc),localMom[1]);
77   Double_t cotheta = TMath::Abs(TMath::Cos(localTheta));
78   if(gMC->GetRandom()->Rndm() < Fresnel(p4.E()*1e9,cotheta,1)){
79     if(GetDebug()) Info("IsLostByFresnel","");
80     return kTRUE;
81   }else
82     return kFALSE;
83 }//IsLostByFresnel()
84 //__________________________________________________________________________________________________