]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRD.cxx
Change for reprocessing 2010 data (Raphaelle)
[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 <TGeoGlobalMagField.h>
27 #include <TVirtualMC.h>
28 #include <TGeoManager.h>
29  
30 #include "AliMC.h"
31 #include "AliMagF.h"
32 #include "AliRun.h"
33 #include "AliLoader.h"
34
35 #include "AliTRD.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"
42
43 ClassImp(AliTRD)
44  
45 //_____________________________________________________________________________
46 AliTRD::AliTRD()
47   :AliDetector()
48   ,fGeometry(0)
49   ,fGasDensity(0)
50   ,fFoilDensity(0)
51   ,fGasNobleFraction(0)
52   ,fPrimaryIonisation(0)
53 {
54   //
55   // Default constructor
56   //
57  
58 }
59  
60 //_____________________________________________________________________________
61 AliTRD::AliTRD(const char *name, const char *title)
62   :AliDetector(name,title)
63   ,fGeometry(0)
64   ,fGasDensity(0)
65   ,fFoilDensity(0)
66   ,fGasNobleFraction(0)
67   ,fPrimaryIonisation(0)
68 {
69   //
70   // Standard constructor for the TRD
71   //
72
73   // Check that FRAME is there otherwise we have no place where to put TRD
74   AliModule *frame = gAlice->GetModule("FRAME");
75   if (!frame) {
76     AliError("TRD needs FRAME to be present\n");
77     exit(1);
78   } 
79
80   // Define the TRD geometry
81   if ((frame->IsVersion() == 0) ||
82       (frame->IsVersion() == 1)) {
83     fGeometry = new AliTRDgeometry();
84   }
85   else {
86     AliError("Could not find valid FRAME version\n");
87     exit(1);
88   }
89
90   // Allocate the hit array
91   fHits = new TClonesArray("AliTRDhit",405);
92   gAlice->GetMCApp()->AddHitList(fHits);
93
94 }
95
96 //_____________________________________________________________________________
97 AliTRD::~AliTRD()
98 {
99   //
100   // TRD destructor
101   //
102
103   if (fGeometry) {
104     delete fGeometry;
105     fGeometry = 0;
106   }
107
108   if (fHits) {
109     delete fHits;
110     fHits     = 0;
111   }
112
113 }
114
115 //_____________________________________________________________________________
116 void AliTRD::Hits2Digits()
117 {
118   //
119   // Create digits
120   //
121
122   AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
123   AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
124
125   // Initialization
126   digitizer.InitDetector();
127     
128   if (!fLoader->TreeH()) {
129     fLoader->LoadHits("read");
130   }
131   fLoader->LoadDigits("recreate");
132
133   AliRunLoader *runLoader = fLoader->GetRunLoader(); 
134
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();
140   }
141
142   fLoader->UnloadHits();
143   fLoader->UnloadDigits();
144
145 }
146
147 //_____________________________________________________________________________
148 void AliTRD::Hits2SDigits()
149 {
150   //
151   // Create summable digits
152   //
153
154   AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
155   // For the summable digits
156   digitizer.SetSDigits(kTRUE);
157   AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
158
159   // Initialization
160   digitizer.InitDetector();
161     
162   if (!fLoader->TreeH()) {
163     fLoader->LoadHits("read");
164   }
165   fLoader->LoadSDigits("recreate");
166
167   AliRunLoader *runLoader = fLoader->GetRunLoader(); 
168
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();
174   }
175
176   fLoader->UnloadHits();
177   fLoader->UnloadSDigits();
178   
179 }
180
181 //_____________________________________________________________________________
182 AliDigitizer *AliTRD::CreateDigitizer(AliDigitizationInput* digInput) const
183 {
184   //
185   // Creates a new digitizer object
186   //
187
188   return new AliTRDdigitizer(digInput);
189
190 }
191
192 //_____________________________________________________________________________
193 void AliTRD::SDigits2Digits()
194 {
195   //
196   // Create final digits from summable digits
197   //
198
199   // Create the TRD digitizer
200   AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");  
201   AliLog::SetClassDebugLevel("TRDdigitizer",AliDebugLevel());
202
203   // Set the parameter
204   digitizer.SetEvent(gAlice->GetEvNumber());
205
206   // Initialization
207   digitizer.InitDetector();
208
209   // Read the s-digits via digits manager
210   AliTRDdigitsManager sdigitsManager;
211  
212   AliLog::SetClassDebugLevel("TRDdigitisManager",AliDebugLevel());
213   sdigitsManager.SetSDigits(kTRUE);
214   sdigitsManager.CreateArrays();
215   
216   if (!fLoader->TreeS()) { 
217     if (fLoader->LoadSDigits("read")) {
218       return;
219     }
220   }
221   if (!fLoader->TreeS()) {
222     AliError(Form("Error while reading SDigits for event %d",gAlice->GetEvNumber()));
223     return;
224   }
225   
226   sdigitsManager.ReadDigits(fLoader->TreeS());
227
228   // Add the s-digits to the input list 
229   digitizer.AddSDigitsManager(&sdigitsManager);
230
231   // Convert the s-digits to normal digits
232   digitizer.SDigits2Digits();
233
234   // Store the digits
235   if (!fLoader->TreeD()) {
236     fLoader->MakeTree("D");
237   }
238   if (digitizer.MakeBranch(fLoader->TreeD())){
239     digitizer.WriteDigits();
240   }
241
242 }
243
244 //_____________________________________________________________________________
245 void AliTRD::Digits2Raw() 
246 {
247   //
248   // Convert digits of the current event to raw data
249   //
250
251   fLoader->LoadDigits();
252   TTree *digits = fLoader->TreeD();
253   if (!digits) {
254     AliError("No digits tree");
255     return;
256   }
257
258   AliTRDrawData rawWriter;
259   if (!rawWriter.Digits2Raw(digits)) {
260     AliError("The raw writer could not load the digits tree");
261   }
262
263   fLoader->UnloadDigits();
264
265 }
266
267 //_____________________________________________________________________________
268 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
269                   , Float_t time, Bool_t inDrift)
270 {
271   //
272   // Add a hit for the TRD
273   // 
274
275   TClonesArray &lhits = *fHits;
276   AliTRDhit *hit = new(lhits[fNhits++]) AliTRDhit(fIshunt
277                                                  ,track
278                                                  ,det
279                                                  ,hits
280                                                  ,q
281                                                  ,time);
282
283   if (inDrift) {
284     hit->SetDrift();
285   }
286   else {
287     hit->SetAmplification();
288   }
289
290   if (q < 0) {
291     hit->SetTRphoton();
292   }
293
294 }
295  
296 //_____________________________________________________________________________
297 void AliTRD::CreateGeometry()
298 {
299   //
300   // Creates the volumes for the TRD chambers
301   //
302
303   // Check that FRAME is there otherwise we have no place where to put the TRD
304   AliModule *frame = gAlice->GetModule("FRAME");
305   if (!frame) {
306     AliFatal("The TRD needs the FRAME to be defined first");
307   }
308
309   fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
310
311 }
312
313 //_____________________________________________________________________________
314 void AliTRD::CreateMaterials()
315 {
316   //
317   // Create the materials for the TRD
318   //
319
320   Int_t   isxfld = ((AliMagF *) TGeoGlobalMagField::Instance()->GetField())->Integ();
321   Float_t sxmgmx = ((AliMagF *) TGeoGlobalMagField::Instance()->GetField())->Max();
322   
323   //////////////////////////////////////////////////////////////////////////
324   //     Define Materials 
325   //////////////////////////////////////////////////////////////////////////
326
327   // Aluminum
328   AliMaterial( 1,"Al",  26.98, 13.0, 2.7,    8.9,  37.2);
329   // Copper
330   AliMaterial( 2,"Cu",  63.54, 29.0, 8.96,   1.43, 14.8);
331   // Carbon
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);
335   // Zinc
336   AliMaterial( 5,"Sn", 118.71, 50.0, 7.31,   1.21, 14.8);
337   // Silicon
338   AliMaterial( 6,"Si",  28.09, 14.0, 2.33,   9.36, 37.2);
339   // Iron
340   AliMaterial( 7,"Fe",  55.85, 26.0, 7.87,   1.76, 14.8);
341
342   // Air  
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    };
352   Float_t dpe       = 0.95;
353   AliMixture(52,"Polyethilene", ape,    zpe,    dpe,    -2, wpe   );
354   // Gas mixtures
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     }; 
359   Float_t fxc       = 0.85;
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     }; 
367   Float_t fac       = 0.82;
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);
372   }
373   else if (AliTRDCommonParam::Instance()->IsArgon()) {
374     AliInfo("Gas mixture: Ar C02 (80/20)");
375     AliMixture(53,"ArCO2",        aArCO2, zArCO2, dgmAr,  -3, wArCO2);
376   }
377   else {
378     AliFatal("Wrong gas mixture");
379     exit(1);
380   }
381   // G10
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  };
385   Float_t dG10      = 2.0;
386   AliMixture(54,"G10",          aG10,  zG10,  dG10,   4,wG10  );
387   // Water
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    };
391   Float_t dwa       = 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    };
397   Float_t drh       = 0.075;   
398   AliMixture(56,"Rohacell",     arh,   zrh,   drh,   -3,wrh   );
399   // Epoxy (C18H19O3)
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 );
411   // Mylar
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    };
415   Float_t dMy       = 1.39;
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    };
421   Float_t dpp       = 0.068;
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  };
433   Float_t dGFK      = 2.0;
434   AliMixture(62,"GFK",          aGFK,  zGFK,  dGFK,   4,wGFK  );
435
436   //////////////////////////////////////////////////////////////////////////
437   //     Tracking Media Parameters 
438   //////////////////////////////////////////////////////////////////////////
439
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;
446
447   // Al Frame 
448   AliMedium( 1,"Al Frame"   , 1,0,isxfld,sxmgmx
449               ,tmaxfd,stemax,deemax,epsil,stmin);
450   // Air 
451   AliMedium( 2,"Air"        ,51,0,isxfld,sxmgmx
452               ,tmaxfd,stemax,deemax,epsil,stmin);
453   // Wires
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);
459   // Cu pads 
460   AliMedium( 5,"Padplane"   , 2,1,isxfld,sxmgmx
461               ,tmaxfd,stemax,deemax,epsil,stmin);
462   // Fee + cables 
463   AliMedium( 6,"Readout"    , 2,0,isxfld,sxmgmx
464               ,tmaxfd,stemax,deemax,epsil,stmin);
465   // C frame (Wacosit) 
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);
474   // Honeycomb
475   AliMedium(10,"Honeycomb"  ,61,0,isxfld,sxmgmx
476               ,tmaxfd,stemax,deemax,epsil,stmin);
477   // Araldite glue
478   AliMedium(11,"Glue"       ,58,0,isxfld,sxmgmx
479               ,tmaxfd,stemax,deemax,epsil,stmin);
480   // G10-plates
481   AliMedium(13,"G10-plates" ,54,0,isxfld,sxmgmx
482               ,tmaxfd,stemax,deemax,epsil,stmin);
483   // Cooling water
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);
489   // Al layer in MCMs
490   AliMedium(16,"MCM-Al"     , 1,0,isxfld,sxmgmx
491               ,tmaxfd,stemax,deemax,epsil,stmin);
492   // Sn layer in MCMs
493   AliMedium(17,"MCM-Sn"     , 5,0,isxfld,sxmgmx
494               ,tmaxfd,stemax,deemax,epsil,stmin);
495   // Cu layer in MCMs
496   AliMedium(18,"MCM-Cu"     , 2,0,isxfld,sxmgmx
497               ,tmaxfd,stemax,deemax,epsil,stmin);
498   // G10 layer in MCMs
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);
507   // PE in connectors
508   AliMedium(22,"Conn-PE"    ,52,0,isxfld,sxmgmx
509               ,tmaxfd,stemax,deemax,epsil,stmin);
510   // Cu in connectors
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);
516   // Cu in services
517   AliMedium(25,"Serv-Cu"    , 2,0,isxfld,sxmgmx
518               ,tmaxfd,stemax,deemax,epsil,stmin);
519   // Carbon fiber mat
520   AliMedium(26,"Carbon"     , 4,0,isxfld,sxmgmx
521               ,tmaxfd,stemax,deemax,epsil,stmin);
522   // Mylar foil
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);
528
529   // Save the density values for the TRD absorbtion
530   Float_t dmy  = 1.39;
531   fFoilDensity = dmy;
532   if      (AliTRDCommonParam::Instance()->IsXenon()) {
533     fGasDensity       = dgmXe;
534     fGasNobleFraction = fxc;
535   }
536   else if (AliTRDCommonParam::Instance()->IsArgon()) {
537     fGasDensity       = dgmAr;
538     fGasNobleFraction = fac;
539   }
540
541 }
542  
543 //_____________________________________________________________________________
544 void AliTRD::Init()
545 {
546   //
547   // Initialize the TRD detector after the geometry has been created
548   //
549
550   AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++");
551
552   if (fGeometry->IsVersion() != 1) {
553     AliError("Not a valid geometry");
554   }
555
556 }
557
558 //_____________________________________________________________________________
559 void AliTRD::ResetDigits()
560 {
561   //
562   // Reset number of digits and the digits array for this detector
563   //
564
565   fNdigits = 0;
566
567   if (fDigits) {
568     fDigits->Clear();
569   }
570
571 }
572
573 //_____________________________________________________________________________
574 void AliTRD::SetTreeAddress()
575 {
576   //
577   // Set the branch addresses for the trees.
578   //
579
580   if (fLoader->TreeH() && 
581       (fHits == 0x0)) {
582     fHits = new TClonesArray("AliTRDhit",405);
583   }
584   AliDetector::SetTreeAddress();
585
586 }
587
588 //_____________________________________________________________________________
589 Bool_t AliTRD::Raw2SDigits(AliRawReader *rawReader)
590 {
591   //
592   // Converts RAW data to SDigits
593   //
594
595   AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
596   if (!loader) {
597     AliError("Can not get TRD loader from Run Loader");
598     return kFALSE;
599   }
600     
601   TTree *tree = 0;
602   tree = loader->TreeS();
603   if (!tree) {
604     loader->MakeTree("S");
605     tree = loader->TreeS();
606   }
607
608   AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");  
609
610   AliTRDrawData       *rawdata        = new AliTRDrawData();
611   AliTRDdigitsManager *digitsManager  = rawdata->Raw2Digits(rawReader);
612
613   // Create the s-digits manager
614   AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
615
616   if (sdigitsManager) {
617
618     sdigitsManager->SetSDigits(kTRUE);
619     sdigitsManager->CreateArrays();
620
621     // Convert the digits into s-digits
622     digitizer.Digits2SDigits(digitsManager,sdigitsManager);
623
624     sdigitsManager->MakeBranch(tree);
625     sdigitsManager->WriteDigits();
626
627     delete digitsManager;
628
629     return kTRUE;
630
631   } 
632   else {
633
634     return kFALSE;
635
636   }
637
638 }
639
640 //_____________________________________________________________________________
641 AliLoader *AliTRD::MakeLoader(const Char_t *topfoldername)
642 {
643   //
644   // Create a loader for the TRD tracklets
645   //
646
647  fLoader = new AliLoader(GetName(),topfoldername);
648
649  AliInfo("Adding Tracklets-loader");
650
651  AliDataLoader *dl = new AliDataLoader("TRD.Tracklets.root"
652                                       ,"tracklets"
653                                       ,"tracklets");
654  fLoader->AddDataLoader(dl);
655
656                 dl = new AliDataLoader("TRD.GtuTracks.root"
657                                       ,"gtutracks"
658                                       ,"gtutracks");
659  fLoader->AddDataLoader(dl);
660
661  return fLoader;
662
663 }
664
665 //_____________________________________________________________________________
666 AliTRD &AliTRD::operator=(const AliTRD &trd)
667 {
668   //
669   // Assignment operator
670   //
671
672   if (this != &trd) {
673     ((AliTRD &) trd).Copy(*this);
674   }
675
676   return *this;
677
678 }