1 // **************************************************************************
2 // * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 // * Author: The ALICE Off-line Project. *
5 // * Contributors are mentioned in the code where appropriate. *
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 // **************************************************************************
17 #include "AliRICHParam.h"
18 #include "AliRICHChamber.h"
19 #include "AliRICHTracker.h"
20 #include "AliRICHHelix.h"
21 //#include <TArrayF.h>
22 #include <TGeometry.h>
27 #include <TObjArray.h>
28 #include <TParticle.h>
32 #include <AliRunDigitizer.h>
35 #include <TVirtualMC.h>
38 #include <TBenchmark.h>
41 #include <AliTracker.h>
42 #include <AliRawDataHeader.h>
43 #include <TLatex.h> //Display()
44 #include <TCanvas.h> //Display()
45 #include <TGraph.h> //Display()
46 #include <TStyle.h> //Display()
47 #include <TMarker.h> //Display()
50 //__________________________________________________________________________________________________
54 <img src="gif/alirich.gif">
57 //__________________________________________________________________________________________________
58 AliRICH::AliRICH():AliDetector(),fParam(0), fSdigits(0),fNsdigits(0),fDigs(0),fClus(0)
60 //Default ctor should not contain any new operators
61 //AliDetector ctor deals with Hits and Digits
62 for(int i=0;i<kNchambers;i++) fNdigs[i] =0;
63 for(int i=0;i<kNchambers;i++) fNclus[i]=0;
64 // fCounters.ResizeTo(20); fCounters.Zero();
66 //__________________________________________________________________________________________________
67 AliRICH::AliRICH(const char *name, const char *title)
68 :AliDetector(name,title),fParam(new AliRICHParam),fSdigits(0),fNsdigits(0),fDigs(0),fClus(0)
72 //AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
73 HitsCreate(); gAlice->GetMCApp()->AddHitList(fHits);
74 fCounters.ResizeTo(20); fCounters.Zero();
76 }//AliRICH::AliRICH(const char *name, const char *title)
77 //__________________________________________________________________________________________________
83 if(fParam) delete fParam;
85 if(fHits) delete fHits;
86 if(fSdigits) delete fSdigits;
87 if(fDigits) delete fDigits;
88 if(fDigs) {fDigs->Delete(); delete fDigs;}
89 if(fClus) {fClus->Delete(); delete fClus;}
91 }//AliRICH::~AliRICH()
92 //__________________________________________________________________________________________________
93 void AliRICH::Hits2SDigits()
95 // Create a list of sdigits corresponding to list of hits. Every hit generates one or more sdigits.
97 for(Int_t iEventN=0;iEventN<GetLoader()->GetRunLoader()->GetAliRun()->GetEventsPerRun();iEventN++){//events loop
98 GetLoader()->GetRunLoader()->GetEvent(iEventN);//get next event
100 if(!GetLoader()->TreeH()) GetLoader()->LoadHits(); GetLoader()->GetRunLoader()->LoadHeader();
101 if(!GetLoader()->GetRunLoader()->TreeK()) GetLoader()->GetRunLoader()->LoadKinematics();//from
102 if(!GetLoader()->TreeS()) GetLoader()->MakeTree("S"); MakeBranch("S");//to
104 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
105 GetLoader()->TreeH()->GetEntry(iPrimN);
106 for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){//hits loop
107 AliRICHHit *pHit=(AliRICHHit*)Hits()->At(iHitN);//get current hit
108 TVector2 x2 = C(pHit->C())->Mrs2Anod(0.5*(pHit->InX3()+pHit->OutX3()));//hit position in the anod plane
109 Int_t iTotQdc=P()->TotQdc(x2,pHit->Eloss());//total charge produced by hit, 0 if hit in dead zone
110 if(iTotQdc==0) continue;
112 //need to quantize the anod....
113 TVector padHit=AliRICHParam::Loc2Pad(x2);
114 TVector2 padHitXY=AliRICHParam::Pad2Loc(padHit);
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
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));
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]++){
125 Double_t padQdc=iTotQdc*P()->FracQdc(anod,pad);
126 AliDebug(1,Form("current pad(%3.0f,%3.0f) with QDC =%6.2f",pad[0],pad[1],padQdc));
127 if(padQdc>0.1) SDigitAdd(pHit->C(),pad,padQdc,GetLoader()->GetRunLoader()->Stack()->Particle(pHit->GetTrack())->GetPdgCode(),pHit->GetTrack());
128 }//affected pads loop
131 GetLoader()->TreeS()->Fill();
132 GetLoader()->WriteSDigits("OVERWRITE");
135 GetLoader()->UnloadHits(); GetLoader()->GetRunLoader()->UnloadHeader(); GetLoader()->GetRunLoader()->UnloadKinematics();
136 GetLoader()->UnloadSDigits();
139 //__________________________________________________________________________________________________
140 void AliRICH::Digits2Raw()
142 //Loops over all digits and creates raw data files in DDL format. GetEvent() is done outside (AliSimulation)
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)
149 AliDebug(1,"Start.");
150 GetLoader()->LoadDigits();
151 GetLoader()->TreeD()->GetEntry(0);
153 Int_t kRichOffset=0x700; //currently one DDL per 3 sectors
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
159 for(Int_t iChN=1;iChN<=kNchambers;iChN++){ //2 DDL per chamber open both in parallel
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
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
166 Int_t counter135=0,counter246=0;//counts total number of records per DDL
168 for(Int_t iDigN=0;iDigN<Digits(iChN)->GetEntriesFast();iDigN++){//digits loop for a given chamber
169 AliRICHDigit *pDig=(AliRICHDigit*)Digits(iChN)->At(iDigN);
170 word32=UInt_t (pDig->Q()+0x400*pDig->X()+0x4000*pDig->Y()); //arbitrary structure
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;
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();
181 GetLoader()->UnloadDigits();
184 //__________________________________________________________________________________________________
185 void AliRICH::BuildGeometry()
187 //Builds a TNode geometry for event display
190 TNode *node, *subnode, *top;
191 top=gAlice->GetGeometry()->GetNode("alice");
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();
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
201 for(int i=1;i<=P()->Nchambers();i++){
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());
204 node->SetLineColor(kRed);
206 subnode = new TNode("PHOTO1","PHOTO1","RPC",-widx/2-dead/2,-leny-dead/2,dz,"");
207 subnode->SetLineColor(kGreen);
208 fNodes->Add(subnode);
209 subnode = new TNode("PHOTO1","PHOTO1","RPC", widx/2+dead/2,-leny-dead/2,dz,"");
210 subnode->SetLineColor(kGreen);
211 fNodes->Add(subnode);
212 subnode = new TNode("PHOTO1","PHOTO1","RPC",-widx/2-dead/2, 0,dz,"");
213 subnode->SetLineColor(kGreen);
214 fNodes->Add(subnode);
215 subnode = new TNode("PHOTO1","PHOTO1","RPC", widx/2+dead/2, 0,dz,"");
216 subnode->SetLineColor(kGreen);
217 fNodes->Add(subnode);
218 subnode = new TNode("PHOTO1","PHOTO1","RPC",-widx/2-dead/2, leny+dead/2,dz,"");
219 subnode->SetLineColor(kGreen);
220 fNodes->Add(subnode);
221 subnode = new TNode("PHOTO1","PHOTO1","RPC", widx/2+dead/2, leny+dead/2,dz,"");
222 subnode->SetLineColor(kGreen);
223 fNodes->Add(subnode);
228 }//void AliRICH::BuildGeometry()
229 //__________________________________________________________________________________________________
230 void AliRICH::CreateMaterials()
232 // Definition of available RICH materials
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
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();
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
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);
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);
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);
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);
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);
258 Float_t aFreon[2]={12,19}; Float_t zFreon[2]={6,9}; Float_t wmatFreon[2]={6,14}; // C12-6 F19-9
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);
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);
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);
268 AliMaterial(++material, "RichCsI", a=12.01,z=6.0, den=0.1, radl=18.8, absl=0); //6 CsI-radl equivalent
269 AliMedium(kCsI, "RichCsI", material, 1, isxfld, sxmgmx,tmaxfd, stemax, deemax, epsil, stmin);
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);
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);
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);
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);
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};
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);
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);
291 if(P()->IsRadioSrc()){
292 AliInfo("Special radioactive source materials");
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);
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);
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);
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);
307 //Optical properties:
308 #include "Opticals.h"
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
322 }//void AliRICH::CreateMaterials()
323 //__________________________________________________________________________________________________
324 Float_t AliRICH::Fresnel(Float_t ene,Float_t pdoti, Bool_t pola)
327 //ENE(EV), PDOTI=COS(INC.ANG.), PDOTR=COS(POL.PLANE ROT.ANG.)
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};
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,
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,
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]);
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
348 Float_t sinin=TMath::Sqrt(1-pdoti*pdoti);
349 Float_t tanin=sinin/pdoti;
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);
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);
360 //CORRECTION FACTOR FOR SURFACE ROUGHNESS
361 //B.J. STAGG APPLIED OPTICS, 30(1991),4113
364 Float_t lamb=1240/ene;
367 Float_t rO=TMath::Exp(-(4*TMath::Pi()*pdoti*sigraf/lamb)*(4*TMath::Pi()*pdoti*sigraf/lamb));
371 Float_t pdotr=0.8; //DEGREE OF POLARIZATION : 1->P , -1->S
372 fresn=0.5*(rp*(1+pdotr)+rs*(1-pdotr));
380 //__________________________________________________________________________________________________
381 void AliRICH::MakeBranch(Option_t* option)
383 //Create Tree branches for the RICH.
384 AliDebug(1,Form("Start with option= %s.",option));
386 const Int_t kBufferSize = 4000;
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");
394 HitsCreate(); //branch will be created in AliDetector::MakeBranch
396 AliDetector::MakeBranch(option);//this is after cH because we need to guarantee that fHits array is created
398 if(cS&&fLoader->TreeS()){//S
399 SDigitsCreate(); MakeBranchInTree(fLoader->TreeS(),"RICH",&fSdigits,kBufferSize,0) ;
402 if(cD&&fLoader->TreeD()){//D
404 for(Int_t i=0;i<kNchambers;i++){
405 MakeBranchInTree(fLoader->TreeD(),Form("%s%d",GetName(),i+1),&((*fDigs)[i]),kBufferSize,0);
409 if(cR&&fLoader->TreeR()){//R
411 for(Int_t i=0;i<kNchambers;i++)
412 MakeBranchInTree(fLoader->TreeR(),Form("%sClusters%d",GetName(),i+1), &((*fClus)[i]), kBufferSize, 0);
415 }//void AliRICH::MakeBranch(Option_t* option)
416 //__________________________________________________________________________________________________
417 void AliRICH::SetTreeAddress()
419 //Set branch address for the Hits and Digits Tree.
420 AliDebug(1,"Start.");
424 if(fLoader->TreeH()){//H
425 AliDebug(1,"tree H is requested.");
426 HitsCreate();//branch map will be in AliDetector::SetTreeAddress
428 AliDetector::SetTreeAddress();//this is after TreeH because we need to guarantee that fHits array is created
430 if(fLoader->TreeS()){//S
431 AliDebug(1,"tree S is requested.");
432 branch=fLoader->TreeS()->GetBranch(GetName()); if(branch){SDigitsCreate(); branch->SetAddress(&fSdigits);}
435 if(fLoader->TreeD()){//D
436 AliDebug(1,"tree D is requested.");
437 for(int i=0;i<kNchambers;i++){
438 branch=fLoader->TreeD()->GetBranch(Form("%s%d",GetName(),i+1));
439 if(branch){DigitsCreate(); branch->SetAddress(&((*fDigs)[i]));}
443 if(fLoader->TreeR()){//R
444 AliDebug(1,"tree R is requested.");
445 for(int i=0;i<kNchambers;i++){
446 branch=fLoader->TreeR()->GetBranch(Form("%sClusters%d" ,GetName(),i+1));
447 if(branch){ClustersCreate(); branch->SetAddress(&((*fClus)[i]));}
451 }//void AliRICH::SetTreeAddress()
452 //__________________________________________________________________________________________________
453 void AliRICH::Print(Option_t *option)const
456 TObject::Print(option);
459 }//void AliRICH::Print(Option_t *option)const
460 //__________________________________________________________________________________________________
461 void AliRICH::ControlPlots()
463 //Creates a set of QA hists to control the results of simulation. Hists are in file $HOME/RCP.root
464 TH1F *pElecP=0 ,*pMuonP=0 ,*pPionP=0 ,*pKaonP=0 ,*pProtP=0, //stack particles
465 *pHxD=0,*pHyD=0,*pHxSd=0,*pHySd=0, //diff hit position - digit sdigit position
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;
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();
480 Bool_t isClus=!GetLoader()->LoadRecPoints();
482 gBenchmark->Start("ControlPlots");
484 TFile *pFile = new TFile("$(HOME)/RCP.root","RECREATE");
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.);
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);
502 AliInfo("Digits available");
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);
508 AliInfo("Clusters available");
509 pNumClusH1=new TH1F("NumClusPerEvent","Number of clusters per event;number",50,0,49);
511 pQdcH1 =new TH1F("ClusQdc", "Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
512 pSizeH1 =new TH1F("ClusSize", "Cluster size all chambers;size [number of pads in cluster]",100,0,100);
513 pMapH2 =new TH2F("ClusMap", "Cluster map;x [cm];y [cm]",1000,0,P()->PcSizeX(),1000,0,P()->PcSizeY());
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());
518 pPureMipQdcH1 =new TH1F("QdcPureMip" ,"MIP only Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
519 pPureMipSizeH1=new TH1F("SizePureMip" ,"MIP only Cluster size all chambers;size [number of pads in cluster]",100,0,100);
520 pPureMipMapH2 =new TH2F("MapPureMip" ,"MIP only Cluster map;x [cm];y [cm]",1000,0,P()->PcSizeX(),1000,0,P()->PcSizeY());
522 pPureCerQdcH1 =new TH1F("QdcPureCer" ,"Cerenkov only Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
523 pPureCerSizeH1=new TH1F("SizePureCer" ,"Cernekov only Cluster size all chambers;size [number of pads in cluster]",100,0,100);
524 pPureCerMapH2 =new TH2F("MapPureCer" ,"Cerenkov only Cluster map;x [cm];y [cm]",1000,0,P()->PcSizeX(),1000,0,P()->PcSizeY());
526 pPureFeeQdcH1 =new TH1F("QdcPureFee" ,"Feedback only Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
527 pPureFeeSizeH1=new TH1F("SizePureFee" ,"Feedback only Cluster size all chambers;size [number of pads in cluster]",100,0,100);
528 pPureFeeMapH2 =new TH2F("MapPureFee" ,"Feedback only Cluster map;x [cm];y [cm]",1000,0,P()->PcSizeX(),1000,0,P()->PcSizeY());
531 //end of hists booking
532 for(Int_t iEvtN=0;iEvtN < GetLoader()->GetRunLoader()->GetAliRun()->GetEventsPerRun();iEvtN++){//events loop
533 GetLoader()->GetRunLoader()->GetEvent(iEvtN); //get current event
535 for(Int_t iPrimN=0;iPrimN < GetLoader()->TreeH()->GetEntries();iPrimN++){//hit tree loop
536 GetLoader()->TreeH()->GetEntry(iPrimN);
537 for(Int_t j=0;j<Hits()->GetEntries();j++){//hits loop
538 AliRICHHit *pHit = (AliRICHHit*)Hits()->At(j);
539 TParticle *pParticle = GetLoader()->GetRunLoader()->Stack()->Particle(pHit->GetTrack());//get particle produced this hit
540 Double_t dRadius = TMath::Sqrt(pParticle->Vx()*pParticle->Vx()+pParticle->Vy()*pParticle->Vy()+pParticle->Vz()*pParticle->Vz());
541 switch(pParticle->GetPdgCode()){
542 case kPositron : pElecP->Fill( pParticle->P());pelecRadius->Fill(dRadius); break;
543 case kElectron : pElecP->Fill(-pParticle->P());pelecRadius->Fill(dRadius); break;
545 case kMuonPlus : pMuonP->Fill( pParticle->P()); break;
546 case kMuonMinus: pMuonP->Fill(-pParticle->P()); break;
548 case kPiPlus : pPionP->Fill( pParticle->P()); break;
549 case kPiMinus : pPionP->Fill(-pParticle->P()); break;
551 case kKPlus : pKaonP->Fill( pParticle->P()); break;
552 case kKMinus : pKaonP->Fill(-pParticle->P()); break;
554 case kProton : pProtP->Fill( pParticle->P()); pprotRadius->Fill(dRadius); break;
555 case kProtonBar: pProtP->Fill(-pParticle->P()); pprotbarRadius->Fill(dRadius); break;
563 GetLoader()->TreeS()->GetEntry(0);
564 for(Int_t iSdigN=0;iSdigN<SDigits()->GetEntries();iSdigN++){//sdigits loop
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)
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());
574 if(isDig) GetLoader()->TreeD()->GetEntry(0);
575 if(isClus) GetLoader()->TreeR()->GetEntry(0);
577 for(Int_t iChamN=1;iChamN<=7;iChamN++){//chambers loop
579 for(Int_t iDigN=0;iDigN<Digits(iChamN)->GetEntries();iDigN++){//digits loop
580 AliRICHDigit *pDig=(AliRICHDigit*)Digits(iChamN)->At(iDigN);
581 AliRICHHit *pHit=Hit(pDig->GetTrack(0)); //get first hit of this digit
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());
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
590 AliRICHCluster *pClus=(AliRICHCluster*)Clusters(iChamN)->At(iClusN);
591 pQdcH1 ->Fill(pClus->Q());
592 pSizeH1 ->Fill(pClus->Size());
593 pMapH2 ->Fill(pClus->X(),pClus->Y()); //common
595 if(pClus->IsSingleMip()) {pPureMipQdcH1 ->Fill(pClus->Q());
596 pPureMipSizeH1->Fill(pClus->Size());
597 pPureMipMapH2 ->Fill(pClus->X(),pClus->Y());}//Pure Mips
599 if(pClus->IsSingleCerenkov()){pPureCerQdcH1 ->Fill(pClus->Q());
600 pPureCerSizeH1->Fill(pClus->Size());
601 pPureCerMapH2 ->Fill(pClus->X(),pClus->Y());}//Pure Cerenkovs
603 if(pClus->IsSingleFeedback()){pPureFeeQdcH1 ->Fill(pClus->Q());
604 pPureFeeSizeH1->Fill(pClus->Size());
605 pPureFeeMapH2 ->Fill(pClus->X(),pClus->Y());}//Pure Feedbacks
607 if(pClus->IsMip()) {pMipQdcH1 ->Fill(pClus->Q());} //MIP+ other contributions
608 if(!pClus->IsPureMip()) pPhotQdcH1->Fill(pClus->Q()); //not MIP
612 Info("ControlPlots","Event %i processed.",iEvtN);
614 GetLoader()->UnloadHits();
615 if(isSdig) GetLoader()->UnloadSDigits();
616 if(isDig) GetLoader()->UnloadDigits();
617 if(isClus) GetLoader()->UnloadRecPoints();
619 GetLoader()->GetRunLoader()->UnloadHeader();
620 GetLoader()->GetRunLoader()->UnloadKinematics();
622 pFile->Write(); delete pFile;
624 gBenchmark->Show("ControlPlots");
626 //__________________________________________________________________________________________________
627 AliRICHHit* AliRICH::Hit(Int_t tid)const
629 //defines which hit provided by given tid for the currently loaded event
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++){
634 AliRICHHit *pHit=(AliRICHHit*)Hits()->At(iHitN);
635 if(tid==pHit->Track()) {GetLoader()->UnloadHits();return pHit;}
638 GetLoader()->UnloadHits();
641 //__________________________________________________________________________________________________
642 void AliRICH::HitsPrint(Int_t iEvtN)const
644 //Prints a list of RICH hits for a given event. Default is event number 0.
645 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
646 AliInfo(Form("List of RICH hits for event %i",iEvtN));
647 if(GetLoader()->LoadHits()) return;
650 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
651 GetLoader()->TreeH()->GetEntry(iPrimN);
653 iTotalHits+=Hits()->GetEntries();
655 GetLoader()->UnloadHits();
656 AliInfo(Form("totally %i hits",iTotalHits));
658 //__________________________________________________________________________________________________
659 void AliRICH::SDigitsPrint(Int_t iEvtN)const
661 //prints a list of RICH sdigits for a given event
662 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
663 Info("PrintSDigits","List of RICH sdigits for event %i",iEvtN);
664 if(GetLoader()->LoadSDigits()) return;
666 GetLoader()->TreeS()->GetEntry(0);
668 GetLoader()->UnloadSDigits();
669 Info("PrintSDigits","totally %i sdigits",SDigits()->GetEntries());
671 //__________________________________________________________________________________________________
672 void AliRICH::DigitsPrint(Int_t iEvtN)const
674 //prints a list of RICH digits for a given event
675 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
676 Info("PrintDigits","List of RICH digits for event %i",iEvtN);
677 if(GetLoader()->LoadDigits()) return;
679 Int_t iTotalDigits=0;
680 GetLoader()->TreeD()->GetEntry(0);
681 for(Int_t iChamber=1;iChamber<=kNchambers;iChamber++){
682 Digits(iChamber)->Print();
683 iTotalDigits+=Digits(iChamber)->GetEntries();
685 GetLoader()->UnloadDigits();
686 Info("PrintDigits","totally %i Digits",iTotalDigits);
688 //__________________________________________________________________________________________________
689 void AliRICH::ClustersPrint(Int_t iEvtN)const
691 //prints a list of RICH clusters for a given event
692 AliInfo(Form("List of RICH clusters for event %i",iEvtN));
693 GetLoader()->GetRunLoader()->GetEvent(iEvtN);
694 if(GetLoader()->LoadRecPoints()) return;
696 Int_t iTotalClusters=0;
697 GetLoader()->TreeR()->GetEntry(0);
698 for(Int_t iChamber=1;iChamber<=kNchambers;iChamber++){
699 Clusters(iChamber)->Print();
700 iTotalClusters+=Clusters(iChamber)->GetEntries();
702 GetLoader()->UnloadRecPoints();
703 AliInfo(Form("totally %i clusters for event %i",iTotalClusters,iEvtN));
705 //__________________________________________________________________________________________________
706 void AliRICH::PrintTracks(Int_t iEvtN)
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();
715 for(Int_t i=0;i<pStack->GetNtrack();i++) pStack->Particle(i)->Print();
717 AliInfo(Form("totally %i tracks including %i primaries for event %i",pStack->GetNtrack(),pStack->GetNprimary(),iEvtN));
718 GetLoader()->GetRunLoader()->UnloadHeader();
719 GetLoader()->GetRunLoader()->UnloadKinematics();
721 //__________________________________________________________________________________________________
722 void AliRICH::GeomPadPanelFrame()const
724 //Pad Panel frame 6 sectors
725 Double_t cm=1,mm=0.1*cm;//default is cm
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)
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 //__________________________________________________________________________________________________
758 void AliRICH::GeomAmpGap()const
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
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
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
778 //__________________________________________________________________________________________________
779 void AliRICH::GeomRadiators()const
781 //Defines radiators geometry
782 Double_t mm=0.1;//default is cm
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
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
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
804 //__________________________________________________________________________________________________
805 void AliRICH::GeomSandBox()const
807 //Defines SandBox geometry
808 Double_t mm=0.1;//default is cm
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
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
819 //__________________________________________________________________________________________________
820 void AliRICH::GeomRadioSrc()const
822 // Defines geometry for radioactive source
823 Double_t cm=1,mm=0.1*cm,mkm=0.001*cm;
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
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
846 //__________________________________________________________________________________________________
847 void AliRICH::GeomAerogel()const
849 //Creates detailed geometry for aerogel study.
850 AliDebug(1,"Start.");
852 Float_t par[3]; //tmp array for volume dimentions
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
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
863 //__________________________________________________________________________________________________
864 void AliRICH::CreateGeometry()
866 //Creates detailed geometry simulation (currently GEANT volumes tree)
867 AliDebug(1,"Start main.");
868 Double_t mm=0.1;//default is cm
870 Int_t matrixIdReturn=0; //matrix id returned by AliMatrix
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(),
882 C(i)->Center().Z(),matrixIdReturn, "ONLY");
890 if(P()->IsRadioSrc()) GeomRadioSrc(); else GeomRadiators();
893 AliDebug(1,"Stop main.");
895 //__________________________________________________________________________________________________
896 void AliRICH::CheckPR()const
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");
902 // printf("Pattern Recognition done for event %5i",0);
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);
909 Info("CheckPR","Pattern Recognition done for event %i \b",iEvtN);
910 // printf("\b\b\b\b\b%5i",iEvtN+1);
913 pFile->Write();pFile->Close();
915 //__________________________________________________________________________________________________
916 void AliRICH::DisplayEvent(Int_t iEvtNmin,Int_t iEvtNmax)const
920 Bool_t isDigits =!GetLoader()->LoadDigits();
921 if(!isDigits){Error("ShoEvent","No digits. Nothing to display.");return;}
923 TCanvas *canvas = new TCanvas("RICHDisplay","RICH Display",0,0,1226,900);
924 gStyle->SetPalette(1);
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);
933 pDigitsH2[iChamber]->SetMaximum(300);
936 if(iEvtNmax>gAlice->GetEventsPerRun()||iEvtNmax==0) iEvtNmax=gAlice->GetEventsPerRun()-1;
938 TLatex t; t.SetTextSize(0.1);
939 for(Int_t iEventN=iEvtNmin;iEventN<=iEvtNmax;iEventN++) {//events loop
942 t.DrawText(0.2,0.4,Form("Event Number %i",iEventN));
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());
951 pDigitsH2[iChamber]->Fill(x2.X(),x2.Y(),pDig->Q());
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);
960 pDigitsH2[iChamber]->Draw("col");
961 ReadESD(iEventN,iChamber);
962 AliRICHParam::DrawSectors();
967 if(iEventN<iEvtNmax) {gPad->WaitPrimitive();canvas->Clear();}
970 //__________________________________________________________________________________________________
971 void AliRICH::Display()const
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();
979 if(!isHits && !isDigits && !isClusters){Error("Exec","No hits digits and clusters. Nothing to display.");return;}
981 TCanvas *pCanvas = new TCanvas("Display","RICH Display",0,0,600,600);
983 TH2F *pHitsH2=0,*pDigitsH2=0,*pClustersH2=0;
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);
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());
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();
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);
1013 pHitsH2->SetTitle(Form("event %i chamber %2i",iEventN,iChamber));
1014 pHitsH2->SetMarkerColor(kRed); pHitsH2->SetMarkerStyle(29); pHitsH2->SetMarkerSize(0.4);
1015 ReadESD(iEventN,iChamber);
1017 ReadESD(iEventN,iChamber);
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();
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);
1032 pDigitsH2->SetMarkerColor(kGreen); pDigitsH2->SetMarkerStyle(29); pDigitsH2->SetMarkerSize(0.4);
1033 pDigitsH2->Draw("same");
1034 pCanvas->Update(); pCanvas->Modified(); gPad->WaitPrimitive();
1036 //deals with clusters
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);
1043 pClustersH2->SetMarkerColor(kBlue); pClustersH2->SetMarkerStyle(29); pClustersH2->SetMarkerSize(0.4);
1044 pClustersH2->Draw("same");
1045 pCanvas->Update(); pCanvas->Modified(); gPad->WaitPrimitive();
1051 GetLoader()->UnloadHits();
1052 if(isDigits) GetLoader()->UnloadDigits();
1053 if(isClusters) GetLoader()->UnloadRecPoints();
1055 //__________________________________________________________________________________________________
1056 Int_t AliRICH::Nparticles(Int_t iPartID,Int_t iEvtN,AliRunLoader *pRL)
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();
1065 for(Int_t i=0;i<pStack->GetNtrack();i++){
1066 if(pStack->Particle(i)->GetPdgCode()==iPartID) iCounter++;
1069 pRL->UnloadHeader();
1070 pRL->UnloadKinematics();
1073 //__________________________________________________________________________________________________
1074 void AliRICH::ReadESD(Int_t iEventN, Int_t iChamber)const
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
1083 AliInfo("ESD found. Try to draw ring");
1085 AliESD *pESD=new AliESD; pTree->SetBranchAddress("ESD", &pESD);
1087 pTree->GetEvent(iEventN);
1089 Double_t b = pESD->GetMagneticField()/10.;
1091 Int_t iNtracks=pESD->GetNumberOfTracks();
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 charge = (Int_t)(-TMath::Sign(1.,pTrack->GetSign()*b));
1096 AliRICHHelix helix(pTrack->X3(),pTrack->P3(),charge,b);
1097 Int_t iChamberOnRICH=helix.RichIntersect(P());
1098 if(iChamberOnRICH==iChamber) {
1100 TMarker *trackImpact = new TMarker(helix.PosPc().X(),helix.PosPc().Y(),kStar);
1101 trackImpact->SetMarkerColor(kRed);
1102 trackImpact->Draw();
1104 Int_t iChamberRecon = pTrack->GetRICHcluster()/100000;
1105 if(iChamberRecon==iChamber) {
1106 Double_t thetaCer = pTrack->GetRICHsignal();
1107 if(thetaCer<0) continue;
1108 TVector3 entrance(helix.PosRad().X(),helix.PosRad().Y(),0);
1109 Double_t thetaTrack,phiTrack;
1110 pTrack->GetRICHthetaPhi(thetaTrack,phiTrack);
1111 TVector3 vectorTrack;
1112 vectorTrack.SetMagThetaPhi(pTrack->GetP(),thetaTrack,phiTrack);
1113 AliInfo(Form("Draw ring started for track %i on chamber %i",iTrackN,iChamber));
1114 AliInfo(Form("ThetaCer %f TrackTheta %f TrackPhi %f Momentum %f",thetaCer,thetaTrack,phiTrack,pTrack->GetP()));
1116 pTrack->GetRICHdxdy(dx,dy);
1117 AliInfo(Form("dx %f dy %f ",dx,dy));
1118 DrawRing(entrance,vectorTrack,thetaCer);
1122 delete pESD; pFile->Close();//close AliESDs.root
1125 //__________________________________________________________________________________________________
1126 void AliRICH::DrawRing(TVector3 entrance,TVector3 vectorTrack,Double_t thetaCer)const
1128 Double_t xGraph[100],yGraph[100];
1129 Int_t nPointsToDraw = 0;
1130 for(Int_t i=0;i<100;i++) {
1131 Double_t phiCer = 2*TMath::Pi()*i/100;
1132 TVector3 pos = AliRICHParam::ForwardTracing(entrance,vectorTrack,thetaCer,phiCer);
1133 if(pos.X()==-999) continue;
1134 xGraph[nPointsToDraw] = pos.X();yGraph[nPointsToDraw] = pos.Y();nPointsToDraw++;
1136 // AliInfo(Form("Npoints per ring %i",nPointsToDraw));
1137 TGraph *gra = new TGraph(nPointsToDraw,xGraph,yGraph);