21 #include <TObjArray.h>
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"
34 #include "AliVCaloCells.h"
35 #include "AliVCaloTrigger.h"
36 #include "AliVEvent.h"
37 #include "AliVVZERO.h"
46 fOfflineBadChannels(),
47 fFastORPedestal(5000),
48 fTriggerBitConfig(NULL),
50 fLevel0PatchFinder(NULL),
61 fMinCellAmplitude(0.),
63 fPatchAmplitudes(NULL),
64 fPatchADCSimple(NULL),
70 memset(fThresholdConstants, 0,
sizeof(Int_t) * 12);
71 memset(fL1ThresholdsOffline, 0,
sizeof(ULong64_t) * 4);
87 AliWarning(
"Trigger bit configuration was not provided! Assuming new bit configuration (>= 2013).");
88 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
99 int nrows =
fGeometry->GetNTotalTRU() * 2;
100 std::cout <<
"Allocating channel grid with 48 columns in eta and " << nrows <<
" rows in phi" << std::endl;
112 trigger->SetPatchSize(patchSize);
113 trigger->SetSubregionSize(subregionSize);
127 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
143 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
159 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
173 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
187 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
201 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
215 while (stream.good()) {
223 std::ifstream
file(fname);
231 while (stream.good()) {
239 std::ifstream
file(fname);
246 AliWarning(Form(
"Abs. ID %d out of range (0,5000)", absId));
256 while (stream.good()) {
265 std::ifstream
file(fname);
280 Int_t globCol=-1, globRow=-1;
281 Int_t adcAmp=-1, bitmap = 0;
282 while(trigger->Next()){
285 trigger->GetPosition(globCol, globRow);
287 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absId);
292 trigger->GetL1TimeSum(adcAmp);
293 if (adcAmp < 0) adcAmp = 0;
294 trigger->GetTriggerBits(bitmap);
298 (*fPatchADC)(globCol,globRow) = adcAmp;
303 (*fTriggerBitMap)(globCol, globRow) = bitmap;
315 Float_t amplitude(0);
316 trigger->GetAmplitude(amplitude);
319 if(amplitude < 0) amplitude = 0;
321 (*fPatchAmplitudes)(globCol,globRow) = amplitude;
323 trigger->GetNL0Times(nl0times);
325 TArrayI l0times(nl0times);
326 trigger->GetL0Times(l0times.GetArray());
327 for(
int itime = 0; itime < nl0times; itime++){
328 (*fLevel0TimeMap)(globCol,globRow) = static_cast<Char_t>(l0times[itime]);
338 Int_t nCell = cells->GetNumberOfCells();
339 for(Int_t iCell = 0; iCell < nCell; ++iCell) {
341 Short_t cellId = cells->GetCellNumber(iCell);
345 AliDebug(10, Form(
"%hd is a bad channel, skipped.", cellId));
349 Double_t amp = cells->GetAmplitude(iCell),
350 celltime = cells->GetTime(iCell);
355 fGeometry->GetFastORIndexFromCellIndex(cellId, absId);
356 Int_t globCol=-1, globRow=-1;
357 fGeometry->GetPositionInEMCALFromAbsFastORIndex(absId, globCol, globRow);
361 if (amp >=
fMinCellAmp) (*fPatchADCSimple)(globCol,globRow) += amp;
371 ULong64_t v0S = vzerodata->GetTriggerChargeA() + vzerodata->GetTriggerChargeC();
372 for (Int_t i = 0; i < 4; ++i) {
389 fADCtoGeV = EMCALTrigger::kEMCL1ADCtoGeV;
392 Double_t vertexpos[3];
393 inputevent->GetPrimaryVertex()->GetXYZ(vertexpos);
394 TVector3 vertexvec(vertexpos);
412 std::vector<AliEMCALTriggerRawPatch> patches;
421 TObjArray *result =
new TObjArray(1000);
422 result->SetOwner(kTRUE);
423 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = patches.begin(); patchit != patches.end(); ++patchit){
426 Int_t offlinebits = 0, onlinebits = (*fTriggerBitMap)(patchit->GetColStart(), patchit->GetRowStart());
433 onlinebits &= gammaPatchMask;
440 onlinebits &= jetPatchMask;
445 onlinebits &= bkgPatchMask;
448 AliEMCALTriggerPatchInfo *fullpatch = AliEMCALTriggerPatchInfo::CreateAndInitialize(patchit->GetColStart(), patchit->GetRowStart(),
449 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
450 onlinebits | offlinebits, vertexvec,
fGeometry);
452 fullpatch->SetOffSet(offset);
453 result->Add(fullpatch);
457 std::vector<AliEMCALTriggerRawPatch> l0patches;
459 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = l0patches.begin(); patchit != l0patches.end(); ++patchit){
460 Int_t offlinebits = 0, onlinebits = 0;
466 if (patchit->GetOfflineADC() >
fL0Threshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset +
fTriggerBitConfig->GetLevel0Bit());
468 AliEMCALTriggerPatchInfo *fullpatch = AliEMCALTriggerPatchInfo::CreateAndInitialize(patchit->GetColStart(), patchit->GetRowStart(),
469 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
470 onlinebits | offlinebits, vertexvec,
fGeometry);
472 result->Add(fullpatch);
481 if(col < 0 || row < 0){
482 AliError(Form(
"Patch outside range [col %d, row %d]", col, row));
485 Int_t truref(-1), trumod(-1), absFastor(-1), adc(-1);
486 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col, row, absFastor);
487 fGeometry->GetTRUFromAbsFastORIndex(absFastor, truref, adc);
489 const int kNRowsPhi =
fGeometry->GetNTotalTRU() * 2;
490 for(
int ipos = 0; ipos < 2; ipos++){
491 if(row + ipos >= kNRowsPhi)
continue;
492 for(
int jpos = 0; jpos < 2; jpos++){
493 if(col + jpos >=
kColsEta)
continue;
496 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col+jpos, row+ipos, absFastor);
497 fGeometry->GetTRUFromAbsFastORIndex(absFastor, trumod, adc);
498 if(trumod != truref) {
502 if(col + jpos >=
kColsEta) AliError(Form(
"Boundary error in col [%d, %d + %d]", col + jpos, col, jpos));
503 if(row + ipos >= kNRowsPhi) AliError(Form(
"Boundary error in row [%d, %d + %d]", row + ipos, row, ipos));
504 Char_t l0times = (*fLevel0TimeMap)(col + jpos,row + ipos);
522 return bitmask & testmask;
527 return bitmask & testmask;
531 ULong_t bitmask = patch.GetBitmask(), testmask = 1 <<
fTriggerBitConfig->GetBkgBit();
532 return bitmask & testmask;
542 const int kEtaMinPhos = 16, kEtaMaxPhos = 31, kPhiMinPhos = 64, kPhiMaxPhos = 99;
543 if(patch.GetRowStart() + patch.GetPatchSize() -1 < kPhiMinPhos)
return false;
544 if(patch.GetRowStart() > kPhiMaxPhos)
return false;
545 if(patch.GetColStart() + patch.GetPatchSize() -1 < kEtaMinPhos)
return false;
546 if(patch.GetColStart() > kEtaMaxPhos)
return false;
Int_t fBkgThreshold
threshold for the background patches (8x8)
ELevel0TriggerStatus_t CheckForL0(Int_t col, Int_t row) const
Double_t fMinCellAmplitude
Minimum amplitude in cell required to be considered for filling the data grid.
Bool_t IsGammaPatch(const AliEMCALTriggerRawPatch &patch) const
void ConfigureForPbPb2015()
void ConfigureForPP2015()
Bool_t IsBkgPatch(const AliEMCALTriggerRawPatch &patch) const
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 AddFastORBadChannel(Short_t absId)
void SetTriggerBitConfig(const AliEMCALTriggerBitConfig *const config)
void ConfigureForPbPb2011()
Int_t fMinCellAmp
Minimum offline amplitude of the cells used to generate the patches.
void ClearFastORBadChannels()
void ConfigureForPP2011()
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
Bool_t fIsMC
Set MC offset.
ULong64_t fL1ThresholdsOffline[4]
container for V0-dependent offline thresholds
void ReadOfflineBadChannelFromFile(const char *fname)
void ConfigureForPP2012()
Int_t fThresholdConstants[4][3]
simple offline trigger thresholds constants
virtual ~AliEmcalTriggerMakerKernel()
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)
void AddOfflineBadChannel(Short_t absId)
std::set< Short_t > fBadChannels
Container of bad channels.
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
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.
void ClearOfflineBadChannels()
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
Double_t fMaxAbsCellTime
Maximum allowed abs cell time (default - 1)
Int_t fL0MinTime
Minimum L0 time.
Int_t fL0MaxTime
Maximum L0 time.
void ReadFastORPedestalFromStream(std::istream &stream)
void ReadCellData(AliVCaloCells *cells)
void ConfigureForPPb2013()
const Double_t kEMCL0ADCtoGeV_AP