]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRIGGER/AliTrigConnector.cxx
L1phase shift corrected
[u/mrichter/AliRoot.git] / TRIGGER / AliTrigConnector.cxx
CommitLineData
88f843f1 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/* $Id$ */
17// Author: Andrei Gheata, 28/07/2009
18
19//==============================================================================
20// AliTrigConnector - General connector class. A connector links a feeder
21// device output to a number of other device inputs (clients). It transmits the
22// signal to all clients and calls their SetInput() method.
23//==============================================================================
24
25#include "AliTrigConnector.h"
26
27#include <TObjArray.h>
28#include <TClass.h>
29
30#include "AliTrigDevice.h"
31#include "AliTrigEvent.h"
32
33
34ClassImp(AliTrigConnector)
35
36//______________________________________________________________________________
37AliTrigConnector::AliTrigConnector(const AliTrigConnector &other)
38 :TNamed(other),
39 fFeeder(other.fFeeder),
40 fOutput(other.fOutput),
41 fNclients(other.fNclients),
42 fArraySize(other.fArraySize),
43 fInputs(0),
44 fDevices(0)
45{
46// Copy ctor.
47 if (fArraySize && other.fInputs) {
79e35bac 48 fInputs = new Int_t[fArraySize];
49 memcpy(fInputs, other.fInputs, fNclients*sizeof(Int_t));
88f843f1 50 fDevices = new TObjArray(fArraySize);
51 for (Int_t i=0; i<fNclients; i++) fDevices->Add(other.fDevices->At(i));
52 }
53}
54
55//______________________________________________________________________________
56AliTrigConnector::~AliTrigConnector()
57{
58// Destructor.
59 if (fInputs) delete [] fInputs;
60 if (fDevices) delete fDevices;
61}
62
63//______________________________________________________________________________
64AliTrigConnector& AliTrigConnector::operator=(const AliTrigConnector &other)
65{
66// Assignment
67 if (&other == this) return *this;
68 TNamed::operator=(other);
69 fFeeder = other.fFeeder;
70 fOutput = other.fOutput;
71 fNclients = other.fNclients;
72 fArraySize = other.fArraySize;
73 fInputs = 0;
74 fDevices = 0;
75 if (fArraySize && other.fInputs) {
79e35bac 76 fInputs = new Int_t[fArraySize];
77 memcpy(fInputs, other.fInputs, fNclients*sizeof(Int_t));
88f843f1 78 fDevices = new TObjArray(fArraySize);
79 for (Int_t i=0; i<fNclients; i++) fDevices->Add(other.fDevices->At(i));
80 }
81 return *this;
82}
83
84//______________________________________________________________________________
79e35bac 85void AliTrigConnector::Connect(AliTrigDevice *client, Int_t input)
88f843f1 86{
87// Adds the device and its input to the list of clients.
88 // Loop array of inputs to check if this input is already connected.
89 for (Int_t i=0; i<fNclients; i++) {
90 if (fInputs[i]==input && fDevices->At(i)==client) {
91 Info("Connect", "Output #%d of device %s already connected to input #%d of device%s",
92 fOutput, fFeeder->GetName(), input, client->GetName());
93 return;
94 }
95 }
79e35bac 96// if (strcmp(client->GetInputType(fFeeder->GetOutputType(fOutput))) {
97// Fatal("Cannot connect output slot #%d (type %s) of device %s to input slot #%d of device %s. Aborting",
98// fOutput, fFeeder->GetInputType(fOutput), fFeeder->GetName(), input, client->GetName());
99// }
88f843f1 100 if (!fArraySize) {
101 fArraySize = 8;
79e35bac 102 fInputs = new Int_t[fArraySize];
88f843f1 103 fDevices = new TObjArray(fArraySize);
104 }
105 if (fNclients >= fArraySize) {
106 fArraySize *= 2;
79e35bac 107 Int_t *array = new Int_t[fArraySize];
108 memcpy(array, fInputs, fNclients*sizeof(Int_t));
88f843f1 109 delete [] fInputs;
110 fInputs = array;
111 }
112 fInputs[fNclients] = input;
113 fDevices->Add(client);
114 fNclients++;
115}
116
117//______________________________________________________________________________
118void AliTrigConnector::Print(Option_t */*option*/) const
119{
120// Print info about this connector.
121 Printf(" feeder: output #%d of device %s\n", fOutput, fFeeder->GetName());
122 Printf(" client devices:\n");
123 for (Int_t i=0; i<fNclients; i++) Printf(" #%d %s\n", fInputs[i], fDevices->At(i)->GetName());
124}
125
126//______________________________________________________________________________
127Bool_t AliTrigConnector::Transmit(Bool_t value)
128{
129// Transmit Boolean signal from feeder to all clients.
130 AliTrigDevice *nextclient;
131 Bool_t transmit = kTRUE;
132 for (Int_t i=0; i<fNclients; i++) {
133 nextclient = (AliTrigDevice*)fDevices->At(i);
134 Bool_t done = nextclient->SetInputValue(fInputs[i], value);
135 if (!done) {
136 Error("Transmit", "Connector %s: Boolean value cannot be transmitted to input %d of device %s",
137 GetName(), i, nextclient->GetName());
138 transmit = kFALSE;
139 }
140 }
141 return transmit;
142}
143
144//______________________________________________________________________________
145Bool_t AliTrigConnector::Transmit(AliTrigEvent *event)
146{
147// Transmit Boolean signal from feeder to all clients.
148 AliTrigDevice *nextclient;
149 Bool_t transmit = kTRUE;
150 for (Int_t i=0; i<fNclients; i++) {
151 nextclient = (AliTrigDevice*)fDevices->At(i);
152 Bool_t done = nextclient->SetInputValue(fInputs[i], event);
153 if (!done) {
154 Error("Transmit", "Connector %s: Event cannot be transmitted to input %d of device %s",
155 GetName(), i, nextclient->GetName());
156 transmit = kFALSE;
157 }
158 }
159 return transmit;
160}