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 **************************************************************************/
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.
24 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH)
25 //////////////////////////////////////////////////////////////////////////////
28 // --- ROOT system ---
32 #include <TVirtualMC.h>
35 // --- Standard library ---
37 // --- AliRoot header files ---
40 #include "AliPHOSGetter.h"
42 #include "AliPHOSDigitizer.h"
43 #include "AliPHOSSDigitizer.h"
44 #include "AliPHOSDigit.h"
45 #include "AliAltroBuffer.h"
48 //____________________________________________________________________________
49 AliPHOS:: AliPHOS() : AliDetector()
56 fRan = new TRandom(123456) ;
59 //____________________________________________________________________________
60 AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name, title)
62 // ctor : title is used to identify the layout
67 fRan = new TRandom(123456) ;
70 //____________________________________________________________________________
76 //____________________________________________________________________________
77 void AliPHOS::Copy(AliPHOS & phos)
79 // copy method to be used byy the cpy ctor
81 // fQATask = AliPHOSQAChecker::Copy(*(phos.fQATask)) ;
82 phos.fTreeQA = fTreeQA->CloneTree() ;
85 //____________________________________________________________________________
86 AliDigitizer* AliPHOS::CreateDigitizer(AliRunDigitizer* manager) const
88 return new AliPHOSDigitizer(manager);
91 //____________________________________________________________________________
92 void AliPHOS::CreateMaterials()
94 // Definitions of materials to build PHOS and associated tracking media.
95 // media number in idtmed are 699 to 798.
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} ;
103 AliMixture(0, "PbWO4$", aX, zX, dX, -3, wX) ;
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} ;
112 AliMixture(1, "Polystyrene$", aP, zP, dP, -2, wP) ;
115 AliMaterial(2, "Al$", 26.98, 13., 2.7, 8.9, 999., 0, 0) ;
116 // --- Absorption length is ignored ^
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} ;
124 AliMixture(3, "Tyvek$", aT, zT, dT, -2, wT) ;
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} ;
132 AliMixture(4, "Foam$", aF, zF, dF, -2, wF) ;
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} ;
140 AliMixture(5, "Titanium$", aTIT, zTIT, dTIT, -3, wTIT);
143 AliMaterial(6, "Si$", 28.0855, 14., 2.33, 9.36, 42.3, 0, 0) ;
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} ;
153 AliMixture(7, "Thermo Insul.$", aTI, zTI, dTI, -2, wTI) ;
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} ;
161 AliMixture(8, "Textolit$", aTX, zTX, dTX, -4, wTX) ;
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} ;
169 AliMixture(9, "FR4$", aFR, zFR, dFR, -3, wFR) ;
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 ;
177 AliMixture(10, "Compo Mat$", aCM, zCM, dCM, -2, wCM) ;
180 AliMaterial(11, "Cu$", 63.546, 29, 8.96, 1.43, 14.8, 0, 0) ;
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} ;
188 AliMixture(12, "G10$", aG10, zG10, dG10, -4, wG10);
191 AliMaterial(13, "Pb$", 207.2, 82, 11.35, 0.56, 0., 0, 0) ;
193 // --- The gas mixture ---
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 ;
200 AliMixture(14, "CO2$", aCO, zCO, dCO, -2, wCO);
203 Float_t dAr = 0.001782 ;
204 AliMaterial(15, "Ar$", 39.948, 18.0, dAr, 14.0, 0., 0, 0) ;
207 Char_t namate[21]="";
213 Float_t absL, radL, density ;
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
221 // Create gas mixture
223 Float_t arContent = 0.80 ; // Ar-content of the Ar/CO2-mixture (80% / 20%)
226 wGM[1] = 1. - arContent ;
227 dGM = wGM[0] * dAr + wGM[1] * dCO;
230 AliMixture(16, "ArCO2$", aGM, zGM, dGM, 2, wGM) ;
232 // --- Stainless steel (let it be pure iron) ---
233 AliMaterial(17, "Steel$", 55.845, 26, 7.87, 1.76, 0., 0, 0) ;
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} ;
242 AliMixture(18, "Fibergla$", aFG, zFG, dFG, -4, wFG) ;
244 // --- Cables in Air box ---
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
252 AliMixture(19, "Cables $", aCA, zCA, dCA, -4, wCA) ;
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;
261 AliMixture(99, "Air$", aAir, zAir, dAir, 4, wAir) ;
263 // DEFINITION OF THE TRACKING MEDIA
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() ;
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) ;
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) ;
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) ;
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) ;
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) ;
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) ;
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) ;
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) ;
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) ;
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) ;
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) ;
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) ;
319 // G10: Printed Circuit material -> idtmed[711]
321 AliMedium(12, "G10 $", 12, 0,
322 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.01, 0, 0) ;
324 // The Lead -> idtmed[712]
326 AliMedium(13, "Lead $", 13, 0,
327 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
329 // The gas mixture: ArCo2 -> idtmed[715]
331 AliMedium(16, "ArCo2 $", 16, 1,
332 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.01, 0, 0) ;
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) ;
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) ;
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) ;
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) ;
350 // --- Set decent energy thresholds for gamma and electron tracking
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) ;
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.) ;
385 //____________________________________________________________________________
386 void AliPHOS::Digits2Raw()
388 // convert digits of the current event to raw data
391 AliPHOSGetter * gime = AliPHOSGetter::Instance(AliRunLoader::GetGAliceName()) ;
393 Error("Digits2Raw", "PHOS Getter not instantiated") ;
396 gime->Event(gime->EventNumber(), "D") ;
397 TClonesArray* digits = gime->Digits() ;
400 Error("Digits2Raw", "no digits found !");
405 AliPHOSGeometry* geom = gime->PHOSGeometry();
407 Error("Digits2Raw", "no geometry found !");
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;
421 AliAltroBuffer* buffer = NULL;
423 Int_t adcValuesLow[kTimeBins];
424 Int_t adcValuesHigh[kTimeBins];
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)
432 geom->AbsToRelNumbering(digit->GetId(), relId);
433 Int_t module = relId[0];
437 continue; // ignore digits from CPV
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();
444 if (iDDL != prevDDL) {
445 // write real header and close previous file
448 buffer->WriteDataHeader(kFALSE, kFALSE);
452 // open new file and write dummy header
453 TString fileName("PHOS_") ;
454 fileName += (iDDL + kDDLOffset) ;
456 buffer = new AliAltroBuffer(fileName.Data(), 1);
457 buffer->WriteDataHeader(kTRUE, kFALSE); //Dummy;
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
469 // simulate linear rise and gaussian decay of signal
471 Bool_t highGain = kFALSE;
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;
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));
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)
498 // write low and eventually high gain channel
499 buffer->WriteChannel(relId[3], relId[2], module,
500 kTimeBins, adcValuesLow, kThreshold);
502 buffer->WriteChannel(relId[3], relId[2], module + kHighGainOffset,
503 kTimeBins, adcValuesHigh, 1);
508 // write real header and close last file
511 buffer->WriteDataHeader(kFALSE, kFALSE);
515 gime->PhosLoader()->UnloadDigits();
518 //____________________________________________________________________________
519 void AliPHOS::Hits2SDigits()
521 // create summable digits
523 AliPHOSSDigitizer* phosDigitizer =
524 new AliPHOSSDigitizer(fLoader->GetRunLoader()->GetFileName().Data()) ;
525 phosDigitizer->SetEventRange(0, -1) ; // do all the events
526 phosDigitizer->ExecuteTask("all") ;
529 //____________________________________________________________________________
530 AliLoader* AliPHOS::MakeLoader(const char* topfoldername)
532 //different behaviour than standard (singleton getter)
533 // --> to be discussed and made eventually coherent
534 fLoader = new AliPHOSLoader(GetName(),topfoldername);
538 //____________________________________________________________________________
539 void AliPHOS::SetTreeAddress()
541 // Links Hits in the Tree to Hits array
544 sprintf(branchname,"%s",GetName());
546 // Branch address for hit tree
547 TTree *treeH = TreeH();
549 branch = treeH->GetBranch(branchname);
552 if (fHits == 0x0) fHits= new TClonesArray("AliPHOSHit",1000);
553 //Info("SetTreeAddress","<%s> Setting Hits Address",GetName());
554 branch->SetAddress(&fHits);
559 //____________________________________________________________________________
560 void AliPHOS::WriteQA()
563 // Make TreeQA in the output file.
566 fTreeQA = new TTree("TreeQA", "QA Alarms") ;
567 // Create Alarms branches
568 Int_t bufferSize = 32000 ;
569 Int_t splitlevel = 0 ;
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
578 Error("WriteQA","Can not find folder with qa alarms");
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() ;