AliPhysics  2ad5f07 (2ad5f07)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalTriggerMakerKernel.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2015, 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 #include <iostream>
16 #include <vector>
17 #include <cstring>
18 #include <fstream>
19 
20 #include <TArrayI.h>
21 #include <TObjArray.h>
22 
23 #include "AliAODCaloTrigger.h"
24 #include "AliEMCALGeometry.h"
25 #include "AliEMCALTriggerConstants.h"
26 #include "AliEMCALTriggerDataGrid.h"
27 #include "AliEMCALTriggerPatchInfo.h"
28 #include "AliEMCALTriggerPatchFinder.h"
29 #include "AliEMCALTriggerAlgorithm.h"
30 #include "AliEMCALTriggerRawPatch.h"
33 #include "AliLog.h"
34 #include "AliVCaloCells.h"
35 #include "AliVCaloTrigger.h"
36 #include "AliVEvent.h"
37 #include "AliVVZERO.h"
38 
42 
44  TObject(),
45  fBadChannels(),
46  fOfflineBadChannels(),
47  fFastORPedestal(5000),
48  fTriggerBitConfig(NULL),
49  fPatchFinder(NULL),
50  fLevel0PatchFinder(NULL),
51  fL0MinTime(7),
52  fL0MaxTime(10),
53  fMinCellAmp(0),
54  fMinL0FastORAmp(0),
55  fMinL1FastORAmp(0),
56  fBkgThreshold(-1),
57  fL0Threshold(0),
58  fIsMC(kFALSE),
59  fDebugLevel(0),
60  fGeometry(NULL),
61  fPatchAmplitudes(NULL),
62  fPatchADCSimple(NULL),
63  fPatchADC(NULL),
64  fLevel0TimeMap(NULL),
65  fTriggerBitMap(NULL),
66  fADCtoGeV(1.)
67 {
68  memset(fThresholdConstants, 0, sizeof(Int_t) * 12);
69  memset(fL1ThresholdsOffline, 0, sizeof(ULong64_t) * 4);
70 }
71 
73  delete fPatchAmplitudes;
74  delete fPatchADCSimple;
75  delete fPatchADC;
76  delete fLevel0TimeMap;
77  delete fTriggerBitMap;
78  delete fPatchFinder;
79  delete fLevel0PatchFinder;
81 }
82 
84  if (!fTriggerBitConfig) {
85  AliWarning("Trigger bit configuration was not provided! Assuming new bit configuration (>= 2013).");
86  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigNew();
87  SetTriggerBitConfig(triggerBitConfig);
88  }
89 
95 
96  // Allocate containers for the ADC values
97  int nrows = fGeometry->GetNTotalTRU() * 2;
98  std::cout << "Allocating channel grid with 48 columns in eta and " << nrows << " rows in phi" << std::endl;
99  fPatchAmplitudes->Allocate(48, nrows);
100  fPatchADC->Allocate(48, nrows);
101  fPatchADCSimple->Allocate(48, nrows);
102  fLevel0TimeMap->Allocate(48, nrows);
103  fTriggerBitMap->Allocate(48, nrows);
104 }
105 
106 void AliEmcalTriggerMakerKernel::AddL1TriggerAlgorithm(Int_t rowmin, Int_t rowmax, UInt_t bitmask, Int_t patchSize, Int_t subregionSize)
107 {
109  AliEMCALTriggerAlgorithm<double> *trigger = new AliEMCALTriggerAlgorithm<double>(rowmin, rowmax, bitmask);
110  trigger->SetPatchSize(patchSize);
111  trigger->SetSubregionSize(subregionSize);
112  fPatchFinder->AddTriggerAlgorithm(trigger);
113 }
114 
115 void AliEmcalTriggerMakerKernel::SetL0TriggerAlgorithm(Int_t rowmin, Int_t rowmax, UInt_t bitmask, Int_t patchSize, Int_t subregionSize)
116 {
118  fLevel0PatchFinder = new AliEMCALTriggerAlgorithm<double>(rowmin, rowmax, bitmask);
119  fLevel0PatchFinder->SetPatchSize(patchSize);
120  fLevel0PatchFinder->SetSubregionSize(subregionSize);
121 }
122 
124 {
125  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigNew();
126  SetTriggerBitConfig(triggerBitConfig);
127 
128  // Initialize patch finder
129  if (fPatchFinder) delete fPatchFinder;
131 
132  SetL0TriggerAlgorithm(0, 103, 1<<fTriggerBitConfig->GetLevel0Bit(), 2, 1);
133  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetGammaHighBit() | 1<<fTriggerBitConfig->GetGammaLowBit(), 2, 1);
134  AddL1TriggerAlgorithm(64, 103, 1<<fTriggerBitConfig->GetGammaHighBit() | 1<<fTriggerBitConfig->GetGammaLowBit(), 2, 1);
135  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetJetHighBit() | 1<<fTriggerBitConfig->GetJetLowBit() | 1<<fTriggerBitConfig->GetBkgBit(), 8, 4);
136  AddL1TriggerAlgorithm(64, 103, 1<<fTriggerBitConfig->GetJetHighBit() | 1<<fTriggerBitConfig->GetJetLowBit() | 1<<fTriggerBitConfig->GetBkgBit(), 8, 4);
137 }
138 
140 {
141  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigNew();
142  SetTriggerBitConfig(triggerBitConfig);
143 
144  // Initialize patch finder
145  if (fPatchFinder) delete fPatchFinder;
147 
148  SetL0TriggerAlgorithm(0, 103, 1<<fTriggerBitConfig->GetLevel0Bit(), 2, 1);
149  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetGammaHighBit() | 1<<fTriggerBitConfig->GetGammaLowBit(), 2, 1);
150  AddL1TriggerAlgorithm(64, 103, 1<<fTriggerBitConfig->GetGammaHighBit() | 1<<fTriggerBitConfig->GetGammaLowBit(), 2, 1);
151  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetJetHighBit() | 1<<fTriggerBitConfig->GetJetLowBit(), 16, 4);
152  AddL1TriggerAlgorithm(64, 103, 1<<fTriggerBitConfig->GetJetHighBit() | 1<<fTriggerBitConfig->GetJetLowBit(), 16, 4);
153 }
154 
156 {
157  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigNew();
158  SetTriggerBitConfig(triggerBitConfig);
159 
160  // Initialize patch finder
161  if (fPatchFinder) delete fPatchFinder;
163 
164  SetL0TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetLevel0Bit(), 2, 1);
165  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetGammaHighBit() | 1<<fTriggerBitConfig->GetGammaLowBit(), 2, 1);
166  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetJetHighBit() | 1<<fTriggerBitConfig->GetJetLowBit(), 16, 4);
167 }
168 
170 {
171  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigOld();
172  SetTriggerBitConfig(triggerBitConfig);
173 
174  // Initialize patch finder
175  if (fPatchFinder) delete fPatchFinder;
177 
178  SetL0TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetLevel0Bit(), 2, 1);
179  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetGammaHighBit(), 2, 1);
180  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetJetHighBit(), 16, 4);
181 }
182 
184 {
185  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigOld();
186  SetTriggerBitConfig(triggerBitConfig);
187 
188  // Initialize patch finder
189  if (fPatchFinder) delete fPatchFinder;
191 
192  SetL0TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetLevel0Bit(), 2, 1);
193  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetGammaHighBit(), 2, 1);
194  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetJetHighBit(), 16, 4);
195 }
196 
198 {
199  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigOld();
200  SetTriggerBitConfig(triggerBitConfig);
201 
202  // Initialize patch finder
203  if (fPatchFinder) delete fPatchFinder;
205 
206  SetL0TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetLevel0Bit(), 2, 1);
207 }
208 
210 {
211  Short_t absId = 0;
212 
213  while (stream.good()) {
214  stream >> absId;
215  AddOfflineBadChannel(absId);
216  }
217 }
218 
220 {
221  std::ifstream file(fname);
223 }
224 
226 {
227  Short_t absId = -1;
228 
229  while (stream.good()) {
230  stream >> absId;
231  AddFastORBadChannel(absId);
232  }
233 }
234 
236 {
237  std::ifstream file(fname);
239 }
240 
241 void AliEmcalTriggerMakerKernel::SetFastORPedestal(Short_t absId, Float_t ped)
242 {
243  if (absId < 0 || absId >= fFastORPedestal.GetSize()) {
244  AliWarning(Form("Abs. ID %d out of range (0,5000)", absId));
245  return;
246  }
247  fFastORPedestal[absId] = ped;
248 }
249 
251 {
252  Short_t absId = 0;
253  Float_t ped = 0;
254  while (stream.good()) {
255  stream >> ped;
256  SetFastORPedestal(absId, ped);
257  absId++;
258  }
259 }
260 
262 {
263  std::ifstream file(fname);
265 }
266 
268  fPatchAmplitudes->Reset();
269  fPatchADC->Reset();
270  fPatchADCSimple->Reset();
271  fLevel0TimeMap->Reset();
272  fTriggerBitMap->Reset();
273  memset(fL1ThresholdsOffline, 0, sizeof(ULong64_t) * 4);
274 }
275 
276 void AliEmcalTriggerMakerKernel::ReadTriggerData(AliVCaloTrigger *trigger){
277  trigger->Reset();
278  Int_t globCol=-1, globRow=-1;
279  Int_t adcAmp=-1, bitmap = 0;
280  while(trigger->Next()){
281  // get position in global 2x2 tower coordinates
282  // A0 left bottom (0,0)
283  trigger->GetPosition(globCol, globRow);
284  Int_t absId = -1;
285  fGeometry->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absId);
286  // exclude channel completely if it is masked as hot channel
287  if (fBadChannels.find(absId) != fBadChannels.end()) continue;
288  // for some strange reason some ADC amps are initialized in reconstruction
289  // as -1, neglect those
290  trigger->GetL1TimeSum(adcAmp);
291  if (adcAmp < 0) adcAmp = 0;
292  trigger->GetTriggerBits(bitmap);
293 
294  if (adcAmp >= fMinL1FastORAmp) {
295  try {
296  (*fPatchADC)(globCol,globRow) = adcAmp;
297  }
299  }
300  try {
301  (*fTriggerBitMap)(globCol, globRow) = bitmap;
302  }
304  }
305  }
306 
307  // Handling for L0 triggers
308  // For the ADC value we use fCaloTriggers->GetAmplitude()
309  // In data, all patches which have 4 TRUs with proper level0 times are
310  // valid trigger patches. Therefore we need to check all neighbors for
311  // the level0 times, not only the bottom left. In order to obtain this
312  // information, a lookup table with the L0 times for each TRU is created
313  Float_t amplitude(0);
314  trigger->GetAmplitude(amplitude);
315  amplitude *= 4; // values are shifted by 2 bits to fit in a 10 bit word (on the hardware side)
316  amplitude -= fFastORPedestal[absId];
317  if(amplitude < 0) amplitude = 0;
318  if (amplitude >= fMinL0FastORAmp) {
319  (*fPatchAmplitudes)(globCol,globRow) = amplitude;
320  Int_t nl0times(0);
321  trigger->GetNL0Times(nl0times);
322  if(nl0times){
323  TArrayI l0times(nl0times);
324  trigger->GetL0Times(l0times.GetArray());
325  for(int itime = 0; itime < nl0times; itime++){
326  (*fLevel0TimeMap)(globCol,globRow) = static_cast<Char_t>(l0times[itime]);
327  break;
328  }
329  }
330  }
331  }
332 }
333 
334 void AliEmcalTriggerMakerKernel::ReadCellData(AliVCaloCells *cells){
335  // fill the patch ADCs from cells
336  Int_t nCell = cells->GetNumberOfCells();
337  for(Int_t iCell = 0; iCell < nCell; ++iCell) {
338  // get the cell info, based in index in array
339  Short_t cellId = cells->GetCellNumber(iCell);
340 
341  // Check bad channel map
342  if (fOfflineBadChannels.find(cellId) != fOfflineBadChannels.end()) {
343  AliDebug(10, Form("%hd is a bad channel, skipped.", cellId));
344  continue;
345  }
346 
347  Double_t amp = cells->GetAmplitude(iCell);
348  // get position
349  Int_t absId=-1;
350  fGeometry->GetFastORIndexFromCellIndex(cellId, absId);
351  Int_t globCol=-1, globRow=-1;
352  fGeometry->GetPositionInEMCALFromAbsFastORIndex(absId, globCol, globRow);
353  // add
354  amp /= fADCtoGeV;
355  try {
356  if (amp >= fMinCellAmp) (*fPatchADCSimple)(globCol,globRow) += amp;
357  }
359  }
360  }
361 }
362 
364  // get the V0 value and compute and set the offline thresholds
365  // get V0, compute thresholds and save them as global parameters
366  ULong64_t v0S = vzerodata->GetTriggerChargeA() + vzerodata->GetTriggerChargeC();
367  for (Int_t i = 0; i < 4; ++i) {
368  // A*V0^2/2^32+B*V0/2^16+C
369  fL1ThresholdsOffline[i]= ( ((ULong64_t)fThresholdConstants[i][0]) * v0S * v0S ) >> 32;
370  fL1ThresholdsOffline[i] += ( ((ULong64_t)fThresholdConstants[i][1]) * v0S ) >> 16;
371  fL1ThresholdsOffline[i] += ((ULong64_t)fThresholdConstants[i][2]);
372  }
373 }
374 
375 TObjArray *AliEmcalTriggerMakerKernel::CreateTriggerPatches(const AliVEvent *inputevent, Bool_t useL0amp){
376  //std::cout << "Finding trigger patches" << std::endl;
377  //AliEMCALTriggerPatchInfo *trigger, *triggerMainJet, *triggerMainGamma, *triggerMainLevel0;
378  //AliEMCALTriggerPatchInfo *triggerMainJetSimple, *triggerMainGammaSimple;
379 
380  if (useL0amp) {
382  }
383  else {
384  fADCtoGeV = EMCALTrigger::kEMCL1ADCtoGeV;
385  }
386 
387  Double_t vertexpos[3];
388  inputevent->GetPrimaryVertex()->GetXYZ(vertexpos);
389  TVector3 vertexvec(vertexpos);
390 
391  Int_t isMC = fIsMC ? 1 : 0;
392  Int_t offset = (1 - isMC) * fTriggerBitConfig->GetTriggerTypesEnd();
393 
394  // Create trigger bit masks. They are needed later to remove
395  // trigger bits from the trigger bit mask for non-matching patch types
396  Int_t jetPatchMask = 1 << fTriggerBitConfig->GetJetHighBit()
397  | 1 << fTriggerBitConfig->GetJetLowBit()
398  | 1 << (fTriggerBitConfig->GetJetHighBit() + fTriggerBitConfig->GetTriggerTypesEnd())
399  | 1 << (fTriggerBitConfig->GetJetLowBit() + fTriggerBitConfig->GetTriggerTypesEnd()),
400  gammaPatchMask = 1 << fTriggerBitConfig->GetGammaHighBit()
401  | 1 << fTriggerBitConfig->GetGammaLowBit()
402  | 1 << (fTriggerBitConfig->GetGammaHighBit() + fTriggerBitConfig->GetTriggerTypesEnd())
403  | 1 << (fTriggerBitConfig->GetGammaLowBit() + fTriggerBitConfig->GetTriggerTypesEnd()),
404  bkgPatchMask = 1 << fTriggerBitConfig->GetBkgBit();
405  //l0PatchMask = 1 << fTriggerBitConfig->GetLevel0Bit();
406 
407  std::vector<AliEMCALTriggerRawPatch> patches;
408  if (fPatchFinder) {
409  if (useL0amp) {
410  patches = fPatchFinder->FindPatches(*fPatchAmplitudes, *fPatchADCSimple);
411  }
412  else {
413  patches = fPatchFinder->FindPatches(*fPatchADC, *fPatchADCSimple);
414  }
415  }
416  TObjArray *result = new TObjArray(1000);
417  result->SetOwner(kTRUE);
418  for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = patches.begin(); patchit != patches.end(); ++patchit){
419  // Apply offline and recalc selection
420  // Remove unwanted bits from the online bits (gamma bits from jet patches and vice versa)
421  Int_t offlinebits = 0, onlinebits = (*fTriggerBitMap)(patchit->GetColStart(), patchit->GetRowStart());
422  if(IsGammaPatch(*patchit)){
423  if(patchit->GetADC() > fL1ThresholdsOffline[1]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kRecalcOffset + fTriggerBitConfig->GetGammaHighBit());
424  if(patchit->GetOfflineADC() > fL1ThresholdsOffline[1]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset + fTriggerBitConfig->GetGammaHighBit());
425  if(patchit->GetADC() > fL1ThresholdsOffline[3]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kRecalcOffset + fTriggerBitConfig->GetGammaLowBit());
426  if(patchit->GetOfflineADC() > fL1ThresholdsOffline[3]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset + fTriggerBitConfig->GetGammaLowBit());
427  onlinebits &= gammaPatchMask;
428  }
429  if (IsJetPatch(*patchit)){
430  if(patchit->GetADC() > fL1ThresholdsOffline[0]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kRecalcOffset + fTriggerBitConfig->GetJetHighBit());
431  if(patchit->GetOfflineADC() > fL1ThresholdsOffline[0]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset + fTriggerBitConfig->GetJetHighBit());
432  if(patchit->GetADC() > fL1ThresholdsOffline[2]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kRecalcOffset + fTriggerBitConfig->GetJetLowBit());
433  if(patchit->GetOfflineADC() > fL1ThresholdsOffline[2]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset + fTriggerBitConfig->GetJetLowBit());
434  onlinebits &= jetPatchMask;
435  }
436  if (IsBkgPatch(*patchit)){
437  if(patchit->GetADC() > fBkgThreshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kRecalcOffset + fTriggerBitConfig->GetBkgBit());
438  if(patchit->GetOfflineADC() > fBkgThreshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset + fTriggerBitConfig->GetBkgBit());
439  onlinebits &= bkgPatchMask;
440  }
441  // convert
442  AliEMCALTriggerPatchInfo *fullpatch = AliEMCALTriggerPatchInfo::CreateAndInitialize(patchit->GetColStart(), patchit->GetRowStart(),
443  patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() * fADCtoGeV,
444  onlinebits | offlinebits, vertexvec, fGeometry);
445  fullpatch->SetTriggerBitConfig(fTriggerBitConfig);
446  fullpatch->SetOffSet(offset);
447  result->Add(fullpatch);
448  }
449 
450  // Find Level0 patches
451  std::vector<AliEMCALTriggerRawPatch> l0patches;
452  if (fLevel0PatchFinder) l0patches = fLevel0PatchFinder->FindPatches(*fPatchAmplitudes, *fPatchADCSimple);
453  for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = l0patches.begin(); patchit != l0patches.end(); ++patchit){
454  Int_t offlinebits = 0, onlinebits = 0;
455  ELevel0TriggerStatus_t L0status = CheckForL0(patchit->GetColStart(), patchit->GetRowStart());
456  if (L0status == kNotLevel0) continue;
457  if (L0status == kLevel0Fired) SETBIT(onlinebits, fTriggerBitConfig->GetLevel0Bit());
458  if (patchit->GetADC() > fL0Threshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kRecalcOffset + fTriggerBitConfig->GetLevel0Bit());
459  if (patchit->GetOfflineADC() > fL0Threshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset + fTriggerBitConfig->GetLevel0Bit());
460 
461  AliEMCALTriggerPatchInfo *fullpatch = AliEMCALTriggerPatchInfo::CreateAndInitialize(patchit->GetColStart(), patchit->GetRowStart(),
462  patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() * fADCtoGeV,
463  onlinebits | offlinebits, vertexvec, fGeometry);
464  fullpatch->SetTriggerBitConfig(fTriggerBitConfig);
465  result->Add(fullpatch);
466  }
467  // std::cout << "Finished finding trigger patches" << std::endl;
468  return result;
469 }
470 
473 
474  if(col < 0 || row < 0){
475  AliError(Form("Patch outside range [col %d, row %d]", col, row));
476  return kNotLevel0;
477  }
478  Int_t truref(-1), trumod(-1), absFastor(-1), adc(-1);
479  fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col, row, absFastor);
480  fGeometry->GetTRUFromAbsFastORIndex(absFastor, truref, adc);
481  int nvalid(0);
482  const int kNRowsPhi = fGeometry->GetNTotalTRU() * 2;
483  for(int ipos = 0; ipos < 2; ipos++){
484  if(row + ipos >= kNRowsPhi) continue; // boundary check
485  for(int jpos = 0; jpos < 2; jpos++){
486  if(col + jpos >= kColsEta) continue; // boundary check
487  // Check whether we are in the same TRU
488  trumod = -1;
489  fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col+jpos, row+ipos, absFastor);
490  fGeometry->GetTRUFromAbsFastORIndex(absFastor, trumod, adc);
491  if(trumod != truref) {
492  result = kNotLevel0;
493  return result;
494  }
495  if(col + jpos >= kColsEta) AliError(Form("Boundary error in col [%d, %d + %d]", col + jpos, col, jpos));
496  if(row + ipos >= kNRowsPhi) AliError(Form("Boundary error in row [%d, %d + %d]", row + ipos, row, ipos));
497  Char_t l0times = (*fLevel0TimeMap)(col + jpos,row + ipos);
498  if(l0times > fL0MinTime && l0times < fL0MaxTime) nvalid++;
499  }
500  }
501  if (nvalid == 4) result = kLevel0Fired;
502  return result;
503 }
504 
505 Bool_t AliEmcalTriggerMakerKernel::IsGammaPatch(const AliEMCALTriggerRawPatch &patch) const {
506  ULong_t bitmask = patch.GetBitmask(), testmask = 1 << fTriggerBitConfig->GetGammaHighBit() | 1 << fTriggerBitConfig->GetGammaLowBit();
507  return bitmask & testmask;
508 }
509 
510 Bool_t AliEmcalTriggerMakerKernel::IsJetPatch(const AliEMCALTriggerRawPatch &patch) const {
511  ULong_t bitmask = patch.GetBitmask(), testmask = 1 << fTriggerBitConfig->GetJetHighBit() | 1 << fTriggerBitConfig->GetJetLowBit();
512  return bitmask & testmask;
513 }
514 
515 Bool_t AliEmcalTriggerMakerKernel::IsBkgPatch(const AliEMCALTriggerRawPatch &patch) const {
516  ULong_t bitmask = patch.GetBitmask(), testmask = 1 << fTriggerBitConfig->GetBkgBit();
517  return bitmask & testmask;
518 }
519 
520 void AliEmcalTriggerMakerKernel::SetTriggerBitConfig(const AliEMCALTriggerBitConfig *const config) {
521  if (config == fTriggerBitConfig) return;
523  fTriggerBitConfig = config;
524 }
Int_t fBkgThreshold
threshold for the background patches (8x8)
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
ELevel0TriggerStatus_t CheckForL0(Int_t col, Int_t row) const
Bool_t IsGammaPatch(const AliEMCALTriggerRawPatch &patch) const
Bool_t IsBkgPatch(const AliEMCALTriggerRawPatch &patch) const
TObjArray * CreateTriggerPatches(const AliVEvent *inputevent, Bool_t useL0amp=kFALSE)
AliEMCALTriggerDataGrid< int > * fTriggerBitMap
! Map of trigger bits
void ReadFastORBadChannelFromStream(std::istream &stream)
TArrayF fFastORPedestal
FastOR pedestal.
void SetTriggerBitConfig(const AliEMCALTriggerBitConfig *const config)
Int_t fMinCellAmp
Minimum offline amplitude of the cells used to generate the patches.
void ReadFastORBadChannelFromFile(const char *fname)
void ReadTriggerData(AliVCaloTrigger *trigger)
Int_t fMinL1FastORAmp
Minimum L1 amplitude of the FastORs used to generate the patches.
const AliEMCALTriggerBitConfig * fTriggerBitConfig
Trigger bit configuration, aliroot-dependent.
const AliEMCALGeometry * fGeometry
! Underlying EMCAL geometry
ULong64_t fL1ThresholdsOffline[4]
container for V0-dependent offline thresholds
void ReadOfflineBadChannelFromFile(const char *fname)
Int_t fThresholdConstants[4][3]
simple offline trigger thresholds constants
Double_t fADCtoGeV
! Conversion factor from ADC to GeV
void AddL1TriggerAlgorithm(Int_t rowmin, Int_t rowmax, UInt_t bitmask, Int_t patchSize, Int_t subregionSize)
void SetL0TriggerAlgorithm(Int_t rowmin, Int_t rowmax, UInt_t bitmask, Int_t patchSize, Int_t subregionSize)
void ReadOfflineBadChannelFromStream(std::istream &stream)
void SetFastORPedestal(Short_t absId, Float_t ped)
std::set< Short_t > fBadChannels
Container of bad channels.
Int_t fDebugLevel
Int_t fL0Threshold
threshold for the L0 patches (2x2)
AliEMCALTriggerDataGrid< double > * fPatchAmplitudes
! TRU Amplitudes (for L0)
Manager for constants used in the trigger maker.
void BuildL1ThresholdsOffline(const AliVVZERO *vzdata)
AliEMCALTriggerDataGrid< double > * fPatchADC
! ADC values map
Bool_t isMC
Int_t fMinL0FastORAmp
Minimum L0 amplitude of the FastORs used to generate the patches.
std::set< Short_t > fOfflineBadChannels
Abd ID of offline bad channels.
AliEMCALTriggerPatchFinder< double > * fPatchFinder
The actual patch finder.
TFile * file
AliEMCALTriggerDataGrid< double > * fPatchADCSimple
! patch map for simple offline trigger
Kernel of the EMCAL trigger patch makerThe trigger maker kernel contains the core functionality of th...
void ReadFastORPedestalFromFile(const char *fname)
AliEMCALTriggerDataGrid< char > * fLevel0TimeMap
! Map needed to store the level0 times
AliEMCALTriggerAlgorithm< double > * fLevel0PatchFinder
Patch finder for Level0 patches.
Bool_t IsJetPatch(const AliEMCALTriggerRawPatch &patch) const
void ReadFastORPedestalFromStream(std::istream &stream)
void ReadCellData(AliVCaloCells *cells)
const Double_t kEMCL0ADCtoGeV_AP