CMake: Retrieve Git information
[u/mrichter/AliRoot.git] / GRP / MakeCosmicTriggersEntry.C
... / ...
CommitLineData
1#include "ARVersion.h"
2#include <iostream>
3#include <fstream>
4#if !defined(__CINT__) || defined(__MAKECINT__)
5#include "AliCDBManager.h"
6#include "AliCDBStorage.h"
7#include "AliCDBId.h"
8#include "AliCDBMetaData.h"
9#include <TROOT.h>
10#include <TSystem.h>
11#include <THashTable.h>
12#include <TString.h>
13#include <TError.h>
14#include <TObjString.h>
15#endif
16
17Bool_t MakeCosmicTriggersEntry(const char *fileName, const char* cdbUri)
18{
19 const char* macroname = "MakeCosmicTriggersEntry.C";
20
21 if (gSystem->AccessPathName(fileName)) {
22 Error(macroname,Form("file (%s) not found", fileName));
23 return kFALSE;
24 }
25
26 ifstream *file = new ifstream(fileName);
27 if (!*file) {
28 Error(macroname,Form("Error opening file (%s) !",fileName));
29 file->close();
30 delete file;
31 return kFALSE;
32 }
33
34 THashTable *table = new THashTable();
35 table->SetName("List of defined cosmic triggers");
36
37 TString strLine;
38 while (strLine.ReadLine(*file)) {
39
40 if (strLine.BeginsWith("#")) continue;
41
42 strLine.ReplaceAll(" ","");
43 strLine.ReplaceAll("\t","");
44 if (strLine.IsNull()) continue;
45
46 TObjString *obj = new TObjString(strLine.Data());
47 table->Add(obj);
48 }
49
50 file->close();
51 delete file;
52
53
54 // create OCDB storage
55 TString Storage(cdbUri);
56 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
57 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
58 return kFALSE;
59 }
60 AliCDBManager* cdb = AliCDBManager::Instance();
61 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
62 if(!storage){
63 Error(macroname,"Unable to open storage %s\n",Storage.Data());
64 return kFALSE;
65 }
66
67 AliCDBMetaData* md = new AliCDBMetaData();
68 md->SetResponsible("Federico Antinori");
69 md->SetComment("List of the defined cosmic triggers. It is used in order to steer the reconstruction, namely in the selection of the proper event specie. It is maintained and updated by the trigger coordinator.");
70 // Get root and AliRoot versions and set them in the metadata
71 const char* rootv = gROOT->GetVersion();
72 TString av(ALIROOT_VERSION);
73 TString revnum(ALIROOT_REVISION);
74 av+=" - revision: ";
75 av+=revnum;
76 md->SetAliRootVersion(av.Data());
77
78 AliCDBId id("GRP/Calib/CosmicTriggers",0,AliCDBRunRange::Infinity());
79 Info(macroname,"Saving the list of defined cosmic triggers in the OCDB storage \"%s\"",Storage.Data());
80 storage->Put(table,id,md);
81
82 table->Delete();
83 delete table;
84
85 return kTRUE;
86}