1 /**************************************************************************
2 * Copyright(c) 2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //This class produces PHOS digits of one event
19 //using AliPHOSRawDecoder.
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);
30 // Author: Boris Polichtchouk
32 // --- ROOT system ---
33 #include "TClonesArray.h"
35 // --- AliRoot header files ---
36 #include "AliPHOSRawDigiProducer.h"
37 #include "AliPHOSRawDecoder.h"
38 #include "AliPHOSGeometry.h"
39 #include "AliPHOSDigit.h"
41 ClassImp(AliPHOSRawDigiProducer)
43 //--------------------------------------------------------------------------------------
44 void AliPHOSRawDigiProducer::MakeDigits(TClonesArray *digits, AliPHOSRawDecoder* decoder)
47 //TClonesArray *digits and raw data decoder should be provided by calling function.
51 AliPHOSGeometry* geo = AliPHOSGeometry::GetInstance();
52 if(!geo) geo = AliPHOSGeometry::GetInstance("IHEP");
57 Bool_t seen,lowGainFlag;
58 Int_t relId[4], absId =0;
60 while (decoder->NextDigit()) {
62 if (decoder->GetEnergy() <= 0.)
65 if(decoder->IsOverflow())
68 lowGainFlag = decoder->IsLowGain();
69 time = decoder->GetTime();
71 relId[0] = decoder->GetModule();
73 relId[2] = decoder->GetRow();
74 relId[3] = decoder->GetColumn();
75 geo->RelToAbsNumbering(relId, absId);
77 // Add low gain digit only
78 //if the high gain digit does not exist in the digits array
79 //or has negative energy (overflow)
84 for (iOldDigit=iDigit-1; iOldDigit>=0; iOldDigit--) {
85 AliPHOSDigit * dig = dynamic_cast<AliPHOSDigit*>(digits->At(iOldDigit)) ;
86 if (dig->GetId() == absId) {
88 // //if High Gain overflowed - replace energy
89 // if(dig->GetEnergy()<0)
90 // dig->SetEnergy((Float_t)decoder->GetEnergy()) ;
95 new((*digits)[iDigit]) AliPHOSDigit(-1,absId,(Float_t)decoder->GetEnergy(),time);
99 // Add high gain digit only if it is not saturated;
100 // replace low gain digit by a high gain one
102 for (iOldDigit=iDigit-1; iOldDigit>=0; iOldDigit--) {
103 AliPHOSDigit * dig = dynamic_cast<AliPHOSDigit*>(digits->At(iOldDigit)) ;
104 if (dig->GetId() == absId) {
105 dig->SetTime(time) ; //Replace time in any case
106 dig->SetEnergy((Float_t)decoder->GetEnergy()) ;
107 // if (decoder->GetEnergy() > 0){ //replace Energy only if not saturated
108 // dig->SetEnergy((Float_t)decoder->GetEnergy()) ;
115 new((*digits)[iDigit]) AliPHOSDigit(-1,absId,(Float_t)decoder->GetEnergy(),time);