]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSTRURawReader.cxx
bug in increment corrected
[u/mrichter/AliRoot.git] / PHOS / AliPHOSTRURawReader.cxx
CommitLineData
e1aec4f9 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 * Class for reading TRU data from a bunch from a raw datastream.
20 * Author: Henrik Qvigstad <henrik.qvigstad@cern.ch>
21 */
22
23#include "AliPHOSTRURawReader.h"
24
25#include "AliCaloRawStreamV3.h"
26#include <bitset> // std::bitset
27
28ClassImp(AliPHOSTRURawReader)
29
30
31//________________________________________________________________
32AliPHOSTRURawReader::AliPHOSTRURawReader()
33 : TObject(),
34 fSignals(),
35 fFlags(),
d0f6a608 36 fActive(false),
e19e9fb1 37 fHasSignal(false),
d0f6a608 38 fActiveTime(),
e19e9fb1 39 fHasSignalTime()
40
e1aec4f9 41{
42 // default constructor
43
44 // fSignals Initialization:
45 for(Int_t row = 0; row < kN2x2XPrTRURow; ++row) {
46 for(Int_t branch = 0; branch < kN2x2ZPrBranch; ++branch) {
47 for(Int_t timeBin = 0; timeBin < kNTimeBins; ++timeBin) {
48 fSignals[row][branch][timeBin] = kDefaultSignalValue;
49 }
50 }
51 }
52
53 // fFlags Initialization
54 for(Int_t row = 0; row < kN4x4XPrTRURow; ++row){
55 for(Int_t branch = 0; branch < kN4x4ZPrBranch; ++branch){
56 for(Int_t timeBin = 0; timeBin < kNTimeBins; ++timeBin){
57 fFlags[row][branch][timeBin] = kFALSE;
58 }
59 }
60 }
61
62 // fActiveTime Initialization
63 for(Int_t timeBin = 0; timeBin < kNTimeBins; ++timeBin){
64 fActiveTime[timeBin] = kFALSE;
e19e9fb1 65 fHasSignalTime[timeBin] = kFALSE;
e1aec4f9 66 }
67}
68
69
70//________________________________________________________________
71AliPHOSTRURawReader::~AliPHOSTRURawReader()
72{
73 // destructor
74}
75
76//________________________________________________________________
77void AliPHOSTRURawReader::ReadFromStream(AliCaloRawStreamV3* rawStream)
78{
79 // reads the trigger signal amplitudes and trigger flags from the rawStream
80
81 const UShort_t * const signal = rawStream->GetSignals(); // stream of 10-bit words, buffered as 16-bit words
82 const Int_t signalLength = rawStream->GetBunchLength();
83 const Int_t timeBin = rawStream->GetHWAddress() & 0x7f; // , i.e. & '01111111', strips the first 7 bits ([0:6]) and interprits it as a int
84
85 // TODO: this may need to be an error
86 if(signalLength != 16 && signalLength != 16+112)
87 Warning("ReadFromStream", " signalLength: !16 && !16+112, reader logic may not be valid.");
88
89
90 fActive = kTRUE;
91 fActiveTime[timeBin] = kTRUE;
92
93 /* There are 91 4x4 Sliding Window signal sum trigger flags.
94 * We read the trigger location information from first 12 10-bit words of the signal
95 * (these are buffered to 12 16-bit words in the rawstream object)
96 * , but only 10 of the 10-bit words are used for trigger location within the TRU.
97 * The flags are found in word_2[0] to word_11[9].
98 * We read the information as following. */
99
100 for(Int_t wIdx = 2; wIdx < 12; ++wIdx) { // words
101 const std::bitset<10> word(signal[wIdx]); // @param word represent a 10-bit word
102 for(Int_t bIdx = 0; bIdx < 10; ++bIdx) { // bits
103 //const Int_t index = 119 - (wIdx*10 + (9-bi)); // index used in TRU documentation,
104 const Int_t index = (110 - wIdx*10) + bIdx; // equivalent
105 if( index < 91 ) { // we are only interrested in these words/bits
106 const Int_t xIdx = index % 7; // x index in TRU internal 2x2 coordinate system
107 const Int_t zIdx = index / 7; // z index in TRU internal 2x2 coordinate system
108 // fFlags[xIdx][zIdx][time] = (signal[wIdx] & (0x01 * 2**i)) != 1;
109 fFlags[xIdx][zIdx][timeBin] = (bool) word[bIdx];
110 }
111 } // end bit loop
112 }// end word loop
113
114
115
116 /* The 2x2 trigger signal sum may follow.
117 * If so, it is found in the following 112 10-bit words
118 * (, 16-bit words in buffer.)
119 * We read the signal as following.
120 */
121
122 if( 16+112 == signalLength) {
e19e9fb1 123 fHasSignal = kTRUE;
124 fHasSignalTime[timeBin] = kTRUE;
e1aec4f9 125 for (Int_t idx = 0; idx < 112; idx++)
126 {
127 const Int_t xIdx = 7 - idx % 8; // x index in TRU
128 const Int_t zIdx = 13 - idx / 8; // z index in TRU
129 const Int_t wIdx = idx + 16; // word index in signal array
130 fSignals[xIdx][zIdx][timeBin] = signal[wIdx];
131 }
132 }
133}
134
135
136//________________________________________________________________
137void AliPHOSTRURawReader::Reset()
138{
139 // Reset to default values
140
141 if( ! fActive )
142 return;
143
144 for(Int_t timeBin = 0; timeBin < kNTimeBins; ++timeBin) { // loop timeBins
145 if( fActiveTime[timeBin] ) {
146 for(Int_t xIdx = 0; xIdx < kN2x2XPrTRURow; ++xIdx) { // loop 2x2
147 for(Int_t zIdx = 0; zIdx < kN2x2ZPrBranch; ++zIdx) {
148 fSignals[xIdx][zIdx][timeBin] = kDefaultSignalValue;
149 } // zIdx
150 } // xIdx
151 for(Int_t xIdx = 0; xIdx < kN4x4XPrTRURow; ++xIdx) { // loop 4x4
152 for(Int_t zIdx = 0; zIdx < kN4x4ZPrBranch; ++zIdx) {
153 fFlags[xIdx][zIdx][timeBin] = false;
154 } // zIdx
155 } // xIdx
156 }// end if fActiveTime
157 fActiveTime[timeBin] = false;
e19e9fb1 158 fHasSignalTime[timeBin] = false;
e1aec4f9 159 } // timeBin
160
161 fActive = false;
e19e9fb1 162 fHasSignal = false;
e1aec4f9 163}