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
56 printf("Output found.\n");
61 TMap* CreateDCSAliasMap()
63 // Creates a DCS structure
64 // The structure is the following:
65 // TMap (key --> value)
66 // <DCSAlias> --> <valueList>
67 // <DCSAlias> is a string
68 // <valueList> is a TObjArray of AliDCSValue
69 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
71 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
72 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
74 TMap* aliasMap = new TMap;
75 aliasMap->SetOwner(1);
78 TDatime *datime = new TDatime();
79 Int_t time = datime->GetTime();
80 Int_t date = datime->GetDate();
81 Int_t pid = gSystem->GetPid();
83 Int_t iseed = TMath::Abs(10000 * pid + time - date);
85 //Float_t thrHVv=7.75, thrHVc=3, thrLVv=2.75, thrLVc=2.5,
86 //thrFEEthr=1.5, thrFEEt=10, thrTemp=35, thrPress=1000;
87 //Float_t tentHVv=6.75, tentHVc=2, tentLVv=1.75, tentLVc=1.5,
88 // tentFEEthr=0.5, te result=0;
89 //ntFEEt=20, tentTemp=25, tentPress=900;
90 //Float_t sigmaHVv=1, sigmaHVc=0.25, sigmaLVv=0.25, sigmaLVc=0.25,
91 // sigmaFEEthr=0.05, sigmaFEEt=5, sigmaTemp=1, sigmaPress=10;
93 Float_t tentHVv=6500, tentHVi=80, tentLVv=2.7, tentLVi=4.5,
94 tentLVv33=3.3, tentLVv50=5.0, tentLVv48=48,
95 tentLVi33=100, tentLVi50=3.0, tentLVi48=10,
96 tentFEEthr=1.0, tentFEEtfeac=25, tentFEEttrm=45;
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;
102 Float_t tent=0, sigma=0, thr=0;
103 Int_t NAliases=10514, NHV=90, NLV=576, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576, NFEEttrm=6840, NT=1, NP=1;
105 for(int nAlias=0;nAlias<NAliases;nAlias++) {
107 TObjArray* valueSet = new TObjArray;
108 valueSet->SetOwner(1);
113 aliasName = "tof_hv_vp_";
114 sindex.Form("%02i",nAlias);
116 //aliasName += nAlias;
121 else if (nAlias<NHV*2){
122 // aliasName = "HVvneg";
123 //aliasName += nAlias-NHV;
124 aliasName = "tof_hv_vn_";
125 sindex.Form("%02i",nAlias-NHV);
131 else if (nAlias<NHV*3){
132 // aliasName = "HVcpos";
133 //aliasName += nAlias-2*NHV;
134 aliasName = "tof_hv_ip_";
135 sindex.Form("%02i",nAlias-2*NHV);
141 else if (nAlias<NHV*4){
142 // aliasName = "HVcneg";
143 //aliasName += nAlias-3*NHV;
144 aliasName = "tof_hv_in_";
145 sindex.Form("%02i",nAlias-3*NHV);
151 else if (nAlias<NHV*4+NLV){
152 // aliasName = "LVv";
153 //aliasName += nAlias-4*NHV;
154 aliasName = "tof_lv_vfea_";
155 sindex.Form("%03i",nAlias-4*NHV);
161 else if (nAlias<NHV*4+2*NLV){
162 // aliasName = "LVc";
163 //aliasName += nAlias-(4*NHV+NLV);
164 aliasName = "tof_lv_ifea_";
165 sindex.Form("%03i",nAlias-(4*NHV+NLV));
171 else if (nAlias<NHV*4+2*NLV+NLV33){
172 // aliasName = "LVc";
173 //aliasName += nAlias-(4*NHV+NLV);
174 aliasName = "tof_lv_v33_";
175 sindex.Form("%02i",nAlias-(4*NHV+2*NLV));
181 else if (nAlias<NHV*4+2*NLV+2*NLV33){
182 // aliasName = "LVc";
183 //aliasName += nAlias-(4*NHV+NLV);
184 aliasName = "tof_lv_i33_";
185 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+NLV33));
191 else if (nAlias<NHV*4+2*NLV+2*NLV33+NLV50){
192 // aliasName = "LVc";
193 //aliasName += nAlias-(4*NHV+NLV);
194 aliasName = "tof_lv_v50_";
195 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33));
201 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50){
202 // aliasName = "LVc";
203 //aliasName += nAlias-(4*NHV+NLV);
204 aliasName = "tof_lv_i50_";
205 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+NLV50));
211 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+NLV48){
212 // aliasName = "LVc";
213 //aliasName += nAlias-(4*NHV+NLV);
214 aliasName = "tof_lv_v48_";
215 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50));
221 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48){
222 // aliasName = "LVc";
223 //aliasName += nAlias-(4*NHV+NLV);
224 aliasName = "tof_lv_i48_";
225 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+NLV48));
231 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr){
232 // aliasName = "FEEthr";
233 //aliasName += nAlias-(4*NHV+2*NLV-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
234 aliasName = "tof_fee_th_";
235 sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
241 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac){
242 //cout << " nalias fee temp = " << nAlias << endl;
243 // aliasName = "FEEt";
244 //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
245 aliasName = "tof_fee_tfeac_";
246 sindex.Form("%03i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr));
248 //cout << " nalias fee temp name = " << aliasName << endl;
253 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm){
254 //cout << " nalias fee temp = " << nAlias << endl;
255 // aliasName = "FEEt";
256 //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
257 aliasName = "tof_fee_ttrm_";
258 sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac));
260 //cout << " nalias fee temp name = " << aliasName << endl;
266 // gauss generation of values
267 for (int timeStamp=0;timeStamp<1000;timeStamp+=10){
268 Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
269 if (TMath::Abs(gaussvalue-tent)>sigma){
270 AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp);
271 valueSet->Add(dcsVal);
275 aliasMap->Add(new TObjString(aliasName), valueSet);
281 TMap* ReadDCSAliasMap()
283 // Open a file that contains DCS input data
284 // The CDB framework is used to open the file, this means the file is located
285 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
286 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
287 // An explanation of the structure can be found in CreateDCSAliasMap()
289 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0);
290 return dynamic_cast<TMap*> (entry->GetObject());
293 void WriteDCSAliasMap()
295 // This writes the output from CreateDCSAliasMap to a CDB file
297 TMap* dcsAliasMap = CreateDCSAliasMap();
299 AliCDBMetaData metaData;
300 metaData.SetBeamPeriod(0);
301 metaData.SetResponsible("Chiara");
302 metaData.SetComment("Test object for TOFPreprocessor.C");
304 AliCDBId id("TOF/DCS/Data", 0, 0);
306 // initialize location of CDB
307 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
309 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);