AliPhysics  4c20e6b (4c20e6b)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends 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  fTriggerPatches(0),
41  fHistEMCalTriggers(0),
42  fHistEventQA(0)
43 {
44 }
45 
51  AliAnalysisTaskEmcal(name,kTRUE),
52  fTriggerPatchesName("EmcalTriggers"),
53  fEMCALTriggerQA(0),
54  fADCperBin(20),
55  fBkgPatchType(kTMEMCalBkg),
56  fTriggerPatches(0),
57  fHistEMCalTriggers(0),
58  fHistEventQA(0)
59 {
60  // Constructor.
62 
63  fEMCALTriggerQA = new TObjArray((fNcentBins+1)*2);
64  fEMCALTriggerQA->SetOwner(kTRUE);
65 
66  for (Int_t i = 0; i < fNcentBins; i++) {
67  TString qaName(Form("%s_AliEMCALTriggerQA_Cent%d", name, i));
68  fEMCALTriggerQA->AddAt(new AliEMCALTriggerQA(qaName), i);
69  }
70 }
71 
76 {
77  delete fEMCALTriggerQA;
78 }
79 
84 {
86 
87  if (!fInitialized) return;
88 
89  fTriggerPatches = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTriggerPatchesName));
90 
91  if (fTriggerPatches) {
92  TString objname(fTriggerPatches->GetClass()->GetName());
93  TClass cls(objname);
94  if (!cls.InheritsFrom("AliEMCALTriggerPatchInfo")) {
95  AliError(Form("%s: Objects of type %s in %s are not inherited from AliEMCALTriggerPatchInfo!",
96  GetName(), cls.GetName(), fTriggerPatchesName.Data()));
97  fTriggerPatches = 0;
98  }
99  }
100 
101  if (!fTriggerPatches) {
102  fInitialized = kFALSE;
103  AliError(Form("%s: Unable to get trigger patch container with name %s. Aborting", GetName(), fTriggerPatchesName.Data()));
104  return;
105  }
106 }
107 
112 {
113  fCaloTriggerNames[kMinBias] = "CINT7-B-NOPF-CENT";
114  fCaloTriggerNames[kEMCalL0] = "CEMC7-B-NOPF-CENTNOPMD";
115  fCaloTriggerNames[kEMCalL1G1] = "CINT7EG1-B-NOPF-CENTNOPMD";
116  fCaloTriggerNames[kEMCalL1G2] = "CINT7EG2-B-NOPF-CENTNOPMD";
117  fCaloTriggerNames[kEMCalL1J1] = "CINT7EJ1-B-NOPF-CENTNOPMD";
118  fCaloTriggerNames[kEMCalL1J2] = "CINT7EJ2-B-NOPF-CENTNOPMD";
119  fCaloTriggerNames[kDCalL0] = "CDMC7-B-NOPF-CENTNOPMD";
120  fCaloTriggerNames[kDCalL1G1] = "CINT7DG1-B-NOPF-CENTNOPMD";
121  fCaloTriggerNames[kDCalL1G2] = "CINT7DG2-B-NOPF-CENTNOPMD";
122  fCaloTriggerNames[kDCalL1J1] = "CINT7DJ1-B-NOPF-CENTNOPMD";
123  fCaloTriggerNames[kDCalL1J2] = "CINT7DJ2-B-NOPF-CENTNOPMD";
124  fCaloTriggerNames[kPHOSL0] = "CPHI7-B-NOPF-CENTNOPMD";
125  fCaloTriggerNames[kPHOSL1H] = "CINT7PHH-B-NOPF-CENTNOPMD";
126  fCaloTriggerNames[kPHOSL1M] = "CINT7PHM-B-NOPF-CENTNOPMD";
127  fCaloTriggerNames[kPHOSL1L] = "CINT7PHL-B-NOPF-CENTNOPMD";
128 }
129 
134 {
136 
137  if (fOutput) {
138  fHistEMCalTriggers = new TH1F("fHistEMCalTriggers","fHistEMCalTriggers; triggers; counts",40,0,40);
139 #if ROOT_VERSION_CODE < ROOT_VERSION(6,4,2)
140  fHistEMCalTriggers->SetBit(TH1::kCanRebin);
141 #else
142  fHistEMCalTriggers->SetCanExtend(TH1::kAllAxes);
143 #endif
144  fHistEMCalTriggers->GetXaxis()->SetBinLabel(1, "EMCal L0");
145  fHistEMCalTriggers->GetXaxis()->SetBinLabel(2, "EMCal L1 G1");
146  fHistEMCalTriggers->GetXaxis()->SetBinLabel(3, "EMCal L1 G2");
147  fHistEMCalTriggers->GetXaxis()->SetBinLabel(4, "EMCal L1 J1");
148  fHistEMCalTriggers->GetXaxis()->SetBinLabel(5, "EMCal L1 J2");
149  fHistEMCalTriggers->GetXaxis()->SetBinLabel(6, "EMCal L1 Any");
150  fHistEMCalTriggers->GetXaxis()->SetBinLabel(7, "EMCal Any");
151 
152  fHistEMCalTriggers->GetXaxis()->SetBinLabel(8, "DCal L0");
153  fHistEMCalTriggers->GetXaxis()->SetBinLabel(9, "DCal L1 G1");
154  fHistEMCalTriggers->GetXaxis()->SetBinLabel(10, "DCal L1 G2");
155  fHistEMCalTriggers->GetXaxis()->SetBinLabel(11, "DCal L1 J1");
156  fHistEMCalTriggers->GetXaxis()->SetBinLabel(12, "DCal L1 J2");
157  fHistEMCalTriggers->GetXaxis()->SetBinLabel(13, "DCal L1 Any");
158  fHistEMCalTriggers->GetXaxis()->SetBinLabel(14, "DCal Any");
159 
160  fHistEMCalTriggers->GetXaxis()->SetBinLabel(15, "EMCal/DCal L0");
161  fHistEMCalTriggers->GetXaxis()->SetBinLabel(16, "EMCal/DCal L1 G1");
162  fHistEMCalTriggers->GetXaxis()->SetBinLabel(17, "EMCal/DCal L1 G2");
163  fHistEMCalTriggers->GetXaxis()->SetBinLabel(18, "EMCal/DCal L1 J1");
164  fHistEMCalTriggers->GetXaxis()->SetBinLabel(19, "EMCal/DCal L1 J2");
165  fHistEMCalTriggers->GetXaxis()->SetBinLabel(20, "EMCal/DCal L1 Any");
166 
167  fHistEMCalTriggers->GetXaxis()->SetBinLabel(21, "EMCal/DCal Any");
168 
169  fHistEMCalTriggers->GetXaxis()->SetBinLabel(22, "PHOS L0");
170  fHistEMCalTriggers->GetXaxis()->SetBinLabel(23, "PHOS L1 H");
171  fHistEMCalTriggers->GetXaxis()->SetBinLabel(24, "PHOS L1 M");
172  fHistEMCalTriggers->GetXaxis()->SetBinLabel(25, "PHOS L1 L");
173  fHistEMCalTriggers->GetXaxis()->SetBinLabel(26, "PHOS L1 Any");
174  fHistEMCalTriggers->GetXaxis()->SetBinLabel(27, "PHOS Any");
175 
176  fHistEMCalTriggers->GetXaxis()->SetBinLabel(28, "CALO L0");
177  fHistEMCalTriggers->GetXaxis()->SetBinLabel(29, "CALO L1");
178  fHistEMCalTriggers->GetXaxis()->SetBinLabel(30, "CALO Any");
179 
180  fHistEMCalTriggers->GetXaxis()->SetBinLabel(31, "MB");
181 
182  fHistEMCalTriggers->GetXaxis()->SetBinLabel(32, "MB or CALO");
183 
184  fHistEMCalTriggers->GetXaxis()->SetBinLabel(33, "EMCal Any and !MB");
185  fHistEMCalTriggers->GetXaxis()->SetBinLabel(34, "DCal Any and !MB");
186  fHistEMCalTriggers->GetXaxis()->SetBinLabel(35, "EMCal/DCal Any and !MB");
187 
189 
190  for (Int_t i = 0; i < fNcentBins; i++) {
191  GetTriggerQA(i)->SetDebugLevel(DebugLevel());
192  GetTriggerQA(i)->Init();
193  fOutput->Add(GetTriggerQA(i)->GetListOfHistograms());
194  }
195 
196  Int_t dim = 0;
197  TString title[20];
198  Int_t nbins[20] = {0};
199  Double_t min[20] = {0};
200  Double_t max[20] = {0};
201 
203  title[dim] = "Centrality %";
204  nbins[dim] = 101;
205  min[dim] = 0;
206  max[dim] = 101;
207  dim++;
208  }
209 
210  title[dim] = "DCal median (offline)";
211  nbins[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / fADCperBin / 10;
212  min[dim] = 0;
213  max[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / 10;
214  dim++;
215 
216  title[dim] = "EMCal median (offline)";
217  nbins[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / fADCperBin / 10;
218  min[dim] = 0;
219  max[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / 10;
220  dim++;
221 
222  title[dim] = "DCal median (recalc)";
223  nbins[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / fADCperBin / 10;
224  min[dim] = 0;
225  max[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / 10;
226  dim++;
227 
228  title[dim] = "EMCal median (recalc)";
229  nbins[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / fADCperBin / 10;
230  min[dim] = 0;
231  max[dim] = AliEMCALTriggerQA::fgkMaxPatchAmp[fBkgPatchType] / 10;
232  dim++;
233 
234  fHistEventQA = new THnSparseF("fHistEventQA","fHistEventQA",dim,nbins,min,max);
235  for (Int_t i = 0; i < dim; i++)
236  fHistEventQA->GetAxis(i)->SetTitle(title[i]);
237  fOutput->Add(fHistEventQA);
238 
239  PostData(1, fOutput);
240  }
241 }
242 
248 {
249  return kTRUE;
250 }
251 
252 UInt_t AliEmcalTriggerQATask::SteerFiredTriggers(const TString& firedTriggersStr) const
253 {
254  UInt_t firedTriggers = 0;
255 
256  for (Int_t bit = 0; bit < kLastCaloTrigger; bit++) {
257  if (firedTriggersStr.Contains(fCaloTriggerNames[bit])) {
258  SETBIT(firedTriggers, bit);
259  }
260  }
261 
262  return firedTriggers;
263 }
264 
270 {
271  UInt_t firedTriggerBits = SteerFiredTriggers(InputEvent()->GetFiredTriggerClasses());
272 
273  if ((firedTriggerBits & kEMCalL0bit) != 0) fHistEMCalTriggers->Fill("EMCal L0", 1);
274  if ((firedTriggerBits & kEMCalL1G1bit) != 0) fHistEMCalTriggers->Fill("EMCal L1 G1", 1);
275  if ((firedTriggerBits & kEMCalL1G2bit) != 0) fHistEMCalTriggers->Fill("EMCal L1 G2", 1);
276  if ((firedTriggerBits & kEMCalL1J1bit) != 0) fHistEMCalTriggers->Fill("EMCal L1 J1", 1);
277  if ((firedTriggerBits & kEMCalL1J2bit) != 0) fHistEMCalTriggers->Fill("EMCal L1 J2", 1);
278  if ((firedTriggerBits & kEMCalL1Anybit) != 0) fHistEMCalTriggers->Fill("EMCal L1 Any", 1);
279  if ((firedTriggerBits & kEMCalAnybit) != 0) fHistEMCalTriggers->Fill("EMCal Any", 1);
280 
281  if ((firedTriggerBits & kDCalL0bit) != 0) fHistEMCalTriggers->Fill("DCal L0", 1);
282  if ((firedTriggerBits & kDCalL1G1bit) != 0) fHistEMCalTriggers->Fill("DCal L1 G1", 1);
283  if ((firedTriggerBits & kDCalL1G2bit) != 0) fHistEMCalTriggers->Fill("DCal L1 G2", 1);
284  if ((firedTriggerBits & kDCalL1J1bit) != 0) fHistEMCalTriggers->Fill("DCal L1 J1", 1);
285  if ((firedTriggerBits & kDCalL1J2bit) != 0) fHistEMCalTriggers->Fill("DCal L1 J2", 1);
286  if ((firedTriggerBits & kDCalL1Anybit) != 0) fHistEMCalTriggers->Fill("DCal L1 Any", 1);
287  if ((firedTriggerBits & kDCalAnybit) != 0) fHistEMCalTriggers->Fill("DCal Any", 1);
288 
289  if ((firedTriggerBits & kEMCalDCalL0bit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal L0", 1);
290  if ((firedTriggerBits & kEMCalDCalL1G1bit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal L1 G1", 1);
291  if ((firedTriggerBits & kEMCalDCalL1G2bit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal L1 G2", 1);
292  if ((firedTriggerBits & kEMCalDCalL1J1bit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal L1 J1", 1);
293  if ((firedTriggerBits & kEMCalDCalL1J2bit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal L1 J2", 1);
294  if ((firedTriggerBits & kEMCalDCalL1Anybit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal L1 Any", 1);
295 
296  if ((firedTriggerBits & kEMCalDCalAnybit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal Any", 1);
297 
298  if ((firedTriggerBits & kPHOSL0bit) != 0) fHistEMCalTriggers->Fill("PHOS L0", 1);
299  if ((firedTriggerBits & kPHOSL1Hbit) != 0) fHistEMCalTriggers->Fill("PHOS L1 H", 1);
300  if ((firedTriggerBits & kPHOSL1Mbit) != 0) fHistEMCalTriggers->Fill("PHOS L1 M", 1);
301  if ((firedTriggerBits & kPHOSL1Lbit) != 0) fHistEMCalTriggers->Fill("PHOS L1 L", 1);
302  if ((firedTriggerBits & kPHOSL1Anybit) != 0) fHistEMCalTriggers->Fill("PHOS L1 Any", 1);
303  if ((firedTriggerBits & kPHOSAnybit) != 0) fHistEMCalTriggers->Fill("PHOS Any", 1);
304 
305  if ((firedTriggerBits & kCALOL0bit) != 0) fHistEMCalTriggers->Fill("CALO L0", 1);
306  if ((firedTriggerBits & kCALOL1bit) != 0) fHistEMCalTriggers->Fill("CALO L1", 1);
307  if ((firedTriggerBits & kCALOAnybit) != 0) fHistEMCalTriggers->Fill("CALO Any", 1);
308 
309  if ((firedTriggerBits & kMinBiasbit) != 0) fHistEMCalTriggers->Fill("MB", 1);
310 
311  if ((firedTriggerBits & kCALOMinBias) != 0) fHistEMCalTriggers->Fill("MB or CALO", 1);
312 
313  if ((firedTriggerBits & kMinBiasbit) == 0 &&
314  (firedTriggerBits & kEMCalAnybit) != 0) fHistEMCalTriggers->Fill("EMCal Any and !MB", 1);
315 
316  if ((firedTriggerBits & kMinBiasbit) == 0 &&
317  (firedTriggerBits & kDCalAnybit) != 0) fHistEMCalTriggers->Fill("DCal Any and !MB", 1);
318 
319  if ((firedTriggerBits & kMinBiasbit) == 0 &&
320  (firedTriggerBits & kEMCalDCalAnybit) != 0) fHistEMCalTriggers->Fill("EMCal/DCal Any and !MB", 1);
321 
322  if (fTriggerPatches) {
323  Int_t nPatches = fTriggerPatches->GetEntriesFast();
324 
325  AliDebug(2, Form("nPatches = %d", nPatches));
326 
327  //Int_t type = 0;
328 
329  for (Int_t i = 0; i < nPatches; i++) {
330  AliDebug(2, Form("Processing patch %d", i));
331 
332  AliEMCALTriggerPatchInfo* patch = static_cast<AliEMCALTriggerPatchInfo*>(fTriggerPatches->At(i));
333  if (!patch) continue;
334 
335  GetTriggerQA(fCentBin)->ProcessBkgPatch(patch);
336  }
337 
338  GetTriggerQA(fCentBin)->ComputeBackground();
339 
340  FillEventQA();
341 
342  for (Int_t i = 0; i < nPatches; i++) {
343  AliDebug(2, Form("Processing patch %d", i));
344 
345  AliEMCALTriggerPatchInfo* patch = static_cast<AliEMCALTriggerPatchInfo*>(fTriggerPatches->At(i));
346  if (!patch) continue;
347 
348  GetTriggerQA(fCentBin)->ProcessPatch(patch);
349  }
350  }
351 
352  if (fCaloTriggers) {
353  AliEMCALTriggerFastOR fastor;
354  fCaloTriggers->Reset();
355  Int_t globCol = -1, globRow = -1;
356  Float_t L0amp = -1;
357  Int_t L1amp = -1;
358  while (fCaloTriggers->Next()) {
359  // get position in global 2x2 tower coordinates
360  // A0 left bottom (0,0)
361  fCaloTriggers->GetPosition(globCol, globRow);
362  // for some strange reason some ADC amps are initialized in reconstruction
363  // as -1, neglect those
364  fCaloTriggers->GetL1TimeSum(L1amp);
365  if (L1amp < 0) L1amp = 0;
366  fCaloTriggers->GetAmplitude(L0amp);
367  if (L0amp < 0) L0amp = 0;
368 
369  Int_t time = 0;
370  Int_t nl0times(0);
371  fCaloTriggers->GetNL0Times(nl0times);
372  if(nl0times) {
373  TArrayI l0times(nl0times);
374  fCaloTriggers->GetL0Times(l0times.GetArray());
375  for(int itime = 0; itime < nl0times; itime++){
376  if(l0times[itime] >7 && l0times[itime] < 10){
377  time = l0times[itime];
378  break;
379  }
380  }
381  }
382 
383  fastor.Initialize(L0amp, L1amp, globRow, globCol, time, fGeom);
384 
385  GetTriggerQA(fCentBin)->ProcessFastor(&fastor);
386  }
387  }
388  GetTriggerQA(fCentBin)->EventCompleted();
389 
390  return kTRUE;
391 }
392 
397 {
398  Double_t contents[20] = {0};
399 
400  Double_t DCalmedian[3] = {0};
401  Double_t EMCalmedian[3] = {0};
402 
403  GetTriggerQA(fCentBin)->GetDCalMedian(DCalmedian);
404  GetTriggerQA(fCentBin)->GetEMCalMedian(EMCalmedian);
405 
406  for (Int_t i = 0; i < fHistEventQA->GetNdimensions(); i++) {
407  TString title(fHistEventQA->GetAxis(i)->GetTitle());
408  if (title=="Centrality %")
409  contents[i] = fCent;
410  else if (title=="DCal median (offline)")
411  contents[i] = DCalmedian[2];
412  else if (title=="EMCal median (offline)")
413  contents[i] = EMCalmedian[2];
414  else if (title=="DCal median (recalc)")
415  contents[i] = DCalmedian[1];
416  else if (title=="EMCal median (recalc)")
417  contents[i] = EMCalmedian[1];
418  else
419  AliWarning(Form("Unable to fill dimension %s!",title.Data()));
420  }
421 
422  fHistEventQA->Fill(contents);
423 }
424 
430 {
431  fADCperBin = n;
432 
433  for (Int_t i = 0; i < fNcentBins; i++) {
434  GetTriggerQA(i)->SetADCperBin(n);
435  }
436 }
437 
443 {
444  fBkgPatchType = t;
445 
446  for (Int_t i = 0; i < fNcentBins; i++) {
447  GetTriggerQA(i)->SetBkgPatchType(t);
448  }
449 }
450 
456 {
457  if (n <= 0) n = 0;
458 
459  // delete superflouos items in fEMCALTriggerQA
460  for (Int_t i = n; i < fNcentBins; i++) {
461  fEMCALTriggerQA->RemoveAt(i);
462  }
463 
464  for (Int_t i = fNcentBins; i < n; i++) {
465  TString qaName(Form("%s_AliEMCALTriggerQA_Cent%d", GetName(), i));
466  if (fEMCALTriggerQA->At(0)) {
467  AliEMCALTriggerQA* triggerQA = new AliEMCALTriggerQA(*(static_cast<AliEMCALTriggerQA*>(fEMCALTriggerQA->At(0))));
468  triggerQA->SetName(qaName);
469  triggerQA->SetTitle(qaName);
470  fEMCALTriggerQA->AddAt(triggerQA, i);
471  }
472  else {
473  fEMCALTriggerQA->AddAt(new AliEMCALTriggerQA(qaName), i);
474  }
475  }
476 
477  fNcentBins = n;
478 }
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
forced beam type
Int_t fNcentBins
how many centrality bins
Double_t fCent
!event centrality
TObjArray * fEMCALTriggerQA
produces the QA histograms
Int_t fBkgPatchType
Background patch type.
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 the task has been already initialized
AliEMCALTriggerQA * GetTriggerQA(Int_t i=0)