]>
Commit | Line | Data |
---|---|---|
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" | |
c93255fe | 38 | #include "AliLoader.h" |
a5a091ce | 39 | |
40 | #include "AliTriggerInput.h" | |
41 | #include "AliTriggerDetector.h" | |
42 | ||
43 | ||
44 | ||
45 | ClassImp( AliTriggerDetector ) | |
46 | ||
47 | //_____________________________________________________________________________ | |
75e3794b | 48 | AliTriggerDetector::AliTriggerDetector() : |
49 | TNamed(), | |
50 | fMask(0), | |
51 | fInputs() | |
a5a091ce | 52 | { |
53 | // Default constructor | |
a5a091ce | 54 | } |
55 | ||
51f6d619 | 56 | //_____________________________________________________________________________ |
57 | AliTriggerDetector::AliTriggerDetector(const AliTriggerDetector & de ): | |
58 | TNamed(de), | |
59 | fMask(de.fMask), | |
60 | fInputs(de.fInputs) | |
61 | { | |
62 | // Copy constructor | |
63 | ||
64 | } | |
65 | ||
66 | //_____________________________________________________________________________ | |
67 | AliTriggerDetector::~AliTriggerDetector() | |
68 | { | |
69 | // Destructor | |
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 && | |
76 | inp->GetMask() == 0) | |
77 | delete fInputs.RemoveAt(i); | |
78 | } | |
79 | } | |
80 | ||
81 | //_____________________________________________________________________________ | |
a4d25339 | 82 | void AliTriggerDetector::AssignInputs(const TObjArray &inputs) |
51f6d619 | 83 | { |
a4d25339 | 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. | |
92 | ||
51f6d619 | 93 | // Check if we have to create the inputs first |
94 | if( fInputs.GetEntriesFast() == 0 ) { | |
95 | // Create the inputs that the detector can provide | |
96 | CreateInputs(); | |
97 | } | |
98 | ||
99 | TString name = GetName(); | |
100 | ||
101 | // Pointer to the available inputs provided by the detector | |
102 | TObjArray* availInputs = &fInputs; | |
103 | ||
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; | |
108 | ||
109 | TObject *tempObj = availInputs->FindObject(inp->GetInputName().Data()); | |
110 | if ( tempObj ) { | |
111 | Int_t tempIndex = availInputs->IndexOf(tempObj); | |
112 | delete availInputs->Remove(tempObj); | |
113 | fInputs.AddAt( inp, tempIndex ); | |
114 | inp->Enable(); | |
01eed601 | 115 | AliDebug(1,Form("Trigger input (%s) is found in the CTP configuration. Therefore it is enabled for trigger detector (%s)", |
51f6d619 | 116 | inp->GetInputName().Data(),name.Data())); |
117 | } | |
118 | else { | |
119 | AliWarning(Form("Trigger Input (%s) is not implemented for the trigger detector (%s) ! It will be disabled !", | |
120 | inp->GetInputName().Data(),name.Data())); | |
121 | } | |
122 | } | |
123 | ||
124 | for( Int_t j=0; j<fInputs.GetEntriesFast(); j++ ) { | |
125 | AliTriggerInput *inp = (AliTriggerInput *)fInputs.At(j); | |
126 | if (inp->GetSignature() == -1 && | |
f788dba9 | 127 | inp->GetMask() == 0) { |
51f6d619 | 128 | inp->Enable(); |
01eed601 | 129 | AliDebug(1,Form("Trigger input (%s) was not found in the CTP configuration. Therefore it will be run in a stand-alone mode", |
51f6d619 | 130 | inp->GetInputName().Data())); |
f788dba9 | 131 | } |
51f6d619 | 132 | } |
133 | ||
134 | fInputs.SetOwner(kFALSE); | |
135 | } | |
136 | ||
a5a091ce | 137 | //_____________________________________________________________________________ |
138 | void AliTriggerDetector::CreateInputs() | |
139 | { | |
140 | // Define the inputs to the Central Trigger Processor | |
141 | // This is a dummy version | |
142 | ||
143 | // Do not create inputs again!! | |
144 | if( fInputs.GetEntriesFast() > 0 ) return; | |
145 | ||
51f6d619 | 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 ) ); | |
a5a091ce | 149 | } |
150 | ||
151 | //_____________________________________________________________________________ | |
152 | void AliTriggerDetector::Trigger() | |
153 | { | |
154 | // This is a dummy version set all inputs in a random way | |
155 | ||
156 | AliWarning( Form( "Triggering dummy detector %s", GetName() ) ); | |
157 | ||
158 | // ********** Get Digits for the current event ********** | |
33c3c91a | 159 | AliRunLoader* runLoader = AliRunLoader::Instance(); |
a5a091ce | 160 | AliInfo( Form( "Event %d", runLoader->GetEventNumber() ) ); |
161 | ||
162 | TString loadername = GetName(); | |
163 | loadername.Append( "Loader" ); | |
164 | AliLoader * loader = runLoader->GetLoader( loadername.Data() ); | |
165 | if( loader ) { | |
166 | loader->LoadDigits( "READ" ); | |
167 | TTree* digits = loader->TreeD(); | |
168 | // Do something with the digits !!! | |
169 | if( digits ) { | |
170 | // digits->Print(); | |
171 | } | |
172 | loader->UnloadDigits(); | |
173 | } | |
174 | // ****************************************************** | |
175 | ||
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 ) { | |
181 | in->Set(); | |
182 | fMask |= in->GetValue(); | |
183 | } | |
184 | } | |
185 | } | |
186 | ||
187 | //_____________________________________________________________________________ | |
188 | void AliTriggerDetector::SetInput( TString& name ) | |
189 | { | |
190 | // Set Input by name | |
92c1978f | 191 | SetInput( name.Data() ); |
a5a091ce | 192 | } |
193 | ||
194 | //_____________________________________________________________________________ | |
195 | void AliTriggerDetector::SetInput( const char * name ) | |
196 | { | |
197 | // Set Input by name | |
198 | AliTriggerInput* in = ((AliTriggerInput*)fInputs.FindObject( name )); | |
92c1978f | 199 | if( in ) { |
200 | in->Set(); | |
201 | fMask |= in->GetValue(); | |
202 | } else | |
203 | AliError( Form( "There is not input named %s", name ) ); | |
a5a091ce | 204 | } |
205 | ||
bacbe0fd | 206 | //_____________________________________________________________________________ |
207 | void AliTriggerDetector::Print( const Option_t* opt ) const | |
208 | { | |
209 | ||
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 ); | |
215 | in->Print( opt ); | |
216 | } | |
217 | } |