3 // This class runs the test preprocessor
4 // It uses AliTestShuttle to simulate a full Shuttle process
6 // The input data is created in the functions
7 // CreateDCSAliasMap() creates input that would in the same way come from DCS
8 // ReadDCSAliasMap() reads from a file
9 // CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
11 void TestPreprocessor()
14 gSystem->Load("libTestShuttle.so");
16 // TODO if needed, change location of OCDB and Reference test folders
17 // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference
18 // AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
19 // AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
21 printf("Test OCDB storage Uri: %s\n", AliTestShuttle::GetMainCDB().Data());
22 printf("Test Reference storage Uri: %s\n", AliTestShuttle::GetMainRefStorage().Data());
24 // TODO if needed, change location of temp and log folders (however they are not explicitly used here)
25 // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/temp and log
26 // AliTestShuttle::SetShuttleTempDir("local://$ALICE_ROOT/SHUTTLE/TestShuttle/temp");
27 // AliTestShuttle::SetShuttleLogDir("local://$ALICE_ROOT/SHUTTLE/TestShuttle/log");
29 printf("Test Shuttle temp dir: %s\n", AliTestShuttle::GetShuttleTempDir());
30 printf("Test Shuttle log dir: %s\n", AliTestShuttle::GetShuttleLogDir());
33 // create AliTestShuttle instance
34 // The parameters are run, startTime, endTime
35 AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
39 // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data,
40 // some fake data has to be created.
42 // The "fake" input data can be taken using either (a) or (b):
43 // (a) data from a file: Use ReadDCSAliasMap()
44 // the format of the file is explained in ReadDCSAliasMap()
45 // To use it uncomment the following line:
47 //TMap* dcsAliasMap = ReadDCSAliasMap();
49 // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
50 // To use it uncomment the following line:
52 TMap* dcsAliasMap = CreateDCSAliasMap();
54 // now give the alias map to the shuttle
55 shuttle->SetDCSInput(dcsAliasMap);
59 // The shuttle can also process files that originate from DCS, DAQ and HLT.
60 // To test it, we provide some local files and locations where these would be found when
61 // the online machinery would be there.
62 // In real life this functions would be produces by the sub-detectors
63 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
65 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
66 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
67 // In this example we add a file originating from the GDC with the id PEDESTALS
68 // Three files originating from different LDCs but with the same id are also added
69 // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
70 // the "online" naming convention ALICE-INT-2003-039.
71 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TPC", "PEDESTALS", "GDC", "file1.root");
72 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TPC", "DRIFTVELOCITY", "LDC0", "file2a.root");
73 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TPC", "DRIFTVELOCITY", "LDC1", "file2b.root");
74 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TPC", "DRIFTVELOCITY", "LDC2", "file2b.root");
78 // The shuttle can read run parameters stored in the DAQ run logbook.
79 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
80 // using GetRunParameter function.
81 // In real life the parameters will be retrieved automatically from the run logbook;
82 shuttle->AddInputRunParameter("totalEvents", "30000");
83 shuttle->AddInputRunParameter("NumberOfGDCs", "15");
86 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
87 AliPreprocessor* test = new AliTestPreprocessor(shuttle);
89 // Test the preprocessor
93 // In the preprocessor AliShuttleInterface::Store should be called to put the final
94 // data to the CDB. To check if all went fine have a look at the files produced in
95 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
97 // Check the file which should have been created
98 AliCDBEntry* entry = AliCDBManager::Instance()->GetStorage(AliTestShuttle::GetMainCDB())
99 ->Get("TPC/SHUTTLE/Data", 7);
102 printf("The file is not there. Something went wrong.\n");
106 AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (entry->GetObject());
107 // If everything went fine, draw the result
112 TMap* CreateDCSAliasMap()
114 // Creates a DCS structure
115 // The structure is the following:
116 // TMap (key --> value)
117 // <DCSAlias> --> <valueList>
118 // <DCSAlias> is a string
119 // <valueList> is a TObjArray of AliDCSValue
120 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
122 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
123 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
125 TMap* aliasMap = new TMap;
126 aliasMap->SetOwner(1);
130 for(int nAlias=0;nAlias<6;nAlias++)
132 TObjArray* valueSet = new TObjArray;
133 valueSet->SetOwner(1);
135 TString aliasName="DCSAlias";
137 //printf("\n\n alias: %s\n\n",aliasName.Data());
139 for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
141 AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
142 //printf("%s\n",dcsVal->ToString().Data());
143 valueSet->Add(dcsVal);
145 aliasMap->Add(new TObjString(aliasName), valueSet);
151 TMap* ReadDCSAliasMap()
153 // Open a file that contains DCS input data
154 // The CDB framework is used to open the file, this means the file is located
155 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
156 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
157 // An explanation of the structure can be found in CreateDCSAliasMap()
159 AliCDBManager::Instance()->GetStorage(AliTestShuttle::GetMainCDB())
160 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliTestShuttle::GetMainCDB())
161 ->Get("DET/DCS/Data", 0);
162 return dynamic_cast<TMap*> (entry->GetObject());
165 void WriteDCSAliasMap()
167 // This writes the output from CreateDCSAliasMap to a CDB file
169 TMap* dcsAliasMap = CreateDCSAliasMap();
171 AliCDBMetaData metaData;
172 metaData.SetBeamPeriod(0);
173 metaData.SetResponsible("Responsible person");
174 metaData.SetComment("Test object for TestPreprocessor.C");
176 AliCDBId id("DET/DCS/Data", 0, 0);
178 // look into AliTestShuttle's CDB main folder
180 AliCDBManager::Instance()->GetStorage(AliTestShuttle::GetMainCDB())
181 ->Put(dcsAliasMap, id, &metaData);