AliRoot Core  edcc906 (edcc906)
AliEMCALDigitizer.cxx
Go to the documentation of this file.
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 #include <TROOT.h>
17 #include <TTree.h>
18 #include <TSystem.h>
19 #include <TBenchmark.h>
20 #include <TBrowser.h>
21 #include <TObjectTable.h>
22 #include <TRandom.h>
23 #include <TF1.h>
24 #include <cassert>
25 
26 // --- AliRoot header files ---
27 #include "AliLog.h"
28 #include "AliRun.h"
29 #include "AliDigitizationInput.h"
30 #include "AliRunLoader.h"
31 #include "AliCDBManager.h"
32 #include "AliCDBEntry.h"
33 #include "AliEMCALDigit.h"
34 #include "AliEMCAL.h"
35 #include "AliEMCALLoader.h"
36 #include "AliEMCALDigitizer.h"
37 #include "AliEMCALSDigitizer.h"
38 #include "AliEMCALGeometry.h"
39 #include "AliEMCALCalibData.h"
40 #include "AliEMCALCalibTime.h"
41 #include "AliEMCALSimParam.h"
43 #include "AliCaloCalibPedestal.h"
44 
45 namespace
46 {
47  Double_t HeavisideTheta(Double_t x)
48  {
49  Double_t signal = 0.;
50 
51  if (x > 0.) signal = 1.;
52 
53  return signal;
54  }
55 
56  Double_t AnalogFastORFunction(Double_t *x, Double_t *par)
57  {
58  Double_t v0 = par[0];
59  Double_t t0 = par[1];
60  Double_t tr = par[2];
61 
62  Double_t R1 = 1000.;
63  Double_t C1 = 33e-12;
64  Double_t R2 = 1800;
65  Double_t C2 = 22e-12;
66 
67  Double_t t = x[0];
68 
69  return (((0.8*(-((TMath::Power(C1,2)*C2*TMath::Power(TMath::E(),(-t + t0)/(C1*R1))*
70  TMath::Power(R1,2)*R2)/(C1*R1 - C2*R2)) +
71  C1*C2*R1*R2*(1 - (C2*TMath::Power(TMath::E(),(-t + t0)/(C2*R2))*R2)/(-(C1*R1) + C2*R2)))*v0*
72  HeavisideTheta(t - t0))/tr
73  - (0.8*(C1*C2*R1*R2 -
74  (TMath::Power(C1,2)*C2*TMath::Power(TMath::E(),(-1.*t + t0 + 1.25*tr)/(C1*R1))*
75  TMath::Power(R1,2)*R2)/(C1*R1 - C2*R2) +
76  (C1*TMath::Power(C2,2)*TMath::Power(TMath::E(),(-1.*t + t0 + 1.25*tr)/(C2*R2))*
77  R1*TMath::Power(R2,2))/(C1*R1 - C2*R2))*v0*
78  HeavisideTheta(t - t0 - 1.25*tr))/tr)/(C2*R1));
79  }
80 }
81 
83 ClassImp(AliEMCALDigitizer) ;
85 
88 //____________________________________________________________________________
90  : AliDigitizer("",""),
91  fDefaultInit(kTRUE),
92  fDigitsInRun(0),
93  fInit(0),
94  fInput(0),
95  fInputFileNames(0x0),
96  fEventNames(0x0),
97  fDigitThreshold(0),
98  fMeanPhotonElectron(0),
99  fGainFluctuations(0),
100  fPinNoise(0),
101  fTimeNoise(0),
102  fTimeDelay(0),
103  fTimeDelayFromOCDB(0),
104  fTimeResolutionPar0(0),
105  fTimeResolutionPar1(0),
106  fADCchannelEC(0),
107  fADCpedestalEC(0),
108  fADCchannelECDecal(0),
109  fTimeChannel(0),
110  fTimeChannelDecal(0),
111  fNADCEC(0),
112  fEventFolderName(""),
113  fFirstEvent(0),
114  fLastEvent(0),
115  fCalibData(0x0),
116  fCalibTime(0x0),
117  fSDigitizer(0x0)
118 {
119  InitParameters() ;
120  fDigInput = 0 ; // We work in the standalone mode
121 }
122 
125 //____________________________________________________________________________
126 AliEMCALDigitizer::AliEMCALDigitizer(TString alirunFileName, TString eventFolderName)
127  : AliDigitizer("EMCALDigitizer", alirunFileName),
128  fDefaultInit(kFALSE),
129  fDigitsInRun(0),
130  fInit(0),
131  fInput(0),
132  fInputFileNames(0),
133  fEventNames(0),
134  fDigitThreshold(0),
137  fPinNoise(0),
138  fTimeNoise(0),
139  fTimeDelay(0),
143  fADCchannelEC(0),
144  fADCpedestalEC(0),
146  fTimeChannel(0),
148  fNADCEC(0),
149  fEventFolderName(eventFolderName),
150  fFirstEvent(0),
151  fLastEvent(0),
152  fCalibData(0x0),
153  fCalibTime(0x0),
154  fSDigitizer(0x0)
155 {
156  InitParameters() ;
157  Init() ;
158  fDigInput = 0 ; // We work in the standalone mode
159 }
160 
163 //____________________________________________________________________________
165  : AliDigitizer(d.GetName(),d.GetTitle()),
168  fInit(d.fInit),
169  fInput(d.fInput),
175  fPinNoise(d.fPinNoise),
185  fNADCEC(d.fNADCEC),
192 { }
193 
197 //____________________________________________________________________________
199  : AliDigitizer(rd,"EMCALDigitizer"),
200  fDefaultInit(kFALSE),
201  fDigitsInRun(0),
202  fInit(0),
203  fInput(0),
204  fInputFileNames(0),
205  fEventNames(0),
206  fDigitThreshold(0),
209  fPinNoise(0.),
210  fTimeNoise(0.),
211  fTimeDelay(0.),
212  fTimeDelayFromOCDB(0.),
215  fADCchannelEC(0),
216  fADCpedestalEC(0),
218  fTimeChannel(0),
219  fTimeChannelDecal(0),
220  fNADCEC(0),
221  fEventFolderName(0),
222  fFirstEvent(0),
223  fLastEvent(0),
224  fCalibData(0x0),
225  fCalibTime(0x0),
226  fSDigitizer(0x0)
227 {
228  fDigInput = rd ;
230  SetTitle(dynamic_cast<AliStream*>(fDigInput->GetInputStream(0))->GetFileName(0));
231  InitParameters() ;
232 }
233 
236 //____________________________________________________________________________
238 {
239  delete [] fInputFileNames ;
240  delete [] fEventNames ;
241  if (fSDigitizer) delete fSDigitizer;
242 }
243 
257 //____________________________________________________________________________
259 {
261  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
262 
263  if(!emcalLoader)
264  {
265  AliFatal("EMCALLoader is NULL!") ;
266  return; // not needed but in case coverity complains ...
267  }
268 
269  Int_t readEvent = event ;
270  if (fDigInput) // fDigInput is data member from AliDigitizer
271  readEvent = dynamic_cast<AliStream*>(fDigInput->GetInputStream(0))->GetCurrentEventNumber() ;
272 
273  AliDebug(1,Form("Adding event %d from input stream 0 %s %s",
274  readEvent, GetTitle(), fEventFolderName.Data())) ;
275 
276  rl->GetEvent(readEvent);
277 
278  TClonesArray * digits = emcalLoader->Digits() ;
279  digits->Clear("C") ; //correct way to clear array when memory is
280  //allocated by objects stored in array
281 
282  // Load Geometry
283  if (!rl->GetAliRun())
284  {
285  AliFatal("Could not get AliRun from runLoader");
286  return; // not needed but in case coverity complains ...
287  }
288 
289  AliEMCAL * emcal = (AliEMCAL*)rl->GetAliRun()->GetDetector("EMCAL");
290  AliEMCALGeometry *geom = emcal->GetGeometry();
291  static int nEMC = geom->GetNCells();//max number of digits possible
292 
293  AliDebug(1,Form("nEMC %i (number cells in EMCAL) | %s \n", nEMC, geom->GetName()));
294 
295  digits->Expand(nEMC) ;
296 
297  // RS create a digitizer on the fly
298  if (!fSDigitizer) fSDigitizer = new AliEMCALSDigitizer(rl->GetFileName().Data());
299  fSDigitizer->SetEventRange(0, -1) ;
300 
301  //-------------------------------------------------------
302  //take all the inputs to add together and load the SDigits
303  TObjArray * sdigArray = new TObjArray(fInput) ;
304  sdigArray->AddAt(emcalLoader->SDigits(), 0) ;
305 
306  Int_t i ;
307  Int_t embed = kFALSE;
308  for(i = 1 ; i < fInput ; i++)
309  {
310  TString tempo(fEventNames[i]) ;
311  tempo += i ;
312 
314 
315  if (!rl2)
316  rl2 = AliRunLoader::Open(fInputFileNames[i], tempo) ;
317 
318  if(!rl2)
319  {
320  AliFatal("Run Loader of second event not available!");
321  return; // not needed but in case coverity complains ...
322  }
323 
324  if (fDigInput)
325  readEvent = dynamic_cast<AliStream*>(fDigInput->GetInputStream(i))->GetCurrentEventNumber() ;
326 
327  AliInfo(Form("Adding event %d from input stream %d %s %s", readEvent, i, fInputFileNames[i].Data(), tempo.Data())) ;
328 
329  rl2->LoadSDigits();
330  // rl2->LoadDigits();
331  rl2->GetEvent(readEvent);
332 
333  if(!rl2->GetDetectorLoader("EMCAL"))
334  {
335  AliFatal("Loader of second input not found");
336  return; // not needed but in case coverity complains ...
337  }
338 
339  AliEMCALLoader *emcalLoader2 = dynamic_cast<AliEMCALLoader*>(rl2->GetDetectorLoader("EMCAL"));
340 
341  if(!emcalLoader2)
342  {
343  AliFatal("EMCAL Loader of second event not available!");
344  return; // not needed but in case coverity complains ...
345  }
346 
347  //Merge 2 simulated sdigits
348  if(!emcalLoader2->SDigits()) continue;
349 
350  TClonesArray* sdigits2 = emcalLoader2->SDigits();
351  sdigArray->AddAt(sdigits2, i) ;
352 
353  // Check if first sdigit is of embedded type, if so, handle the sdigits differently:
354  // do not smear energy of embedded, do not add noise to any sdigits
355  if( sdigits2->GetEntriesFast() <= 0 ) continue;
356 
357  //printf("Merged digit type: %d\n",dynamic_cast<AliEMCALDigit*> (sdigits2->At(0))->GetType());
358  AliEMCALDigit * digit2 = dynamic_cast<AliEMCALDigit*> (sdigits2->At(0));
359  if( digit2 && digit2->GetType()==AliEMCALDigit::kEmbedded ) embed = kTRUE;
360 
361  }// input loop
362 
363  //--------------------------------
364  //Find the first tower with signal
365  Int_t nextSig = nEMC + 1 ;
366  TClonesArray * sdigits ;
367  for(i = 0 ; i < fInput ; i++)
368  {
369  if(i > 0 && embed) continue;
370 
371  sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
372  if(!sdigits)
373  {
374  AliDebug(1,"Null sdigit pointer");
375  continue;
376  }
377 
378  if (sdigits->GetEntriesFast() <= 0 )
379  {
380  AliDebug(1, "No sdigits entries");
381  continue;
382  }
383 
384  AliEMCALDigit *sd = dynamic_cast<AliEMCALDigit *>(sdigits->At(0));
385  if(!sd)
386  {
387  AliDebug(1, "NULL sdigit pointer");
388  continue;
389  }
390 
391  Int_t curNext = sd->GetId() ;
392  if(curNext < nextSig)
393  nextSig = curNext ;
394  AliDebug(1,Form("input %i : #sdigits %i \n",i, sdigits->GetEntriesFast()));
395 
396  }// input loop
397 
398  AliDebug(1,Form("FIRST tower with signal %i \n", nextSig));
399 
400  TArrayI index(fInput) ;
401  index.Reset() ; //Set all indexes to zero
402 
403  AliEMCALDigit * digit ;
404  AliEMCALDigit * curSDigit ;
405 
406  //---------------------------------------------
407  //Put Noise contribution, smear time and energy
408  Float_t timeResolution = 0;
409  Int_t absID = -1 ;
410  for(absID = 0; absID < nEMC; absID++)
411  {
412  Float_t energy = 0 ;
413 
414  // amplitude set to zero, noise will be added later
415  Float_t noiseTime = 0.;
416  if(!embed) noiseTime = TimeOfNoise(); //No need for embedded events?
417  new((*digits)[absID]) AliEMCALDigit( -1, -1, absID, 0., noiseTime,kFALSE); // absID-1->absID
418  //look if we have to add signal?
419  digit = dynamic_cast<AliEMCALDigit *>(digits->At(absID)); // absID-1->absID
420 
421  if (!digit)
422  {
423  AliDebug(1,"Digit pointer is null");
424  continue;
425  }
426 
427  if(absID==nextSig)
428  {
429  // Calculate time as time of the largest digit
430  Float_t time = digit->GetTime() ;
431  Float_t aTime= digit->GetAmplitude() ;
432 
433  // loop over input
434  Int_t nInputs = fInput;
435  if(embed) nInputs = 1; // In case of embedding, merge later real digits, do not smear energy and time of data
436  for(i = 0; i< nInputs ; i++)
437  {
438  //loop over (possible) merge sources
439  TClonesArray* sdtclarr = dynamic_cast<TClonesArray *>(sdigArray->At(i));
440  if(sdtclarr)
441  {
442  Int_t sDigitEntries = sdtclarr->GetEntriesFast();
443 
444  if(sDigitEntries > index[i] ) curSDigit = dynamic_cast<AliEMCALDigit*>(sdtclarr->At(index[i])) ;
445  else curSDigit = 0 ;
446 
447  //May be several digits will contribute from the same input
448  while(curSDigit && (curSDigit->GetId() == absID))
449  {
450  //Shift primary to separate primaries belonging different inputs
451  Int_t primaryoffset = i ;
452  if(fDigInput) primaryoffset = fDigInput->GetMask(i) ;
453  curSDigit->ShiftPrimary(primaryoffset) ;
454 
455  if(curSDigit->GetAmplitude()>aTime)
456  {
457  aTime = curSDigit->GetAmplitude();
458  time = curSDigit->GetTime();
459  }
460 
461  *digit = *digit + *curSDigit ; //adds amplitudes of each digit
462 
463  index[i]++ ;
464 
465  if( sDigitEntries > index[i] ) curSDigit = dynamic_cast<AliEMCALDigit*>(sdtclarr->At(index[i])) ;
466  else curSDigit = 0 ;
467  }// while
468  }// source exists
469  }// loop over merging sources
470 
471  //Here we convert the summed amplitude to an energy in GeV only for simulation or mixing of simulations
472  energy = fSDigitizer->Calibrate(digit->GetAmplitude()) ; // GeV
473 
474  // add fluctuations for photo-electron creation
475  // corrected fluctuations after comparison with beam test, Paraskevi Ganoti (06/11/2011)
476  Float_t fluct = static_cast<Float_t>((energy*fMeanPhotonElectron)/fGainFluctuations);
477  energy *= static_cast<Float_t>(gRandom->Poisson(fluct)) / fluct ;
478 
479  //calculate and set time
480  digit->SetTime(time) ;
481 
482  //Find next signal module
483  nextSig = nEMC + 1 ;
484  for(i = 0 ; i < nInputs ; i++)
485  {
486  sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
487 
488  if(sdigits)
489  {
490  Int_t curNext = nextSig ;
491  if(sdigits->GetEntriesFast() > index[i])
492  {
493  AliEMCALDigit * tmpdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(index[i]));
494  if ( tmpdigit ) curNext = tmpdigit->GetId() ;
495  }
496 
497  if(curNext < nextSig) nextSig = curNext ;
498  }// sdigits exist
499  } // input loop
500 
501  }//absID==nextSig
502 
503  // add the noise now, no need for embedded events with real data
504  if(!embed)
505  energy += gRandom->Gaus(0., fPinNoise) ;
506 
507  // JLK 26-June-2008
508  //Now digitize the energy according to the fSDigitizer method,
509  //which merely converts the energy to an integer. Later we will
510  //check that the stored value matches our allowed dynamic ranges
511  digit->SetAmplitude(fSDigitizer->Digitize(energy)) ;
512 
513  //Set time resolution with final energy
514  timeResolution = GetTimeResolution(energy);
515  digit->SetTime(gRandom->Gaus(digit->GetTime(),timeResolution) ) ;
516  AliDebug(10,Form(" absID %5i energy %f nextSig %5i\n",
517  absID, energy, nextSig));
518  //Add delay to time
519  digit->SetTime(digit->GetTime()) ;
520 
521  } // for(absID = 0; absID < nEMC; absID++)
522 
523  //---------------------------------------------------------
524  //Embed simulated amplitude (and time?) to real data digits
525  if ( embed )
526  {
527  for(Int_t input = 1; input<fInput; input++)
528  {
529  TClonesArray *realDigits = dynamic_cast<TClonesArray*> (sdigArray->At(input));
530  if(!realDigits)
531  {
532  AliDebug(1,"No sdigits to merge\n");
533  continue;
534  }
535 
536  for(Int_t i2 = 0 ; i2 < realDigits->GetEntriesFast() ; i2++)
537  {
538  AliEMCALDigit * digit2 = dynamic_cast<AliEMCALDigit*>( realDigits->At(i2) ) ;
539  if ( !digit2 ) continue;
540 
541  digit = dynamic_cast<AliEMCALDigit*>( digits->At(digit2->GetId()) ) ;
542  if ( !digit ) continue;
543 
544  // Put the embedded cell energy in same units as simulated sdigits -> transform to energy units
545  // and multiply to get a big int.
546  Float_t time2 = digit2->GetTime();
547  Float_t e2 = digit2->GetAmplitude();
548  CalibrateADCTime(e2,time2,digit2->GetId());
549  Float_t amp2 = fSDigitizer->Digitize(e2);
550 
551  Float_t e0 = digit ->GetAmplitude();
552  if(e0>0.01)
553  AliDebug(1,Form("digit 1: Abs ID %d, amp %f, type %d, time %e; digit2: Abs ID %d, amp %f, type %d, time %e\n",
554  digit ->GetId(),digit ->GetAmplitude(), digit ->GetType(), digit->GetTime(),
555  digit2->GetId(),amp2, digit2->GetType(), time2 ));
556 
557  // Sum amplitudes, change digit amplitude
558  digit->SetAmplitude( digit->GetAmplitude() + amp2);
559 
560  // Rough assumption, assign time of the largest of the 2 digits,
561  // data or signal to the final digit.
562  if(amp2 > digit->GetAmplitude()) digit->SetTime(time2);
563 
564  // Mark the new digit as embedded
566 
567  if(digit2->GetAmplitude()>0.01 && e0> 0.01 )
568  AliDebug(1,Form("Embedded digit: Abs ID %d, amp %f, type %d\n",
569  digit->GetId(), digit->GetAmplitude(), digit->GetType()));
570  }//loop digit 2
571  }//input loop
572  }//embed
573 
574  //JLK is it better to call Clear() here?
575  delete sdigArray ; //We should not delete its contents
576 
577  //------------------------------
578  // Remove digits below ADC thresholds or
579  // dead in OCDB, decalibrate them
580  //
581 
582  Float_t ampADC = 0;
583  Float_t time = 0;
584  Int_t idigit = 0;
585  for(i = 0 ; i < nEMC ; i++)
586  {
587  digit = dynamic_cast<AliEMCALDigit*>( digits->At(i) ) ;
588  if ( !digit )
589  {
590  digits->RemoveAt(i) ; // It should not happen, but just in case
591  continue;
592  }
593 
594  // Get the time and energy before calibration
595  ampADC = fSDigitizer->Calibrate(digit->GetAmplitude()) ;
596 
597  time = digit->GetTime();
598 
599  // Then digitize energy (GeV to ADC) and shift time
600  // using the calibration constants of the OCDB
601  DigitizeEnergyTime(ampADC, time, digit->GetId()) ;
602 
603  // Skip digits with below 3 ADC or found dead in OCDB
604  if(ampADC < fDigitThreshold || IsDead(digit->GetId()))
605  {
606  digits->RemoveAt(i) ;
607  continue;
608  }
609 
610  // Set digit final values
611  digit->SetIndexInList(idigit++) ;
612  digit->SetAmplitude(ampADC) ;
613  digit->SetTime(time);
614 
615  // High Gain or Low Gain
616  if ( digit->GetType() != AliEMCALDigit::kEmbedded )
617  {
618  if ( digit->GetAmplitude() > CaloConstants::OVERFLOWCUT )
619  digit->SetType(AliEMCALDigit::kLG);
620  else
621  digit->SetType(AliEMCALDigit::kHG);
622  }
623 
624  } // digit loop
625 
626  digits->Compress() ;
627 
628  Int_t ndigits = digits->GetEntriesFast();
629 
630  if(idigit != ndigits)
631  AliFatal(Form("Total number of digits in array %d different to expected %d",ndigits,idigit));
632 
633  AliDebug(1,Form("Number of recorded digits is %d",ndigits));
634 }
635 
647 //_____________________________________________________________________
648 void AliEMCALDigitizer::DigitizeEnergyTime(Float_t & energy, Float_t & time, Int_t absId)
649 {
650  // Load Geometry and cell indeces
652 
653  if (geom==0)
654  {
655  AliFatal("Did not get geometry from EMCALLoader");
656  return;
657  }
658 
659  Int_t iSupMod = -1;
660  Int_t nModule = -1;
661  Int_t nIphi = -1;
662  Int_t nIeta = -1;
663  Int_t iphi = -1;
664  Int_t ieta = -1;
665 
666  Bool_t bCell = geom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
667  if(!bCell) Error("DigitizeEnergyTime","Wrong cell id number : absId %i ", absId) ;
668 
669  geom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
670 
671  // Recover parameters from OCDB for this channel
672  if(fCalibData)
673  {
674  // Energy
675  fADCpedestalEC = fCalibData->GetADCpedestal (iSupMod,ieta,iphi);
676  fADCchannelEC = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
677  fADCchannelECDecal = fCalibData->GetADCchannelDecal (iSupMod,ieta,iphi);
678  }
679 
680  if(fCalibTime)
681  {
682  // Time
683  // Recover parameters for bunch crossing number equal to 0
684  // (has simulation different bunch crossings stored? not for the moment)
685  // Time stored in ns, pass to ns
686  fTimeChannel = fCalibTime->GetTimeChannel (iSupMod,ieta,iphi,0) * 1e-9;
687  fTimeChannelDecal = fCalibTime->GetTimeChannelDecal(iSupMod,ieta,iphi) * 1e-9;
688  }
689 
690  // Apply calibration to get ADC counts and partial decalibration as especified in OCDB
691  energy = (energy + fADCpedestalEC)/fADCchannelEC/fADCchannelECDecal ;
692 
693  if ( energy > fNADCEC ) energy = fNADCEC ;
694 
695  // Apply shift to time, if requested and calibration parameter is available,
696  // if not, apply fix shift
697  if ( fTimeDelayFromOCDB )
699  else
700  time += fTimeDelay;
701 }
702 
707 //_____________________________________________________________________
709 {
710  if ( !fCalibData ) return ;
711 
712  // Load Geometry
714 
715  if (!geom)
716  {
717  AliFatal("Did not get geometry from EMCALLoader");
718  return;
719  }
720 
721  // Recover the digit location in row-column-SM
722  Int_t absId = digit->GetId();
723  Int_t iSupMod = -1;
724  Int_t nModule = -1;
725  Int_t nIphi = -1;
726  Int_t nIeta = -1;
727  Int_t iphi = -1;
728  Int_t ieta = -1;
729 
730  Bool_t bCell = geom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
731  if (!bCell) Error("Decalibrate","Wrong cell id number : absId %i ", absId) ;
732 
733  geom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
734 
735  // Now decalibrate
736  Float_t adcChannel = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
737  Float_t adcChannelOnline = fCalibData->GetADCchannelOnline(iSupMod,ieta,iphi);
738  //printf("calib param for (SM%d,col%d,row%d): %1.4f - online param: %1.4f \n",iSupMod,ieta,iphi,adcChannel,adcChannelOnline);
739  Float_t factor = 1./(adcChannel/adcChannelOnline);
740 
741  *digit = *digit * factor;
742 }
743 
756 //_____________________________________________________________________
757 void AliEMCALDigitizer::CalibrateADCTime(Float_t & adc, Float_t & time, const Int_t absId)
758 {
759  // Load Geometry
761 
762  if (!geom)
763  {
764  AliFatal("Did not get geometry from EMCALLoader");
765  return;
766  }
767 
768  Int_t iSupMod = -1;
769  Int_t nModule = -1;
770  Int_t nIphi = -1;
771  Int_t nIeta = -1;
772  Int_t iphi = -1;
773  Int_t ieta = -1;
774 
775  Bool_t bCell = geom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
776  if(!bCell) Error("CalibrateADCTime","Wrong cell id number : absId %i ", absId) ;
777 
778  geom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
779 
780  // Energy calibration
781  if(fCalibData)
782  {
783  fADCpedestalEC = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
784  fADCchannelEC = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
785  }
786 
787  adc = adc * fADCchannelEC - fADCpedestalEC;
788 
789  // Time calibration
790  // Assign bunch crossing number equal to 0 (has simulation different bunch crossings? Not for the moment)
792  fTimeChannel = fCalibTime->GetTimeChannel(iSupMod,ieta,iphi,0) * 1e-9; // pass from ns to s
793 
794  time -= fTimeChannel;
795 }
796 
803 //____________________________________________________________________________
804 void AliEMCALDigitizer::Digitize(Option_t *option)
805 {
806  if (!fInit)
807  {
808  // to prevent overwrite existing file
809  Error( "Digitize", "Give a version name different from %s", fEventFolderName.Data() ) ;
810  return ;
811  }
812 
813  if (strstr(option,"print"))
814  {
815  Print();
816  return ;
817  }
818 
819  if(strstr(option,"tim"))
820  gBenchmark->Start("EMCALDigitizer");
821 
823 
824  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
825  if(!emcalLoader)
826  {
827  AliFatal("Did not get the Loader");
828  return; // coverity
829  }
830 
831  if (fLastEvent == -1)
832  fLastEvent = rl->GetNumberOfEvents() - 1 ;
833  else if (fDigInput)
834  fLastEvent = fFirstEvent ; // what is this ??
835 
836  Int_t nEvents = fLastEvent - fFirstEvent + 1;
837  Int_t ievent = -1;
838 
839  AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
840  if(!emcal)
841  {
842  AliFatal("Did not get the AliEMCAL pointer");
843  return; // coverity
844  }
845 
846  AliEMCALGeometry *geom = emcal->GetGeometry();
847  if(!geom)
848  {
849  AliFatal("Geometry pointer null");
850  return; // fix for coverity
851  }
852 
853  const Int_t nTRU = geom->GetNTotalTRU();
854  TClonesArray* digitsTMP = new TClonesArray("AliEMCALDigit", nTRU*96);
855  TClonesArray* digitsTRG = new TClonesArray("AliEMCALTriggerRawDigit", nTRU*96);
856  rl->LoadSDigits("EMCAL");
857 
858  for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++)
859  {
860  rl->GetEvent(ievent);
861 
862  Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
863 
864  WriteDigits() ;
865 
866  //Trigger Digits
867  //-------------------------------------
868 
869  Digits2FastOR(digitsTMP, digitsTRG);
870 
871  WriteDigits(digitsTRG);
872 
873  (emcalLoader->TreeD())->Fill();
874 
875  emcalLoader->WriteDigits("OVERWRITE");
876 
877  Unload();
878 
879  digitsTRG ->Clear("C");
880  digitsTMP ->Clear("C");
881 
882  //-------------------------------------
883 
884  if(strstr(option,"deb"))
885  PrintDigits(option);
886  if(strstr(option,"table")) gObjectTable->Print();
887 
888  //increment the total number of Digits per run
889  fDigitsInRun += emcalLoader->Digits()->GetEntriesFast() ;
890  }//loop
891 
892  delete digitsTMP;
893  delete digitsTRG;
894 
895  if(strstr(option,"tim"))
896  {
897  gBenchmark->Stop("EMCALDigitizer");
898  Float_t cputime = gBenchmark->GetCpuTime("EMCALDigitizer");
899  Float_t avcputime = cputime;
900  if(nEvents==0) avcputime = 0 ;
901  AliInfo(Form("Digitize: took %f seconds for Digitizing %f seconds per event", cputime, avcputime)) ;
902  }
903 }
904 
910 //__________________________________________________________________
911 Float_t AliEMCALDigitizer::GetTimeResolution(Float_t energy) const
912 {
913 
914  Float_t res = -1;
915  if (energy > 0)
916  {
917  res = TMath::Sqrt(fTimeResolutionPar0 +
918  fTimeResolutionPar1/(energy*energy) );
919  }
920 
921  // parametrization above is for ns. Convert to seconds:
922  return res*1e-9;
923 }
924 
932 //____________________________________________________________________________
933 void AliEMCALDigitizer::Digits2FastOR(TClonesArray* digitsTMP, TClonesArray* digitsTRG)
934 {
935  AliRunLoader *runLoader = AliRunLoader::Instance();
936 
937  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL"));
938  if (!emcalLoader) AliFatal("Did not get the Loader");
939 
941  if(!geom)
942  {
943  AliFatal("Geometry pointer null");
944  return; // fix for coverity
945  }
946 
947  // build FOR from simulated digits
948  // and xfer to the corresponding TRU input (mapping)
949 
950  TClonesArray* sdigits = emcalLoader->SDigits();
951 
952  TClonesArray *digits = (TClonesArray*)sdigits->Clone();
953 
954  AliDebug(999,Form("=== %d SDigits to trigger digits ===",digits->GetEntriesFast()));
955 
956  TIter NextDigit(digits);
957  while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit())
958  {
959  if (IsDead(digit)) continue;
960 
961  DecalibrateTrigger(digit);
962 
963  Int_t id = digit->GetId();
964 
965  Int_t trgid;
966  if (geom->GetFastORIndexFromCellIndex(id , trgid))
967  {
968  AliDebug(1,Form("trigger digit id: %d from cell id: %d\n",trgid,id));
969 
970  AliEMCALDigit* d = static_cast<AliEMCALDigit*>(digitsTMP->At(trgid));
971 
972  if (!d)
973  {
974  new((*digitsTMP)[trgid]) AliEMCALDigit(*digit);
975  d = (AliEMCALDigit*)digitsTMP->At(trgid);
976  d->SetId(trgid);
977  }
978  else
979  {
980  *d = *d + *digit;
981  }
982  }
983  }
984 
985  if (AliDebugLevel()) printf("Number of TRG digits: %d\n",digitsTMP->GetEntriesFast());
986 
987  Int_t nSamples = 32;
988  Int_t *timeSamples = new Int_t[nSamples];
989 
990  NextDigit = TIter(digitsTMP);
991  while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit())
992  {
993  if (digit)
994  {
995  Int_t id = digit->GetId();
996  Float_t time = 50.e-9;
997 
998  Double_t depositedEnergy = 0.;
999  for (Int_t j = 1; j <= digit->GetNprimary(); j++) depositedEnergy += digit->GetDEPrimary(j);
1000 
1001  if (AliDebugLevel()) printf("Deposited Energy: %f\n", depositedEnergy);
1002 
1003  // FIXME: Check digit time!
1004  if (depositedEnergy) {
1005  depositedEnergy += gRandom->Gaus(0., .08);
1006  DigitalFastOR(time, depositedEnergy, timeSamples, nSamples);
1007 
1008  for (Int_t j=0;j<nSamples;j++) {
1009  if (AliDebugLevel()) printf("timeSamples[%d]: %d\n",j,timeSamples[j]);
1010  timeSamples[j] = ((j << 16) | (timeSamples[j] & 0xFFFF));
1011  }
1012 
1013  new((*digitsTRG)[digitsTRG->GetEntriesFast()]) AliEMCALTriggerRawDigit(id, timeSamples, nSamples);
1014 
1015  if (AliDebugLevel()) ((AliEMCALTriggerRawDigit*)digitsTRG->At(digitsTRG->GetEntriesFast() - 1))->Print("");
1016  }
1017  }
1018  }
1019 
1020  delete [] timeSamples;
1021 
1022  if (digits && digits->GetEntriesFast()) digits->Clear("C");
1023 }
1024 
1032 //____________________________________________________________________________
1033 void AliEMCALDigitizer::DigitalFastOR( Double_t time, Double_t dE, Int_t timeSamples[], Int_t nSamples )
1034 {
1035  // parameters:
1036  // id: 0..95
1037  const Int_t reso = 12; // 11-bit resolution ADC
1038  const Double_t vFSR = 2.; // Full scale input voltage range 2V (p-p)
1039  //const Double_t dNe = 125; // signal of the APD per MeV of energy deposit in a tower: 125 photo-e-/MeV @ M=30
1040  const Double_t dNe = 125/1.3; // F-ALTRO max V. FEE: factor 4
1041  const Double_t vA = .136e-6; // CSP output range: 0.136uV/e-
1042  const Double_t rise = 50e-9; // rise time (10-90%) of the FastOR signal before shaping
1043 
1044  const Double_t kTimeBinWidth = 25E-9; // sampling frequency (40MHz)
1045 
1046  Double_t vV = 1000. * dE * dNe * vA; // GeV 2 MeV
1047 
1048  TF1 signalF("signal", AnalogFastORFunction, 0, nSamples * kTimeBinWidth, 3);
1049  signalF.SetParameter( 0, vV );
1050  signalF.SetParameter( 1, time ); // FIXME: when does the signal arrive? Might account for cable lengths
1051  signalF.SetParameter( 2, rise );
1052 
1053  for (Int_t iTime=0; iTime<nSamples; iTime++)
1054  {
1055  // FIXME: add noise (probably not simply Gaussian) according to DA measurements
1056  // probably plan an access to OCDB
1057  Double_t sig = signalF.Eval(iTime * kTimeBinWidth);
1058  if (TMath::Abs(sig) > vFSR/2.)
1059  {
1060  AliError("Signal overflow!");
1061  timeSamples[iTime] = (1 << reso) - 1;
1062  }
1063  else
1064  {
1065  AliDebug(999,Form("iTime: %d sig: %f\n",iTime,sig));
1066  timeSamples[iTime] = ((1 << reso) / vFSR) * sig + 0.5;
1067  }
1068  }
1069 }
1070 
1073 //____________________________________________________________________________
1075 {
1076  fInit = kTRUE ;
1077  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::Instance()->GetDetectorLoader("EMCAL"));
1078 
1079  if ( emcalLoader == 0 )
1080  {
1081  AliFatal("Could not obtain the AliEMCALLoader");
1082  return kFALSE;
1083  }
1084 
1085  fFirstEvent = 0 ;
1086  fLastEvent = fFirstEvent ;
1087 
1088  if(fDigInput)
1089  fInput = fDigInput->GetNinputs() ;
1090  else
1091  fInput = 1 ;
1092 
1093  fInputFileNames = new TString[fInput] ;
1094  fEventNames = new TString[fInput] ;
1095  fInputFileNames[0] = GetTitle() ;
1096  fEventNames[0] = fEventFolderName.Data() ;
1097 
1098  Int_t index ;
1099  for (index = 1 ; index < fInput ; index++)
1100  {
1101  fInputFileNames[index] = dynamic_cast<AliStream*>(fDigInput->GetInputStream(index))->GetFileName(0);
1102  TString tempo = fDigInput->GetInputFolderName(index) ;
1103  fEventNames[index] = tempo.Remove(tempo.Length()-1) ; // strip of the stream number added bt fDigInput
1104  }
1105 
1106  // Calibration instances
1107  fCalibData = emcalLoader->CalibData();
1108  fCalibTime = emcalLoader->CalibTime();
1109 
1110  return fInit ;
1111 }
1112 
1115 //____________________________________________________________________________
1117 {
1118  // Get the parameters from the OCDB via the loader
1120  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
1121 
1122  AliEMCALSimParam * simParam = 0x0;
1123  if(emcalLoader) simParam = emcalLoader->SimulationParameters();
1124 
1125  if(!simParam)
1126  {
1127  simParam = AliEMCALSimParam::GetInstance();
1128  AliWarning("Simulation Parameters not available in OCDB?");
1129  }
1130 
1131  fMeanPhotonElectron = simParam->GetMeanPhotonElectron() ; // 4400; // electrons per GeV
1132  fGainFluctuations = simParam->GetGainFluctuations() ; // 15.0;
1133 
1134  fPinNoise = simParam->GetPinNoise();//0.012; // pin noise in GeV from analysis test beam data
1135  if (fPinNoise < 0.0001 )
1136  Warning("InitParameters", "No noise added\n") ;
1137  fTimeNoise = simParam->GetTimeNoise(); // 1.28E-5 s
1138  fDigitThreshold = simParam->GetDigitThreshold(); //fPinNoise * 3; // 3 * sigma
1141  fTimeDelay = simParam->GetTimeDelay(); //600e-9 ; // 600 ns
1142  fTimeDelayFromOCDB = simParam->IsTimeDelayFromOCDB();
1143 
1144  // These defaults are normally not used.
1145  // Values are read from calibration database instead
1146  fADCchannelEC = 0.0162; // Nominal value set online for most of the channels, MIP peak sitting at ~266./16/1024
1147  fADCpedestalEC = 0.0 ; // GeV
1148  fADCchannelECDecal = 1.0; // No decalibration by default
1149  fTimeChannel = 0.0; // No time calibration by default
1150  fTimeChannelDecal = 0.0; // No time decalibration by default
1151 
1152  fNADCEC = simParam->GetNADCEC();//(Int_t) TMath::Power(2,16) ; // number of channels in Tower ADC - 65536
1153 
1154  AliDebug(2,Form("Mean Photon Electron %d, Gain Fluct. %2.1f; Noise: APD %f, Time %f; Digit Threshold %d,Time Resolution Par0 %g Par1 %g,NADCEC %d",
1157 }
1158 
1161 //__________________________________________________________________
1162 void AliEMCALDigitizer::Print1(Option_t * option)
1163 {
1164  Print();
1165  PrintDigits(option);
1166 }
1167 
1169 // Print Digitizer's parameters
1170 //__________________________________________________________________
1171 void AliEMCALDigitizer::Print (Option_t * ) const
1172 {
1173  printf("Print: \n------------------- %s -------------", GetName() ) ;
1174 
1175  if( strcmp(fEventFolderName.Data(), "") != 0 )
1176  {
1177  printf(" Writing Digits to branch with title %s\n", fEventFolderName.Data()) ;
1178 
1179  Int_t nStreams ;
1180  if (fDigInput)
1181  nStreams = GetNInputStreams() ;
1182  else
1183  nStreams = fInput ;
1184 
1185  AliRunLoader *rl=0;
1186 
1187  Int_t index = 0 ;
1188  for (index = 0 ; index < nStreams ; index++)
1189  {
1190  TString tempo(fEventNames[index]) ;
1191  tempo += index ;
1192 
1193  if ((rl = AliRunLoader::GetRunLoader(tempo)) == 0)
1194  rl = AliRunLoader::Open(fInputFileNames[index], tempo) ;
1195 
1196  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
1197 
1198  if(emcalLoader)
1199  {
1200  TString fileName( emcalLoader->GetSDigitsFileName() ) ;
1201  if ( fEventNames[index] != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
1202  fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index] + ".root" ;
1203 
1204  printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ;
1205  }//loader
1206  }
1207 
1208  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::Instance()->GetDetectorLoader("EMCAL"));
1209 
1210  if(emcalLoader) printf("\nWriting digits to %s", emcalLoader->GetDigitsFileName().Data()) ;
1211  else printf("\nNULL LOADER");
1212 
1213  printf("\nWith following parameters:\n") ;
1214  printf(" Electronics noise in EMC, APD (fPinNoise) = %f, Time = %f \n", fPinNoise, fTimeNoise) ;
1215  printf(" Threshold in Tower (fDigitThreshold) = %d\n", fDigitThreshold) ;
1216  printf("---------------------------------------------------\n") ;
1217  }
1218  else
1219  printf("Print: AliEMCALDigitizer not initialized") ;
1220 }
1221 
1224 //__________________________________________________________________
1225 void AliEMCALDigitizer::PrintDigits(Option_t * option)
1226 {
1227  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::Instance()->GetDetectorLoader("EMCAL"));
1228  if(emcalLoader)
1229  {
1230  TClonesArray * digits = emcalLoader->Digits() ;
1231  TClonesArray * sdigits = emcalLoader->SDigits() ;
1232 
1233  printf("\n #Digits: %d : sdigits %d ", digits->GetEntriesFast(), sdigits->GetEntriesFast()) ;
1234  printf("\n event %d", emcalLoader->GetRunLoader()->GetEventNumber());
1235 
1236  if(strstr(option,"all"))
1237  {
1238  //loop over digits
1239  AliEMCALDigit * digit;
1240  printf("\nEMC digits (with primaries):\n") ;
1241  printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
1242 
1243  Int_t index ;
1244  for (index = 0 ; index < digits->GetEntries() ; index++)
1245  {
1246  digit = dynamic_cast<AliEMCALDigit *>(digits->At(index)) ;
1247  if(digit)
1248  {
1249  printf("\n%6d %8f %6.5e %4d %2d : ",
1250  digit->GetId(), digit->GetAmplitude(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
1251  Int_t iprimary;
1252  for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
1253  printf("%d ",digit->GetPrimary(iprimary+1) ) ;
1254  }
1255  }// digit exists
1256  }// loop
1257  }
1258  printf("\n");
1259  }// loader exists
1260  else printf("NULL LOADER, cannot print\n");
1261 }
1262 
1265 //__________________________________________________________________
1267 {
1268  //printf("Time noise %e\n",fTimeNoise);
1269  return gRandom->Rndm() * fTimeNoise;
1270 }
1271 
1274 //__________________________________________________________________
1276 {
1277  AliRunLoader *rl=0;
1278 
1279  Int_t i ;
1280  for(i = 1 ; i < fInput ; i++)
1281  {
1282  TString tempo(fEventNames[i]) ;
1283  tempo += i;
1284 
1285  if ((rl = AliRunLoader::GetRunLoader(tempo)))
1286  rl->GetDetectorLoader("EMCAL")->UnloadSDigits() ;
1287  }
1288 
1289  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::Instance()->GetDetectorLoader("EMCAL"));
1290 
1291  if(emcalLoader)emcalLoader->UnloadDigits() ;
1292  else AliFatal("Did not get the loader");
1293 }
1294 
1303 //_________________________________________________________________________________________
1305 {
1306  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::Instance()->GetDetectorLoader("EMCAL"));
1307 
1308  if(emcalLoader)
1309  {
1310  const TClonesArray * digits = emcalLoader->Digits() ;
1311 
1312  TTree * treeD = emcalLoader->TreeD();
1313  if ( !treeD )
1314  {
1315  emcalLoader->MakeDigitsContainer();
1316  treeD = emcalLoader->TreeD();
1317  }
1318 
1319  // -- create Digits branch
1320  Int_t bufferSize = 32000 ;
1321  TBranch * digitsBranch = 0;
1322  if ((digitsBranch = treeD->GetBranch("EMCAL")))
1323  {
1324  digitsBranch->SetAddress(&digits);
1325  AliWarning("Digits Branch already exists. Not all digits will be visible");
1326  }
1327  else
1328  treeD->Branch("EMCAL","TClonesArray",&digits,bufferSize);
1329 
1330  //digitsBranch->SetTitle(fEventFolderName);
1331 
1332  // treeD->Fill() ;
1333  /*
1334  emcalLoader->WriteDigits("OVERWRITE");
1335  emcalLoader->WriteDigitizer("OVERWRITE");
1336 
1337  Unload() ;
1338  */
1339 
1340  }// loader exists
1341  else AliFatal("Loader not available");
1342 }
1343 
1346 //__________________________________________________________________
1347 void AliEMCALDigitizer::WriteDigits(TClonesArray* digits, const char* branchName)
1348 {
1349  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::Instance()->GetDetectorLoader("EMCAL"));
1350  if(emcalLoader)
1351  {
1352  TTree* treeD = emcalLoader->TreeD();
1353  if (!treeD)
1354  {
1355  emcalLoader->MakeDigitsContainer();
1356  treeD = emcalLoader->TreeD();
1357  }
1358 
1359  // -- create Digits branch
1360  Int_t bufferSize = 32000;
1361 
1362  if (TBranch* triggerBranch = treeD->GetBranch(branchName))
1363  {
1364  triggerBranch->SetAddress(&digits);
1365  }
1366  else
1367  {
1368  treeD->Branch(branchName,"TClonesArray",&digits,bufferSize);
1369  }
1370  // treeD->Fill();
1371  }// loader exists
1372  else AliFatal("Loader not available");
1373 }
1374 
1380 //__________________________________________________________________
1382 {
1383  Int_t absId = digit->GetId();
1384 
1385  return IsDead(absId);
1386 }
1387 
1394 //__________________________________________________________________
1395 Bool_t AliEMCALDigitizer::IsDead(Int_t absId)
1396 {
1397  AliRunLoader *runLoader = AliRunLoader::Instance();
1398  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL"));
1399  if (!emcalLoader)
1400  {
1401  AliFatal("Did not get the Loader");
1402  return kTRUE;
1403  }
1404 
1405  AliCaloCalibPedestal *caloPed = emcalLoader->PedestalData();
1406  if (!caloPed)
1407  {
1408  AliWarning("Could not access pedestal data! No dead channel removal applied");
1409  return kFALSE;
1410  }
1411 
1412  // Load Geometry
1414  if (!geom)
1415  {
1416  AliFatal("Did not get geometry from EMCALLoader");
1417  return kTRUE; //coverity
1418  }
1419 
1420  Int_t iSupMod = -1;
1421  Int_t nModule = -1;
1422  Int_t nIphi = -1;
1423  Int_t nIeta = -1;
1424  Int_t iphi = -1;
1425  Int_t ieta = -1;
1426 
1427  Bool_t bCell = geom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
1428 
1429  if (!bCell) Error("IsDead","Wrong cell id number : absId %i ", absId) ;
1430  geom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
1431 
1432  Int_t channelStatus = (Int_t)(caloPed->GetDeadMap(iSupMod))->GetBinContent(ieta,iphi);
1433 
1434  if (channelStatus == AliCaloCalibPedestal::kDead)
1435  return kTRUE;
1436  else
1437  return kFALSE;
1438 }
1439 
static AliRunLoader * Instance()
Definition: AliRunLoader.h:176
Int_t GetEventNumber() const
Definition: AliRunLoader.h:59
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
Int_t GetNCells(void) const
void InitParameters()
/ Parameter initialization for digitizer
Double_t GetTimeDelay() const
static const TString & GetDefaultEventFolderName()
Definition: AliConfig.h:58
void Print(Option_t *option="") const
Int_t fInput
Number of files to merge.
#define AliDebugLevel()
void SetType(Int_t t)
Definition: AliEMCALDigit.h:78
Double_t GetTimeResolutionPar0() const
AliDigitizationInput * fDigInput
Definition: AliDigitizer.h:43
#define TObjArray
Float_t GetTime(void) const
Definition: AliEMCALDigit.h:64
EMCal trigger raw digits.
void DigitizeEnergyTime(Float_t &energy, Float_t &time, Int_t absId)
AliCaloCalibPedestal * PedestalData()
Int_t GetMask(Int_t i) const
Float_t fGainFluctuations
Correct fMeanPhotonElectron by the gain fluctuations.
TBenchmark * gBenchmark
void SetId(Int_t idt)
Definition: AliEMCALDigit.h:73
virtual void Print(const Option_t *opt) const
Dump raw digit info.
AliEMCALSDigitizer * fSDigitizer
SDigitization object.
Int_t LoadSDigits(Option_t *detectors="all", Option_t *opt="READ")
TClonesArray * SDigits()
TTree * TreeD() const
Definition: AliLoader.h:87
Float_t fADCchannelECDecal
Decalibration width of one ADC channel in EC section (GeV)
AliEMCALSimParam * SimulationParameters()
AliLoader * GetDetectorLoader(const char *detname)
void DecalibrateTrigger(AliEMCALDigit *digit)
Float_t Calibrate(Float_t amp) const
Convert the amplitude back to energy in GeV.
Double_t fTimeResolutionPar0
Time resolution of FEE electronics.
static AliEMCALSimParam * GetInstance()
Get Instance.
Float_t GetPinNoise() const
Float_t Digitize(Float_t energy) const
Digitize the energy.
Double_t fTimeDelay
Time delay to mimick roughly data delay.
EMCal digits object.
Definition: AliEMCALDigit.h:30
TClonesArray * Digits()
TString fileName(const char *dir, int runNumber, const char *da, int i, const char *type)
TString * fEventNames
List of event names to merge.
const TString & GetInputFolderName(Int_t i) const
#define AliWarning(message)
Definition: AliLog.h:541
void CalibrateADCTime(Float_t &adc, Float_t &time, Int_t absId)
Give access to hits, digits, recpoints arrays and OCDB.
Int_t GetNTotalTRU() const
Bool_t GetFastORIndexFromCellIndex(const Int_t id, Int_t &idx) const
Int_t fFirstEvent
First event to process.
static AliRunLoader * Open(const char *filename="galice.root", const char *eventfoldername=AliConfig::GetDefaultEventFolderName(), Option_t *option="READ")
void GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta, Int_t &iphi, Int_t &ieta) const
Int_t fNADCEC
Number of channels in EC section ADC.
void SetTime(Float_t time)
Definition: AliEMCALDigit.h:74
TString GetFileName() const
Double_t IsTimeDelayFromOCDB() const
void UnloadDigits() const
Definition: AliLoader.h:131
Float_t TimeOfNoise(void)
Calculates the time signal generated by noise.
Float_t GetADCchannelOnline(Int_t module, Int_t column, Int_t row) const
#define AliInfo(message)
Definition: AliLog.h:484
Bool_t GetCellIndex(Int_t absId, Int_t &nSupMod, Int_t &nModule, Int_t &nIphi, Int_t &nIeta) const
Int_t GetNprimary() const
Definition: AliEMCALDigit.h:57
Int_t fLastEvent
Last event to process.
Int_t fMeanPhotonElectron
Number of photon electrons per GeV deposited energy.
AliRunLoader * GetRunLoader()
Definition: AliLoader.cxx:495
EMCal digitization maker.
Float_t GetADCchannelDecal(Int_t module, Int_t column, Int_t row) const
void Unload()
Unloads the SDigits and Digits.
Double_t fTimeResolutionPar1
Time resolution of FEE electronics.
Int_t GetNInputStreams() const
virtual void MakeDigitsContainer() const
Definition: AliLoader.h:75
Float_t GetTimeChannelDecal(Int_t supermodule, Int_t column, Int_t row) const
Container of simulation parameters.
void ShiftPrimary(Int_t shift)
Shifts primary number to BIG offset, to separate primary in different TreeK.
AliStream * GetInputStream(Int_t index) const
virtual AliEMCALGeometry * GetGeometry() const
Definition: AliEMCAL.cxx:466
Float_t fTimeChannel
Calibration time width for one channel.
Int_t GetIndexInList() const
Definition: AliDigitNew.h:24
EMCal summable digits maker.
Int_t GetNumberOfEvents()
Double_t GetTimeNoise() const
Bool_t Init()
Initializations, it makes all memory allocations.
Int_t GetType() const
Definition: AliEMCALDigit.h:69
Base Class for EMCAL description.
Definition: AliEMCAL.h:35
AliTPCcalibV0 v0
Int_t GetDigitThreshold() const
pedestal/bad map monitoring and calibration tools
void SetIndexInList(Int_t val)
Definition: AliDigitNew.h:25
#define AliFatal(message)
Definition: AliLog.h:640
Int_t GetMeanPhotonElectron() const
Bool_t fDefaultInit
! Says if the task was created by defaut ctor (only parameters are initialized)
TString fEventFolderName
skowron: name of EFN to read data from in stand alone mode
Int_t GetEvent(Int_t evno)
Float_t GetADCchannel(Int_t module, Int_t column, Int_t row) const
void Digitize(Int_t event)
#define AliDebug(logLevel, message)
Definition: AliLog.h:300
void PrintDigits(Option_t *option)
Utility method for printing digit information.
Int_t GetPrimary(Int_t index) const
Double_t GetTimeResolutionPar1() const
Float_t fADCchannelEC
Calibration width of one ADC channel in EC section (GeV)
virtual Int_t WriteDigits(Option_t *opt="") const
Definition: AliLoader.h:148
void Digits2FastOR(TClonesArray *digitsTMP, TClonesArray *digitsTRG)
const TString & GetSDigitsFileName() const
Definition: AliLoader.h:171
void DigitalFastOR(Double_t time, Double_t dE, Int_t timeSamples[], Int_t nSamples)
Int_t GetId() const
Definition: AliDigitNew.h:23
Int_t fDigitThreshold
Threshold for storing digits in EMC, ACD units.
Double_t fTimeNoise
Electronics noise in EMC, time.
Float_t GetTimeChannel(Int_t supermodule, Int_t column, Int_t row, Int_t bc) const
void UnloadSDigits() const
Definition: AliLoader.h:130
AliEMCALDigitizer()
Default constructor.
Int_t GetNADCEC() const
Float_t GetADCpedestal(Int_t module, Int_t column, Int_t row) const
virtual ~AliEMCALDigitizer()
Destructor.
AliEMCALCalibData * CalibData()
Float_t fADCpedestalEC
Calibration pedestal for one ADC channel.
AliDetector * GetDetector(const char *name) const
Definition: AliRun.cxx:200
#define AliError(message)
Definition: AliLog.h:591
AliEMCALCalibTime * CalibTime()
AliEMCALCalibTime * fCalibTime
Time Calibration data pointer.
static AliEMCALGeometry * GetInstance()
AliEMCALCalibData * fCalibData
Energy Calibration data pointer.
Bool_t IsDead(AliEMCALDigit *digit)
void res(Char_t i)
Definition: Resolution.C:2
static AliRunLoader * GetRunLoader(const char *eventfoldername)
TEveGeoShape * geom
Definition: tpc_tracks.C:10
void Print1(Option_t *option)
Print info, call all prints.
Bool_t fTimeDelayFromOCDB
Recover time delay from data.
Float_t GetTimeResolution(Float_t energy) const
TString * fInputFileNames
List of file names to merge.
Float_t fPinNoise
Electronics noise in EMC, APD.
Bool_t fInit
! To avoid overwriting existing files
Float_t GetAmplitude() const
Definition: AliEMCALDigit.h:55
Float_t GetGainFluctuations() const
const int OVERFLOWCUT
sample overflow
Float_t fTimeChannelDecal
Calibration time width for one channel.
EMCal geometry, singleton.
Int_t fDigitsInRun
! Total number of digits in one run
AliRun * GetAliRun() const
void SetEventRange(Int_t first=0, Int_t last=-1)
void SetAmplitude(Float_t amp)
Definition: AliEMCALDigit.h:72