Update of calibration code (Raphaelle)
[u/mrichter/AliRoot.git] / TRD / Macros / AddTaskTRDCalib.C
CommitLineData
98937691 1//=============================================================================
2//
3// *** AddTaskTRDCalib
4//
5// This macros setup the TRD calibration task
6//
7//=============================================================================
8
9const AliTRDCalDet *GetCalDet(Int_t runNumber);
10
11AliAnalysisTask *AddTaskTRDCalib(Int_t runNumber)
12{
13 gSystem->Load("libTRDcalib");
14 // pointer to the analysis manager
15 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
16 if (!mgr) {
17 Error("AddTaskTRDCalib", "No analysis manager to connect to.");
18 return NULL;
19 }
20
21 // check the input handler
22 if (!mgr->GetInputEventHandler()) {
23 ::Error("AddTask", "This task requires an input event handler");
24 return NULL;
25 }
26
27 /////////////////////////
28 // The TRD calib Task
29 /////////////////////////
30 AliTRDCalibTask *calibTask = new AliTRDCalibTask();
31 calibTask->SetHisto2d(kTRUE);
01239968 32 calibTask->SetVector2d(kFALSE);
98937691 33 calibTask->SetVdriftLinear(kTRUE);
34 calibTask->SetNz(0,0);
35 calibTask->SetNrphi(0,0);
36 calibTask->SetNz(0,1);
37 calibTask->SetNrphi(0,1);
38 calibTask->SetNz(0,2);
39 calibTask->SetNrphi(0,2);
40 calibTask->SetLow(0);
41 calibTask->SetHigh(30);
01239968 42 calibTask->SetFillZero(kTRUE);
43 calibTask->AddSelectedTriggerClass("CINT1B-ABCE-NOPF-ALL");
44 calibTask->SetReject(kFALSE);
98937691 45 //calibTask->SetDebug(3);
46 calibTask->SetNbTimeBins(30);
47 //calibTask->SetMaxEvent(20);
48 calibTask->SetRequirePrimaryVertex(kTRUE);
49 calibTask->SetMinNbOfContributors(1);
50 calibTask->SetMaxCluster(100.0);
51 calibTask->SetNbMaxCluster(2);
52 calibTask->SetCalDetGain(GetCalDet(runNumber));
53
54 /////////////////////////////
55 // Track cuts
56 /////////////////////////////
57 AliESDtrackCuts *trackCuts = new AliESDtrackCuts("trackcuts","trackcuts");
58 trackCuts->SetMinNClustersTPC(50);
59 trackCuts->SetMaxChi2PerClusterTPC(3.5);
60 //trackCuts->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
61 trackCuts->SetRequireTPCRefit(kTRUE);
62 //trackCuts->SetRequireITSRefit(kTRUE);
63 //trackCuts->SetMinNsigmaToVertex(10);
64 trackCuts->SetRequireSigmaToVertex(kFALSE);
65 trackCuts->SetAcceptKinkDaughters(kFALSE);
66 trackCuts->SetMaxDCAToVertexZ(30.0);
67 trackCuts->SetMaxDCAToVertexXY(3.0);
68 trackCuts->SetDCAToVertex2D(kFALSE);
69
70 calibTask->SetESDtrackCuts(trackCuts);
71
72 mgr->AddTask(calibTask);
73
74 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
75
76 if (!cinput) cinput = mgr->CreateContainer("cchain",TChain::Class(),
77 AliAnalysisManager::kInputContainer);
78
79 AliAnalysisDataContainer *coutput =mgr->CreateContainer("TRDCalib",TList::Class(), AliAnalysisManager::kOutputContainer, "AliESDfriends_v1.root");
80
81
82 mgr->ConnectInput(calibTask,0,cinput);
01239968 83 mgr->ConnectOutput(calibTask,1,coutput);
98937691 84 return calibTask;
85
86}
87
88const AliTRDCalDet *GetCalDet(Int_t runNumber){
89 //
90 // Get Cal Det for gas gain
91 //
92
93 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TRD/Calib/ChamberGainFactor",runNumber);
94 if(!entry) {
95 printf("Found no entry\n");
96 return 0x0;
97 }
98 const AliTRDCalDet* calDet = (AliTRDCalDet *)entry->GetObject();
99
100 return calDet;
101
01239968 102}
103