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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // Transition Radiation Detector //
21 // This class contains the basic functions for the Transition Radiation //
24 ///////////////////////////////////////////////////////////////////////////////
26 #include <TGeoGlobalMagField.h>
27 #include <TVirtualMC.h>
28 #include <TGeoManager.h>
33 #include "AliLoader.h"
36 #include "AliTRDdigitizer.h"
37 #include "AliTRDdigitsManager.h"
38 #include "AliTRDgeometry.h"
39 #include "AliTRDhit.h"
40 #include "AliTRDrawData.h"
41 #include "AliTRDCommonParam.h"
45 //_____________________________________________________________________________
52 ,fPrimaryIonisation(0)
55 // Default constructor
60 //_____________________________________________________________________________
61 AliTRD::AliTRD(const char *name, const char *title)
62 :AliDetector(name,title)
67 ,fPrimaryIonisation(0)
70 // Standard constructor for the TRD
73 // Check that FRAME is there otherwise we have no place where to put TRD
74 AliModule *frame = gAlice->GetModule("FRAME");
76 AliError("TRD needs FRAME to be present\n");
80 // Define the TRD geometry
81 if ((frame->IsVersion() == 0) ||
82 (frame->IsVersion() == 1)) {
83 fGeometry = new AliTRDgeometry();
86 AliError("Could not find valid FRAME version\n");
90 // Allocate the hit array
91 fHits = new TClonesArray("AliTRDhit",405);
92 gAlice->GetMCApp()->AddHitList(fHits);
96 //_____________________________________________________________________________
115 //_____________________________________________________________________________
116 void AliTRD::Hits2Digits()
122 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
123 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
126 digitizer.InitDetector();
128 if (!fLoader->TreeH()) {
129 fLoader->LoadHits("read");
131 fLoader->LoadDigits("recreate");
133 AliRunLoader *runLoader = fLoader->GetRunLoader();
135 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
136 runLoader->GetEvent(iEvent);
137 digitizer.Open(runLoader,iEvent);
138 digitizer.MakeDigits();
139 digitizer.WriteDigits();
142 fLoader->UnloadHits();
143 fLoader->UnloadDigits();
147 //_____________________________________________________________________________
148 void AliTRD::Hits2SDigits()
151 // Create summable digits
154 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
155 // For the summable digits
156 digitizer.SetSDigits(kTRUE);
157 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
160 digitizer.InitDetector();
162 if (!fLoader->TreeH()) {
163 fLoader->LoadHits("read");
165 fLoader->LoadSDigits("recreate");
167 AliRunLoader *runLoader = fLoader->GetRunLoader();
169 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
170 runLoader->GetEvent(iEvent);
171 digitizer.Open(runLoader,iEvent);
172 digitizer.MakeDigits();
173 digitizer.WriteDigits();
176 fLoader->UnloadHits();
177 fLoader->UnloadSDigits();
181 //_____________________________________________________________________________
182 AliDigitizer *AliTRD::CreateDigitizer(AliDigitizationInput* digInput) const
185 // Creates a new digitizer object
188 return new AliTRDdigitizer(digInput);
192 //_____________________________________________________________________________
193 void AliTRD::SDigits2Digits()
196 // Create final digits from summable digits
199 // Create the TRD digitizer
200 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
201 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
204 digitizer.SetEvent(gAlice->GetEvNumber());
207 digitizer.InitDetector();
209 // Read the s-digits via digits manager
210 AliTRDdigitsManager sdigitsManager;
212 AliLog::SetClassDebugLevel("TRDdigitisManager",AliDebugLevel());
213 sdigitsManager.SetSDigits(kTRUE);
214 sdigitsManager.CreateArrays();
216 if (!fLoader->TreeS()) {
217 if (fLoader->LoadSDigits("read")) {
221 if (!fLoader->TreeS()) {
222 AliError(Form("Error while reading SDigits for event %d",gAlice->GetEvNumber()));
226 sdigitsManager.ReadDigits(fLoader->TreeS());
228 // Add the s-digits to the input list
229 digitizer.AddSDigitsManager(&sdigitsManager);
231 // Convert the s-digits to normal digits
232 digitizer.SDigits2Digits();
235 if (!fLoader->TreeD()) {
236 fLoader->MakeTree("D");
238 if (digitizer.MakeBranch(fLoader->TreeD())){
239 digitizer.WriteDigits();
244 //_____________________________________________________________________________
245 void AliTRD::Digits2Raw()
248 // Convert digits of the current event to raw data
251 fLoader->LoadDigits();
252 TTree *digits = fLoader->TreeD();
254 AliError("No digits tree");
258 AliTRDrawData rawWriter;
259 if (!rawWriter.Digits2Raw(digits)) {
260 AliError("The raw writer could not load the digits tree");
263 fLoader->UnloadDigits();
267 //_____________________________________________________________________________
268 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
269 , Float_t time, Bool_t inDrift)
272 // Add a hit for the TRD
275 TClonesArray &lhits = *fHits;
276 AliTRDhit *hit = new(lhits[fNhits++]) AliTRDhit(fIshunt
287 hit->SetAmplification();
296 //_____________________________________________________________________________
297 void AliTRD::CreateGeometry()
300 // Creates the volumes for the TRD chambers
303 // Check that FRAME is there otherwise we have no place where to put the TRD
304 AliModule *frame = gAlice->GetModule("FRAME");
306 AliFatal("The TRD needs the FRAME to be defined first");
309 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
313 //_____________________________________________________________________________
314 void AliTRD::CreateMaterials()
317 // Create the materials for the TRD
320 Int_t isxfld = ((AliMagF *) TGeoGlobalMagField::Instance()->GetField())->Integ();
321 Float_t sxmgmx = ((AliMagF *) TGeoGlobalMagField::Instance()->GetField())->Max();
323 //////////////////////////////////////////////////////////////////////////
325 //////////////////////////////////////////////////////////////////////////
328 AliMaterial( 1,"Al", 26.98, 13.0, 2.7, 8.9, 37.2);
330 AliMaterial( 2,"Cu", 63.54, 29.0, 8.96, 1.43, 14.8);
332 AliMaterial( 3,"C" , 12.01, 6.0, 2.265, 18.8, 74.4);
333 // Carbon for fiber mats
334 AliMaterial( 4,"C2", 12.01, 6.0, 1.75, 18.8, 74.4);
336 AliMaterial( 5,"Sn", 118.71, 50.0, 7.31, 1.21, 14.8);
338 AliMaterial( 6,"Si", 28.09, 14.0, 2.33, 9.36, 37.2);
340 AliMaterial( 7,"Fe", 55.85, 26.0, 7.87, 1.76, 14.8);
343 Float_t aAir[4] = { 12.011 , 14.0 , 15.9994 , 36.0 };
344 Float_t zAir[4] = { 6.0 , 7.0 , 8.0 , 18.0 };
345 Float_t wAir[4] = { 0.000124, 0.755267, 0.231781, 0.012827 };
346 Float_t dAir = 1.20479e-03;
347 AliMixture(51,"Air", aAir, zAir, dAir, 4, wAir );
348 // Polyethilene (CH2)
349 Float_t ape[2] = { 12.011 , 1.0079 };
350 Float_t zpe[2] = { 6.0 , 1.0 };
351 Float_t wpe[2] = { 1.0 , 2.0 };
353 AliMixture(52,"Polyethilene", ape, zpe, dpe, -2, wpe );
355 // Xe/CO2-gas-mixture (85% / 15%)
356 Float_t aXeCO2[3] = { 131.29 , 12.0107 , 15.9994 };
357 Float_t zXeCO2[3] = { 54.0 , 6.0 , 8.0 };
358 Float_t wXeCO2[3] = { 8.5 , 1.5 , 3.0 };
360 Float_t dxe = 0.00549; // at 20C
361 Float_t dco = 0.00186; // at 20C
362 Float_t dgmXe = fxc * dxe + (1.0 - fxc) * dco;
363 // Ar/CO2-gas-mixture
364 Float_t aArCO2[3] = { 39.948 , 12.0107 , 15.9994 };
365 Float_t zArCO2[3] = { 18.0 , 6.0 , 8.0 };
366 Float_t wArCO2[3] = { 8.2 , 1.8 , 3.6 };
368 Float_t dar = 0.00166; // at 20C
369 Float_t dgmAr = fac * dar + (1.0 - fac) * dco;
370 if (AliTRDCommonParam::Instance()->IsXenon()) {
371 AliMixture(53,"XeCO2", aXeCO2, zXeCO2, dgmXe, -3, wXeCO2);
373 else if (AliTRDCommonParam::Instance()->IsArgon()) {
374 AliInfo("Gas mixture: Ar C02 (80/20)");
375 AliMixture(53,"ArCO2", aArCO2, zArCO2, dgmAr, -3, wArCO2);
378 AliFatal("Wrong gas mixture");
382 Float_t aG10[4] = { 1.0079, 12.011 , 15.9994, 28.086 };
383 Float_t zG10[4] = { 1.0 , 6.0 , 8.0 , 14.0 };
384 Float_t wG10[4] = { 0.023 , 0.194 , 0.443 , 0.340 };
386 AliMixture(54,"G10", aG10, zG10, dG10, 4,wG10 );
388 Float_t awa[2] = { 1.0079, 15.9994 };
389 Float_t zwa[2] = { 1.0 , 8.0 };
390 Float_t wwa[2] = { 2.0 , 1.0 };
392 AliMixture(55,"Water", awa, zwa, dwa, -2,wwa );
393 // Rohacell (C5H8O2), X0 = 535.005cm
394 Float_t arh[3] = { 12.011 , 1.0079, 15.9994 };
395 Float_t zrh[3] = { 6.0 , 1.0 , 8.0 };
396 Float_t wrh[3] = { 5.0 , 8.0 , 2.0 };
398 AliMixture(56,"Rohacell", arh, zrh, drh, -3,wrh );
400 Float_t aEpoxy[3] = { 15.9994, 1.0079, 12.011 };
401 Float_t zEpoxy[3] = { 8.0 , 1.0 , 6.0 };
402 Float_t wEpoxy[3] = { 3.0 , 19.0 , 18.0 };
403 Float_t dEpoxy = 1.8 ;
404 AliMixture(57,"Epoxy", aEpoxy,zEpoxy,dEpoxy,-3,wEpoxy);
405 // Araldite, low density epoxy (C18H19O3)
406 Float_t aAral[3] = { 15.9994, 1.0079, 12.011 };
407 Float_t zAral[3] = { 8.0 , 1.0 , 6.0 };
408 Float_t wAral[3] = { 3.0 , 19.0 , 18.0 };
409 Float_t dAral = 1.12; // Hardener: 1.15, epoxy: 1.1, mixture: 1/2
410 AliMixture(58,"Araldite", aAral, zAral, dAral, -3,wAral );
412 Float_t aMy[3] = { 12.011 , 1.0 , 15.9994 };
413 Float_t zMy[3] = { 6.0 , 1.0 , 8.0 };
414 Float_t wMy[3] = { 5.0 , 4.0 , 2.0 };
416 AliMixture(59,"Mylar", aMy, zMy, dMy, -3,wMy );
417 // Polypropylene (C3H6) for radiator fibers
418 Float_t app[2] = { 12.011 , 1.0079 };
419 Float_t zpp[2] = { 6.0 , 1.0 };
420 Float_t wpp[2] = { 3.0 , 6.0 };
422 AliMixture(60,"Polypropylene",app, zpp, dpp, -2,wpp );
423 // Aramide for honeycomb
424 Float_t aAra[4] = { 1.0079, 12.011 , 15.9994, 14.0067 };
425 Float_t zAra[4] = { 1.0 , 6.0 , 8.0 , 7.0 };
426 Float_t wAra[4] = { 3.0 , 1.0 , 1.0 , 1.0 };
427 Float_t dAra = 0.032;
428 AliMixture(61,"Aramide", aAra, zAra, dAra, -4,wAra );
429 // GFK for Wacosit (Epoxy + Si)
430 Float_t aGFK[4] = { 1.0079, 12.011 , 15.9994, 28.086 };
431 Float_t zGFK[4] = { 1.0 , 6.0 , 8.0 , 14.0 };
432 Float_t wGFK[4] = { 0.0445, 0.5031, 0.1118, 0.340 };
434 AliMixture(62,"GFK", aGFK, zGFK, dGFK, 4,wGFK );
436 //////////////////////////////////////////////////////////////////////////
437 // Tracking Media Parameters
438 //////////////////////////////////////////////////////////////////////////
440 // General tracking parameter
441 Float_t tmaxfd = -10.0;
442 Float_t stemax = -1.0e10;
443 Float_t deemax = -0.1;
444 Float_t epsil = 1.0e-4;
445 Float_t stmin = -0.001;
448 AliMedium( 1,"Al Frame" , 1,0,isxfld,sxmgmx
449 ,tmaxfd,stemax,deemax,epsil,stmin);
451 AliMedium( 2,"Air" ,51,0,isxfld,sxmgmx
452 ,tmaxfd,stemax,deemax,epsil,stmin);
454 AliMedium( 3,"Wires" , 2,0,isxfld,sxmgmx
455 ,tmaxfd,stemax,deemax,epsil,stmin);
456 // All other ROB materials (caps, etc.)
457 AliMedium( 4,"ROB Other" , 2,0,isxfld,sxmgmx
458 ,tmaxfd,stemax,deemax,epsil,stmin);
460 AliMedium( 5,"Padplane" , 2,1,isxfld,sxmgmx
461 ,tmaxfd,stemax,deemax,epsil,stmin);
463 AliMedium( 6,"Readout" , 2,0,isxfld,sxmgmx
464 ,tmaxfd,stemax,deemax,epsil,stmin);
466 AliMedium( 7,"Wacosit" ,62,0,isxfld,sxmgmx
467 ,tmaxfd,stemax,deemax,epsil,stmin);
468 // INOX of cooling bus bars
469 AliMedium( 8,"Cooling bus", 7,0,isxfld,sxmgmx
470 ,tmaxfd,stemax,deemax,epsil,stmin);
471 // Gas-mixture (Xe/CO2)
472 AliMedium( 9,"Gas-mix" ,53,1,isxfld,sxmgmx
473 ,tmaxfd,stemax,deemax,epsil,stmin);
475 AliMedium(10,"Honeycomb" ,61,0,isxfld,sxmgmx
476 ,tmaxfd,stemax,deemax,epsil,stmin);
478 AliMedium(11,"Glue" ,58,0,isxfld,sxmgmx
479 ,tmaxfd,stemax,deemax,epsil,stmin);
481 AliMedium(13,"G10-plates" ,54,0,isxfld,sxmgmx
482 ,tmaxfd,stemax,deemax,epsil,stmin);
484 AliMedium(14,"Water" ,55,0,isxfld,sxmgmx
485 ,tmaxfd,stemax,deemax,epsil,stmin);
486 // Rohacell for the radiator
487 AliMedium(15,"Rohacell" ,56,0,isxfld,sxmgmx
488 ,tmaxfd,stemax,deemax,epsil,stmin);
490 AliMedium(16,"MCM-Al" , 1,0,isxfld,sxmgmx
491 ,tmaxfd,stemax,deemax,epsil,stmin);
493 AliMedium(17,"MCM-Sn" , 5,0,isxfld,sxmgmx
494 ,tmaxfd,stemax,deemax,epsil,stmin);
496 AliMedium(18,"MCM-Cu" , 2,0,isxfld,sxmgmx
497 ,tmaxfd,stemax,deemax,epsil,stmin);
499 AliMedium(19,"MCM-G10" ,54,0,isxfld,sxmgmx
500 ,tmaxfd,stemax,deemax,epsil,stmin);
501 // Si in readout chips
502 AliMedium(20,"Chip-Si" , 6,0,isxfld,sxmgmx
503 ,tmaxfd,stemax,deemax,epsil,stmin);
504 // Epoxy in readout chips
505 AliMedium(21,"Chip-Ep" ,57,0,isxfld,sxmgmx
506 ,tmaxfd,stemax,deemax,epsil,stmin);
508 AliMedium(22,"Conn-PE" ,52,0,isxfld,sxmgmx
509 ,tmaxfd,stemax,deemax,epsil,stmin);
511 AliMedium(23,"Chip-Cu" , 2,0,isxfld,sxmgmx
512 ,tmaxfd,stemax,deemax,epsil,stmin);
513 // Al of cooling pipes
514 AliMedium(24,"Cooling" , 1,0,isxfld,sxmgmx
515 ,tmaxfd,stemax,deemax,epsil,stmin);
517 AliMedium(25,"Serv-Cu" , 2,0,isxfld,sxmgmx
518 ,tmaxfd,stemax,deemax,epsil,stmin);
520 AliMedium(26,"Carbon" , 4,0,isxfld,sxmgmx
521 ,tmaxfd,stemax,deemax,epsil,stmin);
523 AliMedium(27,"Mylar" ,59,0,isxfld,sxmgmx
524 ,tmaxfd,stemax,deemax,epsil,stmin);
525 // Polypropylene fibers
526 AliMedium(28,"Fiber" ,60,0,isxfld,sxmgmx
527 ,tmaxfd,stemax,deemax,epsil,stmin);
529 // Save the density values for the TRD absorbtion
532 if (AliTRDCommonParam::Instance()->IsXenon()) {
534 fGasNobleFraction = fxc;
536 else if (AliTRDCommonParam::Instance()->IsArgon()) {
538 fGasNobleFraction = fac;
543 //_____________________________________________________________________________
547 // Initialize the TRD detector after the geometry has been created
550 AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++");
552 if (fGeometry->IsVersion() != 1) {
553 AliError("Not a valid geometry");
558 //_____________________________________________________________________________
559 void AliTRD::ResetDigits()
562 // Reset number of digits and the digits array for this detector
573 //_____________________________________________________________________________
574 void AliTRD::SetTreeAddress()
577 // Set the branch addresses for the trees.
580 if (fLoader->TreeH() &&
582 fHits = new TClonesArray("AliTRDhit",405);
584 AliDetector::SetTreeAddress();
588 //_____________________________________________________________________________
589 Bool_t AliTRD::Raw2SDigits(AliRawReader *rawReader)
592 // Converts RAW data to SDigits
595 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
597 AliError("Can not get TRD loader from Run Loader");
602 tree = loader->TreeS();
604 loader->MakeTree("S");
605 tree = loader->TreeS();
608 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
610 AliTRDrawData *rawdata = new AliTRDrawData();
611 AliTRDdigitsManager *digitsManager = rawdata->Raw2Digits(rawReader);
613 // Create the s-digits manager
614 AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
616 if (sdigitsManager) {
618 sdigitsManager->SetSDigits(kTRUE);
619 sdigitsManager->CreateArrays();
621 // Convert the digits into s-digits
622 digitizer.Digits2SDigits(digitsManager,sdigitsManager);
624 sdigitsManager->MakeBranch(tree);
625 sdigitsManager->WriteDigits();
627 delete digitsManager;
640 //_____________________________________________________________________________
641 AliLoader *AliTRD::MakeLoader(const Char_t *topfoldername)
644 // Create a loader for the TRD tracklets
647 fLoader = new AliLoader(GetName(),topfoldername);
649 AliInfo("Adding Tracklets-loader");
651 AliDataLoader *dl = new AliDataLoader("TRD.Tracklets.root"
654 fLoader->AddDataLoader(dl);
656 dl = new AliDataLoader("TRD.GtuTracks.root"
659 fLoader->AddDataLoader(dl);
665 //_____________________________________________________________________________
666 AliTRD &AliTRD::operator=(const AliTRD &trd)
669 // Assignment operator
673 ((AliTRD &) trd).Copy(*this);