setting of eta reange (Sidharth
[u/mrichter/AliRoot.git] / MUON / MUONTRKPEDda.cxx
CommitLineData
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 -------------------------------------------------------------------------
ff496840 32 2010-07-09 New version: MUONTRKPEDda.cxx,v 1.7
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*/
45extern "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 101int main(Int_t argc, const char **argv)
dc928fbf 102{
dc928fbf 103 Int_t status=0;
104 TStopwatch timers;
105 timers.Start(kTRUE);
106
f3cfa63e 107 const char* prefixDA = "MUONTRKPEDda"; // program prefix
108 printf(" ######## Begin execution : %s ######## \n\n",prefixDA);
109
dc928fbf 110 // needed for streamer application
111 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
112 "*",
113 "TStreamerInfo",
114 "RIO",
115 "TStreamerInfo()");
dc928fbf 116 // needed for Minuit plugin
117 gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer",
118 "Minuit",
119 "TMinuitMinimizer",
120 "Minuit",
121 "TMinuitMinimizer(const char*)");
dc928fbf 122// cout << argv[0];
123
124 Int_t skipEvents = 0;
125 Int_t maxEvents = 1000000;
126 Int_t maxDateEvents = 1000000;
f3cfa63e 127 TString inputFile;
dc928fbf 128
129 Int_t nDateEvents = 0;
130 Int_t nGlitchErrors= 0;
131 Int_t nParityErrors= 0;
132 Int_t nPaddingErrors= 0;
18ec51a0 133 Int_t nTokenlostErrors= 0;
dc928fbf 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;
f9e83f1d 144 Int_t nConfig = 1;
ff496840 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)
dc928fbf 147 ofstream filcout;
dc928fbf 148
149 // decode the input line
150 for (Int_t i = 1; i < argc; i++) // argument 0 is the executable name
151 {
f3cfa63e 152 const char* arg = argv[i];
dc928fbf 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 {
f3cfa63e 160 inputFile=argv[i];
dc928fbf 161 }
162 continue;
163 }
164 switch (arg[1])
165 {
166 case 'f' :
167 i++;
f3cfa63e 168 inputFile=argv[i];
169 nConfig=0;
dc928fbf 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;
dc928fbf 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]);
f3cfa63e 191 printf("\n%s can be used locally only with options (without DiMuon configuration file)",argv[0]);
dc928fbf 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");
f3cfa63e 196 printf("\n-f <raw data file> (default = %s)",inputFile.Data());
dc928fbf 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);
dc928fbf 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
f3cfa63e 224 Char_t dbfile[256]="";
225 // nConfig=1 : Reading configuration (or not) status via "mutrkpedvalues" file located in DetDB
226 if(nConfig)
227 {
ff496840 228// Int_t maxEvts;
1ccd531d 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;
ff496840 234 filein >> nSorting;
235 // filein >> maxEvts;
236// if(maxEvts!=0)maxEvents=maxEvts;
f3cfa63e 237 }
1ccd531d 238 else printf(" *** Config= %d: no configuration ascii file is used \n",nConfig);
1b15b395 239 muonPedestal->SetconfigDA(nConfig);
f9e83f1d 240 muonPedestal->SetnEvthreshold(nEvthreshold);
ff496840 241 muonPedestal->SetnSorting(nSorting);
1b15b395 242
b9c33bca 243 // nConfig=1: configuration ascii file config_$DATE_ROLE_NAME read from DetDB
1b15b395 244 if(nConfig)
245 {
1ccd531d 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; }
b9c33bca 249 // else printf(" *** Copy ascii config file: %s from DetDB to working directory and reading ...*** \n",dbfile);
1ccd531d 250 muonPedestal->LoadConfig(dbfile);
1b15b395 251 }
252
dc928fbf 253 // Rawdeader, RawStreamHP
254 AliRawReader* rawReader = AliRawReader::Create(inputFile);
255 AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader);
18ec51a0 256// rawStream->DisableWarnings();
dc928fbf 257 rawStream->EnabbleErrorLogger();
18ec51a0 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);
f9e83f1d 263 rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kMediumErrorDetail);
264 // rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kHighErrorDetail);
dc928fbf 265
f3cfa63e 266 printf("\n %s : Reading data from file %s\n",prefixDA,inputFile.Data());
dc928fbf 267
f9e83f1d 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
dc928fbf 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;
dc928fbf 281 //Skip events
282 while (skipEvents)
283 {
284 rawReader->NextEvent();
285 skipEvents--;
286 }
dc928fbf 287 Int_t eventType = rawReader->GetType();
288 runNumber = rawReader->GetRunNumber();
289
290 // Output log file initialisations
291 if(nDateEvents==0)
292 {
5431405e 293 sprintf(flatFile,"%s.log",prefixDA);
dc928fbf 294 logOutputFile=flatFile;
18ec51a0 295 AliLog::SetStreamOutput(&filcout); // Print details on logfile
dc928fbf 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
f9e83f1d 312 const char* detail = "";
dc928fbf 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;
18ec51a0 319 int eventTokenlostErrors = 0;
dc928fbf 320 rawStream->First();
321 do
322 {
323 if (rawStream->IsErrorMessage()) eventIsErrorMessage = kTRUE;
324 eventGlitchErrors += rawStream->GetGlitchErrors();
325 eventParityErrors += rawStream->GetParityErrors();
326 eventPaddingErrors += rawStream->GetPaddingErrors();
18ec51a0 327 eventTokenlostErrors += rawStream->GetTokenLostErrors();
f9e83f1d 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 }
dc928fbf 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();
f9e83f1d 363 nEvents++;
364 muonPedestal->SetAliNCurrentEvents(nEvents);
dc928fbf 365 while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next()))
366 {
367 for(int i = 0; i < busPatch->GetLength(); ++i)
368 {
dc928fbf 369 busPatch->GetData(i, manuId, channelId, charge);
370 muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
371 }
372 }
dc928fbf 373 }
374 else
375 {
376 // Events with errors
377 if (recoverParityErrors && eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors)
378 {
18ec51a0 379 filcout << " ----------- Date Event recovered = " << nDateEvents << " ----------------" << endl;
dc928fbf 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();
f9e83f1d 395 nEvents++;
396 muonPedestal->SetAliNCurrentEvents(nEvents);
dc928fbf 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 {
dc928fbf 410 busPatch->GetData(i, manuId, channelId, charge);
dc928fbf 411 muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
412 }
413 }
414 else
415 {
dc928fbf 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
a54854fc 421 if (!(errorCounter = (AliMUONErrorCounter*) (muonPedestal->GetErrorBuspatchTable()->FindObject(busPatch->GetBusPatchId()))))
dc928fbf 422 {
423 // New buspatch
424 errorCounter = new AliMUONErrorCounter(busPatch->GetBusPatchId());
dc928fbf 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 ...
f9e83f1d 435 // nEvents++;
dc928fbf 436 nEventsRecovered++;
437 } //end of if (recoverParityErrors && eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors)
438 else
439 {
440 // Fatal errors reject the event
f9e83f1d 441 detail = Form(" ----------- Date Event rejected = %d ----------------",nDateEvents);
442 filcout << detail << endl;
dc928fbf 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
18ec51a0 460 <<" Padding "<<eventPaddingErrors
461 <<" Token lost "<<eventTokenlostErrors<<endl;
dc928fbf 462 filcout<<endl;
463 } // end of if (!rawStream->IsErrorMessage())
464
465 if (eventGlitchErrors) nGlitchErrors++;
466 if (eventParityErrors) nParityErrors++;
467 if (eventPaddingErrors) nPaddingErrors++;
f9e83f1d 468 // if (eventTokenlostErrors) nTokenlostErrors++;
469 // muonPedestal->SetAliNCurrentEvents(nEvents);
dc928fbf 470
471 } // while (rawReader->NextEvent())
472 delete rawReader;
473 delete rawStream;
474
5431405e 475 sprintf(flatFile,"%s.ped",prefixDA);
dc928fbf 476 if(shuttleFile.IsNull())shuttleFile=flatFile;
477 muonPedestal->SetAliNEvents(nEvents);
478 muonPedestal->SetAliRunNumber(runNumber);
dbbb2c64 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());
f9e83f1d 496 Int_t amoreStatus = amoreDA.Send("Pedestals",&peddata);
497 if ( amoreStatus )
498 cout << "Warning: Failed to write Pedestals in the AMORE database : " << amoreStatus << endl;
dbbb2c64 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 }
dc928fbf 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;
18ec51a0 512 cout << prefixDA << " : Nb of Padding errors = " << nPaddingErrors << endl;
513 cout << prefixDA << " : Nb of Token lost errors = " << nTokenlostErrors << endl;
dc928fbf 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;
18ec51a0 523 filcout << prefixDA << " : Nb of Token lost errors = " << nTokenlostErrors << endl;
dc928fbf 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
dc928fbf 528 // ouput files
529 cout << endl;
530 cout << prefixDA << " : Output logfile : " << logOutputFile << endl;
5431405e 531 cout << prefixDA << " : Pedestal Histo file : " << muonPedestal->GetHistoFileName() << endl;
532 cout << prefixDA << " : Ped. file (to SHUTTLE) : " << shuttleFile << endl;
dc928fbf 533
f9e83f1d 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
1dd09aa3 558 filcout << endl;
dc928fbf 559 filcout << prefixDA << " : Output logfile : " << logOutputFile << endl;
5431405e 560 filcout << prefixDA << " : Pedestal Histo file : " << muonPedestal->GetHistoFileName() << endl;
561 filcout << prefixDA << " : Ped. file (to SHUTTLE) : " << shuttleFile << endl;
dc928fbf 562
5431405e 563 // Copying files to local DB folder defined by DAQ_DETDB_LOCAL
564 Char_t *dir;
565 dir= getenv("DAQ_DETDB_LOCAL");
1ccd531d 566 unsigned int nLastVersions=50;
5431405e 567 cout << "\n *** Local DataBase: " << dir << " (Max= " << nLastVersions << ") ***" << endl;
1dd09aa3 568 status = daqDA_localDB_storeFile(muonPedestal->GetHistoFileName(),nLastVersions);
f3cfa63e 569 if(status)printf(" Store file : %s status = %d\n",muonPedestal->GetHistoFileName(),status);
1dd09aa3 570 status = daqDA_localDB_storeFile(shuttleFile.Data(),nLastVersions);
f3cfa63e 571 if(status)printf(" Store file : %s status = %d\n",shuttleFile.Data(),status);
1dd09aa3 572 status = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions);
f3cfa63e 573 if(status)printf(" Store file : %s status = %d\n",logOutputFile.Data(),status);
dc928fbf 574
f3cfa63e 575 filcout.close();
dc928fbf 576
b9c33bca 577 // Transferring to FES (be sure that env variable DAQDALIB_PATH is set)
578 printf("\n ***** STORE Pedestal FILE in FES ****** \n");
dc928fbf 579 status = daqDA_FES_storeFile(shuttleFile.Data(),"PEDESTALS");
1ccd531d 580 if (status) { printf(" !!! Failed to export file : %s , status = %d\n",shuttleFile.Data(),status); return -1; }
b9c33bca 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);
dc928fbf 588
1ccd531d 589
f3cfa63e 590 printf("\n ######## End execution : %s ######## \n",prefixDA);
dc928fbf 591 timers.Stop();
592 printf("\nExecution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
593 return status;
5431405e 594}