// Author: Fons Rademakers 26/11/99
// Updated: Dario Favretto 15/04/2003
+/**************************************************************************
+ * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+//////////////////////////////////////////////////////////////////////////
+// //
+// AliRawEvent //
+// //
+// Set of classes defining the ALICE RAW event format. The AliRawEvent //
+// class defines a RAW event. It consists of an AliEventHeader object //
+// an AliEquipmentHeader object, an AliRawData object and an array of //
+// sub-events, themselves also being AliRawEvents. The number of //
+// sub-events depends on the number of DATE LDC's. //
+// The AliRawEvent objects are written to a ROOT file using different //
+// technologies, i.e. to local disk via AliRawDB or via rfiod using //
+// AliRawRFIODB or via rootd using AliRawRootdDB or to CASTOR via //
+// rootd using AliRawCastorDB (and for performance testing there is //
+// also AliRawNullDB). //
+// The AliRunDB class provides the interface to the run and file //
+// catalogues (AliEn or plain MySQL). //
+// The AliStats class provides statics information that is added as //
+// a single keyed object to each raw file. //
+// The AliTagDB provides an interface to a TAG database. //
+// The AliMDC class is usid by the "alimdc" stand-alone program //
+// that reads data directly from DATE. //
+// //
+//////////////////////////////////////////////////////////////////////////
+
#include <sys/types.h>
#include <sys/stat.h>
#if defined(__DECCXX)
#include <TSQLResult.h>
#include <TUrl.h>
#include <TGrid.h>
+#include <TH1.h>
#if defined(__APPLE__)
#undef Free
// Fixed file system locations for the different DB's
#ifdef USE_RDM
-const char *kFifo = "/tmp/alimdc.fifo";
-const char *kRawDBFS[2] = { "/tmp/mdc1", "/tmp/mdc2" };
-const char *kTagDBFS = "/tmp/mdc1/tags";
-const char *kRunDBFS = "/tmp/mdc1/meta";
-const char *kRFIOFS = "rfio:/castor/cern.ch/user/r/rdm";
-const char *kCastorFS = "castor:/castor/cern.ch/user/r/rdm";
-const char *kRootdFS = "root://localhost//tmp/mdc1";
-const char *kAlienHost = "alien://aliens7.cern.ch:15000/?direct";
-const char *kAlienDir = "/alice_mdc/DC";
+const char* const kFifo = "/tmp/alimdc.fifo";
+const char* const kRawDBFS[2] = { "/tmp/mdc1", "/tmp/mdc2" };
+const char* const kTagDBFS = "/tmp/mdc1/tags";
+const char* const kRunDBFS = "/tmp/mdc1/meta";
+const char* const kRFIOFS = "rfio:/castor/cern.ch/user/r/rdm";
+const char* const kCastorFS = "castor:/castor/cern.ch/user/r/rdm";
+const char* const kRootdFS = "root://localhost//tmp/mdc1";
+const char* const kAlienHost = "alien://aliens7.cern.ch:15000/?direct";
+const char* const kAlienDir = "/alice_mdc/DC";
#else
-const char *kFifo = "/tmp/alimdc.fifo";
-const char *kRawDBFS[2] = { "/data1/mdc", "/data2/mdc" };
-const char *kTagDBFS = "/data1/mdc/tags";
-const char *kRunDBFS = "/data1/mdc/meta";
-const char *kRFIOFS = "rfio:/castor/cern.ch/lcg/dc5";
-const char *kCastorFS = "castor:/castor/cern.ch/lcg/dc5";
-const char *kRootdFS = "root://localhost//tmp/mdc1";
-const char *kAlienHost = "alien://aliens7.cern.ch:15000/?direct";
-const char *kAlienDir = "/alice_mdc/DC";
+const char* const kFifo = "/tmp/alimdc.fifo";
+const char* const kRawDBFS[2] = { "/data1/mdc", "/data2/mdc" };
+const char* const kTagDBFS = "/data1/mdc/tags";
+const char* const kRunDBFS = "/data1/mdc/meta";
+const char* const kRFIOFS = "rfio:/castor/cern.ch/lcg/dc5";
+const char* const kCastorFS = "castor:/castor/cern.ch/lcg/dc5";
+const char* const kRootdFS = "root://localhost//tmp/mdc1";
+const char* const kAlienHost = "alien://aliens7.cern.ch:15000/?direct";
+const char* const kAlienDir = "/alice_mdc/DC";
#endif
// Maximum size of tag db files
// raw data object, otherwise a private copy will be made.
fNSubEvents = 0;
- fEvtHdr = new AliRawEventHeader;
+ fEvtHdr = 0;
fEqpHdr = 0;
fRawData = 0;
fSubEvents = 0;
}
+//______________________________________________________________________________
+AliRawEventHeader *AliRawEvent::GetHeader()
+{
+ // Get event header part of AliRawEvent.
+
+ if (!fEvtHdr)
+ fEvtHdr = new AliRawEventHeader;
+
+ return fEvtHdr;
+}
+
//______________________________________________________________________________
AliRawEquipmentHeader *AliRawEvent::GetEquipmentHeader()
{
}
//______________________________________________________________________________
-Bool_t AliRawDB::FSHasSpace(const char *fs)
+Bool_t AliRawDB::FSHasSpace(const char *fs) const
{
// Check for at least fMaxSize bytes of free space on the file system.
// If the space is not available return kFALSE, kTRUE otherwise.
}
//______________________________________________________________________________
-const char *AliRawDB::GetFileName()
+const char *AliRawDB::GetFileName() const
{
// Return filename based on hostname and date and time. This will make
// each file unique. Also makes sure (via FSHasSpace()) that there is
{
// Create a new raw DB.
- const Int_t maxRetry = 10;
+ const Int_t kMaxRetry = 200;
+ const Int_t kMaxSleep = 1; // seconds
+ const Int_t kMaxSleepLong = 10; // seconds
Int_t retry = 0;
again:
retry++;
fRawDB = TFile::Open(fname, GetOpenOption(),
- Form("ALICE MDC%d raw DB", kMDC), fCompress);
+ Form("ALICE MDC%d raw DB", kMDC), fCompress,
+ GetNetopt());
if (!fRawDB) {
- if (retry < maxRetry) {
- Warning("Create", "failure to open file, sleeping 10 seconds before retrying...");
- gSystem->Sleep(10000);
+ if (retry < kMaxRetry) {
+ Warning("Create", "failure to open file, sleeping %d %s before retrying...",
+ kMaxSleep, kMaxSleep==1 ? "second" : "seconds");
+ gSystem->Sleep(kMaxSleep*1000);
goto again;
}
- Error("Create", "failure to open file %s after %d tries", fname, maxRetry);
+ Error("Create", "failure to open file %s after %d tries", fname, kMaxRetry);
return kFALSE;
}
+ if (retry > 1)
+ Warning("Create", "succeeded to open file after %d retries", retry);
+
if (fRawDB->IsZombie()) {
if (fRawDB->GetErrno() == ENOSPC ||
fRawDB->GetErrno() == 1018 || // SECOMERR
fRawDB->GetErrno() == 1027) { // SESYSERR
fRawDB->ResetErrno();
delete fRawDB;
- Warning("Create", "file is a zombie (no space), sleeping 10 seconds before retrying...");
- gSystem->Sleep(10000); // sleep 10 seconds before retrying
+ Warning("Create", "file is a zombie (no space), sleeping %d %s before retrying...",
+ kMaxSleepLong, kMaxSleepLong==1 ? "second" : "seconds");
+ gSystem->Sleep(kMaxSleepLong*1000); // sleep 10 seconds before retrying
goto again;
}
Error("Create", "file %s is zombie", fname);
fRawDB->ResetErrno();
delete fRawDB;
fRawDB = 0;
- if (retry < maxRetry) {
- Warning("Create", "file is a zombie, sleeping 10 seconds before retrying...");
- gSystem->Sleep(10000);
+ if (retry < kMaxRetry) {
+ Warning("Create", "file is a zombie, sleeping %d %s before retrying...",
+ kMaxSleep, kMaxSleep==1 ? "second" : "seconds");
+ gSystem->Sleep(kMaxSleep*1000);
goto again;
}
- Error("Create", "failure to open file %s after %d tries", fname, maxRetry);
+ Error("Create", "failure to open file %s after %d tries", fname, kMaxRetry);
return kFALSE;
}
// WHATEVER HAS BEEN SET IN THE DATE SITE
//gSystem->Setenv("STAGE_POOL", "lcg00");
//gSystem->Setenv("STAGE_HOST", "stage013");
+
+ // however for sanity we check if they are really set
+ if (!gSystem->Getenv("STAGE_POOL"))
+ Error("AliRawRFIODB", "STAGE_POOL not set");
+ if (!gSystem->Getenv("STAGE_HOST"))
+ Error("AliRawRFIODB", "STAGE_HOST not set");
init = 1;
}
#endif
}
//______________________________________________________________________________
-const char *AliRawRFIODB::GetFileName()
+const char *AliRawRFIODB::GetFileName() const
{
// Return filename based on hostname and date and time. This will make
// each file unique. Also the directory will be made unique for each
// WHATEVER HAS BEEN SET IN THE DATE SITE
//gSystem->Setenv("STAGE_POOL", "lcg00");
//gSystem->Setenv("STAGE_HOST", "stage013");
+
+ // however for sanity we check if they are really set
+ if (!gSystem->Getenv("STAGE_POOL"))
+ Error("AliRawRFIODB", "STAGE_POOL not set");
+ if (!gSystem->Getenv("STAGE_HOST"))
+ Error("AliRawRFIODB", "STAGE_HOST not set");
init = 1;
}
#endif
}
//______________________________________________________________________________
-const char *AliRawCastorDB::GetFileName()
+const char *AliRawCastorDB::GetFileName() const
{
// Return filename based on hostname and date and time. This will make
// each file unique. Also the directory will be made unique for each
}
//______________________________________________________________________________
-const char *AliRawRootdDB::GetFileName()
+const char *AliRawRootdDB::GetFileName() const
{
// Return filename based on hostname and date and time. This will make
// each file unique. Also the directory will be made unique for each
}
//______________________________________________________________________________
-const char *AliRawNullDB::GetFileName()
+const char *AliRawNullDB::GetFileName() const
{
// Return /dev/null as filename.
}
//______________________________________________________________________________
-const char *AliTagDB::GetFileName()
+const char *AliTagDB::GetFileName() const
{
// Return filename based on hostname and date and time. This will make
// each file unique. The tags will be stored in the /data1/tags directory.
}
//______________________________________________________________________________
-const char *AliTagNullDB::GetFileName()
+const char *AliTagNullDB::GetFileName() const
{
// Return /dev/null as filename.
TGrid *g = TGrid::Connect(kAlienHost, "");
TString lfn = kAlienDir;
+ TDatime dt;
+
+ // make a subdirectory for each day
+ lfn += "/adc-";
+ lfn += dt.GetDate();
+
+ // check if directory exists, if not create it
+ Grid_ResultHandle_t res = 0;
+ if (!(res = g->OpenDir(lfn))) {
+ // directory does not exist, create it
+ if (g->Mkdir(lfn) == -1) {
+ Error("UpdateAliEn", "cannot create directory %s", lfn.Data());
+ lfn = kAlienDir;
+ }
+ }
+ if (res) g->CloseResult(res);
+
lfn += "/";
lfn += gSystem->BaseName(stats->GetFileName());
//----------------- Use SIGUSR1 to interupt endless loop -----------------------
class AliMDCInterruptHandler : public TSignalHandler {
-private:
- AliMDC *fMDC; // alimdc to signal
public:
AliMDCInterruptHandler(AliMDC *mdc) : TSignalHandler(kSigUser1, kFALSE), fMDC(mdc) { }
Bool_t Notify() {
fMDC->SetStopLoop();
return kTRUE;
}
+private:
+ AliMDC *fMDC; // alimdc to signal
+
+ AliMDCInterruptHandler(const AliMDCInterruptHandler &);
+ void operator=(const AliMDCInterruptHandler &);
};
//______________________________________________________________________________
Info("Run", "Skipping %s (%d bytes)", header.GetTypeName(), skip);
continue;
}
- break;
default:
ALIDEBUG(1) {
Int_t s = header.GetEventSize() - header.HeaderSize();
return nrecv;
}
-#ifdef USE_HLT
-#include <AliTPCL3Tunnel.h>
-#endif
-
//______________________________________________________________________________
Int_t AliMDC::Filter(AliRawData &raw)
{
// Call 3rd level filter for this raw data segment.
#ifdef USE_HLT
- AliTPCL3Tunnel *tunnel = 0;
- if (!tunnel) {
- // initialisation
- tunnel = new AliTPCL3Tunnel(Form("%s/TPCparams.root",
- gSystem->Getenv("ALITPC")));
- }
-
- Int_t obytes, nbytes;
- obytes = nbytes = raw.GetSize();
- char *outbuf = tunnel->EvalTrack((char *)raw.GetBuffer(), nbytes);
-
- raw.SetSize(nbytes);
- memcpy(raw.GetBuffer(), outbuf, nbytes);
- printf("Filter called for event %d: reduced from %d to %d\n", fNumEvents,
- obytes, nbytes);
+ // Add HLT code here
#else