1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
21 Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
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"
34 #include <TClonesArray.h>
41 #include <Riostream.h>
44 ClassImp(AliEMCALTriggerSTU)
47 AliEMCALTriggerSTU::AliEMCALTriggerSTU() : AliEMCALTriggerBoard()
56 AliEMCALTriggerSTU::AliEMCALTriggerSTU(AliEMCALTriggerSTUDCSConfig *dcsConf, const TVector2& RS) : AliEMCALTriggerBoard(RS)
65 AliEMCALTriggerSTU::~AliEMCALTriggerSTU()
71 void AliEMCALTriggerSTU::Build( TString& str, Int_t iTRU, Int_t** M, const TVector2* rSize )
77 Int_t ix = (iTRU % 2) ? 24 : 0;
83 if (str.Contains("map"))
87 else if (str.Contains("region"))
93 AliError("Operation not allowed: STU won't be configured properly!");
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];
103 void AliEMCALTriggerSTU::L1(TriggerType_t type)
107 TVector2 s1, s2, s3, s4;
108 fDCSConfig->GetSegmentation(s1, s2, s3, s4);
113 SetSubRegionSize(s1);
117 SetSubRegionSize(s3);
121 AliError("Not supported L1 trigger type");
126 SlidingWindow(type, GetThreshold(type));
130 void AliEMCALTriggerSTU::PrintADC( TriggerType_t type, TVector2& pos, TVector2& idx )
134 Int_t ix = (Int_t) (( pos.X() + fPatchSize->X() ) * fSubRegionSize->X());
136 Int_t iy = (Int_t) (( pos.Y() + fPatchSize->Y() ) * fSubRegionSize->Y());
138 TString subRegionADC[] = {"0->15", "16->31", "32->47", "48->63", "64->79", "80->95"};
144 Int_t iTRU = ( (ix-1) < 24 ) ? 31 - int(pos.Y() / 4) : 15 - int(pos.Y() / 4);
146 printf("TRU #%d row #%d col #%d fastor: ",iTRU,int(idx.Y()),int(idx.X()));
148 for (Int_t i=(Int_t)(pos.X() * fSubRegionSize->X());i<ix;i++)
150 for (Int_t j=(Int_t) (pos.Y() * fSubRegionSize->Y());j<iy;j++)
152 Int_t jtru = ( i < 24 ) ? 31 - j / 4 : 15 - j / 4;
153 printf("TRU#%d_%d ",jtru,fMap[i][j]);
162 //Int_t jTRU = ( (ix-1) < 24 ) ? 31 - (iy-1) / 4 : 15 - (iy-1) / 4;
164 printf("jet found at row : %d and col : %d",int(idx.X()),int(idx.Y()));
167 Int_t nSubRegion = 0;
169 for (Int_t i=(Int_t)(pos.X() * fSubRegionSize->X());i<ix;i++)
171 for (Int_t j=(Int_t)(pos.Y() * fSubRegionSize->Y());j<iy;j++)
173 Int_t itru = ( i < 24 ) ? 31 - j / 4 : 15 - j / 4;
175 Int_t idSR = fMap[i][j]/16;
177 Char_t value = ((itru << 3) & 0xF8) | (idSR & 0x7);
179 Bool_t isFound = kFALSE;
181 for (Int_t k=0;k<nSubRegion && nSubRegion;k++)
183 if (vPair[k] == value) isFound = kTRUE;
190 vPair[nSubRegion-1] = value;
196 for (Int_t i=0;i<nSubRegion;i++)
198 cout << " TRU#" << ((vPair[i] & 0xF8) >> 3) << "_" << subRegionADC[(vPair[i] & 0x7)];
205 AliError("AliEMCALTriggerSTU::PrintADC(): Undefined trigger type, pls check!");
210 void AliEMCALTriggerSTU::PatchGenerator(const TClonesArray* lpos, Int_t val)
216 Int_t vTRU[32][24][4] ;//= {0};
218 for (Int_t i = 0; i < 32; i++)
219 for (Int_t j = 0; j < 24; j++)
220 for (Int_t k = 0; k < 4; k++) vTRU[i][j][k]=0;
223 AliWarning("AliEMCALTriggerSTU::PatchGenerator(): STU region has been reset!");
225 // Fill the patch FOR at 'pos' w/ value 'val'
227 TIter NextPosition( lpos );
229 while ( TVector2 *pos = (TVector2*)NextPosition() )
232 for (Int_t i=(Int_t)(pos->X()*fSubRegionSize->X()); i<int((pos->X()+fPatchSize->X())*fSubRegionSize->X()); i++)
233 for (Int_t j=(Int_t)(pos->Y()*fSubRegionSize->Y()); j<int((pos->Y()+fPatchSize->Y())*fSubRegionSize->Y()); j++)
237 for (Int_t i=0; i<2; i++)
239 for (Int_t j=0; j<16; j++)
241 Int_t iTRU = ( !i ) ? 31 - j : 15 - j;
243 for (Int_t i1=24*i; i1<24*(i+1); i1++)
245 for (Int_t j1=4*j; j1<4*(j+1); j1++)
247 vTRU[iTRU][i1%24][j1%4] = fRegion[i1][j1];
253 gSystem->Exec(Form("mkdir -p GP"));
255 for (Int_t i=0; i<32; i++)
257 std::ofstream outfile(Form("GP/data_TRU%d.txt",i),std::ios::trunc);
259 for (Int_t j=0;j<96;j++)
274 outfile << vTRU[i][ietam][iphim] << endl;
282 void AliEMCALTriggerSTU::ComputeThFromV0(TriggerType_t type, const Int_t M[])
284 // Compute threshold from V0
291 P[0] = fDCSConfig->GetGA();
292 P[1] = fDCSConfig->GetGB();
293 P[2] = fDCSConfig->GetGC();
296 P[0] = fDCSConfig->GetJA();
297 P[1] = fDCSConfig->GetJB();
298 P[2] = fDCSConfig->GetJC();
301 AliError("AliEMCALTriggerSTU::ComputeThFromV0(): Undefined trigger type, pls check!");
305 ULong64_t v0sum = M[0] + M[1];
307 ULong64_t sqrV0 = v0sum * v0sum;
316 SetThreshold(type, (UShort_t)(sqrV0 + v0sum + P[2]));
320 void AliEMCALTriggerSTU::SetThreshold(TriggerType_t type, Int_t v)
333 AliError("AliEMCALTriggerSTU::SetThreshold(): Undefined trigger type, pls check!");
338 Int_t AliEMCALTriggerSTU::GetThreshold(TriggerType_t type)
340 // Compute threshold FIXME: need an access to the OCDB
341 // to get f(V0) parameters depending on trigger type
353 AliError("AliEMCALTriggerSTU::GetThreshold(): Undefined trigger type, pls check!");
360 void AliEMCALTriggerSTU::Reset()