T0 QA Task
[u/mrichter/AliRoot.git] / T0 / AliT0AnalysisTaskQA.cxx
CommitLineData
2d3c1146 1#include "TChain.h"
2#include "TTree.h"
3#include "TH1F.h"
4#include "TF1.h"
5#include "TH2F.h"
6#include "TCanvas.h"
7#include "TObjArray.h"
8
9#include "AliAnalysisTask.h"
10#include "AliAnalysisManager.h"
11
12#include "AliESDEvent.h"
13#include "AliESDInputHandler.h"
14
15#include "AliT0AnalysisTaskQA.h"
16
17//#include "AliCDBMetaData.h"
18//#include "AliCDBId.h"
19//#include "AliCDBEntry.h"
20//#include "AliCDBManager.h"
21//#include "AliCDBStorage.h"
22
23// Task should calculate channels offset
24// Authors: Alla
25
26ClassImp(AliT0AnalysisTaskQA)
27//________________________________________________________________________
28AliT0AnalysisTaskQA::AliT0AnalysisTaskQA()
29 : AliAnalysisTaskSE(), fESD(0x0), fTzeroObject(0x0),
30 fTzeroORA(0x0), fTzeroORC(0x0), fResolution(0x0), fTzeroORAplusORC(0x0),
31 fRunNumber(0),fTimeVSAmplitude(0x0),fCFDVSPmtId(0x0),fSPDVertexVST0Vertex(0x0),
32 fOrAvsNtracks(0), fOrCvsNtracks(0), fT0vsNtracks(0)
33{
34 // Constructor
35
36 // Define input and output slots here
37 // Input slot #0 works with a TChain
38
39// ########### NEVER define slots in the IO constructor
40// DefineInput(0, TChain::Class());
41// DefineOutput(1, TObjArray::Class());
42}
43
44
45//________________________________________________________________________
46AliT0AnalysisTaskQA::AliT0AnalysisTaskQA(const char *name)
47 : AliAnalysisTaskSE(name), fESD(0x0), fTzeroObject(0x0),
48 fTzeroORA(0x0), fTzeroORC(0x0), fResolution(0x0), fTzeroORAplusORC(0x0),
49 fRunNumber(0),fTimeVSAmplitude(0x0),fCFDVSPmtId(0x0),fSPDVertexVST0Vertex(0x0),
50 fOrAvsNtracks(0), fOrCvsNtracks(0), fT0vsNtracks(0)
51{
52 // Constructor
53 // Define input and output slots here
54 // Input slot #0 works with a TChain
55 DefineInput(0, TChain::Class());
56 DefineOutput(1, TObjArray::Class());
57 // Output slot #0 id reserved by the base class for AOD
58 // Output slot #1 writes into a TH1 container
59}
60
61//________________________________________________________________________
62AliT0AnalysisTaskQA::~AliT0AnalysisTaskQA()
63{
64 // Destructor
65 // printf("AliT0CalibOffsetChannels~AliT0CalibOffsetChannels() ");
66 delete fTzeroORA;
67 delete fTzeroORC;
68 delete fResolution;
69 delete fTzeroORAplusORC;
70 delete [] fTimeVSAmplitude;
71 delete fCFDVSPmtId;
72 delete fSPDVertexVST0Vertex;
73 delete fOrAvsNtracks;
74 delete fOrCvsNtracks;
75 delete fT0vsNtracks;
76
77 delete fTzeroObject;
78}
79
80//------------------------------------------------------------------
81void AliT0AnalysisTaskQA::UserCreateOutputObjects()
82{
83 // Create histograms
84 fTimeVSAmplitude = new TH2F*[NPMT0];
85
86 for (Int_t i=0; i<NPMT0; i++) {
87 fTimeVSAmplitude[i]= new TH2F (Form("fTimeVSAmplitude%d",i+1),"fTimeVsAmplitude",60, -10, 50,500,6000,7000);
88 }
89
90 fTzeroORAplusORC = new TH1F("fTzeroORAplusORC","ORA+ORC /2",100,-2000,2000); //or A plus or C
91 fResolution = new TH1F("fResolution","fResolution",100,-2000,2000);// or A minus or C spectrum
92 fTzeroORA = new TH1F("fTzeroORA","fTzeroORA",100,-2000,2000);// or A spectrum
93 fTzeroORC = new TH1F("fTzeroORC","fTzeroORC",100,-2000,2000);// or C spectrum
94 fCFDVSPmtId = new TH2F("fCFDVSPmtId","fCFDVSPmtId",24,0,24,250,6000,7000); //
95 fSPDVertexVST0Vertex = new TH2F("fSPDVertexVST0Vertex","fSPDVertexVST0Vertex",30,-30,30,30,-30,30);
96 fOrAvsNtracks = new TH2F("fAvstracks", "Avstracks",200, 0, 1000, 500, -1000, 1000);
97 fOrCvsNtracks = new TH2F("fCvstracks", "Cvstracks",200, 0, 1000, 500, -1000, 1000);
98 fT0vsNtracks = new TH2F("fT0ACvstrackles", "T0ACvstracks",200, 0, 1000, 500, -1000, 1000);
99
100 fTzeroObject = new TObjArray(0);
101 fTzeroObject->SetOwner(kTRUE);
102
103 for (Int_t i=0; i<24; i++)
104 fTzeroObject->AddAtAndExpand(fTimeVSAmplitude[i],i);
105
106 fTzeroObject->AddAtAndExpand(fCFDVSPmtId,24);
107 fTzeroObject->AddAtAndExpand(fSPDVertexVST0Vertex,25);
108 fTzeroObject->AddAtAndExpand(fTzeroORAplusORC, 26);
109 fTzeroObject->AddAtAndExpand(fResolution, 27);
110 fTzeroObject->AddAtAndExpand(fTzeroORA, 28);
111 fTzeroObject->AddAtAndExpand(fTzeroORC, 29);
112 fTzeroObject->AddAtAndExpand(fT0vsNtracks, 30);
113 fTzeroObject->AddAtAndExpand(fOrAvsNtracks,31);
114 fTzeroObject->AddAtAndExpand(fOrCvsNtracks, 32);
115
116 PostData(1, fTzeroObject);
117 // Called once
118}
119
120//________________________________________________________________________
121void AliT0AnalysisTaskQA::UserExec(Option_t *)
122{
123 // Main loop
124 // Called for each event
125
126 // Post output data.
127 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
128 if (!fESD) {
129 printf("ERROR: fESD not available\n");
130 return;
131 }
132
133 fRunNumber = fESD->GetRunNumber() ;
134
135 const Double32_t* time = fESD->GetT0time();
136 const Double32_t* amplitude = fESD->GetT0amplitude();
137
138
139 for (Int_t i=0; i<24; i++) {
140 if(time[i]<9999 &&abs(time[i])>1e-8 && amplitude[i]<9999&&abs(amplitude[i])>1e-8 )
141 {
142 // cout<<"time "<<time[i]<<" amplitude "<<amplitude[i]<<endl;
143 fTimeVSAmplitude[i]->Fill(amplitude[i],time[i]);
144 fCFDVSPmtId->Fill(i,time[i]);
145 }
146 }
147
148 const Double32_t* mean = fESD->GetT0TOF();
149 Double32_t orA = mean[1];
150 Double32_t orC = mean[2];
151 Int_t ntracks = fESD->GetNumberOfTracks();
152
153 if(orA<9999){
154 fTzeroORA->Fill(orA);
155 fOrAvsNtracks->Fill(ntracks, orA);
156 }
157 if(orC<9999) {
158 fTzeroORC->Fill(orC);
159 fOrCvsNtracks->Fill(ntracks, orC);
160 }
161 if(orA<9999 && orC<9999) {
162 fResolution->Fill((orA-orC)/2.);
163 fTzeroORAplusORC->Fill(mean[0]);
164 fT0vsNtracks->Fill(ntracks, mean[0]);
165 }
166
167 Double32_t t0vertex = fESD->GetT0zVertex();
168 // cout << "t0 vertex "<<t0vertex<<endl;
169 Double32_t esdzvertex;
170 const AliESDVertex * esdvertex = fESD->GetPrimaryVertex();
171 Int_t nofcontrib=-1;
172 if(esdvertex && t0vertex<999)
173 {
174 nofcontrib=esdvertex->GetNContributors();
175 if(nofcontrib>1)
176 {
177 esdzvertex=esdvertex->GetZv();
178 // cout << "esd vertex "<<esdzvertex<<endl;
179 fSPDVertexVST0Vertex->Fill(t0vertex,esdzvertex);
180 }
181 }
182 // printf("%f %f %f\n",orA,orC,time);
183 PostData(1, fTzeroObject);
184}
185 //________________________________________________________________________
186void AliT0AnalysisTaskQA::Terminate(Option_t *)
187{
188
189 // Called once at the end of the query
190}