Adding Domenico Colella as responsible for SPD part in TRI pp
[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
a8da1749 133 for(Int_t ipar=0; ipar< 10; ipar++){
134 for(Int_t ich = 0; ich < 2; ich++){
135 for(Int_t icls = 0; icls < 2; icls++){
136
137 TVectorF tmp;
138 //!!! has to be consistent with
139 //Int_t GetIter(const Int_t itype, const Int_t nch, const Int_t ncls) const
140 //in AliTRDdEdxParams
141 const Int_t nch = ich==0? 6 : 1;
142 const Int_t ncls = icls==0? 180 : 1;
143
144
145 if(ich==0 && icls==0){
146 if(ipar == AliPID::kProton){
147 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};
148 defobj->SetMeanParameter(ipar, nch, ncls, sizeof(tmpproton)/sizeof(Float_t), tmpproton);
149 }
150 else if(ipar == AliPID::kPion || ipar ==AliPID::kElectron){
151 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};
152 defobj->SetMeanParameter(ipar, nch, ncls, sizeof(tmppe)/sizeof(Float_t), tmppe);
153 }
154 else{
155 defobj->SetMeanParameter(ipar, nch, ncls, sizeof(meanpars)/sizeof(Float_t), meanpars);
156 }
157
158 defobj->SetSigmaParameter(ipar, nch, ncls, sizeof(respars)/sizeof(Float_t), respars);
159 }
160 else{
161 //bad nch and ncls, 0-size array
162 defobj->SetMeanParameter( ipar, nch, ncls, 0, meanpars);
163 defobj->SetSigmaParameter(ipar, nch, ncls, 0, respars);
164 }
165
166 }
9c499471 167 }
9c499471 168 }
169
170 defobj->Print();
171
172 return defobj;
173}
174
175void makeTRDdEdxOADB(const Bool_t kMC=0)
176{
177 //
178 //make OADB object
179 //currently only default
180 //non-default has to be tested after finer inspection on dependence on eta, multiplicity, etc.
181 //
182
183 AliTRDdEdxParams * defobj = getDefault();
184
185 TString containerName = "TRDdEdxParamsContainer";
186 AliOADBContainer* cont = new AliOADBContainer(containerName.Data());
187
188 //current convention as other detetor is only to provide for data
189 //no MC is seen in current (31/07/2014) AliROOT except for HMPID
190
191 const TString filePathNamePackage=Form("$ALICE_ROOT/OADB/COMMON/PID/%s/TRDdEdxParams.root", kMC?"MC":"data");
192 Int_t statusCont = cont->InitFromFile(filePathNamePackage.Data(), cont->GetName());
193 if (statusCont) {
194 printf("No OADBContainer for the current settings found - creating a new one...\n");
195 }
196
197 //non-default params
198 /*
199 const Double_t runLow = 1;
200 const Double_t runUp = 10;
201 const Int_t index = cont->GetIndexForRun((runUp + runLow) / 2.0);
202 if (index < 0) {
203 printf("Creating new object for run range %d - %d...\n", runLow, runUp);
204 cont->AppendObject(hh, runLow, runUp);
205 }
206 else {
207 printf("Updating existing object for run range %d - %d...\n", runLow, runUp);
208 cont->UpdateObject(index, hh, runLow, runUp);
209 }
210 */
211
212 //default params
213 cont->CleanDefaultList(); // Remove old default objects at first
214 cont->AddDefaultObject(defobj);
215
216
217 TFile* f = new TFile(filePathNamePackage.Data(), "update");
218 f->Delete(cont->GetName());
219 cont->Write(0, TObject::kOverwrite);
220 f->Purge();
221 f->Close();
222
223 printf("makeTRDdEdxOADB done\n");
224}
225
226void readTRDdEdxOADB(const Bool_t kMC=0)
227{
228 //
229 //only read in default
230 //non-default has to be uncommented if needed
231 //
232
233 const TString containerName = "TRDdEdxParamsContainer";
234 AliOADBContainer cont(containerName.Data());
235
236 const TString filePathNamePackage=Form("$ALICE_ROOT/OADB/COMMON/PID/%s/TRDdEdxParams.root", kMC?"MC":"data");
237
238 const Int_t statusCont = cont.InitFromFile(filePathNamePackage.Data(), cont.GetName());
239 if (statusCont){
240 printf("Failed initializing settings from OADB\n"); exit(1);
241 }
242
243 /*
244 Int_t fRun = 5;
245 AliTRDdEdxParams *jj=(AliTRDdEdxParams*)(cont.GetObject(fRun, defaultObj.Data()));
246 jj->Print();
247 */
248
249 TString defaultObj = "default";
250 AliTRDdEdxParams *jj=(AliTRDdEdxParams*)(cont.GetObject(1000, defaultObj.Data()));
251 jj->Print();
252
253}
254
255int main(int argc, char * argv[])
256{
257 for(Int_t ii=0; ii<argc; ii++){
258 printf("%d: %s\n", ii, argv[ii]);
259 }
260
261 if(argc!=2){
262 printf("argc!=2\n");
263 return 1;
264 }
265
266 if(atoi(argv[1])){
267 makeTRDdEdxOADB();
268 }
269 else{
270 readTRDdEdxOADB();
271 }
272
273 return 0;
274}