Extacting the OCDB in a separate module. The detectors have write permission in the...
[u/mrichter/AliRoot.git] / TPC / macros / CalibrateTPC.C
CommitLineData
1037b1ac 1/*
2 Simple calibration analysis
967eae0d 3 //
4 //0. Setup memory chcecker if you want
5 //
3d64ddde 6 TMemStat *memstat = new TMemStat("new,gnubuildin");
967eae0d 7 AliSysInfo::AddCallBack(TMemStatManager::GetInstance()->fStampCallBack);
1037b1ac 8
967eae0d 9 AliSysInfo::AddStamp("Start");
1037b1ac 10 //1. Load needed libraries
11 gSystem->Load("libANALYSIS");
12 gSystem->Load("libTPCcalib");
13 //
14 // Setup analysis manager
15 //
1037b1ac 16 .L $ALICE_ROOT/TPC/macros/CalibrateTPC.C
3d64ddde 17 AliAnalysisManager * mgr = ( AliAnalysisManager *)SetupCalibTask("/V2/");
18 gROOT->Macro(Form("$ALICE_ROOT/TPC/macros/ConfigOCDB.C(%f)",5));
19
1037b1ac 20 //
21 // Process data - chain
22 //
23 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
ae28e92e 24 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
6fa23923 25 AliXRDPROOFtoolkit tool;
3d64ddde 26 TChain * chain = tool.MakeChainRandom("esd.txt","esdTree",0,5);
ae28e92e 27 chain->Lookup();
cbc19295 28 // memory
3d64ddde 29 mgr->SetNSysInfo(1000);
cbc19295 30 //
3d64ddde 31 mgr->SetDebugLevel(10);
f491be13 32 mgr->StartAnalysis("proof",chain);
33 //mgr->StartAnalysis("local",chain);
967eae0d 34 // delete manager
35 //
36 delete mgr;
37 AliSysInfo::AddStamp("End");
38 //
39 // analyze memstat report
40 //
41 delete memstat;
3d64ddde 42 TMemStat mem;
43 mem.MakeReport(0,0,"order 0 sortstat 3 sortstamp 0 sortdeep 10 stackdeep 15 maxlength 50")
1037b1ac 44*/
45
3d64ddde 46TObject * SetupCalibTask(char * prefix ="/V12/") {
1037b1ac 47 //
48 //
49 //
50 TStopwatch stopwatch;
51 stopwatch.Start();
967eae0d 52 //
f491be13 53 //
1037b1ac 54 AliAnalysisManager *mgr=new AliAnalysisManager("TestManager");
55
56 AliESDInputHandler* esdH=new AliESDInputHandler;
57 esdH->SetActiveBranches("ESDfriend");
58 mgr->SetInputEventHandler(esdH);
ae28e92e 59 //
60 //
61 AliCDBManager::Instance()->SetRun(1) ;
162637e4 62 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
ae28e92e 63 AliTPCClusterParam * clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
967eae0d 64 AliTPCAnalysisTaskcalib *task1=new AliTPCAnalysisTaskcalib("TPC calibration task");
1037b1ac 65
78abca19 66 AliTPCcalibTracksCuts *cuts = new AliTPCcalibTracksCuts(40, 0.4, 0.5, 0.13, 0.018);
1037b1ac 67
967eae0d 68 //
ae28e92e 69 AliTPCcalibTracks *calibTracks = new AliTPCcalibTracks("calibTracks", "Resolution calibration object for tracks", clusterParam, cuts);
78abca19 70
71
967eae0d 72 AliTPCcalibTracksGain *calibTracksGain = new AliTPCcalibTracksGain("calibTracksGain","Gain calibration using tracks",cuts);
73 AliTPCcalibAlign *calibAlign = new AliTPCcalibAlign("alignTPC","Alignment of the TPC sectors");
3d64ddde 74 AliTPCcalibAlign *calibAlignAll = new AliTPCcalibAlign("alignTPCAll","Alignment of the TPC sectors- All");
752287d5 75 AliTPCcalibLaser *calibLaser = new AliTPCcalibLaser("laserTPC","laserTPC");
76 AliTPCcalibCosmic *calibCosmic = new AliTPCcalibCosmic("cosmicTPC","cosmicTPC");
78abca19 77 AliTPCcalibCalib *calibCalib = new AliTPCcalibCalib("calibTPC","calibTPC");
78 TTimeStamp startTime(2008,9,0,0,0,0);
79 TTimeStamp stopTime(2008,11,0,0,0,0);
3d64ddde 80 AliTPCcalibTime *calibTime = new AliTPCcalibTime("calibTime","calibTime", startTime.GetSec(), stopTime.GetSec(), 5*60, 5*60);
81
82 AliTPCcalibUnlinearity *calibUnlinearity = new AliTPCcalibUnlinearity("calibUnlinearity","calibUnlinearity");
83 AliTPCcalibUnlinearity *calibUnlinearityAll = new AliTPCcalibUnlinearity("calibUnlinearityAll","calibUnlinearityAll");
78abca19 84
f491be13 85 //
3d64ddde 86 calibTracks->SetDebugLevel(2);
f491be13 87 calibTracks->SetStreamLevel(20);
88 calibTracksGain->SetDebugLevel(2);
89 calibTracksGain->SetStreamLevel(20);
967eae0d 90 calibAlign->SetDebugLevel(20);
f491be13 91 calibAlign->SetStreamLevel(10);
3d64ddde 92 calibAlignAll->SetDebugLevel(20);
93 calibAlignAll->SetStreamLevel(10);
94 calibLaser->SetDebugLevel(0);
95 calibLaser->SetStreamLevel(0);
752287d5 96 calibCosmic->SetDebugLevel(20);
97 calibCosmic->SetStreamLevel(2);
3d64ddde 98 calibCalib->SetDebugLevel(0);
99 calibCalib->SetStreamLevel(0);
100 calibTime->SetDebugLevel(20);
101 calibTime->SetStreamLevel(10);
102 //
103 calibUnlinearity->SetDebugLevel(20);
104 calibUnlinearity->SetStreamLevel(10);
105 calibUnlinearityAll->SetDebugLevel(20);
106 calibUnlinearityAll->SetStreamLevel(10);
107
108 calibCalib->SetTriggerMask(-1,-1,kFALSE); //accept everything
109 calibTracks->SetTriggerMask(-1,16,kTRUE); //reject laser trigger, accept everything else
110 calibTracksGain->SetTriggerMask(-1,16,kTRUE); //reject laser trigger, accept everything else
111 calibAlign->SetTriggerMask(-1,-1,kTRUE); //accept everything
112 calibAlignAll->SetTriggerMask(-1,-1,kFALSE); //accept everything
113 calibLaser->SetTriggerMask(-1,-1,kFALSE); //accept only laser trigger
114 calibCosmic->SetTriggerMask(-1,-1,kTRUE); //reject laser trigger, accept everything else
115 calibTime->SetTriggerMask(-1,-1,kFALSE); //accept everything
116 calibUnlinearity->SetTriggerMask(-1,-1,kTRUE); //reject laser
117 calibUnlinearityAll->SetTriggerMask(-1,-1,kFALSE); //non reject laser
118
752287d5 119
967eae0d 120 //
ae28e92e 121 // ---*---*-----*-*-----*----------*---
1037b1ac 122 // ADD CALIB JOBS HERE!!!!!!!!!!!!!!!!
78abca19 123 task1->AddJob(calibCalib);
3d64ddde 124 //task1->AddJob(calibAlign);
125 //task1->AddJob(calibAlignAll);
126 //task1->AddJob(calibLaser);
127 //task1->AddJob(calibCosmic);
78abca19 128 task1->AddJob(calibTime);
129
3d64ddde 130 //task1->AddJob(calibTracksGain);
131 //task1->AddJob(calibTracks);
132 //task1->AddJob(calibUnlinearity);
133 //task1->AddJob(calibUnlinearityAll);
1037b1ac 134 // task1->AddJob(new AliTPCcalibV0);
135 // -*----*----*---*-*------*-------**--
136 // -------*--*---------*-----*-------*-
78abca19 137 TString path=gSystem->pwd();
138 path+=prefix;
139 gSystem->mkdir(path);
140 task1->SetDebugOuputhPath(path.Data());
141
1037b1ac 142 mgr->AddTask(task1);
143
144 AliAnalysisDataContainer *cinput1
145 =mgr->CreateContainer("cchain1",TChain::Class(),
146 AliAnalysisManager::kInputContainer);
147 AliAnalysisDataContainer *coutput1
bdb9738c 148 =mgr->CreateContainer("TPCCalib",TObjArray::Class(),
1037b1ac 149 AliAnalysisManager::kOutputContainer,
150 "CalibObjects.root");
78abca19 151
3d64ddde 152 //coutput1->SetSpecialOutput(kTRUE);
78abca19 153 //coutput1->SetFileName("CalibObjectFile.root");
1037b1ac 154 mgr->ConnectInput(task1,0,cinput1);
155 mgr->ConnectOutput(task1,0,coutput1);
78abca19 156 //
157 //mgr->SetSpecialOutputLocation(path->Data());
1037b1ac 158
3d64ddde 159 if (!mgr->InitAnalysis()) return 0;
1037b1ac 160 mgr->PrintStatus();
161
162 stopwatch.Stop();
163 stopwatch.Print();
164 return mgr;
165}
78abca19 166
167
3d64ddde 168
169
170
171
172void CalibrateTPC(Float_t magf, Int_t first, Int_t last){
173 gSystem->Load("libANALYSIS");
174 gSystem->Load("libTPCcalib");
175 gROOT->Macro(Form("$ALICE_ROOT/TPC/macros/ConfigOCDB.C(%f)",magf));
176 //
177 // Setup analysis manager
178 //
179 //.L $ALICE_ROOT/TPC/macros/CalibrateTPC.C
180 AliAnalysisManager * mgr = (AliAnalysisManager*)SetupCalibTask("/V3/");
181 //
182 // Process data - chain
183 //
184 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
185 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+");
186 AliXRDPROOFtoolkit tool;
187 TChain * chain = tool.MakeChain("esd.txt","esdTree",0,last-first,last);
188 chain->Lookup();
189 // memory
190 mgr->SetNSysInfo(5000);
191 //
192 mgr->SetDebugLevel(1);
193 mgr->StartAnalysis("local",chain);
194
78abca19 195}