]>
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 | { |
52 | // | |
53 | fV0M[0] = fV0M[1] = 0; | |
54 | } | |
55 | ||
56 | //_______________ | |
fff39dd1 | 57 | AliEMCALTriggerSTU::AliEMCALTriggerSTU(AliEMCALTriggerSTUDCSConfig *dcsConf, const TVector2& RS) : AliEMCALTriggerBoard(RS) |
58 | ,fGammaTh(0) | |
59 | ,fJetTh(0) | |
60 | ,fDCSConfig(dcsConf) | |
916f1e76 | 61 | { |
62 | // | |
63 | fV0M[0] = fV0M[1] = 0; | |
64 | } | |
65 | ||
66 | //_______________ | |
67 | AliEMCALTriggerSTU::~AliEMCALTriggerSTU() | |
68 | { | |
69 | // | |
70 | } | |
71 | ||
72 | //_______________ | |
73 | void AliEMCALTriggerSTU::BuildMap( Int_t iTRU, Int_t** M, const TVector2* rSize ) | |
74 | { | |
75 | // | |
76 | if ( iTRU == 31 ) iTRU = 35; | |
77 | ||
78 | Int_t i2y = iTRU / 3 / 2; | |
79 | ||
80 | if ( ( iTRU / 3 ) % 2 ) // odd (z<0) C side | |
81 | { | |
82 | Int_t i1y = 2 - ( iTRU - int( iTRU / 3 ) * 3 ); // 0 1 2 w/ increasing phi | |
83 | ||
84 | for (Int_t i=0; i<rSize->X(); i++) | |
85 | for (Int_t j=0; j<rSize->Y(); j++) fMap[24+i][j + i1y * 4 + i2y * 12] = M[i][j]; | |
86 | } | |
87 | else // A side | |
88 | { | |
89 | Int_t i1y = iTRU - int( iTRU / 3 ) * 3; | |
90 | ||
91 | for (Int_t i=0; i<rSize->X(); i++) | |
92 | for (Int_t j=0; j<rSize->Y(); j++) fMap[ i][j + i1y * 4 + i2y * 12] = M[i][j]; | |
93 | } | |
94 | } | |
95 | ||
96 | //_______________ | |
97 | void AliEMCALTriggerSTU::L1( L1TriggerType_t type ) | |
98 | { | |
99 | // | |
fff39dd1 | 100 | SlidingWindow( type, GetThreshold( type ) ); |
916f1e76 | 101 | } |
102 | ||
103 | //________________ | |
104 | void AliEMCALTriggerSTU::PrintADC( L1TriggerType_t type, TVector2& pos, TVector2& idx ) | |
105 | { | |
106 | // | |
da509d54 | 107 | Int_t ix = (Int_t) (( pos.X() + fPatchSize->X() ) * fSubRegionSize->X()); |
108 | Int_t iy = (Int_t) (( pos.Y() + fPatchSize->Y() ) * fSubRegionSize->Y()); | |
916f1e76 | 109 | |
110 | TString subRegionADC[] = {"0->15", "16->31", "32->47", "48->63", "64->79", "80->95"}; | |
111 | ||
112 | switch ( type ) | |
113 | { | |
114 | case kGamma: | |
115 | { | |
116 | Int_t iTRU = ( (ix-1) < 24 ) ? 31 - int(pos.Y() / 4) : 15 - int(pos.Y() / 4); | |
117 | ||
118 | printf("TRU #%d row #%d col #%d fastor: ",iTRU,int(idx.Y()),int(idx.X())); | |
119 | ||
da509d54 | 120 | for (Int_t i=(Int_t)(pos.X() * fSubRegionSize->X());i<ix;i++) |
916f1e76 | 121 | { |
da509d54 | 122 | for (Int_t j=(Int_t) (pos.Y() * fSubRegionSize->Y());j<iy;j++) |
916f1e76 | 123 | { |
124 | Int_t jtru = ( i < 24 ) ? 31 - j / 4 : 15 - j / 4; | |
125 | printf("TRU#%d_%d ",jtru,fMap[i][j]); | |
126 | } | |
127 | } | |
128 | ||
129 | cout << endl; | |
130 | } | |
131 | break; | |
132 | case kJet: | |
133 | { | |
134 | //Int_t jTRU = ( (ix-1) < 24 ) ? 31 - (iy-1) / 4 : 15 - (iy-1) / 4; | |
135 | ||
136 | printf("jet found at row : %d and col : %d",int(idx.X()),int(idx.Y())); | |
137 | ||
138 | Char_t* vPair = 0x0; | |
139 | Int_t nSubRegion = 0; | |
140 | ||
da509d54 | 141 | for (Int_t i=(Int_t)(pos.X() * fSubRegionSize->X());i<ix;i++) |
916f1e76 | 142 | { |
da509d54 | 143 | for (Int_t j=(Int_t)(pos.Y() * fSubRegionSize->Y());j<iy;j++) |
916f1e76 | 144 | { |
145 | Int_t itru = ( i < 24 ) ? 31 - j / 4 : 15 - j / 4; | |
146 | ||
147 | Int_t idSR = fMap[i][j]/16; | |
148 | ||
149 | Char_t value = ((itru << 3) & 0xF8) | (idSR & 0x7); | |
150 | ||
151 | Bool_t isFound = kFALSE; | |
152 | ||
153 | for (Int_t k=0;k<nSubRegion && nSubRegion;k++) | |
154 | { | |
155 | if (vPair[k] == value) isFound = kTRUE; | |
156 | } | |
157 | ||
158 | if (!isFound) | |
159 | { | |
160 | nSubRegion++; | |
161 | vPair = (Char_t*)realloc(vPair, nSubRegion * sizeof(Char_t)); | |
162 | if (vPair == NULL) {AliError("Error (re)allocating PrintADC() memory");} | |
163 | ||
164 | vPair[nSubRegion-1] = value; | |
165 | } | |
166 | } | |
167 | } | |
168 | ||
169 | cout << " fastor:"; | |
170 | for (Int_t i=0;i<nSubRegion;i++) | |
171 | { | |
172 | cout << " TRU#" << ((vPair[i] & 0xF8) >> 3) << "_" << subRegionADC[(vPair[i] & 0x7)]; | |
173 | } | |
174 | ||
175 | cout << endl; | |
176 | if (vPair) delete[] vPair; | |
177 | } | |
178 | break; | |
179 | default: | |
180 | AliError("AliEMCALTriggerSTU::PrintADC(): Undefined trigger type, pls check!"); | |
181 | } | |
182 | } | |
183 | ||
916f1e76 | 184 | //________________ |
185 | void AliEMCALTriggerSTU::FetchFOR( Int_t iTRU, Int_t **R, const TVector2* rSize ) | |
186 | { | |
187 | // L1 triggers run over the whole EMCal surface | |
188 | // STU builds its own fRegion aggregating TRU fRegion into one | |
189 | ||
190 | // STU I from TRUs O in Olivier's coordinate system | |
191 | ||
192 | if ( iTRU == 31 ) iTRU = 35; | |
193 | ||
194 | Int_t i2y = iTRU / 3 / 2; | |
195 | ||
196 | if ( ( iTRU / 3 ) % 2 ) // C side odd (z<0) | |
197 | { | |
198 | Int_t i1y = 2 - ( iTRU - int( iTRU / 3 ) * 3 ); // 0 1 2 w/ increasing phi | |
199 | ||
200 | for (Int_t i=0; i<rSize->X(); i++) // 0:23 0:4 | |
201 | for (Int_t j=0; j<rSize->Y(); j++) fRegion[24+i][j + i1y * 4 + i2y * 12] = R[i][j]; | |
202 | } | |
203 | else // A side | |
204 | { | |
205 | Int_t i1y = iTRU - int( iTRU / 3 ) * 3; | |
206 | ||
207 | for (Int_t i=0; i<rSize->X(); i++) | |
208 | for (Int_t j=0; j<rSize->Y(); j++) fRegion[ i][j + i1y * 4 + i2y * 12] = R[i][j]; | |
209 | } | |
210 | } | |
211 | ||
212 | //___________ | |
213 | void AliEMCALTriggerSTU::PatchGenerator(const TClonesArray* lpos, Int_t val) | |
214 | { | |
215 | ZeroRegion(); | |
216 | ||
217 | Int_t vTRU[32][24][4] ;//= {0}; | |
218 | ||
219 | for (Int_t i = 0; i < 32; i++) | |
220 | for (Int_t j = 0; j < 24; j++) | |
221 | for (Int_t k = 0; k < 4; k++) vTRU[i][j][k]=0; | |
222 | ||
223 | ||
224 | AliWarning("AliEMCALTriggerSTU::PatchGenerator(): STU region has been reset!"); | |
225 | ||
226 | // Fill the patch FOR at 'pos' w/ value 'val' | |
227 | ||
228 | TIter NextPosition( lpos ); | |
229 | ||
230 | while ( TVector2 *pos = (TVector2*)NextPosition() ) | |
231 | { | |
232 | pos->Print(); | |
da509d54 | 233 | for (Int_t i=(Int_t)(pos->X()*fSubRegionSize->X()); i<int((pos->X()+fPatchSize->X())*fSubRegionSize->X()); i++) |
234 | for (Int_t j=(Int_t)(pos->Y()*fSubRegionSize->Y()); j<int((pos->Y()+fPatchSize->Y())*fSubRegionSize->Y()); j++) | |
916f1e76 | 235 | fRegion[i][j] = val; |
236 | } | |
237 | ||
238 | for (Int_t i=0; i<2; i++) | |
239 | { | |
240 | for (Int_t j=0; j<16; j++) | |
241 | { | |
242 | Int_t iTRU = ( !i ) ? 31 - j : 15 - j; | |
243 | ||
244 | for (Int_t i1=24*i; i1<24*(i+1); i1++) | |
245 | { | |
246 | for (Int_t j1=4*j; j1<4*(j+1); j1++) | |
247 | { | |
248 | vTRU[iTRU][i1%24][j1%4] = fRegion[i1][j1]; | |
249 | } | |
250 | } | |
251 | } | |
252 | } | |
253 | ||
254 | gSystem->Exec(Form("mkdir -p GP")); | |
255 | ||
256 | for (Int_t i=0; i<32; i++) | |
257 | { | |
258 | std::ofstream outfile(Form("GP/data_TRU%d.txt",i),std::ios::trunc); | |
259 | ||
260 | for (Int_t j=0;j<96;j++) | |
261 | { | |
262 | Int_t ietam, iphim; | |
263 | ||
264 | if ( int(i / 16) ) | |
265 | { | |
266 | ietam = j/4; | |
267 | iphim = 3 - j%4; | |
268 | } | |
269 | else | |
270 | { | |
271 | ietam = 23 - j/4; | |
272 | iphim = j%4; | |
273 | } | |
274 | ||
275 | outfile << vTRU[i][ietam][iphim] << endl; | |
276 | } | |
277 | ||
278 | outfile.close(); | |
279 | } | |
280 | } | |
281 | ||
282 | //___________ | |
fff39dd1 | 283 | void AliEMCALTriggerSTU::SetV0Multiplicity(const Int_t M[], Int_t n) |
284 | { | |
285 | // | |
286 | for (Int_t i=0;i<n;i++) fV0M[i] = M[i]; | |
287 | ||
288 | Int_t sumV0 = fV0M[0] + fV0M[1]; | |
289 | ||
290 | if (!sumV0) AliWarning("V0A + V0C is null!"); | |
291 | ||
292 | fGammaTh = fDCSConfig->GetGA()*sumV0*sumV0+fDCSConfig->GetGB()*sumV0+fDCSConfig->GetGC(); | |
293 | ||
294 | fJetTh = fDCSConfig->GetJA()*sumV0*sumV0+fDCSConfig->GetJB()*sumV0+fDCSConfig->GetJC(); | |
295 | } | |
296 | ||
297 | //___________ | |
298 | Int_t AliEMCALTriggerSTU::GetThreshold( L1TriggerType_t type ) | |
916f1e76 | 299 | { |
300 | // Compute threshold FIXME: need an access to the OCDB | |
301 | // to get f(V0) parameters depending on trigger type | |
302 | ||
303 | switch ( type ) | |
304 | { | |
305 | case kGamma: | |
fff39dd1 | 306 | return fGammaTh; |
916f1e76 | 307 | break; |
308 | case kJet: | |
fff39dd1 | 309 | return fJetTh; |
916f1e76 | 310 | break; |
311 | default: | |
fff39dd1 | 312 | AliError("AliEMCALTriggerSTU::GetThreshold(): Undefined trigger type, pls check!"); |
916f1e76 | 313 | } |
314 | ||
fff39dd1 | 315 | return 0; |
916f1e76 | 316 | } |
317 | ||
318 | //__________ | |
319 | void AliEMCALTriggerSTU::Reset() | |
320 | { | |
321 | fPatches->Delete(); | |
322 | } |