Line data Source code
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 :
30 12 : ClassImp(AliTrigModule)
31 :
32 : //______________________________________________________________________________
33 : AliTrigModule::~AliTrigModule()
34 0 : {
35 : // Destructor
36 0 : if (fInputs) {fInputs->Delete(); delete fInputs;}
37 0 : if (fOutputs) {fOutputs->Delete(); delete fOutputs;}
38 0 : if (fOutputConnectors) {fOutputConnectors->Delete(); delete fOutputConnectors;}
39 0 : }
40 :
41 : //______________________________________________________________________________
42 : Bool_t AliTrigModule::Connect(Int_t output, AliTrigDevice *other, Int_t at_input)
43 : {
44 : // Connect to an input of another device.
45 0 : if (!fOutputConnectors) fOutputConnectors = new TObjArray(fNoutputs);
46 0 : AliTrigConnector *connector = new AliTrigConnector(Form("wire_%s_%d", GetName(), output), (AliTrigDevice*)this, 0);
47 0 : connector->Connect(other, at_input);
48 0 : fOutputConnectors->AddAt(connector, output);
49 0 : return kTRUE;
50 0 : }
51 :
52 : //______________________________________________________________________________
53 : void AliTrigModule::DefineInput(Int_t islot, AliTrigEvent *event)
54 : {
55 : // Define an input slot and provide an event derived from AliTrigEvent.
56 0 : if (!fInputs) fInputs = new TObjArray(fNinputs);
57 0 : fInputs->AddAt(event, islot);
58 0 : }
59 :
60 : //______________________________________________________________________________
61 : void AliTrigModule::DefineOutput(Int_t islot, AliTrigEvent *event)
62 : {
63 : // Define an output slot and provide an event derived from AliTrigEvent.
64 0 : if (!fOutputs) fOutputs = new TObjArray(fNoutputs);
65 0 : fOutputs->AddAt(event, islot);
66 0 : }
67 :
68 : //______________________________________________________________________________
69 : AliTrigEvent *AliTrigModule::GetInputValue(Int_t input) const
70 : {
71 : // Get current input value for a slot.
72 0 : if (!fInputs) return 0;
73 0 : return (AliTrigEvent*)fInputs->At(input);
74 0 : }
75 :
76 : //______________________________________________________________________________
77 : AliTrigEvent *AliTrigModule::GetOutputValue(Int_t output) const
78 : {
79 : // Get current input value for a slot.
80 0 : if (!fOutputs) return 0;
81 0 : return (AliTrigEvent*)fOutputs->At(output);
82 0 : }
83 :
84 : //______________________________________________________________________________
85 : Bool_t AliTrigModule::Response(Int_t ioutput)
86 : {
87 : // Response function of the digital circuit. Calling user-defined one.
88 0 : Bool_t response = Trigger(ioutput);
89 0 : AliTrigConnector *connector = (AliTrigConnector*)fOutputConnectors->At(ioutput);
90 0 : if (connector) connector->Transmit(GetOutputValue(ioutput));
91 0 : return response;
92 : }
93 :
94 : //______________________________________________________________________________
95 : void AliTrigModule::ResetInputs()
96 : {
97 : // Reset all inputs
98 0 : }
99 :
100 : //______________________________________________________________________________
101 : Bool_t AliTrigModule::SetInputValue(Int_t input, AliTrigEvent *event)
102 : {
103 : // A way to set directly the input value.
104 0 : if (!fInputs) return kFALSE;
105 0 : AliTrigEvent *input_event = GetInputValue(input);
106 0 : if (!input_event) return kFALSE;
107 0 : input_event->ImportData(event);
108 0 : return kTRUE;
109 0 : }
|