Completely Updated (Mario Sitta)
[u/mrichter/AliRoot.git] / STEER / AliTriggerBCMask.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 ///////////////////////////////////////////////////////////////////////////////
17 //
18 // This class which defines the trigger bunch-crossing mask
19 //
20 //
21 ///////////////////////////////////////////////////////////////////////////////
22 #include <Riostream.h>
23
24 #include "AliTriggerBCMask.h"
25
26 ClassImp(AliTriggerBCMask)
27
28 //_____________________________________________________________________________
29 AliTriggerBCMask::AliTriggerBCMask():
30   TNamed()
31 {
32   // Default constructor
33   for (Int_t i = 0; i < kNBytesPerBCMask; i++) fBCMask[i] = 0;
34 }
35
36 //_____________________________________________________________________________
37 AliTriggerBCMask::AliTriggerBCMask( TString & name ):
38   TNamed( name, name )
39 {
40   // Constructor
41   for (Int_t i = 0; i < kNBytesPerBCMask; i++) fBCMask[i] = 255;
42 }
43
44 //_____________________________________________________________________________
45 AliTriggerBCMask::AliTriggerBCMask( TString & name, TString & mask ):
46   TNamed( name, mask )
47 {
48   // Constructor
49   CreateMask(mask);
50 }
51 //_____________________________________________________________________________
52 AliTriggerBCMask::~AliTriggerBCMask() 
53
54   // Destructor
55 }
56 //_____________________________________________________________________________
57 AliTriggerBCMask::AliTriggerBCMask( const AliTriggerBCMask& mask ):
58   TNamed( mask )
59 {
60    // Copy constructor
61   for (Int_t i = 0; i < kNBytesPerBCMask; i++) fBCMask[i] = mask.fBCMask[i];
62 }
63
64 //______________________________________________________________________________
65 AliTriggerBCMask& AliTriggerBCMask::operator=(const AliTriggerBCMask& mask)
66 {
67    // AliTriggerBCMask assignment operator.
68
69    if (this != &mask) {
70       TNamed::operator=(mask);
71       for (Int_t i = 0; i < kNBytesPerBCMask; i++) fBCMask[i] = mask.fBCMask[i];
72    }
73    return *this;
74 }
75
76 //_____________________________________________________________________________
77 Bool_t AliTriggerBCMask::GetMask( UShort_t index) const
78 {
79   // Return true or false whenever the mask is active
80   // for the bunch-crossing # = index
81   UShort_t position = index/8;
82   if (position >= kNBytesPerBCMask) return kFALSE;
83   UChar_t offset = index%8;
84   return (fBCMask[position] & (0x1 << offset));
85 }
86
87 //_____________________________________________________________________________
88 void AliTriggerBCMask::Print( const Option_t* ) const
89 {
90    // Print
91   cout << "Trigger bunch-crossing mask:" << endl;
92   cout << "  Name:                      " << GetName() << endl;
93   cout << "  Mask:                      " << GetTitle() << endl;
94 }