]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGGA/PHOSTasks/PHOS_TriggerQA/AliAnalysisTaskPHOSTriggerQA.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGGA / PHOSTasks / PHOS_TriggerQA / AliAnalysisTaskPHOSTriggerQA.cxx
CommitLineData
debeb29a 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#include "AliAnalysisManager.h"
17#include "AliAnalysisTaskSE.h"
18#include "AliAnalysisTaskPHOSTriggerQA.h"
19#include "AliESDCaloCluster.h"
20#include "AliPHOSGeometry.h"
21#include "AliESDEvent.h"
22#include "AliESDCaloCells.h"
23#include "AliLog.h"
24#include "TObjArray.h"
25#include "TList.h"
26#include "TH1.h"
27#include "TH2.h"
28
29// QA of PHOS Trigger data.
30//...
31// Author: Boris Polishchuk
32// Date : 06.02.2012
33
34ClassImp(AliAnalysisTaskPHOSTriggerQA)
35
36//________________________________________________________________________
37AliAnalysisTaskPHOSTriggerQA::AliAnalysisTaskPHOSTriggerQA() : AliAnalysisTaskSE(),
38 fOutputContainer(0),fPHOSGeo(0),fEventCounter(0)
39{
40 //Default constructor.
41 // Initialize the PHOS geometry
42 fPHOSGeo = AliPHOSGeometry::GetInstance("IHEP") ;
43
44}
45
46//________________________________________________________________________
47AliAnalysisTaskPHOSTriggerQA::AliAnalysisTaskPHOSTriggerQA(const char *name)
48: AliAnalysisTaskSE(name),
49 fOutputContainer(0),fPHOSGeo(0),fEventCounter(0)
50{
51
52 // Output slots #0 write into a TH1 container
53 DefineOutput(1,TList::Class());
54
55 // Initialize the PHOS geometry
56 fPHOSGeo = AliPHOSGeometry::GetInstance("IHEP") ;
57
58}
59
60//________________________________________________________________________
61void AliAnalysisTaskPHOSTriggerQA::UserCreateOutputObjects()
62{
63 // Create histograms
64 // Called once
65
66 // ESD histograms
67 if(fOutputContainer != NULL){
68 delete fOutputContainer;
69 }
70
71 fOutputContainer = new TList();
72 fOutputContainer->SetOwner(kTRUE);
73
74 //Bin 1: total number of processed events.
75 //Bin 2: number of events contained PHOS trigger digits.
76 fOutputContainer->Add(new TH1F("hNev","Number of events",10,0.,10.));
77
78 char key[55],titl[55];
79 Int_t nCols = 56, nRows = 64;
80
81 Int_t nPtPhot = 1000 ;
82 Double_t ptPhotMax = 100. ;
83
84 Int_t nTrMax = 1200;
85 Float_t trMax = 600.;
86
099fce1d 87 fOutputContainer->Add(new TH1F("hNtr","Number of fired 4x4 regions per event",nTrMax,0.,trMax));
debeb29a 88
89 for(Int_t sm=1; sm<4; sm++) {
90
91 snprintf(key,55,"hNtrSM%d",sm);
92 snprintf(titl,55,"Number of fired 4x4 regions in SM%d",sm);
93 fOutputContainer->Add(new TH1F(key,titl,nTrMax/3,0.,trMax/3));
94
95 snprintf(key,55,"h4x4SM%d",sm);
96 snprintf(titl,55,"SM%d 4x4 occupancy",sm);
97 fOutputContainer->Add(new TH2F(key,titl,nRows,0.,nRows,nCols,0.,nCols));
98
099fce1d 99 snprintf(key,55,"h4x4CluSM%d",sm);
100 snprintf(titl,55,"SM%d 4x4 occupancy associated with clusters (E>2GeV)",sm);
101 fOutputContainer->Add(new TH2F(key,titl,nRows,0.,nRows,nCols,0.,nCols));
102
debeb29a 103 snprintf(key,55,"hCluSM%d",sm);
104 snprintf(titl,55,"SM%d cluster occupancy",sm);
105 fOutputContainer->Add(new TH2F(key,titl,nRows,0.,nRows,nCols,0.,nCols));
106
107 snprintf(key,55,"hCluTSM%d",sm);
108 snprintf(titl,55,"SM%d triggered cluster occupancy",sm);
109 fOutputContainer->Add(new TH2F(key,titl,nRows,0.,nRows,nCols,0.,nCols));
110
111 snprintf(key,55,"hPhotAllSM%d",sm);
112 snprintf(titl,55,"SM%d cluster energy",sm);
113 fOutputContainer->Add(new TH1F(key,titl,nPtPhot,0.,ptPhotMax));
114
099fce1d 115 for(Int_t iTRU=1; iTRU<=8; iTRU++) {
116 snprintf(key,55,"hPhotAllSM%dTRU%d",sm,iTRU);
117 snprintf(titl,55,"SM%d: clusters energy in TRU%d",sm,iTRU);
118 fOutputContainer->Add(new TH1F(key,titl,nPtPhot,0.,ptPhotMax));
119 }
120
debeb29a 121 snprintf(key,55,"hPhotTrigSM%d",sm);
122 snprintf(titl,55,"SM%d triggered cluster energy",sm);
123 fOutputContainer->Add(new TH1F(key,titl,nPtPhot,0.,ptPhotMax));
099fce1d 124
125 for(Int_t iTRU=1; iTRU<=8; iTRU++) {
126 snprintf(key,55,"hPhotTrigSM%dTRU%d",sm,iTRU);
127 snprintf(titl,55,"SM%d: triggered clusters energy in TRU%d",sm,iTRU);
128 fOutputContainer->Add(new TH1F(key,titl,nPtPhot,0.,ptPhotMax));
129 }
130
debeb29a 131 }
132
133 PostData(1, fOutputContainer);
134
135}
136
137//________________________________________________________________________
138void AliAnalysisTaskPHOSTriggerQA::UserExec(Option_t *)
139{
140 // Main loop, called for each event
141 // Analyze ESD/AOD
142
143 AliESDEvent *event = dynamic_cast<AliESDEvent*>(InputEvent());
144
145 if (!event) {
146 Printf("ERROR: Could not retrieve event");
147 PostData(1, fOutputContainer);
148 return;
149 }
150
151 FillHistogram("hNev",0.); // all events
152 fEventCounter++;
153
154 AliESDCaloTrigger* trgESD = event->GetCaloTrigger("PHOS");
155 trgESD->Reset();
156
099fce1d 157 if(trgESD->GetEntries()) FillHistogram("hNev",1.); // triggered events
debeb29a 158 FillHistogram("hNtr",trgESD->GetEntries());
099fce1d 159
debeb29a 160 TString trigClasses = event->GetFiredTriggerClasses();
161 printf("\nEvent %d: %d non-zero trigger digits %s\n",
162 fEventCounter,trgESD->GetEntries(),trigClasses.Data());
163
164 // Get PHOS rotation matrices from ESD and set them to the PHOS geometry
165 char key[55] ;
166
167 if(fEventCounter == 0) {
168 for(Int_t mod=0; mod<5; mod++) {
169 if(!event->GetPHOSMatrix(mod)) continue;
170 fPHOSGeo->SetMisalMatrix(event->GetPHOSMatrix(mod),mod) ;
171 }
172 }
173
174 Int_t multClu = event->GetNumberOfCaloClusters();
175 AliESDCaloCells *phsCells = event->GetPHOSCells();
176
177 Int_t inPHOS[3] = {};
178
179 //Loop over 4x4 fired regions
180 while(trgESD->Next()) {
181
182 Int_t tmod,tabsId; // "Online" module number, bottom-left 4x4 edge cell absId
183 trgESD->GetPosition(tmod,tabsId);
184
185 Int_t trelid[4] ;
186 fPHOSGeo->AbsToRelNumbering(tabsId,trelid);
187
188 snprintf(key,55,"h4x4SM%d",trelid[0]);
189 FillHistogram(key,trelid[2]-1,trelid[3]-1);
190
191 inPHOS[trelid[0]-1]++;
192
193 for (Int_t i=0; i<multClu; i++) {
194
195 AliESDCaloCluster *c1 = event->GetCaloCluster(i);
196 if(!c1->IsPHOS()) continue;
197
099fce1d 198 if(c1->E()<0.3) continue;
199 if(c1->GetNCells()<3) continue ;
200
debeb29a 201 Int_t maxId, relid[4];
202 MaxEnergyCellPos(phsCells,c1,maxId);
203
204 fPHOSGeo->AbsToRelNumbering(maxId, relid);
205 snprintf(key,55,"hPhotAllSM%d",relid[0]);
206 FillHistogram(key,c1->E());
099fce1d 207
208 snprintf(key,55,"hPhotAllSM%dTRU%d",relid[0],GetTRUNum(relid[2]-1,relid[3]-1));
209 FillHistogram(key,c1->E());
debeb29a 210
211 snprintf(key,55,"hCluSM%d",relid[0]);
212 FillHistogram(key,relid[2]-1,relid[3]-1);
213
214 if( Matched(trelid,relid) ) {
215
216 snprintf(key,55,"hPhotTrigSM%d",relid[0]);
217 FillHistogram(key,c1->E());
099fce1d 218
219 snprintf(key,55,"hPhotTrigSM%dTRU%d",relid[0],GetTRUNum(relid[2]-1,relid[3]-1));
220 FillHistogram(key,c1->E());
debeb29a 221
222 snprintf(key,55,"hCluTSM%d",relid[0]);
223 FillHistogram(key,relid[2]-1,relid[3]-1);
224
099fce1d 225 if(c1->E()>2.) { // Eclu > 2 GeV
226 snprintf(key,55,"h4x4CluSM%d",trelid[0]);
227 FillHistogram(key,trelid[2]-1,trelid[3]-1);
228 }
debeb29a 229 continue;
230 }
231
232 }
233 } //while(trgESD->Next())
234
235 for(Int_t sm=1; sm<4; sm++) {
236 snprintf(key,55,"hNtrSM%d",sm);
237 if(inPHOS[sm-1]) FillHistogram(key,inPHOS[sm-1]);
238 }
239
240 // Post output data.
241 PostData(1, fOutputContainer);
242
243}
244
245//_____________________________________________________________________________
246void AliAnalysisTaskPHOSTriggerQA::FillHistogram(const char * key,Double_t x)const{
247 //FillHistogram
248 TH1I * tmpI = dynamic_cast<TH1I*>(fOutputContainer->FindObject(key)) ;
249 if(tmpI){
250 tmpI->Fill(x) ;
251 return ;
252 }
253 TH1F * tmpF = dynamic_cast<TH1F*>(fOutputContainer->FindObject(key)) ;
254 if(tmpF){
255 tmpF->Fill(x) ;
256 return ;
257 }
258 TH1D * tmpD = dynamic_cast<TH1D*>(fOutputContainer->FindObject(key)) ;
259 if(tmpD){
260 tmpD->Fill(x) ;
261 return ;
262 }
263 AliInfo(Form("can not find histogram <%s> ",key)) ;
264}
265//_____________________________________________________________________________
266void AliAnalysisTaskPHOSTriggerQA::FillHistogram(const char * key,Double_t x,Double_t y)const{
267 //FillHistogram
268 TObject * tmp = fOutputContainer->FindObject(key) ;
269 if(!tmp){
270 AliInfo(Form("can not find histogram <%s> ",key)) ;
271 return ;
272 }
273 if(tmp->IsA() == TClass::GetClass("TH1F")){
274 ((TH1F*)tmp)->Fill(x,y) ;
275 return ;
276 }
277 if(tmp->IsA() == TClass::GetClass("TH2F")){
278 ((TH2F*)tmp)->Fill(x,y) ;
279 return ;
280 }
281 AliError(Form("Calling FillHistogram with 2 parameters for histo <%s> of type %s",key,tmp->IsA()->GetName())) ;
282}
283
284//_____________________________________________________________________________
285void AliAnalysisTaskPHOSTriggerQA::MaxEnergyCellPos(AliESDCaloCells *cells, AliESDCaloCluster* clu, Int_t& maxId)
286{
287 Double_t eMax = -111;
288
289 for (Int_t iDig=0; iDig< clu->GetNCells(); iDig++) {
290 Int_t cellAbsId = clu->GetCellAbsId(iDig);
291 Double_t eCell = cells->GetCellAmplitude(cellAbsId)*clu->GetCellAmplitudeFraction(iDig);
292 if(eCell>eMax) {
293 eMax = eCell;
294 maxId = cellAbsId;
295 }
296 }
297
298}
299
300//_____________________________________________________________________________
301Bool_t AliAnalysisTaskPHOSTriggerQA::Matched(Int_t *trig_relid, Int_t *cluster_relid)
302{
303 //Returns kTRUE if cluster position coincides with 4x4 position.
304
305 if( trig_relid[0] != cluster_relid[0] ) return kFALSE; // different modules!
306 if( TMath::Abs(trig_relid[2]-cluster_relid[2])>3 ) return kFALSE; // X-distance too large!
307 if( TMath::Abs(trig_relid[3]-cluster_relid[3])>3 ) return kFALSE; // Z-distance too large!
308
309 return kTRUE;
310}
099fce1d 311
312//_______________________________________________________________________________
313Int_t AliAnalysisTaskPHOSTriggerQA::GetTRUNum(Int_t cellX, Int_t cellZ)
314{
315 //Return TRU region number for given cell.
316 //cellX: [0-63], cellZ: [0-55]
317
318 Int_t iTRU=-111;
319
320 //RCU0: TRU 1,2
321 if(0<=cellX&&cellX<16) {
322
323 if(0<=cellZ&&cellZ<28) iTRU=2;
324 else iTRU=1;
325 }
326
327 //RCU1: TRU 3,4
328 if(16<=cellX&&cellX<32) {
329
330 if(0<=cellZ&&cellZ<28) iTRU=4;
331 else iTRU=3;
332 }
333
334 //RCU2: TRU 5,6
335 if(32<=cellX&&cellX<48) {
336
337 if(0<=cellZ&&cellZ<28) iTRU=6;
338 else iTRU=5;
339 }
340
341 //RCU3: TRU 7,8
342 if(48<=cellX&&cellX<64) {
343
344 if(0<=cellZ&&cellZ<28) iTRU=8;
345 else iTRU=7;
346 }
347
348 return iTRU;
349}