Method to count the physical contribution to a cluster added.
[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   TLorentzVector x4,p4;
39   Float_t        pos[3],mom[4],localPos[3],localMom[4];
40   Float_t        coscerenkov;
41        
42   TParticle *current = (TParticle*)(*gAlice->GetMCApp()->Particles())[gAlice->GetMCApp()->GetCurrentTrackNumber()];
43
44     
45  
46   Float_t cherenkovLoss=0;
47     
48     
49
50   if(gMC->TrackPid()==kCerenkov){//C
51     Float_t ckovEnergy = current->Energy();
52     if(ckovEnergy > 5.6e-09 && ckovEnergy < 7.8e-09 ){//C+E
53         if(gMC->IsTrackEntering()){                                     //is track entering?
54                     
55                     if (gMC->VolId("CSI ")==gMC->CurrentVolID(copy)){             //is it in csi?      
56                         gMC->TrackMomentum(p4); mom[0]=p4(0);   mom[1]=p4(1);   mom[2]=p4(2);   mom[3]=p4(3);
57                         gMC->Gmtod(mom,localMom,2);
58                         Double_t localTc    = localMom[0]*localMom[0]+localMom[2]*localMom[2];
59                         Double_t localTheta = TMath::ATan2(TMath::Sqrt(localTc),localMom[1]);
60                         Double_t cotheta = TMath::Abs(TMath::Cos(localTheta));
61                         if(gMC->GetRandom()->Rndm() < Fresnel(p4.E()*1e9,cotheta,1))  gMC->StopTrack();
62                                 
63                       }//C+E+produced in Freon
64                   } //track entering?
65     }//C+E
66   }//C
67     
68   if((gMC->TrackPid()==kCerenkov||gMC->TrackPid()==kFeedback)&&gMC->CurrentVolID(copy)==gMC->VolId("CSI ")){//photon in CSI     
69       if(gMC->Edep()>0.){//CF+CSI+DE
70         gMC->TrackPosition(x4);   pos[0]=x4(0);   pos[1]=x4(1);   pos[2]=x4(2);
71         gMC->TrackMomentum(p4);   mom[0]=p4(0);   mom[1]=p4(1);   mom[2]=p4(2);   mom[3]=p4(3);
72         if(IsFresnelLoss()){ gMC->StopTrack(); return;}        
73         gMC->CurrentVolOffID(2,copy);iCurrentChamber=copy;
74         
75         gMC->Gmtod(pos,localPos,1);     gMC->Gmtod(mom,localMom,2);
76
77         cherenkovLoss  += gMC->Edep();
78                     
79         AliRICHhit *mipHit =  (AliRICHhit*) (fHits->UncheckedAt(0));
80         if(mipHit){
81           mom[0] = current->Px();   mom[1] = current->Py();   mom[2] = current->Pz();
82           Float_t mipPx = mipHit->MomX();   Float_t mipPy = mipHit->MomY();   Float_t mipPz = mipHit->MomZ();
83                         
84           Float_t r = mom[0]*mom[0] + mom[1]*mom[1] + mom[2]*mom[2];
85           Float_t rt = TMath::Sqrt(r);
86           Float_t mipR = mipPx*mipPx + mipPy*mipPy + mipPz*mipPz;       
87           Float_t mipRt = TMath::Sqrt(mipR);
88           if((rt*mipRt) > 0)
89             coscerenkov = (mom[0]*mipPx + mom[1]*mipPy + mom[2]*mipPz)/(rt*mipRt);
90           else
91             coscerenkov = 0;
92         }
93         AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),x4.Vect());//HIT for PHOTON in conditions CF+CSI+DE
94         GenerateFeedbacks(iCurrentChamber,cherenkovLoss);//CF+CSI+DE
95       }//CF+CSI+DE
96   }//CF in CSI
97   
98 //Treat charged particles  
99   static Float_t eloss;
100   if(gMC->TrackCharge() && gMC->CurrentVolID(copy)==gMC->VolId("GAP ")){//MIP in GAP
101     gMC->CurrentVolOffID(3,copy); iCurrentChamber=copy;
102     if(gMC->IsTrackEntering()||gMC->IsNewTrack())//MIP in GAP Entering
103       eloss=0;                                                           
104     else if(gMC->IsTrackExiting()||gMC->IsTrackStop()||gMC->IsTrackDisappeared()){//MIP in GAP Exiting
105       eloss+=gMC->Edep();//take into account last step dEdX
106       gMC->TrackPosition(x4);  
107       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),x4.Vect(),eloss);//HIT for MIP for conditions: MIP in GAP Exiting
108       GenerateFeedbacks(iCurrentChamber,eloss);//MIP+GAP+Exit
109     }else//MIP in GAP going inside
110       eloss   += gMC->Edep();
111   }//MIP in GAP
112 }//void AliRICHv1::StepManager()
113
114 Bool_t AliRICHv1::IsFresnelLoss()
115 {
116   return kFALSE;
117 }