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