]>
Commit | Line | Data |
---|---|---|
2c780493 | 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 | /// \class AliMUONPadStatusMapMaker | |
18 | /// | |
19 | /// Convert a pad status container into a pad status *map* container | |
20 | /// | |
21 | /// A pad status is one 32-bits word describing whether this pad pedestal, gains | |
22 | /// hv is correct or not. | |
23 | /// | |
24 | /// A pad status *map* is one 32-bits (of which 24 only are used) | |
25 | /// word describing whether this pad neighbours are ok or not | |
26 | /// (whether a pad is ok or not is determined by applying a given | |
27 | /// bitmask to the pad status word). Each bit in this word is related to one | |
28 | /// neighbour, assuming the pad itself is at bit 0 | |
29 | /// | |
30 | /// ---------------- | |
31 | /// | 3 | 5 | 8 | | |
32 | /// ---------------- | |
33 | /// | 2 | 0 | 7 | | |
34 | /// ---------------- | |
35 | /// | 1 | 4 | 6 | | |
36 | /// ---------------- | |
37 | /// | |
38 | /// Note that for instance in NonBending plane of slats, at the boundaries | |
39 | /// between two pad densities, the pictures is a bit different, e.g. | |
40 | /// (bits in () are always zero) | |
41 | /// | |
42 | /// so some care must be taken when designing a mask to be tested ;-) if you | |
43 | /// want to go farther than immediate neighbours... | |
44 | /// | |
45 | /// If a pad is at a physical boundary, is will for sure have some bits at 1 | |
46 | /// (i.e. a non-existing neighbour is considered = bad). | |
47 | /// | |
78649106 | 48 | /// \author Laurent Aphecetche |
2c780493 | 49 | |
50 | #include "AliMUONPadStatusMapMaker.h" | |
51 | ||
52 | #include "AliLog.h" | |
4f8ed2e4 | 53 | #include "AliMUON2DMap.h" |
5eeebd4b | 54 | #include "AliMUONCalibParamNI.h" |
55 | #include "AliMUONCalibrationData.h" | |
8d8e920c | 56 | #include "AliMUONVStore.h" |
2c780493 | 57 | #include "AliMUONVCalibParam.h" |
8d8e920c | 58 | #include "AliMpConstants.h" |
5eeebd4b | 59 | #include "AliMpIntPair.h" |
8d8e920c | 60 | #include "AliMpManuList.h" |
4f8ed2e4 | 61 | #include <Riostream.h> |
8d8e920c | 62 | #include <TList.h> |
4f8ed2e4 | 63 | #include <TStopwatch.h> |
2c780493 | 64 | |
78649106 | 65 | /// \cond CLASSIMP |
2c780493 | 66 | ClassImp(AliMUONPadStatusMapMaker) |
78649106 | 67 | /// \endcond |
2c780493 | 68 | |
69 | Int_t AliMUONPadStatusMapMaker::fgkSelfDead = 1; | |
70 | ||
2c780493 | 71 | //_____________________________________________________________________________ |
5eeebd4b | 72 | AliMUONPadStatusMapMaker::AliMUONPadStatusMapMaker(const AliMUONCalibrationData& calibData) |
2c780493 | 73 | : TObject(), |
74 | fStatus(0x0), | |
75 | fMask(0), | |
5eeebd4b | 76 | fCalibrationData(calibData) |
2c780493 | 77 | { |
78 | /// ctor | |
79 | } | |
80 | ||
81 | //_____________________________________________________________________________ | |
82 | AliMUONPadStatusMapMaker::~AliMUONPadStatusMapMaker() | |
83 | { | |
84 | /// dtor | |
2c780493 | 85 | } |
86 | ||
87 | //_____________________________________________________________________________ | |
88 | Int_t | |
5eeebd4b | 89 | AliMUONPadStatusMapMaker::ComputeStatusMap(const AliMUONVCalibParam& neighbours, |
90 | Int_t manuChannel, | |
91 | Int_t detElemId) const | |
2c780493 | 92 | { |
93 | /// Given a list of neighbours of one pad (which includes the pad itself) | |
94 | /// compute the status map (aka deadmap) for that pad. | |
95 | ||
2c780493 | 96 | Int_t statusMap(0); |
5eeebd4b | 97 | |
98 | //Compute the statusmap related to the status of neighbouring | |
99 | //pads. An invalid pad means "outside of edges". | |
100 | ||
101 | Int_t n = neighbours.Dimension(); | |
102 | for ( Int_t i = 0; i < n; ++i ) | |
2c780493 | 103 | { |
5eeebd4b | 104 | Int_t x = neighbours.ValueAsInt(manuChannel,i); |
105 | Int_t m,c; | |
106 | neighbours.UnpackValue(x,m,c); | |
107 | if ( c < 0 ) continue; | |
2c780493 | 108 | Int_t status = 0; |
5eeebd4b | 109 | if ( !m ) |
2c780493 | 110 | { |
111 | status = -1; | |
112 | } | |
113 | else | |
114 | { | |
5eeebd4b | 115 | status = GetPadStatus(detElemId,m,c); |
2c780493 | 116 | } |
117 | if ( ( fMask==0 && status !=0 ) || ( (status & fMask) != 0 ) ) | |
118 | { | |
119 | statusMap |= (1<<i); | |
120 | } | |
2c780493 | 121 | } |
2c780493 | 122 | return statusMap; |
123 | } | |
124 | ||
125 | //_____________________________________________________________________________ | |
126 | Int_t | |
5eeebd4b | 127 | AliMUONPadStatusMapMaker::GetPadStatus(Int_t detElemId, |
128 | Int_t manuId, Int_t manuChannel) const | |
129 | ||
2c780493 | 130 | { |
131 | /// Get the pad status | |
8d8e920c | 132 | AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId)); |
2c780493 | 133 | return param->ValueAsInt(manuChannel); |
134 | } | |
135 | ||
2c780493 | 136 | //_____________________________________________________________________________ |
8d8e920c | 137 | AliMUONVStore* |
4f8ed2e4 | 138 | AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap() |
139 | { | |
9f37150e | 140 | /// Make an empty (but complete) statusMap |
8d8e920c | 141 | |
142 | AliMUONVStore* store = new AliMUON2DMap(true); | |
143 | ||
144 | TList* list = AliMpManuList::ManuList(); | |
145 | ||
146 | AliMpIntPair* pair; | |
147 | ||
148 | TIter next(list); | |
149 | ||
150 | while ( ( pair = static_cast<AliMpIntPair*>(next()) ) ) | |
151 | { | |
152 | Int_t detElemId = pair->GetFirst(); | |
153 | Int_t manuId = pair->GetSecond(); | |
154 | AliMUONVCalibParam* param = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(), | |
155 | detElemId,manuId, | |
156 | 0); | |
157 | store->Add(param); | |
158 | } | |
159 | ||
160 | delete list; | |
161 | ||
162 | return store; | |
4f8ed2e4 | 163 | } |
164 | ||
165 | //_____________________________________________________________________________ | |
8d8e920c | 166 | AliMUONVStore* |
167 | AliMUONPadStatusMapMaker::MakePadStatusMap(const AliMUONVStore& status, | |
2c780493 | 168 | Int_t mask) |
169 | { | |
170 | /// Given the status store for all pads, compute a status map store | |
171 | /// for all pads. | |
78649106 | 172 | /// \param status |
173 | /// \param mask is the status mask to be tested to tell if a pad is ok or not | |
2c780493 | 174 | |
175 | fStatus = &status; | |
176 | fMask = mask; | |
177 | ||
5eeebd4b | 178 | TStopwatch timer; |
2c780493 | 179 | timer.Start(kTRUE); |
180 | ||
8d8e920c | 181 | AliMUONVStore* neighbourStore = fCalibrationData.Neighbours(); |
5eeebd4b | 182 | |
8d8e920c | 183 | AliMUONVStore* statusMap = status.Create(); |
2c780493 | 184 | |
8d8e920c | 185 | TIter next(status.CreateIterator()); |
186 | AliMUONVCalibParam* statusEntry; | |
2c780493 | 187 | |
8d8e920c | 188 | while ( ( statusEntry = static_cast<AliMUONVCalibParam*>(next()) ) ) |
2c780493 | 189 | { |
8d8e920c | 190 | Int_t detElemId = statusEntry->ID0(); |
191 | Int_t manuId = statusEntry->ID1(); | |
5eeebd4b | 192 | |
2c780493 | 193 | AliMUONVCalibParam* statusMapEntry = static_cast<AliMUONVCalibParam*> |
8d8e920c | 194 | (statusMap->FindObject(detElemId,manuId)); |
2c780493 | 195 | |
196 | if (!statusMapEntry) | |
197 | { | |
8d8e920c | 198 | statusMapEntry = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(), |
199 | detElemId,manuId,0); | |
200 | statusMap->Add(statusMapEntry); | |
2c780493 | 201 | } |
202 | ||
5eeebd4b | 203 | AliMUONVCalibParam* neighbours = static_cast<AliMUONVCalibParam*> |
8d8e920c | 204 | (neighbourStore->FindObject(detElemId,manuId)); |
5eeebd4b | 205 | |
206 | if (!neighbours) | |
207 | { | |
208 | AliFatal(Form("Could not find neighbours for DE %d manuId %d", | |
209 | detElemId,manuId)); | |
210 | continue; | |
211 | } | |
212 | ||
2c780493 | 213 | for ( Int_t manuChannel = 0; manuChannel < statusEntry->Size(); ++manuChannel ) |
214 | { | |
215 | // Loop over channels and for each channel loop on its immediate neighbours | |
216 | // to produce a statusMap word for this channel. | |
217 | ||
2c780493 | 218 | Int_t statusMapValue(0); |
5eeebd4b | 219 | |
220 | Int_t x = neighbours->ValueAsInt(manuChannel,0); | |
2c780493 | 221 | |
5eeebd4b | 222 | if ( x > 0 ) |
8d8e920c | 223 | { |
224 | // channel is a valid one (i.e. (manuId,manuChannel) is an existing pad) | |
5eeebd4b | 225 | statusMapValue = ComputeStatusMap(*neighbours,manuChannel,detElemId); |
2c780493 | 226 | } |
227 | else | |
228 | { | |
229 | statusMapValue = fgkSelfDead; | |
230 | } | |
5eeebd4b | 231 | |
2c780493 | 232 | statusMapEntry->SetValueAsInt(manuChannel,0,statusMapValue); |
233 | } | |
2c780493 | 234 | } |
5eeebd4b | 235 | timer.Stop(); |
2c780493 | 236 | |
5eeebd4b | 237 | StdoutToAliInfo( |
238 | cout << "MakePadStatusMap total timer : "; | |
239 | timer.Print(); | |
240 | cout << endl; | |
241 | ); | |
242 | ||
2c780493 | 243 | return statusMap; |
244 | } | |
245 |