]> git.uio.no Git - u/mrichter/AliRoot.git/blame - SHUTTLE/TestShuttle/TestPreprocessor.C
We don't check the path to the raw-data file, it is done inside AliRawReader::Create...
[u/mrichter/AliRoot.git] / SHUTTLE / TestShuttle / TestPreprocessor.C
CommitLineData
36137ac1 1/* $Id$ */
2
5c6b40ae 3// This class runs the test preprocessor
4// It uses AliTestShuttle to simulate a full Shuttle process
5
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
10
11void TestPreprocessor()
12{
36137ac1 13 // load library
14 gSystem->Load("libTestShuttle.so");
5c6b40ae 15
d461a8a7 16 // create AliTestShuttle instance
17 // The parameters are run, startTime, endTime
18 AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
19
eba76848 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
441b0e9c 22 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
23 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
e19c88ea 24
9b19dde4 25 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
26 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
e19c88ea 27
36137ac1 28
29 // TODO(1)
30 //
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.
33 //
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:
38 //
39 //TMap* dcsAliasMap = ReadDCSAliasMap();
40 //
41 // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
42 // To use it uncomment the following line:
43 //
44 TMap* dcsAliasMap = CreateDCSAliasMap();
45
46 // now give the alias map to the shuttle
47 shuttle->SetDCSInput(dcsAliasMap);
48
49 // TODO(2)
50 //
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.
56 //
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
fc5a4708 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.
4a33bdd9 63 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "PEDESTALS", "GDC0", "file1.root");
9b19dde4 64 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC0", "file2a.root");
65 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC1", "file2b.root");
886d60e6 66 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC2", "file2c.root");
87968cd5 67 shuttle->AddInputFile(AliShuttleInterface::kHLT, "TPC", "HLTData", "source1", "hlt_file1.root");
68 shuttle->AddInputFile(AliShuttleInterface::kHLT, "TPC", "HLTData", "source2", "hlt_file2.root");
36137ac1 69
70 // TODO(3)
eba76848 71 //
9827400b 72 // The shuttle can read run type stored in the DAQ logbook.
441b0e9c 73 // To test it, we must provide the run type manually. They will be retrieved in the preprocessor
74 // using GetRunType function.
9827400b 75 shuttle->SetInputRunType("PHYSICS");
441b0e9c 76
77 // TODO(4)
78 //
eba76848 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.
eba76848 82 shuttle->AddInputRunParameter("totalEvents", "30000");
83 shuttle->AddInputRunParameter("NumberOfGDCs", "15");
84
441b0e9c 85 // TODO(5)
d461a8a7 86 //
87968cd5 87 // This is for preprocessor that require data from HLT.
88 // Since HLT may be switched off, the preprocessor should first query the Run logbook where
89 // the HLT status is stored. SHUTTLE implements a shortcut function (GetHLTStatus) that returns
90 // a bool directly. 1 = HLT ON, 0 = HLT OFF
91 //
d461a8a7 92
87968cd5 93 Bool_t hltStatus=kTRUE;
94 shuttle->SetInputHLTStatus(hltStatus);
d461a8a7 95
96
77dc0223 97 // TODO(6)
36137ac1 98 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
fc5a4708 99 AliPreprocessor* test = new AliTestPreprocessor(shuttle);
36137ac1 100
101 // Test the preprocessor
102 shuttle->Process();
103
77dc0223 104 // TODO(7)
36137ac1 105 // In the preprocessor AliShuttleInterface::Store should be called to put the final
106 // data to the CDB. To check if all went fine have a look at the files produced in
107 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
108 //
109 // Check the file which should have been created
d461a8a7 110 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
441b0e9c 111 ->Get("TPC/Calib/Data", 7);
d461a8a7 112 if (!chkEntry)
36137ac1 113 {
114 printf("The file is not there. Something went wrong.\n");
115 return;
116 }
117
d461a8a7 118 AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry->GetObject());
36137ac1 119 // If everything went fine, draw the result
120 if (output)
121 output->Draw();
5c6b40ae 122}
123
124TMap* CreateDCSAliasMap()
125{
36137ac1 126 // Creates a DCS structure
127 // The structure is the following:
128 // TMap (key --> value)
129 // <DCSAlias> --> <valueList>
130 // <DCSAlias> is a string
131 // <valueList> is a TObjArray of AliDCSValue
132 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
5c6b40ae 133
36137ac1 134 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
135 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
5c6b40ae 136
36137ac1 137 TMap* aliasMap = new TMap;
138 aliasMap->SetOwner(1);
5c6b40ae 139
36137ac1 140 TRandom random;
5c6b40ae 141
36137ac1 142 for(int nAlias=0;nAlias<6;nAlias++)
143 {
144 TObjArray* valueSet = new TObjArray;
145 valueSet->SetOwner(1);
5c6b40ae 146
36137ac1 147 TString aliasName="DCSAlias";
148 aliasName += nAlias;
149 //printf("\n\n alias: %s\n\n",aliasName.Data());
150
151 for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
152 {
45a493ce 153 AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
36137ac1 154 //printf("%s\n",dcsVal->ToString().Data());
155 valueSet->Add(dcsVal);
156 }
157 aliasMap->Add(new TObjString(aliasName), valueSet);
158 }
5c6b40ae 159
160 return aliasMap;
161}
162
163TMap* ReadDCSAliasMap()
164{
36137ac1 165 // Open a file that contains DCS input data
166 // The CDB framework is used to open the file, this means the file is located
167 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
168 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
169 // An explanation of the structure can be found in CreateDCSAliasMap()
170
9b19dde4 171 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
e19c88ea 172 ->Get("DET/DCS/Data", 0);
5c6b40ae 173 return dynamic_cast<TMap*> (entry->GetObject());
174}
175
36137ac1 176void WriteDCSAliasMap()
5c6b40ae 177{
36137ac1 178 // This writes the output from CreateDCSAliasMap to a CDB file
5c6b40ae 179
36137ac1 180 TMap* dcsAliasMap = CreateDCSAliasMap();
5c6b40ae 181
36137ac1 182 AliCDBMetaData metaData;
183 metaData.SetBeamPeriod(0);
184 metaData.SetResponsible("Responsible person");
185 metaData.SetComment("Test object for TestPreprocessor.C");
5c6b40ae 186
36137ac1 187 AliCDBId id("DET/DCS/Data", 0, 0);
5c6b40ae 188
e19c88ea 189 // look into AliTestShuttle's CDB main folder
5c6b40ae 190
9b19dde4 191 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
e19c88ea 192 ->Put(dcsAliasMap, id, &metaData);
5c6b40ae 193}