New convention on numbering and LRS
[u/mrichter/AliRoot.git] / RICH / AliRICHv0.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 #include "AliRICHv0.h"
17 #include "AliRICHChamber.h" 
18 #include <AliRun.h>
19 #include <AliMC.h>
20 #include <TVirtualMC.h>
21 #include <TPDGCode.h>
22 #include <TLorentzVector.h>
23 #include <TMath.h>
24
25 #include <TGeoManager.h>
26
27 ClassImp(AliRICHv0)
28
29 void AliRICHv0::StepManager()
30 {
31 //This StepManager is a provision for different test-learn activities on the current MC layer  
32   const char *sParticle;
33   switch(gMC->TrackPid()){
34     case kProton:
35       sParticle="proton";break;
36     case kNeutron:
37       sParticle="neutron";break;
38     case kGamma:
39       sParticle="gamma";break;
40     case kCerenkov:
41       sParticle="photon";break;
42     case kPi0:
43       sParticle="Pi0";break;  
44     case kElectron:
45       sParticle="electron";break;  
46     default:
47       sParticle="not known";break;
48   }
49
50   Info("","event=%i hunt=%i tid=%i pid=%i(%s) m=%f q=%3.1f dEdX=%9.3f",
51                             gMC->CurrentEvent(),
52                             fIshunt,
53                             gAlice->GetMCApp()->GetCurrentTrackNumber(),
54                             gMC->TrackPid(),
55                             sParticle,
56                             gMC->TrackMass(),
57                             gMC->TrackCharge(),
58                             gMC->Edep());
59   Info("","Flags:alive(%i) disap(%i) enter(%i) exit(%i) inside(%i) out(%i) stop(%i) new(%i)",
60                             gMC->IsTrackAlive(),
61                             gMC->IsTrackDisappeared(),
62                             gMC->IsTrackEntering(),
63                             gMC->IsTrackExiting(),
64                             gMC->IsTrackInside(),
65                             gMC->IsTrackOut(),
66                             gMC->IsTrackStop(),
67                             gMC->IsNewTrack());
68   Int_t copy0,copy1,copy2,copy3;
69   Int_t vid0=gMC->CurrentVolID(copy0);
70   Int_t vid1=gMC->CurrentVolOffID(1,copy1);
71   Int_t vid2=gMC->CurrentVolOffID(2,copy2);
72   Int_t vid3=gMC->CurrentVolOffID(3,copy3);
73   Info("","vid0=%i(%s)c%i vid1=%i(%s)c%i vid2=%i(%s)c%i vid3=%i(%s)c%i   %s-%s-%s-%s",
74                       vid0,gMC->VolName(vid0),copy0, 
75                       vid1,gMC->VolName(vid1),copy1, 
76                       vid2,gMC->VolName(vid2),copy2, 
77                       vid3,gMC->VolName(vid3),copy3, 
78                       gMC->CurrentVolName(),
79                       gMC->CurrentVolOffName(1),
80                       gMC->CurrentVolOffName(2),
81                       gMC->CurrentVolOffName(3));
82   
83   Float_t a,z,den,rad,abs; a=z=den=rad=abs=kBad;
84   Int_t mid=gMC->CurrentMaterial(a,z,den,rad,abs);
85   Info("","mid=%i a=%7.2f z=%7.2f den=%7.2f rad=%7.2f abs=%7.2f",mid,a,z,den,rad,abs);
86   
87   TLorentzVector x4;
88   gMC->TrackPosition(x4);
89   Float_t glo[3],loc[3];
90   glo[0]=x4.X();glo[1]=x4.Y();glo[2]=x4.Z();  
91   gMC->Gmtod(glo,loc,1);
92   Info("","glo(%+8.3f,%+8.3f,%+8.3f) r=%8.3f theta=%8.3f phi=%8.3f",
93                       glo[0],glo[1],glo[2],x4.Rho(),x4.Theta()*TMath::RadToDeg(),x4.Phi()*TMath::RadToDeg());  
94   Info("","loc(%+8.3f,%+8.3f,%8.3f) by gMC->Gmtod()",         loc[0],loc[1],loc[2]);  
95   if(gMC->VolId("CSI ")==gMC->CurrentVolID(copy0)){
96     Int_t iChamber;
97     gMC->CurrentVolOffID(2,iChamber);
98     TVector2 x2=C(iChamber)->Glob2Loc(x4);
99     Info("","loc(%+8.3f,%+8.3f) by Glob2Loc",      x2.X(),x2.Y());  
100   }
101   Info("","end of current step\n");
102 }//StepManager()
103
104 void AliRICHv0::CreateGeometry()
105 {
106   if(GetDebug())Info("CreateGeometry","Start v0.");  
107   
108   Double_t cm=1,mm=0.1;
109   //place radioactive source compartment if needed
110   Double_t containerLen=21.8*mm/2                        ,containerR=38*mm/2;  
111   Double_t screwLen=15*mm/2                              ,screwR=5*mm/2;  
112   Double_t srcLen=10*mm/2                                ,srcR=2*mm/2;  
113   Double_t perpexLen=20*mm/2                             ,perpexR=34*mm/2;  
114   Double_t perpexWholeLen=10*mm/2                        ,perpexWholeR=4*mm/2;  
115   Double_t alBottomLen=containerLen-perpexLen            ,alWholeR=5*mm/2;      
116 //volumes    
117   Double_t par[3];
118
119 //  Double_t anodWireD=20*mkm, cathWireD=100*mkm, collWireD=100*mkm;
120         
121   Double_t pcZ2=0.5*mm;
122   par[0]=68.8*cm;            par[1]=70.86*cm;                par[2]=13*cm;           gMC->Gsvolu("RICH","BOX ",(*fIdtmed)[kCH4],par,3); //RICH    
123   par[0]=P()->PcSizeX()/2;   par[1]=P()->PcSizeY()/2;        par[2]=pcZ2;            gMC->Gsvolu("CSI ","BOX ",(*fIdtmed)[kCSI],par,3); //CSI
124   par[0]=P()->PcSizeX()/2;   par[1]=P()->PcSizeY()/2;        par[2]=P()->GapAmp();   gMC->Gsvolu("GAP ","BOX ",(*fIdtmed)[kCH4],par,3); //GAP
125 //  par[0]=0;                  par[1]=;                        par[2]=P()->PcSizeX()/2;gMC->Gsvolu("WIAN","TUBE",(*fIdtmed)[kW],par,3);//Anod wire
126 //  par[0]=0;                  par[1]=srcR;                    par[2]=P()->PcSizeX()/2;gMC->Gsvolu("WICA","TUBE",(*fIdtmed)[kCu],par,3);//Cathod wire
127 //  par[0]=0;                  par[1]=srcR;                    par[2]=P()->PcSizeX()/2;gMC->Gsvolu("WICO","TUBE",(*fIdtmed)[kCu],par,3);//Collect wire
128     
129   par[0]=0      ;par[1]=containerR  ;par[2]=containerLen;  gMC->Gsvolu("CONT","TUBE",(*fIdtmed)[kCH4]   ,par,3); //container 
130   par[0]=perpexR;par[1]=containerR  ;par[2]=containerLen;  gMC->Gsvolu("ALWA","TUBE",(*fIdtmed)[kAl]    ,par,3); //Al cylindric wall
131   par[0]=0      ;par[1]=perpexR     ;par[2]=alBottomLen;   gMC->Gsvolu("ALBO","TUBE",(*fIdtmed)[kAl]    ,par,3); //Al bottom 
132   par[0]=0      ;par[1]=alWholeR    ;par[2]=alBottomLen;   gMC->Gsvolu("ALWH","TUBE",(*fIdtmed)[kCH4]   ,par,3); //Whole in Al bottom
133   par[0]=0      ;par[1]=perpexR     ;par[2]=perpexLen;     gMC->Gsvolu("PEPL","TUBE",(*fIdtmed)[kPerpex],par,3); //Perpex plug
134   par[0]=0      ;par[1]=perpexWholeR;par[2]=perpexWholeLen;gMC->Gsvolu("PEWH","TUBE",(*fIdtmed)[kCH4]   ,par,3); //Whole in Perpex
135   par[0]=0      ;par[1]=screwR      ;par[2]=screwLen;      gMC->Gsvolu("SCRE","TUBE",(*fIdtmed)[kSteel] ,par,3); //Screw
136   par[0]=0      ;par[1]=srcR        ;par[2]=srcLen;        gMC->Gsvolu("SOUR","TUBE",(*fIdtmed)[kSteel] ,par,3); //Source itself
137 //nodes    
138   gMC->Gspos("RICH",1,"ALIC",0,0,-9                                ,0,"ONLY");     //RICH in ALIC
139   gMC->Gspos("CSI ",1,"RICH",0,0,-(P()->GapProx()+pcZ2)           ,0,"ONLY");     //CsI  in ALIC
140   gMC->Gspos("GAP ",1,"RICH",0,0,-(P()->GapProx()-P()->GapAmp()/2),0,"ONLY");     //GAP in ALIC
141     
142   gMC->Gspos("CONT",1,"RICH",0,0,1*cm                             ,0,"ONLY");     //Sr90 container in RICH
143   gMC->Gspos("ALWA",1,"CONT",0,0,0                                ,0,"ONLY");     //Al wall
144   gMC->Gspos("ALBO",1,"CONT",0,0,-containerLen+alBottomLen        ,0,"ONLY");     //Al bottom
145   gMC->Gspos("PEPL",1,"CONT",0,0,containerLen-perpexLen           ,0,"ONLY");     //Perpex plug
146    
147   gMC->Gspos("ALWH",1,"ALBO",6*mm,0,0                             ,0,"ONLY");     //Whole in Al bottom
148     
149   gMC->Gspos("PEWH",1,"PEPL",6*mm,0,-perpexLen+perpexWholeLen     ,0,"ONLY");     //Whole in Perpex plug
150   gMC->Gspos("SOUR",1,"PEPL",6*mm,0, perpexLen-srcLen             ,0,"ONLY");     //Source in Perpex plug
151   gMC->Gspos("SCRE",1,"PEPL",0,0,perpexLen-screwLen               ,0,"ONLY");     //Screw in Perpex plug
152   if(GetDebug())Info("CreateGeometry","Stop v0.");  
153 }//CreateGeometry()