AliPhysics  32b88a8 (32b88a8)
 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-2016, 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 <AliESDEvent.h>
20 #include <AliEMCALTriggerOnlineQAPbPb.h>
21 #include <AliEMCALTriggerQA.h>
22 #include <AliEMCALTriggerPatchInfo.h>
23 #include <AliEMCALTriggerFastOR.h>
24 #include <AliEMCALTriggerConstants.h>
25 #include <AliEMCALTriggerOnlineQAPP.h>
26 
28 #include "AliEmcalTriggerQATask.h"
29 
30 using namespace EMCALTrigger;
31 
35 
41  fTriggerPatchesName("EmcalTriggers"),
42  fEMCALTriggerQA(),
43  fADCperBin(20),
44  fMinAmplitude(0),
45  fDCalPlots(kTRUE),
46  fMinTimeStamp(0),
47  fMaxTimeStamp(0),
48  fTimeStampBinWidth(0),
49  fTriggerPatches(0),
50  fESDEvent(0)
51 {
52 }
53 
59  AliAnalysisTaskEmcalLight(name,kTRUE),
60  fTriggerPatchesName("EmcalTriggers"),
61  fEMCALTriggerQA(),
62  fADCperBin(20),
63  fMinAmplitude(0),
64  fDCalPlots(kTRUE),
65  fMinTimeStamp(0),
66  fMaxTimeStamp(0),
67  fTimeStampBinWidth(0),
68  fTriggerPatches(0),
69  fESDEvent(0)
70 {
71  // Constructor.
73 
74  SetNCentBins(nCentBins);
75 
76  if (nCentBins == 0) {
77  AliInfo("Setting up the task for pp collisions.");
79  fEMCALTriggerQA.SetLast(0);
80  if (online){
81  fEMCALTriggerQA.AddAt(new AliEMCALTriggerOnlineQAPP(name), 0);
82  }
83  else {
84  fEMCALTriggerQA.AddAt(new AliEMCALTriggerOfflineQAPP(name), 0);
85  }
86  }
87  else {
88  AliInfo("Setting up the task for PbPb collisions.");
89  // No offline class for PbPb... yet
91  fEMCALTriggerQA.SetLast(nCentBins-1);
92  for (Int_t i = 0; i < nCentBins; i++) {
93  fEMCALTriggerQA.AddAt(new AliEMCALTriggerOnlineQAPbPb(name), i);
94  }
95  }
96 
97  fEMCALTriggerQA.SetOwner(kTRUE);
98 }
99 
104 {
105 }
106 
111 {
113 
114  fESDEvent = dynamic_cast<AliESDEvent*>(InputEvent());
115 
116  if (!fESDEvent){
117  fMinTimeStamp = 0;
118  fMaxTimeStamp = 0;
119  fTimeStampBinWidth = 0;
120  }
121 
122  if (!fInitialized) return;
123 
124  fTriggerPatches = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTriggerPatchesName));
125 
126  if (fTriggerPatches) {
127  TString objname(fTriggerPatches->GetClass()->GetName());
128  TClass cls(objname);
129  if (!cls.InheritsFrom("AliEMCALTriggerPatchInfo")) {
130  AliError(Form("%s: Objects of type %s in %s are not inherited from AliEMCALTriggerPatchInfo!",
131  GetName(), cls.GetName(), fTriggerPatchesName.Data()));
132  fTriggerPatches = 0;
133  }
134  }
135 
136  if (!fTriggerPatches) {
137  fInitialized = kFALSE;
138  AliError(Form("%s: Unable to get trigger patch container with name %s. Aborting", GetName(), fTriggerPatchesName.Data()));
139  return;
140  }
141 
142  for (Int_t i = 0; i < fNcentBins; i++) {
143  GetTriggerQA(i)->ExecOnce();
144  }
145 }
146 
151 {
153 
154  if (fOutput) {
155  for (Int_t i = 0; i < fNcentBins; i++) {
156  GetTriggerQA(i)->EnableHistogramsByTimeStamp(fTimeStampBinWidth);
157  GetTriggerQA(i)->SetDebugLevel(DebugLevel());
158  GetTriggerQA(i)->Init();
159  fOutput->Add(GetTriggerQA(i)->GetListOfHistograms());
160 
161  AliEMCALTriggerOfflineQAPP* triggerOffline = dynamic_cast<AliEMCALTriggerOfflineQAPP*>(GetTriggerQA(i));
162  if (triggerOffline) {
163  triggerOffline->EnableDCal(fDCalPlots);
164  }
165  }
166 
167  PostData(1, fOutput);
168  }
169 }
170 
176 {
177  return kTRUE;
178 }
179 
180 
186 {
187  if (fESDEvent) {
188  if (fESDEvent->GetTimeStamp() < fMinTimeStamp) return kFALSE;
189  if (fMaxTimeStamp > fMinTimeStamp && fESDEvent->GetTimeStamp() > fMaxTimeStamp) return kFALSE;
190  GetTriggerQA(fCentBin)->EventTimeStamp(fESDEvent->GetTimeStamp());
191  }
192 
193  if (fTriggerPatches) {
194  Int_t nPatches = fTriggerPatches->GetEntriesFast();
195 
196  AliDebug(2, Form("nPatches = %d", nPatches));
197 
198  for (Int_t i = 0; i < nPatches; i++) {
199  AliDebug(2, Form("Processing bkg patch %d", i));
200 
201  AliEMCALTriggerPatchInfo* patch = static_cast<AliEMCALTriggerPatchInfo*>(fTriggerPatches->At(i));
202  if (!patch) continue;
203  if (patch->GetADCAmp() < fMinAmplitude) continue;
204 
205  GetTriggerQA(fCentBin)->ProcessBkgPatch(patch);
206  }
207 
208  GetTriggerQA(fCentBin)->ComputeBackground();
209 
210  for (Int_t i = 0; i < nPatches; i++) {
211  AliDebug(2, Form("Processing patch %d", i));
212 
213  AliEMCALTriggerPatchInfo* patch = static_cast<AliEMCALTriggerPatchInfo*>(fTriggerPatches->At(i));
214  if (!patch) continue;
215  if (patch->GetADCAmp() < fMinAmplitude) continue;
216 
217  GetTriggerQA(fCentBin)->ProcessPatch(patch);
218  }
219  }
220 
221  if (fCaloTriggers) {
222  AliEMCALTriggerFastOR fastor;
223  fCaloTriggers->Reset();
224  Int_t globCol = -1, globRow = -1;
225  Float_t L0amp = -1;
226  Int_t L1amp = -1;
227  while (fCaloTriggers->Next()) {
228  // get position in global 2x2 tower coordinates
229  // A0 left bottom (0,0)
230  fCaloTriggers->GetPosition(globCol, globRow);
231  // for some strange reason some ADC amps are initialized in reconstruction
232  // as -1, neglect those
233  fCaloTriggers->GetL1TimeSum(L1amp);
234  if (L1amp < 0) L1amp = 0;
235  fCaloTriggers->GetAmplitude(L0amp);
236  L0amp *= 4;
237  if (L0amp < 0) L0amp = 0;
238 
239  Int_t time = -1;
240  Int_t nl0times(0);
241  fCaloTriggers->GetNL0Times(nl0times);
242  if(nl0times) {
243  TArrayI l0times(nl0times);
244  fCaloTriggers->GetL0Times(l0times.GetArray());
245  for(int itime = 0; itime < nl0times; itime++){
246  time = l0times[itime];
247  break;
248  }
249  }
250 
251  fastor.Initialize(L0amp, L1amp, globRow, globCol, time, fGeom);
252 
253  GetTriggerQA(fCentBin)->ProcessFastor(&fastor, fCaloCells);
254  }
255  }
256 
257  if (fCaloCells) {
258  const Int_t ncells = fCaloCells->GetNumberOfCells();
259  AliEMCALTriggerQA::AliEMCALCellInfo cellInfo;
260  for (Int_t pos = 0; pos < ncells; pos++) {
261  Double_t amp = fCaloCells->GetAmplitude(pos);
262  Int_t absId = fCaloCells->GetCellNumber(pos);
263  cellInfo.Set(absId, amp);
264  GetTriggerQA(fCentBin)->ProcessCell(cellInfo);
265  }
266  }
267 
268  GetTriggerQA(fCentBin)->EventCompleted();
269 
270  return kTRUE;
271 }
272 
278 {
279  fADCperBin = n;
280 
281  TIter next(&fEMCALTriggerQA);
282  AliEMCALTriggerQA* qa = 0;
283  while ((qa = static_cast<AliEMCALTriggerQA*>(next()))) {
284  qa->SetADCperBin(n);
285  }
286 }
Int_t fADCperBin
ADC counts per bin.
Int_t fNcentBins
how many centrality bins
AliEMCALGeometry * fGeom
!emcal geometry
double Double_t
Definition: External.C:58
TClonesArray * fTriggerPatches
! trigger array in
UInt_t fTimeStampBinWidth
Time stamp bin width.
Class to do some fast QA of the EMCal trigger. Useful also to tune trigger thresholds.
AliESDEvent * fESDEvent
! current ESD event
Bool_t fDCalPlots
Whether to add DCal QA plots.
TString fTriggerPatchesName
name of input trigger array
Int_t nCentBins
Class to generate EMCal trigger QA plots in pp collisions.
UInt_t fMinTimeStamp
Minimum event time stamp (only ESD)
Int_t fMinAmplitude
Minimum trigger patch amplitude.
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
Base task in the EMCAL framework (lighter version of AliAnalysisTaskEmcal)
Bool_t fInitialized
!whether or not the task has been already initialized
Int_t fCentBin
!event centrality bin
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
TObjArray fEMCALTriggerQA
produces the QA histograms
UInt_t fMaxTimeStamp
Maximum event time stamp (only ESD)
bool Bool_t
Definition: External.C:53
AliVCaloTrigger * fCaloTriggers
!calo triggers
AliEMCALTriggerQA * GetTriggerQA(Int_t i=0)