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