]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - STEER/AliDetectorTag.cxx
Do not reset a zero pointer to MC info
[u/mrichter/AliRoot.git] / STEER / AliDetectorTag.cxx
... / ...
CommitLineData
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
30ClassImp(AliDetectorTag)
31
32//___________________________________________________________________________
33AliDetectorTag::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//___________________________________________________________________________
58AliDetectorTag::AliDetectorTag(const AliDetectorTag & detTag) :
59 TObject(detTag),
60 fDetectorArray(new TObjArray(*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//___________________________________________________________________________
83AliDetectorTag & AliDetectorTag::operator=(const AliDetectorTag &detTag) {
84 //DetectorTag assignment operator
85 if (this != &detTag) {
86 TObject::operator=(detTag);
87
88 fDetectorArray = new TObjArray(*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//___________________________________________________________________________
111AliDetectorTag::~AliDetectorTag() {
112 // Destructor
113 if (fDetectorArray)
114 delete fDetectorArray;
115}
116
117//___________________________________________________________________________
118void AliDetectorTag::Int2Bin() {
119 // Convert the integer into binary
120 Int_t j=0;
121 UInt_t mask = fMask;
122 for(Int_t k = 0; k < 32; k++) fDetectors[k] = 0;
123 while(mask > 0) {
124 fDetectors[j] = mask%2;
125 mask = mask/2;
126 j++;
127 }
128 SetDetectorConfiguration();
129}
130
131//___________________________________________________________________________
132UInt_t AliDetectorTag::GetIntDetectorMask() {
133 // Returns the detector mask UInt_t
134 UInt_t mask = 0;
135 for(Int_t k = 0; k < 32; k++)
136 if(fDetectors[k] == 1) mask += (UInt_t)TMath::Power(2,k);
137
138 return mask;
139}
140
141//___________________________________________________________________________
142void AliDetectorTag::SetDetectorConfiguration() {
143 //sets the detector configuration
144 if(fDetectors[0] == 1) {
145 SetITSSPD(); fDetectorArray->Add(new TObjString("SPD"));}
146 if(fDetectors[1] == 1) {
147 SetITSSDD(); fDetectorArray->Add(new TObjString("SDD"));}
148 if(fDetectors[2] == 1) {
149 SetITSSSD(); fDetectorArray->Add(new TObjString("SSD"));}
150 if(fDetectors[3] == 1) {
151 SetTPC(); fDetectorArray->Add(new TObjString("TPC"));}
152 if(fDetectors[4] == 1) {
153 SetTRD(); fDetectorArray->Add(new TObjString("TRD"));}
154 if(fDetectors[5] == 1) {
155 SetTOF(); fDetectorArray->Add(new TObjString("TOF"));}
156 if(fDetectors[6] == 1) {
157 SetHMPID();fDetectorArray->Add(new TObjString("HMPID"));}
158 if(fDetectors[7] == 1) {
159 SetPHOS(); fDetectorArray->Add(new TObjString("PHOS"));}
160 if(fDetectors[9] == 1) {
161 SetPMD(); fDetectorArray->Add(new TObjString("PMD"));}
162 if(fDetectors[10] == 1) {
163 SetMUON(); fDetectorArray->Add(new TObjString("MUON"));}
164 if(fDetectors[12] == 1) {
165 SetFMD(); fDetectorArray->Add(new TObjString("FMD"));}
166 if(fDetectors[13] == 1) {
167 SetTZERO(); fDetectorArray->Add(new TObjString("T0"));}
168 if(fDetectors[14] == 1) {
169 SetVZERO(); fDetectorArray->Add(new TObjString("VZERO"));}
170 if(fDetectors[15] == 1) {
171 SetZDC(); fDetectorArray->Add(new TObjString("ZDC"));}
172 if(fDetectors[18] == 1) {
173 SetEMCAL(); fDetectorArray->Add(new TObjString("EMCAL"));}
174}
175
176//___________________________________________________________________________
177void AliDetectorTag::PrintDetectorMask() {
178 //prints the detector mask
179 AliInfo( Form( "ITS-SPD: %d", GetITSSPD()) );
180 AliInfo( Form( "ITS-SDD: %d", GetITSSDD()) );
181 AliInfo( Form( "ITS-SSD: %d", GetITSSSD()) );
182 AliInfo( Form( "TPC: %d", GetTPC()) );
183 AliInfo( Form( "TRD: %d", GetTRD()) );
184 AliInfo( Form( "TOF: %d", GetTOF()) );
185 AliInfo( Form( "HMPID: %d", GetHMPID()) );
186 AliInfo( Form( "PHOS: %d", GetPHOS()) );
187 AliInfo( Form( "PMD: %d", GetPMD()) );
188 AliInfo( Form( "MUON: %d", GetMUON()) );
189 AliInfo( Form( "FMD: %d", GetFMD()) );
190 AliInfo( Form( "TZERO: %d", GetTZERO()) );
191 AliInfo( Form( "VZERO: %d", GetVZERO()) );
192 AliInfo( Form( "ZDC: %d", GetZDC()) );
193 AliInfo( Form( "EMCAL: %d", GetEMCAL()) );
194}