efficiency histograms added
[u/mrichter/AliRoot.git] / PWG1 / T0 / AliT0AnalysisTaskQA.cxx
CommitLineData
07682040 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 fTzeroObject; // This deletes everything ...
67}
68
69//------------------------------------------------------------------
70void AliT0AnalysisTaskQA::UserCreateOutputObjects()
71{
72 // Create histograms
73 fTimeVSAmplitude = new TH2F*[NPMT0];
74
75 for (Int_t i=0; i<NPMT0; i++) {
750c312d 76 fTimeVSAmplitude[i]= new TH2F (Form("fTimeVSAmplitude%d",i+1),"fTimeVsAmplitude",60, -10, 50,1500,1000,7000);
07682040 77 }
78
79 fTzeroORAplusORC = new TH1F("fTzeroORAplusORC","ORA+ORC /2",100,-2000,2000); //or A plus or C
80 fResolution = new TH1F("fResolution","fResolution",100,-2000,2000);// or A minus or C spectrum
81 fTzeroORA = new TH1F("fTzeroORA","fTzeroORA",100,-2000,2000);// or A spectrum
82 fTzeroORC = new TH1F("fTzeroORC","fTzeroORC",100,-2000,2000);// or C spectrum
750c312d 83 fCFDVSPmtId = new TH2F("fCFDVSPmtId","fCFDVSPmtId",24,0,24,1500,1000,7000); //
07682040 84 fSPDVertexVST0Vertex = new TH2F("fSPDVertexVST0Vertex","fSPDVertexVST0Vertex",30,-30,30,30,-30,30);
85 fOrAvsNtracks = new TH2F("fAvstracks", "Avstracks",200, 0, 1000, 500, -1000, 1000);
86 fOrCvsNtracks = new TH2F("fCvstracks", "Cvstracks",200, 0, 1000, 500, -1000, 1000);
87 fT0vsNtracks = new TH2F("fT0ACvstrackles", "T0ACvstracks",200, 0, 1000, 500, -1000, 1000);
750c312d 88 fEffAC = new TH1F("EffAC","T0Eff ", 200, 0, 1000);
89 fEffA = new TH1F("EffA","T0AEff ", 200, 0, 1000);
90 fEffC = new TH1F("EffC","T0CEff ", 200, 0, 1000);
91 ftracksEffSPD= new TH1F("ftracksEffSPD","SPDeff", 200, 0, 1000);
07682040 92
93 fTzeroObject = new TObjArray();
94 fTzeroObject->SetOwner(kTRUE);
95
96 for (Int_t i=0; i<24; i++)
97 fTzeroObject->AddAtAndExpand(fTimeVSAmplitude[i],i);
98
99 fTzeroObject->AddAtAndExpand(fCFDVSPmtId,24);
100 fTzeroObject->AddAtAndExpand(fSPDVertexVST0Vertex,25);
101 fTzeroObject->AddAtAndExpand(fTzeroORAplusORC, 26);
102 fTzeroObject->AddAtAndExpand(fResolution, 27);
103 fTzeroObject->AddAtAndExpand(fTzeroORA, 28);
104 fTzeroObject->AddAtAndExpand(fTzeroORC, 29);
105 fTzeroObject->AddAtAndExpand(fT0vsNtracks, 30);
106 fTzeroObject->AddAtAndExpand(fOrAvsNtracks,31);
107 fTzeroObject->AddAtAndExpand(fOrCvsNtracks, 32);
750c312d 108 fTzeroObject->AddAtAndExpand(fEffC, 33);
109 fTzeroObject->AddAtAndExpand(fEffA, 34);
110 fTzeroObject->AddAtAndExpand(fEffAC, 35);
111 fTzeroObject->AddAtAndExpand(ftracksEffSPD, 36);
07682040 112
113 PostData(1, fTzeroObject);
114 // Called once
115}
116
117//________________________________________________________________________
118void AliT0AnalysisTaskQA::UserExec(Option_t *)
119{
120 // Main loop
121 // Called for each event
122
123 // Post output data.
124 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
125 if (!fESD) {
126 printf("ERROR: fESD not available\n");
127 return;
128 }
129
130 fRunNumber = fESD->GetRunNumber() ;
131
132 const Double32_t* time = fESD->GetT0time();
133 const Double32_t* amplitude = fESD->GetT0amplitude();
134
135
136 for (Int_t i=0; i<24; i++) {
137 if(time[i]<9999 &&abs(time[i])>1e-8 && amplitude[i]<9999&&abs(amplitude[i])>1e-8 )
138 {
139 // cout<<"time "<<time[i]<<" amplitude "<<amplitude[i]<<endl;
140 fTimeVSAmplitude[i]->Fill(amplitude[i],time[i]);
141 fCFDVSPmtId->Fill(i,time[i]);
142 }
143 }
144
145 const Double32_t* mean = fESD->GetT0TOF();
146 Double32_t orA = mean[1];
147 Double32_t orC = mean[2];
148 Int_t ntracks = fESD->GetNumberOfTracks();
149
750c312d 150 if(orA<99999){
07682040 151 fTzeroORA->Fill(orA);
152 fOrAvsNtracks->Fill(ntracks, orA);
750c312d 153 fEffA->Fill(ntracks);
07682040 154 }
750c312d 155 if(orC<99999) {
07682040 156 fTzeroORC->Fill(orC);
157 fOrCvsNtracks->Fill(ntracks, orC);
750c312d 158 fEffC->Fill(ntracks);
159 }
160 if(orA<99999 && orC<99999) {
07682040 161 fResolution->Fill((orA-orC)/2.);
162 fTzeroORAplusORC->Fill(mean[0]);
750c312d 163 fEffAC->Fill(ntracks);
07682040 164 fT0vsNtracks->Fill(ntracks, mean[0]);
165 }
166
167 Double32_t t0vertex = fESD->GetT0zVertex();
07682040 168 Double32_t esdzvertex;
169 const AliESDVertex * esdvertex = fESD->GetPrimaryVertex();
170 Int_t nofcontrib=-1;
750c312d 171 nofcontrib=esdvertex->GetNContributors();
172 if(nofcontrib>0) ftracksEffSPD->Fill(ntracks);
173 if(esdvertex && t0vertex<999)
07682040 174 {
750c312d 175 if(nofcontrib>0)
07682040 176 {
177 esdzvertex=esdvertex->GetZv();
07682040 178 fSPDVertexVST0Vertex->Fill(t0vertex,esdzvertex);
179 }
180 }
07682040 181 PostData(1, fTzeroObject);
182}
183 //________________________________________________________________________
184void AliT0AnalysisTaskQA::Terminate(Option_t *)
185{
186
187 // Called once at the end of the query
188}