]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONPadStatusMapMaker.cxx
commented logging message
[u/mrichter/AliRoot.git] / MUON / AliMUONPadStatusMapMaker.cxx
CommitLineData
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"
2c780493 56#include "AliMUONObjectPair.h"
57#include "AliMUONV2DStore.h"
58#include "AliMUONVCalibParam.h"
59#include "AliMUONVDataIterator.h"
5eeebd4b 60#include "AliMpIntPair.h"
4f8ed2e4 61#include <Riostream.h>
4f8ed2e4 62#include <TStopwatch.h>
2c780493 63
78649106 64/// \cond CLASSIMP
2c780493 65ClassImp(AliMUONPadStatusMapMaker)
78649106 66/// \endcond
2c780493 67
68Int_t AliMUONPadStatusMapMaker::fgkSelfDead = 1;
69
2c780493 70//_____________________________________________________________________________
5eeebd4b 71AliMUONPadStatusMapMaker::AliMUONPadStatusMapMaker(const AliMUONCalibrationData& calibData)
2c780493 72: TObject(),
73fStatus(0x0),
74fMask(0),
5eeebd4b 75fCalibrationData(calibData)
2c780493 76{
77 /// ctor
78}
79
80//_____________________________________________________________________________
81AliMUONPadStatusMapMaker::~AliMUONPadStatusMapMaker()
82{
83 /// dtor
2c780493 84}
85
86//_____________________________________________________________________________
87Int_t
5eeebd4b 88AliMUONPadStatusMapMaker::ComputeStatusMap(const AliMUONVCalibParam& neighbours,
89 Int_t manuChannel,
90 Int_t detElemId) const
2c780493 91{
92 /// Given a list of neighbours of one pad (which includes the pad itself)
93 /// compute the status map (aka deadmap) for that pad.
94
2c780493 95 Int_t statusMap(0);
5eeebd4b 96
97 //Compute the statusmap related to the status of neighbouring
98 //pads. An invalid pad means "outside of edges".
99
100 Int_t n = neighbours.Dimension();
101 for ( Int_t i = 0; i < n; ++i )
2c780493 102 {
5eeebd4b 103 Int_t x = neighbours.ValueAsInt(manuChannel,i);
104 Int_t m,c;
105 neighbours.UnpackValue(x,m,c);
106 if ( c < 0 ) continue;
2c780493 107 Int_t status = 0;
5eeebd4b 108 if ( !m )
2c780493 109 {
110 status = -1;
111 }
112 else
113 {
5eeebd4b 114 status = GetPadStatus(detElemId,m,c);
2c780493 115 }
116 if ( ( fMask==0 && status !=0 ) || ( (status & fMask) != 0 ) )
117 {
118 statusMap |= (1<<i);
119 }
2c780493 120 }
2c780493 121 return statusMap;
122}
123
124//_____________________________________________________________________________
125Int_t
5eeebd4b 126AliMUONPadStatusMapMaker::GetPadStatus(Int_t detElemId,
127 Int_t manuId, Int_t manuChannel) const
128
2c780493 129{
130 /// Get the pad status
2c780493 131 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->Get(detElemId,manuId));
132 return param->ValueAsInt(manuChannel);
133}
134
2c780493 135//_____________________________________________________________________________
4f8ed2e4 136AliMUONV2DStore*
137AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap()
138{
9f37150e 139 /// Make an empty (but complete) statusMap
4f8ed2e4 140
5eeebd4b 141 AliMUONCalibParamNI param(1,64,0);
4f8ed2e4 142
9f37150e 143 return AliMUON2DMap::Generate(param);
4f8ed2e4 144}
145
146//_____________________________________________________________________________
2c780493 147AliMUONV2DStore*
148AliMUONPadStatusMapMaker::MakePadStatusMap(const AliMUONV2DStore& status,
149 Int_t mask)
150{
151 /// Given the status store for all pads, compute a status map store
152 /// for all pads.
78649106 153 /// \param status
154 /// \param mask is the status mask to be tested to tell if a pad is ok or not
2c780493 155
156 fStatus = &status;
157 fMask = mask;
158
5eeebd4b 159 TStopwatch timer;
2c780493 160 timer.Start(kTRUE);
161
5eeebd4b 162 AliMUONV2DStore* neighbourStore = fCalibrationData.Neighbours();
163
2c780493 164 AliMUONV2DStore* statusMap = status.CloneEmpty();
165
166 AliMUONVDataIterator* it = status.Iterator();
167 AliMUONObjectPair* pair;
168
169 while ( ( pair = static_cast<AliMUONObjectPair*>(it->Next()) ) )
170 {
171 AliMpIntPair* ip = static_cast<AliMpIntPair*>(pair->First());
172
5eeebd4b 173 Int_t detElemId = ip->GetFirst();
2c780493 174 Int_t manuId = ip->GetSecond();
5eeebd4b 175
2c780493 176 AliMUONVCalibParam* statusEntry = static_cast<AliMUONVCalibParam*>(pair->Second());
177
178 AliMUONVCalibParam* statusMapEntry = static_cast<AliMUONVCalibParam*>
179 (statusMap->Get(detElemId,manuId));
180
181 if (!statusMapEntry)
182 {
5eeebd4b 183 statusMapEntry = new AliMUONCalibParamNI(1,64,0);
2c780493 184 statusMap->Set(detElemId,manuId,statusMapEntry,false);
185 }
186
5eeebd4b 187 AliMUONVCalibParam* neighbours = static_cast<AliMUONVCalibParam*>
188 (neighbourStore->Get(detElemId,manuId));
189
190 if (!neighbours)
191 {
192 AliFatal(Form("Could not find neighbours for DE %d manuId %d",
193 detElemId,manuId));
194 continue;
195 }
196
2c780493 197 for ( Int_t manuChannel = 0; manuChannel < statusEntry->Size(); ++manuChannel )
198 {
199 // Loop over channels and for each channel loop on its immediate neighbours
200 // to produce a statusMap word for this channel.
201
2c780493 202 Int_t statusMapValue(0);
5eeebd4b 203
204 Int_t x = neighbours->ValueAsInt(manuChannel,0);
2c780493 205
5eeebd4b 206 if ( x > 0 )
207 { // channel is a valid one (i.e. (manuId,manuChannel) is an existing pad)
208 // assert(x>=0);
209 statusMapValue = ComputeStatusMap(*neighbours,manuChannel,detElemId);
2c780493 210 }
211 else
212 {
213 statusMapValue = fgkSelfDead;
214 }
5eeebd4b 215
2c780493 216 statusMapEntry->SetValueAsInt(manuChannel,0,statusMapValue);
217 }
5eeebd4b 218
219 if (it->IsOwner()) delete pair;
2c780493 220 }
221
222 delete it;
2c780493 223
5eeebd4b 224 timer.Stop();
2c780493 225
5eeebd4b 226 StdoutToAliInfo(
227 cout << "MakePadStatusMap total timer : ";
228 timer.Print();
229 cout << endl;
230 );
231
2c780493 232 return statusMap;
233}
234