]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRD.cxx
Several changes:
[u/mrichter/AliRoot.git] / TRD / AliTRD.cxx
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
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  Transition Radiation Detector                                            //
21 //  This class contains the basic functions for the Transition Radiation     //
22 //  Detector.                                                                //
23 //                                                                           //
24 ///////////////////////////////////////////////////////////////////////////////
25
26 #include <stdlib.h>
27 #include <Riostream.h>
28
29 #include <TClonesArray.h>
30 #include <TFile.h>
31 #include <TGeometry.h>
32 #include <TLorentzVector.h>
33 #include <TMath.h>
34 #include <TNode.h>
35 #include <TPGON.h> 
36 #include <TParticle.h>
37 #include <TROOT.h>
38 #include <TTree.h>
39 #include <TVirtualMC.h>
40  
41 #include "AliConst.h"
42 #include "AliDigit.h"
43 #include "AliLoader.h"
44 #include "AliLog.h"
45 #include "AliMC.h"
46 #include "AliMagF.h"
47 #include "AliRun.h"
48 #include "AliTrackReference.h"
49 #include "AliRawReader.h"
50
51 #include "AliTRD.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"
61
62 ClassImp(AliTRD)
63  
64 //_____________________________________________________________________________
65 AliTRD::AliTRD()
66   :AliDetector()
67   ,fGeometry(0)
68   ,fGasDensity(0)
69   ,fFoilDensity(0)
70   ,fGasNobleFraction(0)
71   ,fDrawTR(0)
72   ,fDisplayType(0)
73 {
74   //
75   // Default constructor
76   //
77  
78 }
79  
80 //_____________________________________________________________________________
81 AliTRD::AliTRD(const char *name, const char *title)
82   :AliDetector(name,title)
83   ,fGeometry(0)
84   ,fGasDensity(0)
85   ,fFoilDensity(0)
86   ,fGasNobleFraction(0)
87   ,fDrawTR(0)
88   ,fDisplayType(0)
89 {
90   //
91   // Standard constructor for the TRD
92   //
93
94   // Check that FRAME is there otherwise we have no place where to put TRD
95   AliModule *frame = gAlice->GetModule("FRAME");
96   if (!frame) {
97     AliError("TRD needs FRAME to be present\n");
98     exit(1);
99   } 
100
101   // Define the TRD geometry
102   if ((frame->IsVersion() == 0) ||
103       (frame->IsVersion() == 1)) {
104     fGeometry = new AliTRDgeometry();
105   }
106   else {
107     AliError("Could not find valid FRAME version\n");
108     exit(1);
109   }
110
111   // Allocate the hit array
112   fHits = new TClonesArray("AliTRDhit",405);
113   gAlice->GetMCApp()->AddHitList(fHits);
114
115 }
116
117 //_____________________________________________________________________________
118 AliTRD::~AliTRD()
119 {
120   //
121   // TRD destructor
122   //
123
124   if (fGeometry) {
125     delete fGeometry;
126     fGeometry = 0;
127   }
128
129   if (fHits) {
130     delete fHits;
131     fHits     = 0;
132   }
133
134 }
135
136 //_____________________________________________________________________________
137 void AliTRD::Hits2Digits()
138 {
139   //
140   // Create digits
141   //
142
143   AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
144   AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
145
146   // Initialization
147   digitizer.InitDetector();
148     
149   if (!fLoader->TreeH()) {
150     fLoader->LoadHits("read");
151   }
152   fLoader->LoadDigits("recreate");
153
154   AliRunLoader *runLoader = fLoader->GetRunLoader(); 
155
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();
161   }
162
163   fLoader->UnloadHits();
164   fLoader->UnloadDigits();
165
166 }
167
168 //_____________________________________________________________________________
169 void AliTRD::Hits2SDigits()
170 {
171   //
172   // Create summable digits
173   //
174
175   AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
176   // For the summable digits
177   digitizer.SetSDigits(kTRUE);
178   AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
179
180   // Initialization
181   digitizer.InitDetector();
182     
183   if (!fLoader->TreeH()) {
184     fLoader->LoadHits("read");
185   }
186   fLoader->LoadSDigits("recreate");
187
188   AliRunLoader *runLoader = fLoader->GetRunLoader(); 
189
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();
195   }
196
197   fLoader->UnloadHits();
198   fLoader->UnloadSDigits();
199   
200 }
201
202 //_____________________________________________________________________________
203 AliDigitizer *AliTRD::CreateDigitizer(AliRunDigitizer *manager) const
204 {
205   //
206   // Creates a new digitizer object
207   //
208
209   return new AliTRDdigitizer(manager);
210
211 }
212
213 //_____________________________________________________________________________
214 void AliTRD::SDigits2Digits()
215 {
216   //
217   // Create final digits from summable digits
218   //
219
220   // Create the TRD digitizer
221   AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");  
222   AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
223
224   // Set the parameter
225   digitizer.SetEvent(gAlice->GetEvNumber());
226
227   // Initialization
228   digitizer.InitDetector();
229
230   // Read the s-digits via digits manager
231   AliTRDdigitsManager sdigitsManager;
232  
233   AliLog::SetClassDebugLevel("TRDdigitisManager",AliDebugLevel());
234   sdigitsManager.SetSDigits(kTRUE);
235   sdigitsManager.CreateArrays();
236   
237   if (!fLoader->TreeS()) { 
238     if (fLoader->LoadSDigits("read")) {
239       return;
240     }
241   }
242   if (!fLoader->TreeS()) {
243     AliError(Form("Error while reading SDigits for event %d",gAlice->GetEvNumber()));
244     return;
245   }
246   
247   sdigitsManager.ReadDigits(fLoader->TreeS());
248
249   // Add the s-digits to the input list 
250   digitizer.AddSDigitsManager(&sdigitsManager);
251
252   // Convert the s-digits to normal digits
253   digitizer.SDigits2Digits();
254
255   // Store the digits
256   if (!fLoader->TreeD()) {
257     fLoader->MakeTree("D");
258   }
259   if (digitizer.MakeBranch(fLoader->TreeD())){
260     digitizer.WriteDigits();
261   }
262
263 }
264
265 //_____________________________________________________________________________
266 void AliTRD::Digits2Raw() 
267 {
268   //
269   // Convert digits of the current event to raw data
270   //
271
272   fLoader->LoadDigits();
273   TTree *digits = fLoader->TreeD();
274   if (!digits) {
275     AliError("No digits tree");
276     return;
277   }
278
279   AliTRDrawData rawWriter;
280   if (!rawWriter.Digits2Raw(digits)) {
281     AliError("The raw writer could not load the digits tree");
282   }
283
284   fLoader->UnloadDigits();
285
286 }
287
288 //_____________________________________________________________________________
289 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
290                   , Float_t time, Bool_t inDrift)
291 {
292   //
293   // Add a hit for the TRD
294   // 
295
296   TClonesArray &lhits = *fHits;
297   AliTRDhit *hit = new(lhits[fNhits++]) AliTRDhit(fIshunt
298                                                  ,track
299                                                  ,det
300                                                  ,hits
301                                                  ,q
302                                                  ,time);
303
304   if (inDrift) {
305     hit->SetDrift();
306   }
307   else {
308     hit->SetAmplification();
309   }
310
311   if (q < 0) {
312     hit->SetTRphoton();
313   }
314
315 }
316  
317 //_____________________________________________________________________________
318 void AliTRD::CreateGeometry()
319 {
320   //
321   // Creates the volumes for the TRD chambers
322   //
323
324   // Check that FRAME is there otherwise we have no place where to put the TRD
325   AliModule *frame = gAlice->GetModule("FRAME");
326   if (!frame) {
327     AliFatal("The TRD needs the FRAME to be defined first");
328   }
329
330   fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
331
332 }
333  
334 //_____________________________________________________________________________
335 void AliTRD::CreateMaterials()
336 {
337   //
338   // Create the materials for the TRD
339   //
340
341   Int_t   isxfld = gAlice->Field()->Integ();
342   Float_t sxmgmx = gAlice->Field()->Max();
343   
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    };
348   Float_t dpe       = 0.95;
349
350   // For CO2 
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
355
356   // For water
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    };
360   Float_t dwa       = 1.0;
361
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    };
366   Float_t dpg       = 1.18; 
367   
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 ; 
373
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; 
379
380   // For air  
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;
385
386   // For G10
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  };
390   Float_t dG10      = 1.7;
391
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%) 
397   Float_t fxc       = 0.85;
398   Float_t dxe       = 0.00549; // at 20C
399   Float_t dgmXe     = fxc * dxe + (1.0 - fxc) * dco;
400
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%) 
406   Float_t fac       = 0.82;
407   Float_t dar       = 0.00166; // at 20C
408   Float_t dgmAr     = fac * dar + (1.0 - fac) * dco;
409   
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;
416   
417   //////////////////////////////////////////////////////////////////////////
418   //     Define Materials 
419   //////////////////////////////////////////////////////////////////////////
420
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);
428
429   // Mixtures 
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);
435   }
436   else if (AliTRDSimParam::Instance()->IsArgon()) {
437     AliInfo("Gas mixture: Ar C02 (80/20)");
438     AliMixture(10,"ArCO2",        aArCO2, zArCO2, dgmAr,  -3, wArCO2);
439   }
440   else {
441     AliFatal("Wrong gas mixture");
442     exit(1);
443   }
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 );
449
450   //////////////////////////////////////////////////////////////////////////
451   //     Tracking Media Parameters 
452   //////////////////////////////////////////////////////////////////////////
453
454   // Al Frame 
455   AliMedium( 1,"Al Frame"   , 1,0,isxfld,sxmgmx
456               ,tmaxfd,stemax,deemax,epsil,stmin);
457   // Air 
458   AliMedium( 2,"Air"        , 2,0,isxfld,sxmgmx
459               ,tmaxfd,stemax,deemax,epsil,stmin);
460   // Wires
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);
466   // Cu pads 
467   AliMedium( 5,"Padplane"   , 5,1,isxfld,sxmgmx
468               ,tmaxfd,stemax,deemax,epsil,stmin);
469   // Fee + cables 
470   AliMedium( 6,"Readout"    , 5,0,isxfld,sxmgmx
471               ,tmaxfd,stemax,deemax,epsil,stmin);
472   // C frame 
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);
481   // Nomex-honeycomb
482   AliMedium(10,"Nomex"      ,12,0,isxfld,sxmgmx
483               ,tmaxfd,stemax,deemax,epsil,stmin);
484   // Araldite glue
485   AliMedium(11,"Glue"       ,19,0,isxfld,sxmgmx
486               ,tmaxfd,stemax,deemax,epsil,stmin);
487   // G10-plates
488   AliMedium(13,"G10-plates" ,12,0,isxfld,sxmgmx
489               ,tmaxfd,stemax,deemax,epsil,stmin);
490   // Cooling water
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);
496   // Al layer in MCMs
497   AliMedium(16,"MCM-Al"     , 1,0,isxfld,sxmgmx
498               ,tmaxfd,stemax,deemax,epsil,stmin);
499   // Sn layer in MCMs
500   AliMedium(17,"MCM-Sn"     ,15,0,isxfld,sxmgmx
501               ,tmaxfd,stemax,deemax,epsil,stmin);
502   // Cu layer in MCMs
503   AliMedium(18,"MCM-Cu"     , 5,0,isxfld,sxmgmx
504               ,tmaxfd,stemax,deemax,epsil,stmin);
505   // G10 layer in MCMs
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);
514   // PE in connectors
515   AliMedium(22,"Conn-PE"    , 3,0,isxfld,sxmgmx
516               ,tmaxfd,stemax,deemax,epsil,stmin);
517   // Cu in connectors
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);
523   // Cu in services
524   AliMedium(25,"Serv-Cu"    , 5,0,isxfld,sxmgmx
525               ,tmaxfd,stemax,deemax,epsil,stmin);
526
527   // Save the density values for the TRD absorbtion
528   Float_t dmy  = 1.39;
529   fFoilDensity = dmy;
530   if      (AliTRDSimParam::Instance()->IsXenon()) {
531     fGasDensity       = dgmXe;
532     fGasNobleFraction = fxc;
533   }
534   else if (AliTRDSimParam::Instance()->IsArgon()) {
535     fGasDensity       = dgmAr;
536     fGasNobleFraction = fac;
537   }
538
539 }
540
541 //_____________________________________________________________________________
542 void AliTRD::DrawModule() const
543 {
544   //
545   // Draw a shaded view of the Transition Radiation Detector version 0
546   //
547
548   // Set everything unseen
549   gMC->Gsatt("*"   ,"SEEN",-1);
550   
551   // Set ALIC mother transparent
552   gMC->Gsatt("ALIC","SEEN", 0);
553   
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);
566   }
567   else {
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);
576   }
577   
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);
583   gMC->DefaultRange();
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");
587
588 }
589  
590 //_____________________________________________________________________________
591 void AliTRD::Init()
592 {
593   //
594   // Initialize the TRD detector after the geometry has been created
595   //
596
597   AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++");
598
599   if (fGeometry->IsVersion() != 1) {
600     AliError("Not a valid geometry");
601   }
602
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
609
610 }
611
612 //_____________________________________________________________________________
613 void AliTRD::ResetDigits()
614 {
615   //
616   // Reset number of digits and the digits array for this detector
617   //
618
619   fNdigits = 0;
620
621   if (fDigits) {
622     fDigits->Clear();
623   }
624
625 }
626
627 //_____________________________________________________________________________
628 void AliTRD::SetTreeAddress()
629 {
630   //
631   // Set the branch addresses for the trees.
632   //
633
634   if (fLoader->TreeH() && 
635       (fHits == 0x0)) {
636     fHits = new TClonesArray("AliTRDhit",405);
637   }
638   AliDetector::SetTreeAddress();
639
640 }
641
642 //_____________________________________________________________________________
643 Bool_t AliTRD::Raw2SDigits(AliRawReader *rawReader)
644 {
645   //
646   // Converts RAW data to SDigits
647   //
648
649   AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
650   if (!loader) {
651     AliError("Can not get TRD loader from Run Loader");
652     return kFALSE;
653   }
654     
655   TTree *tree = 0;
656   tree = loader->TreeS();
657   if (!tree) {
658     loader->MakeTree("S");
659     tree = loader->TreeS();
660   }
661
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();
668     return kTRUE;
669   } 
670   else {
671     return kFALSE;
672   }
673
674 }
675
676 //_____________________________________________________________________________
677 AliLoader* AliTRD::MakeLoader(const char* topfoldername)
678 {
679  fLoader = new AliLoader(GetName(),topfoldername);
680
681  AliInfo("Adding Tracklets-loader");
682  AliDataLoader *dl = new AliDataLoader("TRD.Tracklets.root","tracklets", "tracklets");
683  fLoader->AddDataLoader(dl);
684
685  return fLoader;
686 }
687
688 //_____________________________________________________________________________
689 AliTRD &AliTRD::operator=(const AliTRD &trd)
690 {
691   //
692   // Assignment operator
693   //
694
695   if (this != &trd) {
696     ((AliTRD &) trd).Copy(*this);
697   }
698
699   return *this;
700
701 }