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