//////////////////////////////////////////////////////////////////////////
#include <errno.h>
+#include <Riostream.h>
+
+#if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
+#include <TBufferFile.h>
+#else
+#include <TBuffer.h>
+#endif
#include <TSystem.h>
#include <TKey.h>
-#ifdef ALI_DATE
-#include "event.h"
-#endif
+#include <TObjString.h>
#include "AliESD.h"
#include "AliRawEvent.h"
-#include "AliRawEventHeader.h"
+#include "AliRawDataArray.h"
+#include "AliRawEventHeaderBase.h"
+#include "AliRawEquipment.h"
+#include "AliRawEquipmentHeader.h"
#include "AliStats.h"
#include "AliRawDB.h"
ClassImp(AliRawDB)
+const char *AliRawDB::fgkAliRootTag = "$Name$";
//______________________________________________________________________________
AliRawDB::AliRawDB(AliRawEvent *event,
{
// Create a new raw DB
- // Consistency check with DATE header file
-#ifdef ALI_DATE
- if (fEvent->GetHeader()->HeaderSize() != EVENT_HEAD_BASE_SIZE) {
- Error("AliRawDB", "inconsistency between DATE and AliRawEvent headers");
- MakeZombie();
- return;
- }
-#endif
+ for (Int_t iDet = 0; iDet < AliDAQ::kNDetectors; iDet++)
+ fDetRawData[iDet] = new AliRawDataArray(AliDAQ::NumberOfDdls(iDet));
+
+ fDetRawData[AliDAQ::kNDetectors] = new AliRawDataArray(100);
if (fileName) {
if (!Create(fileName))
}
}
-//______________________________________________________________________________
-AliRawDB::AliRawDB(const AliRawDB& rawDB): TObject(rawDB)
-{
-// copy constructor
-
- Fatal("AliRawDB", "copy constructor not implemented");
-}
//______________________________________________________________________________
-AliRawDB& AliRawDB::operator = (const AliRawDB& /*rawDB*/)
-{
-// assignment operator
+AliRawDB::~AliRawDB() {
+ // Destructor
+
+ if(Close()==-1) Error("~AliRawDB", "cannot close output file!");
- Fatal("operator =", "assignment operator not implemented");
- return *this;
+ for (Int_t iDet = 0; iDet < (AliDAQ::kNDetectors + 1); iDet++)
+ delete fDetRawData[iDet];
}
//______________________________________________________________________________
retry++;
fRawDB = TFile::Open(fname, GetOpenOption(),
- Form("ALICE MDC%d raw DB", kMDC), fCompress,
+ Form("ALICE raw-data file (%s)", GetAliRootTag()), fCompress,
GetNetopt());
if (!fRawDB) {
if (retry < kMaxRetry) {
{
// Create ROOT Tree object container.
- fTree = new TTree("RAW", Form("ALICE MDC%d raw data tree", kMDC));
+ fTree = new TTree("RAW", Form("ALICE raw-data tree (%s)", GetAliRootTag()));
fTree->SetAutoSave(2000000000); // autosave when 2 Gbyte written
+ fTree->BranchRef();
+
Int_t bufsize = 256000;
// splitting 29.6 MB/s, no splitting 35.3 MB/s on P4 2GHz 15k SCSI
//Int_t split = 1;
Int_t split = 0;
fTree->Branch("rawevent", "AliRawEvent", &fEvent, bufsize, split);
+ // Make brach for each sub-detector
+ for (Int_t iDet = 0; iDet < AliDAQ::kNDetectors; iDet++) {
+ fTree->Branch(AliDAQ::DetectorName(iDet),"AliRawDataArray",
+ &fDetRawData[iDet],bufsize,split);
+ }
+ // Make special branch for unrecognized raw-data payloads
+ fTree->Branch("Common","AliRawDataArray",
+ &fDetRawData[AliDAQ::kNDetectors],bufsize,split);
+
// Create tree which will contain the HLT ESD information
if (fESD) {
- fESDTree = new TTree("esdTree", Form("ALICE MDC%d HLT ESD tree", kMDC));
+ fESDTree = new TTree("esdTree", Form("ALICE HLT ESD tree (%s)", GetAliRootTag()));
fESDTree->SetAutoSave(2000000000); // autosave when 2 Gbyte written
split = 0;
fESDTree->Branch("ESD", "AliESD", &fESD, bufsize, split);
return -1;
}
- // Create semaphore to say this file is finished
- Int_t tfd = ::creat(Form("%s.done", fRawDB->GetName()), 0644);
- close(tfd);
-
delete fRawDB;
fRawDB = 0;
if(!error)
{
// Fill the trees and return the number of written bytes
+ for (Int_t iDet = 0; iDet < (AliDAQ::kNDetectors + 1); iDet++)
+ fDetRawData[iDet]->ClearData();
+
+ // Move the raw-data payloads to the corresponding branches
+ for(Int_t iSubEvent = 0; iSubEvent < fEvent->GetNSubEvents(); iSubEvent++) {
+ AliRawEvent *subEvent = fEvent->GetSubEvent(iSubEvent);
+ for(Int_t iEquipment = 0; iEquipment < subEvent->GetNEquipments(); iEquipment++) {
+ AliRawEquipment *equipment = subEvent->GetEquipment(iEquipment);
+ UInt_t eqId = equipment->GetEquipmentHeader()->GetId();
+ Int_t ddlIndex;
+ Int_t iDet = AliDAQ::DetectorIDFromDdlID(eqId,ddlIndex);
+ if (iDet < 0 || iDet > AliDAQ::kNDetectors)
+ iDet = AliDAQ::kNDetectors;
+ equipment->SetRawDataRef(fDetRawData[iDet]);
+ }
+ }
+
Double_t bytes = fRawDB->GetBytesWritten();
Bool_t error = kFALSE;
if (fTree->Fill() == -1)
TKey *key = dir->GetKey(fTree->GetName());
if (key) skey = key->GetKeylen();
}
- total += skey;
- if (fTree->GetZipBytes() > 0) total += fTree->GetTotBytes();
- TBuffer b(TBuffer::kWrite,10000);
- TTree::Class()->WriteBuffer(b,fTree);
- total += b.Length();
+ total += skey + fTree->GetZipBytes();
}
if(fESDTree)
TKey *key = dir->GetKey(fESDTree->GetName());
if (key) skey = key->GetKeylen();
}
- total += skey;
- if (fESDTree->GetZipBytes() > 0) total += fESDTree->GetTotBytes();
- TBuffer b(TBuffer::kWrite,10000);
- TTree::Class()->WriteBuffer(b,fESDTree);
- total += b.Length();
+ total += skey + fESDTree->GetZipBytes();
}
return total;
{
// Write stats to raw DB, local run DB and global MySQL DB.
- AliRawEventHeader &header = *GetEvent()->GetHeader();
+ AliRawEventHeaderBase &header = *GetEvent()->GetHeader();
// Write stats into RawDB
TDirectory *ds = gDirectory;
GetDB()->cd();
stats->SetEvents(GetEvents());
- stats->SetLastId(header.GetRunNumber(), header.GetEventInRun());
+ stats->SetLastId(header.GetP("Id")[0]);
stats->SetFileSize(GetBytesWritten());
stats->SetCompressionFactor(GetCompressionFactor());
stats->SetEndTime();
else
return fTree->GetTotBytes()/fTree->GetZipBytes();
}
+
+//______________________________________________________________________________
+const char *AliRawDB::GetAliRootTag()
+{
+ // Return the aliroot tag (version)
+ // used to generate the raw data file.
+ // Stored in the raw-data file title.
+
+ TString version = fgkAliRootTag;
+ version.Remove(TString::kBoth,'$');
+ version.ReplaceAll("Name","AliRoot version");
+
+ return version.Data();
+}
+
+//______________________________________________________________________________
+Bool_t AliRawDB::WriteGuidFile(const char *guidFileFolder)
+{
+ // Write the guid file
+ // in the specified folder or
+ // in the folder where the raw data
+ // file is.
+
+ TString guidFileName;
+ if (guidFileFolder) {
+ guidFileName = guidFileFolder;
+
+ TString pathStr = fRawDB->GetName();
+ TObjArray *pathArr = pathStr.Tokenize('/');
+ guidFileName.Append("/");
+ guidFileName.Append(((TObjString *)pathArr->Last())->String());
+ pathArr->Delete();
+ delete pathArr;
+ }
+ else
+ guidFileName = fRawDB->GetName();
+
+ guidFileName += ".guid";
+
+ ofstream fguid(guidFileName.Data());
+ if (!fguid.is_open()) {
+ Error("WriteGuidFile", "failure to open guid file %s", guidFileName.Data());
+ return kFALSE;
+ }
+ TString guid = fRawDB->GetUUID().AsString();
+ fguid << "guid: \t" << guid.Data();
+ fguid.close();
+
+ return kTRUE;
+}