]>
Commit | Line | Data |
---|---|---|
dc928fbf | 1 | /* |
18ec51a0 | 2 | Contact: Jean-Luc Charvet <jean-luc.charvet@cern.ch> |
f3cfa63e | 3 | Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_mchda.html |
18ec51a0 | 4 | Reference Run: 109302 (station 3 only) |
f3cfa63e | 5 | Run Type: PEDESTAL |
6 | DA Type: LDC | |
7 | Number of events needed: 400 events for pedestal run | |
18ec51a0 | 8 | Input Files: mutrkpedvalues and config_ldc-MTRK-S3-0 in path : /afs/cern.ch/user/j/jcharvet/public/DA_validation |
f3cfa63e | 9 | Output Files: local dir (not persistent) -> MUONTRKPEDda.ped FXS -> run<#>_MCH_<ldc>_PEDESTALS |
10 | Trigger types used: | |
dc928fbf | 11 | */ |
12 | ||
13 | /************************************************************************** | |
14 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
15 | * * | |
16 | * Author: The ALICE Off-line Project. * | |
17 | * Contributors are mentioned in the code where appropriate. * | |
18 | * * | |
19 | * Permission to use, copy, modify and distribute this software and its * | |
20 | * documentation strictly for non-commercial purposes is hereby granted * | |
21 | * without fee, provided that the above copyright notice appears in all * | |
22 | * copies and that both the copyright notice and this permission notice * | |
23 | * appear in the supporting documentation. The authors make no claims * | |
24 | * about the suitability of this software for any purpose. It is * | |
25 | * provided "as is" without express or implied warranty. * | |
26 | **************************************************************************/ | |
27 | ||
28 | /* $Id$ */ | |
29 | ||
30 | /* | |
31 | ------------------------------------------------------------------------- | |
493c5a63 | 32 | 2012-11-23 New version: MUONTRKPEDda.cxx,v 1.9 |
dc928fbf | 33 | ------------------------------------------------------------------------- |
34 | ||
35 | Version for MUONTRKPEDda MUON tracking | |
36 | (A. Baldisseri, J.-L. Charvet) | |
37 | ||
38 | ||
39 | Rem: AliMUON2DMap stores all channels, even those which are not connected | |
40 | if pedMean == -1, channel not connected to a pad | |
41 | ||
1b15b395 | 42 | & |
dc928fbf | 43 | |
44 | */ | |
45 | extern "C" { | |
46 | #include <daqDA.h> | |
47 | } | |
48 | ||
49 | #include "event.h" | |
50 | #include "monitor.h" | |
51 | ||
52 | #include <Riostream.h> | |
53 | #include <stdio.h> | |
54 | #include <stdlib.h> | |
55 | #include <sstream> | |
56 | #include <math.h> | |
57 | ||
58 | //AliRoot | |
59 | #include "AliMUONRawStreamTrackerHP.h" | |
60 | #include "AliRawReader.h" | |
61 | #include "AliMUONVStore.h" | |
62 | #include "AliMUON2DMap.h" | |
63 | #include "AliMUONCalibParamND.h" | |
64 | #include "AliMpIntPair.h" | |
65 | #include "AliMpConstants.h" | |
66 | #include "AliRawDataErrorLog.h" | |
67 | #include "AliMUONTrackerIO.h" | |
18ec51a0 | 68 | #include "AliLog.h" |
f9e83f1d | 69 | #include "AliMUONDspHeader.h" |
70 | #include "AliDAQ.h" | |
dc928fbf | 71 | |
72 | //ROOT | |
73 | #include "TFile.h" | |
74 | #include "TSystem.h" | |
75 | #include "TTree.h" | |
76 | #include "TH1F.h" | |
77 | #include "TString.h" | |
78 | #include "TStopwatch.h" | |
79 | #include "TMath.h" | |
80 | #include "TTimeStamp.h" | |
81 | #include "TGraphErrors.h" | |
82 | #include "TF1.h" | |
83 | #include "TROOT.h" | |
84 | #include "TPluginManager.h" | |
85 | #include "TFitter.h" | |
86 | #include "TObjString.h" | |
87 | #include "THashTable.h" | |
88 | #include <THashList.h> | |
dbbb2c64 | 89 | // |
90 | //AMORE | |
91 | // | |
92 | #ifdef ALI_AMORE | |
93 | #include <AmoreDA.h> | |
94 | #endif | |
dc928fbf | 95 | |
96 | #include "AliMUONPedestal.h" | |
97 | #include "AliMUONErrorCounter.h" | |
98 | ||
18ec51a0 | 99 | |
dc928fbf | 100 | // main routine |
f3cfa63e | 101 | int main(Int_t argc, const char **argv) |
dc928fbf | 102 | { |
9c2d4e89 | 103 | Int_t status=0, status1=0; |
dc928fbf | 104 | TStopwatch timers; |
105 | timers.Start(kTRUE); | |
106 | ||
9c2d4e89 | 107 | // Needed for streamer application |
dc928fbf | 108 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", |
109 | "*", | |
110 | "TStreamerInfo", | |
111 | "RIO", | |
112 | "TStreamerInfo()"); | |
dc928fbf | 113 | // needed for Minuit plugin |
114 | gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", | |
115 | "Minuit", | |
116 | "TMinuitMinimizer", | |
117 | "Minuit", | |
118 | "TMinuitMinimizer(const char*)"); | |
dc928fbf | 119 | // cout << argv[0]; |
120 | ||
121 | Int_t skipEvents = 0; | |
122 | Int_t maxEvents = 1000000; | |
123 | Int_t maxDateEvents = 1000000; | |
9c2d4e89 | 124 | Int_t errorDetail = 1; |
125 | Int_t checkTokenlost = 0; | |
126 | Int_t flag_histo=1; | |
f3cfa63e | 127 | TString inputFile; |
dc928fbf | 128 | |
129 | Int_t nDateEvents = 0; | |
9c2d4e89 | 130 | Int_t nDateRejEvents = 0; |
dc928fbf | 131 | Int_t nGlitchErrors= 0; |
132 | Int_t nParityErrors= 0; | |
133 | Int_t nPaddingErrors= 0; | |
18ec51a0 | 134 | Int_t nTokenlostErrors= 0; |
dc928fbf | 135 | Int_t recoverParityErrors = 1; |
136 | ||
137 | TString logOutputFile; | |
138 | ||
139 | Char_t flatFile[256]=""; | |
9c2d4e89 | 140 | Char_t* detail; |
dc928fbf | 141 | TString shuttleFile; |
142 | ||
143 | Int_t nEventsRecovered = 0; | |
144 | Int_t nEvents = 0; | |
145 | UInt_t runNumber = 0; | |
f9e83f1d | 146 | Int_t nConfig = 1; |
ff496840 | 147 | Int_t nEvthreshold = 100; //below this nb_evt pedestal are not calculated and forced to 4085 (sigma) |
9c2d4e89 | 148 | Int_t nSorting = 1 ; // pedestal sorting (ON by default) |
149 | Int_t statusDA = 0 ; // DA return code | |
dc928fbf | 150 | ofstream filcout; |
dc928fbf | 151 | |
152 | // decode the input line | |
153 | for (Int_t i = 1; i < argc; i++) // argument 0 is the executable name | |
154 | { | |
f3cfa63e | 155 | const char* arg = argv[i]; |
dc928fbf | 156 | |
157 | arg = argv[i]; | |
158 | if (arg[0] != '-') | |
159 | { | |
160 | // If only one argument and no "-" => DA calling from ECS | |
161 | if (argc == 2) | |
162 | { | |
f3cfa63e | 163 | inputFile=argv[i]; |
dc928fbf | 164 | } |
165 | continue; | |
166 | } | |
9c2d4e89 | 167 | nConfig=0; |
168 | //prefixLDC = "LDC" | |
dc928fbf | 169 | switch (arg[1]) |
170 | { | |
171 | case 'f' : | |
172 | i++; | |
f3cfa63e | 173 | inputFile=argv[i]; |
174 | nConfig=0; | |
dc928fbf | 175 | break; |
176 | case 'a' : | |
177 | i++; | |
178 | shuttleFile = argv[i]; | |
179 | break; | |
180 | case 's' : | |
181 | i++; | |
182 | skipEvents=atoi(argv[i]); | |
183 | break; | |
184 | case 'm' : | |
185 | i++; | |
186 | sscanf(argv[i],"%d",&maxDateEvents); | |
187 | break; | |
188 | case 'n' : | |
189 | i++; | |
190 | sscanf(argv[i],"%d",&maxEvents); | |
191 | break; | |
9c2d4e89 | 192 | case 'v' : |
193 | i++; | |
194 | sscanf(argv[i],"%d",&errorDetail); | |
195 | break; | |
196 | case 't' : | |
197 | i++; | |
198 | sscanf(argv[i],"%d",&checkTokenlost); | |
199 | break; | |
dc928fbf | 200 | case 'h' : |
201 | i++; | |
202 | printf("\n******************* %s usage **********************",argv[0]); | |
203 | printf("\nOnline (called from ECS) : %s <raw data file> (no inline options)\n",argv[0]); | |
9c2d4e89 | 204 | printf("\n%s can be used locally only with options (without DiMuon configuration file: nConfig=%d)",argv[0],nConfig); |
dc928fbf | 205 | printf("\n%s -options, the available options are :",argv[0]); |
206 | printf("\n-h help (this screen)"); | |
207 | printf("\n"); | |
208 | printf("\n Input"); | |
f3cfa63e | 209 | printf("\n-f <raw data file> (default = %s)",inputFile.Data()); |
dc928fbf | 210 | printf("\n"); |
211 | printf("\n Output"); | |
212 | printf("\n-a <Flat ASCII file> (default = %s)",shuttleFile.Data()); | |
213 | printf("\n"); | |
214 | printf("\n Options"); | |
215 | printf("\n-m <max date events> (default = %d)",maxDateEvents); | |
216 | printf("\n-s <skip events> (default = %d)",skipEvents); | |
217 | printf("\n-n <max events> (default = %d)",maxEvents); | |
9c2d4e89 | 218 | printf("\n-v <error detail> (default = %d : 0=low 1=medium 2=high)",errorDetail); |
219 | printf("\n-t <token lost check> (default = %d : 0=no , 1=yes)",checkTokenlost); | |
dc928fbf | 220 | |
221 | printf("\n\n"); | |
222 | exit(-1); | |
223 | default : | |
224 | printf("%s : bad argument %s (please check %s -h)\n",argv[0],argv[i],argv[0]); | |
225 | argc = 2; exit(-1); // exit if error | |
226 | } // end of switch | |
227 | } // end of for i | |
228 | ||
dc928fbf | 229 | UShort_t manuId; |
230 | UChar_t channelId; | |
231 | UShort_t charge; | |
232 | ||
9c2d4e89 | 233 | const char* prefixDA = "MUONTRKPEDda"; // program prefix |
234 | const char* prefixLDC = getenv("DATE_ROLE_NAME"); // LDC name | |
235 | if(prefixLDC == NULL) prefixLDC ="MCH" ; | |
236 | printf("%s : -------- Begin execution : %s -------- \n",prefixLDC,prefixDA); | |
237 | ||
dc928fbf | 238 | //Pedestal object |
239 | AliMUONPedestal* muonPedestal = new AliMUONPedestal(); | |
240 | muonPedestal->SetprefixDA(prefixDA); | |
9c2d4e89 | 241 | muonPedestal->SetprefixLDC(prefixLDC); |
242 | muonPedestal->SetStatusDA(statusDA); | |
243 | ||
244 | // Output log file initialisations | |
245 | sprintf(flatFile,"%s.log",prefixDA); | |
246 | logOutputFile=flatFile; | |
247 | AliLog::SetStreamOutput(&filcout); // Print details on logfile | |
248 | filcout.open(logOutputFile.Data()); | |
249 | filcout<<"//=================================================" << endl; | |
250 | filcout<<"//" << prefixLDC << " " << prefixDA << endl; | |
251 | filcout<<"//=================================================" << endl; | |
252 | filcout<<"// * Date : " << muonPedestal->GetDate()->AsString("l") << "\n" << endl; | |
253 | ||
254 | muonPedestal->SetAlifilcout(&filcout); | |
255 | cout<<prefixLDC << " : Date: " << muonPedestal->GetDate()->AsString("l") << "\n" << endl; | |
256 | ||
dc928fbf | 257 | |
f3cfa63e | 258 | Char_t dbfile[256]=""; |
259 | // nConfig=1 : Reading configuration (or not) status via "mutrkpedvalues" file located in DetDB | |
260 | if(nConfig) | |
261 | { | |
9c2d4e89 | 262 | Int_t flag_hist, nEvthres,maxEvts; |
263 | char line[80]; | |
1ccd531d | 264 | sprintf(dbfile,"mutrkpedvalues"); |
265 | status=daqDA_DB_getFile(dbfile,dbfile); | |
266 | if(status) {printf(" !!! Failed : input file %s is missing, status = %d\n",dbfile,status); return -1; } | |
267 | ifstream filein(dbfile,ios::in); | |
160f3a71 | 268 | filein >> line >> nConfig ; cout << "mutrkpedvalues: " << line << nConfig << " " ; |
269 | filein >> line >> nEvthres ; if(nEvthres !=0)nEvthreshold=nEvthres; cout << line << nEvthreshold << " " ; | |
270 | filein >> line >> checkTokenlost ; cout << line << checkTokenlost << " " ; | |
493c5a63 | 271 | filein >> line >> flag_histo ; cout << line << flag_histo << " " ; // =0 , 1-> standard , 2-> ntuple charge |
160f3a71 | 272 | filein >> line >> maxEvts ; if(maxEvts!=0){maxEvents=maxEvts; cout << line << maxEvents;} |
273 | // filein >> line >> errorDetail ; cout << line << errorDetail << " " ; | |
274 | // filein >> line >> nSorting ; cout << line << nSorting << " " ; | |
9c2d4e89 | 275 | cout << endl; |
f3cfa63e | 276 | } |
9c2d4e89 | 277 | if(!nConfig) printf("%s : *** Config= %d: no configuration ascii file is used \n",prefixLDC,nConfig); |
1b15b395 | 278 | muonPedestal->SetconfigDA(nConfig); |
f9e83f1d | 279 | muonPedestal->SetnEvthreshold(nEvthreshold); |
ff496840 | 280 | muonPedestal->SetnSorting(nSorting); |
493c5a63 | 281 | muonPedestal->SetHistos(flag_histo); |
1b15b395 | 282 | |
b9c33bca | 283 | // nConfig=1: configuration ascii file config_$DATE_ROLE_NAME read from DetDB |
1b15b395 | 284 | if(nConfig) |
285 | { | |
1ccd531d | 286 | sprintf(dbfile,"config_%s",getenv("DATE_ROLE_NAME")); |
287 | status=daqDA_DB_getFile(dbfile,dbfile); | |
288 | if(status) {printf(" !!! Failed : Configuration file %s is missing, status = %d\n",dbfile,status); return -1; } | |
1ccd531d | 289 | muonPedestal->LoadConfig(dbfile); |
1b15b395 | 290 | } |
291 | ||
493c5a63 | 292 | if(flag_histo)muonPedestal->CreateControlHistos(); /// Generate pedestal histo rootfile |
293 | ||
dc928fbf | 294 | // Rawdeader, RawStreamHP |
295 | AliRawReader* rawReader = AliRawReader::Create(inputFile); | |
296 | AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader); | |
18ec51a0 | 297 | // rawStream->DisableWarnings(); |
dc928fbf | 298 | rawStream->EnabbleErrorLogger(); |
9c2d4e89 | 299 | |
300 | switch (errorDetail) | |
301 | { | |
302 | case 0: rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kLowErrorDetail); break;/// Logs minimal information in the error messages. | |
303 | case 1: rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kMediumErrorDetail); break;/// Logs a medium level of detail in the error messages. | |
304 | case 2: rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kHighErrorDetail); break;/// Logs a medium level of detail in the error messages. | |
305 | default: rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kMediumErrorDetail); break; | |
306 | } | |
dc928fbf | 307 | |
9c2d4e89 | 308 | printf("\n%s : Reading data from file %s\n",prefixLDC,inputFile.Data()); |
dc928fbf | 309 | |
f9e83f1d | 310 | Int_t tabTokenError[20][14]; |
311 | for ( Int_t i=0 ; i<20 ; i++) { for ( Int_t j=0 ; j<14 ; j++) { tabTokenError[i][j]=0;} } | |
312 | ||
dc928fbf | 313 | while (rawReader->NextEvent()) |
314 | { | |
9c2d4e89 | 315 | Int_t eventType = rawReader->GetType(); |
316 | runNumber = rawReader->GetRunNumber(); | |
317 | if(nDateEvents==0) { filcout<<"// ----> RUN = " << runNumber << "\n" << endl;} | |
dc928fbf | 318 | if (nDateEvents >= maxDateEvents) break; |
319 | if (nEvents >= maxEvents) break; | |
320 | if (nDateEvents>0 && nDateEvents % 100 == 0) | |
9c2d4e89 | 321 | cout<< prefixLDC << " : DATE events = " << nDateEvents << " Used events = " << nEvents << endl; |
dc928fbf | 322 | |
323 | // check shutdown condition | |
9c2d4e89 | 324 | if (daqDA_checkShutdown()) break; |
dc928fbf | 325 | //Skip events |
326 | while (skipEvents) | |
327 | { | |
328 | rawReader->NextEvent(); | |
329 | skipEvents--; | |
330 | } | |
dc928fbf | 331 | nDateEvents++; |
332 | if (eventType != PHYSICS_EVENT) | |
333 | continue; // for the moment | |
334 | ||
9c2d4e89 | 335 | // const char* detail = ""; |
dc928fbf | 336 | // First lopp over DDL's to find good events |
337 | // Error counters per event (counters in the decoding lib are for each DDL) | |
338 | Bool_t eventIsErrorMessage = kFALSE; | |
339 | int eventGlitchErrors = 0; | |
340 | int eventParityErrors = 0; | |
341 | int eventPaddingErrors = 0; | |
18ec51a0 | 342 | int eventTokenlostErrors = 0; |
dc928fbf | 343 | rawStream->First(); |
344 | do | |
345 | { | |
346 | if (rawStream->IsErrorMessage()) eventIsErrorMessage = kTRUE; | |
347 | eventGlitchErrors += rawStream->GetGlitchErrors(); | |
348 | eventParityErrors += rawStream->GetParityErrors(); | |
349 | eventPaddingErrors += rawStream->GetPaddingErrors(); | |
18ec51a0 | 350 | eventTokenlostErrors += rawStream->GetTokenLostErrors(); |
9c2d4e89 | 351 | // cout << nDateEvents << " " << rawStream->GetDDL() << " " << eventTokenlostErrors << endl; |
f9e83f1d | 352 | if (rawStream->GetTokenLostErrors()) |
353 | { | |
354 | nTokenlostErrors++; | |
355 | const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0; | |
356 | const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0; | |
357 | Int_t nBlock = rawStream->GetBlockCount(); | |
358 | for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++) | |
359 | { | |
360 | blkHeader = rawStream->GetBlockHeader(iBlock); | |
361 | // printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength()); | |
362 | Int_t nDsp = rawStream->GetDspCount(iBlock); | |
363 | // printf("Block %d DSP %d\n",iBlock,nDsp); | |
364 | for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++) | |
365 | { | |
366 | dspHeader = blkHeader->GetDspHeader(iDsp); | |
367 | // printf("Dsp %d Add %X\n",iDsp,dspHeader); | |
368 | if (dspHeader->GetErrorWord()) | |
369 | { | |
370 | Int_t ddl = rawStream->GetDDL() ; | |
371 | // Int_t ddl = AliDAQ::DdlID("MUONTRK", rawStream->GetDDL()) - 2560 ; // format 2560 + ddl | |
372 | Int_t frt = (dspHeader->GetErrorWord() & 0xFFFF0000) >> 16 ; // 4*4bits right shift | |
373 | tabTokenError[ddl][frt]++; | |
374 | // printf(" DDL %d error word %X %d %d\n",ddl,dspHeader->GetErrorWord(),frt,tabTokenError[8][4]); | |
375 | } | |
376 | ||
377 | } | |
378 | } | |
379 | } | |
dc928fbf | 380 | } while(rawStream->NextDDL()); |
381 | ||
382 | AliMUONRawStreamTrackerHP::AliBusPatch* busPatch; | |
383 | if (!eventIsErrorMessage) | |
384 | { | |
385 | // Good events (no error) -> compute pedestal for all channels | |
386 | rawStream->First(); | |
f9e83f1d | 387 | nEvents++; |
388 | muonPedestal->SetAliNCurrentEvents(nEvents); | |
dc928fbf | 389 | while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next())) |
390 | { | |
391 | for(int i = 0; i < busPatch->GetLength(); ++i) | |
392 | { | |
dc928fbf | 393 | busPatch->GetData(i, manuId, channelId, charge); |
394 | muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge); | |
395 | } | |
396 | } | |
dc928fbf | 397 | } |
398 | else | |
399 | { | |
400 | // Events with errors | |
9c2d4e89 | 401 | if (recoverParityErrors && eventParityErrors && !eventGlitchErrors && !eventPaddingErrors && !(eventTokenlostErrors && checkTokenlost)) |
dc928fbf | 402 | { |
18ec51a0 | 403 | filcout << " ----------- Date Event recovered = " << nDateEvents << " ----------------" << endl; |
dc928fbf | 404 | // Recover parity errors -> compute pedestal for all good buspatches |
405 | if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(), | |
406 | ATTR_ORBIT_BC )) | |
407 | { | |
408 | filcout <<"Event recovered -> Period:"<<EVENT_ID_GET_PERIOD( rawReader->GetEventId() ) | |
409 | <<" Orbit:"<<EVENT_ID_GET_ORBIT( rawReader->GetEventId() ) | |
410 | <<" BunchCrossing:"<<EVENT_ID_GET_BUNCH_CROSSING( rawReader->GetEventId() )<<endl; | |
411 | } | |
412 | else | |
413 | { | |
414 | filcout <<"Event recovered -> nbInRun:"<<EVENT_ID_GET_NB_IN_RUN( rawReader->GetEventId() ) | |
415 | <<" burstNb:"<<EVENT_ID_GET_BURST_NB( rawReader->GetEventId() ) | |
416 | <<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl; | |
417 | } | |
418 | rawStream->First(); | |
f9e83f1d | 419 | nEvents++; |
420 | muonPedestal->SetAliNCurrentEvents(nEvents); | |
dc928fbf | 421 | while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next())) |
422 | { | |
423 | // Check the buspatch -> if error not use it in the pedestal calculation | |
424 | int errorCount = 0; | |
425 | for(int i = 0; i < busPatch->GetLength(); ++i) | |
426 | { | |
427 | if (!busPatch->IsParityOk(i)) errorCount++; | |
428 | } | |
429 | if (!errorCount) | |
430 | { | |
431 | // Good buspatch | |
432 | for(int i = 0; i < busPatch->GetLength(); ++i) | |
433 | { | |
dc928fbf | 434 | busPatch->GetData(i, manuId, channelId, charge); |
dc928fbf | 435 | muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge); |
436 | } | |
437 | } | |
438 | else | |
439 | { | |
dc928fbf | 440 | AliMUONErrorCounter* errorCounter; |
441 | // Bad buspatch -> not used (just print) | |
442 | filcout<<"bpId "<<busPatch->GetBusPatchId()<<" words "<<busPatch->GetLength() | |
443 | <<" parity errors "<<errorCount<<endl; | |
444 | // Number of events where this buspatch is missing | |
a54854fc | 445 | if (!(errorCounter = (AliMUONErrorCounter*) (muonPedestal->GetErrorBuspatchTable()->FindObject(busPatch->GetBusPatchId())))) |
dc928fbf | 446 | { |
447 | // New buspatch | |
448 | errorCounter = new AliMUONErrorCounter(busPatch->GetBusPatchId()); | |
dc928fbf | 449 | muonPedestal->GetErrorBuspatchTable()->Add(errorCounter); |
450 | } | |
451 | else | |
452 | { | |
453 | // Existing buspatch | |
454 | errorCounter->Increment(); | |
455 | } | |
456 | // errorCounter->Print(); | |
457 | } // end of if (!errorCount) | |
458 | } // end of while( (busPatch = (AliMUONRawStreamTrackerHP ... | |
f9e83f1d | 459 | // nEvents++; |
dc928fbf | 460 | nEventsRecovered++; |
461 | } //end of if (recoverParityErrors && eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors) | |
462 | else | |
463 | { | |
464 | // Fatal errors reject the event | |
f9e83f1d | 465 | detail = Form(" ----------- Date Event rejected = %d ----------------",nDateEvents); |
9c2d4e89 | 466 | nDateRejEvents++; |
f9e83f1d | 467 | filcout << detail << endl; |
dc928fbf | 468 | if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(), |
469 | ATTR_ORBIT_BC )) | |
470 | { | |
471 | filcout <<"Event rejected -> Period:"<<EVENT_ID_GET_PERIOD( rawReader->GetEventId() ) | |
472 | <<" Orbit:"<<EVENT_ID_GET_ORBIT( rawReader->GetEventId() ) | |
473 | <<" BunchCrossing:"<<EVENT_ID_GET_BUNCH_CROSSING( rawReader->GetEventId() )<<endl; | |
474 | } | |
475 | else | |
476 | { | |
477 | filcout <<"Event rejected -> nbInRun:"<<EVENT_ID_GET_NB_IN_RUN( rawReader->GetEventId() ) | |
478 | <<" burstNb:"<<EVENT_ID_GET_BURST_NB( rawReader->GetEventId() ) | |
479 | <<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl; | |
480 | ||
481 | } | |
482 | } // end of if (!rawStream->GetGlitchErrors() && !rawStream->GetPaddingErrors() ... | |
483 | filcout<<"Number of errors : Glitch "<<eventGlitchErrors | |
484 | <<" Parity "<<eventParityErrors | |
18ec51a0 | 485 | <<" Padding "<<eventPaddingErrors |
486 | <<" Token lost "<<eventTokenlostErrors<<endl; | |
dc928fbf | 487 | filcout<<endl; |
488 | } // end of if (!rawStream->IsErrorMessage()) | |
489 | ||
490 | if (eventGlitchErrors) nGlitchErrors++; | |
491 | if (eventParityErrors) nParityErrors++; | |
492 | if (eventPaddingErrors) nPaddingErrors++; | |
493 | ||
494 | } // while (rawReader->NextEvent()) | |
495 | delete rawReader; | |
496 | delete rawStream; | |
497 | ||
5431405e | 498 | sprintf(flatFile,"%s.ped",prefixDA); |
dc928fbf | 499 | if(shuttleFile.IsNull())shuttleFile=flatFile; |
500 | muonPedestal->SetAliNEvents(nEvents); | |
501 | muonPedestal->SetAliRunNumber(runNumber); | |
dbbb2c64 | 502 | |
9c2d4e89 | 503 | muonPedestal->Finalize(); |
504 | status = muonPedestal->GetStatusDA() ; | |
505 | ||
dc928fbf | 506 | // writing some counters |
9c2d4e89 | 507 | detail=Form("\n%s : Nb of DATE events = %d",prefixLDC,nDateEvents) ; cout << detail; filcout << detail ; |
508 | detail=Form("\n%s : Nb of Glitch errors = %d",prefixLDC,nGlitchErrors) ; cout << detail; filcout << detail ; | |
509 | detail=Form("\n%s : Nb of Parity errors = %d",prefixLDC,nParityErrors) ; cout << detail; filcout << detail ; | |
510 | detail=Form("\n%s : Nb of Token lost errors = %d",prefixLDC,nTokenlostErrors) ; cout << detail; filcout << detail ; | |
511 | detail=Form("\n%s : Nb of Rejected DATE events = %d",prefixLDC,nDateRejEvents) ; cout << detail; filcout << detail ; | |
512 | detail=Form("\n%s : Nb of recovered events = %d",prefixLDC,nEventsRecovered) ; cout << detail; filcout << detail ; | |
513 | detail=Form("\n%s : Nb of events without errors = %d",prefixLDC,nEvents-nEventsRecovered) ; cout << detail; filcout << detail ; | |
514 | detail=Form("\n%s : Nb of used events = %d (threshold= %d)\n\n",prefixLDC,nEvents,nEvthreshold); cout << detail; filcout << detail ; | |
dc928fbf | 515 | |
f9e83f1d | 516 | // Writing Token Error table |
517 | if(nTokenlostErrors) | |
518 | { | |
9c2d4e89 | 519 | detail=Form("%s : Warning: Token Lost occurence \n",prefixLDC); |
f9e83f1d | 520 | printf("%s",detail); |
521 | filcout << detail ; | |
522 | for ( Int_t i=0 ; i<20 ; i++) | |
523 | { | |
524 | for ( Int_t j=4 ; j<14 ; j++) | |
525 | { | |
526 | if(tabTokenError[i][j]>0) | |
527 | { | |
528 | Int_t tab=tabTokenError[i][j]; | |
529 | Int_t frt=j/2-1; | |
530 | Int_t station = i/4 +1; | |
9c2d4e89 | 531 | if( j % 2 == 0)detail=Form("%s : in DDL= %d (station %d) and FRT%d ( Up ) => %d Token errors (address = 0x%X0000)",prefixLDC,2560+i,station,frt,tab,j); |
532 | else detail=Form("%s : in DDL= %d (station %d) and FRT%d (Down) => %d Token errors (address = 0x%X0000)",prefixLDC,2560+i,station,frt,tab,j); | |
f9e83f1d | 533 | printf("%s\n",detail); |
534 | filcout << detail << endl; | |
535 | } | |
536 | } | |
537 | } | |
538 | } | |
539 | ||
9c2d4e89 | 540 | if (!shuttleFile.IsNull()) |
541 | { | |
542 | ofstream out(shuttleFile.Data()); | |
543 | muonPedestal->MakeASCIIoutput(out); /// Generate pedestal output file | |
544 | out.close(); | |
545 | detail=Form("%s : Pedestal file (to SHUTTLE) : %s\n",prefixLDC,shuttleFile.Data()); | |
546 | cout << detail; filcout << detail ; | |
547 | } | |
548 | if(flag_histo) /// Generate pedestal histo rootfile | |
549 | { | |
550 | muonPedestal->MakeControlHistos(); | |
551 | detail=Form("%s : Pedestal Histo file : %s\n",prefixLDC,muonPedestal->GetHistoFileName()); | |
552 | cout << detail; filcout << detail ; | |
553 | } | |
554 | // .log files | |
555 | detail=Form("%s : Output logfile : %s\n",prefixLDC,logOutputFile.Data()); | |
556 | cout << detail; filcout << detail ; | |
557 | ||
558 | ||
559 | // Transferring pedestal file to FES (be sure that env variable DAQDALIB_PATH is set) | |
560 | cout << endl; | |
561 | status1 = daqDA_FES_storeFile(shuttleFile.Data(),"PEDESTALS"); | |
562 | if (status1) { detail=Form("%s: !!! ERROR: Failed to export pedestal file : %s to FES \n",prefixLDC,shuttleFile.Data()); | |
563 | printf("%s",detail); filcout << detail ; status= -1; } | |
9c2d4e89 | 564 | |
565 | // Transferring configuration file to FES (be sure that env variable DAQDALIB_PATH is set) | |
566 | if(nConfig) | |
567 | { cout << endl; | |
568 | status1 = daqDA_FES_storeFile(dbfile,"CONFIG"); | |
569 | if (status1) { detail=Form("%s: !!! ERROR: Failed to export configuration file : %s to FES \n",prefixLDC,dbfile); | |
570 | printf("%s",detail); filcout << detail ; status=-1; } | |
9c2d4e89 | 571 | } |
dc928fbf | 572 | |
493c5a63 | 573 | filcout.close(); |
574 | ||
5431405e | 575 | // Copying files to local DB folder defined by DAQ_DETDB_LOCAL |
576 | Char_t *dir; | |
1ccd531d | 577 | unsigned int nLastVersions=50; |
9c2d4e89 | 578 | dir= getenv("DAQ_DETDB_LOCAL"); |
579 | if(dir != NULL) { | |
493c5a63 | 580 | // unsigned int nLastVersions=50; |
160f3a71 | 581 | printf("\n%s : --- Local DataBase: %s (Max= %d) ---\n",prefixLDC,dir,nLastVersions); |
9c2d4e89 | 582 | if(!shuttleFile.IsNull())status1 = daqDA_localDB_storeFile(shuttleFile.Data(),nLastVersions); |
583 | if(flag_histo)status1 = daqDA_localDB_storeFile(muonPedestal->GetHistoFileName(),nLastVersions); | |
584 | status1 = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions); | |
585 | } | |
b9c33bca | 586 | |
9c2d4e89 | 587 | cout << " " << endl; |
588 | ||
589 | #ifdef ALI_AMORE | |
590 | // | |
591 | //Send objects to the AMORE DB | |
592 | // | |
593 | ostringstream stringout; | |
594 | muonPedestal->MakeASCIIoutput(stringout); | |
595 | ||
596 | amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender); | |
597 | TObjString peddata(stringout.str().c_str()); | |
598 | Int_t amoreStatus = amoreDA.Send("Pedestals",&peddata); | |
599 | if ( amoreStatus ) | |
160f3a71 | 600 | {cout << prefixLDC << " : !!! ERROR: Failed to write Pedestals in the AMORE database : " << amoreStatus << endl ; status=-1 ;} |
9c2d4e89 | 601 | else |
602 | cout << prefixLDC << " : amoreDA.Send(Pedestals) ok" << endl; | |
603 | #else | |
604 | cout << prefixLDC << " : Warning: MCH DA not compiled with AMORE support" << endl; | |
605 | #endif | |
606 | ||
1ccd531d | 607 | |
9c2d4e89 | 608 | if(!status)printf("\n%s : -------- End execution : %s -------- (status= %d) \n",prefixLDC,prefixDA,status); |
609 | else { printf("\n%s : -------- %s ending in ERROR !!!! -------- (status= %d) \n",prefixLDC,prefixDA,status);} | |
dc928fbf | 610 | timers.Stop(); |
9c2d4e89 | 611 | printf("\n Execution time : R:%7.2fs C:%7.2fs\n",timers.RealTime(), timers.CpuTime()); |
dc928fbf | 612 | return status; |
5431405e | 613 | } |