]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/TOFPreprocessor.C
Split femto code into two libraries
[u/mrichter/AliRoot.git] / TOF / TOFPreprocessor.C
CommitLineData
ccc28861 1/*
2$Id$
3*/
4
5// This class runs the test TOF preprocessor
6// It uses AliTestShuttle to simulate a full Shuttle process
7
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
12
27a53fea 13extern TBenchmark *gBenchmark;
ccc28861 14void TOFPreprocessor()
15{
16 gSystem->Load("$ALICE/SHUTTLE/TestShuttle/libTestShuttle.so");
17
18 // initialize location of CDB
58f7f59a 19 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
20 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
21
ccc28861 22 // create AliTestShuttle instance
23 AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000);
24
25 // Generation of "fake" input DCS data
27a53fea 26 TMap* dcsAliasMap = CreateDCSAliasMap();
ccc28861 27
28 // now give the alias map to the shuttle
27a53fea 29 shuttle->SetDCSInput(dcsAliasMap);
ccc28861 30
31 // processing files. for the time being, the files are local.
5abdf772 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");
ccc28861 34
35 // instantiation of the preprocessor
124a2863 36 AliPreprocessor* pp = new AliTOFPreprocessor(shuttle);
ccc28861 37
38 // preprocessing
27a53fea 39 gBenchmark->Start("process");
ccc28861 40 shuttle->Process();
27a53fea 41 gBenchmark->Stop("process");
42 gBenchmark->Print("process");
ccc28861 43
44 // checking the file which should have been created
27a53fea 45 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
46 ->Get("TOF/Calib/OnlineDelay", 0);
47 if (!chkEntry)
ccc28861 48 {
49 printf("The file is not there. Something went wrong.\n");
50 return;
51 }
52
27a53fea 53 AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject());
ccc28861 54 // If everything went fine, draw the result
55 if (output)
56 output->Draw();
57
58}
59
60TMap* CreateDCSAliasMap()
61{
62 // Creates a DCS structure
63 // The structure is the following:
27a53fea 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
ccc28861 69
27a53fea 70 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
71 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
ccc28861 72
73 TMap* aliasMap = new TMap;
74 aliasMap->SetOwner(1);
75
76 TRandom random;
77 TDatime *datime = new TDatime();
78 Int_t time = datime->GetTime();
79 Int_t date = datime->GetDate();
80 Int_t pid = gSystem->GetPid();
81 delete datime;
82 Int_t iseed = TMath::Abs(10000 * pid + time - date);
83
27a53fea 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;
91
124a2863 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;
ccc28861 102
103 Float_t tent=0, sigma=0, thr=0;
124a2863 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;
ccc28861 105
106 for(int nAlias=0;nAlias<NAliases;nAlias++) {
107
108 TObjArray* valueSet = new TObjArray;
109 valueSet->SetOwner(1);
110
124a2863 111 TString sindex;
ccc28861 112 TString aliasName;
113 if (nAlias<NHV){
124a2863 114 aliasName = "tof_hv_vp_";
115 sindex.Form("%02i",nAlias);
116 aliasName += sindex;
117 //aliasName += nAlias;
ccc28861 118 tent=tentHVv;
119 sigma=sigmaHVv;
120 // thr=thrHVv;
121 }
122 else if (nAlias<NHV*2){
124a2863 123 // aliasName = "HVvneg";
124 //aliasName += nAlias-NHV;
125 aliasName = "tof_hv_vn_";
126 sindex.Form("%02i",nAlias-NHV);
127 aliasName += sindex;
ccc28861 128 tent=-tentHVv;
129 sigma=-sigmaHVv;
130 //thr=-thrHVv;
131 }
132 else if (nAlias<NHV*3){
124a2863 133 // aliasName = "HVcpos";
134 //aliasName += nAlias-2*NHV;
135 aliasName = "tof_hv_ip_";
136 sindex.Form("%02i",nAlias-2*NHV);
137 aliasName += sindex;
138 tent=tentHVi;
139 sigma=sigmaHVi;
ccc28861 140 //thr=thrHVc;
141 }
142 else if (nAlias<NHV*4){
124a2863 143 // aliasName = "HVcneg";
144 //aliasName += nAlias-3*NHV;
145 aliasName = "tof_hv_in_";
146 sindex.Form("%02i",nAlias-3*NHV);
147 aliasName += sindex;
148 tent=-tentHVi;
149 sigma=-sigmaHVi;
ccc28861 150 //thr=-thrHVc;
151 }
152 else if (nAlias<NHV*4+NLV){
124a2863 153 // aliasName = "LVv";
154 //aliasName += nAlias-4*NHV;
155 aliasName = "tof_lv_vfea_";
156 sindex.Form("%03i",nAlias-4*NHV);
157 aliasName += sindex;
ccc28861 158 tent=tentLVv;
159 sigma=sigmaLVv;
160 //thr=thrLVv;
161 }
162 else if (nAlias<NHV*4+2*NLV){
124a2863 163 // aliasName = "LVc";
164 //aliasName += nAlias-(4*NHV+NLV);
165 aliasName = "tof_lv_ifea_";
166 sindex.Form("%03i",nAlias-(4*NHV+NLV));
167 aliasName += sindex;
168 tent=tentLVi;
169 sigma=sigmaLVi;
ccc28861 170 //thr=thrLVc;
171 }
124a2863 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));
177 aliasName += sindex;
178 tent=tentLVv33;
179 sigma=sigmaLVv33;
180 //thr=thrLVc;
181 }
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));
187 aliasName += sindex;
188 tent=tentLVi33;
189 sigma=sigmaLVi33;
190 //thr=thrLVc;
191 }
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));
197 aliasName += sindex;
198 tent=tentLVv50;
199 sigma=sigmaLVv50;
200 //thr=thrLVc;
201 }
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));
207 aliasName += sindex;
208 tent=tentLVi50;
209 sigma=sigmaLVi50;
210 //thr=thrLVc;
211 }
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));
217 aliasName += sindex;
218 tent=tentLVv48;
219 sigma=sigmaLVv48;
220 //thr=thrLVc;
221 }
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));
227 aliasName += sindex;
228 tent=tentLVi48;
229 sigma=sigmaLVi48;
230 //thr=thrLVc;
231 }
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));
237 aliasName += sindex;
ccc28861 238 tent=tentFEEthr;
239 sigma=sigmaFEEthr;
240 //thr=thrFEEthr;
241 }
124a2863 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));
248 aliasName += sindex;
249 //cout << " nalias fee temp name = " << aliasName << endl;
250 tent=tentFEEtfeac;
251 sigma=sigmaFEEtfeac;
252 //thr=thrFEEthr;
253 }
254 else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm){
ccc28861 255 //cout << " nalias fee temp = " << nAlias << endl;
124a2863 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));
260 aliasName += sindex;
ccc28861 261 //cout << " nalias fee temp name = " << aliasName << endl;
124a2863 262 tent=tentFEEttrm;
263 sigma=sigmaFEEttrm;
ccc28861 264 //thr=thrFEEthr;
265 }
124a2863 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";
ccc28861 269 tent=tentTemp;
270 sigma=sigmaTemp;
271 //thr=thrTemp;
272 }
124a2863 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";
ccc28861 276 tent=tentPress;
277 sigma=sigmaPress;
278 //thr=thrPress;
279 }
280
281
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);
288 }
289 }
290
291 aliasMap->Add(new TObjString(aliasName), valueSet);
292 }
293
294 return aliasMap;
295}
296
297TMap* ReadDCSAliasMap()
298{
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()
304
305 AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0);
306 return dynamic_cast<TMap*> (entry->GetObject());
307}
308
309void WriteDCSAliasMap()
310{
311 // This writes the output from CreateDCSAliasMap to a CDB file
312
313 TMap* dcsAliasMap = CreateDCSAliasMap();
314
315 AliCDBMetaData metaData;
316 metaData.SetBeamPeriod(0);
317 metaData.SetResponsible("Chiara");
318 metaData.SetComment("Test object for TOFPreprocessor.C");
319
320 AliCDBId id("TOF/DCS/Data", 0, 0);
321
322 // initialize location of CDB
323 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
324
325 AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);
326}