]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New base class for trigger modules handling generic events.
authoragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 4 Feb 2010 15:50:56 +0000 (15:50 +0000)
committeragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 4 Feb 2010 15:50:56 +0000 (15:50 +0000)
TRIGGER/AliTrigEvent.h
TRIGGER/AliTrigModule.cxx [new file with mode: 0644]
TRIGGER/AliTrigModule.h [new file with mode: 0644]
TRIGGER/libTRIGGERbase.pkg

index f973066f4911cc6911df96f6ee72fee5ce41b384..1a2f628046b4081bda2eda29f5015b5f64f0f707 100644 (file)
@@ -77,7 +77,7 @@ private:
 class AliTrigEventWithObject : public AliTrigEvent {
 
 public:
-  AliTrigEventWithObject() : AliTrigEvent(), fValue(0) {}
+  AliTrigEventWithObject() : AliTrigEvent(), fValue(0), fType() {}
   AliTrigEventWithObject(const char *classname);
   AliTrigEventWithObject(const AliTrigEventWithObject &other);
   virtual ~AliTrigEventWithObject() {}
diff --git a/TRIGGER/AliTrigModule.cxx b/TRIGGER/AliTrigModule.cxx
new file mode 100644 (file)
index 0000000..d1f5338
--- /dev/null
@@ -0,0 +1,109 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+// Author: Andrei Gheata, 28/07/2009
+
+//==============================================================================
+//   AliTrigModule - Base class for trigger devices handling generic events. 
+//      A module has arbitrary number of inputs and outputs. Derived classes must 
+//      implement CreateDevice() and Trigger() metods.
+//==============================================================================
+
+#include "AliTrigModule.h"
+
+#include "TObjArray.h"
+#include "AliTrigConnector.h"
+#include "AliTrigEvent.h"
+
+ClassImp(AliTrigModule)
+
+//______________________________________________________________________________
+AliTrigModule::~AliTrigModule()
+{;
+// Destructor
+  if (fInputs) {fInputs->Delete(); delete fInputs;}
+  if (fOutputs) {fOutputs->Delete(); delete fOutputs;}
+  if (fOutputConnectors) {fOutputConnectors->Delete(); delete fOutputConnectors;}
+}  
+
+//______________________________________________________________________________
+Bool_t AliTrigModule::Connect(Int_t output, AliTrigDevice *other, Int_t at_input)
+{
+// Connect to an input of another device.
+  if (!fOutputConnectors) fOutputConnectors = new TObjArray(fNoutputs);
+  AliTrigConnector *connector = new AliTrigConnector(Form("wire_%s_%d", GetName(), output), (AliTrigDevice*)this, 0);
+  connector->Connect(other, at_input);
+  fOutputConnectors->AddAt(connector, output);
+  return kTRUE;
+}
+
+//______________________________________________________________________________
+void AliTrigModule::DefineInput(Int_t islot, AliTrigEvent *event)
+{
+// Define an input slot and provide an event derived from AliTrigEvent.
+  if (!fInputs) fInputs = new TObjArray(fNinputs);
+  fInputs->AddAt(event, islot);
+}   
+
+//______________________________________________________________________________
+void AliTrigModule::DefineOutput(Int_t islot, AliTrigEvent *event)
+{
+// Define an output slot and provide an event derived from AliTrigEvent.
+  if (!fOutputs) fOutputs = new TObjArray(fNoutputs);
+  fOutputs->AddAt(event, islot);
+}   
+
+//______________________________________________________________________________
+AliTrigEvent *AliTrigModule::GetInputValue(Int_t input) const
+{
+// Get current input value for a slot.
+  if (!fInputs) return 0;
+  return (AliTrigEvent*)fInputs->At(input);
+}   
+
+//______________________________________________________________________________
+AliTrigEvent *AliTrigModule::GetOutputValue(Int_t output) const
+{
+// Get current input value for a slot.
+  if (!fOutputs) return 0;
+  return (AliTrigEvent*)fOutputs->At(output);
+}   
+
+//______________________________________________________________________________
+Bool_t AliTrigModule::Response(Int_t ioutput)
+{
+// Response function of the digital circuit. Calling user-defined one.
+  Bool_t response = Trigger(ioutput);
+  AliTrigConnector *connector = (AliTrigConnector*)fOutputConnectors->At(ioutput);
+  if (connector) connector->Transmit(GetOutputValue(ioutput));
+  return response;
+}   
+
+//______________________________________________________________________________
+void AliTrigModule::ResetInputs()
+{
+// Reset all inputs
+}
+
+//______________________________________________________________________________
+Bool_t AliTrigModule::SetInputValue(Int_t input, AliTrigEvent *event)
+{
+// A way to set directly the input value.
+  if (!fInputs) return kFALSE;
+  AliTrigEvent *input_event = GetInputValue(input);
+  if (!input_event) return kFALSE;
+  input_event->ImportData(event);
+  return kTRUE;
+}
diff --git a/TRIGGER/AliTrigModule.h b/TRIGGER/AliTrigModule.h
new file mode 100644 (file)
index 0000000..4dfe070
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef ALITRIGMODULE_H
+#define ALITRIGMODULE_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+// Author: Andrei Gheata, 27/07/2009
+
+//==============================================================================
+//   AliTrigModule - Base class for trigger devices handling generic events. 
+//      A module has arbitrary number of inputs and outputs. Derived classes must 
+//      implement CreateDevice() and Trigger() metods.
+//==============================================================================
+
+#ifndef ALITRIGDEVICE_H
+#include "AliTrigDevice.h"
+#endif
+
+class TObjArray;
+class AliTrigEvent;
+
+class AliTrigModule : public AliTrigDevice {
+
+public:
+  AliTrigModule() : AliTrigDevice(), fInputs(0), fOutputs(0), fOutputConnectors(0) {}
+  AliTrigModule(const char *name, Int_t ninputs, Int_t noutputs) : AliTrigDevice(name, ninputs, noutputs), fInputs(0), fOutputs(0), fOutputConnectors(0) {}
+  virtual ~AliTrigModule();
+
+  virtual Bool_t            Connect(Int_t output, AliTrigDevice *other, Int_t at_input);
+  virtual Bool_t            CreateDevice() = 0;
+  void                      DefineInput(Int_t islot, AliTrigEvent *event);
+  void                      DefineOutput(Int_t islot, AliTrigEvent *event);
+  virtual Bool_t            Response(Int_t output);
+  // Get/Set inputs
+  AliTrigEvent             *GetInputValue(Int_t input) const;
+  AliTrigEvent             *GetOutputValue(Int_t output) const;
+  virtual void              ResetInputs();
+  virtual Bool_t            SetInputType(Int_t /*input*/, const char */*classname*/) {return kFALSE;}
+  virtual Bool_t            SetInputValue(Int_t /*input*/, Bool_t /*value*/)         {return kFALSE;}
+  virtual Bool_t            SetInputValue(Int_t input, AliTrigEvent *event);
+private:
+   // Circuit response function. 
+  AliTrigModule(const AliTrigModule &other);
+  AliTrigModule &operator=(const AliTrigModule &other);
+  virtual Bool_t            Trigger(Int_t ioutput) = 0;
+   
+protected:
+  TObjArray                *fInputs;           // Array of input events
+  TObjArray                *fOutputs;          // Array of output events
+  TObjArray                *fOutputConnectors; // Array of output connectors
+   
+  ClassDef(AliTrigModule,1)  // Base class for a trigger module handling events
+};
+#endif
index 9321e3bf251b26527a1b4638c50c71d6cb644a97..ef1e45c5914b689cf46409ce2bde57c86c5c6bbd 100644 (file)
@@ -3,7 +3,7 @@
 
 SRCS:=  AliTRIPreprocessor.cxx  AliTrigConnector.cxx AliTrigDevice.cxx \
         AliTrigDigitalCircuit.cxx AliTrigEvent.cxx AliTrigScheduledEntry.cxx \
-        AliTrigScheduler.cxx
+        AliTrigScheduler.cxx AliTrigModule.cxx
 CINTHDRS:= $(SRCS:.cxx=.h)
 
 HDRS:= $(SRCS:.cxx=.h)