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_ROOT/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");
37 shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEE.20080310.164003.4001");
41 for (Int_t iLDC=0;iLDC<2;iLDC++){
42 sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutPulserLDC_%02i.root",iLDC*2);
43 sprintf(LDCname,"LDC%i",iLDC*2);
44 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "PULSER", LDCname, filename);
45 sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutNoiseLDC_%02i.root",iLDC*2);
46 sprintf(LDCname,"LDC%i",iLDC*2);
47 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "NOISE", LDCname, filename);
50 // instantiation of the preprocessor
51 AliPreprocessor* pp = new AliTOFPreprocessor(shuttle);
54 gBenchmark->Start("process");
56 gBenchmark->Stop("process");
57 gBenchmark->Print("process");
59 // checking the file which should have been created
60 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/ParOnline", 0);
63 printf("The file is not there. Something went wrong.\n");
67 AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject());
68 // If everything went fine, draw the result
70 printf("Output found.\n");
75 TMap* CreateDCSAliasMap()
77 // Creates a DCS structure
78 // The structure is the following:
79 // TMap (key --> value)
80 // <DCSAlias> --> <valueList>
81 // <DCSAlias> is a string
82 // <valueList> is a TObjArray of AliDCSValue
83 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
85 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
86 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
88 TMap* aliasMap = new TMap;
89 aliasMap->SetOwner(1);
92 TDatime *datime = new TDatime();
93 Int_t time = datime->GetTime();
94 Int_t date = datime->GetDate();
95 Int_t pid = gSystem->GetPid();
97 Int_t iseed = TMath::Abs(10000 * pid + time - date);
99 //Float_t thrHVv=7.75, thrHVc=3, thrLVv=2.75, thrLVc=2.5,
100 //thrFEEthr=1.5, thrFEEt=10, thrTemp=35, thrPress=1000;
101 //Float_t tentHVv=6.75, tentHVc=2, tentLVv=1.75, tentLVc=1.5,
102 // tentFEEthr=0.5, te result=0;
103 //ntFEEt=20, tentTemp=25, tentPress=900;
104 //Float_t sigmaHVv=1, sigmaHVc=0.25, sigmaLVv=0.25, sigmaLVc=0.25,
105 // sigmaFEEthr=0.05, sigmaFEEt=5, sigmaTemp=1, sigmaPress=10;
107 Float_t tentHVv=6500, tentHVi=80, tentLVv=2.7, tentLVi=4.5,
108 tentLVv33=3.3, tentLVv50=5.0, tentLVv48=48,
109 tentLVi33=100, tentLVi50=3.0, tentLVi48=10,
110 tentFEEthr=1.0, tentFEEtfeac=25, tentFEEttrm=45;
111 Float_t sigmaHVv=10, sigmaHVi=10, sigmaLVv=0.2, sigmaLVi=1.0,
112 sigmaLVv33=0.1, sigmaLVv50=0.1, sigmaLVv48=1,
113 sigmaLVi33=10, sigmaLVi50=0.5, sigmaLVi48=2,
114 sigmaFEEthr=0.1, sigmaFEEtfeac=10, sigmaFEEttrm=4;
116 Float_t tent=0, sigma=0, thr=0;
117 // to have all the aliases, deccoment the following line:
118 // Int_t NAliases=10944, NHV=90, NLV=792, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576, NFEEttrm=6840;
120 // if not all the aliases are there, use this:
121 Int_t NAliases=4104, NHV=90, NLV=792, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576;
123 for(int nAlias=0;nAlias<NAliases;nAlias++) {
125 TObjArray* valueSet = new TObjArray;
126 valueSet->SetOwner(1);
131 aliasName = "tof_hv_vp_";
132 sindex.Form("%02i",nAlias);
134 //aliasName += nAlias;
139 else if (nAlias<NHV*2){
140 // aliasName = "HVvneg";
141 //aliasName += nAlias-NHV;
142 aliasName = "tof_hv_vn_";
143 sindex.Form("%02i",nAlias-NHV);
149 else if (nAlias<NHV*3){
150 // aliasName = "HVcpos";
151 //aliasName += nAlias-2*NHV;
152 aliasName = "tof_hv_ip_";
153 sindex.Form("%02i",nAlias-2*NHV);
159 else if (nAlias<NHV*4){
160 // aliasName = "HVcneg";
161 //aliasName += nAlias-3*NHV;
162 aliasName = "tof_hv_in_";
163 sindex.Form("%02i",nAlias-3*NHV);
169 else if (nAlias<NHV*4+NLV){
170 // aliasName = "LVv";
171 //aliasName += nAlias-4*NHV;
172 aliasName = "tof_lv_vfea_";
173 sindex.Form("%03i",nAlias-4*NHV);
179 else if (nAlias<NHV*4+2*NLV){
180 // aliasName = "LVc";
181 //aliasName += nAlias-(4*NHV+NLV);
182 aliasName = "tof_lv_ifea_";
183 sindex.Form("%03i",nAlias-(4*NHV+NLV));
189 else if (nAlias<NHV*4+2*NLV+NLV33){
190 // aliasName = "LVc";
191 //aliasName += nAlias-(4*NHV+NLV);
192 aliasName = "tof_lv_v33_";
193 sindex.Form("%02i",nAlias-(4*NHV+2*NLV));
199 else if (nAlias<NHV*4+2*NLV+2*NLV33){
200 // aliasName = "LVc";
201 //aliasName += nAlias-(4*NHV+NLV);
202 aliasName = "tof_lv_i33_";
203 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+NLV33));
209 else if (nAlias<NHV*4+2*NLV+2*NLV33+NLV50){
210 // aliasName = "LVc";
211 //aliasName += nAlias-(4*NHV+NLV);
212 aliasName = "tof_lv_v50_";
213 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33));
219 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50){
220 // aliasName = "LVc";
221 //aliasName += nAlias-(4*NHV+NLV);
222 aliasName = "tof_lv_i50_";
223 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+NLV50));
229 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+NLV48){
230 // aliasName = "LVc";
231 //aliasName += nAlias-(4*NHV+NLV);
232 aliasName = "tof_lv_v48_";
233 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50));
239 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48){
240 // aliasName = "LVc";
241 //aliasName += nAlias-(4*NHV+NLV);
242 aliasName = "tof_lv_i48_";
243 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+NLV48));
249 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr){
250 // aliasName = "FEEthr";
251 //aliasName += nAlias-(4*NHV+2*NLV-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
252 aliasName = "tof_fee_th_";
253 sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
259 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac){
260 //cout << " nalias fee temp = " << nAlias << endl;
261 // aliasName = "FEEt";
262 //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
263 aliasName = "tof_fee_tfeac_";
264 sindex.Form("%03i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr));
266 //cout << " nalias fee temp name = " << aliasName << endl;
272 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm){
273 //cout << " nalias fee temp = " << nAlias << endl;
274 // aliasName = "FEEt";
275 //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
276 aliasName = "tof_fee_ttrm_";
277 sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac));
279 //cout << " nalias fee temp name = " << aliasName << endl;
285 // gauss generation of values
286 for (int timeStamp=0;timeStamp<1000;timeStamp+=10){
287 //for (int timeStamp=0;timeStamp<1;timeStamp++){
288 Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
289 if (TMath::Abs(gaussvalue-tent)>sigma){
290 AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp);
291 valueSet->Add(dcsVal);
295 aliasMap->Add(new TObjString(aliasName), valueSet);
301 TMap* ReadDCSAliasMap()
303 // Open a file that contains DCS input data
304 // The CDB framework is used to open the file, this means the file is located
305 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
306 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
307 // An explanation of the structure can be found in CreateDCSAliasMap()
309 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0);
310 return dynamic_cast<TMap*> (entry->GetObject());
313 void WriteDCSAliasMap()
315 // This writes the output from CreateDCSAliasMap to a CDB file
317 TMap* dcsAliasMap = CreateDCSAliasMap();
319 AliCDBMetaData metaData;
320 metaData.SetBeamPeriod(0);
321 metaData.SetResponsible("Chiara");
322 metaData.SetComment("Test object for TOFPreprocessor.C");
324 AliCDBId id("TOF/DCS/Data", 0, 0);
326 // initialize location of CDB
327 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
329 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);