22 #include <TObjArray.h>
25 #include "AliAODCaloTrigger.h"
26 #include "AliEMCALGeometry.h"
27 #include "AliEMCALTriggerConstants.h"
28 #include "AliEMCALTriggerDataGrid.h"
30 #include "AliEMCALTriggerPatchFinder.h"
31 #include "AliEMCALTriggerAlgorithm.h"
32 #include "AliEMCALTriggerRawPatch.h"
36 #include "AliVCaloCells.h"
37 #include "AliVCaloTrigger.h"
38 #include "AliVEvent.h"
39 #include "AliVVZERO.h"
48 fOfflineBadChannels(),
49 fFastORPedestal(5000),
50 fTriggerBitConfig(
nullptr),
51 fPatchFinder(
nullptr),
52 fLevel0PatchFinder(
nullptr),
62 fMinCellAmplitude(0.),
63 fApplyOnlineBadChannelsToOffline(kFALSE),
65 fSmearModelMean(
nullptr),
66 fSmearModelSigma(
nullptr),
69 fPatchAmplitudes(
nullptr),
70 fPatchADCSimple(
nullptr),
72 fPatchEnergySimpleSmeared(
nullptr),
73 fLevel0TimeMap(
nullptr),
74 fTriggerBitMap(
nullptr),
77 memset(fThresholdConstants, 0,
sizeof(
Int_t) * 12);
78 memset(fL1ThresholdsOffline, 0,
sizeof(ULong64_t) * 4);
79 fCellTimeLimits[0] = -10000.;
80 fCellTimeLimits[1] = 10000.;
97 AliWarning(
"Trigger bit configuration was not provided! Assuming new bit configuration (>= 2013).");
98 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
109 int nrows =
fGeometry->GetNTotalTRU() * 2;
110 std::cout <<
"Allocating channel grid with 48 columns in eta and " << nrows <<
" rows in phi" << std::endl;
128 trigger->SetPatchSize(patchSize);
129 trigger->SetSubregionSize(subregionSize);
143 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
160 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
177 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
192 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
207 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
222 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
237 while (stream.good()) {
245 std::ifstream
file(fname);
253 while (stream.good()) {
261 std::ifstream
file(fname);
268 AliWarning(Form(
"Abs. ID %d out of range (0,5000)", absId));
278 while (stream.good()) {
287 std::ifstream
file(fname);
303 Int_t globCol=-1, globRow=-1;
304 Int_t adcAmp=-1, bitmap = 0;
305 while(trigger->Next()){
308 trigger->GetPosition(globCol, globRow);
310 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absId);
315 trigger->GetTriggerBits(bitmap);
317 (*fTriggerBitMap)(globCol, globRow) = bitmap;
321 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
327 trigger->GetNL0Times(nl0times);
330 trigger->GetL0Times(l0times.GetArray());
331 for(
int itime = 0; itime < nl0times; itime++){
333 (*fLevel0TimeMap)(globCol,globRow) = static_cast<Char_t>(l0times[itime]);
338 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
345 AliDebugStream(1) <<
"Found ADC for masked fastor " << absId <<
", rejecting" << std::endl;
350 trigger->GetL1TimeSum(adcAmp);
351 if (adcAmp < 0) adcAmp = 0;
355 (*fPatchADC)(globCol,globRow) = adcAmp;
359 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
370 trigger->GetAmplitude(amplitude);
373 if(amplitude < 0) amplitude = 0;
376 (*fPatchAmplitudes)(globCol,globRow) = amplitude;
380 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
388 Int_t nCell = cells->GetNumberOfCells();
389 for(
Int_t iCell = 0; iCell < nCell; ++iCell) {
391 Short_t cellId = cells->GetCellNumber(iCell);
395 AliDebugStream(1) <<
"Cell " << cellId <<
" masked as bad channel, rejecting." << std::endl;
399 Double_t amp = cells->GetAmplitude(iCell),
400 celltime = cells->GetTime(iCell);
405 fGeometry->GetFastORIndexFromCellIndex(cellId, absId);
411 AliDebugStream(1) <<
"Cell " << cellId <<
" corresponding to masked fastor " << absId <<
", rejecting." << std::endl;
415 Int_t globCol=-1, globRow=-1;
416 fGeometry->GetPositionInEMCALFromAbsFastORIndex(absId, globCol, globRow);
420 if (amp >=
fMinCellAmp) (*fPatchADCSimple)(globCol,globRow) += amp;
428 AliDebugStream(1) <<
"Trigger Maker: Apply energy smearing" << std::endl;
431 double energyorig = (*fPatchADCSimple)(icol, irow) *
fADCtoGeV;
432 double energysmear = energyorig;
436 if(energysmear < 0) energysmear = 0;
437 AliDebugStream(1) <<
"Original energy " << energyorig <<
", mean " << mean <<
", sigma " <<
sigma <<
", smeared " << energysmear << std::endl;
439 (*fPatchEnergySimpleSmeared)(icol, irow) = energysmear;
442 AliDebugStream(1) <<
"Smearing done" << std::endl;
449 ULong64_t v0S = vzerodata->GetTriggerChargeA() + vzerodata->GetTriggerChargeC();
450 for (
Int_t i = 0; i < 4; ++i) {
467 fADCtoGeV = EMCALTrigger::kEMCL1ADCtoGeV;
471 inputevent->GetPrimaryVertex()->GetXYZ(vertexpos);
472 TVector3 vertexvec(vertexpos);
490 std::vector<AliEMCALTriggerRawPatch> patches;
500 result->SetOwner(kTRUE);
501 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = patches.begin(); patchit != patches.end(); ++patchit){
504 Int_t offlinebits = 0, onlinebits = (*fTriggerBitMap)(patchit->GetColStart(), patchit->GetRowStart());
511 onlinebits &= gammaPatchMask;
518 onlinebits &= jetPatchMask;
523 onlinebits &= bkgPatchMask;
527 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
528 onlinebits | offlinebits, vertexvec,
fGeometry);
530 fullpatch->SetOffSet(offset);
533 double energysmear = 0;
534 for(
int icol = 0; icol < fullpatch->GetPatchSize(); icol++){
535 for(
int irow = 0; irow < fullpatch->GetPatchSize(); irow++){
536 energysmear += (*fPatchEnergySimpleSmeared)(fullpatch->GetColStart() + icol, fullpatch->GetRowStart() + irow);
539 AliDebugStream(1) <<
"Patch size(" << fullpatch->GetPatchSize() <<
") energy " << fullpatch->GetPatchE() <<
" smeared " << energysmear << std::endl;
542 result->Add(fullpatch);
546 std::vector<AliEMCALTriggerRawPatch> l0patches;
548 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = l0patches.begin(); patchit != l0patches.end(); ++patchit){
549 Int_t offlinebits = 0, onlinebits = 0;
555 if (patchit->GetOfflineADC() >
fL0Threshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset +
fTriggerBitConfig->GetLevel0Bit());
558 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
559 onlinebits | offlinebits, vertexvec,
fGeometry);
563 double energysmear = 0;
564 for(
int icol = 0; icol < fullpatch->GetPatchSize(); icol++){
565 for(
int irow = 0; irow < fullpatch->GetPatchSize(); irow++){
566 energysmear += (*fPatchEnergySimpleSmeared)(fullpatch->GetColStart() + icol, fullpatch->GetRowStart() + irow);
571 result->Add(fullpatch);
580 if(col < 0 || row < 0){
581 AliError(Form(
"Patch outside range [col %d, row %d]", col, row));
584 Int_t truref(-1), trumod(-1), absFastor(-1), adc(-1);
585 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col, row, absFastor);
586 fGeometry->GetTRUFromAbsFastORIndex(absFastor, truref, adc);
588 const int kNRowsPhi =
fGeometry->GetNTotalTRU() * 2;
589 for(
int ipos = 0; ipos < 2; ipos++){
590 if(row + ipos >= kNRowsPhi)
continue;
591 for(
int jpos = 0; jpos < 2; jpos++){
592 if(col + jpos >=
kColsEta)
continue;
595 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col+jpos, row+ipos, absFastor);
596 fGeometry->GetTRUFromAbsFastORIndex(absFastor, trumod, adc);
597 if(trumod != truref) {
601 if(col + jpos >=
kColsEta) AliError(Form(
"Boundary error in col [%d, %d + %d]", col + jpos, col, jpos));
602 if(row + ipos >= kNRowsPhi) AliError(Form(
"Boundary error in row [%d, %d + %d]", row + ipos, row, ipos));
603 Char_t l0times = (*fLevel0TimeMap)(col + jpos,row + ipos);
621 return bitmask & testmask;
626 return bitmask & testmask;
631 return bitmask & testmask;
641 const int kEtaMinPhos = 16, kEtaMaxPhos = 31, kPhiMinPhos = 64, kPhiMaxPhos = 99;
642 if(patch.GetRowStart() + patch.GetPatchSize() -1 < kPhiMinPhos)
return false;
643 if(patch.GetRowStart() > kPhiMaxPhos)
return false;
644 if(patch.GetColStart() + patch.GetPatchSize() -1 < kEtaMinPhos)
return false;
645 if(patch.GetColStart() > kEtaMaxPhos)
return false;
void Reset()
Reset all data grids and VZERO-dependent L1 thresholds.
Int_t fBkgThreshold
threshold for the background patches (8x8)
ELevel0TriggerStatus_t CheckForL0(Int_t col, Int_t row) const
Accept trigger patch as Level0 patch.
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
Check from the bitmask whether the patch is a gamma patch.
void ConfigureForPbPb2015()
Configure the class for 2015 PbPb.
void ConfigureForPP2015()
Configure the class for 2015 pp.
Bool_t IsBkgPatch(const AliEMCALTriggerRawPatch &patch) const
Check from the bitmask whether the patch is a background patch.
TObjArray * CreateTriggerPatches(const AliVEvent *inputevent, Bool_t useL0amp=kFALSE)
Run patch finders on input data.
bool HasPHOSOverlap(const AliEMCALTriggerRawPatch &patch) const
AliEMCALTriggerDataGrid< int > * fTriggerBitMap
! Map of trigger bits
void ReadFastORBadChannelFromStream(std::istream &stream)
Read the FastOR bad channel map from a standard stream.
TArrayF fFastORPedestal
FastOR pedestal.
void AddFastORBadChannel(Short_t absId)
Add a FastOR bad channel to the list.
void SetTriggerBitConfig(const AliEMCALTriggerBitConfig *const config)
Set the trigger bit configuration applied for the given data set.
void ConfigureForPbPb2011()
Configure the class for 2011 PbPb.
Bool_t fConfigured
Switch specifying whether the trigger maker kernel has been configured for a given data set...
void Init()
Initialize the trigger maker Kernel.
Int_t fMinCellAmp
Minimum offline amplitude of the cells used to generate the patches.
void ClearFastORBadChannels()
Clear FastOR bad channel list.
void ConfigureForPP2011()
Configure the class for 2011 pp.
void ReadFastORBadChannelFromFile(const char *fname)
Read the FastOR bad channel map from a text file.
void SetSmearedEnergyV1(double e)
Bool_t fApplyOnlineBadChannelsToOffline
Apply online bad channels to offline ADC values.
void ReadTriggerData(AliVCaloTrigger *trigger)
Read the calo trigger data.
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)
Read the offline bad channel map from a text file.
void ConfigureForPP2012()
Configure the class for 2012 pp.
Int_t fThresholdConstants[4][3]
simple offline trigger thresholds constants
virtual ~AliEmcalTriggerMakerKernel()
Destructor.
Double_t fSmearThreshold
Smear threshold: Only cell energies above threshold are smeared.
Temporary class handling.
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)
Set the L0 algorithm.
void ReadOfflineBadChannelFromStream(std::istream &stream)
Read the offline bad channel map from a standard stream.
void SetFastORPedestal(Short_t absId, Float_t ped)
Set the pedestal value for a FastOR.
void AddOfflineBadChannel(Short_t absId)
Add an offline bad channel to the set.
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)
Build VZERO-dependent thresholds for the offline trigger.
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()
Clear offline bad channel list.
AliEMCALTriggerDataGrid< double > * fPatchADCSimple
! patch map for simple offline trigger
Kernel of the EMCAL trigger patch maker.
void ReadFastORPedestalFromFile(const char *fname)
Read the FastOR pedestals from a text file.
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
Check from the bitmask whether the patch is a jet patch.
TF1 * fSmearModelMean
Smearing parameterization for the mean.
static AliEMCALTriggerPatchInfoV1 * CreateAndInitializeV1(UChar_t col0, UChar_t row0, UChar_t size, UInt_t adc, UInt_t offlineAdc, Double_t patchE, UInt_t bitmask, const TVector3 &vertex, const AliEMCALGeometry *geom)
Int_t fL0MinTime
Minimum L0 time.
Int_t fL0MaxTime
Maximum L0 time.
void ReadFastORPedestalFromStream(std::istream &stream)
Read the FastOR pedestals from a standard stream.
void ReadCellData(AliVCaloCells *cells)
Read the EMCAL cell data.
void ConfigureForPPb2013()
Configure the class for 2013 pPb.
AliEMCALTriggerDataGrid< double > * fPatchEnergySimpleSmeared
! Data grid for smeared energy values from cell energies
TF1 * fSmearModelSigma
Smearing parameterization for the width.
const Double_t kEMCL0ADCtoGeV_AP