]>
Commit | Line | Data |
---|---|---|
916f1e76 | 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 | /* | |
17 | ||
18 | ||
19 | ||
20 | ||
21 | Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3 | |
22 | */ | |
23 | ||
24 | #include "AliEMCALTriggerSTU.h" | |
25 | #include "AliCDBManager.h" | |
26 | #include "AliCDBEntry.h" | |
fff39dd1 | 27 | #include "AliEMCALTriggerSTUDCSConfig.h" |
916f1e76 | 28 | #include "AliVZEROCalibData.h" |
29 | #include "AliVZEROdigit.h" | |
30 | #include "AliEMCALTriggerPatch.h" | |
31 | #include "AliESDVZERO.h" | |
32 | #include "AliLog.h" | |
33 | ||
34 | #include <TClonesArray.h> | |
35 | #include <TSystem.h> | |
36 | #include <TH2F.h> | |
37 | #include <TFile.h> | |
38 | #include <TTree.h> | |
39 | ||
40 | #include <fstream> | |
41 | #include <Riostream.h> | |
c58cfdff | 42 | #include <cstdlib> |
916f1e76 | 43 | |
44 | ClassImp(AliEMCALTriggerSTU) | |
45 | ||
46 | //_______________ | |
47 | AliEMCALTriggerSTU::AliEMCALTriggerSTU() : AliEMCALTriggerBoard() | |
fff39dd1 | 48 | ,fGammaTh(0) |
49 | ,fJetTh(0) | |
50 | ,fDCSConfig(0x0) | |
916f1e76 | 51 | { |
79b05051 | 52 | // Ctor |
916f1e76 | 53 | } |
54 | ||
55 | //_______________ | |
fff39dd1 | 56 | AliEMCALTriggerSTU::AliEMCALTriggerSTU(AliEMCALTriggerSTUDCSConfig *dcsConf, const TVector2& RS) : AliEMCALTriggerBoard(RS) |
57 | ,fGammaTh(0) | |
58 | ,fJetTh(0) | |
59 | ,fDCSConfig(dcsConf) | |
916f1e76 | 60 | { |
79b05051 | 61 | // Ctor |
916f1e76 | 62 | } |
63 | ||
64 | //_______________ | |
65 | AliEMCALTriggerSTU::~AliEMCALTriggerSTU() | |
66 | { | |
79b05051 | 67 | // Dtor |
916f1e76 | 68 | } |
69 | ||
de39a0ff | 70 | //_______________ |
71 | void AliEMCALTriggerSTU::Build( TString& str, Int_t iTRU, Int_t** M, const TVector2* rSize ) | |
72 | { | |
79b05051 | 73 | // Build |
74 | ||
de39a0ff | 75 | str.ToLower(); |
76 | ||
77 | Int_t ix = (iTRU % 2) ? 24 : 0; | |
78 | ||
79 | Int_t iy = iTRU / 2; | |
916f1e76 | 80 | |
de39a0ff | 81 | Int_t** v = 0x0; |
916f1e76 | 82 | |
de39a0ff | 83 | if (str.Contains("map")) |
916f1e76 | 84 | { |
de39a0ff | 85 | v = fMap; |
916f1e76 | 86 | } |
de39a0ff | 87 | else if (str.Contains("region")) |
916f1e76 | 88 | { |
de39a0ff | 89 | v = fRegion; |
90 | } | |
91 | else | |
92 | { | |
93 | AliError("Operation not allowed: STU won't be configured properly!"); | |
94 | } | |
a51e676d | 95 | |
96 | if(v){ | |
97 | for (Int_t i=0; i<rSize->X(); i++) | |
98 | for (Int_t j=0; j<rSize->Y(); j++) v[i + ix][j + iy * 4] = M[i][j]; | |
99 | } | |
916f1e76 | 100 | } |
101 | ||
102 | //_______________ | |
de39a0ff | 103 | void AliEMCALTriggerSTU::L1(TriggerType_t type) |
916f1e76 | 104 | { |
79b05051 | 105 | // L1 |
106 | ||
de39a0ff | 107 | TVector2 s1, s2, s3, s4; |
108 | fDCSConfig->GetSegmentation(s1, s2, s3, s4); | |
109 | ||
110 | switch (type) | |
111 | { | |
112 | case kL1Gamma: | |
113 | SetSubRegionSize(s1); | |
114 | SetPatchSize(s2); | |
115 | break; | |
116 | case kL1Jet: | |
117 | SetSubRegionSize(s3); | |
118 | SetPatchSize(s4); | |
119 | break; | |
120 | default: | |
121 | AliError("Not supported L1 trigger type"); | |
122 | return; | |
123 | break; | |
124 | } | |
125 | ||
126 | SlidingWindow(type, GetThreshold(type)); | |
916f1e76 | 127 | } |
128 | ||
129 | //________________ | |
de39a0ff | 130 | void AliEMCALTriggerSTU::PrintADC( TriggerType_t type, TVector2& pos, TVector2& idx ) |
916f1e76 | 131 | { |
79b05051 | 132 | // Dump |
133 | ||
de39a0ff | 134 | Int_t ix = (Int_t) (( pos.X() + fPatchSize->X() ) * fSubRegionSize->X()); |
135 | ||
136 | Int_t iy = (Int_t) (( pos.Y() + fPatchSize->Y() ) * fSubRegionSize->Y()); | |
916f1e76 | 137 | |
138 | TString subRegionADC[] = {"0->15", "16->31", "32->47", "48->63", "64->79", "80->95"}; | |
139 | ||
140 | switch ( type ) | |
141 | { | |
de39a0ff | 142 | case kL1Gamma: |
916f1e76 | 143 | { |
144 | Int_t iTRU = ( (ix-1) < 24 ) ? 31 - int(pos.Y() / 4) : 15 - int(pos.Y() / 4); | |
145 | ||
146 | printf("TRU #%d row #%d col #%d fastor: ",iTRU,int(idx.Y()),int(idx.X())); | |
147 | ||
da509d54 | 148 | for (Int_t i=(Int_t)(pos.X() * fSubRegionSize->X());i<ix;i++) |
916f1e76 | 149 | { |
da509d54 | 150 | for (Int_t j=(Int_t) (pos.Y() * fSubRegionSize->Y());j<iy;j++) |
916f1e76 | 151 | { |
152 | Int_t jtru = ( i < 24 ) ? 31 - j / 4 : 15 - j / 4; | |
153 | printf("TRU#%d_%d ",jtru,fMap[i][j]); | |
154 | } | |
155 | } | |
156 | ||
157 | cout << endl; | |
158 | } | |
159 | break; | |
de39a0ff | 160 | case kL1Jet: |
916f1e76 | 161 | { |
162 | //Int_t jTRU = ( (ix-1) < 24 ) ? 31 - (iy-1) / 4 : 15 - (iy-1) / 4; | |
163 | ||
164 | printf("jet found at row : %d and col : %d",int(idx.X()),int(idx.Y())); | |
165 | ||
de39a0ff | 166 | Char_t vPair[100]; |
916f1e76 | 167 | Int_t nSubRegion = 0; |
168 | ||
da509d54 | 169 | for (Int_t i=(Int_t)(pos.X() * fSubRegionSize->X());i<ix;i++) |
916f1e76 | 170 | { |
da509d54 | 171 | for (Int_t j=(Int_t)(pos.Y() * fSubRegionSize->Y());j<iy;j++) |
916f1e76 | 172 | { |
173 | Int_t itru = ( i < 24 ) ? 31 - j / 4 : 15 - j / 4; | |
174 | ||
175 | Int_t idSR = fMap[i][j]/16; | |
176 | ||
177 | Char_t value = ((itru << 3) & 0xF8) | (idSR & 0x7); | |
178 | ||
179 | Bool_t isFound = kFALSE; | |
180 | ||
181 | for (Int_t k=0;k<nSubRegion && nSubRegion;k++) | |
182 | { | |
183 | if (vPair[k] == value) isFound = kTRUE; | |
184 | } | |
185 | ||
186 | if (!isFound) | |
187 | { | |
188 | nSubRegion++; | |
916f1e76 | 189 | |
190 | vPair[nSubRegion-1] = value; | |
191 | } | |
192 | } | |
193 | } | |
194 | ||
195 | cout << " fastor:"; | |
196 | for (Int_t i=0;i<nSubRegion;i++) | |
197 | { | |
198 | cout << " TRU#" << ((vPair[i] & 0xF8) >> 3) << "_" << subRegionADC[(vPair[i] & 0x7)]; | |
199 | } | |
200 | ||
201 | cout << endl; | |
916f1e76 | 202 | } |
203 | break; | |
204 | default: | |
205 | AliError("AliEMCALTriggerSTU::PrintADC(): Undefined trigger type, pls check!"); | |
206 | } | |
207 | } | |
208 | ||
916f1e76 | 209 | //___________ |
210 | void AliEMCALTriggerSTU::PatchGenerator(const TClonesArray* lpos, Int_t val) | |
211 | { | |
79b05051 | 212 | // Patch generator |
213 | ||
916f1e76 | 214 | ZeroRegion(); |
215 | ||
216 | Int_t vTRU[32][24][4] ;//= {0}; | |
217 | ||
218 | for (Int_t i = 0; i < 32; i++) | |
219 | for (Int_t j = 0; j < 24; j++) | |
220 | for (Int_t k = 0; k < 4; k++) vTRU[i][j][k]=0; | |
221 | ||
222 | ||
223 | AliWarning("AliEMCALTriggerSTU::PatchGenerator(): STU region has been reset!"); | |
224 | ||
225 | // Fill the patch FOR at 'pos' w/ value 'val' | |
226 | ||
227 | TIter NextPosition( lpos ); | |
228 | ||
229 | while ( TVector2 *pos = (TVector2*)NextPosition() ) | |
230 | { | |
231 | pos->Print(); | |
da509d54 | 232 | for (Int_t i=(Int_t)(pos->X()*fSubRegionSize->X()); i<int((pos->X()+fPatchSize->X())*fSubRegionSize->X()); i++) |
233 | for (Int_t j=(Int_t)(pos->Y()*fSubRegionSize->Y()); j<int((pos->Y()+fPatchSize->Y())*fSubRegionSize->Y()); j++) | |
916f1e76 | 234 | fRegion[i][j] = val; |
235 | } | |
236 | ||
237 | for (Int_t i=0; i<2; i++) | |
238 | { | |
239 | for (Int_t j=0; j<16; j++) | |
240 | { | |
241 | Int_t iTRU = ( !i ) ? 31 - j : 15 - j; | |
242 | ||
243 | for (Int_t i1=24*i; i1<24*(i+1); i1++) | |
244 | { | |
245 | for (Int_t j1=4*j; j1<4*(j+1); j1++) | |
246 | { | |
247 | vTRU[iTRU][i1%24][j1%4] = fRegion[i1][j1]; | |
248 | } | |
249 | } | |
250 | } | |
251 | } | |
252 | ||
253 | gSystem->Exec(Form("mkdir -p GP")); | |
254 | ||
255 | for (Int_t i=0; i<32; i++) | |
256 | { | |
257 | std::ofstream outfile(Form("GP/data_TRU%d.txt",i),std::ios::trunc); | |
258 | ||
259 | for (Int_t j=0;j<96;j++) | |
260 | { | |
261 | Int_t ietam, iphim; | |
262 | ||
263 | if ( int(i / 16) ) | |
264 | { | |
265 | ietam = j/4; | |
266 | iphim = 3 - j%4; | |
267 | } | |
268 | else | |
269 | { | |
270 | ietam = 23 - j/4; | |
271 | iphim = j%4; | |
272 | } | |
273 | ||
274 | outfile << vTRU[i][ietam][iphim] << endl; | |
275 | } | |
276 | ||
277 | outfile.close(); | |
278 | } | |
279 | } | |
280 | ||
281 | //___________ | |
804b828a | 282 | void AliEMCALTriggerSTU::ComputeThFromV0(TriggerType_t type, const Int_t M[]) |
fff39dd1 | 283 | { |
79b05051 | 284 | // Compute threshold from V0 |
285 | ||
804b828a | 286 | Short_t P[3] = {0}; |
287 | ||
288 | switch (type) | |
289 | { | |
290 | case kL1Gamma: | |
291 | P[0] = fDCSConfig->GetGA(); | |
292 | P[1] = fDCSConfig->GetGB(); | |
293 | P[2] = fDCSConfig->GetGC(); | |
294 | break; | |
295 | case kL1Jet: | |
296 | P[0] = fDCSConfig->GetJA(); | |
297 | P[1] = fDCSConfig->GetJB(); | |
298 | P[2] = fDCSConfig->GetJC(); | |
299 | break; | |
300 | default: | |
301 | AliError("AliEMCALTriggerSTU::ComputeThFromV0(): Undefined trigger type, pls check!"); | |
302 | return; | |
303 | } | |
304 | ||
305 | ULong64_t v0sum = M[0] + M[1]; | |
306 | ||
307 | ULong64_t sqrV0 = v0sum * v0sum; | |
308 | ||
309 | sqrV0 *= P[0]; | |
310 | sqrV0 >>= 32; | |
311 | ||
312 | v0sum *= P[1]; | |
fff39dd1 | 313 | |
804b828a | 314 | v0sum >>= 16; |
fff39dd1 | 315 | |
804b828a | 316 | SetThreshold(type, (UShort_t)(sqrV0 + v0sum + P[2])); |
de39a0ff | 317 | } |
318 | ||
319 | //___________ | |
320 | void AliEMCALTriggerSTU::SetThreshold(TriggerType_t type, Int_t v) | |
321 | { | |
79b05051 | 322 | // Set threshold |
323 | ||
de39a0ff | 324 | switch (type) |
325 | { | |
326 | case kL1Gamma: | |
327 | fGammaTh = v; | |
328 | break; | |
329 | case kL1Jet: | |
330 | fJetTh = v; | |
331 | break; | |
332 | default: | |
333 | AliError("AliEMCALTriggerSTU::SetThreshold(): Undefined trigger type, pls check!"); | |
334 | } | |
fff39dd1 | 335 | } |
336 | ||
337 | //___________ | |
de39a0ff | 338 | Int_t AliEMCALTriggerSTU::GetThreshold(TriggerType_t type) |
916f1e76 | 339 | { |
340 | // Compute threshold FIXME: need an access to the OCDB | |
341 | // to get f(V0) parameters depending on trigger type | |
342 | ||
de39a0ff | 343 | |
344 | switch (type) | |
916f1e76 | 345 | { |
de39a0ff | 346 | case kL1Gamma: |
fff39dd1 | 347 | return fGammaTh; |
916f1e76 | 348 | break; |
de39a0ff | 349 | case kL1Jet: |
fff39dd1 | 350 | return fJetTh; |
916f1e76 | 351 | break; |
352 | default: | |
fff39dd1 | 353 | AliError("AliEMCALTriggerSTU::GetThreshold(): Undefined trigger type, pls check!"); |
916f1e76 | 354 | } |
355 | ||
fff39dd1 | 356 | return 0; |
916f1e76 | 357 | } |
358 | ||
359 | //__________ | |
360 | void AliEMCALTriggerSTU::Reset() | |
361 | { | |
79b05051 | 362 | // Reset |
363 | ||
916f1e76 | 364 | fPatches->Delete(); |
365 | } |