]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliTriggerDetector.cxx
A new method DrawPMDModule is added
[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
51f6d619 55//_____________________________________________________________________________
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//_____________________________________________________________________________
81void AliTriggerDetector::CreateInputs(const TObjArray &inputs)
82{
83 // Define the inputs to the Central Trigger Processor
84 // This is a dummy version
85
86 // Check if we have to create the inputs first
87 if( fInputs.GetEntriesFast() == 0 ) {
88 // Create the inputs that the detector can provide
89 CreateInputs();
90 }
91
92 TString name = GetName();
93
94 // Pointer to the available inputs provided by the detector
95 TObjArray* availInputs = &fInputs;
96
97 Int_t ninputs = inputs.GetEntriesFast();
98 for( Int_t j=0; j<ninputs; j++ ) {
99 AliTriggerInput *inp = (AliTriggerInput*)inputs.At(j);
100 if ( name.CompareTo(inp->GetModule().Data()) ) continue;
101
102 TObject *tempObj = availInputs->FindObject(inp->GetInputName().Data());
103 if ( tempObj ) {
104 Int_t tempIndex = availInputs->IndexOf(tempObj);
105 delete availInputs->Remove(tempObj);
106 fInputs.AddAt( inp, tempIndex );
107 inp->Enable();
108 AliInfo(Form("Trigger input (%s) is found in the CTP configuration. Therefore it is enabled for trigger detector (%s)",
109 inp->GetInputName().Data(),name.Data()));
110 }
111 else {
112 AliWarning(Form("Trigger Input (%s) is not implemented for the trigger detector (%s) ! It will be disabled !",
113 inp->GetInputName().Data(),name.Data()));
114 }
115 }
116
117 for( Int_t j=0; j<fInputs.GetEntriesFast(); j++ ) {
118 AliTriggerInput *inp = (AliTriggerInput *)fInputs.At(j);
119 if (inp->GetSignature() == -1 &&
f788dba9 120 inp->GetMask() == 0) {
51f6d619 121 inp->Enable();
122 AliInfo(Form("Trigger input (%s) was not found in the CTP configuration. Therefore it will be run in a stand-alone mode",
123 inp->GetInputName().Data()));
f788dba9 124 }
51f6d619 125 }
126
127 fInputs.SetOwner(kFALSE);
128}
129
a5a091ce 130//_____________________________________________________________________________
131void AliTriggerDetector::CreateInputs()
132{
133 // Define the inputs to the Central Trigger Processor
134 // This is a dummy version
135
136 // Do not create inputs again!!
137 if( fInputs.GetEntriesFast() > 0 ) return;
138
51f6d619 139 fInputs.AddLast( new AliTriggerInput( "TEST1_L0", "TEST", 0 ) );
140 fInputs.AddLast( new AliTriggerInput( "TEST2_L0", "TEST", 0 ) );
141 fInputs.AddLast( new AliTriggerInput( "TEST3_L0", "TEST", 0 ) );
a5a091ce 142}
143
144//_____________________________________________________________________________
145void AliTriggerDetector::Trigger()
146{
147 // This is a dummy version set all inputs in a random way
148
149 AliWarning( Form( "Triggering dummy detector %s", GetName() ) );
150
151 // ********** Get Digits for the current event **********
152 AliRunLoader* runLoader = gAlice->GetRunLoader();
153 AliInfo( Form( "Event %d", runLoader->GetEventNumber() ) );
154
155 TString loadername = GetName();
156 loadername.Append( "Loader" );
157 AliLoader * loader = runLoader->GetLoader( loadername.Data() );
158 if( loader ) {
159 loader->LoadDigits( "READ" );
160 TTree* digits = loader->TreeD();
161 // Do something with the digits !!!
162 if( digits ) {
163// digits->Print();
164 }
165 loader->UnloadDigits();
166 }
167 // ******************************************************
168
169 // set all inputs in a random way
170 Int_t nInputs = fInputs.GetEntriesFast();
171 for( Int_t j=0; j<nInputs; j++ ) {
172 AliTriggerInput* in = (AliTriggerInput*)fInputs.At( j );
173 if( gRandom->Rndm() > 0.5 ) {
174 in->Set();
175 fMask |= in->GetValue();
176 }
177 }
178}
179
180//_____________________________________________________________________________
181void AliTriggerDetector::SetInput( TString& name )
182{
183 // Set Input by name
92c1978f 184 SetInput( name.Data() );
a5a091ce 185}
186
187//_____________________________________________________________________________
188void AliTriggerDetector::SetInput( const char * name )
189{
190 // Set Input by name
191 AliTriggerInput* in = ((AliTriggerInput*)fInputs.FindObject( name ));
92c1978f 192 if( in ) {
193 in->Set();
194 fMask |= in->GetValue();
195 } else
196 AliError( Form( "There is not input named %s", name ) );
a5a091ce 197}
198
bacbe0fd 199//_____________________________________________________________________________
200void AliTriggerDetector::Print( const Option_t* opt ) const
201{
202 // Print
203 cout << "Trigger Detector : " << GetName() << endl;
204 cout << " Trigger Class Mask: 0x" << hex << GetMask() << dec << endl;
205 Int_t nInputs = fInputs.GetEntriesFast();
206 for( Int_t j=0; j<nInputs; j++ ) {
207 AliTriggerInput* in = (AliTriggerInput*)fInputs.At( j );
208 in->Print( opt );
209 }
210}