]>
Commit | Line | Data |
---|---|---|
2012850d | 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 | // Base Class for EMCAL description: | |
ffa6d63b | 20 | // This class contains material definitions |
21 | // for the EMCAL - It does not place the detector in Alice | |
2012850d | 22 | //*-- Author: Yves Schutz (SUBATECH) |
b13bbe81 | 23 | // |
24 | //*-- Additional Contributions: Sahal Yacoob (LBNL/UCT) | |
25 | // | |
2012850d | 26 | ////////////////////////////////////////////////////////////////////////////// |
27 | ||
2012850d | 28 | // --- ROOT system --- |
b13bbe81 | 29 | class TFile; |
88cb7938 | 30 | #include <TFolder.h> |
88cb7938 | 31 | #include <TTree.h> |
32 | #include <TVirtualMC.h> | |
046ae904 | 33 | #include <TH1F.h> |
34 | #include <TF1.h> | |
35 | #include <TRandom.h> | |
2012850d | 36 | |
05a92d59 | 37 | // --- Standard library --- |
2012850d | 38 | |
05a92d59 | 39 | // --- AliRoot header files --- |
2012850d | 40 | #include "AliMagF.h" |
88cb7938 | 41 | #include "AliEMCAL.h" |
f51151a0 | 42 | #include "AliEMCALGetter.h" |
85a5290f | 43 | #include "AliRun.h" |
44 | #include "AliEMCALSDigitizer.h" | |
45 | #include "AliEMCALDigitizer.h" | |
f51151a0 | 46 | #include "AliAltroBuffer.h" |
2012850d | 47 | |
48 | ClassImp(AliEMCAL) | |
56088960 | 49 | Double_t AliEMCAL::fgCapa = 1.; // 1pF |
50 | Int_t AliEMCAL::fgOrder = 2 ; | |
51 | Double_t AliEMCAL::fgTimeMax = 2.56E-5 ; // each sample is over 100 ns fTimeMax/fTimeBins | |
52 | Double_t AliEMCAL::fgTimePeak = 4.1E-6 ; // 4 micro seconds | |
53 | Double_t AliEMCAL::fgTimeTrigger = 100E-9 ; // 100ns, just for a reference | |
54 | ||
2012850d | 55 | //____________________________________________________________________________ |
56 | AliEMCAL::AliEMCAL():AliDetector() | |
57 | { | |
05a92d59 | 58 | // Default ctor |
046ae904 | 59 | fName = "EMCAL" ; |
2012850d | 60 | } |
05a92d59 | 61 | |
2012850d | 62 | //____________________________________________________________________________ |
05a92d59 | 63 | AliEMCAL::AliEMCAL(const char* name, const char* title): AliDetector(name,title) |
64 | { | |
65 | // ctor : title is used to identify the layout | |
046ae904 | 66 | |
56088960 | 67 | fHighCharge = 8.2 ; // adjusted for a high gain range of 5.12 GeV (10 bits) |
68 | fHighGain = 6.64 ; | |
69 | fHighLowGainFactor = 16. ; // adjusted for a low gain range of 82 GeV (10 bits) | |
70 | fLowGainOffset = 1 ; // offset added to the module id to distinguish high and low gain data | |
2012850d | 71 | } |
05a92d59 | 72 | |
2012850d | 73 | //____________________________________________________________________________ |
05a92d59 | 74 | AliEMCAL::~AliEMCAL() |
75 | { | |
76 | ||
2012850d | 77 | } |
78 | ||
8367ce9a | 79 | //____________________________________________________________________________ |
80 | void AliEMCAL::Copy(AliEMCAL & emcal) | |
81 | { | |
82 | TObject::Copy(emcal) ; | |
56088960 | 83 | emcal.fHighCharge = fHighCharge ; |
84 | emcal.fHighGain = fHighGain ; | |
85 | emcal.fHighLowGainFactor = fHighLowGainFactor ; | |
86 | emcal.fLowGainOffset = fLowGainOffset; | |
8367ce9a | 87 | } |
88 | ||
89 | //____________________________________________________________________________ | |
90 | AliDigitizer* AliEMCAL::CreateDigitizer(AliRunDigitizer* manager) const | |
91 | { | |
92 | return new AliEMCALDigitizer(manager); | |
93 | } | |
94 | ||
2012850d | 95 | //____________________________________________________________________________ |
05a92d59 | 96 | void AliEMCAL::CreateMaterials() |
97 | { | |
2012850d | 98 | // Definitions of materials to build EMCAL and associated tracking media. |
99 | // media number in idtmed are 1599 to 1698. | |
100 | ||
996cf306 | 101 | // --- Air --- |
102 | Float_t aAir[4]={12.0107,14.0067,15.9994,39.948}; | |
103 | Float_t zAir[4]={6.,7.,8.,18.}; | |
104 | Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827}; | |
105 | Float_t dAir = 1.20479E-3; | |
106 | AliMixture(0, "Air$", aAir, zAir, dAir, 4, wAir) ; | |
b13bbe81 | 107 | |
2012850d | 108 | // --- Lead --- |
109 | AliMaterial(1, "Pb$", 207.2, 82, 11.35, 0.56, 0., 0, 0) ; | |
110 | ||
b13bbe81 | 111 | |
112 | // --- The polysterene scintillator (CH) --- | |
113 | Float_t aP[2] = {12.011, 1.00794} ; | |
114 | Float_t zP[2] = {6.0, 1.0} ; | |
115 | Float_t wP[2] = {1.0, 1.0} ; | |
116 | Float_t dP = 1.032 ; | |
117 | ||
118 | AliMixture(2, "Polystyrene$", aP, zP, dP, -2, wP) ; | |
119 | ||
120 | // --- Aluminium --- | |
121 | AliMaterial(3, "Al$", 26.98, 13., 2.7, 8.9, 999., 0, 0) ; | |
122 | // --- Absorption length is ignored ^ | |
123 | ||
2012850d | 124 | // DEFINITION OF THE TRACKING MEDIA |
125 | ||
126 | // for EMCAL: idtmed[1599->1698] equivalent to fIdtmed[0->100] | |
127 | Int_t * idtmed = fIdtmed->GetArray() - 1599 ; | |
128 | Int_t isxfld = gAlice->Field()->Integ() ; | |
129 | Float_t sxmgmx = gAlice->Field()->Max() ; | |
130 | ||
996cf306 | 131 | // Air -> idtmed[1599] |
132 | AliMedium(0, "Air $", 0, 0, | |
133 | isxfld, sxmgmx, 10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ; | |
2012850d | 134 | |
a63e0d5e | 135 | // The Lead -> idtmed[1600] |
2012850d | 136 | |
137 | AliMedium(1, "Lead $", 1, 0, | |
138 | isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ; | |
139 | ||
b13bbe81 | 140 | // The scintillator of the CPV made of Polystyrene scintillator -> idtmed[1601] |
141 | AliMedium(2, "CPV scint. $", 2, 1, | |
61e0abb5 | 142 | isxfld, sxmgmx, 10.0, 0.001, 0.1, 0.001, 0.001, 0, 0) ; |
b13bbe81 | 143 | |
a63e0d5e | 144 | // Various Aluminium parts made of Al -> idtmed[1602] |
b13bbe81 | 145 | AliMedium(3, "Al parts $", 3, 0, |
146 | isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ; | |
147 | ||
2012850d | 148 | |
b13bbe81 | 149 | // --- Set decent energy thresholds for gamma and electron tracking |
2012850d | 150 | |
151 | // Tracking threshold for photons and electrons in Lead | |
ffa6d63b | 152 | gMC->Gstpar(idtmed[1600],"CUTGAM",0.00008) ; |
153 | gMC->Gstpar(idtmed[1600],"CUTELE",0.001) ; | |
154 | gMC->Gstpar(idtmed[1600],"BCUTE",0.0001) ; | |
2012850d | 155 | |
156 | // --- Generate explicitly delta rays in Lead --- | |
157 | gMC->Gstpar(idtmed[1600], "LOSS",3.) ; | |
158 | gMC->Gstpar(idtmed[1600], "DRAY",1.) ; | |
05a92d59 | 159 | gMC->Gstpar(idtmed[1600], "DCUTE",0.00001) ; |
160 | gMC->Gstpar(idtmed[1600], "DCUTM",0.00001) ; | |
161 | ||
a63e0d5e | 162 | // --- in aluminium parts --- |
b13bbe81 | 163 | gMC->Gstpar(idtmed[1602], "LOSS",3.) ; |
164 | gMC->Gstpar(idtmed[1602], "DRAY",1.) ; | |
05a92d59 | 165 | gMC->Gstpar(idtmed[1602], "DCUTE",0.00001) ; |
166 | gMC->Gstpar(idtmed[1602], "DCUTM",0.00001) ; | |
b13bbe81 | 167 | |
ffa6d63b | 168 | // --- and finally thresholds for photons and electrons in the scintillator --- |
61e0abb5 | 169 | gMC->Gstpar(idtmed[1601],"CUTGAM",0.00008) ; |
170 | gMC->Gstpar(idtmed[1601],"CUTELE",0.001) ; | |
171 | gMC->Gstpar(idtmed[1601],"BCUTE",0.0001) ; | |
172 | ||
ab37d09c | 173 | //set constants for Birk's Law implentation |
174 | fBirkC0 = 1; | |
175 | fBirkC1 = 0.013/dP; | |
176 | fBirkC2 = 9.6e-6/(dP * dP); | |
177 | ||
178 | ||
2012850d | 179 | } |
f6019cda | 180 | |
f51151a0 | 181 | //____________________________________________________________________________ |
182 | void AliEMCAL::Digits2Raw() | |
183 | { | |
56088960 | 184 | // convert digits of the current event to raw data |
185 | AliEMCALLoader * loader = dynamic_cast<AliEMCALLoader*>(fLoader) ; | |
f51151a0 | 186 | |
187 | // get the digits | |
56088960 | 188 | loader->LoadDigits(); |
189 | TClonesArray* digits = loader->Digits() ; | |
f51151a0 | 190 | |
191 | if (!digits) { | |
192 | Error("Digits2Raw", "no digits found !"); | |
193 | return; | |
194 | } | |
195 | ||
56088960 | 196 | // get the digitizer |
197 | loader->LoadDigitizer(); | |
198 | AliEMCALDigitizer * digitizer = dynamic_cast<AliEMCALDigitizer *>(loader->Digitizer()) ; | |
199 | ||
f51151a0 | 200 | // get the geometry |
56088960 | 201 | AliEMCALGeometry* geom = GetGeometry(); |
f51151a0 | 202 | if (!geom) { |
203 | Error("Digits2Raw", "no geometry found !"); | |
204 | return; | |
205 | } | |
206 | ||
207 | // some digitization constants | |
208 | const Int_t kDDLOffset = 0x800; | |
56088960 | 209 | const Int_t kThreshold = 1; |
f51151a0 | 210 | const Int_t kChannelsperDDL = 897 ; |
f51151a0 | 211 | AliAltroBuffer* buffer = NULL; |
212 | Int_t prevDDL = -1; | |
046ae904 | 213 | Int_t adcValuesLow[fkTimeBins]; |
214 | Int_t adcValuesHigh[fkTimeBins]; | |
56088960 | 215 | |
f51151a0 | 216 | // loop over digits (assume ordered digits) |
217 | for (Int_t iDigit = 0; iDigit < digits->GetEntries(); iDigit++) { | |
56088960 | 218 | AliEMCALDigit* digit = dynamic_cast<AliEMCALDigit *>(digits->At(iDigit)) ; |
f51151a0 | 219 | if (digit->GetAmp() < kThreshold) |
220 | continue; | |
221 | Int_t iDDL = digit->GetId() / kChannelsperDDL ; | |
222 | // for each DDL id is numbered from 1 to kChannelsperDDL -1 | |
223 | Int_t idDDL = digit->GetId() - iDDL * ( kChannelsperDDL - 1 ) ; | |
224 | // new DDL | |
225 | if (iDDL != prevDDL) { | |
226 | // write real header and close previous file | |
227 | if (buffer) { | |
228 | buffer->Flush(); | |
229 | buffer->WriteDataHeader(kFALSE, kFALSE); | |
230 | delete buffer; | |
231 | } | |
232 | ||
233 | // open new file and write dummy header | |
234 | TString fileName("EMCAL_") ; | |
235 | fileName += (iDDL + kDDLOffset) ; | |
236 | fileName += ".ddl" ; | |
237 | buffer = new AliAltroBuffer(fileName.Data(), 1); | |
238 | buffer->WriteDataHeader(kTRUE, kFALSE); //Dummy; | |
239 | ||
240 | prevDDL = iDDL; | |
241 | } | |
242 | ||
243 | // out of time range signal (?) | |
56088960 | 244 | if (digit->GetTimeR() > GetRawFormatTimeMax() ) { |
f51151a0 | 245 | buffer->FillBuffer(digit->GetAmp()); |
56088960 | 246 | buffer->FillBuffer(GetRawFormatTimeBins() ); // time bin |
f51151a0 | 247 | buffer->FillBuffer(3); // bunch length |
248 | buffer->WriteTrailer(3, idDDL, 0, 0); // trailer | |
56088960 | 249 | |
250 | // calculate the time response function | |
f51151a0 | 251 | } else { |
56088960 | 252 | Double_t energy = 0 ; |
253 | energy = digit->GetAmp() * digitizer->GetECAchannel() + digitizer->GetECApedestal() ; | |
254 | ||
255 | Bool_t lowgain = RawSampledResponse(digit->GetTimeR(), energy, adcValuesHigh, adcValuesLow) ; | |
256 | ||
257 | if (lowgain) | |
258 | buffer->WriteChannel(iDDL, 0, fLowGainOffset, | |
259 | GetRawFormatTimeBins(), adcValuesLow, kThreshold); | |
260 | else | |
261 | buffer->WriteChannel(iDDL, 0, 0, | |
262 | GetRawFormatTimeBins(), adcValuesHigh, kThreshold); | |
263 | ||
f51151a0 | 264 | } |
265 | } | |
56088960 | 266 | |
f51151a0 | 267 | // write real header and close last file |
268 | if (buffer) { | |
269 | buffer->Flush(); | |
270 | buffer->WriteDataHeader(kFALSE, kFALSE); | |
271 | delete buffer; | |
272 | } | |
56088960 | 273 | |
274 | loader->UnloadDigits(); | |
f51151a0 | 275 | } |
276 | ||
8367ce9a | 277 | //____________________________________________________________________________ |
278 | void AliEMCAL::Hits2SDigits() | |
279 | { | |
280 | // create summable digits | |
281 | ||
282 | AliEMCALSDigitizer* emcalDigitizer = | |
da480a28 | 283 | new AliEMCALSDigitizer(fLoader->GetRunLoader()->GetFileName().Data()) ; |
284 | emcalDigitizer->SetEventRange(0, -1) ; // do all the events | |
285 | emcalDigitizer->ExecuteTask() ; | |
286 | } | |
287 | ||
8367ce9a | 288 | //____________________________________________________________________________ |
289 | AliLoader* AliEMCAL::MakeLoader(const char* topfoldername) | |
290 | { | |
291 | //different behaviour than standard (singleton getter) | |
292 | // --> to be discussed and made eventually coherent | |
293 | fLoader = new AliEMCALLoader(GetName(),topfoldername); | |
294 | return fLoader; | |
295 | } | |
296 | ||
046ae904 | 297 | //__________________________________________________________________ |
298 | Double_t AliEMCAL::RawResponseFunction(Double_t *x, Double_t *par) | |
299 | { | |
300 | // Shape of the electronics raw reponse: | |
56088960 | 301 | // It is a semi-gaussian, 2nd order Gamma function of the general form |
302 | // v(t) = n**n * Q * A**n / C *(t/tp)**n * exp(-n * t/tp) with | |
303 | // tp : peaking time par[0] | |
304 | // n : order of the function | |
305 | // C : integrating capacitor in the preamplifier | |
306 | // A : open loop gain of the preamplifier | |
307 | // Q : the total APD charge to be measured Q = C * energy | |
046ae904 | 308 | |
56088960 | 309 | Double_t signal ; |
310 | Double_t xx = x[0] - ( fgTimeTrigger + par[3] ) ; | |
046ae904 | 311 | |
56088960 | 312 | if (xx < 0 || xx > fgTimeMax) |
313 | signal = 0. ; | |
314 | else { | |
315 | Double_t fac = par[0] * TMath::Power(fgOrder, fgOrder) * TMath::Power(par[1], fgOrder) / fgCapa ; | |
316 | signal = fac * par[2] * TMath::Power(xx / fgTimePeak, fgOrder) * TMath::Exp(-fgOrder * (xx / fgTimePeak)) ; | |
317 | } | |
318 | return signal ; | |
046ae904 | 319 | } |
320 | ||
321 | //__________________________________________________________________ | |
56088960 | 322 | Double_t AliEMCAL::RawResponseFunctionMax(Double_t charge, Double_t gain) |
323 | { | |
324 | return ( charge * TMath::Power(fgOrder, fgOrder) * TMath::Power(gain, fgOrder) | |
325 | / ( fgCapa * TMath::Exp(fgOrder) ) ); | |
326 | ||
327 | } | |
328 | //__________________________________________________________________ | |
329 | Bool_t AliEMCAL::RawSampledResponse( | |
330 | const Double_t dtime, const Double_t damp, Int_t * adcH, Int_t * adcL) const | |
046ae904 | 331 | { |
332 | // for a start time dtime and an amplitude damp given by digit, | |
56088960 | 333 | // calculates the raw sampled response AliEMCAL::RawResponseFunction |
046ae904 | 334 | |
335 | const Int_t kRawSignalOverflow = 0x3FF ; | |
56088960 | 336 | Bool_t lowGain = kFALSE ; |
337 | ||
338 | TF1 signalF("signal", RawResponseFunction, 0, GetRawFormatTimeMax(), 4); | |
339 | ||
340 | for (Int_t iTime = 0; iTime < GetRawFormatTimeBins(); iTime++) { | |
341 | signalF.SetParameter(0, GetRawFormatHighCharge() ) ; | |
342 | signalF.SetParameter(1, GetRawFormatHighGain() ) ; | |
343 | signalF.SetParameter(2, damp) ; | |
344 | signalF.SetParameter(3, dtime) ; | |
345 | Double_t time = iTime * GetRawFormatTimeMax() / GetRawFormatTimeBins() ; | |
346 | Double_t signal = signalF.Eval(time) ; | |
347 | if ( static_cast<Int_t>(signal+0.5) > kRawSignalOverflow ){ // larger than 10 bits | |
348 | signal = kRawSignalOverflow ; | |
349 | lowGain = kTRUE ; | |
350 | } | |
351 | adcH[iTime] = static_cast<Int_t>(signal + 0.5) ; | |
352 | ||
353 | signalF.SetParameter(0, GetRawFormatLowCharge() ) ; | |
354 | signalF.SetParameter(1, GetRawFormatLowGain() ) ; | |
355 | signal = signalF.Eval(time) ; | |
356 | if ( static_cast<Int_t>(signal+0.5) > kRawSignalOverflow) // larger than 10 bits | |
357 | signal = kRawSignalOverflow ; | |
358 | adcL[iTime] = static_cast<Int_t>(0.5 + signal ) ; | |
359 | ||
046ae904 | 360 | } |
56088960 | 361 | return lowGain ; |
046ae904 | 362 | } |
363 | ||
2012850d | 364 | //____________________________________________________________________________ |
365 | void AliEMCAL::SetTreeAddress() | |
366 | { | |
d64c959b | 367 | // Linking Hits in Tree to Hits array |
2012850d | 368 | TBranch *branch; |
369 | char branchname[20]; | |
370 | sprintf(branchname,"%s",GetName()); | |
371 | ||
372 | // Branch address for hit tree | |
88cb7938 | 373 | TTree *treeH = TreeH(); |
374 | if (treeH) { | |
2012850d | 375 | branch = treeH->GetBranch(branchname); |
88cb7938 | 376 | if (branch) |
377 | { | |
d64c959b | 378 | if (fHits == 0x0) |
379 | fHits= new TClonesArray("AliEMCALHit",1000); | |
88cb7938 | 380 | branch->SetAddress(&fHits); |
381 | } | |
382 | else | |
383 | { | |
384 | Warning("SetTreeAddress","<%s> Failed",GetName()); | |
385 | } | |
2012850d | 386 | } |
2012850d | 387 | } |
2012850d | 388 | |
85a5290f | 389 | |
85a5290f | 390 | |
85a5290f | 391 | |
8367ce9a | 392 |