]> git.uio.no Git - u/mrichter/AliRoot.git/blame - GRP/UpdateCDBGRPEntryMC.C
doxy: Ignore Begin_Html and End_Html tags
[u/mrichter/AliRoot.git] / GRP / UpdateCDBGRPEntryMC.C
CommitLineData
75958532 1 void UpdateCDBGRPEntryMC() {
2 // produce the GRP entry in CDB
3 // reading MC parameter from Config.C
4
5 AliCDBManager* man = AliCDBManager::Instance();
162637e4 6 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
75958532 7 man->SetRun(0);
8 AliCDBId id(AliQA::GetGRPPath(), 0, AliCDBRunRange::Infinity());
9 AliCDBMetaData *metadata= new AliCDBMetaData();
10
11 // Get root version
12 const char* rootv = gROOT->GetVersion();
13 metadata->SetResponsible("Yves.Schutz@cern.ch");
14 metadata->SetComment("GRP parameters for Monte Carlo");
15
16
17 TMap *mappp = GetGRPList();
18
19 // Printf("Storing in CDB the default values for the GRP %d parameters produced with root %s and AliRoot version %s",list->GetEntries(),rootv,alirootv);
20
21 man->Put(mappp,id,metadata);
22}
23
24TString ParseConfig(char * option)
25{
26 // Parse Config file to retrieve usefull information for the GRP
27
28 ifstream in("Config.C", ios::in) ;
29 if (!in)
30 AliError("Config.C file not found in current path") ;
31
32 TString rv("") ;
33
34 TString soption(option) ;
35
36 string line ;
37 TString sline ;
38
39 // search for the system p-p or Pb-Pb or .....
40 if (soption.Contains("system") || soption.Contains("fAliceBeamType")){
41 while (getline(in, line)) {
42 sline = line ;
28da60d3 43 if (sline.Contains("AliSimulation::Instance()->SetTriggerConfig"))
75958532 44 break ;
45 }
46 TString sarg1 = sline(sline.Index("[")+1, sline.Index("]") - sline.Index("[")-1) ;
47 sarg1 = sarg1.Strip(TString::kLeading) ;
48 sarg1 = sarg1.Strip(TString::kTrailing) ;
49 TString sarg2 = sline(sline.Index("(")+1, sline.Index("[") - sline.Index("(")-1) ;
50 sarg2 = sarg2.Strip(TString::kLeading) ;
51 sarg2 = sarg2.Strip(TString::kTrailing) ;
52 in.seekg(0) ;
53 while (getline(in, line)) {
54 sline = line ;
55 if (sline.Contains(sarg1)) {
56 sarg1 = sline(sline.Index("=")+1, sline.Index(";")-sline.Index("=")-1) ;
57 sarg1 = sarg1.Strip(TString::kLeading) ;
58 sarg1 = sarg1.Strip(TString::kTrailing) ;
59 break ;
60 }
61 }
62 in.seekg(0) ;
63 Int_t index = -1 ;
64 while (getline(in, line)) {
65 sline = line ;
66 if (sline.Contains(sarg1)) {
67 sline = sline.Strip(TString::kLeading) ;
68 Ssiz_t deb = sline.Index(sarg1) ;
69 Ssiz_t kom = sline.Index(",") ;
70 if ( deb == 0 || deb < kom)
71 index = 1 ;
72 else
73 index = 2 ;
74 continue ;
75 }
76 if (sline.Contains(sarg2)) {
77 Ssiz_t deb = sline.First("\"") ;
78 if ( deb == -1 ) {
79 getline(in, line) ;
80 sline = line ;
81 }
82 sline.ReplaceAll("\"", "") ;
83 sline = sline.Strip(TString::kLeading) ;
84 if (index == 1 )
85 rv = sline(0, sline.Index(",")) ;
86 else if (index == 2)
87 rv = sline(sline.Index(",")+1, sline.Length()-sline.Index(",")) ;
88 break ;
89 }
90 }
91 }
92 // get the beam energy
93 else if (soption.Contains("fAliceBeamEnergy")) {
94 while (getline(in, line)) {
95 sline = line ;
96 if ( sline.Contains("->SetEnergyCMS(") ) {
97 rv = sline(sline.Index("(")+1, sline.Index(")")-sline.Index("(")-1) ;
98 break ;
99 }
100 }
101 }
102 // get the number of active detectors
103 else if (soption.Contains("fNumberOfDetectors")) {
104 UShort_t det = 0 ;
105 while (getline(in, line)) {
106 sline = line ;
107 sline.ReplaceAll(" ", "") ;
108 if (sline.Contains("iITS=1") ||
109 sline.Contains("iTPC=1") ||
110 sline.Contains("iTRD=1") ||
111 sline.Contains("iTOF=1") ||
112 sline.Contains("iPHOS=1") ||
113 sline.Contains("iHMPID=1") ||
114 sline.Contains("iEMCAL=1") ||
115 sline.Contains("iMUON=1") ||
116 sline.Contains("iFMD=1") ||
117 sline.Contains("iPMD=1") ||
118 sline.Contains("iT0=1") ||
119 sline.Contains("iVZERO=1") ||
120 sline.Contains("iZDC=1") ||
121 sline.Contains("iACORDE=1"))
122 det++ ;
123 }
124 rv = Form("%d", det) ;
125 }
126 else if (soption.Contains("fL3Current")) {
127 TString sarg ;
128 while (getline(in, line)) {
129 sline = line ;
130 sline.ReplaceAll(" ", "") ;
f7a1cc68 131 if (sline.Contains("AliMagF*field=newAliMagF(")) {
75958532 132 sarg = sline(sline.Last(',')+1, sline.Last(')')-sline.Last(',')-1) ;
133 break ;
134 }
135 }
136 in.seekg(0) ;
137 while (getline(in, line)) {
138 sline = line ;
139 sline.ReplaceAll(" ", "") ;
140 if (sline.Contains(Form("%s=",sarg.Data()))) {
141 sarg = sline(sline.Index("=")+1, sline.Index(";")-sline.Index("=")-1) ;
142 if (sarg == "k5kG")
143 rv = "30000" ;
144 else if (sarg == "k2kG")
145 rv = "12000" ;
75958532 146 break ;
147 }
148 }
149 }
150 in.close() ;
151 rv.Strip(TString::kLeading) ;
152 rv.Strip() ;
153 return rv ;
154}
155
156//_______________________________________//
157TMap *GetGRPList() {
158
159 TString system = ParseConfig("fAliceBeamType") ;
160 TString fSystem = system;
161 TMap *map = new TMap();
162 map->SetName("MONTECARLO");
163
164 //DAQ
165 map->Add(new TObjString("fRunType"),new TObjString(AliQA::GetRunTypeName(AliQA::kPHYSICS)));
166 map->Add(new TObjString("fAliceStartTime"),new TObjString("0"));
167 map->Add(new TObjString("fAliceStopTime"),new TObjString("9999"));
168 map->Add(new TObjString("fAliceBeamEnergy"),new TObjString(ParseConfig("fAliceBeamEnergy")));
169 map->Add(new TObjString("fAliceBeamType"),new TObjString(system));
170 map->Add(new TObjString("fNumberOfDetectors"),new TObjString(ParseConfig("fNumberOfDetectors")));
7e88424f 171 map->Add(new TObjString("fDetectorMask"),new TObjString("1074790399"));
172 map->Add(new TObjString("fLHCPeriod"),new TObjString("LHC08c"));
75958532 173
174 //DCS
175 map->Add(new TObjString("fLHCState"),new TObjString("0"));
176 map->Add(new TObjString("fLHCCondition"),new TObjString("0"));
177 map->Add(new TObjString("fLHCLuminosity"),new TObjString("0"));
178 map->Add(new TObjString("fBeamIntensity"),new TObjString("0"));
179 map->Add(new TObjString("fL3Current"),new TObjString(ParseConfig("fL3Current")));
180 map->Add(new TObjString("fL3Polarity"),new TObjString("0"));
181 map->Add(new TObjString("fDipoleCurrent"),new TObjString("6000"));
182 map->Add(new TObjString("fDipolePolarity"),new TObjString("0"));
183 map->Add(new TObjString("fCavernTemperature"),new TObjString("0"));
184 map->Add(new TObjString("fCavernPressure"),new TObjString("0"));
185
186 return map;
187}