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::AssignInputs(const TObjArray &inputs)
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.
92 // Check if we have to create the inputs first
93 if( fInputs.GetEntriesFast() == 0 ) {
94 // Create the inputs that the detector can provide
98 TString name = GetName();
100 // Pointer to the available inputs provided by the detector
101 TObjArray* availInputs = &fInputs;
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;
108 TObject *tempObj = availInputs->FindObject(inp->GetInputName().Data());
110 Int_t tempIndex = availInputs->IndexOf(tempObj);
111 delete availInputs->Remove(tempObj);
112 fInputs.AddAt( inp, tempIndex );
114 AliDebug(1,Form("Trigger input (%s) is found in the CTP configuration. Therefore it is enabled for trigger detector (%s)",
115 inp->GetInputName().Data(),name.Data()));
118 AliWarning(Form("Trigger Input (%s) is not implemented for the trigger detector (%s) ! It will be disabled !",
119 inp->GetInputName().Data(),name.Data()));
123 for( Int_t j=0; j<fInputs.GetEntriesFast(); j++ ) {
124 AliTriggerInput *inp = (AliTriggerInput *)fInputs.At(j);
125 if (inp->GetSignature() == -1 &&
126 inp->GetMask() == 0) {
128 AliDebug(1,Form("Trigger input (%s) was not found in the CTP configuration. Therefore it will be run in a stand-alone mode",
129 inp->GetInputName().Data()));
133 fInputs.SetOwner(kFALSE);
136 //_____________________________________________________________________________
137 void AliTriggerDetector::CreateInputs()
139 // Define the inputs to the Central Trigger Processor
140 // This is a dummy version
142 // Do not create inputs again!!
143 if( fInputs.GetEntriesFast() > 0 ) return;
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 ) );
150 //_____________________________________________________________________________
151 void AliTriggerDetector::Trigger()
153 // This is a dummy version set all inputs in a random way
155 AliWarning( Form( "Triggering dummy detector %s", GetName() ) );
157 // ********** Get Digits for the current event **********
158 AliRunLoader* runLoader = AliRunLoader::Instance();
159 AliInfo( Form( "Event %d", runLoader->GetEventNumber() ) );
161 TString loadername = GetName();
162 loadername.Append( "Loader" );
163 AliLoader * loader = runLoader->GetLoader( loadername.Data() );
165 loader->LoadDigits( "READ" );
166 TTree* digits = loader->TreeD();
167 // Do something with the digits !!!
171 loader->UnloadDigits();
173 // ******************************************************
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 ) {
181 fMask |= in->GetValue();
186 //_____________________________________________________________________________
187 void AliTriggerDetector::SetInput( TString& name )
190 SetInput( name.Data() );
193 //_____________________________________________________________________________
194 void AliTriggerDetector::SetInput( const char * name )
197 AliTriggerInput* in = ((AliTriggerInput*)fInputs.FindObject( name ));
200 fMask |= in->GetValue();
202 AliError( Form( "There is not input named %s", name ) );
205 //_____________________________________________________________________________
206 void AliTriggerDetector::Print( const Option_t* opt ) const
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 );