22 #include <TObjArray.h>
25 #include "AliAODCaloTrigger.h"
26 #include "AliEMCALGeometry.h"
27 #include "AliEMCALTriggerConstants.h"
28 #include "AliEMCALTriggerDataGrid.h"
29 #include "AliEMCALTriggerPatchInfo.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();
194 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
209 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
224 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
239 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
254 while (stream.good()) {
262 std::ifstream
file(fname);
270 while (stream.good()) {
278 std::ifstream
file(fname);
285 AliWarning(Form(
"Abs. ID %d out of range (0,5000)", absId));
295 while (stream.good()) {
304 std::ifstream
file(fname);
320 Int_t globCol=-1, globRow=-1;
321 Int_t adcAmp=-1, bitmap = 0;
322 while(trigger->Next()){
325 trigger->GetPosition(globCol, globRow);
327 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absId);
332 trigger->GetTriggerBits(bitmap);
334 (*fTriggerBitMap)(globCol, globRow) = bitmap;
338 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
344 trigger->GetNL0Times(nl0times);
347 trigger->GetL0Times(l0times.GetArray());
348 for(
int itime = 0; itime < nl0times; itime++){
350 (*fLevel0TimeMap)(globCol,globRow) = static_cast<Char_t>(l0times[itime]);
355 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
362 AliDebugStream(1) <<
"Found ADC for masked fastor " << absId <<
", rejecting" << std::endl;
367 trigger->GetL1TimeSum(adcAmp);
368 if (adcAmp < 0) adcAmp = 0;
372 (*fPatchADC)(globCol,globRow) = adcAmp;
376 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
387 trigger->GetAmplitude(amplitude);
390 if(amplitude < 0) amplitude = 0;
393 (*fPatchAmplitudes)(globCol,globRow) = amplitude;
397 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
405 Int_t nCell = cells->GetNumberOfCells();
406 for(
Int_t iCell = 0; iCell < nCell; ++iCell) {
408 Short_t cellId = cells->GetCellNumber(iCell);
412 AliDebugStream(1) <<
"Cell " << cellId <<
" masked as bad channel, rejecting." << std::endl;
416 Double_t amp = cells->GetAmplitude(iCell),
417 celltime = cells->GetTime(iCell);
422 fGeometry->GetFastORIndexFromCellIndex(cellId, absId);
428 AliDebugStream(1) <<
"Cell " << cellId <<
" corresponding to masked fastor " << absId <<
", rejecting." << std::endl;
432 Int_t globCol=-1, globRow=-1;
433 fGeometry->GetPositionInEMCALFromAbsFastORIndex(absId, globCol, globRow);
437 if (amp >=
fMinCellAmp) (*fPatchADCSimple)(globCol,globRow) += amp;
445 AliDebugStream(1) <<
"Trigger Maker: Apply energy smearing" << std::endl;
448 double energyorig = (*fPatchADCSimple)(icol, irow) *
fADCtoGeV;
449 double energysmear = energyorig;
453 if(energysmear < 0) energysmear = 0;
454 AliDebugStream(1) <<
"Original energy " << energyorig <<
", mean " << mean <<
", sigma " <<
sigma <<
", smeared " << energysmear << std::endl;
456 (*fPatchEnergySimpleSmeared)(icol, irow) = energysmear;
459 AliDebugStream(1) <<
"Smearing done" << std::endl;
466 ULong64_t v0S = vzerodata->GetTriggerChargeA() + vzerodata->GetTriggerChargeC();
467 for (
Int_t i = 0; i < 4; ++i) {
484 fADCtoGeV = EMCALTrigger::kEMCL1ADCtoGeV;
488 inputevent->GetPrimaryVertex()->GetXYZ(vertexpos);
489 TVector3 vertexvec(vertexpos);
507 std::vector<AliEMCALTriggerRawPatch> patches;
517 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = patches.begin(); patchit != patches.end(); ++patchit){
520 Int_t offlinebits = 0, onlinebits = (*fTriggerBitMap)(patchit->GetColStart(), patchit->GetRowStart());
527 onlinebits &= gammaPatchMask;
534 onlinebits &= jetPatchMask;
539 onlinebits &= bkgPatchMask;
542 AliEMCALTriggerPatchInfo fullpatch;
543 fullpatch.Initialize(patchit->GetColStart(), patchit->GetRowStart(),
544 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
545 onlinebits | offlinebits, vertexvec,
fGeometry);
547 fullpatch.SetOffSet(offset);
550 double energysmear = 0;
551 for(
int icol = 0; icol < fullpatch.GetPatchSize(); icol++){
552 for(
int irow = 0; irow < fullpatch.GetPatchSize(); irow++){
553 energysmear += (*fPatchEnergySimpleSmeared)(fullpatch.GetColStart() + icol, fullpatch.GetRowStart() + irow);
556 AliDebugStream(1) <<
"Patch size(" << fullpatch.GetPatchSize() <<
") energy " << fullpatch.GetPatchE() <<
" smeared " << energysmear << std::endl;
557 fullpatch.SetSmearedEnergy(energysmear);
559 outputcont.push_back(fullpatch);
563 std::vector<AliEMCALTriggerRawPatch> l0patches;
565 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = l0patches.begin(); patchit != l0patches.end(); ++patchit){
566 Int_t offlinebits = 0, onlinebits = 0;
572 if (patchit->GetOfflineADC() >
fL0Threshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset +
fTriggerBitConfig->GetLevel0Bit());
574 AliEMCALTriggerPatchInfo fullpatch;
575 fullpatch.Initialize(patchit->GetColStart(), patchit->GetRowStart(),
576 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
577 onlinebits | offlinebits, vertexvec,
fGeometry);
581 double energysmear = 0;
582 for(
int icol = 0; icol < fullpatch.GetPatchSize(); icol++){
583 for(
int irow = 0; irow < fullpatch.GetPatchSize(); irow++){
584 energysmear += (*fPatchEnergySimpleSmeared)(fullpatch.GetColStart() + icol, fullpatch.GetRowStart() + irow);
587 fullpatch.SetSmearedEnergy(energysmear);
589 outputcont.push_back(fullpatch);
597 amp = (*fPatchAmplitudes)(col, row);
607 adc = (*fPatchADC)(col, row);
617 adc = (*fPatchADC)(col, row) * EMCALTrigger::kEMCL1ADCtoGeV;
627 adc = (*fPatchADCSimple)(col, row);
637 adc = (*fPatchADCSimple)(col, row) *
fADCtoGeV;
648 adc = (*fPatchEnergySimpleSmeared)(col, row);
663 if(col < 0 || row < 0){
664 AliError(Form(
"Patch outside range [col %d, row %d]", col, row));
667 Int_t truref(-1), trumod(-1), absFastor(-1), adc(-1);
668 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col, row, absFastor);
669 fGeometry->GetTRUFromAbsFastORIndex(absFastor, truref, adc);
671 const int kNRowsPhi =
fGeometry->GetNTotalTRU() * 2;
672 for(
int ipos = 0; ipos < 2; ipos++){
673 if(row + ipos >= kNRowsPhi)
continue;
674 for(
int jpos = 0; jpos < 2; jpos++){
675 if(col + jpos >=
kColsEta)
continue;
678 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col+jpos, row+ipos, absFastor);
679 fGeometry->GetTRUFromAbsFastORIndex(absFastor, trumod, adc);
680 if(trumod != truref) {
684 if(col + jpos >=
kColsEta) AliError(Form(
"Boundary error in col [%d, %d + %d]", col + jpos, col, jpos));
685 if(row + ipos >= kNRowsPhi) AliError(Form(
"Boundary error in row [%d, %d + %d]", row + ipos, row, ipos));
686 Char_t l0times = (*fLevel0TimeMap)(col + jpos,row + ipos);
704 return bitmask & testmask;
709 return bitmask & testmask;
714 return bitmask & testmask;
724 const int kEtaMinPhos = 16, kEtaMaxPhos = 31, kPhiMinPhos = 64, kPhiMaxPhos = 99;
725 if(patch.GetRowStart() + patch.GetPatchSize() -1 < kPhiMinPhos)
return false;
726 if(patch.GetRowStart() > kPhiMaxPhos)
return false;
727 if(patch.GetColStart() + patch.GetPatchSize() -1 < kEtaMinPhos)
return false;
728 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.
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 CreateTriggerPatches(const AliVEvent *inputevent, std::vector< AliEMCALTriggerPatchInfo > &outputcont, Bool_t useL0amp=kFALSE)
Run patch finders on input data.
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.
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 ConfigureForPP20158x8()
Configure the class for 2015 pp.
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 GetTriggerChannelADC(Int_t col, Int_t row) const
Get ADC value of a given trigger channel (in col-row space)
Double_t fSmearThreshold
Smear threshold: Only cell energies above threshold are smeared.
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.
double GetTriggerChannelEnergy(Int_t col, Int_t row) const
Get energy of the trigger channel estimated from cells (in col-row space)
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.
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.
TFile * file
TList with histograms for a given trigger.
double GetTriggerChannelADCSimple(Int_t col, Int_t row) const
Get ADC value of trigger channel estimated from cell energies.
double GetTriggerChannelEnergyRough(Int_t col, Int_t row) const
Get estimated energy of the trigger channel based on ADC measurement (in col-row space) ...
double GetTriggerChannelEnergySmeared(Int_t col, Int_t row) const
Get (simulated) smeared energy of a trigger channel estimated based on the measured energy from cells...
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.
Int_t fL0MinTime
Minimum L0 time.
Int_t fL0MaxTime
Maximum L0 time.
double GetDataGridDimensionRows() const
Get the dimension of the underlying data grids in row direction.
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
double GetL0TriggerChannelAmplitude(Int_t col, Int_t row) const
Get L0 amplitude of a given trigger channel (in col-row space)
TF1 * fSmearModelSigma
Smearing parameterization for the width.
const Double_t kEMCL0ADCtoGeV_AP