]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONTRKPEDda.cxx
New: Sorting pedestal values ordered by Buspatch and Manu (by default sorting is...
[u/mrichter/AliRoot.git] / MUON / MUONTRKPEDda.cxx
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) -> MUONTRKPEDda.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         2010-07-09 New version: MUONTRKPEDda.cxx,v 1.7
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
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
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"
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;
104   TStopwatch timers;
105   timers.Start(kTRUE); 
106
107   const char* prefixDA = "MUONTRKPEDda"; // program prefix
108   printf(" ######## Begin execution : %s ######## \n\n",prefixDA); 
109
110   // needed for streamer application
111   gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
112                                         "*",
113                                         "TStreamerInfo",
114                                         "RIO",
115                                         "TStreamerInfo()"); 
116   // needed for Minuit plugin
117   gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer",
118                                         "Minuit",
119                                         "TMinuitMinimizer",
120                                         "Minuit",
121                                         "TMinuitMinimizer(const char*)");
122 //   cout << argv[0];
123  
124   Int_t skipEvents = 0;
125   Int_t maxEvents  = 1000000;
126   Int_t maxDateEvents  = 1000000;
127   TString inputFile;
128
129   Int_t  nDateEvents = 0;
130   Int_t nGlitchErrors= 0;
131   Int_t nParityErrors= 0;
132   Int_t nPaddingErrors= 0;
133   Int_t nTokenlostErrors= 0;
134   Int_t recoverParityErrors = 1;
135
136   TString logOutputFile;
137
138   Char_t flatFile[256]="";
139   TString shuttleFile;
140
141   Int_t nEventsRecovered = 0;
142   Int_t nEvents = 0;
143   UInt_t runNumber   = 0;
144   Int_t nConfig = 1;
145   Int_t nEvthreshold = 100; //below this nb_evt pedestal are not calculated and forced to 4085 (sigma)
146   Int_t nSorting = 0 ; // pedestal sorting (OFF by default)
147   ofstream filcout;
148
149   // decode the input line
150   for (Int_t i = 1; i < argc; i++) // argument 0 is the executable name
151     {
152       const char* arg = argv[i];
153
154       arg = argv[i];
155       if (arg[0] != '-') 
156         {
157           // If only one argument and no "-" => DA calling from ECS
158           if (argc == 2)
159             {
160         inputFile=argv[i];
161             }
162           continue;
163         }
164       switch (arg[1])
165         {
166         case 'f' : 
167           i++;
168       inputFile=argv[i];
169           nConfig=0;
170           break;
171         case 'a' : 
172           i++;
173           shuttleFile = argv[i];
174           break;
175         case 's' :
176           i++; 
177           skipEvents=atoi(argv[i]);
178           break;
179         case 'm' :
180           i++; 
181           sscanf(argv[i],"%d",&maxDateEvents);
182           break;
183         case 'n' :
184           i++; 
185           sscanf(argv[i],"%d",&maxEvents);
186           break;
187         case 'h' :
188           i++;
189           printf("\n******************* %s usage **********************",argv[0]);
190           printf("\nOnline (called from ECS) : %s <raw data file> (no inline options)\n",argv[0]);
191           printf("\n%s can be used locally only with options (without DiMuon configuration file)",argv[0]);
192           printf("\n%s -options, the available options are :",argv[0]);
193           printf("\n-h help                    (this screen)");
194           printf("\n");
195           printf("\n Input");
196           printf("\n-f <raw data file>         (default = %s)",inputFile.Data()); 
197           printf("\n");
198           printf("\n Output");
199           printf("\n-a <Flat ASCII file>       (default = %s)",shuttleFile.Data()); 
200           printf("\n");
201           printf("\n Options");
202           printf("\n-m <max date events>       (default = %d)",maxDateEvents);
203           printf("\n-s <skip events>           (default = %d)",skipEvents);
204           printf("\n-n <max events>            (default = %d)",maxEvents);
205
206           printf("\n\n");
207           exit(-1);
208         default :
209           printf("%s : bad argument %s (please check %s -h)\n",argv[0],argv[i],argv[0]);
210           argc = 2; exit(-1); // exit if error
211         } // end of switch  
212     } // end of for i  
213
214   // decoding the events
215
216   UShort_t manuId;  
217   UChar_t channelId;
218   UShort_t charge;
219
220   //Pedestal object
221   AliMUONPedestal* muonPedestal = new AliMUONPedestal();
222   muonPedestal->SetprefixDA(prefixDA);
223
224   Char_t dbfile[256]="";
225   // nConfig=1 : Reading configuration (or not) status via "mutrkpedvalues" file located in DetDB
226   if(nConfig)
227     { 
228 //      Int_t maxEvts;
229       sprintf(dbfile,"mutrkpedvalues");
230       status=daqDA_DB_getFile(dbfile,dbfile);
231       if(status) {printf(" !!! Failed  : input file %s is missing, status = %d\n",dbfile,status); return -1; } 
232       ifstream filein(dbfile,ios::in);
233       filein >> nConfig;
234       filein >> nSorting;
235       //      filein >> maxEvts;
236 //      if(maxEvts!=0)maxEvents=maxEvts;
237     }
238   else  printf(" ***  Config= %d: no configuration ascii file is used \n",nConfig); 
239   muonPedestal->SetconfigDA(nConfig);
240   muonPedestal->SetnEvthreshold(nEvthreshold);
241   muonPedestal->SetnSorting(nSorting);
242
243   // nConfig=1: configuration ascii file config_$DATE_ROLE_NAME read from DetDB
244   if(nConfig)
245     {
246       sprintf(dbfile,"config_%s",getenv("DATE_ROLE_NAME"));
247       status=daqDA_DB_getFile(dbfile,dbfile);
248       if(status) {printf(" !!! Failed  : Configuration file %s is missing, status = %d\n",dbfile,status); return -1; }
249       //      else printf(" *** Copy ascii config file: %s from DetDB to working directory and reading ...*** \n",dbfile);
250       muonPedestal->LoadConfig(dbfile);  
251     } 
252
253   // Rawdeader, RawStreamHP
254   AliRawReader* rawReader = AliRawReader::Create(inputFile);
255   AliMUONRawStreamTrackerHP* rawStream  = new AliMUONRawStreamTrackerHP(rawReader);    
256 //      rawStream->DisableWarnings();
257   rawStream->EnabbleErrorLogger();
258   //
259   // kLowErrorDetail,     /// Logs minimal information in the error messages.
260   // kMediumErrorDetail,  /// Logs a medium level of detail in the error messages.
261   // kHighErrorDetail     /// Logs maximum information in the error messages.
262   //  rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kLowErrorDetail);
263      rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kMediumErrorDetail);
264   //   rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kHighErrorDetail);
265
266   printf("\n %s : Reading data from file %s\n",prefixDA,inputFile.Data());
267
268   Int_t tabTokenError[20][14];
269   for ( Int_t i=0 ; i<20 ; i++) { for ( Int_t j=0 ; j<14 ; j++) { tabTokenError[i][j]=0;}       }
270
271   while (rawReader->NextEvent())
272     {
273       if (nDateEvents >= maxDateEvents) break;
274       if (nEvents >= maxEvents) break;
275       if (nDateEvents>0 &&  nDateEvents % 100 == 0)     
276         cout<<"Cumulated:  DATE events = " << nDateEvents << "   Used events = " << nEvents << endl;
277
278       // check shutdown condition 
279       if (daqDA_checkShutdown()) 
280         break;
281       //Skip events
282       while (skipEvents)
283         {
284           rawReader->NextEvent();
285           skipEvents--;
286         }
287       Int_t eventType = rawReader->GetType();
288       runNumber = rawReader->GetRunNumber();
289
290       // Output log file initialisations
291       if(nDateEvents==0)
292         {
293           sprintf(flatFile,"%s.log",prefixDA);
294           logOutputFile=flatFile;
295                 AliLog::SetStreamOutput(&filcout); // Print details on logfile
296           filcout.open(logOutputFile.Data());
297           filcout<<"//=================================================" << endl;
298           filcout<<"//       " << prefixDA << " for run = " << runNumber << endl;
299           filcout<<"//=================================================" << endl;
300           filcout<<"//   * Date          : " << muonPedestal->GetDate()->AsString("l") << "\n" << endl;
301           cout<<"\n ********  " << prefixDA << " for run = " << runNumber << " ********\n" << endl;
302           cout<<" * Date          : " << muonPedestal->GetDate()->AsString("l") << "\n" << endl;
303
304         }
305
306       muonPedestal->SetAlifilcout(&filcout);
307
308       nDateEvents++;
309       if (eventType != PHYSICS_EVENT)
310         continue; // for the moment
311
312       const char* detail = "";
313       // First lopp over DDL's to find good events
314       // Error counters per event (counters in the decoding lib are for each DDL)
315       Bool_t eventIsErrorMessage = kFALSE;
316       int eventGlitchErrors = 0;
317       int eventParityErrors = 0;
318       int eventPaddingErrors = 0;
319       int eventTokenlostErrors = 0;
320       rawStream->First();
321       do
322         {
323           if (rawStream->IsErrorMessage()) eventIsErrorMessage = kTRUE;
324           eventGlitchErrors += rawStream->GetGlitchErrors();
325           eventParityErrors += rawStream->GetParityErrors();
326           eventPaddingErrors += rawStream->GetPaddingErrors();
327           eventTokenlostErrors += rawStream->GetTokenLostErrors();
328           if (rawStream->GetTokenLostErrors())
329             {
330               nTokenlostErrors++;
331               const AliMUONRawStreamTrackerHP::AliBlockHeader*      blkHeader  = 0x0;
332               const AliMUONRawStreamTrackerHP::AliDspHeader*        dspHeader  = 0x0;
333               Int_t nBlock = rawStream->GetBlockCount();
334               for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++)
335                 {
336                   blkHeader = rawStream->GetBlockHeader(iBlock);
337                   //              printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
338                   Int_t nDsp = rawStream->GetDspCount(iBlock);
339                   //              printf("Block %d DSP %d\n",iBlock,nDsp);                
340                   for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++)
341                     {
342                       dspHeader =  blkHeader->GetDspHeader(iDsp);
343                       //                      printf("Dsp %d Add %X\n",iDsp,dspHeader);
344                       if (dspHeader->GetErrorWord())
345                         {
346                           Int_t ddl = rawStream->GetDDL()  ; 
347                           //     Int_t ddl = AliDAQ::DdlID("MUONTRK", rawStream->GetDDL()) - 2560 ; // format 2560 + ddl
348                           Int_t frt = (dspHeader->GetErrorWord() & 0xFFFF0000) >> 16 ; // 4*4bits right shift
349                           tabTokenError[ddl][frt]++;
350                           //     printf(" DDL %d error word %X %d %d\n",ddl,dspHeader->GetErrorWord(),frt,tabTokenError[8][4]);
351                         }
352                       
353                     }
354                 }
355             }
356         } while(rawStream->NextDDL()); 
357
358       AliMUONRawStreamTrackerHP::AliBusPatch* busPatch;
359       if (!eventIsErrorMessage) 
360         {
361           // Good events (no error) -> compute pedestal for all channels
362           rawStream->First(); 
363           nEvents++;
364           muonPedestal->SetAliNCurrentEvents(nEvents);
365           while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next())) 
366             {
367               for(int i = 0; i < busPatch->GetLength(); ++i)
368                 {
369                   busPatch->GetData(i, manuId, channelId, charge);
370                   muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
371                 }
372             }
373         }
374       else
375         {
376           // Events with errors
377           if (recoverParityErrors && eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors)
378             {
379               filcout << " ----------- Date Event recovered = " << nDateEvents <<  " ----------------" << endl;
380               // Recover parity errors -> compute pedestal for all good buspatches
381               if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(),
382                                           ATTR_ORBIT_BC )) 
383                 {
384                   filcout <<"Event recovered -> Period:"<<EVENT_ID_GET_PERIOD( rawReader->GetEventId() )
385                               <<" Orbit:"<<EVENT_ID_GET_ORBIT( rawReader->GetEventId() )
386                               <<" BunchCrossing:"<<EVENT_ID_GET_BUNCH_CROSSING( rawReader->GetEventId() )<<endl;                                
387                 } 
388               else 
389                 {
390                   filcout <<"Event recovered -> nbInRun:"<<EVENT_ID_GET_NB_IN_RUN( rawReader->GetEventId() )
391                               <<" burstNb:"<<EVENT_ID_GET_BURST_NB( rawReader->GetEventId() )
392                               <<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl;
393                 }
394               rawStream->First();
395               nEvents++;
396               muonPedestal->SetAliNCurrentEvents(nEvents);
397               while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next())) 
398                 {
399                   // Check the buspatch -> if error not use it in the pedestal calculation
400                   int errorCount = 0;
401                   for(int i = 0; i < busPatch->GetLength(); ++i)
402                     {
403                       if (!busPatch->IsParityOk(i)) errorCount++;
404                     }
405                   if (!errorCount) 
406                     {
407                       // Good buspatch
408                       for(int i = 0; i < busPatch->GetLength(); ++i)
409                         {
410                           busPatch->GetData(i, manuId, channelId, charge);
411                           muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
412                         }
413                     }
414                   else
415                     {
416                       AliMUONErrorCounter* errorCounter;
417                       // Bad buspatch -> not used (just print)
418                       filcout<<"bpId "<<busPatch->GetBusPatchId()<<" words "<<busPatch->GetLength()
419                                  <<" parity errors "<<errorCount<<endl;
420                       // Number of events where this buspatch is missing
421                       if (!(errorCounter = (AliMUONErrorCounter*) (muonPedestal->GetErrorBuspatchTable()->FindObject(busPatch->GetBusPatchId()))))
422                         {
423                           // New buspatch
424                           errorCounter = new AliMUONErrorCounter(busPatch->GetBusPatchId());
425                           muonPedestal->GetErrorBuspatchTable()->Add(errorCounter);
426                         }
427                       else
428                         {
429                           // Existing buspatch
430                           errorCounter->Increment();
431                         }       
432                       // errorCounter->Print();                                         
433                     } // end of if (!errorCount)
434                 } // end of while( (busPatch = (AliMUONRawStreamTrackerHP ...
435               //              nEvents++;
436               nEventsRecovered++;
437             } //end of if (recoverParityErrors && eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors)
438           else
439             {
440               // Fatal errors reject the event
441               detail = Form(" ----------- Date Event rejected = %d  ----------------",nDateEvents);
442               filcout << detail << endl;
443               if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(),
444                                           ATTR_ORBIT_BC )) 
445                 {
446                   filcout <<"Event rejected -> Period:"<<EVENT_ID_GET_PERIOD( rawReader->GetEventId() )
447                               <<" Orbit:"<<EVENT_ID_GET_ORBIT( rawReader->GetEventId() )
448                               <<" BunchCrossing:"<<EVENT_ID_GET_BUNCH_CROSSING( rawReader->GetEventId() )<<endl;                                
449                 } 
450               else 
451                 {
452                   filcout <<"Event rejected -> nbInRun:"<<EVENT_ID_GET_NB_IN_RUN( rawReader->GetEventId() )
453                               <<" burstNb:"<<EVENT_ID_GET_BURST_NB( rawReader->GetEventId() )
454                               <<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl;
455
456                 }
457             } // end of if (!rawStream->GetGlitchErrors() && !rawStream->GetPaddingErrors() ...
458           filcout<<"Number of errors : Glitch "<<eventGlitchErrors
459                      <<" Parity "<<eventParityErrors
460                      <<" Padding "<<eventPaddingErrors
461                      <<" Token lost "<<eventTokenlostErrors<<endl;
462           filcout<<endl;                        
463         } // end of if (!rawStream->IsErrorMessage())
464
465       if (eventGlitchErrors)  nGlitchErrors++;
466       if (eventParityErrors)  nParityErrors++;
467       if (eventPaddingErrors) nPaddingErrors++;
468       //      if (eventTokenlostErrors) nTokenlostErrors++;
469       //      muonPedestal->SetAliNCurrentEvents(nEvents);
470
471     } // while (rawReader->NextEvent())
472   delete rawReader;
473   delete rawStream;
474
475   sprintf(flatFile,"%s.ped",prefixDA);
476   if(shuttleFile.IsNull())shuttleFile=flatFile;
477   muonPedestal->SetAliNEvents(nEvents);
478   muonPedestal->SetAliRunNumber(runNumber);
479   
480   muonPedestal->Finalize();  
481   muonPedestal->MakeControlHistos();  
482   if (!shuttleFile.IsNull())  
483   {
484     ofstream out(shuttleFile.Data());  
485     muonPedestal->MakeASCIIoutput(out);
486     out.close();
487 #ifdef ALI_AMORE
488   //
489   //Send objects to the AMORE DB
490   //
491     ostringstream stringout;
492     muonPedestal->MakeASCIIoutput(stringout);
493     
494     amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
495     TObjString peddata(stringout.str().c_str());
496     Int_t amoreStatus = amoreDA.Send("Pedestals",&peddata);
497     if ( amoreStatus )
498       cout << "Warning: Failed to write Pedestals in the AMORE database : " << amoreStatus << endl;
499     else 
500       cout << "amoreDA.Send(Pedestals) ok" << endl;  
501 #else
502     cout << "Warning: MCH DA not compiled with AMORE support" << endl;
503 #endif
504     
505   }
506
507   // writing some counters
508   cout << endl;
509   cout << prefixDA << " : Nb of DATE events           = " << nDateEvents    << endl;
510   cout << prefixDA << " : Nb of Glitch errors         = "   << nGlitchErrors  << endl;
511   cout << prefixDA << " : Nb of Parity errors         = "   << nParityErrors  << endl;
512   cout << prefixDA << " : Nb of Padding errors        = "   << nPaddingErrors << endl;  
513   cout << prefixDA << " : Nb of Token lost errors     = "   << nTokenlostErrors << endl;
514   cout << prefixDA << " : Nb of events recovered      = "   << nEventsRecovered<< endl;
515   cout << prefixDA << " : Nb of events without errors = "   << nEvents-nEventsRecovered<< endl;
516   cout << prefixDA << " : Nb of events used           = "   << nEvents        << endl;
517
518   filcout << endl;
519   filcout << prefixDA << " : Nb of DATE events           = " << nDateEvents    << endl;
520   filcout << prefixDA << " : Nb of Glitch errors         = "   << nGlitchErrors << endl;
521   filcout << prefixDA << " : Nb of Parity errors         = "   << nParityErrors << endl;
522   filcout << prefixDA << " : Nb of Padding errors        = "   << nPaddingErrors << endl;
523   filcout << prefixDA << " : Nb of Token lost errors     = "   << nTokenlostErrors << endl;
524   filcout << prefixDA << " : Nb of events recovered      = "   << nEventsRecovered<< endl;      
525   filcout << prefixDA << " : Nb of events without errors = "   << nEvents-nEventsRecovered<< endl;
526   filcout << prefixDA << " : Nb of events used           = "   << nEvents        << endl;
527
528   // ouput files
529   cout << endl;
530   cout << prefixDA << " : Output logfile         : " << logOutputFile  << endl;
531   cout << prefixDA << " : Pedestal Histo file    : " << muonPedestal->GetHistoFileName() << endl;
532   cout << prefixDA << " : Ped. file (to SHUTTLE) : " << shuttleFile << endl;   
533
534   // Writing Token Error table
535   if(nTokenlostErrors)
536     {
537       char* detail=Form("\nWarning: Token Lost occurence \n");
538       printf("%s",detail);
539       filcout <<  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(" in DDL= %d (station %d) and FRT%d ( Up ) => %d Token errors (address = 0x%X0000)",2560+i,station,frt,tab,j);
550                   else detail=Form(" in DDL= %d (station %d) and FRT%d (Down) => %d Token errors (address = 0x%X0000)",2560+i,station,frt,tab,j);
551                   printf("%s\n",detail);
552                   filcout <<  detail << endl;
553                 }
554             }
555         }
556     }
557
558   filcout << endl;
559   filcout << prefixDA << " : Output logfile         : " << logOutputFile  << endl;
560   filcout << prefixDA << " : Pedestal Histo file    : " << muonPedestal->GetHistoFileName() << endl;
561   filcout << prefixDA << " : Ped. file (to SHUTTLE) : " << shuttleFile << endl;   
562
563  // Copying files to local DB folder defined by DAQ_DETDB_LOCAL
564   Char_t *dir;
565   dir= getenv("DAQ_DETDB_LOCAL");
566   unsigned int nLastVersions=50;
567   cout << "\n ***  Local DataBase: " << dir << " (Max= " << nLastVersions << ") ***" << endl;
568   status = daqDA_localDB_storeFile(muonPedestal->GetHistoFileName(),nLastVersions);
569   if(status)printf(" Store file : %s   status = %d\n",muonPedestal->GetHistoFileName(),status);
570   status = daqDA_localDB_storeFile(shuttleFile.Data(),nLastVersions);
571   if(status)printf(" Store file : %s   status = %d\n",shuttleFile.Data(),status);
572   status = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions);
573   if(status)printf(" Store file : %s   status = %d\n",logOutputFile.Data(),status);
574
575   filcout.close();
576
577   // Transferring to FES  (be sure that env variable DAQDALIB_PATH is set)
578   printf("\n *****  STORE Pedestal FILE in FES ****** \n");
579   status = daqDA_FES_storeFile(shuttleFile.Data(),"PEDESTALS");
580   if (status) { printf(" !!! Failed to export file : %s , status = %d\n",shuttleFile.Data(),status); return -1; }
581   //  else printf(" %s successfully exported to FES  \n",shuttleFile.Data());
582
583   // Transferring to FES  (be sure that env variable DAQDALIB_PATH is set)
584   printf("\n *****  STORE Configuration FILE in FES ****** \n");
585   status = daqDA_FES_storeFile(dbfile,"CONFIG");
586   if (status) { printf(" !!! Failed to export file : %s , status = %d\n",dbfile,status); return -1; }
587   //  else printf(" %s successfully exported to FES  \n",dbfile);
588
589
590   printf("\n ######## End execution : %s ######## \n",prefixDA); 
591   timers.Stop();
592   printf("\nExecution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
593   return status;
594 }