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"
38 #include "AliLoader.h"
40 #include "AliTriggerInput.h"
41 #include "AliTriggerDetector.h"
48 ClassImp( AliTriggerDetector )
50 //_____________________________________________________________________________
51 AliTriggerDetector::AliTriggerDetector() :
56 // Default constructor
59 //_____________________________________________________________________________
60 AliTriggerDetector::AliTriggerDetector(const AliTriggerDetector & de ):
69 //_____________________________________________________________________________
70 AliTriggerDetector::~AliTriggerDetector()
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 &&
80 delete fInputs.RemoveAt(i);
84 //_____________________________________________________________________________
85 void AliTriggerDetector::AssignInputs(const TObjArray &inputs)
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.
96 // Check if we have to create the inputs first
97 if( fInputs.GetEntriesFast() == 0 ) {
98 // Create the inputs that the detector can provide
102 TString name = GetName();
104 // Pointer to the available inputs provided by the detector
105 TObjArray* availInputs = &fInputs;
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;
112 TObject *tempObj = availInputs->FindObject(inp->GetInputName().Data());
114 Int_t tempIndex = availInputs->IndexOf(tempObj);
115 delete availInputs->Remove(tempObj);
116 fInputs.AddAt( inp, tempIndex );
118 AliDebug(1,Form("Trigger input (%s) is found in the CTP configuration. Therefore it is enabled for trigger detector (%s)",
119 inp->GetInputName().Data(),name.Data()));
122 AliWarning(Form("Trigger Input (%s) is not implemented for the trigger detector (%s) ! It will be disabled !",
123 inp->GetInputName().Data(),name.Data()));
127 for( Int_t j=0; j<fInputs.GetEntriesFast(); j++ ) {
128 AliTriggerInput *inp = (AliTriggerInput *)fInputs.At(j);
129 if (inp->GetSignature() == -1 &&
130 inp->GetMask() == 0) {
132 AliDebug(1,Form("Trigger input (%s) was not found in the CTP configuration. Therefore it will be run in a stand-alone mode",
133 inp->GetInputName().Data()));
137 fInputs.SetOwner(kFALSE);
140 //_____________________________________________________________________________
141 void AliTriggerDetector::CreateInputs()
143 // Define the inputs to the Central Trigger Processor
144 // This is a dummy version
146 // Do not create inputs again!!
147 if( fInputs.GetEntriesFast() > 0 ) return;
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 ) );
154 //_____________________________________________________________________________
155 void AliTriggerDetector::Trigger()
157 // This is a dummy version set all inputs in a random way
159 AliWarning( Form( "Triggering dummy detector %s", GetName() ) );
161 // ********** Get Digits for the current event **********
162 AliRunLoader* runLoader = AliRunLoader::Instance();
163 AliInfo( Form( "Event %d", runLoader->GetEventNumber() ) );
165 TString loadername = GetName();
166 loadername.Append( "Loader" );
167 AliLoader * loader = runLoader->GetLoader( loadername.Data() );
169 loader->LoadDigits( "READ" );
170 TTree* digits = loader->TreeD();
171 // Do something with the digits !!!
175 loader->UnloadDigits();
177 // ******************************************************
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 ) {
185 fMask |= in->GetValue();
190 //_____________________________________________________________________________
191 void AliTriggerDetector::SetInput( TString& name )
194 SetInput( name.Data() );
197 //_____________________________________________________________________________
198 void AliTriggerDetector::SetInput( const char * name )
201 AliTriggerInput* in = ((AliTriggerInput*)fInputs.FindObject( name ));
204 fMask |= in->GetValue();
206 AliError( Form( "There is not input named %s", name ) );
209 //_____________________________________________________________________________
210 void AliTriggerDetector::Print( const Option_t* opt ) const
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 );