]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ZDC/TestZDCPreprocessor.C
Removing unuseful prints
[u/mrichter/AliRoot.git] / ZDC / TestZDCPreprocessor.C
CommitLineData
438a188c 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
bf867209 11void TestZDCPreprocessor(const char* runType="PHYSICS")
438a188c 12{
13 // load library
14 gSystem->Load("libTestShuttle.so");
15
16 // create AliTestShuttle instance
17 // The parameters are run, startTime, endTime
86dc0caa 18 AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1);
438a188c 19
438a188c 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
1a1c78d4 22 //AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
23 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/OCDB");
da2b6160 24 //AliTestShuttle::SetMainCDB("alien://folder=/alice/data/2009/OCDB/");
e83c8d88 25 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
438a188c 26
da2b6160 27 printf("\n Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
28 printf(" Test Reference storage Uri: %s\n\n", AliShuttleInterface::GetMainRefStorage().Data());
438a188c 29
438a188c 30 // TODO(1)
31 //
32 // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data,
33 // some fake data has to be created.
34 //
35 // The "fake" input data can be taken using either (a) or (b):
36 // (a) data from a file: Use ReadDCSAliasMap()
37 // the format of the file is explained in ReadDCSAliasMap()
38 // To use it uncomment the following line:
39 //
1a1c78d4 40 //TMap* dcsAliasMap = ReadDCSAliasMap();
438a188c 41 //
42 // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
43 // To use it uncomment the following line:
44 //
1a1c78d4 45 TMap* dcsAliasMap = CreateDCSAliasMap();
57c85e6e 46 //dcsAliasMap->Print("");
da2b6160 47 //WriteDCSAliasMap();
438a188c 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.
1ee299a5 66 //
da2b6160 67 shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PEDESTALDATA", "LDC", "ZDCPedestal.dat");
68 shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PEDESTALHISTOS", "LDC", "ZDCPedHisto.root");
321fe3b8 69 //
da2b6160 70 shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "LASERDATA", "LDC", "ZDCLaserCalib.dat");
71 shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "LASERHISTOS", "LDC", "ZDCLaserHisto.root");
321fe3b8 72 //
da2b6160 73 shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "EMDENERGYCALIB", "LDC", "ZDCEnergyCalib.dat");
74 shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "EMDTOWERCALIB", "LDC", "ZDCTowerCalib.dat");
321fe3b8 75 //
da2b6160 76 shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "MAPPING", "MON", "ZDCChMapping.dat");
438a188c 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.
da2b6160 83 shuttle->SetInputRunType(runType);
84
438a188c 85 // TODO(4)
86 //
87 // The shuttle can read run parameters stored in the DAQ run logbook.
88 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
89 // using GetRunParameter function.
90 // In real life the parameters will be retrieved automatically from the run logbook;
e83c8d88 91 //shuttle->AddInputRunParameter("beamType", "A-A");
321fe3b8 92 shuttle->AddInputRunParameter("beamType", "p-p");
438a188c 93 shuttle->AddInputRunParameter("totalEvents", "1000");
94 shuttle->AddInputRunParameter("NumberOfGDCs", "1");
95
952af594 96 // TODO(5) NEW!
97 //
98 // This is for preprocessor that require data from HLT.
99 // Since HLT may be switched off, the preprocessor should first query the Run logbook where
100 // the HLT status is stored. SHUTTLE implements a shortcut function (GetHLTStatus) that returns
101 // a bool directly. 1 = HLT ON, 0 = HLT OFF
102 //
103 Bool_t hltStatus=kFALSE;
d2317a93 104 shuttle->SetInputHLTStatus(hltStatus);
952af594 105
106 // TODO(6)
438a188c 107 //
108 // The shuttle can query condition parameters valid from the current run from the OCDB
109 // To test it, we must first store the object into the OCDB. It will be retrieved in the preprocessor
110 // using GetFromOCDB function.
1ee299a5 111
112 /*TObjString obj("This is a condition parameter stored in OCDB");
438a188c 113 AliCDBId id("ZDC/Calib/Data", 0, AliCDBRunRange::Infinity());
114 AliCDBMetaData md;
115 AliCDBEntry entry(&obj, id, &md);
116
117 shuttle->AddInputCDBEntry(&entry);
1ee299a5 118 */
119
438a188c 120 // TODO(6)
121 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
952af594 122 AliPreprocessor* test = new AliZDCPreprocessor(shuttle);
da2b6160 123 shuttle->Print();
124
438a188c 125 // Test the preprocessor
126 shuttle->Process();
1a1c78d4 127 //printf(" Back to test macro: final checks! \n");
438a188c 128
129 // TODO(7)
130 // In the preprocessor AliShuttleInterface::Store should be called to put the final
131 // data to the CDB. To check if all went fine have a look at the files produced in
132 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
133 //
134 // Check the file which should have been created
1ee299a5 135 AliCDBEntry* chkEntry0 = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
dfa968c2 136 ->Get("ZDC/Calib/ChMap", 0);
da2b6160 137 TString str(runType);
86dc0caa 138 AliCDBEntry* chkEntry1;
da2b6160 139 if((str.CompareTo("STANDALONE_PEDESTAL")) == 0) chkEntry1 = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
dfa968c2 140 ->Get("ZDC/Calib/Pedestals", 0);
da2b6160 141 else if((str.CompareTo("STANDALONE_LASER")) == 0) chkEntry1 = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
dfa968c2 142 ->Get("ZDC/Calib/LaserCalib", 0);
da2b6160 143 else if((str.CompareTo("CALIBRATION_EMD")) == 0) chkEntry1 = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
dfa968c2 144 ->Get("ZDC/Calib/EnergyCalib", 0);
1ee299a5 145
6024ec85 146
86dc0caa 147 if(!chkEntry0){
73bc3a3f 148 printf("No file in ZDC/Calib/ChMap\n");
438a188c 149 return;
150 }
86dc0caa 151 if(!chkEntry1){
da2b6160 152 if((str.CompareTo("STANDALONE_PEDESTAL")) == 0) printf("No file in ZDC/Calib/Pedestal\n");
153 else if((str.CompareTo("STANDALONE_LASER")) == 0) printf("No file in ZDC/Calib/LaserCalib\n");
154 else if((str.CompareTo("CALIBRATION_EMD")) == 0) printf("No file in ZDC/Calib/EnergyCalib\n");
86dc0caa 155 return;
156 }
157
438a188c 158
86dc0caa 159 /*AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry1->GetObject());
438a188c 160 // If everything went fine, draw the result
161 if (output)
86dc0caa 162 output->Draw();*/
438a188c 163}
164
165TMap* CreateDCSAliasMap()
166{
167 // Creates a DCS structure
168 // The structure is the following:
169 // TMap (key --> value)
170 // <DCSAlias> --> <valueList>
171 // <DCSAlias> is a string
172 // <valueList> is a TObjArray of AliDCSValue
173 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
174
175 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
176 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
177
178 TMap* aliasMap = new TMap;
179 aliasMap->SetOwner(1);
180
181 TRandom random;
952af594 182 TString aliasNames[28];
438a188c 183
184 // ******************************** alignment values
185 aliasNames[0] = "ZDC_ZNA_POS.actual.position";
186 aliasNames[1] = "ZDC_ZPA_POS.actual.position";
187 aliasNames[2] = "ZDC_ZNC_POS.actual.position";
188 aliasNames[3] = "ZDC_ZPC_POS.actual.position";
189 //
57c85e6e 190 for(int nAlias=0; nAlias<4; nAlias++){
438a188c 191 TObjArray* valueSet = new TObjArray;
192 valueSet->SetOwner(1);
193
194 TString aliasName = aliasNames[nAlias];
73bc3a3f 195 //printf("\n\n alias: %s\n\n",aliasName.Data());
438a188c 196
197 Float_t simVal = (Float_t) (random.Rndm()*0.025+random.Rndm()*0.1);
57c85e6e 198 int timeStamp1[5] = {0,500,1000,1500,2000};
199 for(int i=0;i<5;i++){
438a188c 200 AliDCSValue* dcsVal = new AliDCSValue(simVal, timeStamp1[i]);
73bc3a3f 201 //printf("%s\n",dcsVal->ToString());
438a188c 202 valueSet->Add(dcsVal);
203 }
204 aliasMap->Add(new TObjString(aliasName), valueSet);
205 }
206 // ******************************** HV values
438a188c 207 aliasNames[4] = "ZDC_ZNA_HV0.actual.vMon";
208 aliasNames[5] = "ZDC_ZNA_HV1.actual.vMon";
209 aliasNames[6] = "ZDC_ZNA_HV2.actual.vMon";
210 aliasNames[7] = "ZDC_ZNA_HV3.actual.vMon";
211 aliasNames[8] = "ZDC_ZNA_HV4.actual.vMon";
212 //
213 aliasNames[9] = "ZDC_ZPA_HV0.actual.vMon";
214 aliasNames[10] = "ZDC_ZPA_HV1.actual.vMon";
215 aliasNames[11] = "ZDC_ZPA_HV2.actual.vMon";
216 aliasNames[12] = "ZDC_ZPA_HV3.actual.vMon";
217 aliasNames[13] = "ZDC_ZPA_HV4.actual.vMon";
218 //
219 aliasNames[14] = "ZDC_ZNC_HV0.actual.vMon";
220 aliasNames[15] = "ZDC_ZNC_HV1.actual.vMon";
221 aliasNames[16] = "ZDC_ZNC_HV2.actual.vMon";
222 aliasNames[17] = "ZDC_ZNC_HV3.actual.vMon";
223 aliasNames[18] = "ZDC_ZNC_HV4.actual.vMon";
224 //
225 aliasNames[19] = "ZDC_ZPC_HV0.actual.vMon";
226 aliasNames[20] = "ZDC_ZPC_HV1.actual.vMon";
227 aliasNames[21] = "ZDC_ZPC_HV2.actual.vMon";
228 aliasNames[22] = "ZDC_ZPC_HV3.actual.vMon";
229 aliasNames[23] = "ZDC_ZPC_HV4.actual.vMon";
230 //
952af594 231 aliasNames[24] = "ZDC_ZEM_HV0.actual.vMon";
232 aliasNames[25] = "ZDC_ZEM_HV1.actual.vMon";
233 //
20a3b76c 234 aliasNames[26] = "ZDC_REFA_HV.actual.vMon";
235 aliasNames[27] = "ZDC_REFC_HV.actual.vMon";
438a188c 236 //
57c85e6e 237 for(int nAlias=4;nAlias<28;nAlias++){
238 if(nAlias<14 || nAlias>18){
239 TObjArray* valueSet = new TObjArray;
240 valueSet->SetOwner(1);
438a188c 241
57c85e6e 242 TString aliasName = aliasNames[nAlias];
1a1c78d4 243 //printf("\n\n alias: %s\n\n",aliasName.Data());
57c85e6e 244
245 for(int timeStamp=0;timeStamp<=2000;timeStamp+=500){
246 Float_t simVal = (Float_t) (random.Gaus()*600.+1800.);
247 AliDCSValue* dcsVal = new AliDCSValue(simVal, timeStamp);
248 //printf("%s\n",dcsVal->ToString());
249 valueSet->Add(dcsVal);
250 }
251 aliasMap->Add(new TObjString(aliasName), valueSet);
252 }
438a188c 253 }
254
255 return aliasMap;
256}
257
258TMap* ReadDCSAliasMap()
259{
260 // Open a file that contains DCS input data
261 // The CDB framework is used to open the file, this means the file is located
262 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
263 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
264 // An explanation of the structure can be found in CreateDCSAliasMap()
265
bf867209 266 AliCDBManager *manager = AliCDBManager::Instance();
267 AliCDBStorage *sto = manager->GetStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/");
268 AliCDBId id("ZDC/DCS/Data",0,999999999);
57c85e6e 269 AliCDBEntry *entry = sto->Get("ZDC/DCS/Data", 0);
bf867209 270 if(!entry) printf("TestZDCPreprocessor.C -> ERROR! No entry found as DCS Map! \n");
438a188c 271 return dynamic_cast<TMap*> (entry->GetObject());
272}
273
274void WriteDCSAliasMap()
275{
276 // This writes the output from CreateDCSAliasMap to a CDB file
277
278 TMap* dcsAliasMap = CreateDCSAliasMap();
279
280 AliCDBMetaData metaData;
281 metaData.SetBeamPeriod(0);
d2317a93 282 metaData.SetResponsible("Chiara Oppedisano");
283 metaData.SetComment("Test object for TestZDCPreprocessor.C");
438a188c 284
bf867209 285 AliCDBId id("ZDC/DCS/Data", 0, 999999999);
438a188c 286
287 // initialize location of CDB
162637e4 288 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB");
438a188c 289
290 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);
291}