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 ///////////////////////////////////////////////////////////////////////////////
27 #include <Riostream.h>
29 #include <TClonesArray.h>
31 #include <TGeometry.h>
32 #include <TLorentzVector.h>
36 #include <TParticle.h>
39 #include <TVirtualMC.h>
43 #include "AliLoader.h"
48 #include "AliTrackReference.h"
49 #include "AliRawReader.h"
52 #include "AliTRDdigit.h"
53 #include "AliTRDdigitizer.h"
54 #include "AliTRDdigitsManager.h"
55 #include "AliTRDgeometry.h"
56 #include "AliTRDhit.h"
57 #include "AliTRDrawData.h"
58 #include "AliTRDSimParam.h"
59 #include "AliTRDCommonParam.h"
60 #include "AliTRDcalibDB.h"
64 //_____________________________________________________________________________
75 // Default constructor
80 //_____________________________________________________________________________
81 AliTRD::AliTRD(const char *name, const char *title)
82 :AliDetector(name,title)
91 // Standard constructor for the TRD
94 // Check that FRAME is there otherwise we have no place where to put TRD
95 AliModule *frame = gAlice->GetModule("FRAME");
97 AliError("TRD needs FRAME to be present\n");
101 // Define the TRD geometry
102 if ((frame->IsVersion() == 0) ||
103 (frame->IsVersion() == 1)) {
104 fGeometry = new AliTRDgeometry();
107 AliError("Could not find valid FRAME version\n");
111 // Allocate the hit array
112 fHits = new TClonesArray("AliTRDhit",405);
113 gAlice->GetMCApp()->AddHitList(fHits);
117 //_____________________________________________________________________________
136 //_____________________________________________________________________________
137 void AliTRD::Hits2Digits()
143 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
144 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
147 digitizer.InitDetector();
149 if (!fLoader->TreeH()) {
150 fLoader->LoadHits("read");
152 fLoader->LoadDigits("recreate");
154 AliRunLoader *runLoader = fLoader->GetRunLoader();
156 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
157 runLoader->GetEvent(iEvent);
158 digitizer.Open(runLoader,iEvent);
159 digitizer.MakeDigits();
160 digitizer.WriteDigits();
163 fLoader->UnloadHits();
164 fLoader->UnloadDigits();
168 //_____________________________________________________________________________
169 void AliTRD::Hits2SDigits()
172 // Create summable digits
175 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
176 // For the summable digits
177 digitizer.SetSDigits(kTRUE);
178 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
181 digitizer.InitDetector();
183 if (!fLoader->TreeH()) {
184 fLoader->LoadHits("read");
186 fLoader->LoadSDigits("recreate");
188 AliRunLoader *runLoader = fLoader->GetRunLoader();
190 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
191 runLoader->GetEvent(iEvent);
192 digitizer.Open(runLoader,iEvent);
193 digitizer.MakeDigits();
194 digitizer.WriteDigits();
197 fLoader->UnloadHits();
198 fLoader->UnloadSDigits();
202 //_____________________________________________________________________________
203 AliDigitizer *AliTRD::CreateDigitizer(AliRunDigitizer *manager) const
206 // Creates a new digitizer object
209 return new AliTRDdigitizer(manager);
213 //_____________________________________________________________________________
214 void AliTRD::SDigits2Digits()
217 // Create final digits from summable digits
220 // Create the TRD digitizer
221 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
222 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
225 digitizer.SetEvent(gAlice->GetEvNumber());
228 digitizer.InitDetector();
230 // Read the s-digits via digits manager
231 AliTRDdigitsManager sdigitsManager;
233 AliLog::SetClassDebugLevel("TRDdigitisManager",AliDebugLevel());
234 sdigitsManager.SetSDigits(kTRUE);
235 sdigitsManager.CreateArrays();
237 if (!fLoader->TreeS()) {
238 if (fLoader->LoadSDigits("read")) {
242 if (!fLoader->TreeS()) {
243 AliError(Form("Error while reading SDigits for event %d",gAlice->GetEvNumber()));
247 sdigitsManager.ReadDigits(fLoader->TreeS());
249 // Add the s-digits to the input list
250 digitizer.AddSDigitsManager(&sdigitsManager);
252 // Convert the s-digits to normal digits
253 digitizer.SDigits2Digits();
256 if (!fLoader->TreeD()) {
257 fLoader->MakeTree("D");
259 if (digitizer.MakeBranch(fLoader->TreeD())){
260 digitizer.WriteDigits();
265 //_____________________________________________________________________________
266 void AliTRD::Digits2Raw()
269 // Convert digits of the current event to raw data
272 fLoader->LoadDigits();
273 TTree *digits = fLoader->TreeD();
275 AliError("No digits tree");
279 AliTRDrawData rawWriter;
280 if (!rawWriter.Digits2Raw(digits)) {
281 AliError("The raw writer could not load the digits tree");
284 fLoader->UnloadDigits();
288 //_____________________________________________________________________________
289 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
290 , Float_t time, Bool_t inDrift)
293 // Add a hit for the TRD
296 TClonesArray &lhits = *fHits;
297 AliTRDhit *hit = new(lhits[fNhits++]) AliTRDhit(fIshunt
308 hit->SetAmplification();
317 //_____________________________________________________________________________
318 void AliTRD::CreateGeometry()
321 // Creates the volumes for the TRD chambers
324 // Check that FRAME is there otherwise we have no place where to put the TRD
325 AliModule *frame = gAlice->GetModule("FRAME");
327 AliFatal("The TRD needs the FRAME to be defined first");
330 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
334 //_____________________________________________________________________________
335 void AliTRD::CreateMaterials()
338 // Create the materials for the TRD
341 Int_t isxfld = gAlice->Field()->Integ();
342 Float_t sxmgmx = gAlice->Field()->Max();
344 // For polyethilene (CH2)
345 Float_t ape[2] = { 12.011 , 1.0079 };
346 Float_t zpe[2] = { 6.0 , 1.0 };
347 Float_t wpe[2] = { 1.0 , 2.0 };
351 Float_t aco[2] = { 12.011 , 15.9994 };
352 Float_t zco[2] = { 6.0 , 8.0 };
353 Float_t wco[2] = { 1.0 , 2.0 };
354 Float_t dco = 0.00186; // at 20C
357 Float_t awa[2] = { 1.0079, 15.9994 };
358 Float_t zwa[2] = { 1.0 , 8.0 };
359 Float_t wwa[2] = { 2.0 , 1.0 };
362 // For plexiglas (C5H8O2)
363 Float_t apg[3] = { 12.011 , 1.0079, 15.9994 };
364 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
365 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
368 // For epoxy (C18H19O3)
369 Float_t aEpoxy[3] = { 15.9994, 1.0079, 12.011 };
370 Float_t zEpoxy[3] = { 8.0 , 1.0 , 6.0 };
371 Float_t wEpoxy[3] = { 3.0 , 19.0 , 18.0 };
372 Float_t dEpoxy = 1.8 ;
374 // For Araldite, low density epoxy (C18H19O3)
375 Float_t aAral[3] = { 15.9994, 1.0079, 12.011 };
376 Float_t zAral[3] = { 8.0 , 1.0 , 6.0 };
377 Float_t wAral[3] = { 3.0 , 19.0 , 18.0 };
378 Float_t dAral = 1.05;
381 Float_t aAir[4] = { 12.011 , 14.0 , 15.9994 , 36.0 };
382 Float_t zAir[4] = { 6.0 , 7.0 , 8.0 , 18.0 };
383 Float_t wAir[4] = { 0.000124, 0.755267, 0.231781, 0.012827 };
384 Float_t dAir = 1.20479e-03;
387 Float_t aG10[4] = { 1.0079 , 12.011 , 15.9994 , 28.086 };
388 Float_t zG10[4] = { 1.0 , 6.0 , 8.0 , 14.0 };
389 Float_t wG10[4] = { 0.15201 , 0.10641 , 0.49444 , 0.24714 };
392 // For Xe/CO2-gas-mixture
393 Float_t aXeCO2[3] = { 131.29 , 12.0107 , 15.9994 };
394 Float_t zXeCO2[3] = { 54.0 , 6.0 , 8.0 };
395 Float_t wXeCO2[3] = { 8.5 , 1.5 , 3.0 };
396 // Xe-content of the Xe/CO2-mixture (85% / 15%)
398 Float_t dxe = 0.00549; // at 20C
399 Float_t dgmXe = fxc * dxe + (1.0 - fxc) * dco;
401 // For Ar/CO2-gas-mixture
402 Float_t aArCO2[3] = { 39.948 , 12.0107 , 15.9994 };
403 Float_t zArCO2[3] = { 18.0 , 6.0 , 8.0 };
404 Float_t wArCO2[3] = { 8.2 , 1.8 , 3.6 };
405 // Ar-content of the Ar/CO2-mixture (82% / 18%)
407 Float_t dar = 0.00166; // at 20C
408 Float_t dgmAr = fac * dar + (1.0 - fac) * dco;
410 // General tracking parameter
411 Float_t tmaxfd = -10.0;
412 Float_t stemax = -1.0e10;
413 Float_t deemax = -0.1;
414 Float_t epsil = 1.0e-4;
415 Float_t stmin = -0.001;
417 //////////////////////////////////////////////////////////////////////////
419 //////////////////////////////////////////////////////////////////////////
421 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
422 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1546.16, 0.0);
423 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
424 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
425 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
426 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
427 AliMaterial(18, "Fe" , 55.85, 26.0, 7.87 , 1.76, 14.8);
430 AliMixture(2, "Air" , aAir, zAir, dAir, 4, wAir );
431 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe );
432 AliMixture(8, "CO2", aco, zco, dco, -2, wco );
433 if (AliTRDSimParam::Instance()->IsXenon()) {
434 AliMixture(10,"XeCO2", aXeCO2, zXeCO2, dgmXe, -3, wXeCO2);
436 else if (AliTRDSimParam::Instance()->IsArgon()) {
437 AliInfo("Gas mixture: Ar C02 (80/20)");
438 AliMixture(10,"ArCO2", aArCO2, zArCO2, dgmAr, -3, wArCO2);
441 AliFatal("Wrong gas mixture");
444 AliMixture(12,"G10", aG10, zG10, dG10, 4, wG10 );
445 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa );
446 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg );
447 AliMixture(17,"Epoxy", aEpoxy, zEpoxy, dEpoxy, -3, wEpoxy);
448 AliMixture(19,"Araldite", aAral, zAral, dAral, -3, wAral );
450 //////////////////////////////////////////////////////////////////////////
451 // Tracking Media Parameters
452 //////////////////////////////////////////////////////////////////////////
455 AliMedium( 1,"Al Frame" , 1,0,isxfld,sxmgmx
456 ,tmaxfd,stemax,deemax,epsil,stmin);
458 AliMedium( 2,"Air" , 2,0,isxfld,sxmgmx
459 ,tmaxfd,stemax,deemax,epsil,stmin);
461 AliMedium( 3,"Wires" , 5,0,isxfld,sxmgmx
462 ,tmaxfd,stemax,deemax,epsil,stmin);
463 // All other ROB materials (caps, etc.)
464 AliMedium( 4,"ROB Other" , 5,0,isxfld,sxmgmx
465 ,tmaxfd,stemax,deemax,epsil,stmin);
467 AliMedium( 5,"Padplane" , 5,1,isxfld,sxmgmx
468 ,tmaxfd,stemax,deemax,epsil,stmin);
470 AliMedium( 6,"Readout" , 5,0,isxfld,sxmgmx
471 ,tmaxfd,stemax,deemax,epsil,stmin);
473 AliMedium( 7,"C Frame" , 6,0,isxfld,sxmgmx
474 ,tmaxfd,stemax,deemax,epsil,stmin);
475 // INOX of cooling bus bars
476 AliMedium( 8,"Cooling bus",18,0,isxfld,sxmgmx
477 ,tmaxfd,stemax,deemax,epsil,stmin);
478 // Gas-mixture (Xe/CO2)
479 AliMedium( 9,"Gas-mix" ,10,1,isxfld,sxmgmx
480 ,tmaxfd,stemax,deemax,epsil,stmin);
482 AliMedium(10,"Nomex" ,12,0,isxfld,sxmgmx
483 ,tmaxfd,stemax,deemax,epsil,stmin);
485 AliMedium(11,"Glue" ,19,0,isxfld,sxmgmx
486 ,tmaxfd,stemax,deemax,epsil,stmin);
488 AliMedium(13,"G10-plates" ,12,0,isxfld,sxmgmx
489 ,tmaxfd,stemax,deemax,epsil,stmin);
491 AliMedium(14,"Water" ,13,0,isxfld,sxmgmx
492 ,tmaxfd,stemax,deemax,epsil,stmin);
493 // Rohacell (plexiglas) for the radiator
494 AliMedium(15,"Rohacell" ,14,0,isxfld,sxmgmx
495 ,tmaxfd,stemax,deemax,epsil,stmin);
497 AliMedium(16,"MCM-Al" , 1,0,isxfld,sxmgmx
498 ,tmaxfd,stemax,deemax,epsil,stmin);
500 AliMedium(17,"MCM-Sn" ,15,0,isxfld,sxmgmx
501 ,tmaxfd,stemax,deemax,epsil,stmin);
503 AliMedium(18,"MCM-Cu" , 5,0,isxfld,sxmgmx
504 ,tmaxfd,stemax,deemax,epsil,stmin);
506 AliMedium(19,"MCM-G10" ,12,0,isxfld,sxmgmx
507 ,tmaxfd,stemax,deemax,epsil,stmin);
508 // Si in readout chips
509 AliMedium(20,"Chip-Si" ,16,0,isxfld,sxmgmx
510 ,tmaxfd,stemax,deemax,epsil,stmin);
511 // Epoxy in readout chips
512 AliMedium(21,"Chip-Ep" ,17,0,isxfld,sxmgmx
513 ,tmaxfd,stemax,deemax,epsil,stmin);
515 AliMedium(22,"Conn-PE" , 3,0,isxfld,sxmgmx
516 ,tmaxfd,stemax,deemax,epsil,stmin);
518 AliMedium(23,"Chip-Cu" , 5,0,isxfld,sxmgmx
519 ,tmaxfd,stemax,deemax,epsil,stmin);
520 // Al of cooling pipes
521 AliMedium(24,"Cooling" , 1,0,isxfld,sxmgmx
522 ,tmaxfd,stemax,deemax,epsil,stmin);
524 AliMedium(25,"Serv-Cu" , 5,0,isxfld,sxmgmx
525 ,tmaxfd,stemax,deemax,epsil,stmin);
527 // Save the density values for the TRD absorbtion
530 if (AliTRDSimParam::Instance()->IsXenon()) {
532 fGasNobleFraction = fxc;
534 else if (AliTRDSimParam::Instance()->IsArgon()) {
536 fGasNobleFraction = fac;
541 //_____________________________________________________________________________
542 void AliTRD::DrawModule() const
545 // Draw a shaded view of the Transition Radiation Detector version 0
548 // Set everything unseen
549 gMC->Gsatt("*" ,"SEEN",-1);
551 // Set ALIC mother transparent
552 gMC->Gsatt("ALIC","SEEN", 0);
554 // Set the volumes visible
555 if (fGeometry->IsVersion() == 0) {
556 gMC->Gsatt("B071","SEEN", 0);
557 gMC->Gsatt("B074","SEEN", 0);
558 gMC->Gsatt("B075","SEEN", 0);
559 gMC->Gsatt("B077","SEEN", 0);
560 gMC->Gsatt("BTR1","SEEN", 0);
561 gMC->Gsatt("BTR2","SEEN", 0);
562 gMC->Gsatt("BTR3","SEEN", 0);
563 gMC->Gsatt("UTR1","SEEN", 0);
564 gMC->Gsatt("UTR2","SEEN", 0);
565 gMC->Gsatt("UTR3","SEEN", 0);
568 gMC->Gsatt("B071","SEEN", 0);
569 gMC->Gsatt("B074","SEEN", 0);
570 gMC->Gsatt("B075","SEEN", 0);
571 gMC->Gsatt("B077","SEEN", 0);
572 gMC->Gsatt("BTR1","SEEN", 0);
573 gMC->Gsatt("BTR2","SEEN", 0);
574 gMC->Gsatt("BTR3","SEEN", 0);
575 gMC->Gsatt("UTR1","SEEN", 0);
578 gMC->Gdopt("hide", "on");
579 gMC->Gdopt("shad", "on");
580 gMC->Gsatt("*", "fill", 7);
581 gMC->SetClipBox(".");
582 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
584 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
585 gMC->Gdhead(1111, "Transition Radiation Detector");
586 gMC->Gdman(18, 4, "MAN");
590 //_____________________________________________________________________________
594 // Initialize the TRD detector after the geometry has been created
597 AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++");
599 if (fGeometry->IsVersion() != 1) {
600 AliError("Not a valid geometry");
603 // Special tracking options for charged particles for XeCO2
604 gMC->Gstpar((* fIdtmed)[9],"DRAY" , 1.0);
605 gMC->Gstpar((* fIdtmed)[9],"STRA" , 1.0);
606 gMC->Gstpar((* fIdtmed)[9],"LOSS" ,13.0); // Specific energy loss
607 gMC->Gstpar((* fIdtmed)[9],"PRIMIO_E",23.53); // 1st ionisation potential
608 gMC->Gstpar((* fIdtmed)[9],"PRIMIO_N",19.344431); // Number of primaries
612 //_____________________________________________________________________________
613 void AliTRD::ResetDigits()
616 // Reset number of digits and the digits array for this detector
627 //_____________________________________________________________________________
628 void AliTRD::SetTreeAddress()
631 // Set the branch addresses for the trees.
634 if (fLoader->TreeH() &&
636 fHits = new TClonesArray("AliTRDhit",405);
638 AliDetector::SetTreeAddress();
642 //_____________________________________________________________________________
643 Bool_t AliTRD::Raw2SDigits(AliRawReader *rawReader)
646 // Converts RAW data to SDigits
649 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
651 AliError("Can not get TRD loader from Run Loader");
656 tree = loader->TreeS();
658 loader->MakeTree("S");
659 tree = loader->TreeS();
662 AliTRDrawData *rawdata = new AliTRDrawData();
663 AliTRDdigitsManager *sdigitsManager = rawdata->Raw2Digits(rawReader);
664 if (sdigitsManager) {
665 sdigitsManager->SetSDigits(kTRUE);
666 sdigitsManager->MakeBranch(tree);
667 sdigitsManager->WriteDigits();
676 //_____________________________________________________________________________
677 AliLoader* AliTRD::MakeLoader(const char* topfoldername)
679 fLoader = new AliLoader(GetName(),topfoldername);
681 AliInfo("Adding Tracklets-loader");
682 AliDataLoader *dl = new AliDataLoader("TRD.Tracklets.root","tracklets", "tracklets");
683 fLoader->AddDataLoader(dl);
688 //_____________________________________________________________________________
689 AliTRD &AliTRD::operator=(const AliTRD &trd)
692 // Assignment operator
696 ((AliTRD &) trd).Copy(*this);