From fcd2bfb7ba769005b4a4b8f27707b8e1bf4066bc Mon Sep 17 00:00:00 2001 From: agheata Date: Thu, 4 Feb 2010 15:50:56 +0000 Subject: [PATCH] New base class for trigger modules handling generic events. --- TRIGGER/AliTrigEvent.h | 2 +- TRIGGER/AliTrigModule.cxx | 109 +++++++++++++++++++++++++++++++++++++ TRIGGER/AliTrigModule.h | 53 ++++++++++++++++++ TRIGGER/libTRIGGERbase.pkg | 2 +- 4 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 TRIGGER/AliTrigModule.cxx create mode 100644 TRIGGER/AliTrigModule.h diff --git a/TRIGGER/AliTrigEvent.h b/TRIGGER/AliTrigEvent.h index f973066f491..1a2f628046b 100644 --- a/TRIGGER/AliTrigEvent.h +++ b/TRIGGER/AliTrigEvent.h @@ -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 index 00000000000..d1f5338472a --- /dev/null +++ b/TRIGGER/AliTrigModule.cxx @@ -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 index 00000000000..4dfe070898e --- /dev/null +++ b/TRIGGER/AliTrigModule.h @@ -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 diff --git a/TRIGGER/libTRIGGERbase.pkg b/TRIGGER/libTRIGGERbase.pkg index 9321e3bf251..ef1e45c5914 100644 --- a/TRIGGER/libTRIGGERbase.pkg +++ b/TRIGGER/libTRIGGERbase.pkg @@ -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) -- 2.31.1