]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICH.cxx
Bugs in rename same Reset methods. Improvement in display
[u/mrichter/AliRoot.git] / RICH / AliRICH.cxx
CommitLineData
53fd478b 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// **************************************************************************
4c039060 15
53fd478b 16#include "AliRICH.h"
17#include "AliRICHParam.h"
18#include "AliRICHChamber.h"
d3eb6079 19#include "AliRICHTracker.h"
56030c8d 20#include "AliRICHHelix.h"
d3eb6079 21//#include <TArrayF.h>
543d5224 22#include <TGeometry.h>
116cbefd 23#include <TBRIK.h>
543d5224 24#include <TTUBE.h>
237c933d 25#include <TFile.h>
116cbefd 26#include <TNode.h>
27#include <TObjArray.h>
3582c1f9 28#include <TParticle.h>
29#include <AliStack.h>
c60862bf 30#include <AliMagF.h>
c60862bf 31#include <AliRun.h>
32#include <AliRunDigitizer.h>
53fd478b 33#include <AliMC.h>
e42a7b46 34#include <AliESD.h>
5d12ce38 35#include <TVirtualMC.h>
e42a7b46 36#include <TH1F.h>
37#include <TH2F.h>
d3eb6079 38#include <TBenchmark.h>
998b831f 39#include <AliLog.h>
d3eb6079 40#include <TNtupleD.h>
41#include <AliTracker.h>
42#include <AliRawDataHeader.h>
0fe8fa07 43#include <TLatex.h> //Display()
44#include <TCanvas.h> //Display()
56030c8d 45#include <TGraph.h> //Display()
f770edb5 46#include <TStyle.h> //Display()
47#include <TMarker.h> //Display()
ddae0931 48
c60862bf 49ClassImp(AliRICH)
50//__________________________________________________________________________________________________
15d8311d 51// RICH manager class
c60862bf 52//BEGIN_HTML
15d8311d 53/*
54 <img src="gif/alirich.gif">
55*/
c60862bf 56//END_HTML
57//__________________________________________________________________________________________________
0fe8fa07 58AliRICH::AliRICH():AliDetector(),fParam(0), fSdigits(0),fNsdigits(0),fDigs(0),fClus(0)
53fd478b 59{
60//Default ctor should not contain any new operators
543d5224 61//AliDetector ctor deals with Hits and Digits
0fe8fa07 62 for(int i=0;i<kNchambers;i++) fNdigs[i] =0;
63 for(int i=0;i<kNchambers;i++) fNclus[i]=0;
e42a7b46 64// fCounters.ResizeTo(20); fCounters.Zero();
15d8311d 65}//AliRICH::AliRICH()
c021cb15 66//__________________________________________________________________________________________________
fe4da5cc 67AliRICH::AliRICH(const char *name, const char *title)
0fe8fa07 68 :AliDetector(name,title),fParam(new AliRICHParam),fSdigits(0),fNsdigits(0),fDigs(0),fClus(0)
53fd478b 69{
70//Named ctor
998b831f 71 AliDebug(1,"Start.");
543d5224 72//AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
0fe8fa07 73 HitsCreate(); gAlice->GetMCApp()->AddHitList(fHits);
e42a7b46 74 fCounters.ResizeTo(20); fCounters.Zero();
998b831f 75 AliDebug(1,"Stop.");
dfb4e77d 76}//AliRICH::AliRICH(const char *name, const char *title)
c021cb15 77//__________________________________________________________________________________________________
fe4da5cc 78AliRICH::~AliRICH()
53fd478b 79{
80//dtor
998b831f 81 AliDebug(1,"Start.");
237c933d 82
0fe8fa07 83 if(fParam) delete fParam;
c60862bf 84
85 if(fHits) delete fHits;
86 if(fSdigits) delete fSdigits;
87 if(fDigits) delete fDigits;
0fe8fa07 88 if(fDigs) {fDigs->Delete(); delete fDigs;}
89 if(fClus) {fClus->Delete(); delete fClus;}
998b831f 90 AliDebug(1,"Stop.");
dfb4e77d 91}//AliRICH::~AliRICH()
c021cb15 92//__________________________________________________________________________________________________
3ea9cb08 93void AliRICH::Hits2SDigits()
53fd478b 94{
3582c1f9 95// Create a list of sdigits corresponding to list of hits. Every hit generates one or more sdigits.
998b831f 96 AliDebug(1,"Start.");
3582c1f9 97 for(Int_t iEventN=0;iEventN<GetLoader()->GetRunLoader()->GetAliRun()->GetEventsPerRun();iEventN++){//events loop
e42a7b46 98 GetLoader()->GetRunLoader()->GetEvent(iEventN);//get next event
3582c1f9 99
e42a7b46 100 if(!GetLoader()->TreeH()) GetLoader()->LoadHits(); GetLoader()->GetRunLoader()->LoadHeader();
d0831219 101 if(!GetLoader()->GetRunLoader()->TreeK()) GetLoader()->GetRunLoader()->LoadKinematics();//from
e42a7b46 102 if(!GetLoader()->TreeS()) GetLoader()->MakeTree("S"); MakeBranch("S");//to
3582c1f9 103
104 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
e42a7b46 105 GetLoader()->TreeH()->GetEntry(iPrimN);
3582c1f9 106 for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){//hits loop
0fe8fa07 107 AliRICHHit *pHit=(AliRICHHit*)Hits()->At(iHitN);//get current hit
d3eb6079 108 TVector2 x2 = C(pHit->C())->Mrs2Anod(0.5*(pHit->InX3()+pHit->OutX3()));//hit position in the anod plane
e42a7b46 109 Int_t iTotQdc=P()->TotQdc(x2,pHit->Eloss());//total charge produced by hit, 0 if hit in dead zone
09c52ebc 110 if(iTotQdc==0) continue;
1cb5a97c 111 //
112 //need to quantize the anod....
113 TVector padHit=AliRICHParam::Loc2Pad(x2);
114 TVector2 padHitXY=AliRICHParam::Pad2Loc(padHit);
115 TVector2 anod;
116 if((x2.Y()-padHitXY.Y())>0) anod.Set(x2.X(),padHitXY.Y()+AliRICHParam::PitchAnod()/2);
117 else anod.Set(x2.X(),padHitXY.Y()-AliRICHParam::PitchAnod()/2);
118 //end to quantize anod
119 //
120 TVector area=P()->Loc2Area(anod);//determine affected pads, dead zones analysed inside
121 AliDebug(1,Form("hitanod(%6.2f,%6.2f)->area(%3.0f,%3.0f)-(%3.0f,%3.0f) QDC=%4i",anod.X(),anod.Y(),area[0],area[1],area[2],area[3],iTotQdc));
e42a7b46 122 TVector pad(2);
123 for(pad[1]=area[1];pad[1]<=area[3];pad[1]++)//affected pads loop
124 for(pad[0]=area[0];pad[0]<=area[2];pad[0]++){
1cb5a97c 125 Double_t padQdc=iTotQdc*P()->FracQdc(anod,pad);
998b831f 126 AliDebug(1,Form("current pad(%3.0f,%3.0f) with QDC =%6.2f",pad[0],pad[1],padQdc));
0fe8fa07 127 if(padQdc>0.1) SDigitAdd(pHit->C(),pad,padQdc,GetLoader()->GetRunLoader()->Stack()->Particle(pHit->GetTrack())->GetPdgCode(),pHit->GetTrack());
3582c1f9 128 }//affected pads loop
129 }//hits loop
130 }//prims loop
e42a7b46 131 GetLoader()->TreeS()->Fill();
132 GetLoader()->WriteSDigits("OVERWRITE");
d0831219 133 SDigitsReset();
3582c1f9 134 }//events loop
e42a7b46 135 GetLoader()->UnloadHits(); GetLoader()->GetRunLoader()->UnloadHeader(); GetLoader()->GetRunLoader()->UnloadKinematics();
3582c1f9 136 GetLoader()->UnloadSDigits();
998b831f 137 AliDebug(1,"Stop.");
3582c1f9 138}//Hits2SDigits()
c021cb15 139//__________________________________________________________________________________________________
d3eb6079 140void AliRICH::Digits2Raw()
141{
142//Loops over all digits and creates raw data files in DDL format. GetEvent() is done outside (AliSimulation)
0fe8fa07 143//RICH has 2 DDL per chamber, even number for right part(2-4-6) odd number for left part(1-3-5)
144//RICH has no any propriate header just uses the common one
145//Each PC is divided by 8 rows counted from 1 to 8 from top to bottom for left PCs(1-3-5) and from bottom to top for right PCc(2-4-6) (denoted rrrrr 5 bits 32 values)
146//Each raw is composed from 10 DILOGIC chips counted from left to right from 1 to 10 (denoted dddd 4 bits 16 values)
147//Each DILOGIC chip serves 48 channels counted from 0 to 47 (denoted aaaaaa 6 bits 64 values)
148//So RICH info word is 32 bits word with structure: 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq (five 0 five r six a twelve q) with QDC (denoted q...q 12 bits 4096 values)
d3eb6079 149 AliDebug(1,"Start.");
150 GetLoader()->LoadDigits();
151 GetLoader()->TreeD()->GetEntry(0);
152
153 Int_t kRichOffset=0x700; //currently one DDL per 3 sectors
154
155 ofstream file135,file246;//output streams 2 DDL per chamber
156 AliRawDataHeader header;//empty DDL miniheader
157 UInt_t word32=1; //32 bits data word
158
159 for(Int_t iChN=1;iChN<=kNchambers;iChN++){ //2 DDL per chamber open both in parallel
0fe8fa07 160 file135.open(Form("RICH_%4i.ddl",kRichOffset+2*iChN-1)); //left part of chamber; sectors 1-3-5 odd DDL number
161 file246.open(Form("RICH_%4i.ddl",kRichOffset+2*iChN)); //right part of chamber; sectors 2-4-6 even DDL number
d3eb6079 162//common DDL header defined by standart, now dummy as the total number of bytes is not yet known
163 file135.write((char*)&header,sizeof(header)); //dummy header just place holder
164 file246.write((char*)&header,sizeof(header)); //actual will be written later
d3eb6079 165
166 Int_t counter135=0,counter246=0;//counts total number of records per DDL
167
168 for(Int_t iDigN=0;iDigN<Digits(iChN)->GetEntriesFast();iDigN++){//digits loop for a given chamber
0fe8fa07 169 AliRICHDigit *pDig=(AliRICHDigit*)Digits(iChN)->At(iDigN);
170 word32=UInt_t (pDig->Q()+0x400*pDig->X()+0x4000*pDig->Y()); //arbitrary structure
d3eb6079 171 switch(pDig->S()){//readout by vertical sectors: 1,3,5-left DDL 2,4,6-right DDL
172 case 1: case 3: case 5: file135.write((char*)&word32,sizeof(word32)); counter135++; break;
173 case 2: case 4: case 6: file246.write((char*)&word32,sizeof(word32)); counter246++; break;
174 }//switch sector
175 }//digits loop for a given chamber
176//now count total byte number for each DDL file and rewrite actual header
177 header.fSize=sizeof(header)+counter135*sizeof(word32); header.SetAttribute(0); file135.seekp(0); file135.write((char*)&header,sizeof(header));
178 header.fSize=sizeof(header)+counter246*sizeof(word32); header.SetAttribute(0); file246.seekp(0); file246.write((char*)&header,sizeof(header));
179 file135.close(); file246.close();
180 }//chambers loop
181 GetLoader()->UnloadDigits();
182 AliDebug(1,"Stop.");
183}//Digits2Raw()
184//__________________________________________________________________________________________________
dfb4e77d 185void AliRICH::BuildGeometry()
53fd478b 186{
187//Builds a TNode geometry for event display
998b831f 188 AliInfo("Start.");
237c933d 189
3ea9cb08 190 TNode *node, *subnode, *top;
191 top=gAlice->GetGeometry()->GetNode("alice");
53d98323 192
a25b3368 193 Float_t widx =P()->SectorSizeX();
194 Float_t leny =P()->SectorSizeY();
195 Float_t dz =P()->Zfreon()+P()->Zwin()+P()->Pc2Win();
196 Float_t dead =P()->DeadZone();
998b831f 197
198 new TBRIK("RICH","RICH","void",widx+dead/2,leny+leny/2+dead,dz+0.1); //RICH chamber
199 new TBRIK("RPC" ,"RPC" ,"void",widx/2,leny/2,0.01); //RICH sector
200
a25b3368 201 for(int i=1;i<=P()->Nchambers();i++){
237c933d 202 top->cd();
998b831f 203 node = new TNode(Form("RICH%i",i),Form("RICH%i",i),"RICH",C(i)->Center().X(),C(i)->Center().Y(),C(i)->Center().Z(),C(i)->RotMatrixName());
3ea9cb08 204 node->SetLineColor(kRed);
91975aa2 205 node->cd();
998b831f 206 subnode = new TNode("PHOTO1","PHOTO1","RPC",-widx/2-dead/2,-leny-dead/2,dz,"");
91975aa2 207 subnode->SetLineColor(kGreen);
208 fNodes->Add(subnode);
998b831f 209 subnode = new TNode("PHOTO1","PHOTO1","RPC", widx/2+dead/2,-leny-dead/2,dz,"");
91975aa2 210 subnode->SetLineColor(kGreen);
211 fNodes->Add(subnode);
998b831f 212 subnode = new TNode("PHOTO1","PHOTO1","RPC",-widx/2-dead/2, 0,dz,"");
91975aa2 213 subnode->SetLineColor(kGreen);
214 fNodes->Add(subnode);
998b831f 215 subnode = new TNode("PHOTO1","PHOTO1","RPC", widx/2+dead/2, 0,dz,"");
91975aa2 216 subnode->SetLineColor(kGreen);
217 fNodes->Add(subnode);
998b831f 218 subnode = new TNode("PHOTO1","PHOTO1","RPC",-widx/2-dead/2, leny+dead/2,dz,"");
91975aa2 219 subnode->SetLineColor(kGreen);
220 fNodes->Add(subnode);
998b831f 221 subnode = new TNode("PHOTO1","PHOTO1","RPC", widx/2+dead/2, leny+dead/2,dz,"");
91975aa2 222 subnode->SetLineColor(kGreen);
223 fNodes->Add(subnode);
237c933d 224 fNodes->Add(node);
998b831f 225 }
226
227 AliDebug(1,"Stop.");
dfb4e77d 228}//void AliRICH::BuildGeometry()
a25b3368 229//__________________________________________________________________________________________________
452a64c6 230void AliRICH::CreateMaterials()
231{
e42a7b46 232// Definition of available RICH materials
af3d25a6 233
998b831f 234 Int_t material=0; //tmp material id number
235 Float_t a=0,z=0,den=0,radl=0,absl=0; //tmp material parameters
a25b3368 236
c60862bf 237 Float_t tmaxfd=-10.0, deemax=-0.2, stemax=-0.1,epsil=0.001, stmin=-0.001;
238 Int_t isxfld = gAlice->Field()->Integ();
239 Float_t sxmgmx = gAlice->Field()->Max();
452a64c6 240
a25b3368 241 Float_t aAir[4]={12,14,16,36}; Float_t zAir[4]={6,7,8,18}; Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};//total 0.9999999
998b831f 242 AliMixture(++material, "RichAir",aAir,zAir,den=0.00120479,4,wAir); //1 (Air) 0.01% C 75% N 23% O 1% Ar
243 AliMedium(kAir, "RichAir",material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
452a64c6 244
a25b3368 245 AliMixture(++material, "RichAerogel",aAir,zAir,den=P()->DenGel(),4,wAir); //Aerogel represented by Air
246 AliMedium(kGel, "RichAerogel",material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
247
248 AliMixture(++material, "RichAerogelReflector",aAir,zAir,den=P()->DenGel(),4,wAir); //Aerogel reflector represented by Air
249 AliMedium(kReflector, "RichAerogelReflector",material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
250
998b831f 251 AliMaterial(++material, "RichRohacell", a=12.01,z=6.0, den=0.1, radl=18.8, absl=0); //2 Rohacell 51 C-equiv radl rad cover
252 AliMedium(kRoha, "RichRohacell", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
c60862bf 253
998b831f 254 Float_t aQuartz[2]={28.09,16.0}; Float_t zQuartz[2]={14.00, 8.0}; Float_t wQuartz[2]={1,2};
255 AliMixture(++material, "RichSiO2",aQuartz,zQuartz,den=2.64,-2, wQuartz); //3 Quarz (SiO2) -trasparent rad window
256 AliMedium(kSiO2, "RichSiO2",material, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
c60862bf 257
a25b3368 258 Float_t aFreon[2]={12,19}; Float_t zFreon[2]={6,9}; Float_t wmatFreon[2]={6,14}; // C12-6 F19-9
998b831f 259 AliMixture(++material, "RichC6F14",aFreon,zFreon,den=1.68,-2,wmatFreon); //4 Freon (C6F14)
260 AliMedium(kC6F14, "RichC6F14",material, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
261
262 Float_t aMethane[2]={12.01,1}; Float_t zMethane[2]={6,1}; Float_t wMethane[2]={1,4};
263 AliMixture (++material, "RichCH4", aMethane, zMethane, den=7.17e-4,-2, wMethane); //5,9 methane (CH4) normal and for Gap
264 AliMedium(kCH4, "RichCH4" , material, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
a25b3368 265 AliMixture (++material, "RichCH4gap", aMethane, zMethane, den=7.17e-4,-2, wMethane); //5,9 methane (CH4) normal and for Gap
266 AliMedium(kGap, "RichCH4gap", material, 1, isxfld, sxmgmx, tmaxfd, 0.1 , -deemax, epsil, -stmin);
998b831f 267
268 AliMaterial(++material, "RichCsI", a=12.01,z=6.0, den=0.1, radl=18.8, absl=0); //6 CsI-radl equivalent
a25b3368 269 AliMedium(kCsI, "RichCsI", material, 1, isxfld, sxmgmx,tmaxfd, stemax, deemax, epsil, stmin);
c60862bf 270
a25b3368 271 AliMaterial(++material, "RichGridCu", a=63.54,z=29.0,den=8.96, radl=1.43, absl=0); //7 anode grid (Cu)
272 AliMedium(kGridCu, "RichGridCu", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
273
274 AliMaterial(++material, "RichPcbCu", a=63.54,z=29.0,den=8.96, radl=1.4, absl=0); //12 Cu
275 AliMedium(kCu, "RichPcbCu", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
c60862bf 276
a25b3368 277 AliMixture (++material, "RichOpSiO2",aQuartz, zQuartz, den=2.64, -2, wQuartz); //8 Quarz (SiO2) - opaque
278 AliMedium(kOpSiO2, "RichOpSiO2",material, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
c60862bf 279
a25b3368 280 AliMaterial(++material, "RichAl", a=26.98,z=13.0,den=2.699, radl=8.9, absl=0); //10 aluminium sheet (Al)
281 AliMedium(kAl, "RichAl", material, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
c60862bf 282
998b831f 283 Float_t aGlass[5]={12.01,28.09,16,10.8,23}; Float_t zGlass[5]={6,14,8,5,11}; Float_t wGlass[5]={0.5,0.105,0.355,0.03,0.01};
a25b3368 284 AliMixture(++material,"RichGlass",aGlass, zGlass, den=1.74, 5, wGlass); //11 Glass 50%-C 10.5%-Si 35.5%-O 3%-B 1%-Na
285 AliMedium(kGlass, "RichGlass", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
998b831f 286
a25b3368 287 AliMaterial(++material, "RichW", a=183.84,z=74.0,den=19.3, radl=0.35, absl=185.0/den); //13 W - anod wires
288 AliMedium(kW, "RichW", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
c60862bf 289
e42a7b46 290
291 if(P()->IsRadioSrc()){
998b831f 292 AliInfo("Special radioactive source materials");
a25b3368 293 AliMaterial(++material, "RichSteel", a=55.845,z=26.0,den=7.87, radl=1.76, absl=131.9/den); //14 Steel (Fe)
294 AliMedium(kSteel, "RichSteel", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
c60862bf 295
a25b3368 296 AliMaterial(++material, "RichPerpex", a=63.54,z=29.0,den=8.96, radl=1.4, absl=0); //15 Perpex
297 AliMedium(kPerpex, "RichPerpex", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
e42a7b46 298
a25b3368 299 AliMaterial(++material, "RichSr90", a=87.62,z=38.0,den=2.54, radl=4.24, absl=0); //16 Sr90
300 AliMedium(kSr90, "RichSr90", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
301
302 Float_t aMylar[5]={12.01,1,16}; Float_t zMylar[5]={6,1,8}; Float_t wMylar[5]={5,4,5}; //17 Mylar C5H4O5
303 AliMixture(++material,"RichMylar",aMylar, zMylar, den=1.39, -3, wMylar);
304 AliMedium(kMylar, "RichMylar", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
e42a7b46 305 }
c60862bf 306
998b831f 307//Optical properties:
308#include "Opticals.h"
a25b3368 309 gMC->SetCerenkov((*fIdtmed)[kAir] , kNbins, aPckov, aAbsCH4 , aQeAll, aIdxCH4); //1 Air
310 gMC->SetCerenkov((*fIdtmed)[kRoha] , kNbins, aPckov, aAbsCH4 , aQeAll, aIdxCH4); //2 Honeycomb
311 gMC->SetCerenkov((*fIdtmed)[kSiO2] , kNbins, aPckov, aAbsSiO2 , aQeAll, aIdxSiO2); //3 Quartz SiO2
312 gMC->SetCerenkov((*fIdtmed)[kC6F14] , kNbins, aPckov, aAbsC6F14 , aQeAll, aIdxC6F14); //4 Freon C6F14
313 gMC->SetCerenkov((*fIdtmed)[kCH4] , kNbins, aPckov, aAbsCH4 , aQeAll, aIdxCH4); //5 Methane CH4
314 gMC->SetCerenkov((*fIdtmed)[kCsI] , kNbins, aPckov, aAbsCsI , aQeCsI, aIdxCH4); //6 CsI
315 gMC->SetCerenkov((*fIdtmed)[kGridCu] , kNbins, aPckov, aAbsGrid , aQeAll, aIdxMetal); //7 grid Cu
316 gMC->SetCerenkov((*fIdtmed)[kOpSiO2] , kNbins, aPckov, aAbsOpSiO2 , aQeAll, aIdxMetal); //8 Opaque quartz SiO2
317 gMC->SetCerenkov((*fIdtmed)[kGap] , kNbins, aPckov, aAbsCH4 , aQeAll, aIdxCH4); //9 Special methane gap
318 gMC->SetCerenkov((*fIdtmed)[kAl] , kNbins, aPckov, aAbsGrid , aQeAll, aIdxMetal); //10 Aluminium
319 gMC->SetCerenkov((*fIdtmed)[kGlass] , kNbins, aPckov, aAbsOpSiO2 , aQeAll, aIdxMetal); //11 Glass
320 gMC->SetCerenkov((*fIdtmed)[kGel] , kNbins, aPckov, aAbsGel , aQeAll, aIdxGel); //12 Aerogel
321 gMC->SetCerenkov((*fIdtmed)[kReflector], kNbins, aPckov, aAbsRef , aQeAll, aIdxMetal); //13 Aerogel reflector
c60862bf 322}//void AliRICH::CreateMaterials()
c021cb15 323//__________________________________________________________________________________________________
a25b3368 324Float_t AliRICH::Fresnel(Float_t ene,Float_t pdoti, Bool_t pola)
452a64c6 325{
326
327 //ENE(EV), PDOTI=COS(INC.ANG.), PDOTR=COS(POL.PLANE ROT.ANG.)
328
329 Float_t en[36] = {5.0,5.1,5.2,5.3,5.4,5.5,5.6,5.7,5.8,5.9,6.0,6.1,6.2,
330 6.3,6.4,6.5,6.6,6.7,6.8,6.9,7.0,7.1,7.2,7.3,7.4,7.5,7.6,7.7,
331 7.8,7.9,8.0,8.1,8.2,8.3,8.4,8.5};
452a64c6 332 Float_t csin[36] = {2.14,2.21,2.33,2.48,2.76,2.97,2.99,2.59,2.81,3.05,
333 2.86,2.53,2.55,2.66,2.79,2.96,3.18,3.05,2.84,2.81,2.38,2.11,
334 2.01,2.13,2.39,2.73,3.08,3.15,2.95,2.73,2.56,2.41,2.12,1.95,
335 1.72,1.53};
452a64c6 336 Float_t csik[36] = {0.,0.,0.,0.,0.,0.196,0.408,0.208,0.118,0.49,0.784,0.543,
337 0.424,0.404,0.371,0.514,0.922,1.102,1.139,1.376,1.461,1.253,0.878,
338 0.69,0.612,0.649,0.824,1.347,1.571,1.678,1.763,1.857,1.824,1.824,
339 1.714,1.498};
340 Float_t xe=ene;
341 Int_t j=Int_t(xe*10)-49;
342 Float_t cn=csin[j]+((csin[j+1]-csin[j])/0.1)*(xe-en[j]);
343 Float_t ck=csik[j]+((csik[j+1]-csik[j])/0.1)*(xe-en[j]);
344
345 //FORMULAE FROM HANDBOOK OF OPTICS, 33.23 OR
346 //W.R. HUNTER, J.O.S.A. 54 (1964),15 , J.O.S.A. 55(1965),1197
347
348 Float_t sinin=TMath::Sqrt(1-pdoti*pdoti);
349 Float_t tanin=sinin/pdoti;
350
351 Float_t c1=cn*cn-ck*ck-sinin*sinin;
352 Float_t c2=4*cn*cn*ck*ck;
353 Float_t aO=TMath::Sqrt(0.5*(TMath::Sqrt(c1*c1+c2)+c1));
354 Float_t b2=0.5*(TMath::Sqrt(c1*c1+c2)-c1);
355
356 Float_t rs=((aO-pdoti)*(aO-pdoti)+b2)/((aO+pdoti)*(aO+pdoti)+b2);
357 Float_t rp=rs*((aO-sinin*tanin)*(aO-sinin*tanin)+b2)/((aO+sinin*tanin)*(aO+sinin*tanin)+b2);
358
359
360 //CORRECTION FACTOR FOR SURFACE ROUGHNESS
361 //B.J. STAGG APPLIED OPTICS, 30(1991),4113
362
363 Float_t sigraf=18.;
364 Float_t lamb=1240/ene;
365 Float_t fresn;
366
367 Float_t rO=TMath::Exp(-(4*TMath::Pi()*pdoti*sigraf/lamb)*(4*TMath::Pi()*pdoti*sigraf/lamb));
368
369 if(pola)
370 {
371 Float_t pdotr=0.8; //DEGREE OF POLARIZATION : 1->P , -1->S
372 fresn=0.5*(rp*(1+pdotr)+rs*(1-pdotr));
373 }
374 else
375 fresn=0.5*(rp+rs);
376
377 fresn = fresn*rO;
378 return(fresn);
53fd478b 379}//Fresnel()
c021cb15 380//__________________________________________________________________________________________________
dfb4e77d 381void AliRICH::MakeBranch(Option_t* option)
53fd478b 382{
383//Create Tree branches for the RICH.
998b831f 384 AliDebug(1,Form("Start with option= %s.",option));
dfb4e77d 385
386 const Int_t kBufferSize = 4000;
dfb4e77d 387
dfb4e77d 388 const char *cH = strstr(option,"H");
389 const char *cD = strstr(option,"D");
390 const char *cR = strstr(option,"R");
391 const char *cS = strstr(option,"S");
392
c60862bf 393 if(cH&&TreeH()){//H
0fe8fa07 394 HitsCreate(); //branch will be created in AliDetector::MakeBranch
c60862bf 395 }//H
dfb4e77d 396 AliDetector::MakeBranch(option);//this is after cH because we need to guarantee that fHits array is created
397
c60862bf 398 if(cS&&fLoader->TreeS()){//S
0fe8fa07 399 SDigitsCreate(); MakeBranchInTree(fLoader->TreeS(),"RICH",&fSdigits,kBufferSize,0) ;
c60862bf 400 }//S
dfb4e77d 401
c60862bf 402 if(cD&&fLoader->TreeD()){//D
0fe8fa07 403 DigitsCreate();
e42a7b46 404 for(Int_t i=0;i<kNchambers;i++){
0fe8fa07 405 MakeBranchInTree(fLoader->TreeD(),Form("%s%d",GetName(),i+1),&((*fDigs)[i]),kBufferSize,0);
543d5224 406 }
c60862bf 407 }//D
408
409 if(cR&&fLoader->TreeR()){//R
0fe8fa07 410 ClustersCreate();
e42a7b46 411 for(Int_t i=0;i<kNchambers;i++)
0fe8fa07 412 MakeBranchInTree(fLoader->TreeR(),Form("%sClusters%d",GetName(),i+1), &((*fClus)[i]), kBufferSize, 0);
cb8189e7 413 }//R
998b831f 414 AliDebug(1,"Stop.");
c021cb15 415}//void AliRICH::MakeBranch(Option_t* option)
c60862bf 416//__________________________________________________________________________________________________
dfb4e77d 417void AliRICH::SetTreeAddress()
53fd478b 418{
419//Set branch address for the Hits and Digits Tree.
998b831f 420 AliDebug(1,"Start.");
c60862bf 421
dfb4e77d 422 TBranch *branch;
dfb4e77d 423
c60862bf 424 if(fLoader->TreeH()){//H
998b831f 425 AliDebug(1,"tree H is requested.");
0fe8fa07 426 HitsCreate();//branch map will be in AliDetector::SetTreeAddress
c60862bf 427 }//H
c021cb15 428 AliDetector::SetTreeAddress();//this is after TreeH because we need to guarantee that fHits array is created
429
c60862bf 430 if(fLoader->TreeS()){//S
998b831f 431 AliDebug(1,"tree S is requested.");
0fe8fa07 432 branch=fLoader->TreeS()->GetBranch(GetName()); if(branch){SDigitsCreate(); branch->SetAddress(&fSdigits);}
c60862bf 433 }//S
dfb4e77d 434
c60862bf 435 if(fLoader->TreeD()){//D
998b831f 436 AliDebug(1,"tree D is requested.");
e42a7b46 437 for(int i=0;i<kNchambers;i++){
c60862bf 438 branch=fLoader->TreeD()->GetBranch(Form("%s%d",GetName(),i+1));
0fe8fa07 439 if(branch){DigitsCreate(); branch->SetAddress(&((*fDigs)[i]));}
aed240d4 440 }
c60862bf 441 }//D
dfb4e77d 442
c60862bf 443 if(fLoader->TreeR()){//R
998b831f 444 AliDebug(1,"tree R is requested.");
e42a7b46 445 for(int i=0;i<kNchambers;i++){
c60862bf 446 branch=fLoader->TreeR()->GetBranch(Form("%sClusters%d" ,GetName(),i+1));
0fe8fa07 447 if(branch){ClustersCreate(); branch->SetAddress(&((*fClus)[i]));}
dfb4e77d 448 }
c60862bf 449 }//R
998b831f 450 AliDebug(1,"Stop.");
dfb4e77d 451}//void AliRICH::SetTreeAddress()
c021cb15 452//__________________________________________________________________________________________________
dfb4e77d 453void AliRICH::Print(Option_t *option)const
454{
53fd478b 455//Debug printout
dfb4e77d 456 TObject::Print(option);
e42a7b46 457 P()->Print();
458 fCounters.Print();
dfb4e77d 459}//void AliRICH::Print(Option_t *option)const
c021cb15 460//__________________________________________________________________________________________________
e42a7b46 461void AliRICH::ControlPlots()
462{
d3eb6079 463//Creates a set of QA hists to control the results of simulation. Hists are in file $HOME/RCP.root
a25b3368 464 TH1F *pElecP=0 ,*pMuonP=0 ,*pPionP=0 ,*pKaonP=0 ,*pProtP=0, //stack particles
d3eb6079 465 *pHxD=0,*pHyD=0,*pHxSd=0,*pHySd=0, //diff hit position - digit sdigit position
466 *pNumClusH1=0,
e42a7b46 467 *pQdcH1=0, *pSizeH1=0,
468 *pPureMipQdcH1=0,*pPureMipSizeH1=0,
469 *pPureCerQdcH1=0,*pPureCerSizeH1=0,
470 *pPureFeeQdcH1=0,*pPureFeeSizeH1=0,
471 *pMipQdcH1=0, *pPhotQdcH1=0;
472 TH2F *pMapH2=0,*pPureMipMapH2=0,*pPureCerMapH2=0,*pPureFeeMapH2=0;
d3eb6079 473 TH1F *pelecRadius=0,*pprotRadius=0,*pprotbarRadius=0;
474//load all information
475 GetLoader()->GetRunLoader()->LoadHeader();
476 GetLoader()->GetRunLoader()->LoadKinematics();
477 GetLoader()->LoadHits();
478 Bool_t isSdig=0;//!GetLoader()->LoadSDigits();
479 Bool_t isDig =0;//!GetLoader()->LoadDigits();
e42a7b46 480 Bool_t isClus=!GetLoader()->LoadRecPoints();
481
d3eb6079 482 gBenchmark->Start("ControlPlots");
c021cb15 483
e42a7b46 484 TFile *pFile = new TFile("$(HOME)/RCP.root","RECREATE");
d3eb6079 485
486 pElecP=new TH1F("Pelec","Electrons made hit in RICH;p [GeV]",1000,-30,30);
487 pMuonP=new TH1F("Pmuon","Muons made hit in RICH;p [GeV]",1000,-30,30);
488 pPionP=new TH1F("Ppion","Pions made hit in RICH;p [GeV]",1000,-30,30);
489 pKaonP=new TH1F("Pkaon","Kaon made hit in RICH;p [GeV]",1000,-30,30);
490 pProtP=new TH1F("Pprot","Protons made hit in RICH;p [GeV]",1000,-30,30);
491 pelecRadius=new TH1F("elecRadius","elec",600,0.,600.);
492 pprotRadius=new TH1F("protRadius","elec",600,0.,600.);
493 pprotbarRadius=new TH1F("protbarRadius","elec",600,0.,600.);
494
495 if(isSdig){
496 AliInfo("SDigits available");
497 pHxSd=new TH1F("DiffHitSDigitX","Hit-SDigit diff X all chambers;diff [cm]",300,-10,10);
498 pHySd=new TH1F("DiffHitSDigitY","Hit-SDigit diff Y all chambers;diff [cm]",300,-10,10);
499 }//isSdig
e42a7b46 500
501 if(isDig){
998b831f 502 AliInfo("Digits available");
d3eb6079 503 pHxD=new TH1F("DiffHitDigitX","Hit-Digit diff X all chambers;diff [cm]",300,-10,10);
504 pHyD=new TH1F("DiffHitDigitY","Hit-Digit diff Y all chambers;diff [cm]",300,-10,10);
e42a7b46 505 }//isDig
506
507 if(isClus){
a25b3368 508 AliInfo("Clusters available");
e42a7b46 509 pNumClusH1=new TH1F("NumClusPerEvent","Number of clusters per event;number",50,0,49);
c021cb15 510
a25b3368 511 pQdcH1 =new TH1F("ClusQdc", "Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
e42a7b46 512 pSizeH1 =new TH1F("ClusSize", "Cluster size all chambers;size [number of pads in cluster]",100,0,100);
a25b3368 513 pMapH2 =new TH2F("ClusMap", "Cluster map;x [cm];y [cm]",1000,0,P()->PcSizeX(),1000,0,P()->PcSizeY());
e42a7b46 514
a25b3368 515 pMipQdcH1 =new TH1F("QdcMip" ,"MIP Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
516 pPhotQdcH1 =new TH1F("QdcPhot" ,"Cer+Fee Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
e42a7b46 517
a25b3368 518 pPureMipQdcH1 =new TH1F("QdcPureMip" ,"MIP only Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
e42a7b46 519 pPureMipSizeH1=new TH1F("SizePureMip" ,"MIP only Cluster size all chambers;size [number of pads in cluster]",100,0,100);
a25b3368 520 pPureMipMapH2 =new TH2F("MapPureMip" ,"MIP only Cluster map;x [cm];y [cm]",1000,0,P()->PcSizeX(),1000,0,P()->PcSizeY());
e42a7b46 521
a25b3368 522 pPureCerQdcH1 =new TH1F("QdcPureCer" ,"Cerenkov only Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
e42a7b46 523 pPureCerSizeH1=new TH1F("SizePureCer" ,"Cernekov only Cluster size all chambers;size [number of pads in cluster]",100,0,100);
a25b3368 524 pPureCerMapH2 =new TH2F("MapPureCer" ,"Cerenkov only Cluster map;x [cm];y [cm]",1000,0,P()->PcSizeX(),1000,0,P()->PcSizeY());
c021cb15 525
a25b3368 526 pPureFeeQdcH1 =new TH1F("QdcPureFee" ,"Feedback only Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
e42a7b46 527 pPureFeeSizeH1=new TH1F("SizePureFee" ,"Feedback only Cluster size all chambers;size [number of pads in cluster]",100,0,100);
a25b3368 528 pPureFeeMapH2 =new TH2F("MapPureFee" ,"Feedback only Cluster map;x [cm];y [cm]",1000,0,P()->PcSizeX(),1000,0,P()->PcSizeY());
d3eb6079 529
e42a7b46 530 }//isClus
d3eb6079 531//end of hists booking
e42a7b46 532 for(Int_t iEvtN=0;iEvtN < GetLoader()->GetRunLoader()->GetAliRun()->GetEventsPerRun();iEvtN++){//events loop
d3eb6079 533 GetLoader()->GetRunLoader()->GetEvent(iEvtN); //get current event
c021cb15 534
a25b3368 535 for(Int_t iPrimN=0;iPrimN < GetLoader()->TreeH()->GetEntries();iPrimN++){//hit tree loop
536 GetLoader()->TreeH()->GetEntry(iPrimN);
d3eb6079 537 for(Int_t j=0;j<Hits()->GetEntries();j++){//hits loop
0fe8fa07 538 AliRICHHit *pHit = (AliRICHHit*)Hits()->At(j);
d3eb6079 539 TParticle *pParticle = GetLoader()->GetRunLoader()->Stack()->Particle(pHit->GetTrack());//get particle produced this hit
0fe8fa07 540 Double_t dRadius = TMath::Sqrt(pParticle->Vx()*pParticle->Vx()+pParticle->Vy()*pParticle->Vy()+pParticle->Vz()*pParticle->Vz());
a25b3368 541 switch(pParticle->GetPdgCode()){
0fe8fa07 542 case kPositron : pElecP->Fill( pParticle->P());pelecRadius->Fill(dRadius); break;
543 case kElectron : pElecP->Fill(-pParticle->P());pelecRadius->Fill(dRadius); break;
a25b3368 544
545 case kMuonPlus : pMuonP->Fill( pParticle->P()); break;
546 case kMuonMinus: pMuonP->Fill(-pParticle->P()); break;
547
548 case kPiPlus : pPionP->Fill( pParticle->P()); break;
549 case kPiMinus : pPionP->Fill(-pParticle->P()); break;
550
551 case kKPlus : pKaonP->Fill( pParticle->P()); break;
552 case kKMinus : pKaonP->Fill(-pParticle->P()); break;
553
0fe8fa07 554 case kProton : pProtP->Fill( pParticle->P()); pprotRadius->Fill(dRadius); break;
555 case kProtonBar: pProtP->Fill(-pParticle->P()); pprotbarRadius->Fill(dRadius); break;
a25b3368 556
557 }//switch PdgCode
558
559 }//hits loop
560 }//hit tree loop
c021cb15 561
d3eb6079 562 if(isSdig){
563 GetLoader()->TreeS()->GetEntry(0);
564 for(Int_t iSdigN=0;iSdigN<SDigits()->GetEntries();iSdigN++){//sdigits loop
0fe8fa07 565 AliRICHDigit *pSdig=(AliRICHDigit*)SDigits()->At(iSdigN); //get current sdigit pointer
566 AliRICHHit *pHit=Hit(pSdig->GetTrack(0)); //get hit of this sdigit (always one)
d3eb6079 567 TVector2 hit2 =C(pHit->C())->Mrs2Pc(pHit->OutX3()); //this hit position in local system
568 TVector2 sdig2=P()->Pad2Loc(pSdig->Pad()); //center of pad for this sdigit
569 pHxSd->Fill(hit2.X()-sdig2.X());
570 pHySd->Fill(hit2.Y()-sdig2.Y());
571 }//sdigits loop
572 }//if(isSdig)
573
e42a7b46 574 if(isDig) GetLoader()->TreeD()->GetEntry(0);
d3eb6079 575 if(isClus) GetLoader()->TreeR()->GetEntry(0);
c021cb15 576
e42a7b46 577 for(Int_t iChamN=1;iChamN<=7;iChamN++){//chambers loop
d3eb6079 578 if(isDig){
579 for(Int_t iDigN=0;iDigN<Digits(iChamN)->GetEntries();iDigN++){//digits loop
0fe8fa07 580 AliRICHDigit *pDig=(AliRICHDigit*)Digits(iChamN)->At(iDigN);
581 AliRICHHit *pHit=Hit(pDig->GetTrack(0)); //get first hit of this digit
d3eb6079 582 TVector2 hitV2=C(iChamN)->Mrs2Pc(pHit->OutX3());
583 TVector2 digV2=P()->Pad2Loc(pDig->Pad()); //center of pad for this digit
584 pHxD->Fill(hitV2.X()-digV2.X()); pHyD->Fill(hitV2.Y()-digV2.Y());
585 }//digits loop
586 }//isDig
e42a7b46 587 if(isClus){
588 Int_t iNclusCham=Clusters(iChamN)->GetEntries(); if(iNclusCham) pNumClusH1->Fill(iNclusCham);//number of clusters per event
589 for(Int_t iClusN=0;iClusN<iNclusCham;iClusN++){//clusters loop
0fe8fa07 590 AliRICHCluster *pClus=(AliRICHCluster*)Clusters(iChamN)->At(iClusN);
e42a7b46 591 pQdcH1 ->Fill(pClus->Q());
592 pSizeH1 ->Fill(pClus->Size());
593 pMapH2 ->Fill(pClus->X(),pClus->Y()); //common
594
595 if(pClus->IsSingleMip()) {pPureMipQdcH1 ->Fill(pClus->Q());
596 pPureMipSizeH1->Fill(pClus->Size());
597 pPureMipMapH2 ->Fill(pClus->X(),pClus->Y());}//Pure Mips
598
599 if(pClus->IsSingleCerenkov()){pPureCerQdcH1 ->Fill(pClus->Q());
600 pPureCerSizeH1->Fill(pClus->Size());
601 pPureCerMapH2 ->Fill(pClus->X(),pClus->Y());}//Pure Cerenkovs
602
603 if(pClus->IsSingleFeedback()){pPureFeeQdcH1 ->Fill(pClus->Q());
604 pPureFeeSizeH1->Fill(pClus->Size());
605 pPureFeeMapH2 ->Fill(pClus->X(),pClus->Y());}//Pure Feedbacks
606
607 if(pClus->IsMip()) {pMipQdcH1 ->Fill(pClus->Q());} //MIP+ other contributions
608 if(!pClus->IsPureMip()) pPhotQdcH1->Fill(pClus->Q()); //not MIP
609 }//clusters loop
610 }//isClus
e42a7b46 611 }//chambers loop
612 Info("ControlPlots","Event %i processed.",iEvtN);
613 }//events loop
d3eb6079 614 GetLoader()->UnloadHits();
615 if(isSdig) GetLoader()->UnloadSDigits();
e42a7b46 616 if(isDig) GetLoader()->UnloadDigits();
617 if(isClus) GetLoader()->UnloadRecPoints();
618
a25b3368 619 GetLoader()->GetRunLoader()->UnloadHeader();
620 GetLoader()->GetRunLoader()->UnloadKinematics();
621
e42a7b46 622 pFile->Write(); delete pFile;
d3eb6079 623
624 gBenchmark->Show("ControlPlots");
e42a7b46 625}//ControlPlots()
626//__________________________________________________________________________________________________
0fe8fa07 627AliRICHHit* AliRICH::Hit(Int_t tid)const
e42a7b46 628{
629//defines which hit provided by given tid for the currently loaded event
a25b3368 630 GetLoader()->LoadHits();
631 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
632 GetLoader()->TreeH()->GetEntry(iPrimN);
633 for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){
0fe8fa07 634 AliRICHHit *pHit=(AliRICHHit*)Hits()->At(iHitN);
a25b3368 635 if(tid==pHit->Track()) {GetLoader()->UnloadHits();return pHit;}
e42a7b46 636 }//hits
637 }//prims loop
a25b3368 638 GetLoader()->UnloadHits();
e42a7b46 639 return 0;
640}
641//__________________________________________________________________________________________________
0fe8fa07 642void AliRICH::HitsPrint(Int_t iEvtN)const
e42a7b46 643{
644//Prints a list of RICH hits for a given event. Default is event number 0.
d3eb6079 645 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
998b831f 646 AliInfo(Form("List of RICH hits for event %i",iEvtN));
a25b3368 647 if(GetLoader()->LoadHits()) return;
e42a7b46 648
649 Int_t iTotalHits=0;
a25b3368 650 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
651 GetLoader()->TreeH()->GetEntry(iPrimN);
652 Hits()->Print();
653 iTotalHits+=Hits()->GetEntries();
e42a7b46 654 }
a25b3368 655 GetLoader()->UnloadHits();
998b831f 656 AliInfo(Form("totally %i hits",iTotalHits));
e42a7b46 657}
658//__________________________________________________________________________________________________
0fe8fa07 659void AliRICH::SDigitsPrint(Int_t iEvtN)const
e42a7b46 660{
661//prints a list of RICH sdigits for a given event
d3eb6079 662 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
e42a7b46 663 Info("PrintSDigits","List of RICH sdigits for event %i",iEvtN);
a25b3368 664 if(GetLoader()->LoadSDigits()) return;
e42a7b46 665
a25b3368 666 GetLoader()->TreeS()->GetEntry(0);
667 SDigits()->Print();
668 GetLoader()->UnloadSDigits();
669 Info("PrintSDigits","totally %i sdigits",SDigits()->GetEntries());
e42a7b46 670}
671//__________________________________________________________________________________________________
0fe8fa07 672void AliRICH::DigitsPrint(Int_t iEvtN)const
e42a7b46 673{
674//prints a list of RICH digits for a given event
d3eb6079 675 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
e42a7b46 676 Info("PrintDigits","List of RICH digits for event %i",iEvtN);
a25b3368 677 if(GetLoader()->LoadDigits()) return;
e42a7b46 678
679 Int_t iTotalDigits=0;
a25b3368 680 GetLoader()->TreeD()->GetEntry(0);
e42a7b46 681 for(Int_t iChamber=1;iChamber<=kNchambers;iChamber++){
a25b3368 682 Digits(iChamber)->Print();
683 iTotalDigits+=Digits(iChamber)->GetEntries();
e42a7b46 684 }
a25b3368 685 GetLoader()->UnloadDigits();
e42a7b46 686 Info("PrintDigits","totally %i Digits",iTotalDigits);
687}
688//__________________________________________________________________________________________________
0fe8fa07 689void AliRICH::ClustersPrint(Int_t iEvtN)const
e42a7b46 690{
691//prints a list of RICH clusters for a given event
d3eb6079 692 AliInfo(Form("List of RICH clusters for event %i",iEvtN));
a25b3368 693 GetLoader()->GetRunLoader()->GetEvent(iEvtN);
694 if(GetLoader()->LoadRecPoints()) return;
e42a7b46 695
696 Int_t iTotalClusters=0;
a25b3368 697 GetLoader()->TreeR()->GetEntry(0);
e42a7b46 698 for(Int_t iChamber=1;iChamber<=kNchambers;iChamber++){
a25b3368 699 Clusters(iChamber)->Print();
700 iTotalClusters+=Clusters(iChamber)->GetEntries();
e42a7b46 701 }
a25b3368 702 GetLoader()->UnloadRecPoints();
d3eb6079 703 AliInfo(Form("totally %i clusters for event %i",iTotalClusters,iEvtN));
e42a7b46 704}
705//__________________________________________________________________________________________________
998b831f 706void AliRICH::PrintTracks(Int_t iEvtN)
e42a7b46 707{
a25b3368 708//prints a list of tracks (including secondary) for a given event
709 AliInfo(Form("List of all tracks for event %i",iEvtN));
710 GetLoader()->GetRunLoader()->GetEvent(iEvtN);
711 if(GetLoader()->GetRunLoader()->LoadHeader()) return;
712 if(GetLoader()->GetRunLoader()->LoadKinematics()) return;
713 AliStack *pStack=GetLoader()->GetRunLoader()->Stack();
714
d3eb6079 715 for(Int_t i=0;i<pStack->GetNtrack();i++) pStack->Particle(i)->Print();
a25b3368 716
d3eb6079 717 AliInfo(Form("totally %i tracks including %i primaries for event %i",pStack->GetNtrack(),pStack->GetNprimary(),iEvtN));
a25b3368 718 GetLoader()->GetRunLoader()->UnloadHeader();
719 GetLoader()->GetRunLoader()->UnloadKinematics();
e42a7b46 720}
a25b3368 721//__________________________________________________________________________________________________
d3eb6079 722void AliRICH::GeomPadPanelFrame()const
a25b3368 723{
724//Pad Panel frame 6 sectors
725 Double_t cm=1,mm=0.1*cm;//default is cm
726 Float_t par[3];
727
728 par[0]=648*mm/2;par[1]= 411*mm/2;par[2]=40 *mm/2;gMC->Gsvolu("RPPF","BOX ",(*fIdtmed)[kAl] ,par,3);//PPF 2001P2 inner size of the slab by 1mm more
729 par[0]=181*mm/2;par[1]=89.25*mm/2;par[2]=38.3*mm/2;gMC->Gsvolu("PPFL","BOX ",(*fIdtmed)[kAir] ,par,3);//large whole
730 par[0]=114*mm/2;par[1]=89.25*mm/2;par[2]=38.3*mm/2;gMC->Gsvolu("PPFS","BOX ",(*fIdtmed)[kAir] ,par,3);//small whole
731 par[0]=644*mm/2;par[1]= 407*mm/2;par[2]= 1.7*mm/2;gMC->Gsvolu("RPC ","BOX ",(*fIdtmed)[kCsI] ,par,3);//by 0.2 mm more then actual size (PCB 2006P1)
732
733 gMC->Gspos("RPPF",1,"RICH", -335*mm, -433*mm, 8*cm+20*mm, 0,"ONLY");//F1 2040P1 z p.84 TDR
734 gMC->Gspos("RPPF",2,"RICH", +335*mm, -433*mm, 8*cm+20*mm, 0,"ONLY");
735 gMC->Gspos("RPPF",3,"RICH", -335*mm, 0*mm, 8*cm+20*mm, 0,"ONLY");
736 gMC->Gspos("RPPF",4,"RICH", +335*mm, 0*mm, 8*cm+20*mm, 0,"ONLY");
737 gMC->Gspos("RPPF",5,"RICH", -335*mm, +433*mm, 8*cm+20*mm, 0,"ONLY");
738 gMC->Gspos("RPPF",6,"RICH", +335*mm, +433*mm, 8*cm+20*mm, 0,"ONLY");
739 gMC->Gspos("RPC ",1,"RPPF", 0*mm, 0*mm, -19.15*mm, 0,"ONLY");//PPF 2001P2
740 gMC->Gspos("PPFL",1,"RPPF", -224.5*mm, -151.875*mm, 0.85*mm, 0,"ONLY");
741 gMC->Gspos("PPFL",2,"RPPF", -224.5*mm, - 50.625*mm, 0.85*mm, 0,"ONLY");
742 gMC->Gspos("PPFL",3,"RPPF", -224.5*mm, + 50.625*mm, 0.85*mm, 0,"ONLY");
743 gMC->Gspos("PPFL",4,"RPPF", -224.5*mm, +151.875*mm, 0.85*mm, 0,"ONLY");
744 gMC->Gspos("PPFS",1,"RPPF", - 65.0*mm, -151.875*mm, 0.85*mm, 0,"ONLY");
745 gMC->Gspos("PPFS",2,"RPPF", - 65.0*mm, - 50.625*mm, 0.85*mm, 0,"ONLY");
746 gMC->Gspos("PPFS",3,"RPPF", - 65.0*mm, + 50.625*mm, 0.85*mm, 0,"ONLY");
747 gMC->Gspos("PPFS",4,"RPPF", - 65.0*mm, +151.875*mm, 0.85*mm, 0,"ONLY");
748 gMC->Gspos("PPFS",5,"RPPF", + 65.0*mm, -151.875*mm, 0.85*mm, 0,"ONLY");
749 gMC->Gspos("PPFS",6,"RPPF", + 65.0*mm, - 50.625*mm, 0.85*mm, 0,"ONLY");
750 gMC->Gspos("PPFS",7,"RPPF", + 65.0*mm, + 50.625*mm, 0.85*mm, 0,"ONLY");
751 gMC->Gspos("PPFS",8,"RPPF", + 65.0*mm, +151.875*mm, 0.85*mm, 0,"ONLY");
752 gMC->Gspos("PPFL",5,"RPPF", +224.5*mm, -151.875*mm, 0.85*mm, 0,"ONLY");
753 gMC->Gspos("PPFL",6,"RPPF", +224.5*mm, - 50.625*mm, 0.85*mm, 0,"ONLY");
754 gMC->Gspos("PPFL",7,"RPPF", +224.5*mm, + 50.625*mm, 0.85*mm, 0,"ONLY");
755 gMC->Gspos("PPFL",8,"RPPF", +224.5*mm, +151.875*mm, 0.85*mm, 0,"ONLY");
756}//GeomPadPanelFrame()
757//__________________________________________________________________________________________________
d3eb6079 758void AliRICH::GeomAmpGap()const
a25b3368 759{
760//Gap - anod wires 6 copies to RICH
761 Double_t cm=1,mm=0.1*cm,mkm=0.001*mm;//default is cm
762 Int_t matrixIdReturn=0; //matrix id returned by AliMatrix
763 Float_t par[3];
764
765 par[0]=648*mm/2;par[1]= 411*mm/2 ;par[2]=4.45*mm/2;gMC->Gsvolu("RGAP ","BOX ",(*fIdtmed)[kCH4] ,par,3);//xy as PPF 2001P2 z WP 2099P1
766 par[0]= 0*mm ;par[1]= 20*mkm/2 ;par[2]= 648*mm/2;gMC->Gsvolu("RANO","TUBE",(*fIdtmed)[kW] ,par,3);//WP 2099P1 z = gap x PPF 2001P2
767 AliMatrix(matrixIdReturn,180,0, 90,90, 90,0); //wires along x
768
769 gMC->Gspos("RGAP",1,"RICH", -335*mm, -433*mm,8*cm-2.225*mm, 0,"ONLY"); //F1 2040P1 z WP 2099P1
770 gMC->Gspos("RGAP",2,"RICH", +335*mm, -433*mm,8*cm-2.225*mm, 0,"ONLY");
771 gMC->Gspos("RGAP",3,"RICH", -335*mm, 0*mm,8*cm-2.225*mm, 0,"ONLY");
772 gMC->Gspos("RGAP",4,"RICH", +335*mm, 0*mm,8*cm-2.225*mm, 0,"ONLY");
773 gMC->Gspos("RGAP",5,"RICH", -335*mm, +433*mm,8*cm-2.225*mm, 0,"ONLY");
774 gMC->Gspos("RGAP",6,"RICH", +335*mm, +433*mm,8*cm-2.225*mm, 0,"ONLY");
775 for(int i=1;i<=96;i++)
776 gMC->Gspos("RANO",i,"RGAP", 0*mm, -411/2*mm+i*4*mm, 0.185*mm, matrixIdReturn,"ONLY"); //WP 2099P1
777}//GeomAmpGap()
778//__________________________________________________________________________________________________
d3eb6079 779void AliRICH::GeomRadiators()const
a25b3368 780{
781//Defines radiators geometry
782 Double_t mm=0.1;//default is cm
783 Float_t par[3];
784 par[0]=1330*mm/2 ;par[1]= 413*mm/2 ;par[2]= 24*mm/2; gMC->Gsvolu("RRAD","BOX ",(*fIdtmed)[kC6F14] ,par,3); // Rad 2011P1
785 par[0]=1330*mm/2 ;par[1]= 413*mm/2 ;par[2]= 4*mm/2; gMC->Gsvolu("RRFR","BOX ",(*fIdtmed)[kRoha] ,par,3); //front
786 par[0]=1330*mm/2 ;par[1]= 413*mm/2 ;par[2]= 5*mm/2; gMC->Gsvolu("RRWI","BOX ",(*fIdtmed)[kSiO2] ,par,3); //window
787 par[0]=1330*mm/2 ;par[1]= 5*mm/2 ;par[2]= 15*mm/2; gMC->Gsvolu("RRLO","BOX ",(*fIdtmed)[kRoha] ,par,3); //long side
788 par[0]= 10*mm/2 ;par[1]= 403*mm/2 ;par[2]= 15*mm/2; gMC->Gsvolu("RRSH","BOX ",(*fIdtmed)[kRoha] ,par,3); //short side
789 par[0]= 0 ;par[1]= 10*mm/2 ;par[2]= 15*mm/2; gMC->Gsvolu("RRSP","TUBE",(*fIdtmed)[kSiO2] ,par,3); //spacer
790
791 gMC->Gspos("RRAD",1,"RICH", 0*mm,-434*mm, -12*mm, 0,"ONLY"); //3 radiators to RICH
792 gMC->Gspos("RRAD",2,"RICH", 0*mm, 0*mm, -12*mm, 0,"ONLY");
793 gMC->Gspos("RRAD",3,"RICH", 0*mm,+434*mm, -12*mm, 0,"ONLY");
794 gMC->Gspos("RRFR",1,"RRAD", 0*mm, 0*mm, -10.0*mm, 0,"ONLY"); //front cover
795 gMC->Gspos("RRWI",1,"RRAD", 0*mm, 0*mm, 9.5*mm, 0,"ONLY"); //quartz window (back cover)
796 gMC->Gspos("RRLO",1,"RRAD", 0*mm,-204*mm, -0.5*mm, 0,"ONLY"); //long side
797 gMC->Gspos("RRLO",2,"RRAD", 0*mm,+204*mm, -0.5*mm, 0,"ONLY"); //long side
798 gMC->Gspos("RRSH",1,"RRAD",-660*mm, 0*mm, -0.5*mm, 0,"ONLY"); //short side
799 gMC->Gspos("RRSH",2,"RRAD",+660*mm, 0*mm, -0.5*mm, 0,"ONLY"); //short side
800 for(int i=0;i<3;i++)
801 for(int j=0;j<10;j++)
802 gMC->Gspos("RRSP",10*i+j,"RRAD",-1330*mm/2+116*mm+j*122*mm,(i-1)*105*mm,-0.5*mm,0,"ONLY");//spacers
803}//GeomRadiators()
804//__________________________________________________________________________________________________
d3eb6079 805void AliRICH::GeomSandBox()const
a25b3368 806{
807//Defines SandBox geometry
808 Double_t mm=0.1;//default is cm
809 Float_t par[3];
810 par[0]=1419*mm/2 ;par[1]=1378*mm/2;par[2]=50.5*mm/2; gMC->Gsvolu("RSNB","BOX ",(*fIdtmed)[kAir] ,par,3); //2072P1
811 par[0]=1419*mm/2 ;par[1]=1378*mm/2;par[2]= 0.5*mm/2; gMC->Gsvolu("RSCO","BOX ",(*fIdtmed)[kAl] ,par,3); //cover
812 par[0]=1359*mm/2 ;par[1]=1318*mm/2;par[2]=49.5*mm/2; gMC->Gsvolu("RSHO","BOX ",(*fIdtmed)[kRoha] ,par,3); //honeycomb structure
813
814 gMC->Gspos("RSNB",1,"RICH", 0*mm, 0*mm, -73.75*mm, 0,"ONLY"); //p.84 TDR sandbox to rich
815 gMC->Gspos("RSHO",1,"RSNB", 0*mm, 0*mm, 0*mm, 0,"ONLY"); //2072P1 honeycomv to sandbox
816 gMC->Gspos("RSCO",1,"RSNB", 0*mm, 0*mm, +25*mm, 0,"ONLY"); //cover to sandbox
817 gMC->Gspos("RSCO",2,"RSNB", 0*mm, 0*mm, -25*mm, 0,"ONLY"); //cover to sandbox
818}//GeomSandBox()
819//__________________________________________________________________________________________________
d3eb6079 820void AliRICH::GeomRadioSrc()const
a25b3368 821{
822// Defines geometry for radioactive source
823 Double_t cm=1,mm=0.1*cm,mkm=0.001*cm;
824 Float_t par[3];
825
826 par[0]=0 ;par[1]= 70*mm/2 ;par[2]= 30*mm/2; gMC->Gsvolu("RSRC","TUBE",(*fIdtmed)[kCH4] ,par,3); //top src container
827 par[0]=0 ;par[1]= 38*mm/2 ;par[2]= 21.8*mm/2; gMC->Gsvolu("RSAG","TUBE",(*fIdtmed)[kAl] ,par,3); //Al glass
828 par[0]=0 ;par[1]= 34*mm/2 ;par[2]= 20*mm/2; gMC->Gsvolu("RSPP","TUBE",(*fIdtmed)[kPerpex] ,par,3); //perpex plug
829 par[0]=0 ;par[1]= 5*mm/2 ;par[2]= 15*mm/2; gMC->Gsvolu("RSSC","TUBE",(*fIdtmed)[kSteel] ,par,3); //steel screw in center of perpex
830 par[0]=0 ;par[1]= 2*mm/2 ;par[2]= 10*mm/2; gMC->Gsvolu("RSSS","TUBE",(*fIdtmed)[kSteel] ,par,3); //Steel screw to support Sr90
831 par[0]=0 ;par[1]= 1*mm/2 ;par[2]= 1*mm/2; gMC->Gsvolu("RSSR","TUBE",(*fIdtmed)[kSr90] ,par,3); //Sr90 source
832 par[0]=0 ;par[1]= 4*mm/2 ;par[2]= 10*mm/2; gMC->Gsvolu("RSWP","TUBE",(*fIdtmed)[kAir] ,par,3); //Air hole in perpex plug
833 par[0]=0 ;par[1]= 5*mm/2 ;par[2]= 1.8*mm/2; gMC->Gsvolu("RSWA","TUBE",(*fIdtmed)[kAir] ,par,3); //Air hole in Al glass bottom
834 par[0]=0 ;par[1]= 30*mm/2 ;par[2]= 50*mkm/2; gMC->Gsvolu("RSMF","TUBE",(*fIdtmed)[kMylar] ,par,3); //Mylar foil
835
836 gMC->Gspos("RSRC",1,"RICH", 30*cm, 0, 1*cm, 0,"ONLY"); //source to RICH
837 gMC->Gspos("RSMF",1,"RSRC", 0, 0,21.8*mm/2+50*mkm/2, 0,"ONLY");//mylar foil to top src volume
838 gMC->Gspos("RSAG",1,"RSRC", 0, 0, 0, 0,"ONLY");//Al glass to fake Src volume
839 gMC->Gspos("RSWA",1,"RSAG", 6*mm, 0, -10*mm, 0,"ONLY");//air whole in al glass bottom
840 gMC->Gspos("RSPP",1,"RSAG", 0, 0, 0.9*mm, 0,"ONLY");//perpex plug to Al glass
841 gMC->Gspos("RSWP",1,"RSPP", 6*mm, 0, -5*mm, 0,"ONLY");//air whole in perpex plug
842 gMC->Gspos("RSSC",1,"RSPP", 0, 0, 2.5*mm, 0,"ONLY");//steel screw in center of perpex plug
843 gMC->Gspos("RSSS",1,"RSPP", 6*mm, 0, 5*mm, 0,"ONLY");//steel screw to support Sr90 in perpex plug
844 gMC->Gspos("RSSR",1,"RSSS", 0, 0, -4.5*mm, 0,"ONLY");//Sr90 in support steel screw
845}//GeomSr90()
846//__________________________________________________________________________________________________
d3eb6079 847void AliRICH::GeomAerogel()const
a25b3368 848{
849//Creates detailed geometry for aerogel study.
850 AliDebug(1,"Start.");
851 Double_t cm=1;
852 Float_t par[3]; //tmp array for volume dimentions
853
854 par[0]=10.1*cm/2;par[1]=10.1*cm/2;par[2]=10.1*cm/2;
855 gMC->Gsvolu("RREF","BOX ",(*fIdtmed)[kReflector],par,3);//reflector box
856 gMC->Gspos("RREF",1,"RICH",0,0,0,0, "ONLY"); //put it to RICH volume
857
858 par[0]=10*cm/2;par[1]=10*cm/2;par[2]=10*cm/2;
859 gMC->Gsvolu("RGEL","BOX ",(*fIdtmed)[kGel],par,3);//10x10x10 cm^3 cubic of aerogel
860 gMC->Gspos("RGEL",1,"RREF",0,0,0,0,"ONLY");//put gel cell to reflector
861 AliDebug(1,"Stop.");
862}//GeomAerogel()
863//__________________________________________________________________________________________________
864void AliRICH::CreateGeometry()
865{
866//Creates detailed geometry simulation (currently GEANT volumes tree)
867 AliDebug(1,"Start main.");
868 Double_t mm=0.1;//default is cm
869 Float_t par[3];
870 Int_t matrixIdReturn=0; //matrix id returned by AliMatrix
871
872//place chambers into mother volume ALIC
873 par[0]=(6*mm+1681*mm+6*mm)/2;par[1]=(6*mm+1466*mm+6*mm)/2;par[2]=(80*mm+40*mm)*2/2;
874 gMC->Gsvolu("RICH","BOX ",(*fIdtmed)[kCH4],par,3);//2033P1 z p84 TDR
875 for(int i=1;i<=P()->Nchambers();i++){ //test configuration with single chamber is taken into account automaticaly in AliRICHParam
876 AliMatrix(matrixIdReturn,
877 C(i)->ThetaXd(),C(i)->PhiXd(),
878 C(i)->ThetaYd(),C(i)->PhiYd(),
879 C(i)->ThetaZd(),C(i)->PhiZd());
880 gMC->Gspos("RICH",i,"ALIC",C(i)->Center().X(),
881 C(i)->Center().Y(),
882 C(i)->Center().Z(),matrixIdReturn, "ONLY");
883 }
884
885 if(P()->IsAerogel())
886 GeomAerogel();
887 else{
888 GeomPadPanelFrame();
889 GeomAmpGap();
890 if(P()->IsRadioSrc()) GeomRadioSrc(); else GeomRadiators();
891 GeomSandBox();
892 }
893 AliDebug(1,"Stop main.");
894}//CreateGeometry()
895//__________________________________________________________________________________________________
d3eb6079 896void AliRICH::CheckPR()const
897{
898//Pattern recognition with stack particles
899 TFile *pFile = new TFile("$(HOME)/RPR.root","RECREATE","RICH Pattern Recognition");
900 TNtupleD *hn = new TNtupleD("hn","ntuple","Pmod:Charge:TrackTheta:TrackPhi:TrackX:TrackY:MinX:MinY:ChargeMIP:ThetaCerenkov:NPhotons:MipIndex:Chamber:Particle");
ef210ba6 901// printf("\n\n");
902// printf("Pattern Recognition done for event %5i",0);
d3eb6079 903 AliMagF * magf = gAlice->Field();
904 AliTracker::SetFieldMap(magf);
905 for(Int_t iEvtN=0;iEvtN<GetLoader()->GetRunLoader()->GetNumberOfEvents();iEvtN++) {
906 GetLoader()->GetRunLoader()->GetEvent(iEvtN);
907 AliRICHTracker *tr = new AliRICHTracker();
908 tr->RecWithStack(hn);
ef210ba6 909 Info("CheckPR","Pattern Recognition done for event %i \b",iEvtN);
910// printf("\b\b\b\b\b%5i",iEvtN+1);
d3eb6079 911 }
912 printf("\n\n");
913 pFile->Write();pFile->Close();
914}
0fe8fa07 915//__________________________________________________________________________________________________
916void AliRICH::DisplayEvent(Int_t iEvtNmin,Int_t iEvtNmax)const
917{
918 TH2F *pDigitsH2[8];
919
920 Bool_t isDigits =!GetLoader()->LoadDigits();
921 if(!isDigits){Error("ShoEvent","No digits. Nothing to display.");return;}
922
f770edb5 923 TCanvas *canvas = new TCanvas("RICHDisplay","RICH Display",0,0,1226,900);
924 gStyle->SetPalette(1);
0fe8fa07 925
926
927 for(Int_t iChamber=1;iChamber<=7;iChamber++) {
928 pDigitsH2[iChamber] = new TH2F(Form("pDigitsH2_%i",iChamber),Form("Chamber %i",iChamber),165,0,P()->PcSizeX(),144,0,P()->PcSizeY());
929 pDigitsH2[iChamber]->SetMarkerColor(kGreen);
930 pDigitsH2[iChamber]->SetMarkerStyle(29);
931 pDigitsH2[iChamber]->SetMarkerSize(0.4);
932 pDigitsH2[iChamber]->SetStats(kFALSE);
f770edb5 933 pDigitsH2[iChamber]->SetMaximum(300);
0fe8fa07 934 }
935
f770edb5 936 if(iEvtNmax>gAlice->GetEventsPerRun()||iEvtNmax==0) iEvtNmax=gAlice->GetEventsPerRun()-1;
0fe8fa07 937
d0831219 938 TLatex t; t.SetTextSize(0.1);
0fe8fa07 939 for(Int_t iEventN=iEvtNmin;iEventN<=iEvtNmax;iEventN++) {//events loop
f770edb5 940 canvas->Divide(3,3);
0fe8fa07 941 canvas->cd(1);
942 t.DrawText(0.2,0.4,Form("Event Number %i",iEventN));
943
944 GetLoader()->GetRunLoader()->GetEvent(iEventN); //get event
945 GetLoader()->TreeD()->GetEntry(0); //get list of digits
946 for(Int_t iChamber=1;iChamber<=7;iChamber++) {//chambers loop
947 pDigitsH2[iChamber]->Reset();
948 for(Int_t j=0;j<Digits(iChamber)->GetEntries();j++) {//digits loop
949 AliRICHDigit *pDig = (AliRICHDigit*)Digits(iChamber)->At(j);
950 TVector2 x2=AliRICHParam::Pad2Loc(pDig->Pad());
f770edb5 951 pDigitsH2[iChamber]->Fill(x2.X(),x2.Y(),pDig->Q());
0fe8fa07 952 }//digits loop
953 if(iChamber==1) canvas->cd(7);
954 if(iChamber==2) canvas->cd(8);
955 if(iChamber==3) canvas->cd(4);
956 if(iChamber==4) canvas->cd(5);
957 if(iChamber==5) canvas->cd(6);
958 if(iChamber==6) canvas->cd(2);
959 if(iChamber==7) canvas->cd(3);
f770edb5 960 pDigitsH2[iChamber]->Draw("col");
961 ReadESD(iEventN,iChamber);
962 AliRICHParam::DrawSectors();
0fe8fa07 963 }//chambers loop
964 canvas->Update();
965 canvas->Modified();
f770edb5 966
967 if(iEventN<iEvtNmax) {gPad->WaitPrimitive();canvas->Clear();}
0fe8fa07 968 }//events loop
969}//ShowEvent()
970//__________________________________________________________________________________________________
971void AliRICH::Display()const
972{
973//Provides fast event display
974//For RICH only, full display is .x Display.C
975 Bool_t isHits =!GetLoader()->LoadHits();
976 Bool_t isDigits =!GetLoader()->LoadDigits();
977 Bool_t isClusters=!GetLoader()->LoadRecPoints();
978
979 if(!isHits && !isDigits && !isClusters){Error("Exec","No hits digits and clusters. Nothing to display.");return;}
980
981 TCanvas *pCanvas = new TCanvas("Display","RICH Display",0,0,600,600);
982
983 TH2F *pHitsH2=0,*pDigitsH2=0,*pClustersH2=0;
984
985 if(isHits) pHitsH2 = new TH2F("pHitsH2" , "Event Display;x,cm;y,cm",165,0,AliRICHParam::PcSizeX(),
986 144,0,AliRICHParam::PcSizeY());
987 if(pHitsH2) pHitsH2->SetStats(kFALSE);
988
989 if(isDigits) pDigitsH2 = new TH2F("pDigitsH2" ,"Event Display",165,0,AliRICHParam::PcSizeX(),
990 144,0,AliRICHParam::PcSizeY());
991 if(isClusters) pClustersH2 = new TH2F("pClustersH2","Event Display",165,0,AliRICHParam::PcSizeX(),
992 144,0,AliRICHParam::PcSizeY());
993
994 for(Int_t iEventN=0;iEventN<gAlice->GetEventsPerRun();iEventN++){//events Loop
995 GetLoader()->GetRunLoader()->GetEvent(iEventN);
996//display all the staff on chamber by chamber basis
997 for(Int_t iChamber=1;iChamber<=7;iChamber++){//chambers loop
998 if(isHits) pHitsH2 ->Reset();
999 if(isDigits) pDigitsH2 ->Reset();
1000 if(isClusters) pClustersH2->Reset();
1001//deals with hits
1002 for(Int_t i=0;i<GetLoader()->TreeH()->GetEntries();i++){//TreeH loop
1003 GetLoader()->TreeH()->GetEntry(i);
1004 for(Int_t j=0;j<Hits()->GetEntries();j++){//hits loop
1005 AliRICHHit *pHit = (AliRICHHit*)Hits()->At(j);
1006 if(pHit->C()==iChamber){
1007 TVector3 hitGlobX3= pHit->OutX3();
1008 TVector2 hitLocX2 = C(iChamber)->Mrs2Pc(hitGlobX3);
1009 pHitsH2->Fill(hitLocX2.X(),hitLocX2.Y(),200);
1010 }//if
1011 }//hits loop
1012 }//TreeH loop
1013 pHitsH2->SetTitle(Form("event %i chamber %2i",iEventN,iChamber));
1014 pHitsH2->SetMarkerColor(kRed); pHitsH2->SetMarkerStyle(29); pHitsH2->SetMarkerSize(0.4);
f770edb5 1015 ReadESD(iEventN,iChamber);
0fe8fa07 1016 pHitsH2->Draw();
56030c8d 1017 ReadESD(iEventN,iChamber);
0fe8fa07 1018 AliRICHParam::DrawSectors();
1019 TLatex l; l.SetNDC(); l.SetTextSize(0.02);
1020 if(!isHits) {l.SetTextColor(kRed) ;l.DrawLatex(0.1,0.01,"No Hits" );}
1021 if(!isDigits) {l.SetTextColor(kGreen);l.DrawLatex(0.4,0.01,"No DIGITS" );}
1022 if(!isClusters) {l.SetTextColor(kBlue) ;l.DrawLatex(0.8,0.01,"No CLUSTERS");}
1023 pCanvas->Update(); pCanvas->Modified(); gPad->WaitPrimitive();
1024//deals with digits
1025 if(isDigits){
1026 GetLoader()->TreeD()->GetEntry(0);
1027 for(Int_t j=0;j<Digits(iChamber)->GetEntries();j++){//digits loop
1028 AliRICHDigit *pDig = (AliRICHDigit*)Digits(iChamber)->At(j);
1029 TVector2 x2=AliRICHParam::Pad2Loc(pDig->Pad());
1030 pDigitsH2->Fill(x2.X(),x2.Y(),100);
1031 }//digits loop
1032 pDigitsH2->SetMarkerColor(kGreen); pDigitsH2->SetMarkerStyle(29); pDigitsH2->SetMarkerSize(0.4);
1033 pDigitsH2->Draw("same");
1034 pCanvas->Update(); pCanvas->Modified(); gPad->WaitPrimitive();
1035 }//if(isDigits)
1036//deals with clusters
1037 if(isClusters){
1038 GetLoader()->TreeR()->GetEntry(0);
1039 for(Int_t j=0;j<Clusters(iChamber)->GetEntries();j++){//clusters loop
1040 AliRICHCluster *pClus = (AliRICHCluster*)Clusters(iChamber)->At(j);
1041 pClustersH2->Fill(pClus->X(),pClus->Y(),50);
1042 }//clusters loop
1043 pClustersH2->SetMarkerColor(kBlue); pClustersH2->SetMarkerStyle(29); pClustersH2->SetMarkerSize(0.4);
1044 pClustersH2->Draw("same");
1045 pCanvas->Update(); pCanvas->Modified(); gPad->WaitPrimitive();
1046 }//if(isClusters)
1047 }//chambers loop
1048 }//events Loop
1049
1050 delete pCanvas;
1051 GetLoader()->UnloadHits();
1052 if(isDigits) GetLoader()->UnloadDigits();
1053 if(isClusters) GetLoader()->UnloadRecPoints();
1054}//Display()
1055//__________________________________________________________________________________________________
1056Int_t AliRICH::Nparticles(Int_t iPartID,Int_t iEvtN,AliRunLoader *pRL)
1057{
1058//counts total number of particles of given type (including secondary) for a given event
1059 pRL->GetEvent(iEvtN);
1060 if(pRL->LoadHeader()) return 0;
1061 if(pRL->LoadKinematics()) return 0;
1062 AliStack *pStack=pRL->Stack();
1063
1064 Int_t iCounter=0;
1065 for(Int_t i=0;i<pStack->GetNtrack();i++){
1066 if(pStack->Particle(i)->GetPdgCode()==iPartID) iCounter++;
1067 }
1068
1069 pRL->UnloadHeader();
1070 pRL->UnloadKinematics();
1071 return iCounter;
1072}
56030c8d 1073//__________________________________________________________________________________________________
1074void AliRICH::ReadESD(Int_t iEventN, Int_t iChamber)const
1075{
1076//
f770edb5 1077 AliInfo("Start.");
56030c8d 1078 TFile *pFile=TFile::Open("AliESDs.root","read");
1079 if(!pFile || !pFile->IsOpen()) {AliInfo("ESD file not open.");return;} //open AliESDs.root
1080 TTree *pTree = (TTree*) pFile->Get("esdTree");
1081 if(!pTree){AliInfo("ESD not found.");return;} //get ESD tree
1082
f770edb5 1083 AliInfo("ESD found. Try to draw ring");
56030c8d 1084
1085 AliESD *pESD=new AliESD; pTree->SetBranchAddress("ESD", &pESD);
1086
1087 pTree->GetEvent(iEventN);
1088
1089 Double_t b = pESD->GetMagneticField()/10.;
1090
1091 Int_t iNtracks=pESD->GetNumberOfTracks();
1092
1093 for(Int_t iTrackN=0;iTrackN<iNtracks;iTrackN++){//ESD tracks loop
1094 AliESDtrack *pTrack = pESD->GetTrack(iTrackN);// get next reconstructed track
1095 Int_t iChTrack = pTrack->GetRICHcluster()/100000;
1096 if(iChTrack==iChamber) {
f770edb5 1097 Double_t thetaCer = pTrack->GetRICHsignal();
1098 if(thetaCer<0) continue;
56030c8d 1099 Int_t charge = (Int_t)(-TMath::Sign(1.,pTrack->GetSign()*b));
1100 AliRICHHelix helix(pTrack->X3(),pTrack->P3(),charge,b);
1101 helix.RichIntersect(P());
1102 TVector3 entrance(helix.PosRad().X(),helix.PosRad().Y(),0);
1103 Double_t thetaTrack,phiTrack;
1104 pTrack->GetRICHthetaPhi(thetaTrack,phiTrack);
1105 TVector3 vectorTrack;
1106 vectorTrack.SetMagThetaPhi(pTrack->GetP(),thetaTrack,phiTrack);
f770edb5 1107 AliInfo(Form("Draw ring started for track %i on chamber %i",iTrackN,iChamber));
1108 AliInfo(Form("ThetaCer %f TrackTheta %f TrackPhi %f Momentum %f",thetaCer,thetaTrack,phiTrack,pTrack->GetP()));
1109 Double_t dx,dy;
1110 pTrack->GetRICHdxdy(dx,dy);
1111 AliInfo(Form("dx %f dy %f ",dx,dy));
1112 DrawRing(entrance,vectorTrack,thetaCer);
1113 TMarker *trackImpact = new TMarker(helix.PosPc().X(),helix.PosPc().Y(),kStar);
1114 trackImpact->SetMarkerColor(kRed);
1115 trackImpact->Draw();
56030c8d 1116 }
1117 }
1118 delete pESD; pFile->Close();//close AliESDs.root
f770edb5 1119 AliInfo("Stop.");
56030c8d 1120}
1121//__________________________________________________________________________________________________
1122void AliRICH::DrawRing(TVector3 entrance,TVector3 vectorTrack,Double_t thetaCer)const
1123{
1124 Double_t xGraph[100],yGraph[100];
1125 Int_t nPointsToDraw = 0;
1126 for(Int_t i=0;i<100;i++) {
1127 Double_t phiCer = 2*TMath::Pi()*i/100;
1128 TVector3 pos = AliRICHParam::ForwardTracing(entrance,vectorTrack,thetaCer,phiCer);
f770edb5 1129 if(pos.X()==-999) continue;
56030c8d 1130 xGraph[nPointsToDraw] = pos.X();yGraph[nPointsToDraw] = pos.Y();nPointsToDraw++;
1131 }
f770edb5 1132 AliInfo(Form("Npoints per ring %i",nPointsToDraw));
56030c8d 1133 TGraph *gra = new TGraph(nPointsToDraw,xGraph,yGraph);
f770edb5 1134 gra->Draw("C");
56030c8d 1135}