Some of the trigger base classes. Steering part not yet in.
authoragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Nov 2009 17:32:55 +0000 (17:32 +0000)
committeragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Nov 2009 17:32:55 +0000 (17:32 +0000)
TRIGGER/AliTrigConnector.cxx [new file with mode: 0644]
TRIGGER/AliTrigConnector.h [new file with mode: 0644]
TRIGGER/AliTrigDevice.cxx [new file with mode: 0644]
TRIGGER/AliTrigDevice.h [new file with mode: 0644]
TRIGGER/AliTrigDigitalCircuit.cxx [new file with mode: 0644]
TRIGGER/AliTrigDigitalCircuit.h [new file with mode: 0644]
TRIGGER/AliTrigEvent.cxx [new file with mode: 0644]
TRIGGER/AliTrigEvent.h [new file with mode: 0644]

diff --git a/TRIGGER/AliTrigConnector.cxx b/TRIGGER/AliTrigConnector.cxx
new file mode 100644 (file)
index 0000000..0a82cc7
--- /dev/null
@@ -0,0 +1,160 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+/* $Id$ */
+// Author: Andrei Gheata, 28/07/2009
+
+//==============================================================================
+//   AliTrigConnector - General connector class. A connector links a feeder
+// device output to a number of other device inputs (clients). It transmits the 
+// signal to all clients and calls their SetInput() method.
+//==============================================================================
+
+#include "AliTrigConnector.h"
+
+#include <TObjArray.h>
+#include <TClass.h>
+
+#include "AliTrigDevice.h"
+#include "AliTrigEvent.h"
+
+
+ClassImp(AliTrigConnector)
+
+//______________________________________________________________________________
+AliTrigConnector::AliTrigConnector(const AliTrigConnector &other)
+                 :TNamed(other),
+                  fFeeder(other.fFeeder),
+                  fOutput(other.fOutput),
+                  fNclients(other.fNclients),
+                  fArraySize(other.fArraySize),
+                  fInputs(0),
+                  fDevices(0)
+{
+// Copy ctor.
+  if (fArraySize && other.fInputs) {
+    fInputs = new UInt_t[fArraySize];
+    memcpy(fInputs, other.fInputs, fNclients*sizeof(UInt_t));
+    fDevices = new TObjArray(fArraySize);
+    for (Int_t i=0; i<fNclients; i++) fDevices->Add(other.fDevices->At(i));
+  }   
+}                        
+
+//______________________________________________________________________________
+AliTrigConnector::~AliTrigConnector()
+{
+// Destructor.
+  if (fInputs) delete [] fInputs;
+  if (fDevices) delete fDevices;
+}
+
+//______________________________________________________________________________
+AliTrigConnector& AliTrigConnector::operator=(const AliTrigConnector &other)
+{
+// Assignment
+  if (&other == this) return *this;
+  TNamed::operator=(other);
+  fFeeder = other.fFeeder;
+  fOutput = other.fOutput;
+  fNclients = other.fNclients;
+  fArraySize = other.fArraySize;
+  fInputs = 0;
+  fDevices = 0;
+  if (fArraySize && other.fInputs) {
+    fInputs = new UInt_t[fArraySize];
+    memcpy(fInputs, other.fInputs, fNclients*sizeof(UInt_t));
+    fDevices = new TObjArray(fArraySize);
+    for (Int_t i=0; i<fNclients; i++) fDevices->Add(other.fDevices->At(i));
+  }     
+  return *this;
+}
+
+//______________________________________________________________________________
+void AliTrigConnector::Connect(AliTrigDevice *client, UInt_t input)
+{
+// Adds the device and its input to the list of clients.
+  // Loop array of inputs to check if this input is already connected.
+  for (Int_t i=0; i<fNclients; i++) {
+    if (fInputs[i]==input && fDevices->At(i)==client) {
+      Info("Connect", "Output #%d of device %s already connected to input #%d of device%s",
+           fOutput, fFeeder->GetName(), input, client->GetName());
+      return;
+    } 
+  }
+  if (!client->SetInputType(fFeeder->GetOutputType(fOutput))) {
+    Fatal("Cannot connect output slot #%d (type %s) of device %s to input slot #%d of device %s. Aborting",
+            fOutput, fFeeder->GetInputType(fOutput), fFeeder->GetName(), input, client->GetName());
+  }          
+  if (!fArraySize) {
+    fArraySize = 8;
+    fInputs = new UInt_t[fArraySize];
+    fDevices = new TObjArray(fArraySize);
+  }
+  if (fNclients >= fArraySize) {
+    fArraySize *= 2;
+    UInt_t *array = new UInt_t[fArraySize];
+    memcpy(array, fInputs, fNclients*sizeof(UInt_t));
+    delete [] fInputs;
+    fInputs = array;
+  }
+  fInputs[fNclients] = input;
+  fDevices->Add(client);
+  fNclients++;
+}    
+
+//______________________________________________________________________________
+void AliTrigConnector::Print(Option_t */*option*/) const
+{
+// Print info about this connector.
+  Printf("   feeder: output #%d of device %s\n", fOutput, fFeeder->GetName());
+  Printf("   client devices:\n");
+  for (Int_t i=0; i<fNclients; i++) Printf("      #%d %s\n", fInputs[i], fDevices->At(i)->GetName());
+}
+
+//______________________________________________________________________________
+Bool_t AliTrigConnector::Transmit(Bool_t value)
+{
+// Transmit Boolean signal from feeder to all clients.
+  AliTrigDevice *nextclient;
+  Bool_t transmit = kTRUE;
+  for (Int_t i=0; i<fNclients; i++) {
+    nextclient = (AliTrigDevice*)fDevices->At(i);
+    Bool_t done = nextclient->SetInputValue(fInputs[i], value);
+    if (!done) {
+      Error("Transmit", "Connector %s: Boolean value cannot be transmitted to input %d of device %s",
+            GetName(), i,  nextclient->GetName());
+      transmit = kFALSE;      
+    }
+  }
+  return transmit;
+}
+
+//______________________________________________________________________________
+Bool_t AliTrigConnector::Transmit(AliTrigEvent *event)
+{
+// Transmit Boolean signal from feeder to all clients.
+  AliTrigDevice *nextclient;
+  Bool_t transmit = kTRUE;
+  for (Int_t i=0; i<fNclients; i++) {
+    nextclient = (AliTrigDevice*)fDevices->At(i);
+    Bool_t done = nextclient->SetInputValue(fInputs[i], event);
+    if (!done) {
+      Error("Transmit", "Connector %s: Event cannot be transmitted to input %d of device %s",
+            GetName(), i,  nextclient->GetName());
+      transmit = kFALSE;      
+    }
+  }
+  return transmit;    
+}
diff --git a/TRIGGER/AliTrigConnector.h b/TRIGGER/AliTrigConnector.h
new file mode 100644 (file)
index 0000000..8ea668a
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef ALITRIGCONNECTOR_H
+#define ALITRIGCONNECTOR_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+// Author: Andrei Gheata, 28/07/2009
+
+//==============================================================================
+//   AliTrigConnector - Class representing a connector between an output of a 
+// device (feeder) and an arbitrary number of inputs of other devices.
+//==============================================================================
+
+#ifndef ROOT_TNamed
+#include "TNamed.h"
+#endif
+
+class TObjArray;
+class AliTrigDevice;
+class AliTrigEvent;
+
+class AliTrigConnector : public TNamed {
+
+public:
+  AliTrigConnector() : TNamed(), fFeeder(0), fOutput(0), fNclients(0), fArraySize(0), fInputs(0), fDevices(0) {}
+  AliTrigConnector(const char *name, AliTrigDevice *feeder, UInt_t output) : TNamed(name, ""), fFeeder(feeder), fOutput(output), fNclients(0), fArraySize(0), fInputs(0), fDevices(0) {}
+  AliTrigConnector(const AliTrigConnector &other);
+  virtual ~AliTrigConnector();
+
+  AliTrigConnector &operator=(const AliTrigConnector &other);
+  
+  // Connect a client input.
+  void                      Connect(AliTrigDevice *client, UInt_t input);
+
+  virtual void              Print(Option_t *option="") const;  
+  
+  // Transmit the feeder signal to all connected inputs. Different device types
+  // call different Transmit() methods.
+  Bool_t                    Transmit(Bool_t value);
+  Bool_t                    Transmit(AliTrigEvent *event);
+  
+private:
+  AliTrigDevice            *fFeeder;    // Feeder device
+  UInt_t                    fOutput;    // Output slot index for the feeder
+  Int_t                     fNclients;  // Number of clients
+  Int_t                     fArraySize; // Size of the clients array
+  UInt_t                   *fInputs;    //[fArraySize] Array of input slot indices
+  TObjArray                *fDevices;   // Array of client devices
+   
+  ClassDef(AliTrigConnector,1)  // Class representing a connector between devices.
+};
+#endif
diff --git a/TRIGGER/AliTrigDevice.cxx b/TRIGGER/AliTrigDevice.cxx
new file mode 100644 (file)
index 0000000..2479734
--- /dev/null
@@ -0,0 +1,114 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+/* $Id$ */
+// Author: Andrei Gheata, 28/07/2009
+
+//==============================================================================
+//   AliTrigDevice - Generic device class. A device has a number of inputs and
+// outputs. The data handled by the device can be either Boolean (digital
+// devices) or arbitrary (wrapped by the class AliTrigSignal). A device must
+// provide a response function that may depend on the output id. To replay the 
+// device response function for a given output id, the device MUST register the
+// output via the RegisterOutput() method providing the delay in arbitrary time
+// units. After the execution of the response for some output, the Emit() method
+// will be invoked to propagate the computed result to all devices connected to 
+// this output. The method Connect() must be implemented by all devices and should
+// create a connector specific to the device types that are linked. 
+// The ResetInputs() method is called during simulation after the execution of 
+// all response functions.
+//==============================================================================
+
+#include "AliTrigDevice.h"
+
+ClassImp(AliTrigDevice)
+
+//______________________________________________________________________________
+AliTrigDevice::AliTrigDevice()
+{
+// Destructor.
+   if (fComponents) delete fComponents;
+}   
+
+//______________________________________________________________________________
+AliTrigDevice::AliTrigDevice(const AliTrigDevice &other)
+                    :TNamed(other), 
+                     fNinputs(other.fNinputs), 
+                     fNoutputs(other.fNoutputs),
+                     fComponents(0)
+{
+// Copy ctor.
+  if (other.fComponents) {
+     fComponents = new TObjArray();
+     TIter next(other.fComponents);
+     AliTrigDevice *dev;
+     while ((dev=(AliTrigDevice*)next())) fComponents->Add(dev);
+  }   
+}                        
+
+//______________________________________________________________________________
+AliTrigDevice& AliTrigDevice::operator=(const AliTrigDevice &other)
+{
+// Assignment
+  if (&other == this) return *this;
+  TNamed::operator=(other);
+  fNinputs  = other.fNinputs;
+  fNoutputs = other.fNoutputs;
+  fComponents = 0;
+  if (other.fComponents) {
+     fComponents = new TObjArray();
+     TIter next(other.fComponents);
+     AliTrigDevice *dev;
+     while ((dev=(AliTrigDevice*)next())) fComponents->Add(dev);
+  }   
+  return *this;
+}
+
+//______________________________________________________________________________
+void AliTrigDevice::AddDevice(AliTrigDevice *other)
+{
+// Add another device as component of this device.
+  if (!fComponents) fComponents = new TObjArray();
+  fComponents->Add(other);
+}
+
+//______________________________________________________________________________
+Int_t AliTrigDevice::GetNcomponents()
+{
+// Returns number of components.
+  if (!fComponents) return 0;
+  return fComponents->GetEntriesFast();
+}
+
+//______________________________________________________________________________
+AliTrigDevice *AliTrigDevice::GetComponent(Int_t n)
+{
+// Get component at index n.
+   if (!fComponents) return NULL;
+   return fComponents->At(n);
+}
+   
+//______________________________________________________________________________
+Bool_t AliTrigDevice::RegisterResponseFunction(AliTrigScheduler *calendar, UInt_t output, Int_t delay) const
+{
+// Register the response functions to be replayed by the provided scheduler.
+// The delay argument is in arbitrary time units with respect to the startup
+// reference of the simulation.
+// CALLING SEQUENCE:
+//   The delay behaves like a BUSY gate for the device and MUST be called when
+//   configuring the whole setup of devices. The method may fail in case the
+//   determinism is not satisfied with other connected devices providing inputs.
+   return calendar->RegisterResponseFunction(this, output, delay);
+}
diff --git a/TRIGGER/AliTrigDevice.h b/TRIGGER/AliTrigDevice.h
new file mode 100644 (file)
index 0000000..eb5c3c6
--- /dev/null
@@ -0,0 +1,70 @@
+#ifndef ALITRIGDEVICE_H
+#define ALITRIGDEVICE_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+// Author: Andrei Gheata, 27/07/2009
+
+//==============================================================================
+//   AliTrigDevice - Base class for a generic device.
+//==============================================================================
+
+#ifndef ROOT_TNamed
+#include "TNamed.h"
+#endif
+
+class AliTrigScheduler;
+
+class AliTrigDevice : public TNamed {
+
+public:
+  AliTrigDevice() : TNamed(), fNinputs(0), fNoutputs(0) {}
+  AliTrigDevice(const char *name, UInt_t ninputs, UInt_t noutputs) 
+              : TNamed(name,""), fNinputs(ninputs), fNoutputs(noutputs) {}
+  AliTrigDevice(const AliTrigDevice &other);
+  virtual ~AliTrigDevice();
+  AliTrigDevice &operator=(const AliTrigDevice &other);
+
+  virtual void              AddDevice(AliTrigDevice *other);
+  Int_t                     GetNcomponents() const;
+  AliTrigDevice            *GetComponent(Int_t n);
+  //____________________________________________________________________________
+  // Connectivity to other devices. The method will create a connector between
+  // an output of this device to one input of the other.
+  virtual Bool_t            Connect(UInt_t output, AliTrigDevice *other, UInt_t at_input) = 0;
+
+  //____________________________________________________________________________
+  // Response functions to be overloaded by specific devices. Has to propagate
+  // the response to all connected devices. Representing the output #n of the device.
+  virtual Bool_t            Response(UInt_t output = 0) = 0;
+
+  //____________________________________________________________________________
+  // Register the response functions to be replayed by the global scheduler.
+  // The delay argument is in arbitrary time units with respect to the startup
+  // reference.
+  Bool_t                    RegisterResponseFunction(AliTrigScheduler *calendar, UInt_t output, Int_t delay, Int_t group) const;
+
+  //____________________________________________________________________________
+  // Setting the value for a given input for digital devices of general ones
+  // that are handling generic signals.
+  virtual const char       *GetOutputType(UInt_t output) {return 0;}
+  virtual Bool_t            SetInputType(UInt_t input, const char *classname) = 0;
+  virtual Bool_t            SetInputValue(UInt_t input, Bool_t value) = 0;
+  virtual Bool_t            SetInputValue(UInt_t input, AliTrigSignal *signal) = 0;
+
+  //____________________________________________________________________________
+  // Device-dependent inputs reset method
+  virtual void              ResetInputs() = 0;
+
+  UInt_t                    GetNinputs() const {return fNinputs;}
+  UInt_t                    GetNoutputs() const {return fNoutputs;}
+   
+protected:
+  UInt_t                    fNinputs;  // Number of inputs.
+  UInt_t                    fNoutputs; // Number of outputs.
+  TObjArray                *fComponents; // Component devices if any
+   
+  ClassDef(AliTrigDevice,1)  // Base class for trigger devices
+};
+#endif
diff --git a/TRIGGER/AliTrigDigitalCircuit.cxx b/TRIGGER/AliTrigDigitalCircuit.cxx
new file mode 100644 (file)
index 0000000..2f4c910
--- /dev/null
@@ -0,0 +1,75 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+/* $Id$ */
+// Author: Andrei Gheata, 28/07/2009
+
+//==============================================================================
+//   AliTrigDigitalCircuit - Device that has N Boolean inputs and one Boolean
+// output. This is a base class and derived digital circuits must implement the
+// response function Trigger()
+//==============================================================================
+
+#include "AliTrigDigitalCircuit.h"
+
+ClassImp(AliTrigDigitalCircuit)
+
+//______________________________________________________________________________
+AliTrigDigitalCircuit::AliTrigDigitalCircuit(const AliTrigDigitalCircuit &other)
+                    :AliTrigDevice(other),
+                     fLastOutput(other.fLastOutput),
+                     fConnector(0),
+                     fInputs(other.fInputs)
+{
+// Copy ctor.
+  if (other.fConnector) fConnector = new AliTrigConnector(*other.fConnector);
+}                        
+
+//______________________________________________________________________________
+AliTrigDigitalCircuit::~AliTrigDigitalCircuit()
+{
+// Destructor
+  if (fConnector) delete fConnector;
+}  
+
+//______________________________________________________________________________
+AliTrigDigitalCircuit& AliTrigDigitalCircuit::operator=(const AliTrigDigitalCircuit &other)
+{
+// Assignment
+  if (&other == this) return *this;
+  AliTrigDevice::operator=(other);
+  fLastOutput = other.fLastOutput;
+  if (other.fConnector) fConnector = new AliTrigConnector(*other.fConnector);
+  else fConnector = 0;
+  fInputs = other.fInputs;
+  return *this;
+}
+
+//______________________________________________________________________________
+Bool_t AliTrigDigitalCircuit::Connect(UInt_t output, AliTrigDevice *other, UInt_t at_input)
+{
+// Connect to an input of another device.
+  if (!fConnector) fConnector = new AliTrigConnector(this, 0);
+  fConnector->Connect(other, at_input);
+}
+
+//______________________________________________________________________________
+Bool_t AliTrigDigitalCircuit::Response(UInt_t /*output*/)
+{
+// Response function of the digital circuit. Calling user-defined one.
+  fLastOutput = CircuitResponse();
+  if (fConnector) fConnector->Transmit(fLastOutput);
+  return fLastOutput;
+}   
diff --git a/TRIGGER/AliTrigDigitalCircuit.h b/TRIGGER/AliTrigDigitalCircuit.h
new file mode 100644 (file)
index 0000000..2e27a13
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef ALITRIGDIGITALCIRCUIT_H
+#define ALITRIGDIGITALCIRCUIT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+// Author: Andrei Gheata, 27/07/2009
+
+//==============================================================================
+//   AliTrigDigitalCircuit - Base class for digital circuits having N Boolean 
+//      inputs and one Boolean output. Derived classes must implement the pure 
+//      virtual method Trigger() that will return the Boolean response 
+//      of the circuit as function of the inputs.
+//==============================================================================
+
+#ifndef ALITRIGDEVICE_H
+#include "AliTrigDevice.h"
+#endif
+
+#ifndef ROOT_TBits
+#include "TBits.h"
+#endif
+
+class AliTrigEvent;
+class AliTrigConnector;
+
+class AliTrigDigitalCircuit : public AliTrigDevice {
+
+public:
+  AliTrigDigitalCircuit() : AliTrigDevice(), fLastOutput(kFALSE), fConnector(0), fInputs() {}
+  AliTrigDigitalCircuit(const char *name, UInt_t ninputs) : AliTrigDevice(name, ninputs, 1), fLastOutput(kFALSE), fConnector(0), fInputs(ninputs) {}
+  AliTrigDigitalCircuit(const AliTrigDigitalCircuit &other);
+  virtual ~AliTrigDigitalCircuit() {}
+  AliTrigDigitalCircuit &operator=(const AliTrigDigitalCircuit &other);
+
+  virtual Bool_t            Connect(UInt_t output, AliTrigDevice *other, UInt_t at_input);
+  virtual Bool_t            Response(UInt_t output);
+  // Get/Set inputs
+  Bool_t                    GetInputValue(UInt_t input) const {return fInputs.TestBitNumber(input);}
+  virtual void              ResetInputs() {fInputs.ResetAllBits();}
+  virtual void              SetInputValue(UInt_t input, Bool_t value) {fInputs.SetBitNumber(input,value);}
+  virtual void              SetInputValue(UInt_t input, AliTrigEvent *signal) {};
+private:
+   // Circuit response function. 
+  virtual Bool_t            Trigger() = 0;
+   
+protected:
+  Bool_t                    fLastOutput; // Output recorded after the last Response() call.
+  AliTrigConnector         *fConnector;  // Connector for the circuit output
+  TBits                     fInputs;
+   
+  ClassDef(AliTrigDigitalCircuit,1)  // Base class for digital circuits
+};
+#endif
diff --git a/TRIGGER/AliTrigEvent.cxx b/TRIGGER/AliTrigEvent.cxx
new file mode 100644 (file)
index 0000000..93b8fe6
--- /dev/null
@@ -0,0 +1,134 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+/* $Id$ */
+// Author: Andrei Gheata, 28/07/2009
+
+//==============================================================================
+//   AliTrigEvent - Base class for generic information exchanged by a trigger
+//                  device. Trigger inputs and outputs are represented and
+//                  handled via AliTrigEvent objects. Trigger events are typically
+//                  wrappers for the information exchanged on a single I/O slot
+//                  or a group of correlated inputs.
+//==============================================================================
+
+#include "AliTrigEvent.h"
+
+#include <TClass.h>
+#include <TBits.h>
+#include <TROOT.h>
+
+
+ClassImp(AliTrigEvent)
+
+//______________________________________________________________________________
+AliTrigEvent::Activate()
+{
+// Activate/deactivate this signal.
+  TObject::SetBit(kActive, flag);
+}                        
+
+ClassImp(AliTrigEventWithMask)
+
+//______________________________________________________________________________
+Bool_t AliTrigEventWithMask::ImportData(AliTrigEvent *source)
+{
+// Import data from likewise signal.
+  AliTrigEventWithMask *src = (AliTrigEventWithMask *)source;
+  fValue = src->GetValue();
+  return kTRUE;
+}
+
+ClassImp(AliTrigEventWithObject)
+
+//______________________________________________________________________________
+AliTrigEventWithObject::AliTrigEventWithObject(const char *classname)
+                       :AliTrigEvent(),
+                        fValue(0),
+                        fType(0)
+{
+// Normal constructor where a class name is provided for the embedded object.
+// If the event is created in this way one will only be able to connect to 
+// events embedding the same object type (via connectors). Otherwise the type
+// will be set upon the first call of SetValue.
+   fType = gROOT->GetClass(classname);
+   if (!fType) Error("ctor", "No class named <%s> available.", classname);
+}   
+
+//______________________________________________________________________________
+AliTrigEventWithObject::AliTrigEventWithObject(const AliTrigEventWithObject &other)
+                       :AliTrigEvent(other),
+                        fValue(other.fValue),
+                        fType(other.fType)
+{
+// Copy constructor.   
+}
+
+//______________________________________________________________________________
+AliTrigEventWithObject::operator=(const AliTrigEventWithObject &other)
+{
+// Assignment operator.
+   if (&other == this) return *this;
+   AliTrigEvent::operator=(other);
+   fValue = other.fValue;
+   fType = other.fType;
+}
+
+//______________________________________________________________________________
+Bool_t AliTrigEventWithObject::ImportData(AliTrigEvent *source)
+{
+// Import data from likewise signal.
+  AliTrigEventWithObject *src = (AliTrigEventWithObject *)source;
+  Bool_t done = SetValue(src->GetValue());
+  if (!done) Error("ImportData", "Cannot import object <%s> of class <%s> since event type was set to: <%s>",
+                   src->GetValue()->GetName(), src->GetValue()->ClassName(), fType->GetName());
+  return done;
+}
+
+//______________________________________________________________________________
+Bool_t AliTrigEventWithObject::SetType(const char *classname)
+{
+// Set the type of this event. Can be done only once.
+  TClass *type = gROOT->GetClass(classname);
+  if (!type) {
+    Error("SetType", "Unknown class %s", classname);
+    return kFALSE;
+  }
+  if (!fType) fType = type;
+  if (fType != type) {
+    Error("SetType", "Type %s not matching the one defined for this event <%s>",
+          classname, fType->GetName());
+    return kFALSE;
+  }
+  return kTRUE;
+}
+
+//______________________________________________________________________________
+Bool_t AliTrigEventWithObject::SetValue(TObject *value)
+{
+// Set the current event content. Checks consistency with event type.
+  if (!value) {
+    // Reset current value.
+    fValue = NULL;
+    return kTRUE;
+  }
+  TClass *type = value->IsA();
+  // Set the type if used for the first time.
+  if (!fType) fType = type;
+  // Check consistency of the value with event type.  
+  if (type != fType) return kFALSE;
+  fValue = value;
+  return kTRUE;
+}  
diff --git a/TRIGGER/AliTrigEvent.h b/TRIGGER/AliTrigEvent.h
new file mode 100644 (file)
index 0000000..b129865
--- /dev/null
@@ -0,0 +1,94 @@
+#ifndef ALITRIGEVENT_H
+#define ALITRIGEVENT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+// Author: Andrei Gheata, 28/07/2009
+
+//==============================================================================
+//   AliTrigEvent - Base class for generic information exchanged by a trigger
+//                  device. Trigger inputs and outputs are represented and
+//                  handled via AliTrigEvent objects. Trigger events are typically
+//                  wrappers for the information exchanged on a single I/O slot
+//                  or a group of correlated inputs.
+//==============================================================================
+
+#ifndef ROOT_TObject
+#include "TObject.h"
+#endif
+
+class TClass;
+class AliTrigEvent : public TObject {
+
+public:
+enum ETrigSignalFlags {
+  kActive = BIT(14)
+}
+  
+  AliTrigEvent() : TObject {}
+  virtual ~AliTrigEvent() {}
+
+  void                      Activate(Bool_t flag);
+  Bool_t                    IsActive() const {return TObject::TestBit(kActive);}
+  
+  // Import data from a source signal. Has to be implemented by derived signals.
+  virtual Bool_t            ImportData(AliTrigEvent *source) = 0;
+  virtual Bool_t            SetType(const char *classname) {return kTRUE;}
+  virtual TClass           *GetType() {return NULL;}
+     
+  ClassDef(AliTrigEvent,1)  // Generic event embedding data.
+};
+
+
+//==============================================================================
+//   AliTrigEventWithMask - Event embedding a bit mask as TBits
+// 
+//==============================================================================
+class TBits;
+class AliTrigEventWithMask : public AliTrigEvent {
+
+public:
+  AliTrigEventWithMask() : AliTrigEvent(), fValue() {}
+  virtual ~AliTrigEventWithMask() {}
+  
+  virtual Bool_t            ImportData(AliTrigEvent *source);
+
+  const TBits              &GetValue() const {return fValue;}
+  void                      SetValue(const TBits &value) {fValue = value;}
+
+private:
+  TBits                     fValue;  // Mask value
+     
+  ClassDef(AliTrigEventWithMask,1)  // Signal embedding a TBits object.
+};
+
+//==============================================================================
+//   AliTrigEventWithObject - Event embedding a TObject
+// 
+//==============================================================================
+
+class TClass;
+class AliTrigEventWithObject : public AliTrigEvent {
+
+public:
+  AliTrigEventWithObject() : AliTrigEvent(), fValue(0) {}
+  AliTrigEventWithObject(const char *classname);
+  AliTrigEventWithObject(const AliTrigEventWithObject &other);
+  virtual ~AliTrigEventWithObject() {}
+  
+  AliTrigEventWithObject   &operator=(const AliTrigEventWithObject &other);
+  virtual Bool_t            ImportData(AliTrigEvent *source);
+  virtual TClass           *GetType() const  {return fType;}
+  virtual Bool_t            SetType(const char *classname);
+  TObject                  *GetValue() const {return fValue;}
+  Bool_t                    SetValue(TObject *value);
+
+private:
+  TObject                  *fValue;  // Embedded object
+  TClass                   *fType;   //! Object type
+     
+  ClassDef(AliTrigEventWithObject,1)  // Signal embedding an object.
+};
+
+#endif