5 // This class runs the test TOF preprocessor
6 // It uses AliTestShuttle to simulate a full Shuttle process
8 // The input data is created in the functions
9 // CreateDCSAliasMap() creates input that would in the same way come from DCS
10 // ReadDCSAliasMap() reads from a file
11 // CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
13 extern TBenchmark *gBenchmark;
14 void TOFPreprocessor()
16 gSystem->Load("$ALICE/SHUTTLE/TestShuttle/libTestShuttle.so");
18 AliLog::SetClassDebugLevel("AliTOFPreprocessor",1);
19 // initialize location of CDB
20 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
21 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
23 // create AliTestShuttle instance
24 AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000);
26 // Generation of "fake" input DCS data
27 TMap* dcsAliasMap = CreateDCSAliasMap();
29 // now give the alias map to the shuttle
30 shuttle->SetDCSInput(dcsAliasMap);
32 // processing files. for the time being, the files are local.
33 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root");
34 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root");
37 for (Int_t iLDC=0;iLDC<2;iLDC++){
38 sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutPulserLDC_%02i.root",iLDC*2);
39 sprintf(LDCname,"LDC%i",iLDC*2);
40 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "PULSER", LDCname, filename);
41 sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutNoiseLDC_%02i.root",iLDC*2);
42 sprintf(LDCname,"LDC%i",iLDC*2);
43 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "NOISE", LDCname, filename);
46 // instantiation of the preprocessor
47 AliPreprocessor* pp = new AliTOFPreprocessor(shuttle);
50 gBenchmark->Start("process");
52 gBenchmark->Stop("process");
53 gBenchmark->Print("process");
55 // checking the file which should have been created
56 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/ParOnline", 0);
59 printf("The file is not there. Something went wrong.\n");
63 AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject());
64 // If everything went fine, draw the result
66 printf("Output found.\n");
71 TMap* CreateDCSAliasMap()
73 // Creates a DCS structure
74 // The structure is the following:
75 // TMap (key --> value)
76 // <DCSAlias> --> <valueList>
77 // <DCSAlias> is a string
78 // <valueList> is a TObjArray of AliDCSValue
79 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
81 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
82 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
84 TMap* aliasMap = new TMap;
85 aliasMap->SetOwner(1);
88 TDatime *datime = new TDatime();
89 Int_t time = datime->GetTime();
90 Int_t date = datime->GetDate();
91 Int_t pid = gSystem->GetPid();
93 Int_t iseed = TMath::Abs(10000 * pid + time - date);
95 //Float_t thrHVv=7.75, thrHVc=3, thrLVv=2.75, thrLVc=2.5,
96 //thrFEEthr=1.5, thrFEEt=10, thrTemp=35, thrPress=1000;
97 //Float_t tentHVv=6.75, tentHVc=2, tentLVv=1.75, tentLVc=1.5,
98 // tentFEEthr=0.5, te result=0;
99 //ntFEEt=20, tentTemp=25, tentPress=900;
100 //Float_t sigmaHVv=1, sigmaHVc=0.25, sigmaLVv=0.25, sigmaLVc=0.25,
101 // sigmaFEEthr=0.05, sigmaFEEt=5, sigmaTemp=1, sigmaPress=10;
103 Float_t tentHVv=6500, tentHVi=80, tentLVv=2.7, tentLVi=4.5,
104 tentLVv33=3.3, tentLVv50=5.0, tentLVv48=48,
105 tentLVi33=100, tentLVi50=3.0, tentLVi48=10,
106 tentFEEthr=1.0, tentFEEtfeac=25, tentFEEttrm=45;
107 Float_t sigmaHVv=10, sigmaHVi=10, sigmaLVv=0.2, sigmaLVi=1.0,
108 sigmaLVv33=0.1, sigmaLVv50=0.1, sigmaLVv48=1,
109 sigmaLVi33=10, sigmaLVi50=0.5, sigmaLVi48=2,
110 sigmaFEEthr=0.1, sigmaFEEtfeac=10, sigmaFEEttrm=4;
112 Float_t tent=0, sigma=0, thr=0;
113 Int_t NAliases=10514, NHV=90, NLV=576, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576, NFEEttrm=6840, NT=1, NP=1;
115 for(int nAlias=0;nAlias<NAliases;nAlias++) {
117 TObjArray* valueSet = new TObjArray;
118 valueSet->SetOwner(1);
123 aliasName = "tof_hv_vp_";
124 sindex.Form("%02i",nAlias);
126 //aliasName += nAlias;
131 else if (nAlias<NHV*2){
132 // aliasName = "HVvneg";
133 //aliasName += nAlias-NHV;
134 aliasName = "tof_hv_vn_";
135 sindex.Form("%02i",nAlias-NHV);
141 else if (nAlias<NHV*3){
142 // aliasName = "HVcpos";
143 //aliasName += nAlias-2*NHV;
144 aliasName = "tof_hv_ip_";
145 sindex.Form("%02i",nAlias-2*NHV);
151 else if (nAlias<NHV*4){
152 // aliasName = "HVcneg";
153 //aliasName += nAlias-3*NHV;
154 aliasName = "tof_hv_in_";
155 sindex.Form("%02i",nAlias-3*NHV);
161 else if (nAlias<NHV*4+NLV){
162 // aliasName = "LVv";
163 //aliasName += nAlias-4*NHV;
164 aliasName = "tof_lv_vfea_";
165 sindex.Form("%03i",nAlias-4*NHV);
171 else if (nAlias<NHV*4+2*NLV){
172 // aliasName = "LVc";
173 //aliasName += nAlias-(4*NHV+NLV);
174 aliasName = "tof_lv_ifea_";
175 sindex.Form("%03i",nAlias-(4*NHV+NLV));
181 else if (nAlias<NHV*4+2*NLV+NLV33){
182 // aliasName = "LVc";
183 //aliasName += nAlias-(4*NHV+NLV);
184 aliasName = "tof_lv_v33_";
185 sindex.Form("%02i",nAlias-(4*NHV+2*NLV));
191 else if (nAlias<NHV*4+2*NLV+2*NLV33){
192 // aliasName = "LVc";
193 //aliasName += nAlias-(4*NHV+NLV);
194 aliasName = "tof_lv_i33_";
195 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+NLV33));
201 else if (nAlias<NHV*4+2*NLV+2*NLV33+NLV50){
202 // aliasName = "LVc";
203 //aliasName += nAlias-(4*NHV+NLV);
204 aliasName = "tof_lv_v50_";
205 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33));
211 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50){
212 // aliasName = "LVc";
213 //aliasName += nAlias-(4*NHV+NLV);
214 aliasName = "tof_lv_i50_";
215 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+NLV50));
221 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+NLV48){
222 // aliasName = "LVc";
223 //aliasName += nAlias-(4*NHV+NLV);
224 aliasName = "tof_lv_v48_";
225 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50));
231 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48){
232 // aliasName = "LVc";
233 //aliasName += nAlias-(4*NHV+NLV);
234 aliasName = "tof_lv_i48_";
235 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+NLV48));
241 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr){
242 // aliasName = "FEEthr";
243 //aliasName += nAlias-(4*NHV+2*NLV-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
244 aliasName = "tof_fee_th_";
245 sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
251 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac){
252 //cout << " nalias fee temp = " << nAlias << endl;
253 // aliasName = "FEEt";
254 //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
255 aliasName = "tof_fee_tfeac_";
256 sindex.Form("%03i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr));
258 //cout << " nalias fee temp name = " << aliasName << endl;
263 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm){
264 //cout << " nalias fee temp = " << nAlias << endl;
265 // aliasName = "FEEt";
266 //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
267 aliasName = "tof_fee_ttrm_";
268 sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac));
270 //cout << " nalias fee temp name = " << aliasName << endl;
276 // gauss generation of values
277 for (int timeStamp=0;timeStamp<1000;timeStamp+=10){
278 Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
279 if (TMath::Abs(gaussvalue-tent)>sigma){
280 AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp);
281 valueSet->Add(dcsVal);
285 aliasMap->Add(new TObjString(aliasName), valueSet);
291 TMap* ReadDCSAliasMap()
293 // Open a file that contains DCS input data
294 // The CDB framework is used to open the file, this means the file is located
295 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
296 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
297 // An explanation of the structure can be found in CreateDCSAliasMap()
299 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0);
300 return dynamic_cast<TMap*> (entry->GetObject());
303 void WriteDCSAliasMap()
305 // This writes the output from CreateDCSAliasMap to a CDB file
307 TMap* dcsAliasMap = CreateDCSAliasMap();
309 AliCDBMetaData metaData;
310 metaData.SetBeamPeriod(0);
311 metaData.SetResponsible("Chiara");
312 metaData.SetComment("Test object for TOFPreprocessor.C");
314 AliCDBId id("TOF/DCS/Data", 0, 0);
316 // initialize location of CDB
317 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
319 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);