#include <TSystem.h>
#include <TKey.h>
+#include <TObjString.h>
+
#include "AliESD.h"
#include "AliRawEvent.h"
+#include "AliRawDataArray.h"
#include "AliRawEventHeaderBase.h"
+#include "AliRawEquipment.h"
+#include "AliRawEquipmentHeader.h"
#include "AliStats.h"
#include "AliRawDB.h"
{
// Create a new raw DB
+ 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))
MakeZombie();
}
}
+
+//______________________________________________________________________________
+AliRawDB::~AliRawDB() {
+ // Destructor
+
+ if(Close()==-1) Error("~AliRawDB", "cannot close output file!");
+
+ for (Int_t iDet = 0; iDet < (AliDAQ::kNDetectors + 1); iDet++)
+ delete fDetRawData[iDet];
+}
+
//______________________________________________________________________________
Bool_t AliRawDB::FSHasSpace(const char *fs) const
{
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) {
return -1;
}
- // Write a text file with file GUID
- TString guidFileName = fRawDB->GetName();
- guidFileName += ".guid";
- ofstream fguid(guidFileName.Data());
- TString guid = fRawDB->GetUUID().AsString();
- fguid << "guid: \t" << guid.Data();
- fguid.close();
-
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();
-#if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
- TBufferFile b(TBuffer::kWrite,10000);
-#else
- TBuffer b(TBuffer::kWrite,10000);
-#endif
- 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();
-#if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
- TBufferFile b(TBuffer::kWrite,10000);
-#else
- TBuffer b(TBuffer::kWrite,10000);
-#endif
- TTree::Class()->WriteBuffer(b,fESDTree);
- total += b.Length();
+ total += skey + fESDTree->GetZipBytes();
}
return total;
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;
+}