15 #include <TClonesArray.h>
17 #include <THashList.h>
18 #include "AliAODCaloTrigger.h"
19 #include "AliEMCALGeometry.h"
24 #include "AliVCaloCells.h"
25 #include "AliVCaloTrigger.h"
26 #include "AliVVZERO.h"
29 #include "THistManager.h"
42 const TString
AliEmcalTriggerMaker::fgkTriggerTypeNames[5] = {
"EJE",
"EGA",
"EL0",
"REJE",
"REGA"};
49 fCaloTriggersOutName(
"EmcalTriggers"),
50 fCaloTriggerSetupOutName(
"EmcalTriggersSetup"),
51 fV0InName(
"AliAODVZERO"),
52 fUseTriggerBitConfig(kNewConfig),
53 fTriggerBitConfig(NULL),
55 fCaloTriggerSetupOut(0),
56 fSimpleOfflineTriggers(0),
59 fRejectOffAcceptancePatches(kFALSE),
82 fCaloTriggersOutName(
"EmcalTriggers"),
83 fCaloTriggerSetupOutName(
"EmcalTriggersSetup"),
84 fV0InName(
"AliAODVZERO"),
85 fUseTriggerBitConfig(kNewConfig),
86 fTriggerBitConfig(NULL),
88 fCaloTriggerSetupOut(0),
89 fSimpleOfflineTriggers(0),
92 fRejectOffAcceptancePatches(kFALSE),
147 AliFatal(Form(
"%s: Container with same name %s already present. Aborting", GetName(),
fCaloTriggersOutName.Data()));
161 AliFatal(Form(
"%s: Container with same name %s already present. Aborting", GetName(),
fCaloTriggerSetupOutName.Data()));
167 fV0 = (AliVVZERO*)InputEvent()->FindListObject(
fV0InName);
183 fQAHistos =
new THistManager(
"TriggerQA");
184 const char *patchtypes[2] = {
"Online",
"Offline"};
186 for(
int itype = 0; itype < 5; itype++){
187 for(
const char **patchtype = patchtypes; patchtype < patchtypes + 2; ++patchtype){
188 fQAHistos->CreateTH2(Form(
"RCPos%s%s",
fgkTriggerTypeNames[itype].Data(), *patchtype), Form(
"Lower edge position of %s %s patches (col-row);iEta;iPhi", *patchtype,
fgkTriggerTypeNames[itype].Data()), 48, -0.5, 47.5, 64, -0.5, 63.5);
189 fQAHistos->CreateTH2(Form(
"EPCentPos%s%s",
fgkTriggerTypeNames[itype].Data(), *patchtype), Form(
"Center position of the %s %s trigger patches;#eta;#phi", *patchtype,
fgkTriggerTypeNames[itype].Data()), 20, -0.8, 0.8, 100, 1., 4.);
190 fQAHistos->CreateTH2(Form(
"PatchADCvsE%s%s",
fgkTriggerTypeNames[itype].Data(), *patchtype), Form(
"Patch ADC value for trigger type %s %s;Trigger ADC;FEE patch energy (GeV)", *patchtype,
fgkTriggerTypeNames[itype].Data()), 2000, 0., 2000, 200, 0., 200);
193 fQAHistos->CreateTH1(
"triggerBitsAll",
"Trigger bits for all incoming patches;bit nr", 64, -0.5, 63.5);
194 fQAHistos->CreateTH1(
"triggerBitsSel",
"Trigger bits for reconstructed patches;bit nr", 64, -0.5, 63.5);
214 AliError(Form(
"Calo triggers container %s not available.",
fCaloTriggersName.Data()));
218 AliError(Form(
"Calo cells container %s not available.",
fCaloCellsName.Data()));
222 AliError(Form(
"V0 container %s not available.",
fV0InName.Data()));
254 Int_t globCol=-1, globRow=-1;
271 Float_t amplitude(0);
273 if(amplitude < 0) amplitude = 0;
278 TArrayI l0times(nl0times);
280 for(
int itime = 0; itime < nl0times; itime++){
281 if(l0times[itime] >7 && l0times[itime] < 10){
282 fLevel0TimeMap[globCol][globRow] =
static_cast<Char_t
>(l0times[itime]);
296 for(Int_t iCell = 0; iCell < nCell; ++iCell) {
298 Short_t cellId =
fCaloCells->GetCellNumber(iCell);
299 Double_t amp =
fCaloCells->GetAmplitude(iCell);
302 fGeom->GetFastORIndexFromCellIndex(cellId, absId);
303 Int_t globCol=-1, globRow=-1;
304 fGeom->GetPositionInEMCALFromAbsFastORIndex(absId, globCol, globRow);
319 v0[0] =
fV0->GetTriggerChargeA();
320 v0[1] =
fV0->GetTriggerChargeC();
321 ULong64_t v0S = v0[0] + v0[1];
324 for (Int_t i = 0; i < 4; ++i) {
348 triggerMainGamma = 0;
350 triggerMainGammaSimple = 0;
351 triggerMainJetSimple = 0;
352 triggerMainLevel0 = 0;
355 Bool_t isOfflineSimple=0;
363 if (!isOfflineSimple) {
365 triggerMainJet = trigger;
367 if (triggerMainJetSimple == 0 || (triggerMainJetSimple->
GetPatchE() < trigger->
GetPatchE()))
368 triggerMainJetSimple = trigger;
379 if (!isOfflineSimple) {
381 triggerMainGamma = trigger;
383 if (triggerMainGammaSimple == 0 || (triggerMainGammaSimple->
GetPatchE() < trigger->
GetPatchE()))
384 triggerMainGammaSimple = trigger;
390 if(!isOfflineSimple){
396 triggerMainLevel0 = trigger;
410 if (triggerMainJet != 0) {
416 if (triggerMainJetSimple != 0) {
422 if (triggerMainGamma != 0) {
428 if (triggerMainGammaSimple != 0) {
434 if(triggerMainLevel0){
443 int npatchOnline = 0;
444 for(TIter patchIter = TIter(
fCaloTriggersOut).Begin(); patchIter != TIter::End(); ++patchIter){
447 AliDebug(1,Form(
"Patch with bits: %s, types: JH[%s], JL[%s], GH[%s], GL[%s], L0[%s]",
448 std::bitset<
sizeof(
int)*4>(mypatch->
GetTriggerBits()).to_string().c_str(),
453 AliDebug(1, Form(
"Number of online patches: %d", npatchOnline));
468 if (!isOfflineSimple)
474 for(
unsigned int ibit = 0; ibit <
sizeof(tBits)*8; ibit++) {
475 if(tBits & (1 << ibit)){
476 fQAHistos->FillTH1(
"triggerBitsAll", ibit);
494 Int_t globCol=-1, globRow=-1;
495 if (!isOfflineSimple)
503 AliDebug(1, Form(
"Jet patch in inactive area: row[%d]", globRow));
511 AliError(Form(
"Invalid patch position for patch type %s: Col[%d], Row[%d] - patch rejected",
fgkTriggerTypeNames[type].Data(), globCol, globRow));
518 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absId);
520 Int_t cellAbsId[4]={-1,-1,-1,-1};
521 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
525 fGeom->GetGlobal(cellAbsId[0], edge1);
526 Int_t colEdge1 = globCol, rowEdge1 = globRow, absIdEdge1 = absId, cellIdEdge1 = cellAbsId[0];
535 Double_t adcOfflineAmp = 0;
537 for (Int_t i = 0; i < nfastor; ++i) {
538 for (Int_t j = 0; j < nfastor; ++j) {
540 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol+i, globRow+j, absId);
541 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
543 for (Int_t k = 0; k < 4; ++k) {
544 Float_t ca =
fCaloCells->GetCellAmplitude(cellAbsId[k]);
547 cmiCol += ca*(Float_t)i;
548 cmiRow += ca*(Float_t)j;
554 adcAmp +=
fPatchADC[globCol+i][globRow+j];
562 AliDebug(2,
"EMCal trigger patch with 0 energy.");
569 Int_t cmCol = globCol + (Int_t)cmiCol;
570 Int_t cmRow = globRow + (Int_t)cmiRow;
573 fGeom->GetAbsFastORIndexFromPositionInEMCAL( cmCol, cmRow, absId );
574 fGeom->GetCellIndexFromFastORIndex( absId, cellAbsId );
577 Int_t cmiCellCol = TMath::Nint(cmiCol * 2.);
578 Int_t cmiCellRow = TMath::Nint(cmiRow * 2.);
580 fGeom->GetGlobal(cellAbsId[(cmiCellRow%2)*2 + cmiCellCol%2], centerMass);
601 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol+posOffset, globRow+posOffset, absId);
602 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
604 fGeom->GetGlobal(cellAbsId[3], edge2);
605 Int_t colEdge2 = globCol+posOffset, rowEdge2 = globRow+posOffset, absIdEdge2 = absId, cellIdEdge2 = cellAbsId[3];
626 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol+posOffset, globRow+posOffset, absId);
627 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
629 fGeom->GetGlobal(cellAbsId[3], center1);
644 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol+posOffset, globRow+posOffset, absId);
645 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
647 fGeom->GetGlobal(cellAbsId[0], center2);
649 TVector3 centerGeo(center1);
650 centerGeo += center2;
654 TVector3 edge1tmp = edge1, edge2tmp = edge2;
656 centerMass -= vertex;
660 if(!(edge1[0] || edge1[1] || edge1[2])){
661 AliWarning(Form(
"Inconsistency in patch position for edge1: [%f|%f|%f]", edge1[0], edge1[1], edge1[2]));
662 AliWarning(
"Original vectors:");
663 AliWarning(Form(
"edge1: [%f|%f|%f]", edge1tmp[0], edge1tmp[1], edge1tmp[2]));
664 AliWarning(Form(
"vertex: [%f|%f|%f]", vertex[0], vertex[1], vertex[2]));
665 AliWarning(Form(
"Col: %d, Row: %d, FABSID: %d, Cell: %d", colEdge1, rowEdge1, absIdEdge1, cellIdEdge1));
666 AliWarning(Form(
"Offline: %s", isOfflineSimple ?
"yes" :
"no"));
668 if(!(edge2[0] || edge2[1] || edge2[2])){
669 AliWarning(Form(
"Inconsistency in patch position for edge2: [%f|%f|%f]", edge2[0], edge2[1], edge2[2]));
670 AliWarning(
"Original vectors:");
671 AliWarning(Form(
"edge2: [%f|%f|%f]", edge2tmp[0], edge2tmp[1], edge2tmp[2]));
672 AliWarning(Form(
"vertex: [%f|%f|%f]", vertex[0], vertex[1], vertex[2]));
673 AliWarning(Form(
"Col: %d, Row: %d, FABSID: %d, Cell: %d", colEdge2, rowEdge2, absIdEdge2, cellIdEdge2));
674 AliWarning(Form(
"Offline: %s", isOfflineSimple ?
"yes" :
"no"));
677 Int_t isMC = MCEvent() ? 1 : 0;
721 TString patchtype = isOfflineSimple ?
"Offline" :
"Online";
726 for(
unsigned int ibit = 0; ibit <
sizeof(tBits)*8; ibit++) {
727 if(tBits & (1 << ibit)){
728 fQAHistos->FillTH1(
"triggerBitsSel", ibit);
746 TArrayI tBitsArray(4), rowArray(4), colArray(4);
766 Double_t maxPatchADCoffline = -1;
767 Int_t maxPatchADC = -1;
770 Int_t maxRow =
fGeom->GetNTotalTRU()*2;
774 int runnumber = InputEvent()->GetRunNumber();
775 if(runnumber > 139517 && runnumber <= 170593) maxRow = 60;
776 Int_t isMC = MCEvent() ? 1 : 0;
778 for (Int_t i = 0; i <= (maxCol-16); i += 4) {
779 for (Int_t j = 0; j <= (maxRow-16); j += 4) {
780 Double_t tSumOffline = 0;
784 for (Int_t k = 0; k < 16; ++k) {
785 for (Int_t l = 0; l < 16; ++l) {
791 if (tSum > maxPatchADC) {
797 if (tSumOffline > maxPatchADCoffline) {
798 maxPatchADCoffline = tSumOffline;
813 tBitsArray.Set( tBitsArray.GetSize() + 1 );
814 colArray.Set( colArray.GetSize() + 1 );
815 rowArray.Set( rowArray.GetSize() + 1 );
816 tBitsArray[tBitsArray.GetSize()-1] = tBits;
817 colArray[colArray.GetSize()-1] = i;
818 rowArray[rowArray.GetSize()-1] = j;
825 maxPatchADCoffline = -1;
827 for (Int_t i = 0; i <= (maxCol-2); ++i) {
828 for (Int_t j = 0; j <= (maxRow-2); ++j) {
830 Double_t tSumOffline = 0;
834 for (Int_t k = 0; k < 2; ++k) {
835 for (Int_t l = 0; l < 2; ++l) {
841 if (tSum > maxPatchADC) {
846 if (tSumOffline > maxPatchADCoffline) {
847 maxPatchADCoffline = tSumOffline;
862 tBitsArray.Set( tBitsArray.GetSize() + 1 );
863 colArray.Set( colArray.GetSize() + 1 );
864 rowArray.Set( rowArray.GetSize() + 1 );
865 tBitsArray[tBitsArray.GetSize()-1] = tBits;
866 colArray[colArray.GetSize()-1] = i;
867 rowArray[rowArray.GetSize()-1] = j;
875 for (Int_t i = 0; i < tBitsArray.GetSize(); ++i){
888 isOfflineSimple = kFALSE;
892 isOfflineSimple = kTRUE;
904 Int_t row(-1), col(-1); trg.GetPosition(col, row);
905 if(col < 0 || row < 0){
906 AliError(Form(
"Patch outside range [col %d, row %d]", col, row));
909 Int_t truref(-1), trumod(-1), absFastor(-1), adc(-1);
910 fGeom->GetAbsFastORIndexFromPositionInEMCAL(col, row, absFastor);
911 fGeom->GetTRUFromAbsFastORIndex(absFastor, truref, adc);
913 for(
int ipos = 0; ipos < 2; ipos++){
915 for(
int jpos = 0; jpos < 2; jpos++){
919 fGeom->GetAbsFastORIndexFromPositionInEMCAL(col+jpos, row+ipos, absFastor);
920 fGeom->GetTRUFromAbsFastORIndex(absFastor, trumod, adc);
921 if(trumod != truref)
continue;
922 if(col + jpos >=
kPatchCols) AliError(Form(
"Boundary error in col [%d, %d + %d]", col + jpos, col, jpos));
923 if(row + ipos >=
kPatchRows) AliError(Form(
"Boundary error in row [%d, %d + %d]", row + ipos, row, ipos));
925 if(l0times > 7 && l0times < 10) nvalid++;
928 if (nvalid != 4)
return false;
951 if(fChannels.FindObject(&refChannel))
return true;
Bool_t fRejectOffAcceptancePatches
Int_t GetThresholdJetHighSimple() const
Int_t GetTriggerBits() const
Int_t GetThresholdGammaHighSimple() const
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
void SetTriggerBits(Int_t i)
TString fCaloTriggersOutName
name of output track array
Class to make array of trigger patch objects in AOD/ESD events.
void AddChannel(int col, int row)
Old configuration, no distinction between high and low threshold.
void SetEdge2(TLorentzVector &v)
TriggerMakerBitConfig_t fUseTriggerBitConfig
type of trigger config
TriggerMakerTriggerType_t
Definition of different trigger patch types.
Bool_t fDoQA
Fill QA histograms.
void SetEdge1(TLorentzVector &v)
const AliEmcalTriggerBitConfig * fTriggerBitConfig
Bool_t IsGammaLow() const
Int_t fITrigger
trigger counter
void UserCreateOutputObjects()
TList * fOutput
x-section from pythia header
Float_t fPatchAmplitudes[kPatchCols][kPatchRows]
TRU Amplitudes (for L0)
AliEmcalTriggerChannelContainer fBadChannels
Container of bad channels.
Int_t GetJetLowBit() const
Int_t GetLevel0Bit() const
void SetADCOfflineAmp(Int_t a)
Int_t GetThresholdGammaLowSimple() const
New configuration, distiction between high and low threshold.
static const TString fgkTriggerTypeNames[5]
Histogram name tags.
2D position of a trigger channel on the EMCAL surface
Bool_t IsEGA(Int_t tBits) const
AliEMCALGeometry * fGeom
whether it's an ESD analysis
Int_t fPatchADC[kPatchCols][kPatchRows]
ADC values map.
TString fCaloTriggersName
bool HasChannel(int col, int row)
Int_t GetGammaLowBit() const
Bool_t IsGammaHigh() const
Int_t fThresholdConstants[4][3]
simple offline trigger thresholds constants
Bool_t IsEJE(Int_t tBits) const
Int_t GetThresholdJetLowSimple() const
void SetEdgeCell(Int_t x, Int_t y)
TString fV0InName
name of output track array
EMCAL Jet patches, recalculated.
Double_t GetPatchE() const
AliEmcalTriggerSetupInfo * fCaloTriggerSetupOut
trigger setup
Int_t GetTriggerTypesEnd() const
Double_t fPatchADCSimple[kPatchCols][kPatchRows]
patch map for simple offline trigger
AliVCaloCells * fCaloCells
clusters
AliVVZERO * fV0
V0 object.
AliAODCaloTrigger * fSimpleOfflineTriggers
simple offline trigger
EMCAL trigger patch maker.
TClonesArray * fCaloTriggersOut
trigger array out
void SetCenterMass(TLorentzVector &v)
THistManager * fQAHistos
Histograms for QA.
Int_t GetJetHighBit() const
Double_t fVertex[3]
event plane V0C
static const Double_t kEMCL1ADCtoGeV
void SetTriggerBitConfig(const AliEmcalTriggerBitConfig *ref)
EMCAL Gamma patches, recalculated.
Int_t GetRunNumber(TString)
Char_t fLevel0TimeMap[kPatchCols][kPatchRows]
Map needed to store the level0 times.
AliVCaloTrigger * fCaloTriggers
cells
void UserCreateOutputObjects()
Bool_t fRunTriggerType[5]
Run patch maker for a given trigger type.
void RunSimpleOfflineTrigger()
TString fCaloTriggerSetupOutName
name of output track array
void SetThresholdsSimple(Int_t i0, Int_t i1, Int_t i2, Int_t i3)
AliEmcalTriggerPatchInfo * ProcessPatch(TriggerMakerTriggerType_t type, Bool_t isOfflineSimple)
Bool_t NextTrigger(Bool_t &isOfflineSimple)
void SetCenterGeo(TVector3 &v, Double_t e)
virtual ~AliEmcalTriggerMaker()
TSortedList fChannels
Container for listed channels.
void SetThresholds(Int_t i0, Int_t i1, Int_t i2, Int_t i3)
Bool_t CheckForL0(const AliVCaloTrigger &trg) const
Bool_t IsOfflineSimple() const
Int_t GetGammaHighBit() const