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