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