Extacting the OCDB in a separate module. The detectors have write permission in the...
[u/mrichter/AliRoot.git] / TPC / CalibMacros / CalibClParam.C
1 //
2 // Procedures to create a cluster parametererization
3 // Currently only pseudo code - once will be stable - to be updated as a "normal" macro
4 //
5
6 void PseudoCode(){
7   //
8   // That rough sequence to update  a Cluster param calibration using debug streamers
9   //
10
11   //
12   //0. Load libraries
13   gSystem->Load("libANALYSIS");
14   gSystem->Load("libSTAT");
15   gSystem->Load("libTPCcalib");
16   
17   
18   //1. Load Parameters to be modified:
19   //e.g:
20   AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
21   AliCDBManager::Instance()->SetRun(0) ;
22   AliTPCClusterParam * param = AliTPCcalibDB::Instance()->GetClusterParam();  
23   //
24   //2. Load chain from debug streamers
25   //
26   //e.g
27   gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
28   gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+");
29   AliXRDPROOFtoolkit tool;  
30   TChain * chainres = tool.MakeChain("tracks.txt","ResolCl",0,10200);
31   chainres->Lookup();  
32   TChain * chainGain = tool.MakeChain("gain.txt","dEdx",0,1000000);
33   chainGain->Lookup();
34   TChain * chainCosmic =  tool.MakeChain("cosmic.txt","Track0",0,1000000);
35   chainCosmic->Lookup();
36   //
37   // 3. Do fits - pos correction
38   //
39   AliTPCcalibTracks::MakeQPosNormAll(chainres,param,200000,0) ;
40
41   //
42   //4. Do fits gain
43   // 
44   param->fPosQTnorm[0] = AliTPCcalibTracksGain::MakeQPosNorm(chainGain,0,kFALSE,200000,kTRUE);
45   param->fPosQTnorm[1] = AliTPCcalibTracksGain::MakeQPosNorm(chainGain,1,kFALSE,200000,kTRUE);
46   param->fPosQTnorm[2] = AliTPCcalibTracksGain::MakeQPosNorm(chainGain,2,kFALSE,200000,kTRUE);
47   //
48   param->fPosQMnorm[0] = AliTPCcalibTracksGain::MakeQPosNorm(chainGain,0,kTRUE,200000,kTRUE);
49   param->fPosQMnorm[1] = AliTPCcalibTracksGain::MakeQPosNorm(chainGain,1,kTRUE,200000,kTRUE);
50   param->fPosQMnorm[2] = AliTPCcalibTracksGain::MakeQPosNorm(chainGain,2,kTRUE,200000,kTRUE);
51   //
52   //5. Store results
53   //
54   TFile f("paramout.root","recreate");
55   param->Write("clusterParam");
56   f.Close();
57
58
59   //6. Verification
60   TFile f2("paramout.root");
61   AliTPCClusterParam *param2 = (AliTPCClusterParam*)f2.Get("clusterParam");
62   param2->SetInstance(param2);
63   //
64   // position correction
65   chainres->Draw("AliTPCClusterParam::SPosCorrection(1,0,Cl.fPad,Cl.fTimeBin,Cl.fZ,Cl.fSigmaY2,Cl.fSigmaZ2,Cl.fMax)","Cl.fDetector<36","",10000); // should be line 
66   // gain correction
67   TCut cutA("dedge>3&&fraction2<0.7");
68   chainGain->Draw("(Cl.fMax/gain/dedxM.fElements[2]):AliTPCClusterParam::SQnormPos(0,1,Cl.fPad,Cl.fTimeBin,Cl.fZ,Cl.fSigmaY2,Cl.fSigmaZ2,Cl.fMax,Cl.fQ)","IPad==0"+cutA,"prof",100000);
69
70
71 }
72
73
74 void UpdateParam(){
75   //
76   // Pseudo code -to update cluster params
77   //
78   .L $ALICE_ROOT/TPC/Cal/AliTPCCreateDummyCDB.C
79   TFile f2("paramout.root");
80   AliTPCClusterParam *param2 = (AliTPCClusterParam*)f2.Get("clusterParam");  
81   AliCDBManager *man = AliCDBManager::Instance();
82   gStorLoc = man->GetStorage(gCDBpath);
83   metaData = CreateMetaObject("AliTPCClusterParam");
84   StoreObject("TPC/Calib/ClusterParam/", param2, metaData);
85   
86 }
87
88
89 void TestChainCosmicDedx(){
90   //
91   // pseudo cose
92   //
93   gSystem->Load("libANALYSIS");
94   gSystem->Load("libSTAT");
95   gSystem->Load("libTPCcalib");
96   AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
97   AliCDBManager::Instance()->SetRun(0) ;
98   AliTPCClusterParam * param = AliTPCcalibDB::Instance()->GetClusterParam();  
99   param->SetInstance(param);
100   //e.g
101   gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
102   gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+");
103   AliXRDPROOFtoolkit tool;  
104   TChain * chainCosmic =  tool.MakeChain("cosmic.txt","Track0",0,1000000);
105   chainCosmic->Lookup();
106
107
108
109   TCut cutT("cutT","abs(Tr1.fP[3]+Tr0.fP[3])<0.01");  // OK
110   TCut cutD("cutD","abs(Tr0.fP[0]+Tr1.fP[0])<2");     // OK
111   TCut cutP1("cutP1","abs(Tr0.fP[1]-Tr1.fP[1])<3");   // OK
112   TCut cutPt("cutPt","abs(Tr1.fP[4]+Tr0.fP[4])<0.1&&abs(Tr0.fP[4])+abs(Tr1.fP[4])<10");
113   TCut cutN("cutN","min(Orig0.fTPCncls,Orig1.fTPCncls)>100");
114   TCut cutA=cutT+cutD+cutPt+cutN+cutP1;
115   
116   TCut cutS("cutS","Orig0.fIp.fP[1]*Orig1.fIp.fP[1]>0");
117
118   if (gProof) chainCosmic->SetProof(kTRUE);
119   //
120   //
121   //
122   //
123   chainCosmic->Draw("Seed0.CookdEdxNorm(0.01,0.65,1,0,159,0)/Seed1.CookdEdxNorm(0.01,0.65,1,0,159,0)","min(Orig0.fTPCncls,Orig1.fTPCncls)>120","",10000);
124   
125   //
126   // Q normalization - short - medium - long
127   //
128
129   TVectorD paramT(3);
130   TVectorD paramM(3);
131   TH1F * his =0;
132   chainCosmic->Draw("Seed0.CookdEdxNorm(0.01,0.65,0,0,64,0,kTRUE)/Seed0.CookdEdxNorm(0.01,0.65,0,0,159,0,kTRUE)>>his(100,0.5,1.5)","min(Orig0.fTPCncls,Orig1.fTPCncls)>140","",100000); 
133   TH1 * his = (TH1*)gROOT->FindObject("his");
134   paramT[0]=his->GetMean();
135   //
136  chainCosmic->Draw("Seed0.CookdEdxNorm(0.01,0.65,0,64,129,0,kTRUE)/Seed0.CookdEdxNorm(0.01,0.65,0,0,159,0,kTRUE)>>his(100,0.5,1.5)","min(Orig0.fTPCncls,Orig1.fTPCncls)>140","",100000);  
137  TH1 * his = (TH1*)gROOT->FindObject("his");
138   paramT[1]=his->GetMean();
139   //
140   chainCosmic->Draw("Seed0.CookdEdxNorm(0.01,0.65,0,129,159,0,kTRUE)/Seed0.CookdEdxNorm(0.01,0.65,0,0,159,0,kTRUE)>>his(100,0.5,2.0)","min(Orig0.fTPCncls,Orig1.fTPCncls)>140","",100000); 
141  TH1 * his = (TH1*)gROOT->FindObject("his");
142  paramT[2]=his->GetMean();
143   //
144   //
145   chainCosmic->Draw("Seed0.CookdEdxNorm(0.01,0.65,1,0,64,0,kTRUE)/Seed0.CookdEdxNorm(0.01,0.65,1,0,159,0,kTRUE)>>his(100,0.5,1.5)","min(Orig0.fTPCncls,Orig1.fTPCncls)>140","",100000); 
146   TH1 * his = (TH1*)gROOT->FindObject("his");
147   paramM[0]=his->GetMean();
148   //
149  chainCosmic->Draw("Seed0.CookdEdxNorm(0.01,0.65,1,64,129,0,kTRUE)/Seed0.CookdEdxNorm(0.01,0.65,1,0,159,0,kTRUE)>>his(100,0.5,1.5)","min(Orig0.fTPCncls,Orig1.fTPCncls)>140","",100000); 
150  TH1 * his = (TH1*)gROOT->FindObject("his");
151  paramM[1]=his->GetMean();
152   //
153   chainCosmic->Draw("Seed0.CookdEdxNorm(0.01,0.65,1,129,159,0,kTRUE)/Seed0.CookdEdxNorm(0.01,0.65,1,0,159,0,kTRUE)>>his(100,0.5,2.0)","min(Orig0.fTPCncls,Orig1.fTPCncls)>140","",100000); 
154  TH1 * his = (TH1*)gROOT->FindObject("his");
155  paramM[2]=his->GetMean();
156
157  param->fQpadTnorm=(TVectorD*)paramT->Clone();
158  param->fQpadMnorm=(TVectorD*)paramM->Clone();
159  
160  TFile f("paramout.root","recreate");
161  param->Write("clusterParam");
162  f.Close();
163
164 }
165
166
167 void dedxDemo(){
168   chainCosmic->Draw("(Seed0.CookdEdxNorm(0.01,0.65,1,0,159,0,kTRUE,kTRUE)+Seed1.CookdEdxNorm(0.01,0.65,1,0,159,0,kTRUE,kTRUE))*0.5:log(Tr0.P())>>his2(100,-2,5,500,0,200)","min(Orig0.fTPCncls,Orig1.fTPCncls)>110");   
169 }