]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCAL.cxx
correction for ALICE numbering scheme in Trigger methods
[u/mrichter/AliRoot.git] / EMCAL / AliEMCAL.cxx
CommitLineData
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 29class 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>
2d5d9e60 36#include <TGraph.h>
2012850d 37
05a92d59 38// --- Standard library ---
2012850d 39
05a92d59 40// --- AliRoot header files ---
2012850d 41#include "AliMagF.h"
88cb7938 42#include "AliEMCAL.h"
85a5290f 43#include "AliRun.h"
5dee926e 44#include "AliEMCALLoader.h"
85a5290f 45#include "AliEMCALSDigitizer.h"
46#include "AliEMCALDigitizer.h"
5dee926e 47#include "AliEMCALDigit.h"
f51151a0 48#include "AliAltroBuffer.h"
2d5d9e60 49#include "AliRawReader.h"
50#include "AliEMCALRawStream.h"
362c9d61 51#include "AliDAQ.h"
2012850d 52
53ClassImp(AliEMCAL)
56088960 54Double_t AliEMCAL::fgCapa = 1.; // 1pF
55Int_t AliEMCAL::fgOrder = 2 ;
56Double_t AliEMCAL::fgTimeMax = 2.56E-5 ; // each sample is over 100 ns fTimeMax/fTimeBins
57Double_t AliEMCAL::fgTimePeak = 4.1E-6 ; // 4 micro seconds
58Double_t AliEMCAL::fgTimeTrigger = 100E-9 ; // 100ns, just for a reference
2d5d9e60 59// some digitization constants
2d5d9e60 60Int_t AliEMCAL::fgThreshold = 1;
61// 24*48=1152 towers per SM; divided up on 3 DDLs,
62// each DDL with 12FEC *32towers or 12*32*2 channels (high&low gain)
63Int_t AliEMCAL::fgChannelsPerDDL = 768; // 2*(1152/3 or 12*32)
56088960 64
2012850d 65//____________________________________________________________________________
66AliEMCAL::AliEMCAL():AliDetector()
67{
05a92d59 68 // Default ctor
046ae904 69 fName = "EMCAL" ;
2012850d 70}
05a92d59 71
2012850d 72//____________________________________________________________________________
05a92d59 73AliEMCAL::AliEMCAL(const char* name, const char* title): AliDetector(name,title)
74{
75 // ctor : title is used to identify the layout
046ae904 76
56088960 77 fHighCharge = 8.2 ; // adjusted for a high gain range of 5.12 GeV (10 bits)
78 fHighGain = 6.64 ;
79 fHighLowGainFactor = 16. ; // adjusted for a low gain range of 82 GeV (10 bits)
80 fLowGainOffset = 1 ; // offset added to the module id to distinguish high and low gain data
2012850d 81}
05a92d59 82
2012850d 83//____________________________________________________________________________
05a92d59 84AliEMCAL::~AliEMCAL()
85{
14ce0a6e 86 //dtor
2012850d 87}
88
8367ce9a 89//____________________________________________________________________________
5dee926e 90void AliEMCAL::Copy(AliEMCAL & emcal) const
8367ce9a 91{
14ce0a6e 92 //copy
93
8367ce9a 94 TObject::Copy(emcal) ;
56088960 95 emcal.fHighCharge = fHighCharge ;
96 emcal.fHighGain = fHighGain ;
97 emcal.fHighLowGainFactor = fHighLowGainFactor ;
98 emcal.fLowGainOffset = fLowGainOffset;
8367ce9a 99}
100
101//____________________________________________________________________________
102AliDigitizer* AliEMCAL::CreateDigitizer(AliRunDigitizer* manager) const
103{
14ce0a6e 104 //create and return the digitizer
8367ce9a 105 return new AliEMCALDigitizer(manager);
106}
107
2012850d 108//____________________________________________________________________________
05a92d59 109void AliEMCAL::CreateMaterials()
110{
2012850d 111 // Definitions of materials to build EMCAL and associated tracking media.
112 // media number in idtmed are 1599 to 1698.
113
996cf306 114 // --- Air ---
115 Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
116 Float_t zAir[4]={6.,7.,8.,18.};
117 Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
118 Float_t dAir = 1.20479E-3;
119 AliMixture(0, "Air$", aAir, zAir, dAir, 4, wAir) ;
b13bbe81 120
2012850d 121 // --- Lead ---
122 AliMaterial(1, "Pb$", 207.2, 82, 11.35, 0.56, 0., 0, 0) ;
123
b13bbe81 124
125 // --- The polysterene scintillator (CH) ---
126 Float_t aP[2] = {12.011, 1.00794} ;
127 Float_t zP[2] = {6.0, 1.0} ;
128 Float_t wP[2] = {1.0, 1.0} ;
129 Float_t dP = 1.032 ;
130
131 AliMixture(2, "Polystyrene$", aP, zP, dP, -2, wP) ;
132
133 // --- Aluminium ---
134 AliMaterial(3, "Al$", 26.98, 13., 2.7, 8.9, 999., 0, 0) ;
135 // --- Absorption length is ignored ^
136
1963b290 137 // 25-aug-04 by PAI - see PMD/AliPMDv0.cxx for STEEL definition
138 Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
139 Float_t zsteel[4] = { 26.,24.,28.,14. };
140 Float_t wsteel[4] = { .715,.18,.1,.005 };
141 AliMixture(4, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
142
2012850d 143 // DEFINITION OF THE TRACKING MEDIA
144
145 // for EMCAL: idtmed[1599->1698] equivalent to fIdtmed[0->100]
146 Int_t * idtmed = fIdtmed->GetArray() - 1599 ;
147 Int_t isxfld = gAlice->Field()->Integ() ;
148 Float_t sxmgmx = gAlice->Field()->Max() ;
149
996cf306 150 // Air -> idtmed[1599]
905263da 151 AliMedium(0, "Air$", 0, 0,
996cf306 152 isxfld, sxmgmx, 10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
2012850d 153
a63e0d5e 154 // The Lead -> idtmed[1600]
2012850d 155
905263da 156 AliMedium(1, "Lead$", 1, 0,
2012850d 157 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
158
b13bbe81 159 // The scintillator of the CPV made of Polystyrene scintillator -> idtmed[1601]
905263da 160 AliMedium(2, "Scintillator$", 2, 1,
61e0abb5 161 isxfld, sxmgmx, 10.0, 0.001, 0.1, 0.001, 0.001, 0, 0) ;
b13bbe81 162
a63e0d5e 163 // Various Aluminium parts made of Al -> idtmed[1602]
905263da 164 AliMedium(3, "Al$", 3, 0,
b13bbe81 165 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ;
166
1963b290 167 // 25-aug-04 by PAI : see PMD/AliPMDv0.cxx for STEEL definition -> idtmed[1603]
168 AliMedium(4, "S steel$", 4, 0,
169 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ;
2012850d 170
b13bbe81 171// --- Set decent energy thresholds for gamma and electron tracking
2012850d 172
173 // Tracking threshold for photons and electrons in Lead
905263da 174 Float_t cutgam=10.e-5; // 100 kev;
175 Float_t cutele=10.e-5; // 100 kev;
176 TString ntmp(GetTitle());
177 ntmp.ToUpper();
178 if(ntmp.Contains("10KEV")) {
179 cutele = cutgam = 1.e-5;
180 } else if(ntmp.Contains("50KEV")) {
181 cutele = cutgam = 5.e-5;
182 } else if(ntmp.Contains("100KEV")) {
183 cutele = cutgam = 1.e-4;
184 } else if(ntmp.Contains("200KEV")) {
185 cutele = cutgam = 2.e-4;
186 } else if(ntmp.Contains("500KEV")) {
187 cutele = cutgam = 5.e-4;
188 }
2012850d 189
905263da 190 gMC->Gstpar(idtmed[1600],"CUTGAM", cutgam);
191 gMC->Gstpar(idtmed[1600],"CUTELE", cutele); // 1MEV -> 0.1MEV; 15-aug-05
192 gMC->Gstpar(idtmed[1600],"BCUTE", cutgam); // BCUTE and BCUTM start from GUTGUM
193 gMC->Gstpar(idtmed[1600],"BCUTM", cutgam); // BCUTE and BCUTM start from GUTGUM
2012850d 194 // --- Generate explicitly delta rays in Lead ---
195 gMC->Gstpar(idtmed[1600], "LOSS",3.) ;
196 gMC->Gstpar(idtmed[1600], "DRAY",1.) ;
905263da 197 gMC->Gstpar(idtmed[1600], "DCUTE", cutele) ;
198 gMC->Gstpar(idtmed[1600], "DCUTM", cutele) ;
05a92d59 199
a63e0d5e 200// --- in aluminium parts ---
905263da 201 gMC->Gstpar(idtmed[1602],"CUTGAM", cutgam) ;
202 gMC->Gstpar(idtmed[1602],"CUTELE", cutele) ;
203 gMC->Gstpar(idtmed[1602],"BCUTE", cutgam); // BCUTE and BCUTM start from GUTGUM
204 gMC->Gstpar(idtmed[1602],"BCUTM", cutgam); // BCUTE and BCUTM start from GUTGUM
b13bbe81 205 gMC->Gstpar(idtmed[1602], "LOSS",3.) ;
206 gMC->Gstpar(idtmed[1602], "DRAY",1.) ;
905263da 207 gMC->Gstpar(idtmed[1602], "DCUTE", cutele) ;
208 gMC->Gstpar(idtmed[1602], "DCUTM", cutele) ;
b13bbe81 209
ffa6d63b 210// --- and finally thresholds for photons and electrons in the scintillator ---
905263da 211 gMC->Gstpar(idtmed[1601],"CUTGAM", cutgam) ;
212 gMC->Gstpar(idtmed[1601],"CUTELE", cutele) ;// 1MEV -> 0.1MEV; 15-aug-05
213 gMC->Gstpar(idtmed[1601],"BCUTE", cutgam); // BCUTE and BCUTM start from GUTGUM
214 gMC->Gstpar(idtmed[1601],"BCUTM", cutgam); // BCUTE and BCUTM start from GUTGUM
215 gMC->Gstpar(idtmed[1601], "LOSS",3.) ; // generate delta rays
216 gMC->Gstpar(idtmed[1601], "DRAY",1.) ;
217 gMC->Gstpar(idtmed[1601], "DCUTE", cutele) ;
218 gMC->Gstpar(idtmed[1601], "DCUTM", cutele) ;
219
220 // S steel -
221 gMC->Gstpar(idtmed[1603],"CUTGAM", cutgam);
222 gMC->Gstpar(idtmed[1603],"CUTELE", cutele);
223 gMC->Gstpar(idtmed[1603],"BCUTE", cutgam); // BCUTE and BCUTM start from GUTGUM
224 gMC->Gstpar(idtmed[1603],"BCUTM", cutgam); // BCUTE and BCUTM start from GUTGUM
225 // --- Generate explicitly delta rays
1963b290 226 gMC->Gstpar(idtmed[1603], "LOSS",3.);
227 gMC->Gstpar(idtmed[1603], "DRAY",1.);
905263da 228 gMC->Gstpar(idtmed[1603], "DCUTE", cutele) ;
229 gMC->Gstpar(idtmed[1603], "DCUTM", cutele) ;
1963b290 230
ab37d09c 231 //set constants for Birk's Law implentation
232 fBirkC0 = 1;
233 fBirkC1 = 0.013/dP;
234 fBirkC2 = 9.6e-6/(dP * dP);
235
2012850d 236}
f6019cda 237
f51151a0 238//____________________________________________________________________________
239void AliEMCAL::Digits2Raw()
240{
56088960 241 // convert digits of the current event to raw data
242 AliEMCALLoader * loader = dynamic_cast<AliEMCALLoader*>(fLoader) ;
f51151a0 243
244 // get the digits
00d03c2f 245 loader->LoadDigits("EMCAL");
56088960 246 TClonesArray* digits = loader->Digits() ;
f51151a0 247
248 if (!digits) {
249 Error("Digits2Raw", "no digits found !");
250 return;
251 }
252
56088960 253 // get the digitizer
254 loader->LoadDigitizer();
255 AliEMCALDigitizer * digitizer = dynamic_cast<AliEMCALDigitizer *>(loader->Digitizer()) ;
256
f51151a0 257
f51151a0 258 AliAltroBuffer* buffer = NULL;
259 Int_t prevDDL = -1;
14ce0a6e 260 Int_t adcValuesLow[fgkTimeBins];
261 Int_t adcValuesHigh[fgkTimeBins];
56088960 262
f51151a0 263 // loop over digits (assume ordered digits)
264 for (Int_t iDigit = 0; iDigit < digits->GetEntries(); iDigit++) {
56088960 265 AliEMCALDigit* digit = dynamic_cast<AliEMCALDigit *>(digits->At(iDigit)) ;
2d5d9e60 266 if (digit->GetAmp() < fgThreshold)
f51151a0 267 continue;
2d5d9e60 268 Int_t iDDL = digit->GetId() / fgChannelsPerDDL ;
269 // for each DDL id is numbered from 1 to fgChannelsperDDL -1
270 Int_t idDDL = digit->GetId() - iDDL * ( fgChannelsPerDDL - 1 ) ;
f51151a0 271 // new DDL
272 if (iDDL != prevDDL) {
273 // write real header and close previous file
274 if (buffer) {
275 buffer->Flush();
276 buffer->WriteDataHeader(kFALSE, kFALSE);
277 delete buffer;
278 }
279
280 // open new file and write dummy header
362c9d61 281 TString fileName(AliDAQ::DdlFileName("EMCAL",iDDL));
4c846604 282 buffer = new AliAltroBuffer(fileName.Data());
f51151a0 283 buffer->WriteDataHeader(kTRUE, kFALSE); //Dummy;
284
285 prevDDL = iDDL;
286 }
287
288 // out of time range signal (?)
56088960 289 if (digit->GetTimeR() > GetRawFormatTimeMax() ) {
f51151a0 290 buffer->FillBuffer(digit->GetAmp());
56088960 291 buffer->FillBuffer(GetRawFormatTimeBins() ); // time bin
f51151a0 292 buffer->FillBuffer(3); // bunch length
293 buffer->WriteTrailer(3, idDDL, 0, 0); // trailer
56088960 294
295 // calculate the time response function
f51151a0 296 } else {
56088960 297 Double_t energy = 0 ;
298 energy = digit->GetAmp() * digitizer->GetECAchannel() + digitizer->GetECApedestal() ;
299
300 Bool_t lowgain = RawSampledResponse(digit->GetTimeR(), energy, adcValuesHigh, adcValuesLow) ;
301
302 if (lowgain)
303 buffer->WriteChannel(iDDL, 0, fLowGainOffset,
2d5d9e60 304 GetRawFormatTimeBins(), adcValuesLow, fgThreshold);
56088960 305 else
306 buffer->WriteChannel(iDDL, 0, 0,
2d5d9e60 307 GetRawFormatTimeBins(), adcValuesHigh, fgThreshold);
56088960 308
f51151a0 309 }
310 }
56088960 311
f51151a0 312 // write real header and close last file
313 if (buffer) {
314 buffer->Flush();
315 buffer->WriteDataHeader(kFALSE, kFALSE);
316 delete buffer;
317 }
56088960 318
319 loader->UnloadDigits();
f51151a0 320}
321
2d5d9e60 322//____________________________________________________________________________
323void AliEMCAL::Raw2Digits(AliRawReader* reader)
324{
4800667c 325 // convert raw data of the current event to digits
ddca522a 326 GetGeometry();
2d5d9e60 327 AliEMCALLoader * loader = dynamic_cast<AliEMCALLoader*>(fLoader) ;
328
329 // get the digits
330 loader->CleanDigits(); // start from scratch
00d03c2f 331 loader->LoadDigits("EMCAL");
2d5d9e60 332 TClonesArray* digits = loader->Digits() ;
333 digits->Clear(); // yes, this is perhaps somewhat paranoid.. [clearing an extra time]
334
335 if (!digits) {
336 Error("Raw2Digits", "no digits found !");
337 return;
338 }
339 if (!reader) {
340 Error("Raw2Digits", "no raw reader found !");
341 return;
342 }
343
344 // and get the digitizer too
345 loader->LoadDigitizer();
346 AliEMCALDigitizer * digitizer = dynamic_cast<AliEMCALDigitizer *>(loader->Digitizer()) ;
347
348 // Use AliAltroRawStream to read the ALTRO format. No need to
349 // reinvent the wheel :-)
350 AliEMCALRawStream in(reader);
362c9d61 351 // Select EMCAL DDL's;
352 reader->Select("EMCAL");
2d5d9e60 353
354 // reading is from previously existing AliEMCALGetter.cxx
355 // ReadRaw method
356 Bool_t first = kTRUE ;
357
358 TF1 * signalF = new TF1("signal", RawResponseFunction, 0, GetRawFormatTimeMax(), 4);
359 signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero");
360
361 Int_t id = -1;
362 Bool_t lowGainFlag = kFALSE ;
363
364 Int_t idigit = 0 ;
365 Int_t amp = 0 ;
366 Double_t time = 0. ;
367 Double_t energy = 0. ;
368
369 TGraph * gLowGain = new TGraph(GetRawFormatTimeBins()) ;
370 TGraph * gHighGain= new TGraph(GetRawFormatTimeBins()) ;
371
372 while ( in.Next() ) { // EMCAL entries loop
373 if ( in.IsNewId() ) {
374 if (!first) {
375 FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time) ;
376
377 if (time == 0. && energy == 0.) {
378 amp = 0 ;
379 }
380 else {
381 amp = static_cast<Int_t>( (energy - digitizer->GetECApedestal()) / digitizer->GetECAchannel() + 0.5 ) ;
382 }
383
384 if (amp > 0) {
385 new((*digits)[idigit]) AliEMCALDigit( -1, -1, id, amp, time) ;
386 idigit++ ;
387 }
388 Int_t index ;
389 for (index = 0; index < GetRawFormatTimeBins(); index++) {
390 gLowGain->SetPoint(index, index * GetRawFormatTimeMax() / GetRawFormatTimeBins(), 0) ;
391 gHighGain->SetPoint(index, index * GetRawFormatTimeMax() / GetRawFormatTimeBins(), 0) ;
392 }
393 } // not first
394 first = kFALSE ;
395 id = in.GetId() ;
396 if (in.GetModule() == GetRawFormatLowGainOffset() ) {
397 lowGainFlag = kTRUE ;
398 }
399 else {
400 lowGainFlag = kFALSE ;
401 }
402 } // new Id?
403 if (lowGainFlag) {
404 gLowGain->SetPoint(in.GetTime(),
405 in.GetTime()* GetRawFormatTimeMax() / GetRawFormatTimeBins(),
406 in.GetSignal()) ;
407 }
408 else {
409 gHighGain->SetPoint(in.GetTime(),
410 in.GetTime() * GetRawFormatTimeMax() / GetRawFormatTimeBins(),
411 in.GetSignal() ) ;
412 }
413 } // EMCAL entries loop
414 digits->Sort() ;
415
416 delete signalF ;
417 delete gLowGain;
418 delete gHighGain ;
419
420 return ;
421}
422
423//____________________________________________________________________________
424void AliEMCAL::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time)
425{
426 // Fits the raw signal time distribution; from AliEMCALGetter
427
428 const Int_t kNoiseThreshold = 0 ;
429 Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
430 Double_t signal = 0., signalmax = 0. ;
431 energy = time = 0. ;
432
433 if (lowGainFlag) {
434 timezero1 = timezero2 = signalmax = timemax = 0. ;
435 signalF->FixParameter(0, GetRawFormatLowCharge()) ;
436 signalF->FixParameter(1, GetRawFormatLowGain()) ;
437 Int_t index ;
438 for (index = 0; index < GetRawFormatTimeBins(); index++) {
439 gLowGain->GetPoint(index, time, signal) ;
440 if (signal > kNoiseThreshold && timezero1 == 0.)
441 timezero1 = time ;
442 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
443 timezero2 = time ;
444 if (signal > signalmax) {
445 signalmax = signal ;
446 timemax = time ;
447 }
448 }
449 signalmax /= RawResponseFunctionMax(GetRawFormatLowCharge(),
450 GetRawFormatLowGain()) ;
451 if ( timezero1 + GetRawFormatTimePeak() < GetRawFormatTimeMax() * 0.4 ) { // else its noise
452 signalF->SetParameter(2, signalmax) ;
453 signalF->SetParameter(3, timezero1) ;
454 gLowGain->Fit(signalF, "QRON", "", 0., timezero2); //, "QRON") ;
455 energy = signalF->GetParameter(2) ;
456 time = signalF->GetMaximumX() - GetRawFormatTimePeak() - GetRawFormatTimeTrigger() ;
457 }
458 } else {
459 timezero1 = timezero2 = signalmax = timemax = 0. ;
460 signalF->FixParameter(0, GetRawFormatHighCharge()) ;
461 signalF->FixParameter(1, GetRawFormatHighGain()) ;
462 Int_t index ;
463 for (index = 0; index < GetRawFormatTimeBins(); index++) {
464 gHighGain->GetPoint(index, time, signal) ;
465 if (signal > kNoiseThreshold && timezero1 == 0.)
466 timezero1 = time ;
467 if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
468 timezero2 = time ;
469 if (signal > signalmax) {
470 signalmax = signal ;
471 timemax = time ;
472 }
473 }
474 signalmax /= RawResponseFunctionMax(GetRawFormatHighCharge(),
475 GetRawFormatHighGain()) ;;
476 if ( timezero1 + GetRawFormatTimePeak() < GetRawFormatTimeMax() * 0.4 ) { // else its noise
477 signalF->SetParameter(2, signalmax) ;
478 signalF->SetParameter(3, timezero1) ;
479 gHighGain->Fit(signalF, "QRON", "", 0., timezero2) ;
480 energy = signalF->GetParameter(2) ;
481 time = signalF->GetMaximumX() - GetRawFormatTimePeak() - GetRawFormatTimeTrigger() ;
482 }
483 }
484
485 return;
486}
487
8367ce9a 488//____________________________________________________________________________
489void AliEMCAL::Hits2SDigits()
490{
491// create summable digits
492
ddca522a 493 GetGeometry();
4d33c797 494 AliEMCALSDigitizer emcalDigitizer(fLoader->GetRunLoader()->GetFileName().Data()) ;
495 emcalDigitizer.SetEventRange(0, -1) ; // do all the events
496 emcalDigitizer.ExecuteTask() ;
da480a28 497}
498
8367ce9a 499//____________________________________________________________________________
5dee926e 500
8367ce9a 501AliLoader* AliEMCAL::MakeLoader(const char* topfoldername)
502{
503//different behaviour than standard (singleton getter)
504// --> to be discussed and made eventually coherent
505 fLoader = new AliEMCALLoader(GetName(),topfoldername);
506 return fLoader;
507}
508
046ae904 509//__________________________________________________________________
510Double_t AliEMCAL::RawResponseFunction(Double_t *x, Double_t *par)
511{
512 // Shape of the electronics raw reponse:
56088960 513 // It is a semi-gaussian, 2nd order Gamma function of the general form
514 // v(t) = n**n * Q * A**n / C *(t/tp)**n * exp(-n * t/tp) with
515 // tp : peaking time par[0]
516 // n : order of the function
517 // C : integrating capacitor in the preamplifier
518 // A : open loop gain of the preamplifier
519 // Q : the total APD charge to be measured Q = C * energy
046ae904 520
56088960 521 Double_t signal ;
522 Double_t xx = x[0] - ( fgTimeTrigger + par[3] ) ;
046ae904 523
56088960 524 if (xx < 0 || xx > fgTimeMax)
525 signal = 0. ;
526 else {
527 Double_t fac = par[0] * TMath::Power(fgOrder, fgOrder) * TMath::Power(par[1], fgOrder) / fgCapa ;
528 signal = fac * par[2] * TMath::Power(xx / fgTimePeak, fgOrder) * TMath::Exp(-fgOrder * (xx / fgTimePeak)) ;
529 }
530 return signal ;
046ae904 531}
532
533//__________________________________________________________________
56088960 534Double_t AliEMCAL::RawResponseFunctionMax(Double_t charge, Double_t gain)
535{
14ce0a6e 536 //compute the maximum of the raw response function and return
56088960 537 return ( charge * TMath::Power(fgOrder, fgOrder) * TMath::Power(gain, fgOrder)
538 / ( fgCapa * TMath::Exp(fgOrder) ) );
539
540}
541//__________________________________________________________________
542Bool_t AliEMCAL::RawSampledResponse(
543const Double_t dtime, const Double_t damp, Int_t * adcH, Int_t * adcL) const
046ae904 544{
545 // for a start time dtime and an amplitude damp given by digit,
56088960 546 // calculates the raw sampled response AliEMCAL::RawResponseFunction
046ae904 547
548 const Int_t kRawSignalOverflow = 0x3FF ;
56088960 549 Bool_t lowGain = kFALSE ;
550
551 TF1 signalF("signal", RawResponseFunction, 0, GetRawFormatTimeMax(), 4);
552
553 for (Int_t iTime = 0; iTime < GetRawFormatTimeBins(); iTime++) {
554 signalF.SetParameter(0, GetRawFormatHighCharge() ) ;
555 signalF.SetParameter(1, GetRawFormatHighGain() ) ;
556 signalF.SetParameter(2, damp) ;
557 signalF.SetParameter(3, dtime) ;
558 Double_t time = iTime * GetRawFormatTimeMax() / GetRawFormatTimeBins() ;
559 Double_t signal = signalF.Eval(time) ;
560 if ( static_cast<Int_t>(signal+0.5) > kRawSignalOverflow ){ // larger than 10 bits
561 signal = kRawSignalOverflow ;
562 lowGain = kTRUE ;
563 }
564 adcH[iTime] = static_cast<Int_t>(signal + 0.5) ;
565
566 signalF.SetParameter(0, GetRawFormatLowCharge() ) ;
567 signalF.SetParameter(1, GetRawFormatLowGain() ) ;
568 signal = signalF.Eval(time) ;
569 if ( static_cast<Int_t>(signal+0.5) > kRawSignalOverflow) // larger than 10 bits
570 signal = kRawSignalOverflow ;
571 adcL[iTime] = static_cast<Int_t>(0.5 + signal ) ;
572
046ae904 573 }
56088960 574 return lowGain ;
046ae904 575}