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