Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 2007, 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 : // PHOS Cpv bad channels map. //
21 : // //
22 : ///////////////////////////////////////////////////////////////////////////////
23 :
24 : #include "AliPHOSCpvBadChannelsMap.h"
25 : #include "AliPHOSGeometry.h"
26 :
27 22 : ClassImp(AliPHOSCpvBadChannelsMap)
28 :
29 : //________________________________________________________________
30 :
31 6 : AliPHOSCpvBadChannelsMap::AliPHOSCpvBadChannelsMap() : fBads(-1)
32 15 : {
33 3 : Reset();
34 6 : }
35 :
36 : //________________________________________________________________
37 :
38 : void AliPHOSCpvBadChannelsMap::Reset()
39 : {
40 : //Set all channels as good.
41 :
42 39 : for(Int_t module=0; module<AliPHOSCpvParam::kNDDL; module++)
43 3870 : for(Int_t column=0; column<AliPHOSCpvParam::kPadPcX; column++)
44 234240 : for(Int_t row=0; row<AliPHOSCpvParam::kPadPcY; row++)
45 115200 : fBadChannelCpv[module][column][row] = kFALSE;
46 :
47 3 : fBads=0;
48 :
49 3 : }
50 :
51 : //________________________________________________________________
52 :
53 : void AliPHOSCpvBadChannelsMap::Reset(Int_t module)
54 : {
55 : //Set all channels in module as good.
56 : Int_t nBadsInModule=0;
57 0 : for(Int_t column=0; column<AliPHOSCpvParam::kPadPcX; column++)
58 0 : for(Int_t row=0; row<AliPHOSCpvParam::kPadPcY; row++)
59 0 : if(fBadChannelCpv[module][column][row]){
60 0 : fBadChannelCpv[module][column][row] = kFALSE;
61 0 : nBadsInModule++;
62 0 : }
63 0 : fBads-=nBadsInModule;
64 :
65 0 : }
66 :
67 : //________________________________________________________________
68 :
69 : AliPHOSCpvBadChannelsMap::AliPHOSCpvBadChannelsMap(const AliPHOSCpvBadChannelsMap &map):
70 0 : TObject(map),fBads(map.fBads)
71 0 : {
72 : //Copy constructor.
73 0 : for(Int_t module=0; module<AliPHOSCpvParam::kNDDL; module++)
74 0 : for(Int_t column=0; column<AliPHOSCpvParam::kPadPcX; column++)
75 0 : for(Int_t row=0; row<AliPHOSCpvParam::kPadPcY; row++)
76 0 : fBadChannelCpv[module][column][row] = map.fBadChannelCpv[module][column][row];
77 :
78 0 : }
79 :
80 : //________________________________________________________________
81 :
82 : AliPHOSCpvBadChannelsMap& AliPHOSCpvBadChannelsMap::operator= (const AliPHOSCpvBadChannelsMap &map)
83 : {
84 : //Assignment operator.
85 :
86 0 : if(this != &map) {
87 0 : fBads = map.fBads;
88 0 : for(Int_t module=0; module<AliPHOSCpvParam::kNDDL; module++)
89 0 : for(Int_t column=0; column<AliPHOSCpvParam::kPadPcX; column++)
90 0 : for(Int_t row=0; row<AliPHOSCpvParam::kPadPcY; row++)
91 0 : fBadChannelCpv[module][column][row] = map.fBadChannelCpv[module][column][row];
92 0 : }
93 :
94 0 : return *this;
95 : }
96 :
97 : //_________________________________________________________________
98 :
99 : void AliPHOSCpvBadChannelsMap::SetBadChannel(Int_t module, Int_t col, Int_t row)
100 : {
101 : // Declare a channel (module,col,row) as a bad, if it was not set before
102 :
103 0 : if (!fBadChannelCpv[module-1][col-1][row-1]) {
104 0 : fBadChannelCpv[module-1][col-1][row-1] = kTRUE;
105 0 : ++fBads;
106 0 : }
107 0 : }
108 : //_________________________________________________________________
109 :
110 : void AliPHOSCpvBadChannelsMap::BadChannelIds(Int_t *badIds)
111 : {
112 : //Fill array badIds by the Ids of bad channels.
113 : //Array badIds of length GetNumOfBadChannels() should be prepared in advance.
114 :
115 0 : if(!badIds) return;
116 0 : if(fBads <=0 ) return;
117 :
118 0 : AliPHOSGeometry* geom = AliPHOSGeometry::GetInstance();
119 :
120 0 : if(!geom)
121 0 : geom = AliPHOSGeometry::GetInstance("IHEP");
122 :
123 0 : Int_t absId;
124 0 : Int_t relId[4];
125 :
126 : Int_t iBad = 0;
127 0 : relId[1] = -1; // CPV pad
128 :
129 0 : for(Int_t mod=1; mod<=AliPHOSCpvParam::kNDDL; mod++) {
130 0 : for(Int_t col=1; col<=AliPHOSCpvParam::kPadPcX; col++) {
131 0 : for(Int_t row=1; row<=AliPHOSCpvParam::kPadPcY; row++) {
132 0 : if(IsBadChannel(mod,col,row)) {
133 0 : relId[0] = mod;
134 0 : relId[2] = col;
135 0 : relId[3] = row;
136 0 : geom->RelToAbsNumbering(relId,absId);
137 0 : badIds[iBad]=absId;
138 0 : iBad++;
139 0 : }
140 : }
141 : }
142 : }
143 :
144 0 : }
|