coverity fixed
[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
30 fRunNumber(0)\r
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
37 }\r
38\r
39 // Define input and output slots here\r
40 // Input slot #0 works with a TChain\r
41 // DefineInput(0, TChain::Class());\r
42 // DefineOutput(1, TObjArray::Class());\r
43}\r
44\r
45\r
46//________________________________________________________________________\r
47AliT0CalibOffsetChannelsTask::AliT0CalibOffsetChannelsTask(const char *name) \r
48 : AliAnalysisTaskSE(name), fESD(0), fTzeroObject(0),\r
49 fTzeroORA(0x0), fTzeroORC(0x0), fResolution(0x0), fTzeroORAplusORC(0x0),\r
50 fRunNumber(0)\r
51{\r
52 // Constructor\r
53 \r
54 for( int ip=0; ip < 24; ip++){\r
55 fTimeDiff[ip] = 0;\r
56 fCFD[ip] = 0;\r
57 }\r
58 \r
59 // Define input and output slots here\r
60 // Input slot #0 works with a TChain\r
61 DefineInput(0, TChain::Class());\r
62 DefineOutput(1, TObjArray::Class());\r
63 // Output slot #0 id reserved by the base class for AOD\r
64 // Output slot #1 writes into a TH1 container\r
65}\r
66\r
67//________________________________________________________________________\r
68AliT0CalibOffsetChannelsTask::~AliT0CalibOffsetChannelsTask() \r
69{\r
70 // Destructor\r
71 // printf("AliT0CalibOffsetChannels~AliT0CalibOffsetChannels() ");\r
72 delete fTzeroORA;\r
73 delete fTzeroORC;\r
74 delete fResolution;\r
75 delete fTzeroORAplusORC;\r
33b89db7 76 for (Int_t i=0; i<24; i++) {\r
77 delete fTimeDiff[i];\r
78 delete fCFD[i];\r
79 }\r
b5e0299c 80 delete fTzeroObject;\r
81}\r
82\r
83//________________________________________________________________________\r
84/*void AliT0CalibOffsetChannelsTaskX::ConnectInputData(Option_t *) {\r
85 //\r
86 //\r
87 //\r
88 TTree* tree=dynamic_cast<TTree*>(GetInputData(0));\r
89 if (!tree) {\r
90 printf("ERROR: Could not read chain from input slot 0");\r
91 } \r
92 else {\r
93 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r
94 if (!esdH) {\r
95 printf ("ERROR: Could not get ESDInputHandler");\r
96 } \r
97 else {\r
98 fESD = esdH->GetEvent();\r
99 printf ("*** CONNECTED NEW EVENT ****");\r
100 }\r
101 }\r
102}\r
103*/\r
104//________________________________________________________________________\r
105void AliT0CalibOffsetChannelsTask::UserCreateOutputObjects()\r
106{\r
107 // Create histograms\r
108 for (Int_t i=0; i<24; i++) {\r
109 fTimeDiff[i] = new TH1F (Form("CFD1minCFD%d",i+1),"fTimeDiff",300, -300, 300);\r
110 fCFD[i] = new TH1F(Form("CFD%d",i+1),"CFD",500, 2000, 3000);//6000, 7000);\r
111 }\r
112\r
113 fTzeroORAplusORC = new TH1F("fTzeroORAplusORC","ORA+ORC /2",400,-2000,2000); //or A plus or C \r
114 fResolution = new TH1F("fResolution","fResolution",400,-2000,2000);// or A minus or C spectrum\r
115 fTzeroORA = new TH1F("fTzeroORA","fTzeroORA",400,-2000,2000);// or A spectrum\r
116 fTzeroORC = new TH1F("fTzeroORC","fTzeroORC",400,-2000,2000);// or C spectrum\r
117\r
118 \r
119 fTzeroObject = new TObjArray(0);\r
120 fTzeroObject->SetOwner(kTRUE);\r
121 \r
122 for (Int_t i=0; i<24; i++)\r
123 fTzeroObject->AddAtAndExpand(fTimeDiff[i],i);\r
124\r
125 for (Int_t i=0; i<24; i++)\r
126 fTzeroObject->AddAtAndExpand(fCFD[i],i+24); //24 - 48\r
127\r
128 fTzeroObject->AddAtAndExpand(fTzeroORAplusORC, 48);\r
129 fTzeroObject->AddAtAndExpand(fResolution, 49);\r
130 fTzeroObject->AddAtAndExpand(fTzeroORA, 50);\r
131 fTzeroObject->AddAtAndExpand(fTzeroORC, 51);\r
132\r
133 PostData(1, fTzeroObject);\r
134 // Called once\r
135}\r
136\r
137//________________________________________________________________________\r
138void AliT0CalibOffsetChannelsTask::UserExec(Option_t *) \r
139{\r
140 // Main loop\r
141 // Called for each event\r
142\r
143 // Post output data.\r
144 fESD = dynamic_cast<AliESDEvent*>(InputEvent());\r
145 if (!fESD) {\r
146 printf("ERROR: fESD not available\n");\r
147 return;\r
148 }\r
149\r
150 fRunNumber = fESD->GetRunNumber() ; \r
151\r
152 const Double32_t* time = fESD->GetT0time();\r
153 for (Int_t i=0; i<12; i++) {\r
154 if( time[i]>1 ){\r
155 fCFD[i]->Fill( time[i]);\r
156 if( time[0]>1 ) \r
157 fTimeDiff[i]->Fill( time[i]-time[0]);\r
158 }\r
159 }\r
160 for (Int_t i=12; i<24; i++) {\r
161 if( time[i]>1) {\r
162 fCFD[i]->Fill( time[i]);\r
163 if( time[12]>1 ) \r
164 fTimeDiff[i]->Fill( time[i]-time[12]);\r
165 }\r
166 }\r
167 const Double32_t* mean = fESD->GetT0TOF();\r
168 Double32_t meanTOF = mean[0] + 100000. ;\r
169 Double32_t orA = mean[1] + 100000.;\r
170 Double32_t orC = mean[2] + 100000.;\r
171 \r
172 if(orA<9999) fTzeroORA->Fill(orA);\r
173 if(orC<9999) fTzeroORC->Fill(orC);\r
174 if(orA<9999 && orC<9999) fResolution->Fill((orA-orC)/2.);\r
175 if(orA<9999 && orC<9999) fTzeroORAplusORC->Fill(meanTOF); \r
176\r
177 // printf("%f %f %f\n",orA,orC,meanTOF);\r
178 PostData(1, fTzeroObject);\r
179} \r
180 //________________________________________________________________________\r
181void AliT0CalibOffsetChannelsTask::Terminate(Option_t *) \r
182{\r
183 \r
184 // Called once at the end of the query\r
185}\r
186 \r