LCOV - code coverage report
Current view: top level - TRIGGER - AliTrigDevice.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 42 2.4 %
Date: 2016-06-14 17:26:59 Functions: 1 11 9.1 %

          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             : /* $Id$ */
      17             : // Author: Andrei Gheata, 28/07/2009
      18             : 
      19             : 
      20             : #include "AliTrigDevice.h"
      21             : 
      22             : #include <TObjArray.h>
      23             : #include "AliTrigScheduler.h"
      24             : #include "AliTrigScheduledEntry.h"
      25             : 
      26          12 : ClassImp(AliTrigDevice)
      27             : //==============================================================================
      28             : //   AliTrigDevice - Generic device class. A device has a number of inputs and
      29             : // outputs. The data handled by the device can be either Boolean (digital
      30             : // devices) or arbitrary (wrapped by the class AliTrigSignal). A device must
      31             : // provide a response function that may depend on the output id. To replay the 
      32             : // device response function for a given output id, the device MUST register the
      33             : // output via the RegisterResponseFunction() method providing the delay in arbitrary time
      34             : // units. After the execution of the response for some output, the result will
      35             : // be propagated to all devices connected to this output. The method CreateDevice() 
      36             : // must be implemented by all devices and should connect all component devices
      37             : // and register all response functions. 
      38             : // The ResetInputs() method is called during simulation after the execution of 
      39             : // all response functions.
      40             : //==============================================================================
      41             : 
      42             : //______________________________________________________________________________
      43             : AliTrigDevice::AliTrigDevice()
      44           0 :               :TNamed(),
      45           0 :                fNinputs(0),
      46           0 :                fNoutputs(0),
      47           0 :                fScheduler(NULL),
      48           0 :                fComponents(NULL),
      49           0 :                fResponseFunctions(NULL) 
      50           0 : {
      51             : // I/O constructor.
      52           0 : }
      53             : 
      54             : //______________________________________________________________________________
      55             : AliTrigDevice::AliTrigDevice(const char *name, Int_t ninputs, Int_t noutputs)
      56           0 :               :TNamed(name, ""),
      57           0 :                fNinputs(ninputs),
      58           0 :                fNoutputs(noutputs),
      59           0 :                fScheduler(new AliTrigScheduler(name)),
      60           0 :                fComponents(NULL),
      61           0 :                fResponseFunctions(NULL) 
      62           0 : {
      63             : // Constructor.
      64           0 : }
      65             : 
      66             : //______________________________________________________________________________
      67             : AliTrigDevice::~AliTrigDevice()
      68           0 : {
      69             : // Destructor.
      70           0 :   delete fScheduler;
      71           0 :   if (fComponents) {fComponents->Delete(); delete fComponents;}
      72           0 :   if (fResponseFunctions) {fResponseFunctions->Delete(); delete fResponseFunctions;}
      73           0 : }   
      74             : 
      75             : //______________________________________________________________________________
      76             : void AliTrigDevice::AddDevice(AliTrigDevice *other)
      77             : {
      78             : // Add another device as component of this device.
      79           0 :   if (!fComponents) fComponents = new TObjArray();
      80           0 :   fComponents->Add(other);
      81           0 : }
      82             : 
      83             : //______________________________________________________________________________
      84             : Int_t AliTrigDevice::GetNcomponents() const
      85             : {
      86             : // Returns number of components.
      87           0 :   if (!fComponents) return 0;
      88           0 :   return fComponents->GetEntriesFast();
      89           0 : }
      90             : 
      91             : //______________________________________________________________________________
      92             : AliTrigDevice *AliTrigDevice::GetComponent(Int_t n)
      93             : {
      94             : // Get component at index n.
      95           0 :   if (!fComponents) return NULL;
      96           0 :   return (AliTrigDevice*)fComponents->At(n);
      97           0 : }
      98             : 
      99             : //______________________________________________________________________________
     100             : AliTrigScheduledResponse *AliTrigDevice::GetResponseFunction(const char *name)
     101             : {
     102             : // Get a response function by name.
     103           0 :   if (!fResponseFunctions) return NULL;
     104           0 :   return (AliTrigScheduledResponse*)fResponseFunctions->FindObject(name);
     105           0 : }  
     106             : 
     107             : //______________________________________________________________________________
     108             : AliTrigScheduledResponse *AliTrigDevice::RegisterResponseFunction(const char *name, Int_t output, Int_t delay)
     109             : {
     110             : // Creates a response function of the device. The delay argument is in arbitrary 
     111             : // time units with respect to the startup reference. Note that the created 
     112             : // scheduled entry must be registered to the device scheduler via: 
     113             : //    fDevice->AddScheduledEntry() method, otherwise it will not be replayed.
     114           0 :   if (!fResponseFunctions) fResponseFunctions = new TObjArray();
     115           0 :   if (fResponseFunctions->FindObject(name)) {
     116           0 :     Error("RegisterResponseFunction", "A response function named %s was already registered for device %s",
     117           0 :           name, GetName());
     118           0 :     return NULL;
     119             :   }        
     120           0 :   AliTrigScheduledResponse *response = new AliTrigScheduledResponse(name, (AliTrigDevice*)this, output, delay);
     121           0 :   fResponseFunctions->Add(response);
     122             :   return response;
     123           0 : }

Generated by: LCOV version 1.11