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