for pass0 AliT0PreprocessorOffline.cxx
[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
76 delete [] fTimeDiff;\r
77 delete [] fCFD;\r
78\r
79 delete fTzeroObject;\r
80}\r
81\r
82//________________________________________________________________________\r
83/*void AliT0CalibOffsetChannelsTaskX::ConnectInputData(Option_t *) {\r
84 //\r
85 //\r
86 //\r
87 TTree* tree=dynamic_cast<TTree*>(GetInputData(0));\r
88 if (!tree) {\r
89 printf("ERROR: Could not read chain from input slot 0");\r
90 } \r
91 else {\r
92 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r
93 if (!esdH) {\r
94 printf ("ERROR: Could not get ESDInputHandler");\r
95 } \r
96 else {\r
97 fESD = esdH->GetEvent();\r
98 printf ("*** CONNECTED NEW EVENT ****");\r
99 }\r
100 }\r
101}\r
102*/\r
103//________________________________________________________________________\r
104void AliT0CalibOffsetChannelsTask::UserCreateOutputObjects()\r
105{\r
106 // Create histograms\r
107 for (Int_t i=0; i<24; i++) {\r
108 fTimeDiff[i] = new TH1F (Form("CFD1minCFD%d",i+1),"fTimeDiff",300, -300, 300);\r
109 fCFD[i] = new TH1F(Form("CFD%d",i+1),"CFD",500, 2000, 3000);//6000, 7000);\r
110 }\r
111\r
112 fTzeroORAplusORC = new TH1F("fTzeroORAplusORC","ORA+ORC /2",400,-2000,2000); //or A plus or C \r
113 fResolution = new TH1F("fResolution","fResolution",400,-2000,2000);// or A minus or C spectrum\r
114 fTzeroORA = new TH1F("fTzeroORA","fTzeroORA",400,-2000,2000);// or A spectrum\r
115 fTzeroORC = new TH1F("fTzeroORC","fTzeroORC",400,-2000,2000);// or C spectrum\r
116\r
117 \r
118 fTzeroObject = new TObjArray(0);\r
119 fTzeroObject->SetOwner(kTRUE);\r
120 \r
121 for (Int_t i=0; i<24; i++)\r
122 fTzeroObject->AddAtAndExpand(fTimeDiff[i],i);\r
123\r
124 for (Int_t i=0; i<24; i++)\r
125 fTzeroObject->AddAtAndExpand(fCFD[i],i+24); //24 - 48\r
126\r
127 fTzeroObject->AddAtAndExpand(fTzeroORAplusORC, 48);\r
128 fTzeroObject->AddAtAndExpand(fResolution, 49);\r
129 fTzeroObject->AddAtAndExpand(fTzeroORA, 50);\r
130 fTzeroObject->AddAtAndExpand(fTzeroORC, 51);\r
131\r
132 PostData(1, fTzeroObject);\r
133 // Called once\r
134}\r
135\r
136//________________________________________________________________________\r
137void AliT0CalibOffsetChannelsTask::UserExec(Option_t *) \r
138{\r
139 // Main loop\r
140 // Called for each event\r
141\r
142 // Post output data.\r
143 fESD = dynamic_cast<AliESDEvent*>(InputEvent());\r
144 if (!fESD) {\r
145 printf("ERROR: fESD not available\n");\r
146 return;\r
147 }\r
148\r
149 fRunNumber = fESD->GetRunNumber() ; \r
150\r
151 const Double32_t* time = fESD->GetT0time();\r
152 for (Int_t i=0; i<12; i++) {\r
153 if( time[i]>1 ){\r
154 fCFD[i]->Fill( time[i]);\r
155 if( time[0]>1 ) \r
156 fTimeDiff[i]->Fill( time[i]-time[0]);\r
157 }\r
158 }\r
159 for (Int_t i=12; i<24; i++) {\r
160 if( time[i]>1) {\r
161 fCFD[i]->Fill( time[i]);\r
162 if( time[12]>1 ) \r
163 fTimeDiff[i]->Fill( time[i]-time[12]);\r
164 }\r
165 }\r
166 const Double32_t* mean = fESD->GetT0TOF();\r
167 Double32_t meanTOF = mean[0] + 100000. ;\r
168 Double32_t orA = mean[1] + 100000.;\r
169 Double32_t orC = mean[2] + 100000.;\r
170 \r
171 if(orA<9999) fTzeroORA->Fill(orA);\r
172 if(orC<9999) fTzeroORC->Fill(orC);\r
173 if(orA<9999 && orC<9999) fResolution->Fill((orA-orC)/2.);\r
174 if(orA<9999 && orC<9999) fTzeroORAplusORC->Fill(meanTOF); \r
175\r
176 // printf("%f %f %f\n",orA,orC,meanTOF);\r
177 PostData(1, fTzeroObject);\r
178} \r
179 //________________________________________________________________________\r
180void AliT0CalibOffsetChannelsTask::Terminate(Option_t *) \r
181{\r
182 \r
183 // Called once at the end of the query\r
184}\r
185 \r