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();
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 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = patches.begin(); patchit != patches.end(); ++patchit){
503 Int_t offlinebits = 0, onlinebits = (*fTriggerBitMap)(patchit->GetColStart(), patchit->GetRowStart());
510 onlinebits &= gammaPatchMask;
517 onlinebits &= jetPatchMask;
522 onlinebits &= bkgPatchMask;
525 AliEMCALTriggerPatchInfo fullpatch;
526 fullpatch.Initialize(patchit->GetColStart(), patchit->GetRowStart(),
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;
540 fullpatch.SetSmearedEnergy(energysmear);
542 outputcont.push_back(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());
557 AliEMCALTriggerPatchInfo fullpatch;
558 fullpatch.Initialize(patchit->GetColStart(), patchit->GetRowStart(),
559 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
560 onlinebits | offlinebits, vertexvec,
fGeometry);
564 double energysmear = 0;
565 for(
int icol = 0; icol < fullpatch.GetPatchSize(); icol++){
566 for(
int irow = 0; irow < fullpatch.GetPatchSize(); irow++){
567 energysmear += (*fPatchEnergySimpleSmeared)(fullpatch.GetColStart() + icol, fullpatch.GetRowStart() + irow);
570 fullpatch.SetSmearedEnergy(energysmear);
572 outputcont.push_back(fullpatch);
581 adc = (*fPatchADC)(col, row);
591 adc = (*fPatchADC)(col, row) * EMCALTrigger::kEMCL1ADCtoGeV;
601 adc = (*fPatchADCSimple)(col, row);
611 adc = (*fPatchADCSimple)(col, row) *
fADCtoGeV;
622 adc = (*fPatchEnergySimpleSmeared)(col, row);
637 if(col < 0 || row < 0){
638 AliError(Form(
"Patch outside range [col %d, row %d]", col, row));
641 Int_t truref(-1), trumod(-1), absFastor(-1), adc(-1);
642 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col, row, absFastor);
643 fGeometry->GetTRUFromAbsFastORIndex(absFastor, truref, adc);
645 const int kNRowsPhi =
fGeometry->GetNTotalTRU() * 2;
646 for(
int ipos = 0; ipos < 2; ipos++){
647 if(row + ipos >= kNRowsPhi)
continue;
648 for(
int jpos = 0; jpos < 2; jpos++){
649 if(col + jpos >=
kColsEta)
continue;
652 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col+jpos, row+ipos, absFastor);
653 fGeometry->GetTRUFromAbsFastORIndex(absFastor, trumod, adc);
654 if(trumod != truref) {
658 if(col + jpos >=
kColsEta) AliError(Form(
"Boundary error in col [%d, %d + %d]", col + jpos, col, jpos));
659 if(row + ipos >= kNRowsPhi) AliError(Form(
"Boundary error in row [%d, %d + %d]", row + ipos, row, ipos));
660 Char_t l0times = (*fLevel0TimeMap)(col + jpos,row + ipos);
678 return bitmask & testmask;
683 return bitmask & testmask;
688 return bitmask & testmask;
698 const int kEtaMinPhos = 16, kEtaMaxPhos = 31, kPhiMinPhos = 64, kPhiMaxPhos = 99;
699 if(patch.GetRowStart() + patch.GetPatchSize() -1 < kPhiMinPhos)
return false;
700 if(patch.GetRowStart() > kPhiMaxPhos)
return false;
701 if(patch.GetColStart() + patch.GetPatchSize() -1 < kEtaMinPhos)
return false;
702 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 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.
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.
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
TF1 * fSmearModelSigma
Smearing parameterization for the width.
const Double_t kEMCL0ADCtoGeV_AP