15 #include <TClonesArray.h>
17 #include <THashList.h>
19 #include <TObjArray.h>
20 #include <TParameter.h>
21 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,8,0)
22 #include <ROOT/TSeq.hxx>
25 #include "AliCDBEntry.h"
26 #include "AliCDBManager.h"
27 #include "AliEMCALGeometry.h"
28 #include "AliEMCALTriggerBitConfig.h"
29 #include "AliEMCALTriggerDCSConfig.h"
30 #include "AliEMCALTriggerTRUDCSConfig.h"
31 #include "AliEMCALTriggerPatchInfo.h"
34 #include "AliEMCALTriggerMapping.h"
36 #include "AliOADBContainer.h"
54 fCaloTriggersOutName("EmcalTriggers"),
55 fV0InName("AliAODVZERO"),
56 fBadFEEChannelOADB(""),
57 fMaskedFastorOADB(""),
58 fUseL0Amplitudes(kFALSE),
59 fLoadFastORMaskingFromOCDB(kFALSE),
71 fCaloTriggersOutName(
"EmcalTriggers"),
72 fV0InName(
"AliAODVZERO"),
73 fBadFEEChannelOADB(
""),
74 fMaskedFastorOADB(
""),
75 fUseL0Amplitudes(kFALSE),
76 fLoadFastORMaskingFromOCDB(kFALSE),
77 fCaloTriggersOut(NULL),
93 const std::array<const TString, 3> kTriggerTypeNames = {
"EJE",
"EGA",
"EL0"},
94 kPatchTypes = {
"Online",
"Offline",
"Recalc"};
96 if(
fDoQA) AliInfoStream() <<
"Trigger maker - QA requested" << std::endl;
97 else AliInfoStream() <<
"Trigger maker - no QA requested" << std::endl;
98 if(!
fOutput) AliErrorStream() <<
"No output container initialized" << std::endl;
102 AliInfoStream() <<
"Enabling QA for trigger maker" << std::endl;
105 for(
const auto &triggertype : kTriggerTypeNames){
106 for(
const auto &patchtype : kPatchTypes){
108 "RCPos" + triggertype + patchtype,
109 "Lower edge position of " + patchtype +
" " + triggertype +
" patches (col-row);iEta;iPhi",
110 48, -0.5, 47.5, 104, -0.5, 103.5
113 "EPCentPos" + triggertype + patchtype,
114 "Center position of the " + patchtype +
" " + triggertype +
" trigger patches;#eta;#phi",
115 20, -0.8, 0.8, 700, 0., 7.
118 "PatchADCvsE" + triggertype + patchtype,
119 "Patch ADC value for trigger type " + patchtype +
" " + triggertype +
"; Trigger ADC; FEE patch energy (GeV)",
120 2000, 0., 2000, 200, 0., 200
123 "PatchEvsEsmear" + triggertype + patchtype,
124 "Patch energy vs. smeared energy for " + patchtype +
" " + triggertype +
"; FEE patch energy (GeV); smeared FEE energy (GeV)",
125 200, 0., 200, 200, 0., 200
128 "PatchADCvsEsmear" + triggertype + patchtype,
129 "Patch ADC vs. smeared energy for " + patchtype +
" " + triggertype +
"; Trigger ADC; smeared FEE energy (GeV)",
130 2000, 0., 2000, 200, 0., 200
133 "PatchADCOffvsE" + triggertype + patchtype,
134 "Patch offline ADC value for trigger type " + patchtype +
" " + triggertype +
"; Trigger ADC; FEE patch energy (GeV)",
135 2000, 0., 2000, 200, 0., 200
138 "PatchEvsADCrough" + triggertype + patchtype,
139 "Patch Energy vs. ADC rough for trigger type " + patchtype +
" " + triggertype +
"; FEE patch energy (GeV); ADC rough (GeV)",
140 2000, 0., 2000, 200, 0., 200
144 fQAHistos->
CreateTH1(
"triggerBitsAll",
"Trigger bits for all incoming patches;bit nr", 64, -0.5, 63.5);
145 fQAHistos->
CreateTH1(
"triggerBitsSel",
"Trigger bits for reconstructed patches;bit nr", 64, -0.5, 63.5);
146 fQAHistos->
CreateTH2(
"FastORMaskOnline",
"Masked FastORs at online level; col; row", 48, -0.5, 47.5, 104, -0.5, 103.5);
149 fQAHistos->
CreateTH2(
"FastORCorrEnergyADCrough",
"FastOR cell energy vs. ADC energy", 200, 0., 20., 200, 0., 20.);
150 fQAHistos->
CreateTH2(
"FastORCorrEnergyESmear",
"FastOR cell energy vs. smeared energy", 200, 0., 20., 200, 0., 20.);
151 fQAHistos->
CreateTH2(
"FastORCorrADCroughEsmear",
"FastOR ADC rough vs. smeared energy", 200, 0., 20., 200, 0., 20.);
152 fQAHistos->
CreateTH2(
"FastORDiffEnergyADCrough",
"FastOR ADCrough - cell energy", 4994, -0.5, 4993.5, 200, -10., 10);
153 fQAHistos->
CreateTH2(
"FastORDiffEnergyEsmear",
"FastOR smeared energy - cell energy", 4994, -0.5, 4993.5, 200, -10., 10);
154 fQAHistos->
CreateTH2(
"FastORDiffEsmearADCrough",
"FastOR ADC rough - smeared energy", 4994, -0.5, 4993.5, 200, -10., 10);
159 AliWarningStream() <<
"QA requested but no output container initialized - QA needs to be disabled" << std::endl;
167 AliEMCALTriggerBitConfig *triggerBitConfig(NULL);
170 triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
173 triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
192 AliFatal(Form(
"%s: Container with same name %s already present. Aborting", GetName(),
fCaloTriggersOutName.Data()));
198 fV0 = (AliVVZERO*)InputEvent()->FindListObject(
fV0InName);
203 AliInfoStream() <<
"Trigger maker not yet configure - automatically configuring ..." << std::endl;
204 int runnumber = InputEvent()->GetRunNumber();
205 std::string dataset =
"";
206 if(runnumber >= 145144 && runnumber <= 165746){
209 }
else if(runnumber >= 167806 && runnumber <= 170593){
211 dataset =
"Pb-Pb 2011";
212 }
else if(runnumber >= 176326 && runnumber <= 193766){
215 }
else if(runnumber >= 195344 && runnumber <= 197692){
218 dataset =
"p-Pb 2013";
219 }
else if((runnumber >= 224891 && runnumber <= 244628) || runnumber >= 253434){
222 dataset =
"pp 2015-2016";
223 }
else if(runnumber >= 244824 && runnumber <= 246994){
225 dataset =
"Pb-Pb 2015";
229 AliInfoStream() <<
"Applying configuration for " << dataset << std::endl;
231 AliErrorStream() <<
"No valid configuration found for the given dataset - trigger maker disabled" << std::endl;
257 double ecell, eadc, esmear;
259 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,8,0)
261 for(
auto icol : ROOT::TSeqI(0, 48)){
265 for(
int icol = 0; icol < 48; icol++){
271 fGeom->GetTriggerMapping()->GetAbsFastORIndexFromPositionInEMCAL(icol, irow, fastORAbsID);
273 if(TMath::Abs(ecell) > DBL_EPSILON || TMath::Abs(eadc) > DBL_EPSILON){
277 if(TMath::Abs(ecell) > DBL_EPSILON || TMath::Abs(esmear) > DBL_EPSILON){
281 if(TMath::Abs(eadc) > DBL_EPSILON || TMath::Abs(esmear) > DBL_EPSILON){
289 std::vector<AliEMCALTriggerPatchInfo> patches;
291 Int_t patchcounter = 0;
293 AliDebugStream(2) << GetName() <<
": Found " << patches.size() <<
" patches" << std::endl;
294 for(
const auto &patchIter : patches){
296 AliDebugStream(3) << GetName() <<
": Next patch: size " << patchIter.GetPatchSize() <<
" , trigger bits " << std::bitset<sizeof(Int_t)*8>(patchIter.GetTriggerBits()) << std::endl;
298 if(patchIter.IsJetHigh() || patchIter.IsJetLow())
FillQAHistos(
"EJEOnline", patchIter);
299 if(patchIter.IsGammaHigh() || patchIter.IsGammaLow())
FillQAHistos(
"EGAOnline", patchIter);
300 if(patchIter.IsJetHighSimple() || patchIter.IsJetLowSimple())
FillQAHistos(
"EJEOffline", patchIter);
301 if(patchIter.IsGammaHighSimple() || patchIter.IsGammaLowSimple())
FillQAHistos(
"EGAOffline", patchIter);
302 if(patchIter.IsLevel0())
FillQAHistos(
"EL0Online", patchIter);
303 if(patchIter.IsRecalcJet())
FillQAHistos(
"EJERecalc", patchIter);
304 if(patchIter.IsRecalcGamma())
FillQAHistos(
"EGARecalc", patchIter);
306 int tBits = patchIter.GetTriggerBits();
307 for(
unsigned int ibit = 0; ibit <
sizeof(tBits)*8; ibit++) {
308 if(tBits & (1 << ibit)){
313 new((*fCaloTriggersOut)[patchcounter++]) AliEMCALTriggerPatchInfo(patchIter);
319 AliDebugStream(1) <<
"Run changed, new run " << newrun << std::endl;
327 Int_t globCol(-1), globRow(-1) ;
329 fGeom->GetTriggerMapping()->GetPositionInEMCALFromAbsFastORIndex(ifastOrID, globCol, globRow);
336 AliInfoStream() <<
"Loading additional bad FEE channels from OADB container " <<
fBadFEEChannelOADB << std::endl;
339 AliOADBContainer badchannelDB(
"EmcalBadChannelsAdditional");
342 if(!badchannelmap || !badchannelmap->GetEntries())
return;
343 for(TIter citer = TIter(badchannelmap).Begin(); citer != TIter::End(); ++citer){
350 AliInfoStream() <<
"Loading masked fastors from OCDB" << std::endl;
351 AliCDBManager *cdb = AliCDBManager::Instance();
353 AliCDBEntry *en = cdb->Get(
"EMCAL/Calib/Trigger");
355 AliErrorStream() << GetName() <<
": FastOR masking from CDB required, but OCDB entry is not available. No masking will be applied." << std::endl;
359 AliEMCALTriggerDCSConfig *trgconf =
dynamic_cast<AliEMCALTriggerDCSConfig *
>(en->GetObject());
361 AliErrorStream() << GetName() <<
": Failed decoding OCDB entry: Object is not of type AliEMCALTriggerDCSConfig." << std::endl;
369 Int_t fastOrAbsID(-1), ic(-1);
370 for(
int itru = 0; itru < trgconf->GetTRUArr()->GetEntries(); itru++){
371 AliEMCALTriggerTRUDCSConfig *truconf = trgconf->GetTRUDCSConfig(itru);
380 for(
unsigned int ifield = 0; ifield < 6; ifield++){
381 for(
unsigned int ibit = 0; ibit < 16; ibit ++){
382 if((truconf->GetMaskReg(ifield) >> ibit) & 0x1){
384 fGeom->GetTriggerMapping()->GetAbsFastORIndexFromTRU(itru, (ic =
GetMaskHandler()(ifield, ibit)), fastOrAbsID);
385 AliDebugStream(1) << GetName() <<
"Channel " << ic <<
" in TRU " << itru <<
" ( abs fastor " << fastOrAbsID <<
") masked." << std::endl;
388 AliErrorStream() << GetName() <<
"Invalid mask: (" << ifield <<
"|" << ibit <<
"), exception " << exept <<
" thrown. Mask will not be recognized" << std::endl;
397 AliInfoStream() <<
"Initializing masked fastors from OADB container " <<
fMaskedFastorOADB.Data() << std::endl;
399 AliOADBContainer badchannelDB(
"AliEmcalMaskedFastors");
402 if(!badchannelmap || !badchannelmap->GetEntries())
return;
403 for(TIter citer = TIter(badchannelmap).Begin(); citer != TIter::End(); ++citer){
405 AliDebugStream(1) << GetName() <<
": Found masked fastor channel " << channelID->GetVal() << std::endl;
412 if(
fGeom->GetTriggerMappingVersion() == 2){
414 return [] (
unsigned int ifield,
unsigned int ibit) ->
int {
416 const int kChannelMap[6][16] = {{ 8, 9,10,11,20,21,22,23,32,33,34,35,44,45,46,47},
417 {56,57,58,59,68,69,70,71,80,81,82,83,92,93,94,95},
418 { 4, 5, 6, 7,16,17,18,19,28,29,30,31,40,41,42,43},
419 {52,53,54,55,64,65,66,67,76,77,78,79,88,89,90,91},
420 { 0, 1, 2, 3,12,13,14,15,24,25,26,27,36,37,38,39},
421 {48,49,50,51,60,61,62,63,72,73,74,75,84,85,86,87}};
422 return kChannelMap[ifield][ibit];
426 return [] (
int ifield,
int ibit) ->
int {
428 return ifield * 16 + ibit;
434 fQAHistos->
FillTH2(
"RCPos" + patchtype, recpatch.GetColStart(), recpatch.GetRowStart());
435 fQAHistos->
FillTH2(
"EPCentPos" + patchtype, recpatch.GetEtaGeo(), recpatch.GetPhiGeo());
436 fQAHistos->
FillTH2(
"PatchADCvsE" + patchtype, recpatch.GetADCAmp(), recpatch.GetPatchE());
437 fQAHistos->
FillTH2(
"PatchEvsEsmear" + patchtype, recpatch.GetPatchE(), recpatch.GetSmearedEnergy());
438 fQAHistos->
FillTH2(
"PatchADCvsEsmear" + patchtype, recpatch.GetADCAmp(), recpatch.GetSmearedEnergy());
439 fQAHistos->
FillTH2(
"PatchADCOffvsE" + patchtype, recpatch.GetADCOfflineAmp(), recpatch.GetPatchE());
440 fQAHistos->
FillTH2(
"PatchEvsADCrough" + patchtype, recpatch.GetPatchE(), recpatch.GetADCAmpGeVRough());
AliVVZERO * fV0
! VZERO data
AliEmcalTriggerMakerTask()
Dummy constructor.
void Reset()
Reset all data grids and VZERO-dependent L1 thresholds.
New configuration, distinction between high and low threshold.
void InitializeBadFEEChannels()
Initialize bad channels from the OADB container.
virtual void ExecOnce()
Initialize the trigger maker kernel.
void ConfigureForPbPb2015()
Configure the class for 2015 PbPb.
Base task in the EMCAL framework.
Bool_t fLocalInitialized
whether or not the task has been already initialized
virtual Bool_t Run()
Run trigger patch finding.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
void InitializeFastORMaskingFromOADB()
Initialize the FastOR masking from the OADB.
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 fUseL0Amplitudes
Use L0 amplitudes instead of L1 time sum (useful for runs where STU was not read) ...
virtual void UserCreateOutputObjects()
Initializing output objects.
void Init()
Initialize the trigger maker Kernel.
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 SetIsMC(Bool_t isMC)
Define whether running on MC or not (for offset)
void ConfigureForPP2011()
Configure the class for 2011 pp.
Bool_t fLoadFastORMaskingFromOCDB
Load FastOR masking from the OCDB.
void ReadTriggerData(AliVCaloTrigger *trigger)
Read the calo trigger data.
virtual ~AliEmcalTriggerMakerTask()
Destructor.
TString fV0InName
name of output track array
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
Old configuration, no distinction between high and low threshold.
void ConfigureForPP2012()
Configure the class for 2012 pp.
THashList * GetListOfHistograms() const
Get the list of histograms.
AliEMCALGeometry * fGeom
!emcal geometry
void SetUseTriggerBitConfig(TriggerMakerBitConfig_t bitConfig)
Trigger bit configuration to be used in the trigger patch maker.
AliEmcalTriggerMakerKernel * fTriggerMaker
The actual trigger maker kernel.
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
void AddOfflineBadChannel(Short_t absId)
Add an offline bad channel to the set.
EMCAL trigger maker task.
double GetTriggerChannelEnergy(Int_t col, Int_t row) const
Get energy of the trigger channel estimated from cells (in col-row space)
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
const std::set< Short_t > & GetListOfBadFastORAbsIDs() const
Get the list of online masked FastOR's used in the trigger maker.
AliVCaloCells * fCaloCells
!cells
void BuildL1ThresholdsOffline(const AliVVZERO *vzdata)
Build VZERO-dependent thresholds for the offline trigger.
ClassImp(AliAnalysisTaskDeltaPt) AliAnalysisTaskDeltaPt
std::function< int(unsigned int, unsigned int)> GetMaskHandler() const
AliEmcalList * fOutput
!output list
void SetGeometry(const AliEMCALGeometry *const geo)
Provide the EMCAL geometry to the trigger maker Kernel.
virtual void RunChanged(Int_t newrun)
RunChanged method of the trigger maker.
void FillQAHistos(const TString &patchtype, const AliEMCALTriggerPatchInfo &recpatch)
Internal QA handler for trigger pathches of given type.
TString fBadFEEChannelOADB
name of the OADB container containing channels to be masked inside the trigger maker ...
TString fCaloTriggersOutName
name of output track array
TClonesArray * fCaloTriggersOut
! trigger array out
void ClearOfflineBadChannels()
Clear offline bad channel list.
double GetTriggerChannelEnergyRough(Int_t col, Int_t row) const
Get estimated energy of the trigger channel based on ADC measurement (in col-row space) ...
Container class for histograms.
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...
Kernel of the EMCAL trigger patch maker.
TString fMaskedFastorOADB
name of the OADB container containing fastors to be masked inside the trigger maker ...
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
Int_t GetRunNumber(TString)
AliVCaloTrigger * fCaloTriggers
!calo triggers
void UserCreateOutputObjects()
Main initialization function on the worker.
void InitializeFastORMaskingFromOCDB()
Initialize the FastOR masking from the OCDB.
Bool_t IsConfigured() const
THistManager * fQAHistos
! Histograms for QA
double GetDataGridDimensionRows() const
Get the dimension of the underlying data grids in row direction.
Bool_t fDoQA
Fill QA histograms.
void ReadCellData(AliVCaloCells *cells)
Read the EMCAL cell data.
void ConfigureForPPb2013()
Configure the class for 2013 pPb.