]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOS.cxx
Addition of electronic noise corrected
[u/mrichter/AliRoot.git] / PHOS / AliPHOS.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 /* $Id$ */
16
17 //_________________________________________________________________________
18 // Base Class for PHOS description:
19 //   PHOS consists of a PbWO4 calorimeter (EMCA) and a gazeous charged 
20 //    particles detector (CPV or PPSD).
21 //   The only provided method here is CreateMaterials, 
22 //    which defines the materials common to all PHOS versions.   
23 // 
24 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) 
25 //////////////////////////////////////////////////////////////////////////////
26
27
28 // --- ROOT system ---
29 class TFile;
30 #include <TFolder.h> 
31 #include <TTree.h>
32 #include <TVirtualMC.h> 
33 #include <TRandom.h> 
34
35 // --- Standard library ---
36
37 // --- AliRoot header files ---
38 #include "AliMagF.h"
39 #include "AliPHOS.h"
40 #include "AliPHOSGetter.h"
41 #include "AliRun.h"
42 #include "AliPHOSDigitizer.h"
43 #include "AliPHOSSDigitizer.h"
44 #include "AliPHOSDigit.h"
45 #include "AliAltroBuffer.h"
46
47 ClassImp(AliPHOS)
48 //____________________________________________________________________________
49 AliPHOS:: AliPHOS() : AliDetector()
50 {
51   // Default ctor
52   fName="PHOS";
53   fQATask = 0;
54   fTreeQA = 0;
55   fDebug  = 0; 
56   fRan    = new TRandom(123456) ; 
57 }
58
59 //____________________________________________________________________________
60 AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name, title) 
61 {
62   //   ctor : title is used to identify the layout
63   
64   fQATask = 0;
65   fTreeQA = 0;
66   fDebug  = 0; 
67   fRan    = new TRandom(123456) ; 
68 }
69
70 //____________________________________________________________________________
71 AliPHOS::~AliPHOS() 
72 {  
73   delete fRan ; 
74 }
75
76 //____________________________________________________________________________
77 void AliPHOS::Copy(AliPHOS & phos)
78 {
79   // copy method to be used byy the cpy ctor
80   TObject::Copy(phos) ; 
81   //  fQATask = AliPHOSQAChecker::Copy(*(phos.fQATask)) ; 
82   phos.fTreeQA = fTreeQA->CloneTree() ; 
83 }
84
85 //____________________________________________________________________________
86 AliDigitizer* AliPHOS::CreateDigitizer(AliRunDigitizer* manager) const
87 {
88   return new AliPHOSDigitizer(manager);
89 }
90
91 //____________________________________________________________________________
92 void AliPHOS::CreateMaterials()
93 {
94   // Definitions of materials to build PHOS and associated tracking media.
95   // media number in idtmed are 699 to 798.
96
97   // --- The PbWO4 crystals ---
98   Float_t aX[3] = {207.19, 183.85, 16.0} ;
99   Float_t zX[3] = {82.0, 74.0, 8.0} ;
100   Float_t wX[3] = {1.0, 1.0, 4.0} ;
101   Float_t dX = 8.28 ;
102
103   AliMixture(0, "PbWO4$", aX, zX, dX, -3, wX) ;
104
105
106   // --- The polysterene scintillator (CH) ---
107   Float_t aP[2] = {12.011, 1.00794} ;
108   Float_t zP[2] = {6.0, 1.0} ;
109   Float_t wP[2] = {1.0, 1.0} ;
110   Float_t dP = 1.032 ;
111
112   AliMixture(1, "Polystyrene$", aP, zP, dP, -2, wP) ;
113
114   // --- Aluminium ---
115   AliMaterial(2, "Al$", 26.98, 13., 2.7, 8.9, 999., 0, 0) ;
116   // ---         Absorption length is ignored ^
117
118  // --- Tyvek (CnH2n) ---
119   Float_t aT[2] = {12.011, 1.00794} ;
120   Float_t zT[2] = {6.0, 1.0} ;
121   Float_t wT[2] = {1.0, 2.0} ;
122   Float_t dT = 0.331 ;
123
124   AliMixture(3, "Tyvek$", aT, zT, dT, -2, wT) ;
125
126   // --- Polystyrene foam ---
127   Float_t aF[2] = {12.011, 1.00794} ;
128   Float_t zF[2] = {6.0, 1.0} ;
129   Float_t wF[2] = {1.0, 1.0} ;
130   Float_t dF = 0.12 ;
131
132   AliMixture(4, "Foam$", aF, zF, dF, -2, wF) ;
133
134  // --- Titanium ---
135   Float_t aTIT[3] = {47.88, 26.98, 54.94} ;
136   Float_t zTIT[3] = {22.0, 13.0, 25.0} ;
137   Float_t wTIT[3] = {69.0, 6.0, 1.0} ;
138   Float_t dTIT = 4.5 ;
139
140   AliMixture(5, "Titanium$", aTIT, zTIT, dTIT, -3, wTIT);
141
142  // --- Silicon ---
143   AliMaterial(6, "Si$", 28.0855, 14., 2.33, 9.36, 42.3, 0, 0) ;
144
145
146
147   // --- Foam thermo insulation ---
148   Float_t aTI[2] = {12.011, 1.00794} ;
149   Float_t zTI[2] = {6.0, 1.0} ;
150   Float_t wTI[2] = {1.0, 1.0} ;
151   Float_t dTI = 0.04 ;
152
153   AliMixture(7, "Thermo Insul.$", aTI, zTI, dTI, -2, wTI) ;
154
155   // --- Textolitn ---
156   Float_t aTX[4] = {16.0, 28.09, 12.011, 1.00794} ;
157   Float_t zTX[4] = {8.0, 14.0, 6.0, 1.0} ;
158   Float_t wTX[4] = {292.0, 68.0, 462.0, 736.0} ;
159   Float_t dTX    = 1.75 ;
160
161   AliMixture(8, "Textolit$", aTX, zTX, dTX, -4, wTX) ;
162
163   //--- FR4  ---
164   Float_t aFR[3] = {28.0855, 15.9994, 17.749} ; 
165   Float_t zFR[3] = {14., 8., 8.875} ; 
166   Float_t wFR[3] = {.28, .32, .4} ;
167   Float_t dFR = 1.8 ; 
168
169   AliMixture(9, "FR4$", aFR, zFR, dFR, -3, wFR) ;
170
171   // --- The Composite Material for  micromegas (so far polyetylene) ---                                       
172   Float_t aCM[2] = {12.01, 1.} ; 
173   Float_t zCM[2] = {6., 1.} ; 
174   Float_t wCM[2] = {1., 2.} ; 
175   Float_t dCM = 0.935 ; 
176
177   AliMixture(10, "Compo Mat$", aCM, zCM, dCM, -2, wCM) ;
178
179   // --- Copper ---                                                                    
180   AliMaterial(11, "Cu$", 63.546, 29, 8.96, 1.43, 14.8, 0, 0) ;
181  
182   // --- G10 : Printed Circuit material ---                                                  
183   Float_t aG10[4] = { 12., 1., 16., 28.} ;
184   Float_t zG10[4] = { 6., 1., 8., 14.} ;
185   Float_t wG10[4] = { .259, .288, .248, .205} ;
186   Float_t dG10  = 1.7 ;
187   
188   AliMixture(12, "G10$", aG10, zG10, dG10, -4, wG10);
189
190   // --- Lead ---                                                                     
191   AliMaterial(13, "Pb$", 207.2, 82, 11.35, 0.56, 0., 0, 0) ;
192
193  // --- The gas mixture ---                                                                
194  // Co2
195   Float_t aCO[2] = {12.0, 16.0} ; 
196   Float_t zCO[2] = {6.0, 8.0} ; 
197   Float_t wCO[2] = {1.0, 2.0} ; 
198   Float_t dCO = 0.001977 ; 
199
200   AliMixture(14, "CO2$", aCO, zCO, dCO, -2, wCO);
201
202  // Ar
203   Float_t dAr = 0.001782 ; 
204   AliMaterial(15, "Ar$", 39.948, 18.0, dAr, 14.0, 0., 0, 0) ;   
205  
206  // ArCo2
207   Char_t namate[21]="";
208   Float_t aGM[2] ; 
209   Float_t zGM[2] ; 
210   Float_t wGM[2] ; 
211   Float_t dGM ; 
212
213   Float_t absL, radL, density ;
214   Float_t buf[1] ;
215   Int_t nbuf ;
216
217   gMC->Gfmate((*fIdmate)[15], namate, aGM[0], zGM[0], density, radL, absL, buf, nbuf) ; // Get properties of Ar 
218   gMC->Gfmate((*fIdmate)[14], namate, aGM[1], zGM[1], density, radL, absL, buf, nbuf) ; // Get properties of CO2 
219
220
221   // Create gas mixture 
222
223   Float_t arContent    = 0.80 ;  // Ar-content of the Ar/CO2-mixture (80% / 20%) 
224  
225   wGM[0] = arContent;
226   wGM[1] = 1. - arContent ;
227   dGM    = wGM[0] * dAr + wGM[1] * dCO;
228
229   
230   AliMixture(16, "ArCO2$", aGM, zGM, dGM,  2, wGM) ;
231
232   // --- Stainless steel (let it be pure iron) ---
233   AliMaterial(17, "Steel$", 55.845, 26, 7.87, 1.76, 0., 0, 0) ;
234
235
236   // --- Fiberglass ---
237   Float_t aFG[4] = {16.0, 28.09, 12.011, 1.00794} ;
238   Float_t zFG[4] = {8.0, 14.0, 6.0, 1.0} ;
239   Float_t wFG[4] = {292.0, 68.0, 462.0, 736.0} ;
240   Float_t dFG    = 1.9 ;
241
242   AliMixture(18, "Fibergla$", aFG, zFG, dFG, -4, wFG) ;
243
244   // --- Cables in Air box  ---
245   // SERVICES
246
247   Float_t aCA[4] = { 1.,12.,55.8,63.5 };
248   Float_t zCA[4] = { 1.,6.,26.,29. }; 
249   Float_t wCA[4] = { .014,.086,.42,.48 };
250   Float_t dCA    = 0.8 ;  //this density is raw estimation, if you know better - correct
251
252   AliMixture(19, "Cables  $", aCA, zCA, dCA, -4, wCA) ;
253
254
255   // --- Air ---
256   Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
257   Float_t zAir[4]={6.,7.,8.,18.};
258   Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
259   Float_t dAir = 1.20479E-3;
260  
261   AliMixture(99, "Air$", aAir, zAir, dAir, 4, wAir) ;
262
263   // DEFINITION OF THE TRACKING MEDIA
264
265   // for PHOS: idtmed[699->798] equivalent to fIdtmed[0->100]
266   Int_t * idtmed = fIdtmed->GetArray() - 699 ; 
267   Int_t   isxfld = gAlice->Field()->Integ() ;
268   Float_t sxmgmx = gAlice->Field()->Max() ;
269
270   // The scintillator of the calorimeter made of PBW04                              -> idtmed[699]
271   AliMedium(0, "PHOS Xtal    $", 0, 1,
272             isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
273
274   // The scintillator of the CPV made of Polystyrene scintillator                   -> idtmed[700]
275   AliMedium(1, "CPV scint.   $", 1, 1,
276             isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
277
278   // Various Aluminium parts made of Al                                             -> idtmed[701]
279   AliMedium(2, "Al parts     $", 2, 0,
280              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ;
281
282   // The Tywek which wraps the calorimeter crystals                                 -> idtmed[702]
283   AliMedium(3, "Tyvek wrapper$", 3, 0,
284              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ;
285
286   // The Polystyrene foam around the calorimeter module                             -> idtmed[703]
287   AliMedium(4, "Polyst. foam $", 4, 0,
288              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
289
290   // The Titanium around the calorimeter crystal                                    -> idtmed[704]
291   AliMedium(5, "Titan. cover $", 5, 0,
292              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.0001, 0.0001, 0, 0) ;
293
294   // The Silicon of the pin diode to read out the calorimeter crystal               -> idtmed[705] 
295  AliMedium(6, "Si PIN       $", 6, 0,
296              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.01, 0.01, 0, 0) ;
297
298  // The thermo insulating material of the box which contains the calorimeter module -> idtmed[706]
299   AliMedium(7, "Thermo Insul.$", 7, 0,
300              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
301
302   // The Textolit which makes up the box which contains the calorimeter module      -> idtmed[707]
303   AliMedium(8, "Textolit     $", 8, 0,
304              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
305
306   // FR4: The Plastic which makes up the frame of micromegas                        -> idtmed[708]
307   AliMedium(9, "FR4 $", 9, 0,
308              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.0001, 0, 0) ; 
309
310
311   // The Composite Material for  micromegas                                         -> idtmed[709]
312   AliMedium(10, "CompoMat   $", 10, 0,
313              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
314
315   // Copper                                                                         -> idtmed[710]
316   AliMedium(11, "Copper     $", 11, 0,
317              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.0001, 0, 0) ;
318
319   // G10: Printed Circuit material                                                  -> idtmed[711]
320  
321   AliMedium(12, "G10        $", 12, 0,
322              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.01, 0, 0) ;
323
324   // The Lead                                                                       -> idtmed[712]
325  
326   AliMedium(13, "Lead      $", 13, 0,
327              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
328
329   // The gas mixture: ArCo2                                                         -> idtmed[715]
330  
331   AliMedium(16, "ArCo2      $", 16, 1,
332              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.01, 0, 0) ;
333  
334   // Stainless steel                                                                -> idtmed[716]
335   AliMedium(17, "Steel     $", 17, 0,
336              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.0001, 0, 0) ;
337
338   // Fibergalss                                                                     -> idtmed[717]
339   AliMedium(18, "Fiberglass$", 18, 0,
340              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
341
342   // Cables in air                                                                  -> idtmed[718]
343   AliMedium(19, "Cables    $", 19, 0,
344              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
345
346   // Air                                                                            -> idtmed[798] 
347   AliMedium(99, "Air          $", 99, 0,
348              isxfld, sxmgmx, 10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
349
350   // --- Set decent energy thresholds for gamma and electron tracking
351
352   // Tracking threshold for photons and electrons in the scintillator crystal 
353   gMC->Gstpar(idtmed[699], "CUTGAM",0.5E-4) ; 
354   gMC->Gstpar(idtmed[699], "CUTELE",1.0E-4) ;
355  
356   // --- Generate explicitly delta rays in the titan cover ---
357   gMC->Gstpar(idtmed[704], "LOSS",3.) ;
358   gMC->Gstpar(idtmed[704], "DRAY",1.) ;
359   // --- and in aluminium parts ---
360   gMC->Gstpar(idtmed[701], "LOSS",3.) ;
361   gMC->Gstpar(idtmed[701], "DRAY",1.) ;
362   // --- and in PIN diode
363   gMC->Gstpar(idtmed[705], "LOSS",3) ;
364   gMC->Gstpar(idtmed[705], "DRAY",1) ;
365   // --- and in the passive convertor
366   gMC->Gstpar(idtmed[712], "LOSS",3) ;
367   gMC->Gstpar(idtmed[712], "DRAY",1) ;
368   // Tracking threshold for photons and electrons in the gas ArC02 
369   gMC->Gstpar(idtmed[715], "CUTGAM",1.E-5) ; 
370   gMC->Gstpar(idtmed[715], "CUTELE",1.E-5) ;
371   gMC->Gstpar(idtmed[715], "CUTNEU",1.E-5) ;
372   gMC->Gstpar(idtmed[715], "CUTHAD",1.E-5) ;
373   gMC->Gstpar(idtmed[715], "CUTMUO",1.E-5) ;
374   gMC->Gstpar(idtmed[715], "BCUTE",1.E-5) ;
375   gMC->Gstpar(idtmed[715], "BCUTM",1.E-5) ;
376   gMC->Gstpar(idtmed[715], "DCUTE",1.E-5) ;
377   gMC->Gstpar(idtmed[715], "DCUTM",1.E-5) ;
378   gMC->Gstpar(idtmed[715], "PPCUTM",1.E-5) ;
379   gMC->Gstpar(idtmed[715], "LOSS",2.) ;
380   gMC->Gstpar(idtmed[715], "DRAY",0.) ;
381   gMC->Gstpar(idtmed[715], "STRA",2.) ;
382
383 }
384
385 //____________________________________________________________________________
386 void AliPHOS::Digits2Raw()
387 {
388 // convert digits of the current event to raw data
389
390   // get the digits
391   AliPHOSGetter * gime = AliPHOSGetter::Instance(AliRunLoader::GetGAliceName()) ; 
392   if (!gime) {
393     Error("Digits2Raw", "PHOS Getter not instantiated") ;
394     return ; 
395   }
396   gime->Event(gime->EventNumber(), "D") ; 
397   TClonesArray* digits = gime->Digits() ;
398
399   if (!digits) {
400     Error("Digits2Raw", "no digits found !");
401     return;
402   }
403
404   // get the geometry
405   AliPHOSGeometry* geom = gime->PHOSGeometry();
406   if (!geom) {
407     Error("Digits2Raw", "no geometry found !");
408     return;
409   }
410
411   // some digitization constants
412   const Int_t    kDDLOffset = 0x600;
413   const Double_t kTimeMax = 1.28E-5;
414   const Int_t    kTimeBins = 256;
415   const Double_t kTimePeak = 2.0E-6;
416   const Double_t kTimeRes = 1.5E-6;
417   const Int_t    kThreshold = 3;
418   const Int_t    kHighGainFactor = 40;
419   const Int_t    kHighGainOffset = 0x200;
420
421   AliAltroBuffer* buffer = NULL;
422   Int_t prevDDL = -1;
423   Int_t adcValuesLow[kTimeBins];
424   Int_t adcValuesHigh[kTimeBins];
425
426   // loop over digits (assume ordered digits)
427   for (Int_t iDigit = 0; iDigit < digits->GetEntries(); iDigit++) {
428     AliPHOSDigit* digit = gime->Digit(iDigit);
429     if (digit->GetAmp() < kThreshold) 
430       continue;
431     Int_t relId[4];
432     geom->AbsToRelNumbering(digit->GetId(), relId);
433     Int_t module = relId[0];
434  
435    // Begin FIXME 
436     if (relId[1] != 0) 
437       continue;    // ignore digits from CPV
438    // End FIXME 
439
440     // PHOS EMCA has 4 DDL per module. Splitting is done based on the row number
441     Int_t iDDL = 4 * (module - 1) + (4 * (relId[2] - 1)) / geom->GetNPhi();
442
443     // new DDL
444     if (iDDL != prevDDL) {
445       // write real header and close previous file
446       if (buffer) {
447         buffer->Flush();
448         buffer->WriteDataHeader(kFALSE, kFALSE);
449         delete buffer;
450       }
451
452       // open new file and write dummy header
453       TString fileName("PHOS_") ;
454       fileName += (iDDL + kDDLOffset) ; 
455       fileName += ".ddl" ; 
456       buffer = new AliAltroBuffer(fileName.Data(), 1);
457       buffer->WriteDataHeader(kTRUE, kFALSE);  //Dummy;
458
459       prevDDL = iDDL;
460     }
461
462     // out of time range signal (?)
463     if (digit->GetTime() > kTimeMax) {
464       buffer->FillBuffer(digit->GetAmp());
465       buffer->FillBuffer(kTimeBins);  // time bin
466       buffer->FillBuffer(3);          // bunch length
467       buffer->WriteTrailer(3, relId[3], relId[2], module);  // trailer
468       
469     // simulate linear rise and gaussian decay of signal
470     } else {
471       Bool_t highGain = kFALSE;
472
473       // fill time bin values :
474       // 1. the signal starts at the time given by the digit
475       // 2. the rise is linear and the maximum is reached kTimePeak after start
476       // 3. the decay is gaussian with a sigma of kTimeRes
477       // 4. the signal is binned into kTimeBins bins 
478       for (Int_t iTime = 0; iTime < kTimeBins; iTime++) {
479         Double_t time = iTime * kTimeMax/kTimeBins;
480         Int_t signal = 0;
481         if (time < digit->GetTime() + kTimePeak) {      // signal is rising
482           signal = static_cast<Int_t>(fRan->Rndm() + digit->GetAmp() * 
483                          (time - digit->GetTime()) / kTimePeak);
484         } else {                                        // signal is decaying
485           signal = static_cast<Int_t>(fRan->Rndm() + digit->GetAmp() * 
486                  TMath::Gaus(time, digit->GetTime() + kTimePeak, kTimeRes));
487         }
488         if (signal < 0) 
489           signal = 0;
490         adcValuesLow[iTime] = signal;
491         if (signal > 0x3FF) // larger than 10 bits 
492           adcValuesLow[iTime] = 0x3FF;
493         adcValuesHigh[iTime] = signal / kHighGainFactor;
494         if (adcValuesHigh[iTime] > 0) 
495           highGain = kTRUE;
496       }
497
498       // write low and eventually high gain channel
499       buffer->WriteChannel(relId[3], relId[2], module, 
500                            kTimeBins, adcValuesLow, kThreshold);
501       if (highGain) {
502         buffer->WriteChannel(relId[3], relId[2], module + kHighGainOffset, 
503                              kTimeBins, adcValuesHigh, 1);
504       }
505     }
506   }
507
508   // write real header and close last file
509   if (buffer) {
510     buffer->Flush();
511     buffer->WriteDataHeader(kFALSE, kFALSE);
512     delete buffer;
513   }
514
515   gime->PhosLoader()->UnloadDigits();
516 }
517
518 //____________________________________________________________________________
519 void AliPHOS::Hits2SDigits()  
520
521 // create summable digits
522
523   AliPHOSSDigitizer* phosDigitizer = 
524     new AliPHOSSDigitizer(fLoader->GetRunLoader()->GetFileName().Data()) ;
525   phosDigitizer->SetEventRange(0, -1) ; // do all the events
526   phosDigitizer->ExecuteTask("all") ;
527 }
528
529 //____________________________________________________________________________
530 AliLoader* AliPHOS::MakeLoader(const char* topfoldername)
531 {
532 //different behaviour than standard (singleton getter)
533 // --> to be discussed and made eventually coherent
534  fLoader = new AliPHOSLoader(GetName(),topfoldername);
535  return fLoader;
536 }
537
538 //____________________________________________________________________________
539 void AliPHOS::SetTreeAddress()
540
541   // Links Hits in the Tree to Hits array
542   TBranch *branch;
543   char branchname[20];
544   sprintf(branchname,"%s",GetName());
545   
546   // Branch address for hit tree
547   TTree *treeH = TreeH();
548   if (treeH) {
549     branch = treeH->GetBranch(branchname);
550     if (branch) 
551      { 
552        if (fHits == 0x0) fHits= new TClonesArray("AliPHOSHit",1000);
553        //Info("SetTreeAddress","<%s> Setting Hits Address",GetName());
554        branch->SetAddress(&fHits);
555      }
556   }
557 }
558
559 //____________________________________________________________________________
560 void AliPHOS::WriteQA()
561 {
562
563   // Make TreeQA in the output file. 
564
565   if(fTreeQA == 0)
566     fTreeQA = new TTree("TreeQA", "QA Alarms") ;    
567   // Create Alarms branches
568   Int_t bufferSize = 32000 ;    
569   Int_t splitlevel = 0 ; 
570
571   TFolder* topfold = GetLoader()->GetTopFolder(); //get top aliroot folder; skowron
572   TString phosqafn(AliConfig::Instance()->GetQAFolderName()+"/"); //get name of QAaut folder relative to top event; skowron
573   phosqafn+=GetName(); //hard wired string!!! add the detector name to the pathname; skowron 
574   TFolder * alarmsF = (TFolder*)topfold->FindObjectAny(phosqafn); //get the folder
575  
576   if (alarmsF == 0x0)
577    {
578      Error("WriteQA","Can not find folder with qa alarms");
579      return;
580    }
581   TString branchName(alarmsF->GetName());
582   TBranch * alarmsBranch = fTreeQA->Branch(branchName,"TFolder", &alarmsF, bufferSize, splitlevel);
583   TString branchTitle = branchName + " QA alarms" ; 
584   alarmsBranch->SetTitle(branchTitle);
585   alarmsBranch->Fill() ; 
586
587   //fTreeQA->Fill() ; 
588 }
589