]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliTriggerCluster.cxx
Importing the code for relative ITS-TPC alignment (Mikolaj)
[u/mrichter/AliRoot.git] / STEER / AliTriggerCluster.cxx
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 ClassImp( AliTriggerCluster )
39
40 //_____________________________________________________________________________
41 AliTriggerCluster::AliTriggerCluster(): 
42   TNamed(),
43   fClusterMask(0)
44 {
45 }
46
47 //_____________________________________________________________________________
48 AliTriggerCluster::AliTriggerCluster( TString & name, UChar_t index, TString & detectors ) :
49   TNamed(name,detectors),
50   fClusterMask((index <=6) ? 1 << (index-1) : 0)
51 {
52   TString detClus;
53   for( Int_t iDet = 0; iDet < AliDAQ::kNDetectors; iDet++ ) {
54     if( IsSelected( AliTriggerInput::fgkCTPDetectorName[iDet], fTitle )) {
55       // Add the detector
56       detClus.Append( " " );
57       detClus.Append( AliDAQ::DetectorName(iDet) );
58     }
59   }
60   SetTitle(detClus.Data());
61 }
62
63 //_____________________________________________________________________________
64 AliTriggerCluster::AliTriggerCluster( const AliTriggerCluster &clus ):
65   TNamed(clus),
66   fClusterMask(clus.fClusterMask)
67 {
68   // Copy constructor
69 }
70
71 //_____________________________________________________________________________
72 Bool_t AliTriggerCluster::IsDetectorInCluster( TString & detName )
73 {
74    // search for the given detector
75    Bool_t result = kFALSE;
76    if( (fTitle.CompareTo( detName ) == 0) ||
77         fTitle.BeginsWith( detName+" " ) ||
78         fTitle.EndsWith( " "+detName ) ||
79         fTitle.Contains( " "+detName+" " ) ) {
80       result = kTRUE;
81    }
82    return result;
83 }
84
85
86 //_____________________________________________________________________________
87 void AliTriggerCluster::Print( const Option_t* ) const
88 {
89    // Print
90    cout << "Detector Cluster:" << endl;
91    cout << "  Name:           " << GetName() << endl;
92    cout << "  Cluster index:  " << (Int_t)TMath::Log2(fClusterMask) + 1 << endl;
93    cout << "  Detectors:      " << GetDetectorsInCluster() << endl;
94 }
95
96
97 //////////////////////////////////////////////////////////////////////////////
98 // Helper method
99
100 //_____________________________________________________________________________
101 Bool_t AliTriggerCluster::IsSelected( TString detName, TString& detectors ) const
102 {
103    // check whether detName is contained in detectors
104    // if yes, it is removed from detectors
105
106    // check if all detectors are selected
107    if( (detectors.CompareTo("ALL") == 0 ) ||
108         detectors.BeginsWith("ALL ") ||
109         detectors.EndsWith(" ALL") ||
110         detectors.Contains(" ALL ") ) {
111       detectors = "ALL";
112       return kTRUE;
113    }
114
115    // search for the given detector
116    Bool_t result = kFALSE;
117    if( (detectors.CompareTo( detName ) == 0) ||
118         detectors.BeginsWith( detName+" " ) ||
119         detectors.EndsWith( " "+detName ) ||
120         detectors.Contains( " "+detName+" " ) ) {
121       detectors.ReplaceAll( detName, "" );
122       result = kTRUE;
123    }
124
125    // clean up the detectors string
126    while( detectors.Contains("  ") )  detectors.ReplaceAll( "  ", " " );
127    while( detectors.BeginsWith(" ") ) detectors.Remove( 0, 1 );
128    while( detectors.EndsWith(" ") )   detectors.Remove( detectors.Length()-1, 1 );
129
130    return result;
131 }