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 // initialize location of CDB
19 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
20 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
22 // create AliTestShuttle instance
23 AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000);
25 // Generation of "fake" input DCS data
26 TMap* dcsAliasMap = CreateDCSAliasMap();
28 // now give the alias map to the shuttle
29 shuttle->SetDCSInput(dcsAliasMap);
31 // processing files. for the time being, the files are local.
32 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root");
33 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root");
35 // instantiation of the preprocessor
36 AliPreprocessor* pp = new AliTOFPreprocessor(shuttle);
39 gBenchmark->Start("process");
41 gBenchmark->Stop("process");
42 gBenchmark->Print("process");
44 // checking the file which should have been created
45 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
46 ->Get("TOF/Calib/OnlineDelay", 0);
49 printf("The file is not there. Something went wrong.\n");
53 AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject());
54 // If everything went fine, draw the result
60 TMap* CreateDCSAliasMap()
62 // Creates a DCS structure
63 // The structure is the following:
64 // TMap (key --> value)
65 // <DCSAlias> --> <valueList>
66 // <DCSAlias> is a string
67 // <valueList> is a TObjArray of AliDCSValue
68 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
70 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
71 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
73 TMap* aliasMap = new TMap;
74 aliasMap->SetOwner(1);
77 TDatime *datime = new TDatime();
78 Int_t time = datime->GetTime();
79 Int_t date = datime->GetDate();
80 Int_t pid = gSystem->GetPid();
82 Int_t iseed = TMath::Abs(10000 * pid + time - date);
84 //Float_t thrHVv=7.75, thrHVc=3, thrLVv=2.75, thrLVc=2.5,
85 //thrFEEthr=1.5, thrFEEt=10, thrTemp=35, thrPress=1000;
86 //Float_t tentHVv=6.75, tentHVc=2, tentLVv=1.75, tentLVc=1.5,
87 // tentFEEthr=0.5, te result=0;
88 //ntFEEt=20, tentTemp=25, tentPress=900;
89 //Float_t sigmaHVv=1, sigmaHVc=0.25, sigmaLVv=0.25, sigmaLVc=0.25,
90 // sigmaFEEthr=0.05, sigmaFEEt=5, sigmaTemp=1, sigmaPress=10;
92 Float_t tentHVv=6500, tentHVi=80, tentLVv=2.7, tentLVi=4.5,
93 tentLVv33=3.3, tentLVv50=5.0, tentLVv48=48,
94 tentLVi33=100, tentLVi50=3.0, tentLVi48=10,
95 tentFEEthr=1.0, tentFEEtfeac=25, tentFEEttrm=45,
96 tentTemp=25, tentPress=900;
97 Float_t sigmaHVv=10, sigmaHVi=10, sigmaLVv=0.2, sigmaLVi=1.0,
98 sigmaLVv33=0.1, sigmaLVv50=0.1, sigmaLVv48=1,
99 sigmaLVi33=10, sigmaLVi50=0.5, sigmaLVi48=2,
100 sigmaFEEthr=0.1, sigmaFEEtfeac=10, sigmaFEEttrm=4,
101 sigmaTemp=1, sigmaPress=10;
103 Float_t tent=0, sigma=0, thr=0;
104 Int_t NAliases=10514, NHV=90, NLV=576, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576, NFEEttrm=6840, NT=1, NP=1;
106 for(int nAlias=0;nAlias<NAliases;nAlias++) {
108 TObjArray* valueSet = new TObjArray;
109 valueSet->SetOwner(1);
114 aliasName = "tof_hv_vp_";
115 sindex.Form("%02i",nAlias);
117 //aliasName += nAlias;
122 else if (nAlias<NHV*2){
123 // aliasName = "HVvneg";
124 //aliasName += nAlias-NHV;
125 aliasName = "tof_hv_vn_";
126 sindex.Form("%02i",nAlias-NHV);
132 else if (nAlias<NHV*3){
133 // aliasName = "HVcpos";
134 //aliasName += nAlias-2*NHV;
135 aliasName = "tof_hv_ip_";
136 sindex.Form("%02i",nAlias-2*NHV);
142 else if (nAlias<NHV*4){
143 // aliasName = "HVcneg";
144 //aliasName += nAlias-3*NHV;
145 aliasName = "tof_hv_in_";
146 sindex.Form("%02i",nAlias-3*NHV);
152 else if (nAlias<NHV*4+NLV){
153 // aliasName = "LVv";
154 //aliasName += nAlias-4*NHV;
155 aliasName = "tof_lv_vfea_";
156 sindex.Form("%03i",nAlias-4*NHV);
162 else if (nAlias<NHV*4+2*NLV){
163 // aliasName = "LVc";
164 //aliasName += nAlias-(4*NHV+NLV);
165 aliasName = "tof_lv_ifea_";
166 sindex.Form("%03i",nAlias-(4*NHV+NLV));
172 else if (nAlias<NHV*4+2*NLV+NLV33){
173 // aliasName = "LVc";
174 //aliasName += nAlias-(4*NHV+NLV);
175 aliasName = "tof_lv_v33_";
176 sindex.Form("%02i",nAlias-(4*NHV+2*NLV));
182 else if (nAlias<NHV*4+2*NLV+2*NLV33){
183 // aliasName = "LVc";
184 //aliasName += nAlias-(4*NHV+NLV);
185 aliasName = "tof_lv_i33_";
186 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+NLV33));
192 else if (nAlias<NHV*4+2*NLV+2*NLV33+NLV50){
193 // aliasName = "LVc";
194 //aliasName += nAlias-(4*NHV+NLV);
195 aliasName = "tof_lv_v50_";
196 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33));
202 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50){
203 // aliasName = "LVc";
204 //aliasName += nAlias-(4*NHV+NLV);
205 aliasName = "tof_lv_i50_";
206 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+NLV50));
212 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+NLV48){
213 // aliasName = "LVc";
214 //aliasName += nAlias-(4*NHV+NLV);
215 aliasName = "tof_lv_v48_";
216 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50));
222 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48){
223 // aliasName = "LVc";
224 //aliasName += nAlias-(4*NHV+NLV);
225 aliasName = "tof_lv_i48_";
226 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+NLV48));
232 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr){
233 // aliasName = "FEEthr";
234 //aliasName += nAlias-(4*NHV+2*NLV-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
235 aliasName = "tof_fee_th_";
236 sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
242 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac){
243 //cout << " nalias fee temp = " << nAlias << endl;
244 // aliasName = "FEEt";
245 //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
246 aliasName = "tof_fee_tfeac_";
247 sindex.Form("%03i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr));
249 //cout << " nalias fee temp name = " << aliasName << endl;
254 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm){
255 //cout << " nalias fee temp = " << nAlias << endl;
256 // aliasName = "FEEt";
257 //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
258 aliasName = "tof_fee_ttrm_";
259 sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac));
261 //cout << " nalias fee temp name = " << aliasName << endl;
266 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm+1){
267 cout << " putting temperature" << endl;
268 aliasName = "temperature";
273 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm+2){
274 cout << " putting pressure" << endl;
275 aliasName = "pressure";
282 // gauss generation of values
283 for (int timeStamp=0;timeStamp<1000;timeStamp+=10){
284 Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
285 if (TMath::Abs(gaussvalue-tent)>sigma){
286 AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp);
287 valueSet->Add(dcsVal);
291 aliasMap->Add(new TObjString(aliasName), valueSet);
297 TMap* ReadDCSAliasMap()
299 // Open a file that contains DCS input data
300 // The CDB framework is used to open the file, this means the file is located
301 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
302 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
303 // An explanation of the structure can be found in CreateDCSAliasMap()
305 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0);
306 return dynamic_cast<TMap*> (entry->GetObject());
309 void WriteDCSAliasMap()
311 // This writes the output from CreateDCSAliasMap to a CDB file
313 TMap* dcsAliasMap = CreateDCSAliasMap();
315 AliCDBMetaData metaData;
316 metaData.SetBeamPeriod(0);
317 metaData.SetResponsible("Chiara");
318 metaData.SetComment("Test object for TOFPreprocessor.C");
320 AliCDBId id("TOF/DCS/Data", 0, 0);
322 // initialize location of CDB
323 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
325 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);