Input number added to Print
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTriggerRawDigitMaker.cxx
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 "AliEMCALTriggerRawDigitMaker.h"
25 #include "AliEMCALTriggerSTURawStream.h"
26 #include "AliCaloRawAnalyzerFakeALTRO.h"
27 #include "AliEMCALTriggerRawDigit.h"
28 #include "AliCaloRawStreamV3.h"
29 #include "AliRun.h"
30 #include "AliRunLoader.h"
31 #include "AliEMCAL.h"
32 #include "AliCaloBunchInfo.h"
33 #include "AliRawReader.h"
34 #include "AliEMCALTriggerDCSConfigDB.h"
35 #include "AliEMCALTriggerDCSConfig.h"
36 #include "AliEMCALTriggerTRUDCSConfig.h"
37 #include "AliEMCALTriggerSTUDCSConfig.h"
38 #include "AliEMCALTriggerData.h"
39 #include "AliEMCALTriggerPatch.h"
40 #include "AliLog.h"
41
42 #include "AliRawDataHeader.h"
43 #include "AliRawVEvent.h"
44 #include "AliRawEventHeaderBase.h"
45 #include "AliRawEvent.h"
46 #include "AliRawVEquipment.h"
47 #include "AliRawEquipmentHeader.h"
48
49 #include "Riostream.h"
50
51 #include "AliCaloRawAnalyzerFactory.h"
52
53 namespace
54 {
55         const Int_t kSTUEqId = 4652;
56 }
57
58 ClassImp(AliEMCALTriggerRawDigitMaker)
59
60 //_______________
61 AliEMCALTriggerRawDigitMaker::AliEMCALTriggerRawDigitMaker() : TObject(),
62 fGeometry(0x0),
63 fRawReader(0x0),
64 fCaloRawStream(0x0),
65 fSTURawStream(0x0),
66 fRawDigits(0x0),
67 fRawAnalyzer(0x0),
68 fDCSConfig(0x0),
69 fTriggerData(0x0)
70 {
71   // def ctor
72   
73   AliRunLoader* rl = AliRunLoader::Instance();
74   if (rl && rl->GetAliRun()){
75     AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
76     if(emcal) fGeometry = emcal->GetGeometry();
77   }
78   
79   if(!fGeometry)
80     {
81       AliDebug(1, Form("Using default geometry"));
82       fGeometry =  AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
83     }
84   
85   //  fRawAnalyzer = new AliCaloRawAnalyzerFakeALTRO ();
86   
87   fRawAnalyzer =  (AliCaloRawAnalyzerFakeALTRO*)AliCaloRawAnalyzerFactory::CreateAnalyzer(kFakeAltro);
88
89   fDCSConfig = AliEMCALTriggerDCSConfigDB::Instance();
90
91   Int_t nRawDigits = fGeometry->GetNTotalTRU() * 96;  
92   for (Int_t i=0; i<nRawDigits; i++) fRawDigitIndex[i] = -1;
93 }       
94
95 //_______________
96 AliEMCALTriggerRawDigitMaker::~AliEMCALTriggerRawDigitMaker()
97 {
98         // dtor
99 }
100
101 //_______________
102 void AliEMCALTriggerRawDigitMaker::SetIO(AliRawReader* reader, AliCaloRawStreamV3& in, AliEMCALTriggerSTURawStream& inSTU, TClonesArray* digits, AliEMCALTriggerData* data)
103 {
104         // Connect I/O
105         
106         fRawReader     = reader;
107         fCaloRawStream = &in;
108         fRawDigits     = digits;
109         fSTURawStream  = &inSTU;
110         fTriggerData   = data;
111 }
112
113 //_______________
114 void AliEMCALTriggerRawDigitMaker::Add(const std::vector<AliCaloBunchInfo> &bunchlist)
115 {
116         // Add bunch list
117         
118         Int_t    hwAdd   = fCaloRawStream->GetHWAddress();
119         UShort_t iRCU    = fCaloRawStream->GetDDLNumber() % 2; // 0/1
120         UShort_t iBranch = ( hwAdd >> 11 ) & 0x1;              // 0/1
121         
122         // TRU id       
123         Int_t iTRU = ( (iRCU << 1) | iBranch ) - 1; // 0..2
124         
125         iTRU  = (fCaloRawStream->GetModule() % 2) ? 2 * (2 - iTRU) + 1 : 2 * iTRU;
126         
127         iTRU += 6 * int(fCaloRawStream->GetModule()/2);
128         
129         if (AliDebugLevel())
130         {
131                 printf("===\n");
132                 printf("| Hw Adress: 0x%x => SM# %2d / RCU# %d / Branch# %d / TRU# %2d / ADC# %2d\n",
133                            hwAdd, fCaloRawStream->GetModule(), iRCU, iBranch, iTRU, fCaloRawStream->GetColumn());
134         }
135         
136         Int_t idx;
137         
138         AliEMCALTriggerRawDigit* dig = 0x0;     
139         
140         Int_t timeSamples[256]; for (Int_t j=0; j<256; j++) timeSamples[j] = 0;
141         Int_t nSamples = 0;
142         
143         UInt_t iBin   = bunchlist.at(0).GetStartBin();
144          Int_t iBunch = 0;
145         
146         for (UInt_t i = 0; i < bunchlist.size(); i++)
147         {
148                 AliCaloBunchInfo bunch = bunchlist.at(i);
149                 
150                 if (iBin > bunch.GetStartBin()) 
151                 {
152                         iBin   = bunch.GetStartBin();
153                         iBunch = i;
154                 }
155                 
156                 if (fCaloRawStream->GetColumn() < 96)
157                 {
158                         const UShort_t* sig = bunch.GetData();
159                         Int_t startBin = bunch.GetStartBin();
160                         
161                         for (Int_t iS = 0; iS < bunch.GetLength(); iS++) 
162                         {
163                                 Int_t time = startBin--;
164                                 Int_t amp  = sig[iS];
165                                 
166                                 if (amp) timeSamples[nSamples++] = ((time << 12) & 0xFF000) | (amp & 0xFFF);
167                                 
168                                 if (AliDebugLevel())
169                                 {
170                                         printf("ADC# %2d / time: %2d amplitude: %d\n", fCaloRawStream->GetColumn(), time, amp);
171                                 }
172                         }
173                 }
174         }
175         
176         if (fCaloRawStream->GetColumn() > 95 && fCaloRawStream->GetColumn() < 106)
177         {
178                 Int_t nBits = (fCaloRawStream->GetColumn() == 105) ? 6 : 10;
179                 
180                 const UShort_t* sig = bunchlist.at(iBunch).GetData();
181                 
182                 if (AliDebugLevel()) printf("| L0 id in F-ALTRO => bunch length is: %d\n", bunchlist.at(iBunch).GetLength());
183                 
184                 for (Int_t i = 0; i < bunchlist.at(iBunch).GetLength(); i++) 
185                 {
186                         if (AliDebugLevel()) printf("| sig[%3d]: %x\n",i,sig[i]);
187                                                                                 
188                         for (Int_t j = 0; j < nBits; j++)
189                         {
190                                 if (sig[i] & ( 1 << j ))
191                                 {
192                                         if (AliDebugLevel()) 
193                                         {
194                                                 printf("| Add L0 patch index in TRU# %2d position %2d\n",iTRU,(fCaloRawStream->GetColumn() - 96) * 10 + j);
195                                         }
196                                         
197                                         if (fGeometry->GetAbsFastORIndexFromTRU(iTRU, (fCaloRawStream->GetColumn() - 96) * 10 + j, idx))
198                                         {
199                                                 if (fRawDigitIndex[idx] >= 0)
200                                                 {
201                                                         dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
202                                                 }
203                                                 else
204                                                 {
205                                                         AliDebug(100,"L0: Trying to update trigger info of a non-existent digit!");
206                                                         
207                                                         fRawDigitIndex[idx] = fRawDigits->GetEntriesFast();
208                                                         new((*fRawDigits)[fRawDigits->GetEntriesFast()]) AliEMCALTriggerRawDigit(idx, 0x0, 0);
209                                                         
210                                                         dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
211                                                 }
212                                                 
213                                                 dig->SetL0Time(iBin);
214                                         }
215                                 }
216                         }
217                         
218                         if (fCaloRawStream->GetColumn() == 105 && (sig[i] & (1 << 6))) 
219                         {
220                                 fTriggerData->SetL0Trigger(1, iTRU, 1);
221                                                                                    
222                                 if (AliDebugLevel()) printf("=======TRU# %2d has issued a L0\n",iTRU);
223                         }
224                         
225                         iBin--;
226                 }
227         } 
228         else
229         {
230                 if (nSamples && fGeometry->GetAbsFastORIndexFromTRU(iTRU, fCaloRawStream->GetColumn(), idx)) 
231                 {
232                         if (fRawDigitIndex[idx] < 0)
233                         {
234                                 fRawDigitIndex[idx] = fRawDigits->GetEntriesFast();
235                                 new((*fRawDigits)[fRawDigits->GetEntriesFast()]) AliEMCALTriggerRawDigit(idx, timeSamples, nSamples);
236                         }
237                         else
238                         {
239                                 dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
240                                 dig->SetTimeSamples(timeSamples, nSamples);
241                         }
242                         
243                         if (AliDebugLevel())
244                         {
245                                 printf("| Add TRG digit of id# %4d from TRU# %2d ADC# %2d\n", idx, iTRU, fCaloRawStream->GetColumn());
246
247                                 dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
248                                 dig->Print("");
249
250                                 Int_t iSm, iTru, iEta, iPhi, iD[4], iFor;
251                                 if (fGeometry->GetPositionInTRUFromAbsFastORIndex(idx, iTru, iEta, iPhi))
252                                 {
253                                         printf("| Position => TRU: %2d Eta: %2d Phi: %2d\n", iTru, iEta, iPhi);
254                                 }
255                                 
256                                 if (fGeometry->GetPositionInSMFromAbsFastORIndex(idx, iSm, iEta, iPhi))
257                                 {
258                                         printf("| Position =>  SM: %2d Eta: %2d Phi: %2d\n", iSm, iEta, iPhi);
259                                 }
260                                                                 
261                                 if (fGeometry->GetCellIndexFromFastORIndex(idx, iD))
262                                 {
263                                         printf("| tower iDs: ");
264                                         for (Int_t i = 0; i < 4; i++)
265                                         {
266                                                 printf("%5d ",iD[i]); 
267                                         }
268                                         printf("\n");
269                                         
270                                         for (Int_t i = 0; i < 4; i++)
271                                         {
272                                                 if (fGeometry->GetFastORIndexFromCellIndex(iD[i], iFor))
273                                                 {
274                                                         printf("| tower %d to F-OR %d\n",iD[i],iFor);
275                                                 }
276                                         }
277                                 }                               
278                         }
279                 }
280         }
281 }
282
283 //_______________
284 void AliEMCALTriggerRawDigitMaker::PostProcess()
285 {       
286         // Post process digits
287         
288         AliDebug(2,"Start post processing the raw digit maker");
289         Int_t idx;
290         
291         AliEMCALTriggerRawDigit* dig = 0x0;
292         
293         TVector2 sizeL1gsubr, sizeL1gpatch, sizeL1jsubr, sizeL1jpatch;
294         
295         fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->GetSegmentation(sizeL1gsubr, sizeL1gpatch, sizeL1jsubr, sizeL1jpatch);
296         
297         fRawReader->Reset();
298         fRawReader->Select("EMCAL",44); 
299
300         Bool_t isSTUin = kFALSE;
301         
302         Int_t nSubEv = fRawReader->GetEvent()->GetNSubEvents();
303         
304         for ( Int_t iSubEv=0; iSubEv<nSubEv; iSubEv++)
305         {
306                 AliRawVEvent *subEv = ((AliRawEvent*)fRawReader->GetEvent())->GetSubEvent(iSubEv);
307                 if ( !subEv ) continue;
308                 
309                 for (Int_t iEquip = 0; iEquip < subEv->GetNEquipments(); iEquip++)
310                 {
311                         Int_t eqId = subEv->GetEquipment(iEquip)->GetEquipmentHeader()->GetId();
312                         
313                         if (eqId == kSTUEqId) isSTUin = kTRUE;
314                 }
315         }
316         
317         fRawReader->Reset();
318         
319         if (isSTUin && fSTURawStream && fSTURawStream->ReadPayLoad())
320         {
321                 fTriggerData->SetL1DataDecoded(1);
322                 
323                 for (int i = 0; i < 2; i++) {
324                         fTriggerData->SetL1GammaThreshold(i, fSTURawStream->GetL1GammaThreshold(i));
325                         fTriggerData->SetL1JetThreshold(  i, fSTURawStream->GetL1JetThreshold(i)  );
326                 }
327                 
328                 Int_t v0[2] = {fSTURawStream->GetV0A(), fSTURawStream->GetV0C()};
329                 
330                 Int_t type[15] = 
331                 {
332                         fSTURawStream->GetG(0, 0),
333                         fSTURawStream->GetG(1, 0),
334                         fSTURawStream->GetG(2, 0),
335                         fSTURawStream->GetJ(0, 0),
336                         fSTURawStream->GetJ(1, 0),
337                         fSTURawStream->GetJ(2, 0),
338                         fSTURawStream->GetG(0, 1),
339                         fSTURawStream->GetG(1, 1),
340                         fSTURawStream->GetG(2, 1),
341                         fSTURawStream->GetJ(0, 1),
342                         fSTURawStream->GetJ(1, 1),
343                         fSTURawStream->GetJ(2, 1),
344                         fSTURawStream->GetRawData(), 
345                         fSTURawStream->GetRegionEnable(), 
346                         fSTURawStream->GetFwVersion()
347                 };              
348
349                 // Modify DCS config from STU payload content
350                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetG(0, 0, type[0]);
351                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetG(1, 0, type[1]);
352                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetG(2, 0, type[2]);
353                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetJ(0, 0, type[3]);
354                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetJ(1, 0, type[4]);
355                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetJ(2, 0, type[5]);
356                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetG(0, 1, type[6]);
357                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetG(1, 1, type[7]);
358                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetG(2, 1, type[8]);
359                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetJ(0, 1, type[9]);
360                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetJ(1, 1, type[10]);
361                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetJ(2, 1, type[11]);
362                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetRawData(type[12]);             
363                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetRegion(type[13]);
364                 fDCSConfig->GetTriggerDCSConfig()->GetSTUDCSConfig()->SetFw(type[14]);
365                 
366                 fTriggerData->SetL1FrameMask(fSTURawStream->GetFrameReceived());
367                 fTriggerData->SetL1V0(v0);
368                 fTriggerData->SetL1TriggerType(type);
369                 
370                 fTriggerData->SetL1RawData(fSTURawStream->GetRawData());
371                 
372                 Int_t iTRU, x, y;
373
374                 if (fSTURawStream->GetRawData())
375                 {
376                         if (AliDebugLevel()) printf("| STU => TRU raw data are there!\n");
377                         
378                         Int_t nTRU = fGeometry->GetNTotalTRU();
379                         for (Int_t i = 0; i < nTRU; i++)
380                         {
381                                 iTRU = fGeometry->GetTRUIndexFromSTUIndex(i);
382                                 
383                                 UInt_t adc[96]; for (Int_t j = 0; j < 96; j++) adc[j] = 0;
384                                 
385                                 fSTURawStream->GetADC(i, adc);
386
387                                 for (Int_t j = 0; j < 96; j++)
388                                 {
389                                         if (adc[j] <= 0) continue;
390                                         
391                                         AliDebug(10,Form("| STU => TRU# %2d raw data: ADC# %2d: %d\n", iTRU, j, adc[j]));
392                                         
393                                         fGeometry->GetAbsFastORIndexFromTRU(iTRU, j, idx);
394                                         
395                                         if (fRawDigitIndex[idx] >= 0)
396                                         {
397                                                 dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
398                                                 
399                                                 if (!dig->GetNSamples()) AliDebug(10,Form("TRG digit of id: %4d found in STU but has no time sample in F-ALTRO!",idx));
400                                         }
401                                         else
402                                         {
403                                                 AliDebug(10,Form("TRG digit of id: %4d found in STU but not in F-ALTRO! Create a new digit!",idx));
404                                                 
405                                                 fRawDigitIndex[idx] = fRawDigits->GetEntriesFast();
406                                                 new((*fRawDigits)[fRawDigits->GetEntriesFast()]) AliEMCALTriggerRawDigit(idx, 0x0, 0);
407                                                 
408                                                 dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
409                                         }
410                                         
411                                         dig->SetL1TimeSum(adc[j]);
412                                 }
413                         }
414                 }
415                 
416                 // List of patches in EMCal coordinate system
417                 
418                 for (Int_t i = 0; i < fSTURawStream->GetNL0GammaPatch(); i++)
419                 {
420                         fSTURawStream->GetL0GammaPatch(i, iTRU, x);
421
422                         iTRU = fGeometry->GetTRUIndexFromSTUIndex(iTRU);
423                         
424                         const Int_t sizePatchL0 = 
425                         ((AliEMCALTriggerTRUDCSConfig*)fDCSConfig->GetTriggerDCSConfig()->GetTRUArr()->At(fGeometry->GetOnlineIndexFromTRUIndex(iTRU)))->GetSegmentation() 
426                         * 
427                         ((AliEMCALTriggerTRUDCSConfig*)fDCSConfig->GetTriggerDCSConfig()->GetTRUArr()->At(fGeometry->GetOnlineIndexFromTRUIndex(iTRU)))->GetSegmentation();
428                         
429                         if (AliDebugLevel()) printf("| STU => Found L0 patch id: %2d in TRU# %2d\n", x, iTRU);
430                                                 
431                         Int_t idFastOR[4];
432                         for (Int_t j = 0; j < 4; j++) idFastOR[j] = -1;
433                         
434                         if (fGeometry->GetFastORIndexFromL0Index(iTRU, x, idFastOR, sizePatchL0))
435                         {
436                                 idx = idFastOR[1];
437                                 
438                                 Int_t px, py;
439                                 if (fGeometry->GetPositionInEMCALFromAbsFastORIndex(idx, px, py))
440                                 {
441                                         if (AliDebugLevel()) printf("| STU => Add L0 patch at (%2d , %2d)\n", px, py);
442                                                                                 
443                                         if (fRawDigitIndex[idx] >= 0)
444                                         {
445                                                 dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
446                                         }
447                                         else
448                                         {
449                                                 fRawDigitIndex[idx] = fRawDigits->GetEntriesFast();
450                                                 new((*fRawDigits)[fRawDigits->GetEntriesFast()]) AliEMCALTriggerRawDigit(idx, 0x0, 0);
451                         
452                                                 dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
453                                         }
454                 
455                                         dig->SetTriggerBit(kL0,1);
456                                 }
457                         }
458                 }
459                 
460                 for (int ithr = 0; ithr < 2; ithr++) {
461                         
462                         for (Int_t i = 0; i < fSTURawStream->GetNL1GammaPatch(ithr); i++)
463                         {
464                                 if (fSTURawStream->GetL1GammaPatch(i, ithr, iTRU, x, y)) // col (0..23), row (0..3)
465                                 {
466                                         iTRU = fGeometry->GetTRUIndexFromSTUIndex(iTRU);
467                                         
468                                         if (AliDebugLevel()) printf("| STU => Found L1 gamma patch at (%2d , %2d) in TRU# %2d\n", x, y, iTRU);
469                                         
470                                         Int_t vx = 23 - x, vy = y + 4 * int(iTRU / 2); // Position in EMCal frame
471                                         
472                                         if (iTRU % 2) vx += 24; // C side
473                                         
474                                         vx = vx - int(sizeL1gsubr.X()) * int(sizeL1gpatch.X()) + 1;
475                                         
476                                         if (vx >= 0 && vy < 63) 
477                                         {
478                                                 if (fGeometry->GetAbsFastORIndexFromPositionInEMCAL(vx, vy, idx))
479                                                 {
480                                                         if (AliDebugLevel()) printf("| STU => Add L1 gamma [%d] patch at (%2d , %2d)\n", ithr, vx, vy);
481                                                         
482                                                         if (fRawDigitIndex[idx] >= 0)
483                                                         {
484                                                                 dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
485                                                         }
486                                                         else
487                                                         {
488                                                                 fRawDigitIndex[idx] = fRawDigits->GetEntriesFast();
489                                                                 new((*fRawDigits)[fRawDigits->GetEntriesFast()]) AliEMCALTriggerRawDigit(idx, 0x0, 0);
490                                                                 
491                                                                 dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
492                                                         }
493                                                         
494                                                         dig->SetTriggerBit(kL1GammaHigh + ithr,1);
495                                                 }
496                                         }
497                                 }
498                         }
499                         
500                         for (Int_t i = 0; i < fSTURawStream->GetNL1JetPatch(ithr); i++)
501                         {
502                                 if (fSTURawStream->GetL1JetPatch(i, ithr, x, y)) // col (0,15), row (0,11)
503                                 {
504                                         AliDebug(1, Form("| STU => Found L1 jet [%d] patch at (%2d , %2d)\n", ithr, x, y));
505                                         
506                                         Int_t ix = int(sizeL1jsubr.X()) * (11 - y - int(sizeL1jpatch.X()) + 1);
507                                         
508                                         Int_t iy = int(sizeL1jsubr.Y()) * (15 - x - int(sizeL1jpatch.Y()) + 1);
509                                         
510                                         if (ix >= 0 && iy >= 0)
511                                         {       
512                                                 if (fGeometry->GetAbsFastORIndexFromPositionInEMCAL(ix, iy, idx))
513                                                 {
514                                                         if (AliDebugLevel()) printf("| STU => Add L1 jet patch at (%2d , %2d)\n", ix, iy);
515                                                         
516                                                         if (fRawDigitIndex[idx] >= 0)
517                                                         {
518                                                                 dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
519                                                         }
520                                                         else
521                                                         {
522                                                                 fRawDigitIndex[idx] = fRawDigits->GetEntriesFast();
523                                                                 new((*fRawDigits)[fRawDigits->GetEntriesFast()]) AliEMCALTriggerRawDigit(idx, 0x0, 0);
524                                                                 
525                                                                 dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
526                                                         }
527                                                         
528                                                         dig->SetTriggerBit(kL1JetHigh + ithr,1);
529                                                 }
530                                         }
531                                 }
532                         }               
533                 }
534         }
535 }
536
537 //_______________
538 void AliEMCALTriggerRawDigitMaker::Reset()
539 {
540         // Reset
541         
542         Int_t nRawDigits = fGeometry->GetNTotalTRU() * 96;  
543         for (Int_t i = 0; i < nRawDigits; i++) fRawDigitIndex[i] = -1;
544 }
545
546