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(Char_t * RunType="PHYSICS")
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);
25 //setting run type to physiscs
26 shuttle->SetInputRunType(RunType);
28 // Generation of "fake" input DCS data
29 TMap* dcsAliasMap = CreateDCSAliasMap();
31 // now give the alias map to the shuttle
32 shuttle->SetDCSInput(dcsAliasMap);
34 // processing files. for the time being, the files are local.
35 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root");
36 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root");
40 for (Int_t iLDC=0;iLDC<2;iLDC++){
41 sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutPulserLDC_%02i.root",iLDC*2);
42 sprintf(LDCname,"LDC%i",iLDC*2);
43 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "PULSER", LDCname, filename);
44 sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutNoiseLDC_%02i.root",iLDC*2);
45 sprintf(LDCname,"LDC%i",iLDC*2);
46 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "NOISE", LDCname, filename);
49 // instantiation of the preprocessor
50 AliPreprocessor* pp = new AliTOFPreprocessor(shuttle);
53 gBenchmark->Start("process");
55 gBenchmark->Stop("process");
56 gBenchmark->Print("process");
58 // checking the file which should have been created
59 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/ParOnline", 0);
62 printf("The file is not there. Something went wrong.\n");
66 AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject());
67 // If everything went fine, draw the result
69 printf("Output found.\n");
74 TMap* CreateDCSAliasMap()
76 // Creates a DCS structure
77 // The structure is the following:
78 // TMap (key --> value)
79 // <DCSAlias> --> <valueList>
80 // <DCSAlias> is a string
81 // <valueList> is a TObjArray of AliDCSValue
82 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
84 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
85 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
87 TMap* aliasMap = new TMap;
88 aliasMap->SetOwner(1);
91 TDatime *datime = new TDatime();
92 Int_t time = datime->GetTime();
93 Int_t date = datime->GetDate();
94 Int_t pid = gSystem->GetPid();
96 Int_t iseed = TMath::Abs(10000 * pid + time - date);
98 //Float_t thrHVv=7.75, thrHVc=3, thrLVv=2.75, thrLVc=2.5,
99 //thrFEEthr=1.5, thrFEEt=10, thrTemp=35, thrPress=1000;
100 //Float_t tentHVv=6.75, tentHVc=2, tentLVv=1.75, tentLVc=1.5,
101 // tentFEEthr=0.5, te result=0;
102 //ntFEEt=20, tentTemp=25, tentPress=900;
103 //Float_t sigmaHVv=1, sigmaHVc=0.25, sigmaLVv=0.25, sigmaLVc=0.25,
104 // sigmaFEEthr=0.05, sigmaFEEt=5, sigmaTemp=1, sigmaPress=10;
106 Float_t tentHVv=6500, tentHVi=80, tentLVv=2.7, tentLVi=4.5,
107 tentLVv33=3.3, tentLVv50=5.0, tentLVv48=48,
108 tentLVi33=100, tentLVi50=3.0, tentLVi48=10,
109 tentFEEthr=1.0, tentFEEtfeac=25, tentFEEttrm=45;
110 Float_t sigmaHVv=10, sigmaHVi=10, sigmaLVv=0.2, sigmaLVi=1.0,
111 sigmaLVv33=0.1, sigmaLVv50=0.1, sigmaLVv48=1,
112 sigmaLVi33=10, sigmaLVi50=0.5, sigmaLVi48=2,
113 sigmaFEEthr=0.1, sigmaFEEtfeac=10, sigmaFEEttrm=4;
115 Float_t tent=0, sigma=0, thr=0;
116 // to have all the aliases, deccoment the following line:
117 // Int_t NAliases=10944, NHV=90, NLV=792, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576, NFEEttrm=6840;
119 // if not all the aliases are there, use this:
120 Int_t NAliases=4104, NHV=90, NLV=792, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576;
122 for(int nAlias=0;nAlias<NAliases;nAlias++) {
124 TObjArray* valueSet = new TObjArray;
125 valueSet->SetOwner(1);
130 aliasName = "tof_hv_vp_";
131 sindex.Form("%02i",nAlias);
133 //aliasName += nAlias;
138 else if (nAlias<NHV*2){
139 // aliasName = "HVvneg";
140 //aliasName += nAlias-NHV;
141 aliasName = "tof_hv_vn_";
142 sindex.Form("%02i",nAlias-NHV);
148 else if (nAlias<NHV*3){
149 // aliasName = "HVcpos";
150 //aliasName += nAlias-2*NHV;
151 aliasName = "tof_hv_ip_";
152 sindex.Form("%02i",nAlias-2*NHV);
158 else if (nAlias<NHV*4){
159 // aliasName = "HVcneg";
160 //aliasName += nAlias-3*NHV;
161 aliasName = "tof_hv_in_";
162 sindex.Form("%02i",nAlias-3*NHV);
168 else if (nAlias<NHV*4+NLV){
169 // aliasName = "LVv";
170 //aliasName += nAlias-4*NHV;
171 aliasName = "tof_lv_vfea_";
172 sindex.Form("%03i",nAlias-4*NHV);
178 else if (nAlias<NHV*4+2*NLV){
179 // aliasName = "LVc";
180 //aliasName += nAlias-(4*NHV+NLV);
181 aliasName = "tof_lv_ifea_";
182 sindex.Form("%03i",nAlias-(4*NHV+NLV));
188 else if (nAlias<NHV*4+2*NLV+NLV33){
189 // aliasName = "LVc";
190 //aliasName += nAlias-(4*NHV+NLV);
191 aliasName = "tof_lv_v33_";
192 sindex.Form("%02i",nAlias-(4*NHV+2*NLV));
198 else if (nAlias<NHV*4+2*NLV+2*NLV33){
199 // aliasName = "LVc";
200 //aliasName += nAlias-(4*NHV+NLV);
201 aliasName = "tof_lv_i33_";
202 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+NLV33));
208 else if (nAlias<NHV*4+2*NLV+2*NLV33+NLV50){
209 // aliasName = "LVc";
210 //aliasName += nAlias-(4*NHV+NLV);
211 aliasName = "tof_lv_v50_";
212 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33));
218 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50){
219 // aliasName = "LVc";
220 //aliasName += nAlias-(4*NHV+NLV);
221 aliasName = "tof_lv_i50_";
222 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+NLV50));
228 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+NLV48){
229 // aliasName = "LVc";
230 //aliasName += nAlias-(4*NHV+NLV);
231 aliasName = "tof_lv_v48_";
232 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50));
238 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48){
239 // aliasName = "LVc";
240 //aliasName += nAlias-(4*NHV+NLV);
241 aliasName = "tof_lv_i48_";
242 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+NLV48));
248 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr){
249 // aliasName = "FEEthr";
250 //aliasName += nAlias-(4*NHV+2*NLV-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
251 aliasName = "tof_fee_th_";
252 sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
258 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac){
259 //cout << " nalias fee temp = " << nAlias << endl;
260 // aliasName = "FEEt";
261 //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
262 aliasName = "tof_fee_tfeac_";
263 sindex.Form("%03i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr));
265 //cout << " nalias fee temp name = " << aliasName << endl;
271 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm){
272 //cout << " nalias fee temp = " << nAlias << endl;
273 // aliasName = "FEEt";
274 //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
275 aliasName = "tof_fee_ttrm_";
276 sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac));
278 //cout << " nalias fee temp name = " << aliasName << endl;
284 // gauss generation of values
285 for (int timeStamp=0;timeStamp<1000;timeStamp+=10){
286 Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
287 if (TMath::Abs(gaussvalue-tent)>sigma){
288 AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp);
289 valueSet->Add(dcsVal);
293 aliasMap->Add(new TObjString(aliasName), valueSet);
299 TMap* ReadDCSAliasMap()
301 // Open a file that contains DCS input data
302 // The CDB framework is used to open the file, this means the file is located
303 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
304 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
305 // An explanation of the structure can be found in CreateDCSAliasMap()
307 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0);
308 return dynamic_cast<TMap*> (entry->GetObject());
311 void WriteDCSAliasMap()
313 // This writes the output from CreateDCSAliasMap to a CDB file
315 TMap* dcsAliasMap = CreateDCSAliasMap();
317 AliCDBMetaData metaData;
318 metaData.SetBeamPeriod(0);
319 metaData.SetResponsible("Chiara");
320 metaData.SetComment("Test object for TOFPreprocessor.C");
322 AliCDBId id("TOF/DCS/Data", 0, 0);
324 // initialize location of CDB
325 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
327 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);