AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCHPEDda.cxx
Go to the documentation of this file.
1 /*
2  Contact: Jean-Luc Charvet <jean-luc.charvet@cern.ch>
3  Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_mchda.html
4  Reference Run: 109302 (station 3 only)
5  Run Type: PEDESTAL
6  DA Type: LDC
7  Number of events needed: 400 events for pedestal run
8  Input Files: mutrkpedvalues and config_ldc-MTRK-S3-0 in path : /afs/cern.ch/user/j/jcharvet/public/DA_validation
9  Output Files: local dir (not persistent) -> MCHPEDda.ped FXS -> run<#>_MCH_<ldc>_PEDESTALS
10  Trigger types used:
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  -------------------------------------------------------------------------
32  2016-03-15 New version: MCHPEDda.cxx,v 1.10
33  -------------------------------------------------------------------------
34 
35  Version for MCHPEDda 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 
42 &
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
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"
68 #include "AliLog.h"
69 #include "AliMUONDspHeader.h"
70 #include "AliDAQ.h"
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>
89 //
90 //AMORE
91 //
92 #ifdef ALI_AMORE
93 #include <AmoreDA.h>
94 #endif
95 
96 #include "AliMUONPedestal.h"
97 #include "AliMUONErrorCounter.h"
98 
99 
100 // main routine
101 int main(Int_t argc, const char **argv)
102 {
103  Int_t status=0, status1=0;
104  TStopwatch timers;
105  timers.Start(kTRUE);
106 
107  // Needed for streamer application
108  gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
109  "*",
110  "TStreamerInfo",
111  "RIO",
112  "TStreamerInfo()");
113  // needed for Minuit plugin
114  gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer",
115  "Minuit",
116  "TMinuitMinimizer",
117  "Minuit",
118  "TMinuitMinimizer(const char*)");
119 // cout << argv[0];
120 
121  Int_t skipEvents = 0;
122  Int_t maxEvents = 1000000;
123  Int_t maxDateEvents = 1000000;
124  Int_t errorDetail = 1;
125  Int_t checkTokenlost = 0;
126  Int_t flag_histo=1;
127  TString inputFile;
128 
129  Int_t nDateEvents = 0;
130  Int_t nDateRejEvents = 0;
131  Int_t nGlitchErrors= 0;
132  Int_t nParityErrors= 0;
133  Int_t nPaddingErrors= 0;
134  Int_t nTokenlostErrors= 0;
135  Int_t recoverParityErrors = 1;
136 
137  TString logOutputFile;
138 
139  Char_t flatFile[256]="";
140  Char_t* detail;
141  TString shuttleFile;
142 
143  Int_t nEventsRecovered = 0;
144  Int_t nEvents = 0;
145  UInt_t runNumber = 0;
146  Int_t nConfig = 1;
147  Int_t nEvthreshold = 100; //below this nb_evt pedestal are not calculated and forced to 4085 (sigma)
148  Int_t nSorting = 1 ; // pedestal sorting (ON by default)
149  Int_t statusDA = 0 ; // DA return code
150  ofstream filcout;
151 
152  // decode the input line
153  for (Int_t i = 1; i < argc; i++) // argument 0 is the executable name
154  {
155  const char* arg = argv[i];
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  {
163  inputFile=argv[i];
164  }
165  continue;
166  }
167  nConfig=0;
168  //prefixLDC = "LDC"
169  switch (arg[1])
170  {
171  case 'f' :
172  i++;
173  inputFile=argv[i];
174  nConfig=0;
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;
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;
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]);
204  printf("\n%s can be used locally only with options (without DiMuon configuration file: nConfig=%d)",argv[0],nConfig);
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");
209  printf("\n-f <raw data file> (default = %s)",inputFile.Data());
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);
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);
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 
229  UShort_t manuId;
230  UChar_t channelId;
231  UShort_t charge;
232 
233  Char_t dum[256] ="";
234  sprintf(dum,"%sPEDda",getenv("DATE_DETECTOR_CODE")); // DATE_DETECTOR_CODE = MCH
235  const char* prefixDA = dum ; // program prefix
236  const char* prefixLDC = getenv("DATE_ROLE_NAME"); // LDC name
237  if(prefixLDC == NULL) prefixLDC ="MCH" ;
238  printf("%s : -------- Begin execution : %s -------- \n",prefixLDC,prefixDA);
239 
240  //Pedestal object
241  AliMUONPedestal* muonPedestal = new AliMUONPedestal();
242  muonPedestal->SetprefixDA(prefixDA);
243  muonPedestal->SetprefixLDC(prefixLDC);
244  muonPedestal->SetStatusDA(statusDA);
245 
246  // Output log file initialisations
247  sprintf(flatFile,"%s.log",prefixDA);
248  logOutputFile=flatFile;
249  AliLog::SetStreamOutput(&filcout); // Print details on logfile
250  filcout.open(logOutputFile.Data());
251  filcout<<"//=================================================" << endl;
252  filcout<<"//" << prefixLDC << " " << prefixDA << endl;
253  filcout<<"//=================================================" << endl;
254  filcout<<"// * Date : " << muonPedestal->GetDate()->AsString("l") << "\n" << endl;
255 
256  muonPedestal->SetAlifilcout(&filcout);
257  cout<<prefixLDC << " : Date: " << muonPedestal->GetDate()->AsString("l") << "\n" << endl;
258 
259 
260  Char_t dbfile[256]="";
261  // nConfig=1 : Reading configuration (or not) status via "mutrkpedvalues" file located in DetDB
262  if(nConfig)
263  {
264  Int_t flag_hist, nEvthres,maxEvts;
265  char line[80];
266  sprintf(dbfile,"mutrkpedvalues");
267  status=daqDA_DB_getFile(dbfile,dbfile);
268  if(status) {fprintf(stderr," !!! ERROR : input file %s is missing, status = %d\n",dbfile,status);
269  fprintf(stderr,"\n%s : -------- %s ending in ERROR !!!! -------- (status= %d) \n",prefixLDC,prefixDA,-1);
270  return -1; }
271 
272  ifstream filein(dbfile,ios::in);
273  filein >> line >> nConfig ; cout << "mutrkpedvalues: " << line << nConfig << " " ;
274  filein >> line >> nEvthres ; if(nEvthres !=0)nEvthreshold=nEvthres; cout << line << nEvthreshold << " " ;
275  filein >> line >> checkTokenlost ; cout << line << checkTokenlost << " " ;
276  filein >> line >> flag_histo ; cout << line << flag_histo << " " ; // =0 , 1-> standard , 2-> ntuple charge
277  filein >> line >> maxEvts ; if(maxEvts!=0){maxEvents=maxEvts; cout << line << maxEvents;}
278  // filein >> line >> errorDetail ; cout << line << errorDetail << " " ;
279  // filein >> line >> nSorting ; cout << line << nSorting << " " ;
280  cout << endl;
281  }
282  if(!nConfig) printf("%s : *** Config= %d: no configuration ascii file is used \n",prefixLDC,nConfig);
283  muonPedestal->SetconfigDA(nConfig);
284  muonPedestal->SetnEvthreshold(nEvthreshold);
285  muonPedestal->SetnSorting(nSorting);
286  muonPedestal->SetHistos(flag_histo);
287 
288  // nConfig=1: configuration ascii file config_$DATE_ROLE_NAME read from DetDB
289  if(nConfig)
290  {
291  sprintf(dbfile,"config_%s",getenv("DATE_ROLE_NAME"));
292  status=daqDA_DB_getFile(dbfile,dbfile);
293  if(status) {fprintf(stderr," !!! ERROR : Configuration file %s is missing, status = %d\n",dbfile,status);
294  fprintf(stderr,"\n%s : -------- %s ending in ERROR !!!! -------- (status= %d) \n",prefixLDC,prefixDA,-1);
295  return -1; }
296  muonPedestal->LoadConfig(dbfile);
297  }
298 
299  if(flag_histo)muonPedestal->CreateControlHistos();
300 
301  // Rawdeader, RawStreamHP
302  AliRawReader* rawReader = AliRawReader::Create(inputFile);
303  AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader);
304 // rawStream->DisableWarnings();
305  rawStream->EnabbleErrorLogger();
306 
307  switch (errorDetail)
308  {
313  }
314 
315  printf("\n%s : Reading data from file %s\n",prefixLDC,inputFile.Data());
316 
317  Int_t tabTokenError[20][14];
318  for ( Int_t i=0 ; i<20 ; i++) { for ( Int_t j=0 ; j<14 ; j++) { tabTokenError[i][j]=0;} }
319 
320  while (rawReader->NextEvent())
321  {
322  Int_t eventType = rawReader->GetType();
323  runNumber = rawReader->GetRunNumber();
324  if(nDateEvents==0) { filcout<<"// ----> RUN = " << runNumber << "\n" << endl;}
325  if (nDateEvents >= maxDateEvents) break;
326  if (nEvents >= maxEvents) break;
327  if (nDateEvents>0 && nDateEvents % 100 == 0)
328  cout<< prefixLDC << " : DATE events = " << nDateEvents << " Used events = " << nEvents << endl;
329 
330  // check shutdown condition
331  if (daqDA_checkShutdown()) break;
332  //Skip events
333  while (skipEvents)
334  {
335  rawReader->NextEvent();
336  skipEvents--;
337  }
338  nDateEvents++;
339  if (eventType != PHYSICS_EVENT)
340  continue; // for the moment
341 
342  // const char* detail = "";
343  // First lopp over DDL's to find good events
344  // Error counters per event (counters in the decoding lib are for each DDL)
345  Bool_t eventIsErrorMessage = kFALSE;
346  int eventGlitchErrors = 0;
347  int eventParityErrors = 0;
348  int eventPaddingErrors = 0;
349  int eventTokenlostErrors = 0;
350 
351  rawStream->First();
352  do
353  {
354 //** if (rawStream->GetDDL()== 8 ) {
355 
356  if (rawStream->IsErrorMessage()) eventIsErrorMessage = kTRUE;
357  eventGlitchErrors += rawStream->GetGlitchErrors();
358  eventParityErrors += rawStream->GetParityErrors();
359  eventPaddingErrors += rawStream->GetPaddingErrors();
360  eventTokenlostErrors += rawStream->GetTokenLostErrors();
361  // cout << nDateEvents << " " << rawStream->GetDDL() << " " << eventTokenlostErrors << endl;
362  if (rawStream->GetTokenLostErrors())
363  {
364  nTokenlostErrors++;
365  const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
366  const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
367  Int_t nBlock = rawStream->GetBlockCount();
368  for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++)
369  {
370  blkHeader = rawStream->GetBlockHeader(iBlock);
371  // printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
372  Int_t nDsp = rawStream->GetDspCount(iBlock);
373  // printf("Block %d DSP %d\n",iBlock,nDsp);
374  for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++)
375  {
376  dspHeader = blkHeader->GetDspHeader(iDsp);
377  // printf("Dsp %d Add %X\n",iDsp,dspHeader);
378  if (dspHeader->GetErrorWord())
379  {
380  Int_t ddl = rawStream->GetDDL() ;
381  // Int_t ddl = AliDAQ::DdlID("MUONTRK", rawStream->GetDDL()) - 2560 ; // format 2560 + ddl
382  Int_t frt = (dspHeader->GetErrorWord() & 0xFFFF0000) >> 16 ; // 4*4bits right shift
383  tabTokenError[ddl][frt]++;
384  // printf(" DDL %d error word %X %d %d\n",ddl,dspHeader->GetErrorWord(),frt,tabTokenError[8][4]);
385  }
386 
387  }
388  }
389  }
390  //** } // if (rawStream->GetDDL()== 8 ) {
391  } while(rawStream->NextDDL());
392 
394 
395  if (!eventIsErrorMessage)
396  {
397  // Good events (no error) -> compute pedestal for all channels
398  rawStream->First();
399  nEvents++;
400  muonPedestal->SetAliNCurrentEvents(nEvents);
401  while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next()))
402  {
403  for(int i = 0; i < busPatch->GetLength(); ++i)
404  {
405  busPatch->GetData(i, manuId, channelId, charge);
406  muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
407  }
408  }
409  }
410  else
411  {
412  // Events with errors
413  if (recoverParityErrors && eventParityErrors && !eventGlitchErrors && !eventPaddingErrors && !(eventTokenlostErrors && checkTokenlost))
414  {
415  filcout << " ----------- Date Event recovered = " << nDateEvents << " ----------------" << endl;
416  // Recover parity errors -> compute pedestal for all good buspatches
417  if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(),
418  ATTR_ORBIT_BC ))
419  {
420  filcout <<"Event recovered -> Period:"<<EVENT_ID_GET_PERIOD( rawReader->GetEventId() )
421  <<" Orbit:"<<EVENT_ID_GET_ORBIT( rawReader->GetEventId() )
422  <<" BunchCrossing:"<<EVENT_ID_GET_BUNCH_CROSSING( rawReader->GetEventId() )<<endl;
423  }
424  else
425  {
426  filcout <<"Event recovered -> nbInRun:"<<EVENT_ID_GET_NB_IN_RUN( rawReader->GetEventId() )
427  <<" burstNb:"<<EVENT_ID_GET_BURST_NB( rawReader->GetEventId() )
428  <<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl;
429  }
430  rawStream->First();
431  nEvents++;
432  muonPedestal->SetAliNCurrentEvents(nEvents);
433  while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next()))
434  {
435  // Check the buspatch -> if error not use it in the pedestal calculation
436  int errorCount = 0;
437  for(int i = 0; i < busPatch->GetLength(); ++i)
438  {
439  if (!busPatch->IsParityOk(i)) errorCount++;
440  }
441  if (!errorCount)
442  {
443  // Good buspatch
444  for(int i = 0; i < busPatch->GetLength(); ++i)
445  {
446  busPatch->GetData(i, manuId, channelId, charge);
447  muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
448  }
449  }
450  else
451  {
452  AliMUONErrorCounter* errorCounter;
453  // Bad buspatch -> not used (just print)
454  filcout<<"bpId "<<busPatch->GetBusPatchId()<<" words "<<busPatch->GetLength()
455  <<" parity errors "<<errorCount<<endl;
456  // Number of events where this buspatch is missing
457  if (!(errorCounter = (AliMUONErrorCounter*) (muonPedestal->GetErrorBuspatchTable()->FindObject(busPatch->GetBusPatchId()))))
458  {
459  // New buspatch
460  errorCounter = new AliMUONErrorCounter(busPatch->GetBusPatchId());
461  muonPedestal->GetErrorBuspatchTable()->Add(errorCounter);
462  }
463  else
464  {
465  // Existing buspatch
466  errorCounter->Increment();
467  }
468  // errorCounter->Print();
469  } // end of if (!errorCount)
470  } // end of while( (busPatch = (AliMUONRawStreamTrackerHP ...
471  // nEvents++;
472  nEventsRecovered++;
473  } //end of if (recoverParityErrors && eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors)
474  else
475  {
476  // Fatal errors reject the event
477  detail = Form(" ----------- Date Event rejected = %d ----------------",nDateEvents);
478  nDateRejEvents++;
479  filcout << detail << endl;
480  if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(),
481  ATTR_ORBIT_BC ))
482  {
483  filcout <<"Event rejected -> Period:"<<EVENT_ID_GET_PERIOD( rawReader->GetEventId() )
484  <<" Orbit:"<<EVENT_ID_GET_ORBIT( rawReader->GetEventId() )
485  <<" BunchCrossing:"<<EVENT_ID_GET_BUNCH_CROSSING( rawReader->GetEventId() )<<endl;
486  }
487  else
488  {
489  filcout <<"Event rejected -> nbInRun:"<<EVENT_ID_GET_NB_IN_RUN( rawReader->GetEventId() )
490  <<" burstNb:"<<EVENT_ID_GET_BURST_NB( rawReader->GetEventId() )
491  <<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl;
492 
493  }
494  } // end of if (!rawStream->GetGlitchErrors() && !rawStream->GetPaddingErrors() ...
495  filcout<<"Number of errors : Glitch "<<eventGlitchErrors
496  <<" Parity "<<eventParityErrors
497  <<" Padding "<<eventPaddingErrors
498  <<" Token lost "<<eventTokenlostErrors<<endl;
499  filcout<<endl;
500  } // end of if (!rawStream->IsErrorMessage())
501 
502  if (eventGlitchErrors) nGlitchErrors++;
503  if (eventParityErrors) nParityErrors++;
504  if (eventPaddingErrors) nPaddingErrors++;
505 
506  } // while (rawReader->NextEvent())
507  delete rawReader;
508  delete rawStream;
509 
510  sprintf(flatFile,"%s.ped",prefixDA);
511  if(shuttleFile.IsNull())shuttleFile=flatFile;
512  muonPedestal->SetAliNEvents(nEvents);
513  muonPedestal->SetAliRunNumber(runNumber);
514 
515  muonPedestal->Finalize();
516  status = muonPedestal->GetStatusDA() ;
517 
518  // writing some counters
519  detail=Form("\n%s : Nb of DATE events = %d",prefixLDC,nDateEvents) ; cout << detail; filcout << detail ;
520  detail=Form("\n%s : Nb of Glitch errors = %d",prefixLDC,nGlitchErrors) ; cout << detail; filcout << detail ;
521  detail=Form("\n%s : Nb of Parity errors = %d",prefixLDC,nParityErrors) ; cout << detail; filcout << detail ;
522  detail=Form("\n%s : Nb of Token lost errors = %d",prefixLDC,nTokenlostErrors) ; cout << detail; filcout << detail ;
523  detail=Form("\n%s : Nb of Rejected DATE events = %d",prefixLDC,nDateRejEvents) ; cout << detail; filcout << detail ;
524  detail=Form("\n%s : Nb of recovered events = %d",prefixLDC,nEventsRecovered) ; cout << detail; filcout << detail ;
525  detail=Form("\n%s : Nb of events without errors = %d",prefixLDC,nEvents-nEventsRecovered) ; cout << detail; filcout << detail ;
526  detail=Form("\n%s : Nb of used events = %d (threshold= %d)\n\n",prefixLDC,nEvents,nEvthreshold); cout << detail; filcout << detail ;
527 
528  //2015-01-22 create filerror.txt file for checking (should be removed later)
529  //2015-01-22 FILE *fp;
530  //2015-01-22 fp= fopen("filerror.txt","w+");
531  // Writing Token Error table
532  if(nTokenlostErrors)
533  {
534  detail=Form("%s : Error : Token Lost occurence \n",prefixLDC);
535  filcout << detail ;
536  //2015-01-22 printf("%s",detail);
537  //2015-01-22 cerr << "ERROR : " << detail;
538  fprintf(stderr,"%s",detail);
539  //2015-01-22 fprintf(fp,"%s",detail);
540  for ( Int_t i=0 ; i<20 ; i++)
541  {
542  for ( Int_t j=4 ; j<14 ; j++)
543  {
544  if(tabTokenError[i][j]>0)
545  {
546  Int_t tab=tabTokenError[i][j];
547  Int_t frt=j/2-1;
548  Int_t station = i/4 +1;
549  if( j % 2 == 0)detail=Form("%s : Error : in DDL= %d (station %d) and FRT%d ( Up ) => %d Token errors (address = 0x%X0000)",prefixLDC,2560+i,station,frt,tab,j);
550  else detail=Form("%s : Error : in DDL= %d (station %d) and FRT%d (Down) => %d Token errors (address = 0x%X0000)",prefixLDC,2560+i,station,frt,tab,j);
551  //2015-01-22 printf("%s\n",detail);
552  fprintf(stderr,"%s\n",detail);
553  filcout << detail << endl;
554  }
555  }
556  }
557  }
558  //2015-01-22 fclose(fp);
559 
560  if (!shuttleFile.IsNull())
561  {
562  ofstream out(shuttleFile.Data());
563  muonPedestal->MakeASCIIoutput(out);
564  out.close();
565  detail=Form("%s : Pedestal file (to SHUTTLE) : %s\n",prefixLDC,shuttleFile.Data());
566  cout << detail; filcout << detail ;
567  }
568  if(flag_histo)
569  {
570  muonPedestal->MakeControlHistos();
571  detail=Form("%s : Pedestal Histo file : %s\n",prefixLDC,muonPedestal->GetHistoFileName());
572  cout << detail; filcout << detail ;
573  }
574  // .log files
575  detail=Form("%s : Output logfile : %s\n",prefixLDC,logOutputFile.Data());
576  cout << detail; filcout << detail ;
577 
578 
579  // Transferring pedestal file to FES (be sure that env variable DAQDALIB_PATH is set)
580  cout << endl;
581  status1 = daqDA_FES_storeFile(shuttleFile.Data(),"PEDESTALS");
582  if (status1) { detail=Form("%s: !!! ERROR: Failed to export pedestal file : %s to FES \n",prefixLDC,shuttleFile.Data());
583  //2015-01-22 printf("%s",detail); filcout << detail ; status= -1; }
584  fprintf(stderr,"%s",detail); filcout << detail ; status= -1; }
585 
586  // Transferring configuration file to FES (be sure that env variable DAQDALIB_PATH is set)
587  if(nConfig)
588  { cout << endl;
589  status1 = daqDA_FES_storeFile(dbfile,"CONFIG");
590  if (status1) { detail=Form("%s: !!! ERROR: Failed to export configuration file : %s to FES \n",prefixLDC,dbfile);
591  //2015-01-22 printf("%s",detail); filcout << detail ; status=-1; }
592  fprintf(stderr,"%s",detail); filcout << detail ; status=-1; }
593  }
594 
595  filcout.close();
596 
597  // Copying files to local DB folder defined by DAQ_DETDB_LOCAL
598  Char_t *dir;
599  unsigned int nLastVersions=50;
600  dir= getenv("DAQ_DETDB_LOCAL");
601  if(dir != NULL) {
602  // unsigned int nLastVersions=50;
603  printf("\n%s : --- Local DataBase: %s (Max= %d) ---\n",prefixLDC,dir,nLastVersions);
604  if(!shuttleFile.IsNull())status1 = daqDA_localDB_storeFile(shuttleFile.Data(),nLastVersions);
605  if(flag_histo)status1 = daqDA_localDB_storeFile(muonPedestal->GetHistoFileName(),nLastVersions);
606  status1 = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions);
607  }
608 
609  cout << " " << endl;
610 
611 #ifdef ALI_AMORE
612  //
613  //Send objects to the AMORE DB
614  //
615  ostringstream stringout;
616  muonPedestal->MakeASCIIoutput(stringout);
617 
618  amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
619  TObjString peddata(stringout.str().c_str());
620  Int_t amoreStatus = amoreDA.Send("Pedestals",&peddata);
621  if ( amoreStatus )
622  {cout << prefixLDC << " : !!! ERROR: Failed to write Pedestals in the AMORE database : " << amoreStatus << endl ; status=-1 ;}
623  else
624  cout << prefixLDC << " : amoreDA.Send(Pedestals) ok" << endl;
625 #else
626  cout << prefixLDC << " : Warning: MCH DA not compiled with AMORE support" << endl;
627 #endif
628 
629 
630  if(!status)printf("\n%s : -------- End execution : %s -------- (status= %d) \n",prefixLDC,prefixDA,status);
631  else { fprintf(stderr,"\n%s : -------- %s ending in ERROR !!!! -------- (status= %d) \n",prefixLDC,prefixDA,status);}
632  timers.Stop();
633  printf("\n Execution time : R:%7.2fs C:%7.2fs\n",timers.RealTime(), timers.CpuTime());
634  return status;
635 }
virtual void EnabbleErrorLogger()
Enable error logging to the raw reader.
A high performance stream decoder for muon tracking DDL streams.
Int_t GetStatusDA() const
get DA status (return code)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
TTimeStamp * GetDate() const
return date and time
Logs a medium level of detail in the error messages.
void Increment()
Increment nb of erroneous event.
Int_t GetTokenLostErrors() const
Get number of token lost errors in the DDL last decoded.
TROOT * gROOT
void MakeASCIIoutput(ostream &out) const
Create String to be put into file or AMORE DB.
Light weight interface class to the block header data.
void SetAliRunNumber(Int_t run)
return the Run number
Int_t GetLength() const
Return length of raw data.
Int_t GetErrorWord() const
Return Error word.
void MakeControlHistos()
Fill Histograms.
const char * GetHistoFileName() const
return the name of DAPedestal .root file
void SetLoggingDetailLevel(EDetailLevel level)
Sets the level of detail used in the error messages.
void Finalize()
Compute the pedestal data (mean, sigma)
void SetconfigDA(Int_t ind)
set config flag
void SetprefixDA(const char *folder)
set specific DA prefixname
void SetAlifilcout(ofstream *stream)
output .log file of DAs
void SetAliNEvents(Int_t events)
return the number of events
Light weight interface class to the DSP header data.
void SetnSorting(Int_t ind)
sorting flag
void SetAliNCurrentEvents(Int_t events)
return the number of current events
Int_t GetBusPatchId() const
Return bus patch id.
const UInt_t * GetData() const
Return raw digit data.
virtual Bool_t IsErrorMessage() const
check error/Warning presence
virtual Int_t GetDDL() const
Return number of the current DDL being processed in the range [0..19] or -1 if no DDL set...
Int_t GetPaddingErrors() const
Get number of padding word errors in the DDL last decoded.
void SetprefixLDC(const char *folder)
set specific LDC prefixname
Int_t GetParityErrors() const
Get number of parity errors in the DDL last decoded.
Logs minimal information in the error messages.
void SetHistos(Int_t ind)
set Histos flag
void LoadConfig(const char *dbfile)
load MuonTrk configuration from ascii dbfile
int main(Int_t argc, const char **argv)
Definition: MCHPEDda.cxx:101
virtual Bool_t Add(TObject *object)=0
Add an object to the store.
Implementation of the pedestal computing.
UInt_t GetDspCount(UInt_t block) const
Returns the number of DSPs for the given block number.
virtual void First()
Initialize iterator.
void CreateControlHistos()
Create Histograms.
Light weight interface class to the bus patch data.
Int_t GetGlitchErrors() const
Get number of glitch errors in the DDL last decoded.
const AliDspHeader * GetDspHeader(UInt_t i) const
Return the i'th DSP in this block.
UInt_t GetBlockCount() const
Return the number of blocks in the DDL payload.
AliMUONVStore * GetErrorBuspatchTable() const
Count parity errors per Buspatch.
void MakePed(Int_t bp, Int_t manu, Int_t ch, Int_t charge)
sum pedestal values for mean and sigma determination
void SetStatusDA(Int_t ind)
set DA status (return code)
Declaration of the high performance decoder for muon trigger chamber raw streams. ...
void SetnEvthreshold(Int_t ind)
set Nb of evt threshold to calculate pedestal
virtual Bool_t Next(Int_t &busPatchId, UShort_t &manuId, UChar_t &manuChannel, UShort_t &adc)
Advance one step in the iteration. Returns false if finished.
virtual TObject * FindObject(const char *name) const
Find an object by name.
virtual Bool_t NextDDL()
DDL iterator.
const AliBlockHeader * GetBlockHeader(UInt_t i) const
Return the i'th block header or NULL if not found.