- // Events with errors
- if (recoverParityErrors && 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)
- {
- if (nEvents == 0) nChannel++;
- busPatch->GetData(i, manuId, channelId, charge);
- // if (busPatch->GetBusPatchId()==1719 && manuId == 1 && channelId == 0) cout <<"Recovered charge "<<charge<<endl;
- 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 (recoverParityErrors && 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;
-
- }
- } // end of if (!rawStream->GetGlitchErrors() && !rawStream->GetPaddingErrors() ...
- filcout<<"Number of errors : Glitch "<<eventGlitchErrors
- <<" Parity "<<eventParityErrors
- <<" Padding "<<eventPaddingErrors<<endl;
- filcout<<endl;
- } // end of if (!rawStream->IsErrorMessage())
-
- if (eventGlitchErrors) nGlitchErrors++;
- if (eventParityErrors) nParityErrors++;
- if (eventPaddingErrors) nPaddingErrors++;
-
- } // while (rawReader->NextEvent())
- delete rawReader;
- delete rawStream;
-
- // process and store mean peak values in .root file
- sprintf(flatFile,"%s_%d.par",prefixDA,runNumber);
- if(shuttleFile.IsNull())shuttleFile=flatFile;
- injCharge=vDAC[nIndex-1];
- muonGain->SetAliIndex(nIndex); // fIndex
- muonGain->SetAliInjCharge(injCharge);
- muonGain->SetAliNEvents(nEvents);
- muonGain->SetAliRunNumber(runNumber);
- muonGain->SetAliNChannel(nChannel);
- 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 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 events recovered = " << nEventsRecovered<< endl;
- filcout << prefixDA << " : Nb of events without errors = " << nEvents-nEventsRecovered<< endl;
- filcout << prefixDA << " : Nb of events used = " << nEvents << endl;
-
- // Computing gain
- if(nIndex==nEntries)
- {
- muonGain->SetAliInit(nInit); // fnInit
- muonGain->SetAliEntries(nEntries); // fnEntries
- muonGain->SetAliNbpf1(nbpf1); // fnbpf1
- muonGain->MakeGainStore(shuttleFile);
- }
-
- // Copying files to local DB folder defined by DAQ_DETDB_LOCAL
- Char_t *dir;
- dir= getenv("DAQ_DETDB_LOCAL");
- unsigned int nLastVersions = 2;
- cout << "\n *** Output files stored locally in " << dir << " (nb of previous versions = " << nLastVersions << ") ***" << endl;
- filcout << "\n *** Output files stored locally in " << dir << " (nb of previous versions = " << nLastVersions << ") ***" << endl;
-
- status = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions);
- if(nIndex==nEntries)status = daqDA_localDB_storeFile(muonGain->GetRootDataFileName(),nLastVersions);
- status = daqDA_localDB_storeFile(muonGain->GetHistoFileName(),nLastVersions);
- status = daqDA_localDB_storeFile(shuttleFile.Data(),nLastVersions);
-
- }
-
-
-// ouput files
+ // 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;
+
+ }
+ } // 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++;
+
+ } // while (rawReader->NextEvent())
+ delete rawReader;
+ delete rawStream;
+
+ // process and store mean peak values in .root file
+ sprintf(flatFile,"%s.par",prefixDA);
+ if(shuttleFile.IsNull())shuttleFile=flatFile;
+ injCharge=vDAC[nIndex-1];
+ muonGain->SetAliIndex(nIndex); // fIndex
+ muonGain->SetAliInjCharge(injCharge);
+ muonGain->SetAliNEvents(nEvents);
+ 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;
+
+ // Computing gain
+ if(nIndex==nEntries)
+ {
+ muonGain->SetAliInit(nInit); // fnInit
+ 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
+ }
+
+ // 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
+ Char_t *dir;
+ 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