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 fDoBackgroundSubtraction(false),
71 fPatchAmplitudes(
nullptr),
72 fPatchADCSimple(
nullptr),
74 fPatchEnergySimpleSmeared(
nullptr),
75 fLevel0TimeMap(
nullptr),
76 fTriggerBitMap(
nullptr),
79 memset(fThresholdConstants, 0,
sizeof(
Int_t) * 12);
80 memset(fL1ThresholdsOffline, 0,
sizeof(ULong64_t) * 4);
81 fCellTimeLimits[0] = -10000.;
82 fCellTimeLimits[1] = 10000.;
83 memset(fRhoValues, 0,
sizeof(
Double_t) * kNIndRho);
100 AliWarning(
"Trigger bit configuration was not provided! Assuming new bit configuration (>= 2013).");
101 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
112 int nrows =
fGeometry->GetNTotalTRU() * 2;
113 std::cout <<
"Allocating channel grid with 48 columns in eta and " << nrows <<
" rows in phi" << std::endl;
131 trigger->SetPatchSize(patchSize);
132 trigger->SetSubregionSize(subregionSize);
146 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
164 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
181 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
198 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
213 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
228 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
243 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
258 while (stream.good()) {
266 std::ifstream
file(fname);
274 while (stream.good()) {
282 std::ifstream
file(fname);
289 AliWarning(Form(
"Abs. ID %d out of range (0,5000)", absId));
299 while (stream.good()) {
308 std::ifstream
file(fname);
324 Int_t globCol=-1, globRow=-1;
325 Int_t adcAmp=-1, bitmap = 0;
326 while(trigger->Next()){
329 trigger->GetPosition(globCol, globRow);
331 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absId);
336 trigger->GetTriggerBits(bitmap);
338 (*fTriggerBitMap)(globCol, globRow) = bitmap;
342 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
348 trigger->GetNL0Times(nl0times);
351 trigger->GetL0Times(l0times.GetArray());
352 for(
int itime = 0; itime < nl0times; itime++){
354 (*fLevel0TimeMap)(globCol,globRow) = static_cast<Char_t>(l0times[itime]);
359 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
366 AliDebugStream(1) <<
"Found ADC for masked fastor " << absId <<
", rejecting" << std::endl;
371 trigger->GetL1TimeSum(adcAmp);
372 if (adcAmp < 0) adcAmp = 0;
376 (*fPatchADC)(globCol,globRow) = adcAmp;
380 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
391 trigger->GetAmplitude(amplitude);
394 if(amplitude < 0) amplitude = 0;
397 (*fPatchAmplitudes)(globCol,globRow) = amplitude;
401 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
416 Int_t nCell = cells->GetNumberOfCells();
417 for(
Int_t iCell = 0; iCell < nCell; ++iCell) {
419 Short_t cellId = cells->GetCellNumber(iCell);
423 AliDebugStream(1) <<
"Cell " << cellId <<
" masked as bad channel, rejecting." << std::endl;
427 Double_t amp = cells->GetAmplitude(iCell),
428 celltime = cells->GetTime(iCell);
432 amp = TMath::Max(amp, 0.);
435 fGeometry->GetFastORIndexFromCellIndex(cellId, absId);
441 AliDebugStream(1) <<
"Cell " << cellId <<
" corresponding to masked fastor " << absId <<
", rejecting." << std::endl;
445 Int_t globCol=-1, globRow=-1;
446 fGeometry->GetPositionInEMCALFromAbsFastORIndex(absId, globCol, globRow);
450 if (amp >=
fMinCellAmp) (*fPatchADCSimple)(globCol,globRow) += amp;
458 AliDebugStream(1) <<
"Trigger Maker: Apply energy smearing" << std::endl;
461 double energyorig = (*fPatchADCSimple)(icol, irow) *
fADCtoGeV;
462 double energysmear = energyorig;
466 if(energysmear < 0) energysmear = 0;
467 AliDebugStream(1) <<
"Original energy " << energyorig <<
", mean " << mean <<
", sigma " <<
sigma <<
", smeared " << energysmear << std::endl;
469 (*fPatchEnergySimpleSmeared)(icol, irow) = energysmear;
472 AliDebugStream(1) <<
"Smearing done" << std::endl;
479 ULong64_t v0S = vzerodata->GetTriggerChargeA() + vzerodata->GetTriggerChargeC();
480 for (
Int_t i = 0; i < 4; ++i) {
497 fADCtoGeV = EMCALTrigger::kEMCL1ADCtoGeV;
501 inputevent->GetPrimaryVertex()->GetXYZ(vertexpos);
502 TVector3 vertexvec(vertexpos);
520 std::vector<AliEMCALTriggerRawPatch> patches;
530 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = patches.begin(); patchit != patches.end(); ++patchit){
533 Int_t offlinebits = 0, onlinebits = (*fTriggerBitMap)(patchit->GetColStart(), patchit->GetRowStart());
540 onlinebits &= gammaPatchMask;
547 onlinebits &= jetPatchMask;
552 onlinebits &= bkgPatchMask;
555 double area = TMath::Power(static_cast<double>(patchit->GetPatchSize())/8., 2);
557 AliDebugStream(1) <<
"Subtracting background for area " << area <<
": " << rhoval <<
" -> " << (area * rhoval) << std::endl;
558 patchit->SetADC(patchit->GetADC() - area * rhoval);
561 AliEMCALTriggerPatchInfo fullpatch;
562 fullpatch.Initialize(patchit->GetColStart(), patchit->GetRowStart(),
563 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
564 onlinebits | offlinebits, vertexvec,
fGeometry);
566 fullpatch.SetOffSet(offset);
569 double energysmear = 0;
570 for(
int icol = 0; icol < fullpatch.GetPatchSize(); icol++){
571 for(
int irow = 0; irow < fullpatch.GetPatchSize(); irow++){
572 energysmear += (*fPatchEnergySimpleSmeared)(fullpatch.GetColStart() + icol, fullpatch.GetRowStart() + irow);
575 AliDebugStream(1) <<
"Patch size(" << fullpatch.GetPatchSize() <<
") energy " << fullpatch.GetPatchE() <<
" smeared " << energysmear << std::endl;
576 fullpatch.SetSmearedEnergy(energysmear);
578 outputcont.push_back(fullpatch);
582 std::vector<AliEMCALTriggerRawPatch> l0patches;
584 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = l0patches.begin(); patchit != l0patches.end(); ++patchit){
585 Int_t offlinebits = 0, onlinebits = 0;
591 if (patchit->GetOfflineADC() >
fL0Threshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset +
fTriggerBitConfig->GetLevel0Bit());
593 AliEMCALTriggerPatchInfo fullpatch;
594 fullpatch.Initialize(patchit->GetColStart(), patchit->GetRowStart(),
595 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
596 onlinebits | offlinebits, vertexvec,
fGeometry);
600 double energysmear = 0;
601 for(
int icol = 0; icol < fullpatch.GetPatchSize(); icol++){
602 for(
int irow = 0; irow < fullpatch.GetPatchSize(); irow++){
603 energysmear += (*fPatchEnergySimpleSmeared)(fullpatch.GetColStart() + icol, fullpatch.GetRowStart() + irow);
606 fullpatch.SetSmearedEnergy(energysmear);
608 outputcont.push_back(fullpatch);
616 amp = (*fPatchAmplitudes)(col, row);
626 adc = (*fPatchADC)(col, row);
636 adc = (*fPatchADC)(col, row) * EMCALTrigger::kEMCL1ADCtoGeV;
646 adc = (*fPatchADCSimple)(col, row);
656 adc = (*fPatchADCSimple)(col, row) *
fADCtoGeV;
667 adc = (*fPatchEnergySimpleSmeared)(col, row);
682 if(col < 0 || row < 0){
683 AliError(Form(
"Patch outside range [col %d, row %d]", col, row));
686 Int_t truref(-1), trumod(-1), absFastor(-1), adc(-1);
687 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col, row, absFastor);
688 fGeometry->GetTRUFromAbsFastORIndex(absFastor, truref, adc);
690 const int kNRowsPhi =
fGeometry->GetNTotalTRU() * 2;
691 for(
int ipos = 0; ipos < 2; ipos++){
692 if(row + ipos >= kNRowsPhi)
continue;
693 for(
int jpos = 0; jpos < 2; jpos++){
694 if(col + jpos >=
kColsEta)
continue;
697 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col+jpos, row+ipos, absFastor);
698 fGeometry->GetTRUFromAbsFastORIndex(absFastor, trumod, adc);
699 if(trumod != truref) {
703 if(col + jpos >=
kColsEta) AliError(Form(
"Boundary error in col [%d, %d + %d]", col + jpos, col, jpos));
704 if(row + ipos >= kNRowsPhi) AliError(Form(
"Boundary error in row [%d, %d + %d]", row + ipos, row, ipos));
705 Char_t l0times = (*fLevel0TimeMap)(col + jpos,row + ipos);
723 return bitmask & testmask;
728 return bitmask & testmask;
733 return bitmask & testmask;
743 const int kEtaMinPhos = 16, kEtaMaxPhos = 31, kPhiMinPhos = 64, kPhiMaxPhos = 99;
744 if(patch.GetRowStart() + patch.GetPatchSize() -1 < kPhiMinPhos)
return false;
745 if(patch.GetRowStart() > kPhiMaxPhos)
return false;
746 if(patch.GetColStart() + patch.GetPatchSize() -1 < kEtaMinPhos)
return false;
747 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.
Bool_t fDoBackgroundSubtraction
Swtich for background subtraction (only online ADC)
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.
Double_t fRhoValues[kNIndRho]
! Rho values for background subtraction (only online ADC)
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_t fScaleShift
Scale shift simulation.
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