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()
48 //__________________________________________________________________________________________________
52 <img src="gif/alirich.gif">
55 //__________________________________________________________________________________________________
56 AliRICH::AliRICH():AliDetector(),fParam(0), fSdigits(0),fNsdigits(0),fDigs(0),fClus(0)
58 //Default ctor should not contain any new operators
59 //AliDetector ctor deals with Hits and Digits
60 for(int i=0;i<kNchambers;i++) fNdigs[i] =0;
61 for(int i=0;i<kNchambers;i++) fNclus[i]=0;
62 // fCounters.ResizeTo(20); fCounters.Zero();
64 //__________________________________________________________________________________________________
65 AliRICH::AliRICH(const char *name, const char *title)
66 :AliDetector(name,title),fParam(new AliRICHParam),fSdigits(0),fNsdigits(0),fDigs(0),fClus(0)
70 //AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
71 HitsCreate(); gAlice->GetMCApp()->AddHitList(fHits);
72 fCounters.ResizeTo(20); fCounters.Zero();
74 }//AliRICH::AliRICH(const char *name, const char *title)
75 //__________________________________________________________________________________________________
81 if(fParam) delete fParam;
83 if(fHits) delete fHits;
84 if(fSdigits) delete fSdigits;
85 if(fDigits) delete fDigits;
86 if(fDigs) {fDigs->Delete(); delete fDigs;}
87 if(fClus) {fClus->Delete(); delete fClus;}
89 }//AliRICH::~AliRICH()
90 //__________________________________________________________________________________________________
91 void AliRICH::Hits2SDigits()
93 // Create a list of sdigits corresponding to list of hits. Every hit generates one or more sdigits.
95 for(Int_t iEventN=0;iEventN<GetLoader()->GetRunLoader()->GetAliRun()->GetEventsPerRun();iEventN++){//events loop
96 GetLoader()->GetRunLoader()->GetEvent(iEventN);//get next event
98 if(!GetLoader()->TreeH()) GetLoader()->LoadHits(); GetLoader()->GetRunLoader()->LoadHeader();
99 if(!GetLoader()->GetRunLoader()->TreeK()) GetLoader()->GetRunLoader()->LoadKinematics();//from
100 if(!GetLoader()->TreeS()) GetLoader()->MakeTree("S"); MakeBranch("S");//to
102 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
103 GetLoader()->TreeH()->GetEntry(iPrimN);
104 for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){//hits loop
105 AliRICHHit *pHit=(AliRICHHit*)Hits()->At(iHitN);//get current hit
106 TVector2 x2 = C(pHit->C())->Mrs2Anod(0.5*(pHit->InX3()+pHit->OutX3()));//hit position in the anod plane
107 Int_t iTotQdc=P()->TotQdc(x2,pHit->Eloss());//total charge produced by hit, 0 if hit in dead zone
108 if(iTotQdc==0) continue;
110 //need to quantize the anod....
111 TVector padHit=AliRICHParam::Loc2Pad(x2);
112 TVector2 padHitXY=AliRICHParam::Pad2Loc(padHit);
114 if((x2.Y()-padHitXY.Y())>0) anod.Set(x2.X(),padHitXY.Y()+AliRICHParam::PitchAnod()/2);
115 else anod.Set(x2.X(),padHitXY.Y()-AliRICHParam::PitchAnod()/2);
116 //end to quantize anod
118 TVector area=P()->Loc2Area(anod);//determine affected pads, dead zones analysed inside
119 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));
121 for(pad[1]=area[1];pad[1]<=area[3];pad[1]++)//affected pads loop
122 for(pad[0]=area[0];pad[0]<=area[2];pad[0]++){
123 Double_t padQdc=iTotQdc*P()->FracQdc(anod,pad);
124 AliDebug(1,Form("current pad(%3.0f,%3.0f) with QDC =%6.2f",pad[0],pad[1],padQdc));
125 if(padQdc>0.1) SDigitAdd(pHit->C(),pad,padQdc,GetLoader()->GetRunLoader()->Stack()->Particle(pHit->GetTrack())->GetPdgCode(),pHit->GetTrack());
126 }//affected pads loop
129 GetLoader()->TreeS()->Fill();
130 GetLoader()->WriteSDigits("OVERWRITE");
133 GetLoader()->UnloadHits(); GetLoader()->GetRunLoader()->UnloadHeader(); GetLoader()->GetRunLoader()->UnloadKinematics();
134 GetLoader()->UnloadSDigits();
137 //__________________________________________________________________________________________________
138 void AliRICH::Digits2Raw()
140 //Loops over all digits and creates raw data files in DDL format. GetEvent() is done outside (AliSimulation)
141 //RICH has 2 DDL per chamber, even number for right part(2-4-6) odd number for left part(1-3-5)
142 //RICH has no any propriate header just uses the common one
143 //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)
144 //Each raw is composed from 10 DILOGIC chips counted from left to right from 1 to 10 (denoted dddd 4 bits 16 values)
145 //Each DILOGIC chip serves 48 channels counted from 0 to 47 (denoted aaaaaa 6 bits 64 values)
146 //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)
147 AliDebug(1,"Start.");
148 GetLoader()->LoadDigits();
149 GetLoader()->TreeD()->GetEntry(0);
151 Int_t kRichOffset=0x700; //currently one DDL per 3 sectors
153 ofstream file135,file246;//output streams 2 DDL per chamber
154 AliRawDataHeader header;//empty DDL miniheader
155 UInt_t word32=1; //32 bits data word
157 for(Int_t iChN=1;iChN<=kNchambers;iChN++){ //2 DDL per chamber open both in parallel
158 file135.open(Form("RICH_%4i.ddl",kRichOffset+2*iChN-1)); //left part of chamber; sectors 1-3-5 odd DDL number
159 file246.open(Form("RICH_%4i.ddl",kRichOffset+2*iChN)); //right part of chamber; sectors 2-4-6 even DDL number
160 //common DDL header defined by standart, now dummy as the total number of bytes is not yet known
161 file135.write((char*)&header,sizeof(header)); //dummy header just place holder
162 file246.write((char*)&header,sizeof(header)); //actual will be written later
164 Int_t counter135=0,counter246=0;//counts total number of records per DDL
166 for(Int_t iDigN=0;iDigN<Digits(iChN)->GetEntriesFast();iDigN++){//digits loop for a given chamber
167 AliRICHDigit *pDig=(AliRICHDigit*)Digits(iChN)->At(iDigN);
168 word32=UInt_t (pDig->Q()+0x400*pDig->X()+0x4000*pDig->Y()); //arbitrary structure
169 switch(pDig->S()){//readout by vertical sectors: 1,3,5-left DDL 2,4,6-right DDL
170 case 1: case 3: case 5: file135.write((char*)&word32,sizeof(word32)); counter135++; break;
171 case 2: case 4: case 6: file246.write((char*)&word32,sizeof(word32)); counter246++; break;
173 }//digits loop for a given chamber
174 //now count total byte number for each DDL file and rewrite actual header
175 header.fSize=sizeof(header)+counter135*sizeof(word32); header.SetAttribute(0); file135.seekp(0); file135.write((char*)&header,sizeof(header));
176 header.fSize=sizeof(header)+counter246*sizeof(word32); header.SetAttribute(0); file246.seekp(0); file246.write((char*)&header,sizeof(header));
177 file135.close(); file246.close();
179 GetLoader()->UnloadDigits();
182 //__________________________________________________________________________________________________
183 void AliRICH::BuildGeometry()
185 //Builds a TNode geometry for event display
188 TNode *node, *subnode, *top;
189 top=gAlice->GetGeometry()->GetNode("alice");
191 Float_t widx =P()->SectorSizeX();
192 Float_t leny =P()->SectorSizeY();
193 Float_t dz =P()->Zfreon()+P()->Zwin()+P()->Pc2Win();
194 Float_t dead =P()->DeadZone();
196 new TBRIK("RICH","RICH","void",widx+dead/2,leny+leny/2+dead,dz+0.1); //RICH chamber
197 new TBRIK("RPC" ,"RPC" ,"void",widx/2,leny/2,0.01); //RICH sector
199 for(int i=1;i<=P()->Nchambers();i++){
201 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());
202 node->SetLineColor(kRed);
204 subnode = new TNode("PHOTO1","PHOTO1","RPC",-widx/2-dead/2,-leny-dead/2,dz,"");
205 subnode->SetLineColor(kGreen);
206 fNodes->Add(subnode);
207 subnode = new TNode("PHOTO1","PHOTO1","RPC", widx/2+dead/2,-leny-dead/2,dz,"");
208 subnode->SetLineColor(kGreen);
209 fNodes->Add(subnode);
210 subnode = new TNode("PHOTO1","PHOTO1","RPC",-widx/2-dead/2, 0,dz,"");
211 subnode->SetLineColor(kGreen);
212 fNodes->Add(subnode);
213 subnode = new TNode("PHOTO1","PHOTO1","RPC", widx/2+dead/2, 0,dz,"");
214 subnode->SetLineColor(kGreen);
215 fNodes->Add(subnode);
216 subnode = new TNode("PHOTO1","PHOTO1","RPC",-widx/2-dead/2, leny+dead/2,dz,"");
217 subnode->SetLineColor(kGreen);
218 fNodes->Add(subnode);
219 subnode = new TNode("PHOTO1","PHOTO1","RPC", widx/2+dead/2, leny+dead/2,dz,"");
220 subnode->SetLineColor(kGreen);
221 fNodes->Add(subnode);
226 }//void AliRICH::BuildGeometry()
227 //__________________________________________________________________________________________________
228 void AliRICH::CreateMaterials()
230 // Definition of available RICH materials
232 Int_t material=0; //tmp material id number
233 Float_t a=0,z=0,den=0,radl=0,absl=0; //tmp material parameters
235 Float_t tmaxfd=-10.0, deemax=-0.2, stemax=-0.1,epsil=0.001, stmin=-0.001;
236 Int_t isxfld = gAlice->Field()->Integ();
237 Float_t sxmgmx = gAlice->Field()->Max();
239 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
240 AliMixture(++material, "RichAir",aAir,zAir,den=0.00120479,4,wAir); //1 (Air) 0.01% C 75% N 23% O 1% Ar
241 AliMedium(kAir, "RichAir",material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
243 AliMixture(++material, "RichAerogel",aAir,zAir,den=P()->DenGel(),4,wAir); //Aerogel represented by Air
244 AliMedium(kGel, "RichAerogel",material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
246 AliMixture(++material, "RichAerogelReflector",aAir,zAir,den=P()->DenGel(),4,wAir); //Aerogel reflector represented by Air
247 AliMedium(kReflector, "RichAerogelReflector",material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
249 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
250 AliMedium(kRoha, "RichRohacell", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
252 Float_t aQuartz[2]={28.09,16.0}; Float_t zQuartz[2]={14.00, 8.0}; Float_t wQuartz[2]={1,2};
253 AliMixture(++material, "RichSiO2",aQuartz,zQuartz,den=2.64,-2, wQuartz); //3 Quarz (SiO2) -trasparent rad window
254 AliMedium(kSiO2, "RichSiO2",material, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
256 Float_t aFreon[2]={12,19}; Float_t zFreon[2]={6,9}; Float_t wmatFreon[2]={6,14}; // C12-6 F19-9
257 AliMixture(++material, "RichC6F14",aFreon,zFreon,den=1.68,-2,wmatFreon); //4 Freon (C6F14)
258 AliMedium(kC6F14, "RichC6F14",material, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
260 Float_t aMethane[2]={12.01,1}; Float_t zMethane[2]={6,1}; Float_t wMethane[2]={1,4};
261 AliMixture (++material, "RichCH4", aMethane, zMethane, den=7.17e-4,-2, wMethane); //5,9 methane (CH4) normal and for Gap
262 AliMedium(kCH4, "RichCH4" , material, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
263 AliMixture (++material, "RichCH4gap", aMethane, zMethane, den=7.17e-4,-2, wMethane); //5,9 methane (CH4) normal and for Gap
264 AliMedium(kGap, "RichCH4gap", material, 1, isxfld, sxmgmx, tmaxfd, 0.1 , -deemax, epsil, -stmin);
266 AliMaterial(++material, "RichCsI", a=12.01,z=6.0, den=0.1, radl=18.8, absl=0); //6 CsI-radl equivalent
267 AliMedium(kCsI, "RichCsI", material, 1, isxfld, sxmgmx,tmaxfd, stemax, deemax, epsil, stmin);
269 AliMaterial(++material, "RichGridCu", a=63.54,z=29.0,den=8.96, radl=1.43, absl=0); //7 anode grid (Cu)
270 AliMedium(kGridCu, "RichGridCu", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
272 AliMaterial(++material, "RichPcbCu", a=63.54,z=29.0,den=8.96, radl=1.4, absl=0); //12 Cu
273 AliMedium(kCu, "RichPcbCu", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
275 AliMixture (++material, "RichOpSiO2",aQuartz, zQuartz, den=2.64, -2, wQuartz); //8 Quarz (SiO2) - opaque
276 AliMedium(kOpSiO2, "RichOpSiO2",material, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
278 AliMaterial(++material, "RichAl", a=26.98,z=13.0,den=2.699, radl=8.9, absl=0); //10 aluminium sheet (Al)
279 AliMedium(kAl, "RichAl", material, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
281 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};
282 AliMixture(++material,"RichGlass",aGlass, zGlass, den=1.74, 5, wGlass); //11 Glass 50%-C 10.5%-Si 35.5%-O 3%-B 1%-Na
283 AliMedium(kGlass, "RichGlass", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
285 AliMaterial(++material, "RichW", a=183.84,z=74.0,den=19.3, radl=0.35, absl=185.0/den); //13 W - anod wires
286 AliMedium(kW, "RichW", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
289 if(P()->IsRadioSrc()){
290 AliInfo("Special radioactive source materials");
291 AliMaterial(++material, "RichSteel", a=55.845,z=26.0,den=7.87, radl=1.76, absl=131.9/den); //14 Steel (Fe)
292 AliMedium(kSteel, "RichSteel", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
294 AliMaterial(++material, "RichPerpex", a=63.54,z=29.0,den=8.96, radl=1.4, absl=0); //15 Perpex
295 AliMedium(kPerpex, "RichPerpex", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
297 AliMaterial(++material, "RichSr90", a=87.62,z=38.0,den=2.54, radl=4.24, absl=0); //16 Sr90
298 AliMedium(kSr90, "RichSr90", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
300 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
301 AliMixture(++material,"RichMylar",aMylar, zMylar, den=1.39, -3, wMylar);
302 AliMedium(kMylar, "RichMylar", material, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
305 //Optical properties:
306 #include "Opticals.h"
307 gMC->SetCerenkov((*fIdtmed)[kAir] , kNbins, aPckov, aAbsCH4 , aQeAll, aIdxCH4); //1 Air
308 gMC->SetCerenkov((*fIdtmed)[kRoha] , kNbins, aPckov, aAbsCH4 , aQeAll, aIdxCH4); //2 Honeycomb
309 gMC->SetCerenkov((*fIdtmed)[kSiO2] , kNbins, aPckov, aAbsSiO2 , aQeAll, aIdxSiO2); //3 Quartz SiO2
310 gMC->SetCerenkov((*fIdtmed)[kC6F14] , kNbins, aPckov, aAbsC6F14 , aQeAll, aIdxC6F14); //4 Freon C6F14
311 gMC->SetCerenkov((*fIdtmed)[kCH4] , kNbins, aPckov, aAbsCH4 , aQeAll, aIdxCH4); //5 Methane CH4
312 gMC->SetCerenkov((*fIdtmed)[kCsI] , kNbins, aPckov, aAbsCsI , aQeCsI, aIdxCH4); //6 CsI
313 gMC->SetCerenkov((*fIdtmed)[kGridCu] , kNbins, aPckov, aAbsGrid , aQeAll, aIdxMetal); //7 grid Cu
314 gMC->SetCerenkov((*fIdtmed)[kOpSiO2] , kNbins, aPckov, aAbsOpSiO2 , aQeAll, aIdxMetal); //8 Opaque quartz SiO2
315 gMC->SetCerenkov((*fIdtmed)[kGap] , kNbins, aPckov, aAbsCH4 , aQeAll, aIdxCH4); //9 Special methane gap
316 gMC->SetCerenkov((*fIdtmed)[kAl] , kNbins, aPckov, aAbsGrid , aQeAll, aIdxMetal); //10 Aluminium
317 gMC->SetCerenkov((*fIdtmed)[kGlass] , kNbins, aPckov, aAbsOpSiO2 , aQeAll, aIdxMetal); //11 Glass
318 gMC->SetCerenkov((*fIdtmed)[kGel] , kNbins, aPckov, aAbsGel , aQeAll, aIdxGel); //12 Aerogel
319 gMC->SetCerenkov((*fIdtmed)[kReflector], kNbins, aPckov, aAbsRef , aQeAll, aIdxMetal); //13 Aerogel reflector
320 }//void AliRICH::CreateMaterials()
321 //__________________________________________________________________________________________________
322 Float_t AliRICH::Fresnel(Float_t ene,Float_t pdoti, Bool_t pola)
325 //ENE(EV), PDOTI=COS(INC.ANG.), PDOTR=COS(POL.PLANE ROT.ANG.)
327 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,
328 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,
329 7.8,7.9,8.0,8.1,8.2,8.3,8.4,8.5};
330 Float_t csin[36] = {2.14,2.21,2.33,2.48,2.76,2.97,2.99,2.59,2.81,3.05,
331 2.86,2.53,2.55,2.66,2.79,2.96,3.18,3.05,2.84,2.81,2.38,2.11,
332 2.01,2.13,2.39,2.73,3.08,3.15,2.95,2.73,2.56,2.41,2.12,1.95,
334 Float_t csik[36] = {0.,0.,0.,0.,0.,0.196,0.408,0.208,0.118,0.49,0.784,0.543,
335 0.424,0.404,0.371,0.514,0.922,1.102,1.139,1.376,1.461,1.253,0.878,
336 0.69,0.612,0.649,0.824,1.347,1.571,1.678,1.763,1.857,1.824,1.824,
339 Int_t j=Int_t(xe*10)-49;
340 Float_t cn=csin[j]+((csin[j+1]-csin[j])/0.1)*(xe-en[j]);
341 Float_t ck=csik[j]+((csik[j+1]-csik[j])/0.1)*(xe-en[j]);
343 //FORMULAE FROM HANDBOOK OF OPTICS, 33.23 OR
344 //W.R. HUNTER, J.O.S.A. 54 (1964),15 , J.O.S.A. 55(1965),1197
346 Float_t sinin=TMath::Sqrt(1-pdoti*pdoti);
347 Float_t tanin=sinin/pdoti;
349 Float_t c1=cn*cn-ck*ck-sinin*sinin;
350 Float_t c2=4*cn*cn*ck*ck;
351 Float_t aO=TMath::Sqrt(0.5*(TMath::Sqrt(c1*c1+c2)+c1));
352 Float_t b2=0.5*(TMath::Sqrt(c1*c1+c2)-c1);
354 Float_t rs=((aO-pdoti)*(aO-pdoti)+b2)/((aO+pdoti)*(aO+pdoti)+b2);
355 Float_t rp=rs*((aO-sinin*tanin)*(aO-sinin*tanin)+b2)/((aO+sinin*tanin)*(aO+sinin*tanin)+b2);
358 //CORRECTION FACTOR FOR SURFACE ROUGHNESS
359 //B.J. STAGG APPLIED OPTICS, 30(1991),4113
362 Float_t lamb=1240/ene;
365 Float_t rO=TMath::Exp(-(4*TMath::Pi()*pdoti*sigraf/lamb)*(4*TMath::Pi()*pdoti*sigraf/lamb));
369 Float_t pdotr=0.8; //DEGREE OF POLARIZATION : 1->P , -1->S
370 fresn=0.5*(rp*(1+pdotr)+rs*(1-pdotr));
378 //__________________________________________________________________________________________________
379 void AliRICH::MakeBranch(Option_t* option)
381 //Create Tree branches for the RICH.
382 AliDebug(1,Form("Start with option= %s.",option));
384 const Int_t kBufferSize = 4000;
386 const char *cH = strstr(option,"H");
387 const char *cD = strstr(option,"D");
388 const char *cR = strstr(option,"R");
389 const char *cS = strstr(option,"S");
392 HitsCreate(); //branch will be created in AliDetector::MakeBranch
394 AliDetector::MakeBranch(option);//this is after cH because we need to guarantee that fHits array is created
396 if(cS&&fLoader->TreeS()){//S
397 SDigitsCreate(); MakeBranchInTree(fLoader->TreeS(),"RICH",&fSdigits,kBufferSize,0) ;
400 if(cD&&fLoader->TreeD()){//D
402 for(Int_t i=0;i<kNchambers;i++){
403 MakeBranchInTree(fLoader->TreeD(),Form("%s%d",GetName(),i+1),&((*fDigs)[i]),kBufferSize,0);
407 if(cR&&fLoader->TreeR()){//R
409 for(Int_t i=0;i<kNchambers;i++)
410 MakeBranchInTree(fLoader->TreeR(),Form("%sClusters%d",GetName(),i+1), &((*fClus)[i]), kBufferSize, 0);
413 }//void AliRICH::MakeBranch(Option_t* option)
414 //__________________________________________________________________________________________________
415 void AliRICH::SetTreeAddress()
417 //Set branch address for the Hits and Digits Tree.
418 AliDebug(1,"Start.");
422 if(fLoader->TreeH()){//H
423 AliDebug(1,"tree H is requested.");
424 HitsCreate();//branch map will be in AliDetector::SetTreeAddress
426 AliDetector::SetTreeAddress();//this is after TreeH because we need to guarantee that fHits array is created
428 if(fLoader->TreeS()){//S
429 AliDebug(1,"tree S is requested.");
430 branch=fLoader->TreeS()->GetBranch(GetName()); if(branch){SDigitsCreate(); branch->SetAddress(&fSdigits);}
433 if(fLoader->TreeD()){//D
434 AliDebug(1,"tree D is requested.");
435 for(int i=0;i<kNchambers;i++){
436 branch=fLoader->TreeD()->GetBranch(Form("%s%d",GetName(),i+1));
437 if(branch){DigitsCreate(); branch->SetAddress(&((*fDigs)[i]));}
441 if(fLoader->TreeR()){//R
442 AliDebug(1,"tree R is requested.");
443 for(int i=0;i<kNchambers;i++){
444 branch=fLoader->TreeR()->GetBranch(Form("%sClusters%d" ,GetName(),i+1));
445 if(branch){ClustersCreate(); branch->SetAddress(&((*fClus)[i]));}
449 }//void AliRICH::SetTreeAddress()
450 //__________________________________________________________________________________________________
451 void AliRICH::Print(Option_t *option)const
454 TObject::Print(option);
457 }//void AliRICH::Print(Option_t *option)const
458 //__________________________________________________________________________________________________
459 void AliRICH::ControlPlots()
461 //Creates a set of QA hists to control the results of simulation. Hists are in file $HOME/RCP.root
462 TH1F *pElecP=0 ,*pMuonP=0 ,*pPionP=0 ,*pKaonP=0 ,*pProtP=0, //stack particles
463 *pHxD=0,*pHyD=0,*pHxSd=0,*pHySd=0, //diff hit position - digit sdigit position
465 *pQdcH1=0, *pSizeH1=0,
466 *pPureMipQdcH1=0,*pPureMipSizeH1=0,
467 *pPureCerQdcH1=0,*pPureCerSizeH1=0,
468 *pPureFeeQdcH1=0,*pPureFeeSizeH1=0,
469 *pMipQdcH1=0, *pPhotQdcH1=0;
470 TH2F *pMapH2=0,*pPureMipMapH2=0,*pPureCerMapH2=0,*pPureFeeMapH2=0;
471 TH1F *pelecRadius=0,*pprotRadius=0,*pprotbarRadius=0;
472 //load all information
473 GetLoader()->GetRunLoader()->LoadHeader();
474 GetLoader()->GetRunLoader()->LoadKinematics();
475 GetLoader()->LoadHits();
476 Bool_t isSdig=0;//!GetLoader()->LoadSDigits();
477 Bool_t isDig =0;//!GetLoader()->LoadDigits();
478 Bool_t isClus=!GetLoader()->LoadRecPoints();
480 gBenchmark->Start("ControlPlots");
482 TFile *pFile = new TFile("$(HOME)/RCP.root","RECREATE");
484 pElecP=new TH1F("Pelec","Electrons made hit in RICH;p [GeV]",1000,-30,30);
485 pMuonP=new TH1F("Pmuon","Muons made hit in RICH;p [GeV]",1000,-30,30);
486 pPionP=new TH1F("Ppion","Pions made hit in RICH;p [GeV]",1000,-30,30);
487 pKaonP=new TH1F("Pkaon","Kaon made hit in RICH;p [GeV]",1000,-30,30);
488 pProtP=new TH1F("Pprot","Protons made hit in RICH;p [GeV]",1000,-30,30);
489 pelecRadius=new TH1F("elecRadius","elec",600,0.,600.);
490 pprotRadius=new TH1F("protRadius","elec",600,0.,600.);
491 pprotbarRadius=new TH1F("protbarRadius","elec",600,0.,600.);
494 AliInfo("SDigits available");
495 pHxSd=new TH1F("DiffHitSDigitX","Hit-SDigit diff X all chambers;diff [cm]",300,-10,10);
496 pHySd=new TH1F("DiffHitSDigitY","Hit-SDigit diff Y all chambers;diff [cm]",300,-10,10);
500 AliInfo("Digits available");
501 pHxD=new TH1F("DiffHitDigitX","Hit-Digit diff X all chambers;diff [cm]",300,-10,10);
502 pHyD=new TH1F("DiffHitDigitY","Hit-Digit diff Y all chambers;diff [cm]",300,-10,10);
506 AliInfo("Clusters available");
507 pNumClusH1=new TH1F("NumClusPerEvent","Number of clusters per event;number",50,0,49);
509 pQdcH1 =new TH1F("ClusQdc", "Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
510 pSizeH1 =new TH1F("ClusSize", "Cluster size all chambers;size [number of pads in cluster]",100,0,100);
511 pMapH2 =new TH2F("ClusMap", "Cluster map;x [cm];y [cm]",1000,0,P()->PcSizeX(),1000,0,P()->PcSizeY());
513 pMipQdcH1 =new TH1F("QdcMip" ,"MIP Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
514 pPhotQdcH1 =new TH1F("QdcPhot" ,"Cer+Fee Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
516 pPureMipQdcH1 =new TH1F("QdcPureMip" ,"MIP only Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
517 pPureMipSizeH1=new TH1F("SizePureMip" ,"MIP only Cluster size all chambers;size [number of pads in cluster]",100,0,100);
518 pPureMipMapH2 =new TH2F("MapPureMip" ,"MIP only Cluster map;x [cm];y [cm]",1000,0,P()->PcSizeX(),1000,0,P()->PcSizeY());
520 pPureCerQdcH1 =new TH1F("QdcPureCer" ,"Cerenkov only Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
521 pPureCerSizeH1=new TH1F("SizePureCer" ,"Cernekov only Cluster size all chambers;size [number of pads in cluster]",100,0,100);
522 pPureCerMapH2 =new TH2F("MapPureCer" ,"Cerenkov only Cluster map;x [cm];y [cm]",1000,0,P()->PcSizeX(),1000,0,P()->PcSizeY());
524 pPureFeeQdcH1 =new TH1F("QdcPureFee" ,"Feedback only Cluster Charge all chambers;q [QDC]",P()->MaxQdc(),0,P()->MaxQdc());
525 pPureFeeSizeH1=new TH1F("SizePureFee" ,"Feedback only Cluster size all chambers;size [number of pads in cluster]",100,0,100);
526 pPureFeeMapH2 =new TH2F("MapPureFee" ,"Feedback only Cluster map;x [cm];y [cm]",1000,0,P()->PcSizeX(),1000,0,P()->PcSizeY());
529 //end of hists booking
530 for(Int_t iEvtN=0;iEvtN < GetLoader()->GetRunLoader()->GetAliRun()->GetEventsPerRun();iEvtN++){//events loop
531 GetLoader()->GetRunLoader()->GetEvent(iEvtN); //get current event
533 for(Int_t iPrimN=0;iPrimN < GetLoader()->TreeH()->GetEntries();iPrimN++){//hit tree loop
534 GetLoader()->TreeH()->GetEntry(iPrimN);
535 for(Int_t j=0;j<Hits()->GetEntries();j++){//hits loop
536 AliRICHHit *pHit = (AliRICHHit*)Hits()->At(j);
537 TParticle *pParticle = GetLoader()->GetRunLoader()->Stack()->Particle(pHit->GetTrack());//get particle produced this hit
538 Double_t dRadius = TMath::Sqrt(pParticle->Vx()*pParticle->Vx()+pParticle->Vy()*pParticle->Vy()+pParticle->Vz()*pParticle->Vz());
539 switch(pParticle->GetPdgCode()){
540 case kPositron : pElecP->Fill( pParticle->P());pelecRadius->Fill(dRadius); break;
541 case kElectron : pElecP->Fill(-pParticle->P());pelecRadius->Fill(dRadius); break;
543 case kMuonPlus : pMuonP->Fill( pParticle->P()); break;
544 case kMuonMinus: pMuonP->Fill(-pParticle->P()); break;
546 case kPiPlus : pPionP->Fill( pParticle->P()); break;
547 case kPiMinus : pPionP->Fill(-pParticle->P()); break;
549 case kKPlus : pKaonP->Fill( pParticle->P()); break;
550 case kKMinus : pKaonP->Fill(-pParticle->P()); break;
552 case kProton : pProtP->Fill( pParticle->P()); pprotRadius->Fill(dRadius); break;
553 case kProtonBar: pProtP->Fill(-pParticle->P()); pprotbarRadius->Fill(dRadius); break;
561 GetLoader()->TreeS()->GetEntry(0);
562 for(Int_t iSdigN=0;iSdigN<SDigits()->GetEntries();iSdigN++){//sdigits loop
563 AliRICHDigit *pSdig=(AliRICHDigit*)SDigits()->At(iSdigN); //get current sdigit pointer
564 AliRICHHit *pHit=Hit(pSdig->GetTrack(0)); //get hit of this sdigit (always one)
565 TVector2 hit2 =C(pHit->C())->Mrs2Pc(pHit->OutX3()); //this hit position in local system
566 TVector2 sdig2=P()->Pad2Loc(pSdig->Pad()); //center of pad for this sdigit
567 pHxSd->Fill(hit2.X()-sdig2.X());
568 pHySd->Fill(hit2.Y()-sdig2.Y());
572 if(isDig) GetLoader()->TreeD()->GetEntry(0);
573 if(isClus) GetLoader()->TreeR()->GetEntry(0);
575 for(Int_t iChamN=1;iChamN<=7;iChamN++){//chambers loop
577 for(Int_t iDigN=0;iDigN<Digits(iChamN)->GetEntries();iDigN++){//digits loop
578 AliRICHDigit *pDig=(AliRICHDigit*)Digits(iChamN)->At(iDigN);
579 AliRICHHit *pHit=Hit(pDig->GetTrack(0)); //get first hit of this digit
580 TVector2 hitV2=C(iChamN)->Mrs2Pc(pHit->OutX3());
581 TVector2 digV2=P()->Pad2Loc(pDig->Pad()); //center of pad for this digit
582 pHxD->Fill(hitV2.X()-digV2.X()); pHyD->Fill(hitV2.Y()-digV2.Y());
586 Int_t iNclusCham=Clusters(iChamN)->GetEntries(); if(iNclusCham) pNumClusH1->Fill(iNclusCham);//number of clusters per event
587 for(Int_t iClusN=0;iClusN<iNclusCham;iClusN++){//clusters loop
588 AliRICHCluster *pClus=(AliRICHCluster*)Clusters(iChamN)->At(iClusN);
589 pQdcH1 ->Fill(pClus->Q());
590 pSizeH1 ->Fill(pClus->Size());
591 pMapH2 ->Fill(pClus->X(),pClus->Y()); //common
593 if(pClus->IsSingleMip()) {pPureMipQdcH1 ->Fill(pClus->Q());
594 pPureMipSizeH1->Fill(pClus->Size());
595 pPureMipMapH2 ->Fill(pClus->X(),pClus->Y());}//Pure Mips
597 if(pClus->IsSingleCerenkov()){pPureCerQdcH1 ->Fill(pClus->Q());
598 pPureCerSizeH1->Fill(pClus->Size());
599 pPureCerMapH2 ->Fill(pClus->X(),pClus->Y());}//Pure Cerenkovs
601 if(pClus->IsSingleFeedback()){pPureFeeQdcH1 ->Fill(pClus->Q());
602 pPureFeeSizeH1->Fill(pClus->Size());
603 pPureFeeMapH2 ->Fill(pClus->X(),pClus->Y());}//Pure Feedbacks
605 if(pClus->IsMip()) {pMipQdcH1 ->Fill(pClus->Q());} //MIP+ other contributions
606 if(!pClus->IsPureMip()) pPhotQdcH1->Fill(pClus->Q()); //not MIP
610 Info("ControlPlots","Event %i processed.",iEvtN);
612 GetLoader()->UnloadHits();
613 if(isSdig) GetLoader()->UnloadSDigits();
614 if(isDig) GetLoader()->UnloadDigits();
615 if(isClus) GetLoader()->UnloadRecPoints();
617 GetLoader()->GetRunLoader()->UnloadHeader();
618 GetLoader()->GetRunLoader()->UnloadKinematics();
620 pFile->Write(); delete pFile;
622 gBenchmark->Show("ControlPlots");
624 //__________________________________________________________________________________________________
625 AliRICHHit* AliRICH::Hit(Int_t tid)const
627 //defines which hit provided by given tid for the currently loaded event
628 GetLoader()->LoadHits();
629 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
630 GetLoader()->TreeH()->GetEntry(iPrimN);
631 for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){
632 AliRICHHit *pHit=(AliRICHHit*)Hits()->At(iHitN);
633 if(tid==pHit->Track()) {GetLoader()->UnloadHits();return pHit;}
636 GetLoader()->UnloadHits();
639 //__________________________________________________________________________________________________
640 void AliRICH::HitsPrint(Int_t iEvtN)const
642 //Prints a list of RICH hits for a given event. Default is event number 0.
643 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
644 AliInfo(Form("List of RICH hits for event %i",iEvtN));
645 if(GetLoader()->LoadHits()) return;
648 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
649 GetLoader()->TreeH()->GetEntry(iPrimN);
651 iTotalHits+=Hits()->GetEntries();
653 GetLoader()->UnloadHits();
654 AliInfo(Form("totally %i hits",iTotalHits));
656 //__________________________________________________________________________________________________
657 void AliRICH::SDigitsPrint(Int_t iEvtN)const
659 //prints a list of RICH sdigits for a given event
660 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
661 Info("PrintSDigits","List of RICH sdigits for event %i",iEvtN);
662 if(GetLoader()->LoadSDigits()) return;
664 GetLoader()->TreeS()->GetEntry(0);
666 GetLoader()->UnloadSDigits();
667 Info("PrintSDigits","totally %i sdigits",SDigits()->GetEntries());
669 //__________________________________________________________________________________________________
670 void AliRICH::DigitsPrint(Int_t iEvtN)const
672 //prints a list of RICH digits for a given event
673 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
674 Info("PrintDigits","List of RICH digits for event %i",iEvtN);
675 if(GetLoader()->LoadDigits()) return;
677 Int_t iTotalDigits=0;
678 GetLoader()->TreeD()->GetEntry(0);
679 for(Int_t iChamber=1;iChamber<=kNchambers;iChamber++){
680 Digits(iChamber)->Print();
681 iTotalDigits+=Digits(iChamber)->GetEntries();
683 GetLoader()->UnloadDigits();
684 Info("PrintDigits","totally %i Digits",iTotalDigits);
686 //__________________________________________________________________________________________________
687 void AliRICH::ClustersPrint(Int_t iEvtN)const
689 //prints a list of RICH clusters for a given event
690 AliInfo(Form("List of RICH clusters for event %i",iEvtN));
691 GetLoader()->GetRunLoader()->GetEvent(iEvtN);
692 if(GetLoader()->LoadRecPoints()) return;
694 Int_t iTotalClusters=0;
695 GetLoader()->TreeR()->GetEntry(0);
696 for(Int_t iChamber=1;iChamber<=kNchambers;iChamber++){
697 Clusters(iChamber)->Print();
698 iTotalClusters+=Clusters(iChamber)->GetEntries();
700 GetLoader()->UnloadRecPoints();
701 AliInfo(Form("totally %i clusters for event %i",iTotalClusters,iEvtN));
703 //__________________________________________________________________________________________________
704 void AliRICH::PrintTracks(Int_t iEvtN)
706 //prints a list of tracks (including secondary) for a given event
707 AliInfo(Form("List of all tracks for event %i",iEvtN));
708 GetLoader()->GetRunLoader()->GetEvent(iEvtN);
709 if(GetLoader()->GetRunLoader()->LoadHeader()) return;
710 if(GetLoader()->GetRunLoader()->LoadKinematics()) return;
711 AliStack *pStack=GetLoader()->GetRunLoader()->Stack();
713 for(Int_t i=0;i<pStack->GetNtrack();i++) pStack->Particle(i)->Print();
715 AliInfo(Form("totally %i tracks including %i primaries for event %i",pStack->GetNtrack(),pStack->GetNprimary(),iEvtN));
716 GetLoader()->GetRunLoader()->UnloadHeader();
717 GetLoader()->GetRunLoader()->UnloadKinematics();
719 //__________________________________________________________________________________________________
720 void AliRICH::GeomPadPanelFrame()const
722 //Pad Panel frame 6 sectors
723 Double_t cm=1,mm=0.1*cm;//default is cm
726 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
727 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
728 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
729 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)
731 gMC->Gspos("RPPF",1,"RICH", -335*mm, -433*mm, 8*cm+20*mm, 0,"ONLY");//F1 2040P1 z p.84 TDR
732 gMC->Gspos("RPPF",2,"RICH", +335*mm, -433*mm, 8*cm+20*mm, 0,"ONLY");
733 gMC->Gspos("RPPF",3,"RICH", -335*mm, 0*mm, 8*cm+20*mm, 0,"ONLY");
734 gMC->Gspos("RPPF",4,"RICH", +335*mm, 0*mm, 8*cm+20*mm, 0,"ONLY");
735 gMC->Gspos("RPPF",5,"RICH", -335*mm, +433*mm, 8*cm+20*mm, 0,"ONLY");
736 gMC->Gspos("RPPF",6,"RICH", +335*mm, +433*mm, 8*cm+20*mm, 0,"ONLY");
737 gMC->Gspos("RPC ",1,"RPPF", 0*mm, 0*mm, -19.15*mm, 0,"ONLY");//PPF 2001P2
738 gMC->Gspos("PPFL",1,"RPPF", -224.5*mm, -151.875*mm, 0.85*mm, 0,"ONLY");
739 gMC->Gspos("PPFL",2,"RPPF", -224.5*mm, - 50.625*mm, 0.85*mm, 0,"ONLY");
740 gMC->Gspos("PPFL",3,"RPPF", -224.5*mm, + 50.625*mm, 0.85*mm, 0,"ONLY");
741 gMC->Gspos("PPFL",4,"RPPF", -224.5*mm, +151.875*mm, 0.85*mm, 0,"ONLY");
742 gMC->Gspos("PPFS",1,"RPPF", - 65.0*mm, -151.875*mm, 0.85*mm, 0,"ONLY");
743 gMC->Gspos("PPFS",2,"RPPF", - 65.0*mm, - 50.625*mm, 0.85*mm, 0,"ONLY");
744 gMC->Gspos("PPFS",3,"RPPF", - 65.0*mm, + 50.625*mm, 0.85*mm, 0,"ONLY");
745 gMC->Gspos("PPFS",4,"RPPF", - 65.0*mm, +151.875*mm, 0.85*mm, 0,"ONLY");
746 gMC->Gspos("PPFS",5,"RPPF", + 65.0*mm, -151.875*mm, 0.85*mm, 0,"ONLY");
747 gMC->Gspos("PPFS",6,"RPPF", + 65.0*mm, - 50.625*mm, 0.85*mm, 0,"ONLY");
748 gMC->Gspos("PPFS",7,"RPPF", + 65.0*mm, + 50.625*mm, 0.85*mm, 0,"ONLY");
749 gMC->Gspos("PPFS",8,"RPPF", + 65.0*mm, +151.875*mm, 0.85*mm, 0,"ONLY");
750 gMC->Gspos("PPFL",5,"RPPF", +224.5*mm, -151.875*mm, 0.85*mm, 0,"ONLY");
751 gMC->Gspos("PPFL",6,"RPPF", +224.5*mm, - 50.625*mm, 0.85*mm, 0,"ONLY");
752 gMC->Gspos("PPFL",7,"RPPF", +224.5*mm, + 50.625*mm, 0.85*mm, 0,"ONLY");
753 gMC->Gspos("PPFL",8,"RPPF", +224.5*mm, +151.875*mm, 0.85*mm, 0,"ONLY");
754 }//GeomPadPanelFrame()
755 //__________________________________________________________________________________________________
756 void AliRICH::GeomAmpGap()const
758 //Gap - anod wires 6 copies to RICH
759 Double_t cm=1,mm=0.1*cm,mkm=0.001*mm;//default is cm
760 Int_t matrixIdReturn=0; //matrix id returned by AliMatrix
763 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
764 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
765 AliMatrix(matrixIdReturn,180,0, 90,90, 90,0); //wires along x
767 gMC->Gspos("RGAP",1,"RICH", -335*mm, -433*mm,8*cm-2.225*mm, 0,"ONLY"); //F1 2040P1 z WP 2099P1
768 gMC->Gspos("RGAP",2,"RICH", +335*mm, -433*mm,8*cm-2.225*mm, 0,"ONLY");
769 gMC->Gspos("RGAP",3,"RICH", -335*mm, 0*mm,8*cm-2.225*mm, 0,"ONLY");
770 gMC->Gspos("RGAP",4,"RICH", +335*mm, 0*mm,8*cm-2.225*mm, 0,"ONLY");
771 gMC->Gspos("RGAP",5,"RICH", -335*mm, +433*mm,8*cm-2.225*mm, 0,"ONLY");
772 gMC->Gspos("RGAP",6,"RICH", +335*mm, +433*mm,8*cm-2.225*mm, 0,"ONLY");
773 for(int i=1;i<=96;i++)
774 gMC->Gspos("RANO",i,"RGAP", 0*mm, -411/2*mm+i*4*mm, 0.185*mm, matrixIdReturn,"ONLY"); //WP 2099P1
776 //__________________________________________________________________________________________________
777 void AliRICH::GeomRadiators()const
779 //Defines radiators geometry
780 Double_t mm=0.1;//default is cm
782 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
783 par[0]=1330*mm/2 ;par[1]= 413*mm/2 ;par[2]= 4*mm/2; gMC->Gsvolu("RRFR","BOX ",(*fIdtmed)[kRoha] ,par,3); //front
784 par[0]=1330*mm/2 ;par[1]= 413*mm/2 ;par[2]= 5*mm/2; gMC->Gsvolu("RRWI","BOX ",(*fIdtmed)[kSiO2] ,par,3); //window
785 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
786 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
787 par[0]= 0 ;par[1]= 10*mm/2 ;par[2]= 15*mm/2; gMC->Gsvolu("RRSP","TUBE",(*fIdtmed)[kSiO2] ,par,3); //spacer
789 gMC->Gspos("RRAD",1,"RICH", 0*mm,-434*mm, -12*mm, 0,"ONLY"); //3 radiators to RICH
790 gMC->Gspos("RRAD",2,"RICH", 0*mm, 0*mm, -12*mm, 0,"ONLY");
791 gMC->Gspos("RRAD",3,"RICH", 0*mm,+434*mm, -12*mm, 0,"ONLY");
792 gMC->Gspos("RRFR",1,"RRAD", 0*mm, 0*mm, -10.0*mm, 0,"ONLY"); //front cover
793 gMC->Gspos("RRWI",1,"RRAD", 0*mm, 0*mm, 9.5*mm, 0,"ONLY"); //quartz window (back cover)
794 gMC->Gspos("RRLO",1,"RRAD", 0*mm,-204*mm, -0.5*mm, 0,"ONLY"); //long side
795 gMC->Gspos("RRLO",2,"RRAD", 0*mm,+204*mm, -0.5*mm, 0,"ONLY"); //long side
796 gMC->Gspos("RRSH",1,"RRAD",-660*mm, 0*mm, -0.5*mm, 0,"ONLY"); //short side
797 gMC->Gspos("RRSH",2,"RRAD",+660*mm, 0*mm, -0.5*mm, 0,"ONLY"); //short side
799 for(int j=0;j<10;j++)
800 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
802 //__________________________________________________________________________________________________
803 void AliRICH::GeomSandBox()const
805 //Defines SandBox geometry
806 Double_t mm=0.1;//default is cm
808 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
809 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
810 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
812 gMC->Gspos("RSNB",1,"RICH", 0*mm, 0*mm, -73.75*mm, 0,"ONLY"); //p.84 TDR sandbox to rich
813 gMC->Gspos("RSHO",1,"RSNB", 0*mm, 0*mm, 0*mm, 0,"ONLY"); //2072P1 honeycomv to sandbox
814 gMC->Gspos("RSCO",1,"RSNB", 0*mm, 0*mm, +25*mm, 0,"ONLY"); //cover to sandbox
815 gMC->Gspos("RSCO",2,"RSNB", 0*mm, 0*mm, -25*mm, 0,"ONLY"); //cover to sandbox
817 //__________________________________________________________________________________________________
818 void AliRICH::GeomRadioSrc()const
820 // Defines geometry for radioactive source
821 Double_t cm=1,mm=0.1*cm,mkm=0.001*cm;
824 par[0]=0 ;par[1]= 70*mm/2 ;par[2]= 30*mm/2; gMC->Gsvolu("RSRC","TUBE",(*fIdtmed)[kCH4] ,par,3); //top src container
825 par[0]=0 ;par[1]= 38*mm/2 ;par[2]= 21.8*mm/2; gMC->Gsvolu("RSAG","TUBE",(*fIdtmed)[kAl] ,par,3); //Al glass
826 par[0]=0 ;par[1]= 34*mm/2 ;par[2]= 20*mm/2; gMC->Gsvolu("RSPP","TUBE",(*fIdtmed)[kPerpex] ,par,3); //perpex plug
827 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
828 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
829 par[0]=0 ;par[1]= 1*mm/2 ;par[2]= 1*mm/2; gMC->Gsvolu("RSSR","TUBE",(*fIdtmed)[kSr90] ,par,3); //Sr90 source
830 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
831 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
832 par[0]=0 ;par[1]= 30*mm/2 ;par[2]= 50*mkm/2; gMC->Gsvolu("RSMF","TUBE",(*fIdtmed)[kMylar] ,par,3); //Mylar foil
834 gMC->Gspos("RSRC",1,"RICH", 30*cm, 0, 1*cm, 0,"ONLY"); //source to RICH
835 gMC->Gspos("RSMF",1,"RSRC", 0, 0,21.8*mm/2+50*mkm/2, 0,"ONLY");//mylar foil to top src volume
836 gMC->Gspos("RSAG",1,"RSRC", 0, 0, 0, 0,"ONLY");//Al glass to fake Src volume
837 gMC->Gspos("RSWA",1,"RSAG", 6*mm, 0, -10*mm, 0,"ONLY");//air whole in al glass bottom
838 gMC->Gspos("RSPP",1,"RSAG", 0, 0, 0.9*mm, 0,"ONLY");//perpex plug to Al glass
839 gMC->Gspos("RSWP",1,"RSPP", 6*mm, 0, -5*mm, 0,"ONLY");//air whole in perpex plug
840 gMC->Gspos("RSSC",1,"RSPP", 0, 0, 2.5*mm, 0,"ONLY");//steel screw in center of perpex plug
841 gMC->Gspos("RSSS",1,"RSPP", 6*mm, 0, 5*mm, 0,"ONLY");//steel screw to support Sr90 in perpex plug
842 gMC->Gspos("RSSR",1,"RSSS", 0, 0, -4.5*mm, 0,"ONLY");//Sr90 in support steel screw
844 //__________________________________________________________________________________________________
845 void AliRICH::GeomAerogel()const
847 //Creates detailed geometry for aerogel study.
848 AliDebug(1,"Start.");
850 Float_t par[3]; //tmp array for volume dimentions
852 par[0]=10.1*cm/2;par[1]=10.1*cm/2;par[2]=10.1*cm/2;
853 gMC->Gsvolu("RREF","BOX ",(*fIdtmed)[kReflector],par,3);//reflector box
854 gMC->Gspos("RREF",1,"RICH",0,0,0,0, "ONLY"); //put it to RICH volume
856 par[0]=10*cm/2;par[1]=10*cm/2;par[2]=10*cm/2;
857 gMC->Gsvolu("RGEL","BOX ",(*fIdtmed)[kGel],par,3);//10x10x10 cm^3 cubic of aerogel
858 gMC->Gspos("RGEL",1,"RREF",0,0,0,0,"ONLY");//put gel cell to reflector
861 //__________________________________________________________________________________________________
862 void AliRICH::CreateGeometry()
864 //Creates detailed geometry simulation (currently GEANT volumes tree)
865 AliDebug(1,"Start main.");
866 Double_t mm=0.1;//default is cm
868 Int_t matrixIdReturn=0; //matrix id returned by AliMatrix
870 //place chambers into mother volume ALIC
871 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;
872 gMC->Gsvolu("RICH","BOX ",(*fIdtmed)[kCH4],par,3);//2033P1 z p84 TDR
873 for(int i=1;i<=P()->Nchambers();i++){ //test configuration with single chamber is taken into account automaticaly in AliRICHParam
874 AliMatrix(matrixIdReturn,
875 C(i)->ThetaXd(),C(i)->PhiXd(),
876 C(i)->ThetaYd(),C(i)->PhiYd(),
877 C(i)->ThetaZd(),C(i)->PhiZd());
878 gMC->Gspos("RICH",i,"ALIC",C(i)->Center().X(),
880 C(i)->Center().Z(),matrixIdReturn, "ONLY");
888 if(P()->IsRadioSrc()) GeomRadioSrc(); else GeomRadiators();
891 AliDebug(1,"Stop main.");
893 //__________________________________________________________________________________________________
894 void AliRICH::CheckPR()const
896 //Pattern recognition with stack particles
897 TFile *pFile = new TFile("$(HOME)/RPR.root","RECREATE","RICH Pattern Recognition");
898 TNtupleD *hn = new TNtupleD("hn","ntuple","Pmod:Charge:TrackTheta:TrackPhi:TrackX:TrackY:MinX:MinY:ChargeMIP:ThetaCerenkov:NPhotons:MipIndex:Chamber:Particle");
900 // printf("Pattern Recognition done for event %5i",0);
901 AliMagF * magf = gAlice->Field();
902 AliTracker::SetFieldMap(magf);
903 for(Int_t iEvtN=0;iEvtN<GetLoader()->GetRunLoader()->GetNumberOfEvents();iEvtN++) {
904 GetLoader()->GetRunLoader()->GetEvent(iEvtN);
905 AliRICHTracker *tr = new AliRICHTracker();
906 tr->RecWithStack(hn);
907 Info("CheckPR","Pattern Recognition done for event %i \b",iEvtN);
908 // printf("\b\b\b\b\b%5i",iEvtN+1);
911 pFile->Write();pFile->Close();
913 //__________________________________________________________________________________________________
914 void AliRICH::DisplayEvent(Int_t iEvtNmin,Int_t iEvtNmax)const
918 Bool_t isDigits =!GetLoader()->LoadDigits();
919 if(!isDigits){Error("ShoEvent","No digits. Nothing to display.");return;}
921 TCanvas *canvas = new TCanvas("RICHDisplay","RICH Display",0,0,1226,900); canvas->Divide(3,3);
922 // gStyle->SetPalette(1);
925 for(Int_t iChamber=1;iChamber<=7;iChamber++) {
926 pDigitsH2[iChamber] = new TH2F(Form("pDigitsH2_%i",iChamber),Form("Chamber %i",iChamber),165,0,P()->PcSizeX(),144,0,P()->PcSizeY());
927 pDigitsH2[iChamber]->SetMarkerColor(kGreen);
928 pDigitsH2[iChamber]->SetMarkerStyle(29);
929 pDigitsH2[iChamber]->SetMarkerSize(0.4);
930 pDigitsH2[iChamber]->SetStats(kFALSE);
933 if(iEvtNmax>gAlice->GetEventsPerRun()) iEvtNmax=gAlice->GetEventsPerRun();
935 TLatex t; t.SetTextSize(0.1);
936 for(Int_t iEventN=iEvtNmin;iEventN<=iEvtNmax;iEventN++) {//events loop
938 t.DrawText(0.2,0.4,Form("Event Number %i",iEventN));
940 GetLoader()->GetRunLoader()->GetEvent(iEventN); //get event
941 GetLoader()->TreeD()->GetEntry(0); //get list of digits
942 for(Int_t iChamber=1;iChamber<=7;iChamber++) {//chambers loop
943 pDigitsH2[iChamber]->Reset();
944 for(Int_t j=0;j<Digits(iChamber)->GetEntries();j++) {//digits loop
945 AliRICHDigit *pDig = (AliRICHDigit*)Digits(iChamber)->At(j);
946 TVector2 x2=AliRICHParam::Pad2Loc(pDig->Pad());
947 pDigitsH2[iChamber]->Fill(x2.X(),x2.Y());
949 if(iChamber==1) canvas->cd(7);
950 if(iChamber==2) canvas->cd(8);
951 if(iChamber==3) canvas->cd(4);
952 if(iChamber==4) canvas->cd(5);
953 if(iChamber==5) canvas->cd(6);
954 if(iChamber==6) canvas->cd(2);
955 if(iChamber==7) canvas->cd(3);
956 pDigitsH2[iChamber]->Draw();
961 if(iEvtNmin<iEvtNmax) gPad->WaitPrimitive();
964 //__________________________________________________________________________________________________
965 void AliRICH::Display()const
967 //Provides fast event display
968 //For RICH only, full display is .x Display.C
969 Bool_t isHits =!GetLoader()->LoadHits();
970 Bool_t isDigits =!GetLoader()->LoadDigits();
971 Bool_t isClusters=!GetLoader()->LoadRecPoints();
973 if(!isHits && !isDigits && !isClusters){Error("Exec","No hits digits and clusters. Nothing to display.");return;}
975 TCanvas *pCanvas = new TCanvas("Display","RICH Display",0,0,600,600);
977 TH2F *pHitsH2=0,*pDigitsH2=0,*pClustersH2=0;
979 if(isHits) pHitsH2 = new TH2F("pHitsH2" , "Event Display;x,cm;y,cm",165,0,AliRICHParam::PcSizeX(),
980 144,0,AliRICHParam::PcSizeY());
981 if(pHitsH2) pHitsH2->SetStats(kFALSE);
983 if(isDigits) pDigitsH2 = new TH2F("pDigitsH2" ,"Event Display",165,0,AliRICHParam::PcSizeX(),
984 144,0,AliRICHParam::PcSizeY());
985 if(isClusters) pClustersH2 = new TH2F("pClustersH2","Event Display",165,0,AliRICHParam::PcSizeX(),
986 144,0,AliRICHParam::PcSizeY());
988 for(Int_t iEventN=0;iEventN<gAlice->GetEventsPerRun();iEventN++){//events Loop
989 GetLoader()->GetRunLoader()->GetEvent(iEventN);
990 //display all the staff on chamber by chamber basis
991 for(Int_t iChamber=1;iChamber<=7;iChamber++){//chambers loop
992 if(isHits) pHitsH2 ->Reset();
993 if(isDigits) pDigitsH2 ->Reset();
994 if(isClusters) pClustersH2->Reset();
996 for(Int_t i=0;i<GetLoader()->TreeH()->GetEntries();i++){//TreeH loop
997 GetLoader()->TreeH()->GetEntry(i);
998 for(Int_t j=0;j<Hits()->GetEntries();j++){//hits loop
999 AliRICHHit *pHit = (AliRICHHit*)Hits()->At(j);
1000 if(pHit->C()==iChamber){
1001 TVector3 hitGlobX3= pHit->OutX3();
1002 TVector2 hitLocX2 = C(iChamber)->Mrs2Pc(hitGlobX3);
1003 pHitsH2->Fill(hitLocX2.X(),hitLocX2.Y(),200);
1007 pHitsH2->SetTitle(Form("event %i chamber %2i",iEventN,iChamber));
1008 pHitsH2->SetMarkerColor(kRed); pHitsH2->SetMarkerStyle(29); pHitsH2->SetMarkerSize(0.4);
1011 ReadESD(iEventN,iChamber);
1013 AliRICHParam::DrawSectors();
1014 TLatex l; l.SetNDC(); l.SetTextSize(0.02);
1015 if(!isHits) {l.SetTextColor(kRed) ;l.DrawLatex(0.1,0.01,"No Hits" );}
1016 if(!isDigits) {l.SetTextColor(kGreen);l.DrawLatex(0.4,0.01,"No DIGITS" );}
1017 if(!isClusters) {l.SetTextColor(kBlue) ;l.DrawLatex(0.8,0.01,"No CLUSTERS");}
1018 pCanvas->Update(); pCanvas->Modified(); gPad->WaitPrimitive();
1021 GetLoader()->TreeD()->GetEntry(0);
1022 for(Int_t j=0;j<Digits(iChamber)->GetEntries();j++){//digits loop
1023 AliRICHDigit *pDig = (AliRICHDigit*)Digits(iChamber)->At(j);
1024 TVector2 x2=AliRICHParam::Pad2Loc(pDig->Pad());
1025 pDigitsH2->Fill(x2.X(),x2.Y(),100);
1027 pDigitsH2->SetMarkerColor(kGreen); pDigitsH2->SetMarkerStyle(29); pDigitsH2->SetMarkerSize(0.4);
1028 pDigitsH2->Draw("same");
1029 pCanvas->Update(); pCanvas->Modified(); gPad->WaitPrimitive();
1031 //deals with clusters
1033 GetLoader()->TreeR()->GetEntry(0);
1034 for(Int_t j=0;j<Clusters(iChamber)->GetEntries();j++){//clusters loop
1035 AliRICHCluster *pClus = (AliRICHCluster*)Clusters(iChamber)->At(j);
1036 pClustersH2->Fill(pClus->X(),pClus->Y(),50);
1038 pClustersH2->SetMarkerColor(kBlue); pClustersH2->SetMarkerStyle(29); pClustersH2->SetMarkerSize(0.4);
1039 pClustersH2->Draw("same");
1040 pCanvas->Update(); pCanvas->Modified(); gPad->WaitPrimitive();
1046 GetLoader()->UnloadHits();
1047 if(isDigits) GetLoader()->UnloadDigits();
1048 if(isClusters) GetLoader()->UnloadRecPoints();
1050 //__________________________________________________________________________________________________
1051 Int_t AliRICH::Nparticles(Int_t iPartID,Int_t iEvtN,AliRunLoader *pRL)
1053 //counts total number of particles of given type (including secondary) for a given event
1054 pRL->GetEvent(iEvtN);
1055 if(pRL->LoadHeader()) return 0;
1056 if(pRL->LoadKinematics()) return 0;
1057 AliStack *pStack=pRL->Stack();
1060 for(Int_t i=0;i<pStack->GetNtrack();i++){
1061 if(pStack->Particle(i)->GetPdgCode()==iPartID) iCounter++;
1064 pRL->UnloadHeader();
1065 pRL->UnloadKinematics();
1068 //__________________________________________________________________________________________________
1069 void AliRICH::ReadESD(Int_t iEventN, Int_t iChamber)const
1072 // AliInfo("Start.");
1073 TFile *pFile=TFile::Open("AliESDs.root","read");
1074 if(!pFile || !pFile->IsOpen()) {AliInfo("ESD file not open.");return;} //open AliESDs.root
1075 TTree *pTree = (TTree*) pFile->Get("esdTree");
1076 if(!pTree){AliInfo("ESD not found.");return;} //get ESD tree
1078 // AliInfo("ESD found. Try to draw ring");
1080 AliESD *pESD=new AliESD; pTree->SetBranchAddress("ESD", &pESD);
1082 pTree->GetEvent(iEventN);
1084 Double_t b = pESD->GetMagneticField()/10.;
1086 Int_t iNtracks=pESD->GetNumberOfTracks();
1088 for(Int_t iTrackN=0;iTrackN<iNtracks;iTrackN++){//ESD tracks loop
1089 AliESDtrack *pTrack = pESD->GetTrack(iTrackN);// get next reconstructed track
1090 Int_t iChTrack = pTrack->GetRICHcluster()/100000;
1091 if(iChTrack==iChamber) {
1092 if(pTrack->GetRICHsignal()<0) continue;
1093 Int_t charge = (Int_t)(-TMath::Sign(1.,pTrack->GetSign()*b));
1094 AliRICHHelix helix(pTrack->X3(),pTrack->P3(),charge,b);
1095 helix.RichIntersect(P());
1096 TVector3 entrance(helix.PosRad().X(),helix.PosRad().Y(),0);
1097 Double_t thetaTrack,phiTrack;
1098 pTrack->GetRICHthetaPhi(thetaTrack,phiTrack);
1099 TVector3 vectorTrack;
1100 vectorTrack.SetMagThetaPhi(pTrack->GetP(),thetaTrack,phiTrack);
1101 // vectorTrack.SetMagThetaPhi(pTrack->GetP(),thetaTrack,1.5*TMath::Pi());
1102 // AliInfo("Draw ring started");
1103 DrawRing(entrance,vectorTrack,pTrack->GetRICHsignal());
1106 delete pESD; pFile->Close();//close AliESDs.root
1108 //__________________________________________________________________________________________________
1109 void AliRICH::DrawRing(TVector3 entrance,TVector3 vectorTrack,Double_t thetaCer)const
1111 Double_t xGraph[100],yGraph[100];
1112 Int_t nPointsToDraw = 0;
1113 for(Int_t i=0;i<100;i++) {
1114 Double_t phiCer = 2*TMath::Pi()*i/100;
1115 TVector3 pos = AliRICHParam::ForwardTracing(entrance,vectorTrack,thetaCer,phiCer);
1116 if(pos.X()==-999.) continue;
1117 xGraph[nPointsToDraw] = pos.X();yGraph[nPointsToDraw] = pos.Y();nPointsToDraw++;
1119 // AliInfo(Form("Npoints per ring %i",nPointsToDraw));
1120 TGraph *gra = new TGraph(nPointsToDraw,xGraph,yGraph);