AliPhysics  db95e02 (db95e02)
 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  fMinCellAmplitude(0.),
61  fApplyOnlineBadChannelsToOffline(kFALSE),
62  fConfigured(kFALSE),
63  fGeometry(NULL),
64  fPatchAmplitudes(NULL),
65  fPatchADCSimple(NULL),
66  fPatchADC(NULL),
67  fLevel0TimeMap(NULL),
68  fTriggerBitMap(NULL),
69  fADCtoGeV(1.)
70 {
71  memset(fThresholdConstants, 0, sizeof(Int_t) * 12);
72  memset(fL1ThresholdsOffline, 0, sizeof(ULong64_t) * 4);
73  fCellTimeLimits[0] = -10000.;
74  fCellTimeLimits[1] = 10000.;
75 }
76 
78  delete fPatchAmplitudes;
79  delete fPatchADCSimple;
80  delete fPatchADC;
81  delete fLevel0TimeMap;
82  delete fTriggerBitMap;
83  delete fPatchFinder;
84  delete fLevel0PatchFinder;
86 }
87 
89  if (!fTriggerBitConfig) {
90  AliWarning("Trigger bit configuration was not provided! Assuming new bit configuration (>= 2013).");
91  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigNew();
92  SetTriggerBitConfig(triggerBitConfig);
93  }
94 
100 
101  // Allocate containers for the ADC values
102  int nrows = fGeometry->GetNTotalTRU() * 2;
103  std::cout << "Allocating channel grid with 48 columns in eta and " << nrows << " rows in phi" << std::endl;
104  fPatchAmplitudes->Allocate(48, nrows);
105  fPatchADC->Allocate(48, nrows);
106  fPatchADCSimple->Allocate(48, nrows);
107  fLevel0TimeMap->Allocate(48, nrows);
108  fTriggerBitMap->Allocate(48, nrows);
109 }
110 
111 void AliEmcalTriggerMakerKernel::AddL1TriggerAlgorithm(Int_t rowmin, Int_t rowmax, UInt_t bitmask, Int_t patchSize, Int_t subregionSize)
112 {
114  AliEMCALTriggerAlgorithm<double> *trigger = new AliEMCALTriggerAlgorithm<double>(rowmin, rowmax, bitmask);
115  trigger->SetPatchSize(patchSize);
116  trigger->SetSubregionSize(subregionSize);
117  fPatchFinder->AddTriggerAlgorithm(trigger);
118 }
119 
120 void AliEmcalTriggerMakerKernel::SetL0TriggerAlgorithm(Int_t rowmin, Int_t rowmax, UInt_t bitmask, Int_t patchSize, Int_t subregionSize)
121 {
123  fLevel0PatchFinder = new AliEMCALTriggerAlgorithm<double>(rowmin, rowmax, bitmask);
124  fLevel0PatchFinder->SetPatchSize(patchSize);
125  fLevel0PatchFinder->SetSubregionSize(subregionSize);
126 }
127 
129 {
130  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigNew();
131  SetTriggerBitConfig(triggerBitConfig);
132 
133  // Initialize patch finder
134  if (fPatchFinder) delete fPatchFinder;
136 
137  SetL0TriggerAlgorithm(0, 103, 1<<fTriggerBitConfig->GetLevel0Bit(), 2, 1);
138  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetGammaHighBit() | 1<<fTriggerBitConfig->GetGammaLowBit(), 2, 1);
139  AddL1TriggerAlgorithm(64, 103, 1<<fTriggerBitConfig->GetGammaHighBit() | 1<<fTriggerBitConfig->GetGammaLowBit(), 2, 1);
140  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetJetHighBit() | 1<<fTriggerBitConfig->GetJetLowBit() | 1<<fTriggerBitConfig->GetBkgBit(), 8, 4);
141  AddL1TriggerAlgorithm(64, 103, 1<<fTriggerBitConfig->GetJetHighBit() | 1<<fTriggerBitConfig->GetJetLowBit() | 1<<fTriggerBitConfig->GetBkgBit(), 8, 4);
142  fConfigured = true;
143 }
144 
146 {
147  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigNew();
148  SetTriggerBitConfig(triggerBitConfig);
149 
150  // Initialize patch finder
151  if (fPatchFinder) delete fPatchFinder;
153 
154  SetL0TriggerAlgorithm(0, 103, 1<<fTriggerBitConfig->GetLevel0Bit(), 2, 1);
155  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetGammaHighBit() | 1<<fTriggerBitConfig->GetGammaLowBit(), 2, 1);
156  AddL1TriggerAlgorithm(64, 103, 1<<fTriggerBitConfig->GetGammaHighBit() | 1<<fTriggerBitConfig->GetGammaLowBit(), 2, 1);
157  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetJetHighBit() | 1<<fTriggerBitConfig->GetJetLowBit(), 16, 4);
158  AddL1TriggerAlgorithm(64, 103, 1<<fTriggerBitConfig->GetJetHighBit() | 1<<fTriggerBitConfig->GetJetLowBit(), 16, 4);
159  fConfigured = true;
160 }
161 
163 {
164  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigNew();
165  SetTriggerBitConfig(triggerBitConfig);
166 
167  // Initialize patch finder
168  if (fPatchFinder) delete fPatchFinder;
170 
171  SetL0TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetLevel0Bit(), 2, 1);
172  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetGammaHighBit() | 1<<fTriggerBitConfig->GetGammaLowBit(), 2, 1);
173  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetJetHighBit() | 1<<fTriggerBitConfig->GetJetLowBit(), 16, 4);
174  fConfigured = true;
175 }
176 
178 {
179  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigOld();
180  SetTriggerBitConfig(triggerBitConfig);
181 
182  // Initialize patch finder
183  if (fPatchFinder) delete fPatchFinder;
185 
186  SetL0TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetLevel0Bit(), 2, 1);
187  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetGammaHighBit(), 2, 1);
188  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetJetHighBit(), 16, 4);
189  fConfigured = true;
190 }
191 
193 {
194  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigOld();
195  SetTriggerBitConfig(triggerBitConfig);
196 
197  // Initialize patch finder
198  if (fPatchFinder) delete fPatchFinder;
200 
201  SetL0TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetLevel0Bit(), 2, 1);
202  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetGammaHighBit(), 2, 1);
203  AddL1TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetJetHighBit(), 16, 4);
204  fConfigured = true;
205 }
206 
208 {
209  AliEMCALTriggerBitConfig* triggerBitConfig = new AliEMCALTriggerBitConfigOld();
210  SetTriggerBitConfig(triggerBitConfig);
211 
212  // Initialize patch finder
213  if (fPatchFinder) delete fPatchFinder;
215 
216  SetL0TriggerAlgorithm(0, 63, 1<<fTriggerBitConfig->GetLevel0Bit(), 2, 1);
217  fConfigured = true;
218 }
219 
221 {
222  Short_t absId = 0;
223 
224  while (stream.good()) {
225  stream >> absId;
226  AddOfflineBadChannel(absId);
227  }
228 }
229 
231 {
232  std::ifstream file(fname);
234 }
235 
237 {
238  Short_t absId = -1;
239 
240  while (stream.good()) {
241  stream >> absId;
242  AddFastORBadChannel(absId);
243  }
244 }
245 
247 {
248  std::ifstream file(fname);
250 }
251 
253 {
254  if (absId < 0 || absId >= fFastORPedestal.GetSize()) {
255  AliWarning(Form("Abs. ID %d out of range (0,5000)", absId));
256  return;
257  }
258  fFastORPedestal[absId] = ped;
259 }
260 
262 {
263  Short_t absId = 0;
264  Float_t ped = 0;
265  while (stream.good()) {
266  stream >> ped;
267  SetFastORPedestal(absId, ped);
268  absId++;
269  }
270 }
271 
273 {
274  std::ifstream file(fname);
276 }
277 
279  fPatchAmplitudes->Reset();
280  fPatchADC->Reset();
281  fPatchADCSimple->Reset();
282  fLevel0TimeMap->Reset();
283  fTriggerBitMap->Reset();
284  memset(fL1ThresholdsOffline, 0, sizeof(ULong64_t) * 4);
285 }
286 
287 void AliEmcalTriggerMakerKernel::ReadTriggerData(AliVCaloTrigger *trigger){
288  trigger->Reset();
289  Int_t globCol=-1, globRow=-1;
290  Int_t adcAmp=-1, bitmap = 0;
291  while(trigger->Next()){
292  // get position in global 2x2 tower coordinates
293  // A0 left bottom (0,0)
294  trigger->GetPosition(globCol, globRow);
295  Int_t absId = -1;
296  fGeometry->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absId);
297 
298  // trigger bits can also occur on online masked fastors. Therefore trigger
299  // bits are handled before ADC values, and independently whether fastor is
300  // masked or not
301  trigger->GetTriggerBits(bitmap);
302  try {
303  (*fTriggerBitMap)(globCol, globRow) = bitmap;
304  }
306  std::string dirstring = e.GetDirection() == AliEMCALTriggerDataGrid<int>::OutOfBoundsException::kColDir ? "Col" : "Row";
307  AliErrorStream() << "Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring << ": " << e.GetIndex() << std::endl;
308  }
309 
310  // also Level0 times need to be handled without masking of the fastor ...
311  // @TODO cross check
312  Int_t nl0times(0);
313  trigger->GetNL0Times(nl0times);
314  if(nl0times){
315  TArrayI l0times(nl0times);
316  trigger->GetL0Times(l0times.GetArray());
317  for(int itime = 0; itime < nl0times; itime++){
318  try{
319  (*fLevel0TimeMap)(globCol,globRow) = static_cast<Char_t>(l0times[itime]);
320  break;
321  }
323  std::string dirstring = e.GetDirection() == AliEMCALTriggerDataGrid<char>::OutOfBoundsException::kColDir ? "Col" : "Row";
324  AliErrorStream() << "Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring << ": " << e.GetIndex() << std::endl;
325  }
326  }
327  }
328 
329  // exclude channel completely if it is masked as hot channel
330  if (fBadChannels.find(absId) != fBadChannels.end()){
331  AliDebugStream(1) << "Found ADC for masked fastor " << absId << ", rejecting" << std::endl;
332  continue;
333  }
334  // for some strange reason some ADC amps are initialized in reconstruction
335  // as -1, neglect those
336  trigger->GetL1TimeSum(adcAmp);
337  if (adcAmp < 0) adcAmp = 0;
338 
339  if (adcAmp >= fMinL1FastORAmp) {
340  try {
341  (*fPatchADC)(globCol,globRow) = adcAmp;
342  }
344  std::string dirstring = e.GetDirection() == AliEMCALTriggerDataGrid<double>::OutOfBoundsException::kColDir ? "Col" : "Row";
345  AliErrorStream() << "Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring << ": " << e.GetIndex() << std::endl;
346  }
347  }
348 
349  // Handling for L0 triggers
350  // For the ADC value we use fCaloTriggers->GetAmplitude()
351  // In data, all patches which have 4 TRUs with proper level0 times are
352  // valid trigger patches. Therefore we need to check all neighbors for
353  // the level0 times, not only the bottom left. In order to obtain this
354  // information, a lookup table with the L0 times for each TRU is created
355  Float_t amplitude(0);
356  trigger->GetAmplitude(amplitude);
357  amplitude *= 4; // values are shifted by 2 bits to fit in a 10 bit word (on the hardware side)
358  amplitude -= fFastORPedestal[absId];
359  if(amplitude < 0) amplitude = 0;
360  if (amplitude >= fMinL0FastORAmp) {
361  try{
362  (*fPatchAmplitudes)(globCol,globRow) = amplitude;
363  }
365  std::string dirstring = e.GetDirection() == AliEMCALTriggerDataGrid<int>::OutOfBoundsException::kColDir ? "Col" : "Row";
366  AliErrorStream() << "Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring << ": " << e.GetIndex() << std::endl;
367  }
368  }
369  }
370 }
371 
372 void AliEmcalTriggerMakerKernel::ReadCellData(AliVCaloCells *cells){
373  // fill the patch ADCs from cells
374  Int_t nCell = cells->GetNumberOfCells();
375  for(Int_t iCell = 0; iCell < nCell; ++iCell) {
376  // get the cell info, based in index in array
377  Short_t cellId = cells->GetCellNumber(iCell);
378 
379  // Check bad channel map
380  if (fOfflineBadChannels.find(cellId) != fOfflineBadChannels.end()) {
381  AliDebugStream(1) << "Cell " << cellId << " masked as bad channel, rejecting." << std::endl;
382  continue;
383  }
384 
385  Double_t amp = cells->GetAmplitude(iCell),
386  celltime = cells->GetTime(iCell);
387  if(celltime < fCellTimeLimits[0] || celltime > fCellTimeLimits[1]) continue;
388  if(amp < fMinCellAmplitude) continue;
389  // get position
390  Int_t absId=-1;
391  fGeometry->GetFastORIndexFromCellIndex(cellId, absId);
393  // Exclude FEE amplitudes from cells which are within a TRU which is masked at
394  // online level. Using this the online acceptance can be applied to offline
395  // patches as well.
396  if(fBadChannels.find(absId) != fBadChannels.end()){
397  AliDebugStream(1) << "Cell " << cellId << " corresponding to masked fastor " << absId << ", rejecting." << std::endl;
398  continue;
399  }
400  }
401  Int_t globCol=-1, globRow=-1;
402  fGeometry->GetPositionInEMCALFromAbsFastORIndex(absId, globCol, globRow);
403  // add
404  amp /= fADCtoGeV;
405  try {
406  if (amp >= fMinCellAmp) (*fPatchADCSimple)(globCol,globRow) += amp;
407  }
409  }
410  }
411 }
412 
414  // get the V0 value and compute and set the offline thresholds
415  // get V0, compute thresholds and save them as global parameters
416  ULong64_t v0S = vzerodata->GetTriggerChargeA() + vzerodata->GetTriggerChargeC();
417  for (Int_t i = 0; i < 4; ++i) {
418  // A*V0^2/2^32+B*V0/2^16+C
419  fL1ThresholdsOffline[i]= ( ((ULong64_t)fThresholdConstants[i][0]) * v0S * v0S ) >> 32;
420  fL1ThresholdsOffline[i] += ( ((ULong64_t)fThresholdConstants[i][1]) * v0S ) >> 16;
421  fL1ThresholdsOffline[i] += ((ULong64_t)fThresholdConstants[i][2]);
422  }
423 }
424 
425 TObjArray *AliEmcalTriggerMakerKernel::CreateTriggerPatches(const AliVEvent *inputevent, Bool_t useL0amp){
426  //std::cout << "Finding trigger patches" << std::endl;
427  //AliEMCALTriggerPatchInfo *trigger, *triggerMainJet, *triggerMainGamma, *triggerMainLevel0;
428  //AliEMCALTriggerPatchInfo *triggerMainJetSimple, *triggerMainGammaSimple;
429 
430  if (useL0amp) {
432  }
433  else {
434  fADCtoGeV = EMCALTrigger::kEMCL1ADCtoGeV;
435  }
436 
437  Double_t vertexpos[3];
438  inputevent->GetPrimaryVertex()->GetXYZ(vertexpos);
439  TVector3 vertexvec(vertexpos);
440 
441  Int_t isMC = fIsMC ? 1 : 0;
442  Int_t offset = (1 - isMC) * fTriggerBitConfig->GetTriggerTypesEnd();
443 
444  // Create trigger bit masks. They are needed later to remove
445  // trigger bits from the trigger bit mask for non-matching patch types
446  Int_t jetPatchMask = 1 << fTriggerBitConfig->GetJetHighBit()
447  | 1 << fTriggerBitConfig->GetJetLowBit()
448  | 1 << (fTriggerBitConfig->GetJetHighBit() + fTriggerBitConfig->GetTriggerTypesEnd())
449  | 1 << (fTriggerBitConfig->GetJetLowBit() + fTriggerBitConfig->GetTriggerTypesEnd()),
450  gammaPatchMask = 1 << fTriggerBitConfig->GetGammaHighBit()
451  | 1 << fTriggerBitConfig->GetGammaLowBit()
452  | 1 << (fTriggerBitConfig->GetGammaHighBit() + fTriggerBitConfig->GetTriggerTypesEnd())
453  | 1 << (fTriggerBitConfig->GetGammaLowBit() + fTriggerBitConfig->GetTriggerTypesEnd()),
454  bkgPatchMask = 1 << fTriggerBitConfig->GetBkgBit();
455  //l0PatchMask = 1 << fTriggerBitConfig->GetLevel0Bit();
456 
457  std::vector<AliEMCALTriggerRawPatch> patches;
458  if (fPatchFinder) {
459  if (useL0amp) {
460  patches = fPatchFinder->FindPatches(*fPatchAmplitudes, *fPatchADCSimple);
461  }
462  else {
463  patches = fPatchFinder->FindPatches(*fPatchADC, *fPatchADCSimple);
464  }
465  }
466  TObjArray *result = new TObjArray(1000);
467  result->SetOwner(kTRUE);
468  for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = patches.begin(); patchit != patches.end(); ++patchit){
469  // Apply offline and recalc selection
470  // Remove unwanted bits from the online bits (gamma bits from jet patches and vice versa)
471  Int_t offlinebits = 0, onlinebits = (*fTriggerBitMap)(patchit->GetColStart(), patchit->GetRowStart());
472  if(HasPHOSOverlap(*patchit)) continue;
473  if(IsGammaPatch(*patchit)){
474  if(patchit->GetADC() > fL1ThresholdsOffline[1]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kRecalcOffset + fTriggerBitConfig->GetGammaHighBit());
475  if(patchit->GetOfflineADC() > fL1ThresholdsOffline[1]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset + fTriggerBitConfig->GetGammaHighBit());
476  if(patchit->GetADC() > fL1ThresholdsOffline[3]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kRecalcOffset + fTriggerBitConfig->GetGammaLowBit());
477  if(patchit->GetOfflineADC() > fL1ThresholdsOffline[3]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset + fTriggerBitConfig->GetGammaLowBit());
478  onlinebits &= gammaPatchMask;
479  }
480  if (IsJetPatch(*patchit)){
481  if(patchit->GetADC() > fL1ThresholdsOffline[0]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kRecalcOffset + fTriggerBitConfig->GetJetHighBit());
482  if(patchit->GetOfflineADC() > fL1ThresholdsOffline[0]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset + fTriggerBitConfig->GetJetHighBit());
483  if(patchit->GetADC() > fL1ThresholdsOffline[2]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kRecalcOffset + fTriggerBitConfig->GetJetLowBit());
484  if(patchit->GetOfflineADC() > fL1ThresholdsOffline[2]) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset + fTriggerBitConfig->GetJetLowBit());
485  onlinebits &= jetPatchMask;
486  }
487  if (IsBkgPatch(*patchit)){
488  if(patchit->GetADC() > fBkgThreshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kRecalcOffset + fTriggerBitConfig->GetBkgBit());
489  if(patchit->GetOfflineADC() > fBkgThreshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset + fTriggerBitConfig->GetBkgBit());
490  onlinebits &= bkgPatchMask;
491  }
492  // convert
493  AliEMCALTriggerPatchInfo *fullpatch = AliEMCALTriggerPatchInfo::CreateAndInitialize(patchit->GetColStart(), patchit->GetRowStart(),
494  patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() * fADCtoGeV,
495  onlinebits | offlinebits, vertexvec, fGeometry);
496  fullpatch->SetTriggerBitConfig(fTriggerBitConfig);
497  fullpatch->SetOffSet(offset);
498  result->Add(fullpatch);
499  }
500 
501  // Find Level0 patches
502  std::vector<AliEMCALTriggerRawPatch> l0patches;
503  if (fLevel0PatchFinder) l0patches = fLevel0PatchFinder->FindPatches(*fPatchAmplitudes, *fPatchADCSimple);
504  for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = l0patches.begin(); patchit != l0patches.end(); ++patchit){
505  Int_t offlinebits = 0, onlinebits = 0;
506  if(HasPHOSOverlap(*patchit)) continue;
507  ELevel0TriggerStatus_t L0status = CheckForL0(patchit->GetColStart(), patchit->GetRowStart());
508  if (L0status == kNotLevel0) continue;
509  if (L0status == kLevel0Fired) SETBIT(onlinebits, fTriggerBitConfig->GetLevel0Bit());
510  if (patchit->GetADC() > fL0Threshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kRecalcOffset + fTriggerBitConfig->GetLevel0Bit());
511  if (patchit->GetOfflineADC() > fL0Threshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset + fTriggerBitConfig->GetLevel0Bit());
512 
513  AliEMCALTriggerPatchInfo *fullpatch = AliEMCALTriggerPatchInfo::CreateAndInitialize(patchit->GetColStart(), patchit->GetRowStart(),
514  patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() * fADCtoGeV,
515  onlinebits | offlinebits, vertexvec, fGeometry);
516  fullpatch->SetTriggerBitConfig(fTriggerBitConfig);
517  result->Add(fullpatch);
518  }
519  // std::cout << "Finished finding trigger patches" << std::endl;
520  return result;
521 }
522 
525 
526  if(col < 0 || row < 0){
527  AliError(Form("Patch outside range [col %d, row %d]", col, row));
528  return kNotLevel0;
529  }
530  Int_t truref(-1), trumod(-1), absFastor(-1), adc(-1);
531  fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col, row, absFastor);
532  fGeometry->GetTRUFromAbsFastORIndex(absFastor, truref, adc);
533  int nvalid(0);
534  const int kNRowsPhi = fGeometry->GetNTotalTRU() * 2;
535  for(int ipos = 0; ipos < 2; ipos++){
536  if(row + ipos >= kNRowsPhi) continue; // boundary check
537  for(int jpos = 0; jpos < 2; jpos++){
538  if(col + jpos >= kColsEta) continue; // boundary check
539  // Check whether we are in the same TRU
540  trumod = -1;
541  fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col+jpos, row+ipos, absFastor);
542  fGeometry->GetTRUFromAbsFastORIndex(absFastor, trumod, adc);
543  if(trumod != truref) {
544  result = kNotLevel0;
545  return result;
546  }
547  if(col + jpos >= kColsEta) AliError(Form("Boundary error in col [%d, %d + %d]", col + jpos, col, jpos));
548  if(row + ipos >= kNRowsPhi) AliError(Form("Boundary error in row [%d, %d + %d]", row + ipos, row, ipos));
549  Char_t l0times = (*fLevel0TimeMap)(col + jpos,row + ipos);
550  if(l0times > fL0MinTime && l0times < fL0MaxTime) nvalid++;
551  }
552  }
553  if (nvalid == 4) result = kLevel0Fired;
554  return result;
555 }
556 
558  fBadChannels.clear();
559 }
560 
562  fOfflineBadChannels.clear();
563 }
564 
565 Bool_t AliEmcalTriggerMakerKernel::IsGammaPatch(const AliEMCALTriggerRawPatch &patch) const {
566  ULong_t bitmask = patch.GetBitmask(), testmask = 1 << fTriggerBitConfig->GetGammaHighBit() | 1 << fTriggerBitConfig->GetGammaLowBit();
567  return bitmask & testmask;
568 }
569 
570 Bool_t AliEmcalTriggerMakerKernel::IsJetPatch(const AliEMCALTriggerRawPatch &patch) const {
571  ULong_t bitmask = patch.GetBitmask(), testmask = 1 << fTriggerBitConfig->GetJetHighBit() | 1 << fTriggerBitConfig->GetJetLowBit();
572  return bitmask & testmask;
573 }
574 
575 Bool_t AliEmcalTriggerMakerKernel::IsBkgPatch(const AliEMCALTriggerRawPatch &patch) const {
576  ULong_t bitmask = patch.GetBitmask(), testmask = 1 << fTriggerBitConfig->GetBkgBit();
577  return bitmask & testmask;
578 }
579 
580 void AliEmcalTriggerMakerKernel::SetTriggerBitConfig(const AliEMCALTriggerBitConfig *const config) {
581  if (config == fTriggerBitConfig) return;
583  fTriggerBitConfig = config;
584 }
585 
586 bool AliEmcalTriggerMakerKernel::HasPHOSOverlap(const AliEMCALTriggerRawPatch &patch) const {
587  const int kEtaMinPhos = 16, kEtaMaxPhos = 31, kPhiMinPhos = 64, kPhiMaxPhos = 99;
588  if(patch.GetRowStart() + patch.GetPatchSize() -1 < kPhiMinPhos) return false; // EMCAL Patch
589  if(patch.GetRowStart() > kPhiMaxPhos) return false; // DCAL 1/3 supermodule
590  if(patch.GetColStart() + patch.GetPatchSize() -1 < kEtaMinPhos) return false;
591  if(patch.GetColStart() > kEtaMaxPhos) return false;
592  return true;
593 }
Int_t fBkgThreshold
threshold for the background patches (8x8)
ELevel0TriggerStatus_t CheckForL0(Int_t col, Int_t row) const
double Double_t
Definition: External.C:58
Double_t fCellTimeLimits[2]
Maximum allowed abs cell time (default [0] = - 10000, [1] = 10000)
Double_t fMinCellAmplitude
Minimum amplitude in cell required to be considered for filling the data grid.
Bool_t IsGammaPatch(const AliEMCALTriggerRawPatch &patch) const
Bool_t IsBkgPatch(const AliEMCALTriggerRawPatch &patch) const
char Char_t
Definition: External.C:18
TObjArray * CreateTriggerPatches(const AliVEvent *inputevent, Bool_t useL0amp=kFALSE)
bool HasPHOSOverlap(const AliEMCALTriggerRawPatch &patch) const
AliEMCALTriggerDataGrid< int > * fTriggerBitMap
! Map of trigger bits
void ReadFastORBadChannelFromStream(std::istream &stream)
TArrayF fFastORPedestal
FastOR pedestal.
void SetTriggerBitConfig(const AliEMCALTriggerBitConfig *const config)
Bool_t fConfigured
Switch specifying whether the trigger maker kernel has been configured for a given data set...
Int_t fMinCellAmp
Minimum offline amplitude of the cells used to generate the patches.
void ReadFastORBadChannelFromFile(const char *fname)
Bool_t fApplyOnlineBadChannelsToOffline
Apply online bad channels to offline ADC values.
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
int Int_t
Definition: External.C:63
void ReadOfflineBadChannelFromFile(const char *fname)
unsigned int UInt_t
Definition: External.C:33
Int_t fThresholdConstants[4][3]
simple offline trigger thresholds constants
float Float_t
Definition: External.C:68
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)
unsigned long ULong_t
Definition: External.C:38
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.
short Short_t
Definition: External.C:23
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.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
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 maker.
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
bool Bool_t
Definition: External.C:53
void ReadFastORPedestalFromStream(std::istream &stream)
void ReadCellData(AliVCaloCells *cells)
const Double_t kEMCL0ADCtoGeV_AP