updated patch for TRD dEdx OADB
[u/mrichter/AliRoot.git] / TRD / makeTRDdEdxOADB.C
CommitLineData
9c499471 1/*
2g++ makeTRDdEdxOADB.C -g -O3 -Wall -Werror -I$ROOTSYS/include -I$ALICE_BUILD/include -I$ALICE_ROOT/TRD -I$ALICE_ROOT/TRD/Cal -L$ROOTSYS/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -lMinuit -lEG -lGeom -lVMC -lProof -lProofPlayer -lXMLParser -lXMLIO -lSpectrum -lTreePlayer -lMLP -lGui -L$ALICE_BUILD/lib/tgt_linuxx8664gcc -lCDB -lSTEER -lRAWDatarec -lESD -lSTEERBase -lANALYSIS -lRAWDatabase -lANALYSISalice -lAOD -lTPCrec -lTPCbase -lTRDbase -lTRDrec -lSTAT -o makeTRDdEdxOADB
3
4#generate OADB
5makeTRDdEdxOADB 1
6
7#read and print OADB content
8makeTRDdEdxOADB 0
9 */
10
11#include <math.h>
12#include <stdio.h>
13#include <fstream>
14#include <string>
15#include <iostream>
16using namespace std;
17
18#include "Math/Functor.h"
19#include "Math/Factory.h"
20#include "Math/Minimizer.h"
21
22#include "TASImage.h"
23#include "TAxis.h"
24#include "TColor.h"
25#include "TCut.h"
26#include "TCanvas.h"
27#include "TChain.h"
28#include "TDatabasePDG.h"
29#include "TDecompLU.h"
30#include "TDecompSVD.h"
31#include "TDirectory.h"
32#include "TEventList.h"
33#include "TF1.h"
34#include "TF2.h"
35#include "TFile.h"
36#include "TGaxis.h"
37#include "TGeoManager.h"
38#include "TGeoGlobalMagField.h"
39#include "TRandom3.h"
40#include "TGraph.h"
41#include "TGraphAsymmErrors.h"
42#include "TGraphErrors.h"
43#include "TGraphPolar.h"
44#include "TGrid.h"
45#include "TH1F.h"
46#include "TH2F.h"
47#include "TH1D.h"
48#include "TH2D.h"
49#include "TH3D.h"
50#include "THnSparse.h"
51#include "TLatex.h"
52#include "TLegend.h"
53#include "TLegendEntry.h"
54#include "TLinearFitter.h"
55#include "TMarker.h"
56#include "TMath.h"
57#include "TMatrixD.h"
58#include "TMinuit.h"
59#include "TPaletteAxis.h"
60#include "TPaveText.h"
61#include "TPolyMarker.h"
62#include "TProfile.h"
63#include "TROOT.h"
64#include "TStopwatch.h"
65#include "TString.h"
66#include "TStyle.h"
67#include "TSystem.h"
68#include "TSystemDirectory.h"
69#include "TTree.h"
70#include "TTimeStamp.h"
71#include "TUUID.h"
72#include "TVector3.h"
73#include "TVectorD.h"
74
75#include "AliAnalysisManager.h"
76#include "AliAnalysisTask.h"
77#include "AliAODInputHandler.h"
78#include "AliCDBEntry.h"
79#include "AliCDBManager.h"
80#include "AliCentralitySelectionTask.h"
81#include "AliCTPRawStream.h"
82#include "AliESDEvent.h"
83#include "AliESDfriend.h"
84#include "AliESDHeader.h"
85#include "AliESDInputHandler.h"
86#include "AliESDtrackCuts.h"
87#include "AliESDtrack.h"
88#include "AliESDVertex.h"
89#include "AliExternalTrackParam.h"
90#include "AliGeomManager.h"
91#include "AliGRPManager.h"
92#include "AliGRPObject.h"
93#include "AliLog.h"
94#include "AliMagF.h"
95#include "AliMathBase.h"
96#include "AliMCEventHandler.h"
97#include "AliPhysicsSelectionTask.h"
98#include "AliPID.h"
99#include "AliRawReaderRoot.h"
100#include "AliReconstruction.h"
101//#include "AliTPCcalibDB.h"
102#include "AliTPCclusterMI.h"
103//#include "AliTPCParam.h"
104//#include "AliTPCRecoParam.h"
105//#include "AliTPCseed.h"
106//#include "AliTPCTransform.h"
107#include "AliTrackerBase.h"
108#include "AliTracker.h"
109#include "AliTrackPointArray.h"
110#include "AliTRDdEdxBaseUtils.h"
111#include "AliTRDdigitsManager.h"
112#include "AliTRDrawStream.h"
113#include "AliTRDseedV1.h"
114#include "AliTriggerAnalysis.h"
115#include "AliSysInfo.h"
116
117
118#include "AliTRDdEdxParams.h"
119#include "AliOADBContainer.h"
120#include "AliLog.h"
121
122AliTRDdEdxParams * getDefault()
123{
124 //
125 //version 31/07/2014 by Xianguo Lu based on pPb small sample only for nch=6 ncls/nch>=18, no binning in eta, no binning on multiplicity
126 //
127
128 AliTRDdEdxParams *defobj=new AliTRDdEdxParams("default","default");
129
130 const Float_t meanpars[]={1.521e+00 , 7.294e-01 , 8.066e+00 , 2.146e-02 , 3.137e+01 , 7.160e-15 , 2.838e+00 , 1.100e+01};
131 const Float_t respars[]={-4.122e-01 , 1.019e+00 , -1.319e-01};
132
133 for(Int_t ipar=0; ipar< MAXNPAR; ipar++){
134 if(ipar == AliPID::kProton){
135 const Float_t tmpproton[]={2.026e+00 , -1.462e-04 , 1.202e+00 , 1.162e-01 , 2.092e+00 , -3.018e-02 , 3.665e+00 , 3.487e-07};
136 defobj->SetMeanParameter(ipar, sizeof(tmpproton)/sizeof(Float_t), tmpproton);
137 }
138 else if(ipar == AliPID::kPion || ipar ==AliPID::kElectron){
139 const Float_t tmppe[]={1.508e+00 , 7.356e-01 , 8.002e+00 , 1.932e-02 , 3.058e+01 , 5.114e-18 , 3.561e+00 , 1.408e+01};
140 defobj->SetMeanParameter(ipar, sizeof(tmppe)/sizeof(Float_t), tmppe);
141 }
142 else{
143 defobj->SetMeanParameter(ipar, sizeof(meanpars)/sizeof(Float_t), meanpars);
144 }
145
146 defobj->SetSigmaParameter(ipar, sizeof(respars)/sizeof(Float_t), respars);
147 }
148
149 defobj->Print();
150
151 return defobj;
152}
153
154void makeTRDdEdxOADB(const Bool_t kMC=0)
155{
156 //
157 //make OADB object
158 //currently only default
159 //non-default has to be tested after finer inspection on dependence on eta, multiplicity, etc.
160 //
161
162 AliTRDdEdxParams * defobj = getDefault();
163
164 TString containerName = "TRDdEdxParamsContainer";
165 AliOADBContainer* cont = new AliOADBContainer(containerName.Data());
166
167 //current convention as other detetor is only to provide for data
168 //no MC is seen in current (31/07/2014) AliROOT except for HMPID
169
170 const TString filePathNamePackage=Form("$ALICE_ROOT/OADB/COMMON/PID/%s/TRDdEdxParams.root", kMC?"MC":"data");
171 Int_t statusCont = cont->InitFromFile(filePathNamePackage.Data(), cont->GetName());
172 if (statusCont) {
173 printf("No OADBContainer for the current settings found - creating a new one...\n");
174 }
175
176 //non-default params
177 /*
178 const Double_t runLow = 1;
179 const Double_t runUp = 10;
180 const Int_t index = cont->GetIndexForRun((runUp + runLow) / 2.0);
181 if (index < 0) {
182 printf("Creating new object for run range %d - %d...\n", runLow, runUp);
183 cont->AppendObject(hh, runLow, runUp);
184 }
185 else {
186 printf("Updating existing object for run range %d - %d...\n", runLow, runUp);
187 cont->UpdateObject(index, hh, runLow, runUp);
188 }
189 */
190
191 //default params
192 cont->CleanDefaultList(); // Remove old default objects at first
193 cont->AddDefaultObject(defobj);
194
195
196 TFile* f = new TFile(filePathNamePackage.Data(), "update");
197 f->Delete(cont->GetName());
198 cont->Write(0, TObject::kOverwrite);
199 f->Purge();
200 f->Close();
201
202 printf("makeTRDdEdxOADB done\n");
203}
204
205void readTRDdEdxOADB(const Bool_t kMC=0)
206{
207 //
208 //only read in default
209 //non-default has to be uncommented if needed
210 //
211
212 const TString containerName = "TRDdEdxParamsContainer";
213 AliOADBContainer cont(containerName.Data());
214
215 const TString filePathNamePackage=Form("$ALICE_ROOT/OADB/COMMON/PID/%s/TRDdEdxParams.root", kMC?"MC":"data");
216
217 const Int_t statusCont = cont.InitFromFile(filePathNamePackage.Data(), cont.GetName());
218 if (statusCont){
219 printf("Failed initializing settings from OADB\n"); exit(1);
220 }
221
222 /*
223 Int_t fRun = 5;
224 AliTRDdEdxParams *jj=(AliTRDdEdxParams*)(cont.GetObject(fRun, defaultObj.Data()));
225 jj->Print();
226 */
227
228 TString defaultObj = "default";
229 AliTRDdEdxParams *jj=(AliTRDdEdxParams*)(cont.GetObject(1000, defaultObj.Data()));
230 jj->Print();
231
232}
233
234int main(int argc, char * argv[])
235{
236 for(Int_t ii=0; ii<argc; ii++){
237 printf("%d: %s\n", ii, argv[ii]);
238 }
239
240 if(argc!=2){
241 printf("argc!=2\n");
242 return 1;
243 }
244
245 if(atoi(argv[1])){
246 makeTRDdEdxOADB();
247 }
248 else{
249 readTRDdEdxOADB();
250 }
251
252 return 0;
253}