Setting new FXS for DQM.
[u/mrichter/AliRoot.git] / SHUTTLE / TestShuttle / AliTestShuttle.cxx
CommitLineData
5c6b40ae 1/**************************************************************************
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
16/*
17$Log$
77dc0223 18Revision 1.14 2007/08/06 12:25:47 acolla
19Function Bool_t GetHLTStatus added to preprocessor. It returns the status of HLT
20read from the run logbook.
21TestShuttle setup updated.
22TRD data point configuration updated.
23
87968cd5 24Revision 1.13 2007/05/30 06:35:21 jgrosseo
25Adding functionality to the Shuttle/TestShuttle:
26o) Function to retrieve list of sources from a given system (GetFileSources with id=0)
27o) Function to retrieve list of IDs for a given source (GetFileIDs)
28These functions are needed for dealing with the tag files that are saved for the GRP preprocessor
29Example code has been added to the TestProcessor in TestShuttle
30
4a33bdd9 31Revision 1.12 2007/04/27 07:06:48 jgrosseo
32GetFileSources returns empty list in case of no files, but successful query
33No mails sent in testmode
34
86aa42c3 35Revision 1.11 2007/04/04 10:33:36 jgrosseo
361) Storing of files to the Grid is now done _after_ your preprocessors succeeded. This is transparent, which means that you can still use the same functions (Store, StoreReferenceData) to store files to the Grid. However, the Shuttle first stores them locally and transfers them after the preprocessor finished. The return code of these two functions has changed from UInt_t to Bool_t which gives you the success of the storing.
37In case of an error with the Grid, the Shuttle will retry the storing later, the preprocessor does not need to be run again.
38
392) The meaning of the return code of the preprocessor has changed. 0 is now success and any other value means failure. This value is stored in the log and you can use it to keep details about the error condition.
40
413) New function StoreReferenceFile to _directly_ store a file (without opening it) to the reference storage.
42
434) The memory usage of the preprocessor is monitored. If it exceeds 2 GB it is terminated.
44
455) New function AliPreprocessor::ProcessDCS(). If you do not need to have DCS data in all cases, you can skip the processing by implemting this function and returning kFALSE under certain conditions. E.g. if there is a certain run type.
46If you always need DCS data (like before), you do not need to implement it.
47
486) The run type has been added to the monitoring page
49
9827400b 50Revision 1.10 2007/02/28 10:41:01 acolla
51Run type field added in SHUTTLE framework. Run type is read from "run type" logbook and retrieved by
52AliPreprocessor::GetRunType() function.
53Added some ldap definition files.
54
d461a8a7 55Revision 1.8 2007/02/13 11:22:25 acolla
56Shuttle getters and setters of main/local OCDB/Reference storages, temp and log
57folders moved to AliShuttleInterface
58
e19c88ea 59Revision 1.6 2006/11/06 14:22:47 jgrosseo
60major update (Alberto)
61o) reading of run parameters from the logbook
62o) online offline naming conversion
63o) standalone DCSclient package
64
eba76848 65Revision 1.5 2006/10/02 12:58:52 jgrosseo
66Small interface change in StoreReferenceData
67
8c77aee7 68Revision 1.4 2006/08/08 14:19:07 jgrosseo
69Update to shuttle classes (Alberto)
70
71- Possibility to set the full object's path in the Preprocessor's and
72Shuttle's Store functions
73- Possibility to extend the object's run validity in the same classes
74("startValidity" and "validityInfinite" parameters)
75- Implementation of the StoreReferenceData function to store reference
76data in a dedicated CDB storage.
77
84090f85 78Revision 1.3 2006/07/11 12:44:32 jgrosseo
79adding parameters for extended validity range of data produced by preprocessor
80
17111222 81Revision 1.2 2006/06/06 14:20:05 jgrosseo
82o) updated test preprocessor (alberto)
83o) added comments to example macro
84o) test shuttle implements new interface
85
5c6b40ae 86Revision 1.2 2006/03/07 07:52:34 hristov
87New version (B.Yordanov)
88
89Revision 1.3 2005/11/17 17:47:34 byordano
90TList changed to TObjArray
91
92Revision 1.2 2005/11/17 14:43:22 byordano
93import to local CVS
94
95Revision 1.1.1.1 2005/10/28 07:33:58 hristov
96Initial import as subdirectory in AliRoot
97
98Revision 1.1.1.1 2005/09/12 22:11:40 byordano
99SHUTTLE package
100
101Revision 1.2 2005/08/29 21:15:47 byordano
102some docs added
103
104*/
105
106//
107// test implementation of the AliShuttleInterface, to be used for local tests of preprocessors
108//
109// reads files from the local disk
110// stores to local CDB
111// logs to the screen
112//
113
114#include "AliTestShuttle.h"
115#include "AliLog.h"
116
117#include "AliCDBManager.h"
84090f85 118#include "AliCDBStorage.h"
5c6b40ae 119#include "AliCDBMetaData.h"
84090f85 120#include "AliCDBPath.h"
5c6b40ae 121#include "AliCDBId.h"
36137ac1 122#include "AliPreprocessor.h"
6ecb073a 123#include "AliLTUConfig.h"
124#include "AliDAQ.h"
125#include "AliTriggerInput.h"
5c6b40ae 126
127#include <TMap.h>
128#include <TList.h>
5c6b40ae 129#include <TObjString.h>
e19c88ea 130#include <TSystem.h>
77dc0223 131#include <TTimeStamp.h>
6ecb073a 132#include <TObjArray.h>
5c6b40ae 133
134ClassImp(AliTestShuttle)
135
36137ac1 136//______________________________________________________________________________________________
17111222 137AliTestShuttle::AliTestShuttle(Int_t run, UInt_t startTime, UInt_t endTime) :
138 fRun(run),
139 fStartTime(startTime),
140 fEndTime(endTime),
eff647d5 141 fTimeCreated(startTime),
142 fDCSQueryOffset(0),
36137ac1 143 fInputFiles(0),
eba76848 144 fRunParameters(0),
9827400b 145 fRunType(),
36137ac1 146 fPreprocessors(0),
2c5f9d06 147 fDcsAliasMap(0),
148 fTriggerConfiguration(""),
149 fTriggerDetectorMask(""),
6ecb073a 150 fCTPtiming(""),
151 fltuConfig(0x0)
5c6b40ae 152{
153 // constructor
36137ac1 154
155 fInputFiles = new TMap;
eba76848 156 fRunParameters = new TMap;
36137ac1 157 fPreprocessors = new TObjArray;
441b0e9c 158
159 fInputFiles->SetOwner(1);
160 fRunParameters->SetOwner(1);
441b0e9c 161 fPreprocessors->SetOwner(1);
6ecb073a 162
163 fltuConfig = new TObjArray();
164 fltuConfig->SetOwner(1);
5c6b40ae 165}
166
36137ac1 167//______________________________________________________________________________________________
5c6b40ae 168AliTestShuttle::~AliTestShuttle()
169{
170 // destructor
36137ac1 171
172 delete fInputFiles;
173 fInputFiles = 0;
174
eba76848 175 delete fRunParameters;
176 fRunParameters = 0;
177
36137ac1 178 delete fPreprocessors;
179 fPreprocessors = 0;
180
181 delete fDcsAliasMap;
182 fDcsAliasMap = 0;
6ecb073a 183
184 delete fltuConfig;
185 fltuConfig = 0;
5c6b40ae 186}
187
36137ac1 188//______________________________________________________________________________________________
9827400b 189Bool_t AliTestShuttle::Store(const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData,
84090f85 190 Int_t validityStart, Bool_t validityInfinite)
5c6b40ae 191{
192 // Stores the CDB object
193 // This function should be called at the end of the preprocessor cycle
194 //
195 // This implementation just stores it on the local disk, the full AliShuttle
196 // puts it to the Grid FileCatalog
197
84090f85 198 Int_t startRun = fRun - validityStart;
199 if(startRun < 0) {
200 AliError("First valid run happens to be less than 0! Setting it to 0...");
201 startRun=0;
202 }
17111222 203
84090f85 204 Int_t endRun = -1;
205 if(validityInfinite) {
206 endRun = AliCDBRunRange::Infinity();
207 } else {
208 endRun = fRun;
209 }
17111222 210
84090f85 211 AliCDBId id(path, startRun, endRun);
17111222 212
e19c88ea 213 return AliCDBManager::Instance()->GetStorage(fgkMainCDB)->Put(object, id, metaData);
84090f85 214}
17111222 215
84090f85 216//______________________________________________________________________________________________
9827400b 217Bool_t AliTestShuttle::StoreReferenceData(const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData)
84090f85 218{
219 // Stores the object as reference data
220 // This function should be called at the end of the preprocessor cycle
221 //
222 // This implementation just stores it on the local disk, the full AliShuttle
223 // puts it to the Grid FileCatalog
224
8c77aee7 225 AliCDBId id(path, fRun, fRun);
84090f85 226
e19c88ea 227 return AliCDBManager::Instance()->GetStorage(fgkMainRefStorage)->Put(object, id, metaData);
5c6b40ae 228}
229
36137ac1 230//______________________________________________________________________________________________
9827400b 231Bool_t AliTestShuttle::StoreReferenceFile(const char* detector, const char* localFile, const char* gridFileName)
232{
233 //
234 // Stores reference file directly (without opening it).
235 //
236 // This implementation just stores it on the local disk, the full AliShuttle
237 // puts it to the Grid FileCatalog
238
239 AliCDBManager* man = AliCDBManager::Instance();
77dc0223 240 AliCDBStorage* sto = man->GetStorage(fgkLocalRefStorage);
9827400b 241
242 TString localBaseFolder = sto->GetBaseFolder();
243
77dc0223 244 TString targetDir = GetRefFilePrefix(localBaseFolder.Data(), detector);
9827400b 245
77dc0223 246 return CopyFileLocally(targetDir, localFile, gridFileName);
247}
248
249//______________________________________________________________________________________________
250Bool_t AliTestShuttle::StoreRunMetadataFile(const char* localFile, const char* gridFileName)
251{
252 //
253 // Stores Run metadata file to the Grid, in the run folder
254 //
255 // Only GRP can call this function.
9827400b 256
77dc0223 257 AliCDBManager* man = AliCDBManager::Instance();
258 AliCDBStorage* sto = man->GetStorage(fgkLocalRefStorage);
259
260 TString localBaseFolder = sto->GetBaseFolder();
261
262 // Build Run level folder
263 // folder = /alice/data/year/lhcPeriod/runNb/Raw
264
265 TTimeStamp startTime(fStartTime);
266
267 TString year = Form("%d",startTime.GetDate());
268 year = year(0,4);
269
270 TString lhcPeriod = GetRunParameter("LHCperiod");
271
272 if (lhcPeriod.Length() == 0)
9827400b 273 {
77dc0223 274 Log("SHUTTLE","StoreRunMetaDataFile - LHCPeriod not found in logbook!");
275 return 0;
276 }
277
278 // TODO: currently SHUTTLE cannot write in /alice/data/ !!!!!
279 //TString targetDir = Form("%s/GRP/RunMetadata/alice/data/%s/%s/%d/Raw",
280 // localBaseFolder.Data(), year.Data(),
281 // lhcPeriod.Data(), fRun);
282
283 TString targetDir = Form("%s/GRP/RunMetadata/alice/simulation/%s/%s/%d/Raw",
284 localBaseFolder.Data(), year.Data(),
285 lhcPeriod.Data(), fRun);
286
287 return CopyFileLocally(targetDir, localFile, gridFileName);
288}
289
290//______________________________________________________________________________________________
291Bool_t AliTestShuttle::CopyFileLocally(TString& targetDir, const char* localFile, const char* gridFileName)
292{
293 //
294 // Stores file locally. Called by StoreReferenceFile and StoreRunMetadataFile
295 //
296
297 //try to open folder, if it does not exist
298 void* dir = gSystem->OpenDirectory(targetDir.Data());
299 if (dir == NULL) {
300 if (gSystem->mkdir(targetDir.Data(), kTRUE)) {
301 Log("SHUTTLE", Form("StoreFileLocally - Can't open directory <%s>", targetDir.Data()));
9827400b 302 return kFALSE;
303 }
77dc0223 304
305 } else {
306 gSystem->FreeDirectory(dir);
9827400b 307 }
77dc0223 308
309 TString target = Form("%s/%s", targetDir.Data(), gridFileName);
310
311 Int_t result = gSystem->GetPathInfo(localFile, 0, (Long64_t*) 0, 0, 0);
312 if (result)
313 {
314 Log("SHUTTLE", Form("StoreFileLocally - %s does not exist", localFile));
315 return kFALSE;
316 }
317
9827400b 318 result = gSystem->CopyFile(localFile, target);
319
320 if (result == 0)
321 {
77dc0223 322 Log("SHUTTLE", Form("StoreFileLocally - File %s stored locally to %s", localFile, target.Data()));
9827400b 323 return kTRUE;
324 }
325 else
326 {
77dc0223 327 Log("SHUTTLE", Form("StoreFileLocally - Could not store file %s to %s!. Error code = %d",
328 localFile, target.Data(), result));
9827400b 329 return kFALSE;
77dc0223 330 }
331
332
333
334}
335
336//______________________________________________________________________________________________
337const char* AliTestShuttle::GetRefFilePrefix(const char* base, const char* detector)
338{
339 //
340 // Get folder name of reference files
341 //
342
343 TString offDetStr(GetOfflineDetName(detector));
0ffe41b3 344 static TString dir;
77dc0223 345 if (offDetStr == "ITS" || offDetStr == "MUON" || offDetStr == "PHOS")
346 {
347 dir.Form("%s/%s/%s", base, offDetStr.Data(), detector);
348 } else {
349 dir.Form("%s/%s", base, offDetStr.Data());
350 }
351
352 return dir.Data();
9827400b 353}
354
355//______________________________________________________________________________________________
5c6b40ae 356const char* AliTestShuttle::GetFile(Int_t system, const char* detector, const char* id, const char* source)
357{
efec19bd 358 // This function retrieves a file from the given system (kDAQ, kDCS, kHLT, kDQM) with the given file id
5c6b40ae 359 // and from the given source in the system.
360 // The function returnes the path to the local file.
361 //
362 // test implementation of GetFile
363 // takes files from the local disks, files are passen in a TMap in the constructor
364
365 TString key;
366 key.Form("%s-%s-%s", fkSystemNames[system], detector, id);
367 TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(key.Data()));
368 TMap* sourceList = 0;
369 if (sourceListPair)
370 sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
371 if (!sourceList)
372 {
373 AliError(Form("Could not find any file in %s with id %s (%s)", fkSystemNames[system], id, key.Data()));
374 return 0;
375 }
376
4a33bdd9 377 TObjString* fileName = 0;
5c6b40ae 378 TPair* fileNamePair = dynamic_cast<TPair*> (sourceList->FindObject(source));
4a33bdd9 379 if (fileNamePair)
380 fileName = dynamic_cast<TObjString*> (fileNamePair->Value());
5c6b40ae 381 if (!fileName)
382 {
36137ac1 383 AliError(Form("Could not find files from source %s in %s with id %s",
384 source, fkSystemNames[system], id));
5c6b40ae 385 return 0;
386 }
387
388 return fileName->GetString().Data();
389}
390
36137ac1 391//______________________________________________________________________________________________
5c6b40ae 392TList* AliTestShuttle::GetFileSources(Int_t system, const char* detector, const char* id)
393{
394 // Returns a list of sources in a given system that saved a file with the given id
395 //
396 // test implementation of GetFileSources
397 // takes files from the local disks, files are passen in a TMap in the constructor
398
399 TString key;
4a33bdd9 400 if (id)
401 key.Form("%s-%s-%s", fkSystemNames[system], detector, id);
402 else
403 key.Form("%s-%s", fkSystemNames[system], detector);
404
405 TList* list = new TList;
406
407 TIterator* iter = fInputFiles->MakeIterator();
408 TObject* obj = 0;
409 while ((obj = iter->Next()))
5c6b40ae 410 {
4a33bdd9 411 TObjString* objStr = dynamic_cast<TObjString*> (obj);
412 if (objStr)
413 {
414 Bool_t found = kFALSE;
415 if (id)
416 {
417 found = (objStr->String().CompareTo(key) == 0);
418 }
419 else
420 found = objStr->String().BeginsWith(key);
421
422 if (found)
423 {
424 TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(objStr->String().Data()));
425 TMap* sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
426
427 TIterator* iter2 = sourceList->GetTable()->MakeIterator();
428 TObject* obj2 = 0;
429 while ((obj2 = iter2->Next()))
430 {
431 TPair* pair = dynamic_cast<TPair*> (obj2);
432 if (pair)
433 {
434 if (!list->FindObject(pair->Key()))
435 list->Add(new TObjString(pair->Key()->GetName()));
436 }
437 }
438
439 delete iter2;
440 }
441 }
5c6b40ae 442 }
4a33bdd9 443
444 if (list->GetEntries() == 0)
445 AliInfo(Form("Could not find any file in %s with id %s (%s)", fkSystemNames[system], id, key.Data()));
446
447 return list;
448}
5c6b40ae 449
4a33bdd9 450//______________________________________________________________________________________________
451TList* AliTestShuttle::GetFileIDs(Int_t system, const char* detector, const char* source)
452{
453 // Returns a list of ids in a given system that saved a file with the given source
454 //
455 // test implementation of GetFileSources
456 // takes files from the local disks, files are passen in a TMap in the constructor
457
458
459 TString key;
460 key.Form("%s-%s", fkSystemNames[system], detector);
461
5c6b40ae 462 TList* list = new TList;
4a33bdd9 463
464 TIterator* iter = fInputFiles->MakeIterator();
465 TObject* obj = 0;
5c6b40ae 466 while ((obj = iter->Next()))
467 {
4a33bdd9 468 TObjString* objStr = dynamic_cast<TObjString*> (obj);
469 if (objStr)
470 {
471 if (objStr->String().BeginsWith(key))
472 {
473 Bool_t found = kFALSE;
474
475 TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(objStr->String().Data()));
476 TMap* sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
477
478 TIterator* iter2 = sourceList->GetTable()->MakeIterator();
479 TObject* obj2 = 0;
480 while ((obj2 = iter2->Next()))
481 {
482 TPair* pair = dynamic_cast<TPair*> (obj2);
483 if (pair)
484 {
485 if (strcmp(pair->Key()->GetName(), source) == 0)
486 found = kTRUE;
487 }
488 }
489
490 delete iter2;
491
492 if (found)
493 {
494 TObjArray* tokens = objStr->String().Tokenize("-");
495 if (tokens->GetEntries() == 3)
496 {
497 TObjString* id = dynamic_cast<TObjString*> (tokens->At(2));
498 if (id && !list->FindObject(id->String()))
499 list->Add(new TObjString(id->String()));
500 }
501
502 delete tokens;
503
504 }
505 }
506 }
5c6b40ae 507 }
4a33bdd9 508
509 if (list->GetEntries() == 0)
510 AliInfo(Form("Could not find any file in %s with source %s (%s)", fkSystemNames[system], source, key.Data()));
511
5c6b40ae 512 return list;
513}
514
36137ac1 515//______________________________________________________________________________________________
6a150f83 516void AliTestShuttle::Log(const char* detector, const char* message, UInt_t level)
5c6b40ae 517{
518 // test implementation of Log
519 // just prints to the screen
520
6a150f83 521 TString fullMessage = detector;
522 fullMessage.Append(Form(": %s",message));
523 AliLog::Message(level, fullMessage, MODULENAME(), ClassName(), FUNCTIONNAME(), __FILE__, __LINE__);
5c6b40ae 524}
525
36137ac1 526//______________________________________________________________________________________________
527void AliTestShuttle::AddInputFile(Int_t system, const char* detector, const char* id, const char* source, const char* fileName)
528{
4a33bdd9 529 //
36137ac1 530 // This function adds a file to the list of input files
4a33bdd9 531 // the list is stored in fInputFiles
532 // fInputFiles: TMap (key -> value)
533 // <system>-<detector>-<id> -> TMap (key -> value)
534 // <source> -> <filename>
535 //
536
36137ac1 537 TString key;
538 key.Form("%s-%s-%s", fkSystemNames[system], detector, id);
539 TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(key.Data()));
540 TMap* sourceList = 0;
541 if (sourceListPair)
542 sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
543 if (!sourceList)
544 {
545 sourceList = new TMap;
546 fInputFiles->Add(new TObjString(key), sourceList);
547 }
548
549 sourceList->Add(new TObjString(source), new TObjString(fileName));
550}
551
552//______________________________________________________________________________________________
d461a8a7 553Bool_t AliTestShuttle::AddInputCDBEntry(AliCDBEntry* entry)
554{
555 // This function adds an object in the OCDB to be later retrieved with GetFromOCDB
556
557 AliCDBStorage *sto = AliCDBManager::Instance()->GetStorage(fgkMainCDB);
558 if (!sto)
559 {
560 Log("SHUTTLE", "GetFromOCDB - Cannot activate main OCDB for query!");
561 return 0;
562 }
563
564 return sto->Put(entry);
565}
566
567//______________________________________________________________________________________________
9827400b 568AliCDBEntry* AliTestShuttle::GetFromOCDB(const char* detector, const AliCDBPath& path)
d461a8a7 569{
570// returns obiect from OCDB valid for current run
571
572 AliCDBStorage *sto = AliCDBManager::Instance()->GetStorage(fgkMainCDB);
573 if (!sto)
574 {
575 Log("SHUTTLE", "GetFromOCDB - Cannot activate main OCDB for query!");
576 return 0;
577 }
578
579 return (AliCDBEntry*) sto->Get(path, fRun);
580}
581
582//______________________________________________________________________________________________
36137ac1 583void AliTestShuttle::Process()
584{
585 // This function tests all preprocessors that are registered to it
586 // All preprocessors get the same dcs alias map and have access to the same list of files.
587
588 for (Int_t i=0; i<fPreprocessors->GetEntries(); ++i)
589 {
590 AliPreprocessor* preprocessor = dynamic_cast<AliPreprocessor*> (fPreprocessors->At(i));
591 if (preprocessor)
592 {
0ffe41b3 593 if (preprocessor->ProcessRunType())
c986bd09 594 {
595 preprocessor->Initialize(fRun, fStartTime, fEndTime);
596 preprocessor->Process(fDcsAliasMap);
597 }
598
36137ac1 599 }
600 }
601}
602
603//______________________________________________________________________________________________
604void AliTestShuttle::RegisterPreprocessor(AliPreprocessor* preprocessor)
605{
606 // registers a preprocessor
607
eba76848 608 const char* detName = preprocessor->GetName();
609 if(strcmp("DET", detName) != 0) {
610 if(GetDetPos(detName) < 0)
611 AliFatal(Form("********** !!!!! Invalid detector name: %s !!!!! **********", detName));
441b0e9c 612 }
eba76848 613
614 fPreprocessors->Add(preprocessor);
615}
616
617//______________________________________________________________________________________________
618void AliTestShuttle::AddInputRunParameter(const char* key, const char* value){
619// set a run parameter (in reality it will be read from the DAQ logbook)
620
621 TObjString* keyObj = new TObjString(key);
622 if (fRunParameters->Contains(key)) {
623 AliWarning(Form("Parameter %s already existing and it will be replaced.", key));
624 delete fRunParameters->Remove(keyObj);
625
626 }
627 fRunParameters->Add(keyObj, new TObjString(value));
628 AliDebug(2, Form("Number of parameters: %d", fRunParameters->
629 GetEntries()));
630}
631
632//______________________________________________________________________________________________
9827400b 633const char* AliTestShuttle::GetRunType()
634{
635 //
636 // get a run parameter
637 //
441b0e9c 638
87968cd5 639 return fRunType.Data();
441b0e9c 640}
641
642//______________________________________________________________________________________________
eba76848 643const char* AliTestShuttle::GetRunParameter(const char* key){
644// get a run parameter
645
646 TObjString* value = dynamic_cast<TObjString*> (fRunParameters->GetValue(key));
647 if(!value) {
648 AliError(Form("No such parameter: %s", key));
649 return 0;
650 }
651 return value->GetName();
36137ac1 652}
e19c88ea 653
d461a8a7 654//______________________________________________________________________________________________
655void AliTestShuttle::SetShuttleTempDir(const char* tmpDir)
656{
657// sets Shuttle temp directory
658
659 fgkShuttleTempDir = gSystem->ExpandPathName(tmpDir);
660}
661
662//______________________________________________________________________________________________
663void AliTestShuttle::SetShuttleLogDir(const char* logDir)
664{
665// sets Shuttle log directory
666
667 fgkShuttleLogDir = gSystem->ExpandPathName(logDir);
668}
669
59def2a2 670//______________________________________________________________________________________________
671const char* AliTestShuttle::GetTriggerConfiguration()
672{
673 //returns trigger configuration
674 if (fTriggerConfiguration.Length()>0){
675 return fTriggerConfiguration;
676 }
677 return NULL;
678}
eff647d5 679//______________________________________________________________________________________________
2c5f9d06 680const char* AliTestShuttle::GetCTPTimeParams()
681{
682 //returns trigger configuration
683 if (fCTPtiming.Length()>0){
684 return fCTPtiming;
685 }
686 return NULL;
687}
688//______________________________________________________________________________________________
c986bd09 689const char* AliTestShuttle::GetTriggerDetectorMask()
690{
691 //returns trigger detector mask
692 if (fTriggerDetectorMask.Length()>0){
693 return fTriggerDetectorMask;
694 }
695 return NULL;
696}
697//______________________________________________________________________________________________
09324cf1 698UInt_t AliTestShuttle::GetStartTimeDCSQuery()
eff647d5 699{
700 // Return Start Time for the DCS query
701 //
702 // The call is delegated to AliShuttleInterface
703
704 return fTimeCreated-fDCSQueryOffset;
705}
706//______________________________________________________________________________________________
09324cf1 707UInt_t AliTestShuttle::GetEndTimeDCSQuery()
eff647d5 708{
709 // Return End Time for the DCS query
710 //
711 // The call is delegated to AliShuttleInterface
712
713 return fEndTime+fDCSQueryOffset;
714}
1f0f7c2e 715//______________________________________________________________________________________________
716void AliTestShuttle::SendMLFromDet(const char* value)
717{
718 //
719 // Sending an information coming from the current detector to ML
720 //
721
52453e05 722 Printf("%s will be sent to monalisa in the $currentdetector_RunCondition tag",value);
1f0f7c2e 723 return;
724}
6ecb073a 725//______________________________________________________________________________________________
726void AliTestShuttle::SetLTUConfig(TString* ltuConfig, const char* det){
727
728 //
729 // Setting LTU configuration for detector det
730 //
731
732 AliInfo(Form("LTU Config will be added for detector %s",det));
733 AliInfo(Form("First element of the array of strings will correspond to LTUFineDelay1 --> %s",ltuConfig[0].Data()));
734 AliInfo(Form("Second element of the array of strings will correspond to LTUFineDelay2 --> %s",ltuConfig[1].Data()));
735 AliInfo(Form("Third element of the array of strings will correspond to LTUBCDelayAdd --> %s",ltuConfig[2].Data()));
736 Float_t ltuFineDelay1 = ltuConfig[0].Atof();
737 Float_t ltuFineDelay2 = ltuConfig[1].Atof();
738 Float_t ltuBCDelayAdd = ltuConfig[2].Atof();
739 AliLTUConfig* ltu = new AliLTUConfig((UChar_t)AliDAQ::DetectorID(det),ltuFineDelay1,ltuFineDelay2,ltuBCDelayAdd);
740 Int_t idet = AliDAQ::DetectorID(det);
741 fltuConfig->AddAtAndExpand(ltu,idet);
742 return;
743}
744//______________________________________________________________________________________________
745TString* AliTestShuttle::GetLTUConfig(const char* det){
746
747 //
748 // Getting LTU configuration for detector det
749 //
750
751 TString* ltuConfigString = new TString[3];
752 Int_t idet = -1;
753 for (Int_t index = 0; index < AliDAQ::kNDetectors; index++){
754 AliDebug(3,Form("index = %d, det = %s, CTP name = %s",index,det,AliTriggerInput::fgkCTPDetectorName[index]));
755 if (strcmp(det,AliTriggerInput::fgkCTPDetectorName[index]) == 0){
756 AliInfo(Form("Getting LTU configuration for detector %s",AliTriggerInput::fgkCTPDetectorName[index]));
757 idet = index;
758 break;
759 }
760 }
761 if (idet != -1){
762 AliLTUConfig* ltu = (AliLTUConfig*)fltuConfig->At(idet);
763 if (!ltu){
764 AliInfo(Form("ltu for detector %s not added in the simulated run, returning a null pointer",det));
765 return 0x0;
766 }
767 else{
768 ltuConfigString[0]=Form("%f",ltu->GetFineDelay1());
769 ltuConfigString[1]=Form("%f",ltu->GetFineDelay2());
770 ltuConfigString[0]=Form("%f",ltu->GetBCDelayAdd());
771 }
772 }
773 else{
774 AliError(Form("Detector %s not found in the list of CTP detector names",det));
775 }
776 return ltuConfigString;
777
778}
779
1f0f7c2e 780