- Three classes by MinJung Kweon AliHFEpriVtx, AliHFEsecVtx and AliHFEmcQA for primar...
[u/mrichter/AliRoot.git] / STEER / AliTriggerDetector.cxx
CommitLineData
a5a091ce 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
18///////////////////////////////////////////////////////////////////////////////
19// //
20// Base Class for Detector specific Trigger // //
21// //
22// //
23// //
24// //
25// //
26///////////////////////////////////////////////////////////////////////////////
27
bacbe0fd 28#include <Riostream.h>
a5a091ce 29#include <TNamed.h>
30#include <TString.h>
31#include <TObjArray.h>
32#include <TRandom.h>
33
34
35#include "AliLog.h"
36#include "AliRun.h"
37#include "AliRunLoader.h"
38
39#include "AliTriggerInput.h"
40#include "AliTriggerDetector.h"
41
42
43
44ClassImp( AliTriggerDetector )
45
46//_____________________________________________________________________________
75e3794b 47AliTriggerDetector::AliTriggerDetector() :
48 TNamed(),
49 fMask(0),
50 fInputs()
a5a091ce 51{
52 // Default constructor
a5a091ce 53}
54
55//_____________________________________________________________________________
51f6d619 56AliTriggerDetector::AliTriggerDetector(const AliTriggerDetector & de ):
57 TNamed(de),
58 fMask(de.fMask),
59 fInputs(de.fInputs)
60{
61 // Copy constructor
62
63}
64
65//_____________________________________________________________________________
66AliTriggerDetector::~AliTriggerDetector()
67{
68 // Destructor
69 // Delete only inputs that are not
70 // associated to the CTP
71 Int_t ninputs = fInputs.GetEntriesFast();
72 for(Int_t i = 0; i < ninputs; i++) {
73 AliTriggerInput *inp = (AliTriggerInput *)fInputs.At(i);
74 if (inp->GetSignature() == -1 &&
75 inp->GetMask() == 0)
76 delete fInputs.RemoveAt(i);
77 }
78}
79
80//_____________________________________________________________________________
a4d25339 81void AliTriggerDetector::AssignInputs(const TObjArray &inputs)
51f6d619 82{
a4d25339 83 // Cross-check the trigger inputs provided by the detector trigger
84 // processor (TP) and the inputs defined in CTP
85 // a) If the input is defined in the TP, but not in CTP it
86 // will be generated but not used by CTP. It will be possibly stored
87 // in the detector raw data if the hardware allows this.
88 // b) If hte input is not defined in the TP, but is defined in CTP
89 // then a warning is issued and the CTP simulation is working
90 // with this input disabled.
91
51f6d619 92 // Check if we have to create the inputs first
93 if( fInputs.GetEntriesFast() == 0 ) {
94 // Create the inputs that the detector can provide
95 CreateInputs();
96 }
97
98 TString name = GetName();
99
100 // Pointer to the available inputs provided by the detector
101 TObjArray* availInputs = &fInputs;
102
103 Int_t ninputs = inputs.GetEntriesFast();
104 for( Int_t j=0; j<ninputs; j++ ) {
105 AliTriggerInput *inp = (AliTriggerInput*)inputs.At(j);
106 if ( name.CompareTo(inp->GetModule().Data()) ) continue;
107
108 TObject *tempObj = availInputs->FindObject(inp->GetInputName().Data());
109 if ( tempObj ) {
110 Int_t tempIndex = availInputs->IndexOf(tempObj);
111 delete availInputs->Remove(tempObj);
112 fInputs.AddAt( inp, tempIndex );
113 inp->Enable();
01eed601 114 AliDebug(1,Form("Trigger input (%s) is found in the CTP configuration. Therefore it is enabled for trigger detector (%s)",
51f6d619 115 inp->GetInputName().Data(),name.Data()));
116 }
117 else {
118 AliWarning(Form("Trigger Input (%s) is not implemented for the trigger detector (%s) ! It will be disabled !",
119 inp->GetInputName().Data(),name.Data()));
120 }
121 }
122
123 for( Int_t j=0; j<fInputs.GetEntriesFast(); j++ ) {
124 AliTriggerInput *inp = (AliTriggerInput *)fInputs.At(j);
125 if (inp->GetSignature() == -1 &&
f788dba9 126 inp->GetMask() == 0) {
51f6d619 127 inp->Enable();
01eed601 128 AliDebug(1,Form("Trigger input (%s) was not found in the CTP configuration. Therefore it will be run in a stand-alone mode",
51f6d619 129 inp->GetInputName().Data()));
f788dba9 130 }
51f6d619 131 }
132
133 fInputs.SetOwner(kFALSE);
134}
135
136//_____________________________________________________________________________
a5a091ce 137void AliTriggerDetector::CreateInputs()
138{
139 // Define the inputs to the Central Trigger Processor
140 // This is a dummy version
141
142 // Do not create inputs again!!
143 if( fInputs.GetEntriesFast() > 0 ) return;
144
51f6d619 145 fInputs.AddLast( new AliTriggerInput( "TEST1_L0", "TEST", 0 ) );
146 fInputs.AddLast( new AliTriggerInput( "TEST2_L0", "TEST", 0 ) );
147 fInputs.AddLast( new AliTriggerInput( "TEST3_L0", "TEST", 0 ) );
a5a091ce 148}
149
150//_____________________________________________________________________________
151void AliTriggerDetector::Trigger()
152{
153 // This is a dummy version set all inputs in a random way
154
155 AliWarning( Form( "Triggering dummy detector %s", GetName() ) );
156
157 // ********** Get Digits for the current event **********
33c3c91a 158 AliRunLoader* runLoader = AliRunLoader::Instance();
a5a091ce 159 AliInfo( Form( "Event %d", runLoader->GetEventNumber() ) );
160
161 TString loadername = GetName();
162 loadername.Append( "Loader" );
163 AliLoader * loader = runLoader->GetLoader( loadername.Data() );
164 if( loader ) {
165 loader->LoadDigits( "READ" );
166 TTree* digits = loader->TreeD();
167 // Do something with the digits !!!
168 if( digits ) {
169// digits->Print();
170 }
171 loader->UnloadDigits();
172 }
173 // ******************************************************
174
175 // set all inputs in a random way
176 Int_t nInputs = fInputs.GetEntriesFast();
177 for( Int_t j=0; j<nInputs; j++ ) {
178 AliTriggerInput* in = (AliTriggerInput*)fInputs.At( j );
179 if( gRandom->Rndm() > 0.5 ) {
180 in->Set();
181 fMask |= in->GetValue();
182 }
183 }
184}
185
186//_____________________________________________________________________________
187void AliTriggerDetector::SetInput( TString& name )
188{
189 // Set Input by name
92c1978f 190 SetInput( name.Data() );
a5a091ce 191}
192
193//_____________________________________________________________________________
194void AliTriggerDetector::SetInput( const char * name )
195{
196 // Set Input by name
197 AliTriggerInput* in = ((AliTriggerInput*)fInputs.FindObject( name ));
92c1978f 198 if( in ) {
199 in->Set();
200 fMask |= in->GetValue();
201 } else
202 AliError( Form( "There is not input named %s", name ) );
a5a091ce 203}
204
205//_____________________________________________________________________________
bacbe0fd 206void AliTriggerDetector::Print( const Option_t* opt ) const
207{
208 // Print
209 cout << "Trigger Detector : " << GetName() << endl;
210 cout << " Trigger Class Mask: 0x" << hex << GetMask() << dec << endl;
211 Int_t nInputs = fInputs.GetEntriesFast();
212 for( Int_t j=0; j<nInputs; j++ ) {
213 AliTriggerInput* in = (AliTriggerInput*)fInputs.At( j );
214 in->Print( opt );
215 }
216}