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