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