15 #include <TClonesArray.h>
17 #include <THashList.h>
19 #include <TObjArray.h>
20 #include <TParameter.h>
22 #include "AliCDBEntry.h"
23 #include "AliCDBManager.h"
24 #include "AliEMCALGeometry.h"
25 #include "AliEMCALTriggerBitConfig.h"
26 #include "AliEMCALTriggerDCSConfig.h"
27 #include "AliEMCALTriggerTRUDCSConfig.h"
28 #include "AliEMCALTriggerPatchInfo.h"
31 #include "AliEMCALTriggerMapping.h"
33 #include "AliOADBContainer.h"
48 fCaloTriggersOutName("EmcalTriggers"),
49 fV0InName("AliAODVZERO"),
50 fBadFEEChannelOADB(""),
51 fMaskedFastorOADB(""),
52 fUseL0Amplitudes(kFALSE),
53 fLoadFastORMaskingFromOCDB(kFALSE),
65 fCaloTriggersOutName(
"EmcalTriggers"),
66 fV0InName(
"AliAODVZERO"),
67 fBadFEEChannelOADB(
""),
68 fMaskedFastorOADB(
""),
69 fUseL0Amplitudes(kFALSE),
70 fLoadFastORMaskingFromOCDB(kFALSE),
71 fCaloTriggersOut(NULL),
87 const TString kTriggerTypeNames[3] = {
"EJE",
"EGA",
"EL0"},
88 kPatchTypes[3] = {
"Online",
"Offline",
"Recalc"};
90 if(
fDoQA) std::cout <<
"Trigger maker - QA requested" << std::endl;
91 else std::cout <<
"Trigger maker - no QA requested" << std::endl;
92 if(!
fOutput) std::cout <<
"No output container initialized" << std::endl;
96 AliInfoStream() <<
"Enabling QA for trigger maker" << std::endl;
99 for(
const TString *triggertype = kTriggerTypeNames; triggertype < kTriggerTypeNames +
sizeof(kTriggerTypeNames)/
sizeof(
TString); triggertype++){
100 for(
const TString *patchtype = kPatchTypes; patchtype < kPatchTypes +
sizeof(kPatchTypes)/
sizeof(
TString); ++patchtype){
102 Form(
"RCPos%s%s", triggertype->Data(), patchtype->Data()),
103 Form(
"Lower edge position of %s %s patches (col-row);iEta;iPhi", patchtype->Data(), triggertype->Data()),
104 48, -0.5, 47.5, 104, -0.5, 103.5
107 Form(
"EPCentPos%s%s", triggertype->Data(), patchtype->Data()),
108 Form(
"Center position of the %s %s trigger patches;#eta;#phi", patchtype->Data(), triggertype->Data()),
109 20, -0.8, 0.8, 700, 0., 7.
112 Form(
"PatchADCvsE%s%s", triggertype->Data(), patchtype->Data()),
113 Form(
"Patch ADC value for trigger type %s %s;Trigger ADC;FEE patch energy (GeV)", patchtype->Data(), triggertype->Data()),
114 2000, 0., 2000, 200, 0., 200
117 Form(
"PatchADCOffvsE%s%s", triggertype->Data(), patchtype->Data()),
118 Form(
"Patch offline ADC value for trigger type %s %s;Trigger ADC;FEE patch energy (GeV)", patchtype->Data(), triggertype->Data()),
119 2000, 0., 2000, 200, 0., 200
123 fQAHistos->
CreateTH1(
"triggerBitsAll",
"Trigger bits for all incoming patches;bit nr", 64, -0.5, 63.5);
124 fQAHistos->
CreateTH1(
"triggerBitsSel",
"Trigger bits for reconstructed patches;bit nr", 64, -0.5, 63.5);
125 fQAHistos->
CreateTH2(
"FastORMaskOnline",
"Masked FastORs at online level; col; row", 48, -0.5, 47.5, 104, -0.5, 103.5);
129 AliWarningStream() <<
"QA requested but no output container initialized - QA needs to be disabled" << std::endl;
137 AliEMCALTriggerBitConfig *triggerBitConfig(NULL);
140 triggerBitConfig =
new AliEMCALTriggerBitConfigNew();
143 triggerBitConfig =
new AliEMCALTriggerBitConfigOld();
166 AliFatal(Form(
"%s: Container with same name %s already present. Aborting", GetName(),
fCaloTriggersOutName.Data()));
172 fV0 = (AliVVZERO*)InputEvent()->FindListObject(
fV0InName);
177 AliInfoStream() <<
"Trigger maker not yet configure - automatically configuring ..." << std::endl;
178 int runnumber = InputEvent()->GetRunNumber();
179 std::string dataset =
"";
180 if(runnumber >= 145144 && runnumber <= 165746){
183 }
else if(runnumber >= 167806 && runnumber <= 170593){
185 dataset =
"Pb-Pb 2011";
186 }
else if(runnumber >= 176326 && runnumber <= 193766){
189 }
else if(runnumber >= 195344 && runnumber <= 197692){
192 dataset =
"p-Pb 2013";
193 }
else if((runnumber >= 224891 && runnumber <= 244628) || runnumber >= 253434){
196 dataset =
"pp 2015-2016";
197 }
else if(runnumber >= 244824 && runnumber <= 246994){
199 dataset =
"Pb-Pb 2015";
203 AliInfoStream() <<
"Applying configuration for " << dataset << std::endl;
205 AliErrorStream() <<
"No valid configuration found for the given dataset - trigger maker disabled" << std::endl;
229 AliEMCALTriggerPatchInfo *recpatch = NULL;
230 Int_t patchcounter = 0;
232 AliDebugStream(2) << GetName() <<
": Found " << patches->GetEntries() <<
" patches" << std::endl;
233 for(TIter patchIter = TIter(patches).Begin(); patchIter != TIter::End(); ++patchIter){
234 recpatch =
dynamic_cast<AliEMCALTriggerPatchInfo *
>(*patchIter);
236 AliDebugStream(3) << GetName() <<
": Next patch: size " << recpatch->GetPatchSize() <<
" , trigger bits " << std::bitset<sizeof(Int_t)*8>(recpatch->GetTriggerBits()) << std::endl;
238 if(recpatch->IsJetHigh() || recpatch->IsJetLow())
FillQAHistos(
"EJEOnline", *recpatch);
239 if(recpatch->IsGammaHigh() || recpatch->IsGammaLow())
FillQAHistos(
"EGAOnline", *recpatch);
240 if(recpatch->IsJetHighSimple() || recpatch->IsJetLowSimple())
FillQAHistos(
"EJEOffline", *recpatch);
241 if(recpatch->IsGammaHighSimple() || recpatch->IsGammaLowSimple())
FillQAHistos(
"EGAOffline", *recpatch);
242 if(recpatch->IsLevel0())
FillQAHistos(
"EL0Online", *recpatch);
243 if(recpatch->IsRecalcJet())
FillQAHistos(
"EJERecalc", *recpatch);
244 if(recpatch->IsRecalcGamma())
FillQAHistos(
"EGARecalc", *recpatch);
246 int tBits = recpatch->GetTriggerBits();
247 for(
unsigned int ibit = 0; ibit <
sizeof(tBits)*8; ibit++) {
248 if(tBits & (1 << ibit)){
253 new((*fCaloTriggersOut)[patchcounter++]) AliEMCALTriggerPatchInfo(*recpatch);
255 if(patches)
delete patches;
267 Int_t globCol(-1), globRow(-1) ;
269 fGeom->GetTriggerMapping()->GetPositionInEMCALFromAbsFastORIndex(ifastOrID, globCol, globRow);
276 AliInfoStream() <<
"Loading additional bad FEE channels from OADB container " <<
fBadFEEChannelOADB << std::endl;
279 AliOADBContainer badchannelDB(
"EmcalBadChannelsAdditional");
282 if(!badchannelmap || !badchannelmap->GetEntries())
return;
283 for(TIter citer = TIter(badchannelmap).Begin(); citer != TIter::End(); ++citer){
290 AliInfoStream() <<
"Loading masked fastors from OCDB" << std::endl;
291 AliCDBManager *cdb = AliCDBManager::Instance();
293 AliCDBEntry *en = cdb->Get(
"EMCAL/Calib/Trigger");
295 AliErrorStream() << GetName() <<
": FastOR masking from CDB required, but OCDB entry is not available. No masking will be applied." << std::endl;
299 AliEMCALTriggerDCSConfig *trgconf =
dynamic_cast<AliEMCALTriggerDCSConfig *
>(en->GetObject());
301 AliErrorStream() << GetName() <<
": Failed decoding OCDB entry: Object is not of type AliEMCALTriggerDCSConfig." << std::endl;
309 Int_t fastOrAbsID(-1), ic(-1);
310 for(
int itru = 0; itru < trgconf->GetTRUArr()->GetEntries(); itru++){
311 AliEMCALTriggerTRUDCSConfig *truconf = trgconf->GetTRUDCSConfig(itru);
320 for(
unsigned int ifield = 0; ifield < 6; ifield++){
321 for(
unsigned int ibit = 0; ibit < 16; ibit ++){
322 if((truconf->GetMaskReg(ifield) >> ibit) & 0x1){
324 fGeom->GetTriggerMapping()->GetAbsFastORIndexFromTRU(itru, (ic =
GetMaskHandler()(ifield, ibit)), fastOrAbsID);
325 AliDebugStream(1) << GetName() <<
"Channel " << ic <<
" in TRU " << itru <<
" ( abs fastor " << fastOrAbsID <<
") masked." << std::endl;
328 AliErrorStream() << GetName() <<
"Invalid mask: (" << ifield <<
"|" << ibit <<
"), exception " << exept <<
" thrown. Mask will not be recognized" << std::endl;
337 AliInfoStream() <<
"Initializing masked fastors from OADB container " <<
fMaskedFastorOADB.Data() << std::endl;
339 AliOADBContainer badchannelDB(
"AliEmcalMaskedFastors");
342 if(!badchannelmap || !badchannelmap->GetEntries())
return;
343 for(TIter citer = TIter(badchannelmap).Begin(); citer != TIter::End(); ++citer){
345 AliDebugStream(1) << GetName() <<
": Found masked fastor channel " << channelID->GetVal() << std::endl;
352 if(
fGeom->GetTriggerMappingVersion() == 2){
354 return [] (
unsigned int ifield,
unsigned int ibit) ->
int {
356 const int kChannelMap[6][16] = {{ 8, 9,10,11,20,21,22,23,32,33,34,35,44,45,46,47},
357 {56,57,58,59,68,69,70,71,80,81,82,83,92,93,94,95},
358 { 4, 5, 6, 7,16,17,18,19,28,29,30,31,40,41,42,43},
359 {52,53,54,55,64,65,66,67,76,77,78,79,88,89,90,91},
360 { 0, 1, 2, 3,12,13,14,15,24,25,26,27,36,37,38,39},
361 {48,49,50,51,60,61,62,63,72,73,74,75,84,85,86,87}};
362 return kChannelMap[ifield][ibit];
366 return [] (
int ifield,
int ibit) ->
int {
368 return ifield * 16 + ibit;
374 fQAHistos->
FillTH2(Form(
"RCPos%s", patchtype.Data()), recpatch.GetColStart(), recpatch.GetRowStart());
375 fQAHistos->
FillTH2(Form(
"EPCentPos%s", patchtype.Data()), recpatch.GetEtaGeo(), recpatch.GetPhiGeo());
376 fQAHistos->
FillTH2(Form(
"PatchADCvsE%s", patchtype.Data()), recpatch.GetADCAmp(), recpatch.GetPatchE());
377 fQAHistos->
FillTH2(Form(
"PatchADCOffvsE%s", patchtype.Data()), recpatch.GetADCOfflineAmp(), recpatch.GetPatchE());
AliVVZERO * fV0
! VZERO data
AliEmcalTriggerMakerTask()
New configuration, distinction between high and low threshold.
void InitializeBadFEEChannels()
void ConfigureForPbPb2015()
Base task in the EMCAL framework.
Bool_t fLocalInitialized
whether or not the task has been already initialized
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
TObjArray * CreateTriggerPatches(const AliVEvent *inputevent, Bool_t useL0amp=kFALSE)
void InitializeFastORMaskingFromOADB()
void AddFastORBadChannel(Short_t absId)
void SetTriggerBitConfig(const AliEMCALTriggerBitConfig *const config)
void ConfigureForPbPb2011()
Bool_t fUseL0Amplitudes
Use L0 amplitudes instead of L1 time sum (useful for runs where STU was not read) ...
virtual void UserCreateOutputObjects()
void ClearFastORBadChannels()
void SetIsMC(Bool_t isMC)
void ConfigureForPP2011()
Bool_t fLoadFastORMaskingFromOCDB
Load FastOR masking from the OCDB.
void ReadTriggerData(AliVCaloTrigger *trigger)
virtual ~AliEmcalTriggerMakerTask()
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="")
Old configuration, no distinction between high and low threshold.
void ConfigureForPP2012()
THashList * GetListOfHistograms() const
AliEMCALGeometry * fGeom
!emcal geometry
void SetUseTriggerBitConfig(TriggerMakerBitConfig_t bitConfig)
AliEmcalTriggerMakerKernel * fTriggerMaker
The actual trigger maker kernel.
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
void AddOfflineBadChannel(Short_t absId)
EMCAL trigger maker task.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
const std::set< Short_t > & GetListOfBadFastORAbsIDs() const
AliVCaloCells * fCaloCells
!cells
void BuildL1ThresholdsOffline(const AliVVZERO *vzdata)
std::function< int(unsigned int, unsigned int)> GetMaskHandler() const
AliEmcalList * fOutput
!output list
void SetGeometry(const AliEMCALGeometry *const geo)
virtual void RunChanged(Int_t newrun)
void FillQAHistos(const TString &patchtype, const AliEMCALTriggerPatchInfo &recpatch)
TString fBadFEEChannelOADB
name of the OADB container containing channels to be masked inside the trigger maker ...
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
TString fCaloTriggersOutName
name of output track array
TClonesArray * fCaloTriggersOut
! trigger array out
void ClearOfflineBadChannels()
Container class for histograms.
Kernel of the EMCAL trigger patch maker.
TString fMaskedFastorOADB
name of the OADB container containing fastors to be masked inside the trigger maker ...
Int_t GetRunNumber(TString)
AliVCaloTrigger * fCaloTriggers
!calo triggers
void UserCreateOutputObjects()
void InitializeFastORMaskingFromOCDB()
Bool_t IsConfigured() const
THistManager * fQAHistos
! Histograms for QA
Bool_t fDoQA
Fill QA histograms.
void ReadCellData(AliVCaloCells *cells)
void ConfigureForPPb2013()