From: ivana Date: Mon, 5 Mar 2012 09:36:27 +0000 (+0000) Subject: In DAs: X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=9c2d4e89fc809c5428a52a0d3f1390df4deb916e;hp=d391281b6c9fe7c46748ae7f478fdecf5dc87d9e In DAs: - Setting DA error return code (0 = OK, if not 0 => warning or error messages are written in infobrowser) - Pedestal and gain files transferred first to FES and then to Amore DB (it was the opposite previously) - Adding some new counters to better check DA processes (Jean-Luc) --- diff --git a/MUON/AliMUONGain.cxx b/MUON/AliMUONGain.cxx index 46455d0fadd..0db771274bb 100644 --- a/MUON/AliMUONGain.cxx +++ b/MUON/AliMUONGain.cxx @@ -166,7 +166,7 @@ void AliMUONGain::MakePedStoreForGain(TString shuttleFile) // compute and store mean DAC values (like pedestals) flatFile = Form("%s.ped",fPrefixDA.Data()); outputFile=flatFile; - cout << "\n" << fPrefixDA.Data() << " : Flat file generated : " << flatFile.Data() << "\n"; + cout << "\n" << fPrefixLDC.Data() << " : Flat file generated : " << flatFile.Data() << "\n"; if (!outputFile.IsNull()) { ofstream out(outputFile.Data()); @@ -260,11 +260,13 @@ TString AliMUONGain::WriteGainData(Int_t BP, Int_t Manu, Int_t ch, Double_t p1, //_______________________________________________________________________________ void AliMUONGain::MakeGainStore(TString shuttleFile) { + Int_t status=0; /// Store gains in ASCII files ofstream fileout; ofstream filcouc; TString tempstring; TString filename; + char* detail; Double_t goodA1Min = 0.5; Double_t goodA1Max = 2.; @@ -317,27 +319,23 @@ void AliMUONGain::MakeGainStore(TString shuttleFile) Double_t injChargeErr[11]; for ( Int_t i=0 ; i<11 ; i++) {injCharge[i]=0.;injChargeErr[i]=1.;}; - // some print - cout<<"\n ******** MUONTRKGAINda for Gain computing (Last Run = " << fRunNumber << ") ********\n" << endl; - cout<<" * Date : " << fDate->AsString("l") << "\n" << endl; - cout << " Entries = " << nEntries << " DAC values \n" << endl; - for (Int_t i = 0; i < nEntries; ++i) { - cout<< " Run = " << run[i]->GetFirst() << " DAC = " << run[i]->GetSecond() << endl; - numrun[i] = run[i]->GetFirst(); - injCharge[i] = run[i]->GetSecond(); - injChargeErr[i] = 0.01*injCharge[i]; - if(injChargeErr[i] <= 1.) injChargeErr[i]=1.; - } - cout << "" << endl; - // print out in .log file - + detail=Form("\n%s : ------ MUONTRKGAINda for Gain computing (Last Run = %d) ------\n",fPrefixLDC.Data(),fRunNumber); printf("%s",detail); (*fFilcout)<<"\n\n//=================================================" << endl; (*fFilcout)<<"// MUONTRKGAINda: Gain Computing Run = " << fRunNumber << endl; (*fFilcout)<<"// RootDataFile = "<< fRootDataFileName.Data() << endl; (*fFilcout)<<"//=================================================" << endl; (*fFilcout)<<"//* Date : " << fDate->AsString("l") << "\n" << endl; + (*fFilcout) << " Entries = " << nEntries << " DAC values \n" << endl; + for (Int_t i = 0; i < nEntries; ++i) { + (*fFilcout) << " Run = " << run[i]->GetFirst() << " DAC = " << run[i]->GetSecond() << endl; + numrun[i] = run[i]->GetFirst(); + injCharge[i] = run[i]->GetSecond(); + injChargeErr[i] = 0.01*injCharge[i]; + if(injChargeErr[i] <= 1.) injChargeErr[i]=1.; + } + detail=Form("%s : .... Fitting .... \n",fPrefixLDC.Data()); printf("%s",detail); // why 2 files ? (Ch. F.) => second file contains detailed results @@ -345,7 +343,8 @@ void AliMUONGain::MakeGainStore(TString shuttleFile) if(fPrintLevel>1) { filename=Form("%s.param",fPrefixDA.Data()); - cout << " Second fit parameter file = " << filename.Data() << "\n"; + detail=Form("%s : Second fit parameter file = %s\n",fPrefixLDC.Data(),filename.Data()); printf("%s",detail); + // cout << " Second fit parameter file = " << filename.Data() << "\n"; pfilen = fopen (filename.Data(),"w"); fprintf(pfilen,"//===================================================================\n"); @@ -368,7 +367,8 @@ void AliMUONGain::MakeGainStore(TString shuttleFile) if(fPrintLevel>1) { filename=Form("%s.peak",fPrefixDA.Data()); - cout << " File containing Peak mean values = " << filename << "\n"; + detail=Form("%s : File containing Peak mean values = %s\n",fPrefixLDC.Data(),filename.Data()); printf("%s",detail); + // cout << " File containing Peak mean values = " << filename << "\n"; pfilep = fopen (filename,"w"); fprintf(pfilep,"//==============================================================================================================================\n"); @@ -482,9 +482,7 @@ void AliMUONGain::MakeGainStore(TString shuttleFile) fprintf(pfilep," sig= %9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f \n",pedSigma[0],pedSigma[1],pedSigma[2],pedSigma[3],pedSigma[4],pedSigma[5],pedSigma[6],pedSigma[7],pedSigma[8],pedSigma[9],pedSigma[10]); } - // makegain - - + // makegain // Fit Method: Linear fit over gAlinbpf1 points + parabolic fit over nbpf2 points) // nInit=1 : 1st pt DAC=0 excluded @@ -683,7 +681,7 @@ void AliMUONGain::MakeGainStore(TString shuttleFile) } nmanu++; Int_t step=500; - if(nmanu % step == 0)std::cout << " Nb manu = " << nmanu << std::endl; + if(nmanu % step == 0)printf("%s : Nb manu = %d\n",fPrefixLDC.Data(),nmanu); } // print in logfile @@ -706,44 +704,43 @@ void AliMUONGain::MakeGainStore(TString shuttleFile) (*fFilcout) << " Number of bad calibrated channel = " << uncalcountertotal << endl; } - - - (*fFilcout) << "\n Nb of channels in raw data = " << nmanu*64 << " (" << nmanu << " Manu)" << endl; - (*fFilcout) << " Nb of calibrated channel = " << nGoodChannel << " (" << goodA1Min << " ratio_limit) { status=-1; + detail=Form("\n%s : !!!!! WARNING : Nb of uncalibrated channels very large : %6.4f > %6.4f (status= %d) ",fPrefixLDC.Data(),ratio,ratio_limit,status); + (*fFilcout) << detail ; printf("%s",detail); + } + Double_t meanA1 = sumA1/(nGoodChannel); Double_t meanProbChi2 = sumProbChi2/(nGoodChannel); Double_t meanA2 = sumA2/(nGoodChannel); Double_t meanProbChi2P2 = sumProbChi2P2/(nGoodChannel); - Double_t capaManu = 0.2; // pF - (*fFilcout) << "\n linear fit : = " << meanA1 << "\t = " << 1./(meanA1*capaManu) + (*fFilcout) << "\n linear fit : = " << meanA1 << " Prob(chi2)> = " << meanProbChi2 << " = " << 1./(meanA1*capaManu) << " mV/fC (capa= " << capaManu << " pF)" << endl; - (*fFilcout) << " Prob(chi2)> = " << meanProbChi2 << endl; - (*fFilcout) << "\n parabolic fit: = " << meanA2 << endl; - (*fFilcout) << " Prob(chi2)> = " << meanProbChi2P2 << "\n" << endl; - - cout << "\n = " << 1./(meanA1*capaManu) - << " mV/fC (capa= " << capaManu << " pF)" - << " Prob(chi2)> = " << meanProbChi2 << endl; + (*fFilcout) <<" parabolic fit: = " << meanA2 << " Prob(chi2)> = " << meanProbChi2P2 << "\n" << endl; + + detail=Form("\n%s : = %7.5f mV/fC (capa= %3.1f pF) Prob(chi2) = %5.3f\n" ,fPrefixLDC.Data(),1./(meanA1*capaManu),capaManu,meanProbChi2); + printf("%s",detail); } else - { - (*fFilcout) << "\n !!!!! BIG PROBLEM: Nb of calibrated channel = " << nGoodChannel << " !!!!! \n" << endl; - cout << "\n !!!!! BIG PROBLEM: Nb of calibrated channel = " << nGoodChannel << " !!!!! \n" << endl; + { status=-1; + detail=Form("\n%s : !!!!! ERROR : Nb of Manu = %d or Nb calibrated channel = %d !!!!! (status= %d)\n",fPrefixLDC.Data(),nmanu,nGoodChannel,status); + (*fFilcout) << detail ; printf("%s",detail); } - pfilew.close(); if(fPlotLevel>0){tg->Write();histoFile->Close();} if(fPrintLevel>1){fclose(pfilep); fclose(pfilen);} + SetStatusDA(status); } diff --git a/MUON/AliMUONPedestal.cxx b/MUON/AliMUONPedestal.cxx index 2afe06f0142..5abbc0b7bc1 100644 --- a/MUON/AliMUONPedestal.cxx +++ b/MUON/AliMUONPedestal.cxx @@ -60,6 +60,7 @@ fNChannel(0), fNManu(0), fNManuConfig(0), fConfig(1), +fStatusDA(0), fErrorBuspatchTable(new AliMUON2DMap(kFALSE)), fManuBuspatchTable(new AliMUON2DMap(kFALSE)), fManuBPoutofconfigTable(new AliMUON2DMap(kFALSE)), @@ -68,11 +69,11 @@ fFilcout(0), fHistoFileName(), fPedestalStore(new AliMUON2DMap(kTRUE)), fIndex(-1), -fPrefixDA() +fPrefixDA(), +fPrefixLDC() { /// Default constructor } - //______________________________________________________________________________ AliMUONPedestal::AliMUONPedestal(TRootIOCtor* /*dummy*/) : TObject(), @@ -86,6 +87,7 @@ fNChannel(0), fNManu(0), fNManuConfig(0), fConfig(1), +fStatusDA(0), fErrorBuspatchTable(0), fManuBuspatchTable(0), fManuBPoutofconfigTable(0), @@ -94,7 +96,8 @@ fFilcout(0), fHistoFileName(), fPedestalStore(0), fIndex(-1), -fPrefixDA() +fPrefixDA(), +fPrefixLDC() { /// Root IO constructor } @@ -163,10 +166,10 @@ void AliMUONPedestal::MakePed(Int_t busPatchId, Int_t manuId, Int_t channelId, I { // Fill out_of_config (buspatch,manu) table if (!(static_cast(fManuBPoutofconfigTable->FindObject(busPatchId,manuId)))) fManuBPoutofconfigTable->Add(new AliMUONErrorCounter(busPatchId,manuId)); - if(warn<10) cout << " !!! WARNING : busPatchId = " << busPatchId << " manuId = " << manuId << " not in the Detector configuration " << endl; - else if(warn==10) cout << " !!! see .log file for an exhaustive list of (busPatchId, manuId) out of Detector configuration \n" << endl; + if(warn<10) cout << fPrefixLDC.Data() << " : !!! WARNING : busPatchId = " << busPatchId << " manuId = " << manuId << " not in the Detector configuration " << endl; + else if(warn==10) cout << fPrefixLDC.Data() << " : !!! see .log file for an exhaustive list of (busPatchId, manuId) out of Detector configuration \n" << endl; warn++; - (*fFilcout) << " !!! WARNING : busPatchId = " << busPatchId << " manuId = " << manuId << " not in the Detector configuration " << endl; + (*fFilcout) <<" !!! WARNING : busPatchId = " << busPatchId << " manuId = " << manuId << " not in the Detector configuration " << endl; } else {fNManu++;} fNChannel+=64; @@ -213,21 +216,22 @@ void AliMUONPedestal::Finalize() Int_t busPatchId; Int_t manuId; Int_t channelId; + Int_t status=0; // print in logfile if (fErrorBuspatchTable->GetSize()) { - cout<<"\nWarning: Buspatches with less statistics (due to parity errors)"<CreateIterator()); AliMUONErrorCounter* parityerror; while((parityerror = static_cast(nextParityError()))) { - cout<<" bp "<BusPatch()<<": events used = "<Events()<BusPatch()<<": events used = "<Events()<BusPatch()<<": used events = "<Events()<BusPatch()<<": used events = "<Events()<ID1(); if(manuId==0) { - cout << "Warning: ManuId = " << manuId << " !!! in BP = " << busPatchId << endl; + cout << fPrefixLDC.Data() << " : Warning: ManuId = " << manuId << " !!! in BP = " << busPatchId << endl; (*fFilcout) << "Warning: ManuId = " << manuId << " !!! in BP = " << busPatchId << endl; } Int_t eventCounter; @@ -261,20 +265,20 @@ void AliMUONPedestal::Finalize() if(eventCounter>0)occupancy = manuCounter->Events()/64/eventCounter; if(occupancy>1) { - cout << "Warning: ManuId = " << manuId << " !!! in BP = " << busPatchId << " occupancy (>1) = " << occupancy << endl; + cout << fPrefixLDC.Data() << " : Warning: ManuId = " << manuId << " !!! in BP = " << busPatchId << " occupancy (>1) = " << occupancy << endl; (*fFilcout) << "Warning: ManuId = " << manuId << " !!! in BP = " << busPatchId << " occupancy (>1) = " << occupancy <Size() ; ++channelId) { - pedMean = ped->ValueAsDouble(channelId, 0); + pedMean = ped->ValueAsDouble(channelId, 0); if (pedMean >= 0) // connected channels { ped->SetValueAsDouble(channelId, 0, pedMean/(Double_t)eventCounter); pedMean = ped->ValueAsDouble(channelId, 0); pedSigma = ped->ValueAsDouble(channelId, 1); - ped->SetValueAsDouble(channelId, 1, TMath::Sqrt(TMath::Abs(pedSigma/(Double_t)eventCounter - pedMean*pedMean))); + ped->SetValueAsDouble(channelId, 1, TMath::Sqrt(TMath::Abs(pedSigma/(Double_t)eventCounter - pedMean*pedMean))); if(eventCounter < fNEvthreshold ) { nADCmax++; ped->SetValueAsDouble(channelId, 0, ADCMax()); @@ -292,19 +296,39 @@ void AliMUONPedestal::Finalize() ped->SetValueAsDouble(channelId, 1, ADCMax());} } } - if(nADCmax>0) - { char* detail=Form("Warning: Nb of Channels with bad Pedestal (Ped=4095) = %d over %d",nADCmax,fNChannel); - printf("%s\n",detail); - (*fFilcout) << detail << endl; } - if(nADC4090>0) - { char* detail=Form("Warning: Nb of Channels with PedSigma<0.5 (Ped=4090) = %d over %d",nADC4090,fNChannel); - printf("%s\n",detail); - (*fFilcout) << detail << endl; } + + float frac1=0. , frac2=0. ; + float frac_badped = 0.25 ; // maximal acceptable ratio of bad pedestals + char* detail; + + if(fNChannel) + { + if(nADCmax>0) + { frac1 = float(nADCmax)/float(fNChannel); + detail=Form("%s : Warning: Nb of Channels with bad Pedestal (Ped=4095) = %d over %d (%6.4f)",fPrefixLDC.Data(),nADCmax,fNChannel,frac1); + printf("%s\n",detail); + (*fFilcout) << detail << endl;} + + if(nADC4090>0) + { frac2 = 1.*nADC4090/fNChannel; + detail=Form("%s : Warning: Nb of Channels with PedSigma<0.5 (Ped=4090) = %d over %d (%6.4f)",fPrefixLDC.Data(),nADC4090,fNChannel,frac2); + printf("%s\n",detail); + (*fFilcout) << detail << endl; } + + if (frac1+frac2 > frac_badped) { status=-1 ; + detail=Form("\n%s !!! ERROR : fraction of Channels with Pedestal>=4090 = %6.4f (> %5.3f) (status= %d) \n",fPrefixLDC.Data(),frac1+frac2,frac_badped,status); + (*fFilcout) << detail << endl; printf("%s",detail) ;} + } + else { status= -1; + detail=Form("\n%s !!! ERROR : Nb good channel = 0 (all pedestals are forced to 4095) !!! (status= %d)\n",fPrefixLDC.Data(),status); + cout << detail; (*fFilcout) << detail ;} + + SetStatusDA(status); } //______________________________________________________________________________ void AliMUONPedestal::MakeASCIIoutput(ostream& out) const { - /// put pedestal store in the output stream +/// put pedestal store in the output stream out<<"//===========================================================================" << endl; out<<"// Pedestal file calculated by "<< fPrefixDA.Data() << endl; @@ -380,7 +404,7 @@ void AliMUONPedestal::MakeASCIIoutput(ostream& out) const // Sorting if (fSorting) { - cout << " ..... sorting pedestal values ....." << endl; + printf("%s : ..... sorting pedestal values .....\n",fPrefixLDC.Data()); THashList pedtable(100,2); while ( ( ped = dynamic_cast(next() ) ) ) { diff --git a/MUON/AliMUONPedestal.h b/MUON/AliMUONPedestal.h index 1ffb8b0fee6..2858958e808 100644 --- a/MUON/AliMUONPedestal.h +++ b/MUON/AliMUONPedestal.h @@ -55,11 +55,17 @@ class AliMUONPedestal : public TObject void SetconfigDA(Int_t ind) {fConfig = ind;} /// set Nb of evt threshold to calculate pedestal void SetnEvthreshold(Int_t ind) {fNEvthreshold = ind;} + /// set DA status (return code) + void SetStatusDA(Int_t ind) {fStatusDA = ind;} + /// get DA status (return code) + Int_t GetStatusDA() const {return fStatusDA;} /// sorting flag void SetnSorting(Int_t ind) {fSorting = ind;} /// set specific DA prefixname void SetprefixDA(const char* folder) { fPrefixDA=folder;} - /// set the index of calibration runs + /// set specific LDC prefixname + void SetprefixLDC(const char* folder) { fPrefixLDC=folder;} + /// set the index of calibration runs void SetAliIndex(Int_t ind) {fIndex = ind;} /// Compute the pedestal data (mean, sigma) void Finalize(); @@ -68,7 +74,7 @@ class AliMUONPedestal : public TObject /// Fill Histograms void MakeControlHistos(); - Int_t ADCMax() const { return 4095; } + Int_t ADCMax() const { return 4095; } protected: // Int_t fN; ///< @@ -81,6 +87,7 @@ protected: Int_t fNManu; ///< Nb of Manu Int_t fNManuConfig; ///< Nb of Manu in the current detector configuration Int_t fConfig; ///< flag 1(0) for reading(or not) configuration ascii file + Int_t fStatusDA; ///< DA return code (0=OK) AliMUONVStore* fErrorBuspatchTable; ///< Table for buspatches with parity errors AliMUONVStore* fManuBuspatchTable; ///< Occupancy rate for each (buspatch, manu) AliMUONVStore* fManuBPoutofconfigTable; ///< (buspatch, manu) out of config @@ -91,6 +98,7 @@ protected: AliMUONVStore* fPedestalStore; ///< data container: (Pedmean,sigma) values for each (BP,manuId) Int_t fIndex; ///< calibration run index TString fPrefixDA; ///< specific DA prefixname + TString fPrefixLDC; ///< specific LDC prefixname static const Int_t fgkADCMax; ///< max channel count diff --git a/MUON/MUONTRKGAINda.cxx b/MUON/MUONTRKGAINda.cxx index c49d9883a50..5c5d1b88ada 100644 --- a/MUON/MUONTRKGAINda.cxx +++ b/MUON/MUONTRKGAINda.cxx @@ -41,7 +41,7 @@ /* ------------------------------------------------------------------------- - 2010-04-18 New version: MUONTRKGAINda.cxx,v 1.6 + 2012-02-29 New version: MUONTRKGAINda.cxx,v 1.7 ------------------------------------------------------------------------- Version for MUONTRKGAINda MUON tracking @@ -111,12 +111,17 @@ extern "C" { // main routine int main(Int_t argc, const char** argv) { - Int_t status=0; + Int_t status=0 , status1=0 ; TStopwatch timers; timers.Start(kTRUE); const char* prefixDA = "MUONTRKGAINda"; // program prefix - printf(" ######## Begin execution : %s ######## \n\n",prefixDA); + const char* prefixLDC = getenv("DATE_ROLE_NAME"); // LDC name + if(prefixLDC == NULL) prefixLDC ="MCH" ; + printf("%s : -------- Begin execution : %s -------- \n",prefixLDC,prefixDA); + + // const char* prefixDA = "MUONTRKGAINda"; // program prefix + // printf(" ######## Begin execution : %s ######## \n\n",prefixDA); TString inputFile; // decode the input line @@ -141,15 +146,18 @@ int main(Int_t argc, const char** argv) Int_t maxDateEvents = 1000000; Int_t nDateEvents = 0; + Int_t nDateRejEvents = 0; Int_t nGlitchErrors= 0; Int_t nParityErrors= 0; Int_t nPaddingErrors= 0; Int_t nTokenlostErrors= 0; Int_t nEventsRecovered = 0; Int_t nEvents = 0; - Int_t nEvthreshold = 10; //below this nb_evt the mean of the charge is not calculated and forced to 4085 (sigma) + Int_t nEvthreshold = 50; //below this nb_evt the mean of the charge is not calculated and forced to 4085 (sigma) + Int_t statusDA = 0 ; // DA return code TString logOutputFile; + Char_t* detail; Char_t flatFile[256]=""; TString shuttleFile; @@ -159,8 +167,8 @@ int main(Int_t argc, const char** argv) // For DA Gain Int_t nEntries = daqDA_ECS_getTotalIteration(); // usually = 11 = Nb of calibration runs - Int_t nInit=1; // = 0 all DAC values ; = 1 DAC=0 excluded (default=1) - Int_t nbpf1=6; // nb of points for linear fit (default=6) + Int_t nInit=0; // = 0 all DAC values ; = 1 DAC=0 excluded (default=1) + Int_t nbpf1=4; // nb of points for linear fit (default=6) Int_t printLevel = 0; // printout (default=0, =1 =>.ped , => .peak & .param) Int_t plotLevel = 1; // plotout (default=1 => tree , =2 tree+Tgraph+fit) Int_t nbev=0; @@ -173,8 +181,25 @@ int main(Int_t argc, const char** argv) //Gain object AliMUONGain* muonGain = new AliMUONGain(); muonGain->SetprefixDA(prefixDA); + muonGain->SetprefixLDC(prefixLDC); muonGain->SetAliRootDataFileName(); // MUONTRKGAINda_data.root - + muonGain->SetStatusDA(statusDA); + + // Output log file initialisations + sprintf(flatFile,"%s.log",prefixDA); + logOutputFile=flatFile; + AliLog::SetStreamOutput(&filcout); // Print details on logfile + filcout.open(logOutputFile.Data()); + filcout<<"//=================================================" << endl; + filcout<<"//" << prefixLDC << " " << prefixDA << endl; + filcout<<"//=================================================" << endl; + filcout<<"// * Date : " << muonGain->GetDate()->AsString("l") << "\n" << endl; + + muonGain->SetAlifilcout(&filcout); + cout<GetDate()->AsString("l") << "\n" << endl; + + + UShort_t manuId; UChar_t channelId; UShort_t charge; @@ -184,6 +209,8 @@ int main(Int_t argc, const char** argv) Int_t nConfig = 1; // flag to read or not configuration ascii file in detDB Int_t vDAC[11]; // DAC values Char_t dbfile[256]=""; + Int_t nEvthres; + Char_t line[80]; sprintf(dbfile,"mutrkcalibvalues"); status=daqDA_DB_getFile(dbfile,dbfile); if(status) {printf(" Failed : input file %s is missing, status = %d\n",dbfile,status); return -1; } @@ -192,23 +219,22 @@ int main(Int_t argc, const char** argv) while (k> kk >> vDAC[k] ; k++; } injCharge=vDAC[nIndex-1]; - filein >> nInit; // = 0 all DAC values fitted ; = 1 DAC=0 excluded (default=1) - filein >> nbpf1; // nb of points for linear fit (default=6) - filein >> printLevel; // printout (default=0, =1 =>.ped /run, =2 => .peak & .param) - filein >> plotLevel; // plotout (default=1 => tree , =2 tree+Tgraph+fit) - filein >> nConfig; //nConfig (default=1 => read config in DetDB, otherwise =0) - filein >> nbev; // Nb of events to read (default = 0 => reading all events) - if(nbev>0)maxEvents=nbev; - - // printf(" *** Copy: %s from DetDB to working directory *** Config= %d\n",dbfile,nConfig); - printf(" Input parameters: nInit= %d Nb linear pts= %d Print level= %d Plot Level= %d nConfig= %d",nInit,nbpf1,printLevel,plotLevel,nConfig); - if(nbev==0)printf("\n"); - else printf(" Nb_max evt = %d\n",maxEvents); + filein >> nInit >> line ; cout << "mutrkcalibvalues: " << line << "=" << nInit << " " ; // = 0 all DAC values fitted ; = 1 DAC=0 excluded (default=1) + filein >> nbpf1 >> line ; cout << line << "=" << nbpf1 << " " ; // nb of points for linear fit (default=6) + filein >> printLevel >> line; cout << line << "=" << printLevel << " " ; // printout (default=0, =1 =>.ped /run, =2 => .peak & .param) + filein >> plotLevel >> line; cout << line << "=" << plotLevel << " " ; // plotout (default=1 => tree , =2 tree+Tgraph+fit) + filein >> nConfig >> line; cout << line << "=" << nConfig << " " ; //nConfig (default=1 => read config in DetDB, otherwise =0) + filein >> nEvthres >> line ; + if(nEvthres !=0)nEvthreshold=nEvthres; cout << line << "=" << nEvthreshold << " " ; // (default = 0 <=> 50) below nEvthreshold calibration not performed + filein >> nbev >> line; // Nb of events to read (default = 0 => reading all events) + if(nbev !=0){maxEvents=nbev; cout << line << "=" << maxEvents << " " ;} + cout << endl; muonGain->SetAliPrintLevel(printLevel); muonGain->SetAliPlotLevel(plotLevel); muonGain->SetconfigDA(nConfig); muonGain->SetnEvthreshold(nEvthreshold); + // muonGain->SetStatusDA(statusDA); if(nConfig) { @@ -233,17 +259,20 @@ int main(Int_t argc, const char** argv) rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kMediumErrorDetail); // rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kHighErrorDetail); - cout << "\n" << prefixDA << " : Reading data from file " << inputFile.Data() << endl; + printf("\n%s : Reading data from file %s\n",prefixLDC,inputFile.Data()); 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()) { + Int_t eventType = rawReader->GetType(); + runNumber = rawReader->GetRunNumber(); + if(nDateEvents==0) { filcout<<"// ----> RUN = " << runNumber << "\n" << endl;} if (nDateEvents >= maxDateEvents) break; if (nEvents >= maxEvents) break; if (nDateEvents>0 && nDateEvents % 100 == 0) - cout<<"Cumulated: DATE events = " << nDateEvents << " Used events = " << nEvents << endl; + cout<< prefixLDC << " : DATE events = " << nDateEvents << " Used events = " << nEvents << endl; // check shutdown condition if (daqDA_checkShutdown()) @@ -254,27 +283,6 @@ int main(Int_t argc, const char** argv) rawReader->NextEvent(); skipEvents--; } - Int_t eventType = rawReader->GetType(); - runNumber = rawReader->GetRunNumber(); - - // Output log file initialisations - if(nDateEvents==0) - { - 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 << " (DAC=" << injCharge << ")" << endl; - filcout<<"//=================================================" << endl; - filcout<<"// * Date : " << muonGain->GetDate()->AsString("l") << "\n" << endl; - - cout<<"\n ******** " << prefixDA << " for run = " << runNumber << " (Index= " << nIndex << "/" << nEntries << " DAC=" << injCharge << ") ********\n" << endl; - cout<<" * Date : " << muonGain->GetDate()->AsString("l") << "\n" << endl; - } - - muonGain->SetAlifilcout(&filcout); - nDateEvents++; if (eventType != PHYSICS_EVENT) continue; // for the moment @@ -412,6 +420,7 @@ int main(Int_t argc, const char** argv) { // Fatal errors reject the event detail = Form(" ----------- Date Event rejected = %d ----------------",nDateEvents); + nDateRejEvents++; filcout << detail << endl; if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(), ATTR_ORBIT_BC )) @@ -454,28 +463,16 @@ int main(Int_t argc, const char** argv) muonGain->SetAliRunNumber(runNumber); muonGain->MakePedStoreForGain(shuttleFile); - - // writing some counters - cout << endl; - 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 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; - - filcout << endl; - filcout << prefixDA << " : Nb of DATE events = " << nDateEvents << endl; - 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; - + // writing some counters + detail=Form("\n%s : Nb of DATE events = %d",prefixLDC,nDateEvents) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of Glitch errors = %d",prefixLDC,nGlitchErrors) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of Parity errors = %d",prefixLDC,nParityErrors) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of Token lost errors = %d",prefixLDC,nTokenlostErrors) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of Rejected DATE events = %d",prefixLDC,nDateRejEvents) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of recovered events = %d",prefixLDC,nEventsRecovered) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of events without errors = %d",prefixLDC,nEvents-nEventsRecovered) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of used events = %d (threshold= %d)\n\n",prefixLDC,nEvents,nEvthreshold); cout << detail; filcout << detail ; + // Writing Token Error table if(nTokenlostErrors) { @@ -507,71 +504,66 @@ int main(Int_t argc, const char** argv) muonGain->SetAliEntries(nEntries); // fnEntries muonGain->SetAliNbpf1(nbpf1); // fnbpf1 muonGain->MakeGainStore(shuttleFile); -#ifdef ALI_AMORE - std::ifstream in(shuttleFile.Data()); - ostringstream stringout; - char line[1024]; - while ( in.getline(line,1024) ) - stringout << line << "\n"; - in.close(); - - amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender); - TObjString gaindata(stringout.str().c_str()); - status = amoreDA.Send("Gains",&gaindata); - if ( status ) - cout << "Warning: Failed to write Pedestals in the AMORE database : " << status << endl; - else - cout << "amoreDA.Send(Gains) ok" << endl; -#else - cout << "Warning: MCH DA not compiled with AMORE support" << endl; -#endif + status = muonGain->GetStatusDA() ; } // ouput files - filcout << endl; - filcout << prefixDA << " : Root data file : " << muonGain->GetRootDataFileName() << endl; - filcout << prefixDA << " : Output logfile : " << logOutputFile << endl; - filcout << prefixDA << " : Gain Histo file : " << muonGain->GetHistoFileName() << endl; - filcout << prefixDA << " : Gain file (to SHUTTLE) : " << shuttleFile << endl; - - // Copying files to local DB folder defined by DAQ_DETDB_LOCAL + detail=Form("%s : Root data file : %s\n",prefixLDC,muonGain->GetRootDataFileName()); filcout << detail ; // cout << detail; + detail=Form("%s : Output logfile : %s\n",prefixLDC,logOutputFile.Data()); filcout << detail ; // cout << detail; + detail=Form("%s : Gain Histo file : %s\n",prefixLDC,muonGain->GetHistoFileName()); filcout << detail ; // cout << detail; + detail=Form("%s : Gain file (to SHUTTLE) : %s\n",prefixLDC,shuttleFile.Data()); filcout << detail ; // cout << detail; + + // Copying files to local DB folder defined by DAQ_DETDB_LOCAL Char_t *dir; + unsigned int nLastVersions=50; dir= getenv("DAQ_DETDB_LOCAL"); - unsigned int nLastVersions = 50; - printf("\n *** Local DataBase: %s (Max= %d) ***\n",dir,nLastVersions); - status = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions); - if(status)printf(" Store file : %s status = %d\n",logOutputFile.Data(),status); - if(nIndex==nEntries) - { - status = daqDA_localDB_storeFile(muonGain->GetRootDataFileName(),nLastVersions); - if(status)printf(" Store file : %s status = %d\n",muonGain->GetRootDataFileName(),status); - status = daqDA_localDB_storeFile(muonGain->GetHistoFileName(),nLastVersions); - if(status)printf(" Store file : %s status = %d\n",muonGain->GetHistoFileName(),status); - status = daqDA_localDB_storeFile(shuttleFile.Data(),nLastVersions); - if(status)printf(" Store file : %s status = %d\n",shuttleFile.Data(),status); - } - - - // ouput files - cout << endl; - cout << prefixDA << " : Root data file : " << muonGain->GetRootDataFileName() << endl; - cout << prefixDA << " : Output logfile : " << logOutputFile << endl; - cout << prefixDA << " : Gain Histo file : " << muonGain->GetHistoFileName() << endl; - cout << prefixDA << " : Gain file (to SHUTTLE) : " << shuttleFile << endl; - + if(dir != NULL) { + unsigned int nLastVersions=50; + printf("\n%s : *** Local DataBase: %s (Max= %d) ***\n",prefixLDC,dir,nLastVersions); + status1 = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions); + + if(nIndex==nEntries) + { + status1 = daqDA_localDB_storeFile(muonGain->GetRootDataFileName(),nLastVersions); + status1 = daqDA_localDB_storeFile(muonGain->GetHistoFileName(),nLastVersions); + status1 = daqDA_localDB_storeFile(shuttleFile.Data(),nLastVersions); // if(status1)printf(" Store file : %s status = %d\n",shuttleFile.Data(),status1); + } + } filcout.close(); - // Transferring to calibration file to FES - // be sure that env variable DAQDALIB_PATH is set in script file - // gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger"); - printf("\n ***** STORE calibration FILE to FES ****** \n"); - status = daqDA_FES_storeFile(shuttleFile.Data(),"GAINS"); - 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()); - - printf("\n ######## End execution : %s ######## \n",prefixDA); + // Transferring pedestal file to FES (be sure that env variable DAQDALIB_PATH is set) + cout << endl; + status1 = daqDA_FES_storeFile(shuttleFile.Data(),"GAINS"); + if (status1) { detail=Form("%s: !!! ERROR: Failed to export calibration file : %s to FES \n",prefixLDC,shuttleFile.Data()); + printf("%s",detail); filcout << detail ; status= -1; } + // else { detail=Form("%s : ---- STORE calibration FILE in FES : OK ---- \n",prefixLDC); printf("%s",detail); filcout << detail ;} + + if(nIndex==nEntries) + { +#ifdef ALI_AMORE + std::ifstream in(shuttleFile.Data()); + ostringstream stringout; + char line[1024]; + while ( in.getline(line,1024) ) + stringout << line << "\n"; + in.close(); + + amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender); + TObjString gaindata(stringout.str().c_str()); + Int_t amoreStatus = amoreDA.Send("Gains",&gaindata); + if ( amoreStatus ) + cout << prefixLDC << " : !!! ERROR: Failed to write Gains in the AMORE database : " << amoreStatus << endl ; status=-1 ; + else + cout << prefixLDC << " : amoreDA.Send(Gains) ok" << endl; +#else + cout << prefixLDC << " : Warning: MCH DA not compiled with AMORE support" << endl; +#endif + } + + if(!status)printf("\n%s : -------- End execution : %s -------- (status= %d) \n",prefixLDC,prefixDA,status); + else { printf("\n%s : -------- %s ending in ERROR !!!! -------- (status= %d) \n",prefixLDC,prefixDA,status);} + timers.Stop(); printf("\nExecution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime()); return status; } - diff --git a/MUON/MUONTRKPEDda.cxx b/MUON/MUONTRKPEDda.cxx index f390e684f43..82fa246f0af 100644 --- a/MUON/MUONTRKPEDda.cxx +++ b/MUON/MUONTRKPEDda.cxx @@ -29,7 +29,7 @@ /* ------------------------------------------------------------------------- - 2010-07-09 New version: MUONTRKPEDda.cxx,v 1.7 + 2012-02-16 New version: MUONTRKPEDda.cxx,v 1.8 ------------------------------------------------------------------------- Version for MUONTRKPEDda MUON tracking @@ -100,14 +100,11 @@ extern "C" { // main routine int main(Int_t argc, const char **argv) { - Int_t status=0; + Int_t status=0, status1=0; TStopwatch timers; timers.Start(kTRUE); - const char* prefixDA = "MUONTRKPEDda"; // program prefix - printf(" ######## Begin execution : %s ######## \n\n",prefixDA); - - // needed for streamer application + // Needed for streamer application gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo", @@ -124,9 +121,13 @@ int main(Int_t argc, const char **argv) Int_t skipEvents = 0; Int_t maxEvents = 1000000; Int_t maxDateEvents = 1000000; + Int_t errorDetail = 1; + Int_t checkTokenlost = 0; + Int_t flag_histo=1; TString inputFile; Int_t nDateEvents = 0; + Int_t nDateRejEvents = 0; Int_t nGlitchErrors= 0; Int_t nParityErrors= 0; Int_t nPaddingErrors= 0; @@ -136,6 +137,7 @@ int main(Int_t argc, const char **argv) TString logOutputFile; Char_t flatFile[256]=""; + Char_t* detail; TString shuttleFile; Int_t nEventsRecovered = 0; @@ -143,7 +145,8 @@ int main(Int_t argc, const char **argv) 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) + Int_t nSorting = 1 ; // pedestal sorting (ON by default) + Int_t statusDA = 0 ; // DA return code ofstream filcout; // decode the input line @@ -161,6 +164,8 @@ int main(Int_t argc, const char **argv) } continue; } + nConfig=0; + //prefixLDC = "LDC" switch (arg[1]) { case 'f' : @@ -184,11 +189,19 @@ int main(Int_t argc, const char **argv) i++; sscanf(argv[i],"%d",&maxEvents); break; + case 'v' : + i++; + sscanf(argv[i],"%d",&errorDetail); + break; + case 't' : + i++; + sscanf(argv[i],"%d",&checkTokenlost); + break; case 'h' : 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 can be used locally only with options (without DiMuon configuration file: nConfig=%d)",argv[0],nConfig); printf("\n%s -options, the available options are :",argv[0]); printf("\n-h help (this screen)"); printf("\n"); @@ -202,6 +215,8 @@ int main(Int_t argc, const char **argv) printf("\n-m (default = %d)",maxDateEvents); printf("\n-s (default = %d)",skipEvents); printf("\n-n (default = %d)",maxEvents); + printf("\n-v (default = %d : 0=low 1=medium 2=high)",errorDetail); + printf("\n-t (default = %d : 0=no , 1=yes)",checkTokenlost); printf("\n\n"); exit(-1); @@ -211,31 +226,58 @@ int main(Int_t argc, const char **argv) } // end of switch } // end of for i - // decoding the events - UShort_t manuId; UChar_t channelId; UShort_t charge; + const char* prefixDA = "MUONTRKPEDda"; // program prefix + const char* prefixLDC = getenv("DATE_ROLE_NAME"); // LDC name + if(prefixLDC == NULL) prefixLDC ="MCH" ; + printf("%s : -------- Begin execution : %s -------- \n",prefixLDC,prefixDA); + //Pedestal object AliMUONPedestal* muonPedestal = new AliMUONPedestal(); muonPedestal->SetprefixDA(prefixDA); + muonPedestal->SetprefixLDC(prefixLDC); + muonPedestal->SetStatusDA(statusDA); + + // Output log file initialisations + sprintf(flatFile,"%s.log",prefixDA); + logOutputFile=flatFile; + AliLog::SetStreamOutput(&filcout); // Print details on logfile + filcout.open(logOutputFile.Data()); + filcout<<"//=================================================" << endl; + filcout<<"//" << prefixLDC << " " << prefixDA << endl; + filcout<<"//=================================================" << endl; + filcout<<"// * Date : " << muonPedestal->GetDate()->AsString("l") << "\n" << endl; + + muonPedestal->SetAlifilcout(&filcout); + cout<GetDate()->AsString("l") << "\n" << endl; + Char_t dbfile[256]=""; // nConfig=1 : Reading configuration (or not) status via "mutrkpedvalues" file located in DetDB if(nConfig) { -// Int_t maxEvts; + Int_t flag_hist, nEvthres,maxEvts; + char line[80]; 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; + filein >> nConfig >> line ; cout << "mutrkpedvalues: " << line << " " << nConfig << " " ; + filein >> nEvthres >> line ; + if(nEvthres !=0)nEvthreshold=nEvthres; cout << line << " " << nEvthreshold << " " ; + filein >> checkTokenlost >> line ; cout << line << " " << checkTokenlost << " " ; + filein >> flag_histo >> line ; + if(flag_histo !=0) cout << line << " " << flag_histo << " " ; + filein >> maxEvts >> line ; + if(maxEvts!=0){maxEvents=maxEvts; cout << line << " " << maxEvents;} + // filein >> errorDetail >> line ; cout << line << " " << errorDetail << " " ; + // filein >> nSorting >> line ; cout << line << " " << nSorting << " " ; + cout << endl; } - else printf(" *** Config= %d: no configuration ascii file is used \n",nConfig); + if(!nConfig) printf("%s : *** Config= %d: no configuration ascii file is used \n",prefixLDC,nConfig); muonPedestal->SetconfigDA(nConfig); muonPedestal->SetnEvthreshold(nEvthreshold); muonPedestal->SetnSorting(nSorting); @@ -246,7 +288,6 @@ int main(Int_t argc, const char **argv) 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); } @@ -255,61 +296,43 @@ int main(Int_t argc, const char **argv) AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader); // 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); + + switch (errorDetail) + { + case 0: rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kLowErrorDetail); break;/// Logs minimal information in the error messages. + case 1: rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kMediumErrorDetail); break;/// Logs a medium level of detail in the error messages. + case 2: rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kHighErrorDetail); break;/// Logs a medium level of detail in the error messages. + default: rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kMediumErrorDetail); break; + } - printf("\n %s : Reading data from file %s\n",prefixDA,inputFile.Data()); + printf("\n%s : Reading data from file %s\n",prefixLDC,inputFile.Data()); 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()) { + Int_t eventType = rawReader->GetType(); + runNumber = rawReader->GetRunNumber(); + if(nDateEvents==0) { filcout<<"// ----> RUN = " << runNumber << "\n" << endl;} if (nDateEvents >= maxDateEvents) break; if (nEvents >= maxEvents) break; if (nDateEvents>0 && nDateEvents % 100 == 0) - cout<<"Cumulated: DATE events = " << nDateEvents << " Used events = " << nEvents << endl; + cout<< prefixLDC << " : DATE events = " << nDateEvents << " Used events = " << nEvents << endl; // check shutdown condition - if (daqDA_checkShutdown()) - break; + if (daqDA_checkShutdown()) break; //Skip events while (skipEvents) { rawReader->NextEvent(); skipEvents--; } - Int_t eventType = rawReader->GetType(); - runNumber = rawReader->GetRunNumber(); - - // Output log file initialisations - if(nDateEvents==0) - { - 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; - filcout<<"//=================================================" << endl; - filcout<<"// * Date : " << muonPedestal->GetDate()->AsString("l") << "\n" << endl; - cout<<"\n ******** " << prefixDA << " for run = " << runNumber << " ********\n" << endl; - cout<<" * Date : " << muonPedestal->GetDate()->AsString("l") << "\n" << endl; - - } - - muonPedestal->SetAlifilcout(&filcout); - nDateEvents++; if (eventType != PHYSICS_EVENT) continue; // for the moment - const char* detail = ""; + // 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; @@ -325,6 +348,7 @@ int main(Int_t argc, const char **argv) eventParityErrors += rawStream->GetParityErrors(); eventPaddingErrors += rawStream->GetPaddingErrors(); eventTokenlostErrors += rawStream->GetTokenLostErrors(); + // cout << nDateEvents << " " << rawStream->GetDDL() << " " << eventTokenlostErrors << endl; if (rawStream->GetTokenLostErrors()) { nTokenlostErrors++; @@ -374,7 +398,7 @@ int main(Int_t argc, const char **argv) else { // Events with errors - if (recoverParityErrors && eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors) + if (recoverParityErrors && eventParityErrors && !eventGlitchErrors && !eventPaddingErrors && !(eventTokenlostErrors && checkTokenlost)) { filcout << " ----------- Date Event recovered = " << nDateEvents << " ----------------" << endl; // Recover parity errors -> compute pedestal for all good buspatches @@ -439,6 +463,7 @@ int main(Int_t argc, const char **argv) { // Fatal errors reject the event detail = Form(" ----------- Date Event rejected = %d ----------------",nDateEvents); + nDateRejEvents++; filcout << detail << endl; if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(), ATTR_ORBIT_BC )) @@ -465,8 +490,6 @@ int main(Int_t argc, const char **argv) if (eventGlitchErrors) nGlitchErrors++; if (eventParityErrors) nParityErrors++; if (eventPaddingErrors) nPaddingErrors++; - // if (eventTokenlostErrors) nTokenlostErrors++; - // muonPedestal->SetAliNCurrentEvents(nEvents); } // while (rawReader->NextEvent()) delete rawReader; @@ -477,64 +500,23 @@ int main(Int_t argc, const char **argv) muonPedestal->SetAliNEvents(nEvents); muonPedestal->SetAliRunNumber(runNumber); - muonPedestal->Finalize(); - muonPedestal->MakeControlHistos(); - if (!shuttleFile.IsNull()) - { - ofstream out(shuttleFile.Data()); - muonPedestal->MakeASCIIoutput(out); - out.close(); -#ifdef ALI_AMORE - // - //Send objects to the AMORE DB - // - ostringstream stringout; - muonPedestal->MakeASCIIoutput(stringout); - - amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender); - TObjString peddata(stringout.str().c_str()); - 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 - cout << "Warning: MCH DA not compiled with AMORE support" << endl; -#endif - - } - + muonPedestal->Finalize(); + status = muonPedestal->GetStatusDA() ; + // writing some counters - cout << endl; - 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 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; - - filcout << endl; - filcout << prefixDA << " : Nb of DATE events = " << nDateEvents << endl; - 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; - - // ouput files - cout << endl; - cout << prefixDA << " : Output logfile : " << logOutputFile << endl; - cout << prefixDA << " : Pedestal Histo file : " << muonPedestal->GetHistoFileName() << endl; - cout << prefixDA << " : Ped. file (to SHUTTLE) : " << shuttleFile << endl; + detail=Form("\n%s : Nb of DATE events = %d",prefixLDC,nDateEvents) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of Glitch errors = %d",prefixLDC,nGlitchErrors) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of Parity errors = %d",prefixLDC,nParityErrors) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of Token lost errors = %d",prefixLDC,nTokenlostErrors) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of Rejected DATE events = %d",prefixLDC,nDateRejEvents) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of recovered events = %d",prefixLDC,nEventsRecovered) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of events without errors = %d",prefixLDC,nEvents-nEventsRecovered) ; cout << detail; filcout << detail ; + detail=Form("\n%s : Nb of used events = %d (threshold= %d)\n\n",prefixLDC,nEvents,nEvthreshold); cout << detail; filcout << detail ; // Writing Token Error table if(nTokenlostErrors) { - char* detail=Form("\nWarning: Token Lost occurence \n"); + detail=Form("%s : Warning: Token Lost occurence \n",prefixLDC); printf("%s",detail); filcout << detail ; for ( Int_t i=0 ; i<20 ; i++) @@ -546,8 +528,8 @@ int main(Int_t argc, const char **argv) 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); + if( j % 2 == 0)detail=Form("%s : in DDL= %d (station %d) and FRT%d ( Up ) => %d Token errors (address = 0x%X0000)",prefixLDC,2560+i,station,frt,tab,j); + else detail=Form("%s : in DDL= %d (station %d) and FRT%d (Down) => %d Token errors (address = 0x%X0000)",prefixLDC,2560+i,station,frt,tab,j); printf("%s\n",detail); filcout << detail << endl; } @@ -555,40 +537,79 @@ int main(Int_t argc, const char **argv) } } - filcout << endl; - filcout << prefixDA << " : Output logfile : " << logOutputFile << endl; - filcout << prefixDA << " : Pedestal Histo file : " << muonPedestal->GetHistoFileName() << endl; - filcout << prefixDA << " : Ped. file (to SHUTTLE) : " << shuttleFile << endl; + if (!shuttleFile.IsNull()) + { + ofstream out(shuttleFile.Data()); + muonPedestal->MakeASCIIoutput(out); /// Generate pedestal output file + out.close(); + detail=Form("%s : Pedestal file (to SHUTTLE) : %s\n",prefixLDC,shuttleFile.Data()); + cout << detail; filcout << detail ; + } + if(flag_histo) /// Generate pedestal histo rootfile + { + muonPedestal->MakeControlHistos(); + detail=Form("%s : Pedestal Histo file : %s\n",prefixLDC,muonPedestal->GetHistoFileName()); + cout << detail; filcout << detail ; + } + // .log files + detail=Form("%s : Output logfile : %s\n",prefixLDC,logOutputFile.Data()); + cout << detail; filcout << detail ; + + + // Transferring pedestal file to FES (be sure that env variable DAQDALIB_PATH is set) + cout << endl; + status1 = daqDA_FES_storeFile(shuttleFile.Data(),"PEDESTALS"); + if (status1) { detail=Form("%s: !!! ERROR: Failed to export pedestal file : %s to FES \n",prefixLDC,shuttleFile.Data()); + printf("%s",detail); filcout << detail ; status= -1; } + //else { detail=Form("%s : ***** STORE Pedestal FILE in FES : OK ****** \n",prefixLDC); printf("%s",detail); filcout << detail ;} + + // Transferring configuration file to FES (be sure that env variable DAQDALIB_PATH is set) + if(nConfig) + { cout << endl; + status1 = daqDA_FES_storeFile(dbfile,"CONFIG"); + if (status1) { detail=Form("%s: !!! ERROR: Failed to export configuration file : %s to FES \n",prefixLDC,dbfile); + printf("%s",detail); filcout << detail ; status=-1; } + // else {detail=Form("%s : ***** STORE Configuration FILE in FES : OK ****** \n",prefixLDC); printf("%s",detail); filcout << detail ;} + } // Copying files to local DB folder defined by DAQ_DETDB_LOCAL Char_t *dir; - dir= getenv("DAQ_DETDB_LOCAL"); unsigned int nLastVersions=50; - cout << "\n *** Local DataBase: " << dir << " (Max= " << nLastVersions << ") ***" << endl; - status = daqDA_localDB_storeFile(muonPedestal->GetHistoFileName(),nLastVersions); - if(status)printf(" Store file : %s status = %d\n",muonPedestal->GetHistoFileName(),status); - status = daqDA_localDB_storeFile(shuttleFile.Data(),nLastVersions); - if(status)printf(" Store file : %s status = %d\n",shuttleFile.Data(),status); - status = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions); - if(status)printf(" Store file : %s status = %d\n",logOutputFile.Data(),status); - - 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 : %s , status = %d\n",shuttleFile.Data(),status); return -1; } - // else printf(" %s successfully exported to FES \n",shuttleFile.Data()); + dir= getenv("DAQ_DETDB_LOCAL"); + if(dir != NULL) { + unsigned int nLastVersions=50; + printf("\n%s : *** Local DataBase: %s (Max= %d) ***\n",prefixLDC,dir,nLastVersions); + if(!shuttleFile.IsNull())status1 = daqDA_localDB_storeFile(shuttleFile.Data(),nLastVersions); + if(flag_histo)status1 = daqDA_localDB_storeFile(muonPedestal->GetHistoFileName(),nLastVersions); + status1 = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions); + } - // 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); + cout << " " << endl; + +#ifdef ALI_AMORE + // + //Send objects to the AMORE DB + // + ostringstream stringout; + muonPedestal->MakeASCIIoutput(stringout); + + amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender); + TObjString peddata(stringout.str().c_str()); + Int_t amoreStatus = amoreDA.Send("Pedestals",&peddata); + if ( amoreStatus ) + cout << prefixLDC << " : !!! ERROR: Failed to write Pedestals in the AMORE database : " << amoreStatus << endl ; status=-1 ; + else + cout << prefixLDC << " : amoreDA.Send(Pedestals) ok" << endl; +#else + cout << prefixLDC << " : Warning: MCH DA not compiled with AMORE support" << endl; +#endif + + filcout.close(); - printf("\n ######## End execution : %s ######## \n",prefixDA); + if(!status)printf("\n%s : -------- End execution : %s -------- (status= %d) \n",prefixLDC,prefixDA,status); + else { printf("\n%s : -------- %s ending in ERROR !!!! -------- (status= %d) \n",prefixLDC,prefixDA,status);} timers.Stop(); - printf("\nExecution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime()); + printf("\n Execution time : R:%7.2fs C:%7.2fs\n",timers.RealTime(), timers.CpuTime()); return status; }