]>
Commit | Line | Data |
---|---|---|
33c82fbf | 1 | /************************************************************************** |
3dedb44a | 2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
7ca4655f | 16 | /* $Id$ */ |
17 | ||
3dedb44a | 18 | //------------------------------------------------------------------------- |
19 | // Class AliGRPPreprocessor | |
20 | // Global Run Parameters (GRP) preprocessor | |
21 | // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch | |
e7a6790f | 22 | // Modified: Ernesto.Lopez.Torres@cern.ch CEADEN-CERN |
3dedb44a | 23 | //------------------------------------------------------------------------- |
24 | ||
836d8b4f | 25 | #include <TChain.h> |
7ca4655f | 26 | #include <TList.h> |
27 | #include <TMap.h> | |
28 | #include <TObjString.h> | |
29 | #include <TTimeStamp.h> | |
29cc8704 | 30 | #include <TSystem.h> |
31 | #include <TFile.h> | |
7ca4655f | 32 | |
3dedb44a | 33 | #include "AliGRPPreprocessor.h" |
34 | #include "AliGRPDCS.h" | |
17984b61 | 35 | #include "AliDCSSensorArray.h" |
3dedb44a | 36 | |
48b1b444 | 37 | #include "AliTriggerConfiguration.h" |
38 | #include "AliTriggerRunScalers.h" | |
39 | ||
3dedb44a | 40 | #include "AliCDBMetaData.h" |
41 | #include "AliLog.h" | |
42 | ||
3dedb44a | 43 | class AliDCSValue; |
44 | class AliShuttleInterface; | |
45 | ||
46 | #include <TH1.h> | |
47 | ||
1e27bb6b | 48 | // needed for ReceivePromptRecoParameters |
49 | #include <TSQLServer.h> | |
50 | #include <TSQLResult.h> | |
51 | #include <TSQLRow.h> | |
52 | #include <AliCDBManager.h> | |
53 | #include <AliCDBMetaData.h> | |
54 | #include <AliCDBId.h> | |
55 | #include <AliTriggerConfiguration.h> | |
56 | ||
17984b61 | 57 | const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required |
58 | ||
3dedb44a | 59 | ClassImp(AliGRPPreprocessor) |
60 | ||
17984b61 | 61 | //_______________________________________________________________ |
e7a6790f | 62 | const Int_t AliGRPPreprocessor::fgknDAQLbPar = 8; // num parameters in the logbook |
6240e6a4 | 63 | const Int_t AliGRPPreprocessor::fgknDCSDP = 10; // number of dcs dps |
e7a6790f | 64 | const char* AliGRPPreprocessor::fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = { |
1676baf1 | 65 | "LHCState", // missing in DCS |
e7a6790f | 66 | "L3Polarity", |
67 | "DipolePolarity", | |
1676baf1 | 68 | "LHCLuminosity", // missing in DCS |
69 | "BeamIntensity", // missing in DCS | |
e7a6790f | 70 | "L3Current", |
71 | "DipoleCurrent", | |
72 | "CavernTemperature", | |
73 | "CavernAtmosPressure", | |
6240e6a4 | 74 | "SurfaceAtmosPressure" |
e7a6790f | 75 | }; |
76 | ||
77 | const Short_t kSensors = 9; // start index position of sensor in DCS DPs | |
6240e6a4 | 78 | const Short_t kNumSensors = 1; // Number of sensors in DCS DPs |
e7a6790f | 79 | |
80 | const char* AliGRPPreprocessor::fgkLHCState[20] = { | |
81 | "P", "PREPARE", | |
82 | "J", "PREINJECTION", | |
83 | "I", "INJECTION", | |
84 | "F", "FILLING", | |
85 | "A", "ADJUST", | |
86 | "U", "UNSTABLE BEAMS", | |
87 | "S", "STABLE BEAMS", | |
88 | "D", "BEAM DUMP", | |
89 | "R", "RECOVER", | |
90 | "C", "PRECYCLE" | |
91 | }; | |
92 | ||
93 | const char* kppError[] = { | |
94 | "", | |
95 | "(DAQ logbook ERROR)", | |
96 | "(DAQ FXS ERROR)", | |
97 | "(DCS FXS ERROR)", | |
7e1a6c0b | 98 | "(DCS data points ERROR)", |
99 | "(Trigger Configuration ERROR)" | |
e7a6790f | 100 | }; |
17984b61 | 101 | |
3dedb44a | 102 | //_______________________________________________________________ |
103 | AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle): | |
08a446c2 | 104 | AliPreprocessor("GRP",shuttle), fPressure(0) |
e7a6790f | 105 | { |
3dedb44a | 106 | // constructor - shuttle must be instantiated! |
ad103e84 | 107 | |
108 | AddRunType("PHYSICS"); | |
3dedb44a | 109 | } |
110 | ||
111 | //_______________________________________________________________ | |
e7a6790f | 112 | AliGRPPreprocessor::~AliGRPPreprocessor() |
113 | { | |
3dedb44a | 114 | //destructor |
e7a6790f | 115 | |
17984b61 | 116 | delete fPressure; |
3dedb44a | 117 | } |
118 | ||
119 | //_______________________________________________________________ | |
e7a6790f | 120 | void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) |
121 | { | |
3dedb44a | 122 | // Initialize preprocessor |
5a5052e5 | 123 | |
124 | AliPreprocessor::Initialize(run, startTime, endTime); | |
e7a6790f | 125 | |
17984b61 | 126 | AliInfo("Initialization of the GRP preprocessor."); |
6240e6a4 | 127 | TClonesArray * array = new TClonesArray("AliDCSSensor",kNumSensors); |
128 | for(Int_t j = 0; j < kNumSensors; j++) { | |
17984b61 | 129 | AliDCSSensor * sens = new ((*array)[j])AliDCSSensor; |
e7a6790f | 130 | sens->SetStringID(fgkDCSDataPoints[j+kSensors]); |
17984b61 | 131 | } |
132 | AliInfo(Form("Pressure Entries: %d",array->GetEntries())); | |
133 | ||
134 | fPressure = new AliDCSSensorArray(fStartTime, fEndTime, array); | |
3dedb44a | 135 | } |
136 | ||
137 | //_______________________________________________________________ | |
e7a6790f | 138 | UInt_t AliGRPPreprocessor::Process(TMap* valueMap) |
139 | { | |
3dedb44a | 140 | // process data retrieved by the Shuttle |
17984b61 | 141 | |
142 | //=================// | |
143 | // DAQ logbook // | |
144 | //=================// | |
e7a6790f | 145 | UInt_t error = 0; |
29cc8704 | 146 | |
e7a6790f | 147 | TMap *grpmap = ProcessDaqLB(); |
148 | if( grpmap->GetEntries() == fgknDAQLbPar ) { | |
149 | Log(Form("DAQ logbook, successful!")); | |
150 | } else { | |
151 | Log(Form("DAQ logbook, missing parameters!!!")); | |
152 | error |= 1; | |
17984b61 | 153 | } |
17984b61 | 154 | //=================// |
155 | // DAQ FXS // | |
156 | //=================// | |
bba57327 | 157 | UInt_t iDaqFxs = ProcessDaqFxs(); |
e7a6790f | 158 | if( iDaqFxs == 0 ) { |
159 | Log(Form("DAQ FXS, successful!")); | |
b49acef7 | 160 | } else { |
e7a6790f | 161 | Log(Form("DAQ FXS, could not store run raw tag file!!!")); |
162 | error |= 2; | |
b49acef7 | 163 | } |
164 | ||
48b1b444 | 165 | //=================// |
166 | // DCS FXS // | |
167 | //=================// | |
168 | UInt_t iDcsFxs = ProcessDcsFxs(); | |
e7a6790f | 169 | if( iDcsFxs == 0 ) { |
170 | Log(Form("DCS FXS, successful!")); | |
48b1b444 | 171 | } else { |
e7a6790f | 172 | Log(Form("DCS FXS, Could not store CTP run configuration and scalers!!!")); |
173 | error |= 4; | |
48b1b444 | 174 | } |
b49acef7 | 175 | |
17984b61 | 176 | //=================// |
177 | // DCS data points // | |
178 | //=================// | |
e7a6790f | 179 | Int_t entries = ProcessDcsDPs( valueMap, grpmap ); |
6240e6a4 | 180 | if( entries < fgknDCSDP-3 ) { // FIXME (!= ) LHState and pressure map are not working yet... |
17984b61 | 181 | Log(Form("Problem with the DCS data points!!!")); |
e7a6790f | 182 | error |= 8; |
183 | } else Log(Form("DCS data points, successful!")); | |
184 | ||
7e1a6c0b | 185 | //=======================// |
186 | // Trigger Configuration // | |
187 | //=======================// | |
188 | // either from DAQ logbook..... | |
189 | const char * triggerConf = GetTriggerConfiguration(); | |
190 | if (triggerConf!= NULL) { | |
191 | Log("Found trigger configuration in DAQ logbook"); | |
192 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConf); | |
193 | if (!runcfg) { | |
194 | Log("Bad CTP run configuration file from DAQ logbook! The corresponding CDB entry will not be filled!"); | |
195 | error |= 16; | |
196 | } | |
197 | else { | |
982f17c2 | 198 | TString titleCTPcfg = Form("CTP cfg for run %i from DAQ",fRun); |
199 | runcfg->SetTitle(titleCTPcfg); | |
7e1a6c0b | 200 | AliCDBMetaData metaData; |
201 | metaData.SetBeamPeriod(0); | |
202 | metaData.SetResponsible("Roman Lietava"); | |
203 | metaData.SetComment("CTP run configuration from DAQ logbook"); | |
204 | if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) { | |
205 | Log("Unable to store the CTP run configuration object to OCDB!"); | |
206 | error |= 16; | |
207 | } | |
208 | } | |
209 | } | |
210 | // ...or from DCS FXS | |
211 | else{ | |
212 | Log("No trigger configuration found in the DAQ logbook!! Trying reading from DCS FXS..."); | |
213 | TString runcfgfile = GetFile(kDCS, "CTP_runconfig", ""); | |
214 | if (runcfgfile.IsNull()) { | |
215 | Log("No CTP runconfig files has been found in DCS FXS!"); | |
216 | error |= 16; | |
217 | } | |
218 | else { | |
219 | Log(Form("File with Id CTP_runconfig found! Copied to %s",runcfgfile.Data())); | |
220 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfiguration(runcfgfile); | |
221 | if (!runcfg) { | |
222 | Log("Bad CTP run configuration file from DCS FXS! The corresponding CDB entry will not be filled!"); | |
223 | error |= 16;; | |
224 | } | |
225 | else { | |
08a446c2 | 226 | TString titleCTPcfg = Form("CTP cfg for run %i from DCS",fRun); |
227 | runcfg->SetTitle(titleCTPcfg); | |
7e1a6c0b | 228 | AliCDBMetaData metaData; |
229 | metaData.SetBeamPeriod(0); | |
230 | metaData.SetResponsible("Roman Lietava"); | |
231 | metaData.SetComment("CTP run configuration from DCS FXS"); | |
232 | if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) { | |
233 | Log("Unable to store the CTP run configuration object to OCDB!"); | |
234 | error |= 16; | |
235 | } | |
236 | } | |
237 | } | |
238 | } | |
239 | ||
e7a6790f | 240 | grpmap->SetOwner(1); |
241 | AliInfo(Form("Final list entries: %d",grpmap->GetEntries())); | |
17984b61 | 242 | |
243 | AliCDBMetaData md; | |
e7a6790f | 244 | md.SetResponsible("Ernesto Lopez Torres"); |
17984b61 | 245 | md.SetComment("Output parameters from the GRP preprocessor."); |
246 | ||
e7a6790f | 247 | Bool_t result = Store("GRP", "Data", grpmap, &md); |
17984b61 | 248 | |
e7a6790f | 249 | delete grpmap; |
17984b61 | 250 | |
e7a6790f | 251 | if (result && !error ) { |
252 | Log("GRP Preprocessor Success"); | |
17984b61 | 253 | return 0; |
e7a6790f | 254 | } else { |
7e1a6c0b | 255 | Log( Form("GRP Preprocessor FAILS!!! %s%s%s%s%s", |
e7a6790f | 256 | kppError[(error&1)?1:0], |
257 | kppError[(error&2)?2:0], | |
258 | kppError[(error&4)?3:0], | |
7e1a6c0b | 259 | kppError[(error&8)?4:0], |
260 | kppError[(error&16)?5:0] | |
e7a6790f | 261 | )); |
262 | return error; | |
263 | } | |
17984b61 | 264 | } |
265 | ||
17984b61 | 266 | //_______________________________________________________________ |
e7a6790f | 267 | TMap *AliGRPPreprocessor::ProcessDaqLB() |
268 | { | |
269 | //Getting the DAQ lb information | |
270 | ||
833efe22 | 271 | const char* timeStart = GetRunParameter("DAQ_time_start"); |
272 | const char* timeEnd = GetRunParameter("DAQ_time_end"); | |
e7a6790f | 273 | const char* beamEnergy = GetRunParameter("beamEnergy"); |
274 | const char* beamType = GetRunParameter("beamType"); | |
125567f8 | 275 | const char* numberOfDetectors = GetRunParameter("numberOfDetectors"); |
e7a6790f | 276 | const char* detectorMask = GetRunParameter("detectorMask"); |
277 | const char* lhcPeriod = GetRunParameter("LHCperiod"); | |
278 | ||
279 | TMap *mapDAQ = new TMap(); | |
280 | ||
17984b61 | 281 | if (timeStart) { |
282 | Log(Form("Start time for run %d: %s",fRun, timeStart)); | |
283 | } else { | |
284 | Log(Form("Start time not put in logbook!")); | |
285 | } | |
e7a6790f | 286 | mapDAQ->Add(new TObjString("fAliceStartTime"), new TObjString(timeStart)); |
17984b61 | 287 | |
288 | if (timeEnd) { | |
289 | Log(Form("End time for run %d: %s",fRun, timeEnd)); | |
290 | } else { | |
291 | Log(Form("End time not put in logbook!")); | |
292 | } | |
e7a6790f | 293 | mapDAQ->Add(new TObjString("fAliceStopTime"), new TObjString(timeEnd)); |
17984b61 | 294 | |
295 | if (beamEnergy) { | |
296 | Log(Form("Beam energy for run %d: %s",fRun, beamEnergy)); | |
297 | } else { | |
298 | Log(Form("Beam energy not put in logbook!")); | |
299 | } | |
e7a6790f | 300 | mapDAQ->Add(new TObjString("fAliceBeamEnergy"), new TObjString(beamEnergy)); |
17984b61 | 301 | |
302 | if (beamType) { | |
303 | Log(Form("Beam type for run %d: %s",fRun, beamType)); | |
304 | } else { | |
305 | Log(Form("Beam type not put in logbook!")); | |
306 | } | |
e7a6790f | 307 | mapDAQ->Add(new TObjString("fAliceBeamType"), new TObjString(beamType)); |
17984b61 | 308 | |
309 | if (numberOfDetectors) { | |
310 | Log(Form("Number of active detectors for run %d: %s",fRun, numberOfDetectors)); | |
311 | } else { | |
312 | Log(Form("Number of active detectors not put in logbook!")); | |
313 | } | |
e7a6790f | 314 | mapDAQ->Add(new TObjString("fNumberOfDetectors"), new TObjString(numberOfDetectors)); |
17984b61 | 315 | |
316 | if (detectorMask) { | |
317 | Log(Form("Detector mask for run %d: %s",fRun, detectorMask)); | |
318 | } else { | |
319 | Log(Form("Detector mask not put in logbook!")); | |
320 | } | |
e7a6790f | 321 | mapDAQ->Add(new TObjString("fDetectorMask"), new TObjString(detectorMask)); |
17984b61 | 322 | |
323 | if (lhcPeriod) { | |
324 | Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod)); | |
325 | } else { | |
326 | Log(Form("LHCperiod not put in logbook!")); | |
327 | } | |
e7a6790f | 328 | mapDAQ->Add(new TObjString("fLHCPeriod"), new TObjString(lhcPeriod)); |
5a5052e5 | 329 | |
e7a6790f | 330 | mapDAQ->Add(new TObjString("fRunType"), new TObjString(GetRunType())); |
331 | Log( Form("Retrived %d parameters from logbook", mapDAQ->GetEntries() ) ); | |
17984b61 | 332 | |
e7a6790f | 333 | return mapDAQ; |
17984b61 | 334 | } |
335 | ||
336 | //_______________________________________________________________ | |
e7a6790f | 337 | UInt_t AliGRPPreprocessor::ProcessDaqFxs() |
338 | { | |
836d8b4f | 339 | //======DAQ FXS======// |
29cc8704 | 340 | |
c865efca | 341 | TList* list = GetFileSources(kDAQ); |
342 | if (!list) { | |
ff97356e | 343 | Log("No raw data tag list: connection problems with DAQ FXS logbook!"); |
344 | return 1; | |
345 | } | |
e7a6790f | 346 | |
347 | if (list->GetEntries() == 0) { | |
348 | Log("no raw data tags in this run: nothing to merge!"); | |
349 | delete list; list=0; | |
350 | return 0; | |
c865efca | 351 | } |
ff97356e | 352 | |
353 | TChain *fRawTagChain = new TChain("T"); | |
354 | Int_t nFiles=0; | |
4a33bdd9 | 355 | TIterator* iter = list->MakeIterator(); |
356 | TObject* obj = 0; | |
958ecabf | 357 | while ((obj = iter->Next())) { |
358 | TObjString* objStr = dynamic_cast<TObjString*> (obj); | |
359 | if (objStr) { | |
360 | Log(Form("Found source %s", objStr->String().Data())); | |
361 | TList* list2 = GetFileIDs(kDAQ, objStr->String()); | |
836d8b4f | 362 | if (!list2) { |
e7a6790f | 363 | Log("No list with ids from DAQ was found: connection problems with DAQ FXS logbook!"); |
364 | delete fRawTagChain; fRawTagChain=0; | |
365 | return 1; | |
836d8b4f | 366 | } |
367 | Log(Form("Number of ids: %d",list2->GetEntries())); | |
368 | for(Int_t i = 0; i < list2->GetEntries(); i++) { | |
e7a6790f | 369 | TObjString *idStr = (TObjString *)list2->At(i); |
370 | TString fileName = GetFile(kDAQ,idStr->String().Data(),objStr->String().Data()); | |
371 | if (fileName.Length() > 0) { | |
372 | Log(Form("Adding file in the chain: %s",fileName.Data())); | |
373 | fRawTagChain->Add(fileName.Data()); | |
374 | nFiles++; | |
375 | } else { | |
376 | Log(Form("Could not retrieve file with id %s from source %s: " | |
377 | "connection problems with DAQ FXS!", | |
378 | idStr->String().Data(), objStr->String().Data())); | |
379 | delete list; list=0; | |
380 | delete list2; list2=0; | |
381 | delete fRawTagChain; fRawTagChain=0; | |
382 | return 2; | |
383 | } | |
836d8b4f | 384 | } |
958ecabf | 385 | delete list2; |
386 | } | |
387 | } | |
ff97356e | 388 | |
29cc8704 | 389 | TString fRawDataFileName = "GRP_Merged.tag.root"; |
ff97356e | 390 | Log(Form("Merging %d raw data tags into file: %s", nFiles, fRawDataFileName.Data())); |
e7a6790f | 391 | if( fRawTagChain->Merge(fRawDataFileName) < 1 ) { |
392 | Log("Error merging raw data files!!!"); | |
393 | return 3; | |
394 | } | |
29cc8704 | 395 | |
b49acef7 | 396 | TString outputfile = Form("Run%d.Merged.RAW.tag.root", fRun); |
bba57327 | 397 | Bool_t result = StoreRunMetadataFile(fRawDataFileName.Data(),outputfile.Data()); |
ff97356e | 398 | |
e7a6790f | 399 | if (!result) { |
400 | Log("Problem storing raw data tags in local file!!!"); | |
8b5f35a9 | 401 | } else { |
e7a6790f | 402 | Log("Raw data tags merged successfully!!"); |
ff97356e | 403 | } |
404 | ||
405 | delete iter; | |
406 | delete list; | |
407 | delete fRawTagChain; fRawTagChain=0; | |
e7a6790f | 408 | |
409 | if (result == kFALSE) { | |
410 | return 4; | |
8b5f35a9 | 411 | } |
e7a6790f | 412 | |
073502c9 | 413 | return 0; |
e7a6790f | 414 | |
17984b61 | 415 | } |
416 | ||
48b1b444 | 417 | //_______________________________________________________________ |
e7a6790f | 418 | UInt_t AliGRPPreprocessor::ProcessDcsFxs() |
419 | { | |
48b1b444 | 420 | //======DCS FXS======// |
421 | // Get the CTP run configuration | |
422 | // and scalers from DCS FXS | |
423 | ||
7e1a6c0b | 424 | /* |
48b1b444 | 425 | { |
7e1a6c0b | 426 | |
48b1b444 | 427 | // Get the CTP run configuration |
428 | TList* list = GetFileSources(kDCS,"CTP_runconfig"); | |
429 | if (!list) { | |
cbdd8439 | 430 | Log("No CTP runconfig file: connection problems with DCS FXS logbook!"); |
48b1b444 | 431 | return 1; |
432 | } | |
433 | ||
434 | if (list->GetEntries() == 0) { | |
435 | Log("No CTP runconfig file to be processed!"); | |
e7a6790f | 436 | return 1; |
48b1b444 | 437 | } |
438 | else { | |
439 | TIter iter(list); | |
440 | TObjString *source; | |
441 | while ((source = dynamic_cast<TObjString *> (iter.Next()))) { | |
e7a6790f | 442 | TString runcfgfile = GetFile(kDCS, "CTP_runconfig", source->GetName()); |
443 | if (runcfgfile.IsNull()) { | |
444 | Log("No CTP runconfig files has been found: empty source!"); | |
445 | } | |
446 | else { | |
447 | Log(Form("File with Id CTP_runconfig found in source %s! Copied to %s",source->GetName(),runcfgfile.Data())); | |
448 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfiguration(runcfgfile); | |
449 | if (!runcfg) { | |
450 | Log("Bad CTP run configuration file! The corresponding CDB entry will not be filled!"); | |
451 | return 1; | |
452 | } | |
453 | else { | |
454 | AliCDBMetaData metaData; | |
455 | metaData.SetBeamPeriod(0); | |
456 | metaData.SetResponsible("Roman Lietava"); | |
457 | metaData.SetComment("CTP run configuration"); | |
458 | if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) { | |
459 | Log("Unable to store the CTP run configuration object to OCDB!"); | |
460 | } | |
461 | } | |
462 | } | |
48b1b444 | 463 | } |
464 | } | |
465 | delete list; | |
466 | } | |
7e1a6c0b | 467 | */ |
48b1b444 | 468 | { |
469 | // Get the CTP counters information | |
470 | TList* list = GetFileSources(kDCS,"CTP_xcounters"); | |
471 | if (!list) { | |
472 | Log("No CTP counters file: connection problems with DAQ FXS logbook!"); | |
473 | return 1; | |
474 | } | |
475 | ||
476 | if (list->GetEntries() == 0) { | |
477 | Log("No CTP counters file to be processed!"); | |
e7a6790f | 478 | return 1; |
48b1b444 | 479 | } |
480 | else { | |
481 | TIter iter(list); | |
482 | TObjString *source; | |
483 | while ((source = dynamic_cast<TObjString *> (iter.Next()))) { | |
e7a6790f | 484 | TString countersfile = GetFile(kDCS, "CTP_xcounters", source->GetName()); |
485 | if (countersfile.IsNull()) { | |
486 | Log("No CTP counters files has been found: empty source!"); | |
487 | } | |
488 | else { | |
489 | Log(Form("File with Id CTP_xcounters found in source %s! Copied to %s",source->GetName(),countersfile.Data())); | |
490 | AliTriggerRunScalers *scalers = AliTriggerRunScalers::ReadScalers(countersfile); | |
491 | if (!scalers) { | |
492 | Log("Bad CTP counters file! The corresponding CDB entry will not be filled!"); | |
493 | return 1; | |
494 | } | |
495 | else { | |
496 | AliCDBMetaData metaData; | |
497 | metaData.SetBeamPeriod(0); | |
498 | metaData.SetResponsible("Roman Lietava"); | |
499 | metaData.SetComment("CTP scalers"); | |
500 | if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) { | |
501 | Log("Unable to store the CTP scalers object to OCDB!"); | |
502 | } | |
503 | } | |
504 | } | |
48b1b444 | 505 | } |
506 | } | |
507 | delete list; | |
508 | } | |
509 | ||
510 | return 0; | |
511 | } | |
512 | ||
17984b61 | 513 | //_______________________________________________________________ |
e7a6790f | 514 | Int_t AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap, TMap* mapDCS) |
515 | { | |
17984b61 | 516 | //Getting the DCS dps |
e97cc90e | 517 | //===========// |
17984b61 | 518 | |
e97cc90e | 519 | //DCS data points |
520 | //===========// | |
e7a6790f | 521 | |
522 | Int_t entries = 0; | |
523 | ||
17984b61 | 524 | AliInfo(Form("==========LHCState===========")); |
525 | TObjArray *aliasLHCState = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[0]); | |
e97cc90e | 526 | if(!aliasLHCState) { |
527 | Log(Form("LHCState not found!!!")); | |
e7a6790f | 528 | } else { |
529 | AliGRPDCS *dcs1 = new AliGRPDCS(aliasLHCState,fStartTime,fEndTime); | |
530 | TString sLHCState = dcs1->ProcessDCS(2); | |
531 | if (sLHCState) { | |
532 | for( Int_t i=0; i<20; i+=2 ) { | |
533 | if( sLHCState.CompareTo(fgkLHCState[i]) == 0 ) { | |
534 | sLHCState = fgkLHCState[i+1]; | |
535 | break; | |
536 | } | |
537 | } | |
538 | Log(Form("<LHCState> for run %d: %s",fRun, sLHCState.Data())); | |
539 | } else { | |
540 | Log("LHCState not put in TMap!"); | |
541 | } | |
542 | mapDCS->Add(new TObjString("fLHCState"),new TObjString(sLHCState)); | |
543 | ++entries; | |
8ecdaed6 | 544 | } |
e7a6790f | 545 | |
546 | AliInfo(Form("==========L3Polarity===========")); | |
547 | TObjArray *aliasL3Polarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[1]); | |
548 | if(!aliasL3Polarity) { | |
549 | Log(Form("L3Polarity not found!!!")); | |
e97cc90e | 550 | } else { |
e7a6790f | 551 | AliGRPDCS *dcs6 = new AliGRPDCS(aliasL3Polarity,fStartTime,fEndTime); |
552 | TString sL3Polarity = dcs6->ProcessDCS(1); | |
553 | if (sL3Polarity) { | |
554 | Log(Form("<L3Polarity> for run %d: %s",fRun, sL3Polarity.Data())); | |
555 | } else { | |
556 | Log("L3Polarity not put in TMap!"); | |
557 | } | |
558 | mapDCS->Add(new TObjString("fL3Polarity"),new TObjString(sL3Polarity)); | |
559 | ++entries; | |
560 | } | |
561 | ||
562 | AliInfo(Form("==========DipolePolarity===========")); | |
563 | TObjArray *aliasDipolePolarity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[2]); | |
564 | if(!aliasDipolePolarity) { | |
565 | Log(Form("DipolePolarity not found!!!")); | |
3dedb44a | 566 | } else { |
e7a6790f | 567 | AliGRPDCS *dcs8 = new AliGRPDCS(aliasDipolePolarity,fStartTime,fEndTime); |
568 | TString sDipolePolarity = dcs8->ProcessDCS(1); | |
569 | if (sDipolePolarity) { | |
570 | Log(Form("<DipolePolarity> for run %d: %s",fRun, sDipolePolarity.Data())); | |
571 | } else { | |
572 | Log("DipolePolarity not put in TMap!"); | |
573 | } | |
574 | mapDCS->Add(new TObjString("fDipolePolarity"),new TObjString(sDipolePolarity)); | |
575 | ++entries; | |
3dedb44a | 576 | } |
125567f8 | 577 | |
17984b61 | 578 | AliInfo(Form("==========LHCLuminosity===========")); |
e7a6790f | 579 | TObjArray *aliasLHCLuminosity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[3]); |
e97cc90e | 580 | if(!aliasLHCLuminosity) { |
581 | Log(Form("LHCLuminosity not found!!!")); | |
e97cc90e | 582 | } else { |
e7a6790f | 583 | AliGRPDCS *dcs3 = new AliGRPDCS(aliasLHCLuminosity,fStartTime,fEndTime); |
584 | TString sMeanLHCLuminosity = dcs3->ProcessDCS(5); | |
585 | if (sMeanLHCLuminosity) { | |
586 | Log(Form("<LHCLuminosity> for run %d: %s",fRun, sMeanLHCLuminosity.Data())); | |
587 | } else { | |
588 | Log("LHCLuminosity not put in TMap!"); | |
589 | } | |
590 | mapDCS->Add(new TObjString("fLHCLuminosity"), new TObjString(sMeanLHCLuminosity)); | |
591 | ++entries; | |
e97cc90e | 592 | } |
593 | ||
17984b61 | 594 | AliInfo(Form("==========BeamIntensity===========")); |
e7a6790f | 595 | TObjArray *aliasBeamIntensity = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[4]); |
e97cc90e | 596 | if(!aliasBeamIntensity) { |
597 | Log(Form("BeamIntensity not found!!!")); | |
e97cc90e | 598 | } else { |
e7a6790f | 599 | AliGRPDCS *dcs4 = new AliGRPDCS(aliasBeamIntensity,fStartTime,fEndTime); |
600 | TString sMeanBeamIntensity = dcs4->ProcessDCS(5); | |
601 | if (sMeanBeamIntensity) { | |
602 | Log(Form("<BeamIntensity> for run %d: %s",fRun, sMeanBeamIntensity.Data())); | |
603 | } else { | |
604 | Log("BeamIntensity not put in TMap!"); | |
605 | } | |
606 | mapDCS->Add(new TObjString("fBeamIntensity"),new TObjString(sMeanBeamIntensity)); | |
607 | ++entries; | |
e97cc90e | 608 | } |
609 | ||
17984b61 | 610 | AliInfo(Form("==========L3Current===========")); |
e7a6790f | 611 | TObjArray *aliasL3Current = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[5]); |
e97cc90e | 612 | if(!aliasL3Current) { |
613 | Log(Form("L3Current not found!!!")); | |
e97cc90e | 614 | } else { |
e7a6790f | 615 | AliGRPDCS *dcs5 = new AliGRPDCS(aliasL3Current,fStartTime,fEndTime); |
616 | TString sMeanL3Current = dcs5->ProcessDCS(5); | |
617 | if (sMeanL3Current) { | |
618 | Log(Form("<L3Current> for run %d: %s",fRun, sMeanL3Current.Data())); | |
619 | } else { | |
620 | Log("L3Current not put in TMap!"); | |
621 | } | |
622 | mapDCS->Add(new TObjString("fL3Current"),new TObjString(sMeanL3Current)); | |
623 | ++entries; | |
e97cc90e | 624 | } |
625 | ||
e97cc90e | 626 | |
17984b61 | 627 | AliInfo(Form("==========DipoleCurrent===========")); |
628 | TObjArray *aliasDipoleCurrent = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[6]); | |
e97cc90e | 629 | if(!aliasDipoleCurrent) { |
630 | Log(Form("DipoleCurrent not found!!!")); | |
e7a6790f | 631 | } else { |
632 | AliGRPDCS *dcs7 = new AliGRPDCS(aliasDipoleCurrent,fStartTime,fEndTime); | |
633 | TString sMeanDipoleCurrent = dcs7->ProcessDCS(5); | |
634 | if (sMeanDipoleCurrent) { | |
635 | Log(Form("<DipoleCurrent> for run %d: %s",fRun, sMeanDipoleCurrent.Data())); | |
636 | } else { | |
637 | Log("DipoleCurrent not put in TMap!"); | |
638 | } | |
639 | mapDCS->Add(new TObjString("fDipoleCurrent"),new TObjString(sMeanDipoleCurrent)); | |
640 | ++entries; | |
e97cc90e | 641 | } |
642 | ||
17984b61 | 643 | AliInfo(Form("==========CavernTemperature===========")); |
e7a6790f | 644 | TObjArray *aliasCavernTemperature = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[7]); |
e97cc90e | 645 | if(!aliasCavernTemperature) { |
646 | Log(Form("CavernTemperature not found!!!")); | |
e7a6790f | 647 | } else { |
648 | AliGRPDCS *dcs9 = new AliGRPDCS(aliasCavernTemperature,fStartTime,fEndTime); | |
649 | TString sMeanCavernTemperature = dcs9->ProcessDCS(5); | |
650 | if (sMeanCavernTemperature) { | |
651 | Log(Form("<CavernTemperature> for run %d: %s",fRun, sMeanCavernTemperature.Data())); | |
652 | } else { | |
653 | Log("CavernTemperature not put in TMap!"); | |
654 | } | |
655 | mapDCS->Add(new TObjString("fCavernTemperature"),new TObjString(sMeanCavernTemperature)); | |
656 | ++entries; | |
e97cc90e | 657 | } |
658 | ||
17984b61 | 659 | AliInfo(Form("==========CavernPressure===========")); |
e7a6790f | 660 | TObjArray *aliasCavernPressure = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[8]); |
e97cc90e | 661 | if(!aliasCavernPressure) { |
e7a6790f | 662 | Log("CavernPressure not found!!!"); |
e97cc90e | 663 | } else { |
e7a6790f | 664 | AliGRPDCS *dcs10 = new AliGRPDCS(aliasCavernPressure,fStartTime,fEndTime); |
665 | TString sMeanCavernPressure = dcs10->ProcessDCS(5); | |
666 | if (sMeanCavernPressure) { | |
667 | Log(Form("<CavernPressure> for run %d: %s",fRun, sMeanCavernPressure.Data())); | |
668 | } else { | |
669 | Log("CavernPressure not put in TMap!"); | |
670 | } | |
671 | mapDCS->Add(new TObjString("fCavernPressure"),new TObjString(sMeanCavernPressure)); | |
672 | ++entries; | |
673 | } | |
674 | ||
675 | ||
676 | // NEEDS TO BE REVISED, CONFIRMED | |
6240e6a4 | 677 | AliInfo(Form("==========P2PressureMap===========")); |
3ba92a38 | 678 | AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap); |
e7a6790f | 679 | if( fPressure->NumFits()==0 ) { |
680 | Log("Problem with the pressure sensor values!!!"); | |
6240e6a4 | 681 | } |
682 | else { | |
683 | AliDCSSensor* sensorP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[9]); | |
684 | if( sensorP2->GetFit() ) { | |
685 | Log(Form("<P2Pressure> for run %d: Sensor Fit found",fRun)); | |
686 | mapDCS->Add( new TObjString("fP2Pressure"), sensorP2 ); | |
e7a6790f | 687 | ++entries; |
6240e6a4 | 688 | } |
689 | else { | |
e7a6790f | 690 | Log(Form("ERROR Sensor Fit for %s not found: ", fgkDCSDataPoints[9] )); |
691 | } | |
692 | ||
6240e6a4 | 693 | /* |
e7a6790f | 694 | AliDCSSensor* sensorMeyrin = dcsSensorArray->GetSensor(fgkDCSDataPoints[10]); |
695 | if( sensorMeyrin->GetFit() ) { | |
696 | Log(Form("<MeyrinPressure> for run %d: Sensor Fit found",fRun)); | |
697 | mapDCS->Add( new TObjString("fMeyrinPressure"), sensorMeyrin ); | |
698 | ++entries; | |
699 | } else { | |
700 | Log(Form("ERROR Sensor Fit for %s not found: ", fgkDCSDataPoints[10] )); | |
701 | } | |
6240e6a4 | 702 | */ |
e7a6790f | 703 | } |
e97cc90e | 704 | |
e7a6790f | 705 | return entries; |
17984b61 | 706 | } |
125567f8 | 707 | |
17984b61 | 708 | //_______________________________________________________________ |
3ba92a38 | 709 | AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap) |
e7a6790f | 710 | { |
17984b61 | 711 | // extract DCS pressure maps. Perform fits to save space |
3dedb44a | 712 | |
17984b61 | 713 | TMap *map = fPressure->ExtractDCS(dcsAliasMap); |
714 | if (map) { | |
715 | fPressure->MakeSplineFit(map); | |
716 | Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors(); | |
717 | if (fitFraction > kFitFraction ) { | |
e7a6790f | 718 | AliInfo(Form("Pressure values extracted, %d fits performed.", fPressure->NumFits())); |
17984b61 | 719 | } else { |
e7a6790f | 720 | AliInfo("Too few pressure maps fitted!!!"); |
17984b61 | 721 | } |
722 | } else { | |
e7a6790f | 723 | AliInfo("no atmospheric pressure map extracted!!!"); |
17984b61 | 724 | } |
725 | delete map; | |
726 | ||
727 | return fPressure; | |
728 | } | |
e97cc90e | 729 | |
17984b61 | 730 | //_______________________________________________________________ |
731 | /*UInt_t AliGRPPreprocessor::MapPressure(TMap* dcsAliasMap) { | |
732 | // extract DCS pressure maps. Perform fits to save space | |
3dedb44a | 733 | |
17984b61 | 734 | UInt_t result=0; |
735 | TMap *map = fPressure->ExtractDCS(dcsAliasMap); | |
736 | if (map) { | |
737 | fPressure->MakeSplineFit(map); | |
738 | Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors(); | |
739 | if (fitFraction > kFitFraction ) { | |
740 | AliInfo(Form("Pressure values extracted, fits performed.\n")); | |
741 | } else { | |
742 | Log ("Too few pressure maps fitted. \n"); | |
743 | result = 9; | |
744 | } | |
745 | } else { | |
746 | Log("AliTPCPreprocsessor: no atmospheric pressure map extracted. \n"); | |
747 | result=9; | |
748 | } | |
749 | delete map; | |
750 | // Now store the final CDB file | |
3dedb44a | 751 | |
17984b61 | 752 | if ( result == 0 ) { |
753 | AliCDBMetaData metaData; | |
754 | metaData.SetBeamPeriod(0); | |
755 | metaData.SetResponsible("Panos Christakoglou"); | |
756 | metaData.SetComment("Preprocessor AliGRP data base pressure entries."); | |
757 | ||
758 | Bool_t storeOK = Store("Calib", "Pressure", fPressure, &metaData, 0, 0); | |
759 | if ( !storeOK ) result=1; | |
760 | } | |
3dedb44a | 761 | |
17984b61 | 762 | return result; |
763 | }*/ | |
1e27bb6b | 764 | |
765 | ||
766 | //_______________________________________________________________ | |
3dfcd47d | 767 | Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* dbHost, Int_t dbPort, const char* dbName, const char* user, const char* password, const char *cdbRoot) |
1e27bb6b | 768 | { |
e7a6790f | 769 | // |
770 | // Retrieves logbook and trigger information from the online logbook | |
771 | // This information is needed for prompt reconstruction | |
772 | // | |
773 | // Parameters are: | |
774 | // Run number | |
775 | // DAQ params: dbHost, dbPort, dbName, user, password, logbookTable, triggerTable | |
776 | // cdbRoot | |
777 | // | |
778 | // returns: | |
779 | // positive on success: the return code is the run number of last run processed of the same run type already processed by the SHUTTLE | |
780 | // 0 on success and no run was found | |
781 | // negative on error | |
782 | // | |
783 | // This function is NOT called during the preprocessor run in the Shuttle! | |
784 | // | |
785 | ||
786 | // defaults | |
787 | if (dbPort == 0) | |
788 | dbPort = 3306; | |
789 | ||
790 | // CDB connection | |
791 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
792 | cdb->SetDefaultStorage(cdbRoot); | |
793 | ||
794 | // SQL connection | |
795 | TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password); | |
796 | ||
797 | if (!server) | |
798 | { | |
799 | Printf("ERROR: Could not connect to DAQ LB"); | |
800 | return -1; | |
801 | } | |
802 | ||
803 | // main logbook | |
804 | TString sqlQuery; | |
805 | sqlQuery.Form("SELECT DAQ_time_start, run_type, detectorMask FROM logbook WHERE run = %d", run); | |
806 | TSQLResult* result = server->Query(sqlQuery); | |
807 | if (!result) | |
808 | { | |
809 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
810 | return -2; | |
811 | } | |
812 | ||
813 | if (result->GetRowCount() == 0) | |
814 | { | |
815 | Printf("ERROR: Run %d not found", run); | |
816 | delete result; | |
817 | return -3; | |
818 | } | |
819 | ||
820 | TSQLRow* row = result->Next(); | |
821 | if (!row) | |
822 | { | |
823 | Printf("ERROR: Could not receive data from run %d", run); | |
824 | delete result; | |
825 | return -4; | |
826 | } | |
827 | ||
828 | TString runType(row->GetField(1)); | |
829 | ||
830 | TMap grpData; | |
831 | grpData.Add(new TObjString("DAQ_time_start"), new TObjString(row->GetField(0))); | |
832 | grpData.Add(new TObjString("run_type"), new TObjString(runType)); | |
833 | grpData.Add(new TObjString("detectorMask"), new TObjString(row->GetField(2))); | |
834 | ||
835 | delete row; | |
836 | row = 0; | |
837 | ||
838 | delete result; | |
839 | result = 0; | |
840 | ||
841 | Printf("Storing GRP/GRP/Data object with the following content"); | |
842 | grpData.Print(); | |
843 | ||
844 | AliCDBMetaData metadata; | |
845 | metadata.SetResponsible("Jan Fiete Grosse-Oetringhaus"); | |
846 | metadata.SetComment("GRP Output parameters received during online running"); | |
847 | ||
848 | AliCDBId id("GRP/GRP/Data", run, run); | |
849 | Bool_t success = cdb->Put(&grpData, id, &metadata); | |
850 | ||
851 | grpData.DeleteAll(); | |
852 | ||
853 | if (!success) | |
854 | { | |
855 | Printf("ERROR: Could not store GRP/GRP/Data into OCDB"); | |
856 | return -5; | |
857 | } | |
858 | ||
859 | // Receive trigger information | |
860 | sqlQuery.Form("SELECT configFile FROM logbook_trigger_config WHERE run = %d", run); | |
861 | result = server->Query(sqlQuery); | |
862 | if (!result) | |
863 | { | |
864 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
865 | return -11; | |
866 | } | |
867 | ||
868 | if (result->GetRowCount() == 0) | |
869 | { | |
870 | Printf("ERROR: Run %d not found in logbook_trigger_config", run); | |
871 | delete result; | |
872 | return -12; | |
873 | } | |
874 | ||
875 | row = result->Next(); | |
876 | if (!row) | |
877 | { | |
878 | Printf("ERROR: Could not receive logbook_trigger_config data from run %d", run); | |
879 | delete result; | |
880 | return -13; | |
881 | } | |
882 | ||
883 | TString triggerConfig(row->GetField(0)); | |
884 | ||
885 | delete row; | |
886 | row = 0; | |
887 | ||
888 | delete result; | |
889 | result = 0; | |
890 | ||
891 | Printf("Found trigger configuration: %s", triggerConfig.Data()); | |
892 | ||
893 | AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConfig); | |
894 | if (!runcfg) | |
895 | { | |
896 | Printf("ERROR: Could not create CTP configuration object"); | |
897 | return -14; | |
898 | } | |
899 | ||
900 | metadata.SetComment("CTP run configuration received during online running"); | |
901 | ||
902 | AliCDBId id2("GRP/CTP/Config", run, run); | |
903 | success = cdb->Put(runcfg, id2, &metadata); | |
904 | ||
905 | delete runcfg; | |
906 | runcfg = 0; | |
907 | ||
908 | if (!success) | |
909 | { | |
910 | Printf("ERROR: Could not store GRP/CTP/Config into OCDB"); | |
911 | return -15; | |
912 | } | |
913 | ||
914 | // get last run with same run type that was already processed by the SHUTTLE | |
915 | ||
916 | sqlQuery.Form("SELECT max(logbook.run) FROM logbook LEFT JOIN logbook_shuttle ON logbook_shuttle.run = logbook.run WHERE run_type = '%s' AND shuttle_done = 1", runType.Data()); | |
917 | result = server->Query(sqlQuery); | |
918 | if (!result) | |
919 | { | |
920 | Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); | |
921 | return -21; | |
922 | } | |
923 | ||
924 | if (result->GetRowCount() == 0) | |
925 | { | |
926 | Printf("ERROR: No result with query <%s>", sqlQuery.Data()); | |
927 | delete result; | |
928 | return -22; | |
929 | } | |
930 | ||
931 | row = result->Next(); | |
932 | if (!row) | |
933 | { | |
934 | Printf("ERROR: Could not receive data for query <%s>", sqlQuery.Data()); | |
935 | delete result; | |
936 | return -23; | |
937 | } | |
938 | ||
939 | TString lastRunStr(row->GetField(0)); | |
940 | Int_t lastRun = lastRunStr.Atoi(); | |
941 | ||
942 | Printf("Last run with same run type %s is %d", runType.Data(), lastRun); | |
943 | ||
944 | delete row; | |
945 | row = 0; | |
946 | ||
947 | delete result; | |
948 | result = 0; | |
949 | ||
950 | server->Close(); | |
951 | delete server; | |
952 | server = 0; | |
953 | ||
954 | return lastRun; | |
1e27bb6b | 955 | } |