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