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