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 // create AliTestShuttle instance
17 // The parameters are run, startTime, endTime
18 AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
20 // TODO if needed, change location of OCDB and Reference test folders
21 // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference
22 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
23 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
25 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
26 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
31 // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data,
32 // some fake data has to be created.
34 // The "fake" input data can be taken using either (a) or (b):
35 // (a) data from a file: Use ReadDCSAliasMap()
36 // the format of the file is explained in ReadDCSAliasMap()
37 // To use it uncomment the following line:
39 //TMap* dcsAliasMap = ReadDCSAliasMap();
41 // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
42 // To use it uncomment the following line:
44 TMap* dcsAliasMap = CreateDCSAliasMap();
46 // now give the alias map to the shuttle
47 shuttle->SetDCSInput(dcsAliasMap);
51 // The shuttle can also process files that originate from DCS, DAQ and HLT.
52 // To test it, we provide some local files and locations where these would be found when
53 // the online machinery would be there.
54 // In real life this functions would be produces by the sub-detectors
55 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
57 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
58 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
59 // In this example we add a file originating from the GDC with the id PEDESTALS
60 // Three files originating from different LDCs but with the same id are also added
61 // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
62 // the "online" naming convention ALICE-INT-2003-039.
63 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "PEDESTALS", "GDC0", "file1.root");
64 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC0", "file2a.root");
65 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC1", "file2b.root");
66 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC2", "file2c.root");
67 shuttle->AddInputFile(AliShuttleInterface::kHLT, "TPC", "HLTData", "source1", "hlt_file1.root");
68 shuttle->AddInputFile(AliShuttleInterface::kHLT, "TPC", "HLTData", "source2", "hlt_file2.root");
72 // The shuttle can read run type stored in the DAQ logbook.
73 // To test it, we must provide the run type manually. They will be retrieved in the preprocessor
74 // using GetRunType function.
75 shuttle->SetInputRunType("PHYSICS");
79 // The shuttle can read run parameters stored in the DAQ run logbook.
80 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
81 // using GetRunParameter function.
82 shuttle->AddInputRunParameter("totalEvents", "30000");
83 shuttle->AddInputRunParameter("NumberOfGDCs", "15");
87 // The shuttle can read run parameters stored in the DAQ run logbook.
88 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
89 // using GetRunParameter function.
90 shuttle->AddInputRunParameter("totalEvents", "30000");
91 shuttle->AddInputRunParameter("NumberOfGDCs", "15");
95 // This is for preprocessor that require data from HLT.
96 // Since HLT may be switched off, the preprocessor should first query the Run logbook where
97 // the HLT status is stored. SHUTTLE implements a shortcut function (GetHLTStatus) that returns
98 // a bool directly. 1 = HLT ON, 0 = HLT OFF
101 Bool_t hltStatus=kTRUE;
102 shuttle->SetInputHLTStatus(hltStatus);
106 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
107 AliPreprocessor* test = new AliTestPreprocessor(shuttle);
109 // Test the preprocessor
113 // In the preprocessor AliShuttleInterface::Store should be called to put the final
114 // data to the CDB. To check if all went fine have a look at the files produced in
115 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
117 // Check the file which should have been created
118 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
119 ->Get("TPC/Calib/Data", 7);
122 printf("The file is not there. Something went wrong.\n");
126 AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry->GetObject());
127 // If everything went fine, draw the result
132 TMap* CreateDCSAliasMap()
134 // Creates a DCS structure
135 // The structure is the following:
136 // TMap (key --> value)
137 // <DCSAlias> --> <valueList>
138 // <DCSAlias> is a string
139 // <valueList> is a TObjArray of AliDCSValue
140 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
142 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
143 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
145 TMap* aliasMap = new TMap;
146 aliasMap->SetOwner(1);
150 for(int nAlias=0;nAlias<6;nAlias++)
152 TObjArray* valueSet = new TObjArray;
153 valueSet->SetOwner(1);
155 TString aliasName="DCSAlias";
157 //printf("\n\n alias: %s\n\n",aliasName.Data());
159 for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
161 AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
162 //printf("%s\n",dcsVal->ToString().Data());
163 valueSet->Add(dcsVal);
165 aliasMap->Add(new TObjString(aliasName), valueSet);
171 TMap* ReadDCSAliasMap()
173 // Open a file that contains DCS input data
174 // The CDB framework is used to open the file, this means the file is located
175 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
176 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
177 // An explanation of the structure can be found in CreateDCSAliasMap()
179 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
180 ->Get("DET/DCS/Data", 0);
181 return dynamic_cast<TMap*> (entry->GetObject());
184 void WriteDCSAliasMap()
186 // This writes the output from CreateDCSAliasMap to a CDB file
188 TMap* dcsAliasMap = CreateDCSAliasMap();
190 AliCDBMetaData metaData;
191 metaData.SetBeamPeriod(0);
192 metaData.SetResponsible("Responsible person");
193 metaData.SetComment("Test object for TestPreprocessor.C");
195 AliCDBId id("DET/DCS/Data", 0, 0);
197 // look into AliTestShuttle's CDB main folder
199 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
200 ->Put(dcsAliasMap, id, &metaData);