21 #include <TObjArray.h>
23 #include "AliAODCaloTrigger.h"
24 #include "AliEMCALGeometry.h"
25 #include "AliEMCALTriggerConstants.h"
26 #include "AliEMCALTriggerDataGrid.h"
27 #include "AliEMCALTriggerPatchInfo.h"
28 #include "AliEMCALTriggerPatchFinder.h"
29 #include "AliEMCALTriggerAlgorithm.h"
30 #include "AliEMCALTriggerRawPatch.h"
34 #include "AliVCaloCells.h"
35 #include "AliVCaloTrigger.h"
36 #include "AliVEvent.h"
37 #include "AliVVZERO.h"
46 fOfflineBadChannels(),
47 fFastORPedestal(5000),
48 fTriggerBitConfig(NULL),
50 fPatchAmplitudes(NULL),
51 fPatchADCSimple(NULL),
56 fLevel0PatchFinder(NULL),
69 memset(fThresholdConstants, 0,
sizeof(Int_t) * 12);
70 memset(fL1ThresholdsOffline, 0,
sizeof(ULong64_t) * 4);
92 int nrows =
fGeometry->GetNTotalTRU() * 2;
93 std::cout <<
"Allocating channel grid with 48 columns in eta and " << nrows <<
" rows in phi" << std::endl;
94 std::cout <<
"Using jet patch size " <<
fJetPatchsize << std::endl;
134 while (stream.good()) {
142 std::ifstream
file(fname);
150 while (stream.good()) {
158 std::ifstream
file(fname);
165 AliWarning(Form(
"Abs. ID %d out of range (0,5000)", absId));
175 while (stream.good()) {
184 std::ifstream
file(fname);
199 Int_t globCol=-1, globRow=-1;
200 Int_t adcAmp=-1, bitmap = 0;
201 while(trigger->Next()){
204 trigger->GetPosition(globCol, globRow);
206 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absId);
211 trigger->GetL1TimeSum(adcAmp);
212 if (adcAmp < 0) adcAmp = 0;
215 (*fPatchADC)(globCol,globRow) = adcAmp;
216 trigger->GetTriggerBits(bitmap);
217 (*fTriggerBitMap)(globCol, globRow) = bitmap;
226 Float_t amplitude(0);
227 trigger->GetAmplitude(amplitude);
230 if(amplitude < 0) amplitude = 0;
232 (*fPatchAmplitudes)(globCol,globRow) = amplitude;
234 trigger->GetNL0Times(nl0times);
236 TArrayI l0times(nl0times);
237 trigger->GetL0Times(l0times.GetArray());
238 for(
int itime = 0; itime < nl0times; itime++){
239 (*fLevel0TimeMap)(globCol,globRow) = static_cast<Char_t>(l0times[itime]);
249 Int_t nCell = cells->GetNumberOfCells();
250 for(Int_t iCell = 0; iCell < nCell; ++iCell) {
252 Short_t cellId = cells->GetCellNumber(iCell);
256 AliDebug(10, Form(
"%hd is a bad channel, skipped.", cellId));
260 Double_t amp = cells->GetAmplitude(iCell);
263 fGeometry->GetFastORIndexFromCellIndex(cellId, absId);
264 Int_t globCol=-1, globRow=-1;
265 fGeometry->GetPositionInEMCALFromAbsFastORIndex(absId, globCol, globRow);
268 if (amp >=
fMinCellAmp) (*fPatchADCSimple)(globCol,globRow) += amp;
275 ULong64_t v0S = vzerodata->GetTriggerChargeA() + vzerodata->GetTriggerChargeC();
276 for (Int_t i = 0; i < 4; ++i) {
293 fADCtoGeV = EMCALTrigger::kEMCL1ADCtoGeV;
296 Double_t vertexpos[3];
297 inputevent->GetPrimaryVertex()->GetXYZ(vertexpos);
298 TVector3 vertexvec(vertexpos);
316 std::vector<AliEMCALTriggerRawPatch> patches;
323 TObjArray *result =
new TObjArray(1000);
324 result->SetOwner(kTRUE);
325 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = patches.begin(); patchit != patches.end(); ++patchit){
328 Int_t offlinebits = 0, onlinebits = (*fTriggerBitMap)(patchit->GetColStart(), patchit->GetRowStart());
334 onlinebits &= gammaPatchMask;
341 onlinebits &= jetPatchMask;
346 onlinebits &= bkgPatchMask;
349 AliEMCALTriggerPatchInfo *fullpatch = AliEMCALTriggerPatchInfo::CreateAndInitialize(patchit->GetColStart(), patchit->GetRowStart(),
350 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
351 onlinebits | offlinebits, vertexvec,
fGeometry);
353 fullpatch->SetOffSet(offset);
354 result->Add(fullpatch);
359 for(std::vector<AliEMCALTriggerRawPatch>::iterator patchit = l0patches.begin(); patchit != l0patches.end(); ++patchit){
360 Int_t offlinebits = 0, onlinebits = 0;
365 if (patchit->GetOfflineADC() >
fL0Threshold) SETBIT(offlinebits, AliEMCALTriggerPatchInfo::kOfflineOffset +
fTriggerBitConfig->GetLevel0Bit());
367 AliEMCALTriggerPatchInfo *fullpatch = AliEMCALTriggerPatchInfo::CreateAndInitialize(patchit->GetColStart(), patchit->GetRowStart(),
368 patchit->GetPatchSize(), patchit->GetADC(), patchit->GetOfflineADC(), patchit->GetOfflineADC() *
fADCtoGeV,
369 onlinebits | offlinebits, vertexvec,
fGeometry);
371 result->Add(fullpatch);
380 if(col < 0 || row < 0){
381 AliError(Form(
"Patch outside range [col %d, row %d]", col, row));
384 Int_t truref(-1), trumod(-1), absFastor(-1), adc(-1);
385 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col, row, absFastor);
386 fGeometry->GetTRUFromAbsFastORIndex(absFastor, truref, adc);
388 const int kNRowsPhi =
fGeometry->GetNTotalTRU() * 2;
389 for(
int ipos = 0; ipos < 2; ipos++){
390 if(row + ipos >= kNRowsPhi)
continue;
391 for(
int jpos = 0; jpos < 2; jpos++){
392 if(col + jpos >=
kColsEta)
continue;
395 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(col+jpos, row+ipos, absFastor);
396 fGeometry->GetTRUFromAbsFastORIndex(absFastor, trumod, adc);
397 if(trumod != truref) {
401 if(col + jpos >=
kColsEta) AliError(Form(
"Boundary error in col [%d, %d + %d]", col + jpos, col, jpos));
402 if(row + ipos >= kNRowsPhi) AliError(Form(
"Boundary error in row [%d, %d + %d]", row + ipos, row, ipos));
403 Char_t l0times = (*fLevel0TimeMap)(col + jpos,row + ipos);
413 result->SetPatchSize(2);
414 result->SetSubregionSize(1);
422 result->SetSubregionSize(4);
429 result->SetPatchSize(8);
430 result->SetSubregionSize(4);
437 return bitmask & testmask;
442 return bitmask & testmask;
446 ULong_t bitmask = patch.GetBitmask(), testmask = 1 <<
fTriggerBitConfig->GetBkgBit();
447 return bitmask & testmask;
Int_t fBkgThreshold
threshold for the background patches (8x8)
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
ELevel0TriggerStatus_t CheckForL0(Int_t col, Int_t row) const
Bool_t IsGammaPatch(const AliEMCALTriggerRawPatch &patch) const
Bool_t IsBkgPatch(const AliEMCALTriggerRawPatch &patch) const
TObjArray * CreateTriggerPatches(const AliVEvent *inputevent, Bool_t useL0amp=kFALSE)
AliEMCALTriggerDataGrid< int > * fTriggerBitMap
! Map of trigger bits
void ReadFastORBadChannelFromStream(std::istream &stream)
TArrayF fFastORPedestal
FastOR pedestal.
void AddFastORBadChannel(Short_t absId)
Int_t fMinCellAmp
Minimum offline amplitude of the cells used to generate the patches.
void ReadFastORBadChannelFromFile(const char *fname)
void ReadTriggerData(AliVCaloTrigger *trigger)
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)
Int_t fThresholdConstants[4][3]
simple offline trigger thresholds constants
virtual ~AliEmcalTriggerMakerKernel()
AliEMCALTriggerAlgorithm< double > * CreateGammaTriggerAlgorithm(Int_t rowmin, Int_t rowmax) const
Double_t fADCtoGeV
! Conversion factor from ADC to GeV
void ReadOfflineBadChannelFromStream(std::istream &stream)
void SetFastORPedestal(Short_t absId, Float_t ped)
void AddOfflineBadChannel(Short_t absId)
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)
AliEMCALTriggerDataGrid< double > * fPatchADC
! ADC values map
Int_t fMinL0FastORAmp
Minimum L0 amplitude of the FastORs used to generate the patches.
AliEMCALTriggerAlgorithm< double > * CreateBkgTriggerAlgorithm(Int_t rowmin, Int_t rowmax) const
std::set< Short_t > fOfflineBadChannels
Abd ID of offline bad channels.
AliEMCALTriggerPatchFinder< double > * fPatchFinder
! The actual patch finder
AliEMCALTriggerDataGrid< double > * fPatchADCSimple
! patch map for simple offline trigger
Kernel of the EMCAL trigger patch makerThe trigger maker kernel contains the core functionality of th...
void ReadFastORPedestalFromFile(const char *fname)
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
Int_t fL0MinTime
Minimum L0 time.
Int_t fL0MaxTime
Maximum L0 time.
Int_t fJetPatchsize
Size of a jet patch.
void ReadFastORPedestalFromStream(std::istream &stream)
void ReadCellData(AliVCaloCells *cells)
AliEMCALTriggerAlgorithm< double > * CreateJetTriggerAlgorithm(Int_t rowmin, Int_t rowmax) const
const Double_t kEMCL0ADCtoGeV_AP