]> git.uio.no Git - u/mrichter/AliRoot.git/blob - GRP/UpdateCDBVertexDiamond.C
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / GRP / UpdateCDBVertexDiamond.C
1 #include "ARVersion.h"
2 #if !defined(__CINT__) || defined(__MAKECINT__)
3 #include "AliCDBManager.h"
4 #include "AliCDBStorage.h"
5 #include "AliCDBId.h"
6 #include "AliCDBMetaData.h"
7 #include "AliESDVertex.h"
8 #include <TROOT.h>
9 #include "AliRun.h"
10 #include <TString.h>
11 #include "AliLog.h"
12 #endif
13
14 void UpdateCDBVertexDiamond(const char* objName, Double_t xmed, Double_t ymed, Double_t zmed, Double_t sigx, Double_t sigy, Double_t sigz) {
15   // produce the mean vertex with the current AliRoot and store it in the
16   // CDB
17   // andrea.dainese@pd.infn.it
18   
19   AliCDBManager* man = AliCDBManager::Instance();
20   if(!gSystem->Getenv("STORAGE")){
21       man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
22   }else{
23       man->SetDefaultStorage(gSystem->Getenv("STORAGE"));
24   }
25
26   Int_t firstRun=0;
27   if(gSystem->Getenv("FIRSTRUN")) firstRun=TString(gSystem->Getenv("FIRSTRUN")).Atoi();
28   Int_t lastRun=AliCDBRunRange::Infinity();
29   if(gSystem->Getenv("LASTRUN")) lastRun=TString(gSystem->Getenv("LASTRUN")).Atoi();
30   TString objFullName="GRP/Calib/";
31
32   if(objName=="MeanVertex" || objName=="MeanVertexSPD" || objName=="MeanVertexTPC"){
33       objFullName += objName;
34   }else{
35      Printf("\"%s\" is not a valid calibration object. Exiting!",objName);
36      return;
37   }
38   AliCDBId id(objFullName.Data(),firstRun,lastRun);
39   AliCDBMetaData *metadata= new AliCDBMetaData();
40
41   // Get root and AliRoot versions
42   const char* rootv = gROOT->GetVersion();
43   TString av(ALIROOT_BRANCH);
44   TString revnum(ALIROOT_REVISION);
45
46   metadata->SetResponsible("prino@to.infn.it");
47   metadata->SetComment("Default mean vertex position");
48   metadata->SetAliRootVersion(av.Data());
49   metadata->SetComment(Form("Default mean vertex produced with root version %s and AliRoot %s, revision number %s",rootv,av.Data(),revnum));
50   
51
52   Printf(Form("Storing in CDB the default mean vertex produced with root version %s and"
53                           "AliRoot version %s, revision number %s", rootv, av.Data(), revnum));
54
55   Double_t sigma[3],position[3];
56   position[0]=xmed;
57   position[1]=ymed;
58   position[2]=zmed;
59   sigma[0]=sigx;
60   sigma[1]=sigy;
61   sigma[2]=sigz;
62
63   AliESDVertex *vertex = new AliESDVertex(position,sigma,"vtxmean");
64   vertex->PrintStatus();
65
66   man->Put(vertex,id,metadata);
67
68 }
69
70
71 void UpdateCDBVertexDiamondOld(Double_t xmed = 0., Double_t ymed = 0., Double_t sigx = 0.0060, Double_t sigy = 0.0060, Double_t sigz = 3.8) {
72   // produce the mean vertex with the current AliRoot and store it in the
73   // CDB
74   
75   AliCDBManager* man = AliCDBManager::Instance();
76   man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
77   man->SetRun(0);
78   AliCDBId id("GRP/Calib/MeanVertex",0,AliCDBRunRange::Infinity());
79   AliCDBId idTPC("GRP/Calib/MeanVertexTPC",0,AliCDBRunRange::Infinity());
80   AliCDBId idSPD("GRP/Calib/MeanVertexSPD",0,AliCDBRunRange::Infinity());
81   AliCDBMetaData *metadata= new AliCDBMetaData();
82
83   // Get root and AliRoot versions
84   const char* rootv = gROOT->GetVersion();
85   TString av(ALIROOT_BRANCH);
86   TString revnum(ALIROOT_REVISION);
87
88   metadata->SetResponsible("prino@to.infn.it");
89   metadata->SetComment("Default mean vertex position");
90   metadata->SetAliRootVersion(av.Data());
91   metadata->SetComment(Form("Default mean vertex produced with root version %s and AliRoot %s, revision number %s",rootv,av.Data(),revnum));
92   
93
94   Printf(Form("Storing in CDB the default mean vertex produced with root version %s and"
95                           "AliRoot version %s, revision number %s", rootv, av.Data(), revnum));
96
97   Double_t resolx=5./10000.; // this is error on the weighted mean (5 micron) 
98   Double_t resoly=5./10000.; // this is error on the weighted mean (5 micron)
99   Double_t sigma[3],position[3];
100   position[0]=xmed;
101   position[1]=ymed;
102   position[2]=0.;
103   sigma[0]=TMath::Sqrt(sigx*sigx+resolx*resolx);
104   sigma[1]=TMath::Sqrt(sigy*sigy+resoly*resoly);
105   sigma[2]=sigz;
106
107   AliESDVertex *vertex = new AliESDVertex(position,sigma,"vtxmean");
108   vertex->PrintStatus();
109
110   man->Put(vertex,id,metadata);
111
112   position[0]=xmed;
113   position[1]=ymed;
114   position[2]=0.;
115   sigma[0]=TMath::Sqrt(sigx*sigx+resolx*resolx);
116   sigma[1]=TMath::Sqrt(sigy*sigy+resoly*resoly);
117   sigma[2]=sigz;
118
119   AliESDVertex *vertexTPC = new AliESDVertex(position,sigma,"vtxmean");
120   vertexTPC->PrintStatus();
121
122   man->Put(vertexTPC,idTPC,metadata);
123
124   position[0]=xmed;
125   position[1]=ymed;
126   position[2]=0.;
127   sigma[0]=TMath::Sqrt(sigx*sigx+resolx*resolx);
128   sigma[1]=TMath::Sqrt(sigy*sigy+resoly*resoly);
129   sigma[2]=sigz;
130
131   AliESDVertex *vertexSPD = new AliESDVertex(position,sigma,"vtxmean");
132   vertexSPD->PrintStatus();
133
134   man->Put(vertexSPD,idSPD,metadata);
135
136
137
138 }
139
140
141