]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/macros/Trigger/raw/AliTRUPedestalAnalysis.cxx
Added PHOS/macros/Trigger/raw and contained code.
[u/mrichter/AliRoot.git] / PHOS / macros / Trigger / raw / AliTRUPedestalAnalysis.cxx
CommitLineData
1b98727b 1/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
2 * See cxx source for full Copyright notice */
3
4// Author: Henrik Qvigstad <henrik.qvigstad@cern.ch>
5/* $Id$ */
6
7#include "AliCaloRawStreamV3.h"
8#include "AliTRUPedestalOutput.h"
9#include "AliPHOSTriggerRawReader.h"
10#include "AliPHOSTRURawReader.h"
11#include "TH1I.h"
12
13#include "AliTRUPedestalAnalysis.h"
14#include <TRandom.h>
15
16AliTRUPedestalAnalysis::AliTRUPedestalAnalysis()
17: fOutput(new AliTRUPedestalOutput),
18 fTriggerReader(new AliPHOSTriggerRawReader)
19{
20}
21
22AliTRUPedestalAnalysis::~AliTRUPedestalAnalysis()
23{
24 delete fOutput;
25}
26
27void AliTRUPedestalAnalysis::ProcessEvent ( AliCaloRawStreamV3* phosStream )
28{
29 fTriggerReader->Reset();
30
31 phosStream->Reset();
32 while (phosStream->NextDDL()) {
33 while (phosStream->NextChannel()) {
34 if (phosStream->IsTRUData()) {
35 fTriggerReader->ReadFromStream(phosStream);
36 }// IsTRUData
37 }// NextChannel
38 }//NextDDL
39
40 bool data_in_event = false;
41 for (unsigned int mod=0; mod<kNMods; ++mod) {
42 for (unsigned int row=0; row<kNTRURows; ++row) {
43 for (unsigned int branch=0; branch<kNBranches; ++branch) {
44 // if there is tru data in this branch, for this event.
45 if( fTriggerReader->GetTRU(mod, row, branch)->IsActive() ) {
46 data_in_event = true;
47 for (unsigned int xrow=0; xrow<kN2x2XPrTRURow; ++xrow) {
48 for (unsigned int zcol=0; zcol<kN2x2ZPrBranch; ++zcol) {
49 // if there is tru data for this timebin, for this branch.
50 for (unsigned int timeBin=0; timeBin < kNTRUTimeBins; ++timeBin) {
51 if( fTriggerReader->GetTRU(mod, row, branch)->IsActive(timeBin) ){
52 double signal = fTriggerReader->GetTRU(mod, row, branch)->GetTriggerSignal(xrow, zcol, timeBin);
53 fOutput->GetTRUSignals(mod, row, branch, xrow, zcol)->Fill(signal);
54 } // if timebin is active
55 } // timeBin
56 } // zcol
57 } // xrow
58 } // if branch is active
59 } // branch
60 } // row
61 } // mod
62
63 if( data_in_event )
64 fOutput->EventAdded();
65}
66
67
68UInt_t AliTRUPedestalAnalysis::Get2x2Max ( AliPHOSTriggerRawReader* reader, int mod, int row, int branch, int x, int z )
69{
70 UInt_t max = 0;
71 for(UInt_t timeBin = 0; timeBin < kNTRUTimeBins; ++timeBin) {
72 const UInt_t signal = reader->GetTRU(mod, row, branch)->GetTriggerSignal(x, z, timeBin);
73 if( max < signal )
74 max = signal;
75 }
76 return max;
77}