X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FMUONTRKPEDda.cxx;h=f390e684f43a94580865e0a7f2d955b5446abd47;hb=f43fc416d40e00681aff395a9a23627875665108;hp=c07efd54fec6548fd331488b716eb861392df799;hpb=1b15b39544641e5205a9d5a10e9d662bc133d8d4;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/MUONTRKPEDda.cxx b/MUON/MUONTRKPEDda.cxx index c07efd54fec..f390e684f43 100644 --- a/MUON/MUONTRKPEDda.cxx +++ b/MUON/MUONTRKPEDda.cxx @@ -1,13 +1,13 @@ /* -Contact: Jean-Luc Charvet -Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_Mchda -Run Type: PEDESTAL - DA Type: LDC - Number of events needed: 400 events for pedestal run - Input Files: Rawdata file (DATE format) - Output Files: local dir (not persistent) -> MUONTRKPEDda_.ped - FXS -> run<#>_MCH__PEDESTALS - Trigger types used: + Contact: Jean-Luc Charvet + Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_mchda.html + Reference Run: 109302 (station 3 only) + Run Type: PEDESTAL + DA Type: LDC + Number of events needed: 400 events for pedestal run + Input Files: mutrkpedvalues and config_ldc-MTRK-S3-0 in path : /afs/cern.ch/user/j/jcharvet/public/DA_validation + Output Files: local dir (not persistent) -> MUONTRKPEDda.ped FXS -> run<#>_MCH__PEDESTALS + Trigger types used: */ /************************************************************************** @@ -29,7 +29,7 @@ Run Type: PEDESTAL /* ------------------------------------------------------------------------- - 2009-10-06 New version: MUONTRKPEDda.cxx,v 1.3 + 2010-07-09 New version: MUONTRKPEDda.cxx,v 1.7 ------------------------------------------------------------------------- Version for MUONTRKPEDda MUON tracking @@ -65,6 +65,9 @@ extern "C" { #include "AliMpConstants.h" #include "AliRawDataErrorLog.h" #include "AliMUONTrackerIO.h" +#include "AliLog.h" +#include "AliMUONDspHeader.h" +#include "AliDAQ.h" //ROOT #include "TFile.h" @@ -93,41 +96,41 @@ extern "C" { #include "AliMUONPedestal.h" #include "AliMUONErrorCounter.h" - + // main routine -int main(Int_t argc, Char_t **argv) +int main(Int_t argc, const char **argv) { - Int_t status=0; TStopwatch timers; timers.Start(kTRUE); + const char* prefixDA = "MUONTRKPEDda"; // program prefix + printf(" ######## Begin execution : %s ######## \n\n",prefixDA); + // needed for streamer application gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo", "RIO", "TStreamerInfo()"); - // needed for Minuit plugin gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", "Minuit", "TMinuitMinimizer", "Minuit", "TMinuitMinimizer(const char*)"); - - Char_t prefixDA[256]="MUONTRKPEDda"; // program prefix // cout << argv[0]; Int_t skipEvents = 0; Int_t maxEvents = 1000000; Int_t maxDateEvents = 1000000; - Char_t inputFile[256]=""; + TString inputFile; Int_t nDateEvents = 0; Int_t nGlitchErrors= 0; Int_t nParityErrors= 0; Int_t nPaddingErrors= 0; + Int_t nTokenlostErrors= 0; Int_t recoverParityErrors = 1; TString logOutputFile; @@ -138,12 +141,15 @@ int main(Int_t argc, Char_t **argv) Int_t nEventsRecovered = 0; Int_t nEvents = 0; UInt_t runNumber = 0; + Int_t nConfig = 1; + Int_t nEvthreshold = 100; //below this nb_evt pedestal are not calculated and forced to 4085 (sigma) + Int_t nSorting = 0 ; // pedestal sorting (OFF by default) ofstream filcout; // decode the input line for (Int_t i = 1; i < argc; i++) // argument 0 is the executable name { - Char_t* arg; + const char* arg = argv[i]; arg = argv[i]; if (arg[0] != '-') @@ -151,7 +157,7 @@ int main(Int_t argc, Char_t **argv) // If only one argument and no "-" => DA calling from ECS if (argc == 2) { - sprintf(inputFile,argv[i]); + inputFile=argv[i]; } continue; } @@ -159,7 +165,8 @@ int main(Int_t argc, Char_t **argv) { case 'f' : i++; - sprintf(inputFile,argv[i]); + inputFile=argv[i]; + nConfig=0; break; case 'a' : i++; @@ -181,11 +188,12 @@ int main(Int_t argc, Char_t **argv) i++; printf("\n******************* %s usage **********************",argv[0]); printf("\nOnline (called from ECS) : %s (no inline options)\n",argv[0]); + printf("\n%s can be used locally only with options (without DiMuon configuration file)",argv[0]); printf("\n%s -options, the available options are :",argv[0]); printf("\n-h help (this screen)"); printf("\n"); printf("\n Input"); - printf("\n-f (default = %s)",inputFile); + printf("\n-f (default = %s)",inputFile.Data()); printf("\n"); printf("\n Output"); printf("\n-a (default = %s)",shuttleFile.Data()); @@ -213,35 +221,52 @@ int main(Int_t argc, Char_t **argv) AliMUONPedestal* muonPedestal = new AliMUONPedestal(); muonPedestal->SetprefixDA(prefixDA); - // Reading configuration status via "mutrkpedvalues" file located in DetDB - // config=1: config ascii file read from DetDB, otherwise: config=0 - Int_t nConfig = 1; - Char_t *dbfile; - dbfile="mutrkpedvalues"; - cout << "\n *** Copy: " << dbfile << " from DetDB to working directory *** \n" << endl; - status=daqDA_DB_getFile(dbfile,dbfile); - ifstream filein(dbfile,ios::in); - filein >> nConfig; - cout << " Config= " << nConfig << endl; + Char_t dbfile[256]=""; + // nConfig=1 : Reading configuration (or not) status via "mutrkpedvalues" file located in DetDB + if(nConfig) + { +// Int_t maxEvts; + sprintf(dbfile,"mutrkpedvalues"); + status=daqDA_DB_getFile(dbfile,dbfile); + if(status) {printf(" !!! Failed : input file %s is missing, status = %d\n",dbfile,status); return -1; } + ifstream filein(dbfile,ios::in); + filein >> nConfig; + filein >> nSorting; + // filein >> maxEvts; +// if(maxEvts!=0)maxEvents=maxEvts; + } + else printf(" *** Config= %d: no configuration ascii file is used \n",nConfig); muonPedestal->SetconfigDA(nConfig); + muonPedestal->SetnEvthreshold(nEvthreshold); + muonPedestal->SetnSorting(nSorting); + // nConfig=1: configuration ascii file config_$DATE_ROLE_NAME read from DetDB if(nConfig) { - // MuonTrk Configuration ascii file (initCROCUS.dat -> ascii file = mutrkconfig) - Char_t dbfil[256]=""; - sprintf(dbfil,"config_%s",getenv("DATE_ROLE_NAME")); - cout << "\n *** Copy ascii config file: " << dbfil << " from DetDB to working directory and reading ...*** \n" << endl; - status=daqDA_DB_getFile(dbfil,dbfil); - muonPedestal->Load_config(dbfil); + sprintf(dbfile,"config_%s",getenv("DATE_ROLE_NAME")); + status=daqDA_DB_getFile(dbfile,dbfile); + if(status) {printf(" !!! Failed : Configuration file %s is missing, status = %d\n",dbfile,status); return -1; } + // else printf(" *** Copy ascii config file: %s from DetDB to working directory and reading ...*** \n",dbfile); + muonPedestal->LoadConfig(dbfile); } // Rawdeader, RawStreamHP AliRawReader* rawReader = AliRawReader::Create(inputFile); AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader); - rawStream->DisableWarnings(); +// rawStream->DisableWarnings(); rawStream->EnabbleErrorLogger(); + // + // kLowErrorDetail, /// Logs minimal information in the error messages. + // kMediumErrorDetail, /// Logs a medium level of detail in the error messages. + // kHighErrorDetail /// Logs maximum information in the error messages. + // rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kLowErrorDetail); + rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kMediumErrorDetail); + // rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kHighErrorDetail); + + printf("\n %s : Reading data from file %s\n",prefixDA,inputFile.Data()); - cout << "\n" << prefixDA << " : Reading data from file " << inputFile << endl; + Int_t tabTokenError[20][14]; + for ( Int_t i=0 ; i<20 ; i++) { for ( Int_t j=0 ; j<14 ; j++) { tabTokenError[i][j]=0;} } while (rawReader->NextEvent()) { @@ -253,14 +278,12 @@ int main(Int_t argc, Char_t **argv) // check shutdown condition if (daqDA_checkShutdown()) break; - //Skip events while (skipEvents) { rawReader->NextEvent(); skipEvents--; } - Int_t eventType = rawReader->GetType(); runNumber = rawReader->GetRunNumber(); @@ -269,7 +292,7 @@ int main(Int_t argc, Char_t **argv) { sprintf(flatFile,"%s.log",prefixDA); logOutputFile=flatFile; - + AliLog::SetStreamOutput(&filcout); // Print details on logfile filcout.open(logOutputFile.Data()); filcout<<"//=================================================" << endl; filcout<<"// " << prefixDA << " for run = " << runNumber << endl; @@ -286,12 +309,14 @@ int main(Int_t argc, Char_t **argv) if (eventType != PHYSICS_EVENT) continue; // for the moment + const char* detail = ""; // First lopp over DDL's to find good events // Error counters per event (counters in the decoding lib are for each DDL) Bool_t eventIsErrorMessage = kFALSE; int eventGlitchErrors = 0; int eventParityErrors = 0; int eventPaddingErrors = 0; + int eventTokenlostErrors = 0; rawStream->First(); do { @@ -299,6 +324,35 @@ int main(Int_t argc, Char_t **argv) eventGlitchErrors += rawStream->GetGlitchErrors(); eventParityErrors += rawStream->GetParityErrors(); eventPaddingErrors += rawStream->GetPaddingErrors(); + eventTokenlostErrors += rawStream->GetTokenLostErrors(); + if (rawStream->GetTokenLostErrors()) + { + nTokenlostErrors++; + const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0; + const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0; + Int_t nBlock = rawStream->GetBlockCount(); + for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++) + { + blkHeader = rawStream->GetBlockHeader(iBlock); + // printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength()); + Int_t nDsp = rawStream->GetDspCount(iBlock); + // printf("Block %d DSP %d\n",iBlock,nDsp); + for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++) + { + dspHeader = blkHeader->GetDspHeader(iDsp); + // printf("Dsp %d Add %X\n",iDsp,dspHeader); + if (dspHeader->GetErrorWord()) + { + Int_t ddl = rawStream->GetDDL() ; + // Int_t ddl = AliDAQ::DdlID("MUONTRK", rawStream->GetDDL()) - 2560 ; // format 2560 + ddl + Int_t frt = (dspHeader->GetErrorWord() & 0xFFFF0000) >> 16 ; // 4*4bits right shift + tabTokenError[ddl][frt]++; + // printf(" DDL %d error word %X %d %d\n",ddl,dspHeader->GetErrorWord(),frt,tabTokenError[8][4]); + } + + } + } + } } while(rawStream->NextDDL()); AliMUONRawStreamTrackerHP::AliBusPatch* busPatch; @@ -306,6 +360,8 @@ int main(Int_t argc, Char_t **argv) { // Good events (no error) -> compute pedestal for all channels rawStream->First(); + nEvents++; + muonPedestal->SetAliNCurrentEvents(nEvents); while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next())) { for(int i = 0; i < busPatch->GetLength(); ++i) @@ -314,13 +370,13 @@ int main(Int_t argc, Char_t **argv) muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge); } } - nEvents++; } else { // Events with errors if (recoverParityErrors && eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors) { + filcout << " ----------- Date Event recovered = " << nDateEvents << " ----------------" << endl; // Recover parity errors -> compute pedestal for all good buspatches if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(), ATTR_ORBIT_BC )) @@ -336,6 +392,8 @@ int main(Int_t argc, Char_t **argv) <<" nbInBurst:"<GetEventId() )<First(); + nEvents++; + muonPedestal->SetAliNCurrentEvents(nEvents); while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next())) { // Check the buspatch -> if error not use it in the pedestal calculation @@ -374,12 +432,14 @@ int main(Int_t argc, Char_t **argv) // errorCounter->Print(); } // end of if (!errorCount) } // end of while( (busPatch = (AliMUONRawStreamTrackerHP ... - nEvents++; + // nEvents++; nEventsRecovered++; } //end of if (recoverParityErrors && eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors) else { // Fatal errors reject the event + detail = Form(" ----------- Date Event rejected = %d ----------------",nDateEvents); + filcout << detail << endl; if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(), ATTR_ORBIT_BC )) { @@ -397,13 +457,16 @@ int main(Int_t argc, Char_t **argv) } // end of if (!rawStream->GetGlitchErrors() && !rawStream->GetPaddingErrors() ... filcout<<"Number of errors : Glitch "<IsErrorMessage()) if (eventGlitchErrors) nGlitchErrors++; if (eventParityErrors) nParityErrors++; if (eventPaddingErrors) nPaddingErrors++; + // if (eventTokenlostErrors) nTokenlostErrors++; + // muonPedestal->SetAliNCurrentEvents(nEvents); } // while (rawReader->NextEvent()) delete rawReader; @@ -430,10 +493,9 @@ int main(Int_t argc, Char_t **argv) amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender); TObjString peddata(stringout.str().c_str()); - Int_t status =0; - status = amoreDA.Send("Pedestals",&peddata); - if ( status ) - cout << "Warning: Failed to write Pedestals in the AMORE database : " << status << endl; + Int_t amoreStatus = amoreDA.Send("Pedestals",&peddata); + if ( amoreStatus ) + cout << "Warning: Failed to write Pedestals in the AMORE database : " << amoreStatus << endl; else cout << "amoreDA.Send(Pedestals) ok" << endl; #else @@ -447,7 +509,8 @@ int main(Int_t argc, Char_t **argv) cout << prefixDA << " : Nb of DATE events = " << nDateEvents << endl; cout << prefixDA << " : Nb of Glitch errors = " << nGlitchErrors << endl; cout << prefixDA << " : Nb of Parity errors = " << nParityErrors << endl; - cout << prefixDA << " : Nb of Padding errors = " << nPaddingErrors << endl; + cout << prefixDA << " : Nb of Padding errors = " << nPaddingErrors << endl; + cout << prefixDA << " : Nb of Token lost errors = " << nTokenlostErrors << endl; cout << prefixDA << " : Nb of events recovered = " << nEventsRecovered<< endl; cout << prefixDA << " : Nb of events without errors = " << nEvents-nEventsRecovered<< endl; cout << prefixDA << " : Nb of events used = " << nEvents << endl; @@ -457,6 +520,7 @@ int main(Int_t argc, Char_t **argv) filcout << prefixDA << " : Nb of Glitch errors = " << nGlitchErrors << endl; filcout << prefixDA << " : Nb of Parity errors = " << nParityErrors << endl; filcout << prefixDA << " : Nb of Padding errors = " << nPaddingErrors << endl; + filcout << prefixDA << " : Nb of Token lost errors = " << nTokenlostErrors << endl; filcout << prefixDA << " : Nb of events recovered = " << nEventsRecovered<< endl; filcout << prefixDA << " : Nb of events without errors = " << nEvents-nEventsRecovered<< endl; filcout << prefixDA << " : Nb of events used = " << nEvents << endl; @@ -467,6 +531,30 @@ int main(Int_t argc, Char_t **argv) cout << prefixDA << " : Pedestal Histo file : " << muonPedestal->GetHistoFileName() << endl; cout << prefixDA << " : Ped. file (to SHUTTLE) : " << shuttleFile << endl; + // Writing Token Error table + if(nTokenlostErrors) + { + char* detail=Form("\nWarning: Token Lost occurence \n"); + printf("%s",detail); + filcout << detail ; + for ( Int_t i=0 ; i<20 ; i++) + { + for ( Int_t j=4 ; j<14 ; j++) + { + if(tabTokenError[i][j]>0) + { + Int_t tab=tabTokenError[i][j]; + Int_t frt=j/2-1; + Int_t station = i/4 +1; + 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); + else detail=Form(" in DDL= %d (station %d) and FRT%d (Down) => %d Token errors (address = 0x%X0000)",2560+i,station,frt,tab,j); + printf("%s\n",detail); + filcout << detail << endl; + } + } + } + } + filcout << endl; filcout << prefixDA << " : Output logfile : " << logOutputFile << endl; filcout << prefixDA << " : Pedestal Histo file : " << muonPedestal->GetHistoFileName() << endl; @@ -475,29 +563,31 @@ int main(Int_t argc, Char_t **argv) // Copying files to local DB folder defined by DAQ_DETDB_LOCAL Char_t *dir; dir= getenv("DAQ_DETDB_LOCAL"); - unsigned int nLastVersions=90; + unsigned int nLastVersions=50; cout << "\n *** Local DataBase: " << dir << " (Max= " << nLastVersions << ") ***" << endl; status = daqDA_localDB_storeFile(muonPedestal->GetHistoFileName(),nLastVersions); - printf(" Store file : %s status = %d\n",muonPedestal->GetHistoFileName(),status); + if(status)printf(" Store file : %s status = %d\n",muonPedestal->GetHistoFileName(),status); status = daqDA_localDB_storeFile(shuttleFile.Data(),nLastVersions); - printf(" Store file : %s status = %d\n",shuttleFile.Data(),status); + if(status)printf(" Store file : %s status = %d\n",shuttleFile.Data(),status); status = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions); - printf(" Store file : %s status = %d\n",logOutputFile.Data(),status); - - // Transferring to OCDB via the SHUTTLE - printf("\n ***** STORE FILE in FES ****** \n"); + if(status)printf(" Store file : %s status = %d\n",logOutputFile.Data(),status); - // be sure that env variable DAQDALIB_PATH is set in script file - // gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger"); + filcout.close(); + // Transferring to FES (be sure that env variable DAQDALIB_PATH is set) + printf("\n ***** STORE Pedestal FILE in FES ****** \n"); status = daqDA_FES_storeFile(shuttleFile.Data(),"PEDESTALS"); - if (status) - { - printf(" Failed to export file : %d\n",status); - } - else printf(" %s successfully exported to FES \n",shuttleFile.Data()); + if (status) { printf(" !!! Failed to export file : %s , status = %d\n",shuttleFile.Data(),status); return -1; } + // else printf(" %s successfully exported to FES \n",shuttleFile.Data()); - filcout.close(); + // Transferring to FES (be sure that env variable DAQDALIB_PATH is set) + printf("\n ***** STORE Configuration FILE in FES ****** \n"); + status = daqDA_FES_storeFile(dbfile,"CONFIG"); + if (status) { printf(" !!! Failed to export file : %s , status = %d\n",dbfile,status); return -1; } + // else printf(" %s successfully exported to FES \n",dbfile); + + + printf("\n ######## End execution : %s ######## \n",prefixDA); timers.Stop(); printf("\nExecution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime()); return status;