1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // Base Class for Detector specific Trigger // //
26 ///////////////////////////////////////////////////////////////////////////////
28 #include <Riostream.h>
31 #include <TObjArray.h>
37 #include "AliRunLoader.h"
39 #include "AliTriggerInput.h"
40 #include "AliTriggerDetector.h"
44 ClassImp( AliTriggerDetector )
46 //_____________________________________________________________________________
47 AliTriggerDetector::AliTriggerDetector() :
52 // Default constructor
55 //_____________________________________________________________________________
56 AliTriggerDetector::AliTriggerDetector(const AliTriggerDetector & de ):
65 //_____________________________________________________________________________
66 AliTriggerDetector::~AliTriggerDetector()
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 &&
76 delete fInputs.RemoveAt(i);
80 //_____________________________________________________________________________
81 void AliTriggerDetector::CreateInputs(const TObjArray &inputs)
83 // Define the inputs to the Central Trigger Processor
84 // This is a dummy version
86 // Check if we have to create the inputs first
87 if( fInputs.GetEntriesFast() == 0 ) {
88 // Create the inputs that the detector can provide
92 TString name = GetName();
94 // Pointer to the available inputs provided by the detector
95 TObjArray* availInputs = &fInputs;
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;
102 TObject *tempObj = availInputs->FindObject(inp->GetInputName().Data());
104 Int_t tempIndex = availInputs->IndexOf(tempObj);
105 delete availInputs->Remove(tempObj);
106 fInputs.AddAt( inp, tempIndex );
108 AliDebug(1,Form("Trigger input (%s) is found in the CTP configuration. Therefore it is enabled for trigger detector (%s)",
109 inp->GetInputName().Data(),name.Data()));
112 AliWarning(Form("Trigger Input (%s) is not implemented for the trigger detector (%s) ! It will be disabled !",
113 inp->GetInputName().Data(),name.Data()));
117 for( Int_t j=0; j<fInputs.GetEntriesFast(); j++ ) {
118 AliTriggerInput *inp = (AliTriggerInput *)fInputs.At(j);
119 if (inp->GetSignature() == -1 &&
120 inp->GetMask() == 0) {
122 AliDebug(1,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()));
127 fInputs.SetOwner(kFALSE);
130 //_____________________________________________________________________________
131 void AliTriggerDetector::CreateInputs()
133 // Define the inputs to the Central Trigger Processor
134 // This is a dummy version
136 // Do not create inputs again!!
137 if( fInputs.GetEntriesFast() > 0 ) return;
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 ) );
144 //_____________________________________________________________________________
145 void AliTriggerDetector::Trigger()
147 // This is a dummy version set all inputs in a random way
149 AliWarning( Form( "Triggering dummy detector %s", GetName() ) );
151 // ********** Get Digits for the current event **********
152 AliRunLoader* runLoader = AliRunLoader::Instance();
153 AliInfo( Form( "Event %d", runLoader->GetEventNumber() ) );
155 TString loadername = GetName();
156 loadername.Append( "Loader" );
157 AliLoader * loader = runLoader->GetLoader( loadername.Data() );
159 loader->LoadDigits( "READ" );
160 TTree* digits = loader->TreeD();
161 // Do something with the digits !!!
165 loader->UnloadDigits();
167 // ******************************************************
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 ) {
175 fMask |= in->GetValue();
180 //_____________________________________________________________________________
181 void AliTriggerDetector::SetInput( TString& name )
184 SetInput( name.Data() );
187 //_____________________________________________________________________________
188 void AliTriggerDetector::SetInput( const char * name )
191 AliTriggerInput* in = ((AliTriggerInput*)fInputs.FindObject( name ));
194 fMask |= in->GetValue();
196 AliError( Form( "There is not input named %s", name ) );
199 //_____________________________________________________________________________
200 void AliTriggerDetector::Print( const Option_t* opt ) const
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 );