]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRIGGER/AliTrigEvent.cxx
Trigger inputs for AOD MC
[u/mrichter/AliRoot.git] / TRIGGER / AliTrigEvent.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
88f843f1 19#include "AliTrigEvent.h"
20
21#include <TClass.h>
22#include <TBits.h>
23#include <TROOT.h>
24
88f843f1 25ClassImp(AliTrigEvent)
26
79e35bac 27//==============================================================================
28// AliTrigEvent - Base class for generic information exchanged by a trigger
29// device. Trigger inputs and outputs are represented and
30// handled via AliTrigEvent objects. Trigger events are typically
31// wrappers for the information exchanged on a single I/O slot
32// or a group of correlated inputs.
33//==============================================================================
34
90719948 35//______________________________________________________________________________
36AliTrigEvent &AliTrigEvent::operator=(const AliTrigEvent &other)
37{
38// Assignment operator.
39 if (&other == this) return *this;
40 TNamed::operator=(other);
41 return *this;
42}
88f843f1 43//______________________________________________________________________________
79e35bac 44void AliTrigEvent::Activate(Bool_t flag)
88f843f1 45{
46// Activate/deactivate this signal.
47 TObject::SetBit(kActive, flag);
48}
49
50ClassImp(AliTrigEventWithMask)
51
52//______________________________________________________________________________
53Bool_t AliTrigEventWithMask::ImportData(AliTrigEvent *source)
54{
55// Import data from likewise signal.
56 AliTrigEventWithMask *src = (AliTrigEventWithMask *)source;
79e35bac 57 SetValue(src->GetValue());
88f843f1 58 return kTRUE;
59}
60
79e35bac 61//______________________________________________________________________________
62void AliTrigEventWithMask::SetValue(TBits *value)
63{
64// Set the mask value.
65 *fValue = *value;
66}
67
68//______________________________________________________________________________
69AliTrigEventWithMask::AliTrigEventWithMask(const AliTrigEventWithMask &other)
70 :AliTrigEvent(other),
71 fValue(NULL)
72{
73// Copy constructor.
74 *fValue = *other.fValue;
75}
76
77//______________________________________________________________________________
78AliTrigEventWithMask &AliTrigEventWithMask::operator=(const AliTrigEventWithMask &other)
79{
80// Assignment operator.
81 if (&other == this) return *this;
82 AliTrigEvent::operator=(other);
83 *fValue = *other.fValue;
84 return *this;
85}
86
88f843f1 87ClassImp(AliTrigEventWithObject)
88
89//______________________________________________________________________________
90719948 90AliTrigEventWithObject::AliTrigEventWithObject(const char *name,const char *classname)
91 :AliTrigEvent(name),
88f843f1 92 fValue(0),
79e35bac 93 fType("")
88f843f1 94{
95// Normal constructor where a class name is provided for the embedded object.
96// If the event is created in this way one will only be able to connect to
79e35bac 97// events embedding the same object type (via connectors). If empty string the type
88f843f1 98// will be set upon the first call of SetValue.
79e35bac 99 SetType(classname);
88f843f1 100}
101
102//______________________________________________________________________________
103AliTrigEventWithObject::AliTrigEventWithObject(const AliTrigEventWithObject &other)
104 :AliTrigEvent(other),
79e35bac 105 fValue(NULL),
88f843f1 106 fType(other.fType)
107{
108// Copy constructor.
79e35bac 109 TClass* pClass=TClass::GetClass(fType);
110 if (!pClass) return;
111 fValue = (TObject*)pClass->New();
112 fValue->Copy(*other.fValue);
88f843f1 113}
114
115//______________________________________________________________________________
79e35bac 116AliTrigEventWithObject &AliTrigEventWithObject::operator=(const AliTrigEventWithObject &other)
88f843f1 117{
118// Assignment operator.
79e35bac 119 if (&other == this) return *this;
120 AliTrigEvent::operator=(other);
121 fType = other.fType;
122 TClass* pClass=TClass::GetClass(fType);
123 if (!pClass) return *this;
124 fValue = (TObject*)pClass->New();
125 fValue->Copy(*other.fValue);
126 return *this;
88f843f1 127}
128
129//______________________________________________________________________________
130Bool_t AliTrigEventWithObject::ImportData(AliTrigEvent *source)
131{
132// Import data from likewise signal.
133 AliTrigEventWithObject *src = (AliTrigEventWithObject *)source;
134 Bool_t done = SetValue(src->GetValue());
135 if (!done) Error("ImportData", "Cannot import object <%s> of class <%s> since event type was set to: <%s>",
79e35bac 136 src->GetValue()->GetName(), src->GetValue()->ClassName(), fType.Data());
88f843f1 137 return done;
138}
139
140//______________________________________________________________________________
141Bool_t AliTrigEventWithObject::SetType(const char *classname)
142{
143// Set the type of this event. Can be done only once.
79e35bac 144 if (!strlen(classname)) return kFALSE;
145 if (!fType.IsNull()) {
146 Error("SetType", "Type for this trigger event already set to: %s", fType.Data());
147 return kFALSE;
148 }
88f843f1 149 TClass *type = gROOT->GetClass(classname);
150 if (!type) {
151 Error("SetType", "Unknown class %s", classname);
152 return kFALSE;
153 }
79e35bac 154 fType = classname;
88f843f1 155 return kTRUE;
156}
157
158//______________________________________________________________________________
159Bool_t AliTrigEventWithObject::SetValue(TObject *value)
160{
161// Set the current event content. Checks consistency with event type.
162 if (!value) {
163 // Reset current value.
164 fValue = NULL;
165 return kTRUE;
166 }
88f843f1 167 // Set the type if used for the first time.
79e35bac 168 if (!fType) fType = value->ClassName();
88f843f1 169 fValue = value;
170 return kTRUE;
171}