restructure the output container for the TPC calib
[u/mrichter/AliRoot.git] / PWGPP / CalibMacros / CPass0 / AddTaskTPCCalib.C
CommitLineData
27eb9bff 1/*
2
3 This macros setup the TPC calibration task AddTaskTPCCalib
4c8432c7 4 for CPass0.
27eb9bff 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();
27eb9bff 43 AliTPCAnalysisTaskcalib *task1=new AliTPCAnalysisTaskcalib("CalibObjectsTrain1");
44 SetupCalibTaskTrain1(task1);
45 mgr->AddTask(task1);
27eb9bff 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 }
27eb9bff 58 mgr->ConnectInput(task1,0,cinput1);
6a5d02df 59 //
08669268 60 // setup task TPCAlign
6a5d02df 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(),
6a5d02df 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);
6a5d02df 77 //
08669268 78 // setup task TPCCluster
6a5d02df 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 }
6a5d02df 94 mgr->ConnectInput(taskCluster,0,cinput1);
08669268 95 //
6a5d02df 96
27eb9bff 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
27eb9bff 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);
27eb9bff 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);
27eb9bff 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);
27eb9bff 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);
27eb9bff 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
6a5d02df 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
282
6a5d02df 283
27eb9bff 284//_____________________________________________________________________________
285void SetupCalibTaskTrain1(TObject* task){
286 //
287 // Setup tasks for calibration train
288 //
289 AddCalibCalib(task);
290 AddCalibTimeGain(task);
291 AddCalibTime(task);
6a5d02df 292}
293
294void SetupCalibTaskTrainAlign(TObject* task){
295 //
296 // Setup tasks for calibration train
297 //
298 AddCalibAlign(task);
299 AddCalibLaser(task);
9e160db9 300 //AddCalibCosmic(task);
6a5d02df 301}
302
303void SetupCalibTaskTrainCluster(TObject* task){
304 //
305 // Setup tasks for calibration train
306 //
307 AddCalibTracks(task);
27eb9bff 308}
309
310//_____________________________________________________________________________
311void ConfigOCDB(Int_t run){
312 //
313 // Configure TPC OCDB
314 //
315 printf("SETUP OCBD for TPC\n");
316 printf("SETUP OCBD for TPC\n");
317 printf("SETUP OCBD for TPC Run =%d\n", run);
318 //
319 //
320 AliTPCParam *param= AliTPCcalibDB::Instance()->GetParameters();
321 param->ReadGeoMatrices();
322 //
323 AliMagF* magF= TGeoGlobalMagField::Instance()->GetField();
324 printf("\n\nSET EXB FIELD\t\n\n");
325 AliTPCcalibDB::Instance()->SetExBField(magF);
326 //
327 //
328 //
329 AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
330 //
331 //AliTPCRecoParam * tpcRecoParam = AliTPCRecoParam::GetCosmicTestParam(kTRUE);
332 //
333 AliCDBEntry* entry = AliCDBManager::Instance()->Get("TPC/Calib/RecoParam");
334 if (!entry){
335 printf("TPC reco param not available");
336 }
337 TObjArray * array = (TObjArray*)entry->GetObject();
338 if (!array){
339 printf("TPC reco param not available");
340 }
341 // 0 - Low Flux (pp), 1- High Flux (Pb-Pb)
342 AliTPCRecoParam * tpcRecoParam = (AliTPCRecoParam*)array->At(1);
343
344 transform->SetCurrentRecoParam(tpcRecoParam);
345 tpcRecoParam->SetUseGainCorrectionTime(0);
346 tpcRecoParam->SetUseRPHICorrection(kFALSE);
347 tpcRecoParam->SetUseTOFCorrection(kFALSE);
348 //
349 tpcRecoParam->SetUseDriftCorrectionTime(0);
350 tpcRecoParam->SetUseDriftCorrectionGY(0);
351 //
352 tpcRecoParam->SetUseRadialCorrection(kFALSE);
353 tpcRecoParam->SetUseQuadrantAlignment(kFALSE);
354 //
355 tpcRecoParam->SetUseSectorAlignment(kFALSE);
356 tpcRecoParam->SetUseFieldCorrection(kFALSE);
357 tpcRecoParam->SetUseExBCorrection(kFALSE);
358 //
359 tpcRecoParam->SetUseMultiplicityCorrectionDedx(kFALSE);
360 tpcRecoParam->SetUseAlignmentTime(kFALSE);
361 tpcRecoParam->SetUseComposedCorrection(kTRUE);
362
363 AliTPCcalibDB::Instance()->SetRun(run);
364}