]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Update of DAs (PED & GAIN):
authorlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 21 Apr 2010 11:05:06 +0000 (11:05 +0000)
committerlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 21 Apr 2010 11:05:06 +0000 (11:05 +0000)
- Add messages giving faulty DDL (and FRT) in case of Token lost errors
- Pedestal forced to 4095 (or 4090) when statistics < 10 events (or
RMS < 0.5)

(Jean-Luc Charvet)

MUON/AliMUONGain.cxx
MUON/AliMUONPedestal.cxx
MUON/AliMUONPedestal.h
MUON/MUONTRKGAINda.cxx
MUON/MUONTRKPEDda.cxx
MUON/READMEmchda.txt

index 998f0ae850f37c549cce681d6eaf78a36485fe1f..b42e01dbed2af038f8c2b92754618a5dd79a445f 100644 (file)
@@ -269,7 +269,7 @@ void AliMUONGain::MakeGainStore(TString shuttleFile)
   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);
@@ -496,15 +496,17 @@ void AliMUONGain::MakeGainStore(TString shuttleFile)
 
          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];
index d4de7c3293c5658f0b158bcb20149436deb94f5a..70bd7296781adc96a70ab4d358f7e61cb2b950f0 100644 (file)
@@ -50,6 +50,8 @@ ClassImp(AliMUONPedestal)
 AliMUONPedestal::AliMUONPedestal()
 : TObject(),
 //fN(0),
+fNCurrentEvents(0),
+fNEvthreshold(0),
 fNEvents(0),
 fRunNumber(0),
 fNChannel(0),
@@ -96,20 +98,6 @@ void AliMUONPedestal::LoadConfig(const char* dbfile)
   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())
     { 
@@ -194,6 +182,7 @@ void AliMUONPedestal::Finalize()
   
   Double_t pedMean;
   Double_t pedSigma;
+  Double_t pedSigmalimit=0.5;
   Int_t busPatchId;
   Int_t manuId;
   Int_t channelId;
@@ -201,8 +190,8 @@ void AliMUONPedestal::Finalize()
   // 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())))
@@ -212,6 +201,8 @@ void AliMUONPedestal::Finalize()
        }
     }
 
+  Int_t nADC4090=0;
+  Int_t nADCmax=0;
   // iterator over pedestal
   TIter next(fPedestalStore ->CreateIterator());
   AliMUONVCalibParam* ped;
@@ -222,8 +213,8 @@ void AliMUONPedestal::Finalize()
       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
@@ -236,7 +227,6 @@ void AliMUONPedestal::Finalize()
        {
          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;
@@ -244,39 +234,45 @@ void AliMUONPedestal::Finalize()
       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
@@ -286,14 +282,18 @@ 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;
@@ -302,12 +302,12 @@ void AliMUONPedestal::MakeASCIIoutput(ostream& out) const
       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)
@@ -325,10 +325,10 @@ void AliMUONPedestal::MakeASCIIoutput(ostream& out) const
              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))))
@@ -336,13 +336,11 @@ void AliMUONPedestal::MakeASCIIoutput(ostream& out) const
              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;
@@ -376,6 +374,7 @@ void AliMUONPedestal::MakeControlHistos()
 
   Double_t pedMean;
   Double_t pedSigma;
+  Double_t evt;
   Int_t busPatchId;
   Int_t manuId;
   Int_t channelId;
@@ -413,10 +412,12 @@ void AliMUONPedestal::MakeControlHistos()
   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() ) ) )
   {
@@ -427,6 +428,8 @@ void AliMUONPedestal::MakeControlHistos()
     {
       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);
index 47ca993c5d44b5d1114e177168b124cd3c3616c8..5de7f59c6e8d7bf746aa42a61e22445a8170901f 100644 (file)
@@ -29,6 +29,8 @@ class AliMUONPedestal : public TObject
     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
@@ -50,6 +52,8 @@ class AliMUONPedestal : public TObject
 
     /// 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
@@ -65,6 +69,8 @@ class AliMUONPedestal : public TObject
 
 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)
@@ -90,7 +96,7 @@ protected:
     /// Not implemented
     AliMUONPedestal& operator = (const AliMUONPedestal& rhs);
 
-  ClassDef(AliMUONPedestal,4) // Pedestal computing for DA 
+  ClassDef(AliMUONPedestal,5) // Pedestal computing for DA 
 };
 
 #endif
index bc862ee00a891276ae491e9b4e4793d5796aa4c6..c49d9883a509d02fed7f0a98e5e14f1df7681ce6 100644 (file)
@@ -41,7 +41,7 @@
 
 /*
  -------------------------------------------------------------------------
- 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
@@ -76,6 +76,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"
@@ -144,6 +147,7 @@ int main(Int_t argc, const char** argv)
   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]="";
@@ -204,6 +208,7 @@ int main(Int_t argc, const char** argv)
   muonGain->SetAliPrintLevel(printLevel);
   muonGain->SetAliPlotLevel(plotLevel);
   muonGain->SetconfigDA(nConfig);
+  muonGain->SetnEvthreshold(nEvthreshold);
   
   if(nConfig)
   {
@@ -218,10 +223,20 @@ int main(Int_t argc, const char** argv)
   // 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())
   {
@@ -238,8 +253,7 @@ int main(Int_t argc, const char** argv)
     {
       rawReader->NextEvent();
       skipEvents--;
-    }
-    
+    }  
     Int_t eventType = rawReader->GetType();
     runNumber = rawReader->GetRunNumber();
     
@@ -248,7 +262,7 @@ int main(Int_t argc, const char** 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 << "  (DAC=" << injCharge << ")" << endl;
@@ -265,6 +279,7 @@ int main(Int_t argc, const char** 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;
@@ -274,19 +289,49 @@ int main(Int_t argc, const char** argv)
     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)
@@ -295,101 +340,105 @@ int main(Int_t argc, const char** argv)
           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;
@@ -427,6 +476,30 @@ int main(Int_t argc, const char** argv)
   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)
   {
index 7b8617d31c28bdd922fc65ba1978af0d16fb7f28..5f48d712509b7cd2a98b5181b33dc5b094801bc7 100644 (file)
@@ -29,7 +29,7 @@
 
 /*
        -------------------------------------------------------------------------
-        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
@@ -66,6 +66,8 @@ extern "C" {
 #include "AliRawDataErrorLog.h"
 #include "AliMUONTrackerIO.h"
 #include "AliLog.h"
+#include "AliMUONDspHeader.h"
+#include "AliDAQ.h"
 
 //ROOT
 #include "TFile.h"
@@ -139,7 +141,8 @@ int main(Int_t argc, const char **argv)
   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
@@ -226,9 +229,11 @@ int main(Int_t argc, const char **argv)
       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)
@@ -250,10 +255,14 @@ int main(Int_t argc, const char **argv)
   // 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;
@@ -264,14 +273,12 @@ int main(Int_t argc, const char **argv)
       // check shutdown condition 
       if (daqDA_checkShutdown()) 
        break;
-
       //Skip events
       while (skipEvents)
        {
          rawReader->NextEvent();
          skipEvents--;
        }
-
       Int_t eventType = rawReader->GetType();
       runNumber = rawReader->GetRunNumber();
 
@@ -297,6 +304,7 @@ int main(Int_t argc, const char **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;
@@ -312,6 +320,34 @@ int main(Int_t argc, const char **argv)
          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;
@@ -319,6 +355,8 @@ int main(Int_t argc, const char **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)
@@ -327,7 +365,6 @@ int main(Int_t argc, const char **argv)
                  muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
                }
            }
-         nEvents++;
        }
       else
        {
@@ -350,6 +387,8 @@ int main(Int_t argc, const char **argv)
                              <<" 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
@@ -388,13 +427,14 @@ int main(Int_t argc, const char **argv)
                      // 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 )) 
                {
@@ -420,7 +460,8 @@ int main(Int_t argc, const char **argv)
       if (eventGlitchErrors)  nGlitchErrors++;
       if (eventParityErrors)  nParityErrors++;
       if (eventPaddingErrors) nPaddingErrors++;
-      if (eventTokenlostErrors) nTokenlostErrors++;
+      //      if (eventTokenlostErrors) nTokenlostErrors++;
+      //      muonPedestal->SetAliNCurrentEvents(nEvents);
 
     } // while (rawReader->NextEvent())
   delete rawReader;
@@ -447,10 +488,9 @@ int main(Int_t argc, const char **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
@@ -486,6 +526,30 @@ int main(Int_t argc, const char **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;
index d305506fd66ad6579b4cbb666c238b32333ebffe..56efbb1486f6be910e0d0971e92996eccaf0e2f2 100644 (file)
@@ -70,12 +70,10 @@ The syntax is: MUONTRKPEDda.exe "raw data file"
 
 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
@@ -86,7 +84,7 @@ The syntax is: MUONTRKGAINda.exe "raw data file"
 
 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