Line data Source code
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 "AliEMCALTriggerSTUDCSConfig.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>
42 : #include <cstdlib>
43 :
44 42 : ClassImp(AliEMCALTriggerSTU)
45 :
46 : //_______________
47 0 : AliEMCALTriggerSTU::AliEMCALTriggerSTU() : AliEMCALTriggerBoard()
48 0 : ,fDCSConfig(0x0)
49 0 : {
50 : // Ctor
51 0 : fGammaTh[0] = fGammaTh[1] = 0;
52 0 : fJetTh[0] = fJetTh[1] = 0;
53 0 : }
54 :
55 : //_______________
56 2 : AliEMCALTriggerSTU::AliEMCALTriggerSTU(AliEMCALTriggerSTUDCSConfig *dcsConf, const TVector2& RS) : AliEMCALTriggerBoard(RS)
57 2 : ,fDCSConfig(dcsConf)
58 10 : {
59 : // Ctor
60 2 : fGammaTh[0] = fGammaTh[1] = 0;
61 2 : fJetTh[0] = fJetTh[1] = 0;
62 4 : }
63 :
64 : //_______________
65 : AliEMCALTriggerSTU::~AliEMCALTriggerSTU()
66 8 : {
67 : // Dtor
68 8 : }
69 :
70 : //_______________
71 : void AliEMCALTriggerSTU::Build( TString& str, Int_t iTRU, Int_t** M, const TVector2* rSize )
72 : {
73 : // Build
74 :
75 120 : str.ToLower();
76 :
77 60 : Int_t ix = (iTRU % 2) ? 24 : 0;
78 :
79 60 : Int_t iy = iTRU / 2;
80 :
81 : Int_t** v = 0x0;
82 :
83 60 : if (str.Contains("map"))
84 : {
85 60 : v = fMap;
86 60 : }
87 0 : else if (str.Contains("region"))
88 : {
89 0 : v = fRegion;
90 0 : }
91 : else
92 : {
93 0 : AliError("Operation not allowed: STU won't be configured properly!");
94 : }
95 :
96 60 : if(v){
97 3000 : for (Int_t i=0; i<rSize->X(); i++)
98 14400 : for (Int_t j=0; j<rSize->Y(); j++) v[i + ix][j + iy * 4] = M[i][j];
99 60 : }
100 60 : }
101 :
102 : //_______________
103 : void AliEMCALTriggerSTU::L1(int type)
104 : {
105 : // L1
106 :
107 128 : TVector2 s1, s2, s3, s4;
108 32 : fDCSConfig->GetSegmentation(s1, s2, s3, s4);
109 :
110 32 : switch (type)
111 : {
112 : case kL1GammaHigh:
113 : case kL1GammaLow:
114 16 : SetSubRegionSize(s1);
115 16 : SetPatchSize(s2);
116 : break;
117 : case kL1JetHigh:
118 : case kL1JetLow:
119 16 : SetSubRegionSize(s3);
120 16 : SetPatchSize(s4);
121 : break;
122 : default:
123 0 : AliError("Not supported L1 trigger type");
124 0 : return;
125 : break;
126 : }
127 :
128 64 : SlidingWindow(GetThreshold(type));
129 160 : AliDebug(999, Form("STU type %d sliding window w/ thr %d found %d patches", type, GetThreshold(type), fPatches->GetEntriesFast()));
130 64 : }
131 :
132 : //___________
133 : void AliEMCALTriggerSTU::ComputeThFromV0(int type, const Int_t M[])
134 : {
135 : // Compute threshold from V0
136 :
137 : Short_t P[3] = {0};
138 :
139 32 : switch (type)
140 : {
141 : case kL1GammaHigh:
142 4 : P[0] = fDCSConfig->GetG(0, 0);
143 4 : P[1] = fDCSConfig->GetG(1, 0);
144 4 : P[2] = fDCSConfig->GetG(2, 0);
145 4 : break;
146 : case kL1GammaLow:
147 4 : P[0] = fDCSConfig->GetG(0, 1);
148 4 : P[1] = fDCSConfig->GetG(1, 1);
149 4 : P[2] = fDCSConfig->GetG(2, 1);
150 4 : break;
151 : case kL1JetHigh:
152 4 : P[0] = fDCSConfig->GetJ(0, 0);
153 4 : P[1] = fDCSConfig->GetJ(1, 0);
154 4 : P[2] = fDCSConfig->GetJ(2, 0);
155 4 : break;
156 : case kL1JetLow:
157 4 : P[0] = fDCSConfig->GetJ(0, 1);
158 4 : P[1] = fDCSConfig->GetJ(1, 1);
159 4 : P[2] = fDCSConfig->GetJ(2, 1);
160 4 : break;
161 : default:
162 0 : AliError("AliEMCALTriggerSTU::ComputeThFromV0(): Undefined trigger type, pls check!");
163 0 : return;
164 : }
165 :
166 16 : ULong64_t v0sum = M[0] + M[1];
167 :
168 16 : ULong64_t sqrV0 = v0sum * v0sum;
169 :
170 16 : sqrV0 *= P[0];
171 :
172 16 : sqrV0 >>= 32;
173 :
174 16 : v0sum *= P[1];
175 :
176 16 : v0sum >>= 16;
177 :
178 16 : SetThreshold(type, (UShort_t)(sqrV0 + v0sum + P[2]));
179 32 : }
180 :
181 : //___________
182 : void AliEMCALTriggerSTU::SetThreshold(int type, Int_t v)
183 : {
184 : // Set threshold
185 :
186 64 : switch (type)
187 : {
188 : case kL1GammaHigh:
189 8 : fGammaTh[0] = v;
190 8 : break;
191 : case kL1GammaLow:
192 8 : fGammaTh[1] = v;
193 8 : break;
194 : case kL1JetHigh:
195 8 : fJetTh[0] = v;
196 8 : break;
197 : case kL1JetLow:
198 8 : fJetTh[1] = v;
199 8 : break;
200 : default:
201 0 : AliError("AliEMCALTriggerSTU::SetThreshold(): Undefined trigger type, pls check!");
202 0 : }
203 32 : }
204 :
205 : //___________
206 : Int_t AliEMCALTriggerSTU::GetThreshold(int type)
207 : {
208 : // Compute threshold FIXME: need an access to the OCDB
209 : // to get f(V0) parameters depending on trigger type
210 :
211 96 : switch (type)
212 : {
213 : case kL1GammaHigh:
214 12 : return fGammaTh[0];
215 : break;
216 : case kL1GammaLow:
217 12 : return fGammaTh[1];
218 : break;
219 : case kL1JetHigh:
220 12 : return fJetTh[0];
221 : break;
222 : case kL1JetLow:
223 12 : return fJetTh[1];
224 : break;
225 : default:
226 0 : AliError("AliEMCALTriggerSTU::GetThreshold(): Undefined trigger type, pls check!");
227 : }
228 :
229 0 : return 0;
230 48 : }
231 :
232 : //__________
233 : void AliEMCALTriggerSTU::Reset()
234 : {
235 : // Reset
236 :
237 80 : fPatches->Delete();
238 40 : }
|