AliPhysics  ec707b8 (ec707b8)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
AliEmcalTriggerQATask.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2015, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 #include <TClonesArray.h>
16 #include <THashList.h>
17 #include <THnSparse.h>
18 
19 #include "AliEMCALTriggerPatchInfo.h"
20 #include "AliEMCALTriggerFastOR.h"
21 #include "AliEMCALTriggerConstants.h"
22 #include "AliEmcalTriggerQATask.h"
23 
24 
25 using namespace EMCALTrigger;
26 
30 
36  fTriggerPatchesName("EmcalTriggers"),
37  fEMCALTriggerQA(0),
38  fADCperBin(20),
39  fBkgPatchType(kTMEMCalBkg),
40  fBadChannels(),
41  fTriggerPatches(0),
42  fHistEMCalTriggers(0),
43  fHistEventQA(0)
44 {
45 }
46 
52  AliAnalysisTaskEmcal(name,kTRUE),
53  fTriggerPatchesName("EmcalTriggers"),
54  fEMCALTriggerQA(0),
55  fADCperBin(20),
56  fBkgPatchType(kTMEMCalBkg),
57  fBadChannels(),
58  fTriggerPatches(0),
59  fHistEMCalTriggers(0),
60  fHistEventQA(0)
61 {
62  // Constructor.
64 
65  fEMCALTriggerQA = new TObjArray((fNcentBins+1)*2);
66  fEMCALTriggerQA->SetOwner(kTRUE);
67 
68  for (Int_t i = 0; i < fNcentBins; i++) {
69  TString qaName(Form("%s_AliEMCALTriggerQA_Cent%d", name, i));
70  fEMCALTriggerQA->AddAt(new AliEMCALTriggerQA(qaName), i);
71  }
72 }
73 
78 {
79  delete fEMCALTriggerQA;
80 }
81 
86 {
88 
89  if (!fInitialized) return;
90 
91  fTriggerPatches = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTriggerPatchesName));
92 
93  if (fTriggerPatches) {
94  TString objname(fTriggerPatches->GetClass()->GetName());
95  TClass cls(objname);
96  if (!cls.InheritsFrom("AliEMCALTriggerPatchInfo")) {
97  AliError(Form("%s: Objects of type %s in %s are not inherited from AliEMCALTriggerPatchInfo!",
98  GetName(), cls.GetName(), fTriggerPatchesName.Data()));
99  fTriggerPatches = 0;
100  }
101  }
102 
103  if (!fTriggerPatches) {
104  fInitialized = kFALSE;
105  AliError(Form("%s: Unable to get trigger patch container with name %s. Aborting", GetName(), fTriggerPatchesName.Data()));
106  return;
107  }
108 }
109 
114 {
115  fCaloTriggerNames[kMinBias] = "CINT7-B-NOPF-CENT";
116  fCaloTriggerNames[kEMCalL0] = "CEMC7-B-NOPF-CENTNOPMD";
117  fCaloTriggerNames[kEMCalL1G1] = "CINT7EG1-B-NOPF-CENTNOPMD";
118  fCaloTriggerNames[kEMCalL1G2] = "CINT7EG2-B-NOPF-CENTNOPMD";
119  fCaloTriggerNames[kEMCalL1J1] = "CINT7EJ1-B-NOPF-CENTNOPMD";
120  fCaloTriggerNames[kEMCalL1J2] = "CINT7EJ2-B-NOPF-CENTNOPMD";
121  fCaloTriggerNames[kDCalL0] = "CDMC7-B-NOPF-CENTNOPMD";
122  fCaloTriggerNames[kDCalL1G1] = "CINT7DG1-B-NOPF-CENTNOPMD";
123  fCaloTriggerNames[kDCalL1G2] = "CINT7DG2-B-NOPF-CENTNOPMD";
124  fCaloTriggerNames[kDCalL1J1] = "CINT7DJ1-B-NOPF-CENTNOPMD";
125  fCaloTriggerNames[kDCalL1J2] = "CINT7DJ2-B-NOPF-CENTNOPMD";
126  fCaloTriggerNames[kPHOSL0] = "CPHI7-B-NOPF-CENTNOPMD";
127  fCaloTriggerNames[kPHOSL1H] = "CINT7PHH-B-NOPF-CENTNOPMD";
128  fCaloTriggerNames[kPHOSL1M] = "CINT7PHM-B-NOPF-CENTNOPMD";
129  fCaloTriggerNames[kPHOSL1L] = "CINT7PHL-B-NOPF-CENTNOPMD";
130 }
131 
136 {
138 
139  if (fOutput) {
140  fHistEMCalTriggers = new TH1F("fHistEMCalTriggers","fHistEMCalTriggers; triggers; counts",40,0,40);
141 #if ROOT_VERSION_CODE < ROOT_VERSION(6,4,2)
142  fHistEMCalTriggers->SetBit(TH1::kCanRebin);
143 #else
144  fHistEMCalTriggers->SetCanExtend(TH1::kAllAxes);
145 #endif
146  fHistEMCalTriggers->GetXaxis()->SetBinLabel(1, "EMCal L0");
147  fHistEMCalTriggers->GetXaxis()->SetBinLabel(2, "EMCal L1 G1");
148  fHistEMCalTriggers->GetXaxis()->SetBinLabel(3, "EMCal L1 G2");
149  fHistEMCalTriggers->GetXaxis()->SetBinLabel(4, "EMCal L1 J1");
150  fHistEMCalTriggers->GetXaxis()->SetBinLabel(5, "EMCal L1 J2");
151  fHistEMCalTriggers->GetXaxis()->SetBinLabel(6, "EMCal L1 Any");
152  fHistEMCalTriggers->GetXaxis()->SetBinLabel(7, "EMCal Any");
153 
154  fHistEMCalTriggers->GetXaxis()->SetBinLabel(8, "DCal L0");
155  fHistEMCalTriggers->GetXaxis()->SetBinLabel(9, "DCal L1 G1");
156  fHistEMCalTriggers->GetXaxis()->SetBinLabel(10, "DCal L1 G2");
157  fHistEMCalTriggers->GetXaxis()->SetBinLabel(11, "DCal L1 J1");
158  fHistEMCalTriggers->GetXaxis()->SetBinLabel(12, "DCal L1 J2");
159  fHistEMCalTriggers->GetXaxis()->SetBinLabel(13, "DCal L1 Any");
160  fHistEMCalTriggers->GetXaxis()->SetBinLabel(14, "DCal Any");
161 
162  fHistEMCalTriggers->GetXaxis()->SetBinLabel(15, "EMCal/DCal L0");
163  fHistEMCalTriggers->GetXaxis()->SetBinLabel(16, "EMCal/DCal L1 G1");
164  fHistEMCalTriggers->GetXaxis()->SetBinLabel(17, "EMCal/DCal L1 G2");
165  fHistEMCalTriggers->GetXaxis()->SetBinLabel(18, "EMCal/DCal L1 J1");
166  fHistEMCalTriggers->GetXaxis()->SetBinLabel(19, "EMCal/DCal L1 J2");
167  fHistEMCalTriggers->GetXaxis()->SetBinLabel(20, "EMCal/DCal L1 Any");
168 
169  fHistEMCalTriggers->GetXaxis()->SetBinLabel(21, "EMCal/DCal Any");
170 
171  fHistEMCalTriggers->GetXaxis()->SetBinLabel(22, "PHOS L0");
172  fHistEMCalTriggers->GetXaxis()->SetBinLabel(23, "PHOS L1 H");
173  fHistEMCalTriggers->GetXaxis()->SetBinLabel(24, "PHOS L1 M");
174  fHistEMCalTriggers->GetXaxis()->SetBinLabel(25, "PHOS L1 L");
175  fHistEMCalTriggers->GetXaxis()->SetBinLabel(26, "PHOS L1 Any");
176  fHistEMCalTriggers->GetXaxis()->SetBinLabel(27, "PHOS Any");
177 
178  fHistEMCalTriggers->GetXaxis()->SetBinLabel(28, "CALO L0");
179  fHistEMCalTriggers->GetXaxis()->SetBinLabel(29, "CALO L1");
180  fHistEMCalTriggers->GetXaxis()->SetBinLabel(30, "CALO Any");
181 
182  fHistEMCalTriggers->GetXaxis()->SetBinLabel(31, "MB");
183 
184  fHistEMCalTriggers->GetXaxis()->SetBinLabel(32, "MB or CALO");
185 
186  fHistEMCalTriggers->GetXaxis()->SetBinLabel(33, "EMCal Any and !MB");
187  fHistEMCalTriggers->GetXaxis()->SetBinLabel(34, "DCal Any and !MB");
188  fHistEMCalTriggers->GetXaxis()->SetBinLabel(35, "EMCal/DCal Any and !MB");
189 
191 
192  for (Int_t i = 0; i < fNcentBins; i++) {
193  GetTriggerQA(i)->SetDebugLevel(DebugLevel());
194  GetTriggerQA(i)->Init();
195  fOutput->Add(GetTriggerQA(i)->GetListOfHistograms());
196  }
197 
198  Int_t dim = 0;
199  TString title[20];
200  Int_t nbins[20] = {0};
201  Double_t min[20] = {0};
202  Double_t max[20] = {0};
203 
205  title[dim] = "Centrality %";
206  nbins[dim] = 101;
207  min[dim] = 0;
208  max[dim] = 101;
209  dim++;
210  }
211 
212  title[dim] = "DCal median (offline)";
213  nbins[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / fADCperBin / 10;
214  min[dim] = 0;
215  max[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / 10;
216  dim++;
217 
218  title[dim] = "EMCal median (offline)";
219  nbins[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / fADCperBin / 10;
220  min[dim] = 0;
221  max[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / 10;
222  dim++;
223 
224  title[dim] = "DCal median (recalc)";
225  nbins[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / fADCperBin / 10;
226  min[dim] = 0;
227  max[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / 10;
228  dim++;
229 
230  title[dim] = "EMCal median (recalc)";
231  nbins[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / fADCperBin / 10;
232  min[dim] = 0;
233  max[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / 10;
234  dim++;
235 
236  fHistEventQA = new THnSparseF("fHistEventQA","fHistEventQA",dim,nbins,min,max);
237  for (Int_t i = 0; i < dim; i++)
238  fHistEventQA->GetAxis(i)->SetTitle(title[i]);
239  fOutput->Add(fHistEventQA);
240 
241  PostData(1, fOutput);
242  }
243 }
244 
250 {
251  return kTRUE;
252 }
253 
254 UInt_t AliEmcalTriggerQATask::SteerFiredTriggers(const TString& firedTriggersStr) const
255 {
256  UInt_t firedTriggers = 0;
257 
258  for (Int_t bit = 0; bit < kLastCaloTrigger; bit++) {
259  if (firedTriggersStr.Contains(fCaloTriggerNames[bit])) {
260  SETBIT(firedTriggers, bit);
261  }
262  }
263 
264  return firedTriggers;
265 }
266 
272 {
273  UInt_t firedTriggerBits = SteerFiredTriggers(InputEvent()->GetFiredTriggerClasses());
274 
275  if ((firedTriggerBits & kEMCalL0bit) != 0) fHistEMCalTriggers->Fill("EMCal L0", 1);
276  if ((firedTriggerBits & kEMCalL1G1bit) != 0) fHistEMCalTriggers->Fill("EMCal L1 G1", 1);
277  if ((firedTriggerBits & kEMCalL1G2bit) != 0) fHistEMCalTriggers->Fill("EMCal L1 G2", 1);
278  if ((firedTriggerBits & kEMCalL1J1bit) != 0) fHistEMCalTriggers->Fill("EMCal L1 J1", 1);
279  if ((firedTriggerBits & kEMCalL1J2bit) != 0) fHistEMCalTriggers->Fill("EMCal L1 J2", 1);
280  if ((firedTriggerBits & kEMCalL1Anybit) != 0) fHistEMCalTriggers->Fill("EMCal L1 Any", 1);
281  if ((firedTriggerBits & kEMCalAnybit) != 0) fHistEMCalTriggers->Fill("EMCal Any", 1);
282 
283  if ((firedTriggerBits & kDCalL0bit) != 0) fHistEMCalTriggers->Fill("DCal L0", 1);
284  if ((firedTriggerBits & kDCalL1G1bit) != 0) fHistEMCalTriggers->Fill("DCal L1 G1", 1);
285  if ((firedTriggerBits & kDCalL1G2bit) != 0) fHistEMCalTriggers->Fill("DCal L1 G2", 1);
286  if ((firedTriggerBits & kDCalL1J1bit) != 0) fHistEMCalTriggers->Fill("DCal L1 J1", 1);
287  if ((firedTriggerBits & kDCalL1J2bit) != 0) fHistEMCalTriggers->Fill("DCal L1 J2", 1);
288  if ((firedTriggerBits & kDCalL1Anybit) != 0) fHistEMCalTriggers->Fill("DCal L1 Any", 1);
289  if ((firedTriggerBits & kDCalAnybit) != 0) fHistEMCalTriggers->Fill("DCal Any", 1);
290 
291  if ((firedTriggerBits & kEMCalDCalL0bit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal L0", 1);
292  if ((firedTriggerBits & kEMCalDCalL1G1bit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal L1 G1", 1);
293  if ((firedTriggerBits & kEMCalDCalL1G2bit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal L1 G2", 1);
294  if ((firedTriggerBits & kEMCalDCalL1J1bit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal L1 J1", 1);
295  if ((firedTriggerBits & kEMCalDCalL1J2bit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal L1 J2", 1);
296  if ((firedTriggerBits & kEMCalDCalL1Anybit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal L1 Any", 1);
297 
298  if ((firedTriggerBits & kEMCalDCalAnybit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal Any", 1);
299 
300  if ((firedTriggerBits & kPHOSL0bit) != 0) fHistEMCalTriggers->Fill("PHOS L0", 1);
301  if ((firedTriggerBits & kPHOSL1Hbit) != 0) fHistEMCalTriggers->Fill("PHOS L1 H", 1);
302  if ((firedTriggerBits & kPHOSL1Mbit) != 0) fHistEMCalTriggers->Fill("PHOS L1 M", 1);
303  if ((firedTriggerBits & kPHOSL1Lbit) != 0) fHistEMCalTriggers->Fill("PHOS L1 L", 1);
304  if ((firedTriggerBits & kPHOSL1Anybit) != 0) fHistEMCalTriggers->Fill("PHOS L1 Any", 1);
305  if ((firedTriggerBits & kPHOSAnybit) != 0) fHistEMCalTriggers->Fill("PHOS Any", 1);
306 
307  if ((firedTriggerBits & kCALOL0bit) != 0) fHistEMCalTriggers->Fill("CALO L0", 1);
308  if ((firedTriggerBits & kCALOL1bit) != 0) fHistEMCalTriggers->Fill("CALO L1", 1);
309  if ((firedTriggerBits & kCALOAnybit) != 0) fHistEMCalTriggers->Fill("CALO Any", 1);
310 
311  if ((firedTriggerBits & kMinBiasbit) != 0) fHistEMCalTriggers->Fill("MB", 1);
312 
313  if ((firedTriggerBits & kCALOMinBias) != 0) fHistEMCalTriggers->Fill("MB or CALO", 1);
314 
315  if ((firedTriggerBits & kMinBiasbit) == 0 &&
316  (firedTriggerBits & kEMCalAnybit) != 0) fHistEMCalTriggers->Fill("EMCal Any and !MB", 1);
317 
318  if ((firedTriggerBits & kMinBiasbit) == 0 &&
319  (firedTriggerBits & kDCalAnybit) != 0) fHistEMCalTriggers->Fill("DCal Any and !MB", 1);
320 
321  if ((firedTriggerBits & kMinBiasbit) == 0 &&
322  (firedTriggerBits & kEMCalDCalAnybit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal Any and !MB", 1);
323 
324  if (fTriggerPatches) {
325  Int_t nPatches = fTriggerPatches->GetEntriesFast();
326 
327  AliDebug(2, Form("nPatches = %d", nPatches));
328 
329  Int_t type = 0;
330 
331  for (Int_t i = 0; i < nPatches; i++) {
332  AliDebug(2, Form("Processing patch %d", i));
333 
334  AliEMCALTriggerPatchInfo* patch = static_cast<AliEMCALTriggerPatchInfo*>(fTriggerPatches->At(i));
335  if (!patch) continue;
336 
337  GetTriggerQA(fCentBin)->ProcessBkgPatch(patch);
338  }
339 
340  GetTriggerQA(fCentBin)->ComputeBackground();
341 
342  FillEventQA();
343 
344  for (Int_t i = 0; i < nPatches; i++) {
345  AliDebug(2, Form("Processing patch %d", i));
346 
347  AliEMCALTriggerPatchInfo* patch = static_cast<AliEMCALTriggerPatchInfo*>(fTriggerPatches->At(i));
348  if (!patch) continue;
349 
350  GetTriggerQA(fCentBin)->ProcessPatch(patch);
351  }
352  }
353 
354  if (fCaloTriggers) {
355  AliEMCALTriggerFastOR fastor;
356  fCaloTriggers->Reset();
357  Int_t globCol = -1, globRow = -1;
358  Float_t L0amp = -1;
359  Int_t L1amp = -1;
360  while (fCaloTriggers->Next()) {
361  // get position in global 2x2 tower coordinates
362  // A0 left bottom (0,0)
363  fCaloTriggers->GetPosition(globCol, globRow);
364  // exclude channel completely if it is masked as hot channel
365  if (fBadChannels.HasChannel(globCol, globRow)) continue;
366  // for some strange reason some ADC amps are initialized in reconstruction
367  // as -1, neglect those
368  fCaloTriggers->GetL1TimeSum(L1amp);
369  if (L1amp < 0) L1amp = 0;
370  fCaloTriggers->GetAmplitude(L0amp);
371  if (L0amp < 0) L0amp = 0;
372 
373  Int_t time = 0;
374  Int_t nl0times(0);
375  fCaloTriggers->GetNL0Times(nl0times);
376  if(nl0times) {
377  TArrayI l0times(nl0times);
378  fCaloTriggers->GetL0Times(l0times.GetArray());
379  for(int itime = 0; itime < nl0times; itime++){
380  if(l0times[itime] >7 && l0times[itime] < 10){
381  time = l0times[itime];
382  break;
383  }
384  }
385  }
386 
387  fastor.Initialize(L0amp, L1amp, globRow, globCol, time, fGeom);
388 
389  GetTriggerQA(fCentBin)->ProcessFastor(&fastor);
390  }
391  }
392  GetTriggerQA(fCentBin)->EventCompleted();
393 
394  return kTRUE;
395 }
396 
401 {
402  Double_t contents[20] = {0};
403 
404  Double_t DCalmedian[3] = {0};
405  Double_t EMCalmedian[3] = {0};
406 
407  GetTriggerQA(fCentBin)->GetDCalMedian(DCalmedian);
408  GetTriggerQA(fCentBin)->GetEMCalMedian(EMCalmedian);
409 
410  for (Int_t i = 0; i < fHistEventQA->GetNdimensions(); i++) {
411  TString title(fHistEventQA->GetAxis(i)->GetTitle());
412  if (title=="Centrality %")
413  contents[i] = fCent;
414  else if (title=="DCal median (offline)")
415  contents[i] = DCalmedian[2];
416  else if (title=="EMCal median (offline)")
417  contents[i] = EMCalmedian[2];
418  else if (title=="DCal median (recalc)")
419  contents[i] = DCalmedian[1];
420  else if (title=="EMCal median (recalc)")
421  contents[i] = EMCalmedian[1];
422  else
423  AliWarning(Form("Unable to fill dimension %s!",title.Data()));
424  }
425 
426  fHistEventQA->Fill(contents);
427 }
428 
434 {
435  fADCperBin = n;
436 
437  for (Int_t i = 0; i < fNcentBins; i++) {
438  GetTriggerQA(i)->SetADCperBin(n);
439  }
440 }
441 
447 {
448  fBkgPatchType = t;
449 
450  for (Int_t i = 0; i < fNcentBins; i++) {
451  GetTriggerQA(i)->SetBkgPatchType(t);
452  }
453 }
454 
460 {
461  if (n <= 0) n = 0;
462 
463  // delete superflouos items in fEMCALTriggerQA
464  for (Int_t i = n; i < fNcentBins; i++) {
465  fEMCALTriggerQA->RemoveAt(i);
466  }
467 
468  for (Int_t i = fNcentBins; i < n; i++) {
469  TString qaName(Form("%s_AliEMCALTriggerQA_Cent%d", GetName(), i));
470  if (fEMCALTriggerQA->At(0)) {
471  AliEMCALTriggerQA* triggerQA = new AliEMCALTriggerQA(*(static_cast<AliEMCALTriggerQA*>(fEMCALTriggerQA->At(0))));
472  triggerQA->SetName(qaName);
473  triggerQA->SetTitle(qaName);
474  fEMCALTriggerQA->AddAt(triggerQA, i);
475  }
476  else {
477  fEMCALTriggerQA->AddAt(new AliEMCALTriggerQA(qaName), i);
478  }
479  }
480 
481  fNcentBins = n;
482 }
Int_t fADCperBin
ADC counts per bin.
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
const char * title
Definition: MakeQAPdf.C:26
TClonesArray * fTriggerPatches
! trigger array in
Base task in the EMCAL framework.
EMCAL trigger QA task.
TString fTriggerPatchesName
name of input trigger array
TH1 * fHistEMCalTriggers
! EMCal triggers
Int_t fCentBin
!event centrality bin
TList * fOutput
!output list
THnSparse * fHistEventQA
! Event QA
Class to do some fast QA of the EMCal trigger. Useful also to tune trigger thresholds.
UInt_t SteerFiredTriggers(const TString &firedTriggersStr) const
AliEMCALGeometry * fGeom
!emcal geometry
BeamType fForceBeamType
name of pythia info object
Int_t fNcentBins
if MC label > fMCLabelShift, MC label -= fMCLabelShift
Double_t fCent
!event centrality
TObjArray * fEMCALTriggerQA
produces the QA histograms
Int_t fBkgPatchType
Background patch type.
AliEMCALTriggerChannelContainer fBadChannels
Container of bad channels.
void SetMakeGeneralHistograms(Bool_t g)
TString fCaloTriggerNames[kLastCaloTrigger]
names of the calo trigger classes
AliVCaloTrigger * fCaloTriggers
!calo triggers
const Int_t nbins
Bool_t fInitialized
whether or not it should fill some general histograms
AliEMCALTriggerQA * GetTriggerQA(Int_t i=0)