]>
Commit | Line | Data |
---|---|---|
c51c5c6c | 1 | // $Id$ |
2 | ||
3 | /************************************************************************** | |
4 | * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Authors: Boris Polichtchouk & Per Thomas Hille for the ALICE * | |
7 | * offline/HLT Project. Contributors are mentioned in the code where * | |
8 | * appropriate. * | |
9 | * * | |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
19 | #include "AliHLTPHOSRcuAltroPatternTest.h" | |
20 | #include <iostream> | |
21 | #include "AliHLTPHOSPattern.h" | |
22 | #include "AliHLTPHOSConstants.h" | |
23 | ||
24 | using namespace PhosHLTConst; | |
25 | using namespace std; | |
26 | ||
27 | // fPatternTestPtr = new AliHLTPHOSRcuAltroPatternTest(fModuleID, fRcuX, fRcuZ, tmpPattern, ALTRO_MAX_SAMPLES ); | |
28 | AliHLTPHOSRcuAltroPatternTest::AliHLTPHOSRcuAltroPatternTest(const AliHLTUInt8_t moduleID, const AliHLTUInt8_t rcuX, | |
29 | const AliHLTUInt8_t rcuZ, const int *pattern, const int length): AliHLTPHOSBase(), | |
30 | fModuleID(moduleID), | |
31 | fRcuX(rcuX), | |
32 | fRcuZ(rcuZ), | |
33 | fReferenceAltroPattern(0), | |
34 | fCnt(0) | |
35 | { | |
36 | fReferenceAltroPattern = new AliHLTPHOSPattern(pattern, length); | |
37 | ||
38 | for(int z=0; z < NZROWSRCU; z++) | |
39 | { | |
40 | for(int x=0; x < NXCOLUMNSRCU; x++) | |
41 | { | |
42 | for(int gain = 0; gain < NGAINS; gain ++) | |
43 | { | |
44 | fNEqual[z][x][gain] = 0; | |
45 | fNNotEqual[z][x][gain] = 0; | |
46 | fPerChannelPatterns[z][x][gain] = 0; | |
47 | } | |
48 | } | |
49 | } | |
50 | } | |
51 | ||
52 | ||
53 | ||
54 | AliHLTPHOSRcuAltroPatternTest::~ AliHLTPHOSRcuAltroPatternTest() | |
55 | { | |
56 | //Destructor | |
57 | } | |
58 | ||
59 | ||
60 | int | |
61 | AliHLTPHOSRcuAltroPatternTest::ValidateAltroPattern(const int *inputPattern, const int samples, const int presamples) const | |
62 | { | |
63 | if(fReferenceAltroPattern !=0) | |
64 | { | |
65 | return fReferenceAltroPattern->ValidatePattern(inputPattern, samples, presamples); | |
66 | } | |
67 | else | |
68 | { | |
69 | return -99; | |
70 | } | |
71 | } | |
72 | ||
73 | ||
74 | int | |
75 | AliHLTPHOSRcuAltroPatternTest::AddPattern(const int *inputPattern, const int z, const int x, const int gain, const int nSamples, const int nPresamples) | |
76 | { | |
77 | ||
78 | if(fPerChannelPatterns[z][x][gain] == 0) | |
79 | { | |
80 | // cout << "AliHLTPHOSRcuAltroPatternTest::AddPattern creating new pattern z = "<< z <<" x =" << x <<" gain = "<< gain <<endl; | |
81 | fPerChannelPatterns[z][x][gain] = new AliHLTPHOSPattern(&inputPattern[nPresamples], nSamples); | |
82 | return 1; | |
83 | } | |
84 | else | |
85 | { | |
86 | // cout << "AliHLTPHOSRcuAltroPatternTest::AddPattern adding new pattern to z = "<< z <<" x =" << x <<" gain = "<< gain <<endl; | |
87 | fPerChannelPatterns[z][x][gain]->AddPattern(inputPattern, nSamples, nPresamples); | |
88 | return 0; | |
89 | } | |
90 | ||
91 | ||
92 | } | |
93 | ||
94 | /* | |
95 | *Conts the number of linkes (patterns) in the linked list) | |
96 | */ | |
97 | int | |
98 | AliHLTPHOSRcuAltroPatternTest::countPatterns(const AliHLTPHOSPattern *pattern) const | |
99 | { | |
100 | int tmp = 0; | |
101 | ||
102 | const AliHLTPHOSPattern *tmpPattern = pattern; | |
103 | ||
104 | while(tmpPattern !=0) | |
105 | { | |
106 | tmp ++; | |
107 | // cout <<"tmp =" << tmp <<endl; | |
108 | tmpPattern = tmpPattern->GetNextPtr(); | |
109 | } | |
110 | return tmp; | |
111 | } | |
112 | ||
113 | ||
114 | // const int GetPattern(int *pattern, const int maxlengths = ALTROMAXSAMPLES) const; | |
115 | // const int GetPatternLength() const {return fPatternLength;}; | |
116 | ||
117 | /* Counts the total number of differen patterns dtetected across all channels | |
118 | * for one RCU. | |
119 | * @param length the only the number of samples spcified by length will be compared | |
120 | * starting from zero. The default value is the maximum number of altro samples (1008, presamples exluded) | |
121 | * tyically the electronics is configured to read out (playback) less than the maximum number of samples so length can | |
122 | * be either equal or smaller than the lenght of the pattern. | |
123 | * @return the number of different patterns detected across all channels | |
124 | */ | |
125 | ||
126 | // const int GetPattern(int *pattern, const int maxlengths = ALTROMAXSAMPLES) const; | |
127 | // const int GetPatternLength() const {return fPatternLength;}; | |
128 | int | |
129 | AliHLTPHOSRcuAltroPatternTest::countAllPatterns(const int length, const bool /*doprintpattern*/) | |
130 | { | |
131 | fCnt ++; | |
132 | ||
133 | int tmpPatternArray[ALTROMAXSAMPLES]; | |
134 | int tmplength = fReferenceAltroPattern->GetPattern(tmpPatternArray, length); | |
135 | AliHLTPHOSPattern *tmpPattern = new AliHLTPHOSPattern(tmpPatternArray, tmplength); | |
136 | ||
137 | for(int z=0; z < NZROWSRCU; z++) | |
138 | { | |
139 | for(int x=0; x < NXCOLUMNSRCU; x++) | |
140 | { | |
141 | for(int gain = 0; gain < NGAINS; gain ++) | |
142 | { | |
143 | if(fPerChannelPatterns[z][x][gain] != 0) | |
144 | { | |
145 | const AliHLTPHOSPattern *tmpLinkedPattern = 0; | |
146 | fPerChannelPatterns[z][x][gain]->GetPattern(tmpPatternArray); | |
147 | tmpPattern->AddPattern(tmpPatternArray, tmplength); | |
148 | tmpLinkedPattern = fPerChannelPatterns[z][x][gain]->GetNextPtr(); | |
149 | ||
150 | while(tmpLinkedPattern !=0) | |
151 | { | |
152 | tmpLinkedPattern->GetPattern(tmpPatternArray); | |
153 | tmpPattern->AddPattern(tmpPatternArray, tmplength); | |
154 | tmpLinkedPattern = tmpLinkedPattern->GetNextPtr(); | |
155 | } | |
156 | } | |
157 | } | |
158 | } | |
159 | } | |
160 | ||
161 | int tmpcnt = countPatterns(tmpPattern); | |
162 | cout << "AliHLTPHOSRcuAltroPatternTest::countAllPatterns the total number of patterns found is" << tmpcnt << endl; | |
163 | PrintPatterns(tmpPattern); | |
164 | ||
165 | delete tmpPattern; | |
166 | ||
167 | return tmpcnt; | |
168 | ||
169 | } | |
170 | ||
171 | ||
172 | void | |
173 | AliHLTPHOSRcuAltroPatternTest::PrintStatistics() const | |
174 | { | |
175 | for(int z=0; z < NZROWSRCU; z++) | |
176 | { | |
177 | for(int x=0; x < NXCOLUMNSRCU; x++) | |
178 | { | |
179 | for(int gain = 0; gain < NGAINS; gain ++) | |
180 | { | |
181 | int tmp = countPatterns(fPerChannelPatterns[z][x][gain]); | |
182 | if(tmp > 2) | |
183 | { | |
184 | cout << "z = "<< z <<" x " << x << " gain "<< gain << " Has "<< tmp <<" patterns " <<endl; | |
185 | } | |
186 | } | |
187 | } | |
188 | } | |
189 | ||
190 | } | |
191 | ||
192 | ||
193 | //TODO, both argument and fucntion should be constant, but coannot right | |
194 | //because of some problem with the template Dumpdata function of AliHLTPHOSBase | |
195 | void | |
196 | AliHLTPHOSRcuAltroPatternTest::PrintPatterns(AliHLTPHOSPattern *pattern) | |
197 | { | |
198 | // const AliHLTPHOSPattern *tmpPattern = pattern; | |
199 | const AliHLTPHOSPattern *tmpPattern = pattern; | |
200 | ||
201 | cout << endl; | |
202 | cout <<"***********************************************************" << endl; | |
203 | cout <<"***************PRINTING PATTERNS **************************" << endl; | |
204 | cout <<"***********************************************************" << endl; | |
205 | ||
206 | while(tmpPattern != 0) | |
207 | { | |
208 | const_cast<AliHLTPHOSPattern *>(tmpPattern)->PrintPattern(); | |
209 | tmpPattern = tmpPattern->GetNextPtr(); | |
210 | } | |
211 | ||
212 | cout <<endl; | |
213 | ||
214 | } | |
215 |