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>
34 #include "AliTRDdigitizer.h"
35 #include "AliTRDdigitsManager.h"
36 #include "AliTRDgeometry.h"
37 #include "AliTRDhit.h"
38 #include "AliTRDrawData.h"
39 #include "AliTRDCommonParam.h"
43 //_____________________________________________________________________________
52 // Default constructor
57 //_____________________________________________________________________________
58 AliTRD::AliTRD(const char *name, const char *title)
59 :AliDetector(name,title)
66 // Standard constructor for the TRD
69 // Check that FRAME is there otherwise we have no place where to put TRD
70 AliModule *frame = gAlice->GetModule("FRAME");
72 AliError("TRD needs FRAME to be present\n");
76 // Define the TRD geometry
77 if ((frame->IsVersion() == 0) ||
78 (frame->IsVersion() == 1)) {
79 fGeometry = new AliTRDgeometry();
82 AliError("Could not find valid FRAME version\n");
86 // Allocate the hit array
87 fHits = new TClonesArray("AliTRDhit",405);
88 gAlice->GetMCApp()->AddHitList(fHits);
92 //_____________________________________________________________________________
111 //_____________________________________________________________________________
112 void AliTRD::Hits2Digits()
118 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
119 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
122 digitizer.InitDetector();
124 if (!fLoader->TreeH()) {
125 fLoader->LoadHits("read");
127 fLoader->LoadDigits("recreate");
129 AliRunLoader *runLoader = fLoader->GetRunLoader();
131 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
132 runLoader->GetEvent(iEvent);
133 digitizer.Open(runLoader,iEvent);
134 digitizer.MakeDigits();
135 digitizer.WriteDigits();
138 fLoader->UnloadHits();
139 fLoader->UnloadDigits();
143 //_____________________________________________________________________________
144 void AliTRD::Hits2SDigits()
147 // Create summable digits
150 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
151 // For the summable digits
152 digitizer.SetSDigits(kTRUE);
153 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
156 digitizer.InitDetector();
158 if (!fLoader->TreeH()) {
159 fLoader->LoadHits("read");
161 fLoader->LoadSDigits("recreate");
163 AliRunLoader *runLoader = fLoader->GetRunLoader();
165 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
166 runLoader->GetEvent(iEvent);
167 digitizer.Open(runLoader,iEvent);
168 digitizer.MakeDigits();
169 digitizer.WriteDigits();
172 fLoader->UnloadHits();
173 fLoader->UnloadSDigits();
177 //_____________________________________________________________________________
178 AliDigitizer *AliTRD::CreateDigitizer(AliRunDigitizer *manager) const
181 // Creates a new digitizer object
184 return new AliTRDdigitizer(manager);
188 //_____________________________________________________________________________
189 void AliTRD::SDigits2Digits()
192 // Create final digits from summable digits
195 // Create the TRD digitizer
196 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
197 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
200 digitizer.SetEvent(gAlice->GetEvNumber());
203 digitizer.InitDetector();
205 // Read the s-digits via digits manager
206 AliTRDdigitsManager sdigitsManager;
208 AliLog::SetClassDebugLevel("TRDdigitisManager",AliDebugLevel());
209 sdigitsManager.SetSDigits(kTRUE);
210 sdigitsManager.CreateArrays();
212 if (!fLoader->TreeS()) {
213 if (fLoader->LoadSDigits("read")) {
217 if (!fLoader->TreeS()) {
218 AliError(Form("Error while reading SDigits for event %d",gAlice->GetEvNumber()));
222 sdigitsManager.ReadDigits(fLoader->TreeS());
224 // Add the s-digits to the input list
225 digitizer.AddSDigitsManager(&sdigitsManager);
227 // Convert the s-digits to normal digits
228 digitizer.SDigits2Digits();
231 if (!fLoader->TreeD()) {
232 fLoader->MakeTree("D");
234 if (digitizer.MakeBranch(fLoader->TreeD())){
235 digitizer.WriteDigits();
240 //_____________________________________________________________________________
241 void AliTRD::Digits2Raw()
244 // Convert digits of the current event to raw data
247 fLoader->LoadDigits();
248 TTree *digits = fLoader->TreeD();
250 AliError("No digits tree");
254 AliTRDrawData rawWriter;
255 if (!rawWriter.Digits2Raw(digits)) {
256 AliError("The raw writer could not load the digits tree");
259 fLoader->UnloadDigits();
263 //_____________________________________________________________________________
264 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
265 , Float_t time, Bool_t inDrift)
268 // Add a hit for the TRD
271 TClonesArray &lhits = *fHits;
272 AliTRDhit *hit = new(lhits[fNhits++]) AliTRDhit(fIshunt
283 hit->SetAmplification();
292 //_____________________________________________________________________________
293 void AliTRD::CreateGeometry()
296 // Creates the volumes for the TRD chambers
299 // Check that FRAME is there otherwise we have no place where to put the TRD
300 AliModule *frame = gAlice->GetModule("FRAME");
302 AliFatal("The TRD needs the FRAME to be defined first");
305 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
309 //_____________________________________________________________________________
310 void AliTRD::CreateMaterials()
313 // Create the materials for the TRD
316 Int_t isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
317 Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
319 // For polyethilene (CH2)
320 Float_t ape[2] = { 12.011 , 1.0079 };
321 Float_t zpe[2] = { 6.0 , 1.0 };
322 Float_t wpe[2] = { 1.0 , 2.0 };
326 Float_t aco[2] = { 12.011 , 15.9994 };
327 Float_t zco[2] = { 6.0 , 8.0 };
328 Float_t wco[2] = { 1.0 , 2.0 };
329 Float_t dco = 0.00186; // at 20C
332 Float_t awa[2] = { 1.0079, 15.9994 };
333 Float_t zwa[2] = { 1.0 , 8.0 };
334 Float_t wwa[2] = { 2.0 , 1.0 };
337 // For plexiglas (C5H8O2)
338 Float_t apg[3] = { 12.011 , 1.0079, 15.9994 };
339 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
340 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
343 // For epoxy (C18H19O3)
344 Float_t aEpoxy[3] = { 15.9994, 1.0079, 12.011 };
345 Float_t zEpoxy[3] = { 8.0 , 1.0 , 6.0 };
346 Float_t wEpoxy[3] = { 3.0 , 19.0 , 18.0 };
347 Float_t dEpoxy = 1.8 ;
349 // For Araldite, low density epoxy (C18H19O3)
350 Float_t aAral[3] = { 15.9994, 1.0079, 12.011 };
351 Float_t zAral[3] = { 8.0 , 1.0 , 6.0 };
352 Float_t wAral[3] = { 3.0 , 19.0 , 18.0 };
353 Float_t dAral = 1.05;
356 Float_t aAir[4] = { 12.011 , 14.0 , 15.9994 , 36.0 };
357 Float_t zAir[4] = { 6.0 , 7.0 , 8.0 , 18.0 };
358 Float_t wAir[4] = { 0.000124, 0.755267, 0.231781, 0.012827 };
359 Float_t dAir = 1.20479e-03;
362 Float_t aG10[4] = { 1.0079 , 12.011 , 15.9994 , 28.086 };
363 Float_t zG10[4] = { 1.0 , 6.0 , 8.0 , 14.0 };
364 Float_t wG10[4] = { 0.15201 , 0.10641 , 0.49444 , 0.24714 };
367 // For Xe/CO2-gas-mixture
368 Float_t aXeCO2[3] = { 131.29 , 12.0107 , 15.9994 };
369 Float_t zXeCO2[3] = { 54.0 , 6.0 , 8.0 };
370 Float_t wXeCO2[3] = { 8.5 , 1.5 , 3.0 };
371 // Xe-content of the Xe/CO2-mixture (85% / 15%)
373 Float_t dxe = 0.00549; // at 20C
374 Float_t dgmXe = fxc * dxe + (1.0 - fxc) * dco;
376 // For Ar/CO2-gas-mixture
377 Float_t aArCO2[3] = { 39.948 , 12.0107 , 15.9994 };
378 Float_t zArCO2[3] = { 18.0 , 6.0 , 8.0 };
379 Float_t wArCO2[3] = { 8.2 , 1.8 , 3.6 };
380 // Ar-content of the Ar/CO2-mixture (82% / 18%)
382 Float_t dar = 0.00166; // at 20C
383 Float_t dgmAr = fac * dar + (1.0 - fac) * dco;
385 // General tracking parameter
386 Float_t tmaxfd = -10.0;
387 Float_t stemax = -1.0e10;
388 Float_t deemax = -0.1;
389 Float_t epsil = 1.0e-4;
390 Float_t stmin = -0.001;
392 //////////////////////////////////////////////////////////////////////////
394 //////////////////////////////////////////////////////////////////////////
396 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
397 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1546.16, 0.0);
398 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
399 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
400 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
401 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
402 AliMaterial(18, "Fe" , 55.85, 26.0, 7.87 , 1.76, 14.8);
405 AliMixture(2, "Air" , aAir, zAir, dAir, 4, wAir );
406 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe );
407 AliMixture(8, "CO2", aco, zco, dco, -2, wco );
408 if (AliTRDCommonParam::Instance()->IsXenon()) {
409 AliMixture(10,"XeCO2", aXeCO2, zXeCO2, dgmXe, -3, wXeCO2);
411 else if (AliTRDCommonParam::Instance()->IsArgon()) {
412 AliInfo("Gas mixture: Ar C02 (80/20)");
413 AliMixture(10,"ArCO2", aArCO2, zArCO2, dgmAr, -3, wArCO2);
416 AliFatal("Wrong gas mixture");
419 AliMixture(12,"G10", aG10, zG10, dG10, 4, wG10 );
420 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa );
421 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg );
422 AliMixture(17,"Epoxy", aEpoxy, zEpoxy, dEpoxy, -3, wEpoxy);
423 AliMixture(19,"Araldite", aAral, zAral, dAral, -3, wAral );
425 //////////////////////////////////////////////////////////////////////////
426 // Tracking Media Parameters
427 //////////////////////////////////////////////////////////////////////////
430 AliMedium( 1,"Al Frame" , 1,0,isxfld,sxmgmx
431 ,tmaxfd,stemax,deemax,epsil,stmin);
433 AliMedium( 2,"Air" , 2,0,isxfld,sxmgmx
434 ,tmaxfd,stemax,deemax,epsil,stmin);
436 AliMedium( 3,"Wires" , 5,0,isxfld,sxmgmx
437 ,tmaxfd,stemax,deemax,epsil,stmin);
438 // All other ROB materials (caps, etc.)
439 AliMedium( 4,"ROB Other" , 5,0,isxfld,sxmgmx
440 ,tmaxfd,stemax,deemax,epsil,stmin);
442 AliMedium( 5,"Padplane" , 5,1,isxfld,sxmgmx
443 ,tmaxfd,stemax,deemax,epsil,stmin);
445 AliMedium( 6,"Readout" , 5,0,isxfld,sxmgmx
446 ,tmaxfd,stemax,deemax,epsil,stmin);
448 AliMedium( 7,"C Frame" , 6,0,isxfld,sxmgmx
449 ,tmaxfd,stemax,deemax,epsil,stmin);
450 // INOX of cooling bus bars
451 AliMedium( 8,"Cooling bus",18,0,isxfld,sxmgmx
452 ,tmaxfd,stemax,deemax,epsil,stmin);
453 // Gas-mixture (Xe/CO2)
454 AliMedium( 9,"Gas-mix" ,10,1,isxfld,sxmgmx
455 ,tmaxfd,stemax,deemax,epsil,stmin);
457 AliMedium(10,"Nomex" ,12,0,isxfld,sxmgmx
458 ,tmaxfd,stemax,deemax,epsil,stmin);
460 AliMedium(11,"Glue" ,19,0,isxfld,sxmgmx
461 ,tmaxfd,stemax,deemax,epsil,stmin);
463 AliMedium(13,"G10-plates" ,12,0,isxfld,sxmgmx
464 ,tmaxfd,stemax,deemax,epsil,stmin);
466 AliMedium(14,"Water" ,13,0,isxfld,sxmgmx
467 ,tmaxfd,stemax,deemax,epsil,stmin);
468 // Rohacell (plexiglas) for the radiator
469 AliMedium(15,"Rohacell" ,14,0,isxfld,sxmgmx
470 ,tmaxfd,stemax,deemax,epsil,stmin);
472 AliMedium(16,"MCM-Al" , 1,0,isxfld,sxmgmx
473 ,tmaxfd,stemax,deemax,epsil,stmin);
475 AliMedium(17,"MCM-Sn" ,15,0,isxfld,sxmgmx
476 ,tmaxfd,stemax,deemax,epsil,stmin);
478 AliMedium(18,"MCM-Cu" , 5,0,isxfld,sxmgmx
479 ,tmaxfd,stemax,deemax,epsil,stmin);
481 AliMedium(19,"MCM-G10" ,12,0,isxfld,sxmgmx
482 ,tmaxfd,stemax,deemax,epsil,stmin);
483 // Si in readout chips
484 AliMedium(20,"Chip-Si" ,16,0,isxfld,sxmgmx
485 ,tmaxfd,stemax,deemax,epsil,stmin);
486 // Epoxy in readout chips
487 AliMedium(21,"Chip-Ep" ,17,0,isxfld,sxmgmx
488 ,tmaxfd,stemax,deemax,epsil,stmin);
490 AliMedium(22,"Conn-PE" , 3,0,isxfld,sxmgmx
491 ,tmaxfd,stemax,deemax,epsil,stmin);
493 AliMedium(23,"Chip-Cu" , 5,0,isxfld,sxmgmx
494 ,tmaxfd,stemax,deemax,epsil,stmin);
495 // Al of cooling pipes
496 AliMedium(24,"Cooling" , 1,0,isxfld,sxmgmx
497 ,tmaxfd,stemax,deemax,epsil,stmin);
499 AliMedium(25,"Serv-Cu" , 5,0,isxfld,sxmgmx
500 ,tmaxfd,stemax,deemax,epsil,stmin);
502 // Save the density values for the TRD absorbtion
505 if (AliTRDCommonParam::Instance()->IsXenon()) {
507 fGasNobleFraction = fxc;
509 else if (AliTRDCommonParam::Instance()->IsArgon()) {
511 fGasNobleFraction = fac;
516 //_____________________________________________________________________________
520 // Initialize the TRD detector after the geometry has been created
523 AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++");
525 if (fGeometry->IsVersion() != 1) {
526 AliError("Not a valid geometry");
529 // Special tracking options for charged particles for XeCO2
530 gMC->Gstpar((* fIdtmed)[9],"DRAY" , 1.0);
531 gMC->Gstpar((* fIdtmed)[9],"STRA" , 1.0);
532 gMC->Gstpar((* fIdtmed)[9],"LOSS" ,13.0); // Specific energy loss
533 // Parameters specific to Fluka
534 //gMC->Gstpar((* fIdtmed)[9],"PRIMIO_E",23.53); // 1st ionisation potential
535 //gMC->Gstpar((* fIdtmed)[9],"PRIMIO_N",19.344431); // Number of primaries
539 //_____________________________________________________________________________
540 void AliTRD::ResetDigits()
543 // Reset number of digits and the digits array for this detector
554 //_____________________________________________________________________________
555 void AliTRD::SetTreeAddress()
558 // Set the branch addresses for the trees.
561 if (fLoader->TreeH() &&
563 fHits = new TClonesArray("AliTRDhit",405);
565 AliDetector::SetTreeAddress();
569 //_____________________________________________________________________________
570 Bool_t AliTRD::Raw2SDigits(AliRawReader *rawReader)
573 // Converts RAW data to SDigits
576 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
578 AliError("Can not get TRD loader from Run Loader");
583 tree = loader->TreeS();
585 loader->MakeTree("S");
586 tree = loader->TreeS();
589 AliTRDrawData *rawdata = new AliTRDrawData();
590 AliTRDdigitsManager *sdigitsManager = rawdata->Raw2Digits(rawReader);
591 if (sdigitsManager) {
592 sdigitsManager->SetSDigits(kTRUE);
593 sdigitsManager->MakeBranch(tree);
594 sdigitsManager->WriteDigits();
603 //_____________________________________________________________________________
604 AliLoader* AliTRD::MakeLoader(const char* topfoldername)
606 fLoader = new AliLoader(GetName(),topfoldername);
608 AliInfo("Adding Tracklets-loader");
609 AliDataLoader *dl = new AliDataLoader("TRD.Tracklets.root","tracklets", "tracklets");
610 fLoader->AddDataLoader(dl);
611 dl = new AliDataLoader("TRD.GtuTracks.root", "gtutracks", "gtutracks");
612 fLoader->AddDataLoader(dl);
617 //_____________________________________________________________________________
618 AliTRD &AliTRD::operator=(const AliTRD &trd)
621 // Assignment operator
625 ((AliTRD &) trd).Copy(*this);