Double_t goodA1Max = 2.;
// Double_t goodA2Min = -0.5E-03;
// Double_t goodA2Max = 1.E-03;
- Double_t goodA2Min = -0.5E-01; // changed 28/10/2009 (JLC) <=> no condition on a2
+ Double_t goodA2Min = -0.5E-01; // changed 28/10/2009 (JLC) <=> enlarged condition on a2
Double_t goodA2Max = 1.E-01;
// Table for uncalibrated buspatches and manus
THashList* uncalBuspatchManuTable = new THashList(1000,2);
Int_t fitproceed=1;
Int_t nbpf2Dynamic=nbpf2;
+ Int_t ADClimit=4090; // when RMS < 0.5 (in other cases mean values forced to 4095, see DA_PED)
for (Int_t j = 0; j < nbs; ++j)
{
Int_t k = j + fnInit;
x[j] = pedMean[k];
if(x[j]<=0.){fitproceed=0; break;}
- if(x[j]>= ADCMax())
+ // if(x[j]>= ADCMax())
+ if(x[j]>= ADClimit)
{
if(j < nbs-1){fitproceed=0; break;}
- else nbpf2Dynamic=nbpf2-1;
+ else { nbpf2Dynamic=nbpf2-1; break;}
}
xErr[j] = pedSigma[k];
y[j] = injCharge[k];
AliMUONPedestal::AliMUONPedestal()
: TObject(),
//fN(0),
+fNCurrentEvents(0),
+fNEvthreshold(0),
fNEvents(0),
fRunNumber(0),
fNChannel(0),
Int_t busPatchId;
ifstream filein(dbfile,ios::in);
-
- // check if the 1st caracter of the 1st line is # (Config read from the OCDB => OffLine)
- // NO NEED ANYMORE : change configuration tested by the Shuttle (from 16/02/10)
-// string line;
-// getline(filein, line, '\n');
-// cout << " line 1: " << line ;
-// if ( int(line[0]) == 35 ) // ascii code of # character
-// {
-// cout << " ==> 1st caracter = " << line[0] << " (ascii code =" << int(line[0]) << ")" << endl;
-// }
-// else
-// { filein.clear(); filein.seekg(0); // rewind
-// cout << " ==> rewind configuration file: "<< dbfile << endl;
-// }
while (!filein.eof())
{
Double_t pedMean;
Double_t pedSigma;
+ Double_t pedSigmalimit=0.5;
Int_t busPatchId;
Int_t manuId;
Int_t channelId;
// print in logfile
if (fErrorBuspatchTable->GetSize())
{
- cout<<"\n* Buspatches with less statistics (due to parity errors)"<<endl;
- (*fFilcout)<<"\n* Buspatches with less statistics (due to parity errors)"<<endl;
+ cout<<"\nWarning: Buspatches with less statistics (due to parity errors)"<<endl;
+ (*fFilcout)<<"\nWarning: Buspatches with less statistics (due to parity errors)"<<endl;
TIter nextParityError(fErrorBuspatchTable->CreateIterator());
AliMUONErrorCounter* parityerror;
while((parityerror = static_cast<AliMUONErrorCounter*>(nextParityError())))
}
}
+ Int_t nADC4090=0;
+ Int_t nADCmax=0;
// iterator over pedestal
TIter next(fPedestalStore ->CreateIterator());
AliMUONVCalibParam* ped;
manuId = ped->ID1();
if(manuId==0)
{
- cout << " !!! BIG WARNING: ManuId = " << manuId << " !!! in BP = " << busPatchId << endl;
- (*fFilcout) << " !!! BIG WARNING: ManuId = " << manuId << " !!! in BP = " << busPatchId << endl;
+ cout << "Warning: ManuId = " << manuId << " !!! in BP = " << busPatchId << endl;
+ (*fFilcout) << "Warning: ManuId = " << manuId << " !!! in BP = " << busPatchId << endl;
}
Int_t eventCounter;
// Correct the number of events for buspatch with errors
{
eventCounter = fNEvents;
}
-
Int_t occupancy=0; // channel missing in raw data or read but rejected (case of parity error)
// value of (buspatch, manu) occupancy
AliMUONErrorCounter* manuCounter;
if(eventCounter>0)occupancy = manuCounter->Events()/64/eventCounter;
if(occupancy>1)
{
- cout << " !!! BIG WARNING: ManuId = " << manuId << " !!! in BP = " << busPatchId << " occupancy (>1) = " << occupancy << endl;
- (*fFilcout) << " !!! BIG WARNING: ManuId = " << manuId << " !!! in BP = " << busPatchId << " occupancy (>1) = " << occupancy <<endl;
+ cout << "Warning: ManuId = " << manuId << " !!! in BP = " << busPatchId << " occupancy (>1) = " << occupancy << endl;
+ (*fFilcout) << "Warning: ManuId = " << manuId << " !!! in BP = " << busPatchId << " occupancy (>1) = " << occupancy <<endl;
}
for (channelId = 0; channelId < ped->Size() ; ++channelId)
{
- pedMean = ped->ValueAsDouble(channelId, 0);
+ pedMean = ped->ValueAsDouble(channelId, 0);
- if (pedMean > 0) // connected channels
+ 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)));
- if(manuId == 0)
- {
- ped->SetValueAsDouble(channelId, 0, ADCMax());
+ ped->SetValueAsDouble(channelId, 1, TMath::Sqrt(TMath::Abs(pedSigma/(Double_t)eventCounter - pedMean*pedMean)));
+
+ if(eventCounter < fNEvthreshold )
+ { nADCmax++; ped->SetValueAsDouble(channelId, 0, ADCMax());
+ ped->SetValueAsDouble(channelId, 1, ADCMax());}
+ if( ped->ValueAsDouble(channelId, 1) < pedSigmalimit )
+ { nADC4090++; ped->SetValueAsDouble(channelId, 0, ADCMax()-5);
+ ped->SetValueAsDouble(channelId, 1, ADCMax()-5);}
+ if(manuId == 0 || occupancy>1)
+ { nADCmax++; ped->SetValueAsDouble(channelId, 0, ADCMax());
ped->SetValueAsDouble(channelId, 1, ADCMax());
- }
- if(occupancy>1)
- {
- ped->SetValueAsDouble(channelId, 0, ADCMax());
- ped->SetValueAsDouble(channelId, 1, ADCMax());
- if(channelId==0)ped->SetValueAsDouble(channelId, 0, ADCMax()+occupancy);
- }
+ if(occupancy>1 && channelId==0)ped->SetValueAsDouble(channelId, 0, ADCMax()+occupancy);}
}
else
- {
- ped->SetValueAsDouble(channelId, 0, ADCMax());
- ped->SetValueAsDouble(channelId, 1, ADCMax());
- }
+ { nADCmax++; ped->SetValueAsDouble(channelId, 0, ADCMax());
+ 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; }
}
//______________________________________________________________________________
void AliMUONPedestal::MakeASCIIoutput(ostream& out) const
out<<"//===========================================================================" << endl;
out<<"// Pedestal file calculated by "<< fPrefixDA.Data() << endl;
out<<"//===========================================================================" << endl;
- out<<"// * Run : " << fRunNumber << endl;
- out<<"// * Date : " << fDate->AsString("l") <<endl;
- out<<"// * Statictics : " << fNEvents << endl;
+ out<<"// * Run : " << fRunNumber << endl;
+ out<<"// * Date : " << fDate->AsString("l") <<endl;
+ out<<"// * Statictics : " << fNEvents << endl;
if(fConfig)
- out<<"// * # of MANUS : " << fNManuConfig << " read in the Det. config. " << endl;
- out<<"// * # of MANUS : " << fNManu << " read in raw data " << endl;
- out<<"// * # of MANUS : " << fNChannel/64 << " written in pedestal file " << endl;
- out<<"// * # of channels : " << fNChannel << endl;
+ out<<"// * Nb of MANUS : " << fNManuConfig << " read in the Det. config. " << endl;
+ out<<"// * Nb of MANUS : " << fNManu << " read in raw data " << endl;
+ out<<"// * Nb of MANUS : " << fNChannel/64 << " written in pedestal file " << endl;
+ out<<"// * Nb of channels: " << fNChannel << endl;
+ out<<"//"<<endl;
+ out<<"// * Below " << fNEvthreshold << " events=> Ped.&sig.=4095" << endl;
+ out<<"// * PedSigma < 0.5 => Ped.&sig.=4090" << endl;
+
if (fErrorBuspatchTable->GetSize())
{
out<<"//"<<endl;
AliMUONErrorCounter* parityerror;
while((parityerror = static_cast<AliMUONErrorCounter*>(next())))
{
- out<<"// BusPatch = "<<parityerror->BusPatch()<<"\t Nevents used = "<<fNEvents-parityerror->Events()<<endl;
+ if(fNEvents-parityerror->Events()>fNEvthreshold)
+ { out<<"// BusPatch = "<<parityerror->BusPatch()<<"\t Nevents used = "<<fNEvents-parityerror->Events()<<endl; }
+ else
+ { out<<"// BusPatch = "<<parityerror->BusPatch()<<"\t Nevents used = "<<fNEvents-parityerror->Events()<< " (Ped.&sig.=4095)" << endl; }
}
}
-
-// out<<"//"<<endl;
-// out<<"// * Puzzling (Buspatch,Manu) read in raw data ?"<<endl;
Int_t writitle=0;
Int_t occupancy=1;
if(occupancy)
writitle++;
if(writitle==1){
out<<"//"<<endl;
- out<<"// * Puzzling (Buspatch,Manu) read in raw data ?"<<endl;}
+ out<<"// * Puzzling (Buspatch,Manu) read in raw data ? (Ped.&sig.=4095)"<<endl;}
occupancy=TMath::Nint(pedMean-ADCMax());
ped->SetValueAsDouble(0, 0, ADCMax());
- out<<"// BusPatch = "<< busPatchId <<"\t ManuId = "<< manuId << "\t occupancy = " << occupancy <<endl;
+ out<<"// BusPatch = "<< busPatchId <<"\t ManuId = "<< manuId << "\t occupancy = " << occupancy << endl;
}
if (manuId==0 || (fConfig && static_cast<AliMUONErrorCounter*>(fManuBPoutofconfigTable->FindObject(busPatchId,manuId))))
writitle++;
if(writitle==1){
out<<"//"<<endl;
- out<<"// * Puzzling (Buspatch,Manu) read in raw data ?"<<endl;}
+ out<<"// * Puzzling (Buspatch,Manu) read in raw data ? (Ped.&sig.=4095)"<<endl;}
out<<"// BusPatch = "<< busPatchId <<"\t ManuId = "<< manuId << "\t missing in the mapping" << endl;
}
}
}
-
-
out<<"//"<<endl;
out<<"//---------------------------------------------------------------------------" << endl;
out<<"//---------------------------------------------------------------------------" << endl;
Double_t pedMean;
Double_t pedSigma;
+ Double_t evt;
Int_t busPatchId;
Int_t manuId;
Int_t channelId;
tree->Branch("channel",&channelId,",channel/I");
tree->Branch("pedMean",&pedMean,",pedMean/D");
tree->Branch("pedSigma",&pedSigma,",pedSigma/D");
+ tree->Branch("nevt",&evt,",evt/D");
// iterator over pedestal
TIter next(fPedestalStore ->CreateIterator());
AliMUONVCalibParam* ped;
+ AliMUONErrorCounter* manuCounter;
while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
{
{
pedMean = ped->ValueAsDouble(channelId, 0);
pedSigma = ped->ValueAsDouble(channelId, 1);
+ manuCounter = static_cast<AliMUONErrorCounter*>(fManuBuspatchTable->FindObject(busPatchId,manuId));
+ evt = manuCounter->Events()/64;
pedMeanHisto->Fill(pedMean);
pedSigmaHisto->Fill(pedSigma);
AliMUONPedestal();
virtual ~AliMUONPedestal();
+ /// return the number of current events
+ void SetAliNCurrentEvents(Int_t events) {fNCurrentEvents = events;}
/// return the number of events
void SetAliNEvents(Int_t events) {fNEvents = events;}
/// return the Run number
/// set config flag
void SetconfigDA(Int_t ind) {fConfig = ind;}
+ /// set Nb of evt threshold to calculate pedestal
+ void SetnEvthreshold(Int_t ind) {fNEvthreshold = ind;}
/// set specific DA prefixname
void SetprefixDA(const char* folder) { fPrefixDA=folder;}
/// set the index of calibration runs
protected:
// Int_t fN; ///<
+ Int_t fNCurrentEvents; ///< Number of current events
+ Int_t fNEvthreshold; ///< Nbevt threshold (pedestal calculation)
Int_t fNEvents; ///< Number of events
Int_t fRunNumber; ///< run number
Int_t fNChannel; ///< Nb of channels (pads)
/// Not implemented
AliMUONPedestal& operator = (const AliMUONPedestal& rhs);
- ClassDef(AliMUONPedestal,4) // Pedestal computing for DA
+ ClassDef(AliMUONPedestal,5) // Pedestal computing for DA
};
#endif
/*
-------------------------------------------------------------------------
- 2010-02-16 New version: MUONTRKGAINda.cxx,v 1.5
+ 2010-04-18 New version: MUONTRKGAINda.cxx,v 1.6
-------------------------------------------------------------------------
Version for MUONTRKGAINda MUON tracking
#include "AliMpConstants.h"
#include "AliRawDataErrorLog.h"
#include "AliMUONTrackerIO.h"
+#include "AliLog.h"
+#include "AliMUONDspHeader.h"
+#include "AliDAQ.h"
//ROOT
#include "TFile.h"
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)
TString logOutputFile;
Char_t flatFile[256]="";
muonGain->SetAliPrintLevel(printLevel);
muonGain->SetAliPlotLevel(plotLevel);
muonGain->SetconfigDA(nConfig);
+ muonGain->SetnEvthreshold(nEvthreshold);
if(nConfig)
{
// Rawdeader, RawStreamHP
AliRawReader* rawReader = AliRawReader::Create(inputFile.Data());
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);
cout << "\n" << prefixDA << " : Reading data from file " << inputFile.Data() << 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())
{
{
rawReader->NextEvent();
skipEvents--;
- }
-
+ }
Int_t eventType = rawReader->GetType();
runNumber = rawReader->GetRunNumber();
{
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;
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 eventTokenlostErrors = 0;
rawStream->First();
do
- {
- if (rawStream->IsErrorMessage()) eventIsErrorMessage = kTRUE;
- eventGlitchErrors += rawStream->GetGlitchErrors();
- eventParityErrors += rawStream->GetParityErrors();
- eventPaddingErrors += rawStream->GetPaddingErrors();
- eventTokenlostErrors += rawStream->GetTokenLostErrors();
- } while(rawStream->NextDDL());
+ {
+ if (rawStream->IsErrorMessage()) eventIsErrorMessage = kTRUE;
+ 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;
if (!eventIsErrorMessage)
{
// Good events (no error) -> compute pedestal for all channels
rawStream->First();
+ nEvents++;
+ muonGain->SetAliNCurrentEvents(nEvents);
while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next()))
{
for(int i = 0; i < busPatch->GetLength(); ++i)
muonGain->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
}
}
- nEvents++;
}
else
- {
- // Events with errors
- if (eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors)
- {
- // Recover parity errors -> compute pedestal for all good buspatches
- if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(),
- ATTR_ORBIT_BC ))
- {
- filcout <<"Event recovered -> Period:"<<EVENT_ID_GET_PERIOD( rawReader->GetEventId() )
- <<" Orbit:"<<EVENT_ID_GET_ORBIT( rawReader->GetEventId() )
- <<" BunchCrossing:"<<EVENT_ID_GET_BUNCH_CROSSING( rawReader->GetEventId() )<<endl;
- }
- else
- {
- filcout <<"Event recovered -> nbInRun:"<<EVENT_ID_GET_NB_IN_RUN( rawReader->GetEventId() )
- <<" burstNb:"<<EVENT_ID_GET_BURST_NB( rawReader->GetEventId() )
- <<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl;
- }
- rawStream->First();
- while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next()))
- {
- // Check the buspatch -> if error not use it in the pedestal calculation
- int errorCount = 0;
- for(int i = 0; i < busPatch->GetLength(); ++i)
- {
- if (!busPatch->IsParityOk(i)) errorCount++;
- }
- if (!errorCount)
- {
- // Good buspatch
- for(int i = 0; i < busPatch->GetLength(); ++i)
- {
- busPatch->GetData(i, manuId, channelId, charge);
- muonGain->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
- }
- }
- else
- {
- char bpname[256];
- AliMUONErrorCounter* errorCounter;
- // Bad buspatch -> not used (just print)
- filcout<<"bpId "<<busPatch->GetBusPatchId()<<" words "<<busPatch->GetLength()
- <<" parity errors "<<errorCount<<endl;
- // Number of events where this buspatch is missing
- sprintf(bpname,"bp%d",busPatch->GetBusPatchId());
- if (!(errorCounter = (AliMUONErrorCounter*) (muonGain->GetErrorBuspatchTable()->FindObject(bpname))))
- {
- // New buspatch
- errorCounter = new AliMUONErrorCounter(busPatch->GetBusPatchId());
- errorCounter->SetName(bpname);
- muonGain->GetErrorBuspatchTable()->Add(errorCounter);
- }
- else
- {
- // Existing buspatch
- errorCounter->Increment();
- }
- // errorCounter->Print();
- } // end of if (!errorCount)
- } // end of while( (busPatch = (AliMUONRawStreamTrackerHP ...
- nEvents++;
- nEventsRecovered++;
- } //end of if (eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors)
- else
- {
- // Fatal errors reject the event
- if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(),
- ATTR_ORBIT_BC ))
- {
- filcout <<"Event rejected -> Period:"<<EVENT_ID_GET_PERIOD( rawReader->GetEventId() )
- <<" Orbit:"<<EVENT_ID_GET_ORBIT( rawReader->GetEventId() )
- <<" BunchCrossing:"<<EVENT_ID_GET_BUNCH_CROSSING( rawReader->GetEventId() )<<endl;
- }
- else
- {
- filcout <<"Event rejected -> nbInRun:"<<EVENT_ID_GET_NB_IN_RUN( rawReader->GetEventId() )
- <<" burstNb:"<<EVENT_ID_GET_BURST_NB( rawReader->GetEventId() )
- <<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl;
+ {
+ // Events with errors
+ if (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 ))
+ {
+ filcout <<"Event recovered -> Period:"<<EVENT_ID_GET_PERIOD( rawReader->GetEventId() )
+ <<" Orbit:"<<EVENT_ID_GET_ORBIT( rawReader->GetEventId() )
+ <<" BunchCrossing:"<<EVENT_ID_GET_BUNCH_CROSSING( rawReader->GetEventId() )<<endl;
+ }
+ else
+ {
+ filcout <<"Event recovered -> nbInRun:"<<EVENT_ID_GET_NB_IN_RUN( rawReader->GetEventId() )
+ <<" burstNb:"<<EVENT_ID_GET_BURST_NB( rawReader->GetEventId() )
+ <<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl;
+ }
+ rawStream->First();
+ nEvents++;
+ muonGain->SetAliNCurrentEvents(nEvents);
+ while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next()))
+ {
+ // Check the buspatch -> if error not use it in the pedestal calculation
+ int errorCount = 0;
+ for(int i = 0; i < busPatch->GetLength(); ++i)
+ {
+ if (!busPatch->IsParityOk(i)) errorCount++;
+ }
+ if (!errorCount)
+ {
+ // Good buspatch
+ for(int i = 0; i < busPatch->GetLength(); ++i)
+ {
+ busPatch->GetData(i, manuId, channelId, charge);
+ muonGain->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
+ }
+ }
+ else
+ {
+ char bpname[256];
+ AliMUONErrorCounter* errorCounter;
+ // Bad buspatch -> not used (just print)
+ filcout<<"bpId "<<busPatch->GetBusPatchId()<<" words "<<busPatch->GetLength()
+ <<" parity errors "<<errorCount<<endl;
+ // Number of events where this buspatch is missing
+ sprintf(bpname,"bp%d",busPatch->GetBusPatchId());
+ if (!(errorCounter = (AliMUONErrorCounter*) (muonGain->GetErrorBuspatchTable()->FindObject(bpname))))
+ {
+ // New buspatch
+ errorCounter = new AliMUONErrorCounter(busPatch->GetBusPatchId());
+ errorCounter->SetName(bpname);
+ muonGain->GetErrorBuspatchTable()->Add(errorCounter);
+ }
+ else
+ {
+ // Existing buspatch
+ errorCounter->Increment();
+ }
+ // errorCounter->Print();
+ } // end of if (!errorCount)
+ } // end of while( (busPatch = (AliMUONRawStreamTrackerHP ...
+ // nEvents++;
+ nEventsRecovered++;
+ } //end of if (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 ))
+ {
+ filcout <<"Event rejected -> Period:"<<EVENT_ID_GET_PERIOD( rawReader->GetEventId() )
+ <<" Orbit:"<<EVENT_ID_GET_ORBIT( rawReader->GetEventId() )
+ <<" BunchCrossing:"<<EVENT_ID_GET_BUNCH_CROSSING( rawReader->GetEventId() )<<endl;
+ }
+ else
+ {
+ filcout <<"Event rejected -> nbInRun:"<<EVENT_ID_GET_NB_IN_RUN( rawReader->GetEventId() )
+ <<" burstNb:"<<EVENT_ID_GET_BURST_NB( rawReader->GetEventId() )
+ <<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl;
- }
- } // end of if (!rawStream->GetGlitchErrors() && !rawStream->GetPaddingErrors() ...
- filcout<<"Number of errors : Glitch "<<eventGlitchErrors
- <<" Parity "<<eventParityErrors
- <<" Padding "<<eventPaddingErrors
- <<" Token lost "<<eventTokenlostErrors<<endl;
- filcout<<endl;
- } // end of if (!rawStream->IsErrorMessage())
+ }
+ } // end of if (!rawStream->GetGlitchErrors() && !rawStream->GetPaddingErrors() ...
+ filcout<<"Number of errors : Glitch "<<eventGlitchErrors
+ <<" Parity "<<eventParityErrors
+ <<" Padding "<<eventPaddingErrors
+ <<" Token lost "<<eventTokenlostErrors<<endl;
+ filcout<<endl;
+ } // end of if (!rawStream->IsErrorMessage())
if (eventGlitchErrors) nGlitchErrors++;
if (eventParityErrors) nParityErrors++;
if (eventPaddingErrors) nPaddingErrors++;
- if (eventTokenlostErrors) nTokenlostErrors++;
+ //if (eventTokenlostErrors) nTokenlostErrors++;
} // while (rawReader->NextEvent())
delete rawReader;
filcout << prefixDA << " : Nb of events without errors = " << nEvents-nEventsRecovered<< endl;
filcout << prefixDA << " : Nb of events used = " << nEvents << 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;
+ }
+ }
+ }
+ }
+
// Computing gain
if(nIndex==nEntries)
{
/*
-------------------------------------------------------------------------
- 2010-02-16 New version: MUONTRKPEDda.cxx,v 1.5
+ 2010-04-18 New version: MUONTRKPEDda.cxx,v 1.6
-------------------------------------------------------------------------
Version for MUONTRKPEDda MUON tracking
#include "AliRawDataErrorLog.h"
#include "AliMUONTrackerIO.h"
#include "AliLog.h"
+#include "AliMUONDspHeader.h"
+#include "AliDAQ.h"
//ROOT
#include "TFile.h"
Int_t nEventsRecovered = 0;
Int_t nEvents = 0;
UInt_t runNumber = 0;
- Int_t nConfig = 1;
+ Int_t nConfig = 1;
+ Int_t nEvthreshold = 10; //below this nb_evt pedestal are not calculated and forced to 4085 (sigma)
ofstream filcout;
// decode the input line
if(status) {printf(" !!! Failed : input file %s is missing, status = %d\n",dbfile,status); return -1; }
ifstream filein(dbfile,ios::in);
filein >> nConfig;
+ // filein >> nEvthreshold;
}
else printf(" *** Config= %d: no configuration ascii file is used \n",nConfig);
muonPedestal->SetconfigDA(nConfig);
+ muonPedestal->SetnEvthreshold(nEvthreshold);
// nConfig=1: configuration ascii file config_$DATE_ROLE_NAME read from DetDB
if(nConfig)
// 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::kHighErrorDetail);
+ rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kMediumErrorDetail);
+ // rawStream->SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kHighErrorDetail);
printf("\n %s : Reading data from file %s\n",prefixDA,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())
{
if (nDateEvents >= maxDateEvents) break;
// check shutdown condition
if (daqDA_checkShutdown())
break;
-
//Skip events
while (skipEvents)
{
rawReader->NextEvent();
skipEvents--;
}
-
Int_t eventType = rawReader->GetType();
runNumber = rawReader->GetRunNumber();
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;
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;
{
// 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)
muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
}
}
- nEvents++;
}
else
{
<<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl;
}
rawStream->First();
+ nEvents++;
+ muonPedestal->SetAliNCurrentEvents(nEvents);
while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next()))
{
// Check the buspatch -> if error not use it in the pedestal calculation
// errorCounter->Print();
} // end of if (!errorCount)
} // end of while( (busPatch = (AliMUONRawStreamTrackerHP ...
- nEvents++;
+ // nEvents++;
nEventsRecovered++;
} //end of if (recoverParityErrors && eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors)
else
{
- filcout << " ----------- Date Event rejected = " << nDateEvents << " ----------------" << endl;
// Fatal errors reject the event
+ detail = Form(" ----------- Date Event rejected = %d ----------------",nDateEvents);
+ filcout << detail << endl;
if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(),
ATTR_ORBIT_BC ))
{
if (eventGlitchErrors) nGlitchErrors++;
if (eventParityErrors) nParityErrors++;
if (eventPaddingErrors) nPaddingErrors++;
- if (eventTokenlostErrors) nTokenlostErrors++;
+ // if (eventTokenlostErrors) nTokenlostErrors++;
+ // muonPedestal->SetAliNCurrentEvents(nEvents);
} // while (rawReader->NextEvent())
delete rawReader;
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
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;
Two input files located in the DAQ Detector database (DetDB) are needed:
-- muontrkpedvalues is built in flight in CONFIGURATION_PED.sh (ECS script) and contains two parameters "config" and "writeconfig"
+- muontrkpedvalues is built in flight in CONFIGURATION_PED.sh (ECS script) and contains one parameter "config" :
config = 1 if configuration file has to be used (OnLine case)
config = 0 if not (OffLine case for the time being)
- writeconfig=0 if configuration is unchanged
- writeconfig=1 if configuration is changed , then new config. file is written in DetDB
-
+
- config_ldc-MTRK-S3-0 : configuration file name corresponding to MuonTracker Station 3 if (for example) DA is running on ldc-MTRK-S3-0
- DA validation: see Header of MUONTRKPEDda.cxx for reference run, and corresponding input mutrkpedvalues and configuration files are located in path=/afs/cern.ch/user/j/jcharvet/public/DA_validation
Two input files located in the DAQ Detector database (DetDB) are needed:
-- muontrkcalibvalues: which attributes to each the run index (1->11) its corrresponding DAC value. The other parameters are used to tune the fit procedure (for expert). The last parameter indicates the number of events to be read: if "0" all events in the run are read, if not the parameter indicates the maximum number of events to be read.
+- muontrkcalibvalues: which attributes to each run index (1->11) its corrresponding DAC value. The other parameters are used to tune the fit procedure (for expert). The last parameter indicates the number of events to be read: if "0" all events in the run are read, if not the parameter indicates the maximum number of events to be read.
Default values are listed below
\verbatim