]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/VZEROTestPreprocessor.C
Possibility to specify a DA output file with eq factors.
[u/mrichter/AliRoot.git] / VZERO / VZEROTestPreprocessor.C
CommitLineData
19a3e642 1/* $Id: TestPreprocessor.C 30923 2009-02-09 15:47:08Z hristov $ */
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 VZEROTestPreprocessor()
12{
13 // load library
14 gSystem->Load("libTestShuttle.so");
15
16 // create AliTestShuttle instance
17 // The parameters are run, startTime, endTime
d5deaaa5 18 AliTestShuttle* shuttle = new AliTestShuttle(12345, 0, 123450);
19a3e642 19
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/OCDB");
23 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB");
24
25 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
26 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
27
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
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::kDAQ, "V00", "V00da_results", "source1", "VZERO/V00da_results.txt");
69//
70 // TODO(3)
71 //
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");
76
77 // TODO(4)
78 //
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");
84
85 // TODO(5)
86 //
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 //
92
93 Bool_t hltStatus=kFALSE;
94 shuttle->SetInputHLTStatus(hltStatus);
95
96
97 // TODO(6)
98 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
99 AliPreprocessor* vzeroPreprocessor = new AliVZEROPreprocessor(shuttle);
100
101 // Test the preprocessor
102 shuttle->Process();
103
104 // TODO(7)
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
110 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
111 ->Get("VZERO/Calib/Data", 0);
112 if (!chkEntry)
113 {
114 printf("The file is not there. Something went wrong.\n");
115 return;
116 }
117 chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
118 ->Get("VZERO/Trigger/Data", 0);
119 if (!chkEntry)
120 {
121 printf("The file is not there. Something went wrong.\n");
122 return;
123 }
124
125 AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry->GetObject());
126 // If everything went fine, draw the result
127 if (output)
128 output->Draw();
129}
130
131TMap* CreateDCSAliasMap()
132{
133 // Creates a DCS structure
134 // The structure is the following:
135 // TMap (key --> value)
136 // <DCSAlias> --> <valueList>
137 // <DCSAlias> is a string
138 // <valueList> is a TObjArray of AliDCSValue
139 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
140
141 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
142 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
143
144 TMap* aliasMap = new TMap;
145 aliasMap->SetOwner(1);
146 TRandom random;
147
148 FILE *fp = fopen("VZERO/DCSValues.txt","r");
149
150 char name[50];
151 Float_t val;
152 while(!(EOF == fscanf(fp,"%s %f",name,&val))){
153 TObjArray* valueSet = new TObjArray;
154 valueSet->SetOwner(1);
155
156 TString aliasName=name;
157
158 //printf("alias: %s\t\t",aliasName.Data());
159
160 int timeStamp=10;
161
19a3e642 162
163 if(aliasName.Contains("HV")) {
d5deaaa5 164 for(int i=0;i<10;i++){
165 dcsVal = new AliDCSValue((Float_t) (val+random.Gaus(0,10)), timeStamp+10*i);
166 valueSet->Add(dcsVal);
167 }
5978520a 168 } else {
169 for(int i=0;i<2;i++){
170 AliDCSValue* dcsVal = new AliDCSValue((Int_t) (val), timeStamp+10*i);
171 valueSet->Add(dcsVal);
172 }
19a3e642 173 }
174
175 aliasMap->Add(new TObjString(aliasName), valueSet);
176
177 }
178 fclose(fp);
179 return aliasMap;
180}
181
182TMap* ReadDCSAliasMap()
183{
184 // Open a file that contains DCS input data
185 // The CDB framework is used to open the file, this means the file is located
186 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
187 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
188 // An explanation of the structure can be found in CreateDCSAliasMap()
189
190 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
191 ->Get("DET/DCS/Data", 0);
192 return dynamic_cast<TMap*> (entry->GetObject());
193}
194
195void WriteDCSAliasMap()
196{
197 // This writes the output from CreateDCSAliasMap to a CDB file
198
199 TMap* dcsAliasMap = CreateDCSAliasMap();
200
201 AliCDBMetaData metaData;
202 metaData.SetBeamPeriod(0);
203 metaData.SetResponsible("Responsible person");
204 metaData.SetComment("Test object for TestPreprocessor.C");
205
206 AliCDBId id("DET/DCS/Data", 0, 0);
207
208 // look into AliTestShuttle's CDB main folder
209
210 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
211 ->Put(dcsAliasMap, id, &metaData);
212}