change definition of TRU fitter, remove unneeded class dependencies
[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,fDCSConfig(0x0)
916f1e76 49{
79b05051 50 // Ctor
63c22917 51 fGammaTh[0] = fGammaTh[1] = 0;
52 fJetTh[0] = fJetTh[1] = 0;
916f1e76 53}
54
55//_______________
fff39dd1 56AliEMCALTriggerSTU::AliEMCALTriggerSTU(AliEMCALTriggerSTUDCSConfig *dcsConf, const TVector2& RS) : AliEMCALTriggerBoard(RS)
fff39dd1 57,fDCSConfig(dcsConf)
916f1e76 58{
79b05051 59 // Ctor
63c22917 60 fGammaTh[0] = fGammaTh[1] = 0;
61 fJetTh[0] = fJetTh[1] = 0;
916f1e76 62}
63
64//_______________
65AliEMCALTriggerSTU::~AliEMCALTriggerSTU()
66{
79b05051 67 // Dtor
916f1e76 68}
69
70//_______________
de39a0ff 71void 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//_______________
63c22917 103void AliEMCALTriggerSTU::L1(int 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 {
63c22917 112 case kL1GammaHigh:
113 case kL1GammaLow:
de39a0ff 114 SetSubRegionSize(s1);
115 SetPatchSize(s2);
116 break;
63c22917 117 case kL1JetHigh:
118 case kL1JetLow:
de39a0ff 119 SetSubRegionSize(s3);
120 SetPatchSize(s4);
121 break;
122 default:
123 AliError("Not supported L1 trigger type");
124 return;
125 break;
126 }
127
63c22917 128 SlidingWindow(GetThreshold(type));
129 AliDebug(999, Form("STU type %d sliding window w/ thr %d found %d patches", type, GetThreshold(type), fPatches->GetEntriesFast()));
916f1e76 130}
131
916f1e76 132//___________
63c22917 133void AliEMCALTriggerSTU::ComputeThFromV0(int type, const Int_t M[])
fff39dd1 134{
79b05051 135 // Compute threshold from V0
136
804b828a 137 Short_t P[3] = {0};
138
139 switch (type)
140 {
63c22917 141 case kL1GammaHigh:
142 P[0] = fDCSConfig->GetG(0, 0);
143 P[1] = fDCSConfig->GetG(1, 0);
144 P[2] = fDCSConfig->GetG(2, 0);
145 break;
146 case kL1GammaLow:
147 P[0] = fDCSConfig->GetG(0, 1);
148 P[1] = fDCSConfig->GetG(1, 1);
149 P[2] = fDCSConfig->GetG(2, 1);
804b828a 150 break;
63c22917 151 case kL1JetHigh:
152 P[0] = fDCSConfig->GetJ(0, 0);
153 P[1] = fDCSConfig->GetJ(1, 0);
154 P[2] = fDCSConfig->GetJ(2, 0);
155 break;
156 case kL1JetLow:
157 P[0] = fDCSConfig->GetJ(0, 1);
158 P[1] = fDCSConfig->GetJ(1, 1);
159 P[2] = fDCSConfig->GetJ(2, 1);
804b828a 160 break;
161 default:
162 AliError("AliEMCALTriggerSTU::ComputeThFromV0(): Undefined trigger type, pls check!");
163 return;
164 }
165
166 ULong64_t v0sum = M[0] + M[1];
167
168 ULong64_t sqrV0 = v0sum * v0sum;
169
170 sqrV0 *= P[0];
63c22917 171
804b828a 172 sqrV0 >>= 32;
173
174 v0sum *= P[1];
fff39dd1 175
804b828a 176 v0sum >>= 16;
fff39dd1 177
804b828a 178 SetThreshold(type, (UShort_t)(sqrV0 + v0sum + P[2]));
de39a0ff 179}
180
181//___________
63c22917 182void AliEMCALTriggerSTU::SetThreshold(int type, Int_t v)
de39a0ff 183{
79b05051 184 // Set threshold
185
de39a0ff 186 switch (type)
187 {
63c22917 188 case kL1GammaHigh:
189 fGammaTh[0] = v;
de39a0ff 190 break;
63c22917 191 case kL1GammaLow:
192 fGammaTh[1] = v;
193 break;
194 case kL1JetHigh:
195 fJetTh[0] = v;
196 break;
197 case kL1JetLow:
198 fJetTh[1] = v;
de39a0ff 199 break;
200 default:
201 AliError("AliEMCALTriggerSTU::SetThreshold(): Undefined trigger type, pls check!");
202 }
fff39dd1 203}
204
205//___________
63c22917 206Int_t AliEMCALTriggerSTU::GetThreshold(int type)
916f1e76 207{
208 // Compute threshold FIXME: need an access to the OCDB
209 // to get f(V0) parameters depending on trigger type
210
de39a0ff 211 switch (type)
916f1e76 212 {
63c22917 213 case kL1GammaHigh:
214 return fGammaTh[0];
215 break;
216 case kL1GammaLow:
217 return fGammaTh[1];
218 break;
219 case kL1JetHigh:
220 return fJetTh[0];
916f1e76 221 break;
63c22917 222 case kL1JetLow:
223 return fJetTh[1];
916f1e76 224 break;
225 default:
fff39dd1 226 AliError("AliEMCALTriggerSTU::GetThreshold(): Undefined trigger type, pls check!");
916f1e76 227 }
228
fff39dd1 229 return 0;
916f1e76 230}
231
232//__________
233void AliEMCALTriggerSTU::Reset()
234{
79b05051 235 // Reset
236
916f1e76 237 fPatches->Delete();
238}