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"
45 ClassImp( AliTriggerDetector )
47 //_____________________________________________________________________________
48 AliTriggerDetector::AliTriggerDetector() :
53 // Default constructor
56 //_____________________________________________________________________________
57 AliTriggerDetector::AliTriggerDetector(const AliTriggerDetector & de ):
66 //_____________________________________________________________________________
67 AliTriggerDetector::~AliTriggerDetector()
70 // Delete only inputs that are not
71 // associated to the CTP
72 Int_t ninputs = fInputs.GetEntriesFast();
73 for(Int_t i = 0; i < ninputs; i++) {
74 AliTriggerInput *inp = (AliTriggerInput *)fInputs.At(i);
75 if (inp->GetSignature() == -1 &&
77 delete fInputs.RemoveAt(i);
81 //_____________________________________________________________________________
82 void AliTriggerDetector::AssignInputs(const TObjArray &inputs)
84 // Cross-check the trigger inputs provided by the detector trigger
85 // processor (TP) and the inputs defined in CTP
86 // a) If the input is defined in the TP, but not in CTP it
87 // will be generated but not used by CTP. It will be possibly stored
88 // in the detector raw data if the hardware allows this.
89 // b) If hte input is not defined in the TP, but is defined in CTP
90 // then a warning is issued and the CTP simulation is working
91 // with this input disabled.
93 // Check if we have to create the inputs first
94 if( fInputs.GetEntriesFast() == 0 ) {
95 // Create the inputs that the detector can provide
99 TString name = GetName();
101 // Pointer to the available inputs provided by the detector
102 TObjArray* availInputs = &fInputs;
104 Int_t ninputs = inputs.GetEntriesFast();
105 for( Int_t j=0; j<ninputs; j++ ) {
106 AliTriggerInput *inp = (AliTriggerInput*)inputs.At(j);
107 if ( name.CompareTo(inp->GetModule().Data()) ) continue;
109 TObject *tempObj = availInputs->FindObject(inp->GetInputName().Data());
111 Int_t tempIndex = availInputs->IndexOf(tempObj);
112 delete availInputs->Remove(tempObj);
113 fInputs.AddAt( inp, tempIndex );
115 AliDebug(1,Form("Trigger input (%s) is found in the CTP configuration. Therefore it is enabled for trigger detector (%s)",
116 inp->GetInputName().Data(),name.Data()));
119 AliWarning(Form("Trigger Input (%s) is not implemented for the trigger detector (%s) ! It will be disabled !",
120 inp->GetInputName().Data(),name.Data()));
124 for( Int_t j=0; j<fInputs.GetEntriesFast(); j++ ) {
125 AliTriggerInput *inp = (AliTriggerInput *)fInputs.At(j);
126 if (inp->GetSignature() == -1 &&
127 inp->GetMask() == 0) {
129 AliDebug(1,Form("Trigger input (%s) was not found in the CTP configuration. Therefore it will be run in a stand-alone mode",
130 inp->GetInputName().Data()));
134 fInputs.SetOwner(kFALSE);
137 //_____________________________________________________________________________
138 void AliTriggerDetector::CreateInputs()
140 // Define the inputs to the Central Trigger Processor
141 // This is a dummy version
143 // Do not create inputs again!!
144 if( fInputs.GetEntriesFast() > 0 ) return;
146 fInputs.AddLast( new AliTriggerInput( "TEST1_L0", "TEST", 0 ) );
147 fInputs.AddLast( new AliTriggerInput( "TEST2_L0", "TEST", 0 ) );
148 fInputs.AddLast( new AliTriggerInput( "TEST3_L0", "TEST", 0 ) );
151 //_____________________________________________________________________________
152 void AliTriggerDetector::Trigger()
154 // This is a dummy version set all inputs in a random way
156 AliWarning( Form( "Triggering dummy detector %s", GetName() ) );
158 // ********** Get Digits for the current event **********
159 AliRunLoader* runLoader = AliRunLoader::Instance();
160 AliInfo( Form( "Event %d", runLoader->GetEventNumber() ) );
162 TString loadername = GetName();
163 loadername.Append( "Loader" );
164 AliLoader * loader = runLoader->GetLoader( loadername.Data() );
166 loader->LoadDigits( "READ" );
167 TTree* digits = loader->TreeD();
168 // Do something with the digits !!!
172 loader->UnloadDigits();
174 // ******************************************************
176 // set all inputs in a random way
177 Int_t nInputs = fInputs.GetEntriesFast();
178 for( Int_t j=0; j<nInputs; j++ ) {
179 AliTriggerInput* in = (AliTriggerInput*)fInputs.At( j );
180 if( gRandom->Rndm() > 0.5 ) {
182 fMask |= in->GetValue();
187 //_____________________________________________________________________________
188 void AliTriggerDetector::SetInput( TString& name )
191 SetInput( name.Data() );
194 //_____________________________________________________________________________
195 void AliTriggerDetector::SetInput( const char * name )
198 AliTriggerInput* in = ((AliTriggerInput*)fInputs.FindObject( name ));
201 fMask |= in->GetValue();
203 AliError( Form( "There is not input named %s", name ) );
206 //_____________________________________________________________________________
207 void AliTriggerDetector::Print( const Option_t* opt ) const
210 cout << "Trigger Detector : " << GetName() << endl;
211 cout << " Trigger Class Mask: 0x" << hex << GetMask() << dec << endl;
212 Int_t nInputs = fInputs.GetEntriesFast();
213 for( Int_t j=0; j<nInputs; j++ ) {
214 AliTriggerInput* in = (AliTriggerInput*)fInputs.At( j );