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 **************************************************************************/
17 // Author: Andrei Gheata, 28/07/2009
19 //==============================================================================
20 // AliTrigDevice - Generic device class. A device has a number of inputs and
21 // outputs. The data handled by the device can be either Boolean (digital
22 // devices) or arbitrary (wrapped by the class AliTrigSignal). A device must
23 // provide a response function that may depend on the output id. To replay the
24 // device response function for a given output id, the device MUST register the
25 // output via the RegisterOutput() method providing the delay in arbitrary time
26 // units. After the execution of the response for some output, the Emit() method
27 // will be invoked to propagate the computed result to all devices connected to
28 // this output. The method Connect() must be implemented by all devices and should
29 // create a connector specific to the device types that are linked.
30 // The ResetInputs() method is called during simulation after the execution of
31 // all response functions.
32 //==============================================================================
34 #include "AliTrigDevice.h"
36 ClassImp(AliTrigDevice)
38 //______________________________________________________________________________
39 AliTrigDevice::AliTrigDevice()
42 if (fComponents) delete fComponents;
45 //______________________________________________________________________________
46 AliTrigDevice::AliTrigDevice(const AliTrigDevice &other)
48 fNinputs(other.fNinputs),
49 fNoutputs(other.fNoutputs),
53 if (other.fComponents) {
54 fComponents = new TObjArray();
55 TIter next(other.fComponents);
57 while ((dev=(AliTrigDevice*)next())) fComponents->Add(dev);
61 //______________________________________________________________________________
62 AliTrigDevice& AliTrigDevice::operator=(const AliTrigDevice &other)
65 if (&other == this) return *this;
66 TNamed::operator=(other);
67 fNinputs = other.fNinputs;
68 fNoutputs = other.fNoutputs;
70 if (other.fComponents) {
71 fComponents = new TObjArray();
72 TIter next(other.fComponents);
74 while ((dev=(AliTrigDevice*)next())) fComponents->Add(dev);
79 //______________________________________________________________________________
80 void AliTrigDevice::AddDevice(AliTrigDevice *other)
82 // Add another device as component of this device.
83 if (!fComponents) fComponents = new TObjArray();
84 fComponents->Add(other);
87 //______________________________________________________________________________
88 Int_t AliTrigDevice::GetNcomponents()
90 // Returns number of components.
91 if (!fComponents) return 0;
92 return fComponents->GetEntriesFast();
95 //______________________________________________________________________________
96 AliTrigDevice *AliTrigDevice::GetComponent(Int_t n)
98 // Get component at index n.
99 if (!fComponents) return NULL;
100 return fComponents->At(n);
103 //______________________________________________________________________________
104 Bool_t AliTrigDevice::RegisterResponseFunction(AliTrigScheduler *calendar, UInt_t output, Int_t delay) const
106 // Register the response functions to be replayed by the provided scheduler.
107 // The delay argument is in arbitrary time units with respect to the startup
108 // reference of the simulation.
110 // The delay behaves like a BUSY gate for the device and MUST be called when
111 // configuring the whole setup of devices. The method may fail in case the
112 // determinism is not satisfied with other connected devices providing inputs.
113 return calendar->RegisterResponseFunction(this, output, delay);