]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGUD/DIFFRACTIVE/QA/AliAnalysisTaskCPQA.cxx
05dc2b15a3ef2ffeb59795d08d2311a656b75ec5
[u/mrichter/AliRoot.git] / PWGUD / DIFFRACTIVE / QA / AliAnalysisTaskCPQA.cxx
1 // QA task for central production study
2 // author: Martin Poghosyan
3
4 #include <TList.h>
5 #include <TTree.h>
6 #include <TH1F.h>
7 #include <TH2F.h>
8 #include <TH3F.h>
9
10
11 #include "AliVEvent.h"
12 #include "AliESDEvent.h"
13 #include "AliESDtrack.h"
14 #include "AliHeader.h"
15 #include "AliESDInputHandler.h"
16 #include "AliAnalysisManager.h"
17 #include "AliMultiplicity.h"
18 #include "AliTriggerAnalysis.h"
19 #include "AliESDVertex.h"
20 #include "AliESDtrackCuts.h"
21
22 #include "AliAnalysisTaskCPQA.h"
23
24
25 ClassImp(AliAnalysisTaskCPQA)
26
27 //________________________________________________________________________
28   AliAnalysisTaskCPQA::AliAnalysisTaskCPQA(const char *name)
29   : AliAnalysisTaskSE(name),
30   fUseMC(kFALSE),
31   fESD(0),
32   fOutputList(0),
33   fhEvent(0),
34   fTriggerAnalysis(0)
35
36 {
37   for(Int_t i = 0; i<4; i++)
38     {
39       fhV0A[i]=0;
40       fhV0C[i]=0;
41       fhV0online[i]=0;
42       fhV0offline[i]=0;
43       fhSPDFiredChip[i]=0;
44       fhSPDFastOrChip[i]=0;
45       fhReferenceMultiplicity[i]=0;
46       fhVtxTrack[i]=0;
47     }
48
49   fEtaMaxM = 2;
50   fEtaMaxD = 0.9;
51   fVtxZmax = 10;
52
53   DefineOutput(1, TList::Class());
54 }
55
56 AliAnalysisTaskCPQA::~AliAnalysisTaskCPQA() 
57 {
58    if (fOutputList && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
59     printf("Deleteing output\n");
60
61     if(fOutputList){
62       delete fOutputList;
63       fOutputList = 0;
64     }
65
66         if(fTriggerAnalysis)
67           delete fTriggerAnalysis;
68
69    }
70 }
71
72
73
74
75 //________________________________________________________________________
76 void AliAnalysisTaskCPQA::UserCreateOutputObjects()
77 {
78   fTriggerAnalysis = new AliTriggerAnalysis();
79   if (fUseMC) fTriggerAnalysis->SetAnalyzeMC(1);
80
81   // Create histograms
82   // Called once
83
84   fOutputList = new TList();
85   fOutputList->SetOwner();
86
87
88   fhEvent = new TH1F("hEvent","hEvent",100, -0.5, 99.5); 
89   fOutputList->Add(fhEvent);
90
91   for(Int_t i = 0; i<4; i++)
92     {
93       fhV0A[i] = Hist2D(Form("hV0A_%d",i), 5, -1.5, 3.5, 5, -1.5, 3.5,"V0A_{online}","V0A_{offline}"); fOutputList->Add(fhV0A[i]);
94       fhV0C[i] = Hist2D(Form("hV0C_%d",i), 5, -1.5, 3.5, 5, -1.5, 3.5,"V0C_{online}","V0C_{offline}"); fOutputList->Add(fhV0C[i]);
95       fhV0online[i]  = Hist2D(Form("hV0online_%d",i) , 5, -1.5, 3.5, 5, -1.5, 3.5,"V0C_{online}","V0A_{online}"); fOutputList->Add(fhV0online[i]);
96       fhV0offline[i] = Hist2D(Form("hV0offline_%d",i), 5, -1.5, 3.5, 5, -1.5, 3.5,"V0C_{offline}","V0A_{offline}"); fOutputList->Add(fhV0offline[i]);
97       fhSPDFiredChip[i] = Hist1D(Form("fhSPDFiredChip_%d",i), 1200, -0.5, 1199.5); fOutputList->Add(fhSPDFiredChip[i]);
98       fhSPDFastOrChip[i] = Hist1D(Form("fhSPDFastOrChip_%d",i), 1200, -0.5, 1199.5); fOutputList->Add(fhSPDFastOrChip[i]);
99       fhReferenceMultiplicity[i] = Hist1D(Form("fhReferenceMultiplicity_%d",i), 50, -10.5, 39.5);  fOutputList->Add(fhReferenceMultiplicity[i]);
100       fhVtxTrack[i] = Hist3D(Form("fhVtxTrack_%d",i), 100, -1, 1, 100, -1, 1, 1000, -30, 30, "x_{vtx}", "y_{vtx}", "z_{vtx}"); fOutputList->Add(fhVtxTrack[i]);
101    }
102
103   PostData(1, fOutputList);
104  
105
106 }
107
108
109
110 TH1F* AliAnalysisTaskCPQA::Hist1D(const char* name, Int_t nBins, Double_t xMin, Double_t xMax,  const char* xLabel, Int_t color, Int_t lst, const char* yLabel)
111 {
112 // create a 1D histogram
113
114   TH1F* res = new TH1F(name, name, nBins, xMin, xMax);
115   if (xLabel) res->GetXaxis()->SetTitle(xLabel);
116   if (yLabel) res->GetYaxis()->SetTitle(yLabel);
117   res->SetLineColor(color);
118   res->SetMarkerColor(color);
119   res->SetLineStyle(lst);
120   return res;
121 }
122
123
124 TH2F *AliAnalysisTaskCPQA::Hist2D(const char* name, Int_t nBinsx, Double_t xMin, Double_t xMax, Int_t nBinsy, Double_t yMin, Double_t yMax, const char* xLabel, const char* yLabel, Int_t color)
125 {
126 // create a 2D histogram
127
128   TH2F *res = new TH2F(name, name, nBinsx, xMin, xMax, nBinsy, yMin, yMax);
129   if (xLabel) res->GetXaxis()->SetTitle(xLabel);
130   if (yLabel) res->GetYaxis()->SetTitle(yLabel);
131   //  res->SetMarkerStyle(kFullCircle);
132   //  res->SetOption("E");
133   res->SetLineColor(color);
134   //  fOutputList->Add(res);
135   return res;
136 }
137
138   TH3F *AliAnalysisTaskCPQA::Hist3D(const char* name, Int_t nBinsx, Double_t xMin, Double_t xMax, Int_t nBinsy, Double_t yMin, Double_t yMax,  Int_t nBinsz, Double_t zMin, Double_t zMax, const char* xLabel, const char* yLabel, const char *zLabel)
139 {
140 // create a 3D histogram
141
142   TH3F *res = new TH3F(name, name, nBinsx, xMin, xMax, nBinsy, yMin, yMax, nBinsz, zMin, zMax);
143   if (xLabel) res->GetXaxis()->SetTitle(xLabel);
144   if (yLabel) res->GetYaxis()->SetTitle(yLabel);
145   if (zLabel) res->GetZaxis()->SetTitle(zLabel);
146   //  res->SetMarkerStyle(kFullCircle);
147   //  res->SetOption("E");
148   //  res->SetLineColor(color);
149   //  fOutputList->Add(res);
150   return res;
151 }
152
153
154
155 //________________________________________________________________________
156 void AliAnalysisTaskCPQA::UserExec(Option_t *)
157 {
158   // Main loop
159   // Called for each event
160
161   //    return;
162   AliVEvent *event = InputEvent();
163   if (!event) {
164      Error("UserExec", "Could not retrieve event");
165      return;
166   }
167
168   fESD = dynamic_cast<AliESDEvent*> (InputEvent());
169   if (fESD) {
170     LoopESD();
171       if (fUseMC)
172          LoopESDMC();
173   }
174
175
176
177   PostData(1, fOutputList);
178 }      
179
180 //________________________________________________________________________
181 void AliAnalysisTaskCPQA::Terminate(Option_t*)
182 {
183  
184 }
185
186
187 void AliAnalysisTaskCPQA::LoopESDMC()
188 {
189   // Main loop
190   // Called for each event
191   /*
192
193   Int_t indexD1 = 1;
194   Int_t indexD2 = 2;
195
196
197   AliMCEvent *mcEvent = (AliMCEvent*) MCEvent();
198   if (!mcEvent) {
199     Error("LoopESDMC", "Could not retrieve MC event");
200     return;
201   }
202
203
204   AliHeader* header = mcEvent->Header();
205   if (!header)
206     {
207           AliDebug(AliLog::kError, "Header not available");
208           return;
209     }
210
211   AliGenEventHeader* genHeader = header->GenEventHeader();
212   if(!genHeader)
213     {
214       AliDebug(AliLog::kError, "GenHeader not available");
215       return;
216     }
217
218 */  
219  
220
221 }
222
223
224
225
226 //________________________________________________________________________
227 void AliAnalysisTaskCPQA::LoopESD()
228 {
229    Int_t TrType = 0;
230    Bool_t fkIsPhysSel = kFALSE;
231
232   fhEvent->Fill(0);
233
234   if(!fUseMC)
235     {
236       TrType = -1;
237       if(fESD->IsTriggerClassFired("CINT1-B-NOPF-ALLNOTRD"))        TrType=0;
238       else if(fESD->IsTriggerClassFired("CINT1-AC-NOPF-ALLNOTRD"))  TrType=1;
239       else if(fESD->IsTriggerClassFired("CINT1-E-NOPF-ALLNOTRD"))   TrType=3;
240
241       else if(fESD->IsTriggerClassFired("CINT1-B-NOPF-FASTNOTRD"))  TrType=0;
242       else if(fESD->IsTriggerClassFired("CINT1-AC-NOPF-FASTNOTRD")) TrType=1;
243       else if(fESD->IsTriggerClassFired("CINT1-E-NOPF-FASTNOTRD"))  TrType=3;
244
245       else if(fESD->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL"))  TrType=0;
246       else if(fESD->IsTriggerClassFired("CINT1A-ABCE-NOPF-ALL"))  TrType=1;
247       else if(fESD->IsTriggerClassFired("CINT1C-ABCE-NOPF-ALL"))  TrType=2;
248       else if(fESD->IsTriggerClassFired("CINT1-E-NOPF-ALL"))      TrType=3;
249
250       UInt_t mask =  ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
251       fkIsPhysSel=(mask & AliVEvent::kMB) ? 1 : 0; // check if minimum bias trigger class fired
252  
253
254       if(!fkIsPhysSel) return;
255       printf("TrType = %d\n",TrType);
256       if(TrType==-1) return;
257     }
258
259   fhEvent->Fill(1);
260
261
262   Int_t V0Aonline  = fTriggerAnalysis->V0Trigger(fESD, AliTriggerAnalysis::kASide, kTRUE) ;
263   Int_t V0Conline  = fTriggerAnalysis->V0Trigger(fESD, AliTriggerAnalysis::kCSide, kTRUE) ;
264   Int_t V0Aoffline = fTriggerAnalysis->V0Trigger(fESD, AliTriggerAnalysis::kASide, kFALSE) ;
265   Int_t V0Coffline = fTriggerAnalysis->V0Trigger(fESD, AliTriggerAnalysis::kCSide, kFALSE) ;
266
267
268   fhV0A[TrType]->Fill(V0Aonline, V0Aoffline);
269   fhV0C[TrType]->Fill(V0Conline, V0Coffline);
270   fhV0online[TrType]->Fill(V0Conline, V0Aonline);
271   fhV0offline[TrType]->Fill(V0Coffline, V0Aoffline);
272
273
274   if(V0Aoffline!=0 || V0Coffline!=0) 
275     {
276       return;
277     }
278  
279   fhEvent->Fill(2);
280
281   const AliMultiplicity *mult = fESD->GetMultiplicity();
282   for (Int_t i=0; i<1200; i++)
283     {
284       if(mult->TestFiredChipMap(i)) fhSPDFiredChip[TrType]->Fill(i);
285       if(mult->TestFastOrFiredChips(i)) fhSPDFastOrChip[TrType]->Fill(i);
286     }
287
288
289   fhReferenceMultiplicity[TrType]->Fill(AliESDtrackCuts::GetReferenceMultiplicity(fESD,AliESDtrackCuts::kTrackletsITSTPC,1.2));
290
291
292   const AliESDVertex *primaryTrackVtx = fESD->GetPrimaryVertexTracks();
293   if (!primaryTrackVtx->GetStatus() && !primaryTrackVtx->GetStatus() )
294     {
295       return;
296     }
297
298   fhEvent->Fill(3);
299
300   fhVtxTrack[TrType]->Fill(primaryTrackVtx->GetX(), primaryTrackVtx->GetY(), primaryTrackVtx->GetZ());
301
302
303
304   return;
305 }   
306