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 Int_t runno = InputEvent()->GetRunNumber();
504 if(runno > 176000 && runno <= 197692){
507 AliDebug(1, Form(
"Jet patch in inactive area: row[%d]", globRow));
516 AliError(Form(
"Invalid patch position for patch type %s: Col[%d], Row[%d] - patch rejected",
fgkTriggerTypeNames[type].
Data(), globCol, globRow));
523 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, absId);
525 Int_t cellAbsId[4]={-1,-1,-1,-1};
526 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
530 fGeom->GetGlobal(cellAbsId[0], edge1);
531 Int_t colEdge1 = globCol, rowEdge1 = globRow, absIdEdge1 = absId, cellIdEdge1 = cellAbsId[0];
540 Double_t adcOfflineAmp = 0;
542 for (Int_t i = 0; i < nfastor; ++i) {
543 for (Int_t j = 0; j < nfastor; ++j) {
545 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol+i, globRow+j, absId);
546 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
548 for (Int_t k = 0; k < 4; ++k) {
549 Float_t ca =
fCaloCells->GetCellAmplitude(cellAbsId[k]);
552 cmiCol += ca*(Float_t)i;
553 cmiRow += ca*(Float_t)j;
559 adcAmp +=
fPatchADC[globCol+i][globRow+j];
567 AliDebug(2,
"EMCal trigger patch with 0 energy.");
574 Int_t cmCol = globCol + (Int_t)cmiCol;
575 Int_t cmRow = globRow + (Int_t)cmiRow;
578 fGeom->GetAbsFastORIndexFromPositionInEMCAL( cmCol, cmRow, absId );
579 fGeom->GetCellIndexFromFastORIndex( absId, cellAbsId );
582 Int_t cmiCellCol = TMath::Nint(cmiCol * 2.);
583 Int_t cmiCellRow = TMath::Nint(cmiRow * 2.);
585 fGeom->GetGlobal(cellAbsId[(cmiCellRow%2)*2 + cmiCellCol%2], centerMass);
606 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol+posOffset, globRow+posOffset, absId);
607 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
609 fGeom->GetGlobal(cellAbsId[3], edge2);
610 Int_t colEdge2 = globCol+posOffset, rowEdge2 = globRow+posOffset, absIdEdge2 = absId, cellIdEdge2 = cellAbsId[3];
631 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol+posOffset, globRow+posOffset, absId);
632 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
634 fGeom->GetGlobal(cellAbsId[3], center1);
649 fGeom->GetAbsFastORIndexFromPositionInEMCAL(globCol+posOffset, globRow+posOffset, absId);
650 fGeom->GetCellIndexFromFastORIndex(absId, cellAbsId);
652 fGeom->GetGlobal(cellAbsId[0], center2);
654 TVector3 centerGeo(center1);
655 centerGeo += center2;
659 TVector3 edge1tmp = edge1, edge2tmp = edge2;
661 centerMass -= vertex;
665 if(!(edge1[0] || edge1[1] || edge1[2])){
666 AliWarning(Form(
"Inconsistency in patch position for edge1: [%f|%f|%f]", edge1[0], edge1[1], edge1[2]));
667 AliWarning(
"Original vectors:");
668 AliWarning(Form(
"edge1: [%f|%f|%f]", edge1tmp[0], edge1tmp[1], edge1tmp[2]));
669 AliWarning(Form(
"vertex: [%f|%f|%f]", vertex[0], vertex[1], vertex[2]));
670 AliWarning(Form(
"Col: %d, Row: %d, FABSID: %d, Cell: %d", colEdge1, rowEdge1, absIdEdge1, cellIdEdge1));
671 AliWarning(Form(
"Offline: %s", isOfflineSimple ?
"yes" :
"no"));
673 if(!(edge2[0] || edge2[1] || edge2[2])){
674 AliWarning(Form(
"Inconsistency in patch position for edge2: [%f|%f|%f]", edge2[0], edge2[1], edge2[2]));
675 AliWarning(
"Original vectors:");
676 AliWarning(Form(
"edge2: [%f|%f|%f]", edge2tmp[0], edge2tmp[1], edge2tmp[2]));
677 AliWarning(Form(
"vertex: [%f|%f|%f]", vertex[0], vertex[1], vertex[2]));
678 AliWarning(Form(
"Col: %d, Row: %d, FABSID: %d, Cell: %d", colEdge2, rowEdge2, absIdEdge2, cellIdEdge2));
679 AliWarning(Form(
"Offline: %s", isOfflineSimple ?
"yes" :
"no"));
682 Int_t
isMC = MCEvent() ? 1 : 0;
726 TString patchtype = isOfflineSimple ?
"Offline" :
"Online";
731 for(
unsigned int ibit = 0; ibit <
sizeof(tBits)*8; ibit++) {
732 if(tBits & (1 << ibit)){
733 fQAHistos->FillTH1(
"triggerBitsSel", ibit);
751 TArrayI tBitsArray(4), rowArray(4), colArray(4);
771 Double_t maxPatchADCoffline = -1;
772 Int_t maxPatchADC = -1;
775 Int_t maxRow =
fGeom->GetNTotalTRU()*2;
779 int runnumber = InputEvent()->GetRunNumber();
780 if(runnumber > 139517 && runnumber <= 170593) maxRow = 60;
781 Int_t
isMC = MCEvent() ? 1 : 0;
783 for (Int_t i = 0; i <= (maxCol-16); i += 4) {
784 for (Int_t j = 0; j <= (maxRow-16); j += 4) {
785 Double_t tSumOffline = 0;
789 for (Int_t k = 0; k < 16; ++k) {
790 for (Int_t l = 0; l < 16; ++l) {
796 if (tSum > maxPatchADC) {
802 if (tSumOffline > maxPatchADCoffline) {
803 maxPatchADCoffline = tSumOffline;
818 tBitsArray.Set( tBitsArray.GetSize() + 1 );
819 colArray.Set( colArray.GetSize() + 1 );
820 rowArray.Set( rowArray.GetSize() + 1 );
821 tBitsArray[tBitsArray.GetSize()-1] = tBits;
822 colArray[colArray.GetSize()-1] = i;
823 rowArray[rowArray.GetSize()-1] = j;
830 maxPatchADCoffline = -1;
832 for (Int_t i = 0; i <= (maxCol-2); ++i) {
833 for (Int_t j = 0; j <= (maxRow-2); ++j) {
835 Double_t tSumOffline = 0;
839 for (Int_t k = 0; k < 2; ++k) {
840 for (Int_t l = 0; l < 2; ++l) {
846 if (tSum > maxPatchADC) {
851 if (tSumOffline > maxPatchADCoffline) {
852 maxPatchADCoffline = tSumOffline;
867 tBitsArray.Set( tBitsArray.GetSize() + 1 );
868 colArray.Set( colArray.GetSize() + 1 );
869 rowArray.Set( rowArray.GetSize() + 1 );
870 tBitsArray[tBitsArray.GetSize()-1] = tBits;
871 colArray[colArray.GetSize()-1] = i;
872 rowArray[rowArray.GetSize()-1] = j;
880 for (Int_t i = 0; i < tBitsArray.GetSize(); ++i){
893 isOfflineSimple = kFALSE;
897 isOfflineSimple = kTRUE;
909 Int_t row(-1), col(-1); trg.GetPosition(col, row);
910 if(col < 0 || row < 0){
911 AliError(Form(
"Patch outside range [col %d, row %d]", col, row));
914 Int_t truref(-1), trumod(-1), absFastor(-1), adc(-1);
915 fGeom->GetAbsFastORIndexFromPositionInEMCAL(col, row, absFastor);
916 fGeom->GetTRUFromAbsFastORIndex(absFastor, truref, adc);
918 for(
int ipos = 0; ipos < 2; ipos++){
920 for(
int jpos = 0; jpos < 2; jpos++){
924 fGeom->GetAbsFastORIndexFromPositionInEMCAL(col+jpos, row+ipos, absFastor);
925 fGeom->GetTRUFromAbsFastORIndex(absFastor, trumod, adc);
926 if(trumod != truref)
continue;
927 if(col + jpos >=
kPatchCols) AliError(Form(
"Boundary error in col [%d, %d + %d]", col + jpos, col, jpos));
928 if(row + ipos >=
kPatchRows) AliError(Form(
"Boundary error in row [%d, %d + %d]", row + ipos, row, ipos));
930 if(l0times > 7 && l0times < 10) nvalid++;
933 if (nvalid != 4)
return false;
956 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
Trigger bit for recalculated jet patches.
Trigger bit indicating the main (highest energy) trigger patch of a given type per event...
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
Trigger bit for recalculated gamma patches.
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
Trigger bit indicating that the patch was created by the offline trigger algorithm.
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
Main data structure storing all relevant information of EMCAL/DCAL trigger patches.
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
Definition of old trigger bit configuration.
Definition of new trigger bit configuration.
Manager for constants used in the trigger maker.
AliEmcalTriggerSetupInfo * fCaloTriggerSetupOut
trigger setup
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
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
Conversion from EMCAL Level1 ADC to energy.
void SetTriggerBitConfig(const AliEmcalTriggerBitConfig *ref)
EMCAL Gamma patches, recalculated.
Class to make array of trigger patch objects in AOD/ESD events.
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
Settings manager for the trigger patch algorithm.
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