]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/AliT0CalibOffsetChannelsTask.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / T0 / AliT0CalibOffsetChannelsTask.cxx
CommitLineData
a65a7e70 1#include "TChain.h"
2#include "TTree.h"
3#include "TH1D.h"
4#include "TF1.h"
5#include "TCanvas.h"
6#include "TObjArray.h"
7
8#include "AliAnalysisTask.h"
9#include "AliAnalysisManager.h"
10
11#include "AliESDEvent.h"
12#include "AliESDInputHandler.h"
13
14#include "AliT0CalibOffsetChannelsTask.h"
15
16//#include "AliCDBMetaData.h"
17//#include "AliCDBId.h"
18//#include "AliCDBEntry.h"
19//#include "AliCDBManager.h"
20//#include "AliCDBStorage.h"
21
22// Task should calculate channels offset
23// Authors: Alla
24
25ClassImp(AliT0CalibOffsetChannelsTask)
26//________________________________________________________________________
27AliT0CalibOffsetChannelsTask::AliT0CalibOffsetChannelsTask()
28 : AliAnalysisTaskSE(), fESD(0x0), fTzeroObject(0x0),
29 fTzeroORA(0x0), fTzeroORC(0x0), fResolution(0x0), fTzeroORAplusORC(0x0),
30 fRunNumber(0),fRefPMTA(12), fRefPMTC(0)
31{
32 // Constructor
33
34 for( int ip=0; ip < 24; ip++){
35 fTimeDiff[ip] = 0;
36 fCFD[ip] = 0;
37 fCDBdelays[ip]= 0;
38 fCDBcfds[ip]= 0;
39 if (ip<4 ) fCDBT0s[ip]= 0;
40 }
41
42 // Define input and output slots here
43 // Input slot #0 works with a TChain
44 // DefineInput(0, TChain::Class());
45 // DefineOutput(1, TObjArray::Class());
46}
47
48
49//________________________________________________________________________
50AliT0CalibOffsetChannelsTask::AliT0CalibOffsetChannelsTask(const char *name)
51 : AliAnalysisTaskSE(name), fESD(0), fTzeroObject(0),
52 fTzeroORA(0x0), fTzeroORC(0x0), fResolution(0x0), fTzeroORAplusORC(0x0),
53 fRunNumber(0),fRefPMTA(12), fRefPMTC(0)
54{
55 // Constructor
56
57 for( int ip=0; ip < 24; ip++){
58 fTimeDiff[ip] = 0;
59 fCFD[ip] = 0;
60 fCDBdelays[ip]= 0;
61 fCDBcfds[ip]= 0;
62 if (ip<4 ) fCDBT0s[ip]= 0;
63
64 }
65
66 // Define input and output slots here
67 // Input slot #0 works with a TChain
68 DefineInput(0, TChain::Class());
69 DefineOutput(1, TObjArray::Class());
70 // Output slot #0 id reserved by the base class for AOD
71 // Output slot #1 writes into a TH1 container
72}
73
74//________________________________________________________________________
75AliT0CalibOffsetChannelsTask::~AliT0CalibOffsetChannelsTask()
76{
77 // Destructor
78 // printf("AliT0CalibOffsetChannels~AliT0CalibOffsetChannels() ");
79 delete fTzeroORA;
80 delete fTzeroORC;
81 delete fResolution;
82 delete fTzeroORAplusORC;
83 for( Int_t ip=0; ip < 24; ip++){
84 delete fTimeDiff[ip];
85 delete fCFD[ip];
86 }
87
88 delete fTzeroObject;
89}
90
91//________________________________________________________________________
92/*void AliT0CalibOffsetChannelsTaskX::ConnectInputData(Option_t *) {
93 //
94 //
95 //
96 TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
97 if (!tree) {
98 printf("ERROR: Could not read chain from input slot 0");
99 }
100 else {
101 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
102 if (!esdH) {
103 printf ("ERROR: Could not get ESDInputHandler");
104 }
105 else {
106 fESD = esdH->GetEvent();
107 printf ("*** CONNECTED NEW EVENT ****");
108 }
109 }
110}
111*/
112//________________________________________________________________________
113void AliT0CalibOffsetChannelsTask::UserCreateOutputObjects()
114{
115 // Create histograms
116 Float_t low = fCDBcfds[fRefPMTC] - 500;
117 Float_t high = fCDBcfds[fRefPMTA] + 500;
118 for (Int_t i=0; i<24; i++) {
119 fTimeDiff[i] = new TH1F (Form("CFD1minCFD%d",i+1),"fTimeDiff",150, -300, 300);
120 fCFD[i] = new TH1F(Form("CFD%d",i+1),"CFD",250,low, high);//6000, 7000);
121 // fCFD[i] = new TH1F(Form("CFD%d",i+1),"CFD",250, -1000, 1000);//6000, 7000);
122 }
123
124 fTzeroORAplusORC = new TH1F("fTzeroORAplusORC","ORA+ORC /2",200,-4000,4000); //or A plus or C
125 fResolution = new TH1F("fResolution","fResolution",200,-2000,2000);// or A minus or C spectrum
126 fTzeroORA = new TH1F("fTzeroORA","fTzeroORA",200,-4000,4000);// or A spectrum
127 fTzeroORC = new TH1F("fTzeroORC","fTzeroORC",200,-4000,4000);// or C spectrum
128
129
130 fTzeroObject = new TObjArray(0);
131 fTzeroObject->SetOwner(kTRUE);
132
133 for (Int_t i=0; i<24; i++)
134 fTzeroObject->AddAtAndExpand(fTimeDiff[i],i);
135
136 for (Int_t i=0; i<24; i++)
137 fTzeroObject->AddAtAndExpand(fCFD[i],i+24); //24 - 48
138
139 fTzeroObject->AddAtAndExpand(fTzeroORAplusORC, 48);
140 fTzeroObject->AddAtAndExpand(fResolution, 49);
141 fTzeroObject->AddAtAndExpand(fTzeroORA, 50);
142 fTzeroObject->AddAtAndExpand(fTzeroORC, 51);
143
144 PostData(1, fTzeroObject);
145 // Called once
146}
147
148//________________________________________________________________________
149void AliT0CalibOffsetChannelsTask::UserExec(Option_t *)
150{
151 // Main loop
152 // Called for each event
153
154 // Post output data.
155
156 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
157 if (!fESD) {
158 printf("ERROR: fESD not available\n");
159 return;
160 }
161 Int_t trigT0 = fESD->GetT0Trig();
162 Bool_t eq = kTRUE;
163 fRunNumber = fESD->GetRunNumber() ;
164 if( fRunNumber<165747) eq = kFALSE;
165
166 const Double32_t* time = fESD->GetT0time();
167 const Double32_t* amp = fESD->GetT0amplitude();
168
169 Double32_t diff;
170 for (Int_t i=0; i<24; i++) {
171 if( time[i] > 0 && amp[i]>0.1 ){
172 if (eq) {
173 fCFD[i]->Fill( time[i] );//////!!!!!
174 if( time[fRefPMTC] > 0 && i<12) {
175 diff = time[i]-time[fRefPMTC];
176 fTimeDiff[i]->Fill( diff);
177 }
178 if( time[fRefPMTA] >0 && i>11) {
179 diff = time[i]-time[fRefPMTA] ;
180 fTimeDiff[i]->Fill( diff);
181 }
182 } //eq=1
183 else {
184 fCFD[i]->Fill( time[i] + fCDBdelays[i] );
185 if( time[fRefPMTC] > 0 && i<12) {
186 diff = time[i]-time[fRefPMTC] + fCDBdelays[i];
187 fTimeDiff[i]->Fill( diff);
188 } //C
189 if( time[fRefPMTA] >0 && i>11) {
190 diff = time[i]-time[fRefPMTA] + fCDBdelays[i];
191 fTimeDiff[i]->Fill( diff);
192 } //A
193 } //eq=0
194 }
195
196 }
197 if (trigT0>5) {
198 const Double32_t* mean = fESD->GetT0TOF();
199 Double32_t meanTOF = mean[0] + fCDBT0s[0] ;
200 Double32_t orA = mean[1] + fCDBT0s[1] ;
201 Double32_t orC = mean[2] + fCDBT0s[2] ;
202
203 if(orA<99999) fTzeroORA->Fill(orA);
204 if(orC<99999) fTzeroORC->Fill(orC);
205 if(orA<99999 && orC<99999) fResolution->Fill((orA-orC)/2.);
206 if(orA<99999 && orC<99999) fTzeroORAplusORC->Fill(meanTOF);
207 } //if TVDC on
208 // printf("%f %f %f\n",orA,orC,meanTOF);
209 PostData(1, fTzeroObject);
210 }
211 //________________________________________________________________________
212 void AliT0CalibOffsetChannelsTask::Terminate(Option_t *)
213{
214
215 // Called once at the end of the query
216}
217