]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRD.cxx
fix coverity
[u/mrichter/AliRoot.git] / TRD / AliTRD.cxx
CommitLineData
4c039060 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
88cb7938 16/* $Id$ */
4c039060 17
fe4da5cc 18///////////////////////////////////////////////////////////////////////////////
19// //
20// Transition Radiation Detector //
21// This class contains the basic functions for the Transition Radiation //
6f1e466d 22// Detector. //
fe4da5cc 23// //
24///////////////////////////////////////////////////////////////////////////////
25
f7a1cc68 26#include <TGeoGlobalMagField.h>
88cb7938 27#include <TVirtualMC.h>
32b13758 28#include <TGeoManager.h>
88cb7938 29
45160b1f 30#include "AliMC.h"
793ff80c 31#include "AliMagF.h"
88cb7938 32#include "AliRun.h"
030b4415 33
793ff80c 34#include "AliTRD.h"
851d3db9 35#include "AliTRDdigitizer.h"
88cb7938 36#include "AliTRDdigitsManager.h"
bd0f8685 37#include "AliTRDgeometry.h"
88cb7938 38#include "AliTRDhit.h"
b864d801 39#include "AliTRDrawData.h"
a076fc2f 40#include "AliTRDCommonParam.h"
3551db50 41
fe4da5cc 42ClassImp(AliTRD)
43
44//_____________________________________________________________________________
45AliTRD::AliTRD()
030b4415 46 :AliDetector()
47 ,fGeometry(0)
48 ,fGasDensity(0)
49 ,fFoilDensity(0)
f2979d08 50 ,fGasNobleFraction(0)
674812e4 51 ,fPrimaryIonisation(0)
fe4da5cc 52{
53 //
54 // Default constructor
55 //
332e9569 56
fe4da5cc 57}
58
59//_____________________________________________________________________________
60AliTRD::AliTRD(const char *name, const char *title)
030b4415 61 :AliDetector(name,title)
62 ,fGeometry(0)
63 ,fGasDensity(0)
64 ,fFoilDensity(0)
457b47bb 65 ,fGasNobleFraction(0)
674812e4 66 ,fPrimaryIonisation(0)
fe4da5cc 67{
68 //
69 // Standard constructor for the TRD
70 //
71
030b4415 72 // Check that FRAME is there otherwise we have no place where to put TRD
73 AliModule *frame = gAlice->GetModule("FRAME");
8230f242 74 if (!frame) {
030b4415 75 AliError("TRD needs FRAME to be present\n");
5c7f4665 76 exit(1);
77 }
78
d37eec5e 79 // Define the TRD geometry
80 if ((frame->IsVersion() == 0) ||
81 (frame->IsVersion() == 1)) {
bd0f8685 82 fGeometry = new AliTRDgeometry();
851d3db9 83 }
84 else {
030b4415 85 AliError("Could not find valid FRAME version\n");
851d3db9 86 exit(1);
87 }
5c7f4665 88
fe4da5cc 89 // Allocate the hit array
030b4415 90 fHits = new TClonesArray("AliTRDhit",405);
5d12ce38 91 gAlice->GetMCApp()->AddHitList(fHits);
e306b465 92
8230f242 93}
94
99d5402e 95//_____________________________________________________________________________
96AliTRD::~AliTRD()
97{
98 //
99 // TRD destructor
100 //
e306b465 101
abaf1f1d 102 if (fGeometry) {
103 delete fGeometry;
030b4415 104 fGeometry = 0;
abaf1f1d 105 }
030b4415 106
abaf1f1d 107 if (fHits) {
108 delete fHits;
030b4415 109 fHits = 0;
abaf1f1d 110 }
bd0f8685 111
5c7f4665 112}
113
6244debe 114//_____________________________________________________________________________
115void AliTRD::Hits2Digits()
2ab0c725 116{
117 //
118 // Create digits
119 //
bd0f8685 120
be385a87 121 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
45160b1f 122 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
9a96f175 123
6244debe 124 // Initialization
be385a87 125 digitizer.InitDetector();
e306b465 126
030b4415 127 if (!fLoader->TreeH()) {
128 fLoader->LoadHits("read");
129 }
85a5290f 130 fLoader->LoadDigits("recreate");
95867fd1 131
030b4415 132 AliRunLoader *runLoader = fLoader->GetRunLoader();
6244debe 133
85a5290f 134 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
95867fd1 135 runLoader->GetEvent(iEvent);
136 digitizer.Open(runLoader,iEvent);
be385a87 137 digitizer.MakeDigits();
138 digitizer.WriteDigits();
6244debe 139 }
140
85a5290f 141 fLoader->UnloadHits();
142 fLoader->UnloadDigits();
a328fff9 143
6244debe 144}
145
146//_____________________________________________________________________________
147void AliTRD::Hits2SDigits()
148{
149 //
150 // Create summable digits
151 //
a328fff9 152
be385a87 153 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
6244debe 154 // For the summable digits
be385a87 155 digitizer.SetSDigits(kTRUE);
45160b1f 156 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
6244debe 157
158 // Initialization
be385a87 159 digitizer.InitDetector();
e306b465 160
030b4415 161 if (!fLoader->TreeH()) {
162 fLoader->LoadHits("read");
163 }
85a5290f 164 fLoader->LoadSDigits("recreate");
95867fd1 165
166 AliRunLoader *runLoader = fLoader->GetRunLoader();
6244debe 167
85a5290f 168 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
95867fd1 169 runLoader->GetEvent(iEvent);
170 digitizer.Open(runLoader,iEvent);
be385a87 171 digitizer.MakeDigits();
172 digitizer.WriteDigits();
85a5290f 173 }
2ab0c725 174
85a5290f 175 fLoader->UnloadHits();
176 fLoader->UnloadSDigits();
a328fff9 177
178}
6244debe 179
85a5290f 180//_____________________________________________________________________________
95867fd1 181AliDigitizer *AliTRD::CreateDigitizer(AliRunDigitizer *manager) const
85a5290f 182{
a328fff9 183 //
184 // Creates a new digitizer object
185 //
186
85a5290f 187 return new AliTRDdigitizer(manager);
a328fff9 188
6244debe 189}
190
191//_____________________________________________________________________________
192void AliTRD::SDigits2Digits()
193{
194 //
195 // Create final digits from summable digits
196 //
197
bd0f8685 198 // Create the TRD digitizer
be385a87 199 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
45160b1f 200 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
99d5402e 201
abaf1f1d 202 // Set the parameter
be385a87 203 digitizer.SetEvent(gAlice->GetEvNumber());
abaf1f1d 204
205 // Initialization
be385a87 206 digitizer.InitDetector();
abaf1f1d 207
208 // Read the s-digits via digits manager
be385a87 209 AliTRDdigitsManager sdigitsManager;
88cb7938 210
45160b1f 211 AliLog::SetClassDebugLevel("TRDdigitisManager",AliDebugLevel());
be385a87 212 sdigitsManager.SetSDigits(kTRUE);
213 sdigitsManager.CreateArrays();
88cb7938 214
030b4415 215 if (!fLoader->TreeS()) {
216 if (fLoader->LoadSDigits("read")) {
217 return;
218 }
219 }
220 if (!fLoader->TreeS()) {
221 AliError(Form("Error while reading SDigits for event %d",gAlice->GetEvNumber()));
222 return;
223 }
88cb7938 224
be385a87 225 sdigitsManager.ReadDigits(fLoader->TreeS());
abaf1f1d 226
227 // Add the s-digits to the input list
be385a87 228 digitizer.AddSDigitsManager(&sdigitsManager);
99d5402e 229
abaf1f1d 230 // Convert the s-digits to normal digits
be385a87 231 digitizer.SDigits2Digits();
abaf1f1d 232
233 // Store the digits
030b4415 234 if (!fLoader->TreeD()) {
235 fLoader->MakeTree("D");
236 }
be385a87 237 if (digitizer.MakeBranch(fLoader->TreeD())){
238 digitizer.WriteDigits();
abaf1f1d 239 }
99d5402e 240
241}
242
b864d801 243//_____________________________________________________________________________
244void AliTRD::Digits2Raw()
245{
246 //
030b4415 247 // Convert digits of the current event to raw data
b864d801 248 //
249
250 fLoader->LoadDigits();
030b4415 251 TTree *digits = fLoader->TreeD();
b864d801 252 if (!digits) {
030b4415 253 AliError("No digits tree");
b864d801 254 return;
255 }
256
257 AliTRDrawData rawWriter;
b864d801 258 if (!rawWriter.Digits2Raw(digits)) {
030b4415 259 AliError("The raw writer could not load the digits tree");
b864d801 260 }
261
262 fLoader->UnloadDigits();
263
264}
265
fe4da5cc 266//_____________________________________________________________________________
332e9569 267void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
2fa01832 268 , Float_t time, Bool_t inDrift)
fe4da5cc 269{
270 //
271 // Add a hit for the TRD
332e9569 272 //
82bbf98a 273
a328fff9 274 TClonesArray &lhits = *fHits;
2fa01832 275 AliTRDhit *hit = new(lhits[fNhits++]) AliTRDhit(fIshunt
276 ,track
277 ,det
278 ,hits
279 ,q
280 ,time);
281
a328fff9 282 if (inDrift) {
283 hit->SetDrift();
332e9569 284 }
a328fff9 285 else {
286 hit->SetAmplification();
287 }
030b4415 288
a328fff9 289 if (q < 0) {
290 hit->SetTRphoton();
332e9569 291 }
82bbf98a 292
fe4da5cc 293}
fe4da5cc 294
295//_____________________________________________________________________________
82bbf98a 296void AliTRD::CreateGeometry()
fe4da5cc 297{
82bbf98a 298 //
299 // Creates the volumes for the TRD chambers
300 //
82bbf98a 301
302 // Check that FRAME is there otherwise we have no place where to put the TRD
030b4415 303 AliModule *frame = gAlice->GetModule("FRAME");
8230f242 304 if (!frame) {
45160b1f 305 AliFatal("The TRD needs the FRAME to be defined first");
82bbf98a 306 }
d3f347ff 307
851d3db9 308 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
5c7f4665 309
82bbf98a 310}
2d0eca96 311
82bbf98a 312//_____________________________________________________________________________
313void AliTRD::CreateMaterials()
314{
fe4da5cc 315 //
316 // Create the materials for the TRD
fe4da5cc 317 //
318
32b13758 319 Int_t isxfld = ((AliMagF *) TGeoGlobalMagField::Instance()->GetField())->Integ();
320 Float_t sxmgmx = ((AliMagF *) TGeoGlobalMagField::Instance()->GetField())->Max();
fe4da5cc 321
32b13758 322 //////////////////////////////////////////////////////////////////////////
323 // Define Materials
324 //////////////////////////////////////////////////////////////////////////
0c5a8090 325
32b13758 326 // Aluminum
327 AliMaterial( 1,"Al", 26.98, 13.0, 2.7, 8.9, 37.2);
328 // Copper
329 AliMaterial( 2,"Cu", 63.54, 29.0, 8.96, 1.43, 14.8);
330 // Carbon
331 AliMaterial( 3,"C" , 12.01, 6.0, 2.265, 18.8, 74.4);
332 // Carbon for fiber mats
333 AliMaterial( 4,"C2", 12.01, 6.0, 1.75, 18.8, 74.4);
334 // Zinc
335 AliMaterial( 5,"Sn", 118.71, 50.0, 7.31, 1.21, 14.8);
336 // Silicon
337 AliMaterial( 6,"Si", 28.09, 14.0, 2.33, 9.36, 37.2);
338 // Iron
339 AliMaterial( 7,"Fe", 55.85, 26.0, 7.87, 1.76, 14.8);
340
341 // Air
3dac2b2d 342 Float_t aAir[4] = { 12.011 , 14.0 , 15.9994 , 36.0 };
343 Float_t zAir[4] = { 6.0 , 7.0 , 8.0 , 18.0 };
344 Float_t wAir[4] = { 0.000124, 0.755267, 0.231781, 0.012827 };
0c5a8090 345 Float_t dAir = 1.20479e-03;
32b13758 346 AliMixture(51,"Air", aAir, zAir, dAir, 4, wAir );
347 // Polyethilene (CH2)
348 Float_t ape[2] = { 12.011 , 1.0079 };
349 Float_t zpe[2] = { 6.0 , 1.0 };
350 Float_t wpe[2] = { 1.0 , 2.0 };
351 Float_t dpe = 0.95;
352 AliMixture(52,"Polyethilene", ape, zpe, dpe, -2, wpe );
353 // Gas mixtures
354 // Xe/CO2-gas-mixture (85% / 15%)
3dac2b2d 355 Float_t aXeCO2[3] = { 131.29 , 12.0107 , 15.9994 };
356 Float_t zXeCO2[3] = { 54.0 , 6.0 , 8.0 };
330bfc2f 357 Float_t wXeCO2[3] = { 8.5 , 1.5 , 3.0 };
3dac2b2d 358 Float_t fxc = 0.85;
f2979d08 359 Float_t dxe = 0.00549; // at 20C
32b13758 360 Float_t dco = 0.00186; // at 20C
f2979d08 361 Float_t dgmXe = fxc * dxe + (1.0 - fxc) * dco;
32b13758 362 // Ar/CO2-gas-mixture
f2979d08 363 Float_t aArCO2[3] = { 39.948 , 12.0107 , 15.9994 };
364 Float_t zArCO2[3] = { 18.0 , 6.0 , 8.0 };
365 Float_t wArCO2[3] = { 8.2 , 1.8 , 3.6 };
f2979d08 366 Float_t fac = 0.82;
367 Float_t dar = 0.00166; // at 20C
368 Float_t dgmAr = fac * dar + (1.0 - fac) * dco;
a076fc2f 369 if (AliTRDCommonParam::Instance()->IsXenon()) {
32b13758 370 AliMixture(53,"XeCO2", aXeCO2, zXeCO2, dgmXe, -3, wXeCO2);
f2979d08 371 }
a076fc2f 372 else if (AliTRDCommonParam::Instance()->IsArgon()) {
f2979d08 373 AliInfo("Gas mixture: Ar C02 (80/20)");
32b13758 374 AliMixture(53,"ArCO2", aArCO2, zArCO2, dgmAr, -3, wArCO2);
f2979d08 375 }
376 else {
377 AliFatal("Wrong gas mixture");
378 exit(1);
379 }
32b13758 380 // G10
381 Float_t aG10[4] = { 1.0079, 12.011 , 15.9994, 28.086 };
382 Float_t zG10[4] = { 1.0 , 6.0 , 8.0 , 14.0 };
383 Float_t wG10[4] = { 0.023 , 0.194 , 0.443 , 0.340 };
384 Float_t dG10 = 2.0;
385 AliMixture(54,"G10", aG10, zG10, dG10, 4,wG10 );
386 // Water
387 Float_t awa[2] = { 1.0079, 15.9994 };
388 Float_t zwa[2] = { 1.0 , 8.0 };
389 Float_t wwa[2] = { 2.0 , 1.0 };
390 Float_t dwa = 1.0;
391 AliMixture(55,"Water", awa, zwa, dwa, -2,wwa );
392 // Rohacell (C5H8O2), X0 = 535.005cm
393 Float_t arh[3] = { 12.011 , 1.0079, 15.9994 };
394 Float_t zrh[3] = { 6.0 , 1.0 , 8.0 };
395 Float_t wrh[3] = { 5.0 , 8.0 , 2.0 };
396 Float_t drh = 0.075;
397 AliMixture(56,"Rohacell", arh, zrh, drh, -3,wrh );
398 // Epoxy (C18H19O3)
399 Float_t aEpoxy[3] = { 15.9994, 1.0079, 12.011 };
400 Float_t zEpoxy[3] = { 8.0 , 1.0 , 6.0 };
401 Float_t wEpoxy[3] = { 3.0 , 19.0 , 18.0 };
402 Float_t dEpoxy = 1.8 ;
403 AliMixture(57,"Epoxy", aEpoxy,zEpoxy,dEpoxy,-3,wEpoxy);
404 // Araldite, low density epoxy (C18H19O3)
405 Float_t aAral[3] = { 15.9994, 1.0079, 12.011 };
406 Float_t zAral[3] = { 8.0 , 1.0 , 6.0 };
407 Float_t wAral[3] = { 3.0 , 19.0 , 18.0 };
408 Float_t dAral = 1.12; // Hardener: 1.15, epoxy: 1.1, mixture: 1/2
409 AliMixture(58,"Araldite", aAral, zAral, dAral, -3,wAral );
410 // Mylar
411 Float_t aMy[3] = { 12.011 , 1.0 , 15.9994 };
412 Float_t zMy[3] = { 6.0 , 1.0 , 8.0 };
413 Float_t wMy[3] = { 5.0 , 4.0 , 2.0 };
414 Float_t dMy = 1.39;
415 AliMixture(59,"Mylar", aMy, zMy, dMy, -3,wMy );
416 // Polypropylene (C3H6) for radiator fibers
417 Float_t app[2] = { 12.011 , 1.0079 };
418 Float_t zpp[2] = { 6.0 , 1.0 };
419 Float_t wpp[2] = { 3.0 , 6.0 };
420 Float_t dpp = 0.068;
421 AliMixture(60,"Polypropylene",app, zpp, dpp, -2,wpp );
422 // Aramide for honeycomb
423 Float_t aAra[4] = { 1.0079, 12.011 , 15.9994, 14.0067 };
424 Float_t zAra[4] = { 1.0 , 6.0 , 8.0 , 7.0 };
425 Float_t wAra[4] = { 3.0 , 1.0 , 1.0 , 1.0 };
426 Float_t dAra = 0.032;
427 AliMixture(61,"Aramide", aAra, zAra, dAra, -4,wAra );
428 // GFK for Wacosit (Epoxy + Si)
429 Float_t aGFK[4] = { 1.0079, 12.011 , 15.9994, 28.086 };
430 Float_t zGFK[4] = { 1.0 , 6.0 , 8.0 , 14.0 };
431 Float_t wGFK[4] = { 0.0445, 0.5031, 0.1118, 0.340 };
432 Float_t dGFK = 2.0;
433 AliMixture(62,"GFK", aGFK, zGFK, dGFK, 4,wGFK );
3dac2b2d 434
d3f347ff 435 //////////////////////////////////////////////////////////////////////////
fe4da5cc 436 // Tracking Media Parameters
d3f347ff 437 //////////////////////////////////////////////////////////////////////////
438
32b13758 439 // General tracking parameter
440 Float_t tmaxfd = -10.0;
441 Float_t stemax = -1.0e10;
442 Float_t deemax = -0.1;
443 Float_t epsil = 1.0e-4;
444 Float_t stmin = -0.001;
445
d3f347ff 446 // Al Frame
0c5a8090 447 AliMedium( 1,"Al Frame" , 1,0,isxfld,sxmgmx
448 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 449 // Air
32b13758 450 AliMedium( 2,"Air" ,51,0,isxfld,sxmgmx
0c5a8090 451 ,tmaxfd,stemax,deemax,epsil,stmin);
452 // Wires
32b13758 453 AliMedium( 3,"Wires" , 2,0,isxfld,sxmgmx
0c5a8090 454 ,tmaxfd,stemax,deemax,epsil,stmin);
455 // All other ROB materials (caps, etc.)
32b13758 456 AliMedium( 4,"ROB Other" , 2,0,isxfld,sxmgmx
0c5a8090 457 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 458 // Cu pads
32b13758 459 AliMedium( 5,"Padplane" , 2,1,isxfld,sxmgmx
0c5a8090 460 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 461 // Fee + cables
32b13758 462 AliMedium( 6,"Readout" , 2,0,isxfld,sxmgmx
0c5a8090 463 ,tmaxfd,stemax,deemax,epsil,stmin);
32b13758 464 // C frame (Wacosit)
465 AliMedium( 7,"Wacosit" ,62,0,isxfld,sxmgmx
466 ,tmaxfd,stemax,deemax,epsil,stmin);
0c5a8090 467 // INOX of cooling bus bars
32b13758 468 AliMedium( 8,"Cooling bus", 7,0,isxfld,sxmgmx
0c5a8090 469 ,tmaxfd,stemax,deemax,epsil,stmin);
3dac2b2d 470 // Gas-mixture (Xe/CO2)
32b13758 471 AliMedium( 9,"Gas-mix" ,53,1,isxfld,sxmgmx
0c5a8090 472 ,tmaxfd,stemax,deemax,epsil,stmin);
32b13758 473 // Honeycomb
474 AliMedium(10,"Honeycomb" ,61,0,isxfld,sxmgmx
0c5a8090 475 ,tmaxfd,stemax,deemax,epsil,stmin);
476 // Araldite glue
32b13758 477 AliMedium(11,"Glue" ,58,0,isxfld,sxmgmx
0c5a8090 478 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 479 // G10-plates
32b13758 480 AliMedium(13,"G10-plates" ,54,0,isxfld,sxmgmx
0c5a8090 481 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 482 // Cooling water
32b13758 483 AliMedium(14,"Water" ,55,0,isxfld,sxmgmx
0c5a8090 484 ,tmaxfd,stemax,deemax,epsil,stmin);
32b13758 485 // Rohacell for the radiator
486 AliMedium(15,"Rohacell" ,56,0,isxfld,sxmgmx
0c5a8090 487 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 488 // Al layer in MCMs
0c5a8090 489 AliMedium(16,"MCM-Al" , 1,0,isxfld,sxmgmx
490 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 491 // Sn layer in MCMs
32b13758 492 AliMedium(17,"MCM-Sn" , 5,0,isxfld,sxmgmx
0c5a8090 493 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 494 // Cu layer in MCMs
32b13758 495 AliMedium(18,"MCM-Cu" , 2,0,isxfld,sxmgmx
0c5a8090 496 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 497 // G10 layer in MCMs
32b13758 498 AliMedium(19,"MCM-G10" ,54,0,isxfld,sxmgmx
0c5a8090 499 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 500 // Si in readout chips
32b13758 501 AliMedium(20,"Chip-Si" , 6,0,isxfld,sxmgmx
0c5a8090 502 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 503 // Epoxy in readout chips
32b13758 504 AliMedium(21,"Chip-Ep" ,57,0,isxfld,sxmgmx
0c5a8090 505 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 506 // PE in connectors
32b13758 507 AliMedium(22,"Conn-PE" ,52,0,isxfld,sxmgmx
0c5a8090 508 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 509 // Cu in connectors
32b13758 510 AliMedium(23,"Chip-Cu" , 2,0,isxfld,sxmgmx
0c5a8090 511 ,tmaxfd,stemax,deemax,epsil,stmin);
16bf9884 512 // Al of cooling pipes
0c5a8090 513 AliMedium(24,"Cooling" , 1,0,isxfld,sxmgmx
514 ,tmaxfd,stemax,deemax,epsil,stmin);
73ae7b59 515 // Cu in services
32b13758 516 AliMedium(25,"Serv-Cu" , 2,0,isxfld,sxmgmx
517 ,tmaxfd,stemax,deemax,epsil,stmin);
518 // Carbon fiber mat
519 AliMedium(26,"Carbon" , 4,0,isxfld,sxmgmx
520 ,tmaxfd,stemax,deemax,epsil,stmin);
521 // Mylar foil
522 AliMedium(27,"Mylar" ,59,0,isxfld,sxmgmx
523 ,tmaxfd,stemax,deemax,epsil,stmin);
524 // Polypropylene fibers
525 AliMedium(28,"Fiber" ,60,0,isxfld,sxmgmx
0c5a8090 526 ,tmaxfd,stemax,deemax,epsil,stmin);
d3f347ff 527
793ff80c 528 // Save the density values for the TRD absorbtion
0c5a8090 529 Float_t dmy = 1.39;
793ff80c 530 fFoilDensity = dmy;
a076fc2f 531 if (AliTRDCommonParam::Instance()->IsXenon()) {
f2979d08 532 fGasDensity = dgmXe;
533 fGasNobleFraction = fxc;
534 }
a076fc2f 535 else if (AliTRDCommonParam::Instance()->IsArgon()) {
f2979d08 536 fGasDensity = dgmAr;
537 fGasNobleFraction = fac;
538 }
793ff80c 539
fe4da5cc 540}
fe4da5cc 541
542//_____________________________________________________________________________
543void AliTRD::Init()
544{
545 //
851d3db9 546 // Initialize the TRD detector after the geometry has been created
fe4da5cc 547 //
82bbf98a 548
45160b1f 549 AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++");
5c7f4665 550
bd0f8685 551 if (fGeometry->IsVersion() != 1) {
45160b1f 552 AliError("Not a valid geometry");
d37eec5e 553 }
5f06bf41 554
7235aed2 555 // Special tracking options for charged particles for XeCO2
5f06bf41 556 gMC->Gstpar((* fIdtmed)[9],"DRAY" , 1.0);
557 gMC->Gstpar((* fIdtmed)[9],"STRA" , 1.0);
558 gMC->Gstpar((* fIdtmed)[9],"LOSS" ,13.0); // Specific energy loss
e8ec3430 559 // Parameters specific to Fluka
560 //gMC->Gstpar((* fIdtmed)[9],"PRIMIO_E",23.53); // 1st ionisation potential
561 //gMC->Gstpar((* fIdtmed)[9],"PRIMIO_N",19.344431); // Number of primaries
5f06bf41 562
5c7f4665 563}
564
6244debe 565//_____________________________________________________________________________
566void AliTRD::ResetDigits()
567{
568 //
abaf1f1d 569 // Reset number of digits and the digits array for this detector
6244debe 570 //
571
abaf1f1d 572 fNdigits = 0;
030b4415 573
574 if (fDigits) {
575 fDigits->Clear();
576 }
6244debe 577
578}
579
5c7f4665 580//_____________________________________________________________________________
581void AliTRD::SetTreeAddress()
582{
583 //
584 // Set the branch addresses for the trees.
585 //
586
030b4415 587 if (fLoader->TreeH() &&
588 (fHits == 0x0)) {
a328fff9 589 fHits = new TClonesArray("AliTRDhit",405);
332e9569 590 }
a328fff9 591 AliDetector::SetTreeAddress();
332e9569 592
fe4da5cc 593}
594
68119ad1 595//_____________________________________________________________________________
596Bool_t AliTRD::Raw2SDigits(AliRawReader *rawReader)
597{
598 //
599 // Converts RAW data to SDigits
600 //
601
602 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
603 if (!loader) {
604 AliError("Can not get TRD loader from Run Loader");
605 return kFALSE;
606 }
607
608 TTree *tree = 0;
609 tree = loader->TreeS();
610 if (!tree) {
611 loader->MakeTree("S");
612 tree = loader->TreeS();
613 }
614
e7539003 615 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
616
68119ad1 617 AliTRDrawData *rawdata = new AliTRDrawData();
e7539003 618 AliTRDdigitsManager *digitsManager = rawdata->Raw2Digits(rawReader);
619
620 // Create the s-digits manager
621 AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
e7539003 622
68119ad1 623 if (sdigitsManager) {
e7539003 624
1f96c08f 625 sdigitsManager->SetSDigits(kTRUE);
626 sdigitsManager->CreateArrays();
627
e7539003 628 // Convert the digits into s-digits
629 digitizer.Digits2SDigits(digitsManager,sdigitsManager);
630
68119ad1 631 sdigitsManager->MakeBranch(tree);
632 sdigitsManager->WriteDigits();
e7539003 633
634 delete digitsManager;
635
68119ad1 636 return kTRUE;
e7539003 637
68119ad1 638 }
639 else {
e7539003 640
68119ad1 641 return kFALSE;
e7539003 642
68119ad1 643 }
644
645}
646
9c7c9ec1 647//_____________________________________________________________________________
e7539003 648AliLoader *AliTRD::MakeLoader(const Char_t *topfoldername)
9c7c9ec1 649{
e7539003 650 //
651 // Create a loader for the TRD tracklets
652 //
653
9c7c9ec1 654 fLoader = new AliLoader(GetName(),topfoldername);
655
656 AliInfo("Adding Tracklets-loader");
e7539003 657
658 AliDataLoader *dl = new AliDataLoader("TRD.Tracklets.root"
659 ,"tracklets"
660 ,"tracklets");
9c7c9ec1 661 fLoader->AddDataLoader(dl);
e7539003 662
663 dl = new AliDataLoader("TRD.GtuTracks.root"
664 ,"gtutracks"
665 ,"gtutracks");
c8b1590d 666 fLoader->AddDataLoader(dl);
e7539003 667
9c7c9ec1 668 return fLoader;
e7539003 669
9c7c9ec1 670}
671
dd9a6ee3 672//_____________________________________________________________________________
673AliTRD &AliTRD::operator=(const AliTRD &trd)
674{
675 //
676 // Assignment operator
677 //
678
0c5a8090 679 if (this != &trd) {
680 ((AliTRD &) trd).Copy(*this);
681 }
030b4415 682
dd9a6ee3 683 return *this;
684
68119ad1 685}