3 // This class runs the test preprocessor
4 // It uses AliTestShuttle to simulate a full Shuttle process
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
11 void TestZDCPreprocessor()
14 gSystem->Load("libTestShuttle.so");
16 // create AliTestShuttle instance
17 // The parameters are run, startTime, endTime
18 AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
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/SHUTTLE/TestShuttle/TestCDB");
23 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
25 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
26 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
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.
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:
39 //TMap* dcsAliasMap = ReadDCSAliasMap();
41 // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
42 // To use it uncomment the following line:
44 TMap* dcsAliasMap = CreateDCSAliasMap();
47 // now give the alias map to the shuttle
48 shuttle->SetDCSInput(dcsAliasMap);
52 // The shuttle can also process files that originate from DCS, DAQ and HLT.
53 // To test it, we provide some local files and locations where these would be found when
54 // the online machinery would be there.
55 // In real life this functions would be produces by the sub-detectors
56 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
58 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
59 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
60 // In this example we add a file originating from the GDC with the id PEDESTALS
61 // Three files originating from different LDCs but with the same id are also added
62 // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
63 // the "online" naming convention ALICE-INT-2003-039.
64 shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PEDESTALS", "LDC0", "ZDCPedestal.dat");
65 shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "EMDCALIB", "LDC0", "ZDCEMDCalib.dat");
66 shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PHYSICS", "LDC0", "ZDCRecParam.dat");
70 // The shuttle can read run type stored in the DAQ logbook.
71 // To test it, we must provide the run type manually. They will be retrieved in the preprocessor
72 // using GetRunType function.
73 shuttle->SetInputRunType("STANDALONE_PEDESTAL");
74 //shuttle->SetInputRunType("STANDALONE_EMD");
75 //shuttle->SetInputRunType("PHYSICS");
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 // In real life the parameters will be retrieved automatically from the run logbook;
83 //shuttle->AddInputRunParameter("beamType", "Pb-Pb");
84 shuttle->AddInputRunParameter("beamType", "p-p");
85 shuttle->AddInputRunParameter("totalEvents", "1000");
86 shuttle->AddInputRunParameter("NumberOfGDCs", "1");
90 // This is for preprocessor that require data from HLT.
91 // Since HLT may be switched off, the preprocessor should first query the Run logbook where
92 // the HLT status is stored. SHUTTLE implements a shortcut function (GetHLTStatus) that returns
93 // a bool directly. 1 = HLT ON, 0 = HLT OFF
95 Bool_t hltStatus=kFALSE;
96 shuttle->SetInputHLTStatus(hltStatus);
100 // The shuttle can query condition parameters valid from the current run from the OCDB
101 // To test it, we must first store the object into the OCDB. It will be retrieved in the preprocessor
102 // using GetFromOCDB function.
104 TObjString obj("This is a condition parameter stored in OCDB");
105 AliCDBId id("ZDC/Calib/Data", 0, AliCDBRunRange::Infinity());
107 AliCDBEntry entry(&obj, id, &md);
109 shuttle->AddInputCDBEntry(&entry);
112 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
113 AliPreprocessor* test = new AliZDCPreprocessor(shuttle);
115 // Test the preprocessor
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
123 // Check the file which should have been created
124 /*AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
125 ->Get("ZDC/Calib/Pedestals", 7);
127 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
128 ->Get("ZDC/Calib/Calib", 7);
130 /*AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
131 ->Get("ZDC/Calib/RecParam", 7);
136 printf("The file is not there. Something went wrong.\n");
140 AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry->GetObject());
141 // If everything went fine, draw the result
146 TMap* CreateDCSAliasMap()
148 // Creates a DCS structure
149 // The structure is the following:
150 // TMap (key --> value)
151 // <DCSAlias> --> <valueList>
152 // <DCSAlias> is a string
153 // <valueList> is a TObjArray of AliDCSValue
154 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
156 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
157 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
159 TMap* aliasMap = new TMap;
160 aliasMap->SetOwner(1);
163 TString aliasNames[28];
165 // ******************************** alignment values
166 aliasNames[0] = "ZDC_ZNA_POS.actual.position";
167 aliasNames[1] = "ZDC_ZPA_POS.actual.position";
168 aliasNames[2] = "ZDC_ZNC_POS.actual.position";
169 aliasNames[3] = "ZDC_ZPC_POS.actual.position";
171 for(int nAlias=0; nAlias<4; nAlias++)
173 TObjArray* valueSet = new TObjArray;
174 valueSet->SetOwner(1);
176 TString aliasName = aliasNames[nAlias];
177 printf("\n\n alias: %s\n\n",aliasName.Data());
179 Float_t simVal = (Float_t) (random.Rndm()*0.025+random.Rndm()*0.1);
182 int timeStamp1[3] = {0,500,1000};
183 AliDCSValue* dcsVal = new AliDCSValue(simVal, timeStamp1[i]);
184 printf("%s\n",dcsVal->ToString());
185 valueSet->Add(dcsVal);
187 aliasMap->Add(new TObjString(aliasName), valueSet);
189 // ******************************** HV values
190 aliasNames[4] = "ZDC_ZNA_HV0.actual.vMon";
191 aliasNames[5] = "ZDC_ZNA_HV1.actual.vMon";
192 aliasNames[6] = "ZDC_ZNA_HV2.actual.vMon";
193 aliasNames[7] = "ZDC_ZNA_HV3.actual.vMon";
194 aliasNames[8] = "ZDC_ZNA_HV4.actual.vMon";
196 aliasNames[9] = "ZDC_ZPA_HV0.actual.vMon";
197 aliasNames[10] = "ZDC_ZPA_HV1.actual.vMon";
198 aliasNames[11] = "ZDC_ZPA_HV2.actual.vMon";
199 aliasNames[12] = "ZDC_ZPA_HV3.actual.vMon";
200 aliasNames[13] = "ZDC_ZPA_HV4.actual.vMon";
202 aliasNames[14] = "ZDC_ZNC_HV0.actual.vMon";
203 aliasNames[15] = "ZDC_ZNC_HV1.actual.vMon";
204 aliasNames[16] = "ZDC_ZNC_HV2.actual.vMon";
205 aliasNames[17] = "ZDC_ZNC_HV3.actual.vMon";
206 aliasNames[18] = "ZDC_ZNC_HV4.actual.vMon";
208 aliasNames[19] = "ZDC_ZPC_HV0.actual.vMon";
209 aliasNames[20] = "ZDC_ZPC_HV1.actual.vMon";
210 aliasNames[21] = "ZDC_ZPC_HV2.actual.vMon";
211 aliasNames[22] = "ZDC_ZPC_HV3.actual.vMon";
212 aliasNames[23] = "ZDC_ZPC_HV4.actual.vMon";
214 aliasNames[24] = "ZDC_ZEM_HV0.actual.vMon";
215 aliasNames[25] = "ZDC_ZEM_HV1.actual.vMon";
217 aliasNames[26] = "ZDC_REFA_HV.actual.vMon";
218 aliasNames[27] = "ZDC_REFC_HV.actual.vMon";
220 for(int nAlias=4;nAlias<28;nAlias++)
222 TObjArray* valueSet = new TObjArray;
223 valueSet->SetOwner(1);
225 TString aliasName = aliasNames[nAlias];
226 printf("\n\n alias: %s\n\n",aliasName.Data());
228 for(int timeStamp=0;timeStamp<=1000;timeStamp+=500)
230 Float_t simVal = (Float_t) (random.Gaus()*600.+1800.);
231 AliDCSValue* dcsVal = new AliDCSValue(simVal, timeStamp);
232 printf("%s\n",dcsVal->ToString());
233 valueSet->Add(dcsVal);
235 aliasMap->Add(new TObjString(aliasName), valueSet);
241 TMap* ReadDCSAliasMap()
243 // Open a file that contains DCS input data
244 // The CDB framework is used to open the file, this means the file is located
245 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
246 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
247 // An explanation of the structure can be found in CreateDCSAliasMap()
249 AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/DCS/Data", 0);
250 return dynamic_cast<TMap*> (entry->GetObject());
253 void WriteDCSAliasMap()
255 // This writes the output from CreateDCSAliasMap to a CDB file
257 TMap* dcsAliasMap = CreateDCSAliasMap();
259 AliCDBMetaData metaData;
260 metaData.SetBeamPeriod(0);
261 metaData.SetResponsible("Chiara Oppedisano");
262 metaData.SetComment("Test object for TestZDCPreprocessor.C");
264 AliCDBId id("ZDC/DCS/Data", 0, 0);
266 // initialize location of CDB
267 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
269 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);