]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Moving GUID calculation to base class and setting unique ID of global decisions to...
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 8 Sep 2010 12:27:26 +0000 (12:27 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 8 Sep 2010 12:27:26 +0000 (12:27 +0000)
HLT/BASE/AliHLTComponent.cxx
HLT/BASE/AliHLTComponent.h
HLT/trigger/AliHLTGlobalTriggerComponent.cxx
HLT/trigger/AliHLTGlobalTriggerComponent.h
HLT/trigger/test/testGlobalTriggerComponent.C

index 9c649d4caa0544b979b8910bb3be03f8ad05a092..ad800acb7f3c69d1374110cbd7865835cc9da6a5 100644 (file)
@@ -42,6 +42,9 @@ using namespace std;
 #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>
@@ -2585,6 +2588,55 @@ int AliHLTComponent::LoggingVarargs(AliHLTComponentLogSeverity severity,
   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
index 117d2e94ce1764226cb67a83b9e6e0495d221dd8..335f14c6034f1cedde02afd2ad03d0aa14f554e4 100644 (file)
@@ -82,6 +82,7 @@ class AliHLTComponentHandler;
 class TObjArray;
 class TMap;
 class TStopwatch;
+class TUUID;
 class AliRawDataHeader;
 class AliHLTComponent;
 class AliHLTMemoryFile;
@@ -877,6 +878,15 @@ class AliHLTComponent : public AliHLTLogging {
    */
   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:
 
   /**
index 694c1a6d831f036a9bd5e82b3dcf1e6f454c1903..340bfdad5e2aa1d2ba6a8f165d87f7dcb9c9eef8 100644 (file)
@@ -33,8 +33,6 @@
 #include "AliCDBStorage.h"
 #include "AliCDBEntry.h"
 #include "TUUID.h"
-#include "TMD5.h"
-#include "TRandom3.h"
 #include "TROOT.h"
 #include "TSystem.h"
 #include "TRegexp.h"
@@ -83,8 +81,9 @@ AliHLTGlobalTriggerComponent::AliHLTGlobalTriggerComponent() :
        fIncludeFiles(TObjString::Class()),
        fLibStateAtLoad(),
        fBits(0),
-       fDataEventsOnly(true)
-       , fMonitorPeriod(-1)
+       fDataEventsOnly(true),
+       fMonitorPeriod(-1),
+       fUniqueID(0)
 {
   // Default constructor.
   
@@ -488,6 +487,7 @@ int AliHLTGlobalTriggerComponent::DoTrigger()
       (triggerResult == true) ? description.Data() : GetDescription()
     );
 
+  decision.SetUniqueID(fUniqueID);
   decision.SetCounters(fTrigger->GetCounters(), GetEventCount()+1);
   if (fTrigger->CallFailed()) return -EPROTO;
   
@@ -706,52 +706,22 @@ int AliHLTGlobalTriggerComponent::LoadTriggerMenu(const char* cdbPath, const Ali
 }
 
 
-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.
index e5204a54fc99c9d467ff9142bd3c352d5b0dc859..08a84b94e8ae2f7370bd0450848e54705bd629e7 100644 (file)
@@ -202,11 +202,11 @@ class AliHLTGlobalTriggerComponent : public AliHLTTrigger
   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.
@@ -308,6 +308,7 @@ class AliHLTGlobalTriggerComponent : public AliHLTTrigger
   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.
   
index 47809a52838eb325ad4925f2ff4594d6584b2986..1d285df52caea318642f29fcd310ec20dcdfc312 100644 (file)
@@ -202,8 +202,10 @@ void RunTrigger(int config = 0, bool usecint = false, bool debug = false, int nu
        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.
        );
 }