Line data Source code
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 : // Class to define a Trigger Cluster
21 : //
22 : // A Trigger Cluster is a group of detector to be trigger together
23 : //
24 : ///////////////////////////////////////////////////////////////////////////////
25 :
26 : #include <Riostream.h>
27 :
28 : #include <TObject.h>
29 : #include <TClass.h>
30 : #include <TString.h>
31 : #include <TMath.h>
32 :
33 : #include "AliLog.h"
34 : #include "AliDAQ.h"
35 : #include "AliTriggerCluster.h"
36 : #include "AliTriggerInput.h"
37 :
38 : using std::endl;
39 : using std::cout;
40 172 : ClassImp( AliTriggerCluster )
41 :
42 : //_____________________________________________________________________________
43 : AliTriggerCluster::AliTriggerCluster():
44 10 : TNamed(),
45 10 : fClusterMask(0)
46 50 : {
47 20 : }
48 :
49 : //_____________________________________________________________________________
50 : AliTriggerCluster::AliTriggerCluster( TString & name, UChar_t index, TString & detectors ) :
51 2 : TNamed(name,detectors),
52 6 : fClusterMask((index <=6) ? 1 << (index-1) : 0)
53 10 : {
54 2 : TString detClus;
55 104 : for( Int_t iDet = 0; iDet < AliDAQ::kNDetectors; iDet++ ) {
56 150 : if( IsSelected( AliTriggerInput::fgkCTPDetectorName[iDet], fTitle )) {
57 : // Add the detector
58 26 : detClus.Append( " " );
59 52 : detClus.Append( AliDAQ::DetectorName(iDet) );
60 : }
61 : }
62 4 : SetTitle(detClus.Data());
63 4 : }
64 :
65 : //_____________________________________________________________________________
66 : AliTriggerCluster::AliTriggerCluster( const AliTriggerCluster &clus ):
67 0 : TNamed(clus),
68 0 : fClusterMask(clus.fClusterMask)
69 0 : {
70 : // Copy constructor
71 0 : }
72 :
73 : //_____________________________________________________________________________
74 : Bool_t AliTriggerCluster::IsDetectorInCluster( TString & detName )
75 : {
76 : // search for the given detector
77 : Bool_t result = kFALSE;
78 0 : if( (fTitle.CompareTo( detName ) == 0) ||
79 0 : fTitle.BeginsWith( detName+" " ) ||
80 0 : fTitle.EndsWith( " "+detName ) ||
81 0 : fTitle.Contains( " "+detName+" " ) ) {
82 : result = kTRUE;
83 0 : }
84 0 : return result;
85 0 : }
86 :
87 :
88 : //_____________________________________________________________________________
89 : void AliTriggerCluster::Print( const Option_t* ) const
90 : {
91 : // Print
92 0 : cout << "Detector Cluster:" << endl;
93 0 : cout << " Name: " << GetName() << endl;
94 0 : cout << " Cluster index: " << (Int_t)TMath::Log2(fClusterMask) + 1 << endl;
95 0 : cout << " Detectors: " << GetDetectorsInCluster() << endl;
96 0 : }
97 :
98 :
99 : //////////////////////////////////////////////////////////////////////////////
100 : // Helper method
101 :
102 : //_____________________________________________________________________________
103 : Bool_t AliTriggerCluster::IsSelected( TString detName, TString& detectors ) const
104 : {
105 : // check whether detName is contained in detectors
106 : // if yes, it is removed from detectors
107 :
108 : // check if all detectors are selected
109 150 : if( (detectors.CompareTo("ALL") == 0 ) ||
110 50 : detectors.BeginsWith("ALL ") ||
111 50 : detectors.EndsWith(" ALL") ||
112 50 : detectors.Contains(" ALL ") ) {
113 0 : detectors = "ALL";
114 0 : return kTRUE;
115 : }
116 :
117 : // search for the given detector
118 : Bool_t result = kFALSE;
119 441 : if( (detectors.CompareTo( detName ) == 0) ||
120 96 : detectors.BeginsWith( detName+" " ) ||
121 124 : detectors.EndsWith( " "+detName ) ||
122 93 : detectors.Contains( " "+detName+" " ) ) {
123 26 : detectors.ReplaceAll( detName, "" );
124 : result = kTRUE;
125 26 : }
126 :
127 : // clean up the detectors string
128 64 : while( detectors.Contains(" ") ) detectors.ReplaceAll( " ", " " );
129 84 : while( detectors.BeginsWith(" ") ) detectors.Remove( 0, 1 );
130 54 : while( detectors.EndsWith(" ") ) detectors.Remove( detectors.Length()-1, 1 );
131 :
132 50 : return result;
133 50 : }
|