#include "TClass.h"
#include "TStopwatch.h"
#include "TFormula.h"
+#include "TUUID.h"
+#include "TMD5.h"
+#include "TRandom3.h"
#include "AliHLTMemoryFile.h"
#include "AliHLTMisc.h"
#include <cassert>
return iResult;
}
+TUUID AliHLTComponent::GenerateGUID()
+{
+ // Generates a globally unique identifier.
+
+ // Start by creating a new UUID. We cannot use the one automatically generated
+ // by ROOT because the algorithm used will not guarantee unique IDs when generating
+ // these UUIDs at a high rate in parallel.
+ TUUID uuid;
+ // We then use the generated UUID to form part of the random number seeds which
+ // will be used to generate a proper random UUID. For good measure we use a MD5
+ // hash also. Note that we want to use the TUUID class because it will combine the
+ // host address information into the UUID. Using gSystem->GetHostByName() apparently
+ // can cause problems on Windows machines with a firewall, because it always tries
+ // to contact a DNS. The TUUID class handles this case appropriately.
+ union
+ {
+ UChar_t buf[16];
+ UShort_t word[8];
+ UInt_t dword[4];
+ };
+ uuid.GetUUID(buf);
+ TMD5 md5;
+ md5.Update(buf, sizeof(buf));
+ TMD5 md52 = md5;
+ md5.Final(buf);
+ dword[0] += gSystem->GetUid();
+ dword[1] += gSystem->GetGid();
+ dword[2] += gSystem->GetPid();
+ for (int i = 0; i < 4; ++i)
+ {
+ gRandom->SetSeed(dword[i]);
+ dword[i] = gRandom->Integer(0xFFFFFFFF);
+ }
+ md52.Update(buf, sizeof(buf));
+ md52.Final(buf);
+ // To keep to the standard we need to set the version and reserved bits.
+ word[3] = (word[3] & 0x0FFF) | 0x4000;
+ buf[8] = (buf[8] & 0x3F) | 0x80;
+
+ // Create the name of the new class and file.
+ char uuidstr[64];
+ sprintf(uuidstr, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ dword[0], word[2], word[3], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]
+ );
+
+ uuid.SetUUID(uuidstr);
+ return uuid;
+}
+
int AliHLTComponent::ScanECSParam(const char* ecsParam)
{
// see header file for function documentation
class TObjArray;
class TMap;
class TStopwatch;
+class TUUID;
class AliRawDataHeader;
class AliHLTComponent;
class AliHLTMemoryFile;
*/
int GetLastObjectSize() const {return fLastObjectSize;}
+ /**
+ * This method generates a V4 Globally Unique Identifier (GUID) using the
+ * ROOT TRandom3 pseudo-random number generator with the process' UID, GID
+ * PID and host address as seeds. For good measure MD5 sum hashing is also
+ * applied.
+ * @return the newly generated GUID structure.
+ */
+ static TUUID GenerateGUID();
+
protected:
/**
#include "AliCDBStorage.h"
#include "AliCDBEntry.h"
#include "TUUID.h"
-#include "TMD5.h"
-#include "TRandom3.h"
#include "TROOT.h"
#include "TSystem.h"
#include "TRegexp.h"
fIncludeFiles(TObjString::Class()),
fLibStateAtLoad(),
fBits(0),
- fDataEventsOnly(true)
- , fMonitorPeriod(-1)
+ fDataEventsOnly(true),
+ fMonitorPeriod(-1),
+ fUniqueID(0)
{
// Default constructor.
(triggerResult == true) ? description.Data() : GetDescription()
);
+ decision.SetUniqueID(fUniqueID);
decision.SetCounters(fTrigger->GetCounters(), GetEventCount()+1);
if (fTrigger->CallFailed()) return -EPROTO;
}
-void AliHLTGlobalTriggerComponent::GenerateFileName(TString& name, TString& filename) const
+void AliHLTGlobalTriggerComponent::GenerateFileName(TString& name, TString& filename)
{
// Creates a unique file name for the generated code.
- // Start by creating a new UUID. We cannot use the one automatically generated
- // by ROOT because the algorithm used will not guarantee unique IDs when generating
- // these UUIDs at a high rate in parallel.
- TUUID uuid;
- // We then use the generated UUID to form part of the random number seeds which
- // will be used to generate a proper random UUID. For good measure we use a MD5
- // hash also. Note that we want to use the TUUID class because it will combine the
- // host address information into the UUID. Using gSystem->GetHostByName() apparently
- // can cause problems on Windows machines with a firewall, because it always tries
- // to contact a DNS. The TUUID class handles this case appropriately.
- union
- {
- UChar_t buf[16];
- UShort_t word[8];
- UInt_t dword[4];
- };
- uuid.GetUUID(buf);
- TMD5 md5;
- md5.Update(buf, sizeof(buf));
- TMD5 md52 = md5;
- md5.Final(buf);
- dword[0] += gSystem->GetUid();
- dword[1] += gSystem->GetGid();
- dword[2] += gSystem->GetPid();
- for (int i = 0; i < 4; ++i)
- {
- gRandom->SetSeed(dword[i]);
- dword[i] = gRandom->Integer(0xFFFFFFFF);
- }
- md52.Update(buf, sizeof(buf));
- md52.Final(buf);
- // To keep to the standard we need to set the version and reserved bits.
- word[3] = (word[3] & 0x0FFF) | 0x4000;
- buf[8] = (buf[8] & 0x3F) | 0x80;
-
- // Create the name of the new class and file.
- char uuidstr[64];
- sprintf(uuidstr, "%08x_%04x_%04x_%02x%02x_%02x%02x%02x%02x%02x%02x",
- dword[0], word[2], word[3], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]
- );
+ TUUID guid = GenerateGUID();
+ UChar_t buf[16];
+ guid.GetUUID(buf);
+ fUniqueID = *reinterpret_cast<UInt_t*>(buf);
+ TString guidstr = guid.AsString();
+ // Replace '-' with '_' in string.
+ for (int i = 0; i < guidstr.Length(); ++i)
+ {
+ if (guidstr[i] == '-') guidstr[i] = '_';
+ }
name = "AliHLTGlobalTriggerImpl_";
- name += uuidstr;
+ name += guidstr;
filename = name + ".cxx";
// For good measure, check that the file names are not used. If they are then regenerate.
int LoadTriggerMenu(const char* cdbPath, const AliHLTTriggerMenu*& menu);
/**
- * Generates a file name for the generated on the fly code using a UUID.
+ * Generates a file name for the generated on the fly code using a GUID.
* \param name <i>out</i> The name of the class to use.
* \param filename <i>out</i> The name of the file containing the code.
*/
- void GenerateFileName(TString& name, TString& filename) const;
+ void GenerateFileName(TString& name, TString& filename);
/**
* Generates the code for the global trigger to apply the given trigger menu.
AliHLTUInt32_t fBits; //! Status bits
bool fDataEventsOnly; //! Flag indicating if only data events are processed with trigger logic.
int fMonitorPeriod; //! Period of the monitoring trigger in s, -1 means monitoring trigger off
+ UInt_t fUniqueID; //! Unique ID for the decision output objects.
static const char* fgkTriggerMenuCDBPath; //! The path string to read the trigger menu from the CDB.
sys.BuildTaskList("sink");
sys.Run(
numOfEvents,
- 1, // Stop chain at end of run.
- 0x1 // Active CTP trigger mask.
+ 1, // Stop chain at end of run.
+ 0x1, // Active CTP trigger mask.
+ 0, // Time stamp.
+ 0 // Event type.
);
}