]>
Commit | Line | Data |
---|---|---|
51f6d619 | 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 | /////////////////////////////////////////////////////////////////////////////// | |
17 | // | |
18 | // This class which defines defines the Trigger Configuration | |
19 | // | |
20 | // Trigger Configuration defines the trigger setup for a particular run | |
21 | // We have default configurations for each running mode (Pb-Pb, p-p, p-A, Calibration, etc). | |
22 | // It keep: | |
23 | // All the information conained in the CTP configuration file used | |
24 | // online during the data taking | |
25 | // | |
26 | // Configurations could be created and stored in local file. | |
27 | // By default the configuration is loaded from the corresponding GRP entry | |
28 | // inside the OCDB. There one can have one and only one configuration per run. | |
29 | // | |
30 | // Example how to create a Trigger Configuration: | |
31 | // | |
32 | // AliTriggerConfiguration config( "TEST", "Test Configuration" ); | |
33 | // | |
34 | // // Define a Cluster Detector | |
35 | // config.AddDetectorCluster( "VZERO ZDC MUON" ); | |
36 | // | |
37 | // // Define the trigger conditions (see AliTriggerCondition.cxx) | |
38 | // config.AddCondition( "VZERO_TEST1_L0 & MUON_SPlus_LPt_L0 & ZDC_TEST2_L0", // condition | |
39 | // "VO1_M1_ZDC2", // short name | |
40 | // "Dummy", // short description | |
41 | // 0x0100 ); // class mask (set one bit) | |
42 | // | |
43 | // config.AddCondition( "VZERO_TEST2_L0 & MUON_SMinus_HPt_L0 & ZDC_TEST1_L0", | |
44 | // "VO2_M3_ZDC1", | |
45 | // "Dummy", | |
46 | // 0x0200 ); | |
47 | // | |
48 | // config.AddCondition( "VZERO_TEST3_L0 | MUON_Unlike_LPt_L0 | ZDC_TEST3_L0", | |
49 | // "VO3_M1_ZDC3", | |
50 | // "Dummy", | |
51 | // 0x0400 ); | |
52 | // config.CheckInputsConditions("Config.C"); | |
53 | // config.Print(); | |
54 | // | |
55 | // // save the configuration to file | |
56 | // // (default file name $ALICE_ROOT/data/triggerConfigurations.root) | |
57 | // config.WriteConfiguration(); or config.WriteConfiguration( filename ); | |
58 | // | |
59 | /////////////////////////////////////////////////////////////////////////////// | |
60 | #include <Riostream.h> | |
51f6d619 | 61 | |
3e2e3ece | 62 | #include <TCint.h> |
63 | #include <TFile.h> | |
64 | #include <TKey.h> | |
65 | #include <TObjArray.h> | |
66 | #include <TObjString.h> | |
51f6d619 | 67 | #include <TObject.h> |
3e2e3ece | 68 | #include <TROOT.h> |
51f6d619 | 69 | #include <TString.h> |
51f6d619 | 70 | #include <TSystem.h> |
2efec14e | 71 | #include <TMath.h> |
51f6d619 | 72 | |
73 | #include "AliLog.h" | |
51f6d619 | 74 | #include "AliTriggerBCMask.h" |
51f6d619 | 75 | #include "AliTriggerClass.h" |
3e2e3ece | 76 | #include "AliTriggerCluster.h" |
51f6d619 | 77 | #include "AliTriggerConfiguration.h" |
3e2e3ece | 78 | #include "AliTriggerDescriptor.h" |
79 | #include "AliTriggerInput.h" | |
80 | #include "AliTriggerInteraction.h" | |
81 | #include "AliTriggerPFProtection.h" | |
51f6d619 | 82 | |
83 | ClassImp(AliTriggerConfiguration) | |
84 | ||
85 | const TString AliTriggerConfiguration::fgkConfigurationFileName("/data/triggerConfigurations.root"); | |
86 | ||
87 | //_____________________________________________________________________________ | |
88 | AliTriggerConfiguration::AliTriggerConfiguration(): | |
89 | TNamed(), | |
90 | fInputs(), | |
91 | fInteractions(), | |
92 | fFunctions(), | |
93 | fPFProtections(), | |
94 | fMasks(), | |
95 | fDescriptors(), | |
96 | fClusters(), | |
509b7052 | 97 | fClasses(), |
98 | fVersion(0) | |
51f6d619 | 99 | { |
100 | // Default constructor | |
101 | } | |
102 | ||
103 | //_____________________________________________________________________________ | |
104 | AliTriggerConfiguration::AliTriggerConfiguration( TString & name, TString & description ): | |
105 | TNamed( name, description ), | |
106 | fInputs(), | |
107 | fInteractions(), | |
108 | fFunctions(), | |
109 | fPFProtections(), | |
110 | fMasks(), | |
111 | fDescriptors(), | |
112 | fClusters(), | |
509b7052 | 113 | fClasses(), |
114 | fVersion(0) | |
51f6d619 | 115 | { |
116 | // Constructor | |
117 | } | |
118 | ||
119 | //_____________________________________________________________________________ | |
120 | AliTriggerConfiguration::~AliTriggerConfiguration() | |
121 | { | |
f3eb4d78 | 122 | // Destructor |
51f6d619 | 123 | fInputs.SetOwner(); |
124 | fInputs.Delete(); | |
125 | fInteractions.SetOwner(); | |
126 | fInteractions.Delete(); | |
127 | fFunctions.SetOwner(); | |
128 | fFunctions.Delete(); | |
129 | fPFProtections.SetOwner(); | |
130 | fPFProtections.Delete(); | |
131 | fMasks.SetOwner(); | |
132 | fMasks.Delete(); | |
133 | fDescriptors.SetOwner(); | |
134 | fDescriptors.Delete(); | |
135 | fClusters.SetOwner(); | |
136 | fClusters.Delete(); | |
137 | fClasses.SetOwner(); | |
138 | fClasses.Delete(); | |
139 | } | |
140 | ||
141 | //_____________________________________________________________________________ | |
142 | Bool_t AliTriggerConfiguration::AddInput( AliTriggerInput* input ) | |
143 | { | |
f3eb4d78 | 144 | // Add a trigger input to |
145 | // the list of the trigger inputs | |
51f6d619 | 146 | if (fInputs.GetEntries() < kNMaxInputs) { |
147 | fInputs.AddLast( input ); | |
148 | return kTRUE; | |
149 | } | |
150 | else { | |
a5a9f26b | 151 | AliError("CTP can handle up to 60 inputs ! Impossible to add the required input !"); |
51f6d619 | 152 | return kFALSE; |
153 | } | |
154 | } | |
155 | ||
156 | //_____________________________________________________________________________ | |
157 | AliTriggerInput* AliTriggerConfiguration::AddInput( TString &name, TString &det, | |
158 | UChar_t level, UInt_t signature, | |
159 | UChar_t number ) | |
160 | { | |
f3eb4d78 | 161 | // Add a trigger input to |
162 | // the list of the trigger inputs | |
51f6d619 | 163 | AliTriggerInput *input = new AliTriggerInput(name,det,level,signature,number); |
164 | if (!AddInput(input)) { | |
165 | delete input; | |
166 | return NULL; | |
167 | } | |
168 | else | |
169 | return input; | |
170 | } | |
171 | ||
172 | //_____________________________________________________________________________ | |
173 | AliTriggerInteraction* AliTriggerConfiguration::AddInteraction(TString &name, TString &logic) | |
174 | { | |
f3eb4d78 | 175 | // Add a trigger interaction object to |
176 | // the list of the trigger interactions | |
51f6d619 | 177 | AliTriggerInteraction *interact = new AliTriggerInteraction(name,logic); |
178 | if (!AddInteraction(interact)) { | |
179 | delete interact; | |
180 | return NULL; | |
181 | } | |
182 | else | |
183 | return interact; | |
184 | } | |
185 | ||
186 | //_____________________________________________________________________________ | |
187 | Bool_t AliTriggerConfiguration::AddInteraction(AliTriggerInteraction *interact) | |
188 | { | |
f3eb4d78 | 189 | // Add a trigger interaction object to |
190 | // the list of the trigger interactions | |
51f6d619 | 191 | if (fInteractions.GetEntries() < kNMaxInteractions) { |
192 | if (interact->CheckInputs(fInputs)) { | |
193 | fInteractions.AddLast( interact ); | |
194 | return kTRUE; | |
195 | } | |
196 | else | |
197 | AliError("Invalid interaction ! Impossible to add it !"); | |
198 | } | |
199 | else | |
200 | AliError("CTP can handle up to 2 interactions ! Impossible to add the required interaction !"); | |
201 | ||
202 | return kFALSE; | |
203 | } | |
204 | ||
205 | //_____________________________________________________________________________ | |
206 | AliTriggerInteraction* AliTriggerConfiguration::AddFunction(TString &name, TString &logic) | |
207 | { | |
f3eb4d78 | 208 | // Add a trigger function object to |
209 | // the list of the trigger functions | |
51f6d619 | 210 | AliTriggerInteraction *func = new AliTriggerInteraction(name,logic); |
211 | if (!AddFunction(func)) { | |
212 | delete func; | |
213 | return NULL; | |
214 | } | |
215 | else | |
216 | return func; | |
217 | } | |
218 | ||
219 | //_____________________________________________________________________________ | |
220 | Bool_t AliTriggerConfiguration::AddFunction(AliTriggerInteraction *func) | |
221 | { | |
f3eb4d78 | 222 | // Add a trigger function object to |
223 | // the list of the trigger functions | |
51f6d619 | 224 | if (fFunctions.GetEntries() < kNMaxFunctions) { |
225 | if (func->CheckInputs(fInputs)) { | |
226 | fFunctions.AddLast( func ); | |
227 | return kTRUE; | |
228 | } | |
229 | else | |
230 | AliError("Invalid logical function ! Impossible to add it !"); | |
231 | } | |
232 | else | |
233 | AliError("CTP can handle up to 2 logical functions ! Impossible to add the required interaction !"); | |
234 | ||
235 | return kFALSE; | |
236 | } | |
237 | ||
238 | //_____________________________________________________________________________ | |
239 | Bool_t AliTriggerConfiguration::AddPFProtection( AliTriggerPFProtection* pfp ) | |
240 | { | |
f3eb4d78 | 241 | // Add a trigger past-future protection object to |
242 | // the list of the trigger past-future protections | |
51f6d619 | 243 | if (fPFProtections.GetEntries() < kNMaxPFProtections) { |
e0602036 | 244 | //if (pfp->CheckInteractions(fInteractions)) { |
245 | if (1) { | |
51f6d619 | 246 | fPFProtections.AddLast( pfp ); |
247 | return kTRUE; | |
248 | } | |
249 | else | |
250 | AliError("Invalid past-future protection ! Impossible to add it !"); | |
251 | } | |
252 | else | |
253 | AliError("CTP can handle up to 4 past-future protections ! Impossible to add the required protection !"); | |
254 | ||
255 | return kFALSE; | |
256 | } | |
257 | ||
258 | //_____________________________________________________________________________ | |
259 | AliTriggerBCMask* AliTriggerConfiguration::AddMask( TString &name, TString &mask ) | |
260 | { | |
f3eb4d78 | 261 | // Add a trigger bunch-crossing mask object to |
262 | // the list of the trigger bunch-crossing masks | |
51f6d619 | 263 | AliTriggerBCMask *bcmask = new AliTriggerBCMask(name,mask); |
264 | if (!AddMask(bcmask)) { | |
265 | delete bcmask; | |
266 | return NULL; | |
267 | } | |
268 | else | |
269 | return bcmask; | |
270 | } | |
271 | ||
272 | //_____________________________________________________________________________ | |
273 | Bool_t AliTriggerConfiguration::AddMask( AliTriggerBCMask* mask ) | |
274 | { | |
f3eb4d78 | 275 | // Add a trigger bunch-crossing mask object to |
276 | // the list of the trigger bunch-crossing masks | |
583e63b8 | 277 | if (fMasks.GetEntries() < (kNMaxMasks+1)) { //+1 to account for NONE |
51f6d619 | 278 | fMasks.AddLast( mask ); |
279 | return kTRUE; | |
280 | } | |
281 | else | |
282 | AliError("CTP can handle up to 4 bunch-crossing masks ! Impossible to add the required mask !"); | |
283 | ||
284 | return kFALSE; | |
285 | } | |
286 | ||
287 | //_____________________________________________________________________________ | |
288 | AliTriggerCluster* AliTriggerConfiguration::AddCluster( TString &name, UChar_t index, TString &detectors) | |
289 | { | |
f3eb4d78 | 290 | // Add a trigger detector readout cluster to |
291 | // the list of the trigger clusters | |
51f6d619 | 292 | AliTriggerCluster *clust = new AliTriggerCluster(name,index,detectors); |
293 | if (!AddCluster(clust)) { | |
294 | delete clust; | |
295 | return NULL; | |
296 | } | |
297 | else | |
298 | return clust; | |
299 | ||
300 | } | |
301 | ||
302 | //_____________________________________________________________________________ | |
303 | Bool_t AliTriggerConfiguration::AddCluster( AliTriggerCluster* cluster ) | |
304 | { | |
f3eb4d78 | 305 | // Add a trigger detector readout cluster to |
306 | // the list of the trigger clusters | |
51f6d619 | 307 | if (fClusters.GetEntries() < kNMaxClusters) { |
308 | TString dets(cluster->GetDetectorsInCluster()); | |
309 | if (!(dets.IsNull())) { | |
310 | fClusters.AddLast( cluster ); | |
311 | return kTRUE; | |
312 | } | |
313 | else | |
314 | AliError("Empty trigger cluster ! Impossible to add it !"); | |
315 | } | |
316 | else | |
317 | AliError("CTP can handle up to 6 different detector clusters ! Impossible to add the required cluster !"); | |
318 | ||
319 | return kFALSE; | |
320 | } | |
321 | ||
322 | //_____________________________________________________________________________ | |
323 | TString AliTriggerConfiguration::GetActiveDetectors() const | |
324 | { | |
f3eb4d78 | 325 | // Return an string with all active detector |
326 | // from each cluster | |
51f6d619 | 327 | |
328 | TString activeDet = ""; | |
329 | ||
330 | Int_t nclus = fClusters.GetEntriesFast(); | |
331 | if( !nclus ) return activeDet; | |
332 | ||
605cb8bb | 333 | for( Int_t j=0; j<nclus; ++j ) { |
51f6d619 | 334 | TString detStr = ((AliTriggerCluster*)fClusters.At(j))->GetDetectorsInCluster(); |
335 | TObjArray* det = detStr.Tokenize(" "); | |
336 | Int_t ndet = det->GetEntriesFast(); | |
605cb8bb | 337 | for( Int_t k=0; k<ndet; ++k ) { |
338 | if( activeDet.Contains( ((TObjString*)det->At(k))->String() ) )continue; | |
51f6d619 | 339 | activeDet.Append( " " ); |
605cb8bb | 340 | activeDet.Append( ((TObjString*)det->At(k))->String() ); |
51f6d619 | 341 | } |
342 | } | |
343 | return activeDet; | |
344 | } | |
345 | ||
346 | //_____________________________________________________________________________ | |
347 | TString AliTriggerConfiguration::GetTriggeringDetectors() const | |
348 | { | |
f3eb4d78 | 349 | // Return an string with all detectors |
350 | // used for triggering | |
51f6d619 | 351 | |
352 | TString trDet = ""; | |
353 | ||
354 | Int_t ninputs = fInputs.GetEntriesFast(); | |
355 | if( !ninputs ) return trDet; | |
356 | ||
357 | for( Int_t j=0; j<ninputs; j++ ) { | |
358 | TString detStr = ((AliTriggerInput*)fInputs.At(j))->GetDetector(); | |
359 | if( trDet.Contains( detStr ) ) continue; | |
360 | trDet.Append( " " ); | |
361 | trDet.Append( detStr ); | |
362 | } | |
363 | return trDet; | |
364 | } | |
365 | ||
366 | //_____________________________________________________________________________ | |
367 | TString AliTriggerConfiguration::GetTriggeringModules() const | |
368 | { | |
369 | // Return an string with all detectors (modules in the AliRoot | |
370 | // simulation sense) used for triggering | |
371 | ||
372 | TString trDet = ""; | |
373 | ||
374 | Int_t ninputs = fInputs.GetEntriesFast(); | |
375 | if( !ninputs ) return trDet; | |
376 | ||
377 | for( Int_t j=0; j<ninputs; j++ ) { | |
378 | TString detStr = ((AliTriggerInput*)fInputs.At(j))->GetModule(); | |
379 | if( trDet.Contains( detStr ) ) continue; | |
380 | trDet.Append( " " ); | |
381 | trDet.Append( detStr ); | |
382 | } | |
383 | return trDet; | |
384 | } | |
385 | ||
386 | //_____________________________________________________________________________ | |
387 | AliTriggerDescriptor* AliTriggerConfiguration::AddDescriptor( TString &name, TString &cond ) | |
388 | { | |
f3eb4d78 | 389 | // Add a trigger descriptor to |
390 | // the list of the trigger descriptors | |
51f6d619 | 391 | AliTriggerDescriptor *desc = new AliTriggerDescriptor(name,cond); |
392 | if (!AddDescriptor(desc)) { | |
393 | delete desc; | |
394 | return NULL; | |
395 | } | |
396 | else | |
397 | return desc; | |
398 | } | |
399 | ||
400 | //_____________________________________________________________________________ | |
401 | Bool_t AliTriggerConfiguration::AddDescriptor( AliTriggerDescriptor *desc ) | |
402 | { | |
f3eb4d78 | 403 | // Add a trigger descriptor to |
404 | // the list of the trigger descriptors | |
51f6d619 | 405 | if (fDescriptors.GetEntries() < kNMaxClasses) { |
406 | if (desc->CheckInputsAndFunctions(fInputs,fFunctions)) { | |
407 | fDescriptors.AddLast( desc ); | |
408 | return kTRUE; | |
409 | } | |
410 | else | |
411 | AliError("Invalid trigger desciptor ! Impossible to add it !"); | |
412 | } | |
413 | else | |
414 | AliError("CTP can handle up to 50 different descriptors ! Impossible to add the required descriptor !"); | |
415 | ||
416 | return kFALSE; | |
417 | } | |
418 | ||
419 | //_____________________________________________________________________________ | |
420 | Bool_t AliTriggerConfiguration::AddClass( AliTriggerClass *trclass ) | |
421 | { | |
f3eb4d78 | 422 | // Add a trigger class to |
423 | // the list of the trigger classes | |
51f6d619 | 424 | if (fClasses.GetEntries() < kNMaxClasses) { |
425 | if (trclass->CheckClass(this)) { | |
426 | fClasses.AddLast( trclass ); | |
427 | return kTRUE; | |
428 | } | |
429 | else | |
430 | AliError("Invalid trigger class ! Impossible to add it !"); | |
431 | } | |
432 | else | |
433 | AliError("CTP can handle up to 50 different classes ! Impossible to add the required class !"); | |
434 | ||
435 | return kFALSE; | |
436 | } | |
437 | ||
438 | //_____________________________________________________________________________ | |
439 | AliTriggerClass *AliTriggerConfiguration::AddClass( TString &name, UChar_t index, | |
440 | AliTriggerDescriptor *desc, AliTriggerCluster *clus, | |
441 | AliTriggerPFProtection *pfp, AliTriggerBCMask *mask, | |
442 | UInt_t prescaler, Bool_t allrare) | |
443 | { | |
f3eb4d78 | 444 | // Add a trigger class to |
445 | // the list of the trigger classes | |
51f6d619 | 446 | if (!fDescriptors.FindObject(desc)) { |
447 | AliError("Invalid descriptor ! Impossible to add the class !"); | |
448 | return NULL; | |
449 | } | |
450 | if (!fClusters.FindObject(clus)) { | |
451 | AliError("Invalid cluster ! Impossible to add the class !"); | |
452 | return NULL; | |
453 | } | |
454 | if (!fPFProtections.FindObject(pfp)) { | |
455 | AliError("Invalid past-future protection ! Impossible to add the class !"); | |
456 | return NULL; | |
457 | } | |
458 | if (!fMasks.FindObject(mask)) { | |
459 | AliError("Invalid bunch-crossing mask ! Impossible to add the class !"); | |
460 | return NULL; | |
461 | } | |
462 | AliTriggerClass* trclass = new AliTriggerClass( name,index,desc,clus,pfp,mask,prescaler,allrare ); | |
463 | if (!AddClass(trclass)) { | |
464 | delete trclass; | |
465 | return NULL; | |
466 | } | |
467 | else | |
468 | return trclass; | |
469 | } | |
470 | ||
471 | //_____________________________________________________________________________ | |
472 | AliTriggerClass *AliTriggerConfiguration::AddClass( TString &name, UChar_t index, | |
473 | TString &desc, TString &clus, | |
474 | TString &pfp, TString &mask, | |
475 | UInt_t prescaler, Bool_t allrare) | |
476 | { | |
477 | // Add a new trigger class | |
478 | if (!fDescriptors.FindObject(desc)) { | |
479 | AliError("Invalid descriptor ! Impossible to add the class !"); | |
480 | return NULL; | |
481 | } | |
482 | if (!fClusters.FindObject(clus)) { | |
483 | AliError("Invalid cluster ! Impossible to add the class !"); | |
484 | return NULL; | |
485 | } | |
486 | if (!fPFProtections.FindObject(pfp)) { | |
487 | AliError("Invalid past-future protection ! Impossible to add the class !"); | |
488 | return NULL; | |
489 | } | |
490 | if (!fMasks.FindObject(mask)) { | |
491 | AliError("Invalid bunch-crossing mask ! Impossible to add the class !"); | |
492 | return NULL; | |
493 | } | |
494 | AliTriggerClass* trclass = new AliTriggerClass( this, name,index,desc,clus,pfp,mask,prescaler,allrare ); | |
495 | if (!AddClass(trclass)) { | |
496 | delete trclass; | |
497 | return NULL; | |
498 | } | |
499 | else | |
500 | return trclass; | |
501 | } | |
502 | ||
503 | //_____________________________________________________________________________ | |
43afc9d8 | 504 | Bool_t AliTriggerConfiguration::ProcessConfigurationLine(const char* line, Int_t& level) |
51f6d619 | 505 | { |
43afc9d8 | 506 | // processes one line of configuration |
51f6d619 | 507 | |
43afc9d8 | 508 | TString strLine(line); |
51f6d619 | 509 | |
43afc9d8 | 510 | if (strLine.BeginsWith("#")) return kTRUE; |
509b7052 | 511 | if (strLine.BeginsWith("PARTITION:")) { |
512 | strLine.ReplaceAll("PARTITION:",""); | |
513 | SetName(strLine.Data()); | |
514 | return kTRUE; | |
515 | } | |
516 | if (strLine.BeginsWith("VERSION:")) { | |
517 | strLine.ReplaceAll("VERSION:",""); | |
518 | fVersion = strLine.Atoi(); | |
519 | return kTRUE; | |
520 | } | |
51f6d619 | 521 | if (strLine.BeginsWith("INPUTS:")) { |
522 | level = 1; | |
43afc9d8 | 523 | return kTRUE; |
51f6d619 | 524 | } |
525 | if (strLine.BeginsWith("INTERACTIONS:")) { | |
526 | level = 2; | |
43afc9d8 | 527 | return kTRUE; |
51f6d619 | 528 | } |
529 | if (strLine.BeginsWith("DESCRIPTORS:")) { | |
530 | level = 3; | |
43afc9d8 | 531 | return kTRUE; |
51f6d619 | 532 | } |
533 | if (strLine.BeginsWith("CLUSTERS:")) { | |
534 | level = 4; | |
43afc9d8 | 535 | return kTRUE; |
51f6d619 | 536 | } |
537 | if (strLine.BeginsWith("PFS:")) { | |
538 | level = 5; | |
43afc9d8 | 539 | return kTRUE; |
51f6d619 | 540 | } |
541 | if (strLine.BeginsWith("BCMASKS:")) { | |
542 | level = 6; | |
43afc9d8 | 543 | return kTRUE; |
51f6d619 | 544 | } |
545 | if (strLine.BeginsWith("CLASSES:")) { | |
546 | level = 7; | |
43afc9d8 | 547 | return kTRUE; |
51f6d619 | 548 | } |
43afc9d8 | 549 | |
51f6d619 | 550 | strLine.ReplaceAll("*",'!'); |
31e839aa | 551 | strLine.ReplaceAll("~",'!'); |
51f6d619 | 552 | TObjArray *tokens = strLine.Tokenize(" \t"); |
553 | Int_t ntokens = tokens->GetEntriesFast(); | |
43afc9d8 | 554 | if (ntokens == 0) |
555 | { | |
556 | delete tokens; | |
557 | return kTRUE; | |
558 | } | |
51f6d619 | 559 | switch (level) { |
560 | case 1: | |
561 | // Read inputs | |
562 | if (ntokens != 5) { | |
43afc9d8 | 563 | AliError(Form("Invalid trigger input syntax (%s)!",strLine.Data())); |
564 | return kFALSE; | |
51f6d619 | 565 | } |
43afc9d8 | 566 | AddInput(((TObjString*)tokens->At(0))->String(), |
51f6d619 | 567 | ((TObjString*)tokens->At(1))->String(), |
568 | ((TObjString*)tokens->At(2))->String().Atoi(), | |
569 | ((TObjString*)tokens->At(3))->String().Atoi(), | |
570 | ((TObjString*)tokens->At(4))->String().Atoi()); | |
571 | break; | |
572 | case 2: | |
43afc9d8 | 573 | // Read interaction |
574 | if (ntokens != 2) { | |
575 | AliError(Form("Invalid trigger interaction syntax (%s)!",strLine.Data())); | |
576 | return kFALSE; | |
577 | } | |
578 | AddInteraction(((TObjString*)tokens->At(0))->String(), | |
51f6d619 | 579 | ((TObjString*)tokens->At(1))->String()); |
580 | break; | |
581 | case 3: | |
582 | // Read logical functions and descriptors | |
43afc9d8 | 583 | if (ntokens < 2) { |
e89c03c6 | 584 | if ((((TObjString*)tokens->At(0))->String().CompareTo("EMPTY") == 0) || |
583e63b8 | 585 | (((TObjString*)tokens->At(0))->String().CompareTo("DTRUE") == 0) || |
e89c03c6 | 586 | (((TObjString*)tokens->At(0))->String().CompareTo("DEMPTY") == 0)) { |
587 | AddDescriptor(((TObjString*)tokens->At(0))->String(), | |
588 | strLine.ReplaceAll(((TObjString*)tokens->At(0))->String(),"")); | |
589 | break; | |
590 | } | |
591 | else { | |
592 | AliError(Form("Invalid trigger descriptor syntax (%s)!",strLine.Data())); | |
593 | return kFALSE; | |
594 | } | |
43afc9d8 | 595 | } |
51f6d619 | 596 | if (((TObjString*)tokens->At(0))->String().BeginsWith("l0f")) { |
597 | // function | |
43afc9d8 | 598 | AddFunction(((TObjString*)tokens->At(0))->String(), |
51f6d619 | 599 | strLine.ReplaceAll(((TObjString*)tokens->At(0))->String(),"")); |
600 | } | |
601 | else { | |
43afc9d8 | 602 | AddDescriptor(((TObjString*)tokens->At(0))->String(), |
51f6d619 | 603 | strLine.ReplaceAll(((TObjString*)tokens->At(0))->String(),"")); |
604 | } | |
605 | break; | |
606 | case 4: | |
607 | { | |
43afc9d8 | 608 | if (ntokens < 2) { |
609 | AliError(Form("Invalid trigger cluster syntax (%s)!",strLine.Data())); | |
610 | return kFALSE; | |
611 | } | |
af51ca16 | 612 | if (((TObjString*)tokens->At(1))->String().Atoi() <= 0) { |
613 | AliError(Form("Invalid trigger cluster syntax (%s)!",strLine.Data())); | |
614 | return kFALSE; | |
615 | } | |
51f6d619 | 616 | TString strTemp; |
617 | for(Int_t i = 2; i < ntokens; i++) { | |
618 | strTemp += ((TObjString*)tokens->At(i))->String(); | |
619 | strTemp += " "; | |
620 | } | |
43afc9d8 | 621 | AddCluster(((TObjString*)tokens->At(0))->String(), |
51f6d619 | 622 | ((TObjString*)tokens->At(1))->String().Atoi(), |
623 | strTemp); | |
624 | } | |
625 | break; | |
626 | case 5: | |
627 | { | |
628 | AliTriggerPFProtection *pfp = NULL; | |
909d646e | 629 | if ((((TObjString*)tokens->At(0))->String().CompareTo("NONE") == 0) || |
630 | (((TObjString*)tokens->At(0))->String().CompareTo("NOPF") == 0)) { | |
51f6d619 | 631 | pfp = new AliTriggerPFProtection(((TObjString*)tokens->At(0))->String()); |
632 | } | |
633 | else { | |
b87d7e83 | 634 | if (ntokens == 10){ |
635 | pfp = new AliTriggerPFProtection(((TObjString*)tokens->At(0))->String(), | |
51f6d619 | 636 | ((TObjString*)tokens->At(1))->String(), |
637 | ((TObjString*)tokens->At(2))->String(), | |
638 | ((TObjString*)tokens->At(3))->String()); | |
b87d7e83 | 639 | pfp->SetNa1(((TObjString*)tokens->At(4))->String().Atoi()); |
640 | pfp->SetNa2(((TObjString*)tokens->At(5))->String().Atoi()); | |
641 | pfp->SetNb1(((TObjString*)tokens->At(6))->String().Atoi()); | |
642 | pfp->SetNb2(((TObjString*)tokens->At(7))->String().Atoi()); | |
643 | pfp->SetTa(((TObjString*)tokens->At(8))->String().Atoi()); | |
644 | pfp->SetTb(((TObjString*)tokens->At(9))->String().Atoi()); | |
645 | }else if(ntokens == 13){ | |
646 | UInt_t pfdef[12]; | |
647 | for(Int_t i=0;i<12;i++){ | |
648 | TString ss(((TObjString*)tokens->At(i+1))->String()); | |
649 | ss.Remove(0,2); | |
650 | UInt_t num=0; | |
651 | for(Int_t j=ss.Length()-1;j>=0;j--){ | |
652 | UInt_t nn=ss[j]; | |
417aea4a | 653 | if(nn >= (UInt_t)'0' && nn <= (UInt_t)'9')nn=nn-(UInt_t)'0'; else |
654 | if(nn >= (UInt_t)'A' && nn <= (UInt_t)'F')nn=10+nn-(UInt_t)'A'; else | |
655 | if(nn >= (UInt_t)'a' && nn <= (UInt_t)'f')nn=10+nn-(UInt_t)'a'; else{ | |
656 | AliError(Form("Invalid trigger pfs syntax (%s)!",strLine.Data())); | |
657 | //return kFALSE; | |
658 | } | |
b87d7e83 | 659 | num=num+(1<<(ss.Length()-1-j)*4)*nn; |
417aea4a | 660 | //cout << ss[j] << " 2 " << nn << " " << num << endl; |
b87d7e83 | 661 | } |
662 | pfdef[i]=num; | |
663 | } | |
664 | pfp = new AliTriggerPFProtection(((TObjString*)tokens->At(0))->String(),pfdef); | |
665 | }else{ | |
666 | AliError(Form("Invalid trigger pfs syntax (%s)!",strLine.Data())); | |
417aea4a | 667 | //return kFALSE; |
b87d7e83 | 668 | } |
51f6d619 | 669 | } |
43afc9d8 | 670 | AddPFProtection(pfp); |
51f6d619 | 671 | } |
672 | break; | |
673 | case 6: | |
43afc9d8 | 674 | if (ntokens > 2) { |
675 | AliError(Form("Invalid trigger bcmasks syntax (%s)!",strLine.Data())); | |
676 | return kFALSE; | |
677 | } | |
51f6d619 | 678 | if (((TObjString*)tokens->At(0))->String().CompareTo("NONE") == 0) |
583e63b8 | 679 | { |
680 | AddMask(new AliTriggerBCMask(((TObjString*)tokens->At(0))->String())); | |
681 | } | |
51f6d619 | 682 | else { |
43afc9d8 | 683 | AddMask(((TObjString*)tokens->At(0))->String(), |
51f6d619 | 684 | ((TObjString*)tokens->At(1))->String()); |
685 | } | |
686 | break; | |
687 | case 7: | |
688 | { | |
b98dcc47 | 689 | if ((ntokens < 8) || (ntokens >10)) { |
43afc9d8 | 690 | AliError(Form("Invalid trigger class syntax (%s)!",strLine.Data())); |
691 | return kFALSE; | |
692 | } | |
693 | AliTriggerClass *trclass = new AliTriggerClass(this, | |
51f6d619 | 694 | ((TObjString*)tokens->At(0))->String(),((TObjString*)tokens->At(1))->String().Atoi(), |
695 | ((TObjString*)tokens->At(2))->String(),((TObjString*)tokens->At(3))->String(), | |
696 | ((TObjString*)tokens->At(4))->String(),((TObjString*)tokens->At(5))->String(), | |
43afc9d8 | 697 | ((TObjString*)tokens->At(6))->String().Atoi(),(Bool_t)(((TObjString*)tokens->At(7))->String().Atoi())); |
698 | AddClass(trclass); | |
51f6d619 | 699 | } |
700 | default: | |
701 | break; | |
702 | } | |
703 | delete tokens; | |
43afc9d8 | 704 | |
705 | return kTRUE; | |
706 | } | |
707 | ||
708 | //_____________________________________________________________________________ | |
709 | AliTriggerConfiguration* AliTriggerConfiguration::LoadConfiguration(TString & configuration) | |
710 | { | |
711 | // Load one pre-created Configurations from database/file that match | |
712 | // with the input string 'configuration' | |
713 | // Ej: "Pb-Pb" or "p-p-DIMUON CALIBRATION-CENTRAL-BARREL" | |
714 | // By default the files are stored in GRP/CTP folder. | |
715 | // The filename is constructed as: GRP/CTP/<configuration>.cfg | |
716 | ||
717 | // Load the selected configuration | |
718 | TString filename; | |
719 | if (configuration.EndsWith(".cfg") || | |
720 | configuration.EndsWith(".shuttle")) { | |
721 | filename = configuration; | |
722 | } | |
723 | else { | |
724 | filename = gSystem->Getenv("ALICE_ROOT"); | |
725 | filename += "/GRP/CTP/"; | |
726 | filename += configuration; | |
727 | filename += ".cfg"; | |
728 | } | |
729 | ||
730 | if( gSystem->AccessPathName( filename.Data() ) ) { | |
731 | AliErrorClass( Form( "file (%s) not found", filename.Data() ) ); | |
732 | return NULL; | |
733 | } | |
734 | ||
735 | ||
736 | ifstream *file = new ifstream ( filename.Data() ); | |
737 | if (!*file) { | |
738 | AliErrorClass(Form("Error opening file (%s) !",filename.Data())); | |
739 | file->close(); | |
740 | delete file; | |
741 | return NULL; | |
742 | } | |
743 | ||
744 | AliTriggerConfiguration *cfg = new AliTriggerConfiguration(); | |
745 | ||
746 | Int_t level = 0; | |
747 | ||
748 | TString strLine; | |
749 | while (strLine.ReadLine(*file)) { | |
750 | if (cfg->ProcessConfigurationLine(strLine, level) == kFALSE) | |
751 | { | |
752 | delete cfg; | |
753 | cfg = 0; | |
754 | break; | |
755 | } | |
51f6d619 | 756 | } |
757 | ||
758 | file->close(); | |
759 | delete file; | |
760 | ||
761 | return cfg; | |
43afc9d8 | 762 | } |
51f6d619 | 763 | |
43afc9d8 | 764 | //_____________________________________________________________________________ |
765 | AliTriggerConfiguration* AliTriggerConfiguration::LoadConfigurationFromString(const char* configuration) | |
766 | { | |
767 | // Loads configuration given as parameter <configuration> | |
768 | ||
769 | if (!configuration) | |
770 | return 0; | |
771 | ||
772 | AliTriggerConfiguration *cfg = new AliTriggerConfiguration(); | |
773 | ||
774 | Int_t level = 0; | |
775 | ||
776 | TObjArray* tokens = TString(configuration).Tokenize("\n"); | |
777 | for (Int_t i=0; i<tokens->GetEntries(); i++) | |
778 | { | |
779 | TObjString* str = dynamic_cast<TObjString*>(tokens->At(i)); | |
780 | if (!str) | |
781 | continue; | |
782 | ||
783 | if (cfg->ProcessConfigurationLine(str->String(), level) == kFALSE) | |
784 | { | |
785 | delete cfg; | |
786 | cfg = 0; | |
787 | break; | |
788 | } | |
789 | } | |
790 | ||
791 | delete tokens; | |
792 | ||
793 | return cfg; | |
51f6d619 | 794 | } |
795 | ||
796 | //_____________________________________________________________________________ | |
797 | TObjArray* AliTriggerConfiguration::GetAvailableConfigurations( const char* filename ) | |
798 | { | |
799 | // Return an array of configuration in the file | |
800 | ||
801 | TString path; | |
802 | if( !filename[0] ) { | |
803 | path += gSystem->Getenv( "ALICE_ROOT" ); | |
804 | path += fgkConfigurationFileName; | |
805 | } | |
806 | else | |
807 | path += filename; | |
808 | ||
809 | if( gSystem->AccessPathName( path.Data() ) ) { | |
810 | AliErrorGeneral( "AliTriggerConfiguration", Form( "file (%s) not found", path.Data() ) ); | |
811 | return NULL; | |
812 | } | |
813 | ||
814 | TObjArray* desArray = new TObjArray(); | |
815 | ||
816 | TFile file( path.Data(), "READ" ); | |
817 | if( file.IsZombie() ) { | |
818 | AliErrorGeneral( "AliTriggerConfiguration", Form( "Error opening file (%s)", path.Data() ) ); | |
819 | return NULL; | |
820 | } | |
821 | ||
822 | file.ReadAll(); | |
823 | ||
824 | TKey* key; | |
825 | TIter next( file.GetListOfKeys() ); | |
826 | while( (key = (TKey*)next()) ) { | |
827 | TObject* obj = key->ReadObj(); | |
828 | if( obj->InheritsFrom( "AliTriggerConfiguration" ) ) { | |
829 | desArray->AddLast( obj ); | |
830 | } | |
831 | } | |
832 | file.Close(); | |
833 | ||
834 | return desArray; | |
835 | } | |
836 | ||
837 | //_____________________________________________________________________________ | |
838 | void AliTriggerConfiguration::WriteConfiguration( const char* filename ) | |
839 | { | |
840 | // Write the configuration | |
841 | TString path; | |
842 | if( !filename[0] ) { | |
843 | path += gSystem->Getenv("ALICE_ROOT"); | |
844 | path += fgkConfigurationFileName; | |
845 | } | |
846 | else | |
847 | path += filename; | |
848 | ||
849 | TFile file( path.Data(), "UPDATE" ); | |
850 | if( file.IsZombie() ) { | |
851 | AliErrorGeneral( "AliTriggerConfiguration", | |
852 | Form( "Can't open file (%s)", path.Data() ) ); | |
853 | return; | |
854 | } | |
855 | ||
856 | Bool_t result = (Write( GetName(), TObject::kOverwrite ) != 0); | |
857 | if( !result ) | |
858 | AliErrorGeneral( "AliTriggerConfiguration", | |
859 | Form( "Can't write entry to file <%s>!", path.Data() ) ); | |
860 | file.Close(); | |
861 | } | |
862 | ||
c3e7fba3 | 863 | //_____________________________________________________________________________ |
864 | Int_t AliTriggerConfiguration::GetClassIndexFromName(const char* className) const | |
865 | { | |
866 | //const TObjArray& classes = cfg->GetClasses(); | |
867 | Int_t nclasses = (Int_t)fClasses.GetEntriesFast(); | |
868 | for (Int_t i=0;i<nclasses;i++) { | |
869 | AliTriggerClass* trgclass = (AliTriggerClass*)fClasses.At(i); | |
870 | if (TString(trgclass->GetName()).CompareTo(className) == 0) { | |
871 | ULong64_t classmask = (ULong64_t)trgclass->GetMask(); | |
872 | return TMath::Nint(TMath::Log2(classmask))+1; | |
873 | } | |
874 | } | |
875 | return -1; | |
876 | } | |
877 | //_____________________________________________________________________________ | |
878 | const char* AliTriggerConfiguration::GetClassNameFromIndex(Int_t classIndex) const | |
879 | { | |
880 | Int_t nclasses = (Int_t)fClasses.GetEntriesFast(); | |
881 | for (Int_t i=0;i<nclasses;i++) { | |
882 | AliTriggerClass* trgclass = (AliTriggerClass*)fClasses.At(i); | |
883 | ULong64_t classmask = (ULong64_t)trgclass->GetMask(); | |
884 | if (TMath::Nint(TMath::Log2(classmask))+1 == classIndex) return trgclass->GetName(); | |
885 | } | |
886 | return 0; | |
887 | } | |
888 | //_____________________________________________________________________________ | |
889 | AliTriggerClass* AliTriggerConfiguration::GetTriggerClass(Int_t classIndex) const | |
890 | { | |
891 | Int_t nclasses = (Int_t)fClasses.GetEntriesFast(); | |
892 | for (Int_t i=0;i<nclasses;i++) { | |
893 | AliTriggerClass* trgclass = (AliTriggerClass*)fClasses.At(i); | |
894 | ULong64_t classmask = (ULong64_t)trgclass->GetMask(); | |
895 | if (TMath::Nint(TMath::Log2(classmask))+1 == classIndex) return trgclass; | |
896 | } | |
897 | return 0; | |
898 | } | |
895affe8 | 899 | //_____________________________________________________________________________ |
900 | void AliTriggerConfiguration::Reset() | |
901 | { | |
902 | for( Int_t j=0; j<fInputs.GetEntriesFast(); j++ ) | |
903 | ((AliTriggerInput*)fInputs.At(j))->Reset(); | |
904 | ||
905 | for( Int_t j=0; j<fClasses.GetEntriesFast(); j++ ) | |
906 | ((AliTriggerClass*)fClasses.At(j))->Reset(); | |
907 | } | |
51f6d619 | 908 | |
909 | //_____________________________________________________________________________ | |
910 | void AliTriggerConfiguration::Print( const Option_t* ) const | |
911 | { | |
912 | ||
913 | cout << "#################################################" << endl; | |
914 | cout << "Trigger Configuration:" << endl; | |
915 | cout << " Name: " << GetName() << endl; | |
916 | cout << " Description: " << GetTitle() << endl; | |
509b7052 | 917 | cout << " Version: " << GetVersion() << endl; |
51f6d619 | 918 | cout << " Active Detectors: " << GetActiveDetectors() << endl; |
919 | cout << " Trigger Detectors: " << GetTriggeringDetectors() << endl; | |
920 | ||
921 | cout << "#################################################" << endl; | |
922 | fInputs.Print(); | |
923 | cout << "#################################################" << endl; | |
924 | fInteractions.Print(); | |
925 | cout << "#################################################" << endl; | |
926 | fFunctions.Print(); | |
927 | cout << "#################################################" << endl; | |
928 | fDescriptors.Print(); | |
929 | cout << "#################################################" << endl; | |
930 | fClusters.Print(); | |
931 | cout << "#################################################" << endl; | |
932 | fPFProtections.Print(); | |
933 | cout << "#################################################" << endl; | |
934 | fMasks.Print(); | |
935 | cout << "#################################################" << endl; | |
936 | fClasses.Print(); | |
937 | cout << "#################################################" << endl; | |
938 | ||
939 | cout << endl; | |
940 | } | |
941 | ||
942 | ||
943 | ////////////////////////////////////////////////////////////////////////////// | |
944 | // Helper method | |
945 | ||
946 | //_____________________________________________________________________________ | |
947 | Bool_t AliTriggerConfiguration::IsSelected( TString detName, TString& detectors ) const | |
948 | { | |
949 | // check whether detName is contained in detectors | |
950 | // if yes, it is removed from detectors | |
951 | ||
952 | // check if all detectors are selected | |
953 | if( (detectors.CompareTo("ALL") == 0 ) || | |
954 | detectors.BeginsWith("ALL ") || | |
955 | detectors.EndsWith(" ALL") || | |
956 | detectors.Contains(" ALL ") ) { | |
957 | detectors = "ALL"; | |
958 | return kTRUE; | |
959 | } | |
960 | ||
961 | // search for the given detector | |
962 | Bool_t result = kFALSE; | |
963 | if( (detectors.CompareTo( detName ) == 0) || | |
964 | detectors.BeginsWith( detName+" " ) || | |
965 | detectors.EndsWith( " "+detName ) || | |
966 | detectors.Contains( " "+detName+" " ) ) { | |
967 | detectors.ReplaceAll( detName, "" ); | |
968 | result = kTRUE; | |
969 | } | |
970 | ||
971 | // clean up the detectors string | |
972 | while( detectors.Contains(" ") ) detectors.ReplaceAll( " ", " " ); | |
973 | while( detectors.BeginsWith(" ") ) detectors.Remove( 0, 1 ); | |
974 | while( detectors.EndsWith(" ") ) detectors.Remove( detectors.Length()-1, 1 ); | |
975 | ||
976 | return result; | |
977 | } |