1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // Author: Andrei Gheata, 28/07/2009
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 //==============================================================================
24 #include "AliTrigModule.h"
26 #include "TObjArray.h"
27 #include "AliTrigConnector.h"
28 #include "AliTrigEvent.h"
30 ClassImp(AliTrigModule)
32 //______________________________________________________________________________
33 AliTrigModule::~AliTrigModule()
36 if (fInputs) {fInputs->Delete(); delete fInputs;}
37 if (fOutputs) {fOutputs->Delete(); delete fOutputs;}
38 if (fOutputConnectors) {fOutputConnectors->Delete(); delete fOutputConnectors;}
41 //______________________________________________________________________________
42 Bool_t AliTrigModule::Connect(Int_t output, AliTrigDevice *other, Int_t at_input)
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);
52 //______________________________________________________________________________
53 void AliTrigModule::DefineInput(Int_t islot, AliTrigEvent *event)
55 // Define an input slot and provide an event derived from AliTrigEvent.
56 if (!fInputs) fInputs = new TObjArray(fNinputs);
57 fInputs->AddAt(event, islot);
60 //______________________________________________________________________________
61 void AliTrigModule::DefineOutput(Int_t islot, AliTrigEvent *event)
63 // Define an output slot and provide an event derived from AliTrigEvent.
64 if (!fOutputs) fOutputs = new TObjArray(fNoutputs);
65 fOutputs->AddAt(event, islot);
68 //______________________________________________________________________________
69 AliTrigEvent *AliTrigModule::GetInputValue(Int_t input) const
71 // Get current input value for a slot.
72 if (!fInputs) return 0;
73 return (AliTrigEvent*)fInputs->At(input);
76 //______________________________________________________________________________
77 AliTrigEvent *AliTrigModule::GetOutputValue(Int_t output) const
79 // Get current input value for a slot.
80 if (!fOutputs) return 0;
81 return (AliTrigEvent*)fOutputs->At(output);
84 //______________________________________________________________________________
85 Bool_t AliTrigModule::Response(Int_t ioutput)
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));
94 //______________________________________________________________________________
95 void AliTrigModule::ResetInputs()
100 //______________________________________________________________________________
101 Bool_t AliTrigModule::SetInputValue(Int_t input, AliTrigEvent *event)
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);