]>
Commit | Line | Data |
---|---|---|
92e5c8ed | 1 | |
2 | // This macro runs the GRP test preprocessor | |
3 | // It uses AliTestShuttle to simulate a full Shuttle process | |
4 | ||
5 | // The input data is created in the functions | |
6 | // CreateDCSAliasMap() creates input that would in the same way come from DCS | |
7 | // ReadDCSAliasMap() reads from a file | |
8 | // CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle | |
9 | ||
e75e6e01 | 10 | // Taking as input runtype and errorLevel |
11 | // errorLevel used to simulate errors: | |
12 | // 0 --> no error | |
13 | // 1 --> DAQ logbook error | |
14 | // 2 --> DAQ FXS error | |
15 | // 3 --> DAQ logbook_trigger_config erro | |
16 | // 4 --> DCS FXS error | |
17 | // 5 --> DCS DPs error | |
18 | // 6 --> Missing beamEnergy | |
19 | // 7 --> null buffer for Trigger Config | |
20 | ||
21 | // Need to include dummy files in TestShuttle/TestCDB for CTP Configuration and Scalers | |
22 | // (see macro $ALICE_ROOT/GRP/MakeCTPDummyEntries.C) | |
23 | ||
24 | // Modified by C. Zampolli | |
25 | ||
26 | ||
e3efae04 | 27 | #include <iostream> |
28 | #include <fstream> | |
29 | using namespace std; | |
92e5c8ed | 30 | |
e75e6e01 | 31 | void TestGRPPreprocessor(const char* runtype="PHYSICS", TString partition="ALICE", TString detector="", TString beamType = "p-p", Int_t errorLevel=0) |
92e5c8ed | 32 | { |
92e5c8ed | 33 | gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so"); |
34 | ||
92e5c8ed | 35 | Int_t kRun = 7; |
36 | AliTestShuttle* shuttle = new AliTestShuttle(kRun, 1, 10); | |
37 | ||
e75e6e01 | 38 | AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); |
39 | AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference"); | |
92e5c8ed | 40 | |
41 | printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data()); | |
42 | printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data()); | |
43 | ||
e75e6e01 | 44 | // setting runtype |
45 | shuttle->SetInputRunType(runtype); | |
92e5c8ed | 46 | |
e75e6e01 | 47 | // simulating DCS DPs |
48 | TMap* dcsAliasMap = CreateDCSAliasMap(errorLevel); | |
92e5c8ed | 49 | shuttle->SetDCSInput(dcsAliasMap); |
50 | ||
e75e6e01 | 51 | // simulating input from DAQ FXS |
52 | if (errorLevel != 2){ | |
53 | shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root", "GDC0", "$ALICE_ROOT/GRP/ShuttleInput/run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root"); | |
54 | shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021390_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root", "GDC1", "$ALICE_ROOT/GRP/ShuttleInput/run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root"); | |
55 | shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021391_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root", "GDC0", "$ALICE_ROOT/GRP/ShuttleInput/run000021391_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root"); | |
56 | shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021391_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root", "GDC1", "$ALICE_ROOT/GRP/ShuttleInput/run000021391_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root"); | |
57 | ||
58 | } | |
59 | ||
60 | // simulating input from DCS FXS | |
61 | if (errorLevel != 4 && !partition.IsNull() && detector.IsNull()){ | |
62 | shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt")); | |
63 | } | |
64 | ||
e3efae04 | 65 | Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg"); |
66 | ifstream is; | |
67 | is.open(filename); | |
68 | is.seekg(0,ios::end); | |
69 | int length = is.tellg(); | |
70 | const char *buffer = new char[length]; | |
71 | is.seekg(0,ios::beg); | |
72 | is.read(buffer,length); | |
73 | is.close(); | |
e75e6e01 | 74 | const char *emptybuffer = NULL; |
92e5c8ed | 75 | |
e75e6e01 | 76 | // simulating input from DAQ logbook_trigger_config |
77 | if { | |
78 | (errorLevel != 3 errorLevel != 7 && !partition.IsNull() && detector.IsNull()) shuttle->SetInputTriggerConfiguration(buffer); | |
79 | } | |
80 | else if (errorLevel == 7) { | |
81 | shuttle->SetInputTriggerConfiguration(emptybuffer); | |
82 | } | |
e3efae04 | 83 | |
e75e6e01 | 84 | // simulating input from DAQ logbook |
85 | if (errorLevel != 1){ | |
86 | shuttle->AddInputRunParameter("DAQ_time_start", "1233213.22"); | |
87 | } | |
88 | if (errorLevel != 6){ | |
89 | shuttle->AddInputRunParameter("beamEnergy", "1400."); | |
90 | } | |
91 | ||
92 | shuttle->AddInputRunParameter("DAQ_time_end", "1345645.22"); | |
93 | shuttle->AddInputRunParameter("beamType", beamType); | |
92e5c8ed | 94 | shuttle->AddInputRunParameter("numberOfDetectors", "5"); |
95 | shuttle->AddInputRunParameter("detectorMask", "34555"); | |
96 | shuttle->AddInputRunParameter("LHCperiod", "LHC08b"); | |
e75e6e01 | 97 | shuttle->AddInputRunParameter("partition",partition); |
98 | shuttle->AddInputRunParameter("detector",detector); | |
92e5c8ed | 99 | |
e75e6e01 | 100 | // simulating HLT |
92e5c8ed | 101 | Bool_t hltStatus = kTRUE; |
102 | shuttle->SetInputHLTStatus(hltStatus); | |
103 | ||
92e5c8ed | 104 | // Create the preprocessor that should be tested, it registers itself automatically to the shuttle |
105 | AliPreprocessor* test = new AliGRPPreprocessor(shuttle); | |
106 | ||
107 | // Test the preprocessor | |
108 | shuttle->Process(); | |
109 | ||
110 | printf("\n\n"); | |
111 | ||
92e5c8ed | 112 | // Check the file which should have been created |
113 | AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
114 | ->Get("GRP/GRP/Data", kRun); | |
115 | if (!chkEntry) { | |
116 | printf("The file is not there. Something went wrong.\n"); | |
117 | return; | |
118 | } | |
119 | chkEntry->PrintId(); | |
120 | chkEntry->GetObject()->Print(); | |
121 | printf("\n\n"); | |
122 | ||
92e5c8ed | 123 | } |
124 | ||
e75e6e01 | 125 | TMap* CreateDCSAliasMap(Int_t errorLevel) |
92e5c8ed | 126 | { |
127 | // Creates a DCS structure | |
128 | // The structure is the following: | |
e75e6e01 | 129 | // TMap (key --> value) |
130 | // <DCSAlias> --> <valueList> | |
131 | // <DCSAlias> is a string | |
132 | // <valueList> is a TObjArray of AliDCSValue | |
133 | // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue | |
92e5c8ed | 134 | |
e75e6e01 | 135 | const Int_t fgknDCSDP = 50; |
92e5c8ed | 136 | const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = { |
e75e6e01 | 137 | "LHCState", // missing in DCS |
92e5c8ed | 138 | "L3Polarity", |
139 | "DipolePolarity", | |
e75e6e01 | 140 | "LHCLuminosity", // missing in DCS |
141 | "BeamIntensity", // missing in DCS | |
92e5c8ed | 142 | "L3Current", |
143 | "DipoleCurrent", | |
e75e6e01 | 144 | "L3_BSF17_H1", |
145 | "L3_BSF17_H2", | |
146 | "L3_BSF17_H3", | |
147 | "L3_BSF17_Temperature", | |
148 | "L3_BSF4_H1", | |
149 | "L3_BSF4_H2", | |
150 | "L3_BSF4_H3", | |
151 | "L3_BSF4_Temperature", | |
152 | "L3_BKF17_H1", | |
153 | "L3_BKF17_H2", | |
154 | "L3_BKF17_H3", | |
155 | "L3_BKF17_Temperature", | |
156 | "L3_BKF4_H1", | |
157 | "L3_BKF4_H2", | |
158 | "L3_BKF4_H3", | |
159 | "L3_BKF4_Temperature", | |
160 | "L3_BSF13_H1", | |
161 | "L3_BSF13_H2", | |
162 | "L3_BSF13_H3", | |
163 | "L3_BSF13_Temperature", | |
164 | "L3_BSF8_H1", | |
165 | "L3_BSF8_H2", | |
166 | "L3_BSF8_H3", | |
167 | "L3_BSF8_Temperature", | |
168 | "L3_BKF13_H1", | |
169 | "L3_BKF13_H2", | |
170 | "L3_BKF13_H3", | |
171 | "L3_BKF13_Temperature", | |
172 | "L3_BKF8_H1", | |
173 | "L3_BKF8_H2", | |
174 | "L3_BKF8_H3", | |
175 | "L3_BKF8_Temperature", | |
176 | "Dipole_Inside_H1", | |
177 | "Dipole_Inside_H2", | |
178 | "Dipole_Inside_H3", | |
179 | "Dipole_Inside_Temperature", | |
180 | "Dipole_Outside_H1", | |
181 | "Dipole_Outside_H2", | |
182 | "Dipole_Outside_H3", | |
183 | "Dipole_Outside_Temperature", | |
92e5c8ed | 184 | "CavernTemperature", |
185 | "CavernAtmosPressure", | |
649b8dcf | 186 | "SurfaceAtmosPressure" |
92e5c8ed | 187 | }; |
188 | ||
189 | TMap* aliasMap; | |
190 | TObjArray* valueSet; | |
191 | AliDCSValue* dcsVal; | |
192 | ||
193 | aliasMap = new TMap; | |
194 | aliasMap->SetOwner(1); | |
195 | ||
196 | // LHCState | |
197 | valueSet = new TObjArray; | |
198 | valueSet->SetOwner(1); | |
e75e6e01 | 199 | dcsVal = new AliDCSValue( 'F', 2 ); |
92e5c8ed | 200 | valueSet->Add(dcsVal); |
e75e6e01 | 201 | aliasMap->Add( new TObjString(fgkDCSDataPoints[0]), valueSet ); |
92e5c8ed | 202 | |
203 | // L3Polarity | |
204 | valueSet = new TObjArray; | |
205 | valueSet->SetOwner(1); | |
e75e6e01 | 206 | dcsVal = new AliDCSValue( kTRUE, 2 ); |
92e5c8ed | 207 | valueSet->Add(dcsVal); |
208 | aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet ); | |
209 | ||
210 | // DipolePolarity | |
211 | valueSet = new TObjArray; | |
212 | valueSet->SetOwner(1); | |
e75e6e01 | 213 | dcsVal = new AliDCSValue( kTRUE, 2 ); |
92e5c8ed | 214 | valueSet->Add(dcsVal); |
215 | aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet ); | |
216 | ||
217 | TRandom random; | |
218 | ||
e75e6e01 | 219 | Int_t maxDPindex = 0; |
220 | if (errorLevel != 5) { | |
221 | maxDPindex = fgknDCSDP; | |
222 | } | |
223 | else { | |
224 | maxDPindex = 3; // simulating only a few DP in case errorLevel=5 | |
225 | } | |
226 | ||
227 | for( int nAlias=3; nAlias<maxDPindex; nAlias++) { | |
228 | if (nAlias>=7 && nAlias < 47) continue; | |
92e5c8ed | 229 | valueSet = new TObjArray; |
230 | valueSet->SetOwner(1); | |
231 | ||
e75e6e01 | 232 | for (int timeStamp=0; timeStamp<10; timeStamp++) { |
233 | dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStamp+1); | |
92e5c8ed | 234 | valueSet->Add(dcsVal); |
235 | } | |
236 | aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet ); | |
237 | } | |
238 | ||
e75e6e01 | 239 | // Hall Probes |
240 | TString probe1[3] = {"L3_BSF","L3_BKF","Dipole_"}; | |
241 | TString probe2[6] = {"17_","4_","13_","8_","Inside_","Outside_"}; | |
242 | TString probe3[4] = {"H1","H2","H3","Temperature"}; | |
243 | Int_t hp = 0; | |
244 | ||
245 | for (Int_t i=0;i<3;i++){ | |
246 | for (Int_t j=0;j<6;j++){ | |
247 | for (Int_t k=0;k<4;k++){ | |
248 | TString dpAlias = probe1[i]+probe2[j]+probe3[k]; | |
249 | valueSet = new TObjArray; | |
250 | valueSet->SetOwner(1); | |
251 | for (int timeStamp=0; timeStamp<10; timeStamp++) { | |
252 | dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStamp+1); | |
253 | valueSet->Add(dcsVal); | |
254 | //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl; | |
255 | } | |
256 | aliasMap->Add( new TObjString(dpAlias), valueSet ); | |
257 | hp++; | |
258 | } | |
259 | } | |
260 | } | |
261 | ||
92e5c8ed | 262 | return aliasMap; |
263 | } | |
264 | ||
265 | /* | |
266 | TMap* ReadDCSAliasMap() | |
267 | { | |
268 | // Open a file that contains DCS input data | |
269 | // The CDB framework is used to open the file, this means the file is located | |
270 | // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data | |
271 | // The file contains an AliCDBEntry that contains a TMap with the DCS structure. | |
272 | // An explanation of the structure can be found in CreateDCSAliasMap() | |
273 | ||
274 | AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
275 | ->Get("DET/DCS/Data", 0); | |
276 | return dynamic_cast<TMap*> (entry->GetObject()); | |
277 | } | |
278 | */ | |
279 | ||
280 | ||
281 | void WriteDCSAliasMap() | |
282 | { | |
283 | // This writes the output from CreateDCSAliasMap to a CDB file | |
284 | ||
e75e6e01 | 285 | TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel); |
92e5c8ed | 286 | |
287 | AliCDBMetaData metaData; | |
288 | metaData.SetBeamPeriod(0); | |
289 | metaData.SetResponsible("Ernesto Lopez Torres"); | |
290 | metaData.SetComment("Test object for TestGRPPreprocessor.C"); | |
291 | ||
292 | AliCDBId id("GRP/Data", 0, 0); | |
293 | ||
294 | // look into AliTestShuttle's CDB main folder | |
295 | ||
296 | AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
297 | ->Put(dcsAliasMap, id, &metaData); | |
298 | } |