Correct method combining conversion photons and calorimeter clusters, now fill also...
[u/mrichter/AliRoot.git] / PWG4 / UserTasks / EmcalTasks / AliAnalysisTaskEMCALTriggerQA.cxx
CommitLineData
bce9493b 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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
16//------------------------------------------------------------------------//
17// Fill histograms with basic QA information for EMCAL offline trigger //
18// Author: Nicolas Arbor (LPSC-Grenoble) //
19// Gustavo Conesa Balbastre (LPSC-Grenoble) //
20// //
21//------------------------------------------------------------------------//
22
23
24#include <TList.h>
25#include <TH1F.h>
26#include <TH2F.h>
27#include <TF1.h>
28
29#include "AliLog.h"
30#include "AliVCluster.h"
31#include "AliVCaloCells.h"
32#include "AliVEvent.h"
33#include "AliESDEvent.h"
34#include "AliESDVZERO.h"
35#include "AliESDCaloTrigger.h"
36#include "AliEMCALGeometry.h"
37
38#include "AliAnalysisTaskEMCALTriggerQA.h"
39
40ClassImp(AliAnalysisTaskEMCALTriggerQA)
41
85196c29 42//______________________________________________________________
bce9493b 43AliAnalysisTaskEMCALTriggerQA::AliAnalysisTaskEMCALTriggerQA() :
44AliAnalysisTaskSE(),
45fOutputList(0),
46fGeometry(0), fGeoName("EMCAL_COMPLETEV1"),
47fhNEvents(0),
48fhFORPos(0),
49fhL0Pos(0),
50fhL1Pos(0),
51fhL0Patch(0),
52fhL1GPatch(0),
53fhL1JPatch(0),
85196c29 54fhFEESTU(0),
55fhTRUSTU(0),
bce9493b 56fhV0STU(0),
57fhFullTRUSTU(0),
58fhSTUChecks(0),
85196c29 59fNBinsSTUSignal (2000), fMaxSTUSignal (200000),
60fNBinsTRUSignal (2000), fMaxTRUSignal (200000),
61fNBinsV0Signal (2000), fMaxV0Signal (20000),
62fNBinsSTUFEERatio(2000), fMaxSTUFEERatio(20000),
63fNBinsSTUTRURatio(2000), fMaxSTUTRURatio(200)
bce9493b 64
65{
66 // Constructor
bce9493b 67
68}
69
85196c29 70//______________________________________________________________________________
bce9493b 71AliAnalysisTaskEMCALTriggerQA::AliAnalysisTaskEMCALTriggerQA(const char *name) :
72AliAnalysisTaskSE(name),
73fOutputList(0),
74fGeometry(0), fGeoName("EMCAL_COMPLETEV1"),
75fhNEvents(0),
76fhFORPos(0),
77fhL0Pos(0),
78fhL1Pos(0),
79fhL0Patch(0),
80fhL1GPatch(0),
81fhL1JPatch(0),
85196c29 82fhFEESTU(0),
83fhTRUSTU(0),
bce9493b 84fhV0STU(0),
85fhFullTRUSTU(0),
86fhSTUChecks(0),
85196c29 87fNBinsSTUSignal (2000), fMaxSTUSignal (200000),
88fNBinsTRUSignal (2000), fMaxTRUSignal (200000),
89fNBinsV0Signal (2000), fMaxV0Signal (20000),
90fNBinsSTUFEERatio(2000), fMaxSTUFEERatio(20000),
91fNBinsSTUTRURatio(2000), fMaxSTUTRURatio(200)
bce9493b 92
93{
94 // Constructor
bce9493b 95
96 DefineOutput(1, TList::Class());
97
98}
99
100
85196c29 101//___________________________________________________________
bce9493b 102void AliAnalysisTaskEMCALTriggerQA::UserCreateOutputObjects()
103{
104 // Init histograms and geometry
105
106 fGeometry = AliEMCALGeometry::GetInstance(fGeoName);
107
85196c29 108 fOutputList = new TList;
109 fOutputList ->SetOwner(kTRUE);
bce9493b 110
85196c29 111 fhNEvents = new TH1F("hNEvents","Number of selected events",1,0,1);
112 fhNEvents ->SetYTitle("N events");
bce9493b 113
85196c29 114 fhFORPos = new TH2F("hFORPos", "FEE cells deposited energy, grouped like FastOR 2x2 per Row and Column",fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
115 fhFORPos ->SetXTitle("Index #eta (collumns)");
116 fhFORPos ->SetYTitle("Index #phi (rows)");
bce9493b 117
85196c29 118 fhL0Pos = new TH2F("hL0Pos","FALTRO signal per Row and Column",fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
119 fhL0Pos ->SetXTitle("Index #eta (collumns)");
120 fhL0Pos ->SetYTitle("Index #phi (rows)");
bce9493b 121
85196c29 122 fhL1Pos = new TH2F("hL1Pos","STU signal per Row and Column",fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
123 fhL1Pos ->SetXTitle("Index #eta (collumns)");
124 fhL1Pos ->SetYTitle("Index #phi (rows)");
bce9493b 125
85196c29 126 fhL0Patch = new TH2F("hL0Patch","FOR with associated L0 Patch",fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
127 fhL0Patch ->SetXTitle("Index #eta (collumns)");
128 fhL0Patch ->SetYTitle("Index #phi (rows)");
bce9493b 129
85196c29 130 fhL1GPatch = new TH2F("hL1GPatch","FOR with associated L1 Gamma Patch",fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
131 fhL1GPatch ->SetXTitle("Index #eta (collumns)");
132 fhL1GPatch ->SetYTitle("Index #phi (rows)");
bce9493b 133
85196c29 134 fhL1JPatch = new TH2F("hL1JPatch","FOR with associated L1 Jet Patch",fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
135 fhL1JPatch ->SetXTitle("Index #eta (collumns)");
136 fhL1JPatch ->SetYTitle("Index #phi (rows)");
bce9493b 137
85196c29 138 fhFullTRUSTU = new TH2I("hFullTRUSTU","Total signal STU vs TRU",fNBinsTRUSignal,0,fMaxTRUSignal,fNBinsSTUSignal,0,fMaxSTUSignal);
bce9493b 139 fhFullTRUSTU->SetXTitle("Total signal TRU");
140 fhFullTRUSTU->SetYTitle("Total signal STU");
141
85196c29 142 fhV0STU = new TH2I("hV0STU","Total signal STU vs V0C+V0S",fNBinsV0Signal,0,fMaxV0Signal,fNBinsSTUSignal,0,fMaxSTUSignal);
143 fhV0STU ->SetXTitle("Signal V0C+V0A");
144 fhV0STU ->SetYTitle("Total signal STU");
bce9493b 145
85196c29 146 fhSTUChecks = new TH2I("hSTUChecks","Check FEE/STU link",2,0,2,15,0,15);
147 fhSTUChecks ->SetXTitle("Index #eta");
148 fhSTUChecks ->SetYTitle("Index #phi");
bce9493b 149
85196c29 150 fhFEESTU = new TH2F("hFEESTU","STU / FEE vs channel", fNBinsSTUFEERatio,0,fMaxSTUFEERatio,30,0,30);
151 fhFEESTU ->SetXTitle("STU/FEE signal");
152 fhFEESTU ->SetYTitle("channel");
153
154 fhTRUSTU = new TH2F("hTRUSTU","STU / TRU vs channel", fNBinsSTUTRURatio,0,fMaxSTUTRURatio,30,0,30);
155 fhTRUSTU ->SetXTitle("STU/TRU signal");
156 fhTRUSTU ->SetYTitle("channel");
bce9493b 157
158 fOutputList->Add(fhNEvents);
159 fOutputList->Add(fhV0STU);
160 fOutputList->Add(fhFORPos);
161 fOutputList->Add(fhL0Pos);
162 fOutputList->Add(fhL1Pos);
163 fOutputList->Add(fhL0Patch);
164 fOutputList->Add(fhL1GPatch);
165 fOutputList->Add(fhL1JPatch);
166 fOutputList->Add(fhFullTRUSTU);
167 fOutputList->Add(fhSTUChecks);
85196c29 168 fOutputList->Add(fhFEESTU);
169 fOutputList->Add(fhTRUSTU);
bce9493b 170
171 PostData(1, fOutputList);
172
173}
85196c29 174//______________________________________________________
bce9493b 175void AliAnalysisTaskEMCALTriggerQA::UserExec(Option_t *)
176{
177 // Main loop
bce9493b 178
179 AliVEvent* event = InputEvent();
180
181 //Remove next lines when AODs ready
182 AliESDEvent *esdEvent = dynamic_cast<AliESDEvent*>(event);
183
184 if (!esdEvent)
185 {
186 AliError("Work only with ESDs, not available, exit");
187 return;
188 }
189
190 fhNEvents->Fill(0);
191
bce9493b 192 //map for cells and patches
193
85196c29 194 Double_t emcalCell [fgkFALTRORows][fgkFALTROCols], emcalTrigL0 [fgkFALTRORows][fgkFALTROCols], emcalTrigL1 [fgkFALTRORows][fgkFALTROCols];
bce9493b 195 Double_t emcalPatchL0[fgkFALTRORows][fgkFALTROCols], emcalPatchL1G[fgkFALTRORows][fgkFALTROCols], emcalPatchL1J[fgkFALTRORows][fgkFALTROCols];
196
197 for (Int_t i = 0; i < fgkFALTRORows; i++)
198 {
199 for (Int_t j = 0; j < fgkFALTROCols; j++)
200 {
85196c29 201 emcalTrigL0[i][j] = 0.;
202 emcalTrigL1[i][j] = 0.;
203 emcalCell[i][j] = 0.;
204 emcalPatchL0[i][j] = 0.;
bce9493b 205 emcalPatchL1G[i][j] = 0.;
206 emcalPatchL1J[i][j] = 0.;
207 }
208 }
209
210 // ---------------------------------
211 // Cells analysis
212 // Fill FEE energy per channel array
213 // ---------------------------------
214
215 Int_t posX = -1, posY = -1;
216 Int_t nSupMod = -1, ieta = -1, iphi = -1, nModule = -1, nIphi = -1, nIeta = -1;
217 Short_t absId = -1;
218 Int_t nCells = 0;
219
220 AliVCaloCells& cells= *(event->GetEMCALCells());
221
222 if (cells.IsEMCAL())
223 {
224 for (Int_t icell = 0; icell < cells.GetNumberOfCells(); icell++)
225 {
226 nCells ++;
227
228 Double_t amp =0., time = 0.;
229
230 cells.GetCell(icell, absId, amp, time);
231
232 fGeometry->GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
233 fGeometry->GetCellPhiEtaIndexInSModule(nSupMod, nModule, nIphi, nIeta, iphi, ieta);
234
235 posX = (nSupMod % 2) ? ieta + AliEMCALGeoParams::fgkEMCALCols : ieta;
236 posY = iphi + AliEMCALGeoParams::fgkEMCALRows * int(nSupMod / 2);
bce9493b 237
85196c29 238 if(int(posX/2) > fgkFALTROCols || int(posY/2) > fgkFALTRORows ) {
239 printf("AliAnalysisTaskEMCALTriggerQA::UserExec() - Wrong Position (x,y) = (%d,%d)\n",posX,posY);
240 continue;
241 }
242
243 emcalCell[int(posY/2)][int(posX/2)] += amp;
244
bce9493b 245 }
246 }
247
85196c29 248 //-------------------------------------
249 // Trigger analysis, fill L0, L1 arrays
250 //-------------------------------------
bce9493b 251
252 AliESDCaloTrigger& trg= * (esdEvent->GetCaloTrigger("EMCAL"));
253
254 Int_t nL0Patch = 0 ;
255 Int_t nL1Patch = 0 ;
256 Double_t totSTU = 0.;
257 Double_t totTRU = 0.;
258
259 trg.Reset();
260 while (trg.Next())
261 {
262 trg.GetPosition(posX,posY);
263
264
265 if (posX > -1 && posY > -1)
266 {
267 //L0 analysis
268 Int_t nTimes = 0;
269 trg.GetNL0Times(nTimes);
85196c29 270
bce9493b 271 if (nTimes)
272 {
273 nL0Patch += nTimes;
274 Float_t ampL0 = 0.;
275 trg.GetAmplitude(ampL0);
85196c29 276 emcalTrigL0 [posY][posX] = ampL0;
bce9493b 277 emcalPatchL0[posY][posX] = 1.;
278 totTRU += ampL0;
279 fhL0Patch->Fill(posX-1,posY-1);//-1 is used to compare in good way patch L0 and patch L1
280 }
281
282 //L1 analysis
283 Int_t bit = 0;
284 trg.GetTriggerBits(bit);
285
286 //L1-Gamma
287 if (bit >> 4 & 0x1)
288 {
289 nL1Patch ++;
290 emcalPatchL1G[posY][posX] = 1.;
291 fhL1GPatch->Fill(posX,posY);
292
293 Int_t ts = 0;
294 trg.GetL1TimeSum(ts);
295 emcalTrigL1[posY][posX] += ts;
85196c29 296 //printf("Gamma STU patch %d, time sum %d, posX %d , posY %d\n",nL1Patch,ts,posX, posY);
bce9493b 297 totSTU += ts;
298 }
299
300 //L1-Jet
301 if (bit >> 5 & 0x1)
302 {
303 nL1Patch ++;
304 emcalPatchL1J[posY][posX] = 1.;
305 fhL1JPatch->Fill(posX,posY);
306
307 Int_t ts = 0;
308 trg.GetL1TimeSum(ts);
309 emcalTrigL1[posY][posX] += ts;
85196c29 310 //printf("Jet STU patch %d, time sum %d, posX %d , posY %d\n",nL1Patch,ts,posX, posY);
bce9493b 311 totSTU += ts;
312 }
313
314 }
315 }
316
85196c29 317 if(totTRU > fMaxTRUSignal)printf("AliAnalysisTaskEMCALTriggerQA::UserExec() - Large totTRU %f\n",totTRU);
318 if(totSTU > fMaxSTUSignal)printf("AliAnalysisTaskEMCALTriggerQA::UserExec() - Large totSTU %f\n",totSTU);
bce9493b 319
320 if (totTRU != 0) fhFullTRUSTU->Fill(totTRU,totSTU);
321
322 //V0 analysis
323 AliESDVZERO* eventV0 = esdEvent->GetVZEROData();
324
325 Float_t v0C = 0, v0A = 0;
326
327 if (eventV0)
328 {
329 for (Int_t i = 0; i < 32; i++)
330 {
331 v0C += eventV0->GetAdcV0C(i);
332 v0A += eventV0->GetAdcV0A(i);
333 }
334 }
335
336 if (totSTU != 0) {
337 fhV0STU->Fill(v0A+v0C,totSTU);
85196c29 338 if( v0A+v0C > fMaxV0Signal) printf("AliAnalysisTaskEMCALTriggerQA::UserExec() - Large v0A+v0C %f\n",v0A+v0C);
bce9493b 339 }
340
85196c29 341 //if(nL0Patch!=0 || nL1Patch!=0) printf("total TRU %f, total STU %f, V0C+V0A %f; nL0 %d, nL1 %d \n",
342 // totTRU,totSTU,v0A+v0C,nL0Patch,nL1Patch);
343
344
bce9493b 345 //Matrix with signal per channel
346 for (Int_t i = 0; i < fgkFALTRORows-1; i++)
347 {
348 for (Int_t j = 0; j < fgkFALTROCols-1; j++) //check x,y direction for reading FOR ((0,0) = top left);
349 {
350 fhFORPos->Fill(fgkFALTROCols-j, i, emcalCell [i][j]);
351 fhL0Pos ->Fill(fgkFALTROCols-j, i, emcalTrigL0[i][j]);
352 fhL1Pos ->Fill(fgkFALTROCols-j, i, emcalTrigL1[i][j]);
353 }
354 }
355
356 //TRU checks
357 Double_t ampFOR[30] = {0.}, ampL0[30] = {0.}, ampL1[30] = {0.};
358 for (Int_t i = 0; i < fgkFALTRORows-1; i++)
359 {
360 for (Int_t j = 0; j < fgkFALTROCols-1; j++) //A-side
361 {
362
363 //method to get TRU number
85196c29 364 Int_t idFOR = -1;
365 fGeometry->GetAbsFastORIndexFromPositionInEMCAL(j,i,idFOR);
366 Int_t iTRU = -1;
367 Int_t iADC = -1;
368 fGeometry->GetTRUFromAbsFastORIndex(idFOR,iTRU,iADC);
369 //printf("i %d, j %d, iTRU %d, iADC %d, idFOR %d; cell %f, L0 %f, L1 %f\n",
370 // i,j,iTRU,iADC,idFOR, emcalCell [i][j],emcalTrigL0[i][j],emcalTrigL1[i][j]);
bce9493b 371 if (iTRU >= 0)
372 {
373 ampFOR[iTRU] += emcalCell [i][j];
374 ampL0[iTRU] += emcalTrigL0[i][j];
375 ampL1[iTRU] += emcalTrigL1[i][j];
376 }
377 }
378 }
379
85196c29 380 // FEE vs STU and TRU vs STU ratios
bce9493b 381 for (Int_t i = 0; i < 30; i++)
382 {
85196c29 383
384 if (ampFOR[i] != 0 && ampL1[i] != 0) {
385 fhFEESTU->Fill(ampL1[i]/ampFOR[i],i);
386 if(ampL1[i]/ampFOR[i] > fMaxSTUFEERatio) printf("AliAnalysisTaskEMCALTriggerQA::UserExec() - Large STU/FEE ratio %f\n",ampL1[i]/ampFOR[i]);
387 }
388
389 if (ampL0[i] != 0 && ampL1[i] != 0) {
390 fhTRUSTU->Fill(ampL1[i]/ampL0[i] ,i);
391 if(ampL1[i]/ampL0[i] > fMaxSTUTRURatio) printf("AliAnalysisTaskEMCALTriggerQA::UserExec() - Large STU/TRU ratio %f\n",ampL1[i]/ampL0[i]);
392 }
393
bce9493b 394 }
395
bce9493b 396 PostData(1, fOutputList);
397
398}
399
85196c29 400//_______________________________________________________
401void AliAnalysisTaskEMCALTriggerQA::Terminate(Option_t *)
402{
403 // Terminate analysis
404 // Do some plots
405
406 Int_t checkSTU[30];
407 for (Int_t i = 0; i < 30; i++)
408 {
409 checkSTU[i] = 1 ; // Init array
410 TH1F* hTRUSTUChannel = (TH1F*) fhTRUSTU->ProjectionY(Form("hTRUSTUChannel%d",i),i,i);
411 //printf("AliAnalysisTaskEMCALTriggerQA::Terminate() - Channel %d TRUSTU Entries %d, Integral(10,20) %f ",
412 // i, hTRUSTUChannel->GetEntries(), hTRUSTUChannel->Integral(10,20));
413 if (hTRUSTUChannel->GetEntries() > 0 &&
414 hTRUSTUChannel->Integral(10,20)/hTRUSTUChannel->GetEntries() < 0.9)
415 checkSTU[i] = 0;
416 else if(hTRUSTUChannel->GetEntries() <= 0)
417 checkSTU[i] = 0;
418
419 //printf(" - %d\n",checkSTU[i]);
420 delete hTRUSTUChannel;
421 }
422
423 for (Int_t i = 0; i < 30; i++)
424 {
425 if (i<15) fhSTUChecks->Fill(0.,i,checkSTU[i]);
426 else fhSTUChecks->Fill(1.,i,checkSTU[i]);
427 }
428
429}