]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliDetectorTag.cxx
Previous commit had the bad side-effect of changing the behaviour of Raw QA to comput...
[u/mrichter/AliRoot.git] / STEER / AliDetectorTag.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 //           Implementation of the DetectorTag class
20 //   This is the class to deal with the tags in the detector level
21 //   Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
22 //-----------------------------------------------------------------
23
24 #include "TMath.h"
25
26 #include "AliDetectorTag.h"
27 #include "AliLog.h"
28 #include "TObjString.h"
29
30 ClassImp(AliDetectorTag)
31
32 //___________________________________________________________________________
33 AliDetectorTag::AliDetectorTag() :
34   TObject(),
35   fDetectorArray(new TObjArray()),
36   fMask(0),
37   fITSSPD(kFALSE),
38   fITSSDD(kFALSE),
39   fITSSSD(kFALSE),
40   fTPC(kFALSE),
41   fTRD(kFALSE),
42   fTOF(kFALSE),
43   fHMPID(kFALSE),
44   fPHOS(kFALSE),
45   fPMD(kFALSE),
46   fMUON(kFALSE),
47   fFMD(kFALSE),
48   fTZERO(kFALSE),
49   fVZERO(kFALSE),
50   fZDC(kFALSE),
51   fEMCAL(kFALSE)
52 {
53   // Default constructor
54   for(Int_t k = 0; k < 32; k++) fDetectors[k] = 0;
55 }
56
57 //___________________________________________________________________________
58 AliDetectorTag::AliDetectorTag(const AliDetectorTag & detTag) :
59   TObject(detTag),
60   fDetectorArray(detTag.fDetectorArray),
61   fMask(detTag.fMask),
62   fITSSPD(detTag.fITSSPD),
63   fITSSDD(detTag.fITSSDD),
64   fITSSSD(detTag.fITSSSD),
65   fTPC(detTag.fTPC),
66   fTRD(detTag.fTRD),
67   fTOF(detTag.fTOF),
68   fHMPID(detTag.fHMPID),
69   fPHOS(detTag.fPHOS),
70   fPMD(detTag.fPMD),
71   fMUON(detTag.fMUON),
72   fFMD(detTag.fFMD),
73   fTZERO(detTag.fTZERO),
74   fVZERO(detTag.fVZERO),
75   fZDC(detTag.fZDC),
76   fEMCAL(detTag.fEMCAL)
77  {
78   // DetectorTag copy constructor
79   for(Int_t k = 0; k < 32; k++) fDetectors[k] = detTag.fDetectors[k];
80 }
81
82 //___________________________________________________________________________
83 AliDetectorTag & AliDetectorTag::operator=(const AliDetectorTag &detTag) {
84   //DetectorTag assignment operator
85   if (this != &detTag) {
86     TObject::operator=(detTag);
87     
88     fDetectorArray = detTag.fDetectorArray;
89     fMask = detTag.fMask;   
90     fITSSPD = detTag.fITSSPD;
91     fITSSDD = detTag.fITSSDD;
92     fITSSSD = detTag.fITSSSD;
93     fTPC = detTag.fTPC;
94     fTRD = detTag.fTRD;
95     fTOF = detTag.fTOF;
96     fHMPID = detTag.fHMPID;
97     fPHOS = detTag.fPHOS;
98     fPMD = detTag.fPMD;
99     fMUON = detTag.fMUON;
100     fFMD = detTag.fFMD;
101     fTZERO = detTag.fTZERO;
102     fVZERO = detTag.fVZERO;
103     fZDC = detTag.fZDC;
104     fEMCAL = detTag.fEMCAL;
105     for(Int_t k = 0; k < 32; k++) fDetectors[k] = detTag.fDetectors[k];
106   }
107   return *this;
108 }
109
110 //___________________________________________________________________________
111 AliDetectorTag::~AliDetectorTag() {
112   // Destructor
113   delete fDetectorArray;
114 }
115
116 //___________________________________________________________________________
117 void AliDetectorTag::Int2Bin() {
118   // Convert the integer into binary
119   Int_t j=0; 
120   UInt_t mask = fMask;
121   for(Int_t k = 0; k < 32; k++) fDetectors[k] = 0;
122   while(mask > 0) {
123    fDetectors[j] = mask%2;
124    mask = mask/2;
125    j++; 
126   }
127   SetDetectorConfiguration();
128 }
129
130 //___________________________________________________________________________
131 UInt_t AliDetectorTag::GetIntDetectorMask() {
132   // Returns the detector mask UInt_t
133   UInt_t mask = 0;
134   for(Int_t k = 0; k < 32; k++) 
135     if(fDetectors[k] == 1) mask += (UInt_t)TMath::Power(2,k);
136   
137   return mask;
138 }
139
140 //___________________________________________________________________________
141 void AliDetectorTag::SetDetectorConfiguration() {
142   //sets the detector configuration
143   if(fDetectors[0] == 1) {
144     SetITSSPD(); fDetectorArray->Add(new TObjString("SPD"));}
145   if(fDetectors[1] == 1) {
146     SetITSSDD(); fDetectorArray->Add(new TObjString("SDD"));}
147   if(fDetectors[2] == 1) {
148     SetITSSSD(); fDetectorArray->Add(new TObjString("SSD"));}
149   if(fDetectors[3] == 1) {
150     SetTPC(); fDetectorArray->Add(new TObjString("TPC"));}
151   if(fDetectors[4] == 1) {
152     SetTRD(); fDetectorArray->Add(new TObjString("TRD"));}
153   if(fDetectors[5] == 1) {
154     SetTOF(); fDetectorArray->Add(new TObjString("TOF"));}
155   if(fDetectors[6] == 1) {
156     SetHMPID();fDetectorArray->Add(new TObjString("HMPID"));}
157   if(fDetectors[7] == 1) {
158     SetPHOS(); fDetectorArray->Add(new TObjString("PHOS"));}
159   if(fDetectors[9] == 1) {
160     SetPMD(); fDetectorArray->Add(new TObjString("PMD"));}
161   if(fDetectors[10] == 1) {
162     SetMUON(); fDetectorArray->Add(new TObjString("MUON"));}
163   if(fDetectors[12] == 1) {
164     SetFMD(); fDetectorArray->Add(new TObjString("FMD"));}
165   if(fDetectors[13] == 1) {
166     SetTZERO(); fDetectorArray->Add(new TObjString("T0"));}
167   if(fDetectors[14] == 1) {
168     SetVZERO(); fDetectorArray->Add(new TObjString("VZERO"));}
169   if(fDetectors[15] == 1) {
170     SetZDC(); fDetectorArray->Add(new TObjString("ZDC"));}
171   if(fDetectors[18] == 1) {
172     SetEMCAL(); fDetectorArray->Add(new TObjString("EMCAL"));}
173 }
174
175 //___________________________________________________________________________
176 void AliDetectorTag::PrintDetectorMask() {
177   //prints the detector mask
178   AliInfo( Form( "ITS-SPD: %d", GetITSSPD()) );
179   AliInfo( Form( "ITS-SDD: %d", GetITSSDD()) );
180   AliInfo( Form( "ITS-SSD: %d", GetITSSSD()) );
181   AliInfo( Form( "TPC: %d", GetTPC()) );
182   AliInfo( Form( "TRD: %d", GetTRD()) );
183   AliInfo( Form( "TOF: %d", GetTOF()) );
184   AliInfo( Form( "HMPID: %d", GetHMPID()) );
185   AliInfo( Form( "PHOS: %d", GetPHOS()) );
186   AliInfo( Form( "PMD: %d", GetPMD()) );
187   AliInfo( Form( "MUON: %d", GetMUON()) );
188   AliInfo( Form( "FMD: %d", GetFMD()) );
189   AliInfo( Form( "TZERO: %d", GetTZERO()) );
190   AliInfo( Form( "VZERO: %d", GetVZERO()) );
191   AliInfo( Form( "ZDC: %d", GetZDC()) );
192   AliInfo( Form( "EMCAL: %d", GetEMCAL()) );
193 }