+Int_t AliRawDB::Fill()
+{
+ // Fill the trees and return the number of written bytes
+
+ Double_t bytes = fRawDB->GetBytesWritten();
+ fTree->Fill();
+ if (fESDTree) fESDTree->Fill();
+ return Int_t(fRawDB->GetBytesWritten() - bytes);
+}
+
+//______________________________________________________________________________
+Int_t AliRawDB::GetTotalSize()
+{
+ // Return the total size of the trees
+ Int_t total = 0;
+
+ {
+ Int_t skey = 0;
+ TDirectory *dir = fTree->GetDirectory();
+ if (dir) {
+ 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();
+ }
+
+ if(fESDTree)
+ {
+ Int_t skey = 0;
+ TDirectory *dir = fESDTree->GetDirectory();
+ if (dir) {
+ 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();
+ }
+
+ return total;
+}
+
+//______________________________________________________________________________
+void AliRawDB::WriteStats(AliStats* stats)
+{
+ // Write stats to raw DB, local run DB and global MySQL DB.
+
+ AliRawEventHeader &header = *GetEvent()->GetHeader();
+
+ // Write stats into RawDB
+ TDirectory *ds = gDirectory;
+ GetDB()->cd();
+ stats->SetEvents(GetEvents());
+ stats->SetLastId(header.GetRunNumber(), header.GetEventInRun());
+ stats->SetFileSize(GetBytesWritten());
+ stats->SetCompressionFactor(GetCompressionFactor());
+ stats->SetEndTime();
+ stats->Write("stats");
+ ds->cd();
+}
+
+//______________________________________________________________________________
+Bool_t AliRawDB::NextFile(const char* fileName)