Fix for coverity (AdC)
[u/mrichter/AliRoot.git] / FIT / AliFITv1.cxx
CommitLineData
c1c44db3 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17/////////////////////////////////////////////////////////////////////
18// //
19// FIT detector full geometry version 1 //
20//
21//Begin Html
22/*
23<img src="gif/AliFITv1Class.gif">
24*/
25//End Html
26// //
27// //
28//////////////////////////////////////////////////////////////////////
29
30#include <Riostream.h>
31#include <stdlib.h>
32
33#include "TGeoCompositeShape.h"
34#include "TGeoManager.h"
35#include "TGeoMatrix.h"
36#include "TGeoVolume.h"
37#include "TGeoTube.h"
38#include "TGeoBBox.h"
39#include "TGeoNode.h"
40
41
42#include <TGeoGlobalMagField.h>
43#include <TGraph.h>
44#include <TLorentzVector.h>
45#include <TMath.h>
46#include <TVirtualMC.h>
47#include <TString.h>
48
49#include "AliLog.h"
50#include "AliMagF.h"
51#include "AliRun.h"
52
53#include "AliFITHits.h"
54#include "AliFITv1.h"
55
56#include "AliMC.h"
57#include "AliCDBLocal.h"
58#include "AliCDBStorage.h"
59#include "AliCDBManager.h"
60#include "AliCDBEntry.h"
61#include "AliTrackReference.h"
62
63ClassImp(AliFITv1)
64
65
66//--------------------------------------------------------------------
67AliFITv1::AliFITv1(): AliFIT(),
68 fIdSens1(0),
69 fPMTeff(0x0)
70
71{
72 //
73 // Standart constructor for T0 Detector version 0
74}
75//--------------------------------------------------------------------
76AliFITv1::AliFITv1(const char *name, const char *title):
77 AliFIT(name,title),
78 fIdSens1(0),
79 fPMTeff(0x0)
80
81{
82 //
83 // Standart constructor for T0 Detector version 0
84 //
85 fIshunt = 2;
86 SetPMTeff();
87}
88//_____________________________________________________________________________
89
90AliFITv1::~AliFITv1()
91{
92 // desctructor
93}
94
95//-------------------------------------------------------------------------
96void AliFITv1::CreateGeometry()
97{
98 //
99 // Create the geometry of FIT Detector version 1 full geometry
100 //
101 // begin Html
102 //
103
104 Int_t *idtmed = fIdtmed->GetArray();
105 Float_t zdetC = 83;
106 Float_t zdetA = 375.;
107
108 Int_t idrotm[999];
109 Double_t x,y,z;
110 Float_t pstart[3] = {6, 20 ,3};
111 Float_t pinstart[3] = {3,3,2.55};
112 Float_t pmcp[3] = {2.95, 2.95, 1.5}; //MCP
113 Float_t ptop[3] = {1.324, 1.324, 1.};//cherenkov radiator
114 Float_t preg[3] = {1.324, 1.324, 0.05};//photcathode
115
116 AliMatrix(idrotm[901], 90., 0., 90., 90., 180., 0.);
117
118 //-------------------------------------------------------------------
119 // T0 volume
120 //-------------------------------------------------------------------
121
122 Float_t x1[20] = {9, 9, 15 ,15 , 9,
123 3, -3, 3, -3, -9,
124 -9, -9, -15, -15, -9,
125 -3, 3, -3, 3, 9};
126
127 Float_t y1[20] = {3.2, -3.2, 3.2, -3.2, -9.2,
128 -9, -9, -15, -15, -9.2,
129 -3.2, 3.2, -3.2, 3.2, 9.2,
130 9, 9, 15, 15, 9.2};
131
132
133
134 TGeoVolumeAssembly * stlin = new TGeoVolumeAssembly("0STL");//empty segment
135 //T0 interior
2942f542 136 TVirtualMC::GetMC()->Gsvolu("0INS","BOX",idtmed[kAir],pinstart,3);
c1c44db3 137 TGeoVolume *ins = gGeoManager->GetVolume("0INS");
138 //
139 TGeoTranslation *tr [20];
140 TString nameTr;
141 for (Int_t itr=0; itr<20; itr++) {
142 nameTr = Form("0TR%i",itr+1);
143 z=-pstart[2]+pinstart[2];
144 tr[itr] = new TGeoTranslation(nameTr.Data(),x1[itr],y1[itr], z );
145 tr[itr]->RegisterYourself();
146 stlin->AddNode(ins,itr,tr[itr]);
147 }
148 TGeoVolume *alice = gGeoManager->GetVolume("ALIC");
149 alice->AddNode(stlin,1,new TGeoTranslation(0,0, zdetA ) );
150 TGeoRotation * rotC = new TGeoRotation( "rotC",90., 0., 90., 90., 180., 0.);
151 alice->AddNode(stlin,2, new TGeoCombiTrans(0., 0., -zdetC , rotC) );
152
153 x=0;
154 y=0;
155
156 // Entry window (glass)
2942f542 157 TVirtualMC::GetMC()->Gsvolu("0TOP","BOX",idtmed[kOpGlass],ptop,3); //glass
c1c44db3 158 TGeoVolume *top = gGeoManager->GetVolume("0TOP");
2942f542 159 TVirtualMC::GetMC()->Gsvolu ("0REG", "BOX", idtmed[kOpGlassCathode], preg, 3);
c1c44db3 160 TGeoVolume *cat = gGeoManager->GetVolume("0REG");
2942f542 161 TVirtualMC::GetMC()->Gsvolu("0MCP","BOX",idtmed[kGlass],pmcp,3); //glass
c1c44db3 162 TGeoVolume *mcp = gGeoManager->GetVolume("0MCP");
163
164 Int_t ntops=0;
165 Float_t xin=0, yin=0;
166 for (Int_t ix=0; ix<2; ix++) {
167 xin = - pinstart[0] + 0.35 + (ix+0.5)*2*ptop[0] ;
168 for (Int_t iy=0; iy<2; iy++) {
169 z = - pinstart[2]+ptop[2];
170 yin = - pinstart[1] + 0.35 + (iy+0.5)*2*ptop[1];
171 ntops++;
172 ins->AddNode(top, ntops, new TGeoTranslation(xin,yin,z) );
173 // printf(" 0TOP full x %f y %f z %f \n", xin, yin, z);
174 z = -pinstart[2] + 2 * ptop[2] + preg[2];
175 ins->AddNode(cat, ntops, new TGeoTranslation(xin,yin,z) );
176
177 // printf(" GEOGEO %i %i %i %f %f %f %f %f %f \n", ntops, ix, iy,
178 // xin,yin,x1[ntops],y1[ntops],x1[ntops]+xin,y1[ntops]+yin);
179 }
180 }
181// MCP
182 z=-pinstart[2] + 2*ptop[2] + 2*preg[2] + pmcp[2];
183 ins->AddNode(mcp, 1 , new TGeoTranslation(0,0,z) );
184
185
186
187
188}
189//------------------------------------------------------------------------
190void AliFITv1::AddAlignableVolumes() const
191{
192 //
193 // Create entries for alignable volumes associating the symbolic volume
194 // name with the corresponding volume path. Needs to be syncronized with
195 // eventual changes in the geometry.
196 //
197 TString volPath;
198 TString symName, sn;
199 TString vpAalign = "/ALIC_1/0STL_1";
200 TString vpCalign = "/ALIC_1/0STL_2";
201 for (Int_t imod=0; imod<2; imod++) {
202 if (imod==0) {volPath = vpCalign; symName="/ALIC_1/0STL_1"; }
203 if (imod==1) {volPath = vpAalign; symName="/ALIC_1/0STL_2"; }
204
205 AliDebug(2,"--------------------------------------------");
206 AliDebug(2,Form("volPath=%s\n",volPath.Data()));
207 AliDebug(2,Form("symName=%s\n",symName.Data()));
208 AliDebug(2,"--------------------------------------------");
209 if(!gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data()))
210 AliFatal(Form("Alignable entry %s not created. Volume path %s not valid",
211symName.Data(),volPath.Data()));
212 }
213}
214//------------------------------------------------------------------------
215void AliFITv1::CreateMaterials()
216{
217
218 Int_t isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
219 Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
220 // Float_t a,z,d,radl,absl,buf[1];
221 // Int_t nbuf;
222// AIR
223
224 Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
225 Float_t zAir[4]={6.,7.,8.,18.};
226 Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
227 Float_t dAir = 1.20479E-3;
228 Float_t dAir1 = 1.20479E-11;
229 // Radiator glass SiO2
230 Float_t aglass[2]={28.0855,15.9994};
231 Float_t zglass[2]={14.,8.};
232 Float_t wglass[2]={1.,2.};
233 Float_t dglass=2.65;
234 // MCP glass SiO2
235 Float_t dglass_mcp=1.3;
236//*** Definition Of avaible T0 materials ***
237 AliMixture(1, "Vacuum$", aAir, zAir, dAir1,4,wAir);
238 AliMixture(2, "Air$", aAir, zAir, dAir,4,wAir);
239 AliMixture( 4, "MCP glass $",aglass,zglass,dglass_mcp,-2,wglass);
240 AliMixture( 24, "Radiator Optical glass$",aglass,zglass,dglass,-2,wglass);
241
242 AliMedium(1, "Air$", 2, 0, isxfld, sxmgmx, 10., .1, 1., .003, .003);
243 AliMedium(3, "Vacuum$", 1, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
244 AliMedium(6, "Glass$", 4, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
245
246 AliMedium(16, "OpticalGlass$", 24, 1, isxfld, sxmgmx, 10., .01, .1, .003, .003);
247 AliMedium(19, "OpticalGlassCathode$", 24, 1, isxfld, sxmgmx, 10., .01, .1, .003, .003);
248 AliMedium(22, "SensAir$", 2, 1, isxfld, sxmgmx, 10., .1, 1., .003, .003);
249
250 AliDebugClass(1,": ++++++++++++++Medium set++++++++++");
251
252
253}
254
255//-------------------------------------------------------------------
256void AliFITv1::DefineOpticalProperties()
257{
258
259
260// Optical properties definition.
261 Int_t *idtmed = fIdtmed->GetArray();
262// Definition Cherenkov parameters
263 int i;
264 const Int_t kNbins=31;
265
266 Float_t rindexSiO2[kNbins], efficAll[kNbins], rindexAir[kNbins], absorAir[kNbins],rindexCathodeNext[kNbins], absorbCathodeNext[kNbins];
267 Double_t efficMet[kNbins], aReflMet[kNbins];
268
269 // quartz 20mm
270 Float_t aAbsSiO2[kNbins]={29.0, 28.6, 28.3, 27.7, 27.3, 26.7, 26.4,
271 25.9, 25.3, 24.9, 24.5, 23.7,
272 23.2, 22.8, 22.4, 21.8, 21.3,
273 22.8, 22.1, 21.7, 21.2, 20.5,
274 19.9, 19.3, 18.7, 18.0, 17.1,
275 16.3, 15.3, 14.3, 14.3 };
276
277 Float_t aPckov[kNbins] ={3.87, 3.94, 4.02, 4.11, 4.19, 4.29, 4.38,
278 4.48, 4.58, 4.69, 4.81, 4.93,
279 5.05, 5.19, 5.33, 5.48, 5.63,
280 5.8, 5.97, 6.16, 6.36, 6.57,
281 6.8, 7.04, 7.3, 7.58, 7.89,
282 8.22, 8.57, 8.97, 9.39 };
283 Double_t dPckov[kNbins] ={3.87, 3.94, 4.02, 4.11, 4.19, 4.29, 4.38,
284 4.48, 4.58, 4.69, 4.81, 4.93,
285 5.05, 5.19, 5.33, 5.48, 5.63,
286 5.8, 5.97, 6.16, 6.36, 6.57,
287 6.8, 7.04, 7.3, 7.58, 7.89,
288 8.22, 8.57, 8.97, 9.39 };
289
290 /*
291 Float_t effCathode[kNbins]={0.11, 0.13, 0.15, 0.16, 0.18, 0.19, 0.20,
292 0.21, 0.22, 0.23, 0.24, 0.26,
293 0.27, 0.29, 0.30, 0.29, 0.29,
294 0.28, 0.28, 0.27, 0.26, 0.25,
295 0.25, 0.23, 0.20, 0.19, 0.17,
296 0.17, 0.17, 0.2, 0.23};
297 */
298 // Float_t aAbsSiO2[kNbins]; //quartz 30mm
299 for(i=0;i<kNbins;i++)
300
301 {
302 aPckov[i]=aPckov[i]*1e-9;//Photons energy bins 4 eV - 8.5 eV step 0.1 eV
303 dPckov[i]=dPckov[i]*1e-9;//Photons energy bins 4 eV - 8.5 eV step 0.1 eV
304 // rindexAir[i]=0.0001;
305 rindexAir[i] = 1.;
306 rindexSiO2[i]=1.458; //refractive index for qwarts
307 rindexCathodeNext[i]=0;
308 efficAll[i]=1.;
309 efficMet[i]=0.;
310 aReflMet[i]=1.;
311 // aAbsSiO2[i]=28.5; //quartz 30mm
312 absorAir[i]=0.3;
313 absorbCathodeNext[i]=0;
314
315 }
316
2942f542 317 TVirtualMC::GetMC()->SetCerenkov (idtmed[kOpGlass], kNbins, aPckov, aAbsSiO2, efficAll, rindexSiO2 );
318 // TVirtualMC::GetMC()->SetCerenkov (idtmed[kOpGlassCathode], kNbins, aPckov, aAbsSiO2, effCathode, rindexSiO2 );
319 TVirtualMC::GetMC()->SetCerenkov (idtmed[kOpGlassCathode], kNbins, aPckov, aAbsSiO2,efficAll , rindexSiO2 );
320 // TVirtualMC::GetMC()->SetCerenkov (idtmed[kOpAir], kNbins, aPckov,absorAir , efficAll,rindexAir );
321 // TVirtualMC::GetMC()->SetCerenkov (idtmed[kOpAirNext], kNbins, aPckov,absorbCathodeNext , efficAll, rindexCathodeNext);
c1c44db3 322
323 //Define a boarder for radiator optical properties
2942f542 324 TVirtualMC::GetMC()->DefineOpSurface("surfRd", kUnified /*kGlisur*/,kDielectric_metal,kPolished, 0.);
325 TVirtualMC::GetMC()->SetMaterialProperty("surfRd", "EFFICIENCY", kNbins, dPckov, efficMet);
326 TVirtualMC::GetMC()->SetMaterialProperty("surfRd", "REFLECTIVITY", kNbins, dPckov, aReflMet);
c1c44db3 327
328
329}
330
331//-------------------------------------------------------------------
332void AliFITv1::Init()
333{
334// Initialises version 0 of the Forward Multiplicity Detector
335//
336 AliFIT::Init();
2942f542 337 fIdSens1=TVirtualMC::GetMC()->VolId("0REG");
c1c44db3 338
339 AliDebug(1,Form("%s: *** FIT version 1 initialized ***\n",ClassName()));
340}
341
342//-------------------------------------------------------------------
343
344void AliFITv1::StepManager()
345{
346 //
347 // Called for every step in the T0 Detector
348 //
349 Int_t id,copy,copy1;
350 static Float_t hits[6];
351 static Int_t vol[3];
352 TLorentzVector pos;
353 TLorentzVector mom;
354
355 // TClonesArray &lhits = *fHits;
356
2942f542 357 if(!TVirtualMC::GetMC()->IsTrackAlive()) return; // particle has disappeared
c1c44db3 358
2942f542 359 id=TVirtualMC::GetMC()->CurrentVolID(copy);
c1c44db3 360 // Check the sensetive volume
361 if(id==fIdSens1 ) {
2942f542 362 if(TVirtualMC::GetMC()->IsTrackEntering()) {
363 TVirtualMC::GetMC()->CurrentVolOffID(1,copy1);
c1c44db3 364 vol[1] = copy1;
365 vol[0]=copy;
2942f542 366 TVirtualMC::GetMC()->TrackPosition(pos);
c1c44db3 367 hits[0] = pos[0];
368 hits[1] = pos[1];
369 hits[2] = pos[2];
370 if(pos[2]<0) vol[2] = 0;
371 else vol[2] = 1 ;
372 // printf(" volumes pmt %i mcp %i side %i x %f y %f z %f\n", vol[0], vol[1], vol[2], hits[0], hits[1], hits[2] );
373
2942f542 374 Float_t etot=TVirtualMC::GetMC()->Etot();
c1c44db3 375 hits[3]=etot;
2942f542 376 Int_t iPart= TVirtualMC::GetMC()->TrackPid();
377 Int_t partID=TVirtualMC::GetMC()->IdFromPDG(iPart);
c1c44db3 378 hits[4]=partID;
2942f542 379 Float_t ttime=TVirtualMC::GetMC()->TrackTime();
c1c44db3 380 hits[5]=ttime*1e12;
2942f542 381 if (TVirtualMC::GetMC()->TrackPid() == 50000050) // If particles is photon then ...
c1c44db3 382 {
383 // if(RegisterPhotoE(vol[1]-1,hits[3])) {
384 if(RegisterPhotoE(hits[3])) {
385 AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
386 // Create a track reference at the exit of photocatode
387 }
388 }
389
390 //charge particle
2942f542 391 if ( TVirtualMC::GetMC()->TrackCharge() )
c1c44db3 392 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kFIT);
393
394 }// trck entering
395 } //sensitive
396
397}
398
399
400
401//------------------------------------------------------------------------
402Bool_t AliFITv1::RegisterPhotoE(Double_t energy)
403{
404
405
406 // Float_t hc=197.326960*1.e6; //mev*nm
407 Double_t hc=1.973*1.e-6; //gev*nm
408 Float_t lambda=hc/energy;
409 Float_t eff = fPMTeff->Eval(lambda);
410 Double_t p = gRandom->Rndm();
411
412 if (p > eff)
413 return kFALSE;
414
415 return kTRUE;
416}
417
418//----------------------------------------------------------------------------
419
420void AliFITv1::SetPMTeff()
421{
422 Float_t lambda[50];
423 Float_t eff[50 ] = {0, 0, 0.23619, 0.202909, 0.177913,
424 0.175667, 0.17856, 0.190769, 0.206667, 0.230286,
425 0.252276, 0.256267,0.26, 0.27125, 0.281818,
426 0.288118, 0.294057,0.296222, 0.301622, 0.290421,
427 0.276615, 0.2666, 0.248, 0.23619, 0.227814,
428 0.219818, 0.206667,0.194087, 0.184681, 0.167917,
429 0.154367, 0.1364, 0.109412, 0.0834615,0.0725283,
430 0.0642963,0.05861, 0.0465, 0.0413333,0.032069,
431 0.0252203,0.02066, 0.016262, 0.012, 0.00590476,
432 0.003875, 0.00190, 0, 0, 0 } ;
433 for (Int_t i=0; i<50; i++) lambda[i]=200+10*i;
434
435 fPMTeff = new TGraph(50,lambda,eff);
436
437}
438
439
440
441
442