restructure the output container for the TPC calib
[u/mrichter/AliRoot.git] / PWGPP / CalibMacros / CPass1 / AddTaskTPCCalib.C
CommitLineData
807998f3 1/*
2
3 This macros setup the TPC calibration task AddTaskTPCCalib
054d9070 4 for CPass1.
807998f3 5 - the run number is required to config TPC OCDB
6
7 The following calibration components are added to the AliTPCAnalysisTaskcalib task:
8 1. AliTPCcalibCalib - redo reconstruction with current calibration
9 2. AliTPCcalibTimeGain - TPC time dependent gain calibration
10 3. AliTPCcalibTime - TPC time dependent drift time calibration
11
12*/
13
14// function to set TPC OCDB parameters
15void ConfigOCDB(Int_t crun);
16
17Int_t debugLevel=0;
18Int_t streamLevel=0;
19
20//_____________________________________________________________________________
21AliAnalysisTask *AddTaskTPCCalib(Int_t runNumber)
22{
23 //
24 // add calibration task
25 //
26 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
27 if (!mgr) {
28 ::Error("AddTaskTPCCalib", "No analysis manager to connect to.");
29 return NULL;
30 }
31
32 // check the input handler
33 if (!mgr->GetInputEventHandler()) {
34 ::Error("AddTaskTPCCalib", "This task requires an input event handler");
35 return NULL;
36 }
37
38 // set TPC OCDB parameters
39 ConfigOCDB(runNumber);
40
08669268 41 // setup task TPCCalib
42 TString outputFileName=mgr->GetCommonFileName();
807998f3 43 AliTPCAnalysisTaskcalib *task1=new AliTPCAnalysisTaskcalib("CalibObjectsTrain1");
44 SetupCalibTaskTrain1(task1);
45 mgr->AddTask(task1);
807998f3 46 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
47 if (!cinput1) cinput1 = mgr->CreateContainer("cchain",TChain::Class(),
48 AliAnalysisManager::kInputContainer);
08669268 49 for (Int_t i=0; i<task1->GetJobs()->GetEntries(); i++) {
50 if (task1->GetJobs()->At(i)) {
51 AliAnalysisDataContainer* coutput = mgr->CreateContainer(task1->GetJobs()->At(i)->GetName(),
52 AliTPCcalibBase::Class(),
53 AliAnalysisManager::kOutputContainer,
54 "AliESDfriends_v1.root:TPCCalib");
55 mgr->ConnectOutput(task1,i,coutput);
56 }
57 }
807998f3 58 mgr->ConnectInput(task1,0,cinput1);
08669268 59 //
60 // setup task TPCAlign
fe072aad 61 AliTPCAnalysisTaskcalib *taskAlign=new AliTPCAnalysisTaskcalib("CalibObjectsTrain1");
62 SetupCalibTaskTrainAlign(taskAlign);
63 mgr->AddTask(taskAlign);
08669268 64 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
65 if (!cinput1) cinput1 = mgr->CreateContainer("cchain",TChain::Class(),
fe072aad 66 AliAnalysisManager::kInputContainer);
08669268 67 for (Int_t i=0; i<taskAlign->GetJobs()->GetEntries(); i++) {
68 if (taskAlign->GetJobs()->At(i)) {
69 AliAnalysisDataContainer* coutput = mgr->CreateContainer(taskAlign->GetJobs()->At(i)->GetName(),
70 AliTPCcalibBase::Class(),
71 AliAnalysisManager::kOutputContainer,
72 "AliESDfriends_v1.root:TPCAlign");
73 mgr->ConnectOutput(taskAlign,i,coutput);
74 }
75 }
76 mgr->ConnectInput(taskAlign,0,cinput1);
77 //
78 // setup task TPCCluster
fe072aad 79 AliTPCAnalysisTaskcalib *taskCluster=new AliTPCAnalysisTaskcalib("CalibObjectsTrain1");
80 SetupCalibTaskTrainCluster(taskCluster);
81 mgr->AddTask(taskCluster);
08669268 82 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
83 if (!cinput1) cinput1 = mgr->CreateContainer("cchain",TChain::Class(),
84 AliAnalysisManager::kInputContainer);
85 for (Int_t i=0; i<taskCluster->GetJobs()->GetEntries(); i++) {
86 if (taskCluster->GetJobs()->At(i)) {
87 AliAnalysisDataContainer* coutput = mgr->CreateContainer(taskCluster->GetJobs()->At(i)->GetName(),
88 AliTPCcalibBase::Class(),
89 AliAnalysisManager::kOutputContainer,
90 "AliESDfriends_v1.root:TPCCluster");
91 mgr->ConnectOutput(taskCluster,i,coutput);
92 }
93 }
fe072aad 94 mgr->ConnectInput(taskCluster,0,cinput1);
08669268 95 //
fe072aad 96
807998f3 97 return task1;
98}
99
100//_____________________________________________________________________________
101void AddCalibCalib(TObject* task){
102 //
103 // Responsible: Marian Ivanov
104 // Description:
105 // calibCalib is a prefilter
106 // The current OCDB entries transformation are applied on cluster, tracks are refitted
107 //
108 AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
109 AliTPCcalibCalib *calibCalib = new AliTPCcalibCalib("calibTPC","calibTPC");
110 calibCalib->SetDebugLevel(0);
111 calibCalib->SetStreamLevel(0);
112 calibCalib->SetTriggerMask(-1,-1,kFALSE); //accept everything
113 myTask->AddJob(calibCalib);
114}
115
116//_____________________________________________________________________________
117void AddCalibTimeGain(TObject* task, Bool_t isCosmic = kFALSE, char * name = "calibTimeGain"){
118 //
119 // Responsible: Alexander Kalweit
120 // Description: Time Gain calibration
121 //
122
123 // Set run time ranges (time stamps)
124 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
125 if(!entry) {
126 ::Error("AddCalibTimeGain","Cannot get AliCDBEntry");
127 return;
128 }
129 const AliGRPObject* grpData = dynamic_cast<AliGRPObject*>(entry->GetObject());
130 if(!grpData) {
131 ::Error("AddCalibTimeGain","Cannot get AliGRPObject");
132 return;
133 }
134 time_t sTime = grpData->GetTimeStart();
135 time_t eTime = grpData->GetTimeEnd();
136 TTimeStamp startRunTime(sTime);
137 TTimeStamp stopRunTime(eTime);
138
139 UInt_t year;
140 startRunTime.GetDate(kTRUE,0,&year);
141 TTimeStamp startTime(year,1,1,0,0,0);
142 TTimeStamp stopTime(year,12,31,23,59,59);
143
144 //
145 // setup calibration component
146 //
1611b277 147
148 Bool_t useQmax = (grpData->GetBeamType()).Contains("Pb-Pb");
149
807998f3 150 AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
151 AliTPCcalibTimeGain *calibTimeGain = new AliTPCcalibTimeGain(name,"calibTimeGain", startTime.GetSec(), stopTime.GetSec(), 10*60);
152 calibTimeGain->SetIsCosmic(isCosmic);
153 calibTimeGain->SetUseCookAnalytical(kTRUE);
1611b277 154 calibTimeGain->SetUseMax(useQmax);
807998f3 155 calibTimeGain->SetDebugLevel(0);
156 calibTimeGain->SetStreamLevel(0);
157 calibTimeGain->SetTriggerMask(-1,-1,kTRUE); //reject laser
158 calibTimeGain->SetLowerTrunc(0.02);
159 calibTimeGain->SetUpperTrunc(0.6);
160
161 myTask->AddJob(calibTimeGain);
162
163 AliTPCcalibGainMult *calibGainMult = new AliTPCcalibGainMult("calibGainMult","calibGainMult");
1611b277 164 calibGainMult->SetUseMax(useQmax);
807998f3 165 calibGainMult->SetDebugLevel(0);
166 calibGainMult->SetStreamLevel(0);
167 calibGainMult->SetTriggerMask(-1,-1,kTRUE); //reject laser
168 calibGainMult->SetLowerTrunc(0.02);
169 calibGainMult->SetUpperTrunc(0.6);
170
8cf075d0 171 myTask->AddJob(calibGainMult);
807998f3 172
173}
174
175//_____________________________________________________________________________
176void AddCalibTime(TObject* task){
177 //
178 // Responsible: Dag Larsen
179 // Description: Time V drift calibration
180 //
181
182 // Set run time ranges (time stamps)
183 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
184 if(!entry) {
185 ::Error("AddCalibTime","Cannot get AliCDBEntry");
186 return;
187 }
188 const AliGRPObject* grpData = dynamic_cast<AliGRPObject*>(entry->GetObject());
189 if(!grpData) {
190 ::Error("AddCalibTime","Cannot get AliGRPObject");
191 return;
192 }
193 time_t sTime = grpData->GetTimeStart();
194 time_t eTime = grpData->GetTimeEnd();
195
196 TTimeStamp startRunTime(sTime);
197 TTimeStamp stopRunTime(eTime);
198
199 UInt_t year;
200 startRunTime.GetDate(kTRUE,0,&year);
201 TTimeStamp startTime(year,1,1,0,0,0);
202 TTimeStamp stopTime(year,12,31,23,59,59);
203
204 //
205 // setup calibration component
206 //
207 AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
208 AliTPCcalibTime *calibTime = new AliTPCcalibTime("calibTime","calibTime", startTime.GetSec(), stopTime.GetSec(), 10*60, 2);
209 calibTime->SetDebugLevel(0);
210 calibTime->SetStreamLevel(0);
211 calibTime->SetTriggerMask(-1,-1,kFALSE); //accept everything
212
c9707c1c 213 // max 15000 tracks per event
214 calibTime->SetCutTracks(15000);
807998f3 215
216 myTask->AddJob(calibTime);
217}
218
219
220void AddCalibTracks(TObject* task){
221 //
222 // Responsible: Marian Ivanov
223 // Description:
224 // Histogram residuals and pulls of the track parameters in bins of track parameters
225 //
226 AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
227 AliTPCClusterParam * clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
228
229 AliTPCcalibTracksCuts *cuts = new AliTPCcalibTracksCuts(30, 0.4, 5, 0.13, 0.018);
230 //
231 AliTPCcalibTracks *calibTracks = new AliTPCcalibTracks("calibTracks", "Resolution calibration object for tracks", clusterParam, cuts);
232 calibTracks->SetDebugLevel(debugLevel);
233 calibTracks->SetStreamLevel(streamLevel);
234 calibTracks->SetTriggerMask(-1,-1,kTRUE);
235 myTask->AddJob(calibTracks);
236}
237
238
fe072aad 239void AddCalibAlign(TObject* task){
240 //
241 // Responsible: Marian Ivanov
242 // Description:
243 //
244 AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
245 AliTPCcalibAlign *calibAlign = new AliTPCcalibAlign("alignTPC","Alignment of the TPC sectors");
246 calibAlign->SetDebugLevel(debugLevel);
247 calibAlign->SetStreamLevel(streamLevel);
248 calibAlign->SetTriggerMask(-1,-1,kTRUE); //accept everything
249 myTask->AddJob(calibAlign);
250}
251
252
253void AddCalibLaser(TObject* task){
254 //
255 // Responsible: Marian Ivanov
256 // Description:
257 //
258 AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
259 AliTPCcalibLaser *calibLaser = new AliTPCcalibLaser("laserTPC","laserTPC");
260 calibLaser->SetDebugLevel(debugLevel);
261 calibLaser->SetStreamLevel(streamLevel);
262 calibLaser->SetTriggerMask(-1,-1,kFALSE); //accept everything
263 myTask->AddJob(calibLaser);
264}
265
266
9e160db9 267void AddCalibCosmic(TObject* task){
268 //
269 // Responsible: Marian Ivanov
270 // Description:
271 // Histogram residuals and pulls of the track parameters in bins of track parameters
272 // Dump cosmic tracks to the tree
273 //
274 AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
275 AliTPCcalibCosmic *calibCosmic = new AliTPCcalibCosmic("cosmicTPC","cosmicTPC");
276 calibCosmic->SetDebugLevel(debugLevel);
277 calibCosmic->SetStreamLevel(1);
278 calibCosmic->SetTriggerMask(-1,-1,kTRUE); //accept everything
279 myTask->AddJob(calibCosmic);
280}
281
fe072aad 282
283
807998f3 284//_____________________________________________________________________________
285void SetupCalibTaskTrain1(TObject* task){
286 //
287 // Setup tasks for calibration train
288 //
fe072aad 289 // AddCalibCalib(task); - disable refitting
807998f3 290 AddCalibTimeGain(task);
291 AddCalibTime(task);
9e160db9 292 //AddCalibCosmic(task);
807998f3 293}
294
fe072aad 295
296void SetupCalibTaskTrainAlign(TObject* task){
297 //
298 // Setup tasks for calibration train
299 //
300 AddCalibAlign(task);
301 AddCalibLaser(task);
302}
303
304
305void SetupCalibTaskTrainCluster(TObject* task){
306 //
307 // Setup tasks for calibration train
308 //
309 AddCalibTracks(task);
310}
311
312
807998f3 313//_____________________________________________________________________________
314void ConfigOCDB(Int_t run){
315 //
316 // Configure TPC OCDB
317 //
318 printf("SETUP OCBD for TPC\n");
319 printf("SETUP OCBD for TPC\n");
320 printf("SETUP OCBD for TPC Run =%d\n", run);
321 //
322 //
323 AliTPCParam *param= AliTPCcalibDB::Instance()->GetParameters();
324 param->ReadGeoMatrices();
325 //
326 AliMagF* magF= TGeoGlobalMagField::Instance()->GetField();
327 printf("\n\nSET EXB FIELD\t\n\n");
328 AliTPCcalibDB::Instance()->SetExBField(magF);
329 //
330 //
331 //
332 AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
333 //
334 //AliTPCRecoParam * tpcRecoParam = AliTPCRecoParam::GetCosmicTestParam(kTRUE);
335 //
336 AliCDBEntry* entry = AliCDBManager::Instance()->Get("TPC/Calib/RecoParam");
337 if (!entry){
338 printf("TPC reco param not available");
339 }
340 TObjArray * array = (TObjArray*)entry->GetObject();
341 if (!array){
342 printf("TPC reco param not available");
343 }
344 // 0 - Low Flux (pp), 1- High Flux (Pb-Pb)
345 AliTPCRecoParam * tpcRecoParam = (AliTPCRecoParam*)array->At(1);
346
347 transform->SetCurrentRecoParam(tpcRecoParam);
fe072aad 348 // in CPass1 use a default setting
349// tpcRecoParam->SetUseGainCorrectionTime(0);
350// tpcRecoParam->SetUseRPHICorrection(kFALSE);
351// tpcRecoParam->SetUseTOFCorrection(kFALSE);
352// //
353// tpcRecoParam->SetUseDriftCorrectionTime(0);
354// tpcRecoParam->SetUseDriftCorrectionGY(0);
355// //
356// tpcRecoParam->SetUseRadialCorrection(kFALSE);
357// tpcRecoParam->SetUseQuadrantAlignment(kFALSE);
358// //
359// tpcRecoParam->SetUseSectorAlignment(kFALSE);
360// tpcRecoParam->SetUseFieldCorrection(kFALSE);
361// tpcRecoParam->SetUseExBCorrection(kFALSE);
362// //
363// tpcRecoParam->SetUseMultiplicityCorrectionDedx(kFALSE);
364// tpcRecoParam->SetUseAlignmentTime(kFALSE);
365// tpcRecoParam->SetUseComposedCorrection(kTRUE);
807998f3 366
367 AliTPCcalibDB::Instance()->SetRun(run);
368}