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),
70 fPatchAmplitudes(
nullptr),
71 fPatchADCSimple(
nullptr),
73 fPatchEnergySimpleSmeared(
nullptr),
74 fLevel0TimeMap(
nullptr),
75 fTriggerBitMap(
nullptr),
78 memset(fThresholdConstants, 0,
sizeof(
Int_t) * 12);
79 memset(fL1ThresholdsOffline, 0,
sizeof(ULong64_t) * 4);
80 fCellTimeLimits[0] = -10000.;
81 fCellTimeLimits[1] = 10000.;
98 AliWarning(
"Trigger bit configuration was not provided! Assuming new bit configuration (>= 2013).");
99 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
110 int nrows =
fGeometry->GetNTotalTRU() * 2;
111 std::cout <<
"Allocating channel grid with 48 columns in eta and " << nrows <<
" rows in phi" << std::endl;
129 trigger->SetPatchSize(patchSize);
130 trigger->SetSubregionSize(subregionSize);
144 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
161 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
178 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
195 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
210 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
225 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
240 AliEMCALTriggerBitConfig* triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
255 while (stream.good()) {
263 std::ifstream
file(fname);
271 while (stream.good()) {
279 std::ifstream
file(fname);
286 AliWarning(Form(
"Abs. ID %d out of range (0,5000)", absId));
296 while (stream.good()) {
305 std::ifstream
file(fname);
321 Int_t globCol=-1, globRow=-1;
322 Int_t adcAmp=-1, bitmap = 0;
323 while(trigger->Next()){
326 trigger->GetPosition(globCol, globRow);
328 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absId);
333 trigger->GetTriggerBits(bitmap);
335 (*fTriggerBitMap)(globCol, globRow) = bitmap;
339 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
345 trigger->GetNL0Times(nl0times);
348 trigger->GetL0Times(l0times.GetArray());
349 for(
int itime = 0; itime < nl0times; itime++){
351 (*fLevel0TimeMap)(globCol,globRow) = static_cast<Char_t>(l0times[itime]);
356 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
363 AliDebugStream(1) <<
"Found ADC for masked fastor " << absId <<
", rejecting" << std::endl;
368 trigger->GetL1TimeSum(adcAmp);
369 if (adcAmp < 0) adcAmp = 0;
373 (*fPatchADC)(globCol,globRow) = adcAmp;
377 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
388 trigger->GetAmplitude(amplitude);
391 if(amplitude < 0) amplitude = 0;
394 (*fPatchAmplitudes)(globCol,globRow) = amplitude;
398 AliErrorStream() <<
"Trigger maker task - filling trigger bit grid - index out-of-bounds in " << dirstring <<
": " << e.GetIndex() << std::endl;
406 Int_t nCell = cells->GetNumberOfCells();
407 for(
Int_t iCell = 0; iCell < nCell; ++iCell) {
409 Short_t cellId = cells->GetCellNumber(iCell);
413 AliDebugStream(1) <<
"Cell " << cellId <<
" masked as bad channel, rejecting." << std::endl;
417 Double_t amp = cells->GetAmplitude(iCell),
418 celltime = cells->GetTime(iCell);
422 amp = TMath::Max(amp, 0.);
425 fGeometry->GetFastORIndexFromCellIndex(cellId, absId);
431 AliDebugStream(1) <<
"Cell " << cellId <<
" corresponding to masked fastor " << absId <<
", rejecting." << std::endl;
435 Int_t globCol=-1, globRow=-1;
436 fGeometry->GetPositionInEMCALFromAbsFastORIndex(absId, globCol, globRow);
440 if (amp >=
fMinCellAmp) (*fPatchADCSimple)(globCol,globRow) += amp;
448 AliDebugStream(1) <<
"Trigger Maker: Apply energy smearing" << std::endl;
451 double energyorig = (*fPatchADCSimple)(icol, irow) *
fADCtoGeV;
452 double energysmear = energyorig;
456 if(energysmear < 0) energysmear = 0;
457 AliDebugStream(1) <<
"Original energy " << energyorig <<
", mean " << mean <<
", sigma " <<
sigma <<
", smeared " << energysmear << std::endl;
459 (*fPatchEnergySimpleSmeared)(icol, irow) = energysmear;
462 AliDebugStream(1) <<
"Smearing done" << std::endl;
469 ULong64_t v0S = vzerodata->GetTriggerChargeA() + vzerodata->GetTriggerChargeC();
470 for (
Int_t i = 0; i < 4; ++i) {
487 fADCtoGeV = EMCALTrigger::kEMCL1ADCtoGeV;
491 inputevent->GetPrimaryVertex()->GetXYZ(vertexpos);
492 TVector3 vertexvec(vertexpos);
510 std::vector<AliEMCALTriggerRawPatch> patches;
520 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = patches.begin(); patchit != patches.end(); ++patchit){
523 Int_t offlinebits = 0, onlinebits = (*fTriggerBitMap)(patchit->GetColStart(), patchit->GetRowStart());
530 onlinebits &= gammaPatchMask;
537 onlinebits &= jetPatchMask;
542 onlinebits &= bkgPatchMask;
545 AliEMCALTriggerPatchInfo fullpatch;
546 fullpatch.Initialize(patchit->GetColStart(), patchit->GetRowStart(),
547 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
548 onlinebits | offlinebits, vertexvec,
fGeometry);
550 fullpatch.SetOffSet(offset);
553 double energysmear = 0;
554 for(
int icol = 0; icol < fullpatch.GetPatchSize(); icol++){
555 for(
int irow = 0; irow < fullpatch.GetPatchSize(); irow++){
556 energysmear += (*fPatchEnergySimpleSmeared)(fullpatch.GetColStart() + icol, fullpatch.GetRowStart() + irow);
559 AliDebugStream(1) <<
"Patch size(" << fullpatch.GetPatchSize() <<
") energy " << fullpatch.GetPatchE() <<
" smeared " << energysmear << std::endl;
560 fullpatch.SetSmearedEnergy(energysmear);
562 outputcont.push_back(fullpatch);
566 std::vector<AliEMCALTriggerRawPatch> l0patches;
568 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = l0patches.begin(); patchit != l0patches.end(); ++patchit){
569 Int_t offlinebits = 0, onlinebits = 0;
575 if (patchit->GetOfflineADC() >
fL0Threshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset +
fTriggerBitConfig->GetLevel0Bit());
577 AliEMCALTriggerPatchInfo fullpatch;
578 fullpatch.Initialize(patchit->GetColStart(), patchit->GetRowStart(),
579 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
580 onlinebits | offlinebits, vertexvec,
fGeometry);
584 double energysmear = 0;
585 for(
int icol = 0; icol < fullpatch.GetPatchSize(); icol++){
586 for(
int irow = 0; irow < fullpatch.GetPatchSize(); irow++){
587 energysmear += (*fPatchEnergySimpleSmeared)(fullpatch.GetColStart() + icol, fullpatch.GetRowStart() + irow);
590 fullpatch.SetSmearedEnergy(energysmear);
592 outputcont.push_back(fullpatch);
600 amp = (*fPatchAmplitudes)(col, row);
610 adc = (*fPatchADC)(col, row);
620 adc = (*fPatchADC)(col, row) * EMCALTrigger::kEMCL1ADCtoGeV;
630 adc = (*fPatchADCSimple)(col, row);
640 adc = (*fPatchADCSimple)(col, row) *
fADCtoGeV;
651 adc = (*fPatchEnergySimpleSmeared)(col, row);
666 if(col < 0 || row < 0){
667 AliError(Form(
"Patch outside range [col %d, row %d]", col, row));
670 Int_t truref(-1), trumod(-1), absFastor(-1), adc(-1);
671 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col, row, absFastor);
672 fGeometry->GetTRUFromAbsFastORIndex(absFastor, truref, adc);
674 const int kNRowsPhi =
fGeometry->GetNTotalTRU() * 2;
675 for(
int ipos = 0; ipos < 2; ipos++){
676 if(row + ipos >= kNRowsPhi)
continue;
677 for(
int jpos = 0; jpos < 2; jpos++){
678 if(col + jpos >=
kColsEta)
continue;
681 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col+jpos, row+ipos, absFastor);
682 fGeometry->GetTRUFromAbsFastORIndex(absFastor, trumod, adc);
683 if(trumod != truref) {
687 if(col + jpos >=
kColsEta) AliError(Form(
"Boundary error in col [%d, %d + %d]", col + jpos, col, jpos));
688 if(row + ipos >= kNRowsPhi) AliError(Form(
"Boundary error in row [%d, %d + %d]", row + ipos, row, ipos));
689 Char_t l0times = (*fLevel0TimeMap)(col + jpos,row + ipos);
707 return bitmask & testmask;
712 return bitmask & testmask;
717 return bitmask & testmask;
727 const int kEtaMinPhos = 16, kEtaMaxPhos = 31, kPhiMinPhos = 64, kPhiMaxPhos = 99;
728 if(patch.GetRowStart() + patch.GetPatchSize() -1 < kPhiMinPhos)
return false;
729 if(patch.GetRowStart() > kPhiMaxPhos)
return false;
730 if(patch.GetColStart() + patch.GetPatchSize() -1 < kEtaMinPhos)
return false;
731 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_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