Updating macro to check the various methods of the AliMUONMCDataInterface
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRawDigiProducer.cxx
CommitLineData
7bc140a5 1/**************************************************************************
2 * Copyright(c) 2007, 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//This class produces PHOS digits of one event
19//using AliPHOSRawDecoder.
20//
21// For example:
22// TClonesArray *digits = new TClonesArray("AliPHOSDigit",100);
23// AliRawReader* rawReader = new AliRawReaderDate("2006run2211.raw");
24// AliPHOSRawDecoder dc(rawReader);
25// while (rawReader->NextEvent()) {
26// AliPHOSRawDigiProducer producer;
27// producer.MakeDigits(digits,&dc);
28// }
29
30// Author: Boris Polichtchouk
31
32// --- ROOT system ---
88fb5e50 33#include "TClonesArray.h"
34
7bc140a5 35// --- AliRoot header files ---
88fb5e50 36#include "AliPHOSRawDigiProducer.h"
37#include "AliPHOSRawDecoder.h"
38#include "AliPHOSGeometry.h"
39#include "AliPHOSDigit.h"
40
41ClassImp(AliPHOSRawDigiProducer)
42
7bc140a5 43//--------------------------------------------------------------------------------------
88fb5e50 44void AliPHOSRawDigiProducer::MakeDigits(TClonesArray *digits, AliPHOSRawDecoder* decoder)
45{
7bc140a5 46 //Makes the job.
47 //TClonesArray *digits and raw data decoder should be provided by calling function.
48
88fb5e50 49 digits->Clear();
50
51 AliPHOSGeometry* geo = AliPHOSGeometry::GetInstance();
52 if(!geo) geo = AliPHOSGeometry::GetInstance("IHEP");
53
54 Int_t iDigit = 0 ;
55 Double_t time = 0. ;
56 Int_t iOldDigit;
57 Bool_t seen,lowGainFlag;
58 Int_t relId[4], absId =0;
59
60 while (decoder->NextDigit()) {
61
1267d56d 62 if (decoder->GetEnergy() <= 0.) continue;
63
88fb5e50 64 lowGainFlag = decoder->IsLowGain();
65 time = decoder->GetTime();
66
67 relId[0] = decoder->GetModule();
68 relId[1] = 0;
69 relId[2] = decoder->GetRow();
70 relId[3] = decoder->GetColumn();
71 geo->RelToAbsNumbering(relId, absId);
72
73 // Add low gain digit only
74 //if the high gain digit does not exist in the digits array
75
76 seen = kFALSE;
77
78 if(lowGainFlag) {
79 for (iOldDigit=iDigit-1; iOldDigit>=0; iOldDigit--) {
80 if ((dynamic_cast<AliPHOSDigit*>(digits->At(iOldDigit)))->GetId() == absId) {
81 seen = kTRUE;
82 break;
83 }
84 }
85 if (!seen) {
86 new((*digits)[iDigit]) AliPHOSDigit(-1,absId,(Float_t)decoder->GetEnergy(),time);
87 iDigit++;
88 }
89 }
90
91 // Add high gain digit only if it is not saturated;
92 // replace low gain digit by a high gain one
93 else {
94 if (decoder->GetEnergy() >= 1023) continue;
95 for (iOldDigit=iDigit-1; iOldDigit>=0; iOldDigit--) {
77ea1c6f 96 AliPHOSDigit * dig = dynamic_cast<AliPHOSDigit*>(digits->At(iOldDigit)) ;
97 if (dig->GetId() == absId) {
98 dig->SetEnergy((Float_t)decoder->GetEnergy()) ;
99 dig->SetTime(time) ;
88fb5e50 100 seen = kTRUE;
101 break;
102 }
103 }
104 if (!seen) {
105 new((*digits)[iDigit]) AliPHOSDigit(-1,absId,(Float_t)decoder->GetEnergy(),time);
106 iDigit++;
107 }
108 }
77ea1c6f 109
88fb5e50 110 }
111
112 digits->Compress();
113 digits->Sort();
114}