]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/TestPreprocessor.C
Coding conventions fixed.
[u/mrichter/AliRoot.git] / PMD / TestPreprocessor.C
CommitLineData
cda4fe9e 1/* $Id$ */
2
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
51e6156c 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,
10// that can be accessed by the shuttle
cda4fe9e 11
12void TestPreprocessor()
13{
51e6156c 14 // load library
15 gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
16
17 // create AliTestShuttle instance
18 // The parameters are run, startTime, endTime
19 AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
20
21
22 printf("Test Shuttle temp dir: %s\n", AliShuttleInterface::GetShuttleTempDir());
23
24 // TODO if needed, change location of OCDB and Reference test folders
25 // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB
26 // and TestReference
27
28 AliTestShuttle::SetMainCDB("local://TestCDB");
29 AliTestShuttle::SetMainRefStorage("local://TestReference");
30
31 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
32 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
33
34
35 // TODO(1)
36 //
37 // The shuttle can read DCS data, if the preprocessor should be
38 // tested to process DCS data,
39 // some fake data has to be created.
40 //
41 // The "fake" input data can be taken using either (a) or (b):
42 // (a) data from a file: Use ReadDCSAliasMap()
43 // the format of the file is explained in ReadDCSAliasMap()
44 // To use it uncomment the following line:
45 //
46 // TMap* dcsAliasMap = ReadDCSAliasMap();
47 //
48 // (b) generated in this macro: Use CreateDCSAliasMap() and
49 // its documentation
50 // To use it uncomment the following line:
51 //
52
53 TMap* dcsAliasMap = CreateDCSAliasMap();
54
55 // now give the alias map to the shuttle
56
57 shuttle->SetDCSInput(dcsAliasMap);
58
59 // TODO(2)
60 //
61 // The shuttle can also process files that originate from DCS, DAQ and HLT.
62 // To test it, we provide some local files and locations where these would
63 // be found when
64 // the online machinery would be there.
65 // In real life this functions would be produces by the sub-detectors
66 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
67 //
68 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
69 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
70 // In this example we add a file originating from the GDC with the id PEDESTALS
71 // Three files originating from different LDCs but with the same id are also added
72 // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
73 // the "online" naming convention ALICE-INT-2003-039.
74
75 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "PMD", "PMD_PED", "GDC0", "PMD_PED.root");
76 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "PMD", "PMDGAINS", "GDC0", "xy.root");
77
78 // TODO(3)
79 //
80 // The shuttle can read run type stored in the DAQ logbook.
81 // To test it, we must provide the run type manually. They will be retrieved in the preprocessor
82 // using GetRunType function.
83
84 shuttle->SetInputRunType("PEDESTAL_RUN");
85
86 // TODO(4)
87 //
88 // The shuttle can read run parameters stored in the DAQ run logbook.
89 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
90 // using GetRunParameter function.
91
92 shuttle->AddInputRunParameter("totalEvents", "30000");
93 shuttle->AddInputRunParameter("NumberOfGDCs", "15");
94
95 // TODO(5)
96 //
97 // The shuttle can query condition parameters valid from the current run from the OCDB
98 // To test it, we must first store the object into the OCDB. It will be retrieved in the preprocessor
99 // using GetFromOCDB function.
100
101 TObjString obj("This is a condition parameter stored in OCDB");
102 AliCDBId id("TPC/Calib/Data", 0, AliCDBRunRange::Infinity());
103 AliCDBMetaData md;
104 AliCDBEntry entry(&obj, id, &md);
105
106 shuttle->AddInputCDBEntry(&entry);
107
108
109 // TODO(6)
110 // Create the preprocessor that should be tested, it registers
111 // itself automatically to the shuttle
112 // AliPreprocessor* test = new AliTestPreprocessor(shuttle);
113 AliPMDPreprocessor* test = new AliPMDPreprocessor(shuttle);
114
115 // Test the preprocessor
116 shuttle->Process();
117
118 // TODO(7)
119 // In the preprocessor AliShuttleInterface::Store should be called to put the final
120 // data to the CDB. To check if all went fine have a look at the files produced in
121 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
122 //
123 // Check the file which should have been created
124 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
125 ->Get("PMD/Calib/Ped", 7);
126 if (!chkEntry)
127 {
128 printf("The file is not there. Something went wrong.\n");
129 return;
130 }
131
132 AliPMDPedestal* output = dynamic_cast<AliPMDPedestal*> (chkEntry->GetObject());
133 // If everything went fine, draw the result
134 if (output)
135 output->Print();
cda4fe9e 136}
137
138TMap* CreateDCSAliasMap()
139{
51e6156c 140 // Creates a DCS structure
141 // The structure is the following:
142 // TMap (key --> value)
143 // <DCSAlias> --> <valueList>
144 // <DCSAlias> is a string
145 // <valueList> is a TObjArray of AliDCSValue
146 // An AliDCSValue consists of timestamp and a value in form
147 // of a AliSimpleValue
148
149 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
150 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
151
152 TMap* aliasMap = new TMap;
153 aliasMap->SetOwner(1);
154
155 TRandom random;
156
157 for(int nAlias=0;nAlias<6;nAlias++)
cda4fe9e 158 {
51e6156c 159 TObjArray* valueSet = new TObjArray;
160 valueSet->SetOwner(1);
161
162 TString aliasName="DCSAlias";
163 aliasName += nAlias;
164 //printf("\n\n alias: %s\n\n",aliasName.Data());
165
166 for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
167 {
168 AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
169 //printf("%s\n",dcsVal->ToString().Data());
170 valueSet->Add(dcsVal);
171 }
172 aliasMap->Add(new TObjString(aliasName), valueSet);
cda4fe9e 173 }
51e6156c 174
175 return aliasMap;
cda4fe9e 176}
177
178TMap* ReadDCSAliasMap()
179{
51e6156c 180 // Open a file that contains DCS input data
181 // The CDB framework is used to open the file, this means the file is located
182 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
183 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
184 // An explanation of the structure can be found in CreateDCSAliasMap()
185
186 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
187 ->Get("DET/DCS/Data", 0);
188 return dynamic_cast<TMap*> (entry->GetObject());
cda4fe9e 189}
190
191void WriteDCSAliasMap()
192{
51e6156c 193 // This writes the output from CreateDCSAliasMap to a CDB file
194
195 TMap* dcsAliasMap = CreateDCSAliasMap();
196
197 AliCDBMetaData metaData;
198 metaData.SetBeamPeriod(0);
199 metaData.SetResponsible("Responsible person");
200 metaData.SetComment("Test object for TestPreprocessor.C");
201
202 AliCDBId id("DET/DCS/Data", 0, 0);
203
204 // look into AliTestShuttle's CDB main folder
205
206 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
207 ->Put(dcsAliasMap, id, &metaData);
cda4fe9e 208}