]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRIGGER/AliTrigModule.cxx
nvartrk=7 in ESE task
[u/mrichter/AliRoot.git] / TRIGGER / AliTrigModule.cxx
CommitLineData
fcd2bfb7 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16// Author: Andrei Gheata, 28/07/2009
17
18//==============================================================================
19// AliTrigModule - Base class for trigger devices handling generic events.
20// A module has arbitrary number of inputs and outputs. Derived classes must
21// implement CreateDevice() and Trigger() metods.
22//==============================================================================
23
24#include "AliTrigModule.h"
25
26#include "TObjArray.h"
27#include "AliTrigConnector.h"
28#include "AliTrigEvent.h"
29
30ClassImp(AliTrigModule)
31
32//______________________________________________________________________________
33AliTrigModule::~AliTrigModule()
90719948 34{
fcd2bfb7 35// Destructor
36 if (fInputs) {fInputs->Delete(); delete fInputs;}
37 if (fOutputs) {fOutputs->Delete(); delete fOutputs;}
38 if (fOutputConnectors) {fOutputConnectors->Delete(); delete fOutputConnectors;}
39}
40
41//______________________________________________________________________________
42Bool_t AliTrigModule::Connect(Int_t output, AliTrigDevice *other, Int_t at_input)
43{
44// Connect to an input of another device.
45 if (!fOutputConnectors) fOutputConnectors = new TObjArray(fNoutputs);
46 AliTrigConnector *connector = new AliTrigConnector(Form("wire_%s_%d", GetName(), output), (AliTrigDevice*)this, 0);
47 connector->Connect(other, at_input);
48 fOutputConnectors->AddAt(connector, output);
49 return kTRUE;
50}
51
52//______________________________________________________________________________
53void AliTrigModule::DefineInput(Int_t islot, AliTrigEvent *event)
54{
55// Define an input slot and provide an event derived from AliTrigEvent.
56 if (!fInputs) fInputs = new TObjArray(fNinputs);
57 fInputs->AddAt(event, islot);
58}
59
60//______________________________________________________________________________
61void AliTrigModule::DefineOutput(Int_t islot, AliTrigEvent *event)
62{
63// Define an output slot and provide an event derived from AliTrigEvent.
64 if (!fOutputs) fOutputs = new TObjArray(fNoutputs);
65 fOutputs->AddAt(event, islot);
66}
67
68//______________________________________________________________________________
69AliTrigEvent *AliTrigModule::GetInputValue(Int_t input) const
70{
71// Get current input value for a slot.
72 if (!fInputs) return 0;
73 return (AliTrigEvent*)fInputs->At(input);
74}
75
76//______________________________________________________________________________
77AliTrigEvent *AliTrigModule::GetOutputValue(Int_t output) const
78{
79// Get current input value for a slot.
80 if (!fOutputs) return 0;
81 return (AliTrigEvent*)fOutputs->At(output);
82}
83
84//______________________________________________________________________________
85Bool_t AliTrigModule::Response(Int_t ioutput)
86{
87// Response function of the digital circuit. Calling user-defined one.
88 Bool_t response = Trigger(ioutput);
89 AliTrigConnector *connector = (AliTrigConnector*)fOutputConnectors->At(ioutput);
90 if (connector) connector->Transmit(GetOutputValue(ioutput));
91 return response;
92}
93
94//______________________________________________________________________________
95void AliTrigModule::ResetInputs()
96{
97// Reset all inputs
98}
99
100//______________________________________________________________________________
101Bool_t AliTrigModule::SetInputValue(Int_t input, AliTrigEvent *event)
102{
103// A way to set directly the input value.
104 if (!fInputs) return kFALSE;
105 AliTrigEvent *input_event = GetInputValue(input);
106 if (!input_event) return kFALSE;
107 input_event->ImportData(event);
108 return kTRUE;
109}