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 <TVirtualMC.h>
33 #include "AliTRDdigitizer.h"
34 #include "AliTRDdigitsManager.h"
35 #include "AliTRDgeometry.h"
36 #include "AliTRDhit.h"
37 #include "AliTRDrawData.h"
38 #include "AliTRDSimParam.h"
42 //_____________________________________________________________________________
51 // Default constructor
56 //_____________________________________________________________________________
57 AliTRD::AliTRD(const char *name, const char *title)
58 :AliDetector(name,title)
65 // Standard constructor for the TRD
68 // Check that FRAME is there otherwise we have no place where to put TRD
69 AliModule *frame = gAlice->GetModule("FRAME");
71 AliError("TRD needs FRAME to be present\n");
75 // Define the TRD geometry
76 if ((frame->IsVersion() == 0) ||
77 (frame->IsVersion() == 1)) {
78 fGeometry = new AliTRDgeometry();
81 AliError("Could not find valid FRAME version\n");
85 // Allocate the hit array
86 fHits = new TClonesArray("AliTRDhit",405);
87 gAlice->GetMCApp()->AddHitList(fHits);
91 //_____________________________________________________________________________
110 //_____________________________________________________________________________
111 void AliTRD::Hits2Digits()
117 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
118 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
121 digitizer.InitDetector();
123 if (!fLoader->TreeH()) {
124 fLoader->LoadHits("read");
126 fLoader->LoadDigits("recreate");
128 AliRunLoader *runLoader = fLoader->GetRunLoader();
130 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
131 runLoader->GetEvent(iEvent);
132 digitizer.Open(runLoader,iEvent);
133 digitizer.MakeDigits();
134 digitizer.WriteDigits();
137 fLoader->UnloadHits();
138 fLoader->UnloadDigits();
142 //_____________________________________________________________________________
143 void AliTRD::Hits2SDigits()
146 // Create summable digits
149 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
150 // For the summable digits
151 digitizer.SetSDigits(kTRUE);
152 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
155 digitizer.InitDetector();
157 if (!fLoader->TreeH()) {
158 fLoader->LoadHits("read");
160 fLoader->LoadSDigits("recreate");
162 AliRunLoader *runLoader = fLoader->GetRunLoader();
164 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
165 runLoader->GetEvent(iEvent);
166 digitizer.Open(runLoader,iEvent);
167 digitizer.MakeDigits();
168 digitizer.WriteDigits();
171 fLoader->UnloadHits();
172 fLoader->UnloadSDigits();
176 //_____________________________________________________________________________
177 AliDigitizer *AliTRD::CreateDigitizer(AliRunDigitizer *manager) const
180 // Creates a new digitizer object
183 return new AliTRDdigitizer(manager);
187 //_____________________________________________________________________________
188 void AliTRD::SDigits2Digits()
191 // Create final digits from summable digits
194 // Create the TRD digitizer
195 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
196 AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
199 digitizer.SetEvent(gAlice->GetEvNumber());
202 digitizer.InitDetector();
204 // Read the s-digits via digits manager
205 AliTRDdigitsManager sdigitsManager;
207 AliLog::SetClassDebugLevel("TRDdigitisManager",AliDebugLevel());
208 sdigitsManager.SetSDigits(kTRUE);
209 sdigitsManager.CreateArrays();
211 if (!fLoader->TreeS()) {
212 if (fLoader->LoadSDigits("read")) {
216 if (!fLoader->TreeS()) {
217 AliError(Form("Error while reading SDigits for event %d",gAlice->GetEvNumber()));
221 sdigitsManager.ReadDigits(fLoader->TreeS());
223 // Add the s-digits to the input list
224 digitizer.AddSDigitsManager(&sdigitsManager);
226 // Convert the s-digits to normal digits
227 digitizer.SDigits2Digits();
230 if (!fLoader->TreeD()) {
231 fLoader->MakeTree("D");
233 if (digitizer.MakeBranch(fLoader->TreeD())){
234 digitizer.WriteDigits();
239 //_____________________________________________________________________________
240 void AliTRD::Digits2Raw()
243 // Convert digits of the current event to raw data
246 fLoader->LoadDigits();
247 TTree *digits = fLoader->TreeD();
249 AliError("No digits tree");
253 AliTRDrawData rawWriter;
254 if (!rawWriter.Digits2Raw(digits)) {
255 AliError("The raw writer could not load the digits tree");
258 fLoader->UnloadDigits();
262 //_____________________________________________________________________________
263 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
264 , Float_t time, Bool_t inDrift)
267 // Add a hit for the TRD
270 TClonesArray &lhits = *fHits;
271 AliTRDhit *hit = new(lhits[fNhits++]) AliTRDhit(fIshunt
282 hit->SetAmplification();
291 //_____________________________________________________________________________
292 void AliTRD::CreateGeometry()
295 // Creates the volumes for the TRD chambers
298 // Check that FRAME is there otherwise we have no place where to put the TRD
299 AliModule *frame = gAlice->GetModule("FRAME");
301 AliFatal("The TRD needs the FRAME to be defined first");
304 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
308 //_____________________________________________________________________________
309 void AliTRD::CreateMaterials()
312 // Create the materials for the TRD
315 Int_t isxfld = gAlice->Field()->Integ();
316 Float_t sxmgmx = gAlice->Field()->Max();
318 // For polyethilene (CH2)
319 Float_t ape[2] = { 12.011 , 1.0079 };
320 Float_t zpe[2] = { 6.0 , 1.0 };
321 Float_t wpe[2] = { 1.0 , 2.0 };
325 Float_t aco[2] = { 12.011 , 15.9994 };
326 Float_t zco[2] = { 6.0 , 8.0 };
327 Float_t wco[2] = { 1.0 , 2.0 };
328 Float_t dco = 0.00186; // at 20C
331 Float_t awa[2] = { 1.0079, 15.9994 };
332 Float_t zwa[2] = { 1.0 , 8.0 };
333 Float_t wwa[2] = { 2.0 , 1.0 };
336 // For plexiglas (C5H8O2)
337 Float_t apg[3] = { 12.011 , 1.0079, 15.9994 };
338 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
339 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
342 // For epoxy (C18H19O3)
343 Float_t aEpoxy[3] = { 15.9994, 1.0079, 12.011 };
344 Float_t zEpoxy[3] = { 8.0 , 1.0 , 6.0 };
345 Float_t wEpoxy[3] = { 3.0 , 19.0 , 18.0 };
346 Float_t dEpoxy = 1.8 ;
348 // For Araldite, low density epoxy (C18H19O3)
349 Float_t aAral[3] = { 15.9994, 1.0079, 12.011 };
350 Float_t zAral[3] = { 8.0 , 1.0 , 6.0 };
351 Float_t wAral[3] = { 3.0 , 19.0 , 18.0 };
352 Float_t dAral = 1.05;
355 Float_t aAir[4] = { 12.011 , 14.0 , 15.9994 , 36.0 };
356 Float_t zAir[4] = { 6.0 , 7.0 , 8.0 , 18.0 };
357 Float_t wAir[4] = { 0.000124, 0.755267, 0.231781, 0.012827 };
358 Float_t dAir = 1.20479e-03;
361 Float_t aG10[4] = { 1.0079 , 12.011 , 15.9994 , 28.086 };
362 Float_t zG10[4] = { 1.0 , 6.0 , 8.0 , 14.0 };
363 Float_t wG10[4] = { 0.15201 , 0.10641 , 0.49444 , 0.24714 };
366 // For Xe/CO2-gas-mixture
367 Float_t aXeCO2[3] = { 131.29 , 12.0107 , 15.9994 };
368 Float_t zXeCO2[3] = { 54.0 , 6.0 , 8.0 };
369 Float_t wXeCO2[3] = { 8.5 , 1.5 , 3.0 };
370 // Xe-content of the Xe/CO2-mixture (85% / 15%)
372 Float_t dxe = 0.00549; // at 20C
373 Float_t dgmXe = fxc * dxe + (1.0 - fxc) * dco;
375 // For Ar/CO2-gas-mixture
376 Float_t aArCO2[3] = { 39.948 , 12.0107 , 15.9994 };
377 Float_t zArCO2[3] = { 18.0 , 6.0 , 8.0 };
378 Float_t wArCO2[3] = { 8.2 , 1.8 , 3.6 };
379 // Ar-content of the Ar/CO2-mixture (82% / 18%)
381 Float_t dar = 0.00166; // at 20C
382 Float_t dgmAr = fac * dar + (1.0 - fac) * dco;
384 // General tracking parameter
385 Float_t tmaxfd = -10.0;
386 Float_t stemax = -1.0e10;
387 Float_t deemax = -0.1;
388 Float_t epsil = 1.0e-4;
389 Float_t stmin = -0.001;
391 //////////////////////////////////////////////////////////////////////////
393 //////////////////////////////////////////////////////////////////////////
395 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
396 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1546.16, 0.0);
397 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
398 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
399 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
400 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
401 AliMaterial(18, "Fe" , 55.85, 26.0, 7.87 , 1.76, 14.8);
404 AliMixture(2, "Air" , aAir, zAir, dAir, 4, wAir );
405 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe );
406 AliMixture(8, "CO2", aco, zco, dco, -2, wco );
407 if (AliTRDSimParam::Instance()->IsXenon()) {
408 AliMixture(10,"XeCO2", aXeCO2, zXeCO2, dgmXe, -3, wXeCO2);
410 else if (AliTRDSimParam::Instance()->IsArgon()) {
411 AliInfo("Gas mixture: Ar C02 (80/20)");
412 AliMixture(10,"ArCO2", aArCO2, zArCO2, dgmAr, -3, wArCO2);
415 AliFatal("Wrong gas mixture");
418 AliMixture(12,"G10", aG10, zG10, dG10, 4, wG10 );
419 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa );
420 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg );
421 AliMixture(17,"Epoxy", aEpoxy, zEpoxy, dEpoxy, -3, wEpoxy);
422 AliMixture(19,"Araldite", aAral, zAral, dAral, -3, wAral );
424 //////////////////////////////////////////////////////////////////////////
425 // Tracking Media Parameters
426 //////////////////////////////////////////////////////////////////////////
429 AliMedium( 1,"Al Frame" , 1,0,isxfld,sxmgmx
430 ,tmaxfd,stemax,deemax,epsil,stmin);
432 AliMedium( 2,"Air" , 2,0,isxfld,sxmgmx
433 ,tmaxfd,stemax,deemax,epsil,stmin);
435 AliMedium( 3,"Wires" , 5,0,isxfld,sxmgmx
436 ,tmaxfd,stemax,deemax,epsil,stmin);
437 // All other ROB materials (caps, etc.)
438 AliMedium( 4,"ROB Other" , 5,0,isxfld,sxmgmx
439 ,tmaxfd,stemax,deemax,epsil,stmin);
441 AliMedium( 5,"Padplane" , 5,1,isxfld,sxmgmx
442 ,tmaxfd,stemax,deemax,epsil,stmin);
444 AliMedium( 6,"Readout" , 5,0,isxfld,sxmgmx
445 ,tmaxfd,stemax,deemax,epsil,stmin);
447 AliMedium( 7,"C Frame" , 6,0,isxfld,sxmgmx
448 ,tmaxfd,stemax,deemax,epsil,stmin);
449 // INOX of cooling bus bars
450 AliMedium( 8,"Cooling bus",18,0,isxfld,sxmgmx
451 ,tmaxfd,stemax,deemax,epsil,stmin);
452 // Gas-mixture (Xe/CO2)
453 AliMedium( 9,"Gas-mix" ,10,1,isxfld,sxmgmx
454 ,tmaxfd,stemax,deemax,epsil,stmin);
456 AliMedium(10,"Nomex" ,12,0,isxfld,sxmgmx
457 ,tmaxfd,stemax,deemax,epsil,stmin);
459 AliMedium(11,"Glue" ,19,0,isxfld,sxmgmx
460 ,tmaxfd,stemax,deemax,epsil,stmin);
462 AliMedium(13,"G10-plates" ,12,0,isxfld,sxmgmx
463 ,tmaxfd,stemax,deemax,epsil,stmin);
465 AliMedium(14,"Water" ,13,0,isxfld,sxmgmx
466 ,tmaxfd,stemax,deemax,epsil,stmin);
467 // Rohacell (plexiglas) for the radiator
468 AliMedium(15,"Rohacell" ,14,0,isxfld,sxmgmx
469 ,tmaxfd,stemax,deemax,epsil,stmin);
471 AliMedium(16,"MCM-Al" , 1,0,isxfld,sxmgmx
472 ,tmaxfd,stemax,deemax,epsil,stmin);
474 AliMedium(17,"MCM-Sn" ,15,0,isxfld,sxmgmx
475 ,tmaxfd,stemax,deemax,epsil,stmin);
477 AliMedium(18,"MCM-Cu" , 5,0,isxfld,sxmgmx
478 ,tmaxfd,stemax,deemax,epsil,stmin);
480 AliMedium(19,"MCM-G10" ,12,0,isxfld,sxmgmx
481 ,tmaxfd,stemax,deemax,epsil,stmin);
482 // Si in readout chips
483 AliMedium(20,"Chip-Si" ,16,0,isxfld,sxmgmx
484 ,tmaxfd,stemax,deemax,epsil,stmin);
485 // Epoxy in readout chips
486 AliMedium(21,"Chip-Ep" ,17,0,isxfld,sxmgmx
487 ,tmaxfd,stemax,deemax,epsil,stmin);
489 AliMedium(22,"Conn-PE" , 3,0,isxfld,sxmgmx
490 ,tmaxfd,stemax,deemax,epsil,stmin);
492 AliMedium(23,"Chip-Cu" , 5,0,isxfld,sxmgmx
493 ,tmaxfd,stemax,deemax,epsil,stmin);
494 // Al of cooling pipes
495 AliMedium(24,"Cooling" , 1,0,isxfld,sxmgmx
496 ,tmaxfd,stemax,deemax,epsil,stmin);
498 AliMedium(25,"Serv-Cu" , 5,0,isxfld,sxmgmx
499 ,tmaxfd,stemax,deemax,epsil,stmin);
501 // Save the density values for the TRD absorbtion
504 if (AliTRDSimParam::Instance()->IsXenon()) {
506 fGasNobleFraction = fxc;
508 else if (AliTRDSimParam::Instance()->IsArgon()) {
510 fGasNobleFraction = fac;
515 //_____________________________________________________________________________
519 // Initialize the TRD detector after the geometry has been created
522 AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++");
524 if (fGeometry->IsVersion() != 1) {
525 AliError("Not a valid geometry");
528 // Special tracking options for charged particles for XeCO2
529 gMC->Gstpar((* fIdtmed)[9],"DRAY" , 1.0);
530 gMC->Gstpar((* fIdtmed)[9],"STRA" , 1.0);
531 gMC->Gstpar((* fIdtmed)[9],"LOSS" ,13.0); // Specific energy loss
532 gMC->Gstpar((* fIdtmed)[9],"PRIMIO_E",23.53); // 1st ionisation potential
533 gMC->Gstpar((* fIdtmed)[9],"PRIMIO_N",19.344431); // Number of primaries
537 //_____________________________________________________________________________
538 void AliTRD::ResetDigits()
541 // Reset number of digits and the digits array for this detector
552 //_____________________________________________________________________________
553 void AliTRD::SetTreeAddress()
556 // Set the branch addresses for the trees.
559 if (fLoader->TreeH() &&
561 fHits = new TClonesArray("AliTRDhit",405);
563 AliDetector::SetTreeAddress();
567 //_____________________________________________________________________________
568 Bool_t AliTRD::Raw2SDigits(AliRawReader *rawReader)
571 // Converts RAW data to SDigits
574 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
576 AliError("Can not get TRD loader from Run Loader");
581 tree = loader->TreeS();
583 loader->MakeTree("S");
584 tree = loader->TreeS();
587 AliTRDrawData *rawdata = new AliTRDrawData();
588 AliTRDdigitsManager *sdigitsManager = rawdata->Raw2Digits(rawReader);
589 if (sdigitsManager) {
590 sdigitsManager->SetSDigits(kTRUE);
591 sdigitsManager->MakeBranch(tree);
592 sdigitsManager->WriteDigits();
601 //_____________________________________________________________________________
602 AliLoader* AliTRD::MakeLoader(const char* topfoldername)
604 fLoader = new AliLoader(GetName(),topfoldername);
606 AliInfo("Adding Tracklets-loader");
607 AliDataLoader *dl = new AliDataLoader("TRD.Tracklets.root","tracklets", "tracklets");
608 fLoader->AddDataLoader(dl);
613 //_____________________________________________________________________________
614 AliTRD &AliTRD::operator=(const AliTRD &trd)
617 // Assignment operator
621 ((AliTRD &) trd).Copy(*this);