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 void TOFPreprocessor()
15 gSystem->Load("$ALICE/SHUTTLE/TestShuttle/libTestShuttle.so");
17 // initialize location of CDB
18 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
20 // create AliTestShuttle instance
21 AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000);
23 // Generation of "fake" input DCS data
24 TMap* dcsAliasMap = CreateDCSAliasMap();
26 // now give the alias map to the shuttle
27 shuttle->SetDCSInput(dcsAliasMap);
29 // processing files. for the time being, the files are local.
30 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root");
31 shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root");
33 // instantiation of the preprocessor
34 AliPreprocessor* pp = new AliTOFPreprocessor(shuttle);
39 // checking the file which should have been created
40 AliCDBEntry* entry = AliCDBManager::Instance()->Get("TOF/Calib/OnlineDelay", 0);
43 printf("The file is not there. Something went wrong.\n");
47 AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (entry->GetObject());
48 // If everything went fine, draw the result
54 TMap* CreateDCSAliasMap()
56 // Creates a DCS structure
57 // The structure is the following:
58 // TMap (key --> value)
59 // <DCSAlias> --> <valueList>
60 // <DCSAlias> is a string
61 // <valueList> is a TObjArray of AliDCSValue
64 TMap* aliasMap = new TMap;
65 aliasMap->SetOwner(1);
68 TDatime *datime = new TDatime();
69 Int_t time = datime->GetTime();
70 Int_t date = datime->GetDate();
71 Int_t pid = gSystem->GetPid();
73 Int_t iseed = TMath::Abs(10000 * pid + time - date);
75 Float_t tentHVv=6500, tentHVi=80, tentLVv=2.7, tentLVi=4.5,
76 tentLVv33=3.3, tentLVv50=5.0, tentLVv48=48,
77 tentLVi33=100, tentLVi50=3.0, tentLVi48=10,
78 tentFEEthr=1.0, tentFEEtfeac=25, tentFEEttrm=45,
79 tentTemp=25, tentPress=900;
80 Float_t sigmaHVv=10, sigmaHVi=10, sigmaLVv=0.2, sigmaLVi=1.0,
81 sigmaLVv33=0.1, sigmaLVv50=0.1, sigmaLVv48=1,
82 sigmaLVi33=10, sigmaLVi50=0.5, sigmaLVi48=2,
83 sigmaFEEthr=0.1, sigmaFEEtfeac=10, sigmaFEEttrm=4,
84 sigmaTemp=1, sigmaPress=10;
86 Float_t tent=0, sigma=0, thr=0;
87 Int_t NAliases=10514, NHV=90, NLV=576, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576, NFEEttrm=6840, NT=1, NP=1;
89 for(int nAlias=0;nAlias<NAliases;nAlias++) {
91 TObjArray* valueSet = new TObjArray;
92 valueSet->SetOwner(1);
97 aliasName = "tof_hv_vp_";
98 sindex.Form("%02i",nAlias);
100 //aliasName += nAlias;
105 else if (nAlias<NHV*2){
106 // aliasName = "HVvneg";
107 //aliasName += nAlias-NHV;
108 aliasName = "tof_hv_vn_";
109 sindex.Form("%02i",nAlias-NHV);
115 else if (nAlias<NHV*3){
116 // aliasName = "HVcpos";
117 //aliasName += nAlias-2*NHV;
118 aliasName = "tof_hv_ip_";
119 sindex.Form("%02i",nAlias-2*NHV);
125 else if (nAlias<NHV*4){
126 // aliasName = "HVcneg";
127 //aliasName += nAlias-3*NHV;
128 aliasName = "tof_hv_in_";
129 sindex.Form("%02i",nAlias-3*NHV);
135 else if (nAlias<NHV*4+NLV){
136 // aliasName = "LVv";
137 //aliasName += nAlias-4*NHV;
138 aliasName = "tof_lv_vfea_";
139 sindex.Form("%03i",nAlias-4*NHV);
145 else if (nAlias<NHV*4+2*NLV){
146 // aliasName = "LVc";
147 //aliasName += nAlias-(4*NHV+NLV);
148 aliasName = "tof_lv_ifea_";
149 sindex.Form("%03i",nAlias-(4*NHV+NLV));
155 else if (nAlias<NHV*4+2*NLV+NLV33){
156 // aliasName = "LVc";
157 //aliasName += nAlias-(4*NHV+NLV);
158 aliasName = "tof_lv_v33_";
159 sindex.Form("%02i",nAlias-(4*NHV+2*NLV));
165 else if (nAlias<NHV*4+2*NLV+2*NLV33){
166 // aliasName = "LVc";
167 //aliasName += nAlias-(4*NHV+NLV);
168 aliasName = "tof_lv_i33_";
169 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+NLV33));
175 else if (nAlias<NHV*4+2*NLV+2*NLV33+NLV50){
176 // aliasName = "LVc";
177 //aliasName += nAlias-(4*NHV+NLV);
178 aliasName = "tof_lv_v50_";
179 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33));
185 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50){
186 // aliasName = "LVc";
187 //aliasName += nAlias-(4*NHV+NLV);
188 aliasName = "tof_lv_i50_";
189 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+NLV50));
195 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+NLV48){
196 // aliasName = "LVc";
197 //aliasName += nAlias-(4*NHV+NLV);
198 aliasName = "tof_lv_v48_";
199 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50));
205 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48){
206 // aliasName = "LVc";
207 //aliasName += nAlias-(4*NHV+NLV);
208 aliasName = "tof_lv_i48_";
209 sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+NLV48));
215 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr){
216 // aliasName = "FEEthr";
217 //aliasName += nAlias-(4*NHV+2*NLV-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
218 aliasName = "tof_fee_th_";
219 sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
225 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac){
226 //cout << " nalias fee temp = " << nAlias << endl;
227 // aliasName = "FEEt";
228 //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
229 aliasName = "tof_fee_tfeac_";
230 sindex.Form("%03i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr));
232 //cout << " nalias fee temp name = " << aliasName << endl;
237 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm){
238 //cout << " nalias fee temp = " << nAlias << endl;
239 // aliasName = "FEEt";
240 //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
241 aliasName = "tof_fee_ttrm_";
242 sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac));
244 //cout << " nalias fee temp name = " << aliasName << endl;
249 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm+1){
250 cout << " putting temperature" << endl;
251 aliasName = "temperature";
256 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm+2){
257 cout << " putting pressure" << endl;
258 aliasName = "pressure";
265 // gauss generation of values
266 for (int timeStamp=0;timeStamp<1000;timeStamp+=10){
267 Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
268 if (TMath::Abs(gaussvalue-tent)>sigma){
269 AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp);
270 valueSet->Add(dcsVal);
274 aliasMap->Add(new TObjString(aliasName), valueSet);
280 TMap* ReadDCSAliasMap()
282 // Open a file that contains DCS input data
283 // The CDB framework is used to open the file, this means the file is located
284 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
285 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
286 // An explanation of the structure can be found in CreateDCSAliasMap()
288 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0);
289 return dynamic_cast<TMap*> (entry->GetObject());
292 void WriteDCSAliasMap()
294 // This writes the output from CreateDCSAliasMap to a CDB file
296 TMap* dcsAliasMap = CreateDCSAliasMap();
298 AliCDBMetaData metaData;
299 metaData.SetBeamPeriod(0);
300 metaData.SetResponsible("Chiara");
301 metaData.SetComment("Test object for TOFPreprocessor.C");
303 AliCDBId id("TOF/DCS/Data", 0, 0);
305 // initialize location of CDB
306 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
308 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);