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.),
62 fApplyOnlineBadChannelsToOffline(kFALSE),
65 fPatchAmplitudes(NULL),
66 fPatchADCSimple(NULL),
72 memset(fThresholdConstants, 0,
sizeof(
Int_t) * 12);
73 memset(fL1ThresholdsOffline, 0,
sizeof(ULong64_t) * 4);
89 AliWarning(
"Trigger bit configuration was not provided! Assuming new bit configuration (>= 2013).");
90 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
101 int nrows =
fGeometry->GetNTotalTRU() * 2;
102 std::cout <<
"Allocating channel grid with 48 columns in eta and " << nrows <<
" rows in phi" << std::endl;
114 trigger->SetPatchSize(patchSize);
115 trigger->SetSubregionSize(subregionSize);
129 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
146 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
163 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
178 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
193 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
208 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
223 while (stream.good()) {
231 std::ifstream
file(fname);
239 while (stream.good()) {
247 std::ifstream
file(fname);
254 AliWarning(Form(
"Abs. ID %d out of range (0,5000)", absId));
264 while (stream.good()) {
273 std::ifstream
file(fname);
288 Int_t globCol=-1, globRow=-1;
289 Int_t adcAmp=-1, bitmap = 0;
290 while(trigger->Next()){
293 trigger->GetPosition(globCol, globRow);
295 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absId);
300 trigger->GetTriggerBits(bitmap);
302 (*fTriggerBitMap)(globCol, globRow) = bitmap;
306 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
312 trigger->GetNL0Times(nl0times);
315 trigger->GetL0Times(l0times.GetArray());
316 for(
int itime = 0; itime < nl0times; itime++){
318 (*fLevel0TimeMap)(globCol,globRow) = static_cast<Char_t>(l0times[itime]);
323 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
330 AliDebugStream(1) <<
"Found ADC for masked fastor " << absId <<
", rejecting" << std::endl;
335 trigger->GetL1TimeSum(adcAmp);
336 if (adcAmp < 0) adcAmp = 0;
340 (*fPatchADC)(globCol,globRow) = adcAmp;
344 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
355 trigger->GetAmplitude(amplitude);
358 if(amplitude < 0) amplitude = 0;
361 (*fPatchAmplitudes)(globCol,globRow) = amplitude;
365 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
373 Int_t nCell = cells->GetNumberOfCells();
374 for(
Int_t iCell = 0; iCell < nCell; ++iCell) {
376 Short_t cellId = cells->GetCellNumber(iCell);
380 AliDebugStream(1) <<
"Cell " << cellId <<
" masked as bad channel, rejecting." << std::endl;
384 Double_t amp = cells->GetAmplitude(iCell),
385 celltime = cells->GetTime(iCell);
390 fGeometry->GetFastORIndexFromCellIndex(cellId, absId);
396 AliDebugStream(1) <<
"Cell " << cellId <<
" corresponding to masked fastor " << absId <<
", rejecting." << std::endl;
400 Int_t globCol=-1, globRow=-1;
401 fGeometry->GetPositionInEMCALFromAbsFastORIndex(absId, globCol, globRow);
405 if (amp >=
fMinCellAmp) (*fPatchADCSimple)(globCol,globRow) += amp;
415 ULong64_t v0S = vzerodata->GetTriggerChargeA() + vzerodata->GetTriggerChargeC();
416 for (
Int_t i = 0; i < 4; ++i) {
433 fADCtoGeV = EMCALTrigger::kEMCL1ADCtoGeV;
437 inputevent->GetPrimaryVertex()->GetXYZ(vertexpos);
438 TVector3 vertexvec(vertexpos);
456 std::vector<AliEMCALTriggerRawPatch> patches;
466 result->SetOwner(kTRUE);
467 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = patches.begin(); patchit != patches.end(); ++patchit){
470 Int_t offlinebits = 0, onlinebits = (*fTriggerBitMap)(patchit->GetColStart(), patchit->GetRowStart());
477 onlinebits &= gammaPatchMask;
484 onlinebits &= jetPatchMask;
489 onlinebits &= bkgPatchMask;
492 AliEMCALTriggerPatchInfo *fullpatch = AliEMCALTriggerPatchInfo::CreateAndInitialize(patchit->GetColStart(), patchit->GetRowStart(),
493 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
494 onlinebits | offlinebits, vertexvec,
fGeometry);
496 fullpatch->SetOffSet(offset);
497 result->Add(fullpatch);
501 std::vector<AliEMCALTriggerRawPatch> l0patches;
503 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = l0patches.begin(); patchit != l0patches.end(); ++patchit){
504 Int_t offlinebits = 0, onlinebits = 0;
510 if (patchit->GetOfflineADC() >
fL0Threshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset +
fTriggerBitConfig->GetLevel0Bit());
512 AliEMCALTriggerPatchInfo *fullpatch = AliEMCALTriggerPatchInfo::CreateAndInitialize(patchit->GetColStart(), patchit->GetRowStart(),
513 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
514 onlinebits | offlinebits, vertexvec,
fGeometry);
516 result->Add(fullpatch);
525 if(col < 0 || row < 0){
526 AliError(Form(
"Patch outside range [col %d, row %d]", col, row));
529 Int_t truref(-1), trumod(-1), absFastor(-1), adc(-1);
530 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col, row, absFastor);
531 fGeometry->GetTRUFromAbsFastORIndex(absFastor, truref, adc);
533 const int kNRowsPhi =
fGeometry->GetNTotalTRU() * 2;
534 for(
int ipos = 0; ipos < 2; ipos++){
535 if(row + ipos >= kNRowsPhi)
continue;
536 for(
int jpos = 0; jpos < 2; jpos++){
537 if(col + jpos >=
kColsEta)
continue;
540 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col+jpos, row+ipos, absFastor);
541 fGeometry->GetTRUFromAbsFastORIndex(absFastor, trumod, adc);
542 if(trumod != truref) {
546 if(col + jpos >=
kColsEta) AliError(Form(
"Boundary error in col [%d, %d + %d]", col + jpos, col, jpos));
547 if(row + ipos >= kNRowsPhi) AliError(Form(
"Boundary error in row [%d, %d + %d]", row + ipos, row, ipos));
548 Char_t l0times = (*fLevel0TimeMap)(col + jpos,row + ipos);
566 return bitmask & testmask;
571 return bitmask & testmask;
576 return bitmask & testmask;
586 const int kEtaMinPhos = 16, kEtaMaxPhos = 31, kPhiMinPhos = 64, kPhiMaxPhos = 99;
587 if(patch.GetRowStart() + patch.GetPatchSize() -1 < kPhiMinPhos)
return false;
588 if(patch.GetRowStart() > kPhiMaxPhos)
return false;
589 if(patch.GetColStart() + patch.GetPatchSize() -1 < kEtaMinPhos)
return false;
590 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()
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 ClearFastORBadChannels()
void ConfigureForPP2011()
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
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 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
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